X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FGUI%2Fmenubar.hxx;h=3e70c48c1feb6ef6366f85bd18dcacd0120c4838;hb=24e6150d738b6d674d884e63e6b1cffda028b4b3;hp=79e0af8146d9e4802824c4fe113c96d8743a258f;hpb=c6062ad93cf3bfbffb6dec63cd6844167bb56980;p=flightgear.git diff --git a/src/GUI/menubar.hxx b/src/GUI/menubar.hxx index 79e0af814..3e70c48c1 100644 --- a/src/GUI/menubar.hxx +++ b/src/GUI/menubar.hxx @@ -3,42 +3,20 @@ #ifndef __MENUBAR_HXX #define __MENUBAR_HXX 1 -#ifndef __cplusplus -# error This library requires C++ -#endif - -#include
- -#include - -#include -#include - -class puMenuBar; -class puObject; -class SGBinding; - +class SGPropertyNode; /** - * XML-configured PUI menu bar. + * XML-configured menu bar interface * * This class creates a menu bar from a tree of XML properties. These * properties are not part of the main FlightGear property tree, but * are read from a separate file ($FG_ROOT/gui/menubar.xml). - * - * WARNING: because PUI provides no easy way to attach user data to a - * menu item, all menu item strings must be unique; otherwise, this - * class will always use the first binding with any given name. + */ class FGMenuBar { public: - - /** - * Constructor. - */ - FGMenuBar (); - + FGMenuBar(); /** * Destructor. @@ -49,89 +27,32 @@ public: /** * Initialize the menu bar from $FG_ROOT/gui/menubar.xml */ - virtual void init (); + virtual void init () = 0; /** * Make the menu bar visible. */ - virtual void show (); + virtual void show () = 0; /** * Make the menu bar invisible. */ - virtual void hide (); + virtual void hide () = 0; /** * Test whether the menu bar is visible. */ - virtual bool isVisible () const; - - - /** - * IGNORE THIS METHOD!!! - * - * This is necessary only because plib does not provide any easy - * way to attach user data to a menu item. FlightGear should not - * have to know about PUI internals, but this method allows the - * callback to pass the menu item one-shot on to the current menu. - */ - virtual void fireItem (puObject * item); - - - /** - * create a menubar based on a PropertyList within the PropertyTree - */ - void make_menubar (SGPropertyNode * props); - + virtual bool isVisible () const = 0; /** - * destroy a menubar based on a PropertyList within the PropertyTree + * Read a menu label from the menu's property tree. + * Take care of mapping it to the appropriate translation, if available. + * Returns an UTF-8 encoded string. */ - void destroy_menubar (); - - - /** - * Disable/enable menu titles and entries - */ - bool enable_item (const SGPropertyNode * item, bool state); - - -private: - - // Make a single menu. - void make_menu (SGPropertyNode * node); - - // Make the top-level menubar. - void make_menubar (); - - // Create a property-path -> puObject map for menu node - void make_object_map(SGPropertyNode * node); - - // Add listener that enables/disables menu entries. - void add_enabled_listener(SGPropertyNode * node); - - // Is the menu visible? - bool _visible; - - // The top-level menubar itself. - puMenuBar * _menuBar; - - // A map of bindings for the menubar. - std::map > _bindings; - - // These are hoops that we have to jump through because PUI doesn't - // do memory management for lists. We have to allocate the arrays, - // hang onto pointers, and then delete them when the menubar is - // freed. - char ** make_char_array (int size); - puCallback * make_callback_array (int size); - std::vector _char_arrays; - std::vector _callback_arrays; + static const char* getLocalizedLabel(SGPropertyNode* node); - // A map for {menu node path}->puObject translation. - std::map _objects; }; #endif // __MENUBAR_HXX