]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/toplevel.cpp
Include wx/pen.h according to precompiled headers of wx/wx.h (with other minor cleaning).
[wxWidgets.git] / src / mac / carbon / toplevel.cpp
index c7c49f7f2bdd3a834370cc4fd90db34fbadb7723..38bee34358a026576ee401962e9c51162af5fd7f 100644 (file)
@@ -38,7 +38,6 @@
 
 #include "wx/mac/uma.h"
 #include "wx/mac/aga.h"
-#include "wx/app.h"
 #include "wx/tooltip.h"
 #include "wx/dnd.h"
 
@@ -122,7 +121,10 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
         focus = (wxTopLevelWindowMac*) data ;
 
     unsigned char charCode ;
-    wxChar uniChar = 0 ;
+    wxChar uniChar[2] ;
+    uniChar[0] = 0;
+    uniChar[1] = 0;
+
     UInt32 keyCode ;
     UInt32 modifiers ;
     Point point ;
@@ -133,21 +135,23 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
     if ( GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, 0 , &dataSize, NULL ) == noErr )
     {
         UniChar buf[2] ;
+        int numChars = dataSize / sizeof( UniChar) + 1;
 
         UniChar* charBuf = buf ;
 
-        if ( dataSize > 4 )
-            charBuf = new UniChar[ dataSize / sizeof( UniChar) ] ;
+        if ( numChars * 2 > 4 )
+            charBuf = new UniChar[ numChars ] ;
         GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ;
+        charBuf[ numChars - 1 ] = 0;
 
 #if SIZEOF_WCHAR_T == 2
         uniChar = charBuf[0] ;
 #else
         wxMBConvUTF16 converter ;
-        converter.MB2WC( &uniChar , (const char*)charBuf , 1 ) ;
+        converter.MB2WC( uniChar , (const char*)charBuf , 2 ) ;
 #endif
 
-        if ( dataSize > 4 )
+        if ( numChars * 2 > 4 )
             delete[] charBuf ;
     }
 #endif
@@ -167,7 +171,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
                 WXEVENTHANDLERCALLREF formerHandler = wxTheApp->MacGetCurrentEventHandlerCallRef() ;
                 wxTheApp->MacSetCurrentEvent( event , handler ) ;
                 if ( /* focus && */ wxTheApp->MacSendKeyDownEvent(
-                    focus , message , modifiers , when , point.h , point.v , uniChar ) )
+                    focus , message , modifiers , when , point.h , point.v , uniChar[0] ) )
                 {
                     result = noErr ;
                 }
@@ -177,7 +181,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
 
         case kEventRawKeyUp :
             if ( /* focus && */ wxTheApp->MacSendKeyUpEvent(
-                focus , message , modifiers , when , point.h , point.v , uniChar ) )
+                focus , message , modifiers , when , point.h , point.v , uniChar[0] ) )
             {
                 result = noErr ;
             }
@@ -195,7 +199,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
                 event.m_y = point.v;
 
 #if wxUSE_UNICODE
-                event.m_uniChar = uniChar ;
+                event.m_uniChar = uniChar[0] ;
 #endif
 
                 event.SetTimestamp(when);
@@ -1784,4 +1788,3 @@ static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16
 
     return 0;
 }
-