Check whether the dialog is maximized rather than whether it's not iconized in PersistLocation. Updates #1451.

Originally committed to SVN as r6445.
This commit is contained in:
Thomas Goyne 2012-02-07 01:21:56 +00:00
parent 5a53aa5511
commit 813f23e762
2 changed files with 11 additions and 9 deletions

View file

@ -38,9 +38,7 @@ PersistLocation::PersistLocation(wxDialog *dialog, std::string options_prefix)
, dialog(dialog)
{
dialog->Bind(wxEVT_MOVE, &PersistLocation::OnMove, this);
dialog->Bind(wxEVT_ICONIZE, &PersistLocation::OnMinimize, this);
if (maximize_opt->GetBool()) dialog->Maximize();
dialog->Bind(wxEVT_SIZE, &PersistLocation::OnSize, this);
int x = x_opt->GetInt();
int y = y_opt->GetInt();
@ -77,14 +75,18 @@ PersistLocation::PersistLocation(wxDialog *dialog, std::string options_prefix)
dialog->Move(x, y);
}
if (maximize_opt->GetBool()) dialog->Maximize();
}
void PersistLocation::OnMove(wxMoveEvent &) {
void PersistLocation::OnMove(wxMoveEvent &e) {
wxPoint pos = dialog->GetPosition();
x_opt->SetInt(pos.x);
y_opt->SetInt(pos.y);
e.Skip();
}
void PersistLocation::OnMinimize(wxIconizeEvent &evt) {
maximize_opt->SetBool(!evt.IsIconized());
void PersistLocation::OnSize(wxSizeEvent &e) {
maximize_opt->SetBool(dialog->IsMaximized());
e.Skip();
}

View file

@ -40,10 +40,10 @@ class PersistLocation {
agi::OptionValue *x_opt;
agi::OptionValue *y_opt;
agi::OptionValue *maximize_opt;
class wxDialog *dialog;
wxDialog *dialog;
void OnMove(wxMoveEvent &);
void OnMinimize(wxIconizeEvent &evt);
void OnMove(wxMoveEvent&);
void OnSize(wxSizeEvent&);
public:
/// Persist the location of a dialog