\membersection{wxDC::DeviceToLogicalX}\label{wxdcdevicetologicalx}
-\func{wxCoord}{DeviceToLogicalX}{\param{wxCoord}{ x}}
+\func{virtual wxCoord}{DeviceToLogicalX}{\param{wxCoord}{ x}}
Convert device X coordinate to logical coordinate, using the current
mapping mode.
\membersection{wxDC::DeviceToLogicalXRel}\label{wxdcdevicetologicalxrel}
-\func{wxCoord}{DeviceToLogicalXRel}{\param{wxCoord}{ x}}
+\func{virtual wxCoord}{DeviceToLogicalXRel}{\param{wxCoord}{ x}}
Convert device X coordinate to relative logical coordinate, using the current
mapping mode but ignoring the x axis orientation.
\membersection{wxDC::DeviceToLogicalY}\label{wxdcdevicetologicaly}
-\func{wxCoord}{DeviceToLogicalY}{\param{wxCoord}{ y}}
+\func{virtual wxCoord}{DeviceToLogicalY}{\param{wxCoord}{ y}}
Converts device Y coordinate to logical coordinate, using the current
mapping mode.
\membersection{wxDC::DeviceToLogicalYRel}\label{wxdcdevicetologicalyrel}
-\func{wxCoord}{DeviceToLogicalYRel}{\param{wxCoord}{ y}}
+\func{virtual wxCoord}{DeviceToLogicalYRel}{\param{wxCoord}{ y}}
Convert device Y coordinate to relative logical coordinate, using the current
mapping mode but ignoring the y axis orientation.
\membersection{wxDC::LogicalToDeviceX}\label{wxdclogicaltodevicex}
-\func{wxCoord}{LogicalToDeviceX}{\param{wxCoord}{ x}}
+\func{virtual wxCoord}{LogicalToDeviceX}{\param{wxCoord}{ x}}
Converts logical X coordinate to device coordinate, using the current
mapping mode.
\membersection{wxDC::LogicalToDeviceXRel}\label{wxdclogicaltodevicexrel}
-\func{wxCoord}{LogicalToDeviceXRel}{\param{wxCoord}{ x}}
+\func{virtual wxCoord}{LogicalToDeviceXRel}{\param{wxCoord}{ x}}
Converts logical X coordinate to relative device coordinate, using the current
mapping mode but ignoring the x axis orientation.
\membersection{wxDC::LogicalToDeviceY}\label{wxdclogicaltodevicey}
-\func{wxCoord}{LogicalToDeviceY}{\param{wxCoord}{ y}}
+\func{virtual wxCoord}{LogicalToDeviceY}{\param{wxCoord}{ y}}
Converts logical Y coordinate to device coordinate, using the current
mapping mode.
\membersection{wxDC::LogicalToDeviceYRel}\label{wxdclogicaltodeviceyrel}
-\func{wxCoord}{LogicalToDeviceYRel}{\param{wxCoord}{ y}}
+\func{virtual wxCoord}{LogicalToDeviceYRel}{\param{wxCoord}{ y}}
Converts logical Y coordinate to relative device coordinate, using the current
mapping mode but ignoring the y axis orientation.
// This group of functions does actual conversion of the input, as you'd
// expect.
- wxCoord DeviceToLogicalX(wxCoord x) const;
- wxCoord DeviceToLogicalY(wxCoord y) const;
- wxCoord DeviceToLogicalXRel(wxCoord x) const;
- wxCoord DeviceToLogicalYRel(wxCoord y) const;
- wxCoord LogicalToDeviceX(wxCoord x) const;
- wxCoord LogicalToDeviceY(wxCoord y) const;
- wxCoord LogicalToDeviceXRel(wxCoord x) const;
- wxCoord LogicalToDeviceYRel(wxCoord y) const;
+ virtual wxCoord DeviceToLogicalX(wxCoord x) const = 0;
+ virtual wxCoord DeviceToLogicalY(wxCoord y) const = 0;
+ virtual wxCoord DeviceToLogicalXRel(wxCoord x) const = 0;
+ virtual wxCoord DeviceToLogicalYRel(wxCoord y) const = 0;
+ virtual wxCoord LogicalToDeviceX(wxCoord x) const = 0;
+ virtual wxCoord LogicalToDeviceY(wxCoord y) const = 0;
+ virtual wxCoord LogicalToDeviceXRel(wxCoord x) const = 0;
+ virtual wxCoord LogicalToDeviceYRel(wxCoord y) const = 0;
// query DC capabilities
// ---------------------
class WXDLLIMPEXP_CORE wxSVGFileDC : public wxDC
{
+public:
+ wxSVGFileDC (wxString f);
+ wxSVGFileDC (wxString f, int Width, int Height);
+ wxSVGFileDC (wxString f, int Width, int Height, float dpi);
+
+ ~wxSVGFileDC();
- private:
- wxFileOutputStream * m_outfile ;
- wxString m_filename ;
- //holds number of png format images we have
- int m_sub_images ;
- bool m_OK, m_graphics_changed ;
- int m_width, m_height ;
-
- double
- m_logicalScaleX,
- m_logicalScaleY,
- m_userScaleX,
- m_userScaleY,
- m_scaleX,
- m_scaleY,
- m_OriginX,
- m_OriginY,
- m_mm_to_pix_x,
- m_mm_to_pix_y;
-
- bool
- m_needComputeScaleX,
- m_needComputeScaleY; // not yet used
+ bool CanDrawBitmap() const { return true; }
+ bool CanGetTextExtent() const { return true; }
+ int GetDepth() const
+ { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetDepth Call not implemented")); return -1 ; }
+
+ void Clear()
+ { wxASSERT_MSG (false, wxT("wxSVGFILEDC::Clear() Call not implemented \nNot sensible for an output file?")); return ; }
+
+ void DestroyClippingRegion()
+ { wxASSERT_MSG (false, wxT("wxSVGFILEDC::void Call not yet implemented")); return ; }
+
+ wxCoord GetCharHeight() const;
+ wxCoord GetCharWidth() const;
+
+ void SetClippingRegion(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxCoord WXUNUSED(width), wxCoord WXUNUSED(height))
+ { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetClippingRegion not implemented")); return ; }
+
+ void SetPalette(const wxPalette& WXUNUSED(palette))
+ { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetPalette not implemented")); return ; }
+
+ void GetClippingBox(wxCoord *WXUNUSED(x), wxCoord *WXUNUSED(y), wxCoord * WXUNUSED(width), wxCoord * WXUNUSED(height))
+ { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetClippingBox not implemented")); return ; }
+
+ void SetLogicalFunction(int WXUNUSED(function))
+ { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetLogicalFunction Call not implemented")); return ; }
+
+ int GetLogicalFunction() const
+ { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetLogicalFunction() not implemented")); return wxCOPY ; }
+
+ void SetBackground( const wxBrush &brush ) ;
+ void SetBackgroundMode( int mode ) ;
+ void SetBrush(const wxBrush& brush) ;
+ void SetFont(const wxFont& font) ;
+ void SetPen(const wxPen& pen) ;
+
+ bool IsOk() const {return m_OK;}
+
+ virtual wxCoord DeviceToLogicalX(wxCoord x) const;
+ virtual wxCoord DeviceToLogicalY(wxCoord y) const;
+ virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
+ virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
+ virtual wxCoord LogicalToDeviceX(wxCoord x) const;
+ virtual wxCoord LogicalToDeviceY(wxCoord y) const;
+ virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
+ virtual wxCoord LogicalToDeviceYRel(wxCoord y) const ;
+
+ virtual void SetMapMode( int mode );
+ virtual void SetUserScale( double x, double y );
+ virtual void SetLogicalScale( double x, double y );
+ virtual void SetLogicalOrigin( wxCoord x, wxCoord y );
+ virtual void SetDeviceOrigin( wxCoord x, wxCoord y );
+
+ virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp );
+
+ virtual void ComputeScaleAndOrigin();
+private:
bool DoGetPixel(wxCoord, wxCoord, class wxColour *) const
{ wxASSERT_MSG (false, wxT("wxSVGFILEDC::DoGetPixel Call not implemented")); return true; }
void DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) ;
+ void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0) ;
+
void DoDrawPoint(wxCoord, wxCoord) ;
void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int fillStyle) ;
void Init (wxString f, int Width, int Height, float dpi);
- void NewGraphics () ;
-
-#ifdef XDEV2LOG
-#undef XDEV2LOG
-#endif
- wxCoord XDEV2LOG(wxCoord x) const
- {
- wxCoord new_x = x - m_deviceOriginX;
- if (new_x > 0)
- return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
- else
- return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
- }
-#ifdef XDEV2LOGREL
-#undef XDEV2LOGREL
-#endif
- wxCoord XDEV2LOGREL(wxCoord x) const
- {
- if (x > 0)
- return (wxCoord)((double)(x) / m_scaleX + 0.5);
- else
- return (wxCoord)((double)(x) / m_scaleX - 0.5);
- }
-#ifdef YDEV2LOG
-#undef YDEV2LOG
-#endif
- wxCoord YDEV2LOG(wxCoord y) const
- {
- wxCoord new_y = y - m_deviceOriginY;
- if (new_y > 0)
- return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
- else
- return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
- }
-#ifdef YDEV2LOGREL
-#undef YDEV2LOGREL
-#endif
- wxCoord YDEV2LOGREL(wxCoord y) const
- {
- if (y > 0)
- return (wxCoord)((double)(y) / m_scaleY + 0.5);
- else
- return (wxCoord)((double)(y) / m_scaleY - 0.5);
- }
-#ifdef XLOG2DEV
-#undef XLOG2DEV
-#endif
- wxCoord XLOG2DEV(wxCoord x) const
- {
- wxCoord new_x = x - m_logicalOriginX;
- if (new_x > 0)
- return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
- else
- return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
- }
-#ifdef XLOG2DEVREL
-#undef XLOG2DEVREL
-#endif
- wxCoord XLOG2DEVREL(wxCoord x) const
- {
- if (x > 0)
- return (wxCoord)((double)(x) * m_scaleX + 0.5);
- else
- return (wxCoord)((double)(x) * m_scaleX - 0.5);
- }
-#ifdef YLOG2DEV
-#undef YLOG2DEV
-#endif
- wxCoord YLOG2DEV(wxCoord y) const
- {
- wxCoord new_y = y - m_logicalOriginY;
- if (new_y > 0)
- return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
- else
- return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
- }
-#ifdef YLOG2DEVREL
-#undef YLOG2DEVREL
-#endif
- wxCoord YLOG2DEVREL(wxCoord y) const
- {
- if (y > 0)
- return (wxCoord)((double)(y) * m_scaleY + 0.5);
- else
- return (wxCoord)((double)(y) * m_scaleY - 0.5);
- }
-
- void write(const wxString &s);
-
- public:
-
- wxSVGFileDC (wxString f);
- wxSVGFileDC (wxString f, int Width, int Height);
- wxSVGFileDC (wxString f, int Width, int Height, float dpi);
- ~wxSVGFileDC();
-
-
- bool CanDrawBitmap() const { return true; }
-
- bool CanGetTextExtent() const { return true; }
-
- int GetDepth() const
- { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetDepth Call not implemented")); return -1 ; }
-
- void BeginDrawing() { return;}
-
- bool Blit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC* source, wxCoord xsrc, wxCoord ysrc, int logicalFunc = wxCOPY, bool useMask = false)
- { return DoBlit(xdest, ydest, width, height, source, xsrc, ysrc, logicalFunc, useMask); }
-
- void Clear()
- { wxASSERT_MSG (false, wxT("wxSVGFILEDC::Clear() Call not implemented \nNot sensible for an output file?")); return ; }
-
- void CrossHair(wxCoord x, wxCoord y)
- { DoCrossHair (x,y); return; }
-
- virtual void ComputeScaleAndOrigin();
-
- void DestroyClippingRegion()
- { wxASSERT_MSG (false, wxT("wxSVGFILEDC::void Call not yet implemented")); return ; }
-
- wxCoord DeviceToLogicalX(wxCoord x) const ;
-
- wxCoord DeviceToLogicalXRel(wxCoord x) const ;
-
- wxCoord DeviceToLogicalY(wxCoord y) const ;
-
- wxCoord DeviceToLogicalYRel(wxCoord y) const ;
-
- void DrawBitmap(const wxBitmap& bitmap, wxCoord x, wxCoord y, bool transparent)
- { DoDrawBitmap ( bitmap, x, y, transparent ) ; return ;}
-
- void DrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
- {DoDrawIcon(icon, x, y) ; return ; }
-
- void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0) ;
-
- void EndDoc()
- { return ; }
-
- void EndDrawing()
- { return ; }
-
- void EndPage()
- { return ; }
-
- void FloodFill(wxCoord x, wxCoord y, wxColour *colour, int style=wxFLOOD_SURFACE)
- { DoFloodFill (x, y, *colour, style); return ;}
-
- wxCoord GetCharHeight() const;
-
- wxCoord GetCharWidth() const;
-
- void GetClippingBox(wxCoord *WXUNUSED(x), wxCoord *WXUNUSED(y), wxCoord * WXUNUSED(width), wxCoord * WXUNUSED(height))
- { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetClippingBox Call not yet implemented")); return ; }
-
- int GetLogicalFunction() const
- { wxASSERT_MSG (false, wxT("wxSVGFILEDC::GetLogicalFunction() Call not implemented")); return wxCOPY ; }
-
- int GetMapMode() const ;
-
- bool GetPixel(wxCoord x, wxCoord y, wxColour *colour)
- { return DoGetPixel (x, y, colour) ; }
-
- void GetUserScale(double *x, double *y) const ;
-
- wxCoord LogicalToDeviceX(wxCoord x) const ;
-
- wxCoord LogicalToDeviceXRel(wxCoord x) const ;
-
- wxCoord LogicalToDeviceY(wxCoord y) const ;
-
- wxCoord LogicalToDeviceYRel(wxCoord y) const ;
-
- bool Ok() const {return m_OK;}
-
- void SetAxisOrientation( bool xLeftRight, bool yBottomUp ) ;
-
- void SetClippingRegion(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxCoord WXUNUSED(width), wxCoord WXUNUSED(height))
- { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetClippingRegion Call not yet implemented")); return ; }
-
- void SetPalette(const wxPalette& WXUNUSED(palette))
- { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetPalette Call not yet implemented")); return ; }
-
- void SetBackground( const wxBrush &brush ) ;
-
- void SetBackgroundMode( int mode ) ;
-
- void SetBrush(const wxBrush& brush) ;
-
- void SetFont(const wxFont& font) ;
-
- void SetLogicalFunction(int WXUNUSED(function))
- { wxASSERT_MSG (false, wxT("wxSVGFILEDC::SetLogicalFunction Call not implemented")); return ; }
-
- void SetLogicalScale( double x, double y ) ;
-
- void SetLogicalOrigin( wxCoord x, wxCoord y ) ;
-
- void SetDeviceOrigin( wxCoord x, wxCoord y ) ;
-
- void SetMapMode(int anint) ;
-
- void SetPen(const wxPen& pen) ;
-
- void SetUserScale(double xScale, double yScale) ;
-
- bool StartDoc(const wxString& WXUNUSED(message))
- { return false; }
-
- void StartPage()
- { return ; }
+ void NewGraphics();
+
+ void write( const wxString &s );
+
+private:
+ wxFileOutputStream *m_outfile;
+ wxString m_filename;
+ int m_sub_images; // number of png format images we have
+ bool m_OK;
+ bool m_graphics_changed;
+ int m_width, m_height;
+ double m_mm_to_pix_x, m_mm_to_pix_y;
+
+private:
+ DECLARE_ABSTRACT_CLASS(wxSVGFileDC)
};
#endif // __DCSVG_H
virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
virtual void SetLogicalFunction(int function);
+ virtual wxCoord DeviceToLogicalX(wxCoord x) const;
+ virtual wxCoord DeviceToLogicalY(wxCoord y) const;
+ virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
+ virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
+ virtual wxCoord LogicalToDeviceX(wxCoord x) const;
+ virtual wxCoord LogicalToDeviceY(wxCoord y) const;
+ virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
+ virtual wxCoord LogicalToDeviceYRel(wxCoord y) const ;
+
// implementation from now on
// --------------------------
#define MM_METRIC 7
#endif
-//-----------------------------------------------------------------------------
-// coordinates transformations
-//-----------------------------------------------------------------------------
-
-inline wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const
-{
- return wxRound((x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX;
-}
-inline wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const
-{
- return wxRound((y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY;
-}
-inline wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const
-{
- return wxRound(x / m_scaleX);
-}
-inline wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const
-{
- return wxRound(y / m_scaleY);
-}
-inline wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const
-{
- return wxRound((x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX;
-}
-inline wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const
-{
- return wxRound((y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY;
-}
-inline wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const
-{
- return wxRound(x * m_scaleX);
-}
-inline wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
-{
- return wxRound(y * m_scaleY);
-}
-
//-----------------------------------------------------------------------------
// wxDC
//-----------------------------------------------------------------------------
virtual void StartPage() { }
virtual void EndPage() { }
+ virtual wxCoord DeviceToLogicalX(wxCoord x) const;
+ virtual wxCoord DeviceToLogicalY(wxCoord y) const;
+ virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
+ virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
+ virtual wxCoord LogicalToDeviceX(wxCoord x) const;
+ virtual wxCoord LogicalToDeviceY(wxCoord y) const;
+ virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
+ virtual wxCoord LogicalToDeviceYRel(wxCoord y) const ;
+
virtual void SetMapMode( int mode );
virtual void SetUserScale( double x, double y );
virtual void SetLogicalScale( double x, double y );
virtual void StartPage() { }
virtual void EndPage() { }
+ virtual wxCoord DeviceToLogicalX(wxCoord x) const;
+ virtual wxCoord DeviceToLogicalY(wxCoord y) const;
+ virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
+ virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
+ virtual wxCoord LogicalToDeviceX(wxCoord x) const;
+ virtual wxCoord LogicalToDeviceY(wxCoord y) const;
+ virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
+ virtual wxCoord LogicalToDeviceYRel(wxCoord y) const ;
+
virtual void SetMapMode( int mode );
virtual void SetUserScale( double x, double y );
virtual void SetLogicalScale( double x, double y );
virtual void ComputeScaleAndOrigin();
+ virtual wxCoord DeviceToLogicalX(wxCoord x) const;
+ virtual wxCoord DeviceToLogicalY(wxCoord y) const;
+ virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
+ virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
+ virtual wxCoord LogicalToDeviceX(wxCoord x) const;
+ virtual wxCoord LogicalToDeviceY(wxCoord y) const;
+ virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
+ virtual wxCoord LogicalToDeviceYRel(wxCoord y) const ;
+
public:
wxCoord XDEV2LOG(wxCoord x) const
{
virtual int GetDepth() const;
virtual wxSize GetPPI() const;
+ virtual wxCoord DeviceToLogicalX(wxCoord x) const;
+ virtual wxCoord DeviceToLogicalY(wxCoord y) const;
+ virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
+ virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
+ virtual wxCoord LogicalToDeviceX(wxCoord x) const;
+ virtual wxCoord LogicalToDeviceY(wxCoord y) const;
+ virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
+ virtual wxCoord LogicalToDeviceYRel(wxCoord y) const ;
+
virtual void SetMapMode(int mode);
virtual void SetUserScale(double x, double y);
virtual void SetSystemScale(double x, double y);
);
virtual void SetLogicalFunction(int nFunction);
+ virtual wxCoord DeviceToLogicalX(wxCoord x) const;
+ virtual wxCoord DeviceToLogicalY(wxCoord y) const;
+ virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
+ virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
+ virtual wxCoord LogicalToDeviceX(wxCoord x) const;
+ virtual wxCoord LogicalToDeviceY(wxCoord y) const;
+ virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
+ virtual wxCoord LogicalToDeviceYRel(wxCoord y) const ;
+
// implementation from now on
// --------------------------
virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
virtual void SetLogicalFunction(int function);
+ virtual wxCoord DeviceToLogicalX(wxCoord x) const;
+ virtual wxCoord DeviceToLogicalY(wxCoord y) const;
+ virtual wxCoord DeviceToLogicalXRel(wxCoord x) const;
+ virtual wxCoord DeviceToLogicalYRel(wxCoord y) const;
+ virtual wxCoord LogicalToDeviceX(wxCoord x) const;
+ virtual wxCoord LogicalToDeviceY(wxCoord y) const;
+ virtual wxCoord LogicalToDeviceXRel(wxCoord x) const;
+ virtual wxCoord LogicalToDeviceYRel(wxCoord y) const ;
+
// implementation from now on
// --------------------------
return s ;
}
+// ----------------------------------------------------------
+// wxSVGFileDC
+// ----------------------------------------------------------
+
+IMPLEMENT_ABSTRACT_CLASS(wxSVGFileDC, wxDC)
void wxSVGFileDC::Init (wxString f, int Width, int Height, float dpi)
{
- //set up things first wxDCBase does all this?
m_width = Width ;
m_height = Height ;
- m_clipping = FALSE;
m_OK = TRUE;
m_mm_to_pix_x = dpi/25.4;
m_mm_to_pix_y = dpi/25.4;
- m_signX = m_signY = 1;
-
- m_userScaleX = m_userScaleY =
- m_deviceOriginX = m_deviceOriginY = 0;
-
- m_OriginX = m_OriginY = 0;
- m_logicalOriginX = m_logicalOriginY = 0;
- m_logicalScaleX = m_logicalScaleY = 0 ;
- m_scaleX = m_scaleY = 1.0 ;
-
- m_logicalFunction = wxCOPY;
- m_backgroundMode = wxTRANSPARENT;
- m_mappingMode = wxMM_TEXT;
-
m_backgroundBrush = *wxTRANSPARENT_BRUSH;
m_textForegroundColour = *wxBLACK;
m_textBackgroundColour = *wxWHITE;
sWarn = sWarn + wxT("<!--- wxSVGFileDC::SetPen Call called to set a Style which is not available --> \n") ;
}
- sLast.Printf ( wxT("stroke-width:%d\" \n transform=\"translate(%.2g %.2g) scale(%.2g %.2g)\">"),
- w, m_OriginX, m_OriginY, m_scaleX, m_scaleY );
+ sLast.Printf( wxT("stroke-width:%d\" \n transform=\"translate(%.2g %.2g) scale(%.2g %.2g)\">"),
+ w, (double)m_logicalOriginX, m_logicalOriginY, m_scaleX, m_scaleY );
s = sBrush + sPenCap + sPenJoin + sPenStyle + sLast + newline + sWarn;
write(s);
}
-void wxSVGFileDC::ComputeScaleAndOrigin()
-{
- m_scaleX = m_logicalScaleX * m_userScaleX;
- m_scaleY = m_logicalScaleY * m_userScaleY;
- m_OriginX = m_logicalOriginX * m_logicalScaleX + m_deviceOriginX ;
- m_OriginY = m_logicalOriginY * m_logicalScaleY + m_deviceOriginY ;
- m_graphics_changed = TRUE;
-}
-
-
-int wxSVGFileDC::GetMapMode() const
-{
- return m_mappingMode ;
-}
-
-
-void wxSVGFileDC::SetMapMode( int mode )
-{
- switch (mode)
- {
- case wxMM_TWIPS:
- SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y );
- break;
- case wxMM_POINTS:
- SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y );
- break;
- case wxMM_METRIC:
- SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y );
- break;
- case wxMM_LOMETRIC:
- SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 );
- break;
- default:
- case wxMM_TEXT:
- SetLogicalScale( 1.0, 1.0 );
- break;
- }
- m_mappingMode = mode;
-
- /* we don't do this mega optimisation
- if (mode != wxMM_TEXT)
- {
- m_needComputeScaleX = TRUE;
- m_needComputeScaleY = TRUE;
- }
- */
-}
-
-
-void wxSVGFileDC::GetUserScale(double *x, double *y) const
-{
- *x = m_userScaleX ;
- *y = m_userScaleY ;
-}
-
-
-void wxSVGFileDC::SetUserScale( double x, double y )
-{
- // allow negative ? -> no
- m_userScaleX = x;
- m_userScaleY = y;
- ComputeScaleAndOrigin();
-}
-
-
-void wxSVGFileDC::SetLogicalScale( double x, double y )
-{
- // allow negative ?
- m_logicalScaleX = x;
- m_logicalScaleY = y;
- ComputeScaleAndOrigin();
-}
-
-
-void wxSVGFileDC::SetLogicalOrigin( wxCoord x, wxCoord y )
-{
- // is this still correct ?
- m_logicalOriginX = x * m_signX;
- m_logicalOriginY = y * m_signY;
- ComputeScaleAndOrigin();
-}
-
-
-void wxSVGFileDC::SetDeviceOrigin( wxCoord x, wxCoord y )
-{
- // only wxPostScripDC has m_signX = -1,
- m_deviceOriginX = x;
- m_deviceOriginY = y;
- ComputeScaleAndOrigin();
-}
-
-
-void wxSVGFileDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
-{
- // only wxPostScripDC has m_signX = -1,
- m_signX = (xLeftRight ? 1 : -1);
- m_signY = (yBottomUp ? -1 : 1);
- ComputeScaleAndOrigin();
-}
-
-
// export a bitmap as a raster image in png
bool wxSVGFileDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC* source, wxCoord xsrc, wxCoord ysrc,
return FALSE ;
}
-
void wxSVGFileDC::DoDrawIcon(const class wxIcon & myIcon, wxCoord x, wxCoord y)
{
wxBitmap myBitmap (myIcon.GetWidth(), myIcon.GetHeight() ) ;
return ;
}
-
-
void wxSVGFileDC::DoDrawBitmap(const class wxBitmap & bmp, wxCoord x, wxCoord y , bool WXUNUSED(bTransparent) /*=0*/ )
{
if (m_graphics_changed) NewGraphics ();
return ;
}
+void wxSVGFileDC::write(const wxString &s)
+{
+ const wxWX2MBbuf buf = s.mb_str(wxConvUTF8);
+ m_outfile->Write(buf, strlen((const char *)buf));
+ m_OK = m_outfile->Ok();
+}
// ---------------------------------------------------------------------------
// coordinates transformations
wxCoord wxSVGFileDC::DeviceToLogicalX(wxCoord x) const
{
- return XDEV2LOG(x);
+ return wxRound((x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX;
}
-
wxCoord wxSVGFileDC::DeviceToLogicalY(wxCoord y) const
{
- return YDEV2LOG(y);
+ return wxRound((y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY;
}
-
wxCoord wxSVGFileDC::DeviceToLogicalXRel(wxCoord x) const
{
- return XDEV2LOGREL(x);
+ return wxRound(x / m_scaleX);
}
-
wxCoord wxSVGFileDC::DeviceToLogicalYRel(wxCoord y) const
{
- return YDEV2LOGREL(y);
+ return wxRound(y / m_scaleY);
}
-
wxCoord wxSVGFileDC::LogicalToDeviceX(wxCoord x) const
{
- return XLOG2DEV(x);
+ return wxRound((x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX;
}
-
wxCoord wxSVGFileDC::LogicalToDeviceY(wxCoord y) const
{
- return YLOG2DEV(y);
+ return wxRound((y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY;
}
-
wxCoord wxSVGFileDC::LogicalToDeviceXRel(wxCoord x) const
{
- return XLOG2DEVREL(x);
+ return wxRound(x * m_scaleX);
}
-
wxCoord wxSVGFileDC::LogicalToDeviceYRel(wxCoord y) const
{
- return YLOG2DEVREL(y);
+ return wxRound(y * m_scaleY);
}
-void wxSVGFileDC::write(const wxString &s)
+void wxSVGFileDC::ComputeScaleAndOrigin()
{
- const wxWX2MBbuf buf = s.mb_str(wxConvUTF8);
- m_outfile->Write(buf, strlen((const char *)buf));
- m_OK = m_outfile->Ok();
+ m_scaleX = m_logicalScaleX * m_userScaleX;
+ m_scaleY = m_logicalScaleY * m_userScaleY;
}
+void wxSVGFileDC::SetMapMode( int mode )
+{
+ switch (mode)
+ {
+ case wxMM_TWIPS:
+ SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y );
+ break;
+ case wxMM_POINTS:
+ SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y );
+ break;
+ case wxMM_METRIC:
+ SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y );
+ break;
+ case wxMM_LOMETRIC:
+ SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 );
+ break;
+ default:
+ case wxMM_TEXT:
+ SetLogicalScale( 1.0, 1.0 );
+ break;
+ }
+ m_mappingMode = mode;
+}
+
+void wxSVGFileDC::SetUserScale( double x, double y )
+{
+ // allow negative ? -> no
+ m_userScaleX = x;
+ m_userScaleY = y;
+ ComputeScaleAndOrigin();
+}
+
+void wxSVGFileDC::SetLogicalScale( double x, double y )
+{
+ // allow negative ?
+ m_logicalScaleX = x;
+ m_logicalScaleY = y;
+ ComputeScaleAndOrigin();
+}
+
+void wxSVGFileDC::SetLogicalOrigin( wxCoord x, wxCoord y )
+{
+ m_logicalOriginX = x * m_signX; // is this still correct ?
+ m_logicalOriginY = y * m_signY;
+ ComputeScaleAndOrigin();
+}
+
+void wxSVGFileDC::SetDeviceOrigin( wxCoord x, wxCoord y )
+{
+ // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
+ m_deviceOriginX = x;
+ m_deviceOriginY = y;
+ ComputeScaleAndOrigin();
+}
+
+void wxSVGFileDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
+{
+ // only wxPostScripDC has m_signX = -1, we override SetAxisOrientation there
+ m_signX = (xLeftRight ? 1 : -1);
+ m_signY = (yBottomUp ? -1 : 1);
+ ComputeScaleAndOrigin();
+}
+
+
#ifdef __BORLANDC__
#pragma warn .rch
#pragma warn .ccc
// coordinates transformations
// ---------------------------------------------------------------------------
-wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const
+wxCoord wxDC::DeviceToLogicalX(wxCoord x) const
{
- return ((wxDC *)this)->XDEV2LOG(x);
+ return XDEV2LOG(x);
}
-wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const
+wxCoord wxDC::DeviceToLogicalY(wxCoord y) const
{
- return ((wxDC *)this)->YDEV2LOG(y);
+ return YDEV2LOG(y);
}
-wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const
+wxCoord wxDC::DeviceToLogicalXRel(wxCoord x) const
{
- return ((wxDC *)this)->XDEV2LOGREL(x);
+ return XDEV2LOGREL(x);
}
-wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const
+wxCoord wxDC::DeviceToLogicalYRel(wxCoord y) const
{
- return ((wxDC *)this)->YDEV2LOGREL(y);
+ return YDEV2LOGREL(y);
}
-wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const
+wxCoord wxDC::LogicalToDeviceX(wxCoord x) const
{
- return ((wxDC *)this)->XLOG2DEV(x);
+ return XLOG2DEV(x);
}
-wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const
+wxCoord wxDC::LogicalToDeviceY(wxCoord y) const
{
- return ((wxDC *)this)->YLOG2DEV(y);
+ return YLOG2DEV(y);
}
-wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const
+wxCoord wxDC::LogicalToDeviceXRel(wxCoord x) const
{
- return ((wxDC *)this)->XLOG2DEVREL(x);
+ return XLOG2DEVREL(x);
}
-wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
+wxCoord wxDC::LogicalToDeviceYRel(wxCoord y) const
{
- return ((wxDC *)this)->YLOG2DEVREL(y);
+ return YLOG2DEVREL(y);
}
// set various DC parameters
// ---------------------------------------------------------------------------
+wxCoord wxDC::DeviceToLogicalX(wxCoord x) const
+{
+ return wxRound((x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX;
+}
+
+wxCoord wxDC::DeviceToLogicalY(wxCoord y) const
+{
+ return wxRound((y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY;
+}
+
+wxCoord wxDC::DeviceToLogicalXRel(wxCoord x) const
+{
+ return wxRound(x / m_scaleX);
+}
+
+wxCoord wxDC::DeviceToLogicalYRel(wxCoord y) const
+{
+ return wxRound(y / m_scaleY);
+}
+
+wxCoord wxDC::LogicalToDeviceX(wxCoord x) const
+{
+ return wxRound((x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX;
+}
+
+wxCoord wxDC::LogicalToDeviceY(wxCoord y) const
+{
+ return wxRound((y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY;
+}
+
+wxCoord wxDC::LogicalToDeviceXRel(wxCoord x) const
+{
+ return wxRound(x * m_scaleX);
+}
+
+wxCoord wxDC::LogicalToDeviceYRel(wxCoord y) const
+{
+ return wxRound(y * m_scaleY);
+}
+
void wxDC::ComputeScaleAndOrigin()
{
m_scaleX = m_logicalScaleX * m_userScaleX;
// set various DC parameters
// ---------------------------------------------------------------------------
+wxCoord wxDC::DeviceToLogicalX(wxCoord x) const
+{
+ return wxRound((x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX;
+}
+
+wxCoord wxDC::DeviceToLogicalY(wxCoord y) const
+{
+ return wxRound((y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY;
+}
+
+wxCoord wxDC::DeviceToLogicalXRel(wxCoord x) const
+{
+ return wxRound(x / m_scaleX);
+}
+
+wxCoord wxDC::DeviceToLogicalYRel(wxCoord y) const
+{
+ return wxRound(y / m_scaleY);
+}
+
+wxCoord wxDC::LogicalToDeviceX(wxCoord x) const
+{
+ return wxRound((x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX;
+}
+
+wxCoord wxDC::LogicalToDeviceY(wxCoord y) const
+{
+ return wxRound((y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY;
+}
+
+wxCoord wxDC::LogicalToDeviceXRel(wxCoord x) const
+{
+ return wxRound(x * m_scaleX);
+}
+
+wxCoord wxDC::LogicalToDeviceYRel(wxCoord y) const
+{
+ return wxRound(y * m_scaleY);
+}
+
void wxDC::ComputeScaleAndOrigin()
{
m_scaleX = m_logicalScaleX * m_userScaleX;
// coordinates transformations
// ---------------------------------------------------------------------------
-wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const
+wxCoord wxDC::DeviceToLogicalX(wxCoord x) const
{
- return ((wxDC *)this)->XDEV2LOG(x);
+ return XDEV2LOG(x);
}
-wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const
+wxCoord wxDC::DeviceToLogicalY(wxCoord y) const
{
- return ((wxDC *)this)->YDEV2LOG(y);
+ return YDEV2LOG(y);
}
-wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const
+wxCoord wxDC::DeviceToLogicalXRel(wxCoord x) const
{
- return ((wxDC *)this)->XDEV2LOGREL(x);
+ return XDEV2LOGREL(x);
}
-wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const
+wxCoord wxDC::DeviceToLogicalYRel(wxCoord y) const
{
- return ((wxDC *)this)->YDEV2LOGREL(y);
+ return YDEV2LOGREL(y);
}
-wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const
+wxCoord wxDC::LogicalToDeviceX(wxCoord x) const
{
- return ((wxDC *)this)->XLOG2DEV(x);
+ return XLOG2DEV(x);
}
-wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const
+wxCoord wxDC::LogicalToDeviceY(wxCoord y) const
{
- return ((wxDC *)this)->YLOG2DEV(y);
+ return YLOG2DEV(y);
}
-wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const
+wxCoord wxDC::LogicalToDeviceXRel(wxCoord x) const
{
- return ((wxDC *)this)->XLOG2DEVREL(x);
+ return XLOG2DEVREL(x);
}
-wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
+wxCoord wxDC::LogicalToDeviceYRel(wxCoord y) const
{
- return ((wxDC *)this)->YLOG2DEVREL(y);
+ return YLOG2DEVREL(y);
}
#endif // !wxMAC_USE_CORE_GRAPHICS
// coordinates transformations
// ---------------------------------------------------------------------------
-wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const
+wxCoord wxDC::DeviceToLogicalX(wxCoord x) const
{
return DeviceToLogicalXRel(x - m_deviceOriginX)*m_signX + m_logicalOriginX;
}
-wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const
+wxCoord wxDC::DeviceToLogicalXRel(wxCoord x) const
{
// axis orientation is not taken into account for conversion of a distance
return (wxCoord)(x / (m_logicalScaleX*m_userScaleX*m_scaleX));
}
-wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const
+wxCoord wxDC::DeviceToLogicalY(wxCoord y) const
{
return DeviceToLogicalYRel(y - m_deviceOriginY)*m_signY + m_logicalOriginY;
}
-wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const
+wxCoord wxDC::DeviceToLogicalYRel(wxCoord y) const
{
// axis orientation is not taken into account for conversion of a distance
return (wxCoord)( y / (m_logicalScaleY*m_userScaleY*m_scaleY));
}
-wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const
+wxCoord wxDC::LogicalToDeviceX(wxCoord x) const
{
return LogicalToDeviceXRel(x - m_logicalOriginX)*m_signX + m_deviceOriginX;
}
-wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const
+wxCoord wxDC::LogicalToDeviceXRel(wxCoord x) const
{
// axis orientation is not taken into account for conversion of a distance
return (wxCoord) (x*m_logicalScaleX*m_userScaleX*m_scaleX);
}
-wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const
+wxCoord wxDC::LogicalToDeviceY(wxCoord y) const
{
return LogicalToDeviceYRel(y - m_logicalOriginY)*m_signY + m_deviceOriginY;
}
-wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
+wxCoord wxDC::LogicalToDeviceYRel(wxCoord y) const
{
// axis orientation is not taken into account for conversion of a distance
return (wxCoord) (y*m_logicalScaleY*m_userScaleY*m_scaleY);
return (wxCoord) ((x)/(m_logicalScaleX*m_userScaleX*m_scaleX));
}
-wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const
+wxCoord wxDC::DeviceToLogicalY(wxCoord y) const
{
return (wxCoord) (((y) - m_deviceOriginY)/(m_logicalScaleY*m_userScaleY*m_signY*m_scaleY) - m_logicalOriginY);
}
-wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const
+wxCoord wxDC::DeviceToLogicalYRel(wxCoord y) const
{
// axis orientation is not taken into account for conversion of a distance
return (wxCoord) ((y)/(m_logicalScaleY*m_userScaleY*m_scaleY));
}
-wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const
+wxCoord wxDC::LogicalToDeviceX(wxCoord x) const
{
return (wxCoord) ((x - m_logicalOriginX)*m_logicalScaleX*m_userScaleX*m_signX*m_scaleX + m_deviceOriginX);
}
-wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const
+wxCoord wxDC::LogicalToDeviceXRel(wxCoord x) const
{
// axis orientation is not taken into account for conversion of a distance
return (wxCoord) (x*m_logicalScaleX*m_userScaleX*m_scaleX);
}
-wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const
+wxCoord wxDC::LogicalToDeviceY(wxCoord y) const
{
return (wxCoord) ((y - m_logicalOriginY)*m_logicalScaleY*m_userScaleY*m_signY*m_scaleY + m_deviceOriginY);
}
-wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
+wxCoord wxDC::LogicalToDeviceYRel(wxCoord y) const
{
// axis orientation is not taken into account for conversion of a distance
return (wxCoord) (y*m_logicalScaleY*m_userScaleY*m_scaleY);
// coordinates transformations
// ---------------------------------------------------------------------------
-wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const
+wxCoord wxDC::DeviceToLogicalX(wxCoord x) const
{
return 0;
}
-wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const
+wxCoord wxDC::DeviceToLogicalXRel(wxCoord x) const
{
return 0;
}
-wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const
+wxCoord wxDC::DeviceToLogicalY(wxCoord y) const
{
return 0;
}
-wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const
+wxCoord wxDC::DeviceToLogicalYRel(wxCoord y) const
{
return 0;
}
-wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const
+wxCoord wxDC::LogicalToDeviceX(wxCoord x) const
{
return 0;
}
-wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const
+wxCoord wxDC::LogicalToDeviceXRel(wxCoord x) const
{
return 0;
}
-wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const
+wxCoord wxDC::LogicalToDeviceY(wxCoord y) const
{
return 0;
}
-wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
+wxCoord wxDC::LogicalToDeviceYRel(wxCoord y) const
{
return 0;
}