mirror of
https://github.com/fltk/fltk.git
synced 2026-06-04 15:32:12 +08:00
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
This commit is contained in:
+45
-14
@@ -80,6 +80,8 @@
|
|||||||
/// tree.end();
|
/// tree.end();
|
||||||
/// \endcode
|
/// \endcode
|
||||||
///
|
///
|
||||||
|
/// \b FEATURES
|
||||||
|
///
|
||||||
/// Items can be added with add(),
|
/// Items can be added with add(),
|
||||||
/// removed with remove(),
|
/// removed with remove(),
|
||||||
/// completely cleared with clear(),
|
/// completely cleared with clear(),
|
||||||
@@ -95,7 +97,13 @@
|
|||||||
/// and an item's pathname can be found with item_pathname().
|
/// 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 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 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
|
/// FLTK widgets (including custom widgets) can be assigned to tree items via
|
||||||
/// Fl_Tree_Item::widget().
|
/// Fl_Tree_Item::widget().
|
||||||
@@ -110,6 +118,8 @@
|
|||||||
/// adding the FL_TREE_ITEM_HEIGHT_FROM_WIDGET flag causes widget's height
|
/// adding the FL_TREE_ITEM_HEIGHT_FROM_WIDGET flag causes widget's height
|
||||||
/// to define the widget()'s height.
|
/// to define the widget()'s height.
|
||||||
///
|
///
|
||||||
|
/// \b ICONS
|
||||||
|
///
|
||||||
/// The tree's open/close icons can be redefined with
|
/// The tree's open/close icons can be redefined with
|
||||||
/// Fl_Tree::openicon(), Fl_Tree::closeicon(). User icons
|
/// Fl_Tree::openicon(), Fl_Tree::closeicon(). User icons
|
||||||
/// can either be changed globally with Fl_Tree::usericon(),
|
/// can either be changed globally with Fl_Tree::usericon(),
|
||||||
@@ -118,6 +128,27 @@
|
|||||||
/// Various default preferences can be globally manipulated via Fl_Tree_Prefs,
|
/// Various default preferences can be globally manipulated via Fl_Tree_Prefs,
|
||||||
/// including colors, margins, icons, connection lines, etc.
|
/// 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.
|
/// The tree's callback() will be invoked when items change state or are open/closed.
|
||||||
/// when() controls when mouse/keyboard events invoke the callback.
|
/// 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:
|
/// 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
|
FL_TREE_REASON_DESELECTED, ///< an item was de-selected
|
||||||
#if FLTK_ABI_VERSION >= 10302
|
#if FLTK_ABI_VERSION >= 10302
|
||||||
FL_TREE_REASON_RESELECTED, ///< an item was re-selected (e.g. double-clicked)
|
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_OPENED, ///< an item was opened
|
||||||
FL_TREE_REASON_CLOSED ///< an item was closed
|
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
|
#if FLTK_ABI_VERSION >= 10302
|
||||||
// NEW:
|
// NEW:
|
||||||
Fl_Tree_Item *_lastselect;
|
Fl_Tree_Item *_lastselect;
|
||||||
#else
|
#else /*FLTK_ABI_VERSION*/
|
||||||
// OLD: static data inside handle() method
|
// OLD: static data inside handle() method
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
|
|
||||||
void fix_scrollbar_order();
|
void fix_scrollbar_order();
|
||||||
|
|
||||||
@@ -368,17 +399,18 @@ public:
|
|||||||
void set_item_focus(Fl_Tree_Item *item);
|
void set_item_focus(Fl_Tree_Item *item);
|
||||||
int is_selected(Fl_Tree_Item *item) const;
|
int is_selected(Fl_Tree_Item *item) const;
|
||||||
int is_selected(const char *path);
|
int is_selected(const char *path);
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Item attribute related methods
|
// Item attribute related methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
Fl_Font item_labelfont() const;
|
||||||
|
void item_labelfont(Fl_Font val);
|
||||||
Fl_Fontsize item_labelsize() const;
|
Fl_Fontsize item_labelsize() const;
|
||||||
void item_labelsize(Fl_Fontsize val);
|
void item_labelsize(Fl_Fontsize val);
|
||||||
Fl_Font item_labelfont() const;
|
Fl_Color item_labelfgcolor(void) const;
|
||||||
void item_labelfont(Fl_Font val);
|
void item_labelfgcolor(Fl_Color val);
|
||||||
Fl_Color item_labelfgcolor(void) const;
|
Fl_Color item_labelbgcolor(void) const;
|
||||||
void item_labelfgcolor(Fl_Color val);
|
void item_labelbgcolor(Fl_Color val);
|
||||||
Fl_Color item_labelbgcolor(void) const;
|
|
||||||
void item_labelbgcolor(Fl_Color val);
|
|
||||||
Fl_Color connectorcolor() const;
|
Fl_Color connectorcolor() const;
|
||||||
void connectorcolor(Fl_Color val);
|
void connectorcolor(Fl_Color val);
|
||||||
int marginleft() const;
|
int marginleft() const;
|
||||||
@@ -388,7 +420,7 @@ public:
|
|||||||
#if FLTK_ABI_VERSION >= 10302
|
#if FLTK_ABI_VERSION >= 10302
|
||||||
int marginbottom() const;
|
int marginbottom() const;
|
||||||
void marginbottom(int val);
|
void marginbottom(int val);
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
int linespacing() const;
|
int linespacing() const;
|
||||||
void linespacing(int val);
|
void linespacing(int val);
|
||||||
int openchild_marginbottom() const;
|
int openchild_marginbottom() const;
|
||||||
@@ -400,7 +432,7 @@ public:
|
|||||||
#if FLTK_ABI_VERSION >= 10302
|
#if FLTK_ABI_VERSION >= 10302
|
||||||
int widgetmarginleft() const;
|
int widgetmarginleft() const;
|
||||||
void widgetmarginleft(int val);
|
void widgetmarginleft(int val);
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
int connectorwidth() const;
|
int connectorwidth() const;
|
||||||
void connectorwidth(int val);
|
void connectorwidth(int val);
|
||||||
Fl_Image* usericon() const;
|
Fl_Image* usericon() const;
|
||||||
@@ -427,8 +459,7 @@ public:
|
|||||||
Fl_Tree_Item_Draw_Mode item_draw_mode() const;
|
Fl_Tree_Item_Draw_Mode item_draw_mode() const;
|
||||||
void item_draw_mode(Fl_Tree_Item_Draw_Mode mode);
|
void item_draw_mode(Fl_Tree_Item_Draw_Mode mode);
|
||||||
void item_draw_mode(int mode);
|
void item_draw_mode(int mode);
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
|
|
||||||
int displayed(Fl_Tree_Item *item);
|
int displayed(Fl_Tree_Item *item);
|
||||||
void show_item(Fl_Tree_Item *item, int yoff);
|
void show_item(Fl_Tree_Item *item, int yoff);
|
||||||
void show_item(Fl_Tree_Item *item);
|
void show_item(Fl_Tree_Item *item);
|
||||||
|
|||||||
+65
-13
@@ -56,11 +56,23 @@ class FL_EXPORT Fl_Tree_Item {
|
|||||||
Fl_Font _labelfont; // label's font face
|
Fl_Font _labelfont; // label's font face
|
||||||
Fl_Fontsize _labelsize; // label's font size
|
Fl_Fontsize _labelsize; // label's font size
|
||||||
Fl_Color _labelfgcolor; // label's fg color
|
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 _open; // item is open?
|
||||||
char _visible; // item is visible?
|
char _visible; // item is visible?
|
||||||
char _active; // item activated?
|
char _active; // item activated?
|
||||||
char _selected; // item selected?
|
char _selected; // item selected?
|
||||||
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
int _xywh[4]; // xywh of this widget (if visible)
|
int _xywh[4]; // xywh of this widget (if visible)
|
||||||
int _collapse_xywh[4]; // xywh of collapse icon (if visible)
|
int _collapse_xywh[4]; // xywh of collapse icon (if visible)
|
||||||
int _label_xywh[4]; // xywh of label
|
int _label_xywh[4]; // xywh of label
|
||||||
@@ -131,10 +143,12 @@ public:
|
|||||||
return(_labelfgcolor);
|
return(_labelfgcolor);
|
||||||
}
|
}
|
||||||
/// Set item's label background color.
|
/// Set item's label background color.
|
||||||
|
/// A special case is made for color 0xffffffff which is treated as 'transparent'.
|
||||||
void labelbgcolor(Fl_Color val) {
|
void labelbgcolor(Fl_Color val) {
|
||||||
_labelbgcolor = val;
|
_labelbgcolor = val;
|
||||||
}
|
}
|
||||||
/// Return item's background text color.
|
/// Return item's background text color.
|
||||||
|
/// If the color is 0xffffffff, it is 'transparent'.
|
||||||
Fl_Color labelbgcolor() const {
|
Fl_Color labelbgcolor() const {
|
||||||
return(_labelbgcolor);
|
return(_labelbgcolor);
|
||||||
}
|
}
|
||||||
@@ -208,26 +222,26 @@ public:
|
|||||||
void close();
|
void close();
|
||||||
/// See if the item is 'open'.
|
/// See if the item is 'open'.
|
||||||
int is_open() const {
|
int is_open() const {
|
||||||
return(_open?1:0);
|
return(is_flag(OPEN));
|
||||||
}
|
}
|
||||||
/// See if the item is 'closed'.
|
/// See if the item is 'closed'.
|
||||||
int is_close() const {
|
int is_close() const {
|
||||||
return(_open?0:1);
|
return(is_flag(OPEN)?0:1);
|
||||||
}
|
}
|
||||||
/// Toggle the item's open/closed state.
|
/// Toggle the item's open/closed state.
|
||||||
void open_toggle() {
|
void open_toggle() {
|
||||||
_open?close():open();
|
is_open()?close():open();
|
||||||
}
|
}
|
||||||
/// Change the item's selection state to the optionally specified 'val'.
|
/// Change the item's selection state to the optionally specified 'val'.
|
||||||
/// If 'val' is not specified, the item will be selected.
|
/// If 'val' is not specified, the item will be selected.
|
||||||
///
|
///
|
||||||
void select(int val=1) {
|
void select(int val=1) {
|
||||||
_selected = val;
|
set_flag(SELECTED, val);
|
||||||
}
|
}
|
||||||
/// Toggle the item's selection state.
|
/// Toggle the item's selection state.
|
||||||
void select_toggle() {
|
void select_toggle() {
|
||||||
if ( is_selected() ) {
|
if ( is_selected() ) {
|
||||||
deselect(); // deselect if selected
|
deselect(); // deselect if selected
|
||||||
} else {
|
} else {
|
||||||
select(); // select if deselected
|
select(); // select if deselected
|
||||||
}
|
}
|
||||||
@@ -249,7 +263,7 @@ public:
|
|||||||
}
|
}
|
||||||
/// Disable the item's selection state.
|
/// Disable the item's selection state.
|
||||||
void deselect() {
|
void deselect() {
|
||||||
_selected = 0;
|
set_flag(SELECTED, 0);
|
||||||
}
|
}
|
||||||
/// Deselect item and all its children.
|
/// Deselect item and all its children.
|
||||||
/// Returns count of how many items were in the 'selected' state,
|
/// Returns count of how many items were in the 'selected' state,
|
||||||
@@ -268,7 +282,7 @@ public:
|
|||||||
}
|
}
|
||||||
/// See if the item is selected.
|
/// See if the item is selected.
|
||||||
char is_selected() const {
|
char is_selected() const {
|
||||||
return(_selected);
|
return(is_flag(SELECTED));
|
||||||
}
|
}
|
||||||
/// Change the item's activation state to the optionally specified 'val'.
|
/// 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.
|
/// If 'val' is not specified, the item will be activated.
|
||||||
///
|
///
|
||||||
void activate(int val=1) {
|
void activate(int val=1) {
|
||||||
_active = val;
|
set_flag(ACTIVE,val);
|
||||||
if ( _widget && val != (int)_widget->active() ) {
|
if ( _widget && val != (int)_widget->active() ) {
|
||||||
if ( val ) {
|
if ( val ) {
|
||||||
_widget->activate();
|
_widget->activate();
|
||||||
@@ -298,15 +312,19 @@ public:
|
|||||||
}
|
}
|
||||||
/// See if the item is activated.
|
/// See if the item is activated.
|
||||||
char is_activated() const {
|
char is_activated() const {
|
||||||
return(_active);
|
return(is_flag(ACTIVE));
|
||||||
}
|
}
|
||||||
/// See if the item is activated.
|
/// See if the item is activated.
|
||||||
char is_active() const {
|
char is_active() const {
|
||||||
return(_active);
|
return(is_activated());
|
||||||
|
}
|
||||||
|
/// See if the item is visible. Alias for is_visible().
|
||||||
|
int visible() const {
|
||||||
|
return(is_visible());
|
||||||
}
|
}
|
||||||
/// See if the item is visible.
|
/// See if the item is visible.
|
||||||
int visible() const {
|
int is_visible() const {
|
||||||
return(_visible ? 1 : 0);
|
return(is_flag(VISIBLE));
|
||||||
}
|
}
|
||||||
int visible_r() const;
|
int visible_r() const;
|
||||||
|
|
||||||
@@ -329,6 +347,40 @@ public:
|
|||||||
int is_root() const {
|
int is_root() const {
|
||||||
return(_parent==0?1:0);
|
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*/
|
#endif /*FL_TREE_ITEM_H*/
|
||||||
|
|||||||
+57
-33
@@ -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_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
|
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
|
/// \class Fl_Tree_Prefs
|
||||||
///
|
///
|
||||||
@@ -119,7 +119,7 @@ class FL_EXPORT Fl_Tree_Prefs {
|
|||||||
int _linespacing; // vertical space between lines
|
int _linespacing; // vertical space between lines
|
||||||
// Colors
|
// Colors
|
||||||
Fl_Color _labelfgcolor; // label's foreground color
|
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_Color _connectorcolor; // connector dotted line color
|
||||||
Fl_Tree_Connector _connectorstyle; // connector line style
|
Fl_Tree_Connector _connectorstyle; // connector line style
|
||||||
Fl_Image *_openimage; // the 'open' icon [+]
|
Fl_Image *_openimage; // the 'open' icon [+]
|
||||||
@@ -133,7 +133,7 @@ class FL_EXPORT Fl_Tree_Prefs {
|
|||||||
#if FLTK_ABI_VERSION >= 10302
|
#if FLTK_ABI_VERSION >= 10302
|
||||||
Fl_Tree_Item_Reselect_Mode _itemreselectmode; // controls item selection callback() behavior
|
Fl_Tree_Item_Reselect_Mode _itemreselectmode; // controls item selection callback() behavior
|
||||||
Fl_Tree_Item_Draw_Mode _itemdrawmode; // controls how items draw label + widget()
|
Fl_Tree_Item_Draw_Mode _itemdrawmode; // controls how items draw label + widget()
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
public:
|
public:
|
||||||
Fl_Tree_Prefs();
|
Fl_Tree_Prefs();
|
||||||
|
|
||||||
@@ -141,21 +141,61 @@ public:
|
|||||||
// Labels
|
// Labels
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
/// Return the label's font.
|
/// Return the label's font.
|
||||||
inline Fl_Font labelfont() const {
|
inline Fl_Font item_labelfont() const { return(_labelfont); }
|
||||||
return(_labelfont);
|
|
||||||
}
|
|
||||||
/// Set the label's font to \p val.
|
/// Set the label's font to \p val.
|
||||||
inline void labelfont(Fl_Font val) {
|
inline void item_labelfont(Fl_Font val) { _labelfont = val; }
|
||||||
_labelfont = val;
|
|
||||||
}
|
|
||||||
/// Return the label's size in pixels.
|
/// Return the label's size in pixels.
|
||||||
inline Fl_Fontsize labelsize() const {
|
inline Fl_Fontsize item_labelsize() const { return(_labelsize); }
|
||||||
return(_labelsize);
|
|
||||||
}
|
|
||||||
/// Set the label's size in pixels to \p val.
|
/// Set the label's size in pixels to \p val.
|
||||||
inline void labelsize(Fl_Fontsize val) {
|
inline void item_labelsize(Fl_Fontsize val) { _labelsize = 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
|
// Margins
|
||||||
@@ -187,7 +227,7 @@ public:
|
|||||||
inline void marginbottom(int val) {
|
inline void marginbottom(int val) {
|
||||||
_marginbottom = val;
|
_marginbottom = val;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
/// Get the margin below an open child in pixels
|
/// Get the margin below an open child in pixels
|
||||||
inline int openchild_marginbottom() const {
|
inline int openchild_marginbottom() const {
|
||||||
return(_openchild_marginbottom);
|
return(_openchild_marginbottom);
|
||||||
@@ -221,7 +261,7 @@ public:
|
|||||||
inline void widgetmarginleft(int val) {
|
inline void widgetmarginleft(int val) {
|
||||||
_widgetmarginleft = val;
|
_widgetmarginleft = val;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
/// Get the line spacing value in pixels
|
/// Get the line spacing value in pixels
|
||||||
inline int linespacing() const {
|
inline int linespacing() const {
|
||||||
return(_linespacing);
|
return(_linespacing);
|
||||||
@@ -234,22 +274,6 @@ public:
|
|||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Colors and Styles
|
// 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.
|
/// Get the connector color used for tree connection lines.
|
||||||
inline Fl_Color connectorcolor() const {
|
inline Fl_Color connectorcolor() const {
|
||||||
return(_connectorcolor);
|
return(_connectorcolor);
|
||||||
@@ -388,7 +412,7 @@ public:
|
|||||||
inline void item_draw_mode(Fl_Tree_Item_Draw_Mode val) {
|
inline void item_draw_mode(Fl_Tree_Item_Draw_Mode val) {
|
||||||
_itemdrawmode = val;
|
_itemdrawmode = val;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*FL_TREE_PREFS_H*/
|
#endif /*FL_TREE_PREFS_H*/
|
||||||
|
|||||||
+12
-10
@@ -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
|
#if FLTK_ABI_VERSION >= 10302
|
||||||
// NEW
|
// NEW
|
||||||
_lastselect = 0;
|
_lastselect = 0;
|
||||||
#else
|
#else /*FLTK_ABI_VERSION*/
|
||||||
// OLD: data initialized static inside handle()
|
// OLD: data initialized static inside handle()
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
|
|
||||||
box(FL_DOWN_BOX);
|
box(FL_DOWN_BOX);
|
||||||
color(FL_BACKGROUND2_COLOR, FL_SELECTION_COLOR);
|
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
|
char is_command = Fl::event_state() & FL_COMMAND ? 1 : 0; // ctrl on win/lin, 'Command' on mac
|
||||||
#if FLTK_ABI_VERSION >= 10302
|
#if FLTK_ABI_VERSION >= 10302
|
||||||
// NEW: data inside Fl_Tree
|
// NEW: data inside Fl_Tree
|
||||||
#else
|
#else /*FLTK_ABI_VERSION*/
|
||||||
// OLD:
|
// OLD:
|
||||||
static Fl_Tree_Item *_lastselect = 0;
|
static Fl_Tree_Item *_lastselect = 0;
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
// Developer note: Fl_Browser_::handle() used for reference here..
|
// Developer note: Fl_Browser_::handle() used for reference here..
|
||||||
// #include <FL/names.h> // for event debugging
|
// #include <FL/names.h> // for event debugging
|
||||||
// fprintf(stderr, "DEBUG: %s (%d)\n", fl_eventnames[e], e);
|
// fprintf(stderr, "DEBUG: %s (%d)\n", fl_eventnames[e], e);
|
||||||
@@ -477,10 +477,10 @@ int Fl_Tree::draw_tree() {
|
|||||||
#if FLTK_ABI_VERSION >= 10302
|
#if FLTK_ABI_VERSION >= 10302
|
||||||
// NEW
|
// NEW
|
||||||
int SY = Y + _prefs.marginbottom();
|
int SY = Y + _prefs.marginbottom();
|
||||||
#else
|
#else /*FLTK_ABI_VERSION*/
|
||||||
// OLD
|
// OLD
|
||||||
int SY = Y;
|
int SY = Y;
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
int ydiff = (SY+_prefs.margintop())-Ysave; // ydiff=size of tree
|
int ydiff = (SY+_prefs.margintop())-Ysave; // ydiff=size of tree
|
||||||
int ytoofar = (cy+ch) - SY; // ytoofar -- if >0, scrolled beyond bottom
|
int ytoofar = (cy+ch) - SY; // ytoofar -- if >0, scrolled beyond bottom
|
||||||
if ( ytoofar > 0 ) ydiff += ytoofar;
|
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);
|
do_callback_for_item(item, FL_TREE_REASON_RESELECTED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
return(0);
|
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.
|
/// 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 {
|
Fl_Color Fl_Tree::item_labelbgcolor(void) const {
|
||||||
return(_prefs.labelbgcolor());
|
return(_prefs.labelbgcolor());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the default label background color used for creating new items.
|
/// 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)
|
/// 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) {
|
void Fl_Tree::item_labelbgcolor(Fl_Color val) {
|
||||||
@@ -1478,7 +1480,7 @@ void Fl_Tree::marginbottom(int val) {
|
|||||||
_prefs.marginbottom(val);
|
_prefs.marginbottom(val);
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
|
|
||||||
/// Get the amount of white space (in pixels) that should appear
|
/// Get the amount of white space (in pixels) that should appear
|
||||||
/// between items in the tree.
|
/// between items in the tree.
|
||||||
@@ -1543,7 +1545,7 @@ void Fl_Tree::widgetmarginleft(int val) {
|
|||||||
_prefs.widgetmarginleft(val);
|
_prefs.widgetmarginleft(val);
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
|
|
||||||
/// Gets the width of the horizontal connection lines (in pixels)
|
/// Gets the width of the horizontal connection lines (in pixels)
|
||||||
/// that appear to the left of each tree item's label.
|
/// 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) {
|
void Fl_Tree::item_draw_mode(int val) {
|
||||||
_prefs.item_draw_mode(Fl_Tree_Item_Draw_Mode(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).
|
/// 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.
|
/// This can be used to detect if the item is scrolled off-screen.
|
||||||
|
|||||||
+30
-21
@@ -44,10 +44,14 @@ Fl_Tree_Item::Fl_Tree_Item(const Fl_Tree_Prefs &prefs) {
|
|||||||
_labelfgcolor = prefs.labelfgcolor();
|
_labelfgcolor = prefs.labelfgcolor();
|
||||||
_labelbgcolor = prefs.labelbgcolor();
|
_labelbgcolor = prefs.labelbgcolor();
|
||||||
_widget = 0;
|
_widget = 0;
|
||||||
|
#if FLTK_ABI_VERSION >= 10302
|
||||||
|
_flags = OPEN|VISIBLE|ACTIVE;
|
||||||
|
#else /*FLTK_ABI_VERSION*/
|
||||||
_open = 1;
|
_open = 1;
|
||||||
_visible = 1;
|
_visible = 1;
|
||||||
_active = 1;
|
_active = 1;
|
||||||
_selected = 0;
|
_selected = 0;
|
||||||
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
_xywh[0] = 0;
|
_xywh[0] = 0;
|
||||||
_xywh[1] = 0;
|
_xywh[1] = 0;
|
||||||
_xywh[2] = 0;
|
_xywh[2] = 0;
|
||||||
@@ -88,10 +92,14 @@ Fl_Tree_Item::Fl_Tree_Item(const Fl_Tree_Item *o) {
|
|||||||
_labelfgcolor = o->labelfgcolor();
|
_labelfgcolor = o->labelfgcolor();
|
||||||
_labelbgcolor = o->labelbgcolor();
|
_labelbgcolor = o->labelbgcolor();
|
||||||
_widget = o->widget();
|
_widget = o->widget();
|
||||||
|
#if FLTK_ABI_VERSION >= 10302
|
||||||
|
_flags = o->_flags;
|
||||||
|
#else /*FLTK_ABI_VERSION*/
|
||||||
_open = o->_open;
|
_open = o->_open;
|
||||||
_visible = o->_visible;
|
_visible = o->_visible;
|
||||||
_active = o->_active;
|
_active = o->_active;
|
||||||
_selected = o->_selected;
|
_selected = o->_selected;
|
||||||
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
_xywh[0] = o->_xywh[0];
|
_xywh[0] = o->_xywh[0];
|
||||||
_xywh[1] = o->_xywh[1];
|
_xywh[1] = o->_xywh[1];
|
||||||
_xywh[2] = o->_xywh[2];
|
_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.
|
/// \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 {
|
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() ) {
|
if ( is_root() && !prefs.showroot() ) {
|
||||||
// skip event check if we're root but root not being shown
|
// skip event check if we're root but root not being shown
|
||||||
} else {
|
} 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.
|
/// \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) {
|
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() ) {
|
if ( is_root() && !prefs.showroot() ) {
|
||||||
// skip event check if we're root but root not being shown
|
// skip event check if we're root but root not being shown
|
||||||
} else {
|
} 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().
|
/// Doesn't include linespacing(); prevents affecting eg. height of widget().
|
||||||
///
|
///
|
||||||
int Fl_Tree_Item::calc_item_height(const Fl_Tree_Prefs &prefs) const {
|
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;
|
int H = 0;
|
||||||
if ( _label ) {
|
if ( _label ) {
|
||||||
fl_font(_labelfont, _labelsize); // fl_descent() needs this :/
|
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()) {
|
||||||
H = widget()->h();
|
H = widget()->h();
|
||||||
}
|
}
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
if ( has_children() && prefs.openicon() && H<prefs.openicon()->h() )
|
if ( has_children() && prefs.openicon() && H<prefs.openicon()->h() )
|
||||||
H = prefs.openicon()->h();
|
H = prefs.openicon()->h();
|
||||||
if ( usericon() && H<usericon()->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,
|
void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree,
|
||||||
Fl_Tree_Item *itemfocus,
|
Fl_Tree_Item *itemfocus,
|
||||||
const Fl_Tree_Prefs &prefs, int lastchild) {
|
const Fl_Tree_Prefs &prefs, int lastchild) {
|
||||||
if ( ! _visible ) return;
|
if ( ! is_visible() ) return;
|
||||||
int tree_top = tree->y();
|
int tree_top = tree->y();
|
||||||
int tree_bot = tree_top + tree->h();
|
int tree_bot = tree_top + tree->h();
|
||||||
int H = calc_item_height(prefs); // height of item
|
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;
|
? widget()->h() : H;
|
||||||
if ( _label &&
|
if ( _label &&
|
||||||
(prefs.item_draw_mode() & FL_TREE_ITEM_DRAW_LABEL_AND_WIDGET) ) {
|
(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
|
int wh = H; // lock widget's height to item height
|
||||||
if ( _label && !widget() ) { // back compat: don't draw label if widget() present
|
if ( _label && !widget() ) { // back compat: don't draw label if widget() present
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
fl_font(_labelfont, _labelsize); // fldescent() needs this
|
fl_font(_labelfont, _labelsize); // fldescent() needs this
|
||||||
int lw=0, lh=0;
|
int lw=0, lh=0;
|
||||||
fl_measure(_label,lw,lh); // get box around text (including white space)
|
fl_measure(_label,lw,lh); // get box around text (including white space)
|
||||||
#if FLTK_ABI_VERSION >= 10302
|
#if FLTK_ABI_VERSION >= 10302
|
||||||
// NEW
|
// NEW
|
||||||
wx += (lw + prefs.widgetmarginleft());
|
wx += (lw + prefs.widgetmarginleft());
|
||||||
#else
|
#else /*FLTK_ABI_VERSION*/
|
||||||
// OLD
|
// OLD
|
||||||
wx += (lw + 3);
|
wx += (lw + 3);
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
}
|
}
|
||||||
if ( widget()->x() != wx || widget()->y() != wy ||
|
if ( widget()->x() != wx || widget()->y() != wy ||
|
||||||
widget()->w() != ww || widget()->h() != wh ) {
|
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 clipped = ((Y+H) < tree_top) || (Y>tree_bot) ? 1 : 0;
|
||||||
char drawthis = ( is_root() && prefs.showroot() == 0 ) ? 0 : 1;
|
char drawthis = ( is_root() && prefs.showroot() == 0 ) ? 0 : 1;
|
||||||
if ( !clipped ) {
|
if ( !clipped ) {
|
||||||
Fl_Color fg = _selected ? fl_contrast(_labelfgcolor, tree->selection_color())
|
Fl_Color fg = is_selected() ? fl_contrast(_labelfgcolor, tree->selection_color())
|
||||||
: _active ? _labelfgcolor
|
: is_active() ? _labelfgcolor
|
||||||
: fl_inactive(_labelfgcolor);
|
: fl_inactive(_labelfgcolor);
|
||||||
Fl_Color bg = _selected ? _active ? tree->selection_color()
|
Fl_Color bg = is_selected() ? is_active() ? tree->selection_color()
|
||||||
: fl_inactive(tree->selection_color())
|
: fl_inactive(tree->selection_color())
|
||||||
: _labelbgcolor;
|
: _labelbgcolor == 0xffffffff ? tree->color() // transparent bg?
|
||||||
|
: _labelbgcolor;
|
||||||
// See if we should draw this item
|
// See if we should draw this item
|
||||||
// If this item is root, and showroot() is disabled, don't draw.
|
// If this item is root, and showroot() is disabled, don't draw.
|
||||||
// 'clipped' is an optimization to prevent drawing anything offscreen.
|
// '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 &&
|
if ( _label &&
|
||||||
( !widget() ||
|
( !widget() ||
|
||||||
(prefs.item_draw_mode() & FL_TREE_ITEM_DRAW_LABEL_AND_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
|
if ( _label && !widget() ) // back compat: don't draw label if widget() present
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
{
|
{
|
||||||
fl_color(fg);
|
fl_color(fg);
|
||||||
fl_font(_labelfont, _labelsize);
|
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?
|
/// Was the event on the 'collapse' button?
|
||||||
///
|
///
|
||||||
int Fl_Tree_Item::event_on_collapse_icon(const Fl_Tree_Prefs &prefs) const {
|
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);
|
return(event_inside(_collapse_xywh) ? 1 : 0);
|
||||||
} else {
|
} else {
|
||||||
return(0);
|
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()?
|
/// Was event on the label()?
|
||||||
///
|
///
|
||||||
int Fl_Tree_Item::event_on_label(const Fl_Tree_Prefs &prefs) const {
|
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);
|
return(event_inside(_label_xywh) ? 1 : 0);
|
||||||
} else {
|
} else {
|
||||||
return(0);
|
return(0);
|
||||||
@@ -822,7 +831,7 @@ void Fl_Tree_Item::hide_widgets() {
|
|||||||
|
|
||||||
/// Open this item and all its children.
|
/// Open this item and all its children.
|
||||||
void Fl_Tree_Item::open() {
|
void Fl_Tree_Item::open() {
|
||||||
_open = 1;
|
set_flag(OPEN,1);
|
||||||
// Tell children to show() their widgets
|
// Tell children to show() their widgets
|
||||||
for ( int t=0; t<_children.total(); t++ ) {
|
for ( int t=0; t<_children.total(); t++ ) {
|
||||||
_children[t]->show_widgets();
|
_children[t]->show_widgets();
|
||||||
@@ -831,7 +840,7 @@ void Fl_Tree_Item::open() {
|
|||||||
|
|
||||||
/// Close this item and all its children.
|
/// Close this item and all its children.
|
||||||
void Fl_Tree_Item::close() {
|
void Fl_Tree_Item::close() {
|
||||||
_open = 0;
|
set_flag(OPEN,0);
|
||||||
// Tell children to hide() their widgets
|
// Tell children to hide() their widgets
|
||||||
for ( int t=0; t<_children.total(); t++ ) {
|
for ( int t=0; t<_children.total(); t++ ) {
|
||||||
_children[t]->hide_widgets();
|
_children[t]->hide_widgets();
|
||||||
|
|||||||
+10
-10
@@ -5,7 +5,7 @@
|
|||||||
#include <FL/Fl.H>
|
#include <FL/Fl.H>
|
||||||
#include <FL/Fl_Pixmap.H>
|
#include <FL/Fl_Pixmap.H>
|
||||||
#include <FL/Fl_Tree_Prefs.H>
|
#include <FL/Fl_Tree_Prefs.H>
|
||||||
#include <string.h>
|
#include <string.h> // strcmp
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
// Fl_Tree_Prefs.cxx
|
// Fl_Tree_Prefs.cxx
|
||||||
@@ -44,7 +44,7 @@ static const char *L_open_xpm[] = {
|
|||||||
"...@@@.....",
|
"...@@@.....",
|
||||||
"...@@......",
|
"...@@......",
|
||||||
"...@......."
|
"...@......."
|
||||||
#else
|
#else /* __APPLE__ */
|
||||||
"11 11 3 1",
|
"11 11 3 1",
|
||||||
". c #fefefe",
|
". c #fefefe",
|
||||||
"# c #444444",
|
"# c #444444",
|
||||||
@@ -60,7 +60,7 @@ static const char *L_open_xpm[] = {
|
|||||||
"#.........#",
|
"#.........#",
|
||||||
"#.........#",
|
"#.........#",
|
||||||
"###########"
|
"###########"
|
||||||
#endif
|
#endif /* __APPLE__ */
|
||||||
};
|
};
|
||||||
static Fl_Pixmap L_openpixmap(L_open_xpm);
|
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",
|
"11 11 3 1",
|
||||||
". c #fefefe",
|
". c #fefefe",
|
||||||
"# c #444444",
|
"# c #444444",
|
||||||
@@ -96,7 +96,7 @@ static const char *L_close_xpm[] = {
|
|||||||
"#.........#",
|
"#.........#",
|
||||||
"#.........#",
|
"#.........#",
|
||||||
"###########"
|
"###########"
|
||||||
#endif
|
#endif /* __APPLE__ */
|
||||||
};
|
};
|
||||||
static Fl_Pixmap L_closepixmap(L_close_xpm);
|
static Fl_Pixmap L_closepixmap(L_close_xpm);
|
||||||
|
|
||||||
@@ -127,22 +127,22 @@ Fl_Tree_Prefs::Fl_Tree_Prefs() {
|
|||||||
_margintop = 3;
|
_margintop = 3;
|
||||||
#if FLTK_ABI_VERSION >= 10302
|
#if FLTK_ABI_VERSION >= 10302
|
||||||
_marginbottom = 20;
|
_marginbottom = 20;
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
_openchild_marginbottom = 0;
|
_openchild_marginbottom = 0;
|
||||||
_usericonmarginleft = 3;
|
_usericonmarginleft = 3;
|
||||||
_labelmarginleft = 3;
|
_labelmarginleft = 3;
|
||||||
#if FLTK_ABI_VERSION >= 10302
|
#if FLTK_ABI_VERSION >= 10302
|
||||||
_widgetmarginleft = 3;
|
_widgetmarginleft = 3;
|
||||||
#endif
|
#endif /*FLTK_ABI_VERSION*/
|
||||||
_linespacing = 0;
|
_linespacing = 0;
|
||||||
_labelfgcolor = FL_BLACK;
|
_labelfgcolor = FL_BLACK;
|
||||||
_labelbgcolor = FL_WHITE;
|
_labelbgcolor = 0xffffffff; // we use this as 'transparent'
|
||||||
_connectorcolor = Fl_Color(43);
|
_connectorcolor = Fl_Color(43);
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
_connectorstyle = FL_TREE_CONNECTOR_NONE;
|
_connectorstyle = FL_TREE_CONNECTOR_NONE;
|
||||||
#else
|
#else /* __APPLE__ */
|
||||||
_connectorstyle = FL_TREE_CONNECTOR_DOTTED;
|
_connectorstyle = FL_TREE_CONNECTOR_DOTTED;
|
||||||
#endif
|
#endif /* __APPLE__ */
|
||||||
_openimage = &L_openpixmap;
|
_openimage = &L_openpixmap;
|
||||||
_closeimage = &L_closepixmap;
|
_closeimage = &L_closepixmap;
|
||||||
_userimage = 0;
|
_userimage = 0;
|
||||||
|
|||||||
+432
-176
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user