GUI
include
Widget.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017 by Maciej Wiecierzewski
3
*/
4
5
#ifndef WIDGET_H
6
#define WIDGET_H
7
8
#include <functional>
9
#include <string>
10
#include <forward_list>
11
12
#include "
Renderer.h
"
13
#include "
EventEmitter.h
"
14
#include "
Event.h
"
15
16
namespace
gui
17
{
18
19
class
Event;
20
22
23
class
Widget
:
public
EventEmitter
24
{
25
public
:
26
typedef
char
State
;
27
enum
states
{
STATE_HOVER
,
STATE_DOWN
,
STATE_UP
};
28
29
Widget
();
30
Widget
(
int
x
,
int
y
,
int
w
,
int
h
);
31
virtual
~Widget
();
32
33
virtual
void
render
(
Renderer
*renderer);
34
virtual
void
keyChar
(
int
uchar);
35
virtual
void
keyDown
(
int
keyCode);
36
virtual
void
mouseMove
(
int
x,
int
y);
37
virtual
void
stateChange
(State
state
);
38
virtual
void
focusIn
();
39
virtual
void
focusOut
();
40
41
void
addChild
(
Widget
*widget);
42
void
removeChild
(
Widget
*widget);
43
void
setParent
(
Widget
*widget);
44
void
resize
(
int
x,
int
y,
int
w,
int
h);
45
void
updateAbs
();
46
47
void
setVisibility
(
bool
visible
);
48
49
bool
contain
(
int
posX,
int
posY);
50
bool
isFocused
() {
return
focused
; };
51
State
getState
() {
return
state
; };
52
53
protected
:
54
int
x
,
y
,
w
,
h
;
55
int
xAbs
,
yAbs
;
56
int
state
;
57
bool
focused
;
58
bool
visible
;
59
60
private
:
61
Widget
*
parent
;
62
std::forward_list<Widget*>
children
;
63
64
friend
class
GUISystem
;
65
};
66
67
}
68
69
#endif // WIDGET_H
Generated on Sat Feb 11 2017 20:22:32 for GUI by
1.8.13