2 // "$Id: Fl_Browser_.H,v 1.2 2002/12/01 15:38:37 neurosurg Exp $"
4 // Common browser header file for the Fast Light Tool Kit (FLTK).
6 // Copyright 1998-2002 by Bill Spitzak and others.
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // Please report all bugs and problems to "fltk-bugs@fltk.org".
26 // This is the base class for browsers. To be useful it must
27 // be subclassed and several virtual functions defined. The
28 // Forms-compatable browser and the file chooser's browser are
29 // subclassed off of this.
31 // Yes, I know this should be a template...
39 #include "Fl_Scrollbar.H"
41 #define FL_NORMAL_BROWSER 0
42 #define FL_SELECT_BROWSER 1
43 #define FL_HOLD_BROWSER 2
44 #define FL_MULTI_BROWSER 3
46 class FL_EXPORT Fl_Browser_ : public Fl_Group {
47 int position_; // where user wants it scrolled to
48 int real_position_; // the current vertical scrolling position
49 int hposition_; // where user wants it panned to
50 int real_hposition_; // the current horizontal scrolling position
51 int offset_; // how far down top_ item the real_position is
52 int max_width; // widest object seen so far
53 uchar has_scrollbar_; // which scrollbars are enabled
54 uchar textfont_, textsize_;
56 void* top_; // which item scrolling position is in
57 void* selection_; // which is selected (except for FL_MULTI_BROWSER)
58 void *redraw1,*redraw2; // minimal update pointers
59 void* max_width_item; // which item has max_width_
61 static int scrollbar_width_;
67 // All of the following must be supplied by the subclass:
68 virtual void *item_first() const = 0;
69 virtual void *item_next(void *) const = 0;
70 virtual void *item_prev(void *) const = 0;
71 virtual int item_height(void *) const = 0;
72 virtual int item_width(void *) const = 0;
73 virtual int item_quick_height(void *) const ;
74 virtual void item_draw(void *,int,int,int,int) const = 0;
75 // you don't have to provide these but it may help speed it up:
76 virtual int full_width() const ; // current width of all items
77 virtual int full_height() const ; // current height of all items
78 virtual int incr_height() const ; // average height of an item
79 // These only need to be done by subclass if you want a multi-browser:
80 virtual void item_select(void *,int=1);
81 virtual int item_selected(void *) const ;
83 // things the subclass may want to call:
84 void *top() const {return top_;}
85 void *selection() const {return selection_;}
86 void new_list(); // completely clobber all data, as though list replaced
87 void deleting(void *a); // get rid of any pointers to a
88 void replacing(void *a,void *b); // change a pointers to b
89 void inserting(void *a,void *b); // insert a before b
90 int displayed(void *) const ; // true if this line is visible
91 void redraw_line(void *); // minimal update, no change in size
92 void redraw_lines() {damage(FL_DAMAGE_SCROLL);} // redraw all of them
93 void bbox(int&,int&,int&,int&) const;
94 int leftedge() const; // x position after scrollbar & border
95 void *find_item(int my); // item under mouse
96 void draw(int,int,int,int);
97 int handle(int,int,int,int,int);
100 Fl_Browser_(int,int,int,int,const char * = 0);
104 Fl_Scrollbar scrollbar; // Vertical scrollbar
105 Fl_Scrollbar hscrollbar; // Horizontal scrollbar
108 void resize(int,int,int,int);
110 int select(void *,int=1,int docallbacks=0);
111 int select_only(void *,int docallbacks=0);
112 int deselect(int docallbacks=0);
113 int position() const {return position_;}
114 int hposition() const {return hposition_;}
115 void position(int); // scroll to here
116 void hposition(int); // pan to here
117 void display(void*); // scroll so this item is shown
119 uchar has_scrollbar() const {return has_scrollbar_;}
120 void has_scrollbar(uchar i) {has_scrollbar_ = i;}
121 enum { // values for has_scrollbar()
126 HORIZONTAL_ALWAYS = 5,
131 Fl_Font textfont() const {return (Fl_Font)textfont_;}
132 void textfont(uchar s) {textfont_ = s;}
133 uchar textsize() const {return textsize_;}
134 void textsize(uchar s) {textsize_ = s;}
135 Fl_Color textcolor() const {return (Fl_Color)textcolor_;}
136 void textcolor(unsigned n) {textcolor_ = n;}
138 static void scrollbar_width(int b) {scrollbar_width_ = b;}
139 static int scrollbar_width() {return scrollbar_width_;}
141 // for back compatability:
142 void scrollbar_right() {scrollbar.align(FL_ALIGN_RIGHT);}
143 void scrollbar_left() {scrollbar.align(FL_ALIGN_LEFT);}
150 // End of "$Id: Fl_Browser_.H,v 1.2 2002/12/01 15:38:37 neurosurg Exp $".