pzData = (char *)zBits; // const_cast is harmless
}
+ if (nDepth > 24)
+ nDepth = 24; // MAX supported in PM
memset(&vHeader, '\0', 16);
vHeader.cbFix = 16;
vHeader.cx = (USHORT)nWidth;
hDCScreen = ::GpiQueryDevice(hPSScreen);
::DevQueryCaps(hDCScreen, CAPS_COLOR_BITCOUNT, 1L, &lBitCount);
+ if (lBitCount > 24)
+ lBitCount = 24;
+
memset(&vHeader, '\0', 16);
vHeader.cbFix = 16;
vHeader.cx = nW;
//
BITMAPINFOHEADER2 vHeader;
BITMAPINFO2 vInfo;
+ LONG alFormats[24]; // Max formats OS/2 PM supports
+ ULONG ulBitcount;
//
// Fill in the DIB header
vHeader.cPlanes = 1L;
vHeader.cBitCount = 24;
- memset(&vInfo, '\0', 16);
- vInfo.cbFix = 16;
- vInfo.cx = (ULONG)nWidth;
- vInfo.cy = (ULONG)nHeight;
- vInfo.cPlanes = 1L;
- vInfo.cBitCount = 24;
//
// Memory for DIB data
//
HBITMAP hBmp;
HBITMAP hBmpOld;
+ ::GpiQueryDeviceBitmapFormats(hPS, 24, alFormats);
+ ulBitcount = alFormats[1]; // the best one for the device
+ if (ulBitcount > 24)
+ ulBitcount = 24; // MAX bits supported by PM
+ memset(&vInfo, '\0', 16);
+ vInfo.cbFix = 16;
+ vInfo.cx = (ULONG)nWidth;
+ vInfo.cy = (ULONG)nHeight;
+ vInfo.cPlanes = 1;
+ vInfo.cBitCount = ulBitcount;
+
hBmp = ::GpiCreateBitmap( hPS
,&vHeader
,0L
// Have to do something similar to WIN32's StretchDIBits, use GpiBitBlt
// in combination with setting the bits into the selected bitmap
//
- vInfo.cBitCount = 16;
if ((lScans = ::GpiSetBitmapBits( hPS
,0 // Start at the bottom
,(LONG)nHeight // One line per scan
sError = wxPMErrorToStr(vError);
}
- //
- // for debugging----
- //
-LONG alFormats[24];
-::GpiQueryDeviceBitmapFormats(hPS, 24, alFormats);
-if ((lScans = ::GpiQueryBitmapBits( hPS
- ,0L
- ,(LONG)nHeight
- ,(PBYTE)pucBits
- ,&vInfo
- )) == GPI_ALTERROR)
-{
- ERRORID vError;
- wxString sError;
-
- vError = ::WinGetLastError(vHabmain);
- sError = wxPMErrorToStr(vError);
-}
-
hPSScreen = ::GpiCreatePS( vHabmain
,hDCScreen
,&vSize
//
::GpiSetBitmap(hPS, NULLHANDLE);
::GpiDestroyPS(hPS);
+ ::DevCloseDC(hDCScreen);
::DevCloseDC(hDC);
free(pucBits);
return TRUE;
DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
SIZEL vSizlPage = {0,0};
HDC hDCMem;
+ LONG alFormats[24]; // 24 is MAX formats supported
+ ULONG ulBitcount;
+ ::GpiQueryDeviceBitmapFormats(hPS, 24, alFormats);
+ ulBitcount = alFormats[1]; // the best one
+ if (ulBitcount > 24) // PM supports a max of 24
+ ulBitcount = 24;
vImage.Create( nWidth
,nHeight
);
vDIBInfo.cx = nWidth;
vDIBInfo.cy = nHeight;
vDIBInfo.cPlanes = 1;
- vDIBInfo.cBitCount = 24;
+ vDIBInfo.cBitCount = ulBitcount;
lpBits = (unsigned char *)malloc(nBytePerLine * nHeight);
if (!lpBits)
vPoint[0].x = vX;
vPoint[0].y = vY;
- vPoint[1].x = vX + vWidth;
- vPoint[1].y = vY + vHeight;
+ vPoint[1].x = vX + vWidth - 1;
+ vPoint[1].y = vY + vHeight - 1;
::GpiMove(m_hPS, &vPoint[0]);
lColor = m_brush.GetColour().GetPixel();
lBorderColor = m_pen.GetColour().GetPixel();
);
vPoint[0].x = vX + 1;
vPoint[0].y = vY + 1;
- vPoint[1].x = vX + vWidth - 1;
- vPoint[1].y = vY + vHeight - 1;
+ vPoint[1].x = vX + vWidth - 2;
+ vPoint[1].y = vY + vHeight - 2;
::GpiMove(m_hPS, &vPoint[0]);
::GpiBox( m_hPS
,lControl
, bool bUseMask
)
{
- if (!bUseMask && !IsKindOf(CLASSINFO(wxPrinterDC)))
+ if (!IsKindOf(CLASSINFO(wxPrinterDC)))
{
HBITMAP hBitmap = (HBITMAP)rBmp.GetHBITMAP();
wxBitmap vNewBitmap( rBmp.GetWidth()
LONG lOldTextground = ::GpiQueryColor((HPS)GetHPS());
LONG lOldBackground = ::GpiQueryBackColor((HPS)GetHPS());
+ vY = OS2Y(vY,rBmp.GetHeight());
+
+ //
+ // Flip the picture as OS/2 is upside-down
+ //
+ POINTL vPoint[4] = { vX, vY + rBmp.GetHeight()
+ ,vX + rBmp.GetWidth(), vY
+ ,0, 0
+ ,rBmp.GetWidth(), rBmp.GetHeight()
+ };
+
if (m_textForegroundColour.Ok())
{
::GpiSetColor( (HPS)GetHPS()
,m_textBackgroundColour.GetPixel()
);
}
+ if (bUseMask)
+ {
+ wxMask* pMask = rBmp.GetMask();
+ HPS hPS;
+ HDC hDC;
- vY = OS2Y(vY,rBmp.GetHeight());
+ if (!IsKindOf(CLASSINFO(wxMemoryDC)))
+ {
+ DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L};
+ SIZEL vSize = {0, 0};
- //
- // Flip the picture as OS/2 is upside-down
- //
- POINTL vPoint[4] = { vX, vY + rBmp.GetHeight()
- ,vX + rBmp.GetWidth(), vY
- ,0, 0
- ,rBmp.GetWidth(), rBmp.GetHeight()
- };
- ::GpiWCBitBlt( (HPS)GetHPS()
- ,hBitmap
- ,4
- ,vPoint
- ,ROP_SRCCOPY
- ,BBO_IGNORE
- );
+ hDC = ::DevOpenDC(vHabmain, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&vDop, NULLHANDLE);
+ hPS = ::GpiCreatePS(vHabmain, hDC, &vSize, PU_PELS | GPIA_ASSOC);
+ }
+ else
+ hPS = m_hPS;
+
+ if (pMask)
+ {
+ BITMAPINFOHEADER2 vHeader;
+ BITMAPINFO2 vInfo;
+ int nBytesPerLine = rBmp.GetWidth() * 3;
+ unsigned char* pucData;
+ LONG lScans = 0L;
+ LONG alFormats[24]; // Max formats OS/2 PM supports
+ ULONG ulBitcount;
+ HBITMAP hMask = (HBITMAP)pMask->GetMaskBitmap();
+ POINTL vPointMask[4] = { 0, 0, rBmp.GetWidth(), rBmp.GetHeight()
+ ,0, 0, rBmp.GetWidth(), rBmp.GetHeight()
+ };
+
+ ::GpiSetBitmap(hPS, hMask);
+
+ ::GpiQueryDeviceBitmapFormats(hPS, 24, alFormats);
+ ulBitcount = alFormats[1]; // the best one
+ if (ulBitcount > 24) // PM supports a max of 24
+ ulBitcount = 24;
+
+ vInfo.cbFix = 16;
+ vInfo.cx = rBmp.GetWidth();
+ vInfo.cy = rBmp.GetHeight();
+ vInfo.cPlanes = 1;
+ vInfo.cBitCount = ulBitcount;
+ pucData = (unsigned char*)malloc(nBytesPerLine * rBmp.GetHeight());
+ if ((lScans = ::GpiQueryBitmapBits( hPS
+ ,0L
+ ,(LONG)rBmp.GetHeight()
+ ,(PBYTE)pucData
+ ,&vInfo
+ )) == GPI_ALTERROR)
+ {
+ ERRORID vError;
+ wxString sError;
+
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ }
+ if ((hBitmapOld = ::GpiSetBitmap(hPS, (HBITMAP)vNewBitmap.GetHBITMAP())) == HBM_ERROR)
+ {
+ ERRORID vError;
+ wxString sError;
+
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ }
+ if ((lScans = ::GpiSetBitmapBits( hPS
+ ,0
+ ,(LONG)rBmp.GetHeight()
+ ,(PBYTE)pucData
+ ,&vInfo
+ )) == GPI_ALTERROR)
+ {
+ ERRORID vError;
+ wxString sError;
+
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ }
+ if ((hBitmapOld = ::GpiSetBitmap(hPS, NULLHANDLE)) == HBM_ERROR)
+ {
+ ERRORID vError;
+ wxString sError;
+
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ }
+ if ((hBitmapOld = ::GpiSetBitmap((HPS)GetHPS(), vNewBitmap.GetHBITMAP())) == HBM_ERROR)
+ {
+ ERRORID vError;
+ wxString sError;
+
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ }
+ ::GpiWCBitBlt( (HPS)GetHPS()
+ ,hBitmap
+ ,4
+ ,vPoint
+ ,ROP_SRCAND
+ ,BBO_IGNORE
+ );
+ }
+ }
+ else
+ {
+ ::GpiWCBitBlt( (HPS)GetHPS()
+ ,hBitmap
+ ,4
+ ,vPoint
+ ,ROP_SRCCOPY
+ ,BBO_IGNORE
+ );
+ }
::GpiSetBitmap((HPS)GetHPS(), hBitmapOld);
::GpiSetColor((HPS)GetHPS(), lOldTextground);
::GpiSetBackColor((HPS)GetHPS(), lOldBackground);
{
HPS hPS;
+ m_hDC = (WXHDC)::WinOpenWindowDC(GetWinHwnd(m_pCanvas));
hPS = ::WinBeginPaint( GetWinHwnd(m_pCanvas)
,NULLHANDLE
,&g_paintStruct
);
if(hPS)
{
+ ::GpiAssociate(hPS, m_hDC);
m_hOldPS = m_hPS;
m_hPS = hPS;
::GpiCreateLogColorTable( m_hPS
}
m_bIsPaintTime = TRUE;
- m_hDC = (WXHDC) -1; // to satisfy those anonizmous efforts
ms_cache.Add(new wxPaintDCInfo(m_pCanvas, this));
}
InitDC();
LONG lScans = 0L;
POINTL vPoint;
LONG lColor;
+ LONG alFormats[24]; // Max formats OS/2 PM supports
+ ULONG ulBitcount;
+ ::GpiQueryDeviceBitmapFormats(m_hPS, 24, alFormats);
+ ulBitcount = alFormats[1]; // the best one for the device
+ if (ulBitcount > 24)
+ ulBitcount = 24; // MAX bits supported by PM
vInfo.cbFix = 16;
vInfo.cx = vHeader.cx;
vInfo.cy = vHeader.cy;
vInfo.cPlanes = vHeader.cPlanes;
- vInfo.cBitCount = 24;
+ vInfo.cBitCount = ulBitcount;
pucData = (unsigned char*)malloc(nBytesPerLine * m_vSelectedBitmap.GetHeight());
if ((lScans = ::GpiQueryBitmapBits( m_hPS
,0L
{
for (int j = 0; j < m_vSelectedBitmap.GetWidth(); j++)
{
- if (i >= vY && j >= vX && i < vHeight && j < vWidth)
- {
- if (i == vY || j == vX ||
- i == m_vSelectedBitmap.GetWidth() -1 ||
- j == m_vSelectedBitmap.GetHeight() - 1
- )
- lColor = m_pen.GetColour().GetPixel();
- else
- lColor = m_brush.GetColour().GetPixel();
- *(pucBits++) = (unsigned char)lColor;
- *(pucBits++) = (unsigned char)(lColor >> 8);
- *(pucBits++) = (unsigned char)(lColor >> 16);
- }
- else
- pucBits += 3;
+ vPoint.x = j; vPoint.y = i;
+ lColor = ::GpiQueryPel(m_hPS, &vPoint);
+ *(pucBits++) = (unsigned char)lColor;
+ *(pucBits++) = (unsigned char)(lColor >> 8);
+ *(pucBits++) = (unsigned char)(lColor >> 16);
+ }
+ }
+ if ((lScans = ::GpiSetBitmapBits( m_hPS
+ ,0
+ ,(LONG)m_vSelectedBitmap.GetHeight()
+ ,(PBYTE)pucData
+ ,&vInfo
+ )) == GPI_ALTERROR)
+ {
+ ERRORID vError;
+ wxString sError;
+
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ }
+ free(pucData);
+ }
+ }
+} // end of wxMemoryDC::DoDrawRectangle
+
+void wxMemoryDC::DoDrawRoundedRectangle(
+ wxCoord vX
+, wxCoord vY
+, wxCoord vWidth
+, wxCoord vHeight
+, double dRadius
+)
+{
+ wxDC::DoDrawRoundedRectangle(vX, vY, vWidth, vHeight, dRadius);
+
+ //
+ // Debug testing:
+ //
+ if (m_vSelectedBitmap.GetHBITMAP() != NULLHANDLE)
+ {
+ BITMAPINFOHEADER2 vHeader;
+ BITMAPINFO2 vInfo;
+
+ vHeader.cbFix = 16L;
+ if (::GpiQueryBitmapInfoHeader(m_vSelectedBitmap.GetHBITMAP(), &vHeader))
+ {
+ unsigned char* pucData = NULL;
+ unsigned char* pucBits;
+ int nBytesPerLine = m_vSelectedBitmap.GetWidth() * 3;
+ LONG lScans = 0L;
+ POINTL vPoint;
+ LONG lColor;
+ LONG alFormats[24]; // Max formats OS/2 PM supports
+ ULONG ulBitcount;
+
+ ::GpiQueryDeviceBitmapFormats(m_hPS, 24, alFormats);
+ ulBitcount = alFormats[1]; // the best one for the device
+ if (ulBitcount > 24)
+ ulBitcount = 24; // MAX bits supported by PM
+ vInfo.cbFix = 16;
+ vInfo.cx = vHeader.cx;
+ vInfo.cy = vHeader.cy;
+ vInfo.cPlanes = vHeader.cPlanes;
+ vInfo.cBitCount = ulBitcount;
+ pucData = (unsigned char*)malloc(nBytesPerLine * m_vSelectedBitmap.GetHeight());
+ if ((lScans = ::GpiQueryBitmapBits( m_hPS
+ ,0L
+ ,(LONG)m_vSelectedBitmap.GetHeight()
+ ,(PBYTE)pucData
+ ,&vInfo
+ )) == GPI_ALTERROR)
+ {
+ ERRORID vError;
+ wxString sError;
+
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ }
+ pucBits = pucData;
+ for (int i = 0; i < m_vSelectedBitmap.GetHeight(); i++)
+ {
+ for (int j = 0; j < m_vSelectedBitmap.GetWidth(); j++)
+ {
+ vPoint.x = j; vPoint.y = i;
+ lColor = ::GpiQueryPel(m_hPS, &vPoint);
+ *(pucBits++) = (unsigned char)lColor;
+ *(pucBits++) = (unsigned char)(lColor >> 8);
+ *(pucBits++) = (unsigned char)(lColor >> 16);
}
}
if ((lScans = ::GpiSetBitmapBits( m_hPS