summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2011-01-30 20:22:06 +0000
committerGreg Ercolano <erco@seriss.com>2011-01-30 20:22:06 +0000
commit2c5006563f893723f0f224d7b3115e5fd03272ca (patch)
treeb23c1eb923d31727f60470607e08ecfef4e476cc
parent31db787583e1b862d1e26acc542a294a9c31fd0e (diff)
Fl_Tree API breaking changes (we haven't released 1.3.0 yet..):
Fl_Tree::labelsize() -> item_labelsize() -- TO AVOID COLLISION WITH Fl_Widget::labelsize()! Fl_Tree::labelfont() -> item_labelfont() -- TO AVOID COLLISION WITH Fl_Widget::labelfont()! Fl_Tree_Prefs (internal) changes: Fl_Tree_Prefs::fgcolor() -> labelfgcolor() -- for consistency with above Fl_Tree_Prefs::bgcolor() -> labelbgcolor() -- for consistency with above Fl_Tree_Prefs::selectcolor() removed -- uses Fl_Widget::selection_color() instead Fl_Tree_Prefs::inactivecolor() removed -- was unused; inactive color procedurally calculated Other Fl_Tree mods: o Fixed bug with select_all(item) and deselect_all(item) (they were not limiting themselves to children of specified item) o Fixed bug with item not drawing in its /own/ bgcolor when item selected o Fl_Tree uses the Fl_Widget::selection_color() o All methods that deal with 'font types' changed int -> Fl_Font o All methods that deal with 'font sizes' changed int -> Fl_Fontsize o Added needed methods to Fl_Tree for accessing colors: item_labelfgcolor() -- access default fg color used for new items item_labelbgcolor() -- access default bg color used for new items tree_connectorcolor() -- access the connector line color o Small doxygen comment adjustments and general clarifications o test/tree demo modified to include testing of new label color methods, cleanup git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8340 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--FL/Fl_Tree.H63
-rw-r--r--FL/Fl_Tree_Item.H12
-rw-r--r--FL/Fl_Tree_Prefs.H62
-rw-r--r--src/Fl_Tree.cxx22
-rw-r--r--src/Fl_Tree_Item.cxx8
-rw-r--r--src/Fl_Tree_Prefs.cxx6
-rw-r--r--test/tree.fl1206
7 files changed, 823 insertions, 556 deletions
diff --git a/FL/Fl_Tree.H b/FL/Fl_Tree.H
index af25e2312..82185d56a 100644
--- a/FL/Fl_Tree.H
+++ b/FL/Fl_Tree.H
@@ -97,6 +97,7 @@
/// next_selected_item().
/// Items can be found by their pathname using find_item(const char*),
/// and an item's pathname can be found with item_pathname().
+/// The selected items' colors are controlled by selection_color() (inherited from Fl_Widget).
///
/// The tree can have different selection behaviors controlled by selectmode().
///
@@ -604,36 +605,57 @@ public:
/////////////////////////////////
/// Get the default label fontsize used for creating new items.
- int labelsize() const {
+ Fl_Fontsize item_labelsize() const {
return(_prefs.labelsize());
}
/// Set the default label font size used for creating new items.
- /// To change the font size on a per-item basis, use Fl_Tree_Item::labelsize(int)
+ /// To change the font size on a per-item basis, use Fl_Tree_Item::labelsize(Fl_Fontsize)
///
- void labelsize(int val) {
+ void item_labelsize(Fl_Fontsize val) {
_prefs.labelsize(val);
}
-
- /// Get the default font face used for item's labels when new items are created.
- ///
- /// Don't use this if you want to change an existing label() size; use
- /// item->labelfont() instead.
- ///
- int labelfont() const {
+ /// Get the default font face used for creating new items.
+ Fl_Font item_labelfont() const {
return(_prefs.labelfont());
}
- /// Set the default font face used for item's labels when new items are created.
- ///
- /// Don't use this if you want to change an existing label() size; use
- /// item->labelfont(int) instead.
+ /// Set the default font face used for creating new items.
+ /// To change the font face on a per-item basis, use Fl_Tree_Item::labelfont(Fl_Font)
///
- void labelfont(int val) {
+ void item_labelfont(Fl_Font val) {
_prefs.labelfont(val);
}
+ /// Get the default label foreground color used for creating new items.
+ Fl_Color item_labelfgcolor(void) const {
+ return(_prefs.labelfgcolor());
+ }
+ /// Set the default label foreground color used for creating new items.
+ /// To change the foreground color on a per-item basis, use Fl_Tree_Item::labelfgcolor(Fl_Color)
+ ///
+ void item_labelfgcolor(Fl_Color val) {
+ _prefs.labelfgcolor(val);
+ }
+ /// Get the default label background color used for creating new items.
+ Fl_Color item_labelbgcolor(void) const {
+ return(_prefs.labelbgcolor());
+ }
+ /// Set the default label background color used for creating new items.
+ /// To change the background color on a per-item basis, use Fl_Tree_Item::labelbgcolor(Fl_Color)
+ ///
+ void item_labelbgcolor(Fl_Color val) {
+ _prefs.labelbgcolor(val);
+ }
+ /// Get the connector color used for tree connection lines.
+ Fl_Color connectorcolor() const {
+ return(_prefs.connectorcolor());
+ }
+ /// Set the connector color used for tree connection lines.
+ void connectorcolor(Fl_Color val) {
+ _prefs.connectorcolor(val);
+ }
/// Get the amount of white space (in pixels) that should appear
/// between the widget's left border and the tree's contents.
///
- int marginleft() const {
+ int marginleft() const {
return(_prefs.marginleft());
}
/// Set the amount of white space (in pixels) that should appear
@@ -646,7 +668,7 @@ public:
/// Get the amount of white space (in pixels) that should appear
/// between the widget's top border and the top of the tree's contents.
///
- int margintop() const {
+ int margintop() const {
return(_prefs.margintop());
}
/// Sets the amount of white space (in pixels) that should appear
@@ -659,7 +681,7 @@ public:
/// Get the amount of white space (in pixels) that should appear
/// below an open child tree's contents.
///
- int openchild_marginbottom() const {
+ int openchild_marginbottom() const {
return(_prefs.openchild_marginbottom());
}
/// Set the amount of white space (in pixels) that should appear
@@ -672,7 +694,7 @@ public:
/// Gets the width of the horizontal connection lines (in pixels)
/// that appear to the left of each tree item's label.
///
- int connectorwidth() const {
+ int connectorwidth() const {
return(_prefs.connectorwidth());
}
/// Sets the width of the horizontal connection lines (in pixels)
@@ -682,7 +704,8 @@ public:
_prefs.connectorwidth(val);
redraw();
}
- /// Returns the Fl_Image being used as the default user icon for newly created items.
+ /// Returns the Fl_Image being used as the default user icon for all
+ /// newly created items.
/// Returns zero if no icon has been set, which is the default.
///
Fl_Image *usericon() const {
diff --git a/FL/Fl_Tree_Item.H b/FL/Fl_Tree_Item.H
index 3163668ed..c5a742ad9 100644
--- a/FL/Fl_Tree_Item.H
+++ b/FL/Fl_Tree_Item.H
@@ -58,8 +58,8 @@
///
class FL_EXPORT Fl_Tree_Item {
const char *_label; // label (memory managed)
- int _labelfont; // label's font face
- int _labelsize; // label's font size
+ Fl_Font _labelfont; // label's font face
+ Fl_Fontsize _labelsize; // label's font size
Fl_Color _labelfgcolor; // label's fg color
Fl_Color _labelbgcolor; // label's bg color
char _open; // item is open?
@@ -99,19 +99,19 @@ public:
inline void* user_data() const { return _userdata; }
/// Set item's label font face.
- void labelfont(int val) {
+ void labelfont(Fl_Font val) {
_labelfont = val;
}
/// Get item's label font face.
- int labelfont() const {
+ Fl_Font labelfont() const {
return(_labelfont);
}
/// Set item's label font size.
- void labelsize(int val) {
+ void labelsize(Fl_Fontsize val) {
_labelsize = val;
}
/// Get item's label font size.
- int labelsize() const {
+ Fl_Fontsize labelsize() const {
return(_labelsize);
}
/// Set item's label foreground text color.
diff --git a/FL/Fl_Tree_Prefs.H b/FL/Fl_Tree_Prefs.H
index 59773c3b8..81868263c 100644
--- a/FL/Fl_Tree_Prefs.H
+++ b/FL/Fl_Tree_Prefs.H
@@ -83,8 +83,8 @@ enum Fl_Tree_Select {
/// instead of trying to accessing tree's preferences settings directly.
///
class FL_EXPORT Fl_Tree_Prefs {
- int _labelfont; // label's font face
- int _labelsize; // label's font size
+ Fl_Font _labelfont; // label's font face
+ Fl_Fontsize _labelsize; // label's font size
int _margintop; // --
int _marginleft; // |- tree's margins
//int _marginright; // |
@@ -95,10 +95,8 @@ class FL_EXPORT Fl_Tree_Prefs {
int _connectorwidth; // connector width (right of open/close icon)
int _linespacing; // vertical space between lines
// Colors
- Fl_Color _fgcolor; // label's foreground color
- Fl_Color _bgcolor; // background color
- Fl_Color _selectcolor; // selection color
- Fl_Color _inactivecolor; // inactive color
+ Fl_Color _labelfgcolor; // label's foreground color
+ Fl_Color _labelbgcolor; // background color
Fl_Color _connectorcolor; // connector dotted line color
Fl_Tree_Connector _connectorstyle; // connector line style
Fl_Image *_openimage; // the 'open' icon [+]
@@ -116,19 +114,19 @@ public:
// Labels
////////////////////////////
/// Return the label's font.
- inline int labelfont() const {
+ inline Fl_Font labelfont() const {
return(_labelfont);
}
/// Set the label's font to \p val.
- inline void labelfont(int val) {
+ inline void labelfont(Fl_Font val) {
_labelfont = val;
}
/// Return the label's size in pixels.
- inline int labelsize() const {
+ inline Fl_Fontsize labelsize() const {
return(_labelsize);
}
/// Set the label's size in pixels to \p val.
- inline void labelsize(int val) {
+ inline void labelsize(Fl_Fontsize val) {
_labelsize = val;
}
@@ -204,50 +202,34 @@ public:
// Colors and Styles
////////////////////////////
/// Get the default label foreground color
- inline Fl_Color fgcolor() const {
- return(_fgcolor);
+ inline Fl_Color labelfgcolor() const {
+ return(_labelfgcolor);
}
/// Set the default label foreground color
- inline void fgcolor(Fl_Color val) {
- _fgcolor = val;
+ inline void labelfgcolor(Fl_Color val) {
+ _labelfgcolor = val;
}
/// Get the default label background color
- inline Fl_Color bgcolor() const {
- return(_bgcolor);
+ inline Fl_Color labelbgcolor() const {
+ return(_labelbgcolor);
}
/// Set the default label background color
- inline void bgcolor(Fl_Color val) {
- _bgcolor = val;
+ inline void labelbgcolor(Fl_Color val) {
+ _labelbgcolor = val;
}
- /// Get the default selection color
- inline Fl_Color selectcolor() const {
- return(_selectcolor);
- }
- /// Set the default selection color
- inline void selectcolor(Fl_Color val) {
- _selectcolor = val;
- }
- /// Get the default inactive color
- inline Fl_Color inactivecolor() const {
- return(_inactivecolor);
- }
- /// Set the default inactive color
- inline void inactivecolor(Fl_Color val) {
- _inactivecolor = val;
- }
- /// Get the connector color; the color used for tree connection lines
+ /// Get the connector color used for tree connection lines.
inline Fl_Color connectorcolor() const {
return(_connectorcolor);
}
- /// Set the connector color; the color used for tree connection lines
+ /// Set the connector color used for tree connection lines.
inline void connectorcolor(Fl_Color val) {
_connectorcolor = val;
}
- /// Get the connector style
+ /// Get the connector style.
inline Fl_Tree_Connector connectorstyle() const {
return(_connectorstyle);
}
- /// Set the connector style
+ /// Set the connector style.
inline void connectorstyle(Fl_Tree_Connector val) {
_connectorstyle = val;
}
@@ -255,11 +237,11 @@ public:
inline void connectorstyle(int val) {
_connectorstyle = Fl_Tree_Connector(val);
}
- /// Get the tree connection line's width
+ /// Get the tree connection line's width.
inline int connectorwidth() const {
return(_connectorwidth);
}
- /// Set the tree connection line's width
+ /// Set the tree connection line's width.
inline void connectorwidth(int val) {
_connectorwidth = val;
}
diff --git a/src/Fl_Tree.cxx b/src/Fl_Tree.cxx
index 5d29b7cfe..fe3a8e267 100644
--- a/src/Fl_Tree.cxx
+++ b/src/Fl_Tree.cxx
@@ -697,10 +697,13 @@ int Fl_Tree::deselect_all(Fl_Tree_Item *item, int docallback) {
item = item ? item : first(); // NULL? use first()
if ( ! item ) return(0);
int count = 0;
- for ( ; item; item = next(item) ) {
- if ( item->is_selected() )
- if ( deselect(item, docallback) )
- ++count;
+ // Deselect item
+ if ( item->is_selected() )
+ if ( deselect(item, docallback) )
+ ++count;
+ // Deselect its children
+ for ( int t=0; t<item->children(); t++ ) {
+ count += deselect_all(item->child(t), docallback); // recurse
}
return(count);
}
@@ -726,10 +729,13 @@ int Fl_Tree::select_all(Fl_Tree_Item *item, int docallback) {
item = item ? item : first(); // NULL? use first()
if ( ! item ) return(0);
int count = 0;
- for ( ; item; item = next(item) ) {
- if ( !item->is_selected() )
- if ( select(item, docallback) )
- ++count;
+ // Select item
+ if ( !item->is_selected() )
+ if ( select(item, docallback) )
+ ++count;
+ // Select its children
+ for ( int t=0; t<item->children(); t++ ) {
+ count += select_all(item->child(t), docallback); // recurse
}
return(count);
}
diff --git a/src/Fl_Tree_Item.cxx b/src/Fl_Tree_Item.cxx
index 15a45833a..329c0ef33 100644
--- a/src/Fl_Tree_Item.cxx
+++ b/src/Fl_Tree_Item.cxx
@@ -44,8 +44,8 @@ Fl_Tree_Item::Fl_Tree_Item(const Fl_Tree_Prefs &prefs) {
_label = 0;
_labelfont = prefs.labelfont();
_labelsize = prefs.labelsize();
- _labelfgcolor = prefs.fgcolor();
- _labelbgcolor = prefs.bgcolor();
+ _labelfgcolor = prefs.labelfgcolor();
+ _labelbgcolor = prefs.labelbgcolor();
_widget = 0;
_open = 1;
_visible = 1;
@@ -562,8 +562,8 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree,
W += prefs.openicon()->w();
}
// Colors, fonts
- Fl_Color fg = _selected ? prefs.bgcolor() : _labelfgcolor;
- Fl_Color bg = _selected ? prefs.selectcolor() : _labelbgcolor;
+ Fl_Color fg = _selected ? _labelbgcolor : _labelfgcolor; // selected uses bgcolor, unselected uses fgcolor
+ Fl_Color bg = _selected ? tree->selection_color() : _labelbgcolor; // selected uses selectcolor, unselected uses bgcolor
if ( ! _active ) {
fg = fl_inactive(fg);
if ( _selected ) bg = fl_inactive(bg);
diff --git a/src/Fl_Tree_Prefs.cxx b/src/Fl_Tree_Prefs.cxx
index 7884c2afc..df5f856ac 100644
--- a/src/Fl_Tree_Prefs.cxx
+++ b/src/Fl_Tree_Prefs.cxx
@@ -136,10 +136,8 @@ Fl_Tree_Prefs::Fl_Tree_Prefs() {
_usericonmarginleft = 3;
_labelmarginleft = 3;
_linespacing = 0;
- _fgcolor = FL_BLACK;
- _bgcolor = FL_WHITE;
- _selectcolor = FL_DARK_BLUE;
- _inactivecolor = FL_GRAY;
+ _labelfgcolor = FL_BLACK;
+ _labelbgcolor = FL_WHITE;
_connectorcolor = Fl_Color(43);
#ifdef __APPLE__
_connectorstyle = FL_TREE_CONNECTOR_NONE;
diff --git a/test/tree.fl b/test/tree.fl
index 6316f8fcf..bb604b1c0 100644
--- a/test/tree.fl
+++ b/test/tree.fl
@@ -29,11 +29,15 @@ decl {\#include <FL/Fl_File_Chooser.H>} {public global
decl {\#include <FL/Fl_Preferences.H>} {public global
}
+decl {\#include <FL/Fl_Color_Chooser.H>} {public global
+}
+
decl {int G_cb_counter = 0;} {
comment {// Global callback event counter} private local
}
-Function {reason_as_name(Fl_Tree_Reason reason)} {open return_type {const char*}
+Function {reason_as_name(Fl_Tree_Reason reason)} {
+ comment {Return an Fl_Tree_Reason as a text string name} return_type {const char*}
} {
code {switch ( reason ) {
case FL_TREE_REASON_NONE: return("none");
@@ -50,7 +54,9 @@ Function {Button_CB(Fl_Widget*w, void*data)} {return_type void
code {fprintf(stderr, "'%s' button pushed\\n", w->label());} {}
}
-Function {RebuildTree()} {} {
+Function {RebuildTree()} {
+ comment {Rebuild the 'example tree' from scratch}
+} {
code {// REBUILD THE TREE TO MAKE CURRENT "DEFAULT" PREFS TAKE EFFECT
tree->clear();
tree->add("Aaa");
@@ -138,13 +144,28 @@ tree->close("500 Items"); // close the 500 items by default
tree->redraw();} {}
}
+Function {EditColor(Fl_Color val)} {
+ comment {Prompt the user to change the specified color} return_type Fl_Color
+} {
+ code {uchar r,g,b;
+// Get the current color
+Fl::get_color(val,r,g,b);
+
+// Bring up a color chooser to edit it
+fl_color_chooser("Choose Color",r,g,b);
+
+// Return the new color the user picked
+return(fl_rgb_color(r,g,b));} {}
+}
+
Function {} {open
} {
Fl_Window window {
label tree open
- xywh {1153 115 580 695} type Double visible
+ xywh {800 102 1015 420} type Double visible
} {
Fl_Group tree {
+ label Tree
user_data 1234
callback {G_cb_counter++; // Increment callback counter whenever tree callback is invoked
@@ -158,157 +179,56 @@ if ( item ) {
fprintf(stderr, "TREE CALLBACK: reason=%s item=(no item -- probably multiple items were changed at once)\\n",
reason_as_name(tree->callback_reason()));
}} open
- xywh {15 15 550 390} box DOWN_BOX color 55
+ tooltip {Test tree} xywh {15 22 280 385} box DOWN_BOX color 55 selection_color 15
class Fl_Tree
} {}
- Fl_Value_Slider margintop_slider {
- label {margintop()}
- user_data tree
- callback {int val = (int)margintop_slider->value();
+ Fl_Group {} {open selected
+ xywh {300 5 705 410}
+ code0 {o->resizable(0);}
+ } {
+ Fl_Box {} {
+ label {Tree Globals}
+ tooltip {These controls only affect the selected items. If no items are selected, all existing items in tree are modified.} xywh {311 23 335 241} box GTK_DOWN_BOX color 47 labelsize 12 align 1
+ }
+ Fl_Value_Slider margintop_slider {
+ label {margintop()}
+ user_data tree
+ callback {int val = (int)margintop_slider->value();
tree->margintop(val);
tree->redraw();}
- tooltip {Changes the top margin for the tree widget} xywh {190 414 240 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12
- code0 {o->value(tree->margintop());}
- code1 {o->range(0.0, 100.0);}
- code2 {o->step(1.0);}
- code3 {o->color(46); o->selection_color(FL_RED);}
- }
- Fl_Value_Slider marginleft_slider {
- label {marginleft()}
- user_data tree
- callback {int val = (int)marginleft_slider->value();
+ tooltip {Changes the top margin for the tree widget} xywh {486 31 140 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12
+ code0 {o->value(tree->margintop());}
+ code1 {o->range(0.0, 100.0);}
+ code2 {o->step(1.0);}
+ code3 {o->color(46); o->selection_color(FL_RED);}
+ }
+ Fl_Value_Slider marginleft_slider {
+ label {marginleft()}
+ user_data tree
+ callback {int val = (int)marginleft_slider->value();
tree->marginleft(val);
tree->redraw();}
- tooltip {Changes the left margin for the tree widget} xywh {190 434 240 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12
- code0 {o->value(tree->marginleft());}
- code1 {o->range(0.0, 100.0);}
- code2 {o->step(1.0);}
- code3 {o->color(46); o->selection_color(FL_RED);}
- }
- Fl_Value_Slider openchild_marginbottom_slider {
- label {openchild_marginbottom()}
- user_data tree
- callback {int val = (int)openchild_marginbottom_slider->value();
+ tooltip {Changes the left margin for the tree widget} xywh {486 51 140 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12
+ code0 {o->value(tree->marginleft());}
+ code1 {o->range(0.0, 100.0);}
+ code2 {o->step(1.0);}
+ code3 {o->color(46); o->selection_color(FL_RED);}
+ }
+ Fl_Value_Slider openchild_marginbottom_slider {
+ label {openchild_marginbottom()}
+ user_data tree
+ callback {int val = (int)openchild_marginbottom_slider->value();
tree->openchild_marginbottom(val);
tree->redraw();}
- tooltip {Changes the vertical space below an open child tree} xywh {190 454 240 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12
- code0 {o->value(tree->openchild_marginbottom());}
- code1 {o->range(0.0, 100.0);}
- code2 {o->step(1.0);}
- code3 {o->color(46); o->selection_color(FL_RED);}
- }
- Fl_Value_Slider labelsize_slider {
- label {Text size}
- user_data tree
- callback {int size = (int)labelsize_slider->value();
-
-// DO SELECTED ITEMS
-int count = 0;
-for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
- if ( item->is_selected() ) {
- item->labelsize(size);
- count++;
- }
-}
-
-// NO ITEMS SELECTED? DO ALL
-if ( ! count ) {
- for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
- item->labelsize(size);
- }
-}
-
-tree->redraw();}
- tooltip {Changes the font size of the selected items
-If none selected, all are changed} xywh {190 474 240 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12
- code0 {o->value(tree->labelsize());}
- code1 {o->range(5.0, 200.0);}
- code2 {o->step(1.0);}
- code3 {o->color(46); o->selection_color(FL_RED);}
- }
- Fl_Value_Slider connectorwidth_slider {
- label {Connector width}
- user_data tree
- callback {tree->connectorwidth((int)connectorwidth_slider->value());}
- tooltip {Tests Fl_Tree::connectorwidth()} xywh {190 494 240 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12
- code0 {o->value(tree->connectorwidth());}
- code1 {o->range(1.0, 100.0);}
- code2 {o->step(1.0);}
- code3 {o->color(46); o->selection_color(FL_RED);}
- }
- Fl_Check_Button usericon_radio {
- label {Enable user icons?}
- user_data tree
- callback {static const char *L_folder_xpm[] = {
- "11 11 3 1",
- ". c None",
- "x c \#d8d833",
- "@ c \#808011",
- "...........",
- ".....@@@@..",
- "....@xxxx@.",
- "@@@@@xxxx@@",
- "@xxxxxxxxx@",
- "@xxxxxxxxx@",
- "@xxxxxxxxx@",
- "@xxxxxxxxx@",
- "@xxxxxxxxx@",
- "@xxxxxxxxx@",
- "@@@@@@@@@@@"};
-static Fl_Pixmap L_folderpixmap(L_folder_xpm);
-
-static const char *L_document_xpm[] = {
- "11 11 3 1",
- ". c None",
- "x c \#d8d8f8",
- "@ c \#202060",
- ".@@@@@@@@@.",
- ".@xxxxxxx@.",
- ".@xxxxxxx@.",
- ".@xxxxxxx@.",
- ".@xxxxxxx@.",
- ".@xxxxxxx@.",
- ".@xxxxxxx@.",
- ".@xxxxxxx@.",
- ".@xxxxxxx@.",
- ".@xxxxxxx@.",
- ".@@@@@@@@@."};
-static Fl_Pixmap L_documentpixmap(L_document_xpm);
-
-Fl_Tree_Item *i = 0;
-if ( usericon_radio->value() ) {
- tree->usericon(&L_folderpixmap);
- if ( ( i = tree->find_item("Bbb/bgb/111") ) != NULL ) i->usericon(&L_documentpixmap);
- if ( ( i = tree->find_item("Bbb/bgb/222") ) != NULL ) i->usericon(&L_documentpixmap);
- if ( ( i = tree->find_item("Bbb/bgb/333") ) != NULL ) i->usericon(&L_documentpixmap);
-} else {
- tree->usericon(0);
- if ( ( i = tree->find_item("Bbb/bgb/111") ) != NULL ) i->usericon(0);
- if ( ( i = tree->find_item("Bbb/bgb/222") ) != NULL ) i->usericon(0);
- if ( ( i = tree->find_item("Bbb/bgb/333") ) != NULL ) i->usericon(0);
-}}
- tooltip {Tests Fl_Tree_Item::usericon()} xywh {90 525 130 16} down_box DOWN_BOX labelsize 11
- }
- Fl_Check_Button showroot_radio {
- label {Show root?}
- user_data tree
- callback {int onoff = showroot_radio->value();
-tree->showroot(onoff);}
- tooltip {Tests Fl_Tree_Item::usericon()} xywh {90 542 130 16} down_box DOWN_BOX labelsize 11
- code0 {int onoff = tree->showroot(); showroot_radio->value(onoff);}
- }
- Fl_Check_Button visiblefocus_checkbox {
- label {Visible focus?}
- user_data tree
- callback {int onoff = visiblefocus_checkbox->value();
-tree->visible_focus(onoff);}
- tooltip {Toggles the tree's visible_focus()
-This toggles the visible 'focus box'} xywh {90 559 130 16} down_box DOWN_BOX labelsize 11
- code0 {int onoff = tree->visible_focus(); visiblefocus_checkbox->value(onoff);}
- }
- Fl_Choice collapseicons_chooser {
- label {Collapse icons}
- callback {static const char *L_open_xpm[] = {
+ tooltip {Changes the vertical space below an open child tree} xywh {486 71 140 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12
+ code0 {o->value(tree->openchild_marginbottom());}
+ code1 {o->range(0.0, 100.0);}
+ code2 {o->step(1.0);}
+ code3 {o->color(46); o->selection_color(FL_RED);}
+ }
+ Fl_Choice collapseicons_chooser {
+ label {Collapse icons}
+ callback {static const char *L_open_xpm[] = {
\#ifdef __APPLE__
"11 11 3 1",
". c \#fefefe",
@@ -394,331 +314,241 @@ switch ( collapseicons_chooser->value() ) {
case 2:
tree->showcollapse(0);
break;
-}} open
- tooltip {Tests Fl_Tree::openicon() and Fl_Tree::closeicon()} xywh {115 589 110 16} down_box BORDER_BOX labelsize 11 textsize 11
- } {
- MenuItem {} {
- label Normal
- xywh {0 0 36 21} labelsize 11
- }
- MenuItem {} {
- label Custom
- xywh {10 10 36 21} labelsize 11
- }
- MenuItem {} {
- label Off
- xywh {20 20 36 21} labelsize 11
+}}
+ tooltip {Tests Fl_Tree::openicon() and Fl_Tree::closeicon()} xywh {486 96 140 18} down_box BORDER_BOX labelsize 12 textsize 11
+ } {
+ MenuItem {} {
+ label Normal
+ xywh {10 10 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label Custom
+ xywh {20 20 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label Off
+ xywh {30 30 36 21} labelsize 12
+ }
}
- }
- Fl_Choice connectorstyle_chooser {
- label {Line style}
- callback {// CHANGE COLLAPSESTYLE
+ Fl_Choice connectorstyle_chooser {
+ label {Line style}
+ callback {// CHANGE COLLAPSESTYLE
switch ( connectorstyle_chooser->value() ) {
case 0: tree->connectorstyle(FL_TREE_CONNECTOR_NONE); break;
case 1: tree->connectorstyle(FL_TREE_CONNECTOR_DOTTED); break;
case 2: tree->connectorstyle(FL_TREE_CONNECTOR_SOLID); break;
-}} open
- tooltip {Tests connectorstyle() bit flags} xywh {115 609 110 16} down_box BORDER_BOX labelsize 11 textsize 11
- code0 {switch (tree->connectorstyle()) { case FL_TREE_CONNECTOR_NONE: connectorstyle_chooser->value(0); break; case FL_TREE_CONNECTOR_DOTTED: connectorstyle_chooser->value(1); break; case FL_TREE_CONNECTOR_SOLID: connectorstyle_chooser->value(2); break; }}
- } {
- MenuItem {} {
- label None
- xywh {30 30 36 21} labelsize 11
- }
- MenuItem {} {
- label Dotted
- xywh {10 10 36 21} labelsize 11
- }
- MenuItem {} {
- label Solid
- xywh {20 20 36 21} labelsize 11
- }
- }
- Fl_Choice labelcolor_chooser {
- label {Item Text Color}
- callback {// Set color..
-Fl_Color c = Fl_Color(0x00000000);
-switch ( labelcolor_chooser->value() ) {
- case 0: c = Fl_Color(0x00000000); break; // black
- case 1: c = Fl_Color(0xd0000000); break; // red
- case 2: c = Fl_Color(0x00a00000); break; // green
- case 3: c = Fl_Color(0x0000a000); break; // blue
- default: c = Fl_Color(0x00000000); break; // black
-}
-
-// DO SELECTED ITEMS
-int count = 0;
- for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
- if ( item->is_selected() ) {
- item->labelcolor(c);
- count++;
- }
-}
-
-// NO ITEMS SELECTED? DO ALL
-if ( ! count ) {
- for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
- item->labelcolor(c);
- }
-}
-
-tree->redraw();} open
- tooltip {Changes the label color for the selected items
-If no items selected, all are changed} xywh {115 629 110 16} down_box BORDER_BOX labelsize 11 textsize 11
- } {
- MenuItem {} {
- label Black
- xywh {20 20 36 21} labelsize 11
- }
- MenuItem {} {
- label Red
- xywh {30 30 36 21} labelsize 11
- }
- MenuItem {} {
- label Green
- xywh {40 40 36 21} labelsize 11
- }
- MenuItem {} {
- label Blue
- xywh {50 50 36 21} labelsize 11
+}}
+ tooltip {Tests connectorstyle() bit flags} xywh {486 116 140 18} down_box BORDER_BOX labelsize 12 textsize 11
+ code0 {switch (tree->connectorstyle()) { case FL_TREE_CONNECTOR_NONE: connectorstyle_chooser->value(0); break; case FL_TREE_CONNECTOR_DOTTED: connectorstyle_chooser->value(1); break; case FL_TREE_CONNECTOR_SOLID: connectorstyle_chooser->value(2); break; }}
+ } {
+ MenuItem {} {
+ label None
+ xywh {40 40 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label Dotted
+ xywh {20 20 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label Solid
+ xywh {30 30 36 21} labelsize 12
+ }
}
- }
- Fl_Choice selectmode_chooser {
- label {Selection Mode}
- callback {// Set selection mode
+ Fl_Choice selectmode_chooser {
+ label {Selection Mode}
+ callback {// Set selection mode
switch ( selectmode_chooser->value() ) {
case 0: tree->selectmode(FL_TREE_SELECT_NONE); break; // None
case 1: tree->selectmode(FL_TREE_SELECT_SINGLE); break; // Single
case 2: tree->selectmode(FL_TREE_SELECT_MULTI); break; // Multi
default: tree->selectmode(FL_TREE_SELECT_SINGLE); break; // Single
}}
- tooltip {Sets how Fl_Tree handles mouse selection of tree items} xywh {115 649 110 16} down_box BORDER_BOX labelsize 11 textsize 11
- code0 {selectmode_chooser->value(1);}
- code1 {cb_selectmode_chooser(selectmode_chooser, (void*)0);}
- } {
- MenuItem {} {
- label None
- xywh {30 30 36 21} labelsize 11
- }
- MenuItem {} {
- label Single
- xywh {40 40 36 21} labelsize 11
- }
- MenuItem {} {
- label Multi
- xywh {50 50 36 21} labelsize 11
+ tooltip {Sets how Fl_Tree handles mouse selection of tree items} xywh {486 136 140 18} down_box BORDER_BOX labelsize 12 textsize 11
+ code0 {selectmode_chooser->value(1);}
+ code1 {cb_selectmode_chooser(selectmode_chooser, (void*)0);}
+ } {
+ MenuItem {} {
+ label None
+ xywh {40 40 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label Single
+ xywh {50 50 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label Multi
+ xywh {60 60 36 21} labelsize 12
+ }
}
- }
- Fl_Choice whenmode_chooser {
- label When
- callback {// Set when mode
+ Fl_Choice whenmode_chooser {
+ label When
+ callback {// Set when mode
switch ( whenmode_chooser->value() ) {
case 0: tree->when(FL_WHEN_RELEASE); break;
case 1: tree->when(FL_WHEN_CHANGED); break;
case 2: tree->when(FL_WHEN_NEVER); break;
default: tree->when(FL_WHEN_RELEASE); break;
-}} open
- tooltip {Sets when() the tree's callback is invoked} xywh {115 669 110 16} down_box BORDER_BOX labelsize 11 textsize 11
- code0 {whenmode_chooser->value(1);}
- code1 {cb_whenmode_chooser(whenmode_chooser, (void*)0);}
- } {
- MenuItem {} {
- label Changed
- xywh {40 40 36 21} labelsize 11
+}}
+ tooltip {Sets when() the tree's callback is invoked} xywh {486 156 140 18} down_box BORDER_BOX labelsize 12 textsize 11
+ code0 {whenmode_chooser->value(1);}
+ code1 {cb_whenmode_chooser(whenmode_chooser, (void*)0);}
+ } {
+ MenuItem {} {
+ label Changed
+ xywh {50 50 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label Released
+ xywh {60 60 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label Never
+ xywh {70 70 36 21} labelsize 12
+ }
}
- MenuItem {} {
- label Released
- xywh {50 50 36 21} labelsize 11
+ Fl_Check_Button usericon_radio {
+ label {Enable user icons?}
+ user_data tree
+ callback {static const char *L_folder_xpm[] = {
+ "11 11 3 1",
+ ". c None",
+ "x c \#d8d833",
+ "@ c \#808011",
+ "...........",
+ ".....@@@@..",
+ "....@xxxx@.",
+ "@@@@@xxxx@@",
+ "@xxxxxxxxx@",
+ "@xxxxxxxxx@",
+ "@xxxxxxxxx@",
+ "@xxxxxxxxx@",
+ "@xxxxxxxxx@",
+ "@xxxxxxxxx@",
+ "@@@@@@@@@@@"};
+static Fl_Pixmap L_folderpixmap(L_folder_xpm);
+
+static const char *L_document_xpm[] = {
+ "11 11 3 1",
+ ". c None",
+ "x c \#d8d8f8",
+ "@ c \#202060",
+ ".@@@@@@@@@.",
+ ".@xxxxxxx@.",
+ ".@xxxxxxx@.",
+ ".@xxxxxxx@.",
+ ".@xxxxxxx@.",
+ ".@xxxxxxx@.",
+ ".@xxxxxxx@.",
+ ".@xxxxxxx@.",
+ ".@xxxxxxx@.",
+ ".@xxxxxxx@.",
+ ".@@@@@@@@@."};
+static Fl_Pixmap L_documentpixmap(L_document_xpm);
+
+Fl_Tree_Item *i = 0;
+if ( usericon_radio->value() ) {
+ tree->usericon(&L_folderpixmap);
+ if ( ( i = tree->find_item("Bbb/bgb/111") ) != NULL ) i->usericon(&L_documentpixmap);
+ if ( ( i = tree->find_item("Bbb/bgb/222") ) != NULL ) i->usericon(&L_documentpixmap);
+ if ( ( i = tree->find_item("Bbb/bgb/333") ) != NULL ) i->usericon(&L_documentpixmap);
+} else {
+ tree->usericon(0);
+ if ( ( i = tree->find_item("Bbb/bgb/111") ) != NULL ) i->usericon(0);
+ if ( ( i = tree->find_item("Bbb/bgb/222") ) != NULL ) i->usericon(0);
+ if ( ( i = tree->find_item("Bbb/bgb/333") ) != NULL ) i->usericon(0);
+}}
+ tooltip {Tests Fl_Tree_Item::usericon()} xywh {486 182 20 16} down_box DOWN_BOX labelsize 12 align 7
}
- MenuItem {} {
- label Never
- xywh {60 60 36 21} labelsize 11
+ Fl_Check_Button showroot_radio {
+ label {Show root?}
+ user_data tree
+ callback {int onoff = showroot_radio->value();
+tree->showroot(onoff);}
+ tooltip {Tests tree->showroot();} xywh {486 199 20 16} down_box DOWN_BOX labelsize 12 align 7
+ code0 {int onoff = tree->showroot(); showroot_radio->value(onoff);}
}
- }
- Fl_Box showitem_box {
- label {show_item()
+ Fl_Check_Button visiblefocus_checkbox {
+ label {Visible focus?}
+ user_data tree
+ callback {int onoff = visiblefocus_checkbox->value();
+tree->visible_focus(onoff);}
+ tooltip {Toggles the tree's visible_focus() box} xywh {486 216 20 16} down_box DOWN_BOX labelsize 12 align 7
+ code0 {int onoff = tree->visible_focus(); visiblefocus_checkbox->value(onoff);}
+ }
+ Fl_Button selection_color_button {
+ label {Selection Color}
+ callback {Fl_Color val = EditColor(tree->selection_color()); // Get color of first item in tree
+selection_color_button->color(val); // update modified color to button
+tree->selection_color(val);
+tree->redraw();}
+ tooltip {Changes the tree widget's selection color. Tests Fl_Tree::selection_color()} xywh {486 239 16 16} box DOWN_BOX labelsize 12 align 7
+ code0 {o->color(tree->selection_color());}
+ }
+ Fl_Box {} {
+ label {Test Operations}
+ tooltip {These controls only affect the defaults for new items that are created. These test the Fl_Tree_Prefs methods.} xywh {311 286 335 120} box GTK_DOWN_BOX color 47 labelsize 12 align 1
+ }
+ Fl_Box showitem_box {
+ label {show_item()
}
- xywh {480 425 70 82} box GTK_DOWN_BOX color 47 labelsize 11 align 1
- }
- Fl_Button {} {
- label Show
- callback {Fl_Tree_Item *item = tree->next_selected_item();
-tree->show_item(item);} selected
- tooltip {Tests show_item() with no position specified.
+ xywh {331 309 70 82} box GTK_DOWN_BOX labelsize 11 align 1
+ }
+ Fl_Button {} {
+ label Show
+ callback {Fl_Tree_Item *item = tree->next_selected_item();
+tree->show_item(item);}
+ tooltip {Tests show_item() with no position specified.
Makes the selected item visible IF it is off-screen.
-No change made if it is not off-screen.} xywh {495 434 40 17} labelsize 11
- }
- Fl_Button {} {
- label Top
- callback {Fl_Tree_Item *item = tree->next_selected_item();
+No change made if it is not off-screen.} xywh {346 318 40 17} labelsize 11
+ }
+ Fl_Button {} {
+ label Top
+ callback {Fl_Tree_Item *item = tree->next_selected_item();
tree->show_item_top(item);}
- tooltip {Test show_item_top().
+ tooltip {Test show_item_top().
Scrolls selected item to the top of the display
(only works if scrollbar showing)
To use:
1) open '500 items'
2) select item 0010
-3) Hit Top/Mid/Bot} xywh {495 451 40 16} labelsize 11
- }
- Fl_Button {} {
- label Mid
- callback {Fl_Tree_Item *item = tree->next_selected_item();
+3) Hit Top/Mid/Bot} xywh {346 335 40 16} labelsize 11
+ }
+ Fl_Button {} {
+ label Mid
+ callback {Fl_Tree_Item *item = tree->next_selected_item();
tree->show_item_middle(item);}
- tooltip {Tests show_item_middle().
+ tooltip {Tests show_item_middle().
Scrolls the selected item to the middle of the display
To use:
1) open '500 items'
2) select 'item 0010'
- 3) Hit Top/Mid/Bot} xywh {495 467 40 16} labelsize 11
- }
- Fl_Button {} {
- label Bot
- callback {Fl_Tree_Item *item = tree->next_selected_item();
+ 3) Hit Top/Mid/Bot} xywh {346 351 40 16} labelsize 11
+ }
+ Fl_Button {} {
+ label Bot
+ callback {Fl_Tree_Item *item = tree->next_selected_item();
tree->show_item_bottom(item);}
- tooltip {Tests show_item_bottom().
+ tooltip {Tests show_item_bottom().
Scrolls the selected item to the bottom of the display
To use:
1) open '500 items'
2) select 'item 0010'
- 3) Hit Top/Mid/Bot} xywh {495 483 40 16} labelsize 11
- }
- Fl_Box docallback_box {
- label {Selection State Changes}
- xywh {245 527 320 77} box GTK_DOWN_BOX color 47 labelsize 12 align 1
- }
- Fl_Button selectall_button {
- label {Select All}
- callback {tree->select_all(0);
-tree->redraw();}
- tooltip {Selects all items in the tree} xywh {260 539 75 16} labelsize 9
- }
- Fl_Button deselectall_button {
- label {Deselect All}
- callback {tree->deselect_all(0);
-tree->redraw();}
- tooltip {Deselects all items in the tree} xywh {260 559 75 16} labelsize 9
- }
- Fl_Light_Button bbbselect_toggle {
- label { Select Bbb}
- callback {// Toggle select of just the Bbb item (not children)
-Fl_Tree_Item *bbb = tree->find_item("/Bbb");
-if ( !bbb) {
- fl_alert("FAIL: Couldn't find item '/Bbb'???");
- return;
-}
-int onoff = bbbselect_toggle->value();
-if ( onoff ) tree->select(bbb); // select /Bbb
-else tree->deselect(bbb); // deselect /Bbb}
- tooltip {Toggle selection of just the /Bbb item
-(Not children)} xywh {350 540 95 15} selection_color 1 labelsize 9
- }
- Fl_Light_Button bbbselect2_toggle {
- label { Select Bbb+}
- callback {// Toggle select of just the Bbb item and its immediate children
-Fl_Tree_Item *bbb = tree->find_item("/Bbb");
-if ( !bbb) {
- fl_alert("FAIL: Couldn't find item '/Bbb'???");
- return;
-}
-int onoff = bbbselect2_toggle->value();
-if ( onoff ) tree->select_all(bbb); // select /Bbb and its children
-else tree->deselect_all(bbb); // deselect /Bbb and its children}
- tooltip {Toggle selection of the /Bbb item and its children} xywh {350 560 95 15} selection_color 1 labelsize 9
- }
- Fl_Light_Button bbbchild02select_toggle {
- label { Toggle child-02}
- callback {// Toggle select of just the /Bbb/child-02 item
-int onoff = bbbchild02select_toggle->value();
-if ( onoff ) tree->select("/Bbb/child-02");
-else tree->deselect("/Bbb/child-02");}
- tooltip {Toggle the single item /Bbb/child-02} xywh {350 579 95 16} selection_color 1 labelsize 9
- }
- Fl_Light_Button rootselect_toggle {
- label {Select ROOT}
- callback {// Toggle select of ROOT item and its children
-Fl_Tree_Item *item = tree->find_item("/ROOT");
-if ( !item) {
- fl_alert("FAIL: Couldn't find item '/ROOT'???");
- return;
-}
-int onoff = rootselect_toggle->value();
-if ( onoff ) tree->select(item); // select /ROOT and its children
-else tree->deselect(item); // deselect /ROOT and its children}
- tooltip {Toggle selection of the ROOT item} xywh {460 540 90 15} selection_color 1 labelsize 9
- }
- Fl_Light_Button rootselect2_toggle {
- label {Select ROOT+}
- callback {// Toggle select of ROOT item and its children
-Fl_Tree_Item *item = tree->find_item("/ROOT");
-if ( !item) {
- fl_alert("FAIL: Couldn't find item '/ROOT'???");
- return;
-}
-int onoff = rootselect2_toggle->value();
-if ( onoff ) tree->select_all(item); // select /ROOT and its children
-else tree->deselect_all(item); // deselect /ROOT and its children}
- tooltip {Toggle selection of the ROOT item and all children} xywh {460 560 90 15} selection_color 1 labelsize 9
- }
- Fl_Light_Button deactivate_toggle {
- label { Deactivate}
- callback {int onoff = deactivate_toggle->value() ? 0 : 1;
-
-int count = 0;
-for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
- if ( item->is_selected() ) {
- item->activate(onoff);
- ++count;
- }
-}
-
-if ( count == 0 ) {
- for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
- item->activate(onoff);
- }
-}
-
-tree->redraw();}
- tooltip {Toggle the deactivation state of the selected items.
-If none are selected, all are set.} xywh {280 634 90 16} selection_color 1 labelsize 9
- }
- Fl_Light_Button bold_toggle {
- label { Bold Font}
- callback {int face = bold_toggle->value() ? FL_HELVETICA_BOLD : FL_HELVETICA;
-
-// DO SELECTED ITEMS
-int count = 0;
-for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
- if ( item->is_selected() ) {
- item->labelfont(face);
- count++;
- }
-}
-
-// NO ITEMS SELECTED? DO ALL
-if ( ! count ) {
- for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
- item->labelfont(face);
- }
-}
-
-tree->redraw();}
- tooltip {Toggles bold font for selected items
-If nothing selected, all are changed} xywh {280 654 90 16} selection_color 1 labelsize 9
- }
- Fl_Button loaddb_button {
- label {Load Database...}
- callback {const char *filename = fl_file_chooser("Select a Preferences style Database", "Preferences(*.prefs)", 0L);
+ 3) Hit Top/Mid/Bot} xywh {346 367 40 16} labelsize 11
+ }
+ Fl_Button loaddb_button {
+ label {Load Database...}
+ callback {const char *filename = fl_file_chooser("Select a Preferences style Database", "Preferences(*.prefs)", 0L);
if (filename) {
tree->clear();
Fl_Preferences prefs(filename, 0L, 0L);
tree->load(prefs);
tree->redraw();
}}
- tooltip {Load the contents of an Fl_Preferences database into the tree view} xywh {380 614 90 16} labelsize 9
- }
- Fl_Button insertabove_button {
- label {Insert Above}
- callback {Fl_Tree_Item *item=tree->first();
+ tooltip {Load the contents of an Fl_Preferences database into the tree view} xywh {431 312 95 16} labelsize 9
+ }
+ Fl_Button insertabove_button {
+ label {Insert Above}
+ callback {Fl_Tree_Item *item=tree->first();
while (item) {
if ( item->is_selected() ) {
tree->insert_above(item, "AaaAaa");
@@ -729,16 +559,16 @@ while (item) {
}
tree->redraw();}
- tooltip {Inserts three items above the selected items} xywh {380 634 90 16} labelsize 9
- }
- Fl_Button rebuildtree_button {
- label {Rebuild Tree}
- callback {RebuildTree();}
- tooltip {Rebuilds the tree with defaults} xywh {380 654 90 16} labelsize 9
- }
- Fl_Button showpathname_button {
- label {Show Pathname}
- callback {Fl_Tree_Item *item = tree->first_selected_item();
+ tooltip {Inserts three items above the selected items} xywh {431 332 95 16} labelsize 9
+ }
+ Fl_Button rebuildtree_button {
+ label {Rebuild Tree}
+ callback {RebuildTree();}
+ tooltip {Rebuilds the tree with defaults} xywh {431 352 95 16} labelsize 9
+ }
+ Fl_Button showpathname_button {
+ label {Show Pathname}
+ callback {Fl_Tree_Item *item = tree->first_selected_item();
if ( !item ) { fl_message("No item was selected"); return; }
char pathname[256];
@@ -747,43 +577,18 @@ switch ( tree->item_pathname(pathname, sizeof(pathname), item) ) {
case -1: fl_message("item_pathname() returned -1 (NOT FOUND)"); break;
case -2: fl_message("item_pathname() returned -2 (STRING TOO LONG)"); break;
}}
- tooltip {Show the pathname for the selected item. Tests the Fl_Tree::item_pathname() method.} xywh {380 674 90 16} labelsize 8
- }
- Fl_Button showselected_button {
- label {Show Selected}
- callback {fprintf(stderr, "--- SELECTED ITEMS\\n");
-for ( Fl_Tree_Item *item = tree->first_selected_item();
- item;
- item = tree->next_selected_item(item) ) {
- fprintf(stderr, "\\t%s\\n", item->label() ? item->label() : "???");
-}}
- tooltip {Clears the selected items} xywh {475 614 90 16} labelsize 9
- }
- Fl_Button clearselected_button {
- label {Remove Selected}
- callback {Fl_Tree_Item *item=tree->first();
-while (item) {
- if ( item->is_selected() ) {
- if ( tree->remove(item) == -1 ) break;
- item = tree->first();
- } else {
- item = item->next();
- }
-}
-
-tree->redraw();}
- tooltip {Removes the selected items} xywh {475 634 90 16} labelsize 9
- }
- Fl_Button clearall_button {
- label {Clear All}
- callback {tree->clear();
+ tooltip {Show the pathname for the selected item. Tests the Fl_Tree::item_pathname() method.} xywh {431 372 95 16} labelsize 9
+ }
+ Fl_Button clearall_button {
+ label {Clear All}
+ callback {tree->clear();
tree->redraw();}
- tooltip {Clears all items
-Tests Fl_Tree::clear()} xywh {475 654 90 16} labelsize 9
- }
- Fl_Button testcallbackflag_button {
- label {Test Callback Flag}
- callback {Fl_Tree_Item *root = tree->root();
+ tooltip {Clears all items
+Tests Fl_Tree::clear()} xywh {531 312 95 16} labelsize 9
+ }
+ Fl_Button testcallbackflag_button {
+ label {Test Callback Flag}
+ callback {Fl_Tree_Item *root = tree->root();
fprintf(stderr, "--- Checking docallback off\\n");
if (!root) return;
@@ -844,7 +649,460 @@ G_cb_counter = 0; tree->select("ROOT"); if ( !G_cb_counter ) fl_alert("FAIL
tree->deselect("ROOT"); // leave deselected
fl_alert("TEST COMPLETED\\n If you didn't see any error dialogs, test PASSED.");}
- tooltip {Test the 'docallback' argument can disable callbacks.} xywh {475 674 90 16} labelsize 8
+ tooltip {Test the 'docallback' argument can disable callbacks.} xywh {531 332 95 16} labelsize 9
+ }
+ Fl_Box {} {
+ label {Selected Items}
+ tooltip {These controls only affect the selected items. If no items are selected, all existing items in tree are modified.} xywh {661 23 335 241} box GTK_DOWN_BOX color 47 labelsize 12 align 1
+ }
+ Fl_Choice all_font_choice {
+ label {Label Font}
+ callback {// Find first item in tree
+Fl_Tree_Item *item = tree->first();
+if ( !item ) return;
+
+// Get first item's font.
+Fl_Font val = (Fl_Font)all_font_choice->value(); // Get font value
+
+// Do selected items
+int count = 0;
+for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
+ if ( item->is_selected() ) {
+ item->labelfont(val);
+ count++;
+ }
+}
+
+// No items selected? Do all..
+if ( ! count ) {
+ for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
+ item->labelfont(val);
+ }
+}
+
+tree->redraw();}
+ tooltip {Changes the font for the selected items's labels. If none selected, all are changed. Tests Fl_Tree_Item::labelfont();} xywh {828 31 140 18} down_box BORDER_BOX labelsize 12 textsize 11
+ code0 {o->value((int)tree->item_labelfont()); // get tree's current font, assign to chooser}
+ } {
+ MenuItem {} {
+ label Helvetica
+ xywh {30 30 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Helvetica Bold}
+ xywh {40 40 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Helvetica Italic}
+ xywh {55 55 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Helvetica Bold Italic}
+ xywh {60 60 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label Courier
+ xywh {70 70 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Courier Bold}
+ xywh {80 80 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Courier Italic}
+ xywh {65 65 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Courier Bold Italic}
+ xywh {70 70 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label Times
+ xywh {80 80 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Times Bold}
+ xywh {90 90 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Times Italic}
+ xywh {75 75 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Times Bold Italic}
+ xywh {80 80 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label Symbol
+ xywh {90 90 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label Screen
+ xywh {100 100 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Screen bold}
+ xywh {85 85 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Zapf Dingbats}
+ xywh {90 90 36 21} labelsize 12
+ }
+ }
+ Fl_Value_Slider labelsize_slider {
+ label {Label Size}
+ user_data tree
+ callback {int size = (int)labelsize_slider->value();
+
+// DO SELECTED ITEMS
+int count = 0;
+for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
+ if ( item->is_selected() ) {
+ item->labelsize(size);
+ count++;
+ }
+}
+
+// NO ITEMS SELECTED? DO ALL
+if ( ! count ) {
+ for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
+ item->labelsize(size);
+ }
+}
+
+tree->redraw();}
+ tooltip {Changes the font size of the selected items's labels. If none selected, all are changed. Tests Fl_Tree_Item::labelsize();} xywh {828 53 140 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12
+ code0 {o->value(tree->item_labelsize());}
+ code1 {o->range(5.0, 200.0);}
+ code2 {o->step(1.0);}
+ code3 {o->color(46); o->selection_color(FL_RED);}
+ }
+ Fl_Button all_labelfgcolor_button {
+ label {Label FG Color}
+ callback {// Find first item in tree
+Fl_Tree_Item *item = tree->first();
+if ( !item ) return;
+
+// Get first item's color
+Fl_Color val = EditColor(item->labelfgcolor()); // Get color of first item in tree
+all_labelfgcolor_button->color(val); // update modified color to button
+
+// Do selected items
+int count = 0;
+for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
+ if ( item->is_selected() ) {
+ item->labelfgcolor(val);
+ count++;
+ }
+}
+
+// No items selected? Do all..
+if ( ! count ) {
+ for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
+ item->labelfgcolor(val);
+ }
+}
+
+tree->redraw();}
+ tooltip {Changes the label fg color for the selected items. If none selected, all are changed. Tests Fl_Tree_Item::labelfgcolor();} xywh {828 79 16 16} box DOWN_BOX labelsize 12 align 7
+ code0 {o->color(tree->item_labelfgcolor());}
+ }
+ Fl_Button all_labelbgcolor_button {
+ label {Label BG Color}
+ callback {// Find first item in tree
+Fl_Tree_Item *item = tree->first();
+if ( !item ) return;
+
+// Get first item's color
+Fl_Color val = EditColor(item->labelbgcolor()); // Get color of first item in tree
+all_labelbgcolor_button->color(val); // update modified color to button
+
+// Do selected items
+int count = 0;
+for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
+ if ( item->is_selected() ) {
+ item->labelbgcolor(val);
+ count++;
+ }
+}
+
+// No items selected? Do all..
+if ( ! count ) {
+ for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
+ item->labelbgcolor(val);
+ }
+}
+
+tree->redraw();}
+ tooltip {Changes the label bg color for the selected items. If none selected, all are changed. Tests Fl_Tree_Item::labelbgcolor();} xywh {828 97 16 16} box DOWN_BOX labelsize 12 align 7
+ code0 {o->color(tree->item_labelbgcolor());}
+ }
+ Fl_Value_Slider connectorwidth_slider {
+ label {Connector Width}
+ user_data tree
+ callback {tree->connectorwidth((int)connectorwidth_slider->value());}
+ tooltip {Tests Fl_Tree::connectorwidth()} xywh {828 124 140 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12
+ code0 {o->value(tree->connectorwidth());}
+ code1 {o->range(1.0, 100.0);}
+ code2 {o->step(1.0);}
+ code3 {o->color(46); o->selection_color(FL_RED);}
+ }
+ Fl_Light_Button deactivate_toggle {
+ label { Deactivate}
+ callback {int onoff = deactivate_toggle->value() ? 0 : 1;
+
+int count = 0;
+for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
+ if ( item->is_selected() ) {
+ item->activate(onoff);
+ ++count;
+ }
+}
+
+if ( count == 0 ) {
+ for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
+ item->activate(onoff);
+ }
+}
+
+tree->redraw();}
+ tooltip {Toggle the deactivation state of the selected items.
+If none are selected, all are set.} xywh {734 152 95 16} selection_color 1 labelsize 9
+ }
+ Fl_Light_Button bold_toggle {
+ label { Bold Font}
+ callback {int face = bold_toggle->value() ? FL_HELVETICA_BOLD : FL_HELVETICA;
+
+// DO SELECTED ITEMS
+int count = 0;
+for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
+ if ( item->is_selected() ) {
+ item->labelfont(face);
+ count++;
+ }
+}
+
+// NO ITEMS SELECTED? DO ALL
+if ( ! count ) {
+ for ( Fl_Tree_Item *item=tree->first(); item; item = tree->next(item) ) {
+ item->labelfont(face);
+ }
+}
+
+tree->redraw();}
+ tooltip {Toggles bold font for selected items
+If nothing selected, all are changed} xywh {734 172 95 16} selection_color 1 labelsize 9
+ }
+ Fl_Button showselected_button {
+ label {Show Selected}
+ callback {fprintf(stderr, "--- SELECTED ITEMS\\n");
+for ( Fl_Tree_Item *item = tree->first_selected_item();
+ item;
+ item = tree->next_selected_item(item) ) {
+ fprintf(stderr, "\\t%s\\n", item->label() ? item->label() : "???");
+}}
+ tooltip {Clears the selected items} xywh {829 152 95 16} labelsize 9
+ }
+ Fl_Button clearselected_button {
+ label {Remove Selected}
+ callback {Fl_Tree_Item *item=tree->first();
+while (item) {
+ if ( item->is_selected() ) {
+ if ( tree->remove(item) == -1 ) break;
+ item = tree->first();
+ } else {
+ item = item->next();
+ }
+}
+
+tree->redraw();}
+ tooltip {Removes the selected items} xywh {829 172 95 16} labelsize 9
+ }
+ Fl_Button selectall_button {
+ label {Select All}
+ callback {tree->select_all(0);
+tree->redraw();}
+ tooltip {Selects all items in the tree} xywh {689 199 95 16} labelsize 9
+ }
+ Fl_Button deselectall_button {
+ label {Deselect All}
+ callback {tree->deselect_all(0);
+tree->redraw();}
+ tooltip {Deselects all items in the tree} xywh {689 219 95 16} labelsize 9
+ }
+ Fl_Light_Button bbbselect_toggle {
+ label { Select Bbb}
+ callback {// Toggle select of just the Bbb item (not children)
+Fl_Tree_Item *bbb = tree->find_item("/Bbb");
+if ( !bbb) {
+ fl_alert("FAIL: Couldn't find item '/Bbb'???");
+ return;
+}
+int onoff = bbbselect_toggle->value();
+if ( onoff ) tree->select(bbb); // select /Bbb
+else tree->deselect(bbb); // deselect /Bbb}
+ tooltip {Toggle selection of just the /Bbb item
+(Not children)} xywh {784 199 95 16} selection_color 1 labelsize 9
+ }
+ Fl_Light_Button bbbselect2_toggle {
+ label { Select Bbb+}
+ callback {// Toggle select of just the Bbb item and its immediate children
+Fl_Tree_Item *bbb = tree->find_item("/Bbb");
+if ( !bbb) {
+ fl_alert("FAIL: Couldn't find item '/Bbb'???");
+ return;
+}
+int onoff = bbbselect2_toggle->value();
+if ( onoff ) tree->select_all(bbb); // select /Bbb and its children
+else tree->deselect_all(bbb); // deselect /Bbb and its children}
+ tooltip {Toggle selection of the /Bbb item and its children} xywh {784 219 95 16} selection_color 1 labelsize 9
+ }
+ Fl_Light_Button bbbchild02select_toggle {
+ label { Toggle child-02}
+ callback {// Toggle select of just the /Bbb/child-02 item
+const char *pathname = "/Bbb/child-02";
+int onoff = bbbchild02select_toggle->value();
+int err = 0;
+if ( onoff ) err = tree->select(pathname);
+else err = tree->deselect(pathname);
+
+if ( err == -1 ) {
+ fl_alert("FAIL: Couldn't find item '%s'",pathname);
+ return;
+}}
+ tooltip {Toggle the single item "/Bbb/child-02" using the item's "pathname".} xywh {784 239 95 16} selection_color 1 labelsize 9
+ }
+ Fl_Light_Button rootselect_toggle {
+ label {Select ROOT}
+ callback {// Toggle select of ROOT item and its children
+Fl_Tree_Item *item = tree->find_item("/ROOT");
+if ( !item) {
+ fl_alert("FAIL: Couldn't find item '/ROOT'???");
+ return;
+}
+int onoff = rootselect_toggle->value();
+if ( onoff ) tree->select(item); // select /ROOT and its children
+else tree->deselect(item); // deselect /ROOT and its children}
+ tooltip {Toggle selection of the ROOT item} xywh {879 199 95 16} selection_color 1 labelsize 9
+ }
+ Fl_Light_Button rootselect2_toggle {
+ label {Select ROOT+}
+ callback {// Toggle select of ROOT item and its children
+Fl_Tree_Item *item = tree->find_item("/ROOT");
+if ( !item) {
+ fl_alert("FAIL: Couldn't find item '/ROOT'???");
+ return;
+}
+int onoff = rootselect2_toggle->value();
+if ( onoff ) tree->select_all(item); // select /ROOT and its children
+else tree->deselect_all(item); // deselect /ROOT and its children}
+ tooltip {Toggle selection of the ROOT item and all children} xywh {879 219 95 16} selection_color 1 labelsize 9
+ }
+ Fl_Box {} {
+ label {New Item Defaults}
+ tooltip {These controls only affect the defaults for new items that are created. These test the Fl_Tree_Prefs methods.} xywh {661 286 335 120} box GTK_DOWN_BOX color 47 labelsize 12 align 1
+ }
+ Fl_Button item_labelfgcolor_button {
+ label item_labelfgcolor
+ callback {Fl_Color val = EditColor(tree->item_labelfgcolor()); // Let user edit the color
+tree->item_labelfgcolor(val); // apply modified color to tree
+item_labelfgcolor_button->color(val); // update modified color to button}
+ tooltip {Sets the *default* label foreground color for new items created. Does NOT affect existing items.} xywh {828 301 16 16} box DOWN_BOX labelsize 12 align 7
+ code0 {o->color(tree->item_labelfgcolor());}
+ }
+ Fl_Button item_labelbgcolor_button {
+ label item_labelbgcolor
+ callback {Fl_Color val = EditColor(tree->item_labelbgcolor()); // Let user edit the color
+tree->item_labelbgcolor(val); // apply modified color to tree
+item_labelbgcolor_button->color(val); // update modified color to button}
+ tooltip {Sets the *default* label background color for new items created. Does NOT affect existing items.} xywh {828 319 16 16} box DOWN_BOX labelsize 12 align 7
+ code0 {item_labelbgcolor_button->color(tree->item_labelbgcolor());}
+ }
+ Fl_Choice item_font_choice {
+ label {Item label font}
+ callback {Fl_Font val = (Fl_Font)item_font_choice->value(); // get chooser's current font value
+tree->item_labelfont(val); // change font in tree}
+ tooltip {Sets the default font used for new items created. Does NOT affect existing items.} xywh {828 345 140 18} down_box BORDER_BOX labelsize 12 textsize 12
+ code0 {o->value((int)tree->item_labelfont()); // get tree's current font, assign to chooser}
+ } {
+ MenuItem {} {
+ label Helvetica
+ xywh {20 20 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Helvetica Bold}
+ xywh {30 30 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Helvetica Italic}
+ xywh {45 45 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Helvetica Bold Italic}
+ xywh {50 50 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label Courier
+ xywh {60 60 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Courier Bold}
+ xywh {70 70 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Courier Italic}
+ xywh {55 55 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Courier Bold Italic}
+ xywh {60 60 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label Times
+ xywh {70 70 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Times Bold}
+ xywh {80 80 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Times Italic}
+ xywh {65 65 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Times Bold Italic}
+ xywh {70 70 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label Symbol
+ xywh {80 80 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label Screen
+ xywh {90 90 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Screen bold}
+ xywh {75 75 36 21} labelsize 12
+ }
+ MenuItem {} {
+ label {Zapf Dingbats}
+ xywh {80 80 36 21} labelsize 12
+ }
+ }
+ Fl_Value_Slider item_labelsize_slider {
+ label item_labelsize
+ user_data tree
+ callback {tree->item_labelsize((int)item_labelsize_slider->value());}
+ tooltip {Sets the default labelsize used for new items. Does NOT affect existing items.} xywh {828 366 140 16} type Horizontal labelsize 12 align 4 step 0.01 textsize 12
+ code0 {o->value((int)tree->item_labelsize());}
+ code1 {o->range(1.0, 50.0);}
+ code2 {o->step(1.0);}
+ code3 {o->color(46); o->selection_color(FL_RED);}
+ }
+ }
+ Fl_Box resizer_box {
+ xywh {0 263 15 14}
}
}
code {// Initialize Tree
@@ -855,7 +1113,7 @@ RebuildTree();
//Fl::scheme("gtk+");
-window->resizable(window);
+window->resizable(tree);
window->size_range(window->w(), window->h(), 0, 0);
if ( tree->when() == FL_WHEN_CHANGED ) whenmode_chooser->value(0);