class Fl_Browser : public Fl_Browser_
This is the Forms compatible browser. It displays a scrolling list of
text lines, and manages all the storage for the text. This object
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_.
Notice that the first line is No. 1, this is so that zero can be
reserved for "no line" in the selective browsers.
Fl_Browser(int,int,int,int,const char * =0);
The constructor makes an empty browser.
void add(const char *);
Add a new line to the end of the browser. The text is strdup'ed. It
may also be null to make a blank line.
void remove(int);
Remove line n and make the browser one line shorter. N must be
greater than zero and <= size().
void insert(int,const char *);
Insert a new line before line n, it becomes the new line n. N must
be greater than zero. If N is
greater than size() the line is added to the end.
void replace(int,const char *);
Replace the text for line n with this text. N must be
greater than zero and <= size().
void clear();
Remove all the lines in the browser.
int load(const char *filename);
Clears the browser, then reads the file and adds each line from the
file to the browser. If the filename is null or a zero-length string
then this just clears the browser. This returns zero if there was any
error in opening or reading the file, in which case errno is set to
the system error.
int size() const ;
Returns how many lines are in the browser. The last line number is
equal to this.
const char *text(int) const ;
Returns the text for line n.
int topline() const ;
void topline(int);
Get or set which line is at the top of the browser, due to scrolling.
If there are fewer lines than the size of the browser (and thus no
scrollbar) than this is always set to 1.
int position() const ;
void position(int);
Get or set the scrolling position of the browser. This is measured in
pixels, with 0 at the top. If there are fewer lines than the size of
the browser (and thus no scrollbar) than this is always set to 0.
void display(int,int=1);
int displayed(int) const ;
Set or get the "displayed" property for line n. If this is false
then the line takes no space and cannot be chosen.
uchar textfont() const ;
void textfont(uchar);
uchar textsize() const ;
void textsize(uchar);
uchar textcolor() const ;
void textcolor(uchar);
Set or get the default font, font size, or color used to draw the lines.
uchar specialkey() const ;
void specialkey(char);
Get or set the character used to introduce formatting codes, which by
default is '@'. Set this to zero to prevent formatting. A string of
formatting codes at the start of a text line are stripped off and used
to modify how the rest of the line is printed:
@@
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 (actually this adds one to textfont())
@i
Use an italic font (actually this adds two to textfont())
@f
or @t
Use a fixed-pitch
font (actually this sets the textfont() to 4)
@c
Center the line horizontally
@r
Right-justify the text
@C1, @C2, ... @C255
Use fl_color(n) to draw the text
@u
or @_
Underline the text.
@-
draw an engraved line through the middle.