summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2009-12-08 08:06:44 +0000
committerGreg Ercolano <erco@seriss.com>2009-12-08 08:06:44 +0000
commita657069cc53cc05245762e9323efa040a9f70da2 (patch)
treec007a095998f8a4d20ed4359eb7174803c4f8784 /src
parent5bc48808b6aed5469c3e62e1402e10c797a5d02a (diff)
Checked in SebHoll's API mods, fixed indents.
o Added user_data() to Fl_Tree_Item o Added insert() and add() methods that allow specification of Fl_Tree_Prefs o Changed Fl_Pixmap args to Fl_Image for more flexibility o Fixes for positioning of items in the presence of user icons o find_children() changed from protected -> public git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6956 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Tree.cxx70
-rw-r--r--src/Fl_Tree_Item.cxx203
-rw-r--r--src/Fl_Tree_Item_Array.cxx14
-rw-r--r--src/Fl_Tree_Prefs.cxx22
4 files changed, 164 insertions, 145 deletions
diff --git a/src/Fl_Tree.cxx b/src/Fl_Tree.cxx
index 843439e11..e946ccaf5 100644
--- a/src/Fl_Tree.cxx
+++ b/src/Fl_Tree.cxx
@@ -123,6 +123,18 @@ Fl_Tree_Item* Fl_Tree::insert_above(Fl_Tree_Item *above, const char *name) {
return(above->insert_above(_prefs, name));
}
+/// Insert a new item into a tree-item's children at a specified position.
+/// \returns the item that was added.
+Fl_Tree_Item* Fl_Tree::insert(Fl_Tree_Item *item, const char *name, int pos) {
+ return(item->insert(_prefs, name, pos));
+}
+
+/// Add a new child to a tree-item.
+/// \returns the item that was added.
+Fl_Tree_Item* Fl_Tree::add(Fl_Tree_Item *item, const char *name) {
+ return(item->add(_prefs, name));
+}
+
/// Find the item, given a menu style path, eg: "/Parent/Child/item".
///
/// There is both a const and non-const version of this method.
@@ -209,11 +221,11 @@ int Fl_Tree::handle(int e) {
if ( ! _root ) return(ret);
switch ( e ) {
case FL_PUSH: {
- lastselect = 0;
- item_clicked(0); // assume no item was clicked
- Fl_Tree_Item *o = _root->find_clicked(_prefs);
- if ( o ) {
- ret |= 1; // handled
+ lastselect = 0;
+ item_clicked(0); // assume no item was clicked
+ Fl_Tree_Item *o = _root->find_clicked(_prefs);
+ if ( o ) {
+ ret |= 1; // handled
if ( Fl::event_button() == FL_LEFT_MOUSE ) {
// Was collapse icon clicked?
if ( o->event_on_collapse_icon(_prefs) ) {
@@ -226,9 +238,10 @@ int Fl_Tree::handle(int e) {
callback() &&
(!_vscroll->visible() || !Fl::event_inside(_vscroll)) ) {
item_clicked(o); // save item clicked
+
// Handle selection behavior
switch ( _prefs.selectmode() ) {
- case FL_TREE_SELECT_NONE: { // no selection changes
+ case FL_TREE_SELECT_NONE: { // no selection changes
break;
}
case FL_TREE_SELECT_SINGLE: {
@@ -243,7 +256,7 @@ int Fl_Tree::handle(int e) {
changed = 1; // changed
}
} else if ( state & FL_CTRL ) {
- changed = 1; // changed
+ changed = 1; // changed
o->select_toggle(); // toggle selection state
lastselect = o; // save we toggled it (prevents oscillation)
} else {
@@ -252,8 +265,9 @@ int Fl_Tree::handle(int e) {
break;
}
}
+
if ( changed ) {
- redraw(); // make change(s) visible
+ redraw(); // make change(s) visible
if ( when() & FL_WHEN_CHANGED ) {
set_changed();
do_callback((Fl_Widget*)this, user_data()); // item callback
@@ -261,22 +275,22 @@ int Fl_Tree::handle(int e) {
}
}
}
- }
- break;
+ }
+ break;
}
case FL_DRAG: {
- Fl_Tree_Item *o = _root->find_clicked(_prefs);
- if ( o ) {
+ Fl_Tree_Item *o = _root->find_clicked(_prefs);
+ if ( o ) {
ret |= 1; // handled
// Item's label clicked?
if ( o->event_on_label(_prefs) &&
- (!o->widget() || !Fl::event_inside(o->widget())) &&
- callback() &&
- (!_vscroll->visible() || !Fl::event_inside(_vscroll)) ) {
+ (!o->widget() || !Fl::event_inside(o->widget())) &&
+ callback() &&
+ (!_vscroll->visible() || !Fl::event_inside(_vscroll)) ) {
item_clicked(o); // save item clicked
// Handle selection behavior
switch ( _prefs.selectmode() ) {
- case FL_TREE_SELECT_NONE: { // no selection changes
+ case FL_TREE_SELECT_NONE: { // no selection changes
break;
}
case FL_TREE_SELECT_SINGLE: {
@@ -301,20 +315,20 @@ int Fl_Tree::handle(int e) {
}
}
if ( changed ) {
- redraw(); // make change(s) visible
+ redraw(); // make change(s) visible
if ( when() & FL_WHEN_CHANGED ) {
set_changed();
do_callback((Fl_Widget*)this, user_data()); // item callback
}
}
}
- }
+ }
}
case FL_RELEASE: {
- if ( Fl::event_button() == FL_LEFT_MOUSE ) {
+ if ( Fl::event_button() == FL_LEFT_MOUSE ) {
ret |= 1;
- }
- break;
+ }
+ break;
}
}
return(ret);
@@ -327,7 +341,7 @@ int Fl_Tree::handle(int e) {
/// ie. how many items were "changed".
///
int Fl_Tree::deselect_all(Fl_Tree_Item *item) {
- item = item ? item : root(); // NULL? use root()
+ item = item ? item : root(); // NULL? use root()
int count = item->deselect_all();
if ( count ) redraw(); // anything changed? cause redraw
return(count);
@@ -343,17 +357,17 @@ int Fl_Tree::select_only(Fl_Tree_Item *selitem) {
int changed = 0;
for ( Fl_Tree_Item *item = first(); item; item = item->next() ) {
if ( item == selitem ) {
- if ( item->is_selected() ) continue; // don't count if already selected
- item->select();
- ++changed;
+ if ( item->is_selected() ) continue; // don't count if already selected
+ item->select();
+ ++changed;
} else {
- if ( item->is_selected() ) {
+ if ( item->is_selected() ) {
item->deselect();
++changed;
- }
+ }
}
}
- if ( changed ) redraw(); // anything changed? redraw
+ if ( changed ) redraw(); // anything changed? redraw
return(changed);
}
diff --git a/src/Fl_Tree_Item.cxx b/src/Fl_Tree_Item.cxx
index 9d93f6d9e..cf92b7078 100644
--- a/src/Fl_Tree_Item.cxx
+++ b/src/Fl_Tree_Item.cxx
@@ -74,7 +74,7 @@ Fl_Tree_Item::~Fl_Tree_Item() {
_label = 0;
}
_widget = 0; // Fl_Group will handle destruction
- _usericon = 0; // user handled allocation
+ _usericon = 0; // user handled allocation
//_children.clear(); // array's destructor handles itself
}
@@ -103,6 +103,7 @@ Fl_Tree_Item::Fl_Tree_Item(const Fl_Tree_Item *o) {
_label_xywh[2] = o->_label_xywh[2];
_label_xywh[3] = o->_label_xywh[3];
_usericon = o->usericon();
+ _userdata = 0;
_parent = o->_parent;
}
@@ -119,7 +120,7 @@ void Fl_Tree_Item::show_self(const char *indent) const {
strcpy(i2, indent);
strcat(i2, " |");
for ( int t=0; t<children(); t++ ) {
- child(t)->show_self(i2);
+ child(t)->show_self(i2);
}
}
fflush(stdout);
@@ -153,11 +154,11 @@ void Fl_Tree_Item::clear_children() {
int Fl_Tree_Item::find_child(const char *name) {
if ( name ) {
for ( int t=0; t<children(); t++ ) {
- if ( child(t)->label() ) {
+ if ( child(t)->label() ) {
if ( strcmp(child(t)->label(), name) == 0 ) {
return(t);
}
- }
+ }
}
}
return(-1);
@@ -171,13 +172,13 @@ int Fl_Tree_Item::find_child(const char *name) {
const Fl_Tree_Item *Fl_Tree_Item::find_item(char **arr) const {
for ( int t=0; t<children(); t++ ) {
if ( child(t)->label() ) {
- if ( strcmp(child(t)->label(), *arr) == 0 ) { // match?
+ if ( strcmp(child(t)->label(), *arr) == 0 ) { // match?
if ( *(arr+1) ) { // more in arr? descend
return(_children[t]->find_item(arr+1));
} else { // end of arr? done
return(_children[t]);
}
- }
+ }
}
}
return(0);
@@ -191,13 +192,13 @@ const Fl_Tree_Item *Fl_Tree_Item::find_item(char **arr) const {
Fl_Tree_Item *Fl_Tree_Item::find_item(char **arr) {
for ( int t=0; t<children(); t++ ) {
if ( child(t)->label() ) {
- if ( strcmp(child(t)->label(), *arr) == 0 ) { // match?
+ if ( strcmp(child(t)->label(), *arr) == 0 ) { // match?
if ( *(arr+1) ) { // more in arr? descend
return(_children[t]->find_item(arr+1));
} else { // end of arr? done
return(_children[t]);
}
- }
+ }
}
}
return(0);
@@ -211,7 +212,7 @@ Fl_Tree_Item *Fl_Tree_Item::find_item(char **arr) {
int Fl_Tree_Item::find_child(Fl_Tree_Item *item) {
for ( int t=0; t<children(); t++ ) {
if ( item == child(t) ) {
- return(t);
+ return(t);
}
}
return(-1);
@@ -227,30 +228,30 @@ Fl_Tree_Item *Fl_Tree_Item::add(const Fl_Tree_Prefs &prefs, const char *new_labe
item->_parent = this;
switch ( prefs.sortorder() ) {
case FL_TREE_SORT_NONE: {
- _children.add(item);
- return(item);
+ _children.add(item);
+ return(item);
}
case FL_TREE_SORT_ASCENDING: {
- for ( int t=0; t<_children.total(); t++ ) {
+ for ( int t=0; t<_children.total(); t++ ) {
Fl_Tree_Item *c = _children[t];
if ( c->label() && strcmp(c->label(), new_label) > 0 ) {
_children.insert(t, item);
return(item);
}
- }
- _children.add(item);
- return(item);
+ }
+ _children.add(item);
+ return(item);
}
case FL_TREE_SORT_DESCENDING: {
- for ( int t=0; t<_children.total(); t++ ) {
+ for ( int t=0; t<_children.total(); t++ ) {
Fl_Tree_Item *c = _children[t];
if ( c->label() && strcmp(c->label(), new_label) < 0 ) {
_children.insert(t, item);
return(item);
}
- }
- _children.add(item);
- return(item);
+ }
+ _children.add(item);
+ return(item);
}
}
return(item);
@@ -292,7 +293,7 @@ Fl_Tree_Item *Fl_Tree_Item::insert_above(const Fl_Tree_Prefs &prefs, const char
for ( int t=0; t<p->children(); t++ ) {
Fl_Tree_Item *c = p->child(t);
if ( this == c ) {
- return(p->insert(prefs, new_label, t));
+ return(p->insert(prefs, new_label, t));
}
}
return(0);
@@ -304,9 +305,9 @@ Fl_Tree_Item *Fl_Tree_Item::insert_above(const Fl_Tree_Prefs &prefs, const char
int Fl_Tree_Item::remove_child(Fl_Tree_Item *item) {
for ( int t=0; t<children(); t++ ) {
if ( child(t) == item ) {
- item->clear_children();
- _children.remove(t);
- return(0);
+ item->clear_children();
+ _children.remove(t);
+ return(0);
}
}
return(-1);
@@ -318,10 +319,10 @@ int Fl_Tree_Item::remove_child(Fl_Tree_Item *item) {
int Fl_Tree_Item::remove_child(const char *name) {
for ( int t=0; t<children(); t++ ) {
if ( child(t)->label() ) {
- if ( strcmp(child(t)->label(), name) == 0 ) {
+ if ( strcmp(child(t)->label(), name) == 0 ) {
_children.remove(t);
return(0);
- }
+ }
}
}
return(-1);
@@ -368,17 +369,17 @@ void Fl_Tree_Item::draw_horizontal_connector(int x1, int x2, int y, const Fl_Tre
fl_color(prefs.connectorcolor());
switch ( prefs.connectorstyle() ) {
case FL_TREE_CONNECTOR_SOLID:
- y |= 1; // force alignment w/dot pattern
- fl_line(x1,y,x2,y);
- return;
+ y |= 1; // force alignment w/dot pattern
+ fl_line(x1,y,x2,y);
+ return;
case FL_TREE_CONNECTOR_DOTTED:
- y |= 1; // force alignment w/dot pattern
- for ( int xx=x1; xx<=x2; xx++ ) {
+ y |= 1; // force alignment w/dot pattern
+ for ( int xx=x1; xx<=x2; xx++ ) {
if ( !(xx & 1) ) fl_point(xx, y);
- }
- return;
+ }
+ return;
case FL_TREE_CONNECTOR_NONE:
- return;
+ return;
}
}
@@ -387,19 +388,19 @@ void Fl_Tree_Item::draw_vertical_connector(int x, int y1, int y2, const Fl_Tree_
fl_color(prefs.connectorcolor());
switch ( prefs.connectorstyle() ) {
case FL_TREE_CONNECTOR_SOLID:
- y1 |= 1; // force alignment w/dot pattern
- y2 |= 1; // force alignment w/dot pattern
- fl_line(x,y1,x,y2);
- return;
+ y1 |= 1; // force alignment w/dot pattern
+ y2 |= 1; // force alignment w/dot pattern
+ fl_line(x,y1,x,y2);
+ return;
case FL_TREE_CONNECTOR_DOTTED:
- y1 |= 1; // force alignment w/dot pattern
- y2 |= 1; // force alignment w/dot pattern
- for ( int yy=y1; yy<=y2; yy++ ) {
+ y1 |= 1; // force alignment w/dot pattern
+ y2 |= 1; // force alignment w/dot pattern
+ for ( int yy=y1; yy<=y2; yy++ ) {
if ( yy & 1 ) fl_point(x, yy);
- }
- return;
+ }
+ return;
case FL_TREE_CONNECTOR_NONE:
- return;
+ return;
}
}
@@ -418,15 +419,15 @@ const Fl_Tree_Item *Fl_Tree_Item::find_clicked(const Fl_Tree_Prefs &prefs) const
} else {
// See if event is over us
if ( event_inside(_xywh) ) { // event within this item?
- return(this); // found
+ return(this); // found
}
}
if ( is_open() ) { // open? check children of this item
for ( int t=0; t<children(); t++ ) {
- const Fl_Tree_Item *item;
- if ( ( item = _children[t]->find_clicked(prefs) ) != NULL) { // check child and its descendents
+ const Fl_Tree_Item *item;
+ if ( ( item = _children[t]->find_clicked(prefs) ) != NULL) { // check child and its descendents
return(item); // found?
- }
+ }
}
}
return(0);
@@ -448,15 +449,15 @@ Fl_Tree_Item *Fl_Tree_Item::find_clicked(const Fl_Tree_Prefs &prefs) {
} else {
// See if event is over us
if ( event_inside(_xywh) ) { // event within this item?
- return(this); // found
+ return(this); // found
}
}
if ( is_open() ) { // open? check children of this item
for ( int t=0; t<children(); t++ ) {
- Fl_Tree_Item *item;
- if ( ( item = _children[t]->find_clicked(prefs) ) != NULL ) { // check child and its descendents
+ Fl_Tree_Item *item;
+ if ( ( item = _children[t]->find_clicked(prefs) ) != NULL ) { // check child and its descendents
return(item); // found?
- }
+ }
}
}
return(0);
@@ -467,7 +468,9 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree,
const Fl_Tree_Prefs &prefs, int lastchild) {
if ( ! _visible ) return;
fl_font(_labelfont, _labelsize);
- int H = _labelsize + fl_descent() + prefs.linespacing();
+ int H = _labelsize;
+ if(usericon() && H < usericon()->h()) H = usericon()->h();
+ H += prefs.linespacing() + fl_descent();
// Colors, fonts
Fl_Color fg = _selected ? prefs.bgcolor() : _labelfgcolor;
Fl_Color bg = _selected ? prefs.selectcolor() : _labelbgcolor;
@@ -500,95 +503,97 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Widget *tree,
if ( drawthis ) {
// Draw connectors
if ( prefs.connectorstyle() != FL_TREE_CONNECTOR_NONE ) {
- // Horiz connector between center of icon and text
- draw_horizontal_connector(hstartx, hendx, textycenter, prefs);
- if ( has_children() && is_open() ) {
+ // Horiz connector between center of icon and text
+ draw_horizontal_connector(hstartx, hendx, textycenter, prefs);
+ if ( has_children() && is_open() ) {
// Small vertical line down to children
draw_vertical_connector(hcenterx, textycenter, Y+H, prefs);
- }
- // Connectors for last child
- if ( ! is_root() ) {
+ }
+ // Connectors for last child
+ if ( ! is_root() ) {
if ( lastchild ) {
draw_vertical_connector(hstartx, Y, textycenter, prefs);
} else {
draw_vertical_connector(hstartx, Y, Y+H, prefs);
}
- }
+ }
}
// Draw collapse icon
if ( has_children() && prefs.showcollapse() ) {
- // Draw icon image
- if ( is_open() ) {
+ // Draw icon image
+ if ( is_open() ) {
prefs.closeicon()->draw(icon_x,icon_y);
- } else {
+ } else {
prefs.openicon()->draw(icon_x,icon_y);
- }
+ }
}
// Background for this item
int &bx = _label_xywh[0] = X+(icon_w/2-1+prefs.connectorwidth());
int &by = _label_xywh[1] = Y;
int &bw = _label_xywh[2] = W-(icon_w/2-1+prefs.connectorwidth());
- int &bh = _label_xywh[3] = texth;
+ int &bh = _label_xywh[3] = H;
// Draw bg only if different from tree's bg
if ( bg != tree->color() || is_selected() ) {
- if ( is_selected() ) {
+ if ( is_selected() ) {
// Selected? Use selectbox() style
fl_draw_box(prefs.selectbox(), bx, by, bw, bh, bg);
- } else {
+ } else {
// Not Selected? use plain filled rectangle
fl_color(bg);
fl_rectf(bx, by, bw, bh);
- }
+ }
}
// Draw user icon (if any)
int useroff = (icon_w/2-1+prefs.connectorwidth());
if ( usericon() ) {
- // Item has user icon? Use it
- useroff += prefs.usericonmarginleft();
- usericon()->draw(X+useroff,icon_y);
- useroff += usericon()->w();
+ // Item has user icon? Use it
+ useroff += prefs.usericonmarginleft();
+ icon_y = textycenter - (usericon()->h() >> 1);
+ usericon()->draw(X+useroff,icon_y);
+ useroff += usericon()->w();
} else if ( prefs.usericon() ) {
- // Prefs has user icon? Use it
- useroff += prefs.usericonmarginleft();
- prefs.usericon()->draw(X+useroff,icon_y);
- useroff += prefs.usericon()->w();
+ // Prefs has user icon? Use it
+ useroff += prefs.usericonmarginleft();
+ icon_y = textycenter - (prefs.usericon()->h() >> 1);
+ prefs.usericon()->draw(X+useroff,icon_y);
+ useroff += prefs.usericon()->w();
}
useroff += prefs.labelmarginleft();
// Draw label
if ( widget() ) {
- // Widget? Draw it
- int lx = X+useroff;
- int ly = by;
- int lw = widget()->w();
- int lh = bh;
- if ( widget()->x() != lx || widget()->y() != ly ||
+ // Widget? Draw it
+ int lx = X+useroff;
+ int ly = by;
+ int lw = widget()->w();
+ int lh = bh;
+ if ( widget()->x() != lx || widget()->y() != ly ||
widget()->w() != lw || widget()->h() != lh ) {
widget()->resize(lx, ly, lw, lh); // fltk will handle drawing this
- }
+ }
} else {
- // No label widget? Draw text label
- if ( _label ) {
+ // No label widget? Draw text label
+ if ( _label ) {
fl_color(fg);
fl_draw(_label, X+useroff, Y+H-fl_descent()-1);
- }
+ }
}
Y += H;
} // end drawthis
// Draw children
if ( has_children() && is_open() ) {
- int child_x = drawthis ? // offset children to right,
- (hcenterx - (icon_w/2) + 1) : X; // unless didn't drawthis
+ int child_x = drawthis ? // offset children to right,
+ (hcenterx - (icon_w/2) + 1) : X; // unless didn't drawthis
int child_w = W - (child_x-X);
int child_y_start = Y;
for ( int t=0; t<children(); t++ ) {
- int lastchild = ((t+1)==children()) ? 1 : 0;
- _children[t]->draw(child_x, Y, child_w, tree, prefs, lastchild);
+ int lastchild = ((t+1)==children()) ? 1 : 0;
+ _children[t]->draw(child_x, Y, child_w, tree, prefs, lastchild);
}
if ( has_children() && is_open() ) {
- Y += prefs.openchild_marginbottom(); // offset below open child tree
+ Y += prefs.openchild_marginbottom(); // offset below open child tree
}
if ( ! lastchild ) {
- draw_vertical_connector(hstartx, child_y_start, Y, prefs);
+ draw_vertical_connector(hstartx, child_y_start, Y, prefs);
}
}
}
@@ -620,7 +625,7 @@ void Fl_Tree_Item::show_widgets() {
if ( _widget ) _widget->show();
if ( is_open() ) {
for ( int t=0; t<_children.total(); t++ ) {
- _children[t]->show_widgets();
+ _children[t]->show_widgets();
}
}
}
@@ -681,9 +686,9 @@ Fl_Tree_Item *Fl_Tree_Item::next() {
return(c->child(0));
}
while ( ( p = c->parent() ) != NULL ) { // loop upwards through parents
- int t = p->find_child(c); // find our position in parent's children[] array
- if ( ++t < p->children() ) // not last child?
- return(p->child(t)); // return next child
+ int t = p->find_child(c); // find our position in parent's children[] array
+ if ( ++t < p->children() ) // not last child?
+ return(p->child(t)); // return next child
c = p; // child becomes parent to move up generation
} // loop: moves up to next parent
return(0); // hit root? done
@@ -698,13 +703,13 @@ Fl_Tree_Item *Fl_Tree_Item::next() {
///
Fl_Tree_Item *Fl_Tree_Item::prev() {
Fl_Tree_Item *p=parent(); // start with parent
- if ( ! p ) return(0); // hit root? done
- int t = p->find_child(this); // find our position in parent's children[] array
+ if ( ! p ) return(0); // hit root? done
+ int t = p->find_child(this); // find our position in parent's children[] array
if ( --t == -1 ) { // are we first child?
- return(p); // return immediate parent
+ return(p); // return immediate parent
}
p = p->child(t); // take parent's previous child
- while ( p->has_children() ) { // has children?
+ while ( p->has_children() ) { // has children?
p = p->child(p->children()-1); // take last child
}
return(p);
diff --git a/src/Fl_Tree_Item_Array.cxx b/src/Fl_Tree_Item_Array.cxx
index be0216b44..5f37ce8e2 100644
--- a/src/Fl_Tree_Item_Array.cxx
+++ b/src/Fl_Tree_Item_Array.cxx
@@ -68,8 +68,8 @@ Fl_Tree_Item_Array::Fl_Tree_Item_Array(const Fl_Tree_Item_Array* o) {
void Fl_Tree_Item_Array::clear() {
if ( _items ) {
for ( int t=0; t<_total; t++ ) {
- delete _items[t];
- _items[t] = 0;
+ delete _items[t];
+ _items[t] = 0;
}
free((void*)_items); _items = 0;
}
@@ -88,9 +88,9 @@ void Fl_Tree_Item_Array::enlarge(int count) {
int newsize = _size + _chunksize;
Fl_Tree_Item **newitems = (Fl_Tree_Item**)malloc(newsize * sizeof(Fl_Tree_Item*));
if ( _items ) {
- // Copy old array -> new, delete old
- memmove(newitems, _items, _size * sizeof(Fl_Tree_Item*));
- free((void*)_items); _items = 0;
+ // Copy old array -> new, delete old
+ memmove(newitems, _items, _size * sizeof(Fl_Tree_Item*));
+ free((void*)_items); _items = 0;
}
// Adjust items/sizeitems
_items = newitems;
@@ -145,8 +145,8 @@ void Fl_Tree_Item_Array::remove(int index) {
int Fl_Tree_Item_Array::remove(Fl_Tree_Item *item) {
for ( int t=0; t<_total; t++ ) {
if ( item == _items[t] ) {
- remove(t);
- return(0);
+ remove(t);
+ return(0);
}
}
return(-1);
diff --git a/src/Fl_Tree_Prefs.cxx b/src/Fl_Tree_Prefs.cxx
index 2c81c7ab9..4adee203d 100644
--- a/src/Fl_Tree_Prefs.cxx
+++ b/src/Fl_Tree_Prefs.cxx
@@ -73,19 +73,19 @@ static Fl_Pixmap L_closepixmap(L_close_xpm);
/// when items are add()ed to the tree.
/// This overrides the built in default '[+]' icon.
///
-/// \param[in] val -- The new pixmap, or zero to use the default [+] icon.
+/// \param[in] val -- The new image, or zero to use the default [+] icon.
///
-void Fl_Tree_Prefs::openicon(Fl_Pixmap *val) {
- _openpixmap = val ? val : &L_openpixmap;
+void Fl_Tree_Prefs::openicon(Fl_Image *val) {
+ _openimage = val ? val : &L_openpixmap;
}
/// Sets the icon to be used as the 'close' icon.
/// This overrides the built in default '[-]' icon.
///
-/// \param[in] val -- The new pixmap, or zero to use the default [-] icon.
+/// \param[in] val -- The new image, or zero to use the default [-] icon.
///
-void Fl_Tree_Prefs::closeicon(Fl_Pixmap *val) {
- _closepixmap = val ? val : &L_closepixmap;
+void Fl_Tree_Prefs::closeicon(Fl_Image *val) {
+ _closeimage = val ? val : &L_closepixmap;
}
/// Fl_Tree_Prefs constructor
@@ -106,9 +106,9 @@ Fl_Tree_Prefs::Fl_Tree_Prefs() {
_inactivecolor = FL_GRAY;
_connectorcolor = Fl_Color(43);
_connectorstyle = FL_TREE_CONNECTOR_DOTTED;
- _openpixmap = &L_openpixmap;
- _closepixmap = &L_closepixmap;
- _userpixmap = 0;
+ _openimage = &L_openpixmap;
+ _closeimage = &L_closepixmap;
+ _userimage = 0;
_showcollapse = 1;
_showroot = 1;
_connectorwidth = 17;
@@ -118,9 +118,9 @@ Fl_Tree_Prefs::Fl_Tree_Prefs() {
// Let fltk's current 'scheme' affect defaults
if ( Fl::scheme() ) {
if ( strcmp(Fl::scheme(), "gtk+") == 0 ) {
- _selectbox = _FL_GTK_THIN_UP_BOX;
+ _selectbox = _FL_GTK_THIN_UP_BOX;
} else if ( strcmp(Fl::scheme(), "plastic") == 0 ) {
- _selectbox = _FL_PLASTIC_THIN_UP_BOX;
+ _selectbox = _FL_PLASTIC_THIN_UP_BOX;
}
}
}