Albrecht Schlosser wrote:
>>> Should I do this in Fl_Tree too, or is there a 'better way'?
>
> I believe the better way is to make the scrollbars private or
> protected and make one's own methods for all the methods needed.
Right, I was torn between being consistent with the existing Fl_Browser
API
and cleaning things up.
I figured there must've been a good reason for Fl_Browser to have the
scrollbar
public, and that I should probably follow suit without knowing what it
was.
I like the idea of just making it protected, and add methods later when
folks request it. It can always be made public later too, I suppose,
or exposed via a method that returns its pointer.
I was kinda landing on the side of "consistency", as I figured future
FLTK
releases (2.x, 3.x, etc) would be fixing everything "the right way"
with better encapsulation, making FLTK1's weirdness moot.
But good to hear your suggs. So I'll:
protect the scrollbars
change Fl_Tree::position() to vposition()
..and check that in.
> [Side note: if the scrollbars are part of Fl_Tree's group, then I would
> prefer to remove them from the group, just as I would like to do this
> for Fl_Scroll etc., but that's another story and has implications for
> event handling.]
Agreed, though I've never seen a clear way to do this.
I was confronted with this in Fl_Table too, and thought about it quite
a bit.
It is troublesome that the scrollbars are part of the group, but really
usually only to the extent that the user wants to walk the children
without
accidentally considering them. [Overriding clear() is important too..]
I figure possibly another reason the Fl_Scroll bars are public
is so that someone walking the children can skip the scrollbars
by comparing pointers, eg:
for ( i=0; i<brow->children(); i++ ) {
Fl_Widget *w = tree->child(i);
if ( w != brow->vscroll && w != brow->hscroll ) { // SKIP SCROLLBARS
(BAD:PUBLIC)
..do work..
}
}
Not an issue for Fl_Browser since the I don't think it supports children
other than its own.
But Fl_Scroll and Fl_Tree do, so I wonder if a method along the lines of
"is_scrollbar()" can be useful to allow skipping the scrollbars, eg:
for ( i=0; i<tree->children(); i++ ) {
Fl_Widget *w= tree->child(i);
if ( !brow->is_scrollbar(w) ) { // SKIP SCROLLBARS
(BETTER:PROTECTED)
..do work..
}
}
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev