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 _airports(globals->get_airports()),
16 AirportList::~AirportList ()
22 AirportList::create_list ()
24 int num_apt = _airports->size();
25 char **content = new char *[num_apt + 1];
28 for (int i = 0; i < num_apt; i++) {
29 const FGAirport *apt = _airports->getAirport(i);
30 STD::string entry(apt->getName() + " (" + apt->getId() + ')');
32 if (!_filter.empty() && entry.find(_filter) == STD::string::npos)
35 content[n] = new char[entry.size() + 1];
36 strcpy(content[n], entry.c_str());
40 // work around plib 2006/04/18 bug: lists with no entries cause crash on arrow-up
41 newList(n > 0 ? content : 0);
50 AirportList::destroy_list ()
52 for (char **c = _content; *c; c++) {
60 AirportList::getListStringValue ()
62 int i = getListIntegerValue();
63 return i < 0 ? 0 : _content[i];
67 AirportList::setValue (const char *s)
69 STD::string filter(s);
70 if (filter != _filter) {
76 // end of AirportList.cxx