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,12 +17,11 @@
#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,
@ -30,22 +29,10 @@ AboutDolphin::AboutDolphin(wxWindow *parent, wxWindowID id,
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,35 +61,36 @@ 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))
{
EndModal(wxID_OK);
EndModal(wxID_CLOSE);
}
void AboutDolphin::CloseClick(wxCommandEvent& WXUNUSED(event))

View File

@ -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_

View File

@ -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

View File

@ -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();
}

View File

@ -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)

View File

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

View File

@ -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()

View File

@ -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();
}