summaryrefslogtreecommitdiff
path: root/src/Fl_Tree_Item.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Fl_Tree_Item.cxx')
-rw-r--r--src/Fl_Tree_Item.cxx62
1 files changed, 41 insertions, 21 deletions
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; t<children(); t++ ) {
+ int t;
+ for (t =0; t<children(); t++ ) {
child(t)->show_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; t<children(); t++ )
+ int t;
+ for (t =0; t<children(); t++ )
if ( child(t)->label() )
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; t<children(); t++ )
+ if ( name ) {
+ int t;
+ for (t =0; t<children(); t++ )
if ( child(t)->label() )
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; t<children(); t++ ) {
+ int t;
+ for (t =0; t<children(); t++ ) {
if ( child(t)->label() ) {
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; t<children(); t++ )
+ int t;
+ for (t =0; t<children(); t++ )
if ( item == child(t) )
return(t);
return(-1);
@@ -309,13 +315,14 @@ Fl_Tree_Item *Fl_Tree_Item::add(const Fl_Tree_Prefs &prefs,
{ item = new Fl_Tree_Item(_tree); item->label(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; t<p->children(); t++ ) {
+ int t;
+ for (t =0; t<p->children(); 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; t<children(); t++ ) {
+ int t;
+ for (t =0; t<children(); t++ ) {
if ( child(t) == item ) {
item->clear_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; t<children(); t++ ) {
+ int t;
+ for (t =0; t<children(); t++ ) {
if ( child(t)->label() ) {
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; t<children(); t++ ) { // find index for a and b
+ int t;
+ for (t =0; t<children(); t++ ) { // find index for a and b
if ( _children[t] == a ) { ax = t; if ( bx != -1 ) break; else continue; }
if ( _children[t] == b ) { bx = t; if ( ax != -1 ) break; else continue; }
}
@@ -722,7 +733,8 @@ void Fl_Tree_Item::draw_horizontal_connector(int x1, int x2, int y, const Fl_Tre
case FL_TREE_CONNECTOR_DOTTED:
{
x1 |= 1; // force alignment w/dot pattern
- for ( int xx=x1; xx<=x2; xx+=2 ) {
+ int xx;
+ for (xx =x1; xx<=x2; xx+=2 ) {
fl_point(xx, y);
}
return;
@@ -751,7 +763,8 @@ void Fl_Tree_Item::draw_vertical_connector(int x, int y1, int y2, const Fl_Tree_
{
y1 |= 1; // force alignment w/dot pattern
y2 |= 1; // force alignment w/dot pattern
- for ( int yy=y1; yy<=y2; yy+=2 ) {
+ int yy;
+ for (yy =y1; yy<=y2; yy+=2 ) {
fl_point(x, yy);
}
return;
@@ -787,7 +800,8 @@ const Fl_Tree_Item *Fl_Tree_Item::find_clicked(const Fl_Tree_Prefs &prefs, int y
}
}
if ( is_open() ) { // open? check children of this item
- for ( int t=0; t<children(); t++ ) {
+ int t;
+ for (t =0; t<children(); t++ ) {
const Fl_Tree_Item *item;
if ( (item = _children[t]->find_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; t<children(); t++ ) {
+ int t;
+ for (t =0; t<children(); t++ ) {
int is_lastchild = ((t+1)==children()) ? 1 : 0;
_children[t]->draw(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);
}