diff options
| author | Manolo Gouy <Manolo> | 2017-12-02 16:20:30 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2017-12-02 16:20:30 +0000 |
| commit | 34dd1b15fbbc44e70bfdb21498ce7898bf8658b3 (patch) | |
| tree | fb65dd41847ff4205236066de124a1c9cb27e33c /FL | |
| parent | a8fe10cf88e757f59057fdaf51637d26ab3019aa (diff) | |
Converted class Fl_Sys_Menu_Bar to the driver model.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12575 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'FL')
| -rw-r--r-- | FL/Fl_Menu_Bar.H | 3 | ||||
| -rw-r--r-- | FL/Fl_Sys_Menu_Bar.H | 44 | ||||
| -rw-r--r-- | FL/Fl_Sys_Menu_Bar_Driver.H | 58 | ||||
| -rw-r--r-- | FL/mac.H | 13 |
4 files changed, 78 insertions, 40 deletions
diff --git a/FL/Fl_Menu_Bar.H b/FL/Fl_Menu_Bar.H index b6261069d..11a895430 100644 --- a/FL/Fl_Menu_Bar.H +++ b/FL/Fl_Menu_Bar.H @@ -3,7 +3,7 @@ // // Menu bar header file for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2016 by Bill Spitzak and others. +// Copyright 1998-2017 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -65,6 +65,7 @@ callbacks exactly the same as when you pick the item with the mouse. */ class FL_EXPORT Fl_Menu_Bar : public Fl_Menu_ { + friend class Fl_Sys_Menu_Bar_Driver; protected: void draw(); public: diff --git a/FL/Fl_Sys_Menu_Bar.H b/FL/Fl_Sys_Menu_Bar.H index 833140c24..31bcb3cc7 100644 --- a/FL/Fl_Sys_Menu_Bar.H +++ b/FL/Fl_Sys_Menu_Bar.H @@ -3,7 +3,7 @@ // // MacOS system menu bar header file for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2010 by Bill Spitzak and others. +// Copyright 1998-2017 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -21,7 +21,7 @@ #include <FL/Fl_Menu_Bar.H> -#if defined(__APPLE__) || defined(FL_DOXYGEN) +class Fl_Sys_Menu_Bar_Driver; /** A class to create, modify and delete menus that appear on Mac OS X in the menu bar at the top of the screen. @@ -41,14 +41,15 @@ \li no embossed labels \li no font sizes - You can configure a callback for the 'About' menu item to invoke your own code with fl_mac_set_about(). + You can configure a callback for the 'About' menu item to invoke your own code with Fl_Sys_Menu_Bar::about(). */ class FL_EXPORT Fl_Sys_Menu_Bar : public Fl_Menu_Bar { protected: - void draw(); + virtual void draw(); public: Fl_Sys_Menu_Bar(int x,int y,int w,int h,const char *l=0); - ~Fl_Sys_Menu_Bar(); + virtual ~Fl_Sys_Menu_Bar(); + Fl_Sys_Menu_Bar_Driver *driver(); /** Return the system menu's array of Fl_Menu_Item's */ const Fl_Menu_Item *menu() const {return Fl_Menu_::menu();} @@ -71,38 +72,25 @@ public: } void remove(int n); void replace(int index, const char *name); - /** Set the Fl_Menu_Item array pointer to null, indicating a zero-length menu. - \see Fl_Menu_::clear() - */ void clear(); - /** Clears the specified submenu pointed to by index of all menu items. - \see Fl_Menu_::clear_submenu(int index) - */ int clear_submenu(int index); - /** Make the shortcuts for this menu work no matter what window has the focus when you type it. - */ - void global() {}; - /** Sets the flags of item i - \see Fl_Menu_::mode(int i, int fl) */ - void mode (int i, int fl) { - Fl_Menu_::mode(i, fl); - update(); - } + void mode (int i, int fl); /** Gets the flags of item i. */ int mode(int i) const { return Fl_Menu_::mode(i); } - /** Changes the shortcut of item i to n. - */ - void shortcut (int i, int s) { Fl_Menu_::shortcut(i, s); update(); } - /** Turns the radio item "on" for the menu item and turns "off" adjacent radio items of the same group.*/ - void setonly (Fl_Menu_Item *item) { Fl_Menu_::setonly(item); update(); } + void shortcut (int i, int s); + void setonly (Fl_Menu_Item *item); + static void about(Fl_Callback *cb, void *data); }; -#else +extern Fl_Sys_Menu_Bar *fl_sys_menu_bar; -typedef Fl_Menu_Bar Fl_Sys_Menu_Bar; +/** + * Attaches a callback to the "About myprog" item of the system application menu. + For back-compatibility. Equivalent to Fl_Sys_Menu_Bar::about(cb, user_data). + */ +inline void fl_mac_set_about(Fl_Callback *cb, void *user_data, int shortcut = 0) { Fl_Sys_Menu_Bar::about(cb, user_data);} -#endif // defined(__APPLE__) || defined(FL_DOXYGEN) #endif // Fl_Sys_Menu_Bar_H diff --git a/FL/Fl_Sys_Menu_Bar_Driver.H b/FL/Fl_Sys_Menu_Bar_Driver.H new file mode 100644 index 000000000..8ab45cc93 --- /dev/null +++ b/FL/Fl_Sys_Menu_Bar_Driver.H @@ -0,0 +1,58 @@ +// +// "$Id$" +// +// system menu bar widget for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2017 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// http://www.fltk.org/COPYING.php +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +#ifndef Fl_Sys_Menu_Bar_Driver_H +#define Fl_Sys_Menu_Bar_Driver_H + +#include <FL/Fl_Sys_Menu_Bar.H> + +class Fl_Sys_Menu_Bar_Driver { + friend class Fl_Sys_Menu_Bar; +protected: + Fl_Sys_Menu_Bar *bar; +public: + Fl_Sys_Menu_Bar_Driver(); + virtual ~Fl_Sys_Menu_Bar_Driver(); + virtual void update() {} + virtual void draw() { bar->Fl_Menu_Bar::draw();} + virtual void about(Fl_Callback *cb, void *data) {} + virtual int add(const char* label, int shortcut, Fl_Callback *cb, void *user_data, int flags) { + return bar->Fl_Menu_Bar::add(label, shortcut, cb, user_data, flags); + } + virtual int add(const char* str) { return bar->Fl_Menu_Bar::add(str); } + virtual int insert(int index, const char* label, int shortcut, Fl_Callback *cb, void *user_data, int flags) { + return bar->Fl_Menu_Bar::insert(index, label, shortcut, cb, user_data, flags); + } + virtual void menu(const Fl_Menu_Item *m) { bar->Fl_Menu_Bar::menu(m); } + virtual void shortcut(int i, int s) { bar->Fl_Menu_Bar::shortcut(i, s); } + virtual void setonly(Fl_Menu_Item *item) { bar->Fl_Menu_Bar::setonly(item); } + virtual void clear() { bar->Fl_Menu_Bar::clear(); } + virtual int clear_submenu(int index) { return bar->Fl_Menu_Bar::clear_submenu(index);} + virtual void remove(int index) { bar->Fl_Menu_Bar::remove(index); } + virtual void replace(int index, const char *name) { bar->Fl_Menu_Bar::replace(index, name); } + virtual void mode(int i, int fl) { bar->Fl_Menu_Bar::mode(i, fl); } + + static Fl_Sys_Menu_Bar_Driver *driver_; // to be assigned with a unique object of this class or of a derived class +}; + + +#endif // Fl_Sys_Menu_Bar_Driver_H + +// +// End of "$Id$". +// @@ -3,7 +3,7 @@ // // Mac header file for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2016 by Bill Spitzak and others. +// Copyright 1998-2017 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -113,15 +113,6 @@ extern CGContextRef fl_gc; \sa \ref osissues_macos @{ */ -/** - * \brief Attaches a callback to the "About myprog" item of the system application menu. - * - * \param cb a callback that will be called by "About myprog" menu item - * with NULL 1st argument. - * \param user_data a pointer transmitted as 2nd argument to the callback. - * \param shortcut optional shortcut to attach to the "About myprog" menu item (e.g., FL_META+'a') - */ -extern void fl_mac_set_about( Fl_Callback *cb, void *user_data, int shortcut = 0); /** \brief The version number of the running Mac OS X (e.g., 100604 for 10.6.4) */ @@ -129,7 +120,7 @@ extern int fl_mac_os_version; /** The system menu bar. */ -extern class Fl_Sys_Menu_Bar *fl_sys_menu_bar; +//extern class Fl_Sys_Menu_Bar *fl_sys_menu_bar; struct Fl_Menu_Item; |
