2003-07-21 15:15:17 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/dcmirror.h
|
|
|
|
// Purpose: wxMirrorDC class
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 21.07.2003
|
2004-05-23 10:56:36 -04:00
|
|
|
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2003-07-21 15:15:17 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_DCMIRROR_H_
|
|
|
|
#define _WX_DCMIRROR_H_
|
|
|
|
|
|
|
|
#include "wx/dc.h"
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxMirrorDC allows to write the same code for horz/vertical layout
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxMirrorDCImpl : public wxDCImpl
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// constructs a mirror DC associated with the given real DC
|
|
|
|
//
|
|
|
|
// if mirror parameter is true, all vertical and horizontal coordinates are
|
|
|
|
// exchanged, otherwise this class behaves in exactly the same way as a
|
|
|
|
// plain DC
|
2007-11-30 15:56:12 -05:00
|
|
|
wxMirrorDCImpl(wxDC *owner, wxDCImpl& dc, bool mirror)
|
|
|
|
: wxDCImpl(owner),
|
|
|
|
m_dc(dc)
|
|
|
|
{
|
|
|
|
m_mirror = mirror;
|
|
|
|
}
|
2003-07-21 15:15:17 -04:00
|
|
|
|
|
|
|
// wxDCBase operations
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void Clear() wxOVERRIDE { m_dc.Clear(); }
|
|
|
|
virtual void SetFont(const wxFont& font) wxOVERRIDE { m_dc.SetFont(font); }
|
|
|
|
virtual void SetPen(const wxPen& pen) wxOVERRIDE { m_dc.SetPen(pen); }
|
|
|
|
virtual void SetBrush(const wxBrush& brush) wxOVERRIDE { m_dc.SetBrush(brush); }
|
|
|
|
virtual void SetBackground(const wxBrush& brush) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{ m_dc.SetBackground(brush); }
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetBackgroundMode(int mode) wxOVERRIDE { m_dc.SetBackgroundMode(mode); }
|
2003-07-21 15:15:17 -04:00
|
|
|
#if wxUSE_PALETTE
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetPalette(const wxPalette& palette) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{ m_dc.SetPalette(palette); }
|
|
|
|
#endif // wxUSE_PALETTE
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DestroyClippingRegion() wxOVERRIDE { m_dc.DestroyClippingRegion(); }
|
|
|
|
virtual wxCoord GetCharHeight() const wxOVERRIDE { return m_dc.GetCharHeight(); }
|
|
|
|
virtual wxCoord GetCharWidth() const wxOVERRIDE { return m_dc.GetCharWidth(); }
|
|
|
|
virtual bool CanDrawBitmap() const wxOVERRIDE { return m_dc.CanDrawBitmap(); }
|
|
|
|
virtual bool CanGetTextExtent() const wxOVERRIDE { return m_dc.CanGetTextExtent(); }
|
|
|
|
virtual int GetDepth() const wxOVERRIDE { return m_dc.GetDepth(); }
|
|
|
|
virtual wxSize GetPPI() const wxOVERRIDE { return m_dc.GetPPI(); }
|
|
|
|
virtual bool IsOk() const wxOVERRIDE { return m_dc.IsOk(); }
|
|
|
|
virtual void SetMapMode(wxMappingMode mode) wxOVERRIDE { m_dc.SetMapMode(mode); }
|
|
|
|
virtual void SetUserScale(double x, double y) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{ m_dc.SetUserScale(GetX(x, y), GetY(x, y)); }
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetLogicalOrigin(wxCoord x, wxCoord y) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{ m_dc.SetLogicalOrigin(GetX(x, y), GetY(x, y)); }
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetDeviceOrigin(wxCoord x, wxCoord y) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{ m_dc.SetDeviceOrigin(GetX(x, y), GetY(x, y)); }
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{ m_dc.SetAxisOrientation(GetX(xLeftRight, yBottomUp),
|
|
|
|
GetY(xLeftRight, yBottomUp)); }
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetLogicalFunction(wxRasterOperationMode function) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{ m_dc.SetLogicalFunction(function); }
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void* GetHandle() const wxOVERRIDE
|
2012-07-28 15:31:03 -04:00
|
|
|
{ return m_dc.GetHandle(); }
|
|
|
|
|
2003-07-21 15:15:17 -04:00
|
|
|
protected:
|
|
|
|
// returns x and y if not mirroring or y and x if mirroring
|
|
|
|
wxCoord GetX(wxCoord x, wxCoord y) const { return m_mirror ? y : x; }
|
|
|
|
wxCoord GetY(wxCoord x, wxCoord y) const { return m_mirror ? x : y; }
|
|
|
|
double GetX(double x, double y) const { return m_mirror ? y : x; }
|
|
|
|
double GetY(double x, double y) const { return m_mirror ? x : y; }
|
|
|
|
bool GetX(bool x, bool y) const { return m_mirror ? y : x; }
|
|
|
|
bool GetY(bool x, bool y) const { return m_mirror ? x : y; }
|
|
|
|
|
|
|
|
// same thing but for pointers
|
|
|
|
wxCoord *GetX(wxCoord *x, wxCoord *y) const { return m_mirror ? y : x; }
|
|
|
|
wxCoord *GetY(wxCoord *x, wxCoord *y) const { return m_mirror ? x : y; }
|
|
|
|
|
|
|
|
// exchange x and y components of all points in the array if necessary
|
2013-01-18 12:27:51 -05:00
|
|
|
wxPoint* Mirror(int n, const wxPoint*& points) const
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
2013-01-18 12:27:51 -05:00
|
|
|
wxPoint* points_alloc = NULL;
|
2003-07-21 15:15:17 -04:00
|
|
|
if ( m_mirror )
|
|
|
|
{
|
2013-01-18 12:27:51 -05:00
|
|
|
points_alloc = new wxPoint[n];
|
2003-07-21 15:15:17 -04:00
|
|
|
for ( int i = 0; i < n; i++ )
|
|
|
|
{
|
2013-01-18 12:27:51 -05:00
|
|
|
points_alloc[i].x = points[i].y;
|
|
|
|
points_alloc[i].y = points[i].x;
|
2003-07-21 15:15:17 -04:00
|
|
|
}
|
2013-01-18 12:27:51 -05:00
|
|
|
points = points_alloc;
|
2003-07-21 15:15:17 -04:00
|
|
|
}
|
2013-01-18 12:27:51 -05:00
|
|
|
return points_alloc;
|
2003-07-21 15:15:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// wxDCBase functions
|
|
|
|
virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
|
2014-03-29 20:02:23 -04:00
|
|
|
wxFloodFillStyle style = wxFLOOD_SURFACE) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
return m_dc.DoFloodFill(GetX(x, y), GetY(x, y), col, style);
|
|
|
|
}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
return m_dc.DoGetPixel(GetX(x, y), GetY(x, y), col);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoDrawPoint(wxCoord x, wxCoord y) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
m_dc.DoDrawPoint(GetX(x, y), GetY(x, y));
|
|
|
|
}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
m_dc.DoDrawLine(GetX(x1, y1), GetY(x1, y1), GetX(x2, y2), GetY(x2, y2));
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void DoDrawArc(wxCoord x1, wxCoord y1,
|
|
|
|
wxCoord x2, wxCoord y2,
|
2014-03-29 20:02:23 -04:00
|
|
|
wxCoord xc, wxCoord yc) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
2009-07-23 16:30:22 -04:00
|
|
|
wxFAIL_MSG( wxT("this is probably wrong") );
|
2003-07-21 15:15:17 -04:00
|
|
|
|
|
|
|
m_dc.DoDrawArc(GetX(x1, y1), GetY(x1, y1),
|
2004-09-10 08:56:07 -04:00
|
|
|
GetX(x2, y2), GetY(x2, y2),
|
2003-07-21 15:15:17 -04:00
|
|
|
xc, yc);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
|
2014-03-29 20:02:23 -04:00
|
|
|
wxCoord w, wxCoord h) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
m_dc.DoDrawCheckMark(GetX(x, y), GetY(x, y),
|
|
|
|
GetX(w, h), GetY(w, h));
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
2014-03-29 20:02:23 -04:00
|
|
|
double sa, double ea) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
2009-07-23 16:30:22 -04:00
|
|
|
wxFAIL_MSG( wxT("this is probably wrong") );
|
2003-07-21 15:15:17 -04:00
|
|
|
|
|
|
|
m_dc.DoDrawEllipticArc(GetX(x, y), GetY(x, y),
|
2004-09-10 08:56:07 -04:00
|
|
|
GetX(w, h), GetY(w, h),
|
2003-07-21 15:15:17 -04:00
|
|
|
sa, ea);
|
|
|
|
}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
m_dc.DoDrawRectangle(GetX(x, y), GetY(x, y), GetX(w, h), GetY(w, h));
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
|
|
|
|
wxCoord w, wxCoord h,
|
2014-03-29 20:02:23 -04:00
|
|
|
double radius) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
m_dc.DoDrawRoundedRectangle(GetX(x, y), GetY(x, y),
|
|
|
|
GetX(w, h), GetY(w, h),
|
|
|
|
radius);
|
|
|
|
}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
m_dc.DoDrawEllipse(GetX(x, y), GetY(x, y), GetX(w, h), GetY(w, h));
|
|
|
|
}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoCrossHair(wxCoord x, wxCoord y) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
m_dc.DoCrossHair(GetX(x, y), GetY(x, y));
|
|
|
|
}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
m_dc.DoDrawIcon(icon, GetX(x, y), GetY(x, y));
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
|
2014-03-29 20:02:23 -04:00
|
|
|
bool useMask = false) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
m_dc.DoDrawBitmap(bmp, GetX(x, y), GetY(x, y), useMask);
|
|
|
|
}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
// this is never mirrored
|
|
|
|
m_dc.DoDrawText(text, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void DoDrawRotatedText(const wxString& text,
|
2014-03-29 20:02:23 -04:00
|
|
|
wxCoord x, wxCoord y, double angle) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
// this is never mirrored
|
|
|
|
m_dc.DoDrawRotatedText(text, x, y, angle);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
|
|
|
|
wxCoord w, wxCoord h,
|
|
|
|
wxDC *source, wxCoord xsrc, wxCoord ysrc,
|
2009-08-21 06:41:26 -04:00
|
|
|
wxRasterOperationMode rop = wxCOPY,
|
2009-01-08 09:21:53 -05:00
|
|
|
bool useMask = false,
|
2014-03-29 20:02:23 -04:00
|
|
|
wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
return m_dc.DoBlit(GetX(xdest, ydest), GetY(xdest, ydest),
|
|
|
|
GetX(w, h), GetY(w, h),
|
|
|
|
source, GetX(xsrc, ysrc), GetY(xsrc, ysrc),
|
|
|
|
rop, useMask,
|
|
|
|
GetX(xsrcMask, ysrcMask), GetX(xsrcMask, ysrcMask));
|
|
|
|
}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoGetSize(int *w, int *h) const wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
m_dc.DoGetSize(GetX(w, h), GetY(w, h));
|
|
|
|
}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoGetSizeMM(int *w, int *h) const wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
m_dc.DoGetSizeMM(GetX(w, h), GetY(w, h));
|
|
|
|
}
|
|
|
|
|
2013-01-18 12:27:51 -05:00
|
|
|
virtual void DoDrawLines(int n, const wxPoint points[],
|
2014-03-29 20:02:23 -04:00
|
|
|
wxCoord xoffset, wxCoord yoffset) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
2013-01-18 12:27:51 -05:00
|
|
|
wxPoint* points_alloc = Mirror(n, points);
|
2003-07-21 15:15:17 -04:00
|
|
|
|
|
|
|
m_dc.DoDrawLines(n, points,
|
|
|
|
GetX(xoffset, yoffset), GetY(xoffset, yoffset));
|
|
|
|
|
2013-01-18 12:27:51 -05:00
|
|
|
delete[] points_alloc;
|
2003-07-21 15:15:17 -04:00
|
|
|
}
|
|
|
|
|
2013-01-18 12:27:51 -05:00
|
|
|
virtual void DoDrawPolygon(int n, const wxPoint points[],
|
2003-07-21 15:15:17 -04:00
|
|
|
wxCoord xoffset, wxCoord yoffset,
|
2014-03-29 20:02:23 -04:00
|
|
|
wxPolygonFillMode fillStyle = wxODDEVEN_RULE) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
2013-01-18 12:27:51 -05:00
|
|
|
wxPoint* points_alloc = Mirror(n, points);
|
2003-07-21 15:15:17 -04:00
|
|
|
|
|
|
|
m_dc.DoDrawPolygon(n, points,
|
|
|
|
GetX(xoffset, yoffset), GetY(xoffset, yoffset),
|
|
|
|
fillStyle);
|
|
|
|
|
2013-01-18 12:27:51 -05:00
|
|
|
delete[] points_alloc;
|
2003-07-21 15:15:17 -04:00
|
|
|
}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void DoSetDeviceClippingRegion(const wxRegion& WXUNUSED(region)) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
2009-07-23 16:30:22 -04:00
|
|
|
wxFAIL_MSG( wxT("not implemented") );
|
2003-07-21 15:15:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
|
2014-03-29 20:02:23 -04:00
|
|
|
wxCoord w, wxCoord h) wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
m_dc.DoSetClippingRegion(GetX(x, y), GetY(x, y), GetX(w, h), GetY(w, h));
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void DoGetTextExtent(const wxString& string,
|
|
|
|
wxCoord *x, wxCoord *y,
|
|
|
|
wxCoord *descent = NULL,
|
|
|
|
wxCoord *externalLeading = NULL,
|
2014-03-29 20:02:23 -04:00
|
|
|
const wxFont *theFont = NULL) const wxOVERRIDE
|
2003-07-21 15:15:17 -04:00
|
|
|
{
|
|
|
|
// never mirrored
|
|
|
|
m_dc.DoGetTextExtent(string, x, y, descent, externalLeading, theFont);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2007-11-30 15:56:12 -05:00
|
|
|
wxDCImpl& m_dc;
|
|
|
|
|
|
|
|
bool m_mirror;
|
|
|
|
|
2009-02-08 06:45:59 -05:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxMirrorDCImpl);
|
2007-11-30 15:56:12 -05:00
|
|
|
};
|
2003-07-21 15:15:17 -04:00
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxMirrorDC : public wxDC
|
2007-11-30 15:56:12 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxMirrorDC(wxDC& dc, bool mirror)
|
|
|
|
: wxDC(new wxMirrorDCImpl(this, *dc.GetImpl(), mirror))
|
|
|
|
{
|
|
|
|
m_mirror = mirror;
|
|
|
|
}
|
|
|
|
|
|
|
|
// helper functions which may be useful for the users of this class
|
|
|
|
wxSize Reflect(const wxSize& sizeOrig)
|
|
|
|
{
|
|
|
|
return m_mirror ? wxSize(sizeOrig.y, sizeOrig.x) : sizeOrig;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2003-07-21 15:15:17 -04:00
|
|
|
bool m_mirror;
|
2003-07-21 20:24:07 -04:00
|
|
|
|
2009-02-08 06:45:59 -05:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxMirrorDC);
|
2003-07-21 15:15:17 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WX_DCMIRROR_H_
|
|
|
|
|