28
28
extern FreeDVInterface freedvInterface;
29
29
30
30
#define UNKNOWN_STR " --"
31
+ #if defined(WIN32)
32
+ #define NUM_COLS (14 ) /* Note: need empty column 0 to work around callsign truncation issue. */
33
+ #else
31
34
#define NUM_COLS (13 )
35
+ #endif // defined(WIN32)
32
36
#define RX_ONLY_STATUS " RX Only"
33
37
#define RX_COLORING_TIMEOUT_SEC (20 )
34
38
#define MSG_COLORING_TIMEOUT_SEC (5 )
@@ -59,24 +63,33 @@ FreeDVReporterDialog::FreeDVReporterDialog(wxWindow* parent, wxWindowID id, cons
59
63
60
64
// Main list box
61
65
// =============================
66
+ int col = 0 ;
62
67
m_listSpots = new wxListView (this , wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_SINGLE_SEL | wxLC_REPORT | wxLC_HRULES);
63
- m_listSpots->InsertColumn (0 , wxT (" Callsign" ), wxLIST_FORMAT_CENTER, 80 );
64
- m_listSpots->InsertColumn (1 , wxT (" Locator" ), wxLIST_FORMAT_CENTER, 80 );
65
- m_listSpots->InsertColumn (2 , wxT (" KM" ), wxLIST_FORMAT_CENTER, 80 );
66
- m_listSpots->InsertColumn (3 , wxT (" Version" ), wxLIST_FORMAT_CENTER, 80 );
67
- m_listSpots->InsertColumn (4 , wxGetApp ().appConfiguration .reportingConfiguration .reportingFrequencyAsKhz ? wxT (" KHz" ) : wxT (" MHz" ), wxLIST_FORMAT_CENTER, 80 );
68
- m_listSpots->InsertColumn (5 , wxT (" Status" ), wxLIST_FORMAT_CENTER, 80 );
69
- m_listSpots->InsertColumn (6 , wxT (" Msg" ), wxLIST_FORMAT_CENTER, 20 );
70
- m_listSpots->InsertColumn (7 , wxT (" Last TX" ), wxLIST_FORMAT_CENTER, 80 );
71
- m_listSpots->InsertColumn (8 , wxT (" Mode" ), wxLIST_FORMAT_CENTER, 80 );
72
- m_listSpots->InsertColumn (9 , wxT (" RX Call" ), wxLIST_FORMAT_CENTER, 120 );
73
- m_listSpots->InsertColumn (10 , wxT (" Mode" ), wxLIST_FORMAT_CENTER, 120 );
74
- m_listSpots->InsertColumn (11 , wxT (" SNR" ), wxLIST_FORMAT_CENTER, 40 );
75
- m_listSpots->InsertColumn (12 , wxT (" Last Update" ), wxLIST_FORMAT_CENTER, 120 );
68
+
69
+ #if defined(WIN32)
70
+ // Create "hidden" column at the beginning. The column logic in wxWidgets
71
+ // seems to want to add an image to column 0, which affects
72
+ // autosizing.
73
+ m_listSpots->InsertColumn (col++, wxT (" " ), wxLIST_FORMAT_CENTER, 1 );
74
+ #endif // defined(WIN32)
75
+
76
+ m_listSpots->InsertColumn (col++, wxT (" Callsign" ), wxLIST_FORMAT_CENTER, 80 );
77
+ m_listSpots->InsertColumn (col++, wxT (" Locator" ), wxLIST_FORMAT_CENTER, 80 );
78
+ m_listSpots->InsertColumn (col++, wxT (" KM" ), wxLIST_FORMAT_CENTER, 80 );
79
+ m_listSpots->InsertColumn (col++, wxT (" Version" ), wxLIST_FORMAT_CENTER, 80 );
80
+ m_listSpots->InsertColumn (col++, wxGetApp ().appConfiguration .reportingConfiguration .reportingFrequencyAsKhz ? wxT (" KHz" ) : wxT (" MHz" ), wxLIST_FORMAT_CENTER, 80 );
81
+ m_listSpots->InsertColumn (col++, wxT (" Status" ), wxLIST_FORMAT_CENTER, 80 );
82
+ m_listSpots->InsertColumn (col++, wxT (" Msg" ), wxLIST_FORMAT_CENTER, 20 );
83
+ m_listSpots->InsertColumn (col++, wxT (" Last TX" ), wxLIST_FORMAT_CENTER, 80 );
84
+ m_listSpots->InsertColumn (col++, wxT (" Mode" ), wxLIST_FORMAT_CENTER, 80 );
85
+ m_listSpots->InsertColumn (col++, wxT (" RX Call" ), wxLIST_FORMAT_CENTER, 120 );
86
+ m_listSpots->InsertColumn (col++, wxT (" Mode" ), wxLIST_FORMAT_CENTER, 120 );
87
+ m_listSpots->InsertColumn (col++, wxT (" SNR" ), wxLIST_FORMAT_CENTER, 40 );
88
+ m_listSpots->InsertColumn (col++, wxT (" Last Update" ), wxLIST_FORMAT_CENTER, 120 );
76
89
77
90
// On Windows, the last column will end up taking a lot more space than desired regardless
78
91
// of the space we actually need. Create a "dummy" column to take that space instead.
79
- m_listSpots->InsertColumn (13 , wxT (" " ), wxLIST_FORMAT_CENTER, 1 );
92
+ m_listSpots->InsertColumn (col++ , wxT (" " ), wxLIST_FORMAT_CENTER, 1 );
80
93
81
94
sectionSizer->Add (m_listSpots, 0 , wxALL | wxEXPAND, 2 );
82
95
@@ -275,8 +288,15 @@ FreeDVReporterDialog::~FreeDVReporterDialog()
275
288
276
289
void FreeDVReporterDialog::refreshLayout ()
277
290
{
291
+ int colOffset = 0 ;
292
+
293
+ #if defined(WIN32)
294
+ // Column 0 is hidden, so everything is shifted by 1 column.
295
+ colOffset++;
296
+ #endif // defined(WIN32)
297
+
278
298
wxListItem item;
279
- m_listSpots->GetColumn (2 , item);
299
+ m_listSpots->GetColumn (2 + colOffset , item);
280
300
281
301
if (wxGetApp ().appConfiguration .reportingConfiguration .useMetricDistances )
282
302
{
@@ -287,10 +307,10 @@ void FreeDVReporterDialog::refreshLayout()
287
307
item.SetText (" Miles" );
288
308
}
289
309
290
- m_listSpots->SetColumn (2 , item);
310
+ m_listSpots->SetColumn (2 + colOffset , item);
291
311
292
312
// Refresh frequency units as appropriate.
293
- m_listSpots->GetColumn (4 , item);
313
+ m_listSpots->GetColumn (4 + colOffset , item);
294
314
if (wxGetApp ().appConfiguration .reportingConfiguration .reportingFrequencyAsKhz )
295
315
{
296
316
item.SetText (" KHz" );
@@ -299,7 +319,7 @@ void FreeDVReporterDialog::refreshLayout()
299
319
{
300
320
item.SetText (" MHz" );
301
321
}
302
- m_listSpots->SetColumn (4 , item);
322
+ m_listSpots->SetColumn (4 + colOffset , item);
303
323
304
324
std::map<int , int > colResizeList;
305
325
for (auto & kvp : allReporterData_)
@@ -451,6 +471,15 @@ void FreeDVReporterDialog::OnSortColumn(wxListEvent& event)
451
471
{
452
472
int col = event.GetColumn ();
453
473
474
+ #if defined(WIN32)
475
+ // The "hidden" column 0 is new as of 1.9.7. Automatically
476
+ // assume the user is sorting by callsign.
477
+ if (col == 0 )
478
+ {
479
+ col = 1 ;
480
+ }
481
+ #endif // defined(WIN32)
482
+
454
483
if (col > 12 )
455
484
{
456
485
// Don't allow sorting by "fake" columns.
@@ -704,6 +733,15 @@ void FreeDVReporterDialog::sortColumn_(int col)
704
733
705
734
void FreeDVReporterDialog::sortColumn_ (int col, bool direction)
706
735
{
736
+ #if defined(WIN32)
737
+ // The hidden column 0 is new in 1.9.7. Assume sort by the "old" column 0
738
+ // (callsign).
739
+ if (col == 0 )
740
+ {
741
+ col = 1 ;
742
+ }
743
+ #endif // defined(WIN32)
744
+
707
745
if (currentSortColumn_ != -1 )
708
746
{
709
747
m_listSpots->ClearColumnImage (currentSortColumn_);
@@ -745,6 +783,14 @@ void FreeDVReporterDialog::clearAllEntries_(bool clearForAllBands)
745
783
// Reset lengths to force auto-resize on (re)connect.
746
784
for (int col = 0 ; col < NUM_COLS; col++)
747
785
{
786
+ #if defined(WIN32)
787
+ // First column is hidden, so don't auto-size.
788
+ if (col == 0 )
789
+ {
790
+ continue ;
791
+ }
792
+ #endif // defined(WIN32)
793
+
748
794
columnLengths_[col] = 0 ;
749
795
m_listSpots->SetColumnWidth (col, wxLIST_AUTOSIZE_USEHEADER);
750
796
}
@@ -1315,6 +1361,14 @@ void FreeDVReporterDialog::resizeChangedColumns_(std::map<int, int>& colResizeLi
1315
1361
{
1316
1362
for (auto & kvp : colResizeList)
1317
1363
{
1364
+ #if defined(WIN32)
1365
+ // The first column on Windows is hidden, so don't resize.
1366
+ if (kvp.first == 0 )
1367
+ {
1368
+ continue ;
1369
+ }
1370
+ #endif // defined(WIN32)
1371
+
1318
1372
m_listSpots->SetColumnWidth (kvp.first , wxLIST_AUTOSIZE_USEHEADER);
1319
1373
}
1320
1374
@@ -1360,40 +1414,62 @@ void FreeDVReporterDialog::addOrUpdateListIfNotFiltered_(ReporterData* data, std
1360
1414
}
1361
1415
else if (itemIndex == -1 && !filtered)
1362
1416
{
1363
- itemIndex = m_listSpots->InsertItem (m_listSpots->GetItemCount (), data-> callsign );
1417
+ itemIndex = m_listSpots->InsertItem (m_listSpots->GetItemCount (), _ ( " " ) );
1364
1418
m_listSpots->SetItemPtrData (itemIndex, (wxUIntPtr)new std::string (data->sid ));
1365
- needResort = currentSortColumn_ == 0 ;
1366
1419
}
1367
1420
else if (filtered)
1368
1421
{
1369
1422
// Don't add for now as it's not supposed to display.
1370
1423
return ;
1371
1424
}
1372
1425
1373
- bool changed = setColumnForRow_ (itemIndex, 1 , data->gridSquare , colResizeList);
1374
- needResort |= changed && currentSortColumn_ == 1 ;
1375
- changed = setColumnForRow_ (itemIndex, 2 , data->distance , colResizeList);
1376
- needResort |= changed && currentSortColumn_ == 2 ;
1377
- changed = setColumnForRow_ (itemIndex, 3 , data->version , colResizeList);
1378
- needResort |= changed && currentSortColumn_ == 3 ;
1379
- changed = setColumnForRow_ (itemIndex, 4 , data->freqString , colResizeList);
1380
- needResort |= changed && currentSortColumn_ == 4 ;
1381
- changed = setColumnForRow_ (itemIndex, 5 , data->status , colResizeList);
1382
- needResort |= changed && currentSortColumn_ == 5 ;
1383
- changed = setColumnForRow_ (itemIndex, 6 , data->userMessage , colResizeList);
1384
- needResort |= changed && currentSortColumn_ == 6 ;
1385
- changed = setColumnForRow_ (itemIndex, 7 , data->lastTx , colResizeList);
1386
- needResort |= changed && currentSortColumn_ == 7 ;
1387
- changed = setColumnForRow_ (itemIndex, 8 , data->txMode , colResizeList);
1388
- needResort |= changed && currentSortColumn_ == 8 ;
1389
- changed = setColumnForRow_ (itemIndex, 9 , data->lastRxCallsign , colResizeList);
1390
- needResort |= changed && currentSortColumn_ == 9 ;
1391
- changed = setColumnForRow_ (itemIndex, 10 , data->lastRxMode , colResizeList);
1392
- needResort |= changed && currentSortColumn_ == 10 ;
1393
- changed = setColumnForRow_ (itemIndex, 11 , data->snr , colResizeList);
1394
- needResort |= changed && currentSortColumn_ == 11 ;
1395
- changed = setColumnForRow_ (itemIndex, 12 , data->lastUpdate , colResizeList);
1396
- needResort |= changed && currentSortColumn_ == 12 ;
1426
+ int col = 0 ;
1427
+ #if defined(WIN32)
1428
+ // Column 0 is "hidden" to avoid column autosize issue. Callsign should be in column 1 instead.
1429
+ // Also, clear the item image for good measure as wxWidgets for Windows will set one for some
1430
+ // reason.
1431
+ m_listSpots->SetItemColumnImage (itemIndex, 0 , -1 );
1432
+ col = 1 ;
1433
+ #endif // defined(WIN32)
1434
+
1435
+ bool changed = setColumnForRow_ (itemIndex, col++, data->callsign , colResizeList);
1436
+ needResort |= changed && currentSortColumn_ == (col - 1 );
1437
+
1438
+ changed = setColumnForRow_ (itemIndex, col++, data->gridSquare , colResizeList);
1439
+ needResort |= changed && currentSortColumn_ == (col - 1 );
1440
+
1441
+ changed = setColumnForRow_ (itemIndex, col++, data->distance , colResizeList);
1442
+ needResort |= changed && currentSortColumn_ == (col - 1 );
1443
+
1444
+ changed = setColumnForRow_ (itemIndex, col++, data->version , colResizeList);
1445
+ needResort |= changed && currentSortColumn_ == (col - 1 );
1446
+
1447
+ changed = setColumnForRow_ (itemIndex, col++, data->freqString , colResizeList);
1448
+ needResort |= changed && currentSortColumn_ == (col - 1 );
1449
+
1450
+ changed = setColumnForRow_ (itemIndex, col++, data->status , colResizeList);
1451
+ needResort |= changed && currentSortColumn_ == (col - 1 );
1452
+
1453
+ changed = setColumnForRow_ (itemIndex, col++, data->userMessage , colResizeList);
1454
+ needResort |= changed && currentSortColumn_ == (col - 1 );
1455
+
1456
+ changed = setColumnForRow_ (itemIndex, col++, data->lastTx , colResizeList);
1457
+ needResort |= changed && currentSortColumn_ == (col - 1 );
1458
+
1459
+ changed = setColumnForRow_ (itemIndex, col++, data->txMode , colResizeList);
1460
+ needResort |= changed && currentSortColumn_ == (col - 1 );
1461
+
1462
+ changed = setColumnForRow_ (itemIndex, col++, data->lastRxCallsign , colResizeList);
1463
+ needResort |= changed && currentSortColumn_ == (col - 1 );
1464
+
1465
+ changed = setColumnForRow_ (itemIndex, col++, data->lastRxMode , colResizeList);
1466
+ needResort |= changed && currentSortColumn_ == (col - 1 );
1467
+
1468
+ changed = setColumnForRow_ (itemIndex, col++, data->snr , colResizeList);
1469
+ needResort |= changed && currentSortColumn_ == (col - 1 );
1470
+
1471
+ changed = setColumnForRow_ (itemIndex, col++, data->lastUpdate , colResizeList);
1472
+ needResort |= changed && currentSortColumn_ == (col - 1 );
1397
1473
1398
1474
// Messaging updates take highest priority.
1399
1475
auto curDate = wxDateTime::Now ().ToUTC ();
0 commit comments