]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/uma.cpp
activate new xpm handler under Classic Mac OS after xpm handler fixes
[wxWidgets.git] / src / mac / carbon / uma.cpp
index f95b4c52bd0425d79cc228e962f2fdebd140d47f..3be88ef8ec9c288a3a44f0d037d83e1f1bdb668a 100644 (file)
@@ -1,11 +1,20 @@
-#include <wx/mac/uma.h>
-#include <wx/mac/aga.h>
+#include "wx/defs.h"
+#include "wx/dc.h"
+#include "wx/mac/uma.h"
+#include "wx/mac/aga.h"
 
-
-#include "Navigation.h"
+#ifdef __UNIX__
+  #include <Carbon/Carbon.h>
+#else
+  #include <Navigation.h>
+#endif
 
 // init
 
+#if !TARGET_CARBON
+#define        GetControlOwner( control ) (**control).contrlOwner
+#endif
+
 static bool    sUMAHasAppearance = false ;
 static long sUMAAppearanceVersion = 0 ;
 extern int gAGABackgroundColor ;
@@ -75,10 +84,16 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls )
 #endif // UMA_USE_WINDOWMGR
 #endif
                
+#ifndef __UNIX__
+#if TARGET_CARBON
+// Call currently implicitely done :           InitFloatingWindows() ;
+#else
        if ( sUMAHasWindowManager )
                InitFloatingWindows() ;
        else
                InitWindows();
+#endif
+#endif
 
        if ( NavServicesAvailable() )
        {
@@ -387,13 +402,22 @@ void                      UMASetWTitleC( WindowRef inWindowRef , const char *title )
        Str255  ptitle ;
        strncpy( (char*)ptitle , title , 96 ) ;
        ptitle[96] = 0 ;
+#if TARGET_CARBON
+       c2pstrcpy( ptitle, (char *)ptitle ) ;
+#else
        c2pstr( (char*)ptitle ) ;
+#endif
        SetWTitle( inWindowRef , ptitle ) ;
 }
+
 void                   UMAGetWTitleC( WindowRef inWindowRef , char *title ) 
 {
        GetWTitle( inWindowRef , (unsigned char*)title ) ;
+#if TARGET_CARBON
+       p2cstrcpy( title, (unsigned char *)title ) ;
+#else
        p2cstr( (unsigned char*)title ) ;
+#endif
 }
 
 void                   UMAShowWindow( WindowRef inWindowRef ) 
@@ -433,6 +457,8 @@ void                        UMACloseWindow(WindowRef inWindowRef)
 
 void UMAActivateControl( ControlHandle inControl ) 
 {
+                       RgnHandle updateRgn = NewRgn() ;
+                       GetWindowUpdateRgn( GetControlOwner(inControl) , updateRgn ) ;
 #if UMA_USE_APPEARANCE
        if ( UMAHasAppearance() )
        {
@@ -448,10 +474,13 @@ void UMAActivateControl( ControlHandle inControl )
        {
        }
 #endif
+                       InvalRgn( updateRgn ) ;
 }
 
 void UMADrawControl( ControlHandle inControl ) 
 {
+                       RgnHandle updateRgn = NewRgn() ;
+                       GetWindowUpdateRgn( GetControlOwner(inControl) , updateRgn ) ;
 #if UMA_USE_APPEARANCE
        if ( UMAHasAppearance() )
        {
@@ -467,10 +496,13 @@ void UMADrawControl( ControlHandle inControl )
        {
        }
 #endif
+                       InvalRgn( updateRgn ) ;
 }
 
 void UMAMoveControl( ControlHandle inControl , short x , short y ) 
 {
+                       RgnHandle updateRgn = NewRgn() ;
+                       GetWindowUpdateRgn( GetControlOwner(inControl) , updateRgn ) ;
 #if UMA_USE_APPEARANCE
        if ( UMAHasAppearance() )
        {
@@ -486,10 +518,13 @@ void UMAMoveControl( ControlHandle inControl , short x , short y )
        {
        }
 #endif
+                       InvalRgn( updateRgn ) ;
 }
 
 void UMASizeControl( ControlHandle inControl , short x , short y ) 
 {
+                       RgnHandle updateRgn = NewRgn() ;
+                       GetWindowUpdateRgn( GetControlOwner(inControl) , updateRgn ) ;
 #if UMA_USE_APPEARANCE
        if ( UMAHasAppearance() )
        {
@@ -505,10 +540,13 @@ void UMASizeControl( ControlHandle inControl , short x , short y )
        {
        }
 #endif
+                       InvalRgn( updateRgn ) ;
 }
 
 void UMADeactivateControl( ControlHandle inControl ) 
 {
+                       RgnHandle updateRgn = NewRgn() ;
+                       GetWindowUpdateRgn( GetControlOwner(inControl) , updateRgn ) ;
 #if UMA_USE_APPEARANCE
        if ( UMAHasAppearance() )
        {
@@ -524,6 +562,7 @@ void UMADeactivateControl( ControlHandle inControl )
        {
        }
 #endif
+                       InvalRgn( updateRgn ) ;
 }
 
 void                   UMASetThemeWindowBackground             (WindowRef                              inWindow,
@@ -620,6 +659,8 @@ void UMADisposeControl (ControlHandle                       theControl)
 void UMAHiliteControl  (ControlHandle                  theControl,
                                                                 ControlPartCode                hiliteState)
                                                                 {
+                       RgnHandle updateRgn = NewRgn() ;
+                       GetWindowUpdateRgn( GetControlOwner(theControl) , updateRgn ) ;
        if ( UMAHasAppearance() )
        {
        ::HiliteControl( theControl , hiliteState ) ;
@@ -628,11 +669,14 @@ void UMAHiliteControl     (ControlHandle                  theControl,
    {
        ::HiliteControl( theControl , hiliteState ) ;
        }
+                       InvalRgn( updateRgn ) ;
 }
 
 
 void UMAShowControl                                            (ControlHandle                  theControl)
 {
+                       RgnHandle updateRgn = NewRgn() ;
+                       GetWindowUpdateRgn( GetControlOwner(theControl) , updateRgn ) ;
        if ( UMAHasAppearance() )
        {
        ::ShowControl( theControl ) ;
@@ -641,6 +685,7 @@ void UMAShowControl                                         (ControlHandle                  theControl)
    {
        ::ShowControl( theControl ) ;
    }
+                       InvalRgn( updateRgn ) ;
 }
 
 
@@ -648,11 +693,11 @@ void UMAHideControl                                               (ControlHandle                  theControl)
 {
        if ( UMAHasAppearance() )
        {
-       ::HideControl( theControl ) ;
+               ::HideControl( theControl ) ;
    }
    else
    {
-       ::HideControl( theControl ) ;
+               ::HideControl( theControl ) ;
    }
 }
 
@@ -893,6 +938,8 @@ void UMAIdleControls                                        (WindowPtr                              inWindow)
 
 void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn ) 
 {
+                       RgnHandle updateRgn = NewRgn() ;
+                       GetWindowUpdateRgn( inWindow , updateRgn ) ;
 #if UMA_USE_APPEARANCE
        if ( UMAHasAppearance() )
        {
@@ -908,6 +955,7 @@ void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn )
        {
        }
 #endif
+                       InvalRgn( updateRgn ) ;
 }
 
 OSErr UMAGetRootControl( WindowPtr inWindow , ControlHandle *outControl ) 
@@ -1339,33 +1387,42 @@ void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate )
        {
 //             bool isHighlighted = IsWindowHighlited( inWindowRef ) ;
 //             if ( inActivate != isHightlited )
-                               HiliteWindow( inWindowRef , inActivate ) ;
-                               ControlHandle control = NULL ;
-                               UMAGetRootControl( inWindowRef , & control ) ;
-                               if ( control )
-                               {
-                                       if ( inActivate )
-                                               UMAActivateControl( control ) ;
-                                       else
-                                               UMADeactivateControl( control ) ;
-                               }       
+               GrafPtr port ;
+               GetPort( &port ) ;
+#if TARGET_CARBON
+               SetPort( GetWindowPort( inWindowRef ) ) ;
+#else
+               SetPort( inWindowRef ) ;
+#endif
+               SetOrigin( 0 , 0 ) ;
+               HiliteWindow( inWindowRef , inActivate ) ;
+               ControlHandle control = NULL ;
+               UMAGetRootControl( inWindowRef , & control ) ;
+               if ( control )
+               {
+                       if ( inActivate )
+                               UMAActivateControl( control ) ;
+                       else
+                               UMADeactivateControl( control ) ;
+               }       
+               SetPort( port ) ;
        }
 }
 OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) 
 {
 #if UMA_USE_APPEARANCE
-       if ( UMAHasAppearance() )
-       {
-               ::DrawThemePlacard( inRect , inState ) ;
-   }
-   else
+  if ( UMAHasAppearance() )
+  {
+    ::DrawThemePlacard( inRect , inState ) ;
+  }
+  else
 #endif
 #if !TARGET_CARBON
-   {
-   }
+  {
+  }
 #else
-       {
-       }
+  {
+  }
 #endif
 }