wxWidgets/include/wx/dcgraph.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

275 lines
9.9 KiB
C
Raw Normal View History

/////////////////////////////////////////////////////////////////////////////
// Name: wx/dcgraph.h
// Purpose: graphics context device bridge header
// Author: Stefan Csomor
// Modified by:
// Created:
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GRAPHICS_DC_H_
#define _WX_GRAPHICS_DC_H_
#if wxUSE_GRAPHICS_CONTEXT
#include "wx/dc.h"
#include "wx/geometry.h"
#include "wx/graphics.h"
class WXDLLIMPEXP_FWD_CORE wxWindowDC;
class WXDLLIMPEXP_CORE wxGCDC: public wxDC
{
public:
wxGCDC( const wxWindowDC& dc );
wxGCDC( const wxMemoryDC& dc );
#if wxUSE_PRINTING_ARCHITECTURE
wxGCDC( const wxPrinterDC& dc );
#endif
#if defined(__WXMSW__) && wxUSE_ENH_METAFILE
wxGCDC( const wxEnhMetaFileDC& dc );
#endif
wxGCDC(wxGraphicsContext* context);
wxGCDC();
virtual ~wxGCDC();
#ifdef __WXMSW__
// override wxDC virtual functions to provide access to HDC associated with
// underlying wxGraphicsContext
2016-09-25 16:21:28 -04:00
virtual WXHDC AcquireHDC() wxOVERRIDE;
virtual void ReleaseHDC(WXHDC hdc) wxOVERRIDE;
#endif // __WXMSW__
private:
wxDECLARE_DYNAMIC_CLASS(wxGCDC);
wxDECLARE_NO_COPY_CLASS(wxGCDC);
};
class WXDLLIMPEXP_CORE wxGCDCImpl: public wxDCImpl
{
public:
wxGCDCImpl( wxDC *owner, const wxWindowDC& dc );
wxGCDCImpl( wxDC *owner, const wxMemoryDC& dc );
#if wxUSE_PRINTING_ARCHITECTURE
wxGCDCImpl( wxDC *owner, const wxPrinterDC& dc );
#endif
#if defined(__WXMSW__) && wxUSE_ENH_METAFILE
wxGCDCImpl( wxDC *owner, const wxEnhMetaFileDC& dc );
#endif
// Ctor using an existing graphics context given to wxGCDC ctor.
wxGCDCImpl(wxDC *owner, wxGraphicsContext* context);
wxGCDCImpl( wxDC *owner );
virtual ~wxGCDCImpl();
// implement base class pure virtuals
// ----------------------------------
2015-09-06 20:20:42 -04:00
virtual void Clear() wxOVERRIDE;
2015-09-06 20:20:42 -04:00
virtual bool StartDoc( const wxString& message ) wxOVERRIDE;
virtual void EndDoc() wxOVERRIDE;
2015-09-06 20:20:42 -04:00
virtual void StartPage() wxOVERRIDE;
virtual void EndPage() wxOVERRIDE;
// flushing the content of this dc immediately onto screen
2015-09-06 20:20:42 -04:00
virtual void Flush() wxOVERRIDE;
2015-09-06 20:20:42 -04:00
virtual void SetFont(const wxFont& font) wxOVERRIDE;
virtual void SetPen(const wxPen& pen) wxOVERRIDE;
virtual void SetBrush(const wxBrush& brush) wxOVERRIDE;
virtual void SetBackground(const wxBrush& brush) wxOVERRIDE;
virtual void SetBackgroundMode(int mode) wxOVERRIDE;
#if wxUSE_PALETTE
2015-09-06 20:20:42 -04:00
virtual void SetPalette(const wxPalette& palette) wxOVERRIDE;
#endif
2015-09-06 20:20:42 -04:00
virtual void DestroyClippingRegion() wxOVERRIDE;
2015-09-06 20:20:42 -04:00
virtual wxCoord GetCharHeight() const wxOVERRIDE;
virtual wxCoord GetCharWidth() const wxOVERRIDE;
2015-09-06 20:20:42 -04:00
virtual bool CanDrawBitmap() const wxOVERRIDE;
virtual bool CanGetTextExtent() const wxOVERRIDE;
virtual int GetDepth() const wxOVERRIDE;
virtual wxSize GetPPI() const wxOVERRIDE;
2015-09-06 20:20:42 -04:00
virtual void SetLogicalFunction(wxRasterOperationMode function) wxOVERRIDE;
2015-09-06 20:20:42 -04:00
virtual void SetTextForeground(const wxColour& colour) wxOVERRIDE;
virtual void SetTextBackground(const wxColour& colour) wxOVERRIDE;
2015-09-06 20:20:42 -04:00
virtual void ComputeScaleAndOrigin() wxOVERRIDE;
2015-09-06 20:20:42 -04:00
wxGraphicsContext* GetGraphicsContext() const wxOVERRIDE { return m_graphicContext; }
virtual void SetGraphicsContext( wxGraphicsContext* ctx ) wxOVERRIDE;
2015-09-06 20:20:42 -04:00
virtual void* GetHandle() const wxOVERRIDE;
#if wxUSE_DC_TRANSFORM_MATRIX
virtual bool CanUseTransformMatrix() const wxOVERRIDE;
virtual bool SetTransformMatrix(const wxAffineMatrix2D& matrix) wxOVERRIDE;
virtual wxAffineMatrix2D GetTransformMatrix() const wxOVERRIDE;
virtual void ResetTransformMatrix() wxOVERRIDE;
#endif // wxUSE_DC_TRANSFORM_MATRIX
// coordinates conversions and transforms
virtual wxPoint DeviceToLogical(wxCoord x, wxCoord y) const wxOVERRIDE;
virtual wxPoint LogicalToDevice(wxCoord x, wxCoord y) const wxOVERRIDE;
virtual wxSize DeviceToLogicalRel(int x, int y) const wxOVERRIDE;
virtual wxSize LogicalToDeviceRel(int x, int y) const wxOVERRIDE;
// the true implementations
virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
2015-09-06 20:20:42 -04:00
wxFloodFillStyle style = wxFLOOD_SURFACE) wxOVERRIDE;
virtual void DoGradientFillLinear(const wxRect& rect,
const wxColour& initialColour,
const wxColour& destColour,
2015-09-06 20:20:42 -04:00
wxDirection nDirection = wxEAST) wxOVERRIDE;
virtual void DoGradientFillConcentric(const wxRect& rect,
const wxColour& initialColour,
const wxColour& destColour,
2015-09-06 20:20:42 -04:00
const wxPoint& circleCenter) wxOVERRIDE;
2015-09-06 20:20:42 -04:00
virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const wxOVERRIDE;
2015-09-06 20:20:42 -04:00
virtual void DoDrawPoint(wxCoord x, wxCoord y) wxOVERRIDE;
#if wxUSE_SPLINES
2015-09-06 20:20:42 -04:00
virtual void DoDrawSpline(const wxPointList *points) wxOVERRIDE;
#endif
2015-09-06 20:20:42 -04:00
virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) wxOVERRIDE;
virtual void DoDrawArc(wxCoord x1, wxCoord y1,
wxCoord x2, wxCoord y2,
2015-09-06 20:20:42 -04:00
wxCoord xc, wxCoord yc) wxOVERRIDE;
virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
2015-09-06 20:20:42 -04:00
wxCoord width, wxCoord height) wxOVERRIDE;
virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
2015-09-06 20:20:42 -04:00
double sa, double ea) wxOVERRIDE;
2015-09-06 20:20:42 -04:00
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) wxOVERRIDE;
virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
wxCoord width, wxCoord height,
2015-09-06 20:20:42 -04:00
double radius) wxOVERRIDE;
virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) wxOVERRIDE;
2015-09-06 20:20:42 -04:00
virtual void DoCrossHair(wxCoord x, wxCoord y) wxOVERRIDE;
2015-09-06 20:20:42 -04:00
virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) wxOVERRIDE;
virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
2015-09-06 20:20:42 -04:00
bool useMask = false) wxOVERRIDE;
2015-09-06 20:20:42 -04:00
virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) wxOVERRIDE;
virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
2015-09-06 20:20:42 -04:00
double angle) wxOVERRIDE;
virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc,
wxRasterOperationMode rop = wxCOPY, bool useMask = false,
2015-09-06 20:20:42 -04:00
wxCoord xsrcMask = -1, wxCoord ysrcMask = -1) wxOVERRIDE;
virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest,
wxCoord dstWidth, wxCoord dstHeight,
wxDC *source,
wxCoord xsrc, wxCoord ysrc,
wxCoord srcWidth, wxCoord srcHeight,
wxRasterOperationMode = wxCOPY, bool useMask = false,
2015-09-06 20:20:42 -04:00
wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord) wxOVERRIDE;
2015-09-06 20:20:42 -04:00
virtual void DoGetSize(int *,int *) const wxOVERRIDE;
virtual void DoGetSizeMM(int* width, int* height) const wxOVERRIDE;
virtual void DoDrawLines(int n, const wxPoint points[],
2015-09-06 20:20:42 -04:00
wxCoord xoffset, wxCoord yoffset) wxOVERRIDE;
virtual void DoDrawPolygon(int n, const wxPoint points[],
wxCoord xoffset, wxCoord yoffset,
2015-09-06 20:20:42 -04:00
wxPolygonFillMode fillStyle = wxODDEVEN_RULE) wxOVERRIDE;
virtual void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[],
wxCoord xoffset, wxCoord yoffset,
2015-09-06 20:20:42 -04:00
wxPolygonFillMode fillStyle) wxOVERRIDE;
2015-09-06 20:20:42 -04:00
virtual void DoSetDeviceClippingRegion(const wxRegion& region) wxOVERRIDE;
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
2015-09-06 20:20:42 -04:00
wxCoord width, wxCoord height) wxOVERRIDE;
virtual bool DoGetClippingRect(wxRect& rect) const wxOVERRIDE;
virtual void DoGetTextExtent(const wxString& string,
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
2015-09-06 20:20:42 -04:00
const wxFont *theFont = NULL) const wxOVERRIDE;
2015-09-06 20:20:42 -04:00
virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const wxOVERRIDE;
#ifdef __WXMSW__
2016-09-25 16:21:28 -04:00
virtual wxRect MSWApplyGDIPlusTransform(const wxRect& r) const wxOVERRIDE;
#endif // __WXMSW__
// update the internal clip box variables
void UpdateClipBox();
protected:
// unused int parameter distinguishes this version, which does not create a
// wxGraphicsContext, in the expectation that the derived class will do it
wxGCDCImpl(wxDC* owner, int);
#ifdef __WXOSX__
virtual wxPoint OSXGetOrigin() const { return wxPoint(); }
#endif
// scaling variables
bool m_logicalFunctionSupported;
wxGraphicsMatrix m_matrixOriginal;
wxGraphicsMatrix m_matrixCurrent;
wxGraphicsMatrix m_matrixCurrentInv;
#if wxUSE_DC_TRANSFORM_MATRIX
wxAffineMatrix2D m_matrixExtTransform;
#endif // wxUSE_DC_TRANSFORM_MATRIX
wxGraphicsContext* m_graphicContext;
bool m_isClipBoxValid;
private:
// This method only initializes trivial fields.
void CommonInit();
// This method initializes all fields (including those initialized by
// CommonInit() as it calls it) and the given context, if non-null, which
// is assumed to be newly created.
void Init(wxGraphicsContext*);
// This method initializes m_graphicContext, m_ok and m_matrixOriginal
// fields, returns true if the context was valid.
bool DoInitContext(wxGraphicsContext* ctx);
// Another convenient wrapper for CalcBoundingBox().
// This is not an overload in order to avoid hiding the base class ones.
void CalcBoundingBoxForBox(const wxRect2DDouble& box)
{
CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y));
CalcBoundingBox(wxRound(box.m_x + box.m_width),
wxRound(box.m_y + box.m_height));
}
wxDECLARE_CLASS(wxGCDCImpl);
wxDECLARE_NO_COPY_CLASS(wxGCDCImpl);
};
#endif // wxUSE_GRAPHICS_CONTEXT
#endif // _WX_GRAPHICS_DC_H_