diff --git a/common/build/Utilities/Utilities.cbp b/common/build/Utilities/Utilities.cbp index ca76f19964..fe26f9f0be 100644 --- a/common/build/Utilities/Utilities.cbp +++ b/common/build/Utilities/Utilities.cbp @@ -1,129 +1,131 @@ - - - - - - + + + + + + diff --git a/common/build/Utilities/utilities.vcproj b/common/build/Utilities/utilities.vcproj index aefa145428..2a009cca43 100644 --- a/common/build/Utilities/utilities.vcproj +++ b/common/build/Utilities/utilities.vcproj @@ -255,6 +255,10 @@ /> + + @@ -469,6 +473,10 @@ RelativePath="..\..\src\Utilities\PrecompiledHeader.h" > + + diff --git a/common/include/Utilities/pxRadioPanel.h b/common/include/Utilities/pxRadioPanel.h new file mode 100644 index 0000000000..2eece126b4 --- /dev/null +++ b/common/include/Utilities/pxRadioPanel.h @@ -0,0 +1,178 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2009 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +#pragma once + +#include +#include "SafeArray.h" +#include "wxGuiTools.h" + +// -------------------------------------------------------------------------------------- +// RadioPanelItem +// -------------------------------------------------------------------------------------- + +struct RadioPanelItem +{ + wxString Label; + wxString SubText; + wxString ToolTip; + + RadioPanelItem( const wxString& label, const wxString& subtext=wxEmptyString, const wxString& tooltip=wxEmptyString ) + : Label( label ) + , SubText( subtext ) + , ToolTip( tooltip ) + { + } + + RadioPanelItem& SetToolTip( const wxString& tip ) + { + ToolTip = tip; + return *this; + } + + RadioPanelItem& SetSubText( const wxString& text ) + { + SubText = text; + return *this; + } +}; + + +// Used as a cache for the "original" labels and subtexts, so that text can be properly +// wrapped and re-wrapped with multiple calls to OnResize(). +struct RadioPanelObjects +{ + wxRadioButton* LabelObj; + wxStaticText* SubTextObj; +}; + +// -------------------------------------------------------------------------------------- +// pxRadioPanel +// -------------------------------------------------------------------------------------- +// Radio buttons work best when they are created consecutively, and then their subtext +// created in a second sweep (this keeps the radio buttons together in the parent window's +// child list, and avoids potentially unwanted behavior with radio buttons failing to +// group expectedly). Because of this, our radio button helper is shaped as a panel of +// a group of radio butons only, instead of bothering with the lower level per-button +// design. This makes a few other things nicer as well, such as binding a single message +// handler to all radio buttons in the panel. +// +// The SetToolTip API provided by this function applies the tooltip to both both the radio +// button and it's static subtext (if present), and performs word wrapping on platforms +// that need it (eg mswindows). +// +class pxRadioPanel : public wxPanelWithHelpers +{ +protected: + typedef std::vector ButtonArray; + typedef SafeArray ButtonObjArray; + + ButtonArray m_buttonStrings; + ButtonObjArray m_objects; + + bool m_IsRealized; + int m_idealWidth; + + wxSize m_padding; + int m_Indentation; + +public: + template< int size > + pxRadioPanel( wxPanelWithHelpers* parent, const RadioPanelItem (&src)[size] ) + : wxPanelWithHelpers( parent, parent->GetIdealWidth() ) + { + Init( src, size ); + } + + template< int size > + pxRadioPanel( wxDialogWithHelpers* parent, const RadioPanelItem (&src)[size] ) + : wxDialogWithHelpers( parent, parent->GetIdealWidth() ) + { + Init( src, size ); + } + + template< int size > + pxRadioPanel( int idealWidth, wxWindow* parent, const RadioPanelItem (&src)[size] ) + : wxPanelWithHelpers( parent, idealWidth ) + { + Init( src, size ); + } + + pxRadioPanel( wxPanelWithHelpers* parent ) + : wxPanelWithHelpers( parent, parent->GetIdealWidth() ) + { + Init(); + } + + pxRadioPanel( wxDialogWithHelpers* parent ) + : wxPanelWithHelpers( parent, parent->GetIdealWidth() ) + { + Init(); + } + + pxRadioPanel( int idealWidth, wxPanelWithHelpers* parent ) + : wxPanelWithHelpers( parent, idealWidth ) + { + Init(); + } + + virtual ~pxRadioPanel() throw() {} + + void Reset(); + void Realize(); + + wxStaticText* GetSubText( int idx ); + const wxStaticText* GetSubText( int idx ) const; + pxRadioPanel& Append( const RadioPanelItem& entry ); + + pxRadioPanel& SetToolTip( int idx, const wxString& tip ); + pxRadioPanel& SetSelection( int idx ); + + int GetSelection() const; + wxWindowID GetSelectionId() const; + bool IsSelected( int idx ) const; + + wxRadioButton* GetButton( int idx ); + const wxRadioButton* GetButton( int idx ) const; + + int GetPaddingHoriz() const { return m_padding.GetHeight(); } + int GetIndentation() const { return m_Indentation; } + + pxRadioPanel& SetPaddingHoriz( int newpad ) + { + m_padding.SetHeight( newpad ); + return *this; + } + + pxRadioPanel& SetIndentation( int newdent ) + { + m_Indentation = newdent; + return *this; + } + + bool HasSubText( int idx ) const + { + return !m_buttonStrings[idx].SubText.IsEmpty(); + } + + pxRadioPanel& Append( const wxString& label, const wxString& subtext=wxEmptyString, const wxString& tooltip=wxEmptyString ) + { + return Append( RadioPanelItem(label, subtext, tooltip) ); + } + +protected: + void Init( const RadioPanelItem* srcArray=NULL, int arrsize=0 ); + void pxRadioPanel::_setToolTipImmediate( int idx, const wxString &tip ); +}; diff --git a/common/include/Utilities/wxBaseTools.h b/common/include/Utilities/wxBaseTools.h index 49289e79e2..13c09cdda0 100644 --- a/common/include/Utilities/wxBaseTools.h +++ b/common/include/Utilities/wxBaseTools.h @@ -26,6 +26,11 @@ // which require wxCore, see wxGuiTools.h // -------------------------------------------------------------------------------------- +extern void pxExplore( const wxString& path ); +extern void pxExplore( const char *path ); + +extern void pxLaunch( const wxString& path ); +extern void pxLaunch( const char *path ); // -------------------------------------------------------------------------------------- // wxDoNotLogInThisScope diff --git a/common/include/Utilities/wxGuiTools.h b/common/include/Utilities/wxGuiTools.h index 7daaf5451c..21f03955c8 100644 --- a/common/include/Utilities/wxGuiTools.h +++ b/common/include/Utilities/wxGuiTools.h @@ -21,6 +21,8 @@ #include "ScopedPtr.h" #include +#include + // ---------------------------------------------------------------------------- // wxGuiTools.h // @@ -30,6 +32,69 @@ // them. For tools which require only wxBase, see wxBaseTools.h // ---------------------------------------------------------------------------- +namespace pxSizerFlags +{ + extern wxSizerFlags StdSpace(); + extern wxSizerFlags StdCenter(); + extern wxSizerFlags StdExpand(); + extern wxSizerFlags TopLevelBox(); + extern wxSizerFlags SubGroup(); + extern wxSizerFlags StdButton(); + extern wxSizerFlags Checkbox(); +}; + +// -------------------------------------------------------------------------------------- +// wxDialogWithHelpers +// -------------------------------------------------------------------------------------- +class wxDialogWithHelpers : public wxDialog +{ +protected: + bool m_hasContextHelp; + int m_idealWidth; + +public: + wxDialogWithHelpers(wxWindow* parent, int id, const wxString& title, bool hasContextHelp, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize ); + virtual ~wxDialogWithHelpers() throw(); + + wxStaticText& AddStaticText(wxSizer& sizer, const wxString& label, int alignFlags=wxALIGN_CENTRE, int size=wxDefaultCoord ); + void AddOkCancel( wxSizer& sizer, bool hasApply=false ); + + wxDialogWithHelpers& SetIdealWidth( int newWidth ) { m_idealWidth = newWidth; return *this; } + int GetIdealWidth() const { return m_idealWidth; } + bool HasIdealWidth() const { return m_idealWidth != wxDefaultCoord; } + +protected: + +}; + +// -------------------------------------------------------------------------------------- +// wxPanelWithHelpers +// -------------------------------------------------------------------------------------- +class wxPanelWithHelpers : public wxPanel +{ +protected: + int m_idealWidth; + bool m_StartNewRadioGroup; + +public: + wxPanelWithHelpers( wxWindow* parent, int idealWidth=wxDefaultCoord ); + wxPanelWithHelpers( wxWindow* parent, const wxPoint& pos, const wxSize& size=wxDefaultSize ); + + //wxRadioButton& NewSpinCtrl( const wxString& label, const wxString& subtext=wxEmptyString, const wxString& tooltip=wxEmptyString ); + + //wxRadioButton& AddRadioButton( wxSizer& sizer, const wxString& label, const wxString& subtext=wxEmptyString, const wxString& tooltip=wxEmptyString ); + wxStaticText& AddStaticText(wxSizer& sizer, const wxString& label, int alignFlags=wxALIGN_CENTRE, int size=wxDefaultCoord ); + + wxPanelWithHelpers& SetIdealWidth( int newWidth ) { m_idealWidth = newWidth; return *this; } + int GetIdealWidth() const { return m_idealWidth; } + bool HasIdealWidth() const { return m_idealWidth != wxDefaultCoord; } + + void StartRadioGroup() { m_StartNewRadioGroup = true; } + +protected: +}; + + // -------------------------------------------------------------------------------------- // pxTextWrapperBase // -------------------------------------------------------------------------------------- diff --git a/common/src/Utilities/PathUtils.cpp b/common/src/Utilities/PathUtils.cpp index dc07e6640f..e521f096ac 100644 --- a/common/src/Utilities/PathUtils.cpp +++ b/common/src/Utilities/PathUtils.cpp @@ -17,6 +17,7 @@ #include "Path.h" #include +#include // --------------------------------------------------------------------------------- // wxDirName Implementations @@ -168,3 +169,31 @@ wxString Path::GetRootDirectory( const wxString& src ) return wxString( src.begin(), src.begin()+pos ); } +// ------------------------------------------------------------------------ +// Launches the specified file according to its mime type +// +void pxLaunch( const wxString& filename ) +{ + wxLaunchDefaultBrowser( filename ); +} + +void pxLaunch(const char *filename) +{ + pxLaunch( fromUTF8(filename) ); +} + +// ------------------------------------------------------------------------ +// Launches a file explorer window on the specified path. If the given path is not +// a qualified URI (with a prefix:// ), file:// is automatically prepended. This +// bypasses wxWidgets internal filename checking, which can end up launching things +// through browser more often than desired. +// +void pxExplore( const wxString& path ) +{ + wxLaunchDefaultBrowser( !path.Contains( L"://") ? L"file://" + path : path ); +} + +void pxExplore(const char *path) +{ + pxExplore( fromUTF8(path) ); +} diff --git a/common/src/Utilities/pxRadioPanel.cpp b/common/src/Utilities/pxRadioPanel.cpp new file mode 100644 index 0000000000..96b64d39b8 --- /dev/null +++ b/common/src/Utilities/pxRadioPanel.cpp @@ -0,0 +1,192 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2009 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +#include "PrecompiledHeader.h" +#include "pxRadioPanel.h" + + +// =========================================================================================== +// pxRadioPanel Implementations +// =========================================================================================== + +#define VerifyRealizedState() \ + pxAssertDev( m_IsRealized, "Invalid object state: RadioButtonGroup as not been realized." ) + +void pxRadioPanel::Init( const RadioPanelItem* srcArray, int arrsize ) +{ + m_IsRealized = false; + + // FIXME: This probably needs to be platform-dependent, and/or based on font size. + m_Indentation = 23; + + SetSizer( new wxBoxSizer(wxVERTICAL) ); + + for( int i=0; i 0) && pxAssertMsg( m_idealWidth < 40, "Unusably short text wrapping specified!" ) ) + m_objects[i].SubTextObj->Wrap( m_idealWidth - m_Indentation ); + } + + pxAssert( GetSizer() != NULL ); + wxSizer& sizer( *GetSizer() ); + for( int i=0; iSetToolTip( wrapped ); + + if( wxStaticText* woot = m_objects[idx].SubTextObj ) + woot->SetToolTip( wrapped ); +} + +pxRadioPanel& pxRadioPanel::SetToolTip(int idx, const wxString &tip) +{ + m_buttonStrings[idx].SetToolTip( tip ); + + if( m_IsRealized ) + _setToolTipImmediate( idx, tip ); + + return *this; +} + +pxRadioPanel& pxRadioPanel::SetSelection( int idx ) +{ + if( !VerifyRealizedState() ) return *this; + + pxAssert( m_objects[idx].LabelObj != NULL ); + m_objects[idx].LabelObj->SetValue( true ); + return *this; +} + +int pxRadioPanel::GetSelection() const +{ + if( !VerifyRealizedState() ) return 0; + + for( uint i=0; iGetValue() ) return i; + } + + // Technically radio buttons should never allow for a case where none are selected. + // However it *can* happen on some platforms if the program code doesn't explicitly + // select one of the members of the group (which is, as far as I'm concerned, a + // programmer error!). so Assert here in such cases, and return 0 as the assumed + // default, so that calling code has a "valid" return code in release builds. + + pxFailDev( "No valid selection was found in this group!" ); + return 0; +} + +// Returns the wxWindowID for the currently selected radio button. +wxWindowID pxRadioPanel::GetSelectionId() const +{ + if( !VerifyRealizedState() ) return 0; + return m_objects[GetSelection()].LabelObj->GetId(); +} + + +bool pxRadioPanel::IsSelected( int idx ) const +{ + if( VerifyRealizedState() ) return false; + pxAssert( m_objects[idx].LabelObj != NULL ); + return m_objects[idx].LabelObj->GetValue(); +} + +wxStaticText* pxRadioPanel::GetSubText( int idx ) +{ + if( VerifyRealizedState() ) return NULL; + return m_objects[idx].SubTextObj; +} + +const wxStaticText* pxRadioPanel::GetSubText( int idx ) const +{ + if( VerifyRealizedState() ) return NULL; + return m_objects[idx].SubTextObj; +} + +wxRadioButton* pxRadioPanel::GetButton( int idx ) +{ + if( VerifyRealizedState() ) return NULL; + return m_objects[idx].LabelObj; +} + +const wxRadioButton* pxRadioPanel::GetButton( int idx ) const +{ + if( VerifyRealizedState() ) return NULL; + return m_objects[idx].LabelObj; +} diff --git a/common/src/Utilities/wxGuiTools.cpp b/common/src/Utilities/wxGuiTools.cpp index f0df4937c1..05288faf66 100644 --- a/common/src/Utilities/wxGuiTools.cpp +++ b/common/src/Utilities/wxGuiTools.cpp @@ -40,6 +40,64 @@ wxRect wxGetDisplayArea() return wxRect( wxPoint(), wxGetDisplaySize() ); } +// -------------------------------------------------------------------------------------- +// pxSizerFlags +// -------------------------------------------------------------------------------------- +// FlagsAccessors - Provides read-write copies of standard sizer flags for our interface. +// These standard definitions provide a consistent and pretty interface for our GUI. +// Without them things look compacted, misaligned, and yucky! +// +// Implementation Note: Accessors are all provisioned as dynamic (realtime) sizer calculations. +// I've preferred this over cstatic const variables on the premise that spacing logic could +// in the future become a dynamic value (currently it is affixed to 6 for most items). +// +wxSizerFlags pxSizerFlags::StdSpace() +{ + return wxSizerFlags().Border( wxALL, 6 ); +} + +wxSizerFlags pxSizerFlags::StdCenter() +{ + return wxSizerFlags().Align( wxALIGN_CENTER ).DoubleBorder(); +} + +wxSizerFlags pxSizerFlags::StdExpand() +{ + return StdSpace().Expand(); +} + +// A good sizer flags setting for top-level static boxes or top-level picture boxes. +// Gives a generous border to the left, right, and bottom. Top border can be configured +// manually by using a spacer. +wxSizerFlags pxSizerFlags::TopLevelBox() +{ + return wxSizerFlags().Border( wxLEFT | wxBOTTOM | wxRIGHT, 6 ).Expand(); +} + +// Flags intended for use on grouped StaticBox controls. These flags are ideal for +// StaticBoxes that are part of sub-panels or children of other static boxes, but may +// not be best for parent StaticBoxes on dialogs (left and right borders feel a bit +// "tight"). +wxSizerFlags pxSizerFlags::SubGroup() +{ + // Groups look better with a slightly smaller margin than standard. + // (basically this accounts for the group's frame) + return wxSizerFlags().Border( wxLEFT | wxBOTTOM | wxRIGHT, 4 ).Expand(); +} + +// This force-aligns the std button sizer to the right, where (at least) us win32 platform +// users always expect it to be. Most likely Mac platforms expect it on the left side +// just because it's *not* where win32 sticks it. Too bad! +wxSizerFlags pxSizerFlags::StdButton() +{ + return wxSizerFlags().Align( wxALIGN_RIGHT ).Border(); +} + +wxSizerFlags pxSizerFlags::Checkbox() +{ + return StdExpand(); +} + // -------------------------------------------------------------------------------------- // pxTextWrapper / pxTextWrapperBase Implementations // -------------------------------------------------------------------------------------- diff --git a/pcsx2/gui/AppInit.cpp b/pcsx2/gui/AppInit.cpp index d630cdce15..c8985c2387 100644 --- a/pcsx2/gui/AppInit.cpp +++ b/pcsx2/gui/AppInit.cpp @@ -93,7 +93,7 @@ void Pcsx2App::ReadUserModeSettings() L"programmers. This is normal. We're working on it.\n\nYou have been warned!", wxALIGN_CENTER, 600 ); - s_main.Add( new wxButton( &preAlpha, wxID_OK ), wxHelpers::SizerFlags::StdCenter() ); + s_main.Add( new wxButton( &preAlpha, wxID_OK ), pxSizerFlags::StdCenter() ); preAlpha.SetSizerAndFit( &s_main ); preAlpha.CentreOnScreen(); preAlpha.ShowModal(); diff --git a/pcsx2/gui/Dialogs/AboutBoxDialog.cpp b/pcsx2/gui/Dialogs/AboutBoxDialog.cpp index 39963c442d..06c65053e3 100644 --- a/pcsx2/gui/Dialogs/AboutBoxDialog.cpp +++ b/pcsx2/gui/Dialogs/AboutBoxDialog.cpp @@ -100,18 +100,18 @@ Dialogs::AboutBoxDialog::AboutBoxDialog( wxWindow* parent, int id ): label_auth->Wrap( 340 ); label_greets->Wrap( 200 ); - aboutUs.Add( label_auth, SizerFlags::StdExpand() ); - contribs.Add( label_greets, SizerFlags::StdExpand() ); + aboutUs.Add( label_auth, pxSizerFlags::StdExpand() ); + contribs.Add( label_greets, pxSizerFlags::StdExpand() ); AuthLogoSizer.Add( &aboutUs ); AuthLogoSizer.AddSpacer( 7 ); AuthLogoSizer.Add( &contribs ); ContribSizer.AddStretchSpacer( 1 ); - ContribSizer.Add( &m_bitmap_dualshock, SizerFlags::StdSpace() ); + ContribSizer.Add( &m_bitmap_dualshock, pxSizerFlags::StdSpace() ); ContribSizer.AddStretchSpacer( 1 ); - mainSizer.Add( &AuthLogoSizer, SizerFlags::StdSpace() ); + mainSizer.Add( &AuthLogoSizer, pxSizerFlags::StdSpace() ); mainSizer.Add( new wxHyperlinkCtrl( this, wxID_ANY, L"Pcsx2 Official Website and Forums" , L"http://www.pcsx2.net" ), @@ -120,9 +120,9 @@ Dialogs::AboutBoxDialog::AboutBoxDialog( wxWindow* parent, int id ): this, wxID_ANY, L"Pcsx2 Official Svn Repository at Googlecode" , L"http://code.google.com/p/pcsx2" ), wxSizerFlags(1).Center().Border( wxALL, 3 ) ); - mainSizer.Add( &ContribSizer, SizerFlags::StdExpand() ); + mainSizer.Add( &ContribSizer, pxSizerFlags::StdExpand() ); - mainSizer.Add( new wxButton( this, wxID_OK, L"I've seen enough"), SizerFlags::StdCenter() ); + mainSizer.Add( new wxButton( this, wxID_OK, L"I've seen enough"), pxSizerFlags::StdCenter() ); SetSizerAndFit( &mainSizer ); CenterOnScreen(); diff --git a/pcsx2/gui/Dialogs/ConfigurationDialog.cpp b/pcsx2/gui/Dialogs/ConfigurationDialog.cpp index 36be09dd84..0aeecb7b43 100644 --- a/pcsx2/gui/Dialogs/ConfigurationDialog.cpp +++ b/pcsx2/gui/Dialogs/ConfigurationDialog.cpp @@ -153,7 +153,7 @@ Dialogs::BiosSelectorDialog::BiosSelectorDialog( wxWindow* parent, int id ) : Panels::BaseSelectorPanel* selpan = new Panels::BiosSelectorPanel( *this, 500 ); - bleh.Add( selpan, SizerFlags::StdExpand() ); + bleh.Add( selpan, pxSizerFlags::StdExpand() ); AddOkCancel( bleh, false ); SetSizerAndFit( &bleh ); diff --git a/pcsx2/gui/Dialogs/ConfirmationDialogs.cpp b/pcsx2/gui/Dialogs/ConfirmationDialogs.cpp index 106de09a10..a8c777eb29 100644 --- a/pcsx2/gui/Dialogs/ConfirmationDialogs.cpp +++ b/pcsx2/gui/Dialogs/ConfirmationDialogs.cpp @@ -126,12 +126,8 @@ wxWindowID Dialogs::IssueConfirmation( wxWindow* parent, const wxString& disable // Add an option that allows the user to disable this popup from showing again. // (and if the config hasn't been initialized yet, then assume the dialog as non-disablable) - wxBoxSizer& cboxPad = *new wxBoxSizer( wxHORIZONTAL ); - wxCheckBox& DisablerCtrl( - AddCheckBoxTo( &confirmDlg, cboxPad, _("Do not show this dialog again.")) - ); - - confirmDlg.GetExtensibleSizer().Add( &cboxPad, wxSizerFlags().Centre() ); + pxCheckBox& DisablerCtrl( *new pxCheckBox(&confirmDlg, _("Do not show this dialog again.")) ); + confirmDlg.GetExtensibleSizer().Add( &DisablerCtrl, wxSizerFlags().Centre() ); if( type != ConfButtons().OK() ) pxSetToolTip(&DisablerCtrl, _("Disables this popup and whatever response you select here will be automatically used from now on.")); @@ -162,7 +158,7 @@ Dialogs::ExtensibleConfirmation::ExtensibleConfirmation( wxWindow* parent, const // Add the message padded some (StdCenter gives us a 5 pt padding). Helps emphasize it a bit. wxBoxSizer& msgPadSizer( *new wxBoxSizer(wxVERTICAL) ); AddStaticText( msgPadSizer, msg, wxALIGN_CENTRE, 444 ); - mainsizer.Add( &msgPadSizer, SizerFlags::StdCenter() ); + mainsizer.Add( &msgPadSizer, pxSizerFlags::StdCenter() ); mainsizer.Add( &m_ExtensibleSizer, wxSizerFlags().Centre() ); @@ -219,7 +215,7 @@ Dialogs::ExtensibleConfirmation::ExtensibleConfirmation( wxWindow* parent, const AddActionButton( wxID_CANCEL ); #endif - mainsizer.Add( &m_ButtonSizer, SizerFlags::StdCenter() ); + mainsizer.Add( &m_ButtonSizer, pxSizerFlags::StdCenter() ); SetSizerAndFit( &mainsizer, true ); CenterOnScreen(); @@ -232,13 +228,13 @@ void Dialogs::ExtensibleConfirmation::OnActionButtonClicked( wxCommandEvent& evt void Dialogs::ExtensibleConfirmation::AddCustomButton( wxWindowID id, const wxString& label ) { - m_ButtonSizer.Add( new wxButton( this, id, label ), SizerFlags::StdButton() )->SetProportion( 6 ); + m_ButtonSizer.Add( new wxButton( this, id, label ), pxSizerFlags::StdButton() )->SetProportion( 6 ); Connect( id, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ExtensibleConfirmation::OnActionButtonClicked ) ); } void Dialogs::ExtensibleConfirmation::AddActionButton( wxWindowID id ) { - m_ButtonSizer.Add( new wxButton( this, id ), SizerFlags::StdButton() )->SetProportion( 6 ); + m_ButtonSizer.Add( new wxButton( this, id ), pxSizerFlags::StdButton() )->SetProportion( 6 ); Connect( id, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ExtensibleConfirmation::OnActionButtonClicked ) ); } diff --git a/pcsx2/gui/Dialogs/FirstTimeWizard.cpp b/pcsx2/gui/Dialogs/FirstTimeWizard.cpp index 36f1e63c03..c4e46ff45f 100644 --- a/pcsx2/gui/Dialogs/FirstTimeWizard.cpp +++ b/pcsx2/gui/Dialogs/FirstTimeWizard.cpp @@ -64,11 +64,11 @@ FirstTimeWizard::UsermodePage::UsermodePage( wxWizard* parent ) : wxBoxSizer& usermodeSizer( *new wxBoxSizer( wxVERTICAL ) ); AddStaticTextTo( this, usermodeSizer, _("PCSX2 is starting from a new or unknown folder and needs to be configured.") ); - usermodeSizer.Add( &m_panel_LangSel, SizerFlags::StdCenter() ); + usermodeSizer.Add( &m_panel_LangSel, pxSizerFlags::StdCenter() ); usermodeSizer.Add( &m_panel_UserSel, wxSizerFlags().Expand().Border( wxALL, 8 ) ); usermodeSizer.AddSpacer( 6 ); - usermodeSizer.Add( &m_dirpick_settings, SizerFlags::SubGroup() ); + usermodeSizer.Add( &m_dirpick_settings, pxSizerFlags::SubGroup() ); SetSizer( &usermodeSizer ); Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(FirstTimeWizard::UsermodePage::OnUsermodeChanged) ); @@ -93,12 +93,12 @@ FirstTimeWizard::FirstTimeWizard( wxWindow* parent ) : { // Page 2 - Plugins Panel wxBoxSizer& pluginSizer( *new wxBoxSizer( wxVERTICAL ) ); - pluginSizer.Add( &m_panel_PluginSel, SizerFlags::StdExpand() ); + pluginSizer.Add( &m_panel_PluginSel, pxSizerFlags::StdExpand() ); m_page_plugins.SetSizer( &pluginSizer ); // Page 3 - Bios Panel wxBoxSizer& biosSizer( *new wxBoxSizer( wxVERTICAL ) ); - biosSizer.Add( &m_panel_BiosSel, SizerFlags::StdExpand() ); + biosSizer.Add( &m_panel_BiosSel, pxSizerFlags::StdExpand() ); m_page_bios.SetSizer( &biosSizer ); // Assign page indexes as client data diff --git a/pcsx2/gui/Dialogs/ImportSettingsDialog.cpp b/pcsx2/gui/Dialogs/ImportSettingsDialog.cpp index f3d329ec4f..9da250ca03 100644 --- a/pcsx2/gui/Dialogs/ImportSettingsDialog.cpp +++ b/pcsx2/gui/Dialogs/ImportSettingsDialog.cpp @@ -39,14 +39,14 @@ Dialogs::ImportSettingsDialog::ImportSettingsDialog( wxWindow* parent ) : wxButton* b_import = new wxButton( this, wxID_ANY, _("Import") ); wxButton* b_over = new wxButton( this, wxID_ANY, _("Overwrite") ); - s_buttons.Add( b_import,SizerFlags::StdButton() ); + s_buttons.Add( b_import,pxSizerFlags::StdButton() ); s_buttons.AddSpacer( 16 ); - s_buttons.Add( b_over, SizerFlags::StdButton() ); + s_buttons.Add( b_over, pxSizerFlags::StdButton() ); s_buttons.AddSpacer( 16 ); - s_buttons.Add( new wxButton( this, wxID_CANCEL ), SizerFlags::StdButton() ); + s_buttons.Add( new wxButton( this, wxID_CANCEL ), pxSizerFlags::StdButton() ); sizer.AddSpacer( 12 ); - sizer.Add( &s_buttons, SizerFlags::StdCenter() ); + sizer.Add( &s_buttons, pxSizerFlags::StdCenter() ); SetSizerAndFit( &sizer ); Connect( b_import->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(ImportSettingsDialog::OnImport_Click) ); diff --git a/pcsx2/gui/Dialogs/PickUserModeDialog.cpp b/pcsx2/gui/Dialogs/PickUserModeDialog.cpp index 96d1541ad7..0515b95401 100644 --- a/pcsx2/gui/Dialogs/PickUserModeDialog.cpp +++ b/pcsx2/gui/Dialogs/PickUserModeDialog.cpp @@ -30,7 +30,7 @@ Dialogs::PickUserModeDialog::PickUserModeDialog( wxWindow* parent, int id ) : AddStaticText( s_main, _("PCSX2 is starting from a new or unknown folder and needs to be configured.") ); - s_main.Add( m_panel_langsel, SizerFlags::StdCenter() ); + s_main.Add( m_panel_langsel, pxSizerFlags::StdCenter() ); s_main.Add( m_panel_usersel, wxSizerFlags().Expand().Border( wxALL, 8 ) ); AddOkCancel( s_main ); diff --git a/pcsx2/gui/Panels/BiosSelectorPanel.cpp b/pcsx2/gui/Panels/BiosSelectorPanel.cpp index 0a6ab99da0..d15026efe2 100644 --- a/pcsx2/gui/Panels/BiosSelectorPanel.cpp +++ b/pcsx2/gui/Panels/BiosSelectorPanel.cpp @@ -85,9 +85,9 @@ Panels::BiosSelectorPanel::BiosSelectorPanel( wxWindow& parent, int idealWidth ) wxBoxSizer& sizer( *new wxBoxSizer( wxVERTICAL ) ); AddStaticText( sizer, _("Select a BIOS rom:"), wxALIGN_LEFT ); - sizer.Add( &m_ComboBox, SizerFlags::StdExpand() ); + sizer.Add( &m_ComboBox, pxSizerFlags::StdExpand() ); sizer.AddSpacer( 6 ); - sizer.Add( &m_FolderPicker, SizerFlags::StdExpand() ); + sizer.Add( &m_FolderPicker, pxSizerFlags::StdExpand() ); SetSizer( &sizer ); } diff --git a/pcsx2/gui/Panels/ConfigurationPanels.h b/pcsx2/gui/Panels/ConfigurationPanels.h index 2599c35fde..6481e3484c 100644 --- a/pcsx2/gui/Panels/ConfigurationPanels.h +++ b/pcsx2/gui/Panels/ConfigurationPanels.h @@ -28,6 +28,7 @@ #include "BaseConfigPanel.h" #include "Utilities/Threading.h" +#include "Utilities/pxRadioPanel.h" namespace Panels { @@ -36,8 +37,7 @@ namespace Panels class UsermodeSelectionPanel : public BaseApplicableConfigPanel { protected: - wxRadioButton* m_radio_user; - wxRadioButton* m_radio_cwd; + pxRadioPanel* m_radio_UserMode; public: virtual ~UsermodeSelectionPanel() { } @@ -66,8 +66,8 @@ namespace Panels class CpuPanelEE : public BaseApplicableConfigPanel { protected: - wxRadioButton* m_Option_RecEE; - wxRadioButton* m_Option_RecIOP; + pxRadioPanel* m_panel_RecEE; + pxRadioPanel* m_panel_RecIOP; public: CpuPanelEE( wxWindow& parent, int idealWidth ); @@ -77,10 +77,8 @@ namespace Panels class CpuPanelVU : public BaseApplicableConfigPanel { protected: - wxRadioButton* m_Option_mVU0; - wxRadioButton* m_Option_mVU1; - wxRadioButton* m_Option_sVU0; - wxRadioButton* m_Option_sVU1; + pxRadioPanel* m_panel_VU0; + pxRadioPanel* m_panel_VU1; public: CpuPanelVU( wxWindow& parent, int idealWidth ); @@ -91,13 +89,11 @@ namespace Panels { protected: wxStaticBoxSizer& s_adv; - wxStaticBoxSizer& s_round; - wxStaticBoxSizer& s_clamp; + //wxStaticBoxSizer& s_round; + //wxStaticBoxSizer& s_clamp; - wxRadioButton* m_Option_Round[4]; - - wxRadioButton* m_Option_None; - wxRadioButton* m_Option_Normal; + pxRadioPanel* m_RoundModePanel; + pxRadioPanel* m_ClampModePanel; pxCheckBox* m_Option_FTZ; pxCheckBox* m_Option_DAZ; @@ -113,10 +109,6 @@ namespace Panels class AdvancedOptionsFPU : public BaseAdvancedCpuOptions { - protected: - wxRadioButton* m_Option_ExtraSign; - wxRadioButton* m_Option_Full; - public: AdvancedOptionsFPU( wxWindow& parent, int idealWidth ); virtual ~AdvancedOptionsFPU() throw() { } @@ -125,10 +117,6 @@ namespace Panels class AdvancedOptionsVU : public BaseAdvancedCpuOptions { - protected: - wxRadioButton* m_Option_Extra; - wxRadioButton* m_Option_ExtraSign; - public: AdvancedOptionsVU( wxWindow& parent, int idealWidth ); virtual ~AdvancedOptionsVU() throw() { } diff --git a/pcsx2/gui/Panels/CpuPanel.cpp b/pcsx2/gui/Panels/CpuPanel.cpp index 73af3528a5..231499f70b 100644 --- a/pcsx2/gui/Panels/CpuPanel.cpp +++ b/pcsx2/gui/Panels/CpuPanel.cpp @@ -16,18 +16,37 @@ #include "PrecompiledHeader.h" #include "ConfigurationPanels.h" -using namespace wxHelpers; +using namespace pxSizerFlags; -Panels::BaseAdvancedCpuOptions::BaseAdvancedCpuOptions( wxWindow& parent, int idealWidth ) : - BaseApplicableConfigPanel( &parent, idealWidth ) -, s_adv( *new wxStaticBoxSizer( wxVERTICAL, this ) ) -, s_round( *new wxStaticBoxSizer( wxVERTICAL, this, _("Round Mode") ) ) -, s_clamp( *new wxStaticBoxSizer( wxVERTICAL, this, _("Clamping Mode") ) ) +Panels::BaseAdvancedCpuOptions::BaseAdvancedCpuOptions( wxWindow& parent, int idealWidth ) + : BaseApplicableConfigPanel( &parent, idealWidth ) + , s_adv( *new wxStaticBoxSizer( wxVERTICAL, this ) ) { + wxStaticBoxSizer* s_round( new wxStaticBoxSizer( wxVERTICAL, this, _("Round Mode") ) ); + wxStaticBoxSizer* s_clamp( new wxStaticBoxSizer( wxVERTICAL, this, _("Clamping Mode") ) ); m_Option_FTZ = new pxCheckBox( this, _("Flush to Zero") ); m_Option_DAZ = new pxCheckBox( this, _("Denormals are Zero") ); + const RadioPanelItem RoundModeChoices[] = + { + RadioPanelItem(_("Nearest")), + RadioPanelItem(_("Negative")), + RadioPanelItem(_("Positive")), + RadioPanelItem(_("Chop / Zero")) + }; + + const RadioPanelItem ClampModeChoices[] = + { + RadioPanelItem(_("None")), + RadioPanelItem(_("Normal")), + }; + + m_RoundModePanel = new pxRadioPanel( this, RoundModeChoices ); + m_ClampModePanel = new pxRadioPanel( this, ClampModeChoices ); + + // ====== The Fitting And Sizing Area ====== + wxFlexGridSizer& grid = *new wxFlexGridSizer( 4 ); // Clever proportions selected for a fairly nice spacing, with the third @@ -38,16 +57,6 @@ Panels::BaseAdvancedCpuOptions::BaseAdvancedCpuOptions( wxWindow& parent, int id grid.AddGrowableCol( 2, 1 ); grid.AddGrowableCol( 3, 19 ); - m_StartNewRadioGroup = true; - m_Option_Round[0] = &AddRadioButton( s_round, _("Nearest") ); - m_Option_Round[1] = &AddRadioButton( s_round, _("Negative") ); - m_Option_Round[2] = &AddRadioButton( s_round, _("Positive") ); - m_Option_Round[3] = &AddRadioButton( s_round, _("Chop / Zero") ); - - m_StartNewRadioGroup = true; - m_Option_None = &AddRadioButton( s_clamp, _("None") ); - m_Option_Normal = &AddRadioButton( s_clamp, _("Normal") ); - wxBoxSizer& s_daz( *new wxBoxSizer( wxVERTICAL ) ); s_daz.AddSpacer( 12 ); s_daz.Add( m_Option_FTZ ); @@ -56,12 +65,15 @@ Panels::BaseAdvancedCpuOptions::BaseAdvancedCpuOptions( wxWindow& parent, int id s_daz.AddSpacer( 22 ); s_daz.Add( new wxButton( this, wxID_DEFAULT, _("Restore Defaults") ), wxSizerFlags().Align( wxALIGN_CENTRE ) ); - grid.Add( &s_round, SizerFlags::SubGroup() ); - grid.Add( &s_clamp, SizerFlags::SubGroup() ); + s_round->Add( m_RoundModePanel, StdExpand() ); + s_clamp->Add( m_ClampModePanel, StdExpand() ); + + grid.Add( s_round, SubGroup() ); + grid.Add( s_clamp, SubGroup() ); grid.Add( new wxBoxSizer( wxVERTICAL ) ); // spacer column! grid.Add( &s_daz, wxSizerFlags().Expand() ); - s_adv.Add( &grid, SizerFlags::StdExpand() ); + s_adv.Add( &grid, StdExpand() ); SetSizer( &s_adv ); @@ -70,20 +82,25 @@ Panels::BaseAdvancedCpuOptions::BaseAdvancedCpuOptions( wxWindow& parent, int id void Panels::BaseAdvancedCpuOptions::OnRestoreDefaults(wxCommandEvent &evt) { - m_Option_Round[3]->SetValue(true); - m_Option_Normal->SetValue(true); + m_RoundModePanel->SetSelection( 3 ); + m_ClampModePanel->SetSelection( 0 ); m_Option_DAZ->SetValue(true); m_Option_FTZ->SetValue(true); } -Panels::AdvancedOptionsFPU::AdvancedOptionsFPU( wxWindow& parent, int idealWidth ) : - BaseAdvancedCpuOptions( parent, idealWidth ) +Panels::AdvancedOptionsFPU::AdvancedOptionsFPU( wxWindow& parent, int idealWidth ) + : BaseAdvancedCpuOptions( parent, idealWidth ) { s_adv.GetStaticBox()->SetLabel(_("EE/FPU Advanced Recompiler Options")); - m_Option_ExtraSign = &AddRadioButton( s_clamp, _("Extra + Preserve Sign") ); - m_Option_Full = &AddRadioButton( s_clamp, _("Full") ); + m_ClampModePanel->Append( _("Extra + Preserve Sign") ); + m_ClampModePanel->Append( _("Full") ); + + m_RoundModePanel->Realize(); + m_ClampModePanel->Realize(); + + // ====== Assign Configured Values ====== Pcsx2Config::CpuOptions& cpuOps( g_Conf->EmuOptions.Cpu ); Pcsx2Config::RecompilerOptions& recOps( cpuOps.Recompiler ); @@ -91,22 +108,27 @@ Panels::AdvancedOptionsFPU::AdvancedOptionsFPU( wxWindow& parent, int idealWidth m_Option_FTZ->SetValue( cpuOps.sseMXCSR.FlushToZero ); m_Option_DAZ->SetValue( cpuOps.sseMXCSR.DenormalsAreZero ); - m_Option_Round[cpuOps.sseMXCSR.RoundingControl]->SetValue( true ); + m_RoundModePanel->SetSelection( cpuOps.sseMXCSR.RoundingControl ); - m_Option_Normal->SetValue( recOps.fpuOverflow ); - m_Option_ExtraSign->SetValue( recOps.fpuExtraOverflow ); - m_Option_Full->SetValue( recOps.fpuFullMode ); - m_Option_None->SetValue( !recOps.fpuOverflow && !recOps.fpuExtraOverflow && !recOps.fpuFullMode ); + if( recOps.fpuFullMode ) m_ClampModePanel->SetSelection( 3 ); + else if( recOps.fpuExtraOverflow ) m_ClampModePanel->SetSelection( 2 ); + else if( recOps.fpuOverflow ) m_ClampModePanel->SetSelection( 1 ); + else m_ClampModePanel->SetSelection( 0 ); } -Panels::AdvancedOptionsVU::AdvancedOptionsVU( wxWindow& parent, int idealWidth ) : - BaseAdvancedCpuOptions( parent, idealWidth ) +Panels::AdvancedOptionsVU::AdvancedOptionsVU( wxWindow& parent, int idealWidth ) + : BaseAdvancedCpuOptions( parent, idealWidth ) { s_adv.GetStaticBox()->SetLabel(_("VU0 / VU1 Advanced Recompiler Options")); - m_Option_Extra = &AddRadioButton( s_clamp, _("Extra") ); - m_Option_ExtraSign = &AddRadioButton( s_clamp, _("Extra + Preserve Sign") ); + m_ClampModePanel->Append( _("Extra") ); + m_ClampModePanel->Append( _("Extra + Preserve Sign") ); + + m_RoundModePanel->Realize(); + m_ClampModePanel->Realize(); + + // ====== Assign Configured Values ====== Pcsx2Config::CpuOptions& cpuOps( g_Conf->EmuOptions.Cpu ); Pcsx2Config::RecompilerOptions& recOps( cpuOps.Recompiler ); @@ -114,55 +136,76 @@ Panels::AdvancedOptionsVU::AdvancedOptionsVU( wxWindow& parent, int idealWidth ) m_Option_FTZ->SetValue( cpuOps.sseVUMXCSR.FlushToZero ); m_Option_DAZ->SetValue( cpuOps.sseVUMXCSR.DenormalsAreZero ); - m_Option_Round[cpuOps.sseVUMXCSR.RoundingControl]->SetValue( true ); + m_RoundModePanel->SetSelection( cpuOps.sseVUMXCSR.RoundingControl ); - m_Option_Normal->SetValue( recOps.vuOverflow ); - m_Option_Extra->SetValue( recOps.vuExtraOverflow ); - m_Option_ExtraSign->SetValue( recOps.vuSignOverflow ); - m_Option_None->SetValue( !recOps.vuOverflow && !recOps.vuExtraOverflow && !recOps.vuSignOverflow ); + if( recOps.vuSignOverflow ) m_ClampModePanel->SetSelection( 3 ); + else if( recOps.vuExtraOverflow ) m_ClampModePanel->SetSelection( 2 ); + else if( recOps.vuOverflow ) m_ClampModePanel->SetSelection( 1 ); + else m_ClampModePanel->SetSelection( 0 ); } -Panels::CpuPanelEE::CpuPanelEE( wxWindow& parent, int idealWidth ) : - BaseApplicableConfigPanel( &parent, idealWidth ) +Panels::CpuPanelEE::CpuPanelEE( wxWindow& parent, int idealWidth ) + : BaseApplicableConfigPanel( &parent, idealWidth ) { - wxBoxSizer& s_main = *new wxBoxSizer( wxVERTICAL ); - wxFlexGridSizer& s_recs = *new wxFlexGridSizer( 2 ); + // i18n: No point in translating PS2 CPU names :) + wxStaticBoxSizer* s_ee = new wxStaticBoxSizer( wxVERTICAL, this, L"EmotionEngine" ); + wxStaticBoxSizer* s_iop = new wxStaticBoxSizer( wxVERTICAL, this, L"IOP" ); + + const RadioPanelItem tbl_CpuTypes_EE[] = + { + RadioPanelItem(_("Interpreter")) + .SetToolTip(_("Quite possibly the slowest thing in the universe.")), + + RadioPanelItem(_("Recompiler [Default]")) + .SetToolTip(_("Performs just-in-time binary translation of 64-bit MIPS-IV machine code to x86.")) + }; + + const RadioPanelItem tbl_CpuTypes_IOP[] = + { + RadioPanelItem(_("Interpreter")) + .SetToolTip(_("Pretty slow; provided for diagnostic purposes only.")), + + RadioPanelItem(_("Recompiler [Default]")) + .SetToolTip(_("Performs just-in-time binary translation of 32-bit MIPS-I machine code to x86.")) + }; + + + m_panel_RecEE = new pxRadioPanel( this, tbl_CpuTypes_EE ); + m_panel_RecIOP = new pxRadioPanel( this, tbl_CpuTypes_IOP ); + + m_panel_RecEE->Realize(); + m_panel_RecIOP->Realize(); + + // ====== Begin Sizer Layout ====== + + wxBoxSizer& s_main = *new wxBoxSizer( wxVERTICAL ); + wxFlexGridSizer& s_recs = *new wxFlexGridSizer( 2 ); s_recs.AddGrowableCol( 0, 1 ); s_recs.AddGrowableCol( 1, 1 ); - // i18n: No point in translating PS2 CPU names :) - wxStaticBoxSizer& s_ee = *new wxStaticBoxSizer( wxVERTICAL, this, L"EmotionEngine" ); - wxStaticBoxSizer& s_iop = *new wxStaticBoxSizer( wxVERTICAL, this, L"IOP" ); + s_ee->Add( m_panel_RecEE, StdExpand() ); + s_iop->Add( m_panel_RecIOP, StdExpand() ); - m_StartNewRadioGroup = true; - AddRadioButton( s_ee, _("Interpreter"), wxEmptyString, _("Quite possibly the slowest thing in the universe.") ); - m_Option_RecEE = &AddRadioButton( s_ee, _("Recompiler [Preferred]") ); + s_recs.Add( s_ee, SubGroup() ); + s_recs.Add( s_iop, SubGroup() ); - m_StartNewRadioGroup = true; - AddRadioButton( s_iop, _("Interpreter") ); - m_Option_RecIOP = &AddRadioButton( s_iop, _("Recompiler [Preferred]") ); - - s_recs.Add( &s_ee, SizerFlags::SubGroup() ); - s_recs.Add( &s_iop, SizerFlags::SubGroup() ); - - s_main.Add( &s_recs, SizerFlags::StdExpand() ); + s_main.Add( &s_recs, StdExpand() ); s_main.Add( new wxStaticLine( this ), wxSizerFlags().Border(wxALL, 24).Expand() ); - s_main.Add( new AdvancedOptionsFPU( *this, idealWidth ), SizerFlags::StdExpand() ); + s_main.Add( new AdvancedOptionsFPU( *this, idealWidth ), StdExpand() ); SetSizer( &s_main ); - // ---------------------------------------------------------------------------- - // Apply current configuration options... + // ====== Apply Current Configuration ====== Pcsx2Config::RecompilerOptions& recOps( g_Conf->EmuOptions.Cpu.Recompiler ); - m_Option_RecEE->SetValue( recOps.EnableEE ); - m_Option_RecIOP->SetValue( recOps.EnableIOP ); + m_panel_RecEE->SetSelection( (int)recOps.EnableEE ); + m_panel_RecIOP->SetSelection( (int)recOps.EnableIOP ); } -Panels::CpuPanelVU::CpuPanelVU( wxWindow& parent, int idealWidth ) : - BaseApplicableConfigPanel( &parent, idealWidth ) +Panels::CpuPanelVU::CpuPanelVU( wxWindow& parent, int idealWidth ) + : BaseApplicableConfigPanel( &parent, idealWidth ) { wxBoxSizer& s_main = *new wxBoxSizer( wxVERTICAL ); wxFlexGridSizer& s_recs = *new wxFlexGridSizer( 2 ); @@ -170,71 +213,75 @@ Panels::CpuPanelVU::CpuPanelVU( wxWindow& parent, int idealWidth ) : s_recs.AddGrowableCol( 0, 1 ); s_recs.AddGrowableCol( 1, 1 ); - wxStaticBoxSizer& s_vu0 = *new wxStaticBoxSizer( wxVERTICAL, this, L"VU0" ); - wxStaticBoxSizer& s_vu1 = *new wxStaticBoxSizer( wxVERTICAL, this, L"VU1" ); + wxStaticBoxSizer* s_vu0 = new wxStaticBoxSizer( wxVERTICAL, this, L"VU0" ); + wxStaticBoxSizer* s_vu1 = new wxStaticBoxSizer( wxVERTICAL, this, L"VU1" ); - m_StartNewRadioGroup = true; - AddRadioButton( s_vu0, _("Interpreter"), wxEmptyString, _("Vector Unit Interpreter. Slow and not very compatible. Only use for testing.") ).SetValue( true ); - m_Option_mVU0 = &AddRadioButton( s_vu0, _("microVU Recompiler [Preferred]"), wxEmptyString, _("New Vector Unit recompiler.") ); - m_Option_sVU0 = &AddRadioButton( s_vu0, _("superVU Recompiler [legacy]"), wxEmptyString, _("Useful for diagnosing possible bugs in the new mVU recompiler.") ); + const RadioPanelItem tbl_CpuTypes_VU[] = + { + RadioPanelItem(_("Interpreter")) + .SetToolTip(_("Vector Unit Interpreter. Slow and not very compatible. Only use for diagnostics.")), - m_StartNewRadioGroup = true; - AddRadioButton( s_vu1, _("Interpreter"), wxEmptyString, _("Vector Unit Interpreter. Slow and not very compatible. Only use for testing.") ).SetValue( true ); - m_Option_mVU1 = &AddRadioButton( s_vu1, _("microVU Recompiler [Preferred]"), wxEmptyString, _("New Vector Unit recompiler.") ); - m_Option_sVU1 = &AddRadioButton( s_vu1, _("superVU Recompiler [legacy]"), wxEmptyString, _("Useful for diagnosing possible bugs in the new mVU recompiler.") ); + RadioPanelItem(_("microVU Recompiler [Default]")) + .SetToolTip(_("New Vector Unit recompiler with much improved compatibility. Recommended.")), + + RadioPanelItem(_("superVU Recompiler [legacy]")) + .SetToolTip(_("Useful for diagnosing bugs or clamping issues in the new mVU recompiler.")) + }; - s_recs.Add( &s_vu0, SizerFlags::SubGroup() ); - s_recs.Add( &s_vu1, SizerFlags::SubGroup() ); + m_panel_VU0 = new pxRadioPanel( this, tbl_CpuTypes_VU ); + m_panel_VU1 = new pxRadioPanel( this, tbl_CpuTypes_VU ); - s_main.Add( &s_recs, SizerFlags::StdExpand() ); + m_panel_VU0->Realize(); + m_panel_VU1->Realize(); + + // ====== Begin Sizer Layout ====== + + s_vu0->Add( m_panel_VU0, StdExpand() ); + s_vu1->Add( m_panel_VU1, StdExpand() ); + + s_recs.Add( s_vu0, SubGroup() ); + s_recs.Add( s_vu1, SubGroup() ); + + s_main.Add( &s_recs, StdExpand() ); s_main.Add( new wxStaticLine( this ), wxSizerFlags().Border(wxALL, 24).Expand() ); - s_main.Add( new AdvancedOptionsVU( *this, idealWidth ), SizerFlags::StdExpand() ); + s_main.Add( new AdvancedOptionsVU( *this, idealWidth ), StdExpand() ); SetSizer( &s_main ); - // ---------------------------------------------------------------------------- - // Apply current configuration options... + // ====== Apply Current Configuration ====== Pcsx2Config::RecompilerOptions& recOps( g_Conf->EmuOptions.Cpu.Recompiler ); if( recOps.UseMicroVU0 ) - m_Option_mVU0->SetValue( recOps.EnableVU0 ); + m_panel_VU0->SetSelection( recOps.EnableVU0 ? 1 : 0 ); else - m_Option_sVU0->SetValue( recOps.EnableVU0 ); + m_panel_VU0->SetSelection( recOps.EnableVU0 ? 2 : 0 ); if( recOps.UseMicroVU1 ) - m_Option_mVU1->SetValue( recOps.EnableVU1 ); + m_panel_VU1->SetSelection( recOps.EnableVU1 ? 1 : 0 ); else - m_Option_sVU1->SetValue( recOps.EnableVU1 ); + m_panel_VU1->SetSelection( recOps.EnableVU1 ? 2 : 0 ); } void Panels::CpuPanelEE::Apply() { Pcsx2Config::RecompilerOptions& recOps( g_Conf->EmuOptions.Cpu.Recompiler ); - recOps.EnableEE = m_Option_RecEE->GetValue(); - recOps.EnableIOP = m_Option_RecIOP->GetValue(); + recOps.EnableEE = !!m_panel_RecEE->GetSelection(); + recOps.EnableIOP = !!m_panel_RecIOP->GetSelection(); } void Panels::CpuPanelVU::Apply() { Pcsx2Config::RecompilerOptions& recOps( g_Conf->EmuOptions.Cpu.Recompiler ); - recOps.EnableVU0 = m_Option_mVU0->GetValue() || m_Option_sVU0->GetValue(); - recOps.EnableVU1 = m_Option_mVU1->GetValue() || m_Option_sVU1->GetValue(); + recOps.EnableVU0 = m_panel_VU0->GetSelection() > 0; + recOps.EnableVU1 = m_panel_VU1->GetSelection() > 0; - recOps.UseMicroVU0 = m_Option_mVU0->GetValue(); - recOps.UseMicroVU1 = m_Option_mVU1->GetValue(); + recOps.UseMicroVU0 = m_panel_VU0->GetSelection() == 1; + recOps.UseMicroVU1 = m_panel_VU1->GetSelection() == 1; } void Panels::BaseAdvancedCpuOptions::ApplyRoundmode( SSE_MXCSR& mxcsr ) { - for( int i=0; i<4; ++i ) - { - if( m_Option_Round[i]->GetValue() ) - { - mxcsr.RoundingControl = i; - break; - } - } - + mxcsr.RoundingControl = m_RoundModePanel->GetSelection(); mxcsr.DenormalsAreZero = m_Option_DAZ->GetValue(); mxcsr.FlushToZero = m_Option_FTZ->GetValue(); } @@ -247,9 +294,11 @@ void Panels::AdvancedOptionsFPU::Apply() cpuOps.sseMXCSR = Pcsx2Config::CpuOptions().sseMXCSR; // set default ApplyRoundmode( cpuOps.sseMXCSR ); - recOps.fpuExtraOverflow = m_Option_ExtraSign->GetValue(); - recOps.fpuOverflow = m_Option_Normal->GetValue() || recOps.fpuExtraOverflow; - recOps.fpuFullMode = m_Option_Full->GetValue(); + const int clampSel = m_ClampModePanel->GetSelection(); + + recOps.fpuOverflow = clampSel >= 1; + recOps.fpuExtraOverflow = clampSel >= 2; + recOps.fpuFullMode = clampSel >= 3; cpuOps.ApplySanityCheck(); } @@ -262,9 +311,11 @@ void Panels::AdvancedOptionsVU::Apply() cpuOps.sseVUMXCSR = Pcsx2Config::CpuOptions().sseVUMXCSR; // set default ApplyRoundmode( cpuOps.sseVUMXCSR ); - recOps.vuSignOverflow = m_Option_ExtraSign->GetValue(); - recOps.vuExtraOverflow = m_Option_Extra->GetValue() || recOps.vuSignOverflow; - recOps.vuOverflow = m_Option_Normal->GetValue() || recOps.vuExtraOverflow; + const int clampSel = m_ClampModePanel->GetSelection(); + + recOps.vuOverflow = clampSel >= 1; + recOps.vuExtraOverflow = clampSel >= 2; + recOps.vuSignOverflow = clampSel >= 3; cpuOps.ApplySanityCheck(); } diff --git a/pcsx2/gui/Panels/DirPickerPanel.cpp b/pcsx2/gui/Panels/DirPickerPanel.cpp index 7a44084eb1..bec63b284b 100644 --- a/pcsx2/gui/Panels/DirPickerPanel.cpp +++ b/pcsx2/gui/Panels/DirPickerPanel.cpp @@ -54,22 +54,21 @@ void Panels::DirPickerPanel::UseDefaultPath_Click( wxCommandEvent &evt ) void Panels::DirPickerPanel::Explore_Click( wxCommandEvent &evt ) { - wxHelpers::Explore( m_pickerCtrl->GetPath() ); + pxExplore( m_pickerCtrl->GetPath() ); } // ------------------------------------------------------------------------ // If initPath is NULL, then it's assumed the default folder is to be used, which is // obtained from invoking the specified getDefault() function. // -Panels::DirPickerPanel::DirPickerPanel( wxWindow* parent, FoldersEnum_t folderid, const wxString& label, const wxString& dialogLabel ) : - BaseApplicableConfigPanel( parent, wxDefaultCoord ) -, m_FolderId( folderid ) -, m_pickerCtrl( NULL ) -, m_checkCtrl( NULL ) +Panels::DirPickerPanel::DirPickerPanel( wxWindow* parent, FoldersEnum_t folderid, const wxString& label, const wxString& dialogLabel ) + : BaseApplicableConfigPanel( parent, wxDefaultCoord ) + , m_FolderId( folderid ) + , m_pickerCtrl( NULL ) + , m_checkCtrl( NULL ) { m_checkCtrl = new pxCheckBox( this, _("Use default setting") ); - wxStaticBoxSizer& s_box( *new wxStaticBoxSizer( wxVERTICAL, this, label ) ); wxFlexGridSizer& s_lower( *new wxFlexGridSizer( 2, 0, 4 ) ); @@ -105,7 +104,7 @@ Panels::DirPickerPanel::DirPickerPanel( wxWindow* parent, FoldersEnum_t folderid wxButton* b_explore( new wxButton( this, wxID_ANY, _("Open in Explorer") ) ); pxSetToolTip( b_explore, _("Open an explorer window to this folder.") ); - s_lower.Add( b_explore, SizerFlags::StdButton().Align( wxALIGN_RIGHT ) ); + s_lower.Add( b_explore, pxSizerFlags::StdButton().Align( wxALIGN_RIGHT ) ); Connect( b_explore->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DirPickerPanel::Explore_Click ) ); #endif diff --git a/pcsx2/gui/Panels/LogOptionsPanels.cpp b/pcsx2/gui/Panels/LogOptionsPanels.cpp index dc5747e2e6..f257432f5e 100644 --- a/pcsx2/gui/Panels/LogOptionsPanels.cpp +++ b/pcsx2/gui/Panels/LogOptionsPanels.cpp @@ -20,7 +20,7 @@ #include -using namespace wxHelpers; +using namespace pxSizerFlags; Panels::eeLogOptionsPanel::eeLogOptionsPanel( LogOptionsPanel* parent ) : CheckedStaticBox( parent, wxVERTICAL, L"EE Logs" ) @@ -62,10 +62,10 @@ Panels::eeLogOptionsPanel::eeLogOptionsPanel( LogOptionsPanel* parent ) wxFlexGridSizer& eeTable( *new wxFlexGridSizer( 2, 5 ) ); - eeTable.Add( &s_misc, SizerFlags::SubGroup() ); - eeTable.Add( m_hwPanel, SizerFlags::SubGroup() ); - eeTable.Add( m_evtPanel, SizerFlags::SubGroup() ); - eeTable.Add( m_disasmPanel, SizerFlags::SubGroup() ); + eeTable.Add( &s_misc, SubGroup() ); + eeTable.Add( m_hwPanel, SubGroup() ); + eeTable.Add( m_evtPanel, SubGroup() ); + eeTable.Add( m_disasmPanel, SubGroup() ); ThisSizer.AddSpacer( 4 ); ThisSizer.Add( &eeTable ); @@ -108,10 +108,10 @@ Panels::iopLogOptionsPanel::iopLogOptionsPanel( LogOptionsPanel* parent ) wxFlexGridSizer& iopTable( *new wxFlexGridSizer( 2, 5 ) ); - iopTable.Add( &s_misc, SizerFlags::SubGroup() ); - iopTable.Add( m_hwPanel, SizerFlags::SubGroup() ); - iopTable.Add( m_evtPanel, SizerFlags::SubGroup() ); - iopTable.Add( m_disasmPanel, SizerFlags::SubGroup() ); + iopTable.Add( &s_misc, SubGroup() ); + iopTable.Add( m_hwPanel, SubGroup() ); + iopTable.Add( m_evtPanel, SubGroup() ); + iopTable.Add( m_disasmPanel, SubGroup() ); ThisSizer.AddSpacer( 4 ); ThisSizer.Add( &iopTable ); @@ -211,14 +211,14 @@ Panels::LogOptionsPanel::LogOptionsPanel(wxWindow* parent, int idealWidth ) //s_head.Add( &s_misc, SizerFlags::SubGroup() ); - topSizer.Add( &m_eeSection, SizerFlags::StdSpace() ); - topSizer.Add( &m_iopSection, SizerFlags::StdSpace() ); + topSizer.Add( &m_eeSection, StdSpace() ); + topSizer.Add( &m_iopSection, StdSpace() ); - mainsizer.Add( m_masterEnabler, SizerFlags::StdSpace() ); - mainsizer.Add( new wxStaticLine( this, wxID_ANY ), SizerFlags::StdExpand().Border(wxLEFT | wxRIGHT, 20) ); + mainsizer.Add( m_masterEnabler, StdSpace() ); + mainsizer.Add( new wxStaticLine( this, wxID_ANY ), StdExpand().Border(wxLEFT | wxRIGHT, 20) ); mainsizer.AddSpacer( 5 ); mainsizer.Add( &topSizer ); - mainsizer.Add( &s_misc, SizerFlags::StdSpace().Centre() ); + mainsizer.Add( &s_misc, StdSpace().Centre() ); SetSizer( &mainsizer ); Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(LogOptionsPanel::OnCheckBoxClicked) ); diff --git a/pcsx2/gui/Panels/MiscPanelStuff.cpp b/pcsx2/gui/Panels/MiscPanelStuff.cpp index e6084ae001..5389f13f51 100644 --- a/pcsx2/gui/Panels/MiscPanelStuff.cpp +++ b/pcsx2/gui/Panels/MiscPanelStuff.cpp @@ -134,10 +134,8 @@ void Panels::BaseApplicableConfigPanel::SetFocusToMe() // ----------------------------------------------------------------------- -Panels::UsermodeSelectionPanel::UsermodeSelectionPanel( wxWindow& parent, int idealWidth, bool isFirstTime ) : - BaseApplicableConfigPanel( &parent, idealWidth ) -, m_radio_user( NULL ) -, m_radio_cwd( NULL ) +Panels::UsermodeSelectionPanel::UsermodeSelectionPanel( wxWindow& parent, int idealWidth, bool isFirstTime ) + : BaseApplicableConfigPanel( &parent, idealWidth ) { const wxString usermodeExplained( pxE( ".Panels:Usermode:Explained", L"Please select your preferred default location for PCSX2 user-level documents below " @@ -151,32 +149,42 @@ Panels::UsermodeSelectionPanel::UsermodeSelectionPanel( wxWindow& parent, int id L"This option only affects Standard Paths which are set to use the installation default value." ) ); - wxStaticBoxSizer& s_boxer = *new wxStaticBoxSizer( wxVERTICAL, this, _( "Usermode Selection" ) ); - AddStaticText( s_boxer, isFirstTime ? usermodeExplained : usermodeWarning ); + const RadioPanelItem UsermodeOptions[] = + { + RadioPanelItem( + _("Current working folder (intended for developer use only)"), + _("Location: ") + wxGetCwd(), + _("This setting requires administration privileges from your operating system.") + ), + + RadioPanelItem( + _("User Documents (recommended)"), + _("Location: ") + wxStandardPaths::Get().GetDocumentsDir() + ), + }; + + wxStaticBoxSizer* s_boxer = new wxStaticBoxSizer( wxVERTICAL, this, _( "Usermode Selection" ) ); + m_radio_UserMode = new pxRadioPanel( this, UsermodeOptions ); + m_radio_UserMode->SetPaddingHoriz( m_radio_UserMode->GetPaddingHoriz() + 4 ); + m_radio_UserMode->Realize(); - m_radio_user = &AddRadioButton( s_boxer, _("User Documents (recommended)"), _("Location: ") + wxStandardPaths::Get().GetDocumentsDir() ); - s_boxer.AddSpacer( 4 ); - m_radio_cwd = &AddRadioButton( s_boxer, _("Current working folder (intended for developer use only)"), _("Location: ") + wxGetCwd(), - _("This setting requires administration privileges from your operating system.") ); - - s_boxer.AddSpacer( 4 ); - SetSizer( &s_boxer ); + AddStaticText( *s_boxer, isFirstTime ? usermodeExplained : usermodeWarning ); + s_boxer->Add( m_radio_UserMode, pxSizerFlags::StdExpand() ); + s_boxer->AddSpacer( 4 ); + SetSizer( s_boxer ); } void Panels::UsermodeSelectionPanel::Apply() { - if( !m_radio_cwd->GetValue() && !m_radio_user->GetValue() ) - throw Exception::CannotApplySettings( this, wxLt( "You must select one of the available user modes before proceeding." ) ); - - UseAdminMode = m_radio_cwd->GetValue(); + UseAdminMode = (m_radio_UserMode->GetSelection() == 0); } // ----------------------------------------------------------------------- -Panels::LanguageSelectionPanel::LanguageSelectionPanel( wxWindow& parent, int idealWidth ) : - BaseApplicableConfigPanel( &parent, idealWidth ) -, m_langs() -, m_picker( NULL ) +Panels::LanguageSelectionPanel::LanguageSelectionPanel( wxWindow& parent, int idealWidth ) + : BaseApplicableConfigPanel( &parent, idealWidth ) + , m_langs() { + m_picker = NULL; i18n_EnumeratePackages( m_langs ); int size = m_langs.size(); @@ -198,7 +206,7 @@ Panels::LanguageSelectionPanel::LanguageSelectionPanel( wxWindow& parent, int id wxBoxSizer& s_lang = *new wxBoxSizer( wxHORIZONTAL ); AddStaticText( s_lang, _("Select a language: "), wxALIGN_CENTRE_VERTICAL ); s_lang.AddSpacer( 5 ); - s_lang.Add( m_picker, SizerFlags::StdSpace() ); + s_lang.Add( m_picker, pxSizerFlags::StdSpace() ); SetSizer( &s_lang ); } diff --git a/pcsx2/gui/Panels/PathsPanel.cpp b/pcsx2/gui/Panels/PathsPanel.cpp index 32de87c3d7..8365c50f46 100644 --- a/pcsx2/gui/Panels/PathsPanel.cpp +++ b/pcsx2/gui/Panels/PathsPanel.cpp @@ -32,7 +32,7 @@ Panels::DirPickerPanel& Panels::BasePathsPanel::AddDirPicker( wxBoxSizer& sizer, FoldersEnum_t folderid, const wxString& label, const wxString& popupLabel ) { DirPickerPanel* dpan = new DirPickerPanel( this, folderid, label, popupLabel ); - sizer.Add( dpan, SizerFlags::SubGroup() ); + sizer.Add( dpan, pxSizerFlags::SubGroup() ); return *dpan; } diff --git a/pcsx2/gui/Panels/PluginSelectorPanel.cpp b/pcsx2/gui/Panels/PluginSelectorPanel.cpp index f183c331b7..ce3232a02e 100644 --- a/pcsx2/gui/Panels/PluginSelectorPanel.cpp +++ b/pcsx2/gui/Panels/PluginSelectorPanel.cpp @@ -152,7 +152,7 @@ Panels::PluginSelectorPanel::StatusPanel::StatusPanel( wxWindow* parent ) : AddStaticText( s_main, _( "Enumerating available plugins..." ) ); s_main.Add( &m_gauge, wxSizerFlags().Expand().Border( wxLEFT | wxRIGHT, 32 ) ); - s_main.Add( &m_label, SizerFlags::StdExpand() ); + s_main.Add( &m_label, pxSizerFlags::StdExpand() ); // The status bar only looks right if I use SetSizerAndFit() here. SetSizerAndFit( &s_main ); @@ -210,7 +210,7 @@ Panels::PluginSelectorPanel::ComboBoxPanel::ComboBoxPanel( PluginSelectorPanel* s_main.Add( &s_plugin, wxSizerFlags().Expand() ); s_main.AddSpacer( 6 ); - s_main.Add( &m_FolderPicker, SizerFlags::StdExpand() ); + s_main.Add( &m_FolderPicker, pxSizerFlags::StdExpand() ); SetSizer( &s_main ); } @@ -235,7 +235,7 @@ Panels::PluginSelectorPanel::PluginSelectorPanel( wxWindow& parent, int idealWid // center of the dialog after it's been fitted to the contents. wxBoxSizer& s_main( *new wxBoxSizer( wxVERTICAL ) ); - s_main.Add( &m_ComponentBoxes, SizerFlags::StdExpand().ReserveSpaceEvenIfHidden() ); + s_main.Add( &m_ComponentBoxes, pxSizerFlags::StdExpand().ReserveSpaceEvenIfHidden() ); m_StatusPanel.Hide(); m_ComponentBoxes.Hide(); diff --git a/pcsx2/gui/Panels/SpeedhacksPanel.cpp b/pcsx2/gui/Panels/SpeedhacksPanel.cpp index 064fd22359..31a990ffd1 100644 --- a/pcsx2/gui/Panels/SpeedhacksPanel.cpp +++ b/pcsx2/gui/Panels/SpeedhacksPanel.cpp @@ -223,12 +223,12 @@ Panels::SpeedHacksPanel::SpeedHacksPanel( wxWindow& parent, int idealWidth ) : miscSizer.Add( m_check_b1fc0 ); miscSizer.Add( m_check_IOPx2 ); - cycleHacksSizer.Add( &cyclerateSizer, SizerFlags::TopLevelBox() ); - cycleHacksSizer.Add( &stealerSizer, SizerFlags::TopLevelBox() ); + cycleHacksSizer.Add( &cyclerateSizer, pxSizerFlags::TopLevelBox() ); + cycleHacksSizer.Add( &stealerSizer, pxSizerFlags::TopLevelBox() ); mainSizer.Add( &cycleHacksSizer, wxSizerFlags().Expand() ); - mainSizer.Add( µVUSizer, SizerFlags::TopLevelBox() ); - mainSizer.Add( &miscSizer, SizerFlags::TopLevelBox() ); + mainSizer.Add( µVUSizer, pxSizerFlags::TopLevelBox() ); + mainSizer.Add( &miscSizer, pxSizerFlags::TopLevelBox() ); SetSizer( &mainSizer ); // There has to be a cleaner way to do this... diff --git a/pcsx2/gui/Panels/VideoPanel.cpp b/pcsx2/gui/Panels/VideoPanel.cpp index c3fd47d445..b663b6c7da 100644 --- a/pcsx2/gui/Panels/VideoPanel.cpp +++ b/pcsx2/gui/Panels/VideoPanel.cpp @@ -18,7 +18,7 @@ #include -using namespace wxHelpers; +using namespace pxSizerFlags; Panels::FramelimiterPanel::FramelimiterPanel( wxWindow& parent, int idealWidth ) : BaseApplicableConfigPanel( &parent, idealWidth ) @@ -62,19 +62,19 @@ Panels::FramelimiterPanel::FramelimiterPanel( wxWindow& parent, int idealWidth ) AddStaticText( s_spins, _("Base Framerate Adjust:"), wxALIGN_LEFT ); s_spins.AddSpacer( 5 ); s_spins.Add( m_spin_NominalPct, wxSizerFlags().Border(wxTOP, 3) ); - s_spins.Add( new wxStaticText( this, wxID_ANY, L"%" ), SizerFlags::StdSpace() ); + s_spins.Add( new wxStaticText( this, wxID_ANY, L"%" ), StdSpace() ); s_spins.AddSpacer( 5 ); AddStaticText( s_spins, _("Slow Motion Adjust:"), wxALIGN_LEFT ); s_spins.AddSpacer( 5 ); s_spins.Add( m_spin_SlomoPct, wxSizerFlags().Border(wxTOP, 3) ); - s_spins.Add( new wxStaticText( this, wxID_ANY, L"%" ), SizerFlags::StdSpace() ); + s_spins.Add( new wxStaticText( this, wxID_ANY, L"%" ), StdSpace() ); s_spins.AddSpacer( 5 ); AddStaticText( s_spins, _("Turbo Adjust:"), wxALIGN_LEFT ); s_spins.AddSpacer( 5 ); s_spins.Add( m_spin_TurboPct, wxSizerFlags().Border(wxTOP, 3) ); - s_spins.Add( new wxStaticText( this, wxID_ANY, L"%" ), SizerFlags::StdSpace() ); + s_spins.Add( new wxStaticText( this, wxID_ANY, L"%" ), StdSpace() ); s_spins.AddSpacer( 5 ); s_spins.AddSpacer( 15 ); @@ -86,13 +86,13 @@ Panels::FramelimiterPanel::FramelimiterPanel( wxWindow& parent, int idealWidth ) AddStaticText( s_spins, _("NTSC Framerate:"), wxALIGN_LEFT ); s_spins.AddSpacer( 5 ); s_spins.Add( m_text_BaseNtsc, wxSizerFlags().Border(wxTOP, 3) ); - s_spins.Add( new wxStaticText( this, wxID_ANY, _("FPS") ), SizerFlags::StdSpace() ); + s_spins.Add( new wxStaticText( this, wxID_ANY, _("FPS") ), StdSpace() ); s_spins.AddSpacer( 5 ); AddStaticText( s_spins, _("PAL Framerate:"), wxALIGN_LEFT ); s_spins.AddSpacer( 5 ); s_spins.Add( m_text_BasePal, wxSizerFlags().Border(wxTOP, 3) ); - s_spins.Add( new wxStaticText( this, wxID_ANY, _("FPS") ), SizerFlags::StdSpace() ); + s_spins.Add( new wxStaticText( this, wxID_ANY, _("FPS") ), StdSpace() ); s_spins.AddSpacer( 5 ); mainSizer.Add( &s_spins ); diff --git a/pcsx2/gui/wxHelpers.cpp b/pcsx2/gui/wxHelpers.cpp index 96c4cf781b..bc88d3981b 100644 --- a/pcsx2/gui/wxHelpers.cpp +++ b/pcsx2/gui/wxHelpers.cpp @@ -23,61 +23,6 @@ # include #endif -// ------------------------------------------------------------------------ -// FlagsAccessors - Provides read-write copies of standard sizer flags for our interface. -// These standard definitions provide a consistent and pretty interface for our GUI. -// Without them things look compacted, misaligned, and yucky! -// -// Implementation Note: Accessors are all provisioned as dynamic (realtime) sizer calculations. -// I've preferred this over cstatic const variables on the premise that spacing logic could -// in the future become a dynamic value (currently it is affixed to 6 for most items). -// -wxSizerFlags wxHelpers::SizerFlags::StdSpace() -{ - return wxSizerFlags().Border( wxALL, 6 ); -} - -wxSizerFlags wxHelpers::SizerFlags::StdCenter() -{ - return wxSizerFlags().Align( wxALIGN_CENTER ).DoubleBorder(); -} - -wxSizerFlags wxHelpers::SizerFlags::StdExpand() -{ - return StdSpace().Expand(); -} - -// A good sizer flags setting for top-level static boxes or top-level picture boxes. -// Gives a generous border to the left, right, and bottom. Top border can be configured -// manually by using a spacer. -wxSizerFlags wxHelpers::SizerFlags::TopLevelBox() -{ - return wxSizerFlags().Border( wxLEFT | wxBOTTOM | wxRIGHT, 6 ).Expand(); -} - -// Flags intended for use on grouped StaticBox controls. These flags are ideal for -// StaticBoxes that are part of sub-panels or children of other static boxes, but may -// not be best for parent StaticBoxes on dialogs (left and right borders feel a bit -// "tight"). -wxSizerFlags wxHelpers::SizerFlags::SubGroup() -{ - // Groups look better with a slightly smaller margin than standard. - // (basically this accounts for the group's frame) - return wxSizerFlags().Border( wxLEFT | wxBOTTOM | wxRIGHT, 4 ).Expand(); -} - -// This force-aligns the std button sizer to the right, where (at least) us win32 platform -// users always expect it to be. Most likely Mac platforms expect it on the left side -// just because it's *not* where win32 sticks it. Too bad! -wxSizerFlags wxHelpers::SizerFlags::StdButton() -{ - return wxSizerFlags().Align( wxALIGN_RIGHT ).Border(); -} - -wxSizerFlags wxHelpers::SizerFlags::Checkbox() -{ - return StdExpand(); -} // This method is used internally to create multi line checkboxes and radio buttons. static wxStaticText* _appendStaticSubtext( wxWindow* parent, wxSizer& sizer, const wxString& subtext, const wxString& tooltip, int wrapLen ) @@ -96,38 +41,33 @@ static wxStaticText* _appendStaticSubtext( wxWindow* parent, wxSizer& sizer, con return joe; } - -// ------------------------------------------------------------------------ -// Creates a new checkbox and adds it to the specified sizer/parent combo, with optional tooltip. -// Uses the default spacer setting for adding checkboxes, and the tooltip (if specified) is applied -// to both the checkbox and it's static subtext (if present). -// -wxCheckBox& wxHelpers::AddCheckBoxTo( wxWindow* parent, wxSizer& sizer, const wxString& label, const wxString& subtext, const wxString& tooltip, int wrapLen ) -{ - wxCheckBox* retval = new wxCheckBox( parent, wxID_ANY, label ); - sizer.Add( retval, SizerFlags::Checkbox() ); - - if( !tooltip.IsEmpty() ) - pxSetToolTip( retval, tooltip ); - - _appendStaticSubtext( parent, sizer, subtext, tooltip, wrapLen ); - - return *retval; -} - pxCheckBox::pxCheckBox(wxPanelWithHelpers* parent, const wxString& label, const wxString& subtext) : wxPanel( parent ) { - m_checkbox = new wxCheckBox( this, wxID_ANY, label ); m_idealWidth = parent->GetIdealWidth() - 24; + Init( label, subtext ); +} + +pxCheckBox::pxCheckBox(wxDialogWithHelpers* parent, const wxString& label, const wxString& subtext) + : wxPanel( parent ) +{ + m_idealWidth = parent->GetIdealWidth() - 24; + Init( label, subtext ); +} + +void pxCheckBox::Init(const wxString& label, const wxString& subtext) +{ + m_checkbox = new wxCheckBox( this, wxID_ANY, label ); wxBoxSizer& mySizer( *new wxBoxSizer(wxVERTICAL) ); - mySizer.Add( m_checkbox, wxHelpers::SizerFlags::StdExpand() ); + mySizer.Add( m_checkbox, pxSizerFlags::StdExpand() ); m_subtext = _appendStaticSubtext( this, mySizer, subtext, wxEmptyString, m_idealWidth ); SetSizer( &mySizer ); } +// applies the tooltip to both both the checkbox and it's static subtext (if present), and +// performs word wrapping on platforms that need it (eg mswindows). pxCheckBox& pxCheckBox::SetToolTip( const wxString& tip ) { const wxString wrapped( pxFormatToolTipText(this, tip) ); @@ -147,26 +87,6 @@ bool pxCheckBox::GetValue() const return m_checkbox->GetValue(); } -// ------------------------------------------------------------------------ -// Creates a new Radio button and adds it to the specified sizer/parent combo, with optional tooltip. -// Uses the default spacer setting for adding checkboxes, and the tooltip (if specified) is applied -// to both the radio button and it's static subtext (if present). -// -// The first item in a group should pass True for the isFirst parameter. -// -wxRadioButton& wxHelpers::AddRadioButtonTo( wxWindow* parent, wxSizer& sizer, const wxString& label, const wxString& subtext, const wxString& tooltip, int wrapLen, bool isFirst ) -{ - wxRadioButton* retval = new wxRadioButton( parent, wxID_ANY, label, wxDefaultPosition, wxDefaultSize, isFirst ? wxRB_GROUP : 0 ); - sizer.Add( retval, SizerFlags::Checkbox() ); - - if( !tooltip.IsEmpty() ) - pxSetToolTip( retval, tooltip ); - - _appendStaticSubtext( parent, sizer, subtext, tooltip, wrapLen ); - - return *retval; -} - // ------------------------------------------------------------------------ // Creates a static text box that generally "makes sense" in a free-flowing layout. Specifically, this // ensures that that auto resizing is disabled, and that the sizer flags match the alignment specified @@ -186,7 +106,7 @@ wxStaticText& wxHelpers::AddStaticTextTo(wxWindow* parent, wxSizer& sizer, const wxStaticText& temp( *new wxStaticText(parent, wxID_ANY, label, wxDefaultPosition, wxDefaultSize, alignFlags ) ); if( size > 0 ) temp.Wrap( size ); - sizer.Add( &temp, SizerFlags::StdSpace().Align( alignFlags & wxALIGN_MASK ) ); + sizer.Add( &temp, pxSizerFlags::StdSpace().Align( alignFlags & wxALIGN_MASK ) ); return temp; } @@ -197,39 +117,10 @@ wxStaticText& wxHelpers::InsertStaticTextAt(wxWindow* parent, wxSizer& sizer, in wxStaticText& temp( *new wxStaticText(parent, wxID_ANY, label, wxDefaultPosition, wxDefaultSize, alignFlags ) ); if( size > 0 ) temp.Wrap( size ); - sizer.Insert( position, &temp, SizerFlags::StdSpace().Align( alignFlags & wxALIGN_MASK ) ); + sizer.Insert( position, &temp, pxSizerFlags::StdSpace().Align( alignFlags & wxALIGN_MASK ) ); return temp; } -// ------------------------------------------------------------------------ -// Launches the specified file according to its mime type -// -void wxHelpers::Launch( const wxString& filename ) -{ - wxLaunchDefaultBrowser( filename ); -} - -void wxHelpers::Launch(const char *filename) -{ - Launch( fromUTF8(filename) ); -} - -// ------------------------------------------------------------------------ -// Launches a file explorer window on the specified path. If the given path is not -// a qualified URI (with a prefix:// ), file:// is automatically prepended. This -// bypasses wxWidgets internal filename checking, which can end up launching things -// through browser more often than desired. -// -void wxHelpers::Explore( const wxString& path ) -{ - wxLaunchDefaultBrowser( !path.Contains( L"://") ? L"file://" + path : path ); -} - -void wxHelpers::Explore(const char *path) -{ - Explore( fromUTF8(path) ); -} - // ===================================================================================================== // wxDialogWithHelpers Class Implementations // ===================================================================================================== @@ -243,13 +134,15 @@ bool pxDialogExists( wxWindowID id ) return (dest > 0); } -wxDialogWithHelpers::wxDialogWithHelpers( wxWindow* parent, int id, const wxString& title, bool hasContextHelp, const wxPoint& pos, const wxSize& size ) : - wxDialog( parent, id, title, pos, size , wxDEFAULT_DIALOG_STYLE), //, (wxCAPTION | wxMAXIMIZE | wxCLOSE_BOX | wxRESIZE_BORDER) ), // flags for resizable dialogs, currently unused. - m_hasContextHelp( hasContextHelp ) +wxDialogWithHelpers::wxDialogWithHelpers( wxWindow* parent, int id, const wxString& title, bool hasContextHelp, const wxPoint& pos, const wxSize& size ) + : wxDialog( parent, id, title, pos, size , wxDEFAULT_DIALOG_STYLE) //, (wxCAPTION | wxMAXIMIZE | wxCLOSE_BOX | wxRESIZE_BORDER) ), // flags for resizable dialogs, currently unused. { ++m_DialogIdents[GetId()]; - if( hasContextHelp ) + m_idealWidth = wxDefaultCoord; + + m_hasContextHelp = hasContextHelp; + if( m_hasContextHelp ) delete wxHelpProvider::Set( new wxSimpleHelpProvider() ); // Note: currently the Close (X) button doesn't appear to work in dialogs. Docs indicate @@ -264,16 +157,6 @@ wxDialogWithHelpers::~wxDialogWithHelpers() throw() pxAssert( m_DialogIdents[GetId()] >= 0 ); } -// ------------------------------------------------------------------------ -// Creates a new checkbox and adds it to the specified sizer/parent combo, with optional tooltip. -// Uses the default spacer setting for adding checkboxes, and the tooltip (if specified) is applied -// to both the checkbox and it's static subtext (if present). -// -wxCheckBox& wxDialogWithHelpers::AddCheckBox( wxSizer& sizer, const wxString& label, const wxString& subtext, const wxString& tooltip ) -{ - return wxHelpers::AddCheckBoxTo( this, sizer, label, subtext, tooltip); -} - wxStaticText& wxDialogWithHelpers::AddStaticText(wxSizer& sizer, const wxString& label, int size, int alignFlags ) { return wxHelpers::AddStaticTextTo( this, sizer, label, size, alignFlags ); @@ -292,7 +175,7 @@ void wxDialogWithHelpers::AddOkCancel( wxSizer &sizer, bool hasApply ) // create a sizer to hold the help and ok/cancel buttons, for platforms // that need a custom help icon. [fixme: help icon prolly better off somewhere else] buttonSizer = new wxBoxSizer( wxHORIZONTAL ); - buttonSizer->Add( new wxContextHelpButton(this), wxHelpers::SizerFlags::StdButton().Align( wxALIGN_LEFT ) ); + buttonSizer->Add( new wxContextHelpButton(this), wxHelpers::pxSizerFlags::StdButton().Align( wxALIGN_LEFT ) ); sizer.Add( buttonSizer, wxSizerFlags().Center() ); #endif } @@ -308,7 +191,7 @@ void wxDialogWithHelpers::AddOkCancel( wxSizer &sizer, bool hasApply ) } s_buttons.Realize(); - buttonSizer->Add( &s_buttons, wxHelpers::SizerFlags::StdButton() ); + buttonSizer->Add( &s_buttons, pxSizerFlags::StdButton() ); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -327,19 +210,6 @@ wxPanelWithHelpers::wxPanelWithHelpers( wxWindow* parent, const wxPoint& pos, co m_StartNewRadioGroup = true; } - -// ------------------------------------------------------------------------ -// Creates a new checkbox and adds it to the specified sizer, with optional tooltip. Uses the default -// spacer setting for adding checkboxes, and the tooltip (if specified) is applied to both the checkbox -// and it's static subtext (if present). -// -// Static subtext, if specified, is displayed below the checkbox and is indented accordingly. -// -/*wxCheckBox& wxPanelWithHelpers::AddCheckBox( wxSizer& sizer, const wxString& label, const wxString& subtext, const wxString& tooltip ) -{ - return wxHelpers::AddCheckBoxTo( this, sizer, label, subtext, tooltip, GetIdealWidth()-8 ); -}*/ - // ------------------------------------------------------------------------ // Creates a static text box that generally "makes sense" in a free-flowing layout. Specifically, this // ensures that that auto resizing is disabled, and that the sizer flags match the alignment specified @@ -365,9 +235,9 @@ wxStaticText& wxPanelWithHelpers::AddStaticText(wxSizer& sizer, const wxString& // Static subtext, if specified, is displayed below the checkbox and is indented accordingly. // The first item in a group should pass True for the isFirst parameter. // -wxRadioButton& wxPanelWithHelpers::AddRadioButton( wxSizer& sizer, const wxString& label, const wxString& subtext, const wxString& tooltip ) +/*wxRadioButton& wxPanelWithHelpers::AddRadioButton( wxSizer& sizer, const wxString& label, const wxString& subtext, const wxString& tooltip ) { wxRadioButton& result = wxHelpers::AddRadioButtonTo( this, sizer, label, subtext, tooltip, GetIdealWidth()-8, m_StartNewRadioGroup ); m_StartNewRadioGroup = false; return result; -} +}*/ diff --git a/pcsx2/gui/wxHelpers.h b/pcsx2/gui/wxHelpers.h index 3fb94b4798..92a7107148 100644 --- a/pcsx2/gui/wxHelpers.h +++ b/pcsx2/gui/wxHelpers.h @@ -22,81 +22,19 @@ namespace wxHelpers { - extern wxCheckBox& AddCheckBoxTo( wxWindow* parent, wxSizer& sizer, const wxString& label, const wxString& subtext=wxEmptyString, const wxString& tooltip=wxEmptyString, int wrapLen=wxDefaultCoord ); - extern wxRadioButton& AddRadioButtonTo( wxWindow* parent, wxSizer& sizer, const wxString& label, const wxString& subtext=wxEmptyString, const wxString& tooltip=wxEmptyString, int wrapLen=wxDefaultCoord, bool isFirst = false ); + //extern wxRadioButton& AddRadioButtonTo( wxWindow* parent, wxSizer& sizer, const wxString& label, const wxString& subtext=wxEmptyString, const wxString& tooltip=wxEmptyString, int wrapLen=wxDefaultCoord, bool isFirst = false ); extern wxStaticText& AddStaticTextTo(wxWindow* parent, wxSizer& sizer, const wxString& label, int alignFlags=wxALIGN_CENTRE, int wrapLen=wxDefaultCoord ); extern wxStaticText& InsertStaticTextAt(wxWindow* parent, wxSizer& sizer, int position, const wxString& label, int alignFlags=wxALIGN_CENTRE, int wrapLen=wxDefaultCoord ); - - extern void Explore( const wxString& path ); - extern void Explore( const char *path ); - - extern void Launch( const wxString& path ); - extern void Launch( const char *path ); - - namespace SizerFlags - { - extern wxSizerFlags StdSpace(); - extern wxSizerFlags StdCenter(); - extern wxSizerFlags StdExpand(); - extern wxSizerFlags TopLevelBox(); - extern wxSizerFlags SubGroup(); - extern wxSizerFlags StdButton(); - extern wxSizerFlags Checkbox(); - }; } -// -------------------------------------------------------------------------------------- -// wxDialogWithHelpers -// -------------------------------------------------------------------------------------- -class wxDialogWithHelpers : public wxDialog -{ -protected: - bool m_hasContextHelp; - -public: - wxDialogWithHelpers(wxWindow* parent, int id, const wxString& title, bool hasContextHelp, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize ); - virtual ~wxDialogWithHelpers() throw(); - - wxCheckBox& AddCheckBox( wxSizer& sizer, const wxString& label, const wxString& subtext=wxEmptyString, const wxString& tooltip=wxEmptyString ); - wxStaticText& AddStaticText(wxSizer& sizer, const wxString& label, int alignFlags=wxALIGN_CENTRE, int size=wxDefaultCoord ); - void AddOkCancel( wxSizer& sizer, bool hasApply=false ); - -protected: -}; - - -// -------------------------------------------------------------------------------------- -// wxPanelWithHelpers -// -------------------------------------------------------------------------------------- -class wxPanelWithHelpers : public wxPanel -{ -protected: - int m_idealWidth; - bool m_StartNewRadioGroup; - -public: - wxPanelWithHelpers( wxWindow* parent, int idealWidth=wxDefaultCoord ); - wxPanelWithHelpers( wxWindow* parent, const wxPoint& pos, const wxSize& size=wxDefaultSize ); - - //wxRadioButton& NewSpinCtrl( const wxString& label, const wxString& subtext=wxEmptyString, const wxString& tooltip=wxEmptyString ); - - //wxCheckBox& AddCheckBox( wxSizer& sizer, const wxString& label, const wxString& subtext=wxEmptyString, const wxString& tooltip=wxEmptyString ); - wxRadioButton& AddRadioButton( wxSizer& sizer, const wxString& label, const wxString& subtext=wxEmptyString, const wxString& tooltip=wxEmptyString ); - wxStaticText& AddStaticText(wxSizer& sizer, const wxString& label, int alignFlags=wxALIGN_CENTRE, int size=wxDefaultCoord ); - - int GetIdealWidth() const { return m_idealWidth; } - bool HasIdealWidth() const { return m_idealWidth != wxDefaultCoord; } - -protected: - void StartRadioGroup() - { - m_StartNewRadioGroup = true; - } -}; - // -------------------------------------------------------------------------------------- // pxCheckBox // -------------------------------------------------------------------------------------- +// The checkbox panel created uses the default spacer setting for adding checkboxes (see +// SizerFlags). The SetToolTip API provided by this function applies the tooltip to both +// both the checkbox and it's static subtext (if present), and performs word wrapping on +// platforms that need it (eg mswindows). +// class pxCheckBox : public wxPanel { protected: @@ -106,6 +44,7 @@ protected: public: pxCheckBox( wxPanelWithHelpers* parent, const wxString& label, const wxString& subtext=wxEmptyString ); + pxCheckBox( wxDialogWithHelpers* parent, const wxString& label, const wxString& subtext=wxEmptyString ); virtual ~pxCheckBox() throw() {} bool HasSubText() const { return m_subtext != NULL; } @@ -121,8 +60,12 @@ public: wxCheckBox* GetWxPtr() { return m_checkbox; } const wxCheckBox* GetWxPtr() const { return m_checkbox; } + + wxWindowID GetId() const { pxAssert( m_checkbox != NULL ); return m_checkbox->GetId(); } + +protected: + void Init( const wxString& label, const wxString& subtext ); }; - extern bool pxDialogExists( wxWindowID id );