From a484859779844254e64071942e06b6527daf6b7a Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Sun, 19 Dec 2004 16:41:41 +0000 Subject: [PATCH] extended EventRef class git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31064 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/mac/carbon/private.h | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/include/wx/mac/carbon/private.h b/include/wx/mac/carbon/private.h index d8775399ab..8a239c0ed3 100644 --- a/include/wx/mac/carbon/private.h +++ b/include/wx/mac/carbon/private.h @@ -233,23 +233,47 @@ class wxMacCarbonEvent { public : + wxMacCarbonEvent() + { + m_eventRef = 0 ; + m_release = false ; + } + wxMacCarbonEvent( EventRef event , bool release = false ) { m_eventRef = event ; m_release = release ; } + wxMacCarbonEvent(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone) { m_eventRef = NULL ; verify_noerr( MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) ) ; m_release = true ; } + ~wxMacCarbonEvent() { if ( m_release ) ReleaseEvent( m_eventRef ) ; } + OSStatus Create(UInt32 inClassID,UInt32 inKind,EventTime inWhen = 0 /*now*/,EventAttributes inAttributes=kEventAttributeNone) + { + verify( (m_eventRef == NULL) || m_release ) ; + if ( m_eventRef && m_release ) + { + ReleaseEvent( m_eventRef ) ; + m_release = false ; + m_eventRef = NULL ; + + } + OSStatus err = MacCreateEvent( NULL , inClassID, inKind,inWhen,inAttributes,&m_eventRef) ; + if ( err == noErr ) + m_release = true ; + return err ; + } + OSStatus GetParameter( EventParamName inName, EventParamType inDesiredType, UInt32 inBufferSize, void * outData) ; template OSStatus GetParameter( EventParamName inName, EventParamType type , T *data ) @@ -307,7 +331,13 @@ public : { return EventTimeToTicks( GetTime() ) ; } - operator EventRef () { return m_eventRef; } + OSStatus SetTime( EventTime inWhen = 0 /*now*/ ) + { + return ::SetEventTime( m_eventRef , inWhen ? inWhen : GetCurrentEventTime() ) ; + } + operator EventRef () { return m_eventRef; } + + bool IsValid() { return m_eventRef != 0 ; } protected : EventRef m_eventRef ; bool m_release ; -- 2.47.2