Changeset 374 for branches/branch-1-0/src/helpers/winh.c
- Timestamp:
- Nov 17, 2008, 12:17:05 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1-0/src/helpers/winh.c
r346 r374 19 19 20 20 /* 21 * Copyright (C) 1997-200 6Ulrich Mller.21 * Copyright (C) 1997-2008 Ulrich Mller. 22 22 * This file is part of the "XWorkplace helpers" source package. 23 23 * This is free software; you can redistribute it and/or modify … … 1857 1857 * Terminology: 1858 1858 * 1859 * -- "window": the actual window with scroll bars which displays 1860 * a subrectangle of the available data. With a typical PM 1861 * application, this will be your client window. 1862 * 1863 * The width or height of this must be passed in ulWinPels. 1864 * 1865 * -- "viewport": the entire data to be displayed, of which the 1866 * "window" can only display a subrectangle, if the viewport 1867 * is larger than the window. 1868 * 1869 * The width or height of this must be passed in ulViewportPels. 1870 * This can be smaller than ulWinPels (if the window is larger 1871 * than the data) or the same or larger than ulWinPels 1872 * (if the window is too small to show all the data). 1873 * 1874 * -- "window offset": the offset of the current window within 1875 * the viewport. 1876 * 1877 * For horizontal scroll bars, this is the X coordinate, 1878 * counting from the left of the window (0 means leftmost). 1879 * 1880 * For vertical scroll bars, this is counted from the _top_ 1881 * of the viewport (0 means topmost, as opposed to OS/2 1882 * window coordinates!). This is because for vertical scroll 1883 * bars controls, higher values move the thumb _down_. Yes 1884 * indeed, this conflicts with PM's coordinate system. 1885 * 1886 * The window offset is therefore always positive. 1887 * 1888 * The scroll bar gets disabled if the entire viewport is visible, 1889 * that is, if ulViewportPels <= ulWinPels. In that case 1859 * -- "window": the actual window with scroll bars which displays 1860 * a subrectangle of the available data. With a typical PM 1861 * application, this will be your client window. 1862 * 1863 * The width or height of this must be passed in ulWinPels. 1864 * 1865 * -- "workarea": the entire data to be displayed, of which the 1866 * "window" can only display a subrectangle, if the workarea 1867 * is larger than the window. 1868 * 1869 * The width or height of this must be passed in ulWorkareaPels. 1870 * This can be smaller than ulWinPels (if the window is larger 1871 * than the data) or the same or larger than ulWinPels 1872 * (if the window is too small to show all the data). 1873 * 1874 * This value is exclusive in the sense that the maximum 1875 * window offset (below) can be the workarea minus one. 1876 * 1877 * -- "window offset": the zero-based offset of the current 1878 * window within the workarea, whose maximum value is 1879 * the workarea minus one. 1880 * 1881 * [pr]: I disagree with the above "workarea minus one" stuff. 1882 * It is perfectly possible to have the workarea and the 1883 * window area the same size and to display all the content. 1884 * This also means you do NOT get a disabled scroll bar 1885 * any more when they are the same size. 1886 * 1887 * For horizontal scroll bars, this is the X coordinate, 1888 * counting from the left of the window (0 means leftmost). 1889 * 1890 * For vertical scroll bars, this is counted from the _top_ 1891 * of the workarea (0 means topmost, as opposed to OS/2 1892 * window coordinates!). This is because for vertical scroll 1893 * bars controls, higher values move the thumb _down_. Yes 1894 * indeed, this conflicts with PM's coordinate system. 1895 * 1896 * The window offset is therefore always positive. 1897 * 1898 * The scroll bar gets disabled if the entire workarea is visible, 1899 * that is, if ulWorkareaPels <= ulWinPels. In that case 1890 1900 * FALSE is returned. If (fAutoHide == TRUE), the scroll 1891 1901 * bar is not only disabled, but also hidden from the display. 1892 1902 * In that case, you will need to reformat your output because 1893 * your viewportbecomes larger without the scroll bar.1903 * your workarea becomes larger without the scroll bar. 1894 1904 * 1895 1905 * This function will set the range of the scroll bar to 0 up 1896 * to a value depending on the viewportsize. For vertical scroll1906 * to a value depending on the workarea size. For vertical scroll 1897 1907 * bars, 0 means topmost (which is kinda sick with the OS/2 1898 1908 * coordinate system), for horizontal scroll bars, 0 means leftmost. … … 1900 1910 * The maximum value of the scroll bar will be 1901 1911 * 1902 + (ul ViewportPels - ulWinPels) / usScrollUnitPels1912 + (ulWorkareaPels - ulWinPels) / usScrollUnitPels 1903 1913 * 1904 1914 * The thumb size of the scroll bar will also be adjusted 1905 * based on the viewportand window size, as it should be.1915 * based on the workarea and window size, as it should be. 1906 1916 * 1907 1917 *@@added V0.9.1 (2000-02-14) [umoeller] 1908 1918 *@@changed V0.9.3 (2000-04-30) [umoeller]: fixed pels/unit confusion 1909 1919 *@@changed V0.9.3 (2000-05-08) [umoeller]: now handling scroll units automatically 1920 *@@changed V1.0.1 (2003-01-25) [umoeller]: fixed max value which caused right/bottommost scroll button to never be disabled 1921 *@@changed V1.0.1 (2003-01-25) [umoeller]: fixed bad thumb position for large offsets 1922 *@@changed WarpIN V1.0.18 (2008-11-16) [pr]: fix rounding errors @@fixes 1086 1923 *@@changed WarpIN V1.0.18 (2008-11-16) [pr]: disable scroll bars when workarea = win area @@fixes 1086 1910 1924 */ 1911 1925 … … 1914 1928 // visible window part (in pixels), 1915 1929 // excluding the scroll bar! 1916 ULONG ul ViewportPels, // in: dimension of total data part, of1930 ULONG ulWorkareaPels, // in: dimension of total data part, of 1917 1931 // which ulWinPels is a sub-dimension 1918 1932 // (in pixels); … … 1925 1939 BOOL brc = FALSE; 1926 1940 1927 // _Pmpf(("Entering winhUpdateScrollBar")); 1928 1929 // for large viewports, adjust scroll bar units 1930 USHORT usScrollUnitPels = 1; 1931 if (ulViewportPels > 10000) 1932 usScrollUnitPels = 100; 1933 1934 if (ulViewportPels > ulWinPels) 1935 { 1941 if (ulWorkareaPels > ulWinPels) // WarpIN V1.0.18 1942 { 1943 // for large workareas, adjust scroll bar units 1944 USHORT usDivisor = 1, usRounder; 1945 USHORT lMaxAllowedUnitOfs; 1946 1947 if (ulWorkareaPels > 10000) 1948 usDivisor = 100; 1949 1950 usRounder = usDivisor - 1; // WarpIN V1.0.18 1936 1951 // scrollbar needed: 1937 USHORT usThumbDivisorUnits = usScrollUnitPels; 1938 USHORT lMaxAllowedUnitOfs; 1939 // _Pmpf(("winhUpdateScrollBar: ulViewportPels > ulWinPels, enabling scroller")); 1940 // divisor for thumb size (below) 1941 if (ulViewportPels > 10000) 1942 // for very large viewports, we need to 1943 // raise the divisor, because we only 1944 // have a USHORT 1945 usThumbDivisorUnits = usScrollUnitPels * 100; 1946 1947 // viewport is larger than window: 1952 1953 // workarea is larger than window: 1948 1954 WinEnableWindow(hwndScrollBar, TRUE); 1949 1955 if (fAutoHide) … … 1951 1957 1952 1958 // calculate limit 1953 lMaxAllowedUnitOfs = ((ulViewportPels - ulWinPels + usScrollUnitPels) 1954 // scroll unit is 10 1955 / usScrollUnitPels); 1956 1957 // _Pmpf((" usCurUnitOfs: %d", ulCurUnitOfs)); 1958 // _Pmpf((" usMaxUnits: %d", lMaxAllowedUnitOfs)); 1959 lMaxAllowedUnitOfs = (ulWorkareaPels - ulWinPels + usRounder) 1960 / usDivisor; 1959 1961 1960 1962 // set thumb position and limit 1961 1963 WinSendMsg(hwndScrollBar, 1962 1964 SBM_SETSCROLLBAR, 1963 (MPARAM)( ulCurPelsOfs), // / usThumbDivisorUnits), // position: 0 means top1965 (MPARAM)((ulCurPelsOfs + usRounder) / usDivisor), // position: 0 means top 1964 1966 MPFROM2SHORT(0, // minimum 1965 1967 lMaxAllowedUnitOfs)); // maximum 1966 1968 1967 1969 // set thumb size based on ulWinPels and 1968 // ul ViewportPels1970 // ulWorkareaPels 1969 1971 WinSendMsg(hwndScrollBar, 1970 1972 SBM_SETTHUMBSIZE, 1971 MPFROM2SHORT( ulWinPels / usThumbDivisorUnits, // visible1972 ulViewportPels / usThumbDivisorUnits), // total1973 MPFROM2SHORT( (ulWinPels + usRounder) / usDivisor, // visible 1974 (ulWorkareaPels + usRounder) / usDivisor), // total 1973 1975 0); 1974 1976 brc = TRUE; … … 1976 1978 else 1977 1979 { 1978 // _Pmpf(("winhUpdateScrollBar: ulViewportPels <= ulWinPels")); 1979 // entire viewport is visible: 1980 // entire workarea is visible: 1980 1981 WinEnableWindow(hwndScrollBar, FALSE); 1981 1982 if (fAutoHide) … … 2026 2027 *@@changed V0.9.3 (2000-05-08) [umoeller]: now handling scroll units automatically 2027 2028 *@@changed V0.9.7 (2001-01-17) [umoeller]: changed PLONG to PULONG 2029 *@@changed WarpIN V1.0.18 (2008-11-16) [pr]: fix rounding error @@fixes 1086 2028 2030 */ 2029 2031 … … 2127 2129 WinSendMsg(hwndScrollBar, 2128 2130 SBM_SETPOS, 2129 (MPARAM)(*pulCurPelsOfs / usScrollUnitPels), // / usScrollUnit), 2131 (MPARAM)((*pulCurPelsOfs + (usScrollUnitPels / 2)) / usScrollUnitPels), 2132 (MPARAM)((*pulCurPelsOfs + (usScrollUnitPels / 2)) / usScrollUnitPels), // WarpIN V1.0.18 2130 2133 0); 2131 2134 // scroll window rectangle:
Note:
See TracChangeset
for help on using the changeset viewer.