#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
if ( win )
{
- int x = 0 , y = 0;
- win->MacWindowToRootWindow( &x,&y ) ;
- // get area including focus rect
- CopyRgn( (RgnHandle) ((wxWindow*)win)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip ) ;
- if ( !EmptyRgn( m_newClip ) )
- OffsetRgn( m_newClip , x , y ) ;
-
+ // guard against half constructed objects, this just leads to a empty clip
+ if( win->GetPeer() )
+ {
+ int x = 0 , y = 0;
+ win->MacWindowToRootWindow( &x,&y ) ;
+ // get area including focus rect
+ CopyRgn( (RgnHandle) ((wxWindow*)win)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip ) ;
+ if ( !EmptyRgn( m_newClip ) )
+ OffsetRgn( m_newClip , x , y ) ;
+ }
SetClip( m_newClip ) ;
}
}
//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())));
- }
+ CopyDeepMask
+ (
+ GetPortBitMapForCopyBits(bmapworld),
+ GetPortBitMapForCopyBits(MAC_WXHBITMAP(maskworld)),
+ GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ),
+ &source, &source, &dest, mode, NULL
+ );
+ UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld)));
}
- else {
- CopyBits( GetPortBitMapForCopyBits( bmapworld ),
- GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ),
- &source, &dest, mode, NULL ) ;
- }
- 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);
+ wxCoord w = icon.GetWidth();
+ wxCoord h = icon.GetHeight();
+ wxCoord ww = XLOG2DEVREL(w);
+ wxCoord hh = YLOG2DEVREL(h);
+
+ Rect r = { yy , xx, yy + hh , xx + ww } ;
+ PlotIconRef( &r , kAlignNone , kTransformNone , kPlotIconRefNormalFlags , MAC_WXHICON( icon.GetHICON() ) ) ;
}
void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
void wxDC::DoSetClippingRegionAsRegion( const wxRegion ®ion )
{
wxCHECK_RET( Ok(), wxT("invalid window dc") ) ;
- if (region.Empty())
- {
- DestroyClippingRegion();
- return;
- }
wxMacFastPortSetter helper(this) ;
wxCoord x, y, w, h;
region.GetBox( x, y, w, h );
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)
{
&chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ;
wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the rotated text") );
+
+ status = ::ATSUSetTransientFontMatching( atsuLayout , true ) ;
+ wxASSERT_MSG( status == noErr , wxT("couldn't setup transient font matching") );
+
int iAngle = int( angle );
int drawX = XLOG2DEVMAC(x) ;
int drawY = YLOG2DEVMAC(y) ;
{
sizeof( Fixed ) ,
} ;
- Boolean kTrue = true ;
- Boolean kFalse = false ;
+// Boolean kTrue = true ;
+// Boolean kFalse = false ;
- ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
+// ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
{
&atsuSize ,
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