cleanup - reformatting

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37313 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Surovell
2006-02-05 07:27:48 +00:00
parent 61fa2e39da
commit b46dde2772

View File

@@ -41,11 +41,15 @@
#include "wx/caret.h" #include "wx/caret.h"
#endif #endif
#define MAC_SCROLLBAR_SIZE 15 #if wxUSE_DRAG_AND_DROP
#define MAC_SMALL_SCROLLBAR_SIZE 11 #include "wx/dnd.h"
#endif
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
#define MAC_SCROLLBAR_SIZE 15
#define MAC_SMALL_SCROLLBAR_SIZE 11
#ifndef __DARWIN__ #ifndef __DARWIN__
#include <Windows.h> #include <Windows.h>
#include <ToolUtils.h> #include <ToolUtils.h>
@@ -59,10 +63,6 @@
#endif #endif
#endif #endif
#if wxUSE_DRAG_AND_DROP
#include "wx/dnd.h"
#endif
#include <string.h> #include <string.h>
extern wxList wxPendingDelete; extern wxList wxPendingDelete;
@@ -160,12 +160,12 @@ static const EventTypeSpec eventList[] =
{ {
{ kEventClassCommand, kEventProcessCommand } , { kEventClassCommand, kEventProcessCommand } ,
{ kEventClassCommand, kEventCommandUpdateStatus } , { kEventClassCommand, kEventCommandUpdateStatus } ,
{ kEventClassControl , kEventControlHit } , { kEventClassControl , kEventControlHit } ,
{ kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } , { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } ,
{ kEventClassTextInput, kEventTextInputUpdateActiveInputArea } , { kEventClassTextInput, kEventTextInputUpdateActiveInputArea } ,
{ kEventClassControl , kEventControlDraw } , { kEventClassControl , kEventControlDraw } ,
{ kEventClassControl , kEventControlVisibilityChanged } , { kEventClassControl , kEventControlVisibilityChanged } ,
{ kEventClassControl , kEventControlEnabledStateChanged } , { kEventClassControl , kEventControlEnabledStateChanged } ,
@@ -492,10 +492,10 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even
{ {
OSStatus result = eventNotHandledErr ; OSStatus result = eventNotHandledErr ;
wxWindowMac* focus = (wxWindowMac*) data ; wxWindowMac* focus = (wxWindowMac*) data ;
wchar_t* uniChars = NULL ; wchar_t* uniChars = NULL ;
UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ; UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ;
UniChar* charBuf; UniChar* charBuf;
UInt32 dataSize = 0 ; UInt32 dataSize = 0 ;
int numChars = 0 ; int numChars = 0 ;
@@ -504,12 +504,12 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even
{ {
numChars = dataSize / sizeof( UniChar) ; numChars = dataSize / sizeof( UniChar) ;
charBuf = buf ; charBuf = buf ;
if ( dataSize > sizeof(buf) ) if ( dataSize > sizeof(buf) )
charBuf = new UniChar[ numChars ] ; charBuf = new UniChar[ numChars ] ;
else else
charBuf = buf ; charBuf = buf ;
uniChars = new wchar_t[ numChars ] ; uniChars = new wchar_t[ numChars ] ;
GetEventParameter( event, kEventParamTextInputSendText, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ; GetEventParameter( event, kEventParamTextInputSendText, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ;
#if SIZEOF_WCHAR_T == 2 #if SIZEOF_WCHAR_T == 2
@@ -521,7 +521,7 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even
numChars = converter.MB2WC( uniChars , (const char*)charBuf , numChars ) ; numChars = converter.MB2WC( uniChars , (const char*)charBuf , numChars ) ;
#endif #endif
} }
switch ( GetEventKind( event ) ) switch ( GetEventKind( event ) )
{ {
case kEventTextInputUpdateActiveInputArea : case kEventTextInputUpdateActiveInputArea :
@@ -530,18 +530,17 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even
// EVT_CHAR // EVT_CHAR
for (int pos=0 ; pos < numChars ; pos++) for (int pos=0 ; pos < numChars ; pos++)
{ {
WXEVENTREF formerEvent = wxTheApp->MacGetCurrentEvent() ; WXEVENTREF formerEvent = wxTheApp->MacGetCurrentEvent() ;
WXEVENTHANDLERCALLREF formerHandler = wxTheApp->MacGetCurrentEventHandlerCallRef() ; WXEVENTHANDLERCALLREF formerHandler = wxTheApp->MacGetCurrentEventHandlerCallRef() ;
wxTheApp->MacSetCurrentEvent( event , handler ) ; wxTheApp->MacSetCurrentEvent( event , handler ) ;
UInt32 message = (0 << 8) + ((char)uniChars[pos] ); UInt32 message = (0 << 8) + ((char)uniChars[pos] );
if ( wxTheApp->MacSendCharEvent( if ( wxTheApp->MacSendCharEvent(
focus , message , 0 , when , 0 , 0 , uniChars[pos] ) ) focus , message , 0 , when , 0 , 0 , uniChars[pos] ) )
{ {
result = noErr ; result = noErr ;
} }
wxTheApp->MacSetCurrentEvent( formerEvent , formerHandler ) ; wxTheApp->MacSetCurrentEvent( formerEvent , formerHandler ) ;
} }
} }
@@ -558,24 +557,23 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even
GetEventParameter( rawEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); GetEventParameter( rawEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
GetEventParameter( rawEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers ); GetEventParameter( rawEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers );
GetEventParameter( rawEvent, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &point ); GetEventParameter( rawEvent, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &point );
UInt32 message = (keyCode << 8) + charCode; UInt32 message = (keyCode << 8) + charCode;
// An IME input event may return several characters, but we need to send one char at a time to // An IME input event may return several characters, but we need to send one char at a time to
// EVT_CHAR // EVT_CHAR
for (int pos=0 ; pos < numChars ; pos++) for (int pos=0 ; pos < numChars ; pos++)
{ {
WXEVENTREF formerEvent = wxTheApp->MacGetCurrentEvent() ; WXEVENTREF formerEvent = wxTheApp->MacGetCurrentEvent() ;
WXEVENTHANDLERCALLREF formerHandler = wxTheApp->MacGetCurrentEventHandlerCallRef() ; WXEVENTHANDLERCALLREF formerHandler = wxTheApp->MacGetCurrentEventHandlerCallRef() ;
wxTheApp->MacSetCurrentEvent( event , handler ) ; wxTheApp->MacSetCurrentEvent( event , handler ) ;
if ( wxTheApp->MacSendCharEvent( if ( wxTheApp->MacSendCharEvent(
focus , message , modifiers , when , point.h , point.v , uniChars[pos] ) ) focus , message , modifiers , when , point.h , point.v , uniChars[pos] ) )
{ {
result = noErr ; result = noErr ;
} }
wxTheApp->MacSetCurrentEvent( formerEvent , formerHandler ) ; wxTheApp->MacSetCurrentEvent( formerEvent , formerHandler ) ;
} }
} }
@@ -583,40 +581,39 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even
default: default:
break ; break ;
} }
delete[] uniChars ; delete [] uniChars ;
if ( charBuf != buf ) if ( charBuf != buf )
delete[] charBuf ; delete [] charBuf ;
return result ; return result ;
} }
static pascal OSStatus wxMacWindowCommandEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) static pascal OSStatus wxMacWindowCommandEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{ {
OSStatus result = eventNotHandledErr ; OSStatus result = eventNotHandledErr ;
wxWindowMac* focus = (wxWindowMac*) data ; wxWindowMac* focus = (wxWindowMac*) data ;
HICommand command ; HICommand command ;
wxMacCarbonEvent cEvent( event ) ; wxMacCarbonEvent cEvent( event ) ;
cEvent.GetParameter<HICommand>(kEventParamDirectObject,typeHICommand,&command) ; cEvent.GetParameter<HICommand>(kEventParamDirectObject,typeHICommand,&command) ;
wxMenuItem* item = NULL ; wxMenuItem* item = NULL ;
wxMenu* itemMenu = wxFindMenuFromMacCommand( command , item ) ; wxMenu* itemMenu = wxFindMenuFromMacCommand( command , item ) ;
int id = wxMacCommandToId( command.commandID ) ; int id = wxMacCommandToId( command.commandID ) ;
if ( item ) if ( item )
{ {
wxASSERT( itemMenu != NULL ) ; wxASSERT( itemMenu != NULL ) ;
switch ( cEvent.GetKind() ) switch ( cEvent.GetKind() )
{ {
case kEventProcessCommand : case kEventProcessCommand :
{ {
if (item->IsCheckable()) if (item->IsCheckable())
item->Check( !item->IsChecked() ) ; item->Check( !item->IsChecked() ) ;
if ( itemMenu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ) if ( itemMenu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) )
result = noErr ; result = noErr ;
else else
@@ -624,27 +621,27 @@ static pascal OSStatus wxMacWindowCommandEventHandler( EventHandlerCallRef handl
wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED , id); wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED , id);
event.SetEventObject(focus); event.SetEventObject(focus);
event.SetInt(item->IsCheckable() ? item->IsChecked() : -1); event.SetInt(item->IsCheckable() ? item->IsChecked() : -1);
if ( focus->GetEventHandler()->ProcessEvent(event) ) if ( focus->GetEventHandler()->ProcessEvent(event) )
result = noErr ; result = noErr ;
} }
} }
break ; break ;
case kEventCommandUpdateStatus: case kEventCommandUpdateStatus:
{ {
wxUpdateUIEvent event(id); wxUpdateUIEvent event(id);
event.SetEventObject( itemMenu ); event.SetEventObject( itemMenu );
bool processed = false; bool processed = false;
// Try the menu's event handler // Try the menu's event handler
{ {
wxEvtHandler *handler = itemMenu->GetEventHandler(); wxEvtHandler *handler = itemMenu->GetEventHandler();
if ( handler ) if ( handler )
processed = handler->ProcessEvent(event); processed = handler->ProcessEvent(event);
} }
// Try the window the menu was popped up from // Try the window the menu was popped up from
// (and up through the hierarchy) // (and up through the hierarchy)
if ( !processed ) if ( !processed )
@@ -658,16 +655,16 @@ static pascal OSStatus wxMacWindowCommandEventHandler( EventHandlerCallRef handl
processed = win->GetEventHandler()->ProcessEvent(event); processed = win->GetEventHandler()->ProcessEvent(event);
break; break;
} }
menu = menu->GetParent(); menu = menu->GetParent();
} }
} }
if ( !processed ) if ( !processed )
{ {
processed = focus->GetEventHandler()->ProcessEvent(event); processed = focus->GetEventHandler()->ProcessEvent(event);
} }
if ( processed ) if ( processed )
{ {
// if anything changed, update the changed attribute // if anything changed, update the changed attribute
@@ -677,12 +674,12 @@ static pascal OSStatus wxMacWindowCommandEventHandler( EventHandlerCallRef handl
itemMenu->Check(id, event.GetChecked()); itemMenu->Check(id, event.GetChecked());
if (event.GetSetEnabled()) if (event.GetSetEnabled())
itemMenu->Enable(id, event.GetEnabled()); itemMenu->Enable(id, event.GetEnabled());
result = noErr ; result = noErr ;
} }
} }
break ; break ;
default : default :
break ; break ;
} }
@@ -714,6 +711,7 @@ pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef
case kEventClassTextInput : case kEventClassTextInput :
result = wxMacUnicodeTextEventHandler( handler , event , data ) ; result = wxMacUnicodeTextEventHandler( handler , event , data ) ;
break ; break ;
default : default :
break ; break ;
} }
@@ -964,7 +962,6 @@ void wxWindowMac::Init()
wxWindowBase::SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); wxWindowBase::SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
} }
// Destructor
wxWindowMac::~wxWindowMac() wxWindowMac::~wxWindowMac()
{ {
SendDestroyEvent(); SendDestroyEvent();
@@ -985,7 +982,7 @@ wxWindowMac::~wxWindowMac()
break; break;
} }
} }
#endif // __WXUNIVERSAL__ #endif
// destroy children before destroying this window itself // destroy children before destroying this window itself
DestroyChildren(); DestroyChildren();
@@ -1770,8 +1767,8 @@ bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y)
{ {
MenuCommand macid; MenuCommand macid;
GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult)) , LoWord(menuResult) , &macid ); GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult)) , LoWord(menuResult) , &macid );
int id = wxMacCommandToId( macid ); int id = wxMacCommandToId( macid );
wxMenuItem* item = NULL ; wxMenuItem* item = NULL ;
wxMenu* realmenu ; wxMenu* realmenu ;
item = menu->FindItem( id, &realmenu ) ; item = menu->FindItem( id, &realmenu ) ;
if ( item ) if ( item )