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

Annotation of /trunk/common/include/Utilities/pxStaticText.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: 4301 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 "wxGuiTools.h"
19    
20     // --------------------------------------------------------------------------------------
21     // pxStaticText
22     // --------------------------------------------------------------------------------------
23     // This class's purpose is to overcome two fundamental annoyances in wxWidgets design:
24     //
25     // * An inability to wrap text to conform to a fitted window (a limitation imposed by
26     // wxWidgets inability to fit individual directions, ie fit widths and then fit heights,
27     // which would allow a textbox to wrap text to a sizer-determined width, and then grow
28 william 62 // the sizers vertically to fit the calculated text-wrapped height).
29 william 31 //
30     // * Textbox alignment requires aligning both the textbox contents, and aligning the text
31     // control within it's containing sizer. If both alignment flags do not match the result
32     // is typically undesirable.
33     //
34 william 62 class pxStaticText : public wxControl
35 william 31 {
36 william 62 typedef wxControl _parent;
37 william 31
38     protected:
39 william 62 wxString m_label;
40     wxString m_wrappedLabel;
41    
42     wxAlignment m_align;
43     bool m_autowrap;
44     int m_wrappedWidth;
45     int m_heightInLines;
46 william 31
47 william 62 int m_paddingPix_horiz;
48     int m_paddingPix_vert;
49     float m_paddingPct_horiz;
50     float m_paddingPct_vert;
51    
52     protected:
53     explicit pxStaticText( wxWindow* parent=NULL );
54    
55     // wxWindow overloads!
56     bool AcceptsFocus() const { return false; }
57     bool HasTransparentBackground() { return true; }
58     void DoSetSize(int x, int y, int w, int h, int sizeFlags = wxSIZE_AUTO);
59    
60 william 31 public:
61 william 62 pxStaticText( wxWindow* parent, const wxString& label, wxAlignment align=wxALIGN_CENTRE_HORIZONTAL );
62     pxStaticText( wxWindow* parent, int heightInLines, const wxString& label, wxAlignment align=wxALIGN_CENTRE_HORIZONTAL );
63 william 31 virtual ~pxStaticText() throw() {}
64    
65 william 62 wxFont GetFontOk() const;
66     bool Enable( bool enabled=true );
67 william 31
68 william 62 virtual void SetLabel(const wxString& label);
69     virtual wxString GetLabel() const { return m_label; }
70 william 31
71 william 62 pxStaticText& SetMinWidth( int width );
72     pxStaticText& SetMinHeight( int height );
73 william 31
74 william 62 pxStaticText& SetHeight( int lines );
75     pxStaticText& Align( wxAlignment align );
76     pxStaticText& Bold();
77     pxStaticText& WrapAt( int width );
78 william 31
79 william 62 pxStaticText& Unwrapped();
80    
81     pxStaticText& PaddingPixH( int pixels );
82     pxStaticText& PaddingPixV( int pixels );
83    
84     pxStaticText& PaddingPctH( float pct );
85     pxStaticText& PaddingPctV( float pct );
86     //pxStaticText& DoBestGuessHeight();
87    
88 william 31 protected:
89 william 62 void SetPaddingDefaults();
90     void Init( const wxString& label );
91    
92     wxSize GetBestWrappedSize( const wxClientDC& dc ) const;
93     wxSize DoGetBestSize() const;
94    
95     int calcPaddingWidth( int newWidth ) const;
96     int calcPaddingHeight( int newHeight ) const;
97    
98     void paintEvent(wxPaintEvent& evt);
99    
100     void UpdateWrapping( bool textChanged );
101     bool _updateWrapping( bool textChanged );
102 william 31 };
103    
104 william 62
105     class pxStaticHeading : public pxStaticText
106     {
107     typedef pxStaticText _parent;
108    
109     public:
110     pxStaticHeading( wxWindow* parent=NULL, const wxString& label=wxEmptyString );
111     pxStaticHeading( wxWindow* parent, int heightInLines, const wxString& label=wxEmptyString );
112     virtual ~pxStaticHeading() throw() {}
113    
114     protected:
115     void SetPaddingDefaults();
116     };
117    
118 william 31 extern void operator+=( wxSizer& target, pxStaticText* src );
119     extern void operator+=( wxSizer& target, pxStaticText& src );
120     extern void operator+=( wxSizer* target, pxStaticText& src );
121    
122     template<>
123     inline void operator+=( wxSizer& target, const pxWindowAndFlags<pxStaticText>& src )
124     {
125 william 62 target.Add( src.window, src.flags );
126 william 31 }
127    
128     template<>
129     inline void operator+=( wxSizer* target, const pxWindowAndFlags<pxStaticText>& src )
130     {
131 william 62 target->Add( src.window, src.flags );
132 william 31 }

  ViewVC Help
Powered by ViewVC 1.1.22