23 #ifndef __EDELIB_MENUITEM_H__
24 #define __EDELIB_MENUITEM_H__
26 #include "edelib-global.h"
28 #include <FL/Fl_Widget.H>
29 #include <FL/Fl_Image.H>
30 #include <FL/Fl_Menu_Item.H>
32 #if defined(__APPLE__) && defined(check)
50 Fl_Callback *callback_;
66 static void init_extensions(
MenuItem *i) {
74 const MenuItem *first()
const {
return next(0); }
75 MenuItem *first() {
return next(0); }
78 const char* label()
const {
return text;}
79 void label(
const char* a) {text=a;}
80 void label(Fl_Labeltype a,
const char* b) {labeltype_ = a; text = b;}
81 Fl_Labeltype labeltype()
const {
return (Fl_Labeltype)labeltype_;}
82 void labeltype(Fl_Labeltype a) {labeltype_ = a;}
83 Fl_Color labelcolor()
const {
return (Fl_Color)labelcolor_;}
84 void labelcolor(
unsigned a) {labelcolor_ = a;}
85 Fl_Font labelfont()
const {
return (Fl_Font)labelfont_;}
86 void labelfont(uchar a) {labelfont_ = a;}
87 uchar labelsize()
const {
return labelsize_;}
88 void labelsize(uchar a) {labelsize_ = a;}
89 Fl_Callback_p callback()
const {
return callback_;}
90 void callback(Fl_Callback* c,
void* p) {callback_=c; user_data_=p;}
91 void callback(Fl_Callback* c) {callback_=c;}
92 void callback(Fl_Callback0*c) {callback_=(Fl_Callback*)c;}
93 void callback(Fl_Callback1*c,
long p=0) {callback_=(Fl_Callback*)c; user_data_=(
void*)p;}
94 void* user_data()
const {
return user_data_;}
95 void user_data(
void* v) {user_data_ = v;}
96 long argument()
const {
return (
long)user_data_;}
97 void argument(
long v) {user_data_ = (
void*)v;}
98 int shortcut()
const {
return shortcut_;}
99 void shortcut(
int s) {shortcut_ = s;}
100 int submenu()
const {
return flags&(FL_SUBMENU|FL_SUBMENU_POINTER);}
101 int checkbox()
const {
return flags&FL_MENU_TOGGLE;}
102 int radio()
const {
return flags&FL_MENU_RADIO;}
103 int value()
const {
return flags&FL_MENU_VALUE;}
104 void set() {flags |= FL_MENU_VALUE;}
105 void clear() {flags &= ~FL_MENU_VALUE;}
107 int visible()
const {
return !(flags&FL_MENU_INVISIBLE);}
108 void show() {flags &= ~FL_MENU_INVISIBLE;}
109 void hide() {flags |= FL_MENU_INVISIBLE;}
110 int active()
const {
return !(flags&FL_MENU_INACTIVE);}
111 void activate() {flags &= ~FL_MENU_INACTIVE;}
112 void deactivate() {flags |= FL_MENU_INACTIVE;}
113 int activevisible()
const {
return !(flags&0x11);}
116 void image(Fl_Image* a) { image_ = a; }
117 void image(Fl_Image& a) { image_ = &a; }
118 Fl_Image* image()
const {
return image_; }
119 void tooltip(
const char* t) { tooltip_ = t; }
120 const char* tooltip()
const {
return tooltip_; }
123 int measure(
int* h,
const MenuBase*)
const;
124 void draw(
int x,
int y,
int w,
int h,
const MenuBase*,
int t=0,
int label_gap=0)
const;
129 const char *title = 0,
134 int X,
int Y,
int W,
int H,
138 int menubar=0)
const;
140 const MenuItem* test_shortcut()
const;
141 const MenuItem* find_shortcut(
int *ip=0)
const;
143 void do_callback(Fl_Widget* o)
const {callback_(o, user_data_);}
144 void do_callback(Fl_Widget* o,
void* arg)
const {callback_(o, arg);}
145 void do_callback(Fl_Widget* o,
long arg)
const {callback_(o, (
void*)arg);}
148 int checked()
const {
return flags&FL_MENU_VALUE;}
149 void check() {flags |= FL_MENU_VALUE;}
150 void uncheck() {flags &= ~FL_MENU_VALUE;}
151 int add(
const char*,
int shortcut, Fl_Callback*,
void* =0,
int = 0);
152 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); }