#define MAKEROP4(fore,back) (DWORD)((((back) << 8) & 0xFF000000) | (fore))
#endif
+// apparently with MicroWindows it is possible that HDC is 0 so we have to
+// check for this ourselves
+#ifdef __WXMICROWIN__
+ #define WXMICROWIN_CHECK_HDC if ( !GetHDC() ) return;
+ #define WXMICROWIN_CHECK_HDC_RET(x) if ( !GetHDC() ) return x;
+#else
+ #define WXMICROWIN_CHECK_HDC
+ #define WXMICROWIN_CHECK_HDC_RET(x)
+#endif
+
IMPLEMENT_ABSTRACT_CLASS(wxDC, wxDCBase)
// ---------------------------------------------------------------------------
void wxDC::UpdateClipBox()
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
RECT rect;
::GetClipBox(GetHdc(), &rect);
{
wxCHECK_RET( hrgn, wxT("invalid clipping region") );
-#ifdef __WXMICROWIN__
- if (!GetHdc()) return;
-#endif // __WXMICROWIN__
+ WXMICROWIN_CHECK_HDC
// note that we combine the new clipping region with the existing one: this
// is compatible with what the other ports do and is the documented
void wxDC::DestroyClippingRegion()
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
if (m_clipping && m_hDC)
{
int wxDC::GetDepth() const
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return 16;
-#endif
+ WXMICROWIN_CHECK_HDC_RET(16)
return (int)::GetDeviceCaps(GetHdc(), BITSPIXEL);
}
void wxDC::Clear()
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
RECT rect;
if ( m_canvas )
return FALSE;
#else
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return FALSE;
-#endif
+ WXMICROWIN_CHECK_HDC_RET(FALSE)
bool success = (0 != ::ExtFloodFill(GetHdc(), XLOG2DEV(x), YLOG2DEV(y),
col.GetPixel(),
bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return FALSE;
-#endif
+ WXMICROWIN_CHECK_HDC_RET(FALSE)
wxCHECK_MSG( col, FALSE, _T("NULL colour parameter in wxDC::GetPixel") );
void wxDC::DoCrossHair(wxCoord x, wxCoord y)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
wxCoord x1 = x-VIEWPORT_EXTENT;
wxCoord y1 = y-VIEWPORT_EXTENT;
void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
wxDrawLine(GetHdc(), XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2));
DoDrawEllipticArcRot( xc-r, yc-r, 2*r, 2*r, sa, ea );
#else
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
void wxDC::DoDrawCheckMark(wxCoord x1, wxCoord y1,
wxCoord width, wxCoord height)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
wxCoord x2 = x1 + width,
y2 = y1 + height;
void wxDC::DoDrawPoint(wxCoord x, wxCoord y)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
COLORREF color = 0x00ffffff;
if (m_pen.Ok())
void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int fillStyle)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
wxCoord yoffset,
int fillStyle)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
int i, cnt;
void wxDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
// Do things less efficiently if we have offsets
if (xoffset != 0 || yoffset != 0)
void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
DoDrawEllipticArcRot( x, y, w, h, sa, ea );
#else
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling
void wxDC::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
wxCHECK_RET( icon.Ok(), wxT("invalid icon in DrawIcon") );
void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask )
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
wxCHECK_RET( bmp.Ok(), _T("invalid bitmap in wxDC::DrawBitmap") );
void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
DrawAnyText(text, x, y);
void wxDC::DrawAnyText(const wxString& text, wxCoord x, wxCoord y)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
// prepare for drawing the text
if ( m_textForegroundColour.Ok() )
wxCoord x, wxCoord y,
double angle)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
// we test that we have some font because otherwise we should still use the
// "else" part below to avoid that DrawRotatedText(angle = 180) and
void wxDC::DoSelectPalette(bool realize)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
// Set the old object temporarily, in case the assignment deletes an object
// that's not yet selected out.
void wxDC::SetFont(const wxFont& the_font)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
// Set the old object temporarily, in case the assignment deletes an object
// that's not yet selected out.
void wxDC::SetPen(const wxPen& pen)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
// Set the old object temporarily, in case the assignment deletes an object
// that's not yet selected out.
void wxDC::SetBrush(const wxBrush& brush)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
// Set the old object temporarily, in case the assignment deletes an object
// that's not yet selected out.
void wxDC::SetBackground(const wxBrush& brush)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
m_backgroundBrush = brush;
void wxDC::SetBackgroundMode(int mode)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
m_backgroundMode = mode;
void wxDC::SetLogicalFunction(int function)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
m_logicalFunction = function;
wxCoord wxDC::GetCharHeight() const
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return 0;
-#endif
+ WXMICROWIN_CHECK_HDC_RET(0)
TEXTMETRIC lpTextMetric;
wxCoord wxDC::GetCharWidth() const
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return 0;
-#endif
+ WXMICROWIN_CHECK_HDC_RET(0)
TEXTMETRIC lpTextMetric;
void wxDC::SetMapMode(int mode)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
m_mappingMode = mode;
void wxDC::SetUserScale(double x, double y)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
#ifndef __WXWINCE__
if ( x == m_userScaleX && y == m_userScaleY )
void wxDC::SetAxisOrientation(bool xLeftRight, bool yBottomUp)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
#ifndef __WXWINCE__
int signX = xLeftRight ? 1 : -1,
void wxDC::SetSystemScale(double x, double y)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
#ifndef __WXWINCE__
if ( x == m_scaleX && y == m_scaleY )
void wxDC::SetLogicalOrigin(wxCoord x, wxCoord y)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
#ifndef __WXWINCE__
if ( x == m_logicalOriginX && y == m_logicalOriginY )
void wxDC::SetDeviceOrigin(wxCoord x, wxCoord y)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
#ifndef __WXWINCE__
if ( x == m_deviceOriginX && y == m_deviceOriginY )
{
wxCHECK_MSG( source, FALSE, _T("wxDC::Blit(): NULL wxDC pointer") );
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return FALSE;
-#endif
+ WXMICROWIN_CHECK_HDC_RET(FALSE)
const wxBitmap& bmpSrc = source->m_selectedBitmap;
if ( bmpSrc.Ok() && bmpSrc.HasAlpha() )
void wxDC::DoGetSize(int *w, int *h) const
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
if ( w ) *w = ::GetDeviceCaps(GetHdc(), HORZRES);
if ( h ) *h = ::GetDeviceCaps(GetHdc(), VERTRES);
void wxDC::DoGetSizeMM(int *w, int *h) const
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
// if we implement it in terms of DoGetSize() instead of directly using the
// results returned by GetDeviceCaps(HORZ/VERTSIZE) as was done before, it
wxSize wxDC::GetPPI() const
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return wxSize();
-#endif
+ WXMICROWIN_CHECK_HDC_RET(wxSize())
int x = ::GetDeviceCaps(GetHdc(), LOGPIXELSX);
int y = ::GetDeviceCaps(GetHdc(), LOGPIXELSY);
// For use by wxWindows only, unless custom units are required.
void wxDC::SetLogicalScale(double x, double y)
{
-#ifdef __WXMICROWIN__
- if (!GetHDC()) return;
-#endif
+ WXMICROWIN_CHECK_HDC
m_logicalScaleX = x;
m_logicalScaleY = y;