]>
Commit | Line | Data |
---|---|---|
fb896a32 DE |
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 | ||
449c5673 DE |
12 | #include "wx/wxprec.h" |
13 | #ifndef WX_PRECOMP | |
14 | #include "wx/app.h" | |
15 | #include "wx/stattext.h" | |
16 | #endif //WX_PRECOMP | |
fb896a32 | 17 | |
7fc77f30 DE |
18 | #include "wx/cocoa/autorelease.h" |
19 | ||
fb896a32 DE |
20 | #import <Foundation/NSString.h> |
21 | #import <AppKit/NSTextField.h> | |
1c54c792 | 22 | #include <math.h> |
fb896a32 DE |
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 | { | |
7fc77f30 | 36 | wxAutoNSAutoreleasePool pool; |
fb896a32 DE |
37 | if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name)) |
38 | return false; | |
39 | m_cocoaNSView = NULL; | |
8d656ea9 | 40 | SetNSTextField([[NSTextField alloc] initWithFrame:MakeDefaultNSRect(size)]); |
fb896a32 DE |
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]; | |
1c54c792 | 47 | |
fb896a32 | 48 | [GetNSControl() sizeToFit]; |
1c54c792 DE |
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 | ||
fb896a32 DE |
54 | if(m_parent) |
55 | m_parent->CocoaAddChild(this); | |
8d656ea9 DE |
56 | SetInitialFrameRect(pos,size); |
57 | ||
fb896a32 DE |
58 | return true; |
59 | } | |
60 | ||
61 | wxStaticText::~wxStaticText() | |
62 | { | |
911e17c6 | 63 | DisassociateNSTextField(GetNSTextField()); |
fb896a32 DE |
64 | } |
65 | ||
66 | void wxStaticText::SetLabel(const wxString& label) | |
67 | { | |
68 | // TODO | |
69 | } | |
70 | ||
71 | void wxStaticText::Cocoa_didChangeText(void) | |
72 | { | |
73 | } | |
74 |