X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7205570233ce8420b71fa5df368054c8953ff0e4..a174f139e105c38ae852104eb6a894b3a0d88e07:/src/mac/carbon/uma.cpp?ds=sidebyside diff --git a/src/mac/carbon/uma.cpp b/src/mac/carbon/uma.cpp index 60b61374a0..91203d7176 100644 --- a/src/mac/carbon/uma.cpp +++ b/src/mac/carbon/uma.cpp @@ -1,6 +1,7 @@ #include "wx/defs.h" #include "wx/dc.h" #include "wx/mac/uma.h" +#include #ifndef __DARWIN__ #include @@ -12,6 +13,8 @@ // windows manager, control manager, navigation services etc. are // present +#define wxUSE_MLTE 0 + static bool sUMAHasAppearance = false ; static long sUMAAppearanceVersion = 0 ; extern int gAGABackgroundColor ; @@ -34,6 +37,9 @@ void UMACleanupToolbox() { NavUnload() ; } +#if wxUSE_MLTE + TXNTerminateTextension( ) ; +#endif } void UMAInitToolbox( UInt16 inMoreMastersCalls ) { @@ -89,6 +95,15 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls ) { NavLoad() ; } + +#if wxUSE_MLTE + TXNMacOSPreferredFontDescription defaults; + defaults.fontID = kFontIDGeneva ; + defaults.pointSize = (10 << 16) ; + defaults.fontStyle = kTXNDefaultFontStyle; + defaults.encoding = kTXNSystemDefaultEncoding; + TXNInitTextension(&defaults, 1, (kTXNAlwaysUseQuickDrawTextMask | kTXNWantMoviesMask | kTXNWantSoundMask | kTXNWantGraphicsMask)); +#endif } // process manager @@ -381,8 +396,10 @@ void UMAGetWTitleC( WindowRef inWindowRef , char *title ) 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 ) ; @@ -392,7 +409,7 @@ void UMAActivateControl( ControlHandle inControl ) Rect ctrlBounds ; InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; } - } + } } void UMADrawControl( ControlHandle inControl ) @@ -400,13 +417,12 @@ 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 ) @@ -432,7 +448,7 @@ void UMASizeControl( ControlHandle inControl , short x , short y ) SetControlVisibility( inControl , false , false ) ; Rect ctrlBounds ; InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; - } + } ::SizeControl( inControl , x , y ) ; if ( visible ) { SetControlVisibility( inControl , true , false ) ; @@ -443,8 +459,8 @@ void UMASizeControl( 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 ) ; @@ -454,7 +470,6 @@ void UMADeactivateControl( ControlHandle inControl ) Rect ctrlBounds ; InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; } - } } // shows the control and adds the region to the update region void UMAShowControl (ControlHandle inControl) @@ -464,6 +479,13 @@ 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, @@ -475,7 +497,6 @@ OSErr UMASetKeyboardFocus (WindowPtr inWindow, SetPortWindowPort( inWindow ) ; - SetOrigin( 0 , 0 ) ; err = SetKeyboardFocus( inWindow , inControl , inPart ) ; SetPort( port ) ; return err ; @@ -527,7 +548,6 @@ void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate ) GrafPtr port ; GetPort( &port ) ; SetPortWindowPort( inWindowRef ) ; - SetOrigin( 0 , 0 ) ; HiliteWindow( inWindowRef , inActivate ) ; ControlHandle control = NULL ; ::GetRootControl( inWindowRef , & control ) ; @@ -546,3 +566,30 @@ OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) return ::DrawThemePlacard( inRect , inState ) ; } +static OSStatus helpMenuStatus = noErr ; +static MenuRef helpMenuHandle = NULL ; +static MenuItemIndex firstCustomItemIndex = 0 ; + +OSStatus UMAGetHelpMenu( + MenuRef * outHelpMenu, + MenuItemIndex * outFirstCustomItemIndex) +{ +#if TARGET_CARBON + return HMGetHelpMenu( outHelpMenu , outFirstCustomItemIndex ) ; +#else + if ( helpMenuHandle == NULL ) + { + helpMenuStatus = HMGetHelpMenuHandle( &helpMenuHandle ) ; + if ( helpMenuStatus == noErr ) + { + firstCustomItemIndex = CountMenuItems( helpMenuHandle ) + 1 ; + } + } + if ( outFirstCustomItemIndex ) + { + *outFirstCustomItemIndex = firstCustomItemIndex ; + } + *outHelpMenu = helpMenuHandle ; + return helpMenuStatus ; +#endif +}