#include "wx/dcmemory.h"
#include "wx/region.h"
#include "wx/image.h"
+#include "wx/log.h"
#if __MSL__ >= 0x6000
const short kEmulatedMode = -1 ;
const short kUnsupportedMode = -2 ;
-#define wxMAC_EXPERIMENTAL_PATTERN 0
-
wxMacPortSetter::wxMacPortSetter( const wxDC* dc ) :
m_ph( (GrafPtr) dc->m_macPort )
{
{
Pattern blackColor ;
::PenPat(GetQDGlobalsBlack(&blackColor));
- DisposePixMap( (PixMapHandle) m_macForegroundPixMap ) ;
+ DisposePixPat( (PixPatHandle) m_macForegroundPixMap ) ;
m_macForegroundPixMap = NULL ;
}
if ( m_macBackgroundPixMap )
{
Pattern whiteColor ;
::BackPat(GetQDGlobalsWhite(&whiteColor));
- DisposePixMap( (PixMapHandle) m_macBackgroundPixMap ) ;
+ DisposePixPat( (PixPatHandle) m_macBackgroundPixMap ) ;
m_macBackgroundPixMap = NULL ;
}
}
int wxDC::GetDepth() const
{
- return wxDisplayDepth() ;
+ if ( IsPortColor( (CGrafPtr) m_macPort ) )
+ {
+ return ( (**GetPortPixMap( (CGrafPtr) m_macPort)).pixelSize ) ;
+ }
+ return 1 ;
}
void wxDC::ComputeScaleAndOrigin()
m_macPenInstalled = false ;
}
-void wxDC::DoFloodFill( wxCoord x, wxCoord y, const wxColour& col,
- int style )
+extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
+ const wxColour & col, int style);
+
+bool wxDC::DoFloodFill(wxCoord x, wxCoord y,
+ const wxColour& col, int style)
{
+ return wxDoFloodFill(this, x, y, col, style);
}
bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const
if (m_pen.GetStyle() != wxTRANSPARENT)
{
- MacInstallPen() ;
wxCoord xx1 = XLOG2DEVMAC(x);
wxCoord yy1 = YLOG2DEVMAC(y);
-
- ::MoveTo(xx1,yy1);
- ::LineTo(xx1+1, yy1+1);
+ RGBColor pencolor = MAC_WXCOLORREF( m_pen.GetColour().GetPixel());
+ ::SetCPixel( xx1,yy1,&pencolor) ;
+ CalcBoundingBox(x, y);
}
}
}
void wxDC::DoDrawPolygon(int n, wxPoint points[],
- wxCoord xoffset, wxCoord yoffset,
- int fillStyle )
+ wxCoord xoffset, wxCoord yoffset,
+ int fillStyle )
{
wxCHECK_RET(Ok(), wxT("Invalid DC"));
wxMacPortSetter helper(this) ;
if ( LockPixels(bmappixels) )
{
wxMacPortSetter helper(this) ;
- RGBColor tempColor ;
if ( source->GetDepth() == 1 )
{
{
wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") );
- if (angle == 0.0)
+ if (angle == 0.0 )
{
DrawText(str, x, y);
return;
}
+ if ( str.Length() == 0 )
+ return ;
+
wxMacPortSetter helper(this) ;
MacInstallFont() ;
&chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ;
wxASSERT_MSG( status == noErr , "couldn't create the layout of the rotated text" );
- Fixed atsuAngle = IntToFixed( angle ) ;
- ByteCount angleSize = sizeof(Fixed) ;
- ATSUAttributeTag rotationTag = kATSULineRotationTag ;
- ATSUAttributeValuePtr angleValue = &atsuAngle ;
- status = ::ATSUSetLayoutControls(atsuLayout , 1 , &rotationTag , &angleSize , &angleValue ) ;
+ if ( abs(angle) > 0 )
+ {
+ Fixed atsuAngle = IntToFixed( angle ) ;
+ ByteCount angleSize = sizeof(Fixed) ;
+ ATSUAttributeTag rotationTag = kATSULineRotationTag ;
+ ATSUAttributeValuePtr angleValue = &atsuAngle ;
+ status = ::ATSUSetLayoutControls(atsuLayout , 1 , &rotationTag , &angleSize , &angleValue ) ;
+ }
- status = ::ATSUDrawText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
- IntToFixed(XLOG2DEVMAC(x) ) , IntToFixed(YLOG2DEVMAC(y) ) );
+ status = ::ATSUDrawText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
+ IntToFixed(XLOG2DEVMAC(x) ) , IntToFixed(YLOG2DEVMAC(y) ) );
wxASSERT_MSG( status == noErr , "couldn't draw the rotated text" );
Rect rect ;
status = ::ATSUMeasureTextImage( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
}
void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
-{
+{
wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
wxMacPortSetter helper(this) ;
long xx = XLOG2DEVMAC(x);
long yy = YLOG2DEVMAC(y);
-
+#if TARGET_CARBON
+ bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ;
+#endif
MacInstallFont() ;
if ( 0 )
{
FontInfo fi ;
::GetFontInfo( &fi ) ;
- yy += fi.ascent ;
+#if TARGET_CARBON
+ if ( !useDrawThemeText )
+#endif
+ yy += fi.ascent ;
+
::MoveTo( xx , yy );
if ( m_backgroundMode == wxTRANSPARENT )
{
int i = 0 ;
int line = 0 ;
- while( i < length )
- {
- if( text[i] == 13 || text[i] == 10)
- {
- ::DrawText( text , laststop , i - laststop ) ;
- line++ ;
- ::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) );
- laststop = i+1 ;
- }
- i++ ;
+ {
+
+ while( i < length )
+ {
+ if( text[i] == 13 || text[i] == 10)
+ {
+#if TARGET_CARBON
+ if ( useDrawThemeText )
+ {
+ Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 1000 } ;
+ CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ;
+ ::DrawThemeTextBox( mString,
+ kThemeCurrentPortFont,
+ kThemeStateActive,
+ true,
+ &frame,
+ teJustLeft,
+ nil );
+ CFRelease( mString ) ;
+ line++ ;
+ }
+ else
+#endif
+ {
+ ::DrawText( text , laststop , i - laststop ) ;
+ line++ ;
+ ::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) );
+ }
+ laststop = i+1 ;
+ }
+ i++ ;
+ }
+#if TARGET_CARBON
+ if ( useDrawThemeText )
+ {
+ Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 1000 } ;
+ CFStringRef mString = CFStringCreateWithCString( NULL , text + laststop , kCFStringEncodingMacRoman ) ;
+ ::DrawThemeTextBox( mString,
+ kThemeCurrentPortFont,
+ kThemeStateActive,
+ true,
+ &frame,
+ teJustLeft,
+ nil );
+ CFRelease( mString ) ;
+ }
+ else
+#endif
+ {
+ ::DrawText( text , laststop , i - laststop ) ;
+ }
}
-
- ::DrawText( text , laststop , i - laststop ) ;
::TextMode( srcOr ) ;
}
{
wxCHECK_RET(Ok(), wxT("Invalid DC"));
wxMacPortSetter helper(this) ;
- Rect rect = { -32000 , -32000 , 32000 , 32000 } ;
+ Rect rect = { -31000 , -31000 , 31000 , 31000 } ;
if (m_backgroundBrush.GetStyle() != wxTRANSPARENT)
{
// return ;
Pattern blackColor ;
+ MacSetupBackgroundForCurrentPort(m_backgroundBrush) ;
+
wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
if ( font )
}
else
{
- short fontnum ;
-
- GetFNum( "\pGeneva" , &fontnum ) ;
- ::TextFont( fontnum ) ;
- ::TextSize( short(m_scaleY * 10) ) ;
- ::TextFace( 0 ) ;
+ FontFamilyID fontId ;
+ Str255 fontName ;
+ SInt16 fontSize ;
+ Style fontStyle ;
+ GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
+ GetFNum( fontName, &fontId );
+
+ ::TextFont( fontId ) ;
+ ::TextSize( short(m_scaleY * fontSize) ) ;
+ ::TextFace( fontStyle ) ;
// todo reset after spacing changes - or store the current spacing somewhere
{
kATSUFontTag ,
kATSUSizeTag ,
- kATSUColorTag ,
-
+// kATSUColorTag ,
+ kATSUBaselineClassTag ,
+ kATSUVerticalCharacterTag,
+
kATSUQDBoldfaceTag ,
kATSUQDItalicTag ,
kATSUQDUnderlineTag ,
kATSUQDCondensedTag ,
kATSUQDExtendedTag ,
-
+
} ;
ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
{
sizeof( ATSUFontID ) ,
sizeof( Fixed ) ,
- sizeof( RGBColor ) ,
+// sizeof( RGBColor ) ,
+ sizeof( BslnBaselineClass ) ,
+ sizeof( ATSUVerticalCharacterType),
+
sizeof( Boolean ) ,
sizeof( Boolean ) ,
sizeof( Boolean ) ,
sizeof( Boolean ) ,
sizeof( Boolean ) ,
+
} ;
Boolean kTrue = true ;
Boolean kFalse = false ;
+ BslnBaselineClass kBaselineDefault = kBSLNHangingBaseline ;
+
+ ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
{
&atsuFont ,
&atsuSize ,
- &MAC_WXCOLORREF( m_textForegroundColour.GetPixel() ) ,
-
+// &MAC_WXCOLORREF( m_textForegroundColour.GetPixel() ) ,
+ &kBaselineDefault ,
+ &kHorizontal,
+
(qdStyle & bold) ? &kTrue : &kFalse ,
(qdStyle & italic) ? &kTrue : &kFalse ,
(qdStyle & underline) ? &kTrue : &kFalse ,
}
+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 } ,
+} ;
+
static void wxMacGetHatchPattern(int hatchStyle, Pattern *pattern)
{
- // we have our own pattern list now
- int thePatListID = 128;
- int theIndex;
+ int theIndex = 1 ;
+
switch(hatchStyle)
{
case wxBDIAGONAL_HATCH:
theIndex = 1; // solid pattern
break;
}
- GetIndPattern( pattern, thePatListID, theIndex);
+ *pattern = gHatchPatterns[theIndex-1] ;
}
void wxDC::MacInstallPen() const