SCV
4.2.1
Simple Components for Visual
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
Component.h
Go to the documentation of this file.
1
7
#ifndef __SCV_COMPONENT__H__
8
#define __SCV_COMPONENT__H__
9
10
#include "
SCVCallbacks.h
"
11
#include "
Point.h
"
12
#include "
Scissor.h
"
13
14
namespace
scv {
15
16
class
ContextMenu;
17
class
Kernel;
18
19
//This is the basic component of the SCV. Most widgets inherit this class.
20
class
Component
:
public
SCVCallbacks
{
21
public
:
22
enum
Type
{
23
NONE
,
PANEL
,
COLORPICKER
,
PROGRESSBAR
,
24
SCROLL
,
SLIDER
,
SPINNER
,
BUTTON
,
25
CHECKBOX
,
RADIOBUTTON
,
TOGGLEBUTTON
,
TEXTFIELD
,
26
TEXTBOX
,
SEPARATOR
,
WINDOW
,
MENUBAR
,
27
TABBEDPANE
,
SCROLLCOMPONENT
,
IMAGE
,
TABLE
,
28
COMBOBOX
,
CANVAS
,
TREEVIEW
,
LABEL
,
29
CONTEXTMENU
,
GENERICTREE
,
30
31
NOFWIDGETS
32
};
33
typedef
std::list<Component*>
List
;
34
35
Component
(
const
scv::Point
&p1,
const
scv::Point
&p2);
36
virtual
~Component
(
void
);
37
38
//position
39
virtual
Point
getRelativePosition
(
void
)
const
;
40
virtual
void
setRelativePosition
(
const
Point
&position);
41
42
virtual
Point
getAbsolutePosition
(
void
)
const
;
43
virtual
void
setAbsolutePosition
(
const
Point
&position);
44
45
//size
46
virtual
inline
int
getWidth
(
void
)
const
;
47
virtual
void
setWidth
(
int
width);
48
49
virtual
inline
int
getHeight
(
void
)
const
;
50
virtual
void
setHeight
(
int
height);
51
52
virtual
inline
Point
getSize
(
void
)
const
;
53
virtual
inline
void
setSize
(
int
width,
int
height);
54
55
virtual
void
setMinimumSize
(
const
scv::Point
&size);
56
virtual
Point
getMinimumSize
(
void
)
const
;
57
58
virtual
void
setPreferredSize
(
const
scv::Point
&size);
59
virtual
Point
getPreferredSize
(
void
)
const
;
60
61
virtual
void
setMaximumSize
(
const
scv::Point
&size);
62
virtual
Point
getMaximumSize
(
void
)
const
;
63
64
virtual
inline
bool
isOvered
(
void
)
const
;
65
virtual
inline
bool
isHolded
(
void
)
const
;
66
virtual
inline
bool
isDragging
(
void
)
const
;
67
virtual
inline
bool
isResizing
(
void
)
const
;
68
69
virtual
bool
isFocused
(
void
)
const
;
70
71
virtual
inline
void
setDraggable
(
bool
state);
72
virtual
inline
bool
isDraggable
(
void
)
const
;
73
74
virtual
inline
void
setResizable
(
bool
state);
75
virtual
inline
bool
isResizable
(
void
)
const
;
76
77
virtual
inline
void
setVisible
(
bool
state);
78
virtual
inline
bool
isVisible
(
void
)
const
;
79
80
inline
ContextMenu
*
getContextMenu
(
void
)
const
;
81
virtual
void
registerContextMenu
(
ContextMenu
*contextMenu);
82
virtual
void
unregisterContextMenu
(
void
);
83
84
virtual
bool
isInside
(
const
Point
&evtPosition)
const
;
85
86
virtual
bool
getCallbacksStatus
(
void
)
const
;
87
virtual
void
setCallbacksStatus
(
bool
state);
88
89
virtual
Scissor::Info
getParentScissor
(
void
)
const
;
90
virtual
Scissor::Info
getScissor
(
void
)
const
;
91
92
virtual
void
processMouse
(
const
scv::MouseEvent
&evt);
93
virtual
void
processKey
(
const
scv::KeyEvent
&evt);
94
95
virtual
void
display
(
void
) = 0;
96
97
Type
getType
(
void
);
98
void
setType
(
Type
type);
99
100
//memory management
101
void
setParent
(
Component
*parent);
102
inline
Component
*
getParent
(
void
)
const
;
103
104
inline
const
Component::List
&
getChildren
(
void
)
const
;
105
virtual
void
addChild
(
Component
*
object
);
106
virtual
void
removeChild
(
Component
*
object
);
107
virtual
void
removeAllChild
(
void
);
108
virtual
Component
*
getChild
(
int
index)
const
;
109
void
pullChildToTop
(
Component
*child);
110
bool
hasChild
(
Component
*child)
const
;
111
Component::List
_children
;
112
113
protected
:
114
Component
*
_parent
;
115
116
Type
_type
;
117
static
const
int
s_mouseBacklash
= 4;
118
119
Point
_p1
,
_p2
,
_clickDiff
;
120
Point
_minimumSize
,
_preferredSize
,
_maximumSize
;
121
122
bool
_receivingCallbacks
;
123
bool
_isResizable
,
_isResizing
;
124
bool
_isHResizable
,
_isVResizable
;
125
bool
_isDraggable
,
_isDragging
;
126
bool
_isOvered
,
_isHolded
;
127
bool
_isVisible
;
128
129
void
setResizingCursor
(
void
);
130
131
enum
Side
{
LEFT
,
RIGHT
,
TOP
,
BOTTOM
};
132
std::vector<bool>
_resizing
;
133
bool
isInsideSide
(
Component::Side
side,
const
Point
&evtPosition);
134
135
ContextMenu
*
_contextMenu
;
136
};
137
139
140
int
Component::getWidth
(
void
)
const
{
141
return
_p2
.
x
-
_p1
.
x
;
142
}
143
144
int
Component::getHeight
(
void
)
const
{
145
return
_p2
.
y
-
_p1
.
y
;
146
}
147
148
void
Component::setSize
(
int
width,
int
height) {
149
setWidth
(width);
150
setHeight
(height);
151
}
152
153
Point
Component::getSize
(
void
)
const
{
154
return
Point
(
getWidth
(),
getHeight
());
155
}
156
157
bool
Component::isOvered
(
void
)
const
{
158
return
_isOvered
;
159
}
160
161
bool
Component::isHolded
(
void
)
const
{
162
return
_isHolded
;
163
}
164
165
bool
Component::isDragging
(
void
)
const
{
166
return
_isDragging
;
167
}
168
169
bool
Component::isResizing
(
void
)
const
{
170
return
_isResizing
;
171
}
172
173
void
Component::setDraggable
(
bool
state) {
174
_isDraggable
= state;
175
}
176
177
bool
Component::isDraggable
(
void
)
const
{
178
return
_isDraggable
;
179
}
180
181
void
Component::setResizable
(
bool
state) {
182
_isResizable
= state;
183
}
184
185
bool
Component::isResizable
(
void
)
const
{
186
return
_isResizable
;
187
}
188
189
void
Component::setVisible
(
bool
state) {
190
_isVisible
= state;
191
}
192
193
bool
Component::isVisible
(
void
)
const
{
194
return
_isVisible
;
195
}
196
197
ContextMenu
*
Component::getContextMenu
(
void
)
const
{
198
return
_contextMenu
;
199
}
200
201
Component
*
Component::getParent
(
void
)
const
{
202
return
_parent
;
203
}
204
205
const
Component::List
&
Component::getChildren
(
void
)
const
{
206
return
_children
;
207
}
208
209
}
// namespace scv
210
211
#endif // __SCV_COMPONENT__H__
include
SCV
Component.h
Generated on Fri Dec 14 2012 09:44:48 for SCV by
1.8.2