NTK 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
41class 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
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
Fl static class.
This is the base class for browsers.
Definition: Fl_Browser_.H:67
virtual int item_selected(void *item) const
This method must be implemented by the subclass if it supports multiple selections; returns the selec...
Definition: Fl_Browser_.cxx:1103
virtual void * item_next(void *item) const =0
This method must be provided by the subclass to return the item in the list after item.
virtual int item_width(void *item) const =0
This method must be provided by the subclass to return the width of the item in pixels.
virtual int item_height(void *item) const =0
This method must be provided by the subclass to return the height of item in pixels.
int handle(int event)
Handles the event within the normal widget bounding box.
Definition: Fl_Browser_.cxx:699
virtual void * item_prev(void *item) const =0
This method must be provided by the subclass to return the item in the list before item.
virtual void * item_first() const =0
This method must be provided by the subclass to return the first item in the list.
virtual void item_select(void *item, int val=1)
This method must be implemented by the subclass if it supports multiple selections; sets the selectio...
Definition: Fl_Browser_.cxx:1095
virtual void item_draw(void *item, int X, int Y, int W, int H) const =0
This method must be provided by the subclass to draw the item in the area indicated by X,...
void * find_item(int ypos)
This method returns the item under mouse y position ypos.
Definition: Fl_Browser_.cxx:589
The Fl_Check_Browser widget displays a scrolling list of text lines that may be selected and/or check...
Definition: Fl_Check_Browser.H:41
int nchecked() const
Returns how many items are currently checked.
Definition: Fl_Check_Browser.H:102
int nitems() const
Returns how many lines are in the browser.
Definition: Fl_Check_Browser.H:100
int add(const char *s)
See int Fl_Check_Browser::add(char *s)
Definition: Fl_Check_Browser.H:91
~Fl_Check_Browser()
The destructor deletes all list items and destroys the browser.
Definition: Fl_Check_Browser.H:83
void set_checked(int item)
Equivalent to Fl_Check_Browser::checked(item, 1).
Definition: Fl_Check_Browser.H:106
int add(const char *s, int b)
See int Fl_Check_Browser::add(char *s)
Definition: Fl_Check_Browser.H:93
void add(Fl_Widget &)
The widget is removed from its current group (if any) and then added to the end of this group.
Definition: Fl_Group.cxx:494
void clear()
Deletes all child widgets from memory recursively.
Definition: Fl_Group.cxx:386
void remove(int index)
Removes the widget at index from the group but does not delete it.
Definition: Fl_Group.cxx:506