FLTK 1.4.4

Loading...
Searching...
No Matches
Fl_Menu_.H
1//
2// Menu base class header file for the Fast Light Tool Kit (FLTK).
3//
4// Copyright 1998-2024 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_Menu_ widget . */
19
20#ifndef Fl_Menu__H
21#define Fl_Menu__H
22
23#ifndef Fl_Widget_H
24#include "Fl_Widget.H"
25#endif
26#include "Fl_Menu_Item.H"
27
53 class FL_EXPORT Fl_Menu_ : public Fl_Widget {
54
55 Fl_Menu_Item *menu_;
56 const Fl_Menu_Item *value_;
57 const Fl_Menu_Item *prev_value_;
58
59 protected:
60
61 uchar alloc; // flag indicates if menu_ is a dynamic copy (=1) or not (=0)
62 uchar down_box_;
63 Fl_Boxtype menu_box_;
64 Fl_Font textfont_;
65 Fl_Fontsize textsize_;
66 Fl_Color textcolor_;
67
68 int item_pathname_(char *name, int namelen, const Fl_Menu_Item *finditem,
69 const Fl_Menu_Item *menu=0) const;
70 public:
71 Fl_Menu_(int,int,int,int,const char * =0);
72 ~Fl_Menu_();
73
74 int item_pathname(char *name, int namelen, const Fl_Menu_Item *finditem=0) const;
75 const Fl_Menu_Item* picked(const Fl_Menu_Item*);
76 const Fl_Menu_Item* find_item(const char *name);
77 const Fl_Menu_Item* find_item(Fl_Callback*);
78 const Fl_Menu_Item* find_item_with_user_data(void*);
79 const Fl_Menu_Item* find_item_with_argument(long);
80 int find_index(const char *name) const;
81 int find_index(const Fl_Menu_Item *item) const;
82 int find_index(Fl_Callback *cb) const;
83
95 const Fl_Menu_Item* test_shortcut() {return picked(menu()->test_shortcut());}
96 void global();
97
133 const Fl_Menu_Item *menu() const {return menu_;}
134 const Fl_Menu_Item *menu_end(); // in src/Fl_Menu_add.cxx
135 void menu(const Fl_Menu_Item *m);
136 void copy(const Fl_Menu_Item *m, void* user_data = 0);
137 int insert(int index, const char*, int shortcut, Fl_Callback*, void* = 0, int = 0);
138 int add(const char*, int shortcut, Fl_Callback*, void* = 0, int = 0); // see src/Fl_Menu_add.cxx
140 int add(const char* a, const char* b, Fl_Callback* c, void* d = 0, int e = 0) {
141 return add(a,fl_old_shortcut(b),c,d,e);
142 }
143
144 int insert(int index, const char* a, const char* b, Fl_Callback* c, void* d = 0, int e = 0) {
145 return insert(index,a,fl_old_shortcut(b),c,d,e);
146 }
147 int add(const char *);
148 int size() const ;
149 void size(int W, int H) { Fl_Widget::size(W, H); }
150 void clear();
151 int clear_submenu(int index);
152 void replace(int,const char *);
153 void remove(int);
155 void shortcut(int i, int s) {menu_[i].shortcut(s);}
157 void mode(int i,int fl) {menu_[i].flags = fl;}
159 int mode(int i) const {return menu_[i].flags;}
160
162 const Fl_Menu_Item *mvalue() const {return value_;}
163
167 const Fl_Menu_Item *prev_mvalue() const {return prev_value_;}
168 // Return the index into the menu() of the last item chosen by the user or -1.
169 int value() const;
170 // Set the internal value_ of the menu to the given Fl_Menu_Item.
171 int value(const Fl_Menu_Item*);
205 int value(int i) {
206 if (!menu_ || i < 0 || i >= size())
207 return 0;
208 return value(menu_ + i);
209 }
210
212 const char *text() const {return value_ ? value_->text : 0;}
214 const char *text(int i) const {return menu_[i].text;}
215
217 Fl_Font textfont() const {return textfont_;}
219 void textfont(Fl_Font c) {textfont_=c;}
221 Fl_Fontsize textsize() const {return textsize_;}
223 void textsize(Fl_Fontsize c) {textsize_=c;}
225 Fl_Color textcolor() const {return textcolor_;}
227 void textcolor(Fl_Color c) {textcolor_=c;}
228
233 Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;}
235 void down_box(Fl_Boxtype b) {down_box_ = b;}
236
240 Fl_Boxtype menu_box() const { return menu_box_; }
245 void menu_box(Fl_Boxtype b) { menu_box_ = b; }
246
248 Fl_Color down_color() const {return selection_color();}
250 void down_color(unsigned c) {selection_color(c);}
251 void setonly(Fl_Menu_Item* item);
252};
253
254#endif
Fl_Font
int Fl_Font
A font number is an index into the internal font table.
Definition Enumerations.H:1063
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition Enumerations.H:1120
Fl_Fontsize
int Fl_Fontsize
Size of a font in pixels.
Definition Enumerations.H:1092
Fl_Boxtype
Fl_Boxtype
FLTK standard box types.
Definition Enumerations.H:644
Fl_Widget.H
Fl_Widget and Fl_Label classes.
Fl_Callback
void Fl_Callback(Fl_Widget *, void *)
Default callback type definition for all fltk widgets (by far the most used)
Definition Fl_Widget.H:33
Fl_Widget::selection_color
Fl_Color selection_color() const
Gets the selection color.
Definition Fl_Widget.H:473
Fl_Widget::size
void size(int W, int H)
Changes the size of the widget.
Definition Fl_Widget.H:418
uchar
unsigned char uchar
unsigned char
Definition fl_types.h:30