00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _FL_MENU_H_
00023 #define _FL_MENU_H_
00024
00025 #include "Fl_Group.h"
00026 #include "Fl_Menu_Item.h"
00027
00028 #define MAX_LEVELS 64
00029
00030 class MenuWindow;
00031 class FL_API Fl_Menu_;
00032
00033 class FL_API Fl_List {
00034 public:
00035 virtual int children(const Fl_Menu_*, const int* indexes, int level);
00036 virtual Fl_Widget* child(const Fl_Menu_*, const int* indexes, int level);
00037 virtual void flags_changed(const Fl_Menu_*, Fl_Widget*);
00038 };
00039
00041 class FL_API Fl_Menu_ : public Fl_Group {
00042 public:
00043
00045 Fl_Menu_();
00047 Fl_Menu_(int,int,int,int, const char* l=0);
00049 Fl_Menu_(const char* l,int layout_size=30,Fl_Align layout_al=FL_ALIGN_TOP,int label_w=-1);
00050
00051 Fl_Callback *about_to_show;
00052 Fl_Callback *about_to_hide;
00053
00054 Fl_List* list() const {return list_;}
00055 void list(Fl_List* l) {list_ = l;}
00056
00057 int children(const int* indexes, int level) const ;
00058 int children() const ;
00059 Fl_Widget* child(const int* indexes, int level) const ;
00060 Fl_Widget* child(int index) const ;
00061 Fl_Widget* item() const {return item_;}
00062 Fl_Widget* item(Fl_Widget* v) {return item_ = v;}
00063 bool focus(const int* indexes, int level);
00064 Fl_Widget* get_focus();
00065
00066 int value() const {return Fl_Group::focus();}
00067 void value(int v) {Fl_Group::focus(v);}
00068 int size() const {return children();}
00069
00070 virtual int popup(int x,int y,int w=0,int h=0);
00071 int handle_shortcut();
00072 static void default_callback(Fl_Widget*, void*);
00073 void execute(Fl_Widget*);
00074 void global();
00075
00076 Fl_Widget* find(const char* label) const;
00077 Fl_Widget* add(const char*, int shortcut, Fl_Callback*, void* = 0, int = 0);
00078 Fl_Widget* replace(const char*, int scut, Fl_Callback*, void* = 0, int = 0);
00079 Fl_Widget* add(const char*, void*);
00080 Fl_Widget* add(const char*);
00081 Fl_Widget* insert(int n, const char* s, void* data = 0);
00082 void remove(const char* l) { delete find(l); }
00083
00084
00085 void add(Fl_Widget& o) {Fl_Group::add(o);}
00086 void add(Fl_Widget* o) {add(*o);}
00087 void insert(Fl_Widget& o, int n) {Fl_Group::insert(o, n);}
00088 void replace(int index, Fl_Widget& o) {Fl_Group::replace(index, o);}
00089 void replace(Fl_Widget& old, Fl_Widget& o) {Fl_Group::replace(old,o);}
00090 void remove(int index) {Fl_Group::remove(index);}
00091 void remove(Fl_Widget& o) {Fl_Group::remove(o);}
00092 void remove(Fl_Widget* o) {Fl_Group::remove(o);}
00093
00094 enum {
00095 TOP_TO_BOTTOM=1,
00096 BOTTOM_TO_TOP=2,
00097 LEFT_TO_RIGHT=4,
00098 RIGHT_TO_LEFT=8
00099 };
00100 void anim_flags(int f) { anim_flags_ = f; }
00101 int anim_flags() { return anim_flags_; }
00102
00103 #ifndef FLTK_2
00104
00105 void copy(const Fl_Menu_Item* m, void* data = 0) { clear(); m->add_to(this,data); }
00106 void menu(const Fl_Menu_Item* m) { copy(m,0); }
00107 void replace(int n, const char* s) { child(n)->label(s); }
00108 void replace(const char* l, const char* s) { find(l)->label(s); }
00109 void shortcut(const char* l, int s) { find(l)->shortcut(s); }
00110 void shortcut(int s) {Fl_Widget::shortcut(s);}
00111 int shortcut() const {return Fl_Widget::shortcut();}
00112 void shortcut(int i, int s) { child(i)->shortcut(s); }
00113 unsigned mode(int i) const {return child(i)->flags() >> 8;}
00114 unsigned mode(const char* l) const {return find(l)->flags() >> 8;}
00115
00116 const Fl_String &text(int i) const { return child(i)->label(); }
00117 const Fl_String &text() const { Fl_Widget* w = item(); return w ? w->label() : Fl_String::null_object; }
00118 #endif
00119
00120
00121 static int default_effect_type() { return default_effect_type_; }
00122 static void default_effect_type(int v) { default_effect_type_ = v; }
00123
00124
00125 int effect_type() { return effect_type_; }
00126 void effect_type(int v) { effect_type_ = v; }
00127
00128
00129 static float default_delay() { return default_delay_; }
00130 static void default_delay(float v) { default_delay_ = v; }
00131
00132
00133 float delay() { return delay_; }
00134 void delay(float v) { delay_ = v; }
00135
00136
00137 static float default_anim_speed() { return default_anim_speed_; }
00138 static void default_anim_speed(float v) { default_anim_speed_ = v; }
00139
00140
00141 float anim_speed() { return anim_speed_; }
00142 void anim_speed(float v) { anim_speed_ = v; }
00143
00144
00145 static bool effects() { return effects_; }
00146 static void effects(bool v) { effects_ = v; }
00147
00148
00149 static bool subwindow_effect() { return subwindow_effect_; }
00150 static void subwindow_effect(bool v) { subwindow_effect_ = v; }
00151
00152 private:
00153 friend class MenuWindow;
00154 Fl_List* list_;
00155
00156 static float default_delay_;
00157 float delay_;
00158
00159 static bool effects_;
00160 static bool subwindow_effect_;
00161
00162 static int default_effect_type_;
00163 int effect_type_;
00164
00165 static float default_anim_speed_;
00166 float anim_speed_;
00167
00168 void ctor_init();
00169
00170 protected:
00171 static bool key_event;
00172
00173 Fl_Widget *item_;
00174 int anim_flags_;
00175 };
00176
00177 #endif