Working on a new replacement for pxStaticText, which should hopefully have more reliable centering and wrapping behavior. Will finish it up later.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3143 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2010-06-02 15:58:34 +00:00
parent 2f69597052
commit dd021b1ea1
13 changed files with 163 additions and 491 deletions

View File

@ -291,122 +291,6 @@
RelativePath="..\..\src\Utilities\wxHelpers.cpp"
>
</File>
<Filter
Name="Linux"
>
<File
RelativePath="..\..\src\Utilities\Linux\LnxHostSys.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Devel|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\Utilities\Linux\LnxMisc.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Devel|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\Utilities\Linux\LnxThreads.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Devel|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\Utilities\x86\MemcpyFast.S"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Devel|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Windows"
>

View File

@ -273,38 +273,6 @@
RelativePath="..\..\src\x86emitter\x86emitter.cpp"
>
</File>
<Filter
Name="Linux"
>
<File
RelativePath="..\..\src\x86emitter\LnxCpuDetect.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Devel|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Windows"
>

View File

@ -456,6 +456,7 @@ public:
}
pxTextWrapper& Wrap( const wxWindow& win, const wxString& text, int widthMax );
pxTextWrapper& Wrap( const wxWindow* win, const wxString& text, int widthMax );
protected:
virtual void OnOutputLine(const wxString& line);
@ -537,6 +538,35 @@ 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

@ -134,3 +134,120 @@ pxWindowTextWriter& pxWindowTextWriter::WriteLn( const wxChar* fmt, ... )
va_end(args);
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

@ -349,6 +349,12 @@ pxTextWrapper& pxTextWrapper::Wrap( const wxWindow& win, const wxString& text, i
return *this;
}
pxTextWrapper& pxTextWrapper::Wrap( const wxWindow* win, const wxString& text, int widthMax )
{
if( win ) _parent::Wrap( *win, text, widthMax );
return *this;
}
void pxTextWrapper::OnOutputLine(const wxString& line)
{
m_text += line;

View File

@ -74,7 +74,9 @@ FirstTimeWizard::UsermodePage::UsermodePage( wxWizard* parent ) :
m_panel_LangSel = new LanguageSelectionPanel( &panel );
m_panel_UserSel = new DocsFolderPickerPanel( &panel );
panel += panel.Heading(_("PCSX2 is starting from a new or unknown folder and needs to be configured."));
panel += new pxStaticTextImproved( this,
_("PCSX2 is starting from a new or unknown folder and needs to be configured.")
) | pxExpand;
panel += m_panel_LangSel | StdCenter();
panel += m_panel_UserSel | pxExpand.Border( wxALL, 8 );

View File

@ -25,17 +25,6 @@
using namespace pxSizerFlags;
namespace Panels
{
// Helper class since the 'AddPage' template system needs a single-parameter constructor.
class McdConfigPanel_Multitap2 : public McdConfigPanel_Multitap
{
public:
McdConfigPanel_Multitap2( wxWindow* parent ) : McdConfigPanel_Multitap( parent, 1 ) {}
virtual ~McdConfigPanel_Multitap2() throw() { }
};
}
wxString GetMsg_McdNtfsCompress()
{
return pxE( ".Panel:Mcd:NtfsCompress",
@ -109,55 +98,6 @@ void Panels::McdConfigPanel_Toggles::AppStatusEvent_OnSettingsApplied()
#endif
}
Panels::McdConfigPanel_Standard::McdConfigPanel_Standard(wxWindow *parent)
: _parent( parent )
{
m_panel_cardinfo[0] = new MemoryCardInfoPanel( this, 0 );
m_panel_cardinfo[1] = new MemoryCardInfoPanel( this, 1 );
for( uint port=0; port<2; ++port )
{
wxStaticBoxSizer& portSizer( *new wxStaticBoxSizer( wxVERTICAL, this, wxsFormat(_("Port %u"), port+1) ) );
portSizer += m_panel_cardinfo[port] | pxExpand;
*this += portSizer | StdExpand();
}
}
void Panels::McdConfigPanel_Standard::Apply()
{
}
void Panels::McdConfigPanel_Standard::AppStatusEvent_OnSettingsApplied()
{
}
Panels::McdConfigPanel_Multitap::McdConfigPanel_Multitap(wxWindow *parent, int port) : _parent( parent )
{
m_port = port;
m_check_Multitap = new pxCheckBox( this, wxsFormat(_("Enable Multitap on Port %u"), m_port+1) );
m_check_Multitap->SetFont( wxFont( m_check_Multitap->GetFont().GetPointSize()+1, wxFONTFAMILY_MODERN, wxNORMAL, wxNORMAL, false, L"Lucida Console" ) );
*this += m_check_Multitap;
Connect( m_check_Multitap->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(McdConfigPanel_Multitap::OnMultitapChecked));
}
void Panels::McdConfigPanel_Multitap::OnMultitapChecked( wxCommandEvent& evt )
{
}
void Panels::McdConfigPanel_Multitap::Apply()
{
}
void Panels::McdConfigPanel_Multitap::AppStatusEvent_OnSettingsApplied()
{
}
using namespace Panels;
using namespace pxSizerFlags;

View File

@ -411,8 +411,6 @@ namespace Panels
virtual bool ValidateEnumerationStatus();
};
class MemoryCardInfoPanel;
// --------------------------------------------------------------------------------------
// PluginSelectorPanel
// --------------------------------------------------------------------------------------

View File

@ -243,31 +243,6 @@ namespace Panels
virtual bool ValidateEnumerationStatus();
};
// --------------------------------------------------------------------------------------
// MemoryCardInfoPanel
// --------------------------------------------------------------------------------------
class MemoryCardInfoPanel : public BaseApplicableConfigPanel
{
protected:
//uint m_port;
uint m_slot;
wxString m_DisplayName;
wxString m_ErrorMessage;
ScopedPtr<McdListItem> m_cardInfo;
public:
virtual ~MemoryCardInfoPanel() throw() {}
MemoryCardInfoPanel( wxWindow* parent, uint slot );
void Apply();
void Eject();
protected:
void AppStatusEvent_OnSettingsApplied();
void paintEvent( wxPaintEvent& evt );
};
// --------------------------------------------------------------------------------------
// McdConfigPanel_Toggles / McdConfigPanel_Standard / McdConfigPanel_Multitap
// --------------------------------------------------------------------------------------
@ -293,40 +268,6 @@ namespace Panels
void OnMultitapClicked();
};
class McdConfigPanel_Standard : public BaseApplicableConfigPanel
{
typedef BaseApplicableConfigPanel _parent;
protected:
MemoryCardInfoPanel* m_panel_cardinfo[2];
public:
McdConfigPanel_Standard( wxWindow* parent );
virtual ~McdConfigPanel_Standard() throw() { }
void Apply();
protected:
void AppStatusEvent_OnSettingsApplied();
};
class McdConfigPanel_Multitap : public BaseApplicableConfigPanel
{
typedef BaseApplicableConfigPanel _parent;
protected:
int m_port;
pxCheckBox* m_check_Multitap;
public:
McdConfigPanel_Multitap( wxWindow* parent, int port=0 );
virtual ~McdConfigPanel_Multitap() throw() { }
void Apply();
protected:
void OnMultitapChecked( wxCommandEvent& evt );
void AppStatusEvent_OnSettingsApplied();
};
};
extern bool EnumerateMemoryCard( McdListItem& dest, const wxFileName& filename );

View File

@ -1,165 +0,0 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2010 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "ConfigurationPanels.h"
#include "MemoryCardPanels.h"
#include "Dialogs/ConfigurationDialog.h"
#include <wx/filepicker.h>
#include <wx/ffile.h>
#include <wx/dir.h>
using namespace pxSizerFlags;
using namespace Panels;
// =====================================================================================================
// MemoryCardInfoPanel (implementations)
// =====================================================================================================
MemoryCardInfoPanel::MemoryCardInfoPanel( wxWindow* parent, uint slot )
: BaseApplicableConfigPanel( parent, wxVERTICAL ) //, wxEmptyString )
{
m_slot = slot;
SetMinSize( wxSize(128, 48) );
Connect( wxEVT_PAINT, wxPaintEventHandler(MemoryCardInfoPanel::paintEvent) );
// [TODO] Add Unmount button.
}
void MemoryCardInfoPanel::paintEvent(wxPaintEvent & evt)
{
wxPaintDC dc( this );
pxWindowTextWriter writer( dc );
writer.Bold();
// Create DC and plot some text (and images!)
writer.WriteLn( m_DisplayName );
//dc.DrawCircle( dc.GetSize().GetWidth()/2, 24, dc.GetSize().GetWidth()/4 );
if( !m_ErrorMessage.IsEmpty() )
{
writer.WriteLn();
writer.WriteLn( m_ErrorMessage );
}
else if( m_cardInfo )
{
writer.Normal();
writer.WriteLn( wxsFormat( L"%d MB (%s)",
m_cardInfo->SizeInMB,
m_cardInfo->IsFormatted ? _("Formatted") : _("Unformatted") )
);
}
}
void MemoryCardInfoPanel::Eject()
{
m_cardInfo = NULL;
Refresh();
}
void MemoryCardInfoPanel::Apply()
{
if( m_cardInfo && m_cardInfo->Filename.GetFullName().IsEmpty() ) m_cardInfo = NULL;
if( m_cardInfo )
{
wxFileName absfile( Path::Combine( g_Conf->Folders.MemoryCards, m_cardInfo->Filename ) );
// The following checks should be theoretically unreachable, unless the user's
// filesystem is changed form under our nose. A little validation goes a
// long way. :p
if( absfile.IsDir() )
{
Eject();
throw Exception::CannotApplySettings( this,
// Diagnostic
wxsFormat( L"Memory card in slot %u conflicts with an existing directory.", m_slot ),
// Translated
wxsFormat(
_("Cannot use or create the memory card in slot %u: the filename conflicts with an existing directory."),
m_slot
)
);
}
if( !absfile.FileExists() )
{
Eject();
throw Exception::CannotApplySettings( this,
// Diagnostic
wxsFormat( L"Memory card in slot %u is no longer valid.", m_slot ),
// Translated
wxsFormat(
_("The configured memory card in slot %u no longer exists. Please create a new memory card, or leave the slot unmounted."),
m_slot
)
);
}
g_Conf->Mcd[m_slot].Filename = m_cardInfo->Filename;
g_Conf->Mcd[m_slot].Enabled = true;
}
else
{
// Card is either disabled or in an error state.
g_Conf->Mcd[m_slot].Enabled = false;
g_Conf->Mcd[m_slot].Filename.Clear();
}
}
void MemoryCardInfoPanel::AppStatusEvent_OnSettingsApplied()
{
m_cardInfo = NULL;
// Collect Info and Format Strings
wxString fname( g_Conf->Mcd[m_slot].Filename.GetFullPath() );
if( fname.IsEmpty() )
{
m_DisplayName = _("No Card (empty)");
m_cardInfo = NULL;
}
else
{
wxFileName absfile( Path::Combine( g_Conf->Folders.MemoryCards, fname ) );
wxFileName relfile( fname );
if( !m_cardInfo )
{
m_cardInfo = new McdListItem();
if( !EnumerateMemoryCard( *m_cardInfo, absfile.GetFullPath() ) )
{
m_ErrorMessage = _("Read Error: Card is truncated or corrupted.");
}
}
absfile.Normalize();
relfile.Normalize();
m_DisplayName = ( absfile == relfile ) ? relfile.GetFullName() : relfile.GetFullPath();
}
Refresh();
}

View File

@ -32,6 +32,8 @@ 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). "
@ -64,7 +66,7 @@ Panels::DocsFolderPickerPanel::DocsFolderPickerPanel( wxWindow* parent, bool isF
m_dirpicker_custom = new DirPickerPanel( this, FolderId_Documents, _("Select a document root for PCSX2") );
*this += Text( isFirstTime ? usermodeExplained : usermodeWarning );
*this += new pxStaticTextImproved( this, 3, isFirstTime ? usermodeExplained : usermodeWarning ) | pxExpand;
*this += m_radio_UserMode | StdExpand();
*this += m_dirpicker_custom | pxExpand.Border( wxLEFT, StdPadding + m_radio_UserMode->GetIndentation() );
*this += 4;

View File

@ -100,7 +100,8 @@ Panels::FramelimiterPanel::FramelimiterPanel( wxWindow* parent )
*this += 5;
*this += Heading( pxE( ".Panel:Framelimiter:Heading",
//*this += Heading( pxE( ".Panel:Framelimiter:Heading",
*this += new pxStaticTextImproved( 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." )
);

View File

@ -492,54 +492,6 @@
>
</File>
</Filter>
<Filter
Name="Linux"
>
<File
RelativePath="..\..\x86\aMicroVU.S"
>
</File>
<File
RelativePath="..\..\x86\ix86-32\aR5900-32.S"
>
</File>
<File
RelativePath="..\..\x86\aVif.S"
>
</File>
<File
RelativePath="..\..\x86\aVUzerorec.S"
>
</File>
<File
RelativePath="..\..\Linux\LnxHostSys.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Devel|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Ps2"
>
@ -2936,10 +2888,6 @@
RelativePath="..\..\gui\Panels\MemoryCardPanels.h"
>
</File>
<File
RelativePath="..\..\gui\Panels\MemoryCardsPanel.cpp"
>
</File>
</Filter>
</Filter>
</Filter>