25 #include "common/array.h" 26 #include "common/stack.h" 27 #include "graphics/screen.h" 28 #include "mm/mm1/messages.h" 29 #include "mm/mm1/utils/mouse.h" 35 #define FRAME_DELAY (1000 / FRAME_RATE) 57 operator const Common::Rect &()
const {
return _bounds; }
59 void setBorderSize(
size_t borderSize);
60 size_t borderSize()
const {
return _borderSize; }
61 int16 width()
const {
return _bounds.
width(); }
62 int16 height()
const {
return _bounds.
height(); }
77 bool _needsRedraw =
true;
87 void delaySeconds(uint seconds);
92 void delayFrames(uint frames);
98 return _timeoutCtr != 0;
116 virtual void timeout();
152 virtual void close();
157 bool isFocused()
const;
162 void replaceView(
UIElement *ui,
bool replaceAllViews =
false);
163 void replaceView(
const Common::String &name,
bool replaceAllViews =
false);
171 void open() { addView(); }
176 int getRandomNumber(
int minNumber,
int maxNumber);
177 int getRandomNumber(
int maxNumber);
206 virtual void clearSurface();
226 #define MESSAGE(NAME) \ 228 virtual bool msg##NAME(const NAME##Message &e) { \ 229 for (Common::Array<UIElement *>::iterator it = _children.begin(); \ 230 it != _children.end(); ++it) { \ 231 if ((*it)->msg##NAME(e)) return true; \ 236 bool send(const Common::String &viewName, const NAME##Message &msg) { \ 237 UIElement *view = UIElement::findViewGlobally(viewName); \ 239 return view->msg##NAME(msg); \ 241 bool send(const NAME##Message &msg) { \ 242 return send("Root", msg); \ 254 MESSAGE(DrawGraphic);
281 virtual bool shouldQuit()
const = 0;
286 #define MESSAGE(NAME) \ 287 bool msg##NAME(const NAME##Message &e) override { \ 288 return !_views.empty() ? focusedView()->msg##NAME(e) : false; \ 296 MESSAGE(DrawGraphic);
299 Events(
bool enhancedMode);
310 void replaceView(
UIElement *ui,
bool replaceAllViews =
false);
311 void replaceView(
const Common::String &name,
bool replaceAllViews =
false);
340 return _views.empty() ? nullptr : _views.top();
347 return _views.size() < 2 ? nullptr :
348 _views[_views.size() - 2];
361 return isPresent(
"Combat");
368 void drawElements() {
370 focusedView()->drawElements();
376 void addKeypress(
const Common::KeyCode kc);
381 void addAction(KeybindingAction action);
386 bool isKeypressPending()
const;
391 return !_views.empty() ? focusedView()->tick() :
false;
398 focusedView()->close();
void draw() override
Definition: events.h:388
Definition: managed_surface.h:51
void cancelDelay()
Definition: events.h:104
UIElement * priorView() const
Definition: events.h:346
bool tick() override
Definition: events.h:390
bool needsRedraw() const
Definition: events.h:136
T width() const
Definition: rect.h:217
T height() const
Definition: rect.h:218
Definition: detection.h:27
UIElement * focusedView() const
Definition: events.h:339
bool isInCombat() const
Definition: events.h:360
void close() override
Definition: events.h:397
virtual void setBounds(const Common::Rect &r)
Definition: events.h:187
Common::Rect getBounds() const
Definition: events.h:194
Common::String getName() const
Definition: events.h:182
bool isDelayActive() const
Definition: events.h:97