2009-09-08 12:08:10 +00:00
|
|
|
/* PCSX2 - PS2 Emulator for PCs
|
2010-05-03 14:08:02 +00:00
|
|
|
* Copyright (C) 2002-2010 PCSX2 Dev Team
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* 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.
|
2009-08-20 14:34:48 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* 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.
|
2009-08-20 14:34:48 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
2009-08-20 14:34:48 +00:00
|
|
|
*/
|
|
|
|
|
2009-07-07 20:53:32 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <wx/wx.h>
|
2009-11-18 07:53:02 +00:00
|
|
|
#include "wxGuiTools.h"
|
2009-07-11 08:31:38 +00:00
|
|
|
|
2009-11-18 07:53:02 +00:00
|
|
|
// -------------------------------------------------------------------------------------
|
2009-11-10 17:53:22 +00:00
|
|
|
// pxCheckBox
|
|
|
|
// --------------------------------------------------------------------------------------
|
2009-11-14 08:36:57 +00:00
|
|
|
// The checkbox panel created uses the default spacer setting for adding checkboxes (see
|
|
|
|
// SizerFlags). The SetToolTip API provided by this function applies the tooltip to both
|
|
|
|
// both the checkbox and it's static subtext (if present), and performs word wrapping on
|
|
|
|
// platforms that need it (eg mswindows).
|
|
|
|
//
|
2009-11-18 07:53:02 +00:00
|
|
|
class pxCheckBox : public wxPanelWithHelpers
|
2009-11-10 17:53:22 +00:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
wxCheckBox* m_checkbox;
|
2009-11-18 07:53:02 +00:00
|
|
|
pxStaticText* m_subtext;
|
2009-11-10 17:53:22 +00:00
|
|
|
|
2010-06-05 14:25:41 +00:00
|
|
|
// padding below the subtext (if there's subtext). If there's no subtext, this value is unused.
|
|
|
|
int m_subPadding;
|
|
|
|
|
|
|
|
wxSizerItem* m_sizerItem_subtext;
|
2009-11-10 17:53:22 +00:00
|
|
|
public:
|
2010-06-18 02:44:27 +00:00
|
|
|
pxCheckBox( wxWindow* parent, const wxString& label, const wxString& subtext=wxEmptyString, int flags = wxCHK_2STATE );
|
|
|
|
pxCheckBox( wxWindow* parent, const wxString& label, int flags );
|
2009-11-10 17:53:22 +00:00
|
|
|
virtual ~pxCheckBox() throw() {}
|
|
|
|
|
|
|
|
bool HasSubText() const { return m_subtext != NULL; }
|
2009-11-18 07:53:02 +00:00
|
|
|
const pxStaticText* GetSubText() const { return m_subtext; }
|
2009-11-10 17:53:22 +00:00
|
|
|
|
2010-06-05 14:25:41 +00:00
|
|
|
pxCheckBox& SetSubPadding( int pad );
|
2009-11-10 17:53:22 +00:00
|
|
|
pxCheckBox& SetToolTip( const wxString& tip );
|
2009-11-11 11:36:13 +00:00
|
|
|
pxCheckBox& SetValue( bool val );
|
2010-06-18 02:44:27 +00:00
|
|
|
pxCheckBox& SetIndeterminate();
|
|
|
|
pxCheckBox& SetState( wxCheckBoxState state );
|
2009-11-10 17:53:22 +00:00
|
|
|
|
2010-06-18 02:44:27 +00:00
|
|
|
wxCheckBoxState GetState() const { pxAssume( m_checkbox != NULL ); return m_checkbox->Get3StateValue(); }
|
|
|
|
bool GetValue() const { pxAssume( m_checkbox != NULL ); return m_checkbox->GetValue(); }
|
|
|
|
bool IsChecked() const { pxAssume( m_checkbox != NULL ); return m_checkbox->IsChecked(); }
|
|
|
|
bool IsIndeterminate() const { pxAssume( m_checkbox != NULL ); return m_checkbox->Get3StateValue() == wxCHK_UNDETERMINED; }
|
|
|
|
operator wxCheckBox&() { pxAssume( m_checkbox != NULL ); return *m_checkbox; }
|
|
|
|
operator const wxCheckBox&() const { pxAssume( m_checkbox != NULL ); return *m_checkbox; }
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-11-11 11:36:13 +00:00
|
|
|
wxCheckBox* GetWxPtr() { return m_checkbox; }
|
|
|
|
const wxCheckBox* GetWxPtr() const { return m_checkbox; }
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-05-25 02:08:17 +00:00
|
|
|
//wxWindowID GetId() const { pxAssert( m_checkbox != NULL ); return m_checkbox->GetId(); }
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-11-14 08:36:57 +00:00
|
|
|
protected:
|
2010-06-18 02:44:27 +00:00
|
|
|
void Init( const wxString& label, const wxString& subtext, int flags );
|
2010-05-25 02:08:17 +00:00
|
|
|
void OnCheckpartCommand( wxCommandEvent& evt );
|
|
|
|
void OnSubtextClicked( wxCommandEvent& evt );
|
2009-11-10 17:53:22 +00:00
|
|
|
};
|
2009-11-19 05:08:24 +00:00
|
|
|
|
2009-11-19 13:44:44 +00:00
|
|
|
extern void operator+=( wxSizer& target, pxCheckBox* src );
|
2009-11-25 03:54:57 +00:00
|
|
|
extern void operator+=( wxSizer& target, pxCheckBox& src );
|
2009-12-14 12:18:55 +00:00
|
|
|
extern void operator+=( wxSizer* target, pxCheckBox& src );
|
2009-11-19 05:08:24 +00:00
|
|
|
|
|
|
|
template<>
|
2009-11-19 14:21:26 +00:00
|
|
|
inline void operator+=( wxSizer& target, const pxWindowAndFlags<pxCheckBox>& src )
|
2009-11-19 05:08:24 +00:00
|
|
|
{
|
|
|
|
target.Add( src.window, src.flags );
|
|
|
|
}
|
2009-12-14 12:18:55 +00:00
|
|
|
|
|
|
|
template<>
|
|
|
|
inline void operator+=( wxSizer* target, const pxWindowAndFlags<pxCheckBox>& src )
|
|
|
|
{
|
|
|
|
target->Add( src.window, src.flags );
|
|
|
|
}
|