FLTK 1.4.5: Fl_Browser.H Source File

FLTK 1.4.5

Loading...
Searching...
No Matches
Fl_Browser.H
1//
2// Browser header file for the Fast Light Tool Kit (FLTK).
3//
4// Copyright 1998-2023 by Bill Spitzak and others.
5//
6// This library is free software. Distribution and use rights are outlined in
7// the file "COPYING" which should have been included with this file. If this
8// file is missing or damaged, see the license at:
9//
10// https://www.fltk.org/COPYING.php
11//
12// Please see the following page on how to report bugs and issues:
13//
14// https://www.fltk.org/bugs.php
15//
16
17/* \file
18 Fl_Browser widget . */
19
20// Forms-compatible browser. Probably useful for other
21// lists of textual data. Notice that the line numbers
22// start from 1, and 0 means "no line".
23
24#ifndef Fl_Browser_H
25#define Fl_Browser_H
26
27#include "Fl_Browser_.H"
28#include "Fl_Image.H"
29
30struct FL_BLINE;
31
86 class FL_EXPORT Fl_Browser : public Fl_Browser_ {
87
88 FL_BLINE *first; // the array of lines
89 FL_BLINE *last;
90 FL_BLINE *cache;
91 int cacheline; // line number of cache
92 int lines; // Number of lines
93 int full_height_;
94 const int* column_widths_;
95 char format_char_; // alternative to @-sign
96 char column_char_; // alternative to tab
97
98protected:
99
100 // required routines for Fl_Browser_ subclass:
101 void* item_first() const FL_OVERRIDE;
102 void* item_next(void* item) const FL_OVERRIDE;
103 void* item_prev(void* item) const FL_OVERRIDE;
104 void* item_last()const FL_OVERRIDE;
105 int item_selected(void* item) const FL_OVERRIDE;
106 void item_select(void* item, int val) FL_OVERRIDE;
107 int item_height(void* item) const FL_OVERRIDE;
108 int item_width(void* item) const FL_OVERRIDE;
109 void item_draw(void* item, int X, int Y, int W, int H) const FL_OVERRIDE;
110 int full_height() const FL_OVERRIDE;
111 int incr_height() const FL_OVERRIDE;
112 const char *item_text(void *item) const FL_OVERRIDE;
118 void item_swap(void *a, void *b) FL_OVERRIDE { swap((FL_BLINE*)a, (FL_BLINE*)b); }
124 void *item_at(int line) const FL_OVERRIDE { return (void*)find_line(line); }
125
126 FL_BLINE* find_line(int line) const ;
127 FL_BLINE* _remove(int line) ;
128 void insert(int line, FL_BLINE* item);
129 int lineno(void *item) const ;
130 void swap(FL_BLINE *a, FL_BLINE *b);
131
132public:
133
134 void remove(int line);
135 void add(const char* newtext, void* d = 0);
136 void insert(int line, const char* newtext, void* d = 0);
137 void move(int to, int from);
138 int load(const char* filename);
139 void swap(int a, int b);
140 void clear();
141
147 int size() const { return lines; }
148 void size(int W, int H) { Fl_Widget::size(W, H); }
149
153 Fl_Fontsize textsize() const { return Fl_Browser_::textsize(); }
154
155 /*
156 Sets the default text size for the lines in the browser to newSize.
157 Defined and documented in Fl_Browser.cxx
158 */
159 void textsize(Fl_Fontsize newSize);
160
161 int topline() const ;
163 enum Fl_Line_Position { TOP, BOTTOM, MIDDLE };
164 void lineposition(int line, Fl_Line_Position pos);
171 void topline(int line) { lineposition(line, TOP); }
178 void bottomline(int line) { lineposition(line, BOTTOM); }
185 void middleline(int line) { lineposition(line, MIDDLE); }
186
187 int select(int line, int val=1);
188 int selected(int line) const ;
189 void show(int line);
191 void show() FL_OVERRIDE { Fl_Widget::show(); }
192 void hide(int line);
194 void hide() FL_OVERRIDE { Fl_Widget::hide(); }
195 int visible(int line) const ;
196
197 int value() const ;
203 void value(int line) { select(line); }
204 const char* text(int line) const ;
205 void text(int line, const char* newtext);
206 void* data(int line) const ;
207 void data(int line, void* d);
208
209 Fl_Browser(int X, int Y, int W, int H, const char *L = 0);
213 ~Fl_Browser() { clear(); }
214
246 char format_char() const { return format_char_; }
252 void format_char(char c) { format_char_ = c; }
258 char column_char() const { return column_char_; }
265 void column_char(char c) { column_char_ = c; }
289 const int* column_widths() const { return column_widths_; }
294 void column_widths(const int* arr) { column_widths_ = arr; }
295
305 int displayed(int line) const { return Fl_Browser_::displayed(find_line(line)); }
306
314 void make_visible(int line) {
315 if (line < 1) Fl_Browser_::display(find_line(1));
316 else if (line > lines) Fl_Browser_::display(find_line(lines));
317 else Fl_Browser_::display(find_line(line));
318 }
319
320 // icon support
321 void icon(int line, Fl_Image* icon);
322 Fl_Image* icon(int line) const;
323 void remove_icon(int line);
324
326 void replace(int a, const char* b) { text(a, b); }
327 void display(int line, int val=1);
328};
329
330#endif
Fl_Fontsize
int Fl_Fontsize
Size of a font in pixels.
Definition Enumerations.H:1092
Fl_Image.H
Fl_Image, Fl_RGB_Image classes.
Fl_Browser_::item_selected
virtual int item_selected(void *item) const
This method must be implemented by the subclass if it supports multiple selections; returns the selec...
Definition Fl_Browser_.cxx:1101
Fl_Browser_::item_next
virtual void * item_next(void *item) const =0
This method must be provided by the subclass to return the item in the list after item.
Fl_Browser_::item_last
virtual void * item_last() const
This method must be provided by the subclass to return the last item in the list.
Definition Fl_Browser_.H:129
Fl_Browser_::incr_height
virtual int incr_height() const
This method may be provided to return the average height of all items to be used for scrolling.
Definition Fl_Browser_.cxx:1056
Fl_Browser_::item_width
virtual int item_width(void *item) const =0
This method must be provided by the subclass to return the width of the item in pixels.
Fl_Browser_::display
void display(void *item)
Displays the item, scrolling the list as necessary.
Definition Fl_Browser_.cxx:244
Fl_Browser_::textsize
Fl_Fontsize textsize() const
Gets the default text size (in pixels) for the lines in the browser.
Definition Fl_Browser_.H:327
Fl_Browser_::item_height
virtual int item_height(void *item) const =0
This method must be provided by the subclass to return the height of item in pixels.
Fl_Browser_::Fl_Browser_
Fl_Browser_(int X, int Y, int W, int H, const char *L=0)
The constructor makes an empty browser.
Definition Fl_Browser_.cxx:954
Fl_Browser_::item_prev
virtual void * item_prev(void *item) const =0
This method must be provided by the subclass to return the item in the list before item.
Fl_Browser_::item_first
virtual void * item_first() const =0
This method must be provided by the subclass to return the first item in the list.
Fl_Browser_::item_select
virtual void item_select(void *item, int val=1)
This method must be implemented by the subclass if it supports multiple selections; sets the selectio...
Definition Fl_Browser_.cxx:1093
Fl_Browser_::full_height
virtual int full_height() const
This method may be provided by the subclass to indicate the full height of the item list,...
Definition Fl_Browser_.cxx:1067
Fl_Browser_::item_draw
virtual void item_draw(void *item, int X, int Y, int W, int H) const =0
This method must be provided by the subclass to draw the item in the area indicated by X,...
Fl_Browser_::select
int select(void *item, int val=1, int docallbacks=0)
Sets the selection state of item to val, and returns 1 if the state changed or 0 if it did not.
Definition Fl_Browser_.cxx:607
Fl_Browser_::item_text
virtual const char * item_text(void *item) const
This optional method returns a string (label) that may be used for sorting.
Definition Fl_Browser_.H:158
Fl_Browser_::displayed
int displayed(void *item) const
Returns non-zero if item has been scrolled to a position where it is being displayed.
Definition Fl_Browser_.cxx:227
Fl_Browser
The Fl_Browser widget displays a scrolling list of text lines, and manages all the storage for the te...
Definition Fl_Browser.H:86
Fl_Browser::hide
void hide() FL_OVERRIDE
Hides the entire Fl_Browser widget – opposite of show().
Definition Fl_Browser.H:194
Fl_Browser::swap
void swap(FL_BLINE *a, FL_BLINE *b)
Swap the two items a and b.
Definition Fl_Browser.cxx:832
Fl_Browser::format_char
char format_char() const
Gets the current format code prefix character, which by default is '@'.
Definition Fl_Browser.H:246
Fl_Browser::Fl_Line_Position
Fl_Line_Position
For internal use only?
Definition Fl_Browser.H:163
Fl_Browser::item_swap
void item_swap(void *a, void *b) FL_OVERRIDE
Swap the items a and b.
Definition Fl_Browser.H:118
Fl_Browser::format_char
void format_char(char c)
Sets the current format code prefix character to c.
Definition Fl_Browser.H:252
Fl_Browser::Fl_Browser
Fl_Browser(int X, int Y, int W, int H, const char *L=0)
The constructor makes an empty browser.
Definition Fl_Browser.cxx:599
Fl_Browser::textsize
Fl_Fontsize textsize() const
Gets the default text size (in pixels) for the lines in the browser.
Definition Fl_Browser.H:153
Fl_Browser::show
void show() FL_OVERRIDE
Shows the entire Fl_Browser widget – opposite of hide().
Definition Fl_Browser.H:191
Fl_Browser::column_widths
void column_widths(const int *arr)
Sets the current array to arr.
Definition Fl_Browser.H:294
Fl_Browser::column_char
void column_char(char c)
Sets the column separator to c.
Definition Fl_Browser.H:265
Fl_Browser::item_at
void * item_at(int line) const FL_OVERRIDE
Return the item at specified line.
Definition Fl_Browser.H:124
Fl_Browser::size
int size() const
Returns how many lines are in the browser.
Definition Fl_Browser.H:147
Fl_Browser::value
void value(int line)
Sets the browser's value(), which selects the specified line.
Definition Fl_Browser.H:203
Fl_Browser::displayed
int displayed(int line) const
Returns non-zero if line has been scrolled to a position where it is being displayed.
Definition Fl_Browser.H:305
Fl_Browser::find_line
FL_BLINE * find_line(int line) const
Returns the item for specified line.
Definition Fl_Browser.cxx:145
Fl_Browser::make_visible
void make_visible(int line)
Make the item at the specified line visible().
Definition Fl_Browser.H:314
Fl_Browser::lineposition
void lineposition(int line, Fl_Line_Position pos)
Updates the browser so that line is shown at position pos.
Definition Fl_Browser.cxx:616
Fl_Browser::column_char
char column_char() const
Gets the current column separator character.
Definition Fl_Browser.H:258
Fl_Browser::~Fl_Browser
~Fl_Browser()
The destructor deletes all list items and destroys the browser.
Definition Fl_Browser.H:213
Fl_Browser::column_widths
const int * column_widths() const
Gets the current column width array.
Definition Fl_Browser.H:289
Fl_Browser::topline
void topline(int line)
Scrolls the browser so the top item in the browser is showing the specified line.
Definition Fl_Browser.H:171
Fl_Browser::text
const char * text(int line) const
Returns the label text for the specified line.
Definition Fl_Browser.cxx:718
Fl_Browser::bottomline
void bottomline(int line)
Scrolls the browser so the bottom item in the browser is showing the specified line.
Definition Fl_Browser.H:178
Fl_Browser::replace
void replace(int a, const char *b)
For back compatibility only.
Definition Fl_Browser.H:326
Fl_Browser::middleline
void middleline(int line)
Scrolls the browser so the middle item in the browser is showing the specified line.
Definition Fl_Browser.H:185
Fl_Group::add
void add(Fl_Widget &)
The widget is removed from its current group (if any) and then added to the end of this group.
Definition Fl_Group.cxx:560
Fl_Group::insert
void insert(Fl_Widget &, int i)
The widget is removed from its current group (if any) and then inserted into this group.
Definition Fl_Group.cxx:511
Fl_Group::clear
void clear()
Deletes all child widgets from memory recursively.
Definition Fl_Group.cxx:381
Fl_Group::remove
void remove(int index)
Removes the widget at index from the group but does not delete it.
Definition Fl_Group.cxx:585
Fl_Image
Base class for image caching, scaling and drawing.
Definition Fl_Image.H:60
Fl_Widget::hide
virtual void hide()
Makes a widget invisible.
Definition Fl_Widget.cxx:263
Fl_Widget::show
virtual void show()
Makes a widget visible.
Definition Fl_Widget.cxx:251
Fl_Widget::visible
unsigned int visible() const
Returns whether a widget is visible.
Definition Fl_Widget.H:872
Fl_Widget::size
void size(int W, int H)
Changes the size of the widget.
Definition Fl_Widget.H:418
FL_OVERRIDE
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46