1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cocoa/stattext.mm
3 // Purpose: wxStaticText
4 // Author: David Elliott
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWidgets licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
15 #include "wx/stattext.h"
18 #include "wx/cocoa/autorelease.h"
19 #include "wx/cocoa/string.h"
21 #import <Foundation/NSString.h>
22 #import <AppKit/NSTextField.h>
25 IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
26 BEGIN_EVENT_TABLE(wxStaticText, wxControl)
28 WX_IMPLEMENT_COCOA_OWNER(wxStaticText,NSTextField,NSControl,NSView)
30 bool wxStaticText::Create(wxWindow *parent, wxWindowID winid,
31 const wxString& label,
37 wxAutoNSAutoreleasePool pool;
38 if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
41 SetNSTextField([[NSTextField alloc] initWithFrame:MakeDefaultNSRect(size)]);
42 [m_cocoaNSView release];
43 [GetNSTextField() setStringValue:wxNSStringWithWxString(label)];
44 // [GetNSTextField() setBordered: NO];
45 [GetNSTextField() setBezeled: NO];
46 [GetNSTextField() setEditable: NO];
47 [GetNSTextField() setDrawsBackground: NO];
49 [GetNSControl() sizeToFit];
50 // Round-up to next integer size
51 NSRect nsrect = [m_cocoaNSView frame];
52 nsrect.size.width = ceil(nsrect.size.width);
53 [m_cocoaNSView setFrameSize: nsrect.size];
56 m_parent->CocoaAddChild(this);
57 SetInitialFrameRect(pos,size);
62 wxStaticText::~wxStaticText()
64 DisassociateNSTextField(GetNSTextField());
67 void wxStaticText::SetLabel(const wxString& label)
72 void wxStaticText::Cocoa_didChangeText(void)