2004-03-23 12:35:05 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: dc.h
|
|
|
|
// Purpose: wxDC class
|
|
|
|
// Author: Stefan Csomor
|
|
|
|
// Modified by:
|
|
|
|
// Created: 1998-01-01
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Stefan Csomor
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2004-03-23 12:35:05 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_DC_H_
|
|
|
|
#define _WX_DC_H_
|
|
|
|
|
|
|
|
#include "wx/pen.h"
|
|
|
|
#include "wx/brush.h"
|
|
|
|
#include "wx/icon.h"
|
|
|
|
#include "wx/font.h"
|
|
|
|
#include "wx/gdicmn.h"
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// constants
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifndef MM_TEXT
|
|
|
|
#define MM_TEXT 0
|
|
|
|
#define MM_ISOTROPIC 1
|
|
|
|
#define MM_ANISOTROPIC 2
|
|
|
|
#define MM_LOMETRIC 3
|
|
|
|
#define MM_HIMETRIC 4
|
|
|
|
#define MM_TWIPS 5
|
|
|
|
#define MM_POINTS 6
|
|
|
|
#define MM_METRIC 7
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2006-02-14 01:54:06 -05:00
|
|
|
class wxMacPortStateHelper;
|
2005-02-12 06:34:05 -05:00
|
|
|
|
2006-10-21 08:37:42 -04:00
|
|
|
#if !wxUSE_GRAPHICS_CONTEXT
|
2006-10-20 05:34:11 -04:00
|
|
|
|
2005-02-12 06:34:05 -05:00
|
|
|
class WXDLLEXPORT wxGraphicPath
|
|
|
|
{
|
|
|
|
public :
|
2006-02-14 01:54:06 -05:00
|
|
|
virtual ~wxGraphicPath() {}
|
2005-09-14 08:05:48 -04:00
|
|
|
|
2006-02-14 01:54:06 -05:00
|
|
|
virtual void MoveToPoint( wxCoord x1, wxCoord y1 ) = 0;
|
2005-02-12 06:34:05 -05:00
|
|
|
|
2006-02-14 01:54:06 -05:00
|
|
|
virtual void AddLineToPoint( wxCoord x1, wxCoord y1 ) = 0;
|
|
|
|
|
|
|
|
virtual void AddQuadCurveToPoint( wxCoord cx1, wxCoord cy1, wxCoord x1, wxCoord y1 ) = 0;
|
|
|
|
|
|
|
|
virtual void AddRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) = 0;
|
2006-09-22 10:10:51 -04:00
|
|
|
|
2006-02-14 01:54:06 -05:00
|
|
|
virtual void AddCircle( wxCoord x, wxCoord y, wxCoord r ) = 0;
|
2006-09-22 10:10:51 -04:00
|
|
|
|
|
|
|
// draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2), also a straight line from (current) to (x1,y1)
|
2006-09-22 10:46:23 -04:00
|
|
|
virtual void AddArcToPoint( wxCoord x1, wxCoord y1 , wxCoord x2, wxCoord y2, wxCoord r ) = 0 ;
|
2006-09-22 10:10:51 -04:00
|
|
|
|
|
|
|
virtual void AddArc( wxCoord x, wxCoord y, wxCoord r, double startAngle, double endAngle, bool clockwise ) = 0 ;
|
2006-02-14 01:54:06 -05:00
|
|
|
|
|
|
|
virtual void CloseSubpath() = 0;
|
|
|
|
};
|
2005-02-12 06:34:05 -05:00
|
|
|
|
|
|
|
class WXDLLEXPORT wxGraphicContext
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~wxGraphicContext() {}
|
|
|
|
|
2006-09-22 10:10:51 -04:00
|
|
|
virtual wxGraphicPath * CreatePath() = 0;
|
|
|
|
|
|
|
|
virtual void PushState() = 0 ;
|
|
|
|
|
|
|
|
virtual void PopState() = 0 ;
|
|
|
|
|
2006-02-14 01:54:06 -05:00
|
|
|
virtual void Clip( const wxRegion ®ion ) = 0;
|
|
|
|
|
2006-09-22 10:10:51 -04:00
|
|
|
virtual void SetPen( const wxPen &pen ) = 0;
|
|
|
|
|
|
|
|
virtual void SetBrush( const wxBrush &brush ) = 0;
|
|
|
|
|
|
|
|
virtual void SetFont( const wxFont &font ) = 0 ;
|
|
|
|
|
|
|
|
virtual void SetTextColor( const wxColour &col ) = 0 ;
|
|
|
|
|
2006-02-14 01:54:06 -05:00
|
|
|
virtual void StrokePath( const wxGraphicPath *path ) = 0;
|
|
|
|
|
|
|
|
virtual void DrawPath( const wxGraphicPath *path, int fillStyle = wxWINDING_RULE ) = 0;
|
|
|
|
|
|
|
|
virtual void FillPath( const wxGraphicPath *path, const wxColor &fillColor, int fillStyle = wxWINDING_RULE ) = 0;
|
|
|
|
|
2006-09-22 10:10:51 -04:00
|
|
|
virtual void DrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, wxCoord w, wxCoord h ) = 0 ;
|
|
|
|
|
|
|
|
virtual void DrawIcon( const wxIcon &icon, wxCoord x, wxCoord y, wxCoord w, wxCoord h ) = 0 ;
|
|
|
|
|
|
|
|
virtual void DrawText( const wxString &str, wxCoord x, wxCoord y, double angle ) = 0 ;
|
|
|
|
|
|
|
|
virtual void GetTextExtent( const wxString &text, wxCoord *width, wxCoord *height,
|
|
|
|
wxCoord *descent, wxCoord *externalLeading ) const = 0 ;
|
|
|
|
|
|
|
|
virtual void GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const = 0 ;
|
|
|
|
|
|
|
|
virtual void Translate( wxCoord dx , wxCoord dy ) = 0 ;
|
|
|
|
|
|
|
|
virtual void Scale( wxCoord xScale , wxCoord yScale ) = 0 ;
|
2006-02-14 01:54:06 -05:00
|
|
|
};
|
2005-02-12 06:34:05 -05:00
|
|
|
|
2004-03-23 12:35:05 -05:00
|
|
|
class WXDLLEXPORT wxDC: public wxDCBase
|
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxDC)
|
|
|
|
DECLARE_NO_COPY_CLASS(wxDC)
|
|
|
|
|
2006-01-18 14:41:30 -05:00
|
|
|
public:
|
2004-03-23 12:35:05 -05:00
|
|
|
wxDC();
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxDC();
|
2004-12-06 10:48:50 -05:00
|
|
|
|
2004-03-23 12:35:05 -05:00
|
|
|
// implement base class pure virtuals
|
|
|
|
// ----------------------------------
|
|
|
|
|
|
|
|
virtual void Clear();
|
|
|
|
|
2004-12-16 16:24:45 -05:00
|
|
|
virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return true; }
|
2006-02-14 01:54:06 -05:00
|
|
|
virtual void EndDoc(void) {}
|
2004-12-06 10:48:50 -05:00
|
|
|
|
2006-02-14 01:54:06 -05:00
|
|
|
virtual void StartPage(void) {}
|
|
|
|
virtual void EndPage(void) {}
|
2004-03-23 12:35:05 -05:00
|
|
|
|
|
|
|
virtual void SetFont(const wxFont& font);
|
|
|
|
virtual void SetPen(const wxPen& pen);
|
|
|
|
virtual void SetBrush(const wxBrush& brush);
|
|
|
|
virtual void SetBackground(const wxBrush& brush);
|
|
|
|
virtual void SetBackgroundMode(int mode);
|
|
|
|
virtual void SetPalette(const wxPalette& palette);
|
|
|
|
|
|
|
|
virtual void DestroyClippingRegion();
|
|
|
|
|
|
|
|
virtual wxCoord GetCharHeight() const;
|
|
|
|
virtual wxCoord GetCharWidth() const;
|
|
|
|
|
|
|
|
virtual bool CanDrawBitmap() const;
|
|
|
|
virtual bool CanGetTextExtent() const;
|
|
|
|
virtual int GetDepth() const;
|
|
|
|
virtual wxSize GetPPI() const;
|
|
|
|
|
|
|
|
virtual void SetLogicalFunction(int function);
|
|
|
|
|
2006-02-14 01:54:06 -05:00
|
|
|
virtual void SetTextForeground(const wxColour& colour);
|
|
|
|
virtual void SetTextBackground(const wxColour& colour);
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-18 14:41:30 -05:00
|
|
|
public:
|
2007-05-02 07:05:45 -04:00
|
|
|
wxCoord XDEV2LOG(wxCoord x) const { return DeviceToLogicalX( x ); }
|
|
|
|
wxCoord XDEV2LOGREL(wxCoord x) const { return DeviceToLogicalXRel( x ); }
|
|
|
|
wxCoord YDEV2LOG(wxCoord y) const { return DeviceToLogicalY( y ); }
|
|
|
|
wxCoord YDEV2LOGREL(wxCoord y) const { return DeviceToLogicalYRel( y ); }
|
|
|
|
wxCoord XLOG2DEV(wxCoord x) const { return LogicalToDeviceX( x ); }
|
|
|
|
wxCoord XLOG2DEVREL(wxCoord x) const { return LogicalToDeviceXRel( x ); }
|
|
|
|
wxCoord YLOG2DEV(wxCoord y) const { return LogicalToDeviceY( y ); }
|
|
|
|
wxCoord YLOG2DEVREL(wxCoord y) const { return LogicalToDeviceYRel( y ); }
|
|
|
|
// probably no longer needed
|
|
|
|
wxCoord XLOG2DEVMAC(wxCoord x) const { return LogicalToDeviceX( x ); }
|
|
|
|
wxCoord YLOG2DEVMAC(wxCoord y) const { return LogicalToDeviceY( y ); }
|
2006-01-18 14:41:30 -05:00
|
|
|
|
2005-02-13 00:59:04 -05:00
|
|
|
#if wxMAC_USE_CORE_GRAPHICS
|
2006-10-21 13:46:33 -04:00
|
|
|
wxGraphicsContext* GetGraphicsContext() { return m_graphicContext; }
|
2005-02-13 00:59:04 -05:00
|
|
|
#else
|
2006-02-14 01:54:06 -05:00
|
|
|
WXHRGN MacGetCurrentClipRgn() { return m_macCurrentClipRgn; }
|
|
|
|
static void MacSetupBackgroundForCurrentPort(const wxBrush& background );
|
2005-02-12 06:34:05 -05:00
|
|
|
#endif
|
2004-03-23 12:35:05 -05:00
|
|
|
|
|
|
|
protected:
|
2006-02-08 16:47:09 -05:00
|
|
|
virtual void DoGetTextExtent(const wxString& string,
|
|
|
|
wxCoord *x, wxCoord *y,
|
|
|
|
wxCoord *descent = NULL,
|
|
|
|
wxCoord *externalLeading = NULL,
|
2007-04-24 21:49:47 -04:00
|
|
|
const wxFont *theFont = NULL) const;
|
2006-02-14 01:54:06 -05:00
|
|
|
|
2006-02-08 16:47:09 -05:00
|
|
|
virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
|
|
|
|
|
2004-03-23 12:35:05 -05:00
|
|
|
virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
|
|
|
|
int style = wxFLOOD_SURFACE);
|
|
|
|
|
|
|
|
virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
|
|
|
|
|
|
|
|
virtual void DoDrawPoint(wxCoord x, wxCoord y);
|
2006-02-14 01:54:06 -05:00
|
|
|
|
2005-09-14 08:05:48 -04:00
|
|
|
#if wxMAC_USE_CORE_GRAPHICS && wxUSE_SPLINES
|
|
|
|
virtual void DoDrawSpline(wxList *points);
|
|
|
|
#endif
|
2006-02-14 01:54:06 -05:00
|
|
|
|
2004-03-23 12:35:05 -05:00
|
|
|
virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
|
|
|
|
|
|
|
|
virtual void DoDrawArc(wxCoord x1, wxCoord y1,
|
|
|
|
wxCoord x2, wxCoord y2,
|
|
|
|
wxCoord xc, wxCoord yc);
|
2004-12-06 10:48:50 -05:00
|
|
|
|
2004-03-23 12:35:05 -05:00
|
|
|
virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
|
|
|
double sa, double ea);
|
|
|
|
|
|
|
|
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
|
|
|
|
virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
|
|
|
|
wxCoord width, wxCoord height,
|
|
|
|
double radius);
|
|
|
|
virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
|
|
|
|
|
|
|
|
virtual void DoCrossHair(wxCoord x, wxCoord y);
|
|
|
|
|
|
|
|
virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
|
|
|
|
virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
|
2004-12-16 16:24:45 -05:00
|
|
|
bool useMask = false);
|
2004-03-23 12:35:05 -05:00
|
|
|
|
|
|
|
virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
|
|
|
|
virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
|
|
|
|
double angle);
|
|
|
|
|
|
|
|
virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
|
|
|
|
wxDC *source, wxCoord xsrc, wxCoord ysrc,
|
2004-12-16 16:24:45 -05:00
|
|
|
int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2007-03-18 11:32:27 -04:00
|
|
|
virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest,
|
|
|
|
wxCoord dstWidth, wxCoord dstHeight,
|
|
|
|
wxDC *source,
|
|
|
|
wxCoord xsrc, wxCoord ysrc,
|
|
|
|
wxCoord srcWidth, wxCoord srcHeight,
|
|
|
|
int rop = wxCOPY, bool useMask = false,
|
|
|
|
wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord);
|
|
|
|
|
2004-03-23 12:35:05 -05:00
|
|
|
// this is gnarly - we can't even call this function DoSetClippingRegion()
|
|
|
|
// because of virtual function hiding
|
2006-02-14 01:54:06 -05:00
|
|
|
|
2004-03-23 12:35:05 -05:00
|
|
|
virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
|
|
|
|
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
|
|
|
|
wxCoord width, wxCoord height);
|
|
|
|
|
2006-02-14 01:54:06 -05:00
|
|
|
virtual void DoGetSizeMM(int *width, int *height) const;
|
2004-03-23 12:35:05 -05:00
|
|
|
|
|
|
|
virtual void DoDrawLines(int n, wxPoint points[],
|
|
|
|
wxCoord xoffset, wxCoord yoffset);
|
|
|
|
virtual void DoDrawPolygon(int n, wxPoint points[],
|
|
|
|
wxCoord xoffset, wxCoord yoffset,
|
|
|
|
int fillStyle = wxODDEVEN_RULE);
|
|
|
|
|
2006-01-18 14:41:30 -05:00
|
|
|
protected:
|
|
|
|
// scaling variables
|
|
|
|
double m_mm_to_pix_x, m_mm_to_pix_y;
|
|
|
|
|
|
|
|
// To be set using SetDeviceOrigin()
|
|
|
|
// by external classes such as wxScrolledWindow
|
|
|
|
long m_externalDeviceOriginX, m_externalDeviceOriginY;
|
|
|
|
|
2005-11-06 02:23:14 -05:00
|
|
|
#if !wxMAC_USE_CORE_GRAPHICS
|
2004-03-23 12:35:05 -05:00
|
|
|
// If un-scrolled is non-zero or d.o. changes with scrolling.
|
|
|
|
// Set using SetInternalDeviceOrigin().
|
2006-01-18 14:41:30 -05:00
|
|
|
long m_internalDeviceOriginX, m_internalDeviceOriginY;
|
2004-12-06 10:48:50 -05:00
|
|
|
|
2006-02-14 01:54:06 -05:00
|
|
|
WXHBITMAP m_macMask;
|
2005-02-12 06:34:05 -05:00
|
|
|
#endif
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-18 14:41:30 -05:00
|
|
|
// not yet used
|
|
|
|
bool m_needComputeScaleX, m_needComputeScaleY;
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-01-18 14:41:30 -05:00
|
|
|
public:
|
|
|
|
// implementation
|
2006-02-14 01:54:06 -05:00
|
|
|
void MacInstallFont() const;
|
2005-02-12 06:34:05 -05:00
|
|
|
|
2006-01-18 14:41:30 -05:00
|
|
|
// in order to preserve the const inheritance of the virtual functions,
|
|
|
|
// we have to use mutable variables starting from CWPro 5
|
2006-02-14 01:54:06 -05:00
|
|
|
wxPoint m_macLocalOrigin;
|
|
|
|
mutable void *m_macATSUIStyle;
|
2004-03-23 12:35:05 -05:00
|
|
|
|
2006-02-14 01:54:06 -05:00
|
|
|
WXHDC m_macPort;
|
2006-01-18 14:41:30 -05:00
|
|
|
|
2005-02-12 06:34:05 -05:00
|
|
|
#if wxMAC_USE_CORE_GRAPHICS
|
2006-10-21 13:46:33 -04:00
|
|
|
wxGraphicsContext *m_graphicContext;
|
2005-02-12 06:34:05 -05:00
|
|
|
#else
|
2006-02-14 01:54:06 -05:00
|
|
|
void MacInstallPen() const;
|
|
|
|
void MacInstallBrush() const;
|
|
|
|
|
|
|
|
void MacSetupPort( wxMacPortStateHelper *ph ) const;
|
|
|
|
void MacCleanupPort( wxMacPortStateHelper *ph ) const;
|
|
|
|
|
|
|
|
mutable wxMacPortStateHelper *m_macCurrentPortStateHelper;
|
|
|
|
|
|
|
|
mutable bool m_macFontInstalled;
|
|
|
|
mutable bool m_macPenInstalled;
|
|
|
|
mutable bool m_macBrushInstalled;
|
|
|
|
|
|
|
|
WXHRGN m_macBoundaryClipRgn;
|
|
|
|
WXHRGN m_macCurrentClipRgn;
|
|
|
|
mutable bool m_macFormerAliasState;
|
|
|
|
mutable short m_macFormerAliasSize;
|
|
|
|
mutable bool m_macAliasWasEnabled;
|
|
|
|
mutable void *m_macForegroundPixMap;
|
|
|
|
mutable void *m_macBackgroundPixMap;
|
2005-02-12 06:34:05 -05:00
|
|
|
#endif
|
2004-03-23 12:35:05 -05:00
|
|
|
};
|
|
|
|
|
2006-10-20 05:34:11 -04:00
|
|
|
#endif
|
|
|
|
|
2006-01-18 14:41:30 -05:00
|
|
|
#endif // _WX_DC_H_
|