Ignore:
Timestamp:
Oct 2, 2001, 8:28:47 PM (24 years ago)
Author:
umoeller
Message:

Misc helpers updates.

File:
1 edited

Legend:

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

    r90 r106  
    19621962 *      cores.
    19631963 *
    1964  *      Presently, this function supports drawing record
    1965  *      cores in gray color if the record has the CRA_DISABLED
    1966  *      style (which, AFAIK, PM ignores per default).
     1964 *      What this draws depends on flFlags:
     1965 *
     1966 *      --  If CODFL_DISABLEDTEXT is set, this function supports
     1967 *          drawing record cores in gray color if the record has
     1968 *          the CRA_DISABLED style (which, AFAIK, PM ignores per
     1969 *          default).
     1970 *
     1971 *      --  If CODFL_MINIICON is set, this function paints the
     1972 *          record's mini-icon properly. So far I have failed
     1973 *          to find out how to get a container to paint the
     1974 *          correct mini-icon if the CV_MINI style is set...
     1975 *          the container normally _does_ paint a small icon,
     1976 *          but it won't use the "real" mini icon data if that
     1977 *          is present.
     1978 *
     1979 *          For painting the mini-icon, WinDrawPointer is used
     1980 *          with DP_MINI set properly and the RECORDCORE's
     1981 *          hptrMiniIcon field.
    19671982 *
    19681983 *      This returns either TRUE or FALSE as an MPARAM, depending
    19691984 *      on whether we have drawn the item. This return value should
    19701985 *      also be the return value of your window procedure.
    1971  */
    1972 
    1973 MRESULT cnrhOwnerDrawRecord(MPARAM mp2) // in: mp2 of WM_DRAWITEM (POWNERITEM)
    1974 {
    1975     MRESULT mrc = 0;
     1986 *
     1987 *@@changed V0.9.16 (2001-09-29) [umoeller]: added flFlags, icon draw support
     1988 */
     1989
     1990MRESULT cnrhOwnerDrawRecord(MPARAM mp2,     // in: mp2 of WM_DRAWITEM (POWNERITEM)
     1991                            ULONG flFlags)  // in: CODFL_* flags
     1992{
     1993    MRESULT mrc = (MPARAM)FALSE; // tell cnr to draw the item
    19761994
    19771995    // get generic DRAWITEM structure
    1978     POWNERITEM poi = (POWNERITEM)mp2;
    1979 
    1980     // check if we're to draw the text
    1981     // (and not the icon)
    1982     if (poi->idItem == CMA_TEXT)
     1996    POWNERITEM poi;
     1997
     1998    if (poi = (POWNERITEM)mp2)
    19831999    {
    19842000        // get container-specific draw-item struct
    19852001        PCNRDRAWITEMINFO pcdii = (PCNRDRAWITEMINFO)poi->hItem;
    19862002
    1987         if (((pcdii->pRecord->flRecordAttr) & CRA_DISABLED) == 0)
     2003        // check if we're to draw the text
     2004        // (and not the icon)
     2005        if (    (poi->idItem == CMA_TEXT)
     2006             && (flFlags & CODFL_DISABLEDTEXT)
     2007           )
    19882008        {
    1989             /*
    1990             // not disabled == valid WPS class
    1991             if ((pcdii->pRecord->flRecordAttr) & CRA_SELECTED)
     2009            if (((pcdii->pRecord->flRecordAttr) & CRA_DISABLED) == 0)
    19922010            {
    1993                 // not disabled, but selected:
    1994                 lBackground = winhQueryPresColor(hwndDlg, PP_HILITEBACKGROUNDCOLOR, SYSCLR_HILITEBACKGROUND);
    1995                 lForeground = winhQueryPresColor(hwndDlg, PP_HILITEFOREGROUNDCOLOR, SYSCLR_HILITEFOREGROUND);
     2011                /*
     2012                // not disabled == valid WPS class
     2013                if ((pcdii->pRecord->flRecordAttr) & CRA_SELECTED)
     2014                {
     2015                    // not disabled, but selected:
     2016                    lBackground = winhQueryPresColor(hwndDlg, PP_HILITEBACKGROUNDCOLOR, SYSCLR_HILITEBACKGROUND);
     2017                    lForeground = winhQueryPresColor(hwndDlg, PP_HILITEFOREGROUNDCOLOR, SYSCLR_HILITEFOREGROUND);
     2018                }
     2019                else
     2020                {
     2021                    // not disabled, not selected:
     2022                    lBackground = winhQueryPresColor(hwndDlg, PP_BACKGROUNDCOLOR, SYSCLR_BACKGROUND);
     2023                    lForeground = winhQueryPresColor(hwndDlg, PP_FOREGROUNDCOLOR, SYSCLR_WINDOWTEXT);
     2024                } */
     2025                mrc = FALSE;
     2026                    // let cnr draw the thing
    19962027            }
    19972028            else
    19982029            {
    1999                 // not disabled, not selected:
    2000                 lBackground = winhQueryPresColor(hwndDlg, PP_BACKGROUNDCOLOR, SYSCLR_BACKGROUND);
    2001                 lForeground = winhQueryPresColor(hwndDlg, PP_FOREGROUNDCOLOR, SYSCLR_WINDOWTEXT);
    2002             } */
    2003             mrc = FALSE;
    2004                 // let cnr draw the thing
     2030                // CRA_DISABLED:
     2031
     2032                ULONG flCmd = DT_LEFT | DT_TOP | DT_ERASERECT;
     2033                RECTL rcl2;
     2034
     2035                // set draw colors
     2036                LONG  lBackground,
     2037                      lForeground;
     2038
     2039                // switch to RGB
     2040                GpiCreateLogColorTable(poi->hps, 0, LCOLF_RGB, 0, 0, NULL);
     2041
     2042                if ((pcdii->pRecord->flRecordAttr) & CRA_SELECTED)
     2043                {
     2044                    // disabled and selected:
     2045                    lBackground = WinQuerySysColor(HWND_DESKTOP,
     2046                                                   SYSCLR_SHADOWTEXT, 0);
     2047                    lForeground = winhQueryPresColor(poi->hwnd,
     2048                                                     PP_BACKGROUNDCOLOR,
     2049                                                     FALSE, // no inherit
     2050                                                     SYSCLR_WINDOW);
     2051                }
     2052                else
     2053                {
     2054                    // disabled and not selected:
     2055                    lBackground = winhQueryPresColor(poi->hwnd,
     2056                                                     PP_BACKGROUNDCOLOR,
     2057                                                     FALSE,
     2058                                                     SYSCLR_WINDOW);
     2059                    lForeground = WinQuerySysColor(HWND_DESKTOP,
     2060                                                   SYSCLR_SHADOWTEXT, 0);
     2061                }
     2062
     2063                memcpy(&rcl2, &(poi->rclItem), sizeof(rcl2));
     2064                /* WinDrawText(poi->hps,
     2065                            strlen(pcdii->pRecord->pszText),
     2066                            pcdii->pRecord->pszText,
     2067                            &rcl2,
     2068                            lForeground,  // foreground
     2069                            lBackground,
     2070                            flCmd); */
     2071
     2072                GpiSetBackColor(poi->hps, lBackground);
     2073                GpiSetColor(poi->hps, lForeground);
     2074
     2075                winhDrawFormattedText(poi->hps,
     2076                                      &rcl2,
     2077                                      pcdii->pRecord->pszText,
     2078                                      flCmd);
     2079
     2080                mrc = (MPARAM)TRUE;     // tell cnr that we've drawn the item
     2081            }
    20052082        }
    2006         else
     2083        else if (    (poi->idItem == CMA_ICON)
     2084                  && (flFlags & CODFL_MINIICON)
     2085                )
    20072086        {
    2008             // CRA_DISABLED:
    2009 
    2010             ULONG flCmd = DT_LEFT | DT_TOP | DT_ERASERECT;
    2011             RECTL rcl2;
    2012 
    2013             // set draw colors
    2014             LONG  lBackground,
    2015                   lForeground;
    2016 
    2017             // switch to RGB
    2018             GpiCreateLogColorTable(poi->hps, 0, LCOLF_RGB, 0, 0, NULL);
    2019 
    2020             if ((pcdii->pRecord->flRecordAttr) & CRA_SELECTED)
    2021             {
    2022                 // disabled and selected:
    2023                 lBackground = WinQuerySysColor(HWND_DESKTOP,
    2024                                                SYSCLR_SHADOWTEXT, 0);
    2025                 lForeground = winhQueryPresColor(poi->hwnd,
    2026                                                  PP_BACKGROUNDCOLOR,
    2027                                                  FALSE, // no inherit
    2028                                                  SYSCLR_WINDOW);
    2029             }
    2030             else
    2031             {
    2032                 // disabled and not selected:
    2033                 lBackground = winhQueryPresColor(poi->hwnd,
    2034                                                  PP_BACKGROUNDCOLOR,
    2035                                                  FALSE,
    2036                                                  SYSCLR_WINDOW);
    2037                 lForeground = WinQuerySysColor(HWND_DESKTOP,
    2038                                                SYSCLR_SHADOWTEXT, 0);
    2039             }
    2040 
    2041             memcpy(&rcl2, &(poi->rclItem), sizeof(rcl2));
    2042             /* WinDrawText(poi->hps,
    2043                         strlen(pcdii->pRecord->pszText),
    2044                         pcdii->pRecord->pszText,
    2045                         &rcl2,
    2046                         lForeground,  // foreground
    2047                         lBackground,
    2048                         flCmd); */
    2049 
    2050             GpiSetBackColor(poi->hps, lBackground);
    2051             GpiSetColor(poi->hps, lForeground);
    2052 
    2053             winhDrawFormattedText(poi->hps,
    2054                                   &rcl2,
    2055                                   pcdii->pRecord->pszText,
    2056                                   flCmd);
    2057 
    2058             mrc = (MPARAM)TRUE; // tell cnr that we've drawn the item
     2087            WinDrawPointer(poi->hps,
     2088                           // center the icon in the rectangle
     2089                           (   poi->rclItem.xLeft
     2090                             + (poi->rclItem.xRight - poi->rclItem.xLeft
     2091                                - WinQuerySysValue(HWND_DESKTOP, SV_CXICON) / 2
     2092                               ) / 2
     2093                           ),
     2094                           (   poi->rclItem.yBottom
     2095                             + (poi->rclItem.yTop - poi->rclItem.yBottom
     2096                                - WinQuerySysValue(HWND_DESKTOP, SV_CYICON) / 2
     2097                               ) / 2
     2098                           ),
     2099                           pcdii->pRecord->hptrMiniIcon,
     2100                           DP_MINI);
     2101
     2102            mrc = (MPARAM)TRUE;         // tell cnr that we've drawn the item
    20592103        }
    2060     } else
    2061         mrc = (MPARAM)FALSE; // tell cnr to draw the item
     2104    }
    20622105
    20632106    return (mrc);
Note: See TracChangeset for help on using the changeset viewer.