X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/90b4f7b5f55d93bf8c79e52a09bf6c116dbc6d47..344ff08345eba81fcdcc55dd711ce6bc4bb747a3:/src/mac/carbon/window.cpp diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index bc118c7741..dbf267960f 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -11,31 +11,34 @@ #include "wx/wxprec.h" -#include "wx/menu.h" #include "wx/window.h" -#include "wx/dc.h" -#include "wx/dcclient.h" -#include "wx/utils.h" -#include "wx/app.h" -#include "wx/panel.h" + +#ifndef WX_PRECOMP + #include "wx/log.h" + #include "wx/app.h" + #include "wx/utils.h" + #include "wx/panel.h" + #include "wx/frame.h" + #include "wx/dc.h" + #include "wx/dcclient.h" + #include "wx/button.h" + #include "wx/menu.h" + #include "wx/dialog.h" + #include "wx/settings.h" + #include "wx/msgdlg.h" +#endif + #include "wx/layout.h" -#include "wx/dialog.h" #include "wx/scrolbar.h" #include "wx/statbox.h" -#include "wx/button.h" -#include "wx/settings.h" -#include "wx/msgdlg.h" -#include "wx/frame.h" #include "wx/tooltip.h" #include "wx/statusbr.h" #include "wx/menuitem.h" #include "wx/spinctrl.h" -#include "wx/log.h" #include "wx/geometry.h" #include "wx/textctrl.h" #include "wx/toolbar.h" -#include "wx/dc.h" #if wxUSE_CARET #include "wx/caret.h" @@ -65,8 +68,6 @@ #include -extern wxList wxPendingDelete; - #ifdef __WXUNIVERSAL__ IMPLEMENT_ABSTRACT_CLASS(wxWindowMac, wxWindowBase) #else @@ -167,9 +168,11 @@ static const EventTypeSpec eventList[] = { kEventClassTextInput, kEventTextInputUpdateActiveInputArea } , { kEventClassControl , kEventControlDraw } , +#if TARGET_API_MAC_OSX { kEventClassControl , kEventControlVisibilityChanged } , { kEventClassControl , kEventControlEnabledStateChanged } , { kEventClassControl , kEventControlHiliteChanged } , +#endif { kEventClassControl , kEventControlSetFocusPart } , { kEventClassService , kEventServiceGetTypes }, @@ -496,25 +499,26 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even wchar_t* uniChars = NULL ; UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ; - UniChar* charBuf; + UniChar* charBuf = NULL; UInt32 dataSize = 0 ; int numChars = 0 ; UniChar buf[2] ; if ( GetEventParameter( event, kEventParamTextInputSendText, typeUnicodeText, NULL, 0 , &dataSize, NULL ) == noErr ) { - numChars = dataSize / sizeof( UniChar) ; + numChars = dataSize / sizeof( UniChar) + 1; charBuf = buf ; - if ( dataSize > sizeof(buf) ) + if ( (size_t) numChars * 2 > sizeof(buf) ) charBuf = new UniChar[ numChars ] ; else charBuf = buf ; uniChars = new wchar_t[ numChars ] ; GetEventParameter( event, kEventParamTextInputSendText, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ; + charBuf[ numChars - 1 ] = 0; #if SIZEOF_WCHAR_T == 2 - uniChars = charBuf ; - memcpy( uniChars , charBuf , dataSize ) ; + uniChars = (wchar_t*) charBuf ; + memcpy( uniChars , charBuf , numChars * 2 ) ; #else // the resulting string will never have more chars than the utf16 version, so this is safe wxMBConvUTF16 converter ; @@ -585,7 +589,7 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even delete [] uniChars ; if ( charBuf != buf ) delete [] charBuf ; - + return result ; } @@ -1257,14 +1261,16 @@ void wxWindowMac::MacSetBackgroundBrush( const wxBrush &brush ) bool wxWindowMac::MacCanFocus() const { // TODO : evaluate performance hits by looking up this value, eventually cache the results for a 1 sec or so - // CAUTION : the value returned currently is 0 or 2, I've also found values of 1 having the same meaning, but the value range - // is nowhere documented + // CAUTION : the value returned currently is 0 or 2, I've also found values of 1 having the same meaning, + // but the value range is nowhere documented Boolean keyExistsAndHasValidFormat ; - CFIndex fullKeyboardAccess = CFPreferencesGetAppIntegerValue ( CFSTR("AppleKeyboardUIMode" ) , - kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat); - + CFIndex fullKeyboardAccess = CFPreferencesGetAppIntegerValue( CFSTR("AppleKeyboardUIMode" ) , + kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat ); + if ( keyExistsAndHasValidFormat && fullKeyboardAccess > 0 ) + { return true ; + } else { UInt32 features = 0 ; @@ -1334,7 +1340,7 @@ void wxWindowMac::DoCaptureMouse() wxApp::s_captureWindow = this ; } -wxWindow* wxWindowBase::GetCapture() +wxWindow * wxWindowBase::GetCapture() { return wxApp::s_captureWindow ; } @@ -1360,7 +1366,7 @@ void wxWindowMac::SetDropTarget(wxDropTarget *pDropTarget) #endif -// Old style file-manager drag&drop +// Old-style File Manager Drag & Drop void wxWindowMac::DragAcceptFiles(bool accept) { // TODO: @@ -1383,10 +1389,7 @@ bool wxWindowMac::MacGetBoundsForControl( int& x, int& y, int& w, int& h , bool adjustOrigin ) const { - bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ; - // the desired size, minus the border pixels gives the correct size of the control - x = (int)pos.x; y = (int)pos.y; @@ -1394,6 +1397,7 @@ bool wxWindowMac::MacGetBoundsForControl( w = wxMax(size.x, 0) ; // WidthDefault( size.x ); h = wxMax(size.y, 0) ; // HeightDefault( size.y ) ; + bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ; if ( !isCompositing ) GetParent()->MacWindowToRootWindow( &x , &y ) ;