Пример #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);
      }
}
Пример #2
0
/*------------------------------------------------------------------------*/
void BlockTextStretch(POBJECT pObj,PRECTL prclNew,WINDOWINFO *pwi,ULONG ulMsg)
{
   POINTL ptl;
   blocktext *pT = (blocktext *)pObj;

   switch (ulMsg)
   {
      case WM_BUTTON1DOWN:
         break;
      case WM_BUTTON1UP:
         pT->rclf[0].xLeft  = (float)prclNew->xLeft;
         pT->rclf[0].xRight = (float)prclNew->xRight;
         pT->rclf[0].yTop   = (float)prclNew->yTop;
         pT->rclf[0].yBottom= (float)prclNew->yBottom;
         pT->rclf[0].xLeft  /= (float)pwi->usFormWidth;
         pT->rclf[0].xRight /= (float)pwi->usFormWidth;
         pT->rclf[0].yTop   /= (float)pwi->usFormHeight;
         pT->rclf[0].yBottom/= (float)pwi->usFormHeight;
         break;
      case WM_MOUSEMOVE:
         GpiSetLineType(pwi->hps,LINETYPE_DOT);
         ptl.x = prclNew->xLeft;
         ptl.y = prclNew->yBottom;
         GpiMove(pwi->hps, &ptl);
         ptl.x = prclNew->xRight;
         ptl.y = prclNew->yTop;
         GpiBox(pwi->hps,DRO_OUTLINE,&ptl,0L,0L);
         break;
      default:
         break;
   }
   return;
}
Пример #3
0
/*------------------------------------------------------------------------*/
void DrawLineSegment(HPS hps, WINDOWINFO *pwi, POBJECT pObj, RECTL *prcl)
{
   POINTL ptl1;
   POINTL ptl2;
   pLines pLin;

   pLin = (pLines)pObj;

   GpiSetMix(hps,FM_DEFAULT);

   if (pwi->usdrawlayer == pLin->bt.usLayer)
   {
      ptl1.x = (LONG)(pLin->ptl1.x * pwi->usFormWidth );
      ptl1.y = (LONG)(pLin->ptl1.y * pwi->usFormHeight);
      ptl1.x +=(LONG)pwi->fOffx;
      ptl1.y +=(LONG)pwi->fOffy;

      ptl2.x = (LONG)(pLin->ptl2.x * pwi->usFormWidth );
      ptl2.y = (LONG)(pLin->ptl2.y * pwi->usFormHeight);
      ptl2.x +=(LONG)pwi->fOffx;
      ptl2.y +=(LONG)pwi->fOffy;

      if (pLin->bt.Shade.lShadeType != SHADE_NONE)
         lineShadow(pLin,hps,pwi,ptl1,ptl2);

      GpiSetLineType(hps,pLin->bt.line.LineType);
      GpiSetColor(hps,pLin->bt.line.LineColor);
      drawLine(pLin,hps,pwi,ptl1,ptl2);
   }     /*layer stuff */
}
Пример #4
0
VOID ShowStatusLine( const HPS hps, const char Moves,
							const char Ships, const LONG Width,
							const LONG Height )
{
    RECTL Rect = { 0, Height, Width, Height + 30 };
    POINTL Point = { Width, Height };
    CHAR text[256];
 
    WinFillRect( hps, &Rect, CLR_WHITE ); //SYSCLR_WINDOW );	// clear background
    GpiSetColor( hps, CLR_BLACK );
    GpiSetLineType( hps, LINETYPE_SHORTDASH );
    GpiSetLineWidth( hps, LINEWIDTH_NORMAL );
    GpiSetMix( hps, FM_OVERPAINT );
    GpiMove( hps, &Point );
    Point.x = 0;
    GpiLine( hps, &Point );
    Point.x += 10;
    Point.y += 10;
    GpiMove( hps, &Point );
    if( Ships )
	sprintf( text, "%d %s made     %d %s still lost", Moves,
		 Moves == 1 ? "move" : "moves", Ships, Ships == 1 ? "ship" : "ships" );
    else
	sprintf( text, "%d %s made     All ships found", Moves,
		 Moves == 1 ? "move" : "moves" );

    GpiCharString( hps, strlen(text), text );
    DosSleep( 1 );	// free time slice 
} 
Пример #5
0
static void lineShadow(pLines pLin,HPS hps,WINDOWINFO *pwi, POINTL ptl1, POINTL ptl2)
{
   POINTL p[2];

   p[0] = ptl1;
   p[1] = ptl2;
   setShadingOffset(pwi,pLin->bt.Shade.lShadeType, 
                    pLin->bt.Shade.lUnits,p,2);

   GpiSetLineType(hps,pLin->bt.line.LineType);
   GpiSetColor(hps,pLin->bt.Shade.lShadeColor);
   drawLine(pLin,hps,pwi,p[0],p[1]);
}
Пример #6
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);
}
Пример #7
0
/*-----------------------------------------------[ 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 newProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{

  switch (msg)
    {      
    case WM_CREATE:
      {
        PCREATESTRUCT pCreate=PVOIDFROMMP(mp2);

        /* Initialize the slider data */
        WinSetWindowUShort(hwnd, SLIDERARMWITH,20);
        WinSetWindowUShort(hwnd, SLIDERARMHEIGHT,10);
        /* Dimensions of slider. The slider active area is smaller than the window to
           allow drawing of active state. */
        WinSetWindowULong(hwnd, SLIDERCX,pCreate->cx-4);
        WinSetWindowULong(hwnd, SLIDERCY,pCreate->cy-4);
        WinSetWindowULong(hwnd, SLIDERX,2);
        WinSetWindowULong(hwnd, SLIDERY,2);
        WinSetWindowULong(hwnd, SLIDERARMPOS, 0);
        WinSetWindowULong(hwnd, SLDRAGGING,FALSE);
        return (MRESULT)0;
      }
    case WM_SIZE:
      WinSetWindowULong(hwnd, SLIDERCX, SHORT1FROMMP(mp2)-4);
      WinSetWindowULong(hwnd, SLIDERCY, SHORT2FROMMP(mp2)-4);
      WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
      return (MRESULT)0;
    case WM_BUTTON1DOWN:
      {
        SHORT x=SHORT1FROMMP( mp1);
        SHORT y=SHORT2FROMMP( mp1);
        LONG  lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
        USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);

        if(x<lPos+usWidth && y<WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
           && y>WinQueryWindowUShort(hwnd, SLIDERY)) {
          WinSetWindowUShort(hwnd, PTRPOSINSLARM, x-lPos);
        }
        WinSetFocus(HWND_DESKTOP, hwnd);
      break;
      }
    case WM_FOCUSCHANGE:
      {
        HPS hps;
        RECTL rcl;
        POINTL ptl;

        if(SHORT1FROMMP(mp2)) {
          hps=WinGetPS(hwnd);
          WinQueryWindowRect(hwnd, &rcl);        
          GpiSetLineType(hps, LINETYPE_DOT);
          ptl.x=rcl.xLeft;
          ptl.y=rcl.yBottom;
          GpiMove(hps,&ptl);
          ptl.x=rcl.xRight-1;
          GpiLine(hps,&ptl);
          ptl.y=rcl.yTop-1;
          GpiLine(hps,&ptl);
          ptl.x=rcl.xLeft;
          GpiLine(hps,&ptl);
          ptl.y=rcl.yBottom;
          GpiLine(hps,&ptl);
          WinReleasePS(hps);
        }
        else {
          WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
        }

        break;
      }
    case WM_CHAR:
      if(WinQueryFocus(HWND_DESKTOP)==hwnd) {
        /* We have the focus */
        if((SHORT1FROMMP(mp1) & (KC_VIRTUALKEY))==(KC_VIRTUALKEY)) {
          LONG  lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
          USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
          ULONG ulCx=WinQueryWindowULong(hwnd, SLIDERCX);
#if 0
          FILE* file;
          file=fopen("d:\\md.log","a");
          fprintf(file,"0x%x 0x%x \n",SHORT1FROMMP(mp1),SHORT2FROMMP(mp1) );
          fclose(file);
#endif
          /*(KC_KEYUP|KC_PREVDOWN|KC_VIRTUALKEY)*/
          switch(SHORT2FROMMP(mp2))
            {
            case VK_RIGHT:

              if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN)) {
                lPos+=2;
                if(lPos>ulCx-usWidth)
                  lPos=ulCx-usWidth;
                else {
                  WinPostMsg( hwnd,
                              SLM_SETSLIDERINFO,
                              MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
                              MPFROMLONG( (LONG) lPos ));
                  if(SHORT1FROMMP(mp1) & KC_LONEKEY)
                    /* Post SLN_CHANGE notification */
                    WinPostMsg( WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
                                MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
                                MPFROMLONG(lPos));
                  else
                    /* Post SLN_SLIDERTRACK notification */
                    WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
                               MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_SLIDERTRACK),
                               MPFROMLONG(lPos));
                  
                }
                WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
              }
              return (MRESULT)TRUE;
            case VK_LEFT:
              if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN)) {
                lPos-=2;
                if(lPos<0) {
                  lPos=0;
                }
                else {
                  WinPostMsg( hwnd,
                              SLM_SETSLIDERINFO,
                              MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
                              MPFROMLONG( (LONG) lPos ));
                  /* Post SLN_CHANGE notification */
                  WinPostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_CONTROL,
                             MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
                   MPFROMLONG(WinQueryWindowULong(hwnd, SLIDERARMPOS)));

                }
                WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
              }
              return (MRESULT)TRUE;
            default:
              break;
            }
        }
      }
      break;
    case WM_BUTTON1MOTIONSTART:
      {
        SHORT x=SHORT1FROMMP( mp1);
        SHORT y=SHORT2FROMMP( mp1);
        LONG  lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
        USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);

        if(x<lPos+usWidth && y<WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
           && y>WinQueryWindowUShort(hwnd, SLIDERY)) {
          WinSetWindowULong(hwnd, SLDRAGGING, TRUE);
          WinSetCapture(HWND_DESKTOP, hwnd);
        }
        break;
      }
    case WM_BUTTON1MOTIONEND:
      if(WinQueryWindowULong(hwnd, SLDRAGGING)) {
        WinSetWindowULong(hwnd, SLDRAGGING,FALSE);
        WinSetCapture(HWND_DESKTOP, NULLHANDLE);
        /* Post SLN_CHANGE notification */
        WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
                   MPFROMLONG(WinQueryWindowULong(hwnd, SLIDERARMPOS)));
      }
      break;
    case SLM_SETSLIDERINFO:
      switch(SHORT1FROMMP(mp1))
        {
          case SMA_SLIDERARMPOSITION:
            /*  SMA_RANGEVALUE only for now !! */
            if(SHORT2FROMMP(mp1)==SMA_RANGEVALUE) {
              WinSetWindowULong(hwnd, SLIDERARMPOS, LONGFROMMP(mp2));
              WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
              return (MRESULT)0;
            }
            break;
        default:
          break;
        }
      break;
    case WM_MOUSEMOVE:
      if(WinQueryWindowULong(hwnd, SLDRAGGING)) {
        HPS hps;
        RECTL rcl, rcl2, rcl3;
        LONG lTemp;
        SHORT x=SHORT1FROMMP(mp1);
        LONG  lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
        USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
       
        lTemp=lPos;
     
        rcl.xLeft=WinQueryWindowULong(hwnd, SLIDERX);
        rcl.yBottom=WinQueryWindowULong(hwnd, SLIDERY);
        rcl.xRight=rcl.xLeft+WinQueryWindowULong(hwnd, SLIDERCX);
        rcl.yTop=rcl.yBottom+WinQueryWindowULong(hwnd, SLIDERCY);

        rcl2=rcl3=rcl;
        rcl.xLeft=x-WinQueryWindowUShort(hwnd, PTRPOSINSLARM);
        if(rcl.xLeft<rcl2.xLeft)/* Make sure we stop at the left border */
          rcl.xLeft=rcl2.xLeft;

        rcl.xRight=rcl.xLeft+usWidth;
        if(rcl.xRight>rcl2.xRight)
          {/* Make sure we stop at the right border */
            rcl.xRight=rcl2.xRight;
            rcl.xLeft=rcl.xRight-usWidth;
          }
        lPos=rcl.xLeft-WinQueryWindowULong(hwnd, SLIDERX);/* Save position zero based */
        WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
        if(lPos!=lTemp) {
          BOOL rc;

          hps=WinGetPS(hwnd);
          /* Paint Background not necessary here */

          /* Shaft */
          /* Left part */
          rcl3.xRight=rcl.xLeft;
          rc=FALSE;
          if(USERSLIDER) {
            OWNERITEM oi={0};
            oi.hwnd=hwnd;
            oi.hps=hps;
            oi.fsState=SLS_OWNERDRAW;/* More to come */
            oi.rclItem=rcl3;
            oi.idItem=SDA_SLIDERSHAFT;
            rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
                                MPFROMP(&oi) );
          }
          if(!rc)
            WinFillRect(hps, &rcl3, CLR_GREEN);

          /* Right part */
          rcl3.xRight=rcl2.xRight;
          rcl3.xLeft=rcl.xRight;
          rc=FALSE;
          if(USERSLIDER) {
            OWNERITEM oi={0};
            oi.hwnd=hwnd;
            oi.hps=hps;
            oi.fsState=SLS_OWNERDRAW;/* More to come */
            oi.rclItem=rcl3;
            oi.idItem=SDA_SLIDERSHAFT;
            rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
                                MPFROMP(&oi) );
          }
          if(!rc)
            WinFillRect(hps, &rcl3, CLR_WHITE);

          /* Paint Slider */
          rc=FALSE;
          if(USERSLIDER) {
            OWNERITEM oi={0};
            oi.hwnd=hwnd;
            oi.hps=hps;
            oi.fsState=SLS_OWNERDRAW;/* More to come */
            oi.rclItem=rcl;
            oi.idItem=SDA_SLIDERARM;
            rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
                                MPFROMP(&oi) );
          }
          if(!rc)
            {
              WinFillRect(hps,&rcl, CLR_BLUE);
              WinDrawBorder(hps, &rcl, 2, 2, 0, 0 ,0x0400);
            }

          WinReleasePS(hps);

          /* Post SLN_SLIDERTRACK notification */
          WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_SLIDERTRACK),
                     MPFROMLONG(lPos));
        }
      }
      break;
    case WM_PAINT:
      {
        HPS hps, hps2;
        RECTL rcl, rcl2, rcl3;
        POINTL ptl;
        LONG  lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
        USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
        BOOL rc;

        WinQueryWindowRect(hwnd, &rcl);

        /* Shaft */
        rcl2.xLeft=WinQueryWindowULong(hwnd, SLIDERX);
        rcl2.yBottom=WinQueryWindowULong(hwnd, SLIDERY);
        rcl2.xRight=rcl2.xLeft+WinQueryWindowULong(hwnd, SLIDERCX)-1;
        rcl2.yTop=rcl2.yBottom+WinQueryWindowULong(hwnd, SLIDERCY)-1;

        /* Background */
        hps2=WinGetPS(hwnd);
        GpiExcludeClipRectangle(hps2,&rcl2);
        WinFillRect(hps2, &rcl, CLR_PALEGRAY);
        WinReleasePS(hps2);
        rcl2.yTop+=1;
        rcl2.xRight+=1;

        hps=WinBeginPaint(hwnd, NULLHANDLE, NULLHANDLE);
        /* Focus */
        if(WinQueryFocus(HWND_DESKTOP)==hwnd) {
          GpiSetLineType(hps, LINETYPE_DOT);
          ptl.x=rcl.xLeft;
          ptl.y=rcl.yBottom;
          GpiMove(hps,&ptl);
          ptl.x=rcl.xRight-1;
          GpiLine(hps,&ptl);
          ptl.y=rcl.yTop-1;
          GpiLine(hps,&ptl);
          ptl.x=rcl.xLeft;
          GpiLine(hps,&ptl);
          ptl.y=rcl.yBottom;
          GpiLine(hps,&ptl);
        }

        rcl3=rcl=rcl2;

        /* Arm pos */        
        rcl2.xLeft+=lPos;
        /* Arm size */        
        rcl2.xRight=rcl2.xLeft+usWidth;
        
        /* Shaft */
        /* Left part */
        rcl3.xRight=rcl2.xLeft;
        rc=FALSE;
        if(USERSLIDER) {
          OWNERITEM oi={0};
          oi.hwnd=hwnd;
          oi.hps=hps;
          oi.fsState=SLS_OWNERDRAW;/* More to come */
          oi.rclItem=rcl3;
          oi.idItem=SDA_SLIDERSHAFT;
          rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
                    MPFROMP(&oi) );
        }
        if(!rc)
          WinFillRect(hps, &rcl3, CLR_GREEN);

        /* Right part */
        rcl3.xRight=rcl.xRight;
        rcl3.xLeft=rcl2.xRight;
        rc=FALSE;
        if(USERSLIDER) {
          OWNERITEM oi={0};
          oi.hwnd=hwnd;
          oi.hps=hps;
          oi.fsState=SLS_OWNERDRAW;/* More to come */
          oi.rclItem=rcl3;
          oi.idItem=SDA_SLIDERSHAFT;
          rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
                              MPFROMP(&oi) );
        }
        if(!rc)
          WinFillRect(hps, &rcl3, CLR_WHITE);

        rc=FALSE;
        if(USERSLIDER) {
          OWNERITEM oi={0};
          oi.hwnd=hwnd;
          oi.hps=hps;
          oi.fsState=SLS_OWNERDRAW;/* More to come */
          oi.rclItem=rcl2;
          oi.idItem=SDA_SLIDERARM;
          rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
                              MPFROMP(&oi) );
        }
        if(!rc)
          {
            WinFillRect(hps,&rcl2, CLR_BLUE);        
            WinDrawBorder(hps, &rcl2, 2, 2, 0, 0 ,0x0400);
          }

        WinEndPaint(hps);
        return (MRESULT)0;
      }
      break;
    default:
      break;
    }

  return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
Пример #9
0
//Draw the Plugin effect into the given presentation space
BOOL CBZPluginRender(PSPAINT * pPaint, PVOID pData, short sActive)
{
    POINTL point;               //should allocate all this data dynamically, to keep it off

    int i, y;                   // the stack!!!

    FONTMETRICS font;
    PLUGINSHARE *pPluginData;

    pPluginData = (PLUGINSHARE *) pData;

    if (pPluginData == NULL)
        return (FALSE);

    if (((sActive == TRUE) && !(pPluginData->bActiveEnabled)) ||
            ((sActive == FALSE) && !(pPluginData->bInactiveEnabled)))
        return (TRUE);

    GpiQueryFontMetrics(pPaint->hpsWin, sizeof(font), &(font));

    GpiSetLineType(pPaint->hps, pPluginData->lLineStyle);

    // if no text
    if (pPaint->rectlText.xLeft == pPaint->rectlText.xRight)
    {
        for (y = 4; y < pPaint->rectlWindow.yTop - 4; y += 3)
        {
            if (sActive == TRUE)
                GpiSetColor(pPaint->hps, pPluginData->lActiveShadowColor);
            else
                GpiSetColor(pPaint->hps, pPluginData->lInactiveShadowColor);
            point.x = pPaint->rectlWindow.xLeft + 6;
            point.y = y;
            GpiMove(pPaint->hps, &point);
            point.x = pPaint->rectlWindow.xRight - 5;
            GpiLine(pPaint->hps, &point);

            if (sActive == TRUE)
                GpiSetColor(pPaint->hps, pPluginData->lActiveLineColor);
            else
                GpiSetColor(pPaint->hps, pPluginData->lInactiveLineColor);
            point.x = pPaint->rectlWindow.xLeft + 5;
            point.y++;
            GpiMove(pPaint->hps, &point);
            point.x = pPaint->rectlWindow.xRight - 6;
            GpiLine(pPaint->hps, &point);
        }
    }
    else                        //text exists... draw around it.
    {
        if (pPaint->rectlWindow.xRight > (pPaint->rectlText.xRight + font.lAveCharWidth))
        {
            for (y = 4; y < pPaint->rectlWindow.yTop - 4; y += 3)
            {
                if (sActive == TRUE)
                    GpiSetColor(pPaint->hps, pPluginData->lActiveShadowColor);
                else
                    GpiSetColor(pPaint->hps, pPluginData->lInactiveShadowColor);
                point.x = pPaint->rectlText.xRight + 6;
                point.y = y;
                GpiMove(pPaint->hps, &point);
                point.x = pPaint->rectlWindow.xRight - 5;
                GpiLine(pPaint->hps, &point);

                if (sActive == TRUE)
                    GpiSetColor(pPaint->hps, pPluginData->lActiveLineColor);
                else
                    GpiSetColor(pPaint->hps, pPluginData->lInactiveLineColor);
                point.x = pPaint->rectlText.xRight + 5;
                point.y++;
                GpiMove(pPaint->hps, &point);
                point.x = pPaint->rectlWindow.xRight - 6;
                GpiLine(pPaint->hps, &point);
            }
        }

        if ((pPaint->rectlWindow.xLeft + font.lAveCharWidth) < (pPaint->rectlText.xLeft))
        {
            for (y = 4; y < pPaint->rectlWindow.yTop - 4; y += 3)
            {
                if (sActive == TRUE)
                    GpiSetColor(pPaint->hps, pPluginData->lActiveShadowColor);
                else
                    GpiSetColor(pPaint->hps, pPluginData->lInactiveShadowColor);
                point.x = pPaint->rectlWindow.xLeft + 6;
                point.y = y;
                GpiMove(pPaint->hps, &point);
                point.x = pPaint->rectlText.xLeft - 5;
                GpiLine(pPaint->hps, &point);

                if (sActive == TRUE)
                    GpiSetColor(pPaint->hps, pPluginData->lActiveLineColor);
                else
                    GpiSetColor(pPaint->hps, pPluginData->lInactiveLineColor);
                point.x = pPaint->rectlWindow.xLeft + 5;
                point.y++;
                GpiMove(pPaint->hps, &point);
                point.x = pPaint->rectlText.xLeft - 6;
                GpiLine(pPaint->hps, &point);
            }
        }
    }
    return (TRUE);
}
Пример #10
0
VOID GRAPHBOARD::DrawPMBoard( const HPS hps )
{
    POINTL StartHor = LowerLeftPlace;
    POINTL EndHor;
    POINTL StartVert = LowerLeftPlace;
    POINTL EndVert;
    int Value;
	
    EndHor.x = StartHor.x + (Columns - 3) * dist;	// shown cols = Columns - 2
    EndHor.y = StartHor.y;
    EndVert.x = StartVert.x;
    EndVert.y = StartVert.y + (Rows - 3) * dist;

    GpiSetColor( hps, CLR_BLACK );
    GpiSetLineType( hps, LINETYPE_SOLID );
    GpiSetLineWidth( hps, LINEWIDTH_NORMAL );


    if( !InfoData.IsLineStyle(IDC_DIAGONALS) ){
	// first we paint the horizontal lines:
	for( ; StartHor.y <= EndVert.y; StartHor.y += dist, EndHor.y += dist ){
	    GpiMove( hps, &StartHor );
	    GpiLine( hps, &EndHor );
	}
	// then the vertical lines:
	for(; StartVert.x <= EndHor.x; StartVert.x += dist, EndVert.x += dist ){
	    GpiMove( hps, &StartVert );
	    GpiLine( hps, &EndVert );
	}
    }	// end if !InfoData.IsLineStyle( IDC_DIAGONALS )
    DosSleep( 1 );	// free time slice 

    if( !InfoData.IsLineStyle(IDC_VERTICALS) ){
	// there are still some diagonals left:
	// Start... draw from left top to right bottom
	GpiSetLineType( hps, LINETYPE_DOT );
	StartVert.x = LowerLeftPlace.x;
	StartVert.y = LowerLeftPlace.y + dist;
	StartHor.x = LowerLeftPlace.x + dist;
	StartHor.y = LowerLeftPlace.y;

	// End... draw from right top to left bottom
	EndVert.x = LowerLeftPlace.x + ( Columns - 3) * dist;
	EndVert.y = LowerLeftPlace.y + dist;
	EndHor.x = LowerLeftPlace.x + ( Columns - 4) * dist;
	EndHor.y = LowerLeftPlace.y;
		
	int VertBreak = 0;
	int HorBreak = 0;
	while( StartVert.x != StartHor.x || StartVert.y != StartHor.y )
	    {
		GpiMove( hps, &StartHor );
		GpiLine( hps, &StartVert );
		GpiMove( hps, &EndHor );
		GpiLine( hps, &EndVert );
		if( VertBreak ){
		    StartVert.x += dist;
		    EndVert.x -= dist;
		} else {
		    StartVert.y += dist;
		    EndVert.y += dist;
		    if( StartVert.y == LowerLeftPlace.y + (Rows - 3)*dist)
			VertBreak = 1;
		}
		if( HorBreak ){
		    StartHor.y += dist;
		    EndHor.y += dist;
		} else {
		    StartHor.x += dist;
		    EndHor.x -= dist;
		    if( StartHor.x == LowerLeftPlace.x + (Columns - 3 ) * dist )
			HorBreak = 1;
		}
	    }	
    }	// end if !InfoData.IsLineStyle( IDC_VERTICALS )
    DosSleep( 1 );	// free time slice 
	
    // now we insert the values that have already been discovered
    for( char i = 1; i < Rows - 1; i++ ){
	for( char j = 1; j < Columns - 1; j++ ){
	    if( (Value = GetDiscovered( i, j) ) != -1 ){
		DrawPMPlace( hps, i, j, Value, FALSE );
	    } else {	
		ToggleMarked( i, j );
		DrawPMMark( hps, i, j );
	    }
	}			// for j
	DosSleep( 1 );		// free timeslice
    }				// for i
}