mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-09 11:20:56 +00:00
WAGE: Implement callback calling in MacWindow
This commit is contained in:
parent
fd7bf64131
commit
b8ec681b86
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user