]> git.mxchange.org Git - flightgear.git/blob - src/GUI/AirportList.cxx
43cee70ab522fd361d336f6c78c54a2e5dbdc6a4
[flightgear.git] / src / GUI / AirportList.cxx
1 #include <Main/globals.hxx>
2 #include <Airports/simple.hxx>
3
4 #include "AirportList.hxx"
5
6
7 AirportList::AirportList (int x, int y, int width, int height)
8     : puList(x, y, width, height)
9 {
10     char buf[1024];
11
12     _airports = globals->get_airports();
13     _nAirports = _airports->size();
14
15     _content = new char *[_nAirports+1];
16     for (int i = 0; i < _nAirports; i++) {
17         const FGAirport * airport = _airports->getAirport(i);
18         snprintf(buf, 1023, "%s  %s\n",
19                  airport->id.c_str(),
20                  airport->name.c_str());
21         _content[i] = strndup(buf, 1023);
22     }
23     _content[_nAirports] = 0;
24     newList(_content);
25 }
26
27 AirportList::~AirportList ()
28 {
29     for (int i = 0; i < _nAirports; i++) {
30         delete _content[i];
31         _content[i] = 0;
32     }
33     delete [] _content;
34 }
35
36 char *
37 AirportList::getStringValue ()
38 {
39     return (char *)_airports->getAirport(getIntegerValue())->id.c_str();
40 }
41
42 // end of AirportList.cxx
43