wavelength 1.0.0
Loading...
Searching...
No Matches
uitextentry.h
Go to the documentation of this file.
1#pragma once
2
4#include "os/prnstream.h"
5#include "os/string.h"
6#include "rnd/rndmesh.h"
7#include "rnd/rndtext.h"
9#include "script/dataarray.h"
10#include "ui/uicomponent.h"
11#include "ui/uistyle.h"
12
27class UITextEntry : public UIComponent {
28public:
37 UITextEntry(DataArray *pData, const char *pszPanel);
38
45 ~UITextEntry() override;
46
58 static UIComponent *New(DataArray *pData, const char *pszPanel) {
59 return new UITextEntry(pData, pszPanel);
60 }
61
70 bool DispatchPriv(Message *pMsg) override;
71
79 const char *Text() const override;
80
88 void SetText(const char *pszText) override;
89
98 void SetState(int nState, bool bForce) override;
99
107 void Poll(float fTime) override;
108
116 void Print(PrnStream &stream) override;
117
126 String MaskText(const char *pszText) const;
127
138 float CharWidth(int nIndex);
139
149 void SetEditing(bool bEditing);
150
159 bool HandleKey(int nKey);
160
168
177 void Layout();
178
186
199 bool ProcessKey(int nKey);
200
210
212 float GetMaxEntryWidth() const {
213 return mMaxEntryWidth;
214 }
215
217 void SetMaxEntryWidth(float fMaxEntryWidth) {
218 mMaxEntryWidth = fMaxEntryWidth;
219 }
220
222 void SetMaxNumChars(int nMaxNumChars) {
223 mMaxNumChars = nMaxNumChars;
224 }
225
227 void SetScroll(int nScroll) {
228 mScroll = nScroll;
229 }
230
232 void SetNumLines(int nNumLines) {
233 mNumLines = nNumLines;
234 }
235
237 void SetPassword(int nPassword) {
238 mPassword = nPassword;
239 }
240
242 void SetInvalidChars(DataArray *pInvalidChars) {
243 mInvalidChars = pInvalidChars;
244 }
245
246#ifdef VIDEO_STANDARD_PAL
248 void SetUtf8MaxLen(int nUtf8MaxLen) {
249 mUtf8MaxLen = nUtf8MaxLen;
250 }
251#endif
252
254 int GetWordWrapLines() const {
255 return mWordWrapLines;
256 }
257
258private:
259 String mText;
260 RndText *mTextObj;
261 RndText *mCaret;
262 RndText *mLastCaret;
263 RndMesh *mMesh;
264 UIStyle *mHighlightStyle;
265 int mCursor;
266 int mScrollStart;
267 alignas(16) Vector3 mCaretOrigin;
268 alignas(16) Vector3 mLastCaretOrigin;
269 int mScroll;
270 String mVisibleText;
271 alignas(16) Vector3 mCaretPos;
272 float mMaxEntryWidth;
273 int mNumLines;
274 int mMaxNumChars;
275#ifdef VIDEO_STANDARD_PAL
276 int mUtf8MaxLen;
277#endif
278 int mWordWrapLines;
279 int mPassword;
280 int mEditing;
281 float mNextBlink;
282 DataArray *mInvalidChars;
283
290 static float sBlinkMs;
291};
Reference-counted array of script data nodes.
Definition dataarray.h:20
Message the keyboard poll sends when a key of a USB keyboard is pressed.
Definition keyboardkeymsg.h:23
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:40
Text output stream.
Definition prnstream.h:16
Triangle mesh with a material.
Definition rndmesh.h:31
Text drawn with a bitmap font as a mesh of one quad per character.
Definition rndtext.h:27
Growable text buffer that is also a PrnStream.
Definition string.h:19
UIComponent(DataArray *pData)
Construct a showing component in the normal state.
Definition uicomponent.h:37
Material and font a component draws with in each of its states.
Definition uistyle.h:15
void SetInvalidChars(DataArray *pInvalidChars)
Definition uitextentry.h:242
int GetWordWrapLines() const
Definition uitextentry.h:254
float CharWidth(int nIndex)
Report the width one character of the text takes, including the font's tracking.
void SetEditing(bool bEditing)
Start or stop editing.
void SetText(const char *pszText) override
Replace the text and put the caret after it.
void Layout()
Show the part of the text that fits, and place the caret.
void ToggleCaret()
Show the caret when it is hidden, and hide it when it shows.
~UITextEntry() override
Destroy the text entry.
static UIComponent * New(DataArray *pData, const char *pszPanel)
Create a text entry from its script description.
Definition uitextentry.h:58
void SetMaxEntryWidth(float fMaxEntryWidth)
Definition uitextentry.h:217
void Poll(float fTime) override
Blink the caret while the entry edits, and hide it otherwise.
void SetMaxNumChars(int nMaxNumChars)
Definition uitextentry.h:222
bool DispatchPriv(Message *pMsg) override
Handle a keyboard key, or pass any other message to UIComponent.
void Print(PrnStream &stream) override
Write the entry's name.
float GetMaxEntryWidth() const
Definition uitextentry.h:212
void SetState(int nState, bool bForce) override
Change the state, showing the material and the font of the highlight style.
const char * Text() const override
Report the text the player has entered.
void UpdateCaret()
Move the caret object to mCaretPos.
void SetScroll(int nScroll)
Definition uitextentry.h:227
bool ProcessKey(int nKey)
Edit the text for a key.
bool HandleKey(int nKey)
Act on a key as if it were typed.
String MaskText(const char *pszText) const
Report a copy of a text with every character replaced by an asterisk.
UITextEntry(DataArray *pData, const char *pszPanel)
Construct a text entry from its script description.
void SetPassword(int nPassword)
Definition uitextentry.h:237
void SetNumLines(int nNumLines)
Definition uitextentry.h:232
bool HandleKeyMsg(KeyboardKeyMsg *pMsg)
Edit the text for a keyboard message.
Three-component vector, padded to a PlayStation 2 quadword.
Definition vector3.h:14