1 // 2 // "$Id$" 3 // 4 // MacOS system menu bar header file for the Fast Light Tool Kit (FLTK). 5 // 6 // Copyright 1998-2010 by Bill Spitzak and others. 7 // 8 // This library is free software. Distribution and use rights are outlined in 9 // the file "COPYING" which should have been included with this file. If this 10 // file is missing or damaged, see the license at: 11 // 12 // http://www.fltk.org/COPYING.php 13 // 14 // Please report all bugs and problems on the following page: 15 // 16 // http://www.fltk.org/str.php 17 // 18 19 #ifndef Fl_Sys_Menu_Bar_H 20 #define Fl_Sys_Menu_Bar_H 21 22 #include "Fl_Menu_Bar.H" 23 #include "x.H" 24 25 #if defined(__APPLE__) || defined(FL_DOXYGEN) 26 27 /** 28 A class to create, modify and delete menus that appear on Mac OS X in the menu bar at the top of the screen. 29 30 On other than Mac OS X platforms, Fl_Sys_Menu_Bar is a synonym of class Fl_Menu_Bar. 31 \n To use this class, just replace Fl_Menu_Bar by Fl_Sys_Menu_Bar, and, on the Mac platform, 32 a system menu at the top of the screen will be available. This menu will match an array 33 of Fl_Menu_Item's exactly as with standard FLTK menus. 34 35 Changes to the menu state are immediately visible in the menubar when they are made 36 using member functions of the Fl_Sys_Menu_Bar class. Other changes (e.g., by a call to 37 Fl_Menu_Item::set()) should be followed by a call to Fl_Sys_Menu_Bar::update() to be 38 visible in the menubar across all platforms. 39 40 A few FLTK features are not supported by the Mac System menu: 41 42 \li no symbolic labels 43 \li no embossed labels 44 \li no font sizes 45 46 You can configure a callback for the 'About' menu item to invoke your own code with fl_mac_set_about(). 47 */ 48 class FL_EXPORT Fl_Sys_Menu_Bar : public Fl_Menu_Bar { 49 50 #if FLTK_ABI_VERSION >= 10304 51 // NEW -- update() public (STR#3317) 52 public: 53 void update(); 54 protected: 55 void draw(); 56 #else 57 // OLD -- update() protected 58 protected: 59 void update(); 60 void draw(); 61 #endif 62 63 public: 64 Fl_Sys_Menu_Bar(int x,int y,int w,int h,const char *l=0); 65 ~Fl_Sys_Menu_Bar(); 66 /** Return the system menu's array of Fl_Menu_Item's 67 */ menu()68 const Fl_Menu_Item *menu() const {return Fl_Menu_::menu();} 69 void menu(const Fl_Menu_Item *m); 70 int add(const char* label, int shortcut, Fl_Callback*, void *user_data=0, int flags=0); 71 /** Adds a new menu item. 72 \see Fl_Menu_::add(const char* label, int shortcut, Fl_Callback*, void *user_data=0, int flags=0) 73 */ 74 int add(const char* label, const char* shortcut, Fl_Callback* cb, void *user_data=0, int flags=0) { 75 return add(label, fl_old_shortcut(shortcut), cb, user_data, flags); 76 } 77 int add(const char* str); 78 int insert(int index, const char* label, int shortcut, Fl_Callback *cb, void *user_data=0, int flags=0); 79 /** Insert a new menu item. 80 \see Fl_Menu_::insert(int index, const char* label, const char* shortcut, Fl_Callback *cb, void *user_data=0, int flags=0) 81 */ 82 int insert(int index, const char* label, const char* shortcut, Fl_Callback *cb, void *user_data=0, int flags=0) { 83 return insert(index, label, fl_old_shortcut(shortcut), cb, user_data, flags); 84 } 85 void remove(int n); 86 void replace(int index, const char *name); 87 /** Set the Fl_Menu_Item array pointer to null, indicating a zero-length menu. 88 \see Fl_Menu_::clear() 89 */ 90 void clear(); 91 /** Clears the specified submenu pointed to by index of all menu items. 92 \see Fl_Menu_::clear_submenu(int index) 93 */ 94 int clear_submenu(int index); 95 /** Make the shortcuts for this menu work no matter what window has the focus when you type it. 96 */ global()97 void global() {}; 98 /** Sets the flags of item i 99 \see Fl_Menu_::mode(int i, int fl) */ mode(int i,int fl)100 void mode (int i, int fl) { 101 Fl_Menu_::mode(i, fl); 102 update(); 103 } 104 /** Gets the flags of item i. 105 */ mode(int i)106 int mode(int i) const { return Fl_Menu_::mode(i); } 107 /** Changes the shortcut of item i to n. 108 */ shortcut(int i,int s)109 void shortcut (int i, int s) { Fl_Menu_::shortcut(i, s); update(); } 110 /** Turns the radio item "on" for the menu item and turns "off" adjacent radio items of the same group.*/ setonly(Fl_Menu_Item * item)111 void setonly (Fl_Menu_Item *item) { Fl_Menu_::setonly(item); update(); } 112 }; 113 114 #else 115 116 #if FLTK_ABI_VERSION >= 10304 117 // NEW -- small class for update() 118 class FL_EXPORT Fl_Sys_Menu_Bar : public Fl_Menu_Bar { 119 public: Fl_Menu_Bar(x,y,w,h,l)120 Fl_Sys_Menu_Bar(int x,int y,int w,int h,const char *l=0) : Fl_Menu_Bar(x,y,w,h,l) {} update()121 inline void update() {} 122 }; 123 #else 124 // OLD -- simple typedef 125 typedef Fl_Menu_Bar Fl_Sys_Menu_Bar; 126 #endif 127 128 #endif // defined(__APPLE__) || defined(FL_DOXYGEN) 129 130 #endif // Fl_Sys_Menu_Bar_H 131 132 // 133 // End of "$Id$". 134 // 135