From e0f1d6c5aa5523d2f1035330c484b96b718da4c8 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 26 Jul 2002 20:38:55 +0000 Subject: [PATCH] make sure the mouse over widget and the focused widget are informed when the dialog is closed svn-id: r4645 --- gui/dialog.cpp | 25 ++++++++++++++++++------- gui/dialog.h | 4 +++- newgui.cpp | 10 +++++----- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/gui/dialog.cpp b/gui/dialog.cpp index c2b96fe8242..82a98085a0c 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -57,6 +57,24 @@ void Dialog::teardownScreenBuf() } } +void Dialog::open() +{ + _gui->openDialog(this); +} + +void Dialog::close() +{ + if (_mouseWidget) { + _mouseWidget->handleMouseLeft(0); + _mouseWidget = 0; + } + if (_focusedWidget) { + _focusedWidget->lostFocus(); + _focusedWidget = 0; + } + _gui->closeTopDialog(); +} + void Dialog::draw() { Widget *w = _firstWidget; @@ -220,13 +238,6 @@ Widget *Dialog::findWidget(int x, int y) return w; } -void Dialog::close() -{ - _mouseWidget = 0; - _focusedWidget = 0; - _gui->closeTopDialog(); -} - void Dialog::addResText(int x, int y, int w, int h, int resID) { // Get the string diff --git a/gui/dialog.h b/gui/dialog.h index 63b15449508..45deb91f3fb 100644 --- a/gui/dialog.h +++ b/gui/dialog.h @@ -54,6 +54,9 @@ public: {} virtual ~Dialog(); + virtual void open(); + virtual void close(); + virtual void draw(); virtual void handleTickle(); // Called periodically (in every guiloop() ) @@ -71,7 +74,6 @@ public: protected: Widget* findWidget(int x, int y); // Find the widget at pos x,y if any - void close(); void addResText(int x, int y, int w, int h, int resID); void addButton(int x, int y, int w, int h, const char *label, uint32 cmd, char hotkey); diff --git a/newgui.cpp b/newgui.cpp index 48556321ebd..4a71be6c793 100644 --- a/newgui.cpp +++ b/newgui.cpp @@ -48,35 +48,35 @@ void NewGui::pauseDialog() { if (!_pauseDialog) _pauseDialog = new PauseDialog(this); - openDialog(_pauseDialog); + _pauseDialog->open(); } void NewGui::saveloadDialog() { if (!_saveLoadDialog) _saveLoadDialog = new SaveLoadDialog(this); - openDialog(_saveLoadDialog); + _saveLoadDialog->open(); } void NewGui::aboutDialog() { if (!_aboutDialog) _aboutDialog = new AboutDialog(this); - openDialog(_aboutDialog); + _aboutDialog->open(); } void NewGui::optionsDialog() { if (!_optionsDialog) _optionsDialog = new OptionsDialog(this); - openDialog(_optionsDialog); + _optionsDialog->open(); } void NewGui::soundDialog() { if (!_soundDialog) _soundDialog = new SoundDialog(this); - openDialog(_soundDialog); + _soundDialog->open(); } void NewGui::loop()