source: NonGTP/include/FL/Fl_Menu_Item.H @ 769

Revision 769, 5.7 KB checked in by gumbau, 18 years ago (diff)

FLTK imported to SVN repository to be linked agains the GeoTool? application

Line 
1//
2// "$Id: Fl_Menu_Item.H 2918 2003-01-19 07:55:01Z spitzak $"
3//
4// Back-compatability menu items for FLTK.  The new fltk::Menu class
5// converts these tables into child fltk::Item and fltk::ItemGroup widgets.
6// You should not use this for new programs.
7//
8// Copyright 1998-2000 by Bill Spitzak and others.
9//
10// This library is free software; you can redistribute it and/or
11// modify it under the terms of the GNU Library General Public
12// License as published by the Free Software Foundation; either
13// version 2 of the License, or (at your option) any later version.
14//
15// This library is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18// Library General Public License for more details.
19//
20// You should have received a copy of the GNU Library General Public
21// License along with this library; if not, write to the Free Software
22// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23// USA.
24//
25// Please report all bugs and problems to "fltk-bugs@fltk.org".
26//
27
28#ifndef Fl_Menu_Item_h
29#define Fl_Menu_Item_h
30
31#include <fltk/Widget.h>
32
33enum { // values for flags:
34  FL_MENU_INACTIVE = 1,
35  FL_MENU_TOGGLE= 2,
36  FL_MENU_VALUE = 4,
37  FL_MENU_RADIO = 8,
38  FL_MENU_INVISIBLE = 0x10,
39  FL_SUBMENU_POINTER = 0x20,
40  FL_SUBMENU = 0x40,
41  FL_MENU_DIVIDER = 0x80,
42  FL_MENU_HORIZONTAL = 0x100 // not used!
43};
44
45namespace fltk {
46  class FL_API Menu;
47}
48
49struct FL_API Fl_Menu_Item {
50  const char *text;
51  int shortcut_;
52  fltk::Callback *callback_;
53  void *user_data_;
54  int flags;
55  fltk::LabelType* labeltype_;
56  fltk::Font* labelfont_;
57  unsigned labelsize_;
58  fltk::Color labelcolor_;
59
60  // Used to add or set an fltk::Menu widget:
61  void add_to(fltk::Menu*, void* data = 0) const;
62
63  // popup menus without using an fltk::Menu widget:
64  // Warning: this is now quite expensive, as it creates a temporary
65  // fltk::Menu and child widgets!  These also do not match the fltk 1.0
66  // calls, if there is any callback it is called directly (with the
67  // dummy fltk::Menu as an argument).
68  const Fl_Menu_Item*
69        pulldown(int X, int Y, int W, int H,
70                 const Fl_Menu_Item* picked = 0,
71                 const char* title = 0) const;
72  const Fl_Menu_Item*
73        popup(int X, int Y, const char* title=0,
74              const Fl_Menu_Item* picked = 0) const {
75    return pulldown(X, Y, 0, 0, picked, title);}
76  const Fl_Menu_Item*
77        test_shortcut() const;
78
79  // return offset of terminating null item:
80  int size() const ;
81
82  // advance a pointer by N items, skipping submenus:
83  const Fl_Menu_Item *next(int=1) const;
84  Fl_Menu_Item *next(int i=1) {
85    return (Fl_Menu_Item*)(((const Fl_Menu_Item*)this)->next(i));}
86
87  const char* label() const {return text;}
88  fltk::LabelType* labeltype() const {return labeltype_;}
89  fltk::Color labelcolor() const {return labelcolor_;}
90  fltk::Font* labelfont() const {return labelfont_;}
91  unsigned labelsize() const {return labelsize_;}
92  fltk::Callback_p callback() const {return callback_;}
93  void* user_data() const {return user_data_;}
94  long argument() const {return (long)user_data_;}
95  int shortcut() const {return shortcut_;}
96  int submenu() const {return flags&(FL_SUBMENU|FL_SUBMENU_POINTER);}
97  int checkbox() const {return flags&FL_MENU_TOGGLE;}
98  int radio() const {return flags&FL_MENU_RADIO;}
99  int value() const {return flags&FL_MENU_VALUE;}
100  int visible() const {return !(flags&FL_MENU_INVISIBLE);}
101  int active() const {return !(flags&FL_MENU_INACTIVE);}
102  int activevisible() const {return !(flags&0x11);}
103
104  void label(const char* a) {text=a;}
105  void label(fltk::LabelType* a,const char* b) {labeltype_ = a; text = b;}
106  void labeltype(fltk::LabelType* a) {labeltype_ = a;}
107  void labelcolor(uchar a) {labelcolor_ = a;}
108  void labelfont(fltk::Font* a) {labelfont_ = a;}
109  void labelsize(uchar a) {labelsize_ = a;}
110  void callback(fltk::Callback* c, void* p) {callback_=c; user_data_=p;}
111  void callback(fltk::Callback* c) {callback_=c;}
112  void callback(fltk::Callback0*c) {callback_=(fltk::Callback*)c;}
113  void callback(fltk::Callback1*c, long p=0) {callback_=(fltk::Callback*)c; user_data_=(void*)p;}
114  void user_data(void* v) {user_data_ = v;}
115  void argument(long v) {user_data_ = (void*)v;}
116  void shortcut(int s) {shortcut_ = s;}
117  void set() {flags |= FL_MENU_VALUE;}
118  void clear() {flags &= ~FL_MENU_VALUE;}
119  void setonly();
120  void show() {flags &= ~FL_MENU_INVISIBLE;}
121  void hide() {flags |= FL_MENU_INVISIBLE;}
122  void activate() {flags &= ~FL_MENU_INACTIVE;}
123  void deactivate() {flags |= FL_MENU_INACTIVE;}
124
125  const Fl_Menu_Item* find_shortcut(int *ip=0) const;
126
127  void do_callback(fltk::Widget* o) const {callback_(o, user_data_);}
128  void do_callback(fltk::Widget* o,void* arg) const {callback_(o, arg);}
129  void do_callback(fltk::Widget* o,long arg) const {callback_(o, (void*)arg);}
130
131  // back-compatability, do not use:
132  int checked() const {return flags&FL_MENU_VALUE;}
133  void check() {flags |= FL_MENU_VALUE;}
134  void uncheck() {flags &= ~FL_MENU_VALUE;}
135
136#if 0
137  int add(const char*, int shortcut, fltk::Callback*, void* =0, int = 0);
138  int add(const char*a, const char* b, fltk::Callback* c,
139          void* d = 0, int e = 0) {
140    return add(a,fltk::old_shortcut(b),c,d,e);}
141#endif
142};
143
144typedef Fl_Menu_Item Fl_Menu; // back compatability with fltk < 1.0
145
146enum {  // back-compatability enum:
147  FL_PUP_NONE   = 0,
148  FL_PUP_GREY   = FL_MENU_INACTIVE,
149  FL_PUP_GRAY   = FL_MENU_INACTIVE,
150  FL_MENU_BOX   = FL_MENU_TOGGLE,
151  FL_PUP_BOX    = FL_MENU_TOGGLE,
152  FL_MENU_CHECK = FL_MENU_VALUE,
153  FL_PUP_CHECK  = FL_MENU_VALUE,
154  FL_PUP_RADIO  = FL_MENU_RADIO,
155  FL_PUP_INVISIBLE = FL_MENU_INVISIBLE,
156  FL_PUP_SUBMENU = FL_SUBMENU_POINTER
157};
158
159#endif
160
161//
162// End of "$Id: Fl_Menu_Item.H 2918 2003-01-19 07:55:01Z spitzak $".
163//
Note: See TracBrowser for help on using the repository browser.