1 // $Id: DRAWxtlViewUI.cxx 1083 2010-11-17 16:21:56Z larry $
2 //
3 // DRAWxtl V5.5 main window description
4 // initial version generated by Fast Light User Interface Designer (fluid) version 1.0104
5 //
6 // Coded using the FLTK 1.1.6 widget set
7 //
8 //     Larry W. Finger, Martin Kroeker and Brian Toby
9 //
10 // routines contained within this file:
11 //
12 //  DRAWxtlViewUI::DRAWxtlViewUI - the constructor
13 //  Draw_Fl_Input::handle - the keyboard handler for this derived class
14 //
15 
16 #include "DRAWxtlViewUI.h"
17 extern DRAWxtlViewUI *drvui;
18 
19 void Main_Frame_Combo_cb (Fl_Widget *, void *);
20 
21 static const char *Origin_X_ttp = { "Fractional coordinate (x) of center of drawing." };
22 static const char *Origin_Y_ttp = { "Fractional coordinate (y) of center of drawing." };
23 static const char *Origin_Z_ttp = { "Fractional coordinate (z) of center of drawing." };
24 
25 static const char *X_Min_ttp = { "Fractional coordinate of minimum value of x\n"
26 	"(See 'pack' command in Help/Input File Commands)"
27 };
28 
29 static const char *Y_Min_ttp = { "Fractional coordinate of minimum value of y\n"
30 	"(See 'pack' command in Help/Input File Commands)"
31 };
32 
33 static const char *Z_Min_ttp = { "Fractional coordinate of minimum value of z\n"
34 	"(See 'pack' command in Help/Input File Commands)"
35 };
36 
37 static const char *X_Max_ttp = { "Fractional coordinate of maximum value of x\n"
38 	"(See 'pack' command in Help/Input File Commands)"
39 };
40 
41 static const char *Y_Max_ttp = { "Fractional coordinate of maximum value of y\n"
42 	"(See 'pack' command in Help/Input File Commands)"
43 };
44 
45 static const char *Z_Max_ttp = { "Fractional coordinate of maximum value of z\n"
46 	"(See 'pack' command in Help/Input File Commands)"
47 };
48 
49 static const char *X_Min_Clip_ttp = { "Fractional coordinate of minimum clip value of x\n"
50 	"(See 'clip' command in Help/Input File Commands)\n"
51 	"Inactive unless 'Use Bond Clipping' is checked."
52 };
53 
54 static const char *Y_Min_Clip_ttp = { "Fractional coordinate of minimum clip value of y\n"
55 	"(See 'clip' command in Help/Input File Commands)\n"
56 	"Inactive unless 'Use Bond Clipping' is checked."
57 };
58 
59 static const char *Z_Min_Clip_ttp = { "Fractional coordinate of minimum clip value of z\n"
60 	"(See 'clip' command in Help/Input File Commands)\n"
61 	"Inactive unless 'Use Bond Clipping' is checked."
62 };
63 
64 static const char *X_Max_Clip_ttp = { "Fractional coordinate of maximum clip value of x\n"
65 	"(See 'clip' command in Help/Input File Commands)\n"
66 	"Inactive unless 'Use Bond Clipping' is checked."
67 };
68 
69 static const char *Y_Max_Clip_ttp = { "Fractional coordinate of maximum clip value of y\n"
70 	"(See 'clip' command in Help/Input File Commands)\n"
71 	"Inactive unless 'Use Bond Clipping' is checked."
72 };
73 
74 static const char *Z_Max_Clip_ttp = { "Fractional coordinate of maximum clip value of z\n"
75 	"(See 'clip' command in Help/Input File Commands)\n"
76 	"Inactive unless 'Use Bond Clipping' is checked."
77 };
78 
79 static const char *Str_Name_ttp = { "File name of current structure file\n"
80 	"Use 'Select Data File' menu item under 'File' to change."
81 };
82 static const char *Orthographic_ttp = { "If set, an orthographic view is generated." };
83 static const char *Bond_Clipping_ttp =
84     { "Set to generate 'half' bonds at edge of drawing." };
85 static const char *Generate_VRML1_ttp = { "Set for VRML1 output (not VRML97)." };
86 
87 //
88 // Remember to update the menuitem number in all deactivate() calls for View->POV in
89 // CrystalView.cxx and Edit1.cxx when you insert a menu item before the POV entry below !
90 //
91 Fl_Menu_Item
92     DRAWxtlViewUI::drawxtl_menu[] = {
93     {"File", 0, 0, 0, FL_SUBMENU, 0, 0, 14, 56},
94     {" Select Data File", 0, (Fl_Callback *) SelectDataFile_cb, 0, 0, 0, 0, 14, 56},
95     {" Import External Format ", 0, 0, 0, FL_SUBMENU, 0, 0, 14, 56},
96     {" Import CIF File", 0, (Fl_Callback *) ImportDataFile_cb, 0, 0, 0, 0, 14, 56},
97     {" Import FDAT File", 0, (Fl_Callback *) ImportDataFile_cb, (void *) 1, 0, 0, 0, 14,
98      56},
99     {" Import GSAS File", 0, (Fl_Callback *) ImportDataFile_cb, (void *) 2, 0, 0, 0, 14,
100      56},
101     {" Import Schakal File", 0, (Fl_Callback *) ImportDataFile_cb, (void *) 3, 0, 0, 0,
102      14, 56},
103     {" Import Shelx File", 0, (Fl_Callback *) ImportDataFile_cb, (void *) 4, 0, 0, 0, 14,
104      56},
105     {" Import WIEN2k File", 0, (Fl_Callback *) ImportDataFile_cb, (void *) 5, 0, 0, 0, 14,
106      56},
107     {" Import DISCUS File", 0, (Fl_Callback *) ImportDataFile_cb, (void *) 6, 0, 0, 0, 14,
108      56},
109     {" Import FULLPROF File", 0, (Fl_Callback *) ImportDataFile_cb, (void *) 7, 0, 0, 0,
110      14, 56},
111     {" Import Exciting File", 0, (Fl_Callback *) ImportDataFile_cb, (void *) 8, 0, 0, 0,
112      14, 56},
113     {0, 0, 0, 0, 0, 0, 0, 0, 0},
114     {" Save Current", 0, (Fl_Callback *) Save_Current_cb, 0, 0, 0, 0, 14, 56},
115     {" Save Image as Postscript", 0, (Fl_Callback *) Dump_View_cb, 0, 0, 0, 0, 14, 56},
116     {" Save Image as GIF", 0, (Fl_Callback *) dump_gif, 0, 0, 0, 0, 14, 56},
117     {" Configure", 0, 0, 0, FL_SUBMENU | FL_MENU_DIVIDER, 0, 0, 14, 56},
118     {" POV", 0, (Fl_Callback *) Configure_cb, 0, 0, 0, 0, 14, 56},
119     {" MSMS", 0, (Fl_Callback *) Configure_MSMS_cb, 0, 0, 0, 0, 14, 56},
120     {" Misc.", 0, (Fl_Callback *) Configure_Misc_cb, 0, 0, 0, 0, 14, 56},
121     {0, 0, 0, 0, 0, 0, 0, 0, 0},
122     {" Exit", 0, (Fl_Callback *) Exit_cb, 0, 0, 0, 0, 14, 56},
123     {0, 0, 0, 0, 0, 0, 0, 0, 0},
124     {"Edit", 0, 0, 0, FL_SUBMENU, 0, 0, 14, 56},
125     {" Edit Parameters", 0, (Fl_Callback *) Edit_Parmeters_cb, 0, 0, 0, 0, 14, 56},
126     {" Edit Spheres", 0, (Fl_Callback *) Edit_Spheres_cb, 0, 0, 0, 0, 14, 56},
127     {" Edit Bonds", 0, (Fl_Callback *) Edit_Bond_cb, 0, 0, 0, 0, 14, 56},
128     {" Edit Ellipsoids", 0, (Fl_Callback *) Edit_Ellipsoid_cb, 0, 0, 0, 0, 14, 56},
129     {" Edit Polyhedra/Planes", 0, (Fl_Callback *) Edit_Polyhedra_cb, 0, 0, 0, 0, 14, 56},
130     {" Edit Arrows", 0, (Fl_Callback *) Edit_Arrow_cb, 0, 0, 0, 0, 14, 56},
131     {" Edit Lone-Pair Cones", 0, (Fl_Callback *) Edit_LonePair_cb, 0, 0, 0, 0, 14, 56},
132     {" Edit Slab Parameters", 0, (Fl_Callback *) Edit_Slab_cb, 0, 0, 0, 0, 14, 56},
133     {" Edit Map Parameters", 0, (Fl_Callback *) Edit_Maps_cb, 0, 0, 0, 0, 14, 56},
134     {" Edit Surface Parameters", 0, (Fl_Callback *) Edit_Surfaces_cb, 0, 0, 0, 0, 14, 56},
135     {" Edit Modulation Parameters", 0, (Fl_Callback *) Edit_Modparms_cb, 0,
136      FL_MENU_DIVIDER, 0, 0, 14, 56},
137     {" Edit STR File (Original Version)", 0, (Fl_Callback *) Edit_STR_cb, (void *) 1, 0,
138      0, 0, 14, 56},
139     {" Edit STR File (Working Version)", 0, (Fl_Callback *) Edit_STR_cb, 0, 0, 0, 0, 14,
140      56},
141     {0, 0, 0, 0, 0, 0, 0, 0, 0},
142     {"View", 0, 0, 0, FL_SUBMENU, 0, 0, 14, 56},
143     {" POV", 0, (Fl_Callback *) View_POV_cb, 0, 0, 0, 0, 14, 56},
144     {" Listing", 0, (Fl_Callback *) View_Listing_cb, 0, 0, 0, 0, 14, 56},
145     {" Console", 0, (Fl_Callback *) View_Console_cb, 0, 0, 0, 0, 14, 56},
146     {" Geometry", 0, (Fl_Callback *) View_Cursor_cb, 0, 0, 0, 0, 14, 56},
147     {" File", 0, (Fl_Callback *) View_File_cb, 0, 0, 0, 0, 14, 56},
148     {0, 0, 0, 0, 0, 0, 0, 0, 0},
149     {"Help", 0, 0, 0, FL_SUBMENU, 0, 0, 14, 56},
150     {" Input File Commands", 0, (Fl_Callback *) Input_Help_cb, 0, 0, 0, 0, 14, 56},
151     {" Color Name/RGB Table", 0, (Fl_Callback *) Color_Help_cb, 0, 0, 0, 0, 14, 56},
152     {" Graphics Help", 0, (Fl_Callback *) Graphics_Help_cb, 0, 0, 0, 0, 14, 56},
153     {" Spacegroup Help", 0, (Fl_Callback *) Spacegroup_Help_cb, 0, FL_MENU_DIVIDER, 0, 0,
154      14, 56},
155     {" About DRAWxtl", 0, (Fl_Callback *) About_Help_cb, 0, 0, 0, 0, 14, 56},
156     {0, 0, 0, 0, 0, 0, 0, 0, 0},
157     {0, 0, 0, 0, 0, 0, 0, 0, 0}
158 };
159 
160 Fl_Group *Menu_Group;
161 
162 CrystalView *crystal2;
163 
164 Fl_Group *Cursor_Group;
165 
166 Fl_Group *Left_Panel_Group;
167 
168 volatile int w_width = 855;
169 
170 volatile int w_height = 660;
171 
172 int y_start = 30;
173 
174 int w_st_x = 150;
175 
176 int w_st_y = 20;
177 
178 static int
scaled_x(int x)179 scaled_x (int x)
180 {
181     return min (x, (x * w_width) / 855);
182 }
183 
184 static int
scaled_y(int y)185 scaled_y (int y)
186 {
187     return (y * w_height) / 660;
188 }
189 
DRAWxtlViewUI()190 DRAWxtlViewUI::DRAWxtlViewUI ()
191 {
192     int y;
193 
194     int y_step = 25;
195 
196     if (Fl::w () == 800) {	// adjust screen parameters for 800 x 600
197 	w_width = 790;
198 	w_height = 530;
199 	w_st_x = 0;
200 	y_step = 20;
201     } else if (Fl::w () == 640) {	// adjust for 640 x 480
202 	w_width = 630;
203 	w_height = 420;
204 	w_st_x = 0;
205 	y_step = 18;
206     }
207     DRAWxtl_Window *o = mainWindow =
208 	new DRAWxtl_Window (w_st_x, w_st_y, w_width, w_height,
209 			    "   DRAWxtl V5.5");
210 
211     o->begin ();
212     o->box (FL_UP_BOX);
213     o->selection_color ((Fl_Color) 128);
214     o->labelfont (1);
215     o->labelsize (49);
216     o->labelcolor (FL_RED);
217     o->callback ((Fl_Callback *) Exit_cb);
218     o->align (FL_ALIGN_BOTTOM);
219     o->when (FL_WHEN_CHANGED);
220     o->size_range (160, 100, Fl::w (), Fl::h ());
221     Fl_Group *g = Menu_Group = new Fl_Group (0, 0, w_width, 25);
222 
223     g->begin ();
224     Fl_Box *b = new Fl_Box (0, 0, w_width, 25);
225 
226     Fl_Menu_Bar *om = new Fl_Menu_Bar (0, 0, w_width - 50, 25);
227 
228     om->menu (drawxtl_menu);
229     Fl_Button *on = new Fl_Button (w_width - 50, 0, 50, 25, "Exit");
230 
231     on->callback ((Fl_Callback *) Exit_cb);
232     g->resizable (b);
233     g->end ();
234     Left_Panel_Group =
235 	new Fl_Group (0, scaled_y (25), scaled_x (275), w_height - scaled_y (25));
236     Fl_Text_Display *op = mainLabel =
237 	new Fl_Text_Display (0, scaled_y (60), scaled_x (275), 0, "DRAWxtl V5.5");
238     op->box (FL_NO_BOX);
239     op->color ((Fl_Color) 1);
240     op->selection_color ((Fl_Color) 1);
241     op->labelfont (1);
242     op->labelsize (scaled_y (20));
243     op->labelcolor ((Fl_Color) 1);
244     op->textcolor (1);
245     y = y_start;
246     {
247 	Fl_Check_Button *o = Show_Vector_Triple =
248 	    new Fl_Check_Button (scaled_x (20), scaled_y (y) + 25,
249 				 scaled_x (25), scaled_y (25), "Show Vector Triple");
250 
251 	o->down_box (FL_DOWN_BOX);
252 	o->callback ((Fl_Callback *) Check_Box_cb);
253     }
254     y += y_step - 5;
255     {
256 	Fl_Check_Button *o = Orthographic_View =
257 	    new Fl_Check_Button (scaled_x (20), scaled_y (y) + 25,
258 				 scaled_x (30), scaled_y (25), "Non-Perspective View");
259 
260 	o->down_box (FL_DOWN_BOX);
261 	o->tooltip (Orthographic_ttp);
262 	o->callback ((Fl_Callback *) Check_Box_cb);
263     }
264     y += y_step - 5;
265     {
266 	Fl_Check_Button *o = Generate_VRML1 =
267 	    new Fl_Check_Button (scaled_x (20), scaled_y (y) + 25,
268 				 scaled_x (25), scaled_y (25), "Generate VRML1");
269 
270 	o->down_box (FL_DOWN_BOX);
271 	o->tooltip (Generate_VRML1_ttp);
272 	o->callback ((Fl_Callback *) Check_Box_cb);
273     }
274     y += y_step - 5;
275     {
276 	Fl_Check_Button *o = Use_Clipping =
277 	    new Fl_Check_Button (scaled_x (20), scaled_y (y) + 25,
278 				 scaled_x (25), scaled_y (25), "Use Bond Clipping");
279 
280 	o->down_box (FL_DOWN_BOX);
281 	o->tooltip (Bond_Clipping_ttp);
282 	o->callback ((Fl_Callback *) Max_Min_cb);
283     }
284     Origin1_Msg =
285 	new Fl_Output (scaled_x (20), scaled_y (y) + 40, scaled_x (250), scaled_y (20));
286     Origin1_Msg->value ("Special space group - see Help/Spacegroup");
287     Origin1_Msg->textsize (scaled_y (12));
288     Origin1_Msg->textcolor (FL_RED);
289     Origin1_Msg->box (FL_NO_BOX);
290     Origin1_Msg->hide ();
291     {
292 	Flu_Combo_List *o = Frame_No =
293 	    new Flu_Combo_List (scaled_x (180), scaled_y (y + 5),
294 				scaled_x (70), scaled_y (20), "Frame No.");
295 
296 	o->align (FL_ALIGN_TOP);
297 	o->hide ();
298 	o->callback (Main_Frame_Combo_cb);
299     }
300     y += y_step + 10;
301     {
302 	Flu_Spinner *o = X_Min = new Flu_Spinner (scaled_x (20), scaled_y (y) + 25,
303 						  scaled_x (100), scaled_y (25), "Xmin");
304 
305 	o->type (1);
306 	o->minimum (-10);
307 	o->maximum (1);
308 	o->step (0.05);
309 	o->align (FL_ALIGN_BOTTOM);
310 	o->valuecolor (FL_WHITE, FL_SELECTION_COLOR);
311 	o->tooltip (X_Min_ttp);
312 	o->callback ((Fl_Callback *) Max_Min_cb);
313     }
314     {
315 	Flu_Spinner *o = X_Max = new Flu_Spinner (scaled_x (150), scaled_y (y) + 25,
316 						  scaled_x (100), scaled_y (25), "Xmax");
317 
318 	o->type (1);
319 	o->minimum (-1);
320 	o->maximum (10);
321 	o->step (0.05);
322 	o->align (FL_ALIGN_BOTTOM);
323 	o->valuecolor (FL_WHITE, FL_SELECTION_COLOR);
324 	o->tooltip (X_Max_ttp);
325 	o->callback ((Fl_Callback *) Max_Min_cb);
326     }
327     y += y_step + 20;
328     {
329 	Flu_Spinner *o = X_Min_clip = new Flu_Spinner (scaled_x (20), scaled_y (y) + 25,
330 						       scaled_x (100), scaled_y (25),
331 						       "Clip Xmin");
332 	o->type (1);
333 	o->minimum (-10);
334 	o->maximum (4);
335 	o->step (0.05);
336 	o->align (FL_ALIGN_BOTTOM);
337 	o->deactivate ();
338 	o->valuecolor (FL_WHITE, FL_SELECTION_COLOR);
339 	o->tooltip (X_Min_Clip_ttp);
340 	o->callback ((Fl_Callback *) Max_Min_cb);
341     }
342     {
343 	Flu_Spinner *o = X_Max_clip = new Flu_Spinner (scaled_x (150), scaled_y (y) + 25,
344 						       scaled_x (100), scaled_y (25),
345 						       "Clip Xmax");
346 	o->type (1);
347 	o->minimum (-4);
348 	o->maximum (10);
349 	o->step (0.05);
350 	o->align (FL_ALIGN_BOTTOM);
351 	o->deactivate ();
352 	o->callback ((Fl_Callback *) Max_Min_cb);
353 	o->tooltip (X_Max_Clip_ttp);
354 	o->valuecolor (FL_WHITE, FL_SELECTION_COLOR);
355     }
356     y += y_step + 20;
357     {
358 	Flu_Spinner *o = Y_Min = new Flu_Spinner (scaled_x (20), scaled_y (y) + 25,
359 						  scaled_x (100), scaled_y (25), "Ymin");
360 
361 	o->type (1);
362 	o->minimum (-10);
363 	o->maximum (1);
364 	o->step (0.05);
365 	o->align (FL_ALIGN_BOTTOM);
366 	o->valuecolor (FL_WHITE, FL_SELECTION_COLOR);
367 	o->tooltip (Y_Min_ttp);
368 	o->callback ((Fl_Callback *) Max_Min_cb);
369     }
370     {
371 	Flu_Spinner *o = Y_Max = new Flu_Spinner (scaled_x (150), scaled_y (y) + 25,
372 						  scaled_x (100), scaled_y (25), "Ymax");
373 
374 	o->type (1);
375 	o->minimum (-1);
376 	o->maximum (10);
377 	o->step (0.05);
378 	o->align (FL_ALIGN_BOTTOM);
379 	o->valuecolor (FL_WHITE, FL_SELECTION_COLOR);
380 	o->tooltip (Y_Max_ttp);
381 	o->callback ((Fl_Callback *) Max_Min_cb);
382     }
383     y += y_step + 20;
384     {
385 	Flu_Spinner *o = Y_Min_clip = new Flu_Spinner (scaled_x (20), scaled_y (y) + 25,
386 						       scaled_x (100), scaled_y (25),
387 						       "Clip Ymin");
388 	o->type (1);
389 	o->minimum (-10);
390 	o->maximum (4);
391 	o->step (0.05);
392 	o->align (FL_ALIGN_BOTTOM);
393 	o->deactivate ();
394 	o->tooltip (Y_Min_Clip_ttp);
395 	o->valuecolor (FL_WHITE, FL_SELECTION_COLOR);
396 	o->callback ((Fl_Callback *) Max_Min_cb);
397     }
398     {
399 	Flu_Spinner *o = Y_Max_clip = new Flu_Spinner (scaled_x (150), scaled_y (y) + 25,
400 						       scaled_x (100), scaled_y (25),
401 						       "Clip Ymax");
402 	o->type (1);
403 	o->minimum (-10);
404 	o->maximum (4);
405 	o->step (0.05);
406 	o->align (FL_ALIGN_BOTTOM);
407 	o->deactivate ();
408 	o->valuecolor (FL_WHITE, FL_SELECTION_COLOR);
409 	o->tooltip (Y_Max_Clip_ttp);
410 	o->callback ((Fl_Callback *) Max_Min_cb);
411     }
412     y += y_step + 20;
413     {
414 	Flu_Spinner *o = Z_Min = new Flu_Spinner (scaled_x (20), scaled_y (y) + 25,
415 						  scaled_x (100), scaled_y (25), "Zmin");
416 
417 	o->type (1);
418 	o->minimum (-10);
419 	o->maximum (1);
420 	o->step (0.05);
421 	o->align (FL_ALIGN_BOTTOM);
422 	o->valuecolor (FL_WHITE, FL_SELECTION_COLOR);
423 	o->tooltip (Z_Min_ttp);
424 	o->callback ((Fl_Callback *) Max_Min_cb);
425     }
426     {
427 	Flu_Spinner *o = Z_Max = new Flu_Spinner (scaled_x (150), scaled_y (y) + 25,
428 						  scaled_x (100), scaled_y (25), "Zmax");
429 
430 	o->type (1);
431 	o->minimum (-1);
432 	o->maximum (10);
433 	o->step (0.05);
434 	o->align (FL_ALIGN_BOTTOM);
435 	o->valuecolor (FL_WHITE, FL_SELECTION_COLOR);
436 	o->tooltip (Z_Max_ttp);
437 	o->callback ((Fl_Callback *) Max_Min_cb);
438     }
439     y += y_step + 20;
440     {
441 	Flu_Spinner *o = Z_Min_clip = new Flu_Spinner (scaled_x (20), scaled_y (y) + 25,
442 						       scaled_x (100), scaled_y (25),
443 						       "Clip Zmin");
444 	o->type (1);
445 	o->minimum (-10);
446 	o->maximum (4);
447 	o->step (0.05);
448 	o->align (FL_ALIGN_BOTTOM);
449 	o->deactivate ();
450 	o->valuecolor (FL_WHITE, FL_SELECTION_COLOR);
451 	o->tooltip (Z_Min_Clip_ttp);
452 	o->callback ((Fl_Callback *) Max_Min_cb);
453     }
454     {
455 	Flu_Spinner *o = Z_Max_clip = new Flu_Spinner (scaled_x (150), scaled_y (y) + 25,
456 						       scaled_x (100), scaled_y (25),
457 						       "Clip Zmax");
458 	o->type (1);
459 	o->minimum (-4);
460 	o->maximum (10);
461 	o->step (0.05);
462 	o->align (FL_ALIGN_BOTTOM);
463 	o->deactivate ();
464 	o->valuecolor (FL_WHITE, FL_SELECTION_COLOR);
465 	o->tooltip (Z_Max_Clip_ttp);
466 	o->callback ((Fl_Callback *) Max_Min_cb);
467     }
468     y += y_step + 20;
469     {
470 	Draw_Fl_Input *o = Origin_X = new Draw_Fl_Input (scaled_x (20), scaled_y (y) + 25,
471 							 scaled_x (60), scaled_y (25),
472 							 "Origin X");
473 	o->callback ((Fl_Callback *) Offset_cb);
474 	o->align (FL_ALIGN_BOTTOM);
475 	o->when (FL_WHEN_CHANGED);
476 	o->tooltip (Origin_X_ttp);
477     }
478     {
479 	Draw_Fl_Input *o = Origin_Y =
480 	    new Draw_Fl_Input (scaled_x (100), scaled_y (y) + 25,
481 			       scaled_x (60), scaled_y (25), "Origin Y");
482 
483 	o->callback ((Fl_Callback *) Offset_cb);
484 	o->align (FL_ALIGN_BOTTOM);
485 	o->when (FL_WHEN_CHANGED);
486 	o->tooltip (Origin_Y_ttp);
487     }
488     {
489 	Draw_Fl_Input *o = Origin_Z =
490 	    new Draw_Fl_Input (scaled_x (185), scaled_y (y) + 25,
491 			       scaled_x (60), scaled_y (25), "Origin Z");
492 
493 	o->callback ((Fl_Callback *) Offset_cb);
494 	o->align (FL_ALIGN_BOTTOM);
495 	o->when (FL_WHEN_CHANGED);
496 	o->tooltip (Origin_Z_ttp);
497     }
498     y += y_step + 20;
499     {
500 	Draw_Fl_Input *o = X_Rot = new Draw_Fl_Input (scaled_x (20), scaled_y (y) + 25,
501 						      scaled_x (60), scaled_y (25),
502 						      "X-Rot");
503 	o->callback ((Fl_Callback *) Rotation_cb);
504 	o->align (FL_ALIGN_BOTTOM);
505 	o->when (FL_WHEN_ENTER_KEY);
506     }
507     {
508 	Draw_Fl_Input *o = Y_Rot = new Draw_Fl_Input (scaled_x (100), scaled_y (y) + 25,
509 						      scaled_x (60), scaled_y (25),
510 						      "Y-Rot");
511 	o->callback ((Fl_Callback *) Rotation_cb);
512 	o->align (FL_ALIGN_BOTTOM);
513 	o->when (FL_WHEN_ENTER_KEY);
514     }
515     {
516 	Draw_Fl_Input *o = Z_Rot = new Draw_Fl_Input (scaled_x (185), scaled_y (y) + 25,
517 						      scaled_x (60), scaled_y (25),
518 						      "Z-Rot");
519 	o->callback ((Fl_Callback *) Rotation_cb);
520 	o->align (FL_ALIGN_BOTTOM);
521 	o->when (FL_WHEN_ENTER_KEY);
522     }
523     y += y_step + 20;
524     {
525 	Fl_Output *o = CurFile = new Fl_Output (scaled_x (20), scaled_y (y) + 25,
526 						scaled_x (225), scaled_y (25),
527 						"Current Structure File");
528 	o->align (FL_ALIGN_BOTTOM);
529 	o->color (FL_BACKGROUND_COLOR);
530 	o->box (FL_THIN_DOWN_BOX);
531 	o->tooltip (Str_Name_ttp);
532     }
533     y += y_step + 20;
534     {
535 	Fl_Output *o = CurDir = new Fl_Output (scaled_x (20), scaled_y (y) + 25,
536 					       scaled_x (225), scaled_y (40),
537 					       "Current Directory");
538 	o->color (FL_BACKGROUND_COLOR);
539 	o->box (FL_THIN_DOWN_BOX);
540 	o->align (FL_ALIGN_BOTTOM);
541     }
542     Left_Panel_Group->end ();
543     {
544 	CrystalView *o = crystal = crystal2 =
545 	    new CrystalView (scaled_x (275), 25, w_width - 275,
546 			     w_height - 65, "label");
547 
548 	o->box (FL_NO_BOX);
549 	o->color (FL_BACKGROUND_COLOR);
550 	o->selection_color (FL_BACKGROUND_COLOR);
551 	o->labeltype (FL_NORMAL_LABEL);
552 	o->labelfont (0);
553 	o->labelsize (14);
554 	o->labelcolor (FL_BLACK);
555 	o->end ();
556     }
557     o->resizable (crystal);
558     Cursor_Group = new Fl_Group (scaled_x (275), w_height - 55, w_width - 275, 35);
559     {
560 	Fl_Multiline_Output *p = Cursor_pos =
561 	    new Fl_Multiline_Output (scaled_x (275), w_height - 35,
562 				     w_width - 275, 45);
563 
564 	p->textsize (13);
565 	p->color (FL_BACKGROUND_COLOR);
566 	p->box (FL_THIN_DOWN_BOX);
567 	p->align (FL_ALIGN_CENTER | FL_ALIGN_INSIDE);
568 	p->when (FL_WHEN_RELEASE);
569     }
570     Cursor_Group->box (FL_NO_BOX);
571     Cursor_Group->resizable (crystal);
572     Cursor_Group->end ();
573     o->end ();
574 }
575 
576 int
handle(int e)577 Draw_Fl_Input::handle (int e)
578 {
579     if (e == FL_KEYDOWN) {
580 	if (Fl::event_key () == FL_Tab) {
581 	    next_focus ();
582 	    return 1;
583 	}
584     }
585     return Fl_Input::handle (e);
586 }
587 
588 void
resize(int X,int Y,int W,int H)589 DRAWxtl_Window::resize (int X, int Y, int W, int H)
590 {
591 /* resize the various parts of the layout as the main window is resized by dragging
592  * a corner, or by pressing the "maximize" button in the upper right-hand corner.
593  * The left-most panel of widgets is never made wider than the 275 pixels that it
594  * had before resizing was implemented. FLTK does not resize widget labels; therefore
595  * each of them has to be resized individually. This works OK, but we get discrete
596  * jumps in the size rather than a smooth transition.
597  */
598     int lp_w;
599 
600     int text_h;
601 
602     int ctext_h;
603 
604     int label_h;
605 
606     /* calculate width for the left panel group, which is in the
607      * range from 0 to 275 */
608     lp_w = (int) (275. * ((float) DRAWxtl_Window::w () / 855.));
609     Fl_Double_Window::resize (X, Y, W, H);
610     Menu_Group->resize (0, 0, DRAWxtl_Window::w (), 25);
611     crystal2->resize (lp_w, 25, DRAWxtl_Window::w () - lp_w, DRAWxtl_Window::h () - 60);
612     Cursor_Group->resize (lp_w, DRAWxtl_Window::h () - 55, DRAWxtl_Window::w () - lp_w,
613 			  35);
614     drvui->Cursor_pos->resize (lp_w, DRAWxtl_Window::h () - 35,
615 			       DRAWxtl_Window::w () - lp_w, 35);
616     Left_Panel_Group->resize (0, 25, lp_w, DRAWxtl_Window::h () - 25);
617     text_h = min (14, (14 * DRAWxtl_Window::h ()) / 660);
618     ctext_h = min (13, (13 * DRAWxtl_Window::h ()) / 660);
619     label_h = min (20, (20 * DRAWxtl_Window::h ()) / 660);
620 
621     drvui->mainLabel->labelsize (label_h);
622     drvui->X_Max->labelsize (text_h);
623     drvui->Y_Max->labelsize (text_h);
624     drvui->Z_Max->labelsize (text_h);
625     drvui->X_Min->labelsize (text_h);
626     drvui->Y_Min->labelsize (text_h);
627     drvui->Z_Min->labelsize (text_h);
628     drvui->X_Max_clip->labelsize (text_h);
629     drvui->Y_Max_clip->labelsize (text_h);
630     drvui->Z_Max_clip->labelsize (text_h);
631     drvui->X_Min_clip->labelsize (text_h);
632     drvui->Y_Min_clip->labelsize (text_h);
633     drvui->Z_Min_clip->labelsize (text_h);
634     drvui->X_Rot->labelsize (text_h);
635     drvui->Y_Rot->labelsize (text_h);
636     drvui->Z_Rot->labelsize (text_h);
637     drvui->X_Max->valuesize (text_h);
638     drvui->Y_Max->valuesize (text_h);
639     drvui->Z_Max->valuesize (text_h);
640     drvui->X_Min->valuesize (text_h);
641     drvui->Y_Min->valuesize (text_h);
642     drvui->Z_Min->valuesize (text_h);
643     drvui->X_Max_clip->valuesize (text_h);
644     drvui->Y_Max_clip->valuesize (text_h);
645     drvui->Z_Max_clip->valuesize (text_h);
646     drvui->X_Min_clip->valuesize (text_h);
647     drvui->Y_Min_clip->valuesize (text_h);
648     drvui->Z_Min_clip->valuesize (text_h);
649     drvui->X_Rot->textsize (text_h);
650     drvui->Y_Rot->textsize (text_h);
651     drvui->Z_Rot->textsize (text_h);
652     drvui->Origin_X->labelsize (text_h);
653     drvui->Origin_Y->labelsize (text_h);
654     drvui->Origin_Z->labelsize (text_h);
655     drvui->Origin_X->textsize (text_h);
656     drvui->Origin_Y->textsize (text_h);
657     drvui->Origin_Z->textsize (text_h);
658     drvui->Orthographic_View->labelsize (text_h);
659     drvui->Show_Vector_Triple->labelsize (text_h);
660     drvui->Use_Clipping->labelsize (text_h);
661     drvui->Generate_VRML1->labelsize (text_h);
662     drvui->Frame_No->labelsize (text_h);
663     drvui->CurFile->labelsize (text_h);
664     drvui->CurFile->textsize (text_h);
665     drvui->CurDir->labelsize (text_h);
666     drvui->CurDir->textsize (text_h);
667     drvui->Cursor_pos->textsize (ctext_h);
668 
669     w_width = crystal2->w();
670     w_height = crystal2->h();
671 }
672