#endif
#ifndef WX_PRECOMP
- #include "wx/frame.h"
+ #include "wx/window.h"
#include "wx/dc.h"
#include "wx/utils.h"
#include "wx/dialog.h"
#include "wx/app.h"
#include "wx/bitmap.h"
#include "wx/dcmemory.h"
+ #include "wx/log.h"
+ #include "wx/icon.h"
#endif
#include "wx/dcprint.h"
-#include "wx/msw/private.h"
#include <string.h>
#include <math.h>
#include <print.h>
#endif
-#ifdef DrawText
- #undef DrawText
-#endif
-
-#ifdef GetCharWidth
- #undef GetCharWidth
-#endif
-
-#ifdef StartDoc
- #undef StartDoc
-#endif
+#include "wx/msw/private.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
// constants
// ---------------------------------------------------------------------------
-#define VIEWPORT_EXTENT 1000
+static const int VIEWPORT_EXTENT = 1000;
+
+static const int MM_POINTS = 9;
+static const int MM_METRIC = 10;
// ---------------------------------------------------------------------------
// macros
// ---------------------------------------------------------------------------
+// Logical to device
+// Absolute
+#define XLOG2DEV(x) (x)
+#define YLOG2DEV(y) (y)
+
+// Relative
+#define XLOG2DEVREL(x) (x)
+#define YLOG2DEVREL(y) (y)
+
+// Device to logical
+// Absolute
+#define XDEV2LOG(x) (x)
+
+#define YDEV2LOG(y) (y)
+
+// Relative
+#define XDEV2LOGREL(x) (x)
+#define YDEV2LOGREL(y) (y)
+
+/*
+ * Have the same macros as for XView but not for every operation:
+ * just for calculating window/viewport extent (a better way of scaling).
+ */
+
+// Logical to device
+// Absolute
+#define MS_XLOG2DEV(x) LogicalToDevice(x)
+
+#define MS_YLOG2DEV(y) LogicalToDevice(y)
+
+// Relative
+#define MS_XLOG2DEVREL(x) LogicalToDeviceXRel(x)
+#define MS_YLOG2DEVREL(y) LogicalToDeviceYRel(y)
+
+// Device to logical
+// Absolute
+#define MS_XDEV2LOG(x) DeviceToLogicalX(x)
+
+#define MS_YDEV2LOG(y) DeviceToLogicalY(y)
+
+// Relative
+#define MS_XDEV2LOGREL(x) DeviceToLogicalXRel(x)
+#define MS_YDEV2LOGREL(y) DeviceToLogicalYRel(y)
+
#define YSCALE(y) (yorigin - (y))
+#define wx_round(a) (int)((a)+.5)
+
// ===========================================================================
// implementation
// ===========================================================================
long y2 = (y+height);
(void)RoundRect(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2),
- YLOG2DEV(y2), 2*XLOG2DEV(radius), 2*YLOG2DEV(radius));
+ YLOG2DEV(y2), (int) (2*XLOG2DEV(radius)), (int)( 2*YLOG2DEV(radius)));
CalcBoundingBox(x, y);
CalcBoundingBox(x2, y2);
HBITMAP hbitmap = (HBITMAP) bmp.GetHBITMAP( );
::SelectObject( memdc, hbitmap );
::BitBlt( cdc, x, y, bmp.GetWidth(), bmp.GetHeight(), memdc, 0, 0, SRCCOPY);
- ::SelectObject( memdc, 0 );
::DeleteDC( memdc );
}
else
else
SetBkMode(GetHdc(), OPAQUE);
- (void)TextOut(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), (char *) (const char *)text, strlen((const char *)text));
+ (void)TextOut(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), WXSTRINGCAST text, wxStrlen(WXSTRINGCAST text));
if (m_textBackgroundColour.Ok())
(void)SetBkColor(GetHdc(), old_background);
HFONT f = (HFONT) ::SelectObject(GetHdc(), (HFONT) m_font.GetResourceHandle());
if (f == (HFONT) NULL)
{
- wxLogDebug("::SelectObject failed in wxDC::SetFont.");
+ wxLogDebug(_T("::SelectObject failed in wxDC::SetFont."));
}
if (!m_oldFont)
m_oldFont = (WXHFONT) f;
SIZE sizeRect;
TEXTMETRIC tm;
- GetTextExtentPoint(GetHdc(), (char *)(const char *) string, strlen((char *)(const char *) string), &sizeRect);
+ GetTextExtentPoint(GetHdc(), WXSTRINGCAST string, wxStrlen(WXSTRINGCAST string), &sizeRect);
GetTextMetrics(GetHdc(), &tm);
if (x) *x = XDEV2LOGREL(sizeRect.cx);
long wxDCBase::LogicalToDeviceX(long x) const
{
- return (long) (floor((x) - m_logicalOriginX)*m_logicalScaleX*m_userScaleX*m_signX*m_scaleX + m_deviceOriginX);
+ return (long) ((x - m_logicalOriginX)*m_logicalScaleX*m_userScaleX*m_signX*m_scaleX + m_deviceOriginX);
}
long wxDCBase::LogicalToDeviceXRel(long x) const
{
- return (long) (floor(x)*m_logicalScaleX*m_userScaleX*m_signX*m_scaleX);
+ return (long) (x*m_logicalScaleX*m_userScaleX*m_signX*m_scaleX);
}
long wxDCBase::LogicalToDeviceY(long y) const
{
- return (long) (floor((y) - m_logicalOriginY)*m_logicalScaleY*m_userScaleY*m_signY*m_scaleY + m_deviceOriginY);
+ return (long) ((y - m_logicalOriginY)*m_logicalScaleY*m_userScaleY*m_signY*m_scaleY + m_deviceOriginY);
}
long wxDCBase::LogicalToDeviceYRel(long y) const
{
- return (long) (floor(y)*m_logicalScaleY*m_userScaleY*m_signY*m_scaleY);
+ return (long) (y*m_logicalScaleY*m_userScaleY*m_signY*m_scaleY);
}
// ---------------------------------------------------------------------------