Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Fl_Menu_.h

00001 /*
00002  * $Id: Fl_Menu_.h,v 1.17 2003/05/29 23:27:28 leka Exp $
00003  *
00004  * Extended Fast Light Toolkit (EFLTK)
00005  * Copyright (C) 2002-2003 by EDE-Team
00006  * WWW: http://www.sourceforge.net/projects/ede
00007  *
00008  * Fast Light Toolkit (FLTK)
00009  * Copyright (C) 1998-2003 by Bill Spitzak and others.
00010  * WWW: http://www.fltk.org
00011  *
00012  * This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00013  * version 2. See COPYING for details.
00014  *
00015  * Author : Mikko Lahteenmaki
00016  * Email  : mikko@fltk.net
00017  *
00018  * Please report all bugs and problems to "efltk-bugs@fltk.net"
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" // for back compatability,should not be necessary,
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     // Constructors do end()
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     // Undo the overrides of stuff from Fl_Group:
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     // Commented-out methods cannot be emulated.
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     // Set/Get default effect type for all menus
00121     static int default_effect_type() { return default_effect_type_; }
00122     static void default_effect_type(int v) { default_effect_type_ = v; }
00123 
00124     // Effect type, ONLY for this menu
00125     int effect_type() { return effect_type_; }
00126     void effect_type(int v) { effect_type_ = v; }
00127 
00128     // Set/Get default sub-menu delay of all menus
00129     static float default_delay() { return default_delay_; }
00130     static void  default_delay(float v) { default_delay_ = v; }
00131 
00132     // sub-menu delay, ONLY for this menu
00133     float delay() { return delay_; }
00134     void delay(float v) { delay_ = v; }
00135 
00136     // Set/Get default animate speed of all menua
00137     static float default_anim_speed() { return default_anim_speed_; }
00138     static void default_anim_speed(float v) { default_anim_speed_ = v; }
00139 
00140     // Set/Get animate speed, ONLY for this menu
00141     float anim_speed() { return anim_speed_; }
00142     void anim_speed(float v) { anim_speed_ = v; }
00143 
00144     // Are menu effects enabled?
00145     static bool effects() { return effects_; }
00146     static void effects(bool v) { effects_ = v; }
00147 
00148     // Does sub-menus animate, like first menuwindow?
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

Generated on Thu Jul 31 15:33:44 2003 for eFLTK by doxygen1.2.15