1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cocoa/stattext.mm
3 // Purpose: wxStaticText
4 // Author: David Elliott
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #include "wx/stattext.h"
15 #include "wx/cocoa/autorelease.h"
17 #import <Foundation/NSString.h>
18 #import <AppKit/NSTextField.h>
21 IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
22 BEGIN_EVENT_TABLE(wxStaticText, wxControl)
24 WX_IMPLEMENT_COCOA_OWNER(wxStaticText,NSTextField,NSControl,NSView)
26 bool wxStaticText::Create(wxWindow *parent, wxWindowID winid,
27 const wxString& label,
33 wxAutoNSAutoreleasePool pool;
34 if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
37 SetNSTextField([[NSTextField alloc] initWithFrame:NSMakeRect(0,0,30,30)]);
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];
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];
52 m_parent->CocoaAddChild(this);
56 wxStaticText::~wxStaticText()
58 DisassociateNSTextField(m_cocoaNSView);
61 void wxStaticText::SetLabel(const wxString& label)
66 void wxStaticText::Cocoa_didChangeText(void)