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 "gettext.h"
22 #include "status.h"
23 #include "util.h"
24 
25 #include "flmsg_dialog.h"
26 #include "flmsg.h"
27 
28 Fl_Group	*tab_cap110 = (Fl_Group *)0;
29 Fl_Tabs		*tab_cap110_type = (Fl_Tabs *)0;
30 
31 Fl_Input2	*txt_110_mission_nbr = (Fl_Input2 *)0;
32 Fl_Input2	*txt_110_station = (Fl_Input2 *)0;
33 Fl_Input2	*txt_110_date = (Fl_Input2 *)0;
34 Fl_Button	*btn_110_date = (Fl_Button *)0;
35 Fl_Group	*desig_src = (Fl_Group *)0;
36 Fl_Input2	*txt_110_ds_a = (Fl_Input2 *)0;
37 Fl_Input2	*txt_110_ds_b = (Fl_Input2 *)0;
38 Fl_Input2	*txt_110_ds_c = (Fl_Input2 *)0;
39 Fl_Input2	*txt_110_ds_d = (Fl_Input2 *)0;
40 Fl_Input2	*txt_110_ds_e = (Fl_Input2 *)0;
41 Fl_Input2	*txt_110_ds_f = (Fl_Input2 *)0;
42 
43 Fl_Input2	*txt_110_comm_time[23] = {(Fl_Input2 *)0};
44 Fl_Button	*btn_110_comm_time[23] = {(Fl_Button *)0};
45 Fl_Input2	*txt_110_comm_call[23] = {(Fl_Input2 *)0};
46 Fl_Input2	*txt_110_comm_chref[23]  = {(Fl_Input2 *)0};
47 Fl_Input2	*txt_110_comm_rem[23]   = {(Fl_Input2 *)0};
48 
49 int cap_bptr[23] = {\
50  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, \
51 10,11,12,13,14,15,16,17,18,19, \
52 20,21,22 };
53 
cap110_changed(Fl_Widget * w,void *)54 void cap110_changed(Fl_Widget *w, void *)
55 {
56 	Fl_Input2 *inp = (Fl_Input2 *)w;
57 	string s = inp->value();
58 	int len = s.length();
59 	int maxlen = 1000;
60 	if (inp == txt_110_mission_nbr) maxlen = 14;
61 	else if (inp == txt_110_station) maxlen = 48;
62 	else if (inp == txt_110_ds_a) maxlen = 12;
63 	else if (inp == txt_110_ds_b) maxlen = 12;
64 	else if (inp == txt_110_ds_c) maxlen = 12;
65 	else if (inp == txt_110_ds_d) maxlen = 12;
66 	else if (inp == txt_110_ds_e) maxlen = 12;
67 	else if (inp == txt_110_ds_f) maxlen = 12;
68 	else for (int i = 0; i < 23; i++) {
69 		if (inp == txt_110_comm_chref[i]) { maxlen = 6; break; }
70 		if (inp == txt_110_comm_call[i]) { maxlen = 10; break; }
71 		if (inp == txt_110_comm_time[i]) { maxlen = 8; break; }
72 		if (inp == txt_110_comm_rem[i]) { maxlen = 53; break; }
73 	}
74 	if (len > maxlen) { s.erase(len-1); inp->value(s.c_str()); }
75 	estimate();
76 }
77 
cb_110_comm_time_changed(Fl_Widget * w,void * d)78 void cb_110_comm_time_changed(Fl_Widget *w, void *d)
79 {
80 	int p = *(int *)d;
81 	txt_110_comm_time[p]->value(szTime(progStatus.UTC) );
82 	cap110_changed(txt_110_comm_time[p], d);
83 }
84 
create_cap110_tab()85 void create_cap110_tab()
86 {
87 	int Y = tab_top;
88 	tab_cap110 = new Fl_Group(0, Y, 570, 380);
89 	tab_cap110->align(FL_ALIGN_TOP);
90 
91 		Y += 24;
92 		txt_110_mission_nbr = new Fl_Input2(5, Y, 110, 24, _("Mission #"));
93 		txt_110_mission_nbr->tooltip(_(""));
94 		txt_110_mission_nbr->box(FL_DOWN_BOX);
95 		txt_110_mission_nbr->color((Fl_Color)FL_BACKGROUND2_COLOR);
96 		txt_110_mission_nbr->selection_color((Fl_Color)FL_SELECTION_COLOR);
97 		txt_110_mission_nbr->labeltype(FL_NORMAL_LABEL);
98 		txt_110_mission_nbr->labelfont(0);
99 		txt_110_mission_nbr->labelsize(13);
100 		txt_110_mission_nbr->textsize(11);
101 		txt_110_mission_nbr->labelcolor((Fl_Color)FL_FOREGROUND_COLOR);
102 		txt_110_mission_nbr->align(FL_ALIGN_TOP_LEFT);
103 		txt_110_mission_nbr->callback(cap110_changed);
104 		txt_110_mission_nbr->when(FL_WHEN_CHANGED);
105 
106 		txt_110_station = new Fl_Input2(117, Y, 350, 24, _("Station Functional Desc."));
107 		txt_110_station->tooltip(_(""));
108 		txt_110_station->box(FL_DOWN_BOX);
109 		txt_110_station->color((Fl_Color)FL_BACKGROUND2_COLOR);
110 		txt_110_station->selection_color((Fl_Color)FL_SELECTION_COLOR);
111 		txt_110_station->labeltype(FL_NORMAL_LABEL);
112 		txt_110_station->labelfont(0);
113 		txt_110_station->labelsize(13);
114 		txt_110_station->textsize(11);
115 		txt_110_station->labelcolor((Fl_Color)FL_FOREGROUND_COLOR);
116 		txt_110_station->align(FL_ALIGN_TOP_LEFT);
117 		txt_110_station->callback(cap110_changed);
118 		txt_110_station->when(FL_WHEN_CHANGED);
119 
120 		txt_110_date = new Fl_Input2(469, Y, 70, 24, _("Date"));
121 		txt_110_date->tooltip(_("Report date"));
122 		txt_110_date->box(FL_DOWN_BOX);
123 		txt_110_date->color((Fl_Color)FL_BACKGROUND2_COLOR);
124 		txt_110_date->selection_color((Fl_Color)FL_SELECTION_COLOR);
125 		txt_110_date->labeltype(FL_NORMAL_LABEL);
126 		txt_110_date->labelfont(0);
127 		txt_110_date->labelsize(13);
128 		txt_110_date->textsize(11);
129 		txt_110_date->labelcolor((Fl_Color)FL_FOREGROUND_COLOR);
130 		txt_110_date->align(FL_ALIGN_TOP_LEFT);
131 		txt_110_date->callback(cap110_changed);
132 		txt_110_date->when(FL_WHEN_CHANGED);
133 
134 		btn_110_date = new Fl_Button(542, Y, 20, 20, _("..."));
135 		btn_110_date->tooltip(_("Set today"));
136 		btn_110_date->callback((Fl_Callback*)cap110_set_date);
137 
138 		Y += 30;
139 		desig_src = new Fl_Group(2, Y, 566, 60, _("DESIGNATOR/SOURCE"));
140 		{
141 			desig_src->box(FL_FLAT_BOX);
142 			desig_src->align (FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_TOP);
143 			desig_src->labelfont(0);
144 			desig_src->labelsize(13);
145 
146 			Y += 34;
147 			txt_110_ds_a = new Fl_Input2(10, Y, 90, 24, _("A"));
148 			txt_110_ds_a->tooltip(_("Designator/Source A"));
149 			txt_110_ds_a->box(FL_DOWN_BOX);
150 			txt_110_ds_a->color((Fl_Color)FL_BACKGROUND2_COLOR);
151 			txt_110_ds_a->selection_color((Fl_Color)FL_SELECTION_COLOR);
152 			txt_110_ds_a->labeltype(FL_NORMAL_LABEL);
153 			txt_110_ds_a->labelfont(0);
154 			txt_110_ds_a->labelsize(13);
155 			txt_110_ds_a->textsize(11);
156 			txt_110_ds_a->labelcolor((Fl_Color)FL_FOREGROUND_COLOR);
157 			txt_110_ds_a->align(FL_ALIGN_TOP_LEFT);
158 			txt_110_ds_a->callback(cap110_changed);
159 			txt_110_ds_a->when(FL_WHEN_CHANGED);
160 
161 			txt_110_ds_b = new Fl_Input2(102, Y, 90, 24, _("B"));
162 			txt_110_ds_b->tooltip(_("Designator/Source B"));
163 			txt_110_ds_b->box(FL_DOWN_BOX);
164 			txt_110_ds_b->color((Fl_Color)FL_BACKGROUND2_COLOR);
165 			txt_110_ds_b->selection_color((Fl_Color)FL_SELECTION_COLOR);
166 			txt_110_ds_b->labeltype(FL_NORMAL_LABEL);
167 			txt_110_ds_b->labelfont(0);
168 			txt_110_ds_b->labelsize(13);
169 			txt_110_ds_b->textsize(11);
170 			txt_110_ds_b->labelcolor((Fl_Color)FL_FOREGROUND_COLOR);
171 			txt_110_ds_b->align(FL_ALIGN_TOP_LEFT);
172 			txt_110_ds_b->callback(cap110_changed);
173 			txt_110_ds_b->when(FL_WHEN_CHANGED);
174 
175 			txt_110_ds_c = new Fl_Input2(194, Y, 90, 24, _("C"));
176 			txt_110_ds_c->tooltip(_("Designator/Source C"));
177 			txt_110_ds_c->box(FL_DOWN_BOX);
178 			txt_110_ds_c->color((Fl_Color)FL_BACKGROUND2_COLOR);
179 			txt_110_ds_c->selection_color((Fl_Color)FL_SELECTION_COLOR);
180 			txt_110_ds_c->labeltype(FL_NORMAL_LABEL);
181 			txt_110_ds_c->labelfont(0);
182 			txt_110_ds_c->labelsize(13);
183 			txt_110_ds_c->textsize(11);
184 			txt_110_ds_c->labelcolor((Fl_Color)FL_FOREGROUND_COLOR);
185 			txt_110_ds_c->align(FL_ALIGN_TOP_LEFT);
186 			txt_110_ds_c->callback(cap110_changed);
187 			txt_110_ds_c->when(FL_WHEN_CHANGED);
188 
189 			txt_110_ds_d = new Fl_Input2(286, Y, 90, 24, _("D"));
190 			txt_110_ds_d->tooltip(_("Designator/Source D"));
191 			txt_110_ds_d->box(FL_DOWN_BOX);
192 			txt_110_ds_d->color((Fl_Color)FL_BACKGROUND2_COLOR);
193 			txt_110_ds_d->selection_color((Fl_Color)FL_SELECTION_COLOR);
194 			txt_110_ds_d->labeltype(FL_NORMAL_LABEL);
195 			txt_110_ds_d->labelfont(0);
196 			txt_110_ds_d->labelsize(13);
197 			txt_110_ds_d->textsize(11);
198 			txt_110_ds_d->labelcolor((Fl_Color)FL_FOREGROUND_COLOR);
199 			txt_110_ds_d->align(FL_ALIGN_TOP_LEFT);
200 			txt_110_ds_d->callback(cap110_changed);
201 			txt_110_ds_d->when(FL_WHEN_CHANGED);
202 
203 			txt_110_ds_e = new Fl_Input2(378, Y, 90, 24, _("E"));
204 			txt_110_ds_e->tooltip(_("Designator/Source E"));
205 			txt_110_ds_e->box(FL_DOWN_BOX);
206 			txt_110_ds_e->color((Fl_Color)FL_BACKGROUND2_COLOR);
207 			txt_110_ds_e->selection_color((Fl_Color)FL_SELECTION_COLOR);
208 			txt_110_ds_e->labeltype(FL_NORMAL_LABEL);
209 			txt_110_ds_e->labelfont(0);
210 			txt_110_ds_e->labelsize(13);
211 			txt_110_ds_e->textsize(11);
212 			txt_110_ds_e->labelcolor((Fl_Color)FL_FOREGROUND_COLOR);
213 			txt_110_ds_e->align(FL_ALIGN_TOP_LEFT);
214 			txt_110_ds_e->callback(cap110_changed);
215 			txt_110_ds_e->when(FL_WHEN_CHANGED);
216 
217 			txt_110_ds_f = new Fl_Input2(470, Y, 90, 24, _("F"));
218 			txt_110_ds_f->tooltip(_("Designator/Source F"));
219 			txt_110_ds_f->box(FL_DOWN_BOX);
220 			txt_110_ds_f->color((Fl_Color)FL_BACKGROUND2_COLOR);
221 			txt_110_ds_f->selection_color((Fl_Color)FL_SELECTION_COLOR);
222 			txt_110_ds_f->labeltype(FL_NORMAL_LABEL);
223 			txt_110_ds_f->labelfont(0);
224 			txt_110_ds_f->labelsize(13);
225 			txt_110_ds_f->textsize(11);
226 			txt_110_ds_f->labelcolor((Fl_Color)FL_FOREGROUND_COLOR);
227 			txt_110_ds_f->align(FL_ALIGN_TOP_LEFT);
228 			txt_110_ds_f->callback(cap110_changed);
229 			txt_110_ds_f->when(FL_WHEN_CHANGED);
230 
231 		desig_src->end();
232 		}
233 
234 		Y += 36;
235 		Fl_Group *g1a = new Fl_Group(2, Y, 566, 260);
236 
237 		Fl_Box* bx1 = new Fl_Box(2, Y, 85, 20, _("TIME"));
238 		bx1->box(FL_DOWN_BOX);
239 		bx1->labelsize(13);
240 		bx1->color((Fl_Color)215);
241 
242 		Fl_Box* bx2 = new Fl_Box(bx1->x() + bx1->w(), Y, 75, 20, _("CALL"));
243 		bx2->box(FL_DOWN_BOX);
244 		bx2->labelsize(13);
245 		bx2->color((Fl_Color)215);
246 
247 		Fl_Box* bx3 = new Fl_Box(bx2->x() + bx2->w(), Y, 50, 20, _("CH REF"));
248 		bx3->box(FL_DOWN_BOX);
249 		bx3->labelsize(13);
250 		bx3->color((Fl_Color)215);
251 
252 		Fl_Box* bx4 = new Fl_Box(bx3->x() + bx3->w(), Y, 340, 20, _("REMARKS"));
253 		bx4->box(FL_DOWN_BOX);
254 		bx4->labelsize(13);
255 		bx4->color((Fl_Color)215);
256 
257 		Y += 22;
258 		Fl_Scroll* scrl = new Fl_Scroll(2, Y, 566, 240);
259 		scrl->type(Fl_Scroll::VERTICAL_ALWAYS);
260 			scrl->box(FL_DOWN_BOX);
261 //			scrl->color((Fl_Color)215);
262 			for (int i = 0; i < 23; i++) {
263 				txt_110_comm_time[i] = new Fl_Input2(2, Y + i*22, 65, 22);
264 				txt_110_comm_time[i]->tooltip(_(""));
265 				txt_110_comm_time[i]->callback(cap110_changed);
266 				txt_110_comm_time[i]->when(FL_WHEN_CHANGED);
267 
268 				btn_110_comm_time[i] = new Fl_Button(
269 					txt_110_comm_time[i]->x() + txt_110_comm_time[i]->w(), Y + i*22,
270 					20, 22, _(".."));
271 				btn_110_comm_time[i]->tooltip(_("Set time now"));
272 				btn_110_comm_time[i]->callback(
273 									cb_110_comm_time_changed, (void *)&cap_bptr[i]);
274 
275 
276 				txt_110_comm_call[i] = new Fl_Input2(
277 					btn_110_comm_time[i]->x() + btn_110_comm_time[i]->w(), Y + i*22,
278 					75, 22, "");
279 				txt_110_comm_call[i]->tooltip(_(""));
280 				txt_110_comm_call[i]->callback(cap110_changed);
281 				txt_110_comm_call[i]->when(FL_WHEN_CHANGED);
282 
283 				txt_110_comm_chref[i] = new Fl_Input2(
284 					txt_110_comm_call[i]->x() + txt_110_comm_call[i]->w(), Y + i*22,
285 					50, 22);
286 				txt_110_comm_chref[i]->tooltip(_(""));
287 				txt_110_comm_chref[i]->callback(cap110_changed);
288 				txt_110_comm_chref[i]->when(FL_WHEN_CHANGED);
289 
290 				txt_110_comm_rem[i] = new Fl_Input2(
291 					txt_110_comm_chref[i]->x() + txt_110_comm_chref[i]->w(), Y + i*22,
292 					340, 22);
293 				txt_110_comm_rem[i]->tooltip(_(""));
294 				txt_110_comm_rem[i]->callback(cap110_changed);
295 				txt_110_comm_rem[i]->when(FL_WHEN_CHANGED);
296 			}
297 			scrl->end();
298 		g1a->end();
299 
300 		Fl_Group *g1b = new Fl_Group(569, Y, 2, 260);
301 		g1b->box(FL_FLAT_BOX);
302 		g1b->end();
303 
304 	tab_cap110->end();
305 	tab_cap110->resizable(g1b);
306 
307 	tab_cap110->hide();
308 }
309 
310