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
simplepicker.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 __SIMPLEPICKER_H__
23
#define __SIMPLEPICKER_H__
24
25
#include "
picker.h
"
26
27
//See cpp file for detailed descriptions of classes, functions, etc.
28
29
class
SimplePickerCells
;
//Forward reference.
30
31
//One entry in a SimplePicker.
32
//This is a simple value class
33
class
SimplePickerCell
:
public
PickerCell
34
{
35
public
:
36
//The text to be displayed.
37
virtual
std::string
text
(
void
)
const
38
{
39
return
m_text
;
40
}
41
//A unique identifier for the cell.
42
virtual
std::string
id
(
void
)
const
43
{
44
return
m_id
;
45
}
46
//The color of the text.
47
virtual
GFXColor
textColor
(
void
)
const
48
{
49
return
m_textColor
;
50
}
51
//List of children.
52
virtual
PickerCells
*
children
(
void
)
const
53
{
54
return
(
PickerCells
*)
m_children
;
55
}
56
//Unique identifier for this cell.
57
virtual
int
tag
(
void
)
const
58
{
59
return
m_tag
;
60
}
61
62
virtual
void
setTextColor
(
const
GFXColor
&
c
)
63
{
64
m_textColor
=
c
;
65
}
66
67
//Add a child to the list of children of this cell.
68
void
addChild
(
SimplePickerCell
*
c
);
69
//Make sure there is an empty list for children.
70
SimplePickerCells
*
createEmptyChildList
(
void
);
71
72
//CONSTRUCTION
73
SimplePickerCell
(
const
std::string &t,
const
std::string &
id
=
""
,
const
GFXColor
&
c
=
GUI_CLEAR
,
int
newTag = 0 );
74
virtual
~SimplePickerCell
(
void
);
75
76
//OPERATIONS
77
SimplePickerCell
&
operator=
(
const
SimplePickerCell
&cell );
78
SimplePickerCell
(
const
SimplePickerCell
&cell );
79
80
protected
:
81
std::string
m_text
;
82
std::string
m_id
;
83
GFXColor
m_textColor
;
84
int
m_tag
;
85
SimplePickerCells
*
m_children
;
86
};
87
88
//A list of Picker cells to show.
89
class
SimplePickerCells
:
public
PickerCells
90
{
91
public
:
92
//Number of cells in this list.
93
virtual
int
count
(
void
)
const
94
{
95
return
m_cells
.size();
96
}
97
//Get a particular cell.
98
virtual
PickerCell
*
cellAt
(
int
index
)
99
{
100
return
m_cells
[
index
];
101
}
102
virtual
const
PickerCell
*
cellAt
(
int
index
)
const
103
{
104
return
m_cells
[
index
];
105
}
106
107
//Add a new cell to this list.
108
virtual
void
addCell
(
PickerCell
*
c
)
109
{
110
m_cells
.push_back( c );
111
}
112
113
//Clear out all the cells.
114
virtual
void
clear
(
void
);
115
116
//CONSTRUCTION
117
SimplePickerCells
(
void
);
118
virtual
~SimplePickerCells
(
void
)
119
{
120
clear
();
121
}
122
123
protected
:
124
std::vector< PickerCell* >
m_cells
;
125
};
126
127
//The Picker class supports a list of items that can be
128
//scrolled and selected.
129
//The list can be a tree. When a branch is selected, its children
130
//are displayed. When it is selected again, they are hidden.
131
class
SimplePicker
:
public
Picker
132
{
133
public
:
134
//Add a new cell to this control.
135
void
addCell
(
SimplePickerCell
*
c
)
136
{
137
static_cast<
SimplePickerCells
*
>
(
m_cells
)->
addCell
( c );
138
}
139
140
//Clear out all the cells.
141
void
clear
(
void
);
142
143
SimplePicker
(
void
);
144
virtual
~SimplePicker
(
void
);
145
};
146
147
//This is a picker cell that can hold any type of data
148
//by using templates.
149
template
<
class
T >
150
class
ValuedPickerCell
:
public
SimplePickerCell
151
{
152
public
:
153
//CONSTRUCTION
154
ValuedPickerCell
( T
value
,
155
const
std::string
text
,
156
const
std::string &
id
=
""
,
157
const
GFXColor
&
c
=
GUI_CLEAR
,
158
int
newTag = 0 ) :
159
SimplePickerCell
( text,
id
,
c
, newTag )
160
,
m_value
( value ) {}
161
162
virtual
~ValuedPickerCell
(
void
) {}
163
164
//The type associated with the cell.
165
T
value
(
void
)
const
166
{
167
return
m_value
;
168
}
169
170
ValuedPickerCell
(
const
ValuedPickerCell
&cell ) :
171
SimplePickerCell
( cell )
172
,
m_value
( cell.
m_value
) {}
173
174
protected
:
175
T
m_value
;
176
};
177
178
#endif //__SIMPLEPICKER_H__
179
src
gui
simplepicker.h
Generated on Fri May 29 2015 23:07:33 for Vegastrike 0.5.1 rc1 by
1.8.4