Each line in the browser is identified by number. The numbers start at one (this is so that zero can be reserved for "no line" in the selective browsers). Unless otherwise noted, the methods do not check to see if the passed line number is in range and legal. It must always be greater than zero and <= size().
Each line contains a null-terminated string of text and a void* data pointer. The text string is displayed, the void* pointer can be used by the callbacks to reference the object the text describes.
The base class does nothing when the user clicks on it. There are subclasses that react to user clicks to select lines in the browser and do callbacks:
There is a base class called Fl_Browser_. This provides the scrolling and selection mechanisms of this and all the subclasses, but the dimensions and appearance of each item are determined by the subclass. You can use Fl_Browser_ to display information other than text, or text that is dynamically produced from your own data structures. If you find that loading the browser is a lot of work or is inefficient, you may want to make a subclass of Fl_Browser_.
Fl_Browser::Fl_Browser(int, int, int, int, const char * =0);
void Fl_Browser::add(const char*, void* = 0);
void Fl_Browser::remove(int n);
void Fl_Browser::insert(int n, const char*, void* = 0);
void Fl_Browser::move(int to, int from);
void Fl_Browser::clear();
int Fl_Browser::load(const char *filename);
int Fl_Browser::size() const ;
const char* Fl_Browser::text(int n) const ;
void Fl_Browser::text(int n, const char*);
void* Fl_Browser::data(int n) const ;
void Fl_Browser::data(int n, void*);
void Fl_Browser::show(int n);
void Fl_Browser::hide(int n);
int Fl_Browser::visible(int n) const ;
int Fl_Browser::topline() const ;
void Fl_Browser::topline(int);
int Fl_Browser::position() const ;
void Fl_Browser::position(int);
Fl_Font Fl_Browser::textfont() const ;
void Fl_Browser::textfont(Fl_Font);
uchar Fl_Browser::textsize() const ;
void Fl_Browser::textsize(uchar);
Fl_Color Fl_Browser::textcolor() const ;
void Fl_Browser::textcolor(Fl_Color);
uchar Fl_Browser::column_char() const ;
void Fl_Browser::column_char(char);
const int* Fl_Browser::column_widths() const ;
void Fl_Browser::column_widths(const int*);
static int widths[] = {40,40,40,0}; browser->column_widths(widths);
uchar Fl_Browser::format_char() const ;
void Fl_Browser::format_char(char);
@.
Print rest of line, don't look for more '@' signs
@@
Print rest of line starting with '@'
@l
Use a large (24 point) font
@m
Use a medium large (18 point) font
@s
Use a small (11 point) font
@b
Use a bold font (adds FL_BOLD to font)
@i
Use an italic font (adds FL_ITALIC to font)
@f
or @t
Use a fixed-pitch
font (sets font to FL_COURIER)
@c
Center the line horizontally
@r
Right-justify the text
@B0, @B1, ... @B255
Fill the backgound with fl_color(n)
@C0, @C1, ... @C255
Use fl_color(n) to draw the text
@F0, @F1, ...
Use fl_font(n) to draw the text
@S1, @S2, ...
Use point size n to draw the text
@u
or @_
Underline the text.
@-
draw an engraved line through the middle.
Notice that the @.
command can be used to reliably
terminate the parsing. To print a random string in a random color,
use sprintf("@C%d@.%s", color, string)
and it
will work even if the string starts with a digit or has an @ sign in
it.
void Fl_Browser_::has_scrollbar(int);
0
- No scrollbars
Fl_Browser::HORIZONTAL
- Only a horizontal scrollbar.
Fl_Browser::VERTICAL
- Only a vertical scrollbar.
Fl_Browser::BOTH
- The default is both scrollbars.
Fl_Browser::HORIZONTAL_ALWAYS
- Horizontal scrollbar
always on, vertical always off.
Fl_Browser::VERTICAL_ALWAYS
- Vertical scrollbar always on,
horizontal always off.
Fl_Browser::BOTH_ALWAYS
- Both always on.
void Fl_Browser_::scrollbar.align(int);
Fl_Scrollbar& Fl_Browser_::scrollbar;
Fl_Scrollbar& Fl_Browser_::hscrollbar;
See Fl_Browser for methods to add and remove lines from the browser.
Fl_Select_Browser::Fl_Select_Browser(int x,int y,int w,int
h,const char *l)
Fl_When Fl_Widget::when() const;
void Fl_Widget::when(Fl_When);
FL_WHEN_RELEASE
:FL_WHEN_CHANGED
: The callback is done as the user
drags the mouse, each time the selected item changes.
FL_WHEN_RELEASE
(default value) : The callback will
be done when the user releases the mouse.
int Fl_Browser::value() const ;
int Fl_Browser::select(int, int=1);
void Fl_Browser::value(int) ;
int Fl_Browser::deselect();
int Fl_Browser::selected(int) const ;
See Fl_Browser for methods to add and remove lines from the browser.
Fl_Hold_Browser::Fl_Hold_Browser(int x,int y,int w,int h,const char
*l)
Fl_When Fl_Widget::when() const;
void Fl_Widget::when(Fl_When);
FL_WHEN_RELEASE
:0
: The callback is not done, instead changed() is
turned on.
FL_WHEN_CHANGED
: The callback is done as the user
drags the mouse, each time the selected item changes.
FL_WHEN_RELEASE
(default value) : The callback will
be done when the user releases the mouse if they picked a different
value.
FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED
will do the callback
even if the user picks the same value.
int Fl_Browser::value() const ;
void Fl_Browser::value(int) ;
int Fl_Browser::deselect();
int Fl_Browser::select(int,int=1);
int Fl_Browser::selected(int) const ;
See Fl_Browser for methods to add and remove lines from the browser.
Fl_Multi_Browser::Fl_Multi_Browser(int x,int y,int w,int
h,const char *l)
Fl_When Fl_Widget::when() const;
void Fl_Widget::when(Fl_When);
FL_WHEN_RELEASE
:0
: The callback is not done, but changed() is turned
on.
FL_WHEN_CHANGED
: The callback is done as the user
drags the mouse, for each item that turns on or off. There can
be many callbacks for each X event. value() will tell you which line
changed.
FL_WHEN_RELEASE
(default value) : The callback is
done when the user releases the mouse. You will have to scan through
them to find out what the new set of selected items is.
FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED
: The callback is
done even if the user clicks on the same item as before.
int Fl_Browser::value() const ;
void Fl_Browser::value(int) ;
int Fl_Browser::deselect();
int Fl_Browser::select(int, int=1);
int Fl_Browser::selected(int) const ;