CodeWarrior Obj-C++ requires explicit casts from id to Objective-C types
[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/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
20 #import <Foundation/NSString.h>
21 #import <AppKit/NSTextField.h>
22 #include <math.h>
23
24 IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
25 BEGIN_EVENT_TABLE(wxStaticText, wxControl)
26 END_EVENT_TABLE()
27 WX_IMPLEMENT_COCOA_OWNER(wxStaticText,NSTextField,NSControl,NSView)
28
29 bool wxStaticText::Create(wxWindow *parent, wxWindowID winid,
30            const wxString& label,
31            const wxPoint& pos,
32            const wxSize& size,
33            long style,
34            const wxString& name)
35 {
36     wxAutoNSAutoreleasePool pool;
37     if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
38         return false;
39     m_cocoaNSView = NULL;
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];
47
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];
53
54     if(m_parent)
55         m_parent->CocoaAddChild(this);
56     SetInitialFrameRect(pos,size);
57
58     return true;
59 }
60
61 wxStaticText::~wxStaticText()
62 {
63     DisassociateNSTextField(GetNSTextField());
64 }
65
66 void wxStaticText::SetLabel(const wxString& label)
67 {
68     // TODO
69 }
70
71 void wxStaticText::Cocoa_didChangeText(void)
72 {
73 }
74