2008-08-21 20:14:26 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2003-11-27 23:41:00 +00:00
|
|
|
#include <Main/globals.hxx>
|
|
|
|
#include <Airports/simple.hxx>
|
|
|
|
|
|
|
|
#include "AirportList.hxx"
|
|
|
|
|
2008-06-03 10:25:58 +00:00
|
|
|
AirportList::AirportList(int x, int y, int width, int height) :
|
|
|
|
puaList(x, y, width, height),
|
|
|
|
GUI_ID(FGCLASS_AIRPORTLIST),
|
|
|
|
_content(0)
|
2003-11-27 23:41:00 +00:00
|
|
|
{
|
2006-03-31 10:17:43 +00:00
|
|
|
create_list();
|
|
|
|
}
|
|
|
|
|
2008-06-03 10:25:58 +00:00
|
|
|
|
|
|
|
AirportList::~AirportList()
|
2006-03-31 10:17:43 +00:00
|
|
|
{
|
|
|
|
destroy_list();
|
|
|
|
}
|
|
|
|
|
2008-06-03 10:25:58 +00:00
|
|
|
|
2006-03-31 10:17:43 +00:00
|
|
|
void
|
2008-06-03 10:25:58 +00:00
|
|
|
AirportList::create_list()
|
2006-03-31 10:17:43 +00:00
|
|
|
{
|
2008-12-27 13:20:08 +00:00
|
|
|
char **content = FGAirport::searchNamesAndIdents(_filter);
|
|
|
|
int n = (content[0] != NULL) ? 1 : 0;
|
|
|
|
|
2006-04-18 15:21:19 +00:00
|
|
|
// work around plib 2006/04/18 bug: lists with no entries cause crash on arrow-up
|
|
|
|
newList(n > 0 ? content : 0);
|
|
|
|
|
|
|
|
if (_content)
|
|
|
|
destroy_list();
|
|
|
|
|
|
|
|
_content = content;
|
2003-11-27 23:41:00 +00:00
|
|
|
}
|
|
|
|
|
2008-06-03 10:25:58 +00:00
|
|
|
|
2006-03-31 10:17:43 +00:00
|
|
|
void
|
2008-06-03 10:25:58 +00:00
|
|
|
AirportList::destroy_list()
|
2003-11-27 23:41:00 +00:00
|
|
|
{
|
2006-03-31 10:17:43 +00:00
|
|
|
for (char **c = _content; *c; c++) {
|
|
|
|
delete *c;
|
|
|
|
*c = 0;
|
2003-11-27 23:41:00 +00:00
|
|
|
}
|
|
|
|
delete [] _content;
|
|
|
|
}
|
|
|
|
|
2008-06-03 10:25:58 +00:00
|
|
|
|
2006-03-31 10:17:43 +00:00
|
|
|
void
|
2008-06-03 10:25:58 +00:00
|
|
|
AirportList::setValue(const char *s)
|
2006-03-31 10:17:43 +00:00
|
|
|
{
|
2008-06-03 10:25:58 +00:00
|
|
|
std::string filter(s);
|
|
|
|
const std::ctype<char> &ct = std::use_facet<std::ctype<char> >(std::locale());
|
|
|
|
ct.toupper((char *)filter.data(), (char *)filter.data() + filter.size());
|
|
|
|
|
2006-03-31 10:17:43 +00:00
|
|
|
if (filter != _filter) {
|
|
|
|
_filter = filter;
|
|
|
|
create_list();
|
|
|
|
}
|
2003-11-27 23:41:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|