2 #include <Main/globals.hxx>
3 #include <Airports/simple.hxx>
5 #include "AirportList.hxx"
8 AirportList::AirportList (int x, int y, int width, int height)
9 : puList(x, y, width, height),
10 GUI_ID(FGCLASS_AIRPORTLIST),
11 _airports(globals->get_airports()),
17 AirportList::~AirportList ()
23 AirportList::create_list ()
25 int num_apt = _airports->size();
26 char **content = new char *[num_apt + 1];
29 for (int i = 0; i < num_apt; i++) {
30 const FGAirport *apt = _airports->getAirport(i);
31 STD::string entry(apt->getName() + " (" + apt->getId() + ')');
33 if (!_filter.empty() && entry.find(_filter) == STD::string::npos)
36 content[n] = new char[entry.size() + 1];
37 strcpy(content[n], entry.c_str());
41 // work around plib 2006/04/18 bug: lists with no entries cause crash on arrow-up
42 newList(n > 0 ? content : 0);
51 AirportList::destroy_list ()
53 for (char **c = _content; *c; c++) {
61 AirportList::getListStringValue ()
63 int i = getListIntegerValue();
64 return i < 0 ? 0 : _content[i];
68 AirportList::setValue (const char *s)
70 STD::string filter(s);
71 if (filter != _filter) {
77 // end of AirportList.cxx