Ignore:
Timestamp:
Jun 2, 2002, 10:50:25 PM (23 years ago)
Author:
umoeller
Message:

Fixes for ip widget.

File:
1 edited

Legend:

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

    r167 r168  
    8989#define INCL_WINBUTTONS
    9090#define INCL_WINSTDCNR
     91#define INCL_WINENTRYFIELDS
    9192
    9293#define INCL_GPIPRIMITIVES
     
    14301431}
    14311432
     1433/* ******************************************************************
     1434 *
     1435 *   Color rectangle
     1436 *
     1437 ********************************************************************/
     1438
     1439static PFNWP G_pfnwpOrigStatic = NULL;
     1440
     1441/*
     1442 *@@ ctl_fnwpSubclassedColorRect:
     1443 *      window procedure for subclassed static frames representing
     1444 *      a color.
     1445 *
     1446 *      The control simply paints itself as a rectangle with the
     1447 *      color specified in its PP_BACKGROUNDCOLOR presentation
     1448 *      parameter. If a window text is set for the control, it is
     1449 *      painted with the PP_FOREGROUNDCOLOR color.
     1450 *
     1451 *      If the user drags a color onto the control, it notifies
     1452 *      its owner with the WM_CONTROL message and the EN_CHANGE
     1453 *      notification code, as with any entry field (since the
     1454 *      static control knows no notifications, we use that code
     1455 *      instead).
     1456 *
     1457 *@@added V0.9.16 (2002-01-05) [umoeller]
     1458 *@@changed V0.9.19 (2002-06-02) [umoeller]: moved this here from w_pulse.c
     1459 */
     1460
     1461static MRESULT EXPENTRY ctl_fnwpSubclassedColorRect(HWND hwndStatic, ULONG msg, MPARAM mp1, MPARAM mp2)
     1462{
     1463    MRESULT mrc = 0;
     1464
     1465    switch (msg)
     1466    {
     1467        case WM_PAINT:
     1468        {
     1469            LONG    lColor;
     1470            RECTL   rclPaint;
     1471            PSZ     pszText;
     1472
     1473            HPS hps = WinBeginPaint(hwndStatic,
     1474                                    NULLHANDLE, // HPS
     1475                                    NULL); // PRECTL
     1476            gpihSwitchToRGB(hps);
     1477            WinQueryWindowRect(hwndStatic,
     1478                               &rclPaint);      // exclusive
     1479            lColor = winhQueryPresColor(hwndStatic,
     1480                                        PP_BACKGROUNDCOLOR,
     1481                                        FALSE,      // no inherit
     1482                                        SYSCLR_DIALOGBACKGROUND);
     1483
     1484            // make rect inclusive
     1485            rclPaint.xRight--;
     1486            rclPaint.yTop--;
     1487
     1488            // draw interior
     1489            GpiSetColor(hps, lColor);
     1490            gpihBox(hps,
     1491                    DRO_FILL,
     1492                    &rclPaint);
     1493
     1494            // draw frame
     1495            GpiSetColor(hps, RGBCOL_BLACK);
     1496            gpihBox(hps,
     1497                    DRO_OUTLINE,
     1498                    &rclPaint);
     1499
     1500            if (pszText = winhQueryWindowText(hwndStatic))
     1501            {
     1502                GpiSetColor(hps,
     1503                            winhQueryPresColor(hwndStatic,
     1504                                               PP_FOREGROUNDCOLOR,
     1505                                               FALSE,
     1506                                               -1));
     1507                WinDrawText(hps,
     1508                            strlen(pszText),
     1509                            pszText,
     1510                            &rclPaint,
     1511                            0,
     1512                            0,
     1513                            DT_CENTER | DT_VCENTER | DT_TEXTATTRS);
     1514
     1515                free(pszText);
     1516            }
     1517
     1518            WinEndPaint(hps);
     1519        }
     1520        break;
     1521
     1522        case WM_PRESPARAMCHANGED:
     1523            switch ((ULONG)mp1)
     1524            {
     1525                case PP_BACKGROUNDCOLOR:
     1526                    WinInvalidateRect(hwndStatic,
     1527                                      NULL,
     1528                                      FALSE);
     1529                    // notify owner; since the static control
     1530                    // doesn't send any notifications, we
     1531                    // use EN_CHANGED
     1532                    WinSendMsg(WinQueryWindow(hwndStatic, QW_OWNER),
     1533                               WM_CONTROL,
     1534                               MPFROM2SHORT(WinQueryWindowUShort(hwndStatic, QWS_ID),
     1535                                            EN_CHANGE),
     1536                               (MPARAM)hwndStatic);
     1537                break;
     1538            }
     1539        break;
     1540
     1541        default:
     1542            mrc = G_pfnwpOrigStatic(hwndStatic, msg, mp1, mp2);
     1543        break;
     1544    }
     1545
     1546    return mrc;
     1547}
     1548
     1549/*
     1550 *@@ ctlMakeColorRect:
     1551 *      turns a static rectangle into a color rectangle.
     1552 *
     1553 *@@added V0.9.19 (2002-06-02) [umoeller]
     1554 */
     1555
     1556BOOL ctlMakeColorRect(HWND hwndStatic)
     1557{
     1558    PFNWP pfnwp;
     1559
     1560    if (pfnwp = WinSubclassWindow(hwndStatic,
     1561                                  ctl_fnwpSubclassedColorRect))
     1562    {
     1563        G_pfnwpOrigStatic = pfnwp;
     1564        return TRUE;
     1565    }
     1566
     1567    return FALSE;
     1568}
     1569
     1570
Note: See TracChangeset for help on using the changeset viewer.