coastline
0.0.4
Loading...
Searching...
No Matches
src
win32
menufont.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <
cstdlib
>
4
#include <
cstring
>
5
6
#include <
windows.h
>
7
8
#include "
common/fontdata.h
"
9
10
#undef DrawText
11
12
#ifdef __cplusplus
13
extern
"C"
{
14
#endif
15
22
static
inline
int
ConvertMenuCoordinate
(
float
value) {
23
if
(!(
static_cast<
long
double
>
(value) >= -0x1p63L &&
24
static_cast<
long
double
>
(value) < 0x1p63L)) {
25
return
0;
26
}
27
return
static_cast<
int
>
(
static_cast<
long
long
>
(value));
28
}
29
#ifdef __cplusplus
30
}
31
#endif
32
33
class
MenuFont
;
34
40
class
MenuFont
{
41
public
:
48
MenuFont
();
49
55
virtual
~MenuFont
();
56
63
virtual
void
MeasureText
();
70
virtual
void
MeasureTextAltFont
();
78
virtual
void
DrawMenuItemText
(
float
x,
float
y);
84
virtual
void
DrawText
();
92
virtual
signed
char
HandleTextInput
();
93
101
virtual
long
double
ComputeCenteredX
();
107
virtual
void
DrawTextAltFont
();
108
110
const
char
*
GetText
()
const
{
111
return
szText;
112
}
113
117
void
SetText
(
const
char
*text) {
118
std::strcpy
(szText, text);
119
}
120
125
void
AppendText
(
const
char
*text) {
126
std::strcat
(szText, text);
127
}
128
135
void
CopyTextPrefix
(
const
char
*text,
size_t
size) {
136
std::strncpy
(szText, text, size);
137
}
138
142
void
SetNumber
(
int
value) {
143
_itoa(value, szText, 10);
144
}
145
146
unsigned
GetFlags
()
const
{
147
return
dwFlags;
148
}
149
154
unsigned
SetFlags
(
unsigned
value) {
155
return
dwFlags = value;
156
}
157
162
unsigned
char
SetStyle
(
unsigned
char
value) {
163
return
bStyle = value;
164
}
165
166
unsigned
char
GetStyle
()
const
{
167
return
bStyle;
168
}
169
170
short
GetWidth
()
const
{
171
return
nWidth;
172
}
173
178
short
SetWidth
(
short
value) {
179
return
nWidth = value;
180
}
181
182
short
GetHeight
()
const
{
183
return
nHeight;
184
}
185
191
short
SetHeight
(
short
value) {
192
return
nHeight = value;
193
}
194
199
float
SetX
(
float
value) {
200
return
fX = value;
201
}
202
203
float
GetX
()
const
{
204
return
fX;
205
}
206
207
float
GetY
()
const
{
208
return
fY;
209
}
210
215
float
SetY
(
float
value) {
216
return
fY = value;
217
}
218
223
float
SetZ
(
float
value) {
224
return
fZ = value;
225
}
226
232
short
SetInputMaxWidth
(
short
value) {
233
return
nInputMaxWidth = value;
234
}
235
236
int
GetDrawCaret
()
const
{
237
return
bDrawCaret;
238
}
239
244
int
SetDrawCaret
(
int
value) {
245
return
bDrawCaret = value;
246
}
247
248
LONG
GetBoundsLeft
()
const
{
249
return
rcBounds.left;
250
}
251
255
const
RECT
&
GetBounds
()
const
{
256
return
rcBounds;
257
}
258
263
LONG
SetBoundsLeft
(
LONG
value) {
264
return
rcBounds.left = value;
265
}
266
267
LONG
GetBoundsTop
()
const
{
268
return
rcBounds.top;
269
}
270
275
LONG
SetBoundsTop
(
LONG
value) {
276
return
rcBounds.top = value;
277
}
278
279
LONG
GetBoundsRight
()
const
{
280
return
rcBounds.right;
281
}
282
287
LONG
SetBoundsRight
(
LONG
value) {
288
return
rcBounds.right = value;
289
}
290
295
LONG
SetBoundsBottom
(
LONG
value) {
296
return
rcBounds.bottom = value;
297
}
298
299
unsigned
GetItemData
()
const
{
300
return
dwItemData;
301
}
302
307
unsigned
SetItemData
(
unsigned
value) {
308
return
dwItemData = value;
309
}
310
311
private
:
316
virtual
int
DrawGlyph(
short
nImage,
float
x,
float
y,
int
nStyle);
321
virtual
int
DrawGlyphNoOp(
short
nImage,
float
x,
float
y);
326
virtual
int
DrawGlyphAltFont(
short
nImage,
float
x,
float
y,
int
nStyle);
331
virtual
void
DrawThrottledMenuGlyph(
float
x,
float
y);
332
333
inline
void
MeasureMenuText(
bool
alternate);
334
inline
void
DrawMenuText(
float
x,
float
y,
bool
alternate,
bool
useFontY);
335
336
unsigned
dwFlags;
337
unsigned
char
bStyle;
338
char
szText[1024];
339
short
nWidth;
340
short
nHeight;
341
float
fX;
342
float
fY;
343
float
fZ;
344
short
nInputMaxWidth;
345
int
bDrawCaret;
346
RECT
rcBounds;
347
unsigned
dwItemData;
348
};
MenuFont
Menu text with a 1024-byte internal buffer, glyph metrics, drawing style, and text-entry state.
Definition
menufont.h:40
MenuFont::GetItemData
unsigned GetItemData() const
Definition
menufont.h:299
MenuFont::SetX
float SetX(float value)
Store horizontal position without updating bounds.
Definition
menufont.h:199
MenuFont::HandleTextInput
virtual signed char HandleTextInput()
Process pending character and key input, including network-setup sound shortcuts.
MenuFont::SetNumber
void SetNumber(int value)
Replace text with a terminated signed decimal integer without measuring the result.
Definition
menufont.h:142
MenuFont::MenuFont
MenuFont()
Initialise empty text, style one, zero dimensions and position, and an inactive caret.
MenuFont::ComputeCenteredX
virtual long double ComputeCenteredX()
Centre measured text between configured left and right bounds and store the horizontal position.
MenuFont::SetY
float SetY(float value)
Store vertical position without updating bounds.
Definition
menufont.h:215
MenuFont::SetStyle
unsigned char SetStyle(unsigned char value)
Store a drawing style without changing font measurements.
Definition
menufont.h:162
MenuFont::GetY
float GetY() const
Definition
menufont.h:207
MenuFont::GetBoundsTop
LONG GetBoundsTop() const
Definition
menufont.h:267
MenuFont::GetDrawCaret
int GetDrawCaret() const
Definition
menufont.h:236
MenuFont::GetBounds
const RECT & GetBounds() const
Definition
menufont.h:255
MenuFont::SetFlags
unsigned SetFlags(unsigned value)
Store text flags without measuring or drawing.
Definition
menufont.h:154
MenuFont::GetFlags
unsigned GetFlags() const
Definition
menufont.h:146
MenuFont::GetText
const char * GetText() const
Definition
menufont.h:110
MenuFont::GetWidth
short GetWidth() const
Definition
menufont.h:170
MenuFont::SetZ
float SetZ(float value)
Store the legacy depth field without changing device state; text drawing does not read it.
Definition
menufont.h:223
MenuFont::AppendText
void AppendText(const char *text)
Append terminated text without checking capacity or measuring the result.
Definition
menufont.h:125
MenuFont::SetItemData
unsigned SetItemData(unsigned value)
Store application-specific item data without interpreting it.
Definition
menufont.h:307
MenuFont::SetDrawCaret
int SetDrawCaret(int value)
Store caret state without resetting its shared blink timer.
Definition
menufont.h:244
MenuFont::GetBoundsLeft
LONG GetBoundsLeft() const
Definition
menufont.h:248
MenuFont::SetBoundsLeft
LONG SetBoundsLeft(LONG value)
Store the left bound without updating position or dimensions.
Definition
menufont.h:263
MenuFont::SetHeight
short SetHeight(short value)
Store height without measuring text or updating bounds.
Definition
menufont.h:191
MenuFont::MeasureText
virtual void MeasureText()
Recalculate primary-font width and raise height to the tallest recognised glyph if needed.
MenuFont::DrawText
virtual void DrawText()
Draw primary-font text at the stored position, applying centring and an enabled caret.
MenuFont::SetBoundsRight
LONG SetBoundsRight(LONG value)
Store the right bound without updating position or dimensions.
Definition
menufont.h:287
MenuFont::SetText
void SetText(const char *text)
Copy terminated text without checking capacity or measuring the result.
Definition
menufont.h:117
MenuFont::~MenuFont
virtual ~MenuFont()
Destroy embedded text and state without releasing external resources.
MenuFont::DrawTextAltFont
virtual void DrawTextAltFont()
Draw alternate-font text at the stored position, applying centring and an enabled caret.
MenuFont::MeasureTextAltFont
virtual void MeasureTextAltFont()
Recalculate alternate-font width and raise height without resetting prior height.
MenuFont::SetBoundsTop
LONG SetBoundsTop(LONG value)
Store the top bound without updating position or dimensions.
Definition
menufont.h:275
MenuFont::GetHeight
short GetHeight() const
Definition
menufont.h:182
MenuFont::CopyTextPrefix
void CopyTextPrefix(const char *text, size_t size)
Copy a text prefix with strncpy() semantics, including zero padding after a source terminator.
Definition
menufont.h:135
MenuFont::GetStyle
unsigned char GetStyle() const
Definition
menufont.h:166
MenuFont::GetBoundsRight
LONG GetBoundsRight() const
Definition
menufont.h:279
MenuFont::SetWidth
short SetWidth(short value)
Store width without measuring text or updating bounds.
Definition
menufont.h:178
MenuFont::SetBoundsBottom
LONG SetBoundsBottom(LONG value)
Store the bottom bound without updating position or dimensions.
Definition
menufont.h:295
MenuFont::GetX
float GetX() const
Definition
menufont.h:203
MenuFont::DrawMenuItemText
virtual void DrawMenuItemText(float x, float y)
Draw primary-font text at supplied coordinates, with optional centring and caret rendering.
MenuFont::SetInputMaxWidth
short SetInputMaxWidth(short value)
Store the width threshold used before accepting an input character.
Definition
menufont.h:232
cstdlib
cstring
fontdata.h
ConvertMenuCoordinate
static int ConvertMenuCoordinate(float value)
Truncate a floating-point coordinate using the native signed 64-bit conversion range.
Definition
menufont.h:22
RECT
std::strcat
T strcat(T... args)
std::strcpy
T strcpy(T... args)
std::strncpy
T strncpy(T... args)
windows.h
LONG
typedef LONG
Generated by
1.15.0