// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "dc.h"
#endif
+#include "wx/wxprec.h"
+
#include "wx/dc.h"
+
+#if !wxMAC_USE_CORE_GRAPHICS
#include "wx/app.h"
#include "wx/mac/uma.h"
#include "wx/dcmemory.h"
#include <ATSUnicode.h>
#include <TextCommon.h>
#include <TextEncodingConverter.h>
-#include <FixMath.h>
#if !USE_SHARED_LIBRARY
IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
#endif
// constants
//-----------------------------------------------------------------------------
-#define mm2inches 0.0393700787402
-#define inches2mm 25.4
-#define mm2twips 56.6929133859
-#define twips2mm 0.0176388888889
-#define mm2pt 2.83464566929
-#define pt2mm 0.352777777778
-
const double RAD2DEG = 180.0 / M_PI;
const short kEmulatedMode = -1 ;
const short kUnsupportedMode = -2 ;
//m_logicalFunction == wxSRC_OR ? srcOr :
//m_logicalFunction == wxSRC_AND ? SRCAND :
srcCopy );
- if ( bmp.GetBitmapType() == kMacBitmapTypePict ) {
- Rect bitmaprect = { 0 , 0 , hh, ww };
- ::OffsetRect( &bitmaprect, xx, yy ) ;
- ::DrawPicture( (PicHandle) bmp.GetPict(), &bitmaprect ) ;
- }
- else if ( bmp.GetBitmapType() == kMacBitmapTypeGrafWorld )
+
+ GWorldPtr maskworld = NULL ;
+ GWorldPtr bmapworld = MAC_WXHBITMAP( bmp.GetHBITMAP((WXHBITMAP*)&maskworld) );
+ PixMapHandle bmappixels ;
+ // Set foreground and background colours (for bitmaps depth = 1)
+ if(bmp.GetDepth() == 1)
+ {
+ RGBColor fore = MAC_WXCOLORREF(m_textForegroundColour.GetPixel());
+ RGBColor back = MAC_WXCOLORREF(m_textBackgroundColour.GetPixel());
+ RGBForeColor(&fore);
+ RGBBackColor(&back);
+ }
+ else
{
- GWorldPtr bmapworld = MAC_WXHBITMAP( bmp.GetHBITMAP() );
- PixMapHandle bmappixels ;
- // Set foreground and background colours (for bitmaps depth = 1)
- if(bmp.GetDepth() == 1)
- {
- RGBColor fore = MAC_WXCOLORREF(m_textForegroundColour.GetPixel());
- RGBColor back = MAC_WXCOLORREF(m_textBackgroundColour.GetPixel());
- RGBForeColor(&fore);
- RGBBackColor(&back);
- }
- else
- {
- RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ;
- RGBColor black = { 0,0,0} ;
- RGBForeColor( &black ) ;
- RGBBackColor( &white ) ;
- }
- bmappixels = GetGWorldPixMap( bmapworld ) ;
- wxCHECK_RET(LockPixels(bmappixels),
- wxT("DoDrawBitmap: Unable to lock pixels"));
- Rect source = { 0, 0, h, w };
- Rect dest = { yy, xx, yy + hh, xx + ww };
- if ( useMask && bmp.GetMask() )
+ RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ;
+ RGBColor black = { 0,0,0} ;
+ RGBForeColor( &black ) ;
+ RGBBackColor( &white ) ;
+ }
+ bmappixels = GetGWorldPixMap( bmapworld ) ;
+ wxCHECK_RET(LockPixels(bmappixels),
+ wxT("DoDrawBitmap: Unable to lock pixels"));
+ Rect source = { 0, 0, h, w };
+ Rect dest = { yy, xx, yy + hh, xx + ww };
+ if ( useMask && maskworld )
+ {
+ if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld))))
{
- if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap()))))
- {
- CopyDeepMask
- (
- GetPortBitMapForCopyBits(bmapworld),
- GetPortBitMapForCopyBits(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap())),
- GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ),
- &source, &source, &dest, mode, NULL
- );
- UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap())));
- }
- }
- else {
- CopyBits( GetPortBitMapForCopyBits( bmapworld ),
- GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ),
- &source, &dest, mode, NULL ) ;
+ CopyDeepMask
+ (
+ GetPortBitMapForCopyBits(bmapworld),
+ GetPortBitMapForCopyBits(MAC_WXHBITMAP(maskworld)),
+ GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ),
+ &source, &source, &dest, mode, NULL
+ );
+ UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld)));
}
- UnlockPixels( bmappixels ) ;
}
- else if ( bmp.GetBitmapType() == kMacBitmapTypeIcon )
- {
- Rect bitmaprect = { 0 , 0 , bmp.GetHeight(), bmp.GetWidth() } ;
- OffsetRect( &bitmaprect, xx, yy ) ;
- PlotCIconHandle( &bitmaprect , atNone , ttNone , MAC_WXHICON(bmp.GetHICON()) ) ;
+ else {
+ CopyBits( GetPortBitMapForCopyBits( bmapworld ),
+ GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ),
+ &source, &dest, mode, NULL ) ;
}
+ UnlockPixels( bmappixels ) ;
+
m_macPenInstalled = false ;
m_macBrushInstalled = false ;
m_macFontInstalled = false ;
{
wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon"));
wxCHECK_RET(icon.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
- DoDrawBitmap( icon , x , y , icon.GetMask() != NULL ) ;
+ wxMacFastPortSetter helper(this) ;
+
+ wxCoord xx = XLOG2DEVMAC(x);
+ wxCoord yy = YLOG2DEVMAC(y);
+
+ Rect r = { yy , xx, yy + 32 , xx + 32 } ;
+ PlotIconRef( &r , kAlignNone , kTransformNone , kPlotIconRefNormalFlags , MAC_WXHICON( icon.GetHICON() ) ) ;
}
void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
return true;
}
-#ifndef FixedToInt
-// as macro in FixMath.h for 10.3
-inline Fixed IntToFixed( int inInt )
-{
- return (((SInt32) inInt) << 16);
-}
-
-inline int FixedToInt( Fixed inFixed )
-{
- return (((SInt32) inFixed) >> 16);
-}
-#endif
-
void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
double angle)
{
Pattern whiteColor ;
::BackPat(GetQDGlobalsWhite(&whiteColor));
}
- if ( m_font.Ok() )
- {
- ::TextFont( m_font.MacGetFontNum() ) ;
- ::TextSize( (short)(m_scaleY * m_font.MacGetFontSize()) ) ;
- ::TextFace( m_font.MacGetFontStyle() ) ;
- m_macFontInstalled = true ;
- m_macBrushInstalled = false ;
- m_macPenInstalled = false ;
- RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel());
- RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel());
- ::RGBForeColor( &forecolor );
- ::RGBBackColor( &backcolor );
- }
- else
- {
- 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
- m_macFontInstalled = true ;
- m_macBrushInstalled = false ;
- m_macPenInstalled = false ;
- RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel());
- RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel());
- ::RGBForeColor( &forecolor );
- ::RGBBackColor( &backcolor );
- }
+
+ wxASSERT( m_font.Ok() ) ;
+
+
+ ::TextFont( m_font.MacGetFontNum() ) ;
+ ::TextSize( (short)(m_scaleY * m_font.MacGetFontSize()) ) ;
+ ::TextFace( m_font.MacGetFontStyle() ) ;
+ m_macFontInstalled = true ;
+ m_macBrushInstalled = false ;
+ m_macPenInstalled = false ;
+ RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel());
+ RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel());
+ ::RGBForeColor( &forecolor );
+ ::RGBBackColor( &backcolor );
+
short mode = patCopy ;
// todo :
switch( m_logicalFunction )
}
::PenMode( mode ) ;
OSStatus status = noErr ;
+ status = ATSUCreateAndCopyStyle( (ATSUStyle) m_font.MacGetATSUStyle() , (ATSUStyle*) &m_macATSUIStyle ) ;
+ wxASSERT_MSG( status == noErr , wxT("couldn't set create ATSU style") ) ;
+
Fixed atsuSize = IntToFixed( int(m_scaleY * m_font.MacGetFontSize()) ) ;
- Style qdStyle = m_font.MacGetATSUAdditionalQDStyles() ;
- ATSUFontID atsuFont = m_font.MacGetATSUFontID() ;
- status = ::ATSUCreateStyle((ATSUStyle *)&m_macATSUIStyle) ;
- wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") ) ;
ATSUAttributeTag atsuTags[] =
{
- kATSUFontTag ,
kATSUSizeTag ,
- // kATSUColorTag ,
- // kATSUBaselineClassTag ,
- kATSUVerticalCharacterTag,
- kATSUQDBoldfaceTag ,
- kATSUQDItalicTag ,
- kATSUQDUnderlineTag ,
- kATSUQDCondensedTag ,
- kATSUQDExtendedTag ,
} ;
ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
{
- sizeof( ATSUFontID ) ,
sizeof( Fixed ) ,
- // 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;
+// Boolean kTrue = true ;
+// Boolean kFalse = false ;
+
+// ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
{
- &atsuFont ,
&atsuSize ,
- // &MAC_WXCOLORREF( m_textForegroundColour.GetPixel() ) ,
- // &kBaselineDefault ,
- &kHorizontal,
- (qdStyle & bold) ? &kTrue : &kFalse ,
- (qdStyle & italic) ? &kTrue : &kFalse ,
- (qdStyle & underline) ? &kTrue : &kFalse ,
- (qdStyle & condense) ? &kTrue : &kFalse ,
- (qdStyle & extend) ? &kTrue : &kFalse ,
} ;
status = ::ATSUSetAttributes((ATSUStyle)m_macATSUIStyle, sizeof(atsuTags)/sizeof(ATSUAttributeTag) ,
atsuTags, atsuSizes, atsuValues);
- wxASSERT_MSG( status == noErr , wxT("couldn't set create ATSU style") ) ;
+
+ wxASSERT_MSG( status == noErr , wxT("couldn't Modify ATSU style") ) ;
+
}
Pattern gPatterns[] =
int height = bitmap->GetHeight() ;
GWorldPtr gw = NULL ;
if ( m_brush.GetStyle() == wxSTIPPLE )
- gw = MAC_WXHBITMAP(bitmap->GetHBITMAP()) ;
+ gw = MAC_WXHBITMAP(bitmap->GetHBITMAP(NULL)) ;
else
- gw = MAC_WXHBITMAP(bitmap->GetMask()->GetMaskBitmap()) ;
+ gw = MAC_WXHBITMAP(bitmap->GetMask()->GetHBITMAP()) ;
PixMapHandle gwpixmaphandle = GetGWorldPixMap( gw ) ;
LockPixels( gwpixmaphandle ) ;
bool isMonochrome = !IsPortColor( gw ) ;
{
return ((wxDC *)this)->YLOG2DEVREL(y);
}
+
+#endif // !wxMAC_USE_CORE_GRAPHICS