1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
//PORTABLE
#ifndef _TEXTBAR_H
#define _TEXTBAR_H
#include <bfc/virtualwnd.h>
#include <bfc/autobitmap.h>
#include <bfc/textalign.h>
class CheckWnd;
#define TEXTBAR_PARENT VirtualWnd
/**
TextBar uses the BaseWnd name field of the object as the text
to be displayed.
@short TextBar control.
@author Nullsoft
@ver 1.0
@see LabelWnd
*/
class TextBar : public VirtualWnd {
public:
/**
Sets the default flags of the TextBar. Defaults to 16px fonts,
no background texture, left justified text, shadowed text in
the bgcolor, no outline, not box around the text.
*/
TextBar();
/**
Event is triggered when the window requires a repaint.
Override this to implement your own behavior.
Paints the bitmap on canvas according to current
options (centering, tiling, stretching, title).
@ret 0 for failure, 1 for success
@param canvas The canvas on which to paint.
*/
virtual int onPaint(Canvas *canvas);
/**
Event is triggered when the name of the window is changed.
Override this to implement your own behavior.
@see BaseWnd::setName()
*/
virtual void onSetName();
/**
Set the text to be displayed to an ascii representation of a numeric value.
@ret 1.
@param i The numeric value to be displayed.
*/
int setInt(int i);
/**
Set the size of the text for the textbar.
@ret 1, success; 0, failure.
@param newsize The new text size, range is from 1 to 72 pixels.
*/
int setTextSize(int newsize);
/**
Get the width of the text displayed, in pixels.
@ret Width of the displayed text (in pixels).
*/
int getTextWidth();
/**
Get the height of the text displayed, in pixels.
@ret Height of the displayed text.
*/
int getTextHeight();
/**
Use the base texture when rendering the TextBar?
If the base texture is used, it will be rendered as
the background of the textbar.
@param u !0, Use base texture; 0, Do not use base texture;
*/
void setUseBaseTexture(int u);
/**
Event is triggered when the left mouse button is pressed while
the textbar has focus. Override this to implement your
own behavior.
@param x X coordinate of the mouse pointer.
@param y Y coordinate of the mouse pointer.
*/
virtual int onLeftButtonDown(int x, int y);
/**
Center the text in the textbar? If not,
it will be left justified by default.
@param center !0, Center text; 0, Do not center text;
*/
// void setCenter(int center); //old code
/**
Get the center text flag.
@see setCenter()
@ret TRUE, Text is being centered; FALSE, No centering (left justified);
*/
// bool getCentered();
/**
Sets the alignment of the text to left, center, or right aligned
(possibly more later on, not too sure yet)
*/
void setAlign(TextAlign alignment);
/**
@ret returns the alignment of the text
*/
TextAlign getAlign();
// The following three options have ascending overriding priority --
/**
Sets the shadowed text flag. If enabled, the text will be shadowed
with the "bgcolor" value.
@see getTextShadowed()
@param settextshadowed !0, Shadow the text; 0, Do not shadow the text;
*/
void setTextShadowed(int settextshadowed) {
textshadowed = !!settextshadowed;
}
/**
Get the shadowed text flag. If enabled, the text will be shadowed
with the "bgcolor" value.
@see setTextShadowed()
@ret !0, Shadow the text; 0, Do not shadow the text;
*/
int getTextShadowed() {
return textshadowed;
}
/**
Sets the outline text flag. If enabled, the text will be
outlined with the "bgcolor" value.
@param settextoutlined !0, Outline the text; 0, Do not outline the text;
*/
void setTextOutlined(int settextoutlined) {
textoutlined = !!settextoutlined;
}
/**
Get the outline text flag. If enabled, the text will be
outlined with the "bgcolor" value.
@ret !0, Outline the text; 0, Do not outline the text;
*/
int getTextOutlined() {
return textoutlined;
}
/**
Set the drawbox flag. If true, the drawbox flag will cause
a box to be drawn around the text in the textbar.
@param setdrawbox !0, Drawbox around the text; 0, No drawbox;
*/
void setDrawBox(int setdrawbox) {
drawbox = !!setdrawbox;
}
/**
Get the drawbox flag. If true, the drawbox flag will cause
a box to be drawn around the text in the textbar.
@ret !0, Drawbox around the text; 0, No drawbox;
*/
int getDrawBox() {
return drawbox;
}
/**
Associate a checkbox with the textbar. When a textbar is linked
to a checkbox, it will toggle the checkbox when it receives
left clicks.
@param target A pointer to the CheckWnd to link.
*/
void setAutoToggleCheckWnd(CheckWnd *target) {
checkwndtarget = target;
}
private:
int size;
int usebt;
TextAlign alignment; //i changed this from centered, to a set text alignment thingie
int textshadowed; // display a shadow of the text in bgcolor. default: on
int textoutlined; // draw an outline of the text in bgcolor. default: off
int drawbox; // draw a box of bgcolor the size of the boundsrect. default: off
AutoSkinBitmap bgbitmap;
CheckWnd *checkwndtarget;
};
const int TEXTBAR_LEFTMARGIN = 2;
#endif
|