wavelength 1.0.0
Loading...
Searching...
No Matches
uicomponent.h
Go to the documentation of this file.
1#pragma once
2
3#include "app/msgsink.h"
4#include "os/prnstream.h"
5#include "script/dataarray.h"
6
21class UIComponent : public MsgSink {
22public:
29
37 explicit UIComponent(DataArray *pData) : mName(pData->Sym(1)), mShowing(1) {
39 }
40
51 static void Init(DataArray *pConfig);
52
64 bool Dispatch(Message *pMsg) override;
65
76 bool DispatchPriv(Message *pMsg) override;
77
85 virtual bool IsShowing() const {
86 return mShowing;
87 }
88
96 virtual void SetShowing(bool bShowing) {
97 mShowing = bShowing;
98 }
99
107 virtual const char *Text() const;
108
118 virtual void SetText(const char *pszText);
119
127 virtual int GetState() const {
128 return mState;
129 }
130
139 virtual void SetState(int nState, [[maybe_unused]] bool bForce) {
140 mState = nState;
141 }
142
151 virtual void Focus() {
152 }
153
162 virtual void Unfocus() {
163 }
164
174 virtual void Poll([[maybe_unused]] float fTime) {
175 }
176
182 virtual void Print(PrnStream &stream) = 0;
183
185 const char *GetName() const {
186 return mName;
187 }
188
190 int GetShowing() const {
191 return mShowing;
192 }
193
194protected:
195 const char *mName;
197 int mState;
204 static int sNumFlashes;
205
212 static float sSelectedMs;
213
220 static float sNormalMs;
221};
Reference-counted array of script data nodes.
Definition dataarray.h:20
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:40
Receiver of engine messages.
Definition msgsink.h:21
Text output stream.
Definition prnstream.h:16
int mState
Definition uicomponent.h:197
virtual void SetText(const char *pszText)
Replace the text the component shows.
virtual void SetShowing(bool bShowing)
Show or hide the component.
Definition uicomponent.h:96
int GetShowing() const
Definition uicomponent.h:190
virtual int GetState() const
Report the state the component shows.
Definition uicomponent.h:127
virtual void SetState(int nState, bool bForce)
Change the state the component shows.
Definition uicomponent.h:139
virtual bool IsShowing() const
Report whether the component is showing.
Definition uicomponent.h:85
static int sNumFlashes
Number of times a chosen button flashes before it reports the choice.
Definition uicomponent.h:204
State
The state a component shows, the values of mState and the index UIStyle selects with.
Definition uicomponent.h:24
@ kStateDisabled
Definition uicomponent.h:27
@ kStateSelected
Definition uicomponent.h:26
@ kStateNormal
Definition uicomponent.h:25
UIComponent(DataArray *pData)
Construct a showing component in the normal state.
Definition uicomponent.h:37
static void Init(DataArray *pConfig)
Read the parameters of the flash a button shows when it is chosen.
virtual void Unfocus()
React to the panel taking the focus away.
Definition uicomponent.h:162
const char * mName
Definition uicomponent.h:195
virtual void Poll(float fTime)
Advance the component to a time.
Definition uicomponent.h:174
virtual void Print(PrnStream &stream)=0
Write a description of the component.
const char * GetName() const
Definition uicomponent.h:185
virtual const char * Text() const
Report the text the component shows.
bool Dispatch(Message *pMsg) override
Offer a message to the focused panel of the current screen, then handle it here.
bool DispatchPriv(Message *pMsg) override
Handle a message sent to the component.
static float sSelectedMs
Milliseconds of each flash a chosen button spends in the selected state.
Definition uicomponent.h:212
int mShowing
Definition uicomponent.h:196
virtual void Focus()
React to the panel giving the component the focus.
Definition uicomponent.h:151
static float sNormalMs
Milliseconds of each flash a chosen button spends in the normal state.
Definition uicomponent.h:220