Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Fl_Browser.h

00001 /*
00002  * $Id: Fl_Browser.h,v 1.7 2003/05/29 23:27:28 leka Exp $
00003  *
00004  * Extended Fast Light Toolkit (EFLTK)
00005  * Copyright (C) 2002-2003 by EDE-Team
00006  * WWW: http://www.sourceforge.net/projects/ede
00007  *
00008  * Fast Light Toolkit (FLTK)
00009  * Copyright (C) 1998-2003 by Bill Spitzak and others.
00010  * WWW: http://www.fltk.org
00011  *
00012  * This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00013  * version 2. See COPYING for details.
00014  *
00015  * Author : Mikko Lahteenmaki
00016  * Email  : mikko@fltk.net
00017  *
00018  * Please report all bugs and problems to "efltk-bugs@fltk.net"
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 { // values for type()
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     // Convienence functions for flat browsers:
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; // bounding box area
00123 
00124     // Marks serve as "indexes" into the hierarchial browser. We probably
00125     // need to make some sort of public interface but I have not figured
00126     // it out completely.
00127     enum { // predefined marks
00128         HERE = 0, // current item, the one moved by all the calls
00129         FOCUS,
00130         FIRST_VISIBLE,
00131         REDRAW_0,
00132         REDRAW_1,
00133         TEMP,
00134         NUMMARKS
00135     };
00136     Fl_Widget* goto_mark(int mark); // set HERE to mark
00137     Fl_Widget* goto_visible_focus(); // set HERE to focus if visible
00138     void set_mark(int dest, int mark); // set dest to mark
00139     int compare_marks(int mark1, int mark2); // returns >0 if mark1 after mark2
00140     bool at_mark(int mark) { return !compare_marks(HERE,mark); }
00141     void unset_mark(int mark);  // makes mark have illegal value
00142     bool is_set(int mark);  // false if unset_mark was called
00143     void damage_item(int mark); // make this item redraw
00144 
00145     int siblings; // # of children of parent of HERE item
00146 
00147     // For each mark:
00148     unsigned char item_level[NUMMARKS]; // depth in hierarchy of the item
00149     unsigned char open_level[NUMMARKS]; // depth of highest closed parent
00150     int item_position[NUMMARKS]; // distance in pixels from top of browser
00151     int* item_index[NUMMARKS]; // indexes at each level of hierarchy
00152     int levels; // maximum depth of all items encountered so far
00153     void set_level(int); // increases levels by reallocating the arrays
00154 };
00155 
00156 #endif

Generated on Thu Jul 31 15:33:43 2003 for eFLTK by doxygen1.2.15