X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c5172ed1bf56c880c4ae928eae4da21c402a2ba3..672456655288ae8bfd67ab7047adffef6b959d77:/src/cocoa/control.mm diff --git a/src/cocoa/control.mm b/src/cocoa/control.mm index fac6d2831d..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