1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/stattext.mm
3 // Purpose: wxStaticText
4 // Author: Stefan Csomor
7 // RCS-ID: $Id: stattext.cpp 54845 2008-07-30 14:52:41Z SC $
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];
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