FLTK 1.3.0
Fl_Check_Browser.H
1 //
2 // "$Id: Fl_Check_Browser.H 7903 2010-11-28 21:06:39Z matt $"
3 //
4 // Fl_Check_Browser header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2010 by Bill Spitzak and others.
7 //
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.
12 //
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.
17 //
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
21 // USA.
22 //
23 // Please report all bugs and problems on the following page:
24 //
25 // http://www.fltk.org/str.php
26 //
27 
28 /* \file
29  Fl_Check_Browser widget . */
30 
31 #ifndef Fl_Check_Browser_H
32 #define Fl_Check_Browser_H
33 
34 #include "Fl.H"
35 #include "Fl_Browser_.H"
36 
41 class FL_EXPORT Fl_Check_Browser : public Fl_Browser_ {
42  /* required routines for Fl_Browser_ subclass: */
43 
44  void *item_first() const;
45  void *item_next(void *) const;
46  void *item_prev(void *) const;
47  int item_height(void *) const;
48  int item_width(void *) const;
49  void item_draw(void *, int, int, int, int) const;
50  void item_select(void *, int);
51  int item_selected(void *) const;
52 
53  /* private data */
54 
55  public: // IRIX 5.3 C++ compiler doesn't support private structures...
56 
57 #ifndef FL_DOXYGEN
58 
59  struct cb_item {
60  cb_item *next;
61  cb_item *prev;
62  char checked;
63  char selected;
64  char *text;
65  };
66 #endif // !FL_DOXYGEN
67 
68  private:
69 
70  cb_item *first;
71  cb_item *last;
72  cb_item *cache;
73  int cached_item;
74  int nitems_;
75  int nchecked_;
76  cb_item *find_item(int) const;
77  int lineno(cb_item *) const;
78 
79  public:
80 
81  Fl_Check_Browser(int x, int y, int w, int h, const char *l = 0);
84  int add(char *s); // add an (unchecked) item
85  int add(char *s, int b); // add an item and set checked
86  // both return the new nitems()
87  int remove(int item); // delete an item. Returns nitems()
88 
89  // inline const char * methods to avoid breaking binary compatibility...
91  int add(const char *s) { return add((char *)s); }
93  int add(const char *s, int b) { return add((char *)s, b); }
94 
95  void clear(); // delete all items
100  int nitems() const { return nitems_; }
102  int nchecked() const { return nchecked_; }
103  int checked(int item) const;
104  void checked(int item, int b);
106  void set_checked(int item) { checked(item, 1); }
107  void check_all();
108  void check_none();
109  int value() const; // currently selected item
110  char *text(int item) const; // returns pointer to internal buffer
111 
112  protected:
113 
114  int handle(int);
115 };
116 
117 #endif // Fl_Check_Browser_H
118 
119 //
120 // End of "$Id: Fl_Check_Browser.H 7903 2010-11-28 21:06:39Z matt $".
121 //
122