]> git.tdb.fi Git - libs/gltk.git/blob - source/state.h
Change State into a bitmask to allow more fine-grained control of styles
[libs/gltk.git] / source / state.h
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 #ifndef MSP_GLTK_STATE_H_
9 #define MSP_GLTK_STATE_H_
10
11 #include <istream>
12 #include <msp/datafile/value.h>
13
14 namespace Msp {
15 namespace GLtk {
16
17 enum State
18 {
19         NORMAL=0,   //< Default state
20         HOVER=1,    //< Pointer over the widget
21         ACTIVE=2,   //< Widget is active (e.g. pressed button)
22         FOCUS=4,    //< Widget has input focus
23         DISABLED=8, //< Widget is unresponsive
24         N_STATES_=16 //< Sentry value
25 };
26
27 inline State operator|(State a, State b)
28 { return static_cast<State>(static_cast<int>(a)|static_cast<int>(b)); }
29
30 inline State operator|=(State &a, State b)
31 { a=a|b; return a; }
32
33 inline State operator&(State a, State b)
34 { return static_cast<State>(static_cast<int>(a)&static_cast<int>(b)); }
35
36 inline State operator&=(State &a, State b)
37 { a=a&b; return a; }
38
39 inline State operator~(State a)
40 { return static_cast<State>(~static_cast<int>(a)); }
41
42 extern std::istream &operator>>(std::istream &, State &);
43
44 } // namespace GLtk
45 } // namespace Msp
46
47 #endif