• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

Fl_Tree_Prefs.H

Go to the documentation of this file.
00001 //
00002 // "$Id$"
00003 //
00004 
00005 #ifndef FL_TREE_PREFS_H
00006 #define FL_TREE_PREFS_H
00007 
00008 #include <FL/Fl.H>      // needed for ABI version features (via Enumerations.H)
00009 
00011 // FL/Fl_Tree_Prefs.H
00013 //
00014 // Fl_Tree_Prefs -- This file is part of the Fl_Tree widget for FLTK
00015 // Copyright (C) 2009-2010 by Greg Ercolano.
00016 //
00017 // This library is free software. Distribution and use rights are outlined in
00018 // the file "COPYING" which should have been included with this file.  If this
00019 // file is missing or damaged, see the license at:
00020 //
00021 //     http://www.fltk.org/COPYING.php
00022 //
00023 // Please report all bugs and problems on the following page:
00024 //
00025 //     http://www.fltk.org/str.php
00026 //
00027 
00042 
00045 
00049 enum Fl_Tree_Sort {
00050   FL_TREE_SORT_NONE=0,          
00051   FL_TREE_SORT_ASCENDING=1,     
00052   FL_TREE_SORT_DESCENDING=2     
00053 };
00054 
00058 enum Fl_Tree_Connector {
00059   FL_TREE_CONNECTOR_NONE=0,     
00060   FL_TREE_CONNECTOR_DOTTED=1,   
00061   FL_TREE_CONNECTOR_SOLID=2     
00062 };
00063 
00067 enum Fl_Tree_Select {
00068   FL_TREE_SELECT_NONE=0,        
00069   FL_TREE_SELECT_SINGLE=1,      
00070   FL_TREE_SELECT_MULTI=2,       
00071 
00072   FL_TREE_SELECT_SINGLE_DRAGGABLE=3 
00073 
00074 };
00075 
00076 #if FLTK_ABI_VERSION >= 10301
00081 enum Fl_Tree_Item_Reselect_Mode {
00082   FL_TREE_SELECTABLE_ONCE=0,    
00083   FL_TREE_SELECTABLE_ALWAYS,    
00084 };
00085 
00090 enum Fl_Tree_Item_Draw_Mode {
00091   FL_TREE_ITEM_DRAW_DEFAULT=0,          
00092 
00093   FL_TREE_ITEM_DRAW_LABEL_AND_WIDGET=1, 
00094   FL_TREE_ITEM_HEIGHT_FROM_WIDGET=2     
00095 };
00096 #endif /*FLTK_ABI_VERSION*/
00097 
00098 #if FLTK_ABI_VERSION >= 10303
00099 class Fl_Tree_Item;
00100 typedef void (Fl_Tree_Item_Draw_Callback)(Fl_Tree_Item*, void*);
00101 #endif
00102 
00111 class FL_EXPORT Fl_Tree_Prefs {
00112   Fl_Font _labelfont;                   // label's font face
00113   Fl_Fontsize _labelsize;               // label's font size
00114   int _margintop;                       // -- 
00115   int _marginleft;                      //   |- tree's controllable margins
00116 #if FLTK_ABI_VERSION >= 10301
00117   int _marginbottom;                    // --
00118 #endif
00119   int _openchild_marginbottom;          // extra space below an open child tree
00120   int _usericonmarginleft;              // space to left of user icon (if any)
00121   int _labelmarginleft;                 // space to left of label
00122 #if FLTK_ABI_VERSION >= 10301
00123   int _widgetmarginleft;                // space to left of widget
00124 #endif
00125   int _connectorwidth;                  // connector width (right of open/close icon)
00126   int _linespacing;                     // vertical space between lines
00127   // Colors
00128   Fl_Color _labelfgcolor;               // label's foreground color
00129   Fl_Color _labelbgcolor;               // label's background color
00130   Fl_Color _connectorcolor;             // connector dotted line color
00131   Fl_Tree_Connector _connectorstyle;    // connector line style
00132   Fl_Image *_openimage;                 // the 'open' icon [+]
00133   Fl_Image *_closeimage;                // the 'close' icon [-]
00134   Fl_Image *_userimage;                 // user's own icon
00135 #if FLTK_ABI_VERSION >= 10304
00136   Fl_Image *_opendeimage;               // deactivated 'open' icon
00137   Fl_Image *_closedeimage;              // deactivated 'close' icon
00138   Fl_Image *_userdeimage;               // deactivated user icon
00139 #endif
00140   char _showcollapse;                   // 1=show collapse icons, 0=don't
00141   char _showroot;                       // show the root item as part of the tree
00142   Fl_Tree_Sort   _sortorder;            // none, ascening, descending, etc.
00143   Fl_Boxtype     _selectbox;            // selection box type
00144   Fl_Tree_Select _selectmode;           // selection mode
00145 #if FLTK_ABI_VERSION >= 10301
00146   Fl_Tree_Item_Reselect_Mode _itemreselectmode; // controls item selection callback() behavior
00147   Fl_Tree_Item_Draw_Mode     _itemdrawmode;     // controls how items draw label + widget()
00148 #endif /*FLTK_ABI_VERSION*/
00149 #if FLTK_ABI_VERSION >= 10303
00150   Fl_Tree_Item_Draw_Callback *_itemdrawcallback;        // callback to handle drawing items (0=none)
00151   void                       *_itemdrawuserdata;        // data for drawing items (0=none)
00152 #endif
00153 public:
00154   Fl_Tree_Prefs();
00155 #if FLTK_ABI_VERSION >= 10304
00156   ~Fl_Tree_Prefs();
00157 #endif
00158   
00160   // Labels
00163   inline Fl_Font item_labelfont() const { return(_labelfont); }
00165   inline void item_labelfont(Fl_Font val) { _labelfont = val; }
00167   inline Fl_Fontsize item_labelsize() const { return(_labelsize); }
00169   inline void item_labelsize(Fl_Fontsize val) { _labelsize = val; }
00171   inline Fl_Color item_labelfgcolor() const { return(_labelfgcolor); }
00173   inline void item_labelfgcolor(Fl_Color val) { _labelfgcolor = val; }
00174 #if FLTK_ABI_VERSION >= 10301
00179   inline Fl_Color item_labelbgcolor() const {
00180     return _labelbgcolor;
00181   }
00185   inline void item_labelbgcolor(Fl_Color val) {
00186     _labelbgcolor = val;
00187   }
00188 #else /*FLTK_ABI_VERSION*/
00190   inline Fl_Color item_labelbgcolor() const {
00191     return(_labelbgcolor);
00192   }
00194   inline void item_labelbgcolor(Fl_Color val) {
00195     _labelbgcolor = val;
00196   }
00197 #endif /*FLTK_ABI_VERSION*/
00198 
00200   // Obsolete names - for 1.3.0 backwards compat
00203   inline Fl_Font labelfont() const { return(_labelfont); }
00205   inline void labelfont(Fl_Font val) { _labelfont = val; }
00207   inline Fl_Fontsize labelsize() const { return(_labelsize); }
00209   inline void labelsize(Fl_Fontsize val) { _labelsize = val; }
00211   inline Fl_Color labelfgcolor() const { return(_labelfgcolor); }
00213   inline void labelfgcolor(Fl_Color val) { _labelfgcolor = val; }
00215   inline Fl_Color labelbgcolor() const { return(item_labelbgcolor()); }
00217   inline void labelbgcolor(Fl_Color val) { item_labelbgcolor(val); }
00218   
00220   // Margins
00223   inline int marginleft() const {
00224     return(_marginleft);
00225   }
00227   inline void marginleft(int val) {
00228     _marginleft = val;
00229   }
00231   inline int margintop() const {
00232     return(_margintop);
00233   }
00235   inline void margintop(int val) {
00236     _margintop = val;
00237   }
00238 #if FLTK_ABI_VERSION >= 10301
00241   inline int marginbottom() const {
00242     return(_marginbottom);
00243   }
00246   inline void marginbottom(int val) {
00247     _marginbottom = val;
00248   }
00249 #endif /*FLTK_ABI_VERSION*/
00251   inline int openchild_marginbottom() const {
00252     return(_openchild_marginbottom);
00253   }
00255   inline void openchild_marginbottom(int val) {
00256     _openchild_marginbottom = val;
00257   }
00259   inline int usericonmarginleft() const {
00260     return(_usericonmarginleft);
00261   }
00263   inline void usericonmarginleft(int val) {
00264     _usericonmarginleft = val;
00265   }
00267   inline int labelmarginleft() const {
00268     return(_labelmarginleft);
00269   }
00271   inline void labelmarginleft(int val) {
00272     _labelmarginleft = val;
00273   }
00274 #if FLTK_ABI_VERSION >= 10301
00276   inline int widgetmarginleft() const {
00277     return(_widgetmarginleft);
00278   }
00280   inline void widgetmarginleft(int val) {
00281     _widgetmarginleft = val;
00282   }
00283 #endif /*FLTK_ABI_VERSION*/
00285   inline int linespacing() const {
00286     return(_linespacing);
00287   }
00289   inline void linespacing(int val) {
00290     _linespacing = val;
00291   }
00292   
00294   // Colors and Styles
00297   inline Fl_Color connectorcolor() const {
00298     return(_connectorcolor);
00299   }
00301   inline void connectorcolor(Fl_Color val) {
00302     _connectorcolor = val;
00303   }
00305   inline Fl_Tree_Connector connectorstyle() const {
00306     return(_connectorstyle);
00307   }
00309   inline void connectorstyle(Fl_Tree_Connector val) {
00310     _connectorstyle = val;
00311   }
00313   inline void connectorstyle(int val) {
00314     _connectorstyle = Fl_Tree_Connector(val);
00315   }
00317   inline int connectorwidth() const {
00318     return(_connectorwidth);
00319   }
00321   inline void connectorwidth(int val) {
00322     _connectorwidth = val;
00323   }
00324   
00326   // Icons
00331   inline Fl_Image *openicon() const {
00332     return(_openimage);
00333   }
00334   void openicon(Fl_Image *val);
00338   inline Fl_Image *closeicon() const {
00339     return(_closeimage);
00340   }
00341   void closeicon(Fl_Image *val);
00343   inline Fl_Image *usericon() const {
00344     return(_userimage);
00345   }
00349   inline void usericon(Fl_Image *val) {
00350     _userimage = val;
00351 #if FLTK_ABI_VERSION >= 10304
00352     // Update deactivated version of icon..
00353     if ( _userdeimage ) delete _userdeimage;
00354     if ( _userimage ) {
00355       _userdeimage = _userimage->copy();
00356       _userdeimage->inactive();
00357     } else {
00358       _userdeimage = 0;
00359     }
00360 #endif
00361   }
00362 
00363 #if FLTK_ABI_VERSION >= 10304
00366   inline Fl_Image *opendeicon() const {
00367     return _opendeimage;
00368   }
00371   inline Fl_Image *closedeicon() const {
00372     return _closedeimage;
00373   }
00376   inline Fl_Image *userdeicon() const {
00377     return _userdeimage;
00378   }
00379 #endif
00380   
00382   // Options
00385   inline char showcollapse() const {
00386     return(_showcollapse);
00387   }
00396   inline void showcollapse(int val) {
00397     _showcollapse = val;
00398   }
00400   inline Fl_Tree_Sort sortorder() const {
00401     return(_sortorder);
00402   }
00407   inline void sortorder(Fl_Tree_Sort val) {
00408     _sortorder = val;
00409   }
00411   inline Fl_Boxtype selectbox() const {
00412     return(_selectbox);
00413   }
00415   inline void selectbox(Fl_Boxtype val) {
00416     _selectbox = val;
00417   }
00419   inline int showroot() const {
00420     return(int(_showroot));
00421   }
00426   inline void showroot(int val) {
00427     _showroot = char(val);
00428   }
00430   inline Fl_Tree_Select selectmode() const {
00431     return(_selectmode);
00432   }
00438   inline void selectmode(Fl_Tree_Select val) {
00439     _selectmode = val;
00440   }
00441 #if FLTK_ABI_VERSION >= 10301
00443   Fl_Tree_Item_Reselect_Mode item_reselect_mode() const {
00444     return _itemreselectmode;
00445   }
00447   void item_reselect_mode(Fl_Tree_Item_Reselect_Mode mode) {
00448     _itemreselectmode = mode;
00449   }
00451   inline Fl_Tree_Item_Draw_Mode item_draw_mode() const {
00452     return(_itemdrawmode);
00453   }
00459   inline void item_draw_mode(Fl_Tree_Item_Draw_Mode val) {
00460     _itemdrawmode = val;
00461   }
00462 #endif
00463 #if FLTK_ABI_VERSION >= 10303
00464   void item_draw_callback(Fl_Tree_Item_Draw_Callback *cb, void *data=0) {
00465     _itemdrawcallback = cb;
00466     _itemdrawuserdata = data;
00467   }
00468   Fl_Tree_Item_Draw_Callback* item_draw_callback() const {
00469     return(_itemdrawcallback);
00470   }
00471   void* item_draw_user_data() const {
00472     return(_itemdrawuserdata);
00473   }
00474   void do_item_draw_callback(Fl_Tree_Item *o) const {
00475     _itemdrawcallback(o, _itemdrawuserdata);
00476   }
00477 #endif
00478 };
00479 
00480 #endif /*FL_TREE_PREFS_H*/
00481 
00482 //
00483 // End of "$Id$".
00484 //
  • © 1998-2016 by Bill Spitzak and others.     FLTK

  • © 1998-2016 by Bill Spitzak and others.     FLTK

    Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.