]> git.tdb.fi Git - libs/gltk.git/blob - source/state.cpp
Change State into a bitmask to allow more fine-grained control of styles
[libs/gltk.git] / source / state.cpp
1 /* $Id$
2
3 This file is part of libmspgltk
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #include "state.h"
9
10 using namespace std;
11
12 namespace Msp {
13 namespace GLtk {
14
15 istream &operator>>(istream &is, State &state)
16 {
17         string str;
18         is>>str;
19
20         unsigned start=0;
21         state=NORMAL;
22
23         while(1)
24         {
25                 unsigned underscore=str.find('_', start);
26                 if(!str.compare(start, underscore-start, "NORMAL"))
27                         state|=NORMAL;
28                 else if(!str.compare(start, underscore-start, "HOVER"))
29                         state|=HOVER;
30                 else if(!str.compare(start, underscore-start, "ACTIVE"))
31                         state|=ACTIVE;
32                 else if(!str.compare(start, underscore-start, "FOCUS"))
33                         state|=FOCUS;
34                 else if(!str.compare(start, underscore-start, "DISABLED"))
35                         state|=DISABLED;
36                 else
37                 {
38                         is.setstate(ios_base::failbit);
39                         break;
40                 }
41
42                 if(underscore==std::string::npos)
43                         break;
44                 start=underscore+1;
45         }
46
47         return is;
48 }
49
50 } // namespace GLtk
51 } // namespace Msp