FLTK 1.3.0
|
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; 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 // Please report all bugs and problems on the following page: 00024 // 00025 // http://www.fltk.org/str.php 00026 // 00027 00028 /* \file 00029 Fl_Menu_ widget . */ 00030 00031 #ifndef Fl_Menu__H 00032 #define Fl_Menu__H 00033 00034 #ifndef Fl_Widget_H 00035 #include "Fl_Widget.H" 00036 #endif 00037 #include "Fl_Menu_Item.H" 00038 00048 class FL_EXPORT Fl_Menu_ : public Fl_Widget { 00049 00050 Fl_Menu_Item *menu_; 00051 const Fl_Menu_Item *value_; 00052 00053 protected: 00054 00055 uchar alloc; // flag indicates if menu_ is a dynamic copy (=1) or not (=0) 00056 uchar down_box_; 00057 Fl_Font textfont_; 00058 Fl_Fontsize textsize_; 00059 Fl_Color textcolor_; 00060 00061 public: 00062 Fl_Menu_(int,int,int,int,const char * =0); 00063 ~Fl_Menu_(); 00064 00065 int item_pathname(char *name, int namelen, const Fl_Menu_Item *finditem=0) const; 00066 const Fl_Menu_Item* picked(const Fl_Menu_Item*); 00067 const Fl_Menu_Item* find_item(const char *name); 00068 const Fl_Menu_Item* find_item(Fl_Callback*); 00069 int find_index(const char *name) const; 00070 int find_index(const Fl_Menu_Item *item) const; 00071 int find_index(Fl_Callback *cb) const; 00072 00084 const Fl_Menu_Item* test_shortcut() {return picked(menu()->test_shortcut());} 00085 void global(); 00086 00091 const Fl_Menu_Item *menu() const {return menu_;} 00092 void menu(const Fl_Menu_Item *m); 00093 void copy(const Fl_Menu_Item *m, void* user_data = 0); 00094 int insert(int index, const char*, int shortcut, Fl_Callback*, void* = 0, int = 0); 00095 int add(const char*, int shortcut, Fl_Callback*, void* = 0, int = 0); 00097 int add(const char* a, const char* b, Fl_Callback* c, void* d = 0, int e = 0) { 00098 return add(a,fl_old_shortcut(b),c,d,e); 00099 } 00101 int insert(int index, const char* a, const char* b, Fl_Callback* c, void* d = 0, int e = 0) { 00102 return insert(index,a,fl_old_shortcut(b),c,d,e); 00103 } 00104 int add(const char *); 00105 int size() const ; 00106 void size(int W, int H) { Fl_Widget::size(W, H); } 00107 void clear(); 00108 int clear_submenu(int index); 00109 void replace(int,const char *); 00110 void remove(int); 00112 void shortcut(int i, int s) {menu_[i].shortcut(s);} 00114 void mode(int i,int fl) {menu_[i].flags = fl;} 00116 int mode(int i) const {return menu_[i].flags;} 00117 00119 const Fl_Menu_Item *mvalue() const {return value_;} 00121 int value() const {return value_ ? (int)(value_-menu_) : -1;} 00122 int value(const Fl_Menu_Item*); 00129 int value(int i) {return value(menu_+i);} 00131 const char *text() const {return value_ ? value_->text : 0;} 00133 const char *text(int i) const {return menu_[i].text;} 00134 00136 Fl_Font textfont() const {return textfont_;} 00138 void textfont(Fl_Font c) {textfont_=c;} 00140 Fl_Fontsize textsize() const {return textsize_;} 00142 void textsize(Fl_Fontsize c) {textsize_=c;} 00144 Fl_Color textcolor() const {return textcolor_;} 00146 void textcolor(Fl_Color c) {textcolor_=c;} 00147 00154 Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;} 00156 void down_box(Fl_Boxtype b) {down_box_ = b;} 00157 00159 Fl_Color down_color() const {return selection_color();} 00161 void down_color(unsigned c) {selection_color(c);} 00162 }; 00163 00164 #endif 00165 00166 // 00167 // End of "$Id$". 00168 //