Ignore:
Timestamp:
Jan 29, 2003, 7:41:39 PM (23 years ago)
Author:
umoeller
Message:

New build system, multimedia, other misc fixes.

File:
1 edited

Legend:

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

    r242 r243  
    18961896
    18971897/*
    1898  *@@ winhCreateScrollBars:
    1899  *      creates two scroll bars with an arbitrary
    1900  *      position for later use with winhUpdateScrollBar.
    1901  *
    1902  *@@added V1.0.1 (2003-01-17) [umoeller]
    1903  */
    1904 
    1905 BOOL winhCreateScrollBars(HWND hwndParent,
    1906                           HWND *phwndV,     // out: vertical scroll bar
    1907                           HWND *phwndH)     // out: horizontal scroll bar
    1908 {
    1909     SBCDATA     sbcd;
    1910     sbcd.cb = sizeof(SBCDATA);
    1911     sbcd.sHilite = 0;
    1912     sbcd.posFirst = 0;
    1913     sbcd.posLast = 100;
    1914     sbcd.posThumb = 30;
    1915     sbcd.cVisible = 50;
    1916     sbcd.cTotal = 50;
    1917 
    1918     return (    (*phwndV = WinCreateWindow(hwndParent,
    1919                                            WC_SCROLLBAR,
    1920                                            "",
    1921                                            SBS_VERT | SBS_THUMBSIZE | WS_VISIBLE,
    1922                                            10, 10,
    1923                                            20, 100,
    1924                                            hwndParent,     // owner
    1925                                            HWND_TOP,
    1926                                            ID_VSCROLL,
    1927                                            &sbcd,
    1928                                            0))
    1929              && (*phwndH = WinCreateWindow(hwndParent,
    1930                                            WC_SCROLLBAR,
    1931                                            "",
    1932                                            SBS_THUMBSIZE | WS_VISIBLE,
    1933                                            10, 10,
    1934                                            20, 100,
    1935                                            hwndParent,     // owner
    1936                                            HWND_TOP,
    1937                                            ID_HSCROLL,
    1938                                            &sbcd,
    1939                                            0))
    1940            );
    1941 }
    1942 
    1943 /*
    19441898 *@@ winhUpdateScrollBar:
    19451899 *      updates the given scroll bar according to the given
     
    19581912 *      Terminology:
    19591913 *
    1960  *      -- "window": the actual window with scroll bars which displays
    1961  *         a subrectangle of the available data. With a typical PM
    1962  *         application, this will be your client window.
    1963  *
    1964  *         The width or height of this must be passed in ulWinPels.
    1965  *
    1966  *      -- "workarea": the entire data to be displayed, of which the
    1967  *         "window" can only display a subrectangle, if the workarea
    1968  *         is larger than the window.
    1969  *
    1970  *         The width or height of this must be passed in ulWorkareaPels.
    1971  *         This can be smaller than ulWinPels (if the window is larger
    1972  *         than the data) or the same or larger than ulWinPels
    1973  *         (if the window is too small to show all the data).
    1974  *
    1975  *      -- "window offset": the offset of the current window within
    1976  *         the workarea.
    1977  *
    1978  *         For horizontal scroll bars, this is the X coordinate,
    1979  *         counting from the left of the window (0 means leftmost).
    1980  *
    1981  *         For vertical scroll bars, this is counted from the _top_
    1982  *         of the workarea (0 means topmost, as opposed to OS/2
    1983  *         window coordinates!). This is because for vertical scroll
    1984  *         bars controls, higher values move the thumb _down_. Yes
    1985  *         indeed, this conflicts with PM's coordinate system.
    1986  *
    1987  *         The window offset is therefore always positive.
     1914 *      --  "window": the actual window with scroll bars which displays
     1915 *          a subrectangle of the available data. With a typical PM
     1916 *          application, this will be your client window.
     1917 *
     1918 *          The width or height of this must be passed in ulWinPels.
     1919 *
     1920 *      --  "workarea": the entire data to be displayed, of which the
     1921 *          "window" can only display a subrectangle, if the workarea
     1922 *          is larger than the window.
     1923 *
     1924 *          The width or height of this must be passed in ulWorkareaPels.
     1925 *          This can be smaller than ulWinPels (if the window is larger
     1926 *          than the data) or the same or larger than ulWinPels
     1927 *          (if the window is too small to show all the data).
     1928 *
     1929 *          This value is exclusive in the sense that the maximum
     1930 *          window offset (below) can be the workarea minus one.
     1931 *
     1932 *      --  "window offset": the zero-based offset of the current
     1933 *          window within the workarea, whose maximum value is
     1934 *          the workarea minus one.
     1935 *
     1936 *          For horizontal scroll bars, this is the X coordinate,
     1937 *          counting from the left of the window (0 means leftmost).
     1938 *
     1939 *          For vertical scroll bars, this is counted from the _top_
     1940 *          of the workarea (0 means topmost, as opposed to OS/2
     1941 *          window coordinates!). This is because for vertical scroll
     1942 *          bars controls, higher values move the thumb _down_. Yes
     1943 *          indeed, this conflicts with PM's coordinate system.
     1944 *
     1945 *          The window offset is therefore always positive.
    19881946 *
    19891947 *      The scroll bar gets disabled if the entire workarea is visible,
     
    20091967 *@@changed V0.9.3 (2000-04-30) [umoeller]: fixed pels/unit confusion
    20101968 *@@changed V0.9.3 (2000-05-08) [umoeller]: now handling scroll units automatically
     1969 *@@changed V1.0.1 (2003-01-25) [umoeller]: fixed max value which caused right/bottommost scroll button to never be disabled
     1970 *@@changed V1.0.1 (2003-01-25) [umoeller]: fixed bad thumb position for large offsets
    20111971 */
    20121972
     
    20261986    BOOL brc = FALSE;
    20271987
    2028     // _Pmpf(("Entering winhUpdateScrollBar"));
    2029 
    2030     // for large workareas, adjust scroll bar units
    2031     USHORT  usScrollUnitPels = 1;
    2032     if (ulWorkareaPels > 10000)
    2033         usScrollUnitPels = 100;
    2034 
    2035     if (ulWorkareaPels > ulWinPels)
    2036     {
     1988    if (ulWorkareaPels >= ulWinPels)
     1989    {
     1990        // for large workareas, adjust scroll bar units
     1991        USHORT  usDivisor = 1;
     1992        USHORT  lMaxAllowedUnitOfs;
     1993
     1994        if (ulWorkareaPels > 10000)
     1995            usDivisor = 100;
     1996
    20371997        // scrollbar needed:
    2038         USHORT  usThumbDivisorUnits = usScrollUnitPels;
    2039         USHORT  lMaxAllowedUnitOfs;
    2040         // _Pmpf(("winhUpdateScrollBar: ulWorkareaPels > ulWinPels, enabling scroller"));
    2041         // divisor for thumb size (below)
    2042         if (ulWorkareaPels > 10000)
    2043             // for very large workareas, we need to
    2044             // raise the divisor, because we only
    2045             // have a USHORT
    2046             usThumbDivisorUnits = usScrollUnitPels * 100;
    20471998
    20481999        // workarea is larger than window:
     
    20522003
    20532004        // calculate limit
    2054         lMaxAllowedUnitOfs = ((ulWorkareaPels - ulWinPels + usScrollUnitPels)
    2055                                // scroll unit is 10
    2056                                / usScrollUnitPels);
    2057 
    2058         // _Pmpf(("    usCurUnitOfs: %d", ulCurUnitOfs));
    2059         // _Pmpf(("    usMaxUnits: %d", lMaxAllowedUnitOfs));
     2005        lMaxAllowedUnitOfs =   (ulWorkareaPels - ulWinPels)
     2006                             / usDivisor;
    20602007
    20612008        // set thumb position and limit
    20622009        WinSendMsg(hwndScrollBar,
    20632010                   SBM_SETSCROLLBAR,
    2064                    (MPARAM)(ulCurPelsOfs), //  / usThumbDivisorUnits),   // position: 0 means top
     2011                   (MPARAM)(ulCurPelsOfs / usDivisor),   // position: 0 means top
    20652012                   MPFROM2SHORT(0,  // minimum
    20662013                                lMaxAllowedUnitOfs));    // maximum
     
    20702017        WinSendMsg(hwndScrollBar,
    20712018                   SBM_SETTHUMBSIZE,
    2072                    MPFROM2SHORT(    ulWinPels / usThumbDivisorUnits,       // visible
    2073                                     ulWorkareaPels / usThumbDivisorUnits), // total
     2019                   MPFROM2SHORT(    ulWinPels / usDivisor,       // visible
     2020                                    ulWorkareaPels / usDivisor), // total
    20742021                   0);
    20752022        brc = TRUE;
     
    20772024    else
    20782025    {
    2079         // _Pmpf(("winhUpdateScrollBar: ulWorkareaPels <= ulWinPels"));
    20802026        // entire workarea is visible:
    20812027        WinEnableWindow(hwndScrollBar, FALSE);
     
    20912037/*
    20922038 *@@ winhHandleScrollMsg:
    2093  *      this helper handles a WM_VSCROLL or WM_HSCROLL
    2094  *      message posted to a client window when the user
    2095  *      has worked on a client scroll bar. Calling this
    2096  *      function is ALL you need to do to handle those
    2097  *      two messages.
     2039 *      this helper handles a WM_VSCROLL or WM_HSCROLL message
     2040 *      posted to a client window when the user has worked on a
     2041 *      client scroll bar. Calling this function is all you need to
     2042 *      do to handle those two messages.
    20982043 *
    20992044 *      This is most useful in conjunction with winhUpdateScrollBar.
    21002045 *      See that function for the terminology also.
    21012046 *
    2102  *      This function calculates the new scrollbar position
    2103  *      (from the mp2 value, which can be line up/down,
    2104  *      page up/down, or slider track) and calls WinScrollWindow
    2105  *      accordingly. The window part which became invalid
    2106  *      because of the scrolling is automatically invalidated
    2107  *      (using WinInvalidateRect), so expect a WM_PAINT after
    2108  *      calling this function.
     2047 *      This function calculates the new scrollbar position (from
     2048 *      the mp2 value, which can be line up/down, page up/down, or
     2049 *      slider track) and calculates the scrolling offset
     2050 *      accordingly, which is returned as a LONG.
    21092051 *
    21102052 *      This function assumes that the scrollbar operates
    21112053 *      on values starting from zero. The maximum value
    2112  *      of the scroll bar is:
    2113  *
    2114  +          ulWorkareaPels - (prcl2Scroll->yTop - prcl2Scroll->yBottom)
    2115  *
    2116  *      This function also automatically changes the scroll bar
     2054 *      of the scroll bar is therefore
     2055 *
     2056 +          lWorkareaPels - (prcl2Scroll->yTop - prcl2Scroll->yBottom)
     2057 *
     2058 *      This function also automatically shrinks the scroll bar
    21172059 *      units, should you have a workarea size which doesn't fit
    21182060 *      into the SHORT's that the scroll bar uses internally. As
    21192061 *      a result, this function handles a the complete range of
    2120  *      a ULONG for the workarea.
     2062 *      a LONG for the workarea. (The PM scroll bar implementation
     2063 *      is really brain-dead in this respect... the workarea can
     2064 *      easily be larger than 32768 pixels. That's what scroll bars
     2065 *      are for in the first place, dammit.)
    21212066 *
    21222067 *      Replace "bottom" and "top" with "right" and "left" for
    21232068 *      horizontal scrollbars in the above formula.
     2069 *
     2070 *      Returns the amount of pixels to be passed to winhScrollWindow
     2071 *      afterwards.
    21242072 *
    21252073 *@@added V0.9.1 (2000-02-13) [umoeller]
     
    21272075 *@@changed V0.9.3 (2000-05-08) [umoeller]: now handling scroll units automatically
    21282076 *@@changed V0.9.7 (2001-01-17) [umoeller]: changed PLONG to PULONG
    2129  */
    2130 
    2131 BOOL winhHandleScrollMsg(HWND hwnd2Scroll,          // in: client window to scroll
    2132                          HWND hwndScrollBar,        // in: vertical or horizontal scroll bar window
    2133                          PULONG pulCurPelsOfs,      // in/out: current workarea offset;
    2134                                                     // this is updated with the proper scroll units
    2135                          PRECTL prcl2Scroll,        // in: hwnd2Scroll rectangle to scroll
    2136                                                     // (in window coordinates);
    2137                                                     // this is passed to WinScrollWindow,
    2138                                                     // which considers this inclusive!
    2139                          LONG ulWorkareaPels,       // in: total workarea dimension,
    2140                                                     // into which *pulCurPelsOfs is an offset
     2077 *@@changed V1.0.1 (2003-01-25) [umoeller]: changed prototype, no longer calling WinScrollWindow, fixed offset bugs
     2078 */
     2079
     2080LONG winhHandleScrollMsg(HWND hwndScrollBar,        // in: vertical or horizontal scroll bar window
     2081                         PLONG plCurPelsOfs,        // in/out: current workarea offset (in window coordinates)
     2082                         LONG lWindowPels,          // in: window cx or cy (in window coordinates)
     2083                         LONG lWorkareaPels,        // in: total workarea dimension,
     2084                                                    // into which *plCurPelsOfs is an offset
    21412085                         USHORT usLineStepPels,     // in: pixels to scroll line-wise
    21422086                                                    // (scroll bar buttons pressed)
     
    21462090                                                    // see PMREF for details
    21472091{
    2148     ULONG   ulOldPelsOfs = *pulCurPelsOfs;
     2092    LONG    lOldPelsOfs = *plCurPelsOfs;
    21492093    USHORT  usPosUnits = SHORT1FROMMP(mp2), // in scroll units
    21502094            usCmd = SHORT2FROMMP(mp2);
    2151     LONG    lMaxAllowedUnitOfs;
    2152     ULONG   ulWinPels;
     2095    LONG    lLimitPels;
    21532096
    21542097    // for large workareas, adjust scroll bar units
    2155     USHORT  usScrollUnitPels = 1;
    2156     if (ulWorkareaPels > 10000)
    2157         usScrollUnitPels = 100;
    2158 
    2159     // calculate window size (vertical or horizontal)
    2160     if (msg == WM_VSCROLL)
    2161         ulWinPels = (prcl2Scroll->yTop - prcl2Scroll->yBottom);
    2162     else
    2163         ulWinPels = (prcl2Scroll->xRight - prcl2Scroll->xLeft);
    2164 
    2165     lMaxAllowedUnitOfs = ((LONG)ulWorkareaPels - ulWinPels) / usScrollUnitPels;
    2166 
    2167     // _Pmpf(("Entering winhHandleScrollMsg"));
     2098    LONG    lScrollUnitPels = 1;
     2099    if (lWorkareaPels > 10000)
     2100        lScrollUnitPels = 100;
    21682101
    21692102    switch (usCmd)
    21702103    {
    21712104        case SB_LINEUP:
    2172             if (*pulCurPelsOfs > usLineStepPels)
    2173                 *pulCurPelsOfs -= usLineStepPels;  //  * usScrollUnitPels);
    2174             else
    2175                 *pulCurPelsOfs = 0;
     2105            *plCurPelsOfs -= usLineStepPels;
    21762106        break;
    21772107
    21782108        case SB_LINEDOWN:
    2179             *pulCurPelsOfs += usLineStepPels;  //  * usScrollUnitPels);
     2109            *plCurPelsOfs += usLineStepPels;
    21802110        break;
    21812111
    21822112        case SB_PAGEUP:
    2183             if (*pulCurPelsOfs > ulWinPels)
    2184                 *pulCurPelsOfs -= ulWinPels; // convert to units
    2185             else
    2186                 *pulCurPelsOfs = 0;
     2113            *plCurPelsOfs -= lWindowPels;
    21872114        break;
    21882115
    21892116        case SB_PAGEDOWN:
    2190             *pulCurPelsOfs += ulWinPels; // convert to units
     2117            *plCurPelsOfs += lWindowPels;
    21912118        break;
    21922119
    21932120        case SB_SLIDERTRACK:
    2194             *pulCurPelsOfs = (usPosUnits * usScrollUnitPels);
    2195             // _Pmpf(("    SB_SLIDERTRACK: usUnits = %d", usPosUnits));
     2121            *plCurPelsOfs = (LONG)usPosUnits * lScrollUnitPels;
    21962122        break;
    21972123
    21982124        case SB_SLIDERPOSITION:
    2199             *pulCurPelsOfs = (usPosUnits * usScrollUnitPels);
     2125            *plCurPelsOfs = (LONG)usPosUnits * lScrollUnitPels;
    22002126        break;
    22012127    }
    22022128
    2203     // are we close to the lower limit?
    2204     /* if (*plCurUnitOfs < usLineStepUnits) // usScrollUnit)
    2205         *plCurUnitOfs = 0;
    2206     // are we close to the upper limit?
    2207     else if (*plCurUnitOfs + usLineStepUnits > lMaxUnitOfs)
    2208     {
    2209         _Pmpf(("        !!! limiting: %d to %d", *plCurUnitOfs, lMaxUnitOfs));
    2210         *plCurUnitOfs = lMaxUnitOfs;
    2211     } */
    2212 
    2213     /* if (*plCurPelsOfs < 0)
    2214         *plCurPelsOfs = 0; */       // checked above
    2215     if (*pulCurPelsOfs > (lMaxAllowedUnitOfs * usScrollUnitPels))
    2216     {
    2217         *pulCurPelsOfs = (lMaxAllowedUnitOfs * usScrollUnitPels);
    2218     }
    2219     if (    (*pulCurPelsOfs != ulOldPelsOfs)
    2220          || (*pulCurPelsOfs == 0)
    2221          || (*pulCurPelsOfs == (lMaxAllowedUnitOfs * usScrollUnitPels))
     2129    // calc max scroll offset:
     2130    // if we have a viewport of 200 and the window size is 199,
     2131    // we can have scroll values of 0 or 1
     2132    lLimitPels = lWorkareaPels - lWindowPels;
     2133
     2134    // now delimit
     2135    if (*plCurPelsOfs < 0)
     2136        *plCurPelsOfs = 0;
     2137    else if (*plCurPelsOfs > lLimitPels)
     2138        *plCurPelsOfs = lLimitPels;
     2139
     2140    if (    (*plCurPelsOfs != lOldPelsOfs)
     2141         || (*plCurPelsOfs == 0)
     2142         || (*plCurPelsOfs == lLimitPels)
    22222143       )
    22232144    {
    2224         RECTL   rcl2Scroll,
    2225                 rcl2Update;
    2226 
    22272145        // changed:
    22282146        WinSendMsg(hwndScrollBar,
    22292147                   SBM_SETPOS,
    2230                    (MPARAM)(*pulCurPelsOfs / usScrollUnitPels), //  / usScrollUnit),
    2231                    0);
    2232         // scroll window rectangle:
    2233         rcl2Scroll.xLeft =  prcl2Scroll->xLeft;
    2234         rcl2Scroll.xRight =  prcl2Scroll->xRight;
    2235         rcl2Scroll.yBottom =  prcl2Scroll->yBottom;
    2236         rcl2Scroll.yTop =  prcl2Scroll->yTop;
    2237 
    2238         if (msg == WM_VSCROLL)
    2239             WinScrollWindow(hwnd2Scroll,
    2240                             0,
    2241                             (*pulCurPelsOfs - ulOldPelsOfs)  // scroll units changed
    2242                             ,    // * usScrollUnitPels,     // convert to pels
    2243                             &rcl2Scroll,  // rcl to scroll
    2244                             prcl2Scroll, // clipping rect
    2245                             NULLHANDLE, // no region
    2246                             &rcl2Update,
    2247                             0);
    2248         else
    2249             WinScrollWindow(hwnd2Scroll,
    2250                             -(LONG)(*pulCurPelsOfs - ulOldPelsOfs) // scroll units changed
    2251                             ,    // * usScrollUnitPels,
    2252                             0,
    2253                             &rcl2Scroll,  // rcl to scroll
    2254                             prcl2Scroll, // clipping rect
    2255                             NULLHANDLE, // no region
    2256                             &rcl2Update,
    2257                             0);
    2258 
    2259         // WinScrollWindow has stored the invalid window
    2260         // rectangle which needs to be repainted in rcl2Update:
    2261         WinInvalidateRect(hwnd2Scroll, &rcl2Update, FALSE);
    2262     }
    2263 
    2264     // _Pmpf(("End of winhHandleScrollMsg"));
    2265 
    2266     return TRUE;
    2267 }
    2268 
    2269 /*
    2270  *@@ winhHandleScrollMsg2:
    2271  *
    2272  *      Returns the amount of pixels to be passed to
    2273  *      WinScrollWindow.
    2274  *
    2275  *@@added V1.0.1 (2003-01-17) [umoeller]
    2276  */
    2277 
    2278 LONG winhHandleScrollMsg2(HWND hwndScrollBar,        // in: vertical or horizontal scroll bar window
    2279                           PLONG plCurPelsOfs,        // in/out: current workarea offset;
    2280                                                      // this is updated with the proper scroll units
    2281                           LONG lWindowPels,          // in: window cx or cy (in window coordinates);
    2282                           LONG lWorkareaPels,        // in: total workarea dimension,
    2283                                                      // into which *plCurPelsOfs is an offset
    2284                           USHORT usLineStepPels,     // in: pixels to scroll line-wise
    2285                                                      // (scroll bar buttons pressed)
    2286                           ULONG msg,                 // in: either WM_VSCROLL or WM_HSCROLL
    2287                           MPARAM mp2)                // in: complete mp2 of WM_VSCROLL/WM_HSCROLL;
    2288                                                      // this has two SHORT's (usPos and usCmd),
    2289                                                      // see PMREF for details
    2290 {
    2291     LONG    lOldPelsOfs = *plCurPelsOfs;
    2292     USHORT  usPosUnits = SHORT1FROMMP(mp2), // in scroll units
    2293             usCmd = SHORT2FROMMP(mp2);
    2294     LONG    lMaxAllowedUnitOfs;
    2295 
    2296     // for large workareas, adjust scroll bar units
    2297     USHORT  usScrollUnitPels = 1;
    2298     if (lWorkareaPels > 10000)
    2299         usScrollUnitPels = 100;
    2300 
    2301     lMaxAllowedUnitOfs = (lWorkareaPels - lWindowPels) / usScrollUnitPels;
    2302 
    2303     // _Pmpf(("Entering winhHandleScrollMsg"));
    2304 
    2305     switch (usCmd)
    2306     {
    2307         case SB_LINEUP:
    2308             if (*plCurPelsOfs > usLineStepPels)
    2309                 *plCurPelsOfs -= usLineStepPels;  //  * usScrollUnitPels);
    2310             else
    2311                 *plCurPelsOfs = 0;
    2312         break;
    2313 
    2314         case SB_LINEDOWN:
    2315             *plCurPelsOfs += usLineStepPels;  //  * usScrollUnitPels);
    2316         break;
    2317 
    2318         case SB_PAGEUP:
    2319             if (*plCurPelsOfs > lWindowPels)
    2320                 *plCurPelsOfs -= lWindowPels; // convert to units
    2321             else
    2322                 *plCurPelsOfs = 0;
    2323         break;
    2324 
    2325         case SB_PAGEDOWN:
    2326             *plCurPelsOfs += lWindowPels; // convert to units
    2327         break;
    2328 
    2329         case SB_SLIDERTRACK:
    2330             *plCurPelsOfs = (usPosUnits * usScrollUnitPels);
    2331             // _Pmpf(("    SB_SLIDERTRACK: usUnits = %d", usPosUnits));
    2332         break;
    2333 
    2334         case SB_SLIDERPOSITION:
    2335             *plCurPelsOfs = (usPosUnits * usScrollUnitPels);
    2336         break;
    2337     }
    2338 
    2339     if (*plCurPelsOfs > (lMaxAllowedUnitOfs * usScrollUnitPels))
    2340         *plCurPelsOfs = (lMaxAllowedUnitOfs * usScrollUnitPels);
    2341 
    2342     if (    (*plCurPelsOfs != lOldPelsOfs)
    2343          || (*plCurPelsOfs == 0)
    2344          || (*plCurPelsOfs == (lMaxAllowedUnitOfs * usScrollUnitPels))
    2345        )
    2346     {
    2347         // changed:
    2348         WinSendMsg(hwndScrollBar,
    2349                    SBM_SETPOS,
    2350                    (MPARAM)(*plCurPelsOfs / usScrollUnitPels), //  / usScrollUnit),
     2148                   (MPARAM)(*plCurPelsOfs / lScrollUnitPels),
    23512149                   0);
    23522150
     
    23812179
    23822180/*
    2383  *@@ winhProcessScrollChars:
     2181 *@@ winhProcessScrollChars2:
    23842182 *      helper for processing WM_CHAR messages for
    23852183 *      client windows with scroll bars.
     
    24002198 *      The following keystrokes are processed here:
    24012199 *
    2402  *      -- "cursor up, down, right, left": scroll one
    2403  *         line in the proper direction.
    2404  *      -- "page up, down": scroll one page up or down.
    2405  *      -- "Home": scroll leftmost.
    2406  *      -- "Ctrl+ Home": scroll topmost.
    2407  *      -- "End": scroll rightmost.
    2408  *      -- "Ctrl+ End": scroll bottommost.
    2409  *      -- "Ctrl + page up, down": scroll one screen left or right.
    2410  *
    2411  *      This is CUA behavior.
    2412  *
    2413  *      Returns TRUE if the message has been
    2414  *      processed.
     2200 *      --  "cursor up, down, right, left": scroll one
     2201 *          line in the proper direction.
     2202 *      --  "page up, down": scroll one page up or down.
     2203 *      --  "Home": scroll leftmost.
     2204 *      --  "Ctrl+ Home": scroll topmost.
     2205 *      --  "End": scroll rightmost.
     2206 *      --  "Ctrl+ End": scroll bottommost.
     2207 *      --  "Ctrl + page up, down": scroll one screen left or right.
     2208 *
     2209 *      This is CUA behavior, if anyone still cares about that.
     2210 *
     2211 *      Returns TRUE if the message has been processed.
    24152212 *
    24162213 *@@added V0.9.3 (2000-04-29) [umoeller]
     
    24182215 */
    24192216
    2420 BOOL winhProcessScrollChars(HWND hwndClient,    // in: client window
    2421                             HWND hwndVScroll,   // in: vertical scroll bar
    2422                             HWND hwndHScroll,   // in: horizontal scroll bar
    2423                             MPARAM mp1,         // in: WM_CHAR mp1
    2424                             MPARAM mp2,         // in: WM_CHAR mp2
    2425                             ULONG ulVertMax,    // in: maximum workarea cy
    2426                             ULONG ulHorzMax)    // in: maximum workarea cx
     2217BOOL winhProcessScrollChars2(HWND hwndClient,    // in: client window
     2218                             const SCROLLABLEWINDOW *pscrw,   // in: scroller data
     2219                             MPARAM mp1,         // in: WM_CHAR mp1
     2220                             MPARAM mp2)         // in: WM_CHAR mp2
    24272221{
    24282222    BOOL    fProcessed = FALSE;
    24292223    USHORT usFlags    = SHORT1FROMMP(mp1);
    2430     // USHORT usch       = SHORT1FROMMP(mp2);
    24312224    USHORT usvk       = SHORT2FROMMP(mp2);
    2432 
    2433     // _Pmpf(("Entering winhProcessScrollChars"));
    24342225
    24352226    if (usFlags & KC_VIRTUALKEY)
     
    24942285                    // vertical:
    24952286                    ulMsg = WM_VSCROLL;
    2496                     sPos = ulVertMax;
     2287                    sPos = pscrw->szlWorkarea.cy;
    24972288                }
    24982289                else
    24992290                {
    25002291                    ulMsg = WM_HSCROLL;
    2501                     sPos = ulHorzMax;
     2292                    sPos = pscrw->szlWorkarea.cx;
    25022293                }
    25032294
     
    25152306        {
    25162307            HWND   hwndScrollBar = ((ulMsg == WM_VSCROLL)
    2517                                         ? hwndVScroll
    2518                                         : hwndHScroll);
     2308                                        ? pscrw->hwndVScroll
     2309                                        : pscrw->hwndHScroll);
    25192310            if (WinIsWindowEnabled(hwndScrollBar))
    25202311            {
     
    25302321    }
    25312322
    2532     // _Pmpf(("End of  winhProcessScrollChars"));
    2533 
    25342323    return fProcessed;
     2324}
     2325
     2326/*
     2327 *@@ winhProcessScrollChars:
     2328 *      wrapper around winhProcessScrollChars2 for prototype
     2329 *      compatibility.
     2330 *
     2331 *@@added V1.0.1 (2003-01-25) [umoeller]
     2332 */
     2333
     2334BOOL winhProcessScrollChars(HWND hwndClient,    // in: client window
     2335                            HWND hwndVScroll,   // in: vertical scroll bar
     2336                            HWND hwndHScroll,   // in: horizontal scroll bar
     2337                            MPARAM mp1,         // in: WM_CHAR mp1
     2338                            MPARAM mp2,         // in: WM_CHAR mp2
     2339                            ULONG ulVertMax,    // in: maximum workarea cy
     2340                            ULONG ulHorzMax)    // in: maximum workarea cx
     2341{
     2342    SCROLLABLEWINDOW scrw;
     2343
     2344    scrw.hwndVScroll = hwndVScroll;
     2345    scrw.hwndHScroll = hwndHScroll;
     2346    scrw.szlWorkarea.cx = ulHorzMax;
     2347    scrw.szlWorkarea.cy = ulVertMax;
     2348
     2349    return winhProcessScrollChars2(hwndClient,
     2350                                   &scrw,
     2351                                   mp1,
     2352                                   mp2);
     2353}
     2354
     2355/*
     2356 *@@ winhCreateScrollBars:
     2357 *      creates two scroll bars with an arbitrary
     2358 *      position for later use with winhUpdateScrollBar.
     2359 *
     2360 *@@added V1.0.1 (2003-01-25) [umoeller]
     2361 */
     2362
     2363BOOL XWPENTRY winhCreateScroller(HWND hwndParent,           // in: parent and owner of scroll bars
     2364                                 PSCROLLABLEWINDOW pscrw,   // out: scroller data
     2365                                 ULONG idVScroll,           // in: window ID of vertical scroll bar
     2366                                 ULONG idHScroll)           // in: window ID of horizontal scroll bar
     2367{
     2368    SBCDATA     sbcd;
     2369    sbcd.cb = sizeof(SBCDATA);
     2370    sbcd.sHilite = 0;
     2371    sbcd.posFirst = 0;
     2372    sbcd.posLast = 100;
     2373    sbcd.posThumb = 30;
     2374    sbcd.cVisible = 50;
     2375    sbcd.cTotal = 50;
     2376
     2377    pscrw->cxScrollBar = WinQuerySysValue(HWND_DESKTOP, SV_CXVSCROLL);
     2378    pscrw->cyScrollBar = WinQuerySysValue(HWND_DESKTOP, SV_CYHSCROLL);
     2379
     2380    pscrw->idVScroll = idVScroll;
     2381    pscrw->idHScroll = idHScroll;
     2382
     2383    pscrw->szlWorkarea.cx
     2384    = pscrw->szlWorkarea.cy
     2385    = pscrw->ptlScrollOfs.x
     2386    = pscrw->ptlScrollOfs.y
     2387    = 0;
     2388
     2389    return (    (pscrw->hwndVScroll = WinCreateWindow(hwndParent,
     2390                                                      WC_SCROLLBAR,
     2391                                                      "",
     2392                                                      SBS_VERT | SBS_THUMBSIZE | WS_VISIBLE,
     2393                                                      10, 10,
     2394                                                      20, 100,
     2395                                                      hwndParent,     // owner
     2396                                                      HWND_TOP,
     2397                                                      idVScroll,
     2398                                                      &sbcd,
     2399                                                      0))
     2400             && (pscrw->hwndHScroll = WinCreateWindow(hwndParent,
     2401                                                      WC_SCROLLBAR,
     2402                                                      "",
     2403                                                      SBS_THUMBSIZE | WS_VISIBLE,
     2404                                                      10, 10,
     2405                                                      20, 100,
     2406                                                      hwndParent,     // owner
     2407                                                      HWND_TOP,
     2408                                                      idHScroll,
     2409                                                      &sbcd,
     2410                                                      0))
     2411           );
     2412}
     2413
     2414/*
     2415 *@@ winhHandleScrollerMsgs:
     2416 *      unified function that you can simply call for all of
     2417 *      the WM_HSCROLL, WM_VSCROLL, and WM_CHAR messages to
     2418 *      get full automatic scrolling support for window
     2419 *      messages.
     2420 *
     2421 *      This calls winhHandleScrollMsg, winhScrollWindow,
     2422 *      and winhProcessScrollChars in turn as appropriate.
     2423 *
     2424 *      However, you still need to call winhUpdateScrollBar
     2425 *      for each scroll bar whenever either the workarea or
     2426 *      window size changes.
     2427 *
     2428 *      See winhUpdateScrollBar for the terminology.
     2429 *
     2430 *      The size of the workarea must be passed in with
     2431 *      pscrw, as well as the window and scrollbar handles.
     2432 *      By contrast, the current window size must be passed
     2433 *      in via the pszlWin parameter. This allows for cooperation
     2434 *      with the ctlDefWindowProc funcs, which have their own
     2435 *      fields for this in DEFWINDOWDATA so we won't duplicate.
     2436 *
     2437 *      Preconditions:
     2438 *
     2439 *      --  hwnd2Scroll (the "client") and the scroll bar windows
     2440 *          must be siblings presently. In other words, scrolling
     2441 *          won't work correctly if the scroll bars are children
     2442 *          of the client because we do not presently handle
     2443 *          passing a clipping rectangle to WinScrollWindow here.
     2444 *
     2445 *@@added V1.0.1 (2003-01-25) [umoeller]
     2446 */
     2447
     2448MRESULT winhHandleScrollerMsgs(HWND hwnd2Scroll,        // in: "client" window
     2449                               PSCROLLABLEWINDOW pscrw, // in: scroller data
     2450                               PSIZEL pszlWin,
     2451                               ULONG msg,
     2452                               MPARAM mp1,
     2453                               MPARAM mp2)
     2454{
     2455    MRESULT mrc = 0;
     2456    POINTL  ptlScroll = {0, 0};
     2457
     2458    switch (msg)
     2459    {
     2460        case WM_VSCROLL:
     2461            if (ptlScroll.y = winhHandleScrollMsg(pscrw->hwndVScroll,
     2462                                                  &pscrw->ptlScrollOfs.y,
     2463                                                  pszlWin->cy,
     2464                                                  pscrw->szlWorkarea.cy,
     2465                                                  10,
     2466                                                  msg,
     2467                                                  mp2))
     2468                winhScrollWindow(hwnd2Scroll,
     2469                                 NULL,
     2470                                 &ptlScroll);
     2471        break;
     2472
     2473        case WM_HSCROLL:
     2474            if (ptlScroll.x = winhHandleScrollMsg(pscrw->hwndHScroll,
     2475                                                  &pscrw->ptlScrollOfs.x,
     2476                                                  pszlWin->cx,
     2477                                                  pscrw->szlWorkarea.cx,
     2478                                                  10,
     2479                                                  msg,
     2480                                                  mp2))
     2481                winhScrollWindow(hwnd2Scroll,
     2482                                 NULL,
     2483                                 &ptlScroll);
     2484        break;
     2485
     2486        case WM_CHAR:
     2487            mrc = (MRESULT)winhProcessScrollChars(hwnd2Scroll,
     2488                                                  pscrw->hwndVScroll,
     2489                                                  pscrw->hwndHScroll,
     2490                                                  mp1,
     2491                                                  mp2,
     2492                                                  pscrw->szlWorkarea.cy,
     2493                                                  pscrw->szlWorkarea.cx);
     2494        break;
     2495    }
     2496
     2497    return mrc;
    25352498}
    25362499
     
    37633726
    37643727    return hswitch;
     3728}
     3729
     3730/*
     3731 *@@ winhUpdateTasklist:
     3732 *      refreshes the task list entry for the given
     3733 *      window with a new title text.
     3734 *
     3735 *@@added V1.0.1 (2003-01-25) [umoeller]
     3736 */
     3737
     3738BOOL winhUpdateTasklist(HWND hwnd,
     3739                        PCSZ pcszNewTitle)
     3740{
     3741    HSWITCH hsw;
     3742    if (hsw = WinQuerySwitchHandle(hwnd, 0))
     3743    {
     3744        SWCNTRL swc;
     3745        WinQuerySwitchEntry(hsw, &swc);
     3746        strhncpy0(swc.szSwtitle,
     3747                  pcszNewTitle,
     3748                  sizeof(swc.szSwtitle));
     3749        return !WinChangeSwitchEntry(hsw, &swc);
     3750    }
     3751
     3752    return FALSE;
    37653753}
    37663754
Note: See TracChangeset for help on using the changeset viewer.