factory.cxx 44 KB

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