+ if (vXoffset != 0L || vXoffset != 0L)
+ {
+ int i;
+
+ vPoint.x = vPoints[0].x + vXoffset;
+ vPoint.y = OS2Y(vPoints[0].y + vYoffset,0);
+ ::GpiMove(m_hPS, &vPoint);
+
+ LONG lBorderColor = m_pen.GetColour().GetPixel();
+
+ ::GpiSetColor(m_hPS, lBorderColor);
+ for(i = 1; i < n; i++)
+ {
+ vPoint.x = vPoints[i].x + vXoffset;
+ vPoint.y = OS2Y(vPoints[i].y + vYoffset,0);
+ ::GpiLine(m_hPS, &vPoint);
+ }
+ }
+ else
+ {
+ int i;
+
+ CalcBoundingBox( vPoints[i].x
+ ,vPoints[i].y
+ );
+ vPoint.x = vPoints[0].x;
+ vPoint.y = OS2Y(vPoints[0].y,0);
+ ::GpiMove(m_hPS, &vPoint);
+
+ for (i = 0; i < n; i++)
+ {
+ CalcBoundingBox( vPoints[i].x
+ ,vPoints[i].y
+ );
+ vPoint.x = vPoints[i].x;
+ vPoint.y = OS2Y(vPoints[i].y,0);
+ ::GpiLine(m_hPS, &vPoint);
+ }
+ }
+} // end of wxDC::DoDrawLines
+
+void wxDC::DoDrawRectangle(
+ wxCoord vX
+, wxCoord vY
+, wxCoord vWidth
+, wxCoord vHeight
+)
+{
+ POINTL vPoint[2];
+ LONG lControl;
+ LONG lColor;
+ LONG lBorderColor;
+ int nIsTRANSPARENT = 0;
+
+ vY = OS2Y(vY,vHeight);
+
+ wxCoord vX2 = vX + vWidth;
+ wxCoord vY2 = vY + vHeight;
+
+ vPoint[0].x = vX;
+ vPoint[0].y = vY;
+ vPoint[1].x = vX + vWidth;
+ vPoint[1].y = vY + vHeight;
+ ::GpiMove(m_hPS, &vPoint[0]);
+ lColor = m_brush.GetColour().GetPixel();
+ lBorderColor = m_pen.GetColour().GetPixel();
+ if (m_brush.GetStyle() == wxTRANSPARENT)
+ nIsTRANSPARENT = 1;
+ if(lColor == lBorderColor || nIsTRANSPARENT)
+ {
+ lControl = DRO_OUTLINEFILL; //DRO_FILL;
+ if(m_brush.GetStyle() == wxTRANSPARENT)
+ lControl = DRO_OUTLINE;
+
+ ::GpiSetColor(m_hPS, lColor);
+ ::GpiBox( m_hPS // handle to a presentation space
+ ,lControl // draw the box outline ? or ?
+ ,&vPoint[1] // address of the corner
+ ,0L // horizontal corner radius
+ ,0L // vertical corner radius
+ );
+ }
+ else
+ {
+ lControl = DRO_OUTLINE;
+ ::GpiSetColor( m_hPS
+ ,lBorderColor
+ );
+ ::GpiBox( m_hPS
+ ,lControl
+ ,&vPoint[1]
+ ,0L
+ ,0L
+ );
+ lControl = DRO_FILL;
+ ::GpiSetColor( m_hPS
+ ,lColor
+ );
+ vPoint[0].x = vX + 1;
+ vPoint[0].y = vY + 1;
+ vPoint[1].x = vX + vWidth - 1;
+ vPoint[1].y = vY + vHeight - 1;
+ ::GpiMove(m_hPS, &vPoint[0]);
+ ::GpiBox( m_hPS
+ ,lControl
+ ,&vPoint[1]
+ ,0L
+ ,0L
+ );
+ }
+ CalcBoundingBox(vX, vY);
+ CalcBoundingBox(vX2, vY2);
+} // end of wxDC::DoDrawRectangle
+
+void wxDC::DoDrawRoundedRectangle(
+ wxCoord vX
+, wxCoord vY
+, wxCoord vWidth
+, wxCoord vHeight
+, double dRadius
+)
+{
+ POINTL vPoint[2];
+ LONG lControl;
+
+ vY = OS2Y(vY,vHeight);
+
+ wxCoord vX2 = (vX + vWidth);
+ wxCoord vY2 = (vY + vHeight);
+
+ vPoint[0].x = vX;
+ vPoint[0].y = YLOG2DEV(vY) - vHeight;
+ vPoint[1].x = vX + vWidth;
+ vPoint[1].y = vY;
+ ::GpiMove(m_hPS, &vPoint[0]);
+
+ lControl = DRO_OUTLINEFILL; //DRO_FILL;
+ if (m_brush.GetStyle() == wxTRANSPARENT)
+ lControl = DRO_OUTLINE;
+ ::GpiBox( m_hPS // handle to a presentation space
+ ,DRO_OUTLINE // draw the box outline ? or ?
+ ,&vPoint[1] // address of the corner
+ ,(LONG)dRadius // horizontal corner radius
+ ,(LONG)dRadius // vertical corner radius
+ );
+ CalcBoundingBox(vX, vY);
+ CalcBoundingBox(vX2, vY2);
+} // end of wxDC::DoDrawRoundedRectangle
+
+// Draw Ellipse within box (x,y) - (x+width, y+height)
+void wxDC::DoDrawEllipse(
+ wxCoord vX
+, wxCoord vY
+, wxCoord vWidth
+, wxCoord vHeight
+)
+{
+ POINTL vPtlPos; // Structure for current position
+ FIXED vFxMult; // Multiplier for ellipse
+ ARCPARAMS vArcp; // Structure for arc parameters
+
+ vY = OS2Y(vY,vHeight);
+
+ vArcp.lR = 0;
+ vArcp.lQ = vHeight/2;
+ vArcp.lP = vWidth/2;
+ vArcp.lS = 0;
+ ::GpiSetArcParams( m_hPS
+ ,&vArcp
+ ); // Sets parameters to default
+ vPtlPos.x = vX + vWidth/2; // Loads x-coordinate
+ vPtlPos.y = vY + vHeight/2; // Loads y-coordinate
+ ::GpiMove( m_hPS
+ ,&vPtlPos
+ ); // Sets current position
+ vFxMult = MAKEFIXED(1, 0); /* Sets multiplier */
+
+ //
+ // DRO_FILL, DRO_OTLINEFILL - where to get
+ //
+ ::GpiFullArc( m_hPS
+ ,DRO_OUTLINE
+ ,vFxMult
+ ); // Draws full arc with center at current position
+
+ wxCoord vX2 = (vX + vWidth);
+ wxCoord vY2 = (vY + vHeight);
+
+ CalcBoundingBox(vX, vY);
+ CalcBoundingBox(vX2, vY2);
+} // end of wxDC::DoDrawEllipse
+
+void wxDC::DoDrawEllipticArc(
+ wxCoord vX
+, wxCoord vY
+, wxCoord vWidth
+, wxCoord vHeight
+, double dSa
+, double dEa
+)
+{
+ POINTL vPtlPos; // Structure for current position
+ FIXED vFxMult; // Multiplier for ellipse
+ ARCPARAMS vArcp; // Structure for arc parameters
+ FIXED vFSa;
+ FIXED vFSweepa; // Start angle, sweep angle
+ double dIntPart;
+ double dFractPart;
+ double dRadius;
+
+ vY = OS2Y(vY,vHeight);
+
+ dFractPart = modf(dSa,&dIntPart);
+ vFSa = MAKEFIXED((int)dIntPart, (int)(dFractPart * 0xffff) );
+ dFractPart = modf(dEa - dSa, &dIntPart);
+ vFSweepa = MAKEFIXED((int)dIntPart, (int)(dFractPart * 0xffff) );
+
+ //
+ // Ellipse main axis (r,q), (p,s) with center at (0,0)
+ //
+ vArcp.lR = 0;
+ vArcp.lQ = vHeight/2;
+ vArcp.lP = vWidth/2;
+ vArcp.lS = 0;
+ ::GpiSetArcParams(m_hPS, &vArcp); // Sets parameters to default
+ vPtlPos.x = vX + vWidth/2 * (1. + cos(DegToRad(dSa))); // Loads x-coordinate
+ vPtlPos.y = vY + vHeight/2 * (1. + sin(DegToRad(dSa))); // Loads y-coordinate
+ ::GpiMove(m_hPS, &vPtlPos); // Sets current position
+
+ //
+ // May be not to the center ?
+ //
+ vPtlPos.x = vX + vWidth/2 ; // Loads x-coordinate
+ vPtlPos.y = vY + vHeight/2; // Loads y-coordinate
+ vFxMult = MAKEFIXED(1, 0); // Sets multiplier
+
+ //
+ // DRO_FILL, DRO_OTLINEFILL - where to get
+ //
+ ::GpiPartialArc( m_hPS
+ ,&vPtlPos
+ ,vFxMult
+ ,vFSa
+ ,vFSweepa
+ );
+ wxCoord vX2 = (vX + vWidth);
+ wxCoord vY2 = (vY + vHeight);
+
+ CalcBoundingBox(vX, vY);
+ CalcBoundingBox(vX2, vY2);
+} // end of wxDC::DoDrawEllipticArc
+
+void wxDC::DoDrawIcon(
+ const wxIcon& rIcon
+, wxCoord vX
+, wxCoord vY
+)
+{
+ vY = OS2Y(vY,rIcon.GetHeight());
+ wxCHECK_RET( rIcon.Ok(), wxT("invalid icon in DrawIcon") );
+
+ ::WinDrawPointer( GetHPS()
+ ,vX
+ ,vY
+ ,(HPOINTER)GetHiconOf(rIcon)
+ ,DP_NORMAL
+ );
+ CalcBoundingBox(vX, vY);
+ CalcBoundingBox(vX + rIcon.GetWidth(), vY + rIcon.GetHeight());
+} // end of wxDC::DoDrawIcon
+
+void wxDC::DoDrawBitmap(
+ const wxBitmap& rBmp
+, wxCoord vX
+, wxCoord vY
+, bool bUseMask
+)
+{
+ if (!bUseMask && !IsKindOf(CLASSINFO(wxPrinterDC)))
+ {
+ HBITMAP hBitmap = (HBITMAP)rBmp.GetHBITMAP();
+ wxBitmap vNewBitmap( rBmp.GetWidth()
+ ,rBmp.GetHeight()
+ ,rBmp.GetDepth()
+ );
+ HBITMAP hBitmapOld = ::GpiSetBitmap((HPS)GetHPS(), vNewBitmap.GetHBITMAP());
+ LONG lOldTextground = ::GpiQueryColor((HPS)GetHPS());
+ LONG lOldBackground = ::GpiQueryBackColor((HPS)GetHPS());
+
+ if (m_textForegroundColour.Ok())
+ {
+ ::GpiSetColor( (HPS)GetHPS()
+ ,m_textForegroundColour.GetPixel()
+ );
+ }
+ if (m_textBackgroundColour.Ok())
+ {
+ ::GpiSetBackColor( (HPS)GetHPS()
+ ,m_textBackgroundColour.GetPixel()
+ );
+ }
+
+ vY = OS2Y(vY,rBmp.GetHeight());
+
+ 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
+ );
+ ::GpiSetBitmap((HPS)GetHPS(), hBitmapOld);
+ ::GpiSetColor((HPS)GetHPS(), lOldTextground);
+ ::GpiSetBackColor((HPS)GetHPS(), lOldBackground);
+ }
+} // end of wxDC::DoDrawBitmap
+
+void wxDC::DoDrawText(
+ const wxString& rsText
+, wxCoord vX
+, wxCoord vY
+)
+{
+ wxCoord vWidth;
+ wxCoord vHeight;
+
+ DrawAnyText( rsText
+ ,vX
+ ,vY
+ );
+
+ CalcBoundingBox(vX, vY);
+ GetTextExtent(rsText, &vWidth, &vHeight);
+ CalcBoundingBox((vX + vWidth), (vY + vHeight));
+} // end of wxDC::DoDrawText
+
+void wxDC::DrawAnyText(
+ const wxString& rsText
+, wxCoord vX
+, wxCoord vY
+)
+{
+ int nOldBackground = 0;
+ POINTL vPtlStart;
+ LONG lHits;
+ wxCoord vTextX = 0;
+ wxCoord vTextY = 0;
+
+ //
+ // prepare for drawing the text
+ //
+
+ //
+ // Set text color attributes
+ //
+ if (m_textForegroundColour.Ok())
+ {
+ SetTextColor( m_hPS
+ ,(int)m_textForegroundColour.GetPixel()
+ );
+ }
+
+ if (m_textBackgroundColour.Ok())
+ {
+ nOldBackground = SetTextBkColor( m_hPS
+ ,(int)m_textBackgroundColour.GetPixel()
+ );
+ }
+ SetBkMode( m_hPS
+ ,m_backgroundMode
+ );
+ GetTextExtent( rsText
+ ,&vTextX
+ ,&vTextY
+ );
+ vPtlStart.x = vX;
+ vPtlStart.y = OS2Y(vY,vTextY);
+
+ lHits = ::GpiCharStringAt( m_hPS
+ ,&vPtlStart
+ ,rsText.length()
+ ,(PCH)rsText.c_str()
+ );
+ if (lHits != GPI_OK)
+ {
+ wxLogLastError(wxT("TextOut"));
+ }
+
+ //
+ // Restore the old parameters (text foreground colour may be left because
+ // it never is set to anything else, but background should remain
+ // transparent even if we just drew an opaque string)
+ //
+ if (m_textBackgroundColour.Ok())
+ SetTextBkColor( m_hPS
+ ,nOldBackground
+ );
+ SetBkMode( m_hPS
+ ,wxTRANSPARENT
+ );