\helpref{wxCONCAT}{wxconcat}\\
\helpref{wxConcatFiles}{wxconcatfiles}\\
\helpref{wxConstCast}{wxconstcast}\\
+\helpref{wxCoordRound}{wxcoordround}\\
\helpref{wxCopyFile}{wxcopyfile}\\
\helpref{wxCreateDynamicObject}{wxcreatedynamicobject}\\
\helpref{wxCreateFileTipProvider}{wxcreatefiletipprovider}\\
this language feature but still take advantage of it when it is available.
+
+\membersection{::wxCoordRound}\label{wxcoordround}
+
+\func{wxCoord}{wxCoordRound}{\param{const float\& }{f}}
+
+\func{wxCoord}{wxCoordRound}{\param{const double\& }{f}}
+
+Convert \em{f} to a wxCoord, using round-to-nearest. This is commonly used
+in scaling calculations.
+
+\wxheading{Include files}
+
+<wx/defs.h>
+
+
\membersection{::wxGetKeyState}\label{wxgetkeystate}
\func{bool}{wxGetKeyState}{\param{wxKeyCode }{key}}
enum { wxDefaultCoord = -1 };
+/* round-to-nearest (used in scaling) */
+#ifdef __cplusplus
+inline wxCoord wxCoordRound(const float& f)
+{
+ return (f > 0) ? (wxCoord)(f + 0.5) : (f < 0) ? (wxCoord)(f - 0.5) : 0;
+}
+inline wxCoord wxCoordRound(const double& f)
+{
+ return (f > 0) ? (wxCoord)(f + 0.5) : (f < 0) ? (wxCoord)(f - 0.5) : 0;
+}
+#endif
+
/* ---------------------------------------------------------------------------- */
/* define fixed length types */
/* ---------------------------------------------------------------------------- */
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;
+ return wxCoordRound((double)(x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX;
}
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);
+ return wxCoordRound((double)(x) / m_scaleX);
}
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;
+ return wxCoordRound((double)(y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY;
}
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);
+ return wCoordRound((double)(y) / m_scaleY);
}
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;
+ return wxCoordRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX;
}
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);
+ return wxCoordRound((double)(x) * m_scaleX);
}
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;
+ return wxCoordRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY;
}
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);
+ return wxCoordRound((double)(y) * m_scaleY);
}
// Returns the surface (and increases its ref count)
private:
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;
+ return wxCoordRound((double)(x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX;
}
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);
+ return wxCoordRound((double)(x) / m_scaleX);
}
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;
+ return wxCoordRound((double)(y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY;
}
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);
+ return wCoordRound((double)(y) / m_scaleY);
}
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;
+ return wxCoordRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX;
}
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);
+ return wxCoordRound((double)(x) * m_scaleX);
}
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;
+ return wxCoordRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY;
}
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);
+ return wxCoordRound((double)(y) * m_scaleY);
}
private:
DECLARE_DYNAMIC_CLASS(wxGnomePrintDC)
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;
+ return wxCoordRound((double)(x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX;
}
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);
+ return wxCoordRound((double)(x) / m_scaleX);
}
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;
+ return wxCoordRound((double)(y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY;
}
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);
+ return wCoordRound((double)(y) / m_scaleY);
}
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;
+ return wxCoordRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX;
}
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);
+ return wxCoordRound((double)(x) * m_scaleX);
}
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;
+ return wxCoordRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY;
}
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);
+ return wxCoordRound((double)(y) * m_scaleY);
}
protected:
public:
wxCoord XDEV2LOG(wxCoord x) const
{
- long 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;
+ return wxCoordRound((double)(x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX;
}
-
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);
+ return wxCoordRound((double)(x) / m_scaleX);
}
-
wxCoord YDEV2LOG(wxCoord y) const
{
- long 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;
+ return wxCoordRound((double)(y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY;
}
-
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);
+ return wCoordRound((double)(y) / m_scaleY);
}
-
wxCoord XLOG2DEV(wxCoord x) const
{
- long 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;
+ return wxCoordRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX;
}
-
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);
+ return wxCoordRound((double)(x) * m_scaleX);
}
-
wxCoord YLOG2DEV(wxCoord y) const
{
- long 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;
+ return wxCoordRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY;
}
-
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);
+ return wxCoordRound((double)(y) * m_scaleY);
}
wxCoord XLOG2DEVMAC(wxCoord x) const
{
- long new_x = x - m_logicalOriginX;
- if (new_x > 0)
- return (wxCoord)((double)new_x * m_scaleX + 0.5) * m_signX + m_deviceOriginX + m_macLocalOrigin.x;
- else
- return (wxCoord)((double)new_x * m_scaleX - 0.5) * m_signX + m_deviceOriginX + m_macLocalOrigin.x;
+ return wxCoordRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX + m_macLocalOrigin.x;
}
wxCoord YLOG2DEVMAC(wxCoord y) const
{
- long new_y = y - m_logicalOriginY;
- if (new_y > 0)
- return (wxCoord)((double)new_y * m_scaleY + 0.5) * m_signY + m_deviceOriginY + m_macLocalOrigin.y;
- else
- return (wxCoord)((double)new_y * m_scaleY - 0.5) * m_signY + m_deviceOriginY + m_macLocalOrigin.y;
+ return wxCoordRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY + m_macLocalOrigin.y;
}
#if wxMAC_USE_CORE_GRAPHICS
wxCoord XDEV2LOG(wxCoord x) const
{
- long 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;
+ return wxCoordRound((double)(x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX;
}
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);
+ return wxCoordRound((double)(x) / m_scaleX);
}
wxCoord YDEV2LOG(wxCoord y) const
{
- long 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;
+ return wxCoordRound((double)(y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY;
}
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);
+ return wCoordRound((double)(y) / m_scaleY);
}
wxCoord XLOG2DEV(wxCoord x) const
{
- long 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 ;
+ return wxCoordRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX;
}
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);
+ return wxCoordRound((double)(x) * m_scaleX);
}
wxCoord YLOG2DEV(wxCoord y) const
{
- long 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 ;
+ return wxCoordRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY;
}
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);
+ return wxCoordRound((double)(y) * m_scaleY);
}
+
wxCoord XLOG2DEVMAC(wxCoord x) const
{
- long new_x = x - m_logicalOriginX;
- if (new_x > 0)
- return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX + m_macLocalOrigin.x ;
- else
- return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX + m_macLocalOrigin.x ;
+ return wxCoordRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX + m_macLocalOrigin.x;
}
+
wxCoord YLOG2DEVMAC(wxCoord y) const
{
- long new_y = y - m_logicalOriginY ;
- if (new_y > 0)
- return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY + m_macLocalOrigin.y ;
- else
- return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY + m_macLocalOrigin.y ;
+ return wxCoordRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY + m_macLocalOrigin.y;
}
WXHRGN MacGetCurrentClipRgn() { return m_macCurrentClipRgn ; }
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;
+ return wxCoordRound((double)(x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX;
}
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);
+ return wxCoordRound((double)(x) / m_scaleX);
}
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;
+ return wxCoordRound((double)(y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY;
}
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);
+ return wCoordRound((double)(y) / m_scaleY);
}
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;
+ return wxCoordRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX;
}
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);
+ return wxCoordRound((double)(x) * m_scaleX);
}
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;
+ return wxCoordRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY;
}
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);
+ return wxCoordRound((double)(y) * m_scaleY);
}
MGLDevCtx *GetMGLDC() const { return m_MGLDC; }
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;
+ return wxCoordRound((double)(x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX;
}
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);
+ return wxCoordRound((double)(x) / m_scaleX);
}
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;
+ return wxCoordRound((double)(y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY;
}
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);
+ return wCoordRound((double)(y) / m_scaleY);
}
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;
+ return wxCoordRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX;
}
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);
+ return wxCoordRound((double)(x) * m_scaleX);
}
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;
+ return wxCoordRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY;
}
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);
+ return wxCoordRound((double)(y) * m_scaleY);
}
public:
GetPageSizeMM(&mw, &mh);
float mmToDeviceX = float(pw) / mw;
float mmToDeviceY = float(ph) / mh;
- wxRect pageMarginsRect(paperRect.x + wxCoord(mmToDeviceX * topLeft.x),
- paperRect.y + wxCoord(mmToDeviceY * topLeft.y),
- paperRect.width - wxCoord(mmToDeviceX * (topLeft.x + bottomRight.x)),
- paperRect.height - wxCoord(mmToDeviceY * (topLeft.y + bottomRight.y)));
+ wxRect pageMarginsRect(paperRect.x + wxCoordRound(mmToDeviceX * topLeft.x),
+ paperRect.y + wxCoordRound(mmToDeviceY * topLeft.y),
+ paperRect.width - wxCoordRound(mmToDeviceX * (topLeft.x + bottomRight.x)),
+ paperRect.height - wxCoordRound(mmToDeviceY * (topLeft.y + bottomRight.y)));
wxCoord w, h;
m_printoutDC->GetSize(&w, &h);
float scaleX = (float(pageMarginsRect.width) * w) / (float(pw) * imageSize.x);
// This DC doesn't match the printed page, so we have to scale.
float scaleX = float(w) / pw;
float scaleY = float(h) / ph;
- return wxRect(m_printoutDC->DeviceToLogicalX(wxCoord(paperRect.x * scaleX)),
- m_printoutDC->DeviceToLogicalY(wxCoord(paperRect.y * scaleY)),
- m_printoutDC->DeviceToLogicalXRel(wxCoord(paperRect.width * scaleX)),
- m_printoutDC->DeviceToLogicalYRel(wxCoord(paperRect.height * scaleY)));
+ return wxRect(m_printoutDC->DeviceToLogicalX(wxCoordRound(paperRect.x * scaleX)),
+ m_printoutDC->DeviceToLogicalY(wxCoordRound(paperRect.y * scaleY)),
+ m_printoutDC->DeviceToLogicalXRel(wxCoordRound(paperRect.width * scaleX)),
+ m_printoutDC->DeviceToLogicalYRel(wxCoordRound(paperRect.height * scaleY)));
}
wxRect wxPrintout::GetLogicalPageRect() const
GetPageSizeMM(&mw, &mh);
float mmToDeviceX = float(pw) / mw;
float mmToDeviceY = float(ph) / mh;
- wxRect pageMarginsRect(paperRect.x + wxCoord(mmToDeviceX * topLeft.x),
- paperRect.y + wxCoord(mmToDeviceY * topLeft.y),
- paperRect.width - wxCoord(mmToDeviceX * (topLeft.x + bottomRight.x)),
- paperRect.height - wxCoord(mmToDeviceY * (topLeft.y + bottomRight.y)));
+ wxRect pageMarginsRect(paperRect.x + wxCoordRound(mmToDeviceX * topLeft.x),
+ paperRect.y + wxCoordRound(mmToDeviceY * topLeft.y),
+ paperRect.width - wxCoordRound(mmToDeviceX * (topLeft.x + bottomRight.x)),
+ paperRect.height - wxCoordRound(mmToDeviceY * (topLeft.y + bottomRight.y)));
wxCoord w, h;
m_printoutDC->GetSize(&w, &h);
if (w == pw && h == ph) {
// This DC doesn't match the printed page, so we have to scale.
float scaleX = float(w) / pw;
float scaleY = float(h) / ph;
- return wxRect(m_printoutDC->DeviceToLogicalX(wxCoord(pageMarginsRect.x * scaleX)),
- m_printoutDC->DeviceToLogicalY(wxCoord(pageMarginsRect.y * scaleY)),
- m_printoutDC->DeviceToLogicalXRel(wxCoord(pageMarginsRect.width * scaleX)),
- m_printoutDC->DeviceToLogicalYRel(wxCoord(pageMarginsRect.height * scaleY)));
+ return wxRect(m_printoutDC->DeviceToLogicalX(wxCoordRound(pageMarginsRect.x * scaleX)),
+ m_printoutDC->DeviceToLogicalY(wxCoordRound(pageMarginsRect.y * scaleY)),
+ m_printoutDC->DeviceToLogicalXRel(wxCoordRound(pageMarginsRect.width * scaleX)),
+ m_printoutDC->DeviceToLogicalYRel(wxCoordRound(pageMarginsRect.height * scaleY)));
}
void wxPrintout::SetLogicalOrigin(wxCoord x, wxCoord y)
*/ // TODO
wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const
{
- long 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;
+ return wxCoordRound((double)(x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX;
}
wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const
{
- long 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;
+ return wxCoordRound((double)(y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY;
}
wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const
{
- if (x > 0)
- return (wxCoord)((double)x / m_scaleX + 0.5);
- else
- return (wxCoord)((double)x / m_scaleX - 0.5);
+ return wxCoordRound((double)(x) / m_scaleX);
}
wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const
{
- if (y > 0)
- return (wxCoord)((double)y / m_scaleY + 0.5);
- else
- return (wxCoord)((double)y / m_scaleY - 0.5);
+ return wxCoordRound((double)(y) / m_scaleY);
}
wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const
{
- long 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;
+ return wxCoordRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX;
}
wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const
{
- long 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;
+ return wxCoordRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY;
}
wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const
{
- if (x > 0)
- return (wxCoord)((double)x * m_scaleX + 0.5);
- else
- return (wxCoord)((double)x * m_scaleX - 0.5);
+ return wxCoordRound((double)(x) * m_scaleX);
}
wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
{
- if (y > 0)
- return (wxCoord)((double)y * m_scaleY + 0.5);
- else
- return (wxCoord)((double)y * m_scaleY - 0.5);
+ return wxCoordRound((double)(y) * m_scaleY);
}
#endif // wxMAC_USE_CORE_GRAPHICS