fltk  1.3.5-source
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X.
  Fossies Dox: fltk-1.3.5-source.tar.bz2  ("inofficial" and yet experimental doxygen-generated source code documentation)  

Fl_Tree.cxx
Go to the documentation of this file.
1 //
2 // "$Id$"
3 //
4 
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 
9 #include <FL/Fl_Tree.H>
10 #include <FL/Fl_Preferences.H>
11 
13 // Fl_Tree.cxx
15 //
16 // Fl_Tree -- This file is part of the Fl_Tree widget for FLTK
17 // Copyright (C) 2009-2010 by Greg Ercolano.
18 //
19 // This library is free software. Distribution and use rights are outlined in
20 // the file "COPYING" which should have been included with this file. If this
21 // file is missing or damaged, see the license at:
22 //
23 // http://www.fltk.org/COPYING.php
24 //
25 // Please report all bugs and problems on the following page:
26 //
27 // http://www.fltk.org/str.php
28 //
29 
30 // INTERNAL: scroller callback (hor+vert scroll)
31 static void scroll_cb(Fl_Widget*,void *data) {
32  ((Fl_Tree*)data)->redraw();
33 }
34 
35 // INTERNAL: Parse elements from 'path' into an array of null terminated strings
36 // Handles escape characters, ignores multiple /'s.
37 // Path="/aa/bb", returns arr[0]="aa", arr[1]="bb", arr[2]=0.
38 // Caller must call free_path(arr).
39 //
40 static char **parse_path(const char *path) {
41  size_t len = strlen(path);
42  char *cp = new char[(len+1)], *word = cp, *s = cp; // freed below or in free_path()
43  char **ap = new char*[(len+1)], **arr = ap; // overallocates arr[]
44  while (1) {
45  if (*path =='/' || *path == 0) { // handle path sep or eos
46  if (word != s) { *s++ = 0; *arr++= word; word = s; }
47  if ( !*path++) break; else continue; // eos? done, else cont
48  } else if ( *path == '\\' ) { // handle escape
49  if ( *(++path) ) { *s++ = *path++; } else continue;
50  } else { *s++ = *path++; } // handle normal char
51  }
52  *arr = 0;
53  if ( arr == ap ) delete[] cp; // empty arr[]? delete since free_path() can't
54  return ap;
55 }
56 
57 // INTERNAL: Free an array 'arr' returned by parse_path()
58 static void free_path(char **arr) {
59  if ( arr ) {
60  if ( arr[0] ) { delete[] arr[0]; } // deletes cp in parse_path
61  delete[] arr; // deletes ptr array
62  }
63 }
64 
65 #if 0 /* unused code -- STR #3169 */
66 // INTERNAL: Recursively descend 'item's tree hierarchy
67 // accumulating total child 'count'
68 //
69 static int find_total_children(Fl_Tree_Item *item, int count=0) {
70  count++;
71  for ( int t=0; t<item->children(); t++ ) {
72  count = find_total_children(item->child(t), count);
73  }
74  return(count);
75 }
76 #endif
77 
79 Fl_Tree::Fl_Tree(int X, int Y, int W, int H, const char *L) : Fl_Group(X,Y,W,H,L) {
80 #if FLTK_ABI_VERSION >= 10303
81  _root = new Fl_Tree_Item(this);
82 #else
83  _root = new Fl_Tree_Item(_prefs);
84 #endif
85  _root->parent(0); // we are root of tree
86  _root->label("ROOT");
87  _item_focus = 0;
88  _callback_item = 0;
90  _scrollbar_size = 0; // 0: uses Fl::scrollbar_size()
91 
92 #if FLTK_ABI_VERSION >= 10301
93  // NEW
94  _lastselect = 0;
95 #else /*FLTK_ABI_VERSION*/
96  // OLD: data initialized static inside handle()
97 #endif /*FLTK_ABI_VERSION*/
98 
102  int scrollsize = _scrollbar_size ? _scrollbar_size : Fl::scrollbar_size();
103  _vscroll = new Fl_Scrollbar(X+W-scrollsize,Y,scrollsize,H);
104  _vscroll->hide();
106  _vscroll->step(1);
107  _vscroll->callback(scroll_cb, (void*)this);
108 #if FLTK_ABI_VERSION >= 10303
109  _hscroll = new Fl_Scrollbar(X,Y+H-scrollsize,W,scrollsize);
110  _hscroll->hide();
111  _hscroll->type(FL_HORIZONTAL);
112  _hscroll->step(1);
113  _hscroll->callback(scroll_cb, (void*)this);
114  _tox = _tix = X + Fl::box_dx(box());
115  _toy = _tiy = Y + Fl::box_dy(box());
116  _tow = _tiw = W - Fl::box_dw(box());
117  _toh = _tih = H - Fl::box_dh(box());
118  _tree_w = -1;
119  _tree_h = -1;
120 #endif
121  end();
122 }
123 
126  if ( _root ) { delete _root; _root = 0; }
127 }
128 
134 #if FLTK_ABI_VERSION >= 10303
135 #endif
153  int dir, int val, bool visible ) {
154  int changed = 0;
155  for (Fl_Tree_Item *item=from; item; item = next_item(item, dir, visible) ) {
156  switch (val) {
157  case 0:
158  if ( deselect(item, when()) ) ++changed;
159  break;
160  case 1:
161  if ( select(item, when()) ) ++changed;
162  break;
163  case 2:
164  select_toggle(item, when());
165  ++changed; // toggle always involves a change
166  break;
167  }
168  if ( item==to ) break;
169  }
170  return(changed);
171 }
172 
190 #if FLTK_ABI_VERSION >= 10303
193  int val, bool visible) {
194 #else
195 // Adding overload if not at least one overload breaks ABI, so avoid
197 // by making a private function until ABI can change..
199  int val, bool visible) {
200 #endif
201  int changed = 0;
202  if ( from == to ) {
203  if ( visible && !from->is_visible() ) return(0); // do nothing
204  switch (val) {
205  case 0:
206  if ( deselect(from, when()) ) ++changed;
207  break;
208  case 1:
209  if ( select(from, when()) ) ++changed;
210  break;
211  case 2:
212  select_toggle(from, when());
213  ++changed; // always changed
214  break;
215  }
216  return(changed);
217  }
218  char on = 0;
219  for ( Fl_Tree_Item *item = first(); item; item = item->next_visible(_prefs) ) {
220  if ( visible && !item->is_visible() ) continue;
221  if ( on || (item == from) || (item == to) ) {
222  switch (val) {
223  case 0:
224  if ( deselect(item, when()) ) ++changed;
225  break;
226  case 1:
227  if ( select(item, when()) ) ++changed;
228  break;
229  case 2:
230  select_toggle(item, when());
231  ++changed; // toggle always involves a change
232  break;
233  }
234  if ( (item == from) || (item == to) ) {
235  on ^= 1;
236  if ( !on ) break; // done
237  }
238  }
239  }
240  return(changed);
241 }
242 
243 #if FLTK_ABI_VERSION >= 10303
244 // not needed, above overload handles this
245 #else
252  const int val = 1; // 0=clr, 1=set, 2=toggle
253  const bool visible = false; // true=only 'open' items, false='open' or 'closed'
254  extend_selection__(from, to, val, visible); // use private method until we can release it
255 }
256 #endif
257 
260 int Fl_Tree::handle(int e) {
261  if (e == FL_NO_EVENT) return(0); // XXX: optimize to prevent slow resizes on large trees!
262  int ret = 0;
263  char is_shift = Fl::event_state() & FL_SHIFT ? 1 : 0;
264  char is_ctrl = Fl::event_state() & FL_CTRL ? 1 : 0;
265  char is_command = Fl::event_state() & FL_COMMAND ? 1 : 0; // ctrl on win/lin, 'Command' on mac
266 #if FLTK_ABI_VERSION >= 10301
267  // NEW: data inside Fl_Tree
268 #else /*FLTK_ABI_VERSION*/
269  // OLD:
270  static Fl_Tree_Item *_lastselect = 0; // used to extend selections
271 #endif /*FLTK_ABI_VERSION*/
272  // Developer note: Fl_Browser_::handle() used for reference here..
273  // #include <FL/names.h> // for event debugging
274  // fprintf(stderr, "DEBUG: %s (%d)\n", fl_eventnames[e], e);
275 
276  if (e == FL_ENTER || e == FL_LEAVE) return(1);
277  switch (e) {
278  case FL_FOCUS: {
279  // FLTK tests if we want focus.
280  // If a nav key was used to give us focus, and we've got no saved
281  // focus widget, determine which item gets focus depending on nav key.
282  //
283  if ( ! _item_focus ) { // no focus established yet?
284  switch (Fl::event_key()) { // determine if focus was navigated..
285  case FL_Tab: { // received focus via TAB?
286  int updown = is_shift ? FL_Up : FL_Down; // SHIFT-TAB similar to Up, TAB similar to Down
287  set_item_focus(next_visible_item(0, updown));
288  break;
289  }
290  case FL_Left: // received focus via LEFT or UP?
291  case FL_Up: { // XK_ISO_Left_Tab
293  break;
294  }
295  case FL_Right: // received focus via RIGHT or DOWN?
296  case FL_Down:
297  default: {
299  break;
300  }
301  }
302  }
303  if ( visible_focus() ) redraw(); // draw focus change
304  return(1);
305  }
306  case FL_UNFOCUS: { // FLTK telling us some other widget took focus.
307  if ( visible_focus() ) redraw(); // draw focus change
308  return(1);
309  }
310  case FL_KEYBOARD: { // keyboard shortcut
311  // Do shortcuts first or scrollbar will get them...
312  if ( (Fl::focus() == this) && // tree has focus?
313  _prefs.selectmode() > FL_TREE_SELECT_NONE ) { // select mode that supports kb events?
314  if ( !_item_focus ) { // no current focus item?
315  set_item_focus(first_visible_item()); // use first vis item
316  if ( Fl::event_key() == FL_Up || // Up or down?
317  Fl::event_key() == FL_Down ) // ..if so, already did 'motion'
318  return(1); // ..so just return.
319  }
320  if ( _item_focus ) {
321  int ekey = Fl::event_key();
322  switch (ekey) {
323  case FL_Enter: // ENTER: toggle open/close
324  case FL_KP_Enter: {
325  open_toggle(_item_focus, when()); // toggle item in focus
326  return(1); // done, we handled key
327  }
328  case ' ': // SPACE: change selection state
329  switch ( _prefs.selectmode() ) {
330  case FL_TREE_SELECT_NONE:
331  break; // ignore, let group have shot at event
334  if ( is_ctrl ) { // CTRL-SPACE: (single mode) toggle
335  if ( ! _item_focus->is_selected() ) {
337  } else {
338  deselect_all(0, when());
339  }
340  } else {
341  select_only(_item_focus, when()); // SPACE: (single mode) select only
342  }
343  _lastselect = _item_focus;
344  return(1); // done, we handled key
346  if ( is_ctrl ) {
347  select_toggle(_item_focus, when()); // CTRL-SPACE: (multi mode) toggle selection
348  } else {
349  select(_item_focus, when()); // SPACE: (multi-mode) select
350  }
351  _lastselect = _item_focus;
352  return(1); // done, we handled key
353  }
354  break;
355  case FL_Right: // RIGHT: open children (if any)
356  case FL_Left: { // LEFT: close children (if any)
357  if ( _item_focus ) {
358  if ( ekey == FL_Right && _item_focus->is_close() ) {
359  open(_item_focus); // open closed item
360  ret = 1;
361  } else if ( ekey == FL_Left && _item_focus->is_open() ) {
362  close(_item_focus); // close open item
363  ret = 1;
364  }
365  return(1);
366  }
367  break;
368  }
369  case FL_Up: // UP: next item up, or extend selection up
370  case FL_Down: { // DOWN: next item down, or extend selection down
371  set_item_focus(next_visible_item(_item_focus, ekey)); // next item up|dn
372  if ( _item_focus ) { // item in focus?
373  // Autoscroll
374  int itemtop = _item_focus->y();
375  int itembot = _item_focus->y()+_item_focus->h();
376  if ( itemtop < y() ) { show_item_top(_item_focus); }
377  if ( itembot > y()+h() ) { show_item_bottom(_item_focus); }
378  // Extend selection
379  if ( _prefs.selectmode() == FL_TREE_SELECT_MULTI && // multiselect on?
380  is_shift && // shift key?
381  ! _item_focus->is_selected() ) { // not already selected?
382  select(_item_focus, when()); // extend selection..
383  _lastselect = _item_focus;
384  }
385  return(1);
386  }
387  break;
388  }
389  case 'a':
390  case 'A': {
391  if ( is_command ) { // ^A (win/linux), Meta-A (mac)
392  switch ( _prefs.selectmode() ) {
393  case FL_TREE_SELECT_NONE:
396  break;
398  // Do a 'select all'
399  select_all();
400  _lastselect = first_visible_item();
401  take_focus();
402  return(1);
403  }
404  }
405  break;
406  }
407  }
408  }
409  }
410  break;
411  }
412  }
413 
414  // Let Fl_Group take a shot at handling the event
415  if (Fl_Group::handle(e)) {
416  return(1); // handled? don't continue below
417  }
418 
419  // Handle events the child FLTK widgets didn't need
420 
421  // fprintf(stderr, "Fl_Tree::handle(): Event was %s (%d)\n", fl_eventnames[e], e); // DEBUGGING
422  if ( ! _root ) return(ret);
423  static int last_my = 0;
424  switch ( e ) {
425  case FL_PUSH: { // clicked on tree
426  last_my = Fl::event_y(); // save for dragging direction..
427  if (Fl::visible_focus() && handle(FL_FOCUS)) Fl::focus(this);
428 #if FLTK_ABI_VERSION >= 10303
429  Fl_Tree_Item *item = _root->find_clicked(_prefs, 0);
430 #else
432 #endif
433  if ( !item ) { // clicked, but not on an item?
434  _lastselect = 0;
435  switch ( _prefs.selectmode() ) {
436  case FL_TREE_SELECT_NONE:
437  break;
441  deselect_all();
442  break;
443  }
444  break;
445  }
446  set_item_focus(item); // becomes new focus widget, calls redraw() if needed
447  ret |= 1; // handled
448  if ( Fl::event_button() == FL_LEFT_MOUSE ) {
449  if ( item->event_on_collapse_icon(_prefs) ) { // collapse icon clicked?
450  open_toggle(item); // toggle open (handles redraw)
451  } else if ( item->event_on_label(_prefs) && // label clicked?
452  (!item->widget() || !Fl::event_inside(item->widget())) ) { // not inside widget
453  switch ( _prefs.selectmode() ) {
454  case FL_TREE_SELECT_NONE:
455  break;
458  select_only(item, when()); // select only this item (handles redraw)
459  _lastselect = item;
460  break;
461  case FL_TREE_SELECT_MULTI: {
462  if ( is_shift ) { // SHIFT+PUSH?
463  if ( _lastselect ) {
464  int val = is_ctrl ? 2 : 1;
465  bool visible = true;
466 #if FLTK_ABI_VERSION >= 10303
467  extend_selection(_lastselect, item, val, visible);
468 #else
469  extend_selection__(_lastselect, item, val, visible);
470 #endif
471  } else {
472  select(item); // add to selection
473  }
474  } else if ( is_ctrl ) { // CTRL+PUSH?
475  select_toggle(item, when()); // toggle selection state
476  } else {
477  select_only(item, when());
478  }
479  _lastselect = item;
480  break;
481  }
482  }
483  }
484  }
485  break;
486  }
487  case FL_DRAG: {
488  // Do scrolling first..
489 
490  // Detect up/down dragging
491  int my = Fl::event_y();
492  int dir = (my>last_my) ? FL_Down : FL_Up;
493  last_my = my;
494 
495  // Handle autoscrolling
496  if ( my < y() ) { // Above top?
497  dir = FL_Up; // ..going up
498  int p = vposition()-(y()-my); // ..position above us
499  if ( p < 0 ) p = 0; // ..don't go above 0
500  vposition(p); // ..scroll to new position
501  } else if ( my > (y()+h()) ) { // Below bottom?
502  dir = FL_Down; // ..going down
503  int p = vposition()+(my-y()-h()); // ..position below us
504  if ( p > (int)_vscroll->maximum() ) // ..don't go below bottom
505  p = (int)_vscroll->maximum();
506  vposition(p); // ..scroll to new position
507  }
508 
509  // Now handle the event..
510  // During drag, only interested in left-mouse operations.
511  //
512  if ( Fl::event_button() != FL_LEFT_MOUSE ) break;
513 #if FLTK_ABI_VERSION >= 10303
514  Fl_Tree_Item *item = _root->find_clicked(_prefs, 1); // item we're on, vertically
515 #else
516  Fl_Tree_Item *item = _root->find_clicked(_prefs); // item we're on, vertically
517 #endif
518  if ( !item ) break; // not near item? ignore drag event
519  ret |= 1; // acknowledge event
521  set_item_focus(item); // becomes new focus item
522  if (item==_lastselect) break; // same item as before? avoid reselect
523 
524  // Handle selection behavior
525  switch ( _prefs.selectmode() ) {
526  case FL_TREE_SELECT_NONE:
527  break; // no selection changes
528  case FL_TREE_SELECT_SINGLE: {
529  select_only(item, when()); // select only this item (handles redraw)
530  break;
531  }
533  item = _lastselect; // Keep the source intact
534  redraw();
535  break;
536  }
537  case FL_TREE_SELECT_MULTI: {
538  Fl_Tree_Item *from = next_visible_item(_lastselect, dir); // avoid reselecting item
539  Fl_Tree_Item *to = item;
540  int val = is_ctrl ? 2 : 1; // toggle_select() or just select()?
541  bool visible = true;
542  extend_selection_dir(from, to, dir, val, visible);
543  break;
544  }
545  }
546  _lastselect = item; // save current item for later
547  break;
548  }
549  case FL_RELEASE:
552 #if FLTK_ABI_VERSION >= 10303
553  Fl_Tree_Item *item = _root->find_clicked(_prefs, 1); // item we're on, vertically
554 #else
555  Fl_Tree_Item *item = _root->find_clicked(_prefs); // item we're on, vertically
556 #endif
557 
558  if (item && _lastselect && item != _lastselect &&
559  Fl::event_x() >= item->label_x()) {
560  //printf("Would drag '%s' to '%s'\n", _lastselect->label(), item->label());
561  // Are we dropping above or below the target item?
562  const int h = Fl::event_y() - item->y();
563  const int mid = item->h() / 2;
564  const bool before = h < mid;
565  //printf("Dropping %s it\n", before ? "before" : "after");
566 
567  // Do nothing if it would be a no-op
568  if ((before && prev(item) != _lastselect) ||
569  (!before && next(item) != _lastselect)) {
570  Fl_Tree_Item *parent = item->parent();
571 
572  if (parent) {
573  int pos = parent->find_child(item);
574  if (!before)
575  pos++;
576 
577  // Special case: trying to drop right before a folder
578  if (item->children() && item->is_open() && !before) {
579  parent = item;
580  pos = 0;
581  }
582 
583  // If we're moving inside the same parent, use the below/above methods
584  if (_lastselect->parent() == parent) {
585  if (before) {
586  _lastselect->move_above(item);
587  } else {
588  _lastselect->move_below(item);
589  }
590  } else {
591  _lastselect->move_into(parent, pos);
592  }
593 
594  redraw();
596  }
597  }
598  }
599  redraw();
600  } // End single-drag check
601  ret |= 1;
602  break;
603  }
604  return(ret);
605 }
606 
607 #if FLTK_ABI_VERSION >= 10303
608 // nothing
609 #else
610 // Redraw timeout callback
611 // (Only need this hack for old ABI 10302 and older)
612 //
613 static void redraw_soon(void *data) {
614  ((Fl_Tree*)data)->redraw();
616 }
617 #endif
618 
619 #if FLTK_ABI_VERSION >= 10303
620 void Fl_Tree::calc_dimensions() {
637  // Calc tree outer xywh
638  // Area of the tree widget /outside/ scrollbars
639  //
640  _tox = x() + Fl::box_dx(box());
641  _toy = y() + Fl::box_dy(box());
642  _tow = w() - Fl::box_dw(box());
643  _toh = h() - Fl::box_dh(box());
644 
645  // Scrollbar visiblity + positions
646  // Calc this ONLY if tree_h and tree_w have been calculated.
647  // Zero values for these indicate calc in progress, but not done yet.
648  //
649  if ( _tree_h >= 0 && _tree_w >= 0 ) {
650  int scrollsize = _scrollbar_size ? _scrollbar_size : Fl::scrollbar_size();
651  int vshow = _tree_h > _toh ? 1 : 0;
652  int hshow = _tree_w > _tow ? 1 : 0;
653  // See if one scroller's appearance affects the other's visibility
654  if ( hshow && !vshow && (_tree_h > (_toh-scrollsize)) ) vshow = 1;
655  if ( vshow && !hshow && (_tree_w > (_tow-scrollsize)) ) hshow = 1;
656  // vertical scrollbar visibility
657  if ( vshow ) {
658  _vscroll->show();
659  _vscroll->resize(_tox+_tow-scrollsize, _toy,
660  scrollsize, h()-Fl::box_dh(box()) - (hshow ? scrollsize : 0));
661  } else {
662  _vscroll->hide();
663  _vscroll->value(0);
664  }
665  // horizontal scrollbar visibility
666  if ( hshow ) {
667  _hscroll->show();
668  _hscroll->resize(_tox, _toy+_toh-scrollsize,
669  _tow - (vshow ? scrollsize : 0), scrollsize);
670  } else {
671  _hscroll->hide();
672  _hscroll->value(0);
673  }
674 
675  // Calculate inner dimensions
676  // The area the tree occupies inside the scrollbars and margins
677  //
678  _tix = _tox;
679  _tiy = _toy;
680  _tiw = _tow - (_vscroll->visible() ? _vscroll->w() : 0);
681  _tih = _toh - (_hscroll->visible() ? _hscroll->h() : 0);
682 
683  // Scrollbar tab sizes
684  _vscroll->slider_size(float(_tih) / float(_tree_h));
685  _vscroll->range(0.0, _tree_h - _tih);
686 
687  _hscroll->slider_size(float(_tiw) / float(_tree_w));
688  _hscroll->range(0.0, _tree_w - _tiw);
689  } else {
690  // Best we can do without knowing tree_h/tree_w
691  _tix = _tox;
692  _tiy = _toy;
693  _tiw = _tow;
694  _tih = _toh;
695  }
696 }
697 
731 void Fl_Tree::calc_tree() {
732  // Set tree width and height to zero, and recalc just _tox/_toy/_tow/_toh for now.
733  _tree_w = _tree_h = -1;
734  calc_dimensions();
735  if ( !_root ) return;
736  // Walk the tree to determine its width and height.
737  // We need this to compute scrollbars..
738  // By the end, 'Y' will be the lowest point on the tree
739  //
740  int X = _tix + _prefs.marginleft() + _hscroll->value();
741  int Y = _tiy + _prefs.margintop() - _vscroll->value();
742  int W = _tiw;
743  // Adjust root's X/W if connectors off
745  X -= _prefs.openicon()->w();
746  W += _prefs.openicon()->w();
747  }
748  int xmax = 0, render = 0, ytop = Y;
750  _root->draw(X, Y, W, 0, xmax, 1, render); // descend into tree without drawing (render=0)
751  // Save computed tree width and height
752  _tree_w = _prefs.marginleft() + xmax - X; // include margin in tree's width
753  _tree_h = _prefs.margintop() + Y - ytop; // include margin in tree's height
754  // Calc tree dims again; now that tree_w/tree_h are known, scrollbars are calculated.
755  calc_dimensions();
756 }
757 #endif
758 
759 void Fl_Tree::resize(int X,int Y,int W, int H) {
761  Fl_Group::resize(X,Y,W,H);
762 #if FLTK_ABI_VERSION >= 10303
763  calc_dimensions();
764 #endif
765  init_sizes();
766 }
767 
768 #if FLTK_ABI_VERSION >= 10303
769 void Fl_Tree::draw() {
772  // Has tree recalc been scheduled? If so, do it
773  if ( _tree_w == -1 ) calc_tree();
774  else calc_dimensions();
775  // Let group draw box+label but *NOT* children.
776  // We handle drawing children ourselves by calling each item's draw()
777  {
778  // Draw group's bg + label
779  if ( damage() & ~FL_DAMAGE_CHILD) { // redraw entire widget?
782  }
783  if ( ! _root ) return;
784  // These values are changed during drawing
785  // By end, 'Y' will be the lowest point on the tree
786  int X = _tix + _prefs.marginleft() - _hscroll->value();
787  int Y = _tiy + _prefs.margintop() - _vscroll->value();
788  int W = _tiw - X + _tix;
789  // Adjust root's X/W if connectors off
791  X -= _prefs.openicon()->w();
792  W += _prefs.openicon()->w();
793  }
794  // Draw entire tree, starting with root
795  fl_push_clip(_tix,_tiy,_tiw,_tih);
796  {
797  int xmax = 0;
799  _root->draw(X, Y, W, // descend into tree here to draw it
800  (Fl::focus()==this)?_item_focus:0, // show focus item ONLY if Fl_Tree has focus
801  xmax, 1, 1);
802  }
803  fl_pop_clip();
804  }
805  // Draw scrollbars last
807  draw_child(*_hscroll);
808  // That little tile between the scrollbars
809  if ( _vscroll->visible() && _hscroll->visible() ) {
810  fl_color(_vscroll->color());
811  fl_rectf(_hscroll->x()+_hscroll->w(),
812  _vscroll->y()+_vscroll->h(),
813  _vscroll->w(),
814  _hscroll->h());
815  }
816 
817  // Draw dragging line
819  Fl::pushed() == this) {
820 
821  Fl_Tree_Item *item = _root->find_clicked(_prefs, 1); // item we're on, vertically
822  if (item && item != _item_focus) {
823  // Are we dropping above or before the target item?
824  const int h = Fl::event_y() - item->y();
825  const int mid = item->h() / 2;
826  const bool before = h < mid;
827 
829 
830  int tgt = item->y() + (before ? 0 : item->h());
831  fl_line(item->x(), tgt, item->x() + item->w(), tgt);
832  }
833  }
834 }
835 #else
836 void Fl_Tree::draw() {
838  int ytoofar = draw_tree();
839 
840  // See if we're scrolled below bottom of tree
841  // This can happen if someone just closed a large item.
842  // If so, change scroller as needed.
843  //
844  if ( _vscroll->visible() && ytoofar > 0 ) {
845  int scrollval = _vscroll->value();
846  int ch = h() - Fl::box_dh(box());
847  int range2 = scrollval - ytoofar;
848  int size2 = ch + range2;
849  if ( range2 < 0 ) {
850  _vscroll->value(0);
851  _vscroll->hide();
852  } else {
853  _vscroll->slider_size(float(ch)/float(size2));
854  _vscroll->range(0.0,range2);
855  _vscroll->value(range2);
856  }
857  Fl::add_timeout(.10, redraw_soon, (void*)this); // use timer to trigger redraw; we can't
858  }
859 
860  // Draw dragging line
862  Fl::pushed() == this) {
863 
864  Fl_Tree_Item *item = _root->find_clicked(_prefs); // item we're on, vertically
865  if (item && item != _item_focus) {
866  // Are we dropping above or before the target item?
867  const int h = Fl::event_y() - item->y();
868  const int mid = item->h() / 2;
869  const bool before = h < mid;
870 
872 
873  int tgt = item->y() + (before ? 0 : item->h());
874  fl_line(item->x(), tgt, item->x() + item->w(), tgt);
875  }
876  }
877 }
878 
879 // This method is undocumented, and has been removed in ABI 1.3.3
881  int ret = 0;
883  // Let group draw box+label but *NOT* children.
884  // We handle drawing children ourselves by calling each item's draw()
885  //
886  int cx = x() + Fl::box_dx(box());
887  int cy = y() + Fl::box_dy(box());
888  int cw = w() - Fl::box_dw(box());
889  int ch = h() - Fl::box_dh(box());
890  {
891  // Handle group's bg
892  if ( damage() & ~FL_DAMAGE_CHILD) { // redraw entire widget?
895  }
896  if ( ! _root ) return(0);
897  // These values are changed during drawing
898  // By end, 'Y' will be the lowest point on the tree
899  int X = cx + _prefs.marginleft();
900  int Y = cy + _prefs.margintop() - (_vscroll->visible() ? _vscroll->value() : 0);
901  int W = cw - _prefs.marginleft(); // - _prefs.marginright();
902  // Adjust root's X/W if connectors off
904  X -= _prefs.openicon()->w();
905  W += _prefs.openicon()->w();
906  }
907  int Ysave = Y;
908  fl_push_clip(cx,cy,cw,ch);
909  {
911  _root->draw(X, Y, W, this,
912  (Fl::focus()==this)?_item_focus:0, // show focus item ONLY if Fl_Tree has focus
913  _prefs);
914  }
915  fl_pop_clip();
916 
917  // Show vertical scrollbar?
918  {
919 #if FLTK_ABI_VERSION >= 10301
920  // NEW
921  int SY = Y + _prefs.marginbottom();
922 #else /*FLTK_ABI_VERSION*/
923  // OLD
924  int SY = Y;
925 #endif /*FLTK_ABI_VERSION*/
926  int ydiff = (SY+_prefs.margintop())-Ysave; // ydiff=size of tree
927  int ytoofar = (cy+ch) - SY; // ytoofar -- if >0, scrolled beyond bottom
928  if ( ytoofar > 0 ) ydiff += ytoofar;
929  if ( Ysave<cy || ydiff>ch || int(_vscroll->value())>1 ) {
930  _vscroll->visible();
931  int scrollsize = _scrollbar_size ? _scrollbar_size : Fl::scrollbar_size();
932  int sx = x()+w()-Fl::box_dx(box())-scrollsize;
933  int sy = y()+Fl::box_dy(box());
934  int sw = scrollsize;
935  int sh = h()-Fl::box_dh(box());
936  _vscroll->show();
937  _vscroll->resize(sx,sy,sw,sh);
938  _vscroll->slider_size(float(ch)/float(ydiff));
939  _vscroll->range(0.0,ydiff-ch);
940  ret = ytoofar;
941  } else {
942  _vscroll->Fl_Slider::value(0);
943  _vscroll->hide();
944  ret = 0;
945  }
946  }
947  }
948  draw_child(*_vscroll); // draw scroll last
949  return(ret);
950 }
951 #endif
952 
959  if ( ! _root ) return;
960  _root->show_self();
961 }
962 
967 void Fl_Tree::root_label(const char *new_label) {
968  if ( ! _root ) return;
969  _root->label(new_label);
970 }
971 
974  return(_root);
975 }
976 
982 #if FLTK_ABI_VERSION >= 10303
983 #endif
988 void Fl_Tree::root(Fl_Tree_Item *newitem) {
991  if ( _root ) clear();
992  _root = newitem;
993 }
994 
1013 Fl_Tree_Item* Fl_Tree::add(const char *path, Fl_Tree_Item *item) {
1014  // Tree has no root? make one
1015  if ( ! _root ) {
1016 #if FLTK_ABI_VERSION >= 10303
1017  _root = new Fl_Tree_Item(this);
1018 #else
1019  _root = new Fl_Tree_Item(_prefs);
1020 #endif
1021  _root->parent(0);
1022  _root->label("ROOT");
1023  }
1024  // Find parent item via path
1025  char **arr = parse_path(path);
1026  item = _root->add(_prefs, arr, item);
1027  free_path(arr);
1028  return(item);
1029 }
1030 
1031 #if FLTK_ABI_VERSION >= 10303
1032 // do nothing here: add(path,item) where item defaults to 0 takes its place
1033 #else
1034 Fl_Tree_Item* Fl_Tree::add(const char *path) {
1042  return add(path, 0);
1043 }
1044 #endif
1045 
1054 Fl_Tree_Item* Fl_Tree::add(Fl_Tree_Item *parent_item, const char *name) {
1055  return(parent_item->add(_prefs, name));
1056 }
1057 
1076  return(above->insert_above(_prefs, name));
1077 }
1078 
1104 Fl_Tree_Item* Fl_Tree::insert(Fl_Tree_Item *item, const char *name, int pos) {
1105  return(item->insert(_prefs, name, pos));
1106 }
1107 
1115  // Item being removed is focus item? zero focus
1116  if ( item == _item_focus ) _item_focus = 0;
1117 #if FLTK_ABI_VERSION >= 10301
1118  if ( item == _lastselect ) _lastselect = 0;
1119 #endif /*FLTK_ABI_VERSION*/
1120  if ( item == _root ) {
1121  clear();
1122  } else {
1123  Fl_Tree_Item *parent = item->parent(); // find item's parent
1124  if ( ! parent ) return(-1);
1125  parent->remove_child(item); // remove child + children
1126  }
1127  return(0);
1128 }
1129 
1134  if ( ! _root ) return;
1135  _root->clear_children();
1136  delete _root; _root = 0;
1137  _item_focus = 0;
1138 #if FLTK_ABI_VERSION >= 10301
1139  _lastselect = 0;
1140 #endif /*FLTK_ABI_VERSION*/
1141 }
1142 
1147  if ( item->has_children() ) {
1148  item->clear_children();
1149  redraw(); // redraw only if there were children to clear
1150  }
1151 }
1152 
1170 const Fl_Tree_Item *Fl_Tree::find_item(const char *path) const {
1171  if ( ! _root ) return(NULL);
1172  char **arr = parse_path(path);
1173  const Fl_Tree_Item *item = _root->find_item(arr);
1174  free_path(arr);
1175  return(item);
1176 }
1177 
1179 Fl_Tree_Item *Fl_Tree::find_item(const char *path) {
1180  // "Effective C++, 3rd Ed", p.23. Sola fide, Amen.
1181  return(const_cast<Fl_Tree_Item*>(
1182  static_cast<const Fl_Tree&>(*this).find_item(path)));
1183 }
1184 
1185 // Handle safe 'reverse string concatenation'.
1186 // In the following we build the pathname from right-to-left,
1187 // since we start at the child and work our way up to the root.
1188 //
1189 #define SAFE_RCAT(c) { \
1190  slen += 1; if ( slen >= pathnamelen ) { pathname[0] = '\0'; return(-2); } \
1191  *s-- = c; \
1192  }
1193 
1211 int Fl_Tree::item_pathname(char *pathname, int pathnamelen, const Fl_Tree_Item *item) const {
1212  pathname[0] = '\0';
1213  item = item ? item : _root;
1214  if ( !item ) return(-1);
1215  // Build pathname starting at end
1216  char *s = (pathname+pathnamelen-1);
1217  int slen = 0; // length of string compiled so far (including NULL)
1218  SAFE_RCAT('\0');
1219  while ( item ) {
1220  if ( item->is_root() && showroot() == 0 ) break; // don't include root in path if showroot() off
1221  // Find name of current item
1222  const char *name = item->label() ? item->label() : "???"; // name for this item
1223  int len = (int) strlen(name);
1224  // Add name to end of pathname[]
1225  for ( --len; len>=0; len-- ) {
1226  SAFE_RCAT(name[len]); // rcat name of item
1227  if ( name[len] == '/' || name[len] == '\\' ) {
1228  SAFE_RCAT('\\'); // escape front or back slashes within name
1229  }
1230  }
1231  SAFE_RCAT('/'); // rcat leading slash
1232  item = item->parent(); // move up tree (NULL==root)
1233  }
1234  if ( *(++s) == '/' ) { ++s; --slen; } // leave off leading slash from pathname
1235  if ( s != pathname ) memmove(pathname, s, slen); // Shift down right-aligned string
1236  return(0);
1237 }
1238 
1239 #if FLTK_ABI_VERSION >= 10303
1240 const Fl_Tree_Item* Fl_Tree::find_clicked(int yonly) const {
1258  if ( ! _root ) return(NULL);
1259  return(_root->find_clicked(_prefs, yonly));
1260 }
1261 
1263 Fl_Tree_Item *Fl_Tree::find_clicked(int yonly) {
1264  // "Effective C++, 3rd Ed", p.23. Sola fide, Amen.
1265  return(const_cast<Fl_Tree_Item*>(
1266  static_cast<const Fl_Tree&>(*this).find_clicked(yonly)));
1267 }
1268 #else
1269 const Fl_Tree_Item* Fl_Tree::find_clicked() const {
1283  if ( ! _root ) return(NULL);
1284  return(_root->find_clicked(_prefs));
1285 }
1286 
1290  // "Effective C++, 3rd Ed", p.23. Sola fide, Amen.
1291  return(const_cast<Fl_Tree_Item*>(
1292  static_cast<const Fl_Tree&>(*this).find_clicked()));
1293 }
1294 #endif
1295 
1303  _callback_item = item;
1304 }
1305 
1315  return(_callback_item);
1316 }
1317 
1339  return next_item(item, dir, true);
1340 }
1341 
1354  return(_root); // first item always root
1355 }
1356 
1361  return(first_visible_item());
1362 }
1363 
1370  Fl_Tree_Item *i = showroot() ? first() : next(first());
1371  while ( i ) {
1372  if ( i->visible() ) return(i);
1373  i = next(i);
1374  }
1375  return(0);
1376 }
1377 
1392  if ( ! item ) return(0);
1393  return(item->next());
1394 }
1395 
1410  if ( ! item ) return(0);
1411  return(item->prev());
1412 }
1413 
1427  if ( ! _root ) return(0);
1428  Fl_Tree_Item *item = _root;
1429  while ( item->has_children() ) {
1430  item = item->child(item->children()-1);
1431  }
1432  return(item);
1433 }
1434 
1439  return(last_visible_item());
1440 }
1441 
1448  Fl_Tree_Item *item = last();
1449  while ( item ) {
1450  if ( item->visible() ) {
1451  if ( item == _root && !showroot() ) {
1452  return(0);
1453  } else {
1454  return(item);
1455  }
1456  }
1457  item = prev(item);
1458  }
1459  return(item);
1460 }
1461 
1477  return(next_selected_item(0));
1478 }
1479 
1480 #if FLTK_ABI_VERSION >= 10303
1481 // nothing
1482 #else
1499  return(next_selected_item(item, FL_Down));
1500 }
1501 #endif
1502 
1519  return(next_selected_item(0, FL_Up));
1520 }
1521 
1568  if ( ! item ) { // no start item?
1569  if ( visible ) {
1570  item = ( dir == FL_Up ) ? last_visible_item() : // wrap to bottom
1571  first_visible_item(); // wrap to top
1572  } else {
1573  item = ( dir == FL_Up ) ? last() : // wrap to bottom
1574  first(); // wrap to top
1575  }
1576  if ( ! item ) return(0);
1577  if ( item->visible_r() ) return(item); // return first/last visible item
1578  }
1579  switch (dir) {
1580  case FL_Up:
1581  if ( visible ) return(item->prev_visible(_prefs));
1582  else return(item->prev());
1583  case FL_Down:
1584  if ( visible ) return(item->next_visible(_prefs));
1585  else return(item->next());
1586  }
1587  return(0); // unknown dir
1588 }
1589 
1616  switch (dir) {
1617  case FL_Down:
1618  if ( ! item ) {
1619  if ( ! (item = first()) ) return(0);
1620  if ( item->is_selected() ) return(item);
1621  }
1622  while ( (item = item->next()) )
1623  if ( item->is_selected() )
1624  return(item);
1625  return(0);
1626  case FL_Up:
1627  if ( ! item ) {
1628  if ( ! (item = last()) ) return(0);
1629  if ( item->is_selected() ) return(item);
1630  }
1631  while ( (item = item->prev()) )
1632  if ( item->is_selected() )
1633  return(item);
1634  return(0);
1635  }
1636  return(0);
1637 }
1638 
1639 #if FLTK_ABI_VERSION >= 10303 /* reason for this: Fl_Tree_Item_Array::manage_item_destroy() */
1640 int Fl_Tree::get_selected_items(Fl_Tree_Item_Array &ret_items) {
1660  ret_items.clear();
1661  for ( Fl_Tree_Item *i=first_selected_item(); i; i=next_selected_item(i) ) {
1662  ret_items.add(i);
1663  }
1664  return ret_items.total();
1665 }
1666 #endif
1667 
1689 int Fl_Tree::open(Fl_Tree_Item *item, int docallback) {
1690  if ( item->is_open() ) return(0);
1691  item->open(); // handles recalc_tree()
1692  redraw();
1693  if ( docallback ) {
1695  }
1696  return(1);
1697 }
1698 
1723 int Fl_Tree::open(const char *path, int docallback) {
1724  Fl_Tree_Item *item = find_item(path);
1725  if ( ! item ) return(-1);
1726  return(open(item, docallback)); // handles recalc_tree()
1727 }
1728 
1746 void Fl_Tree::open_toggle(Fl_Tree_Item *item, int docallback) {
1747  if ( item->is_open() ) {
1748  close(item, docallback); // handles recalc_tree()
1749  } else {
1750  open(item, docallback); // handles recalc_tree()
1751  }
1752 }
1753 
1773 int Fl_Tree::close(Fl_Tree_Item *item, int docallback) {
1774  if ( item->is_close() ) return(0);
1775  item->close(); // handles recalc_tree()
1776  redraw();
1777  if ( docallback ) {
1779  }
1780  return(1);
1781 }
1782 
1806 int Fl_Tree::close(const char *path, int docallback) {
1807  Fl_Tree_Item *item = find_item(path);
1808  if ( ! item ) return(-1);
1809  return(close(item, docallback)); // handles recalc_tree()
1810 }
1811 
1822 int Fl_Tree::is_open(Fl_Tree_Item *item) const {
1823  return(item->is_open()?1:0);
1824 }
1825 
1841 int Fl_Tree::is_open(const char *path) const {
1842  const Fl_Tree_Item *item = find_item(path);
1843  if ( ! item ) return(-1);
1844  return(item->is_open()?1:0);
1845 }
1846 
1855  return(item->is_close());
1856 }
1857 
1869 int Fl_Tree::is_close(const char *path) const {
1870  const Fl_Tree_Item *item = find_item(path);
1871  if ( ! item ) return(-1);
1872  return(item->is_close()?1:0);
1873 }
1874 
1892 int Fl_Tree::select(Fl_Tree_Item *item, int docallback) {
1893  int alreadySelected = item->is_selected();
1894  if ( !alreadySelected ) {
1895  item->select();
1896  set_changed();
1897  if ( docallback ) {
1899  }
1900  redraw();
1901  return(1);
1902  }
1903 #if FLTK_ABI_VERSION >= 10301
1904  // NEW
1905  if ( alreadySelected ) {
1906  if ( (item_reselect_mode() == FL_TREE_SELECTABLE_ALWAYS) && docallback ) {
1907  do_callback_for_item(item, FL_TREE_REASON_RESELECTED);
1908  }
1909  }
1910 #endif /*FLTK_ABI_VERSION*/
1911  return(0);
1912 }
1913 
1936 int Fl_Tree::select(const char *path, int docallback) {
1937  Fl_Tree_Item *item = find_item(path);
1938  if ( ! item ) return(-1);
1939  return(select(item, docallback));
1940 }
1941 
1957 void Fl_Tree::select_toggle(Fl_Tree_Item *item, int docallback) {
1958  item->select_toggle();
1959  set_changed();
1960  if ( docallback ) {
1963  }
1964  redraw();
1965 }
1966 
1985 int Fl_Tree::deselect(Fl_Tree_Item *item, int docallback) {
1986  if ( item->is_selected() ) {
1987  item->deselect();
1988  set_changed();
1989  if ( docallback ) {
1991  }
1992  redraw();
1993  return(1);
1994  }
1995  return(0);
1996 }
1997 
2020 int Fl_Tree::deselect(const char *path, int docallback) {
2021  Fl_Tree_Item *item = find_item(path);
2022  if ( ! item ) return(-1);
2023  return(deselect(item, docallback));
2024 }
2025 
2044 int Fl_Tree::deselect_all(Fl_Tree_Item *item, int docallback) {
2045  item = item ? item : first(); // NULL? use first()
2046  if ( ! item ) return(0);
2047  int count = 0;
2048  // Deselect item
2049  if ( item->is_selected() )
2050  if ( deselect(item, docallback) )
2051  ++count;
2052  // Deselect its children
2053  for ( int t=0; t<item->children(); t++ ) {
2054  count += deselect_all(item->child(t), docallback); // recurse
2055  }
2056  return(count);
2057 }
2058 
2077 int Fl_Tree::select_only(Fl_Tree_Item *selitem, int docallback) {
2078  selitem = selitem ? selitem : first(); // NULL? use first()
2079  if ( ! selitem ) return(0);
2080  int changed = 0;
2081  // Deselect everything first.
2082  // Prevents callbacks from seeing more than one item selected.
2083  //
2084  for ( Fl_Tree_Item *item = first(); item; item = item->next() ) {
2085  if ( item == selitem ) continue; // don't do anything to selitem yet..
2086  if ( item->is_selected() ) {
2087  deselect(item, docallback);
2088  ++changed;
2089  }
2090  }
2091 #if FLTK_ABI_VERSION >= 10301
2092  // Should we 'reselect' item if already selected?
2093  if ( selitem->is_selected() && (item_reselect_mode()==FL_TREE_SELECTABLE_ALWAYS) ) {
2094  // Selection unchanged, so no ++changed
2095  select(selitem, docallback); // do callback with reason=reselect
2096  } else if ( !selitem->is_selected() ) {
2097  // Item was not already selected, select and indicate changed
2098  select(selitem, docallback);
2099  ++changed;
2100  }
2101 #else
2102  if ( !selitem->is_selected() ) {
2103  // All items deselected, now select the one we want
2104  select(selitem, docallback);
2105  ++changed;
2106  }
2107 #endif
2108  return(changed);
2109 }
2110 
2129 int Fl_Tree::select_all(Fl_Tree_Item *item, int docallback) {
2130  item = item ? item : first(); // NULL? use first()
2131  if ( ! item ) return(0);
2132  int count = 0;
2133  // Select item
2134  if ( !item->is_selected() )
2135  if ( select(item, docallback) )
2136  ++count;
2137  // Select its children
2138  for ( int t=0; t<item->children(); t++ ) {
2139  count += select_all(item->child(t), docallback); // recurse
2140  }
2141  return(count);
2142 }
2143 
2146  return(_item_focus);
2147 }
2148 
2156  if ( _item_focus != item ) { // changed?
2157  _item_focus = item; // update
2158  if ( visible_focus() ) redraw(); // redraw to update focus box
2159  }
2160 }
2161 
2171  return(item->is_selected()?1:0);
2172 }
2173 
2185 int Fl_Tree::is_selected(const char *path) {
2186  Fl_Tree_Item *item = find_item(path);
2187  if ( ! item ) return(-1);
2188  return(is_selected(item));
2189 }
2190 
2193  return(_prefs.labelsize());
2194 }
2195 
2200  _prefs.labelsize(val);
2201 }
2202 
2205  return(_prefs.labelfont());
2206 }
2207 
2212  _prefs.labelfont(val);
2213 }
2214 
2217  return(_prefs.labelfgcolor());
2218 }
2219 
2224  _prefs.labelfgcolor(val);
2225 }
2226 
2230  return(_prefs.labelbgcolor());
2231 }
2232 
2238  _prefs.labelbgcolor(val);
2239 }
2240 
2243  return(_prefs.connectorcolor());
2244 }
2245 
2248  _prefs.connectorcolor(val);
2249 }
2250 
2254 int Fl_Tree::marginleft() const {
2255  return(_prefs.marginleft());
2256 }
2257 
2261 void Fl_Tree::marginleft(int val) {
2262  _prefs.marginleft(val);
2263  redraw();
2264  recalc_tree();
2265 }
2266 
2270 int Fl_Tree::margintop() const {
2271  return(_prefs.margintop());
2272 }
2273 
2277 void Fl_Tree::margintop(int val) {
2278  _prefs.margintop(val);
2279  redraw();
2280  recalc_tree();
2281 }
2282 
2283 #if FLTK_ABI_VERSION >= 10301
2284 int Fl_Tree::marginbottom() const {
2288  return(_prefs.marginbottom());
2289 }
2290 
2294 void Fl_Tree::marginbottom(int val) {
2295  _prefs.marginbottom(val);
2296  redraw();
2297  recalc_tree();
2298 }
2299 #endif /*FLTK_ABI_VERSION*/
2300 
2305  return(_prefs.linespacing());
2306 }
2307 
2311 void Fl_Tree::linespacing(int val) {
2312  _prefs.linespacing(val);
2313  redraw();
2314  recalc_tree();
2315 }
2316 
2321  return(_prefs.openchild_marginbottom());
2322 }
2323 
2329  redraw();
2330  recalc_tree();
2331 }
2332 
2336  return(_prefs.usericonmarginleft());
2337 }
2338 
2343  redraw();
2344  recalc_tree();
2345 }
2346 
2350  return(_prefs.labelmarginleft());
2351 }
2352 
2356  _prefs.labelmarginleft(val);
2357  redraw();
2358  recalc_tree();
2359 }
2360 
2361 #if FLTK_ABI_VERSION >= 10301
2362 int Fl_Tree::widgetmarginleft() const {
2365  return(_prefs.widgetmarginleft());
2366 }
2367 
2370 void Fl_Tree::widgetmarginleft(int val) {
2371  _prefs.widgetmarginleft(val);
2372  redraw();
2373  recalc_tree();
2374 }
2375 #endif /*FLTK_ABI_VERSION*/
2376 
2381  return(_prefs.connectorwidth());
2382 }
2383 
2388  _prefs.connectorwidth(val);
2389  redraw();
2390  recalc_tree();
2391 }
2392 
2398  return(_prefs.usericon());
2399 }
2400 
2411  _prefs.usericon(val);
2412  redraw();
2413  recalc_tree();
2414 }
2415 
2421  return(_prefs.openicon());
2422 }
2423 
2430  _prefs.openicon(val);
2431  redraw();
2432  recalc_tree();
2433 }
2434 
2440  return(_prefs.closeicon());
2441 }
2442 
2449  _prefs.closeicon(val);
2450  redraw();
2451  recalc_tree();
2452 }
2453 
2457  return(_prefs.showcollapse());
2458 }
2459 
2468 void Fl_Tree::showcollapse(int val) {
2469  _prefs.showcollapse(val);
2470  redraw();
2471  recalc_tree();
2472 }
2473 
2475 int Fl_Tree::showroot() const {
2476  return(_prefs.showroot());
2477 }
2478 
2483 void Fl_Tree::showroot(int val) {
2484  _prefs.showroot(val);
2485  redraw();
2486  recalc_tree();
2487 }
2488 
2491  return(_prefs.connectorstyle());
2492 }
2493 
2498  _prefs.connectorstyle(val);
2499  redraw();
2500 }
2501 
2506  return(_prefs.sortorder());
2507 }
2508 
2511  _prefs.sortorder(val);
2512  // no redraw().. only affects new add()itions
2513 }
2514 
2520  return(_prefs.selectbox());
2521 }
2522 
2528  _prefs.selectbox(val);
2529  redraw();
2530 }
2531 
2536  return(_prefs.selectmode());
2537 }
2538 
2543  _prefs.selectmode(val);
2544 }
2545 
2546 #if FLTK_ABI_VERSION >= 10301
2547 Fl_Tree_Item_Reselect_Mode Fl_Tree::item_reselect_mode() const {
2551  return(_prefs.item_reselect_mode());
2552 }
2553 
2558 void Fl_Tree::item_reselect_mode(Fl_Tree_Item_Reselect_Mode mode) {
2559  _prefs.item_reselect_mode(mode);
2560 }
2561 
2565 Fl_Tree_Item_Draw_Mode Fl_Tree::item_draw_mode() const {
2566  return(_prefs.item_draw_mode());
2567 }
2568 
2576 void Fl_Tree::item_draw_mode(Fl_Tree_Item_Draw_Mode mode) {
2577  _prefs.item_draw_mode(mode);
2578 }
2579 
2587 void Fl_Tree::item_draw_mode(int mode) {
2588  _prefs.item_draw_mode(Fl_Tree_Item_Draw_Mode(mode));
2589 }
2590 #endif
2591 
2603  item = item ? item : first();
2604  if (!item) return(0);
2605  return( (item->y() >= y()) && (item->y() <= (y()+h()-item->h())) ? 1 : 0);
2606 }
2607 
2622 void Fl_Tree::show_item(Fl_Tree_Item *item, int yoff) {
2623  item = item ? item : first();
2624  if (!item) return;
2625  int newval = item->y() - y() - yoff + (int)_vscroll->value();
2626  if ( newval < _vscroll->minimum() ) newval = (int)_vscroll->minimum();
2627  if ( newval > _vscroll->maximum() ) newval = (int)_vscroll->maximum();
2628  _vscroll->value(newval);
2629  redraw();
2630 }
2631 
2641  item = item ? item : first();
2642  if (!item) return;
2643  if ( displayed(item) ) return;
2644  show_item_top(item);
2645 }
2646 
2652  item = item ? item : first();
2653  if (item) show_item(item, 0);
2654 }
2655 
2661  item = item ? item : first();
2662 #if FLTK_ABI_VERSION >= 10303
2663  if (item) show_item(item, (_tih/2)-(item->h()/2));
2664 #else
2665  if (item) show_item(item, (h()/2)-(item->h()/2));
2666 #endif
2667 }
2668 
2674  item = item ? item : first();
2675 #if FLTK_ABI_VERSION >= 10303
2676  if (item) show_item(item, _tih-item->h());
2677 #else
2678  if (item) show_item(item, h()-item->h());
2679 #endif
2680 }
2681 
2686  item = item ? item : first();
2687  if (item) show_item_middle(item);
2688 }
2689 
2695 int Fl_Tree::vposition() const {
2696  return((int)_vscroll->value());
2697 }
2698 
2705 void Fl_Tree::vposition(int pos) {
2706  if (pos < 0) pos = 0;
2707  if (pos > _vscroll->maximum()) pos = (int)_vscroll->maximum();
2708  if (pos == _vscroll->value()) return;
2709  _vscroll->value(pos);
2710  redraw();
2711 }
2712 
2719 int Fl_Tree::hposition() const {
2720 #if FLTK_ABI_VERSION >= 10303
2721  return((int)_hscroll->value());
2722 #else
2723  return(0);
2724 #endif
2725 }
2726 
2734 void Fl_Tree::hposition(int pos) {
2735 #if FLTK_ABI_VERSION >= 10303
2736  if (pos < 0) pos = 0;
2737  if (pos > _hscroll->maximum()) pos = (int)_hscroll->maximum();
2738  if (pos == _hscroll->value()) return;
2739  _hscroll->value(pos);
2740  redraw();
2741 #endif
2742 }
2743 
2758 #if FLTK_ABI_VERSION >= 10303
2759  return( (w==_vscroll || w==_hscroll) ? 1 : 0 );
2760 #else
2761  return( (w==_vscroll) ? 1 : 0 );
2762 #endif
2763 }
2764 
2775  return(_scrollbar_size);
2776 }
2777 
2799  int scrollsize = _scrollbar_size ? _scrollbar_size : Fl::scrollbar_size();
2800  if ( _vscroll->w() != scrollsize ) {
2801  _vscroll->resize(x()+w()-scrollsize, h(), scrollsize, _vscroll->h());
2802  }
2803 #if FLTK_ABI_VERSION >= 10303
2804  if ( _hscroll->h() != scrollsize ) {
2805  _hscroll->resize(x(), y()+h()-scrollsize, _hscroll->w(), scrollsize);
2806  }
2807  // Changing scrollbar size affects _tiw/_tih + may affect scrollbar visibility
2808  calc_dimensions();
2809 #endif
2810 }
2811 
2816  return(_vscroll->visible() ? 1 : 0);
2817 }
2818 
2824 #if FLTK_ABI_VERSION >= 10303
2825  return(_hscroll->visible() ? 1 : 0);
2826 #else
2827  return 0;
2828 #endif
2829 }
2830 
2835  callback_reason(reason);
2836  callback_item(item);
2837  do_callback((Fl_Widget*)this, user_data());
2838 }
2839 
2844  _callback_item = item;
2845 }
2846 
2851  return(_callback_item);
2852 }
2853 
2858  _callback_reason = reason;
2859 }
2860 
2881  return(_callback_reason);
2882 }
2883 
2891  int i, j, n, pn = (int) strlen(prefs.path());
2892  char *p;
2893  const char *path = prefs.path();
2894  if (strcmp(path, ".")==0)
2895  path += 1; // root path is empty
2896  else
2897  path += 2; // child path starts with "./"
2898  n = prefs.groups();
2899  for (i=0; i<n; i++) {
2900  Fl_Preferences prefsChild(prefs, i);
2901  add(prefsChild.path()+2); // children always start with "./"
2902  load(prefsChild);
2903  }
2904  n = prefs.entries();
2905  for (i=0; i<n; i++) {
2906  // We must remove all fwd slashes in the key and value strings. Replace with backslash.
2907  char *key = strdup(prefs.entry(i));
2908  int kn = (int) strlen(key);
2909  for (j=0; j<kn; j++) {
2910  if (key[j]=='/') key[j]='\\';
2911  }
2912  char *val; prefs.get(key, val, "");
2913  int vn = (int) strlen(val);
2914  for (j=0; j<vn; j++) {
2915  if (val[j]=='/') val[j]='\\';
2916  }
2917  if (vn<40) {
2918  size_t sze = pn + strlen(key) + vn;
2919  p = (char*)malloc(sze+5);
2920  sprintf(p, "%s/%s = %s", path, key, val);
2921  } else {
2922  size_t sze = pn + strlen(key) + 40;
2923  p = (char*)malloc(sze+5);
2924  sprintf(p, "%s/%s = %.40s...", path, key, val);
2925  }
2926  add(p[0]=='/'?p+1:p);
2927  free(p);
2928  free(val);
2929  free(key);
2930  }
2931 }
2932 
2935  Fl_Widget** a = (Fl_Widget**)array();
2936  if (a[children()-1] != _vscroll) {
2937  int i,j;
2938 #if FLTK_ABI_VERSION >= 10303
2939  for (i = j = 0; j < children(); j++) {
2940  if (a[j] != _vscroll && a[j] != _hscroll ) a[i++] = a[j];
2941  }
2942  a[i++] = _hscroll;
2943  a[i++] = _vscroll;
2944 #else
2945  for (i = j = 0; j < children(); j++) {
2946  if (a[j] != _vscroll) a[i++] = a[j];
2947  }
2948  a[i++] = _vscroll;
2949 #endif
2950  }
2951 }
2952 
2957 #if FLTK_ABI_VERSION >= 10303
2958  _tree_w = _tree_h = -1;
2959 #endif
2960 }
2961 
2962 //
2963 // End of "$Id$".
2964 //
Fl_Tree_Item::visible
int visible() const
See if the item is visible. Alias for is_visible().
Definition: Fl_Tree_Item.H:427
Fl_Widget::draw_label
void draw_label() const
Definition: fl_labeltype.cxx:99
Fl_Tree_Prefs::openicon
Fl_Image * openicon() const
Definition: Fl_Tree_Prefs.H:331
Fl_Tree::_callback_reason
Fl_Tree_Reason _callback_reason
Definition: Fl_Tree.H:328
Fl_Tree::show_item
void show_item(Fl_Tree_Item *item, int yoff)
Definition: Fl_Tree.cxx:2622
Fl_Tree_Prefs::connectorwidth
int connectorwidth() const
Get the tree connection line's width.
Definition: Fl_Tree_Prefs.H:317
Fl_Tree_Item::insert
Fl_Tree_Item * insert(const Fl_Tree_Prefs &prefs, const char *new_label, int pos=0)
Definition: Fl_Tree_Item.cxx:445
Fl_Tree_Prefs::linespacing
int linespacing() const
Get the line spacing value in pixels.
Definition: Fl_Tree_Prefs.H:285
fl_font
void fl_font(Fl_Font face, Fl_Fontsize fsize)
Definition: fl_draw.H:509
FL_Up
#define FL_Up
The up arrow key.
Definition: Enumerations.H:481
Fl_Tree::showroot
int showroot() const
Returns 1 if the root item is to be shown, or 0 if not.
Definition: Fl_Tree.cxx:2475
FL_TREE_REASON_NONE
unknown reason
Definition: Fl_Tree.H:312
Fl_Tree_Item::close
void close()
Close this item and all its children.
Definition: Fl_Tree_Item.cxx:1576
SAFE_RCAT
#define SAFE_RCAT(c)
Definition: Fl_Tree.cxx:1189
Fl_Tree::insert
Fl_Tree_Item * insert(Fl_Tree_Item *item, const char *name, int pos)
Definition: Fl_Tree.cxx:1104
Fl_Tree::showcollapse
int showcollapse() const
Definition: Fl_Tree.cxx:2456
Fl_Widget::y
int y() const
Definition: Fl_Widget.H:289
free_path
static void free_path(char **arr)
Definition: Fl_Tree.cxx:58
FL_Enter
#define FL_Enter
The enter key.
Definition: Enumerations.H:471
Fl_Tree::show_item_middle
void show_item_middle(Fl_Tree_Item *item)
Definition: Fl_Tree.cxx:2660
FL_TREE_SELECT_NONE
Nothing selected when items are clicked.
Definition: Fl_Tree_Prefs.H:68
Fl_Tree::marginleft
int marginleft() const
Definition: Fl_Tree.cxx:2254
Fl_Tree::connectorstyle
Fl_Tree_Connector connectorstyle() const
Returns the line drawing style for inter-connecting items.
Definition: Fl_Tree.cxx:2490
Fl_Tree::find_item
Fl_Tree_Item * find_item(const char *path)
Non-const version of Fl_Tree::find_item(const char *path) const.
Definition: Fl_Tree.cxx:1179
Fl_Tree::load
void load(class Fl_Preferences &)
Load FLTK preferences.
Definition: Fl_Tree.cxx:2890
fl_line
void fl_line(int x, int y, int x1, int y1)
Definition: fl_draw.H:223
Fl_Scrollbar
Definition: Fl_Scrollbar.H:43
fl_rectf
void fl_rectf(int x, int y, int w, int h)
Definition: fl_draw.H:206
Fl_Tree::usericonmarginleft
int usericonmarginleft() const
Definition: Fl_Tree.cxx:2335
Fl_Widget::draw_box
void draw_box() const
Definition: fl_boxtype.cxx:442
Fl_Tree_Prefs::sortorder
Fl_Tree_Sort sortorder() const
Get the default sort order value.
Definition: Fl_Tree_Prefs.H:400
Fl_Color
unsigned int Fl_Color
Definition: Enumerations.H:934
Fl_Tree::item_labelfont
Fl_Font item_labelfont() const
Get the default font face used for creating new items.
Definition: Fl_Tree.cxx:2204
Fl_Tree_Item::widget
void widget(Fl_Widget *val)
Assign an FLTK widget to this item.
Definition: Fl_Tree_Item.H:223
FL_TREE_REASON_SELECTED
an item was selected
Definition: Fl_Tree.H:313
Fl_Group::end
void end()
Definition: Fl_Group.cxx:75
Fl_Tree_Item::find_item
const Fl_Tree_Item * find_item(char **arr) const
Definition: Fl_Tree_Item.cxx:291
Fl_Tree_Item::y
int y() const
The item's y position relative to the window.
Definition: Fl_Tree_Item.H:139
Fl_Tree_Item::open
void open()
Open this item and all its children.
Definition: Fl_Tree_Item.cxx:1566
FL_UNFOCUS
Definition: Enumerations.H:288
Fl_Tree::Fl_Tree_Item
friend class Fl_Tree_Item
Definition: Fl_Tree.H:324
Fl_Tree::is_vscroll_visible
int is_vscroll_visible() const
Definition: Fl_Tree.cxx:2815
Fl_Tree::item_labelfgcolor
Fl_Color item_labelfgcolor(void) const
Get the default label foreground color used for creating new items.
Definition: Fl_Tree.cxx:2216
Fl_Tree::deselect
int deselect(Fl_Tree_Item *item, int docallback=1)
Definition: Fl_Tree.cxx:1985
Fl_Tree::draw
void draw()
Standard FLTK draw() method, handles drawing the tree widget.
Definition: Fl_Tree.cxx:837
Fl_Widget::show
virtual void show()
Definition: Fl_Widget.cxx:271
Fl::box_dx
static int box_dx(Fl_Boxtype)
Definition: fl_boxtype.cxx:360
Fl_Boxtype
Fl_Boxtype
Definition: Enumerations.H:603
Fl_Tree::set_item_focus
void set_item_focus(Fl_Tree_Item *item)
Definition: Fl_Tree.cxx:2155
Fl_Tree::first_selected_item
Fl_Tree_Item * first_selected_item()
Definition: Fl_Tree.cxx:1476
Fl_Image
Base class for image caching and drawing.
Definition: Fl_Image.H:55
Fl_Tree_Item::label_x
int label_x() const
Definition: Fl_Tree_Item.H:147
Fl_Tree_Item::event_on_label
int event_on_label(const Fl_Tree_Prefs &prefs) const
Definition: Fl_Tree_Item.cxx:1535
Fl_Tree_Prefs::showcollapse
char showcollapse() const
Returns 1 if the collapse icon is enabled, 0 if not.
Definition: Fl_Tree_Prefs.H:385
Fl_Tree::next
Fl_Tree_Item * next(Fl_Tree_Item *item=0)
Definition: Fl_Tree.cxx:1391
Fl_Tree::select_all
int select_all(Fl_Tree_Item *item=0, int docallback=1)
Definition: Fl_Tree.cxx:2129
Fl_Tree::clear
void clear()
Definition: Fl_Tree.cxx:1133
Fl::event_state
static int event_state()
Definition: Fl.H:704
Fl_Tree::is_close
int is_close(Fl_Tree_Item *item) const
Definition: Fl_Tree.cxx:1854
Fl_Tree_Select
Fl_Tree_Select
Definition: Fl_Tree_Prefs.H:67
Fl_Tree::usericon
Fl_Image * usericon() const
Definition: Fl_Tree.cxx:2397
fl_color
void fl_color(Fl_Color c)
Definition: fl_draw.H:52
Fl::event_button
static int event_button()
Definition: Fl.H:678
FL_DRAG
Definition: Enumerations.H:268
Fl_Tree_Item::is_selected
char is_selected() const
See if the item is selected.
Definition: Fl_Tree_Item.H:390
Fl_Tree::is_hscroll_visible
int is_hscroll_visible() const
Definition: Fl_Tree.cxx:2823
FL_SHIFT
#define FL_SHIFT
One of the shift keys is down.
Definition: Enumerations.H:557
Fl_Tree_Item::move_into
int move_into(Fl_Tree_Item *item, int pos=0)
Definition: Fl_Tree_Item.cxx:609
Fl_Tree::sortorder
Fl_Tree_Sort sortorder() const
Definition: Fl_Tree.cxx:2505
Fl_Tree_Item::prev_visible
Fl_Tree_Item * prev_visible(Fl_Tree_Prefs &prefs)
Definition: Fl_Tree_Item.cxx:1798
Fl_Tree::is_open
int is_open(Fl_Tree_Item *item) const
Definition: Fl_Tree.cxx:1822
Fl_Widget::changed
unsigned int changed() const
Definition: Fl_Widget.H:781
Fl_Tree::first_visible
Fl_Tree_Item * first_visible()
Definition: Fl_Tree.cxx:1360
free
void free()
H
static int H
Definition: Fl_Tooltip.cxx:76
FL_KP_Enter
#define FL_KP_Enter
The enter key on the keypad, same as Fl_KP+'\r'.
Definition: Enumerations.H:493
Fl_Tree_Item::deselect
void deselect()
Disable the item's selection state.
Definition: Fl_Tree_Item.H:371
Fl_Tree::first_visible_item
Fl_Tree_Item * first_visible_item()
Definition: Fl_Tree.cxx:1369
Fl_Widget::x
int x() const
Definition: Fl_Widget.H:284
NULL
#define NULL
Definition: forms.H:34
Fl_Tree_Prefs::selectmode
Fl_Tree_Select selectmode() const
Get the selection mode used for the tree.
Definition: Fl_Tree_Prefs.H:430
Fl_Tree_Item::draw
void draw(int X, int &Y, int W, Fl_Widget *tree, Fl_Tree_Item *itemfocus, const Fl_Tree_Prefs &prefs, int lastchild=1)
Definition: Fl_Tree_Item.cxx:1297
Fl_Tree::draw_tree
int draw_tree()
Definition: Fl_Tree.cxx:880
Fl_Tree_Item::select
void select(int val=1)
Definition: Fl_Tree_Item.H:344
Fl_Tree_Item
Tree widget item.
Definition: Fl_Tree_Item.H:67
Fl_Widget::when
Fl_When when() const
Definition: Fl_Widget.H:621
Fl_Widget::do_callback
void do_callback()
Definition: Fl_Widget.H:861
Fl_Tree::handle
int handle(int e)
Definition: Fl_Tree.cxx:260
Fl_Tree::_callback_item
Fl_Tree_Item * _callback_item
Definition: Fl_Tree.H:327
Fl_Tree_Prefs::showroot
int showroot() const
Returns 1 if the root item is to be shown, or 0 if not.
Definition: Fl_Tree_Prefs.H:419
Fl_Tree::open_toggle
void open_toggle(Fl_Tree_Item *item, int docallback=1)
Definition: Fl_Tree.cxx:1746
Fl_Tree::prev
Fl_Tree_Item * prev(Fl_Tree_Item *item=0)
Definition: Fl_Tree.cxx:1409
Fl_Tree::add
Fl_Tree_Item * add(const char *path)
Definition: Fl_Tree.cxx:1041
FL_LEAVE
Definition: Enumerations.H:259
Fl_Tree_Item::move_above
int move_above(Fl_Tree_Item *item)
Definition: Fl_Tree_Item.cxx:587
Fl::event_key
static int event_key()
Definition: Fl.H:723
Fl_Image::w
void w(int W)
Definition: Fl_Image.H:76
FL_TREE_SELECT_SINGLE
Single item selected when item is clicked (default)
Definition: Fl_Tree_Prefs.H:69
Fl_Widget::user_data
void * user_data() const
Definition: Fl_Widget.H:593
Fl_Valuator::maximum
double maximum() const
Definition: Fl_Valuator.H:81
key
int key
Definition: Fl_Text_Editor.cxx:91
FL_BLACK
const Fl_Color FL_BLACK
Definition: Enumerations.H:956
FL_TREE_REASON_CLOSED
an item was closed
Definition: Fl_Tree.H:319
Fl_Tree::item_pathname
int item_pathname(char *pathname, int pathnamelen, const Fl_Tree_Item *item) const
Definition: Fl_Tree.cxx:1211
Fl_Tree_Item::children
int children() const
Return the number of children this item has.
Definition: Fl_Tree_Item.H:232
Fl_Tree_Item::x
int x() const
The item's x position relative to the window.
Definition: Fl_Tree_Item.H:137
Fl_Preferences::path
const char * path()
Definition: Fl_Preferences.H:106
Fl_Tree_Item::is_root
int is_root() const
Is this item the root of the tree?
Definition: Fl_Tree_Item.H:502
Fl_Tree::closeicon
Fl_Image * closeicon() const
Definition: Fl_Tree.cxx:2439
Fl_Tree::extend_selection_dir
int extend_selection_dir(Fl_Tree_Item *from, Fl_Tree_Item *to, int dir, int val, bool visible)
Definition: Fl_Tree.cxx:152
FL_TREE_SELECT_SINGLE_DRAGGABLE
reordered by mouse drag.
Definition: Fl_Tree_Prefs.H:72
Fl::event_x
static int event_x()
Definition: Fl.H:598
Fl_Tree::open
int open(Fl_Tree_Item *item, int docallback=1)
Definition: Fl_Tree.cxx:1689
Fl::box_dh
static int box_dh(Fl_Boxtype)
Definition: fl_boxtype.cxx:397
FL_HORIZONTAL
#define FL_HORIZONTAL
The valuator can work horizontally.
Definition: Fl_Valuator.H:31
Fl_Tree.H
This file contains the definitions of the Fl_Tree class.
Fl_Tree::connectorcolor
Fl_Color connectorcolor() const
Get the connector color used for tree connection lines.
Definition: Fl_Tree.cxx:2242
FL_TREE_REASON_DRAGGED
an item was dragged into a new place
Definition: Fl_Tree.H:320
Fl_Widget::w
int w() const
Definition: Fl_Widget.H:294
FL_Down
#define FL_Down
The down arrow key.
Definition: Enumerations.H:483
Fl_Valuator::range
void range(double a, double b)
Definition: Fl_Valuator.H:104
Fl_Tree::_root
Fl_Tree_Item * _root
Definition: Fl_Tree.H:325
Fl_Tree::remove
int remove(Fl_Tree_Item *item)
Definition: Fl_Tree.cxx:1114
Fl::box_dw
static int box_dw(Fl_Boxtype)
Definition: fl_boxtype.cxx:391
Fl_Tree_Sort
Fl_Tree_Sort
Definition: Fl_Tree_Prefs.H:49
Fl_Tree::_vscroll
Fl_Scrollbar * _vscroll
Vertical scrollbar.
Definition: Fl_Tree.H:340
Fl_Tree_Prefs::labelfgcolor
Fl_Color labelfgcolor() const
Obsolete: Get the default label foreground color. Please use item_labelfgcolor() instead.
Definition: Fl_Tree_Prefs.H:211
Fl_Tree::is_selected
int is_selected(Fl_Tree_Item *item) const
Definition: Fl_Tree.cxx:2170
Fl_Widget::color
Fl_Color color() const
Definition: Fl_Widget.H:378
Fl_Tree::select_only
int select_only(Fl_Tree_Item *selitem, int docallback=1)
Definition: Fl_Tree.cxx:2077
Fl_Tree::callback_item
Fl_Tree_Item * callback_item()
Definition: Fl_Tree.cxx:2850
p
static menustate * p
Definition: Fl_Menu.cxx:606
FL_WHEN_CHANGED
Do the callback only when the widget value changes.
Definition: Enumerations.H:441
FL_Left
#define FL_Left
The left arrow key.
Definition: Enumerations.H:480
Fl_Widget::w
void w(int v)
Definition: Fl_Widget.H:143
Fl_Tree::insert_above
Fl_Tree_Item * insert_above(Fl_Tree_Item *above, const char *name)
Definition: Fl_Tree.cxx:1075
dir
static int dir
Definition: fl_draw_image.cxx:67
FL_Right
#define FL_Right
The right arrow key.
Definition: Enumerations.H:482
Fl::box_dy
static int box_dy(Fl_Boxtype)
Definition: fl_boxtype.cxx:385
Fl_Tree::is_scrollbar
int is_scrollbar(Fl_Widget *w)
Definition: Fl_Tree.cxx:2757
Fl_Tree_Item::label
void label(const char *val)
Definition: Fl_Tree_Item.cxx:196
Fl_Tree::extend_selection__
int extend_selection__(Fl_Tree_Item *from, Fl_Tree_Item *to, int val, bool visible)
Definition: Fl_Tree.cxx:198
FL_Tab
#define FL_Tab
The tab key.
Definition: Enumerations.H:469
Fl_Tree::_item_focus
Fl_Tree_Item * _item_focus
Definition: Fl_Tree.H:326
Fl_Tree::close
int close(Fl_Tree_Item *item, int docallback=1)
Definition: Fl_Tree.cxx:1773
Fl_Tree::first
Fl_Tree_Item * first()
Definition: Fl_Tree.cxx:1353
Fl_Tree::last_visible
Fl_Tree_Item * last_visible()
Definition: Fl_Tree.cxx:1438
Fl_Tree_Item_Array::add
void add(Fl_Tree_Item *val)
Definition: Fl_Tree_Item_Array.cxx:154
Fl_Tree::_scrollbar_size
int _scrollbar_size
Definition: Fl_Tree.H:330
Fl_Tree::do_callback_for_item
void do_callback_for_item(Fl_Tree_Item *item, Fl_Tree_Reason reason)
Definition: Fl_Tree.cxx:2834
Fl_Tree::item_clicked
Fl_Tree_Item * item_clicked()
Definition: Fl_Tree.cxx:1314
Fl_Tree_Item::select_toggle
void select_toggle()
Toggle the item's selection state.
Definition: Fl_Tree_Item.H:348
Fl_Tree_Prefs::usericonmarginleft
int usericonmarginleft() const
Get the user icon's left margin value in pixels.
Definition: Fl_Tree_Prefs.H:259
FL_DOWN_BOX
see figure 1
Definition: Enumerations.H:608
Fl_Tree::connectorwidth
int connectorwidth() const
Definition: Fl_Tree.cxx:2380
Fl_Tree_Item::h
int h() const
The item's height.
Definition: Fl_Tree_Item.H:144
Fl_Tree_Item::visible_r
int visible_r() const
Definition: Fl_Tree_Item.cxx:1830
Fl_Tree::root_label
void root_label(const char *new_label)
Definition: Fl_Tree.cxx:967
Fl_Group::array
Fl_Widget *const * array() const
Definition: Fl_Group.cxx:44
parse_path
static char ** parse_path(const char *path)
Definition: Fl_Tree.cxx:40
FL_COMMAND
#define FL_COMMAND
An alias for FL_CTRL on WIN32 and X11, or FL_META on MacOS X.
Definition: Enumerations.H:580
FL_FOCUS
Definition: Enumerations.H:283
Fl_Tree::recalc_tree
void recalc_tree()
Definition: Fl_Tree.cxx:2956
Fl_Tree::margintop
int margintop() const
Definition: Fl_Tree.cxx:2270
Fl_Widget::visible
unsigned int visible() const
Definition: Fl_Widget.H:660
scroll_cb
static void scroll_cb(Fl_Widget *, void *data)
Definition: Fl_Tree.cxx:31
Fl_Widget::hide
virtual void hide()
Definition: Fl_Widget.cxx:283
Fl_Fontsize
int Fl_Fontsize
Definition: Enumerations.H:906
Fl_Scrollbar::value
int value() const
Definition: Fl_Scrollbar.H:65
FL_PUSH
Definition: Enumerations.H:236
Fl_Tree_Item::add
Fl_Tree_Item * add(const Fl_Tree_Prefs &prefs, const char *new_label, Fl_Tree_Item *newitem)
Definition: Fl_Tree_Item.cxx:342
Fl_Widget::damage
uchar damage() const
Definition: Fl_Widget.H:917
Fl_Tree::resize
void resize(int, int, int, int)
Definition: Fl_Tree.cxx:759
Fl::remove_timeout
static void remove_timeout(Fl_Timeout_Handler, void *=0)
Definition: Fl.cxx:368
fl_push_clip
void fl_push_clip(int x, int y, int w, int h)
Definition: fl_draw.H:82
Fl_Tree_Prefs::marginleft
int marginleft() const
Get the left margin's value in pixels.
Definition: Fl_Tree_Prefs.H:223
Fl_Tree::openicon
Fl_Image * openicon() const
Definition: Fl_Tree.cxx:2420
Fl_Widget::redraw
void redraw()
Definition: Fl.cxx:1782
Fl_Tree_Prefs::usericon
Fl_Image * usericon() const
Gets the default 'user icon' (default is 0)
Definition: Fl_Tree_Prefs.H:343
Fl_Widget
Definition: Fl_Widget.H:101
Fl_Valuator::minimum
double minimum() const
Definition: Fl_Valuator.H:77
Fl_Group
Definition: Fl_Group.H:41
Fl::focus
static Fl_Widget * focus()
Definition: Fl.H:840
Fl_Tree::_prefs
Fl_Tree_Prefs _prefs
Definition: Fl_Tree.H:329
Fl_Widget::box
Fl_Boxtype box() const
Definition: Fl_Widget.H:363
Fl_Tree::item_labelbgcolor
Fl_Color item_labelbgcolor(void) const
Definition: Fl_Tree.cxx:2229
Fl_Tree_Item::find_clicked
const Fl_Tree_Item * find_clicked(const Fl_Tree_Prefs &prefs) const
Definition: Fl_Tree_Item.cxx:842
Fl_Tree::fix_scrollbar_order
void fix_scrollbar_order()
Ensure the scrollbars are the last children.
Definition: Fl_Tree.cxx:2934
Fl_Widget::h
int h() const
Definition: Fl_Widget.H:299
Fl_Tree_Item::insert_above
Fl_Tree_Item * insert_above(const Fl_Tree_Prefs &prefs, const char *new_label)
Definition: Fl_Tree_Item.cxx:461
Fl_Tree::display
void display(Fl_Tree_Item *item)
Definition: Fl_Tree.cxx:2685
Fl::event_y
static int event_y()
Definition: Fl.H:603
Fl_Tree::vposition
int vposition() const
Definition: Fl_Tree.cxx:2695
Fl_Tree::select
int select(Fl_Tree_Item *item, int docallback=1)
Definition: Fl_Tree.cxx:1892
Fl_Group::children
int children() const
Definition: Fl_Group.H:75
FL_KEYBOARD
Definition: Enumerations.H:315
Fl_Group::resize
void resize(int, int, int, int)
Definition: Fl_Group.cxx:634
Fl::pushed
static Fl_Widget * pushed()
Definition: Fl.H:837
Fl_Group::init_sizes
void init_sizes()
Definition: Fl_Group.cxx:572
Fl_Widget::h
void h(int v)
Definition: Fl_Widget.H:145
Fl_Tree::selectbox
Fl_Boxtype selectbox() const
Definition: Fl_Tree.cxx:2519
Fl_Tree::next_visible_item
Fl_Tree_Item * next_visible_item(Fl_Tree_Item *start, int dir)
Definition: Fl_Tree.cxx:1338
FL_TREE_CONNECTOR_NONE
Use no lines connecting items.
Definition: Fl_Tree_Prefs.H:59
FL_SELECTION_COLOR
const Fl_Color FL_SELECTION_COLOR
the default selection/highlight color
Definition: Enumerations.H:940
FL_NO_EVENT
Definition: Enumerations.H:223
Fl_Tree_Item_Array
Manages an array of Fl_Tree_Item pointers.
Definition: Fl_Tree_Item_Array.H:47
Fl_Widget::y
void y(int v)
Definition: Fl_Widget.H:141
Fl_Tree::openchild_marginbottom
int openchild_marginbottom() const
Definition: Fl_Tree.cxx:2320
Fl_Tree::Fl_Tree
Fl_Tree(int X, int Y, int W, int H, const char *L=0)
Constructor.
Definition: Fl_Tree.cxx:79
Fl_Widget::set_changed
void set_changed()
Definition: Fl_Widget.H:786
Fl_Tree_Item::prev
Fl_Tree_Item * prev()
Definition: Fl_Tree_Item.cxx:1640
Fl::scrollbar_size
static int scrollbar_size()
Definition: Fl.cxx:196
Fl_Tree::show_item_top
void show_item_top(Fl_Tree_Item *item)
Definition: Fl_Tree.cxx:2651
fl_pop_clip
void fl_pop_clip()
Definition: fl_draw.H:103
Fl_Group::handle
int handle(int)
Definition: Fl_Group.cxx:147
Fl_Widget::size
void size(int W, int H)
Definition: Fl_Widget.H:341
Fl_Tree_Item::next_visible
Fl_Tree_Item * next_visible(Fl_Tree_Prefs &prefs)
Definition: Fl_Tree_Item.cxx:1773
Fl_Slider::slider_size
float slider_size() const
Definition: Fl_Slider.H:87
Fl_Tree_Prefs::openchild_marginbottom
int openchild_marginbottom() const
Get the margin below an open child in pixels.
Definition: Fl_Tree_Prefs.H:251
Fl_Widget::callback
Fl_Callback_p callback() const
Definition: Fl_Widget.H:561
Fl_Font
int Fl_Font
Definition: Enumerations.H:877
Fl_Tree::show_item_bottom
void show_item_bottom(Fl_Tree_Item *item)
Definition: Fl_Tree.cxx:2673
Fl_Tree::extend_selection
void extend_selection(Fl_Tree_Item *from, Fl_Tree_Item *to)
Definition: Fl_Tree.cxx:251
FL_TREE_REASON_OPENED
an item was opened
Definition: Fl_Tree.H:318
FL_BACKGROUND2_COLOR
const Fl_Color FL_BACKGROUND2_COLOR
the default background color for text, list, and valuator widgets
Definition: Enumerations.H:938
Fl_Tree_Connector
Fl_Tree_Connector
Definition: Fl_Tree_Prefs.H:58
Fl::add_timeout
static void add_timeout(double t, Fl_Timeout_Handler, void *=0)
Definition: Fl.cxx:329
Fl_Tree::callback_reason
Fl_Tree_Reason callback_reason() const
Definition: Fl_Tree.cxx:2880
Fl::visible_focus
static int visible_focus()
Definition: Fl.H:1197
Fl_Tree_Item::is_close
int is_close() const
See if the item is 'closed'.
Definition: Fl_Tree_Item.H:334
Fl_Tree::last
Fl_Tree_Item * last()
Definition: Fl_Tree.cxx:1426
Fl_Preferences
Fl_Preferences provides methods to store user settings between application starts.
Definition: Fl_Preferences.H:60
Fl_Tree::next_selected_item
Fl_Tree_Item * next_selected_item(Fl_Tree_Item *item=0)
Definition: Fl_Tree.cxx:1498
Fl_Widget::visible_focus
unsigned int visible_focus()
Definition: Fl_Widget.H:838
Fl_Tree_Item::is_visible
int is_visible() const
See if the item is visible.
Definition: Fl_Tree_Item.H:431
Fl_Tree_Item::has_children
int has_children() const
See if this item has children.
Definition: Fl_Tree_Item.H:242
Fl_Tree::clear_children
void clear_children(Fl_Tree_Item *item)
Definition: Fl_Tree.cxx:1146
FL_TREE_SELECT_MULTI
with SHIFT, CTRL or mouse drags.
Definition: Fl_Tree_Prefs.H:70
Fl_Widget::type
uchar type() const
Definition: Fl_Widget.H:274
Fl_Tree_Prefs::connectorstyle
Fl_Tree_Connector connectorstyle() const
Get the connector style.
Definition: Fl_Tree_Prefs.H:305
Fl_Tree::prefs
const Fl_Tree_Prefs & prefs() const
Definition: Fl_Tree.H:376
Fl_Tree_Item::child
Fl_Tree_Item * child(int index)
Return the child item for the given 'index'.
Definition: Fl_Tree_Item.H:236
Fl_Widget::parent
Fl_Group * parent() const
Definition: Fl_Widget.H:254
malloc
voidp malloc()
Fl_Tree_Item::next
Fl_Tree_Item * next()
Definition: Fl_Tree_Item.cxx:1608
Fl_Tree_Item::clear_children
void clear_children()
Clear all the children for this item.
Definition: Fl_Tree_Item.cxx:213
Fl_Tree_Item_Array::total
int total() const
Return the total items in the array, or 0 if empty.
Definition: Fl_Tree_Item_Array.H:72
Y
static int Y
Definition: Fl_Tooltip.cxx:76
Fl_Tree_Prefs::selectbox
Fl_Boxtype selectbox() const
Get the default selection box's box drawing style as an Fl_Boxtype.
Definition: Fl_Tree_Prefs.H:411
Fl_Tree::find_clicked
const Fl_Tree_Item * find_clicked() const
Definition: Fl_Tree.cxx:1282
Fl_Preferences.H
FL_TREE_REASON_DESELECTED
an item was de-selected
Definition: Fl_Tree.H:314
Fl_Tree::root
Fl_Tree_Item * root()
Returns the root item.
Definition: Fl_Tree.cxx:973
Fl_Tree::get_item_focus
Fl_Tree_Item * get_item_focus() const
Get the item that currently has keyboard focus.
Definition: Fl_Tree.cxx:2145
Fl_Widget::resize
virtual void resize(int x, int y, int w, int h)
Definition: Fl_Widget.cxx:150
FL_LEFT_MOUSE
#define FL_LEFT_MOUSE
The left mouse button.
Definition: Enumerations.H:540
Fl_Tree::hposition
int hposition() const
Definition: Fl_Tree.cxx:2719
Fl_Tree::selectmode
Fl_Tree_Select selectmode() const
Definition: Fl_Tree.cxx:2535
FL_RELEASE
Definition: Enumerations.H:244
Fl_Tree::next_item
Fl_Tree_Item * next_item(Fl_Tree_Item *item, int dir=FL_Down, bool visible=false)
Definition: Fl_Tree.cxx:1567
Fl_Widget::take_focus
int take_focus()
Definition: Fl_Widget.cxx:162
Fl_Tree::show_self
void show_self()
Definition: Fl_Tree.cxx:958
Fl_Tree_Reason
Fl_Tree_Reason
Definition: Fl_Tree.H:311
Fl_Tree::last_selected_item
Fl_Tree_Item * last_selected_item()
Definition: Fl_Tree.cxx:1518
Fl_Tree_Prefs::connectorcolor
Fl_Color connectorcolor() const
Get the connector color used for tree connection lines.
Definition: Fl_Tree_Prefs.H:297
Fl_Tree_Item::parent
Fl_Tree_Item * parent()
Return the parent for this item. Returns NULL if we are the root.
Definition: Fl_Tree_Item.H:296
Fl_Tree::scrollbar_size
int scrollbar_size() const
Definition: Fl_Tree.cxx:2774
Fl_Tree_Item::is_open
int is_open() const
See if the item is 'open'.
Definition: Fl_Tree_Item.H:330
Fl_Tree_Prefs::labelsize
Fl_Fontsize labelsize() const
Obsolete: Return the label's size in pixels. Please use item_labelsize() instead.
Definition: Fl_Tree_Prefs.H:207
name
static const char * name
Definition: Fl_arg.cxx:53
FL_CTRL
#define FL_CTRL
One of the ctrl keys is down.
Definition: Enumerations.H:559
FL_VERTICAL
#define FL_VERTICAL
The valuator can work vertically.
Definition: Fl_Valuator.H:30
Fl_Tree_Item::w
int w() const
Definition: Fl_Tree_Item.H:142
Fl_Tree_Item::show_self
void show_self(const char *indent="") const
Definition: Fl_Tree_Item.cxx:171
redraw_soon
static void redraw_soon(void *data)
Definition: Fl_Tree.cxx:613
FL_DAMAGE_CHILD
Definition: Enumerations.H:1106
Fl_Group::draw_child
void draw_child(Fl_Widget &widget) const
Definition: Fl_Group.cxx:768
Fl_Tree::last_visible_item
Fl_Tree_Item * last_visible_item()
Definition: Fl_Tree.cxx:1447
FL_ENTER
Definition: Enumerations.H:253
Fl_Tree::~Fl_Tree
~Fl_Tree()
Destructor.
Definition: Fl_Tree.cxx:125
Fl_Tree::deselect_all
int deselect_all(Fl_Tree_Item *item=0, int docallback=1)
Definition: Fl_Tree.cxx:2044
Fl_Tree_Prefs::labelfont
Fl_Font labelfont() const
Obsolete: Return the label's font. Please use item_labelfont() instead.
Definition: Fl_Tree_Prefs.H:203
Fl_Tree::displayed
int displayed(Fl_Tree_Item *item)
Definition: Fl_Tree.cxx:2602
Fl_Tree::linespacing
int linespacing() const
Definition: Fl_Tree.cxx:2304
Fl_Tree_Prefs::labelbgcolor
Fl_Color labelbgcolor() const
Obsolete: Get the default label background color. Please use item_labelbgcolor() instead.
Definition: Fl_Tree_Prefs.H:215
Fl_Valuator::step
void step(int a)
Definition: Fl_Valuator.H:106
Fl_Tree_Item::event_on_collapse_icon
int event_on_collapse_icon(const Fl_Tree_Prefs &prefs) const
Definition: Fl_Tree_Item.cxx:1525
Fl_Tree_Prefs::closeicon
Fl_Image * closeicon() const
Definition: Fl_Tree_Prefs.H:338
Fl_Tree_Prefs::margintop
int margintop() const
Get the top margin's value in pixels.
Definition: Fl_Tree_Prefs.H:231
Fl_Tree_Prefs::labelmarginleft
int labelmarginleft() const
Get the label's left margin value in pixels.
Definition: Fl_Tree_Prefs.H:267
Fl_Tree
Tree widget.
Definition: Fl_Tree.H:323
Fl::event_inside
static int event_inside(int, int, int, int)
Definition: Fl.cxx:227
Fl_Tree_Item::move_below
int move_below(Fl_Tree_Item *item)
Definition: Fl_Tree_Item.cxx:598
Fl_Tree::select_toggle
void select_toggle(Fl_Tree_Item *item, int docallback=1)
Definition: Fl_Tree.cxx:1957
Fl_Tree::labelmarginleft
int labelmarginleft() const
Definition: Fl_Tree.cxx:2349
Fl_Tree::item_labelsize
Fl_Fontsize item_labelsize() const
Get the default label fontsize used for creating new items.
Definition: Fl_Tree.cxx:2192
Fl_Tree_Item_Array::clear
void clear()
Definition: Fl_Tree_Item_Array.cxx:82