void XBox::Draw(XGraphicDevice * dev) { if (!(settings & GO_HIDE)) { XLine::SetupDevice(dev); POINTL ptl[5], po; po.x = p.x; po.y = p.y; ptl[0].x = ptl[4].x = p.x; ptl[0].y = ptl[4].y = p.y; ptl[1].x = p.x; ptl[1].y = ptl[2].y = height + p.y; ptl[3].x = ptl[2].x = width + p.x; ptl[3].y = p.y; GpiBeginPath(dev->hps, 1); GpiMove(dev->hps, &po); GpiPolyLine(dev->hps, 5, ptl); GpiEndPath(dev->hps); if (fill) GpiFillPath(dev->hps, 1, FPATH_ALTERNATE); else GpiOutlinePath(dev->hps, 1, 0); // GpiStrokePath( dev->hps, 1, 0); } }
static void drawLine(pLines pLin, HPS hps,WINDOWINFO *pwi,POINTL ptl1, POINTL ptl2) { GpiSetLineType(hps,pLin->bt.line.LineType); GpiMove(hps, &ptl1); if (pLin->bt.line.LineWidth > 1 && pwi->uXfactor >= (float)1) { LONG lLineWidth = pLin->bt.line.LineWidth; if (pwi->ulUnits == PU_PELS) { lLineWidth = (lLineWidth * pwi->xPixels)/10000; } GpiSetPattern(hps, PATSYM_SOLID); GpiSetLineJoin(hps,pLin->bt.line.LineJoin); GpiSetLineEnd(hps,pLin->bt.line.LineEnd); GpiSetLineWidthGeom (hps,lLineWidth); GpiBeginPath( hps, 1L); /* define a clip path */ } GpiLine(hps,&ptl2); if (pwi->uXfactor >= (float)1) { GpiSetLineType(hps,LINETYPE_SOLID); drwEndPoints(pwi,pLin->bt.arrow,ptl1,ptl2); } if (pLin->bt.line.LineWidth > 1 && pwi->uXfactor >= (float)1) { GpiEndPath(hps); GpiStrokePath (hps, 1, 0); } }
void PMWindowImp::DeviceRect ( Coord x0, Coord y0, Coord x1, Coord y1 ) { Coord left = min(x0, x1); Coord right = max(x0, x1); Coord bottom = min(y0, y1); Coord top = max(y0, y1); /* */ PPOINTL point[4]; /* */ point[0].x = left; point[0].y = top; point[1].x = right; point[1].y = top; point[2].x = right; point[2].y = bottom; point[3].x = left; point[3].y = bottom; /* */ if ( (GpiBeginPath(_hps, 1L) == false) || (GpiSetCurrentPosition(_hps, &point[3]) == false) || (GpiPolyLine(_hps, 4L, point) == GPI_ERROR) || (GpiEndPath(_hps) == false) ) { // report error /* */ } else { GpiStrokePath(_hps, 1L, 0L); } }
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { static INT cxClient, cyClient ; static LONG alJoin [] = { LINEJOIN_BEVEL, LINEJOIN_ROUND, LINEJOIN_MITRE }, alEnd [] = { LINEEND_FLAT, LINEEND_SQUARE, LINEEND_ROUND } ; HPS hps ; INT i ; switch (msg) { case WM_SIZE: cxClient = SHORT1FROMMP (mp2) ; cyClient = SHORT2FROMMP (mp2) ; return 0 ; case WM_PAINT: hps = WinBeginPaint (hwnd, NULLHANDLE, NULL) ; GpiErase (hps) ; for (i = 0 ; i < 3 ; i++) { // Draw the geometric line GpiSetLineJoin (hps, alJoin [i]) ; GpiSetLineEnd (hps, alEnd [i]) ; GpiSetLineWidthGeom (hps, cxClient / 20) ; GpiSetColor (hps, CLR_DARKGRAY) ; GpiBeginPath (hps, 1) ; DrawFigure (hps, i, cxClient, cyClient) ; GpiEndPath (hps) ; GpiStrokePath (hps, 1, 0) ; // Draw the cosmetic line GpiSetLineWidth (hps, LINEWIDTH_THICK) ; GpiSetColor (hps, CLR_BLACK) ; DrawFigure (hps, i, cxClient, cyClient) ; } WinEndPaint (hps) ; return 0 ; } return WinDefWindowProc (hwnd, msg, mp1, mp2) ; }
void XArc::Draw( XGraphicDevice * dev) { if (!(settings & GO_HIDE)) { SetupDevice(dev); POINTL po; po.x = p.x; po.y = p.y; GpiMove(dev->hps, &po); ARCPARAMS a; a.lQ = w; a.lP = h; a.lR = x; a.lS = y; GpiSetArcParams(dev->hps, &a); if (vis) { GpiBeginPath(dev->hps, 1); GpiPartialArc(dev->hps, &po, MAKEFIXED(1, 0), MAKEFIXED(st, 0), MAKEFIXED(en, 0)); GpiLine(dev->hps, &po); GpiEndPath(dev->hps); if (filled) GpiFillPath(dev->hps, 1, FPATH_WINDING); else GpiOutlinePath(dev->hps, 1, 0); } else { POINTL pt[3]; //berechnen! pt[0].x = pt[0].y = 0; GpiMove(dev->hps, &pt[0]); pt[1].x = pt[1].y = 100; pt[2].x = 200; pt[2].y = 0; GpiPointArc(dev->hps, &pt[1]); } } }
void XLine::Draw( XGraphicDevice * dev) { if (!(settings & GO_HIDE)) { POINTL po; po.x = p.x; po.y = p.y; SetupDevice(dev); GpiBeginPath(dev->hps, 1); GpiMove(dev->hps, &po); //POINTL ptl;// = po; po.x = p.x + width; po.y = p.y + height; GpiLine(dev->hps, &po); GpiEndPath(dev->hps); GpiOutlinePath(dev->hps, 1, 0); } }
/*----------------------------------------------------------------------*/ VOID DrawLine(WINDOWINFO *pwi,POINTL ptlSt,POINTL ptlE, short mode,POBJECT pObj) { pLines pLin; if (pObj && pObj->usClass == CLS_LIN) pLin = (pLines)pObj; else pLin = (pLines)0; if ( mode == CREATEMODE) GpiSetMix(pwi->hps,FM_INVERT); else { GpiSetMix(pwi->hps,FM_DEFAULT); GpiSetColor(pwi->hps,pwi->ulOutLineColor); GpiSetLineType(pwi->hps,pwi->lLntype); } if ( mode != CREATEMODE && pwi->lLnWidth > 1) { GpiSetPattern(pwi->hps,PATSYM_SOLID); GpiSetLineJoin(pwi->hps,pwi->lLnJoin); GpiSetLineEnd(pwi->hps,pwi->lLnEnd); GpiSetLineWidthGeom (pwi->hps,pwi->lLnWidth); GpiBeginPath( pwi->hps, 1L); } GpiMove(pwi->hps,&ptlSt); GpiLine(pwi->hps,&ptlE); if ( mode != CREATEMODE && pwi->lLnWidth > 1) { GpiEndPath(pwi->hps); GpiStrokePath (pwi->hps, 1, 0); } if (pLin) drwEndPoints(pwi,pLin->bt.arrow,ptlSt,ptlE); else drwEndPoints(pwi,pwi->arrow,ptlSt,ptlE); }
/*-----------------------------------------------[ private ]-----------------*/ static BOOL paintColumn(HPS hps,WINDOWINFO *pwi,POBJECT pObj, RECTL rclCol,int iMode) { POINTL ptl1,ptl2; RECTL rcl; blocktext *pT = (blocktext *)pObj; ptl1.x = rclCol.xLeft; ptl1.y = rclCol.yBottom; ptl2.x = rclCol.xRight; ptl2.y = rclCol.yTop; rcl = rclCol; if (pT->bt.lPattern == PATSYM_DEFAULT && pT->bt.line.LineType == LINETYPE_INVISIBLE) return FALSE; if (iMode == MODE_PREPPRINTING) { /* ** During the print preparation we do not draw the column but ** we return true so the column painting can take this square ** into account. */ return TRUE; } GpiSetLineType(hps,pT->bt.line.LineType); GpiSetPattern(hps, PATSYM_SOLID); GpiSetColor(hps,pT->ulColColor); if (pT->bt.lPattern == PATSYM_DEFAULT) { /* ** No filling */ GpiSetColor(hps,pT->bt.line.LineColor); GpiMove(hps,&ptl1); GpiBox(hps,DRO_OUTLINE,&ptl2,0,0); } else if ( pT->bt.lPattern != PATSYM_GRADIENTFILL && pT->bt.lPattern != PATSYM_FOUNTAINFILL ) { /* ** we have a standard OS/2 patternfill. */ GpiMove(hps,&ptl1); if (pT->bt.line.LineColor == pT->ulColColor ) { GpiBox(hps,DRO_OUTLINEFILL, &ptl2,0,0); } else { GpiMove(hps,&ptl1); /* ** Draw the filling part */ GpiBox(hps,DRO_FILL, &ptl2,0,0); /* ** Draw the outline */ GpiMove(hps,&ptl1); GpiSetColor(hps,pT->bt.line.LineColor); GpiBox(hps,DRO_OUTLINE, &ptl2,0,0); } } else if (pT->bt.lPattern == PATSYM_GRADIENTFILL || pT->bt.lPattern == PATSYM_FOUNTAINFILL) { GpiBeginPath( hps, 1L); /* define a clip path */ GpiMove(hps,&ptl1); GpiBox(hps,DRO_OUTLINE, &ptl2,0,0); GpiEndPath(hps); GpiSetClipPath(hps,1L,SCP_AND); GpiSetPattern(hps,PATSYM_SOLID); if (pT->bt.lPattern == PATSYM_GRADIENTFILL) GradientFill(pwi,hps,&rcl,&pT->bt.gradient); else FountainFill(pwi,hps,&rcl,&pT->bt.fountain); GpiSetClipPath(hps, 0L, SCP_RESET); /* clear the clip path */ if (pT->bt.line.LineType != LINETYPE_INVISIBLE) { /* ** Draw the outline */ GpiMove(hps,&ptl1); GpiSetColor(hps,pT->bt.line.LineColor); GpiBox(hps,DRO_OUTLINE, &ptl2,0,0); } } return TRUE; }
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { static INT cxClient, cyClient ; HPS hps ; INT x, y ; POINTL ptl ; switch (msg) { case WM_SIZE: cxClient = SHORT1FROMMP (mp2) ; cyClient = SHORT2FROMMP (mp2) ; return 0 ; case WM_PAINT: hps = WinBeginPaint (hwnd, NULLHANDLE, NULL) ; GpiErase (hps) ; for (x = 0 ; x < 3 ; x++) for (y = 0 ; y < 2 ; y++) { // Create an open sub-path GpiBeginPath (hps, 1) ; ptl.x = (1 + 10 * x) * cxClient / 30 ; ptl.y = (4 + 5 * y) * cyClient / 10 ; GpiMove (hps, &ptl) ; ptl.x = (5 + 10 * x) * cxClient / 30 ; ptl.y = (2 + 5 * y) * cyClient / 10 ; GpiLine (hps, &ptl) ; ptl.x = (9 + 10 * x) * cxClient / 30 ; ptl.y = (4 + 5 * y) * cyClient / 10 ; GpiLine (hps, &ptl) ; // Create a closed sub-path ptl.x = (1 + 10 * x) * cxClient / 30 ; ptl.y = (3 + 5 * y) * cyClient / 10 ; GpiMove (hps, &ptl) ; ptl.x = (5 + 10 * x) * cxClient / 30 ; ptl.y = (1 + 5 * y) * cyClient / 10 ; GpiLine (hps, &ptl) ; ptl.x = (9 + 10 * x) * cxClient / 30 ; ptl.y = (3 + 5 * y) * cyClient / 10 ; GpiLine (hps, &ptl) ; GpiCloseFigure (hps) ; GpiEndPath (hps) ; // Possibly modify the path if (y == 0) { GpiSetLineWidthGeom (hps, cxClient / 30) ; GpiModifyPath (hps, 1, MPATH_STROKE) ; } // Perform the operation GpiSetLineWidth (hps, LINEWIDTH_THICK) ; GpiSetLineWidthGeom (hps, cxClient / 50) ; GpiSetPattern (hps, PATSYM_HALFTONE) ; switch (x) { case 0: GpiOutlinePath (hps, 1, 0) ; break ; case 1: GpiStrokePath (hps, 1, 0) ; break ; case 2: GpiFillPath (hps, 1, FPATH_ALTERNATE) ; break ; } } WinEndPaint (hps) ; return 0 ; } return WinDefWindowProc (hwnd, msg, mp1, mp2) ; }
SOM_Scope void SOMLINK ShapePartAdjustViewTypeShapes(ShapePart *somSelf, Environment *ev, ODFrame* frame) { ShapePartData *somThis = ShapePartGetData(somSelf); ShapePartMethodDebug("ShapePart","ShapePartAdjustViewTypeShapes"); try { // Call parent ShapePart_parent_SimplePart_AdjustViewTypeShapes(somSelf, ev, frame); ODFrameFacetIterator* facets = frame->CreateFacetIterator(ev); // Get facets for frame ODFacet* facet = facets->First(ev); // Assume 1 facet delete facets; ODRect rect; ODTypeToken viewType = frame->GetViewType(ev); // Override SimplePart's behavior only if this is an embedded part displaying as frame. if((viewType == somThis->fSession->Tokenize(ev,kODViewAsFrame)) && (!frame->IsRoot(ev))) { // Set the used and active shape to a circle. int width, height; ODRgnHandle hrgnUsedAndActive; ODRect box; ODCanvas *canvas = facet->GetCanvas(ev); #ifdef _PLATFORM_OS2_ HPS hps; hps = ((ODOS2WindowCanvas*) canvas->GetPlatformCanvas(ev, kODPM))->GetPS(ev); // Obtain a PS #endif //_PLATFORM_OS2_ TempODShape frameShape = frame->AcquireFrameShape(ev, canvas); // Get bounding box frameShape->GetBoundingBox(ev, &box); // of frame width = FixedToInt(box.right)-FixedToInt(box.left); // circle to be height = abs(FixedToInt(box.top)-FixedToInt(box.bottom)); // constructed #ifdef _PLATFORM_OS2_ Point center; center.x = width/2; center.y = height/2; int rad = (width < height) ? center.x : center.y; // get radius GpiBeginPath(hps,1L); // Define GPI path GpiSetCurrentPosition(hps , ¢er); // for circle GpiFullArc(hps,DRO_OUTLINE,MAKEFIXED(rad,0)); GpiEndPath(hps); hrgnUsedAndActive = GpiPathToRegion(hps, 1, FPATH_ALTERNATE); // Convert path to GPI region ((ODOS2WindowCanvas *)canvas->GetPlatformCanvas(ev, kODPM))->ReleasePS(ev); // Release the canvas #elif defined(_PLATFORM_WIN32_) hrgnUsedAndActive = CreateEllipticRgn(0,0,width,height); // region from Ellipse box #endif //_PLATFORM_WIN32_ if(hrgnUsedAndActive) { // Use TempODShape so this object won't have to be released. TempODShape usedAndActiveShape = frame->CreateShape(ev); // create a shape usedAndActiveShape->SetRegion(ev, hrgnUsedAndActive); // assign the region to the shape // Set used and active shapes to the newly defined shape frame->ChangeUsedShape(ev, usedAndActiveShape, kODNULL); if(facet) { facet->ChangeActiveShape(ev, usedAndActiveShape, kODNULL); } } // hrgnUsedAndActive } // viewtype is frame and frame isn't root else { // Reset used and active shapes to frame shape frame->ChangeUsedShape(ev, kODNULL, kODNULL); if(facet) { facet->ChangeActiveShape(ev, kODNULL, kODNULL); } } } catch(...) { } }
MRESULT EXPENTRY XLogoWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { HPS hps; HWND hwndMenu; /* Menu resource */ RECTL rcl; /* For finding current window dimensions */ BOOL fSuccess; switch(msg) { case WM_ERASEBACKGROUND: /* * Return TRUE to request PM to paint the window background * in SYSCLR_WINDOW. */ return (MRESULT)( TRUE ); case WM_PAINT: /* * Window contents are drawn here in WM_PAINT processing. */ { HPS hps; /* Presentation Space handle */ RECTL rc; /* Rectangle coordinates */ POINTL pt; /* String screen coordinates */ LONG Lx, Ly; /* Starting points for paths A and B */ POINTL PathAStart, PathBStart; POINTL PathAPolygon[5], PathBPolygon[5]; /* Paths A, B definitions */ /* Create a presentation space */ hps = WinBeginPaint( hwnd, 0L, &rc ); GpiSetColor(hps, CLR_BLACK); /* colour of the text, */ GpiSetBackColor(hps, CLR_BACKGROUND); /* its background and */ GpiSetBackMix(hps, BM_OVERPAINT); /* how it mixes, */ /* and draw the string...*/ WinFillRect( hps, &rc, SYSCLR_WINDOW); WinQueryWindowRect(hwnd, &rcl); Lx = rcl.xRight - rcl.xLeft; /* Calculate window dimensions! */ Ly = rcl.yTop - rcl.yBottom; /* Find starting points of the two paths which make up the X */ PathAStart.x = 0.061 * Lx; PathAStart.y = Ly; PathBStart.x = 0.864 * Lx; PathBStart.y = Ly; /* Find the points for path A, the left half of the X */ PathAPolygon[0].x = 0.404 * Lx; PathAPolygon[0].y = 0.483 * Ly; PathAPolygon[1].x = 0.06 * Lx; PathAPolygon[1].y = 0; PathAPolygon[2].x = 0.141 * Lx; PathAPolygon[2].y = 0; PathAPolygon[3].x = 0.556 * Lx; PathAPolygon[3].y = 0.589 * Ly; PathAPolygon[4].x = 0.288 * Lx; PathAPolygon[4].y = Ly; /* Find the points for path B, the right half of the X */ PathBPolygon[0].x = 0.455 * Lx; PathBPolygon[0].y = 0.417 * Ly; PathBPolygon[1].x = 0.722 * Lx; PathBPolygon[1].y = 0; PathBPolygon[2].x = 0.939 * Lx; PathBPolygon[2].y = 0; PathBPolygon[3].x = 0.6 * Lx; PathBPolygon[3].y = 0.517 * Ly; PathBPolygon[4].x = 0.939 * Lx; PathBPolygon[4].y = Ly; /* Define and draw path A */ GpiBeginPath(hps, 1L); GpiMove(hps, &PathAStart); GpiPolyLine(hps, 5L, PathAPolygon); GpiCloseFigure(hps); GpiEndPath(hps); GpiFillPath(hps, 1L, FPATH_ALTERNATE); /* Define and draw path B. Path number must be 1L */ GpiBeginPath(hps, 1L); GpiMove(hps, &PathBStart); GpiPolyLine(hps, 5L, PathBPolygon); GpiCloseFigure(hps); GpiEndPath(hps); GpiFillPath(hps, 1L, FPATH_ALTERNATE); WinEndPaint(hps); break; } case WM_BUTTON2DOWN: { /* Opens the popup menu at current mouse co-ordinates */ hwndMenu = WinLoadMenu(hwnd, (HMODULE)NULL, ID_X); fSuccess = WinPopupMenu(hwnd, hwndFrame, hwndMenu, MOUSEMSG(&msg)->x, MOUSEMSG(&msg)->y, IDM_EXIT, PU_POSITIONONITEM | PU_HCONSTRAIN | PU_VCONSTRAIN | PU_MOUSEBUTTON2DOWN | PU_MOUSEBUTTON2); break; } case WM_CLOSE: /* * This is the place to put your termination routines */ WinPostMsg( hwnd, WM_QUIT, (MPARAM)0,(MPARAM)0 ); break; case WM_COMMAND: switch (SHORT1FROMMP (mp1)) { case IDM_ABOUT: /* Show Product information dialog box */ WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc, 0, IDD_ABOUT, 0); return ((MRESULT)0); case IDM_EXIT: WinSendMsg (hwnd, WM_CLOSE, 0L, 0L); return ((MRESULT)0); } break; default: /* * Everything else comes here. This call MUST exist * in your window procedure. */ return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } return (MRESULT)FALSE; } /* End of XLogoWndProc */
// returns TRUE if a line has been painted BOOL GRAPHBOARD::OneLine( const HPS hps, POINTL from, POINTL to, INT time_on, INT time_off ) { if( from.x == to.x && from.y == to.y ) return FALSE; // nothing to do POINTL fromLeftTop, fromRightBot, fromRightTop, toLeftTop, toRightBot, toRightTop; const CHAR CenterOffset = 1, PointDist = 2; // 1 and 2 // from and to really are fromLeftBot and toLeftBot from.x -= CenterOffset; fromLeftTop.x = from.x; from.y -= CenterOffset; fromRightBot.y = from.y; to.x -= CenterOffset; toLeftTop.x = to.x; to.y -= CenterOffset; toRightBot.y = to.y; fromRightTop.y = fromLeftTop.y = from.y + PointDist; fromRightTop.x = fromRightBot.x = from.x + PointDist; toRightTop.y = toLeftTop.y = to.y + PointDist; toRightTop.x = toRightBot.x = to.x + PointDist; if( (from.x < to.x && from.y < to.y ) || ( from.x > to.x && from.y > to.y ) ){ // if the diagonal is painted from lower left to upper right, // do an exchange from <-> fromLeftTop and to <-> toLeftTop. // this is necessary for nicer painting // so in this case from is fromLeftTop and fromLeftTop is fromLeftBot from.x += PointDist; fromRightBot.x -= PointDist; to.x += PointDist; toRightBot.x -= PointDist; } GpiBeginPath( hps, 1L ); GpiMove( hps, &from ); GpiLine( hps, &to ); GpiLine( hps, &toRightBot ); GpiLine( hps, &fromRightBot ); GpiLine( hps, &from ); GpiLine( hps, &to ); GpiLine( hps, &toRightTop ); GpiLine( hps, &fromRightTop ); GpiLine( hps, &from ); GpiLine( hps, &to ); GpiLine( hps, &toLeftTop ); GpiLine( hps, &fromLeftTop ); GpiLine( hps, &from ); GpiEndPath( hps ); GpiSetColor( hps, CLR_BLUE ); GpiSetMix( hps, FM_XOR ); GpiFillPath ( hps, 1L, FPATH_WINDING ); if( time_on ){ // if the line will be visible for a short while and then rem. DosSleep( time_on ); GpiBeginPath( hps, 1L ); GpiMove( hps, &from ); GpiLine( hps, &to ); GpiLine( hps, &toRightBot ); GpiLine( hps, &fromRightBot ); GpiLine( hps, &from ); GpiLine( hps, &to ); GpiLine( hps, &toRightTop ); GpiLine( hps, &fromRightTop ); GpiLine( hps, &from ); GpiLine( hps, &to ); GpiLine( hps, &toLeftTop ); GpiLine( hps, &fromLeftTop ); GpiLine( hps, &from ); GpiEndPath( hps ); GpiFillPath ( hps, 1L, FPATH_WINDING ); // remove it if( time_off ) DosSleep( time_off ); // wait after removing the line } return TRUE; // line(s) has / have been painted }