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
This commit is contained in:
Glenn Rice 2011-03-15 21:57:00 +00:00
parent f26a7288a7
commit e77059d30c
8 changed files with 42 additions and 71 deletions

View File

@ -17,35 +17,22 @@
#include "Common.h" #include "Common.h"
#include "AboutDolphin.h" #include "AboutDolphin.h"
#include "CPUDetect.h"
#include "../resources/dolphin_logo.cpp" #include "../resources/dolphin_logo.cpp"
BEGIN_EVENT_TABLE(AboutDolphin, wxDialog) BEGIN_EVENT_TABLE(AboutDolphin, wxDialog)
EVT_CLOSE(AboutDolphin::OnClose) EVT_CLOSE(AboutDolphin::OnClose)
EVT_BUTTON(wxID_CLOSE, AboutDolphin::CloseClick) EVT_BUTTON(wxID_OK, AboutDolphin::CloseClick)
END_EVENT_TABLE() END_EVENT_TABLE()
AboutDolphin::AboutDolphin(wxWindow *parent, wxWindowID id, AboutDolphin::AboutDolphin(wxWindow *parent, wxWindowID id,
const wxString &title, const wxPoint &position, const wxString &title, const wxPoint &position,
const wxSize& size, long style) const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, 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); wxMemoryInputStream istream(dolphin_logo_png, sizeof dolphin_logo_png);
wxImage iDolphinLogo(istream, wxBITMAP_TYPE_PNG); wxImage iDolphinLogo(istream, wxBITMAP_TYPE_PNG);
sbDolphinLogo = new wxStaticBitmap(this, ID_LOGO, wxStaticBitmap* const sbDolphinLogo = new wxStaticBitmap(this, wxID_ANY,
wxBitmap(iDolphinLogo), wxDefaultPosition, wxDefaultSize, 0); wxBitmap(iDolphinLogo));
std::string Text = std::string(svn_rev_str) + "\n" std::string Text = std::string(svn_rev_str) + "\n"
"Copyright (c) 2003-2011+ Dolphin Team\n" "Copyright (c) 2003-2011+ Dolphin Team\n"
@ -74,38 +61,39 @@ void AboutDolphin::CreateGUIControls()
"The emulator is for educational purposes only\n" "The emulator is for educational purposes only\n"
"and should not be used to play games you do\n" "and should not be used to play games you do\n"
"not legally own."; "not legally own.";
Message = new wxStaticText(this, ID_MESSAGE, wxStaticText* const Message = new wxStaticText(this, wxID_ANY,
wxString::FromAscii(Text.c_str()), wxString::FromAscii(Text.c_str()));
wxDefaultPosition, wxDefaultSize, 0); Message->Wrap(GetSize().GetWidth());
Message->Wrap(this->GetSize().GetWidth());
sMain = new wxBoxSizer(wxVERTICAL); wxBoxSizer* const sInfo = new wxBoxSizer(wxVERTICAL);
sMainHor = new wxBoxSizer(wxHORIZONTAL);
sMainHor->Add(sbDolphinLogo);
sInfo = new wxBoxSizer(wxVERTICAL);
sInfo->Add(Message, 1, wxEXPAND|wxALL, 5); sInfo->Add(Message, 1, wxEXPAND|wxALL, 5);
sMainHor->Add(sInfo);
sMain->Add(sMainHor, 1, wxEXPAND);
sButtons = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* const sMainHor = new wxBoxSizer(wxHORIZONTAL);
sButtons->Add(0, 0, 1, wxEXPAND, 5); sMainHor->Add(sbDolphinLogo);
sButtons->Add(m_Close, 0, wxALL, 5); 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); sMain->Add(sButtons, 0, wxEXPAND);
this->SetSizer(sMain); SetSizer(sMain);
sMain->Layout();
Layout();
Fit(); 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(); Close();
} }

View File

@ -34,29 +34,12 @@ class AboutDolphin : public wxDialog
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE); long style = wxDEFAULT_DIALOG_STYLE);
virtual ~AboutDolphin();
void CloseClick(wxCommandEvent& event);
private: private:
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
wxBoxSizer *sMain; void CloseClick(wxCommandEvent& event);
wxBoxSizer *sButtons;
wxBoxSizer *sMainHor;
wxBoxSizer *sInfo;
wxButton *m_Close;
wxStaticText *Message;
wxStaticBitmap *sbDolphinLogo;
enum
{
ID_LOGO = 1000,
ID_MESSAGE
};
void OnClose(wxCloseEvent& event); void OnClose(wxCloseEvent& event);
void CreateGUIControls();
}; };
#endif //_ABOUTDOLPHIN_H_ #endif //_ABOUTDOLPHIN_H_

View File

@ -32,7 +32,6 @@
#include "Frame.h" #include "Frame.h"
#include "ConfigMain.h" #include "ConfigMain.h"
#include "CheatsWindow.h" #include "CheatsWindow.h"
#include "AboutDolphin.h"
#include "GameListCtrl.h" #include "GameListCtrl.h"
#include "BootManager.h" #include "BootManager.h"
#include "ConsoleListener.h" #include "ConsoleListener.h"
@ -870,7 +869,8 @@ int GetCmdForHotkey(unsigned int key)
void CFrame::OnKeyDown(wxKeyEvent& event) void CFrame::OnKeyDown(wxKeyEvent& event)
{ {
if(Core::GetState() != Core::CORE_UNINITIALIZED) if(Core::GetState() != Core::CORE_UNINITIALIZED &&
RendererHasFocus())
{ {
int WiimoteId = -1; int WiimoteId = -1;
// Toggle fullscreen // Toggle fullscreen

View File

@ -1163,7 +1163,6 @@ void CGameListCtrl::OnProperties(wxCommandEvent& WXUNUSED (event))
if (!iso) if (!iso)
return; return;
CISOProperties ISOProperties(iso->GetFileName(), this); CISOProperties ISOProperties(iso->GetFileName(), this);
ISOProperties.Center();
if(ISOProperties.ShowModal() == wxID_OK) if(ISOProperties.ShowModal() == wxID_OK)
Update(); Update();
} }

View File

@ -55,7 +55,7 @@ PHackData PHack_Data;
BEGIN_EVENT_TABLE(CISOProperties, wxDialog) BEGIN_EVENT_TABLE(CISOProperties, wxDialog)
EVT_CLOSE(CISOProperties::OnClose) EVT_CLOSE(CISOProperties::OnClose)
EVT_BUTTON(ID_CLOSE, CISOProperties::OnCloseClick) EVT_BUTTON(wxID_OK, CISOProperties::OnCloseClick)
EVT_BUTTON(ID_EDITCONFIG, CISOProperties::OnEditConfig) EVT_BUTTON(ID_EDITCONFIG, CISOProperties::OnEditConfig)
EVT_CHOICE(ID_EMUSTATE, CISOProperties::SetRefresh) EVT_CHOICE(ID_EMUSTATE, CISOProperties::SetRefresh)
EVT_CHOICE(ID_EMU_ISSUES, CISOProperties::SetRefresh) EVT_CHOICE(ID_EMU_ISSUES, CISOProperties::SetRefresh)
@ -280,7 +280,7 @@ size_t CISOProperties::CreateDirectoryTree(wxTreeItemId& parent,
void CISOProperties::CreateGUIControls(bool IsWad) 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 = new wxButton(this, ID_EDITCONFIG, _("Edit Config"), wxDefaultPosition, wxDefaultSize);
EditConfig->SetToolTip(_("This will let you Manually Edit the INI config file")); EditConfig->SetToolTip(_("This will let you Manually Edit the INI config file"));
@ -533,6 +533,7 @@ void CISOProperties::CreateGUIControls(bool IsWad)
if (IsWad) if (IsWad)
m_Notebook->RemovePage(4); m_Notebook->RemovePage(4);
m_Notebook->SetSelection(0);
// Add notebook and buttons to the dialog // Add notebook and buttons to the dialog
wxBoxSizer* sMain; wxBoxSizer* sMain;
@ -543,6 +544,7 @@ void CISOProperties::CreateGUIControls(bool IsWad)
SetSizerAndFit(sMain); SetSizerAndFit(sMain);
Layout(); Layout();
Center();
} }
void CISOProperties::OnCheckBoxClicked(wxCommandEvent& event) void CISOProperties::OnCheckBoxClicked(wxCommandEvent& event)

View File

@ -158,8 +158,7 @@ class CISOProperties : public wxDialog
enum enum
{ {
ID_CLOSE = 1000, ID_TREECTRL = 1000,
ID_TREECTRL,
ID_NOTEBOOK, ID_NOTEBOOK,
ID_GAMECONFIG, ID_GAMECONFIG,

View File

@ -191,15 +191,15 @@ void InputConfigDialog::UpdateControlReferences()
(*i)->controller->UpdateReferences(g_controller_interface); (*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(); m_plugin.SaveConfig();
Close(); event.Skip();
} }
void ControlDialog::UpdateListContents() void ControlDialog::UpdateListContents()

View File

@ -159,7 +159,7 @@ void WiimoteConfigPage::RevertSource()
g_wiimote_sources[m_index] = orig_source; 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"; 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); 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) for (size_t p = 0; p < m_pad_notebook->GetPageCount(); ++p)
((WiimoteConfigPage*)m_pad_notebook->GetPage(p))->RevertSource(); ((WiimoteConfigPage*)m_pad_notebook->GetPage(p))->RevertSource();
Close(); event.Skip();
} }