source: rtems-graphics-toolkit/fltk-1.1.10/fluid/factory.cxx @ 513eea1

Last change on this file since 513eea1 was 513eea1, checked in by Joel Sherrill <joel.sherrill@…>, on 01/09/10 at 22:43:24

2010-01-08 Joel Sherrill <joel.sherrill@…>

fltk 1.1.10. imported

  • ORIGIN: Updated.
  • Property mode set to 100644
File size: 39.5 KB
Line 
1//
2// "$Id$"
3//
4// Widget factory code for the Fast Light Tool Kit (FLTK).
5//
6// Type classes for most of the fltk widgets.  Most of the work
7// is done by code in Fl_Widget_Type.C.  Also a factory instance
8// of each of these type classes.
9//
10// This file also contains the "new" menu, which has a pointer
11// to a factory instance for every class (both the ones defined
12// here and ones in other files)
13//
14// Copyright 1998-2006 by Bill Spitzak and others.
15//
16// This library is free software; you can redistribute it and/or
17// modify it under the terms of the GNU Library General Public
18// License as published by the Free Software Foundation; either
19// version 2 of the License, or (at your option) any later version.
20//
21// This library is distributed in the hope that it will be useful,
22// but WITHOUT ANY WARRANTY; without even the implied warranty of
23// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24// Library General Public License for more details.
25//
26// You should have received a copy of the GNU Library General Public
27// License along with this library; if not, write to the Free Software
28// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
29// USA.
30//
31// Please report all bugs and problems on the following page:
32//
33//     http://www.fltk.org/str.php
34//
35
36#include <FL/Fl.H>
37#include <FL/Fl_Group.H>
38#include <FL/Fl_Menu_Item.H>
39#include <FL/Fl_Pixmap.H>
40#include <stdio.h>
41#include "../src/flstring.h"
42#include "undo.h"
43
44#include "Fl_Widget_Type.h"
45
46extern Fl_Pixmap *pixmap[];
47
48#if !HAVE_STRCASECMP
49//
50// 'strcasecmp()' - Do a case-insensitive compare...
51//
52
53static int
54strcasecmp(const char *s, const char *t) {
55  while (*s != '\0' && *t != '\0') {
56    if (tolower(*s) < tolower(*t))
57      return (-1);
58    else if (tolower(*s) > tolower(*t))
59      return (1);
60
61    s ++;
62    t ++;
63  }
64
65  if (*s == '\0' && *t == '\0')
66    return (0);
67  else if (*s != '\0')
68    return (1);
69  else
70    return (-1);
71}
72#endif // !HAVE_STRCASECMP
73
74////////////////////////////////////////////////////////////////
75
76#include <FL/Fl_Box.H>
77class Fl_Box_Type : public Fl_Widget_Type {
78public:
79  virtual const char *type_name() {return "Fl_Box";}
80  Fl_Widget *widget(int x,int y,int w, int h) {
81    return new Fl_Box(x,y,w,h,"label");}
82  Fl_Widget_Type *_make() {return new Fl_Box_Type();}
83  int pixmapID() { return 5; }
84};
85static Fl_Box_Type Fl_Box_type;
86
87////////////////////////////////////////////////////////////////
88
89#include <FL/Fl_Button.H>
90static Fl_Menu_Item buttontype_menu[] = {
91  {"Normal",0,0,(void*)0},
92  {"Toggle",0,0,(void*)FL_TOGGLE_BUTTON},
93  {"Radio",0,0,(void*)FL_RADIO_BUTTON},
94  {0}};
95class Fl_Button_Type : public Fl_Widget_Type {
96  Fl_Menu_Item *subtypes() {return buttontype_menu;}
97public:
98  virtual void ideal_size(int &w, int &h) {
99    Fl_Widget_Type::ideal_size(w, h);
100    w += 2 * (o->labelsize() - 4);
101    h = (h / 5) * 5;
102  }
103  virtual const char *type_name() {return "Fl_Button";}
104  Fl_Widget *widget(int x,int y,int w,int h) {
105    return new Fl_Button(x,y,w,h,"button");}
106  Fl_Widget_Type *_make() {return new Fl_Button_Type();}
107  int is_button() const {return 1;}
108  int pixmapID() { return 2; }
109};
110static Fl_Button_Type Fl_Button_type;
111
112////////////////////////////////////////////////////////////////
113
114#include <FL/Fl_Return_Button.H>
115class Fl_Return_Button_Type : public Fl_Button_Type {
116public:
117  virtual void ideal_size(int &w, int &h) {
118    Fl_Button_Type::ideal_size(w, h);
119    int W = o->h();
120    if (o->w()/3 < W) W = o->w()/3;
121    w += W + 8 - o->labelsize();
122  }
123  virtual const char *type_name() {return "Fl_Return_Button";}
124  Fl_Widget *widget(int x,int y,int w,int h) {
125    return new Fl_Return_Button(x,y,w,h,"button");}
126  Fl_Widget_Type *_make() {return new Fl_Return_Button_Type();}
127  int pixmapID() { return 23; }
128};
129static Fl_Return_Button_Type Fl_Return_Button_type;
130
131////////////////////////////////////////////////////////////////
132
133#include <FL/Fl_Repeat_Button.H>
134class Fl_Repeat_Button_Type : public Fl_Widget_Type {
135public:
136  virtual const char *type_name() {return "Fl_Repeat_Button";}
137  Fl_Widget *widget(int x,int y,int w,int h) {
138    return new Fl_Repeat_Button(x,y,w,h,"button");}
139  Fl_Widget_Type *_make() {return new Fl_Repeat_Button_Type();}
140  int pixmapID() { return 25; }
141};
142static Fl_Repeat_Button_Type Fl_Repeat_Button_type;
143
144////////////////////////////////////////////////////////////////
145
146#include <FL/Fl_Light_Button.H>
147class Fl_Light_Button_Type : public Fl_Button_Type {
148public:
149  virtual void ideal_size(int &w, int &h) {
150    Fl_Button_Type::ideal_size(w, h);
151    w += 4;
152  }
153  virtual const char *type_name() {return "Fl_Light_Button";}
154  Fl_Widget *widget(int x,int y,int w,int h) {
155    return new Fl_Light_Button(x,y,w,h,"button");}
156  Fl_Widget_Type *_make() {return new Fl_Light_Button_Type();}
157  int pixmapID() { return 24; }
158};
159static Fl_Light_Button_Type Fl_Light_Button_type;
160
161////////////////////////////////////////////////////////////////
162
163#include <FL/Fl_Check_Button.H>
164class Fl_Check_Button_Type : public Fl_Button_Type {
165public:
166  virtual void ideal_size(int &w, int &h) {
167    Fl_Button_Type::ideal_size(w, h);
168    w += 4;
169  }
170  virtual const char *type_name() {return "Fl_Check_Button";}
171  Fl_Widget *widget(int x,int y,int w,int h) {
172    return new Fl_Check_Button(x,y,w,h,"button");}
173  Fl_Widget_Type *_make() {return new Fl_Check_Button_Type();}
174  int pixmapID() { return 3; }
175};
176static Fl_Check_Button_Type Fl_Check_Button_type;
177
178////////////////////////////////////////////////////////////////
179
180#include <FL/Fl_Round_Button.H>
181class Fl_Round_Button_Type : public Fl_Button_Type {
182public:
183  virtual void ideal_size(int &w, int &h) {
184    Fl_Button_Type::ideal_size(w, h);
185    w += 4;
186  }
187  virtual const char *type_name() {return "Fl_Round_Button";}
188  Fl_Widget *widget(int x,int y,int w,int h) {
189    return new Fl_Round_Button(x,y,w,h,"button");}
190  Fl_Widget_Type *_make() {return new Fl_Round_Button_Type();}
191  int pixmapID() { return 4; }
192};
193static Fl_Round_Button_Type Fl_Round_Button_type;
194
195////////////////////////////////////////////////////////////////
196
197extern int compile_only;
198
199#include <FL/Fl_Browser.H>
200#include <FL/Fl_Check_Browser.H>
201#include <FL/Fl_File_Browser.H>
202
203static Fl_Menu_Item browser_type_menu[] = {
204  {"No Select",0,0,(void*)FL_NORMAL_BROWSER},
205  {"Select",0,0,(void*)FL_SELECT_BROWSER},
206  {"Hold",0,0,(void*)FL_HOLD_BROWSER},
207  {"Multi",0,0,(void*)FL_MULTI_BROWSER},
208  {0}};
209class Fl_Browser_Type : public Fl_Widget_Type {
210  Fl_Menu_Item *subtypes() {return browser_type_menu;}
211  int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
212public:
213  virtual void ideal_size(int &w, int &h) {
214    Fl_Browser *myo = (Fl_Browser *)o;
215    fl_font(myo->textfont(), myo->textsize());
216    h -= Fl::box_dh(o->box());
217    w -= Fl::box_dw(o->box());
218    int ww = (int)fl_width('m');
219    w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
220    h = ((h + fl_height() - 1) / fl_height()) * fl_height() +
221        Fl::box_dh(o->box());
222    if (h < 30) h = 30;
223    if (w < 50) w = 50;
224  }
225  virtual const char *type_name() {return "Fl_Browser";}
226  Fl_Widget *widget(int x,int y,int w,int h) {
227    Fl_Browser* b = new Fl_Browser(x,y,w,h);
228    // Fl_Browser::add calls fl_height(), which requires the X display open.
229    // Avoid this when compiling so it works w/o a display:
230    if (!compile_only) {
231      char buffer[20];
232      for (int i = 1; i <= 20; i++) {
233        sprintf(buffer,"Browser Line %d",i);
234        b->add(buffer);
235      }
236    }
237    return b;
238  }
239  Fl_Widget_Type *_make() {return new Fl_Browser_Type();}
240  int pixmapID() { return 31; }
241};
242static Fl_Browser_Type Fl_Browser_type;
243
244int Fl_Browser_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
245  Fl_Browser *myo = (Fl_Browser*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
246  switch (w) {
247    case 4:
248    case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
249    case 1: myo->textfont(f); break;
250    case 2: myo->textsize(s); break;
251    case 3: myo->textcolor(c); break;
252  }
253  return 1;
254}
255
256class Fl_Check_Browser_Type : public Fl_Widget_Type {
257  Fl_Menu_Item *subtypes() {return browser_type_menu;}
258  int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
259public:
260  virtual void ideal_size(int &w, int &h) {
261    Fl_Check_Browser *myo = (Fl_Check_Browser *)o;
262    fl_font(myo->textfont(), myo->textsize());
263    h -= Fl::box_dh(o->box());
264    w -= Fl::box_dw(o->box()) - fl_height();
265    int ww = (int)fl_width('m');
266    w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
267    h = ((h + fl_height() - 1) / fl_height()) * fl_height() +
268        Fl::box_dh(o->box());
269    if (h < 30) h = 30;
270    if (w < 50) w = 50;
271  }
272  virtual const char *type_name() {return "Fl_Check_Browser";}
273  Fl_Widget *widget(int x,int y,int w,int h) {
274    Fl_Check_Browser* b = new Fl_Check_Browser(x,y,w,h);
275    // Fl_Check_Browser::add calls fl_height(), which requires the X display open.
276    // Avoid this when compiling so it works w/o a display:
277    if (!compile_only) {
278      char buffer[20];
279      for (int i = 1; i <= 20; i++) {
280        sprintf(buffer,"Browser Line %d",i);
281        b->add(buffer);
282      }
283    }
284    return b;
285  }
286  Fl_Widget_Type *_make() {return new Fl_Check_Browser_Type();}
287  int pixmapID() { return 32; }
288};
289static Fl_Check_Browser_Type Fl_Check_Browser_type;
290
291int Fl_Check_Browser_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
292  Fl_Check_Browser *myo = (Fl_Check_Browser*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
293  switch (w) {
294    case 4:
295    case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
296    case 1: myo->textfont(f); break;
297    case 2: myo->textsize(s); break;
298    case 3: myo->textcolor(c); break;
299  }
300  return 1;
301}
302
303class Fl_File_Browser_Type : public Fl_Widget_Type {
304  Fl_Menu_Item *subtypes() {return browser_type_menu;}
305  int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
306public:
307  virtual void ideal_size(int &w, int &h) {
308    Fl_File_Browser *myo = (Fl_File_Browser *)o;
309    fl_font(myo->textfont(), myo->textsize());
310    h -= Fl::box_dh(o->box());
311    w -= Fl::box_dw(o->box()) + fl_height();
312    int ww = (int)fl_width('m');
313    w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
314    h = ((h + fl_height() - 1) / fl_height()) * fl_height() +
315        Fl::box_dh(o->box());
316    if (h < 30) h = 30;
317    if (w < 50) w = 50;
318  }
319  virtual const char *type_name() {return "Fl_File_Browser";}
320  Fl_Widget *widget(int x,int y,int w,int h) {
321    Fl_File_Browser* b = new Fl_File_Browser(x,y,w,h);
322    // Fl_File_Browser::add calls fl_height(), which requires the X display open.
323    // Avoid this when compiling so it works w/o a display:
324    if (!compile_only) {
325      b->load(".");
326    }
327    return b;
328  }
329  Fl_Widget_Type *_make() {return new Fl_File_Browser_Type();}
330  int pixmapID() { return 33; }
331};
332static Fl_File_Browser_Type Fl_File_Browser_type;
333
334int Fl_File_Browser_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
335  Fl_File_Browser *myo = (Fl_File_Browser*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
336  switch (w) {
337    case 4:
338    case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
339    case 1: myo->textfont(f); break;
340    case 2: myo->textsize(s); break;
341    case 3: myo->textcolor(c); break;
342  }
343  return 1;
344}
345
346////////////////////////////////////////////////////////////////
347
348#include <FL/Fl_Counter.H>
349static Fl_Menu_Item counter_type_menu[] = {
350  {"Normal",0,0,(void*)FL_NORMAL_COUNTER},
351  {"Simple",0,0,(void*)FL_SIMPLE_COUNTER},
352  {0}};
353class Fl_Counter_Type : public Fl_Widget_Type {
354  Fl_Menu_Item *subtypes() {return counter_type_menu;}
355  int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
356  int is_valuator() const {return 1;}
357  int pixmapID() { return 41; }
358public:
359  virtual const char *type_name() {return "Fl_Counter";}
360  Fl_Widget *widget(int x,int y,int w,int h) {
361    return new Fl_Counter(x,y,w,h,"counter:");}
362  Fl_Widget_Type *_make() {return new Fl_Counter_Type();}
363};
364static Fl_Counter_Type Fl_Counter_type;
365
366int Fl_Counter_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
367  Fl_Counter *myo = (Fl_Counter*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
368  switch (w) {
369    case 4:
370    case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
371    case 1: myo->textfont(f); break;
372    case 2: myo->textsize(s); break;
373    case 3: myo->textcolor(c); break;
374  }
375  return 1;
376}
377
378////////////////////////////////////////////////////////////////
379
380#include <FL/Fl_Spinner.H>
381static Fl_Menu_Item spinner_type_menu[] = {
382  {"Integer",0,0,(void*)FL_INT_INPUT},
383  {"Float",  0,0,(void*)FL_FLOAT_INPUT},
384  {0}};
385class Fl_Spinner_Type : public Fl_Widget_Type {
386  Fl_Menu_Item *subtypes() {return spinner_type_menu;}
387  int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
388  int pixmapID() { return 47; }
389public:
390  virtual void ideal_size(int &w, int &h) {
391    Fl_Spinner *myo = (Fl_Spinner *)o;
392    fl_font(myo->textfont(), myo->textsize());
393    h = fl_height() + myo->textsize() - 6;
394    if (h < 15) h = 15;
395    w -= Fl::box_dw(o->box());
396    int ww = (int)fl_width('m');
397    w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box()) + h / 2;
398    if (w < 40) w = 40  ;
399  }
400  virtual const char *type_name() {return "Fl_Spinner";}
401  int is_spinner() const { return 1; }
402  Fl_Widget *widget(int x,int y,int w,int h) {
403    return new Fl_Spinner(x,y,w,h,"spinner:");}
404  Fl_Widget_Type *_make() {return new Fl_Spinner_Type();}
405};
406static Fl_Spinner_Type Fl_Spinner_type;
407
408int Fl_Spinner_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
409  Fl_Spinner *myo = (Fl_Spinner*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
410  switch (w) {
411    case 4:
412    case 0: f = (Fl_Font)myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
413    case 1: myo->textfont(f); break;
414    case 2: myo->textsize(s); break;
415    case 3: myo->textcolor(c); break;
416  }
417  return 1;
418}
419
420////////////////////////////////////////////////////////////////
421
422#include <FL/Fl_Input.H>
423static Fl_Menu_Item input_type_menu[] = {
424  {"Normal",0,0,(void*)FL_NORMAL_INPUT},
425  {"Multiline",0,0,(void*)FL_MULTILINE_INPUT},
426  {"Secret",0,0,(void*)FL_SECRET_INPUT},
427  {"Int",0,0,(void*)FL_INT_INPUT},
428  {"Float",0,0,(void*)FL_FLOAT_INPUT},
429  {0}};
430class Fl_Input_Type : public Fl_Widget_Type {
431  Fl_Menu_Item *subtypes() {return input_type_menu;}
432  int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
433public:
434  virtual void ideal_size(int &w, int &h) {
435    Fl_Input *myo = (Fl_Input *)o;
436    fl_font(myo->textfont(), myo->textsize());
437    h = fl_height() + myo->textsize() - 6;
438    w -= Fl::box_dw(o->box());
439    int ww = (int)fl_width('m');
440    w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
441    if (h < 15) h = 15;
442    if (w < 15) w = 15;
443  }
444  virtual const char *type_name() {return "Fl_Input";}
445  Fl_Widget *widget(int x,int y,int w,int h) {
446    Fl_Input *myo = new Fl_Input(x,y,w,h,"input:");
447    myo->value("Text Input");
448    return myo;
449  }
450  Fl_Widget_Type *_make() {return new Fl_Input_Type();}
451  int pixmapID() { return 14; }
452  virtual void copy_properties() {
453    Fl_Widget_Type::copy_properties();
454    Fl_Input_ *d = (Fl_Input_*)live_widget, *s = (Fl_Input_*)o;
455    d->textfont(s->textfont());
456    d->textsize(s->textsize());
457    d->textcolor(s->textcolor());
458  }
459};
460static Fl_Input_Type Fl_Input_type;
461
462int Fl_Input_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
463  Fl_Input_ *myo = (Fl_Input_*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
464  switch (w) {
465    case 4:
466    case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
467    case 1: myo->textfont(f); break;
468    case 2: myo->textsize(s); break;
469    case 3: myo->textcolor(c); break;
470  }
471  return 1;
472}
473
474////////////////////////////////////////////////////////////////
475
476#include <FL/Fl_File_Input.H>
477class Fl_File_Input_Type : public Fl_Widget_Type {
478  Fl_Menu_Item *subtypes() {return 0;}
479  int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
480public:
481  virtual void ideal_size(int &w, int &h) {
482    Fl_File_Input *myo = (Fl_File_Input *)o;
483    fl_font(myo->textfont(), myo->textsize());
484    h = fl_height() + myo->textsize() + 4;
485    w -= Fl::box_dw(o->box());
486    int ww = (int)fl_width('m');
487    w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
488    if (h < 20) h = 20;
489    if (w < 50) w = 50;
490  }
491  virtual const char *type_name() {return "Fl_File_Input";}
492  Fl_Widget *widget(int x,int y,int w,int h) {
493    Fl_File_Input *myo = new Fl_File_Input(x,y,w,h,"file:");
494    myo->value("/now/is/the/time/for/a/filename.ext");
495    return myo;
496  }
497  Fl_Widget_Type *_make() {return new Fl_File_Input_Type();}
498  int pixmapID() { return 30; }
499};
500static Fl_File_Input_Type Fl_File_Input_type;
501
502int Fl_File_Input_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
503  Fl_File_Input *myo = (Fl_File_Input*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
504  switch (w) {
505    case 4:
506    case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
507    case 1: myo->textfont(f); break;
508    case 2: myo->textsize(s); break;
509    case 3: myo->textcolor(c); break;
510  }
511  return 1;
512}
513
514////////////////////////////////////////////////////////////////
515
516#include <FL/Fl_Text_Display.H>
517class Fl_Text_Display_Type : public Fl_Widget_Type {
518  int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
519public:
520  virtual void ideal_size(int &w, int &h) {
521    Fl_Text_Display *myo = (Fl_Text_Display *)o;
522    fl_font(myo->textfont(), myo->textsize());
523    h -= Fl::box_dh(o->box());
524    w -= Fl::box_dw(o->box());
525    int ww = (int)fl_width('m');
526    w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
527    h = ((h + fl_height() - 1) / fl_height()) * fl_height() +
528        Fl::box_dh(o->box());
529    if (h < 30) h = 30;
530    if (w < 50) w = 50;
531  }
532  virtual const char *type_name() {return "Fl_Text_Display";}
533  Fl_Widget *widget(int x,int y,int w,int h) {
534    Fl_Text_Display *myo = new Fl_Text_Display(x,y,w,h);
535    return myo;
536  }
537  Fl_Widget_Type *_make() {return new Fl_Text_Display_Type();}
538  int pixmapID() { return 28; }
539};
540static Fl_Text_Display_Type Fl_Text_Display_type;
541
542int Fl_Text_Display_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
543  Fl_Text_Display *myo = (Fl_Text_Display*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
544  switch (w) {
545    case 4:
546    case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
547    case 1: myo->textfont(f); break;
548    case 2: myo->textsize(s); break;
549    case 3: myo->textcolor(c); break;
550  }
551  return 1;
552}
553
554////////////////////////////////////////////////////////////////
555
556#include <FL/Fl_Text_Editor.H>
557class Fl_Text_Editor_Type : public Fl_Widget_Type {
558  int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
559public:
560  virtual void ideal_size(int &w, int &h) {
561    Fl_Text_Editor *myo = (Fl_Text_Editor *)o;
562    fl_font(myo->textfont(), myo->textsize());
563    h -= Fl::box_dh(o->box());
564    w -= Fl::box_dw(o->box());
565    int ww = (int)fl_width('m');
566    w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
567    h = ((h + fl_height() - 1) / fl_height()) * fl_height() +
568        Fl::box_dh(o->box());
569    if (h < 30) h = 30;
570    if (w < 50) w = 50;
571  }
572  virtual const char *type_name() {return "Fl_Text_Editor";}
573  Fl_Widget *widget(int x,int y,int w,int h) {
574    Fl_Text_Editor *myo = new Fl_Text_Editor(x,y,w,h);
575    return myo;
576  }
577  Fl_Widget_Type *_make() {return new Fl_Text_Editor_Type();}
578  int pixmapID() { return 29; }
579};
580static Fl_Text_Editor_Type Fl_Text_Editor_type;
581
582int Fl_Text_Editor_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
583  Fl_Text_Editor *myo = (Fl_Text_Editor*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
584  switch (w) {
585    case 4:
586    case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
587    case 1: myo->textfont(f); break;
588    case 2: myo->textsize(s); break;
589    case 3: myo->textcolor(c); break;
590  }
591  return 1;
592}
593
594////////////////////////////////////////////////////////////////
595
596#include <FL/Fl_Clock.H>
597class Fl_Clock_Type : public Fl_Widget_Type {
598public:
599  virtual const char *type_name() {return "Fl_Clock";}
600  Fl_Widget *widget(int x,int y,int w,int h) {
601    return new Fl_Clock(x,y,w,h);}
602  Fl_Widget_Type *_make() {return new Fl_Clock_Type();}
603  int pixmapID() { return 34; }
604};
605static Fl_Clock_Type Fl_Clock_type;
606
607////////////////////////////////////////////////////////////////
608
609#include <FL/Fl_Help_View.H>
610class Fl_Help_View_Type : public Fl_Widget_Type {
611public:
612  virtual void ideal_size(int &w, int &h) {
613    Fl_Help_View *myo = (Fl_Help_View *)o;
614    fl_font(myo->textfont(), myo->textsize());
615    h -= Fl::box_dh(o->box());
616    w -= Fl::box_dw(o->box());
617    int ww = (int)fl_width('m');
618    w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
619    h = ((h + fl_height() - 1) / fl_height()) * fl_height() +
620        Fl::box_dh(o->box());
621    if (h < 30) h = 30;
622    if (w < 50) w = 50;
623  }
624  virtual const char *type_name() {return "Fl_Help_View";}
625  Fl_Widget *widget(int x,int y,int w,int h) {
626    Fl_Help_View *myo = new Fl_Help_View(x,y,w,h);
627    if (!compile_only) {
628      myo->value("<HTML><BODY><H1>Fl_Help_View Widget</H1>"
629                 "<P>This is a Fl_Help_View widget.</P></BODY></HTML>");
630    }
631    return myo;}
632  Fl_Widget_Type *_make() {return new Fl_Help_View_Type();}
633  int pixmapID() { return 35; }
634};
635static Fl_Help_View_Type Fl_Help_View_type;
636
637////////////////////////////////////////////////////////////////
638
639#include <FL/Fl_Progress.H>
640class Fl_Progress_Type : public Fl_Widget_Type {
641public:
642  virtual const char *type_name() {return "Fl_Progress";}
643  Fl_Widget *widget(int x,int y,int w,int h) {
644    Fl_Progress *myo = new Fl_Progress(x,y,w,h,"label");
645    myo->value(50);
646    return myo;}
647  Fl_Widget_Type *_make() {return new Fl_Progress_Type();}
648  int pixmapID() { return 36; }
649};
650static Fl_Progress_Type Fl_Progress_type;
651
652////////////////////////////////////////////////////////////////
653
654#include <FL/Fl_Adjuster.H>
655class Fl_Adjuster_Type : public Fl_Widget_Type {
656  int is_valuator() const {return 1;}
657public:
658  virtual const char *type_name() {return "Fl_Adjuster";}
659  Fl_Widget *widget(int x,int y,int w,int h) {
660    return new Fl_Adjuster(x,y,w,h);}
661  Fl_Widget_Type *_make() {return new Fl_Adjuster_Type();}
662  int pixmapID() { return 40; }
663};
664static Fl_Adjuster_Type Fl_Adjuster_type;
665
666////////////////////////////////////////////////////////////////
667
668#include <FL/Fl_Dial.H>
669static Fl_Menu_Item dial_type_menu[] = {
670  {"Dot",0,0,(void*)0},
671  {"Line",0,0,(void*)FL_LINE_DIAL},
672  {"Fill",0,0,(void*)FL_FILL_DIAL},
673  {0}};
674class Fl_Dial_Type : public Fl_Widget_Type {
675  Fl_Menu_Item *subtypes() {return dial_type_menu;}
676  int is_valuator() const {return 1;}
677public:
678  virtual const char *type_name() {return "Fl_Dial";}
679  Fl_Widget *widget(int x,int y,int w,int h) {
680    return new Fl_Dial(x,y,w,h);}
681  Fl_Widget_Type *_make() {return new Fl_Dial_Type();}
682  int pixmapID() { return 42; }
683};
684static Fl_Dial_Type Fl_Dial_type;
685
686////////////////////////////////////////////////////////////////
687
688#include <FL/Fl_Roller.H>
689static Fl_Menu_Item roller_type_menu[] = {
690  {"Vertical",0,0,(void*)0},
691  {"Horizontal",0,0,(void*)FL_HORIZONTAL},
692  {0}};
693class Fl_Roller_Type : public Fl_Widget_Type {
694  Fl_Menu_Item *subtypes() {return roller_type_menu;}
695  int is_valuator() const {return 1;}
696public:
697  virtual const char *type_name() {return "Fl_Roller";}
698  Fl_Widget *widget(int x,int y,int w,int h) {
699    return new Fl_Roller(x,y,w,h);}
700  Fl_Widget_Type *_make() {return new Fl_Roller_Type();}
701  int pixmapID() { return 43; }
702};
703static Fl_Roller_Type Fl_Roller_type;
704
705////////////////////////////////////////////////////////////////
706
707#include <FL/Fl_Scrollbar.H>
708static Fl_Menu_Item slider_type_menu[] = {
709  {"Vertical",0,0,(void*)FL_VERT_SLIDER},
710  {"Horizontal",0,0,(void*)FL_HOR_SLIDER},
711  {"Vert Fill",0,0,(void*)FL_VERT_FILL_SLIDER},
712  {"Horz Fill",0,0,(void*)FL_HOR_FILL_SLIDER},
713  {"Vert Knob",0,0,(void*)FL_VERT_NICE_SLIDER},
714  {"Horz Knob",0,0,(void*)FL_HOR_NICE_SLIDER},
715  {0}};
716class Fl_Slider_Type : public Fl_Widget_Type {
717  Fl_Menu_Item *subtypes() {return slider_type_menu;}
718  int is_valuator() const {return 2;}
719public:
720  virtual const char *type_name() {return "Fl_Slider";}
721  Fl_Widget *widget(int x,int y,int w,int h) {
722    return new Fl_Slider(x,y,w,h,"slider:");}
723  Fl_Widget_Type *_make() {return new Fl_Slider_Type();}
724  int pixmapID() { return 37; }
725};
726static Fl_Slider_Type Fl_Slider_type;
727
728static Fl_Menu_Item scrollbar_type_menu[] = {
729  {"Vertical",0,0,(void*)FL_VERT_SLIDER},
730  {"Horizontal",0,0,(void*)FL_HOR_SLIDER},
731  {0}};
732class Fl_Scrollbar_Type : public Fl_Slider_Type {
733  Fl_Menu_Item *subtypes() {return scrollbar_type_menu;}
734  int is_valuator() const {return 3;}
735public:
736  virtual const char *type_name() {return "Fl_Scrollbar";}
737  Fl_Widget *widget(int x,int y,int w,int h) {
738    return new Fl_Scrollbar(x,y,w,h);}
739  Fl_Widget_Type *_make() {return new Fl_Scrollbar_Type();}
740  int pixmapID() { return 38; }
741};
742static Fl_Scrollbar_Type Fl_Scrollbar_type;
743
744////////////////////////////////////////////////////////////////
745
746#include <FL/Fl_Output.H>
747static Fl_Menu_Item output_type_menu[] = {
748  {"Normal",0,0,(void*)FL_NORMAL_OUTPUT},
749  {"Multiline",0,0,(void*)FL_MULTILINE_OUTPUT},
750  {0}};
751class Fl_Output_Type : public Fl_Input_Type {
752  Fl_Menu_Item *subtypes() {return output_type_menu;}
753public:
754  virtual void ideal_size(int &w, int &h) {
755    Fl_Output *myo = (Fl_Output *)o;
756    fl_font(myo->textfont(), myo->textsize());
757    h = fl_height() + myo->textsize() - 6;
758    w -= Fl::box_dw(o->box());
759    int ww = (int)fl_width('m');
760    w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
761    if (h < 15) h = 15;
762    if (w < 15) w = 15;
763  }
764  virtual const char *type_name() {return "Fl_Output";}
765  Fl_Widget *widget(int x,int y,int w,int h) {
766    Fl_Output *myo = new Fl_Output(x,y,w,h,"output:");
767    myo->value("Text Output");
768    return myo;
769  }
770  Fl_Widget_Type *_make() {return new Fl_Output_Type();}
771  int pixmapID() { return 27; }
772};
773static Fl_Output_Type Fl_Output_type;
774
775////////////////////////////////////////////////////////////////
776
777#include <FL/Fl_Value_Input.H>
778class Fl_Value_Input_Type : public Fl_Widget_Type {
779public:
780  virtual void ideal_size(int &w, int &h) {
781    Fl_Value_Input *myo = (Fl_Value_Input *)o;
782    fl_font(myo->textfont(), myo->textsize());
783    h = fl_height() + myo->textsize() - 6;
784    w -= Fl::box_dw(o->box());
785    int ww = (int)fl_width('m');
786    w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
787    if (h < 15) h = 15;
788    if (w < 15) w = 15;
789  }
790  virtual const char *type_name() {return "Fl_Value_Input";}
791  int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
792  int is_valuator() const {return 1;}
793  Fl_Widget *widget(int x,int y,int w,int h) {
794    Fl_Value_Input *myo = new Fl_Value_Input(x,y,w,h,"value:");
795    return myo;
796  }
797  Fl_Widget_Type *_make() {return new Fl_Value_Input_Type();}
798  int pixmapID() { return 44; }
799};
800static Fl_Value_Input_Type Fl_Value_Input_type;
801
802int Fl_Value_Input_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
803  Fl_Value_Input *myo = (Fl_Value_Input*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
804  switch (w) {
805    case 4:
806    case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
807    case 1: myo->textfont(f); break;
808    case 2: myo->textsize(s); break;
809    case 3: myo->textcolor(c); break;
810  }
811  return 1;
812}
813
814////////////////////////////////////////////////////////////////
815
816#include <FL/Fl_Value_Output.H>
817class Fl_Value_Output_Type : public Fl_Widget_Type {
818public:
819  virtual void ideal_size(int &w, int &h) {
820    Fl_Value_Output *myo = (Fl_Value_Output *)o;
821    fl_font(myo->textfont(), myo->textsize());
822    h = fl_height() + myo->textsize() - 6;
823    w = o->w() - Fl::box_dw(o->box());
824    int ww = (int)fl_width('m');
825    w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
826    if (h < 15) h = 15;
827    if (w < 15) w = 15;
828  }
829  virtual const char *type_name() {return "Fl_Value_Output";}
830  int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
831  int is_valuator() const {return 1;}
832  Fl_Widget *widget(int x,int y,int w,int h) {
833    Fl_Value_Output *myo = new Fl_Value_Output(x,y,w,h,"value:");
834    return myo;
835  }
836  Fl_Widget_Type *_make() {return new Fl_Value_Output_Type();}
837  int pixmapID() { return 45; }
838};
839static Fl_Value_Output_Type Fl_Value_Output_type;
840
841int Fl_Value_Output_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
842  Fl_Value_Output *myo = (Fl_Value_Output*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
843  switch (w) {
844    case 4:
845    case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
846    case 1: myo->textfont(f); break;
847    case 2: myo->textsize(s); break;
848    case 3: myo->textcolor(c); break;
849  }
850  return 1;
851}
852
853////////////////////////////////////////////////////////////////
854
855#include <FL/Fl_Value_Slider.H>
856class Fl_Value_Slider_Type : public Fl_Slider_Type {
857  int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
858public:
859  virtual const char *type_name() {return "Fl_Value_Slider";}
860  Fl_Widget *widget(int x,int y,int w,int h) {
861    return new Fl_Value_Slider(x,y,w,h,"slider:");}
862  Fl_Widget_Type *_make() {return new Fl_Value_Slider_Type();}
863  int pixmapID() { return 39; }
864};
865static Fl_Value_Slider_Type Fl_Value_Slider_type;
866
867int Fl_Value_Slider_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
868  Fl_Value_Slider *myo = (Fl_Value_Slider*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
869  switch (w) {
870    case 4:
871    case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
872    case 1: myo->textfont(f); break;
873    case 2: myo->textsize(s); break;
874    case 3: myo->textcolor(c); break;
875  }
876  return 1;
877}
878
879////////////////////////////////////////////////////////////////
880
881extern class Fl_Function_Type Fl_Function_type;
882extern class Fl_Code_Type Fl_Code_type;
883extern class Fl_CodeBlock_Type Fl_CodeBlock_type;
884extern class Fl_Decl_Type Fl_Decl_type;
885extern class Fl_DeclBlock_Type Fl_DeclBlock_type;
886extern class Fl_Comment_Type Fl_Comment_type;
887extern class Fl_Class_Type Fl_Class_type;
888extern class Fl_Window_Type Fl_Window_type;
889extern class Fl_Widget_Class_Type Fl_Widget_Class_type;
890extern class Fl_Group_Type Fl_Group_type;
891extern class Fl_Pack_Type Fl_Pack_type;
892extern class Fl_Tabs_Type Fl_Tabs_type;
893extern class Fl_Scroll_Type Fl_Scroll_type;
894extern class Fl_Tile_Type Fl_Tile_type;
895extern class Fl_Input_Choice_Type Fl_Input_Choice_type;
896extern class Fl_Choice_Type Fl_Choice_type;
897extern class Fl_Menu_Bar_Type Fl_Menu_Bar_type;
898extern class Fl_Menu_Button_Type Fl_Menu_Button_type;
899extern class Fl_Menu_Item_Type Fl_Menu_Item_type;
900extern class Fl_Submenu_Type Fl_Submenu_type;
901extern class Fl_Wizard_Type Fl_Wizard_type;
902
903extern void select(Fl_Type *,int);
904extern void select_only(Fl_Type *);
905
906#include <FL/Fl_Window.H>
907
908static void cb(Fl_Widget *, void *v) {
909  undo_checkpoint();
910  undo_suspend();
911  Fl_Type *t = ((Fl_Type*)v)->make();
912  if (t) {
913    if (t->is_widget() && !t->is_window()) {
914      Fl_Widget_Type *wt = (Fl_Widget_Type *)t;
915
916      // Set font sizes...
917      wt->o->labelsize(Fl_Widget_Type::default_size);
918
919      Fl_Font f;
920      int s = Fl_Widget_Type::default_size;
921      Fl_Color c;
922
923      wt->textstuff(2, f, s, c);
924
925      // Resize and/or reposition new widget...
926      int w = 0, h = 0;
927      wt->ideal_size(w, h);
928
929      if (!strcmp(wt->type_name(), "Fl_Menu_Bar")) {
930        // Move and resize the menubar across the top of the window...
931        wt->o->resize(0, 0, w, h);
932      } else {
933        // Just resize to the ideal size...
934        wt->o->size(w, h);
935      }
936    }
937    select_only(t);
938    set_modflag(1);
939    t->open();
940  } else {
941    undo_current --;
942    undo_last --;
943  }
944  undo_resume();
945}
946
947Fl_Menu_Item New_Menu[] = {
948{"Code",0,0,0,FL_SUBMENU},
949  {"Function/Method",0,cb,(void*)&Fl_Function_type},
950  {"Code",0,cb,(void*)&Fl_Code_type},
951  {"Code Block",0,cb,(void*)&Fl_CodeBlock_type},
952  {"Declaration",0,cb,(void*)&Fl_Decl_type},
953  {"Declaration Block",0,cb,(void*)&Fl_DeclBlock_type},
954  {"Class",0,cb,(void*)&Fl_Class_type},
955  {"Widget Class",0,cb,(void*)&Fl_Widget_Class_type},
956  {"Comment",0,cb,(void*)&Fl_Comment_type},
957{0},
958{"Group",0,0,0,FL_SUBMENU},
959  {0,0,cb,(void*)&Fl_Window_type},
960  {0,0,cb,(void*)&Fl_Group_type},
961  {0,0,cb,(void*)&Fl_Pack_type},
962  {0,0,cb,(void*)&Fl_Tabs_type},
963  {0,0,cb,(void*)&Fl_Scroll_type},
964  {0,0,cb,(void*)&Fl_Tile_type},
965  {0,0,cb,(void*)&Fl_Wizard_type},
966{0},
967{"Buttons",0,0,0,FL_SUBMENU},
968  {0,0,cb,(void*)&Fl_Button_type},
969  {0,0,cb,(void*)&Fl_Return_Button_type},
970  {0,0,cb,(void*)&Fl_Light_Button_type},
971  {0,0,cb,(void*)&Fl_Check_Button_type},
972  {0,0,cb,(void*)&Fl_Repeat_Button_type},
973  {0,0,cb,(void*)&Fl_Round_Button_type},
974{0},
975{"Valuators",0,0,0,FL_SUBMENU},
976  {0,0,cb,(void*)&Fl_Slider_type},
977  {0,0,cb,(void*)&Fl_Scrollbar_type},
978  {0,0,cb,(void*)&Fl_Value_Slider_type},
979  {0,0,cb,(void*)&Fl_Adjuster_type},
980  {0,0,cb,(void*)&Fl_Counter_type},
981  {0,0,cb,(void*)&Fl_Spinner_type},
982  {0,0,cb,(void*)&Fl_Dial_type},
983  {0,0,cb,(void*)&Fl_Roller_type},
984  {0,0,cb,(void*)&Fl_Value_Input_type},
985  {0,0,cb,(void*)&Fl_Value_Output_type},
986{0},
987{"Text",0,0,0,FL_SUBMENU},
988  {0,0,cb,(void*)&Fl_File_Input_type},
989  {0,0,cb,(void*)&Fl_Input_type},
990  {0,0,cb,(void*)&Fl_Output_type},
991  {0,0,cb,(void*)&Fl_Text_Display_type},
992  {0,0,cb,(void*)&Fl_Text_Editor_type},
993{0},
994{"Menus",0,0,0,FL_SUBMENU},
995  {0,0,cb,(void*)&Fl_Menu_Bar_type},
996  {0,0,cb,(void*)&Fl_Menu_Button_type},
997  {0,0,cb,(void*)&Fl_Choice_type},
998  {0,0,cb,(void*)&Fl_Input_Choice_type},
999  {0,0,cb, (void*)&Fl_Submenu_type},
1000  {0,0,cb, (void*)&Fl_Menu_Item_type},
1001{0},
1002{"Browsers",0,0,0,FL_SUBMENU},
1003  {0,0,cb,(void*)&Fl_Browser_type},
1004  {0,0,cb,(void*)&Fl_Check_Browser_type},
1005  {0,0,cb,(void*)&Fl_File_Browser_type},
1006{0},
1007{"Other",0,0,0,FL_SUBMENU},
1008  {0,0,cb,(void*)&Fl_Box_type},
1009  {0,0,cb,(void*)&Fl_Clock_type},
1010  {0,0,cb,(void*)&Fl_Help_View_type},
1011  {0,0,cb,(void*)&Fl_Progress_type},
1012{0},
1013{0}};
1014
1015#include <FL/Fl_Multi_Label.H>
1016
1017// modify a menuitem to display an icon in front of the label
1018static void make_iconlabel( Fl_Menu_Item *mi, Fl_Image *ic, const char *txt )
1019{
1020  if (ic) {
1021    char *t1 = new char[strlen(txt)+6];
1022    strcpy( t1, " " );
1023    strcat(t1, txt);
1024    strcat(t1, "...");
1025    mi->image( ic );
1026    Fl_Multi_Label *ml = new Fl_Multi_Label;
1027    ml->labela = (char*)ic;
1028    ml->labelb = t1;
1029    ml->typea = _FL_IMAGE_LABEL;
1030    ml->typeb = FL_NORMAL_LABEL;
1031    ml->label( mi );
1032  }
1033  else if (txt!=mi->text)
1034    mi->label(txt);
1035}
1036
1037void fill_in_New_Menu() {
1038  for (unsigned i = 0; i < sizeof(New_Menu)/sizeof(*New_Menu); i++) {
1039    Fl_Menu_Item *m = New_Menu+i;
1040    if (m->user_data()) {
1041      Fl_Type *t = (Fl_Type*)m->user_data();
1042      if (m->text) {
1043        make_iconlabel( m, pixmap[t->pixmapID()], m->label() );
1044      }
1045      else {
1046        const char *n = t->type_name();
1047        if (!strncmp(n,"Fl_",3)) n += 3;
1048        make_iconlabel( m, pixmap[t->pixmapID()], n );
1049      }
1050    }
1051  }
1052}
1053
1054// use keyword to pick the type, this is used to parse files:
1055int reading_file;
1056Fl_Type *Fl_Type_make(const char *tn) {
1057  reading_file = 1; // makes labels be null
1058  Fl_Type *r = 0;
1059  for (unsigned i = 0; i < sizeof(New_Menu)/sizeof(*New_Menu); i++) {
1060    Fl_Menu_Item *m = New_Menu+i;
1061    if (!m->user_data()) continue;
1062    Fl_Type *t = (Fl_Type*)(m->user_data());
1063    if (!strcasecmp(tn,t->type_name())) {r = t->make(); break;}
1064  }
1065  reading_file = 0;
1066  return r;
1067}
1068
1069////////////////////////////////////////////////////////////////
1070
1071// Since I have included all the .H files, do this table here:
1072// This table is only used to read fdesign files:
1073
1074struct symbol {const char *name; int value;};
1075
1076static symbol table[] = {
1077  {"BLACK",     FL_BLACK},
1078  {"RED",       FL_RED},
1079  {"GREEN",     FL_GREEN},
1080  {"YELLOW",    FL_YELLOW},
1081  {"BLUE",      FL_BLUE},
1082  {"MAGENTA",   FL_MAGENTA},
1083  {"CYAN",      FL_CYAN},
1084  {"WHITE",     FL_WHITE},
1085
1086  {"LCOL",               FL_BLACK},
1087  {"COL1",               FL_GRAY},
1088  {"MCOL",               FL_LIGHT1},
1089  {"LEFT_BCOL",          FL_LIGHT3},
1090  {"TOP_BCOL",           FL_LIGHT2},
1091  {"BOTTOM_BCOL",        FL_DARK2},
1092  {"RIGHT_BCOL",                 FL_DARK3},
1093  {"INACTIVE",           FL_INACTIVE_COLOR},
1094  {"INACTIVE_COL",       FL_INACTIVE_COLOR},
1095  {"FREE_COL1",          FL_FREE_COLOR},
1096  {"FREE_COL2",          FL_FREE_COLOR+1},
1097  {"FREE_COL3",          FL_FREE_COLOR+2},
1098  {"FREE_COL4",          FL_FREE_COLOR+3},
1099  {"FREE_COL5",          FL_FREE_COLOR+4},
1100  {"FREE_COL6",          FL_FREE_COLOR+5},
1101  {"FREE_COL7",          FL_FREE_COLOR+6},
1102  {"FREE_COL8",          FL_FREE_COLOR+7},
1103  {"FREE_COL9",          FL_FREE_COLOR+8},
1104  {"FREE_COL10",                 FL_FREE_COLOR+9},
1105  {"FREE_COL11",                 FL_FREE_COLOR+10},
1106  {"FREE_COL12",                 FL_FREE_COLOR+11},
1107  {"FREE_COL13",                 FL_FREE_COLOR+12},
1108  {"FREE_COL14",                 FL_FREE_COLOR+13},
1109  {"FREE_COL15",                 FL_FREE_COLOR+14},
1110  {"FREE_COL16",                 FL_FREE_COLOR+15},
1111  {"TOMATO",             131},
1112  {"INDIANRED",          164},
1113  {"SLATEBLUE",          195},
1114  {"DARKGOLD",           84},
1115  {"PALEGREEN",          157},
1116  {"ORCHID",             203},
1117  {"DARKCYAN",           189},
1118  {"DARKTOMATO",                 113},
1119  {"WHEAT",              174},
1120  {"ALIGN_CENTER",      FL_ALIGN_CENTER},
1121  {"ALIGN_TOP",         FL_ALIGN_TOP},
1122  {"ALIGN_BOTTOM",      FL_ALIGN_BOTTOM},
1123  {"ALIGN_LEFT",        FL_ALIGN_LEFT},
1124  {"ALIGN_RIGHT",       FL_ALIGN_RIGHT},
1125  {"ALIGN_INSIDE",      FL_ALIGN_INSIDE},
1126  {"ALIGN_TOP_LEFT",     FL_ALIGN_TOP | FL_ALIGN_LEFT},
1127  {"ALIGN_TOP_RIGHT",    FL_ALIGN_TOP | FL_ALIGN_RIGHT},
1128  {"ALIGN_BOTTOM_LEFT",  FL_ALIGN_BOTTOM | FL_ALIGN_LEFT},
1129  {"ALIGN_BOTTOM_RIGHT", FL_ALIGN_BOTTOM | FL_ALIGN_RIGHT},
1130  {"ALIGN_CENTER|FL_ALIGN_INSIDE",      FL_ALIGN_CENTER|FL_ALIGN_INSIDE},
1131  {"ALIGN_TOP|FL_ALIGN_INSIDE",         FL_ALIGN_TOP|FL_ALIGN_INSIDE},
1132  {"ALIGN_BOTTOM|FL_ALIGN_INSIDE",      FL_ALIGN_BOTTOM|FL_ALIGN_INSIDE},
1133  {"ALIGN_LEFT|FL_ALIGN_INSIDE",        FL_ALIGN_LEFT|FL_ALIGN_INSIDE},
1134  {"ALIGN_RIGHT|FL_ALIGN_INSIDE",       FL_ALIGN_RIGHT|FL_ALIGN_INSIDE},
1135  {"ALIGN_INSIDE|FL_ALIGN_INSIDE",      FL_ALIGN_INSIDE|FL_ALIGN_INSIDE},
1136  {"ALIGN_TOP_LEFT|FL_ALIGN_INSIDE",    FL_ALIGN_TOP|FL_ALIGN_LEFT|FL_ALIGN_INSIDE},
1137  {"ALIGN_TOP_RIGHT|FL_ALIGN_INSIDE",   FL_ALIGN_TOP|FL_ALIGN_RIGHT|FL_ALIGN_INSIDE},
1138  {"ALIGN_BOTTOM_LEFT|FL_ALIGN_INSIDE", FL_ALIGN_BOTTOM|FL_ALIGN_LEFT|FL_ALIGN_INSIDE},
1139  {"ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE",FL_ALIGN_BOTTOM|FL_ALIGN_RIGHT|FL_ALIGN_INSIDE},
1140
1141  {"ALIGN_LEFT_TOP",     FL_ALIGN_TOP | FL_ALIGN_LEFT},
1142  {"ALIGN_RIGHT_TOP",    FL_ALIGN_TOP | FL_ALIGN_RIGHT},
1143  {"ALIGN_LEFT_BOTTOM",  FL_ALIGN_BOTTOM | FL_ALIGN_LEFT},
1144  {"ALIGN_RIGHT_BOTTOM", FL_ALIGN_BOTTOM | FL_ALIGN_RIGHT},
1145  {"INVALID_STYLE",      255},
1146  {"NORMAL_STYLE",       FL_HELVETICA},
1147  {"BOLD_STYLE",                 FL_HELVETICA|FL_BOLD},
1148  {"ITALIC_STYLE",       FL_HELVETICA|FL_ITALIC},
1149  {"BOLDITALIC_STYLE",   FL_HELVETICA|FL_BOLD|FL_ITALIC},
1150  {"FIXED_STYLE",        FL_COURIER},
1151  {"FIXEDBOLD_STYLE",    FL_COURIER|FL_BOLD},
1152  {"FIXEDITALIC_STYLE",  FL_COURIER|FL_ITALIC},
1153  {"FIXEDBOLDITALIC_STYLE",  FL_COURIER|FL_BOLD|FL_ITALIC},
1154  {"TIMES_STYLE",        FL_TIMES},
1155  {"TIMESBOLD_STYLE",    FL_TIMES|FL_BOLD},
1156  {"TIMESITALIC_STYLE",  FL_TIMES|FL_ITALIC},
1157  {"TIMESBOLDITALIC_STYLE",  FL_TIMES|FL_BOLD|FL_ITALIC},
1158  {"SHADOW_STYLE",      (_FL_SHADOW_LABEL<<8)},
1159  {"ENGRAVED_STYLE",    (_FL_ENGRAVED_LABEL<<8)},
1160  {"EMBOSSED_STYLE",    (_FL_EMBOSSED_LABEL<<0)},
1161  {"TINY_SIZE",          8},
1162  {"SMALL_SIZE",                 11},
1163  {"NORMAL_SIZE",        FL_NORMAL_SIZE},
1164  {"MEDIUM_SIZE",        18},
1165  {"LARGE_SIZE",                 24},
1166  {"HUGE_SIZE",          32},
1167  {"DEFAULT_SIZE",       FL_NORMAL_SIZE},
1168  {"TINY_FONT",          8},
1169  {"SMALL_FONT",                 11},
1170  {"NORMAL_FONT",        FL_NORMAL_SIZE},
1171  {"MEDIUM_FONT",        18},
1172  {"LARGE_FONT",                 24},
1173  {"HUGE_FONT",          32},
1174  {"NORMAL_FONT1",       11},
1175  {"NORMAL_FONT2",       FL_NORMAL_SIZE},
1176  {"DEFAULT_FONT",       11},
1177  {"RETURN_END_CHANGED",  0},
1178  {"RETURN_CHANGED",     1},
1179  {"RETURN_END",                 2},
1180  {"RETURN_ALWAYS",      3},
1181  {"PUSH_BUTTON",       FL_TOGGLE_BUTTON},
1182  {"RADIO_BUTTON",      FL_RADIO_BUTTON},
1183  {"HIDDEN_BUTTON",     FL_HIDDEN_BUTTON},
1184  {"SELECT_BROWSER",    FL_SELECT_BROWSER},
1185  {"HOLD_BROWSER",      FL_HOLD_BROWSER},
1186  {"MULTI_BROWSER",     FL_MULTI_BROWSER},
1187  {"SIMPLE_COUNTER",    FL_SIMPLE_COUNTER},
1188  {"LINE_DIAL",         FL_LINE_DIAL},
1189  {"FILL_DIAL",         FL_FILL_DIAL},
1190  {"VERT_SLIDER",       FL_VERT_SLIDER},
1191  {"HOR_SLIDER",        FL_HOR_SLIDER},
1192  {"VERT_FILL_SLIDER",  FL_VERT_FILL_SLIDER},
1193  {"HOR_FILL_SLIDER",   FL_HOR_FILL_SLIDER},
1194  {"VERT_NICE_SLIDER",  FL_VERT_NICE_SLIDER},
1195  {"HOR_NICE_SLIDER",   FL_HOR_NICE_SLIDER},
1196};
1197
1198#include <stdlib.h>
1199
1200int lookup_symbol(const char *name, int &v, int numberok) {
1201  if (name[0]=='F' && name[1]=='L' && name[2]=='_') name += 3;
1202  for (int i=0; i < int(sizeof(table)/sizeof(*table)); i++)
1203    if (!strcasecmp(name,table[i].name)) {v = table[i].value; return 1;}
1204  if (numberok && ((v = atoi(name)) || !strcmp(name,"0"))) return 1;
1205  return 0;
1206}
1207
1208//
1209// End of "$Id$".
1210//
Note: See TracBrowser for help on using the repository browser.