- Timestamp:
- Oct 7, 1999, 5:46:30 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/header.c
r1156 r1170 1 /* $Id: header.c,v 1.1 5 1999-10-06 15:41:10 cbratschi Exp $ */1 /* $Id: header.c,v 1.16 1999-10-07 15:46:30 cbratschi Exp $ */ 2 2 /* 3 3 * Header control … … 11 11 * - Control specific cursors (over dividers). 12 12 * - Custom draw support (including Notifications). 13 * - Drag and Drop support (including Notifications).14 13 * - HDS_FILTERBAR 15 14 * … … 379 378 rect.right = x+1; 380 379 InvertRect(hdc,&rect); 381 /* //CB: Odin bug!!! This code doesn't work:382 hOldPen = SelectObject (hdc, GetStockObject (BLACK_PEN));383 oldRop = SetROP2 (hdc, R2_XORPEN);384 MoveToEx (hdc, x, rect.top, NULL);385 LineTo (hdc, x, rect.bottom);386 SetROP2 (hdc, oldRop);387 SelectObject (hdc, hOldPen);388 */389 380 } 390 381 … … 432 423 433 424 if (infoPtr->bCaptured && infoPtr->bTracking && !(dwStyle & HDS_FULLDRAG)) HEADER_DrawTrackLine(hwnd,hdc,infoPtr->xOldTrack); 425 426 if (infoPtr->bDragDrop) 427 { 428 if (infoPtr->iDragItem != infoPtr->iMoveItem && infoPtr->iDragItem != infoPtr->iMoveItem+1 && infoPtr->iDragItem != -1) 429 { 430 INT x,y,width; 431 HPEN hPen = CreatePen(PS_DOT,0,GetSysColor(COLOR_HIGHLIGHT)),hOldPen; 432 INT oldBkMode = SetBkMode(hdc,TRANSPARENT); 433 434 hOldPen = SelectObject(hdc,hPen); 435 if (infoPtr->iDragItem == infoPtr->uNumItem) 436 { 437 x = infoPtr->items[infoPtr->uNumItem-1].rect.right-1; 438 width = 2; 439 } else if (infoPtr->iDragItem == 0) 440 { 441 x = infoPtr->items[0].rect.left; 442 width = 1; 443 } else 444 { 445 x = infoPtr->items[infoPtr->iDragItem].rect.left-2; 446 width = 3; 447 } 448 449 for (y = 0;y < width;y++) 450 { 451 MoveToEx(hdc,x,0,NULL); 452 LineTo(hdc,x,rect.bottom); 453 x++; 454 } 455 SetBkMode(hdc,oldBkMode); 456 SelectObject(hdc,hOldPen); 457 DeleteObject(hPen); 458 } 459 ImageList_Draw(infoPtr->dragImage,0,hdc,infoPtr->items[infoPtr->iMoveItem].rect.left+infoPtr->dragPos.x-infoPtr->dragStart.x,0,ILD_NORMAL); 460 } 434 461 } 435 462 … … 865 892 { 866 893 HEADER_INFO *infoPtr = HEADER_GetInfoPtr(hwnd); 867 868 //CB:todo 869 //HDN_FILTERCHANGE 870 871 return 0; 894 INT iItem = (INT)lParam; 895 896 if (iItem == -1) 897 { 898 INT x; 899 900 for (x = 0;x < infoPtr->uNumItem;x++) 901 { 902 //CB:todo 903 } 904 } else 905 { 906 if ((iItem < 0) || (iItem >= (INT)infoPtr->uNumItem)) return iItem; 907 908 //CB:todo 909 } 910 911 HEADER_SendFilterChange(hwnd,-1); 912 913 return iItem; 872 914 } 873 915 … … 879 921 880 922 if ((iItem < 0) || (iItem >= (INT)infoPtr->uNumItem)) return 0; 923 924 if (!lParam) 925 { 926 //CB: save changes 927 928 HEADER_SendFilterChange(hwnd,iItem); 929 } 881 930 882 931 //CB: todo … … 899 948 INT iItem = (INT)wParam; 900 949 HEADER_ITEM *phdi; 901 HICON hicon; 950 RECT oldRect; 951 HDC hdc,hdcBmp; 952 HBITMAP bmp,mask,oldbmp; 953 HBRUSH hbr; 954 HFONT hFont,hOldFont; 902 955 HIMAGELIST himl; 903 956 904 if (!infoPtr->himl || (iItem < 0) || (iItem >= (INT)infoPtr->uNumItem)) return 0; 957 if (iItem < 0 || iItem >= (INT)infoPtr->uNumItem) return 0; 958 905 959 phdi = &infoPtr->items[iItem]; 906 /* 907 hicon = ImageList_GetIcon(infoPtr->himl,phdi->iImage,ILD_BLEND | ILD_TRANSPARENT); 908 if (!hicon) return 0; 909 910 himl = ImageList_Create(); 911 */ 912 //CB: create and return new imagelist 913 914 return 0; 960 oldRect = phdi->rect; 961 phdi->rect.right -= phdi->rect.left; 962 phdi->rect.left = 0; 963 964 hdc = GetDC(hwnd); 965 hFont = infoPtr->hFont ? infoPtr->hFont:GetStockObject(SYSTEM_FONT); 966 hOldFont = SelectObject(hdc,hFont); 967 hdcBmp = CreateCompatibleDC(hdc); 968 bmp = CreateCompatibleBitmap(hdc,phdi->rect.right,phdi->rect.bottom); 969 mask = CreateCompatibleBitmap(hdc,phdi->rect.right,phdi->rect.bottom); 970 oldbmp = SelectObject(hdcBmp,bmp); 971 HEADER_DrawItem(hwnd,hdcBmp,iItem,FALSE,TRUE); 972 SelectObject(hdcBmp,mask); 973 hbr = CreateSolidBrush(RGB(255,255,255)); 974 FillRect(hdcBmp,&phdi->rect,hbr); 975 DeleteObject(hbr); 976 hbr = CreateHatchBrush(HS_DIAGCROSS,RGB(0,0,0)); 977 FillRect(hdcBmp,&phdi->rect,hbr); 978 DeleteObject(hbr); 979 SelectObject(hdcBmp,oldbmp); 980 981 himl = ImageList_Create(phdi->rect.right,phdi->rect.bottom,ILC_COLOR | ILC_MASK,1,0); 982 ImageList_Add(himl,bmp,mask); 983 984 DeleteObject(bmp); 985 DeleteObject(mask); 986 SelectObject(hdc,hOldFont); 987 DeleteDC(hdcBmp); 988 ReleaseDC(hwnd,hdc); 989 phdi->rect = oldRect; 990 991 return (LRESULT)himl; 915 992 } 916 993 … … 918 995 HEADER_SetHotDivider(HWND hwnd,WPARAM wParam,LPARAM lParam) 919 996 { 920 //CB:todo 997 if (wParam) 998 { 999 //CB:todo 1000 } else 1001 { 1002 //CB:todo 1003 } 921 1004 922 1005 return 0; … … 1131 1214 HEADER_GetOrderArray(HWND hwnd,WPARAM wParam,LPARAM lParam) 1132 1215 { 1216 HEADER_INFO *infoPtr = HEADER_GetInfoPtr(hwnd); 1217 LPINT lpiArray = (LPINT)lParam; 1218 1219 if (wParam != infoPtr->uNumItem || !lpiArray) return FALSE; 1220 1133 1221 //CB: todo 1134 1222 1135 return 0;1223 return TRUE; 1136 1224 } 1137 1225 … … 1139 1227 HEADER_SetOrderArray(HWND hwnd,WPARAM wParam,LPARAM lParam) 1140 1228 { 1229 HEADER_INFO *infoPtr = HEADER_GetInfoPtr(hwnd); 1230 LPINT lpiArray = (LPINT)lParam; 1231 1232 if (wParam != infoPtr->uNumItem || !lpiArray) return FALSE; 1233 1141 1234 //CB: todo 1142 1235 HEADER_SetItemBounds(hwnd,0); 1143 1236 HEADER_Refresh(hwnd); 1144 1237 1145 return 0;1238 return TRUE; 1146 1239 } 1147 1240 … … 1149 1242 HEADER_OrderToIndex(HWND hwnd,WPARAM wParam,LPARAM lParam) 1150 1243 { 1151 //CB:todo 1152 1153 return 0; 1244 HEADER_INFO *infoPtr = HEADER_GetInfoPtr(hwnd); 1245 INT iOrder = (INT)wParam; 1246 INT x; 1247 1248 for (x = 0;x < infoPtr->uNumItem;x++) 1249 { 1250 //CB:todo 1251 } 1252 1253 return iOrder; 1154 1254 } 1155 1255 … … 1668 1768 infoPtr->bPressed = TRUE; 1669 1769 infoPtr->iMoveItem = nItem; 1770 infoPtr->dragStart = pt; 1771 infoPtr->iDragItem = nItem; 1670 1772 1671 1773 infoPtr->items[nItem].bDown = TRUE; … … 1721 1823 if (infoPtr->bPressed) 1722 1824 { 1723 if (PtInRect(&infoPtr->items[infoPtr->iMoveItem].rect,pt)) 1724 { 1725 infoPtr->items[infoPtr->iMoveItem].bDown = FALSE; 1726 hdc = GetDC(hwnd); 1727 HEADER_RefreshItem(hwnd,hdc,infoPtr->iMoveItem); 1728 ReleaseDC(hwnd,hdc); 1729 1730 HEADER_SendItemClick(hwnd,infoPtr->iMoveItem,0); 1825 if (infoPtr->bDragDrop) 1826 { 1827 infoPtr->items[infoPtr->iMoveItem].bDown = FALSE; 1828 infoPtr->bDragDrop = FALSE; 1829 ImageList_Destroy(infoPtr->dragImage); 1830 infoPtr->dragImage = NULL; 1831 1832 if (!HEADER_SendDragNotify(hwnd,HDN_ENDDRAG,infoPtr->iMoveItem,0) && infoPtr->iDragItem != infoPtr->iMoveItem && infoPtr->iDragItem != infoPtr->iMoveItem+1 && infoPtr->iDragItem != -1) 1833 { 1834 HEADER_ITEM tmpItem = infoPtr->items[infoPtr->iMoveItem];; 1835 1836 //CB: notificatons?? 1837 1838 if (infoPtr->iDragItem > infoPtr->iMoveItem) 1839 { 1840 INT x ; 1841 1842 for (x = infoPtr->iMoveItem;x < infoPtr->iDragItem-1;x++) 1843 memcpy(&infoPtr->items[x],&infoPtr->items[x+1],sizeof(HEADER_ITEM)); 1844 1845 infoPtr->items[infoPtr->iDragItem-1] = tmpItem; 1846 } else 1847 { 1848 INT x; 1849 1850 for (x = infoPtr->iMoveItem;x > infoPtr->iDragItem;x--) 1851 memcpy(&infoPtr->items[x],&infoPtr->items[x-1],sizeof(HEADER_ITEM)); 1852 1853 infoPtr->items[infoPtr->iDragItem] = tmpItem; 1854 } 1855 1856 HEADER_SetItemBounds(hwnd,0); 1731 1857 } 1858 HEADER_Refresh(hwnd); 1859 } else if (PtInRect(&infoPtr->items[infoPtr->iMoveItem].rect,pt)) 1860 { 1861 infoPtr->items[infoPtr->iMoveItem].bDown = FALSE; 1862 hdc = GetDC(hwnd); 1863 HEADER_RefreshItem(hwnd,hdc,infoPtr->iMoveItem); 1864 ReleaseDC(hwnd,hdc); 1865 1866 HEADER_SendItemClick(hwnd,infoPtr->iMoveItem,0); 1867 } 1732 1868 // TRACE (header, "Released item %d!\n", infoPtr->iMoveItem); 1733 1869 infoPtr->bPressed = FALSE; 1734 1870 } else if (infoPtr->bTracking) 1735 1871 { 1736 1872 // TRACE (header, "End tracking item %d!\n", infoPtr->iMoveItem); 1737 infoPtr->bTracking = FALSE; 1738 1739 HEADER_SendEndTrack(hwnd,infoPtr->iMoveItem,0); 1740 1741 if (!(dwStyle & HDS_FULLDRAG)) 1742 { 1743 hdc = GetDC (hwnd); 1744 HEADER_DrawTrackLine (hwnd, hdc, infoPtr->xOldTrack); 1745 ReleaseDC (hwnd, hdc); 1746 if (HEADER_SendItemChanging(hwnd,infoPtr->iMoveItem)) 1747 infoPtr->items[infoPtr->iMoveItem].cxy = infoPtr->nOldWidth; 1748 else 1749 { 1750 nWidth = pt.x - infoPtr->items[infoPtr->iMoveItem].rect.left + infoPtr->xTrackOffset; 1751 if (nWidth < MIN_ITEMWIDTH) nWidth = MIN_ITEMWIDTH; 1752 1753 if (infoPtr->nOldWidth != nWidth) 1754 { 1755 infoPtr->items[infoPtr->iMoveItem].cxy = nWidth; 1756 HEADER_SendItemChanged(hwnd,infoPtr->iMoveItem); 1757 1758 HEADER_SetItemBounds (hwnd,infoPtr->iMoveItem); 1759 1760 HEADER_Refresh(hwnd); 1761 } 1762 } 1873 infoPtr->bTracking = FALSE; 1874 1875 HEADER_SendEndTrack(hwnd,infoPtr->iMoveItem,0); 1876 1877 if (!(dwStyle & HDS_FULLDRAG)) 1878 { 1879 hdc = GetDC (hwnd); 1880 HEADER_DrawTrackLine (hwnd, hdc, infoPtr->xOldTrack); 1881 ReleaseDC (hwnd, hdc); 1882 if (HEADER_SendItemChanging(hwnd,infoPtr->iMoveItem)) 1883 infoPtr->items[infoPtr->iMoveItem].cxy = infoPtr->nOldWidth; 1884 else 1885 { 1886 nWidth = pt.x - infoPtr->items[infoPtr->iMoveItem].rect.left + infoPtr->xTrackOffset; 1887 if (nWidth < MIN_ITEMWIDTH) nWidth = MIN_ITEMWIDTH; 1888 1889 if (infoPtr->nOldWidth != nWidth) 1890 { 1891 infoPtr->items[infoPtr->iMoveItem].cxy = nWidth; 1892 HEADER_SendItemChanged(hwnd,infoPtr->iMoveItem); 1893 1894 HEADER_SetItemBounds (hwnd,infoPtr->iMoveItem); 1895 1896 HEADER_Refresh(hwnd); 1897 } 1763 1898 } 1899 } 1764 1900 } 1765 1901 … … 1774 1910 } 1775 1911 1912 static INT 1913 HEADER_DragHitTest(HWND hwnd,HEADER_INFO* infoPtr,POINT pt) 1914 { 1915 RECT rect; 1916 INT x,xDrag; 1917 1918 GetClientRect(hwnd,&rect); 1919 if (pt.y < rect.top || pt.y > rect.bottom) return -1; 1920 1921 xDrag = infoPtr->items[infoPtr->iMoveItem].rect.left+pt.x-infoPtr->dragStart.x; 1922 1923 if (xDrag < infoPtr->items[0].rect.left) return 0; 1924 1925 for (x = 0;x < infoPtr->uNumItem;x++) 1926 { 1927 if (xDrag >= infoPtr->items[x].rect.left && xDrag <= infoPtr->items[x].rect.right) return x; 1928 } 1929 1930 return infoPtr->uNumItem; 1931 } 1776 1932 1777 1933 static LRESULT … … 1789 1945 HEADER_InternalHitTest (hwnd, &pt, &flags, &nItem); 1790 1946 1791 if (dwStyle & HDS_BUTTONS && dwStyle & HDS_HOTTRACK) //CB: check with no buttons1947 if (dwStyle & HDS_BUTTONS && dwStyle & HDS_HOTTRACK) 1792 1948 { 1793 1949 INT newItem; … … 1822 1978 if (infoPtr->bPressed) 1823 1979 { 1824 if (dwStyle & HDS_DRAGDROP && (infoPtr->bDragDrop || !HEADER_SendDragNotify(hwnd,HDN_BEGINDRAG,infoPtr->iMoveItem,0)))1980 if (dwStyle & HDS_DRAGDROP && infoPtr->uNumItem > 1 && (infoPtr->bDragDrop || !HEADER_SendDragNotify(hwnd,HDN_BEGINDRAG,infoPtr->iMoveItem,0))) 1825 1981 { 1826 1982 if (!infoPtr->bDragDrop) 1827 1983 { 1828 1984 infoPtr->bDragDrop = TRUE; 1829 infoPtr->dragImage = (HIMAGELIST)HEADER_CreateDragImage(hwnd, 0,0);1985 infoPtr->dragImage = (HIMAGELIST)HEADER_CreateDragImage(hwnd,infoPtr->iMoveItem,0); 1830 1986 } 1831 //CB:todo 1987 infoPtr->dragPos = pt; 1988 infoPtr->iDragItem = HEADER_DragHitTest(hwnd,infoPtr,pt); 1989 HEADER_Refresh(hwnd); 1832 1990 } else 1833 1991 { … … 1927 2085 HDC hdc; 1928 2086 1929 if (wParam == VK_ESCAPE && infoPtr->bCaptured && infoPtr->bTracking)2087 if (wParam == VK_ESCAPE && infoPtr->bCaptured) 1930 2088 { 1931 i nfoPtr->bTracking = FALSE;1932 1933 HEADER_SendEndTrack(hwnd,infoPtr->iMoveItem,0);1934 hdc = GetDC(hwnd);1935 HEADER_DrawTrackLine(hwnd,hdc,infoPtr->xOldTrack);1936 ReleaseDC(hwnd,hdc);1937 if (dwStyle & HDS_FULLDRAG)1938 { 1939 infoPtr->items[infoPtr->iMoveItem].cxy = infoPtr->nOldWidth;2089 if (infoPtr->bPressed && infoPtr->bDragDrop) 2090 { 2091 infoPtr->items[infoPtr->iMoveItem].bDown = FALSE; 2092 infoPtr->bPressed = FALSE; 2093 infoPtr->bDragDrop = FALSE; 2094 ImageList_Destroy(infoPtr->dragImage); 2095 infoPtr->dragImage = NULL; 2096 2097 HEADER_SendDragNotify(hwnd,HDN_ENDDRAG,infoPtr->iMoveItem,0); 1940 2098 HEADER_Refresh(hwnd); 2099 2100 } else if (infoPtr->bTracking) 2101 { 2102 infoPtr->bTracking = FALSE; 2103 2104 HEADER_SendEndTrack(hwnd,infoPtr->iMoveItem,0); 2105 2106 if (dwStyle & HDS_FULLDRAG) 2107 { 2108 infoPtr->items[infoPtr->iMoveItem].cxy = infoPtr->nOldWidth; 2109 HEADER_Refresh(hwnd); 2110 } else 2111 { 2112 hdc = GetDC(hwnd); 2113 HEADER_DrawTrackLine(hwnd,hdc,infoPtr->xOldTrack); 2114 ReleaseDC(hwnd,hdc); 2115 } 1941 2116 } 1942 2117 … … 1958 2133 HDC hdc; 1959 2134 1960 if (infoPtr->bCaptured && infoPtr->bTracking) 2135 if (infoPtr->bCaptured && infoPtr->bPressed) 2136 { 2137 infoPtr->items[infoPtr->iMoveItem].bDown = FALSE; 2138 infoPtr->bPressed = FALSE; 2139 if (infoPtr->bDragDrop) 2140 { 2141 infoPtr->bDragDrop = FALSE; 2142 ImageList_Destroy(infoPtr->dragImage); 2143 infoPtr->dragImage = NULL; 2144 2145 HEADER_SendDragNotify(hwnd,HDN_ENDDRAG,infoPtr->iMoveItem,0); 2146 HEADER_Refresh(hwnd); 2147 } else 2148 { 2149 hdc = GetDC(hwnd); 2150 HEADER_RefreshItem(hwnd,hdc,infoPtr->iMoveItem); 2151 ReleaseDC(hwnd,hdc); 2152 } 2153 } else if (infoPtr->bCaptured && infoPtr->bTracking) 1961 2154 { 1962 2155 infoPtr->bTracking = FALSE; 1963 2156 1964 2157 HEADER_SendEndTrack(hwnd,infoPtr->iMoveItem,0); 1965 hdc = GetDC(hwnd); 1966 HEADER_DrawTrackLine(hwnd,hdc,infoPtr->xOldTrack); 1967 ReleaseDC(hwnd,hdc); 2158 1968 2159 if (dwStyle & HDS_FULLDRAG) 1969 2160 { 1970 2161 infoPtr->items[infoPtr->iMoveItem].cxy = infoPtr->nOldWidth; 1971 2162 HEADER_Refresh(hwnd); 2163 } else 2164 { 2165 hdc = GetDC(hwnd); 2166 HEADER_DrawTrackLine(hwnd,hdc,infoPtr->xOldTrack); 2167 ReleaseDC(hwnd,hdc); 1972 2168 } 1973 2169 } 2170 2171 infoPtr->bCaptured = FALSE; 1974 2172 1975 2173 return 0; … … 1994 2192 HEADER_RButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam) 1995 2193 { 1996 return HEADER_SendSimpleNotify (hwnd, NM_RCLICK); 2194 HEADER_SendSimpleNotify(hwnd,NM_RCLICK); 2195 2196 return DefWindowProcA(hwnd,WM_RBUTTONUP,wParam,lParam); 1997 2197 } 1998 2198
Note:
See TracChangeset
for help on using the changeset viewer.