2004-04-29 09:36:27 +00:00
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
# include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-01-16 18:06:27 +00:00
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <plib/pu.h>
|
|
|
|
|
#include <simgear/debug/logstream.hxx>
|
|
|
|
|
|
2004-01-31 19:47:45 +00:00
|
|
|
|
#include <Autopilot/auto_gui.hxx>
|
|
|
|
|
#include <Input/input.hxx>
|
2003-01-16 18:06:27 +00:00
|
|
|
|
#include <Main/globals.hxx>
|
|
|
|
|
#include <Main/fg_props.hxx>
|
|
|
|
|
|
|
|
|
|
#include "new_gui.hxx"
|
|
|
|
|
#include "menubar.hxx"
|
|
|
|
|
|
|
|
|
|
|
2003-01-18 16:26:41 +00:00
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// FIXME!!
|
|
|
|
|
//
|
|
|
|
|
// Deprecated wrappers for old menu commands.
|
|
|
|
|
//
|
|
|
|
|
// DO NOT ADD TO THESE. THEY WILL BE DELETED SOON!
|
|
|
|
|
//
|
|
|
|
|
// These are defined in gui_funcs.cxx. They should be replaced with
|
|
|
|
|
// user-configured dialogs and new commands where necessary.
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
extern void reInit (puObject *);
|
|
|
|
|
static bool
|
|
|
|
|
do_reinit_dialog (const SGPropertyNode * arg)
|
|
|
|
|
{
|
|
|
|
|
reInit(0);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if defined(TR_HIRES_SNAP)
|
|
|
|
|
extern void dumpHiResSnapShot (puObject *);
|
|
|
|
|
static bool
|
|
|
|
|
do_hires_snapshot_dialog (const SGPropertyNode * arg)
|
|
|
|
|
{
|
|
|
|
|
dumpHiResSnapShot(0);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#endif // TR_HIRES_SNAP
|
|
|
|
|
|
|
|
|
|
#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
|
|
|
|
|
extern void printScreen (puObject *);
|
|
|
|
|
static bool
|
|
|
|
|
do_print_dialog (const SGPropertyNode * arg)
|
|
|
|
|
{
|
|
|
|
|
printScreen(0);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
extern void prop_pickerView (puObject *);
|
|
|
|
|
static bool
|
|
|
|
|
do_properties_dialog (const SGPropertyNode * arg)
|
|
|
|
|
{
|
|
|
|
|
prop_pickerView(0);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern void AddWayPoint (puObject *);
|
|
|
|
|
static bool
|
|
|
|
|
do_ap_add_waypoint_dialog (const SGPropertyNode * arg)
|
|
|
|
|
{
|
|
|
|
|
AddWayPoint(0);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern void PopWayPoint (puObject *);
|
|
|
|
|
static bool
|
|
|
|
|
do_ap_pop_waypoint_dialog (const SGPropertyNode * arg)
|
|
|
|
|
{
|
|
|
|
|
PopWayPoint(0);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern void ClearRoute (puObject *);
|
|
|
|
|
static bool
|
|
|
|
|
do_ap_clear_route_dialog (const SGPropertyNode * arg)
|
|
|
|
|
{
|
|
|
|
|
ClearRoute(0);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-03 19:34:23 +00:00
|
|
|
|
#if 0
|
2003-01-18 16:26:41 +00:00
|
|
|
|
extern void fgAPAdjust (puObject *);
|
|
|
|
|
static bool
|
|
|
|
|
do_ap_adjust_dialog (const SGPropertyNode * arg)
|
|
|
|
|
{
|
|
|
|
|
fgAPAdjust(0);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2004-02-03 19:34:23 +00:00
|
|
|
|
#endif
|
2003-01-18 16:26:41 +00:00
|
|
|
|
|
|
|
|
|
extern void fgLatLonFormatToggle (puObject *);
|
|
|
|
|
static bool
|
|
|
|
|
do_lat_lon_format_dialog (const SGPropertyNode * arg)
|
|
|
|
|
{
|
|
|
|
|
fgLatLonFormatToggle(0);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern void helpCb (puObject *);
|
|
|
|
|
static bool
|
|
|
|
|
do_help_dialog (const SGPropertyNode * arg)
|
|
|
|
|
{
|
|
|
|
|
helpCb(0);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
|
const char * name;
|
|
|
|
|
SGCommandMgr::command_t command;
|
|
|
|
|
} deprecated_dialogs [] = {
|
2003-01-27 15:39:41 +00:00
|
|
|
|
{ "old-reinit-dialog", do_reinit_dialog },
|
2003-01-18 16:26:41 +00:00
|
|
|
|
#if defined(TR_HIRES_SNAP)
|
|
|
|
|
{ "old-hires-snapshot-dialog", do_hires_snapshot_dialog },
|
|
|
|
|
#endif
|
|
|
|
|
#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
|
|
|
|
|
{ "old-print-dialog", do_print_dialog },
|
|
|
|
|
#endif
|
|
|
|
|
{ "old-properties-dialog", do_properties_dialog },
|
|
|
|
|
{ "old-ap-add-waypoint-dialog", do_ap_add_waypoint_dialog },
|
|
|
|
|
{ "old-ap-pop-waypoint-dialog", do_ap_pop_waypoint_dialog },
|
|
|
|
|
{ "old-ap-clear-route-dialog", do_ap_clear_route_dialog },
|
|
|
|
|
{ "old-lat-lon-format-dialog", do_lat_lon_format_dialog },
|
|
|
|
|
{ "old-help-dialog", do_help_dialog },
|
|
|
|
|
{ 0, 0 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
add_deprecated_dialogs ()
|
|
|
|
|
{
|
|
|
|
|
SG_LOG(SG_GENERAL, SG_INFO, "Initializing old dialog commands:");
|
|
|
|
|
for (int i = 0; deprecated_dialogs[i].name != 0; i++) {
|
|
|
|
|
SG_LOG(SG_GENERAL, SG_INFO, " " << deprecated_dialogs[i].name);
|
|
|
|
|
globals->get_commands()->addCommand(deprecated_dialogs[i].name,
|
|
|
|
|
deprecated_dialogs[i].command);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-01-16 18:06:27 +00:00
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Static functions.
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
menu_callback (puObject * object)
|
|
|
|
|
{
|
|
|
|
|
NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
|
|
|
|
|
gui->getMenuBar()->fireItem(object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Implementation of FGMenuBar.
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FGMenuBar::FGMenuBar ()
|
|
|
|
|
: _visible(false),
|
|
|
|
|
_menuBar(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FGMenuBar::~FGMenuBar ()
|
|
|
|
|
{
|
2004-10-22 09:26:51 +00:00
|
|
|
|
destroy_menubar();
|
2003-01-16 18:06:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
FGMenuBar::init ()
|
|
|
|
|
{
|
2005-03-24 13:41:43 +00:00
|
|
|
|
delete _menuBar; // FIXME: check if PUI owns the pointer
|
2003-01-16 18:06:27 +00:00
|
|
|
|
make_menubar();
|
2003-01-18 16:26:41 +00:00
|
|
|
|
// FIXME: temporary commands to get at
|
|
|
|
|
// old, hard-coded dialogs.
|
|
|
|
|
add_deprecated_dialogs();
|
2003-01-16 18:06:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
FGMenuBar::show ()
|
|
|
|
|
{
|
2003-01-18 21:11:15 +00:00
|
|
|
|
if (_menuBar != 0)
|
2003-01-16 18:06:27 +00:00
|
|
|
|
_menuBar->reveal();
|
2003-01-18 21:11:15 +00:00
|
|
|
|
_visible = true;
|
2003-01-16 18:06:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
FGMenuBar::hide ()
|
|
|
|
|
{
|
2003-01-18 21:11:15 +00:00
|
|
|
|
if (_menuBar != 0)
|
2003-01-16 18:06:27 +00:00
|
|
|
|
_menuBar->hide();
|
|
|
|
|
_visible = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
FGMenuBar::isVisible () const
|
|
|
|
|
{
|
|
|
|
|
return _visible;
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-19 15:27:29 +00:00
|
|
|
|
void
|
2003-01-16 18:06:27 +00:00
|
|
|
|
FGMenuBar::fireItem (puObject * item)
|
|
|
|
|
{
|
|
|
|
|
const char * name = item->getLegend();
|
2003-01-19 23:03:31 +00:00
|
|
|
|
vector<FGBinding *> &bindings = _bindings[name];
|
2003-01-21 02:08:56 +00:00
|
|
|
|
int nBindings = bindings.size();
|
2003-01-16 18:06:27 +00:00
|
|
|
|
|
2003-01-21 02:08:56 +00:00
|
|
|
|
for (int i = 0; i < nBindings; i++)
|
2003-01-19 23:03:31 +00:00
|
|
|
|
bindings[i]->fire();
|
2003-01-16 18:06:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2003-01-21 15:44:21 +00:00
|
|
|
|
FGMenuBar::make_menu (SGPropertyNode * node)
|
2003-01-16 18:06:27 +00:00
|
|
|
|
{
|
|
|
|
|
const char * name = strdup(node->getStringValue("label"));
|
|
|
|
|
vector<SGPropertyNode_ptr> item_nodes = node->getChildren("item");
|
|
|
|
|
|
2003-01-20 16:02:26 +00:00
|
|
|
|
int array_size = item_nodes.size();
|
2003-01-16 18:06:27 +00:00
|
|
|
|
|
2003-01-20 16:02:26 +00:00
|
|
|
|
char ** items = make_char_array(array_size);
|
|
|
|
|
puCallback * callbacks = make_callback_array(array_size);
|
2003-01-16 18:06:27 +00:00
|
|
|
|
|
2003-05-09 19:39:48 +00:00
|
|
|
|
for (unsigned int i = 0, j = item_nodes.size() - 1;
|
2003-01-16 18:06:27 +00:00
|
|
|
|
i < item_nodes.size();
|
|
|
|
|
i++, j--) {
|
2005-07-03 14:43:47 +00:00
|
|
|
|
|
2003-01-16 18:06:27 +00:00
|
|
|
|
// Set up the PUI entries for this item
|
|
|
|
|
items[j] = strdup((char *)item_nodes[i]->getStringValue("label"));
|
|
|
|
|
callbacks[j] = menu_callback;
|
|
|
|
|
|
|
|
|
|
// Load all the bindings for this item
|
2005-07-03 14:43:47 +00:00
|
|
|
|
vector<SGPropertyNode_ptr> bindings = item_nodes[i]->getChildren("binding");
|
|
|
|
|
SGPropertyNode * dest = fgGetNode("/sim/bindings/menu", true);
|
|
|
|
|
|
|
|
|
|
for (unsigned int k = 0; k < bindings.size(); k++) {
|
|
|
|
|
unsigned int m = 0;
|
|
|
|
|
SGPropertyNode *binding;
|
|
|
|
|
while (dest->getChild("binding", m))
|
|
|
|
|
m++;
|
|
|
|
|
|
|
|
|
|
binding = dest->getChild("binding", m, true);
|
|
|
|
|
copyProperties(bindings[k], binding);
|
|
|
|
|
_bindings[items[j]].push_back(new FGBinding(binding));
|
|
|
|
|
}
|
2003-01-16 18:06:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_menuBar->add_submenu(name, items, callbacks);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
FGMenuBar::make_menubar ()
|
|
|
|
|
{
|
2004-10-22 09:26:51 +00:00
|
|
|
|
SGPropertyNode *targetpath;
|
|
|
|
|
|
|
|
|
|
targetpath = fgGetNode("/sim/menubar/default",true);
|
|
|
|
|
// fgLoadProps("gui/menubar.xml", targetpath);
|
|
|
|
|
|
|
|
|
|
/* NOTE: there is no check to see whether there's any usable data at all
|
|
|
|
|
*
|
|
|
|
|
* This would also have the advantage of being able to create some kind of
|
|
|
|
|
* 'fallback' menu - just in case that either menubar.xml is empty OR that
|
|
|
|
|
* its XML data is not valid, that way we would avoid displaying an
|
|
|
|
|
* unusable menubar without any functionality - if we decided to add another
|
|
|
|
|
* char * element to the commands structure in
|
|
|
|
|
* $FG_SRC/src/Main/fgcommands.cxx
|
|
|
|
|
* we could additionally save each function's (short) description and use
|
|
|
|
|
* this as label for the fallback PUI menubar item labels - as a workaround
|
|
|
|
|
* one might simply use the internal fgcommands and put them into the
|
|
|
|
|
* fallback menu, so that the user is at least able to re-init the menu
|
|
|
|
|
* loading - just in case there was some malformed XML in it
|
|
|
|
|
* (it happend to me ...)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
make_menubar(targetpath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* WARNING: We aren't yet doing any validation of what's found - but since
|
|
|
|
|
* this isn't done with menubar.xml either, it should not really matter
|
|
|
|
|
* right now. Although one should later on consider to validate the
|
|
|
|
|
* contents, whether they are representing a 'legal' menubar structure.
|
|
|
|
|
*/
|
|
|
|
|
void
|
2005-12-06 19:51:31 +00:00
|
|
|
|
FGMenuBar::make_menubar(SGPropertyNode * props)
|
2004-10-22 09:26:51 +00:00
|
|
|
|
{
|
|
|
|
|
// Just in case.
|
|
|
|
|
destroy_menubar();
|
2003-01-16 18:06:27 +00:00
|
|
|
|
_menuBar = new puMenuBar;
|
|
|
|
|
|
2004-10-22 09:26:51 +00:00
|
|
|
|
vector<SGPropertyNode_ptr> menu_nodes = props->getChildren("menu");
|
2003-05-09 19:39:48 +00:00
|
|
|
|
for (unsigned int i = 0; i < menu_nodes.size(); i++)
|
2003-01-16 18:06:27 +00:00
|
|
|
|
make_menu(menu_nodes[i]);
|
|
|
|
|
|
|
|
|
|
_menuBar->close();
|
2005-12-06 17:56:17 +00:00
|
|
|
|
make_map(props);
|
|
|
|
|
|
2003-01-18 21:11:15 +00:00
|
|
|
|
if (_visible)
|
|
|
|
|
_menuBar->reveal();
|
|
|
|
|
else
|
|
|
|
|
_menuBar->hide();
|
2003-01-16 18:06:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-10-22 09:26:51 +00:00
|
|
|
|
void
|
|
|
|
|
FGMenuBar::destroy_menubar ()
|
|
|
|
|
{
|
|
|
|
|
if ( _menuBar == 0 )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
hide();
|
|
|
|
|
puDeleteObject(_menuBar);
|
|
|
|
|
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
|
|
// Delete all the character arrays
|
|
|
|
|
// we were forced to keep around for
|
|
|
|
|
// plib.
|
|
|
|
|
SG_LOG(SG_GENERAL, SG_INFO, "Deleting char arrays");
|
|
|
|
|
for (i = 0; i < _char_arrays.size(); i++) {
|
|
|
|
|
for (int j = 0; _char_arrays[i][j] != 0; j++)
|
|
|
|
|
free(_char_arrays[i][j]); // added with strdup
|
|
|
|
|
delete[] _char_arrays[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete all the callback arrays
|
|
|
|
|
// we were forced to keep around for
|
|
|
|
|
// plib.
|
|
|
|
|
SG_LOG(SG_GENERAL, SG_INFO, "Deleting callback arrays");
|
|
|
|
|
for (i = 0; i < _callback_arrays.size(); i++)
|
|
|
|
|
delete[] _callback_arrays[i];
|
|
|
|
|
|
|
|
|
|
// Delete all those bindings
|
|
|
|
|
SG_LOG(SG_GENERAL, SG_INFO, "Deleting bindings");
|
|
|
|
|
map<string,vector<FGBinding *> >::iterator it;
|
|
|
|
|
it = _bindings.begin();
|
|
|
|
|
for (it = _bindings.begin(); it != _bindings.end(); it++) {
|
|
|
|
|
SG_LOG(SG_GENERAL, SG_INFO, "Deleting bindings for " << it->first);
|
|
|
|
|
for ( i = 0; i < it->second.size(); i++ )
|
|
|
|
|
delete it->second[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SG_LOG(SG_GENERAL, SG_INFO, "Done.");
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-06 17:56:17 +00:00
|
|
|
|
void
|
2005-12-06 19:51:31 +00:00
|
|
|
|
FGMenuBar::make_map(SGPropertyNode * node)
|
2005-12-06 17:56:17 +00:00
|
|
|
|
{
|
|
|
|
|
int menu_index = 0;
|
|
|
|
|
for (puObject *obj = ((puGroup *)_menuBar)->getFirstChild();
|
|
|
|
|
obj; obj = obj->getNextObject()) {
|
|
|
|
|
|
|
|
|
|
// skip puPopupMenus. They are also children of _menuBar,
|
|
|
|
|
// but we access them via getUserData() (see below)
|
|
|
|
|
if (!(obj->getType() & PUCLASS_ONESHOT))
|
|
|
|
|
continue;
|
|
|
|
|
|
2005-12-06 19:51:31 +00:00
|
|
|
|
SGPropertyNode *menu = node->getNode("menu", menu_index, false);
|
|
|
|
|
if (!menu) {
|
2005-12-06 21:03:15 +00:00
|
|
|
|
SG_LOG(SG_GENERAL, SG_WARN, "'menu' object without node: "
|
2005-12-06 19:51:31 +00:00
|
|
|
|
<< node->getPath() << "/menu[" << menu_index << ']');
|
2005-12-06 17:56:17 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-09 10:43:09 +00:00
|
|
|
|
_objects[menu->getPath()] = obj;
|
2005-12-06 19:51:31 +00:00
|
|
|
|
add_enabled_listener(menu);
|
2005-12-06 17:56:17 +00:00
|
|
|
|
|
2005-12-06 21:03:15 +00:00
|
|
|
|
puGroup *popup = (puGroup *)obj->getUserData();
|
2005-12-06 17:56:17 +00:00
|
|
|
|
if (!popup)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// the entries are for some reason reversed (last first), and we
|
2005-12-09 10:43:09 +00:00
|
|
|
|
// don't know yet how many there will be; so we collect first
|
2005-12-06 17:56:17 +00:00
|
|
|
|
vector<puObject *> e;
|
2005-12-06 21:03:15 +00:00
|
|
|
|
for (puObject *me = popup->getFirstChild(); me; me = me->getNextObject())
|
2005-12-06 17:56:17 +00:00
|
|
|
|
e.push_back(me);
|
|
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < e.size(); i++) {
|
2005-12-06 19:51:31 +00:00
|
|
|
|
SGPropertyNode *item = menu->getNode("item", e.size() - i - 1, false);
|
|
|
|
|
if (!item) {
|
2005-12-06 21:03:15 +00:00
|
|
|
|
SG_LOG(SG_GENERAL, SG_WARN, "'item' object without node: "
|
2005-12-06 19:51:31 +00:00
|
|
|
|
<< menu->getPath() << "/item[" << i << ']');
|
2005-12-06 17:56:17 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
2005-12-09 10:43:09 +00:00
|
|
|
|
_objects[item->getPath()] = e[i];
|
2005-12-06 19:51:31 +00:00
|
|
|
|
add_enabled_listener(item);
|
2005-12-06 17:56:17 +00:00
|
|
|
|
}
|
|
|
|
|
menu_index++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-09 10:43:09 +00:00
|
|
|
|
struct EnabledListener : SGPropertyChangeListener {
|
|
|
|
|
void valueChanged(SGPropertyNode *node) {
|
|
|
|
|
NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
|
|
|
|
|
if (!gui)
|
|
|
|
|
return;
|
|
|
|
|
FGMenuBar *menubar = gui->getMenuBar();
|
|
|
|
|
if (menubar)
|
|
|
|
|
menubar->enable_item(node->getParent(), node->getBoolValue());
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
FGMenuBar::add_enabled_listener(SGPropertyNode * node)
|
|
|
|
|
{
|
|
|
|
|
if (!node->hasValue("enabled"))
|
|
|
|
|
node->setBoolValue("enabled", true);
|
|
|
|
|
|
|
|
|
|
enable_item(node, node->getBoolValue("enabled"));
|
|
|
|
|
node->getNode("enabled")->addChangeListener(new EnabledListener());
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-06 17:56:17 +00:00
|
|
|
|
bool
|
|
|
|
|
FGMenuBar::enable_item(const SGPropertyNode * node, bool state)
|
|
|
|
|
{
|
2005-12-09 10:43:09 +00:00
|
|
|
|
if (!node || _objects.find(node->getPath()) == _objects.end()) {
|
2005-12-06 17:56:17 +00:00
|
|
|
|
SG_LOG(SG_GENERAL, SG_WARN, "Trying to enable/disable "
|
|
|
|
|
"non-existent menu item");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2005-12-09 10:43:09 +00:00
|
|
|
|
puObject *object = _objects[node->getPath()];
|
2005-12-06 17:56:17 +00:00
|
|
|
|
if (state)
|
|
|
|
|
object->activate();
|
|
|
|
|
else
|
|
|
|
|
object->greyOut();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2004-10-22 09:26:51 +00:00
|
|
|
|
|
2003-01-20 16:02:26 +00:00
|
|
|
|
char **
|
|
|
|
|
FGMenuBar::make_char_array (int size)
|
|
|
|
|
{
|
|
|
|
|
char ** list = new char*[size+1];
|
|
|
|
|
for (int i = 0; i <= size; i++)
|
|
|
|
|
list[i] = 0;
|
|
|
|
|
_char_arrays.push_back(list);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
puCallback *
|
|
|
|
|
FGMenuBar::make_callback_array (int size)
|
|
|
|
|
{
|
|
|
|
|
puCallback * list = new puCallback[size+1];
|
|
|
|
|
for (int i = 0; i <= size; i++)
|
|
|
|
|
list[i] = 0;
|
|
|
|
|
_callback_arrays.push_back(list);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-16 18:06:27 +00:00
|
|
|
|
// end of menubar.cxx
|