FLTK 1.3.0
Fl_Menu_.H
00001 //
00002 // "$Id$"
00003 //
00004 // Menu base class header file for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2010 by Bill Spitzak and others.
00007 //
00008 // This library is free software. Distribution and use rights are outlined in
00009 // the file "COPYING" which should have been included with this file.  If this
00010 // file is missing or damaged, see the license at:
00011 //
00012 //     http://www.fltk.org/COPYING.php
00013 //
00014 // Please report all bugs and problems on the following page:
00015 //
00016 //     http://www.fltk.org/str.php
00017 //
00018 
00019 /* \file
00020    Fl_Menu_ widget . */
00021 
00022 #ifndef Fl_Menu__H
00023 #define Fl_Menu__H
00024 
00025 #ifndef Fl_Widget_H
00026 #include "Fl_Widget.H"
00027 #endif
00028 #include "Fl_Menu_Item.H"
00029 
00039 class FL_EXPORT Fl_Menu_ : public Fl_Widget {
00040 
00041   Fl_Menu_Item *menu_;
00042   const Fl_Menu_Item *value_;
00043 
00044 protected:
00045 
00046   uchar alloc;                  // flag indicates if menu_ is a dynamic copy (=1) or not (=0)
00047   uchar down_box_;
00048   Fl_Font textfont_;
00049   Fl_Fontsize textsize_;
00050   Fl_Color textcolor_;
00051 
00052 public:
00053   Fl_Menu_(int,int,int,int,const char * =0);
00054   ~Fl_Menu_();
00055 
00056   int item_pathname(char *name, int namelen, const Fl_Menu_Item *finditem=0) const;
00057   const Fl_Menu_Item* picked(const Fl_Menu_Item*);
00058   const Fl_Menu_Item* find_item(const char *name);
00059   const Fl_Menu_Item* find_item(Fl_Callback*);
00060   int find_index(const char *name) const;
00061   int find_index(const Fl_Menu_Item *item) const;
00062   int find_index(Fl_Callback *cb) const;
00063 
00075   const Fl_Menu_Item* test_shortcut() {return picked(menu()->test_shortcut());}
00076   void global();
00077 
00096   const Fl_Menu_Item *menu() const {return menu_;}
00097   void menu(const Fl_Menu_Item *m);
00098   void copy(const Fl_Menu_Item *m, void* user_data = 0);
00099   int insert(int index, const char*, int shortcut, Fl_Callback*, void* = 0, int = 0);
00100   int  add(const char*, int shortcut, Fl_Callback*, void* = 0, int = 0);
00102   int  add(const char* a, const char* b, Fl_Callback* c, void* d = 0, int e = 0) {
00103       return add(a,fl_old_shortcut(b),c,d,e);
00104   }
00106   int insert(int index, const char* a, const char* b, Fl_Callback* c, void* d = 0, int e = 0) {
00107       return insert(index,a,fl_old_shortcut(b),c,d,e);
00108   }
00109   int  add(const char *);
00110   int  size() const ;
00111   void size(int W, int H) { Fl_Widget::size(W, H); }
00112   void clear();
00113   int clear_submenu(int index);
00114   void replace(int,const char *);
00115   void remove(int);
00117   void shortcut(int i, int s) {menu_[i].shortcut(s);}
00119   void mode(int i,int fl) {menu_[i].flags = fl;}
00121   int  mode(int i) const {return menu_[i].flags;}
00122 
00124   const Fl_Menu_Item *mvalue() const {return value_;}
00126   int value() const {return value_ ? (int)(value_-menu_) : -1;}
00127   int value(const Fl_Menu_Item*);
00134   int value(int i) {return value(menu_+i);}
00136   const char *text() const {return value_ ? value_->text : 0;}
00138   const char *text(int i) const {return menu_[i].text;}
00139 
00141   Fl_Font textfont() const {return textfont_;}
00143   void textfont(Fl_Font c) {textfont_=c;}
00145   Fl_Fontsize textsize() const {return textsize_;}
00147   void textsize(Fl_Fontsize c) {textsize_=c;}
00149   Fl_Color textcolor() const {return textcolor_;}
00151   void textcolor(Fl_Color c) {textcolor_=c;}
00152 
00159   Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;}
00161   void down_box(Fl_Boxtype b) {down_box_ = b;}
00162 
00164   Fl_Color down_color() const {return selection_color();}
00166   void down_color(unsigned c) {selection_color(c);}
00167 };
00168 
00169 #endif
00170 
00171 //
00172 // End of "$Id$".
00173 //