void DrawBox( HWND hwnd )
{
  HPS hps;
  POINTL pointl;

  // Get a cached PS for the window

  hps = WinGetPS( hwnd );

  pointl.x = pointl.y = 0;

  // Set the current position to (0,0)

  GpiSetCurrentPosition( hps, &pointl );

  pointl.x = pointl.y = 10;

  // Draw a 10 by 10 box from the current position in the
  // current color.

  GpiBox( hps, DRO_OUTLINE, &pointl,0,0 );

  // Free the cached PS

  WinReleasePS( hps );

 }
コード例 #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 BlockTextMoveOutLine(POBJECT pObj,WINDOWINFO *pwi, SHORT dx, SHORT dy)
{
   blocktext *pT = (blocktext *)pObj;
   POINTL ptl1,ptl2;
   RECTL  rcl;

   if (!pObj)
      return;

   rcl.xLeft   = pT->rclf[0].xLeft  * pwi->usFormWidth;
   rcl.xRight  = pT->rclf[0].xRight * pwi->usFormWidth;
   rcl.yTop    = pT->rclf[0].yTop   * pwi->usFormHeight;
   rcl.yBottom = pT->rclf[0].yBottom* pwi->usFormHeight;

   ptl1.x = rcl.xLeft;
   ptl1.y = rcl.yTop;

   ptl1.y += (LONG)dy;
   ptl1.x += (LONG)dx;
 
   ptl2.x = rcl.xRight;
   ptl2.y = rcl.yBottom;

   ptl2.y += (LONG)dy;
   ptl2.x += (LONG)dx;

   GpiMove(pwi->hps,&ptl1);
   GpiBox(pwi->hps,DRO_OUTLINE,&ptl2,0,0);
   return;
}
コード例 #4
0
LONG APIENTRY HdrEllipse (HPS hps, LONG lOption, PPOINTL pptl)
     {
     POINTL ptlCurrent ;

     GpiQueryCurrentPosition (hps, &ptlCurrent) ;

     return GpiBox (hps, lOption, pptl, labs (pptl->x - ptlCurrent.x),
                                        labs (pptl->y - ptlCurrent.y)) ;
     }
コード例 #5
0
VOID DrawZoomBoxInner (HWND hwnd)
     {

     GpiSetMix (cp.hpsScreen, FM_INVERT) ;

     GpiMove (cp.hpsScreen, &ptlZBox1);
     GpiBox (cp.hpsScreen, DRO_OUTLINE, &ptlZBox2, 0L, 0L);

     GpiSetMix (cp.hpsScreen, FM_DEFAULT);
     }
コード例 #6
0
ファイル: pmgame.cpp プロジェクト: kidaa/BermudaTriangle
VOID GRAPHBOARD::ShowPointerPos( HPS hps, LONG ptx, LONG pty )
{
    POINTL Point;

    Point.x = LowerLeftPlace.x + (GetBoardCol( ptx ) - 1) * dist;
    Point.y = LowerLeftPlace.y + (GetBoardRow( pty ) - 1) * dist;
    if( Point.x == DrawPoint.x && Point.y == DrawPoint.y ) return;
    // nothing to do

    if( GetfShowLines() ){	// if the help lines are visible, turn them off
	SetfShowLines( FALSE );
	DisplayLines( hps );
    }

    GpiSetMix( hps, FM_XOR );
    GpiSetColor( hps, CLR_DARKGRAY );
    if( DrawPoint.x >= LowerLeftPlace.x && DrawPoint.y >= LowerLeftPlace.y ) {
	// there exists a visible square that must be removed
	DrawPoint.x -= dist / 3;
	DrawPoint.y -= dist / 3;
	GpiMove( hps, &DrawPoint );
	DrawPoint.x += 2 * dist / 3;
	DrawPoint.y += 2 * dist / 3;
	GpiBox( hps, DRO_OUTLINEFILL, &DrawPoint, 0, 0 );

    }
    DrawPoint.x = Point.x;	// DrawPoint is set to the new point
    DrawPoint.y = Point.y;
    if( Point.x >= LowerLeftPlace.x && Point.y >= LowerLeftPlace.y ){
	// neither GetBoardCol nor GetBoardRow returned 0 => point is visible
	Point.x -= dist / 3;
	Point.y -= dist / 3;
	GpiMove( hps, &Point );
	Point.x += 2 * dist / 3;
	Point.y += 2 * dist / 3;
	GpiBox( hps, DRO_OUTLINEFILL, &Point, 0, 0 );
    }
    GpiSetMix( hps, FM_OVERPAINT );
}
コード例 #7
0
SOM_Scope void  SOMLINK ShapePartDrawFrame(ShapePart *somSelf,
                                            Environment *ev,
                                            ODFacet* facet,
                                            ODShape* invalidShape)
{
    ShapePartData *somThis = ShapePartGetData(somSelf);
    ShapePartMethodDebug("ShapePart","ShapePartDrawFrame");

    ODFrame* displayFrame = facet->GetFrame(ev);
    TempODShape shape = displayFrame->AcquireFrameShape(ev, facet->GetCanvas(ev));
    ODRect rect;
    shape->GetBoundingBox(ev, &rect);


#if defined(_PLATFORM_WIN32_)
    Rect frameRect;
    SetRect(&frameRect, FixedToInt(rect.left),
                       FixedToInt(rect.top),
                       FixedToInt(rect.right),
                       FixedToInt(rect.bottom));

    HDC hdc;
    CFocus focus(facet, invalidShape, &hdc);

    HBRUSH hbr = CreateSolidBrush (_fBackgroundColor);
    FillRect (hdc, &frameRect, hbr);
    DeleteObject (hbr);

#elif defined (_PLATFORM_OS2_)

    RECTL frameRect;
    frameRect.xLeft = FixedToInt(rect.left);
    frameRect.yTop  = FixedToInt(rect.top);
    frameRect.xRight  = FixedToInt(rect.right);
    frameRect.yBottom  = FixedToInt(rect.bottom);

    HPS hdc;
    CFocus focus(facet, invalidShape, &hdc);

    GpiCreateLogColorTable (hdc, 0L, LCOLF_RGB, 0L, 0L, 0L);
    GpiSetColor(hdc, _fBackgroundColor);
    POINTL orig = {0, 0};
    GpiMove(hdc, &orig);
    POINTL ptl = {frameRect.xRight, frameRect.yTop};
    GpiBox(hdc, DRO_FILL, &ptl, 0, 0);


#endif
}
//--------------------------------------------------------------------------
//
// DrawShearedBox
//
// --------------------------------------------------------------------------
void DrawShearedBox( HWND hwnd )
{
  HPS hps;
  POINTL pointl;
  MATRIXLF m;

  // Get a cached PS for the window

  hps = WinGetPS( hwnd );

  // Query the current contents of the model transform

  GpiQueryModelTransformMatrix( hps, 9L, &m );

  m.fxM21 = MAKEFIXED(1,0); // tan(45)
 // m.fxM22 = MAKEFIXED(1,0); // identity

  // Replace the model transform with our modified one

  GpiSetModelTransformMatrix( hps, 9L, &m, TRANSFORM_REPLACE );


  // Set the current position to (0,100)

  pointl.x = 400; pointl.y = 200;

  GpiSetCurrentPosition( hps, &pointl );

  // Draw a 100 by 100 box from the current position in the
  // current color.

  pointl.x = pointl.y = 100;

  GpiSetColor( hps, CLR_BLUE );
  GpiSetPattern( hps, PATSYM_HALFTONE );

  GpiBox( hps, DRO_OUTLINEFILL, &pointl,0,0 );

  // Free the cached PS

  WinReleasePS( hps );
}
//--------------------------------------------------------------------------
//
// DrawTransformedBox
//
// --------------------------------------------------------------------------
void DrawTransformedBox( HWND hwnd )
{
  HPS hps;
  POINTL pointl;
  MATRIXLF m;

  // Get a cached PS for the window

  hps = WinGetPS( hwnd );

  // Query the current contents of the model transform

  GpiQueryModelTransformMatrix( hps, 9L, &m );

  m.lM31  = 100;                 // Translate the x coordinates
  m.lM32  = 100;                 // Translate the y coordinates
  m.fxM11 = MAKEFIXED(10,0);     // Scale up the x coordinates
  m.fxM22 = MAKEFIXED(10,0);     // Scale up the y coordinates

  // Replace the model transform with our modified one

  GpiSetModelTransformMatrix( hps, 9L, &m, TRANSFORM_REPLACE );


  // Set the current position to (0,0)

  pointl.x = pointl.y = 0;

  GpiSetCurrentPosition( hps, &pointl );

  // Draw a 10 by 10 box from the current position in the
  // current color.

  pointl.x = pointl.y = 10;

  GpiBox( hps, DRO_OUTLINE, &pointl,0,0 );

  // Free the cached PS

  WinReleasePS( hps );
}
コード例 #10
0
static void draw ( IPresSpaceHandle hps,
                   IListBox *lb, 
                   const TgtLocation &target )
  {
  if ( target.index != nil )
    {
    // First, get offset from top of listbox:
    unsigned
      offset = target.index - lb->top() + 1,
      height = ListBoxItem::itemHeight( lb );
    // Next, adjust if before this item:
    if ( target.type == ListBoxItem::before )
      offset--;
    // Calculate that item's rectangle's bottom:
    unsigned
      bottom = lb->rect().height() - height * offset;
    // Lower 2 pels 'cause it looks better!
    bottom -= 2;
    // Draw line or box:
    IPoint
      origin( 0, bottom );
    if ( target.type == ListBoxItem::on )
      {
      IPoint
        topRight( lb->rect().width(), bottom + height );
      origin += 1;
      topRight -= IPoint( WinQuerySysValue( HWND_DESKTOP,
                                            SV_CXVSCROLL ) + 1, 1 );
      GpiMove( hps, PPOINTL( &origin ) );
      GpiBox( hps, DRO_OUTLINE, PPOINTL( &topRight ), 0, 0 );
      }
    else
      {
      IPoint
        end( lb->rect().width(), bottom );
      GpiMove( hps, PPOINTL( &origin ) );
      GpiLine( hps, PPOINTL( &end ) );
      }
    }
  }
//--------------------------------------------------------------------------
//
// RotateBox
//
// --------------------------------------------------------------------------
void RotateBox( HWND hwnd )
{
  HPS hps;
  POINTL pointlBox, pointlStart;
  MATRIXLF m;
  LONG i;

  // Get a cached PS for the window

  hps = WinGetPS( hwnd );

  // This time let's draw the boxes in blue

  GpiSetColor( hps, CLR_BLUE );

  // For this simple example, we will choose an arbitary position
  // as the anchor point for each box of (400,400). This will be
  // the point about which each box is rotated. A nice
  // alternative, as a small enhancement, would be to make the
  // start position be wherever the mouse is clicked in the
  // window.

  pointlStart.x = 400;
  pointlStart.y = 400;

  // Query the current contents of the model transform

  GpiQueryModelTransformMatrix( hps, 9L, &m );

  // Setup our box coordinates to be 100 by 100 from wherever
  // the start position is.

  pointlBox.y = pointlStart.y + 100;
  pointlBox.x = pointlStart.x + 100;

  // Draw a series of boxes, each time around the loop we'll
  // rotate through an extra 10 degrees, replacing the transform
  // with our newly calculated one.

  for ( i=0; i<360; i+=10 )
  {
    GpiRotate( hps
             , &m
             , TRANSFORM_REPLACE
             , MAKEFIXED(i,0)
             , &pointlStart );

    GpiSetModelTransformMatrix( hps, 9L, &m, TRANSFORM_REPLACE );

    GpiSetCurrentPosition( hps, &pointlStart );

    // Draw a 100 by 100 box. Note that we issue a normal box
    // drawing request. Blissfully unaware that the transform
    // we setup will cause our box to be rotated.

    GpiBox( hps, DRO_OUTLINE, &pointlBox,0,0 );
  }

  // Free the cached PS

  WinReleasePS( hps );

}
コード例 #12
0
ファイル: pm_tool.cpp プロジェクト: lecheel/fte-fork
MRESULT EXPENTRY ToolBarProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
    if (msg == WM_CREATE) {
        WinSetWindowPtr(hwnd, QWL_USER, PVOIDFROMMP(mp1));
    } else {
        ToolBarData *td = (ToolBarData *)WinQueryWindowPtr(hwnd, QWL_USER);
        ToolBarItem *items = td->pItems;

        switch (msg) {
        case WM_DESTROY:
            free(td);
            free(items);
            break;

        case WM_PAINT:
        {
            HPS hps;
            RECTL rcl;
            POINTL ptl;
            SWP swp;
            int xpos, ypos, item;

            WinQueryWindowPos(hwnd, &swp);

            hps = WinBeginPaint(hwnd, 0, &rcl);

            /* top outside 3D border */
            if (rcl.yBottom < 1) {
                GpiSetColor(hps, CLR_DARKGRAY);
                ptl.x = rcl.xLeft;
                ptl.y = 0;
                GpiMove(hps, &ptl);
                ptl.x = Min(rcl.xRight, swp.cx - 2);
                GpiLine(hps, &ptl);
            }

            /* bottom outside 3D border */
            if (rcl.yTop >= swp.cy - 1 - 1) {
                GpiSetColor(hps, CLR_WHITE);
                ptl.x = Max(rcl.xLeft, 1);
                ptl.y = swp.cy - 1;
                GpiMove(hps, &ptl);
                ptl.x = rcl.xRight;
                GpiLine(hps, &ptl);
            }

            /* 3D corners */
            GpiSetColor(hps, CLR_PALEGRAY);
            ptl.x = 0;
            ptl.y = 0;
            GpiSetPel(hps, &ptl);
            ptl.x = swp.cx - 1;
            ptl.y = swp.cy - 1;
            GpiSetPel(hps, &ptl);

            /* bottom space */
            if (rcl.yBottom < TYBORDER - 1) {
                for (ptl.y = 1; ptl.y < TYBORDER - 2; ptl.y++) {
                    ptl.x = Max(rcl.xLeft, 1);
                    GpiMove(hps, &ptl);
                    ptl.x = Min(rcl.xRight, swp.cx - 1);
                    GpiLine(hps, &ptl);
                }
            }

            /* top space */
            if (rcl.yTop >= swp.cy - TYBORDER + 2) {
                for (ptl.y = swp.cy - TYBORDER + 2; ptl.y < swp.cy - 1; ptl.y++) {
                    ptl.x = Max(rcl.xLeft, 1);
                    GpiMove(hps, &ptl);
                    ptl.x = Min(rcl.xRight, swp.cx - 1);
                    GpiLine(hps, &ptl);
                }
            }

            /* left outside 3D border */
            if (rcl.xLeft < 1) {
                GpiSetColor(hps, CLR_WHITE);
                ptl.y = Max(1, rcl.yBottom);
                ptl.x = 0;
                GpiMove(hps, &ptl);
                ptl.y = rcl.yTop;
                GpiLine(hps, &ptl);
            }

            /* right outside 3D border */
            if (rcl.xRight >= swp.cx - 1) {
                GpiSetColor(hps, CLR_DARKGRAY);
                ptl.y = rcl.yBottom;
                ptl.x = swp.cx - 1;
                GpiMove(hps, &ptl);
                ptl.y = Min(swp.cy - 2, rcl.yTop);
                GpiLine(hps, &ptl);
            }

            /* left border */
            if (rcl.xLeft < TXBORDER - 2) {
                GpiSetColor(hps, CLR_PALEGRAY);
                for (ptl.x = 1; ptl.x < TXBORDER - 2; ptl.x++) {
                    ptl.y = Max(1, rcl.yBottom);
                    GpiMove(hps, &ptl);
                    ptl.y = Min(swp.cy - 2, rcl.yTop);
                    GpiLine(hps, &ptl);
                }
            }

            /* draw toolbar items */
            xpos = TXBORDER;
            ypos = TYBORDER;

            for (item = 0; item < td->ulCount; item++) {
                if (items[item].ulType == tiBITMAP) {
                    if (rcl.xRight >= xpos - 2 && rcl.xLeft <= xpos + TXICON + 1) {
                        GpiSetColor(hps, CLR_BLACK);
                        ptl.x = xpos - 2;
                        ptl.y = ypos - 2;
                        GpiMove(hps, &ptl);
                        ptl.x = xpos + TXICON + 1;
                        ptl.y = ypos + TYICON + 1;
                        GpiBox(hps, DRO_OUTLINE, &ptl, 0, 0);
                        if (item == td->ulDepressed && (items[item].ulFlags & tfDEPRESSED)) {
                            ptl.x = xpos + 1;
                            ptl.y = ypos - 1;
                            WinDrawBitmap(hps,
                                          items[item].hBitmap,
                                          0,
                                          &ptl,
                                          0, 0,
                                          (items[item].ulFlags & tfDISABLED) ? DBM_INVERT: DBM_NORMAL);

                            GpiSetColor(hps, CLR_DARKGRAY);
                            ptl.x = xpos - 1;
                            ptl.y = ypos - 1;
                            GpiMove(hps, &ptl);
                            ptl.y = ypos + TYICON;
                            GpiLine(hps, &ptl);
                            ptl.x = xpos + TXICON;
                            GpiLine(hps, &ptl);
                            ptl.y--;
                            GpiMove(hps, &ptl);
                            ptl.x = xpos;
                            GpiLine(hps, &ptl);
                            ptl.y = ypos - 1;
                            GpiLine(hps, &ptl);
                        } else {
                            ptl.x = xpos;
                            ptl.y = ypos;
                            WinDrawBitmap(hps,
                                          items[item].hBitmap,
                                          0,
                                          &ptl,
                                          0, 0,
                                          (items[item].ulFlags & tfDISABLED) ? DBM_INVERT: DBM_NORMAL);

                            GpiSetColor(hps, CLR_PALEGRAY);
                            ptl.x = xpos - 1;
                            ptl.y = ypos - 1;
                            GpiSetPel(hps, &ptl);
                            GpiSetColor(hps, CLR_WHITE);
                            ptl.y++;
                            GpiMove(hps, &ptl);
                            ptl.y = ypos + TYICON;
                            GpiLine(hps, &ptl);
                            ptl.x = xpos + TXICON - 1;
                            GpiLine(hps, &ptl);
                            GpiSetColor(hps, CLR_PALEGRAY);
                            ptl.x++;
                            GpiSetPel(hps, &ptl);
                            ptl.y--;
                            GpiSetColor(hps, CLR_DARKGRAY);
                            GpiMove(hps, &ptl);
                            ptl.y = ypos - 1;
                            GpiLine(hps, &ptl);
                            ptl.x = xpos;
                            GpiLine(hps, &ptl);
                        }
                    }
                    xpos += TXICON + 3;
                } else if (items[item].ulType == tiSEPARATOR) {
                    if (rcl.xRight >= xpos - 1 && rcl.xLeft <= xpos + TXSEPARATOR + 1) {
                        GpiSetColor(hps, CLR_PALEGRAY);
                        ptl.x = xpos - 1;
                        ptl.y = ypos - 2;
                        GpiMove(hps, &ptl);
                        ptl.x = xpos + TXSEPARATOR + 1;
                        ptl.y = ypos + TYICON + 1;
                        GpiBox(hps, DRO_FILL, &ptl, 0, 0);
                    }
                    xpos += TXSEPARATOR + 3;
                }
            }
            GpiSetColor(hps, CLR_PALEGRAY);
            ptl.x = xpos - 1;
            ptl.y = ypos - 2;
            GpiMove(hps, &ptl);
            ptl.x = swp.cx - 2;
            ptl.y = swp.cy - TYBORDER + 1;
            GpiBox(hps, DRO_FILL, &ptl, 0, 0);

            WinEndPaint(hps);
        }
        break;

        case WM_ADJUSTWINDOWPOS:
        {
            PSWP pswp = (PSWP)PVOIDFROMMP(mp1);
            pswp->cy = TYBORDER + TYICON + TYBORDER;
        }
        break;

        case WM_BUTTON1DOWN:
        case WM_BUTTON1DBLCLK:
        {
            int item;
            POINTL ptl;
            RECTL rcl;

            ptl.x = (LONG) SHORT1FROMMP(mp1);
            ptl.y = (LONG) SHORT2FROMMP(mp1);

            rcl.yBottom = TYBORDER - 1;
            rcl.yTop = TYBORDER + TYICON + 1;
            rcl.xLeft = TXBORDER - 1;
            rcl.xRight = TXBORDER + TXICON + 1;

            for (item = 0; item < td->ulCount; item++) {
                if (rcl.xLeft <= ptl.x && rcl.yBottom <= ptl.y &&
                        rcl.xRight >= ptl.x && rcl.yTop >= ptl.y &&
                        td->pItems[item].ulType == tiBITMAP &&
                        (td->pItems[item].ulFlags & tfDISABLED) == 0)
                {
                    td->ulDepressed = item;
                    td->pItems[item].ulFlags |= tfDEPRESSED;
                    WinInvalidateRect(hwnd, &rcl, FALSE);
                    WinSetCapture(HWND_DESKTOP, hwnd);
                    break;
                }
                if (td->pItems[item].ulType == tiBITMAP) {
                    rcl.xLeft += TXICON + 3;
                    rcl.xRight += TXICON + 3;
                } else if (td->pItems[item].ulType == tiSEPARATOR) {
                    rcl.xLeft += TXSEPARATOR + 3;
                    rcl.xRight += TXSEPARATOR + 3;
                }
            }
        }
        break;

        case WM_MOUSEMOVE:
        {
            STARTFUNC("ToolBarProc[WM_MOUSEMOVE]");
            int item;
            POINTL ptl;
            RECTL rcl;

            if (td->ulDepressed == -1)
                break;

            ptl.x = (LONG) SHORT1FROMMP(mp1);
            ptl.y = (LONG) SHORT2FROMMP(mp1);

            rcl.yBottom = TYBORDER - 1;
            rcl.yTop = TYBORDER + TYICON + 1;
            rcl.xLeft = TXBORDER - 1;
            rcl.xRight = TXBORDER + TXICON + 1;

            LOG << "Depressed: " << td-> ulDepressed << ENDLINE;
            for (item = 0; item < td->ulCount; item++) {
                LOG << "Checking item " << item << ENDLINE;
                LOG << "  pItem -> " << (void*)(td->pItems + item) << ENDLINE;
                if (item == td->ulDepressed) {
                    if (rcl.xLeft <= ptl.x && rcl.yBottom <= ptl.y &&
                            rcl.xRight >= ptl.x && rcl.yTop >= ptl.y)
                    {
                        if ((td->pItems[item].ulFlags & tfDEPRESSED) == 0) {
                            td->pItems[item].ulFlags |= tfDEPRESSED;
                            WinInvalidateRect(hwnd, &rcl, FALSE);
                        }
                    } else {
                        if (td->pItems[item].ulFlags & tfDEPRESSED) {
                            td->pItems[item].ulFlags &= ~tfDEPRESSED;
                            WinInvalidateRect(hwnd, &rcl, FALSE);
                        }
                    }
                    break;
                }
                if (td->pItems[item].ulType == tiBITMAP) {
                    rcl.xLeft += TXICON + 3;
                    rcl.xRight += TXICON + 3;
                } else if (td->pItems[item].ulType == tiSEPARATOR) {
                    rcl.xLeft += TXSEPARATOR + 3;
                    rcl.xRight += TXSEPARATOR + 3;
                }
            }
        }
        break;

        case WM_BUTTON1UP:
        {
            int item;
            POINTL ptl;
            RECTL rcl;

            if (td->ulDepressed == -1)
                break;

            ptl.x = (LONG) SHORT1FROMMP(mp1);
            ptl.y = (LONG) SHORT2FROMMP(mp1);

            rcl.yBottom = TYBORDER - 1;
            rcl.yTop = TYBORDER + TYICON + 1;
            rcl.xLeft = TXBORDER - 1;
            rcl.xRight = TXBORDER + TXICON + 1;

            for (item = 0; item < td->ulCount; item++) {
                if (item == td->ulDepressed) {
                    WinSetCapture(HWND_DESKTOP, (HWND)0);
                    if (rcl.xLeft <= ptl.x && rcl.yBottom <= ptl.y &&
                            rcl.xRight >= ptl.x && rcl.yTop >= ptl.y &&
                            td->pItems[item].ulFlags & tfDEPRESSED)
                    {
                        td->pItems[item].ulFlags &= ~tfDEPRESSED;
                        WinInvalidateRect(hwnd, &rcl, FALSE);

                        // message
                        WinPostMsg(WinQueryWindow(hwnd, QW_OWNER), WM_COMMAND, MPFROM2SHORT(td->pItems[item].ulCommand, 0), MPFROM2SHORT(CMDSRC_OTHER, TRUE));

                        break;
                    }
                }
                if (td->pItems[item].ulType == tiBITMAP) {
                    rcl.xLeft += TXICON + 3;
                    rcl.xRight += TXICON + 3;
                } else if (td->pItems[item].ulType == tiSEPARATOR) {
                    rcl.xLeft += TXSEPARATOR + 3;
                    rcl.xRight += TXSEPARATOR + 3;
                }
            }
            td->ulDepressed = -1;
        }
        break;
        }
    }
    return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
コード例 #13
0
ファイル: titlebar.c プロジェクト: OS2World/UTIL-WPS-Styler_2
//===========================================================================
// Draw the titlebar.
// Parameters --------------------------------------------------------------
// PSTLRFRAME p : windows data.
// Return value ------------------------------------------------------------
// VOID
//===========================================================================
static
VOID DrawTitlebar(PSTLRFRAME p) {
   PTBARAIOPT ptbo = p->is.tbhilited? &o.tb.a : &o.tb.i;
   POINTL apt[3];
   INT i;
   GpiCreateLogColorTable(p->hps, 0, LCOLF_RGB, 0, 0, NULL);
   // background ----------------------------------------------------------
   switch (ptbo->bkgnd) {
      // shade --------------------------------------------------------
      case TBARBKGNDSHADE:
         if (ptbo->shade) {         // sfumatura orizzontale
            WsetRect(apt, 0, 0, p->wrclTitle.cx, p->wrclTitle.cy);
            WinDrawBitmap(p->hps, ptbo->hbmp, NULL, apt, 0, 0, DBM_STRETCH);
         } else {                        // sfumatura verticale
            WsetRect(apt, 0, 0, p->wrclTitle.cx, SHADEH_CY);
            for (i = 0; i < p->wrclTitle.cy; i += 2) {
               WinDrawBitmap(p->hps, ptbo->hbmp, NULL, apt, 0, 0, DBM_STRETCH);
               ((PRECTL)apt)->yBottom += SHADEH_CY;
               ((PRECTL)apt)->yTop += SHADEH_CY;
            } /* endfor */
         } /* endif */
         break;
      // bitmap -------------------------------------------------------
      case TBARBKGNDBMP:
         WsetRect(&apt[1], 0, 0, p->wrclTitle.cx, p->wrclTitle.cy);
         if (ptbo->strch) {
            WinDrawBitmap(p->hps, ptbo->hbmp, NULL, &apt[1], 0, 0, DBM_STRETCH);
         } else {
            apt[0].x = apt[0].y = 0;
            while (apt[0].x <= p->wrclTitle.cx) {
               WinDrawBitmap(p->hps, ptbo->hbmp, (PRECTL)&apt[1], apt, 0, 0, 0);
               apt[0].x += ptbo->size.cx;
               apt[2].x = p->wrclTitle.cx - apt[0].x;
            } /* endwhile */
         } /* endif */
         break;
      // solid color --------------------------------------------------
      default:
         apt[0].x = p->wrclTitle.cx - 1;
         apt[0].y = p->wrclTitle.cy - 1;
         GpiSetColor(p->hps, ptbo->clrLeftTop.l);
         GpiBox(p->hps, DRO_OUTLINEFILL, apt, 0L, 0L);
         break;
   } /* endswitch */
   // text ----------------------------------------------------------------
   if (!p->cyfont) {
      GpiQueryTextBox(p->hps, p->cchTxt, p->achTxt, 3, apt);
      p->yfont = - apt[1].y;
      p->cyfont = apt[0].y - apt[1].y;
      p->cxfont = apt[2].x - apt[0].x;
   } /* endif */
   // se il testo Š pi— largo della finestra viene comunque allineato a sin.
   i = (p->cxfont < p->wrclTitle.cx) ? 8: 0;
   apt[0].x = (ptbo->center && i)? (p->wrclTitle.cx - p->cxfont) / 2 + 1: i + 3;
   apt[0].y = (p->wrclTitle.cy - p->cyfont) / 2 + p->yfont;
   apt[1].x = 0;
   apt[1].y = 0;
   apt[2].x = p->wrclTitle.cx - 1;
   apt[2].y = p->wrclTitle.cy - 1;
   if (ptbo->_3DTxt) {                         // disegna ombra testo
      GpiSetColor(p->hps, ptbo->clrBgTxt.l);
      GpiCharStringPosAt(p->hps, apt, (PRECTL)(apt + 1), CHS_CLIP,
                         p->cchTxt, p->achTxt, NULL);
   } /* endif */
   apt[0].x--;
   apt[0].y++;
   GpiSetColor(p->hps, ptbo->clrFgTxt.l);
   GpiCharStringPosAt(p->hps, apt, (PRECTL)(apt + 1), CHS_CLIP,
                      p->cchTxt, p->achTxt, NULL);
   // border --------------------------------------------------------------
   if (ptbo->border) {
      GpiMove(p->hps, &apt[1]);
      apt[1].y = apt[2].y;
      GpiSetColor(p->hps, ptbo->clrHiBkgnd.l);
      GpiPolyLine(p->hps, 2, &apt[1]);
      apt[1].x = apt[2].x;
      apt[1].y = 0;
      apt[2].x = 1;
      apt[2].y = 0;
      GpiSetColor(p->hps, ptbo->clrShBkgnd.l);
      GpiPolyLine(p->hps, 2, &apt[1]);
   } /* endif */
}
コード例 #14
0
MRESULT EXPENTRY ClientWndProc ( HWND hwndWnd, ULONG ulMsg, MPARAM mpParm1, MPARAM mpParm2 )
{
   switch ( ulMsg )
   {
   // For HELP debugging
   #if 0
      case HM_ERROR:
         {
            CHAR     szTempBuffer[256];

            sprintf( szTempBuffer, "Received HM_ERROR message, mp1=0X%8.8X", (ULONG)mpParm1 );
            WinMessageBox ( HWND_DESKTOP, HWND_DESKTOP, szTempBuffer, "HM_ERROR", 0, MB_OK );
         }
         break;

      case HM_EXT_HELP_UNDEFINED:
         WinMessageBox ( HWND_DESKTOP, HWND_DESKTOP, "Received HM_EXT_HELP_UNDEFINED message", "HM_EXT_HELP_UNDEFINED", 0, MB_OK );
         break;

      case HM_HELPSUBITEM_NOT_FOUND:
         WinMessageBox ( HWND_DESKTOP, HWND_DESKTOP, "Received HM_HELPSUBITEM_NOT_FOUND message", "HM_HELPSUBITEM_NOT_FOUND", 0, MB_OK );
         break;
   #endif

      case HM_QUERY_KEYS_HELP:
         return (MRESULT)IDP_KEYS_INFO;
         break;

      case WM_BUTTON1CLICK:
         MoveCursorToPointer( hwndWnd, (*(POINTS *)&mpParm1).x, (*(POINTS *)&mpParm1).y );
         break;

   #if 0
      case WM_BUTTON2CLICK:
         {
            HPS      hpsClient;
            POINTL   ptl;
            INT      xC, yC;


            xC = ( ( (*(POINTS *)&mpParm1).x - cxChar) / cxChar );
            yC = ( ( cyClient - (*(POINTS *)&mpParm1).y ) / cyChar );

            hpsClient = WinGetPS( hwndWnd );
            GpiSetColor( hpsClient, CLR_PALEGRAY );
            if ( xC < 10 )
               GpiSetMix( hpsClient, FM_XOR );
            else if ( xC < 20 )
               GpiSetMix( hpsClient, FM_INVERT );
            else if ( xC < 30 )
               GpiSetMix( hpsClient, FM_NOTXORSRC );
            else if ( xC < 40 )
               GpiSetMix( hpsClient, FM_NOTMASKSRC );
            else if ( xC < 50 )
               GpiSetMix( hpsClient, FM_SUBTRACT );
///            GpiSetBackColor( hpsClient, CLR_PALEGRAY );
///            GpiSetBackMix( hpsClient, BM_OVERPAINT );
///            ptl.x = ( ( (*(POINTS *)&mpParm1).x - cxChar ) / cxChar ) * cxChar + cxChar;
///            ptl.y = ( ( (*(POINTS *)&mpParm1).y - cyClient ) / cyChar - 1 ) * cyChar + cyClient;
            ptl.x = cxChar + ( xC * cxChar );
            ptl.y = cyClient - ( ( yC + 1) * cyChar );
            GpiMove( hpsClient, &ptl );
            ptl.x += cxChar;
            ptl.y += cyChar;
            if ( yC < 5 )
               GpiBox( hpsClient, DRO_FILL, &ptl, 0, 0 );
            else
               GpiBox( hpsClient, DRO_OUTLINE, &ptl, 0, 0 );
///            GpiSetBackColor( hpsClient, CLR_BACKGROUND );
///            GpiSetMix( hpsClient, FM_DEFAULT );
            WinReleasePS( hpsClient );
         }
         break;
   #endif

      case WM_CHAR:
         if ( !( CHARMSG(&ulMsg)->fs & KC_KEYUP ) )
         {
            if ( CHARMSG(&ulMsg)->fs & KC_CHAR )
            {
               ProcessCharMsg( hwndWnd, ulMsg, mpParm1, mpParm2 );
            }
            else if ( CHARMSG(&ulMsg)->fs & KC_VIRTUALKEY )
            {
               if ( !ProcessCursorMsg( hwndWnd, ulMsg, mpParm1, mpParm2 ) )
               {
                  return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 );
               }
            }
         }
         break;

      case WM_CLOSE:
         if ( QueryAbandonChanges( hwndWnd ) )
            return WinDefWindowProc ( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;

      case WM_COMMAND:
         return ProcessCommandMsg( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;

      case WM_CREATE:
         hwndMenu = WinWindowFromID( WinQueryWindow( hwndWnd, QW_PARENT ), FID_MENU );
         hwndHScroll = WinWindowFromID( WinQueryWindow( hwndWnd, QW_PARENT ), FID_HORZSCROLL );
         hwndVScroll = WinWindowFromID( WinQueryWindow( hwndWnd, QW_PARENT ), FID_VERTSCROLL );
         SetWindowTitle( hwndWnd );
         break;

      case WM_DESTROY:
         ClearFile( hwndWnd );
         break;

      case WM_ERASEBACKGROUND:
         return MRFROMSHORT ( TRUE ) ;

      case WM_HELP:
         ProcessHelpMessage( hwndWnd, mpParm1, mpParm2 );
         break;

      case WM_HSCROLL:
         if ( !ProcessHScrollMsg( hwndWnd, ulMsg, mpParm1, mpParm2 ) )
            return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;

      case WM_PAINT:
         PaintScreen( hwndWnd );
         break;

      case WM_SAVEAPPLICATION:
         SaveSettings( hwndWnd, habAnchor );
         return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;

      case WM_SETFOCUS:
         if ( SHORT1FROMMP( mpParm2 ) )
            CreateCursor( hwndWnd );
         else
            DestroyCursor( hwndWnd );
         break;

      case WM_SIZE:
         UpdateWindowSize( hwndWnd, SHORT1FROMMP( mpParm2), SHORT2FROMMP( mpParm2 ) );
         if ( hwndWnd == WinQueryFocus( HWND_DESKTOP ) )
         {
            DestroyCursor( hwndWnd );
            CreateCursor( hwndWnd );
         }
         break;

      case WM_VSCROLL:
         if ( !ProcessVScrollMsg( hwndWnd, ulMsg, mpParm1, mpParm2 ) )
            return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;

      default:
         return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;
   }

   return MRFROMSHORT ( FALSE ) ;
}
コード例 #15
0
ファイル: toolbar.cpp プロジェクト: OS2World/MM-SOUND-Minta
MRESULT EXPENTRY
TOOLBAR :: fnwp (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    PTOOLBAR        ptb = PTOOLBAR (WinQueryWindowPtr (hwnd, 0));
//    static USHORT   id = 0;

    switch (msg)
        {
        case WM_PAINT:
            {
                RECTL   rcl;
                HPS     hps = WinBeginPaint (hwnd, NULLHANDLE, NULL);

                WinQueryWindowRect (hwnd, &rcl);
                GpiMove (hps, (PPOINTL) &rcl.xLeft);
                GpiSetColor (hps, SYSCLR_MENU);
                GpiBox (hps, DRO_FILL, (PPOINTL) &rcl.xRight, 0, 0);

                POINTL  ptl;

                GpiSetColor (hps, SYSCLR_BUTTONLIGHT);

                ptl.x = rcl.xLeft;
                ptl.y = rcl.yBottom;
                GpiMove (hps, &ptl);

                ptl.x = rcl.xRight;
                ptl.y = rcl.yBottom;
                GpiLine (hps, &ptl);

                GpiSetColor (hps, SYSCLR_BUTTONDARK);

                ptl.x = rcl.xLeft;
                ptl.y = rcl.yBottom+1;
                GpiMove (hps, &ptl);

                ptl.x = rcl.xRight;
                ptl.y = rcl.yBottom+1;
                GpiLine (hps, &ptl);

                WinEndPaint (hps);
            }
            break;

/*        case WM_CONTROLPOINTER:
            DosBeep (1000, 1);
            return MRESULT (TRUE);

        case WM_MOUSEMOVE:
            DosBeep (1000, 1);
            return MRESULT (TRUE);*/

        case WM_COMMAND:
            if (ptb)
                WinSendMsg (ptb->hwndFrame, msg, mp1, mp2);
            else
                DosBeep (1000, 10);
            return MRESULT (FALSE);
        }

    return WinDefWindowProc (hwnd, msg, mp1, mp2);
}
コード例 #16
0
BOOL NextBarDlg::OCommand(ULONG msg, MPARAM mp1, MPARAM mp2)
{
 switch(msg) {
    case WM_INITDLG:
       centerDlg();
       Title.inherit(hwnd);
       Program.inherit(hwnd);
       Path.inherit(hwnd);
       Parms.inherit(hwnd);
       Icon.inherit(hwnd);
       Settings.inherit(hwnd);
       Settings.setFont("8.Helv");
       setProgram2Dialog();
       if (actualButton)
         WinSendMsg(WinWindowFromID(hwnd, NHX_ICONFIELD), SM_SETHANDLE, 
                    MPFROMP(actualButton->pIco->hptr), NULL);
       break;

    case WM_CONTROL:
       handleButtons(mp1);
       break; 

    case DM_DRAGOVER:
     {
      PDRAGINFO  pdinfo = (PDRAGINFO) mp1;
      PDRAGITEM  pditem = NULL;

      DrgAccessDraginfo(pdinfo);
      pditem = DrgQueryDragitemPtr(pdinfo, 0);
      if (DrgVerifyRMF(pditem, "DRM_OS2FILE", NULL))
       {
        DrgFreeDraginfo (pdinfo) ;
        return(TRUE);
       }
      else
       {
        DrgFreeDraginfo (pdinfo) ;
        return(FALSE);
       }
     }

   case DM_DROP: {
     PDRAGINFO       pDragInfo;              /* Pointer to DRAGINFO structure */
     PDRAGITEM       pDragItem;              /* Pointer to DRAGITEM structure */
     CHAR            Buffer[CCHMAXPATH];
     CHAR            ObjectType[CCHMAXPATH];
     PSZ             pszBuffer;
     OString         tmpBuf; 

     pDragInfo = (PDRAGINFO)mp1;
     if(DrgAccessDraginfo(pDragInfo)==FALSE) break;
     pDragItem = DrgQueryDragitemPtr(pDragInfo, 0);
     DrgQueryStrName(pDragItem->hstrRMF, sizeof(ObjectType), ObjectType);
     if(!strstr(ObjectType, "<DRM_OBJECT, DRF_OBJECT>"))
      { // this is not a WPS object
       DrgQueryStrName(pDragItem->hstrContainerName, sizeof(Buffer), Buffer);
       pszBuffer = ((PSZ) Buffer)+strlen(Buffer);
       DrgQueryStrName(pDragItem->hstrSourceName, sizeof(Buffer)-strlen(pszBuffer), pszBuffer);
       tmpBuf << Buffer;
       strupr(tmpBuf);
       if (strstr(tmpBuf, ".ICO")) {
          hps = WinGetPS(WinWindowFromID(hwnd, NHX_ICONFIELD));
          GpiCreateLogColorTable(hps, LCOL_RESET, LCOLF_RGB, 0L, 0L, NULL);
          WinQueryWindowRect(WinWindowFromID(hwnd, NHX_ICONFIELD), &rcl);
          GpiSetColor(hps, SYSCLR_DIALOGBACKGROUND);
          GpiBox(hps, DRO_FILL, (PPOINTL) &rcl.xRight, 0L, 0L);
          WinReleasePS(hps);
          if (actualButton->pIco) 
            delete actualButton->pIco;
          try {
            actualButton->pIco = new OIcon(Buffer); }
          catch(...) {
            delete actualButton->pIco;
            actualButton->pIco = new OIcon(); }
          WinSendMsg(WinWindowFromID(hwnd, NHX_ICONFIELD), SM_SETHANDLE, 
                     MPFROMP(actualButton->pIco->hptr), NULL);
          WinSetDlgItemText(hwnd, NHX_ICON, Buffer); }
       else if ((!strstr(tmpBuf, ".EXE")) &&  (!strstr(tmpBuf, ".COM")) &&
                (!strstr(tmpBuf, ".BAT")) &&  (!strstr(tmpBuf, ".CMD")))
          install2Dialog(Buffer, TRUE);
       else
          install2Dialog(Buffer, FALSE);
      }
     else {
       DrgQueryStrName(pDragItem->hstrSourceName, sizeof(Buffer), Buffer);
       install2Dialog(Buffer, TRUE); }
    break; }

    case WM_COMMAND:
      switch(SHORT1FROMMP(mp1)) 
       {
        case NHX_SAVE:
          setDialog2Program();
          if (isCreation)
             WinPostMsg(nxh->toolbar->hwnd, WM_TOOLBAR_RESET, NULL, NULL);
          else
             WinPostMsg(nxh->toolbar->hwnd, WM_SAVE_BUTTONS, NULL, NULL);
          event = NULL;
          WinPostMsg(hwnd, WM_CLOSE, NULL, NULL);
          break;

        case NHX_CANCEL:
          WinSendMsg(hwnd, WM_CLOSE, NULL, NULL);
          break;

        case NHX_LOAD:
          loadProgram();
          break;
       }
      break;

    case WM_HELP:
       nxh->toolbar->helpRequest(PANEL_CFGS);
       break;

    case WM_CLOSE:
       WinSendMsg(WinWindowFromID(hwnd, NHX_ICONFIELD), SM_SETHANDLE,
                  MPFROMP(NULLHANDLE), NULL);
       if (isCreation)
         WinPostMsg(nxh->toolbar->hwnd, WM_CFG_CANCELED, MPFROMP(event), NULL);
       delete this;
       break;

    default:
       return(FALSE); }
 return(TRUE);
#ifdef __BORLANDC__
  #pragma warn -par
#endif
}
コード例 #17
0
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static DATETIME   dtPrevious ;
     static HDC        hdc ;
     static LONG       xPixelsPerMeter, yPixelsPerMeter ;
     static POINTL     aptlHour   [5] = { 0,-15, 10,0, 0,60, -10,0, 0,-15 },
                       aptlMinute [5] = { 0,-20,  5,0, 0,80,  -5,0, 0,-20 },
                       aptlSecond [2] = { 0,  0,  0,80 } ;
     static WINDOWINFO wi ;
     DATETIME          dt ;
     HPS               hps ;
     INT               iDiamMM, iAngle ;
     POINTL            aptl [3] ;

     switch (msg)
          {
          case WM_CREATE:
               hdc = WinOpenWindowDC (hwnd) ;

               DevQueryCaps (hdc, CAPS_VERTICAL_RESOLUTION,
                                  1L, &yPixelsPerMeter) ;
               DevQueryCaps (hdc, CAPS_HORIZONTAL_RESOLUTION,
                                  1L, &xPixelsPerMeter) ;

               DosGetDateTime (&dtPrevious) ;
               dtPrevious.hours = (dtPrevious.hours * 5) % 60 +
                                   dtPrevious.minutes / 12 ;
               return 0 ;

          case WM_SIZE:
               wi.cxClient = SHORT1FROMMP (mp2) ;
               wi.cyClient = SHORT2FROMMP (mp2) ;

               iDiamMM = min (wi.cxClient * 1000L / xPixelsPerMeter,
                              wi.cyClient * 1000L / yPixelsPerMeter) ;

               wi.cxPixelDiam = xPixelsPerMeter * iDiamMM / 1000 ;
               wi.cyPixelDiam = yPixelsPerMeter * iDiamMM / 1000 ;
               return 0 ;

          case WM_TIMER:
               DosGetDateTime (&dt) ;
               dt.hours = (dt.hours * 5) % 60 + dt.minutes / 12 ;

               hps = WinGetPS (hwnd) ;
               GpiSetColor (hps, CLR_BACKGROUND) ;

               DrawHand (hps, aptlSecond, 2, dtPrevious.seconds, &wi) ;

               if (dt.hours   != dtPrevious.hours ||
                   dt.minutes != dtPrevious.minutes)
                    {
                    DrawHand (hps, aptlHour,   5, dtPrevious.hours,   &wi) ;
                    DrawHand (hps, aptlMinute, 5, dtPrevious.minutes, &wi) ;
                    }

               GpiSetColor (hps, CLR_NEUTRAL) ;

               DrawHand (hps, aptlHour,   5, dt.hours,   &wi) ;
               DrawHand (hps, aptlMinute, 5, dt.minutes, &wi) ;
               DrawHand (hps, aptlSecond, 2, dt.seconds, &wi) ;

               WinReleasePS (hps) ;
               dtPrevious = dt ;
               return 0 ;

          case WM_PAINT:
               hps = WinBeginPaint (hwnd, NULLHANDLE, NULL) ;
               GpiErase (hps) ;

               for (iAngle = 0 ; iAngle < 60 ; iAngle++)
                    {
                    aptl[0].x = 0 ;
                    aptl[0].y = 90 ;

                    RotatePoint    (aptl, 1, iAngle) ;
                    ScalePoint     (aptl, 1, &wi) ;
                    TranslatePoint (aptl, 1, &wi) ;

                    aptl[2].x = aptl[2].y = iAngle % 5 ? 2 : 10 ;

                    ScalePoint (aptl + 2, 1, &wi) ;

                    aptl[0].x -= aptl[2].x / 2 ;
                    aptl[0].y -= aptl[2].y / 2 ;

                    aptl[1].x = aptl[0].x + aptl[2].x ;
                    aptl[1].y = aptl[0].y + aptl[2].y ;

                    GpiMove (hps, aptl) ;
                    GpiBox (hps, DRO_OUTLINEFILL, aptl + 1,
                                 aptl[2].x, aptl[2].y) ;
                    }
               DrawHand (hps, aptlHour,   5, dtPrevious.hours,   &wi) ;
               DrawHand (hps, aptlMinute, 5, dtPrevious.minutes, &wi) ;
               DrawHand (hps, aptlSecond, 2, dtPrevious.seconds, &wi) ;

               WinEndPaint (hps) ;
               return 0 ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }
コード例 #18
0
/*      QWL_USER+8 - reserved for text                        */
MRESULT EXPENTRY TestWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
  PMYCDATA pCData = (PMYCDATA)WinQueryWindowULong(hwnd, QWL_USER+4);
  PSZ pszText = (PSZ)WinQueryWindowULong(hwnd, QWL_USER+8);
  PMYCDATA pCreate;
  PCREATESTRUCT pCreateStruct;

  switch (msg) {
  /* we are creating our control */
  case WM_CREATE:
     /* if data was passed in */
     if (pCreate=(PMYCDATA)PVOIDFROMMP(mp1)) {
        /* allocate memory for the control data */
        DosAllocMem((PPVOID) &pCData,
                           (ULONG) pCreate->cb,
                           PAG_COMMIT|PAG_READ | PAG_WRITE);

        /* copy the data that is passed in */
        memcpy((PBYTE)pCData, (PBYTE) pCreate, pCreate->cb);

        /* save the control data pointer */
        WinSetWindowULong(hwnd, QWL_USER+4, (ULONG)pCData);
     } /* endif */
     /* allocate memory for the text */
     DosAllocMem((PPVOID) &pszText,
                        (ULONG) MAXTEXTLENGTH+1,
                        PAG_COMMIT|PAG_READ | PAG_WRITE);
     /* save the text pointer */
     WinSetWindowULong(hwnd, QWL_USER+8, (ULONG)pszText);
     /* initialize to a NULL string */
     strcpy(pszText,"");
     pCreateStruct=(PCREATESTRUCT)mp2;
     if (pCreateStruct) {
        /* copy the text into the buffer provided */
        strncpy(pszText, pCreateStruct->pszText,  MAXTEXTLENGTH);

        /* NULL terminate the string */
        pszText[MAXTEXTLENGTH]=0;
     }
     break;
  case WM_QUERYWINDOWPARAMS:
     {
        PWNDPARAMS pWndParams = (PWNDPARAMS)PVOIDFROMMP(mp1);
        MRESULT mr;

        /* call the default window proc first so that presentation
        /* parameters are handled */

        mr = WinDefWindowProc( hwnd, msg, mp1, mp2 );
        if (pWndParams) {
           if (pCData) {
              if (pWndParams->fsStatus & WPM_CBCTLDATA) {
                 pWndParams->cbCtlData = pCData->cb;
                 mr=(MRESULT)TRUE;
              } /* endif */
              if (pWndParams->fsStatus & WPM_CTLDATA) {
                 pWndParams->cbCtlData = pCData->cb;
                 memcpy((PBYTE)pWndParams->pCtlData, (PBYTE)pCData,  pCData->cb);
                 mr=(MRESULT)TRUE;
              } /* endif */
           } /* endif */

           /* responding to WinQueryWindowTextLength */
           if (pWndParams->fsStatus & WPM_CCHTEXT) {
              pWndParams->cchText = strlen(pszText);
              mr=(MRESULT)TRUE;
           } /* endif */

           /* responding to WinQueryWindowText */
           if (pWndParams->fsStatus & WPM_TEXT) {

              /* copy the text into the buffer provided */
              strncpy(pWndParams->pszText, pszText,  pWndParams->cchText);

              /* NULL terminate the string */
              pWndParams->pszText[pWndParams->cchText]=0;
              mr=(MRESULT)TRUE;
           } /* endif */
        } /* endif */
        return mr;
     }
     break;
  case WM_SETWINDOWPARAMS:
     {
        PWNDPARAMS pWndParams = (PWNDPARAMS)PVOIDFROMMP(mp1);
        MRESULT mr;

        mr = WinDefWindowProc( hwnd, msg, mp1, mp2 );
        if (pWndParams) {
           if (pWndParams->fsStatus & WPM_CTLDATA) {
              if (pCData) {
                 DosFreeMem(pCData);
              } /* endif */
              DosAllocMem((PPVOID) &(pCData),
                                 (ULONG) pWndParams->cbCtlData,
                                 PAG_COMMIT|PAG_READ | PAG_WRITE);
              WinSetWindowULong(hwnd, QWL_USER+4, (ULONG)pCData);
              memcpy((PBYTE)pCData, (PBYTE)pWndParams->pCtlData,  pWndParams->cbCtlData);
              WinInvalidateRect(hwnd, 0, 0);
              mr=(MRESULT)TRUE;
           } /* endif */

           /* responding to WinQueryWindowText */
           if (pWndParams->fsStatus & WPM_TEXT) {

              /* copy the text into the buffer provided */
              strncpy(pszText, pWndParams->pszText,  MAXTEXTLENGTH);

              /* NULL terminate the string */
              pszText[MAXTEXTLENGTH]=0;
              WinInvalidateRect(hwnd, 0, 0);
              mr=(MRESULT)TRUE;
           } /* endif */
        } /* endif */
        return mr;
     }
     break;
  case WM_PAINT:
     {
        HPS hps;
        RECTL rectlPaint;
        ULONG lTextColor, lBackColor;
        ULONG ulPPIndex;
        SWP swp;
        POINTL ptlPoint;

        WinQueryWindowPos(hwnd,&swp);
        hps=WinBeginPaint(hwnd, 0, &rectlPaint);

        /* put PS into RGB color mode */
        GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, 0 );

        if (!WinQueryPresParam(hwnd,PP_BACKGROUNDCOLOR,0,&ulPPIndex,
              sizeof(LONG),&lBackColor,QPF_NOINHERIT)) {
           lBackColor=WinQuerySysColor(HWND_DESKTOP,SYSCLR_WINDOW, 0);
        } /* endif */

        if (!WinQueryPresParam(hwnd,PP_FOREGROUNDCOLOR,0,&ulPPIndex,
              sizeof(LONG),&lTextColor,QPF_NOINHERIT)) {
           lTextColor=WinQuerySysColor(HWND_DESKTOP,SYSCLR_ICONTEXT, 0);
        } /* endif */

        WinFillRect(hps, &rectlPaint, lBackColor);
        ptlPoint.x=0;
        ptlPoint.y=0;
        GpiMove(hps,&ptlPoint);
        ptlPoint.x=swp.cx-1;
        ptlPoint.y=swp.cy-1;
        GpiBox(hps,DRO_OUTLINE,&ptlPoint,0,0);


        /* draw your control and its text here */
        ptlPoint.x=0;
        ptlPoint.y=0;
        GpiSetCharAngle(hps,&pCData->gradient);
        GpiSetCharMode(hps,CM_MODE3);
        GpiSetColor(hps,lTextColor);
        GpiSetDrawControl(hps,DCTL_DISPLAY,DCTL_OFF);
        GpiSetDrawControl(hps,DCTL_BOUNDARY,DCTL_ON);
        GpiCharStringAt(hps, &ptlPoint,strlen(pszText),pszText);
        GpiQueryBoundaryData(hps,&rectlPaint);
        GpiSetDrawControl(hps,DCTL_DISPLAY,DCTL_ON);
        GpiSetDrawControl(hps,DCTL_BOUNDARY,DCTL_OFF);
        ptlPoint.x=-rectlPaint.xLeft;
        ptlPoint.y=-rectlPaint.yBottom;
        GpiCharStringAt(hps, &ptlPoint,strlen(pszText),pszText);

        WinEndPaint(hps);
     }
     break;
  case WM_DESTROY:
     if (pCData)
        DosFreeMem(pCData);
     if (pszText)
        DosFreeMem(pszText);
     break;
  case WM_PRESPARAMCHANGED:
     WinInvalidateRect(hwnd,0,FALSE);
     break;
  default:
     return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  } /* endswitch */
  return (MRESULT) FALSE;
}
コード例 #19
0
bool PaintButton( VRIconButton *somSelf, PUSERBUTTON pbtn )
{
    FONTMETRICS fm;
    HAB    hab;
    RECTL  rcl,
           rclTxt,
           rclImg;
    POINTL ptl,
           aptl[ TXTBOX_COUNT ];
    LONG   lFlags,
           flPic,
           flTxt,
           lStrW,
           lStrH,
           lOffset,
           lClr;
    ULONG  cb;
    BOOL   fPosition;

//FILE *f = fopen("c:\\iconbtn.log", "a");

    VRIconButtonData *somThis = VRIconButtonGetData(somSelf);
    lFlags = _vrGetWindowFlags( somSelf );

//fprintf(f, "----[ Entering PaintButton ] ----\n");

    if ( !pbtn || ( ! WinQueryWindowRect( pbtn->hwnd, &rcl )))
        return FALSE;

    // Get the current background colour
    cb = WinQueryPresParam( pbtn->hwnd, PP_BACKGROUNDCOLOR,
                            PP_BACKGROUNDCOLORINDEX, NULL,
                            sizeof( lClr ), &lClr, QPF_ID2COLORINDEX );
    if ( cb )
        GpiCreateLogColorTable( pbtn->hps, 0, LCOLF_RGB, 0, 0, NULL );
    else
        lClr = GpiQueryRGBColor( pbtn->hps, 0, SYSCLR_BUTTONMIDDLE );

    // Fill in the button background
    WinFillRect( pbtn->hps, &rcl, lClr );

    ptl.x = rcl.xLeft;
    ptl.y = rcl.yBottom;
    GpiMove( pbtn->hps, &ptl );
    ptl.x = rcl.xRight - 1;
    ptl.y = rcl.yTop - 1;
    // Draw the "default" state outline if applicable
    if ( pbtn->fsState & BDS_DEFAULT ) {
        GpiSetColor( pbtn->hps, SYSCLR_BUTTONDEFAULT );
        GpiBox( pbtn->hps, DRO_OUTLINE, &ptl, 0, 0 );
    }
    else {
        cb = WinQueryPresParam( WinQueryWindow( pbtn->hwnd, QW_PARENT ),
                                PP_BACKGROUNDCOLOR, PP_BACKGROUNDCOLORINDEX,
                                NULL, sizeof( lClr ), &lClr, QPF_ID2COLORINDEX );
        if ( cb )
            GpiSetColor( pbtn->hps, lClr );
        else
            GpiSetColor( pbtn->hps, SYSCLR_DIALOGBACKGROUND );
        GpiBox( pbtn->hps, DRO_OUTLINE, &ptl, 0, 0 );
    }

    if ( !( lFlags & BS_NOBORDER )) {
        /* Draw the button border (if appropriate) depending on the current
         * state(s).
         */
        GpiSetColor( pbtn->hps, ( _fDown || ( pbtn->fsState & BDS_HILITED )) ?
                                CLR_BLACK: SYSCLR_BUTTONDARK );
        ptl.x = rcl.xLeft + 1;
        ptl.y = rcl.yBottom + 2;
        GpiMove( pbtn->hps, &ptl );
        ptl.y = rcl.yTop - 2;
        GpiLine( pbtn->hps, &ptl );
        GpiMove( pbtn->hps, &ptl );
        ptl.x = rcl.xRight - 2;
        GpiLine( pbtn->hps, &ptl );
        GpiSetColor( pbtn->hps, ( _fDown || ( pbtn->fsState & BDS_HILITED )) ?
                                SYSCLR_BUTTONDARK: CLR_BLACK );
        ptl.x = rcl.xLeft + 1;
        ptl.y = rcl.yBottom + 1;
        GpiMove( pbtn->hps, &ptl );
        ptl.x = rcl.xRight - 2;
        GpiLine( pbtn->hps, &ptl );
        GpiMove( pbtn->hps, &ptl );
        ptl.y = rcl.yTop - 3;
        GpiLine( pbtn->hps, &ptl );

        GpiSetColor( pbtn->hps, ( _fDown || ( pbtn->fsState & BDS_HILITED )) ?
                                SYSCLR_BUTTONLIGHT: SYSCLR_BUTTONDARK );
        ptl.x = rcl.xLeft + 2;
        ptl.y = rcl.yBottom + 2;
        GpiMove( pbtn->hps, &ptl );
        ptl.x = rcl.xRight - 3;
        GpiLine( pbtn->hps, &ptl );
        GpiMove( pbtn->hps, &ptl );
        ptl.y = rcl.yTop - 3;
        GpiLine( pbtn->hps, &ptl );
        GpiSetColor( pbtn->hps, ( _fDown || ( pbtn->fsState & BDS_HILITED )) ?
                                SYSCLR_BUTTONDARK: SYSCLR_BUTTONLIGHT );
        ptl.x = rcl.xLeft + 2;
        ptl.y = rcl.yBottom + 3;
        GpiMove( pbtn->hps, &ptl );
        ptl.y = rcl.yTop - 3;
        GpiLine( pbtn->hps, &ptl );
        GpiMove( pbtn->hps, &ptl );
        ptl.x = rcl.xRight - 3;
        GpiLine( pbtn->hps, &ptl );

        if ( pbtn->fsState & BDS_HILITED ) {
            GpiSetColor( pbtn->hps, SYSCLR_BUTTONLIGHT );
            ptl.x = rcl.xLeft + 3;
            ptl.y = rcl.yBottom + 3;
            GpiMove( pbtn->hps, &ptl );
            ptl.x = rcl.xRight - 4;
            GpiLine( pbtn->hps, &ptl );
            GpiMove( pbtn->hps, &ptl );
            ptl.y = rcl.yTop - 4;
            GpiLine( pbtn->hps, &ptl );
            GpiSetColor( pbtn->hps, SYSCLR_BUTTONDARK );
            ptl.x = rcl.xLeft + 3;
            ptl.y = rcl.yBottom + 4;
            GpiMove( pbtn->hps, &ptl );
            ptl.y = rcl.yTop - 4;
            GpiLine( pbtn->hps, &ptl );
            GpiMove( pbtn->hps, &ptl );
            ptl.x = rcl.xRight - 4;
            GpiLine( pbtn->hps, &ptl );
        }

    } // if ( !( lFlags & BS_NOBORDER ))

    /* After this point, rcl is used for the clipping boundaries of the entire
     * button contents exclusive of the border.  Separate bounding rectangles
     * for the image and the text will now be calculated within this area.
     */
    if ( rcl.xRight > 6 ) {
        rcl.xLeft += 3;
        rcl.xRight -= 3;
    }
    if ( rcl.yTop > 6 ) {
        rcl.yBottom += 3;
        rcl.yTop -= 3;
    }
    memcpy( &rclTxt, &rcl, sizeof( RECTL ));
    if ( RECTL_WIDTH( rclTxt ) > 4 ) {
        rclTxt.xLeft += 2;
        rclTxt.xRight -= 2;
    }
    if ( RECTL_WIDTH( rclTxt ) > 4 ) {
        rclTxt.yBottom += 2;
        rclTxt.yTop -= 2;
    }
    if ( _pPic && ( _pPic->type & MEMP_BITMAP ) && _fResize )
        memcpy( &rclImg, &rcl, sizeof( RECTL ));
    else {
        rclImg.xLeft   = ( RECTL_WIDTH( rclTxt ) > 6 )  ?
                         rclTxt.xLeft + 3   : rclTxt.xLeft;
        rclImg.xRight  = ( RECTL_WIDTH( rclTxt ) > 6 )  ?
                         rclTxt.xRight - 3  : rclTxt.xRight;
        rclImg.yBottom = ( RECTL_HEIGHT( rclTxt ) > 6 ) ?
                         rclTxt.yBottom + 3 : rclTxt.yBottom;
        rclImg.yTop    = ( RECTL_HEIGHT( rclTxt ) > 6 ) ?
                         rclTxt.yTop - 3    : rclTxt.yTop;
    }

//fprintf(f, "rcl     = {%d %d %d %d}, width = %d, height= %d\n", rcl.xLeft, rcl.yBottom, rcl.xRight, rcl.yTop, RECTL_WIDTH(rcl), RECTL_HEIGHT(rcl) );
//fprintf(f, "rclImg  = {%d %d %d %d}, width = %d, height= %d\n", rclImg.xLeft, rclImg.yBottom, rclImg.xRight, rclImg.yTop, RECTL_WIDTH(rclImg), RECTL_HEIGHT(rclImg) );

    fPosition = _pPic && ( !_fResize || _pPic->type & MEMP_ICON ) &&
                (( _bAlign == ALIGN_LEFT ) || ( _bAlign == ALIGN_RIGHT )) ?
                TRUE : FALSE;

    /* We won't draw the text until after the image... but unless we're scaling
     * the image into the whole button, we need to calculate how much space the
     * text is going to require so we can fit the image next to it.  (Note that
     * we behave differently for top/bottom alignment vs left/right alignment -
     * with top/bottom, the text area is fixed to the height of the string plus
     * a certain margin.  With left/right alignment, the image rectangle is set
     * to the physical image size, and the text rectangle is offset from that.)
     */
    lStrW = 0;
    lStrH = 0;
    GpiQueryFontMetrics( pbtn->hps, sizeof( FONTMETRICS ), &fm );
    if ( _pszText && *_pszText ) {

        // Get the width of the text as it would be rendered in the current font
        GpiQueryTextBox( pbtn->hps, strlen( _pszText ),
                         _pszText, TXTBOX_COUNT, aptl );

        lStrW = aptl[TXTBOX_TOPRIGHT].x - aptl[TXTBOX_TOPLEFT].x;
        lStrW += ( 2 * fm.lAveCharWidth );
        lStrH = fm.lMaxBaselineExt + fm.lInternalLeading + fm.lMaxDescender;

        // Adjust the bounding rectangles for the text and image
        switch ( _bAlign ) {
            case ALIGN_TOP:
                rclTxt.yBottom = rclTxt.yTop - lStrH;
                if ( _pPic && ( !_fResize || _pPic->type & MEMP_ICON )) {
                    if (( rclTxt.yBottom - rclImg.yBottom ) > _pPic->height )
                        rclImg.yTop = rclTxt.yBottom - 1;
                    else if (( rcl.yTop - rclImg.yBottom ) > _pPic->height )
                        rclImg.yTop = rcl.yBottom + _pPic->height;
                }
                break;
            case ALIGN_BOTTOM:
                rclTxt.yTop = rclTxt.yBottom + lStrH;
                if ( _pPic && ( !_fResize || _pPic->type & MEMP_ICON )) {
                    if ((( rclImg.yTop - rclTxt.yTop ) > _pPic->height ))
                        rclImg.yBottom = rclTxt.yTop + 1;
                    else if (( rclImg.yTop - rcl.yBottom ) > _pPic->height )
                        rclImg.yBottom = (LONG) ( rcl.yTop - _pPic->height );
                }
                break;
            case ALIGN_LEFT:
                if ( fPosition ) {
                    if (( rclTxt.xLeft + lStrW + _pPic->width ) < rclImg.xRight ) {
                        rclImg.xLeft = rclImg.xRight - _pPic->width;
                        rclTxt.xRight = rclImg.xLeft - 1;
                    }
                    else  {
                        rclTxt.xRight = rclTxt.xLeft + lStrW;
                        if (( rclImg.xRight - _pPic->width ) < RECTL_WIDTH( rcl ))
                            rclImg.xLeft = (LONG) ( rclImg.xRight - _pPic->width );
                    }
                }
                else
                    rclTxt.xRight = rclTxt.xLeft + lStrW;
                break;
            case ALIGN_RIGHT:
                if ( fPosition ) {
                    if (( rclImg.xLeft + _pPic->width + lStrW ) < rclImg.xRight ) {
                        rclImg.xRight = rclImg.xLeft + _pPic->width;
                        rclTxt.xLeft = rclImg.xRight + 1;
                    }
                    else {
                        rclTxt.xLeft = rclTxt.xRight - lStrW;
                        if (( rclImg.xLeft + _pPic->width ) < RECTL_WIDTH( rcl ))
                            rclImg.xRight = rclImg.xLeft + _pPic->width;
                    }
                }
                else
                    rclTxt.xLeft = rclTxt.xRight - lStrW;
                break;
            default: break;   // ALIGN_CENTER, no adjustment needed
        }
        if ( rclTxt.yBottom < rcl.yBottom ) rclTxt.yBottom = rcl.yBottom;
        if ( rclTxt.yTop > rcl.yTop ) rclTxt.yTop = rcl.yTop;
        if ( rclTxt.xLeft < rcl.xLeft ) rclTxt.xLeft = rcl.xLeft;
        if ( rclTxt.xRight > rcl.xRight ) rclTxt.xRight = rcl.xRight;
    }

    // Draw the image, if one is defined
    if ( _pPic ) {

        if (( pbtn->fsState & BDS_HILITED ) &&
            !( _fResize && ( _pPic->type & MEMP_BITMAP )))
        {
            rclImg.xLeft++;
            rclImg.xRight++;
            rclImg.yBottom--;
            rclImg.yTop--;
        }

        flPic = PICTDRAW_CENTER_ICON;
        if ( pbtn->fsState & BDS_DISABLED ) flPic |= PICTDRAW_DISABLE;
        if ( _pPic->type & MEMP_BITMAP ) {
            if ( _fResize )
                flPic |= PICTDRAW_STRETCH_BITMAP;
            else {
                ptl.x = ((LONG)( RECTL_WIDTH( rclImg ) - _pPic->width ) / 2 );
                ptl.y = ((LONG)( RECTL_HEIGHT( rclImg ) - _pPic->height ) / 2 );
                if ( ptl.x > 0 ) rclImg.xLeft += ptl.x;
                if ( ptl.y > 0 ) rclImg.yBottom += ptl.y;
            }
        }

        VRPictDisplay( pbtn->hwnd, pbtn->hps, _pPic, &rclImg, flPic );
    }

    // Now draw the text, if any
    if ( _pszText && *_pszText ) {

        // Get the current foreground colour
        if ( pbtn->fsState & BDS_DISABLED )
            lClr = GpiQueryRGBColor( pbtn->hps, 0, SYSCLR_MENUDISABLEDTEXT );
        else {
            cb = WinQueryPresParam( pbtn->hwnd, PP_FOREGROUNDCOLOR,
                                    PP_FOREGROUNDCOLORINDEX, NULL,
                                    sizeof( lClr ), &lClr, QPF_ID2COLORINDEX );
            if ( !cb )
                lClr = GpiQueryRGBColor( pbtn->hps, 0, SYSCLR_WINDOWTEXT );
        }
        GpiSetColor( pbtn->hps, lClr );

        // Now position and draw the button text
        switch ( _bAlign ) {

            case ALIGN_TOP:
#ifdef GPI_DRAWTEXT
                ptl.x = rclTxt.xLeft + ( RECTL_WIDTH( rclTxt ) / 2 );
                ptl.y = ( RECTL_HEIGHT( rclTxt ) < lStrH ) ? rclTxt.yTop :
                        rclTxt.yTop - ( 2 * fm.lInternalLeading );
                GpiSetTextAlignment( pbtn->hps, TA_CENTER, TA_TOP );
#else
                flTxt = DT_CENTER | (( RECTL_HEIGHT( rclTxt ) < lStrH )
                                    ? DT_TOP : DT_VCENTER ) |
                        DT_TEXTATTRS | DT_MNEMONIC;
#endif
                break;

            case ALIGN_BOTTOM:
#ifdef GPI_DRAWTEXT
                ptl.x = rclTxt.xLeft + ( RECTL_WIDTH( rclTxt ) / 2 );
                ptl.y = ( RECTL_HEIGHT( rclTxt ) < lStrH ) ? rclTxt.yBottom :
                        rclTxt.yBottom + ( 2 * fm.lInternalLeading );
                GpiSetTextAlignment( pbtn->hps, TA_CENTER, TA_BOTTOM );
#else
                flTxt = DT_CENTER | (( RECTL_HEIGHT( rclTxt ) < lStrH ) ?
                                    DT_BOTTOM : DT_VCENTER ) |
                        DT_TEXTATTRS | DT_MNEMONIC;
#endif
                break;

            case ALIGN_LEFT:
#ifdef GPI_DRAWTEXT
                ptl.x = rclTxt.xLeft + fm.lAveCharWidth;
                ptl.y = rclTxt.yBottom + (( RECTL_HEIGHT( rclTxt ) - fm.lXHeight ) / 2 );
                GpiSetTextAlignment( pbtn->hps, TA_NORMAL_HORIZ, TA_BASE );
#else
                flTxt = DT_LEFT | DT_VCENTER | DT_TEXTATTRS | DT_MNEMONIC;
                rclTxt.xLeft += fm.lAveCharWidth;
#endif
                break;

            case ALIGN_RIGHT:
#ifdef GPI_DRAWTEXT
                ptl.x = rclTxt.xLeft + fm.lAveCharWidth;
                ptl.y = rclTxt.yBottom + (( RECTL_HEIGHT( rclTxt ) - fm.lXHeight ) / 2 );
                GpiSetTextAlignment( pbtn->hps, TA_NORMAL_HORIZ, TA_BASE );
#else
                flTxt = (fPosition? DT_LEFT: DT_RIGHT) | DT_VCENTER | DT_TEXTATTRS | DT_MNEMONIC;
                if ( RECTL_WIDTH( rclTxt ) > fm.lAveCharWidth ) {
                    if ( fPosition )
                        rclTxt.xLeft += fm.lAveCharWidth;
                    else
                        rclTxt.xRight -= fm.lAveCharWidth;
                }
#endif
                break;

            default:    // ALIGN_CENTER
#ifdef GPI_DRAWTEXT
                ptl.x = rclTxt.xLeft + ( RECTL_WIDTH( rclTxt ) / 2 );
                ptl.y = rclTxt.yBottom + (( RECTL_HEIGHT( rclTxt ) - fm.lXHeight ) / 2 );
                GpiSetTextAlignment( pbtn->hps, TA_CENTER, TA_BASE );
#else
                flTxt = DT_CENTER | DT_VCENTER | DT_TEXTATTRS | DT_MNEMONIC;
#endif
                break;
        }
        if ( pbtn->fsState & BDS_HILITED ) {
            ptl.x++;
            ptl.y--;
        }
        cb = strlen( _pszText );
#ifdef GPI_DRAWTEXT
        GpiCharStringPosAt( pbtn->hps, &ptl, &rclTxt, CHS_CLIP, cb, _pszText, NULL );
#else
        WinDrawText( pbtn->hps, cb, _pszText, &rclTxt, 0, 0, flTxt );
#endif
    }

//fprintf(f, "----[ Leaving PaintButton ] ----\n\n");
//fclose(f);

    return TRUE;
}
コード例 #20
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;
}
コード例 #21
0
MRESULT EXPENTRY AboutDlgProc (HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    BOOL    bHandled = TRUE;
    MRESULT mReturn  = 0;
    ULONG   ulScrWidth, ulScrHeight;
    RECTL   Rectl;
    SWP     Swp;
    HPS     hps;

    switch (msg)
    {           
        case WM_INITDLG:
            /* Center dialog on screen */
            ulScrWidth  = WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN);
            ulScrHeight = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN);
            WinQueryWindowRect (hWnd, &Rectl);
            WinSetWindowPos (hWnd, HWND_TOP, (ulScrWidth-Rectl.xRight)/2,
                (ulScrHeight-Rectl.yTop)/2, 0, 0, SWP_MOVE | SWP_ACTIVATE);

            /* Set application title */
            WinSetDlgItemText (hWnd, 10001, (PSZ)mp2);
            break;

        case WM_PAINT:
            hps = WinBeginPaint (hWnd,0,0);
            WinQueryWindowRect (hWnd, &Rectl);
            WinFillRect (hps, &Rectl, CLR_PALEGRAY);
            WinDrawBorder (hps, &Rectl, 
                WinQuerySysValue(HWND_DESKTOP,SV_CXDLGFRAME), 
                WinQuerySysValue(HWND_DESKTOP,SV_CYDLGFRAME), 
                CLR_DARKGRAY, CLR_WHITE, DB_RAISED);
            GpiMove (hps, (PPOINTL)&Rectl);
            Rectl.xRight--;
            Rectl.yTop--;
            GpiBox (hps, DRO_OUTLINE, (PPOINTL)&Rectl.xRight, 0L, 0L);
            WinQueryWindowPos (WinWindowFromID (hWnd, 10002), &Swp);
            Rectl.xLeft   = Swp.x-1;
            Rectl.yBottom = Swp.y-1;
            Rectl.xRight  = Swp.x + Swp.cx + 1;
            Rectl.yTop    = Swp.y + Swp.cy + 1;
            WinDrawBorder (hps, &Rectl, 1L, 1L,
                CLR_DARKGRAY, CLR_WHITE, DB_DEPRESSED);
            WinQueryWindowPos (WinWindowFromID (hWnd, 10003), &Swp);
            Rectl.xLeft   = Swp.x-1;
            Rectl.yBottom = Swp.y-1;
            Rectl.xRight  = Swp.x + Swp.cx + 1;
            Rectl.yTop    = Swp.y + Swp.cy + 1;
            WinDrawBorder (hps, &Rectl, 1L, 1L,
                CLR_DARKGRAY, CLR_WHITE, DB_DEPRESSED);
            WinEndPaint (hps);
            break;

		  case WM_COMMAND:
            WinDismissDlg (hWnd, DID_OK);
            break;

        default:
            bHandled = FALSE;
            break;
    }

    if (!bHandled)
        mReturn = WinDefDlgProc (hWnd, msg, mp1, mp2);

    return (mReturn);
}