]> git.saurik.com Git - wxWidgets.git/blame - src/osx/iphone/stattext.mm
Reuse wxMessageOutputStderr for wxLogStderr implementation.
[wxWidgets.git] / src / osx / iphone / stattext.mm
CommitLineData
d09d7f11 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/osx/iphone/stattext.mm
d09d7f11
SC
3// Purpose: wxStaticText
4// Author: Stefan Csomor
5// Modified by:
6// Created: 04/01/98
a9a4f229 7// RCS-ID: $Id$
d09d7f11
SC
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#if wxUSE_STATTEXT
15
16#include "wx/stattext.h"
17
18#ifndef WX_PRECOMP
19 #include "wx/app.h"
20 #include "wx/utils.h"
21 #include "wx/dc.h"
22 #include "wx/dcclient.h"
23 #include "wx/settings.h"
24#endif // WX_PRECOMP
25
26#include "wx/osx/private.h"
27
28#include <stdio.h>
29
30@interface wxUILabel : UILabel
31{
32}
33@end
34
35@implementation wxUILabel
36
37+ (void)initialize
38{
39 static BOOL initialized = NO;
40 if (!initialized)
41 {
42 initialized = YES;
43 wxOSXIPhoneClassAddWXMethods( self );
44 }
45}
46
47@end
48
49class wxStaticTextIPhoneImpl : public wxWidgetIPhoneImpl
50{
51public:
52 wxStaticTextIPhoneImpl( wxWindowMac* peer , WXWidget w ) : wxWidgetIPhoneImpl(peer, w)
53 {
54 }
55
56 virtual void SetLabel(const wxString& title, wxFontEncoding encoding)
57 {
58 wxUILabel* v = (wxUILabel*)GetWXWidget();
59 wxCFStringRef text( title , encoding );
60
61 [v setText:text.AsNSString()];
62 }
63private :
64};
65
66wxSize wxStaticText::DoGetBestSize() const
67{
68 return wxWindowMac::DoGetBestSize() ;
69}
70
71wxWidgetImplType* wxWidgetImpl::CreateStaticText( wxWindowMac* wxpeer,
72 wxWindowMac* WXUNUSED(parent),
73 wxWindowID WXUNUSED(id),
74 const wxString& WXUNUSED(label),
75 const wxPoint& pos,
76 const wxSize& size,
77 long style,
78 long WXUNUSED(extraStyle))
79{
80 CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
81 wxUILabel* v = [[wxUILabel alloc] initWithFrame:r];
ca12c122
SC
82 v.backgroundColor = [UIColor clearColor];
83
d09d7f11
SC
84 UILineBreakMode linebreak = UILineBreakModeWordWrap;
85 if ( ((wxStaticText*)wxpeer)->IsEllipsized() )
86 {
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;
93 }
94 [v setLineBreakMode:linebreak];
95
96 if (style & wxALIGN_CENTER)
97 [v setTextAlignment: UITextAlignmentCenter];
98 else if (style & wxALIGN_RIGHT)
99 [v setTextAlignment: UITextAlignmentRight];
100
101 wxWidgetIPhoneImpl* c = new wxStaticTextIPhoneImpl( wxpeer, v );
102 return c;
103}
104
105#endif //if wxUSE_STATTEXT