Gorgon Game Engine
TwoStateControl.h
Go to the documentation of this file.
1 #pragma once
2 
3 namespace Gorgon { namespace UI {
4 
14  public:
16 
17  virtual ~TwoStateControl() { }
18 
19  TwoStateControl &operator =(bool value) { SetState(value); return *this; }
20 
22  explicit operator bool() const { return GetState(); }
23 
25  bool operator !() const { return !GetState(); }
26 
29  bool Check() { return SetState(true); }
30 
32  bool Clear() { return SetState(false); }
33 
36  bool ForceCheck() { return SetState(true, true); }
37 
39  bool ForceClear() { return SetState(false, true); }
40 
42  bool Toggle() { return SetState(!GetState()); }
43 
45  virtual bool GetState() const = 0;
46 
48  virtual bool SetState(bool value, bool force = false) = 0;
49 
51  Event<TwoStateControl, bool /*new state*/, bool & /* allow */> StateChangingEvent;
52 
53  protected:
54 
55  };
56 
57 } }
Gorgon::UI::TwoStateControl::Clear
bool Clear()
Changes the state of the checkbox.
Definition: TwoStateControl.h:32
Gorgon::Event
This class provides event mechanism.
Definition: Event.h:134
Gorgon::UI::TwoStateControl::Toggle
bool Toggle()
Changes the state of the checkbox.
Definition: TwoStateControl.h:42
Gorgon::UI::TwoStateControl::GetState
virtual bool GetState() const =0
Returns the state of the checkbox.
Gorgon::UI::TwoStateControl::~TwoStateControl
virtual ~TwoStateControl()
Definition: TwoStateControl.h:17
Gorgon::UI::TwoStateControl::StateChangingEvent
Event< TwoStateControl, bool, bool & > StateChangingEvent
This event.
Definition: TwoStateControl.h:51
Gorgon::UI::TwoStateControl::Check
bool Check()
Changes the state of the widget.
Definition: TwoStateControl.h:29
Gorgon
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
Gorgon::UI::TwoStateControl::ForceClear
bool ForceClear()
Changes the state of the checkbox.
Definition: TwoStateControl.h:39
Gorgon::UI::TwoStateControl::TwoStateControl
TwoStateControl()
Definition: TwoStateControl.h:15
Gorgon::UI::TwoStateControl::operator!
bool operator!() const
Returns the inverse state of the checkbox.
Definition: TwoStateControl.h:25
Gorgon::UI::TwoStateControl
This class is designed to be the interface class for all checkbox like UI elements.
Definition: TwoStateControl.h:13
Gorgon::UI::TwoStateControl::SetState
virtual bool SetState(bool value, bool force=false)=0
Changes the state of the checkbox.
Gorgon::UI::TwoStateControl::ForceCheck
bool ForceCheck()
Changes the state of the widget.
Definition: TwoStateControl.h:36
Gorgon::UI::TwoStateControl::operator=
TwoStateControl & operator=(bool value)
Definition: TwoStateControl.h:19