From b4995f979d127cea667b4e2b71c91e9db4ab52ef Mon Sep 17 00:00:00 2001 From: maxim nikonov Date: Fri, 6 Feb 2026 18:12:40 +0500 Subject: wip --- src/Fl_Tree_Item.cxx | 62 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 21 deletions(-) (limited to 'src/Fl_Tree_Item.cxx') diff --git a/src/Fl_Tree_Item.cxx b/src/Fl_Tree_Item.cxx index 5157ea04a..3e07cab72 100644 --- a/src/Fl_Tree_Item.cxx +++ b/src/Fl_Tree_Item.cxx @@ -145,7 +145,8 @@ void Fl_Tree_Item::show_self(const char *indent) const { char *i2 = new char [strlen(indent)+3]; // 2 + nul byte strcpy(i2, indent); strcat(i2, " |"); - for ( int t=0; tshow_self(i2); } delete[] i2; @@ -186,7 +187,8 @@ void Fl_Tree_Item::clear_children() { /// int Fl_Tree_Item::find_child(const char *name) { if ( name ) { - for ( int t=0; tlabel() ) if ( strcmp(child(t)->label(), name) == 0 ) return(t); @@ -201,11 +203,13 @@ int Fl_Tree_Item::find_child(const char *name) { /// \version 1.3.3 /// const Fl_Tree_Item* Fl_Tree_Item::find_child_item(const char *name) const { - if ( name ) - for ( int t=0; tlabel() ) if ( strcmp(child(t)->label(), name) == 0 ) return(child(t)); + } return(0); } @@ -224,7 +228,8 @@ Fl_Tree_Item* Fl_Tree_Item::find_child_item(const char *name) { /// \version 1.3.0 release /// const Fl_Tree_Item *Fl_Tree_Item::find_child_item(char **arr) const { - for ( int t=0; tlabel() ) { if ( strcmp(child(t)->label(), *arr) == 0 ) { // match? if ( *(arr+1) ) { // more in arr? descend @@ -276,7 +281,8 @@ Fl_Tree_Item *Fl_Tree_Item::find_item(char **names) { /// \returns the index, or -1 if not found. /// int Fl_Tree_Item::find_child(Fl_Tree_Item *item) { - for ( int t=0; tlabel(new_label); } recalc_tree(); // may change tree geometry item->_parent = this; + int t; switch ( prefs.sortorder() ) { case FL_TREE_SORT_NONE: { _children.add(item); return(item); } case FL_TREE_SORT_ASCENDING: { - for ( int t=0; t<_children.total(); t++ ) { + for (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); @@ -326,7 +333,7 @@ Fl_Tree_Item *Fl_Tree_Item::add(const Fl_Tree_Prefs &prefs, return(item); } case FL_TREE_SORT_DESCENDING: { - for ( int t=0; t<_children.total(); t++ ) { + for (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); @@ -417,7 +424,8 @@ Fl_Tree_Item *Fl_Tree_Item::insert_above(const Fl_Tree_Prefs &prefs, const char Fl_Tree_Item *p = _parent; if ( ! p ) return(0); // Walk our parent's children to find ourself - for ( int t=0; tchildren(); t++ ) { + int t; + for (t =0; tchildren(); t++ ) { Fl_Tree_Item *c = p->child(t); if ( this == c ) { return(p->insert(prefs, new_label, t)); @@ -642,7 +650,8 @@ Fl_Tree_Item *Fl_Tree_Item::replace_child(Fl_Tree_Item *olditem, /// \returns 0 if removed, -1 if item not an immediate child. /// int Fl_Tree_Item::remove_child(Fl_Tree_Item *item) { - for ( int t=0; tclear_children(); _children.remove(t); @@ -661,7 +670,8 @@ int Fl_Tree_Item::remove_child(Fl_Tree_Item *item) { /// \version 1.3.3 /// int Fl_Tree_Item::remove_child(const char *name) { - for ( int t=0; tlabel() ) { if ( strcmp(child(t)->label(), name) == 0 ) { _children.remove(t); @@ -697,7 +707,8 @@ void Fl_Tree_Item::swap_children(int ax, int bx) { /// int Fl_Tree_Item::swap_children(Fl_Tree_Item *a, Fl_Tree_Item *b) { int ax = -1, bx = -1; - for ( int t=0; tfind_clicked(prefs, yonly)) != NULL) // recurse into child for descendents return(item); // found? @@ -1140,7 +1154,8 @@ void Fl_Tree_Item::draw(int X, int &Y, int W, Fl_Tree_Item *itemfocus, : X; // unless didn't drawthis int child_w = W - (child_x-X); int child_y_start = Y; - for ( int t=0; tdraw(child_x, Y, child_w, itemfocus, tree_item_xmax, is_lastchild, render); } @@ -1238,7 +1253,8 @@ int Fl_Tree_Item::event_on_label(const Fl_Tree_Prefs &prefs) const { void Fl_Tree_Item::show_widgets() { if ( _widget ) _widget->show(); if ( is_open() ) { - for ( int t=0; t<_children.total(); t++ ) { + int t; + for (t =0; t<_children.total(); t++ ) { _children[t]->show_widgets(); } } @@ -1249,7 +1265,8 @@ void Fl_Tree_Item::show_widgets() { /// void Fl_Tree_Item::hide_widgets() { if ( _widget ) _widget->hide(); - for ( int t=0; t<_children.total(); t++ ) { + int t; + for (t =0; t<_children.total(); t++ ) { _children[t]->hide_widgets(); } } @@ -1258,7 +1275,8 @@ void Fl_Tree_Item::hide_widgets() { void Fl_Tree_Item::open() { set_flag(OPEN,1); // Tell children to show() their widgets - for ( int t=0; t<_children.total(); t++ ) { + int t; + for (t =0; t<_children.total(); t++ ) { _children[t]->show_widgets(); } recalc_tree(); // may change tree geometry @@ -1268,7 +1286,8 @@ void Fl_Tree_Item::open() { void Fl_Tree_Item::close() { set_flag(OPEN,0); // Tell children to hide() their widgets - for ( int t=0; t<_children.total(); t++ ) { + int t; + for (t =0; t<_children.total(); t++ ) { _children[t]->hide_widgets(); } recalc_tree(); // may change tree geometry @@ -1467,7 +1486,8 @@ Fl_Tree_Item *Fl_Tree_Item::prev_displayed(Fl_Tree_Prefs &prefs) { /// int Fl_Tree_Item::is_visible_r() const { if ( !visible() ) return(0); - for (const Fl_Tree_Item *p=parent(); p; p=p->parent())// move up through parents + const Fl_Tree_Item *p; + for (p =parent(); p; p=p->parent())// move up through parents if (!p->visible() || p->is_close()) return(0); // any parent not visible or closed? return(1); } -- cgit v1.2.3