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
staticdisplay.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 __STATICDISPLAY_H__
23
#define __STATICDISPLAY_H__
24
25
#include "
control.h
"
26
#include "
painttext.h
"
27
#include "
guitexture.h
"
28
29
//See cpp file for detailed descriptions of classes, functions, etc.
30
31
//FORWARD REFERENCES.
32
class
Scroller
;
33
34
//The StaticDisplay class is used to show something on a window.
35
//Right now, it only supports text, but could be expanded to support
36
//images, textures, meshes, etc.
37
//This control does not respond to input events.
38
39
class
StaticDisplay
:
public
Control
40
{
41
public
:
42
//Draw the control.
43
virtual
void
draw
(
void
);
44
45
//Text that appears on the control.
46
virtual
std::string
text
(
void
)
47
{
48
return
m_paintText
.
text
();
49
}
50
virtual
void
setText
( std::string t )
51
{
52
m_paintText
.
setText
( t );
53
}
54
55
//Set justification.
56
virtual
Justification
justification
(
void
)
57
{
58
return
m_paintText
.
justification
();
59
}
60
virtual
void
setJustification
(
Justification
j )
61
{
62
m_paintText
.
setJustification
( j );
63
}
64
65
//Whether the text is multi-line.
66
virtual
bool
multiLine
(
void
)
67
{
68
return
m_paintText
.
widthExceeded
() ==
PaintText::MULTI_LINE
;
69
}
70
virtual
void
setMultiLine
(
bool
multi )
71
{
72
m_paintText
.
setWidthExceeded
( multi ?
PaintText::MULTI_LINE
:
PaintText::ELLIPSIS
);
73
}
74
75
//Text margins.
76
virtual
Size
textMargins
(
void
)
77
{
78
return
m_textMargins
;
79
}
80
virtual
void
setTextMargins
(
const
Size
&s );
81
82
//Set the object that takes care of scrolling.
83
virtual
void
setScroller
(
Scroller
*s );
84
85
//OVERRIDES
86
87
//Color of text in control.
88
virtual
GFXColor
textColor
(
void
)
89
{
90
return
m_paintText
.
color
();
91
}
92
virtual
void
setTextColor
(
const
GFXColor
&
c
)
93
{
94
m_paintText
.
setColor
( c );
95
}
96
97
//Font for text in control.
98
virtual
Font
font
(
void
)
99
{
100
return
m_paintText
.
font
();
101
}
102
virtual
void
setFont
(
const
Font
&f )
103
{
104
m_paintText
.
setFont
( f );
105
}
106
107
//The outside boundaries of the control.
108
virtual
void
setRect
(
const
Rect
&r );
109
110
//OVERRIDES - used for scrolling.
111
virtual
bool
processMouseDown
(
const
InputEvent
&event );
112
113
//Process a command event.
114
virtual
bool
processCommand
(
const
EventCommandId
&command,
Control
*control );
115
116
//CONSTRUCTION
117
public
:
StaticDisplay
(
void
);
118
virtual
~StaticDisplay
(
void
) {}
119
120
protected
:
121
//INTERNAL IMPLEMENTATION
122
123
//The rect for the text object has changed -- reset it.
124
void
setPaintTextRect
(
void
);
125
126
//VARIABLES
127
protected
:
128
PaintText
m_paintText
;
//Text object.
129
Size
m_textMargins
;
//Inset area where no text appears.
130
int
m_scrollPosition
;
//Index of first display cell shown.
131
int
m_layoutVersion
;
//A way to tell when the PaintText layout has changed.
132
Scroller
*
m_scroller
;
133
};
134
135
class
StaticImageDisplay
:
public
Control
136
{
137
public
:
138
//Draw the control.
139
virtual
void
draw
(
void
)
140
{
141
if
(
texturename
.length() )
texture
.
draw
(
m_rect
);
142
}
143
144
//Text that appears on the control.
145
virtual
void
setTexture
( std::string t )
146
{
147
texturename
= t;
148
texture
.
read
( t );
149
}
150
151
//CONSTRUCTION
152
public
:
StaticImageDisplay
(
void
) {}
153
virtual
~StaticImageDisplay
(
void
) {}
154
155
protected
:
156
std::string
texturename
;
157
GuiTexture
texture
;
158
//INTERNAL IMPLEMENTATION
159
};
160
161
#endif //__STATICDISPLAY_H__
162
src
gui
staticdisplay.h
Generated on Fri May 29 2015 23:07:33 for Vegastrike 0.5.1 rc1 by
1.8.4