summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/Fl_Menu_Bar.H3
-rw-r--r--FL/Fl_Sys_Menu_Bar.H44
-rw-r--r--FL/Fl_Sys_Menu_Bar_Driver.H58
-rw-r--r--FL/mac.H13
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/Fl_MacOS_Sys_Menu_Bar.mm (renamed from src/Fl_Sys_Menu_Bar.mm)210
-rw-r--r--src/Fl_Sys_Menu_Bar.cxx189
-rw-r--r--src/Makefile3
8 files changed, 358 insertions, 165 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$".
+//
diff --git a/FL/mac.H b/FL/mac.H
index f4818284f..fce812ec1 100644
--- a/FL/mac.H
+++ b/FL/mac.H
@@ -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;
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ca6dc74be..4216518b8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -63,6 +63,7 @@ set (CPPFILES
Fl_Single_Window.cxx
Fl_Slider.cxx
Fl_Spinner.cxx
+ Fl_Sys_Menu_Bar.cxx
Fl_System_Driver.cxx
Fl_Table.cxx
Fl_Table_Row.cxx
@@ -405,7 +406,7 @@ if (APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL))
Fl_cocoa.mm
drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm
Fl_Native_File_Chooser_MAC.mm
- Fl_Sys_Menu_Bar.mm
+ Fl_MacOS_Sys_Menu_Bar.mm
)
else()
set (MMFILES
diff --git a/src/Fl_Sys_Menu_Bar.mm b/src/Fl_MacOS_Sys_Menu_Bar.mm
index 22d7c983a..bf9af8145 100644
--- a/src/Fl_Sys_Menu_Bar.mm
+++ b/src/Fl_MacOS_Sys_Menu_Bar.mm
@@ -3,7 +3,7 @@
//
// MacOS system menu bar widget for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2013 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
@@ -31,12 +31,35 @@
*
* Many other calls of the parent class don't work.
*/
-
-#if defined(__APPLE__) || defined(FL_DOXYGEN) // PORTME: Fl_Screen_Driver - platform system menu bar
-#include <FL/Fl_Menu_Item.H>
-#include <FL/Fl_Sys_Menu_Bar.H>
+#include <FL/Fl_Sys_Menu_Bar_Driver.H>
#include <FL/x.H>
-#include <FL/Fl.H>
+
+
+#if defined(__APPLE__)
+
+class Fl_MacOS_Sys_Menu_Bar_Driver : public Fl_Sys_Menu_Bar_Driver {
+public:
+ Fl_MacOS_Sys_Menu_Bar_Driver();
+ virtual ~Fl_MacOS_Sys_Menu_Bar_Driver();
+ virtual void update();
+ virtual void 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);
+ virtual int add(const char* str);
+ virtual int insert(int index, const char* label, int shortcut, Fl_Callback *cb, void *user_data, int flags);
+ virtual void menu(const Fl_Menu_Item *m);
+ virtual void shortcut (int i, int s);
+ virtual void setonly (Fl_Menu_Item *item);
+ virtual void clear();
+ virtual int clear_submenu(int index);
+ virtual void remove(int index);
+ virtual void replace(int index, const char *name);
+ virtual void mode(int i, int fl);
+};
+
+// this runs once if this source file is linked in, and initializes the
+// static variable Fl_Sys_Menu_Bar_Driver::driver_ with an object of class Fl_MacOS_Sys_Menu_Bar_Driver
+static int unused = (Fl_Sys_Menu_Bar_Driver::driver_ = new Fl_MacOS_Sys_Menu_Bar_Driver(), 0);
#import <Cocoa/Cocoa.h>
@@ -47,7 +70,6 @@
typedef const Fl_Menu_Item *pFl_Menu_Item;
-Fl_Sys_Menu_Bar *fl_sys_menu_bar = 0;
static Fl_Menu_Bar *custom_menu;
static char *remove_ampersand(const char *s);
@@ -201,22 +223,19 @@ const char *Fl_Mac_App_Menu::quit = "Quit %@";
@end
-void fl_mac_set_about( Fl_Callback *cb, void *user_data, int shortcut)
+void Fl_MacOS_Sys_Menu_Bar_Driver::about( Fl_Callback *cb, void *user_data)
{
fl_open_display();
Fl_Menu_Item aboutItem;
memset(&aboutItem, 0, sizeof(Fl_Menu_Item));
aboutItem.callback(cb);
aboutItem.user_data(user_data);
- aboutItem.shortcut(shortcut);
NSMenu *appleMenu = [[[NSApp mainMenu] itemAtIndex:0] submenu];
CFStringRef cfname = CFStringCreateCopy(NULL, (CFStringRef)[[appleMenu itemAtIndex:0] title]);
[appleMenu removeItemAtIndex:0];
FLMenuItem *item = [[[FLMenuItem alloc] initWithTitle:(NSString*)cfname
action:@selector(directCallback)
keyEquivalent:@""] autorelease];
- if (aboutItem.shortcut())
- [item setFltkShortcut:aboutItem.shortcut()];
NSData *pointer = [NSData dataWithBytes:&aboutItem length:sizeof(Fl_Menu_Item)];
[item setRepresentedObject:pointer];
[appleMenu insertItem:item atIndex:0];
@@ -347,159 +366,104 @@ static void convertToMenuBar(const Fl_Menu_Item *mm)
if (mm) createSubMenu(fl_system_menu, mm, NULL, @selector(doCallback));
}
-
-/**
- * @brief create a system menu bar using the given list of menu structs
- *
- * \author Matthias Melcher
- *
- * @param m list of Fl_Menu_Item
- */
-void Fl_Sys_Menu_Bar::menu(const Fl_Menu_Item *m)
+void Fl_MacOS_Sys_Menu_Bar_Driver::update()
{
- fl_open_display();
- Fl_Menu_Bar::menu( m );
- convertToMenuBar(m);
+ convertToMenuBar(bar->Fl_Menu_::menu());
}
-/**
- * @brief Add a new menu item to the system menu bar.
- *
- * Add to the system menu bar a new menu item, with a title string, shortcut int,
- * callback, argument to the callback, and flags.
- *
- * @param label - new menu item's label
- * @param shortcut - new menu item's integer shortcut (can be 0 for none, or e.g. FL_ALT+'x')
- * @param cb - callback to be invoked when item selected (can be 0 for none, in which case the menubar's callback() can be used instead)
- * @param user_data - argument to the callback
- * @param flags - item's flags, e.g. ::FL_MENU_TOGGLE, etc.
- *
- * \returns the index into the menu() array, where the entry was added
- *
- * @see Fl_Menu_::add(const char* label, int shortcut, Fl_Callback *cb, void *user_data, int flags)
- */
-int Fl_Sys_Menu_Bar::add(const char* label, int shortcut, Fl_Callback *cb, void *user_data, int flags)
+static int process_sys_menu_shortcuts(int event)
{
- fl_open_display();
- int index = Fl_Menu_::add(label, shortcut, cb, user_data, flags);
- update();
- return index;
+ if (event != FL_SHORTCUT || !fl_sys_menu_bar || Fl::modal()) return 0;
+ // is the last event the shortcut of an item of the fl_sys_menu_bar menu ?
+ const Fl_Menu_Item *item = fl_sys_menu_bar->menu()->test_shortcut();
+ if (!item) return 0;
+ if (item->visible()) // have the system menu process the shortcut, highlighting the corresponding menu
+ [[NSApp mainMenu] performKeyEquivalent:[NSApp currentEvent]];
+ else // have FLTK process the shortcut associated to an invisible Fl_Menu_Item
+ fl_sys_menu_bar->picked(item);
+ return 1;
}
-/**
- * Forms-compatible procedure to add items to the system menu bar
- *
- * \returns the index into the menu() array, where the entry was added
- * @see Fl_Menu_::add(const char* str)
- */
-int Fl_Sys_Menu_Bar::add(const char* str)
+Fl_MacOS_Sys_Menu_Bar_Driver::Fl_MacOS_Sys_Menu_Bar_Driver() : Fl_Sys_Menu_Bar_Driver()
{
- fl_open_display();
- int index = Fl_Menu_::add(str);
- update();
- return index;
+ Fl::add_handler(process_sys_menu_shortcuts);
}
-/**
- * @brief insert in the system menu bar a new menu item
- *
- * Insert in the system menu bar a new menu item, with a title string, shortcut int,
- * callback, argument to the callback, and flags.
- *
- * \returns the index into the menu() array, where the entry was inserted
- * @see Fl_Menu_::insert(int index, const char* label, int shortcut, Fl_Callback *cb, void *user_data, int flags)
- */
-int Fl_Sys_Menu_Bar::insert(int index, const char* label, int shortcut, Fl_Callback *cb, void *user_data, int flags)
+Fl_MacOS_Sys_Menu_Bar_Driver::~Fl_MacOS_Sys_Menu_Bar_Driver()
+{
+ Fl::remove_handler(process_sys_menu_shortcuts);
+}
+
+void Fl_MacOS_Sys_Menu_Bar_Driver::menu(const Fl_Menu_Item *m)
{
fl_open_display();
- int menu_index = Fl_Menu_::insert(index, label, shortcut, cb, user_data, flags);
- update();
- return menu_index;
+ bar->Fl_Menu_Bar::menu( m );
+ convertToMenuBar(m);
}
-void Fl_Sys_Menu_Bar::clear()
+void Fl_MacOS_Sys_Menu_Bar_Driver::clear()
{
- Fl_Menu_::clear();
+ bar->Fl_Menu_::clear();
convertToMenuBar(NULL);
}
-int Fl_Sys_Menu_Bar::clear_submenu(int index)
+int Fl_MacOS_Sys_Menu_Bar_Driver::clear_submenu(int index)
{
- int retval = Fl_Menu_::clear_submenu(index);
+ int retval = bar->Fl_Menu_::clear_submenu(index);
if (retval != -1) update();
return retval;
}
-/**
- * @brief remove an item from the system menu bar
- *
- * @param index the index of the item to remove
- */
-void Fl_Sys_Menu_Bar::remove(int index)
+void Fl_MacOS_Sys_Menu_Bar_Driver::remove(int index)
{
- Fl_Menu_::remove(index);
+ bar->Fl_Menu_::remove(index);
update();
}
-
-/**
- * @brief rename an item from the system menu bar
- *
- * @param index the index of the item to rename
- * @param name the new item name as a UTF8 string
- */
-void Fl_Sys_Menu_Bar::replace(int index, const char *name)
+void Fl_MacOS_Sys_Menu_Bar_Driver::replace(int index, const char *name)
{
- Fl_Menu_::replace(index, name); // index
+ bar->Fl_Menu_::replace(index, name);
update();
}
-void Fl_Sys_Menu_Bar::update()
-{
- convertToMenuBar(Fl_Menu_::menu());
+void Fl_MacOS_Sys_Menu_Bar_Driver::mode(int i, int fl) {
+ bar->Fl_Menu_::mode(i, fl);
+ update();
}
-/*
- * Draw the menu bar.
- * Nothing here because the OS does this for us.
- */
-void Fl_Sys_Menu_Bar::draw() {
+void Fl_MacOS_Sys_Menu_Bar_Driver::shortcut (int i, int s) {
+ bar->Fl_Menu_Bar::shortcut(i, s);
+ update();
}
-static int process_sys_menu_shortcuts(int event)
-{
- if (event != FL_SHORTCUT || !fl_sys_menu_bar || Fl::modal()) return 0;
- // is the last event the shortcut of an item of the fl_sys_menu_bar menu ?
- const Fl_Menu_Item *item = fl_sys_menu_bar->menu()->test_shortcut();
- if (!item) return 0;
- if (item->visible()) // have the system menu process the shortcut, highlighting the corresponding menu
- [[NSApp mainMenu] performKeyEquivalent:[NSApp currentEvent]];
- else // have FLTK process the shortcut associated to an invisible Fl_Menu_Item
- fl_sys_menu_bar->picked(item);
- return 1;
+void Fl_MacOS_Sys_Menu_Bar_Driver::setonly (Fl_Menu_Item *item) {
+ bar->Fl_Menu_::setonly(item);
+ update();
}
+int Fl_MacOS_Sys_Menu_Bar_Driver::add(const char* label, int shortcut, Fl_Callback *cb, void *user_data, int flags)
+{
+ fl_open_display();
+ int index = bar->Fl_Menu_::add(label, shortcut, cb, user_data, flags);
+ update();
+ return index;
+}
-/**
- The constructor.
- On Mac OS X, all arguments are unused. On other platforms they are used as by Fl_Menu_Bar::Fl_Menu_Bar().
- */
-Fl_Sys_Menu_Bar::Fl_Sys_Menu_Bar(int x,int y,int w,int h,const char *l)
-: Fl_Menu_Bar(x,y,w,h,l)
+int Fl_MacOS_Sys_Menu_Bar_Driver::add(const char* str)
{
- deactivate(); // don't let the old area take events
- if (fl_sys_menu_bar) delete fl_sys_menu_bar;
- fl_sys_menu_bar = this;
- Fl::add_handler(process_sys_menu_shortcuts);
+ fl_open_display();
+ int index = bar->Fl_Menu_::add(str);
+ update();
+ return index;
}
-/** The destructor */
-Fl_Sys_Menu_Bar::~Fl_Sys_Menu_Bar()
+int Fl_MacOS_Sys_Menu_Bar_Driver::insert(int index, const char* label, int shortcut, Fl_Callback *cb, void *user_data, int flags)
{
- fl_sys_menu_bar = 0;
- clear();
- Fl::remove_handler(process_sys_menu_shortcuts);
+ fl_open_display();
+ int menu_index = bar->Fl_Menu_::insert(index, label, shortcut, cb, user_data, flags);
+ update();
+ return menu_index;
}
/** \class Fl_Mac_App_Menu
@@ -542,7 +506,7 @@ void Fl_Mac_App_Menu::custom_application_menu_items(const Fl_Menu_Item *m)
[item release];
}
}
-#endif /* __APPLE__ */ // PORTME: Fl_Screen_Driver - platform system menu bar
+#endif /* __APPLE__ */
//
// End of "$Id$".
diff --git a/src/Fl_Sys_Menu_Bar.cxx b/src/Fl_Sys_Menu_Bar.cxx
new file mode 100644
index 000000000..08c7186a7
--- /dev/null
+++ b/src/Fl_Sys_Menu_Bar.cxx
@@ -0,0 +1,189 @@
+//
+// "$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
+//
+
+
+#include <FL/Fl_Sys_Menu_Bar_Driver.H>
+#include <FL/x.H>
+
+
+Fl_Sys_Menu_Bar *fl_sys_menu_bar = 0;
+
+// initialize this static variable if it was not initialized previously
+Fl_Sys_Menu_Bar_Driver *Fl_Sys_Menu_Bar_Driver::driver_ =
+ ( driver_ ? driver_ : new Fl_Sys_Menu_Bar_Driver() );
+
+Fl_Sys_Menu_Bar_Driver *Fl_Sys_Menu_Bar::driver() {return Fl_Sys_Menu_Bar_Driver::driver_;}
+
+
+/**
+ The constructor.
+ On Mac OS X, all arguments are unused. On other platforms they are used as by Fl_Menu_Bar::Fl_Menu_Bar().
+ */
+Fl_Sys_Menu_Bar::Fl_Sys_Menu_Bar(int x,int y,int w,int h,const char *l)
+: Fl_Menu_Bar(x,y,w,h,l)
+{
+ if (fl_sys_menu_bar) delete fl_sys_menu_bar;
+ fl_sys_menu_bar = this;
+ Fl_Sys_Menu_Bar_Driver::driver_->bar = this;
+}
+
+/** The destructor */
+Fl_Sys_Menu_Bar::~Fl_Sys_Menu_Bar()
+{
+ fl_sys_menu_bar = 0;
+ clear();
+}
+
+Fl_Sys_Menu_Bar_Driver::Fl_Sys_Menu_Bar_Driver() {bar = NULL;}
+
+Fl_Sys_Menu_Bar_Driver::~Fl_Sys_Menu_Bar_Driver() {}
+
+void Fl_Sys_Menu_Bar::update() {
+ driver()->update();
+}
+
+/**
+ * @brief create a system menu bar using the given list of menu structs
+ *
+ * \author Matthias Melcher
+ *
+ * @param m Zero-ending list of Fl_Menu_Item's
+ */
+void Fl_Sys_Menu_Bar::menu(const Fl_Menu_Item *m)
+{
+ driver()->menu(m);
+}
+
+/** Changes the shortcut of item i to n.
+ */
+void Fl_Sys_Menu_Bar::shortcut (int i, int s) {
+ driver()->shortcut(i, s);
+}
+
+/** Turns the radio item "on" for the menu item and turns "off" adjacent radio items of the same group.*/
+void Fl_Sys_Menu_Bar::setonly (Fl_Menu_Item *item) {
+ driver()->setonly(item);
+}
+
+/** Sets the flags of item i
+ \see Fl_Menu_::mode(int i, int fl) */
+void Fl_Sys_Menu_Bar::mode (int i, int fl) {
+ driver()->mode(i, fl);
+}
+
+/**
+ * @brief Add a new menu item to the system menu bar.
+ *
+ * Add to the system menu bar a new menu item, with a title string, shortcut int,
+ * callback, argument to the callback, and flags.
+ *
+ * @param label - new menu item's label
+ * @param shortcut - new menu item's integer shortcut (can be 0 for none, or e.g. FL_ALT+'x')
+ * @param cb - callback to be invoked when item selected (can be 0 for none, in which case the menubar's callback() can be used instead)
+ * @param user_data - argument to the callback
+ * @param flags - item's flags, e.g. ::FL_MENU_TOGGLE, etc.
+ *
+ * \returns the index into the menu() array, where the entry was added
+ *
+ * @see Fl_Menu_::add(const char* label, int shortcut, Fl_Callback *cb, void *user_data, int flags)
+ */
+int Fl_Sys_Menu_Bar::add(const char* label, int shortcut, Fl_Callback *cb, void *user_data, int flags)
+{
+ return driver()->add(label, shortcut, cb, user_data, flags);
+}
+
+/**
+ * Forms-compatible procedure to add items to the system menu bar
+ *
+ * \returns the index into the menu() array, where the entry was added
+ * @see Fl_Menu_::add(const char* str)
+ */
+int Fl_Sys_Menu_Bar::add(const char* str)
+{
+ return driver()->add(str);
+}
+
+/**
+ * @brief insert in the system menu bar a new menu item
+ *
+ * Insert in the system menu bar a new menu item, with a title string, shortcut int,
+ * callback, argument to the callback, and flags.
+ *
+ * \returns the index into the menu() array, where the entry was inserted
+ * @see Fl_Menu_::insert(int index, const char* label, int shortcut, Fl_Callback *cb, void *user_data, int flags)
+ */
+int Fl_Sys_Menu_Bar::insert(int index, const char* label, int shortcut, Fl_Callback *cb, void *user_data, int flags)
+{
+ return driver()->insert(index, label, shortcut, cb, user_data, flags);
+}
+
+/** Set the Fl_Menu_Item array pointer to null, indicating a zero-length menu.
+ \see Fl_Menu_::clear()
+ */
+void Fl_Sys_Menu_Bar::clear()
+{
+ driver()->clear();
+}
+
+/** Clears the specified submenu pointed to by index of all menu items.
+ \see Fl_Menu_::clear_submenu(int index)
+ */
+int Fl_Sys_Menu_Bar::clear_submenu(int index)
+{
+ return driver()->clear_submenu(index);
+}
+
+/**
+ * @brief remove an item from the system menu bar
+ *
+ * @param index the index of the item to remove
+ */
+void Fl_Sys_Menu_Bar::remove(int index)
+{
+ driver()->remove(index);
+}
+
+/**
+ * @brief rename an item from the system menu bar
+ *
+ * @param index the index of the item to rename
+ * @param name the new item name as a UTF8 string
+ */
+void Fl_Sys_Menu_Bar::replace(int index, const char *name)
+{
+ driver()->replace(index, name);
+}
+
+/**
+ * Attaches a callback to the "About myprog" item of the system application menu.
+ * This cross-platform function is effective only under the MacOS platform.
+ * \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.
+ */
+void Fl_Sys_Menu_Bar::about(Fl_Callback *cb, void *data) {
+ if (fl_sys_menu_bar) fl_sys_menu_bar->driver()->about(cb, data);
+}
+
+void Fl_Sys_Menu_Bar::draw() {
+ driver()->draw();
+}
+
+//
+// End of "$Id$".
+//
diff --git a/src/Makefile b/src/Makefile
index b943f813c..9364320a7 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -82,6 +82,7 @@ CPPFILES = \
Fl_Single_Window.cxx \
Fl_Slider.cxx \
Fl_Spinner.cxx \
+ Fl_Sys_Menu_Bar.cxx \
Fl_System_Driver.cxx \
Fl_Table.cxx \
Fl_Table_Row.cxx \
@@ -167,7 +168,7 @@ OBJCPPFILES = \
Fl_cocoa.mm \
drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm \
Fl_Native_File_Chooser_MAC.mm \
- Fl_Sys_Menu_Bar.mm
+ Fl_MacOS_Sys_Menu_Bar.mm
FLCPPFILES = \
forms_compatibility.cxx \