#include <MacTextEditor.h>
#ifndef __DARWIN__
- #include <Navigation.h>
+# include <Navigation.h>
+# if defined(TARGET_CARBON)
+# if PM_USE_SESSION_APIS
+# include <PMCore.h>
+# endif
+# include <PMApplication.h>
+# else
+# include <Printing.h>
+# endif
#endif
// since we have decided that we only support 8.6 upwards we are
#define wxUSE_MLTE 0
+
static bool sUMAHasAppearance = false ;
static long sUMAAppearanceVersion = 0 ;
+static bool sUMAHasAquaLayout = false ;
+static bool sUMASystemInitialized = false ;
+
extern int gAGABackgroundColor ;
bool UMAHasAppearance() { return sUMAHasAppearance ; }
long UMAGetAppearanceVersion() { return sUMAAppearanceVersion ; }
bool UMAHasWindowManager() { return sUMAHasWindowManager ; }
long UMAGetWindowManagerAttr() { return sUMAWindowManagerAttr ; }
+bool UMAHasAquaLayout() { return sUMAHasAquaLayout ; }
+bool UMASystemIsInitialized() { return sUMASystemInitialized ; }
void UMACleanupToolbox()
{
defaults.encoding = kTXNSystemDefaultEncoding;
TXNInitTextension(&defaults, 1, (kTXNAlwaysUseQuickDrawTextMask | kTXNWantMoviesMask | kTXNWantSoundMask | kTXNWantGraphicsMask));
#endif
+ long menuMgrAttr ;
+ Gestalt( gestaltMenuMgrAttr , &menuMgrAttr ) ;
+ if ( menuMgrAttr & gestaltMenuMgrAquaLayoutMask )
+ sUMAHasAquaLayout = true ;
+ sUMASystemInitialized = true ;
+
}
+/*
+Boolean CanUseATSUI()
+ {
+ long result;
+ OSErr err = Gestalt(gestaltATSUVersion, &result);
+ return (err == noErr);
+ }
+*/
// process manager
long UMAGetProcessMode()
{
void UMASetMenuTitle( MenuRef menu , StringPtr title )
{
+/*
#if !TARGET_CARBON
long size = GetHandleSize( (Handle) menu ) ;
const long headersize = 14 ;
SetHandleSize( (Handle) menu , size + (newlen - oldlen ) ) ;
}
#else
+*/
SetMenuTitle( menu , title ) ;
-#endif
+//#endif
}
UInt32 UMAMenuEvent( EventRecord *inEvent )
int gPrOpenCounter = 0 ;
-#if TARGET_CARBON && PM_USE_SESSION_APIS
-OSStatus UMAPrOpen(PMPrintSession *macPrintSession)
-#else
-OSStatus UMAPrOpen()
-#endif
+OSStatus UMAPrOpen(void *macPrintSession)
{
#if !TARGET_CARBON
OSErr err = noErr ;
if ( gPrOpenCounter == 1 )
{
#if PM_USE_SESSION_APIS
- err = PMCreateSession(macPrintSession) ;
+ err = PMCreateSession((PMPrintSession *)macPrintSession) ;
#else
err = PMBegin() ;
#endif
#endif
}
-#if TARGET_CARBON && PM_USE_SESSION_APIS
-OSStatus UMAPrClose(PMPrintSession *macPrintSession)
-#else
-OSStatus UMAPrClose()
-#endif
+OSStatus UMAPrClose(void *macPrintSession)
{
#if !TARGET_CARBON
OSErr err = noErr ;
if ( gPrOpenCounter == 1 )
{
#if PM_USE_SESSION_APIS
- err = PMRelease(*macPrintSession) ;
- *macPrintSession = kPMNoReference;
+ err = PMRelease(*(PMPrintSession *)macPrintSession) ;
+ *(PMPrintSession *)macPrintSession = kPMNoReference;
#else
err = PMEnd() ;
#endif
{
wxASSERT( inWindowRef != NULL ) ;
#if TARGET_CARBON
- return GetWindowPort( inWindowRef ) ;
+ return (GrafPtr) GetWindowPort( inWindowRef ) ;
#else
return (GrafPtr) inWindowRef ;
#endif
void UMAActivateControl( ControlHandle inControl )
{
- if ( !IsControlActive( inControl ) )
- {
+ // we have to add the control after again to the update rgn
+ // otherwise updates get lost
+ if ( !IsControlActive( inControl ) )
+ {
bool visible = IsControlVisible( inControl ) ;
if ( visible )
SetControlVisibility( inControl , false , false ) ;
Rect ctrlBounds ;
InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
}
- }
+ }
}
void UMADrawControl( ControlHandle inControl )
WindowRef theWindow = GetControlOwner(inControl) ;
RgnHandle updateRgn = NewRgn() ;
GetWindowUpdateRgn( theWindow , updateRgn ) ;
- Point zero = { 0 , 0 } ;
- LocalToGlobal( &zero ) ;
- OffsetRgn( updateRgn , -zero.h , -zero.v ) ;
- ::DrawControlInCurrentPort( inControl ) ;
- InvalWindowRgn( theWindow, updateRgn) ;
- DisposeRgn( updateRgn ) ;
-
+ Point zero = { 0 , 0 } ;
+ LocalToGlobal( &zero ) ;
+ OffsetRgn( updateRgn , -zero.h , -zero.v ) ;
+ ::DrawControlInCurrentPort( inControl ) ;
+ InvalWindowRgn( theWindow, updateRgn) ;
+ DisposeRgn( updateRgn ) ;
}
void UMAMoveControl( ControlHandle inControl , short x , short y )
void UMADeactivateControl( ControlHandle inControl )
{
- if ( IsControlActive( inControl ) )
- {
+ // we have to add the control after again to the update rgn
+ // otherwise updates get lost
bool visible = IsControlVisible( inControl ) ;
if ( visible )
SetControlVisibility( inControl , false , false ) ;
Rect ctrlBounds ;
InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
}
- }
}
// shows the control and adds the region to the update region
void UMAShowControl (ControlHandle inControl)
InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
}
+// shows the control and adds the region to the update region
+void UMAHideControl (ControlHandle inControl)
+{
+ SetControlVisibility( inControl , false , false ) ;
+ Rect ctrlBounds ;
+ InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
+}
// keyboard focus
OSErr UMASetKeyboardFocus (WindowPtr inWindow,
ControlHandle inControl,
SetPortWindowPort( inWindow ) ;
- SetOrigin( 0 , 0 ) ;
err = SetKeyboardFocus( inWindow , inControl , inPart ) ;
SetPort( port ) ;
return err ;
GrafPtr port ;
GetPort( &port ) ;
SetPortWindowPort( inWindowRef ) ;
- SetOrigin( 0 , 0 ) ;
HiliteWindow( inWindowRef , inActivate ) ;
ControlHandle control = NULL ;
::GetRootControl( inWindowRef , & control ) ;
return helpMenuStatus ;
#endif
}
+
+wxMacPortStateHelper::wxMacPortStateHelper( GrafPtr newport)
+{
+ m_clip = NULL ;
+ Setup( newport ) ;
+}
+
+wxMacPortStateHelper::wxMacPortStateHelper()
+{
+ m_clip = NULL ;
+}
+
+void wxMacPortStateHelper::Setup( GrafPtr newport )
+{
+ GetPort( &m_oldPort ) ;
+ SetPort( newport ) ;
+ wxASSERT_MSG( m_clip == NULL , "Cannot call setup twice" ) ;
+ m_clip = NewRgn() ;
+ GetClip( m_clip );
+ m_textFont = GetPortTextFont( (CGrafPtr) newport);
+ m_textSize = GetPortTextSize( (CGrafPtr) newport);
+ m_textStyle = GetPortTextFace( (CGrafPtr) newport);
+ m_textMode = GetPortTextMode( (CGrafPtr) newport);
+ GetThemeDrawingState( &m_drawingState ) ;
+ m_currentPort = newport ;
+}
+void wxMacPortStateHelper::Clear()
+{
+ if ( m_clip )
+ {
+ DisposeRgn( m_clip ) ;
+ DisposeThemeDrawingState( m_drawingState ) ;
+ m_clip = NULL ;
+ }
+}
+
+wxMacPortStateHelper::~wxMacPortStateHelper()
+{
+ if ( m_clip )
+ {
+ SetPort( m_currentPort ) ;
+ SetClip( m_clip ) ;
+ DisposeRgn( m_clip ) ;
+ TextFont( m_textFont );
+ TextSize( m_textSize );
+ TextFace( m_textStyle );
+ TextMode( m_textMode );
+ SetThemeDrawingState( m_drawingState , true ) ;
+ SetPort( m_oldPort ) ;
+ }
+}
+