X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e40298d54ecd5b109222a7c60aa2ef084a304d69..550e6c014ca85140969ab48c22c684755b4e9dce:/src/mac/uma.cpp diff --git a/src/mac/uma.cpp b/src/mac/uma.cpp index 59daa769db..40fc28f1d6 100644 --- a/src/mac/uma.cpp +++ b/src/mac/uma.cpp @@ -1,3 +1,14 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: uma.cpp +// Purpose: UMA support +// Author: Stefan Csomor +// Modified by: +// Created: 04/01/98 +// RCS-ID: $Id$ +// Copyright: (c) Stefan Csomor +// Licence: The wxWindows licence +///////////////////////////////////////////////////////////////////////////// + #include "wx/defs.h" #include "wx/dc.h" #include @@ -189,10 +200,8 @@ MenuRef UMANewMenu( SInt16 id , const wxString& title ) wxString str = wxStripMenuCodes( title ) ; MenuRef menu ; #if TARGET_CARBON - CFStringRef cfs = wxMacCreateCFString( str ) ; CreateNewMenu( id , 0 , &menu ) ; - SetMenuTitleWithCFString( menu , cfs ) ; - CFRelease( cfs ) ; + SetMenuTitleWithCFString( menu , wxMacCFStringHolder(str) ) ; #else Str255 ptitle ; wxMacStringToPascal( str , ptitle ) ; @@ -205,9 +214,7 @@ void UMASetMenuTitle( MenuRef menu , const wxString& title ) { wxString str = wxStripMenuCodes( title ) ; #if TARGET_CARBON - CFStringRef cfs = wxMacCreateCFString( str ) ; - SetMenuTitleWithCFString( menu , cfs ) ; - CFRelease( cfs ) ; + SetMenuTitleWithCFString( menu , wxMacCFStringHolder(str) ) ; #else Str255 ptitle ; wxMacStringToPascal( str , ptitle ) ; @@ -219,9 +226,7 @@ void UMASetMenuItemText( MenuRef menu, MenuItemIndex item, const wxString& tit { wxString str = wxStripMenuCodes( title ) ; #if TARGET_CARBON - CFStringRef cfs = wxMacCreateCFString( str ) ; - SetMenuItemTextWithCFString( menu , item , cfs ) ; - CFRelease( cfs ) ; + SetMenuItemTextWithCFString( menu , item , wxMacCFStringHolder(str) ) ; #else Str255 ptitle ; wxMacStringToPascal( str , ptitle ) ; @@ -437,11 +442,12 @@ void UMAInsertMenuItem( MenuRef menu , const wxString& title , MenuItemIndex ite // quickdraw +#if !TARGET_CARBON + int gPrOpenCounter = 0 ; -OSStatus UMAPrOpen(void *macPrintSession) +OSStatus UMAPrOpen() { -#if !TARGET_CARBON OSErr err = noErr ; ++gPrOpenCounter ; if ( gPrOpenCounter == 1 ) @@ -451,25 +457,10 @@ OSStatus UMAPrOpen(void *macPrintSession) wxASSERT( err == noErr ) ; } return err ; -#else - OSStatus err = noErr ; - ++gPrOpenCounter ; - if ( gPrOpenCounter == 1 ) - { - #if PM_USE_SESSION_APIS - err = PMCreateSession((PMPrintSession *)macPrintSession) ; - #else - err = PMBegin() ; - #endif - wxASSERT( err == noErr ) ; - } - return err ; -#endif } -OSStatus UMAPrClose(void *macPrintSession) +OSStatus UMAPrClose() { -#if !TARGET_CARBON OSErr err = noErr ; wxASSERT( gPrOpenCounter >= 1 ) ; if ( gPrOpenCounter == 1 ) @@ -480,25 +471,8 @@ OSStatus UMAPrClose(void *macPrintSession) } --gPrOpenCounter ; return err ; -#else - OSStatus err = noErr ; - wxASSERT( gPrOpenCounter >= 1 ) ; - if ( gPrOpenCounter == 1 ) - { - #if PM_USE_SESSION_APIS - err = PMRelease(*(PMPrintSession *)macPrintSession) ; - *(PMPrintSession *)macPrintSession = kPMNoReference; - #else - err = PMEnd() ; - #endif - } - --gPrOpenCounter ; - return err ; -#endif } -#if !TARGET_CARBON - pascal QDGlobalsPtr GetQDGlobalsPtr (void) ; pascal QDGlobalsPtr GetQDGlobalsPtr (void) { @@ -558,17 +532,15 @@ void UMADisposeWindow( WindowRef inWindowRef ) DisposeWindow( inWindowRef ) ; } -void UMASetWTitleC( WindowRef inWindowRef , const char *title ) +void UMASetWTitle( WindowRef inWindowRef , const wxString& title ) { - Str255 ptitle ; - strncpy( (char*)ptitle , title , 96 ) ; - ptitle[96] = 0 ; #if TARGET_CARBON - c2pstrcpy( ptitle, (char *)ptitle ) ; + SetWindowTitleWithCFString( inWindowRef , wxMacCFStringHolder(title) ) ; #else - c2pstr( (char*)ptitle ) ; -#endif + Str255 ptitle ; + wxMacStringToPascal( title , ptitle ) ; SetWTitle( inWindowRef , ptitle ) ; +#endif } void UMAGetWTitleC( WindowRef inWindowRef , char *title ) @@ -583,6 +555,17 @@ void UMAGetWTitleC( WindowRef inWindowRef , char *title ) // appearance additions +void UMASetControlTitle( ControlHandle inControl , const wxString& title ) +{ +#if TARGET_CARBON + SetControlTitleWithCFString( inControl , wxMacCFStringHolder(title) ) ; +#else + Str255 ptitle ; + wxMacStringToPascal( title , ptitle ) ; + SetControlTitle( inControl , ptitle ) ; +#endif +} + void UMAActivateControl( ControlHandle inControl ) { // we have to add the control after again to the update rgn @@ -795,7 +778,7 @@ void wxMacPortStateHelper::Setup( GrafPtr newport ) { GetPort( &m_oldPort ) ; SetPort( newport ) ; - wxASSERT_MSG( m_clip == NULL , "Cannot call setup twice" ) ; + wxASSERT_MSG( m_clip == NULL , wxT("Cannot call setup twice") ) ; m_clip = NewRgn() ; GetClip( m_clip ); m_textFont = GetPortTextFont( (CGrafPtr) newport);