// Author: David Webster
// Modified by:
// Created: 10/14/99
-// RCS-ID: $Id$
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
m_hDC = hDC;
} // end of wxPMDCImpl::wxPMDCImpl
-wxPMDCImpl::~wxPMDCImpl(void)
+wxPMDCImpl::~wxPMDCImpl()
{
if ( m_hDC != 0 )
{
if (m_hOldBitmap)
{
::GpiSetBitmap(hPS, (HBITMAP) m_hOldBitmap);
- if (m_vSelectedBitmap.Ok())
+ if (m_vSelectedBitmap.IsOk())
{
m_vSelectedBitmap.SetSelectedInto(NULL);
}
DO_SET_CLIPPING_BOX()
} // end of wxPMDCImpl::DoSetClippingRegion
-void wxPMDCImpl::DoSetClippingRegionAsRegion(
+void wxPMDCImpl::DoSetDeviceClippingRegion(
const wxRegion& rRegion
)
{
,&hRgnOld
);
DO_SET_CLIPPING_BOX()
-} // end of wxPMDCImpl::DoSetClippingRegionAsRegion
+} // end of wxPMDCImpl::DoSetDeviceClippingRegion
-void wxPMDCImpl::DestroyClippingRegion(void)
+void wxPMDCImpl::DestroyClippingRegion()
{
if (m_clipping && m_hPS)
{
int wxPMDCImpl::GetDepth() const
{
- LONG lArray[CAPS_COLOR_BITCOUNT];
+ LONG lCapsColorBitcount;
int nBitsPerPixel = 0;
if(::DevQueryCaps( GetHDC()
- ,CAPS_FAMILY
,CAPS_COLOR_BITCOUNT
- ,lArray
+ ,1L
+ ,&lCapsColorBitcount
))
{
- nBitsPerPixel = (int)lArray[CAPS_COLOR_BITCOUNT];
+ nBitsPerPixel = (int)lCapsColorBitcount;
}
return nBitsPerPixel;
} // end of wxPMDCImpl::GetDepth
wxCoord vX
, wxCoord vY
, const wxColour& rCol
-, int nStyle
+, wxFloodFillStyle nStyle
)
{
POINTL vPtlPos;
}
else
{
- if (m_vSelectedBitmap.Ok())
+ if (m_vSelectedBitmap.IsOk())
{
m_vRclPaint.yTop = m_vSelectedBitmap.GetHeight();
m_vRclPaint.xRight = m_vSelectedBitmap.GetWidth();
vPoint[0].y = vY1;
vPoint[1].x = vX2;
vPoint[1].y = vY2;
- if (m_pen.Ok())
+ if (m_pen.IsOk())
{
vColor = m_pen.GetColour().GetPixel();
}
POINTL vPoint;
COLORREF vColor = 0x00ffffff;
- if (m_pen.Ok())
+ if (m_pen.IsOk())
{
vColor = m_pen.GetColour().GetPixel();
}
} // end of wxPMDCImpl::DoDrawPoint
void wxPMDCImpl::DoDrawPolygon( int n,
- wxPoint vPoints[],
+ const wxPoint vPoints[],
wxCoord vXoffset,
wxCoord vYoffset,
- int nFillStyle )
+ wxPolygonFillMode nFillStyle )
{
ULONG ulCount = 1; // Number of polygons.
POLYGON vPlgn; // polygon.
void wxPMDCImpl::DoDrawLines(
int n
-, wxPoint vPoints[]
+, const wxPoint vPoints[]
, wxCoord vXoffset
, wxCoord vYoffset
)
{
POINTL vPoint;
- if (vXoffset != 0L || vXoffset != 0L)
+ if (vXoffset != 0L || vYoffset != 0L)
{
int i;
vY = OS2Y(vY,vHeight);
else
{
- if (m_vSelectedBitmap.Ok())
+ if (m_vSelectedBitmap.IsOk())
{
m_vRclPaint.yTop = m_vSelectedBitmap.GetHeight();
m_vRclPaint.xRight = m_vSelectedBitmap.GetWidth();
vY = OS2Y(vY,vHeight);
else
{
- if (m_vSelectedBitmap.Ok())
+ if (m_vSelectedBitmap.IsOk())
{
m_vRclPaint.yTop = m_vSelectedBitmap.GetHeight();
m_vRclPaint.xRight = m_vSelectedBitmap.GetWidth();
lColor = pWindowDC->m_pCanvas->GetBackgroundColour().GetPixel();
}
- else if (GetBrush().Ok())
+ else if (GetBrush().IsOk())
lColor = GetBrush().GetColour().GetPixel();
else
lColor = m_textBackgroundColour.GetPixel();
ULONG lOldForeGround = ::GpiQueryColor((HPS)GetHPS());
ULONG lOldBackGround = ::GpiQueryBackColor((HPS)GetHPS());
- if (m_textForegroundColour.Ok())
+ if (m_textForegroundColour.IsOk())
{
::GpiSetColor( (HPS)GetHPS()
,m_textForegroundColour.GetPixel()
);
}
- if (m_textBackgroundColour.Ok())
+ if (m_textBackgroundColour.IsOk())
{
::GpiSetBackColor( (HPS)GetHPS()
,m_textBackgroundColour.GetPixel()
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
+ delete [] pucBits;
return;
}
if ((lScans = ::GpiQueryBitmapBits( hPS
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
+ delete [] pucBits;
return;
}
unsigned char cOldRedFore = (unsigned char)(lOldForeGround >> 16);
//
// Set text color attributes
//
- if (m_textForegroundColour.Ok())
+ if (m_textForegroundColour.IsOk())
{
SetTextColor( m_hPS
,(int)m_textForegroundColour.GetPixel()
);
}
- if (m_textBackgroundColour.Ok())
+ if (m_textBackgroundColour.IsOk())
{
nOldBackground = SetTextBkColor( m_hPS
,(int)m_textBackgroundColour.GetPixel()
}
else
{
- if (m_vSelectedBitmap.Ok())
+ if (m_vSelectedBitmap.IsOk())
{
m_vRclPaint.yTop = m_vSelectedBitmap.GetHeight();
m_vRclPaint.xRight = m_vSelectedBitmap.GetWidth();
// it never is set to anything else, but background should remain
// transparent even if we just drew an opaque string)
//
- if (m_textBackgroundColour.Ok())
+ if (m_textBackgroundColour.IsOk())
SetTextBkColor( m_hPS
,nOldBackground
);
m_hOldPalette = 0;
}
- if (m_palette.Ok())
+ if (m_palette.IsOk())
{
HPALETTE hOldPal;
m_hOldFont = 0;
}
m_palette = rPalette;
- if (!rPalette.Ok())
+ if (!rPalette.IsOk())
{
if (m_hOldFont)
{
m_hOldFont = 0;
}
m_font = rFont;
- if (!rFont.Ok())
+ if (!rFont.IsOk())
{
m_hOldFont = 0;
}
m_font.SetPS(m_hPS); // this will realize the font
- if (m_font.Ok())
+ if (m_font.IsOk())
{
HFONT hFont = m_font.GetResourceHandle();
if (hFont == (HFONT) NULL)
if (m_pen == rPen)
return;
m_pen = rPen;
- if (!m_pen.Ok())
+ if (!m_pen.IsOk())
return;
if (m_hOldPen)
m_hOldPen = 0L;
m_pen = rPen;
- if (!m_pen.Ok())
+ if (!m_pen.IsOk())
{
if (m_hOldPen)
{
m_hOldPen = 0L;
}
- if (m_pen.Ok())
+ if (m_pen.IsOk())
{
if (m_pen.GetResourceHandle())
{
if (m_hOldBrush)
m_hOldBrush = 0L;
m_brush = rBrush;
- if (!m_brush.Ok())
+ if (!m_brush.IsOk())
if (m_brush == rBrush)
return;
- if (!m_brush.Ok())
+ if (!m_brush.IsOk())
if (m_hOldBrush)
m_hOldBrush = 0L;
- if (!m_brush.Ok())
+ if (!m_brush.IsOk())
{
if (m_hOldBrush)
{
m_hOldBrush = 0L;
}
- if (m_brush.Ok())
+ if (m_brush.IsOk())
{
if (m_brush.GetResourceHandle())
{
{
m_backgroundBrush = rBrush;
- if (m_backgroundBrush.Ok())
+ if (m_backgroundBrush.IsOk())
{
(void)::GpiSetBackColor((HPS)m_hPS, m_backgroundBrush.GetColour().GetPixel());
}
m_backgroundMode = nMode;
} // end of wxPMDCImpl::SetBackgroundMode
-void wxPMDCImpl::SetLogicalFunction(int nFunction)
+void wxPMDCImpl::SetLogicalFunction(wxRasterOperationMode nFunction)
{
m_logicalFunction = nFunction;
SetRop((WXHDC)m_hDC);
//
if (!m_hPS)
{
- (void)wxMessageBox( _T("wxWidgets core library")
- ,"Using uninitialized DC for measuring text!\n"
- ,wxICON_INFORMATION
- );
+ (void)wxMessageBox( wxT("wxWidgets core library")
+ ,"Using uninitialized DC for measuring text!\n"
+ ,wxICON_INFORMATION
+ );
}
-
+
bRc = ::GpiQueryTextBox( m_hPS
,l
,rsString.char_str()
vErrorCode = ::WinGetLastError(wxGetInstance());
sError = wxPMErrorToStr(vErrorCode);
// DEBUG
- wxSprintf(zMsg, _T("GpiQueryTextBox for %s: failed with Error: %lx - %s"), rsString.c_str(), vErrorCode, sError.c_str());
- (void)wxMessageBox( _T("wxWidgets core library")
+ wxSprintf(zMsg, wxT("GpiQueryTextBox for %s: failed with Error: %lx - %s"), rsString.c_str(), vErrorCode, sError.c_str());
+ (void)wxMessageBox( wxT("wxWidgets core library")
,zMsg
,wxICON_INFORMATION
);
}
void wxPMDCImpl::SetMapMode(
- int nMode
+ wxMappingMode nMode
)
{
int nPixelWidth = 0;
int nPixelHeight = 0;
int nMmWidth = 1;
int nMmHeight = 1;
- LONG lArray[CAPS_VERTICAL_RESOLUTION];
+ LONG lArray[CAPS_VERTICAL_RESOLUTION+1];
m_mappingMode = nMode;
if(::DevQueryCaps( m_hDC
- ,CAPS_FAMILY
- ,CAPS_VERTICAL_RESOLUTION
+ ,CAPS_FAMILY // id of first item
+ ,CAPS_VERTICAL_RESOLUTION+1 // number of items wanted
,lArray
))
{
lHorzRes = lArray[CAPS_HORIZONTAL_RESOLUTION]; // returns pel/meter
lVertRes = lArray[CAPS_VERTICAL_RESOLUTION]; // returns pel/meter
nMmWidth = (lHorzRes/1000) * nPixelWidth;
- nMmWidth = (lVertRes/1000) * nPixelHeight;
+ nMmHeight = (lVertRes/1000) * nPixelHeight;
}
if ((nPixelWidth == 0) || (nPixelHeight == 0) || (nMmWidth == 0) || (nMmHeight == 0))
{
return;
}
- double dMm2pixelsX = nPixelWidth/nMmWidth;
- double dMm2pixelsY = nPixelHeight/nMmHeight;
+ double dMm2pixelsX = nPixelWidth/(double)nMmWidth;
+ double dMm2pixelsY = nPixelHeight/(double)nMmHeight;
switch (nMode)
{
m_logicalScaleY = 1.0;
break;
}
+
SIZEL vSize;
ULONG ulOptions;
ulOptions = PU_ARBITRARY | GPIF_DEFAULT;
::GpiSetPS(m_hPS, &vSize, ulOptions);
}
- m_nWindowExtX = (int)MS_XDEV2LOG(VIEWPORT_EXTENT);
- m_nWindowExtY = (int)MS_YDEV2LOG(VIEWPORT_EXTENT);
- // ????
-
ComputeScaleAndOrigin();
-
+
}; // end of wxPMDCImpl::SetMapMode
void wxPMDCImpl::SetUserScale( double dX,
wxDC* pSource,
wxCoord vXsrc,
wxCoord vYsrc,
- int nRop,
+ wxRasterOperationMode nRop,
bool bUseMask,
wxCoord WXUNUSED(vXsrcMask),
wxCoord WXUNUSED(vYsrcMask) )
const wxBitmap& rBmp = pm_impl->GetSelectedBitmap();
pMask = rBmp.GetMask();
- if (!(rBmp.Ok() && pMask && pMask->GetMaskBitmap()))
+ if (!(rBmp.IsOk() && pMask && pMask->GetMaskBitmap()))
{
bUseMask = false;
}
);
vOldTextColor = (COLORREF)vCbnd.lColor;
- if (m_textForegroundColour.Ok())
+ if (m_textForegroundColour.IsOk())
{
vCbnd.lColor = (LONG)m_textForegroundColour.GetPixel();
::GpiSetAttrs( m_hPS // presentation-space handle
,&vCbnd // buffer for attributes.
);
}
- if (m_textBackgroundColour.Ok())
+ if (m_textBackgroundColour.IsOk())
{
::GpiSetBackColor(m_hPS, (LONG)m_textBackgroundColour.GetPixel());
}
}
void wxPMDCImpl::DoGetSize( int* pnWidth,
- int* pnHeight ) const
+ int* pnHeight ) const
{
- LONG lArray[CAPS_HEIGHT];
+ LONG lArray[CAPS_HEIGHT+1];
if(::DevQueryCaps( m_hDC
,CAPS_FAMILY
- ,CAPS_HEIGHT
+ ,CAPS_HEIGHT+1
,lArray
))
{
- *pnWidth = lArray[CAPS_WIDTH];
- *pnHeight = lArray[CAPS_HEIGHT];
+ if (pnWidth)
+ *pnWidth = lArray[CAPS_WIDTH];
+ if (pnHeight)
+ *pnHeight = lArray[CAPS_HEIGHT];
}
}; // end of wxPMDCImpl::DoGetSize(
void wxPMDCImpl::DoGetSizeMM( int* pnWidth,
int* pnHeight ) const
{
- LONG lArray[CAPS_VERTICAL_RESOLUTION];
+ LONG lArray[CAPS_VERTICAL_RESOLUTION+1];
if(::DevQueryCaps( m_hDC
,CAPS_FAMILY
- ,CAPS_VERTICAL_RESOLUTION
+ ,CAPS_VERTICAL_RESOLUTION+1
,lArray
))
{
if(pnWidth)
{
- int nWidth = lArray[CAPS_WIDTH];
- int nHorzRes = lArray[CAPS_HORIZONTAL_RESOLUTION]; // returns pel/meter
- *pnWidth = (nHorzRes/1000) * nWidth;
+ int nWidth = lArray[CAPS_WIDTH];
+ int nHorzRes = lArray[CAPS_HORIZONTAL_RESOLUTION]; // returns pel/meter
+ // use fp to avoid returning 0 if nHorzRes < 1000
+ *pnWidth = (int)((nHorzRes/1000.0) * nWidth);
}
if(pnHeight)
{
- int nHeight = lArray[CAPS_HEIGHT];
+ int nHeight = lArray[CAPS_HEIGHT];
int nVertRes = lArray[CAPS_VERTICAL_RESOLUTION]; // returns pel/meter
- *pnHeight = (nVertRes/1000) * nHeight;
+ // use fp to avoid returning 0 if nVertRes < 1000
+ *pnHeight = (int)((nVertRes/1000.0) * nHeight);
}
}
}; // end of wxPMDCImpl::DoGetSizeMM
wxSize wxPMDCImpl::GetPPI() const
{
- LONG lArray[CAPS_VERTICAL_RESOLUTION];
+ LONG lArray[CAPS_VERTICAL_RESOLUTION+1];
int nWidth = 0;
int nHeight = 0;
if(::DevQueryCaps( m_hDC
,CAPS_FAMILY
- ,CAPS_VERTICAL_RESOLUTION
+ ,CAPS_VERTICAL_RESOLUTION+1
,lArray
))
{