1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cocoa/stattext.mm
3 // Purpose: wxStaticText
4 // Author: David Elliott
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
15 #include "wx/stattext.h"
18 #include "wx/cocoa/autorelease.h"
20 #import <Foundation/NSString.h>
21 #import <AppKit/NSTextField.h>
24 IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
25 BEGIN_EVENT_TABLE(wxStaticText, wxControl)
27 WX_IMPLEMENT_COCOA_OWNER(wxStaticText,NSTextField,NSControl,NSView)
29 bool wxStaticText::Create(wxWindow *parent, wxWindowID winid,
30 const wxString& label,
36 wxAutoNSAutoreleasePool pool;
37 if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
40 SetNSTextField([[NSTextField alloc] initWithFrame:MakeDefaultNSRect(size)]);
41 [m_cocoaNSView release];
42 [GetNSTextField() setStringValue:[NSString stringWithCString:label.c_str()]];
43 // [GetNSTextField() setBordered: NO];
44 [GetNSTextField() setBezeled: NO];
45 [GetNSTextField() setEditable: NO];
46 [GetNSTextField() setDrawsBackground: NO];
48 [GetNSControl() sizeToFit];
49 // Round-up to next integer size
50 NSRect nsrect = [m_cocoaNSView frame];
51 nsrect.size.width = ceil(nsrect.size.width);
52 [m_cocoaNSView setFrameSize: nsrect.size];
55 m_parent->CocoaAddChild(this);
56 SetInitialFrameRect(pos,size);
61 wxStaticText::~wxStaticText()
63 DisassociateNSTextField(GetNSTextField());
66 void wxStaticText::SetLabel(const wxString& label)
71 void wxStaticText::Cocoa_didChangeText(void)