]> git.tdb.fi Git - libs/gltk.git/blob - source/state.cpp
Combine common parts of Column and Row into LinearArrangement
[libs/gltk.git] / source / state.cpp
1 #include "state.h"
2
3 using namespace std;
4
5 namespace Msp {
6 namespace GLtk {
7
8 istream &operator>>(istream &is, State &state)
9 {
10         string str;
11         is>>str;
12
13         unsigned start = 0;
14         state = NORMAL;
15
16         while(1)
17         {
18                 string::size_type underscore = str.find('_', start);
19                 if(!str.compare(start, underscore-start, "NORMAL"))
20                         state |= NORMAL;
21                 else if(!str.compare(start, underscore-start, "HOVER"))
22                         state |= HOVER;
23                 else if(!str.compare(start, underscore-start, "ACTIVE"))
24                         state |= ACTIVE;
25                 else if(!str.compare(start, underscore-start, "FOCUS"))
26                         state |= FOCUS;
27                 else if(!str.compare(start, underscore-start, "DISABLED"))
28                         state |= DISABLED;
29                 else
30                 {
31                         is.setstate(ios_base::failbit);
32                         break;
33                 }
34
35                 if(underscore==std::string::npos)
36                         break;
37                 start = underscore+1;
38         }
39
40         return is;
41 }
42
43 } // namespace GLtk
44 } // namespace Msp