00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _FL_BROWSER_H_
00023 #define _FL_BROWSER_H_
00024
00025 #include "Fl_Menu_.h"
00026 #include "Fl_Scrollbar.h"
00027
00029 class FL_API Fl_Browser : public Fl_Menu_ {
00030 Fl_End endgroup;
00031 void ctor_init();
00032 public:
00033
00034 static Fl_Named_Style* default_style;
00035
00036 Fl_Browser(int X,int Y,int W,int H,const char*l=0);
00037 Fl_Browser(const char* l = 0,int layout_size=20,Fl_Align layout_al=FL_ALIGN_TOP,int label_w=100);
00038 ~Fl_Browser();
00039
00040 enum {
00041 NORMAL = 0,
00042 MULTI = 1
00043 };
00044 bool multi() const { return (type()&MULTI); }
00045
00046 virtual int handle(int);
00047 virtual void layout();
00048 virtual void draw();
00049
00050 int max_width() const { return max_width_; }
00051 int max_height() const { return max_height_; }
00052
00053 int xposition() const { return xposition_; }
00054 void xposition(int);
00055 int yposition() const { return yposition_; }
00056 void yposition(int);
00057
00058 bool indented() const { return indented_; }
00059 void indented(bool v) { indented_ = v; }
00060
00061 Fl_Scrollbar scrollbar;
00062 Fl_Scrollbar hscrollbar;
00063
00064 Fl_Widget* goto_top();
00065 Fl_Widget* goto_focus() {return goto_mark(FOCUS);}
00066 Fl_Widget* goto_position(int y);
00067 Fl_Widget* goto_index(const int* indexes, int level);
00068 Fl_Widget* goto_index(int);
00069 Fl_Widget* goto_index(int,int,int=-1,int=-1,int=-1);
00070 Fl_Widget* next();
00071 Fl_Widget* next_visible();
00072 Fl_Widget* previous_visible();
00073 bool item_is_visible() const;
00074 bool item_is_parent() const;
00075
00076 bool set_focus();
00077 bool set_item_selected(bool value = true, int do_callback = 0);
00078 bool select_only_this(int do_callback = 0);
00079 bool deselect(int do_callback = 0);
00080
00081 enum linepos { NOSCROLL, TOP, MIDDLE, BOTTOM };
00082 bool make_item_visible(linepos = NOSCROLL);
00083 void damage_item() { damage_item(HERE); }
00084 bool set_item_opened(bool);
00085 bool set_item_visible(bool);
00086
00087 int current_level() const { return item_level[HERE]; }
00088 const int* current_index() const { return item_index[HERE]; }
00089 int current_position() const { return item_position[HERE]; }
00090
00091 int focus_level() const { return item_level[FOCUS]; }
00092 const int* focus_index() const { return item_index[FOCUS]; }
00093 int focus_position() const { return item_position[FOCUS]; }
00094 void value(int v) { goto_index(v); set_focus(); }
00095 int value() const { return focus_index()[0]; }
00096
00097 const int *column_widths() const { return column_widths_; }
00098 void column_widths(const int *pWidths) { column_widths_ = pWidths; }
00099
00100
00101 bool select(int line, bool value = true);
00102 bool selected(int line);
00103 int topline() const {return item_index[FIRST_VISIBLE][0];}
00104 void topline(int line) {goto_index(line); make_item_visible(TOP);}
00105 void bottomline(int line) {goto_index(line); make_item_visible(BOTTOM);}
00106 void middleline(int line) {goto_index(line); make_item_visible();}
00107 bool displayed(int line);
00108 bool display(int line, bool value = true);
00109
00110 private:
00111
00112 bool indented_;
00113 const int *column_widths_;
00114 int xposition_, yposition_;
00115 int max_width_, max_height_;
00116 int scrolldx, scrolldy;
00117 static void hscrollbar_cb(Fl_Widget*, void*);
00118 static void scrollbar_cb(Fl_Widget*, void*);
00119 void draw_item();
00120 void draw_clip(int,int,int,int);
00121 static void draw_clip_cb(void*,int,int,int,int);
00122 int X,Y,W,H;
00123
00124
00125
00126
00127 enum {
00128 HERE = 0,
00129 FOCUS,
00130 FIRST_VISIBLE,
00131 REDRAW_0,
00132 REDRAW_1,
00133 TEMP,
00134 NUMMARKS
00135 };
00136 Fl_Widget* goto_mark(int mark);
00137 Fl_Widget* goto_visible_focus();
00138 void set_mark(int dest, int mark);
00139 int compare_marks(int mark1, int mark2);
00140 bool at_mark(int mark) { return !compare_marks(HERE,mark); }
00141 void unset_mark(int mark);
00142 bool is_set(int mark);
00143 void damage_item(int mark);
00144
00145 int siblings;
00146
00147
00148 unsigned char item_level[NUMMARKS];
00149 unsigned char open_level[NUMMARKS];
00150 int item_position[NUMMARKS];
00151 int* item_index[NUMMARKS];
00152 int levels;
00153 void set_level(int);
00154 };
00155
00156 #endif