aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui/dialog.cpp25
-rw-r--r--gui/dialog.h4
-rw-r--r--newgui.cpp10
3 files changed, 26 insertions, 13 deletions
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index c2b96fe824..82a98085a0 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 63b1544950..45deb91f3f 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 48556321eb..4a71be6c79 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()