diff options
| author | Greg Ercolano <erco@seriss.com> | 2012-05-09 21:26:32 +0000 |
|---|---|---|
| committer | Greg Ercolano <erco@seriss.com> | 2012-05-09 21:26:32 +0000 |
| commit | 31f320e2c694757e1953e623787df50591108045 (patch) | |
| tree | d10395864465796c62349fc894858fb3b2a44f9b | |
| parent | 4a5e1ec1968dab24cc8671647fba0a2e85adfc7d (diff) | |
o Added new 0xffffffff 'transparent' color behavior for the item's bg color;
with this as the default color, Fl_Tree::color() can control the tree's background.
Tests added to the test/tree application.
o test/tree.fl modified:
o Added a 'Test Suggestions' button to document various tests
o Added tests for new 'transparent' color behavior
o Added test for STR#2832 to check if items can be drawn to the /right/ of child widgets
o Added new methods to Fl_Tree_Prefs:
item_labelfont() -- obsoletes labelfont()
item_labelsize() -- obsoletes labelsize()
item_labelfgcolor() -- obsoletes labelfgcolor()
item_labelbgcolor() -- obsoletes labelbgcolor()
o Added 'Fonts and Colors' section to Fl_Tree docs
o Fl_Tree_Item ABI feature added: using bitflags instead of chars
to keep the class small, as it gets instanced a lot. (fast + LIGHT)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9478 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | FL/Fl_Tree.H | 59 | ||||
| -rw-r--r-- | FL/Fl_Tree_Item.H | 78 | ||||
| -rw-r--r-- | FL/Fl_Tree_Prefs.H | 90 | ||||
| -rw-r--r-- | src/Fl_Tree.cxx | 22 | ||||
| -rw-r--r-- | src/Fl_Tree_Item.cxx | 51 | ||||
| -rw-r--r-- | src/Fl_Tree_Prefs.cxx | 20 | ||||
| -rw-r--r-- | test/tree.fl | 542 |
7 files changed, 618 insertions, 244 deletions
diff --git a/FL/Fl_Tree.H b/FL/Fl_Tree.H index 2a4b8cfa3..dfa75de90 100644 --- a/FL/Fl_Tree.H +++ b/FL/Fl_Tree.H @@ -80,6 +80,8 @@ /// tree.end(); /// \endcode /// +/// \b FEATURES +/// /// Items can be added with add(), /// removed with remove(), /// completely cleared with clear(), @@ -95,7 +97,13 @@ /// and an item's pathname can be found with item_pathname(). /// The selected items' colors are controlled by selection_color() (inherited from Fl_Widget). /// +/// \b SELECTION OF ITEMS +/// /// The tree can have different selection behaviors controlled by selectmode(). +/// The background color used for selected items is the Fl_Tree::selection_color(). +/// The foreground color for selected items is controlled internally with fl_contrast(). +/// +/// \b CHILD WIDGETS /// /// FLTK widgets (including custom widgets) can be assigned to tree items via /// Fl_Tree_Item::widget(). @@ -110,6 +118,8 @@ /// adding the FL_TREE_ITEM_HEIGHT_FROM_WIDGET flag causes widget's height /// to define the widget()'s height. /// +/// \b ICONS +/// /// The tree's open/close icons can be redefined with /// Fl_Tree::openicon(), Fl_Tree::closeicon(). User icons /// can either be changed globally with Fl_Tree::usericon(), @@ -118,6 +128,27 @@ /// Various default preferences can be globally manipulated via Fl_Tree_Prefs, /// including colors, margins, icons, connection lines, etc. /// +/// \b FONTS AND COLORS +/// +/// When adding new items to the tree, the new items get the +/// defaults for fonts and colors from: +/// +/// - Fl_Tree::item_labelfont() -- The default item label font (default: FL_HELVETICA) +/// - Fl_Tree::item_labelsize() -- The default item label size (default: FL_NORMAL_SIZE) +/// - Fl_Tree::item_labelfgcolor() -- The default item label foreground color (default: FL_FOREGROUND_COLOR) +/// - Fl_Tree::item_labelbgcolor() -- The default item label background color (default: 0xffffffff, which tree uses as 'transparent') +/// +/// Each item (Fl_Tree_Item) inherits a copy of these font/color attributes when created, +/// and each item has its own methods to let the app change these values on a per-item basis +/// using methods of the same name: +/// +/// - Fl_Tree_Item::item_labelfont() -- The item's label font (default: FL_HELVETICA) +/// - Fl_Tree_Item::item_labelsize() -- The item's label size (default: FL_NORMAL_SIZE) +/// - Fl_Tree_Item::item_labelfgcolor() -- The item's label foreground color (default: FL_FOREGROUND_COLOR) +/// - Fl_Tree_Item::item_labelbgcolor() -- The item's label background color (default: 0xffffffff, which tree uses as 'transparent') +/// +/// \b CALLBACKS +/// /// The tree's callback() will be invoked when items change state or are open/closed. /// when() controls when mouse/keyboard events invoke the callback. /// callback_item() and callback_reason() can be used to determine the cause of the callback. eg: @@ -271,7 +302,7 @@ enum Fl_Tree_Reason { FL_TREE_REASON_DESELECTED, ///< an item was de-selected #if FLTK_ABI_VERSION >= 10302 FL_TREE_REASON_RESELECTED, ///< an item was re-selected (e.g. double-clicked) -#endif +#endif /*FLTK_ABI_VERSION*/ FL_TREE_REASON_OPENED, ///< an item was opened FL_TREE_REASON_CLOSED ///< an item was closed }; @@ -288,9 +319,9 @@ class FL_EXPORT Fl_Tree : public Fl_Group { #if FLTK_ABI_VERSION >= 10302 // NEW: Fl_Tree_Item *_lastselect; -#else +#else /*FLTK_ABI_VERSION*/ // OLD: static data inside handle() method -#endif +#endif /*FLTK_ABI_VERSION*/ void fix_scrollbar_order(); @@ -368,17 +399,18 @@ public: void set_item_focus(Fl_Tree_Item *item); int is_selected(Fl_Tree_Item *item) const; int is_selected(const char *path); + ///////////////////////////////// // Item attribute related methods ///////////////////////////////// + Fl_Font item_labelfont() const; + void item_labelfont(Fl_Font val); Fl_Fontsize item_labelsize() const; - void item_labelsize(Fl_Fontsize val); - Fl_Font item_labelfont() const; - void item_labelfont(Fl_Font val); - Fl_Color item_labelfgcolor(void) const; - void item_labelfgcolor(Fl_Color val); - Fl_Color item_labelbgcolor(void) const; - void item_labelbgcolor(Fl_Color val); + void item_labelsize(Fl_Fontsize val); + Fl_Color item_labelfgcolor(void) const; + void item_labelfgcolor(Fl_Color val); + Fl_Color item_labelbgcolor(void) const; + void item_labelbgcolor(Fl_Color val); Fl_Color connectorcolor() const; void connectorcolor(Fl_Color val); int marginleft() const; @@ -388,7 +420,7 @@ public: #if FLTK_ABI_VERSION >= 10302 int marginbottom() const; void marginbottom(int val); -#endif +#endif /*FLTK_ABI_VERSION*/ int linespacing() const; void linespacing(int val); int openchild_marginbottom() const; @@ -400,7 +432,7 @@ public: #if FLTK_ABI_VERSION >= 10302 int widgetmarginleft() const; void widgetmarginleft(int val); -#endif +#endif /*FLTK_ABI_VERSION*/ int connectorwidth() const; void connectorwidth(int val); Fl_Image* usericon() const; @@ -427,8 +459,7 @@ public: Fl_Tree_Item_Draw_Mode item_draw_mode() const; void item_draw_mode(Fl_Tree_Item_Draw_Mode mode); void item_draw_mode(int mode); -#endif - +#endif /*FLTK_ABI_VERSION*/ int displayed(Fl_Tree_Item *item); void show_item(Fl_Tree_Item *item, int yoff); void show_item(Fl_Tree_Item *item); diff --git a/FL/Fl_Tree_Item.H b/FL/Fl_Tree_Item.H index 83d6a4b42..b5dd7b985 100644 --- a/FL/Fl_Tree_Item.H +++ b/FL/Fl_Tree_Item.H @@ -56,11 +56,23 @@ class FL_EXPORT Fl_Tree_Item { 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 + Fl_Color _labelbgcolor; // label's bg color (0xffffffff is 'transparent') + enum { + OPEN = 1<<0, ///> item is open + VISIBLE = 1<<1, ///> item is visible + ACTIVE = 1<<2, ///> item is active + SELECTED = 1<<3, ///> item is selected + }; +#if FLTK_ABI_VERSION >= 10302 + // NEW + unsigned short _flags; // misc flags +#else /*FLTK_ABI_VERSION*/ + // OLD: this will go away after 1.3.x char _open; // item is open? char _visible; // item is visible? char _active; // item activated? char _selected; // item selected? +#endif /*FLTK_ABI_VERSION*/ int _xywh[4]; // xywh of this widget (if visible) int _collapse_xywh[4]; // xywh of collapse icon (if visible) int _label_xywh[4]; // xywh of label @@ -131,10 +143,12 @@ public: return(_labelfgcolor); } /// Set item's label background color. + /// A special case is made for color 0xffffffff which is treated as 'transparent'. void labelbgcolor(Fl_Color val) { _labelbgcolor = val; } /// Return item's background text color. + /// If the color is 0xffffffff, it is 'transparent'. Fl_Color labelbgcolor() const { return(_labelbgcolor); } @@ -208,26 +222,26 @@ public: void close(); /// See if the item is 'open'. int is_open() const { - return(_open?1:0); + return(is_flag(OPEN)); } /// See if the item is 'closed'. int is_close() const { - return(_open?0:1); + return(is_flag(OPEN)?0:1); } /// Toggle the item's open/closed state. void open_toggle() { - _open?close():open(); + is_open()?close():open(); } /// Change the item's selection state to the optionally specified 'val'. /// If 'val' is not specified, the item will be selected. /// void select(int val=1) { - _selected = val; + set_flag(SELECTED, val); } /// Toggle the item's selection state. void select_toggle() { if ( is_selected() ) { - deselect(); // deselect if selected + deselect(); // deselect if selected } else { select(); // select if deselected } @@ -249,7 +263,7 @@ public: } /// Disable the item's selection state. void deselect() { - _selected = 0; + set_flag(SELECTED, 0); } /// Deselect item and all its children. /// Returns count of how many items were in the 'selected' state, @@ -268,7 +282,7 @@ public: } /// See if the item is selected. char is_selected() const { - return(_selected); + return(is_flag(SELECTED)); } /// Change the item's activation state to the optionally specified 'val'. /// @@ -280,7 +294,7 @@ public: /// If 'val' is not specified, the item will be activated. /// void activate(int val=1) { - _active = val; + set_flag(ACTIVE,val); if ( _widget && val != (int)_widget->active() ) { if ( val ) { _widget->activate(); @@ -298,15 +312,19 @@ public: } /// See if the item is activated. char is_activated() const { - return(_active); + return(is_flag(ACTIVE)); } /// See if the item is activated. char is_active() const { - return(_active); + return(is_activated()); } - /// See if the item is visible. + /// See if the item is visible. Alias for is_visible(). int visible() const { - return(_visible ? 1 : 0); + return(is_visible()); + } + /// See if the item is visible. + int is_visible() const { + return(is_flag(VISIBLE)); } int visible_r() const; @@ -329,6 +347,40 @@ public: int is_root() const { return(_parent==0?1:0); } + + // Protected methods +protected: +#if FLTK_ABI_VERSION >= 10302 + /// Set a flag to an on or off value. val is 0 or 1. + inline void set_flag(unsigned short flag,int val) { + if ( val ) _flags |= flag; else _flags &= ~flag; + } + /// See if flag set. Returns 0 or 1. + inline int is_flag(unsigned short val) const { + return(_flags & val ? 1 : 0); + } +#else /*FLTK_ABI_VERSION*/ + /// Set a flag to an on or off value. val is 0 or 1. + void set_flag(unsigned short flag,int val) { + switch (flag) { + case OPEN: _open = val; break; + case VISIBLE: _visible = val; break; + case ACTIVE: _active = val; break; + case SELECTED: _selected = val; break; + } + } + /// See if flag set. Returns 0 or 1. + int is_flag(unsigned short flag) const { + switch (flag) { + case OPEN: return(_open ? 1 : 0); + case VISIBLE: return(_visible ? 1 : 0); + case ACTIVE: return(_active ? 1 : 0); + case SELECTED: return(_selected ? 1 : 0); + default: return(0); + } + } +#endif /*FLTK_ABI_VERSION*/ + }; #endif /*FL_TREE_ITEM_H*/ diff --git a/FL/Fl_Tree_Prefs.H b/FL/Fl_Tree_Prefs.H index 12dcafdbf..b87cc8521 100644 --- a/FL/Fl_Tree_Prefs.H +++ b/FL/Fl_Tree_Prefs.H @@ -91,7 +91,7 @@ enum Fl_Tree_Item_Draw_Mode { FL_TREE_ITEM_DRAW_LABEL_AND_WIDGET=1, ///< If widget() defined, include label to the left of the widget FL_TREE_ITEM_HEIGHT_FROM_WIDGET=2 ///< If widget() defined, widget()'s height controls item's height }; -#endif +#endif /*FLTK_ABI_VERSION*/ /// \class Fl_Tree_Prefs /// @@ -119,7 +119,7 @@ class FL_EXPORT Fl_Tree_Prefs { int _linespacing; // vertical space between lines // Colors Fl_Color _labelfgcolor; // label's foreground color - Fl_Color _labelbgcolor; // background color + Fl_Color _labelbgcolor; // label's background color Fl_Color _connectorcolor; // connector dotted line color Fl_Tree_Connector _connectorstyle; // connector line style Fl_Image *_openimage; // the 'open' icon [+] @@ -133,7 +133,7 @@ class FL_EXPORT Fl_Tree_Prefs { #if FLTK_ABI_VERSION >= 10302 Fl_Tree_Item_Reselect_Mode _itemreselectmode; // controls item selection callback() behavior Fl_Tree_Item_Draw_Mode _itemdrawmode; // controls how items draw label + widget() -#endif +#endif /*FLTK_ABI_VERSION*/ public: Fl_Tree_Prefs(); @@ -141,21 +141,61 @@ public: // Labels //////////////////////////// /// Return the label's font. - inline Fl_Font labelfont() const { - return(_labelfont); - } + inline Fl_Font item_labelfont() const { return(_labelfont); } /// Set the label's font to \p val. - inline void labelfont(Fl_Font val) { - _labelfont = val; - } + inline void item_labelfont(Fl_Font val) { _labelfont = val; } /// Return the label's size in pixels. - inline Fl_Fontsize labelsize() const { - return(_labelsize); - } + inline Fl_Fontsize item_labelsize() const { return(_labelsize); } /// Set the label's size in pixels to \p val. - inline void labelsize(Fl_Fontsize val) { - _labelsize = val; + inline void item_labelsize(Fl_Fontsize val) { _labelsize = val; } + /// Get the default label foreground color + inline Fl_Color item_labelfgcolor() const { return(_labelfgcolor); } + /// Set the default label foreground color + inline void item_labelfgcolor(Fl_Color val) { _labelfgcolor = val; } +#if FLTK_ABI_VERSION >= 10302 + /// Get the default label background color. + /// This returns the Fl_Tree::color() unless item_labelbgcolor() + /// has been set explicitly. + /// + inline Fl_Color item_labelbgcolor() const { + return _labelbgcolor; + } + /// Set the default label background color. + /// Once set, overrides the default behavior of using Fl_Tree::color(). + /// + inline void item_labelbgcolor(Fl_Color val) { + _labelbgcolor = val; + } +#else /*FLTK_ABI_VERSION*/ + /// Get the default label background color + inline Fl_Color item_labelbgcolor() const { + return(_labelbgcolor); + } + /// Set the default label background color + inline void item_labelbgcolor(Fl_Color val) { + _labelbgcolor = val; } +#endif /*FLTK_ABI_VERSION*/ + + ///////////////// + // Obsolete names - for 1.3.0 backwards compat + ///////////////// + /// Obsolete: Return the label's font. Please use item_labelfont() instead. + inline Fl_Font labelfont() const { return(_labelfont); } + /// Obsolete: Set the label's font to \p val. Please use item_labelfont(Fl_Font) instead. + inline void labelfont(Fl_Font val) { _labelfont = val; } + /// Obsolete: Return the label's size in pixels. Please use item_labelsize() instead. + inline Fl_Fontsize labelsize() const { return(_labelsize); } + /// Obsolete: Set the label's size in pixels to \p val. Please use item_labelsize(Fl_Fontsize) instead. + inline void labelsize(Fl_Fontsize val) { _labelsize = val; } + /// Obsolete: Get the default label foreground color. Please use item_labelfgcolor() instead. + inline Fl_Color labelfgcolor() const { return(_labelfgcolor); } + /// Obsolete: Set the default label foreground color. Please use item_labelfgcolor(Fl_Color) instead. + inline void labelfgcolor(Fl_Color val) { _labelfgcolor = val; } + /// Obsolete: Get the default label background color. Please use item_labelbgcolor() instead. + inline Fl_Color labelbgcolor() const { return(item_labelbgcolor()); } + /// Obsolete: Set the default label background color. Please use item_labelbgcolor(Fl_Color) instead. + inline void labelbgcolor(Fl_Color val) { item_labelbgcolor(val); } //////////////////////////// // Margins @@ -187,7 +227,7 @@ public: inline void marginbottom(int val) { _marginbottom = val; } -#endif +#endif /*FLTK_ABI_VERSION*/ /// Get the margin below an open child in pixels inline int openchild_marginbottom() const { return(_openchild_marginbottom); @@ -221,7 +261,7 @@ public: inline void widgetmarginleft(int val) { _widgetmarginleft = val; } -#endif +#endif /*FLTK_ABI_VERSION*/ /// Get the line spacing value in pixels inline int linespacing() const { return(_linespacing); @@ -234,22 +274,6 @@ public: //////////////////////////// // Colors and Styles //////////////////////////// - /// Get the default label foreground color - inline Fl_Color labelfgcolor() const { - return(_labelfgcolor); - } - /// Set the default label foreground color - inline void labelfgcolor(Fl_Color val) { - _labelfgcolor = val; - } - /// Get the default label background color - inline Fl_Color labelbgcolor() const { - return(_labelbgcolor); - } - /// Set the default label background color - inline void labelbgcolor(Fl_Color val) { - _labelbgcolor = val; - } /// Get the connector color used for tree connection lines. inline Fl_Color connectorcolor() const { return(_connectorcolor); @@ -388,7 +412,7 @@ public: inline void item_draw_mode(Fl_Tree_Item_Draw_Mode val) { _itemdrawmode = val; } -#endif +#endif /*FLTK_ABI_VERSION*/ }; #endif /*FL_TREE_PREFS_H*/ diff --git a/src/Fl_Tree.cxx b/src/Fl_Tree.cxx index bf5f9daa4..95247e354 100644 --- a/src/Fl_Tree.cxx +++ b/src/Fl_Tree.cxx @@ -102,9 +102,9 @@ Fl_Tree::Fl_Tree(int X, int Y, int W, int H, const char *L) : Fl_Group(X,Y,W,H,L #if FLTK_ABI_VERSION >= 10302 // NEW _lastselect = 0; -#else +#else /*FLTK_ABI_VERSION*/ // OLD: data initialized static inside handle() -#endif +#endif /*FLTK_ABI_VERSION*/ box(FL_DOWN_BOX); color(FL_BACKGROUND2_COLOR, FL_SELECTION_COLOR); @@ -150,10 +150,10 @@ int Fl_Tree::handle(int e) { char is_command = Fl::event_state() & FL_COMMAND ? 1 : 0; // ctrl on win/lin, 'Command' on mac #if FLTK_ABI_VERSION >= 10302 // NEW: data inside Fl_Tree -#else +#else /*FLTK_ABI_VERSION*/ // OLD: static Fl_Tree_Item *_lastselect = 0; -#endif +#endif /*FLTK_ABI_VERSION*/ // Developer note: Fl_Browser_::handle() used for reference here.. // #include <FL/names.h> // for event debugging // fprintf(stderr, "DEBUG: %s (%d)\n", fl_eventnames[e], e); @@ -477,10 +477,10 @@ int Fl_Tree::draw_tree() { #if FLTK_ABI_VERSION >= 10302 // NEW int SY = Y + _prefs.marginbottom(); -#else +#else /*FLTK_ABI_VERSION*/ // OLD int SY = Y; -#endif +#endif /*FLTK_ABI_VERSION*/ int ydiff = (SY+_prefs.margintop())-Ysave; // ydiff=size of tree int ytoofar = (cy+ch) - SY; // ytoofar -- if >0, scrolled beyond bottom if ( ytoofar > 0 ) ydiff += ytoofar; @@ -1117,7 +1117,7 @@ int Fl_Tree::select(Fl_Tree_Item *item, int docallback) { do_callback_for_item(item, FL_TREE_REASON_RESELECTED); } } -#endif +#endif /*FLTK_ABI_VERSION*/ return(0); } @@ -1412,11 +1412,13 @@ void Fl_Tree::item_labelfgcolor(Fl_Color val) { } /// Get the default label background color used for creating new items. +/// If the color is 0xffffffff, it is 'transparent'. Fl_Color Fl_Tree::item_labelbgcolor(void) const { return(_prefs.labelbgcolor()); } /// Set the default label background color used for creating new items. +/// A special case is made for color 0xffffffff (default) which is treated as 'transparent'. /// To change the background color on a per-item basis, use Fl_Tree_Item::labelbgcolor(Fl_Color) /// void Fl_Tree::item_labelbgcolor(Fl_Color val) { @@ -1478,7 +1480,7 @@ void Fl_Tree::marginbottom(int val) { _prefs.marginbottom(val); redraw(); } -#endif +#endif /*FLTK_ABI_VERSION*/ /// Get the amount of white space (in pixels) that should appear /// between items in the tree. @@ -1543,7 +1545,7 @@ void Fl_Tree::widgetmarginleft(int val) { _prefs.widgetmarginleft(val); redraw(); } -#endif +#endif /*FLTK_ABI_VERSION*/ /// Gets the width of the horizontal connection lines (in pixels) /// that appear to the left of each tree item's label. @@ -1728,7 +1730,7 @@ void Fl_Tree::item_draw_mode(Fl_Tree_Item_Draw_Mode val) { void Fl_Tree::item_draw_mode(int val) { _prefs.item_draw_mode(Fl_Tree_Item_Draw_Mode(val)); } -#endif +#endif /*FLTK_ABI_VERSION*/ /// See if \p item is currently displayed on-screen (visible within the widget). /// This can be used to detect if the item is scrolled off-screen. diff --git a/src/Fl_Tree_Item.cxx b/src/Fl_Tree_Item.cxx index b527d649a..d20437b9e 100644 --- a/src/Fl_Tree_Item.cxx +++ b/src/Fl_Tree_Item.cxx @@ -44,10 +44,14 @@ Fl_Tree_Item::Fl_Tree_Item(const Fl_Tree_Prefs &prefs) { _labelfgcolor = prefs.labelfgcolor(); _labelbgcolor = prefs.labelbgcolor(); _widget = 0; +#if FLTK_ABI_VERSION >= 10302 + _flags = OPEN|VISIBLE|ACTIVE; +#else /*FLTK_ABI_VERSION*/ _open = 1; _visible = 1; _active = 1; _selected = 0; +#endif /*FLTK_ABI_VERSION*/ _xywh[0] = 0; _xywh[1] = 0; _xywh[2] = 0; @@ -88,10 +92,14 @@ Fl_Tree_Item::Fl_Tree_Item(const Fl_Tree_Item *o) { _labelfgcolor = o->labelfgcolor(); _labelbgcolor = o->labelbgcolor(); _widget = o->widget(); +#if FLTK_ABI_VERSION >= 10302 + _flags = o->_flags; +#else /*FLTK_ABI_VERSION*/ _open = o->_open; _visible = o->_visible; _active = o->_active; _selected = o->_selected; +#endif /*FLTK_ABI_VERSION*/ _xywh[0] = o->_xywh[0]; _xywh[1] = o->_xywh[1]; _xywh[2] = o->_xywh[2]; @@ -468,7 +476,7 @@ void Fl_Tree_Item::draw_vertical_connector(int x, int y1, int y2, const Fl_Tree_ /// \returns const visible item under the event if found, or 0 if none. /// const Fl_Tree_Item *Fl_Tree_Item::find_clicked(const Fl_Tree_Prefs &prefs) const { - if ( ! _visible ) return(0); + if ( ! is_visible() ) return(0); if ( is_root() && !prefs.showroot() ) { // skip event check if we're root but root not being shown } else { @@ -498,7 +506,7 @@ const Fl_Tree_Item *Fl_Tree_Item::find_clicked(const Fl_Tree_Prefs &prefs) const /// \returns the visible item under the event if found, or 0 if none. /// Fl_Tree_Item *Fl_Tree_Item::find_clicked(const Fl_Tree_Prefs &prefs) { - if ( ! _visible ) return(0); + if ( ! is_visible() ) return(0); if ( is_root() && !prefs.showroot() ) { // skip event check if we're root but root not being shown } else { @@ -562,7 +570,7 @@ static void draw_item_focus(Fl_Boxtype B, Fl_Color C, int X, int Y, int W, int H /// Doesn't include linespacing(); prevents affecting eg. height of widget(). /// int Fl_Tree_Item::calc_item_height(const Fl_Tree_Prefs &prefs) const { - if ( ! _visible ) return(0); + if ( ! is_visible() ) return(0); int H = 0; if ( _label ) { fl_font(_labelfont, _labelsize); // fl_descent() needs this :/ @@ -574,7 +582,7 @@ int Fl_Tree_Item::calc_item_height(const Fl_Tree_Prefs &prefs) const { H < widget()->h()) { H = widget()->h(); } -#endif +#endif /*FLTK_ABI_VERSION*/ if ( has_children() && prefs.openicon() && H<prefs.openicon()->h() ) H = prefs.openicon()->h(); if ( usericon() && H<usericon()->h() ) @@ -586,7 +594,7 @@ int Fl_Tree_Item::calc_item_height(const Fl_Tree_Prefs &prefs) const { void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree, Fl_Tree_Item *itemfocus, const Fl_Tree_Prefs &prefs, int lastchild) { - if ( ! _visible ) return; + if ( ! is_visible() ) return; int tree_top = tree->y(); int tree_bot = tree_top + tree->h(); int H = calc_item_height(prefs); // height of item @@ -645,20 +653,20 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree, ? widget()->h() : H; if ( _label && (prefs.item_draw_mode() & FL_TREE_ITEM_DRAW_LABEL_AND_WIDGET) ) { -#else +#else /*FLTK_ABI_VERSION*/ int wh = H; // lock widget's height to item height if ( _label && !widget() ) { // back compat: don't draw label if widget() present -#endif +#endif /*FLTK_ABI_VERSION*/ fl_font(_labelfont, _labelsize); // fldescent() needs this int lw=0, lh=0; fl_measure(_label,lw,lh); // get box around text (including white space) #if FLTK_ABI_VERSION >= 10302 // NEW wx += (lw + prefs.widgetmarginleft()); -#else +#else /*FLTK_ABI_VERSION*/ // OLD wx += (lw + 3); -#endif +#endif /*FLTK_ABI_VERSION*/ } if ( widget()->x() != wx || widget()->y() != wy || widget()->w() != ww || widget()->h() != wh ) { @@ -668,12 +676,13 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree, char clipped = ((Y+H) < tree_top) || (Y>tree_bot) ? 1 : 0; char drawthis = ( is_root() && prefs.showroot() == 0 ) ? 0 : 1; if ( !clipped ) { - Fl_Color fg = _selected ? fl_contrast(_labelfgcolor, tree->selection_color()) - : _active ? _labelfgcolor - : fl_inactive(_labelfgcolor); - Fl_Color bg = _selected ? _active ? tree->selection_color() - : fl_inactive(tree->selection_color()) - : _labelbgcolor; + Fl_Color fg = is_selected() ? fl_contrast(_labelfgcolor, tree->selection_color()) + : is_active() ? _labelfgcolor + : fl_inactive(_labelfgcolor); + Fl_Color bg = is_selected() ? is_active() ? tree->selection_color() + : fl_inactive(tree->selection_color()) + : _labelbgcolor == 0xffffffff ? tree->color() // transparent bg? + : _labelbgcolor; // See if we should draw this item // If this item is root, and showroot() is disabled, don't draw. // 'clipped' is an optimization to prevent drawing anything offscreen. @@ -730,9 +739,9 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree, if ( _label && ( !widget() || (prefs.item_draw_mode() & FL_TREE_ITEM_DRAW_LABEL_AND_WIDGET) ) ) -#else +#else /*FLTK_ABI_VERSION*/ if ( _label && !widget() ) // back compat: don't draw label if widget() present -#endif +#endif /*FLTK_ABI_VERSION*/ { fl_color(fg); fl_font(_labelfont, _labelsize); @@ -781,7 +790,7 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree, /// Was the event on the 'collapse' button? /// int Fl_Tree_Item::event_on_collapse_icon(const Fl_Tree_Prefs &prefs) const { - if ( _visible && _active && has_children() && prefs.showcollapse() ) { + if ( is_visible() && is_active() && has_children() && prefs.showcollapse() ) { return(event_inside(_collapse_xywh) ? 1 : 0); } else { return(0); @@ -791,7 +800,7 @@ int Fl_Tree_Item::event_on_collapse_icon(const Fl_Tree_Prefs &prefs) const { /// Was event on the label()? /// int Fl_Tree_Item::event_on_label(const Fl_Tree_Prefs &prefs) const { - if ( _visible && _active ) { + if ( is_visible() && is_active() ) { return(event_inside(_label_xywh) ? 1 : 0); } else { return(0); @@ -822,7 +831,7 @@ void Fl_Tree_Item::hide_widgets() { /// Open this item and all its children. void Fl_Tree_Item::open() { - _open = 1; + set_flag(OPEN,1); // Tell children to show() their widgets for ( int t=0; t<_children.total(); t++ ) { _children[t]->show_widgets(); @@ -831,7 +840,7 @@ void Fl_Tree_Item::open() { /// Close this item and all its children. void Fl_Tree_Item::close() { - _open = 0; + set_flag(OPEN,0); // Tell children to hide() their widgets for ( int t=0; t<_children.total(); t++ ) { _children[t]->hide_widgets(); diff --git a/src/Fl_Tree_Prefs.cxx b/src/Fl_Tree_Prefs.cxx index 7f4a5337b..02d1aed61 100644 --- a/src/Fl_Tree_Prefs.cxx +++ b/src/Fl_Tree_Prefs.cxx @@ -5,7 +5,7 @@ #include <FL/Fl.H> #include <FL/Fl_Pixmap.H> #include <FL/Fl_Tree_Prefs.H> -#include <string.h> +#include <string.h> // strcmp ////////////////////// // Fl_Tree_Prefs.cxx @@ -44,7 +44,7 @@ static const char *L_open_xpm[] = { "...@@@.....", "...@@......", "...@......." -#else +#else /* __APPLE__ */ "11 11 3 1", ". c #fefefe", "# c #444444", @@ -60,7 +60,7 @@ static const char *L_open_xpm[] = { "#.........#", "#.........#", "###########" -#endif +#endif /* __APPLE__ */ }; static Fl_Pixmap L_openpixmap(L_open_xpm); @@ -80,7 +80,7 @@ static const char *L_close_xpm[] = { "...@@@@@...", "....@@@....", ".....@....." -#else +#else /* __APPLE__ */ "11 11 3 1", ". c #fefefe", "# c #444444", @@ -96,7 +96,7 @@ static const char *L_close_xpm[] = { "#.........#", "#.........#", "###########" -#endif +#endif /* __APPLE__ */ }; static Fl_Pixmap L_closepixmap(L_close_xpm); @@ -127,22 +127,22 @@ Fl_Tree_Prefs::Fl_Tree_Prefs() { _margintop = 3; #if FLTK_ABI_VERSION >= 10302 _marginbottom = 20; -#endif +#endif /*FLTK_ABI_VERSION*/ _openchild_marginbottom = 0; _usericonmarginleft = 3; _labelmarginleft = 3; #if FLTK_ABI_VERSION >= 10302 _widgetmarginleft = 3; -#endif +#endif /*FLTK_ABI_VERSION*/ _linespacing = 0; _labelfgcolor = FL_BLACK; - _labelbgcolor = FL_WHITE; + _labelbgcolor = 0xffffffff; // we use this as 'transparent' _connectorcolor = Fl_Color(43); #ifdef __APPLE__ _connectorstyle = FL_TREE_CONNECTOR_NONE; -#else +#else /* __APPLE__ */ _connectorstyle = FL_TREE_CONNECTOR_DOTTED; -#endif +#endif /* __APPLE__ */ _openimage = &L_openpixmap; _closeimage = &L_closepixmap; _userimage = 0; diff --git a/test/tree.fl b/test/tree.fl index 10c7185d8..e8c37d519 100644 --- a/test/tree.fl +++ b/test/tree.fl @@ -32,6 +32,9 @@ decl {\#include <FL/Fl_Preferences.H>} {public global decl {\#include <FL/Fl_Color_Chooser.H>} {public global } +decl {\#include <FL/Fl_Text_Display.H>} {public global +} + decl {int G_cb_counter = 0;} { comment {// Global callback event counter} private local } @@ -141,6 +144,25 @@ tree->add("Bbb/child-03"); tree->add("Bbb/child-04"); { + static Fl_Input *in = 0; + // Assign an FLTK input widget to one of the items with a label() of its own (STR\#2832) + Fl_Tree_Item *i; + if ( ( i = tree->find_item("Bbb/child-02") ) != NULL ) { + if ( !in ) { // only do this once at program startup + tree->begin(); + in = new Fl_Input(1,1,100,1,"Fl_Input test"); // we control w() only + in->labelsize(10); + in->textsize(10); + in->align(FL_ALIGN_RIGHT); // show label to the right of the widget + in->tooltip("Fl_Input inside tree.\\n" + "The widget's label 'Fl_Input test' should appear to the widget's right."); + } + i->widget(in); + tree->end(); + } +} + +{ static Fl_Button *but = 0; // Assign an FLTK widget to one of the items Fl_Tree_Item *i; @@ -225,18 +247,41 @@ AssignUserIcons(); tree->redraw();} {} } -Function {EditColor(Fl_Color val)} { +Function {EditColor(Fl_Color &val)} { comment {Prompt the user to change the specified color} return_type Fl_Color } { - code {uchar r,g,b; + code {// Returns: +// 1 if color picked with new color in 'val' +// 0 if user hit 'Cancel'. +// +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); +int ret = fl_color_chooser("Choose Color",r,g,b); -// Return the new color the user picked -return(fl_rgb_color(r,g,b));} {} +val = fl_rgb_color(r,g,b); + + +return(ret);} {} +} + +Function {UpdateColorChips()} { + comment {Updates the color chips with current colors from widget} open return_type void +} { + code {color_button->color(tree->color()); +labelcolor_button->color(tree->labelcolor()); +selection_color_button->color(tree->selection_color()); + +item_labelfgcolor_button->color(tree->item_labelfgcolor()); +item_labelbgcolor_button->color(tree->item_labelbgcolor()); + +all_labelfgcolor_button->color(tree->item_labelfgcolor()); // use default +all_labelbgcolor_button->color(tree->item_labelbgcolor()); // use default + +window->redraw();} {} } Function {GetTreeMarginBottom()} { @@ -261,11 +306,37 @@ return 0; \#endif} {} } +Function {GetSelectedItemFGColor()} { + comment {Return the selected item's fg color} open return_type Fl_Color +} { + code {Fl_Tree_Item *item; +for ( item=tree->first(); item; item = tree->next(item) ) { + if ( item->is_selected() ) { + return(item->labelfgcolor()); + } +} +// No items selected? Use default +return(tree->item_labelfgcolor());} {} +} + +Function {GetSelectedItemBGColor()} { + comment {Return the selected item's bg color} open return_type Fl_Color +} { + code {Fl_Tree_Item *item; +for ( item=tree->first(); item; item = tree->next(item) ) { + if ( item->is_selected() ) { + return(item->labelbgcolor()); + } +} +// No items selected? Use default +return(tree->item_labelbgcolor());} {} +} + Function {} {open } { Fl_Window window { label tree open - xywh {678 506 1015 590} type Double visible + xywh {5 21 1045 580} type Double visible } { Fl_Group tree { label Tree @@ -292,16 +363,16 @@ if ( item ) { tree->changed() ? 1 : 0); } tree->clear_changed();} open - tooltip {Test tree} xywh {15 22 285 553} box DOWN_BOX color 55 selection_color 15 + tooltip {Test tree} xywh {15 22 320 539} box DOWN_BOX color 55 selection_color 15 class Fl_Tree } {} Fl_Group {} {open - xywh {300 5 705 590} + xywh {300 5 731 615} 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 {315 23 330 410} box GTK_DOWN_BOX color 47 labelsize 12 align 1 + tooltip {These controls only affect the selected items. If no items are selected, all existing items in tree are modified.} xywh {350 23 330 389} box GTK_DOWN_BOX color 47 labelsize 12 align 1 } Fl_Value_Slider margintop_slider { label {margintop()} @@ -309,7 +380,7 @@ tree->clear_changed();} open callback {int val = (int)margintop_slider->value(); tree->margintop(val); tree->redraw();} - tooltip {Changes the top margin for the tree widget} xywh {470 31 155 16} type Horizontal color 46 selection_color 1 labelsize 10 align 4 textsize 9 + tooltip {Changes the top margin for the tree widget} xywh {505 40 155 16} type Horizontal color 46 selection_color 1 labelsize 10 align 4 textsize 9 code0 {o->value(tree->margintop());} code1 {o->range(0.0, 100.0);} code2 {o->step(1.0);} @@ -320,7 +391,7 @@ tree->redraw();} callback {int val = (int)marginleft_slider->value(); tree->marginleft(val); tree->redraw();} - tooltip {Changes the left margin for the tree widget} xywh {470 51 155 16} type Horizontal color 46 selection_color 1 labelsize 10 align 4 textsize 9 + tooltip {Changes the left margin for the tree widget} xywh {505 60 155 16} type Horizontal color 46 selection_color 1 labelsize 10 align 4 textsize 9 code0 {o->value(tree->marginleft());} code1 {o->range(0.0, 100.0);} code2 {o->step(1.0);} @@ -341,7 +412,7 @@ marginbottom_slider->tooltip("DISABLED.\\n" "to get this feature"); \#endif} tooltip {Changes the bottom margin for the tree -Sets how far beyond bottom of tree you can scroll} xywh {470 71 155 16} type Horizontal color 46 selection_color 1 labelsize 10 align 4 textsize 9 +Sets how far beyond bottom of tree you can scroll} xywh {505 80 155 16} type Horizontal color 46 selection_color 1 labelsize 10 align 4 textsize 9 code0 {o->value(GetTreeMarginBottom()); // handle ABI feature} code1 {o->range(0.0, 275.0);} code2 {o->step(1.0);} @@ -353,7 +424,7 @@ Sets how far beyond bottom of tree you can scroll} xywh {470 71 155 16} type Hor callback {int val = (int)linespacing_slider->value(); tree->linespacing(val); tree->redraw();} - tooltip {Changes the spacing between items in the tree} xywh {470 91 155 16} type Horizontal color 46 selection_color 1 labelsize 10 align 4 textsize 9 + tooltip {Changes the spacing between items in the tree} xywh {505 100 155 16} type Horizontal color 46 selection_color 1 labelsize 10 align 4 textsize 9 code0 {o->value(tree->linespacing());} code1 {o->range(0.0, 100.0);} code2 {o->step(1.0);} @@ -364,7 +435,7 @@ tree->redraw();} callback {int val = (int)usericonmarginleft_slider->value(); tree->usericonmarginleft(val); tree->redraw();} - tooltip {Changes the left margin for the user icons (if any)} xywh {470 111 155 16} type Horizontal color 46 selection_color 1 labelsize 10 align 4 textsize 9 + tooltip {Changes the left margin for the user icons (if any)} xywh {505 120 155 16} type Horizontal color 46 selection_color 1 labelsize 10 align 4 textsize 9 code0 {o->value(tree->usericonmarginleft());} code1 {o->range(0.0, 100.0);} code2 {o->step(1.0);} @@ -375,7 +446,7 @@ tree->redraw();} callback {int val = (int)labelmarginleft_slider->value(); tree->labelmarginleft(val); tree->redraw();} - tooltip {Changes the left margin for the item label} xywh {470 131 155 16} type Horizontal color 46 selection_color 1 labelsize 10 align 4 textsize 9 + tooltip {Changes the left margin for the item label} xywh {505 140 155 16} type Horizontal color 46 selection_color 1 labelsize 10 align 4 textsize 9 code0 {o->value(tree->labelmarginleft());} code1 {o->range(0.0, 100.0);} code2 {o->step(1.0);} @@ -393,7 +464,7 @@ widgetmarginleft_slider->tooltip("DISABLED.\\n" "Set FLTK_ABI_VERSION to 10302 (or higher)\\n" "to get this feature"); \#endif} - tooltip {Changes the margin to the left of child FLTK widget()} xywh {470 151 155 16} type Horizontal color 46 selection_color 1 labelsize 10 align 4 textsize 9 + tooltip {Changes the margin to the left of child FLTK widget()} xywh {505 160 155 16} type Horizontal color 46 selection_color 1 labelsize 10 align 4 textsize 9 code0 {o->value(GetTreeWidgetMarginLeft()); // handle ABI feature} code1 {o->range(0.0, 100.0);} code2 {o->step(1.0);} @@ -405,11 +476,21 @@ widgetmarginleft_slider->tooltip("DISABLED.\\n" 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 {470 171 155 16} type Horizontal color 46 selection_color 1 labelsize 10 align 4 textsize 9 + tooltip {Changes the vertical space below an open child tree} xywh {505 180 155 16} type Horizontal color 46 selection_color 1 labelsize 10 align 4 textsize 9 code0 {o->value(tree->openchild_marginbottom());} code1 {o->range(0.0, 100.0);} code2 {o->step(1.0);} } + Fl_Value_Slider connectorwidth_slider { + label {connectorwidth()} + user_data tree + callback {tree->connectorwidth((int)connectorwidth_slider->value());} + tooltip {Tests Fl_Tree::connectorwidth()} xywh {505 199 155 16} type Horizontal color 46 selection_color 1 labelsize 11 align 4 textsize 9 + 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_Choice collapseicons_chooser { label {Collapse icons} callback {static const char *L_open_xpm[] = { @@ -499,7 +580,7 @@ switch ( collapseicons_chooser->value() ) { tree->showcollapse(0); break; }} - tooltip {Tests Fl_Tree::openicon() and Fl_Tree::closeicon()} xywh {485 201 140 21} down_box BORDER_BOX labelsize 12 textsize 11 + tooltip {Tests Fl_Tree::openicon() and Fl_Tree::closeicon()} xywh {520 225 140 21} down_box BORDER_BOX labelsize 12 textsize 11 } { MenuItem {} { label Normal @@ -522,7 +603,7 @@ switch ( connectorstyle_chooser->value() ) { case 1: tree->connectorstyle(FL_TREE_CONNECTOR_DOTTED); break; case 2: tree->connectorstyle(FL_TREE_CONNECTOR_SOLID); break; }} - tooltip {Tests connectorstyle() bit flags} xywh {485 225 140 21} down_box BORDER_BOX labelsize 12 textsize 11 + tooltip {Tests connectorstyle() bit flags} xywh {520 249 140 21} 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 {} { @@ -547,7 +628,7 @@ switch ( selectmode_chooser->value() ) { 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 {485 249 140 21} down_box BORDER_BOX labelsize 12 textsize 11 + tooltip {Sets how Fl_Tree handles mouse selection of tree items} xywh {520 273 140 21} down_box BORDER_BOX labelsize 12 textsize 11 code0 {selectmode_chooser->value(2);} code1 {cb_selectmode_chooser(selectmode_chooser, (void*)0);} } { @@ -582,7 +663,7 @@ reselectmode_chooser->tooltip("DISABLED.\\n" window->redraw(); // deactivated \#endif} tooltip {Enable 'reselect' events -These happen when mouse drags or multi-clicks an item} xywh {485 273 140 21} down_box BORDER_BOX labelsize 12 textsize 11 +These happen when mouse drags or multi-clicks an item} xywh {520 297 140 21} down_box BORDER_BOX labelsize 12 textsize 11 code0 {reselectmode_chooser->value(1);} code1 {reselectmode_chooser->do_callback();} } { @@ -604,7 +685,7 @@ switch ( whenmode_chooser->value() ) { case 2: tree->when(FL_WHEN_NEVER); break; default: tree->when(FL_WHEN_RELEASE); break; }} - tooltip {Sets when() the tree's callback is invoked} xywh {485 299 140 21} down_box BORDER_BOX labelsize 12 textsize 11 + tooltip {Sets when() the tree's callback is invoked} xywh {520 323 140 21} down_box BORDER_BOX labelsize 12 textsize 11 code0 {whenmode_chooser->value(1);} code1 {cb_whenmode_chooser(whenmode_chooser, (void*)0);} } { @@ -625,7 +706,7 @@ switch ( whenmode_chooser->value() ) { label {Enable user icons?} user_data tree callback {AssignUserIcons();} - tooltip {Tests Fl_Tree_Item::usericon()} xywh {450 353 20 16} down_box DOWN_BOX labelsize 11 align 7 + tooltip {Tests Fl_Tree_Item::usericon()} xywh {485 355 20 16} down_box DOWN_BOX labelsize 11 align 7 code0 {usericon_radio->value(1);} } Fl_Check_Button showroot_radio { @@ -633,7 +714,7 @@ switch ( whenmode_chooser->value() ) { user_data tree callback {int onoff = showroot_radio->value(); tree->showroot(onoff);} - tooltip {Tests tree->showroot();} xywh {450 370 20 16} down_box DOWN_BOX labelsize 11 align 7 + tooltip {Tests tree->showroot();} xywh {485 372 20 16} down_box DOWN_BOX labelsize 11 align 7 code0 {int onoff = tree->showroot(); showroot_radio->value(onoff);} } Fl_Check_Button visiblefocus_checkbox { @@ -641,18 +722,9 @@ tree->showroot(onoff);} user_data tree callback {int onoff = visiblefocus_checkbox->value(); tree->visible_focus(onoff);} - tooltip {Toggles the tree's visible_focus() box} xywh {450 387 20 16} down_box DOWN_BOX labelsize 11 align 7 + tooltip {Toggles the tree's visible_focus() box} xywh {485 389 20 16} down_box DOWN_BOX labelsize 11 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 {450 409 16 16} box DOWN_BOX labelsize 11 align 7 - code0 {o->color(tree->selection_color());} - } Fl_Check_Button labelandwidget_radio { label {Show label + widget} callback {\#if FLTK_ABI_VERSION >= 10302 @@ -673,7 +745,7 @@ labelandwidget_radio->tooltip("DISABLED.\\n" window->redraw(); // deactivated \#endif} tooltip {Enables both label and widget() for display. -By default, the widget() is shown in place of the item's label} xywh {610 354 20 16} down_box DOWN_BOX labelsize 11 align 7 +When enabled, widget should appear to the right of the item's label. By default, the widget() is shown in place of the item's label.} xywh {645 356 20 16} down_box DOWN_BOX labelsize 11 align 7 code0 {labelandwidget_radio->value(0);} code1 {labelandwidget_radio->do_callback();} } @@ -695,20 +767,20 @@ itemheightfromwidget_radio->tooltip("DISABLED.\\n" "Set FLTK_ABI_VERSION to 10302 (or higher)\\n" "to get this feature"); window->redraw(); // deactivated -\#endif} selected +\#endif} tooltip {If enabled, item's height will track the widget()'s height. -When enabled, click 'ccc' or 'D1/D2' buttons to test} xywh {610 369 20 16} down_box DOWN_BOX labelsize 11 align 7 +When enabled, click 'ccc' or 'D1/D2' buttons to test.} xywh {645 371 20 16} down_box DOWN_BOX labelsize 11 align 7 code0 {itemheightfromwidget_radio->value(0);} code1 {itemheightfromwidget_radio->do_callback();} } 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 {315 450 330 125} box GTK_DOWN_BOX color 47 labelsize 12 align 1 + tooltip {These controls only affect the defaults for new items that are created. These test the Fl_Tree_Prefs methods.} xywh {350 435 330 125} box GTK_DOWN_BOX color 47 labelsize 12 align 1 } Fl_Box showitem_box { label {show_item() } - xywh {335 475 70 82} box GTK_DOWN_BOX labelsize 11 align 1 + xywh {370 460 70 82} box GTK_DOWN_BOX labelsize 11 align 1 } Fl_Button {} { label Show @@ -716,7 +788,7 @@ When enabled, click 'ccc' or 'D1/D2' buttons to test} xywh {610 369 20 16} down_ 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 {350 484 40 17} labelsize 11 +No change made if it is not off-screen.} xywh {385 469 40 17} labelsize 11 } Fl_Button {} { label Top @@ -728,7 +800,7 @@ Scrolls selected item to the top of the display To use: 1) open '500 items' 2) select item 0010 -3) Hit Top/Mid/Bot} xywh {350 501 40 16} labelsize 11 +3) Hit Top/Mid/Bot} xywh {385 486 40 16} labelsize 11 } Fl_Button {} { label Mid @@ -739,7 +811,7 @@ 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 {350 517 40 16} labelsize 11 + 3) Hit Top/Mid/Bot} xywh {385 502 40 16} labelsize 11 } Fl_Button {} { label Bot @@ -750,7 +822,7 @@ 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 {350 533 40 16} labelsize 11 + 3) Hit Top/Mid/Bot} xywh {385 518 40 16} labelsize 11 } Fl_Button openall_button { label {Open All} @@ -761,7 +833,7 @@ To use: item->open(); } tree->redraw();} - tooltip {Opens all nodes that have children} xywh {435 466 95 16} labelsize 9 + tooltip {Opens all nodes that have children} xywh {470 451 95 16} labelsize 9 } Fl_Button loaddb_button { label {Load Database...} @@ -772,7 +844,7 @@ if (filename) { tree->load(prefs); tree->redraw(); }} - tooltip {Load the contents of an Fl_Preferences database into the tree view} xywh {435 486 95 16} labelsize 9 + tooltip {Load the contents of an Fl_Preferences database into the tree view} xywh {470 471 95 16} labelsize 9 } Fl_Button insertabove_button { label {Insert Above} @@ -787,12 +859,12 @@ while (item) { } tree->redraw();} - tooltip {Inserts three items above the selected items} xywh {435 506 95 16} labelsize 9 + tooltip {Inserts three items above the selected items} xywh {470 491 95 16} labelsize 9 } Fl_Button rebuildtree_button { label {Rebuild Tree} callback {RebuildTree();} - tooltip {Rebuilds the tree with defaults} xywh {435 526 95 16} labelsize 9 + tooltip {Rebuilds the tree with defaults} xywh {470 511 95 16} labelsize 9 } Fl_Button showpathname_button { label {Show Pathname} @@ -805,7 +877,7 @@ 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 {435 546 95 16} labelsize 9 + tooltip {Show the pathname for the selected item. Tests the Fl_Tree::item_pathname() method.} xywh {470 531 95 16} labelsize 9 } Fl_Button closeall_button { label {Close All} @@ -817,14 +889,14 @@ switch ( tree->item_pathname(pathname, sizeof(pathname), item) ) { } tree->redraw();} tooltip {Closes all nodes that have children -(doesn't affect 'root')} xywh {535 466 95 16} labelsize 9 +(doesn't affect 'root')} xywh {570 451 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 {535 486 95 16} labelsize 9 +Tests Fl_Tree::clear()} xywh {570 471 95 16} labelsize 9 } Fl_Button testcallbackflag_button { label {Test Callback Flag} @@ -889,14 +961,14 @@ 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 {535 506 95 16} labelsize 9 + tooltip {Test the 'docallback' argument can disable callbacks.} xywh {570 491 95 16} labelsize 9 } Fl_Button testrootshowself_button { label {Root Show Self} callback {Fl_Tree_Item *root = tree->root(); fprintf(stderr, "--- Show Tree\\n"); if (root) root->show_self();} - tooltip {Test the root->'show_self() method to show the entire tree on stdout} xywh {534 526 95 16} labelsize 9 + tooltip {Test the root->'show_self() method to show the entire tree on stdout} xywh {570 511 95 16} labelsize 9 } Fl_Button add20k_button { label {Add 20,000} @@ -917,20 +989,20 @@ while (item) { item = item->next(); } tree->redraw();} - tooltip {Adds 20,000 items to the selected item's parent} xywh {534 546 95 16} labelsize 9 + tooltip {Adds 20,000 items to the selected item's parent} xywh {570 531 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 410} box GTK_DOWN_BOX color 47 labelsize 12 align 1 + tooltip {These controls only affect the selected items. If no items are selected, all existing items in tree are modified.} xywh {696 23 335 246} box GTK_DOWN_BOX color 47 labelsize 12 align 1 } - Fl_Choice all_font_choice { - label {Label Font} + Fl_Choice selected_labelfont_choice { + label {Fl_Tree_Item::labelfont()} 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 +Fl_Font val = (Fl_Font)selected_labelfont_choice->value(); // Get font value // Do selected items int count = 0; @@ -949,7 +1021,7 @@ if ( ! count ) { } 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 21} down_box BORDER_BOX labelsize 12 textsize 11 + tooltip {Changes the font for the selected items's labels. If none selected, all are changed. Tests Fl_Tree_Item::labelfont();} xywh {863 31 140 21} down_box BORDER_BOX labelsize 11 textsize 11 code0 {o->value((int)tree->item_labelfont()); // get tree's current font, assign to chooser} } { MenuItem {} { @@ -1017,10 +1089,10 @@ tree->redraw();} xywh {90 90 36 21} labelsize 12 } } - Fl_Value_Slider labelsize_slider { - label {Label Size} + Fl_Value_Slider selected_labelsize_slider { + label {Fl_Tree_Item::labelsize()} user_data tree - callback {int size = (int)labelsize_slider->value(); + callback {int size = (int)selected_labelsize_slider->value(); // DO SELECTED ITEMS int count = 0; @@ -1040,24 +1112,22 @@ if ( ! count ) { } 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 55 140 16} type Horizontal labelsize 12 align 4 textsize 12 + tooltip {Changes the font size of the selected items's labels. If none selected, all are changed. Tests Fl_Tree_Item::labelsize();} xywh {863 55 140 16} type Horizontal color 46 selection_color 1 labelsize 11 align 4 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 + label {Fl_Tree_Item::labelfgcolor()} + callback {// Get first item's color +Fl_Color val = GetSelectedItemFGColor(); // Get color of first selected item +if ( EditColor(val) == 0 ) return; // Let user edit color. (return if they hit 'Cancel') all_labelfgcolor_button->color(val); // update modified color to button // Do selected items int count = 0; +Fl_Tree_Item *item; for ( item=tree->first(); item; item = tree->next(item) ) { if ( item->is_selected() ) { item->labelfgcolor(val); @@ -1073,21 +1143,19 @@ if ( ! count ) { } 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 81 16 16} box DOWN_BOX labelsize 12 align 7 - code0 {o->color(tree->item_labelfgcolor());} + tooltip {Sets the Fl_Tree_Item::labelfgcolor() for the selected items. If none selected, all are changed.} xywh {863 81 16 16} box DOWN_BOX labelsize 11 align 7 + code0 {o->color(GetSelectedItemFGColor());} } 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 + label {Fl_Tree_Item::labelbgcolor()} + callback {// Get first item's color +Fl_Color val = GetSelectedItemBGColor(); // Get color of first selected item +if ( EditColor(val) == 0 ) return; // Let user edit color. (return if they hit 'Cancel') all_labelbgcolor_button->color(val); // update modified color to button // Do selected items int count = 0; +Fl_Tree_Item *item; for ( item=tree->first(); item; item = tree->next(item) ) { if ( item->is_selected() ) { item->labelbgcolor(val); @@ -1103,18 +1171,8 @@ if ( ! count ) { } 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 99 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 126 140 16} type Horizontal labelsize 12 align 4 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);} + tooltip {Sets the Fl_Tree_Item::labelbgcolor() for the selected items. If none selected, all are changed.} xywh {863 99 16 16} box DOWN_BOX labelsize 11 align 7 + code0 {o->color(GetSelectedItemBGColor());} } Fl_Light_Button deactivate_toggle { label { Deactivate} @@ -1137,7 +1195,7 @@ if ( count == 0 ) { tree->redraw();} tooltip {Toggle the deactivation state of the selected items. -If none are selected, all are set.} xywh {734 154 95 16} selection_color 1 labelsize 9 +If none are selected, all are set.} xywh {769 134 95 16} selection_color 1 labelsize 9 } Fl_Light_Button bold_toggle { label { Bold Font} @@ -1162,7 +1220,7 @@ if ( ! count ) { tree->redraw();} tooltip {Toggles bold font for selected items -If nothing selected, all are changed} xywh {734 174 95 16} selection_color 1 labelsize 9 +If nothing selected, all are changed} xywh {769 154 95 16} selection_color 1 labelsize 9 } Fl_Button showselected_button { label {Show Selected} @@ -1172,7 +1230,7 @@ for ( Fl_Tree_Item *item = tree->first_selected_item(); item = tree->next_selected_item(item) ) { fprintf(stderr, "\\t%s\\n", item->label() ? item->label() : "???"); }} - tooltip {Clears the selected items} xywh {829 154 95 16} labelsize 9 + tooltip {Clears the selected items} xywh {864 134 95 16} labelsize 9 } Fl_Button clearselected_button { label {Remove Selected} @@ -1187,7 +1245,7 @@ while (item) { } tree->redraw();} - tooltip {Removes the selected items} xywh {829 174 95 16} labelsize 9 + tooltip {Removes the selected items} xywh {864 154 95 16} labelsize 9 } Fl_Button swapselected_button { label {Swap Selected} @@ -1217,19 +1275,19 @@ if ( pa != pb ) { pa->swap_children(a,b); tree->redraw();} tooltip {Tests the Fl_Tree_Item::swap_children() method -Swaps two selected items (items must be siblings)} xywh {829 194 95 16} labelsize 9 +Swaps two selected items (items must be siblings)} xywh {864 174 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 219 95 16} labelsize 9 + tooltip {Selects all items in the tree} xywh {724 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 239 95 16} labelsize 9 + tooltip {Deselects all items in the tree} xywh {724 219 95 16} labelsize 9 } Fl_Light_Button bbbselect_toggle { label { Select Bbb} @@ -1243,7 +1301,7 @@ 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 219 95 16} selection_color 1 labelsize 9 +(Not children)} xywh {819 199 95 16} selection_color 1 labelsize 9 } Fl_Light_Button bbbselect2_toggle { label { Select Bbb+} @@ -1256,7 +1314,7 @@ if ( !bbb) { 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 239 95 16} selection_color 1 labelsize 9 + tooltip {Toggle selection of the /Bbb item and its children} xywh {819 219 95 16} selection_color 1 labelsize 9 } Fl_Light_Button bbbchild02select_toggle { label { Toggle child-02} @@ -1271,7 +1329,7 @@ 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 259 95 16} selection_color 1 labelsize 9 + tooltip {Toggle the single item "/Bbb/child-02" using the item's "pathname".} xywh {819 239 95 16} selection_color 1 labelsize 9 } Fl_Light_Button rootselect_toggle { label {Select ROOT} @@ -1284,7 +1342,7 @@ if ( !item) { 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 219 95 16} selection_color 1 labelsize 9 + tooltip {Toggle selection of the ROOT item} xywh {914 199 95 16} selection_color 1 labelsize 9 } Fl_Light_Button rootselect2_toggle { label {Select ROOT+} @@ -1297,110 +1355,308 @@ if ( !item) { 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 239 95 16} selection_color 1 labelsize 9 + tooltip {Toggle selection of the ROOT item and all children} xywh {914 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 {660 450 335 125} box GTK_DOWN_BOX color 47 labelsize 12 align 1 + label {Tree Fonts + Colors} + tooltip {These controls only affect the selected items. If no items are selected, all existing items in tree are modified.} xywh {695 298 335 244} 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 {832 472 16 16} box DOWN_BOX labelsize 12 align 7 - code0 {o->color(tree->item_labelfgcolor());} + Fl_Choice labelfont_choice { + label {labelfont()} + callback {Fl_Font val = (Fl_Font)labelfont_choice->value(); +tree->labelfont(val); +window->redraw();} + tooltip {Sets the default font used for new items created. Does NOT affect existing items.} xywh {850 319 140 21} down_box BORDER_BOX labelsize 12 textsize 12 + code0 {o->value((int)tree->labelfont()); // get tree's current font, assign to chooser} + } { + MenuItem {} { + label Helvetica + xywh {35 35 36 21} labelsize 12 + } + MenuItem {} { + label {Helvetica Bold} + xywh {45 45 36 21} labelsize 12 + } + MenuItem {} { + label {Helvetica Italic} + xywh {60 60 36 21} labelsize 12 + } + MenuItem {} { + label {Helvetica Bold Italic} + xywh {65 65 36 21} labelsize 12 + } + MenuItem {} { + label Courier + xywh {75 75 36 21} labelsize 12 + } + MenuItem {} { + label {Courier Bold} + xywh {85 85 36 21} labelsize 12 + } + MenuItem {} { + label {Courier Italic} + xywh {70 70 36 21} labelsize 12 + } + MenuItem {} { + label {Courier Bold Italic} + xywh {75 75 36 21} labelsize 12 + } + MenuItem {} { + label Times + xywh {85 85 36 21} labelsize 12 + } + MenuItem {} { + label {Times Bold} + xywh {95 95 36 21} labelsize 12 + } + MenuItem {} { + label {Times Italic} + xywh {80 80 36 21} labelsize 12 + } + MenuItem {} { + label {Times Bold Italic} + xywh {85 85 36 21} labelsize 12 + } + MenuItem {} { + label Symbol + xywh {95 95 36 21} labelsize 12 + } + MenuItem {} { + label Screen + xywh {105 105 36 21} labelsize 12 + } + MenuItem {} { + label {Screen bold} + xywh {90 90 36 21} labelsize 12 + } + MenuItem {} { + label {Zapf Dingbats} + xywh {95 95 36 21} labelsize 12 + } } - 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 {832 490 16 16} box DOWN_BOX labelsize 12 align 7 - code0 {item_labelbgcolor_button->color(tree->item_labelbgcolor());} + Fl_Value_Slider labelsize_slider { + label {labelsize()} + user_data tree + callback {tree->labelsize((int)labelsize_slider->value()); +window->redraw();} + tooltip {Sets the font size for the tree's label(). +This is also the font size that will be used to draw the items IF their size hasn't been set with Fl_Tree_Item::labelsize() or Fl_Tree::item_labelsize()} xywh {850 343 140 16} type Horizontal color 46 selection_color 1 labelsize 12 align 4 textsize 12 + code0 {o->value((int)tree->labelsize());} + code1 {o->range(1.0, 50.0);} + code2 {o->step(1.0);} + code3 {o->color(46); o->selection_color(FL_RED);} } - 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 {832 516 140 21} down_box BORDER_BOX labelsize 12 textsize 12 - code0 {o->value((int)tree->item_labelfont()); // get tree's current font, assign to chooser} + Fl_Choice item_labelfont_choice { + label {Item_labelfont()} + callback {Fl_Font val = (Fl_Font)item_labelfont_choice->value(); +tree->item_labelfont(val); +tree->redraw();} + tooltip {Sets the default font used for new items created. +.Also affects any items whose font has NOT specifically been set with item->labelfont().} xywh {850 363 140 21} down_box BORDER_BOX labelsize 12 textsize 12 + code0 {o->value((int)tree->item_labelfont());} } { MenuItem {} { label Helvetica - xywh {20 20 36 21} labelsize 12 + xywh {25 25 36 21} labelsize 12 } MenuItem {} { label {Helvetica Bold} - xywh {30 30 36 21} labelsize 12 + xywh {35 35 36 21} labelsize 12 } MenuItem {} { label {Helvetica Italic} - xywh {45 45 36 21} labelsize 12 + xywh {50 50 36 21} labelsize 12 } MenuItem {} { label {Helvetica Bold Italic} - xywh {50 50 36 21} labelsize 12 + xywh {55 55 36 21} labelsize 12 } MenuItem {} { label Courier - xywh {60 60 36 21} labelsize 12 + xywh {65 65 36 21} labelsize 12 } MenuItem {} { label {Courier Bold} - xywh {70 70 36 21} labelsize 12 + xywh {75 75 36 21} labelsize 12 } MenuItem {} { label {Courier Italic} - xywh {55 55 36 21} labelsize 12 + xywh {60 60 36 21} labelsize 12 } MenuItem {} { label {Courier Bold Italic} - xywh {60 60 36 21} labelsize 12 + xywh {65 65 36 21} labelsize 12 } MenuItem {} { label Times - xywh {70 70 36 21} labelsize 12 + xywh {75 75 36 21} labelsize 12 } MenuItem {} { label {Times Bold} - xywh {80 80 36 21} labelsize 12 + xywh {85 85 36 21} labelsize 12 } MenuItem {} { label {Times Italic} - xywh {65 65 36 21} labelsize 12 + xywh {70 70 36 21} labelsize 12 } MenuItem {} { label {Times Bold Italic} - xywh {70 70 36 21} labelsize 12 + xywh {75 75 36 21} labelsize 12 } MenuItem {} { label Symbol - xywh {80 80 36 21} labelsize 12 + xywh {85 85 36 21} labelsize 12 } MenuItem {} { label Screen - xywh {90 90 36 21} labelsize 12 + xywh {95 95 36 21} labelsize 12 } MenuItem {} { label {Screen bold} - xywh {75 75 36 21} labelsize 12 + xywh {80 80 36 21} labelsize 12 } MenuItem {} { label {Zapf Dingbats} - xywh {80 80 36 21} labelsize 12 + xywh {85 85 36 21} labelsize 12 } } Fl_Value_Slider item_labelsize_slider { - label item_labelsize + 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 {832 541 140 16} type Horizontal labelsize 12 align 4 textsize 12 + callback {tree->item_labelsize((int)item_labelsize_slider->value()); +tree->redraw();} + tooltip {Sets the default font size used for new items created. +.Also affects any items whose font size has NOT specifically been set with item->labelsize().} xywh {850 388 140 16} type Horizontal color 46 selection_color 1 labelsize 12 align 4 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_Button labelcolor_button { + label {labelcolor()} + callback {Fl_Color val = tree->labelcolor(); +if ( EditColor(val) == 0 ) return; // Let user edit color. (return if they hit 'Cancel') +labelcolor_button->color(val); // update modified color to button +tree->labelcolor(val); +window->redraw(); // affects window (tree's label is outside tree's area)} + tooltip {Changes Fl_Tree::labelcolor(). +This affects the text color of the widget's label.} xywh {815 458 16 16} box DOWN_BOX labelsize 11 align 7 + code0 {o->color(tree->labelcolor());} + } + Fl_Button color_button { + label {color()} + callback {Fl_Color val = tree->color(); +if ( EditColor(val) == 0 ) return; // Let user edit color. (return if they hit 'Cancel') +color_button->color(val); // update modified color to button +tree->color(val); +UpdateColorChips(); +tree->redraw();} + tooltip {Changes Fl_Tree::color(). +This affects the background color of the widget. It also affects the bg color of newly created items *if* Fl_Tree::item_labelbgcolor() hasn't been changed.} xywh {815 477 16 16} box DOWN_BOX labelsize 11 align 7 + code0 {o->color(tree->color());} + } + Fl_Button selection_color_button { + label {selection_color()} + callback {Fl_Color val = tree->selection_color(); +if ( EditColor(val) == 0 ) return; // Let user edit color. (return if they hit 'Cancel') +selection_color_button->color(val); // update modified color to button +tree->selection_color(val); +tree->redraw();} + tooltip {Sets the Fl_Tree::selection_color(). +This affects the item's colors when they're selected.} xywh {815 496 16 16} box DOWN_BOX labelsize 11 align 7 + code0 {o->color(tree->selection_color());} + } + Fl_Button item_labelfgcolor_button { + label {item_labelfgcolor()} + callback {Fl_Color val = tree->item_labelfgcolor(); +if ( EditColor(val) == 0 ) return; // Let user edit color. (return if they hit 'Cancel') +tree->item_labelfgcolor(val); // apply modified color to tree +item_labelfgcolor_button->color(val); // update modified color to button +tree->redraw();} + tooltip {Sets the default label fg color for newly created items.} xywh {975 458 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 = tree->item_labelbgcolor(); +if ( EditColor(val) == 0 ) return; // Let user edit color. (return if they hit 'Cancel') +tree->item_labelbgcolor(val); // apply modified color to tree +item_labelbgcolor_button->color(val); // update modified color to button +tree->redraw();} + tooltip {Sets the default label bg color for newly created items. When set, this overrides the default behavior of using Fl_Tree::color().} xywh {975 477 16 16} box DOWN_BOX labelsize 12 align 7 + code0 {item_labelbgcolor_button->color(tree->item_labelbgcolor());} + } + Fl_Button testsuggs_button { + label {Test Suggestions} + callback {const char *helpmsg = +"CHILD WIDGET SIZING TESTS\\n" +"=========================\\n" +" 1) Start program\\n" +" 2) Click the 'ccc button' and D1/D2 buttons.\\n" +" Their sizes should not change.\\n" +" 3) Click the 'Item h() from widget' checkbox.\\n" +" 4) Click the 'ccc button' and D1/D2 buttons.\\n" +" Their sizes should change, getting larger vertically.\\n" +" This validates that widget's size can affect the tree.\\n" +" 5) Disable the checkbox, widgets should resize back to the\\n" +" size of the other items.\\n" +" 6) Hit ^A to select all items\\n" +" 7) Under 'Selected Items', drag the 'Label Size' slider around.\\n" +" All the item's height should change, as well as child widgets.\\n" +" 8) Put Label Size' slider back to normal\\n" +"\\n" +"CHILD WIDGET + LABEL ITEM DRAWING TESTS\\n" +"=======================================\\n" +" 1) Start program\\n" +" 2) Click 'Show label + widget'.\\n" +" The widgets should all show item labels to their left.\\n" +" 3) Disable same, item labels should disappear,\\n" +" showing the widgets in their place.\\n" +"\\n" +" COLORS\\n" +" ======\\n" +" 1) Start program\\n" +" 2) Change 'Tree Fonts+Colors' -> color()\\n" +" 3) Entire tree's background color will change, including items.\\n" +" 4) Change the 'Tree Fonts + Colors -> item_labelbgcolor()'\\n" +" 6) Click the '111' item to select it.\\n" +" 7) Click 'Test Operations -> Insert Above'\\n" +" New items should appear above the selected item using the new color.\\n" +" This color will be different from the background color.\\n" +" 8) Change the 'Tree Fonts+Colors' -> color()\\n" +" The entire tree's bg should change, except the new items.\\n" +" 9) Click the Tree Fonts+Colors -> item_labelbgcolor() 'X' button.\\n" +" This resets item_labelbgcolor() to the default 'transparent' color (0xffffffff)\\n" +" 10) Again, click the 'Insert Above' button.\\n" +" New items will be created in the background color, and changing the color()\\n" +" should affect the new items too.\\n" +""; + +static Fl_Double_Window *helpwin = 0; +static Fl_Text_Display *helpdisp = 0; +static Fl_Text_Buffer *helpbuff = 0; +if ( !helpwin ) { + Fl_Group::current(0); // ensure we don't become child of other win + helpwin = new Fl_Double_Window(600,600,"Test Suggestions"); + helpdisp = new Fl_Text_Display(0,0,helpwin->w(),helpwin->h()); + helpbuff = new Fl_Text_Buffer(); + helpdisp->buffer(helpbuff); + helpdisp->textfont(FL_COURIER); + helpdisp->textsize(12); + helpbuff->text(helpmsg); + helpwin->end(); +} +helpwin->resizable(helpdisp); +helpwin->show();} selected + tooltip {Suggestions on how to do tests} xywh {935 554 95 16} labelsize 9 + } + Fl_Button x_item_labelbgcolor_button { + label X + callback {tree->item_labelbgcolor(0xffffffff); +UpdateColorChips(); +tree->redraw();} + tooltip {Make the bgcolor 'transparent' (0xffffffff)} xywh {995 477 16 16} labelsize 10 align 16 + } } Fl_Box resizer_box { xywh {0 263 15 14} |
