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); } }
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]); } } }
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 */
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) ; }
// 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 }