]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/window.cpp
added support for wxTE_NO_VSCROLL (patch 1588605) and documented its behaviour
[wxWidgets.git] / src / mac / carbon / window.cpp
index 5764a89abfcd1ba51d10e62211490e7ac7912e0e..e141745c0c4a4092eb4628fa9cb9b4ca251c9c87 100644 (file)
     #include "wx/layout.h"
     #include "wx/statusbr.h"
     #include "wx/menuitem.h"
+    #include "wx/treectrl.h"
+    #include "wx/listctrl.h"
 #endif
 
 #include "wx/tooltip.h"
 #include "wx/spinctrl.h"
 #include "wx/geometry.h"
 
+#if wxUSE_LISTCTRL
+    #include "wx/listctrl.h"
+#endif
+
+#if wxUSE_TREECTRL
+    #include "wx/treectrl.h"
+#endif
+
 #if wxUSE_CARET
     #include "wx/caret.h"
 #endif
@@ -167,6 +177,9 @@ static const EventTypeSpec eventList[] =
     { kEventClassControl , kEventControlVisibilityChanged } ,
     { kEventClassControl , kEventControlEnabledStateChanged } ,
     { kEventClassControl , kEventControlHiliteChanged } ,
+
+    { kEventClassControl , kEventControlActivate } ,
+    { kEventClassControl , kEventControlDeactivate } ,
 #endif
     { kEventClassControl , kEventControlSetFocusPart } ,
 
@@ -294,7 +307,20 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
         case kEventControlHiliteChanged :
             thisWindow->MacHiliteChanged() ;
             break ;
+            
+        case kEventControlActivate :
+        case kEventControlDeactivate :
+            // FIXME: we should have a virtual function for this!
+#if wxUSE_TREECTRL
+            if ( thisWindow->IsKindOf( CLASSINFO( wxTreeCtrl ) ) )
+                thisWindow->Refresh();
 #endif
+#if wxUSE_LISTCTRL
+            if ( thisWindow->IsKindOf( CLASSINFO( wxListCtrl ) ) )
+                thisWindow->Refresh();
+#endif
+            break ;
+#endif // TARGET_API_MAC_OSX
 
         // we emulate this event under Carbon CFM
         case kEventControlSetFocusPart :
@@ -485,7 +511,7 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even
         charBuf[ numChars - 1 ] = 0;
 #if SIZEOF_WCHAR_T == 2
         uniChars = (wchar_t*) charBuf ;
-        memcpy( uniChars , charBuf , numChars * 2 ) ;
+/*        memcpy( uniChars , charBuf , numChars * 2 ) ;*/      // is there any point in copying charBuf over itself? (in fact, memcpy isn't even guaranteed to work correctly if the source and destination ranges overlap...)
 #else
         // the resulting string will never have more chars than the utf16 version, so this is safe
         wxMBConvUTF16 converter ;
@@ -505,7 +531,32 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even
                     WXEVENTHANDLERCALLREF formerHandler = wxTheApp->MacGetCurrentEventHandlerCallRef() ;
                     wxTheApp->MacSetCurrentEvent( event , handler ) ;
 
+                    UInt32 message = uniChars[pos] < 128 ? (char)uniChars[pos] : '?';
+/*
+       NB: faking a charcode here is problematic. The kEventTextInputUpdateActiveInputArea event is sent
+       multiple times to update the active range during inline input, so this handler will often receive
+       uncommited text, which should usually not trigger side effects. It might be a good idea to check the
+       kEventParamTextInputSendFixLen parameter and verify if input is being confirmed (see CarbonEvents.h).
+       On the other hand, it can be useful for some applications to react to uncommitted text (for example,
+       to update a status display), as long as it does not disrupt the inline input session. Ideally, wx
+       should add new event types to support advanced text input. For now, I would keep things as they are.
+       
+       However, the code that was being used caused additional problems:
                     UInt32 message = (0  << 8) + ((char)uniChars[pos] );
+       Since it simply truncated the unichar to the last byte, it ended up causing weird bugs with inline
+       input, such as switching to another field when one attempted to insert the character U+4E09 (the kanji
+       for "three"), because it was truncated to 09 (kTabCharCode), which was later "converted" to WXK_TAB
+       (still 09) in wxMacTranslateKey; or triggering the default button when one attempted to insert U+840D
+       (the kanji for "name"), which got truncated to 0D and interpreted as a carriage return keypress.
+       Note that even single-byte characters could have been misinterpreted, since MacRoman charcodes only
+       overlap with Unicode within the (7-bit) ASCII range.
+       But simply passing a NUL charcode would disable text updated events, because wxTextCtrl::OnChar checks
+       for codes within a specific range. Therefore I went for the solution seen above, which keeps ASCII
+       characters as they are and replaces the rest with '?', ensuring that update events are triggered.
+       It would be better to change wxTextCtrl::OnChar to look at the actual unicode character instead, but
+       I don't have time to look into that right now.
+               -- CL
+*/
                     if ( wxTheApp->MacSendCharEvent(
                                                     focus , message , 0 , when , 0 , 0 , uniChars[pos] ) )
                     {
@@ -911,10 +962,6 @@ void wxWindowMac::Init()
     m_frozenness = 0 ;
     m_macAlpha = 255 ;
 
-#if WXWIN_COMPATIBILITY_2_4
-    m_backgroundTransparent = false;
-#endif
-
 #if wxMAC_USE_CORE_GRAPHICS
     m_cgContextRef = NULL ;
 #endif