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);
      }
}
Beispiel #2
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 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);
}
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) ;
     }