1 // ----------------------------------------------------------------------------
2 // Copyright (C) 2014
3 //              David Freese, W1HKJ
4 //
5 // This file is part of flmsg
6 //
7 // flrig is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // flrig is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 // ----------------------------------------------------------------------------
20 
21 #include <FL/Fl_Hold_Browser.H>
22 
23 #include "gettext.h"
24 #include "status.h"
25 #include "util.h"
26 
27 #include "flmsg_dialog.h"
28 #include "flmsg.h"
29 #include "fileselect.h"
30 
31 Fl_Group	*tab_mars_net = (Fl_Group *)0;
32 Fl_Tabs		*tab_mars_net_type = (Fl_Tabs *)0;
33 
34 //----------------------------------------------------------------------
35 
36 Fl_Group	*tab_mars_net_1 = (Fl_Group *)0;//
37 
38 Fl_Input2	*txt_mars_net_DE = (Fl_Input2 *)0;//
39 
40 Fl_Input2	*txt_mars_net_NBR = (Fl_Input2 *)0;//
41 Fl_ListBox	*sel_mars_net_PREC = (Fl_ListBox *)0;//
42 Fl_Input2	*txt_mars_net_DTG = (Fl_Input2 *)0;//
43 Fl_Input2	*txt_mars_net_FMNAME = (Fl_Input2 *)0;//
44 Fl_Input2	*txt_mars_net_FMCALL = (Fl_Input2 *)0;//
45 Fl_Input2	*txt_mars_net_FMSTATE = (Fl_Input2 *)0;//
46 Fl_Input2	*txt_mars_net_TOPOS = (Fl_Input2 *)0;//
47 Fl_Input2	*txt_mars_net_TOCALL = (Fl_Input2 *)0;//
48 Fl_Input2	*txt_mars_net_TOSTATE = (Fl_Input2 *)0;//
49 Fl_Input2	*txt_mars_net_INFOPOS = (Fl_Input2 *)0;//
50 Fl_Input2	*txt_mars_net_INFOCALL = (Fl_Input2 *)0;//
51 Fl_Input2	*txt_mars_net_INFOSTATE = (Fl_Input2 *)0;//
52 
53 Fl_Input2	*txt_mars_net_INCIDENT = (Fl_Input2 *)0;//
54 
55 Fl_Input2	*txt_mars_net_DND = (Fl_Input2 *)0;// date net designator
56 Fl_Input2	*txt_mars_net_NETCALL = (Fl_Input2 *)0;//
57 Fl_Input2	*txt_mars_net_DTGSTART = (Fl_Input2 *)0;//
58 Fl_Input2	*txt_mars_net_DTGEND = (Fl_Input2 *)0;//
59 Fl_Input2	*txt_mars_net_NETSB = (Fl_Input2 *)0;//
60 Fl_Input2	*txt_mars_net_NCSCALL = (Fl_Input2 *)0;//
61 Fl_Input2	*txt_mars_net_NBRSTAS = (Fl_Input2 *)0;//
62 Fl_Input2	*txt_mars_net_CALLS = (Fl_Input2 *)0;//
63 Fl_Input2	*txt_mars_net_NBRMSGS = (Fl_Input2 *)0;
64 Fl_Input2	*txt_mars_net_COMMENTS = (Fl_Input2 *)0;
65 
66 Fl_Button	*btn_mars_net_DE = (Fl_Button*)0;
67 Fl_Button	*btn_mars_net_DTG = (Fl_Button*)0;
68 Fl_Button	*btn_mars_net_pick_fm = (Fl_Button*)0;
69 Fl_Button	*btn_mars_net_pick_to = (Fl_Button*)0;
70 Fl_Button	*btn_mars_net_pick_INFO = (Fl_Button*)0;
71 Fl_Button	*btn_mars_net_pick_NETCALL = (Fl_Button*)0;
72 Fl_Button	*btn_mars_net_DTGSTART = (Fl_Button*)0;
73 Fl_Button	*btn_mars_net_DTGEND = (Fl_Button*)0;
74 Fl_Button	*btn_mars_net_pick_NCSCALL = (Fl_Button*)0;
75 Fl_Button	*btn_mars_net_add_calls = (Fl_Button*)0;
76 
77 //----------------------------------------------------------------------
78 
79 Fl_Group	*tab_mars_net_2 = (Fl_Group *)0;
80 
81 // widget callbacks & support
cb_btn_mars_net_DE(Fl_Widget * w,void * d)82 void cb_btn_mars_net_DE(Fl_Widget *w, void *d)
83 {
84 	txt_mars_net_DE->value(progStatus.my_call.c_str());
85 }
86 
cb_btn_mars_net_DTG(Fl_Widget * w,void * d)87 void cb_btn_mars_net_DTG(Fl_Widget *w, void *d)
88 {
89 	txt_mars_net_DTG->value(szMarsDateTime());
90 }
91 
cb_btn_mars_net_pick_fm(Fl_Widget * w,void * d)92 void cb_btn_mars_net_pick_fm(Fl_Widget *w, void *d)
93 {
94 	if (!get_mars_list_text()) return;
95 	txt_mars_net_FMCALL->value(mars_list_call.c_str());
96 	txt_mars_net_FMNAME->value(mars_list_lname.c_str());
97 	txt_mars_net_FMSTATE->value(mars_list_state.c_str());
98 }
99 
cb_btn_mars_net_pick_to(Fl_Widget * w,void * d)100 void cb_btn_mars_net_pick_to(Fl_Widget *w, void *d)
101 {
102 	if (!get_mars_list_text()) return;
103 	txt_mars_net_TOCALL->value(mars_list_bcall.c_str());
104 	txt_mars_net_TOPOS->value(mars_list_position.c_str());
105 	txt_mars_net_TOSTATE->value(mars_list_state.c_str());
106 }
107 
cb_btn_mars_net_pick_INFO(Fl_Widget * w,void * d)108 void cb_btn_mars_net_pick_INFO(Fl_Widget *w, void *d)
109 {
110 	if (!get_mars_list_text()) return;
111 	txt_mars_net_INFOCALL->value(mars_list_bcall.c_str());
112 	txt_mars_net_INFOPOS->value(mars_list_position.c_str());
113 	txt_mars_net_INFOSTATE->value(mars_list_state.c_str());
114 }
115 
cb_btn_mars_net_pick_NETCALL(Fl_Widget * w,void * d)116 void cb_btn_mars_net_pick_NETCALL(Fl_Widget *w, void *d)
117 {
118 	if (!get_mars_list_text()) return;
119 	txt_mars_net_NETCALL->value(mars_list_bcall.c_str());
120 }
121 
cb_btn_mars_net_DTGSTART(Fl_Widget * w,void * d)122 void cb_btn_mars_net_DTGSTART(Fl_Widget *w, void *d)
123 {
124 	txt_mars_net_DTGSTART->value(szMarsDateTime());
125 }
126 
cb_btn_mars_net_DTGEND(Fl_Widget * w,void * d)127 void cb_btn_mars_net_DTGEND(Fl_Widget *w, void *d)
128 {
129 	txt_mars_net_DTGEND->value(szMarsDateTime());
130 }
131 
cb_btn_mars_net_pick_NCSCALL(Fl_Widget * w,void * d)132 void cb_btn_mars_net_pick_NCSCALL(Fl_Widget *w, void *d)
133 {
134 	if (!get_mars_list_text()) return;
135 	txt_mars_net_NCSCALL->value(mars_list_call.c_str());
136 }
137 
cb_btn_mars_net_add_calls(Fl_Widget * w,void * d)138 void cb_btn_mars_net_add_calls(Fl_Widget *w, void *d)
139 {
140 	if (!get_mars_list_text()) return;
141 	string calls = txt_mars_net_CALLS->value();
142 	if (calls.length() && (calls[calls.length()-1] != '\n')) calls.append(" ");
143 	calls.append(mars_list_call);
144 	txt_mars_net_CALLS->value(calls.c_str());
145 }
146 
147 //----------------------------------------------------------------------
148 
create_mars_net()149 void create_mars_net()
150 {
151 	int Y = tab_top;
152 	tab_mars_net = new Fl_Group(0, Y, 570, 355);
153 	tab_mars_net->align(FL_ALIGN_TOP);
154 
155 	tab_mars_net_type = new Fl_Tabs(0, Y+2, 570, 352);
156 	tab_mars_net_type->selection_color((Fl_Color)246);
157 
158 	tab_mars_net_1 = new Fl_Group(0, Y+25, 570, 325, _("Header"));
159 
160 	Y += 30;
161 
162 	txt_mars_net_DE = new Fl_Input2(100, Y, 150, 24, _("DE"));
163 	txt_mars_net_DE->tooltip(_(""));
164 	txt_mars_net_DE->callback((Fl_Callback*)cb_mars_fl_input2);
165 	txt_mars_net_DE->when(FL_WHEN_CHANGED);
166 
167 	btn_mars_net_DE = new Fl_Button(252, Y, 30, 24, _("ME"));
168 	btn_mars_net_DE->callback((Fl_Callback*)cb_btn_mars_net_DE);
169 
170 	txt_mars_net_NBR = new Fl_Input2(370, Y, 150, 24, _("MSG NBR"));
171 	txt_mars_net_NBR->tooltip(_(""));
172 	txt_mars_net_NBR->callback((Fl_Callback*)cb_mars_fl_input2);
173 	txt_mars_net_NBR->when(FL_WHEN_CHANGED);
174 
175 	Y += 25;
176 	sel_mars_net_PREC = new Fl_ListBox(100, Y, 45, 24, _("PREC"));
177 	sel_mars_net_PREC->tooltip(
178 		_("R - Routine\nP - Priority\nO - Immediate\nZ - Flash"));
179 	sel_mars_net_PREC->add("R|P|O|Z");
180 	sel_mars_net_PREC->align(FL_ALIGN_LEFT);
181 	sel_mars_net_PREC->index(0);
182 
183 	txt_mars_net_DTG = new Fl_Input2(185, Y, 150, 24, _("DTG"));
184 	txt_mars_net_DTG->tooltip(_(""));
185 
186 	btn_mars_net_DTG = new Fl_Button(335, Y, 22, 24, _("..."));
187 	btn_mars_net_DTG->tooltip(_("Set Date/Time Group"));
188 	btn_mars_net_DTG->callback((Fl_Callback*)cb_btn_mars_net_DTG);
189 
190 	Y += 25;
191 	txt_mars_net_FMNAME = new Fl_Input2(100, Y, 150, 24, _("FM"));
192 	txt_mars_net_FMNAME->tooltip(_("Name"));
193 	txt_mars_net_FMNAME->callback((Fl_Callback*)cb_mars_fl_input2);
194 	txt_mars_net_FMNAME->when(FL_WHEN_CHANGED);
195 
196 	txt_mars_net_FMCALL = new Fl_Input2(252, Y, 150, 24, _(""));
197 	txt_mars_net_FMCALL->tooltip(_("Call"));
198 	txt_mars_net_FMCALL->callback((Fl_Callback*)cb_mars_fl_input2);
199 	txt_mars_net_FMCALL->when(FL_WHEN_CHANGED);
200 
201 	txt_mars_net_FMSTATE = new Fl_Input2(404, Y, 30, 24, _(""));
202 	txt_mars_net_FMSTATE->tooltip(_("State"));
203 	txt_mars_net_FMSTATE->callback((Fl_Callback*)cb_mars_fl_input2);
204 	txt_mars_net_FMSTATE->when(FL_WHEN_CHANGED);
205 
206 	btn_mars_net_pick_fm = new Fl_Button(436, Y, 30, 24, _("List"));
207 	btn_mars_net_pick_fm->tooltip(_("Select from list"));
208 	btn_mars_net_pick_fm->callback((Fl_Callback*)cb_btn_mars_net_pick_fm);
209 
210 	Y += 25;
211 	txt_mars_net_TOPOS = new Fl_Input2(100, Y, 150, 24, _("TO"));
212 	txt_mars_net_TOPOS->tooltip(_("Position"));
213 	txt_mars_net_TOPOS->callback((Fl_Callback*)cb_mars_fl_input2);
214 	txt_mars_net_TOPOS->when(FL_WHEN_CHANGED);
215 
216 	txt_mars_net_TOCALL = new Fl_Input2(252, Y, 150, 24, _(""));
217 	txt_mars_net_TOCALL->tooltip(_("Call"));
218 	txt_mars_net_TOCALL->callback((Fl_Callback*)cb_mars_fl_input2);
219 	txt_mars_net_TOCALL->when(FL_WHEN_CHANGED);
220 
221 	txt_mars_net_TOSTATE = new Fl_Input2(404, Y, 30, 24, _(""));
222 	txt_mars_net_TOSTATE->tooltip(_("State"));
223 	txt_mars_net_TOSTATE->callback((Fl_Callback*)cb_mars_fl_input2);
224 	txt_mars_net_TOSTATE->when(FL_WHEN_CHANGED);
225 
226 	btn_mars_net_pick_to = new Fl_Button(436, Y, 30, 24, _("List"));
227 	btn_mars_net_pick_to->tooltip(_("Select from list"));
228 	btn_mars_net_pick_to->callback((Fl_Callback*)cb_btn_mars_net_pick_to);
229 
230 	Y += 25;
231 	txt_mars_net_INFOPOS = new Fl_Input2(100, Y, 150, 24, _("INFO"));
232 	txt_mars_net_INFOPOS->tooltip(_("Position"));
233 	txt_mars_net_INFOPOS->callback((Fl_Callback*)cb_mars_fl_input2);
234 	txt_mars_net_INFOPOS->when(FL_WHEN_CHANGED);
235 
236 	txt_mars_net_INFOCALL = new Fl_Input2(252, Y, 150, 24, _(""));
237 	txt_mars_net_INFOCALL->tooltip(_("Call"));
238 	txt_mars_net_INFOCALL->callback((Fl_Callback*)cb_mars_fl_input2);
239 	txt_mars_net_INFOCALL->when(FL_WHEN_CHANGED);
240 
241 	txt_mars_net_INFOSTATE = new Fl_Input2(404, Y, 30, 24, _(""));
242 	txt_mars_net_INFOSTATE->tooltip(_("State"));
243 	txt_mars_net_INFOSTATE->callback((Fl_Callback*)cb_mars_fl_input2);
244 	txt_mars_net_INFOSTATE->when(FL_WHEN_CHANGED);
245 
246 	btn_mars_net_pick_INFO = new Fl_Button(436, Y, 30, 24, _("List"));
247 	btn_mars_net_pick_INFO->tooltip(_("Select from list"));
248 	btn_mars_net_pick_INFO->callback((Fl_Callback*)cb_btn_mars_net_pick_INFO);
249 
250 	Y += 49;
251 	txt_mars_net_INCIDENT = new Fl_Input2(100, Y, 450, 24, _("INCIDENT"));
252 	txt_mars_net_INCIDENT->tooltip(_("Incident\nleave blank for normal ops"));
253 	txt_mars_net_INCIDENT->callback((Fl_Callback*)cb_mars_fl_input2);
254 	txt_mars_net_INCIDENT->when(FL_WHEN_CHANGED);
255 
256 	Y += 49;
257 	txt_mars_net_DND = new Fl_Input2(100, Y, 80, 24, _("NET REPORT"));
258 	txt_mars_net_DND->tooltip(_("date net designator"));
259 	txt_mars_net_DND->callback((Fl_Callback*)cb_mars_fl_input2);
260 	txt_mars_net_DND->when(FL_WHEN_CHANGED);
261 
262 	tab_mars_net_1->end();
263 
264 	tab_mars_net_2 = new Fl_Group(0, 95, 570, 325, _("Body"));
265 
266 	Y = 100;
267 	Fl_Box *label = new Fl_Box(40, Y, 40, 24, "1.");
268 	label->box(FL_FLAT_BOX);
269 	label->align(FL_ALIGN_LEFT);
270 
271 	txt_mars_net_NETCALL = new Fl_Input2(40, Y, 150, 24, "");
272 	txt_mars_net_NETCALL->tooltip(_("net call"));
273 	txt_mars_net_NETCALL->callback((Fl_Callback*)cb_mars_fl_input2);
274 	txt_mars_net_NETCALL->when(FL_WHEN_CHANGED);
275 
276 	btn_mars_net_pick_NETCALL = new Fl_Button(192, Y, 30, 24, _("List"));
277 	btn_mars_net_pick_NETCALL->tooltip(_("Select from list"));
278 	btn_mars_net_pick_NETCALL->callback((Fl_Callback*)cb_btn_mars_net_pick_NETCALL);
279 
280 	Y += 25;
281 	label = new Fl_Box(40, Y, 40, 24, "2.");
282 	label->box(FL_FLAT_BOX);
283 	label->align(FL_ALIGN_LEFT);
284 
285 	txt_mars_net_DTGSTART = new Fl_Input2(40, Y, 150, 24, "");
286 	txt_mars_net_DTGSTART->tooltip(_("DTG start"));
287 
288 	btn_mars_net_DTGSTART = new Fl_Button(192, Y, 22, 24, _("..."));
289 	btn_mars_net_DTGSTART->tooltip(_("Set Date/Time Group"));
290 	btn_mars_net_DTGSTART->callback((Fl_Callback*)cb_btn_mars_net_DTGSTART);
291 
292 	txt_mars_net_DTGEND = new Fl_Input2(220, Y, 150, 24, _(""));
293 	txt_mars_net_DTGEND->tooltip(_("DTG end"));
294 
295 	btn_mars_net_DTGEND = new Fl_Button(372, Y, 22, 24, _("..."));
296 	btn_mars_net_DTGEND->tooltip(_("Set Date/Time Group"));
297 	btn_mars_net_DTGEND->callback((Fl_Callback*)cb_btn_mars_net_DTGEND);
298 
299 	Y += 25;
300 	label = new Fl_Box(40, Y, 40, 24, "3.");
301 	label->box(FL_FLAT_BOX);
302 	label->align(FL_ALIGN_LEFT);
303 
304 	txt_mars_net_NETSB = new Fl_Input2(40, Y, 80, 24, "");
305 	txt_mars_net_NETSB->tooltip(_("USB / LSB"));
306 	txt_mars_net_NETSB->callback((Fl_Callback*)cb_mars_fl_input2);
307 	txt_mars_net_NETSB->when(FL_WHEN_CHANGED);
308 
309 	Y += 25;
310 	label = new Fl_Box(40, Y, 40, 24, "4.");
311 	label->box(FL_FLAT_BOX);
312 	label->align(FL_ALIGN_LEFT);
313 
314 	txt_mars_net_NCSCALL = new Fl_Input2(40, Y, 150, 24, "");
315 	txt_mars_net_NCSCALL->tooltip(_("net call"));
316 	txt_mars_net_NCSCALL->callback((Fl_Callback*)cb_mars_fl_input2);
317 	txt_mars_net_NCSCALL->when(FL_WHEN_CHANGED);
318 
319 	btn_mars_net_pick_NCSCALL = new Fl_Button(192, Y, 30, 24, _("List"));
320 	btn_mars_net_pick_NCSCALL->tooltip(_("Select from list"));
321 	btn_mars_net_pick_NCSCALL->callback((Fl_Callback*)cb_btn_mars_net_pick_NCSCALL);
322 
323 	Y += 25;
324 	label = new Fl_Box(40, Y, 40, 24, "5.");
325 	label->box(FL_FLAT_BOX);
326 	label->align(FL_ALIGN_LEFT);
327 
328 	txt_mars_net_NBRSTAS = new Fl_Input2(40, Y, 120, 24, "");
329 	txt_mars_net_NBRSTAS->tooltip(_("# stations IN NET"));
330 
331 	btn_mars_net_add_calls = new Fl_Button(480, Y, 80, 24, _("Add Call"));
332 	btn_mars_net_add_calls->tooltip(_("Add from list"));
333 	btn_mars_net_add_calls->callback((Fl_Callback*)cb_btn_mars_net_add_calls);
334 
335 	Y += 25;
336 	txt_mars_net_CALLS = new Fl_Input2(40, Y, 520, 72, "");
337 	txt_mars_net_CALLS->tooltip(_("Station calls\nstarting with alternate NCS"));
338 	txt_mars_net_CALLS->type(4);
339 	txt_mars_net_CALLS->callback((Fl_Callback*)cb_mars_fl_input2);
340 	txt_mars_net_CALLS->when(FL_WHEN_CHANGED);
341 
342 	Y += 73;
343 	label = new Fl_Box(40, Y, 40, 24, "6.");
344 	label->box(FL_FLAT_BOX);
345 	label->align(FL_ALIGN_LEFT);
346 	label = new Fl_Box(40, Y, 2, 24, "N/A");
347 	label->box(FL_FLAT_BOX);
348 	label->align(FL_ALIGN_RIGHT);
349 
350 	Y += 25;
351 	label = new Fl_Box(40, Y, 40, 24, "7. A.");
352 	label->box(FL_FLAT_BOX);
353 	label->align(FL_ALIGN_LEFT);
354 
355 	txt_mars_net_NBRMSGS = new Fl_Input2(40, Y, 120, 24, "");
356 	txt_mars_net_NBRMSGS->tooltip(_("# messages"));
357 
358 	Y += 25;
359 	label = new Fl_Box(40, Y, 40, 24, "B.");
360 	label->box(FL_FLAT_BOX);
361 	label->align(FL_ALIGN_LEFT);
362 
363 	txt_mars_net_COMMENTS = new Fl_Input2(40, Y, 520, 72, "");
364 	txt_mars_net_COMMENTS->tooltip(_("Comments"));
365 	txt_mars_net_COMMENTS->type(4);
366 	txt_mars_net_COMMENTS->callback((Fl_Callback*)cb_mars_fl_input2);
367 	txt_mars_net_COMMENTS->when(FL_WHEN_CHANGED);
368 
369 	tab_mars_net_2->end();
370 
371 //	tab_mars_type->end();
372 
373 	tab_mars_net->end();
374 
375 	tab_mars_net->hide();
376 };
377 
378