UI: Switched from the old 'native' text labels to a new custom draw text label that should (hopefully!) be a lot better about positioning and wrapping text, and fitting to windows and what-not. Also gets rid of my nasty "ideal width" hack I originally used to fix-size some of the dialogs.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3150 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2010-06-04 08:00:19 +00:00
parent 6a9950e9ef
commit 8f92cdf265
33 changed files with 523 additions and 514 deletions

View File

@ -72,7 +72,7 @@ struct RadioPanelItem
struct RadioPanelObjects
{
wxRadioButton* LabelObj;
wxStaticText* SubTextObj;
pxStaticText* SubTextObj;
};
// --------------------------------------------------------------------------------------
@ -122,8 +122,8 @@ public:
void Reset();
void Realize();
wxStaticText* GetSubText( int idx );
const wxStaticText* GetSubText( int idx ) const;
pxStaticText* GetSubText( int idx );
const pxStaticText* GetSubText( int idx ) const;
pxRadioPanel& Append( const RadioPanelItem& entry );
pxRadioPanel& SetToolTip( int idx, const wxString& tip );

View File

@ -21,12 +21,6 @@
// --------------------------------------------------------------------------------------
// pxStaticText
// --------------------------------------------------------------------------------------
// Important:
// Proper use of this class requires using it's custom AddTo( wxSizer& ) method, in the
// place of wxSizer.Add(). You can also use the += operator (recommended):
//
// mySizer += new pxStaticText( this, _("omg translate me?") );
//
// This class's purpose is to overcome two fundamental annoyances in wxWidgets design:
//
// * An inability to wrap text to conform to a fitted window (a limitation imposed by
@ -38,85 +32,72 @@
// control within it's containing sizer. If both alignment flags do not match the result
// is typically undesirable.
//
// The first one is very hard to fix properly. Currently this class employs a hack where it
// grabs the "ideal" fitting width from it's containing panel/window, and then wraps text to
// fit within those confines. Under this design, pxStaticText controls will typically be the
// "regulators" of the window's display size, since they cannot really participate in the
// normal sizer system (since their minimum height is unknown until width-based sizes are
// determined).
//
// Note that if another control in the window has extends that blow the window size larger
// than the "ideal" width, then the pxStaticText will remain consistent in it's size. It
// will not attempt to grow to fit the expanded area. That might be fixable behavior, but
// it was hard enough for me to get this much working. ;)
//
class pxStaticText : public wxStaticText
class pxStaticText : public wxPanel
{
typedef wxStaticText _parent;
typedef wxPanel _parent;
protected:
wxString m_message;
int m_wrapwidth;
int m_alignflags;
bool m_unsetLabel;
double m_centerPadding;
wxAlignment m_align;
wxString m_wrappedLabel;
bool m_autowrap;
int m_wrappedWidth;
int m_heightInLines;
int m_paddingPix_horiz;
int m_paddingPix_vert;
float m_paddingPct_horiz;
float m_paddingPct_vert;
protected:
explicit pxStaticText( wxWindow* parent=NULL );
public:
explicit pxStaticText( wxWindow* parent, const wxString& label=wxEmptyString, int style=wxALIGN_LEFT );
explicit pxStaticText( wxWindow* parent, int style );
pxStaticText( wxWindow* parent, const wxString& label, wxAlignment align=wxALIGN_CENTRE_HORIZONTAL );
pxStaticText( wxWindow* parent, int heightInLines, const wxString& label, wxAlignment align=wxALIGN_CENTRE_HORIZONTAL );
virtual ~pxStaticText() throw() {}
void SetLabel( const wxString& label );
pxStaticText& SetWrapWidth( int newwidth );
pxStaticText& SetToolTip( const wxString& tip );
wxFont GetFontOk() const;
wxSize GetMinSize() const;
//void DoMoveWindow(int x, int y, int width, int height);
virtual void SetLabel(const wxString& label);
pxStaticText& SetHeight( int lines );
pxStaticText& Bold();
pxStaticText& WrapAt( int width );
void AddTo( wxSizer& sizer, wxSizerFlags flags=pxSizerFlags::StdSpace() );
void AddTo( wxSizer* sizer, const wxSizerFlags& flags=pxSizerFlags::StdSpace() ) { AddTo( *sizer, flags ); }
pxStaticText& Unwrapped();
void InsertAt( wxSizer& sizer, int position, wxSizerFlags flags=pxSizerFlags::StdSpace() );
int GetIdealWidth() const;
pxStaticText& PaddingPixH( int pixels );
pxStaticText& PaddingPixV( int pixels );
pxStaticText& PaddingPctH( float pct );
pxStaticText& PaddingPctV( float pct );
//pxStaticText& DoBestGuessHeight();
protected:
void _setLabel();
void SetPaddingDefaults();
void Init( const wxString& label );
wxSize GetBestWrappedSize( const wxClientDC& dc ) const;
wxSize DoGetBestSize() const;
int calcPaddingWidth( int newWidth ) const;
int calcPaddingHeight( int newHeight ) const;
void paintEvent(wxPaintEvent& evt);
void UpdateWrapping( bool textChanged );
bool _updateWrapping( bool textChanged );
};
extern void operator+=( wxSizer& target, pxStaticText* src );
extern void operator+=( wxSizer& target, pxStaticText& src );
extern void operator+=( wxSizer* target, pxStaticText& src );
template<>
inline void operator+=( wxSizer& target, const pxWindowAndFlags<pxStaticText>& src )
{
src.window->AddTo( target, src.flags );
//target.Add( src.window, src.flags );
}
template<>
inline void operator+=( wxSizer* target, const pxWindowAndFlags<pxStaticText>& src )
{
src.window->AddTo( target, src.flags );
//target.Add( src.window, src.flags );
}
// --------------------------------------------------------------------------------------
// pxStaticHeading
// --------------------------------------------------------------------------------------
// Basically like a pxStaticText, except it defaults to wxALIGN_CENTRE, and it has expanded
// left and right side padding.
//
// The padding is not an exact science and, if there isn't any other controls in the form
// that are equal to or exceeding the IdealWidth, the control will end up fitting tightly
// to the heading (padding will be nullified).
//
class pxStaticHeading : public pxStaticText
{
typedef pxStaticText _parent;
public:
pxStaticHeading( wxWindow* parent, const wxString& label=wxEmptyString, int style=wxALIGN_CENTRE );
pxStaticHeading( wxWindow* parent=NULL, const wxString& label=wxEmptyString );
pxStaticHeading( wxWindow* parent, int heightInLines, const wxString& label=wxEmptyString );
virtual ~pxStaticHeading() throw() {}
//using pxStaticText::operator wxSizerFlags;
protected:
void SetPaddingDefaults();
};

View File

@ -58,6 +58,11 @@ struct pxAlignmentType
return Apply( _flgs );
}
wxSizerFlags Expand() const
{
return Apply().Expand();
}
wxSizerFlags Border( int dir, int padding ) const
{
return Apply().Border( dir, padding );
@ -280,7 +285,7 @@ void operator+=( wxSizer* target, const pxWindowAndFlags<WinType>& src )
namespace pxSizerFlags
{
static const int StdPadding = 5;
static const int StdPadding = 4;
extern wxSizerFlags StdSpace();
extern wxSizerFlags StdCenter();
@ -305,7 +310,6 @@ class wxDialogWithHelpers : public wxDialog
protected:
bool m_hasContextHelp;
int m_idealWidth;
wxBoxSizer* m_extraButtonSizer;
public:
@ -328,13 +332,11 @@ public:
// screenshots to disk)
virtual wxString GetDialogName() const;
virtual pxStaticText* Text( const wxString& label );
virtual pxStaticHeading* Heading( const wxString& label );
virtual wxStaticText& Label( const wxString& label );
virtual pxStaticText& Text( const wxString& label );
virtual pxStaticText& Heading( const wxString& label );
virtual wxDialogWithHelpers& SetIdealWidth( int newWidth ) { m_idealWidth = newWidth; return *this; }
int GetIdealWidth() const { return m_idealWidth; }
bool HasIdealWidth() const { return m_idealWidth != wxDefaultCoord; }
virtual wxDialogWithHelpers& SetMinWidth( int newWidth );
protected:
void OnDialogCreated( wxCommandEvent& evt );
@ -363,9 +365,6 @@ class wxPanelWithHelpers : public wxPanel
{
DECLARE_DYNAMIC_CLASS_NO_COPY(wxPanelWithHelpers)
protected:
int m_idealWidth;
public:
wxPanelWithHelpers( wxWindow* parent, wxOrientation orient, const wxString& staticBoxLabel );
wxPanelWithHelpers( wxWindow* parent, wxOrientation orient );
@ -374,13 +373,11 @@ public:
wxPanelWithHelpers* AddFrame( const wxString& label, wxOrientation orient=wxVERTICAL );
pxStaticText* Text( const wxString& label );
pxStaticHeading* Heading( const wxString& label );
wxStaticText& Label( const wxString& label );
pxStaticText& Text( const wxString& label );
pxStaticText& Heading( const wxString& label );
// TODO : Propagate to children?
wxPanelWithHelpers& SetIdealWidth( int width ) { m_idealWidth = width; return *this; }
int GetIdealWidth() const { return m_idealWidth; }
bool HasIdealWidth() const { return m_idealWidth != wxDefaultCoord; }
virtual wxPanelWithHelpers& SetMinWidth( int newWidth );
protected:
void Init();
@ -479,25 +476,14 @@ protected:
void _DoWrite( const wxChar* msg );
public:
pxWindowTextWriter( wxDC& dc )
: m_dc( dc )
{
m_curpos = wxPoint();
m_align = wxALIGN_CENTER;
m_leading = 2;
OnFontChanged();
}
virtual ~pxWindowTextWriter() throw()
{
}
pxWindowTextWriter( wxDC& dc );
virtual ~pxWindowTextWriter() throw() { }
virtual void OnFontChanged();
pxWindowTextWriter& WriteLn();
pxWindowTextWriter& WriteLn( const wxChar* fmt, ... );
pxWindowTextWriter& FormatLn( const wxChar* fmt, ... );
pxWindowTextWriter& WriteLn( const wxChar* fmt );
pxWindowTextWriter& SetFont( const wxFont& font );
pxWindowTextWriter& Align( const wxAlignment& align );
@ -538,35 +524,6 @@ public:
pxWindowTextWriter& MoveY( int ydelta );
};
// --------------------------------------------------------------------------------------
// pxStaticTextImproved
// --------------------------------------------------------------------------------------
class pxStaticTextImproved : public wxPanelWithHelpers
{
typedef wxPanelWithHelpers _parent;
protected:
wxAlignment m_align;
wxString m_wrappedLabel;
bool m_autowrap;
int m_wrappedWidth;
int m_padding_horiz;
public:
pxStaticTextImproved( wxWindow* parent=NULL, const wxString& label=wxEmptyString, wxAlignment align=wxALIGN_CENTER );
pxStaticTextImproved( wxWindow* parent, int heightInLines, const wxString& label=wxEmptyString, wxAlignment align=wxALIGN_CENTER );
virtual ~pxStaticTextImproved() throw() {}
virtual void SetLabel(const wxString& label);
pxStaticTextImproved& Unwrapped();
protected:
void Init();
void paintEvent(wxPaintEvent& evt);
void UpdateWrapping( bool textChanged );
};
// --------------------------------------------------------------------------------------
// MoreStockCursors
// --------------------------------------------------------------------------------------

View File

@ -17,6 +17,7 @@
#include "ThreadingDialogs.h"
#include "pxStaticText.h"
using namespace pxSizerFlags;
DEFINE_EVENT_TYPE(pxEvt_ThreadedTaskComplete);
@ -40,13 +41,8 @@ Threading::WaitForTaskDialog::WaitForTaskDialog( const wxString& title, const wx
Connect( pxEvt_ThreadedTaskComplete, wxCommandEventHandler(WaitForTaskDialog::OnTaskComplete) );
wxBoxSizer& paddedMsg( *new wxBoxSizer( wxHORIZONTAL ) );
paddedMsg += 24;
paddedMsg += Heading(m_heading);
paddedMsg += 24;
*this += 12;
*this += paddedMsg;
*this += Heading(m_heading) | StdExpand();
*this += 12;
// TODO : Implement a cancel button. Not quite sure the best way to do

View File

@ -37,16 +37,15 @@ void pxCheckBox::Init(const wxString& label, const wxString& subtext)
static const int Indentation = 23;
if( !subtext.IsEmpty() )
{
m_subtext = new pxStaticText( this, subtext );
if( HasIdealWidth() )
m_subtext->SetWrapWidth( m_idealWidth - Indentation );
m_subtext = new pxStaticText( this, subtext, wxALIGN_LEFT );
wxBoxSizer& spaced( *new wxBoxSizer( wxHORIZONTAL ) );
wxFlexGridSizer& spaced( *new wxFlexGridSizer(3) );
spaced.AddGrowableCol( 1 );
spaced += Indentation;
spaced += m_subtext | pxBorder( wxBOTTOM, 9 );
spaced += m_subtext | pxBorder( wxBOTTOM, 9 ).Expand();
spaced += pxSizerFlags::StdPadding;
*this += &spaced;
*this += &spaced | pxExpand;
}
Connect( m_checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(pxCheckBox::OnCheckpartCommand) );

View File

@ -15,7 +15,7 @@
#include "PrecompiledHeader.h"
#include "pxRadioPanel.h"
#include "pxStaticText.h"
// ===========================================================================================
// pxRadioPanel Implementations
@ -80,9 +80,7 @@ void pxRadioPanel::Realize()
{
m_objects[i].SubTextObj = NULL;
if( m_buttonStrings[i].SubText.IsEmpty() ) continue;
m_objects[i].SubTextObj = new wxStaticText( this, wxID_ANY, m_buttonStrings[i].SubText );
if( (m_idealWidth > 0) && pxAssertMsg( m_idealWidth > 40, "Unusably short text wrapping specified!" ) )
m_objects[i].SubTextObj->Wrap( m_idealWidth - m_Indentation );
m_objects[i].SubTextObj = new pxStaticText( this, m_buttonStrings[i].SubText );
}
pxAssert( GetSizer() != NULL );
@ -91,9 +89,9 @@ void pxRadioPanel::Realize()
{
*this += m_objects[i].LabelObj | pxSizerFlags::StdExpand();
if( wxStaticText* subobj = m_objects[i].SubTextObj )
if( pxStaticText* subobj = m_objects[i].SubTextObj )
{
*this += subobj | pxBorder( wxLEFT, m_Indentation );
*this += subobj | pxBorder( wxLEFT, m_Indentation ).Expand();
*this += 9 + m_padding.GetHeight();
}
if( !m_buttonStrings[i].ToolTip.IsEmpty() )
@ -109,7 +107,7 @@ void pxRadioPanel::_setToolTipImmediate( int idx, const wxString &tip )
if( wxRadioButton* woot = m_objects[idx].LabelObj )
woot->SetToolTip( wrapped );
if( wxStaticText* woot = m_objects[idx].SubTextObj )
if( pxStaticText* woot = m_objects[idx].SubTextObj )
woot->SetToolTip( wrapped );
}
@ -222,13 +220,13 @@ bool pxRadioPanel::IsSelected( int idx ) const
return m_objects[idx].LabelObj->GetValue();
}
wxStaticText* pxRadioPanel::GetSubText( int idx )
pxStaticText* pxRadioPanel::GetSubText( int idx )
{
if( !VerifyRealizedState() ) return NULL;
return m_objects[idx].SubTextObj;
}
const wxStaticText* pxRadioPanel::GetSubText( int idx ) const
const pxStaticText* pxRadioPanel::GetSubText( int idx ) const
{
if( !VerifyRealizedState() ) return NULL;
return m_objects[idx].SubTextObj;

View File

@ -15,124 +15,328 @@
#include "PrecompiledHeader.h"
#include "pxStaticText.h"
#include <wx/wizard.h>
// --------------------------------------------------------------------------------------
// pxStaticText Implementations
// pxStaticText (implementations)
// --------------------------------------------------------------------------------------
pxStaticText::pxStaticText( wxWindow* parent, const wxString& label, int style )
: wxStaticText( parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, style )
, m_message( label )
pxStaticText::pxStaticText( wxWindow* parent )
: _parent( parent )
{
m_alignflags = style & wxALIGN_MASK;
m_wrapwidth = wxDefaultCoord;
m_centerPadding = 0.08;
m_heightInLines = 1;
}
pxStaticText::pxStaticText( wxWindow* parent, int style )
: wxStaticText( parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, style )
pxStaticText::pxStaticText( wxWindow* parent, const wxString& label, wxAlignment align )
: _parent( parent )
{
m_alignflags = style & wxALIGN_MASK;
m_wrapwidth = wxDefaultCoord;
m_centerPadding = 0.08;
m_heightInLines = 1;
m_align = align;
SetPaddingDefaults();
Init( label );
}
pxStaticText& pxStaticText::SetWrapWidth( int newwidth )
void pxStaticText::Init( const wxString& label )
{
m_wrapwidth = newwidth;
SetLabel( m_message );
m_autowrap = true;
m_wrappedWidth = -1;
//SetHeight( 1 );
SetLabel( label );
Connect( wxEVT_PAINT, wxPaintEventHandler(pxStaticText::paintEvent) );
}
void pxStaticText::SetPaddingDefaults()
{
m_paddingPix_horiz = 7;
m_paddingPix_vert = 1;
m_paddingPct_horiz = 0.0f;
m_paddingPct_vert = 0.0f;
}
pxStaticText& pxStaticText::SetHeight( int lines )
{
if( !pxAssert(lines > 0) ) lines = 2;
m_heightInLines = lines;
int width, height;
GetTextExtent( _("MyjS 23"), &width, &height );
const int newHeight = ((height+1)*m_heightInLines) + (m_paddingPix_vert*2);
SetMinSize( wxSize(GetMinWidth(), newHeight) );
return *this;
}
void pxStaticText::SetLabel( const wxString& label )
pxStaticText& pxStaticText::Bold()
{
m_message = label;
_setLabel();
}
void pxStaticText::_setLabel()
{
_parent::SetLabel( pxTextWrapper().Wrap( *this, m_message, GetIdealWidth() ).GetResult() );
}
pxStaticText& pxStaticText::SetToolTip( const wxString& tip )
{
pxSetToolTip( this, tip );
wxFont bold( GetFont() );
bold.SetWeight(wxBOLD);
SetFont( bold );
return *this;
}
void pxStaticText::AddTo( wxSizer& sizer, wxSizerFlags flags )
pxStaticText& pxStaticText::PaddingPixH( int pixels )
{
sizer.Add( this, flags.Align( m_alignflags | (flags.GetFlags() & wxALIGN_MASK) ) );
_setLabel();
m_paddingPix_horiz = pixels;
UpdateWrapping( false );
Refresh();
return *this;
}
void pxStaticText::InsertAt( wxSizer& sizer, int position, wxSizerFlags flags )
pxStaticText& pxStaticText::PaddingPixV( int pixels )
{
sizer.Insert( position, this, flags.Align( m_alignflags | (flags.GetFlags() & wxALIGN_MASK) ) );
_setLabel();
m_paddingPix_vert = pixels;
Refresh();
return *this;
}
int pxStaticText::GetIdealWidth() const
pxStaticText& pxStaticText::PaddingPctH( float pct )
{
if( m_wrapwidth != wxDefaultCoord ) return m_wrapwidth;
pxAssume( pct < 0.5 );
m_paddingPct_horiz = pct;
UpdateWrapping( false );
Refresh();
return *this;
}
pxStaticText& pxStaticText::PaddingPctV( float pct )
{
pxAssume( pct < 0.5 );
m_paddingPct_vert = pct;
Refresh();
return *this;
}
pxStaticText& pxStaticText::Unwrapped()
{
m_autowrap = false;
UpdateWrapping( false );
return *this;
}
int pxStaticText::calcPaddingWidth( int newWidth ) const
{
return (int)(newWidth*m_paddingPct_horiz*2) + (m_paddingPix_horiz*2);
}
int pxStaticText::calcPaddingHeight( int newHeight ) const
{
return (int)(newHeight*m_paddingPct_vert*2) + (m_paddingPix_vert*2);
}
wxSize pxStaticText::GetBestWrappedSize( const wxClientDC& dc ) const
{
pxAssume( m_autowrap );
// Find an ideal(-ish) width, based on a search of all parent controls and their
// valid Minimum sizes.
//pxAssertDev( GetContainingSizer() != NULL, "The Static Text must first belong to a Sizer!!" );
int idealWidth = wxDefaultCoord;
int parentalAdjust = 0;
const wxWindow* millrun = this;
// Find the first parent with a fixed width:
wxWindow* millrun = this->GetParent();
while( (idealWidth == wxDefaultCoord) && millrun != NULL )
while( millrun )
{
if( wxPanelWithHelpers* panel = wxDynamicCast( millrun, wxPanelWithHelpers ) )
idealWidth = panel->GetIdealWidth();
// IMPORTANT : wxWizard changes its min size and then expects everything else
// to play nice and NOT resize according to the new min size. (wtf stupid)
// Anyway, this fixes it -- ignore min size specifier on wxWizard!
if( wxIsKindOf( millrun, wxWizard ) ) break;
else if( wxDialogWithHelpers* dialog = wxDynamicCast( millrun, wxDialogWithHelpers ) )
idealWidth = dialog->GetIdealWidth();
int min = millrun->GetMinWidth() - parentalAdjust;
if( min > 0 && ((idealWidth < 0 ) || (min < idealWidth)) )
{
idealWidth = min;
}
parentalAdjust += pxSizerFlags::StdPadding*2;
millrun = millrun->GetParent();
}
if( idealWidth != wxDefaultCoord )
if( idealWidth <= 0 )
{
idealWidth -= 6;
// FIXME: The minimum size of this control is unknown, so let's just pick a guess based on some
// heuristics of the string content.. maybe? For now I just return 360. It's round. And happy.
if( GetWindowStyle() & wxALIGN_CENTRE )
idealWidth *= (1.0 - m_centerPadding);
idealWidth = 360;
}
return idealWidth;
wxString label(GetLabel());
return dc.GetMultiLineTextExtent(pxTextWrapper().Wrap( this, label, idealWidth - calcPaddingWidth(idealWidth) ).GetResult());
}
wxSize pxStaticText::GetMinSize() const
pxStaticText& pxStaticText::WrapAt( int width )
{
int ideal = GetIdealWidth();
wxSize minSize( _parent::GetMinSize() );
if( ideal == wxDefaultCoord ) return minSize;
return wxSize( std::min( ideal, minSize.x ), minSize.y );
m_autowrap = false;
if( (width <= 1) || (width == m_wrappedWidth) ) return *this;
wxString wrappedLabel;
m_wrappedWidth = width;
if( width > 1 )
{
wxString label( GetLabel() );
wrappedLabel = pxTextWrapper().Wrap( this, label, width ).GetResult();
}
if(m_wrappedLabel != wrappedLabel )
{
m_wrappedLabel = wrappedLabel;
wxSize area = wxClientDC( this ).GetMultiLineTextExtent(m_wrappedLabel);
SetMinSize( wxSize(
area.GetWidth() + calcPaddingWidth(area.GetWidth()),
area.GetHeight() + calcPaddingHeight(area.GetHeight())
) );
}
return *this;
}
bool pxStaticText::_updateWrapping( bool textChanged )
{
if( !m_autowrap )
{
//m_wrappedLabel = wxEmptyString;
//m_wrappedWidth = -1;
return false;
}
wxString wrappedLabel;
int newWidth = GetSize().GetWidth();
newWidth -= (int)(newWidth*m_paddingPct_horiz*2) + (m_paddingPix_horiz*2);
if( !textChanged && (newWidth == m_wrappedWidth) ) return false;
// Note: during various stages of sizer-calc, width can be 1, 0, or -1.
// We ignore wrapping in these cases. (the PaintEvent also checks the wrapping
// and updates it if needed, in case the control's size isn't figured out prior
// to being painted).
m_wrappedWidth = newWidth;
if( m_wrappedWidth > 1 )
{
wxString label( GetLabel() );
wrappedLabel = pxTextWrapper().Wrap( this, label, m_wrappedWidth ).GetResult();
}
if( m_wrappedLabel == wrappedLabel ) return false;
m_wrappedLabel = wrappedLabel;
return true;
}
void pxStaticText::UpdateWrapping( bool textChanged )
{
if( _updateWrapping( textChanged ) ) Refresh();
}
void pxStaticText::SetLabel(const wxString& label)
{
const bool labelChanged( label != GetLabel() );
if( labelChanged )
{
_parent::SetLabel( label );
Refresh();
}
// Always update wrapping, in case window width or something else also changed.
UpdateWrapping( labelChanged );
}
wxFont pxStaticText::GetFontOk() const
{
wxFont font( GetFont() );
if( !font.Ok() ) return wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
return font;
}
void pxStaticText::paintEvent(wxPaintEvent& evt)
{
wxPaintDC dc( this );
const int dcWidth = dc.GetSize().GetWidth();
const int dcHeight = dc.GetSize().GetHeight();
if( dcWidth < 1 ) return;
dc.SetFont( GetFontOk() );
dc.SetTextForeground(GetForegroundColour());
pxWindowTextWriter writer( dc );
writer.Align( m_align );
wxString label;
if( m_autowrap )
{
_updateWrapping( false );
label = m_wrappedLabel;
}
else
{
label = GetLabel();
}
int tWidth, tHeight;
dc.GetMultiLineTextExtent( label, &tWidth, &tHeight );
writer.Align( m_align );
if( m_align & wxALIGN_CENTER_VERTICAL )
writer.SetY( (dcHeight - tHeight) / 2 );
else
writer.SetY( (int)(dcHeight*m_paddingPct_vert) + m_paddingPix_vert );
writer.WriteLn( label ); // without formatting please.
//dc.SetBrush( *wxTRANSPARENT_BRUSH );
//dc.DrawRectangle(wxPoint(), dc.GetSize());
}
// Overloaded form wxPanel and friends.
wxSize pxStaticText::DoGetBestSize() const
{
wxClientDC dc( const_cast<pxStaticText*>(this) );
dc.SetFont( GetFontOk() );
wxSize best;
if( m_autowrap )
{
best = GetBestWrappedSize(dc);
best.x = wxDefaultCoord;
}
else
{
// No autowrapping, so we can force a specific size here!
best = dc.GetMultiLineTextExtent( GetLabel() );
best.x += calcPaddingWidth( best.x );
}
best.y += calcPaddingHeight( best.y );
CacheBestSize(best);
return best;
}
// --------------------------------------------------------------------------------------
// pxStaticHeading Implementations
// pxStaticHeading (implementations)
// --------------------------------------------------------------------------------------
pxStaticHeading::pxStaticHeading( wxWindow* parent, const wxString& label, int style )
: pxStaticText( parent, label, style )
pxStaticHeading::pxStaticHeading( wxWindow* parent, const wxString& label )
: _parent( parent )
{
m_centerPadding = 0.18;
m_align = wxALIGN_CENTER;
SetPaddingDefaults();
Init( label );
}
void operator+=( wxSizer& target, pxStaticText* src )
void pxStaticHeading::SetPaddingDefaults()
{
if( !pxAssert( src != NULL ) ) return;
src->AddTo( target );
m_paddingPix_horiz = 4;
m_paddingPix_vert = 1;
m_paddingPct_horiz = 0.08f;
m_paddingPct_vert = 0.0f;
}
void operator+=( wxSizer& target, pxStaticText& src )
{
src.AddTo( target );
}
void operator+=( wxSizer* target, pxStaticText& src )
{
src.AddTo( target );
}

View File

@ -19,6 +19,16 @@
// --------------------------------------------------------------------------------------
// pxWindowTextWriter Implementations
// --------------------------------------------------------------------------------------
pxWindowTextWriter::pxWindowTextWriter( wxDC& dc )
: m_dc( dc )
{
m_curpos = wxPoint();
m_align = wxALIGN_CENTER;
m_leading = 0;
OnFontChanged();
}
void pxWindowTextWriter::OnFontChanged()
{
}
@ -116,7 +126,8 @@ pxWindowTextWriter& pxWindowTextWriter::SetFont( const wxFont& font )
pxWindowTextWriter& pxWindowTextWriter::Align( const wxAlignment& align )
{
m_align = align;
m_align = align;
m_curpos.x = 0;
return *this;
}
@ -126,7 +137,13 @@ pxWindowTextWriter& pxWindowTextWriter::WriteLn()
return *this;
}
pxWindowTextWriter& pxWindowTextWriter::WriteLn( const wxChar* fmt, ... )
pxWindowTextWriter& pxWindowTextWriter::WriteLn( const wxChar* fmt )
{
_DoWrite( fmt );
return *this;
}
pxWindowTextWriter& pxWindowTextWriter::FormatLn( const wxChar* fmt, ... )
{
va_list args;
va_start(args,fmt);
@ -135,119 +152,3 @@ pxWindowTextWriter& pxWindowTextWriter::WriteLn( const wxChar* fmt, ... )
return *this;
}
// --------------------------------------------------------------------------------------
// pxStaticTextImproved (implementations)
// --------------------------------------------------------------------------------------
pxStaticTextImproved::pxStaticTextImproved( wxWindow* parent, const wxString& label, wxAlignment align )
: wxPanelWithHelpers( parent )
{
Init();
m_align = align;
SetLabel( label );
}
pxStaticTextImproved::pxStaticTextImproved( wxWindow* parent, int heightInLines, const wxString& label, wxAlignment align )
: wxPanelWithHelpers( parent )
{
SetMinSize( wxSize( wxDefaultCoord, heightInLines*16 ) );
Init();
m_align = align;
SetLabel( label );
}
void pxStaticTextImproved::Init()
{
m_autowrap = true;
m_wrappedWidth = -1;
m_padding_horiz = 8;
Connect( wxEVT_PAINT, wxPaintEventHandler(pxStaticTextImproved::paintEvent) );
}
pxStaticTextImproved& pxStaticTextImproved::Unwrapped()
{
m_autowrap = false;
UpdateWrapping( false );
return *this;
}
void pxStaticTextImproved::UpdateWrapping( bool textChanged )
{
if( !m_autowrap )
{
m_wrappedLabel = wxEmptyString;
m_wrappedWidth = -1;
return;
}
wxString wrappedLabel;
const int newWidth( GetSize().GetWidth() );
if( !textChanged && (newWidth == m_wrappedWidth) ) return;
// Note: during various stages of sizer-calc, width can be 1, 0, or -1.
// We ignore wrapping in these cases. (the PaintEvent also checks the wrapping
// and updates it if needed, in case the control's size isn't figured out prior
// to being painted).
m_wrappedWidth = newWidth;
if( m_wrappedWidth > 1 )
{
wxString label( GetLabel() );
wrappedLabel = pxTextWrapper().Wrap( this, label, m_wrappedWidth-(m_padding_horiz*2) ).GetResult();
}
if( m_wrappedLabel == wrappedLabel ) return;
m_wrappedLabel = wrappedLabel;
Refresh();
}
void pxStaticTextImproved::SetLabel(const wxString& label)
{
const bool labelChanged( label != GetLabel() );
if( labelChanged )
{
_parent::SetLabel( label );
Refresh();
}
// Always update wrapping, in case window width or something else also changed.
UpdateWrapping( labelChanged );
}
void pxStaticTextImproved::paintEvent(wxPaintEvent& evt)
{
wxPaintDC dc( this );
const int dcWidth( dc.GetSize().GetWidth() );
if( dcWidth < 1 ) return;
dc.SetFont( GetFont() );
pxWindowTextWriter writer( dc );
wxString label;
if( m_autowrap )
{
if( m_wrappedLabel.IsEmpty() || m_wrappedWidth != dcWidth )
{
const wxString original( GetLabel() );
if( original.IsEmpty() ) return;
m_wrappedLabel = pxTextWrapper().Wrap( this, original, dcWidth-(m_padding_horiz*2) ).GetResult();
}
label = m_wrappedLabel;
}
else
{
label = GetLabel();
}
int tWidth, tHeight;
GetTextExtent( label, &tWidth, &tHeight );
writer.Align( m_align );
if( m_align & wxALIGN_CENTER_VERTICAL )
writer.SetY( (dc.GetSize().GetHeight() - tHeight) / 2 );
writer.WriteLn( label );
}

View File

@ -129,7 +129,7 @@ wxDialogWithHelpers::wxDialogWithHelpers(wxWindow* parent, const wxString& title
SetSizer( new wxBoxSizer( orient ) );
Init();
m_idealWidth = 500;
SetMinWidth( 500 );
*this += StdPadding;
}
@ -139,7 +139,6 @@ wxDialogWithHelpers::~wxDialogWithHelpers() throw()
void wxDialogWithHelpers::Init()
{
m_idealWidth = wxDefaultCoord;
m_extraButtonSizer = NULL;
if( m_hasContextHelp )
@ -215,14 +214,19 @@ bool wxDialogWithHelpers::Show( bool show )
return wxDialog::Show( show );
}
pxStaticText* wxDialogWithHelpers::Text( const wxString& label )
wxStaticText& wxDialogWithHelpers::Label( const wxString& label )
{
return new pxStaticText( this, label );
return *new wxStaticText( this, wxID_ANY, label, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_VERTICAL );
}
pxStaticHeading* wxDialogWithHelpers::Heading( const wxString& label )
pxStaticText& wxDialogWithHelpers::Text( const wxString& label )
{
return new pxStaticHeading( this, label );
return *new pxStaticText( this, label );
}
pxStaticText& wxDialogWithHelpers::Heading( const wxString& label )
{
return *new pxStaticHeading( this, label );
}
void wxDialogWithHelpers::OnCloseWindow( wxCloseEvent& evt )
@ -280,6 +284,14 @@ void wxDialogWithHelpers::AddOkCancel( wxSizer *sizer, bool hasApply )
AddOkCancel( *sizer, hasApply );
}
wxDialogWithHelpers& wxDialogWithHelpers::SetMinWidth( int newWidth )
{
SetMinSize( wxSize( newWidth, GetMinHeight() ) );
if( wxSizer* sizer = GetSizer() )
sizer->SetMinSize( wxSize( newWidth, sizer->GetMinSize().GetHeight() ) );
return *this;
}
// --------------------------------------------------------------------------------------
// wxPanelWithHelpers Implementations
// --------------------------------------------------------------------------------------
@ -288,42 +300,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxPanelWithHelpers, wxPanel)
void wxPanelWithHelpers::Init()
{
m_idealWidth = wxDefaultCoord;
// Find the first parent with a fixed width:
wxWindow* millrun = this->GetParent();
while( (m_idealWidth == wxDefaultCoord) && millrun != NULL )
{
if( wxIsKindOf( millrun, wxPanelWithHelpers ) )
m_idealWidth = ((wxPanelWithHelpers*)millrun)->GetIdealWidth();
else if( wxIsKindOf( millrun, wxDialogWithHelpers ) )
m_idealWidth = ((wxDialogWithHelpers*)millrun)->GetIdealWidth();
millrun = millrun->GetParent();
}
if( m_idealWidth == wxDefaultCoord || GetParent() == NULL )
return;
// Check for a StaticBox -- if we belong to one then we'll want to "downgrade" the
// inherited textbox width automatically.
wxSizer* guess = GetSizer();
if( guess == NULL ) guess = GetParent()->GetSizer();
if( guess == NULL ) guess = GetParent()->GetContainingSizer();
if( guess != NULL )
{
if( wxIsKindOf( guess, wxStaticBoxSizer ) )
{
int top=0, others=0;
((wxStaticBoxSizer*)guess)->GetStaticBox()->GetBordersForSizer( &top, &others );
m_idealWidth -= others*2;
}
else
m_idealWidth -= 2; // generic padding compensation (no exact sciences to be found here)
}
}
// Creates a Static Box container for this panel. the static box sizer becomes the default
@ -343,14 +319,19 @@ wxPanelWithHelpers* wxPanelWithHelpers::AddFrame( const wxString& label, wxOrien
return this;
}
pxStaticText* wxPanelWithHelpers::Text( const wxString& label )
wxStaticText& wxPanelWithHelpers::Label( const wxString& label )
{
return new pxStaticText( this, label );
return *new wxStaticText( this, wxID_ANY, label );
}
pxStaticHeading* wxPanelWithHelpers::Heading( const wxString& label )
pxStaticText& wxPanelWithHelpers::Text( const wxString& label )
{
return new pxStaticHeading( this, label );
return *new pxStaticText( this, label );
}
pxStaticText& wxPanelWithHelpers::Heading( const wxString& label )
{
return *new pxStaticHeading( this, label );
}
wxPanelWithHelpers::wxPanelWithHelpers( wxWindow* parent, wxOrientation orient, const wxString& staticBoxLabel )
@ -378,3 +359,11 @@ wxPanelWithHelpers::wxPanelWithHelpers( wxWindow* parent, const wxPoint& pos, co
{
Init();
}
wxPanelWithHelpers& wxPanelWithHelpers::SetMinWidth( int newWidth )
{
SetMinSize( wxSize( newWidth, GetMinHeight() ) );
if( wxSizer* sizer = GetSizer() )
sizer->SetMinSize( wxSize( newWidth, sizer->GetMinSize().GetHeight() ) );
return *this;
}

View File

@ -111,7 +111,7 @@ Dialogs::AboutBoxDialog::AboutBoxDialog( wxWindow* parent )
// Main (top-level) layout
*this += Text(_("PCSX2 - Playstation 2 Emulator"));
*this += Text(_("PCSX2 - Playstation 2 Emulator")) | StdCenter();
*this += AuthLogoSizer | StdSpace();
*this += new wxHyperlinkCtrl( this, wxID_ANY,

View File

@ -22,7 +22,7 @@ using namespace pxSizerFlags;
Dialogs::AssertionDialog::AssertionDialog( const wxString& text, const wxString& stacktrace )
: wxDialogWithHelpers( NULL, _("PCSX2 Assertion Failure"), false, !stacktrace.IsEmpty() )
{
m_idealWidth = 720;
SetMinWidth( 720 );
wxFlexGridSizer* flexgrid = new wxFlexGridSizer( 1 );
flexgrid->AddGrowableCol( 0 );
@ -46,19 +46,19 @@ Dialogs::AssertionDialog::AssertionDialog( const wxString& text, const wxString&
traceArea->GetTextExtent( L"blaH yeah", NULL, &fonty );
traceArea->WriteText( stacktrace );
traceArea->SetMinSize( wxSize( GetIdealWidth()-24, (fonty+1)*18 ) );
traceArea->SetMinSize( wxSize( traceArea->GetMinWidth(), (fonty+1)*18 ) );
traceArea->SetInsertionPoint( 0 );
traceArea->ShowPosition( 0 );
}
*this += Heading( text );
*this += Heading( text ) | StdExpand();
if( traceArea != NULL ) *this += traceArea | pxExpand.Border(wxTOP|wxLEFT|wxRIGHT,8);
*this += Heading(
L"\nDo you want to stop the program [Yes/No]?"
L"\nOr press [Ignore] to suppress further assertions."
);
) | StdExpand();
*this += new ModalButtonPanel( this, MsgButtons().YesNo().Ignore() ) | StdCenter();

View File

@ -93,7 +93,7 @@ void BaseApplicableDialog::OnSettingsApplied( wxCommandEvent& evt )
Dialogs::BaseConfigurationDialog::BaseConfigurationDialog( wxWindow* parent, const wxString& title, int idealWidth )
: _parent( parent, title, wxVERTICAL )
{
m_idealWidth = idealWidth;
SetMinWidth( idealWidth );
m_listbook = NULL;
Connect( wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BaseConfigurationDialog::OnOk_Click ) );

View File

@ -30,8 +30,6 @@ using namespace pxSizerFlags;
Dialogs::BiosSelectorDialog::BiosSelectorDialog( wxWindow* parent )
: BaseApplicableDialog( parent, _("BIOS Selector"), wxVERTICAL )
{
m_idealWidth = 500;
m_selpan = new Panels::BiosSelectorPanel( this );
*this += m_selpan | StdExpand();

View File

@ -42,7 +42,7 @@ Dialogs::CreateMemoryCardDialog::CreateMemoryCardDialog( wxWindow* parent, uint
, m_mcdpath( mcdpath.IsOk() ? mcdpath : (wxDirName)g_Conf->Mcd[slot].Filename.GetPath() )
, m_mcdfile( mcdfile.IsEmpty() ? g_Conf->Mcd[slot].Filename.GetFullName() : mcdfile )
{
m_idealWidth = 472;
SetMinWidth( 472 );
m_filepicker = NULL;
m_slot = slot;
@ -69,8 +69,8 @@ Dialogs::CreateMemoryCardDialog::CreateMemoryCardDialog( wxWindow* parent, uint
s_padding += m_filepicker | StdExpand();
else
{
s_padding += Heading( _( "New card will be saved to:" ) );
s_padding += Heading( (m_mcdpath + m_mcdfile).GetFullPath() );
s_padding += Heading( _( "New card will be saved to:" ) ) | StdExpand();
s_padding += Heading( (m_mcdpath + m_mcdfile).GetFullPath() ).Unwrapped() | StdExpand();
}
s_padding += m_radio_CardSize | StdExpand();

View File

@ -42,41 +42,34 @@ bool ApplicableWizardPage::PrepForApply()
// ----------------------------------------------------------------------------
Panels::SettingsDirPickerPanel::SettingsDirPickerPanel( wxWindow* parent ) :
DirPickerPanel( parent, FolderId_Settings, _("Settings"), _("Select a folder for PCSX2 settings") )
Panels::SettingsDirPickerPanel::SettingsDirPickerPanel( wxWindow* parent )
: DirPickerPanel( parent, FolderId_Settings, _("Settings"), _("Select a folder for PCSX2 settings") )
{
pxSetToolTip( this, pxE( ".Tooltip:Folders:Settings",
L"This is the folder where PCSX2 saves your settings, including settings generated "
L"by most plugins (some older plugins may not respect this value)."
) );
// Insert this into the top of the staticboxsizer created by the constructor.
GetSizer()->Insert( 0,
new wxStaticText( this, wxID_ANY,
pxE( ".Panel:SettingsDirPicker",
L"You may optionally specify a location for your PCSX2 settings here. If the location \n"
L"contains existing PCSX2 settings, you will be given the option to import or overwrite them."
), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE
), wxSizerFlags().Expand().Border( wxBOTTOM, 6 )
);
SetStaticDesc( pxE( ".Panel:Folders:Settings",
L"You may optionally specify a location for your PCSX2 settings here. If the location "
L"contains existing PCSX2 settings, you will be given the option to import or overwrite them."
) );
}
// ----------------------------------------------------------------------------
FirstTimeWizard::UsermodePage::UsermodePage( wxWizard* parent ) :
ApplicableWizardPage( parent )
{
SetMinSize( wxSize(640, GetMinHeight()) );
SetSizer( new wxBoxSizer( wxVERTICAL ) );
wxPanelWithHelpers& panel( *new wxPanelWithHelpers( this, wxVERTICAL ) );
panel.SetIdealWidth( 640 );
m_dirpick_settings = new SettingsDirPickerPanel( &panel );
m_panel_LangSel = new LanguageSelectionPanel( &panel );
m_panel_UserSel = new DocsFolderPickerPanel( &panel );
panel += new pxStaticTextImproved( this,
_("PCSX2 is starting from a new or unknown folder and needs to be configured.")
) | pxExpand;
panel += panel.Heading(_("PCSX2 is starting from a new or unknown folder and needs to be configured.")).Bold() | pxExpand;
panel += m_panel_LangSel | StdCenter();
panel += m_panel_UserSel | pxExpand.Border( wxALL, 8 );
@ -162,7 +155,7 @@ FirstTimeWizard::FirstTimeWizard( wxWindow* parent )
L"You cannot use a copy obtained from a friend or the Internet.\n"
L"You must dump the BIOS from your *own* Playstation 2 console."
)
);
) | StdExpand();
// Assign page indexes as client data
m_page_usermode .SetClientData( (void*)0 );
@ -180,9 +173,6 @@ FirstTimeWizard::FirstTimeWizard( wxWindow* parent )
// this doesn't descent from wxDialogWithHelpers, so we need to explicitly
// fit and center it. :(
Fit();
CenterOnScreen();
Connect( wxEVT_WIZARD_PAGE_CHANGED, wxWizardEventHandler (FirstTimeWizard::OnPageChanged) );
Connect( wxEVT_WIZARD_PAGE_CHANGING, wxWizardEventHandler (FirstTimeWizard::OnPageChanging) );
Connect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler (FirstTimeWizard::OnDoubleClicked) );

View File

@ -23,9 +23,9 @@ using namespace pxSizerFlags;
Dialogs::ImportSettingsDialog::ImportSettingsDialog( wxWindow* parent )
: wxDialogWithHelpers( parent, _("Import Existing Settings?"), wxVERTICAL )
{
m_idealWidth = 440;
SetMinWidth( 440 );
pxStaticText* heading = new pxStaticHeading( this, pxE( ".Popup:ImportExistingSettings",
pxStaticText& heading = Text( pxE( ".Popup:ImportExistingSettings",
L"Existing PCSX2 settings have been found in the configured settings folder. "
L"Would you like to import these settings or overwrite them with PCSX2 default values?"
L"\n\n(or press Cancel to select a different settings folder)" )
@ -45,7 +45,7 @@ Dialogs::ImportSettingsDialog::ImportSettingsDialog( wxWindow* parent )
s_buttons += new wxButton( this, wxID_CANCEL ) | StdButton();
*this += 4;
*this += heading;
*this += heading | StdExpand();
*this += 12;
*this += &s_buttons | StdCenter();

View File

@ -24,8 +24,6 @@ using namespace Panels;
Dialogs::LogOptionsDialog::LogOptionsDialog( wxWindow* parent )
: BaseApplicableDialog( parent, _("Trace Logging"), wxVERTICAL )
{
m_idealWidth = 480;
*this += new LogOptionsPanel( this );
AddOkCancel( *GetSizer(), true );

View File

@ -36,8 +36,6 @@ wxString GetMsg_McdNtfsCompress()
Panels::McdConfigPanel_Toggles::McdConfigPanel_Toggles(wxWindow *parent)
: _parent( parent )
{
m_idealWidth -= 48;
m_check_Ejection = new pxCheckBox( this,
_("Auto-eject memory cards when loading savestates"),
pxE( ".Panel:Mcd:EnableEjection",
@ -113,7 +111,7 @@ Dialogs::McdConfigDialog::McdConfigDialog( wxWindow* parent )
//AddPage<McdConfigPanel_Toggles> ( wxLt("Settings"), cfgid.MemoryCard );
//AddPage<McdConfigPanel_Standard> ( wxLt("Slots 1/2"), cfgid.MemoryCard );
*this += Heading(_("Drag items over other items in the list to swap or copy memory cards."));
*this += Heading(_("Drag items over other items in the list to swap or copy memory cards.")) | StdExpand();
*this += StdPadding;
*this += m_panel_mcdlist | StdExpand();

View File

@ -27,8 +27,6 @@ using namespace Threading;
Dialogs::StuckThreadDialog::StuckThreadDialog( wxWindow* parent, StuckThreadActionType action, PersistentThread& stuck_thread )
: wxDialogWithHelpers( parent, _("PCSX2 Thread is not responding"), wxVERTICAL )
{
//m_idealWidth = 720;
stuck_thread.AddListener( this );
*this += Heading( wxsFormat(

View File

@ -25,7 +25,7 @@
using namespace Panels;
Dialogs::SysConfigDialog::SysConfigDialog(wxWindow* parent)
: BaseConfigurationDialog( parent, _("PS2 Settings - PCSX2"), 600 )
: BaseConfigurationDialog( parent, _("PS2 Settings - PCSX2"), 580 )
{
CreateListbook( wxGetApp().GetImgList_Config() );
const AppImageIds::ConfigIds& cfgid( wxGetApp().GetImgId().Config );

View File

@ -16,6 +16,7 @@
#include "PrecompiledHeader.h"
#include "App.h"
using namespace pxSizerFlags;
wxString SysExecEvent::GetEventName() const
{
@ -373,13 +374,14 @@ protected:
WaitingForThreadedTaskDialog::WaitingForThreadedTaskDialog( PersistentThread* thr, wxWindow* parent, const wxString& title, const wxString& content )
: wxDialogWithHelpers( parent, title, wxVERTICAL )
{
m_thread = thr;
m_idealWidth = 500;
SetMinWidth( 500 );
*this += Heading( content );
m_thread = thr;
*this += Text( content ) | StdExpand();
*this += 15;
*this += Heading( _("Press Cancel to attempt to cancel the action.") );
*this += Heading( _("Press Terminate to kill PCSX2 immediately.") );
*this += Heading( _("Press Cancel to attempt to cancel the action.") ) | pxExpand;
*this += Heading( _("Press Terminate to kill PCSX2 immediately.") ) | pxExpand;
*this += new wxButton( this, wxID_CANCEL );
*this += new wxButton( this, wxID_ANY, _("Terminate App") );

View File

@ -82,10 +82,10 @@ void Panels::BaseSelectorPanel::OnFolderChanged( wxFileDirPickerEvent& evt )
// =====================================================================================================
// BiosSelectorPanel
// =====================================================================================================
Panels::BiosSelectorPanel::BiosSelectorPanel( wxWindow* parent, int idealWidth )
Panels::BiosSelectorPanel::BiosSelectorPanel( wxWindow* parent )
: BaseSelectorPanel( parent )
{
if( idealWidth != wxDefaultCoord ) m_idealWidth = idealWidth;
SetMinWidth( 480 );
m_ComboBox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE | wxLB_SORT | wxLB_NEEDED_SB );
m_FolderPicker = new DirPickerPanel( this, FolderId_Bios,
@ -100,7 +100,7 @@ Panels::BiosSelectorPanel::BiosSelectorPanel( wxWindow* parent, int idealWidth )
wxButton* refreshButton = new wxButton( this, wxID_ANY, _("Refresh list") );
*this += Text(_("Select a BIOS rom:"));
*this += Label(_("Select a BIOS rom:"));
*this += m_ComboBox | StdExpand();
*this += refreshButton | pxBorder(wxLEFT, StdPadding);
*this += 8;

View File

@ -401,7 +401,7 @@ namespace Panels
DirPickerPanel* m_FolderPicker;
public:
BiosSelectorPanel( wxWindow* parent, int idealWidth=wxDefaultCoord );
BiosSelectorPanel( wxWindow* parent );
virtual ~BiosSelectorPanel() throw();
protected:
@ -505,7 +505,7 @@ namespace Panels
public:
virtual ~PluginSelectorPanel() throw();
PluginSelectorPanel( wxWindow* parent, int idealWidth=wxDefaultCoord );
PluginSelectorPanel( wxWindow* parent );
void CancelRefresh(); // used from destructor, stays non-virtual
void Apply();

View File

@ -56,7 +56,7 @@ void Panels::DirPickerPanel::Explore_Click( wxCommandEvent &evt )
if( !wxDirExists(path) )
{
wxDialogWithHelpers createPathDlg( NULL, _("Path does not exist"), wxVERTICAL );
createPathDlg.SetIdealWidth( 600 );
createPathDlg.SetMinWidth( 600 );
createPathDlg += createPathDlg.Text( path ) | StdCenter();
@ -167,7 +167,7 @@ void Panels::DirPickerPanel::Init( FoldersEnum_t folderid, const wxString& dialo
Panels::DirPickerPanel& Panels::DirPickerPanel::SetStaticDesc( const wxString& msg )
{
(new pxStaticText( this, msg ))->InsertAt( *GetSizer(), 0 );
GetSizer()->Insert( 0, &Heading( msg ), pxExpand );
return *this;
}

View File

@ -79,16 +79,16 @@ Panels::GSWindowSettingsPanel::GSWindowSettingsPanel( wxWindow* parent )
wxBoxSizer& s_customsize( *new wxBoxSizer( wxHORIZONTAL ) );
s_customsize += m_text_WindowWidth;
s_customsize += Text( L"x" );
s_customsize += Label( L"x" ) | StdExpand();
s_customsize += m_text_WindowHeight;
wxFlexGridSizer& s_AspectRatio( *new wxFlexGridSizer( 2, StdPadding, StdPadding ) );
//s_AspectRatio.AddGrowableCol( 0 );
s_AspectRatio.AddGrowableCol( 1 );
s_AspectRatio += Text(_("Aspect Ratio:")) | pxMiddle;
s_AspectRatio += Label(_("Aspect Ratio:")) | pxMiddle;
s_AspectRatio += m_combo_AspectRatio | pxExpand;
s_AspectRatio += Text(_("Custom Window Size:")) | pxMiddle;
s_AspectRatio += Label(_("Custom Window Size:")) | pxMiddle;
s_AspectRatio += s_customsize | pxAlignRight;
*this += s_AspectRatio | StdExpand();

View File

@ -18,12 +18,9 @@
using namespace pxSizerFlags;
Panels::GameFixesPanel::GameFixesPanel( wxWindow* parent ) :
BaseApplicableConfigPanel( parent )
Panels::GameFixesPanel::GameFixesPanel( wxWindow* parent )
: BaseApplicableConfigPanel( parent )
{
*this += new pxStaticHeading( this, _("Some games need special settings.\nEnable them here."));
wxStaticBoxSizer& groupSizer = *new wxStaticBoxSizer( wxVERTICAL, this, _("PCSX2 Gamefixes") );
// NOTE: Order of checkboxes must match the order of the bits in the GamefixOptions structure!
@ -90,13 +87,16 @@ Panels::GameFixesPanel::GameFixesPanel( wxWindow* parent ) :
m_check_Enable->SetToolTip(_("The safest way to make sure that all game fixes are completely disabled."));
m_check_Enable->SetValue( g_Conf->EnableGameFixes );
*this += Heading(_("Some games need special settings.\nEnable them here.")).Bold() | StdExpand();
*this += groupSizer | pxCenter;
*this += m_check_Enable | StdExpand();
*this += Heading( pxE( ".Panel:Gamefixes:Compat Warning",
L"Enabling game fixes can cause compatibility or performance issues in other games. You "
L"will need to turn off fixes manually when changing games."
));
*this += Heading(
pxE( ".Panel:Gamefixes:Compat Warning",
L"Enabling game fixes can cause compatibility or performance issues in other games. You "
L"will need to turn off fixes manually when changing games."
)
) | StdExpand();
Connect( m_check_Enable->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( GameFixesPanel::OnEnable_Toggled ) );

View File

@ -124,6 +124,8 @@ Panels::iopLogOptionsPanel::iopLogOptionsPanel( LogOptionsPanel* parent )
void Panels::eeLogOptionsPanel::OnSettingsChanged()
{
SetMinWidth( 230 );
const TraceLogFilters& conf( g_Conf->EmuOptions.Trace );
SetValue( conf.EE.m_EnableAll );
@ -158,6 +160,8 @@ void Panels::eeLogOptionsPanel::OnSettingsChanged()
void Panels::iopLogOptionsPanel::OnSettingsChanged()
{
SetMinWidth( 230 );
const TraceLogFilters& conf( g_Conf->EmuOptions.Trace );
SetValue( conf.IOP.m_EnableAll );

View File

@ -160,7 +160,7 @@ void Panels::BaseMcdListPanel::RefreshMcds() const
void Panels::BaseMcdListPanel::CreateLayout()
{
if( m_listview ) m_listview->SetMinSize( wxSize( m_idealWidth, 140 ) );
//if( m_listview ) m_listview->SetMinSize( wxSize( 480, 140 ) );
wxBoxSizer& s_buttons(*new wxBoxSizer( wxHORIZONTAL ));
s_leftside_buttons = new wxBoxSizer( wxHORIZONTAL );

View File

@ -32,8 +32,6 @@ using namespace pxSizerFlags;
Panels::DocsFolderPickerPanel::DocsFolderPickerPanel( wxWindow* parent, bool isFirstTime )
: BaseApplicableConfigPanel( parent, wxVERTICAL, _("Usermode Selection") )
{
SetMinSize( wxSize( GetIdealWidth() - 16, wxDefaultCoord ) );
const wxString usermodeExplained( pxE( ".Panel:Usermode:Explained",
L"Please select your preferred default location for PCSX2 user-level documents below "
L"(includes memory cards, screenshots, settings, and savestates). "
@ -66,7 +64,7 @@ Panels::DocsFolderPickerPanel::DocsFolderPickerPanel( wxWindow* parent, bool isF
m_dirpicker_custom = new DirPickerPanel( this, FolderId_Documents, _("Select a document root for PCSX2") );
*this += new pxStaticTextImproved( this, 3, isFirstTime ? usermodeExplained : usermodeWarning ) | pxExpand;
*this += Heading( isFirstTime ? usermodeExplained : usermodeWarning ) | pxExpand;
*this += m_radio_UserMode | StdExpand();
*this += m_dirpicker_custom | pxExpand.Border( wxLEFT, StdPadding + m_radio_UserMode->GetIndentation() );
*this += 4;
@ -125,7 +123,7 @@ Panels::LanguageSelectionPanel::LanguageSelectionPanel( wxWindow* parent )
m_picker = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
size, compiled.GetPtr(), wxCB_READONLY | wxCB_SORT );
*this += Text(_("Select a language: (unimplemented)")) | pxMiddle;
*this += Label(_("Select a language: (unimplemented)")) | pxMiddle;
*this += 5;
*this += m_picker | pxSizerFlags::StdSpace();

View File

@ -308,7 +308,7 @@ Panels::PluginSelectorPanel::StatusPanel::StatusPanel( wxWindow* parent )
m_gauge.SetToolTip( _("I'm givin' her all she's got, Captain!") );
*this += new pxStaticHeading( this, _( "Enumerating available plugins..." ) );
*this += Heading(_( "Enumerating available plugins..." )).Bold() | StdExpand();
*this += m_gauge | pxExpand.Border( wxLEFT | wxRIGHT, 32 );
*this += m_label | StdExpand();
@ -352,15 +352,14 @@ Panels::PluginSelectorPanel::ComboBoxPanel::ComboBoxPanel( PluginSelectorPanel*
const PluginInfo* pi = tbl_PluginInfo; do
{
const PluginsEnum_t pid = pi->id;
wxStaticText* text = new wxStaticText( this, wxID_ANY, pi->GetShortname() );
m_combobox[pid] = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY );
m_configbutton[pid] = new wxButton( this, ButtonId_Configure, L"Configure..." );
m_configbutton[pid]->SetClientData( (void*)(int)pid );
s_plugin += text | pxBorder( wxTOP | wxLEFT, 2 );
s_plugin += m_combobox[pid] | pxExpand;
s_plugin += Label( pi->GetShortname() ) | pxBorder( wxTOP | wxLEFT, 2 );
s_plugin += m_combobox[pid] | pxExpand;
s_plugin += m_configbutton[pid];
} while( ++pi, pi->shortname != NULL );
@ -403,11 +402,9 @@ void Panels::PluginSelectorPanel::DispatchEvent( const PluginEventType& evt )
}
Panels::PluginSelectorPanel::PluginSelectorPanel( wxWindow* parent, int idealWidth )
Panels::PluginSelectorPanel::PluginSelectorPanel( wxWindow* parent )
: BaseSelectorPanel( parent )
{
if( idealWidth != wxDefaultCoord ) m_idealWidth = idealWidth;
m_StatusPanel = new StatusPanel( this );
m_ComponentBoxes = new ComboBoxPanel( this );

View File

@ -115,8 +115,6 @@ Panels::SpeedHacksPanel::SpeedHacksPanel( wxWindow* parent )
wxPanelWithHelpers* left = new wxPanelWithHelpers( this, wxVERTICAL );
wxPanelWithHelpers* right = new wxPanelWithHelpers( this, wxVERTICAL );
left->SetIdealWidth( (left->GetIdealWidth() - 16) / 2 );
right->SetIdealWidth( (right->GetIdealWidth() - 16) / 2 );
// ------------------------------------------------------------------------
// EE Cyclerate Hack Section:
@ -130,7 +128,7 @@ Panels::SpeedHacksPanel::SpeedHacksPanel( wxWindow* parent )
m_slider_eecycle = new wxSlider( eeSliderPanel, wxID_ANY, 1, 1, 3,
wxDefaultPosition, wxDefaultSize, wxHORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS );
m_msg_eecycle = new pxStaticHeading( eeSliderPanel ) ;//, GetEEcycleSliderMsg( 1 ) );
m_msg_eecycle = new pxStaticHeading( eeSliderPanel );
m_msg_eecycle->SetForegroundColour( wxColour( L"Red" ) );
m_msg_eecycle->SetMinSize( wxSize( wxDefaultCoord, pxGetTextHeight(m_msg_eecycle, 3) ) );
@ -151,7 +149,7 @@ Panels::SpeedHacksPanel::SpeedHacksPanel( wxWindow* parent )
m_slider_vustealer = new wxSlider( vuSliderPanel, wxID_ANY, 0, 0, 3, wxDefaultPosition, wxDefaultSize,
wxHORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS );
m_msg_vustealer = new pxStaticHeading( vuSliderPanel ); //, GetVUcycleSliderMsg( 0 ) );
m_msg_vustealer = new pxStaticHeading( vuSliderPanel );
m_msg_vustealer->SetForegroundColour( wxColour( L"Red" ) );
m_msg_vustealer->SetMinSize( wxSize( wxDefaultCoord, pxGetTextHeight(m_msg_vustealer, 3) ) );
@ -219,10 +217,13 @@ Panels::SpeedHacksPanel::SpeedHacksPanel( wxWindow* parent )
// ------------------------------------------------------------------------
// Layout and Size ---> (!!)
wxFlexGridSizer& DefEnableSizer( *new wxFlexGridSizer( 2, 0, 12 ) );
wxFlexGridSizer& DefEnableSizer( *new wxFlexGridSizer( 3, 0, 12 ) );
DefEnableSizer.AddGrowableCol( 1, 1 );
DefEnableSizer.AddGrowableCol( 2, 10 );
//DefEnableSizer.AddGrowableCol( 1, 1 );
DefEnableSizer += m_button_Defaults | StdSpace().Align( wxALIGN_LEFT );
DefEnableSizer += m_check_Enable | StdSpace().Align( wxALIGN_RIGHT );
DefEnableSizer += pxStretchSpacer(1);
DefEnableSizer += m_check_Enable | StdExpand().Align( wxALIGN_RIGHT );
*eeSliderPanel += m_slider_eecycle | sliderFlags;
*eeSliderPanel += m_msg_eecycle | sliderFlags;
@ -244,12 +245,12 @@ Panels::SpeedHacksPanel::SpeedHacksPanel( wxWindow* parent )
*right += vuHacksPanel | StdExpand();
s_table = new wxFlexGridSizer( 2 );
s_table->AddGrowableCol( 0 );
s_table->AddGrowableCol( 1 );
s_table->AddGrowableCol( 0, 1 );
s_table->AddGrowableCol( 1, 1 );
*s_table+= left | pxExpand;
*s_table+= right | pxExpand;
*this += heading;
*this += heading->Bold() | pxExpand;
*this += s_table | pxExpand;
*this += DefEnableSizer | pxExpand;

View File

@ -29,6 +29,8 @@ using namespace pxSizerFlags;
Panels::FramelimiterPanel::FramelimiterPanel( wxWindow* parent )
: BaseApplicableConfigPanel( parent )
{
SetMinWidth( 280 );
m_check_LimiterDisable = new pxCheckBox( this, _("Disable Framelimiting"),
_("Useful for running benchmarks. Toggle this option in-game by pressing F4.") );
@ -56,22 +58,22 @@ Panels::FramelimiterPanel::FramelimiterPanel( wxWindow* parent )
wxFlexGridSizer& s_spins( *new wxFlexGridSizer( 5 ) );
s_spins.AddGrowableCol( 0 );
s_spins += Text(_("Base Framerate Adjust:"));
s_spins += Label(_("Base Framerate Adjust:")) | StdExpand();
s_spins += 5;
s_spins += m_spin_NominalPct | pxBorder(wxTOP, 3);
s_spins += Text(L"%" );
s_spins += m_spin_NominalPct | pxBorder(wxTOP, 3);
s_spins += Label(L"%") | StdExpand();
s_spins += 5;
s_spins += Text(_("Slow Motion Adjust:"));
s_spins += Label(_("Slow Motion Adjust:")) | StdExpand();
s_spins += 5;
s_spins += m_spin_SlomoPct | pxBorder(wxTOP, 3);
s_spins += Text(L"%" );
s_spins += m_spin_SlomoPct | pxBorder(wxTOP, 3);
s_spins += Label(L"%") | StdExpand();
s_spins += 5;
s_spins += Text(_("Turbo Adjust:"));
s_spins += Label(_("Turbo Adjust:")) | StdExpand();
s_spins += 5;
s_spins += m_spin_TurboPct | pxBorder(wxTOP, 3);
s_spins += Text(L"%" );
s_spins += m_spin_TurboPct | pxBorder(wxTOP, 3);
s_spins += Label(L"%" ) | StdExpand();
s_spins += 5;
s_spins += 15;
@ -83,16 +85,16 @@ Panels::FramelimiterPanel::FramelimiterPanel( wxWindow* parent )
wxFlexGridSizer& s_fps( *new wxFlexGridSizer( 5 ) );
s_fps.AddGrowableCol( 0 );
s_fps += Text(_("NTSC Framerate:"));
s_fps += Label(_("NTSC Framerate:")) | StdExpand();
s_fps += 5;
s_fps += m_text_BaseNtsc | wxSF.Right().Border(wxTOP, 3);
s_fps += Text(_("FPS"));
s_fps += m_text_BaseNtsc | pxBorder(wxTOP, 2).Right();
s_fps += Label(_("FPS")) | StdExpand();
s_fps += 5;
s_fps += Text(_("PAL Framerate:"));
s_fps += Label(_("PAL Framerate:")) | StdExpand();
s_fps += 5;
s_fps += m_text_BasePal | wxSF.Right().Border(wxTOP, 3);
s_fps += Text(_("FPS"));
s_fps += m_text_BasePal | pxBorder(wxTOP, 2).Right();
s_fps += Label(_("FPS")) | StdExpand();
s_fps += 5;
*this += s_spins | pxExpand;
@ -101,7 +103,7 @@ Panels::FramelimiterPanel::FramelimiterPanel( wxWindow* parent )
*this += 5;
//*this += Heading( pxE( ".Panel:Framelimiter:Heading",
*this += new pxStaticTextImproved( this, pxE( ".Panel:Framelimiter:Heading",
*this += new pxStaticText( this, pxE( ".Panel:Framelimiter:Heading",
L"The internal framelimiter regulates the speed of the virtual machine. Adjustment values below are in "
L"percentages of the default region-based framerate, which can also be configured below." )
);
@ -157,6 +159,7 @@ void Panels::FramelimiterPanel::Apply()
Panels::FrameSkipPanel::FrameSkipPanel( wxWindow* parent )
: BaseApplicableConfigPanel( parent )
{
SetMinWidth( 280 );
/*m_check_EnableSkipOnTurbo = new pxCheckBox( this, _("Use Frameskip for Turbo") );
m_check_EnableSkip = new pxCheckBox( this, _("Use Frameskip"),
@ -190,7 +193,6 @@ Panels::FrameSkipPanel::FrameSkipPanel( wxWindow* parent )
};
m_radio_SkipMode = new pxRadioPanel( this, FrameskipOptions );
//m_radio_SkipMode->SetPaddingHoriz( m_radio_UserMode->GetPaddingHoriz() + 4 );
m_radio_SkipMode->Realize();
pxFitToDigits( m_spin_FramesToDraw = new wxSpinCtrl( this ), 6 );
@ -210,22 +212,22 @@ Panels::FrameSkipPanel::FrameSkipPanel( wxWindow* parent )
wxFlexGridSizer& s_spins( *new wxFlexGridSizer( 4 ) );
//s_spins.AddGrowableCol( 0 );
s_spins += m_spin_FramesToDraw | pxBorder(wxTOP, 3);
s_spins += m_spin_FramesToDraw | pxBorder(wxTOP, 2);
s_spins += 10;
s_spins += Text(_("Frames to Draw"));
s_spins += Label(_("Frames to Draw")) | StdExpand();
s_spins += 10;
s_spins += m_spin_FramesToSkip | pxBorder(wxTOP, 3);
s_spins += m_spin_FramesToSkip | pxBorder(wxTOP, 2);
s_spins += 10;
s_spins += Text(_("Frames to Skip"));
s_spins += Label(_("Frames to Skip")) | StdExpand();
s_spins += 10;
*this += s_spins | StdExpand();
*this += Heading( pxE( ".Panel:Frameskip:Heading",
*this += Text( pxE( ".Panel:Frameskip:Heading",
L"Notice: Due to PS2 hardware design, precise frame skipping is impossible. "
L"Enabling it will cause severe graphical errors in some games, and so it should be considered a speedhack." )
);
L"Enabling it will cause severe graphical errors in some games." )
) | StdExpand();
AppStatusEvent_OnSettingsApplied();
}
@ -235,7 +237,7 @@ void Panels::FrameSkipPanel::AppStatusEvent_OnSettingsApplied()
const AppConfig::FramerateOptions& appfps( g_Conf->Framerate );
const Pcsx2Config::GSOptions& gsconf( g_Conf->EmuOptions.GS );
//m_check_EnableSkip ->SetValue( !appfps.SkipOnLimit );
//m_check_EnableSkip ->SetValue( !appfps.SkipOnLimit );
//m_check_EnableSkipOnTurbo ->SetValue( !appfps.SkipOnTurbo );
m_radio_SkipMode ->SetSelection( appfps.SkipOnLimit ? 2 : (appfps.SkipOnTurbo ? 1 : 0) );
@ -282,8 +284,6 @@ Panels::VideoPanel::VideoPanel( wxWindow* parent ) :
{
wxPanelWithHelpers* left = new wxPanelWithHelpers( this, wxVERTICAL );
wxPanelWithHelpers* right = new wxPanelWithHelpers( this, wxVERTICAL );
left->SetIdealWidth( (left->GetIdealWidth()) / 2 );
right->SetIdealWidth( (right->GetIdealWidth()-24) / 2 );
m_check_SynchronousGS = new pxCheckBox( right, _("Use Synchronized MTGS"),
_("For troubleshooting potential bugs in the MTGS only, as it is potentially very slow.")
@ -313,8 +313,8 @@ Panels::VideoPanel::VideoPanel( wxWindow* parent ) :
fpan->AddFrame(_("Framelimiter"));
wxFlexGridSizer* s_table = new wxFlexGridSizer( 2 );
s_table->AddGrowableCol( 0 );
s_table->AddGrowableCol( 1 );
s_table->AddGrowableCol( 0, 1 );
s_table->AddGrowableCol( 1, 1 );
*right += span | pxExpand;
*right += 5;

View File

@ -24,17 +24,17 @@ static bool IsEnglish( int id )
return ( id == wxLANGUAGE_ENGLISH || id == wxLANGUAGE_ENGLISH_US );
}
LangPackEnumeration::LangPackEnumeration( wxLanguage langId ) :
wxLangId( langId )
, englishName( wxLocale::GetLanguageName( wxLangId ) )
, xlatedName( IsEnglish( wxLangId ) ? wxEmptyString : wxGetTranslation( L"NativeName" ) )
LangPackEnumeration::LangPackEnumeration( wxLanguage langId )
: wxLangId( langId )
, englishName( wxLocale::GetLanguageName( wxLangId ) )
, xlatedName( IsEnglish( wxLangId ) ? wxEmptyString : wxGetTranslation( L"NativeName" ) )
{
}
LangPackEnumeration::LangPackEnumeration() :
wxLangId( wxLANGUAGE_DEFAULT )
, englishName( L" System Default" ) // left-side space forces it to sort to the front of the lists
, xlatedName()
LangPackEnumeration::LangPackEnumeration()
: wxLangId( wxLANGUAGE_DEFAULT )
, englishName( L" System Default" ) // left-side space forces it to sort to the front of the lists
, xlatedName()
{
int sysLang( wxLocale::GetSystemLanguage() );
if( sysLang != wxLANGUAGE_UNKNOWN )