* Various configuration dialogs remember their positions now. :)
 * AboutBox is fixed, and is now resizable.
 * Fix for Issue 739 : usermode.ini hashes are now case-insensitive on Win32.
 * Likely Fix for Issue 740 : missing text on Linux/GTK.  (need confirmation)

DevNotes:
 * Moved IniInterface.cpp/h to the Utilities lib.  Linux makefiles will need to be updated. >_<

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3178 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2010-06-06 23:26:07 +00:00
parent a849202d28
commit e86d1d1bd4
22 changed files with 374 additions and 198 deletions

View File

@ -219,6 +219,10 @@
RelativePath="..\..\src\Utilities\HashTools.cpp"
>
</File>
<File
RelativePath="..\..\src\Utilities\IniInterface.cpp"
>
</File>
<File
RelativePath="..\..\src\Utilities\x86\MemcpyFast.cpp"
>
@ -381,6 +385,10 @@
RelativePath="..\..\include\Utilities\HashMap.h"
>
</File>
<File
RelativePath="..\..\include\Utilities\IniInterface.h"
>
</File>
<File
RelativePath="..\..\include\intrin_x86.h"
>

View File

@ -15,11 +15,13 @@
#pragma once
#include "FixedPointTypes.h"
#include "path.h"
#include <wx/config.h>
//////////////////////////////////////////////////////////////////////////////////////////
// IniInterface class (abstract base class)
//
// --------------------------------------------------------------------------------------
// IniInterface (abstract base class)
// --------------------------------------------------------------------------------------
// This is used as an interchangable interface for both loading and saving options from an
// ini/configuration file. The LoadSave code takes an IniInterface, and the interface
// implementation defines whether the options are read or written.
@ -29,17 +31,19 @@
class IniInterface
{
protected:
wxConfigBase& m_Config;
wxConfigBase* m_Config;
public:
virtual ~IniInterface();
explicit IniInterface();
explicit IniInterface( wxConfigBase& config );
explicit IniInterface( wxConfigBase* config );
void SetPath( const wxString& path );
void Flush();
wxConfigBase& GetConfig() { return m_Config; }
wxConfigBase& GetConfig() { pxAssume( m_Config ); return *m_Config; }
bool IsOk() const { return m_Config != NULL; }
virtual bool IsLoading() const=0;
bool IsSaving() const { return !IsLoading(); }
@ -76,8 +80,9 @@ protected:
virtual void _EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, int defvalue )=0;
};
//////////////////////////////////////////////////////////////////////////////////////////
//
// --------------------------------------------------------------------------------------
// IniScopedGroup
// --------------------------------------------------------------------------------------
class IniScopedGroup
{
protected:
@ -88,9 +93,9 @@ public:
virtual ~IniScopedGroup();
};
//////////////////////////////////////////////////////////////////////////////////////////
// IniLoader class
//
// --------------------------------------------------------------------------------------
// IniLoader
// --------------------------------------------------------------------------------------
// Implementation of the IniInterface base class, which maps ini actions to loading from
// an ini source file.
//
@ -102,6 +107,7 @@ public:
virtual ~IniLoader() throw();
explicit IniLoader();
explicit IniLoader( wxConfigBase& config );
explicit IniLoader( wxConfigBase* config );
bool IsLoading() const { return true; }
@ -125,9 +131,9 @@ protected:
void _EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, int defvalue );
};
//////////////////////////////////////////////////////////////////////////////////////////
// IniSaver class
//
// --------------------------------------------------------------------------------------
// IniSaver
// --------------------------------------------------------------------------------------
// Implementation of the IniInterface base class, which maps ini actions to saving to
// an ini dest file.
//
@ -139,6 +145,7 @@ public:
virtual ~IniSaver();
explicit IniSaver();
explicit IniSaver( wxConfigBase& config );
explicit IniSaver( wxConfigBase* config );
bool IsLoading() const { return false; }

View File

@ -129,7 +129,7 @@ namespace Path
extern s64 GetFileSize( const wxString& path );
extern wxString Normalize( const wxString& srcpath );
extern wxString Normalize( wxDirName srcpath );
extern wxString Normalize( const wxDirName& srcpath );
extern wxString Combine( const wxString& srcPath, const wxString& srcFile );
extern wxString Combine( const wxDirName& srcPath, const wxFileName& srcFile );

View File

@ -26,19 +26,21 @@
// * An inability to wrap text to conform to a fitted window (a limitation imposed by
// wxWidgets inability to fit individual directions, ie fit widths and then fit heights,
// which would allow a textbox to wrap text to a sizer-determined width, and then grow
// the sizers vertically to fit the calcuated text-wrapped height).
// the sizers vertically to fit the calculated text-wrapped height).
//
// * Textbox alignment requires aligning both the textbox contents, and aligning the text
// control within it's containing sizer. If both alignment flags do not match the result
// is typically undesirable.
//
class pxStaticText : public wxPanel
class pxStaticText : public wxWindow
{
typedef wxPanel _parent;
typedef wxWindow _parent;
protected:
wxAlignment m_align;
wxString m_label;
wxString m_wrappedLabel;
wxAlignment m_align;
bool m_autowrap;
int m_wrappedWidth;
int m_heightInLines;
@ -51,6 +53,11 @@ protected:
protected:
explicit pxStaticText( wxWindow* parent=NULL );
// wxWindow overloads!
bool AcceptsFocus() const { return false; }
bool HasTransparentBackground() { return true; }
void DoSetSize(int x, int y, int w, int h, int sizeFlags = wxSIZE_AUTO);
public:
pxStaticText( wxWindow* parent, const wxString& label, wxAlignment align=wxALIGN_CENTRE_HORIZONTAL );
pxStaticText( wxWindow* parent, int heightInLines, const wxString& label, wxAlignment align=wxALIGN_CENTRE_HORIZONTAL );
@ -61,6 +68,11 @@ public:
virtual void SetLabel(const wxString& label);
virtual wxString GetLabel() const { return m_label; }
pxStaticText& SetMinWidth( int width );
pxStaticText& SetMinHeight( int height );
pxStaticText& SetHeight( int lines );
pxStaticText& Bold();
pxStaticText& WrapAt( int width );

View File

@ -310,7 +310,7 @@ END_DECLARE_EVENT_TYPES()
class pxDialogCreationFlags
{
public:
int MinimumWidth;
wxSize MinimumSize;
wxOrientation BoxSizerOrient;
bool isResizable;
@ -326,7 +326,7 @@ public:
pxDialogCreationFlags()
{
MinimumWidth = wxDefaultCoord;
MinimumSize = wxDefaultSize;
BoxSizerOrient = wxVERTICAL;
isResizable = false;
hasContextHelp = false;
@ -362,6 +362,8 @@ public:
return *this;
}
// NOTE: Enabling system menu on dialogs usually doesn't work, and might cause
// other unwanted behavior, such as a missing close button.
pxDialogCreationFlags& SetSystemMenu( bool enable=true )
{
hasSystemMenu = enable;
@ -388,10 +390,20 @@ public:
pxDialogCreationFlags& SetMinWidth( int width )
{
if( width > MinimumWidth ) MinimumWidth = width;
if( width > MinimumSize.x ) MinimumSize.SetWidth( width );
return *this;
}
pxDialogCreationFlags& SetMinHeight( int height )
{
if( height > MinimumSize.y ) MinimumSize.SetHeight( height );
return *this;
}
pxDialogCreationFlags& SetMinSize( const wxSize& size )
{
return SetMinWidth(size.x).SetMinHeight(size.y);
}
pxDialogCreationFlags Horizontal() const
@ -424,6 +436,8 @@ public:
return pxDialogCreationFlags(*this).SetMaximize( enable );
}
// NOTE: Enabling system menu on dialogs usually doesn't work, and might cause
// other unwanted behavior, such as a missing close button.
pxDialogCreationFlags SystemMenu( bool enable=true ) const
{
return pxDialogCreationFlags(*this).SetSystemMenu( false );
@ -473,6 +487,21 @@ public:
{
return pxDialogCreationFlags(*this).SetMinWidth( width );
}
pxDialogCreationFlags MinHeight( int height ) const
{
return pxDialogCreationFlags(*this).SetMinHeight( height );
}
pxDialogCreationFlags MinSize( const wxSize& size ) const
{
return pxDialogCreationFlags(*this).SetMinSize( size );
}
pxDialogCreationFlags MinSize( int width, int height ) const
{
return pxDialogCreationFlags(*this).SetMinWidth( width ).SetMinHeight( height );
}
int GetWxWindowFlags() const
{
@ -498,13 +527,14 @@ class wxDialogWithHelpers : public wxDialog
protected:
bool m_hasContextHelp;
wxBoxSizer* m_extraButtonSizer;
wxRect m_CreatedRect;
public:
wxDialogWithHelpers();
wxDialogWithHelpers(wxWindow* parent, const wxString& title, const pxDialogCreationFlags& cflags = pxDialogCreationFlags() );
virtual ~wxDialogWithHelpers() throw();
void Init();
void Init( const pxDialogCreationFlags& cflags );
void AddOkCancel( wxSizer& sizer, bool hasApply=false );
void AddOkCancel( wxSizer* sizer=NULL, bool hasApply=false );
@ -522,12 +552,15 @@ public:
virtual pxStaticText& Text( const wxString& label );
virtual pxStaticText& Heading( const wxString& label );
virtual wxDialogWithHelpers& SetMinWidth( int newWidth );
wxDialogWithHelpers& SetMinWidth( int newWidth );
wxDialogWithHelpers& SetMinHeight( int newHeight );
protected:
void OnDialogCreated( wxCommandEvent& evt );
void OnOkCancel(wxCommandEvent& evt);
void OnCloseWindow(wxCloseEvent& event);
void DoAutoCenter();
};
// --------------------------------------------------------------------------------------

View File

@ -14,7 +14,6 @@
*/
#include "PrecompiledHeader.h"
#include "System.h"
#include "IniInterface.h"
static int _calcEnumLength( const wxChar* const* enumArray )
@ -29,37 +28,8 @@ static int _calcEnumLength( const wxChar* const* enumArray )
return cnt;
}
//////////////////////////////////////////////////////////////////////////////////////////
//
IniInterface::IniInterface( wxConfigBase& config ) :
m_Config( config )
{
}
IniInterface::IniInterface() :
m_Config( *wxConfigBase::Get() )
{
}
IniInterface::~IniInterface()
{
Flush();
}
void IniInterface::SetPath( const wxString& path )
{
m_Config.SetPath( path );
}
void IniInterface::Flush()
{
m_Config.Flush();
}
//////////////////////////////////////////////////////////////////////////////////////////
//
IniScopedGroup::IniScopedGroup( IniInterface& mommy, const wxString& group ) :
m_mom( mommy )
IniScopedGroup::IniScopedGroup( IniInterface& mommy, const wxString& group )
: m_mom( mommy )
{
pxAssertDev( wxStringTokenize( group, L"/" ).Count() <= 1, L"Cannot nest more than one group deep per instance of IniScopedGroup." );
m_mom.SetPath( group );
@ -70,26 +40,62 @@ IniScopedGroup::~IniScopedGroup()
m_mom.SetPath( L".." );
}
//////////////////////////////////////////////////////////////////////////////////////////
//
IniLoader::IniLoader( wxConfigBase& config ) : IniInterface( config )
// --------------------------------------------------------------------------------------
// IniInterface (implementations)
// --------------------------------------------------------------------------------------
IniInterface::IniInterface( wxConfigBase& config )
{
m_Config = &config;
}
IniInterface::IniInterface( wxConfigBase* config )
{
m_Config = config;
}
IniInterface::IniInterface()
{
m_Config = wxConfigBase::Get( false );
}
IniInterface::~IniInterface()
{
Flush();
}
void IniInterface::SetPath( const wxString& path )
{
if( m_Config ) m_Config->SetPath( path );
}
void IniInterface::Flush()
{
if( m_Config ) m_Config->Flush();
}
// --------------------------------------------------------------------------------------
// IniLoader (implementations)
// --------------------------------------------------------------------------------------
IniLoader::IniLoader( wxConfigBase& config ) : IniInterface( config ) { }
IniLoader::IniLoader( wxConfigBase* config ) : IniInterface( config ) { }
IniLoader::IniLoader() : IniInterface() {}
IniLoader::~IniLoader() throw() {}
void IniLoader::Entry( const wxString& var, wxString& value, const wxString& defvalue )
{
m_Config.Read( var, &value, defvalue );
if( m_Config )
m_Config->Read( var, &value, defvalue );
else
value = defvalue;
}
void IniLoader::Entry( const wxString& var, wxDirName& value, const wxDirName& defvalue )
{
wxString dest;
m_Config.Read( var, &dest, wxEmptyString );
if( m_Config ) m_Config->Read( var, &dest, wxEmptyString );
if( dest.IsEmpty() )
value = defvalue;
@ -99,26 +105,32 @@ void IniLoader::Entry( const wxString& var, wxDirName& value, const wxDirName& d
void IniLoader::Entry( const wxString& var, wxFileName& value, const wxFileName& defvalue )
{
wxString dest;
m_Config.Read( var, &dest, defvalue.GetFullPath() );
wxString dest( defvalue.GetFullPath() );
if( m_Config ) m_Config->Read( var, &dest, defvalue.GetFullPath() );
value = dest;
}
void IniLoader::Entry( const wxString& var, int& value, const int defvalue )
{
m_Config.Read( var, &value, defvalue );
if( m_Config )
m_Config->Read( var, &value, defvalue );
else
value = defvalue;
}
void IniLoader::Entry( const wxString& var, uint& value, const uint defvalue )
{
m_Config.Read( var, (int*)&value, (int)defvalue );
if( m_Config )
m_Config->Read( var, (int*)&value, (int)defvalue );
else
value = defvalue;
}
void IniLoader::Entry( const wxString& var, bool& value, const bool defvalue )
{
// TODO : Stricter value checking on enabled/disabled?
wxString dest;
m_Config.Read( var, &dest, defvalue ? L"enabled" : L"disabled" );
wxString dest(defvalue ? L"enabled" : L"disabled");
if( m_Config ) m_Config->Read( var, &dest, dest );
value = (dest == L"enabled") || (dest == L"1");
}
@ -143,23 +155,35 @@ void IniLoader::Entry( const wxString& var, Fixed100& value, const Fixed100& def
// has way too much rounding error so we really need to do things out manually.. >_<
wxString readval( value.ToString() );
m_Config.Read( var, &readval );
if( m_Config ) m_Config->Read( var, &readval );
value = Fixed100::FromString( readval, value );
}
void IniLoader::Entry( const wxString& var, wxPoint& value, const wxPoint& defvalue )
{
TryParse( value, m_Config.Read( var, ToString( defvalue ) ), defvalue );
if( !m_Config )
{
value = defvalue; return;
}
TryParse( value, m_Config->Read( var, ToString( defvalue ) ), defvalue );
}
void IniLoader::Entry( const wxString& var, wxSize& value, const wxSize& defvalue )
{
TryParse( value, m_Config.Read( var, ToString( defvalue ) ), defvalue );
if( !m_Config )
{
value = defvalue; return;
}
TryParse( value, m_Config->Read( var, ToString( defvalue ) ), defvalue );
}
void IniLoader::Entry( const wxString& var, wxRect& value, const wxRect& defvalue )
{
TryParse( value, m_Config.Read( var, ToString( defvalue ) ), defvalue );
if( !m_Config )
{
value = defvalue; return;
}
TryParse( value, m_Config->Read( var, ToString( defvalue ) ), defvalue );
}
void IniLoader::_EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, int defvalue )
@ -175,8 +199,14 @@ void IniLoader::_EnumEntry( const wxString& var, int& value, const wxChar* const
// Sanity confirmed, proceed with craziness!
if( !m_Config )
{
value = defvalue;
return;
}
wxString retval;
m_Config.Read( var, &retval, enumArray[defvalue] );
m_Config->Read( var, &retval, enumArray[defvalue] );
int i=0;
while( enumArray[i] != NULL && ( retval != enumArray[i] ) ) i++;
@ -192,82 +222,95 @@ void IniLoader::_EnumEntry( const wxString& var, int& value, const wxChar* const
value = i;
}
//////////////////////////////////////////////////////////////////////////////////////////
//
// --------------------------------------------------------------------------------------
// IniSaver (implementations)
// --------------------------------------------------------------------------------------
IniSaver::IniSaver( wxConfigBase& config ) : IniInterface( config ) { }
IniSaver::IniSaver( wxConfigBase* config ) : IniInterface( config ) { }
IniSaver::IniSaver( wxConfigBase& config ) : IniInterface( config )
{
}
IniSaver::IniSaver() : IniInterface() {}
IniSaver::~IniSaver() {}
void IniSaver::Entry( const wxString& var, wxString& value, const wxString& defvalue )
{
m_Config.Write( var, value );
if( !m_Config ) return;
m_Config->Write( var, value );
}
void IniSaver::Entry( const wxString& var, wxDirName& value, const wxDirName& defvalue )
{
if( !m_Config ) return;
/*if( value == defvalue )
m_Config.Write( var, wxString() );
m_Config->Write( var, wxString() );
else*/
m_Config.Write( var, value.ToString() );
m_Config->Write( var, value.ToString() );
}
void IniSaver::Entry( const wxString& var, wxFileName& value, const wxFileName& defvalue )
{
m_Config.Write( var, value.GetFullPath() );
if( !m_Config ) return;
m_Config->Write( var, value.GetFullPath() );
}
void IniSaver::Entry( const wxString& var, int& value, const int defvalue )
{
m_Config.Write( var, value );
if( !m_Config ) return;
m_Config->Write( var, value );
}
void IniSaver::Entry( const wxString& var, uint& value, const uint defvalue )
{
m_Config.Write( var, (int)value );
if( !m_Config ) return;
m_Config->Write( var, (int)value );
}
void IniSaver::Entry( const wxString& var, bool& value, const bool defvalue )
{
m_Config.Write( var, value ? L"enabled" : L"disabled" );
if( !m_Config ) return;
m_Config->Write( var, value ? L"enabled" : L"disabled" );
}
bool IniSaver::EntryBitBool( const wxString& var, bool value, const bool defvalue )
{
m_Config.Write( var, value ? L"enabled" : L"disabled" );
if( m_Config ) m_Config->Write( var, value ? L"enabled" : L"disabled" );
return value;
}
int IniSaver::EntryBitfield( const wxString& var, int value, const int defvalue )
{
m_Config.Write( var, value );
if( m_Config ) m_Config->Write( var, value );
return value;
}
void IniSaver::Entry( const wxString& var, Fixed100& value, const Fixed100& defvalue )
{
if( !m_Config ) return;
// Note: the "easy" way would be to convert to double and load/save that, but floating point
// has way too much rounding error so we really need to do things out manually, using strings.
m_Config.Write( var, value.ToString() );
m_Config->Write( var, value.ToString() );
}
void IniSaver::Entry( const wxString& var, wxPoint& value, const wxPoint& defvalue )
{
m_Config.Write( var, ToString( value ) );
if( !m_Config ) return;
m_Config->Write( var, ToString( value ) );
}
void IniSaver::Entry( const wxString& var, wxSize& value, const wxSize& defvalue )
{
m_Config.Write( var, ToString( value ) );
if( !m_Config ) return;
m_Config->Write( var, ToString( value ) );
}
void IniSaver::Entry( const wxString& var, wxRect& value, const wxRect& defvalue )
{
m_Config.Write( var, ToString( value ) );
if( !m_Config ) return;
m_Config->Write( var, ToString( value ) );
}
void IniSaver::_EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, int defvalue )
@ -282,6 +325,8 @@ void IniSaver::_EnumEntry( const wxString& var, int& value, const wxChar* const*
defvalue = cnt-1;
}
if( !m_Config ) return;
if( value >= cnt )
{
Console.Warning( L"(SaveSettings) An illegal enumerated index was detected when saving '%s'", var.c_str() );
@ -297,6 +342,6 @@ void IniSaver::_EnumEntry( const wxString& var, int& value, const wxChar* const*
value = defvalue;
}
m_Config.Write( var, enumArray[value] );
m_Config->Write( var, enumArray[value] );
}

View File

@ -20,7 +20,7 @@
#include <wx/utils.h>
// ---------------------------------------------------------------------------------
// wxDirName Implementations
// wxDirName (implementations)
// ---------------------------------------------------------------------------------
wxFileName wxDirName::Combine( const wxFileName& right ) const
@ -116,10 +116,9 @@ wxString Path::Normalize( const wxString& src )
return normalize.GetFullPath();
}
wxString Path::Normalize( wxDirName src )
wxString Path::Normalize( const wxDirName& src )
{
src.Normalize();
return src.ToString();
return wxDirName(src).Normalize().ToString();
}
// Concatenates two pathnames together, inserting delimiters (backslash on win32)

View File

@ -21,13 +21,13 @@
// pxStaticText (implementations)
// --------------------------------------------------------------------------------------
pxStaticText::pxStaticText( wxWindow* parent )
: _parent( parent )
: _parent( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER )
{
m_heightInLines = 1;
}
pxStaticText::pxStaticText( wxWindow* parent, const wxString& label, wxAlignment align )
: _parent( parent )
: _parent( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER )
{
m_heightInLines = 1;
m_align = align;
@ -40,12 +40,19 @@ void pxStaticText::Init( const wxString& label )
{
m_autowrap = true;
m_wrappedWidth = -1;
//SetHeight( 1 );
SetLabel( label );
m_label = label;
Connect( wxEVT_PAINT, wxPaintEventHandler(pxStaticText::paintEvent) );
}
// we need to refresh the window after changing its size as the standard
// control doesn't always update itself properly (fials typically on window resizes where
// the control is expanded to fit -- ie the control's size changes but the position does not)
void pxStaticText::DoSetSize(int x, int y, int w, int h, int sizeFlags)
{
_parent::DoSetSize(x, y, w, h, sizeFlags);
Refresh();
}
void pxStaticText::SetPaddingDefaults()
{
m_paddingPix_horiz = 7;
@ -55,6 +62,18 @@ void pxStaticText::SetPaddingDefaults()
m_paddingPct_vert = 0.0f;
}
pxStaticText& pxStaticText::SetMinWidth( int width )
{
SetMinSize( wxSize( width, GetMinHeight() ) );
return *this;
}
pxStaticText& pxStaticText::SetMinHeight( int height )
{
SetMinSize( wxSize( GetMinWidth(), height) );
return *this;
}
pxStaticText& pxStaticText::SetHeight( int lines )
{
if( !pxAssert(lines > 0) ) lines = 2;
@ -165,8 +184,7 @@ wxSize pxStaticText::GetBestWrappedSize( const wxClientDC& dc ) const
idealWidth = (int)(wxGetDisplaySize().GetWidth() * 0.66) - (parentalAdjust*2);
}
wxString label(GetLabel());
return dc.GetMultiLineTextExtent(pxTextWrapper().Wrap( this, label, idealWidth - calcPaddingWidth(idealWidth) ).GetResult());
return dc.GetMultiLineTextExtent(pxTextWrapper().Wrap( this, m_label, idealWidth - calcPaddingWidth(idealWidth) ).GetResult());
}
pxStaticText& pxStaticText::WrapAt( int width )
@ -179,10 +197,7 @@ pxStaticText& pxStaticText::WrapAt( int width )
m_wrappedWidth = width;
if( width > 1 )
{
wxString label( GetLabel() );
wrappedLabel = pxTextWrapper().Wrap( this, label, width ).GetResult();
}
wrappedLabel = pxTextWrapper().Wrap( this, m_label, width ).GetResult();
if(m_wrappedLabel != wrappedLabel )
{
@ -218,10 +233,7 @@ bool pxStaticText::_updateWrapping( bool textChanged )
m_wrappedWidth = newWidth;
if( m_wrappedWidth > 1 )
{
wxString label( GetLabel() );
wrappedLabel = pxTextWrapper().Wrap( this, label, m_wrappedWidth ).GetResult();
}
wrappedLabel = pxTextWrapper().Wrap( this, m_label, m_wrappedWidth ).GetResult();
if( m_wrappedLabel == wrappedLabel ) return false;
m_wrappedLabel = wrappedLabel;
@ -236,10 +248,10 @@ void pxStaticText::UpdateWrapping( bool textChanged )
void pxStaticText::SetLabel(const wxString& label)
{
const bool labelChanged( label != GetLabel() );
const bool labelChanged( label != m_label );
if( labelChanged )
{
_parent::SetLabel( label );
m_label = label;
Refresh();
}
@ -280,17 +292,8 @@ void pxStaticText::paintEvent(wxPaintEvent& evt)
pxWindowTextWriter writer( dc );
writer.Align( m_align );
wxString label;
if( m_autowrap )
{
_updateWrapping( false );
label = m_wrappedLabel;
}
else
{
label = GetLabel();
}
const wxString& label( m_autowrap ? m_wrappedLabel : m_label );
if( m_autowrap ) _updateWrapping( false );
int tWidth, tHeight;
dc.GetMultiLineTextExtent( label, &tWidth, &tHeight );

View File

@ -87,8 +87,9 @@ pxWindowTextWriter& pxWindowTextWriter::MoveY( int ydelta )
void pxWindowTextWriter::_DoWriteLn( const wxChar* msg )
{
pxAssume( msg );
int tWidth, tHeight;
m_dc.GetTextExtent( msg, &tWidth, &tHeight );
m_dc.GetMultiLineTextExtent( msg, &tWidth, &tHeight );
wxPoint dispos( m_curpos );

View File

@ -18,6 +18,7 @@
#include "wxGuiTools.h"
#include "pxStaticText.h"
#include "Threading.h"
#include "IniInterface.h"
#include <wx/cshelp.h>
#include <wx/tooltip.h>
@ -27,7 +28,7 @@ using namespace pxSizerFlags;
pxDialogCreationFlags pxDialogFlags()
{
return pxDialogCreationFlags().CloseBox().SystemMenu().Caption().Vertical();
return pxDialogCreationFlags().CloseBox().Caption().Vertical();
}
@ -116,7 +117,7 @@ wxDialogWithHelpers::wxDialogWithHelpers()
m_hasContextHelp = false;
m_extraButtonSizer = NULL;
Init();
Init( pxDialogFlags() );
}
wxDialogWithHelpers::wxDialogWithHelpers( wxWindow* parent, const wxString& title, const pxDialogCreationFlags& cflags )
@ -129,16 +130,21 @@ wxDialogWithHelpers::wxDialogWithHelpers( wxWindow* parent, const wxString& titl
*this += StdPadding;
}
Init();
SetMinWidth( cflags.MinimumWidth );
Init( cflags );
SetMinSize( cflags.MinimumSize );
}
wxDialogWithHelpers::~wxDialogWithHelpers() throw()
{
}
void wxDialogWithHelpers::Init()
void wxDialogWithHelpers::Init( const pxDialogCreationFlags& cflags )
{
// This fixes it so that the dialogs show up in the task bar in Vista:
// (otherwise they go stupid iconized mode if the user minimizes them)
if( cflags.hasMinimizeBox )
SetExtraStyle(GetExtraStyle() & ~wxTOPLEVEL_EX_DIALOG);
m_extraButtonSizer = NULL;
if( m_hasContextHelp )
@ -172,10 +178,8 @@ wxString wxDialogWithHelpers::GetDialogName() const
return wxEmptyString;
}
void wxDialogWithHelpers::SmartCenterFit()
void wxDialogWithHelpers::DoAutoCenter()
{
Fit();
// Smart positioning logic! If our parent window is larger than our window by some
// good amount, then we center on that. If not, center relative to the screen. This
// avoids the popup automatically eclipsing the parent window (which happens in PCSX2
@ -196,12 +200,50 @@ void wxDialogWithHelpers::SmartCenterFit()
if( centerfail ) CenterOnScreen();
}
void wxDialogWithHelpers::SmartCenterFit()
{
Fit();
const wxString dlgName( GetDialogName() );
if( dlgName.IsEmpty() )
{
DoAutoCenter(); return;
}
if( wxConfigBase* cfg = wxConfigBase::Get( false ) )
{
wxRect screenRect( GetScreenRect() );
IniLoader loader( cfg );
IniScopedGroup group( loader, L"DialogPositions" );
cfg->SetRecordDefaults( false );
if( GetWindowStyle() & wxRESIZE_BORDER )
{
wxSize size;
loader.Entry( dlgName + L"_Size", size, screenRect.GetSize() );
SetSize( size );
}
if( !cfg->Exists( dlgName + L"_Pos" ) )
DoAutoCenter();
else
{
wxPoint pos;
loader.Entry( dlgName + L"_Pos", pos, screenRect.GetPosition() );
SetPosition( pos );
}
cfg->SetRecordDefaults( true );
}
}
// Overrides wxDialog behavior to include automatic Fit() and CenterOnParent/Screen. The centering
// is based on a heuristic the centers against the parent window if the parent window is at least
// 75% larger than the fitted dialog.
int wxDialogWithHelpers::ShowModal()
{
SmartCenterFit();
m_CreatedRect = GetScreenRect();
return wxDialog::ShowModal();
}
@ -210,7 +252,11 @@ int wxDialogWithHelpers::ShowModal()
// 75% larger than the fitted dialog.
bool wxDialogWithHelpers::Show( bool show )
{
if( show ) SmartCenterFit();
if( show )
{
SmartCenterFit();
m_CreatedRect = GetScreenRect();
}
return wxDialog::Show( show );
}
@ -231,6 +277,30 @@ pxStaticText& wxDialogWithHelpers::Heading( const wxString& label )
void wxDialogWithHelpers::OnCloseWindow( wxCloseEvent& evt )
{
// Save the dialog position if the dialog is named...
// FIXME : This doesn't get called if the app is exited by alt-f4'ing the main app window.
// ... not sure how to fix that yet. I could register a list of open windows into wxAppWithHelpers
// that systematically get closed. Seems like work, maybe later. --air
if( wxConfigBase* cfg = wxConfigBase::Get( false ) )
{
const wxString dlgName( GetDialogName() );
const wxRect screenRect( GetScreenRect() );
if( !dlgName.IsEmpty() && ( m_CreatedRect != screenRect) )
{
wxPoint pos( screenRect.GetPosition() );
IniSaver saver( cfg );
IniScopedGroup group( saver, L"DialogPositions" );
if( GetWindowStyle() & wxRESIZE_BORDER )
{
wxSize size( screenRect.GetSize() );
saver.Entry( dlgName + L"_Size", size, screenRect.GetSize() );
}
saver.Entry( dlgName + L"_Pos", pos, screenRect.GetPosition() );
}
}
if( !IsModal() ) Destroy();
evt.Skip();
}
@ -292,6 +362,14 @@ wxDialogWithHelpers& wxDialogWithHelpers::SetMinWidth( int newWidth )
return *this;
}
wxDialogWithHelpers& wxDialogWithHelpers::SetMinHeight( int newHeight )
{
SetMinSize( wxSize( GetMinWidth(), newHeight ) );
if( wxSizer* sizer = GetSizer() )
sizer->SetMinSize( wxSize( sizer->GetMinSize().GetWidth(), newHeight ) );
return *this;
}
// --------------------------------------------------------------------------------------
// wxPanelWithHelpers Implementations
// --------------------------------------------------------------------------------------

View File

@ -17,7 +17,7 @@
#include <wx/fileconf.h>
#include "IniInterface.h"
#include "Utilities/IniInterface.h"
#include "Config.h"
#include "GS.h"

View File

@ -16,11 +16,12 @@
#include "PrecompiledHeader.h"
#include "App.h"
#include "MainFrame.h"
#include "IniInterface.h"
#include "Plugins.h"
#include "MemoryCardFile.h"
#include "Utilities/IniInterface.h"
#include <wx/stdpaths.h>
#include "DebugTools/Debug.h"
@ -317,13 +318,10 @@ wxString AppConfig::FullpathTo( PluginsEnum_t pluginidx ) const
// rather than any other type of more direct string comparison!
bool AppConfig::FullpathMatchTest( PluginsEnum_t pluginId, const wxString& cmpto ) const
{
wxFileName right( cmpto );
wxFileName left( FullpathTo(pluginId) );
// Implementation note: wxFileName automatically normalizes things as needed in it's
// equality comparison implementations, so we can do a simple comparison as follows:
left.MakeAbsolute();
right.MakeAbsolute();
return left == right;
return wxFileName(cmpto).SameAs( FullpathTo(pluginId) );
}
wxDirName GetLogFolder()
@ -352,7 +350,7 @@ AppConfig::AppConfig()
: MainGuiPosition( wxDefaultPosition )
, SysSettingsTabName( L"Cpu" )
, McdSettingsTabName( L"Standard" )
, AppSettingsTabName( L"GS Window" )
, AppSettingsTabName( L"Plugins" )
, DeskTheme( L"default" )
{
LanguageId = wxLANGUAGE_DEFAULT;

View File

@ -15,7 +15,7 @@
#include "PrecompiledHeader.h"
#include "App.h"
#include "IniInterface.h"
#include "Utilities/IniInterface.h"
#include "Utilities/EventSource.inl"
template class EventSource< IEventListener_CoreThread >;

View File

@ -14,11 +14,11 @@
*/
#include "PrecompiledHeader.h"
#include "IniInterface.h"
#include "MainFrame.h"
#include "ConsoleLogger.h"
#include "MSWstuff.h"
#include "Utilities/IniInterface.h"
#include "DebugTools/Debug.h"
#include "Dialogs/ModalPopups.h"
@ -61,6 +61,9 @@ void Pcsx2App::WipeUserModeSettings()
if( !usrlocaldir.Exists() ) return;
wxString cwd( Path::Normalize( wxGetCwd() ) );
#ifdef __WXMSW__
cwd.MakeLower();
#endif
u32 hashres = HashTools::Hash( (char*)cwd.c_str(), cwd.Length()*sizeof(wxChar) );
wxFileName usermodefile( FilenameDefs::GetUsermodeConfig() );
@ -91,6 +94,10 @@ void Pcsx2App::ReadUserModeSettings()
}
wxString cwd( Path::Normalize( wxGetCwd() ) );
#ifdef __WXMSW__
cwd.MakeLower();
#endif
u32 hashres = HashTools::Hash( (char*)cwd.c_str(), cwd.Length()*sizeof(wxChar) );
wxFileName usermodefile( FilenameDefs::GetUsermodeConfig() );

View File

@ -14,7 +14,6 @@
*/
#include "PrecompiledHeader.h"
#include "IniInterface.h"
#include "MainFrame.h"
#include "GSFrame.h"
@ -26,6 +25,7 @@
#include "Dialogs/ConfigurationDialog.h"
#include "Dialogs/LogOptionsDialog.h"
#include "Utilities/IniInterface.h"
#include "Utilities/HashMap.h"
#ifdef __WXMSW__

View File

@ -32,16 +32,13 @@ using namespace pxSizerFlags;
// --------------------------------------------------------------------------------------
Dialogs::AboutBoxDialog::AboutBoxDialog( wxWindow* parent )
: wxDialogWithHelpers( parent, _("About PCSX2") )
: wxDialogWithHelpers( parent, _("About PCSX2"), pxDialogFlags().Resize().MinWidth( 460 ) )
, m_bitmap_dualshock( this, wxID_ANY, wxBitmap( EmbeddedImage<res_Dualshock>().Get() ),
wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN
)
{
static const wxString LabelAuthors = fromUTF8(
"Developers"
"\n\n"
"v0.9.6+: Arcum42, Refraction, "
"drk||raziel, cottonvibes, gigaherz, "
"Arcum42, Refraction, drk||raziel, cottonvibes, gigaherz, "
"rama, Jake.Stine, saqib, Tmkk, pseudonym"
"\n\n"
"Previous versions: Alexey silinov, Aumatt, "
@ -56,38 +53,36 @@ Dialogs::AboutBoxDialog::AboutBoxDialog( wxWindow* parent )
);
static const wxString LabelGreets = fromUTF8(
"Contributors"
"\n\n"
"Hiryu and Sjeep (libcdvd / iso filesystem), nneeve (fpu and vu)"
"Hiryu and Sjeep (libcdvd / iso filesystem), nneeve (fpu and vu), gregory (linux distros)"
"\n\n"
"Plugin Specialists: ChickenLiver (Lilypad), Efp (efp), "
"Gabest (Gsdx, Cdvdolio, Xpad), Zeydlitz (ZZogl)"
"\n\n"
"Special thanks to: black_wd, Belmont, BGome, _Demo_, Dreamtime, "
"F|RES, MrBrown, razorblade, Seta-san, Skarmeth, feal87, Athos, gregory"
"F|RES, MrBrown, razorblade, Seta-san, Skarmeth, feal87, Athos"
);
// This sizer holds text of the authors and a logo!
wxBoxSizer& AuthLogoSizer = *new wxBoxSizer( wxHORIZONTAL );
wxFlexGridSizer& AuthLogoSizer = *new wxFlexGridSizer( 2, 0, StdPadding );
AuthLogoSizer.AddGrowableCol(0, 4);
AuthLogoSizer.AddGrowableCol(1, 3);
// this sizer holds text of the contributors/testers, and a ps2 image!
wxBoxSizer& ContribSizer = *new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer& aboutUs = *new wxStaticBoxSizer( wxVERTICAL, this );
wxStaticBoxSizer& contribs = *new wxStaticBoxSizer( wxVERTICAL, this );
wxStaticBoxSizer& aboutUs = *new wxStaticBoxSizer( wxVERTICAL, this );
wxStaticBoxSizer& contribs = *new wxStaticBoxSizer( wxVERTICAL, this );
pxStaticText& label_auth = Text( LabelAuthors );
pxStaticText& label_greets = Text( LabelGreets );
pxStaticText& label_auth = Text( LabelAuthors ).SetMinWidth(240);
pxStaticText& label_greets = Text( LabelGreets ).SetMinWidth(200);
//label_auth->Wrap( 340 );
//label_greets->Wrap( 200 );
aboutUs += Heading(L"Developers").Bold() | StdExpand();
aboutUs += label_auth | StdExpand();
contribs += Heading(L"Contributors").Bold() | StdExpand();
contribs += label_greets | StdExpand();
aboutUs += label_auth | StdExpand();
contribs += label_greets | StdExpand();
AuthLogoSizer += aboutUs;
AuthLogoSizer += 7;
AuthLogoSizer += contribs;
AuthLogoSizer += aboutUs | StdExpand();
AuthLogoSizer += contribs | StdExpand();
ContribSizer += pxStretchSpacer( 1 );
ContribSizer += m_bitmap_dualshock | StdSpace();
@ -95,17 +90,23 @@ Dialogs::AboutBoxDialog::AboutBoxDialog( wxWindow* parent )
// Main (top-level) layout
*this += Text(_("PCSX2 - Playstation 2 Emulator")) | StdCenter();
*this += AuthLogoSizer | StdSpace();
*this += StdPadding;
*this += Text(_("PCSX2")).Bold() | pxExpand;
*this += Text(_("A Playstation 2 Emulator")) | pxExpand;
*this += AuthLogoSizer | StdExpand();
*this += new wxHyperlinkCtrl( this, wxID_ANY,
_("Pcsx2 Official Website and Forums"), L"http://www.pcsx2.net"
) | wxSizerFlags(1).Center().Border( wxALL, 3 );
_("PCSX2 Official Website and Forums"), L"http://www.pcsx2.net"
) | pxProportion(1).Center().Border( wxALL, 3 );
*this += new wxHyperlinkCtrl( this, wxID_ANY,
_("Pcsx2 Official Svn Repository at Googlecode"), L"http://code.google.com/p/pcsx2"
) | wxSizerFlags(1).Center().Border( wxALL, 3 );
_("PCSX2 Official Svn Repository at Googlecode"), L"http://code.google.com/p/pcsx2"
) | pxProportion(1).Center().Border( wxALL, 3 );
*this += ContribSizer | StdExpand();
*this += new wxButton( this, wxID_OK, L"I've seen enough") | StdCenter();
int bestHeight = GetBestSize().GetHeight();
if( bestHeight < 400 ) bestHeight = 400;
SetMinHeight( bestHeight );
}

View File

@ -64,10 +64,6 @@ wxString BaseApplicableDialog::GetDialogName() const
void BaseApplicableDialog::Init()
{
// This fixes it so that the dialogs show up in the task bar in Vista:
// (otherwise they go stupid iconized mode if the user minimizes them)
SetExtraStyle(GetExtraStyle() & ~wxTOPLEVEL_EX_DIALOG);
Connect( pxEvt_ApplySettings, wxCommandEventHandler (BaseApplicableDialog::OnSettingsApplied) );
wxCommandEvent applyEvent( pxEvt_ApplySettings );

View File

@ -132,7 +132,7 @@ void MainEmuFrame::OnMoveAround( wxMoveEvent& evt )
proglog->SetPosition( g_Conf->ProgLogBox.DisplayPosition );
}
//evt.Skip();
evt.Skip();
}
void MainEmuFrame::OnLogBoxHidden()

View File

@ -20,12 +20,13 @@
#include "GS.h"
#include "MainFrame.h"
#include "IsoDropTarget.h"
#include "Dialogs/ModalPopups.h"
#include "Dialogs/ConfigurationDialog.h"
#include "Dialogs/LogOptionsDialog.h"
#include "IniInterface.h"
#include "IsoDropTarget.h"
#include "Utilities/IniInterface.h"
using namespace Dialogs;
@ -51,7 +52,7 @@ void MainEmuFrame::Menu_McdSettings_Click(wxCommandEvent &event)
void MainEmuFrame::Menu_WindowSettings_Click(wxCommandEvent &event)
{
wxCommandEvent evt( pxEvt_SetSettingsPage );
evt.SetString( L"Window" );
evt.SetString( L"GS Window" );
AppOpenDialog<SysConfigDialog>( this )->GetEventHandler()->ProcessEvent( evt );
}
@ -64,7 +65,6 @@ void MainEmuFrame::Menu_GSSettings_Click(wxCommandEvent &event)
void MainEmuFrame::Menu_SelectPluginsBios_Click(wxCommandEvent &event)
{
//AppOpenDialog<BiosSelectorDialog>( this );
AppOpenDialog<ComponentsConfigDialog>( this );
}

View File

@ -165,8 +165,7 @@ void Panels::BiosSelectorPanel::DoRefresh()
m_ComboBox->Clear();
wxFileName right( g_Conf->FullpathToBios() );
right.MakeAbsolute();
const wxFileName right( g_Conf->FullpathToBios() );
for( size_t i=0; i<m_BiosList->GetCount(); ++i )
{
@ -174,10 +173,7 @@ void Panels::BiosSelectorPanel::DoRefresh()
if( !IsBIOS((*m_BiosList)[i], description) ) continue;
int sel = m_ComboBox->Append( description, (void*)i );
wxFileName left( (*m_BiosList)[i] );
left.MakeAbsolute();
if( left == right )
if( wxFileName((*m_BiosList)[i] ) == right )
m_ComboBox->SetSelection( sel );
}
}

View File

@ -16,7 +16,7 @@
#include "PrecompiledHeader.h"
#include "MainFrame.h"
#include "IsoDropTarget.h"
#include "IniInterface.h"
#include "Utilities/IniInterface.h"
extern wxString GetMsg_IsoImageChanged();

View File

@ -1964,10 +1964,6 @@
RelativePath="..\..\gui\i18n.cpp"
>
</File>
<File
RelativePath="..\..\gui\IniInterface.cpp"
>
</File>
<File
RelativePath="..\..\gui\IsoDropTarget.cpp"
>
@ -2689,10 +2685,6 @@
RelativePath="..\..\HostGui.h"
>
</File>
<File
RelativePath="..\..\gui\IniInterface.h"
>
</File>
<File
RelativePath="..\..\gui\IsoDropTarget.h"
>