fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
  SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation)  

factory.cxx

Go to the documentation of this file.
00001 //
00002 // "$Id: factory.cxx 8172 2011-01-03 08:28:38Z matt $"
00003 //
00004 // Widget factory code for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Type classes for most of the fltk widgets.  Most of the work
00007 // is done by code in Fl_Widget_Type.C.  Also a factory instance
00008 // of each of these type classes.
00009 //
00010 // This file also contains the "new" menu, which has a pointer
00011 // to a factory instance for every class (both the ones defined
00012 // here and ones in other files)
00013 //
00014 // Copyright 1998-2010 by Bill Spitzak and others.
00015 //
00016 // This library is free software; you can redistribute it and/or
00017 // modify it under the terms of the GNU Library General Public
00018 // License as published by the Free Software Foundation; either
00019 // version 2 of the License, or (at your option) any later version.
00020 //
00021 // This library is distributed in the hope that it will be useful,
00022 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00023 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00024 // Library General Public License for more details.
00025 //
00026 // You should have received a copy of the GNU Library General Public
00027 // License along with this library; if not, write to the Free Software
00028 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00029 // USA.
00030 //
00031 // Please report all bugs and problems on the following page:
00032 //
00033 //     http://www.fltk.org/str.php
00034 //
00035 
00036 #include <FL/Fl.H>
00037 #include <FL/Fl_Group.H>
00038 #include <FL/Fl_Menu_Item.H>
00039 #include <FL/Fl_Pixmap.H>
00040 #include <FL/Fl_Tree.H>
00041 #include <stdio.h>
00042 #include "../src/flstring.h"
00043 #include "undo.h"
00044 
00045 #include "Fl_Widget_Type.h"
00046 
00047 extern Fl_Pixmap *pixmap[];
00048 
00049 #if !HAVE_STRCASECMP
00050 //
00051 // 'strcasecmp()' - Do a case-insensitive compare...
00052 //
00053 
00054 static int
00055 strcasecmp(const char *s, const char *t) {
00056   while (*s != '\0' && *t != '\0') {
00057     if (tolower(*s) < tolower(*t))
00058       return (-1);
00059     else if (tolower(*s) > tolower(*t))
00060       return (1);
00061 
00062     s ++;
00063     t ++;
00064   }
00065 
00066   if (*s == '\0' && *t == '\0')
00067     return (0);
00068   else if (*s != '\0')
00069     return (1);
00070   else
00071     return (-1);
00072 }
00073 #endif // !HAVE_STRCASECMP
00074 
00076 
00077 #include <FL/Fl_Box.H>
00078 class Fl_Box_Type : public Fl_Widget_Type {
00079 public:
00080   virtual const char *type_name() {return "Fl_Box";}
00081   virtual const char *alt_type_name() {return "fltk::Widget";}
00082   Fl_Widget *widget(int x,int y,int w, int h) {
00083     return new Fl_Box(x,y,w,h,"label");}
00084   Fl_Widget_Type *_make() {return new Fl_Box_Type();}
00085   int pixmapID() { return 5; }
00086 };
00087 static Fl_Box_Type Fl_Box_type;
00088 
00090 
00091 #include <FL/Fl_Button.H>
00092 static Fl_Menu_Item buttontype_menu[] = {
00093   {"Normal",0,0,(void*)0},
00094   {"Toggle",0,0,(void*)FL_TOGGLE_BUTTON},
00095   {"Radio",0,0,(void*)FL_RADIO_BUTTON},
00096   {0}};
00097 class Fl_Button_Type : public Fl_Widget_Type {
00098   Fl_Menu_Item *subtypes() {return buttontype_menu;}
00099 public:
00100   virtual void ideal_size(int &w, int &h) {
00101     Fl_Widget_Type::ideal_size(w, h);
00102     w += 2 * (o->labelsize() - 4);
00103     h = (h / 5) * 5;
00104   }
00105   virtual const char *type_name() {return "Fl_Button";}
00106   virtual const char *alt_type_name() {return "fltk::Button";}
00107   Fl_Widget *widget(int x,int y,int w,int h) {
00108     return new Fl_Button(x,y,w,h,"button");}
00109   Fl_Widget_Type *_make() {return new Fl_Button_Type();}
00110   int is_button() const {return 1;}
00111   int pixmapID() { return 2; }
00112 };
00113 static Fl_Button_Type Fl_Button_type;
00114 
00116 
00117 #include <FL/Fl_Return_Button.H>
00118 class Fl_Return_Button_Type : public Fl_Button_Type {
00119 public:
00120   virtual void ideal_size(int &w, int &h) {
00121     Fl_Button_Type::ideal_size(w, h);
00122     int W = o->h();
00123     if (o->w()/3 < W) W = o->w()/3;
00124     w += W + 8 - o->labelsize();
00125   }
00126   virtual const char *type_name() {return "Fl_Return_Button";}
00127   virtual const char *alt_type_name() {return "fltk::ReturnButton";}
00128   Fl_Widget *widget(int x,int y,int w,int h) {
00129     return new Fl_Return_Button(x,y,w,h,"button");}
00130   Fl_Widget_Type *_make() {return new Fl_Return_Button_Type();}
00131   int pixmapID() { return 23; }
00132 };
00133 static Fl_Return_Button_Type Fl_Return_Button_type;
00134 
00136 
00137 #include <FL/Fl_Repeat_Button.H>
00138 class Fl_Repeat_Button_Type : public Fl_Widget_Type {
00139 public:
00140   virtual const char *type_name() {return "Fl_Repeat_Button";}
00141   virtual const char *alt_type_name() {return "fltk::RepeatButton";}
00142   Fl_Widget *widget(int x,int y,int w,int h) {
00143     return new Fl_Repeat_Button(x,y,w,h,"button");}
00144   Fl_Widget_Type *_make() {return new Fl_Repeat_Button_Type();}
00145   int pixmapID() { return 25; }
00146 };
00147 static Fl_Repeat_Button_Type Fl_Repeat_Button_type;
00148 
00150 
00151 #include <FL/Fl_Light_Button.H>
00152 class Fl_Light_Button_Type : public Fl_Button_Type {
00153 public:
00154   virtual void ideal_size(int &w, int &h) {
00155     Fl_Button_Type::ideal_size(w, h);
00156     w += 4;
00157   }
00158   virtual const char *type_name() {return "Fl_Light_Button";}
00159   virtual const char *alt_type_name() {return "fltk::LightButton";}
00160   Fl_Widget *widget(int x,int y,int w,int h) {
00161     return new Fl_Light_Button(x,y,w,h,"button");}
00162   Fl_Widget_Type *_make() {return new Fl_Light_Button_Type();}
00163   int pixmapID() { return 24; }
00164 };
00165 static Fl_Light_Button_Type Fl_Light_Button_type;
00166 
00168 
00169 #include <FL/Fl_Check_Button.H>
00170 class Fl_Check_Button_Type : public Fl_Button_Type {
00171 public:
00172   virtual void ideal_size(int &w, int &h) {
00173     Fl_Button_Type::ideal_size(w, h);
00174     w += 4;
00175   }
00176   virtual const char *type_name() {return "Fl_Check_Button";}
00177   virtual const char *alt_type_name() {return "fltk::CheckButton";}
00178   Fl_Widget *widget(int x,int y,int w,int h) {
00179     return new Fl_Check_Button(x,y,w,h,"button");}
00180   Fl_Widget_Type *_make() {return new Fl_Check_Button_Type();}
00181   int pixmapID() { return 3; }
00182 };
00183 static Fl_Check_Button_Type Fl_Check_Button_type;
00184 
00186 
00187 #include <FL/Fl_Round_Button.H>
00188 class Fl_Round_Button_Type : public Fl_Button_Type {
00189 public:
00190   virtual void ideal_size(int &w, int &h) {
00191     Fl_Button_Type::ideal_size(w, h);
00192     w += 4;
00193   }
00194   virtual const char *type_name() {return "Fl_Round_Button";}
00195   virtual const char *alt_type_name() {return "fltk::RadioButton";}
00196   Fl_Widget *widget(int x,int y,int w,int h) {
00197     return new Fl_Round_Button(x,y,w,h,"button");}
00198   Fl_Widget_Type *_make() {return new Fl_Round_Button_Type();}
00199   int pixmapID() { return 4; }
00200 };
00201 static Fl_Round_Button_Type Fl_Round_Button_type;
00202 
00204 
00205 extern int compile_only;
00206 
00207 #include <FL/Fl_Browser.H>
00208 #include <FL/Fl_Check_Browser.H>
00209 #include <FL/Fl_File_Browser.H>
00210 
00211 static Fl_Menu_Item browser_type_menu[] = {
00212   {"No Select",0,0,(void*)FL_NORMAL_BROWSER},
00213   {"Select",0,0,(void*)FL_SELECT_BROWSER},
00214   {"Hold",0,0,(void*)FL_HOLD_BROWSER},
00215   {"Multi",0,0,(void*)FL_MULTI_BROWSER},
00216   {0}};
00217 class Fl_Browser_Type : public Fl_Widget_Type {
00218   Fl_Menu_Item *subtypes() {return browser_type_menu;}
00219   int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
00220 public:
00221   virtual void ideal_size(int &w, int &h) {
00222     Fl_Browser *myo = (Fl_Browser *)o;
00223     fl_font(myo->textfont(), myo->textsize());
00224     h -= Fl::box_dh(o->box());
00225     w -= Fl::box_dw(o->box());
00226     int ww = (int)fl_width('m');
00227     w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
00228     h = ((h + fl_height() - 1) / fl_height()) * fl_height() +
00229         Fl::box_dh(o->box());
00230     if (h < 30) h = 30;
00231     if (w < 50) w = 50;
00232   }
00233   virtual const char *type_name() {return "Fl_Browser";}
00234   virtual const char *alt_type_name() {return "fltk::Browser";}
00235   Fl_Widget *widget(int x,int y,int w,int h) {
00236     Fl_Browser* b = new Fl_Browser(x,y,w,h);
00237     // Fl_Browser::add calls fl_height(), which requires the X display open.
00238     // Avoid this when compiling so it works w/o a display:
00239     if (!compile_only) {
00240       char buffer[20];
00241       for (int i = 1; i <= 20; i++) {
00242         sprintf(buffer,"Browser Line %d",i);
00243         b->add(buffer);
00244       }
00245     }
00246     return b;
00247   }
00248   Fl_Widget_Type *_make() {return new Fl_Browser_Type();}
00249   int pixmapID() { return 31; }
00250 };
00251 static Fl_Browser_Type Fl_Browser_type;
00252 
00253 int Fl_Browser_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
00254   Fl_Browser *myo = (Fl_Browser*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
00255   switch (w) {
00256     case 4:
00257     case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
00258     case 1: myo->textfont(f); break;
00259     case 2: myo->textsize(s); break;
00260     case 3: myo->textcolor(c); break;
00261   }
00262   return 1;
00263 }
00264 
00265 class Fl_Check_Browser_Type : public Fl_Widget_Type {
00266   Fl_Menu_Item *subtypes() {return browser_type_menu;}
00267   int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
00268 public:
00269   virtual void ideal_size(int &w, int &h) {
00270     Fl_Check_Browser *myo = (Fl_Check_Browser *)o;
00271     fl_font(myo->textfont(), myo->textsize());
00272     h -= Fl::box_dh(o->box());
00273     w -= Fl::box_dw(o->box()) - fl_height();
00274     int ww = (int)fl_width('m');
00275     w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
00276     h = ((h + fl_height() - 1) / fl_height()) * fl_height() +
00277         Fl::box_dh(o->box());
00278     if (h < 30) h = 30;
00279     if (w < 50) w = 50;
00280   }
00281   virtual const char *type_name() {return "Fl_Check_Browser";}
00282   virtual const char *alt_type_name() {return "fltk::CheckBrowser";}
00283   Fl_Widget *widget(int x,int y,int w,int h) {
00284     Fl_Check_Browser* b = new Fl_Check_Browser(x,y,w,h);
00285     // Fl_Check_Browser::add calls fl_height(), which requires the X display open.
00286     // Avoid this when compiling so it works w/o a display:
00287     if (!compile_only) {
00288       char buffer[20];
00289       for (int i = 1; i <= 20; i++) {
00290         sprintf(buffer,"Browser Line %d",i);
00291         b->add(buffer);
00292       }
00293     }
00294     return b;
00295   }
00296   Fl_Widget_Type *_make() {return new Fl_Check_Browser_Type();}
00297   int pixmapID() { return 32; }
00298 };
00299 static Fl_Check_Browser_Type Fl_Check_Browser_type;
00300 
00301 int Fl_Check_Browser_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
00302   Fl_Check_Browser *myo = (Fl_Check_Browser*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
00303   switch (w) {
00304     case 4:
00305     case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
00306     case 1: myo->textfont(f); break;
00307     case 2: myo->textsize(s); break;
00308     case 3: myo->textcolor(c); break;
00309   }
00310   return 1;
00311 }
00312 
00313 class Fl_Tree_Type : public Fl_Widget_Type {
00314 public:
00315   virtual void ideal_size(int &w, int &h) {
00316     if (h < 60) h = 60;
00317     if (w < 80) w = 80;
00318   }
00319   virtual const char *type_name() {return "Fl_Tree";}
00320   virtual const char *alt_type_name() {return "fltk::TreeBrowser";}
00321   Fl_Widget *widget(int x,int y,int w,int h) {
00322     Fl_Tree* b = new Fl_Tree(x,y,w,h);
00323     if (!compile_only) {
00324       b->add("/A1/B1/C1");
00325       b->add("/A1/B1/C2");
00326       b->add("/A1/B2/C1");
00327       b->add("/A1/B2/C2");
00328       b->add("/A2/B1/C1");
00329       b->add("/A2/B1/C2");
00330       b->add("/A2/B2/C1");
00331       b->add("/A2/B2/C2");
00332     }
00333     return b;
00334   }
00335   Fl_Widget_Type *_make() {return new Fl_Tree_Type();}
00336   int pixmapID() { return 50; }
00337 };
00338 static Fl_Tree_Type Fl_Tree_type;
00339 
00340 class Fl_File_Browser_Type : public Fl_Widget_Type {
00341   Fl_Menu_Item *subtypes() {return browser_type_menu;}
00342   int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
00343 public:
00344   virtual void ideal_size(int &w, int &h) {
00345     Fl_File_Browser *myo = (Fl_File_Browser *)o;
00346     fl_font(myo->textfont(), myo->textsize());
00347     h -= Fl::box_dh(o->box());
00348     w -= Fl::box_dw(o->box()) + fl_height();
00349     int ww = (int)fl_width('m');
00350     w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
00351     h = ((h + fl_height() - 1) / fl_height()) * fl_height() +
00352         Fl::box_dh(o->box());
00353     if (h < 30) h = 30;
00354     if (w < 50) w = 50;
00355   }
00356   virtual const char *type_name() {return "Fl_File_Browser";}
00357   virtual const char *alt_type_name() {return "fltk::FileBrowser";}
00358   Fl_Widget *widget(int x,int y,int w,int h) {
00359     Fl_File_Browser* b = new Fl_File_Browser(x,y,w,h);
00360     // Fl_File_Browser::add calls fl_height(), which requires the X display open.
00361     // Avoid this when compiling so it works w/o a display:
00362     if (!compile_only) {
00363       b->load(".");
00364     }
00365     return b;
00366   }
00367   Fl_Widget_Type *_make() {return new Fl_File_Browser_Type();}
00368   int pixmapID() { return 33; }
00369 };
00370 static Fl_File_Browser_Type Fl_File_Browser_type;
00371 
00372 int Fl_File_Browser_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
00373   Fl_File_Browser *myo = (Fl_File_Browser*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
00374   switch (w) {
00375     case 4:
00376     case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
00377     case 1: myo->textfont(f); break;
00378     case 2: myo->textsize(s); break;
00379     case 3: myo->textcolor(c); break;
00380   }
00381   return 1;
00382 }
00383 
00385 
00386 #include <FL/Fl_Counter.H>
00387 static Fl_Menu_Item counter_type_menu[] = {
00388   {"Normal",0,0,(void*)FL_NORMAL_COUNTER},
00389   {"Simple",0,0,(void*)FL_SIMPLE_COUNTER},
00390   {0}};
00391 class Fl_Counter_Type : public Fl_Widget_Type {
00392   Fl_Menu_Item *subtypes() {return counter_type_menu;}
00393   int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
00394   int is_valuator() const {return 1;}
00395   int pixmapID() { return 41; }
00396 public:
00397   virtual const char *type_name() {return "Fl_Counter";}
00398   virtual const char *alt_type_name() {return "fltk::Counter";}
00399   Fl_Widget *widget(int x,int y,int w,int h) {
00400     return new Fl_Counter(x,y,w,h,"counter:");}
00401   Fl_Widget_Type *_make() {return new Fl_Counter_Type();}
00402 };
00403 static Fl_Counter_Type Fl_Counter_type;
00404 
00405 int Fl_Counter_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
00406   Fl_Counter *myo = (Fl_Counter*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
00407   switch (w) {
00408     case 4:
00409     case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
00410     case 1: myo->textfont(f); break;
00411     case 2: myo->textsize(s); break;
00412     case 3: myo->textcolor(c); break;
00413   }
00414   return 1;
00415 }
00416 
00418 
00419 #include <FL/Fl_Spinner.H>
00420 static Fl_Menu_Item spinner_type_menu[] = {
00421   {"Integer",0,0,(void*)FL_INT_INPUT},
00422   {"Float",  0,0,(void*)FL_FLOAT_INPUT},
00423   {0}};
00424 class Fl_Spinner_Type : public Fl_Widget_Type {
00425   Fl_Menu_Item *subtypes() {return spinner_type_menu;}
00426   int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
00427   int pixmapID() { return 47; }
00428 public:
00429   virtual void ideal_size(int &w, int &h) {
00430     Fl_Spinner *myo = (Fl_Spinner *)o;
00431     fl_font(myo->textfont(), myo->textsize());
00432     h = fl_height() + myo->textsize() - 6;
00433     if (h < 15) h = 15;
00434     w -= Fl::box_dw(o->box());
00435     int ww = (int)fl_width('m');
00436     w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box()) + h / 2;
00437     if (w < 40) w = 40  ;
00438   }
00439   virtual const char *type_name() {return "Fl_Spinner";}
00440   virtual const char *alt_type_name() {return "fltk::Spinner";}
00441   int is_spinner() const { return 1; }
00442   Fl_Widget *widget(int x,int y,int w,int h) {
00443     return new Fl_Spinner(x,y,w,h,"spinner:");}
00444   Fl_Widget_Type *_make() {return new Fl_Spinner_Type();}
00445 };
00446 static Fl_Spinner_Type Fl_Spinner_type;
00447 
00448 int Fl_Spinner_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
00449   Fl_Spinner *myo = (Fl_Spinner*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
00450   switch (w) {
00451     case 4:
00452     case 0: f = (Fl_Font)myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
00453     case 1: myo->textfont(f); break;
00454     case 2: myo->textsize(s); break;
00455     case 3: myo->textcolor(c); break;
00456   }
00457   return 1;
00458 }
00459 
00461 
00462 #include <FL/Fl_Input.H>
00463 static Fl_Menu_Item input_type_menu[] = {
00464   {"Normal",0,0,(void*)FL_NORMAL_INPUT},
00465   {"Multiline",0,0,(void*)FL_MULTILINE_INPUT},
00466   {"Secret",0,0,(void*)FL_SECRET_INPUT},
00467   {"Int",0,0,(void*)FL_INT_INPUT},
00468   {"Float",0,0,(void*)FL_FLOAT_INPUT},
00469   {0}};
00470 class Fl_Input_Type : public Fl_Widget_Type {
00471   Fl_Menu_Item *subtypes() {return input_type_menu;}
00472   int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
00473 public:
00474   virtual void ideal_size(int &w, int &h) {
00475     Fl_Input *myo = (Fl_Input *)o;
00476     fl_font(myo->textfont(), myo->textsize());
00477     h = fl_height() + myo->textsize() - 6;
00478     w -= Fl::box_dw(o->box());
00479     int ww = (int)fl_width('m');
00480     w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
00481     if (h < 15) h = 15;
00482     if (w < 15) w = 15;
00483   }
00484   virtual const char *type_name() {return "Fl_Input";}
00485   virtual const char *alt_type_name() {return "fltk::Input";}
00486   int is_input() const {return 1;}
00487   Fl_Widget *widget(int x,int y,int w,int h) {
00488     Fl_Input *myo = new Fl_Input(x,y,w,h,"input:");
00489     myo->value("Text Input");
00490     return myo;
00491   }
00492   Fl_Widget_Type *_make() {return new Fl_Input_Type();}
00493   int pixmapID() { return 14; }
00494   virtual void copy_properties() {
00495     Fl_Widget_Type::copy_properties();
00496     Fl_Input_ *d = (Fl_Input_*)live_widget, *s = (Fl_Input_*)o;
00497     d->textfont(s->textfont());
00498     d->textsize(s->textsize());
00499     d->textcolor(s->textcolor());
00500     d->shortcut(s->shortcut());
00501   }
00502 };
00503 static Fl_Input_Type Fl_Input_type;
00504 
00505 int Fl_Input_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
00506   Fl_Input_ *myo = (Fl_Input_*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
00507   switch (w) {
00508     case 4:
00509     case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
00510     case 1: myo->textfont(f); break;
00511     case 2: myo->textsize(s); break;
00512     case 3: myo->textcolor(c); break;
00513   }
00514   return 1;
00515 }
00516 
00518 
00519 #include <FL/Fl_File_Input.H>
00520 class Fl_File_Input_Type : public Fl_Widget_Type {
00521   Fl_Menu_Item *subtypes() {return 0;}
00522   int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
00523 public:
00524   virtual void ideal_size(int &w, int &h) {
00525     Fl_File_Input *myo = (Fl_File_Input *)o;
00526     fl_font(myo->textfont(), myo->textsize());
00527     h = fl_height() + myo->textsize() + 4;
00528     w -= Fl::box_dw(o->box());
00529     int ww = (int)fl_width('m');
00530     w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
00531     if (h < 20) h = 20;
00532     if (w < 50) w = 50;
00533   }
00534   virtual const char *type_name() {return "Fl_File_Input";}
00535   virtual const char *alt_type_name() {return "fltk::FileInput";}
00536   int is_input() const {return 1;}
00537   Fl_Widget *widget(int x,int y,int w,int h) {
00538     Fl_File_Input *myo = new Fl_File_Input(x,y,w,h,"file:");
00539     myo->value("/now/is/the/time/for/a/filename.ext");
00540     return myo;
00541   }
00542   Fl_Widget_Type *_make() {return new Fl_File_Input_Type();}
00543   int pixmapID() { return 30; }
00544 };
00545 static Fl_File_Input_Type Fl_File_Input_type;
00546 
00547 int Fl_File_Input_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
00548   Fl_File_Input *myo = (Fl_File_Input*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
00549   switch (w) {
00550     case 4:
00551     case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
00552     case 1: myo->textfont(f); break;
00553     case 2: myo->textsize(s); break;
00554     case 3: myo->textcolor(c); break;
00555   }
00556   return 1;
00557 }
00558 
00560 
00561 #include <FL/Fl_Text_Display.H>
00562 class Fl_Text_Display_Type : public Fl_Widget_Type {
00563   int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
00564 public:
00565   virtual void ideal_size(int &w, int &h) {
00566     Fl_Text_Display *myo = (Fl_Text_Display *)o;
00567     fl_font(myo->textfont(), myo->textsize());
00568     h -= Fl::box_dh(o->box());
00569     w -= Fl::box_dw(o->box());
00570     int ww = (int)fl_width('m');
00571     w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
00572     h = ((h + fl_height() - 1) / fl_height()) * fl_height() +
00573         Fl::box_dh(o->box());
00574     if (h < 30) h = 30;
00575     if (w < 50) w = 50;
00576   }
00577   virtual const char *type_name() {return "Fl_Text_Display";}
00578   virtual const char *alt_type_name() {return "fltk::TextDisplay";}
00579   int is_text_display() const {return 1;}
00580   Fl_Widget *widget(int x,int y,int w,int h) {
00581     Fl_Text_Display *myo = new Fl_Text_Display(x,y,w,h);
00582     return myo;
00583   }
00584   Fl_Widget_Type *_make() {return new Fl_Text_Display_Type();}
00585   int pixmapID() { return 28; }
00586 };
00587 static Fl_Text_Display_Type Fl_Text_Display_type;
00588 
00589 int Fl_Text_Display_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
00590   Fl_Text_Display *myo = (Fl_Text_Display*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
00591   switch (w) {
00592     case 4:
00593     case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
00594     case 1: myo->textfont(f); break;
00595     case 2: myo->textsize(s); break;
00596     case 3: myo->textcolor(c); break;
00597   }
00598   return 1;
00599 }
00600 
00602 
00603 #include <FL/Fl_Text_Editor.H>
00604 class Fl_Text_Editor_Type : public Fl_Widget_Type {
00605   int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
00606 public:
00607   virtual void ideal_size(int &w, int &h) {
00608     Fl_Text_Editor *myo = (Fl_Text_Editor *)o;
00609     fl_font(myo->textfont(), myo->textsize());
00610     h -= Fl::box_dh(o->box());
00611     w -= Fl::box_dw(o->box());
00612     int ww = (int)fl_width('m');
00613     w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
00614     h = ((h + fl_height() - 1) / fl_height()) * fl_height() +
00615         Fl::box_dh(o->box());
00616     if (h < 30) h = 30;
00617     if (w < 50) w = 50;
00618   }
00619   virtual const char *type_name() {return "Fl_Text_Editor";}
00620   virtual const char *alt_type_name() {return "fltk::TextEditor";}
00621   int is_text_display() const {return 1;}
00622   Fl_Widget *widget(int x,int y,int w,int h) {
00623     Fl_Text_Editor *myo = new Fl_Text_Editor(x,y,w,h);
00624     return myo;
00625   }
00626   Fl_Widget_Type *_make() {return new Fl_Text_Editor_Type();}
00627   int pixmapID() { return 29; }
00628 };
00629 static Fl_Text_Editor_Type Fl_Text_Editor_type;
00630 
00631 int Fl_Text_Editor_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
00632   Fl_Text_Editor *myo = (Fl_Text_Editor*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
00633   switch (w) {
00634     case 4:
00635     case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
00636     case 1: myo->textfont(f); break;
00637     case 2: myo->textsize(s); break;
00638     case 3: myo->textcolor(c); break;
00639   }
00640   return 1;
00641 }
00642 
00644 
00645 #include <FL/Fl_Clock.H>
00646 class Fl_Clock_Type : public Fl_Widget_Type {
00647 public:
00648   virtual const char *type_name() {return "Fl_Clock";}
00649   virtual const char *alt_type_name() {return "fltk::Clock";}
00650   Fl_Widget *widget(int x,int y,int w,int h) {
00651     return new Fl_Clock(x,y,w,h);}
00652   Fl_Widget_Type *_make() {return new Fl_Clock_Type();}
00653   int pixmapID() { return 34; }
00654 };
00655 static Fl_Clock_Type Fl_Clock_type;
00656 
00658 
00659 #include <FL/Fl_Help_View.H>
00660 class Fl_Help_View_Type : public Fl_Widget_Type {
00661 public:
00662   virtual void ideal_size(int &w, int &h) {
00663     Fl_Help_View *myo = (Fl_Help_View *)o;
00664     fl_font(myo->textfont(), myo->textsize());
00665     h -= Fl::box_dh(o->box());
00666     w -= Fl::box_dw(o->box());
00667     int ww = (int)fl_width('m');
00668     w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
00669     h = ((h + fl_height() - 1) / fl_height()) * fl_height() +
00670         Fl::box_dh(o->box());
00671     if (h < 30) h = 30;
00672     if (w < 50) w = 50;
00673   }
00674   virtual const char *type_name() {return "Fl_Help_View";}
00675   virtual const char *alt_type_name() {return "fltk::HelpView";}
00676   Fl_Widget *widget(int x,int y,int w,int h) {
00677     Fl_Help_View *myo = new Fl_Help_View(x,y,w,h);
00678     if (!compile_only) {
00679       myo->value("<HTML><BODY><H1>Fl_Help_View Widget</H1>"
00680                  "<P>This is a Fl_Help_View widget.</P></BODY></HTML>");
00681     }
00682     return myo;}
00683   Fl_Widget_Type *_make() {return new Fl_Help_View_Type();}
00684   int pixmapID() { return 35; }
00685 };
00686 static Fl_Help_View_Type Fl_Help_View_type;
00687 
00689 
00690 #include <FL/Fl_Progress.H>
00691 class Fl_Progress_Type : public Fl_Widget_Type {
00692 public:
00693   virtual const char *type_name() {return "Fl_Progress";}
00694   virtual const char *alt_type_name() {return "fltk::ProgressBar";}
00695   Fl_Widget *widget(int x,int y,int w,int h) {
00696     Fl_Progress *myo = new Fl_Progress(x,y,w,h,"label");
00697     myo->value(50);
00698     return myo;}
00699   Fl_Widget_Type *_make() {return new Fl_Progress_Type();}
00700   int pixmapID() { return 36; }
00701 };
00702 static Fl_Progress_Type Fl_Progress_type;
00703 
00705 
00706 #include <FL/Fl_Adjuster.H>
00707 class Fl_Adjuster_Type : public Fl_Widget_Type {
00708   int is_valuator() const {return 1;}
00709 public:
00710   virtual const char *type_name() {return "Fl_Adjuster";}
00711   virtual const char *alt_type_name() {return "fltk::Adjuster";}
00712   Fl_Widget *widget(int x,int y,int w,int h) {
00713     return new Fl_Adjuster(x,y,w,h);}
00714   Fl_Widget_Type *_make() {return new Fl_Adjuster_Type();}
00715   int pixmapID() { return 40; }
00716 };
00717 static Fl_Adjuster_Type Fl_Adjuster_type;
00718 
00720 
00721 #include <FL/Fl_Dial.H>
00722 static Fl_Menu_Item dial_type_menu[] = {
00723   {"Dot",0,0,(void*)0},
00724   {"Line",0,0,(void*)FL_LINE_DIAL},
00725   {"Fill",0,0,(void*)FL_FILL_DIAL},
00726   {0}};
00727 class Fl_Dial_Type : public Fl_Widget_Type {
00728   Fl_Menu_Item *subtypes() {return dial_type_menu;}
00729   int is_valuator() const {return 1;}
00730 public:
00731   virtual const char *type_name() {return "Fl_Dial";}
00732   virtual const char *alt_type_name() {return "fltk::Dial";}
00733   Fl_Widget *widget(int x,int y,int w,int h) {
00734     return new Fl_Dial(x,y,w,h);}
00735   Fl_Widget_Type *_make() {return new Fl_Dial_Type();}
00736   int pixmapID() { return 42; }
00737 };
00738 static Fl_Dial_Type Fl_Dial_type;
00739 
00741 
00742 #include <FL/Fl_Roller.H>
00743 static Fl_Menu_Item roller_type_menu[] = {
00744   {"Vertical",0,0,(void*)0},
00745   {"Horizontal",0,0,(void*)FL_HORIZONTAL},
00746   {0}};
00747 class Fl_Roller_Type : public Fl_Widget_Type {
00748   Fl_Menu_Item *subtypes() {return roller_type_menu;}
00749   int is_valuator() const {return 1;}
00750 public:
00751   virtual const char *type_name() {return "Fl_Roller";}
00752   virtual const char *alt_type_name() {return "fltk::Roller";}
00753   Fl_Widget *widget(int x,int y,int w,int h) {
00754     return new Fl_Roller(x,y,w,h);}
00755   Fl_Widget_Type *_make() {return new Fl_Roller_Type();}
00756   int pixmapID() { return 43; }
00757 };
00758 static Fl_Roller_Type Fl_Roller_type;
00759 
00761 
00762 #include <FL/Fl_Scrollbar.H>
00763 static Fl_Menu_Item slider_type_menu[] = {
00764   {"Vertical",0,0,(void*)FL_VERT_SLIDER},
00765   {"Horizontal",0,0,(void*)FL_HOR_SLIDER},
00766   {"Vert Fill",0,0,(void*)FL_VERT_FILL_SLIDER},
00767   {"Horz Fill",0,0,(void*)FL_HOR_FILL_SLIDER},
00768   {"Vert Knob",0,0,(void*)FL_VERT_NICE_SLIDER},
00769   {"Horz Knob",0,0,(void*)FL_HOR_NICE_SLIDER},
00770   {0}};
00771 class Fl_Slider_Type : public Fl_Widget_Type {
00772   Fl_Menu_Item *subtypes() {return slider_type_menu;}
00773   int is_valuator() const {return 2;}
00774 public:
00775   virtual const char *type_name() {return "Fl_Slider";}
00776   virtual const char *alt_type_name() {return "fltk::Slider";}
00777   Fl_Widget *widget(int x,int y,int w,int h) {
00778     return new Fl_Slider(x,y,w,h,"slider:");}
00779   Fl_Widget_Type *_make() {return new Fl_Slider_Type();}
00780   int pixmapID() { return 37; }
00781 };
00782 static Fl_Slider_Type Fl_Slider_type;
00783 
00784 static Fl_Menu_Item scrollbar_type_menu[] = {
00785   {"Vertical",0,0,(void*)FL_VERT_SLIDER},
00786   {"Horizontal",0,0,(void*)FL_HOR_SLIDER},
00787   {0}};
00788 class Fl_Scrollbar_Type : public Fl_Slider_Type {
00789   Fl_Menu_Item *subtypes() {return scrollbar_type_menu;}
00790   int is_valuator() const {return 3;}
00791 public:
00792   virtual const char *type_name() {return "Fl_Scrollbar";}
00793   virtual const char *alt_type_name() {return "fltk::Scrollbar";}
00794   Fl_Widget *widget(int x,int y,int w,int h) {
00795     return new Fl_Scrollbar(x,y,w,h);}
00796   Fl_Widget_Type *_make() {return new Fl_Scrollbar_Type();}
00797   int pixmapID() { return 38; }
00798 };
00799 static Fl_Scrollbar_Type Fl_Scrollbar_type;
00800 
00802 
00803 #include <FL/Fl_Output.H>
00804 static Fl_Menu_Item output_type_menu[] = {
00805   {"Normal",0,0,(void*)FL_NORMAL_OUTPUT},
00806   {"Multiline",0,0,(void*)FL_MULTILINE_OUTPUT},
00807   {0}};
00808 class Fl_Output_Type : public Fl_Input_Type {
00809   Fl_Menu_Item *subtypes() {return output_type_menu;}
00810 public:
00811   virtual void ideal_size(int &w, int &h) {
00812     Fl_Output *myo = (Fl_Output *)o;
00813     fl_font(myo->textfont(), myo->textsize());
00814     h = fl_height() + myo->textsize() - 6;
00815     w -= Fl::box_dw(o->box());
00816     int ww = (int)fl_width('m');
00817     w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
00818     if (h < 15) h = 15;
00819     if (w < 15) w = 15;
00820   }
00821   virtual const char *type_name() {return "Fl_Output";}
00822   virtual const char *alt_type_name() {return "fltk::Output";}
00823   Fl_Widget *widget(int x,int y,int w,int h) {
00824     Fl_Output *myo = new Fl_Output(x,y,w,h,"output:");
00825     myo->value("Text Output");
00826     return myo;
00827   }
00828   Fl_Widget_Type *_make() {return new Fl_Output_Type();}
00829   int pixmapID() { return 27; }
00830 };
00831 static Fl_Output_Type Fl_Output_type;
00832 
00834 
00835 #include <FL/Fl_Value_Input.H>
00836 class Fl_Value_Input_Type : public Fl_Widget_Type {
00837 public:
00838   virtual void ideal_size(int &w, int &h) {
00839     Fl_Value_Input *myo = (Fl_Value_Input *)o;
00840     fl_font(myo->textfont(), myo->textsize());
00841     h = fl_height() + myo->textsize() - 6;
00842     w -= Fl::box_dw(o->box());
00843     int ww = (int)fl_width('m');
00844     w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
00845     if (h < 15) h = 15;
00846     if (w < 15) w = 15;
00847   }
00848   virtual const char *type_name() {return "Fl_Value_Input";}
00849   virtual const char *alt_type_name() {return "fltk::ValueInput";}
00850   int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
00851   int is_valuator() const {return 1;}
00852   int is_value_input() const {return 1;}
00853   Fl_Widget *widget(int x,int y,int w,int h) {
00854     Fl_Value_Input *myo = new Fl_Value_Input(x,y,w,h,"value:");
00855     return myo;
00856   }
00857   Fl_Widget_Type *_make() {return new Fl_Value_Input_Type();}
00858   int pixmapID() { return 44; }
00859 };
00860 static Fl_Value_Input_Type Fl_Value_Input_type;
00861 
00862 int Fl_Value_Input_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
00863   Fl_Value_Input *myo = (Fl_Value_Input*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
00864   switch (w) {
00865     case 4:
00866     case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
00867     case 1: myo->textfont(f); break;
00868     case 2: myo->textsize(s); break;
00869     case 3: myo->textcolor(c); break;
00870   }
00871   return 1;
00872 }
00873 
00875 
00876 #include <FL/Fl_Value_Output.H>
00877 class Fl_Value_Output_Type : public Fl_Widget_Type {
00878 public:
00879   virtual void ideal_size(int &w, int &h) {
00880     Fl_Value_Output *myo = (Fl_Value_Output *)o;
00881     fl_font(myo->textfont(), myo->textsize());
00882     h = fl_height() + myo->textsize() - 6;
00883     w = o->w() - Fl::box_dw(o->box());
00884     int ww = (int)fl_width('m');
00885     w = ((w + ww - 1) / ww) * ww + Fl::box_dw(o->box());
00886     if (h < 15) h = 15;
00887     if (w < 15) w = 15;
00888   }
00889   virtual const char *type_name() {return "Fl_Value_Output";}
00890   virtual const char *alt_type_name() {return "fltk::ValueOutput";}
00891   int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
00892   int is_valuator() const {return 1;}
00893   Fl_Widget *widget(int x,int y,int w,int h) {
00894     Fl_Value_Output *myo = new Fl_Value_Output(x,y,w,h,"value:");
00895     return myo;
00896   }
00897   Fl_Widget_Type *_make() {return new Fl_Value_Output_Type();}
00898   int pixmapID() { return 45; }
00899 };
00900 static Fl_Value_Output_Type Fl_Value_Output_type;
00901 
00902 int Fl_Value_Output_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
00903   Fl_Value_Output *myo = (Fl_Value_Output*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
00904   switch (w) {
00905     case 4:
00906     case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
00907     case 1: myo->textfont(f); break;
00908     case 2: myo->textsize(s); break;
00909     case 3: myo->textcolor(c); break;
00910   }
00911   return 1;
00912 }
00913 
00915 
00916 #include <FL/Fl_Value_Slider.H>
00917 class Fl_Value_Slider_Type : public Fl_Slider_Type {
00918   int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);
00919 public:
00920   virtual const char *type_name() {return "Fl_Value_Slider";}
00921   virtual const char *alt_type_name() {return "fltk::ValueSlider";}
00922   Fl_Widget *widget(int x,int y,int w,int h) {
00923     return new Fl_Value_Slider(x,y,w,h,"slider:");}
00924   Fl_Widget_Type *_make() {return new Fl_Value_Slider_Type();}
00925   int pixmapID() { return 39; }
00926 };
00927 static Fl_Value_Slider_Type Fl_Value_Slider_type;
00928 
00929 int Fl_Value_Slider_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) {
00930   Fl_Value_Slider *myo = (Fl_Value_Slider*)(w==4 ? ((Fl_Widget_Type*)factory)->o : o);
00931   switch (w) {
00932     case 4:
00933     case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break;
00934     case 1: myo->textfont(f); break;
00935     case 2: myo->textsize(s); break;
00936     case 3: myo->textcolor(c); break;
00937   }
00938   return 1;
00939 }
00940 
00942 
00943 extern class Fl_Function_Type Fl_Function_type;
00944 extern class Fl_Code_Type Fl_Code_type;
00945 extern class Fl_CodeBlock_Type Fl_CodeBlock_type;
00946 extern class Fl_Data_Type Fl_Data_type;
00947 extern class Fl_Decl_Type Fl_Decl_type;
00948 extern class Fl_DeclBlock_Type Fl_DeclBlock_type;
00949 extern class Fl_Comment_Type Fl_Comment_type;
00950 extern class Fl_Class_Type Fl_Class_type;
00951 extern class Fl_Window_Type Fl_Window_type;
00952 extern class Fl_Widget_Class_Type Fl_Widget_Class_type;
00953 extern class Fl_Group_Type Fl_Group_type;
00954 extern class Fl_Pack_Type Fl_Pack_type;
00955 extern class Fl_Tabs_Type Fl_Tabs_type;
00956 extern class Fl_Scroll_Type Fl_Scroll_type;
00957 extern class Fl_Table_Type Fl_Table_type;
00958 extern class Fl_Tile_Type Fl_Tile_type;
00959 extern class Fl_Input_Choice_Type Fl_Input_Choice_type;
00960 extern class Fl_Choice_Type Fl_Choice_type;
00961 extern class Fl_Menu_Bar_Type Fl_Menu_Bar_type;
00962 extern class Fl_Menu_Button_Type Fl_Menu_Button_type;
00963 extern class Fl_Menu_Item_Type Fl_Menu_Item_type;
00964 extern class Fl_Submenu_Type Fl_Submenu_type;
00965 extern class Fl_Wizard_Type Fl_Wizard_type;
00966 
00967 extern void select(Fl_Type *,int);
00968 extern void select_only(Fl_Type *);
00969 
00970 #include <FL/Fl_Window.H>
00971 
00972 static void cb(Fl_Widget *, void *v) {
00973   undo_checkpoint();
00974   undo_suspend();
00975   Fl_Type *t = ((Fl_Type*)v)->make();
00976   if (t) {
00977     if (t->is_widget() && !t->is_window()) {
00978       Fl_Widget_Type *wt = (Fl_Widget_Type *)t;
00979 
00980       // Set font sizes...
00981       wt->o->labelsize(Fl_Widget_Type::default_size);
00982 
00983       Fl_Font f;
00984       int s = Fl_Widget_Type::default_size;
00985       Fl_Color c;
00986 
00987       wt->textstuff(2, f, s, c);
00988 
00989       // Resize and/or reposition new widget...
00990       int w = 0, h = 0;
00991       wt->ideal_size(w, h);
00992 
00993       if (!strcmp(wt->type_name(), "Fl_Menu_Bar")) {
00994         // Move and resize the menubar across the top of the window...
00995         wt->o->resize(0, 0, w, h);
00996       } else {
00997         // Just resize to the ideal size...
00998         wt->o->size(w, h);
00999       }
01000     }
01001     select_only(t);
01002     set_modflag(1);
01003     t->open();
01004   } else {
01005     undo_current --;
01006     undo_last --;
01007   }
01008   undo_resume();
01009 }
01010 
01011 Fl_Menu_Item New_Menu[] = {
01012 {"Code",0,0,0,FL_SUBMENU},
01013   {"Function/Method",0,cb,(void*)&Fl_Function_type},
01014   {"Code",0,cb,(void*)&Fl_Code_type},
01015   {"Code Block",0,cb,(void*)&Fl_CodeBlock_type},
01016   {"Declaration",0,cb,(void*)&Fl_Decl_type},
01017   {"Declaration Block",0,cb,(void*)&Fl_DeclBlock_type},
01018   {"Class",0,cb,(void*)&Fl_Class_type},
01019   {"Widget Class",0,cb,(void*)&Fl_Widget_Class_type},
01020   {"Comment",0,cb,(void*)&Fl_Comment_type},
01021   {"Binary Data",0,cb,(void*)&Fl_Data_type},
01022 {0},
01023 {"Group",0,0,0,FL_SUBMENU},
01024   {0,0,cb,(void*)&Fl_Window_type},
01025   {0,0,cb,(void*)&Fl_Group_type},
01026   {0,0,cb,(void*)&Fl_Pack_type},
01027   {0,0,cb,(void*)&Fl_Tabs_type},
01028   {0,0,cb,(void*)&Fl_Scroll_type},
01029   {0,0,cb,(void*)&Fl_Table_type},
01030   {0,0,cb,(void*)&Fl_Tile_type},
01031   {0,0,cb,(void*)&Fl_Wizard_type},
01032 {0},
01033 {"Buttons",0,0,0,FL_SUBMENU},
01034   {0,0,cb,(void*)&Fl_Button_type},
01035   {0,0,cb,(void*)&Fl_Return_Button_type},
01036   {0,0,cb,(void*)&Fl_Light_Button_type},
01037   {0,0,cb,(void*)&Fl_Check_Button_type},
01038   {0,0,cb,(void*)&Fl_Repeat_Button_type},
01039   {0,0,cb,(void*)&Fl_Round_Button_type},
01040 {0},
01041 {"Valuators",0,0,0,FL_SUBMENU},
01042   {0,0,cb,(void*)&Fl_Slider_type},
01043   {0,0,cb,(void*)&Fl_Scrollbar_type},
01044   {0,0,cb,(void*)&Fl_Value_Slider_type},
01045   {0,0,cb,(void*)&Fl_Adjuster_type},
01046   {0,0,cb,(void*)&Fl_Counter_type},
01047   {0,0,cb,(void*)&Fl_Spinner_type},
01048   {0,0,cb,(void*)&Fl_Dial_type},
01049   {0,0,cb,(void*)&Fl_Roller_type},
01050   {0,0,cb,(void*)&Fl_Value_Input_type},
01051   {0,0,cb,(void*)&Fl_Value_Output_type},
01052 {0},
01053 {"Text",0,0,0,FL_SUBMENU},
01054   {0,0,cb,(void*)&Fl_File_Input_type},
01055   {0,0,cb,(void*)&Fl_Input_type},
01056   {0,0,cb,(void*)&Fl_Output_type},
01057   {0,0,cb,(void*)&Fl_Text_Display_type},
01058   {0,0,cb,(void*)&Fl_Text_Editor_type},
01059 {0},
01060 {"Menus",0,0,0,FL_SUBMENU},
01061   {0,0,cb,(void*)&Fl_Menu_Bar_type},
01062   {0,0,cb,(void*)&Fl_Menu_Button_type},
01063   {0,0,cb,(void*)&Fl_Choice_type},
01064   {0,0,cb,(void*)&Fl_Input_Choice_type},
01065   {0,0,cb, (void*)&Fl_Submenu_type},
01066   {0,0,cb, (void*)&Fl_Menu_Item_type},
01067 {0},
01068 {"Browsers",0,0,0,FL_SUBMENU},
01069   {0,0,cb,(void*)&Fl_Browser_type},
01070   {0,0,cb,(void*)&Fl_Check_Browser_type},
01071   {0,0,cb,(void*)&Fl_File_Browser_type},
01072   {0,0,cb,(void*)&Fl_Tree_type},
01073 {0},
01074 {"Other",0,0,0,FL_SUBMENU},
01075   {0,0,cb,(void*)&Fl_Box_type},
01076   {0,0,cb,(void*)&Fl_Clock_type},
01077   {0,0,cb,(void*)&Fl_Help_View_type},
01078   {0,0,cb,(void*)&Fl_Progress_type},
01079 {0},
01080 {0}};
01081 
01082 #include <FL/Fl_Multi_Label.H>
01083 
01084 // modify a menuitem to display an icon in front of the label
01085 static void make_iconlabel( Fl_Menu_Item *mi, Fl_Image *ic, const char *txt )
01086 {
01087   if (ic) {
01088     char *t1 = new char[strlen(txt)+6];
01089     strcpy( t1, " " );
01090     strcat(t1, txt);
01091     strcat(t1, "...");
01092     mi->image( ic );
01093     Fl_Multi_Label *ml = new Fl_Multi_Label;
01094     ml->labela = (char*)ic;
01095     ml->labelb = t1;
01096     ml->typea = _FL_IMAGE_LABEL;
01097     ml->typeb = FL_NORMAL_LABEL;
01098     ml->label( mi );
01099   }
01100   else if (txt!=mi->text)
01101     mi->label(txt);
01102 }
01103 
01104 void fill_in_New_Menu() {
01105   for (unsigned i = 0; i < sizeof(New_Menu)/sizeof(*New_Menu); i++) {
01106     Fl_Menu_Item *m = New_Menu+i;
01107     if (m->user_data()) {
01108       Fl_Type *t = (Fl_Type*)m->user_data();
01109       if (m->text) {
01110         make_iconlabel( m, pixmap[t->pixmapID()], m->label() );
01111       } else {
01112         const char *n = t->type_name();
01113         if (!strncmp(n,"Fl_",3)) n += 3;
01114         if (!strncmp(n,"fltk::",6)) n += 6;
01115         make_iconlabel( m, pixmap[t->pixmapID()], n );
01116       }
01117     }
01118   }
01119 }
01120 
01121 // use keyword to pick the type, this is used to parse files:
01122 int reading_file;
01123 Fl_Type *Fl_Type_make(const char *tn) {
01124   reading_file = 1; // makes labels be null
01125   Fl_Type *r = 0;
01126   for (unsigned i = 0; i < sizeof(New_Menu)/sizeof(*New_Menu); i++) {
01127     Fl_Menu_Item *m = New_Menu+i;
01128     if (!m->user_data()) continue;
01129     Fl_Type *t = (Fl_Type*)(m->user_data());
01130     if (!strcasecmp(tn,t->type_name())) {r = t->make(); break;}
01131     if (!strcasecmp(tn,t->alt_type_name())) {r = t->make(); break;}
01132   }
01133   reading_file = 0;
01134   return r;
01135 }
01136 
01138 
01139 // Since I have included all the .H files, do this table here:
01140 // This table is only used to read fdesign files:
01141 
01142 struct symbol {const char *name; int value;};
01143 
01144 static symbol table[] = {
01145   {"BLACK",     FL_BLACK},
01146   {"RED",       FL_RED},
01147   {"GREEN",     FL_GREEN},
01148   {"YELLOW",    FL_YELLOW},
01149   {"BLUE",      FL_BLUE},
01150   {"MAGENTA",   FL_MAGENTA},
01151   {"CYAN",      FL_CYAN},
01152   {"WHITE",     FL_WHITE},
01153 
01154   {"LCOL",               FL_BLACK},
01155   {"COL1",               FL_GRAY},
01156   {"MCOL",               FL_LIGHT1},
01157   {"LEFT_BCOL",          FL_LIGHT3},
01158   {"TOP_BCOL",           FL_LIGHT2},
01159   {"BOTTOM_BCOL",        FL_DARK2},
01160   {"RIGHT_BCOL",                 FL_DARK3},
01161   {"INACTIVE",           FL_INACTIVE_COLOR},
01162   {"INACTIVE_COL",       FL_INACTIVE_COLOR},
01163   {"FREE_COL1",          FL_FREE_COLOR},
01164   {"FREE_COL2",          FL_FREE_COLOR+1},
01165   {"FREE_COL3",          FL_FREE_COLOR+2},
01166   {"FREE_COL4",          FL_FREE_COLOR+3},
01167   {"FREE_COL5",          FL_FREE_COLOR+4},
01168   {"FREE_COL6",          FL_FREE_COLOR+5},
01169   {"FREE_COL7",          FL_FREE_COLOR+6},
01170   {"FREE_COL8",          FL_FREE_COLOR+7},
01171   {"FREE_COL9",          FL_FREE_COLOR+8},
01172   {"FREE_COL10",                 FL_FREE_COLOR+9},
01173   {"FREE_COL11",                 FL_FREE_COLOR+10},
01174   {"FREE_COL12",                 FL_FREE_COLOR+11},
01175   {"FREE_COL13",                 FL_FREE_COLOR+12},
01176   {"FREE_COL14",                 FL_FREE_COLOR+13},
01177   {"FREE_COL15",                 FL_FREE_COLOR+14},
01178   {"FREE_COL16",                 FL_FREE_COLOR+15},
01179   {"TOMATO",             131},
01180   {"INDIANRED",          164},
01181   {"SLATEBLUE",          195},
01182   {"DARKGOLD",           84},
01183   {"PALEGREEN",          157},
01184   {"ORCHID",             203},
01185   {"DARKCYAN",           189},
01186   {"DARKTOMATO",                 113},
01187   {"WHEAT",              174},
01188   {"ALIGN_CENTER",      FL_ALIGN_CENTER},
01189   {"ALIGN_TOP",         FL_ALIGN_TOP},
01190   {"ALIGN_BOTTOM",      FL_ALIGN_BOTTOM},
01191   {"ALIGN_LEFT",        FL_ALIGN_LEFT},
01192   {"ALIGN_RIGHT",       FL_ALIGN_RIGHT},
01193   {"ALIGN_INSIDE",      FL_ALIGN_INSIDE},
01194   {"ALIGN_TOP_LEFT",     FL_ALIGN_TOP | FL_ALIGN_LEFT},
01195   {"ALIGN_TOP_RIGHT",    FL_ALIGN_TOP | FL_ALIGN_RIGHT},
01196   {"ALIGN_BOTTOM_LEFT",  FL_ALIGN_BOTTOM | FL_ALIGN_LEFT},
01197   {"ALIGN_BOTTOM_RIGHT", FL_ALIGN_BOTTOM | FL_ALIGN_RIGHT},
01198   {"ALIGN_CENTER|FL_ALIGN_INSIDE",      FL_ALIGN_CENTER|FL_ALIGN_INSIDE},
01199   {"ALIGN_TOP|FL_ALIGN_INSIDE",         FL_ALIGN_TOP|FL_ALIGN_INSIDE},
01200   {"ALIGN_BOTTOM|FL_ALIGN_INSIDE",      FL_ALIGN_BOTTOM|FL_ALIGN_INSIDE},
01201   {"ALIGN_LEFT|FL_ALIGN_INSIDE",        FL_ALIGN_LEFT|FL_ALIGN_INSIDE},
01202   {"ALIGN_RIGHT|FL_ALIGN_INSIDE",       FL_ALIGN_RIGHT|FL_ALIGN_INSIDE},
01203   {"ALIGN_INSIDE|FL_ALIGN_INSIDE",      FL_ALIGN_INSIDE|FL_ALIGN_INSIDE},
01204   {"ALIGN_TOP_LEFT|FL_ALIGN_INSIDE",    FL_ALIGN_TOP|FL_ALIGN_LEFT|FL_ALIGN_INSIDE},
01205   {"ALIGN_TOP_RIGHT|FL_ALIGN_INSIDE",   FL_ALIGN_TOP|FL_ALIGN_RIGHT|FL_ALIGN_INSIDE},
01206   {"ALIGN_BOTTOM_LEFT|FL_ALIGN_INSIDE", FL_ALIGN_BOTTOM|FL_ALIGN_LEFT|FL_ALIGN_INSIDE},
01207   {"ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE",FL_ALIGN_BOTTOM|FL_ALIGN_RIGHT|FL_ALIGN_INSIDE},
01208 
01209   {"ALIGN_LEFT_TOP",     FL_ALIGN_TOP | FL_ALIGN_LEFT},
01210   {"ALIGN_RIGHT_TOP",    FL_ALIGN_TOP | FL_ALIGN_RIGHT},
01211   {"ALIGN_LEFT_BOTTOM",  FL_ALIGN_BOTTOM | FL_ALIGN_LEFT},
01212   {"ALIGN_RIGHT_BOTTOM", FL_ALIGN_BOTTOM | FL_ALIGN_RIGHT},
01213   {"INVALID_STYLE",      255},
01214   {"NORMAL_STYLE",       FL_HELVETICA},
01215   {"BOLD_STYLE",                 FL_HELVETICA|FL_BOLD},
01216   {"ITALIC_STYLE",       FL_HELVETICA|FL_ITALIC},
01217   {"BOLDITALIC_STYLE",   FL_HELVETICA|FL_BOLD|FL_ITALIC},
01218   {"FIXED_STYLE",        FL_COURIER},
01219   {"FIXEDBOLD_STYLE",    FL_COURIER|FL_BOLD},
01220   {"FIXEDITALIC_STYLE",  FL_COURIER|FL_ITALIC},
01221   {"FIXEDBOLDITALIC_STYLE",  FL_COURIER|FL_BOLD|FL_ITALIC},
01222   {"TIMES_STYLE",        FL_TIMES},
01223   {"TIMESBOLD_STYLE",    FL_TIMES|FL_BOLD},
01224   {"TIMESITALIC_STYLE",  FL_TIMES|FL_ITALIC},
01225   {"TIMESBOLDITALIC_STYLE",  FL_TIMES|FL_BOLD|FL_ITALIC},
01226   {"SHADOW_STYLE",      (_FL_SHADOW_LABEL<<8)},
01227   {"ENGRAVED_STYLE",    (_FL_ENGRAVED_LABEL<<8)},
01228   {"EMBOSSED_STYLE",    (_FL_EMBOSSED_LABEL<<0)},
01229   {"TINY_SIZE",          8},
01230   {"SMALL_SIZE",                 11},
01231   {"NORMAL_SIZE",        FL_NORMAL_SIZE},
01232   {"MEDIUM_SIZE",        18},
01233   {"LARGE_SIZE",                 24},
01234   {"HUGE_SIZE",          32},
01235   {"DEFAULT_SIZE",       FL_NORMAL_SIZE},
01236   {"TINY_FONT",          8},
01237   {"SMALL_FONT",                 11},
01238   {"NORMAL_FONT",        FL_NORMAL_SIZE},
01239   {"MEDIUM_FONT",        18},
01240   {"LARGE_FONT",                 24},
01241   {"HUGE_FONT",          32},
01242   {"NORMAL_FONT1",       11},
01243   {"NORMAL_FONT2",       FL_NORMAL_SIZE},
01244   {"DEFAULT_FONT",       11},
01245   {"RETURN_END_CHANGED",  0},
01246   {"RETURN_CHANGED",     1},
01247   {"RETURN_END",                 2},
01248   {"RETURN_ALWAYS",      3},
01249   {"PUSH_BUTTON",       FL_TOGGLE_BUTTON},
01250   {"RADIO_BUTTON",      FL_RADIO_BUTTON},
01251   {"HIDDEN_BUTTON",     FL_HIDDEN_BUTTON},
01252   {"SELECT_BROWSER",    FL_SELECT_BROWSER},
01253   {"HOLD_BROWSER",      FL_HOLD_BROWSER},
01254   {"MULTI_BROWSER",     FL_MULTI_BROWSER},
01255   {"SIMPLE_COUNTER",    FL_SIMPLE_COUNTER},
01256   {"LINE_DIAL",         FL_LINE_DIAL},
01257   {"FILL_DIAL",         FL_FILL_DIAL},
01258   {"VERT_SLIDER",       FL_VERT_SLIDER},
01259   {"HOR_SLIDER",        FL_HOR_SLIDER},
01260   {"VERT_FILL_SLIDER",  FL_VERT_FILL_SLIDER},
01261   {"HOR_FILL_SLIDER",   FL_HOR_FILL_SLIDER},
01262   {"VERT_NICE_SLIDER",  FL_VERT_NICE_SLIDER},
01263   {"HOR_NICE_SLIDER",   FL_HOR_NICE_SLIDER},
01264 };
01265 
01266 #include <stdlib.h>
01267 
01268 int lookup_symbol(const char *name, int &v, int numberok) {
01269   if (name[0]=='F' && name[1]=='L' && name[2]=='_') name += 3;
01270   for (int i=0; i < int(sizeof(table)/sizeof(*table)); i++)
01271     if (!strcasecmp(name,table[i].name)) {v = table[i].value; return 1;}
01272   if (numberok && ((v = atoi(name)) || !strcmp(name,"0"))) return 1;
01273   return 0;
01274 }
01275 
01276 //
01277 // End of "$Id: factory.cxx 8172 2011-01-03 08:28:38Z matt $".
01278 //