The escape key should now work to close most of the dialogs in dolphin. Let me know of any that I missed. I am sure there are some. I also notice that anytime a wxNotebook is used a page should be set to get proper focus on the dialog.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7351 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice 2011-03-15 14:37:04 +00:00
parent 1e46f069c2
commit f26a7288a7
7 changed files with 30 additions and 17 deletions

View File

@ -213,7 +213,7 @@ void CConfigMain::SetSelectedTab(int tab)
switch (tab)
{
case ID_AUDIOPAGE:
this->Notebook->SetSelection(2);
Notebook->SetSelection(2);
break;
}
}
@ -947,6 +947,7 @@ void CConfigMain::CreateGUIControls()
Fit();
Center();
Notebook->SetSelection(0);
}
void CConfigMain::OnClose(wxCloseEvent& WXUNUSED (event))

View File

@ -303,5 +303,6 @@ void HotkeyConfigDialog::CreateHotkeyGUIControls(void)
SetSizer(sMainSizer);
Layout();
Fit();
Notebook->SetSelection(0);
}

View File

@ -191,6 +191,11 @@ void InputConfigDialog::UpdateControlReferences()
(*i)->controller->UpdateReferences(g_controller_interface);
}
void InputConfigDialog::ClickCancel(wxCommandEvent&)
{
Close();
}
void InputConfigDialog::ClickSave(wxCommandEvent&)
{
m_plugin.SaveConfig();
@ -974,13 +979,15 @@ InputConfigDialog::InputConfigDialog(wxWindow* const parent, InputPlugin& plugin
UpdateDeviceComboBox();
UpdateProfileComboBox();
wxButton* const close_button = new wxButton(this, -1, _("Save"));
_connect_macro_(close_button, InputConfigDialog::ClickSave, wxEVT_COMMAND_BUTTON_CLICKED, this);
wxButton* const close_button = new wxButton(this, wxID_OK, _("Save"));
_connect_macro_(close_button, InputConfigDialog::ClickSave, wxEVT_COMMAND_BUTTON_CLICKED, this);
wxButton* const cancel_button = new wxButton(this, wxID_CANCEL, _("Cancel"));
_connect_macro_(cancel_button, InputConfigDialog::ClickCancel, wxEVT_COMMAND_BUTTON_CLICKED, this);
wxBoxSizer* btns = new wxBoxSizer(wxHORIZONTAL);
//btns->Add(new wxStaticText(this, -1, wxString::FromAscii(ver.c_str())), 0, wxLEFT|wxTOP, 5);
btns->AddStretchSpacer();
btns->Add(cancel_button, 0, 0, 0);
btns->Add(close_button, 0, 0, 0);
wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL);

View File

@ -235,6 +235,7 @@ public:
bool Destroy();
void ClickCancel(wxCommandEvent& event);
void ClickSave(wxCommandEvent& event);
void UpdateDeviceComboBox();

View File

@ -461,7 +461,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
page_advanced->SetSizerAndFit(szr_advanced);
}
wxButton* const btn_close = new wxButton(this, -1, _("Close"), wxDefaultPosition);
wxButton* const btn_close = new wxButton(this, wxID_OK, _("Close"), wxDefaultPosition);
_connect_macro_(btn_close, VideoConfigDiag::Event_ClickClose, wxEVT_COMMAND_BUTTON_CLICKED, this);
Connect(wxID_ANY, wxEVT_CLOSE_WINDOW, wxCloseEventHandler(VideoConfigDiag::Event_Close), (wxObject*)0, this);
@ -470,6 +470,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
szr_main->Add(notebook, 1, wxEXPAND | wxALL, 5);
szr_main->Add(btn_close, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 5);
notebook->SetSelection(0);
SetSizerAndFit(szr_main);
Center();

View File

@ -67,7 +67,7 @@ WiimoteConfigPage::WiimoteConfigPage(wxWindow* const parent, const int index)
WiimoteConfigDiag::WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin)
: wxDialog(parent, -1, _("Dolphin Wiimote Configuration"), wxDefaultPosition, wxDefaultSize)
, m_plugin(plugin), m_save(false)
, m_plugin(plugin)
{
m_pad_notebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize, wxNB_DEFAULT);
for (unsigned int i = 0; i < 4; ++i)
@ -75,15 +75,20 @@ WiimoteConfigDiag::WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin
WiimoteConfigPage* const wpage = new WiimoteConfigPage(m_pad_notebook, i);
m_pad_notebook->AddPage(wpage, wxString(_("Wiimote ")) + wxChar('1'+i));
}
m_pad_notebook->SetSelection(0);
wxButton* const ok_button = new wxButton(this, -1, _("OK"), wxDefaultPosition);
wxButton* const ok_button = new wxButton(this, wxID_OK, _("OK"), wxDefaultPosition);
_connect_macro_(ok_button, WiimoteConfigDiag::Save, wxEVT_COMMAND_BUTTON_CLICKED, this);
wxButton* const cancel_button = new wxButton(this, wxID_CANCEL, _("Cancel"), wxDefaultPosition);
_connect_macro_(cancel_button, WiimoteConfigDiag::Cancel, wxEVT_COMMAND_BUTTON_CLICKED, this);
Connect(wxID_ANY, wxEVT_CLOSE_WINDOW, wxCloseEventHandler(WiimoteConfigDiag::OnClose), (wxObject*)0, this);
wxBoxSizer* const button_sizer = new wxBoxSizer(wxHORIZONTAL);
button_sizer->Add(cancel_button, 0, wxALIGN_RIGHT | wxRIGHT, 5);
button_sizer->Add(ok_button, 0, wxALIGN_RIGHT);
wxBoxSizer* const main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(m_pad_notebook, 1, wxEXPAND | wxALL, 5);
main_sizer->Add(ok_button, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 5);
main_sizer->Add(button_sizer, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 5);
SetSizerAndFit(main_sizer);
@ -174,15 +179,13 @@ void WiimoteConfigDiag::Save(wxCommandEvent&)
inifile.Save(ini_filename);
m_save = true;
Close();
}
void WiimoteConfigDiag::OnClose(wxCloseEvent& event)
void WiimoteConfigDiag::Cancel(wxCommandEvent&)
{
if (!m_save)
for (size_t p = 0; p < m_pad_notebook->GetPageCount(); ++p)
((WiimoteConfigPage*)m_pad_notebook->GetPage(p))->RevertSource();
event.Skip();
for (size_t p = 0; p < m_pad_notebook->GetPageCount(); ++p)
((WiimoteConfigPage*)m_pad_notebook->GetPage(p))->RevertSource();
Close();
}

View File

@ -46,11 +46,10 @@ public:
void UpdateGUI();
private:
void OnClose(wxCloseEvent& event);
void Cancel(wxCommandEvent& event);
InputPlugin& m_plugin;
wxNotebook* m_pad_notebook;
bool m_save;
};