1 // ----------------------------------------------------------------------------
2 //
3 //	fl_digi.cxx
4 //
5 // Copyright (C) 2006-2021
6 //		Dave Freese, W1HKJ
7 // Copyright (C) 2007-2010
8 //		Stelios Bounanos, M0GLD
9 // Copyright (C) 2020-2021
10 //		John Phelps, KL4YFD
11 //
12 // This file is part of fldigi.
13 //
14 // Fldigi is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 // Fldigi is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with fldigi.  If not, see <http://www.gnu.org/licenses/>.
26 // ----------------------------------------------------------------------------
27 
28 #include <config.h>
29 
30 #include <sys/types.h>
31 
32 #ifdef __WOE32__
33 #  ifdef __CYGWIN__
34 #    include <w32api/windows.h>
35 #  else
36 #    include <windows.h>
37 #  endif
38 #endif
39 
40 #include <cstdlib>
41 #include <cstdarg>
42 #include <string>
43 #include <fstream>
44 #include <algorithm>
45 #include <map>
46 
47 #ifndef __WOE32__
48 #include <sys/wait.h>
49 #endif
50 
51 //++++++++++++++++++
52 #include <FL/Fl_Scroll.H>
53 extern Fl_Scroll       *wefax_pic_rx_scroll;
54 
55 
56 #include "gettext.h"
57 #include "fl_digi.h"
58 
59 #include <FL/Fl.H>
60 #include <FL/fl_ask.H>
61 #include <FL/Fl_Pixmap.H>
62 #include <FL/Fl_Image.H>
63 //#include <FL/Fl_Tile.H>
64 #include <FL/x.H>
65 #include <FL/Fl_Help_Dialog.H>
66 #include <FL/Fl_Progress.H>
67 #include <FL/Fl_Tooltip.H>
68 #include <FL/Fl_Tabs.H>
69 #include <FL/Fl_Multiline_Input.H>
70 #include <FL/Fl_Menu_Bar.H>
71 #include <FL/Fl_Pack.H>
72 
73 #include "waterfall.h"
74 #include "raster.h"
75 #include "progress.h"
76 #include "Panel.h"
77 
78 #include "main.h"
79 #include "threads.h"
80 #include "trx.h"
81 #if USE_HAMLIB
82 	#include "hamlib.h"
83 #endif
84 #include "timeops.h"
85 #include "rigio.h"
86 #include "nullmodem.h"
87 #include "psk.h"
88 #include "cw.h"
89 #include "mfsk.h"
90 #include "wefax.h"
91 #include "wefax-pic.h"
92 #include "navtex.h"
93 #include "mt63.h"
94 #include "view_rtty.h"
95 #include "olivia.h"
96 #include "contestia.h"
97 #include "thor.h"
98 #include "dominoex.h"
99 #include "feld.h"
100 #include "throb.h"
101 //#include "pkt.h"
102 #include "fsq.h"
103 #include "ifkp.h"
104 #include "wwv.h"
105 #include "analysis.h"
106 #include "ssb.h"
107 
108 #include "fmt.h"
109 #include "fmt_dialog.h"
110 
111 #include "fileselect.h"
112 
113 #include "smeter.h"
114 #include "pwrmeter.h"
115 
116 #include "ascii.h"
117 #include "globals.h"
118 #include "misc.h"
119 #include "FTextRXTX.h"
120 
121 #include "confdialog.h"
122 #include "configuration.h"
123 #include "status.h"
124 
125 #include "macros.h"
126 #include "macroedit.h"
127 #include "logger.h"
128 #include "lookupcall.h"
129 #include "fd_logger.h"
130 #include "fd_view.h"
131 
132 #include "font_browser.h"
133 
134 #include "icons.h"
135 #include "pixmaps.h"
136 
137 #include "rigsupport.h"
138 
139 #include "logsupport.h"
140 
141 #include "qrunner.h"
142 
143 #include "Viewer.h"
144 #include "soundconf.h"
145 
146 #include "htmlstrings.h"
147 #	include "xmlrpc.h"
148 #if BENCHMARK_MODE
149 #	include "benchmark.h"
150 #endif
151 
152 #include "debug.h"
153 #include "re.h"
154 #include "network.h"
155 #include "spot.h"
156 #include "dxcc.h"
157 #include "locator.h"
158 #include "notify.h"
159 #include "strutil.h"
160 
161 #include "test_signal.h"
162 
163 #include "logbook.h"
164 
165 #include "rx_extract.h"
166 #include "speak.h"
167 #include "flmisc.h"
168 
169 #include "arq_io.h"
170 #include "data_io.h"
171 #include "kmlserver.h"
172 #include "psm/psm.h"
173 #include "n3fjp_logger.h"
174 
175 #include "dx_cluster.h"
176 #include "dx_dialog.h"
177 
178 #include "notifydialog.h"
179 #include "macroedit.h"
180 #include "rx_extract.h"
181 #include "wefax-pic.h"
182 #include "charsetdistiller.h"
183 #include "charsetlist.h"
184 #include "outputencoder.h"
185 #include "record_loader.h"
186 #include "record_browse.h"
187 
188 #include "winkeyer.h"
189 #include "nanoIO.h"
190 
191 #include "audio_alert.h"
192 
193 #include "spectrum_viewer.h"
194 
195 #include "contest.h"
196 
197 #include "tabdefs.h"
198 
199 #define CB_WHEN FL_WHEN_CHANGED | FL_WHEN_NOT_CHANGED | FL_WHEN_ENTER_KEY_ALWAYS | FL_WHEN_RELEASE_ALWAYS
200 
201 #define LOG_TO_FILE_MLABEL     _("Log all RX/TX text")
202 #define RIGCONTROL_MLABEL      TAB_RIG_CONTROL
203 #define OPMODES_MLABEL         _("Op &Mode")
204 #define OPMODES_FEWER          _("Show fewer modes")
205 #define OPMODES_ALL            _("Show all modes")
206 #define OLIVIA_MLABEL            "Olivia"
207 #define CONTESTIA_MLABEL         "Contestia"
208 #define RTTY_MLABEL              "RTTY"
209 #define VIEW_MLABEL            _("&View")
210 #define MFSK_IMAGE_MLABEL      _("MFSK Image")
211 #define THOR_IMAGE_MLABEL      _("THOR Raw Image")
212 #define IFKP_IMAGE_MLABEL      _("IFKP Raw Image")
213 #define WEFAX_TX_IMAGE_MLABEL  _("Weather Fax Image TX")
214 #define CONTEST_MLABEL         _("Contest")
215 #define COUNTRIES_MLABEL       _("C&ountries")
216 #define UI_MLABEL              _("&UI")
217 #define RIGLOG_FULL_MLABEL     _("Full")
218 #define RIGLOG_PARTIAL_MLABEL  _("Partial")
219 #define RIGLOG_NONE_MLABEL     _("None")
220 #define DOCKEDSCOPE_MLABEL     _("Docked scope")
221 #define WF_MLABEL              _("Minimal controls")
222 #define SHOW_CHANNELS          _("Show channels")
223 
224 #define LOG_CONNECT_SERVER     _("Connect to server")
225 
226 // MAXIMUM allowable string lengths in log fields
227 #define MAX_FREQ 14
228 #define MAX_TIME 4
229 #define MAX_RST 3
230 #define MAX_CALL 30
231 #define MAX_NAME 30
232 #define MAX_AZ 3
233 #define MAX_QTH 50
234 #define MAX_STATE 2
235 #define MAX_LOC 8
236 #define MAX_SERNO 10
237 #define MAX_XCHG_IN 50
238 #define MAX_COUNTRY 50
239 #define MAX_COUNTY 100
240 #define MAX_NOTES 400
241 #define MAX_SECTION 20
242 #define MAX_CLASS   10
243 
244 using namespace std;
245 
246 void set599();
247 
248 //regular expression parser using by mainViewer (pskbrowser)
249 fre_t seek_re("CQ", REG_EXTENDED | REG_ICASE | REG_NOSUB);
250 
251 bool bWF_only = false;
252 
253 Fl_Double_Window	*fl_digi_main				= (Fl_Double_Window *)0;
254 Fl_Double_Window	*scopeview					= (Fl_Double_Window *)0;
255 Fl_Double_Window	*field_day_viewer			= (Fl_Double_Window *)0;
256 Fl_Double_Window	*dxcluster_viewer			= (Fl_Double_Window *)0;
257 Fl_Double_Window	*rxaudio_dialog				= (Fl_Double_Window *)0;
258 
259 Fl_Help_Dialog 		*help_dialog       = (Fl_Help_Dialog *)0;
260 
261 Fl_Button			*btnDockMacro[48];
262 
263 static Fl_Group		*mnuFrame;
264 Fl_Menu_Bar 		*mnu;
265 
266 Fl_Box				*tx_timer = (Fl_Box *)0;
267 Fl_Light_Button		*btnAutoSpot = (Fl_Light_Button *)0;
268 Fl_Light_Button		*btnTune = (Fl_Light_Button *)0;
269 Fl_Light_Button		*btnRSID = (Fl_Light_Button *)0;
270 Fl_Light_Button		*btnTxRSID = (Fl_Light_Button *)0;
271 Fl_Button			*btnMacroTimer = (Fl_Button *)0;
272 
273 Fl_Group			*center_group = (Fl_Group *)0;
274 Fl_Group			*text_group;
275 Fl_Group			*wefax_group = 0;
276 Fl_Group			*mvgroup = 0;
277 
278 Panel				*text_panel = 0;
279 
280 //------------------------------------------------------------------------------
281 // groups and widgets used exclusively for FSQCALL
282 
283 Fl_Group			*fsq_group = 0;
284 Fl_Group			*fsq_upper = 0;
285 Fl_Group			*fsq_lower = 0;
286 Fl_Group			*fsq_upper_left = 0;
287 Fl_Group			*fsq_upper_right = 0;
288 Fl_Group			*fsq_lower_left = 0;
289 Fl_Group			*fsq_lower_right = 0;
290 
291 Panel				*fsq_left = (Panel *)0;
292 Fl_Box				*fsq_minbox = (Fl_Box *)0;
293 FTextRX				*fsq_rx_text = (FTextRX *)0;
294 FTextTX				*fsq_tx_text = (FTextTX *)0;
295 Fl_Browser			*fsq_heard = (Fl_Browser *)0;
296 
297 Fl_Light_Button		*btn_FSQCALL = (Fl_Light_Button *)0;
298 Fl_Light_Button		*btn_SELCAL = (Fl_Light_Button *)0;
299 Fl_Light_Button		*btn_MONITOR = (Fl_Light_Button *)0;
300 Fl_Button			*btn_FSQQTH = (Fl_Button *)0;
301 Fl_Button			*btn_FSQQTC = (Fl_Button *)0;
302 Fl_Button			*btn_FSQCQ = (Fl_Button *)0;
303 Progress			*ind_fsq_speed = (Progress *)0;
304 Progress			*ind_fsq_s2n = (Progress *)0;
305 
306 //------------------------------------------------------------------------------
307 // groups and widgets used exclusively for IFKP
308 Fl_Group		*ifkp_group = (Fl_Group *)0;
309 Fl_Box			*ifkp_minbox = (Fl_Box *)0;
310 Fl_Group		*ifkp_left = (Fl_Group *)0;
311 FTextRX			*ifkp_rx_text = (FTextRX *)0;
312 FTextTX			*ifkp_tx_text = (FTextTX *)0;
313 Fl_Group		*ifkp_right = (Fl_Group *)0;
314 Fl_Browser		*ifkp_heard = (Fl_Browser *)0;
315 Progress		*ifkp_s2n_progress = (Progress *)0;
316 picture			*ifkp_avatar = (picture *)0;
317 
318 //----------------------------------------------------------------------
319 // FMT group
320 Fl_Group		*fmt_group = (Fl_Group *)0;
321 
322 //------------------------------------------------------------------------------
323 // thor avatar
324 picture			*thor_avatar = (picture *)0;
325 
326 //------------------------------------------------------------------------------
327 
328 Fl_Group			*macroFrame1 = (Fl_Group *)0;
329 Fl_Group			*macroFrame2 = (Fl_Group *)0;
330 Fl_Group			*mf_group1 = (Fl_Group *)0;
331 Fl_Group			*mf_group2 = (Fl_Group *)0;
332 Fl_Group			*tbar = (Fl_Group *)0;
333 
334 FTextRX				*ReceiveText = 0;
335 FTextTX				*TransmitText = 0;
336 Raster				*FHdisp;
337 Fl_Box				*minbox;
338 int					oix;
339 
340 pskBrowser			*mainViewer = (pskBrowser *)0;
341 Fl_Input2			*txtInpSeek = (Fl_Input2 *)0;
342 
343 status_box			*StatusBar = (status_box *)0;
344 Fl_Box				*Status2 = (Fl_Box *)0;
345 Fl_Box				*Status1 = (Fl_Box *)0;
346 Fl_Counter2			*cntTxLevel = (Fl_Counter2 *)0;
347 Fl_Counter2			*cntCW_WPM=(Fl_Counter2 *)0;
348 Fl_Button			*btnCW_Default=(Fl_Button *)0;
349 Fl_Box				*WARNstatus = (Fl_Box *)0;
350 Fl_Button			*MODEstatus = (Fl_Button *)0;
351 Fl_Button 			*btnMacro[NUMMACKEYS * NUMKEYROWS];
352 Fl_Button			*btnAltMacros1 = (Fl_Button *)0;
353 Fl_Button			*btnAltMacros2 = (Fl_Button *)0;
354 Fl_Light_Button		*btnAFC = (Fl_Light_Button *)0;
355 Fl_Light_Button		*btnSQL = (Fl_Light_Button *)0;
356 Fl_Light_Button		*btnPSQL = (Fl_Light_Button *)0;
357 Fl_Box				*corner_box = (Fl_Box *)0;
358 
359 vumeter				*VuMeter = (vumeter *)0;
360 Fl_Box				*VuBox   = (Fl_Box *)0;
361 
362 Fl_Group			*RigControlFrame = (Fl_Group *)0;
363 Fl_Group			*RigViewerFrame = (Fl_Group *)0;
364 
365 cFreqControl 		*qsoFreqDisp = (cFreqControl *)0;
366 Fl_Group			*qso_combos = (Fl_Group *)0;
367 Fl_ListBox			*qso_opMODE = (Fl_ListBox *)0;
368 Fl_Group			*qso_opGROUP = (Fl_Group *)0;
369 Fl_ListBox			*qso_opBW = (Fl_ListBox *)0;
370 Fl_Button			*qso_btnBW1 = (Fl_Button *)0;
371 Fl_ListBox			*qso_opBW1 = (Fl_ListBox *)0;
372 Fl_Button			*qso_btnBW2 = (Fl_Button *)0;
373 Fl_ListBox			*qso_opBW2 = (Fl_ListBox *)0;
374 Fl_Button			*qso_opPICK = (Fl_Button *)0;
375 
376 Fl_Button			*qsoClear;
377 Fl_Button			*qsoSave;
378 
379 Fl_Input2			*inpFreq = (Fl_Input2 *)0;
380 Fl_Input2			*inpTimeOff = (Fl_Input2 *)0;
381 Fl_Input2			*inpTimeOn = (Fl_Input2 *)0;
382 Fl_Button			*btnTimeOn;
383 Fl_Input2			*inpCall = (Fl_Input2 *)0;
384 Fl_Input2			*inpName = (Fl_Input2 *)0;
385 Fl_Input2			*inpRstIn = (Fl_Input2 *)0;
386 Fl_Input2			*inpRstOut = (Fl_Input2 *)0;
387 Fl_Input2			*inpQTH = (Fl_Input2 *)0;
388 Fl_Input2			*inpQth = (Fl_Input2 *)0;
389 Fl_Input2			*inpLoc = (Fl_Input2 *)0;
390 Fl_Input2			*inpState = (Fl_Input2 *)0;
391 
392 Fl_Input2			*inpCounty = (Fl_Input2 *)0;
393 
394 Fl_ComboBox			*cboCountyQSO = (Fl_ComboBox *)0;
395 
396 Fl_ComboBox			*cboCountry = (Fl_ComboBox *)0;
397 Fl_ComboBox			*cboCountryQSO = (Fl_ComboBox *)0;
398 Fl_ComboBox			*cboCountryAICW2 = (Fl_ComboBox *)0;
399 Fl_ComboBox			*cboCountryAIDX = (Fl_ComboBox *)0;
400 Fl_ComboBox			*cboCountryWAE2 = (Fl_ComboBox *)0;
401 Fl_ComboBox			*cboCountryAIDX2 = (Fl_ComboBox *)0;
402 Fl_ComboBox			*cboCountryRTU2 = (Fl_ComboBox *)0;
403 
404 Fl_Input2			*inpSerNo = (Fl_Input2 *)0;
405 Fl_Input2			*outSerNo = (Fl_Input2 *)0;
406 Fl_Input2			*inpXchgIn = (Fl_Input2 *)0;
407 // Field Day fields
408 Fl_Input2			*inpClass = (Fl_Input2 *)0;
409 Fl_Input2			*inpSection = (Fl_Input2 *)0;
410 // CQWW fields
411 Fl_Input2			*inp_CQzone = (Fl_Input2 *)0;
412 Fl_Input2			*inp_CQstate = (Fl_Input2 *)0;
413 // Kids Day fields
414 Fl_Input2			*inp_KD_age = (Fl_Input2 *)0;
415 
416 Fl_Input2			*inpVEprov = (Fl_Input2 *)0;
417 Fl_Input2			*inpNotes = (Fl_Input2 *)0;
418 Fl_Input2			*inpAZ = (Fl_Input2 *)0;
419 
420 
421 Fl_Button			*qsoTime;
422 Fl_Button			*btnQRZ;
423 //Fl_Button			*CFtoggle = (Fl_Button *)0;
424 
425 // Top Frame 1 group controls
426 Fl_Group			*Logging_frame = (Fl_Group *)0;
427 Fl_Group			*Logging_frame_1 = (Fl_Group *)0;
428 
429 Fl_Tabs				*NFtabs = (Fl_Tabs *)0;
430 Fl_Group			*gGEN_QSO_1 = (Fl_Group *)0;
431 Fl_Group			*NotesFrame = (Fl_Group *)0;
432 Fl_Group			*Ccframe = (Fl_Group *)0;
433 Fl_Group			*TopFrame1 = (Fl_Group *)0;
434 Fl_Input2			*inpFreq1 = (Fl_Input2 *)0;
435 Fl_Input2			*inpTimeOff1 = (Fl_Input2 *)0;
436 Fl_Input2			*inpTimeOn1 = (Fl_Input2 *)0;
437 Fl_Button			*btnTimeOn1;
438 Fl_Input2			*inpCall1 = (Fl_Input2 *)0;
439 Fl_Input2			*inpName1 = (Fl_Input2 *)0;
440 Fl_Input2			*inpRstIn1 = (Fl_Input2 *)0;
441 Fl_Input2			*inpRstOut1 = (Fl_Input2 *)0;
442 Fl_Input2			*inpState1 = (Fl_Input2 *)0;
443 Fl_Input2			*inpLoc1 = (Fl_Input2 *)0;
444 // Generic contest sub frame
445 Fl_Group			*gGEN_CONTEST = (Fl_Group *)0;
446 Fl_Input2			*inpXchgIn1 = (Fl_Input2 *)0;
447 Fl_Input2			*outSerNo1 = (Fl_Input2 *)0;
448 Fl_Input2			*inpSerNo1 = (Fl_Input2 *)0;
449 // FD contest sub frame
450 Fl_Group			*gFD = (Fl_Group *)0;
451 Fl_Input2			*inp_FD_class1 = (Fl_Input2 *)0;
452 Fl_Input2			*inp_FD_section1 = (Fl_Input2 *)0;
453 // Kids Day fields
454 Fl_Group			*gKD_1 = (Fl_Group *)0;
455 Fl_Input2			*inp_KD_age1 = (Fl_Input2 *)0;
456 Fl_Input2			*inp_KD_state1 = (Fl_Input2 *)0;
457 Fl_Input2			*inp_KD_VEprov1 = (Fl_Input2 *)0;
458 Fl_Input2			*inp_KD_XchgIn1 = (Fl_Input2 *)0;
459 // CQWW RTTY contest sub frame
460 Fl_Group			*gCQWW_RTTY = (Fl_Group *)0;
461 Fl_Input2			*inp_CQzone1 = (Fl_Input2 *)0;
462 Fl_Input2			*inp_CQstate1 = (Fl_Input2 *)0;
463 // CQWW DX contest sub frame
464 Fl_Group			*gCQWW_DX = (Fl_Group *)0;
465 Fl_Input2			*inp_CQDXzone1 = (Fl_Input2 *)0;
466 // CW Sweepstakes contest sub frame
467 Fl_Group			*gCWSS = (Fl_Group *)0;
468 Fl_Input2			*outSerNo3 = (Fl_Input2 *)0;
469 Fl_Input2			*inp_SS_SerialNoR = (Fl_Input2 *)0;
470 Fl_Input2			*inp_SS_Precedence = (Fl_Input2 *)0;
471 Fl_Input2			*inp_SS_Check = (Fl_Input2 *)0;
472 Fl_Input2			*inp_SS_Section = (Fl_Input2 *)0;
473 Fl_Input2			*inp_SS_SerialNoR1 = (Fl_Input2 *)0;
474 Fl_Input2			*inp_SS_Precedence1 = (Fl_Input2 *)0;
475 Fl_Input2			*inp_SS_Check1 = (Fl_Input2 *)0;
476 Fl_Input2			*inp_SS_Section1 = (Fl_Input2 *)0;
477 // 1010 contest
478 Fl_Group			*g1010 = (Fl_Group *)0;
479 Fl_Input2			*inp_1010_nr = (Fl_Input2 *)0;
480 Fl_Input2			*inp_1010_nr1 = (Fl_Input2 *)0;
481 Fl_Input2			*inp_1010_XchgIn1 = (Fl_Input2 *)0;
482 // VHF contest
483 Fl_Group			*gVHF = (Fl_Group *)0;
484 Fl_Input2			*inp_vhf_RSTin1 = (Fl_Input2 *)0;
485 Fl_Input2			*inp_vhf_RSTout1 = (Fl_Input2 *)0;
486 Fl_Input2			*inp_vhf_Loc1 = (Fl_Input2 *)0;
487 // ARRL Round Up Contest
488 Fl_Group			*gARR = (Fl_Group *)0;
489 Fl_Input2			*inp_ARR_Name2 = (Fl_Input2 *)0;
490 Fl_Input2			*inp_ARR_check = (Fl_Input2 *)0;
491 Fl_Input2			*inp_ARR_check1 = (Fl_Input2 *)0;
492 Fl_Input2			*inp_ARR_check2 = (Fl_Input2 *)0;
493 Fl_Input2			*inp_ARR_XchgIn1 = (Fl_Input2 *)0;
494 Fl_Input2			*inp_ARR_XchgIn2 = (Fl_Input2 *)0;
495 // ARRL School Roundup - LOG_ASCR
496 Fl_Group			*gASCR = (Fl_Group *)0;
497 Fl_Input2			*inp_ASCR_class1 = (Fl_Input2 *)0;
498 Fl_Input2			*inp_ASCR_XchgIn1 = (Fl_Input2 *)0;
499 // LOG_NAQP - North American QSO Party
500 Fl_Group			*gNAQP = (Fl_Group *)0;
501 Fl_Input2			*inpSPCnum = (Fl_Input2 *)0;  // same name used in N3FJP loggers
502 Fl_Input2			*inpSPCnum_NAQP1 = (Fl_Input2 *)0;
503 // LOG_ARRL_RTTY - ARRL RTTY Roundup
504 Fl_Group			*gARRL_RTTY= (Fl_Group *)0;
505 Fl_Input2			*inpRTU_stpr1 = (Fl_Input2 *)0;
506 Fl_Input2			*inpRTU_serno1 = (Fl_Input2 *)0;
507 // LOG_IARI - Italian International DX
508 Fl_Group			*gIARI = (Fl_Group *)0;
509 Fl_Input2			*inp_IARI_PR1 = (Fl_Input2 *)0;
510 Fl_Input2			*out_IARI_SerNo1 = (Fl_Input2 *)0;
511 Fl_Input2			*inp_IARI_SerNo1 = (Fl_Input2 *)0;
512 Fl_Input2			*inp_IARI_RSTin2 = (Fl_Input2 *)0;
513 Fl_Input2			*inp_IARI_RSTout2 = (Fl_Input2 *)0;
514 Fl_Input2			*out_IARI_SerNo2 = (Fl_Input2 *)0;
515 Fl_Input2			*inp_IARI_SerNo2 = (Fl_Input2 *)0;
516 Fl_Input2			*inp_IARI_PR2= (Fl_Input2 *)0;
517 Fl_ComboBox			*cboCountryIARI2 = (Fl_ComboBox *)0;
518 // LOG_NAS - North American Sprint
519 Fl_Group			*gNAS = (Fl_Group *)0;
520 Fl_Input2			*outSerNo5 = (Fl_Input2 *)0;
521 Fl_Input2			*inp_ser_NAS1 = (Fl_Input2 *)0;
522 Fl_Input2			*inpSPCnum_NAS1 = (Fl_Input2 *)0;
523 // LOG_AIDX - African All Mode
524 Fl_Group			*gAIDX = (Fl_Group *)0;
525 Fl_Input2			*outSerNo7 = (Fl_Input2 *)0;
526 Fl_Input2			*inpSerNo3 = (Fl_Input2 *)0;
527 // LOG_JOTA - Jamboree On The Air
528 Fl_Group			*gJOTA = (Fl_Group *)0;
529 Fl_Input2			*inp_JOTA_troop = (Fl_Input2 *)0;
530 Fl_Input2			*inp_JOTA_scout = (Fl_Input2 *)0;
531 Fl_Input2			*inp_JOTA_scout1 = (Fl_Input2 *)0;
532 Fl_Input2			*inp_JOTA_troop1 = (Fl_Input2 *)0;
533 Fl_Input2			*inp_JOTA_spc = (Fl_Input2 *)0;
534 Fl_Input2			*inp_JOTA_spc1 = (Fl_Input2 *)0;
535 // LOG_AICW - ARRL International DX (cw)
536 Fl_Group			*gAICW = (Fl_Group *)0;
537 Fl_Input2			*inpSPCnum_AICW1 = (Fl_Input2 *)0;
538 // LOG_SQSO
539 Fl_Group			*gSQSO = (Fl_Group *)0;
540 Fl_Input2			*inpSQSO_state1 = (Fl_Input2 *)0;
541 Fl_Input2			*inpSQSO_state2 = (Fl_Input2 *)0;
542 Fl_Input2			*inpSQSO_county1 = (Fl_Input2 *)0;
543 Fl_Input2			*inpSQSO_county2 = (Fl_Input2 *)0;
544 Fl_Input2			*inpSQSO_serno1 = (Fl_Input2 *)0;
545 Fl_Input2			*inpSQSO_serno2 = (Fl_Input2 *)0;
546 Fl_Input2			*outSQSO_serno1 = (Fl_Input2 *)0;
547 Fl_Input2			*outSQSO_serno2 = (Fl_Input2 *)0;
548 Fl_Input2			*inpRstIn_SQSO2 = (Fl_Input2 *)0;
549 Fl_Input2			*inpRstOut_SQSO2 = (Fl_Input2 *)0;
550 Fl_Input2			*inpSQSO_name2 = (Fl_Input2 *)0;
551 Fl_Input2			*inpSQSO_category = (Fl_Input2 *)0;
552 Fl_Input2			*inpSQSO_category1 = (Fl_Input2 *)0;
553 Fl_Input2			*inpSQSO_category2 = (Fl_Input2 *)0;
554 // LOG_CQ_WPX
555 Fl_Group			*gCQWPX = (Fl_Group *)0;
556 Fl_Input2			*inpSerNo_WPX1 = (Fl_Input2 *)0;
557 Fl_Input2			*inpSerNo_WPX2 = (Fl_Input2 *)0;
558 Fl_Input2			*outSerNo_WPX1 = (Fl_Input2 *)0;
559 Fl_Input2			*outSerNo_WPX2 = (Fl_Input2 *)0;
560 Fl_Input2			*inpRstIn_WPX2 = (Fl_Input2 *)0;
561 Fl_Input2			*inpRstOut_WPX2 = (Fl_Input2 *)0;
562 // LOG_WAE
563 Fl_Group			*gWAE = (Fl_Group *)0;
564 Fl_Input2			*inpSerNo_WAE1 = (Fl_Input2 *)0;
565 Fl_Input2			*inpSerNo_WAE2 = (Fl_Input2 *)0;
566 Fl_Input2			*outSerNo_WAE1 = (Fl_Input2 *)0;
567 Fl_Input2			*outSerNo_WAE2 = (Fl_Input2 *)0;
568 Fl_Input2			*inpRstIn_WAE2 = (Fl_Input2 *)0;
569 Fl_Input2			*inpRstOut_WAE2 = (Fl_Input2 *)0;
570 
571 //----------------------------------------------------------------------
572 // Single Line Rig / Logging Controls
573 cFreqControl 		*qsoFreqDisp1 = (cFreqControl *)0;
574 
575 // Top Frame 2 group controls - no contest
576 Fl_Group			*TopFrame2 = (Fl_Group *)0;
577 cFreqControl		*qsoFreqDisp2 = (cFreqControl *)0;
578 Fl_Input2	        *inpTimeOff2 = (Fl_Input2 *)0;
579 Fl_Input2			*inpTimeOn2 = (Fl_Input2 *)0;
580 Fl_Button			*btnTimeOn2;
581 Fl_Input2			*inpCall2 = (Fl_Input2 *)0;
582 Fl_Input2			*inpName2 = (Fl_Input2 *)0;
583 Fl_Input2			*inpRstIn2 = (Fl_Input2 *)0;
584 Fl_Input2			*inpRstOut2 = (Fl_Input2 *)0;
585 Fl_Button			*qso_opPICK2;
586 Fl_Button			*qsoClear2;
587 Fl_Button			*qsoSave2;
588 Fl_Button			*btnQRZ2;
589 
590 // Top Frame 3 group controls - contest
591 Fl_Group			*TopFrame3 = (Fl_Group *)0;
592 Fl_Group			*TopFrame3a = (Fl_Group *)0;
593 
594 Fl_Group		*log_generic_frame = (Fl_Group *)0;
595 Fl_Group		*log_fd_frame = (Fl_Group *)0;
596 Fl_Group		*log_kd_frame = (Fl_Group *)0;
597 Fl_Group		*log_1010_frame = (Fl_Group *)0;
598 Fl_Group		*log_arr_frame = (Fl_Group *)0;
599 Fl_Group		*log_vhf_frame = (Fl_Group *)0;
600 Fl_Group		*log_cqww_frame = (Fl_Group *)0;
601 Fl_Group		*log_cqww_rtty_frame = (Fl_Group *)0;
602 Fl_Group		*log_cqss_frame = (Fl_Group *)0;
603 Fl_Group		*log_cqwpx_frame = (Fl_Group *)0;
604 Fl_Group		*log_ascr_frame = (Fl_Group *)0;
605 Fl_Group		*log_naqp_frame = (Fl_Group *)0;
606 Fl_Group		*log_rtty_frame = (Fl_Group *)0;
607 Fl_Group		*log_iari_frame = (Fl_Group *)0;
608 Fl_Group		*log_nas_frame = (Fl_Group *)0;
609 Fl_Group		*log_aidx_frame = (Fl_Group *)0;
610 Fl_Group		*log_jota_frame = (Fl_Group *)0;
611 Fl_Group		*log_aicw_frame = (Fl_Group *)0;
612 Fl_Group		*log_sqso_frame = (Fl_Group *)0;
613 Fl_Group		*log_wae_frame = (Fl_Group *)0;
614 
615 cFreqControl 	*qsoFreqDisp3 = (cFreqControl *)0;
616 Fl_Button		*qso_opPICK3;
617 Fl_Button		*qsoClear3;
618 Fl_Button		*qsoSave3;
619 
620 Fl_Group		*TopFrame3b = (Fl_Group *)0;
621 Fl_Input2		*inpCall3 = (Fl_Input2 *)0;
622 
623 // Generic contest fields
624 Fl_Input2		*inpTimeOff3 = (Fl_Input2 *)0;
625 Fl_Input2		*inpTimeOn3 = (Fl_Input2 *)0;
626 Fl_Button		*btnTimeOn3;
627 Fl_Input2		*outSerNo2 = (Fl_Input2 *)0;
628 Fl_Input2		*inpSerNo2 = (Fl_Input2 *)0;
629 Fl_Input2		*inpXchgIn2 = (Fl_Input2 *)0;
630 // Field Day fields
631 Fl_Input2		*inpTimeOff4 = (Fl_Input2 *)0;
632 Fl_Input2		*inpTimeOn4 = (Fl_Input2 *)0;
633 Fl_Button		*btnTimeOn4;
634 Fl_Input2		*inp_FD_class2 = (Fl_Input2 *)0;
635 Fl_Input2		*inp_FD_section2 = (Fl_Input2 *)0;
636 // Kids Day fields
637 Fl_Input2		*inp_KD_name2 = (Fl_Input2 *)0;
638 Fl_Input2		*inp_KD_age2 = (Fl_Input2 *)0;
639 Fl_Input2		*inp_KD_state2 = (Fl_Input2 *)0;
640 Fl_Input2		*inp_KD_VEprov2 = (Fl_Input2 *)0;
641 Fl_Input2		*inp_KD_XchgIn2 = (Fl_Input2 *)0;
642 // CQWW RTTY fields
643 Fl_Input2		*inp_CQ_RSTin2 = (Fl_Input2 *)0;
644 Fl_Input2		*inp_CQ_RSTout2 = (Fl_Input2 *)0;
645 Fl_Input2		*inp_CQzone2 = (Fl_Input2 *)0;
646 Fl_Input2		*inp_CQstate2 = (Fl_Input2 *)0;
647 Fl_ComboBox		*cboCountryCQ2 = (Fl_ComboBox *)0;
648 // CQWW DX fields
649 Fl_Input2		*inp_CQDX_RSTin2 = (Fl_Input2 *)0;
650 Fl_Input2		*inp_CQDX_RSTout2 = (Fl_Input2 *)0;
651 Fl_Input2		*inp_CQDXzone2 = (Fl_Input2 *)0;
652 Fl_ComboBox		*cboCountryCQDX2 = (Fl_ComboBox *)0;
653 // CW Sweepstakes contest sub frame
654 Fl_Input2		*outSerNo4 = (Fl_Input2 *)0;
655 Fl_Input2		*inp_SS_SerialNoR2 = (Fl_Input2 *)0;
656 Fl_Input2		*inp_SS_Precedence2 = (Fl_Input2 *)0;
657 Fl_Input2		*inp_SS_Check2 = (Fl_Input2 *)0;
658 Fl_Input2		*inp_SS_Section2 = (Fl_Input2 *)0;
659 // 1010 contest
660 Fl_Input2		*inp_1010_name2 = (Fl_Input2 *)0;
661 Fl_Input2		*inp_1010_nr2 = (Fl_Input2 *)0;
662 Fl_Input2		*inp_1010_XchgIn2 = (Fl_Input2 *)0;
663 // VHF contest
664 Fl_Input2		*inp_vhf_RSTin2 = (Fl_Input2 *)0;
665 Fl_Input2		*inp_vhf_RSTout2 = (Fl_Input2 *)0;
666 Fl_Input2		*inp_vhf_Loc2 = (Fl_Input2 *)0;
667 // ARRL School Roundup - LOG_ASCR
668 Fl_Input2		*inp_ASCR_name2 = (Fl_Input2 *)0;
669 Fl_Input2		*inp_ASCR_class2 = (Fl_Input2 *)0;
670 Fl_Input2		*inp_ASCR_XchgIn2 = (Fl_Input2 *)0;
671 Fl_Input2		*inp_ASCR_RSTin2 = (Fl_Input2 *)0;
672 Fl_Input2		*inp_ASCR_RSTout2 = (Fl_Input2 *)0;
673 // LOG_NAQP
674 Fl_Input2		*inpTimeOff5 = (Fl_Input2 *)0;
675 Fl_Input2		*inpTimeOn5 = (Fl_Input2 *)0;
676 Fl_Button		*btnTimeOn5;
677 Fl_Input2		*inpNAQPname2;
678 Fl_Input2		*inpSPCnum_NAQP2 = (Fl_Input2 *)0;
679 // LOG_ARRL_RTTY - ARRL RTTY Roundup
680 Fl_Input2		*inpRTU_stpr2 = (Fl_Input2 *)0;
681 Fl_Input2		*inpRTU_RSTin2 = (Fl_Input2 *)0;
682 Fl_Input2		*inpRTU_RSTout2 = (Fl_Input2 *)0;
683 Fl_Input2		*inpRTU_serno2 = (Fl_Input2 *)0;
684 // LOG_NAS - NA Sprint
685 Fl_Input2		*outSerNo6 = (Fl_Input2 *)0;
686 Fl_Input2		*inp_ser_NAS2 = (Fl_Input2 *)0;
687 Fl_Input2		*inpSPCnum_NAS2 = (Fl_Input2 *)0;
688 Fl_Input2		*inp_name_NAS2 = (Fl_Input2 *)0;
689 // LOG_AIDX - African All Mode
690 Fl_Input2		*inpRstIn3 = (Fl_Input2 *)0;
691 Fl_Input2		*inpRstOut3 = (Fl_Input2 *)0;
692 Fl_Input2		*outSerNo8 = (Fl_Input2 *)0;
693 Fl_Input2		*inpSerNo4 = (Fl_Input2 *)0;
694 // LOG_JOTA - Jamboree On The Air
695 Fl_Input2		*inpRstIn4 = (Fl_Input2 *)0;
696 Fl_Input2		*inpRstOut4 = (Fl_Input2 *)0;
697 Fl_Input2		*inp_JOTA_scout2 = (Fl_Input2 *)0;
698 Fl_Input2		*inp_JOTA_troop2 = (Fl_Input2 *)0;
699 Fl_Input2		*inp_JOTA_spc2 = (Fl_Input2 *)0;
700 // LOG_AICW - ARRL International DX (cw)
701 Fl_Input2		*inpRstIn_AICW2 = (Fl_Input2 *)0;
702 Fl_Input2		*inpRstOut_AICW2 = (Fl_Input2 *)0;
703 Fl_Input2		*inpSPCnum_AICW2 = (Fl_Input2 *)0;
704 
705 // Used when no logging frame visible
706 Fl_Input2		*inpCall4 = (Fl_Input2 *)0;
707 
708 Fl_Browser		*qso_opBrowser = (Fl_Browser *)0;
709 Fl_Button		*qso_btnAddFreq = (Fl_Button *)0;
710 Fl_Button		*qso_btnSelFreq = (Fl_Button *)0;
711 Fl_Button		*qso_btnDelFreq = (Fl_Button *)0;
712 Fl_Button		*qso_btnClearList = (Fl_Button *)0;
713 Fl_Button		*qso_btnAct = 0;
714 Fl_Input2		*qso_inpAct = (Fl_Input2 *)0;
715 Fl_Group		*opUsageFrame = (Fl_Group *)0;
716 Fl_Output		*opOutUsage = (Fl_Output *)0;
717 Fl_Input2		*opUsage = (Fl_Input2 *)0;
718 Fl_Button		*opUsageEnter = (Fl_Button *)0;
719 
720 Fl_Group	 	*wf_group = (Fl_Group *)0;
721 Fl_Group		*status_group = (Fl_Group *)0;
722 
723 Fl_Value_Slider2	*mvsquelch = (Fl_Value_Slider2 *)0;
724 Fl_Button		*btnClearMViewer = 0;
725 
726 static const int pad = 1;
727 static const int Hentry		= 24;
728 static const int Wbtn		= Hentry;
729 static int x_qsoframe	= Wbtn;
730 int Hmenu		= 22;
731 static const int Hqsoframe	= 2*pad + 3 * (Hentry + pad);
732 
733 int Hstatus = 20;
734 int Hmacros = 20;
735 
736 #define TB_HEIGHT 20
737 #define MACROBAR_MIN 18
738 #define MACROBAR_MAX 30
739 
740 static int wf1			= 355;
741 
742 static const int w_inpTime2	= 40;
743 static const int w_inpCall2	= 100;
744 static const int w_inpRstIn2	= 30;
745 static const int w_inpRstOut2	= 30;
746 
747 // maximum 1 row height for raster display, FeldHell
748 static int minhtext = 42*2+6;
749 
750 static int main_hmin;// = HMIN;
751 
752 time_t program_start_time = 0;
753 
754 bool xmlrpc_address_override_flag   = false;
755 bool xmlrpc_port_override_flag      = false;
756 
757 bool arq_address_override_flag      = false;
758 bool arq_port_override_flag         = false;
759 
760 bool kiss_address_override_flag     = false;
761 std::string override_xmlrpc_address = "";
762 std::string override_xmlrpc_port    = "";
763 std::string override_arq_address    = "";
764 std::string override_arq_port       = "";
765 std::string override_kiss_address   = "";
766 std::string override_kiss_io_port   = "";
767 std::string override_kiss_out_port  = "";
768 int override_kiss_dual_port_enabled = -1;          // Ensure this remains negative until assigned
769 int override_data_io_enabled        = DISABLED_IO;
770 
771 int IMAGE_WIDTH;
772 int Hwfall;
773 int Wwfall;
774 
775 int					altMacros = 0;
776 
777 waterfall			*wf = (waterfall *)0;
778 Digiscope			*digiscope = (Digiscope *)0;
779 
780 Fl_Slider2			*sldrSquelch = (Fl_Slider2 *)0;
781 Progress			*pgrsSquelch = (Progress *)0;
782 
783 Smeter				*smeter = (Smeter *)0;
784 PWRmeter			*pwrmeter = (PWRmeter *)0;
785 
786 Fl_Group			*pwrlevel_grp = (Fl_Group *)0;
787 Fl_Value_Slider2	*pwr_level = (Fl_Value_Slider2 *)0;
788 Fl_Button			*set_pwr_level = (Fl_Button *)0;
789 
790 static Fl_Pixmap 		*addrbookpixmap = 0;
791 
792 #if !defined(__APPLE__) && !defined(__WOE32__) && USE_X
793 Pixmap				fldigi_icon_pixmap;
794 #endif
795 
796 // for character set conversion
797 int rxtx_charset;
798 static CharsetDistiller rx_chd;
799 static CharsetDistiller echo_chd;
800 static OutputEncoder    tx_encoder;
801 
802 Fl_Menu_Item *getMenuItem(const char *caption, Fl_Menu_Item* submenu = 0);
803 void UI_select();
804 bool clean_exit(bool ask);
805 
806 void cb_init_mode(Fl_Widget *, void *arg);
807 
808 void cb_oliviaCustom(Fl_Widget *w, void *arg);
809 
810 void cb_contestiaCustom(Fl_Widget *w, void *arg);
811 
812 void cb_rtty45(Fl_Widget *w, void *arg);
813 void cb_rtty50(Fl_Widget *w, void *arg);
814 void cb_rtty75N(Fl_Widget *w, void *arg);
815 void cb_rtty75W(Fl_Widget *w, void *arg);
816 void cb_rtty100(Fl_Widget *w, void *arg);
817 void cb_rttyCustom(Fl_Widget *w, void *arg);
818 
819 void cb_fsq2(Fl_Widget *w, void *arg);
820 void cb_fsq3(Fl_Widget *w, void *arg);
821 void cb_fsq4p5(Fl_Widget *w, void *arg);
822 void cb_fsq6(Fl_Widget *w, void *arg);
823 void cb_fsq1p5(Fl_Widget *w, void *arg);
824 
825 void cb_ifkp0p5(Fl_Widget *w, void *arg);
826 void cb_ifkp1p0(Fl_Widget *w, void *arg);
827 void cb_ifkp2p0(Fl_Widget *w, void *arg);
828 
829 void cb_ifkp0p5a(Fl_Widget *w, void *arg);
830 void cb_ifkp1p0a(Fl_Widget *w, void *arg);
831 void cb_ifkp2p0a(Fl_Widget *w, void *arg);
832 
833 void set_colors();
834 
835 //void cb_pkt1200(Fl_Widget *w, void *arg);
836 //void cb_pkt300(Fl_Widget *w, void *arg);
837 //void cb_pkt2400(Fl_Widget *w, void *arg);
838 
839 Fl_Widget *modem_config_tab;
840 static const Fl_Menu_Item *quick_change;
841 
842 static const Fl_Menu_Item quick_change_psk[] = {
843 	{ mode_info[MODE_PSK31].name, 0, cb_init_mode, (void *)MODE_PSK31 },
844 	{ mode_info[MODE_PSK63].name, 0, cb_init_mode, (void *)MODE_PSK63 },
845 	{ mode_info[MODE_PSK63F].name, 0, cb_init_mode, (void *)MODE_PSK63F },
846 	{ mode_info[MODE_PSK125].name, 0, cb_init_mode, (void *)MODE_PSK125 },
847 	{ mode_info[MODE_PSK250].name, 0, cb_init_mode, (void *)MODE_PSK250 },
848 	{ mode_info[MODE_PSK500].name, 0, cb_init_mode, (void *)MODE_PSK500 },
849 	{ mode_info[MODE_PSK1000].name, 0, cb_init_mode, (void *)MODE_PSK1000 },
850 	{ 0 }
851 };
852 
853 static const Fl_Menu_Item quick_change_qpsk[] = {
854 	{ mode_info[MODE_QPSK31].name, 0, cb_init_mode, (void *)MODE_QPSK31 },
855 	{ mode_info[MODE_QPSK63].name, 0, cb_init_mode, (void *)MODE_QPSK63 },
856 	{ mode_info[MODE_QPSK125].name, 0, cb_init_mode, (void *)MODE_QPSK125 },
857 	{ mode_info[MODE_QPSK250].name, 0, cb_init_mode, (void *)MODE_QPSK250 },
858 	{ mode_info[MODE_QPSK500].name, 0, cb_init_mode, (void *)MODE_QPSK500 },
859 	{ 0 }
860 };
861 
862 static const Fl_Menu_Item quick_change_8psk[] = {
863 	{ mode_info[MODE_8PSK125].name, 0, cb_init_mode, (void *)MODE_8PSK125 },
864 	{ mode_info[MODE_8PSK250].name, 0, cb_init_mode, (void *)MODE_8PSK250 },
865 	{ mode_info[MODE_8PSK500].name, 0, cb_init_mode, (void *)MODE_8PSK500 },
866 	{ mode_info[MODE_8PSK1000].name, 0, cb_init_mode, (void *)MODE_8PSK1000 },
867 	{ mode_info[MODE_8PSK125FL].name, 0, cb_init_mode, (void *)MODE_8PSK125FL },
868 	{ mode_info[MODE_8PSK125F].name, 0, cb_init_mode, (void *)MODE_8PSK125F },
869 	{ mode_info[MODE_8PSK250F].name, 0, cb_init_mode, (void *)MODE_8PSK250F },
870 	{ mode_info[MODE_8PSK250FL].name, 0, cb_init_mode, (void *)MODE_8PSK250FL },
871 	{ mode_info[MODE_8PSK500F].name, 0, cb_init_mode, (void *)MODE_8PSK500F },
872 	{ mode_info[MODE_8PSK1000F].name, 0, cb_init_mode, (void *)MODE_8PSK1000F },
873 	{ mode_info[MODE_8PSK1200F].name, 0, cb_init_mode, (void *)MODE_8PSK1200F },
874 	{ 0 }
875 };
876 
877 static const Fl_Menu_Item quick_change_ofdm[] = {
878 	{ mode_info[MODE_OFDM_500F].name, 0, cb_init_mode, (void *)MODE_OFDM_500F },
879 	{ mode_info[MODE_OFDM_750F].name, 0, cb_init_mode, (void *)MODE_OFDM_750F },
880 //	{ mode_info[MODE_OFDM_2000F].name, 0, cb_init_mode, (void *)MODE_OFDM_2000F },
881 //	{ mode_info[MODE_OFDM_2000].name, 0, cb_init_mode, (void *)MODE_OFDM_2000 },
882 	{ mode_info[MODE_OFDM_3500].name, 0, cb_init_mode, (void *)MODE_OFDM_3500 },
883 	{ 0 }
884 };
885 
886 static const Fl_Menu_Item quick_change_pskr[] = {
887 	{ mode_info[MODE_PSK125R].name, 0, cb_init_mode, (void *)MODE_PSK125R },
888 	{ mode_info[MODE_PSK250R].name, 0, cb_init_mode, (void *)MODE_PSK250R },
889 	{ mode_info[MODE_PSK500R].name, 0, cb_init_mode, (void *)MODE_PSK500R },
890 	{ mode_info[MODE_PSK1000R].name, 0, cb_init_mode, (void *)MODE_PSK1000R },
891 	{ 0 }
892 };
893 
894 static const Fl_Menu_Item quick_change_psk_multiR[] = {
895 	{ mode_info[MODE_4X_PSK63R].name, 0, cb_init_mode, (void *)MODE_4X_PSK63R },
896 	{ mode_info[MODE_5X_PSK63R].name, 0, cb_init_mode, (void *)MODE_5X_PSK63R },
897 	{ mode_info[MODE_10X_PSK63R].name, 0, cb_init_mode, (void *)MODE_10X_PSK63R },
898 	{ mode_info[MODE_20X_PSK63R].name, 0, cb_init_mode, (void *)MODE_20X_PSK63R },
899 	{ mode_info[MODE_32X_PSK63R].name, 0, cb_init_mode, (void *)MODE_32X_PSK63R },
900 
901 	{ mode_info[MODE_4X_PSK125R].name, 0, cb_init_mode, (void *)MODE_4X_PSK125R },
902 	{ mode_info[MODE_5X_PSK125R].name, 0, cb_init_mode, (void *)MODE_5X_PSK125R },
903 	{ mode_info[MODE_10X_PSK125R].name, 0, cb_init_mode, (void *)MODE_10X_PSK125R },
904 	{ mode_info[MODE_12X_PSK125R].name, 0, cb_init_mode, (void *)MODE_12X_PSK125R },
905 	{ mode_info[MODE_16X_PSK125R].name, 0, cb_init_mode, (void *)MODE_16X_PSK125R },
906 
907 	{ mode_info[MODE_2X_PSK250R].name, 0, cb_init_mode, (void *)MODE_2X_PSK250R },
908 	{ mode_info[MODE_3X_PSK250R].name, 0, cb_init_mode, (void *)MODE_3X_PSK250R },
909 	{ mode_info[MODE_5X_PSK250R].name, 0, cb_init_mode, (void *)MODE_5X_PSK250R },
910 	{ mode_info[MODE_6X_PSK250R].name, 0, cb_init_mode, (void *)MODE_6X_PSK250R },
911 	{ mode_info[MODE_7X_PSK250R].name, 0, cb_init_mode, (void *)MODE_7X_PSK250R },
912 
913 	{ mode_info[MODE_2X_PSK500R].name, 0, cb_init_mode, (void *)MODE_2X_PSK500R },
914 	{ mode_info[MODE_3X_PSK500R].name, 0, cb_init_mode, (void *)MODE_3X_PSK500R },
915 	{ mode_info[MODE_4X_PSK500R].name, 0, cb_init_mode, (void *)MODE_4X_PSK500R },
916 
917 	{ mode_info[MODE_2X_PSK800R].name, 0, cb_init_mode, (void *)MODE_2X_PSK800R },
918 
919 	{ mode_info[MODE_2X_PSK1000R].name, 0, cb_init_mode, (void *)MODE_2X_PSK1000R },
920 	{ 0 }
921 };
922 
923 static const Fl_Menu_Item quick_change_psk_multi[] = {
924 	{ mode_info[MODE_12X_PSK125].name, 0, cb_init_mode, (void *)MODE_12X_PSK125 },
925 	{ mode_info[MODE_6X_PSK250].name, 0, cb_init_mode, (void *)MODE_6X_PSK250 },
926 	{ mode_info[MODE_2X_PSK500].name, 0, cb_init_mode, (void *)MODE_2X_PSK500 },
927 	{ mode_info[MODE_4X_PSK500].name, 0, cb_init_mode, (void *)MODE_4X_PSK500 },
928 	{ mode_info[MODE_2X_PSK800].name, 0, cb_init_mode, (void *)MODE_2X_PSK800 },
929 	{ mode_info[MODE_2X_PSK1000].name, 0, cb_init_mode, (void *)MODE_2X_PSK1000 },
930 	{ 0 }
931 };
932 
933 static const Fl_Menu_Item quick_change_mfsk[] = {
934 	{ mode_info[MODE_MFSK4].name, 0, cb_init_mode, (void *)MODE_MFSK4 },
935 	{ mode_info[MODE_MFSK8].name, 0, cb_init_mode, (void *)MODE_MFSK8 },
936 	{ mode_info[MODE_MFSK16].name, 0, cb_init_mode, (void *)MODE_MFSK16 },
937 	{ mode_info[MODE_MFSK11].name, 0, cb_init_mode, (void *)MODE_MFSK11 },
938 	{ mode_info[MODE_MFSK22].name, 0, cb_init_mode, (void *)MODE_MFSK22 },
939 	{ mode_info[MODE_MFSK31].name, 0, cb_init_mode, (void *)MODE_MFSK31 },
940 	{ mode_info[MODE_MFSK32].name, 0, cb_init_mode, (void *)MODE_MFSK32 },
941 	{ mode_info[MODE_MFSK64].name, 0, cb_init_mode, (void *)MODE_MFSK64 },
942 	{ mode_info[MODE_MFSK128].name, 0, cb_init_mode, (void *)MODE_MFSK128 },
943 	{ mode_info[MODE_MFSK64L].name, 0, cb_init_mode, (void *)MODE_MFSK64L },
944 	{ mode_info[MODE_MFSK128L].name, 0, cb_init_mode, (void *)MODE_MFSK128L },
945 	{ 0 }
946 };
947 
948 static const Fl_Menu_Item quick_change_wefax[] = {
949 	{ mode_info[MODE_WEFAX_576].name, 0, cb_init_mode, (void *)MODE_WEFAX_576 },
950 	{ mode_info[MODE_WEFAX_288].name, 0, cb_init_mode, (void *)MODE_WEFAX_288 },
951 	{ 0 }
952 };
953 
954 static const Fl_Menu_Item quick_change_navtex[] = {
955 	{ mode_info[MODE_NAVTEX].name, 0, cb_init_mode, (void *)MODE_NAVTEX },
956 	{ mode_info[MODE_SITORB].name, 0, cb_init_mode, (void *)MODE_SITORB },
957 	{ 0 }
958 };
959 
960 static const Fl_Menu_Item quick_change_mt63[] = {
961 	{ mode_info[MODE_MT63_500S].name, 0, cb_init_mode, (void *)MODE_MT63_500S },
962 	{ mode_info[MODE_MT63_500L].name, 0, cb_init_mode, (void *)MODE_MT63_500L },
963 	{ mode_info[MODE_MT63_1000S].name, 0, cb_init_mode, (void *)MODE_MT63_1000S },
964 	{ mode_info[MODE_MT63_1000L].name, 0, cb_init_mode, (void *)MODE_MT63_1000L },
965 	{ mode_info[MODE_MT63_2000S].name, 0, cb_init_mode, (void *)MODE_MT63_2000S },
966 	{ mode_info[MODE_MT63_2000L].name, 0, cb_init_mode, (void *)MODE_MT63_2000L },
967 	{ 0 }
968 };
969 
970 static const Fl_Menu_Item quick_change_thor[] = {
971 	{ mode_info[MODE_THORMICRO].name, 0, cb_init_mode, (void *)MODE_THORMICRO },
972 	{ mode_info[MODE_THOR4].name, 0, cb_init_mode, (void *)MODE_THOR4 },
973 	{ mode_info[MODE_THOR5].name, 0, cb_init_mode, (void *)MODE_THOR5 },
974 	{ mode_info[MODE_THOR8].name, 0, cb_init_mode, (void *)MODE_THOR8 },
975 	{ mode_info[MODE_THOR11].name, 0, cb_init_mode, (void *)MODE_THOR11 },
976 	{ mode_info[MODE_THOR16].name, 0, cb_init_mode, (void *)MODE_THOR16 },
977 	{ mode_info[MODE_THOR22].name, 0, cb_init_mode, (void *)MODE_THOR22 },
978 	{ mode_info[MODE_THOR25x4].name, 0, cb_init_mode, (void *)MODE_THOR25x4 },
979 	{ mode_info[MODE_THOR50x1].name, 0, cb_init_mode, (void *)MODE_THOR50x1 },
980 	{ mode_info[MODE_THOR50x2].name, 0, cb_init_mode, (void *)MODE_THOR50x2 },
981 	{ mode_info[MODE_THOR100].name, 0, cb_init_mode, (void *)MODE_THOR100 },
982 	{ 0 }
983 };
984 
985 static const Fl_Menu_Item quick_change_domino[] = {
986 	{ mode_info[MODE_DOMINOEXMICRO].name, 0, cb_init_mode, (void *)MODE_DOMINOEXMICRO },
987 	{ mode_info[MODE_DOMINOEX4].name, 0, cb_init_mode, (void *)MODE_DOMINOEX4 },
988 	{ mode_info[MODE_DOMINOEX5].name, 0, cb_init_mode, (void *)MODE_DOMINOEX5 },
989 	{ mode_info[MODE_DOMINOEX8].name, 0, cb_init_mode, (void *)MODE_DOMINOEX8 },
990 	{ mode_info[MODE_DOMINOEX11].name, 0, cb_init_mode, (void *)MODE_DOMINOEX11 },
991 	{ mode_info[MODE_DOMINOEX16].name, 0, cb_init_mode, (void *)MODE_DOMINOEX16 },
992 	{ mode_info[MODE_DOMINOEX22].name, 0, cb_init_mode, (void *)MODE_DOMINOEX22 },
993 	{ mode_info[MODE_DOMINOEX44].name, 0, cb_init_mode, (void *)MODE_DOMINOEX44 },
994 	{ mode_info[MODE_DOMINOEX88].name, 0, cb_init_mode, (void *)MODE_DOMINOEX88 },
995 	{ 0 }
996 };
997 
998 static const Fl_Menu_Item quick_change_feld[] = {
999 	{ mode_info[MODE_FELDHELL].name, 0, cb_init_mode, (void *)MODE_FELDHELL },
1000 	{ mode_info[MODE_SLOWHELL].name, 0, cb_init_mode, (void *)MODE_SLOWHELL },
1001 	{ mode_info[MODE_HELLX5].name,   0, cb_init_mode, (void *)MODE_HELLX5 },
1002 	{ mode_info[MODE_HELLX9].name,   0, cb_init_mode, (void *)MODE_HELLX9 },
1003 	{ mode_info[MODE_FSKH245].name,  0, cb_init_mode, (void *)MODE_FSKH245 },
1004 	{ mode_info[MODE_FSKH105].name,  0, cb_init_mode, (void *)MODE_FSKH105 },
1005 	{ mode_info[MODE_HELL80].name,   0, cb_init_mode, (void *)MODE_HELL80 },
1006 	{ 0 }
1007 };
1008 
1009 static const Fl_Menu_Item quick_change_throb[] = {
1010 	{ mode_info[MODE_THROB1].name, 0, cb_init_mode, (void *)MODE_THROB1 },
1011 	{ mode_info[MODE_THROB2].name, 0, cb_init_mode, (void *)MODE_THROB2 },
1012 	{ mode_info[MODE_THROB4].name, 0, cb_init_mode, (void *)MODE_THROB4 },
1013 	{ mode_info[MODE_THROBX1].name, 0, cb_init_mode, (void *)MODE_THROBX1 },
1014 	{ mode_info[MODE_THROBX2].name, 0, cb_init_mode, (void *)MODE_THROBX2 },
1015 	{ mode_info[MODE_THROBX4].name, 0, cb_init_mode, (void *)MODE_THROBX4 },
1016 	{ 0 }
1017 };
1018 
1019 static const Fl_Menu_Item quick_change_olivia[] = {
1020 	{ mode_info[MODE_OLIVIA_4_125].name, 0, cb_init_mode, (void *)MODE_OLIVIA_4_125 },
1021 	{ mode_info[MODE_OLIVIA_4_250].name, 0, cb_init_mode, (void *)MODE_OLIVIA_4_250 },
1022 	{ mode_info[MODE_OLIVIA_4_500].name, 0, cb_init_mode, (void *)MODE_OLIVIA_4_500 },
1023 	{ mode_info[MODE_OLIVIA_4_1000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_4_1000 },
1024 	{ mode_info[MODE_OLIVIA_4_2000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_4_2000 },
1025 
1026 	{ mode_info[MODE_OLIVIA_8_125].name, 0, cb_init_mode, (void *)MODE_OLIVIA_8_125 },
1027 	{ mode_info[MODE_OLIVIA_8_250].name, 0, cb_init_mode, (void *)MODE_OLIVIA_8_250 },
1028 	{ mode_info[MODE_OLIVIA_8_500].name, 0, cb_init_mode, (void *)MODE_OLIVIA_8_500 },
1029 	{ mode_info[MODE_OLIVIA_8_1000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_8_1000 },
1030 	{ mode_info[MODE_OLIVIA_8_2000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_8_2000 },
1031 
1032 	{ mode_info[MODE_OLIVIA_16_500].name, 0, cb_init_mode, (void *)MODE_OLIVIA_16_500 },
1033 	{ mode_info[MODE_OLIVIA_16_1000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_16_1000 },
1034 	{ mode_info[MODE_OLIVIA_16_2000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_16_2000 },
1035 
1036 	{ mode_info[MODE_OLIVIA_32_1000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_32_1000 },
1037 	{ mode_info[MODE_OLIVIA_32_2000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_32_2000 },
1038 
1039 	{ mode_info[MODE_OLIVIA_64_500].name, 0, cb_init_mode, (void *)MODE_OLIVIA_64_500 },
1040 	{ mode_info[MODE_OLIVIA_64_1000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_64_1000 },
1041 	{ mode_info[MODE_OLIVIA_64_2000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_64_2000 },
1042 
1043 	{ _("Custom..."), 0, cb_oliviaCustom, (void *)MODE_OLIVIA },
1044 	{ 0 }
1045 };
1046 
1047 static const Fl_Menu_Item quick_change_contestia[] = {
1048 	{ mode_info[MODE_CONTESTIA_4_125].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_4_125 },
1049 	{ mode_info[MODE_CONTESTIA_4_250].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_4_250 },
1050 	{ mode_info[MODE_CONTESTIA_4_500].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_4_500 },
1051 	{ mode_info[MODE_CONTESTIA_4_1000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_4_1000 },
1052 	{ mode_info[MODE_CONTESTIA_4_2000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_4_2000 },
1053 
1054 	{ mode_info[MODE_CONTESTIA_8_125].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_8_125 },
1055 	{ mode_info[MODE_CONTESTIA_8_250].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_8_250 },
1056 	{ mode_info[MODE_CONTESTIA_8_500].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_8_500 },
1057 	{ mode_info[MODE_CONTESTIA_8_1000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_8_1000 },
1058 	{ mode_info[MODE_CONTESTIA_8_2000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_8_2000 },
1059 
1060 	{ mode_info[MODE_CONTESTIA_16_250].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_16_250 },
1061 	{ mode_info[MODE_CONTESTIA_16_500].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_16_500 },
1062 	{ mode_info[MODE_CONTESTIA_16_1000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_16_1000 },
1063 	{ mode_info[MODE_CONTESTIA_16_2000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_16_2000 },
1064 
1065 	{ mode_info[MODE_CONTESTIA_32_1000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_32_1000 },
1066 	{ mode_info[MODE_CONTESTIA_32_2000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_32_2000 },
1067 
1068 	{ mode_info[MODE_CONTESTIA_64_500].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_64_500 },
1069 	{ mode_info[MODE_CONTESTIA_64_1000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_64_1000 },
1070 	{ mode_info[MODE_CONTESTIA_64_2000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_64_2000 },
1071 
1072 	{ _("Custom..."), 0, cb_contestiaCustom, (void *)MODE_CONTESTIA },
1073 	{ 0 }
1074 };
1075 
1076 static const Fl_Menu_Item quick_change_rtty[] = {
1077 	{ "RTTY-45", 0, cb_rtty45, (void *)MODE_RTTY },
1078 	{ "RTTY-50", 0, cb_rtty50, (void *)MODE_RTTY },
1079 	{ "RTTY-75N", 0, cb_rtty75N, (void *)MODE_RTTY },
1080 	{ "RTTY-75W", 0, cb_rtty75W, (void *)MODE_RTTY },
1081 	{ "RTTY-100", 0, cb_rtty100, (void *)MODE_RTTY },
1082 	{ _("Custom..."), 0, cb_rttyCustom, (void *)MODE_RTTY },
1083 	{ 0 }
1084 };
1085 
1086 static const Fl_Menu_Item quick_change_fsq[] = {
1087 	{ "FSQ1.5", 0, cb_fsq1p5, (void *)MODE_FSQ },
1088         { "FSQ2", 0, cb_fsq2, (void *)MODE_FSQ },
1089 	{ "FSQ3", 0, cb_fsq3, (void *)MODE_FSQ },
1090 	{ "FSQ4.5", 0, cb_fsq4p5, (void *)MODE_FSQ },
1091 	{ "FSQ6", 0, cb_fsq6, (void *)MODE_FSQ },
1092 	{ 0 }
1093 };
1094 
1095 static const Fl_Menu_Item quick_change_ifkp[] = {
1096 	{ "IFKP 0.5", 0, cb_ifkp0p5a, (void *)MODE_IFKP },
1097 	{ "IFKP 1.0", 0, cb_ifkp1p0a, (void *)MODE_IFKP },
1098 	{ "IFKP 2.0", 0, cb_ifkp2p0a, (void *)MODE_IFKP },
1099 	{ 0}
1100 };
1101 
1102 //Fl_Menu_Item quick_change_pkt[] = {
1103 //    { " 300 baud", 0, cb_pkt300, (void *)MODE_PACKET },
1104 //    { "1200 baud", 0, cb_pkt1200, (void *)MODE_PACKET },
1105 //    { "2400 baud", 0, cb_pkt2400, (void *)MODE_PACKET },
1106 //    { 0 }
1107 //};
1108 
minmax(int val,int min,int max)1109 inline int minmax(int val, int min, int max)
1110 {
1111 	val = val < max ? val : max;
1112 	return val > min ? val : min;
1113 }
1114 
1115 // Olivia
set_olivia_default_integ()1116 void set_olivia_default_integ()
1117 {
1118 	if (!progdefaults.olivia_reset_fec) return;
1119 
1120 	int tones = progdefaults.oliviatones;
1121 	int bw = progdefaults.oliviabw;
1122 
1123 	if (tones < 1) tones = 1;
1124 	int depth = minmax( (8 * (1 << bw)) / (1 << tones), 4, 4 * (1 << bw));
1125 
1126 	progdefaults.oliviasinteg = depth;
1127 	cntOlivia_sinteg->value(depth);
1128 }
1129 
set_olivia_tab_widgets()1130 void set_olivia_tab_widgets()
1131 {
1132 	i_listbox_olivia_bandwidth->index(progdefaults.oliviabw);
1133 	i_listbox_olivia_tones->index(progdefaults.oliviatones);
1134 	set_olivia_default_integ();
1135 }
1136 
close_tree_items()1137 void close_tree_items()
1138 {
1139 	std::string tabs[] = {
1140 		_("Colors-Fonts"),
1141 		_("Contests"),
1142 		_("IDs"),
1143 		_("Logging"),
1144 		_("Modem/CW"),
1145 		_("Modem/TTY"),
1146 		_("Modem"),
1147 		_("Misc"),
1148 		_("Rig Control"),
1149 		_("Soundcard"),
1150 		_("UI"),
1151 		_("Waterfall"),
1152 		_("Web")
1153 	};
1154 	for (size_t n = 0; n < sizeof(tabs) / sizeof(*tabs); n++)
1155 			tab_tree->close(tabs[n].c_str(),0);
1156 }
1157 
select_tab_tree(const char * tab)1158 void select_tab_tree(const char *tab)
1159 {
1160 	close_tree_items();
1161 
1162 	std::string pname = tab;
1163 	size_t p = pname.find("/");
1164 	while (p != std::string::npos) {
1165 		tab_tree->open(pname.substr(0,p).c_str());
1166 		p = pname.find("/", p+1);
1167 	}
1168 	tab_tree->open(pname.c_str(),0);
1169 	tab_tree->select(tab,1);
1170 	SelectItem_CB(tab_tree);
1171 }
1172 
open_config(const char * tab)1173 void open_config(const char *tab)
1174 {
1175 	select_tab_tree(tab);
1176 	dlgConfig->show();
1177 }
1178 
cb_oliviaCustom(Fl_Widget * w,void * arg)1179 void cb_oliviaCustom(Fl_Widget *w, void *arg)
1180 {
1181 	open_config(TAB_OLIVIA);
1182 	cb_init_mode(w, arg);
1183 }
1184 
1185 // Contestia
set_contestia_default_integ()1186 void set_contestia_default_integ()
1187 {
1188 	if (!progdefaults.contestia_reset_fec) return;
1189 
1190 	int tones = progdefaults.contestiatones;
1191 	int bw = progdefaults.contestiabw;
1192 
1193 	if (tones < 1) tones = 1;
1194 	int depth = minmax( (8 * (1 << bw)) / (1 << tones), 4, 4 * (1 << bw));
1195 
1196 	progdefaults.contestiasinteg = depth;
1197 	cntContestia_sinteg->value(depth);
1198 }
1199 
set_contestia_tab_widgets()1200 void set_contestia_tab_widgets()
1201 {
1202 	i_listbox_contestia_bandwidth->index(progdefaults.contestiabw);
1203 	i_listbox_contestia_tones->index(progdefaults.contestiatones);
1204 	set_contestia_default_integ();
1205 }
1206 
cb_contestiaCustom(Fl_Widget * w,void * arg)1207 void cb_contestiaCustom(Fl_Widget *w, void *arg)
1208 {
1209 	open_config(TAB_CONTESTIA);
1210 	cb_init_mode(w, arg);
1211 }
1212 
1213 // rtty
set_rtty_tab_widgets()1214 void set_rtty_tab_widgets()
1215 {
1216 	selShift->index(progdefaults.rtty_shift);
1217 	selCustomShift->deactivate();
1218 	selBits->index(progdefaults.rtty_bits);
1219 	selBaud->index(progdefaults.rtty_baud);
1220 	selParity->index(progdefaults.rtty_parity);
1221 	selStopBits->index(progdefaults.rtty_stop);
1222 }
1223 
enable_rtty_quickchange()1224 void enable_rtty_quickchange()
1225 {
1226 	if (active_modem->get_mode() == MODE_RTTY)
1227 		quick_change = quick_change_rtty;
1228 }
1229 
disable_rtty_quickchange()1230 void disable_rtty_quickchange()
1231 {
1232 	if (active_modem->get_mode() == MODE_RTTY)
1233 		quick_change = 0;
1234 }
1235 
cb_rtty45(Fl_Widget * w,void * arg)1236 void cb_rtty45(Fl_Widget *w, void *arg)
1237 {
1238 	progdefaults.rtty_baud = 1;
1239 	progdefaults.rtty_bits = 0;
1240 	progdefaults.rtty_shift = 3;
1241 	set_rtty_tab_widgets();
1242 	cb_init_mode(w, arg);
1243 }
1244 
cb_rtty50(Fl_Widget * w,void * arg)1245 void cb_rtty50(Fl_Widget *w, void *arg)
1246 {
1247 	progdefaults.rtty_baud = 2;
1248 	progdefaults.rtty_bits = 0;
1249 	progdefaults.rtty_shift = 3;
1250 	set_rtty_tab_widgets();
1251 	cb_init_mode(w, arg);
1252 }
1253 
cb_rtty75N(Fl_Widget * w,void * arg)1254 void cb_rtty75N(Fl_Widget *w, void *arg)
1255 {
1256 	progdefaults.rtty_baud = 4;
1257 	progdefaults.rtty_bits = 0;
1258 	progdefaults.rtty_shift = 3;
1259 	set_rtty_tab_widgets();
1260 	cb_init_mode(w, arg);
1261 }
1262 
cb_rtty75W(Fl_Widget * w,void * arg)1263 void cb_rtty75W(Fl_Widget *w, void *arg)
1264 {
1265 	progdefaults.rtty_baud = 4;
1266 	progdefaults.rtty_bits = 0;
1267 	progdefaults.rtty_shift = 9;
1268 	set_rtty_tab_widgets();
1269 	cb_init_mode(w, arg);
1270 }
1271 
cb_rtty100(Fl_Widget * w,void * arg)1272 void cb_rtty100(Fl_Widget *w, void *arg)
1273 {
1274 	progdefaults.rtty_baud = 5;
1275 	progdefaults.rtty_bits = 0;
1276 	progdefaults.rtty_shift = 3;
1277 	set_rtty_tab_widgets();
1278 	cb_init_mode(w, arg);
1279 }
1280 
cb_rttyCustom(Fl_Widget * w,void * arg)1281 void cb_rttyCustom(Fl_Widget *w, void *arg)
1282 {
1283 	open_config(TAB_RTTY);
1284 
1285 	cb_init_mode(w, arg);
1286 }
1287 
set_fsq_tab_widgets()1288 void set_fsq_tab_widgets()
1289 {
1290 	btn_fsqbaud[0]->value(0);
1291 	btn_fsqbaud[1]->value(0);
1292 	btn_fsqbaud[2]->value(0);
1293 	btn_fsqbaud[3]->value(0);
1294 	btn_fsqbaud[4]->value(0);
1295 	if (progdefaults.fsqbaud == 1.5) btn_fsqbaud[0]->value(1);
1296 	else if (progdefaults.fsqbaud == 2.0) btn_fsqbaud[1]->value(1);
1297 	else if (progdefaults.fsqbaud == 3.0) btn_fsqbaud[2]->value(1);
1298 	else if (progdefaults.fsqbaud == 4.5) btn_fsqbaud[3]->value(1);
1299 	else btn_fsqbaud[4]->value(1);
1300 }
1301 
cb_fsq1p5(Fl_Widget * w,void * arg)1302 void cb_fsq1p5(Fl_Widget *w, void *arg)
1303 {
1304 	progdefaults.fsqbaud = 1.5;
1305 	set_fsq_tab_widgets();
1306 	cb_init_mode(w, arg);
1307 }
1308 
cb_fsq2(Fl_Widget * w,void * arg)1309 void cb_fsq2(Fl_Widget *w, void *arg)
1310 {
1311 	progdefaults.fsqbaud = 2.0;
1312 	set_fsq_tab_widgets();
1313 	cb_init_mode(w, arg);
1314 }
1315 
cb_fsq3(Fl_Widget * w,void * arg)1316 void cb_fsq3(Fl_Widget *w, void *arg)
1317 {
1318 	progdefaults.fsqbaud = 3.0;
1319 	set_fsq_tab_widgets();
1320 	cb_init_mode(w, arg);
1321 }
1322 
cb_fsq4p5(Fl_Widget * w,void * arg)1323 void cb_fsq4p5(Fl_Widget *w, void *arg)
1324 {
1325 	progdefaults.fsqbaud = 4.5;
1326 	set_fsq_tab_widgets();
1327 	cb_init_mode(w, arg);
1328 }
1329 
cb_fsq6(Fl_Widget * w,void * arg)1330 void cb_fsq6(Fl_Widget *w, void *arg)
1331 {
1332 	progdefaults.fsqbaud = 6.0;
1333 	set_fsq_tab_widgets();
1334 	cb_init_mode(w, arg);
1335 }
1336 
set_ifkp_tab_widgets()1337 void set_ifkp_tab_widgets()
1338 {
1339 	btn_ifkpbaud[0]->value(0);
1340 	btn_ifkpbaud[1]->value(0);
1341 	btn_ifkpbaud[2]->value(0);
1342 	if (progdefaults.ifkp_baud == 0) {
1343 		btn_ifkpbaud[0]->value(1);
1344 		put_MODEstatus("IFKP 0.5");
1345 	} else if (progdefaults.ifkp_baud == 1) {
1346 		btn_ifkpbaud[1]->value(1);
1347 		put_MODEstatus("IFKP 1.0");
1348 	}
1349 	else {
1350 		btn_ifkpbaud[2]->value(1);
1351 		put_MODEstatus("IFKP 2.0");
1352 	}
1353 }
1354 
cb_ifkp0p5(Fl_Widget * w,void * arg)1355 void cb_ifkp0p5 (Fl_Widget *w, void *arg)
1356 {
1357 	progdefaults.ifkp_baud = 0;
1358 	set_ifkp_tab_widgets();
1359 	cb_init_mode(w, arg);
1360 }
1361 
cb_ifkp0p5a(Fl_Widget * w,void * arg)1362 void cb_ifkp0p5a (Fl_Widget *w, void *arg)
1363 {
1364 	progdefaults.ifkp_baud = 0;
1365 	set_ifkp_tab_widgets();
1366 }
1367 
cb_ifkp1p0(Fl_Widget * w,void * arg)1368 void cb_ifkp1p0 (Fl_Widget *w, void *arg)
1369 {
1370 	progdefaults.ifkp_baud = 1;
1371 	set_ifkp_tab_widgets();
1372 	cb_init_mode(w, arg);
1373 }
1374 
cb_ifkp1p0a(Fl_Widget * w,void * arg)1375 void cb_ifkp1p0a (Fl_Widget *w, void *arg)
1376 {
1377 	progdefaults.ifkp_baud = 1;
1378 	set_ifkp_tab_widgets();
1379 }
1380 
cb_ifkp2p0(Fl_Widget * w,void * arg)1381 void cb_ifkp2p0 (Fl_Widget *w, void *arg)
1382 {
1383 	progdefaults.ifkp_baud = 2;
1384 	set_ifkp_tab_widgets();
1385 	cb_init_mode(w, arg);
1386 }
1387 
cb_ifkp2p0a(Fl_Widget * w,void * arg)1388 void cb_ifkp2p0a (Fl_Widget *w, void *arg)
1389 {
1390 	progdefaults.ifkp_baud = 2;
1391 	set_ifkp_tab_widgets();
1392 }
1393 
set_dominoex_tab_widgets()1394 void set_dominoex_tab_widgets()
1395 {
1396 	chkDominoEX_FEC->value(progdefaults.DOMINOEX_FEC);
1397 }
1398 
1399 //void cb_pkt1200(Fl_Widget *w, void *arg)
1400 //{
1401 //    progdefaults.PKT_BAUD_SELECT = 0;
1402 //    selPacket_Baud->value(progdefaults.PKT_BAUD_SELECT);
1403 //    cb_init_mode(w, arg);
1404 //}
1405 
1406 //void cb_pkt300(Fl_Widget *w, void *arg)
1407 //{
1408 //    progdefaults.PKT_BAUD_SELECT = 1;
1409 //    selPacket_Baud->value(progdefaults.PKT_BAUD_SELECT);
1410 //    cb_init_mode(w, arg);
1411 //}
1412 
1413 //void cb_pkt2400(Fl_Widget *w, void *arg)
1414 //{
1415 //    progdefaults.PKT_BAUD_SELECT = 2;
1416 //    selPacket_Baud->value(progdefaults.PKT_BAUD_SELECT);
1417 //    cb_init_mode(w, arg);
1418 //}
1419 
set_mode_controls(trx_mode id)1420 void set_mode_controls(trx_mode id)
1421 {
1422 	if (id == MODE_CW) {
1423 		cntCW_WPM->show();
1424 		btnCW_Default->show();
1425 		Status1->hide();
1426 		if (mvsquelch) {
1427 			mvsquelch->value(progStatus.VIEWER_cwsquelch);
1428 			mvsquelch->range(0, 40.0);
1429 			mvsquelch->redraw();
1430 		}
1431 		if (sldrViewerSquelch) {
1432 			sldrViewerSquelch->value(progStatus.VIEWER_cwsquelch);
1433 			sldrViewerSquelch->range(0, 40.0);
1434 			sldrViewerSquelch->redraw();
1435 		}
1436 	} else {
1437 		cntCW_WPM->hide();
1438 		btnCW_Default->hide();
1439 		Status1->show();
1440 	}
1441 
1442 	if (id == MODE_RTTY) {
1443 		if (mvsquelch) {
1444 			mvsquelch->value(progStatus.VIEWER_rttysquelch);
1445 			mvsquelch->range(-6.0, 34.0);
1446 		}
1447 		if (sldrViewerSquelch) {
1448 			sldrViewerSquelch->value(progStatus.VIEWER_rttysquelch);
1449 			sldrViewerSquelch->range(-12.0, 6.0);
1450 		}
1451 	}
1452 
1453 	if (id >= MODE_PSK_FIRST && id <= MODE_PSK_LAST) {
1454 		if (mvsquelch) {
1455 			mvsquelch->value(progStatus.VIEWER_psksquelch);
1456 			mvsquelch->range(-3.0, 6.0);
1457 		}
1458 		if (sldrViewerSquelch) {
1459 			sldrViewerSquelch->value(progStatus.VIEWER_psksquelch);
1460 			sldrViewerSquelch->range(-3.0, 6.0);
1461 		}
1462 	}
1463 
1464 	if (!bWF_only) {
1465 		if (id >= MODE_WEFAX_FIRST && id <= MODE_WEFAX_LAST) {
1466 			text_group->hide();
1467 			fsq_group->hide();
1468 			ifkp_group->hide();
1469 			fmt_group->hide();
1470 			wefax_group->show();
1471 			center_group->redraw();
1472 		} else if (id == MODE_FSQ) {
1473 			text_group->hide();
1474 			wefax_group->hide();
1475 			ifkp_group->hide();
1476 			fmt_group->hide();
1477 			fsq_group->show();
1478 			center_group->redraw();
1479 		} else if (id == MODE_IFKP) {
1480 			text_group->hide();
1481 			wefax_group->hide();
1482 			fsq_group->hide();
1483 			fmt_group->hide();
1484 			ifkp_group->show();
1485 			center_group->redraw();
1486 		} else if (id == MODE_FMT) {
1487 			text_group->hide();
1488 			wefax_group->hide();
1489 			fsq_group->hide();
1490 			ifkp_group->hide();
1491 			fmt_group->show();
1492 			center_group->redraw();
1493 		} else {
1494 			text_group->show();
1495 			wefax_group->hide();
1496 			fsq_group->hide();
1497 			ifkp_group->hide();
1498 			fmt_group->hide();
1499 			if (id >= MODE_HELL_FIRST && id <= MODE_HELL_LAST) {
1500 				ReceiveText->hide();
1501 				FHdisp->show();
1502 			} else {
1503 				FHdisp->hide();
1504 				ReceiveText->show();
1505 			}
1506 			center_group->redraw();
1507 		}
1508 		ifkp_avatar->hide();
1509 		thor_avatar->hide();
1510 		string call = inpCall->value();
1511 		if (id == MODE_IFKP) {
1512 			NFtabs->resize(
1513 				NFtabs->x(), NFtabs->y(),
1514 				fl_digi_main->w() - NFtabs->x() - 59 - pad, NFtabs->h());
1515 			ifkp_avatar->resize(fl_digi_main->w() - 59 - pad, NFtabs->y(), 59, 74);
1516 			ifkp_avatar->show();
1517 			if (!call.empty())
1518 				ifkp_load_avatar(inpCall->value());
1519 			else
1520 				ifkp_load_avatar();
1521 		} else if ( ((id >= MODE_THOR11) && (id <= MODE_THOR22))) {
1522 			NFtabs->resize(
1523 				NFtabs->x(), NFtabs->y(),
1524 				fl_digi_main->w() - NFtabs->x() - 59 - pad, NFtabs->h());
1525 			thor_avatar->resize(fl_digi_main->w() - 59 - pad, NFtabs->y(), 59, 74);
1526 			thor_avatar->show();
1527 			if (!call.empty())
1528 				thor_load_avatar(inpCall->value());
1529 			else
1530 				thor_load_avatar();
1531 		}
1532 		else {
1533 			NFtabs->resize(
1534 				NFtabs->x(), NFtabs->y(),
1535 				fl_digi_main->w() - NFtabs->x() - 2*pad, NFtabs->h());
1536 		}
1537 		ifkp_avatar->redraw();
1538 		thor_avatar->redraw();
1539 		NFtabs->init_sizes();
1540 		NFtabs->redraw();
1541 
1542 	}
1543 
1544 }
1545 
startup_modem(modem * m,int f)1546 void startup_modem(modem* m, int f)
1547 {
1548 	trx_start_modem(m, f);
1549 #if BENCHMARK_MODE
1550 	return;
1551 #endif
1552 
1553 	restoreFocus(1);
1554 
1555 	trx_mode id = m->get_mode();
1556 
1557 	set_mode_controls(id);
1558 
1559 	if (id >= MODE_PSK_FIRST && id <= MODE_PSK_LAST) {
1560 		m->set_sigsearch(SIGSEARCH);
1561 	}
1562 
1563 	if (m->get_cap() & modem::CAP_AFC) {
1564 		btnAFC->value(progStatus.afconoff);
1565 		btnAFC->activate();
1566 	}
1567 	else {
1568 		btnAFC->value(0);
1569 		btnAFC->deactivate();
1570 	}
1571 
1572 	if (m->get_cap() & modem::CAP_REV) {
1573 		wf->btnRev->value(wf->Reverse());
1574 		wf->btnRev->activate();
1575 	}
1576 	else {
1577 		wf->btnRev->value(0);
1578 		wf->btnRev->deactivate();
1579 	}
1580 }
1581 
cb_mnuOpenMacro(Fl_Menu_ *,void *)1582 void cb_mnuOpenMacro(Fl_Menu_*, void*) {
1583 	if (macros.changed) {
1584 		switch (fl_choice2(_("Save changed macros?"), _("Cancel"), _("Save"), _("Don't save"))) {
1585 		case 0:
1586 			return;
1587 		case 1:
1588 			macros.saveMacroFile();
1589 			// fall through
1590 		case 2:
1591 			break;
1592 		}
1593 	}
1594 	macros.openMacroFile();
1595 	macros.changed = false;
1596 	restoreFocus(2);
1597 }
1598 
cb_mnuSaveMacro(Fl_Menu_ *,void *)1599 void cb_mnuSaveMacro(Fl_Menu_*, void*) {
1600 	macros.saveMacroFile();
1601 	restoreFocus(3);
1602 }
1603 
remove_windows()1604 void remove_windows()
1605 {
1606 	std::string titles[] = {
1607 		"scope view", "record loader", "cluster viewer", "dxcc window",
1608 		"viewer", "logbook", "lotw review",
1609 		"export", "cabrillo",
1610 		"config", "notify",
1611 		"mfsk rxwin", "mfsk txwin",
1612 		"thor rxwin", "thor txwin",
1613 		"fsq monitor", "fsq rxwin", "fsq txwin",
1614 		"ifkp rxwin", "ifkp txwin",
1615 		"macro editor", "test signals", "rx audio",
1616 		"wefax tx dialog"
1617 	};
1618 	Fl_Double_Window *w[] = {
1619 		scopeview, dlgRecordLoader,
1620 		dxcluster_viewer, dxcc_window,
1621 		dlgViewer, dlgLogbook, lotw_review_dialog,
1622 		wExport, wCabrillo,
1623 		dlgConfig, notify_window,
1624 		picRxWin, picTxWin,
1625 		thorpicRxWin, thorpicTxWin,
1626 		fsqMonitor, fsqpicRxWin, fsqpicTxWin,
1627 		ifkppicRxWin, ifkppicTxWin,
1628 		MacroEditDialog,
1629 		test_signal_window,
1630 		rxaudio_dialog, wefax_pic_tx_win };
1631 		std::string sdeleting = "\nDeleting dialogs / Stopping debug session";
1632 	for (size_t n = 0; n < sizeof(w) / sizeof(*w); n++) {
1633 		if (w[n]) {
1634 		sdeleting.append("\n   ").append(titles[n]);
1635 			w[n]->hide();
1636 			delete w[n];
1637 			w[n] = 0;
1638 		}
1639 	}
1640 	if (font_browser) {
1641 		sdeleting.append("\n   font browser");
1642 		font_browser->hide();
1643 		delete font_browser;
1644 		font_browser = 0;
1645 	}
1646 	LOG_INFO("%s", sdeleting.c_str());
1647 	MilliSleep(50);
1648 	debug::stop();
1649 }
1650 
1651 // callback executed from Escape / Window decoration 'X' or OS X cmd-Q
1652 
cb_wMain(Fl_Widget *,void *)1653 void cb_wMain(Fl_Widget*, void*)
1654 {
1655 	if (!clean_exit(true)) return;
1656 	remove_windows();
1657 	LOG_INFO("Hiding main window");
1658 	fl_digi_main->hide();
1659 }
1660 
1661 // callback executed from menu item File/Exit
cb_E(Fl_Menu_ *,void *)1662 void cb_E(Fl_Menu_*, void*) {
1663 	if (!clean_exit(true))
1664 		return;
1665 	remove_windows();
1666 	LOG_INFO("Hiding main window");
1667 // this will make Fl::run return
1668 	fl_digi_main->hide();
1669 }
1670 
1671 static int squelch_val;
rsid_squelch_timer(void *)1672 void rsid_squelch_timer(void*)
1673 {
1674 	progStatus.sqlonoff = squelch_val;
1675 	if (progStatus.sqlonoff)
1676 		btnSQL->value(1);
1677 }
1678 
init_modem_squelch(trx_mode mode,int freq)1679 void init_modem_squelch(trx_mode mode, int freq)
1680 {
1681 	squelch_val = progStatus.sqlonoff;
1682 	progStatus.sqlonoff = 0;
1683 	btnSQL->value(0);
1684 	Fl::add_timeout(progdefaults.rsid_squelch, rsid_squelch_timer);
1685 	init_modem(mode, freq);
1686 }
1687 
1688 extern bool valid_kiss_modem(std::string modem_name);
1689 
init_modem(trx_mode mode,int freq)1690 void init_modem(trx_mode mode, int freq)
1691 {
1692 	ENSURE_THREAD(FLMAIN_TID);
1693 
1694 	if (bWF_only)
1695 		if (mode == MODE_FSQ ||
1696 			mode == MODE_IFKP ||
1697 			mode == MODE_FELDHELL ||
1698 			mode == MODE_SLOWHELL ||
1699 			mode == MODE_HELLX5 ||
1700 			mode == MODE_HELLX9 ||
1701 			mode == MODE_FSKH245 ||
1702 			mode == MODE_FSKH105 ||
1703 			mode == MODE_HELL80 ||
1704 			mode == MODE_WEFAX_576 ||
1705 			mode == MODE_WEFAX_288 ||
1706 			mode == MODE_NAVTEX ||
1707 			mode == MODE_SITORB )
1708 		mode = MODE_PSK31;
1709 
1710 	stopMacroTimer();
1711 
1712 	if (data_io_enabled == KISS_IO) {
1713 		trx_mode current_mode = active_modem->get_mode();
1714 		if(!bcast_rsid_kiss_frame(freq, mode, (int) active_modem->get_txfreq(), current_mode,
1715 								  progdefaults.rsid_notify_only ? RSID_KISS_NOTIFY : RSID_KISS_ACTIVE)) {
1716 
1717 			LOG_INFO("Invaild Modem for KISS I/O (%s)",  mode_info[mode].sname);
1718 
1719 			int _yes = false;
1720 			if(!progdefaults.kiss_io_modem_change_inhibit)
1721 				_yes = fl_choice2(_("Switch to ARQ I/O"), _("No"), _("Yes"), NULL);
1722 
1723 			if(_yes) {
1724 				enable_arq();
1725 			} else {
1726 				std::string modem_name;
1727 				modem_name.assign(mode_info[current_mode].sname);
1728 				bool valid = valid_kiss_modem(modem_name);
1729 				if(!valid)
1730 					current_mode = MODE_PSK250;
1731 				mode = current_mode;
1732 			}
1733 		}
1734 	}
1735 
1736 	//LOG_INFO("mode: %d, freq: %d", (int)mode, freq);
1737 
1738 #if !BENCHMARK_MODE
1739 	   quick_change = 0;
1740 //	   modem_config_tab = tabsModems->child(0);
1741 #endif
1742 
1743 	switch (mode) {
1744 	case MODE_NEXT:
1745 		if ((mode = active_modem->get_mode() + 1) == NUM_MODES)
1746 			mode = 0;
1747 		return init_modem(mode, freq);
1748 	case MODE_PREV:
1749 		if ((mode = active_modem->get_mode() - 1) < 0)
1750 			mode = NUM_MODES - 1;
1751 		return init_modem(mode, freq);
1752 
1753 	case MODE_NULL:
1754 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1755 				  *mode_info[mode].modem = new NULLMODEM, freq);
1756 		break;
1757 
1758 	case MODE_CW:
1759 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1760 				  *mode_info[mode].modem = new cw, freq);
1761 //		modem_config_tab = tabCW;
1762 		break;
1763 
1764 	case MODE_THORMICRO: case MODE_THOR4: case MODE_THOR5: case MODE_THOR8:
1765 	case MODE_THOR11:case MODE_THOR16: case MODE_THOR22:
1766 	case MODE_THOR25x4: case MODE_THOR50x1: case MODE_THOR50x2: case MODE_THOR100:
1767 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1768 				  *mode_info[mode].modem = new thor(mode), freq);
1769 		quick_change = quick_change_thor;
1770 //		modem_config_tab = tabTHOR;
1771 		break;
1772 
1773 	case MODE_DOMINOEXMICRO: case MODE_DOMINOEX4: case MODE_DOMINOEX5: case MODE_DOMINOEX8:
1774 	case MODE_DOMINOEX11: case MODE_DOMINOEX16: case MODE_DOMINOEX22:
1775 	case MODE_DOMINOEX44: case MODE_DOMINOEX88:
1776 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1777 				  *mode_info[mode].modem = new dominoex(mode), freq);
1778 		quick_change = quick_change_domino;
1779 //		modem_config_tab = tabDomEX;
1780 		break;
1781 
1782 	case MODE_FELDHELL:
1783 	case MODE_SLOWHELL:
1784 	case MODE_HELLX5:
1785 	case MODE_HELLX9:
1786 	case MODE_FSKH245:
1787 	case MODE_FSKH105:
1788 	case MODE_HELL80:
1789 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1790 				  *mode_info[mode].modem = new feld(mode), freq);
1791 		quick_change = quick_change_feld;
1792 //		modem_config_tab = tabFeld;
1793 		break;
1794 
1795 	case MODE_MFSK4:
1796 	case MODE_MFSK11:
1797 	case MODE_MFSK22:
1798 	case MODE_MFSK31:
1799 	case MODE_MFSK64:
1800 	case MODE_MFSK8:
1801 	case MODE_MFSK16:
1802 	case MODE_MFSK32:
1803 	case MODE_MFSK128:
1804 	case MODE_MFSK64L:
1805 	case MODE_MFSK128L:
1806 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1807 				  *mode_info[mode].modem = new mfsk(mode), freq);
1808 		quick_change = quick_change_mfsk;
1809 		break;
1810 
1811 	case MODE_WEFAX_576:
1812 	case MODE_WEFAX_288:
1813 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1814 				  *mode_info[mode].modem = new wefax(mode), freq);
1815 		quick_change = quick_change_wefax;
1816 //		modem_config_tab = tabWefax;
1817 		break;
1818 
1819 	case MODE_NAVTEX:
1820 	case MODE_SITORB:
1821 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1822 				  *mode_info[mode].modem = new navtex(mode), freq);
1823 		quick_change = quick_change_navtex;
1824 //		modem_config_tab = tabNavtex;
1825 		break;
1826 
1827 	case MODE_MT63_500S: case MODE_MT63_1000S: case MODE_MT63_2000S :
1828 	case MODE_MT63_500L: case MODE_MT63_1000L: case MODE_MT63_2000L :
1829 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1830 				  *mode_info[mode].modem = new mt63(mode), freq);
1831 		quick_change = quick_change_mt63;
1832 //		modem_config_tab = tabMT63;
1833 		break;
1834 
1835 	case MODE_PSK31: case MODE_PSK63: case MODE_PSK63F:
1836 	case MODE_PSK125: case MODE_PSK250: case MODE_PSK500:
1837 	case MODE_PSK1000:
1838 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1839 				  *mode_info[mode].modem = new psk(mode), freq);
1840 		quick_change = quick_change_psk;
1841 //		modem_config_tab = tabPSK;
1842 		break;
1843 
1844 	case MODE_QPSK31: case MODE_QPSK63: case MODE_QPSK125: case MODE_QPSK250: case MODE_QPSK500:
1845 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1846 				  *mode_info[mode].modem = new psk(mode), freq);
1847 		quick_change = quick_change_qpsk;
1848 //		modem_config_tab = tabPSK;
1849 		break;
1850 	case MODE_8PSK125:
1851 	case MODE_8PSK250:
1852 	case MODE_8PSK500:
1853 	case MODE_8PSK1000:
1854 	case MODE_8PSK125FL:
1855 	case MODE_8PSK125F:
1856 	case MODE_8PSK250FL:
1857 	case MODE_8PSK250F:
1858 	case MODE_8PSK500F:
1859 	case MODE_8PSK1000F:
1860 	case MODE_8PSK1200F:
1861 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1862 				  *mode_info[mode].modem = new psk(mode), freq);
1863 		quick_change = quick_change_8psk;
1864 //		modem_config_tab = tabPSK;
1865 		break;
1866 
1867 
1868 	case MODE_OFDM_500F:
1869 	case MODE_OFDM_750F:
1870 	case MODE_OFDM_2000F:
1871 	case MODE_OFDM_2000:
1872 	case MODE_OFDM_3500:
1873 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1874 		*mode_info[mode].modem = new psk(mode), freq);
1875 		quick_change = quick_change_ofdm;
1876 		//		modem_config_tab = tabPSK;
1877 		break;
1878 
1879 
1880 	case MODE_PSK125R: case MODE_PSK250R: case MODE_PSK500R:
1881 	case MODE_PSK1000R:
1882 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1883 				  *mode_info[mode].modem = new psk(mode), freq);
1884 		quick_change = quick_change_pskr;
1885 //		modem_config_tab = tabPSK;
1886 		break;
1887 
1888 	case MODE_12X_PSK125 :
1889 	case MODE_6X_PSK250 :
1890 	case MODE_2X_PSK500 :
1891 	case MODE_4X_PSK500 :
1892 	case MODE_2X_PSK800 :
1893 	case MODE_2X_PSK1000 :
1894 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1895 				  *mode_info[mode].modem = new psk(mode), freq);
1896 		quick_change = quick_change_psk_multi;
1897 //		modem_config_tab = tabPSK;
1898 		break;
1899 
1900 	case MODE_4X_PSK63R :
1901 	case MODE_5X_PSK63R :
1902 	case MODE_10X_PSK63R :
1903 	case MODE_20X_PSK63R :
1904 	case MODE_32X_PSK63R :
1905 
1906 	case MODE_4X_PSK125R :
1907 	case MODE_5X_PSK125R :
1908 	case MODE_10X_PSK125R :
1909 	case MODE_12X_PSK125R :
1910 	case MODE_16X_PSK125R :
1911 
1912 	case MODE_2X_PSK250R :
1913 	case MODE_3X_PSK250R :
1914 	case MODE_5X_PSK250R :
1915 	case MODE_6X_PSK250R :
1916 	case MODE_7X_PSK250R :
1917 
1918 	case MODE_2X_PSK500R :
1919 	case MODE_3X_PSK500R :
1920 	case MODE_4X_PSK500R :
1921 
1922 	case MODE_2X_PSK800R :
1923 	case MODE_2X_PSK1000R :
1924 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1925 				  *mode_info[mode].modem = new psk(mode), freq);
1926 		quick_change = quick_change_psk_multiR;
1927 //		modem_config_tab = tabPSK;
1928 		break;
1929 
1930 	case MODE_OLIVIA:
1931 	case MODE_OLIVIA_4_125:
1932 	case MODE_OLIVIA_4_250:
1933 	case MODE_OLIVIA_4_500:
1934 	case MODE_OLIVIA_4_1000:
1935 	case MODE_OLIVIA_4_2000:
1936 	case MODE_OLIVIA_8_125:
1937 	case MODE_OLIVIA_8_250:
1938 	case MODE_OLIVIA_8_500:
1939 	case MODE_OLIVIA_8_1000:
1940 	case MODE_OLIVIA_8_2000:
1941 	case MODE_OLIVIA_16_500:
1942 	case MODE_OLIVIA_16_1000:
1943 	case MODE_OLIVIA_16_2000:
1944 	case MODE_OLIVIA_32_1000:
1945 	case MODE_OLIVIA_32_2000:
1946 	case MODE_OLIVIA_64_500:
1947 	case MODE_OLIVIA_64_1000:
1948 	case MODE_OLIVIA_64_2000:
1949 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1950 				  *mode_info[mode].modem = new olivia(mode), freq);
1951 //		modem_config_tab = tabOlivia;
1952 		quick_change = quick_change_olivia;
1953 		break;
1954 
1955 	case MODE_CONTESTIA:
1956 	case MODE_CONTESTIA_4_125:  case MODE_CONTESTIA_4_250:
1957 	case MODE_CONTESTIA_4_500:  case MODE_CONTESTIA_4_1000:   case MODE_CONTESTIA_4_2000:
1958 	case MODE_CONTESTIA_8_125:  case MODE_CONTESTIA_8_250:
1959 	case MODE_CONTESTIA_8_500:  case MODE_CONTESTIA_8_1000:   case MODE_CONTESTIA_8_2000:
1960 	case MODE_CONTESTIA_16_250:  case MODE_CONTESTIA_16_500:
1961 	case MODE_CONTESTIA_16_1000: case MODE_CONTESTIA_16_2000:
1962 	case MODE_CONTESTIA_32_1000: case MODE_CONTESTIA_32_2000:
1963 	case MODE_CONTESTIA_64_500:  case MODE_CONTESTIA_64_1000: case MODE_CONTESTIA_64_2000:
1964 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1965 				  *mode_info[mode].modem = new contestia(mode), freq);
1966 //		modem_config_tab = tabContestia;
1967 		quick_change = quick_change_contestia;
1968 		break;
1969 
1970 	case MODE_FSQ:
1971 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1972 				  *mode_info[mode].modem = new fsq(mode), freq);
1973 //		modem_config_tab = tabFSQ;
1974 		quick_change = quick_change_fsq;
1975 		break;
1976 
1977 	case MODE_IFKP:
1978 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1979 				  *mode_info[mode].modem = new ifkp(mode), freq);
1980 //		modem_config_tab = tabIFKP;
1981 		quick_change = quick_change_ifkp;
1982 		break;
1983 
1984 	case MODE_RTTY:
1985 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1986 				  *mode_info[mode].modem = new rtty(mode), freq);
1987 //		modem_config_tab = tabRTTY;
1988 
1989 		if (progStatus.nanoFSK_online || progStatus.Nav_online)
1990 			quick_change = 0;
1991 		else
1992 			quick_change = quick_change_rtty;
1993 		break;
1994 
1995 	case MODE_THROB1: case MODE_THROB2: case MODE_THROB4:
1996 	case MODE_THROBX1: case MODE_THROBX2: case MODE_THROBX4:
1997 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
1998 				  *mode_info[mode].modem = new throb(mode), freq);
1999 		quick_change = quick_change_throb;
2000 		break;
2001 
2002 //	case MODE_PACKET:
2003 //		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
2004 //			      *mode_info[mode].modem = new pkt(mode), freq);
2005 //		modem_config_tab = tabNavtex;
2006 //		quick_change = quick_change_pkt;
2007 //		break;
2008 
2009 	case MODE_WWV:
2010 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
2011 				  *mode_info[mode].modem = new wwv, freq);
2012 		break;
2013 
2014 	case MODE_ANALYSIS:
2015 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
2016 				  *mode_info[mode].modem = new anal, freq);
2017 		break;
2018 
2019 	case MODE_FMT:
2020 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
2021 				  *mode_info[mode].modem = new fmt, freq);
2022 		break;
2023 
2024 	case MODE_SSB:
2025 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
2026 				  *mode_info[mode].modem = new ssb, freq);
2027 		break;
2028 
2029 	default:
2030 		LOG_ERROR("Unknown mode: %d", (int)mode);
2031 		mode = MODE_PSK31;
2032 		startup_modem(*mode_info[mode].modem ? *mode_info[mode].modem :
2033 				  *mode_info[mode].modem = new psk(mode), freq);
2034 		quick_change = quick_change_psk;
2035 //		modem_config_tab = tabPSK;
2036 		break;
2037 	}
2038 
2039 #if BENCHMARK_MODE
2040 	return;
2041 #endif
2042 
2043 	clear_StatusMessages();
2044 	progStatus.lastmode = mode;
2045 
2046 	if (wf->xmtlock->value() == 1 && !mailserver) {
2047 		if(!progdefaults.retain_freq_lock) {
2048 			wf->xmtlock->value(0);
2049 			wf->xmtlock->damage();
2050 			active_modem->set_freqlock(false);
2051 		}
2052 	}
2053 
2054 //	if (FD_logged_on) FD_mode_check();
2055 }
2056 
init_modem_sync(trx_mode m,int f)2057 void init_modem_sync(trx_mode m, int f)
2058 {
2059 	ENSURE_THREAD(FLMAIN_TID);
2060 
2061 	int count = 2000;
2062 	if (trx_state != STATE_RX) {
2063 		LOG_INFO("Waiting for %s", mode_info[active_modem->get_mode()].name);
2064 		abort_tx();
2065 		while (trx_state != STATE_RX && count) {
2066 			LOG_DEBUG("%0.2f secs remaining", count / 100.0);
2067 			Fl::awake();
2068 			MilliSleep(10);
2069 			count--;
2070 		}
2071 		if (count == 0) {
2072 			LOG_ERROR("%s", "TIMED OUT!!");
2073 			return;  // abort modem selection
2074 		}
2075 	}
2076 
2077 	init_modem(m, f);
2078 
2079 	count = 500;
2080 	if (trx_state != STATE_RX) {
2081 		while (trx_state != STATE_RX && count) {
2082 			Fl::awake();
2083 			MilliSleep(10);
2084 			count--;
2085 		}
2086 		if (count == 0)
2087 			LOG_ERROR("%s", "Wait for STATE_RX timed out");
2088 	}
2089 
2090 	REQ_FLUSH(TRX_TID);
2091 }
2092 
cb_init_mode(Fl_Widget *,void * mode)2093 void cb_init_mode(Fl_Widget *, void *mode)
2094 {
2095 	init_modem(reinterpret_cast<trx_mode>(mode));
2096 }
2097 
2098 // character set selection menu
2099 
set_charset_listbox(int rxtx_charset)2100 void set_charset_listbox(int rxtx_charset)
2101 {
2102 	int tiniconv_id = charset_list[rxtx_charset].tiniconv_id;
2103 
2104 	// order all converters to switch to the new encoding
2105 	rx_chd.set_input_encoding(tiniconv_id);
2106 	echo_chd.set_input_encoding(tiniconv_id);
2107 	tx_encoder.set_output_encoding(tiniconv_id);
2108 
2109 	if (mainViewer)
2110 		mainViewer->set_input_encoding(tiniconv_id);
2111 	if (brwsViewer)
2112 		brwsViewer->set_input_encoding(tiniconv_id);
2113 
2114 	// update the button
2115 	progdefaults.charset_name = charset_list[rxtx_charset].name;
2116 	listbox_charset_status->value(progdefaults.charset_name.c_str());
2117 	restoreFocus(4);
2118 }
2119 
cb_listbox_charset(Fl_Widget * w,void *)2120 void cb_listbox_charset(Fl_Widget *w, void *)
2121 {
2122 	Fl_ListBox * lbox = (Fl_ListBox *)w;
2123 	set_charset_listbox(lbox->index());
2124 }
2125 
populate_charset_listbox(void)2126 void populate_charset_listbox(void)
2127 {
2128 	for (unsigned int i = 0; i < number_of_charsets; i++)
2129 		listbox_charset_status->add( charset_list[i].name );
2130 	listbox_charset_status->value(progdefaults.charset_name.c_str());
2131 }
2132 
2133 // find the position of the default charset in charset_list[] and trigger the callback
set_default_charset(void)2134 void set_default_charset(void)
2135 {
2136 	for (unsigned int i = 0; i < number_of_charsets; i++) {
2137 		if (strcmp(charset_list[i].name, progdefaults.charset_name.c_str()) == 0) {
2138 			set_charset_listbox(i);
2139 			return;
2140 		}
2141 	}
2142 }
2143 
2144 // if w is not NULL, give focus to TransmitText only if the last event was an Enter keypress
restoreFocus(int n)2145 void restoreFocus(int n)
2146 {
2147 	if (Fl::focus() == NULL) return;
2148 	if (!active_modem) {
2149 		TransmitText->take_focus();
2150 		return;
2151 	}
2152 	if (active_modem->get_mode() == MODE_FSQ && fsq_tx_text)
2153 		fsq_tx_text->take_focus();
2154 	else if (active_modem->get_mode() == MODE_IFKP && ifkp_tx_text)
2155 		ifkp_tx_text->take_focus();
2156 	else if (TransmitText)
2157 		TransmitText->take_focus();
2158 }
2159 
macro_cb(Fl_Widget * w,void * v)2160 void macro_cb(Fl_Widget *w, void *v)
2161 {
2162 //	if (active_modem->get_mode() == MODE_FSQ)
2163 //		return;
2164 
2165 	int b = (int)(reinterpret_cast<long long> (v));
2166 
2167 	if (b & 0x80) { // 4 bar docked macros
2168 		b &= 0x7F;
2169 	} else {
2170 		if (progdefaults.mbar_scheme > MACRO_SINGLE_BAR_MAX) {
2171 			if (b >= NUMMACKEYS) b += (altMacros - 1) * NUMMACKEYS;
2172 		} else {
2173 			b += altMacros * NUMMACKEYS;
2174 		}
2175 	}
2176 
2177 	int mouse = Fl::event_button();
2178 	if (mouse == FL_LEFT_MOUSE && !macros.text[b].empty()) {
2179 		if (progStatus.timer) return;
2180 		stopMacroTimer();
2181 		progStatus.skip_sked_macro = false;
2182 		macros.execute(b);
2183 	}
2184 	else if (mouse == FL_RIGHT_MOUSE)
2185 		editMacro(b);
2186 	if (Fl::focus() != qsoFreqDisp)
2187 		restoreFocus(5);
2188 }
2189 
colorize_48macros(int i)2190 void colorize_48macros(int i)
2191 {
2192 	if (progdefaults.useGroupColors == true) {
2193 		int k = i / 4;
2194 		if (k == 0 || k == 3 || k == 6 || k == 9)
2195 			btnDockMacro[i]->color(fl_rgb_color(
2196 				progdefaults.btnGroup1.R,
2197 				progdefaults.btnGroup1.G,
2198 				progdefaults.btnGroup1.B));
2199 		else if (k == 1 || k == 4 || k == 7 || k == 10)
2200 			btnDockMacro[i]->color(fl_rgb_color(
2201 				progdefaults.btnGroup2.R,
2202 				progdefaults.btnGroup2.G,
2203 				progdefaults.btnGroup2.B));
2204 		else
2205 			btnDockMacro[i]->color(fl_rgb_color(
2206 				progdefaults.btnGroup3.R,
2207 				progdefaults.btnGroup3.G,
2208 				progdefaults.btnGroup3.B));
2209 		btnDockMacro[i]->labelcolor(
2210 			fl_rgb_color(
2211 				progdefaults.btnFkeyTextColor.R,
2212 				progdefaults.btnFkeyTextColor.G,
2213 				progdefaults.btnFkeyTextColor.B ));
2214 		btnDockMacro[i]->labelcolor(progdefaults.MacroBtnFontcolor);
2215 		btnDockMacro[i]->labelfont(progdefaults.MacroBtnFontnbr);
2216 		btnDockMacro[i]->labelsize(progdefaults.MacroBtnFontsize);
2217 	} else {
2218 		btnDockMacro[i]->color(FL_BACKGROUND_COLOR);
2219 		btnDockMacro[i]->labelcolor(FL_FOREGROUND_COLOR);
2220 		btnDockMacro[i]->labelfont(progdefaults.MacroBtnFontnbr);
2221 		btnDockMacro[i]->labelsize(progdefaults.MacroBtnFontsize);
2222 	}
2223 }
2224 
colorize_macro(int i)2225 void colorize_macro(int i)
2226 {
2227 	int j = i % NUMMACKEYS;
2228 	if (progdefaults.useGroupColors == true) {
2229 		if (j < 4) {
2230 			btnMacro[i]->color(fl_rgb_color(
2231 				progdefaults.btnGroup1.R,
2232 				progdefaults.btnGroup1.G,
2233 				progdefaults.btnGroup1.B));
2234 		} else if (j < 8) {
2235 			btnMacro[i]->color(fl_rgb_color(
2236 				progdefaults.btnGroup2.R,
2237 				progdefaults.btnGroup2.G,
2238 				progdefaults.btnGroup2.B));
2239 		} else {
2240 			btnMacro[i]->color(fl_rgb_color(
2241 				progdefaults.btnGroup3.R,
2242 				progdefaults.btnGroup3.G,
2243 				progdefaults.btnGroup3.B));
2244 		}
2245 		btnMacro[i]->labelcolor(
2246 			fl_rgb_color(
2247 				progdefaults.btnFkeyTextColor.R,
2248 				progdefaults.btnFkeyTextColor.G,
2249 				progdefaults.btnFkeyTextColor.B ));
2250 		btnMacro[i]->labelcolor(progdefaults.MacroBtnFontcolor);
2251 		btnMacro[i]->labelfont(progdefaults.MacroBtnFontnbr);
2252 		btnMacro[i]->labelsize(progdefaults.MacroBtnFontsize);
2253 	} else {
2254 		btnMacro[i]->color(FL_BACKGROUND_COLOR);
2255 		btnMacro[i]->labelcolor(FL_FOREGROUND_COLOR);
2256 		btnMacro[i]->labelfont(progdefaults.MacroBtnFontnbr);
2257 		btnMacro[i]->labelsize(progdefaults.MacroBtnFontsize);
2258 	}
2259 	btnMacro[i]->redraw_label();
2260 }
2261 
colorize_macros()2262 void colorize_macros()
2263 {
2264 	for (int i = 0; i < NUMMACKEYS * NUMKEYROWS; i++) colorize_macro(i);
2265 	for (int i = 0; i < 48; i++) colorize_48macros(i);
2266 	btnAltMacros1->labelsize(progdefaults.MacroBtnFontsize);
2267 	btnAltMacros1->redraw_label();
2268 	btnAltMacros2->labelsize(progdefaults.MacroBtnFontsize);
2269 	btnAltMacros2->redraw_label();
2270 }
2271 
altmacro_cb(Fl_Widget * w,void * v)2272 void altmacro_cb(Fl_Widget *w, void *v)
2273 {
2274 	static char alt_text[2] = "1";
2275 
2276 	intptr_t arg = reinterpret_cast<intptr_t>(v);
2277 	if (arg)
2278 		altMacros += arg;
2279 	else
2280 		altMacros = altMacros + (Fl::event_button() == FL_RIGHT_MOUSE ? -1 : 1);
2281 
2282 	if (progdefaults.mbar_scheme > MACRO_SINGLE_BAR_MAX) { // alternate set
2283 		altMacros = WCLAMP(altMacros, 1, 3);
2284 		alt_text[0] = '1' + altMacros;
2285 		for (int i = 0; i < NUMMACKEYS; i++) {
2286 			btnMacro[i + NUMMACKEYS]->label(macros.name[i + (altMacros * NUMMACKEYS)].c_str());
2287 			btnMacro[i + NUMMACKEYS]->redraw_label();
2288 		}
2289 		btnAltMacros2->label(alt_text);
2290 		btnAltMacros2->redraw_label();
2291 	} else { // primary set
2292 		altMacros = WCLAMP(altMacros, 0, 3);
2293 		alt_text[0] = '1' + altMacros;
2294 		for (int i = 0; i < NUMMACKEYS; i++) {
2295 			btnMacro[i]->label(macros.name[i + (altMacros * NUMMACKEYS)].c_str());
2296 			btnMacro[i]->redraw_label();
2297 		}
2298 		btnAltMacros1->label(alt_text);
2299 		btnAltMacros1->redraw_label();
2300 	}
2301 	restoreFocus(6);
2302 }
2303 
cb_mnuConfigNotify(Fl_Menu_ *,void *)2304 void cb_mnuConfigNotify(Fl_Menu_*, void*)
2305 {
2306 	notify_show();
2307 }
2308 
cb_mnuTestSignals(Fl_Menu_ *,void *)2309 void cb_mnuTestSignals(Fl_Menu_*, void*)
2310 {
2311 	show_testdialog();
2312 }
2313 
cb_mnuConfigModems(Fl_Menu_ *,void *)2314 void cb_mnuConfigModems(Fl_Menu_*, void*) {
2315 	switch (active_modem->get_mode()) {
2316 		case MODE_CW:
2317 			open_config(TAB_CW);
2318 			break;
2319 		case MODE_THORMICRO: case MODE_THOR4: case MODE_THOR5: case MODE_THOR8:
2320 		case MODE_THOR11:case MODE_THOR16: case MODE_THOR22:
2321 		case MODE_THOR25x4: case MODE_THOR50x1: case MODE_THOR50x2: case MODE_THOR100:
2322 			open_config(TAB_THOR);
2323 			break;
2324 		case MODE_DOMINOEXMICRO: case MODE_DOMINOEX4: case MODE_DOMINOEX5: case MODE_DOMINOEX8:
2325 		case MODE_DOMINOEX11: case MODE_DOMINOEX16: case MODE_DOMINOEX22:
2326 		case MODE_DOMINOEX44: case MODE_DOMINOEX88:
2327 			open_config(TAB_DOMINOEX);
2328 			break;
2329 		case MODE_FELDHELL: case MODE_SLOWHELL: case MODE_HELLX5: case MODE_HELLX9:
2330 		case MODE_FSKH245: case MODE_FSKH105:case MODE_HELL80:
2331 			open_config(TAB_FELDHELL);
2332 			break;
2333 		case MODE_WEFAX_576: case MODE_WEFAX_288:
2334 			open_config(TAB_WEFAX);
2335 			break;
2336 		case MODE_NAVTEX: case MODE_SITORB:
2337 			open_config(TAB_NAVTEX);
2338 			break;
2339 		case MODE_MT63_500S: case MODE_MT63_1000S: case MODE_MT63_2000S :
2340 		case MODE_MT63_500L: case MODE_MT63_1000L: case MODE_MT63_2000L :
2341 			quick_change = quick_change_mt63;
2342 			open_config(TAB_MT63);
2343 			break;
2344 		case MODE_OLIVIA:
2345 		case MODE_OLIVIA_4_125:   case MODE_OLIVIA_4_250:   case MODE_OLIVIA_4_500:
2346 		case MODE_OLIVIA_4_1000:  case MODE_OLIVIA_4_2000:
2347 		case MODE_OLIVIA_8_125:   case MODE_OLIVIA_8_250:   case MODE_OLIVIA_8_500:
2348 		case MODE_OLIVIA_8_1000:  case MODE_OLIVIA_8_2000:
2349 		case MODE_OLIVIA_16_500:  case MODE_OLIVIA_16_1000: case MODE_OLIVIA_16_2000:
2350 		case MODE_OLIVIA_32_1000: case MODE_OLIVIA_32_2000:
2351 		case MODE_OLIVIA_64_500:  case MODE_OLIVIA_64_1000: case MODE_OLIVIA_64_2000:
2352 			open_config(TAB_OLIVIA);
2353 			break;
2354 		case MODE_CONTESTIA:
2355 		case MODE_CONTESTIA_4_125:   case MODE_CONTESTIA_4_250:   case MODE_CONTESTIA_4_500:
2356 		case MODE_CONTESTIA_4_1000:  case MODE_CONTESTIA_4_2000:
2357 		case MODE_CONTESTIA_8_125:   case MODE_CONTESTIA_8_250:   case MODE_CONTESTIA_8_500:
2358 		case MODE_CONTESTIA_8_1000:  case MODE_CONTESTIA_8_2000:
2359 		case MODE_CONTESTIA_16_250:  case MODE_CONTESTIA_16_500:
2360 		case MODE_CONTESTIA_16_1000: case MODE_CONTESTIA_16_2000:
2361 		case MODE_CONTESTIA_32_1000: case MODE_CONTESTIA_32_2000:
2362 		case MODE_CONTESTIA_64_500:  case MODE_CONTESTIA_64_1000: case MODE_CONTESTIA_64_2000:
2363 			open_config(TAB_CONTESTIA);
2364 			break;
2365 		case MODE_FSQ:
2366 			open_config(TAB_FSQ);
2367 			break;
2368 		case MODE_IFKP:
2369 			open_config(TAB_IFKP);
2370 			break;
2371 		case MODE_RTTY:
2372 			open_config(TAB_RTTY);
2373 			break;
2374 		default:
2375 			open_config(TAB_PSK);
2376 			break;
2377 	}
2378 }
2379 
2380 /*
2381 void cb_mnuConfigWinkeyer(Fl_Menu_*, void*) {
2382 	open_config(TAB_CW);
2383 }
2384 
2385 void cb_mnuConfigWFcontrols(Fl_Menu_ *, void*) {
2386 	open_config(TAB_UI_WATERFALL);
2387 }
2388 
2389 void cb_n3fjp_logs(Fl_Menu_ *, void*) {
2390 	open_config(TAB_UI_N3FJP);
2391 }
2392 
2393 void cb_maclogger(Fl_Menu_ *, void*) {
2394 	open_config(TAB_UI_MACLOGGER);
2395 }
2396 */
2397 
cb_mnuConfigLoTW(Fl_Menu_ *,void *)2398 void cb_mnuConfigLoTW(Fl_Menu_ *, void *) {
2399 	open_config(TAB_LOG_LOTW);
2400 }
2401 
cb_logfile(Fl_Widget * w,void *)2402 void cb_logfile(Fl_Widget* w, void*)
2403 {
2404 	progStatus.LOGenabled = reinterpret_cast<Fl_Menu_*>(w)->mvalue()->value();
2405 	if (progStatus.LOGenabled == true) {
2406 		Date tdy;
2407 		string lfname = HomeDir;
2408 		lfname.append("fldigi");
2409 		lfname.append(tdy.szDate(2));
2410 		lfname.append(".log");
2411 	   	logfile = new cLogfile(lfname);
2412 		logfile->log_to_file_start();
2413 	} else {
2414 		logfile->log_to_file_stop();
2415 		delete logfile;
2416 		logfile = 0;
2417 	}
2418 }
2419 
2420 
2421 // LOGBOOK server connect
cb_log_server(Fl_Widget * w,void *)2422 void cb_log_server(Fl_Widget* w, void*)
2423 {
2424 	progdefaults.xml_logbook = reinterpret_cast<Fl_Menu_*>(w)->mvalue()->value();
2425 	close_logbook();
2426 	connect_to_log_server();
2427 }
2428 
cb_fd_viewer(Fl_Widget * w,void *)2429 void cb_fd_viewer(Fl_Widget* w, void*)
2430 {
2431 	if (field_day_viewer->visible())
2432 		field_day_viewer->hide();
2433 	else
2434 		field_day_viewer->show();
2435 }
2436 
cb_dxc_viewer(Fl_Widget * w,void *)2437 void cb_dxc_viewer(Fl_Widget* w, void*)
2438 {
2439 	if (dxcluster_viewer->visible())
2440 		dxcluster_viewer->hide();
2441 	else
2442 		dxcluster_viewer->show();
2443 }
2444 
set_server_label(bool val)2445 void set_server_label(bool val)
2446 {
2447 	Fl_Menu_Item *m = getMenuItem(LOG_CONNECT_SERVER);
2448 	if (val) m->set();
2449 	else m->clear();
2450 }
2451 
2452 static int save_mvx = 0;
2453 
cb_view_hide_channels(Fl_Menu_ * w,void * d)2454 void cb_view_hide_channels(Fl_Menu_ *w, void *d)
2455 {
2456 	int mvgw = mvgroup->w();
2457 
2458 	progStatus.show_channels = !(mvgw > mvgroup->x());
2459 
2460 	if (!progStatus.show_channels) {
2461 		save_mvx = mvgw;
2462 		progStatus.tile_x = mvgroup->x();
2463 	} else {
2464 		progStatus.tile_x = save_mvx;
2465 	}
2466 
2467 	if (progdefaults.rxtx_swap) {
2468 		progStatus.tile_y = TransmitText->h();
2469 		progStatus.tile_y_ratio = 1.0 * TransmitText->h() / text_panel->h();
2470 	} else {
2471 		progStatus.tile_y = ReceiveText->h();
2472 		progStatus.tile_y_ratio = 1.0 * ReceiveText->h() / text_panel->h();
2473 	}
2474 	UI_select();
2475 	return;
2476 }
2477 
2478 
2479 static bool capval = false;
2480 static bool genval = false;
2481 static bool playval = false;
2482 
cb_mnuCapture(Fl_Widget * w,void * d)2483 void cb_mnuCapture(Fl_Widget *w, void *d)
2484 {
2485 	if (!RXscard) return;
2486 	Fl_Menu_Item *m = getMenuItem(((Fl_Menu_*)w)->mvalue()->label()); //eek
2487 	if (playval || genval) {
2488 		m->clear();
2489 		return;
2490 	}
2491 	capval = m->value();
2492 
2493 	if (!m->value()) {
2494 		RXscard->stopCapture();
2495 		return;
2496 	}
2497 
2498 	std::string fname;
2499 	int format;
2500 	SND_SUPPORT::get_file_params("capture", fname, format, true);
2501 	if (fname.empty()) {
2502 		m->clear();
2503 		capval = 0;
2504 		return;
2505 	}
2506 
2507 	if(!RXscard->startCapture(fname, format)) {
2508 		m->clear();
2509 		capval = false;
2510 	}
2511 }
2512 
cb_mnuGenerate(Fl_Widget * w,void * d)2513 void cb_mnuGenerate(Fl_Widget *w, void *d)
2514 {
2515 	Fl_Menu_Item *m = getMenuItem(((Fl_Menu_*)w)->mvalue()->label());
2516 	if (capval || playval) {
2517 		m->clear();
2518 		return;
2519 	}
2520 	if (!TXscard) return;
2521 	genval = m->value();
2522 
2523 	if (!genval) {
2524 		TXscard->stopGenerate();
2525 		return;
2526 	}
2527 
2528 	std::string fname;
2529 	int format;
2530 	SND_SUPPORT::get_file_params("generate", fname, format, true);
2531 	if (fname.empty()) {
2532 		m->clear();
2533 		genval = 0;
2534 		return;
2535 	}
2536 
2537 	if (!TXscard->startGenerate(fname, format)) {
2538 		m->clear();
2539 		genval = false;
2540 	}
2541 }
2542 
2543 Fl_Menu_Item *Playback_menu_item = (Fl_Menu_Item *)0;
reset_mnuPlayback()2544 void reset_mnuPlayback()
2545 {
2546 	if (Playback_menu_item == 0) return;
2547 	Playback_menu_item->clear();
2548 	playval = false;
2549 }
2550 
cb_mnuPlayback(Fl_Widget * w,void * d)2551 void cb_mnuPlayback(Fl_Widget *w, void *d)
2552 {
2553 	if (!RXscard) return;
2554 	Fl_Menu_Item *m = getMenuItem(((Fl_Menu_*)w)->mvalue()->label());
2555 	Playback_menu_item = m;
2556 	if (capval || genval) {
2557 		m->clear();
2558 		bHighSpeed = false;
2559 		return;
2560 	}
2561 	playval = m->value();
2562 	if (!playval) {
2563 		bHighSpeed = false;
2564 		RXscard->stopPlayback();
2565 		return;
2566 	}
2567 
2568 	std::string fname;
2569 	int format;
2570 	SND_SUPPORT::get_file_params("playback", fname, format, false);
2571 
2572 	if (fname.empty()) {
2573 		m->clear();
2574 		playval = 0;
2575 		return;
2576 	}
2577 
2578 	progdefaults.loop_playback = fl_choice2(_("Playback continuous loop?"), _("No"), _("Yes"), NULL);
2579 
2580 	int err = RXscard->startPlayback(fname, format);
2581 
2582 	if(err) {
2583 		fl_alert2(_("Unsupported audio format"));
2584 		m->clear();
2585 		playval = false;
2586 		bHighSpeed = false;
2587 		progdefaults.loop_playback = false;
2588 	}
2589 	else if (btnAutoSpot->value()) {
2590 		put_status(_("Spotting disabled"), 3.0);
2591 		btnAutoSpot->value(0);
2592 		btnAutoSpot->do_callback();
2593 	}
2594 }
2595 
2596 bool first_tab_select = true;
2597 
cb_mnu_config_dialog(Fl_Menu_ *,void *)2598 void cb_mnu_config_dialog(Fl_Menu_*, void*)
2599 {
2600 	if (first_tab_select) {
2601 		select_tab_tree(TAB_STATION);
2602 		first_tab_select = false;
2603 	}
2604 	dlgConfig->show();
2605 }
2606 
cb_mnuSaveConfig(Fl_Menu_ *,void *)2607 void cb_mnuSaveConfig(Fl_Menu_ *, void *) {
2608 	progdefaults.saveDefaults();
2609 	restoreFocus(7);
2610 }
2611 
2612 // This function may be called by the QRZ thread
cb_mnuVisitURL(Fl_Widget *,void * arg)2613 void cb_mnuVisitURL(Fl_Widget*, void* arg)
2614 {
2615 	const char* url = reinterpret_cast<const char *>(arg);
2616 #ifndef __WOE32__
2617 	const char* browsers[] = {
2618 #  ifdef __APPLE__
2619 		getenv("FLDIGI_BROWSER"), // valid for any OS - set by user
2620 		"open"                    // OS X
2621 #  else
2622 		"fl-xdg-open",            // Puppy Linux
2623 		"xdg-open",               // other Unix-Linux distros
2624 		getenv("FLDIGI_BROWSER"), // force use of spec'd browser
2625 		getenv("BROWSER"),        // most Linux distributions
2626 		"sensible-browser",
2627 		"firefox",
2628 		"mozilla"                 // must be something out there!
2629 #  endif
2630 	};
2631 	switch (fork()) {
2632 	case 0:
2633 #  ifndef NDEBUG
2634 		unsetenv("MALLOC_CHECK_");
2635 		unsetenv("MALLOC_PERTURB_");
2636 #  endif
2637 		for (size_t i = 0; i < sizeof(browsers)/sizeof(browsers[0]); i++)
2638 			if (browsers[i])
2639 				execlp(browsers[i], browsers[i], url, (char*)0);
2640 		exit(EXIT_FAILURE);
2641 	case -1:
2642 		fl_alert2(_("Could not run a web browser:\n%s\n\n"
2643 			 "Open this URL manually:\n%s"),
2644 			 strerror(errno), url);
2645 	}
2646 #else
2647 	// gurgle... gurgle... HOWL
2648 	// "The return value is cast as an HINSTANCE for backward
2649 	// compatibility with 16-bit Windows applications. It is
2650 	// not a true HINSTANCE, however. The only thing that can
2651 	// be done with the returned HINSTANCE is to cast it to an
2652 	// int and compare it with the value 32 or one of the error
2653 	// codes below." (Error codes omitted to preserve sanity).
2654 	if ((INT_PTR)ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL) <= 32)
2655 		fl_alert2(_("Could not open url:\n%s\n"), url);
2656 #endif
2657 }
2658 
open_recv_folder(const char * folder)2659 void open_recv_folder(const char *folder)
2660 {
2661 	cb_mnuVisitURL(0, (void*)folder);
2662 }
2663 
cb_mnuVisitPSKRep(Fl_Widget *,void *)2664 void cb_mnuVisitPSKRep(Fl_Widget*, void*)
2665 {
2666 	cb_mnuVisitURL(0, (void*)string("http://pskreporter.info/pskmap?").append(progdefaults.myCall).c_str());
2667 }
2668 
html_help(const string & Html)2669 void html_help( const string &Html)
2670 {
2671 	if (!help_dialog)
2672 		help_dialog = new Fl_Help_Dialog;
2673 	help_dialog->value(Html.c_str());
2674 	help_dialog->show();
2675 }
2676 
cb_mnuBeginnersURL(Fl_Widget *,void *)2677 void cb_mnuBeginnersURL(Fl_Widget*, void*)
2678 {
2679 	string deffname = HelpDir;
2680 	deffname.append("beginners.html");
2681 	ofstream f(deffname.c_str());
2682 	if (!f)
2683 		return;
2684 	f << szBeginner;
2685 	f.close();
2686 #ifndef __WOE32__
2687 	cb_mnuVisitURL(NULL, (void *)deffname.insert(0, "file://").c_str());
2688 #else
2689 	cb_mnuVisitURL(NULL, (void *)deffname.c_str());
2690 #endif
2691 }
2692 
cb_mnuOnLineDOCS(Fl_Widget *,void *)2693 void cb_mnuOnLineDOCS(Fl_Widget *, void *)
2694 {
2695 	string helpfile = HelpDir;
2696 	helpfile.append("fldigi-help/index.html");
2697 	ifstream f(helpfile.c_str());
2698 	if (!f) {
2699 		cb_mnuVisitURL(0, (void *)PACKAGE_DOCS);
2700 	} else {
2701 		f.close();
2702 		cb_mnuVisitURL(0, (void *)helpfile.c_str());
2703 	}
2704 }
2705 
version_check(string v1,string v2)2706 inline int version_check(string v1, string v2) {
2707 
2708 	long v1a, v1b, v1c;
2709 	long v2a, v2b, v2c;
2710 	size_t p;
2711 
2712 	v1a = atol(v1.c_str()); p = v1.find("."); v1.erase(0, p + 1);
2713 	v1b = atol(v1.c_str()); p = v1.find("."); v1.erase(0, p + 1);
2714 	v1c = atol(v1.c_str()); p = v1.find("."); v1.erase(0, p + 1);
2715 
2716 	v2a = atol(v2.c_str()); p = v2.find("."); v2.erase(0, p + 1);
2717 	v2b = atol(v2.c_str()); p = v2.find("."); v2.erase(0, p + 1);
2718 	v2c = atol(v2.c_str()); p = v2.find("."); v2.erase(0, p + 1);
2719 
2720 	long l1, l2;
2721 	l1 = v1a * 10000 + v1b * 100 + v1c;
2722 	l2 = v2a * 10000 + v2b * 100 + v2c;
2723 
2724 	if (l1 < l2) return -1;
2725 	if (l1 > l2) return 1;
2726 	if (v1 == v2) return 0;
2727 	return 1;
2728 }
2729 
2730 static notify_dialog *latest_dialog = 0;
cb_mnuCheckUpdate(Fl_Widget *,void *)2731 void cb_mnuCheckUpdate(Fl_Widget *, void *)
2732 {
2733 	const char *url = "http://www.w1hkj.com/files/fldigi/";
2734 
2735 	string version_str;
2736 	string reply;
2737 
2738 	put_status(_("Checking for updates..."));
2739 
2740 	int ret = get_http(url, reply, 20.0);
2741 	if (!ret) {
2742 		put_status(_("Update site not available"), 10);
2743 		return;
2744 	}
2745 
2746 	size_t p = reply.find("_setup.exe");
2747 	size_t p2 = reply.rfind("fldigi", p);
2748 	p2 += 7;
2749 	version_str = reply.substr(p2, p - p2);
2750 	int is_ok = version_check(string(PACKAGE_VERSION), version_str);
2751 
2752 	if (!latest_dialog) latest_dialog = new notify_dialog;
2753 	if (is_ok == 0) {
2754 		latest_dialog->notify(_("You are running the latest version"), 5.0);
2755 		REQ(show_notifier, latest_dialog);
2756 	} else if (is_ok > 0) {
2757 		std::string probable;
2758 		probable.assign(_("You are probably running an alpha version "));
2759 		probable.append( PACKAGE_VERSION ).append(_("\nPosted version: "));
2760 		probable.append(version_str);
2761 		latest_dialog->notify(probable.c_str(), 5.0);
2762 		REQ(show_notifier, latest_dialog);
2763 	} else
2764 		fl_message2(_("Version %s is available at Source Forge"),
2765 				  version_str.c_str());
2766 
2767 	put_status("");
2768 }
2769 
cb_mnuAboutURL(Fl_Widget *,void *)2770 void cb_mnuAboutURL(Fl_Widget*, void*)
2771 {
2772 	if (!help_dialog)
2773 		help_dialog = new Fl_Help_Dialog;
2774 	help_dialog->value(szAbout);
2775 	help_dialog->resize(help_dialog->x(), help_dialog->y(), help_dialog->w(), 440);
2776 	help_dialog->show();
2777 }
2778 
fldigi_help(const string & theHelp)2779 void fldigi_help(const string& theHelp)
2780 {
2781 	string htmlHelp =
2782 "<HTML>"
2783 "<HEAD>"
2784 "<TITLE>" PACKAGE " Help</TITLE>"
2785 "</HEAD>"
2786 "<BODY>"
2787 "<FONT FACE=fixed>"
2788 "<P><TT>";
2789 
2790 	for (size_t i = 0; i < theHelp.length(); i++) {
2791 		if (theHelp[i] == '\n') {
2792 			if (theHelp[i+1] == '\n') {
2793 				htmlHelp += "</TT></P><P><TT>";
2794 				i++;
2795 			}
2796 			else
2797 				htmlHelp += "<BR>";
2798 		} else if (theHelp[i] == ' ' && theHelp[i+1] == ' ') {
2799 			htmlHelp += "&nbsp;&nbsp;";
2800 			i++;
2801 		} else
2802 			htmlHelp += theHelp[i];
2803 	}
2804 	htmlHelp +=
2805 "</TT></P>"
2806 "</BODY>"
2807 "</HTML>";
2808 	html_help(htmlHelp);
2809 }
2810 
cb_mnuCmdLineHelp(Fl_Widget *,void *)2811 void cb_mnuCmdLineHelp(Fl_Widget*, void*)
2812 {
2813 	extern string option_help;
2814 	fldigi_help(option_help);
2815 	restoreFocus(8);
2816 }
2817 
cb_mnuBuildInfo(Fl_Widget *,void *)2818 void cb_mnuBuildInfo(Fl_Widget*, void*)
2819 {
2820 	extern string build_text;
2821 	fldigi_help(build_text);
2822 	restoreFocus(9);
2823 }
2824 
cb_mnuDebug(Fl_Widget *,void *)2825 void cb_mnuDebug(Fl_Widget*, void*)
2826 {
2827 	debug::show();
2828 }
2829 
2830 #ifndef NDEBUG
cb_mnuFun(Fl_Widget *,void *)2831 void cb_mnuFun(Fl_Widget*, void*)
2832 {
2833 		fl_message2(_("Sunspot creation underway!"));
2834 }
2835 #endif
2836 
cb_mnuAudioInfo(Fl_Widget *,void *)2837 void cb_mnuAudioInfo(Fl_Widget*, void*)
2838 {
2839 		if (progdefaults.btnAudioIOis != SND_IDX_PORT) {
2840 				fl_alert2(_("Audio device information is only available for the PortAudio backend"));
2841 				return;
2842 		}
2843 
2844 #if USE_PORTAUDIO
2845 	size_t ndev;
2846 		string devtext[2], headers[2];
2847 	SoundPort::devices_info(devtext[0], devtext[1]);
2848 	if (devtext[0] != devtext[1]) {
2849 		headers[0] = _("Capture device");
2850 		headers[1] = _("Playback device");
2851 		ndev = 2;
2852 	}
2853 	else {
2854 		headers[0] = _("Capture and playback devices");
2855 		ndev = 1;
2856 	}
2857 
2858 	string audio_info;
2859 	for (size_t i = 0; i < ndev; i++) {
2860 		audio_info.append("<center><h4>").append(headers[i]).append("</h4>\n<table border=\"1\">\n");
2861 
2862 		string::size_type j, n = 0;
2863 		while ((j = devtext[i].find(": ", n)) != string::npos) {
2864 			audio_info.append("<tr>")
2865 				  .append("<td align=\"center\">")
2866 				  .append(devtext[i].substr(n, j-n))
2867 				  .append("</td>");
2868 
2869 			if ((n = devtext[i].find('\n', j)) == string::npos) {
2870 				devtext[i] += '\n';
2871 				n = devtext[i].length() - 1;
2872 			}
2873 
2874 			audio_info.append("<td align=\"center\">")
2875 				  .append(devtext[i].substr(j+2, n-j-2))
2876 				  .append("</td>")
2877 				  .append("</tr>\n");
2878 		}
2879 		audio_info.append("</table></center><br>\n");
2880 	}
2881 
2882 	fldigi_help(audio_info);
2883 #endif
2884 }
2885 
cb_ShowConfig(Fl_Widget *,void *)2886 void cb_ShowConfig(Fl_Widget*, void*)
2887 {
2888 	cb_mnuVisitURL(0, (void*)HomeDir.c_str());
2889 }
2890 
cb_ShowDATA(Fl_Widget *,void *)2891 static void cb_ShowDATA(Fl_Widget*, void*)
2892 {
2893 	/// Must be already created by createRecordLoader()
2894 	dlgRecordLoader->show();
2895 }
2896 
ask_dir_creation(const std::string & dir)2897 bool ask_dir_creation( const std::string & dir )
2898 {
2899 	if ( 0 == directory_is_created(dir.c_str())) {
2900 		int ans = fl_choice2(_("%s: Do not exist, create?"), _("No"), _("Yes"), 0, dir.c_str() );
2901 		if (!ans) return false ;
2902 		return true ;
2903 	}
2904 	return false ;
2905 }
2906 
cb_ShowNBEMS(Fl_Widget *,void *)2907 void cb_ShowNBEMS(Fl_Widget*, void*)
2908 {
2909 	if ( ask_dir_creation(NBEMS_dir)) {
2910 		check_nbems_dirs();
2911 	}
2912 	cb_mnuVisitURL(0, (void*)NBEMS_dir.c_str());
2913 }
2914 
cb_ShowFLMSG(Fl_Widget *,void *)2915 void cb_ShowFLMSG(Fl_Widget*, void*)
2916 {
2917 	if ( ask_dir_creation(FLMSG_dir)) {
2918 		check_nbems_dirs();
2919 	}
2920 	cb_mnuVisitURL(0, (void*)FLMSG_dir.c_str());
2921 }
2922 
cb_ShowWEFAX_images(Fl_Widget *,void *)2923 void cb_ShowWEFAX_images(Fl_Widget*, void*)
2924 {
2925 	if (progdefaults.wefax_save_dir.empty())
2926 		cb_mnuVisitURL(0, (void*)PicsDir.c_str());
2927 	else
2928 		cb_mnuVisitURL(0, (void*)progdefaults.wefax_save_dir.c_str());
2929 }
2930 
cbTune(Fl_Widget * w,void *)2931 void cbTune(Fl_Widget *w, void *) {
2932 	Fl_Button *b = (Fl_Button *)w;
2933 	if (!(active_modem->get_cap() & modem::CAP_TX)) {
2934 		b->value(0);
2935 		return;
2936 	}
2937 	if (b->value() == 1) {
2938 		b->labelcolor(FL_RED);
2939 		trx_tune();
2940 	} else {
2941 		b->labelcolor(FL_FOREGROUND_COLOR);
2942 		trx_receive();
2943 	}
2944 	restoreFocus(10);
2945 }
2946 
cb_quick_rsid(Fl_Widget * w,void *)2947 void cb_quick_rsid (Fl_Widget *w, void *)
2948 {
2949 	progdefaults.rsidWideSearch = !progdefaults.rsidWideSearch;
2950 	if (progdefaults.rsidWideSearch) chkRSidWideSearch->set();
2951 	else chkRSidWideSearch->clear();
2952 }
2953 
2954 static Fl_Menu_Item quick_change_rsid[] = {
2955 	{ "Passband", 0, cb_quick_rsid, 0, FL_MENU_TOGGLE },
2956 	{0,0,0,0,0,0,0,0,0}
2957 };
2958 
cbRSID(Fl_Widget * w,void *)2959 void cbRSID(Fl_Widget *w, void *)
2960 {
2961 	if (Fl::focus() != btnRSID) {
2962 		progdefaults.rsid = btnRSID->value();
2963 		btnRSID->redraw();
2964 		return;
2965 	}
2966 
2967 	switch (Fl::event_button()) {
2968 	case FL_LEFT_MOUSE:
2969 		progdefaults.rsid = btnRSID->value();
2970 		progdefaults.changed = true;
2971 		break;
2972 	case FL_RIGHT_MOUSE:
2973 	{
2974 		btnRSID->value(progdefaults.rsid);
2975 		btnRSID->redraw();
2976 		if (progdefaults.rsidWideSearch) quick_change_rsid[0].set();
2977 		else quick_change_rsid[0].clear();
2978 		const Fl_Menu_Item *m =
2979 			quick_change_rsid->popup(
2980 				btnRSID->x(),
2981 				btnRSID->y() + btnRSID->h());
2982 		if (m && m->callback()) m->do_callback(0);
2983 		break;
2984 	}
2985 	default:
2986 		break;
2987 	}
2988 
2989 	Fl_Color clr = progdefaults.rsidWideSearch ? progdefaults.RxIDwideColor : progdefaults.RxIDColor;
2990 	btnRSID->selection_color(clr);
2991 	btnRSID->redraw();
2992 	restoreFocus(11);
2993 }
2994 
cbTxRSID(Fl_Widget * w,void *)2995 void cbTxRSID(Fl_Widget *w, void*)
2996 {
2997 	progdefaults.TransmitRSid = btnTxRSID->value();
2998 	if (Fl::focus() != btnTxRSID) {
2999 		btnTxRSID->redraw();
3000 		return;
3001 	}
3002 	progdefaults.changed = true;
3003 	restoreFocus(12);
3004 }
3005 
cbAutoSpot(Fl_Widget * w,void *)3006 void cbAutoSpot(Fl_Widget* w, void*)
3007 {
3008 	progStatus.spot_recv = static_cast<Fl_Light_Button*>(w)->value();
3009 }
3010 
toggleRSID()3011 void toggleRSID()
3012 {
3013 	progdefaults.rsid = !progdefaults.rsid;
3014 	cbRSID(NULL, NULL);
3015 }
3016 
3017 static notify_dialog *rx_monitor_alert = 0;
cb_mnuRxAudioDialog(Fl_Menu_ * w,void * d)3018 void cb_mnuRxAudioDialog(Fl_Menu_ *w, void *d) {
3019 	if (!progdefaults.enable_audio_alerts) {
3020 		if (!rx_monitor_alert) rx_monitor_alert = new notify_dialog;
3021 		rx_monitor_alert->notify("Audio-Alert / Rx-Monitor device NOT enabled", 10.0);
3022 		show_notifier(rx_monitor_alert);
3023 		return;
3024 	}
3025 	if (rxaudio_dialog)
3026 		rxaudio_dialog->show();
3027 }
3028 
cb_mnuDigiscope(Fl_Menu_ * w,void * d)3029 void cb_mnuDigiscope(Fl_Menu_ *w, void *d) {
3030 	if (scopeview)
3031 		scopeview->show();
3032 }
3033 
cb_mnuViewer(Fl_Menu_ *,void *)3034 void cb_mnuViewer(Fl_Menu_ *, void *) {
3035 	openViewer();
3036 }
3037 
cb_mnuSpectrum(Fl_Menu_ *,void *)3038 void cb_mnuSpectrum (Fl_Menu_ *, void *) {
3039 	open_spectrum_viewer();
3040 }
3041 
cb_mnuShowCountries(Fl_Menu_ *,void *)3042 void cb_mnuShowCountries(Fl_Menu_ *, void *)
3043 {
3044 	notify_dxcc_show();
3045 }
3046 
set_macroLabels()3047 void set_macroLabels()
3048 {
3049 	if (bWF_only) return;
3050 	if (progdefaults.mbar_scheme > MACRO_SINGLE_BAR_MAX) {
3051 		altMacros = 1;
3052 		for (int i = 0; i < NUMMACKEYS; i++) {
3053 			btnMacro[i]->label(macros.name[i].c_str());
3054 			btnMacro[i]->redraw_label();
3055 			btnMacro[NUMMACKEYS + i]->label(
3056 				macros.name[(altMacros * NUMMACKEYS) + i].c_str());
3057 			btnMacro[NUMMACKEYS + i]->redraw_label();
3058 		}
3059 		btnAltMacros1->label("1");
3060 		btnAltMacros1->redraw_label();
3061 		btnAltMacros2->label("2");
3062 		btnAltMacros2->redraw_label();
3063 	} else {
3064 		altMacros = 0;
3065 		btnAltMacros1->label("1");
3066 		btnAltMacros1->redraw_label();
3067 		for (int i = 0; i < NUMMACKEYS; i++) {
3068 			btnMacro[i]->label(macros.name[i].c_str());
3069 			btnMacro[i]->redraw_label();
3070 		}
3071 	}
3072 	for (int i = 0; i < 48; i++) {
3073 		btnDockMacro[i]->label(macros.name[i].c_str());
3074 		btnDockMacro[i]->redraw_label();
3075 	}
3076 }
3077 
cb_mnuPicViewer(Fl_Menu_ *,void *)3078 void cb_mnuPicViewer(Fl_Menu_ *, void *) {
3079 	if (picRxWin) {
3080 		picRx->redraw();
3081 		picRxWin->show();
3082 	}
3083 }
3084 
cb_mnuThorViewRaw(Fl_Menu_ *,void *)3085 void cb_mnuThorViewRaw(Fl_Menu_ *, void *) {
3086 	thor_load_raw_video();
3087 }
3088 
cb_mnuIfkpViewRaw(Fl_Menu_ *,void *)3089 void cb_mnuIfkpViewRaw(Fl_Menu_ *, void *) {
3090 	ifkp_load_raw_video();
3091 }
3092 
cb_sldrSquelch(Fl_Slider * o,void *)3093 void cb_sldrSquelch(Fl_Slider* o, void*) {
3094 
3095 	if (progdefaults.show_psm_btn && progStatus.kpsql_enabled) {
3096 		progStatus.sldrPwrSquelchValue = o->value();
3097 	} else {
3098 		progStatus.sldrSquelchValue = o->value();
3099 	}
3100 
3101 	restoreFocus(13);
3102 }
3103 
3104 bool oktoclear = true;
3105 
updateOutSerNo()3106 void updateOutSerNo()
3107 {
3108 	Fl_Input2* outsn[] = {
3109 		outSQSO_serno1, outSQSO_serno2,
3110 		outSerNo1, outSerNo2, outSerNo3, outSerNo4,
3111 		outSerNo5, outSerNo6, outSerNo7, outSerNo8,
3112 		out_IARI_SerNo1, out_IARI_SerNo2,
3113 //		outSerNo_WAE1, outSerNo_WAE2,
3114 		outSerNo_WPX1, outSerNo_WPX2
3115 		};
3116 
3117 	size_t num_fields = sizeof(outsn)/sizeof(*outsn);
3118 	for (size_t i = 0; i < num_fields; i++) {
3119 		outsn[i]->value("");
3120 		outsn[i]->redraw();
3121 	}
3122 
3123 	int nr = contest_count.count;
3124 
3125 	if (!n3fjp_serno.empty()) {
3126 		sscanf(n3fjp_serno.c_str(), "%d", &nr);
3127 	}
3128 	char szcnt[10] = "";
3129 	contest_count.Format(progdefaults.ContestDigits, progdefaults.UseLeadingZeros);
3130 	snprintf(szcnt, sizeof(szcnt), contest_count.fmt.c_str(), nr);
3131 
3132 	for (size_t i = 0; i < num_fields; i++) {
3133 		outsn[i]->value(szcnt);
3134 		outsn[i]->redraw();
3135 	}
3136 }
3137 
3138 static string old_call;
3139 static string new_call;
3140 
set599()3141 void set599()
3142 {
3143 	if (bWF_only)
3144 		return;
3145 
3146 	Fl_Input2* rstin[] = {
3147 		inpRstIn1, inpRstIn2, inpRstIn3, inpRstIn4, inpRstIn_AICW2,
3148 		inpRstIn_SQSO2,
3149 		inp_IARI_RSTin2,
3150 //		inpRstIn_WAE2,
3151 		inpRstIn_WPX2};
3152 	Fl_Input2* rstout[] = {
3153 		inpRstOut1, inpRstOut2, inpRstOut3, inpRstOut4, inpRstIn_AICW2,
3154 		inpRstOut_SQSO2,
3155 		inp_IARI_RSTout2,
3156 //		inpRstOut_WAE2,
3157 		inpRstOut_WPX2};
3158 	if (!active_modem) return;
3159 	string defrst = (active_modem->get_mode() == MODE_SSB) ? "59" : "599";
3160 	if (progdefaults.RSTin_default) {
3161 		size_t num_fields = sizeof(rstin)/sizeof(*rstin);
3162 		for (size_t i = 0; i < num_fields; i++)
3163 			rstin[i]->value(defrst.c_str());
3164 	}
3165 	if (progdefaults.RSTdefault) {
3166 		size_t num_fields = sizeof(rstout)/sizeof(*rstout);
3167 		for (size_t i = 0; i < num_fields; i++)
3168 			rstout[i]->value(defrst.c_str());
3169 	}
3170 	if (progdefaults.logging > 0 && progdefaults.fixed599) {
3171 		size_t num_fields = sizeof(rstout)/sizeof(*rstout);
3172 		for (size_t i = 0; i < num_fields; i++)
3173 			rstout[i]->value(defrst.c_str());
3174 	}
3175 }
3176 
init_country_fields()3177 void init_country_fields()
3178 {
3179 	Fl_ComboBox *country_fields[] = {
3180 		cboCountryQSO,
3181 		cboCountryAICW2,
3182 		cboCountryAIDX2,
3183 		cboCountryCQ2,
3184 		cboCountryCQDX2,
3185 		cboCountryIARI2,
3186 		cboCountryRTU2//,
3187 //		cboCountryWAE2
3188 	};
3189 	for (size_t i = 0; i < sizeof(country_fields)/sizeof(*country_fields); i++) {
3190 		country_fields[i]->add(cbolist.c_str());
3191 	}
3192 
3193 	cboCountyQSO->add(counties().c_str());
3194 
3195 }
3196 
set_log_colors()3197 void set_log_colors()
3198 {
3199 Fl_Input2* qso_fields[] = {
3200 	inpCall1, inpCall2, inpCall3, inpCall4,
3201 	inpName1, inpName2,
3202 	inpTimeOn1, inpTimeOn2, inpTimeOn3, inpTimeOn4, inpTimeOn5,
3203 	inpRstIn1, inpRstIn2,
3204 	inpRstOut1, inpRstOut2,
3205 	inpQth, inpLoc1, inpAZ, inpVEprov,
3206 	inpState1,
3207 	inpSerNo1, inpSerNo2, inpSerNo3, inpSerNo4,
3208 	outSerNo1, outSerNo2, outSerNo3, outSerNo4,
3209 	outSerNo5, outSerNo6, outSerNo7, outSerNo8,
3210 	inpXchgIn1, inpXchgIn2,
3211 	inp_FD_class1, inp_FD_section1, inp_FD_class2, inp_FD_section2,
3212 	inp_KD_name2, inp_KD_age1, inp_KD_age2,
3213 	inp_KD_state1, inp_KD_state2,
3214 	inp_KD_VEprov1, inp_KD_VEprov2,
3215 	inp_KD_XchgIn1, inp_KD_XchgIn2,
3216 	inp_SS_Check1, inp_SS_Precedence1, inp_SS_Section1, inp_SS_SerialNoR1,
3217 	inp_SS_Check2, inp_SS_Precedence2, inp_SS_Section2, inp_SS_SerialNoR2,
3218 	inp_CQ_RSTin2, inp_CQDX_RSTin2,
3219 	inp_CQ_RSTout2, inp_CQDX_RSTout2,
3220 	inp_CQstate1, inp_CQstate2,
3221 	inp_CQzone1, inp_CQzone2,
3222 	inp_CQDXzone1, inp_CQDXzone2,
3223 	inp_1010_XchgIn1, inp_1010_XchgIn2, inp_1010_name2, inp_1010_nr1, inp_1010_nr2,
3224 	inp_ARR_Name2, inp_ARR_XchgIn1, inp_ARR_XchgIn2, inp_ARR_check1, inp_ARR_check2,
3225 	inp_ASCR_RSTin2, inp_ASCR_RSTout2, inp_ASCR_XchgIn1, inp_ASCR_XchgIn2,
3226 	inp_ASCR_class1, inp_ASCR_class2, inp_ASCR_name2,
3227 	inp_vhf_Loc1, inp_vhf_Loc2,
3228 	inp_vhf_RSTin1, inp_vhf_RSTin2,
3229 	inp_vhf_RSTout1, inp_vhf_RSTout2,
3230 	inpSPCnum_NAQP1, inpSPCnum_NAQP2,
3231 	inpNAQPname2, inp_name_NAS2,
3232 	inp_ser_NAS1, inpSPCnum_NAS1,
3233 	inp_ser_NAS2, inpSPCnum_NAS2,
3234 	inpRTU_stpr1, inpRTU_stpr2,
3235 	inpRTU_RSTin2, inpRTU_RSTout2,
3236 	inpRTU_serno1, inpRTU_serno2,
3237 	inp_IARI_PR1, inp_IARI_PR2,
3238 	inp_IARI_RSTin2, inp_IARI_RSTout2,
3239 	out_IARI_SerNo1, inp_IARI_SerNo1,
3240 	out_IARI_SerNo2, inp_IARI_SerNo2,
3241 	inpRstIn3, inpRstOut3,
3242 	inpRstIn4, inpRstOut4,
3243 	inp_JOTA_scout1, inp_JOTA_scout2,
3244 	inp_JOTA_troop1, inp_JOTA_troop2,
3245 	inp_JOTA_spc1, inp_JOTA_spc2,
3246 	inpRstIn_AICW2, inpRstOut_AICW2,
3247 	inpSPCnum_AICW1, inpSPCnum_AICW2,
3248 	inpSQSO_state1, inpSQSO_state2,
3249 	inpSQSO_county1, inpSQSO_county2,
3250 	inpSQSO_serno1, inpSQSO_serno2,
3251 	outSQSO_serno1, outSQSO_serno2,
3252 	inpRstIn_SQSO2, inpRstOut_SQSO2,
3253 	inpSQSO_name2,
3254 	inpSQSO_category1, inpSQSO_category2,
3255 	inpSerNo_WPX1, inpSerNo_WPX2,
3256 	inpRstIn_WPX2, inpRstOut_WPX2,
3257 	outSerNo_WPX1, outSerNo_WPX2,
3258 	inpSerNo_WAE1, inpSerNo_WAE2,
3259 	outSerNo_WAE1, outSerNo_WAE2,
3260 	inpRstIn_WAE2, inpRstOut_WAE2,
3261 	inpNotes };
3262 
3263 	if (!bWF_only) {
3264 		Fl_ComboBox *country_fields[] = {
3265 			cboCountyQSO, cboCountryQSO,
3266 			cboCountryAICW2,
3267 			cboCountryAIDX2,
3268 			cboCountryCQ2,
3269 			cboCountryCQDX2,
3270 			cboCountryIARI2,
3271 			cboCountryRTU2 //,
3272 //			cboCountryWAE2
3273 		};
3274 		for (size_t i = 0; i < sizeof(country_fields)/sizeof(*country_fields); i++) {
3275 			country_fields[i]->redraw();
3276 			combo_color_font(country_fields[i]);
3277 		}
3278 
3279 		size_t num_fields = sizeof(qso_fields)/sizeof(*qso_fields);
3280 		for (size_t i = 0; i < num_fields; i++) {
3281 			qso_fields[i]->textsize(progdefaults.LOGGINGtextsize);
3282 			qso_fields[i]->textfont(progdefaults.LOGGINGtextfont);
3283 			qso_fields[i]->textcolor(progdefaults.LOGGINGtextcolor);
3284 			qso_fields[i]->color(progdefaults.LOGGINGcolor);
3285 			qso_fields[i]->labelfont(progdefaults.LOGGINGtextfont);
3286 			qso_fields[i]->redraw_label();
3287 		}
3288 
3289 		if (!progdefaults.SQSOlogstate) {
3290 			inpSQSO_state1->hide();
3291 			inpSQSO_state2->hide();
3292 		}
3293 
3294 		if (!progdefaults.SQSOlogcounty) {
3295 			inpSQSO_county1->hide();
3296 			inpSQSO_county2->hide();
3297 		}
3298 
3299 		if (!progdefaults.SQSOlogserno) {
3300 			inpSQSO_serno1->hide();
3301 			inpSQSO_serno2->hide();
3302 			outSQSO_serno1->hide();
3303 			outSQSO_serno2->hide();
3304 		}
3305 
3306 		if (!progdefaults.SQSOlogrst) {
3307 			inpRstIn_SQSO2->hide();
3308 			inpRstOut_SQSO2->hide();
3309 		}
3310 
3311 		if (!progdefaults.SQSOlogname) {
3312 			inpSQSO_name2->hide();
3313 		}
3314 
3315 		if (!progdefaults.SQSOlogcat) {
3316 			inpSQSO_category1->hide();
3317 			inpSQSO_category2->hide();
3318 		}
3319 		for (size_t i = 0; i < num_fields; i++) {
3320 			qso_fields[i]->redraw();
3321 		}
3322 	}
3323 
3324 }
3325 
clear_time_on()3326 void clear_time_on()
3327 {
3328 Fl_Input2* log_fields[] = {
3329 	inpTimeOn1, inpTimeOn2, inpTimeOn3, inpTimeOn4, inpTimeOn5 };
3330 
3331 	size_t num_fields = sizeof(log_fields)/sizeof(*log_fields);
3332 	for (size_t i = 0; i < num_fields; i++) {
3333 		log_fields[i]->value("");
3334 		log_fields[i]->textsize(progdefaults.LOGGINGtextsize);
3335 		log_fields[i]->textfont(progdefaults.LOGGINGtextfont);
3336 		log_fields[i]->textcolor(progdefaults.LOGGINGtextcolor);
3337 		log_fields[i]->color(progdefaults.LOGGINGcolor);
3338 		log_fields[i]->labelfont(progdefaults.LOGGINGtextfont);
3339 		log_fields[i]->show();
3340 		log_fields[i]->redraw_label();
3341 		log_fields[i]->redraw();
3342 	}
3343 }
3344 
clear_log_fields()3345 void clear_log_fields()
3346 {
3347 Fl_Input2* log_fields[] = {
3348 	inpName1, inpName2,
3349 //	inpTimeOn1, inpTimeOn2, inpTimeOn3, inpTimeOn4, inpTimeOn5,
3350 	inpRstIn1, inpRstIn2,
3351 	inpRstOut1, inpRstOut2,
3352 	inpQth, inpLoc1, inpAZ, inpVEprov,
3353 	inpState1,
3354 	inpSerNo1, inpSerNo2,
3355 	outSerNo1, outSerNo2,
3356 	outSerNo3, outSerNo4,
3357 	inpXchgIn1, inpXchgIn2,
3358 	inp_FD_class1, inp_FD_section1, inp_FD_class2, inp_FD_section2,
3359 	inp_KD_name2, inp_KD_age1, inp_KD_age2,
3360 	inp_KD_state1, inp_KD_state2,
3361 	inp_KD_VEprov1, inp_KD_VEprov2,
3362 	inp_KD_XchgIn1, inp_KD_XchgIn2,
3363 	inp_SS_Check1, inp_SS_Precedence1, inp_SS_Section1, inp_SS_SerialNoR1,
3364 	inp_SS_Check2, inp_SS_Precedence2, inp_SS_Section2, inp_SS_SerialNoR2,
3365 	inp_CQ_RSTin2, inp_CQDX_RSTin2,
3366 	inp_CQ_RSTout2, inp_CQDX_RSTout2,
3367 	inp_CQstate1, inp_CQstate2,
3368 	inp_CQzone1, inp_CQzone2,
3369 	inp_CQDXzone1, inp_CQDXzone2,
3370 	inp_1010_XchgIn1, inp_1010_XchgIn2, inp_1010_name2, inp_1010_nr1, inp_1010_nr2,
3371 	inp_ARR_Name2, inp_ARR_XchgIn1, inp_ARR_XchgIn2, inp_ARR_check1, inp_ARR_check2,
3372 	inp_ASCR_RSTin2, inp_ASCR_RSTout2, inp_ASCR_XchgIn1, inp_ASCR_XchgIn2,
3373 	inp_ASCR_class1, inp_ASCR_class2, inp_ASCR_name2,
3374 	inp_vhf_Loc1, inp_vhf_Loc2,
3375 	inp_vhf_RSTin1, inp_vhf_RSTin2,
3376 	inp_vhf_RSTout1, inp_vhf_RSTout2,
3377 	inpSPCnum_NAQP1, inpSPCnum_NAQP2,
3378 	inpNAQPname2, inp_name_NAS2,
3379 	outSerNo4, inp_ser_NAS1, inpSPCnum_NAS1,
3380 	outSerNo5, inp_ser_NAS2, inpSPCnum_NAS2,
3381 	inpRTU_stpr1, inpRTU_stpr2,
3382 	inpRTU_RSTin2, inpRTU_RSTout2,
3383 	inpRTU_serno1, inpRTU_serno2,
3384 	inp_IARI_RSTin2, inp_IARI_RSTout2,
3385 	out_IARI_SerNo1, inp_IARI_SerNo1,
3386 	out_IARI_SerNo2, inp_IARI_SerNo2,
3387 	inp_IARI_PR1, inp_IARI_PR2,
3388 	inpSerNo3, inpSerNo4,
3389 	outSerNo7, outSerNo8,
3390 	inpRstIn3, inpRstOut3,
3391 	inpRstIn4, inpRstOut4,
3392 	inp_JOTA_scout1, inp_JOTA_scout2,
3393 	inp_JOTA_troop1, inp_JOTA_troop2,
3394 	inp_JOTA_spc1, inp_JOTA_spc2,
3395 	inpRstIn_AICW2, inpRstOut_AICW2,
3396 	inpSPCnum_AICW1, inpSPCnum_AICW2,
3397 	inpSerNo_WPX1, inpSerNo_WPX2,
3398 	inpRstIn_WPX2, inpRstOut_WPX2,
3399 	inpSerNo_WAE1, inpSerNo_WAE2,
3400 	outSerNo_WAE1, outSerNo_WAE2,
3401 	inpRstIn_WAE2, inpRstOut_WAE2,
3402 	inpSQSO_category1, inpSQSO_category2,
3403 	inpSQSO_county1, inpSQSO_county2,
3404 	inpSQSO_name2,
3405 	inpSQSO_serno1, inpSQSO_serno2,
3406 	inpSQSO_state1, inpSQSO_state2,
3407 	inpNotes };
3408 
3409 	size_t num_fields = sizeof(log_fields)/sizeof(*log_fields);
3410 	for (size_t i = 0; i < num_fields; i++) {
3411 		log_fields[i]->value("");
3412 		log_fields[i]->textsize(progdefaults.LOGGINGtextsize);
3413 		log_fields[i]->textfont(progdefaults.LOGGINGtextfont);
3414 		log_fields[i]->textcolor(progdefaults.LOGGINGtextcolor);
3415 		log_fields[i]->color(progdefaults.LOGGINGcolor);
3416 		log_fields[i]->labelfont(progdefaults.LOGGINGtextfont);
3417 		log_fields[i]->show();
3418 		log_fields[i]->redraw_label();
3419 		log_fields[i]->redraw();
3420 	}
3421 
3422 	Fl_ComboBox *country_fields[] = {
3423 		cboCountyQSO, cboCountryQSO,
3424 		cboCountryAICW2,
3425 		cboCountryAIDX2,
3426 		cboCountryCQ2,
3427 		cboCountryCQDX2,
3428 		cboCountryIARI2,
3429 		cboCountryRTU2 //,
3430 //		cboCountryWAE2
3431 	};
3432 	for (size_t i = 0; i < sizeof(country_fields)/sizeof(*country_fields); i++) {
3433 		country_fields[i]->value("");
3434 		country_fields[i]->redraw();
3435 		combo_color_font(country_fields[i]);
3436 	}
3437 
3438 	if (!progdefaults.SQSOlogstate) {
3439 		inpSQSO_state1->hide();
3440 		inpSQSO_state2->hide();
3441 	}
3442 
3443 	if (!progdefaults.SQSOlogcounty) {
3444 		inpSQSO_county1->hide();
3445 		inpSQSO_county2->hide();
3446 	}
3447 
3448 	if (!progdefaults.SQSOlogserno) {
3449 		inpSQSO_serno1->hide();
3450 		inpSQSO_serno2->hide();
3451 		outSQSO_serno1->hide();
3452 		outSQSO_serno2->hide();
3453 	}
3454 
3455 	if (!progdefaults.SQSOlogrst) {
3456 		inpRstIn_SQSO2->hide();
3457 		inpRstOut_SQSO2->hide();
3458 	}
3459 
3460 	if (!progdefaults.SQSOlogname) {
3461 		inpSQSO_name2->hide();
3462 	}
3463 
3464 	if (!progdefaults.SQSOlogcat) {
3465 		inpSQSO_category1->hide();
3466 		inpSQSO_category2->hide();
3467 	}
3468 
3469 	if (progdefaults.logging == LOG_SQSO) {
3470 		std::string tmp = QSOparties.qso_parties[progdefaults.SQSOcontest].state;
3471 		if (!progdefaults.SQSOinstate && (tmp != "7QP") && (tmp != "6NE"))
3472 			inpState->value(tmp.c_str());
3473 	}
3474 
3475 	set599();
3476 	updateOutSerNo();
3477 
3478 }
3479 
clearQSO()3480 void clearQSO()
3481 {
3482 if (bWF_only) return;
3483 
3484 	Fl_Input2* call_fields[] = { inpCall1, inpCall2, inpCall3, inpCall4 };
3485 	size_t num_fields = sizeof(call_fields)/sizeof(*call_fields);
3486 	for (size_t i = 0; i < num_fields; i++) {
3487 		call_fields[i]->value("");
3488 		call_fields[i]->textsize(progdefaults.LOGGINGtextsize);
3489 		call_fields[i]->textfont(progdefaults.LOGGINGtextfont);
3490 		call_fields[i]->textcolor(progdefaults.LOGGINGtextcolor);
3491 		call_fields[i]->color(progdefaults.LOGGINGcolor);
3492 		call_fields[i]->labelfont(progdefaults.LOGGINGtextfont);
3493 		call_fields[i]->show();
3494 		call_fields[i]->redraw_label();
3495 		call_fields[i]->redraw();
3496 	}
3497 
3498 	clear_log_fields();
3499 	clear_time_on();
3500 
3501 	if (inpSearchString)
3502 		inpSearchString->value ("");
3503 	old_call.clear();
3504 	new_call.clear();
3505 	qso_time.clear();
3506 	qso_exchange.clear();
3507 	oktoclear = true;
3508 
3509 	inpCall->take_focus();
3510 
3511 	if (n3fjp_connected)
3512 		n3fjp_clear_record();
3513 
3514 	set599();
3515 	updateOutSerNo();
3516 
3517 }
3518 
cb_ResetSerNbr()3519 void cb_ResetSerNbr()
3520 {
3521 	contest_count.count = progdefaults.ContestStart;
3522 	updateOutSerNo();
3523 }
3524 
cb_btnTimeOn(Fl_Widget * w,void *)3525 void cb_btnTimeOn(Fl_Widget* w, void*)
3526 {
3527 	inpTimeOn->value(inpTimeOff->value(), inpTimeOff->size());
3528 	inpTimeOn1->value(inpTimeOff->value(), inpTimeOff->size());
3529 	inpTimeOn2->value(inpTimeOff->value(), inpTimeOff->size());
3530 	inpTimeOn3->value(inpTimeOff->value(), inpTimeOff->size());
3531 	inpTimeOn4->value(inpTimeOff->value(), inpTimeOff->size());
3532 	inpTimeOn5->value(inpTimeOff->value(), inpTimeOff->size());
3533 	sTime_on = sTime_off = ztime();
3534 	sDate_on = sDate_off = zdate();
3535 	restoreFocus(14);
3536 }
3537 
cb_loc(Fl_Widget * w,void *)3538 void cb_loc(Fl_Widget* w, void*)
3539 {
3540 	Fl_Input2 *inp = (Fl_Input2 *) w;
3541 
3542 	inpLoc1->value(inp->value());
3543 	inp_vhf_Loc1->value(inp->value());
3544 	inp_vhf_Loc2->value(inp->value());
3545 
3546 	std::string s;
3547 	s = inp->value();
3548 
3549 	if (s.length() < 3) return;
3550 
3551 	double lon[2], lat[2], distance, azimuth;
3552 	size_t len = s.length();
3553 	if (len > MAX_LOC) {
3554 		s.erase(MAX_LOC);
3555 		len = MAX_LOC;
3556 	}
3557 	bool ok = true;
3558 	for (size_t i = 0; i < len; i++) {
3559 		if (ok)
3560 		switch (i) {
3561 			case 0 :
3562 			case 1 :
3563 			case 4 :
3564 			case 5 :
3565 				ok = isalpha(s[i]);
3566 				break;
3567 			case 2 :
3568 			case 3 :
3569 			case 6 :
3570 			case 7 :
3571 				ok = (s[i] >= '0' && s[i] <= '9');
3572 		}
3573 	}
3574 	if ( !ok) {
3575 		inpLoc1->value("");
3576 		inp_vhf_Loc1->value("");
3577 		inp_vhf_Loc2->value("");
3578 		return;
3579 	}
3580 
3581 	if (QRB::locator2longlat(&lon[0], &lat[0], progdefaults.myLocator.c_str()) == QRB::QRB_OK &&
3582 		QRB::locator2longlat(&lon[1], &lat[1], s.c_str()) == QRB::QRB_OK &&
3583 		QRB::qrb(lon[0], lat[0], lon[1], lat[1], &distance, &azimuth) == QRB::QRB_OK) {
3584 		char az[4];
3585 		snprintf(az, sizeof(az), "%3.0f", azimuth);
3586 		inpAZ->value(az);
3587 	} else
3588 		inpAZ->value("");
3589 
3590 	if (Fl::event() == FL_KEYBOARD) {
3591 		int k = Fl::event_key();
3592 		if (k == FL_Enter || k == FL_KP_Enter)
3593 			restoreFocus(15);
3594 	}
3595 }
3596 
cb_call(Fl_Widget * w,void *)3597 void cb_call(Fl_Widget* w, void*)
3598 {
3599 if (bWF_only) return;
3600 
3601 	qsodb.isdirty(1);
3602 
3603 	if (progdefaults.calluppercase) {
3604 		int pos = inpCall->position();
3605 		char* uc = new char[inpCall->size()];
3606 		transform(inpCall->value(), inpCall->value() + inpCall->size(), uc,
3607 			  static_cast<int (*)(int)>(std::toupper));
3608 		inpCall->value(uc, inpCall->size());
3609 		inpCall->position(pos);
3610 		delete [] uc;
3611 	}
3612 
3613 	new_call = inpCall->value();
3614 
3615 	if (new_call.length() > MAX_CALL) {
3616 		new_call.erase(MAX_CALL);
3617 	}
3618 
3619 	if (new_call != old_call) clear_log_fields();
3620 
3621 	inpCall1->value(new_call.c_str());
3622 	inpCall2->value(new_call.c_str());
3623 	inpCall3->value(new_call.c_str());
3624 	inpCall4->value(new_call.c_str());
3625 
3626 	sDate_on = sDate_off = zdate();
3627 	sTime_on = sTime_off = ztime();
3628 
3629 	inpTimeOn->value(inpTimeOff->value());
3630 	inpTimeOn1->value(inpTimeOff->value());
3631 	inpTimeOn2->value(inpTimeOff->value());
3632 	inpTimeOn3->value(inpTimeOff->value());
3633 	inpTimeOn4->value(inpTimeOff->value());
3634 	inpTimeOn5->value(inpTimeOff->value());
3635 
3636 	if (progStatus.timer && (Fl::event() != FL_HIDE))
3637 		stopMacroTimer();
3638 
3639 	if (Fl::event() == FL_KEYBOARD) {
3640 		int k = Fl::event_key();
3641 		if (k == FL_Enter || k == FL_KP_Enter) {
3642 			restoreFocus(16);
3643 			n3fjp_calltab = true;
3644 		}
3645 		if (k == FL_Tab) {
3646 			n3fjp_calltab = true;
3647 		}
3648 	}
3649 
3650 	if (old_call == new_call) {
3651 		if (n3fjp_calltab && n3fjp_connected)
3652 			SearchLastQSO(inpCall->value());
3653 		return;
3654 	}
3655 
3656 	if (new_call.empty()) {
3657 		if (n3fjp_connected) n3fjp_clear_record();
3658 		ifkp_load_avatar();
3659 		thor_load_avatar();
3660 		updateOutSerNo();
3661 		oktoclear = true;
3662 		return;
3663 	}
3664 
3665 	old_call = new_call;
3666 	oktoclear = false;
3667 
3668 	SearchLastQSO(inpCall->value());
3669 
3670 	if (active_modem->get_mode() == MODE_IFKP)
3671 		ifkp_load_avatar(inpCall->value());
3672 
3673 	if (active_modem->get_mode() >= MODE_THOR11 &&
3674 		active_modem->get_mode() <= MODE_THOR22)
3675 		thor_load_avatar(inpCall->value());
3676 
3677 	const struct dxcc* e = dxcc_lookup(inpCall->value());
3678 	if (e) {
3679 		if (progdefaults.autofill_qso_fields || progdefaults.logging != LOG_QSO) {
3680 			double lon, lat, distance, azimuth;
3681 			if (QRB::locator2longlat(&lon, &lat, progdefaults.myLocator.c_str()) == QRB::QRB_OK &&
3682 				QRB::qrb(lon, lat, -e->longitude, e->latitude, &distance, &azimuth) == QRB::QRB_OK) {
3683 				char az[4];
3684 				snprintf(az, sizeof(az), "%3.0f", azimuth);
3685 				inpAZ->value(az, sizeof(az) - 1);
3686 			}
3687 		}
3688 		std::string cntry = e->country;
3689 		std::ostringstream zone;
3690 		zone << e->cq_zone;
3691 		if (cntry.find("United States") != std::string::npos)
3692 			cntry = "USA";
3693 		cboCountry->value(cntry.c_str());
3694 		inp_CQzone->value(zone.str().c_str());
3695 	}
3696 
3697 	if (progdefaults.EnableDupCheck || FD_logged_on) {
3698 		DupCheck();
3699 	}
3700 
3701 	updateOutSerNo();
3702 
3703 	if (w != inpCall)
3704 		restoreFocus(17);
3705 }
3706 
cb_country(Fl_Widget * w,void *)3707 void cb_country(Fl_Widget *w, void*)
3708 {
3709 	Fl_ComboBox * inp = (Fl_ComboBox *) w;
3710 	std::string str = inp->value();
3711 
3712 	Fl_ComboBox *country_fields[] = {
3713 		cboCountryQSO,
3714 		cboCountryAICW2,
3715 		cboCountryAIDX2,
3716 		cboCountryCQ2,
3717 		cboCountryCQDX2,
3718 		cboCountryIARI2,
3719 		cboCountryRTU2 //,
3720 //		cboCountryWAE2
3721 	};
3722 	for (size_t i = 0; i < sizeof(country_fields)/sizeof(*country_fields); i++) {
3723 		country_fields[i]->value(str.c_str());
3724 		country_fields[i]->position(0);
3725 		country_fields[i]->redraw();
3726 	}
3727 
3728 	if (progdefaults.EnableDupCheck || FD_logged_on) {
3729 		DupCheck();
3730 	}
3731 
3732 	if (Fl::event() == FL_KEYBOARD) {
3733 		int k = Fl::event_key();
3734 		if (k == FL_Enter || k == FL_KP_Enter)
3735 			restoreFocus(18);
3736 	}
3737 }
3738 
cb_log(Fl_Widget * w,void *)3739 void cb_log(Fl_Widget* w, void*)
3740 {
3741 	Fl_Input2 *inp = (Fl_Input2 *) w;
3742 
3743 	if (inp == inpName1 || inp == inpName2 ||
3744 		inp == inp_KD_name2 ||
3745 		inp == inp_1010_name2 ||
3746 		inp == inp_ARR_Name2 ||
3747 		inp == inpNAQPname2 ) {
3748 		int p = inp->position();
3749 		std::string val = inp->value();
3750 		inpName1->value(val.c_str());
3751 		inpName2->value(val.c_str());
3752 		inp_KD_name2->value(val.c_str());
3753 		inp_1010_name2->value(val.c_str());
3754 		inp_ARR_Name2->value(val.c_str());
3755 		inpNAQPname2->value(val.c_str());
3756 		inp->position(p);
3757 	}
3758 
3759 	else if (inp == inp_KD_name2 || inp == inp_1010_name2 ||
3760 		inp == inp_ARR_Name2 || inp == inpNAQPname2) {
3761 		int p = inp->position();
3762 		std::string val = inp->value();
3763 		inpName1->value(val.c_str());
3764 		inpName2->value(val.c_str());
3765 		inp_KD_name2->value(val.c_str());
3766 		inp_1010_name2->value(val.c_str());
3767 		inp_ARR_Name2->value(val.c_str());
3768 		inpNAQPname2->value(val.c_str());
3769 		inp->position(p);
3770 	}
3771 
3772 	else if (inp == inpRstIn1 || inp == inpRstIn2 ||
3773 			 inp == inpRstIn3 || inp == inpRstIn4 || inp == inpRstIn_AICW2 ||
3774 			 inp == inpRTU_RSTin2 || inp == inp_CQ_RSTin2 ||
3775 			 inp == inp_vhf_RSTin1 || inp == inp_vhf_RSTin2 ) {
3776 		int p = inp->position();
3777 		std::string val = inp->value();
3778 		inpRstIn1->value(val.c_str());
3779 		inpRstIn2->value(val.c_str());
3780 		inpRstIn3->value(val.c_str());
3781 		inpRstIn4->value(val.c_str());
3782 		inpRstIn_AICW2->value(val.c_str());
3783 		inpRTU_RSTin2->value(val.c_str());
3784 		inp_vhf_RSTin1->value(val.c_str());
3785 		inp_vhf_RSTin2->value(val.c_str());
3786 		inp_CQ_RSTin2->value(val.c_str());
3787 		inp->position(p);
3788 	}
3789 
3790 	else if (inp == inpRstOut1 || inp == inpRstOut2 ||
3791 		inp == inp_CQ_RSTout2 ||
3792 		inp == inpRTU_RSTout2 ||
3793 		inp == inpRstOut3 || inp == inpRstOut4 || inp == inpRstOut_AICW2 ||
3794 		inp == inp_vhf_RSTout1 || inp == inp_vhf_RSTout2 ) {
3795 		int p = inp->position();
3796 		std::string val = inp->value();
3797 		inpRstOut1->value(val.c_str());
3798 		inpRstOut2->value(val.c_str());
3799 		inpRstOut3->value(val.c_str());
3800 		inpRstOut4->value(val.c_str());
3801 		inpRTU_RSTout2->value(val.c_str());
3802 		inpRstOut_AICW2->value(val.c_str());
3803 		inp_CQ_RSTout2->value(val.c_str());
3804 		inp_vhf_RSTout1->value(val.c_str());
3805 		inp_vhf_RSTout2->value(val.c_str());
3806 		inp->position(p);
3807 	}
3808 
3809 	else if (inp == inpTimeOn1 || inp == inpTimeOn2 || inp == inpTimeOn3 ||
3810 			 inp == inpTimeOn4 || inp == inpTimeOn5) {
3811 		int p = inp->position();
3812 		std::string val = inp->value();
3813 		inpTimeOn1->value(val.c_str());
3814 		inpTimeOn2->value(val.c_str());
3815 		inpTimeOn3->value(val.c_str());
3816 		inpTimeOn4->value(val.c_str());
3817 		inpTimeOn5->value(val.c_str());
3818 		inp->position(p);
3819 	}
3820 
3821 	else if (inp == inpTimeOff1 || inp == inpTimeOff2 || inp == inpTimeOff3 ||
3822 			 inp == inpTimeOff4 || inp == inpTimeOff5) {
3823 		int p = inp->position();
3824 		std::string val = inp->value();
3825 		inpTimeOff1->value(val.c_str());
3826 		inpTimeOff2->value(val.c_str());
3827 		inpTimeOff3->value(val.c_str());
3828 		inpTimeOff4->value(val.c_str());
3829 		inpTimeOff5->value(val.c_str());
3830 		inp->position(p);
3831 	}
3832 
3833 	else if (inp == inpXchgIn1 || inp == inpXchgIn2 ) {
3834 		int p = inp->position();
3835 		std::string val = inp->value();
3836 		inpXchgIn1->value(val.c_str());
3837 		inpXchgIn2->value(val.c_str());
3838 		inp_KD_XchgIn1->value(val.c_str());
3839 		inp_KD_XchgIn2->value(val.c_str());
3840 		inp_1010_XchgIn1->value(val.c_str());
3841 		inp_1010_XchgIn2->value(val.c_str());
3842 		inp_ARR_XchgIn1->value(val.c_str());
3843 		inp_ARR_XchgIn2->value(val.c_str());
3844 		inp->position(p);
3845 	}
3846 
3847 	else if (inp == inp_KD_XchgIn1 || inp == inp_KD_XchgIn2) {
3848 		int p = inp->position();
3849 		std::string val = inp->value();
3850 		inpXchgIn1->value(val.c_str());
3851 		inpXchgIn2->value(val.c_str());
3852 		inp_KD_XchgIn1->value(val.c_str());
3853 		inp_KD_XchgIn2->value(val.c_str());
3854 		inp_1010_XchgIn1->value(val.c_str());
3855 		inp_1010_XchgIn2->value(val.c_str());
3856 		inp_ARR_XchgIn1->value(val.c_str());
3857 		inp_ARR_XchgIn2->value(val.c_str());
3858 		inp->position(p);
3859 	}
3860 
3861 	else if (inp == inp_1010_XchgIn1 || inp == inp_1010_XchgIn2) {
3862 		int p = inp->position();
3863 		std::string val = inp->value();
3864 		inpXchgIn1->value(val.c_str());
3865 		inpXchgIn2->value(val.c_str());
3866 		inp_KD_XchgIn1->value(val.c_str());
3867 		inp_KD_XchgIn2->value(val.c_str());
3868 		inp_1010_XchgIn1->value(val.c_str());
3869 		inp_1010_XchgIn2->value(val.c_str());
3870 		inp_ARR_XchgIn1->value(val.c_str());
3871 		inp_ARR_XchgIn2->value(val.c_str());
3872 		inp->position(p);
3873 	}
3874 
3875 	else if (inp == inp_ARR_XchgIn1 || inp == inp_ARR_XchgIn2) {
3876 		int p = inp->position();
3877 		std::string val = inp->value();
3878 		inpXchgIn1->value(val.c_str());
3879 		inpXchgIn2->value(val.c_str());
3880 		inp_KD_XchgIn1->value(val.c_str());
3881 		inp_KD_XchgIn2->value(val.c_str());
3882 		inp_1010_XchgIn1->value(val.c_str());
3883 		inp_1010_XchgIn2->value(val.c_str());
3884 		inp_ARR_XchgIn1->value(val.c_str());
3885 		inp_ARR_XchgIn2->value(val.c_str());
3886 		inp->position(p);
3887 	}
3888 
3889 	else if (inp == inpSerNo1 || inp == inpSerNo2 ||
3890 		inp == inpRTU_serno1 || inp == inpRTU_serno2 ||
3891 		inp == inp_SS_SerialNoR1 || inp == inp_SS_SerialNoR2 ) {
3892 		int p = inp->position();
3893 		std::string val = inp->value();
3894 		inpSerNo1->value(val.c_str());
3895 		inpSerNo2->value(val.c_str());
3896 		inp_SS_SerialNoR1->value(val.c_str());
3897 		inp_SS_SerialNoR2->value(val.c_str());
3898 		inpRTU_serno1->value(val.c_str());
3899 		inpRTU_serno2->value(val.c_str());
3900 		inp->position(p);
3901 	}
3902 
3903 	else if (inp == inp_SS_Precedence1 || inp == inp_SS_Precedence2) {
3904 		int p = inp->position();
3905 		std::string val = inp->value();
3906 		inp_SS_Precedence1->value(val.c_str());
3907 		inp_SS_Precedence2->value(val.c_str());
3908 		inp->position(p);
3909 	}
3910 
3911 	else if (inp == inp_SS_Check1 || inp == inp_SS_Check2) {
3912 		int p = inp->position();
3913 		std::string val = inp->value();
3914 		inp_SS_Check1->value(val.c_str());
3915 		inp_SS_Check2->value(val.c_str());
3916 		inp->position(p);
3917 	}
3918 
3919 	else if (inp == inp_SS_Section1 || inp == inp_SS_Section2) {
3920 		int p = inp->position();
3921 		std::string val = inp->value();
3922 		inp_SS_Section1->value(val.c_str());
3923 		inp_SS_Section2->value(val.c_str());
3924 		inp->position(p);
3925 	}
3926 
3927 	else if (inp == inpSPCnum_NAQP1 || inp == inpSPCnum_NAQP2) {
3928 		int p = inp->position();
3929 		std::string val = inp->value();
3930 		inpSPCnum_NAQP1->value(val.c_str());
3931 		inpSPCnum_NAQP2->value(val.c_str());
3932 		inp->position(p);
3933 	}
3934 
3935 	else if (inp == inpSPCnum_AICW1 || inp == inpSPCnum_AICW2) { // Rx power
3936 		int p = inp->position();
3937 		std::string val = inp->value();
3938 		inpSPCnum_AICW1->value(val.c_str());
3939 		inpSPCnum_AICW2->value(val.c_str());
3940 		inp->position(p);
3941 	}
3942 
3943 	else if (inp == inp_ARR_check1 || inp == inp_ARR_check2) {
3944 		int p = inp->position();
3945 		std::string val = inp->value();
3946 		inp_ARR_check1->value(val.c_str());
3947 		inp_ARR_check2->value(val.c_str());
3948 		inp->position(p);
3949 	}
3950 
3951 	else if (inp == inp_1010_nr1 || inp == inp_1010_nr2) {
3952 		int p = inp->position();
3953 		std::string val = inp->value();
3954 		inp_1010_nr1->value(val.c_str());
3955 		inp_1010_nr2->value(val.c_str());
3956 		inp->position(p);
3957 	}
3958 
3959 	else if (inp == inp_FD_class1 || inp == inp_FD_class2) {
3960 		int p = inp->position();
3961 		std::string str = ucasestr(inp->value());
3962 		inp_FD_class1->value(str.c_str());
3963 		inp_FD_class2->value(str.c_str());
3964 		inp->position(p);
3965 	}
3966 
3967 	else if (inp == inp_ASCR_class1 || inp == inp_ASCR_class2) {
3968 		int p = inp->position();
3969 		std::string str = ucasestr(inp->value());
3970 		inp_ASCR_class1->value(str.c_str());
3971 		inp_ASCR_class2->value(str.c_str());
3972 		inp->position(p);
3973 	}
3974 
3975 	else if (inp == inp_FD_section1 || inp == inp_FD_section2) {
3976 		int p = inp->position();
3977 		std::string str = ucasestr(inp->value());
3978 		inp_FD_section1->value(str.c_str());
3979 		inp_FD_section2->value(str.c_str());
3980 		inp->position(p);
3981 	}
3982 
3983 	else if (inp == inp_KD_age1 || inp == inp_KD_age2) {
3984 		int p = inp->position();
3985 		std::string val = inp->value();
3986 		inp_KD_age1->value(val.c_str());
3987 		inp_KD_age2->value(val.c_str());
3988 		inp->position(p);
3989 	}
3990 
3991 	else if (inp == inp_KD_state1 || inp == inp_KD_state2) {
3992 		int p = inp->position();
3993 		std::string str = ucasestr(inp->value());
3994 		inp_KD_state1->value(str.c_str());
3995 		inp_KD_state2->value(str.c_str());
3996 		inp->position(p);
3997 	}
3998 
3999 	else if (inp == inp_KD_VEprov1 || inp == inp_KD_VEprov2) {
4000 		int p = inp->position();
4001 		std::string str = ucasestr(inp->value());
4002 		inp_KD_VEprov1->value(str.c_str());
4003 		inp_KD_VEprov2->value(str.c_str());
4004 		inp->position(p);
4005 	}
4006 
4007 	else if (inp == inp_ser_NAS1 || inp == inp_ser_NAS2) {
4008 		int p = inp->position();
4009 		std::string val = inp->value();
4010 		inp_ser_NAS1->value(val.c_str());
4011 		inp_ser_NAS2->value(val.c_str());
4012 		inp->position(p);
4013 	}
4014 
4015 	else if (inp == inp_JOTA_scout1 || inp == inp_JOTA_scout2) {
4016 		int p = inp->position();
4017 		std::string val = inp->value();
4018 		inp_JOTA_scout1->value(val.c_str());
4019 		inp_JOTA_scout2->value(val.c_str());
4020 		inp->position(p);
4021 	}
4022 
4023 	else if (inp == inp_JOTA_troop1 || inp == inp_JOTA_troop2) {
4024 		int p = inp->position();
4025 		std::string val = inp->value();
4026 		inp_JOTA_troop1->value(val.c_str());
4027 		inp_JOTA_troop2->value(val.c_str());
4028 		inp->position(p);
4029 	}
4030 
4031 	else if (inp == inp_JOTA_spc1 || inp == inp_JOTA_spc2) {
4032 		int p = inp->position();
4033 		std::string val = inp->value();
4034 		inp_JOTA_spc1->value(val.c_str());
4035 		inp_JOTA_spc2->value(val.c_str());
4036 		inp->position(p);
4037 	}
4038 
4039 	else if (inp == inpState) {
4040 		Cstates st;
4041 		if (inpCounty->value()[0])
4042 			cboCountyQSO->value(
4043 				string(st.state_short(inpState->value())).append(" ").
4044 				append(st.county(inpState->value(), inpCounty->value())).c_str());
4045 		else
4046 			cboCountyQSO->clear_entry();
4047 		cboCountyQSO->redraw();
4048 	}
4049 
4050 	else if (inp == inpCounty) {
4051 		Cstates st;
4052 		if (inpState->value()[0])
4053 			cboCountyQSO->value(
4054 				string(st.state_short(inpState->value())).append(" ").
4055 				append(st.county(inpState->value(), inpCounty->value())).c_str());
4056 		else
4057 			cboCountyQSO->clear_entry();
4058 		cboCountyQSO->redraw();
4059 	}
4060 
4061 	if (progdefaults.EnableDupCheck || FD_logged_on) {
4062 		DupCheck();
4063 	}
4064 
4065 	if (Fl::event() == FL_KEYBOARD) {
4066 		int k = Fl::event_key();
4067 		if (k == FL_Enter || k == FL_KP_Enter)
4068 			restoreFocus(18);
4069 	}
4070 }
4071 
cbClearCall(Fl_Widget * b,void *)4072 void cbClearCall(Fl_Widget *b, void *)
4073 {
4074 	clearQSO();
4075 }
4076 
qsoClear_cb(Fl_Widget * b,void *)4077 void qsoClear_cb(Fl_Widget *b, void *)
4078 {
4079 	bool CLEARLOG = true;
4080 	if (progdefaults.NagMe && !oktoclear)
4081 		CLEARLOG = (fl_choice2(_("Clear log fields?"), _("Cancel"), _("OK"), NULL) == 1);
4082 	if (CLEARLOG) {
4083 		clearQSO();
4084 	}
4085 	clear_Lookup();
4086 	if (active_modem->get_mode() == MODE_IFKP)
4087 		ifkp_clear_avatar();
4088 	if (active_modem->get_mode() >= MODE_THOR11 &&
4089 		active_modem->get_mode() <= MODE_THOR22)
4090 		thor_clear_avatar();
4091 	qsodb.isdirty(0);
4092 }
4093 
4094 extern cQsoDb	qsodb;
4095 
qso_save_now()4096 void qso_save_now()
4097 {
4098 //	if (!qsodb.isdirty()) return;
4099 	string havecall = inpCall->value();
4100 	string timeon   = inpTimeOn->value();
4101 
4102 	while (!havecall.empty() && havecall[0] <= ' ') havecall.erase(0,1);
4103 	while (!havecall.empty() && havecall[havecall.length() - 1] <= ' ') havecall.erase(havecall.length()-1, 1);
4104 
4105 	if (havecall.empty())
4106 		return;
4107 
4108 	sDate_off = zdate();
4109 	sTime_off = ztime();
4110 
4111 	if (!timeon.empty())
4112 		sTime_on = timeon.c_str();
4113 	else
4114 		sTime_on = sTime_off;
4115 
4116 	submit_log();
4117 	if (progdefaults.ClearOnSave)
4118 		clearQSO();
4119 }
4120 
qsoSave_cb(Fl_Widget * b,void *)4121 void qsoSave_cb(Fl_Widget *b, void *)
4122 {
4123 	qso_save_now();
4124 	ReceiveText->mark(FTextBase::XMIT);
4125 	restoreFocus(20);
4126 }
4127 
cb_QRZ(Fl_Widget * b,void *)4128 void cb_QRZ(Fl_Widget *b, void *)
4129 {
4130 	if (!*inpCall->value())
4131 		return restoreFocus(21);
4132 
4133 	switch (Fl::event_button()) {
4134 	case FL_LEFT_MOUSE:
4135 		CALLSIGNquery();
4136 		oktoclear = false;
4137 		break;
4138 	case FL_RIGHT_MOUSE:
4139 		if (quick_choice(string("Spot \"").append(inpCall->value()).append("\"?").c_str(),
4140 				 2, _("Confirm"), _("Cancel"), NULL) == 1)
4141 			spot_manual(inpCall->value(), inpLoc->value());
4142 		break;
4143 	default:
4144 		break;
4145 	}
4146 	restoreFocus(22);
4147 }
4148 
status_cb(Fl_Widget * b,void * arg)4149 void status_cb(Fl_Widget *b, void *arg)
4150 {
4151 	if (Fl::event_button() == FL_RIGHT_MOUSE) {
4152 		trx_mode md = active_modem->get_mode();
4153 		if (md == MODE_FMT) open_config(TAB_FMT);
4154 		else if (md == MODE_CW) open_config(TAB_CW);
4155 		else if (md == MODE_IFKP) open_config(TAB_IFKP);
4156 		else if (md == MODE_FSQ) open_config(TAB_FSQ);
4157 		else if (md == MODE_RTTY) open_config(TAB_RTTY);
4158 		else if (md >= MODE_THOR_FIRST && md <= MODE_THOR_LAST) open_config(TAB_THOR);
4159 		else if (md >= MODE_OLIVIA_FIRST && md <= MODE_OLIVIA_LAST) open_config(TAB_OLIVIA);
4160 		else if (md >= MODE_PSK_FIRST && md <= MODE_PSK_LAST) open_config(TAB_PSK);
4161 		else if (md >= MODE_QPSK_FIRST && md <= MODE_QPSK_LAST) open_config(TAB_PSK);
4162 		else if (md >= MODE_8PSK_FIRST && md <= MODE_8PSK_LAST) open_config(TAB_PSK);
4163 		else if (md >= MODE_MT63_FIRST && md <= MODE_MT63_LAST) open_config(TAB_MT63);
4164 		else if (md >= MODE_NAVTEX_FIRST && md <= MODE_NAVTEX_LAST) open_config(TAB_NAVTEX);
4165 		else if (md >= MODE_WEFAX_FIRST && md <= MODE_WEFAX_LAST) open_config(TAB_WEFAX);
4166 		else if (md >= MODE_HELL_FIRST && md <= MODE_HELL_LAST) open_config(TAB_FELDHELL);
4167 		else if (md >= MODE_DOMINOEX_FIRST && md <= MODE_DOMINOEX_LAST) open_config(TAB_DOMINOEX);
4168 		else if (md >= MODE_CONTESTIA_FIRST && md <= MODE_CONTESTIA_LAST) open_config(TAB_CONTESTIA);
4169 	}
4170 	else {
4171 		if (!quick_change)
4172 			return;
4173 		const Fl_Menu_Item *m = quick_change->popup(Fl::event_x(), Fl::event_y());
4174 		if (m && m->callback())
4175 		m->do_callback(0);
4176 	}
4177 	static_cast<Fl_Button*>(b)->clear();
4178 	restoreFocus(23);
4179 }
4180 
cbAFC(Fl_Widget * w,void * vi)4181 void cbAFC(Fl_Widget *w, void *vi)
4182 {
4183 	Fl_Button *b = (Fl_Button *)w;
4184 	int v = b->value();
4185 	progStatus.afconoff = v;
4186 }
4187 
cbSQL(Fl_Widget * w,void * vi)4188 void cbSQL(Fl_Widget *w, void *vi)
4189 {
4190 	Fl_Button *b = (Fl_Button *)w;
4191 	int v = b->value();
4192 	progStatus.sqlonoff = v ? true : false;
4193 }
4194 
4195 extern void set_wf_mode(void);
4196 
cbPwrSQL(Fl_Widget * w,void * vi)4197 void cbPwrSQL(Fl_Widget *w, void *vi)
4198 {
4199 	Fl_Button *b = (Fl_Button *)w;
4200 	int v = b->value();
4201 	if(!v) {
4202 		sldrSquelch->value(progStatus.sldrSquelchValue);
4203 		progStatus.kpsql_enabled = false;
4204 		progdefaults.kpsql_enabled = false;
4205 		b->clear();
4206 	} else {
4207 		sldrSquelch->value(progStatus.sldrPwrSquelchValue);
4208 		progStatus.kpsql_enabled = true;
4209 		progdefaults.kpsql_enabled = true;
4210 		set_wf_mode();
4211 		b->set();
4212 	}
4213 }
4214 
startMacroTimer()4215 void startMacroTimer()
4216 {
4217 	ENSURE_THREAD(FLMAIN_TID);
4218 
4219 	btnMacroTimer->color(fl_rgb_color(240, 240, 0));
4220 	btnMacroTimer->clear_output();
4221 	Fl::add_timeout(0.0, macro_timer);
4222 }
4223 
stopMacroTimer()4224 void stopMacroTimer()
4225 {
4226 	ENSURE_THREAD(FLMAIN_TID);
4227 
4228 	progStatus.timer = 0;
4229 	progStatus.repeatMacro = -1;
4230 	local_timed_exec = false;
4231 	Fl::remove_timeout(macro_timer);
4232 	Fl::remove_timeout(macro_timed_execute);
4233 
4234 	btnMacroTimer->label(0);
4235 	btnMacroTimer->color(FL_BACKGROUND_COLOR);
4236 	btnMacroTimer->set_output();
4237 }
4238 
macro_timer(void *)4239 void macro_timer(void*)
4240 {
4241 	char buf[8];
4242 	snprintf(buf, sizeof(buf), "%d", progStatus.timer);
4243 	btnMacroTimer->copy_label(buf);
4244 
4245 	if (progStatus.timer-- == 0) {
4246 		stopMacroTimer();
4247 		if (active_modem->get_mode() == MODE_IFKP) {
4248 			ifkp_tx_text->clear();
4249 		} else {
4250 			TransmitText->clear();
4251 		}
4252 		macros.execute(progStatus.timerMacro);
4253 	}
4254 	else
4255 		Fl::repeat_timeout(1.0, macro_timer);
4256 }
4257 
4258 static long mt_xdt, mt_xtm;
4259 
4260 // called by main loop...ok to write to widget
show_clock(bool yes)4261 void show_clock(bool yes)
4262 {
4263 	if (!yes) {
4264 		StatusBar->label("");
4265 		StatusBar->redraw();
4266 		return;
4267 	}
4268 	static char s_clk_time[40];
4269 	time_t sked_time = time(NULL);
4270 	tm sked_tm;
4271 	gmtime_r(&sked_time, &sked_tm);
4272 	int hrs = sked_tm.tm_hour;
4273 	int mins = sked_tm.tm_min;
4274 	int secs = sked_tm.tm_sec;
4275 	snprintf(s_clk_time, sizeof(s_clk_time), "%02d:%02d:%02d",
4276 		hrs, mins, secs);
4277 	StatusBar->label(s_clk_time);
4278 	StatusBar->redraw();
4279 }
4280 
4281 static int timed_ptt = -1;
macro_timed_execute(void *)4282 void macro_timed_execute(void *)
4283 {
4284 	long dt, tm;
4285 	dt = atol(local_timed_exec ? ldate() : zdate());
4286 	tm = atol(local_timed_exec ? ltime() : ztime());
4287 	if (dt >= mt_xdt && tm >= mt_xtm) {
4288 		show_clock(false);
4289 		if (timed_ptt != 1) {
4290 			push2talk->set(true);
4291 			timed_ptt = 1;
4292 		}
4293 		macros.timed_execute();
4294 		btnMacroTimer->label(0);
4295 		btnMacroTimer->color(FL_BACKGROUND_COLOR);
4296 		btnMacroTimer->set_output();
4297 		mt_xdt = mt_xtm = 0;
4298 	} else {
4299 		show_clock(true);
4300 		if (timed_ptt != 0) {
4301 			push2talk->set(false);
4302 			timed_ptt = 0;
4303 		}
4304 		Fl::repeat_timeout(1.0, macro_timed_execute);
4305 	}
4306 }
4307 
startTimedExecute(std::string & title)4308 void startTimedExecute(std::string &title)
4309 {
4310 	ENSURE_THREAD(FLMAIN_TID);
4311 	string txt = "Macro '";
4312 	txt.append(title).
4313 		append("' scheduled on ").
4314 		append(exec_date.substr(0,4)).append("/").
4315 		append(exec_date.substr(4,2)).append("/").
4316 		append(exec_date.substr(6,2)).
4317 		append(" at ").
4318 		append(exec_time.substr(0,2)).append(":").
4319 		append(exec_time.substr(2,2)).append(":").
4320 		append(exec_time.substr(4,2)).
4321 		append(local_timed_exec ? " Local" : " Zulu").
4322 		append("\n");
4323 
4324 	btnMacroTimer->label("SKED");
4325 	btnMacroTimer->color(fl_rgb_color(240, 240, 0));
4326 	btnMacroTimer->redraw_label();
4327 	ReceiveText->clear();
4328 	ReceiveText->addstr(txt, FTextBase::CTRL);
4329 	mt_xdt = atol(exec_date.c_str());
4330 	mt_xtm = atol(exec_time.c_str());
4331 	Fl::add_timeout(0.0, macro_timed_execute);
4332 }
4333 
cbMacroTimerButton(Fl_Widget *,void *)4334 void cbMacroTimerButton(Fl_Widget*, void*)
4335 {
4336 	stopMacroTimer();
4337 	restoreFocus(24);
4338 }
4339 
cb_mvsquelch(Fl_Widget * w,void * d)4340 void cb_mvsquelch(Fl_Widget *w, void *d)
4341 {
4342 	progStatus.squelch_value = mvsquelch->value();
4343 
4344 	if (active_modem->get_mode() == MODE_CW)
4345 		progStatus.VIEWER_cwsquelch = progStatus.squelch_value;
4346 	else if (active_modem->get_mode() == MODE_RTTY)
4347 		progStatus.VIEWER_rttysquelch = progStatus.squelch_value;
4348 	else
4349 		progStatus.VIEWER_psksquelch = progStatus.squelch_value;
4350 
4351 	if (sldrViewerSquelch)
4352 		sldrViewerSquelch->value(progStatus.squelch_value);
4353 
4354 }
4355 
cb_btnClearMViewer(Fl_Widget * w,void * d)4356 void cb_btnClearMViewer(Fl_Widget *w, void *d)
4357 {
4358 	if (brwsViewer)
4359 		brwsViewer->clear();
4360 	mainViewer->clear();
4361 	active_modem->clear_viewer();
4362 }
4363 
default_handler(int event)4364 int default_handler(int event)
4365 {
4366 	if (bWF_only) {
4367 		if (Fl::event_key() == FL_Escape)
4368 			return 1;
4369 		return 0;
4370 	}
4371 
4372 	if (event != FL_SHORTCUT)
4373 		return 0;
4374 
4375 	if (RigViewerFrame && Fl::event_key() == FL_Escape &&
4376 		RigViewerFrame->visible() && Fl::event_inside(RigViewerFrame)) {
4377 		CloseQsoView();
4378 		return 1;
4379 	}
4380 
4381 	Fl_Widget* w = Fl::focus();
4382 
4383 	int key = Fl::event_key();
4384 	if ((key == FL_F + 4) && Fl::event_alt()) clean_exit(true);
4385 
4386 	if (fl_digi_main->contains(w)) {
4387 		if (key == FL_Escape || (key >= FL_F && key <= FL_F_Last) ||
4388 			((key == '1' || key == '2' || key == '3' || key == '4') && Fl::event_alt())) {
4389 			TransmitText->take_focus();
4390 			TransmitText->handle(FL_KEYBOARD);
4391 			return 1;
4392 		}
4393 #ifdef __APPLE__
4394 		if ((key == '=') && (Fl::event_state() == FL_COMMAND))
4395 #else
4396 		if (key == '=' && Fl::event_alt())
4397 #endif
4398 		{
4399 			progdefaults.txlevel += 0.1;
4400 			if (progdefaults.txlevel > 0) progdefaults.txlevel = 0;
4401 			cntTxLevel->value(progdefaults.txlevel);
4402 			return 1;
4403 		}
4404 #ifdef __APPLE__
4405 		if ((key == '-') && (Fl::event_state() == FL_COMMAND))
4406 #else
4407 		if (key == '-' && Fl::event_alt())
4408 #endif
4409 		{
4410 			progdefaults.txlevel -= 0.1;
4411 			if (progdefaults.txlevel < -30) progdefaults.txlevel = -30;
4412 			cntTxLevel->value(progdefaults.txlevel);
4413 			return 1;
4414 		}
4415 	}
4416 	else if (dlgLogbook->contains(w))
4417 		return log_search_handler(event);
4418 
4419 	else if (Fl::event_key() == FL_Escape)
4420 		return 1;
4421 
4422 	else if ( (fl_digi_main->contains(w) || dlgLogbook->contains(w)) &&
4423 				Fl::event_ctrl() )
4424 			return w->handle(FL_KEYBOARD);
4425 
4426 	return 0;
4427 }
4428 
wo_default_handler(int event)4429 int wo_default_handler(int event)
4430 {
4431 	if (event != FL_SHORTCUT)
4432 		return 0;
4433 
4434 	if (RigViewerFrame && Fl::event_key() == FL_Escape &&
4435 		RigViewerFrame->visible() && Fl::event_inside(RigViewerFrame)) {
4436 		CloseQsoView();
4437 		return 1;
4438 	}
4439 
4440 	Fl_Widget* w = Fl::focus();
4441 	int key = Fl::event_key();
4442 
4443 	if ((key == FL_F + 4) && Fl::event_alt()) clean_exit(true);
4444 
4445 	if (fl_digi_main->contains(w)) {
4446 		if (key == FL_Escape || (key >= FL_F && key <= FL_F_Last) ||
4447 			((key == '1' || key == '2' || key == '3' || key == '4') && Fl::event_alt())) {
4448 			return 1;
4449 		}
4450 #ifdef __APPLE__
4451 		if ((key == '=') && (Fl::event_state() == FL_COMMAND))
4452 #else
4453 		if (key == '=' && Fl::event_alt())
4454 #endif
4455 		{
4456 			progdefaults.txlevel += 0.1;
4457 			if (progdefaults.txlevel > 0) progdefaults.txlevel = 0;
4458 			cntTxLevel->value(progdefaults.txlevel);
4459 			return 1;
4460 		}
4461 #ifdef __APPLE__
4462 		if ((key == '-') && (Fl::event_state() == FL_COMMAND))
4463 #else
4464 		if (key == '-' && Fl::event_alt())
4465 #endif
4466 		{
4467 			progdefaults.txlevel -= 0.1;
4468 			if (progdefaults.txlevel < -30) progdefaults.txlevel = -30;
4469 			cntTxLevel->value(progdefaults.txlevel);
4470 			return 1;
4471 		}
4472 	}
4473 
4474 	else if (Fl::event_ctrl()) return w->handle(FL_KEYBOARD);
4475 
4476 	return 0;
4477 }
4478 
save_on_exit()4479 void save_on_exit() {
4480 	if (progdefaults.changed && progdefaults.SaveConfig) {
4481 		switch (fl_choice2(_("Save changed configuration?"), NULL, _("Yes"), _("No"))) {
4482 			case 1:
4483 				progdefaults.saveDefaults();
4484 			default:
4485 				break;
4486 		}
4487 	}
4488 	if (macros.changed && progdefaults.SaveMacros) {
4489 		switch (fl_choice2(_("Save changed macros?"), NULL, _("Yes"), _("No"))) {
4490 			case 1:
4491 				macros.writeMacroFile();
4492 			default:
4493 				break;
4494 		}
4495 	}
4496 	if (!oktoclear && progdefaults.NagMe) {
4497 		switch (fl_choice2(_("Save log entry?"), NULL, _("Yes"), _("No"))) {
4498 			case 1:
4499 				qsoSave_cb(0, 0);
4500 			default:
4501 				break;
4502 		}
4503 	}
4504 	return;
4505 }
4506 
4507 bool first_use = false;
4508 
4509 bool bEXITING = false;
4510 
clean_exit(bool ask)4511 bool clean_exit(bool ask) {
4512 	if (ask && first_use) {
4513 		switch(fl_choice2(_("Confirm Quit"), NULL, _("Yes"), _("No"))) {
4514 			case 2:
4515 				return false;
4516 			default:
4517 				break;
4518 		}
4519 		progdefaults.saveDefaults();
4520 		macros.writeMacroFile();
4521 		if (!oktoclear) {
4522 			switch (fl_choice2(_("Save log entry?"), NULL, _("Yes"), _("No"))) {
4523 				case 1:
4524 					qsoSave_cb(0, 0);
4525 				default:
4526 					break;
4527 			}
4528 		}
4529 	} else {
4530 		if (ask &&
4531 			progdefaults.confirmExit &&
4532 			(!(progdefaults.changed && progdefaults.SaveConfig) ||
4533 			 !(macros.changed && progdefaults.SaveMacros) ||
4534 			 !(!oktoclear && progdefaults.NagMe))) {
4535 			switch (fl_choice2(_("Confirm quit?"), NULL, _("Yes"), _("No"))) {
4536 				case 1:
4537 					break;
4538 				default:
4539 					return false;
4540 			}
4541 		}
4542 		if (ask)
4543 			save_on_exit();
4544 	}
4545 
4546 	bEXITING = true;
4547 
4548 	if (Maillogfile)
4549 		Maillogfile->log_to_file_stop();
4550 	if (logfile)
4551 		logfile->log_to_file_stop();
4552 
4553 	saveFreqList();
4554 
4555 	progStatus.saveLastState();
4556 
4557 	if (scopeview) scopeview->hide();
4558 	if (dlgViewer) dlgViewer->hide();
4559 	if (dlgLogbook) dlgLogbook->hide();
4560 
4561 	if (trx_state != STATE_RX) {
4562 LOG_INFO("Disable TUNE");
4563 		btnTune->labelcolor(FL_FOREGROUND_COLOR);
4564 		Fl::flush();
4565 		push2talk->set(0);
4566 		set_flrig_ptt(0);
4567 		trx_receive();
4568 		MilliSleep(200);
4569 	}
4570 
4571 LOG_INFO("Disable PTT");
4572 	delete push2talk;
4573 #if USE_HAMLIB
4574 LOG_INFO("Close hamlib");
4575 	hamlib_close();
4576 #endif
4577 LOG_INFO("Close rigCAT");
4578 	rigCAT_close();
4579 
4580 LOG_INFO("Close ADIF i/o");
4581 	ADIF_RW_close();
4582 
4583 LOG_INFO("Close T/R processing");
4584 	trx_close();
4585 
4586 #if USE_HAMLIB
4587 	if (xcvr) delete xcvr;
4588 #endif
4589 
4590 LOG_INFO("Close logbook");
4591 	close_logbook();
4592 	MilliSleep(50);
4593 
4594 LOG_INFO("Stop flrig i/o");
4595 	stop_flrig_thread();
4596 
4597 LOG_INFO("Stop N3FJP logging");
4598 	n3fjp_close();
4599 
4600 LOG_INFO("Stop FMT process");
4601 	FMT_thread_close();
4602 
4603 LOG_INFO("Close WinKeyer i/o");
4604 	WK_exit();
4605 
4606 LOG_INFO("Stop TOD clock");
4607 	TOD_close();
4608 
4609 LOG_INFO("Delete audio_alert");
4610 	delete audio_alert;
4611 
4612 LOG_INFO("Exit_process");
4613 	exit_process();
4614 
4615 
4616 	if (field_day_viewer)
4617 		if (field_day_viewer->visible())
4618 			field_day_viewer->hide();
4619 
4620 	if (dxcluster_viewer)
4621 		if (dxcluster_viewer->visible())
4622 			dxcluster_viewer->hide();
4623 
4624 	save_counties();
4625 
4626 	return true;
4627 }
4628 
4629 bool first_check = true;
4630 
UI_check_swap()4631 void UI_check_swap()
4632 {
4633 	int mv_x = text_panel->x();
4634 	int mv_y = text_panel->y();
4635 	int mv_w = mvgroup->w() > 1 ? mvgroup->w() : text_panel->w() / 2;
4636 	int mv_h = text_panel->h();
4637 
4638 	int tx_y = 0, tx_h = 0, tx_x = 0, tx_w = 0;
4639 	int rx_y = 0, rx_h = 0, rx_x = 0, rx_w = 0;
4640 
4641 	if (progdefaults.rxtx_swap && (ReceiveText->y() <= TransmitText->y())) {
4642 		tx_y = ReceiveText->y();
4643 		tx_h = first_check ? progStatus.tile_y : TransmitText->h();
4644 		tx_x = mv_x + mv_w;
4645 		tx_w = text_panel->w() - mv_w;
4646 
4647 		rx_y = tx_y + tx_h;
4648 		rx_h = mv_h - tx_h;
4649 		rx_x = tx_x;
4650 		rx_w = tx_w;
4651 
4652 		text_panel->remove(minbox);
4653 		text_panel->remove(TransmitText);
4654 		text_panel->remove(FHdisp);
4655 		text_panel->remove(ReceiveText);
4656 		text_panel->remove(mvgroup);
4657 
4658 		mvgroup->resize(mv_x, mv_y, mv_w, mv_h);
4659 		TransmitText->resize(tx_x, tx_y, tx_w, tx_h);
4660 		ReceiveText->resize(rx_x, rx_y, rx_w, rx_h);
4661 		FHdisp->resize(rx_x, rx_y, rx_w, rx_h);
4662 		minbox->resize(
4663 				text_panel->x(),
4664 				text_panel->y() + minhtext,
4665 				text_panel->w() - 100,
4666 				text_panel->h() - 2*minhtext);
4667 
4668 		text_panel->add(mvgroup);
4669 		text_panel->add(TransmitText);
4670 		text_panel->add(ReceiveText);
4671 		text_panel->add(FHdisp);
4672 		text_panel->add(minbox);
4673 		text_panel->resizable(minbox);
4674 		progStatus.tile_y = TransmitText->h();
4675 		progStatus.tile_y_ratio = 1.0 * TransmitText->h() / text_panel->h();
4676 	}
4677 	else if (!progdefaults.rxtx_swap && ReceiveText->y() > TransmitText->y()) {
4678 		rx_y = TransmitText->y();
4679 		rx_h = first_check ? progStatus.tile_y : ReceiveText->h();
4680 		rx_x = mv_x + mv_w;
4681 		rx_w = text_panel->w() - mv_w;
4682 
4683 		tx_y = rx_y + rx_h;
4684 		tx_h = mv_h - rx_h;
4685 		tx_x = rx_x;
4686 		tx_w = rx_w;
4687 
4688 		text_panel->remove(minbox);
4689 		text_panel->remove(TransmitText);
4690 		text_panel->remove(FHdisp);
4691 		text_panel->remove(ReceiveText);
4692 		text_panel->remove(mvgroup);
4693 
4694 		mvgroup->resize(mv_x, mv_y, mv_w, mv_h);
4695 		TransmitText->resize(tx_x, tx_y, tx_w, tx_h);
4696 		ReceiveText->resize(rx_x, rx_y, rx_w, rx_h);
4697 		FHdisp->resize(rx_x, rx_y, rx_w, rx_h);
4698 		minbox->resize(
4699 			text_panel->x(),
4700 			text_panel->y() + minhtext,
4701 			text_panel->w() - 100,
4702 			text_panel->h() - 2*minhtext);
4703 
4704 		text_panel->add(mvgroup);
4705 		text_panel->add(ReceiveText);
4706 		text_panel->add(FHdisp);
4707 		text_panel->add(TransmitText);
4708 		text_panel->add(minbox);
4709 		text_panel->resizable(minbox);
4710 		progStatus.tile_y = ReceiveText->h();
4711 		progStatus.tile_y_ratio = 1.0 * ReceiveText->h() / text_panel->h();
4712 	}
4713 
4714 // resize fsq UI
4715 	int fsq_rx_h = text_panel->h() * progStatus.fsq_ratio;
4716 	if (fsq_rx_h < minhtext) fsq_rx_h = minhtext;
4717 	int fsq_tx_h = text_panel->h() - fsq_rx_h;
4718 	if (fsq_tx_h < minhtext) {
4719 		fsq_tx_h = minhtext;
4720 		fsq_rx_h = text_panel->h() - fsq_tx_h;
4721 	}
4722 
4723 	fsq_left->remove(fsq_minbox);
4724 	fsq_left->remove(fsq_rx_text);
4725 	fsq_left->remove(fsq_tx_text);
4726 
4727 	fsq_rx_text->resize(fsq_left->x(), fsq_left->y(), fsq_left->w(), fsq_rx_h);
4728 	fsq_tx_text->resize(fsq_left->x(), fsq_left->y() + fsq_rx_text->h(), fsq_left->w(), fsq_tx_h);
4729 	fsq_minbox->resize(
4730 			text_panel->x(),
4731 			text_panel->y() + minhtext,
4732 			text_panel->w() - 100,
4733 			text_panel->h() - 2*minhtext);
4734 
4735 	fsq_left->add(fsq_rx_text);
4736 	fsq_left->add(fsq_tx_text);
4737 	fsq_left->add(fsq_minbox);
4738 	fsq_left->resizable(fsq_minbox);
4739 
4740 // resize IFKP UI
4741 	int ifkp_rx_h = text_panel->h() * progStatus.ifkp_ratio;
4742 	if (ifkp_rx_h < minhtext) ifkp_rx_h = minhtext;
4743 	int ifkp_tx_h = text_panel->h() - ifkp_rx_h;
4744 	if (ifkp_tx_h < minhtext) {
4745 		ifkp_tx_h = minhtext;
4746 		ifkp_rx_h = text_panel->h() - ifkp_tx_h;
4747 	}
4748 
4749 	ifkp_left->remove(ifkp_minbox);
4750 	ifkp_left->remove(ifkp_rx_text);
4751 	ifkp_left->remove(ifkp_tx_text);
4752 
4753 	ifkp_rx_text->resize(
4754 		ifkp_left->x(), ifkp_left->y(),
4755 		ifkp_left->w(), ifkp_rx_h);
4756 	ifkp_tx_text->resize(
4757 		ifkp_left->x(), ifkp_left->y() + ifkp_rx_text->h(),
4758 		ifkp_left->w(), ifkp_tx_h);
4759 	ifkp_minbox->resize(
4760 		text_panel->x(),
4761 		text_panel->y() + minhtext,
4762 		text_panel->w() - 100,
4763 		text_panel->h() - 2*minhtext);
4764 
4765 	ifkp_left->add(ifkp_rx_text);
4766 	ifkp_left->add(ifkp_tx_text);
4767 	ifkp_left->add(ifkp_minbox);
4768 	ifkp_left->resizable(ifkp_minbox);
4769 
4770 	first_check = false;
4771 }
4772 
4773 static bool restore_minimize = false;
4774 
UI_select_central_frame(int y,int ht)4775 void UI_select_central_frame(int y, int ht)
4776 {
4777 	text_panel->resize(0, y, fl_digi_main->w(), ht);
4778 	center_group->init_sizes();
4779 }
4780 
resize_macroframe_1(int x,int y,int w,int h)4781 void resize_macroframe_1(int x, int y, int w, int h)
4782 {
4783 	macroFrame1->resize(x, y, w, h);
4784 	macroFrame1->init_sizes();
4785 	macroFrame1->redraw();
4786 }
4787 
resize_macroframe_2(int x,int y,int w,int h)4788 void resize_macroframe_2(int x, int y, int w, int h)
4789 {
4790 	macroFrame2->resize(x, y, w, h);
4791 	macroFrame2->init_sizes();
4792 	macroFrame2->redraw();
4793 }
4794 
UI_position_macros(int x,int y1,int w,int HTh)4795 void UI_position_macros(int x, int y1, int w, int HTh)
4796 {
4797 	int mh = progdefaults.macro_height;
4798 
4799 	if (progdefaults.display_48macros) {
4800 		macroFrame2->hide();
4801 		macroFrame1->hide();
4802 		if (!progdefaults.four_bar_position) {
4803 			tbar->resize(x, y1, w, 4 * TB_HEIGHT);
4804 			tbar->show();
4805 			y1 += tbar->h();
4806 			HTh -= tbar->h();
4807 			center_group->resize(x, y1, w, HTh);
4808 			text_panel->resize(x, y1, w, HTh);
4809 			wefax_group->resize(x, y1, w, HTh);
4810 			fsq_group->resize(x, y1, w, HTh);
4811 			ifkp_group->resize(x, y1, w, HTh);
4812 			fmt_group->resize(x, y1, w, HTh);
4813 			UI_select_central_frame(y1, HTh);
4814 			y1 += HTh;
4815 			wf_group->position(x, y1);
4816 			y1 += wf_group->h();
4817 			status_group->position(x, y1);
4818 		} else {
4819 			int htbar = 4 * TB_HEIGHT;
4820 
4821 			HTh -= htbar;
4822 
4823 			center_group->resize(x, y1, w, HTh);
4824 			text_panel->resize(x, y1, w, HTh);
4825 			wefax_group->resize(x, y1, w, HTh);
4826 			fsq_group->resize(x, y1, w, HTh);
4827 			ifkp_group->resize(x, y1, w, HTh);
4828 			fmt_group->resize(x, y1, w, HTh);
4829 			UI_select_central_frame(y1, HTh);
4830 
4831 			y1 += HTh;
4832 
4833 			tbar->resize(x, y1, w, htbar);
4834 			tbar->show();
4835 
4836 			y1 += htbar;
4837 
4838 			wf_group->position(x, y1);
4839 			y1 += wf_group->h();
4840 			status_group->position(x, y1);
4841 		}
4842 		fl_digi_main->init_sizes();
4843 		return;
4844 	}
4845 
4846 	tbar->hide();
4847 	switch (progdefaults.mbar_scheme) { // 0, 1, 2 one bar schema
4848 		case 0:
4849 			resize_macroframe_2(x,y1,w,mh);
4850 			macroFrame2->hide();
4851 			btnAltMacros2->deactivate();
4852 			resize_macroframe_1(x, y1, w, mh);
4853 			macroFrame1->show();
4854 			btnAltMacros1->activate();
4855 			y1 += mh;
4856 			HTh -= mh;
4857 			center_group->resize(x, y1, w, HTh);
4858 			text_panel->resize(x, y1, w, HTh);
4859 			wefax_group->resize(x, y1, w, HTh);
4860 			fsq_group->resize(x, y1, w, HTh);
4861 			ifkp_group->resize(x, y1, w, HTh);
4862 			fmt_group->resize(x, y1, w, HTh);
4863 			UI_select_central_frame(y1, HTh);
4864 			y1 += HTh;
4865 			wf_group->position(x, y1);
4866 			y1 += wf_group->h();
4867 			status_group->position(x, y1);
4868 			break;
4869 		default:
4870 		case 1:
4871 			resize_macroframe_2(x,y1,w,mh);
4872 			macroFrame2->hide();
4873 			btnAltMacros2->deactivate();
4874 			HTh -= mh;
4875 			center_group->resize(x, y1, w, HTh);
4876 //			text_panel->resize(x, y1, w, HTh);
4877 //			wefax_group->resize(x, y1, w, HTh);
4878 //			fsq_group->resize(x, y1, w, HTh);
4879 //			ifkp_group->resize(x, y1, w, HTh);
4880 			UI_select_central_frame(y1, HTh);
4881 			y1 += HTh;
4882 			resize_macroframe_1(x, y1, w, mh);
4883 			macroFrame1->show();
4884 			btnAltMacros1->activate();
4885 			y1 += mh;
4886 			wf_group->position(x, y1);
4887 			y1 += wf_group->h();
4888 			status_group->position(x, y1);
4889 			break;
4890 		case 2:
4891 			resize_macroframe_2(x,y1,w,mh);
4892 			macroFrame2->hide();
4893 			btnAltMacros2->deactivate();
4894 			HTh -= mh;
4895 			center_group->resize(x, y1, w, HTh);
4896 			text_panel->resize(x, y1, w, HTh);
4897 			wefax_group->resize(x, y1, w, HTh);
4898 			fsq_group->resize(x, y1, w, HTh);
4899 			ifkp_group->resize(x, y1, w, HTh);
4900 			fmt_group->resize(x, y1, w, HTh);
4901 			UI_select_central_frame(y1, HTh);
4902 			y1 += HTh;
4903 			wf_group->position(x, y1);
4904 			y1 += wf_group->h();
4905 			resize_macroframe_1(x, y1, w, mh);
4906 			macroFrame1->show();
4907 			btnAltMacros1->activate();
4908 			y1 += mh;
4909 			status_group->position(x, y1);
4910 			break;
4911 		case 3:
4912 			resize_macroframe_1(x, y1, w, mh);
4913 			macroFrame1->show();
4914 			btnAltMacros1->deactivate();
4915 			y1 += mh;
4916 			HTh -= mh;
4917 			resize_macroframe_2(x, y1, w, mh);
4918 			macroFrame2->show();
4919 			btnAltMacros2->activate();
4920 			y1 += mh;
4921 			HTh -= mh;
4922 			center_group->resize(x, y1, w, HTh);
4923 			text_panel->resize(x, y1, w, HTh);
4924 			wefax_group->resize(x, y1, w, HTh);
4925 			fsq_group->resize(x, y1, w, HTh);
4926 			ifkp_group->resize(x, y1, w, HTh);
4927 			fmt_group->resize(x, y1, w, HTh);
4928 			UI_select_central_frame(y1, HTh);
4929 			y1 += HTh;
4930 			wf_group->position(x, y1);
4931 			y1 += wf_group->h();
4932 			status_group->position(x, y1);
4933 			break;
4934 		case 4:
4935 			resize_macroframe_2(x, y1, w, mh);
4936 			macroFrame2->show();
4937 			btnAltMacros2->activate();
4938 			y1 += mh;
4939 			HTh -= mh;
4940 			resize_macroframe_1(x, y1, w, mh);
4941 			macroFrame1->show();
4942 			btnAltMacros1->deactivate();
4943 			y1 += mh;
4944 			HTh -= mh;
4945 			center_group->resize(x, y1, w, HTh);
4946 			text_panel->resize(x, y1, w, HTh);
4947 			wefax_group->resize(x, y1, w, HTh);
4948 			fsq_group->resize(x, y1, w, HTh);
4949 			ifkp_group->resize(x, y1, w, HTh);
4950 			fmt_group->resize(x, y1, w, HTh);
4951 			UI_select_central_frame(y1, HTh);
4952 			y1 += HTh;
4953 			wf_group->position(x, y1);
4954 			y1 += wf_group->h();
4955 			status_group->position(x, y1);
4956 			break;
4957 		case 5:
4958 			HTh -= 2*mh;
4959 			center_group->resize(x, y1, w, HTh);
4960 			text_panel->resize(x, y1, w, HTh);
4961 			wefax_group->resize(x, y1, w, HTh);
4962 			fsq_group->resize(x, y1, w, HTh);
4963 			ifkp_group->resize(x, y1, w, HTh);
4964 			fmt_group->resize(x, y1, w, HTh);
4965 			UI_select_central_frame(y1, HTh);
4966 			y1 += HTh;
4967 			resize_macroframe_1(x, y1, w, mh);
4968 			macroFrame1->show();
4969 			btnAltMacros1->deactivate();
4970 			y1 += mh;
4971 			resize_macroframe_2(x, y1, w, mh);
4972 			macroFrame2->show();
4973 			btnAltMacros2->activate();
4974 			y1 += mh;
4975 			wf_group->position(x, y1);
4976 			y1 += wf_group->h();
4977 			status_group->position(x, y1);
4978 			break;
4979 		case 6:
4980 			HTh -= 2*mh;
4981 			center_group->resize(x, y1, w, HTh);
4982 			text_panel->resize(x, y1, w, HTh);
4983 			wefax_group->resize(x, y1, w, HTh);
4984 			fsq_group->resize(x, y1, w, HTh);
4985 			ifkp_group->resize(x, y1, w, HTh);
4986 			fmt_group->resize(x, y1, w, HTh);
4987 			y1 += HTh;
4988 			resize_macroframe_2(x, y1, w, mh);
4989 			macroFrame2->show();
4990 			btnAltMacros2->activate();
4991 			y1 += mh;
4992 			resize_macroframe_1(x, y1, w, mh);
4993 			macroFrame1->show();
4994 			btnAltMacros1->deactivate();
4995 			y1 += mh;
4996 			wf_group->position(x, y1);
4997 			y1 += wf_group->h();
4998 			status_group->position(x, y1);
4999 			break;
5000 		case 7:
5001 			HTh -= 2*mh;
5002 			center_group->resize(x, y1, w, HTh);
5003 			text_panel->resize(x, y1, w, HTh);
5004 			wefax_group->resize(x, y1, w, HTh);
5005 			fsq_group->resize(x, y1, w, HTh);
5006 			ifkp_group->resize(x, y1, w, HTh);
5007 			fmt_group->resize(x, y1, w, HTh);
5008 			UI_select_central_frame(y1, HTh);
5009 			y1 += HTh;
5010 			resize_macroframe_1(x, y1, w, mh);
5011 			macroFrame1->show();
5012 			btnAltMacros1->deactivate();
5013 			y1 += mh;
5014 			wf_group->position(x, y1);
5015 			y1 += wf_group->h();
5016 			resize_macroframe_2(x, y1, w, mh);
5017 			macroFrame2->show();
5018 			y1 += mh;
5019 			status_group->position(x, y1);
5020 			break;
5021 		case 8:
5022 			HTh -= 2*mh;
5023 			center_group->resize(x, y1, w, HTh);
5024 			text_panel->resize(x, y1, w, HTh);
5025 			wefax_group->resize(x, y1, w, HTh);
5026 			fsq_group->resize(x, y1, w, HTh);
5027 			ifkp_group->resize(x, y1, w, HTh);
5028 			fmt_group->resize(x, y1, w, HTh);
5029 			y1 += HTh;
5030 			resize_macroframe_2(x, y1, w, mh);
5031 			macroFrame2->show();
5032 			y1 += mh;
5033 			wf_group->position(x, y1);
5034 			y1 += wf_group->h();
5035 			resize_macroframe_1(x, y1, w, mh);
5036 			macroFrame1->show();
5037 			btnAltMacros1->deactivate();
5038 			y1 += mh;
5039 			status_group->position(x, y1);
5040 			break;
5041 		case 9:
5042 			HTh -= 2*mh;
5043 			center_group->resize(x, y1, w, HTh);
5044 			text_panel->resize(x, y1, w, HTh);
5045 			wefax_group->resize(x, y1, w, HTh);
5046 			fsq_group->resize(x, y1, w, HTh);
5047 			ifkp_group->resize(x, y1, w, HTh);
5048 			fmt_group->resize(x, y1, w, HTh);
5049 			UI_select_central_frame(y1, HTh);
5050 			y1 += HTh;
5051 			wf_group->position(x, y1);
5052 			y1 += wf_group->h();
5053 			resize_macroframe_1(x, y1, w, mh);
5054 			macroFrame1->show();
5055 			btnAltMacros1->deactivate();
5056 			y1 += mh;
5057 			resize_macroframe_2(x, y1, w, mh);
5058 			macroFrame2->show();
5059 			btnAltMacros2->activate();
5060 			y1 += mh;
5061 			status_group->position(x, y1);
5062 			break;
5063 		case 10:
5064 			HTh -= 2*mh;
5065 			center_group->resize(x, y1, w, HTh);
5066 			text_panel->resize(x, y1, w, HTh);
5067 			wefax_group->resize(x, y1, w, HTh);
5068 			fsq_group->resize(x, y1, w, HTh);
5069 			ifkp_group->resize(x, y1, w, HTh);
5070 			fmt_group->resize(x, y1, w, HTh);
5071 			UI_select_central_frame(y1, HTh);
5072 			y1 += HTh;
5073 			wf_group->position(x, y1);
5074 			y1 += wf_group->h();
5075 			resize_macroframe_2(x, y1, w, mh);
5076 			macroFrame2->show();
5077 			btnAltMacros2->activate();
5078 			y1 += mh;
5079 			resize_macroframe_1(x, y1, w, mh);
5080 			macroFrame1->show();
5081 			btnAltMacros1->deactivate();
5082 			y1 += mh;
5083 			status_group->position(x, y1);
5084 			break;
5085 		case 11:
5086 			resize_macroframe_2(x, y1, w, mh);
5087 			macroFrame2->show();
5088 			btnAltMacros2->activate();
5089 			y1 += mh;
5090 			HTh -= 2*mh;
5091 			center_group->resize(x, y1, w, HTh);
5092 			text_panel->resize(x, y1, w, HTh);
5093 			wefax_group->resize(x, y1, w, HTh);
5094 			fsq_group->resize(x, y1, w, HTh);
5095 			ifkp_group->resize(x, y1, w, HTh);
5096 			fmt_group->resize(x, y1, w, HTh);
5097 			UI_select_central_frame(y1, HTh);
5098 			y1 += HTh;
5099 			resize_macroframe_1(x, y1, w, mh);
5100 			macroFrame1->show();
5101 			btnAltMacros1->deactivate();
5102 			y1 += mh;
5103 			wf_group->position(x, y1);
5104 			y1 += wf_group->h();
5105 			status_group->position(x, y1);
5106 			break;
5107 		case 12:
5108 			resize_macroframe_1(x, y1, w, mh);
5109 			macroFrame1->show();
5110 			btnAltMacros1->deactivate();
5111 			y1 += mh;
5112 			HTh -= 2*mh;
5113 			center_group->resize(x, y1, w, HTh);
5114 			text_panel->resize(x, y1, w, HTh);
5115 			wefax_group->resize(x, y1, w, HTh);
5116 			fsq_group->resize(x, y1, w, HTh);
5117 			ifkp_group->resize(x, y1, w, HTh);
5118 			fmt_group->resize(x, y1, w, HTh);
5119 			UI_select_central_frame(y1, HTh);
5120 			y1 += HTh;
5121 			resize_macroframe_2(x, y1, w, mh);
5122 			macroFrame2->show();
5123 			btnAltMacros2->activate();
5124 			y1 += mh;
5125 			wf_group->position(x, y1);
5126 			y1 += wf_group->h();
5127 			status_group->position(x, y1);
5128 			break;
5129 	}
5130 	fl_digi_main->init_sizes();
5131 	return;
5132 }
5133 
5134 bool UI_first = true;
UI_select()5135 void UI_select()
5136 {
5137 	if (bWF_only) {
5138 		int Y = cntTxLevel->y();
5139 		int psm_width = progdefaults.show_psm_btn ? bwSqlOnOff : 0;
5140 		int X = rightof(Status2);
5141 		int W = fl_digi_main->w() - X - bwTxLevel - Wwarn - bwAfcOnOff -
5142 			bwSqlOnOff - psm_width;
5143 
5144 		StatusBar->resize( X, Y, W, StatusBar->h());
5145 		VuMeter->resize( X, Y, W, VuMeter->h());
5146 
5147 		cntTxLevel->position(rightof(VuMeter), Y);
5148 
5149 		WARNstatus->position(rightof(cntTxLevel), Y);
5150 		btnAFC->position(rightof(WARNstatus), Y);
5151 		btnSQL->position(rightof(btnAFC), Y);
5152 		btnPSQL->resize(rightof(btnSQL), Y, psm_width, btnPSQL->h());
5153 
5154 		if (progdefaults.show_psm_btn)
5155 			btnPSQL->show();
5156 		else
5157 			btnPSQL->hide();
5158 
5159 		cntTxLevel->redraw();
5160 		WARNstatus->redraw();
5161 		btnAFC->redraw();
5162 		btnSQL->redraw();
5163 		btnPSQL->redraw();
5164 		StatusBar->redraw();
5165 
5166 		status_group->init_sizes();
5167 		status_group->redraw();
5168 
5169 		fl_digi_main->init_sizes();
5170 		fl_digi_main->redraw();
5171 		return;
5172 	}
5173 
5174 	int x =   0;
5175 	int y1 =  Hmenu;
5176 	int w =   fl_digi_main->w();
5177 	int HTh = fl_digi_main->h() - y1;
5178 
5179 	if (cnt_macro_height) {
5180 		cnt_macro_height->minimum(MACROBAR_MIN);
5181 		cnt_macro_height->maximum(MACROBAR_MAX);
5182 		cnt_macro_height->step(1);
5183 		if (progdefaults.macro_height < MACROBAR_MIN) progdefaults.macro_height = MACROBAR_MIN;
5184 		if (progdefaults.macro_height > MACROBAR_MAX) progdefaults.macro_height = MACROBAR_MAX;
5185 		cnt_macro_height->value(progdefaults.macro_height);
5186 	}
5187 
5188 	HTh -= wf_group->h();
5189 	HTh -= status_group->h();
5190 
5191 	if (progStatus.NO_RIGLOG && !restore_minimize) {
5192 		TopFrame1->hide();
5193 		TopFrame2->hide();
5194 		TopFrame3->hide();
5195 		Status2->hide();
5196 		inpCall4->show();
5197 		inpCall = inpCall4;
5198 		UI_position_macros(x, y1, w, HTh);
5199 		goto UI_return;
5200 	}
5201 
5202 	if (!progStatus.Rig_Log_UI || restore_minimize) {
5203 		TopFrame1->resize( x, y1, w, Hqsoframe );
5204 		y1 += (TopFrame1->h());
5205 		HTh -= (TopFrame1->h());
5206 		UI_position_macros(x, y1, w, HTh);
5207 		TopFrame2->hide();
5208 		TopFrame3->hide();
5209 		TopFrame1->show();
5210 		inpFreq = inpFreq1;
5211 		inpCall = inpCall1;
5212 		inpTimeOn = inpTimeOn1;
5213 		inpTimeOff = inpTimeOff1;
5214 		inpName = inpName1;
5215 		inpRstIn = inpRstIn1;
5216 		inpRstOut = inpRstOut1;
5217 		inpSerNo = inpSerNo1;
5218 		outSerNo = outSerNo1;
5219 		inpXchgIn = inpXchgIn1;
5220 		inpState = inpState1;
5221 		inpLoc = inpLoc1;
5222 		inpQTH = inpQth;
5223 		inp_JOTA_scout = inp_JOTA_scout1;
5224 		inp_JOTA_troop = inp_JOTA_troop1;
5225 		cboCountry = cboCountryQSO;
5226 
5227 		gGEN_QSO_1->hide();
5228 		gGEN_CONTEST->hide();
5229 		gCQWW_RTTY->hide();
5230 		gCQWW_DX->hide();
5231 		gFD->hide();
5232 		gCWSS->hide();
5233 		gKD_1->hide();
5234 		gARR->hide();
5235 		g1010->hide();
5236 		gVHF->hide();
5237 		gASCR->hide();
5238 		gNAQP->hide();
5239 		gARRL_RTTY->hide();
5240 		gIARI->hide();
5241 		gNAS->hide();
5242 		gAIDX->hide();
5243 		gJOTA->hide();
5244 		gAICW->hide();
5245 		gSQSO->hide();
5246 		gCQWPX->hide();
5247 		gWAE->hide();
5248 
5249 		switch (progdefaults.logging) {
5250 			case LOG_FD:
5251 				inpClass = inp_FD_class1;
5252 				inpSection = inp_FD_section1;
5253 				gFD->show();
5254 				break;
5255 			case LOG_WFD:
5256 				inpClass = inp_FD_class1;
5257 				inpSection = inp_FD_section1;
5258 				gFD->show();
5259 				break;
5260 			case LOG_KD:
5261 				inp_KD_age = inp_KD_age1;
5262 				inpState = inp_KD_state1;
5263 				inpVEprov = inp_KD_VEprov1;
5264 				inpXchgIn = inp_KD_XchgIn1;
5265 				gKD_1->show();
5266 				break;
5267 			case LOG_ARR:
5268 				inpCall = inpCall1;
5269 				inpName = inpName;
5270 				inp_ARR_check = inp_ARR_check1;
5271 				inpXchgIn = inp_ARR_XchgIn1;
5272 				gARR->show();
5273 				break;
5274 			case LOG_1010:
5275 				inp_1010_nr = inp_1010_nr1;
5276 				inpXchgIn = inp_1010_XchgIn1;
5277 				g1010->show();
5278 				break;
5279 			case LOG_VHF:
5280 				inpRstIn = inp_vhf_RSTin1;
5281 				inpRstOut = inp_vhf_RSTout1;
5282 				inpLoc = inp_vhf_Loc1;
5283 				inp_vhf_Loc1->show();
5284 				inp_vhf_RSTin1->show();
5285 				inp_vhf_RSTout1->show();
5286 				gVHF->show();
5287 				break;
5288 			case LOG_CQ_WPX:
5289 				inpSerNo = inpSerNo_WPX1;
5290 				outSerNo = outSerNo_WPX1;
5291 				inpSerNo_WPX1->show();
5292 				outSerNo_WPX1->show();
5293 				gCQWPX->show();
5294 				break;
5295 			case LOG_CQWW_DX:
5296 				cboCountry = cboCountryQSO;
5297 				inp_CQzone = inp_CQDXzone1;
5298 				inp_CQDXzone1->show();
5299 				gCQWW_DX->show();
5300 				break;
5301 			case LOG_CQWW_RTTY:
5302 				inpState = inp_CQstate = inp_CQstate1;
5303 				cboCountry = cboCountryQSO;
5304 				inp_CQzone = inp_CQzone1;
5305 				gCQWW_RTTY->show();
5306 				break;
5307 			case LOG_CWSS:
5308 				outSerNo = outSerNo3;
5309 				inpSerNo = inp_SS_SerialNoR1;
5310 				inp_SS_SerialNoR = inp_SS_SerialNoR1;
5311 				inp_SS_Check = inp_SS_Check1;
5312 				inp_SS_Precedence = inp_SS_Precedence1;
5313 				inp_SS_Section = inp_SS_Section1;
5314 				gCWSS->show();
5315 				break;
5316 			case LOG_ASCR:
5317 				inpClass = inp_ASCR_class1;
5318 				inpXchgIn = inp_ASCR_XchgIn1;
5319 				inp_ASCR_class1->show();
5320 				inp_ASCR_XchgIn1->show();
5321 				gASCR->show();
5322 				break;
5323 			case LOG_IARI:
5324 				inpXchgIn = inp_IARI_PR1;
5325 				cboCountry = cboCountryQSO;
5326 				inp_IARI_PR1->show();
5327 				gIARI->show();
5328 				break;
5329 			case LOG_NAQP:
5330 				inpSPCnum = inpSPCnum_NAQP1;
5331 				inpSPCnum_NAQP1->show();
5332 				gNAQP->show();
5333 				break;
5334 			case LOG_RTTY:
5335 				inpState = inpRTU_stpr1;
5336 				inpSerNo = inpRTU_serno1;
5337 				cboCountry = cboCountryQSO;
5338 				gARRL_RTTY->show();
5339 				break;
5340 			case LOG_NAS:
5341 				inpSerNo = inp_ser_NAS1;
5342 				inpXchgIn = inpSPCnum_NAS1;
5343 				outSerNo5->show();
5344 				inp_ser_NAS1->show();
5345 				inpSPCnum_NAS1->show();
5346 				gNAS->show();
5347 				break;
5348 			case LOG_AIDX:
5349 				outSerNo = outSerNo7;
5350 				inpSerNo = inpSerNo3;
5351 				cboCountry = cboCountryAIDX = cboCountryQSO;
5352 				outSerNo7->show();
5353 				inpSerNo3->show();
5354 				gAIDX->show();
5355 				break;
5356 			case LOG_JOTA:
5357 				inp_JOTA_scout = inp_JOTA_scout1;
5358 				inp_JOTA_troop = inp_JOTA_troop1;
5359 				inpXchgIn = inp_JOTA_spc1;
5360 				inp_JOTA_scout1->show();
5361 				inp_JOTA_spc1->show();
5362 				inp_JOTA_troop1->show();
5363 				gJOTA->show();
5364 				break;
5365 			case LOG_AICW:
5366 				inpSPCnum = inpSPCnum_AICW1;
5367 				cboCountry = cboCountryQSO;//cboCountryAICW1;
5368 				inpSPCnum_AICW1->show();
5369 				gAICW->show();
5370 				break;
5371 			case LOG_SQSO:
5372 				inpRstIn = inpRstIn1;
5373 				inpRstOut = inpRstOut1;
5374 				inpCounty = inpSQSO_county1;
5375 				inpSQSO_county1->show();
5376 				outSerNo = outSQSO_serno1;
5377 				outSQSO_serno1->show();
5378 				inpSerNo = inpSQSO_serno1;
5379 				inpSQSO_serno1->show();
5380 				inpState = inpSQSO_state1;
5381 				inpSQSO_state1->show();
5382 				if (progdefaults.SQSOlogcat) {
5383 					inpSQSO_category1->show();
5384 					inpSQSO_category = inpSQSO_category1;
5385 				} else {
5386 					inpSQSO_category1->hide();
5387 				}
5388 				gSQSO->show();
5389 				break;
5390 //			case LOG_WAE:
5391 //				inpSerNo = inpSerNo_WAE1;
5392 //				inpSerNo_WAE1->show();
5393 //				outSerNo = outSerNo_WAE1;
5394 //				outSerNo_WAE1->show();
5395 //				cboCountry = cboCountryWAE1;
5396 //				cboCountryWAE1->show();
5397 //				gWAE->show();
5398 //				break;
5399 			case LOG_BART:
5400 			case LOG_GENERIC:
5401 				gGEN_CONTEST->show();
5402 				break;
5403 		default: // no contest
5404 				gGEN_QSO_1->show();
5405 		}
5406 
5407 		gGEN_QSO_1->redraw();
5408 		gGEN_CONTEST->redraw();
5409 		gCQWW_RTTY->redraw();
5410 		gCQWW_DX->redraw();
5411 		gFD->redraw();
5412 		gCWSS->redraw();
5413 		gKD_1->redraw();
5414 		gARR->redraw();
5415 		g1010->redraw();
5416 		gVHF->redraw();
5417 		gIARI->redraw();
5418 		gAICW->redraw();
5419 		gSQSO->redraw();
5420 		gCQWPX->redraw();
5421 		gWAE->redraw();
5422 
5423 		qsoFreqDisp = qsoFreqDisp1;
5424 		TopFrame1->init_sizes();
5425 
5426 		goto UI_return;
5427 	}
5428 	else {
5429 		if (progdefaults.logging == LOG_QSO) { // no contest
5430 			TopFrame2->resize( x, y1, w, Hentry + 2 * pad);
5431 			y1 += TopFrame2->h();
5432 			HTh -= TopFrame2->h();
5433 			UI_position_macros(x, y1, w, HTh);
5434 			TopFrame1->hide();
5435 			TopFrame3->hide();
5436 			TopFrame2->show();
5437 			inpCall = inpCall2;
5438 			inpTimeOn = inpTimeOn2;
5439 			inpTimeOff = inpTimeOff2;
5440 			inpName = inpName2;
5441 			inpSerNo = inpSerNo1;
5442 			outSerNo = outSerNo1;
5443 			inpRstIn = inpRstIn2;
5444 			inpRstOut = inpRstOut2;
5445 			inpState = inpState1;
5446 			inpLoc = inpLoc1;
5447 			inpQTH = inpQth;
5448 			qsoFreqDisp = qsoFreqDisp2;
5449 			inpCall4->hide();
5450 			Status2->show();
5451 			goto UI_return;
5452 		}
5453 
5454 		TopFrame3->resize( x, y1, w, Hentry + 2 * pad);
5455 		y1 += TopFrame3->h();
5456 		HTh -= TopFrame3->h();
5457 		UI_position_macros(x, y1, w, HTh);
5458 		TopFrame1->hide();
5459 		TopFrame2->hide();
5460 		TopFrame3->show();
5461 		inpCall = inpCall3;
5462 		inpTimeOn = inpTimeOn3;
5463 		inpTimeOff = inpTimeOff3;
5464 
5465 		inpSerNo = inpSerNo2;
5466 		outSerNo = outSerNo2;
5467 		inpXchgIn = inpXchgIn2;
5468 
5469 //		inpSQSO_category2->hide();
5470 
5471 		log_generic_frame->hide();
5472 		log_fd_frame->hide();
5473 		log_kd_frame->hide();
5474 		log_1010_frame->hide();
5475 		log_arr_frame->hide();
5476 		log_vhf_frame->hide();
5477 		log_cqww_frame->hide();
5478 		log_cqww_rtty_frame->hide();
5479 		log_cqss_frame->hide();
5480 		log_cqwpx_frame->hide();
5481 		log_ascr_frame->hide();
5482 		log_naqp_frame->hide();
5483 		log_rtty_frame->hide();
5484 		log_iari_frame->hide();
5485 		log_nas_frame->hide();
5486 		log_aidx_frame->hide();
5487 		log_jota_frame->hide();
5488 		log_aicw_frame->hide();
5489 		log_sqso_frame->hide();
5490 		log_wae_frame->hide();
5491 
5492 		switch (progdefaults.logging) {
5493 			case LOG_QSO:
5494 				log_generic_frame->show();
5495 				break;
5496 			case LOG_FD:
5497 				log_fd_frame->show();
5498 				inpClass = inp_FD_class2;
5499 				inpSection = inp_FD_section2;
5500 				break;
5501 			case LOG_WFD:
5502 				log_fd_frame->show();
5503 				inpClass = inp_FD_class2;
5504 				inpSection = inp_FD_section2;
5505 				break;
5506 			case LOG_KD:
5507 				log_kd_frame->show();
5508 				inpName = inp_KD_name2;
5509 				inp_KD_age = inp_KD_age2;
5510 				inpState = inp_KD_state2;
5511 				inpVEprov = inp_KD_VEprov2;
5512 				inpXchgIn = inp_KD_XchgIn2;
5513 				break;
5514 			case LOG_ARR:
5515 				log_arr_frame->show();
5516 				inpCall = inpCall3;
5517 				inpName = inp_ARR_Name2;
5518 				inp_ARR_check = inp_ARR_check2;
5519 				inpXchgIn = inp_ARR_XchgIn2;
5520 				break;
5521 			case LOG_1010:
5522 				log_1010_frame->show();
5523 				inpName = inp_1010_name2;
5524 				inp_1010_nr = inp_1010_nr1;
5525 				inpXchgIn = inp_1010_XchgIn2;
5526 				break;
5527 			case LOG_VHF:
5528 				log_vhf_frame->show();
5529 				inpRstIn = inp_vhf_RSTin2;
5530 				inpRstOut = inp_vhf_RSTout2;
5531 				inpLoc = inp_vhf_Loc2;
5532 				break;
5533 			case LOG_CQWW_DX:
5534 				log_cqww_frame->show();
5535 				inpRstIn = inp_CQDX_RSTin2;
5536 				inpRstOut = inp_CQDX_RSTout2;
5537 				inp_CQzone = inp_CQDXzone2;
5538 				cboCountry = cboCountryCQDX2;
5539 				break;
5540 			case LOG_CQWW_RTTY:
5541 				log_cqww_rtty_frame->show();
5542 				inpRstIn = inp_CQ_RSTin2;
5543 				inpRstOut = inp_CQ_RSTout2;
5544 				inpState = inp_CQstate = inp_CQstate2;
5545 				inp_CQzone = inp_CQzone2;
5546 				cboCountry = cboCountryCQ2;
5547 				break;
5548 			case LOG_CWSS:
5549 				log_cqss_frame->show();
5550 				outSerNo = outSerNo4;
5551 				inpSerNo = inp_SS_SerialNoR2;
5552 				inpTimeOff = inpTimeOff3;
5553 				inpTimeOn = inpTimeOn3;
5554 				inp_SS_Check = inp_SS_Check2;
5555 				inp_SS_Precedence = inp_SS_Precedence2;
5556 				inp_SS_Section = inp_SS_Section2;
5557 				inp_SS_SerialNoR = inp_SS_SerialNoR2;
5558 				break;
5559 			case LOG_ASCR:
5560 				log_ascr_frame->show();
5561 				inpName = inp_ASCR_name2;
5562 				inpRstIn = inp_ASCR_RSTin2;
5563 				inpRstOut = inp_ASCR_RSTout2;
5564 				inpClass = inp_ASCR_class2;
5565 				inpXchgIn = inp_ASCR_XchgIn2;
5566 				break;
5567 			case LOG_IARI:
5568 				log_iari_frame->show();
5569 				inpRstIn = inp_IARI_RSTin2;
5570 				inpRstOut = inp_IARI_RSTout2;
5571 				inpSerNo = inp_IARI_SerNo2;
5572 				outSerNo = out_IARI_SerNo2;
5573 				inpXchgIn = inp_IARI_PR2;
5574 				cboCountry = cboCountryIARI2;
5575 				break;
5576 			case LOG_NAQP:
5577 				log_naqp_frame->show();
5578 				inpName = inpNAQPname2;
5579 				inpSPCnum = inpSPCnum_NAQP2;
5580 				break;
5581 			case LOG_RTTY:
5582 				log_rtty_frame->show();
5583 				inpState = inpRTU_stpr2;
5584 				inpRstIn = inpRTU_RSTin2;
5585 				inpRstOut = inpRTU_RSTout2;
5586 				inpSerNo = inpRTU_serno2;
5587 				cboCountry = cboCountryRTU2;
5588 				break;
5589 			case LOG_AIDX:
5590 				log_aidx_frame->show();
5591 				inpRstIn = inpRstIn3;
5592 				inpRstOut = inpRstOut3;
5593 				outSerNo = outSerNo8;
5594 				inpSerNo = inpSerNo4;
5595 				cboCountry = cboCountryAIDX = cboCountryAIDX2;
5596 				break;
5597 			case LOG_JOTA:
5598 				log_jota_frame->show();
5599 				inpRstIn = inpRstIn4;
5600 				inpRstOut = inpRstOut4;
5601 				inp_JOTA_scout = inp_JOTA_scout2;
5602 				inp_JOTA_troop = inp_JOTA_troop2;
5603 				inpXchgIn = inp_JOTA_spc2;
5604 				break;
5605 			case LOG_AICW:
5606 				log_aicw_frame->show();
5607 				inpRstIn = inpRstIn_AICW2;
5608 				inpRstOut = inpRstOut_AICW2;
5609 				cboCountry = cboCountryAICW2;
5610 				inpSPCnum = inpSPCnum_AICW2;
5611 				break;
5612 			case LOG_SQSO:
5613 				inpSQSO_category2->hide();
5614 				inpSQSO_name2->hide();
5615 				inpSQSO_serno2->hide();
5616 				inpRstOut_SQSO2->hide();
5617 				inpRstIn_SQSO2->hide();
5618 
5619 				inpState = inpSQSO_state2;
5620 				inpSQSO_state2->show();
5621 				inpCounty = inpSQSO_county2;
5622 				inpSQSO_county2->show();
5623 				if (progdefaults.SQSOlogcat) {
5624 					inpSQSO_category2->show();
5625 					inpSQSO_category2->redraw();
5626 					inpSQSO_category = inpSQSO_category2;
5627 				}
5628 				if (progdefaults.SQSOlogrst) {
5629 					inpRstIn = inpRstIn_SQSO2;
5630 					inpRstIn_SQSO2->show();
5631 					inpRstOut = inpRstOut_SQSO2;
5632 					inpRstOut_SQSO2->show();
5633 				}
5634 				if (progdefaults.SQSOlogserno) {
5635 					inpSerNo = inpSQSO_serno2;
5636 					inpSQSO_serno2->show();
5637 					outSerNo = outSQSO_serno2;
5638 					outSQSO_serno2->show();
5639 				}
5640 				if (progdefaults.SQSOlogname) {
5641 					inpName = inpSQSO_name2;
5642 					inpSQSO_name2->show();
5643 				}
5644 				inpSQSO_category2->redraw();
5645 				inpSQSO_name2->redraw();
5646 				inpSQSO_serno2->redraw();
5647 				inpRstOut_SQSO2->redraw();
5648 				inpRstIn_SQSO2->redraw();
5649 				inpSQSO_state2->redraw();
5650 				inpSQSO_county2->redraw();
5651 
5652 				log_sqso_frame->show();
5653 				break;
5654 			case LOG_NAS:
5655 				inpSerNo = inp_ser_NAS2;
5656 				inpXchgIn = inpSPCnum_NAS2;
5657 				inpName = inp_name_NAS2;
5658 				log_nas_frame->show();
5659 				break;
5660 			case LOG_CQ_WPX:
5661 				log_cqwpx_frame->show();
5662 				inpSerNo = inpSerNo_WPX2;
5663 				outSerNo = outSerNo_WPX2;
5664 				inpRstIn = inpRstIn_WPX2;
5665 				inpRstOut = inpRstOut_WPX2;
5666 				break;
5667 //			case LOG_WAE:
5668 //				log_wae_frame->show();
5669 //				inpSerNo = inpSerNo_WAE2;
5670 //				outSerNo = outSerNo_WAE2;
5671 //				inpRstIn = inpRstIn_WAE2;
5672 //				inpRstOut = inpRstOut_WAE2;
5673 //				cboCountry = cboCountryWAE2;
5674 //				break;
5675 			case LOG_BART:
5676 			case LOG_GENERIC:
5677 			default:
5678 				log_generic_frame->show();
5679 				inpTimeOn = inpTimeOn3;
5680 				inpTimeOff = inpTimeOff3;
5681 				inpSerNo = inpSerNo2;
5682 				inpXchgIn = inpXchgIn2;
5683 				break;
5684 		}
5685 
5686 		qsoFreqDisp = qsoFreqDisp3;
5687 		TopFrame3->redraw();
5688 		inpCall4->hide();
5689 		Status2->show();
5690 		goto UI_return;
5691 	}
5692 
5693 UI_return:
5694 	UI_check_swap();
5695 
5696 	if (UI_first) {
5697 		UI_first = false;
5698 	 }
5699 	else {
5700 		int orgx = text_panel->orgx();
5701 		int orgy = text_panel->orgy();
5702 		int nux = text_panel->x() + progStatus.tile_x;
5703 		int nuy = text_panel->y() + progStatus.tile_y_ratio * text_panel->h();
5704 
5705 		text_panel->position(orgx, orgy, nux, nuy);
5706 	}
5707 
5708 	{
5709 		int Y = status_group->y();
5710 		int psm_width = progdefaults.show_psm_btn ? bwSqlOnOff : 0;
5711 
5712 		int vuw =
5713 			fl_digi_main->w() - Status2->x() - Status2->w() - 2 -
5714 			bwTxLevel -  // tx level control
5715 			Wwarn -      // Warn indicator
5716 			bwAfcOnOff - // afc button
5717 			bwSqlOnOff - // sql button
5718 			psm_width -  // psm button, bwSqlOnOff / 0
5719 			corner_box->w();
5720 
5721 		StatusBar->resize(
5722 			Status2->x() + Status2->w() + 2, Y, vuw, StatusBar->h());
5723 
5724 		VuMeter->resize(
5725 			Status2->x() + Status2->w() + 2, Y, vuw, VuMeter->h());
5726 
5727 		cntTxLevel->position(rightof(VuMeter), Y);
5728 
5729 		WARNstatus->position(rightof(cntTxLevel), Y);
5730 		btnAFC->position(rightof(WARNstatus), Y);
5731 		btnSQL->position(rightof(btnAFC), Y);
5732 
5733 		btnPSQL->resize(rightof(btnSQL), Y, psm_width, btnPSQL->h());
5734 		if (progdefaults.show_psm_btn)
5735 			btnPSQL->show();
5736 		else
5737 			btnPSQL->hide();
5738 
5739 		status_group->init_sizes();
5740 		status_group->redraw();
5741 
5742 	}
5743 
5744 	RigControlFrame->init_sizes();
5745 	RigControlFrame->redraw();
5746 	smeter->redraw();
5747 	pwrmeter->redraw();
5748 
5749 	center_group->redraw();
5750 	text_panel->redraw();
5751 	wefax_group->redraw();
5752 	fsq_group->redraw();
5753 	ifkp_group->redraw();
5754 	fmt_group->redraw();
5755 	macroFrame1->redraw();
5756 	macroFrame2->redraw();
5757 	viewer_redraw();
5758 
5759 	fl_digi_main->init_sizes();
5760 	update_main_title();
5761 	LOGBOOK_colors_font();
5762 	fl_digi_main->redraw();
5763 
5764 Fl::flush();
5765 }
5766 
5767 
cb_mnu_wf_all(Fl_Menu_ * w,void * d)5768 void cb_mnu_wf_all(Fl_Menu_* w, void *d)
5769 {
5770 	wf->UI_select(progStatus.WF_UI = w->mvalue()->value());
5771 }
5772 
cb_mnu_riglog_all(Fl_Menu_ * w,void * d)5773 void cb_mnu_riglog_all(Fl_Menu_* w, void *d)
5774 {
5775 	getMenuItem(w->mvalue()->label())->setonly();
5776 	progStatus.Rig_Log_UI = false;
5777 	progStatus.NO_RIGLOG = false;
5778 
5779 	UI_select();
5780 }
5781 
cb_mnu_riglog_partial(Fl_Menu_ * w,void * d)5782 void cb_mnu_riglog_partial(Fl_Menu_* w, void *d)
5783 {
5784 	getMenuItem(w->mvalue()->label())->setonly();
5785 	progStatus.Rig_Log_UI = true;
5786 	progStatus.NO_RIGLOG = false;
5787 
5788 	UI_select();
5789 }
5790 
cb_mnu_riglog_none(Fl_Menu_ * w,void * d)5791 void cb_mnu_riglog_none(Fl_Menu_* w, void *d)
5792 {
5793 	getMenuItem(w->mvalue()->label())->setonly();
5794 	progStatus.NO_RIGLOG = true;
5795 	progStatus.Rig_Log_UI = false;
5796 
5797 	UI_select();
5798 }
5799 
cb_mnuDockedscope(Fl_Menu_ * w,void * d)5800 void cb_mnuDockedscope(Fl_Menu_ *w, void *d)
5801 {
5802 	wf->show_scope(progStatus.DOCKEDSCOPE = w->mvalue()->value());
5803 }
5804 
WF_UI()5805 void WF_UI()
5806 {
5807 	wf->UI_select(progStatus.WF_UI);
5808 }
5809 
toggle_smeter()5810 void toggle_smeter()
5811 {
5812 	if (progStatus.meters && !smeter->visible()) {
5813 		pwrmeter->hide();
5814 		smeter->show();
5815 		qso_combos->hide();
5816 	} else if (!progStatus.meters && smeter->visible()) {
5817 		pwrmeter->hide();
5818 		smeter->hide();
5819 		qso_combos->show();
5820 	}
5821 	RigControlFrame->redraw();
5822 }
5823 
cb_toggle_smeter(Fl_Widget * w,void * v)5824 void cb_toggle_smeter(Fl_Widget *w, void *v)
5825 {
5826 	progStatus.meters = !progStatus.meters;
5827 	toggle_smeter();
5828 }
5829 
5830 extern void cb_scripts(bool);
5831 
cb_menu_scripts(Fl_Widget *,void *)5832 void cb_menu_scripts(Fl_Widget*, void*)
5833 {
5834 	cb_scripts(false);
5835 }
5836 
5837 extern void cb_create_default_script(void);
5838 
cb_menu_make_default_scripts(Fl_Widget *,void *)5839 void cb_menu_make_default_scripts(Fl_Widget*, void*)
5840 {
5841 	cb_create_default_script();
5842 }
5843 
cb_48macros(Fl_Widget *,void *)5844 void cb_48macros(Fl_Widget*, void*)
5845 {
5846 	progdefaults.display_48macros = !progdefaults.display_48macros;
5847 	UI_select();
5848 }
5849 
5850 static void cb_opmode_show(Fl_Widget* w, void*);
5851 
5852 static Fl_Menu_Item menu_[] = {
5853 {_("&File"), 0,  0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
5854 
5855 { icons::make_icon_label(_("Folders")), 0, 0, 0, FL_SUBMENU, _FL_MULTI_LABEL, 0, 14, 0},
5856 { icons::make_icon_label(_("Fldigi config..."), folder_open_icon), 0, cb_ShowConfig, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
5857 { icons::make_icon_label(_("FLMSG files..."), folder_open_icon), 0, cb_ShowFLMSG, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
5858 { icons::make_icon_label(_("NBEMS files..."), folder_open_icon), 0, cb_ShowNBEMS, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
5859 { icons::make_icon_label(_("WEFAX images..."), folder_open_icon), 0, cb_ShowWEFAX_images, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
5860 { icons::make_icon_label(_("Data files..."), folder_open_icon), 0, cb_ShowDATA, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
5861 {0,0,0,0,0,0,0,0,0},
5862 
5863 { icons::make_icon_label(_("Macros")), 0, 0, 0, FL_MENU_DIVIDER | FL_SUBMENU, _FL_MULTI_LABEL, 0, 14, 0},
5864 { icons::make_icon_label(_("Open ..."), file_open_icon), 0,  (Fl_Callback*)cb_mnuOpenMacro, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
5865 { icons::make_icon_label(_("Save ..."), save_as_icon), 0,  (Fl_Callback*)cb_mnuSaveMacro, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
5866 {0,0,0,0,0,0,0,0,0},
5867 
5868 { icons::make_icon_label(_("Config Scripts")), 0, 0, 0, FL_MENU_DIVIDER | FL_SUBMENU, _FL_MULTI_LABEL, 0, 14, 0},
5869 { _("Execute"),  0, (Fl_Callback*)cb_menu_scripts,  0, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
5870 { _("Generate"), 0, (Fl_Callback*)cb_menu_make_default_scripts,  0, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
5871 { 0,0,0,0,0,0,0,0,0},
5872 
5873 { icons::make_icon_label(_("Text Capture")), 0, 0, 0, FL_MENU_DIVIDER | FL_SUBMENU, _FL_MULTI_LABEL, 0, 14, 0},
5874 { LOG_TO_FILE_MLABEL, 0, cb_logfile, 0, FL_MENU_TOGGLE, FL_NORMAL_LABEL, 0, 14, 0},
5875 {0,0,0,0,0,0,0,0,0},
5876 
5877 { icons::make_icon_label(_("Audio")), 0, 0, 0, FL_MENU_DIVIDER | FL_SUBMENU, _FL_MULTI_LABEL, 0, 14, 0},
5878 {_("RX capture"),  0, (Fl_Callback*)cb_mnuCapture,  0, FL_MENU_TOGGLE, FL_NORMAL_LABEL, 0, 14, 0},
5879 {_("TX generate"), 0, (Fl_Callback*)cb_mnuGenerate, 0, FL_MENU_TOGGLE, FL_NORMAL_LABEL, 0, 14, 0},
5880 {_("Playback"),    0, (Fl_Callback*)cb_mnuPlayback, 0, FL_MENU_TOGGLE, FL_NORMAL_LABEL, 0, 14, 0},
5881 {0,0,0,0,0,0,0,0,0},
5882 
5883 { icons::make_icon_label(_("Exit"), log_out_icon), 'x',  (Fl_Callback*)cb_E, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
5884 {0,0,0,0,0,0,0,0,0},
5885 
5886 { OPMODES_MLABEL, 0,  0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
5887 
5888 { mode_info[MODE_CW].name, 0, cb_init_mode, (void *)MODE_CW, 0, FL_NORMAL_LABEL, 0, 14, 0},
5889 
5890 {"Contestia", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
5891 { mode_info[MODE_CONTESTIA_4_125].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_4_125, 0, FL_NORMAL_LABEL, 0, 14, 0},
5892 { mode_info[MODE_CONTESTIA_4_250].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_4_250, 0, FL_NORMAL_LABEL, 0, 14, 0},
5893 { mode_info[MODE_CONTESTIA_4_500].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_4_500, 0, FL_NORMAL_LABEL, 0, 14, 0},
5894 { mode_info[MODE_CONTESTIA_4_1000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_4_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
5895 { mode_info[MODE_CONTESTIA_4_2000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_4_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
5896 
5897 { mode_info[MODE_CONTESTIA_8_125].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_8_125, 0, FL_NORMAL_LABEL, 0, 14, 0},
5898 { mode_info[MODE_CONTESTIA_8_250].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_8_250, 0, FL_NORMAL_LABEL, 0, 14, 0},
5899 { mode_info[MODE_CONTESTIA_8_500].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_8_500, 0, FL_NORMAL_LABEL, 0, 14, 0},
5900 { mode_info[MODE_CONTESTIA_8_1000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_8_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
5901 { mode_info[MODE_CONTESTIA_8_2000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_8_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
5902 
5903 { mode_info[MODE_CONTESTIA_16_250].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_16_250, 0, FL_NORMAL_LABEL, 0, 14, 0},
5904 { mode_info[MODE_CONTESTIA_16_500].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_16_500, 0, FL_NORMAL_LABEL, 0, 14, 0},
5905 { mode_info[MODE_CONTESTIA_16_1000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_16_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
5906 { mode_info[MODE_CONTESTIA_16_2000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_16_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
5907 
5908 { mode_info[MODE_CONTESTIA_32_1000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_32_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
5909 { mode_info[MODE_CONTESTIA_32_2000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_32_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
5910 
5911 { mode_info[MODE_CONTESTIA_64_500].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_64_500, 0, FL_NORMAL_LABEL, 0, 14, 0},
5912 { mode_info[MODE_CONTESTIA_64_1000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_64_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
5913 { mode_info[MODE_CONTESTIA_64_2000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_64_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
5914 { _("Custom..."), 0, cb_contestiaCustom, (void *)MODE_CONTESTIA, 0, FL_NORMAL_LABEL, 0, 14, 0},
5915 {0,0,0,0,0,0,0,0,0},
5916 
5917 {"DominoEX", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
5918 { mode_info[MODE_DOMINOEXMICRO].name, 0, cb_init_mode, (void *)MODE_DOMINOEXMICRO, 0, FL_NORMAL_LABEL, 0, 14, 0},
5919 { mode_info[MODE_DOMINOEX4].name, 0, cb_init_mode, (void *)MODE_DOMINOEX4, 0, FL_NORMAL_LABEL, 0, 14, 0},
5920 { mode_info[MODE_DOMINOEX5].name, 0, cb_init_mode, (void *)MODE_DOMINOEX5, 0, FL_NORMAL_LABEL, 0, 14, 0},
5921 { mode_info[MODE_DOMINOEX8].name, 0, cb_init_mode, (void *)MODE_DOMINOEX8, 0, FL_NORMAL_LABEL, 0, 14, 0},
5922 { mode_info[MODE_DOMINOEX11].name, 0, cb_init_mode, (void *)MODE_DOMINOEX11, 0, FL_NORMAL_LABEL, 0, 14, 0},
5923 { mode_info[MODE_DOMINOEX16].name, 0, cb_init_mode, (void *)MODE_DOMINOEX16, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
5924 { mode_info[MODE_DOMINOEX22].name, 0, cb_init_mode, (void *)MODE_DOMINOEX22, 0, FL_NORMAL_LABEL, 0, 14, 0},
5925 { mode_info[MODE_DOMINOEX44].name, 0,  cb_init_mode, (void *)MODE_DOMINOEX44, 0, FL_NORMAL_LABEL, 0, 14, 0},
5926 { mode_info[MODE_DOMINOEX88].name, 0,  cb_init_mode, (void *)MODE_DOMINOEX88, 0, FL_NORMAL_LABEL, 0, 14, 0},
5927 {0,0,0,0,0,0,0,0,0},
5928 
5929 { "FSQ", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
5930 { "FSQ-6", 0, cb_fsq6, (void *)MODE_FSQ, 0, FL_NORMAL_LABEL, 0, 14, 0},
5931 { "FSQ-4.5", 0, cb_fsq4p5, (void *)MODE_FSQ, 0, FL_NORMAL_LABEL, 0, 14, 0},
5932 { "FSQ-3", 0, cb_fsq3, (void *)MODE_FSQ, 0, FL_NORMAL_LABEL, 0, 14, 0},
5933 { "FSQ-2", 0, cb_fsq2, (void *)MODE_FSQ, 0, FL_NORMAL_LABEL, 0, 14, 0},
5934 { "FSQ-1.5", 0, cb_fsq1p5, (void *)MODE_FSQ, 0, FL_NORMAL_LABEL, 0, 14, 0},
5935 {0,0,0,0,0,0,0,0,0},
5936 
5937 {"Hell", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
5938 { mode_info[MODE_FELDHELL].name, 0, cb_init_mode, (void *)MODE_FELDHELL, 0, FL_NORMAL_LABEL, 0, 14, 0},
5939 { mode_info[MODE_SLOWHELL].name, 0,  cb_init_mode, (void *)MODE_SLOWHELL, 0, FL_NORMAL_LABEL, 0, 14, 0},
5940 { mode_info[MODE_HELLX5].name, 0,  cb_init_mode, (void *)MODE_HELLX5, 0, FL_NORMAL_LABEL, 0, 14, 0},
5941 { mode_info[MODE_HELLX9].name, 0,  cb_init_mode, (void *)MODE_HELLX9, 0, FL_NORMAL_LABEL, 0, 14, 0},
5942 { mode_info[MODE_FSKH245].name, 0, cb_init_mode, (void *)MODE_FSKH245, 0, FL_NORMAL_LABEL, 0, 14, 0},
5943 { mode_info[MODE_FSKH105].name, 0, cb_init_mode, (void *)MODE_FSKH105, 0, FL_NORMAL_LABEL, 0, 14, 0},
5944 { mode_info[MODE_HELL80].name, 0, cb_init_mode, (void *)MODE_HELL80, 0, FL_NORMAL_LABEL, 0, 14, 0},
5945 {0,0,0,0,0,0,0,0,0},
5946 
5947 { "IFKP", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
5948 { "IFKP 0.5", 0, cb_ifkp0p5, (void *)MODE_IFKP, 0, FL_NORMAL_LABEL, 0, 14, 0},
5949 { "IFKP 1.0", 0, cb_ifkp1p0, (void *)MODE_IFKP, 0, FL_NORMAL_LABEL, 0, 14, 0},
5950 { "IFKP 2.0", 0, cb_ifkp2p0, (void *)MODE_IFKP, 0, FL_NORMAL_LABEL, 0, 14, 0},
5951 {0,0,0,0,0,0,0,0,0},
5952 
5953 {"MFSK", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
5954 { mode_info[MODE_MFSK4].name, 0,  cb_init_mode, (void *)MODE_MFSK4, 0, FL_NORMAL_LABEL, 0, 14, 0},
5955 { mode_info[MODE_MFSK8].name, 0,  cb_init_mode, (void *)MODE_MFSK8, 0, FL_NORMAL_LABEL, 0, 14, 0},
5956 { mode_info[MODE_MFSK11].name, 0,  cb_init_mode, (void *)MODE_MFSK11, 0, FL_NORMAL_LABEL, 0, 14, 0},
5957 { mode_info[MODE_MFSK16].name, 0,  cb_init_mode, (void *)MODE_MFSK16, 0, FL_NORMAL_LABEL, 0, 14, 0},
5958 { mode_info[MODE_MFSK22].name, 0,  cb_init_mode, (void *)MODE_MFSK22, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
5959 { mode_info[MODE_MFSK31].name, 0,  cb_init_mode, (void *)MODE_MFSK31, 0, FL_NORMAL_LABEL, 0, 14, 0},
5960 { mode_info[MODE_MFSK32].name, 0,  cb_init_mode, (void *)MODE_MFSK32, 0, FL_NORMAL_LABEL, 0, 14, 0},
5961 { mode_info[MODE_MFSK64].name, 0,  cb_init_mode, (void *)MODE_MFSK64, 0, FL_NORMAL_LABEL, 0, 14, 0},
5962 { mode_info[MODE_MFSK128].name, 0,  cb_init_mode, (void *)MODE_MFSK128, 0, FL_NORMAL_LABEL, 0, 14, 0},
5963 { mode_info[MODE_MFSK64L].name, 0,  cb_init_mode, (void *)MODE_MFSK64L, 0, FL_NORMAL_LABEL, 0, 14, 0},
5964 { mode_info[MODE_MFSK128L].name, 0,  cb_init_mode, (void *)MODE_MFSK128L, 0, FL_NORMAL_LABEL, 0, 14, 0},
5965 {0,0,0,0,0,0,0,0,0},
5966 
5967 {"MT63", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
5968 { mode_info[MODE_MT63_500S].name, 0,  cb_init_mode, (void *)MODE_MT63_500S, 0, FL_NORMAL_LABEL, 0, 14, 0},
5969 { mode_info[MODE_MT63_500L].name, 0,  cb_init_mode, (void *)MODE_MT63_500L, 0, FL_NORMAL_LABEL, 0, 14, 0},
5970 { mode_info[MODE_MT63_1000S].name, 0,  cb_init_mode, (void *)MODE_MT63_1000S, 0, FL_NORMAL_LABEL, 0, 14, 0},
5971 { mode_info[MODE_MT63_1000L].name, 0,  cb_init_mode, (void *)MODE_MT63_1000L, 0, FL_NORMAL_LABEL, 0, 14, 0},
5972 { mode_info[MODE_MT63_2000S].name, 0,  cb_init_mode, (void *)MODE_MT63_2000S, 0, FL_NORMAL_LABEL, 0, 14, 0},
5973 { mode_info[MODE_MT63_2000L].name, 0,  cb_init_mode, (void *)MODE_MT63_2000L, 0, FL_NORMAL_LABEL, 0, 14, 0},
5974 {0,0,0,0,0,0,0,0,0},
5975 
5976 {"OFDM", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
5977 { mode_info[MODE_OFDM_500F].name, 0,  cb_init_mode, (void *)MODE_OFDM_500F, 0, FL_NORMAL_LABEL, 0, 14, 0},
5978 { mode_info[MODE_OFDM_750F].name, 0,  cb_init_mode, (void *)MODE_OFDM_750F, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
5979 //{ mode_info[MODE_OFDM_2000F].name, 0,  cb_init_mode, (void *)MODE_OFDM_2000F, 0, FL_NORMAL_LABEL, 0, 14, 0},
5980 //{ mode_info[MODE_OFDM_2000].name, 0,  cb_init_mode, (void *)MODE_OFDM_2000, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
5981 { mode_info[MODE_OFDM_3500].name, 0,  cb_init_mode, (void *)MODE_OFDM_3500, 0, FL_NORMAL_LABEL, 0, 14, 0},
5982 {0,0,0,0,0,0,0,0,0},
5983 
5984 { OLIVIA_MLABEL, 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
5985 { mode_info[MODE_OLIVIA_4_125].name, 0, cb_init_mode, (void *)MODE_OLIVIA_4_125, 0, FL_NORMAL_LABEL, 0, 14, 0},
5986 { mode_info[MODE_OLIVIA_4_250].name, 0, cb_init_mode, (void *)MODE_OLIVIA_4_250, 0, FL_NORMAL_LABEL, 0, 14, 0},
5987 { mode_info[MODE_OLIVIA_4_500].name, 0, cb_init_mode, (void *)MODE_OLIVIA_4_500, 0, FL_NORMAL_LABEL, 0, 14, 0},
5988 { mode_info[MODE_OLIVIA_4_1000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_4_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
5989 { mode_info[MODE_OLIVIA_4_2000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_4_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
5990 
5991 { mode_info[MODE_OLIVIA_8_125].name, 0, cb_init_mode, (void *)MODE_OLIVIA_8_125, 0, FL_NORMAL_LABEL, 0, 14, 0},
5992 { mode_info[MODE_OLIVIA_8_250].name, 0, cb_init_mode, (void *)MODE_OLIVIA_8_250, 0, FL_NORMAL_LABEL, 0, 14, 0},
5993 { mode_info[MODE_OLIVIA_8_500].name, 0, cb_init_mode, (void *)MODE_OLIVIA_8_500, 0, FL_NORMAL_LABEL, 0, 14, 0},
5994 { mode_info[MODE_OLIVIA_8_1000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_8_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
5995 { mode_info[MODE_OLIVIA_8_2000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_8_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
5996 
5997 { mode_info[MODE_OLIVIA_16_500].name, 0, cb_init_mode, (void *)MODE_OLIVIA_16_500, 0, FL_NORMAL_LABEL, 0, 14, 0},
5998 { mode_info[MODE_OLIVIA_16_1000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_16_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
5999 { mode_info[MODE_OLIVIA_16_2000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_16_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
6000 
6001 { mode_info[MODE_OLIVIA_32_1000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_32_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
6002 { mode_info[MODE_OLIVIA_32_2000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_32_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
6003 
6004 { mode_info[MODE_OLIVIA_64_500].name, 0, cb_init_mode, (void *)MODE_OLIVIA_64_500, 0, FL_NORMAL_LABEL, 0, 14, 0},
6005 { mode_info[MODE_OLIVIA_64_1000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_64_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
6006 { mode_info[MODE_OLIVIA_64_2000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_64_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
6007 { _("Custom..."), 0, cb_oliviaCustom, (void *)MODE_OLIVIA, 0, FL_NORMAL_LABEL, 0, 14, 0},
6008 {0,0,0,0,0,0,0,0,0},
6009 
6010 {"PSK", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
6011 { mode_info[MODE_PSK31].name, 0, cb_init_mode, (void *)MODE_PSK31, 0, FL_NORMAL_LABEL, 0, 14, 0},
6012 { mode_info[MODE_PSK63].name, 0, cb_init_mode, (void *)MODE_PSK63, 0, FL_NORMAL_LABEL, 0, 14, 0},
6013 { mode_info[MODE_PSK63F].name, 0, cb_init_mode, (void *)MODE_PSK63F, 0, FL_NORMAL_LABEL, 0, 14, 0},
6014 { mode_info[MODE_PSK125].name, 0, cb_init_mode, (void *)MODE_PSK125, 0, FL_NORMAL_LABEL, 0, 14, 0},
6015 { mode_info[MODE_PSK250].name, 0, cb_init_mode, (void *)MODE_PSK250, 0, FL_NORMAL_LABEL, 0, 14, 0},
6016 { mode_info[MODE_PSK500].name, 0, cb_init_mode, (void *)MODE_PSK500, 0, FL_NORMAL_LABEL, 0, 14, 0},
6017 { mode_info[MODE_PSK1000].name, 0, cb_init_mode, (void *)MODE_PSK1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
6018 {"MultiCarrier", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
6019 { mode_info[MODE_12X_PSK125].name, 0, cb_init_mode, (void *)MODE_12X_PSK125, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
6020 { mode_info[MODE_6X_PSK250].name, 0, cb_init_mode, (void *)MODE_6X_PSK250, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
6021 { mode_info[MODE_2X_PSK500].name, 0, cb_init_mode, (void *)MODE_2X_PSK500, 0, FL_NORMAL_LABEL, 0, 14, 0},
6022 { mode_info[MODE_4X_PSK500].name, 0, cb_init_mode, (void *)MODE_4X_PSK500, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
6023 { mode_info[MODE_2X_PSK800].name, 0, cb_init_mode, (void *)MODE_2X_PSK800, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
6024 { mode_info[MODE_2X_PSK1000].name, 0, cb_init_mode, (void *)MODE_2X_PSK1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
6025 {0,0,0,0,0,0,0,0,0},
6026 {0,0,0,0,0,0,0,0,0},
6027 
6028 {"QPSK", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
6029 { mode_info[MODE_QPSK31].name, 0, cb_init_mode, (void *)MODE_QPSK31, 0, FL_NORMAL_LABEL, 0, 14, 0},
6030 { mode_info[MODE_QPSK63].name, 0, cb_init_mode, (void *)MODE_QPSK63, 0, FL_NORMAL_LABEL, 0, 14, 0},
6031 { mode_info[MODE_QPSK125].name, 0, cb_init_mode, (void *)MODE_QPSK125, 0, FL_NORMAL_LABEL, 0, 14, 0},
6032 { mode_info[MODE_QPSK250].name, 0, cb_init_mode, (void *)MODE_QPSK250, 0, FL_NORMAL_LABEL, 0, 14, 0},
6033 { mode_info[MODE_QPSK500].name, 0, cb_init_mode, (void *)MODE_QPSK500, 0, FL_NORMAL_LABEL, 0, 14, 0},
6034 {0,0,0,0,0,0,0,0,0},
6035 
6036 {"8PSK", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
6037 { mode_info[MODE_8PSK125].name, 0, cb_init_mode, (void *)MODE_8PSK125, 0, FL_NORMAL_LABEL, 0, 14, 0},
6038 { mode_info[MODE_8PSK250].name, 0, cb_init_mode, (void *)MODE_8PSK250, 0, FL_NORMAL_LABEL, 0, 14, 0},
6039 { mode_info[MODE_8PSK500].name, 0, cb_init_mode, (void *)MODE_8PSK500, 0, FL_NORMAL_LABEL, 0, 14, 0},
6040 { mode_info[MODE_8PSK1000].name, 0, cb_init_mode, (void *)MODE_8PSK1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
6041 { mode_info[MODE_8PSK125FL].name, 0, cb_init_mode, (void *)MODE_8PSK125FL, 0, FL_NORMAL_LABEL, 0, 14, 0},
6042 { mode_info[MODE_8PSK125F].name, 0, cb_init_mode, (void *)MODE_8PSK125F, 0, FL_NORMAL_LABEL, 0, 14, 0},
6043 { mode_info[MODE_8PSK250FL].name, 0, cb_init_mode, (void *)MODE_8PSK250FL, 0, FL_NORMAL_LABEL, 0, 14, 0},
6044 { mode_info[MODE_8PSK250F].name, 0, cb_init_mode, (void *)MODE_8PSK250F, 0, FL_NORMAL_LABEL, 0, 14, 0},
6045 { mode_info[MODE_8PSK500F].name, 0, cb_init_mode, (void *)MODE_8PSK500F, 0, FL_NORMAL_LABEL, 0, 14, 0},
6046 { mode_info[MODE_8PSK1000F].name, 0, cb_init_mode, (void *)MODE_8PSK1000F, 0, FL_NORMAL_LABEL, 0, 14, 0},
6047 { mode_info[MODE_8PSK1200F].name, 0, cb_init_mode, (void *)MODE_8PSK1200F, 0, FL_NORMAL_LABEL, 0, 14, 0},
6048 {0,0,0,0,0,0,0,0,0},
6049 
6050 {"PSKR", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
6051 { mode_info[MODE_PSK125R].name, 0, cb_init_mode, (void *)MODE_PSK125R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6052 { mode_info[MODE_PSK250R].name, 0, cb_init_mode, (void *)MODE_PSK250R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6053 { mode_info[MODE_PSK500R].name, 0, cb_init_mode, (void *)MODE_PSK500R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6054 { mode_info[MODE_PSK1000R].name, 0, cb_init_mode, (void *)MODE_PSK1000R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6055 {"MultiCarrier", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
6056 { mode_info[MODE_4X_PSK63R].name, 0, cb_init_mode, (void *)MODE_4X_PSK63R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6057 { mode_info[MODE_5X_PSK63R].name, 0, cb_init_mode, (void *)MODE_5X_PSK63R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6058 { mode_info[MODE_10X_PSK63R].name, 0, cb_init_mode, (void *)MODE_10X_PSK63R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6059 { mode_info[MODE_20X_PSK63R].name, 0, cb_init_mode, (void *)MODE_20X_PSK63R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6060 { mode_info[MODE_32X_PSK63R].name, 0, cb_init_mode, (void *)MODE_32X_PSK63R, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
6061 { mode_info[MODE_4X_PSK125R].name, 0, cb_init_mode, (void *)MODE_4X_PSK125R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6062 { mode_info[MODE_5X_PSK125R].name, 0, cb_init_mode, (void *)MODE_5X_PSK125R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6063 { mode_info[MODE_10X_PSK125R].name, 0, cb_init_mode, (void *)MODE_10X_PSK125R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6064 { mode_info[MODE_12X_PSK125R].name, 0, cb_init_mode, (void *)MODE_12X_PSK125R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6065 { mode_info[MODE_16X_PSK125R].name, 0, cb_init_mode, (void *)MODE_16X_PSK125R, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
6066 { mode_info[MODE_2X_PSK250R].name, 0, cb_init_mode, (void *)MODE_2X_PSK250R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6067 { mode_info[MODE_3X_PSK250R].name, 0, cb_init_mode, (void *)MODE_3X_PSK250R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6068 { mode_info[MODE_5X_PSK250R].name, 0, cb_init_mode, (void *)MODE_5X_PSK250R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6069 { mode_info[MODE_6X_PSK250R].name, 0, cb_init_mode, (void *)MODE_6X_PSK250R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6070 { mode_info[MODE_7X_PSK250R].name, 0, cb_init_mode, (void *)MODE_7X_PSK250R, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
6071 { mode_info[MODE_2X_PSK500R].name, 0, cb_init_mode, (void *)MODE_2X_PSK500R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6072 { mode_info[MODE_3X_PSK500R].name, 0, cb_init_mode, (void *)MODE_3X_PSK500R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6073 { mode_info[MODE_4X_PSK500R].name, 0, cb_init_mode, (void *)MODE_4X_PSK500R, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
6074 { mode_info[MODE_2X_PSK800R].name, 0, cb_init_mode, (void *)MODE_2X_PSK800R, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
6075 { mode_info[MODE_2X_PSK1000R].name, 0, cb_init_mode, (void *)MODE_2X_PSK1000R, 0, FL_NORMAL_LABEL, 0, 14, 0},
6076 {0,0,0,0,0,0,0,0,0},
6077 {0,0,0,0,0,0,0,0,0},
6078 
6079 { RTTY_MLABEL, 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
6080 { "RTTY-45", 0, cb_rtty45, (void *)MODE_RTTY, 0, FL_NORMAL_LABEL, 0, 14, 0},
6081 { "RTTY-50", 0, cb_rtty50, (void *)MODE_RTTY, 0, FL_NORMAL_LABEL, 0, 14, 0},
6082 { "RTTY-75N", 0, cb_rtty75N, (void *)MODE_RTTY, 0, FL_NORMAL_LABEL, 0, 14, 0},
6083 { "RTTY-75W", 0, cb_rtty75W, (void *)MODE_RTTY, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
6084 { _("Custom..."), 0, cb_rttyCustom, (void *)MODE_RTTY, 0, FL_NORMAL_LABEL, 0, 14, 0},
6085 {0,0,0,0,0,0,0,0,0},
6086 
6087 {"THOR", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
6088 { mode_info[MODE_THORMICRO].name, 0, cb_init_mode, (void *)MODE_THORMICRO, 0, FL_NORMAL_LABEL, 0, 14, 0},
6089 { mode_info[MODE_THOR4].name, 0, cb_init_mode, (void *)MODE_THOR4, 0, FL_NORMAL_LABEL, 0, 14, 0},
6090 { mode_info[MODE_THOR5].name, 0, cb_init_mode, (void *)MODE_THOR5, 0, FL_NORMAL_LABEL, 0, 14, 0},
6091 { mode_info[MODE_THOR8].name, 0, cb_init_mode, (void *)MODE_THOR8, 0, FL_NORMAL_LABEL, 0, 14, 0},
6092 { mode_info[MODE_THOR11].name, 0, cb_init_mode, (void *)MODE_THOR11, 0, FL_NORMAL_LABEL, 0, 14, 0},
6093 { mode_info[MODE_THOR16].name, 0, cb_init_mode, (void *)MODE_THOR16, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
6094 { mode_info[MODE_THOR22].name, 0, cb_init_mode, (void *)MODE_THOR22, 0, FL_NORMAL_LABEL, 0, 14, 0},
6095 { mode_info[MODE_THOR25x4].name, 0,  cb_init_mode, (void *)MODE_THOR25x4, 0, FL_NORMAL_LABEL, 0, 14, 0},
6096 { mode_info[MODE_THOR50x1].name, 0,  cb_init_mode, (void *)MODE_THOR50x1, 0, FL_NORMAL_LABEL, 0, 14, 0},
6097 { mode_info[MODE_THOR50x2].name, 0,  cb_init_mode, (void *)MODE_THOR50x2, 0, FL_NORMAL_LABEL, 0, 14, 0},
6098 { mode_info[MODE_THOR100].name, 0,  cb_init_mode, (void *)MODE_THOR100, 0, FL_NORMAL_LABEL, 0, 14, 0},
6099 {0,0,0,0,0,0,0,0,0},
6100 
6101 {"Throb", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
6102 { mode_info[MODE_THROB1].name, 0, cb_init_mode, (void *)MODE_THROB1, 0, FL_NORMAL_LABEL, 0, 14, 0},
6103 { mode_info[MODE_THROB2].name, 0, cb_init_mode, (void *)MODE_THROB2, 0, FL_NORMAL_LABEL, 0, 14, 0},
6104 { mode_info[MODE_THROB4].name, 0, cb_init_mode, (void *)MODE_THROB4, 0, FL_NORMAL_LABEL, 0, 14, 0},
6105 { mode_info[MODE_THROBX1].name, 0, cb_init_mode, (void *)MODE_THROBX1, 0, FL_NORMAL_LABEL, 0, 14, 0},
6106 { mode_info[MODE_THROBX2].name, 0, cb_init_mode, (void *)MODE_THROBX2, 0, FL_NORMAL_LABEL, 0, 14, 0},
6107 { mode_info[MODE_THROBX4].name, 0, cb_init_mode, (void *)MODE_THROBX4, 0, FL_NORMAL_LABEL, 0, 14, 0},
6108 {0,0,0,0,0,0,0,0,0},
6109 
6110 //{ "Packet", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
6111 //{ " 300 baud", 0, cb_pkt300, (void *)MODE_PACKET, 0, FL_NORMAL_LABEL, 0, 14, 0},
6112 //{ "1200 baud", 0, cb_pkt1200, (void *)MODE_PACKET, 0, FL_NORMAL_LABEL, 0, 14, 0},
6113 //{ "2400 baud", 0, cb_pkt2400, (void *)MODE_PACKET, 0, FL_NORMAL_LABEL, 0, 14, 0},
6114 //{0,0,0,0,0,0,0,0,0},
6115 
6116 {"WEFAX", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
6117 { mode_info[MODE_WEFAX_576].name, 0,  cb_init_mode, (void *)MODE_WEFAX_576, 0, FL_NORMAL_LABEL, 0, 14, 0},
6118 { mode_info[MODE_WEFAX_288].name, 0,  cb_init_mode, (void *)MODE_WEFAX_288, 0, FL_NORMAL_LABEL, 0, 14, 0},
6119 {0,0,0,0,0,0,0,0,0},
6120 
6121 {"Navtex/SitorB", 0, 0, 0, FL_SUBMENU | FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
6122 { mode_info[MODE_NAVTEX].name, 0,  cb_init_mode, (void *)MODE_NAVTEX, 0, FL_NORMAL_LABEL, 0, 14, 0},
6123 { mode_info[MODE_SITORB].name, 0,  cb_init_mode, (void *)MODE_SITORB, 0, FL_NORMAL_LABEL, 0, 14, 0},
6124 {0,0,0,0,0,0,0,0,0},
6125 
6126 { mode_info[MODE_WWV].name, 0, cb_init_mode, (void *)MODE_WWV, 0, FL_NORMAL_LABEL, 0, 14, 0},
6127 { mode_info[MODE_ANALYSIS].name, 0, cb_init_mode, (void *)MODE_ANALYSIS, 0, FL_NORMAL_LABEL, 0, 14, 0},
6128 { mode_info[MODE_FMT].name, 0, cb_init_mode, (void *)MODE_FMT, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
6129 
6130 { mode_info[MODE_NULL].name, 0, cb_init_mode, (void *)MODE_NULL, 0, FL_NORMAL_LABEL, 0, 14, 0},
6131 { mode_info[MODE_SSB].name, 0, cb_init_mode, (void *)MODE_SSB, 0, FL_NORMAL_LABEL, 0, 14, 0},
6132 
6133 { OPMODES_FEWER, 0, cb_opmode_show, 0, FL_MENU_INVISIBLE, FL_NORMAL_LABEL, FL_HELVETICA_ITALIC, 14, 0 },
6134 {0,0,0,0,0,0,0,0,0},
6135 
6136 {_("&Configure"), 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
6137 
6138 { icons::make_icon_label(_("Config Dialog")), 0, (Fl_Callback*)cb_mnu_config_dialog, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6139 { icons::make_icon_label(_("Save Config"), save_icon), 0, (Fl_Callback*)cb_mnuSaveConfig, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6140 { icons::make_icon_label(_("Notifications")), 0,  (Fl_Callback*)cb_mnuConfigNotify, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6141 { icons::make_icon_label(_("Test Signals")), 0, (Fl_Callback*)cb_mnuTestSignals, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
6142 {0,0,0,0,0,0,0,0,0},
6143 
6144 { VIEW_MLABEL, 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
6145 
6146 { icons::make_icon_label(_("Rx Audio Dialog")), 'a', (Fl_Callback*)cb_mnuRxAudioDialog, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6147 
6148 { icons::make_icon_label(_("View/Hide Channels")), 'c', (Fl_Callback*)cb_view_hide_channels, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
6149 { icons::make_icon_label(_("Signal browser")), 'b', (Fl_Callback*)cb_mnuViewer, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6150 
6151 { icons::make_icon_label(_("View/Hide 48 macros")), 'm', (Fl_Callback*)cb_48macros, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6152 
6153 { icons::make_icon_label(_("DX Cluster")), 'd', (Fl_Callback*)cb_dxc_viewer, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6154 
6155 { icons::make_icon_label(_("Floating scope"), utilities_system_monitor_icon), 'f', (Fl_Callback*)cb_mnuDigiscope, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
6156 { icons::make_icon_label(_("Spectrum scope"), utilities_system_monitor_icon), 's', (Fl_Callback*)cb_mnuSpectrum, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6157 
6158 { icons::make_icon_label(MFSK_IMAGE_MLABEL, image_icon), 0, (Fl_Callback*)cb_mnuPicViewer, 0, FL_MENU_INACTIVE, _FL_MULTI_LABEL, 0, 14, 0},
6159 { icons::make_icon_label(THOR_IMAGE_MLABEL, image_icon), 0, (Fl_Callback*)cb_mnuThorViewRaw,0, FL_MENU_INACTIVE, _FL_MULTI_LABEL, 0, 14, 0},
6160 { icons::make_icon_label(IFKP_IMAGE_MLABEL, image_icon), 0, (Fl_Callback*)cb_mnuIfkpViewRaw,0, FL_MENU_INACTIVE | FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6161 { icons::make_icon_label(WEFAX_TX_IMAGE_MLABEL, image_icon), 0, (Fl_Callback*)wefax_pic::cb_mnu_pic_viewer_tx,0, FL_MENU_INACTIVE | FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6162 
6163 { icons::make_icon_label(COUNTRIES_MLABEL), 0, (Fl_Callback*)cb_mnuShowCountries, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6164 
6165 { icons::make_icon_label(_("Rig/Log Controls")), 0, 0, 0, FL_SUBMENU, _FL_MULTI_LABEL, 0, 14, 0},
6166 { RIGLOG_FULL_MLABEL, 0, (Fl_Callback*)cb_mnu_riglog_all, 0, FL_MENU_RADIO, FL_NORMAL_LABEL, 0, 14, 0},
6167 { RIGLOG_PARTIAL_MLABEL, 0, (Fl_Callback*)cb_mnu_riglog_partial, 0, FL_MENU_RADIO, FL_NORMAL_LABEL, 0, 14, 0},
6168 { RIGLOG_NONE_MLABEL, 0, (Fl_Callback*)cb_mnu_riglog_none, 0, FL_MENU_RADIO, FL_NORMAL_LABEL, 0, 14, 0},
6169 {0,0,0,0,0,0,0,0,0},
6170 
6171 { icons::make_icon_label(_("Waterfall")), 0, 0, 0, FL_SUBMENU, _FL_MULTI_LABEL, 0, 14, 0},
6172 { DOCKEDSCOPE_MLABEL, 0, (Fl_Callback*)cb_mnuDockedscope, 0, FL_MENU_TOGGLE, FL_NORMAL_LABEL, 0, 14, 0},
6173 { WF_MLABEL, 0, (Fl_Callback*)cb_mnu_wf_all, 0, FL_MENU_TOGGLE, FL_NORMAL_LABEL, 0, 14, 0},
6174 {0,0,0,0,0,0,0,0,0},
6175 
6176 {0,0,0,0,0,0,0,0,0},
6177 
6178 { _("&Logbook"), 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
6179 { icons::make_icon_label(_("View")), 'l', (Fl_Callback*)cb_mnuShowLogbook, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6180 
6181 { icons::make_icon_label(_("Files")), 0, 0, 0, FL_SUBMENU | FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6182 { icons::make_icon_label(_("Open...")), 0, (Fl_Callback*)cb_mnuOpenLogbook, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
6183 { icons::make_icon_label(_("Save")), 0, (Fl_Callback*)cb_mnuSaveLogbook, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6184 { icons::make_icon_label(_("New")), 0, (Fl_Callback*)cb_mnuNewLogbook, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
6185 {0,0,0,0,0,0,0,0,0},
6186 
6187 { icons::make_icon_label(_("ADIF")), 0, 0, 0, FL_SUBMENU | FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6188 { icons::make_icon_label(_("Merge...")), 0, (Fl_Callback*)cb_mnuMergeADIF_log, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
6189 { icons::make_icon_label(_("Export...")), 0, (Fl_Callback*)cb_mnuExportADIF_log, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
6190 {0,0,0,0,0,0,0,0,0},
6191 
6192 { icons::make_icon_label(_("LoTW")), 0, (Fl_Callback*)cb_mnuConfigLoTW,  0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6193 
6194 { icons::make_icon_label(_("Reports")), 0, 0, 0, FL_SUBMENU | FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6195 { icons::make_icon_label(_("Text...")), 0, (Fl_Callback*)cb_mnuExportTEXT_log, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
6196 { icons::make_icon_label(_("CSV...")), 0, (Fl_Callback*)cb_mnuExportCSV_log, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
6197 { icons::make_icon_label(_("Cabrillo...")), 0, (Fl_Callback*)cb_Export_Cabrillo, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
6198 {0,0,0,0,0,0,0,0,0},
6199 
6200 { LOG_CONNECT_SERVER, 0, (Fl_Callback*)cb_log_server, 0, FL_MENU_TOGGLE | FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
6201 
6202 { icons::make_icon_label(_("Field Day Logging")), 0, (Fl_Callback*)cb_fd_viewer, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
6203 
6204 {0,0,0,0,0,0,0,0,0},
6205 
6206 {"     ", 0, 0, 0, FL_MENU_INACTIVE, FL_NORMAL_LABEL, 0, 14, 0},
6207 {_("&Help"), 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
6208 #ifndef NDEBUG
6209 // settle the gmfsk vs fldigi argument once and for all
6210 { icons::make_icon_label(_("Create sunspots"), weather_clear_icon), 0, cb_mnuFun, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6211 #endif
6212 { icons::make_icon_label(_("Beginners' Guide"), start_here_icon), 0, cb_mnuBeginnersURL, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
6213 { icons::make_icon_label(_("Online documentation..."), help_browser_icon), 0, cb_mnuOnLineDOCS, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
6214 { icons::make_icon_label(_("Fldigi web site..."), net_icon), 0, cb_mnuVisitURL, (void *)PACKAGE_HOME, 0, _FL_MULTI_LABEL, 0, 14, 0},
6215 { icons::make_icon_label(_("Reception reports..."), pskr_icon), 0, cb_mnuVisitPSKRep, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6216 { icons::make_icon_label(_("Command line options"), utilities_terminal_icon), 0, cb_mnuCmdLineHelp, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
6217 { icons::make_icon_label(_("Audio device info"), audio_card_icon), 0, cb_mnuAudioInfo, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
6218 { icons::make_icon_label(_("Build info"), executable_icon), 0, cb_mnuBuildInfo, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
6219 { icons::make_icon_label(_("Event log"), dialog_information_icon), 0, cb_mnuDebug, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
6220 { icons::make_icon_label(_("Check for updates..."), system_software_update_icon), 0, cb_mnuCheckUpdate, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
6221 { icons::make_icon_label(_("&About"), help_about_icon), 'a', cb_mnuAboutURL, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
6222 {0,0,0,0,0,0,0,0,0},
6223 
6224 {"  ", 0, 0, 0, FL_MENU_INACTIVE, FL_NORMAL_LABEL, 0, 14, 0},
6225 {0,0,0,0,0,0,0,0,0},
6226 };
6227 
count_visible_items(Fl_Menu_Item * menu)6228 static int count_visible_items(Fl_Menu_Item* menu)
6229 {
6230 	int n = 0;
6231 	if (menu->flags & FL_SUBMENU)
6232 		menu++;
6233 	while (menu->label()) {
6234 		if (!(menu->flags & FL_SUBMENU) && menu->visible())
6235 			n++;
6236 		menu++;
6237 	}
6238 	return n;
6239 }
6240 
6241 static bool modes_hidden;
cb_opmode_show(Fl_Widget * w,void *)6242 static void cb_opmode_show(Fl_Widget* w, void*)
6243 {
6244 	Fl_Menu_* m = (Fl_Menu_*)w;
6245 	const char* label = m->mvalue()->label();
6246 
6247 	Fl_Menu_Item *item = 0, *first = 0, *last = 0;
6248 	item = first = getMenuItem(OPMODES_MLABEL) + 1;
6249 
6250 	if (!strcmp(label, OPMODES_ALL)) {
6251 		last = getMenuItem(OPMODES_ALL);
6252 		while (item != last) {
6253 			if (item->label())
6254 				item->show();
6255 			item++;
6256 		}
6257 		menu_[m->value()].label(OPMODES_FEWER);
6258 		modes_hidden = false;
6259 	}
6260 	else {
6261 		last = getMenuItem(OPMODES_FEWER);
6262 		while (item != last) {
6263 			if (item->label() && item->callback() == cb_init_mode) {
6264 				intptr_t mode = (intptr_t)item->user_data();
6265 				if (mode < NUM_MODES) {
6266 					if (progdefaults.visible_modes.test(mode))
6267 						item->show();
6268 					else
6269 						item->hide();
6270 				}
6271 			}
6272 			item++;
6273 		}
6274 		item = first;
6275 		while (item != last) {
6276 			if (item->flags & FL_SUBMENU) {
6277 				if (count_visible_items(item))
6278 					item->show();
6279 				else
6280 					item->hide();
6281 			}
6282 			item++;
6283 		}
6284 		if (progdefaults.visible_modes.test(MODE_OLIVIA))
6285 			getMenuItem("Olivia")->show();
6286 		else
6287 			getMenuItem("Olivia")->hide();
6288 
6289 		if (progdefaults.visible_modes.test(MODE_CONTESTIA))
6290 			getMenuItem("Contestia")->show();
6291 		else
6292 			getMenuItem("Contestia")->hide();
6293 
6294 		if (progdefaults.visible_modes.test(MODE_RTTY))
6295 			getMenuItem("RTTY")->show();
6296 		else
6297 			getMenuItem("RTTY")->hide();
6298 
6299 		if (progdefaults.visible_modes.test(MODE_IFKP))
6300 			getMenuItem("IFKP")->show();
6301 		else
6302 			getMenuItem("IFKP")->hide();
6303 
6304 		if (progdefaults.visible_modes.test(MODE_FSQ))
6305 			getMenuItem("FSQ")->show();
6306 		else
6307 			getMenuItem("FSQ")->hide();
6308 
6309 		menu_[m->value()].label(OPMODES_ALL);
6310 		modes_hidden = true;
6311 	}
6312 	m->redraw();
6313 }
6314 
toggle_visible_modes(Fl_Widget *,void *)6315 void toggle_visible_modes(Fl_Widget*, void*)
6316 {
6317 	Fl_Menu_Item* show_modes = modes_hidden ? getMenuItem(OPMODES_ALL) : getMenuItem(OPMODES_FEWER);
6318 
6319 	if (!(~progdefaults.visible_modes).none()) { // some modes disabled
6320 		show_modes->label(OPMODES_FEWER);
6321 		show_modes->show();
6322 		(show_modes - 1)->flags |= FL_MENU_DIVIDER;
6323 		mnu->value(show_modes);
6324 		show_modes->do_callback(mnu, (void*)0);
6325 	}
6326 	else {
6327 		mnu->value(show_modes);
6328 		show_modes->do_callback(mnu, (void*)0);
6329 		show_modes->hide();
6330 		(show_modes - 1)->flags &= ~FL_MENU_DIVIDER;
6331 	}
6332 }
6333 
getMenuItem(const char * caption,Fl_Menu_Item * submenu)6334 Fl_Menu_Item *getMenuItem(const char *caption, Fl_Menu_Item* submenu)
6335 {
6336 	if (submenu == 0 || !(submenu->flags & FL_SUBMENU)) {
6337 		if ( menu_->size() != sizeof(menu_)/sizeof(*menu_) ) {
6338 			LOG_ERROR("FIXME: the menu_ table is corrupt!");
6339 			abort();
6340 		}
6341  		submenu = menu_;
6342 	}
6343 
6344 	int size = submenu->size() - 1;
6345 	Fl_Menu_Item *item = 0;
6346 	const char* label;
6347 	for (int i = 0; i < size; i++) {
6348 		label = (submenu[i].labeltype() == _FL_MULTI_LABEL) ?
6349 			icons::get_icon_label_text(&submenu[i]) : submenu[i].text;
6350 		if (label && !strcmp(label, caption)) {
6351 			item = submenu + i;
6352 			break;
6353 		}
6354 	}
6355 	if (!item) {
6356 		LOG_ERROR("FIXME: could not find menu item \"%s\"", caption);
6357 		abort();
6358 	}
6359 	return item;
6360 }
6361 
activate_wefax_image_item(bool b)6362 void activate_wefax_image_item(bool b)
6363 {
6364 	/// Maybe do not do anything if the new modem has activated this menu item.
6365 	/// This is necessary because of trx_start_modem_loop which deletes
6366 	/// the current modem after the new one is created..
6367 	if( ( b == false )
6368 	 && ( active_modem->get_cap() & modem::CAP_IMG )
6369 	 && ( active_modem->get_mode() >= MODE_WEFAX_FIRST )
6370 	 && ( active_modem->get_mode() <= MODE_WEFAX_LAST )
6371 	 )
6372 	{
6373 		return ;
6374 	}
6375 
6376 	Fl_Menu_Item *wefax_tx_item = getMenuItem(WEFAX_TX_IMAGE_MLABEL);
6377 	if (wefax_tx_item)
6378 		icons::set_active(wefax_tx_item, b);
6379 }
6380 
6381 
activate_menu_item(const char * caption,bool val)6382 void activate_menu_item(const char *caption, bool val)
6383 {
6384 	Fl_Menu_Item *m = getMenuItem(caption);
6385 	icons::set_active(m, val);
6386 }
6387 
activate_mfsk_image_item(bool b)6388 void activate_mfsk_image_item(bool b)
6389 {
6390 	Fl_Menu_Item *mfsk_item = getMenuItem(MFSK_IMAGE_MLABEL);
6391 	if (mfsk_item)
6392 		icons::set_active(mfsk_item, b);
6393 }
6394 
activate_thor_image_item(bool b)6395 void activate_thor_image_item(bool b)
6396 {
6397 	Fl_Menu_Item *menu_item = getMenuItem(THOR_IMAGE_MLABEL);
6398 	if (menu_item)
6399 		icons::set_active(menu_item, b);
6400 }
6401 
activate_ifkp_image_item(bool b)6402 void activate_ifkp_image_item(bool b)
6403 {
6404 	Fl_Menu_Item *menu_item = getMenuItem(IFKP_IMAGE_MLABEL);
6405 	if (menu_item)
6406 		icons::set_active(menu_item, b);
6407 }
6408 
rightof(Fl_Widget * w)6409 inline int rightof(Fl_Widget* w)
6410 {
6411 	return w->x() + w->w();
6412 }
6413 
leftof(Fl_Widget * w)6414 inline int leftof(Fl_Widget* w)
6415 {
6416 	unsigned int a = w->align();
6417 	if (a == FL_ALIGN_CENTER || a & FL_ALIGN_INSIDE)
6418 		return w->x();
6419 
6420 	fl_font(FL_HELVETICA, FL_NORMAL_SIZE);
6421 	int lw = static_cast<int>(ceil(fl_width(w->label())));
6422 
6423 	if (a & (FL_ALIGN_TOP | FL_ALIGN_BOTTOM)) {
6424 		if (a & FL_ALIGN_LEFT)
6425 			return w->x();
6426 		else if (a & FL_ALIGN_RIGHT)
6427 			return w->x() - (lw > w->w() ? lw - w->w() : 0);
6428 		else
6429 			return w->x() - (lw > w->w() ? (lw - w->w())/2 : 0);
6430 	}
6431 	else {
6432 		if (a & FL_ALIGN_LEFT)
6433 			return w->x() - lw;
6434 		else
6435 			return w->x();
6436 	}
6437 }
6438 
above(Fl_Widget * w)6439 inline int above(Fl_Widget* w)
6440 {
6441 	unsigned int a = w->align();
6442 	if (a == FL_ALIGN_CENTER || a & FL_ALIGN_INSIDE)
6443 		return w->y();
6444 
6445 	return (a & FL_ALIGN_TOP) ? w->y() + FL_NORMAL_SIZE : w->y();
6446 }
6447 
below(Fl_Widget * w)6448 inline int below(Fl_Widget* w)
6449 {
6450 	unsigned int a = w->align();
6451 	if (a == FL_ALIGN_CENTER || a & FL_ALIGN_INSIDE)
6452 		return w->y() + w->h();
6453 
6454 	return (a & FL_ALIGN_BOTTOM) ? w->y() + w->h() + FL_NORMAL_SIZE : w->y() + w->h();
6455 }
6456 
6457 string argv_window_title;
6458 string main_window_title;
6459 string xcvr_title;
6460 
update_main_title()6461 void update_main_title()
6462 {
6463 	string buf = argv_window_title;
6464 	buf.append(" ver").append(PACKAGE_VERSION);
6465 	if (!xcvr_title.empty()) {
6466 		buf.append(" / ").append(xcvr_title);
6467 	}
6468 	buf.append(" - ");
6469 	if (bWF_only)
6470 		buf.append(_("waterfall-only mode"));
6471 	else {
6472 		buf.append(progdefaults.myCall.empty() ? _("NO CALLSIGN SET") : progdefaults.myCall.c_str());
6473 		if (progdefaults.logging > LOG_QSO && progdefaults.logging < LOG_SQSO)
6474 			buf.append(" :  ").append(contests[progdefaults.logging].name);
6475 		if (progdefaults.logging == LOG_SQSO) {
6476 			buf.append(" : ").append(QSOparties.qso_parties[progdefaults.SQSOcontest].contest);
6477 		}
6478 		if (progdefaults.logging == 0 && n3fjp_connected) {
6479 			buf.append(" : N3FJP Amateur Contact Log");
6480 		}
6481 	}
6482 	if (fl_digi_main) {
6483 		fl_digi_main->copy_label(buf.c_str());
6484 		fl_digi_main->redraw();
6485 	}
6486 }
6487 
showOpBrowserView(Fl_Widget *,void *)6488 void showOpBrowserView(Fl_Widget *, void *)
6489 {
6490 	if (RigViewerFrame->visible())
6491 		return CloseQsoView();
6492 
6493 	Logging_frame->hide();
6494 	RigViewerFrame->show();
6495 	qso_opPICK->box(FL_DOWN_BOX);
6496 	qso_opBrowser->take_focus();
6497 	qso_opPICK->tooltip(_("Close List"));
6498 }
6499 
CloseQsoView()6500 void CloseQsoView()
6501 {
6502 	RigViewerFrame->hide();
6503 	Logging_frame->show();
6504 	qso_opPICK->box(FL_UP_BOX);
6505 	qso_opPICK->tooltip(_("Open List"));
6506 	if (restore_minimize) {
6507 		restore_minimize = false;
6508 
6509 		UI_select();
6510 	}
6511 }
6512 
showOpBrowserView2(Fl_Widget * w,void *)6513 void showOpBrowserView2(Fl_Widget *w, void *)
6514 {
6515 	restore_minimize = true;
6516 
6517 	UI_select();
6518 	showOpBrowserView(w, NULL);
6519 }
6520 
cb_qso_btnSelFreq(Fl_Widget *,void *)6521 void cb_qso_btnSelFreq(Fl_Widget *, void *)
6522 {
6523 	qso_selectFreq();
6524 }
6525 
cb_qso_btnDelFreq(Fl_Widget *,void *)6526 void cb_qso_btnDelFreq(Fl_Widget *, void *)
6527 {
6528 	qso_delFreq();
6529 }
6530 
cb_qso_btnAddFreq(Fl_Widget *,void *)6531 void cb_qso_btnAddFreq(Fl_Widget *, void *)
6532 {
6533 	qso_addFreq();
6534 }
6535 
cb_qso_btnClearList(Fl_Widget *,void *)6536 void cb_qso_btnClearList(Fl_Widget *, void *)
6537 {
6538 	if (quick_choice(_("Clear list?"), 2, _("Confirm"), _("Cancel"), NULL) == 1)
6539 		clearList();
6540 }
6541 
6542 //======================================================================
6543 // PSK reporter interface
6544 // use separate thread to accomodate very slow responses from
6545 // remote server
6546 //======================================================================
6547 #define PSKREP_MENU_MAX 8
6548 
6549 static pthread_t PSKREP_thread;
6550 static string pskrep_data, pskrep_url, popup_title;
6551 static string pskrep_str[PSKREP_MENU_MAX];
6552 static string::size_type pskrep_i;
6553 static Fl_Menu_Item pskrep_menu[PSKREP_MENU_MAX + 1];
6554 static bool pskrep_working = false;
6555 
do_pskreporter_popup()6556 void do_pskreporter_popup()
6557 {
6558 	int j;
6559 	int sel = 0;
6560 	int t = Fl_Tooltip::enabled();
6561 	const Fl_Menu_Item* p = (Fl_Menu_Item *)0;
6562 
6563 	put_status("");
6564 
6565 	Fl_Tooltip::disable();
6566 	p = pskrep_menu->popup(
6567 		qso_inpAct->x() + qso_inpAct->w(), qso_inpAct->y() + qso_inpAct->h(),
6568 		popup_title.c_str(), pskrep_menu + sel);
6569 
6570 	j = p ? p - pskrep_menu + 1 : 0;
6571 	if (j)
6572 		qsy(strtoll(pskrep_str[j - 1].erase(pskrep_str[j - 1].find(' ')).c_str(), NULL, 10));
6573 
6574 	Fl_Tooltip::enable(t);
6575 }
6576 
do_pskreporter_lookup(void *)6577 void *do_pskreporter_lookup(void *)  // thread action
6578 {
6579 	pskrep_working = true;
6580 	pskrep_data.clear();
6581 	pskrep_url.assign("https://pskreporter.info/cgi-bin/psk-freq.pl");
6582 	pskrep_url.append("?mode=").append(mode_info[active_modem->get_mode()].adif_name);
6583 	if (qso_inpAct->size())
6584 		pskrep_url.append("&?grid=").append(qso_inpAct->value());
6585 	else if (progdefaults.myLocator.length() > 2)
6586 		pskrep_url.append("&?grid=").append(progdefaults.myLocator, 0, 2);
6587 
6588 	if (get_http(pskrep_url, pskrep_data, 20.0) != MBEDTLS_EXIT_SUCCESS) {
6589 		LOG_ERROR("Error while fetching \"%s\": %s", pskrep_url.c_str(), pskrep_data.c_str());
6590 		pskrep_working = false;
6591 		return NULL;
6592 	}
6593 
6594 	if (pskrep_data.find("IP has made too many requests") != std::string::npos) {
6595 		popup_title.assign(progdefaults.myName).append("\nSlow down the requests\nLAST data");
6596 		REQ(do_pskreporter_popup);
6597 		pskrep_working = false;
6598 		return NULL;
6599 	}
6600 
6601 	pskrep_i = pskrep_data.rfind("\r\n\r\n");
6602 	if (pskrep_i == string::npos) {
6603 		LOG_ERROR("Pskreporter return invalid: %s", pskrep_data.c_str());
6604 		pskrep_working = false;
6605 		return NULL;
6606 	}
6607 	pskrep_i += 4;
6608 	pskrep_i = pskrep_data.find("\r\n", pskrep_i);
6609 	pskrep_i += 2;
6610 	re_t re("([[:digit:]]{6,}) [[:digit:]]+ ([[:digit:]]+)[[:space:]]+", REG_EXTENDED);
6611 
6612 	size_t j = 0;
6613 	memset(pskrep_menu, 0, sizeof(pskrep_menu));
6614 	string title;
6615 	while (re.match(pskrep_data.substr(pskrep_i).c_str()) && j < PSKREP_MENU_MAX) {
6616 		pskrep_i = pskrep_data.find("\r\n", pskrep_i + 1);
6617 		if (pskrep_i == string::npos) break;
6618 		pskrep_i += 2;
6619 		pskrep_str[j].assign(re.submatch(1)).append(" (").append(re.submatch(2)).
6620 			append(" ").append(atoi(re.submatch(2).c_str()) == 1 ? _("report") : _("reports")).append(")");
6621 		pskrep_menu[j].label(pskrep_str[j].c_str());
6622 		pskrep_menu[++j].label(NULL);
6623 	}
6624 	if ((pskrep_i = pskrep_data.rfind(" grid ")) != string::npos) {
6625 		popup_title.assign(_("Recent activity for grid ")).
6626 					append(pskrep_data.substr(pskrep_i + 5, 3));
6627 	} else {
6628 		popup_title = " (?) Check network event log!\n";
6629 #ifdef __WIN32__
6630 		popup_title.append("fldigi.files\\debug\\network_debug.txt");
6631 #else
6632 		popup_title.append("~/.fldigi/debug/network_debug.txt");
6633 #endif
6634 	}
6635 	REQ(do_pskreporter_popup);
6636 	pskrep_working = false;
6637 	return NULL;
6638 }
6639 
cb_qso_inpAct(Fl_Widget *,void *)6640 void cb_qso_inpAct(Fl_Widget*, void*)
6641 {
6642 	if (pskrep_working) {
6643 		return;
6644 	}
6645 	if (pthread_create(&PSKREP_thread, NULL, do_pskreporter_lookup, NULL) < 0) {
6646 		LOG_ERROR("%s", "pthread_create failed");
6647 		return;
6648 	}
6649 	put_status("Fetching PSK Reporter data", 15);
6650 }
6651 //======================================================================
6652 
6653 static int i_opUsage;
6654 static string s_opEntry;
6655 static string s_opUsageEntry;
6656 static string s_outEntry;
6657 
cb_opUsageEnter(Fl_Button *,void *)6658 void cb_opUsageEnter(Fl_Button *, void*)
6659 {
6660 	s_opUsageEntry = opUsage->value();
6661 	s_opEntry.append(s_opUsageEntry);
6662 	qso_opBrowser->text(i_opUsage, s_opEntry.c_str());
6663 	qso_updateEntry(i_opUsage, s_opUsageEntry);
6664 	opUsageFrame->hide();
6665 	qso_opBrowser->show();
6666 }
6667 
qso_opBrowser_amend(int i)6668 void qso_opBrowser_amend(int i)
6669 {
6670 	size_t pos;
6671 	s_opEntry = qso_opBrowser->text(i);
6672 	pos = s_opEntry.rfind('|');
6673 	s_opUsageEntry = s_opEntry.substr(pos+1);
6674 	s_opEntry.erase(pos + 1);
6675 
6676 	s_outEntry = s_opEntry.substr(0, pos);
6677 	while ((pos = s_outEntry.find('|')) != string::npos)
6678 		s_outEntry.replace(pos, 1, "  ");
6679 
6680 	opOutUsage->value(s_outEntry.c_str());
6681 
6682 	opUsage->value(s_opUsageEntry.c_str());
6683 
6684 	i_opUsage = i;
6685 	qso_opBrowser->hide();
6686 	opUsageFrame->show();
6687 }
6688 
cb_qso_opBrowser(Fl_Browser *,void *)6689 void cb_qso_opBrowser(Fl_Browser*, void*)
6690 {
6691 	int i = qso_opBrowser->value();
6692 	if (!i)
6693 		return;
6694 
6695 	// This makes the multi browser behave more like a hold browser,
6696 	// but with the ability to invoke the callback via space/return.
6697 	qso_opBrowser->deselect();
6698 	qso_opBrowser->select(i);
6699 
6700 	int ikey = Fl::event_key();
6701 	switch (ikey) {
6702 	case FL_Enter: case FL_KP_Enter: case FL_Button + FL_LEFT_MOUSE:
6703 		if (ikey == FL_Button + FL_LEFT_MOUSE && !Fl::event_clicks())
6704 			break;
6705 		qso_selectFreq();
6706 		CloseQsoView();
6707 		break;
6708 	case ' ': case FL_Button + FL_RIGHT_MOUSE:
6709 		if ((Fl::event_state() & FL_SHIFT) == FL_SHIFT) {
6710 			qso_opBrowser_amend(i);
6711 		} else
6712 			qso_setFreq();
6713 		break;
6714 	case FL_Button + FL_MIDDLE_MOUSE:
6715 		i = qso_opBrowser->value();
6716 		qso_delFreq();
6717 		qso_addFreq();
6718 		qso_opBrowser->select(i);
6719 		break;
6720 	}
6721 }
6722 
_show_frequency(long long freq)6723 void _show_frequency(long long freq)
6724 {
6725 	if (!qsoFreqDisp1 || !qsoFreqDisp2 || !qsoFreqDisp3)
6726 		return;
6727 	qsoFreqDisp1->value(freq);
6728 	qsoFreqDisp2->value(freq);
6729 	qsoFreqDisp3->value(freq);
6730 //	if (FD_logged_on) FD_band_check();
6731 }
6732 
show_frequency(long long freq)6733 void show_frequency(long long freq)
6734 {
6735 	REQ(_show_frequency, freq);
6736 }
6737 
show_mode(const string sMode)6738 void show_mode(const string sMode)
6739 {
6740 	REQ(&Fl_ListBox::put_value, qso_opMODE, sMode.c_str());
6741 }
6742 
show_bw(const string sWidth)6743 void show_bw(const string sWidth)
6744 {
6745 	REQ(&Fl_ListBox::put_value, qso_opBW, sWidth.c_str());
6746 }
6747 
show_bw1(const string sVal)6748 void show_bw1(const string sVal)
6749 {
6750 	REQ(&Fl_ListBox::put_value, qso_opBW1, sVal.c_str());
6751 }
6752 
show_bw2(const string sVal)6753 void show_bw2(const string sVal)
6754 {
6755 	REQ(&Fl_ListBox::put_value, qso_opBW2, sVal.c_str());
6756 }
6757 
show_spot(bool v)6758 void show_spot(bool v)
6759 {
6760 //if (bWF_only) return;
6761 	static bool oldval = false;
6762 	if (v) {
6763 		mnu->size(btnAutoSpot->x(), mnu->h());
6764 		if (oldval)
6765 			progStatus.spot_recv = true;
6766 		btnAutoSpot->value(progStatus.spot_recv);
6767 		btnAutoSpot->activate();
6768 	}
6769 	else {
6770 		btnAutoSpot->deactivate();
6771 		oldval = btnAutoSpot->value();
6772 		btnAutoSpot->value(v);
6773 		btnAutoSpot->do_callback();
6774 		mnu->size(btnRSID->x(), mnu->h());
6775 	}
6776 	mnu->redraw();
6777 }
6778 
setTabColors()6779 void setTabColors()
6780 {
6781 	if (dlgConfig->visible()) dlgConfig->redraw();
6782 
6783 	if (dxcluster_viewer) {
6784 		cluster_tabs->selection_color(progdefaults.TabsColor);
6785 		if (dxcluster_viewer->visible()) dxcluster_viewer->redraw();
6786 	}
6787 }
6788 
showMacroSet()6789 void showMacroSet() {
6790 	set_macroLabels();
6791 }
6792 
showDTMF(const string s)6793 void showDTMF(const string s) {
6794 	string dtmfstr = "\n<DTMF> ";
6795 	dtmfstr.append(s);
6796 	ReceiveText->addstr(dtmfstr);
6797 }
6798 
setwfrange()6799 void setwfrange() {
6800 	wf->opmode();
6801 }
6802 
sync_cw_parameters()6803 void sync_cw_parameters()
6804 {
6805 	active_modem->sync_parameters();
6806 	active_modem->update_Status();
6807 }
6808 
cb_cntCW_WPM(Fl_Widget * w,void * v)6809 void cb_cntCW_WPM(Fl_Widget * w, void *v)
6810 {
6811 	Fl_Counter2 *cnt = (Fl_Counter2 *) w;
6812 	if (progStatus.WK_online && progStatus.WK_use_pot) {
6813 		cnt->value(progStatus.WK_speed_wpm);
6814 		return;
6815 	}
6816 
6817 	if (progStatus.WK_online && cnt->value() > 55) cnt->value(55);
6818 	if (use_nanoIO && cnt->value() > 60) cnt->value(60);
6819 	if (use_nanoIO && cnt->value() < 5) cnt->value(5);
6820 
6821 	progdefaults.CWspeed = (int)cnt->value();
6822 LOG_INFO("%f WPM", progdefaults.CWspeed);
6823 	sldrCWxmtWPM->value(progdefaults.CWspeed);
6824 	cntr_nanoCW_WPM->value(progdefaults.CWspeed);
6825 
6826 	progdefaults.changed = true;
6827 	sync_cw_parameters();
6828 
6829 	if (progStatus.WK_online) WK_set_wpm();
6830 	flrig_set_wpm();
6831 
6832 	restoreFocus(25);
6833 }
6834 
cb_btnCW_Default(Fl_Widget * w,void * v)6835 void cb_btnCW_Default(Fl_Widget *w, void *v)
6836 {
6837 	active_modem->toggleWPM();
6838 	restoreFocus(26);
6839 }
6840 
cb_mainViewer_Seek(Fl_Input *,void *)6841 static void cb_mainViewer_Seek(Fl_Input *, void *)
6842 {
6843 	static const Fl_Color seek_color[2] = { FL_FOREGROUND_COLOR,
6844 					  adjust_color(FL_RED, FL_BACKGROUND2_COLOR) }; // invalid RE
6845 	seek_re.recompile(*txtInpSeek->value() ? txtInpSeek->value() : "[invalid");
6846 	if (txtInpSeek->textcolor() != seek_color[!seek_re]) {
6847 		txtInpSeek->textcolor(seek_color[!seek_re]);
6848 		txtInpSeek->redraw();
6849 	}
6850 	progStatus.browser_search = txtInpSeek->value();
6851 	if (viewer_inp_seek)
6852 		viewer_inp_seek->value(progStatus.browser_search.c_str());
6853 }
6854 
cb_cntTxLevel(Fl_Counter2 * o,void *)6855 static void cb_cntTxLevel(Fl_Counter2* o, void*) {
6856   progdefaults.txlevel = o->value();
6857 }
6858 
cb_mainViewer(Fl_Hold_Browser *,void *)6859 static void cb_mainViewer(Fl_Hold_Browser*, void*) {
6860 	int sel = mainViewer->value();
6861 	if (sel == 0 || sel > progdefaults.VIEWERchannels)
6862 		return;
6863 
6864 	switch (Fl::event_button()) {
6865 	case FL_LEFT_MOUSE:
6866 		if (mainViewer->freq(sel) != NULLFREQ) {
6867 			if (progdefaults.VIEWERhistory){
6868 				ReceiveText->addchr('\n', FTextBase::RECV);
6869 				bHistory = true;
6870 			} else {
6871 				ReceiveText->addchr('\n', FTextBase::ALTR);
6872 				ReceiveText->addstr(mainViewer->line(sel), FTextBase::ALTR);
6873 			}
6874 			active_modem->set_freq(mainViewer->freq(sel));
6875 			recenter_spectrum_viewer();
6876 			active_modem->set_sigsearch(SIGSEARCH);
6877 			if (brwsViewer) brwsViewer->select(sel);
6878 		} else
6879 			mainViewer->deselect();
6880 		break;
6881 	case FL_MIDDLE_MOUSE: // copy from modem
6882 //		set_freq(sel, active_modem->get_freq());
6883 		break;
6884 	case FL_RIGHT_MOUSE: // reset
6885 		{
6886 		int ch = progdefaults.VIEWERascend ? progdefaults.VIEWERchannels - sel : sel - 1;
6887 		active_modem->clear_ch(ch);
6888 		mainViewer->deselect();
6889 		if (brwsViewer) brwsViewer->deselect();
6890 		break;
6891 		}
6892 	default:
6893 		break;
6894 	}
6895 }
6896 
widget_color_font(Fl_Widget * widget)6897 void widget_color_font(Fl_Widget *widget)
6898 {
6899 	widget->labelsize(progdefaults.LOGGINGtextsize);
6900 	widget->labelfont(progdefaults.LOGGINGtextfont);
6901 	widget->labelcolor(progdefaults.LOGGINGtextcolor);
6902 	widget->color(progdefaults.LOGGINGcolor);
6903 	widget->redraw_label();
6904 	widget->redraw();
6905 }
6906 
input_color_font(Fl_Input * input)6907 void input_color_font(Fl_Input *input)
6908 {
6909 	input->textsize(progdefaults.LOGGINGtextsize);
6910 	input->textfont(progdefaults.LOGGINGtextfont);
6911 	input->textcolor(progdefaults.LOGGINGtextcolor);
6912 	input->color(progdefaults.LOGGINGcolor);
6913 	input->redraw();
6914 }
6915 
counter_color_font(Fl_Counter2 * cntr)6916 void counter_color_font(Fl_Counter2 * cntr)
6917 {
6918 	cntr->textsize(progdefaults.LOGGINGtextsize);
6919 	cntr->textfont(progdefaults.LOGGINGtextfont);
6920 	cntr->textcolor(progdefaults.LOGGINGtextcolor);
6921 	cntr->textbkcolor(progdefaults.LOGGINGcolor);
6922 	cntr->redraw();
6923 }
6924 
combo_color_font(Fl_ComboBox * cbo)6925 void combo_color_font(Fl_ComboBox *cbo)
6926 {
6927 	cbo->color(progdefaults.LOGGINGcolor);
6928 	cbo->selection_color(progdefaults.LOGGINGcolor);
6929 	cbo->textfont(progdefaults.LOGGINGtextfont);
6930 	cbo->textsize(progdefaults.LOGGINGtextsize);
6931 	cbo->textcolor(progdefaults.LOGGINGtextcolor);
6932 	cbo->redraw();
6933 	cbo->redraw_label();
6934 }
6935 
LOGGING_colors_font()6936 void LOGGING_colors_font()
6937 {
6938 	Fl_Input* in[] = {
6939 		inpFreq1,
6940 		inpCall1, inpCall2, inpCall3, inpCall4,
6941 		inpName1, inpName2,
6942 		inpTimeOn1, inpTimeOn2, inpTimeOn3, inpTimeOn4, inpTimeOn5,
6943 		inpTimeOff1, inpTimeOff2, inpTimeOff3, inpTimeOff4, inpTimeOff5,
6944 		inpRstIn1, inpRstIn2,
6945 		inpRstOut1, inpRstOut2,
6946 		inpQth, inpLoc, inpAZ, inpVEprov,
6947 		inpState1,
6948 		inpLoc1,
6949 		inpSerNo1, inpSerNo2,
6950 		outSerNo1, outSerNo2,
6951 		outSerNo3, outSerNo4,
6952 		inp_SS_Check1, inp_SS_Precedence1,
6953 		inp_SS_Section1, inp_SS_SerialNoR1,
6954 		inp_SS_Check2, inp_SS_Precedence2,
6955 		inp_SS_Section2, inp_SS_SerialNoR2,
6956 		inpXchgIn1, inpXchgIn2,
6957 		inp_FD_class1, inp_FD_class2,
6958 		inp_FD_section1, inp_FD_section2,
6959 		inp_KD_age1, inp_KD_age2,
6960 		inp_KD_state1, inp_KD_state2,
6961 		inp_KD_VEprov1, inp_KD_VEprov2,
6962 		inp_KD_XchgIn1, inp_KD_XchgIn2,
6963 		inp_CQ_RSTin2, inp_CQ_RSTout2, inp_CQzone1, inp_CQzone2,
6964 		inp_CQstate1, inp_CQstate2,
6965 		inp_CQDX_RSTin2, inp_CQDX_RSTout2,
6966 		inp_CQDXzone1, inp_CQDXzone2,
6967 		inp_ASCR_RSTin2, inp_ASCR_RSTout2,
6968 		inp_ASCR_XchgIn1, inp_ASCR_XchgIn2,
6969 		inp_ASCR_class1, inp_ASCR_class2,
6970 		inp_ASCR_name2,
6971 		inpNAQPname2, inp_name_NAS2,
6972 		inpSPCnum_NAQP1, inpSPCnum_NAQP2,
6973 		inpRTU_stpr1, inpRTU_stpr2, inpRTU_RSTin2, inpRTU_RSTout2,
6974 		inpRTU_serno1, inpRTU_serno2,
6975 		outSerNo4, inp_ser_NAS1, inpSPCnum_NAS1,
6976 		outSerNo5, inp_ser_NAS2, inpSPCnum_NAS2,
6977 		inpSerNo3, inpSerNo4,
6978 		outSerNo7, outSerNo8,
6979 		inpRstIn3, inpRstOut3,
6980 		inp_JOTA_scout1, inp_JOTA_scout2,
6981 		inp_JOTA_troop1, inp_JOTA_troop2,
6982 		inp_JOTA_spc1, inp_JOTA_spc2,
6983 		inpRstIn_AICW2, inpRstOut_AICW2,
6984 		inpSPCnum_AICW1, inpSPCnum_AICW2
6985 	};
6986 	for (size_t i = 0; i < sizeof(in)/sizeof(*in); i++) {
6987 		input_color_font(in[i]);
6988 	}
6989 	input_color_font(inpNotes);
6990 
6991 // buttons, boxes
6992 	Fl_Widget *wid[] = {
6993 		MODEstatus, Status1, Status2, StatusBar, WARNstatus };
6994 	for (size_t i = 0; i < sizeof(wid)/sizeof(*wid); i++)
6995 		widget_color_font(wid[i]);
6996 
6997 // counters
6998 	counter_color_font(cntCW_WPM);
6999 	counter_color_font(cntTxLevel);
7000 	counter_color_font(wf->wfRefLevel);
7001 	counter_color_font(wf->wfAmpSpan);
7002 	counter_color_font(wf->wfcarrier);
7003 
7004 // combo boxes
7005 	Fl_ComboBox *cbo_widgets[] = {
7006 		qso_opMODE, qso_opBW, qso_opBW1, qso_opBW2,
7007 		cboCountyQSO, cboCountryQSO,
7008 		cboCountryAICW2,
7009 		cboCountryAIDX2,
7010 		cboCountryCQ2,
7011 		cboCountryCQDX2,
7012 		cboCountryIARI2,
7013 		cboCountryRTU2 //,
7014 //		cboCountryWAE2
7015 	};
7016 	for (size_t i = 0; i < sizeof(cbo_widgets)/sizeof(*cbo_widgets); i++) {
7017 		combo_color_font(cbo_widgets[i]);
7018 	}
7019 
7020 	fl_digi_main->redraw();
7021 
7022 }
7023 
inp_font_pos(Fl_Input2 * inp,int x,int y,int w,int h)7024 inline void inp_font_pos(Fl_Input2* inp, int x, int y, int w, int h)
7025 {
7026 	inp->textsize(progdefaults.LOGBOOKtextsize);
7027 	inp->textfont(progdefaults.LOGBOOKtextfont);
7028 	inp->textcolor(progdefaults.LOGBOOKtextcolor);
7029 	inp->color(progdefaults.LOGBOOKcolor);
7030 	inp->labelfont(progdefaults.LOGBOOKtextfont);
7031 	int ls = progdefaults.LOGBOOKtextsize - 1;
7032 	ls = ls < 12 ? 12 : (ls > 14 ? 14 : ls);
7033 	inp->labelsize(ls);
7034 	inp->redraw_label();
7035 	inp->resize(x, y, w, h);
7036 	inp->redraw();
7037 }
7038 
date_font_pos(Fl_DateInput * inp,int x,int y,int w,int h)7039 inline void date_font_pos(Fl_DateInput* inp, int x, int y, int w, int h)
7040 {
7041 	inp->textsize(progdefaults.LOGBOOKtextsize);
7042 	inp->textfont(progdefaults.LOGBOOKtextfont);
7043 	inp->textcolor(progdefaults.LOGBOOKtextcolor);
7044 	inp->color(progdefaults.LOGBOOKcolor);
7045 	inp->labelfont(progdefaults.LOGBOOKtextfont);
7046 	int ls = progdefaults.LOGBOOKtextsize - 1;
7047 	ls = ls < 10 ? 10 : (ls > 14 ? 14 : ls);
7048 	inp->labelsize(ls);
7049 	inp->redraw_label();
7050 	inp->resize(x, y, w, h);
7051 }
7052 
btn_font_pos(Fl_Widget * btn,int x,int y,int w,int h)7053 inline void btn_font_pos(Fl_Widget* btn, int x, int y, int w, int h)
7054 {
7055 	btn->labelfont(progdefaults.LOGBOOKtextfont);
7056 	int ls = progdefaults.LOGBOOKtextsize - 1;
7057 	ls = ls < 10 ? 10 : (ls > 14 ? 14 : ls);
7058 	btn->labelsize(ls);
7059 	btn->redraw_label();
7060 	btn->resize(x, y, w, h);
7061 	btn->redraw();
7062 }
7063 
tab_font_pos(Fl_Widget * tab,int x,int y,int w,int h,int ls)7064 inline void tab_font_pos(Fl_Widget* tab, int x, int y, int w, int h, int ls)
7065 {
7066 	tab->labelfont(progdefaults.LOGBOOKtextfont);
7067 	tab->labelsize(ls);
7068 	tab->redraw_label();
7069 	tab->resize(x, y, w, h);
7070 	tab->redraw();
7071 }
7072 
chc_font_pos(Fl_Choice * chc,int x,int y,int w,int h)7073 inline void chc_font_pos(Fl_Choice* chc, int x, int y, int w, int h)
7074 {
7075 	chc->labelfont(progdefaults.LOGBOOKtextfont);
7076 	int ls = progdefaults.LOGBOOKtextsize - 1;
7077 	ls = ls < 10 ? 10 : (ls > 14 ? 14 : ls);
7078 	chc->labelsize(ls);
7079 	chc->redraw_label();
7080 	chc->resize(x, y, w, h);
7081 	chc->redraw();
7082 }
7083 
LOGBOOK_colors_font()7084 void LOGBOOK_colors_font()
7085 {
7086 	if (!dlgLogbook) return;
7087 
7088 	int ls = progdefaults.LOGBOOKtextsize;
7089 
7090 // input / output / date / text fields
7091 	fl_font(progdefaults.LOGBOOKtextfont, ls);
7092 	int wh = fl_height() + 4;// + 8;
7093 	int width_date = fl_width("888888888") + wh;
7094 	int width_time = fl_width("23:59:599");
7095 	int width_freq = fl_width("WW/WW8WWW/WW.");//fl_width("99.9999999");
7096 	int width_rst  = fl_width("5999");
7097 	int width_pwr  = fl_width("0000");
7098 	int width_loc  = fl_width("XX88XXX");
7099 	int width_mode = fl_width("CONTESTIA");
7100 	int width_state = fl_width("WWWW");
7101 	int width_province = fl_width("WWW.");
7102 	int width_country = fl_width("WWWWWWWWWWWWWWWWWWWW");
7103 
7104 	int dlg_width =	2 +
7105 					width_date + 2 +
7106 					width_time + 2 +
7107 					width_freq + 2 +
7108 					width_mode + 2 +
7109 					width_pwr + 2 +
7110 					width_rst + 2 +
7111 					width_loc + 2;
7112 
7113 	int newheight = 4*(wh + 20) + 3*wh + 2 + wh + 2 + wBrowser->h() + 2; //+ 24;
7114 
7115 	if (dlg_width > progStatus.logbook_w)
7116 		progStatus.logbook_w = dlg_width;
7117 	else
7118 		dlg_width = progStatus.logbook_w;
7119 	if (newheight > progStatus.logbook_h)
7120 		progStatus.logbook_h = newheight;
7121 	else
7122 		newheight = progStatus.logbook_h;
7123 
7124 	dlgLogbook->resize( dlgLogbook->x(), dlgLogbook->y(), progStatus.logbook_w, progStatus.logbook_h);
7125 
7126 // row1
7127 	int ypos = 24;
7128 
7129 // date on
7130 	int xpos = 2;
7131 	date_font_pos(inpDate_log, xpos, ypos, width_date, wh);
7132 // timeon
7133 	xpos += width_date + 2;
7134 	inp_font_pos(inpTimeOn_log, xpos, ypos, width_time, wh);
7135 // call
7136 	xpos += width_time + 2;
7137 	inp_font_pos(inpCall_log, xpos, ypos, width_freq, wh);
7138 // name
7139 	xpos += width_freq + 2;
7140 	int wname = dlg_width - xpos - width_rst - width_loc - 6;
7141 	inp_font_pos(inpName_log, xpos, ypos, wname, wh);
7142 // rcvd RST
7143 	xpos += wname + 2;
7144 	inp_font_pos(inpRstR_log, xpos, ypos, width_rst, wh);
7145 // nbr records
7146 	xpos += width_rst + 2;
7147 	inp_font_pos(txtNbrRecs_log, xpos, ypos, width_loc, wh);
7148 
7149 // row2
7150 	ypos += wh + 20;
7151 //date off
7152 	xpos = 2;
7153 	date_font_pos(inpDateOff_log, xpos, ypos, width_date, wh);
7154 //time off
7155 	xpos += width_date + 2;
7156 	inp_font_pos(inpTimeOff_log, xpos, ypos, width_time, wh);
7157 //frequency
7158 	xpos += width_time + 2;
7159 	inp_font_pos(inpFreq_log, xpos, ypos, width_freq, wh);
7160 //mode
7161 	xpos += width_freq + 2;
7162 	int wmode = dlg_width - xpos - width_rst - width_pwr - width_loc - 8;
7163 	inp_font_pos(inpMode_log, xpos, ypos, wmode, wh);
7164 //power
7165 	xpos += wmode + 2;
7166 	inp_font_pos(inpTX_pwr_log, xpos, ypos, width_pwr, wh);
7167 //sent RST
7168 	xpos += width_pwr + 2;
7169 	inp_font_pos(inpRstS_log, xpos, ypos, width_rst, wh);
7170 // locator
7171 	xpos += width_rst + 2;
7172 	inp_font_pos(inpLoc_log, xpos, ypos, width_loc, wh);
7173 
7174 // row 3
7175 // QTH
7176 	ypos += wh + 20;
7177 	xpos = 2;
7178 	int wqth = dlg_width - 4 - width_state - 2 - width_province - 2 - width_country - 2;
7179 	inp_font_pos(inpQth_log, xpos, ypos, wqth, wh);
7180 // state
7181 	xpos += wqth + 2;
7182 	inp_font_pos(inpState_log, xpos, ypos, width_state, wh);
7183 // province
7184 	xpos += width_state + 2;
7185 	inp_font_pos(inpVE_Prov_log, xpos, ypos, width_province, wh);
7186 // country
7187 	xpos += width_province + 2;
7188 	inp_font_pos(inpCountry_log, xpos, ypos, width_country, wh);
7189 
7190 	ypos += wh + 2;
7191 
7192 	grpTabsSearch->position(0, ypos);
7193 	Tabs->position(2, grpTabsSearch->y() + 2);
7194 
7195 	inp_font_pos(inpSearchString, Tabs->x() + Tabs->w() + 4, Tabs->y() + 30,
7196 		dlgLogbook->w() - Tabs->w() - 8, wh);
7197 
7198 	int tab_h = wh * 14 / progdefaults.LOGBOOKtextsize;
7199 	int tab_grp_h = 4 * wh + 4;
7200 //	Tabs->resize(2, ypos, dlg_width - 6 - inpSearchString->w(), tab_grp_h + tab_h);
7201 	Tabs->selection_color(progdefaults.TabsColor);
7202 
7203 	tab_font_pos(tab_log_qsl, 2, ypos + tab_h, Tabs->w(), tab_grp_h, 14);
7204 	tab_font_pos(tab_log_contest, 2, ypos + tab_h, Tabs->w(), tab_grp_h, 14);
7205 	tab_font_pos(tab_log_other, 2, ypos + tab_h, Tabs->w(), tab_grp_h, 14);
7206 	tab_font_pos(tab_log_notes, 2, ypos + tab_h, Tabs->w(), tab_grp_h, 14);
7207 
7208 	Fl_Input2* qso_fields[] = {
7209 		inpTimeOn_log, inpCall_log, inpName_log, inpRstR_log, inpTimeOff_log,
7210 		inpFreq_log, inpMode_log, inpTX_pwr_log, inpRstS_log, inpQth_log,
7211 		inpState_log, inpVE_Prov_log, inpLoc_log, inpCountry_log, inpQSL_VIA_log,
7212 		inpCNTY_log, inpIOTA_log, inpCQZ_log, inpCONT_log, inpITUZ_log,
7213 		inpDXCC_log, inpNotes_log, inp_log_sta_call, inp_log_op_call, inp_log_sta_qth,
7214 		inp_log_sta_loc, inpSerNoOut_log, inpMyXchg_log, inpSerNoIn_log, inpXchgIn_log,
7215 		inpClass_log, inpSection_log, inp_age_log, inp_1010_log, inpBand_log,
7216 		inp_check_log, inp_log_cwss_serno, inp_log_cwss_sec, inp_log_cwss_prec, inp_log_cwss_chk,
7217 		inp_log_troop_s, inp_log_troop_r, inp_log_scout_s, inp_log_scout_r, inpSearchString,
7218 		txtNbrRecs_log
7219 	};
7220 
7221 	Fl_DateInput* dti[] = {
7222 		inp_export_start_date, inp_export_stop_date, inpDate_log, inpDateOff_log,
7223 		inpQSLrcvddate_log, inpEQSLrcvddate_log, inpLOTWrcvddate_log, inpQSLsentdate_log,
7224 		inpEQSLsentdate_log, inpLOTWsentdate_log
7225 	};
7226 	for (size_t i = 0; i < sizeof(qso_fields) / sizeof(*qso_fields); i++)
7227 		inp_font_pos(
7228 			qso_fields[i], qso_fields[i]->x(),
7229 			qso_fields[i]->y(), qso_fields[i]->w(), wh);
7230 
7231 	for (size_t i = 0; i < sizeof(dti) / sizeof(*dti); i++)
7232 		date_font_pos(	dti[i], dti[i]->x(), dti[i]->y(), dti[i]->w(), wh);
7233 
7234 	inpNotes_log->resize(
7235 		tab_log_notes->x() + 2,
7236 		tab_log_notes->y() + 4,
7237 		tab_log_notes->w() - 4,
7238 		tab_log_notes->h() - 6);
7239 
7240 	ypos += grpTabsSearch->h() + 2;
7241 
7242 	grpFileButtons->resize(0, ypos, dlgLogbook->w(), grpFileButtons->h());
7243 	grpFileButtons->redraw();
7244 
7245 	txtLogFile->textsize(ls);
7246 	txtLogFile->textfont(progdefaults.LOGBOOKtextfont);
7247 	txtLogFile->textcolor(progdefaults.LOGBOOKtextcolor);
7248 	txtLogFile->color(progdefaults.LOGBOOKcolor);
7249 
7250 	ypos += grpFileButtons->h() + 2;
7251 
7252 	wBrowser->font(progdefaults.LOGBOOKtextfont);
7253 	wBrowser->fontsize(progdefaults.LOGBOOKtextsize);
7254 	wBrowser->color(progdefaults.LOGBOOKcolor);
7255 	wBrowser->selection_color(FL_SELECTION_COLOR);
7256 
7257 	int datewidth = wBrowser->columnWidth(0);
7258 	int timewidth = wBrowser->columnWidth(1);
7259 	int callwidth = wBrowser->columnWidth(2);
7260 	int namewidth = wBrowser->columnWidth(3);
7261 	int freqwidth = wBrowser->columnWidth(4);
7262 	int modewidth = wBrowser->columnWidth(5);
7263 	int totalwidth = datewidth + timewidth + callwidth + namewidth + freqwidth + modewidth;
7264 
7265 	int nuwidth = dlgLogbook->w() - 2*wBrowser->x();
7266 
7267 	wBrowser->resize(wBrowser->x(), ypos, nuwidth, dlgLogbook->h() - 2 - ypos);
7268 
7269 	nuwidth -= wBrowser->vScrollWidth();
7270 
7271 	datewidth *= (1.0 * nuwidth / totalwidth);
7272 	timewidth *= (1.0 * nuwidth / totalwidth);
7273 	callwidth *= (1.0 * nuwidth / totalwidth);
7274 	freqwidth *= (1.0 * nuwidth / totalwidth);
7275 	modewidth *= (1.0 * nuwidth / totalwidth);
7276 
7277 	namewidth = nuwidth - datewidth - timewidth - callwidth - freqwidth - modewidth;
7278 
7279 	wBrowser->columnWidth (0, datewidth); // Date column
7280 	wBrowser->columnWidth (1, timewidth); // Time column
7281 	wBrowser->columnWidth (2, callwidth); // Callsign column
7282 	wBrowser->columnWidth (3, namewidth); // Name column
7283 	wBrowser->columnWidth (4, freqwidth); // Frequency column
7284 	wBrowser->columnWidth (5, modewidth); // Mode column
7285 
7286 	dlgLogbook->init_sizes();
7287 	dlgLogbook->damage();
7288 	dlgLogbook->redraw();
7289 
7290 }
7291 
set_smeter_colors()7292 void set_smeter_colors()
7293 {
7294 	Fl_Color clr = fl_rgb_color(
7295 					progdefaults.Smeter_bg_color.R,
7296 					progdefaults.Smeter_bg_color.G,
7297 					progdefaults.Smeter_bg_color.B);
7298 	smeter->set_background(clr);
7299 
7300 	clr = fl_rgb_color(
7301 			progdefaults.Smeter_meter_color.R,
7302 			progdefaults.Smeter_meter_color.G,
7303 			progdefaults.Smeter_meter_color.B);
7304 	smeter->set_metercolor(clr);
7305 
7306 	clr = fl_rgb_color(
7307 			progdefaults.Smeter_scale_color.R,
7308 			progdefaults.Smeter_scale_color.G,
7309 			progdefaults.Smeter_scale_color.B);
7310 	smeter->set_scalecolor(clr);
7311 
7312 	smeter->redraw();
7313 
7314 	clr = fl_rgb_color(
7315 			progdefaults.PWRmeter_bg_color.R,
7316 			progdefaults.PWRmeter_bg_color.G,
7317 			progdefaults.PWRmeter_bg_color.B);
7318 	pwrmeter->set_background(clr);
7319 
7320 	clr = fl_rgb_color(
7321 			progdefaults.PWRmeter_meter_color.R,
7322 			progdefaults.PWRmeter_meter_color.G,
7323 			progdefaults.PWRmeter_meter_color.B);
7324 	pwrmeter->set_metercolor(clr);
7325 
7326 	clr = fl_rgb_color(
7327 			progdefaults.PWRmeter_scale_color.R,
7328 			progdefaults.PWRmeter_scale_color.G,
7329 			progdefaults.PWRmeter_scale_color.B);
7330 	pwrmeter->set_scalecolor(clr);
7331 
7332 	pwrmeter->select(progdefaults.PWRselect);
7333 
7334 	pwrmeter->redraw();
7335 }
7336 
FREQ_callback(Fl_Input2 * w)7337 void FREQ_callback(Fl_Input2 *w) {
7338 	std::string s;
7339 	s = w->value();
7340 	if (s.length() > MAX_FREQ) s.erase(MAX_FREQ);
7341 	w->value(s.c_str());
7342 }
7343 
TIME_callback(Fl_Input2 * w)7344 void TIME_callback(Fl_Input2 *w) {
7345 	std::string s;
7346 	s = w->value();
7347 	if (s.length() > MAX_TIME) s.erase(MAX_TIME);
7348 	w->value(s.c_str());
7349 }
7350 
RST_callback(Fl_Input2 * w)7351 void RST_callback(Fl_Input2 *w) {
7352 	std::string s;
7353 	s = w->value();
7354 	if (s.length() > MAX_RST) s.erase(MAX_RST);
7355 	w->value(s.c_str());
7356 }
7357 
CALL_callback(Fl_Input2 * w)7358 void CALL_callback(Fl_Input2 *w) {
7359 	cb_call(w, NULL);
7360 }
7361 
NAME_callback(Fl_Input2 * w)7362 void NAME_callback(Fl_Input2 *w) {
7363 	std::string s;
7364 	s = w->value();
7365 	if (s.length() > MAX_NAME) s.erase(MAX_NAME);
7366 	w->value(s.c_str());
7367 }
7368 
AZ_callback(Fl_Input2 * w)7369 void AZ_callback(Fl_Input2 *w) {
7370 	std::string s;
7371 	s = w->value();
7372 	if (s.length() > MAX_AZ) s.erase(MAX_AZ);
7373 	w->value(s.c_str());
7374 }
7375 
QTH_callback(Fl_Input2 * w)7376 void QTH_callback(Fl_Input2 *w) {
7377 	std::string s;
7378 	s = w->value();
7379 	if (s.length() > MAX_QTH) s.erase(MAX_QTH);
7380 	w->value(s.c_str());
7381 }
7382 
STATE_callback(Fl_Input2 * w)7383 void STATE_callback(Fl_Input2 *w) {
7384 	std::string s;
7385 	s = w->value();
7386 	if (s.length() > MAX_STATE) s.erase(MAX_STATE);
7387 	w->value(s.c_str());
7388 }
7389 
VEPROV_callback(Fl_Input2 * w)7390 void VEPROV_callback(Fl_Input2 *w) {
7391 	std::string s;
7392 	s = w->value();
7393 	if (s.length() > MAX_STATE) s.erase(MAX_STATE);
7394 	w->value(s.c_str());
7395 }
7396 
LOC_callback(Fl_Input2 * w)7397 void LOC_callback(Fl_Input2 *w) {
7398 	cb_loc(w, NULL);
7399 }
7400 
SERNO_callback(Fl_Input2 * w)7401 void SERNO_callback(Fl_Input2 *w) {
7402 	std::string s;
7403 	s = w->value();
7404 	if (s.length() > MAX_SERNO) s.erase(MAX_SERNO);
7405 	w->value(s.c_str());
7406 }
7407 
XCHG_IN_callback(Fl_Input2 * w)7408 void XCHG_IN_callback(Fl_Input2 *w) {
7409 	std::string s;
7410 	s = w->value();
7411 	if (s.length() > MAX_XCHG_IN) s.erase(MAX_XCHG_IN);
7412 	w->value(s.c_str());
7413 }
7414 
COUNTRY_callback(Fl_ComboBox * w)7415 void COUNTRY_callback(Fl_ComboBox *w) {
7416 	std::string s;
7417 	s = w->value();
7418 	if (s.length() > MAX_COUNTRY) s.erase(MAX_COUNTRY);
7419 	if (country_test(s))
7420 		w->value(country_match.c_str());
7421 	else
7422 		w->value(s.c_str());
7423 }
7424 
COUNTY_callback(Fl_Input2 * w)7425 void COUNTY_callback(Fl_Input2 *w) {
7426 	std::string s;
7427 	s = w->value();
7428 	if (s.length() > MAX_COUNTY) s.erase(MAX_COUNTY);
7429 	w->value(s.c_str());
7430 }
7431 
NOTES_callback(Fl_Input2 * w)7432 void NOTES_callback(Fl_Input2 *w) {
7433 	std::string s;
7434 	s = w->value();
7435 	if (s.length() > MAX_NOTES) s.erase(MAX_NOTES);
7436 	w->value(s.c_str());
7437 }
7438 
log_callback(Fl_Widget * w)7439 void log_callback(Fl_Widget *w) {
7440 	if (w == inpCall) {
7441 		n3fjp_calltab = true;
7442 		CALL_callback((Fl_Input2 *)w);
7443 		DupCheck();
7444 		return;
7445 	}
7446 	if (w == inpName) {
7447 		NAME_callback((Fl_Input2 *)w);
7448 		return;
7449 	}
7450 	if (w == cboCountry) {
7451 		COUNTRY_callback((Fl_ComboBox *)w);
7452 		return;
7453 	}
7454 	if (w == inpCounty) {
7455 		COUNTY_callback((Fl_Input2 *)w);
7456 		return;
7457 	}
7458 	if (w == inpNotes) {
7459 		NOTES_callback((Fl_Input2 *)w);
7460 		return;
7461 	}
7462 	if (w == inpLoc) {
7463 		LOC_callback((Fl_Input2 *)w);
7464 		return;
7465 	}
7466 	if (w == inpXchgIn) {
7467 		XCHG_IN_callback((Fl_Input2 *)w);
7468 		return;
7469 	}
7470 	if (w == inpState) {
7471 		STATE_callback((Fl_Input2 *)w);
7472 		return;
7473 	}
7474 	if (w == inpVEprov) {
7475 		VEPROV_callback((Fl_Input2 *)w);
7476 		return;
7477 	}
7478 	if (w == inpQTH) {
7479 		QTH_callback((Fl_Input2 *)w);
7480 		return;
7481 	}
7482 	if (w == inpAZ) {
7483 		AZ_callback((Fl_Input2 *)w);
7484 		return;
7485 	}
7486 	if (w == inpSerNo) {
7487 		SERNO_callback((Fl_Input2 *)w);
7488 		return;
7489 	}
7490 	if (w == inpRstIn) {
7491 		RST_callback((Fl_Input2 *)w);
7492 		return;
7493 	}
7494 	if (w == inpTimeOff || w == inpTimeOn) {
7495 		TIME_callback((Fl_Input2 *)w);
7496 		return;
7497 	}
7498 //	LOG_ERROR("unknown widget %p", w);
7499 }
7500 
cb_CountyQSO(Fl_Widget *)7501 void cb_CountyQSO(Fl_Widget *)
7502 {
7503 	string sc = cboCountyQSO->value();
7504 	if (sc.empty()) return;
7505 	Cstates st;
7506 	string ST = sc.substr(0,2);
7507 	string CNTY = st.cnty_short(sc.substr(0,2), sc.substr(3));
7508 	if (inpState) inpState->value(ST.c_str());
7509 	if (inpState1) inpState1->value(ST.c_str());
7510 	if (inp_CQstate1) inp_CQstate1->value(ST.c_str());
7511 	if (inp_CQstate2) inp_CQstate2->value(ST.c_str());
7512 	if (inpSQSO_state1) inpSQSO_state1->value(ST.c_str());
7513 	if (inpSQSO_state2) inpSQSO_state2->value(ST.c_str());
7514 	if (inpSQSO_county1) inpSQSO_county1->value(CNTY.c_str());
7515 	if (inpSQSO_county2) inpSQSO_county2->value(CNTY.c_str());
7516 }
7517 
cb_meters(Fl_Widget *)7518 void cb_meters(Fl_Widget *)
7519 {
7520 	if (!rigCAT_active()) return;
7521 	pwrlevel_grp->show();
7522 }
7523 
cb_set_pwr_level(void *)7524 void cb_set_pwr_level(void *)
7525 {
7526 	rigCAT_set_pwrlevel((int)pwr_level->value());
7527 }
7528 
cb_exit_pwr_level(void *)7529 void cb_exit_pwr_level(void*)
7530 {
7531 	pwrlevel_grp->hide();
7532 }
7533 
7534 #include "fl_digi_main.cxx"
7535 
7536 void cb_mnuAltDockedscope(Fl_Menu_ *w, void *d);
7537 
7538 static Fl_Menu_Item alt_menu_[] = {
7539 {_("&File"), 0,  0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7540 { icons::make_icon_label(_("Exit"), log_out_icon), 'x',  (Fl_Callback*)cb_E, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
7541 {0,0,0,0,0,0,0,0,0},
7542 
7543 {_("Op &Mode"), 0,  0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7544 
7545 { mode_info[MODE_CW].name, 0, cb_init_mode, (void *)MODE_CW, 0, FL_NORMAL_LABEL, 0, 14, 0},
7546 
7547 {"Contestia", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7548 { mode_info[MODE_CONTESTIA_4_125].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_4_125, 0, FL_NORMAL_LABEL, 0, 14, 0},
7549 { mode_info[MODE_CONTESTIA_4_250].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_4_250, 0, FL_NORMAL_LABEL, 0, 14, 0},
7550 { mode_info[MODE_CONTESTIA_4_500].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_4_500, 0, FL_NORMAL_LABEL, 0, 14, 0},
7551 { mode_info[MODE_CONTESTIA_4_1000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_4_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7552 { mode_info[MODE_CONTESTIA_4_2000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_4_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7553 
7554 { mode_info[MODE_CONTESTIA_8_125].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_8_125, 0, FL_NORMAL_LABEL, 0, 14, 0},
7555 { mode_info[MODE_CONTESTIA_8_250].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_8_250, 0, FL_NORMAL_LABEL, 0, 14, 0},
7556 { mode_info[MODE_CONTESTIA_8_500].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_8_500, 0, FL_NORMAL_LABEL, 0, 14, 0},
7557 { mode_info[MODE_CONTESTIA_8_1000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_8_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7558 { mode_info[MODE_CONTESTIA_8_2000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_8_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7559 
7560 { mode_info[MODE_CONTESTIA_16_250].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_16_250, 0, FL_NORMAL_LABEL, 0, 14, 0},
7561 { mode_info[MODE_CONTESTIA_16_500].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_16_500, 0, FL_NORMAL_LABEL, 0, 14, 0},
7562 { mode_info[MODE_CONTESTIA_16_1000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_16_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7563 { mode_info[MODE_CONTESTIA_16_2000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_16_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7564 
7565 { mode_info[MODE_CONTESTIA_32_1000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_32_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7566 { mode_info[MODE_CONTESTIA_32_2000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_32_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7567 
7568 { mode_info[MODE_CONTESTIA_64_500].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_64_500, 0, FL_NORMAL_LABEL, 0, 14, 0},
7569 { mode_info[MODE_CONTESTIA_64_1000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_64_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7570 { mode_info[MODE_CONTESTIA_64_2000].name, 0, cb_init_mode, (void *)MODE_CONTESTIA_64_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7571 { _("Custom..."), 0, cb_contestiaCustom, (void *)MODE_CONTESTIA, 0, FL_NORMAL_LABEL, 0, 14, 0},
7572 {0,0,0,0,0,0,0,0,0},
7573 
7574 {"DominoEX", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7575 { mode_info[MODE_DOMINOEXMICRO].name, 0, cb_init_mode, (void *)MODE_DOMINOEXMICRO, 0, FL_NORMAL_LABEL, 0, 14, 0},
7576 { mode_info[MODE_DOMINOEX4].name, 0, cb_init_mode, (void *)MODE_DOMINOEX4, 0, FL_NORMAL_LABEL, 0, 14, 0},
7577 { mode_info[MODE_DOMINOEX5].name, 0, cb_init_mode, (void *)MODE_DOMINOEX5, 0, FL_NORMAL_LABEL, 0, 14, 0},
7578 { mode_info[MODE_DOMINOEX8].name, 0, cb_init_mode, (void *)MODE_DOMINOEX8, 0, FL_NORMAL_LABEL, 0, 14, 0},
7579 { mode_info[MODE_DOMINOEX11].name, 0, cb_init_mode, (void *)MODE_DOMINOEX11, 0, FL_NORMAL_LABEL, 0, 14, 0},
7580 { mode_info[MODE_DOMINOEX16].name, 0, cb_init_mode, (void *)MODE_DOMINOEX16, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
7581 { mode_info[MODE_DOMINOEX22].name, 0, cb_init_mode, (void *)MODE_DOMINOEX22, 0, FL_NORMAL_LABEL, 0, 14, 0},
7582 { mode_info[MODE_DOMINOEX44].name, 0,  cb_init_mode, (void *)MODE_DOMINOEX44, 0, FL_NORMAL_LABEL, 0, 14, 0},
7583 { mode_info[MODE_DOMINOEX88].name, 0,  cb_init_mode, (void *)MODE_DOMINOEX88, 0, FL_NORMAL_LABEL, 0, 14, 0},
7584 {0,0,0,0,0,0,0,0,0},
7585 
7586 {"MFSK", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7587 { mode_info[MODE_MFSK4].name, 0,  cb_init_mode, (void *)MODE_MFSK4, 0, FL_NORMAL_LABEL, 0, 14, 0},
7588 { mode_info[MODE_MFSK8].name, 0,  cb_init_mode, (void *)MODE_MFSK8, 0, FL_NORMAL_LABEL, 0, 14, 0},
7589 { mode_info[MODE_MFSK11].name, 0,  cb_init_mode, (void *)MODE_MFSK11, 0, FL_NORMAL_LABEL, 0, 14, 0},
7590 { mode_info[MODE_MFSK16].name, 0,  cb_init_mode, (void *)MODE_MFSK16, 0, FL_NORMAL_LABEL, 0, 14, 0},
7591 { mode_info[MODE_MFSK22].name, 0,  cb_init_mode, (void *)MODE_MFSK22, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
7592 { mode_info[MODE_MFSK31].name, 0,  cb_init_mode, (void *)MODE_MFSK31, 0, FL_NORMAL_LABEL, 0, 14, 0},
7593 { mode_info[MODE_MFSK32].name, 0,  cb_init_mode, (void *)MODE_MFSK32, 0, FL_NORMAL_LABEL, 0, 14, 0},
7594 { mode_info[MODE_MFSK64].name, 0,  cb_init_mode, (void *)MODE_MFSK64, 0, FL_NORMAL_LABEL, 0, 14, 0},
7595 { mode_info[MODE_MFSK128].name, 0,  cb_init_mode, (void *)MODE_MFSK128, 0, FL_NORMAL_LABEL, 0, 14, 0},
7596 { mode_info[MODE_MFSK64L].name, 0,  cb_init_mode, (void *)MODE_MFSK64L, 0, FL_NORMAL_LABEL, 0, 14, 0},
7597 { mode_info[MODE_MFSK128L].name, 0,  cb_init_mode, (void *)MODE_MFSK128L, 0, FL_NORMAL_LABEL, 0, 14, 0},
7598 {0,0,0,0,0,0,0,0,0},
7599 
7600 {"MT63", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7601 { mode_info[MODE_MT63_500S].name, 0,  cb_init_mode, (void *)MODE_MT63_500S, 0, FL_NORMAL_LABEL, 0, 14, 0},
7602 { mode_info[MODE_MT63_500L].name, 0,  cb_init_mode, (void *)MODE_MT63_500L, 0, FL_NORMAL_LABEL, 0, 14, 0},
7603 { mode_info[MODE_MT63_1000S].name, 0,  cb_init_mode, (void *)MODE_MT63_1000S, 0, FL_NORMAL_LABEL, 0, 14, 0},
7604 { mode_info[MODE_MT63_1000L].name, 0,  cb_init_mode, (void *)MODE_MT63_1000L, 0, FL_NORMAL_LABEL, 0, 14, 0},
7605 { mode_info[MODE_MT63_2000S].name, 0,  cb_init_mode, (void *)MODE_MT63_2000S, 0, FL_NORMAL_LABEL, 0, 14, 0},
7606 { mode_info[MODE_MT63_2000L].name, 0,  cb_init_mode, (void *)MODE_MT63_2000L, 0, FL_NORMAL_LABEL, 0, 14, 0},
7607 {0,0,0,0,0,0,0,0,0},
7608 
7609 {"OFDM", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7610 { mode_info[MODE_OFDM_500F].name, 0,  cb_init_mode, (void *)MODE_OFDM_500F, 0, FL_NORMAL_LABEL, 0, 14, 0},
7611 { mode_info[MODE_OFDM_750F].name, 0,  cb_init_mode, (void *)MODE_OFDM_750F, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
7612 //{ mode_info[MODE_OFDM_2000F].name, 0,  cb_init_mode, (void *)MODE_OFDM_2000F, 0, FL_NORMAL_LABEL, 0, 14, 0},
7613 //{ mode_info[MODE_OFDM_2000].name, 0,  cb_init_mode, (void *)MODE_OFDM_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7614 { mode_info[MODE_OFDM_3500].name, 0,  cb_init_mode, (void *)MODE_OFDM_3500, 0, FL_NORMAL_LABEL, 0, 14, 0},
7615 {0,0,0,0,0,0,0,0,0},
7616 
7617 {"Olivia", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7618 { mode_info[MODE_OLIVIA_4_125].name, 0, cb_init_mode, (void *)MODE_OLIVIA_4_125, 0, FL_NORMAL_LABEL, 0, 14, 0},
7619 { mode_info[MODE_OLIVIA_4_250].name, 0, cb_init_mode, (void *)MODE_OLIVIA_4_250, 0, FL_NORMAL_LABEL, 0, 14, 0},
7620 { mode_info[MODE_OLIVIA_4_500].name, 0, cb_init_mode, (void *)MODE_OLIVIA_4_500, 0, FL_NORMAL_LABEL, 0, 14, 0},
7621 { mode_info[MODE_OLIVIA_4_1000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_4_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7622 { mode_info[MODE_OLIVIA_4_2000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_4_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7623 
7624 { mode_info[MODE_OLIVIA_8_125].name, 0, cb_init_mode, (void *)MODE_OLIVIA_8_125, 0, FL_NORMAL_LABEL, 0, 14, 0},
7625 { mode_info[MODE_OLIVIA_8_250].name, 0, cb_init_mode, (void *)MODE_OLIVIA_8_250, 0, FL_NORMAL_LABEL, 0, 14, 0},
7626 { mode_info[MODE_OLIVIA_8_500].name, 0, cb_init_mode, (void *)MODE_OLIVIA_8_500, 0, FL_NORMAL_LABEL, 0, 14, 0},
7627 { mode_info[MODE_OLIVIA_8_1000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_8_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7628 { mode_info[MODE_OLIVIA_8_2000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_8_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7629 
7630 { mode_info[MODE_OLIVIA_16_500].name, 0, cb_init_mode, (void *)MODE_OLIVIA_16_500, 0, FL_NORMAL_LABEL, 0, 14, 0},
7631 { mode_info[MODE_OLIVIA_16_1000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_16_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7632 { mode_info[MODE_OLIVIA_16_2000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_16_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7633 
7634 { mode_info[MODE_OLIVIA_32_1000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_32_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7635 { mode_info[MODE_OLIVIA_32_2000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_32_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7636 
7637 { mode_info[MODE_OLIVIA_64_500].name, 0, cb_init_mode, (void *)MODE_OLIVIA_64_500, 0, FL_NORMAL_LABEL, 0, 14, 0},
7638 { mode_info[MODE_OLIVIA_64_1000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_64_1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7639 { mode_info[MODE_OLIVIA_64_2000].name, 0, cb_init_mode, (void *)MODE_OLIVIA_64_2000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7640 { _("Custom..."), 0, cb_oliviaCustom, (void *)MODE_OLIVIA, 0, FL_NORMAL_LABEL, 0, 14, 0},
7641 {0,0,0,0,0,0,0,0,0},
7642 
7643 {"PSK", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7644 { mode_info[MODE_PSK31].name, 0, cb_init_mode, (void *)MODE_PSK31, 0, FL_NORMAL_LABEL, 0, 14, 0},
7645 { mode_info[MODE_PSK63].name, 0, cb_init_mode, (void *)MODE_PSK63, 0, FL_NORMAL_LABEL, 0, 14, 0},
7646 { mode_info[MODE_PSK63F].name, 0, cb_init_mode, (void *)MODE_PSK63F, 0, FL_NORMAL_LABEL, 0, 14, 0},
7647 { mode_info[MODE_PSK125].name, 0, cb_init_mode, (void *)MODE_PSK125, 0, FL_NORMAL_LABEL, 0, 14, 0},
7648 { mode_info[MODE_PSK250].name, 0, cb_init_mode, (void *)MODE_PSK250, 0, FL_NORMAL_LABEL, 0, 14, 0},
7649 { mode_info[MODE_PSK500].name, 0, cb_init_mode, (void *)MODE_PSK500, 0, FL_NORMAL_LABEL, 0, 14, 0},
7650 { mode_info[MODE_PSK1000].name, 0, cb_init_mode, (void *)MODE_PSK1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7651 {"MultiCarrier", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7652 { mode_info[MODE_12X_PSK125].name, 0, cb_init_mode, (void *)MODE_12X_PSK125, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
7653 { mode_info[MODE_6X_PSK250].name, 0, cb_init_mode, (void *)MODE_6X_PSK250, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
7654 { mode_info[MODE_2X_PSK500].name, 0, cb_init_mode, (void *)MODE_2X_PSK500, 0, FL_NORMAL_LABEL, 0, 14, 0},
7655 { mode_info[MODE_4X_PSK500].name, 0, cb_init_mode, (void *)MODE_4X_PSK500, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
7656 { mode_info[MODE_2X_PSK800].name, 0, cb_init_mode, (void *)MODE_2X_PSK800, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
7657 { mode_info[MODE_2X_PSK1000].name, 0, cb_init_mode, (void *)MODE_2X_PSK1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7658 {0,0,0,0,0,0,0,0,0},
7659 {0,0,0,0,0,0,0,0,0},
7660 
7661 {"QPSK", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7662 { mode_info[MODE_QPSK31].name, 0, cb_init_mode, (void *)MODE_QPSK31, 0, FL_NORMAL_LABEL, 0, 14, 0},
7663 { mode_info[MODE_QPSK63].name, 0, cb_init_mode, (void *)MODE_QPSK63, 0, FL_NORMAL_LABEL, 0, 14, 0},
7664 { mode_info[MODE_QPSK125].name, 0, cb_init_mode, (void *)MODE_QPSK125, 0, FL_NORMAL_LABEL, 0, 14, 0},
7665 { mode_info[MODE_QPSK250].name, 0, cb_init_mode, (void *)MODE_QPSK250, 0, FL_NORMAL_LABEL, 0, 14, 0},
7666 { mode_info[MODE_QPSK500].name, 0, cb_init_mode, (void *)MODE_QPSK500, 0, FL_NORMAL_LABEL, 0, 14, 0},
7667 {0,0,0,0,0,0,0,0,0},
7668 
7669 {"8PSK", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7670 { mode_info[MODE_8PSK125].name, 0, cb_init_mode, (void *)MODE_8PSK125, 0, FL_NORMAL_LABEL, 0, 14, 0},
7671 { mode_info[MODE_8PSK250].name, 0, cb_init_mode, (void *)MODE_8PSK250, 0, FL_NORMAL_LABEL, 0, 14, 0},
7672 { mode_info[MODE_8PSK500].name, 0, cb_init_mode, (void *)MODE_8PSK500, 0, FL_NORMAL_LABEL, 0, 14, 0},
7673 { mode_info[MODE_8PSK1000].name, 0, cb_init_mode, (void *)MODE_8PSK1000, 0, FL_NORMAL_LABEL, 0, 14, 0},
7674 { mode_info[MODE_8PSK125FL].name, 0, cb_init_mode, (void *)MODE_8PSK125FL, 0, FL_NORMAL_LABEL, 0, 14, 0},
7675 { mode_info[MODE_8PSK125F].name, 0, cb_init_mode, (void *)MODE_8PSK125F, 0, FL_NORMAL_LABEL, 0, 14, 0},
7676 { mode_info[MODE_8PSK250FL].name, 0, cb_init_mode, (void *)MODE_8PSK250FL, 0, FL_NORMAL_LABEL, 0, 14, 0},
7677 { mode_info[MODE_8PSK250F].name, 0, cb_init_mode, (void *)MODE_8PSK250F, 0, FL_NORMAL_LABEL, 0, 14, 0},
7678 { mode_info[MODE_8PSK500F].name, 0, cb_init_mode, (void *)MODE_8PSK500F, 0, FL_NORMAL_LABEL, 0, 14, 0},
7679 { mode_info[MODE_8PSK1000F].name, 0, cb_init_mode, (void *)MODE_8PSK1000F, 0, FL_NORMAL_LABEL, 0, 14, 0},
7680 { mode_info[MODE_8PSK1200F].name, 0, cb_init_mode, (void *)MODE_8PSK1200F, 0, FL_NORMAL_LABEL, 0, 14, 0},
7681 {0,0,0,0,0,0,0,0,0},
7682 
7683 {"PSKR", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7684 { mode_info[MODE_PSK125R].name, 0, cb_init_mode, (void *)MODE_PSK125R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7685 { mode_info[MODE_PSK250R].name, 0, cb_init_mode, (void *)MODE_PSK250R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7686 { mode_info[MODE_PSK500R].name, 0, cb_init_mode, (void *)MODE_PSK500R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7687 { mode_info[MODE_PSK1000R].name, 0, cb_init_mode, (void *)MODE_PSK1000R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7688 {"MultiCarrier", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7689 { mode_info[MODE_4X_PSK63R].name, 0, cb_init_mode, (void *)MODE_4X_PSK63R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7690 { mode_info[MODE_5X_PSK63R].name, 0, cb_init_mode, (void *)MODE_5X_PSK63R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7691 { mode_info[MODE_10X_PSK63R].name, 0, cb_init_mode, (void *)MODE_10X_PSK63R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7692 { mode_info[MODE_20X_PSK63R].name, 0, cb_init_mode, (void *)MODE_20X_PSK63R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7693 { mode_info[MODE_32X_PSK63R].name, 0, cb_init_mode, (void *)MODE_32X_PSK63R, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
7694 { mode_info[MODE_4X_PSK125R].name, 0, cb_init_mode, (void *)MODE_4X_PSK125R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7695 { mode_info[MODE_5X_PSK125R].name, 0, cb_init_mode, (void *)MODE_5X_PSK125R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7696 { mode_info[MODE_10X_PSK125R].name, 0, cb_init_mode, (void *)MODE_10X_PSK125R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7697 { mode_info[MODE_12X_PSK125R].name, 0, cb_init_mode, (void *)MODE_12X_PSK125R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7698 { mode_info[MODE_16X_PSK125R].name, 0, cb_init_mode, (void *)MODE_16X_PSK125R, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
7699 { mode_info[MODE_2X_PSK250R].name, 0, cb_init_mode, (void *)MODE_2X_PSK250R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7700 { mode_info[MODE_3X_PSK250R].name, 0, cb_init_mode, (void *)MODE_3X_PSK250R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7701 { mode_info[MODE_5X_PSK250R].name, 0, cb_init_mode, (void *)MODE_5X_PSK250R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7702 { mode_info[MODE_6X_PSK250R].name, 0, cb_init_mode, (void *)MODE_6X_PSK250R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7703 { mode_info[MODE_7X_PSK250R].name, 0, cb_init_mode, (void *)MODE_7X_PSK250R, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
7704 { mode_info[MODE_2X_PSK500R].name, 0, cb_init_mode, (void *)MODE_2X_PSK500R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7705 { mode_info[MODE_3X_PSK500R].name, 0, cb_init_mode, (void *)MODE_3X_PSK500R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7706 { mode_info[MODE_4X_PSK500R].name, 0, cb_init_mode, (void *)MODE_4X_PSK500R, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
7707 { mode_info[MODE_2X_PSK800R].name, 0, cb_init_mode, (void *)MODE_2X_PSK800R, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
7708 { mode_info[MODE_2X_PSK1000R].name, 0, cb_init_mode, (void *)MODE_2X_PSK1000R, 0, FL_NORMAL_LABEL, 0, 14, 0},
7709 {0,0,0,0,0,0,0,0,0},
7710 {0,0,0,0,0,0,0,0,0},
7711 
7712 { RTTY_MLABEL, 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7713 { "RTTY-45", 0, cb_rtty45, (void *)MODE_RTTY, 0, FL_NORMAL_LABEL, 0, 14, 0},
7714 { "RTTY-50", 0, cb_rtty50, (void *)MODE_RTTY, 0, FL_NORMAL_LABEL, 0, 14, 0},
7715 { "RTTY-75N", 0, cb_rtty75N, (void *)MODE_RTTY, 0, FL_NORMAL_LABEL, 0, 14, 0},
7716 { "RTTY-75W", 0, cb_rtty75W, (void *)MODE_RTTY, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
7717 { _("Custom..."), 0, cb_rttyCustom, (void *)MODE_RTTY, 0, FL_NORMAL_LABEL, 0, 14, 0},
7718 {0,0,0,0,0,0,0,0,0},
7719 
7720 {"THOR", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7721 { mode_info[MODE_THORMICRO].name, 0, cb_init_mode, (void *)MODE_THORMICRO, 0, FL_NORMAL_LABEL, 0, 14, 0},
7722 { mode_info[MODE_THOR4].name, 0, cb_init_mode, (void *)MODE_THOR4, 0, FL_NORMAL_LABEL, 0, 14, 0},
7723 { mode_info[MODE_THOR5].name, 0, cb_init_mode, (void *)MODE_THOR5, 0, FL_NORMAL_LABEL, 0, 14, 0},
7724 { mode_info[MODE_THOR8].name, 0, cb_init_mode, (void *)MODE_THOR8, 0, FL_NORMAL_LABEL, 0, 14, 0},
7725 { mode_info[MODE_THOR11].name, 0, cb_init_mode, (void *)MODE_THOR11, 0, FL_NORMAL_LABEL, 0, 14, 0},
7726 { mode_info[MODE_THOR16].name, 0, cb_init_mode, (void *)MODE_THOR16, FL_MENU_DIVIDER, FL_NORMAL_LABEL, 0, 14, 0},
7727 { mode_info[MODE_THOR22].name, 0, cb_init_mode, (void *)MODE_THOR22, 0, FL_NORMAL_LABEL, 0, 14, 0},
7728 { mode_info[MODE_THOR25x4].name, 0,  cb_init_mode, (void *)MODE_THOR25x4, 0, FL_NORMAL_LABEL, 0, 14, 0},
7729 { mode_info[MODE_THOR50x1].name, 0,  cb_init_mode, (void *)MODE_THOR50x1, 0, FL_NORMAL_LABEL, 0, 14, 0},
7730 { mode_info[MODE_THOR50x2].name, 0,  cb_init_mode, (void *)MODE_THOR50x2, 0, FL_NORMAL_LABEL, 0, 14, 0},
7731 { mode_info[MODE_THOR100].name, 0,  cb_init_mode, (void *)MODE_THOR100, 0, FL_NORMAL_LABEL, 0, 14, 0},
7732 {0,0,0,0,0,0,0,0,0},
7733 
7734 {"Throb", 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7735 { mode_info[MODE_THROB1].name, 0, cb_init_mode, (void *)MODE_THROB1, 0, FL_NORMAL_LABEL, 0, 14, 0},
7736 { mode_info[MODE_THROB2].name, 0, cb_init_mode, (void *)MODE_THROB2, 0, FL_NORMAL_LABEL, 0, 14, 0},
7737 { mode_info[MODE_THROB4].name, 0, cb_init_mode, (void *)MODE_THROB4, 0, FL_NORMAL_LABEL, 0, 14, 0},
7738 { mode_info[MODE_THROBX1].name, 0, cb_init_mode, (void *)MODE_THROBX1, 0, FL_NORMAL_LABEL, 0, 14, 0},
7739 { mode_info[MODE_THROBX2].name, 0, cb_init_mode, (void *)MODE_THROBX2, 0, FL_NORMAL_LABEL, 0, 14, 0},
7740 { mode_info[MODE_THROBX4].name, 0, cb_init_mode, (void *)MODE_THROBX4, 0, FL_NORMAL_LABEL, 0, 14, 0},
7741 {0,0,0,0,0,0,0,0,0},
7742 
7743 { mode_info[MODE_WWV].name, 0, cb_init_mode, (void *)MODE_WWV, 0, FL_NORMAL_LABEL, 0, 14, 0},
7744 { mode_info[MODE_NULL].name, 0, cb_init_mode, (void *)MODE_NULL, 0, FL_NORMAL_LABEL, 0, 14, 0},
7745 { mode_info[MODE_SSB].name, 0, cb_init_mode, (void *)MODE_SSB, 0, FL_NORMAL_LABEL, 0, 14, 0},
7746 {0,0,0,0,0,0,0,0,0},
7747 
7748 {_("&Configure"), 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7749 { icons::make_icon_label(_("Config Dialog")), 0, (Fl_Callback*)cb_mnu_config_dialog, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
7750 { icons::make_icon_label(_("Test Signals")), 0, (Fl_Callback*)cb_mnuTestSignals, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
7751 { icons::make_icon_label(_("Notifications")), 0,  (Fl_Callback*)cb_mnuConfigNotify, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
7752 { icons::make_icon_label(_("Save Config"), save_icon), 0, (Fl_Callback*)cb_mnuSaveConfig, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
7753 {0,0,0,0,0,0,0,0,0},
7754 
7755 { VIEW_MLABEL, 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7756 { icons::make_icon_label(_("Rx Audio Dialog")), 'a', (Fl_Callback*)cb_mnuRxAudioDialog, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
7757 { icons::make_icon_label(_("Signal Browser")), 0, (Fl_Callback*)cb_mnuViewer, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
7758 { icons::make_icon_label(_("Spectrum scope")), 0, (Fl_Callback*)cb_mnuSpectrum, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
7759 { icons::make_icon_label(_("Floating scope"), utilities_system_monitor_icon), 'f', (Fl_Callback*)cb_mnuDigiscope, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
7760 { DOCKEDSCOPE_MLABEL, 0, (Fl_Callback*)cb_mnuAltDockedscope, 0, FL_MENU_TOGGLE, FL_NORMAL_LABEL, 0, 14, 0},
7761 
7762 { icons::make_icon_label(MFSK_IMAGE_MLABEL, image_icon), 0, (Fl_Callback*)cb_mnuPicViewer, 0, FL_MENU_INACTIVE, _FL_MULTI_LABEL, 0, 14, 0},
7763 { icons::make_icon_label(THOR_IMAGE_MLABEL, image_icon), 0, (Fl_Callback*)cb_mnuThorViewRaw,0, FL_MENU_INACTIVE, _FL_MULTI_LABEL, 0, 14, 0},
7764 { icons::make_icon_label(IFKP_IMAGE_MLABEL, image_icon), 0, (Fl_Callback*)cb_mnuIfkpViewRaw,0, FL_MENU_INACTIVE | FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
7765 { icons::make_icon_label(WEFAX_TX_IMAGE_MLABEL, image_icon), 0, (Fl_Callback*)wefax_pic::cb_mnu_pic_viewer_tx,0, FL_MENU_INACTIVE | FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
7766 {0,0,0,0,0,0,0,0,0},
7767 
7768 {_("&Help"), 0, 0, 0, FL_SUBMENU, FL_NORMAL_LABEL, 0, 14, 0},
7769 { icons::make_icon_label(_("Online documentation..."), help_browser_icon), 0, cb_mnuOnLineDOCS, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
7770 { icons::make_icon_label(_("Event log"), dialog_information_icon), 0, cb_mnuDebug, 0, FL_MENU_DIVIDER, _FL_MULTI_LABEL, 0, 14, 0},
7771 { icons::make_icon_label(_("Check for updates..."), system_software_update_icon), 0, cb_mnuCheckUpdate, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
7772 { icons::make_icon_label(_("&About"), help_about_icon), 'a', cb_mnuAboutURL, 0, 0, _FL_MULTI_LABEL, 0, 14, 0},
7773 {0,0,0,0,0,0,0,0,0},
7774 
7775 {0,0,0,0,0,0,0,0,0},
7776 };
7777 
cb_mnuAltDockedscope(Fl_Menu_ * w,void * d)7778 void cb_mnuAltDockedscope(Fl_Menu_ *w, void *d) {
7779 	Fl_Menu_Item *m = getMenuItem(((Fl_Menu_*)w)->mvalue()->label(), alt_menu_);
7780 	progStatus.DOCKEDSCOPE = m->value();
7781 	wf->show_scope(progStatus.DOCKEDSCOPE);
7782 }
7783 
7784 
7785 #define defwidget 0, 0, 10, 10, ""
7786 
noop_controls()7787 void noop_controls() // create and then hide all controls not being used
7788 {
7789 	Fl_Double_Window *dummywindow = new Fl_Double_Window(0,0,100,100,"");
7790 
7791 	btnMacroTimer = new Fl_Button(defwidget); btnMacroTimer->hide();
7792 
7793 	ReceiveText = new FTextRX(0,0,100,100); ReceiveText->hide();
7794 	TransmitText = new FTextTX(0,0,100,100); TransmitText->hide();
7795 	FHdisp = new Raster(0,0,10,100); FHdisp->hide();
7796 
7797 	for (int i = 0; i < NUMMACKEYS * NUMKEYROWS; i++) {
7798 		btnMacro[i] = new Fl_Button(defwidget); btnMacro[i]->hide();
7799 	}
7800 	for (int i = 0; i < 48; i++) {
7801 		btnDockMacro[i] = new Fl_Button(defwidget); btnDockMacro[i]->hide();
7802 	}
7803 
7804 	inpQth = new Fl_Input2(defwidget); inpQth->hide();
7805 	inpLoc1 = new Fl_Input2(defwidget); inpLoc1->hide();
7806 	inpState1 = new Fl_Input2(defwidget); inpState1->hide();
7807 	cboCountryQSO = new Fl_ComboBox(defwidget); cboCountryQSO->end();
7808 	cboCountryQSO->hide();
7809 	cboCountyQSO = new Fl_ComboBox(defwidget); cboCountyQSO->hide();
7810 	cboCountyQSO->hide();
7811 	inpSerNo = new Fl_Input2(defwidget); inpSerNo->hide();
7812 	outSerNo = new Fl_Input2(defwidget); outSerNo->hide();
7813 	inpXchgIn = new Fl_Input2(defwidget); inpXchgIn->hide();
7814 	inpVEprov = new Fl_Input2(defwidget); inpVEprov->hide();
7815 	inpNotes = new Fl_Input2(defwidget); inpNotes->hide();
7816 	inpAZ = new Fl_Input2(defwidget); inpAZ->hide();
7817 
7818 	qsoTime = new Fl_Button(defwidget); qsoTime->hide();
7819 	btnQRZ = new Fl_Button(defwidget); btnQRZ->hide();
7820 	qsoClear = new Fl_Button(defwidget); qsoClear->hide();
7821 	qsoSave = new Fl_Button(defwidget); qsoSave->hide();
7822 
7823 	qsoFreqDisp = new cFreqControl(0,0,80,20,""); qsoFreqDisp->hide();
7824 	qso_opMODE = new Fl_ListBox(defwidget); qso_opMODE->hide();
7825 	qso_opBW = new Fl_ListBox(defwidget); qso_opBW->hide();
7826 	qso_opPICK = new Fl_Button(defwidget); qso_opPICK->hide();
7827 	qso_opGROUP = new Fl_Group(defwidget); qso_opGROUP->hide();
7828 
7829 	inpFreq = new Fl_Input2(defwidget); inpFreq->hide();
7830 	inpTimeOff = new Fl_Input2(defwidget); inpTimeOff->hide();
7831 	inpTimeOn = new Fl_Input2(defwidget); inpTimeOn->hide();
7832 	btnTimeOn = new Fl_Button(defwidget); btnTimeOn->hide();
7833 	inpCall = new Fl_Input2(defwidget); inpCall->hide();
7834 	inpName = new Fl_Input2(defwidget); inpName->hide();
7835 	inpRstIn = new Fl_Input2(defwidget); inpRstIn->hide();
7836 	inpRstOut = new Fl_Input2(defwidget); inpRstOut->hide();
7837 
7838 	inpFreq1 = new Fl_Input2(defwidget); inpFreq1->hide();
7839 	inpTimeOff1 = new Fl_Input2(defwidget); inpTimeOff1->hide();
7840 	inpTimeOn1 = new Fl_Input2(defwidget); inpTimeOn1->hide();
7841 	btnTimeOn1 = new Fl_Button(defwidget); btnTimeOn1->hide();
7842 	inpCall1 = new Fl_Input2(defwidget); inpCall1->hide();
7843 	inpName1 = new Fl_Input2(defwidget); inpName1->hide();
7844 	inpRstIn1 = new Fl_Input2(defwidget); inpRstIn1->hide();
7845 	inpRstOut1 = new Fl_Input2(defwidget); inpRstOut1->hide();
7846 	inpXchgIn1 = new Fl_Input2(defwidget); inpXchgIn1->hide();
7847 	outSerNo1 = new Fl_Input2(defwidget); outSerNo1->hide();
7848 	inpSerNo1 = new Fl_Input2(defwidget); inpSerNo1->hide();
7849 	qsoFreqDisp1 = new cFreqControl(0,0,80,20,""); qsoFreqDisp1->hide();
7850 
7851 	inp_FD_class1 = new Fl_Input2(defwidget); inp_FD_class1->hide();
7852 	inp_FD_class2 = new Fl_Input2(defwidget); inp_FD_class2->hide();
7853 	inp_FD_section1 = new Fl_Input2(defwidget); inp_FD_section1->hide();
7854 	inp_FD_section2 = new Fl_Input2(defwidget); inp_FD_section2->hide();
7855 
7856 	inp_KD_name2 = new Fl_Input2(defwidget); inp_KD_name2->hide();
7857 	inp_KD_age1 = new  Fl_Input2(defwidget); inp_KD_age1->hide();
7858 	inp_KD_age2 = new  Fl_Input2(defwidget); inp_KD_age2->hide();
7859 	inp_KD_state1 = new  Fl_Input2(defwidget); inp_KD_state1->hide();
7860 	inp_KD_state2 = new  Fl_Input2(defwidget); inp_KD_state2->hide();
7861 	inp_KD_VEprov1 = new Fl_Input2(defwidget); inp_KD_VEprov1->hide();
7862 	inp_KD_VEprov2 = new Fl_Input2(defwidget); inp_KD_VEprov2->hide();
7863 	inp_KD_XchgIn1 = new  Fl_Input2(defwidget); inp_KD_XchgIn1->hide();
7864 	inp_KD_XchgIn2 = new  Fl_Input2(defwidget); inp_KD_XchgIn2->hide();
7865 
7866 	inp_1010_XchgIn1 = new Fl_Input2(defwidget); inp_1010_XchgIn1->hide();
7867 	inp_1010_XchgIn2 = new Fl_Input2(defwidget); inp_1010_XchgIn2->hide();
7868 	inp_1010_nr1 = new Fl_Input2(defwidget); inp_1010_nr1->hide();
7869 	inp_1010_nr2 = new Fl_Input2(defwidget); inp_1010_nr2->hide();
7870 	inp_1010_name2 = new Fl_Input2(defwidget); inp_1010_name2->hide();
7871 
7872 	inp_ARR_Name2 = new Fl_Input2(defwidget); inp_ARR_Name2->hide();
7873 	inp_ARR_XchgIn1 = new Fl_Input2(defwidget); inp_ARR_XchgIn1->hide();
7874 	inp_ARR_XchgIn2 = new Fl_Input2(defwidget); inp_ARR_XchgIn2->hide();
7875 	inp_ARR_check1 = new Fl_Input2(defwidget); inp_ARR_check1->hide();
7876 	inp_ARR_check2 = new Fl_Input2(defwidget); inp_ARR_check2->hide();
7877 
7878 	inp_vhf_Loc1 = new Fl_Input2(defwidget); inp_vhf_Loc1->hide();
7879 	inp_vhf_Loc2 = new Fl_Input2(defwidget); inp_vhf_Loc2->hide();
7880 	inp_vhf_RSTin1 = new Fl_Input2(defwidget); inp_vhf_RSTin1->hide();
7881 	inp_vhf_RSTin2 = new Fl_Input2(defwidget); inp_vhf_RSTin2->hide();
7882 	inp_vhf_RSTout1 = new Fl_Input2(defwidget); inp_vhf_RSTout1->hide();
7883 	inp_vhf_RSTout2 = new Fl_Input2(defwidget); inp_vhf_RSTout2->hide();
7884 
7885 	inp_CQ_RSTin2 = new Fl_Input2(defwidget); inp_CQ_RSTin2->hide();
7886 	inp_CQ_RSTout2 = new Fl_Input2(defwidget); inp_CQ_RSTout2->hide();
7887 	inp_CQstate1 = new Fl_Input2(defwidget); inp_CQstate1->hide();
7888 	inp_CQstate2 = new Fl_Input2(defwidget); inp_CQstate2->hide();
7889 	inp_CQzone1 = new Fl_Input2(defwidget); inp_CQzone1->hide();
7890 	inp_CQzone2 = new Fl_Input2(defwidget); inp_CQzone2->hide();
7891 	cboCountryCQ2 = new Fl_ComboBox(defwidget); cboCountryCQ2->end();
7892 	cboCountryCQ2->hide();
7893 	inp_CQDX_RSTin2 = new Fl_Input2(defwidget); inp_CQDX_RSTin2->hide();
7894 	inp_CQDX_RSTout2 = new Fl_Input2(defwidget); inp_CQDX_RSTout2->hide();
7895 	cboCountryCQDX2 = new Fl_ComboBox(defwidget); cboCountryCQDX2->end();
7896 	cboCountryCQDX2->hide();
7897 	inp_CQDXzone1 = new Fl_Input2(defwidget); inp_CQDXzone1->hide();
7898 	inp_CQDXzone2 = new Fl_Input2(defwidget); inp_CQDXzone2->hide();
7899 
7900 	inpTimeOff2 = new Fl_Input2(defwidget); inpTimeOff2->hide();
7901 	inpTimeOn2 = new Fl_Input2(defwidget); inpTimeOn2->hide();
7902 	btnTimeOn2 = new Fl_Button(defwidget); btnTimeOn2->hide();
7903 	inpCall2 = new Fl_Input2(defwidget); inpCall2->hide();
7904 	inpName2 = new Fl_Input2(defwidget); inpName2->hide();
7905 	inpRstIn2 = new Fl_Input2(defwidget); inpRstIn2->hide();
7906 	inpRstOut2 = new Fl_Input2(defwidget); inpRstOut2->hide();
7907 	qsoFreqDisp2 = new cFreqControl(0,0,80,20,""); qsoFreqDisp2->hide();
7908 
7909 	qso_opPICK2 = new Fl_Button(defwidget); qso_opPICK2->hide();
7910 	qsoClear2 = new Fl_Button(defwidget); qsoClear2->hide();
7911 	qsoSave2 = new Fl_Button(defwidget); qsoSave2->hide();
7912 	btnQRZ2 = new Fl_Button(defwidget); btnQRZ2->hide();
7913 
7914 	inpTimeOff3 = new Fl_Input2(defwidget); inpTimeOff3->hide();
7915 	inpTimeOn3 = new Fl_Input2(defwidget); inpTimeOn3->hide();
7916 	btnTimeOn3 = new Fl_Button(defwidget); btnTimeOn3->hide();
7917 	inpCall3 = new Fl_Input2(defwidget); inpCall3->hide();
7918 	outSerNo2 = new Fl_Input2(defwidget); outSerNo2->hide();
7919 	inpSerNo2 = new Fl_Input2(defwidget); inpSerNo2->hide();
7920 	inpXchgIn2 = new Fl_Input2(defwidget); inpXchgIn2->hide();
7921 	qsoFreqDisp3 = new cFreqControl(0,0,80,20,""); qsoFreqDisp3->hide();
7922 
7923 	inpTimeOff4 = new Fl_Input2(defwidget); inpTimeOff4->hide();
7924 	inpTimeOn4 = new Fl_Input2(defwidget); inpTimeOn4->hide();
7925 	btnTimeOn4 = new Fl_Button(defwidget); btnTimeOn4->hide();
7926 	inpTimeOff5 = new Fl_Input2(defwidget); inpTimeOff5->hide();
7927 	inpTimeOn5 = new Fl_Input2(defwidget); inpTimeOn5->hide();
7928 	btnTimeOn5 = new Fl_Button(defwidget); btnTimeOn5->hide();
7929 
7930 	outSerNo3 = new Fl_Input2(defwidget); outSerNo3->hide();
7931 	inp_SS_SerialNoR1 = new Fl_Input2(defwidget); inp_SS_SerialNoR1->hide();
7932 	inp_SS_Precedence1 = new Fl_Input2(defwidget); inp_SS_Precedence1->hide();
7933 	inp_SS_Check1 = new Fl_Input2(defwidget); inp_SS_Check1->hide();
7934 	inp_SS_Section1 = new Fl_Input2(defwidget); inp_SS_Section1->hide();
7935 	outSerNo4 = new Fl_Input2(defwidget); outSerNo4->hide();
7936 	inp_SS_SerialNoR2 = new Fl_Input2(defwidget); inp_SS_SerialNoR2->hide();
7937 	inp_SS_Precedence2 = new Fl_Input2(defwidget); inp_SS_Precedence2->hide();
7938 	inp_SS_Check2 = new Fl_Input2(defwidget); inp_SS_Check2->hide();
7939 	inp_SS_Section2 = new Fl_Input2(defwidget); inp_SS_Section2->hide();
7940 
7941 	inp_ASCR_class1 = new Fl_Input2(defwidget); inp_ASCR_class1->hide();
7942 	inp_ASCR_XchgIn1 = new Fl_Input2(defwidget); inp_ASCR_XchgIn1->hide();
7943 	inp_ASCR_name2 = new Fl_Input2(defwidget); inp_ASCR_name2->hide();
7944 	inp_ASCR_class2 = new Fl_Input2(defwidget); inp_ASCR_class2->hide();
7945 	inp_ASCR_XchgIn2 = new Fl_Input2(defwidget); inp_ASCR_XchgIn2->hide();
7946 	inp_ASCR_RSTin2 = new Fl_Input2(defwidget); inp_ASCR_RSTin2->hide();
7947 	inp_ASCR_RSTout2 = new Fl_Input2(defwidget); inp_ASCR_RSTout2->hide();
7948 
7949 	inpNAQPname2 = new Fl_Input2(defwidget); inpNAQPname2->hide();
7950 	inpSPCnum_NAQP1 =  new Fl_Input2(defwidget); inpSPCnum_NAQP1->hide();
7951 	inpSPCnum_NAQP2 =  new Fl_Input2(defwidget); inpSPCnum_NAQP2->hide();
7952 
7953 	inpRTU_stpr1 = new Fl_Input2(defwidget); inpRTU_stpr1->hide();
7954 	inpRTU_serno1 = new Fl_Input2(defwidget); inpRTU_serno1->hide();
7955 	inpRTU_RSTin2 = new Fl_Input2(defwidget); inpRTU_RSTin2->hide();
7956 	inpRTU_RSTout2 = new Fl_Input2(defwidget); inpRTU_RSTout2->hide();
7957 	inpRTU_stpr2 = new Fl_Input2(defwidget); inpRTU_stpr2->hide();
7958 	inpRTU_serno2 = new Fl_Input2(defwidget); inpRTU_serno2->hide();
7959 	cboCountryRTU2 = new Fl_ComboBox(defwidget); cboCountryRTU2->end();
7960 	cboCountryRTU2->hide();
7961 
7962 	inp_IARI_PR1 = new Fl_Input2(defwidget); inp_IARI_PR1->hide();
7963 	inp_IARI_RSTin2 = new Fl_Input2(defwidget); inp_IARI_RSTin2->hide();
7964 	inp_IARI_RSTout2 = new Fl_Input2(defwidget); inp_IARI_RSTout2->hide();
7965 	out_IARI_SerNo1 = new Fl_Input2(defwidget); out_IARI_SerNo1->hide();
7966 	inp_IARI_SerNo1 = new Fl_Input2(defwidget); inp_IARI_SerNo1->hide();
7967 	out_IARI_SerNo2 = new Fl_Input2(defwidget); out_IARI_SerNo2->hide();
7968 	inp_IARI_SerNo2 = new Fl_Input2(defwidget); inp_IARI_SerNo2->hide();
7969 	inp_IARI_PR2 = new Fl_Input2(defwidget); inp_IARI_PR2->hide();
7970 	cboCountryIARI2 = new Fl_ComboBox(defwidget); cboCountryIARI2->end();
7971 	cboCountryIARI2->hide();
7972 
7973 	outSerNo5 = new Fl_Input2(defwidget); outSerNo4->hide();
7974 	inp_ser_NAS1 = new Fl_Input2(defwidget); inp_ser_NAS1->hide();
7975 	inpSPCnum_NAS1 = new Fl_Input2(defwidget); inpSPCnum_NAS1->hide();
7976 	outSerNo6 = new Fl_Input2(defwidget); outSerNo5->hide();
7977 	inp_ser_NAS2 = new Fl_Input2(defwidget); inp_ser_NAS2->hide();
7978 	inpSPCnum_NAS2 = new Fl_Input2(defwidget); inpSPCnum_NAS2->hide();
7979 	inp_name_NAS2 = new Fl_Input2(defwidget); inp_name_NAS2->hide();
7980 
7981 	outSerNo7 = new Fl_Input2(defwidget); outSerNo7->hide();
7982 	inpSerNo3 = new Fl_Input2(defwidget); inpSerNo3->hide();
7983 	cboCountryAIDX2 = new Fl_ComboBox(defwidget); cboCountryAIDX2->end();
7984 	cboCountryAIDX2->hide();
7985 
7986 	inpRstIn3 = new Fl_Input2(defwidget); inpRstIn3->hide();
7987 	inpRstOut3 = new Fl_Input2(defwidget); inpRstOut3->hide();
7988 	outSerNo8 = new Fl_Input2(defwidget); outSerNo8->hide();
7989 	inpSerNo4 = new Fl_Input2(defwidget); inpSerNo4->hide();
7990 
7991 	inp_JOTA_troop1 = new Fl_Input2(defwidget); inp_JOTA_troop1->hide();
7992 	inp_JOTA_troop2 = new Fl_Input2(defwidget); inp_JOTA_troop2->hide();
7993 	inp_JOTA_scout1 = new Fl_Input2(defwidget); inp_JOTA_scout1->hide();
7994 	inp_JOTA_scout2 = new Fl_Input2(defwidget); inp_JOTA_scout2->hide();
7995 	inp_JOTA_spc1 = new Fl_Input2(defwidget); inp_JOTA_spc1->hide();
7996 	inp_JOTA_spc2 = new Fl_Input2(defwidget); inp_JOTA_spc2->hide();
7997 
7998 	inpSPCnum_AICW1 = new Fl_Input2(defwidget); inpSPCnum_AICW1->hide();
7999 	inpSPCnum_AICW2 = new Fl_Input2(defwidget); inpSPCnum_AICW2->hide();
8000 	inpRstIn_AICW2 = new Fl_Input2(defwidget); inpRstIn_AICW2->hide();
8001 	inpRstOut_AICW2 = new Fl_Input2(defwidget); inpRstOut_AICW2->hide();
8002 
8003 	inpSQSO_state1 = new Fl_Input2(defwidget); inpSQSO_state1->hide();
8004 	inpSQSO_state2 = new Fl_Input2(defwidget); inpSQSO_state2->hide();
8005 	inpSQSO_county1 = new Fl_Input2(defwidget); inpSQSO_county1->hide();
8006 	inpSQSO_county2 = new Fl_Input2(defwidget); inpSQSO_county2->hide();
8007 	inpSQSO_serno1 = new Fl_Input2(defwidget); inpSQSO_serno1->hide();
8008 	inpSQSO_serno2 = new Fl_Input2(defwidget); inpSQSO_serno2->hide();
8009 	outSQSO_serno1 = new Fl_Input2(defwidget); outSQSO_serno1->hide();
8010 	outSQSO_serno2 = new Fl_Input2(defwidget); outSQSO_serno2->hide();
8011 	inpSQSO_name2 = new Fl_Input2(defwidget); inpSQSO_name2->hide();
8012 	inpRstIn_SQSO2 = new Fl_Input2(defwidget); inpRstIn_SQSO2->hide();
8013 	inpRstOut_SQSO2 = new Fl_Input2(defwidget); inpRstOut_SQSO2->hide();
8014 	inpSQSO_category1 = new Fl_Input2(defwidget); inpSQSO_category1->hide();
8015 	inpSQSO_category2 = new Fl_Input2(defwidget); inpSQSO_category2->hide();
8016 
8017 	inpSerNo_WPX1 = new Fl_Input2(defwidget); inpSerNo_WPX1->hide();
8018 	outSerNo_WPX1 = new Fl_Input2(defwidget); outSerNo_WPX1->hide();
8019 	inpSerNo_WPX2 = new Fl_Input2(defwidget); inpSerNo_WPX2->hide();
8020 	outSerNo_WPX2 = new Fl_Input2(defwidget); outSerNo_WPX2->hide();
8021 	inpRstIn_WPX2 = new Fl_Input2(defwidget); inpRstIn_WPX2->hide();
8022 	inpRstOut_WPX2 = new Fl_Input2(defwidget); inpRstOut_WPX2->hide();
8023 
8024 	inpSerNo_WAE1 = new Fl_Input2(defwidget); inpSerNo_WAE1->hide();
8025 	inpSerNo_WAE2 = new Fl_Input2(defwidget); inpSerNo_WAE2->hide();
8026 	outSerNo_WAE1 = new Fl_Input2(defwidget); outSerNo_WAE1->hide();
8027 	outSerNo_WAE2 = new Fl_Input2(defwidget); outSerNo_WAE2->hide();
8028 	inpRstIn_WAE2 = new Fl_Input2(defwidget); inpRstIn_WAE2->hide();
8029 	inpRstOut_WAE2 = new Fl_Input2(defwidget); inpRstOut_WAE2->hide();
8030 	cboCountryWAE2 = new Fl_ComboBox(defwidget); cboCountryWAE2->end();
8031 	cboCountryWAE2->hide();
8032 
8033 	qso_opPICK3 = new Fl_Button(defwidget); qso_opPICK3->hide();
8034 	qsoClear3 = new Fl_Button(defwidget); qsoClear3->hide();
8035 	qsoSave3 = new Fl_Button(defwidget); qsoSave3->hide();
8036 
8037 	inpCall4 = new Fl_Input2(defwidget); inpCall4->hide();
8038 
8039 	qso_opBrowser = new Fl_Browser(defwidget); qso_opBrowser->hide();
8040 	qso_btnAddFreq = new Fl_Button(defwidget); qso_btnAddFreq->hide();
8041 	qso_btnSelFreq = new Fl_Button(defwidget); qso_btnSelFreq->hide();
8042 	qso_btnDelFreq = new Fl_Button(defwidget); qso_btnDelFreq->hide();
8043 	qso_btnClearList = new Fl_Button(defwidget); qso_btnClearList->hide();
8044 	qso_btnAct = new Fl_Button(defwidget); qso_btnAct->hide();
8045 	qso_inpAct = new Fl_Input2(defwidget); qso_inpAct->hide();
8046 
8047 	pwrmeter = new PWRmeter(defwidget); pwrmeter->hide();
8048 	smeter = new Smeter(defwidget); smeter->hide();
8049 	pwr_level = new Fl_Value_Slider2(defwidget); pwr_level->hide();
8050 	set_pwr_level = new Fl_Button(defwidget); set_pwr_level->hide();
8051 
8052 	dummywindow->end();
8053 	dummywindow->hide();
8054 
8055 }
8056 
make_scopeviewer()8057 void make_scopeviewer()
8058 {
8059 	scopeview = new Fl_Double_Window(0,0,140,140, _("Scope"));
8060 	scopeview->xclass(PACKAGE_NAME);
8061 	digiscope = new Digiscope (0, 0, 140, 140);
8062 	scopeview->resizable(digiscope);
8063 	scopeview->size_range(SCOPEWIN_MIN_WIDTH, SCOPEWIN_MIN_HEIGHT);
8064 	scopeview->end();
8065 	scopeview->hide();
8066 }
8067 
8068 static int WF_only_height = 0;
8069 
create_fl_digi_main_WF_only()8070 void create_fl_digi_main_WF_only() {
8071 
8072 	int fnt = fl_font();
8073 	int fsize = fl_size();
8074 	int freqheight = Hentry + 2 * pad;
8075 	int Y = 0;
8076 	int W = progStatus.mainW;
8077 
8078 	fl_font(fnt, freqheight);
8079 	fl_font(fnt, fsize);
8080 
8081 
8082 	IMAGE_WIDTH = 4000;
8083 	Hwfall = progdefaults.wfheight;
8084 	Wwfall = W - 2 * DEFAULT_SW - 2 * pad;
8085 	WF_only_height = Hmenu + Hwfall + Hstatus + 4 * pad;
8086 
8087 	fl_digi_main = new Fl_Double_Window(W, WF_only_height);
8088 
8089 		mnuFrame = new Fl_Group(0, 0, W, Hmenu);
8090 
8091 			mnu = new Fl_Menu_Bar(0, 0, W - 275 - pad, Hmenu);
8092 // do some more work on the menu
8093 			for (size_t i = 0; i < sizeof(alt_menu_)/sizeof(alt_menu_[0]); i++) {
8094 // FL_NORMAL_SIZE may have changed; update the menu items
8095 				if (alt_menu_[i].text) {
8096 					alt_menu_[i].labelsize_ = FL_NORMAL_SIZE;
8097 				}
8098 // set the icon label for items with the multi label type
8099 				if (alt_menu_[i].labeltype() == _FL_MULTI_LABEL)
8100 					icons::set_icon_label(&alt_menu_[i]);
8101 			}
8102 			mnu->menu(alt_menu_);
8103 
8104 			tx_timer = new Fl_Box(W - 275 - pad, 0, 75 - pad, Hmenu, "");
8105 			tx_timer->box(FL_UP_BOX);
8106 			tx_timer->color(FL_BACKGROUND_COLOR);
8107 			tx_timer->labelcolor(FL_BACKGROUND_COLOR);
8108 
8109 			btnAutoSpot = new Fl_Light_Button(W - 200 - pad, 0, 50, Hmenu, "Spot");
8110 			btnAutoSpot->selection_color(progdefaults.SpotColor);
8111 			btnAutoSpot->callback(cbAutoSpot, 0);
8112 			btnAutoSpot->deactivate();
8113 
8114 			btnRSID = new Fl_Light_Button(W - 150 - pad, 0, 50, Hmenu, "RxID");
8115 			btnRSID->tooltip("Receive RSID");
8116 			btnRSID->value(progdefaults.rsid);
8117 			btnRSID->callback(cbRSID, 0);
8118 
8119 			btnTxRSID = new Fl_Light_Button(W - 100 - pad, 0, 50, Hmenu, "TxID");
8120 			btnTxRSID->selection_color(progdefaults.TxIDColor);
8121 			btnTxRSID->tooltip("Transmit RSID");
8122 			btnTxRSID->callback(cbTxRSID, 0);
8123 
8124 			btnTune = new Fl_Light_Button(W - 50 - pad, 0, 50, Hmenu, "TUNE");
8125 			btnTune->selection_color(progdefaults.TuneColor);
8126 			btnTune->callback(cbTune, 0);
8127 
8128 		mnuFrame->resizable(mnu);
8129 		mnuFrame->end();
8130 
8131 		Y = Hmenu + pad;
8132 
8133 		wf_group = new Fl_Group(0, Y, W, Hwfall);
8134 
8135 			wf = new waterfall(0, Y, Wwfall, Hwfall);
8136 			wf->end();
8137 
8138 			pgrsSquelch = new Progress(
8139 				rightof(wf), Y + pad,
8140 				DEFAULT_SW, Hwfall - 2 * pad,
8141 				"");
8142 			pgrsSquelch->color(FL_BACKGROUND2_COLOR, FL_DARK_GREEN);
8143 			pgrsSquelch->type(Progress::VERTICAL);
8144 			pgrsSquelch->tooltip(_("Detected signal level"));
8145 
8146 			sldrSquelch = new Fl_Slider2(
8147 				rightof(pgrsSquelch), Y + pad,
8148 				DEFAULT_SW, Hwfall - 2 * pad,
8149 				"");
8150 			sldrSquelch->minimum(100);
8151 			sldrSquelch->maximum(0);
8152 			sldrSquelch->step(1);
8153 			sldrSquelch->value(progStatus.sldrSquelchValue);
8154 			sldrSquelch->callback((Fl_Callback*)cb_sldrSquelch);
8155 			sldrSquelch->color(FL_INACTIVE_COLOR);
8156 			sldrSquelch->tooltip(_("Squelch level"));
8157 			Fl_Group::current()->resizable(wf);
8158 		wf_group->end();
8159 
8160 		Y += (Hwfall + pad);
8161 
8162 		status_group = new Fl_Group(0, Y, W, Hstatus);
8163 
8164 			MODEstatus = new Fl_Button(
8165 				0, Y,
8166 				Wmode, Hstatus, "");
8167 			MODEstatus->box(FL_DOWN_BOX);
8168 			MODEstatus->color(FL_BACKGROUND2_COLOR);
8169 			MODEstatus->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
8170 			MODEstatus->callback(status_cb, (void *)0);
8171 			MODEstatus->when(FL_WHEN_CHANGED);
8172 			MODEstatus->tooltip(_("Left click: change mode\nRight click: configure"));
8173 
8174 			cntCW_WPM = new Fl_Counter2(
8175 				rightof(MODEstatus), Y,
8176 				Ws2n - Hstatus, Hstatus, "");
8177 			cntCW_WPM->callback(cb_cntCW_WPM);
8178 			cntCW_WPM->minimum(progdefaults.CWlowerlimit);
8179 			cntCW_WPM->maximum(progdefaults.CWupperlimit);
8180 			cntCW_WPM->value(progdefaults.CWspeed);
8181 			cntCW_WPM->tooltip(_("CW transmit WPM"));
8182 			cntCW_WPM->type(1);
8183 			cntCW_WPM->step(1);
8184 			cntCW_WPM->hide();
8185 
8186 			btnCW_Default = new Fl_Button(
8187 				rightof(cntCW_WPM), Y,
8188 				Hstatus, Hstatus, "*");
8189 			btnCW_Default->callback(cb_btnCW_Default);
8190 			btnCW_Default->tooltip(_("Default WPM"));
8191 			btnCW_Default->hide();
8192 
8193 			Status1 = new Fl_Box(
8194 				rightof(MODEstatus), Y,
8195 				Ws2n, Hstatus, "");
8196 			Status1->box(FL_DOWN_BOX);
8197 			Status1->color(FL_BACKGROUND2_COLOR);
8198 			Status1->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
8199 
8200 			Status2 = new Fl_Box(
8201 				rightof(Status1), Y,
8202 				Wimd, Hstatus, "");
8203 			Status2->box(FL_DOWN_BOX);
8204 			Status2->color(FL_BACKGROUND2_COLOR);
8205 			Status2->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
8206 
8207 			StatusBar = new status_box(
8208 				rightof(Status2), Y,
8209 				W - rightof(Status2)
8210 				- bwAfcOnOff - bwSqlOnOff
8211 				- Wwarn - bwTxLevel
8212 				- bwSqlOnOff
8213 				- cbwidth,
8214 				Hstatus, "");
8215 			StatusBar->box(FL_DOWN_BOX);
8216 			StatusBar->color(FL_BACKGROUND2_COLOR);
8217 			StatusBar->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
8218 			StatusBar->callback((Fl_Callback *)StatusBar_cb);
8219 			StatusBar->when(FL_WHEN_RELEASE_ALWAYS);
8220 			StatusBar->tooltip(_("Left click to toggle VuMeter"));
8221 			StatusBar->show();
8222 
8223 			VuMeter = new vumeter(StatusBar->x(), StatusBar->y(), StatusBar->w(), StatusBar->h(), "" );
8224 			VuMeter->align(Fl_Align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE));
8225 			VuMeter->when(FL_WHEN_RELEASE_ALWAYS);
8226 			VuMeter->tooltip(_("Left click to toggle Status Bar"));
8227 			VuMeter->callback((Fl_Callback *)VuMeter_cb);
8228 
8229 			cntTxLevel = new Fl_Counter2(
8230 				rightof(StatusBar), Y,
8231 				bwTxLevel, Hstatus, "");
8232 			cntTxLevel->minimum(-30);
8233 			cntTxLevel->maximum(0);
8234 			cntTxLevel->value(-6);
8235 			cntTxLevel->callback((Fl_Callback*)cb_cntTxLevel);
8236 			cntTxLevel->value(progdefaults.txlevel);
8237 			cntTxLevel->lstep(1.0);
8238 			cntTxLevel->tooltip(_("Tx level attenuator (dB)"));
8239 
8240 			WARNstatus = new Fl_Box(
8241 				rightof(cntTxLevel), Y,
8242 				Wwarn, Hstatus, "");
8243 			WARNstatus->box(FL_DIAMOND_DOWN_BOX);
8244 			WARNstatus->color(FL_BACKGROUND_COLOR);
8245 			WARNstatus->labelcolor(FL_RED);
8246 			WARNstatus->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE);
8247 
8248 			btnAFC = new Fl_Light_Button(
8249 				rightof(WARNstatus), Y,
8250 				bwAfcOnOff, Hstatus, "AFC");
8251 			btnAFC->selection_color(progdefaults.AfcColor);
8252 
8253 			btnSQL = new Fl_Light_Button(
8254 				rightof(btnAFC), Y,
8255 				bwSqlOnOff, Hstatus, "SQL");
8256 
8257 // btnPSQL will be resized later depending on the state of the
8258 // configuration parameter to show that widget
8259 
8260 			btnPSQL = new Fl_Light_Button(
8261 				rightof(btnSQL), Y,
8262 				bwSqlOnOff, Hstatus, "PSM");
8263 
8264 			btnAFC->callback(cbAFC, 0);
8265 			btnAFC->value(1);
8266 			btnAFC->tooltip(_("Automatic Frequency Control"));
8267 
8268 			btnSQL->callback(cbSQL, 0);
8269 			btnSQL->selection_color(progdefaults.Sql1Color);
8270 			btnSQL->value(1);
8271 			btnSQL->tooltip(_("Squelch"));
8272 
8273 			btnPSQL->selection_color(progdefaults.Sql1Color);
8274 			btnPSQL->callback(cbPwrSQL, 0);
8275 			btnPSQL->value(progdefaults.kpsql_enabled);
8276 			btnPSQL->tooltip(_("Power Signal Monitor"));
8277 
8278 			Fl_Group::current()->resizable(VuMeter);
8279 
8280 		status_group->end();
8281 
8282 	Fl::add_handler(wo_default_handler);
8283 
8284 	fl_digi_main->end();
8285 	fl_digi_main->callback(cb_wMain);
8286 	fl_digi_main->resizable(wf);
8287 
8288 	const struct {
8289 		bool var; const char* label;
8290 	} toggles[] = {
8291 		{ progStatus.DOCKEDSCOPE, DOCKEDSCOPE_MLABEL }
8292 	};
8293 	Fl_Menu_Item* toggle;
8294 	for (size_t i = 0; i < sizeof(toggles)/sizeof(*toggles); i++) {
8295 		if (toggles[i].var && (toggle = getMenuItem(toggles[i].label, alt_menu_))) {
8296 			toggle->set();
8297 			if (toggle->callback()) {
8298 				mnu->value(toggle);
8299 				toggle->do_callback(reinterpret_cast<Fl_Widget*>(mnu));
8300 			}
8301 		}
8302 	}
8303 
8304 	make_scopeviewer();
8305 	noop_controls();
8306 
8307 	progdefaults.WF_UIwfcarrier =
8308 	progdefaults.WF_UIwfreflevel =
8309 	progdefaults.WF_UIwfampspan =
8310 	progdefaults.WF_UIwfmode =
8311 	progdefaults.WF_UIx1 =
8312 	progdefaults.WF_UIwfshift =
8313 	progdefaults.WF_UIrev =
8314 	progdefaults.WF_UIwfstore =
8315 	progdefaults.WF_UIxmtlock =
8316 	progdefaults.WF_UIwfdrop = true;
8317 	progdefaults.WF_UIqsy = false;
8318 	wf->UI_select(true);
8319 
8320 	load_counties();
8321 
8322 	createConfig();
8323 
8324 	createRecordLoader();
8325 
8326 	if (rx_only) {
8327 		btnTune->deactivate();
8328 		wf->xmtrcv->deactivate();
8329 	}
8330 
8331 	UI_select();
8332 
8333 }
8334 
8335 
create_fl_digi_main(int argc,char ** argv)8336 void create_fl_digi_main(int argc, char** argv)
8337 {
8338 	if (bWF_only)
8339 		create_fl_digi_main_WF_only();
8340 	else
8341 		create_fl_digi_main_primary();
8342 
8343 #if defined(__WOE32__)
8344 #  ifndef IDI_ICON
8345 #    define IDI_ICON 101
8346 #  endif
8347 	fl_digi_main->icon((char*)LoadIcon(fl_display, MAKEINTRESOURCE(IDI_ICON)));
8348 #elif !defined(__APPLE__) && USE_X
8349 	make_pixmap(&fldigi_icon_pixmap, fldigi_icon, argc, argv);
8350 	fl_digi_main->icon((char *)fldigi_icon_pixmap);
8351 #endif
8352 
8353 	fl_digi_main->xclass(PACKAGE_NAME);
8354 
8355 	if (bWF_only)
8356 		fl_digi_main->size_range(WMIN, WF_only_height, 0, WF_only_height);
8357 	else
8358 		fl_digi_main->size_range(WMIN, main_hmin, 0, 0);
8359 
8360 	set_colors();
8361 
8362 }
8363 
put_freq(double frequency)8364 void put_freq(double frequency)
8365 {
8366 	wf->carrier((int)floor(frequency + 0.5));
8367 }
8368 
put_Bandwidth(int bandwidth)8369 void put_Bandwidth(int bandwidth)
8370 {
8371 	wf->Bandwidth ((int)bandwidth);
8372 }
8373 
callback_set_metric(double metric)8374 void callback_set_metric(double metric)
8375 {
8376 	pgrsSquelch->value(metric);
8377 
8378 	if (active_modem->get_mode() == MODE_FSQ)
8379 		ind_fsq_s2n->value(metric);
8380 
8381 	if (active_modem->get_mode() == MODE_IFKP)
8382 		ifkp_s2n_progress->value(metric);
8383 
8384 	if (progdefaults.show_psm_btn && progStatus.kpsql_enabled) {
8385 		if ((metric >= progStatus.sldrPwrSquelchValue) || inhibit_tx_seconds)
8386 			btnPSQL->selection_color(progdefaults.Sql2Color);
8387 		else
8388 			btnPSQL->selection_color(progdefaults.Sql1Color);
8389 
8390 		btnPSQL->redraw_label();
8391 
8392 	} else if(progStatus.sqlonoff) {
8393 		if (metric < progStatus.sldrSquelchValue)
8394 			btnSQL->selection_color(progdefaults.Sql1Color);
8395 		else
8396 			btnSQL->selection_color(progdefaults.Sql2Color);
8397 		btnSQL->redraw_label();
8398 	}
8399 }
8400 
put_cwRcvWPM(double wpm)8401 void put_cwRcvWPM(double wpm)
8402 {
8403 	int U = progdefaults.CWupperlimit;
8404 	int L = progdefaults.CWlowerlimit;
8405 	double dWPM = 100.0*(wpm - L)/(U - L);
8406 	REQ_DROP(static_cast<void (Fl_Progress::*)(float)>(&Fl_Progress::value), prgsCWrcvWPM, dWPM);
8407 	REQ_DROP(static_cast<int (Fl_Value_Output::*)(double)>(&Fl_Value_Output::value), valCWrcvWPM, (int)wpm);
8408 }
8409 
set_scope_mode(Digiscope::scope_mode md)8410 void set_scope_mode(Digiscope::scope_mode md)
8411 {
8412 	if (digiscope) {
8413 		digiscope->mode(md);
8414 		REQ(&Fl_Window::size_range, scopeview, SCOPEWIN_MIN_WIDTH, SCOPEWIN_MIN_HEIGHT,
8415 			0, 0, 0, 0, (md == Digiscope::PHASE || md == Digiscope::XHAIRS));
8416 	}
8417 	wf->wfscope->mode(md);
8418 	if (md == Digiscope::SCOPE) set_scope_clear_axis();
8419 }
8420 
set_scope(double * data,int len,bool autoscale)8421 void set_scope(double *data, int len, bool autoscale)
8422 {
8423 	if (digiscope)
8424 		digiscope->data(data, len, autoscale);
8425 	wf->wfscope->data(data, len, autoscale);
8426 }
8427 
set_phase(double phase,double quality,bool highlight)8428 void set_phase(double phase, double quality, bool highlight)
8429 {
8430 	if (digiscope)
8431 		digiscope->phase(phase, quality, highlight);
8432 	wf->wfscope->phase(phase, quality, highlight);
8433 }
8434 
set_rtty(double flo,double fhi,double amp)8435 void set_rtty(double flo, double fhi, double amp)
8436 {
8437 	if (digiscope)
8438 		digiscope->rtty(flo, fhi, amp);
8439 	wf->wfscope->rtty(flo, fhi, amp);
8440 }
8441 
set_video(double * data,int len,bool dir)8442 void set_video(double *data, int len, bool dir)
8443 {
8444 	if (digiscope)
8445 		digiscope->video(data, len, dir);
8446 	wf->wfscope->video(data, len, dir);
8447 }
8448 
set_zdata(cmplx * zarray,int len)8449 void set_zdata(cmplx *zarray, int len)
8450 {
8451 	if (digiscope)
8452 		digiscope->zdata(zarray, len);
8453 	wf->wfscope->zdata(zarray, len);
8454 }
8455 
set_scope_xaxis_1(double y1)8456 void set_scope_xaxis_1(double y1)
8457 {
8458 	if (digiscope)
8459 		digiscope->xaxis_1(y1);
8460 	wf->wfscope->xaxis_1(y1);
8461 }
8462 
set_scope_xaxis_2(double y2)8463 void set_scope_xaxis_2(double y2)
8464 {
8465 	if (digiscope)
8466 		digiscope->xaxis_2(y2);
8467 	wf->wfscope->xaxis_2(y2);
8468 }
8469 
set_scope_yaxis_1(double x1)8470 void set_scope_yaxis_1(double x1)
8471 {
8472 	if (digiscope)
8473 		digiscope->yaxis_1(x1);
8474 	wf->wfscope->yaxis_1(x1);
8475 }
8476 
set_scope_yaxis_2(double x2)8477 void set_scope_yaxis_2(double x2)
8478 {
8479 	if (digiscope)
8480 		digiscope->yaxis_2(x2);
8481 	wf->wfscope->yaxis_2(x2);
8482 }
8483 
set_scope_clear_axis()8484 void set_scope_clear_axis()
8485 {
8486 	if (digiscope) {
8487 		digiscope->xaxis_1(0);
8488 		digiscope->xaxis_2(0);
8489 		digiscope->yaxis_1(0);
8490 		digiscope->yaxis_2(0);
8491 	}
8492 	wf->wfscope->xaxis_1(0);
8493 	wf->wfscope->xaxis_2(0);
8494 	wf->wfscope->yaxis_1(0);
8495 	wf->wfscope->yaxis_2(0);
8496 }
8497 
8498 // raw buffer functions can ONLY be called by FLMAIN_TID
8499 
8500 //======================================================================
8501 #define RAW_BUFF_LEN 4096
8502 
8503 static char rxtx_raw_chars[RAW_BUFF_LEN+1] = "";
8504 static char rxtx_raw_buff[RAW_BUFF_LEN+1] = "";
8505 static int  rxtx_raw_len = 0;
8506 
get_rxtx_data()8507 char *get_rxtx_data()
8508 {
8509 	ENSURE_THREAD(FLMAIN_TID);
8510 	memset(rxtx_raw_chars, 0, RAW_BUFF_LEN+1);
8511 	strcpy(rxtx_raw_chars, rxtx_raw_buff);
8512 	memset(rxtx_raw_buff, 0, RAW_BUFF_LEN+1);
8513 	rxtx_raw_len = 0;
8514 	return rxtx_raw_chars;
8515 }
8516 
add_rxtx_char(int data)8517 void add_rxtx_char(int data)
8518 {
8519 	ENSURE_THREAD(FLMAIN_TID);
8520 	if (rxtx_raw_len == RAW_BUFF_LEN) {
8521 		memset(rxtx_raw_buff, 0, RAW_BUFF_LEN+1);
8522 		rxtx_raw_len = 0;
8523 	}
8524 	rxtx_raw_buff[rxtx_raw_len++] = (unsigned char)data;
8525 }
8526 
8527 //======================================================================
8528 static char rx_raw_chars[RAW_BUFF_LEN+1] = "";
8529 static char rx_raw_buff[RAW_BUFF_LEN+1] = "";
8530 static int  rx_raw_len = 0;
8531 
8532 static pthread_mutex_t rx_data_mutex = PTHREAD_MUTEX_INITIALIZER;
8533 
get_rx_data()8534 char *get_rx_data()
8535 {
8536 //	ENSURE_THREAD(FLMAIN_TID);
8537 
8538 	guard_lock datalock(&rx_data_mutex);
8539 	memset(rx_raw_chars, 0, RAW_BUFF_LEN+1);
8540 	strcpy(rx_raw_chars, rx_raw_buff);
8541 	memset(rx_raw_buff, 0, RAW_BUFF_LEN+1);
8542 	rx_raw_len = 0;
8543 	return rx_raw_chars;
8544 }
8545 
add_rx_char(int data)8546 void add_rx_char(int data)
8547 {
8548 //	ENSURE_THREAD(FLMAIN_TID);
8549 
8550 	guard_lock datalock(&rx_data_mutex);
8551 	add_rxtx_char(data);
8552 	if (rx_raw_len == RAW_BUFF_LEN) {
8553 		memset(rx_raw_buff, 0, RAW_BUFF_LEN+1);
8554 		rx_raw_len = 0;
8555 	}
8556 	rx_raw_buff[rx_raw_len++] = (unsigned char)data;
8557 }
8558 
8559 //======================================================================
8560 static char tx_raw_chars[RAW_BUFF_LEN+1] = "";
8561 static char tx_raw_buff[RAW_BUFF_LEN+1] = "";
8562 static int  tx_raw_len = 0;
8563 
get_tx_data()8564 char *get_tx_data()
8565 {
8566 	ENSURE_THREAD(FLMAIN_TID);
8567 	memset(tx_raw_chars, 0, RAW_BUFF_LEN+1);
8568 	strcpy(tx_raw_chars, tx_raw_buff);
8569 	memset(tx_raw_buff, 0, RAW_BUFF_LEN+1);
8570 	tx_raw_len = 0;
8571 	return tx_raw_chars;
8572 }
8573 
add_tx_char(int data)8574 void add_tx_char(int data)
8575 {
8576 	ENSURE_THREAD(FLMAIN_TID);
8577 	add_rxtx_char(data);
8578 	if (tx_raw_len == RAW_BUFF_LEN) {
8579 		memset(tx_raw_buff, 0, RAW_BUFF_LEN+1);
8580 		tx_raw_len = 0;
8581 	}
8582 	tx_raw_buff[tx_raw_len++] = (unsigned char)data;
8583 }
8584 
8585 //======================================================================
TTY_bell()8586 static void TTY_bell()
8587 {
8588 	if (progdefaults.audibleBELL)
8589 		audio_alert->alert(progdefaults.BELL_RING);
8590 }
8591 
display_rx_data(const unsigned char data,int style)8592 static void display_rx_data(const unsigned char data, int style)
8593 {
8594 	if (data != '\r') {
8595 		if (active_modem->get_mode() == MODE_FSQ)
8596 			fsq_rx_text->add(data,style);
8597 		else if (active_modem->get_mode() == MODE_IFKP)
8598 			ifkp_rx_text->add(data,style);
8599 		else
8600 			ReceiveText->add(data, style);
8601 	}
8602 
8603 	if (bWF_only) return;
8604 
8605 	speak(data);
8606 
8607 	if (Maillogfile)
8608 		Maillogfile->log_to_file(cLogfile::LOG_RX, string(1, (const char)data));
8609 
8610 	if (progStatus.LOGenabled)
8611 		logfile->log_to_file(cLogfile::LOG_RX, string(1, (const char)data));
8612 }
8613 
rx_parser(const unsigned char data,int style)8614 static void rx_parser(const unsigned char data, int style)
8615 {
8616 	// assign a style to the incoming data
8617 	if (extract_wrap || extract_flamp)
8618 		style = FTextBase::RECV;
8619 	if ((data < ' ') && iscntrl(data))
8620 		style = FTextBase::CTRL;
8621 	if (wf->tmp_carrier())
8622 		style = FTextBase::ALTR;
8623 
8624 	// Collapse the "\r\n" sequence into "\n".
8625 	//
8626 	// The 'data' variable possibly contains only a part of a multi-byte
8627 	// UTF-8 character. This is not a problem. All data has passed
8628 	// through a distiller before we got here, so we can be sure that
8629 	// the input is valid UTF-8. All bytes of a multi-byte character
8630 	// will therefore have the eight bit set and can not match either
8631 	// '\r' or '\n'.
8632 
8633 	static unsigned int lastdata = 0;
8634 	if (data == '\n' && lastdata == '\r');
8635 	else if (data == '\r') {
8636 		display_rx_data('\n', style);
8637 	} else {
8638 		display_rx_data(data, style);
8639 	}
8640 	lastdata = data;
8641 
8642 	if (!(data < ' ' && iscntrl(data)) && progStatus.spot_recv)
8643 		spot_recv(data);
8644 }
8645 
put_rx_char_flmain(unsigned int data,int style)8646 static void put_rx_char_flmain(unsigned int data, int style)
8647 {
8648 	ENSURE_THREAD(FLMAIN_TID);
8649 
8650 	// possible destinations for the data
8651 	enum dest_type {
8652 		DEST_RECV,	// ordinary received text
8653 		DEST_ALTR	// alternate received text
8654 	};
8655 	static enum dest_type destination = DEST_RECV;
8656 	static enum dest_type prev_destination = DEST_RECV;
8657 
8658 	// Determine the destination of the incoming data. If the destination had
8659 	// changed, clear the contents of the distiller.
8660 	destination = (wf->tmp_carrier() ? DEST_ALTR : DEST_RECV);
8661 
8662 	if (destination != prev_destination) {
8663 		rx_chd.reset();
8664 		rx_chd.clear();
8665 	}
8666 
8667 	// select a byte translation table
8668 	trx_mode mode = active_modem->get_mode();
8669 
8670 	add_rx_char(data & 0xFF);
8671 
8672 	if (mailclient || mailserver)
8673 		rx_chd.rx((unsigned char *)ascii2[data & 0xFF]);
8674 
8675 	else if (progdefaults.show_all_codes && iscntrl(data & 0xFF))
8676 		rx_chd.rx((unsigned char *)ascii3[data & 0xFF]);
8677 
8678 	else if (mode == MODE_RTTY)
8679 		if (data == '\a') {
8680 			if (progdefaults.visibleBELL)
8681 				rx_chd.rx((unsigned char *)ascii2[7]);
8682 			REQ(TTY_bell);
8683 		} else
8684 			rx_chd.rx((unsigned char *)ascii[data & 0xFF]);
8685 	else
8686 		rx_chd.rx(data & 0xFF);
8687 
8688 	// feed the decoded data into the RX parser
8689 	if (rx_chd.data_length() > 0) {
8690 		const char *ptr = rx_chd.data().data();
8691 		const char *end = ptr + rx_chd.data_length();
8692 		while (ptr < end)
8693 			rx_parser((const unsigned char)*ptr++, style);
8694 		rx_chd.clear();
8695 	}
8696 }
8697 
8698 static std::string rx_process_buf = "";
8699 static std::string tx_process_buf = "";
8700 static pthread_mutex_t rx_proc_mutex = PTHREAD_MUTEX_INITIALIZER;
8701 
put_rx_processed_char(unsigned int data,int style)8702 void put_rx_processed_char(unsigned int data, int style)
8703 {
8704 	guard_lock rx_proc_lock(&rx_proc_mutex);
8705 
8706 	if(style == FTextBase::XMIT) {
8707 		tx_process_buf += (char) (data & 0xff);
8708 	} else if(style == FTextBase::RECV) {
8709 		rx_process_buf += (char) (data & 0xff);
8710 	}
8711 }
8712 
disp_rx_processed_char(void)8713 void disp_rx_processed_char(void)
8714 {
8715 	guard_lock rx_proc_lock(&rx_proc_mutex);
8716 	unsigned int index = 0;
8717 
8718 	if(!rx_process_buf.empty()) {
8719 		unsigned int count = rx_process_buf.size();
8720 		for(index = 0; index < count; index++)
8721 			REQ(put_rx_char_flmain, rx_process_buf[index], FTextBase::RECV);
8722 		rx_process_buf.clear();
8723 	}
8724 
8725 	if(!tx_process_buf.empty()) {
8726 		unsigned int count = tx_process_buf.size();
8727 		for(index = 0; index < count; index++)
8728 			REQ(put_rx_char_flmain, tx_process_buf[index], FTextBase::XMIT);
8729 		tx_process_buf.clear();
8730 	}
8731 }
8732 
put_rx_char(unsigned int data,int style)8733 void put_rx_char(unsigned int data, int style)
8734 {
8735 #if BENCHMARK_MODE
8736 	if (!benchmark.output.empty()) {
8737 		if (unlikely(benchmark.buffer.length() + 16 > benchmark.buffer.capacity()))
8738 			benchmark.buffer.reserve(benchmark.buffer.capacity() + BUFSIZ);
8739 		benchmark.buffer += (char)data;
8740 	}
8741 #else
8742 	if (progdefaults.autoextract == true)
8743 		rx_extract_add(data);
8744 
8745 	if (active_modem->get_mode() == MODE_FSQ) {
8746 		REQ(put_rx_char_flmain, data, style);
8747 		return;
8748 	}
8749 
8750 	switch(data_io_enabled) {
8751 		case ARQ_IO:
8752 			WriteARQ(data);
8753 			break;
8754 		case KISS_IO:
8755 			WriteKISS(data);
8756 			break;
8757 	}
8758 
8759 	if(progdefaults.ax25_decode_enabled && data_io_enabled == KISS_IO)
8760 		disp_rx_processed_char();
8761 	else
8762 		REQ(put_rx_char_flmain, data, style);
8763 #endif
8764 }
8765 
8766 static string strSecText = "";
8767 
put_sec_char_flmain(char chr)8768 static void put_sec_char_flmain(char chr)
8769 {
8770 	ENSURE_THREAD(FLMAIN_TID);
8771 
8772 	fl_font(FL_HELVETICA, FL_NORMAL_SIZE);
8773 	char s[2] = "W";
8774 	int lc = (int)ceil(fl_width(s));
8775 	int w = StatusBar->w();
8776 	int lw = (int)ceil(fl_width(StatusBar->label()));
8777 	int over = 2 * lc + lw - w;
8778 
8779 	if (chr >= ' ' && chr <= 'z') {
8780 		if ( over > 0 )
8781 			strSecText.erase(0, (int)(1.0 * over / lc + 0.5));
8782 		strSecText.append(1, chr);
8783 		StatusBar->label(strSecText.c_str());
8784 		WARNstatus->damage();
8785 	}
8786 }
8787 
put_sec_char(char chr)8788 void put_sec_char(char chr)
8789 {
8790 	REQ(put_sec_char_flmain, chr);
8791 }
8792 
clear_status_cb(void * arg)8793 static void clear_status_cb(void* arg)
8794 {
8795 	reinterpret_cast<Fl_Box*>(arg)->label("");
8796 }
dim_status_cb(void * arg)8797 static void dim_status_cb(void* arg)
8798 {
8799 	reinterpret_cast<Fl_Box*>(arg)->deactivate();
8800 }
8801 
8802 static void (*const timeout_action[STATUS_NUM])(void*) = { clear_status_cb, dim_status_cb };
8803 
8804 struct PSM_STRUCT {
8805 	Fl_Widget *w;
8806 	double timeout;
8807 	status_timeout action;
8808 	std::string msg;
8809 };
8810 
put_status_msg(void * d)8811 void put_status_msg(void *d)
8812 {
8813 	PSM_STRUCT *psm = (PSM_STRUCT *)d;
8814 
8815 	psm->w->activate();
8816 	psm->w->label(psm->msg.c_str());
8817 	if (psm->timeout > 0.0) {
8818 		Fl::remove_timeout(timeout_action[psm->action], psm->w);
8819 		Fl::add_timeout(psm->timeout, timeout_action[psm->action], psm->w);
8820 	}
8821 }
8822 
put_status(const char * msg,double timeout,status_timeout action)8823 void put_status(const char *msg, double timeout, status_timeout action)
8824 {
8825 	static PSM_STRUCT ps;
8826 	ps.msg.clear();
8827 	ps.msg.assign(msg);
8828 	ps.timeout = timeout;
8829 	ps.action = action;
8830 	ps.w = StatusBar;
8831 	Fl::awake(put_status_msg, (void *)&ps);
8832 }
8833 
put_Status2(const char * msg,double timeout,status_timeout action)8834 void put_Status2(const char *msg, double timeout, status_timeout action)
8835 {
8836 	static PSM_STRUCT ps;
8837 	ps.msg.clear();
8838 	ps.msg.assign(msg);
8839 	ps.timeout = timeout;
8840 	ps.action = action;
8841 	ps.w = Status2;
8842 
8843 	info2msg = msg;
8844 
8845 	Fl::awake(put_status_msg, (void *)&ps);
8846 }
8847 
put_Status1(const char * msg,double timeout,status_timeout action)8848 void put_Status1(const char *msg, double timeout, status_timeout action)
8849 {
8850 	static PSM_STRUCT ps;
8851 	ps.msg.clear();
8852 	ps.msg.assign(msg);
8853 	ps.timeout = timeout;
8854 	ps.action = action;
8855 	ps.w = Status1;
8856 
8857 	info1msg = msg;
8858 
8859 	if (!active_modem) return;
8860 	if (progStatus.NO_RIGLOG && active_modem->get_mode() != MODE_FSQ) return;
8861 
8862 	Fl::awake(put_status_msg, (void *)&ps);
8863 
8864 }
8865 
put_WARNstatus(double v)8866 void put_WARNstatus(double v)
8867 {
8868 	sig_vumeter->value(v);
8869 	sig_vumeter2->value(v);
8870 	VuMeter->value(v);
8871 
8872 	double val = 20 * log10(v == 0 ? 1e-9 : v);
8873 	if (val < progdefaults.normal_signal_level)
8874 		WARNstatus->color(progdefaults.LowSignal);
8875 	else if (val < progdefaults.high_signal_level )
8876 		WARNstatus->color(progdefaults.NormSignal);
8877 	else if (val < progdefaults.over_signal_level)
8878 		WARNstatus->color(progdefaults.HighSignal);
8879 	else WARNstatus->color(progdefaults.OverSignal);
8880 	WARNstatus->redraw();
8881 }
8882 
8883 
set_CWwpm()8884 void set_CWwpm()
8885 {
8886 	if (sldrCWxmtWPM)
8887 		sldrCWxmtWPM->value(progdefaults.CWspeed);
8888 	if (cntCW_WPM)
8889 		cntCW_WPM->value(progdefaults.CWspeed);
8890 	if (use_nanoIO) set_nanoWPM(progdefaults.CWspeed);
8891 }
8892 
clear_StatusMessages()8893 void clear_StatusMessages()
8894 {
8895 	StatusBar->label("");
8896 	Status1->label("");
8897 	Status2->label("");
8898 	info1msg = "";
8899 	info2msg = "";
8900 }
8901 
put_MODEstatus(const char * fmt,...)8902 void put_MODEstatus(const char* fmt, ...)
8903 {
8904 	static char s[32];
8905 	va_list args;
8906 	va_start(args, fmt);
8907 	vsnprintf(s, sizeof(s), fmt, args);
8908 	va_end(args);
8909 
8910 	REQ(static_cast<void (Fl_Button::*)(const char *)>(&Fl_Button::label), MODEstatus, s);
8911 	REQ(static_cast<void (Fl_Button::*)()>(&Fl_Button::redraw_label), MODEstatus);
8912 }
8913 
put_MODEstatus(trx_mode mode)8914 void put_MODEstatus(trx_mode mode)
8915 {
8916 	put_MODEstatus("%s", mode_info[mode].sname);
8917 }
8918 
8919 
put_rx_data(int * data,int len)8920 void put_rx_data(int *data, int len)
8921 {
8922  	FHdisp->data(data, len);
8923 }
8924 
8925 bool idling = false;
8926 
get_tx_char_idle(void *)8927 void get_tx_char_idle(void *)
8928 {
8929 	idling = false;
8930 	progStatus.repeatIdleTime = 0;
8931 }
8932 
8933 int Qwait_time = 0;
8934 int Qidle_time = 0;
8935 
8936 static int que_timeout = 0;
8937 bool que_ok = true;
8938 bool tx_queue_done = true;
8939 bool que_waiting = true;
8940 
post_queue_execute(void *)8941 void post_queue_execute(void*)
8942 {
8943 	if (!que_timeout) {
8944 		LOG_ERROR("%s", "timed out");
8945 		return;
8946 	}
8947 	while (!que_ok && trx_state != STATE_RX) {
8948 		que_timeout--;
8949 		Fl::repeat_timeout(0.05, post_queue_execute);
8950 		Fl::awake();
8951 	}
8952 	trx_transmit();
8953 }
8954 
queue_execute_after_rx(void *)8955 void queue_execute_after_rx(void*)
8956 {
8957 	que_waiting = false;
8958 	if (!que_timeout) {
8959 		LOG_ERROR("%s", "timed out");
8960 		return;
8961 	}
8962 	while (trx_state == STATE_TX) {
8963 		que_timeout--;
8964 		Fl::repeat_timeout(0.05, queue_execute_after_rx);
8965 		Fl::awake();
8966 		return;
8967 	}
8968 	que_timeout = 100; // 5 seconds
8969 	Fl::add_timeout(0.05, post_queue_execute);
8970 	que_ok = false;
8971 	tx_queue_done = false;
8972 	Tx_queue_execute();
8973 }
8974 
do_que_execute(void *)8975 void do_que_execute(void *)
8976 {
8977 	tx_queue_done = false;
8978 	que_ok = false;
8979 	Tx_queue_execute();
8980 	que_waiting = false;
8981 }
8982 
8983 char szTestChar[] = "E|I|S|T|M|O|A|V";
8984 
8985 //string bools = "------";
8986 //char testbools[7];
8987 
8988 extern int get_fsq_tx_char();
8989 bool disable_lowercase = false;
8990 
get_tx_char(void)8991 int get_tx_char(void)
8992 {
8993 	enum { STATE_CHAR, STATE_CTRL };
8994 	static int state = STATE_CHAR;
8995 
8996 	if (idling || csma_idling ) { return GET_TX_CHAR_NODATA; } // Keep this a the top of the list (CSMA TX delay).
8997 
8998 	if (active_modem->get_mode() == MODE_FSQ) return get_fsq_tx_char();
8999 
9000 	if (!que_ok) { return GET_TX_CHAR_NODATA; }
9001 	if (Qwait_time) { return GET_TX_CHAR_NODATA; }
9002 	if (Qidle_time) { return GET_TX_CHAR_NODATA; }
9003 	if (macro_idle_on) { return GET_TX_CHAR_NODATA; }
9004 
9005 	if ((progStatus.repeatMacro > -1) && text2repeat.length()) {
9006 		string repeat_content;
9007 		int utf8size = fl_utf8len1(text2repeat[repeatchar]);
9008 		for (int i = 0; i < utf8size; i++)
9009 			repeat_content += text2repeat[repeatchar + i];
9010 		repeatchar += utf8size;
9011 		tx_encoder.push(repeat_content);
9012 
9013 		if (repeatchar >= text2repeat.length()) {
9014 			text2repeat.clear();
9015 			macros.repeat(progStatus.repeatMacro);
9016 		}
9017 		goto transmit;
9018 	}
9019 
9020 	int c;
9021 
9022 	if (!macrochar.empty()) {
9023 		c = macrochar[0];
9024 		macrochar.erase(0,1);
9025 		start_deadman();
9026 		return c;
9027 	}
9028 
9029 	if (data_io_enabled == ARQ_IO && arq_text_available) {
9030 		start_deadman();
9031 		c = arq_get_char();
9032 		return c;
9033 	} else if (data_io_enabled == KISS_IO && kiss_text_available) {
9034 		start_deadman();
9035 		c = kiss_get_char();
9036 		return c;
9037 	}
9038 
9039 	if (active_modem == cw_modem && progdefaults.QSKadjust) {
9040 		start_deadman();
9041 		c = szTestChar[2 * progdefaults.TestChar];
9042 		return c;
9043 	}
9044 
9045 	if ( (progStatus.repeatMacro > -1) && progStatus.repeatIdleTime > 0 &&
9046 		 !idling ) {
9047 		Fl::add_timeout(progStatus.repeatIdleTime, get_tx_char_idle);
9048 		idling = true;
9049 		return GET_TX_CHAR_NODATA;
9050 	}
9051 
9052 	if ((c = tx_encoder.pop()) != -1) {
9053 		start_deadman();
9054 		return(c);
9055 	}
9056 
9057 	disable_lowercase = false;
9058 	if (xmltest_char_available) {
9059 		num_cps_chars++;
9060 		start_deadman();
9061 		c = xmltest_char();
9062 		disable_lowercase = true;
9063 	}
9064 	else if (active_modem->get_mode() == MODE_IFKP) {
9065 		c = ifkp_tx_text->nextChar();
9066 	}
9067 	else if ((c = next_buffered_macro_char()) == 0) { // preference given to buffered macro chars
9068 		c = TransmitText->nextChar();
9069 	}
9070 
9071 	if (c == GET_TX_CHAR_ETX) {
9072 		active_modem->set_CW_EOT();
9073 		return c;
9074 	}
9075 
9076 	if (c == '^' && state == STATE_CHAR) {
9077 		state = STATE_CTRL;
9078 		if (active_modem->get_mode() == MODE_IFKP)
9079 			c = ifkp_tx_text->nextChar();
9080 		else
9081 			if ((c = next_buffered_macro_char()) == 0) // preference given to buffered macro chars
9082 				c = TransmitText->nextChar();
9083 	}
9084 
9085 	if (c == -1) {
9086 		return(GET_TX_CHAR_NODATA);
9087 	}
9088 
9089 	if (state == STATE_CTRL) {
9090 		state = STATE_CHAR;
9091 
9092 		switch (c) {
9093 		case 'a': case 'A':
9094 			if (active_modem->get_mode() == MODE_IFKP)
9095 				active_modem->m_ifkp_send_avatar();
9096 			else if (active_modem->get_mode() >= MODE_THOR_FIRST &&
9097 					 active_modem->get_mode() <= MODE_THOR_LAST)
9098 				active_modem->m_thor_send_avatar();
9099 			return(GET_TX_CHAR_NODATA);
9100 
9101 		case 'i': case 'I':
9102 			{
9103 				string fname;
9104 				if (active_modem->get_mode() == MODE_IFKP)
9105 					c = ifkp_tx_text->nextChar();
9106 				else
9107 					if ((c = next_buffered_macro_char()) == 0) // preference given to buffered macro chars
9108 						c = TransmitText->nextChar();
9109 				if (c == '[') {
9110 					if (active_modem->get_mode() == MODE_IFKP)
9111 						c = ifkp_tx_text->nextChar();
9112 					else
9113 						if ((c = next_buffered_macro_char()) == 0) // preference given to buffered macro chars
9114 							c = TransmitText->nextChar();
9115 					while (c != ']' && c != -1) {
9116 						fname += c;
9117 						if (active_modem->get_mode() == MODE_IFKP)
9118 							c = ifkp_tx_text->nextChar();
9119 						else
9120 							if ((c = next_buffered_macro_char()) == 0) // preference given to buffered macro chars
9121 								c = TransmitText->nextChar();
9122 					}
9123 					if (c == -1) return (GET_TX_CHAR_NODATA);
9124 					if (active_modem->get_mode() == MODE_IFKP) {
9125 						ifkp_load_scaled_image(fname);
9126 						return (GET_TX_CHAR_NODATA);
9127 					}
9128 					if (active_modem->get_mode() >= MODE_THOR_FIRST &&
9129 					 active_modem->get_mode() <= MODE_THOR_LAST) {
9130 						thor_load_scaled_image(fname);
9131 						return (GET_TX_CHAR_NODATA);
9132 					}
9133 					active_modem->send_color_image(fname);
9134 				}
9135 			}
9136 			return(GET_TX_CHAR_NODATA);
9137 
9138 		case 'p': case 'P':
9139 			TransmitText->pause();
9140 			break;
9141 		case 'r':
9142 			local_timed_exec = false;
9143 			active_modem->set_CW_EOT();
9144 			if (active_modem->get_mode() == MODE_IFKP)
9145 				REQ(&FTextTX::clear, ifkp_tx_text);
9146 			else
9147 				REQ(&FTextTX::clear, TransmitText);
9148 			REQ(Rx_queue_execute);
9149 			return(GET_TX_CHAR_ETX);
9150 			break;
9151 		case 'R':
9152 			local_timed_exec = false;
9153 			active_modem->set_CW_EOT();
9154 			if (active_modem->get_mode() == MODE_IFKP) {
9155 				if (ifkp_tx_text->eot()) {
9156 					REQ(&FTextTX::clear, ifkp_tx_text);
9157 					REQ(Rx_queue_execute);
9158 					return(GET_TX_CHAR_ETX);
9159 				} else
9160 					return(GET_TX_CHAR_NODATA);
9161 			} else {
9162 				REQ(&FTextTX::clear, TransmitText);
9163 				REQ(Rx_queue_execute);
9164 				return(GET_TX_CHAR_ETX);
9165 			}
9166 			break;
9167 		case 'L':
9168 			REQ(qso_save_now);
9169 			return(GET_TX_CHAR_NODATA);
9170 			break;
9171 		case 'C':
9172 			REQ(clearQSO);
9173 			return(GET_TX_CHAR_NODATA);
9174 			break;
9175 		case '!':
9176 			if (queue_must_rx()) {
9177 				que_timeout = 400; // 20 seconds
9178 				REQ(queue_execute_after_rx, (void *)0);
9179 				while(que_waiting) { MilliSleep(10); Fl::awake(); }
9180 				return(GET_TX_CHAR_ETX);
9181 			} else {
9182 				if (active_modem->get_stopflag()) {
9183 					return (GET_TX_CHAR_NODATA);
9184 				}
9185 				REQ(do_que_execute, (void*)0);
9186 				MilliSleep(10);
9187 				while (do_tune_on) return (GET_TX_CHAR_NODATA);
9188 				while (que_waiting) { MilliSleep(10); Fl::awake(); }
9189 				return (GET_TX_CHAR_NODATA);
9190 			}
9191 			break;
9192 		default:
9193 			char utf8_char[6];
9194 			int utf8_len = fl_utf8encode(c, utf8_char);
9195 			tx_encoder.push("^" + string(utf8_char, utf8_len));
9196 		}
9197 	}
9198 	else if (c == '\n') {
9199 		tx_encoder.push("\r\n");
9200 	}
9201 	else {
9202 		char utf8_char[6];
9203 		int utf8_len = fl_utf8encode(c, utf8_char);
9204 		tx_encoder.push(string(utf8_char, utf8_len));
9205 	}
9206 
9207 	transmit:
9208 
9209 	c = tx_encoder.pop();
9210 	if (c == -1) {
9211 		LOG_ERROR("TX encoding conversion error: pushed content, but got nothing back");
9212 		return(GET_TX_CHAR_NODATA);
9213 	}
9214 
9215 	if (progdefaults.tx_lowercase && !disable_lowercase)
9216 		c = fl_tolower(c);
9217 
9218 	start_deadman();
9219 
9220 	return(c);
9221 }
9222 
put_echo_char(unsigned int data,int style)9223 void put_echo_char(unsigned int data, int style)
9224 {
9225 // suppress print to rx widget when making timing tests
9226 	if (PERFORM_CPS_TEST || active_modem->XMLRPC_CPS_TEST) return;
9227 
9228 	if(progdefaults.ax25_decode_enabled && data_io_enabled == KISS_IO) {
9229 		disp_rx_processed_char();
9230 		return;
9231 	}
9232 
9233 	trx_mode mode = active_modem->get_mode();
9234 
9235 	if (mode == MODE_CW && progdefaults.QSKadjust)
9236 		return;
9237 
9238 	REQ(&add_tx_char, data & 0xFF);
9239 
9240 	// select a byte translation table
9241 	const char **asc = NULL;//ascii;
9242 	if (mailclient || mailserver) {
9243 		asc = ascii2;
9244 		style = FTextBase::CTRL;
9245 	} else if ((progdefaults.show_all_codes && iscntrl(data & 0xFF)) ||
9246 				PERFORM_CPS_TEST || active_modem->XMLRPC_CPS_TEST)
9247 		asc = ascii3;
9248 
9249 	// receive and convert the data
9250 	static unsigned int lastdata = 0;
9251 
9252 	if (data == '\r' && lastdata == '\r') // reject multiple CRs
9253 		return;
9254 
9255 	if (mode == MODE_RTTY && data == '\a') {
9256 		if (progdefaults.visibleBELL)
9257 			echo_chd.rx((unsigned char *)ascii2[7]);
9258 		REQ(TTY_bell);
9259 	} else if (asc == NULL)
9260 		echo_chd.rx(data & 0xFF);
9261 	else
9262 		echo_chd.rx((unsigned char *)asc[data & 0xFF]);
9263 
9264 	lastdata = data;
9265 
9266 	if (Maillogfile) {
9267 		string s = iscntrl(data & 0x7F) ? ascii2[data & 0x7F] : string(1, data);
9268 		Maillogfile->log_to_file(cLogfile::LOG_TX, s);
9269 	}
9270 
9271 
9272 	if (echo_chd.data_length() > 0)
9273 	{
9274 		if (active_modem->get_mode() == MODE_FSQ)
9275 			REQ(&FTextRX::addstr, fsq_rx_text, echo_chd.data(), style);
9276 		else if (active_modem->get_mode() == MODE_IFKP)
9277 			REQ(&FTextRX::addstr, ifkp_rx_text, echo_chd.data(), style);
9278 		else
9279 			REQ(&FTextRX::addstr, ReceiveText, echo_chd.data(), style);
9280 		if (progStatus.LOGenabled)
9281 			logfile->log_to_file(cLogfile::LOG_TX, echo_chd.data());
9282 
9283 		echo_chd.clear();
9284 	}
9285 }
9286 
resetRTTY()9287 void resetRTTY() {
9288 	if (active_modem->get_mode() == MODE_RTTY)
9289 		trx_start_modem(active_modem);
9290 }
9291 
resetOLIVIA()9292 void resetOLIVIA() {
9293 	trx_mode md = active_modem->get_mode();
9294 	if (md >= MODE_OLIVIA && md <= MODE_OLIVIA_64_2000)
9295 		trx_start_modem(active_modem);
9296 }
9297 
resetCONTESTIA()9298 void resetCONTESTIA() {
9299 	if (active_modem->get_mode() == MODE_CONTESTIA)
9300 		trx_start_modem(active_modem);
9301 }
9302 
9303 //void updatePACKET() {
9304 //    if (active_modem->get_mode() == MODE_PACKET)
9305 //	trx_start_modem(active_modem);
9306 //}
9307 
resetTHOR()9308 void resetTHOR() {
9309 	trx_mode md = active_modem->get_mode();
9310 	if (md == MODE_THORMICRO || md == MODE_THOR4 || md == MODE_THOR5 || md == MODE_THOR8 ||
9311 		md == MODE_THOR11 ||
9312 		md == MODE_THOR16 || md == MODE_THOR22 ||
9313 		md == MODE_THOR25x4 || md == MODE_THOR50x1 ||
9314 		md == MODE_THOR50x2 || md == MODE_THOR100 )
9315 		trx_start_modem(active_modem);
9316 }
9317 
resetDOMEX()9318 void resetDOMEX() {
9319 	trx_mode md = active_modem->get_mode();
9320 	if (md == MODE_DOMINOEXMICRO || md == MODE_DOMINOEX4 || md == MODE_DOMINOEX5 ||
9321 		md == MODE_DOMINOEX8 || md == MODE_DOMINOEX11 ||
9322 		md == MODE_DOMINOEX16 || md == MODE_DOMINOEX22 ||
9323 		md == MODE_DOMINOEX44 || md == MODE_DOMINOEX88 )
9324 		trx_start_modem(active_modem);
9325 }
9326 
resetSoundCard()9327 void resetSoundCard()
9328 {
9329 	trx_reset();
9330 }
9331 
setReverse(int rev)9332 void setReverse(int rev) {
9333 	active_modem->set_reverse(rev);
9334 }
9335 
start_tx()9336 void start_tx()
9337 {
9338 	if (!(active_modem->get_cap() & modem::CAP_TX))
9339 		return;
9340 	trx_transmit();
9341 }
9342 
abort_tx()9343 void abort_tx()
9344 {
9345 	if (trx_state == STATE_TUNE) {
9346 		btnTune->value(0);
9347 		btnTune->do_callback();
9348 		return;
9349 	}
9350 	if (trx_state == STATE_TX) {
9351 		queue_reset();
9352 		trx_start_modem(active_modem);
9353 	}
9354 }
9355 
set_rx_tx()9356 void set_rx_tx()
9357 {
9358 	abort_tx();
9359 	rx_only = false;
9360 	btnTune->activate();
9361 	wf->xmtrcv->activate();
9362 }
9363 
set_rx_only()9364 void set_rx_only()
9365 {
9366 	abort_tx();
9367 	rx_only = true;
9368 	btnTune->deactivate();
9369 	wf->xmtrcv->deactivate();
9370 }
9371 
qsy(long long rfc,int fmid)9372 void qsy(long long rfc, int fmid)
9373 {
9374 	if (rfc <= 0LL) {
9375 		rfc = wf->rfcarrier();
9376 	}
9377 
9378 	if (fmid > 0) {
9379 		if (active_modem->freqlocked())
9380 			active_modem->set_freqlock(false);
9381 		else
9382 			active_modem->set_freq(fmid);
9383 		// required for modems that will not change their freq (e.g. mt63)
9384 		int adj = active_modem->get_freq() - fmid;
9385 		if (adj)
9386 			rfc += (wf->USB() ? adj : -adj);
9387 	}
9388 
9389 	if (connected_to_flrig)
9390 		REQ(xmlrpc_rig_set_qsy, rfc);
9391 	else if (progdefaults.chkUSERIGCATis)
9392 		REQ(rigCAT_set_qsy, rfc);
9393 #if USE_HAMLIB
9394 	else if (progdefaults.chkUSEHAMLIBis)
9395 		REQ(hamlib_set_qsy, rfc);
9396 #endif
9397 	else
9398 		qso_selectFreq((long int) rfc, fmid);
9399 
9400 	string testmode = qso_opMODE->value();
9401 	bool xcvr_useFSK = (testmode.find("RTTY") != string::npos);
9402 	if (xcvr_useFSK) {
9403 		int fmid = progdefaults.xcvr_FSK_MARK + rtty::SHIFT[progdefaults.rtty_shift]/2;
9404 		wf->carrier(fmid);
9405 	}
9406 }
9407 
9408 map<string, qrg_mode_t> qrg_marks;
9409 qrg_mode_t last_marked_qrg;
9410 
note_qrg(bool no_dup,const char * prefix,const char * suffix,trx_mode mode,long long rfc,int afreq)9411 void note_qrg(bool no_dup, const char* prefix, const char* suffix, trx_mode mode, long long rfc, int afreq)
9412 {
9413 	qrg_mode_t m;
9414 	m.rfcarrier = (rfc ? rfc : wf->rfcarrier());
9415 	m.carrier = (afreq ? afreq : active_modem->get_freq());
9416 	m.mode = (mode < NUM_MODES ? mode : active_modem->get_mode());
9417 	if (no_dup && last_marked_qrg == m)
9418 		return;
9419 	last_marked_qrg = m;
9420 
9421 	char buf[64];
9422 
9423 	time_t t = time(NULL);
9424 	struct tm tm;
9425 	gmtime_r(&t, &tm);
9426 	size_t r1;
9427 	if ((r1 = strftime(buf, sizeof(buf), "<<%Y-%m-%dT%H:%MZ ", &tm)) == 0)
9428 		return;
9429 
9430 	size_t r2;
9431 	if (m.rfcarrier)
9432 		r2 = snprintf(buf+r1, sizeof(buf)-r1, "%s @ %lld%c%04d>>",
9433 				 mode_info[m.mode].name, m.rfcarrier, (wf->USB() ? '+' : '-'), m.carrier);
9434 	else
9435 		r2 = snprintf(buf+r1, sizeof(buf)-r1, "%s @ %04d>>", mode_info[m.mode].name, m.carrier);
9436 	if (r2 >= sizeof(buf)-r1)
9437 		return;
9438 
9439 	qrg_marks[buf] = m;
9440 	if (prefix && *prefix)
9441 		ReceiveText->addstr(prefix);
9442 	ReceiveText->addstr(buf, FTextBase::QSY);
9443 	ReceiveText->mark();
9444 	if (suffix && *suffix)
9445 		ReceiveText->addstr(suffix);
9446 }
9447 
9448 
9449 // To be called from the main thread.
set_xmtrcv_button_true(void)9450 void * set_xmtrcv_button_true(void)
9451 {
9452 	wf->xmtrcv->value(true);
9453 	wf->xmtrcv->redraw();
9454 	return (void *)0;
9455 }
9456 
9457 // To be called from the main thread.
set_xmtrcv_button_false(void)9458 void * set_xmtrcv_button_false(void)
9459 {
9460 	wf->xmtrcv->value(false);
9461 	wf->xmtrcv->redraw();
9462 	return (void *)0;
9463 }
9464 
9465 // To be called from the main thread.
set_xmtrcv_selection_color_transmitting(void)9466 void * set_xmtrcv_selection_color_transmitting(void)
9467 {
9468 	wf->xmtrcv_selection_color(progdefaults.XmtColor);
9469 	return (void *)0;
9470 }
9471 
9472 // To be called from the main thread.
set_xmtrcv_selection_color_pending(void)9473 void * set_xmtrcv_selection_color_pending(void)
9474 {
9475 	wf->xmtrcv_selection_color(FL_YELLOW);
9476 	return (void *)0;
9477 }
9478 
xmtrcv_selection_color(Fl_Color clr)9479 void xmtrcv_selection_color(Fl_Color clr)
9480 {
9481 	wf->xmtrcv_selection_color(clr);
9482 }
9483 
xmtrcv_selection_color()9484 void xmtrcv_selection_color()
9485 {
9486 	wf->xmtrcv_selection_color(progdefaults.XmtColor);
9487 }
9488 
rev_selection_color()9489 void rev_selection_color()
9490 {
9491 	wf->reverse_selection_color(progdefaults.RevColor);
9492 }
9493 
xmtlock_selection_color()9494 void xmtlock_selection_color()
9495 {
9496 	wf->xmtlock_selection_color(progdefaults.LkColor);
9497 }
9498 
sql_selection_color()9499 void sql_selection_color()
9500 {
9501 	if (!btnSQL) return;
9502 	btnSQL->selection_color(progdefaults.Sql1Color);
9503 	btnSQL->redraw();
9504 }
9505 
afc_selection_color()9506 void afc_selection_color()
9507 {
9508 	if (!btnAFC) return;
9509 	btnAFC->selection_color(progdefaults.AfcColor);
9510 	btnAFC->redraw();
9511 }
9512 
rxid_selection_color()9513 void rxid_selection_color()
9514 {
9515 	cbRSID(NULL, NULL);
9516 }
9517 
txid_selection_color()9518 void txid_selection_color()
9519 {
9520 	if (!btnTxRSID) return;
9521 	btnTxRSID->selection_color(progdefaults.TxIDColor);
9522 	btnTxRSID->redraw();
9523 }
9524 
tune_selection_color()9525 void tune_selection_color()
9526 {
9527 	if (!btnTune) return;
9528 	btnTune->selection_color(progdefaults.TuneColor);
9529 	btnTune->redraw();
9530 }
9531 
spot_selection_color()9532 void spot_selection_color()
9533 {
9534 	if (!btnAutoSpot) return;
9535 	btnAutoSpot->selection_color(progdefaults.SpotColor);
9536 	btnAutoSpot->redraw();
9537 }
9538 
set_default_btn_color()9539 void set_default_btn_color()
9540 {
9541 	Fl_Light_Button *buttons[] = {
9542 		btn_FSQCALL, btn_SELCAL, btn_MONITOR, btnPSQL,
9543 		btnDupCheckOn, btn_WKCW_connect, btn_WKFSK_connect,
9544 		btn_nanoCW_connect, btn_nanoIO_connect,
9545 		btn_enable_auditlog, btn_enable_fsq_heard_log,
9546 		btn_enable_ifkp_audit_log, btn_enable_ifkp_audit_log,
9547 		btn_Nav_connect, btn_Nav_config, btn_fmt_record,
9548 		btnConnectTalker,
9549 		btn_unk_enable, btn_ref_enable };
9550 
9551 	size_t nbtns = sizeof(buttons)/sizeof(*buttons);
9552 
9553 	for (size_t i = 0; i < nbtns; i++) {
9554 		if (buttons[i] != NULL) {
9555 			buttons[i]->selection_color(progdefaults.default_btn_color);
9556 			buttons[i]->redraw();
9557 		}
9558 	}
9559 	trx_mode md = active_modem->get_mode();
9560 	if ((md > MODE_WEFAX_FIRST) && (md <= MODE_WEFAX_LAST)) {
9561 		wefax_round_rx_noise_removal->selection_color(progdefaults.default_btn_color);
9562 		wefax_round_rx_binary->selection_color(progdefaults.default_btn_color);
9563 		wefax_round_rx_non_stop->selection_color(progdefaults.default_btn_color);
9564 	}
9565 
9566 }
9567 
set_colors()9568 void set_colors()
9569 {
9570 	spot_selection_color();
9571 	tune_selection_color();
9572 	txid_selection_color();
9573 	rxid_selection_color();
9574 	sql_selection_color();
9575 	afc_selection_color();
9576 	xmtlock_selection_color();
9577 	tune_selection_color();
9578 	set_default_btn_color();
9579 	set_log_colors();
9580 }
9581 
9582 // Olivia
set_olivia_bw(int bw)9583 void set_olivia_bw(int bw)
9584 {
9585 	int i;
9586 	if (bw == 125)
9587 		i = 0;
9588 	else if (bw == 250)
9589 		i = 1;
9590 	else if (bw == 500)
9591 		i = 2;
9592 	else if (bw == 1000)
9593 		i = 3;
9594 	else
9595 		i = 4;
9596 	bool changed = progdefaults.changed;
9597 	i_listbox_olivia_bandwidth->index(i);
9598 	i_listbox_olivia_bandwidth->do_callback();
9599 	progdefaults.changed = changed;
9600 }
9601 
set_olivia_tones(int tones)9602 void set_olivia_tones(int tones)
9603 {
9604 	unsigned i = -1;
9605 	while (tones >>= 1)
9606 		i++;
9607 	bool changed = progdefaults.changed;
9608 	i_listbox_olivia_tones->index(i);//+1);
9609 	i_listbox_olivia_tones->do_callback();
9610 	progdefaults.changed = changed;
9611 }
9612 
9613 //Contestia
set_contestia_bw(int bw)9614 void set_contestia_bw(int bw)
9615 {
9616 	int i;
9617 	if (bw == 125)
9618 		i = 0;
9619 	else if (bw == 250)
9620 		i = 1;
9621 	else if (bw == 500)
9622 		i = 2;
9623 	else if (bw == 1000)
9624 		i = 3;
9625 	else
9626 		i = 4;
9627 	bool changed = progdefaults.changed;
9628 	i_listbox_contestia_bandwidth->index(i);
9629 	i_listbox_contestia_bandwidth->do_callback();
9630 	progdefaults.changed = changed;
9631 }
9632 
set_contestia_tones(int tones)9633 void set_contestia_tones(int tones)
9634 {
9635 	unsigned i = -1;
9636 	while (tones >>= 1)
9637 		i++;
9638 	bool changed = progdefaults.changed;
9639 	i_listbox_contestia_tones->index(i);
9640 	i_listbox_contestia_tones->do_callback();
9641 	progdefaults.changed = changed;
9642 }
9643 
9644 
set_rtty_shift(int shift)9645 void set_rtty_shift(int shift)
9646 {
9647 	if (shift < selCustomShift->minimum() || shift > selCustomShift->maximum())
9648 		return;
9649 
9650 	// Static const array otherwise will be built at each call.
9651 	static const int shifts[] = { 23, 85, 160, 170, 182, 200, 240, 350, 425, 850 };
9652 	size_t i;
9653 	for (i = 0; i < sizeof(shifts)/sizeof(*shifts); i++)
9654 		if (shifts[i] == shift)
9655 			break;
9656 	selShift->index(i);
9657 	selShift->do_callback();
9658 	if (i == sizeof(shifts)/sizeof(*shifts)) {
9659 		selCustomShift->value(shift);
9660 		selCustomShift->do_callback();
9661 	}
9662 }
9663 
set_rtty_baud(float baud)9664 void set_rtty_baud(float baud)
9665 {
9666 	// Static const array otherwise will be rebuilt at each call.
9667 	static const float bauds[] = {
9668 		45.0f, 45.45f, 50.0f, 56.0f, 75.0f,
9669 		100.0f, 110.0f, 150.0f, 200.0f, 300.0f
9670 	};
9671 	for (size_t i = 0; i < sizeof(bauds)/sizeof(*bauds); i++) {
9672 		if (bauds[i] == baud) {
9673 			selBaud->index(i);
9674 			selBaud->do_callback();
9675 			break;
9676 		}
9677 	}
9678 }
9679 
set_rtty_bits(int bits)9680 void set_rtty_bits(int bits)
9681 {
9682 	// Static const array otherwise will be built at each call.
9683 	static const int bits_[] = { 5, 7, 8 };
9684 	for (size_t i = 0; i < sizeof(bits_)/sizeof(*bits_); i++) {
9685 		if (bits_[i] == bits) {
9686 			selBits->index(i);
9687 			selBits->do_callback();
9688 			break;
9689 		}
9690 	}
9691 }
9692 
set_rtty_bw(float bw)9693 void set_rtty_bw(float bw)
9694 {
9695 }
9696 
9697 int notch_frequency = 0;
notch_on(int freq)9698 void notch_on(int freq)
9699 {
9700 	notch_frequency = freq;
9701 	if (progdefaults.fldigi_client_to_flrig)
9702 		set_flrig_notch();
9703 	else
9704 		rigCAT_set_notch(notch_frequency);
9705 }
9706 
notch_off()9707 void notch_off()
9708 {
9709 	notch_frequency = 0;
9710 	if (progdefaults.fldigi_client_to_flrig)
9711 		set_flrig_notch();
9712 	else
9713 		rigCAT_set_notch(notch_frequency);
9714 }
9715 
enable_kiss(void)9716 void enable_kiss(void)
9717 {
9718 	if(btnEnable_arq->value()) {
9719 		btnEnable_arq->value(false);
9720 	}
9721 
9722 	progdefaults.changed = true;
9723 	progdefaults.data_io_enabled = KISS_IO;
9724 	progStatus.data_io_enabled = KISS_IO;
9725 	data_io_enabled = KISS_IO;
9726 
9727 	btnEnable_kiss->value(true);
9728 
9729 	enable_disable_kpsql();
9730 }
9731 
enable_arq(void)9732 void enable_arq(void)
9733 {
9734 	if(btnEnable_kiss->value()) {
9735 		btnEnable_kiss->value(false);
9736 	}
9737 
9738 	progdefaults.changed = true;
9739 	progdefaults.data_io_enabled = ARQ_IO;
9740 	progStatus.data_io_enabled = ARQ_IO;
9741 	data_io_enabled = ARQ_IO;
9742 
9743 	btnEnable_arq->value(true);
9744 
9745 	enable_disable_kpsql();
9746 }
9747 
enable_disable_kpsql(void)9748 void enable_disable_kpsql(void)
9749 {
9750 	if (progdefaults.data_io_enabled == KISS_IO) {
9751 		check_kiss_modem();
9752 		//btnPSQL->activate();
9753 		//if(progStatus.kpsql_enabled || progdefaults.kpsql_enabled) {
9754 		//    btnPSQL->value(true);
9755 		//    btnPSQL->do_callback();
9756 		//}
9757 	} else {
9758 		sldrSquelch->value(progStatus.sldrSquelchValue);
9759 		//btnPSQL->value(false);
9760 		//btnPSQL->deactivate();
9761 	}
9762 
9763 	progStatus.data_io_enabled = progdefaults.data_io_enabled;
9764 }
9765 
disable_config_p2p_io_widgets(void)9766 void disable_config_p2p_io_widgets(void)
9767 {
9768 	btnEnable_arq->deactivate();
9769 	btnEnable_kiss->deactivate();
9770 	btnEnable_ax25_decode->deactivate();
9771 	//btnEnable_csma->deactivate();
9772 
9773 	txtKiss_ip_address->deactivate();
9774 	txtKiss_ip_io_port_no->deactivate();
9775 	txtKiss_ip_out_port_no->deactivate();
9776 	btnEnable_dual_port->deactivate();
9777 	//btnEnableBusyChannel->deactivate();
9778 	//cntKPSQLAttenuation->deactivate();
9779 	//cntBusyChannelSeconds->deactivate();
9780 	btnDefault_kiss_ip->deactivate();
9781 	btn_restart_kiss->deactivate();
9782 	btnEnable_7bit_modem_inhibit->deactivate();
9783 	btnEnable_auto_connect->deactivate();
9784 	btnKissTCPIO->deactivate();
9785 	btnKissUDPIO->deactivate();
9786 	btnKissTCPListen->deactivate();
9787 	btn_connect_kiss_io->deactivate();
9788 
9789 	txtArq_ip_address->deactivate();
9790 	txtArq_ip_port_no->deactivate();
9791 	btnDefault_arq_ip->deactivate();
9792 	btn_restart_arq->deactivate();
9793 
9794 	txtXmlrpc_ip_address->deactivate();
9795 	txtXmlrpc_ip_port_no->deactivate();
9796 	btnDefault_xmlrpc_ip->deactivate();
9797 	btn_restart_xml->deactivate();
9798 
9799 	txt_flrig_ip_address->deactivate();
9800 	txt_flrig_ip_port->deactivate();
9801 	btnDefault_flrig_ip->deactivate();
9802 	btn_reconnect_flrig_server->deactivate();
9803 
9804 	txt_fllog_ip_address->deactivate();
9805 	txt_fllog_ip_port->deactivate();
9806 	btnDefault_fllog_ip->deactivate();
9807 	btn_reconnect_log_server->deactivate();
9808 }
9809 
9810 //-----------------------------------------------------------------------------
9811 //
9812 //-----------------------------------------------------------------------------
enable_config_p2p_io_widgets(void)9813 void enable_config_p2p_io_widgets(void)
9814 {
9815 	btnEnable_arq->activate();
9816 	btnEnable_kiss->activate();
9817 	btnEnable_ax25_decode->activate();
9818 	//btnEnable_csma->activate();
9819 
9820 	txtKiss_ip_address->activate();
9821 	txtKiss_ip_io_port_no->activate();
9822 	txtKiss_ip_out_port_no->activate();
9823 	btnEnable_dual_port->activate();
9824 	//btnEnableBusyChannel->activate();
9825 	//cntKPSQLAttenuation->activate();
9826 	//cntBusyChannelSeconds->activate();
9827 	btnDefault_kiss_ip->activate();
9828 	btn_restart_kiss->activate();
9829 	btnEnable_7bit_modem_inhibit->activate();
9830 	btnEnable_auto_connect->activate();
9831 	btnKissTCPIO->activate();
9832 	btnKissUDPIO->activate();
9833 	btnKissTCPListen->activate();
9834 	btn_connect_kiss_io->activate();
9835 
9836 	txtArq_ip_address->activate();
9837 	txtArq_ip_port_no->activate();
9838 	btnDefault_arq_ip->activate();
9839 	btn_restart_arq->activate();
9840 
9841 	txtXmlrpc_ip_address->activate();
9842 	txtXmlrpc_ip_port_no->activate();
9843 	btnDefault_xmlrpc_ip->activate();
9844 	btn_restart_xml->activate();
9845 
9846 	txt_flrig_ip_address->activate();
9847 	txt_flrig_ip_port->activate();
9848 	btnDefault_flrig_ip->activate();
9849 	btn_reconnect_flrig_server->activate();
9850 
9851 	txt_fllog_ip_address->activate();
9852 	txt_fllog_ip_port->activate();
9853 	btnDefault_fllog_ip->activate();
9854 	btn_reconnect_log_server->activate();
9855 }
9856 
9857 //-----------------------------------------------------------------------------
9858 //
9859 //-----------------------------------------------------------------------------
set_ip_to_default(int which_io)9860 void set_ip_to_default(int which_io)
9861 {
9862 
9863 	switch(which_io) {
9864 		case ARQ_IO:
9865 			txtArq_ip_address->value(DEFAULT_ARQ_IP_ADDRESS);
9866 			txtArq_ip_port_no->value(DEFAULT_ARQ_IP_PORT);
9867 			txtArq_ip_address->do_callback();
9868 			txtArq_ip_port_no->do_callback();
9869 			break;
9870 
9871 		case KISS_IO:
9872 			txtKiss_ip_address->value(DEFAULT_KISS_IP_ADDRESS);
9873 			txtKiss_ip_io_port_no->value(DEFAULT_KISS_IP_IO_PORT);
9874 			txtKiss_ip_out_port_no->value(DEFAULT_KISS_IP_OUT_PORT);
9875 			btnEnable_dual_port->value(false);
9876 			txtKiss_ip_address->do_callback();
9877 			txtKiss_ip_io_port_no->do_callback();
9878 			txtKiss_ip_out_port_no->do_callback();
9879 			btnEnable_dual_port->do_callback();
9880 			break;
9881 
9882 		case XMLRPC_IO:
9883 			txtXmlrpc_ip_address->value(DEFAULT_XMLPRC_IP_ADDRESS);
9884 			txtXmlrpc_ip_port_no->value(DEFAULT_XMLRPC_IP_PORT);
9885 			txtXmlrpc_ip_address->do_callback();
9886 			txtXmlrpc_ip_port_no->do_callback();
9887 			break;
9888 
9889 		case FLRIG_IO:
9890 			txt_flrig_ip_address->value(DEFAULT_FLRIG_IP_ADDRESS);
9891 			txt_flrig_ip_port->value(DEFAULT_FLRIG_IP_PORT);
9892 			txt_flrig_ip_address->do_callback();
9893 			txt_flrig_ip_port->do_callback();
9894 			break;
9895 
9896 		case FLLOG_IO:
9897 			txt_fllog_ip_address->value(DEFAULT_FLLOG_IP_ADDRESS);
9898 			txt_fllog_ip_port->value(DEFAULT_FLLOG_IP_PORT);
9899 			txt_fllog_ip_address->do_callback();
9900 			txt_fllog_ip_port->do_callback();
9901 			break;
9902 	}
9903 }
9904 
9905 //-----------------------------------------------------------------------------
9906 //
9907 //-----------------------------------------------------------------------------
kiss_io_set_button_state(void * ptr)9908 void kiss_io_set_button_state(void *ptr)
9909 {
9910 
9911 	if(progStatus.kiss_tcp_io) {
9912 		btn_connect_kiss_io->activate();
9913 
9914 		btn_connect_kiss_io->redraw();
9915 		btnKissTCPIO->activate();
9916 		btnKissTCPIO->value(true);
9917 		btnKissTCPListen->activate();
9918 
9919 		btnKissUDPIO->value(false);
9920 		btnKissUDPIO->activate();
9921 		btnEnable_dual_port->deactivate();
9922 
9923 	} else {
9924 		btn_connect_kiss_io->activate();
9925 
9926 		btnKissTCPIO->value(false);
9927 		btnKissTCPIO->activate();
9928 		btnKissTCPListen->activate();
9929 
9930 		btnKissUDPIO->value(true);
9931 		btnKissUDPIO->activate();
9932 		btnEnable_dual_port->activate();
9933 	}
9934 
9935 	char *label = (char *)0;
9936 	if(ptr)
9937 		label = (char *)ptr;
9938 
9939 	if(label) {
9940 		btn_connect_kiss_io->label(label);
9941 		btn_connect_kiss_io->redraw();
9942 	}
9943 
9944 	if(progStatus.ip_lock) {
9945 		btn_connect_kiss_io->deactivate();
9946 		btnKissTCPIO->deactivate();
9947 		btnKissUDPIO->deactivate();
9948 		btnKissTCPListen->deactivate();
9949 		btnEnable_dual_port->deactivate();
9950 	}
9951 
9952 }
9953 
9954 //-----------------------------------------------------------------------------
9955 // Update CSMA Display Widgets in the IO Configuration Panel
9956 //-----------------------------------------------------------------------------
update_csma_io_config(int which)9957 void update_csma_io_config(int which)
9958 {
9959    char buf[32];
9960 
9961    if(which & CSMA_PERSISTANCE) {
9962 	  cntPersistance->value(progStatus.csma_persistance);
9963 	  if(progStatus.csma_persistance >= 0) {
9964 		 float results = ((progStatus.csma_persistance + 1) / 256.0) * 100.0;
9965 		 memset(buf, 0, sizeof(buf));
9966 		 snprintf(buf, sizeof(buf) - 1, "%f", results);
9967 		 OutputPersistancePercent->value(buf);
9968 	  }
9969    }
9970 
9971    if(which & CSMA_SLOT_TIME) {
9972 	  cntSlotTime->value(progStatus.csma_slot_time);
9973 	  int results = progStatus.csma_slot_time * 10;
9974 	  memset(buf, 0, sizeof(buf));
9975 	  snprintf(buf, sizeof(buf) - 1, "%d", results);
9976 	  OutputSlotTimeMS->value(buf);
9977    }
9978 
9979    if(which & CSMA_TX_DELAY) {
9980 	  cntTransmitDelay->value(progStatus.csma_transmit_delay);
9981 	  int results = progStatus.csma_transmit_delay * 10;
9982 	  memset(buf, 0, sizeof(buf));
9983 	  snprintf(buf, sizeof(buf) - 1, "%d", results);
9984 	  OutputTransmitDelayMS->value(buf);
9985    }
9986 }
9987 
9988 //-----------------------------------------------------------------------------
9989 // Set PSM configuration panel defaults values.
9990 //-----------------------------------------------------------------------------
psm_set_defaults(void)9991 void psm_set_defaults(void)
9992 {
9993 	progdefaults.csma_persistance               = progStatus.csma_persistance               = 63;
9994 	progdefaults.csma_slot_time                 = progStatus.csma_slot_time                 = 10;
9995 	progdefaults.csma_transmit_delay            = progStatus.csma_transmit_delay            = 50;
9996 	progdefaults.psm_flush_buffer_timeout       = progStatus.psm_flush_buffer_timeout       = 15;
9997 	progdefaults.psm_minimum_bandwidth_margin   = progStatus.psm_minimum_bandwidth_margin   = 10;
9998 	progdefaults.psm_histogram_offset_threshold = progStatus.psm_histogram_offset_threshold = 3;
9999 	progdefaults.psm_hit_time_window            = progStatus.psm_hit_time_window            = 15;
10000 	progdefaults.kpsql_attenuation              = progStatus.kpsql_attenuation              = 2;
10001 	progdefaults.busyChannelSeconds             = progStatus.busyChannelSeconds             = 3;
10002 
10003 	cntPersistance->value(progStatus.csma_persistance);
10004 	cntSlotTime->value(progStatus.csma_slot_time);
10005 	cntTransmitDelay->value(progStatus.csma_transmit_delay);
10006 	cntPSMTXBufferFlushTimer->value(progStatus.psm_flush_buffer_timeout);
10007 	cntPSMBandwidthMargins->value(progStatus.psm_minimum_bandwidth_margin);
10008 	cntPSMThreshold->value(progStatus.psm_histogram_offset_threshold);
10009 	cntPSMValidSamplePeriod->value(progStatus.psm_hit_time_window);
10010 	cntKPSQLAttenuation->value(progdefaults.kpsql_attenuation);
10011 	cntBusyChannelSeconds->value(progStatus.busyChannelSeconds);
10012 
10013 	update_csma_io_config(CSMA_ALL);
10014 }
10015 
10016 //-----------------------------------------------------------------------------
10017 //
10018 //-----------------------------------------------------------------------------
set_CSV(int start)10019 void set_CSV(int start)
10020 {
10021 	if (active_modem->get_mode() == MODE_ANALYSIS) {
10022 		if (active_modem->get_mode() != MODE_ANALYSIS) return;
10023 		if (start == 1)
10024 			active_modem->start_csv();
10025 		else if (start == 0)
10026 			active_modem->stop_csv();
10027 		else if (active_modem->write_to_csv == true)
10028 			active_modem->stop_csv();
10029 		else
10030 			active_modem->start_csv();
10031 	}
10032 }
10033 
10034 //-----------------------------------------------------------------------------
10035 //
10036 //-----------------------------------------------------------------------------
set_freq_control_lsd()10037 void set_freq_control_lsd()
10038 {
10039 	qsoFreqDisp1->set_lsd(progdefaults.sel_lsd);
10040 	qsoFreqDisp2->set_lsd(progdefaults.sel_lsd);
10041 	qsoFreqDisp3->set_lsd(progdefaults.sel_lsd);
10042 }
10043 
10044 //-----------------------------------------------------------------------------
10045 // FSQ mode control interface functions
10046 //-----------------------------------------------------------------------------
10047 std::string fsq_selected_call = "allcall";
10048 static int heard_picked;
10049 
10050 void clear_heard_list();
10051 
cb_heard_delete(Fl_Widget * w,void *)10052 void cb_heard_delete(Fl_Widget *w, void *)
10053 {
10054 	int sel = fl_choice2(_("Delete entry?"), _("All"), _("No"), _("Yes"));
10055 	if (sel == 2) {
10056 		fsq_heard->remove(heard_picked);
10057 		fsq_heard->redraw();
10058 	}
10059 	if (sel == 0) clear_heard_list();
10060 }
10061 
cb_heard_copy(Fl_Widget * w,void *)10062 void cb_heard_copy(Fl_Widget *w, void *)
10063 {
10064 // copy to clipboard
10065 	Fl::copy(fsq_selected_call.c_str(), fsq_selected_call.length(), 1);
10066 }
10067 
cb_heard_copy_to_log(Fl_Widget * w,void *)10068 void cb_heard_copy_to_log(Fl_Widget *w, void *)
10069 {
10070 	inpCall->value(fsq_selected_call.c_str());
10071 	cb_call(inpCall, (void *)0);
10072 }
10073 
cb_heard_copy_all(Fl_Widget * w,void *)10074 void cb_heard_copy_all(Fl_Widget *w, void *)
10075 {
10076 	if (fsq_heard->size() < 2) return;
10077 	fsq_selected_call.clear();
10078 	for (int i = 2; i <= fsq_heard->size(); i++) {
10079 		fsq_selected_call.append(fsq_heard->text(i));
10080 		size_t p = fsq_selected_call.find(',');
10081 		if (p != std::string::npos) fsq_selected_call.erase(p);
10082 		fsq_selected_call.append(" ");
10083 	}
10084 	Fl::copy(fsq_selected_call.c_str(), fsq_selected_call.length(), 1);
10085 }
10086 
cb_heard_query_snr(Fl_Widget * w,void *)10087 void cb_heard_query_snr(Fl_Widget *w, void *)
10088 {
10089 	std::string s = fsq_selected_call.c_str();
10090 	s.append("?");
10091 	fsq_xmt(s);
10092 }
10093 
cb_heard_query_heard(Fl_Widget * w,void *)10094 void cb_heard_query_heard(Fl_Widget *w, void *)
10095 {
10096 	std::string s = fsq_selected_call.c_str();
10097 	s.append("$");
10098 	fsq_xmt(s);
10099 }
10100 
cb_heard_query_at(Fl_Widget * w,void *)10101 void cb_heard_query_at(Fl_Widget *w, void *)
10102 {
10103 	std::string s = fsq_selected_call.c_str();
10104 	s.append("@");
10105 	fsq_xmt(s);
10106 }
10107 
cb_heard_query_carat(Fl_Widget * w,void *)10108 void cb_heard_query_carat(Fl_Widget *w, void *)
10109 {
10110 	std::string s = fsq_selected_call.c_str();
10111 	s.append("^^");
10112 	fsq_xmt(s);
10113 }
10114 
cb_heard_query_amp(Fl_Widget * w,void *)10115 void cb_heard_query_amp(Fl_Widget *w, void *)
10116 {
10117 	std::string s = fsq_selected_call.c_str();
10118 	s.append("&");
10119 	fsq_xmt(s);
10120 }
10121 
cb_heard_send_file(Fl_Widget * w,void *)10122 void cb_heard_send_file(Fl_Widget *w, void *)
10123 {
10124 	std::string deffilename = TempDir;
10125 	deffilename.append("fsq.txt");
10126 
10127 	const char* p = FSEL::select( "Select send file", "*.txt", deffilename.c_str());
10128 	if (!p) return;
10129 	if (!*p) return;
10130 
10131 	std::string fname = fl_filename_name(p);
10132 	ifstream txfile(p);
10133 	if (!txfile) return;
10134 	stringstream text;
10135 	char ch = txfile.get();
10136 	while (!txfile.eof()) {
10137 		text << ch;
10138 		ch = txfile.get();
10139 	}
10140 	txfile.close();
10141 	std::string s = fsq_selected_call.c_str();
10142 	s.append("#[");
10143 	s.append(fname.c_str());
10144 	s.append("]\n");
10145 	s.append(text.str().c_str());
10146 	fsq_xmt(s);
10147 
10148 }
10149 
cb_heard_read_file(Fl_Widget * w,void *)10150 void cb_heard_read_file(Fl_Widget *w, void*)
10151 {
10152 	const char *p = fl_input2("File name");
10153 	if (p == NULL) return;
10154 	string fname = p;
10155 	if (fname.empty()) return;
10156 
10157 	std::string s = fsq_selected_call.c_str();
10158 	s.append("+[");
10159 	s.append(fname.c_str());
10160 	s.append("]^r");
10161 	fsq_xmt(s);
10162 }
10163 
cb_heard_query_plus(Fl_Widget * w,void *)10164 void cb_heard_query_plus(Fl_Widget *w, void *)
10165 {
10166 	std::string s = fsq_selected_call.c_str();
10167 	s.append("+");
10168 	fsq_xmt(s);
10169 }
10170 
cb_heard_send_msg(Fl_Widget * w,void *)10171 void cb_heard_send_msg(Fl_Widget *w, void*)
10172 {
10173 	const char *p = fl_input2("Send message");
10174 	if (p == NULL) return;
10175 	string msg = p;
10176 	if (msg.empty()) return;
10177 
10178 	std::string s = fsq_selected_call.c_str();
10179 	s.append("#[");
10180 	s.append(active_modem->fsq_mycall());
10181 	s.append("]");
10182 	s.append(msg.c_str());
10183 	fsq_xmt(s);
10184 }
10185 
cb_heard_send_image(Fl_Widget * w,void *)10186 void cb_heard_send_image(Fl_Widget *w, void *)
10187 {
10188 	fsq_showTxViewer('L');
10189 }
10190 
10191 static const Fl_Menu_Item *heard_popup;
10192 
10193 static const Fl_Menu_Item all_popup[] = {
10194 	{ "Copy", 0, cb_heard_copy, 0 },
10195 	{ "Copy All", 0, cb_heard_copy_all, 0 , FL_MENU_DIVIDER },
10196 	{ "Send File To... (#)", 0, cb_heard_send_file, 0, FL_MENU_DIVIDER },
10197 	{ "Send Image To... (%)", 0, cb_heard_send_image, 0 },
10198 	{ 0, 0, 0, 0 }
10199 };
10200 
10201 static const Fl_Menu_Item directed_popup[] = {
10202 	{ "Copy", 0, cb_heard_copy, 0 },
10203 	{ "Log call", 0, cb_heard_copy_to_log, 0 },
10204 	{ "Copy All", 0, cb_heard_copy_all, 0 },
10205 	{ "Delete", 0, cb_heard_delete, 0, FL_MENU_DIVIDER },
10206 	{ "Query SNR (?)", 0, cb_heard_query_snr, 0 },
10207 	{ "Query Heard ($)", 0, cb_heard_query_heard, 0 },
10208 	{ "Query Location (@@)", 0, cb_heard_query_at, 0 },
10209 	{ "Query Station Msg (&&)", 0, cb_heard_query_amp, 0 },
10210 	{ "Query program version (^)", 0, cb_heard_query_carat, 0, FL_MENU_DIVIDER },
10211 	{ "Send Message To... (#)", 0, cb_heard_send_msg, 0 },
10212 	{ "Read Messages From  (+)", 0, cb_heard_query_plus, 0,  FL_MENU_DIVIDER },
10213 	{ "Send File To... (#)", 0, cb_heard_send_file, 0 },
10214 	{ "Read File From... (+)", 0, cb_heard_read_file, 0, FL_MENU_DIVIDER },
10215 	{ "Send Image To... (%)", 0, cb_heard_send_image, 0 },
10216 	{ 0, 0, 0, 0 }
10217 };
10218 
heard_list()10219 std::string heard_list()
10220 {
10221 	string heard;
10222 	if (fsq_heard->size() < 2) return heard;
10223 
10224 	for (int i = 2; i <= fsq_heard->size(); i++)
10225 		heard.append(fsq_heard->text(i)).append("\n");
10226 	heard.erase(heard.length() - 1);  // remove last LF
10227 	size_t p = heard.find(",");
10228 	while (p != std::string::npos) {
10229 		heard.insert(p+1," ");
10230 		p = heard.find(",", p+2);
10231 	}
10232 	return heard;
10233 }
10234 
clear_heard_list()10235 void clear_heard_list()
10236 {
10237 	if (active_modem->get_mode() == MODE_FSQ) {
10238 		fsq_heard->clear();
10239 		fsq_heard->add("allcall");
10240 		fsq_heard->redraw();
10241 	} else {
10242 		ifkp_heard->clear();
10243 		ifkp_heard->redraw();
10244 	}
10245 }
10246 
tm2int(string s)10247 int tm2int(string s)
10248 {
10249 	int t = (s[2]-'0')*10 + s[3] - '0';
10250 	t += 60*((s[0] - '0')*10 + s[1] - '0');
10251 	return t * 60;
10252 }
10253 
age_heard_list()10254 void age_heard_list()
10255 {
10256 	string entry;
10257 	string now = ztime(); now.erase(4);
10258 	int tnow = tm2int(now);
10259 	string tm;
10260 	int aging_secs;
10261 	switch (progdefaults.fsq_heard_aging) {
10262 		case 1: aging_secs = 60; break;   // 1 minute
10263 		case 2: aging_secs = 300; break;  // 5 minutes
10264 		case 3: aging_secs = 600; break;  // 10 minutes
10265 		case 4: aging_secs = 1200; break; // 20 minutes
10266 		case 5: aging_secs = 1800; break; // 30 minutes
10267 		case 6: aging_secs = 3600; break; // 60 minutes
10268 		case 7: aging_secs = 5400; break; // 90 minutes
10269 		case 8: aging_secs = 7200; break; // 120 minutes
10270 		case 0:
10271 		default: return; // no aging
10272 	}
10273 	if (active_modem->get_mode() == MODE_FSQ) {
10274 		if (fsq_heard->size() < 2) return;
10275 		for (int i = fsq_heard->size(); i > 1; i--) {
10276 			entry = fsq_heard->text(i);
10277 			size_t pos = entry.find(",");
10278 			tm = entry.substr(pos+1,5);
10279 			tm.erase(2,1);
10280 			int tdiff = tnow - tm2int(tm);
10281 			if (tdiff < 0) tdiff += 24*60*60;
10282 			if (tdiff >= aging_secs)
10283 				fsq_heard->remove(i);
10284 		}
10285 		fsq_heard->redraw();
10286 	} else {
10287 		if (ifkp_heard->size() == 0) return;
10288 		for (int i = ifkp_heard->size(); i > 0; i--) {
10289 			entry = ifkp_heard->text(i);
10290 			size_t pos = entry.find(",");
10291 			tm = entry.substr(pos+1,5);
10292 			tm.erase(2,1);
10293 			int tdiff = tnow - tm2int(tm);
10294 			if (tdiff < 0) tdiff += 24*60*60;
10295 			if (tdiff >= aging_secs)
10296 				ifkp_heard->remove(i);
10297 		}
10298 		ifkp_heard->redraw();
10299 	}
10300 }
10301 
add_to_heard_list(string szcall,string szdb)10302 void add_to_heard_list(string szcall, string szdb)
10303 {
10304 	int found = 0;
10305 	size_t pos_comma;
10306 	std::string testcall;
10307 	std::string line;
10308 	std::string time = inpTimeOff->value();
10309 
10310 	std::string str = szcall;
10311 	str.append(",");
10312 	str += time[0]; str += time[1]; str += ':'; str += time[2]; str += time[3];
10313 	str.append(",").append(szdb);
10314 
10315 	if (active_modem->get_mode() == MODE_FSQ) {
10316 		if (fsq_heard->size() < 2) {
10317 			fsq_heard->add(str.c_str());
10318 		} else {
10319 			for (int i = 2; i <= fsq_heard->size(); i++) {
10320 				line = fsq_heard->text(i);
10321 				pos_comma = line.find(",");
10322 				if (pos_comma != std::string::npos) {
10323 					testcall = line.substr(0, pos_comma);
10324 					if (testcall == szcall) {
10325 						found = i;
10326 						break;
10327 					}
10328 				}
10329 			}
10330 			if (found)
10331 				fsq_heard->remove(found);
10332 			fsq_heard->insert(2, str.c_str());
10333 		}
10334 		fsq_heard->redraw();
10335 	} else {
10336 		if (ifkp_heard->size() == 0) {
10337 			ifkp_heard->add(str.c_str());
10338 		} else {
10339 			for (int i = 1; i <= ifkp_heard->size(); i++) {
10340 				line = ifkp_heard->text(i);
10341 				pos_comma = line.find(",");
10342 				if (pos_comma != std::string::npos) {
10343 					testcall = line.substr(0, pos_comma);
10344 					if (testcall == szcall) {
10345 						found = i;
10346 						break;
10347 					}
10348 				}
10349 			}
10350 			if (found)
10351 				ifkp_heard->remove(found);
10352 			ifkp_heard->insert(1, str.c_str());
10353 		}
10354 		ifkp_heard->redraw();
10355 	}
10356 	if (progStatus.spot_recv)
10357 		spot_log(szcall.c_str(),
10358 			inpLoc->value(),
10359 			wf->rfcarrier(),
10360 			active_modem->get_mode());
10361 }
10362 
in_heard(string call)10363 bool in_heard(string call)
10364 {
10365 	std::string line;
10366 	for (int i = 1; i <= fsq_heard->size(); i++) {
10367 		line = fsq_heard->text(i);
10368 		if (line.find(call) == 0) return true;
10369 	}
10370 	return false;
10371 }
10372 
fsq_repeat_last_heard()10373 void fsq_repeat_last_heard()
10374 {
10375 	fsq_tx_text->add(fsq_selected_call.c_str());
10376 }
10377 
cb_fsq_heard(Fl_Browser *,void *)10378 void cb_fsq_heard(Fl_Browser*, void*)
10379 {
10380 	heard_picked = fsq_heard->value();
10381 	if (!heard_picked)
10382 		return;
10383 	int k = Fl::event_key();
10384 	fsq_selected_call = fsq_heard->text(heard_picked);
10385 	size_t p = fsq_selected_call.find(',');
10386 	if (p != std::string::npos) fsq_selected_call.erase(p);
10387 
10388 	switch (k) {
10389 		case FL_Button + FL_LEFT_MOUSE:
10390 			if (Fl::event_clicks()) {
10391 				if (!fsq_tx_text->eot()) fsq_tx_text->add(" ");
10392 				fsq_tx_text->add(fsq_selected_call.c_str());
10393 			}
10394 			break;
10395 		case FL_Button + FL_RIGHT_MOUSE:
10396 			if (heard_picked == 1)
10397 				heard_popup = all_popup;
10398 			else
10399 				heard_popup = directed_popup;
10400 			const Fl_Menu_Item *m = heard_popup->popup(Fl::event_x(), Fl::event_y());
10401 			if (m && m->callback())
10402 				m->do_callback(0);
10403 			break;
10404 	}
10405 	restoreFocus();
10406 }
10407 
cb_ifkp_heard(Fl_Browser *,void *)10408 void cb_ifkp_heard(Fl_Browser*, void*)
10409 {
10410 	heard_picked = ifkp_heard->value();
10411 	if (!heard_picked)
10412 		return;
10413 
10414 	int k = Fl::event_key();
10415 	std::string selected_call = ifkp_heard->text(heard_picked);
10416 	size_t p = selected_call.find(',');
10417 	if (p != std::string::npos) selected_call.erase(p);
10418 
10419 	switch (k) {
10420 		case FL_Button + FL_LEFT_MOUSE:
10421 			if (Fl::event_clicks()) {
10422 				ifkp_tx_text->add(" ");
10423 				ifkp_tx_text->add(selected_call.c_str());
10424 			}
10425 			break;
10426 		case FL_Button + FL_RIGHT_MOUSE:
10427 			ifkp_heard->remove(heard_picked);
10428 			break;
10429 	}
10430 	restoreFocus();
10431 }
10432 
do_fsq_rx_text(std::string text,int style)10433 static void do_fsq_rx_text(std::string text, int style)
10434 {
10435 	for (size_t n = 0; n < text.length(); n++)
10436 		rx_parser( text[n], style );
10437 }
10438 
display_fsq_rx_text(std::string text,int style)10439 void display_fsq_rx_text(std::string text, int style)
10440 {
10441 	REQ(do_fsq_rx_text, text, style);
10442 }
10443 
display_fsq_mon_text(std::string text,int style)10444 void display_fsq_mon_text(std::string text, int style)
10445 {
10446 	REQ(&FTextRX::addstr, fsq_monitor, text, style);
10447 }
10448 
cbFSQQTC(Fl_Widget * w,void * d)10449 void cbFSQQTC(Fl_Widget *w, void *d)
10450 {
10451 	fsq_tx_text->add(progdefaults.fsqQTCtext.c_str());
10452 	restoreFocus();
10453 }
10454 
cbFSQCQ(Fl_Widget * w,void * d)10455 void cbFSQCQ(Fl_Widget *w, void *d)
10456 {
10457 	fsq_xmt("cqcqcq");
10458 	restoreFocus();
10459 }
10460 
cbFSQQTH(Fl_Widget * w,void * d)10461 void cbFSQQTH(Fl_Widget *w, void *d)
10462 {
10463 	fsq_tx_text->add(progdefaults.myQth.c_str());
10464 	restoreFocus();
10465 }
10466 
cbMONITOR(Fl_Widget * w,void * d)10467 void cbMONITOR(Fl_Widget *w, void *d)
10468 {
10469 	Fl_Light_Button *btn = (Fl_Light_Button *)w;
10470 	if (btn->value() == 1)
10471 		open_fsqMonitor();
10472 	else {
10473 		progStatus.fsqMONITORxpos = fsqMonitor->x();
10474 		progStatus.fsqMONITORypos = fsqMonitor->y();
10475 		progStatus.fsqMONITORwidth = fsqMonitor->w();
10476 		progStatus.fsqMONITORheight = fsqMonitor->h();
10477 		fsqMonitor->hide();
10478 	}
10479 }
10480 
close_fsqMonitor()10481 void close_fsqMonitor()
10482 {
10483 	if (!fsqMonitor) return;
10484 	btn_MONITOR->value(0);
10485 	progStatus.fsqMONITORxpos = fsqMonitor->x();
10486 	progStatus.fsqMONITORypos = fsqMonitor->y();
10487 	progStatus.fsqMONITORwidth = fsqMonitor->w();
10488 	progStatus.fsqMONITORheight = fsqMonitor->h();
10489 	fsqMonitor->hide();
10490 }
10491 
cbSELCAL(Fl_Widget * w,void * d)10492 void cbSELCAL(Fl_Widget *w, void *d)
10493 {
10494 	Fl_Light_Button *btn = (Fl_Light_Button *)w;
10495 	int val = btn->value();
10496 	if (val) {
10497 		btn->label("ACTIVE");
10498 	} else {
10499 		btn->label("ASLEEP");
10500 	}
10501 	btn->redraw_label();
10502 	restoreFocus();
10503 }
10504 
enableSELCAL()10505 void enableSELCAL()
10506 {
10507 	btn_SELCAL->value(1);
10508 	cbSELCAL(btn_SELCAL, (void *)0);
10509 }
10510 
cbFSQCALL(Fl_Widget * w,void * d)10511 void cbFSQCALL(Fl_Widget *w, void *d)
10512 {
10513 	Fl_Light_Button *btn = (Fl_Light_Button *)w;
10514 	int mouse = Fl::event_button();
10515 	int val = btn->value();
10516 	if (mouse == FL_LEFT_MOUSE) {
10517 		progdefaults.fsq_directed = val;
10518 		progdefaults.changed = true;
10519 		if (val == 0) {
10520 			btn_SELCAL->value(0);
10521 			btn_SELCAL->deactivate();
10522 			btn->label("FSQ-OFF");
10523 			btn->redraw_label();
10524 		} else {
10525 			btn_SELCAL->activate();
10526 			btn_SELCAL->value(1);
10527 			cbSELCAL(btn_SELCAL, 0);
10528 			btn->label("FSQ-ON");
10529 			btn->redraw_label();
10530 		}
10531 	}
10532 	restoreFocus();
10533 }
10534 
10535 //======================================================================
10536 //FeldHell resizable Rx character height
10537 //======================================================================
10538 extern pthread_mutex_t feld_mutex;
10539 
FHdisp_char_height()10540 void FHdisp_char_height()
10541 {
10542 	guard_lock raster_lock(&feld_mutex);
10543 
10544 	int rh = progdefaults.HellRcvHeight = (int)valHellRcvHeight->value();
10545 
10546 	rh = FHdisp->change_rowheight(rh);
10547 	if (rh != progdefaults.HellRcvHeight) {
10548 		progdefaults.HellRcvHeight = rh;
10549 		valHellRcvHeight->value(rh);
10550 		valHellRcvHeight->redraw();
10551 		fl_alert2("Selection too large for current Rx height\nIncrease Rx height");
10552 	} else
10553 	progdefaults.changed = true;
10554 
10555 	trx_mode mode = active_modem->get_mode();
10556 	if ( (mode >= MODE_HELL_FIRST) &&
10557 		 (mode <= MODE_HELL_LAST) )
10558 		active_modem->rx_init();
10559 
10560 // adjust upper/lower bounds of Rx/Tx panel
10561 	minhtext = 2 * progdefaults.HellRcvHeight + 4;//6;
10562 	minbox->resize(
10563 			text_panel->x(),
10564 			text_panel->y() + minhtext,
10565 			text_panel->w() - 100,
10566 			text_panel->h() - 2*minhtext);
10567 	minbox->redraw();
10568 
10569 //	UI_select();
10570 
10571 }
10572 
VuMeter_cb(vumeter * vu,void * d)10573 void VuMeter_cb(vumeter *vu, void *d)
10574 {
10575 	VuMeter->hide();
10576 	StatusBar->show();
10577 	progStatus.vumeter_shown = 0;
10578 }
10579 
StatusBar_cb(Fl_Box * bx,void * d)10580 void StatusBar_cb(Fl_Box *bx, void *d)
10581 {
10582 	StatusBar->hide();
10583 	VuMeter->show();
10584 	progStatus.vumeter_shown = 1;
10585 }
10586 
10587 
10588