/[pcsx2_0.9.7]/trunk/common/include/Utilities/pxCheckBox.h
ViewVC logotype

Annotation of /trunk/common/include/Utilities/pxCheckBox.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62 - (hide annotations) (download)
Tue Sep 7 11:08:22 2010 UTC (9 years, 11 months ago) by william
File MIME type: text/plain
File size: 3541 byte(s)
Auto Commited Import of: pcsx2-0.9.7-r3738-debug in ./trunk
1 william 31 /* PCSX2 - PS2 Emulator for PCs
2     * Copyright (C) 2002-2010 PCSX2 Dev Team
3     *
4     * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5     * of the GNU Lesser General Public License as published by the Free Software Found-
6     * ation, either version 3 of the License, or (at your option) any later version.
7     *
8     * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9     * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10     * PURPOSE. See the GNU General Public License for more details.
11     *
12     * You should have received a copy of the GNU General Public License along with PCSX2.
13     * If not, see <http://www.gnu.org/licenses/>.
14     */
15    
16     #pragma once
17    
18     #include <wx/wx.h>
19     #include "wxGuiTools.h"
20    
21     // -------------------------------------------------------------------------------------
22     // pxCheckBox
23     // --------------------------------------------------------------------------------------
24     // The checkbox panel created uses the default spacer setting for adding checkboxes (see
25     // SizerFlags). The SetToolTip API provided by this function applies the tooltip to both
26     // both the checkbox and it's static subtext (if present), and performs word wrapping on
27     // platforms that need it (eg mswindows).
28     //
29     class pxCheckBox : public wxPanelWithHelpers
30     {
31     protected:
32     wxCheckBox* m_checkbox;
33     pxStaticText* m_subtext;
34    
35 william 62 // padding below the subtext (if there's subtext). If there's no subtext, this value is unused.
36     int m_subPadding;
37    
38     wxSizerItem* m_sizerItem_subtext;
39 william 31 public:
40 william 62 pxCheckBox( wxWindow* parent, const wxString& label, const wxString& subtext=wxEmptyString, int flags = wxCHK_2STATE );
41     pxCheckBox( wxWindow* parent, const wxString& label, int flags );
42 william 31 virtual ~pxCheckBox() throw() {}
43    
44     bool HasSubText() const { return m_subtext != NULL; }
45     const pxStaticText* GetSubText() const { return m_subtext; }
46    
47 william 62 pxCheckBox& SetSubPadding( int pad );
48 william 31 pxCheckBox& SetToolTip( const wxString& tip );
49     pxCheckBox& SetValue( bool val );
50 william 62 pxCheckBox& SetIndeterminate();
51     pxCheckBox& SetState( wxCheckBoxState state );
52 william 31
53 william 62 wxCheckBoxState GetState() const { pxAssume( m_checkbox != NULL ); return m_checkbox->Get3StateValue(); }
54     bool GetValue() const { pxAssume( m_checkbox != NULL ); return m_checkbox->GetValue(); }
55     bool IsChecked() const { pxAssume( m_checkbox != NULL ); return m_checkbox->IsChecked(); }
56     bool IsIndeterminate() const { pxAssume( m_checkbox != NULL ); return m_checkbox->Get3StateValue() == wxCHK_UNDETERMINED; }
57     operator wxCheckBox&() { pxAssume( m_checkbox != NULL ); return *m_checkbox; }
58     operator const wxCheckBox&() const { pxAssume( m_checkbox != NULL ); return *m_checkbox; }
59 william 31
60     wxCheckBox* GetWxPtr() { return m_checkbox; }
61     const wxCheckBox* GetWxPtr() const { return m_checkbox; }
62    
63     //wxWindowID GetId() const { pxAssert( m_checkbox != NULL ); return m_checkbox->GetId(); }
64    
65     protected:
66 william 62 void Init( const wxString& label, const wxString& subtext, int flags );
67 william 31 void OnCheckpartCommand( wxCommandEvent& evt );
68     void OnSubtextClicked( wxCommandEvent& evt );
69     };
70    
71     extern void operator+=( wxSizer& target, pxCheckBox* src );
72     extern void operator+=( wxSizer& target, pxCheckBox& src );
73     extern void operator+=( wxSizer* target, pxCheckBox& src );
74    
75     template<>
76     inline void operator+=( wxSizer& target, const pxWindowAndFlags<pxCheckBox>& src )
77     {
78     target.Add( src.window, src.flags );
79     }
80    
81     template<>
82     inline void operator+=( wxSizer* target, const pxWindowAndFlags<pxCheckBox>& src )
83     {
84     target->Add( src.window, src.flags );
85     }

  ViewVC Help
Powered by ViewVC 1.1.22