aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2016-04-19 10:53:06 +0200
committerEugene Sandulenko2016-04-19 10:53:06 +0200
commitb8ec681b86b165caf1486fdf2f1b11c0567e6714 (patch)
tree469f60f4224fe4244b5c454dea7c253bd73d8fca
parentfd7bf64131a0f1ecc5f3b4039c481fff52eb6efa (diff)
downloadscummvm-rg350-b8ec681b86b165caf1486fdf2f1b11c0567e6714.tar.gz
scummvm-rg350-b8ec681b86b165caf1486fdf2f1b11c0567e6714.tar.bz2
scummvm-rg350-b8ec681b86b165caf1486fdf2f1b11c0567e6714.zip
WAGE: Implement callback calling in MacWindow
-rw-r--r--engines/wage/macwindow.cpp22
-rw-r--r--engines/wage/macwindow.h6
2 files changed, 20 insertions, 8 deletions
diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp
index eac552245f..048b193db0 100644
--- a/engines/wage/macwindow.cpp
+++ b/engines/wage/macwindow.cpp
@@ -61,6 +61,9 @@ MacWindow::MacWindow(int id, bool scrollable) : _scrollable(scrollable), _id(id)
_highlightedPart = kBorderNone;
_scrollPos = _scrollSize = 0.0;
+
+ _callback = 0;
+ _dataPtr = 0;
}
MacWindow::~MacWindow() {
@@ -271,7 +274,7 @@ bool MacWindow::processEvent(Common::Event &event) {
//mouseMove(event.mouse.x, event.mouse.y);
break;
case Common::EVENT_LBUTTONDOWN:
- mouseDown(event.mouse.x, event.mouse.y);
+ mouseDown(event);
break;
case Common::EVENT_LBUTTONUP:
#if 0
@@ -290,13 +293,16 @@ bool MacWindow::processEvent(Common::Event &event) {
return true;
}
-void MacWindow::mouseDown(int x, int y) {
- if (_innerDims.contains(x, y)) {
- // (*callback)(x - _dims.left, y - dims.top);
+void MacWindow::mouseDown(Common::Event &event) {
+ if (_innerDims.contains(event.mouse.x, event.mouse.y)) {
+ if (!_callback)
+ return;
+
+ (*_callback)(kBorderInner, event, _dataPtr);
return;
}
- WindowClick click = isInBorder(_innerDims, x, y);
+ WindowClick click = isInBorder(_innerDims, event.mouse.x, event.mouse.y);
if (click == kBorderNone)
return;
@@ -304,9 +310,11 @@ void MacWindow::mouseDown(int x, int y) {
setHighlight(click);
if (click == kBorderScrollUp || click == kBorderScrollDown) {
- // TODO
- }
+ if (!_callback)
+ return;
+ (*_callback)(click, event, _dataPtr);
+ }
}
} // End of namespace Wage
diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h
index fb2974a72f..1998bffe0c 100644
--- a/engines/wage/macwindow.h
+++ b/engines/wage/macwindow.h
@@ -86,6 +86,7 @@ public:
void setDirty(bool dirty) { _contentIsDirty = dirty; }
int getId() { return _id; }
bool processEvent(Common::Event &event);
+ void setCallback(void (*callback)(WindowClick, Common::Event &, void *), void *data) { _callback = callback; _dataPtr = data; }
private:
void drawBorder();
@@ -94,7 +95,7 @@ private:
const Graphics::Font *getTitleFont();
bool builtInFonts();
- void mouseDown(int x, int y);
+ void mouseDown(Common::Event &event);
private:
Graphics::ManagedSurface _surface;
@@ -113,6 +114,9 @@ private:
Common::Rect _innerDims;
Common::String _title;
+
+ void (*_callback)(WindowClick, Common::Event &, void *);
+ void *_dataPtr;
};
} // End of namespace Wage