make sure the mouse over widget and the focused widget are informed when the dialog is closed

svn-id: r4645
This commit is contained in:
Max Horn 2002-07-26 20:38:55 +00:00
parent b9593a256a
commit e0f1d6c5aa
3 changed files with 26 additions and 13 deletions

View File

@ -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() void Dialog::draw()
{ {
Widget *w = _firstWidget; Widget *w = _firstWidget;
@ -220,13 +238,6 @@ Widget *Dialog::findWidget(int x, int y)
return w; return w;
} }
void Dialog::close()
{
_mouseWidget = 0;
_focusedWidget = 0;
_gui->closeTopDialog();
}
void Dialog::addResText(int x, int y, int w, int h, int resID) void Dialog::addResText(int x, int y, int w, int h, int resID)
{ {
// Get the string // Get the string

View File

@ -54,6 +54,9 @@ public:
{} {}
virtual ~Dialog(); virtual ~Dialog();
virtual void open();
virtual void close();
virtual void draw(); virtual void draw();
virtual void handleTickle(); // Called periodically (in every guiloop() ) virtual void handleTickle(); // Called periodically (in every guiloop() )
@ -71,7 +74,6 @@ public:
protected: protected:
Widget* findWidget(int x, int y); // Find the widget at pos x,y if any 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 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); void addButton(int x, int y, int w, int h, const char *label, uint32 cmd, char hotkey);

View File

@ -48,35 +48,35 @@ void NewGui::pauseDialog()
{ {
if (!_pauseDialog) if (!_pauseDialog)
_pauseDialog = new PauseDialog(this); _pauseDialog = new PauseDialog(this);
openDialog(_pauseDialog); _pauseDialog->open();
} }
void NewGui::saveloadDialog() void NewGui::saveloadDialog()
{ {
if (!_saveLoadDialog) if (!_saveLoadDialog)
_saveLoadDialog = new SaveLoadDialog(this); _saveLoadDialog = new SaveLoadDialog(this);
openDialog(_saveLoadDialog); _saveLoadDialog->open();
} }
void NewGui::aboutDialog() void NewGui::aboutDialog()
{ {
if (!_aboutDialog) if (!_aboutDialog)
_aboutDialog = new AboutDialog(this); _aboutDialog = new AboutDialog(this);
openDialog(_aboutDialog); _aboutDialog->open();
} }
void NewGui::optionsDialog() void NewGui::optionsDialog()
{ {
if (!_optionsDialog) if (!_optionsDialog)
_optionsDialog = new OptionsDialog(this); _optionsDialog = new OptionsDialog(this);
openDialog(_optionsDialog); _optionsDialog->open();
} }
void NewGui::soundDialog() void NewGui::soundDialog()
{ {
if (!_soundDialog) if (!_soundDialog)
_soundDialog = new SoundDialog(this); _soundDialog = new SoundDialog(this);
openDialog(_soundDialog); _soundDialog->open();
} }
void NewGui::loop() void NewGui::loop()