edelib
2.0.0
|
00001 // 00002 // "$Id: MenuBase.h 2839 2009-09-28 11:36:20Z karijes $" 00003 // 00004 // Menu base class header file for the Fast Light Tool Kit (FLTK). 00005 // 00006 // Copyright 1998-2005 by Bill Spitzak and others. 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Library General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00021 // USA. 00022 00023 #ifndef __EDELIB_MENUBASE_H__ 00024 #define __EDELIB_MENUBASE_H__ 00025 00026 #include "edelib-global.h" 00027 00028 #include <FL/Fl_Widget.H> 00029 #include "MenuItem.h" 00030 00031 EDELIB_NS_BEGIN 00032 00039 class EDELIB_API MenuBase : public Fl_Widget { 00040 private: 00041 MenuItem *menu_; 00042 const MenuItem *value_; 00043 00044 protected: 00045 #ifndef SKIP_DOCS 00046 uchar alloc; 00047 uchar down_box_; 00048 uchar textfont_; 00049 uchar textsize_; 00050 unsigned textcolor_; 00051 #endif 00052 00053 public: 00054 #ifndef SKIP_DOCS 00055 MenuBase(int,int,int,int,const char * =0); 00056 ~MenuBase(); 00057 00058 int item_pathname(char *name, int namelen, const MenuItem *finditem=0) const; 00059 const MenuItem* picked(const MenuItem*); 00060 const MenuItem* find_item(const char *name); 00061 00062 const MenuItem* test_shortcut() {return picked(menu()->test_shortcut());} 00063 void global(); 00064 00065 const MenuItem *menu() const {return menu_;} 00066 void menu(const MenuItem *m); 00067 void copy(const MenuItem *m, void* user_data = 0); 00068 int add(const char*, int shortcut, Fl_Callback*, void* = 0, int = 0); 00069 int add(const char* a, const char* b, Fl_Callback* c, 00070 void* d = 0, int e = 0) {return add(a,fl_old_shortcut(b),c,d,e);} 00071 int size() const ; 00072 void size(int W, int H) { Fl_Widget::size(W, H); } 00073 void clear(); 00074 int add(const char *); 00075 void replace(int,const char *); 00076 void remove(int); 00077 void shortcut(int i, int s) {menu_[i].shortcut(s);} 00078 void mode(int i,int fl) {menu_[i].flags = fl;} 00079 int mode(int i) const {return menu_[i].flags;} 00080 00081 const MenuItem *mvalue() const {return value_;} 00082 int value() const {return value_ ? (int)(value_-menu_) : -1;} 00083 int value(const MenuItem*); 00084 int value(int i) {return value(menu_+i);} 00085 const char *text() const {return value_ ? value_->text : 0;} 00086 const char *text(int i) const {return menu_[i].text;} 00087 00088 Fl_Font textfont() const {return (Fl_Font)textfont_;} 00089 void textfont(uchar c) {textfont_=c;} 00090 uchar textsize() const {return textsize_;} 00091 void textsize(uchar c) {textsize_=c;} 00092 Fl_Color textcolor() const {return (Fl_Color)textcolor_;} 00093 void textcolor(unsigned c) {textcolor_=c;} 00094 00095 Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;} 00096 void down_box(Fl_Boxtype b) {down_box_ = b;} 00097 00098 // back compatability: 00099 Fl_Color down_color() const {return selection_color();} 00100 void down_color(unsigned c) {selection_color(c);} 00101 #endif 00102 }; 00103 00104 EDELIB_NS_END 00105 #endif