]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/AirportList.cxx
return attribute mask as unsigned
[flightgear.git] / src / GUI / AirportList.cxx
index 636232feeda3eaa662321456877b08578359204a..1b62f0aff3ef823f4e9a21ef699189f153d3eeaf 100644 (file)
@@ -1,36 +1,45 @@
-
+#include <locale>
 #include <Main/globals.hxx>
 #include <Airports/simple.hxx>
 
 #include "AirportList.hxx"
 
 
-AirportList::AirportList (int x, int y, int width, int height)
-    : puList(x, y, width, height),
-      _airports(globals->get_airports()),
-      _content(0)
+AirportList::AirportList(int x, int y, int width, int height) :
+    puaList(x, y, width, height),
+    GUI_ID(FGCLASS_AIRPORTLIST),
+    _airports(globals->get_airports()),
+    _content(0)
 {
     create_list();
 }
 
-AirportList::~AirportList ()
+
+AirportList::~AirportList()
 {
     destroy_list();
 }
 
+
 void
-AirportList::create_list ()
+AirportList::create_list()
 {
+    const std::ctype<char> &ct = std::use_facet<std::ctype<char> >(std::locale());
     int num_apt = _airports->size();
     char **content = new char *[num_apt + 1];
 
     int n = 0;
     for (int i = 0; i < num_apt; i++) {
         const FGAirport *apt = _airports->getAirport(i);
-        STD::string entry(apt->getName() + "   (" + apt->getId() + ')');
+        std::string entry(' ' + apt->getName() + "   (" + apt->getId() + ')');
+
+        if (!_filter.empty()) {
+            std::string upper(entry.data());
+            ct.toupper((char *)upper.data(), (char *)upper.data() + upper.size());
 
-        if (!_filter.empty() && entry.find(_filter) == STD::string::npos)
-            continue;
+            if (upper.find(_filter) == std::string::npos)
+                continue;
+        }
 
         content[n] = new char[entry.size() + 1];
         strcpy(content[n], entry.c_str());
@@ -46,8 +55,9 @@ AirportList::create_list ()
     _content = content;
 }
 
+
 void
-AirportList::destroy_list ()
+AirportList::destroy_list()
 {
     for (char **c = _content; *c; c++) {
         delete *c;
@@ -56,22 +66,18 @@ AirportList::destroy_list ()
     delete [] _content;
 }
 
-char *
-AirportList::getListStringValue ()
-{
-    int i = getListIntegerValue();
-    return i < 0 ? 0 : _content[i];
-}
 
 void
-AirportList::setValue (const char *s)
+AirportList::setValue(const char *s)
 {
-    STD::string filter(s);
+    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());
+
     if (filter != _filter) {
         _filter = filter;
         create_list();
     }
 }
 
-// end of AirportList.cxx