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
Kernel.h
Go to the documentation of this file.
1
/*
2
3
SCV - Simple Components for Visual
4
Developed at Federal University of Santa Maria - UFSM
5
LaCA - Computer Applied Laboratory - Laboratório de Computação Aplicada
6
webpage: www.inf.ufsm.br/~pozzer/scv
7
email: pozzer@inf.ufsm.br
8
2007-2012
9
10
*/
11
12
#ifndef __SCV_KERNEL_H__
13
#define __SCV_KERNEL_H__
14
15
#include "
Singleton.h
"
16
#include "
FontTahoma.h
"
17
18
#include "
Component.h
"
19
#include "
ComponentTexture.h
"
20
21
#include "
Panel.h
"
22
#include "
ScrollComponent.h
"
23
#include "
Scissor.h
"
24
25
#include "
ContextMenu.h
"
26
#include "
InternalFrame.h
"
27
28
#include "
Cursor.h
"
29
#include "
Timer.h
"
30
31
#include "
ColorScheme.h
"
32
33
namespace
scv {
34
42
class
Kernel
:
public
Singleton
<Kernel>,
public
SCVCallbacks
{
43
friend
class
Singleton
<
Kernel
>;
44
public
:
45
enum
TextureFilter
{
LINEAR
,
NEAREST
};
46
47
virtual
void
onDisplay
(
void
) {}
48
49
//used to init the loop handler
50
void
run
(
void
);
51
52
void
showCopyrights
(
void
);
53
54
inline
void
setFramesPerSecond
(
float
fps
);
55
inline
float
getFramesPerSecond
(
void
)
const
;
56
57
void
setWindowSize
(
unsigned
int
width,
unsigned
int
height);
58
void
setWindowTitle
(
const
std::string &title);
59
60
inline
int
getWidth
(
void
)
const
;
61
inline
int
getHeight
(
void
)
const
;
62
63
void
setFullScreen
(
bool
full);
64
void
lockWindowSize
(
bool
lock);
65
66
inline
TextureFilter
getFilterType
(
void
);
67
inline
void
setFilterType
(
TextureFilter
tex);
68
69
bool
lockMouseUse
(
Component
* component);
70
bool
unlockMouseUse
(
Component
* component);
71
72
bool
requestMouseUse
(
Component
* component);
73
74
bool
requestComponentFocus
(
Component
*component);
75
inline
Component
*
getFocusedComponent
(
void
)
const
;
76
77
bool
willAppearOnScreen
(
Component
* component);
78
79
void
applyDefaultTransformMatrix
(
void
);
80
81
std::string
getClipBoardString
(
void
)
const
;
82
void
setClipBoardString
(
const
std::string str);
83
84
void
addWindow
(
InternalFrame
*window);
85
void
addComponent
(
Component
*
object
);
86
void
removeComponent
(
Component
*
object
);
87
88
inline
void
setWidgetTexture
(
scv::Component::Type
widget,
ComponentTexture
*texture);
89
inline
ComponentTexture
*
getWidgetTexture
(
scv::Component::Type
widget);
90
91
typedef
std::list<Component*>
ComponentsList
;
92
ComponentsList
_objects
;
93
protected
:
94
Kernel
(
void
);
95
virtual
~Kernel
(
void
) {}
96
97
void
initOpenGL
(
int
argc,
char
* argv[]);
98
99
void
updateFramesPerSecond
(
void
);
100
101
//Mouse Callbacks
102
static
void
cbMouseMotion
(
int
x,
int
y);
103
static
void
cbMouseClick
(
int
button,
int
state,
int
x,
int
y);
104
static
void
cbMouseWheel
(
int
button,
int
dir,
int
x,
int
y);
105
106
//Keyboard Callbacks
107
static
void
cbKeySpecial
(
int
key,
int
x,
int
y);
108
static
void
cbKeySpecialUp
(
int
key,
int
x,
int
y);
109
static
void
cbKey
(
unsigned
char
key,
int
x,
int
y);
110
static
void
cbKeyUp
(
unsigned
char
key,
int
x,
int
y);
111
112
//Display
113
static
void
cbDisplay
(
void
);
114
115
static
const
std::string
s_defaultTitle
;
116
static
const
unsigned
int
s_defaultWidth
,
s_defaultHeight
;
117
static
const
unsigned
int
s_defaultFramesPerSecond
;
118
119
struct
{
120
bool
isFullScreen
;
121
int
currSize
[2],
userSize
[2];
122
}
Display
;
123
124
struct
{
125
int
count
,
currTime
,
prevTime
,
baseTime
;
126
float
fps
,
currFps
;
127
}
FrameRate
;
128
129
struct
{
130
int
doubleClickTime
;
131
132
Point
lastClickPosition
;
133
Timer
lastTimeClicked
;
134
MouseEvent::Button
lastButton
;
135
136
bool
clicked
,
locked
;
137
Component
*
componentRequestUse
;
138
}
Mouse
;
139
140
ComponentTexture
*
_loadedWidgets
[
Component::NOFWIDGETS
];
141
142
std::string
_windowTitle
;
143
144
TextureFilter
_filterType
;
145
146
Component
*
_focusedComponent
;
147
148
bool
_allowResizing
;
149
bool
_reshapeOnNextFrame
;
150
151
bool
_componentRequestFocus
;
152
ContextMenu
*
_contextMenu
;
153
};
154
156
void
Kernel::setFramesPerSecond
(
float
fps) {
157
FrameRate
.fps =
fps
;
158
}
159
161
inline
float
Kernel::getFramesPerSecond
(
void
)
const
{
162
return
FrameRate
.currFps;
163
}
164
165
inline
void
Kernel::setWidgetTexture
(
scv::Component::Type
widget,
ComponentTexture
*texture) {
166
_loadedWidgets
[widget] = texture;
167
}
168
169
inline
ComponentTexture
*
Kernel::getWidgetTexture
(
scv::Component::Type
widget) {
170
return
_loadedWidgets
[widget];
171
}
172
173
Kernel::TextureFilter
Kernel::getFilterType
(
void
) {
174
return
_filterType
;
175
}
176
177
void
Kernel::setFilterType
(
TextureFilter
tex) {
178
_filterType
= tex;
179
}
180
182
int
Kernel::getWidth
(
void
)
const
{
183
return
Display
.currSize[0];
184
}
185
187
int
Kernel::getHeight
(
void
)
const
{
188
return
Display
.currSize[1];
189
}
190
191
Component
*
Kernel::getFocusedComponent
(
void
)
const
{
192
return
_focusedComponent
;
193
}
194
195
}
// namespace scv
196
197
#endif // __SCV_KERNEL_H__
include
SCV
Kernel.h
Generated on Fri Dec 14 2012 09:44:49 for SCV by
1.8.2