1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/stattext.mm
3 // Purpose: wxStaticText
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
16 #include "wx/stattext.h"
22 #include "wx/dcclient.h"
23 #include "wx/settings.h"
26 #include "wx/osx/private.h"
30 @interface wxUILabel : UILabel
35 @implementation wxUILabel
39 static BOOL initialized = NO;
43 wxOSXIPhoneClassAddWXMethods( self );
49 class wxStaticTextIPhoneImpl : public wxWidgetIPhoneImpl
52 wxStaticTextIPhoneImpl( wxWindowMac* peer , WXWidget w ) : wxWidgetIPhoneImpl(peer, w)
56 virtual void SetLabel(const wxString& title, wxFontEncoding encoding)
58 wxUILabel* v = (wxUILabel*)GetWXWidget();
59 wxCFStringRef text( title , encoding );
61 [v setText:text.AsNSString()];
66 wxSize wxStaticText::DoGetBestSize() const
68 return wxWindowMac::DoGetBestSize() ;
71 wxWidgetImplType* wxWidgetImpl::CreateStaticText( wxWindowMac* wxpeer,
72 wxWindowMac* WXUNUSED(parent),
73 wxWindowID WXUNUSED(id),
74 const wxString& WXUNUSED(label),
78 long WXUNUSED(extraStyle))
80 CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
81 wxUILabel* v = [[wxUILabel alloc] initWithFrame:r];
82 v.backgroundColor = [UIColor clearColor];
84 UILineBreakMode linebreak = UILineBreakModeWordWrap;
85 if ( ((wxStaticText*)wxpeer)->IsEllipsized() )
87 if ( style & wxST_ELLIPSIZE_MIDDLE )
88 linebreak = UILineBreakModeMiddleTruncation;
89 else if (style & wxST_ELLIPSIZE_END )
90 linebreak = UILineBreakModeTailTruncation;
91 else if (style & wxST_ELLIPSIZE_START )
92 linebreak = UILineBreakModeHeadTruncation;
94 [v setLineBreakMode:linebreak];
96 if (style & wxALIGN_CENTER)
97 [v setTextAlignment: UITextAlignmentCenter];
98 else if (style & wxALIGN_RIGHT)
99 [v setTextAlignment: UITextAlignmentRight];
101 wxWidgetIPhoneImpl* c = new wxStaticTextIPhoneImpl( wxpeer, v );
105 #endif //if wxUSE_STATTEXT