|
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) ![]() |
00001 // 00002 // "$Id: Fl_Type.h 8172 2011-01-03 08:28:38Z matt $" 00003 // 00004 // Widget type header file for the Fast Light Tool Kit (FLTK). 00005 // 00006 // Each object described by Fluid is one of these objects. They 00007 // are all stored in a double-linked list. 00008 // 00009 // There is also a single "factory" instance of each type of this. 00010 // The method "make()" is called on this factory to create a new 00011 // instance of this object. It could also have a "copy()" function, 00012 // but it was easier to implement this by using the file read/write 00013 // that is needed to save the setup anyways. 00014 // 00015 // Copyright 1998-2010 by Bill Spitzak and others. 00016 // 00017 // This library is free software; you can redistribute it and/or 00018 // modify it under the terms of the GNU Library General Public 00019 // License as published by the Free Software Foundation; either 00020 // version 2 of the License, or (at your option) any later version. 00021 // 00022 // This library is distributed in the hope that it will be useful, 00023 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00025 // Library General Public License for more details. 00026 // 00027 // You should have received a copy of the GNU Library General Public 00028 // License along with this library; if not, write to the Free Software 00029 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00030 // USA. 00031 // 00032 // Please report all bugs and problems on the following page: 00033 // 00034 // http://www.fltk.org/str.php 00035 // 00036 00037 #include <FL/Fl_Widget.H> 00038 #include <FL/Fl_Menu.H> 00039 #include <FL/Fl_Plugin.H> 00040 #include "Fluid_Image.h" 00041 #include <FL/fl_draw.H> 00042 00043 void set_modflag(int mf); 00044 00045 class Fl_Type { 00046 00047 friend class Widget_Browser; 00048 friend Fl_Widget *make_type_browser(int,int,int,int,const char *l=0); 00049 friend class Fl_Window_Type; 00050 virtual void setlabel(const char *); // virtual part of label(char*) 00051 00052 protected: 00053 00054 Fl_Type(); 00055 00056 const char *name_; 00057 const char *label_; 00058 const char *callback_; 00059 const char *user_data_; 00060 const char *user_data_type_; 00061 const char *comment_; 00062 00063 public: // things that should not be public: 00064 00065 Fl_Type *parent; // parent, which is previous in list 00066 char new_selected; // browser highlight 00067 char selected; // copied here by selection_changed() 00068 char open_; // state of triangle in browser 00069 char visible; // true if all parents are open 00070 char rtti; // hack because I have no rtti, this is 0 for base class 00071 int level; // number of parents over this 00072 static Fl_Type *first, *last; // linked list of all objects 00073 Fl_Type *next, *prev; // linked list of all objects 00074 00075 Fl_Type *factory; 00076 const char *callback_name(); 00077 00078 int code_position, header_position; 00079 int code_position_end, header_position_end; 00080 00081 protected: 00082 int user_defined(const char* cbname) const; 00083 00084 public: 00085 00086 virtual ~Fl_Type(); 00087 virtual Fl_Type *make() = 0; 00088 00089 void add(Fl_Type *parent); // add as new child 00090 void insert(Fl_Type *n); // insert into list before n 00091 Fl_Type* remove(); // remove from list 00092 void move_before(Fl_Type*); // move before a sibling 00093 00094 virtual const char *title(); // string for browser 00095 virtual const char *type_name() = 0; // type for code output 00096 virtual const char *alt_type_name() { return type_name(); } // alternate type for FLTK2 code output 00097 00098 const char *name() const {return name_;} 00099 void name(const char *); 00100 const char *label() const {return label_;} 00101 void label(const char *); 00102 const char *callback() const {return callback_;} 00103 void callback(const char *); 00104 const char *user_data() const {return user_data_;} 00105 void user_data(const char *); 00106 const char *user_data_type() const {return user_data_type_;} 00107 void user_data_type(const char *); 00108 const char *comment() { return comment_; } 00109 void comment(const char *); 00110 00111 virtual Fl_Type* click_test(int,int); 00112 virtual void add_child(Fl_Type*, Fl_Type* beforethis); 00113 virtual void move_child(Fl_Type*, Fl_Type* beforethis); 00114 virtual void remove_child(Fl_Type*); 00115 00116 static Fl_Type *current; // most recently picked object 00117 virtual void open(); // what happens when you double-click 00118 00119 // read and write data to a saved file: 00120 void write(); 00121 virtual void write_properties(); 00122 virtual void read_property(const char *); 00123 virtual int read_fdesign(const char*, const char*); 00124 00125 // write code, these are called in order: 00126 virtual void write_static(); // write static stuff to .c file 00127 virtual void write_code1(); // code and .h before children 00128 virtual void write_code2(); // code and .h after children 00129 void write_comment_h(const char *ind=""); // write the commentary text into the header file 00130 void write_comment_c(const char *ind=""); // write the commentary text into the source file 00131 00132 // live mode 00133 virtual Fl_Widget *enter_live_mode(int top=0); // build wdgets needed for live mode 00134 virtual void leave_live_mode(); // free allocated resources 00135 virtual void copy_properties(); // copy properties from this type into a potetial live object 00136 00137 // get message number for I18N 00138 int msgnum(); 00139 00140 // fake rtti: 00141 virtual int is_parent() const; 00142 virtual int is_widget() const; 00143 virtual int is_button() const; 00144 virtual int is_input() const; 00145 virtual int is_value_input() const; 00146 virtual int is_text_display() const; 00147 virtual int is_valuator() const; 00148 virtual int is_spinner() const; 00149 virtual int is_menu_item() const; 00150 virtual int is_menu_button() const; 00151 virtual int is_group() const; 00152 virtual int is_window() const; 00153 virtual int is_code_block() const; 00154 virtual int is_decl_block() const; 00155 virtual int is_comment() const; 00156 virtual int is_class() const; 00157 virtual int is_public() const; 00158 00159 virtual int pixmapID() { return 0; } 00160 00161 const char* class_name(const int need_nest) const; 00162 const class Fl_Class_Type* is_in_class() const; 00163 }; 00164 00165 class Fl_Function_Type : public Fl_Type { 00166 const char* return_type; 00167 char public_, cdecl_, constructor, havewidgets; 00168 public: 00169 Fl_Function_Type() : 00170 Fl_Type(), 00171 return_type(0L), public_(0), cdecl_(0), constructor(0), havewidgets(0) 00172 { } 00173 ~Fl_Function_Type() { 00174 if (return_type) free((void*)return_type); 00175 } 00176 Fl_Type *make(); 00177 void write_code1(); 00178 void write_code2(); 00179 void open(); 00180 int ismain() {return name_ == 0;} 00181 virtual const char *type_name() {return "Function";} 00182 virtual const char *title() { 00183 return name() ? name() : "main()"; 00184 } 00185 int is_parent() const {return 1;} 00186 int is_code_block() const {return 1;} 00187 virtual int is_public() const; 00188 int pixmapID() { return 7; } 00189 void write_properties(); 00190 void read_property(const char *); 00191 int has_signature(const char *, const char*) const; 00192 }; 00193 00194 class Fl_Code_Type : public Fl_Type { 00195 public: 00196 Fl_Type *make(); 00197 void write_code1(); 00198 void write_code2(); 00199 void open(); 00200 virtual const char *type_name() {return "code";} 00201 int is_code_block() const {return 0;} 00202 int pixmapID() { return 8; } 00203 virtual int is_public() const; 00204 }; 00205 00206 class Fl_CodeBlock_Type : public Fl_Type { 00207 const char* after; 00208 public: 00209 Fl_CodeBlock_Type() : Fl_Type(), after(0L) { } 00210 ~Fl_CodeBlock_Type() { 00211 if (after) free((void*)after); 00212 } 00213 Fl_Type *make(); 00214 void write_code1(); 00215 void write_code2(); 00216 void open(); 00217 virtual const char *type_name() {return "codeblock";} 00218 int is_code_block() const {return 1;} 00219 int is_parent() const {return 1;} 00220 virtual int is_public() const; 00221 int pixmapID() { return 9; } 00222 void write_properties(); 00223 void read_property(const char *); 00224 }; 00225 00226 class Fl_Decl_Type : public Fl_Type { 00227 protected: 00228 char public_; 00229 char static_; 00230 public: 00231 Fl_Type *make(); 00232 void write_code1(); 00233 void write_code2(); 00234 void open(); 00235 virtual const char *type_name() {return "decl";} 00236 void write_properties(); 00237 void read_property(const char *); 00238 virtual int is_public() const; 00239 int pixmapID() { return 10; } 00240 }; 00241 00242 class Fl_Data_Type : public Fl_Decl_Type { 00243 const char *filename_; 00244 public: 00245 Fl_Data_Type() : Fl_Decl_Type(), filename_(0L) { } 00246 ~Fl_Data_Type() { 00247 if (filename_) free((void*)filename_); 00248 } 00249 Fl_Type *make(); 00250 void write_code1(); 00251 void write_code2(); 00252 void open(); 00253 virtual const char *type_name() {return "data";} 00254 void write_properties(); 00255 void read_property(const char *); 00256 int pixmapID() { return 49; } 00257 }; 00258 00259 class Fl_DeclBlock_Type : public Fl_Type { 00260 const char* after; 00261 char public_; 00262 public: 00263 Fl_DeclBlock_Type() : Fl_Type(), after(0L) { } 00264 ~Fl_DeclBlock_Type() { 00265 if (after) free((void*)after); 00266 } 00267 Fl_Type *make(); 00268 void write_code1(); 00269 void write_code2(); 00270 void open(); 00271 virtual const char *type_name() {return "declblock";} 00272 void write_properties(); 00273 void read_property(const char *); 00274 int is_parent() const {return 1;} 00275 int is_decl_block() const {return 1;} 00276 virtual int is_public() const; 00277 int pixmapID() { return 11; } 00278 }; 00279 00280 class Fl_Comment_Type : public Fl_Type { 00281 char in_c_, in_h_, style_; 00282 char title_buf[64]; 00283 public: 00284 Fl_Type *make(); 00285 void write_code1(); 00286 void write_code2(); 00287 void open(); 00288 virtual const char *type_name() {return "comment";} 00289 virtual const char *title(); // string for browser 00290 void write_properties(); 00291 void read_property(const char *); 00292 virtual int is_public() const { return 1; } 00293 virtual int is_comment() const { return 1; } 00294 int pixmapID() { return 46; } 00295 }; 00296 00297 class Fl_Class_Type : public Fl_Type { 00298 const char* subclass_of; 00299 char public_; 00300 public: 00301 Fl_Class_Type() : Fl_Type(), subclass_of(0L) { } 00302 ~Fl_Class_Type() { 00303 if (subclass_of) free((void*)subclass_of); 00304 } 00305 00306 // state variables for output: 00307 char write_public_state; // true when public: has been printed 00308 Fl_Class_Type* parent_class; // save class if nested 00309 // 00310 Fl_Type *make(); 00311 void write_code1(); 00312 void write_code2(); 00313 void open(); 00314 virtual const char *type_name() {return "class";} 00315 int is_parent() const {return 1;} 00316 int is_decl_block() const {return 1;} 00317 int is_class() const {return 1;} 00318 virtual int is_public() const; 00319 int pixmapID() { return 12; } 00320 void write_properties(); 00321 void read_property(const char *); 00322 00323 // class prefix attribute access 00324 void prefix(const char* p); 00325 const char* prefix() const {return class_prefix;} 00326 int has_function(const char*, const char*) const; 00327 private: 00328 const char* class_prefix; 00329 }; 00330 00331 #define NUM_EXTRA_CODE 4 00332 00333 class Fl_Widget_Type : public Fl_Type { 00334 virtual Fl_Widget *widget(int,int,int,int) = 0; 00335 virtual Fl_Widget_Type *_make() = 0; // virtual constructor 00336 virtual void setlabel(const char *); 00337 00338 const char *extra_code_[NUM_EXTRA_CODE]; 00339 const char *subclass_; 00340 const char *tooltip_; 00341 const char *image_name_; 00342 const char *inactive_name_; 00343 uchar hotspot_; 00344 00345 protected: 00346 00347 void write_static(); 00348 void write_code1(); 00349 void write_widget_code(); 00350 void write_extra_code(); 00351 void write_block_close(); 00352 void write_code2(); 00353 void write_color(const char*, Fl_Color); 00354 Fl_Widget *live_widget; 00355 00356 public: 00357 static int default_size; 00358 00359 const char *xclass; // junk string, used for shortcut 00360 Fl_Widget *o; 00361 int public_; 00362 00363 Fluid_Image *image; 00364 void setimage(Fluid_Image *); 00365 Fluid_Image *inactive; 00366 void setinactive(Fluid_Image *); 00367 00368 Fl_Widget_Type(); 00369 Fl_Type *make(); 00370 void open(); 00371 00372 const char *extra_code(int n) const {return extra_code_[n];} 00373 void extra_code(int n,const char *); 00374 const char *subclass() const {return subclass_;} 00375 void subclass(const char *); 00376 const char *tooltip() const {return tooltip_;} 00377 void tooltip(const char *); 00378 const char *image_name() const {return image_name_;} 00379 void image_name(const char *); 00380 const char *inactive_name() const {return inactive_name_;} 00381 void inactive_name(const char *); 00382 uchar hotspot() const {return hotspot_;} 00383 void hotspot(uchar v) {hotspot_ = v;} 00384 uchar resizable() const; 00385 void resizable(uchar v); 00386 00387 virtual int textstuff(int what, Fl_Font &, int &, Fl_Color &); 00388 virtual Fl_Menu_Item *subtypes(); 00389 00390 virtual int is_widget() const; 00391 virtual int is_public() const; 00392 00393 virtual void write_properties(); 00394 virtual void read_property(const char *); 00395 virtual int read_fdesign(const char*, const char*); 00396 00397 virtual Fl_Widget *enter_live_mode(int top=0); 00398 virtual void leave_live_mode(); 00399 virtual void copy_properties(); 00400 00401 virtual void ideal_size(int &w, int &h); 00402 virtual void ideal_spacing(int &x, int &y); 00403 00404 ~Fl_Widget_Type(); 00405 void redraw(); 00406 }; 00407 00408 #include <FL/Fl_Tabs.H> 00409 #include <FL/Fl_Pack.H> 00410 #include <FL/Fl_Wizard.H> 00411 00412 class igroup : public Fl_Group { 00413 public: 00414 void resize(int,int,int,int); 00415 void full_resize(int X, int Y, int W, int H) { Fl_Group::resize(X, Y, W, H); } 00416 igroup(int X,int Y,int W,int H) : Fl_Group(X,Y,W,H) {Fl_Group::current(0);} 00417 }; 00418 00419 class itabs : public Fl_Tabs { 00420 public: 00421 void resize(int,int,int,int); 00422 void full_resize(int X, int Y, int W, int H) { Fl_Group::resize(X, Y, W, H); } 00423 itabs(int X,int Y,int W,int H) : Fl_Tabs(X,Y,W,H) {} 00424 }; 00425 00426 class iwizard : public Fl_Wizard { 00427 public: 00428 void resize(int,int,int,int); 00429 void full_resize(int X, int Y, int W, int H) { Fl_Group::resize(X, Y, W, H); } 00430 iwizard(int X,int Y,int W,int H) : Fl_Wizard(X,Y,W,H) {} 00431 }; 00432 00433 class Fl_Group_Type : public Fl_Widget_Type { 00434 public: 00435 virtual const char *type_name() {return "Fl_Group";} 00436 virtual const char *alt_type_name() {return "fltk::Group";} 00437 Fl_Widget *widget(int X,int Y,int W,int H) { 00438 igroup *g = new igroup(X,Y,W,H); Fl_Group::current(0); return g;} 00439 Fl_Widget_Type *_make() {return new Fl_Group_Type();} 00440 Fl_Type *make(); 00441 void write_code1(); 00442 void write_code2(); 00443 void add_child(Fl_Type*, Fl_Type*); 00444 void move_child(Fl_Type*, Fl_Type*); 00445 void remove_child(Fl_Type*); 00446 int is_parent() const {return 1;} 00447 int is_group() const {return 1;} 00448 int pixmapID() { return 6; } 00449 00450 virtual Fl_Widget *enter_live_mode(int top=0); 00451 virtual void leave_live_mode(); 00452 virtual void copy_properties(); 00453 }; 00454 00455 extern const char pack_type_name[]; 00456 extern Fl_Menu_Item pack_type_menu[]; 00457 00458 class Fl_Pack_Type : public Fl_Group_Type { 00459 Fl_Menu_Item *subtypes() {return pack_type_menu;} 00460 public: 00461 virtual const char *type_name() {return pack_type_name;} 00462 virtual const char *alt_type_name() {return "fltk::PackedGroup";} 00463 Fl_Widget_Type *_make() {return new Fl_Pack_Type();} 00464 int pixmapID() { return 22; } 00465 void copy_properties(); 00466 }; 00467 00468 extern const char table_type_name[]; 00469 00470 class Fl_Table_Type : public Fl_Group_Type { 00471 public: 00472 virtual const char *type_name() {return table_type_name;} 00473 virtual const char *alt_type_name() {return "fltk::TableGroup";} 00474 Fl_Widget_Type *_make() {return new Fl_Table_Type();} 00475 Fl_Widget *widget(int X,int Y,int W,int H); 00476 int pixmapID() { return 51; } 00477 virtual Fl_Widget *enter_live_mode(int top=0); 00478 void add_child(Fl_Type*, Fl_Type*); 00479 void move_child(Fl_Type*, Fl_Type*); 00480 void remove_child(Fl_Type*); 00481 }; 00482 00483 extern const char tabs_type_name[]; 00484 00485 class Fl_Tabs_Type : public Fl_Group_Type { 00486 public: 00487 virtual void ideal_spacing(int &x, int &y) { 00488 x = 10; 00489 fl_font(o->labelfont(), o->labelsize()); 00490 y = fl_height() + o->labelsize() - 6; 00491 } 00492 virtual const char *type_name() {return tabs_type_name;} 00493 virtual const char *alt_type_name() {return "fltk::TabGroup";} 00494 Fl_Widget *widget(int X,int Y,int W,int H) { 00495 itabs *g = new itabs(X,Y,W,H); Fl_Group::current(0); return g;} 00496 Fl_Widget_Type *_make() {return new Fl_Tabs_Type();} 00497 Fl_Type* click_test(int,int); 00498 void add_child(Fl_Type*, Fl_Type*); 00499 void remove_child(Fl_Type*); 00500 int pixmapID() { return 13; } 00501 Fl_Widget *enter_live_mode(int top=0); 00502 }; 00503 00504 extern const char scroll_type_name[]; 00505 extern Fl_Menu_Item scroll_type_menu[]; 00506 00507 class Fl_Scroll_Type : public Fl_Group_Type { 00508 Fl_Menu_Item *subtypes() {return scroll_type_menu;} 00509 public: 00510 virtual const char *type_name() {return scroll_type_name;} 00511 virtual const char *alt_type_name() {return "fltk::ScrollGroup";} 00512 Fl_Widget_Type *_make() {return new Fl_Scroll_Type();} 00513 int pixmapID() { return 19; } 00514 Fl_Widget *enter_live_mode(int top=0); 00515 void copy_properties(); 00516 }; 00517 00518 extern const char tile_type_name[]; 00519 00520 class Fl_Tile_Type : public Fl_Group_Type { 00521 public: 00522 virtual const char *type_name() {return tile_type_name;} 00523 virtual const char *alt_type_name() {return "fltk::TileGroup";} 00524 Fl_Widget_Type *_make() {return new Fl_Tile_Type();} 00525 int pixmapID() { return 20; } 00526 void copy_properties(); 00527 }; 00528 00529 extern const char wizard_type_name[]; 00530 00531 class Fl_Wizard_Type : public Fl_Group_Type { 00532 public: 00533 virtual const char *type_name() {return wizard_type_name;} 00534 virtual const char *alt_type_name() {return "fltk::WizardGroup";} 00535 Fl_Widget *widget(int X,int Y,int W,int H) { 00536 iwizard *g = new iwizard(X,Y,W,H); Fl_Group::current(0); return g;} 00537 Fl_Widget_Type *_make() {return new Fl_Wizard_Type();} 00538 int pixmapID() { return 21; } 00539 }; 00540 00541 extern Fl_Menu_Item window_type_menu[]; 00542 00543 class Fl_Window_Type : public Fl_Widget_Type { 00544 protected: 00545 00546 Fl_Menu_Item* subtypes() {return window_type_menu;} 00547 00548 friend class Overlay_Window; 00549 int mx,my; // mouse position during dragging 00550 int x1,y1; // initial position of selection box 00551 int bx,by,br,bt; // bounding box of selection before snapping 00552 int sx,sy,sr,st; // bounding box of selection after snapping to guides 00553 int dx,dy; 00554 int drag; // which parts of bbox are being moved 00555 int numselected; // number of children selected 00556 enum {LEFT=1,RIGHT=2,BOTTOM=4,TOP=8,DRAG=16,BOX=32}; 00557 void draw_overlay(); 00558 void newdx(); 00559 void newposition(Fl_Widget_Type *,int &x,int &y,int &w,int &h); 00560 int handle(int); 00561 virtual void setlabel(const char *); 00562 void write_code1(); 00563 void write_code2(); 00564 Fl_Widget_Type *_make() {return 0;} // we don't call this 00565 Fl_Widget *widget(int,int,int,int) {return 0;} 00566 int recalc; // set by fix_overlay() 00567 void moveallchildren(); 00568 int pixmapID() { return 1; } 00569 00570 public: 00571 00572 Fl_Window_Type() { drag = dx = dy = 0; sr_min_w = sr_min_h = sr_max_w = sr_max_h = 0; } 00573 uchar modal, non_modal; 00574 00575 Fl_Type *make(); 00576 virtual const char *type_name() {return "Fl_Window";} 00577 virtual const char *alt_type_name() {return "fltk::Window";} 00578 00579 void open(); 00580 00581 void fix_overlay(); // Update the bounding box, etc 00582 uchar *read_image(int &ww, int &hh); // Read an image of the window 00583 00584 virtual void write_properties(); 00585 virtual void read_property(const char *); 00586 virtual int read_fdesign(const char*, const char*); 00587 00588 void add_child(Fl_Type*, Fl_Type*); 00589 void move_child(Fl_Type*, Fl_Type*); 00590 void remove_child(Fl_Type*); 00591 00592 int is_parent() const {return 1;} 00593 int is_group() const {return 1;} 00594 int is_window() const {return 1;} 00595 00596 Fl_Widget *enter_live_mode(int top=0); 00597 void leave_live_mode(); 00598 void copy_properties(); 00599 00600 int sr_min_w, sr_min_h, sr_max_w, sr_max_h; 00601 }; 00602 00603 class Fl_Widget_Class_Type : private Fl_Window_Type { 00604 public: 00605 Fl_Widget_Class_Type() { 00606 write_public_state = 0; 00607 wc_relative = 0; 00608 } 00609 // state variables for output: 00610 char write_public_state; // true when public: has been printed 00611 char wc_relative; // if true, reposition all child widgets in an Fl_Group 00612 00613 virtual void write_properties(); 00614 virtual void read_property(const char *); 00615 00616 void write_code1(); 00617 void write_code2(); 00618 Fl_Type *make(); 00619 virtual const char *type_name() {return "widget_class";} 00620 int pixmapID() { return 48; } 00621 int is_parent() const {return 1;} 00622 int is_code_block() const {return 1;} 00623 int is_decl_block() const {return 1;} 00624 int is_class() const {return 1;} 00625 }; 00626 00627 00628 extern Fl_Menu_Item menu_item_type_menu[]; 00629 00630 class Fl_Menu_Item_Type : public Fl_Widget_Type { 00631 public: 00632 Fl_Menu_Item* subtypes() {return menu_item_type_menu;} 00633 const char* type_name() {return "MenuItem";} 00634 const char* alt_type_name() {return "fltk::Item";} 00635 Fl_Type* make(); 00636 int is_menu_item() const {return 1;} 00637 int is_button() const {return 1;} // this gets shortcut to work 00638 Fl_Widget* widget(int,int,int,int) {return 0;} 00639 Fl_Widget_Type* _make() {return 0;} 00640 const char* menu_name(int& i); 00641 int flags(); 00642 void write_static(); 00643 void write_item(); 00644 void write_code1(); 00645 void write_code2(); 00646 int pixmapID() { return 16; } 00647 }; 00648 00649 class Fl_Submenu_Type : public Fl_Menu_Item_Type { 00650 public: 00651 Fl_Menu_Item* subtypes() {return 0;} 00652 const char* type_name() {return "Submenu";} 00653 const char* alt_type_name() {return "fltk::ItemGroup";} 00654 int is_parent() const {return 1;} 00655 int is_button() const {return 0;} // disable shortcut 00656 Fl_Type* make(); 00657 // changes to submenu must propagate up so build_menu is called 00658 // on the parent Fl_Menu_Type: 00659 void add_child(Fl_Type*a, Fl_Type*b) {parent->add_child(a,b);} 00660 void move_child(Fl_Type*a, Fl_Type*b) {parent->move_child(a,b);} 00661 void remove_child(Fl_Type*a) {parent->remove_child(a);} 00662 int pixmapID() { return 18; } 00663 }; 00664 00665 00666 #include <FL/Fl_Menu_.H> 00667 class Fl_Menu_Type : public Fl_Widget_Type { 00668 int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) { 00669 Fl_Menu_ *myo = (Fl_Menu_*)(w==4 ? ((Fl_Widget_Type*)this->factory)->o : this->o); 00670 switch (w) { 00671 case 4: 00672 case 0: f = myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break; 00673 case 1: myo->textfont(f); break; 00674 case 2: myo->textsize(s); break; 00675 case 3: myo->textcolor(c); break; 00676 } 00677 return 1; 00678 } 00679 public: 00680 int is_menu_button() const {return 1;} 00681 int is_parent() const {return 1;} 00682 int menusize; 00683 virtual void build_menu(); 00684 Fl_Menu_Type() : Fl_Widget_Type() {menusize = 0;} 00685 ~Fl_Menu_Type() { 00686 if (menusize) delete[] (Fl_Menu_Item*)(((Fl_Menu_*)o)->menu()); 00687 } 00688 void add_child(Fl_Type*, Fl_Type*) {build_menu();} 00689 void move_child(Fl_Type*, Fl_Type*) {build_menu();} 00690 void remove_child(Fl_Type*) {build_menu();} 00691 Fl_Type* click_test(int x, int y); 00692 void write_code2(); 00693 void copy_properties(); 00694 }; 00695 00696 extern Fl_Menu_Item button_type_menu[]; 00697 00698 #include <FL/Fl_Menu_Button.H> 00699 class Fl_Menu_Button_Type : public Fl_Menu_Type { 00700 Fl_Menu_Item *subtypes() {return button_type_menu;} 00701 public: 00702 virtual void ideal_size(int &w, int &h) { 00703 Fl_Widget_Type::ideal_size(w, h); 00704 w += 2 * ((o->labelsize() - 3) & ~1) + o->labelsize() - 4; 00705 h = (h / 5) * 5; 00706 if (h < 15) h = 15; 00707 if (w < (15 + h)) w = 15 + h; 00708 } 00709 virtual const char *type_name() {return "Fl_Menu_Button";} 00710 virtual const char *alt_type_name() {return "fltk::MenuButton";} 00711 Fl_Widget *widget(int X,int Y,int W,int H) { 00712 return new Fl_Menu_Button(X,Y,W,H,"menu");} 00713 Fl_Widget_Type *_make() {return new Fl_Menu_Button_Type();} 00714 int pixmapID() { return 26; } 00715 }; 00716 00717 extern Fl_Menu_Item dummymenu[]; 00718 00719 #include <FL/Fl_Choice.H> 00720 class Fl_Choice_Type : public Fl_Menu_Type { 00721 public: 00722 virtual void ideal_size(int &w, int &h) { 00723 Fl_Widget_Type::ideal_size(w, h); 00724 int w1 = o->h() - Fl::box_dh(o->box()); 00725 if (w1 > 20) w1 = 20; 00726 w1 = (w1 - 4) / 3; 00727 if (w1 < 1) w1 = 1; 00728 w += 2 * w1 + o->labelsize() - 4; 00729 h = (h / 5) * 5; 00730 if (h < 15) h = 15; 00731 if (w < (15 + h)) w = 15 + h; 00732 } 00733 virtual const char *type_name() {return "Fl_Choice";} 00734 virtual const char *alt_type_name() {return "fltk::Choice";} 00735 Fl_Widget *widget(int X,int Y,int W,int H) { 00736 Fl_Choice *myo = new Fl_Choice(X,Y,W,H,"choice:"); 00737 myo->menu(dummymenu); 00738 return myo; 00739 } 00740 Fl_Widget_Type *_make() {return new Fl_Choice_Type();} 00741 int pixmapID() { return 15; } 00742 }; 00743 00744 #include <FL/Fl_Input_Choice.H> 00745 class Fl_Input_Choice_Type : public Fl_Menu_Type { 00746 int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) { 00747 Fl_Input_Choice *myo = (Fl_Input_Choice*)(w==4 ? ((Fl_Widget_Type*)this->factory)->o : this->o); 00748 switch (w) { 00749 case 4: 00750 case 0: f = (Fl_Font)myo->textfont(); s = myo->textsize(); c = myo->textcolor(); break; 00751 case 1: myo->textfont(f); break; 00752 case 2: myo->textsize(s); break; 00753 case 3: myo->textcolor(c); break; 00754 } 00755 return 1; 00756 } 00757 public: 00758 virtual void ideal_size(int &w, int &h) { 00759 Fl_Input_Choice *myo = (Fl_Input_Choice *)o; 00760 fl_font(myo->textfont(), myo->textsize()); 00761 h = fl_height() + myo->textsize() - 6; 00762 w = o->w() - 20 - Fl::box_dw(o->box()); 00763 int ww = (int)fl_width('m'); 00764 w = ((w + ww - 1) / ww) * ww + 20 + Fl::box_dw(o->box()); 00765 if (h < 15) h = 15; 00766 if (w < (15 + h)) w = 15 + h; 00767 } 00768 virtual const char *type_name() {return "Fl_Input_Choice";} 00769 virtual const char *alt_type_name() {return "fltk::ComboBox";} 00770 virtual Fl_Type* click_test(int,int); 00771 Fl_Widget *widget(int X,int Y,int W,int H) { 00772 Fl_Input_Choice *myo = new Fl_Input_Choice(X,Y,W,H,"input choice:"); 00773 myo->menu(dummymenu); 00774 myo->value("input"); 00775 return myo; 00776 } 00777 Fl_Widget_Type *_make() {return new Fl_Input_Choice_Type();} 00778 virtual void build_menu(); 00779 int pixmapID() { return 15; } 00780 void copy_properties(); 00781 }; 00782 00783 #include <FL/Fl_Window.H> 00784 #include <FL/Fl_Menu_Bar.H> 00785 class Fl_Menu_Bar_Type : public Fl_Menu_Type { 00786 public: 00787 virtual void ideal_size(int &w, int &h) { 00788 w = o->window()->w(); 00789 h = ((o->labelsize() + Fl::box_dh(o->box()) + 4) / 5) * 5; 00790 if (h < 15) h = 15; 00791 } 00792 virtual const char *type_name() {return "Fl_Menu_Bar";} 00793 virtual const char *alt_type_name() {return "fltk::MenuBar";} 00794 Fl_Widget *widget(int X,int Y,int W,int H) {return new Fl_Menu_Bar(X,Y,W,H);} 00795 Fl_Widget_Type *_make() {return new Fl_Menu_Bar_Type();} 00796 int pixmapID() { return 17; } 00797 }; 00798 // object list operations: 00799 Fl_Widget *make_widget_browser(int X,int Y,int W,int H); 00800 extern int modflag; 00801 void delete_all(int selected_only=0); 00802 void selection_changed(Fl_Type* new_current); 00803 void reveal_in_browser(Fl_Type*); 00804 int has_toplevel_function(const char *rtype, const char *sig); 00805 00806 // file operations: 00807 # ifdef __GNUC__ 00808 # define __fl_attr(x) __attribute__ (x) 00809 # else 00810 # define __fl_attr(x) 00811 # endif // __GNUC__ 00812 00813 void write_word(const char *); 00814 void write_string(const char *,...) __fl_attr((__format__ (__printf__, 1, 2))); 00815 int write_file(const char *, int selected_only = 0); 00816 int write_code(const char *cfile, const char *hfile); 00817 int write_strings(const char *sfile); 00818 00819 int write_declare(const char *, ...) __fl_attr((__format__ (__printf__, 1, 2))); 00820 int is_id(char); 00821 const char* unique_id(void* o, const char*, const char*, const char*); 00822 void write_c(const char*, ...) __fl_attr((__format__ (__printf__, 1, 2))); 00823 void write_h(const char*, ...) __fl_attr((__format__ (__printf__, 1, 2))); 00824 void write_cstring(const char *); 00825 void write_cstring(const char *,int length); 00826 void write_cdata(const char *,int length); 00827 void write_indent(int n); 00828 void write_open(int); 00829 void write_close(int n); 00830 extern int write_number; 00831 extern int write_sourceview; 00832 void write_public(int state); // writes pubic:/private: as needed 00833 extern int indentation; 00834 extern const char* indent(); 00835 00836 int read_file(const char *, int merge); 00837 const char *read_word(int wantbrace = 0); 00838 void read_error(const char *format, ...); 00839 00840 // check legality of c code (sort of) and return error: 00841 const char *c_check(const char *c, int type = 0); 00842 00843 // replace a string pointer with new value, strips leading/trailing blanks: 00844 int storestring(const char *n, const char * & p, int nostrip=0); 00845 00846 extern int include_H_from_C; 00847 extern int use_FL_COMMAND; 00848 00849 /* 00850 * This class is needed for additional command line plugins. 00851 */ 00852 class Fl_Commandline_Plugin : public Fl_Plugin { 00853 public: 00854 Fl_Commandline_Plugin(const char *name) 00855 : Fl_Plugin(klass(), name) { } 00856 virtual const char *klass() { return "commandline"; } 00857 // return a unique name for this plugin 00858 virtual const char *name() = 0; 00859 // return a help text for all supported commands 00860 virtual const char *help() = 0; 00861 // handle a command and return the number of args used, or 0 00862 virtual int arg(int argc, char **argv, int &i) = 0; 00863 // optional test the plugin 00864 virtual int test(const char *a1=0L, const char *a2=0L, const char *a3=0L) { 00865 return 0; 00866 } 00867 // show a GUI panel to edit some data 00868 virtual void show_panel() { } 00869 }; 00870 00871 00872 // 00873 // End of "$Id: Fl_Type.h 8172 2011-01-03 08:28:38Z matt $". 00874 //