Ignore:
Timestamp:
Jun 23, 2001, 11:12:49 AM (24 years ago)
Author:
umoeller
Message:

Tons of changes from the last weeks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/comctl.c

    r53 r81  
    118118/* ******************************************************************
    119119 *
    120  *   Global variables
     120 *   "XButton" control
    121121 *
    122122 ********************************************************************/
     123
     124/*
     125 *@@ ctlPaintXButton:
     126 *      paints an X-button control. Can be called externally
     127 *      for just painting a button even if this is not really
     128 *      a window.
     129 *
     130 *      WARNING: this is work in progress and will change into
     131 *      the future. Eventually this will turn into a full
     132 *      button control replacement.
     133 *
     134 *@@added V0.9.13 (2001-06-21) [umoeller]
     135 */
     136
     137VOID ctlPaintXButton(HPS hps,               // in: presentation space (RGB mode)
     138                     ULONG fl,              // in: XBF_* flags
     139                     PXBUTTONDATA pxbd)     // in: button data
     140{
     141    ULONG   ulBorder = 0,
     142            cx,
     143            cy,
     144            ulOfs = 0;
     145    LONG    lLeft,
     146            lRight;
     147    RECTL   rclWin;
     148    memcpy(&rclWin, &pxbd->rcl, sizeof(RECTL));
     149
     150    if (0 == (fl & XBF_FLAT))
     151        ulBorder = 2;
     152
     153    gpihSwitchToRGB(hps);
     154
     155    if (fl & XBF_PRESSED)
     156    {
     157        // paint button "down":
     158        lLeft = pxbd->lcol3DDark;
     159        lRight = pxbd->lcol3DLight;
     160        // add offset for icon painting at the bottom
     161        ulOfs += 1;
     162        if (ulBorder == 0)
     163            ulBorder = 1;
     164    }
     165    else
     166    {
     167        lLeft = pxbd->lcol3DLight;
     168        lRight = pxbd->lcol3DDark;
     169    }
     170
     171    if (ulBorder)
     172    {
     173        // button border:
     174
     175        // now paint button frame
     176        rclWin.xRight--;
     177        rclWin.yTop--;
     178        gpihDraw3DFrame(hps,
     179                        &rclWin,        // inclusive
     180                        ulBorder,
     181                        lLeft,
     182                        lRight);
     183
     184        // now paint button middle
     185        rclWin.xLeft += ulBorder;
     186        rclWin.yBottom += ulBorder;
     187        rclWin.xRight -= ulBorder - 1;  // make exclusive again
     188        rclWin.yTop -= ulBorder - 1;    // make exclusive again
     189    }
     190
     191    if (fl & XBF_BACKGROUND)
     192        WinFillRect(hps,
     193                    &rclWin,        // exclusive
     194                    pxbd->lMiddle);
     195
     196    // get icon
     197    if (pxbd->hptr)
     198    {
     199        // calculate x and y to be centered in rectangle
     200        POINTL  ptl;
     201
     202        cx = rclWin.xRight - rclWin.xLeft;
     203        cy = rclWin.yTop - rclWin.yBottom;
     204
     205        ptl.x = rclWin.xLeft + ((cx - pxbd->cxMiniIcon) / 2);
     206        ptl.y = rclWin.yBottom + ((cy - pxbd->cxMiniIcon) / 2);
     207
     208        if (fl & XBF_INUSE)
     209        {
     210            // caller wants in-use (hatched) emphasis:
     211            // draw a box then
     212            POINTL ptl2;
     213            ptl2.x = ptl.x - 2;
     214            ptl2.y = ptl.y - 2;
     215            GpiMove(hps,
     216                    &ptl);
     217            GpiSetPattern(hps, PATSYM_DIAG1);
     218            ptl2.x = ptl.x + pxbd->cxMiniIcon + 1; // inclusive!
     219            ptl2.y = ptl.y + pxbd->cxMiniIcon + 1; // inclusive!
     220            GpiBox(hps,
     221                   DRO_FILL,
     222                   &ptl2,
     223                   0,
     224                   0);
     225        }
     226
     227        // now paint icon
     228        GpiIntersectClipRectangle(hps, &rclWin);    // exclusive!
     229        WinDrawPointer(hps,
     230                       // center this in remaining rectl
     231                       ptl.x + ulOfs,
     232                       ptl.y - ulOfs,
     233                       pxbd->hptr,
     234                       DP_MINI);
     235    }
     236}
    123237
    124238/*
Note: See TracChangeset for help on using the changeset viewer.