macOS wxWidgetImpl constructor with flags

replacing bools with int flag
This commit is contained in:
Stefan Csomor
2019-01-03 20:02:24 +01:00
parent 66a9e55f3b
commit e5e6ee7e77
8 changed files with 32 additions and 37 deletions

View File

@@ -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();

View File

@@ -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;

View File

@@ -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();

View File

@@ -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;

View File

@@ -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];
}

View File

@@ -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:)])

View File

@@ -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;
}

View File

@@ -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;
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;