X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a3bf7524f394af039efe196a186f7969cbabcc19..af5454a410ed37a8a1639716a0c96c191e60b7f0:/src/cocoa/control.mm diff --git a/src/cocoa/control.mm b/src/cocoa/control.mm index c316891f96..c83fa93dab 100644 --- a/src/cocoa/control.mm +++ b/src/cocoa/control.mm @@ -20,6 +20,22 @@ #import +@interface wxNonControlNSControl : NSControl +{ +} + +- (void)drawRect: (NSRect)rect; +@end // wxNonControlNSControl + +@implementation wxNonControlNSControl : NSControl +- (void)drawRect: (NSRect)rect +{ + wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self); + if( !win || !win->Cocoa_drawRect(rect) ) + [super drawRect:rect]; +} +@end // wxNonControlNSControl + IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow) BEGIN_EVENT_TABLE(wxControl, wxControlBase) END_EVENT_TABLE() @@ -34,7 +50,7 @@ bool wxControl::Create(wxWindow *parent, wxWindowID winid, return false; wxLogDebug("Created control with id=%d",GetId()); m_cocoaNSView = NULL; - SetNSControl([[NSControl alloc] initWithFrame: MakeDefaultNSRect(size)]); + SetNSControl([[wxNonControlNSControl alloc] initWithFrame: MakeDefaultNSRect(size)]); // NOTE: YES we want to release this (to match the alloc). // DoAddChild(this) will retain us again since addSubView doesn't. [m_cocoaNSView release]; @@ -50,7 +66,7 @@ bool wxControl::Create(wxWindow *parent, wxWindowID winid, wxControl::~wxControl() { - DisassociateNSControl(m_cocoaNSView); + DisassociateNSControl(GetNSControl()); } wxSize wxControl::DoGetBestSize() const @@ -71,3 +87,8 @@ bool wxControl::ProcessCommand(wxCommandEvent& event) return GetEventHandler()->ProcessEvent(event); } +void wxControl::CocoaSetEnabled(bool enable) +{ + [GetNSControl() setEnabled: enable]; +} +