]>
Commit | Line | Data |
---|---|---|
da0634c1 DE |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: cocoa/checkbox.mm | |
3 | // Purpose: wxCheckBox | |
4 | // Author: David Elliott | |
5 | // Modified by: | |
6 | // Created: 2003/03/16 | |
7 | // RCS-ID: $Id: | |
8 | // Copyright: (c) 2003 David Elliott | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #include "wx/app.h" | |
13 | #include "wx/checkbox.h" | |
14 | #include "wx/log.h" | |
15 | ||
7fc77f30 DE |
16 | #include "wx/cocoa/autorelease.h" |
17 | ||
da0634c1 DE |
18 | #import <AppKit/NSButton.h> |
19 | #import <Foundation/NSString.h> | |
20 | ||
21 | IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl) | |
22 | BEGIN_EVENT_TABLE(wxCheckBox, wxCheckBoxBase) | |
23 | END_EVENT_TABLE() | |
24 | WX_IMPLEMENT_COCOA_OWNER(wxCheckBox,NSButton,NSControl,NSView) | |
25 | ||
26 | bool wxCheckBox::Create(wxWindow *parent, wxWindowID winid, | |
27 | const wxString& label, | |
28 | const wxPoint& pos, | |
29 | const wxSize& size, | |
30 | long style, | |
31 | const wxValidator& validator, | |
32 | const wxString& name) | |
33 | { | |
7fc77f30 | 34 | wxAutoNSAutoreleasePool pool; |
da0634c1 DE |
35 | if(!CreateControl(parent,winid,pos,size,style,validator,name)) |
36 | return false; | |
37 | m_cocoaNSView = NULL; | |
38 | NSRect cocoaRect = NSMakeRect(10,10,20,20); | |
39 | SetNSButton([[NSButton alloc] initWithFrame: cocoaRect]); | |
40 | [m_cocoaNSView release]; | |
41 | [GetNSButton() setButtonType: NSSwitchButton]; | |
42 | [GetNSButton() setTitle:[NSString stringWithCString: label.c_str()]]; | |
43 | [GetNSControl() sizeToFit]; | |
44 | ||
45 | if(m_parent) | |
46 | m_parent->CocoaAddChild(this); | |
47 | return true; | |
48 | } | |
49 | ||
50 | wxCheckBox::~wxCheckBox() | |
51 | { | |
570aaadf | 52 | DisassociateNSButton(m_cocoaNSView); |
da0634c1 DE |
53 | } |
54 | ||
55 | void wxCheckBox::SetValue(bool) | |
56 | { | |
57 | } | |
58 | ||
59 | bool wxCheckBox::GetValue() const | |
60 | { | |
61 | return false; | |
62 | } | |
63 | ||
64 | void wxCheckBox::Cocoa_wxNSButtonAction(void) | |
65 | { | |
66 | wxLogDebug("Checkbox"); | |
67 | } | |
68 |