diff --git a/include/wx/osx/cocoa/private.h b/include/wx/osx/cocoa/private.h index bd4f07ff81..a28dd242d6 100644 --- a/include/wx/osx/cocoa/private.h +++ b/include/wx/osx/cocoa/private.h @@ -50,8 +50,7 @@ class WXDLLIMPEXP_FWD_CORE wxDialog; class WXDLLIMPEXP_CORE wxWidgetCocoaImpl : public wxWidgetImpl { public : - wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl, bool isUserPane, bool wantsUserKey ) ; - wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl = false, bool isUserPane = false ) ; + wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, int flags = 0 ) ; wxWidgetCocoaImpl() ; ~wxWidgetCocoaImpl(); diff --git a/include/wx/osx/core/private.h b/include/wx/osx/core/private.h index 4b681bcb7a..9ada10b975 100644 --- a/include/wx/osx/core/private.h +++ b/include/wx/osx/core/private.h @@ -216,8 +216,16 @@ protected : class WXDLLIMPEXP_CORE wxWidgetImpl : public wxObject { public : + enum WidgetFlags + { + Widget_IsRoot = 0x0001, + Widget_IsUserPane = 0x0002, + Widget_UserKeyEvents = 0x0004, + Widget_UserMouseEvents = 0x0008, + }; + wxWidgetImpl( wxWindowMac* peer , bool isRootControl, bool isUserPane, bool wantsUserKey ); - wxWidgetImpl( wxWindowMac* peer , bool isRootControl = false, bool isUserPane = false ); + wxWidgetImpl( wxWindowMac* peer , int flags = 0 ); wxWidgetImpl(); virtual ~wxWidgetImpl(); @@ -225,15 +233,14 @@ public : bool IsRootControl() const { return m_isRootControl; } - // is a completely control that has all events handled in wx code, no built-ins + // is a custom control that has all events handled in wx code, no built-ins bool IsUserPane() const { return m_isUserPane; } // we are doing keyboard handling in wx code, other events might be handled natively virtual bool HasUserKeyHandling() const { return m_wantsUserKey; } // we are doing mouse handling in wx code, other events might be handled natively - // right now this is always in sync with HasUserKeyHandling - virtual bool HasUserMouseHandling() const { return m_wantsUserKey; } + virtual bool HasUserMouseHandling() const { return m_wantsUserMouse; } wxWindowMac* GetWXPeer() const { return m_wxPeer; } @@ -582,6 +589,7 @@ protected : bool m_isRootControl; bool m_isUserPane; bool m_wantsUserKey; + bool m_wantsUserMouse; wxWindowMac* m_wxPeer; bool m_needsFocusRect; bool m_needsFrame; diff --git a/include/wx/osx/iphone/private.h b/include/wx/osx/iphone/private.h index 484e7525ee..557bb68308 100644 --- a/include/wx/osx/iphone/private.h +++ b/include/wx/osx/iphone/private.h @@ -37,7 +37,7 @@ wxBitmap WXDLLIMPEXP_CORE wxOSXCreateSystemBitmap(const wxString& id, const wxSt class WXDLLIMPEXP_CORE wxWidgetIPhoneImpl : public wxWidgetImpl { public : - wxWidgetIPhoneImpl( wxWindowMac* peer , WXWidget w, bool isRootControl = false, bool isUserPane = false ) ; + wxWidgetIPhoneImpl( wxWindowMac* peer , WXWidget w, int flags = 0 ) ; wxWidgetIPhoneImpl() ; ~wxWidgetIPhoneImpl(); diff --git a/src/osx/cocoa/glcanvas.mm b/src/osx/cocoa/glcanvas.mm index 74bb5a9386..59c572e73b 100644 --- a/src/osx/cocoa/glcanvas.mm +++ b/src/osx/cocoa/glcanvas.mm @@ -167,7 +167,7 @@ bool wxGLCanvas::DoCreate(wxWindow *parent, NSRect r = wxOSXGetFrameForControl( this, pos , size ) ; wxNSCustomOpenGLView* v = [[wxNSCustomOpenGLView alloc] initWithFrame:r]; - wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( this, v, false, false, true /* wants key events */ ); + wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( this, v, wxWidgetImpl::Widget_UserKeyEvents | wxWidgetImpl::Widget_UserMouseEvents ); SetPeer(c); MacPostControlCreate(pos, size) ; return true; diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index 5df461d395..4b356e720b 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -2512,24 +2512,8 @@ void wxOSXCocoaClassAddWXMethods(Class c, wxOSXSkipOverrides skipFlags) wxIMPLEMENT_DYNAMIC_CLASS(wxWidgetCocoaImpl , wxWidgetImpl); -wxWidgetCocoaImpl::wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl, bool isUserPane, bool wantsKey ) : - wxWidgetImpl( peer, isRootControl, isUserPane, wantsKey ) -{ - Init(); - m_osxView = w; - - // check if the user wants to create the control initially hidden - if ( !peer->IsShown() ) - SetVisibility(false); - - // gc aware handling - if ( m_osxView ) - CFRetain(m_osxView); - [m_osxView release]; -} - -wxWidgetCocoaImpl::wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl, bool isUserPane ) : -wxWidgetImpl( peer, isRootControl, isUserPane ) +wxWidgetCocoaImpl::wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, int flags ) : +wxWidgetImpl( peer, flags ) { Init(); m_osxView = w; @@ -3834,7 +3818,7 @@ wxWidgetImpl* wxWidgetImpl::CreateUserPane( wxWindowMac* wxpeer, wxWindowMac* WX NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; wxNSView* v = [[wxNSView alloc] initWithFrame:r]; - wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v, false, true ); + wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v, Widget_IsUserPane ); return c; } @@ -3846,7 +3830,7 @@ wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now ) if ( now->IsNativeWindowWrapper() ) { NSView* cv = [tlw contentView]; - c = new wxWidgetCocoaImpl( now, cv, true ); + c = new wxWidgetCocoaImpl( now, cv, Widget_IsRoot ); if ( cv != nil ) { // increase ref count, because the impl destructor will decrement it again @@ -3858,7 +3842,7 @@ wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now ) else { wxNSView* v = [[wxNSView alloc] initWithFrame:[[tlw contentView] frame]]; - c = new wxWidgetCocoaImpl( now, v, true ); + c = new wxWidgetCocoaImpl( now, v, Widget_IsRoot ); c->InstallEventHandler(); [tlw setContentView:v]; } diff --git a/src/osx/iphone/nonownedwnd.mm b/src/osx/iphone/nonownedwnd.mm index 2da94aba87..2b15df7144 100644 --- a/src/osx/iphone/nonownedwnd.mm +++ b/src/osx/iphone/nonownedwnd.mm @@ -354,7 +354,7 @@ wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now ) [contentview setController:controller]; [contentview setHidden:YES]; - wxWidgetIPhoneImpl* impl = new wxWidgetIPhoneImpl( now, contentview, true ); + wxWidgetIPhoneImpl* impl = new wxWidgetIPhoneImpl( now, contentview, Widget_IsRoot ); impl->InstallEventHandler(); if ([toplevelwindow respondsToSelector:@selector(setRootViewController:)]) diff --git a/src/osx/iphone/window.mm b/src/osx/iphone/window.mm index d29beb7035..607c92f839 100644 --- a/src/osx/iphone/window.mm +++ b/src/osx/iphone/window.mm @@ -334,8 +334,8 @@ void wxOSXIPhoneClassAddWXMethods(Class c) wxIMPLEMENT_DYNAMIC_CLASS(wxWidgetIPhoneImpl , wxWidgetImpl); -wxWidgetIPhoneImpl::wxWidgetIPhoneImpl( wxWindowMac* peer , WXWidget w, bool isRootControl, bool isUserPane ) : - wxWidgetImpl( peer, isRootControl, isUserPane ), m_osxView(w) +wxWidgetIPhoneImpl::wxWidgetIPhoneImpl( wxWindowMac* peer , WXWidget w, int flags ) : + wxWidgetImpl( peer, flags ), m_osxView(w) { } @@ -821,7 +821,7 @@ wxWidgetImpl* wxWidgetImpl::CreateUserPane( wxWindowMac* wxpeer, wxWindowMac* WX sv.clipsToBounds = YES; sv.contentMode = UIViewContentModeRedraw; sv.clearsContextBeforeDrawing = NO; - wxWidgetIPhoneImpl* c = new wxWidgetIPhoneImpl( wxpeer, v, false, true ); + wxWidgetIPhoneImpl* c = new wxWidgetIPhoneImpl( wxpeer, v, Widget_IsUserPane ); return c; } diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index f6b8dde4b0..5006e35d91 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -2741,11 +2741,13 @@ void wxWidgetImpl::RemoveAssociation(WXWidget control) wxIMPLEMENT_ABSTRACT_CLASS(wxWidgetImpl, wxObject); -wxWidgetImpl::wxWidgetImpl( wxWindowMac* peer , bool isRootControl, bool isUserPane ) +wxWidgetImpl::wxWidgetImpl( wxWindowMac* peer , int flags ) { - Init(); - m_isRootControl = isRootControl; - m_wantsUserKey = m_isUserPane = isUserPane; + Init(); + m_isRootControl = flags & Widget_IsRoot; + m_isUserPane = flags & Widget_IsUserPane; + m_wantsUserKey = m_isUserPane || (flags & Widget_UserKeyEvents); + m_wantsUserMouse = m_isUserPane || (flags & Widget_UserMouseEvents); m_wxPeer = peer; m_shouldSendEvents = true; } @@ -2773,6 +2775,8 @@ wxWidgetImpl::~wxWidgetImpl() void wxWidgetImpl::Init() { m_isRootControl = false; + m_wantsUserKey = false; + m_wantsUserMouse = false; m_wxPeer = NULL; m_needsFocusRect = false; m_needsFrame = true;