FLTK
Fl_Tree_Prefs.H
Go to the documentation of this file.
1 //
2 
3 #ifndef FL_TREE_PREFS_H
4 #define FL_TREE_PREFS_H
5 
6 #include <FL/Fl.H> // needed for ABI version features (via Enumerations.H)
7 
9 // FL/Fl_Tree_Prefs.H
11 //
12 // Fl_Tree_Prefs -- This file is part of the Fl_Tree widget for FLTK
13 // Copyright (C) 2009-2010 by Greg Ercolano.
14 //
15 // This library is free software. Distribution and use rights are outlined in
16 // the file "COPYING" which should have been included with this file. If this
17 // file is missing or damaged, see the license at:
18 //
19 // https://www.fltk.org/COPYING.php
20 //
21 // Please see the following page on how to report bugs and issues:
22 //
23 // https://www.fltk.org/bugs.php
24 //
25 
40 
43 
51 };
52 
60 };
61 
71 };
73 
81 };
82 
92 };
93 
94 class Fl_Tree_Item;
95 typedef void (Fl_Tree_Item_Draw_Callback)(Fl_Tree_Item*, void*);
96 
105 class FL_EXPORT Fl_Tree_Prefs {
106  Fl_Font _labelfont; // label's font face
107  Fl_Fontsize _labelsize; // label's font size
108  int _margintop; // --
109  int _marginleft; // |- tree's controllable margins
110  int _marginbottom; // --
111  int _openchild_marginbottom; // extra space below an open child tree
112  int _usericonmarginleft; // space to left of user icon (if any)
113  int _labelmarginleft; // space to left of label
114  int _widgetmarginleft; // space to left of widget
115  int _connectorwidth; // connector width (right of open/close icon)
116  int _linespacing; // vertical space between lines
117  // Colors
118  Fl_Color _labelfgcolor; // label's foreground color
119  Fl_Color _labelbgcolor; // label's background color
120  Fl_Color _connectorcolor; // connector dotted line color
121  Fl_Tree_Connector _connectorstyle; // connector line style
122  Fl_Image *_openimage; // the 'open' icon [+]
123  Fl_Image *_closeimage; // the 'close' icon [-]
124  Fl_Image *_userimage; // user's own icon
125  Fl_Image *_opendeimage; // deactivated 'open' icon
126  Fl_Image *_closedeimage; // deactivated 'close' icon
127  Fl_Image *_userdeimage; // deactivated user icon
128  char _showcollapse; // 1=show collapse icons, 0=don't
129  char _showroot; // show the root item as part of the tree
130  Fl_Tree_Sort _sortorder; // none, ascening, descending, etc.
131  Fl_Boxtype _selectbox; // selection box type
132  Fl_Tree_Select _selectmode; // selection mode
133  Fl_Tree_Item_Reselect_Mode _itemreselectmode; // controls item selection callback() behavior
134  Fl_Tree_Item_Draw_Mode _itemdrawmode; // controls how items draw label + widget()
135  Fl_Tree_Item_Draw_Callback *_itemdrawcallback; // callback to handle drawing items (0=none)
136  void *_itemdrawuserdata; // data for drawing items (0=none)
137 public:
138  Fl_Tree_Prefs();
139  ~Fl_Tree_Prefs();
140 
142  // Labels
145  inline Fl_Font item_labelfont() const { return(_labelfont); }
147  inline void item_labelfont(Fl_Font val) { _labelfont = val; }
149  inline Fl_Fontsize item_labelsize() const { return(_labelsize); }
151  inline void item_labelsize(Fl_Fontsize val) { _labelsize = val; }
153  inline Fl_Color item_labelfgcolor() const { return(_labelfgcolor); }
155  inline void item_labelfgcolor(Fl_Color val) { _labelfgcolor = val; }
160  inline Fl_Color item_labelbgcolor() const {
161  return _labelbgcolor;
162  }
166  inline void item_labelbgcolor(Fl_Color val) {
167  _labelbgcolor = val;
168  }
169 
171  // Obsolete names - for 1.3.0 backwards compat
174  inline Fl_Font labelfont() const { return(_labelfont); }
176  inline void labelfont(Fl_Font val) { _labelfont = val; }
178  inline Fl_Fontsize labelsize() const { return(_labelsize); }
180  inline void labelsize(Fl_Fontsize val) { _labelsize = val; }
182  inline Fl_Color labelfgcolor() const { return(_labelfgcolor); }
184  inline void labelfgcolor(Fl_Color val) { _labelfgcolor = val; }
186  inline Fl_Color labelbgcolor() const { return(item_labelbgcolor()); }
188  inline void labelbgcolor(Fl_Color val) { item_labelbgcolor(val); }
189 
191  // Margins
194  inline int marginleft() const {
195  return(_marginleft);
196  }
198  inline void marginleft(int val) {
199  _marginleft = val;
200  }
202  inline int margintop() const {
203  return(_margintop);
204  }
206  inline void margintop(int val) {
207  _margintop = val;
208  }
211  inline int marginbottom() const {
212  return(_marginbottom);
213  }
216  inline void marginbottom(int val) {
217  _marginbottom = val;
218  }
220  inline int openchild_marginbottom() const {
221  return(_openchild_marginbottom);
222  }
224  inline void openchild_marginbottom(int val) {
225  _openchild_marginbottom = val;
226  }
228  inline int usericonmarginleft() const {
229  return(_usericonmarginleft);
230  }
232  inline void usericonmarginleft(int val) {
233  _usericonmarginleft = val;
234  }
236  inline int labelmarginleft() const {
237  return(_labelmarginleft);
238  }
240  inline void labelmarginleft(int val) {
241  _labelmarginleft = val;
242  }
244  inline int widgetmarginleft() const {
245  return(_widgetmarginleft);
246  }
248  inline void widgetmarginleft(int val) {
249  _widgetmarginleft = val;
250  }
252  inline int linespacing() const {
253  return(_linespacing);
254  }
256  inline void linespacing(int val) {
257  _linespacing = val;
258  }
259 
261  // Colors and Styles
264  inline Fl_Color connectorcolor() const {
265  return(_connectorcolor);
266  }
268  inline void connectorcolor(Fl_Color val) {
269  _connectorcolor = val;
270  }
273  return(_connectorstyle);
274  }
277  _connectorstyle = val;
278  }
280  inline void connectorstyle(int val) {
281  _connectorstyle = Fl_Tree_Connector(val);
282  }
284  inline int connectorwidth() const {
285  return(_connectorwidth);
286  }
288  inline void connectorwidth(int val) {
289  _connectorwidth = val;
290  }
291 
293  // Icons
298  inline Fl_Image *openicon() const {
299  return(_openimage);
300  }
301  void openicon(Fl_Image *val);
305  inline Fl_Image *closeicon() const {
306  return(_closeimage);
307  }
308  void closeicon(Fl_Image *val);
310  inline Fl_Image *usericon() const {
311  return(_userimage);
312  }
316  inline void usericon(Fl_Image *val) {
317  _userimage = val;
318  // Update deactivated version of icon..
319  if ( _userdeimage ) delete _userdeimage;
320  if ( _userimage ) {
321  _userdeimage = _userimage->copy();
322  _userdeimage->inactive();
323  } else {
324  _userdeimage = 0;
325  }
326  }
327 
330  inline Fl_Image *opendeicon() const {
331  return _opendeimage;
332  }
335  inline Fl_Image *closedeicon() const {
336  return _closedeimage;
337  }
340  inline Fl_Image *userdeicon() const {
341  return _userdeimage;
342  }
343 
345  // Options
348  inline char showcollapse() const {
349  return(_showcollapse);
350  }
359  inline void showcollapse(int val) {
360  _showcollapse = val;
361  }
363  inline Fl_Tree_Sort sortorder() const {
364  return(_sortorder);
365  }
370  inline void sortorder(Fl_Tree_Sort val) {
371  _sortorder = val;
372  }
374  inline Fl_Boxtype selectbox() const {
375  return(_selectbox);
376  }
378  inline void selectbox(Fl_Boxtype val) {
379  _selectbox = val;
380  }
382  inline int showroot() const {
383  return(int(_showroot));
384  }
389  inline void showroot(int val) {
390  _showroot = char(val);
391  }
393  inline Fl_Tree_Select selectmode() const {
394  return(_selectmode);
395  }
401  inline void selectmode(Fl_Tree_Select val) {
402  _selectmode = val;
403  }
406  return _itemreselectmode;
407  }
410  _itemreselectmode = mode;
411  }
414  return(_itemdrawmode);
415  }
422  _itemdrawmode = val;
423  }
424  void item_draw_callback(Fl_Tree_Item_Draw_Callback *cb, void *data=0) {
425  _itemdrawcallback = cb;
426  _itemdrawuserdata = data;
427  }
428  Fl_Tree_Item_Draw_Callback* item_draw_callback() const {
429  return(_itemdrawcallback);
430  }
431  void* item_draw_user_data() const {
432  return(_itemdrawuserdata);
433  }
434  void do_item_draw_callback(Fl_Tree_Item *o) const {
435  _itemdrawcallback(o, _itemdrawuserdata);
436  }
437 };
438 
439 #endif /*FL_TREE_PREFS_H*/
Fl_Image * closeicon() const
Gets the default &#39;close&#39; icon Returns the Fl_Image* of the icon, or 0 if none.
Definition: Fl_Tree_Prefs.H:305
Add items in ascending sort order.
Definition: Fl_Tree_Prefs.H:49
int widgetmarginleft() const
Get the widget()&#39;s left margin value in pixels.
Definition: Fl_Tree_Prefs.H:244
int linespacing() const
Get the line spacing value in pixels.
Definition: Fl_Tree_Prefs.H:252
Fl_Tree_Sort
Sort order options for items added to the tree.
Definition: Fl_Tree_Prefs.H:47
Fl_Tree_Connector connectorstyle() const
Get the connector style.
Definition: Fl_Tree_Prefs.H:272
void item_labelfont(Fl_Font val)
Set the label&#39;s font to val.
Definition: Fl_Tree_Prefs.H:147
Fl_Tree_Select selectmode() const
Get the selection mode used for the tree.
Definition: Fl_Tree_Prefs.H:393
Fl_Tree_Select
Tree selection style.
Definition: Fl_Tree_Prefs.H:65
Fl_Tree_Item_Draw_Mode item_draw_mode() const
Get the &#39;item draw mode&#39; used for the tree.
Definition: Fl_Tree_Prefs.H:413
void showroot(int val)
Set if the root item should be shown or not.
Definition: Fl_Tree_Prefs.H:389
Fl static class.
void selectmode(Fl_Tree_Select val)
Set the selection mode used for the tree to val.
Definition: Fl_Tree_Prefs.H:401
void labelbgcolor(Fl_Color val)
Obsolete: Set the default label background color. Please use item_labelbgcolor(Fl_Color) instead...
Definition: Fl_Tree_Prefs.H:188
Use solid lines connecting items.
Definition: Fl_Tree_Prefs.H:59
Fl_Color labelfgcolor() const
Obsolete: Get the default label foreground color. Please use item_labelfgcolor() instead.
Definition: Fl_Tree_Prefs.H:182
Fl_Font item_labelfont() const
Return the label&#39;s font.
Definition: Fl_Tree_Prefs.H:145
void usericonmarginleft(int val)
Set the user icon&#39;s left margin value in pixels.
Definition: Fl_Tree_Prefs.H:232
Use no lines connecting items.
Definition: Fl_Tree_Prefs.H:57
Enables FL_TREE_REASON_RESELECTED events for callbacks.
Definition: Fl_Tree_Prefs.H:80
Base class for image caching, scaling and drawing.
Definition: Fl_Image.H:62
Fl_Boxtype selectbox() const
Get the default selection box&#39;s box drawing style as an Fl_Boxtype.
Definition: Fl_Tree_Prefs.H:374
int showroot() const
Returns 1 if the root item is to be shown, or 0 if not.
Definition: Fl_Tree_Prefs.H:382
void item_draw_mode(Fl_Tree_Item_Draw_Mode val)
Set the &#39;item draw mode&#39; used for the tree to val.
Definition: Fl_Tree_Prefs.H:421
void labelfont(Fl_Font val)
Obsolete: Set the label&#39;s font to val. Please use item_labelfont(Fl_Font) instead.
Definition: Fl_Tree_Prefs.H:176
void connectorcolor(Fl_Color val)
Set the connector color used for tree connection lines.
Definition: Fl_Tree_Prefs.H:268
Fl_Color item_labelbgcolor() const
Get the default label background color.
Definition: Fl_Tree_Prefs.H:160
void showcollapse(int val)
Set if we should show the collapse icon or not.
Definition: Fl_Tree_Prefs.H:359
Fl_Fontsize item_labelsize() const
Return the label&#39;s size in pixels.
Definition: Fl_Tree_Prefs.H:149
void labelfgcolor(Fl_Color val)
Obsolete: Set the default label foreground color. Please use item_labelfgcolor(Fl_Color) instead...
Definition: Fl_Tree_Prefs.H:184
Fl_Boxtype
FLTK standard box types.
Definition: Enumerations.H:598
int openchild_marginbottom() const
Get the margin below an open child in pixels.
Definition: Fl_Tree_Prefs.H:220
Multiple items can be selected by clicking with SHIFT, CTRL or mouse drags.
Definition: Fl_Tree_Prefs.H:68
If widget() defined, widget()&#39;s height controls item&#39;s height.
Definition: Fl_Tree_Prefs.H:91
Fl_Image * usericon() const
Gets the default &#39;user icon&#39; (default is 0)
Definition: Fl_Tree_Prefs.H:310
Item can only be selected once (default)
Definition: Fl_Tree_Prefs.H:79
Fl_Image * userdeicon() const
Return the deactivated version of the user icon, if any.
Definition: Fl_Tree_Prefs.H:340
void connectorwidth(int val)
Set the tree connection line&#39;s width.
Definition: Fl_Tree_Prefs.H:288
void item_labelbgcolor(Fl_Color val)
Set the default label background color.
Definition: Fl_Tree_Prefs.H:166
char showcollapse() const
Returns 1 if the collapse icon is enabled, 0 if not.
Definition: Fl_Tree_Prefs.H:348
void inactive()
The inactive() method calls color_average(FL_BACKGROUND_COLOR, 0.33f) to produce an image that appear...
Definition: Fl_Image.H:227
void sortorder(Fl_Tree_Sort val)
Set the default sort order value.
Definition: Fl_Tree_Prefs.H:370
void item_labelfgcolor(Fl_Color val)
Set the default label foreground color.
Definition: Fl_Tree_Prefs.H:155
Fl_Tree_Item_Reselect_Mode item_reselect_mode() const
Returns the current item re/selection mode.
Definition: Fl_Tree_Prefs.H:405
void item_labelsize(Fl_Fontsize val)
Set the label&#39;s size in pixels to val.
Definition: Fl_Tree_Prefs.H:151
void connectorstyle(Fl_Tree_Connector val)
Set the connector style.
Definition: Fl_Tree_Prefs.H:276
void connectorstyle(int val)
Set the connector style [integer].
Definition: Fl_Tree_Prefs.H:280
Fl_Color labelbgcolor() const
Obsolete: Get the default label background color. Please use item_labelbgcolor() instead.
Definition: Fl_Tree_Prefs.H:186
int margintop() const
Get the top margin&#39;s value in pixels.
Definition: Fl_Tree_Prefs.H:202
void widgetmarginleft(int val)
Set the widget&#39;s left margin value in pixels.
Definition: Fl_Tree_Prefs.H:248
int marginleft() const
Get the left margin&#39;s value in pixels.
Definition: Fl_Tree_Prefs.H:194
Fl_Tree_Connector
Defines the style of connection lines between items.
Definition: Fl_Tree_Prefs.H:56
void labelsize(Fl_Fontsize val)
Obsolete: Set the label&#39;s size in pixels to val. Please use item_labelsize(Fl_Fontsize) instead...
Definition: Fl_Tree_Prefs.H:180
int Fl_Fontsize
Size of a font in pixels.
Definition: Enumerations.H:1014
void marginleft(int val)
Set the left margin&#39;s value in pixels.
Definition: Fl_Tree_Prefs.H:198
Nothing selected when items are clicked.
Definition: Fl_Tree_Prefs.H:66
Fl_Image * closedeicon() const
Return the deactivated version of the close icon, if any.
Definition: Fl_Tree_Prefs.H:335
If widget() defined, include label to the left of the widget.
Definition: Fl_Tree_Prefs.H:90
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition: Enumerations.H:1042
Fl_Color connectorcolor() const
Get the connector color used for tree connection lines.
Definition: Fl_Tree_Prefs.H:264
void labelmarginleft(int val)
Set the label&#39;s left margin value in pixels.
Definition: Fl_Tree_Prefs.H:240
Fl_Tree_Item_Draw_Mode
Bit flags that control how item&#39;s labels and widget()s are drawn in the tree via item_draw_mode().
Definition: Fl_Tree_Prefs.H:87
Tree widget item.
Definition: Fl_Tree_Item.H:65
int Fl_Font
A font number is an index into the internal font table.
Definition: Enumerations.H:985
Add items in descending sort order.
Definition: Fl_Tree_Prefs.H:50
Fl_Tree_Item_Reselect_Mode
Defines the ways an item can be (re) selected via item_reselect_mode().
Definition: Fl_Tree_Prefs.H:78
void linespacing(int val)
Set the line spacing value in pixels.
Definition: Fl_Tree_Prefs.H:256
Fl_Font labelfont() const
Obsolete: Return the label&#39;s font. Please use item_labelfont() instead.
Definition: Fl_Tree_Prefs.H:174
Fl_Image * opendeicon() const
Return the deactivated version of the open icon, if any.
Definition: Fl_Tree_Prefs.H:330
void usericon(Fl_Image *val)
Sets the default &#39;user icon&#39; Returns the Fl_Image* of the icon, or 0 if none (default).
Definition: Fl_Tree_Prefs.H:316
Use dotted lines connecting items (default)
Definition: Fl_Tree_Prefs.H:58
int labelmarginleft() const
Get the label&#39;s left margin value in pixels.
Definition: Fl_Tree_Prefs.H:236
Fl_Fontsize labelsize() const
Obsolete: Return the label&#39;s size in pixels. Please use item_labelsize() instead. ...
Definition: Fl_Tree_Prefs.H:178
void marginbottom(int val)
Set the bottom margin&#39;s value in pixels This is the extra distance the vertical scroller lets you tra...
Definition: Fl_Tree_Prefs.H:216
Tree widget&#39;s preferences.
Definition: Fl_Tree_Prefs.H:105
int connectorwidth() const
Get the tree connection line&#39;s width.
Definition: Fl_Tree_Prefs.H:284
void margintop(int val)
Set the top margin&#39;s value in pixels.
Definition: Fl_Tree_Prefs.H:206
virtual Fl_Image * copy(int W, int H)
Creates a resized copy of the specified image.
Definition: Fl_Image.cxx:84
void selectbox(Fl_Boxtype val)
Set the default selection box&#39;s box drawing style to val.
Definition: Fl_Tree_Prefs.H:378
int marginbottom() const
Get the bottom margin&#39;s value in pixels.
Definition: Fl_Tree_Prefs.H:211
Fl_Tree_Sort sortorder() const
Get the default sort order value.
Definition: Fl_Tree_Prefs.H:363
Fl_Color item_labelfgcolor() const
Get the default label foreground color.
Definition: Fl_Tree_Prefs.H:153
Fl_Image * openicon() const
Get the current default &#39;open&#39; icon.
Definition: Fl_Tree_Prefs.H:298
If widget() defined, draw in place of label, and widget() tracks item height (default) ...
Definition: Fl_Tree_Prefs.H:88
void openchild_marginbottom(int val)
Set the margin below an open child in pixels.
Definition: Fl_Tree_Prefs.H:224
Single item selected when item is clicked (default)
Definition: Fl_Tree_Prefs.H:67
No sorting; items are added in the order defined (default).
Definition: Fl_Tree_Prefs.H:48
int usericonmarginleft() const
Get the user icon&#39;s left margin value in pixels.
Definition: Fl_Tree_Prefs.H:228
void item_reselect_mode(Fl_Tree_Item_Reselect_Mode mode)
Sets the item re/selection mode.
Definition: Fl_Tree_Prefs.H:409
Single items may be selected, and they may be reordered by mouse drag.
Definition: Fl_Tree_Prefs.H:70