Added more original works and stubs
[wxWidgets.git] / src / cocoa / checkbox.mm
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
16 #import <AppKit/NSButton.h>
17 #import <Foundation/NSString.h>
18
19 IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
20 BEGIN_EVENT_TABLE(wxCheckBox, wxCheckBoxBase)
21 END_EVENT_TABLE()
22 WX_IMPLEMENT_COCOA_OWNER(wxCheckBox,NSButton,NSControl,NSView)
23
24 bool wxCheckBox::Create(wxWindow *parent, wxWindowID winid,
25            const wxString& label,
26            const wxPoint& pos,
27            const wxSize& size,
28            long style,
29            const wxValidator& validator,
30            const wxString& name)
31 {
32     if(!CreateControl(parent,winid,pos,size,style,validator,name))
33         return false;
34     m_cocoaNSView = NULL;
35     NSRect cocoaRect = NSMakeRect(10,10,20,20);
36     SetNSButton([[NSButton alloc] initWithFrame: cocoaRect]);
37     [m_cocoaNSView release];
38     [GetNSButton() setButtonType: NSSwitchButton];
39     [GetNSButton() setTitle:[NSString stringWithCString: label.c_str()]];
40     [GetNSControl() sizeToFit];
41
42     if(m_parent)
43         m_parent->CocoaAddChild(this);
44     return true;
45 }
46
47 wxCheckBox::~wxCheckBox()
48 {
49     CocoaRemoveFromParent();
50     SetNSButton(NULL);
51 }
52
53 void wxCheckBox::SetValue(bool)
54 {
55 }
56
57 bool wxCheckBox::GetValue() const
58 {
59     return false;
60 }
61
62 void wxCheckBox::Cocoa_wxNSButtonAction(void)
63 {
64     wxLogDebug("Checkbox");
65 }
66