#include "wx/dcprint.h"
#include <string.h>
-#include <math.h>
#include "wx/os2/private.h"
IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
//
-// wxWindows uses the Microsoft convention that the origin is the UPPER left.
+// wxWidgets uses the Microsoft convention that the origin is the UPPER left.
// Native OS/2 however in the GPI and PM define the origin as the LOWER left.
-// In order to map OS/2 GPI/PM y coordinates to wxWindows coordinates we must
+// In order to map OS/2 GPI/PM y coordinates to wxWidgets coordinates we must
// perform the following transformation:
//
// Parent object height: POBJHEIGHT
// Desried origin: WXORIGINY
// Object to place's height: OBJHEIGHT
//
-// To get the OS2 position from the wxWindows one:
+// To get the OS2 position from the wxWidgets one:
//
// OS2Y = POBJHEIGHT - (WXORIGINY + OBJHEIGHT)
//
// For OS/2 wxDC's we will always determine m_vRclPaint as the size of the
// OS/2 Presentation Space associated with the device context. y is the
-// desired application's y coordinate of the origin in wxWindows space.
+// desired application's y coordinate of the origin in wxWidgets space.
// objy is the height of the object we are going to draw.
//
#define OS2Y(y, objy) ((m_vRclPaint.yTop - m_vRclPaint.yBottom) - (y + objy))
static const int MM_POINTS = 9;
static const int MM_METRIC = 10;
-// usually this is defined in math.h
-#ifndef M_PI
- static const double M_PI = 3.14159265358979323846;
-#endif // M_PI
-
// ---------------------------------------------------------------------------
// private functions
// ---------------------------------------------------------------------------
::GpiSetClipRegion(m_hPS, hRgn, &hRgnOld);
}
- m_clipping = false;
+ ResetClipping();
} // end of wxDC::DestroyClippingRegion
// ---------------------------------------------------------------------------
int wxDC::GetDepth() const
{
LONG lArray[CAPS_COLOR_BITCOUNT];
- int nBitsPerPixel;
+ int nBitsPerPixel = 0;
if(::DevQueryCaps( GetHDC()
,CAPS_FAMILY
{
POINTL vPtlPos;
POINTL vPtlArc[2]; // Structure for current position
- int nDx;
- int nDy;
double dRadius;
double dAngl1;
double dAngl2;
// Medium point
//
dAnglmid = (dAngl1 + dAngl2)/2. + M_PI;
- vXm = vXc + dRadius * cos(dAnglmid);
- vYm = vYc + dRadius * sin(dAnglmid);
+ vXm = (wxCoord)(vXc + dRadius * cos(dAnglmid));
+ vYm = (wxCoord)(vYc + dRadius * sin(dAnglmid));
DoDrawArc( vX1, vY1
,vXm, vYm
,vXc, vYc
// Medium point
//
dAnglmid = (dAngl1 + dAngl2)/2.;
- vXm = vXc + dRadius * cos(dAnglmid);
- vYm = vYc + dRadius * sin(dAnglmid);
+ vXm = (wxCoord)(vXc + dRadius * cos(dAnglmid));
+ vYm = (wxCoord)(vYc + dRadius * sin(dAnglmid));
//
// Ellipse main axis (r,q), (p,s) with center at (0,0) */
vPtlArc[1].x = vX2;
vPtlArc[1].y = vY2;
::GpiPointArc(m_hPS, vPtlArc); // Draws the arc
- CalcBoundingBox( (vXc - dRadius)
- ,(vYc - dRadius)
+ CalcBoundingBox( (wxCoord)(vXc - dRadius)
+ ,(wxCoord)(vYc - dRadius)
);
- CalcBoundingBox( (vXc + dRadius)
- ,(vYc + dRadius)
+ CalcBoundingBox( (wxCoord)(vXc + dRadius)
+ ,(wxCoord)(vYc + dRadius)
);
} // end of wxDC::DoDrawArc
{
int i;
- CalcBoundingBox( vPoints[i].x
- ,vPoints[i].y
+ CalcBoundingBox( vPoints[0].x
+ ,vPoints[0].y
);
vPoint.x = vPoints[0].x;
vPoint.y = OS2Y(vPoints[0].y,0);
FIXED vFSweepa; // Start angle, sweep angle
double dIntPart;
double dFractPart;
- double dRadius;
vY = OS2Y(vY,vHeight);
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
+ vPtlPos.x = (wxCoord)(vX + vWidth/2 * (1. + cos(DegToRad(dSa)))); // Loads x-coordinate
+ vPtlPos.y = (wxCoord)(vY + vHeight/2 * (1. + sin(DegToRad(dSa)))); // Loads y-coordinate
::GpiMove(m_hPS, &vPtlPos); // Sets current position
//
lColor = pWindowDC->m_pCanvas->GetBackgroundColour().GetPixel();
}
- else if (GetBrush() != wxNullBrush)
+ else if (GetBrush().Ok())
lColor = GetBrush().GetColour().GetPixel();
else
lColor = m_textBackgroundColour.GetPixel();
}
else
{
- LONG lOldForeGround = ::GpiQueryColor((HPS)GetHPS());
- LONG lOldBackGround = ::GpiQueryBackColor((HPS)GetHPS());
+ ULONG lOldForeGround = ::GpiQueryColor((HPS)GetHPS());
+ ULONG lOldBackGround = ::GpiQueryBackColor((HPS)GetHPS());
if (m_textForegroundColour.Ok())
{
unsigned char cOldGreenFore = (unsigned char)(lOldForeGround >> 8);
unsigned char cOldBlueFore = (unsigned char)lOldForeGround;
- unsigned char cOldRedBack = (unsigned char)(lOldBackGround >> 16);
- unsigned char cOldGreenBack = (unsigned char)(lOldBackGround >> 8);
- unsigned char cOldBlueBack = (unsigned char)lOldBackGround;
-
unsigned char cRedFore = (unsigned char)(lForeGround >> 16);
unsigned char cGreenFore = (unsigned char)(lForeGround >> 8);
unsigned char cBlueFore = (unsigned char)lForeGround;
if (m_pCanvas && m_pCanvas->IsKindOf(CLASSINFO(wxStatusBar)))
vPtlStart.y = OS2Y(vY,vTextY);
else
- vPtlStart.y = OS2Y(vY,vTextY/1.5); // Full extent is a bit much
+ vPtlStart.y = (wxCoord)(OS2Y(vY,vTextY/1.5)); // Full extent is a bit much
}
else
{
if (m_pCanvas && m_pCanvas->IsKindOf(CLASSINFO(wxStatusBar)))
vPtlStart.y = OS2Y(vY,vTextY);
else
- vPtlStart.y = OS2Y(vY,vTextY/1.5);
+ vPtlStart.y = (LONG)(OS2Y(vY,vTextY/1.5));
}
else
vPtlStart.y = vY;
vErrorCode = ::WinGetLastError(wxGetInstance());
sError = wxPMErrorToStr(vErrorCode);
// DEBUG
- sprintf(zMsg, "GpiQueryTextBox for %s: failed with Error: %x - %s", pStr, vErrorCode, sError.c_str());
- (void)wxMessageBox( "wxWindows Menu sample"
+ sprintf(zMsg, "GpiQueryTextBox for %s: failed with Error: %lx - %s", pStr, vErrorCode, sError.c_str());
+ (void)wxMessageBox( "wxWidgets Menu sample"
,zMsg
,wxICON_INFORMATION
);
nPelHeight = lArray[CAPS_HEIGHT];
nHorzRes = lArray[CAPS_HORIZONTAL_RESOLUTION]; // returns pel/meter
nVertRes = lArray[CAPS_VERTICAL_RESOLUTION]; // returns pel/meter
- nWidth = (nHorzRes/39.3) * nPelWidth;
- nHeight = (nVertRes/39.3) * nPelHeight;
+ nWidth = (int)((nHorzRes/39.3) * nPelWidth);
+ nHeight = (int)((nVertRes/39.3) * nPelHeight);
}
return (wxSize(nWidth,nHeight));
} // end of wxDC::GetPPI