]>
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 | ||
12 | #include "wx/app.h" | |
13 | #include "wx/stattext.h" | |
14 | ||
7fc77f30 DE |
15 | #include "wx/cocoa/autorelease.h" |
16 | ||
fb896a32 DE |
17 | #import <Foundation/NSString.h> |
18 | #import <AppKit/NSTextField.h> | |
1c54c792 | 19 | #include <math.h> |
fb896a32 DE |
20 | |
21 | IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl) | |
22 | BEGIN_EVENT_TABLE(wxStaticText, wxControl) | |
23 | END_EVENT_TABLE() | |
24 | WX_IMPLEMENT_COCOA_OWNER(wxStaticText,NSTextField,NSControl,NSView) | |
25 | ||
26 | bool wxStaticText::Create(wxWindow *parent, wxWindowID winid, | |
27 | const wxString& label, | |
28 | const wxPoint& pos, | |
29 | const wxSize& size, | |
30 | long style, | |
31 | const wxString& name) | |
32 | { | |
7fc77f30 | 33 | wxAutoNSAutoreleasePool pool; |
fb896a32 DE |
34 | if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name)) |
35 | return false; | |
36 | m_cocoaNSView = NULL; | |
8d656ea9 | 37 | SetNSTextField([[NSTextField alloc] initWithFrame:MakeDefaultNSRect(size)]); |
fb896a32 DE |
38 | [m_cocoaNSView release]; |
39 | [GetNSTextField() setStringValue:[NSString stringWithCString:label.c_str()]]; | |
40 | // [GetNSTextField() setBordered: NO]; | |
41 | [GetNSTextField() setBezeled: NO]; | |
42 | [GetNSTextField() setEditable: NO]; | |
43 | [GetNSTextField() setDrawsBackground: NO]; | |
1c54c792 | 44 | |
fb896a32 | 45 | [GetNSControl() sizeToFit]; |
1c54c792 DE |
46 | // Round-up to next integer size |
47 | NSRect nsrect = [m_cocoaNSView frame]; | |
48 | nsrect.size.width = ceil(nsrect.size.width); | |
49 | [m_cocoaNSView setFrameSize: nsrect.size]; | |
50 | ||
fb896a32 DE |
51 | if(m_parent) |
52 | m_parent->CocoaAddChild(this); | |
8d656ea9 DE |
53 | SetInitialFrameRect(pos,size); |
54 | ||
fb896a32 DE |
55 | return true; |
56 | } | |
57 | ||
58 | wxStaticText::~wxStaticText() | |
59 | { | |
570aaadf | 60 | DisassociateNSTextField(m_cocoaNSView); |
fb896a32 DE |
61 | } |
62 | ||
63 | void wxStaticText::SetLabel(const wxString& label) | |
64 | { | |
65 | // TODO | |
66 | } | |
67 | ||
68 | void wxStaticText::Cocoa_didChangeText(void) | |
69 | { | |
70 | } | |
71 |