• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

Fl_Menu_.H

00001 //
00002 // "$Id$"
00003 //
00004 // Menu base class header file for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2016 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 
00051 class FL_EXPORT Fl_Menu_ : public Fl_Widget {
00052 
00053   Fl_Menu_Item *menu_;
00054   const Fl_Menu_Item *value_;
00055 
00056 protected:
00057 
00058   uchar alloc;                  // flag indicates if menu_ is a dynamic copy (=1) or not (=0)
00059   uchar down_box_;
00060   Fl_Font textfont_;
00061   Fl_Fontsize textsize_;
00062   Fl_Color textcolor_;
00063 
00064   int item_pathname_(char *name, int namelen, const Fl_Menu_Item *finditem,
00065                      const Fl_Menu_Item *menu=0) const;
00066 public:
00067   Fl_Menu_(int,int,int,int,const char * =0);
00068   ~Fl_Menu_();
00069 
00070   int item_pathname(char *name, int namelen, const Fl_Menu_Item *finditem=0) const;
00071   const Fl_Menu_Item* picked(const Fl_Menu_Item*);
00072   const Fl_Menu_Item* find_item(const char *name);
00073   const Fl_Menu_Item* find_item(Fl_Callback*);
00074   int find_index(const char *name) const;
00075   int find_index(const Fl_Menu_Item *item) const;
00076   int find_index(Fl_Callback *cb) const;
00077 
00089   const Fl_Menu_Item* test_shortcut() {return picked(menu()->test_shortcut());}
00090   void global();
00091 
00110   const Fl_Menu_Item *menu() const {return menu_;}
00111   void menu(const Fl_Menu_Item *m);
00112   void copy(const Fl_Menu_Item *m, void* user_data = 0);
00113   int insert(int index, const char*, int shortcut, Fl_Callback*, void* = 0, int = 0);
00114   int  add(const char*, int shortcut, Fl_Callback*, void* = 0, int = 0); // see src/Fl_Menu_add.cxx
00116   int  add(const char* a, const char* b, Fl_Callback* c, void* d = 0, int e = 0) {
00117       return add(a,fl_old_shortcut(b),c,d,e);
00118   }
00120   int insert(int index, const char* a, const char* b, Fl_Callback* c, void* d = 0, int e = 0) {
00121       return insert(index,a,fl_old_shortcut(b),c,d,e);
00122   }
00123   int  add(const char *);
00124   int  size() const ;
00125   void size(int W, int H) { Fl_Widget::size(W, H); }
00126   void clear();
00127   int clear_submenu(int index);
00128   void replace(int,const char *);
00129   void remove(int);
00131   void shortcut(int i, int s) {menu_[i].shortcut(s);}
00133   void mode(int i,int fl) {menu_[i].flags = fl;}
00135   int  mode(int i) const {return menu_[i].flags;}
00136 
00138   const Fl_Menu_Item *mvalue() const {return value_;}
00140   int value() const {return value_ ? (int)(value_-menu_) : -1;}
00141   int value(const Fl_Menu_Item*);
00148   int value(int i) {return value(menu_+i);}
00150   const char *text() const {return value_ ? value_->text : 0;}
00152   const char *text(int i) const {return menu_[i].text;}
00153 
00155   Fl_Font textfont() const {return textfont_;}
00157   void textfont(Fl_Font c) {textfont_=c;}
00159   Fl_Fontsize textsize() const {return textsize_;}
00161   void textsize(Fl_Fontsize c) {textsize_=c;}
00163   Fl_Color textcolor() const {return textcolor_;}
00165   void textcolor(Fl_Color c) {textcolor_=c;}
00166 
00173   Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;}
00175   void down_box(Fl_Boxtype b) {down_box_ = b;}
00176 
00178   Fl_Color down_color() const {return selection_color();}
00180   void down_color(unsigned c) {selection_color(c);}
00181   void setonly(Fl_Menu_Item* item);
00182 };
00183 
00184 #endif
00185 
00186 //
00187 // End of "$Id$".
00188 //
  • © 1998-2016 by Bill Spitzak and others.     FLTK

  • © 1998-2016 by Bill Spitzak and others.     FLTK

    Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.