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 SetFont( const wxFont & font , const wxColour& WXUNUSED(foreground) , long WXUNUSED(windowStyle), bool WXUNUSED(ignoreBlack) )
57 wxUILabel* v = (wxUILabel*)GetWXWidget();
58 [v setFont: font.OSXGetUIFont()];
61 virtual void SetLabel(const wxString& title, wxFontEncoding encoding)
63 wxUILabel* v = (wxUILabel*)GetWXWidget();
64 wxCFStringRef text( title , encoding );
66 [v setText:text.AsNSString()];
71 wxSize wxStaticText::DoGetBestSize() const
73 return wxWindowMac::DoGetBestSize() ;
76 wxWidgetImplType* wxWidgetImpl::CreateStaticText( wxWindowMac* wxpeer,
77 wxWindowMac* WXUNUSED(parent),
78 wxWindowID WXUNUSED(id),
79 const wxString& WXUNUSED(label),
83 long WXUNUSED(extraStyle))
85 CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
86 wxUILabel* v = [[wxUILabel alloc] initWithFrame:r];
87 v.backgroundColor = [UIColor clearColor];
89 UILineBreakMode linebreak = UILineBreakModeWordWrap;
90 if ( ((wxStaticText*)wxpeer)->IsEllipsized() )
92 if ( style & wxST_ELLIPSIZE_MIDDLE )
93 linebreak = UILineBreakModeMiddleTruncation;
94 else if (style & wxST_ELLIPSIZE_END )
95 linebreak = UILineBreakModeTailTruncation;
96 else if (style & wxST_ELLIPSIZE_START )
97 linebreak = UILineBreakModeHeadTruncation;
99 [v setLineBreakMode:linebreak];
101 if (style & wxALIGN_CENTER)
102 [v setTextAlignment: UITextAlignmentCenter];
103 else if (style & wxALIGN_RIGHT)
104 [v setTextAlignment: UITextAlignmentRight];
106 wxWidgetIPhoneImpl* c = new wxStaticTextIPhoneImpl( wxpeer, v );
110 #endif //if wxUSE_STATTEXT