// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
-#include "wx/app.h"
-#include "wx/checkbox.h"
-#include "wx/log.h"
+#include "wx/wxprec.h"
+#ifndef WX_PRECOMP
+ #include "wx/log.h"
+ #include "wx/app.h"
+ #include "wx/checkbox.h"
+#endif //WX_PRECOMP
#include "wx/cocoa/autorelease.h"
+#include "wx/cocoa/string.h"
#import <AppKit/NSButton.h>
#import <Foundation/NSString.h>
SetNSButton([[NSButton alloc] initWithFrame: MakeDefaultNSRect(size)]);
[m_cocoaNSView release];
[GetNSButton() setButtonType: NSSwitchButton];
- [GetNSButton() setTitle:[NSString stringWithCString: label.c_str()]];
+ [GetNSButton() setTitle:wxNSStringWithWxString(wxStripMenuCodes(label))];
[GetNSControl() sizeToFit];
if(m_parent)
wxCheckBox::~wxCheckBox()
{
- DisassociateNSButton(m_cocoaNSView);
+ DisassociateNSButton(GetNSButton());
}
-void wxCheckBox::SetValue(bool)
+void wxCheckBox::SetValue(bool value)
{
+ if(value)
+ [GetNSButton() setState: NSOnState];
+ else
+ [GetNSButton() setState: NSOffState];
}
bool wxCheckBox::GetValue() const
{
- return false;
+ int state = [GetNSButton() state];
+ wxASSERT(state!=NSMixedState);
+ return state==NSOnState;
}
void wxCheckBox::Cocoa_wxNSButtonAction(void)
{
wxLogDebug("Checkbox");
+ wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, GetId());
+ InitCommandEvent(event); // event.SetEventObject(this);
+ event.SetInt(GetValue());
+ Command(event);
}