Make use of wxStdDialogButtonSizer wherever appropriate.

This makes button spacing more consistent and uses the native button order of the OK/Cancel/... buttons.
(Mostly) fixes issue 4390.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7581 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
NeoBrainX 2011-06-03 12:26:32 +00:00
parent 77b8813e31
commit 147e67703d
6 changed files with 30 additions and 52 deletions

View File

@ -36,7 +36,7 @@ extern CFrame* main_frame;
static wxCheatsWindow *g_cheat_window;
wxCheatsWindow::wxCheatsWindow(wxWindow* const parent)
: wxFrame(parent, wxID_ANY, _("Cheats Manager"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
: wxDialog(parent, wxID_ANY, _("Cheats Manager"), wxDefaultPosition, wxDefaultSize)
{
::g_cheat_window = this;
@ -131,13 +131,14 @@ void wxCheatsWindow::Init_ChildControls()
m_Notebook_Main->AddPage(m_Tab_Log, _("Logging"));
// Button Strip
wxButton* const button_apply = new wxButton(panel, wxID_ANY, _("Apply"), wxDefaultPosition, wxDefaultSize);
wxButton* const button_apply = new wxButton(panel, wxID_APPLY, _("Apply"), wxDefaultPosition, wxDefaultSize);
_connect_macro_(button_apply, wxCheatsWindow::OnEvent_ApplyChanges_Press, wxEVT_COMMAND_BUTTON_CLICKED, this);
wxButton* const button_close = new wxButton(panel, wxID_ANY, _("Close"), wxDefaultPosition, wxDefaultSize);
_connect_macro_(button_close, wxCheatsWindow::OnEvent_ButtonClose_Press, wxEVT_COMMAND_BUTTON_CLICKED, this);
wxBoxSizer* sButtons = new wxBoxSizer(wxHORIZONTAL);
sButtons->Add(button_apply, 1, wxRIGHT, 5);
sButtons->Add(button_close, 1, 0, 0);
wxButton* const button_cancel = new wxButton(panel, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize);
_connect_macro_(button_cancel, wxCheatsWindow::OnEvent_ButtonClose_Press, wxEVT_COMMAND_BUTTON_CLICKED, this);
wxStdDialogButtonSizer* const sButtons = new wxStdDialogButtonSizer();
sButtons->AddButton(button_apply);
sButtons->AddButton(button_cancel);
sButtons->Realize();
wxBoxSizer* const sMain = new wxBoxSizer(wxVERTICAL);
sMain->Add(m_Notebook_Main, 1, wxEXPAND|wxALL, 5);
@ -247,9 +248,9 @@ CheatSearchTab::CheatSearchTab(wxWindow* const parent)
SetSizerAndFit(sizer_main);
}
void wxCheatsWindow::OnEvent_ButtonClose_Press(wxCommandEvent& WXUNUSED (event))
void wxCheatsWindow::OnEvent_ButtonClose_Press(wxCommandEvent& ev)
{
Destroy();
ev.Skip();
}
void wxCheatsWindow::Load_ARCodes()
@ -311,7 +312,7 @@ void wxCheatsWindow::OnEvent_CheatsList_ItemToggled(wxCommandEvent& WXUNUSED (ev
}
}
void wxCheatsWindow::OnEvent_ApplyChanges_Press(wxCommandEvent& WXUNUSED (event))
void wxCheatsWindow::OnEvent_ApplyChanges_Press(wxCommandEvent& ev)
{
// Appply AR Code changes
for (size_t i = 0; i < indexList.size(); i++)
@ -328,6 +329,8 @@ void wxCheatsWindow::OnEvent_ApplyChanges_Press(wxCommandEvent& WXUNUSED (event)
Gecko::SaveCodes(m_gameini, m_geckocode_panel->GetCodes());
m_gameini.Save(m_gameini_path);
}
ev.Skip();
}
void wxCheatsWindow::OnEvent_ButtonUpdateLog_Press(wxCommandEvent& WXUNUSED (event))
@ -563,16 +566,6 @@ CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address)
sizer_value_label->Add(label_value, 0, wxRIGHT, 5);
sizer_value_label->Add(checkbox_use_hex);
wxButton* const btn_ok = new wxButton(this, wxID_OK, _("OK"));
_connect_macro_(btn_ok, CreateCodeDialog::PressOK, wxEVT_COMMAND_BUTTON_CLICKED, this);
wxButton* const btn_cancel = new wxButton(this, wxID_CANCEL, _("Cancel"));
_connect_macro_(btn_cancel, CreateCodeDialog::PressCancel, wxEVT_COMMAND_BUTTON_CLICKED, this);
// button sizer
wxSizer* const sizer_buttons = CreateButtonSizer(wxNO_DEFAULT);
sizer_buttons->Add(btn_ok, 0, wxRIGHT, 5);
sizer_buttons->Add(btn_cancel);
// main sizer
wxBoxSizer* const sizer_main = new wxBoxSizer(wxVERTICAL);
sizer_main->Add(label_name, 0, wxALL, 5);
@ -581,13 +574,15 @@ CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address)
sizer_main->Add(textctrl_code, 0, wxALL, 5);
sizer_main->Add(sizer_value_label, 0, wxALL, 5);
sizer_main->Add(textctrl_value, 0, wxALL, 5);
sizer_main->Add(sizer_buttons, 0, wxALL | wxALIGN_RIGHT, 5);
sizer_main->Add(CreateButtonSizer(wxOK | wxCANCEL | wxNO_DEFAULT), 0, wxALL, 5);
Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CreateCodeDialog::PressOK));
Connect(wxID_CANCEL, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CreateCodeDialog::PressCancel));
SetSizerAndFit(sizer_main);
SetFocus();
}
void CreateCodeDialog::PressOK(wxCommandEvent&)
void CreateCodeDialog::PressOK(wxCommandEvent& ev)
{
const wxString code_name = textctrl_name->GetValue();
if (code_name.empty())
@ -628,10 +623,10 @@ void CreateCodeDialog::PressOK(wxCommandEvent&)
// refresh arcode list in other tab
::g_cheat_window->Load_ARCodes();
Destroy();
ev.Skip();
}
void CreateCodeDialog::PressCancel(wxCommandEvent&)
void CreateCodeDialog::PressCancel(wxCommandEvent& ev)
{
Destroy();
ev.Skip();
}

View File

@ -101,7 +101,7 @@ protected:
void ApplyFocus(wxCommandEvent&);
};
class wxCheatsWindow : public wxFrame
class wxCheatsWindow : public wxDialog
{
friend class CreateCodeDialog;
@ -116,9 +116,6 @@ class wxCheatsWindow : public wxFrame
size_t index;
};
// Event Table
//DECLARE_EVENT_TABLE();
// --- GUI Controls ---
wxNotebook *m_Notebook_Main;

View File

@ -555,14 +555,14 @@ void CISOProperties::CreateGUIControls(bool IsWad)
}
wxSizer* sButtons = CreateButtonSizer(wxNO_DEFAULT);
sButtons->Prepend(EditConfig, 0, wxALL, 5);
sButtons->Add(new wxButton(this, wxID_OK, _("Close")), 0, wxALL, 5);
sButtons->Prepend(EditConfig);
sButtons->Add(new wxButton(this, wxID_OK, _("Close")));
// Add notebook and buttons to the dialog
wxBoxSizer* sMain;
sMain = new wxBoxSizer(wxVERTICAL);
sMain->Add(m_Notebook, 1, wxEXPAND|wxALL, 5);
sMain->Add(sButtons, 0, wxEXPAND, 5);
sMain->Add(sButtons, 0, wxEXPAND|wxLEFT|wxRIGHT|wxBOTTOM, 5);
sMain->SetMinSize(wxSize(500, -1));
SetSizerAndFit(sMain);

View File

@ -972,17 +972,11 @@ InputConfigDialog::InputConfigDialog(wxWindow* const parent, InputPlugin& plugin
UpdateDeviceComboBox();
UpdateProfileComboBox();
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"));
wxSizer* btns = CreateButtonSizer(wxNO_DEFAULT);
btns->Add(cancel_button);
btns->Add(close_button);
Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(InputConfigDialog::ClickSave));
wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL);
szr->Add(m_pad_notebook, 0, wxEXPAND|wxTOP|wxLEFT|wxRIGHT, 5);
szr->Add(btns, 0, wxEXPAND|wxALL, 5);
szr->Add(CreateButtonSizer(wxOK | wxCANCEL | wxNO_DEFAULT), 0, wxEXPAND|wxALL, 5);
SetSizerAndFit(szr);
Center();

View File

@ -26,8 +26,6 @@ UDPConfigDiag::UDPConfigDiag(wxWindow * const parent, UDPWrapper * _wrp) :
nun = new wxCheckBox(this, wxID_ANY, _("Nunchuk"));
nunaccel = new wxCheckBox(this, wxID_ANY, _("Nunchuk Acceleration"));
wxButton *const ok_butt = new wxButton(this, wxID_OK, _("OK"));
wxBoxSizer *const port_sizer = new wxBoxSizer(wxHORIZONTAL);
port_sizer->Add(new wxStaticText(this, wxID_ANY, _("UDP Port:")), 0, wxALIGN_CENTER);
port_tbox = new wxTextCtrl(this, wxID_ANY, wxString::FromUTF8(wrp->port.c_str()));
@ -57,7 +55,7 @@ UDPConfigDiag::UDPConfigDiag(wxWindow * const parent, UDPWrapper * _wrp) :
sizer2->Add(nun, 1, wxALL | wxEXPAND, 5);
sizer2->Add(nunaccel, 1, wxALL | wxEXPAND, 5);
outer_sizer->Add(ok_butt, 0, wxALL | wxALIGN_RIGHT, 5);
outer_sizer->Add(CreateButtonSizer(wxOK), 0, wxALL | wxALIGN_RIGHT, 5);
SetSizerAndFit(outer_sizer);
Center();

View File

@ -165,18 +165,12 @@ WiimoteConfigDiag::WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin
}
m_pad_notebook->SetSelection(0);
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);
wxSizer* const button_sizer = CreateButtonSizer(wxNO_DEFAULT);
button_sizer->Add(cancel_button, 0, wxALIGN_RIGHT | wxRIGHT, 5);
button_sizer->Add(ok_button, 0, wxALIGN_RIGHT);
Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(WiimoteConfigDiag::Save));
Connect(wxID_CANCEL, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(WiimoteConfigDiag::Cancel));
wxBoxSizer* const main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(m_pad_notebook, 1, wxEXPAND | wxALL, 5);
main_sizer->Add(button_sizer, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 5);
main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
SetSizerAndFit(main_sizer);