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);
275 virtual bool shouldQuit()
const = 0;
280 #define MESSAGE(NAME) \ 281 bool msg##NAME(const NAME##Message &e) override { \ 282 return !_views.empty() ? focusedView()->msg##NAME(e) : false; \ 290 MESSAGE(DrawGraphic);
293 Events(
bool enhancedMode);
304 void replaceView(
UIElement *ui,
bool replaceAllViews =
false);
305 void replaceView(
const Common::String &name,
bool replaceAllViews =
false);
334 return _views.empty() ? nullptr : _views.top();
341 return _views.size() < 2 ? nullptr :
342 _views[_views.size() - 2];
355 return isPresent(
"Combat");
362 void drawElements() {
364 focusedView()->drawElements();
370 void addKeypress(
const Common::KeyCode kc);
375 void addAction(KeybindingAction action);
380 bool isKeypressPending()
const;
385 return !_views.empty() ? focusedView()->tick() :
false;
392 focusedView()->close();
void draw() override
Definition: events.h:382
Definition: managed_surface.h:51
void cancelDelay()
Definition: events.h:104
UIElement * priorView() const
Definition: events.h:340
bool tick() override
Definition: events.h:384
bool needsRedraw() const
Definition: events.h:136
int16 width() const
Definition: rect.h:191
Definition: detection.h:27
UIElement * focusedView() const
Definition: events.h:333
bool isInCombat() const
Definition: events.h:354
void close() override
Definition: events.h:391
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
int16 height() const
Definition: rect.h:192
bool isDelayActive() const
Definition: events.h:97