#include "wx/mac/uma.h"
#include "wx/mac/aga.h"
-#ifdef __UNIX__
- #include <Carbon/Carbon.h>
-#else
+#ifndef __DARWIN__
#include <Navigation.h>
#endif
#endif // UMA_USE_WINDOWMGR
#endif
-#ifndef __UNIX__
+#ifndef __DARWIN__
#if TARGET_CARBON
// Call currently implicitely done : InitFloatingWindows() ;
#else
int gPrOpenCounter = 0 ;
-OSStatus UMAPrOpen()
+#if TARGET_CARBON && PM_USE_SESSION_APIS
+OSStatus UMAPrOpen(PMPrintSession *macPrintSession)
+#else
+OSStatus UMAPrOpen()
+#endif
{
#if !TARGET_CARBON
OSErr err = noErr ;
++gPrOpenCounter ;
if ( gPrOpenCounter == 1 )
{
- err = PMBegin() ;
+ #if PM_USE_SESSION_APIS
+ err = PMCreateSession(macPrintSession) ;
+ #else
+ err = PMBegin() ;
+ #endif
wxASSERT( err == noErr ) ;
}
return err ;
#endif
}
-OSStatus UMAPrClose()
+#if TARGET_CARBON && PM_USE_SESSION_APIS
+OSStatus UMAPrClose(PMPrintSession *macPrintSession)
+#else
+OSStatus UMAPrClose()
+#endif
{
#if !TARGET_CARBON
OSErr err = noErr ;
wxASSERT( gPrOpenCounter >= 1 ) ;
if ( gPrOpenCounter == 1 )
{
- err = PMEnd() ;
+ #if PM_USE_SESSION_APIS
+ err = PMRelease(*macPrintSession) ;
+ *macPrintSession = kPMNoReference;
+ #else
+ err = PMEnd() ;
+ #endif
}
--gPrOpenCounter ;
return err ;
void UMAShowWindow( WindowRef inWindowRef )
{
ShowWindow( inWindowRef ) ;
+
}
void UMAHideWindow( WindowRef inWindowRef )
void UMAActivateControl( ControlHandle inControl )
{
- WindowRef theWindow = GetControlOwner(inControl) ;
- RgnHandle updateRgn = NewRgn() ;
-#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332)
- GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ;
-#else
- GetWindowUpdateRgn( theWindow , updateRgn ) ;
-#endif
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() )
- {
+ {
+ if ( !UMAIsControlActive( inControl ) )
+ {
+ bool visible = IsControlVisible( inControl ) ;
+ if ( visible )
+ SetControlVisibility( inControl , false , false ) ;
::ActivateControl( inControl ) ;
+ if ( visible ) {
+ SetControlVisibility( inControl , true , false ) ;
+ Rect ctrlBounds ;
+ InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
+ }
+ }
}
else
#endif
{
}
#endif
-#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332)
- InvalWindowRgn( theWindow, updateRgn) ;
-#else
- InvalRgn( updateRgn ) ;
-#endif
}
void UMADrawControl( ControlHandle inControl )
{
WindowRef theWindow = GetControlOwner(inControl) ;
RgnHandle updateRgn = NewRgn() ;
-#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332)
+#if TARGET_CARBON
GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ;
#else
GetWindowUpdateRgn( theWindow , updateRgn ) ;
#endif
+ Point zero = { 0 , 0 } ;
+ LocalToGlobal( &zero ) ;
+ OffsetRgn( updateRgn , -zero.h , -zero.v ) ;
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() )
{
#else
InvalRgn( updateRgn ) ;
#endif
+ DisposeRgn( updateRgn ) ;
+
}
void UMAMoveControl( ControlHandle inControl , short x , short y )
{
- WindowRef theWindow = GetControlOwner(inControl) ;
- RgnHandle updateRgn = NewRgn() ;
-#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332)
- GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ;
-#else
- GetWindowUpdateRgn( theWindow , updateRgn ) ;
-#endif
-#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() )
{
+ bool visible = UMAIsControlVisible( inControl ) ;
+ if ( visible ) {
+ SetControlVisibility( inControl , false , false ) ;
+ Rect ctrlBounds ;
+ InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
+ }
::MoveControl( inControl , x , y ) ;
+ if ( visible ) {
+ SetControlVisibility( inControl , true , false ) ;
+ Rect ctrlBounds ;
+ InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
+ }
}
- else
-#endif
-#if !TARGET_CARBON
- {
- AGAMoveControl( inControl , x ,y ) ;
- }
-#else
- {
- }
-#endif
-#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332)
- InvalWindowRgn( theWindow, updateRgn) ;
-#else
- InvalRgn( updateRgn ) ;
-#endif
}
void UMASizeControl( ControlHandle inControl , short x , short y )
{
- WindowRef theWindow = GetControlOwner(inControl) ;
- RgnHandle updateRgn = NewRgn() ;
-#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332)
- GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ;
-#else
- GetWindowUpdateRgn( theWindow , updateRgn ) ;
-#endif
-#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() )
{
+ bool visible = UMAIsControlVisible( inControl ) ;
+ if ( visible ) {
+ SetControlVisibility( inControl , false , false ) ;
+ Rect ctrlBounds ;
+ InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
+ }
::SizeControl( inControl , x , y ) ;
+ if ( visible ) {
+ SetControlVisibility( inControl , true , false ) ;
+ Rect ctrlBounds ;
+ InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
+ }
}
- else
-#endif
-#if !TARGET_CARBON
- {
- AGASizeControl( inControl , x ,y ) ;
- }
-#else
- {
- }
-#endif
-#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332)
- InvalWindowRgn( theWindow, updateRgn) ;
-#else
- InvalRgn( updateRgn ) ;
-#endif
-
}
void UMADeactivateControl( ControlHandle inControl )
{
- WindowRef theWindow = GetControlOwner(inControl) ;
- RgnHandle updateRgn = NewRgn() ;
-#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332)
- GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ;
-#else
- GetWindowUpdateRgn( theWindow , updateRgn ) ;
-#endif
-#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() )
{
+ if ( UMAIsControlActive( inControl ) )
+ {
+ bool visible = IsControlVisible( inControl ) ;
+ if ( visible )
+ SetControlVisibility( inControl , false , false ) ;
::DeactivateControl( inControl ) ;
+ if ( visible ) {
+ SetControlVisibility( inControl , true , false ) ;
+ Rect ctrlBounds ;
+ InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
+ }
+ }
}
- else
-#endif
-#if !TARGET_CARBON
- {
- AGADeactivateControl( inControl ) ;
- }
-#else
- {
- }
-#endif
-#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332)
- InvalWindowRgn( theWindow, updateRgn) ;
-#else
- InvalRgn( updateRgn ) ;
-#endif
}
void UMASetThemeWindowBackground (WindowRef inWindow,
void UMAHiliteControl (ControlHandle inControl,
ControlPartCode hiliteState)
{
- WindowRef theWindow = GetControlOwner(inControl) ;
- RgnHandle updateRgn = NewRgn() ;
-#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332)
- GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ;
-#else
- GetWindowUpdateRgn( theWindow , updateRgn ) ;
-#endif
if ( UMAHasAppearance() )
{
::HiliteControl( inControl , hiliteState ) ;
{
::HiliteControl( inControl , hiliteState ) ;
}
-#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332)
- InvalWindowRgn( theWindow, updateRgn) ;
-#else
- InvalRgn( updateRgn ) ;
-#endif
}
+// shows the control and adds the region to the update region
void UMAShowControl (ControlHandle inControl)
{
- WindowRef theWindow = GetControlOwner(inControl) ;
- RgnHandle updateRgn = NewRgn() ;
-#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332)
- GetWindowRegion( theWindow , kWindowUpdateRgn, updateRgn ) ;
-#else
- GetWindowUpdateRgn( theWindow , updateRgn ) ;
-#endif
if ( UMAHasAppearance() )
{
- ::ShowControl( inControl ) ;
+ SetControlVisibility( inControl , true , false ) ;
+ Rect ctrlBounds ;
+ InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
}
- else
- {
- ::ShowControl( inControl ) ;
- }
-#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332)
- InvalWindowRgn( theWindow, updateRgn) ;
-#else
- InvalRgn( updateRgn ) ;
-#endif
}
-
+// Hides the control and adds the region to the update region
void UMAHideControl (ControlHandle inControl)
{
if ( UMAHasAppearance() )
{
return IsControlVisible( inControl ) ;
}
+ else
#endif
+ {
+#if !TARGET_CARBON
+ return (**inControl).contrlVis == 255 ;
+#endif
+ }
return true ;
}
void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn )
{
RgnHandle updateRgn = NewRgn() ;
-#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0332)
+#if TARGET_CARBON
GetWindowRegion( inWindow , kWindowUpdateRgn, updateRgn ) ;
#else
GetWindowUpdateRgn( inWindow , updateRgn ) ;
#endif
+ Point zero = { 0 , 0 } ;
+ LocalToGlobal( &zero ) ;
+ OffsetRgn( updateRgn , -zero.h , -zero.v ) ;
#if UMA_USE_APPEARANCE
if ( UMAHasAppearance() )
{
#else
InvalRgn( updateRgn ) ;
#endif
+ DisposeRgn( updateRgn ) ;
+
}
OSErr UMAGetRootControl( WindowPtr inWindow , ControlHandle *outControl )
{
}
#endif
+ return noErr ;
}