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 #include "fileselect.h"
28 #include "calendar.h"
29 
30 Fl_Group	*tab_severe_wx = (Fl_Group *)0;
31 Fl_Tabs		*tab_severe_wx_type = (Fl_Tabs *)0;
32 
33 Fl_Group	*tab_severe_wx_1 = (Fl_Group *)0;
34 
35 Fl_DateInput	*w_severe_wx_date = (Fl_DateInput *)0;
36 Fl_Input2	*w_severe_wx_time = (Fl_Input2 *)0;
37 Fl_Button	*w_severe_wx_btn_time = (Fl_Button *)0;
38 Fl_ListBox *w_severe_wx_zone = (Fl_ListBox *)0;
39 
40 Fl_Check_Button *w_severe_wx_meas = (Fl_Check_Button *)0;
41 Fl_Check_Button *w_severe_wx_est = (Fl_Check_Button *)0;
42 
43 Fl_ListBox	*w_severe_wx_state = (Fl_ListBox *)0;
44 Fl_ListBox	*w_severe_wx_county = (Fl_ListBox *)0;
45 Fl_Input2	*w_severe_wx_city = (Fl_Input2 *)0;
46 Fl_Button	*use_default = (Fl_Button *)0;
47 Fl_Button	*make_default = (Fl_Button *)0;
48 
49 Fl_Input2	*w_severe_wx_wind_speed = (Fl_Input2 *)0;
50 Fl_ListBox	*w_severe_wx_hail_size = (Fl_ListBox *)0;
51 
52 Fl_Check_Button *w_severe_wx_exact = (Fl_Check_Button *)0;
53 Fl_Check_Button *w_severe_wx_not_exact = (Fl_Check_Button *)0;
54 Fl_Check_Button *w_severe_wx_tornado = (Fl_Check_Button *)0;
55 Fl_Check_Button *w_severe_wx_funnel_cloud = (Fl_Check_Button *)0;
56 Fl_Check_Button *w_severe_wx_wall_cloud = (Fl_Check_Button *)0;
57 Fl_Check_Button *w_severe_wx_hail = (Fl_Check_Button *)0;
58 Fl_Check_Button *w_severe_wx_high_wind = (Fl_Check_Button *)0;
59 Fl_Check_Button *w_severe_wx_measured = (Fl_Check_Button *)0;
60 Fl_Check_Button *w_severe_wx_estimated = (Fl_Check_Button *)0;
61 Fl_Check_Button *w_severe_wx_flood = (Fl_Check_Button *)0;
62 Fl_Check_Button *w_severe_wx_flash_flood = (Fl_Check_Button *)0;
63 Fl_Check_Button *w_severe_wx_other = (Fl_Check_Button *)0;
64 Fl_Check_Button *w_severe_wx_dmg_yes = (Fl_Check_Button *)0;
65 Fl_Check_Button *w_severe_wx_dmg_no = (Fl_Check_Button *)0;
66 Fl_Check_Button *w_severe_wx_inj_yes = (Fl_Check_Button *)0;
67 Fl_Check_Button *w_severe_wx_inj_no = (Fl_Check_Button *)0;
68 
69 Fl_Group	*tab_severe_wx_2 = (Fl_Group *)0;
70 FTextEdit	*w_severe_wx_narrative = (FTextEdit *)0;
71 
72 //----------------------------------------------------------------------
73 
74 // widget callbacks & support
75 
76 //----------------------------------------------------------------------
77 
cb_btn_time(Fl_Button *,void *)78 static void cb_btn_time(Fl_Button*, void*) {
79 	w_severe_wx_time->value(szTime(7));
80 }
81 
cb_exact(Fl_Check_Button *,void *)82 static void cb_exact(Fl_Check_Button*, void*)
83 {
84 	w_severe_wx_not_exact->value(!w_severe_wx_exact->value());
85 	estimate();
86 }
87 
cb_not_exact(Fl_Check_Button *,void *)88 static void cb_not_exact(Fl_Check_Button*, void*)
89 {
90 	w_severe_wx_exact->value(!w_severe_wx_not_exact->value());
91 	estimate();
92 }
93 
cb_severe_wx_measured(Fl_Check_Button *,void *)94 static void cb_severe_wx_measured(Fl_Check_Button*, void*)
95 {
96 	w_severe_wx_estimated->value(!w_severe_wx_measured->value());
97 	estimate();
98 }
99 
cb_severe_wx_estimated(Fl_Check_Button *,void *)100 static void cb_severe_wx_estimated(Fl_Check_Button*, void*)
101 {
102 	w_severe_wx_measured->value(!w_severe_wx_estimated->value());
103 	estimate();
104 }
105 
cb_dmg_yes(Fl_Check_Button *,void *)106 static void cb_dmg_yes(Fl_Check_Button*, void*)
107 {
108 	w_severe_wx_dmg_no->value(!w_severe_wx_dmg_yes->value());
109 	estimate();
110 }
111 
cb_dmg_no(Fl_Check_Button *,void *)112 static void cb_dmg_no(Fl_Check_Button*, void*)
113 {
114 	w_severe_wx_dmg_yes->value(!w_severe_wx_dmg_no->value());
115 	estimate();
116 }
117 
cb_inj_yes(Fl_Check_Button *,void *)118 static void cb_inj_yes(Fl_Check_Button*, void*)
119 {
120 	w_severe_wx_inj_no->value(!w_severe_wx_inj_yes->value());
121 	estimate();
122 }
123 
cb_inj_no(Fl_Check_Button *,void *)124 static void cb_inj_no(Fl_Check_Button*, void*)
125 {
126 	w_severe_wx_inj_yes->value(!w_severe_wx_inj_no->value());
127 	estimate();
128 }
129 
cb_make_default(Fl_Button *,void *)130 static void cb_make_default(Fl_Button*, void*)
131 {
132 	progStatus.swx_index_default_county = w_severe_wx_county->index();
133 	progStatus.swx_index_default_state = w_severe_wx_state->index();
134 	progStatus.swx_default_city = w_severe_wx_city->value();
135 	progStatus.swx_default_zone = w_severe_wx_zone->value();
136 }
137 
cb_use_default(Fl_Button *,void *)138 static void cb_use_default(Fl_Button*, void*)
139 {
140 	w_severe_wx_state->index(progStatus.swx_index_default_state);
141 	set_severe_wx_counties(progStatus.swx_index_default_state);
142 	w_severe_wx_county->index(progStatus.swx_index_default_county);
143 	w_severe_wx_city->value(progStatus.swx_default_city.c_str());
144 	w_severe_wx_zone->value(progStatus.swx_default_zone.c_str());
145 }
146 
severe_wx_changed(Fl_Widget *,void *)147 void severe_wx_changed(Fl_Widget *, void *)
148 {
149 	estimate();
150 }
151 
cb_state(Fl_Widget *,void *)152 void cb_state(Fl_Widget *, void *)
153 {
154 	int n = w_severe_wx_state->index();
155 	set_severe_wx_counties(n);
156 	estimate();
157 }
158 
cb_hail_changed(Fl_Widget *,void *)159 void cb_hail_changed(Fl_Widget *, void *)
160 {
161 	w_severe_wx_hail_size->index(0);
162 	if (w_severe_wx_hail->value())
163 		w_severe_wx_hail_size->activate();
164 	else
165 		w_severe_wx_hail_size->deactivate();
166 }
167 
create_severe_wx_tab()168 void create_severe_wx_tab()
169 {
170 	int Y = tab_top;
171 	tab_severe_wx = new Fl_Group(0, Y, 570, 390, "tab_severe_wx");
172 	tab_severe_wx->begin();
173 	tab_severe_wx->copy_label("");
174 	tab_severe_wx->align(FL_ALIGN_INSIDE);
175 
176 	tab_severe_wx_type = new Fl_Tabs(0, Y+2, 570, 387, "wx_tabs");
177 	tab_severe_wx_type->selection_color((Fl_Color)246);
178 	tab_severe_wx_type->copy_label("");
179 	tab_severe_wx_type->align(FL_ALIGN_INSIDE);
180 
181 	tab_severe_wx_1 = new Fl_Group(0, Y+25, 570, 360, "Report");
182 	tab_severe_wx_1->begin();
183 
184 	Y += 35;
185 
186 	w_severe_wx_date = new Fl_DateInput(50, Y, 140, 22, _("Date"));
187 	w_severe_wx_date->tooltip(_("Observation date : month/day/year"));
188 	w_severe_wx_date->callback(severe_wx_changed);
189 	w_severe_wx_date->box(FL_DOWN_BOX);
190 	w_severe_wx_date->color((Fl_Color)FL_BACKGROUND2_COLOR);
191 	w_severe_wx_date->selection_color((Fl_Color)FL_SELECTION_COLOR);
192 	w_severe_wx_date->labeltype(FL_NORMAL_LABEL);
193 	w_severe_wx_date->labelfont(0);
194 	w_severe_wx_date->labelsize(14);
195 	w_severe_wx_date->labelcolor((Fl_Color)FL_FOREGROUND_COLOR);
196 	w_severe_wx_date->when(FL_WHEN_RELEASE);
197 	w_severe_wx_date->align(FL_ALIGN_LEFT);
198 	w_severe_wx_date->local_datetime();
199 
200 	w_severe_wx_time = new Fl_Input2(230, Y, 60, 22, _("Time"));
201 	w_severe_wx_time->tooltip(_("Observation time : HHMM"));
202 	w_severe_wx_time->callback(severe_wx_changed);
203 	w_severe_wx_time->when(FL_WHEN_RELEASE);
204 	w_severe_wx_time->align(FL_ALIGN_LEFT);
205 
206 	w_severe_wx_btn_time = new Fl_Button(292, Y, 22, 22, _("..."));
207 	w_severe_wx_btn_time->tooltip(_("Current local time"));
208 	w_severe_wx_btn_time->callback((Fl_Callback*)cb_btn_time);
209 
210 	w_severe_wx_zone = new Fl_ListBox(316, Y, 80, 22, "Zone");
211 	w_severe_wx_zone->copy_label(_(""));
212 	w_severe_wx_zone->align(FL_ALIGN_TOP || FL_ALIGN_INSIDE);
213 	w_severe_wx_zone->tooltip(_("Time Zone, ie: EDT"));
214 	w_severe_wx_zone->when(FL_WHEN_RELEASE);
215 	w_severe_wx_zone->align(FL_ALIGN_RIGHT);
216 	for (int n = 0; n < num_us_tzones; n++)
217 		w_severe_wx_zone->add(us_tzones[n].c_str());
218 	w_severe_wx_zone->callback(severe_wx_changed);
219 
220 	w_severe_wx_exact = new Fl_Check_Button(410, Y, 22, 22, "");
221 	w_severe_wx_exact->copy_label(_("Meas."));
222 	w_severe_wx_exact->tooltip(_("Date time exact"));
223 	w_severe_wx_exact->callback((Fl_Callback*)cb_exact);
224 
225 	w_severe_wx_not_exact = new Fl_Check_Button(480, Y, 22, 22, "");
226 	w_severe_wx_not_exact->copy_label(_("Est."));
227 	w_severe_wx_not_exact->tooltip(_("Date time estimated"));
228 	w_severe_wx_not_exact->callback((Fl_Callback*)cb_not_exact);
229 
230 	Y += 25;
231 	w_severe_wx_state = new Fl_ListBox(125, Y, 400, 22, "State");
232 	w_severe_wx_state->copy_label(_("State/Province"));
233 	w_severe_wx_state->tooltip(_("Select state / province"));
234 	w_severe_wx_state->align(FL_ALIGN_LEFT);
235 	w_severe_wx_state->when(FL_WHEN_RELEASE);
236 	w_severe_wx_state->callback((Fl_Callback*)cb_state);
237 
238 	Y += 25;
239 	w_severe_wx_county = new Fl_ListBox(125, Y, 400, 22, "County");
240 	w_severe_wx_county->copy_label(_("County"));
241 	w_severe_wx_county->tooltip(_("Select county"));
242 	w_severe_wx_county->align(FL_ALIGN_LEFT);
243 	w_severe_wx_county->when(FL_WHEN_RELEASE);
244 	w_severe_wx_county->callback((Fl_Callback*)severe_wx_changed);
245 
246 	Y += 25;
247 	w_severe_wx_city = new Fl_Input2(50, Y, 250, 22, "City");
248 	w_severe_wx_city->copy_label(_("City"));
249 	w_severe_wx_city->tooltip(_("Enter city/town"));
250 	w_severe_wx_city->align(FL_ALIGN_LEFT);
251 	w_severe_wx_city->when(FL_WHEN_RELEASE);
252 	w_severe_wx_city->callback((Fl_Callback*)severe_wx_changed);
253 
254 	make_default = new Fl_Button(410, Y, 70, 24, _("Store"));
255 	make_default->tooltip(_("Store state/county/city/time-zone as default"));
256 	make_default->callback((Fl_Callback*)cb_make_default);
257 
258 	use_default = new Fl_Button(485, Y, 70, 24, _("Default"));
259 	use_default->tooltip(_("Use default state/province/county/city/time-zone"));
260 	use_default->callback((Fl_Callback*)cb_use_default);
261 
262 	Y += 35;
263 	w_severe_wx_tornado = new Fl_Check_Button(50, Y, 150, 22, _("Tornado"));
264 	w_severe_wx_tornado->tooltip(_("Report tornado sighting"));
265 	w_severe_wx_tornado->callback((Fl_Callback*)severe_wx_changed);
266 
267 	Y += 25;
268 	w_severe_wx_funnel_cloud = new Fl_Check_Button(50, Y, 150, 22, _("Funnel cloud"));
269 	w_severe_wx_funnel_cloud->tooltip(_("Report funnel cloud sighting"));
270 	w_severe_wx_funnel_cloud->callback((Fl_Callback*)severe_wx_changed);
271 
272 	Y += 25;
273 	w_severe_wx_wall_cloud = new Fl_Check_Button(50, Y, 150, 22, _("Wall cloud"));
274 	w_severe_wx_wall_cloud->tooltip(_("Report wall cloud sighting"));
275 	w_severe_wx_wall_cloud->callback((Fl_Callback*)severe_wx_changed);
276 
277 	Fl_Group lbl1(200, Y, 200, 22, _("Note if there is rotation in narrative"));
278 	lbl1.begin();
279 	lbl1.box(FL_FLAT_BOX);
280 	lbl1.end();
281 
282 	Y += 25;
283 	w_severe_wx_hail = new Fl_Check_Button(50, Y, 150, 22, _("Hail"));
284 	w_severe_wx_hail->tooltip(_("Report incidence of hail"));
285 	w_severe_wx_hail->callback((Fl_Callback*)cb_hail_changed);
286 
287 	w_severe_wx_hail_size = new Fl_ListBox(150, Y, 150, 22, "hail size");
288 	w_severe_wx_hail_size->copy_label(_("Size"));
289 	w_severe_wx_hail_size->align(FL_ALIGN_LEFT);
290 	w_severe_wx_hail_size->when(FL_WHEN_RELEASE);
291 	w_severe_wx_hail_size->callback((Fl_Callback*)severe_wx_changed);
292 	w_severe_wx_hail_size->deactivate();
293 
294 	Y += 25;
295 	w_severe_wx_high_wind = new Fl_Check_Button(50, Y, 60, 22, _("High Wind"));
296 	w_severe_wx_high_wind->tooltip(_("Report high winds"));
297 	w_severe_wx_high_wind->callback((Fl_Callback*)severe_wx_changed);
298 
299 	w_severe_wx_wind_speed = new Fl_Input2(150, Y, 50, 22, _("Wind Speed"));
300 	w_severe_wx_wind_speed->align(FL_ALIGN_RIGHT);
301 	w_severe_wx_wind_speed->tooltip(_("Enter wind speed"));
302 	w_severe_wx_wind_speed->callback((Fl_Callback*)severe_wx_changed);
303 
304 	w_severe_wx_measured = new Fl_Check_Button(350, Y, 50, 22, _("Meas'"));
305 	w_severe_wx_measured->tooltip(_("Winds were measured"));
306 	w_severe_wx_measured->value(0);
307 	w_severe_wx_measured->callback((Fl_Callback*)cb_severe_wx_measured);
308 
309 	w_severe_wx_estimated = new Fl_Check_Button(425, Y, 50, 22, _("Est'"));
310 	w_severe_wx_estimated->tooltip(_("Winds are estimated"));
311 	w_severe_wx_estimated->value(1);
312 	w_severe_wx_estimated->callback((Fl_Callback*)cb_severe_wx_estimated);
313 
314 	Y += 25;
315 	w_severe_wx_flood = new Fl_Check_Button(50, Y, 80, 22, _("Flood"));
316 	w_severe_wx_flood->tooltip(_("Report flooding"));
317 	w_severe_wx_flood->callback((Fl_Callback*)severe_wx_changed);
318 
319 	Y += 25;
320 	w_severe_wx_flash_flood = new Fl_Check_Button(50, Y, 80, 22, _("Flash Flood"));
321 	w_severe_wx_flash_flood->tooltip(_("Report flash flooding"));
322 	w_severe_wx_flash_flood->callback((Fl_Callback*)severe_wx_changed);
323 
324 	w_severe_wx_dmg_yes = new Fl_Check_Button(350, Y, 22, 22,
325 		_("Any damage?   Yes "));
326 	w_severe_wx_dmg_yes->align(FL_ALIGN_LEFT);
327 	w_severe_wx_dmg_yes->tooltip("");
328 	w_severe_wx_dmg_yes->callback((Fl_Callback*)cb_dmg_yes);
329 
330 	w_severe_wx_dmg_no = new Fl_Check_Button(400, Y, 22, 22,
331 		_("No "));
332 	w_severe_wx_dmg_no->align(FL_ALIGN_LEFT);
333 	w_severe_wx_dmg_no->tooltip("");
334 	w_severe_wx_dmg_no->value(1);
335 	w_severe_wx_dmg_no->callback((Fl_Callback*)cb_dmg_no);
336 
337 	Y += 25;
338 	w_severe_wx_other = new Fl_Check_Button(50, Y, 80, 22, _("Other"));
339 	w_severe_wx_other->tooltip(_("Report other in narrative"));
340 	w_severe_wx_other->callback((Fl_Callback*)severe_wx_changed);
341 
342 	w_severe_wx_inj_yes = new Fl_Check_Button(350, Y, 22, 22,
343 		_("Any injuries?   Yes "));
344 	w_severe_wx_inj_yes->align(FL_ALIGN_LEFT);
345 	w_severe_wx_inj_yes->tooltip("");
346 	w_severe_wx_inj_yes->callback((Fl_Callback*)cb_inj_yes);
347 
348 	w_severe_wx_inj_no = new Fl_Check_Button(400, Y, 22, 22,
349 		_("No "));
350 	w_severe_wx_inj_no->align(FL_ALIGN_LEFT);
351 	w_severe_wx_inj_no->tooltip("");
352 	w_severe_wx_inj_no->value(1);
353 	w_severe_wx_inj_no->callback((Fl_Callback*)cb_inj_no);
354 
355 	tab_severe_wx_1->end();
356 
357 	Y = tab_top;
358 	tab_severe_wx_2 = new Fl_Group(0, Y+25, 570, 360, "Narrative");
359 	tab_severe_wx_2->begin();
360 	Y += 35;
361 	w_severe_wx_narrative = new FTextEdit(5, Y, 560, 340, _(""));
362 
363 	tab_severe_wx_2->end();
364 
365 	tab_severe_wx->end();
366 
367 	set_severe_wx_combos();
368 
369 	tab_severe_wx->hide();
370 
371 };
372 
373