]> git.saurik.com Git - wxWidgets.git/blob - src/osx/iphone/stattext.mm
avoid setting initial position if it was not specified, broken in r70734
[wxWidgets.git] / src / osx / iphone / stattext.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/iphone/stattext.mm
3 // Purpose: wxStaticText
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 04/01/98
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #include "wx/wxprec.h"
12
13 #if wxUSE_STATTEXT
14
15 #include "wx/stattext.h"
16
17 #ifndef WX_PRECOMP
18 #include "wx/app.h"
19 #include "wx/utils.h"
20 #include "wx/dc.h"
21 #include "wx/dcclient.h"
22 #include "wx/settings.h"
23 #endif // WX_PRECOMP
24
25 #include "wx/osx/private.h"
26
27 #include <stdio.h>
28
29 @interface wxUILabel : UILabel
30 {
31 }
32 @end
33
34 @implementation wxUILabel
35
36 + (void)initialize
37 {
38 static BOOL initialized = NO;
39 if (!initialized)
40 {
41 initialized = YES;
42 wxOSXIPhoneClassAddWXMethods( self );
43 }
44 }
45
46 @end
47
48 class wxStaticTextIPhoneImpl : public wxWidgetIPhoneImpl
49 {
50 public:
51 wxStaticTextIPhoneImpl( wxWindowMac* peer , WXWidget w ) : wxWidgetIPhoneImpl(peer, w)
52 {
53 }
54
55 virtual void SetLabel(const wxString& title, wxFontEncoding encoding)
56 {
57 wxUILabel* v = (wxUILabel*)GetWXWidget();
58 wxCFStringRef text( title , encoding );
59
60 [v setText:text.AsNSString()];
61 }
62 private :
63 };
64
65 wxSize wxStaticText::DoGetBestSize() const
66 {
67 return wxWindowMac::DoGetBestSize() ;
68 }
69
70 wxWidgetImplType* wxWidgetImpl::CreateStaticText( wxWindowMac* wxpeer,
71 wxWindowMac* WXUNUSED(parent),
72 wxWindowID WXUNUSED(id),
73 const wxString& WXUNUSED(label),
74 const wxPoint& pos,
75 const wxSize& size,
76 long style,
77 long WXUNUSED(extraStyle))
78 {
79 CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
80 wxUILabel* v = [[wxUILabel alloc] initWithFrame:r];
81 v.backgroundColor = [UIColor clearColor];
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