From e77059d30c57a688e6a353abbcdc89603b08e55e Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Tue, 15 Mar 2011 21:57:00 +0000 Subject: [PATCH] Some more work on making dialogs close when escape is pressed. Also make sure dialog modality is ended properly so that they can be closed on OSX. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7352 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/Src/AboutDolphin.cpp | 64 ++++++++----------- Source/Core/DolphinWX/Src/AboutDolphin.h | 19 +----- Source/Core/DolphinWX/Src/Frame.cpp | 4 +- Source/Core/DolphinWX/Src/GameListCtrl.cpp | 1 - Source/Core/DolphinWX/Src/ISOProperties.cpp | 6 +- Source/Core/DolphinWX/Src/ISOProperties.h | 3 +- Source/Core/DolphinWX/Src/InputConfigDiag.cpp | 8 +-- .../Core/DolphinWX/Src/WiimoteConfigDiag.cpp | 8 +-- 8 files changed, 42 insertions(+), 71 deletions(-) diff --git a/Source/Core/DolphinWX/Src/AboutDolphin.cpp b/Source/Core/DolphinWX/Src/AboutDolphin.cpp index a74cc91b73..627ec8a28a 100644 --- a/Source/Core/DolphinWX/Src/AboutDolphin.cpp +++ b/Source/Core/DolphinWX/Src/AboutDolphin.cpp @@ -17,35 +17,22 @@ #include "Common.h" #include "AboutDolphin.h" -#include "CPUDetect.h" #include "../resources/dolphin_logo.cpp" BEGIN_EVENT_TABLE(AboutDolphin, wxDialog) EVT_CLOSE(AboutDolphin::OnClose) - EVT_BUTTON(wxID_CLOSE, AboutDolphin::CloseClick) + EVT_BUTTON(wxID_OK, AboutDolphin::CloseClick) END_EVENT_TABLE() AboutDolphin::AboutDolphin(wxWindow *parent, wxWindowID id, - const wxString &title, const wxPoint &position, - const wxSize& size, long style) + const wxString &title, const wxPoint &position, + const wxSize& size, long style) : wxDialog(parent, id, title, position, size, style) { - CreateGUIControls(); -} - -AboutDolphin::~AboutDolphin() -{ -} - -void AboutDolphin::CreateGUIControls() -{ - m_Close = new wxButton(this, wxID_CLOSE, _("Close"), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - wxMemoryInputStream istream(dolphin_logo_png, sizeof dolphin_logo_png); wxImage iDolphinLogo(istream, wxBITMAP_TYPE_PNG); - sbDolphinLogo = new wxStaticBitmap(this, ID_LOGO, - wxBitmap(iDolphinLogo), wxDefaultPosition, wxDefaultSize, 0); + wxStaticBitmap* const sbDolphinLogo = new wxStaticBitmap(this, wxID_ANY, + wxBitmap(iDolphinLogo)); std::string Text = std::string(svn_rev_str) + "\n" "Copyright (c) 2003-2011+ Dolphin Team\n" @@ -74,38 +61,39 @@ void AboutDolphin::CreateGUIControls() "The emulator is for educational purposes only\n" "and should not be used to play games you do\n" "not legally own."; - Message = new wxStaticText(this, ID_MESSAGE, - wxString::FromAscii(Text.c_str()), - wxDefaultPosition, wxDefaultSize, 0); - Message->Wrap(this->GetSize().GetWidth()); + wxStaticText* const Message = new wxStaticText(this, wxID_ANY, + wxString::FromAscii(Text.c_str())); + Message->Wrap(GetSize().GetWidth()); - sMain = new wxBoxSizer(wxVERTICAL); - sMainHor = new wxBoxSizer(wxHORIZONTAL); - sMainHor->Add(sbDolphinLogo); - - sInfo = new wxBoxSizer(wxVERTICAL); + wxBoxSizer* const sInfo = new wxBoxSizer(wxVERTICAL); sInfo->Add(Message, 1, wxEXPAND|wxALL, 5); - sMainHor->Add(sInfo); - sMain->Add(sMainHor, 1, wxEXPAND); - sButtons = new wxBoxSizer(wxHORIZONTAL); - sButtons->Add(0, 0, 1, wxEXPAND, 5); - sButtons->Add(m_Close, 0, wxALL, 5); + wxBoxSizer* const sMainHor = new wxBoxSizer(wxHORIZONTAL); + sMainHor->Add(sbDolphinLogo); + sMainHor->Add(sInfo); + + wxBoxSizer* const sButtons = new wxBoxSizer(wxHORIZONTAL); + sButtons->AddStretchSpacer(); + sButtons->Add(new wxButton(this, wxID_OK, _("Close")), 0, wxALL, 5); + + wxBoxSizer* const sMain = new wxBoxSizer(wxVERTICAL); + sMain->Add(sMainHor, 1, wxEXPAND); sMain->Add(sButtons, 0, wxEXPAND); - this->SetSizer(sMain); - sMain->Layout(); + SetSizer(sMain); + Layout(); Fit(); - CenterOnParent(); + Center(); + SetFocus(); } -void AboutDolphin::OnClose(wxCloseEvent& WXUNUSED (event)) +void AboutDolphin::OnClose(wxCloseEvent& WXUNUSED(event)) { - EndModal(wxID_OK); + EndModal(wxID_CLOSE); } -void AboutDolphin::CloseClick(wxCommandEvent& WXUNUSED (event)) +void AboutDolphin::CloseClick(wxCommandEvent& WXUNUSED(event)) { Close(); } diff --git a/Source/Core/DolphinWX/Src/AboutDolphin.h b/Source/Core/DolphinWX/Src/AboutDolphin.h index 42ca3f7862..e81f93b11a 100644 --- a/Source/Core/DolphinWX/Src/AboutDolphin.h +++ b/Source/Core/DolphinWX/Src/AboutDolphin.h @@ -34,29 +34,12 @@ class AboutDolphin : public wxDialog const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE); - virtual ~AboutDolphin(); - void CloseClick(wxCommandEvent& event); private: DECLARE_EVENT_TABLE(); - wxBoxSizer *sMain; - wxBoxSizer *sButtons; - wxBoxSizer *sMainHor; - wxBoxSizer *sInfo; - - wxButton *m_Close; - wxStaticText *Message; - wxStaticBitmap *sbDolphinLogo; - - enum - { - ID_LOGO = 1000, - ID_MESSAGE - }; - + void CloseClick(wxCommandEvent& event); void OnClose(wxCloseEvent& event); - void CreateGUIControls(); }; #endif //_ABOUTDOLPHIN_H_ diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index f77346ea27..f9318f4a80 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -32,7 +32,6 @@ #include "Frame.h" #include "ConfigMain.h" #include "CheatsWindow.h" -#include "AboutDolphin.h" #include "GameListCtrl.h" #include "BootManager.h" #include "ConsoleListener.h" @@ -870,7 +869,8 @@ int GetCmdForHotkey(unsigned int key) void CFrame::OnKeyDown(wxKeyEvent& event) { - if(Core::GetState() != Core::CORE_UNINITIALIZED) + if(Core::GetState() != Core::CORE_UNINITIALIZED && + RendererHasFocus()) { int WiimoteId = -1; // Toggle fullscreen diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp index 1c507f4a6d..6d4a8d15d3 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp @@ -1163,7 +1163,6 @@ void CGameListCtrl::OnProperties(wxCommandEvent& WXUNUSED (event)) if (!iso) return; CISOProperties ISOProperties(iso->GetFileName(), this); - ISOProperties.Center(); if(ISOProperties.ShowModal() == wxID_OK) Update(); } diff --git a/Source/Core/DolphinWX/Src/ISOProperties.cpp b/Source/Core/DolphinWX/Src/ISOProperties.cpp index 8201c4f691..69f805ffe1 100644 --- a/Source/Core/DolphinWX/Src/ISOProperties.cpp +++ b/Source/Core/DolphinWX/Src/ISOProperties.cpp @@ -55,7 +55,7 @@ PHackData PHack_Data; BEGIN_EVENT_TABLE(CISOProperties, wxDialog) EVT_CLOSE(CISOProperties::OnClose) - EVT_BUTTON(ID_CLOSE, CISOProperties::OnCloseClick) + EVT_BUTTON(wxID_OK, CISOProperties::OnCloseClick) EVT_BUTTON(ID_EDITCONFIG, CISOProperties::OnEditConfig) EVT_CHOICE(ID_EMUSTATE, CISOProperties::SetRefresh) EVT_CHOICE(ID_EMU_ISSUES, CISOProperties::SetRefresh) @@ -280,7 +280,7 @@ size_t CISOProperties::CreateDirectoryTree(wxTreeItemId& parent, void CISOProperties::CreateGUIControls(bool IsWad) { - m_Close = new wxButton(this, ID_CLOSE, _("Close"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_Close = new wxButton(this, wxID_OK, _("Close"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); EditConfig = new wxButton(this, ID_EDITCONFIG, _("Edit Config"), wxDefaultPosition, wxDefaultSize); EditConfig->SetToolTip(_("This will let you Manually Edit the INI config file")); @@ -533,6 +533,7 @@ void CISOProperties::CreateGUIControls(bool IsWad) if (IsWad) m_Notebook->RemovePage(4); + m_Notebook->SetSelection(0); // Add notebook and buttons to the dialog wxBoxSizer* sMain; @@ -543,6 +544,7 @@ void CISOProperties::CreateGUIControls(bool IsWad) SetSizerAndFit(sMain); Layout(); + Center(); } void CISOProperties::OnCheckBoxClicked(wxCommandEvent& event) diff --git a/Source/Core/DolphinWX/Src/ISOProperties.h b/Source/Core/DolphinWX/Src/ISOProperties.h index 51900676a6..00276e7986 100644 --- a/Source/Core/DolphinWX/Src/ISOProperties.h +++ b/Source/Core/DolphinWX/Src/ISOProperties.h @@ -158,8 +158,7 @@ class CISOProperties : public wxDialog enum { - ID_CLOSE = 1000, - ID_TREECTRL, + ID_TREECTRL = 1000, ID_NOTEBOOK, ID_GAMECONFIG, diff --git a/Source/Core/DolphinWX/Src/InputConfigDiag.cpp b/Source/Core/DolphinWX/Src/InputConfigDiag.cpp index ed9d3fd86d..8c601c9867 100644 --- a/Source/Core/DolphinWX/Src/InputConfigDiag.cpp +++ b/Source/Core/DolphinWX/Src/InputConfigDiag.cpp @@ -191,15 +191,15 @@ void InputConfigDialog::UpdateControlReferences() (*i)->controller->UpdateReferences(g_controller_interface); } -void InputConfigDialog::ClickCancel(wxCommandEvent&) +void InputConfigDialog::ClickCancel(wxCommandEvent& event) { - Close(); + event.Skip(); } -void InputConfigDialog::ClickSave(wxCommandEvent&) +void InputConfigDialog::ClickSave(wxCommandEvent& event) { m_plugin.SaveConfig(); - Close(); + event.Skip(); } void ControlDialog::UpdateListContents() diff --git a/Source/Core/DolphinWX/Src/WiimoteConfigDiag.cpp b/Source/Core/DolphinWX/Src/WiimoteConfigDiag.cpp index 7fc4e4756c..6e49798f1b 100644 --- a/Source/Core/DolphinWX/Src/WiimoteConfigDiag.cpp +++ b/Source/Core/DolphinWX/Src/WiimoteConfigDiag.cpp @@ -159,7 +159,7 @@ void WiimoteConfigPage::RevertSource() g_wiimote_sources[m_index] = orig_source; } -void WiimoteConfigDiag::Save(wxCommandEvent&) +void WiimoteConfigDiag::Save(wxCommandEvent& event) { std::string ini_filename = File::GetUserPath(D_CONFIG_IDX) + WIIMOTE_INI_NAME ".ini"; @@ -179,13 +179,13 @@ void WiimoteConfigDiag::Save(wxCommandEvent&) inifile.Save(ini_filename); - Close(); + event.Skip(); } -void WiimoteConfigDiag::Cancel(wxCommandEvent&) +void WiimoteConfigDiag::Cancel(wxCommandEvent& event) { for (size_t p = 0; p < m_pad_notebook->GetPageCount(); ++p) ((WiimoteConfigPage*)m_pad_notebook->GetPage(p))->RevertSource(); - Close(); + event.Skip(); }