FLTK 1.3.0
|
00001 // 00002 // "$Id$" 00003 // 00004 // Fl_Check_Browser header file for the Fast Light Tool Kit (FLTK). 00005 // 00006 // Copyright 1998-2010 by Bill Spitzak and others. 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Library General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00021 // USA. 00022 // 00023 // Please report all bugs and problems on the following page: 00024 // 00025 // http://www.fltk.org/str.php 00026 // 00027 00028 /* \file 00029 Fl_Check_Browser widget . */ 00030 00031 #ifndef Fl_Check_Browser_H 00032 #define Fl_Check_Browser_H 00033 00034 #include "Fl.H" 00035 #include "Fl_Browser_.H" 00036 00041 class FL_EXPORT Fl_Check_Browser : public Fl_Browser_ { 00042 /* required routines for Fl_Browser_ subclass: */ 00043 00044 void *item_first() const; 00045 void *item_next(void *) const; 00046 void *item_prev(void *) const; 00047 int item_height(void *) const; 00048 int item_width(void *) const; 00049 void item_draw(void *, int, int, int, int) const; 00050 void item_select(void *, int); 00051 int item_selected(void *) const; 00052 00053 /* private data */ 00054 00055 public: // IRIX 5.3 C++ compiler doesn't support private structures... 00056 00057 #ifndef FL_DOXYGEN 00058 00059 struct cb_item { 00060 cb_item *next; 00061 cb_item *prev; 00062 char checked; 00063 char selected; 00064 char *text; 00065 }; 00066 #endif // !FL_DOXYGEN 00067 00068 private: 00069 00070 cb_item *first; 00071 cb_item *last; 00072 cb_item *cache; 00073 int cached_item; 00074 int nitems_; 00075 int nchecked_; 00076 cb_item *find_item(int) const; 00077 int lineno(cb_item *) const; 00078 00079 public: 00080 00081 Fl_Check_Browser(int x, int y, int w, int h, const char *l = 0); 00083 ~Fl_Check_Browser() { clear(); } 00084 int add(char *s); // add an (unchecked) item 00085 int add(char *s, int b); // add an item and set checked 00086 // both return the new nitems() 00087 int remove(int item); // delete an item. Returns nitems() 00088 00089 // inline const char * methods to avoid breaking binary compatibility... 00091 int add(const char *s) { return add((char *)s); } 00093 int add(const char *s, int b) { return add((char *)s, b); } 00094 00095 void clear(); // delete all items 00100 int nitems() const { return nitems_; } 00102 int nchecked() const { return nchecked_; } 00103 int checked(int item) const; 00104 void checked(int item, int b); 00106 void set_checked(int item) { checked(item, 1); } 00107 void check_all(); 00108 void check_none(); 00109 int value() const; // currently selected item 00110 char *text(int item) const; // returns pointer to internal buffer 00111 00112 protected: 00113 00114 int handle(int); 00115 }; 00116 00117 #endif // Fl_Check_Browser_H 00118 00119 // 00120 // End of "$Id$". 00121 // 00122