]> git.saurik.com Git - wxWidgets.git/blame - src/osx/iphone/stattext.mm
wxMessageBox off the main thread lost result code.
[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
d09d7f11
SC
7// Copyright: (c) Stefan Csomor
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#include "wx/wxprec.h"
12
13#if wxUSE_STATTEXT
14
15#include "wx/stattext.h"
16
17#ifndef WX_PRECOMP
18 #include "wx/app.h"
19 #include "wx/utils.h"
20 #include "wx/dc.h"
21 #include "wx/dcclient.h"
22 #include "wx/settings.h"
23#endif // WX_PRECOMP
24
25#include "wx/osx/private.h"
26
27#include <stdio.h>
28
29@interface wxUILabel : UILabel
30{
31}
32@end
33
34@implementation wxUILabel
35
36+ (void)initialize
37{
38 static BOOL initialized = NO;
39 if (!initialized)
40 {
41 initialized = YES;
42 wxOSXIPhoneClassAddWXMethods( self );
43 }
44}
45
46@end
47
48class wxStaticTextIPhoneImpl : public wxWidgetIPhoneImpl
49{
50public:
51 wxStaticTextIPhoneImpl( wxWindowMac* peer , WXWidget w ) : wxWidgetIPhoneImpl(peer, w)
52 {
53 }
54
e4097f77
JF
55 virtual void SetFont( const wxFont & font , const wxColour& WXUNUSED(foreground) , long WXUNUSED(windowStyle), bool WXUNUSED(ignoreBlack) )
56 {
57 wxUILabel* v = (wxUILabel*)GetWXWidget();
58 [v setFont: font.OSXGetUIFont()];
59 }
60
d09d7f11
SC
61 virtual void SetLabel(const wxString& title, wxFontEncoding encoding)
62 {
63 wxUILabel* v = (wxUILabel*)GetWXWidget();
64 wxCFStringRef text( title , encoding );
65
66 [v setText:text.AsNSString()];
67 }
68private :
69};
70
71wxSize wxStaticText::DoGetBestSize() const
72{
73 return wxWindowMac::DoGetBestSize() ;
74}
75
76wxWidgetImplType* wxWidgetImpl::CreateStaticText( wxWindowMac* wxpeer,
77 wxWindowMac* WXUNUSED(parent),
78 wxWindowID WXUNUSED(id),
79 const wxString& WXUNUSED(label),
80 const wxPoint& pos,
81 const wxSize& size,
82 long style,
83 long WXUNUSED(extraStyle))
84{
85 CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
86 wxUILabel* v = [[wxUILabel alloc] initWithFrame:r];
ca12c122
SC
87 v.backgroundColor = [UIColor clearColor];
88
d09d7f11
SC
89 UILineBreakMode linebreak = UILineBreakModeWordWrap;
90 if ( ((wxStaticText*)wxpeer)->IsEllipsized() )
91 {
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;
98 }
84ce7b7d 99 [v setNumberOfLines:0];
d09d7f11
SC
100 [v setLineBreakMode:linebreak];
101
102 if (style & wxALIGN_CENTER)
103 [v setTextAlignment: UITextAlignmentCenter];
104 else if (style & wxALIGN_RIGHT)
105 [v setTextAlignment: UITextAlignmentRight];
106
107 wxWidgetIPhoneImpl* c = new wxStaticTextIPhoneImpl( wxpeer, v );
108 return c;
109}
110
111#endif //if wxUSE_STATTEXT