summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2011-01-30 20:22:06 +0000
committerGreg Ercolano <erco@seriss.com>2011-01-30 20:22:06 +0000
commit2c5006563f893723f0f224d7b3115e5fd03272ca (patch)
treeb23c1eb923d31727f60470607e08ecfef4e476cc /src
parent31db787583e1b862d1e26acc542a294a9c31fd0e (diff)
Fl_Tree API breaking changes (we haven't released 1.3.0 yet..):
Fl_Tree::labelsize() -> item_labelsize() -- TO AVOID COLLISION WITH Fl_Widget::labelsize()! Fl_Tree::labelfont() -> item_labelfont() -- TO AVOID COLLISION WITH Fl_Widget::labelfont()! Fl_Tree_Prefs (internal) changes: Fl_Tree_Prefs::fgcolor() -> labelfgcolor() -- for consistency with above Fl_Tree_Prefs::bgcolor() -> labelbgcolor() -- for consistency with above Fl_Tree_Prefs::selectcolor() removed -- uses Fl_Widget::selection_color() instead Fl_Tree_Prefs::inactivecolor() removed -- was unused; inactive color procedurally calculated Other Fl_Tree mods: o Fixed bug with select_all(item) and deselect_all(item) (they were not limiting themselves to children of specified item) o Fixed bug with item not drawing in its /own/ bgcolor when item selected o Fl_Tree uses the Fl_Widget::selection_color() o All methods that deal with 'font types' changed int -> Fl_Font o All methods that deal with 'font sizes' changed int -> Fl_Fontsize o Added needed methods to Fl_Tree for accessing colors: item_labelfgcolor() -- access default fg color used for new items item_labelbgcolor() -- access default bg color used for new items tree_connectorcolor() -- access the connector line color o Small doxygen comment adjustments and general clarifications o test/tree demo modified to include testing of new label color methods, cleanup git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8340 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Tree.cxx22
-rw-r--r--src/Fl_Tree_Item.cxx8
-rw-r--r--src/Fl_Tree_Prefs.cxx6
3 files changed, 20 insertions, 16 deletions
diff --git a/src/Fl_Tree.cxx b/src/Fl_Tree.cxx
index 5d29b7cfe..fe3a8e267 100644
--- a/src/Fl_Tree.cxx
+++ b/src/Fl_Tree.cxx
@@ -697,10 +697,13 @@ int Fl_Tree::deselect_all(Fl_Tree_Item *item, int docallback) {
item = item ? item : first(); // NULL? use first()
if ( ! item ) return(0);
int count = 0;
- for ( ; item; item = next(item) ) {
- if ( item->is_selected() )
- if ( deselect(item, docallback) )
- ++count;
+ // Deselect item
+ if ( item->is_selected() )
+ if ( deselect(item, docallback) )
+ ++count;
+ // Deselect its children
+ for ( int t=0; t<item->children(); t++ ) {
+ count += deselect_all(item->child(t), docallback); // recurse
}
return(count);
}
@@ -726,10 +729,13 @@ int Fl_Tree::select_all(Fl_Tree_Item *item, int docallback) {
item = item ? item : first(); // NULL? use first()
if ( ! item ) return(0);
int count = 0;
- for ( ; item; item = next(item) ) {
- if ( !item->is_selected() )
- if ( select(item, docallback) )
- ++count;
+ // Select item
+ if ( !item->is_selected() )
+ if ( select(item, docallback) )
+ ++count;
+ // Select its children
+ for ( int t=0; t<item->children(); t++ ) {
+ count += select_all(item->child(t), docallback); // recurse
}
return(count);
}
diff --git a/src/Fl_Tree_Item.cxx b/src/Fl_Tree_Item.cxx
index 15a45833a..329c0ef33 100644
--- a/src/Fl_Tree_Item.cxx
+++ b/src/Fl_Tree_Item.cxx
@@ -44,8 +44,8 @@ Fl_Tree_Item::Fl_Tree_Item(const Fl_Tree_Prefs &prefs) {
_label = 0;
_labelfont = prefs.labelfont();
_labelsize = prefs.labelsize();
- _labelfgcolor = prefs.fgcolor();
- _labelbgcolor = prefs.bgcolor();
+ _labelfgcolor = prefs.labelfgcolor();
+ _labelbgcolor = prefs.labelbgcolor();
_widget = 0;
_open = 1;
_visible = 1;
@@ -562,8 +562,8 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree,
W += prefs.openicon()->w();
}
// Colors, fonts
- Fl_Color fg = _selected ? prefs.bgcolor() : _labelfgcolor;
- Fl_Color bg = _selected ? prefs.selectcolor() : _labelbgcolor;
+ Fl_Color fg = _selected ? _labelbgcolor : _labelfgcolor; // selected uses bgcolor, unselected uses fgcolor
+ Fl_Color bg = _selected ? tree->selection_color() : _labelbgcolor; // selected uses selectcolor, unselected uses bgcolor
if ( ! _active ) {
fg = fl_inactive(fg);
if ( _selected ) bg = fl_inactive(bg);
diff --git a/src/Fl_Tree_Prefs.cxx b/src/Fl_Tree_Prefs.cxx
index 7884c2afc..df5f856ac 100644
--- a/src/Fl_Tree_Prefs.cxx
+++ b/src/Fl_Tree_Prefs.cxx
@@ -136,10 +136,8 @@ Fl_Tree_Prefs::Fl_Tree_Prefs() {
_usericonmarginleft = 3;
_labelmarginleft = 3;
_linespacing = 0;
- _fgcolor = FL_BLACK;
- _bgcolor = FL_WHITE;
- _selectcolor = FL_DARK_BLUE;
- _inactivecolor = FL_GRAY;
+ _labelfgcolor = FL_BLACK;
+ _labelbgcolor = FL_WHITE;
_connectorcolor = Fl_Color(43);
#ifdef __APPLE__
_connectorstyle = FL_TREE_CONNECTOR_NONE;