1 //
2 // "$Id$"
3 //
4 
5 #ifndef FL_TREE_H
6 #define FL_TREE_H
7 
8 #include <FL/Fl.H>
9 #include <FL/Fl_Group.H>
10 #include <FL/Fl_Scrollbar.H>
11 #include <FL/fl_draw.H>
12 
13 #include <FL/Fl_Tree_Item.H>
14 #include <FL/Fl_Tree_Prefs.H>
15 
16 //////////////////////
17 // FL/Fl_Tree.H
18 //////////////////////
19 //
20 // Fl_Tree -- This file is part of the Fl_Tree widget for FLTK
21 // Copyright (C) 2009-2010 by Greg Ercolano.
22 //
23 // This library is free software. Distribution and use rights are outlined in
24 // the file "COPYING" which should have been included with this file.  If this
25 // file is missing or damaged, see the license at:
26 //
27 //     http://www.fltk.org/COPYING.php
28 //
29 // Please report all bugs and problems on the following page:
30 //
31 //     http://www.fltk.org/str.php
32 //
33 
34 ///
35 /// \file
36 /// \brief This file contains the definitions of the Fl_Tree class
37 ///
38 
39 /// \class Fl_Tree
40 ///
41 /// \brief Tree widget.
42 ///
43 ///     \image html tree-simple.png "Fl_Tree example program"
44 ///     \image latex tree-simple.png "Fl_Tree example program" width=4cm
45 ///
46 /// \code
47 ///     Fl_Tree                                         // Top level widget
48 ///        |--- Fl_Tree_Item                            // Items in the tree
49 ///        |--- Fl_Tree_Prefs                           // Preferences for the tree
50 ///                  |--- Fl_Tree_Connector (enum)      // Connection modes
51 ///                  |--- Fl_Tree_Select (enum)         // Selection modes
52 ///                  |--- Fl_Tree_Sort (enum)           // Sort behavior
53 /// \endcode
54 ///     Similar to Fl_Browser, Fl_Tree is a browser of Fl_Tree_Item's arranged
55 ///     in a parented hierarchy, or 'tree'. Subtrees can be expanded or closed.
56 ///     Items can be added, deleted, inserted, sorted and re-ordered.
57 ///
58 ///     The tree items may also contain other FLTK widgets, like buttons, input fields,
59 ///     or even "custom" widgets.
60 ///
61 ///     The callback() is invoked depending on the value of when():
62 ///
63 ///         - FL_WHEN_RELEASE -- callback invoked when left mouse button is released on an item
64 ///         - FL_WHEN_CHANGED -- callback invoked when left mouse changes selection state
65 ///
66 ///     The simple way to define a tree:
67 /// \code
68 ///    #include <FL/Fl_Tree.H>
69 ///    [..]
70 ///    Fl_Tree tree(X,Y,W,H);
71 ///    tree.begin();
72 ///      tree.add("Flintstones/Fred");
73 ///      tree.add("Flintstones/Wilma");
74 ///      tree.add("Flintstones/Pebbles");
75 ///      tree.add("Simpsons/Homer");
76 ///      tree.add("Simpsons/Marge");
77 ///      tree.add("Simpsons/Bart");
78 ///      tree.add("Simpsons/Lisa");
79 ///    tree.end();
80 /// \endcode
81 ///
82 /// \par FEATURES
83 ///     Items can be added with add(),<BR>
84 ///     removed with remove(),<BR>
85 ///     completely cleared with clear(),<BR>
86 ///     inserted with insert() and insert_above(),<BR>
87 ///     selected/deselected with select() and deselect(),<BR>
88 ///     open/closed with open() and close(),<BR>
89 ///     positioned on the screen with show_item_top(), show_item_middle() and
90 ///     show_item_bottom(),<BR>
91 ///     item children can be swapped around with Fl_Tree_Item::swap_children(),<BR>
92 ///     sorting can be controlled when items are add()ed via sortorder().<BR>
93 ///     You can walk the entire tree with first() and next().<BR>
94 ///     You can walk visible items with first_visible_item()
95 ///     and next_visible_item().<BR>
96 ///     You can walk selected items with first_selected_item() and
97 ///     next_selected_item().<BR>
98 ///     Items can be found by their pathname using find_item(const char*),
99 ///     and an item's pathname can be found with item_pathname().<BR>
100 ///     The selected items' colors are controlled by selection_color()
101 ///     (inherited from Fl_Widget).<BR>
102 ///     A hook is provided to allow you to redefine how item's labels are drawn
103 ///     via Fl_Tree::item_draw_callback().<BR>
104 ///
105 /// \par SELECTION OF ITEMS
106 ///     The tree can have different selection behaviors controlled by selectmode().
107 ///     The background color used for selected items is the Fl_Tree::selection_color().
108 ///     The foreground color for selected items is controlled internally with fl_contrast().
109 ///
110 /// \par CHILD WIDGETS
111 ///     FLTK widgets (including custom widgets) can be assigned to tree items via
112 ///     Fl_Tree_Item::widget().
113 /// \par
114 ///     When an Fl_Tree_Item::widget() is defined, the default behavior is for the
115 ///     widget() to be shown in place of the item's label (if it has one).
116 ///     Only the widget()'s width will be used; the widget()'s x() and y() position
117 ///     will be managed by the tree, and the h() will track the item's height.
118 ///     This default behavior can be altered (ABI 1.3.1):
119 ///     Setting Fl_Tree::item_draw_mode()'s FL_TREE_ITEM_DRAW_LABEL_AND_WIDGET flag
120 ///     causes the label + widget to be displayed together in that order, and
121 ///     adding the FL_TREE_ITEM_HEIGHT_FROM_WIDGET flag causes widget's height
122 ///     to define the widget()'s height.
123 ///
124 /// \par ICONS
125 ///     The tree's open/close icons can be redefined with
126 ///     Fl_Tree::openicon(), Fl_Tree::closeicon(). User icons
127 ///     can either be changed globally with Fl_Tree::usericon(),
128 ///     or on a per-item basis with Fl_Tree_Item::usericon().
129 /// \par
130 ///     Various default preferences can be globally manipulated via Fl_Tree_Prefs,
131 ///     including colors, margins, icons, connection lines, etc.
132 ///
133 /// \par FONTS AND COLORS
134 ///     When adding new items to the tree, the new items get the
135 ///     defaults for fonts and colors from:
136 /// \par
137 ///	- Fl_Tree::item_labelfont() -- The default item label font (default: FL_HELVETICA)
138 ///     - Fl_Tree::item_labelsize() -- The default item label size (default: FL_NORMAL_SIZE)
139 ///     - Fl_Tree::item_labelfgcolor() -- The default item label foreground color (default: FL_FOREGROUND_COLOR)
140 ///     - Fl_Tree::item_labelbgcolor() -- The default item label background color (default: 0xffffffff, which tree uses as 'transparent')
141 /// \par
142 ///     Each item (Fl_Tree_Item) inherits a copy of these font/color attributes when created,
143 ///     and each item has its own methods to let the app change these values on a per-item basis
144 ///	using methods of the same name:
145 /// \par
146 ///	- Fl_Tree_Item::labelfont() -- The item's label font (default: FL_HELVETICA)
147 ///     - Fl_Tree_Item::labelsize() -- The item's label size (default: FL_NORMAL_SIZE)
148 ///     - Fl_Tree_Item::labelfgcolor() -- The item's label foreground color (default: FL_FOREGROUND_COLOR)
149 ///     - Fl_Tree_Item::labelbgcolor() -- The item's label background color (default: 0xffffffff, which uses the tree's own bg color)
150 ///
151 /// \par CALLBACKS
152 ///     The tree's callback() will be invoked when items change state or are open/closed.
153 ///     when() controls when mouse/keyboard events invoke the callback.
154 ///     callback_item() and callback_reason() can be used to determine the cause of the callback. e.g.
155 /// \par
156 /// \code
157 /// void MyTreeCallback(Fl_Widget *w, void *data) {
158 ///   Fl_Tree      *tree = (Fl_Tree*)w;
159 ///   Fl_Tree_Item *item = (Fl_Tree_Item*)tree->callback_item();	// get selected item
160 ///   switch ( tree->callback_reason() ) {
161 ///     case FL_TREE_REASON_SELECTED: [..]
162 ///     case FL_TREE_REASON_DESELECTED: [..]
163 ///     case FL_TREE_REASON_RESELECTED: [..]
164 ///     case FL_TREE_REASON_OPENED: [..]
165 ///     case FL_TREE_REASON_CLOSED: [..]
166 ///   }
167 /// \endcode
168 ///
169 /// \par SIMPLE EXAMPLES
170 ///     To find all the selected items:
171 /// \code
172 /// for ( Fl_Tree_Item *i=first_selected_item(); i; i=next_selected_item(i) )
173 ///   printf("Item %s is selected\n", i->label());
174 /// \endcode
175 ///     To get an item's full menu pathname, use Fl_Tree::item_pathname(), e.g.
176 /// \code
177 ///   char pathname[256] = "???";
178 ///   tree->item_pathname(pathname, sizeof(pathname), item);		// eg. "Parent/Child/Item"
179 /// \endcode
180 /// \par
181 ///     To walk all the items of the tree from top to bottom:
182 /// \code
183 /// // Walk all the items in the tree, and print their labels
184 /// for ( Fl_Tree_Item *item = tree->first(); item; item = tree->next(item) ) {
185 ///     printf("Item: %s\n", item->label());
186 /// }
187 /// \endcode
188 /// \par
189 ///     To recursively walk all the children of a particular item,
190 ///     define a function that uses recursion:
191 ///     \code
192 /// // Find all of the item's children and print an indented report of their labels
193 /// void my_print_all_children(Fl_Tree_Item *item, int indent=0) {
194 ///     for ( int t=0; t<item->children(); t++ ) {
195 ///         printf("%*s Item: %s\n", indent, "", item->child(t)->label());
196 ///         my_print_all_children(item->child(t), indent+4);   // recurse
197 ///     }
198 /// }
199 ///     \endcode
200 /// \par
201 ///     To change the default label font and color when creating new items:
202 /// \code
203 ///  tree = new Fl_Tree(..);
204 ///  tree->item_labelfont(FL_COURIER);	// Use Courier font for all new items
205 ///  tree->item_labelfgcolor(FL_RED);	// Use red color for labels of all new items
206 ///  [..]
207 ///  // Now create the items in the tree using the above defaults.
208 ///  tree->add("Aaa");
209 ///  tree->add("Bbb");
210 ///  [..]
211 /// \endcode
212 /// \par
213 ///     To change the font and color of all existing items in the tree:
214 /// \code
215 /// // Change the font and color of all items currently in the tree
216 /// for ( Fl_Tree_Item *item = tree->first(); item; item = tree->next(item) ) {
217 ///     item->labelfont(FL_COURIER);
218 ///     item->labelcolor(FL_RED);
219 /// }
220 /// \endcode
221 ///
222 /// \par DISPLAY DESCRIPTION
223 ///     The following image shows the tree's various visual elements
224 ///     and the methods that control them:
225 /// \par
226 ///     \image html tree-elements.png
227 ///     \image latex tree-elements.png "Fl_Tree elements" width=6cm
228 /// \par
229 ///     The following shows the protected dimension variables 'tree inner' (tix..)
230 ///     and 'tree outer' (tox..):
231 ///     \image html tree-dimensions.png "Fl_Tree inner/outer dimensions" width=6cm
232 ///     \image latex tree-dimensions.png "Fl_Tree inner/outer dimensions" width=6cm
233 ///
234 /// \par KEYBOARD BINDINGS
235 ///     The following table lists keyboard bindings for navigating the tree:
236 ///
237 ///  <TABLE BORDER="1" SUMMARY="Fl_Tree keyboard bindings.">
238 ///    <CAPTION ALIGN=TOP>Keyboard bindings.</CAPTION>
239 ///  <TR>
240 ///    <TD WIDTH=25% ALIGN=CENTER><B>Keyboard</B></TD>
241 ///    <TD WIDTH=25% ALIGN=CENTER><B>FL_TREE_SELECT_MULTI</B></TD>
242 ///    <TD WIDTH=25% ALIGN=CENTER><B>FL_TREE_SELECT_SINGLE</B></TD>
243 ///    <TD WIDTH=25% ALIGN=CENTER><B>FL_TREE_SELECT_NONE</B></TD>
244 ///
245 ///  </TR><TR>
246 ///    <TD ALIGN=CENTER><B>Ctrl-A</B> (Linux/Windows)<BR><B>Command-A</B> (Mac)</TD>
247 ///    <TD ALIGN=CENTER>Select all items.</TD>
248 ///    <TD ALIGN=CENTER>N/A</TD>
249 ///    <TD ALIGN=CENTER>N/A</TD>
250 ///
251 ///  </TR><TR>
252 ///    <TD ALIGN=CENTER><B>Space </B></TD>
253 ///    <TD ALIGN=CENTER>Selects item.</TD>
254 ///    <TD ALIGN=CENTER>Selects item.</TD>
255 ///    <TD ALIGN=CENTER>N/A</TD>
256 ///
257 ///  </TR><TR>
258 ///    <TD ALIGN=CENTER><B>Ctrl-Space </B></TD>
259 ///    <TD ALIGN=CENTER>Toggle item.</TD>
260 ///    <TD ALIGN=CENTER>Toggle item.</TD>
261 ///    <TD ALIGN=CENTER>N/A</TD>
262 ///
263 ///  </TR><TR>
264 ///    <TD ALIGN=CENTER><B>Shift-Space </B></TD>
265 ///    <TD ALIGN=CENTER>Extends selection<BR>from last item.</TD>
266 ///    <TD ALIGN=CENTER>Selects item.</TD>
267 ///    <TD ALIGN=CENTER>N/A</TD>
268 ///
269 ///  </TR><TR>
270 ///    <TD ALIGN=CENTER><B>Enter,<BR>Ctrl-Enter,<BR>Shift-Enter </B></TD>
271 ///    <TD ALIGN=CENTER>Toggles open/close</TD>
272 ///    <TD ALIGN=CENTER>Toggles open/close</TD>
273 ///    <TD ALIGN=CENTER>Toggles open/close</TD>
274 ///
275 ///  </TR><TR>
276 ///    <TD ALIGN=CENTER><B>Right / Left</B></TD>
277 ///    <TD ALIGN=CENTER>Open/Close item.</TD>
278 ///    <TD ALIGN=CENTER>Open/Close item.</TD>
279 ///    <TD ALIGN=CENTER>Open/Close item.</TD>
280 ///
281 ///  </TR><TR>
282 ///    <TD ALIGN=CENTER><B>Up / Down</B></TD>
283 ///    <TD ALIGN=CENTER>Move focus box up/down.</TD>
284 ///    <TD ALIGN=CENTER>Move focus box up/down.</TD>
285 ///    <TD ALIGN=CENTER>N/A</TD>
286 ///
287 ///  </TR><TR>
288 ///    <TD ALIGN=CENTER><B>Shift-Up / Shift-Down</B></TD>
289 ///    <TD ALIGN=CENTER>Extend selection up/down.</TD>
290 ///    <TD ALIGN=CENTER>Move focus up/down.</TD>
291 ///    <TD ALIGN=CENTER>N/A</TD>
292 ///
293 ///  </TR><TR>
294 ///    <TD ALIGN=CENTER><B>Home / End</B></TD>
295 ///    <TD ALIGN=CENTER>Move to top/bottom of tree.</TD>
296 ///    <TD ALIGN=CENTER>Move to top/bottom of tree.</TD>
297 ///    <TD ALIGN=CENTER>Move to top/bottom of tree.</TD>
298 ///
299 ///  </TR><TR>
300 ///    <TD ALIGN=CENTER><B>PageUp / PageDown</B></TD>
301 ///    <TD ALIGN=CENTER>Page up/down.</TD>
302 ///    <TD ALIGN=CENTER>Page up/down.</TD>
303 ///    <TD ALIGN=CENTER>Page up/down.</TD>
304 ///
305 ///  </TD></TR></TABLE>
306 ///
307 
308 /// \enum Fl_Tree_Reason
309 /// The reason the callback was invoked.
310 ///
311 enum Fl_Tree_Reason {
312   FL_TREE_REASON_NONE=0,	///< unknown reason
313   FL_TREE_REASON_SELECTED,	///< an item was selected
314   FL_TREE_REASON_DESELECTED,	///< an item was de-selected
315 #if FLTK_ABI_VERSION >= 10301
316   FL_TREE_REASON_RESELECTED,	///< an item was re-selected (e.g. double-clicked)
317 #endif /*FLTK_ABI_VERSION*/
318   FL_TREE_REASON_OPENED,	///< an item was opened
319   FL_TREE_REASON_CLOSED,	///< an item was closed
320   FL_TREE_REASON_DRAGGED	///< an item was dragged into a new place
321 };
322 
323 class FL_EXPORT Fl_Tree : public Fl_Group {
324   friend class Fl_Tree_Item;
325   Fl_Tree_Item  *_root;				// can be null!
326   Fl_Tree_Item  *_item_focus;			// item that has focus box
327   Fl_Tree_Item  *_callback_item;		// item invoked during callback (can be NULL)
328   Fl_Tree_Reason _callback_reason;		// reason for the callback
329   Fl_Tree_Prefs  _prefs;			// all the tree's settings
330   int            _scrollbar_size;		// size of scrollbar trough
331 #if FLTK_ABI_VERSION >= 10301
332   // NEW:
333   Fl_Tree_Item *_lastselect;			// used to extend selections
334 #else /*FLTK_ABI_VERSION*/
335   // OLD: static data inside handle() method
336 #endif /*FLTK_ABI_VERSION*/
337   void fix_scrollbar_order();
338 
339 protected:
340   Fl_Scrollbar *_vscroll;	///< Vertical scrollbar
341 #if FLTK_ABI_VERSION >= 10303
342   Fl_Scrollbar *_hscroll;	///< Horizontal scrollbar
343   int _tox,_toy,_tow,_toh;	///< Tree widget outer xywh dimension: outside scrollbars, inside widget border
344   int _tix,_tiy,_tiw,_tih;	///< Tree widget inner xywh dimension: inside borders + scrollbars
345 
346   /// the calculated width of the entire tree hierarchy. See calc_tree()
347   int _tree_w;
348   /// the calculated height of the entire tree hierarchy. See calc_tree()
349   int _tree_h;
350 #endif
351   void item_clicked(Fl_Tree_Item* val);
352   void do_callback_for_item(Fl_Tree_Item* item, Fl_Tree_Reason reason);
353 #if FLTK_ABI_VERSION >= 10303
354 // next_visible_item() and extend_selection() moved to 'public' in ABI 1.3.3
355 // undocmented draw_tree() dropped -- draw() does all the work now
356 #else
357   Fl_Tree_Item *next_visible_item(Fl_Tree_Item *start, int dir);
358   void extend_selection(Fl_Tree_Item *from, Fl_Tree_Item *to);
359   int draw_tree();
360 #endif
361 
362 public:
363   Fl_Tree(int X, int Y, int W, int H, const char *L=0);
364   ~Fl_Tree();
365   int handle(int e);
366   void draw();
367   void show_self();
368   void resize(int,int,int,int);
369 
370   ///////////////////////
371   // root methods
372   ///////////////////////
373   void root_label(const char *new_label);
374   Fl_Tree_Item* root();
375   void root(Fl_Tree_Item *newitem);
prefs()376   const Fl_Tree_Prefs& prefs() const { return _prefs; }
377 
378   ////////////////////////////////
379   // Item creation/removal methods
380   ////////////////////////////////
381 #if FLTK_ABI_VERSION >= 10303
382   Fl_Tree_Item *add(const char *path, Fl_Tree_Item *newitem=0);
383 #else
384   Fl_Tree_Item *add(const char *path);
385   Fl_Tree_Item *add(const char *path, Fl_Tree_Item *newitem);
386 #endif
387   Fl_Tree_Item* add(Fl_Tree_Item *parent_item, const char *name);
388   Fl_Tree_Item *insert_above(Fl_Tree_Item *above, const char *name);
389   Fl_Tree_Item* insert(Fl_Tree_Item *item, const char *name, int pos);
390   int remove(Fl_Tree_Item *item);
391   void clear();
392   void clear_children(Fl_Tree_Item *item);
393 
394   ////////////////////////
395   // Item lookup methods
396   ////////////////////////
397   Fl_Tree_Item *find_item(const char *path);
398   const Fl_Tree_Item *find_item(const char *path) const;
399   int item_pathname(char *pathname, int pathnamelen, const Fl_Tree_Item *item) const;
400 #if FLTK_ABI_VERSION >= 10303
401   const Fl_Tree_Item* find_clicked(int yonly=0) const;
402   Fl_Tree_Item* find_clicked(int yonly=0);
403 #else
404   const Fl_Tree_Item *find_clicked() const;
405   Fl_Tree_Item *find_clicked();
406 #endif
407   Fl_Tree_Item *item_clicked();
408   Fl_Tree_Item *first();
409   Fl_Tree_Item *first_visible();		// deprecated in ABI 10303
410   Fl_Tree_Item *first_visible_item();
411   Fl_Tree_Item *next(Fl_Tree_Item *item=0);
412   Fl_Tree_Item *prev(Fl_Tree_Item *item=0);
413   Fl_Tree_Item *last();
414   Fl_Tree_Item *last_visible();			// deprecated in ABI 10303
415   Fl_Tree_Item *last_visible_item();
416 #if FLTK_ABI_VERSION >= 10303
417   Fl_Tree_Item *next_visible_item(Fl_Tree_Item *start, int dir);	// made public in 1.3.3 ABI
418 #endif
419   Fl_Tree_Item *first_selected_item();
420   Fl_Tree_Item *last_selected_item();
421   Fl_Tree_Item *next_item(Fl_Tree_Item *item, int dir=FL_Down, bool visible=false);
422 #if FLTK_ABI_VERSION >= 10303
423   Fl_Tree_Item *next_selected_item(Fl_Tree_Item *item=0, int dir=FL_Down);
424   int get_selected_items(Fl_Tree_Item_Array &ret_items);
425 #else
426   Fl_Tree_Item *next_selected_item(Fl_Tree_Item *item=0);
427   Fl_Tree_Item *next_selected_item(Fl_Tree_Item *item, int dir);
428 #endif
429 
430   //////////////////////////
431   // Item open/close methods
432   //////////////////////////
433   int open(Fl_Tree_Item *item, int docallback=1);
434   int open(const char *path, int docallback=1);
435   void open_toggle(Fl_Tree_Item *item, int docallback=1);
436   int close(Fl_Tree_Item *item, int docallback=1);
437   int close(const char *path, int docallback=1);
438   int is_open(Fl_Tree_Item *item) const;
439   int is_open(const char *path) const;
440   int is_close(Fl_Tree_Item *item) const;
441   int is_close(const char *path) const;
442 
443   /////////////////////////
444   // Item selection methods
445   /////////////////////////
446   int select(Fl_Tree_Item *item, int docallback=1);
447   int select(const char *path, int docallback=1);
448   void select_toggle(Fl_Tree_Item *item, int docallback=1);
449   int deselect(Fl_Tree_Item *item, int docallback=1);
450   int deselect(const char *path, int docallback=1);
451   int deselect_all(Fl_Tree_Item *item=0, int docallback=1);
452   int select_only(Fl_Tree_Item *selitem, int docallback=1);
453   int select_all(Fl_Tree_Item *item=0, int docallback=1);
454   int extend_selection_dir(Fl_Tree_Item *from,
455                            Fl_Tree_Item *to,
456 			   int dir,
457 			   int val,
458 			   bool visible);
459 #if FLTK_ABI_VERSION >= 10303
460   int extend_selection(Fl_Tree_Item *from,
461   		       Fl_Tree_Item *to,
462 		       int val=1,
463 		       bool visible=false);
464 #else
465 private:
466   // Adding overload if not at least one overload breaks ABI, so avoid
467   // by keeping private until we can break ABI. ref: http://www.ros.org/reps/rep-0009.html
468   int extend_selection__(Fl_Tree_Item *from,
469   			 Fl_Tree_Item *to,
470 			 int val,
471 			 bool visible);
472 public:
473 #endif
474   void set_item_focus(Fl_Tree_Item *item);
475   Fl_Tree_Item *get_item_focus() const;
476   int is_selected(Fl_Tree_Item *item) const;
477   int is_selected(const char *path);
478 
479   /////////////////////////////////
480   // Item attribute related methods
481   /////////////////////////////////
482   Fl_Font     item_labelfont() const;
483   void        item_labelfont(Fl_Font val);
484   Fl_Fontsize item_labelsize() const;
485   void        item_labelsize(Fl_Fontsize val);
486   Fl_Color    item_labelfgcolor(void) const;
487   void        item_labelfgcolor(Fl_Color val);
488   Fl_Color    item_labelbgcolor(void) const;
489   void        item_labelbgcolor(Fl_Color val);
490   Fl_Color connectorcolor() const;
491   void connectorcolor(Fl_Color val);
492   int marginleft() const;
493   void marginleft(int val);
494   int margintop() const;
495   void margintop(int val);
496 #if FLTK_ABI_VERSION >= 10301
497   int marginbottom() const;
498   void marginbottom(int val);
499 #endif /*FLTK_ABI_VERSION*/
500   int linespacing() const;
501   void linespacing(int val);
502   int openchild_marginbottom() const;
503   void openchild_marginbottom(int val);
504   int usericonmarginleft() const;
505   void usericonmarginleft(int val);
506   int labelmarginleft() const;
507   void labelmarginleft(int val);
508 #if FLTK_ABI_VERSION >= 10301
509   int widgetmarginleft() const;
510   void widgetmarginleft(int val);
511 #endif /*FLTK_ABI_VERSION*/
512   int connectorwidth() const;
513   void connectorwidth(int val);
514   Fl_Image* usericon() const;
515   void usericon(Fl_Image *val);
516   Fl_Image* openicon() const;
517   void openicon(Fl_Image *val);
518   Fl_Image* closeicon() const;
519   void closeicon(Fl_Image *val);
520   int showcollapse() const;
521   void showcollapse(int val);
522   int showroot() const;
523   void showroot(int val);
524   Fl_Tree_Connector connectorstyle() const;
525   void connectorstyle(Fl_Tree_Connector val);
526   Fl_Tree_Sort sortorder() const;
527   void sortorder(Fl_Tree_Sort val);
528   Fl_Boxtype selectbox() const;
529   void selectbox(Fl_Boxtype val);
530   Fl_Tree_Select selectmode() const;
531   void selectmode(Fl_Tree_Select val);
532 #if FLTK_ABI_VERSION >= 10301
533   Fl_Tree_Item_Reselect_Mode item_reselect_mode() const;
534   void item_reselect_mode(Fl_Tree_Item_Reselect_Mode mode);
535   Fl_Tree_Item_Draw_Mode item_draw_mode() const;
536   void item_draw_mode(Fl_Tree_Item_Draw_Mode mode);
537   void item_draw_mode(int mode);
538 #endif
539 #if FLTK_ABI_VERSION >= 10303
540   void calc_dimensions();
541   void calc_tree();
542 #endif
543   void recalc_tree();
544   int displayed(Fl_Tree_Item *item);
545   void show_item(Fl_Tree_Item *item, int yoff);
546   void show_item(Fl_Tree_Item *item);
547   void show_item_top(Fl_Tree_Item *item);
548   void show_item_middle(Fl_Tree_Item *item);
549   void show_item_bottom(Fl_Tree_Item *item);
550   void display(Fl_Tree_Item *item);
551   int  vposition() const;
552   void vposition(int pos);
553   int  hposition() const;
554   void hposition(int pos);
555 
556   int is_scrollbar(Fl_Widget *w);
557   int scrollbar_size() const;
558   void scrollbar_size(int size);
559   int is_vscroll_visible() const;
560   int is_hscroll_visible() const;
561 
562   ///////////////////////
563   // callback related
564   ///////////////////////
565   void callback_item(Fl_Tree_Item* item);
566   Fl_Tree_Item* callback_item();
567   void callback_reason(Fl_Tree_Reason reason);
568   Fl_Tree_Reason callback_reason() const;
569 
570   /// Load FLTK preferences
571   void load(class Fl_Preferences&);
572 };
573 
574 #endif /*FL_TREE_H*/
575 
576 //
577 // End of "$Id$".
578 //
579