]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/stattext.mm
unicode compilation fix
[wxWidgets.git] / src / cocoa / stattext.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cocoa/stattext.mm
3 // Purpose: wxStaticText
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2003/02/15
7 // RCS-ID: $Id:
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/app.h"
13 #include "wx/stattext.h"
14
15 #include "wx/cocoa/autorelease.h"
16
17 #import <Foundation/NSString.h>
18 #import <AppKit/NSTextField.h>
19 #include <math.h>
20
21 IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
22 BEGIN_EVENT_TABLE(wxStaticText, wxControl)
23 END_EVENT_TABLE()
24 WX_IMPLEMENT_COCOA_OWNER(wxStaticText,NSTextField,NSControl,NSView)
25
26 bool wxStaticText::Create(wxWindow *parent, wxWindowID winid,
27 const wxString& label,
28 const wxPoint& pos,
29 const wxSize& size,
30 long style,
31 const wxString& name)
32 {
33 wxAutoNSAutoreleasePool pool;
34 if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
35 return false;
36 m_cocoaNSView = NULL;
37 SetNSTextField([[NSTextField alloc] initWithFrame:MakeDefaultNSRect(size)]);
38 [m_cocoaNSView release];
39 [GetNSTextField() setStringValue:[NSString stringWithCString:label.c_str()]];
40 // [GetNSTextField() setBordered: NO];
41 [GetNSTextField() setBezeled: NO];
42 [GetNSTextField() setEditable: NO];
43 [GetNSTextField() setDrawsBackground: NO];
44
45 [GetNSControl() sizeToFit];
46 // Round-up to next integer size
47 NSRect nsrect = [m_cocoaNSView frame];
48 nsrect.size.width = ceil(nsrect.size.width);
49 [m_cocoaNSView setFrameSize: nsrect.size];
50
51 if(m_parent)
52 m_parent->CocoaAddChild(this);
53 SetInitialFrameRect(pos,size);
54
55 return true;
56 }
57
58 wxStaticText::~wxStaticText()
59 {
60 DisassociateNSTextField(m_cocoaNSView);
61 }
62
63 void wxStaticText::SetLabel(const wxString& label)
64 {
65 // TODO
66 }
67
68 void wxStaticText::Cocoa_didChangeText(void)
69 {
70 }
71