2009-11-16 00:40:09 +00:00
|
|
|
/* PCSX2 - PS2 Emulator for PCs
|
|
|
|
* Copyright (C) 2002-2009 PCSX2 Dev Team
|
|
|
|
*
|
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <wx/wx.h>
|
|
|
|
#include "SafeArray.h"
|
|
|
|
#include "wxGuiTools.h"
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// RadioPanelItem
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
struct RadioPanelItem
|
|
|
|
{
|
|
|
|
wxString Label;
|
|
|
|
wxString SubText;
|
|
|
|
wxString ToolTip;
|
|
|
|
|
|
|
|
RadioPanelItem( const wxString& label, const wxString& subtext=wxEmptyString, const wxString& tooltip=wxEmptyString )
|
|
|
|
: Label( label )
|
|
|
|
, SubText( subtext )
|
|
|
|
, ToolTip( tooltip )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
RadioPanelItem& SetToolTip( const wxString& tip )
|
|
|
|
{
|
|
|
|
ToolTip = tip;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
RadioPanelItem& SetSubText( const wxString& text )
|
|
|
|
{
|
|
|
|
SubText = text;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Used as a cache for the "original" labels and subtexts, so that text can be properly
|
|
|
|
// wrapped and re-wrapped with multiple calls to OnResize().
|
|
|
|
struct RadioPanelObjects
|
|
|
|
{
|
|
|
|
wxRadioButton* LabelObj;
|
|
|
|
wxStaticText* SubTextObj;
|
|
|
|
};
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// pxRadioPanel
|
|
|
|
// --------------------------------------------------------------------------------------
|
2009-11-19 05:08:24 +00:00
|
|
|
//
|
|
|
|
// Rationale:
|
2009-11-16 00:40:09 +00:00
|
|
|
// Radio buttons work best when they are created consecutively, and then their subtext
|
|
|
|
// created in a second sweep (this keeps the radio buttons together in the parent window's
|
|
|
|
// child list, and avoids potentially unwanted behavior with radio buttons failing to
|
|
|
|
// group expectedly). Because of this, our radio button helper is shaped as a panel of
|
2009-11-19 05:08:24 +00:00
|
|
|
// a group of radio buttons only, instead of bothering with the lower level per-button
|
2009-11-16 00:40:09 +00:00
|
|
|
// design. This makes a few other things nicer as well, such as binding a single message
|
|
|
|
// handler to all radio buttons in the panel.
|
|
|
|
//
|
|
|
|
class pxRadioPanel : public wxPanelWithHelpers
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
typedef std::vector<RadioPanelItem> ButtonArray;
|
|
|
|
typedef SafeArray<RadioPanelObjects> ButtonObjArray;
|
|
|
|
|
|
|
|
ButtonArray m_buttonStrings;
|
|
|
|
ButtonObjArray m_objects;
|
|
|
|
|
|
|
|
bool m_IsRealized;
|
|
|
|
|
|
|
|
wxSize m_padding;
|
|
|
|
int m_Indentation;
|
2009-11-25 03:54:57 +00:00
|
|
|
int m_DefaultIdx; // index of the default option (gets specific color/font treatment)
|
2009-11-16 00:40:09 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
template< int size >
|
2009-11-18 07:53:02 +00:00
|
|
|
pxRadioPanel( wxWindow* parent, const RadioPanelItem (&src)[size] )
|
|
|
|
: wxPanelWithHelpers( parent, wxVERTICAL )
|
2009-11-16 00:40:09 +00:00
|
|
|
{
|
|
|
|
Init( src, size );
|
|
|
|
}
|
|
|
|
|
2009-11-18 07:53:02 +00:00
|
|
|
pxRadioPanel( wxWindow* parent )
|
|
|
|
: wxPanelWithHelpers( parent, wxVERTICAL )
|
2009-11-16 00:40:09 +00:00
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~pxRadioPanel() throw() {}
|
|
|
|
|
|
|
|
void Reset();
|
|
|
|
void Realize();
|
|
|
|
|
|
|
|
wxStaticText* GetSubText( int idx );
|
|
|
|
const wxStaticText* GetSubText( int idx ) const;
|
|
|
|
pxRadioPanel& Append( const RadioPanelItem& entry );
|
|
|
|
|
|
|
|
pxRadioPanel& SetToolTip( int idx, const wxString& tip );
|
|
|
|
pxRadioPanel& SetSelection( int idx );
|
2009-12-14 12:18:55 +00:00
|
|
|
pxRadioPanel& SetDefaultItem( int idx );
|
|
|
|
pxRadioPanel& EnableItem( int idx, bool enable=true );
|
2009-11-16 00:40:09 +00:00
|
|
|
|
|
|
|
int GetSelection() const;
|
|
|
|
wxWindowID GetSelectionId() const;
|
|
|
|
bool IsSelected( int idx ) const;
|
|
|
|
|
|
|
|
wxRadioButton* GetButton( int idx );
|
|
|
|
const wxRadioButton* GetButton( int idx ) const;
|
|
|
|
|
2010-03-05 14:24:44 +00:00
|
|
|
int GetPaddingVert() const { return m_padding.GetHeight(); }
|
2009-11-16 00:40:09 +00:00
|
|
|
int GetIndentation() const { return m_Indentation; }
|
|
|
|
|
|
|
|
pxRadioPanel& SetPaddingHoriz( int newpad )
|
|
|
|
{
|
|
|
|
m_padding.SetHeight( newpad );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxRadioPanel& SetIndentation( int newdent )
|
|
|
|
{
|
|
|
|
m_Indentation = newdent;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HasSubText( int idx ) const
|
|
|
|
{
|
|
|
|
return !m_buttonStrings[idx].SubText.IsEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
pxRadioPanel& Append( const wxString& label, const wxString& subtext=wxEmptyString, const wxString& tooltip=wxEmptyString )
|
|
|
|
{
|
|
|
|
return Append( RadioPanelItem(label, subtext, tooltip) );
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void Init( const RadioPanelItem* srcArray=NULL, int arrsize=0 );
|
|
|
|
void _setToolTipImmediate( int idx, const wxString &tip );
|
2009-11-25 03:54:57 +00:00
|
|
|
void _RealizeDefaultOption();
|
2009-11-16 00:40:09 +00:00
|
|
|
};
|