Added a "Screenshot" button to the Settings window; it saves a screenshot of the settings to png file. :) It's just preliminary for now. I'll replace it with an artsy icon later, hopefully. :)

Cleaned up the operator overloads some more, and added operator,  (yes, comma) to solve some ambiguity problems when trying to apply multiple attributes to a single window.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2252 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-11-25 15:38:24 +00:00
parent cf05172691
commit 35c78ae660
10 changed files with 123 additions and 71 deletions

View File

@ -128,8 +128,8 @@ struct pxWindowAndFlags
};
extern wxSizerFlags operator | ( const wxSizerFlags& _flgs, pxAlignmentType align );
extern wxSizerFlags operator | ( const wxSizerFlags& _flgs, pxStretchType stretch );
extern wxSizerFlags operator , ( const wxSizerFlags& _flgs, const wxSizerFlags& _flgs2 ); //pxAlignmentType align );
//extern wxSizerFlags operator , ( const wxSizerFlags& _flgs, pxStretchType stretch );
template< typename WinType >
pxWindowAndFlags<WinType> operator | ( WinType* _win, const wxSizerFlags& _flgs )
@ -145,20 +145,6 @@ pxWindowAndFlags<WinType> operator | ( WinType& _win, const wxSizerFlags& _flgs
return result;
}
template< typename WinType >
pxWindowAndFlags<WinType> operator | ( const wxSizerFlags& _flgs, WinType* _win )
{
pxWindowAndFlags<WinType> result = { _win, _flgs };
return result;
}
template< typename WinType >
pxWindowAndFlags<WinType> operator | ( const wxSizerFlags& _flgs, WinType& _win )
{
pxWindowAndFlags<WinType> result = { &_win, _flgs };
return result;
}
// --------------------------------------------------------------------------------------
// wxSizer Operator += .. a wxSizer.Add() Substitute
// --------------------------------------------------------------------------------------
@ -238,8 +224,9 @@ class wxDialogWithHelpers : public wxDialog
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDialogWithHelpers)
protected:
bool m_hasContextHelp;
int m_idealWidth;
bool m_hasContextHelp;
int m_idealWidth;
wxBoxSizer* m_extraButtonSizer;
public:
wxDialogWithHelpers();

View File

@ -99,15 +99,29 @@ wxSizerFlags pxStretchType::Apply( wxSizerFlags flags ) const
return flags;
}
wxSizerFlags operator | ( const wxSizerFlags& _flgs, pxAlignmentType align )
wxSizerFlags operator , ( const wxSizerFlags& _flgs, const wxSizerFlags& _flgs2 )
{
return align.Apply( _flgs );
//return align.Apply( _flgs );
wxSizerFlags retval;
uint allflags = (_flgs.GetFlags() | _flgs2.GetFlags());
retval.Align( allflags & wxALIGN_MASK );
if( allflags & wxEXPAND ) retval.Expand();
if( allflags & wxSHAPED ) retval.Shaped();
if( allflags & wxFIXED_MINSIZE ) retval.FixedMinSize();
if( allflags & wxRESERVE_SPACE_EVEN_IF_HIDDEN ) retval.ReserveSpaceEvenIfHidden();
// Compounding borders is probably a fair approach:
retval.Border( allflags & wxALL, _flgs.GetBorderInPixels() + _flgs2.GetBorderInPixels() );
return retval;
}
wxSizerFlags operator | ( const wxSizerFlags& _flgs, pxStretchType stretch )
/*wxSizerFlags operator | ( const wxSizerFlags& _flgs, pxStretchType stretch )
{
return stretch.Apply( _flgs );
}
}*/
void operator+=( wxSizer& target, wxWindow* src )

View File

@ -21,6 +21,8 @@
#include <wx/cshelp.h>
#include <wx/tooltip.h>
using namespace pxSizerFlags;
// =====================================================================================================
// wxDialogWithHelpers Class Implementations
@ -44,6 +46,7 @@ wxDialogWithHelpers::wxDialogWithHelpers()
{
m_idealWidth = wxDefaultCoord;
m_hasContextHelp = false;
m_extraButtonSizer = NULL;
}
wxDialogWithHelpers::wxDialogWithHelpers( wxWindow* parent, int id, const wxString& title, bool hasContextHelp, const wxPoint& pos, const wxSize& size )
@ -51,7 +54,8 @@ wxDialogWithHelpers::wxDialogWithHelpers( wxWindow* parent, int id, const wxStr
{
++m_DialogIdents[GetId()];
m_idealWidth = wxDefaultCoord;
m_idealWidth = wxDefaultCoord;
m_extraButtonSizer = NULL;
m_hasContextHelp = hasContextHelp;
if( m_hasContextHelp )
@ -88,34 +92,38 @@ void wxDialogWithHelpers::OnActivate(wxActivateEvent& evt)
void wxDialogWithHelpers::AddOkCancel( wxSizer &sizer, bool hasApply )
{
wxSizer* buttonSizer = &sizer;
if( m_hasContextHelp )
{
// Add the context-sensitive help button on the caption for the platforms
// which support it (currently MSW only)
SetExtraStyle( wxDIALOG_EX_CONTEXTHELP );
#ifndef __WXMSW__
// 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), pxSizerFlags::StdButton().Align( wxALIGN_LEFT ) );
sizer.Add( buttonSizer, wxSizerFlags().Center() );
#endif
}
wxStdDialogButtonSizer& s_buttons = *new wxStdDialogButtonSizer();
wxStdDialogButtonSizer& s_buttons( *new wxStdDialogButtonSizer() );
s_buttons.AddButton( new wxButton( this, wxID_OK ) );
s_buttons.AddButton( new wxButton( this, wxID_CANCEL ) );
if( hasApply )
{
s_buttons.AddButton( new wxButton( this, wxID_APPLY ) );
m_extraButtonSizer = new wxBoxSizer( wxHORIZONTAL );
// Add the context-sensitive help button on the caption for the platforms
// which support it (currently MSW only)
if( m_hasContextHelp )
{
SetExtraStyle( wxDIALOG_EX_CONTEXTHELP );
#ifndef __WXMSW__
s_littles += new wxContextHelpButton(this) | StdButton();
#endif
}
// 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]
wxFlexGridSizer& flex( *new wxFlexGridSizer( 2 ) );
flex.AddGrowableCol( 0, 1 );
flex.AddGrowableCol( 1, 15 );
flex += m_extraButtonSizer | pxAlignLeft;
flex += s_buttons | pxExpand, pxCenter;
sizer += flex | StdExpand();
s_buttons.Realize();
buttonSizer->Add( &s_buttons, pxSizerFlags::StdButton() );
}
// --------------------------------------------------------------------------------------

View File

@ -18,12 +18,14 @@
#include "App.h"
#include "ConfigurationDialog.h"
#include "ModalPopups.h"
#include "Panels/ConfigurationPanels.h"
#include <wx/artprov.h>
#include <wx/listbook.h>
#include <wx/listctrl.h>
#include <wx/filepicker.h>
//#include "wx/clipbrd.h"
#ifdef __WXMSW__
# include <wx/msw/wrapwin.h> // needed for Vista icon spacing fix.
@ -56,7 +58,7 @@ Dialogs::ConfigurationDialog::ConfigurationDialog( wxWindow* parent, int id ) :
{
m_idealWidth = 600;
wxBoxSizer& mainSizer = *new wxBoxSizer( wxVERTICAL );
SetSizer( new wxBoxSizer( wxVERTICAL ) );
m_listbook.SetImageList( &wxGetApp().GetImgList_Config() );
const AppImageIds::ConfigIds& cfgid( wxGetApp().GetImgId().Config );
@ -71,12 +73,13 @@ Dialogs::ConfigurationDialog::ConfigurationDialog( wxWindow* parent, int id ) :
AddPage<PluginSelectorPanel>( wxLt("Plugins"), cfgid.Plugins );
AddPage<StandardPathsPanel> ( wxLt("Folders"), cfgid.Paths );
mainSizer.Add( &m_listbook );
AddOkCancel( mainSizer, true );
*this += m_listbook;
AddOkCancel( *GetSizer(), true );
*m_extraButtonSizer += new wxButton( this, wxID_SAVE, _("Screenshot!") );
FindWindow( wxID_APPLY )->Disable();
SetSizerAndFit( &mainSizer );
Fit();
CenterOnScreen();
#ifdef __WXMSW__
@ -92,6 +95,7 @@ Dialogs::ConfigurationDialog::ConfigurationDialog( wxWindow* parent, int id ) :
Connect( wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ConfigurationDialog::OnOk_Click ) );
Connect( wxID_CANCEL, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ConfigurationDialog::OnCancel_Click ) );
Connect( wxID_APPLY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ConfigurationDialog::OnApply_Click ) );
Connect( wxID_SAVE, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ConfigurationDialog::OnScreenshot_Click ) );
// ----------------------------------------------------------------------------
// Bind a variety of standard "something probably changed" events. If the user invokes
@ -145,9 +149,31 @@ void Dialogs::ConfigurationDialog::OnApply_Click( wxCommandEvent& evt )
}
void Dialogs::ConfigurationDialog::OnScreenshot_Click( wxCommandEvent& evt )
{
wxBitmap memBmp;
{
wxWindowDC dc( this );
wxSize dcsize( dc.GetSize() );
wxMemoryDC memDC( memBmp = wxBitmap( dcsize.x, dcsize.y ) );
memDC.Blit( wxPoint(), dcsize, &dc, wxPoint() );
}
wxString filenameDefault;
filenameDefault.Printf( L"pcsx2_settings_%s.png", m_listbook.GetPageText( m_listbook.GetSelection() ).c_str() );
filenameDefault.Replace( L"/", L"-" );
wxString filename( wxFileSelector( _("Save dialog screenshots to..."), g_Conf->Folders.Snapshots.ToString(),
filenameDefault, L"png", NULL, wxFD_SAVE | wxFD_OVERWRITE_PROMPT, this ) );
if( !filename.IsEmpty() )
memBmp.SaveFile( filename, wxBITMAP_TYPE_PNG );
}
// ----------------------------------------------------------------------------
Dialogs::BiosSelectorDialog::BiosSelectorDialog( wxWindow* parent, int id ) :
wxDialogWithHelpers( parent, id, _("BIOS Selector"), false )
Dialogs::BiosSelectorDialog::BiosSelectorDialog( wxWindow* parent, int id )
: wxDialogWithHelpers( parent, id, _("BIOS Selector"), false )
{
m_idealWidth = 500;

View File

@ -42,6 +42,7 @@ namespace Dialogs
void OnOk_Click( wxCommandEvent& evt );
void OnCancel_Click( wxCommandEvent& evt );
void OnApply_Click( wxCommandEvent& evt );
void OnScreenshot_Click( wxCommandEvent& evt );
virtual void OnSomethingChanged( wxCommandEvent& evt )
{

View File

@ -85,7 +85,7 @@ static wxWindowID ParseThatResult( const wxString& src, const ConfButtons& valid
return wxID_ANY;
}
wxWindowID Dialogs::IssueConfirmation( wxWindow* parent, const wxString& disablerKey, const ConfButtons& type, const wxString& title, const wxString& msg )
wxWindowID Dialogs::IssueConfirmation( ExtensibleConfirmation& confirmDlg, const wxString& disablerKey )
{
wxConfigBase* cfg = GetAppConfig();
@ -112,14 +112,12 @@ wxWindowID Dialogs::IssueConfirmation( wxWindow* parent, const wxString& disable
result = split[0];
if( result == L"disabled" || result == L"off" || result == L"no" )
{
int result = ParseThatResult( split[1], type );
int result = ParseThatResult( split[1], confirmDlg.GetButtons() );
if( result != wxID_ANY ) return result;
}
}
}
Dialogs::ExtensibleConfirmation confirmDlg( parent, type, title, msg );
if( cfg == NULL ) return confirmDlg.ShowModal();
// Add an option that allows the user to disable this popup from showing again.
@ -128,7 +126,7 @@ wxWindowID Dialogs::IssueConfirmation( wxWindow* parent, const wxString& disable
pxCheckBox& DisablerCtrl( *new pxCheckBox(&confirmDlg, _("Do not show this dialog again.")) );
confirmDlg.GetExtensibleSizer().Add( &DisablerCtrl, wxSizerFlags().Centre() );
if( type != ConfButtons().OK() )
if( confirmDlg.GetButtons() != ConfButtons().OK() )
pxSetToolTip(&DisablerCtrl, _("Disables this popup and whatever response you select here will be automatically used from now on."));
else
pxSetToolTip(&DisablerCtrl, _("The popup will not be shown again. This setting can be undone from the settings panels."));
@ -152,7 +150,8 @@ Dialogs::ExtensibleConfirmation::ExtensibleConfirmation( wxWindow* parent, const
, m_ExtensibleSizer( *new wxBoxSizer( wxVERTICAL ) )
, m_ButtonSizer( *new wxBoxSizer( wxHORIZONTAL ) )
{
m_idealWidth = 500;
m_Buttons = type;
m_idealWidth = 500;
SetSizer( new wxBoxSizer(wxVERTICAL) );
@ -194,6 +193,9 @@ Dialogs::ExtensibleConfirmation::ExtensibleConfirmation( wxWindow* parent, const
if( type.HasReset() )
AddCustomButton( wxID_RESET, _("Reset") );
if( type.HasClose() )
AddActionButton( wxID_CLOSE );
#ifndef __WXGTK__
if( type.HasNo() || type.HasCancel() ) // Extra space between Affirm and Cancel Actions
m_ButtonSizer.Add(0, 0, 1, wxEXPAND, 0);

View File

@ -71,16 +71,17 @@ class ConfButtons
protected:
BITFIELD32()
bool
m_OK:1,
m_Cancel:1,
m_Yes:1,
m_No:1,
m_OK :1,
m_Cancel :1,
m_Yes :1,
m_No :1,
m_AllowToAll:1,
m_Apply:1,
m_Abort:1,
m_Retry:1,
m_Ignore:1,
m_Reset:1;
m_Apply :1,
m_Abort :1,
m_Retry :1,
m_Ignore :1,
m_Reset :1,
m_Close :1;
BITFIELD_END
wxString m_CustomLabel;
@ -99,6 +100,7 @@ public:
ConfButtons& Retry() { m_Retry = true; return *this; }
ConfButtons& Ignore() { m_Ignore = true; return *this; }
ConfButtons& Reset() { m_Reset = true; return *this; }
ConfButtons& Close() { m_Close = true; return *this; }
ConfButtons& Custom( const wxString& label)
{
@ -120,6 +122,7 @@ public:
bool HasRetry() const { return m_Retry; }
bool HasIgnore() const { return m_Ignore; }
bool HasReset() const { return m_Reset; }
bool HasClose() const { return m_Close; }
bool HasCustom() const { return !m_CustomLabel.IsEmpty(); }
const wxString& GetCustomLabel() const { return m_CustomLabel; }
@ -198,10 +201,13 @@ namespace Dialogs
wxBoxSizer& m_ExtensibleSizer;
wxBoxSizer& m_ButtonSizer;
ConfButtons m_Buttons;
public:
ExtensibleConfirmation( wxWindow* parent, const ConfButtons& type, const wxString& title, const wxString& msg );
virtual ~ExtensibleConfirmation() throw() {}
const ConfButtons& GetButtons() const { return m_Buttons; }
virtual wxBoxSizer& GetExtensibleSizer() const { return m_ExtensibleSizer; }
protected:
@ -210,6 +216,6 @@ namespace Dialogs
virtual void OnActionButtonClicked( wxCommandEvent& evt );
};
wxWindowID IssueConfirmation( wxWindow* parent, const wxString& disablerKey, const ConfButtons& type, const wxString& title, const wxString& msg );
wxWindowID IssueConfirmation( ExtensibleConfirmation& confirmDlg, const wxString& disablerKey );
}

View File

@ -69,11 +69,13 @@ bool IsoDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filen
bool confirmed = true;
if( SysHasValidState() )
{
confirmed = Dialogs::IssueConfirmation( m_WindowBound, L"DragDrop:BootELF", ConfButtons().Reset().Cancel(),
Dialogs::ExtensibleConfirmation dialog( m_WindowBound, ConfButtons().Reset().Cancel(),
_("Confirm PS2 Reset"),
_("You have dropped the following ELF binary into PCSX2:\n\n") +
filenames[0] + L"\n\n" + GetMsg_ConfirmSysReset()
) != wxID_CANCEL;
);
confirmed = (Dialogs::IssueConfirmation( dialog, L"DragDrop:BootELF" ) != wxID_CANCEL);
}
if( confirmed )
@ -109,12 +111,14 @@ bool IsoDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filen
if( SysHasValidState() )
{
result = Dialogs::IssueConfirmation( m_WindowBound, L"DragDrop:BootIso", ConfButtons().Reset().Cancel().Custom(_("Swap Disc")),
Dialogs::ExtensibleConfirmation dialog( m_WindowBound, ConfButtons().Reset().Cancel().Custom(_("Swap Disc")),
_("Confirm PS2 Reset"),
_("You have dropped the following ISO image into PCSX2:\n\n") +
filenames[0] + L"\n\n" +
_("Do you want to swap discs or boot the new image (via system reset)?")
);
result = Dialogs::IssueConfirmation( dialog, L"DragDrop:BootIso" );
}
if( result != wxID_CANCEL )

View File

@ -123,9 +123,11 @@ void MainEmuFrame::Menu_BootCdvd_Click( wxCommandEvent &event )
if( SysHasValidState() )
{
bool confirmed = IssueConfirmation( this, L"BootCdvd:ConfirmReset", ConfButtons().Yes().Cancel(),
ExtensibleConfirmation dialog( this, ConfButtons().Yes().Cancel(),
_("Confirm PS2 Reset"), GetMsg_ConfirmSysReset()
) != wxID_CANCEL;
);
bool confirmed = (IssueConfirmation( dialog, L"BootCdvd:ConfirmReset" ) != wxID_CANCEL);
if( !confirmed )
{

View File

@ -312,7 +312,7 @@ void Panels::PluginSelectorPanel::Apply()
if( CoreThread.IsRunning() )
{
// [TODO] : Post notice that this shuts down existing emulation, and may not safely recover.
int result = Dialogs::IssueConfirmation( this, L"PluginSelector:ConfirmShutdown", ConfButtons().OK().Cancel(),
Dialogs::ExtensibleConfirmation dialog( this, ConfButtons().OK().Cancel(),
_("Shutdown PS2 virtual machine?"),
@ -324,6 +324,8 @@ void Panels::PluginSelectorPanel::Apply()
L"Are you sure you want to apply settings now?"
)
);
int result = Dialogs::IssueConfirmation( dialog, L"PluginSelector:ConfirmShutdown" );
if( result == wxID_CANCEL )
throw Exception::CannotApplySettings( this, "Cannot apply settings: canceled by user because plugins changed while the emulation state was active.", false );