]> git.saurik.com Git - wxWidgets.git/blob - src/osx/iphone/stattext.mm
Preserve wxSlider value when changing its range in wxOSX too.
[wxWidgets.git] / src / osx / iphone / stattext.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/stattext.mm
3 // Purpose: wxStaticText
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id: stattext.cpp 54845 2008-07-30 14:52:41Z SC $
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #if wxUSE_STATTEXT
15
16 #include "wx/stattext.h"
17
18 #ifndef WX_PRECOMP
19 #include "wx/app.h"
20 #include "wx/utils.h"
21 #include "wx/dc.h"
22 #include "wx/dcclient.h"
23 #include "wx/settings.h"
24 #endif // WX_PRECOMP
25
26 #include "wx/osx/private.h"
27
28 #include <stdio.h>
29
30 @interface wxUILabel : UILabel
31 {
32 }
33 @end
34
35 @implementation wxUILabel
36
37 + (void)initialize
38 {
39 static BOOL initialized = NO;
40 if (!initialized)
41 {
42 initialized = YES;
43 wxOSXIPhoneClassAddWXMethods( self );
44 }
45 }
46
47 @end
48
49 class wxStaticTextIPhoneImpl : public wxWidgetIPhoneImpl
50 {
51 public:
52 wxStaticTextIPhoneImpl( wxWindowMac* peer , WXWidget w ) : wxWidgetIPhoneImpl(peer, w)
53 {
54 }
55
56 virtual void SetLabel(const wxString& title, wxFontEncoding encoding)
57 {
58 wxUILabel* v = (wxUILabel*)GetWXWidget();
59 wxCFStringRef text( title , encoding );
60
61 [v setText:text.AsNSString()];
62 }
63 private :
64 };
65
66 wxSize wxStaticText::DoGetBestSize() const
67 {
68 return wxWindowMac::DoGetBestSize() ;
69 }
70
71 wxWidgetImplType* wxWidgetImpl::CreateStaticText( wxWindowMac* wxpeer,
72 wxWindowMac* WXUNUSED(parent),
73 wxWindowID WXUNUSED(id),
74 const wxString& WXUNUSED(label),
75 const wxPoint& pos,
76 const wxSize& size,
77 long style,
78 long WXUNUSED(extraStyle))
79 {
80 CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
81 wxUILabel* v = [[wxUILabel alloc] initWithFrame:r];
82
83 UILineBreakMode linebreak = UILineBreakModeWordWrap;
84 if ( ((wxStaticText*)wxpeer)->IsEllipsized() )
85 {
86 if ( style & wxST_ELLIPSIZE_MIDDLE )
87 linebreak = UILineBreakModeMiddleTruncation;
88 else if (style & wxST_ELLIPSIZE_END )
89 linebreak = UILineBreakModeTailTruncation;
90 else if (style & wxST_ELLIPSIZE_START )
91 linebreak = UILineBreakModeHeadTruncation;
92 }
93 [v setLineBreakMode:linebreak];
94
95 if (style & wxALIGN_CENTER)
96 [v setTextAlignment: UITextAlignmentCenter];
97 else if (style & wxALIGN_RIGHT)
98 [v setTextAlignment: UITextAlignmentRight];
99
100 wxWidgetIPhoneImpl* c = new wxStaticTextIPhoneImpl( wxpeer, v );
101 return c;
102 }
103
104 #endif //if wxUSE_STATTEXT