X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fstate.cpp;h=6eaf33613591fc5a0786e55fea9f16fdc0e6367c;hb=6081ed9020ad22214a8e5b3829092f97b12d7c71;hp=bbff03dc9306ef8142935131aba760d75c1d80ee;hpb=c1f038acb91eb3bfaa34dfd4729d19ed3f871a42;p=libs%2Fgltk.git diff --git a/source/state.cpp b/source/state.cpp index bbff03d..6eaf336 100644 --- a/source/state.cpp +++ b/source/state.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include "state.h" using namespace std; @@ -9,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) + { + string::size_type 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; }