Sleeping Wombat GUI  0.100
swGUI
IControl.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 #include <string>
7 
8 
9 
10 
11 
12 namespace sw {
13 namespace gui
14 {
15 
16 struct IEventArgs;
17 struct InputEventArgs;
18 struct MouseEventArgs;
19 struct MouseButtonEventArgs;
20 struct MouseWheelEventArgs;
21 struct KeyEventArgs;
22 
23 class HostWindow;
24 class TopLevelControl;
25 
26 
27 
28 enum class VerticalAlignment : char
29 {
30  Bottom,
31  Center,
32  Stretch,
33  Top
34 };
35 
36 enum class HorizontalAlignment : char
37 {
38  Left,
39  Center,
40  Right,
41  Stretch
42 };
43 
44 
47 class IControl : public EngineObject
48 {
49  RTTR_ENABLE( EngineObject )
50  RTTR_REGISTRATION_FRIEND
51 private:
52 protected:
53 
55 
56  // Properties
57  float m_width;
58  float m_maxWidth;
59  float m_minWidth;
60  float m_height;
61  float m_maxHeight;
62  float m_minHeight;
63 
64  bool m_isVisible : 1;
65  bool m_isEnabled : 1;
66  bool m_isMouseOver : 1;
67  bool m_isFocused : 1;
68  bool m_isFocusable : 1;
69 
72 
74 
76 
77 public:
78  IControl ( IControl* parent );
79  virtual ~IControl ();
80 
81  virtual bool HitTest ( Position mouse, const Rect& parentArea );
82 
83  const std::string& GetName ();
84 
85 protected:
86 
87  IControl* GetParent () { return m_parent; }
89  HostWindow* GetHost ();
90 
91 public:
92  // Event handlers
93 
94  virtual void OnLoaded ( IControl* sender, IEventArgs* e ) { }
95  virtual void Unloaded ( IControl* sender, IEventArgs* e ) { }
96 
97  virtual void GotFocus ( IControl* sender, IEventArgs* e ) { }
98  virtual void LostFocus ( IControl* sender, IEventArgs* e ) { }
99 
100  // Mouse
101  virtual void MouseEnter ( IControl* sender, MouseEventArgs* e ) { }
102  virtual void MouseLeave ( IControl* sender, MouseEventArgs* e ) { }
103  virtual void MouseMove ( IControl* sender, MouseEventArgs* e ) { }
104  virtual void MouseWheel ( IControl* sender, MouseWheelEventArgs* e ) { }
105 
106  virtual void MouseDown ( IControl* sender, MouseButtonEventArgs* e ) { }
107  virtual void MouseUp ( IControl* sender, MouseButtonEventArgs* e ) { }
108 
109  virtual void MouseRightButtonDown ( IControl* sender, MouseButtonEventArgs* e ) { }
110  virtual void MouseRightButtonUp ( IControl* sender, MouseButtonEventArgs* e ) { }
111 
112  virtual void MouseLeftButtonDown ( IControl* sender, MouseButtonEventArgs* e ) { }
113  virtual void MouseLeftButtonUp ( IControl* sender, MouseButtonEventArgs* e ) { }
114 
115 
116  virtual void PreviewMouseEnter ( IControl* sender, MouseEventArgs* e ) { }
117  virtual void PreviewMouseLeave ( IControl* sender, MouseEventArgs* e ) { }
118  virtual void PreviewMouseMove ( IControl* sender, MouseEventArgs* e ) { }
119  virtual void PreviewMouseWheel ( IControl* sender, MouseWheelEventArgs* e ) { }
120 
121  virtual void PreviewMouseDown ( IControl* sender, MouseButtonEventArgs* e ) { }
122  virtual void PreviewMouseUp ( IControl* sender, MouseButtonEventArgs* e ) { }
123 
125  virtual void PreviewMouseRightButtonUp ( IControl* sender, MouseButtonEventArgs* e ) { }
126 
128  virtual void PreviewMouseLeftButtonUp ( IControl* sender, MouseButtonEventArgs* e ) { }
129 
130  //Keyboard
131  virtual void KeyDown ( IControl* sender, KeyEventArgs* e ) { }
132  virtual void KeyUp ( IControl* sender, KeyEventArgs* e ) { }
133 
134  virtual void PreviewKeyDown ( IControl* sender, KeyEventArgs* e ) { }
135  virtual void PreviewKeyUp ( IControl* sender, KeyEventArgs* e ) { }
136 
137 
138 };
139 
140 } // gui
141 
142 } // sw
float m_minWidth
Definition: IControl.h:59
bool m_isEnabled
Definition: IControl.h:65
Base class for events.
Definition: IEventArgs.h:27
virtual void PreviewMouseUp(IControl *sender, MouseButtonEventArgs *e)
Definition: IControl.h:122
virtual void MouseWheel(IControl *sender, MouseWheelEventArgs *e)
Definition: IControl.h:104
HostWindow * GetHost()
Zwraca obiekt zarządzający GUI.
Definition: IControl.cpp:39
virtual void PreviewMouseWheel(IControl *sender, MouseWheelEventArgs *e)
Definition: IControl.h:119
virtual void MouseUp(IControl *sender, MouseButtonEventArgs *e)
Definition: IControl.h:107
const std::string & GetName()
float m_maxHeight
Definition: IControl.h:61
virtual void PreviewKeyDown(IControl *sender, KeyEventArgs *e)
Definition: IControl.h:134
virtual void KeyDown(IControl *sender, KeyEventArgs *e)
Definition: IControl.h:131
virtual void MouseRightButtonDown(IControl *sender, MouseButtonEventArgs *e)
Definition: IControl.h:109
Mouse button clicked event.
Definition: MouseButtonEventArgs.h:22
IControl * GetParent()
Definition: IControl.h:87
VerticalAlignment m_verticalAlignement
Definition: IControl.h:70
virtual void LostFocus(IControl *sender, IEventArgs *e)
Definition: IControl.h:98
Definition: DirectInputModule.cpp:11
TopLevelControl * GetRootControl()
Zwraca najwyższą w hierarchi kontrolkę.
Definition: IControl.cpp:30
Key state changed event.
Definition: KeyEventArgs.h:21
Klasa bazowa dla kontrolek.
Definition: IControl.h:47
virtual void MouseMove(IControl *sender, MouseEventArgs *e)
Definition: IControl.h:103
virtual void MouseLeftButtonDown(IControl *sender, MouseButtonEventArgs *e)
Definition: IControl.h:112
float m_height
Definition: IControl.h:60
Rectangle structure.
Definition: CommonTypes.h:32
IControl * m_parent
Definition: IControl.h:54
Base class for mouse input events.
Definition: MouseEventArgs.h:22
virtual void PreviewMouseDown(IControl *sender, MouseButtonEventArgs *e)
Definition: IControl.h:121
virtual void PreviewKeyUp(IControl *sender, KeyEventArgs *e)
Definition: IControl.h:135
Definition: Thickness.h:8
float m_minHeight
Definition: IControl.h:62
virtual bool HitTest(Position mouse, const Rect &parentArea)
virtual void PreviewMouseRightButtonUp(IControl *sender, MouseButtonEventArgs *e)
Definition: IControl.h:125
virtual void PreviewMouseEnter(IControl *sender, MouseEventArgs *e)
Definition: IControl.h:116
virtual void PreviewMouseRightButtonDown(IControl *sender, MouseButtonEventArgs *e)
Definition: IControl.h:124
virtual void KeyUp(IControl *sender, KeyEventArgs *e)
Definition: IControl.h:132
IControl(IControl *parent)
Definition: IControl.cpp:20
Mouse wheel changed position.
Definition: MouseWheelEventArgs.h:19
EngineObject * m_dataContext
Definition: IControl.h:75
Thickness m_margin
Definition: IControl.h:73
VerticalAlignment
Definition: IControl.h:28
Klasa bazowa dla obiektów, które mają być dostępne w edytorze poprzez rttr. Należy po niej odziedzicz...
Definition: EngineObject.h:22
virtual void MouseEnter(IControl *sender, MouseEventArgs *e)
Definition: IControl.h:101
float m_width
Definition: IControl.h:57
HorizontalAlignment m_horizontalAlignement
Definition: IControl.h:71
virtual void MouseDown(IControl *sender, MouseButtonEventArgs *e)
Definition: IControl.h:106
virtual ~IControl()
Definition: IControl.cpp:25
DirectX::XMFLOAT2 Position
Definition: CommonTypes.h:27
bool m_isMouseOver
Definition: IControl.h:66
bool m_isFocusable
Definition: IControl.h:68
virtual void MouseLeftButtonUp(IControl *sender, MouseButtonEventArgs *e)
Definition: IControl.h:113
virtual void MouseLeave(IControl *sender, MouseEventArgs *e)
Definition: IControl.h:102
virtual void PreviewMouseLeftButtonDown(IControl *sender, MouseButtonEventArgs *e)
Definition: IControl.h:127
float m_maxWidth
Definition: IControl.h:58
virtual void OnLoaded(IControl *sender, IEventArgs *e)
Definition: IControl.h:94
virtual void PreviewMouseLeave(IControl *sender, MouseEventArgs *e)
Definition: IControl.h:117
virtual void Unloaded(IControl *sender, IEventArgs *e)
Definition: IControl.h:95
virtual void GotFocus(IControl *sender, IEventArgs *e)
Definition: IControl.h:97
virtual void MouseRightButtonUp(IControl *sender, MouseButtonEventArgs *e)
Definition: IControl.h:110
HorizontalAlignment
Definition: IControl.h:36
virtual void PreviewMouseMove(IControl *sender, MouseEventArgs *e)
Definition: IControl.h:118
bool m_isVisible
Definition: IControl.h:64
bool m_isFocused
Definition: IControl.h:67
Definition: TopLevelControl.h:13
Root class for controls hierarchy, contains native window.
Definition: HostWindow.h:33
virtual void PreviewMouseLeftButtonUp(IControl *sender, MouseButtonEventArgs *e)
Definition: IControl.h:128