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
control.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 __CONTROL_H__
23
#define __CONTROL_H__
24
25
#include "
eventresponder.h
"
26
#include "
font.h
"
27
28
//See cpp file for detailed descriptions of classes, functions, etc.
29
30
/* The control virtual base class manages a rectangle in a window.
31
* It handles input events (like mouse events) if necessary. It draws the
32
* rectangle it owns.
33
*/
34
class
Control
:
public
EventResponder
35
{
36
public
:
37
38
//The outside boundaries of the control.
39
virtual
Rect
rect
(
void
)
40
{
41
return
m_rect
;
42
}
43
virtual
void
setRect
(
const
Rect
&r )
44
{
45
m_rect
= r;
46
}
47
48
//Whether the specified point is inside this control.
49
virtual
bool
hitTest
(
const
Point
&p );
50
51
//Whether to show the control or not.
52
virtual
bool
hidden
(
void
)
53
{
54
return
m_hidden
;
55
}
56
virtual
void
setHidden
(
bool
h =
true
)
57
{
58
m_hidden
=
h
;
59
}
60
61
//Control have id's. This makes it easy to find them programmatically.
62
//See window::findControlById.
63
virtual
const
std::string&
id
(
void
)
64
{
65
return
m_id
;
66
}
67
virtual
void
setId
(
const
std::string &newId )
68
{
69
m_id
= newId;
70
}
71
72
//The color of the control.
73
//Meaning depends on control. Often background color.
74
virtual
GFXColor
color
(
void
)
75
{
76
return
m_color
;
77
}
78
virtual
void
setColor
(
const
GFXColor
&
c
)
79
{
80
m_color
=
c
;
81
}
82
83
//The color of the outline around the control.
84
virtual
GFXColor
outlineColor
(
void
)
85
{
86
return
m_outlineColor
;
87
}
88
virtual
void
setOutlineColor
(
const
GFXColor
&
c
)
89
{
90
m_outlineColor
=
c
;
91
}
92
93
//Color of text in control.
94
virtual
GFXColor
textColor
(
void
)
95
{
96
return
m_textColor
;
97
}
98
virtual
void
setTextColor
(
const
GFXColor
&
c
)
99
{
100
m_textColor
=
c
;
101
}
102
103
//Font for text in control.
104
virtual
Font
font
(
void
)
105
{
106
return
m_font
;
107
}
108
virtual
void
setFont
(
const
Font
&f )
109
{
110
m_font
= f;
111
}
112
113
//The list of controls "grouped" into this control.
114
virtual
bool
hasGroupChildren
(
void
)
115
{
116
return
false
;
117
}
118
119
//Draw the control.
120
//This should not draw outside its rectangle!
121
virtual
void
draw
(
void
) = 0;
122
123
//CONSTRUCTION
124
public
:
Control
(
void
);
125
virtual
~Control
(
void
) {}
126
127
protected
:
128
//INTERNAL IMPLEMENTATION
129
130
//Draw background.
131
virtual
void
drawBackground
(
void
);
132
133
//VARIABLES
134
protected
:
135
Rect
m_rect
;
//Boundary rectangle of this control.
136
std::string
m_id
;
//ID of the control. See window::findControlByName.
137
GFXColor
m_color
;
//Color of control. Meaning depends on control.
138
GFXColor
m_outlineColor
;
//Color of outline around control.
139
GFXColor
m_textColor
;
//Text color, if control uses text.
140
Font
m_font
;
//Font for the text, if text is needed.
141
bool
m_hidden
;
//False = show the control on the window.
142
};
143
144
#endif //__CONTROL_H__
145
src
gui
control.h
Generated on Fri May 29 2015 23:07:32 for Vegastrike 0.5.1 rc1 by
1.8.4