00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __EDELIB_MENUITEM_H__
00024 #define __EDELIB_MENUITEM_H__
00025
00026 #include "edelib-global.h"
00027
00028 #include <FL/Fl_Widget.H>
00029 #include <FL/Fl_Image.H>
00030 #include <FL/Fl_Menu_Item.H>
00031
00032 #if defined(__APPLE__) && defined(check)
00033 # undef check
00034 #endif
00035
00036 EDELIB_NS_BEGIN
00037
00038 class MenuBase;
00039
00046 struct EDELIB_API MenuItem {
00047 #ifndef SKIP_DOCS
00048 const char *text;
00049 int shortcut_;
00050 Fl_Callback *callback_;
00051 void *user_data_;
00052 int flags;
00053 uchar labeltype_;
00054 uchar labelfont_;
00055 uchar labelsize_;
00056 unsigned labelcolor_;
00057
00058
00059
00060 Fl_Image *image_;
00061
00062
00063 const MenuItem *next(int=1) const;
00064 MenuItem *next(int i=1) { return (MenuItem*)(((const MenuItem*)this)->next(i)); }
00065 const MenuItem *first() const { return next(0); }
00066 MenuItem *first() { return next(0); }
00067
00068
00069 const char* label() const {return text;}
00070 void label(const char* a) {text=a;}
00071 void label(Fl_Labeltype a,const char* b) {labeltype_ = a; text = b;}
00072 Fl_Labeltype labeltype() const {return (Fl_Labeltype)labeltype_;}
00073 void labeltype(Fl_Labeltype a) {labeltype_ = a;}
00074 Fl_Color labelcolor() const {return (Fl_Color)labelcolor_;}
00075 void labelcolor(unsigned a) {labelcolor_ = a;}
00076 Fl_Font labelfont() const {return (Fl_Font)labelfont_;}
00077 void labelfont(uchar a) {labelfont_ = a;}
00078 uchar labelsize() const {return labelsize_;}
00079 void labelsize(uchar a) {labelsize_ = a;}
00080 Fl_Callback_p callback() const {return callback_;}
00081 void callback(Fl_Callback* c, void* p) {callback_=c; user_data_=p;}
00082 void callback(Fl_Callback* c) {callback_=c;}
00083 void callback(Fl_Callback0*c) {callback_=(Fl_Callback*)c;}
00084 void callback(Fl_Callback1*c, long p=0) {callback_=(Fl_Callback*)c; user_data_=(void*)p;}
00085 void* user_data() const {return user_data_;}
00086 void user_data(void* v) {user_data_ = v;}
00087 long argument() const {return (long)user_data_;}
00088 void argument(long v) {user_data_ = (void*)v;}
00089 int shortcut() const {return shortcut_;}
00090 void shortcut(int s) {shortcut_ = s;}
00091 int submenu() const {return flags&(FL_SUBMENU|FL_SUBMENU_POINTER);}
00092 int checkbox() const {return flags&FL_MENU_TOGGLE;}
00093 int radio() const {return flags&FL_MENU_RADIO;}
00094 int value() const {return flags&FL_MENU_VALUE;}
00095 void set() {flags |= FL_MENU_VALUE;}
00096 void clear() {flags &= ~FL_MENU_VALUE;}
00097 void setonly();
00098 int visible() const {return !(flags&FL_MENU_INVISIBLE);}
00099 void show() {flags &= ~FL_MENU_INVISIBLE;}
00100 void hide() {flags |= FL_MENU_INVISIBLE;}
00101 int active() const {return !(flags&FL_MENU_INACTIVE);}
00102 void activate() {flags &= ~FL_MENU_INACTIVE;}
00103 void deactivate() {flags |= FL_MENU_INACTIVE;}
00104 int activevisible() const {return !(flags&0x11);}
00105
00106
00107 void image(Fl_Image* a) { image_ = a; }
00108 void image(Fl_Image& a) { image_ = &a; }
00109 Fl_Image* image() const { return image_; }
00110
00111
00112 int measure(int* h, const MenuBase*) const;
00113 void draw(int x, int y, int w, int h, const MenuBase*, int t=0, int label_gap=0) const;
00114
00115
00116 const MenuItem* popup(
00117 int X, int Y,
00118 const char *title = 0,
00119 const MenuItem* picked=0,
00120 const MenuBase* = 0) const;
00121
00122 const MenuItem* pulldown(
00123 int X, int Y, int W, int H,
00124 const MenuItem* picked = 0,
00125 const MenuBase* = 0,
00126 const MenuItem* title = 0,
00127 int menubar=0) const;
00128
00129 const MenuItem* test_shortcut() const;
00130 const MenuItem* find_shortcut(int *ip=0) const;
00131
00132 void do_callback(Fl_Widget* o) const {callback_(o, user_data_);}
00133 void do_callback(Fl_Widget* o,void* arg) const {callback_(o, arg);}
00134 void do_callback(Fl_Widget* o,long arg) const {callback_(o, (void*)arg);}
00135
00136
00137 int checked() const {return flags&FL_MENU_VALUE;}
00138 void check() {flags |= FL_MENU_VALUE;}
00139 void uncheck() {flags &= ~FL_MENU_VALUE;}
00140 int add(const char*, int shortcut, Fl_Callback*, void* =0, int = 0);
00141 int add(const char*a, const char* b, Fl_Callback* c, void* d = 0, int e = 0) { return add(a,fl_old_shortcut(b),c,d,e); }
00142 int size() const ;
00143 #endif
00144 };
00145
00146 EDELIB_NS_END
00147 #endif