22#ifndef ULTIMA0_EVENTS_H
23#define ULTIMA0_EVENTS_H
25#include "common/array.h"
26#include "common/stack.h"
27#include "graphics/screen.h"
28#include "ultima/ultima0/messages.h"
29#include "ultima/ultima0/gfx/gfx_surface.h"
35#define FRAME_DELAY (1000 / FRAME_RATE)
60 void setBorderSize(
size_t borderSize);
61 size_t borderSize()
const {
65 return _bounds.
width();
67 int16 height()
const {
84 bool _needsRedraw =
true;
101 return _timeoutCtr != 0;
159 bool isFocused()
const;
242#define MESSAGE(NAME) \
244 virtual bool msg##NAME(const NAME##Message &e) { \
245 for (Common::Array<UIElement *>::iterator it = _children.begin(); \
246 it != _children.end(); ++it) { \
247 if ((*it)->msg##NAME(e)) return true; \
252 bool send(const Common::String &viewName, const NAME##Message &msg) { \
253 UIElement *view = UIElement::findViewGlobally(viewName); \
255 return view->msg##NAME(msg); \
257 bool send(const NAME##Message &msg) { \
258 return msg##NAME(msg); \
299#define MESSAGE(NAME) \
300 bool msg##NAME(const NAME##Message &e) override { \
301 return !_views.empty() ? focusedView()->msg##NAME(e) : false; \
355 return _views.empty() ? nullptr : _views.top();
362 return _views.size() < 2 ? nullptr :
363 _views[_views.size() - 2];
420extern Events *g_events;
UIElement * priorView() const
Definition: events.h:361
void processEvent(Common::Event &ev)
UIElement * focusedView() const
Definition: events.h:354
void draw() override
Definition: events.h:402
void close() override
Definition: events.h:415
void addView(UIElement *ui)
bool isPresent(const Common::String &name) const
bool isInCombat() const
Definition: events.h:375
void replaceView(UIElement *ui, bool replaceAllViews=false)
bool tick() override
Definition: events.h:408
Graphics::Screen * getScreen() const
Definition: events.h:382
virtual bool shouldQuit() const =0
void addKeypress(const Common::KeyCode kc)
void drawElements()
Definition: events.h:389
Definition: gfx_surface.h:33
int getRandomNumber(int minNumber, int maxNumber)
Common::String getName() const
Definition: events.h:164
Gfx::GfxSurface getSurface() const
Common::Rect getBounds() const
Definition: events.h:200
void delaySeconds(uint seconds)
void delayFrames(uint frames)
virtual UIElement * findView(const Common::String &name)
void cancelDelay()
Definition: events.h:107
virtual void setBounds(const Common::Rect &r)
Definition: events.h:193
void replaceView(UIElement *ui, bool replaceAllViews=false)
void addView(UIElement *ui)
virtual void clearSurface()
virtual bool msgMouseMove(const MouseMoveMessage &msg)
Definition: events.h:234
bool isDelayActive() const
Definition: events.h:100
bool needsRedraw() const
Definition: events.h:136
T height() const
Definition: rect.h:218
T width() const
Definition: rect.h:217
Definition: messages.h:58