From 964349e401c99b0b5e450b1fc7bec6364e625267 Mon Sep 17 00:00:00 2001 From: ehofman Date: Mon, 31 Jan 2005 10:36:59 +0000 Subject: [PATCH] Andrew Midson: I have made the 'Select Airport from List' option in FlightGear work (I think) properly. I have some concerns about the solution, which could be broken by changes to plib (if they re-use the value I have assigned to PUCLASS_LIST), but for the moment it seems to work OK. Erik Hofman: A request has been sent to John Fay to include the puList code in the puAux subdirectory of plib so expect some changes for future version of FlightGear. --- src/GUI/AirportList.cxx | 4 ++-- src/GUI/AirportList.hxx | 2 +- src/GUI/dialog.cxx | 12 ++++++++++-- src/GUI/puList.cxx | 10 +++++++++- src/GUI/puList.hxx | 5 ++++- 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/GUI/AirportList.cxx b/src/GUI/AirportList.cxx index 6ded7f88b..88d77494d 100644 --- a/src/GUI/AirportList.cxx +++ b/src/GUI/AirportList.cxx @@ -41,9 +41,9 @@ AirportList::~AirportList () } char * -AirportList::getStringValue () +AirportList::getListStringValue () { - return (char *)_airports->getAirport(getIntegerValue())->_id.c_str(); + return (char *)_airports->getAirport(getListIntegerValue())->_id.c_str(); } // end of AirportList.cxx diff --git a/src/GUI/AirportList.hxx b/src/GUI/AirportList.hxx index 97a1c7346..2f3ad87ca 100644 --- a/src/GUI/AirportList.hxx +++ b/src/GUI/AirportList.hxx @@ -15,7 +15,7 @@ class AirportList : public puList virtual ~AirportList (); // FIXME: add other string value functions - virtual char * getStringValue (); + virtual char * getListStringValue (); private: FGAirportList * _airports; diff --git a/src/GUI/dialog.cxx b/src/GUI/dialog.cxx index 52f2fef76..00fc3de8b 100644 --- a/src/GUI/dialog.cxx +++ b/src/GUI/dialog.cxx @@ -135,7 +135,15 @@ copy_from_pui (puObject * object, SGPropertyNode * node) node->setFloatValue(object->getFloatValue()); break; default: - node->setStringValue(object->getStringValue()); + // Special case to handle lists, as getStringValue cannot be overridden + if(object->getType() & PUCLASS_LIST) + { + node->setStringValue(((puList *) object)->getListStringValue()); + } + else + { + node->setStringValue(object->getStringValue()); + } break; } } @@ -398,7 +406,7 @@ FGDialog::makeObject (SGPropertyNode * props, int parentWidth, int parentHeight) puTextBox->enableInput(); } setupObject(puTextBox,props); - return puTextBox; + return puTextBox; } else if (type == "select") { vector value_nodes; SGPropertyNode * selection_node = diff --git a/src/GUI/puList.cxx b/src/GUI/puList.cxx index 17f654bfc..5902a68ca 100644 --- a/src/GUI/puList.cxx +++ b/src/GUI/puList.cxx @@ -53,12 +53,14 @@ handle_arrow (puObject * arrow) puList::puList (int x, int y, int w, int h) : puGroup(x, y) { + type |= PUCLASS_LIST; init(w, h); } puList::puList (int x, int y, int w, int h, char ** contents) : puGroup(x, y) { + type |= PUCLASS_LIST; init(w, h); newList(contents); } @@ -75,11 +77,17 @@ puList::newList (char ** contents) } char * -puList::getStringValue () +puList::getListStringValue () { return _contents[_list_box->getIntegerValue()]; } +int +puList::getListIntegerValue() +{ + return _list_box->getIntegerValue(); +} + void puList::init (int w, int h) { diff --git a/src/GUI/puList.hxx b/src/GUI/puList.hxx index 563763a0b..b33e45f62 100644 --- a/src/GUI/puList.hxx +++ b/src/GUI/puList.hxx @@ -9,6 +9,8 @@ #include +# define PUCLASS_LIST 0x80000000 // Hopefully this value will never be used by plib +# define PUCLASS_LIST 0x80000000 // Hopefully this value will never be used by plib /** * A scrolling list for PUI. @@ -24,7 +26,8 @@ class puList : public puGroup virtual void newList (char ** contents); // TODO: other string value funcs - virtual char * getStringValue (); + virtual char * getListStringValue (); + virtual int getListIntegerValue(); protected: virtual void init (int w, int h); -- 2.39.5