1 // menubar.hxx - XML-configured menu bar.
4 #define __MENUBAR_HXX 1
7 # error This library requires C++
10 #include <simgear/compiler.h> // for SG_USING_STD
27 * XML-configured PUI menu bar.
29 * This class creates a menu bar from a tree of XML properties. These
30 * properties are not part of the main FlightGear property tree, but
31 * are read from a separate file ($FG_ROOT/gui/menubar.xml).
33 * WARNING: because PUI provides no easy way to attach user data to a
34 * menu item, all menu item strings must be unique; otherwise, this
35 * class will always use the first binding with any given name.
50 virtual ~FGMenuBar ();
54 * Initialize the menu bar from $FG_ROOT/gui/menubar.xml
59 * Make the menu bar visible.
65 * Make the menu bar invisible.
71 * Test whether the menu bar is visible.
73 virtual bool isVisible () const;
77 * IGNORE THIS METHOD!!!
79 * This is necessary only because plib does not provide any easy
80 * way to attach user data to a menu item. FlightGear should not
81 * have to know about PUI internals, but this method allows the
82 * callback to pass the menu item one-shot on to the current menu.
84 virtual void fireItem (puObject * item);
88 * create a menubar based on a PropertyList within the PropertyTree
90 void make_menubar (SGPropertyNode * props);
94 * destroy a menubar based on a PropertyList within the PropertyTree
96 void destroy_menubar ();
99 * Disable/enable menu titles and entries
101 bool enable_item (const SGPropertyNode * item, bool state);
106 // Make a single menu.
107 void make_menu (SGPropertyNode * node);
109 // Make the top-level menubar.
110 void make_menubar ();
112 // Create a property-path -> puObject map for menu node
113 void make_map(SGPropertyNode * node);
115 // Add <enabled> listener that enables/disables menu entries.
116 void add_enabled_listener(SGPropertyNode * node);
118 // Is the menu visible?
121 // The top-level menubar itself.
122 puMenuBar * _menuBar;
124 // A map of bindings for the menubar.
125 map<string,vector<FGBinding *> > _bindings;
127 // These are hoops that we have to jump through because PUI doesn't
128 // do memory management for lists. We have to allocate the arrays,
129 // hang onto pointers, and then delete them when the menubar is
131 char ** make_char_array (int size);
132 puCallback * make_callback_array (int size);
133 vector<char **> _char_arrays;
134 vector<puCallback *> _callback_arrays;
136 map<string, puObject *> _entries;
139 #endif // __MENUBAR_HXX