]>
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 | |
065e208e | 9 | // Licence: wxWidgets licence |
fb896a32 DE |
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 | 18 | #include "wx/cocoa/autorelease.h" |
b0c0a393 | 19 | #include "wx/cocoa/string.h" |
7fc77f30 | 20 | |
fb896a32 DE |
21 | #import <Foundation/NSString.h> |
22 | #import <AppKit/NSTextField.h> | |
1c54c792 | 23 | #include <math.h> |
fb896a32 DE |
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 | { | |
7fc77f30 | 37 | wxAutoNSAutoreleasePool pool; |
fb896a32 DE |
38 | if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name)) |
39 | return false; | |
40 | m_cocoaNSView = NULL; | |
8d656ea9 | 41 | SetNSTextField([[NSTextField alloc] initWithFrame:MakeDefaultNSRect(size)]); |
fb896a32 | 42 | [m_cocoaNSView release]; |
b0c0a393 | 43 | [GetNSTextField() setStringValue:wxNSStringWithWxString(label)]; |
fb896a32 DE |
44 | // [GetNSTextField() setBordered: NO]; |
45 | [GetNSTextField() setBezeled: NO]; | |
46 | [GetNSTextField() setEditable: NO]; | |
47 | [GetNSTextField() setDrawsBackground: NO]; | |
1c54c792 | 48 | |
fb896a32 | 49 | [GetNSControl() sizeToFit]; |
1c54c792 DE |
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 | ||
fb896a32 DE |
55 | if(m_parent) |
56 | m_parent->CocoaAddChild(this); | |
8d656ea9 DE |
57 | SetInitialFrameRect(pos,size); |
58 | ||
fb896a32 DE |
59 | return true; |
60 | } | |
61 | ||
62 | wxStaticText::~wxStaticText() | |
63 | { | |
911e17c6 | 64 | DisassociateNSTextField(GetNSTextField()); |
fb896a32 DE |
65 | } |
66 | ||
67 | void wxStaticText::SetLabel(const wxString& label) | |
68 | { | |
69 | // TODO | |
70 | } | |
71 | ||
72 | void wxStaticText::Cocoa_didChangeText(void) | |
73 | { | |
74 | } | |
75 |