1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/iphone/stattext.mm
3 // Purpose: wxStaticText
4 // Author: Stefan Csomor
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #include "wx/wxprec.h"
15 #include "wx/stattext.h"
21 #include "wx/dcclient.h"
22 #include "wx/settings.h"
25 #include "wx/osx/private.h"
29 @interface wxUILabel : UILabel
34 @implementation wxUILabel
38 static BOOL initialized = NO;
42 wxOSXIPhoneClassAddWXMethods( self );
48 class wxStaticTextIPhoneImpl : public wxWidgetIPhoneImpl
51 wxStaticTextIPhoneImpl( wxWindowMac* peer , WXWidget w ) : wxWidgetIPhoneImpl(peer, w)
55 virtual void SetLabel(const wxString& title, wxFontEncoding encoding)
57 wxUILabel* v = (wxUILabel*)GetWXWidget();
58 wxCFStringRef text( title , encoding );
60 [v setText:text.AsNSString()];
65 wxSize wxStaticText::DoGetBestSize() const
67 return wxWindowMac::DoGetBestSize() ;
70 wxWidgetImplType* wxWidgetImpl::CreateStaticText( wxWindowMac* wxpeer,
71 wxWindowMac* WXUNUSED(parent),
72 wxWindowID WXUNUSED(id),
73 const wxString& WXUNUSED(label),
77 long WXUNUSED(extraStyle))
79 CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
80 wxUILabel* v = [[wxUILabel alloc] initWithFrame:r];
81 v.backgroundColor = [UIColor clearColor];
83 UILineBreakMode linebreak = UILineBreakModeWordWrap;
84 if ( ((wxStaticText*)wxpeer)->IsEllipsized() )
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;
93 [v setLineBreakMode:linebreak];
95 if (style & wxALIGN_CENTER)
96 [v setTextAlignment: UITextAlignmentCenter];
97 else if (style & wxALIGN_RIGHT)
98 [v setTextAlignment: UITextAlignmentRight];
100 wxWidgetIPhoneImpl* c = new wxStaticTextIPhoneImpl( wxpeer, v );
104 #endif //if wxUSE_STATTEXT