m_dc->MacCleanupPort(&m_ph) ;
}
+wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win )
+{
+ m_formerClip = NewRgn() ;
+ m_newClip = NewRgn() ;
+ GetClip( m_formerClip ) ;
+
+ if ( win )
+ {
+ RgnHandle insidergn = NewRgn() ;
+ int x = 0 , y = 0;
+ wxWindow *parent = win->GetParent() ;
+ parent->MacWindowToRootWindow( &x,&y ) ;
+
+ wxSize size = parent->GetSize() ;
+ SetRectRgn( insidergn , parent->MacGetLeftBorderSize() , parent->MacGetTopBorderSize() ,
+ size.x - parent->MacGetLeftBorderSize() - parent->MacGetRightBorderSize(),
+ size.y - parent->MacGetTopBorderSize() - parent->MacGetBottomBorderSize()) ;
+
+ CopyRgn( (RgnHandle) parent->MacGetVisibleRegion(false).GetWXHRGN() , m_newClip ) ;
+ SectRgn( m_newClip , insidergn , m_newClip ) ;
+ OffsetRgn( m_newClip , x , y ) ;
+ SetClip( m_newClip ) ;
+ DisposeRgn( insidergn ) ;
+ }
+}
+
+wxMacWindowClipper::~wxMacWindowClipper()
+{
+ SetClip( m_formerClip ) ;
+ DisposeRgn( m_newClip ) ;
+ DisposeRgn( m_formerClip ) ;
+}
+
//-----------------------------------------------------------------------------
// Local functions
//-----------------------------------------------------------------------------
void wxDC::DoCrossHair( wxCoord x, wxCoord y )
{
wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
+ wxMacPortSetter helper(this) ;
if (m_pen.GetStyle() != wxTRANSPARENT)
{
wxCoord xc, wxCoord yc )
{
wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
+ wxMacPortSetter helper(this) ;
wxCoord xx1 = XLOG2DEVMAC(x1);
wxCoord yy1 = YLOG2DEVMAC(y1);
double sa, double ea )
{
wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
+ wxMacPortSetter helper(this) ;
Rect r;
double angle = sa - ea; // Order important Mac in opposite direction to wx
PolyHandle polygon = OpenPoly();
- x1 = XLOG2DEVMAC(points[0].x + xoffset);
- y1 = YLOG2DEVMAC(points[0].y + yoffset);
+ x2 = x1 = XLOG2DEVMAC(points[0].x + xoffset);
+ y2 = y1 = YLOG2DEVMAC(points[0].y + yoffset);
::MoveTo(x1,y1);
for (int i = 1; i < n; i++)
if ( 0 )
{
m_macFormerAliasState = IsAntiAliasedTextEnabled(&m_macFormerAliasSize);
- SetAntiAliasedTextEnabled(true, m_scaleY * font->m_macFontSize);
+ SetAntiAliasedTextEnabled(true, SInt16(m_scaleY * font->m_macFontSize));
m_macAliasWasEnabled = true ;
}
&chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ;
wxASSERT_MSG( status == noErr , "couldn't create the layout of the rotated text" );
- if ( abs(angle) > 0 )
+ int iAngle = int( angle );
+ if ( abs(iAngle) > 0 )
{
- Fixed atsuAngle = IntToFixed( angle ) ;
+ Fixed atsuAngle = IntToFixed( iAngle ) ;
ByteCount angleSize = sizeof(Fixed) ;
ATSUAttributeTag rotationTag = kATSULineRotationTag ;
ATSUAttributeValuePtr angleValue = &atsuAngle ;
long yy = YLOG2DEVMAC(y);
#if TARGET_CARBON
bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ;
+ useDrawThemeText = false ;
#endif
MacInstallFont() ;
if ( 0 )
::DrawThemeTextBox( mString,
kThemeCurrentPortFont,
kThemeStateActive,
- true,
+ false,
&frame,
teJustLeft,
nil );
::DrawThemeTextBox( mString,
kThemeCurrentPortFont,
kThemeStateActive,
- true,
+ false,
&frame,
teJustLeft,
nil );
if ( theFont )
{
- wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
-
- if ( font )
- {
- ::TextFont( font->m_macFontNum ) ;
- ::TextSize( YLOG2DEVREL( font->m_macFontSize) ) ;
- ::TextFace( font->m_macFontStyle ) ;
- }
- }
- else
- {
- MacInstallFont() ;
+ // work around the constness
+ *((wxFont*)(&m_font)) = *theFont ;
}
+ MacInstallFont() ;
+
FontInfo fi ;
::GetFontInfo( &fi ) ;
+#if TARGET_CARBON
+ bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ;
+ useGetThemeText = false ;
+#endif
if ( height )
*height = YDEV2LOGREL( fi.descent + fi.ascent ) ;
{
if ( height )
*height += YDEV2LOGREL( fi.descent + fi.ascent + fi.leading ) ;
- curwidth = ::TextWidth( text , laststop , i - laststop ) ;
+#if TARGET_CARBON
+ if ( useGetThemeText )
+ {
+ Point bounds={0,0} ;
+ SInt16 baseline ;
+ CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ;
+ ::GetThemeTextDimensions( mString,
+ kThemeCurrentPortFont,
+ kThemeStateActive,
+ false,
+ &bounds,
+ &baseline );
+ CFRelease( mString ) ;
+ curwidth = bounds.h ;
+ }
+ else
+#endif
+ {
+ curwidth = ::TextWidth( text , laststop , i - laststop ) ;
+ }
if ( curwidth > *width )
*width = XDEV2LOGREL( curwidth ) ;
laststop = i+1 ;
}
i++ ;
}
-
- curwidth = ::TextWidth( text , laststop , i - laststop ) ;
+
+#if TARGET_CARBON
+ if ( useGetThemeText )
+ {
+ Point bounds={0,0} ;
+ SInt16 baseline ;
+ CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ;
+ ::GetThemeTextDimensions( mString,
+ kThemeCurrentPortFont,
+ kThemeStateActive,
+ false,
+ &bounds,
+ &baseline );
+ CFRelease( mString ) ;
+ curwidth = bounds.h ;
+ }
+ else
+#endif
+ {
+ curwidth = ::TextWidth( text , laststop , i - laststop ) ;
+ }
if ( curwidth > *width )
*width = XDEV2LOGREL( curwidth ) ;
}
if ( theFont )
{
+ // work around the constness
+ *((wxFont*)(&m_font)) = formerFont ;
m_macFontInstalled = false ;
}
}
OSStatus status = noErr ;
- Fixed atsuSize = IntToFixed(m_scaleY * font->m_macFontSize) ;
+ Fixed atsuSize = IntToFixed( int(m_scaleY * font->m_macFontSize) ) ;
Style qdStyle = font->m_macFontStyle ;
ATSUFontID atsuFont = font->m_macATSUFontID ;
Pattern gHatchPatterns[] =
{
- { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } ,
- { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } ,
- { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } ,
- { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } ,
- { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } ,
- { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } ,
- { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } ,
+ { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } },
+ { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } },
+ { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } },
+ { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } },
+ { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } },
+ { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } },
+ { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } }
} ;
static void wxMacGetHatchPattern(int hatchStyle, Pattern *pattern)
case wxUSER_DASH :
{
wxDash* dash ;
- int number = m_pen.GetDashes(&dash) ;
// right now we don't allocate larger pixmaps
for ( int i = 0 ; i < 8 ; ++i )
{