FLTK 1.4.5: Fl_Check_Browser.H Source File

FLTK 1.4.5

Loading...
Searching...
No Matches
Fl_Check_Browser.H
1//
2// Fl_Check_Browser header file for the Fast Light Tool Kit (FLTK).
3//
4// Copyright 1998-2020 by Bill Spitzak and others.
5//
6// This library is free software. Distribution and use rights are outlined in
7// the file "COPYING" which should have been included with this file. If this
8// file is missing or damaged, see the license at:
9//
10// https://www.fltk.org/COPYING.php
11//
12// Please see the following page on how to report bugs and issues:
13//
14// https://www.fltk.org/bugs.php
15//
16
17/* \file
18 Fl_Check_Browser widget . */
19
20#ifndef Fl_Check_Browser_H
21#define Fl_Check_Browser_H
22
23#include "Fl.H"
24#include "Fl_Browser_.H"
25
30 class FL_EXPORT Fl_Check_Browser : public Fl_Browser_ {
31
32protected:
33 /* required routines for Fl_Browser_ subclass: */
34 void *item_first() const FL_OVERRIDE;
35 void *item_next(void *) const FL_OVERRIDE;
36 void *item_prev(void *) const FL_OVERRIDE;
37 int item_height(void *) const FL_OVERRIDE;
38 int item_width(void *) const FL_OVERRIDE;
39 void item_draw(void *, int, int, int, int) const FL_OVERRIDE;
40 void item_select(void *, int) FL_OVERRIDE;
41 int item_selected(void *) const FL_OVERRIDE;
42 const char *item_text(void *item) const FL_OVERRIDE;
43
44public:
45 void *item_at(int index) const FL_OVERRIDE;
46 void item_swap(int ia, int ib);
47 void item_swap(void *a, void *b) FL_OVERRIDE;
48
49 /* private data */
50
51public: // IRIX 5.3 C++ compiler doesn't support private structures...
52
53#ifndef FL_DOXYGEN
55 struct cb_item {
56 cb_item *next;
57 cb_item *prev;
58 char checked;
59 char selected;
60 char *text;
61 };
62#endif // !FL_DOXYGEN
63
64private:
65 cb_item *first;
66 cb_item *last;
67 cb_item *cache;
68 int cached_item;
69 int nitems_;
70 int nchecked_;
71 cb_item *find_item(int) const;
72 int lineno(cb_item *) const;
73
74public:
75 Fl_Check_Browser(int x, int y, int w, int h, const char *l = 0);
77 ~Fl_Check_Browser() { clear(); }
78 int add(char *s); // add an (unchecked) item
79 int add(char *s, int b); // add an item and set checked
80 // both return the new nitems()
81 int remove(int item); // delete an item. Returns nitems()
82
83 // inline const char * methods to avoid breaking binary compatibility...
85 int add(const char *s) { return add((char *)s); }
87 int add(const char *s, int b) { return add((char *)s, b); }
88
89 void clear(); // delete all items
94 int nitems() const { return nitems_; }
96 int nchecked() const { return nchecked_; }
97 int checked(int item) const;
98 void checked(int item, int b);
100 void set_checked(int item) { checked(item, 1); }
101 void check_all();
102 void check_none();
103 int value() const; // currently selected item
104 char *text(int item) const; // returns pointer to internal buffer
105
106protected:
107 int handle(int) FL_OVERRIDE;
108};
109
110#endif // Fl_Check_Browser_H
Fl.H
Fl static class.
Fl_Browser_::item_selected
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:1101
Fl_Browser_::item_next
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.
Fl_Browser_::item_width
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.
Fl_Browser_::item_at
virtual void * item_at(int index) const
This method must be provided by the subclass to return the item for the specified index.
Definition Fl_Browser_.H:171
Fl_Browser_::item_swap
virtual void item_swap(void *a, void *b)
This optional method should be provided by the subclass to efficiently swap browser items a and b,...
Definition Fl_Browser_.H:164
Fl_Browser_::item_height
virtual int item_height(void *item) const =0
This method must be provided by the subclass to return the height of item in pixels.
Fl_Browser_::Fl_Browser_
Fl_Browser_(int X, int Y, int W, int H, const char *L=0)
The constructor makes an empty browser.
Definition Fl_Browser_.cxx:954
Fl_Browser_::item_prev
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.
Fl_Browser_::item_first
virtual void * item_first() const =0
This method must be provided by the subclass to return the first item in the list.
Fl_Browser_::item_select
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:1093
Fl_Browser_::item_draw
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,...
Fl_Browser_::handle
int handle(int event) FL_OVERRIDE
Handles the event within the normal widget bounding box.
Definition Fl_Browser_.cxx:692
Fl_Browser_::find_item
void * find_item(int ypos)
This method returns the item under mouse y position ypos.
Definition Fl_Browser_.cxx:582
Fl_Browser_::item_text
virtual const char * item_text(void *item) const
This optional method returns a string (label) that may be used for sorting.
Definition Fl_Browser_.H:158
Fl_Check_Browser::nchecked
int nchecked() const
Returns how many items are currently checked.
Definition Fl_Check_Browser.H:96
Fl_Check_Browser::checked
int checked(int item) const
Gets the current status of item item.
Definition Fl_Check_Browser.cxx:319
Fl_Check_Browser::text
char * text(int item) const
Return a pointer to an internal buffer holding item item's text.
Definition Fl_Check_Browser.cxx:347
Fl_Check_Browser::nitems
int nitems() const
Returns how many lines are in the browser.
Definition Fl_Check_Browser.H:94
Fl_Check_Browser::add
int add(const char *s)
See int Fl_Check_Browser::add(char *s).
Definition Fl_Check_Browser.H:85
Fl_Check_Browser::Fl_Check_Browser
Fl_Check_Browser(int x, int y, int w, int h, const char *l=0)
The constructor makes an empty browser.
Definition Fl_Check_Browser.cxx:77
Fl_Check_Browser::~Fl_Check_Browser
~Fl_Check_Browser()
The destructor deletes all list items and destroys the browser.
Definition Fl_Check_Browser.H:77
Fl_Check_Browser::set_checked
void set_checked(int item)
Equivalent to Fl_Check_Browser::checked(item, 1).
Definition Fl_Check_Browser.H:100
Fl_Check_Browser::add
int add(const char *s, int b)
See int Fl_Check_Browser::add(char *s).
Definition Fl_Check_Browser.H:87
Fl_Group::add
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:560
Fl_Group::clear
void clear()
Deletes all child widgets from memory recursively.
Definition Fl_Group.cxx:381
Fl_Group::remove
void remove(int index)
Removes the widget at index from the group but does not delete it.
Definition Fl_Group.cxx:585
Fl_Widget::x
void x(int v)
Internal use only.
Definition Fl_Widget.H:150
Fl_Widget::w
void w(int v)
Internal use only.
Definition Fl_Widget.H:154
Fl_Widget::y
void y(int v)
Internal use only.
Definition Fl_Widget.H:152
Fl_Widget::h
void h(int v)
Internal use only.
Definition Fl_Widget.H:156
FL_OVERRIDE
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46