edelib: edelib/MenuBase.h Source File

edelib 1.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List

MenuBase.h
1 //
2 // "$Id: MenuBase.h 2839 2009-09-28 11:36:20Z karijes $"
3 //
4 // Menu base class header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2005 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 #ifndef __EDELIB_MENUBASE_H__
24 #define __EDELIB_MENUBASE_H__
25
26 #include "edelib-global.h"
27
28 #include <FL/Fl_Widget.H>
29 #include "MenuItem.h"
30
31 EDELIB_NS_BEGIN
32
39 class EDELIB_API MenuBase : public Fl_Widget {
40 private:
41 MenuItem *menu_;
42 const MenuItem *value_;
43
44 protected:
45 #ifndef SKIP_DOCS
46 uchar alloc;
47 uchar down_box_;
48 uchar textfont_;
49 uchar textsize_;
50 unsigned textcolor_;
51 #endif
52
53 public:
54 #ifndef SKIP_DOCS
55 MenuBase(int,int,int,int,const char * =0);
56 ~MenuBase();
57
58 int item_pathname(char *name, int namelen, const MenuItem *finditem=0) const;
59 const MenuItem* picked(const MenuItem*);
60 const MenuItem* find_item(const char *name);
61
62 const MenuItem* test_shortcut() {return picked(menu()->test_shortcut());}
63 void global();
64
65 const MenuItem *menu() const {return menu_;}
66 void menu(const MenuItem *m);
67 void copy(const MenuItem *m, void* user_data = 0);
68 int add(const char*, int shortcut, Fl_Callback*, void* = 0, int = 0);
69 int add(const char* a, const char* b, Fl_Callback* c,
70 void* d = 0, int e = 0) {return add(a,fl_old_shortcut(b),c,d,e);}
71 int size() const ;
72 void size(int W, int H) { Fl_Widget::size(W, H); }
73 void clear();
74 int add(const char *);
75 void replace(int,const char *);
76 void remove(int);
77 void shortcut(int i, int s) {menu_[i].shortcut(s);}
78 void mode(int i,int fl) {menu_[i].flags = fl;}
79 int mode(int i) const {return menu_[i].flags;}
80
81 const MenuItem *mvalue() const {return value_;}
82 int value() const {return value_ ? (int)(value_-menu_) : -1;}
83 int value(const MenuItem*);
84 int value(int i) {return value(menu_+i);}
85 const char *text() const {return value_ ? value_->text : 0;}
86 const char *text(int i) const {return menu_[i].text;}
87
88 Fl_Font textfont() const {return (Fl_Font)textfont_;}
89 void textfont(uchar c) {textfont_=c;}
90 uchar textsize() const {return textsize_;}
91 void textsize(uchar c) {textsize_=c;}
92 Fl_Color textcolor() const {return (Fl_Color)textcolor_;}
93 void textcolor(unsigned c) {textcolor_=c;}
94
95 Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;}
96 void down_box(Fl_Boxtype b) {down_box_ = b;}
97
98 // back compatability:
99 Fl_Color down_color() const {return selection_color();}
100 void down_color(unsigned c) {selection_color(c);}
101 #endif
102 };
103
104 EDELIB_NS_END
105 #endif
edelib::MenuItem
The item in menu list.
Definition: MenuItem.h:46
edelib::MenuBase
Menu base class.
Definition: MenuBase.h:39