]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/state.cpp
Change State into a bitmask to allow more fine-grained control of styles
[libs/gltk.git] / source / state.cpp
index 368e69350156337f7e48d2c6a2aaaad8d4f2239a..4e0a1debafadbbd711f03de028252cf20f2ff3c7 100644 (file)
@@ -16,16 +16,33 @@ istream &operator>>(istream &is, State &state)
 {
        string str;
        is>>str;
-       if(str=="NORMAL")
-               state=NORMAL;
-       else if(str=="HOVER")
-               state=HOVER;
-       else if(str=="ACTIVE")
-               state=ACTIVE;
-       else if(str=="DISABLED")
-               state=DISABLED;
-       else
-               is.setstate(ios_base::failbit);
+
+       unsigned start=0;
+       state=NORMAL;
+
+       while(1)
+       {
+               unsigned underscore=str.find('_', start);
+               if(!str.compare(start, underscore-start, "NORMAL"))
+                       state|=NORMAL;
+               else if(!str.compare(start, underscore-start, "HOVER"))
+                       state|=HOVER;
+               else if(!str.compare(start, underscore-start, "ACTIVE"))
+                       state|=ACTIVE;
+               else if(!str.compare(start, underscore-start, "FOCUS"))
+                       state|=FOCUS;
+               else if(!str.compare(start, underscore-start, "DISABLED"))
+                       state|=DISABLED;
+               else
+               {
+                       is.setstate(ios_base::failbit);
+                       break;
+               }
+
+               if(underscore==std::string::npos)
+                       break;
+               start=underscore+1;
+       }
 
        return is;
 }