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
11 #include <Main/fg_props.hxx>
28 * XML-configured PUI menu bar.
30 * This class creates a menu bar from a tree of XML properties. These
31 * properties are not part of the main FlightGear property tree, but
32 * are read from a separate file ($FG_ROOT/gui/menubar.xml).
34 * WARNING: because PUI provides no easy way to attach user data to a
35 * menu item, all menu item strings must be unique; otherwise, this
36 * class will always use the first binding with any given name.
51 virtual ~FGMenuBar ();
55 * Initialize the menu bar from $FG_ROOT/gui/menubar.xml
60 * Make the menu bar visible.
66 * Make the menu bar invisible.
72 * Test whether the menu bar is visible.
74 virtual bool isVisible () const;
78 * IGNORE THIS METHOD!!!
80 * This is necessary only because plib does not provide any easy
81 * way to attach user data to a menu item. FlightGear should not
82 * have to know about PUI internals, but this method allows the
83 * callback to pass the menu item one-shot on to the current menu.
85 virtual void fireItem (puObject * item);
89 * create a menubar based on a PropertyList within the PropertyTree
91 void make_menubar (SGPropertyNode * props);
95 * destroy a menubar based on a PropertyList within the PropertyTree
97 void destroy_menubar ();
101 * Disable/enable menu titles and entries
103 bool enable_item (const SGPropertyNode * item, bool state);
108 // Make a single menu.
109 void make_menu (SGPropertyNode * node);
111 // Make the top-level menubar.
112 void make_menubar ();
114 // Create a property-path -> puObject map for menu node
115 void make_object_map(SGPropertyNode * node);
117 // Add <enabled> listener that enables/disables menu entries.
118 void add_enabled_listener(SGPropertyNode * node);
120 // Is the menu visible?
123 // The top-level menubar itself.
124 puMenuBar * _menuBar;
126 // A map of bindings for the menubar.
127 map<string,vector<FGBinding *> > _bindings;
129 // These are hoops that we have to jump through because PUI doesn't
130 // do memory management for lists. We have to allocate the arrays,
131 // hang onto pointers, and then delete them when the menubar is
133 char ** make_char_array (int size);
134 puCallback * make_callback_array (int size);
135 vector<char **> _char_arrays;
136 vector<puCallback *> _callback_arrays;
138 // A map for {menu node path}->puObject translation.
139 map<string, puObject *> _objects;
142 #endif // __MENUBAR_HXX