wxMacFastPortSetter( const wxDC *dc )
{
wxASSERT( dc->Ok() ) ;
- GetPort( &m_oldPort ) ;
- SetPort( (GrafPtr) dc->m_macPort ) ;
+ m_swapped = QDSwapPort( (GrafPtr) dc->m_macPort , &m_oldPort ) ;
m_clipRgn = NewRgn() ;
GetClip( m_clipRgn ) ;
m_dc = dc ;
}
~wxMacFastPortSetter()
{
- SetPort( (GrafPtr) m_dc->m_macPort ) ;
+ // SetPort( (GrafPtr) m_dc->m_macPort ) ;
SetClip( m_clipRgn ) ;
- SetPort( m_oldPort ) ;
+ if ( m_swapped )
+ SetPort( m_oldPort ) ;
m_dc->MacCleanupPort( NULL ) ;
DisposeRgn( m_clipRgn ) ;
}
private :
+ bool m_swapped ;
RgnHandle m_clipRgn ;
GrafPtr m_oldPort ;
const wxDC* m_dc ;
wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) :
wxMacPortSaver( (GrafPtr) GetWindowPort((WindowRef) win->MacGetTopLevelWindowRef()) )
{
+ m_newPort =(GrafPtr) GetWindowPort((WindowRef) win->MacGetTopLevelWindowRef()) ;
m_formerClip = NewRgn() ;
m_newClip = NewRgn() ;
GetClip( m_formerClip ) ;
wxMacWindowClipper::~wxMacWindowClipper()
{
+ SetPort( m_newPort ) ;
SetClip( m_formerClip ) ;
DisposeRgn( m_newClip ) ;
DisposeRgn( m_formerClip ) ;
}
+wxMacWindowStateSaver::wxMacWindowStateSaver( const wxWindow* win ) :
+ wxMacWindowClipper( win )
+{
+ // the port is already set at this point
+ m_newPort =(GrafPtr) GetWindowPort((WindowRef) win->MacGetTopLevelWindowRef()) ;
+ GetThemeDrawingState( &m_themeDrawingState ) ;
+}
+
+wxMacWindowStateSaver::~wxMacWindowStateSaver()
+{
+ SetPort( m_newPort ) ;
+ SetThemeDrawingState( m_themeDrawingState , true ) ;
+}
+
//-----------------------------------------------------------------------------
// Local functions
//-----------------------------------------------------------------------------
{
wxMacFastPortSetter helper(this) ;
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
- m_clipping = FALSE;
+ ResetClipping();
}
void wxDC::DoGetSizeMM( int* width, int* height ) const
{
// this is a bit artificial, but we need to force wxDC to think
// the pen has changed
- wxPen* pen = & GetPen();
- wxPen tempPen;
- m_pen = tempPen;
- SetPen(* pen);
+ wxPen pen(GetPen());
+ m_pen = wxNullPen;
+ SetPen(pen);
}
}
OSStatus status = noErr ;
ATSUTextLayout atsuLayout ;
UniCharCount chars = str.Length() ;
+ UniChar* ubuf = NULL ;
+#if SIZEOF_WCHAR_T == 4
+ wxMBConvUTF16BE converter ;
#if wxUSE_UNICODE
- status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) (const wxChar*) str , 0 , str.Length() , str.Length() , 1 ,
- &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ;
+ size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
+ ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
+ converter.WC2MB( (char*) ubuf , str.wc_str(), unicharlen + 2 ) ;
+#else
+ const wxWCharBuffer wchar = str.wc_str( wxConvLocal ) ;
+ size_t unicharlen = converter.WC2MB( NULL , wchar.data() , 0 ) ;
+ ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
+ converter.WC2MB( (char*) ubuf , wchar.data() , unicharlen + 2 ) ;
+#endif
+ chars = unicharlen / 2 ;
+#else
+#if wxUSE_UNICODE
+ ubuf = (UniChar*) str.wc_str() ;
#else
wxWCharBuffer wchar = str.wc_str( wxConvLocal ) ;
- int wlen = wxWcslen( wchar.data() ) ;
- status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) wchar.data() , 0 , wlen , wlen , 1 ,
- &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ;
+ chars = wxWcslen( wchar.data() ) ;
+ ubuf = (UniChar*) wchar.data() ;
+#endif
#endif
+
+ status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 ,
+ &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ;
+
wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the rotated text") );
int iAngle = int( angle );
int drawX = XLOG2DEVMAC(x) ;
CalcBoundingBox(XDEV2LOG(rect.left), YDEV2LOG(rect.top) );
CalcBoundingBox(XDEV2LOG(rect.right), YDEV2LOG(rect.bottom) );
::ATSUDisposeTextLayout(atsuLayout);
+#if SIZEOF_WCHAR_T == 4
+ free( ubuf ) ;
+#endif
}
void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
wxCHECK_RET(Ok(), wxT("Invalid DC"));
wxMacFastPortSetter helper(this) ;
Rect rect = { -31000 , -31000 , 31000 , 31000 } ;
- if (m_backgroundBrush.GetStyle() != wxTRANSPARENT)
+ if ( m_backgroundBrush.Ok() && m_backgroundBrush.GetStyle() != wxTRANSPARENT)
{
::PenNormal() ;
- //MacInstallBrush() ;
MacSetupBackgroundForCurrentPort( m_backgroundBrush ) ;
::EraseRect( &rect ) ;
}
void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush& background )
{
Pattern whiteColor ;
- switch( background.MacGetBrushKind() )
+ if ( background.Ok() )
{
- case kwxMacBrushTheme :
+ switch( background.MacGetBrushKind() )
{
- ::SetThemeBackground( background.MacGetTheme() , wxDisplayDepth() , true ) ;
- break ;
- }
- case kwxMacBrushThemeBackground :
- {
- Rect extent ;
- ThemeBackgroundKind bg = background.MacGetThemeBackground( &extent ) ;
- ::ApplyThemeBackground( bg , &extent ,kThemeStateActive , wxDisplayDepth() , true ) ;
- break ;
- }
- case kwxMacBrushColour :
- {
- ::RGBBackColor( &MAC_WXCOLORREF( background.GetColour().GetPixel()) );
- int brushStyle = background.GetStyle();
- if (brushStyle == wxSOLID)
- ::BackPat(GetQDGlobalsWhite(&whiteColor));
- else if (IS_HATCH(brushStyle))
+ case kwxMacBrushTheme :
{
- Pattern pat ;
- wxMacGetPattern(brushStyle, &pat);
- ::BackPat(&pat);
+ ::SetThemeBackground( background.MacGetTheme() , wxDisplayDepth() , true ) ;
+ break ;
}
- else
+ case kwxMacBrushThemeBackground :
{
- ::BackPat(GetQDGlobalsWhite(&whiteColor));
+ Rect extent ;
+ ThemeBackgroundKind bg = background.MacGetThemeBackground( &extent ) ;
+ ::ApplyThemeBackground( bg , &extent ,kThemeStateActive , wxDisplayDepth() , true ) ;
+ break ;
+ }
+ case kwxMacBrushColour :
+ {
+ ::RGBBackColor( &MAC_WXCOLORREF( background.GetColour().GetPixel()) );
+ int brushStyle = background.GetStyle();
+ if (brushStyle == wxSOLID)
+ ::BackPat(GetQDGlobalsWhite(&whiteColor));
+ else if (IS_HATCH(brushStyle))
+ {
+ Pattern pat ;
+ wxMacGetPattern(brushStyle, &pat);
+ ::BackPat(&pat);
+ }
+ else
+ {
+ ::BackPat(GetQDGlobalsWhite(&whiteColor));
+ }
+ break ;
}
- break ;
}
}
}