Vegastrike 0.5.1 rc1
1.0
Original sources for Vegastrike Evolved
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
window.h
Go to the documentation of this file.
1
/*
2
* Vega Strike
3
* Copyright (C) 2003 Mike Byron
4
*
5
* http://vegastrike.sourceforge.net/
6
*
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 2
10
* of the License, or (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
*/
21
22
#ifndef __WINDOW_H__
23
#define __WINDOW_H__
24
25
#include "
eventresponder.h
"
26
#include "
guitexture.h
"
27
28
#include <vector>
29
30
//Forward reference.
31
class
Control
;
32
class
WindowController
;
33
class
GroupControl
;
34
35
/* The Window class owns an area of the screen. It manages the
36
* controls it contains, doing event handling and drawing.
37
*/
38
class
Window
:
public
EventResponder
39
{
40
public
:
41
42
//The outside boundaries of the window.
43
virtual
void
setRect
(
const
Rect
&r );
44
void
setFullScreen
(
void
);
45
void
setSizeAndCenter
(
const
Size
&
size
);
46
47
//Initially display the window.
48
//Call this when all the properties and controls of the window are set.
49
virtual
void
open
(
void
);
50
51
//Done with the window. This will normally delete the window object.
52
virtual
void
close
(
void
);
53
54
//Manage controls.
55
virtual
void
addControl
(
Control
*
c
);
56
virtual
void
deleteControl
(
Control
*c );
57
58
//Take a control away from this window and save it elsewhere.
59
virtual
Control
*
removeControlFromWindow
(
Control
*c );
60
61
//Find a control using its id. NULL returned if none found.
62
//Note that the control may be hidden.
63
virtual
Control
*
findControlById
(
const
std::string &
id
);
64
65
//The background color of the window.
66
virtual
GFXColor
color
(
void
)
67
{
68
return
m_color
;
69
}
70
virtual
void
setColor
(
const
GFXColor
&c )
71
{
72
m_color
=
c
;
73
}
74
75
//The background texture for the window.
76
virtual
GuiTexture
&
texture
(
void
)
77
{
78
return
m_texture
;
79
}
80
virtual
void
setTexture
(
const
std::string &textureName )
81
{
82
m_texture
.
read
( textureName );
83
}
84
85
//The color of the outline around the window.
86
virtual
GFXColor
outlineColor
(
void
)
87
{
88
return
m_outlineColor
;
89
}
90
virtual
void
setOutlineColor
(
const
GFXColor
&c )
91
{
92
m_outlineColor
=
c
;
93
}
94
95
//The width of the outline around the window (in pixels).
96
virtual
float
outlineWidth
(
void
)
97
{
98
return
m_outlineWidth
;
99
}
100
virtual
void
setOutlineWidth
(
float
width
)
101
{
102
m_outlineWidth
=
width
;
103
}
104
105
//Set up a controller object.
106
virtual
WindowController
*
controller
(
void
)
107
{
108
return
m_controller
;
109
}
110
virtual
void
setController
(
WindowController
*
controller
)
111
{
112
m_controller
=
controller
;
113
}
114
115
//Draw the window.
116
virtual
void
draw
(
void
);
117
118
//Read window properties and controls from an XML file.
119
virtual
void
readFromXml
(
const
std::string &fileName );
120
121
//Set whether to delete this object when it closes.
122
virtual
bool
deleteOnClose
(
void
)
123
{
124
return
m_deleteOnClose
;
125
}
126
virtual
void
setDeleteOnClose
(
bool
del )
127
{
128
m_deleteOnClose
= del;
129
}
130
131
//OVERRIDES
132
virtual
bool
processMouseDown
(
const
InputEvent
&event );
133
virtual
bool
processMouseUp
(
const
InputEvent
&event );
134
virtual
bool
processMouseMove
(
const
InputEvent
&event );
135
virtual
bool
processMouseDrag
(
const
InputEvent
&event );
136
virtual
bool
processCommand
(
const
EventCommandId
&command,
Control
*control );
137
138
//CONSTRUCTION
139
public
:
140
virtual
~Window
();
141
Window
();
142
143
//INTERNAL IMPLEMENTATION
144
protected
:
145
//Draw window background.
146
void
drawBackground
(
void
);
147
148
//VARIABLES
149
protected
:
150
Rect
m_rect
;
//Rectangle representing window.
151
GFXColor
m_color
;
//Background color of window.
152
GFXColor
m_outlineColor
;
//Color of outline around control.
153
float
m_outlineWidth
;
//Width of outline (in pixels).
154
GuiTexture
m_texture
;
//Background texture.
155
bool
m_deleteOnClose
;
//True = delete window object when closed.
156
GroupControl
*
m_controls
;
//List of controls that are in this window.
157
WindowController
*
m_controller
;
//Object that controls this window.
158
};
159
160
//This class keeps track of windows, maintaining z-order and rendering them.
161
class
WindowManager
162
{
163
public
:
164
friend
class
Window
;
//Most operations here are done only by windows.
165
166
//Draw all visible windows.
167
void
draw
();
168
169
//Shut down all windows.
170
void
shutDown
(
void
);
171
172
protected
:
173
//A new window has been created and is ready to be drawn.
174
void
openWindow
(
Window
*w );
175
//A window has been closed.
176
void
closeWindow
(
Window
*w,
bool
deleteWindow =
true
);
177
178
//VARIABLES
179
std::vector< Window* >
m_windows
;
//Array of windows. Last entry is top window.
180
};
181
182
//Get the one window manager.
183
WindowManager
&
globalWindowManager
(
void
);
184
185
#endif //__WINDOW_H__
186
src
gui
window.h
Generated on Fri May 29 2015 23:07:33 for Vegastrike 0.5.1 rc1 by
1.8.4