]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/stattext.mm
Should return wxImage not bool
[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: wxWidgets licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13 #ifndef WX_PRECOMP
14 #include "wx/app.h"
15 #include "wx/stattext.h"
16 #endif //WX_PRECOMP
17
18 #include "wx/cocoa/autorelease.h"
19 #include "wx/cocoa/string.h"
20
21 #import <Foundation/NSString.h>
22 #import <AppKit/NSTextField.h>
23 #include <math.h>
24
25 IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
26 BEGIN_EVENT_TABLE(wxStaticText, wxControl)
27 END_EVENT_TABLE()
28 WX_IMPLEMENT_COCOA_OWNER(wxStaticText,NSTextField,NSControl,NSView)
29
30 bool wxStaticText::Create(wxWindow *parent, wxWindowID winid,
31 const wxString& label,
32 const wxPoint& pos,
33 const wxSize& size,
34 long style,
35 const wxString& name)
36 {
37 wxAutoNSAutoreleasePool pool;
38 if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
39 return false;
40 m_cocoaNSView = NULL;
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];
48
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];
54
55 if(m_parent)
56 m_parent->CocoaAddChild(this);
57 SetInitialFrameRect(pos,size);
58
59 return true;
60 }
61
62 wxStaticText::~wxStaticText()
63 {
64 DisassociateNSTextField(GetNSTextField());
65 }
66
67 void wxStaticText::SetLabel(const wxString& label)
68 {
69 // TODO
70 }
71
72 void wxStaticText::Cocoa_didChangeText(void)
73 {
74 }
75