added carbon event handlers

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15614 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2002-05-20 20:14:22 +00:00
parent f6c29ee0c1
commit 7c09167353
2 changed files with 114 additions and 2 deletions

View File

@@ -39,6 +39,7 @@
#include "wx/mac/uma.h"
#include "wx/mac/aga.h"
#include "wx/app.h"
#include "wx/tooltip.h"
#include "wx/dnd.h"
@@ -110,6 +111,7 @@ void wxTopLevelWindowMac::Init()
m_macNoEraseUpdateRgn = NewRgn() ;
m_macNeedsErasing = false ;
m_macWindow = NULL ;
m_macEventHandler = NULL ;
}
class wxMacDeferredWindowDeleter : public wxObject
@@ -159,7 +161,14 @@ wxTopLevelWindowMac::~wxTopLevelWindowMac()
wxToolTip::NotifyWindowDelete(m_macWindow) ;
wxPendingDelete.Append( new wxMacDeferredWindowDeleter( (WindowRef) m_macWindow ) ) ;
}
#if TARGET_CARBON
if ( m_macEventHandler )
{
::RemoveEventHandler((EventHandlerRef) m_macEventHandler);
m_macEventHandler = NULL ;
}
#endif
wxRemoveMacWindowAssociation( this ) ;
wxTopLevelWindows.DeleteObject(this);
@@ -221,6 +230,52 @@ void wxTopLevelWindowMac::SetIcon(const wxIcon& icon)
wxTopLevelWindowBase::SetIcon(icon);
}
#if TARGET_CARBON
EventHandlerUPP wxMacWindowEventHandlerUPP = NULL ;
pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{
OSStatus result = eventNotHandledErr ;
EventRecord rec ;
switch ( GetEventClass( event ) )
{
case kEventClassTextInput :
if ( wxMacConvertEventToRecord( event , &rec ) )
{
wxTheApp->MacHandleOneEvent( &rec ) ;
result = noErr ;
}
break ;
default :
break ;
}
return result ;
}
#endif
void wxTopLevelWindowMac::MacInstallEventHandler()
{
#if TARGET_CARBON
if ( wxMacWindowEventHandlerUPP == NULL )
{
wxMacWindowEventHandlerUPP = NewEventHandlerUPP( wxMacWindowEventHandler ) ;
}
static const EventTypeSpec eventList[] =
{
{ kEventClassTextInput, kEventTextInputUnicodeForKeyEvent }
} ;
if ( m_macEventHandler )
{
::RemoveEventHandler((EventHandlerRef) m_macEventHandler);
m_macEventHandler = NULL ;
}
InstallWindowEventHandler(MAC_WXHWND(m_macWindow), wxMacWindowEventHandlerUPP, WXSIZEOF(eventList), eventList, this, &((EventHandlerRef)m_macEventHandler));
#endif
}
void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
const wxPoint& pos,
const wxSize& size,
@@ -322,6 +377,7 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
label = title ;
UMASetWTitleC( (WindowRef)m_macWindow , label ) ;
::CreateRootControl( (WindowRef)m_macWindow , (ControlHandle*)&m_macRootControl ) ;
MacInstallEventHandler() ;
m_macFocus = NULL ;
}