Changeset 9370 for trunk/src/comctl32/pager.c
- Timestamp:
- Oct 29, 2002, 1:19:36 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/pager.c
r8382 r9370 45 45 INT nPos; /* scroll position */ 46 46 INT nWidth; /* from child wnd's response to PGN_CALCSIZE */ 47 INT nHeight; /* from child wnd's response to PGN_CALCSIZE */ 47 INT nHeight; /* from child wnd's response to PGN_CALCSIZE */ 48 48 BOOL bForward; /* forward WM_MOUSEMOVE msgs to the contained wnd */ 49 BOOL bCapture; /* we have captured the mouse */ 49 50 INT TLbtnState; /* state of top or left btn */ 50 51 INT BRbtnState; /* state of bottom or right btn */ … … 63 64 #define REPEAT_DELAY 50 64 65 65 /* the horizontal arrows are: 66 /* the horizontal arrows are: 66 67 * 67 68 * 01234 01234 … … 72 73 * 5 ** ** 73 74 * 6 * * 74 * 7 75 * 7 75 76 * 76 77 */ … … 79 80 { 80 81 INT x, y, w, h; 81 HPEN h OldPen;82 82 HPEN hPen, hOldPen; 83 83 84 w = r.right - r.left + 1; 84 85 h = r.bottom - r.top + 1; … … 86 87 return; /* refuse to draw partial arrow */ 87 88 88 hOldPen = SelectObject ( hdc, GetSysColorPen (colorRef)); 89 if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return; 90 hOldPen = SelectObject ( hdc, hPen ); 89 91 if (left) 90 92 { … … 111 113 112 114 SelectObject( hdc, hOldPen ); 113 } 114 115 /* the vertical arrows are: 115 DeleteObject( hPen ); 116 } 117 118 /* the vertical arrows are: 116 119 * 117 120 * 01234567 01234567 118 * 1****** ** 121 * 1****** ** 119 122 * 2 **** **** 120 123 * 3 ** ****** … … 126 129 { 127 130 INT x, y, w, h; 128 HPEN h OldPen;129 131 HPEN hPen, hOldPen; 132 130 133 w = r.right - r.left + 1; 131 134 h = r.bottom - r.top + 1; … … 133 136 return; /* refuse to draw partial arrow */ 134 137 135 hOldPen = SelectObject ( hdc, GetSysColorPen (colorRef)); 138 if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return; 139 hOldPen = SelectObject ( hdc, hPen ); 136 140 if (up) 137 141 { … … 158 162 159 163 SelectObject( hdc, hOldPen ); 164 DeleteObject( hPen ); 160 165 } 161 166 … … 171 176 172 177 if ((rc.right - rc.left <= 0) || (rc.bottom - rc.top <= 0)) 173 return; 178 return; 174 179 175 180 hBrush = CreateSolidBrush(clrBk); … … 178 183 FillRect(hdc, &rc, hBrush); 179 184 180 if (btnState == PGF_HOT) 185 if (btnState == PGF_HOT) 181 186 { 182 187 DrawEdge( hdc, &rc, BDR_RAISEDINNER, BF_RECT); … … 186 191 PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft); 187 192 } 188 else if (btnState == PGF_NORMAL) 193 else if (btnState == PGF_NORMAL) 189 194 { 190 195 DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT); … … 194 199 PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft); 195 200 } 196 else if (btnState == PGF_DEPRESSED) 201 else if (btnState == PGF_DEPRESSED) 197 202 { 198 203 DrawEdge( hdc, &rc, BDR_SUNKENOUTER, BF_RECT); … … 202 207 PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft); 203 208 } 204 else if (btnState == PGF_GRAYED) 209 else if (btnState == PGF_GRAYED) 205 210 { 206 211 DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT); … … 223 228 } 224 229 230 static void PAGER_CaptureandTrack(PAGER_INFO *infoPtr, HWND hwnd) 231 { 232 TRACKMOUSEEVENT trackinfo; 233 234 TRACE("[%p] SetCapture\n", hwnd); 235 SetCapture(hwnd); 236 infoPtr->bCapture = TRUE; 237 238 trackinfo.cbSize = sizeof(TRACKMOUSEEVENT); 239 trackinfo.dwFlags = TME_QUERY; 240 trackinfo.hwndTrack = hwnd; 241 trackinfo.dwHoverTime = HOVER_DEFAULT; 242 243 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */ 244 _TrackMouseEvent(&trackinfo); 245 246 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */ 247 if(!(trackinfo.dwFlags & TME_LEAVE)) { 248 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */ 249 250 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */ 251 /* and can properly deactivate the hot button */ 252 _TrackMouseEvent(&trackinfo); 253 } 254 } 255 256 225 257 /* << PAGER_GetDropTarget >> */ 226 258 … … 229 261 { 230 262 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 231 TRACE("[% 04x]\n", hwnd);263 TRACE("[%p]\n", hwnd); 232 264 233 265 infoPtr->bForward = (BOOL)wParam; … … 239 271 PAGER_GetButtonState (HWND hwnd, WPARAM wParam, LPARAM lParam) 240 272 { 241 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 273 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 242 274 LRESULT btnState = PGF_INVISIBLE; 243 275 INT btn = (INT)lParam; 244 TRACE("[% 04x]\n", hwnd);276 TRACE("[%p]\n", hwnd); 245 277 246 278 if (btn == PGB_TOPORLEFT) … … 256 288 PAGER_GetPos(HWND hwnd) 257 289 { 258 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 259 TRACE("[% 04x] returns %d\n", hwnd, infoPtr->nPos);290 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 291 TRACE("[%p] returns %d\n", hwnd, infoPtr->nPos); 260 292 return (LRESULT)infoPtr->nPos; 261 293 } … … 264 296 PAGER_GetButtonSize(HWND hwnd) 265 297 { 266 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 267 TRACE("[% 04x] returns %d\n", hwnd, infoPtr->nButtonSize);298 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 299 TRACE("[%p] returns %d\n", hwnd, infoPtr->nButtonSize); 268 300 return (LRESULT)infoPtr->nButtonSize; 269 301 } … … 272 304 PAGER_GetBorder(HWND hwnd) 273 305 { 274 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 275 TRACE("[% 04x] returns %d\n", hwnd, infoPtr->nBorder);306 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 307 TRACE("[%p] returns %d\n", hwnd, infoPtr->nBorder); 276 308 return (LRESULT)infoPtr->nBorder; 277 309 } … … 280 312 PAGER_GetBkColor(HWND hwnd) 281 313 { 282 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 283 TRACE("[% 04x] returns %06lx\n", hwnd, infoPtr->clrBk);314 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 315 TRACE("[%p] returns %06lx\n", hwnd, infoPtr->clrBk); 284 316 return (LRESULT)infoPtr->clrBk; 285 317 } 286 318 287 static void 288 PAGER_CalcSize (HWND hwnd, INT* size, BOOL getWidth) 319 static void 320 PAGER_CalcSize (HWND hwnd, INT* size, BOOL getWidth) 289 321 { 290 322 NMPGCALCSIZE nmpgcs; … … 301 333 *size = getWidth ? nmpgcs.iWidth : nmpgcs.iHeight; 302 334 303 TRACE("[% 04x] PGN_CALCSIZE returns %s=%d\n", hwnd,335 TRACE("[%p] PGN_CALCSIZE returns %s=%d\n", hwnd, 304 336 getWidth ? "width" : "height", *size); 305 337 } … … 325 357 infoPtr->nWidth = wndSize; 326 358 327 TRACE("[% 04x] SWP %dx%d at (%d,%d)\n", hwnd,359 TRACE("[%p] SWP %dx%d at (%d,%d)\n", hwnd, 328 360 infoPtr->nWidth, infoPtr->nHeight, 329 361 -nPos, 0); … … 339 371 infoPtr->nHeight = wndSize; 340 372 341 TRACE("[% 04x] SWP %dx%d at (%d,%d)\n", hwnd,373 TRACE("[%p] SWP %dx%d at (%d,%d)\n", hwnd, 342 374 infoPtr->nWidth, infoPtr->nHeight, 343 375 0, -nPos); … … 381 413 } 382 414 383 TRACE("[% 04x] returns %d\n", hwnd, scrollRange);415 TRACE("[%p] returns %d\n", hwnd, scrollRange); 384 416 return scrollRange; 385 417 } 386 418 387 static void 419 static void 388 420 PAGER_GrayAndRestoreBtns(PAGER_INFO* infoPtr, INT scrollRange, 389 421 BOOL* needsResize, BOOL* needsRepaint) … … 422 454 423 455 424 static void 456 static void 425 457 PAGER_NormalizeBtns(PAGER_INFO* infoPtr, BOOL* needsRepaint) 426 458 { … … 438 470 } 439 471 440 static void 472 static void 441 473 PAGER_HideGrayBtns(PAGER_INFO* infoPtr, BOOL* needsResize) 442 474 { … … 470 502 471 503 if (resizeClient) /* initiate NCCalcSize to resize client wnd */ { 472 SetWindowPos(hwnd, 0,0,0,0,0, 504 SetWindowPos(hwnd, 0,0,0,0,0, 473 505 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | 474 506 SWP_NOZORDER | SWP_NOACTIVATE); … … 476 508 477 509 if (repaintBtns) 478 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 479 } 480 481 static LRESULT 510 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 511 } 512 513 static LRESULT 482 514 PAGER_SetPos(HWND hwnd, INT newPos, BOOL fromBtnPress) 483 515 { … … 493 525 infoPtr->nPos = newPos; 494 526 495 TRACE("[% 04x] pos=%d\n", hwnd, infoPtr->nPos);527 TRACE("[%p] pos=%d, oldpos=%d\n", hwnd, infoPtr->nPos, oldPos); 496 528 497 529 if (infoPtr->nPos != oldPos) … … 537 569 } 538 570 539 static INT 571 static INT 540 572 PAGER_SetFixedWidth(HWND hwnd, PAGER_INFO* infoPtr) 541 573 { … … 562 594 h = wndRect.bottom - wndRect.top + infoPtr->nButtonSize; 563 595 564 TRACE("[% 04x] infoPtr->nWidth set to %d\n",596 TRACE("[%p] infoPtr->nWidth set to %d\n", 565 597 hwnd, infoPtr->nWidth); 566 598 … … 568 600 } 569 601 570 static INT 602 static INT 571 603 PAGER_SetFixedHeight(HWND hwnd, PAGER_INFO* infoPtr) 572 604 { … … 593 625 w = wndRect.right - wndRect.left + infoPtr->nButtonSize; 594 626 595 TRACE("[% 04x] infoPtr->nHeight set to %d\n",627 TRACE("[%p] infoPtr->nHeight set to %d\n", 596 628 hwnd, infoPtr->nHeight); 597 629 … … 616 648 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 617 649 618 TRACE("[% 04x]\n", hwnd);650 TRACE("[%p]\n", hwnd); 619 651 620 652 if (infoPtr->hwndChild) … … 627 659 PAGER_SetPos(hwnd, 0, FALSE); 628 660 } 629 else 661 else 630 662 { 631 663 PAGER_UpdateBtns(hwnd, infoPtr, scrollRange, TRUE); … … 645 677 646 678 infoPtr->clrBk = (COLORREF)lParam; 647 TRACE("[% 04x] %06lx\n", hwnd, infoPtr->clrBk);679 TRACE("[%p] %06lx\n", hwnd, infoPtr->clrBk); 648 680 649 681 /* the native control seems to do things this way */ 650 SetWindowPos(hwnd, 0,0,0,0,0, 682 SetWindowPos(hwnd, 0,0,0,0,0, 651 683 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | 652 684 SWP_NOZORDER | SWP_NOACTIVATE); … … 665 697 666 698 infoPtr->nBorder = (INT)lParam; 667 TRACE("[% 04x] %d\n", hwnd, infoPtr->nBorder);699 TRACE("[%p] %d\n", hwnd, infoPtr->nBorder); 668 700 669 701 PAGER_RecalcSize(hwnd); … … 680 712 681 713 infoPtr->nButtonSize = (INT)lParam; 682 TRACE("[% 04x] %d\n", hwnd, infoPtr->nButtonSize);714 TRACE("[%p] %d\n", hwnd, infoPtr->nButtonSize); 683 715 684 716 PAGER_RecalcSize(hwnd); … … 698 730 if (infoPtr->hwndChild) 699 731 { 700 TRACE("[% 04x] hwndChild=%04x\n", hwnd, infoPtr->hwndChild);732 TRACE("[%p] hwndChild=%p\n", hwnd, infoPtr->hwndChild); 701 733 702 734 if (PAGER_IsHorizontal(hwnd)) { 703 735 hw = PAGER_SetFixedHeight(hwnd, infoPtr); 704 736 /* adjust non-scrollable dimension to fit the child */ 705 SetWindowPos(hwnd, 0, 0,0, hw, infoPtr->nHeight, 737 SetWindowPos(hwnd, 0, 0,0, hw, infoPtr->nHeight, 706 738 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER | 707 739 SWP_NOSIZE | SWP_NOACTIVATE); … … 710 742 hw = PAGER_SetFixedWidth(hwnd, infoPtr); 711 743 /* adjust non-scrollable dimension to fit the child */ 712 SetWindowPos(hwnd, 0, 0,0, infoPtr->nWidth, hw, 744 SetWindowPos(hwnd, 0, 0,0, infoPtr->nWidth, hw, 713 745 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER | 714 746 SWP_NOSIZE | SWP_NOACTIVATE); … … 741 773 nmpgScroll.hdr.code = PGN_SCROLL; 742 774 743 GetWindowRect(hwnd, &rcWnd); 744 GetClientRect(hwnd, &nmpgScroll.rcParent); 775 GetWindowRect(hwnd, &rcWnd); 776 GetClientRect(hwnd, &nmpgScroll.rcParent); 745 777 nmpgScroll.iXpos = nmpgScroll.iYpos = 0; 746 778 nmpgScroll.iDir = dir; … … 757 789 } 758 790 nmpgScroll.iScroll -= 2*infoPtr->nButtonSize; 759 760 SendMessageA ( hwnd, WM_NOTIFY,791 792 SendMessageA (GetParent(hwnd), WM_NOTIFY, 761 793 (WPARAM)nmpgScroll.hdr.idFrom, (LPARAM)&nmpgScroll); 762 763 TRACE("[% 04x] PGN_SCROLL returns iScroll=%d\n", hwnd, nmpgScroll.iScroll);794 795 TRACE("[%p] PGN_SCROLL returns iScroll=%d\n", hwnd, nmpgScroll.iScroll); 764 796 765 797 if (nmpgScroll.iScroll > 0) … … 783 815 784 816 /* initiate NCCalcSize to resize client wnd and get size */ 785 SetWindowPos(hwnd, 0, 0,0,0,0, 817 SetWindowPos(hwnd, 0, 0,0,0,0, 786 818 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | 787 819 SWP_NOZORDER | SWP_NOACTIVATE); 788 820 789 SetWindowPos(infoPtr->hwndChild, 0, 790 0,0,infoPtr->nWidth,infoPtr->nHeight, 821 SetWindowPos(infoPtr->hwndChild, 0, 822 0,0,infoPtr->nWidth,infoPtr->nHeight, 791 823 0); 792 824 … … 814 846 infoPtr->nHeight = 0; 815 847 infoPtr->bForward = FALSE; 848 infoPtr->bCapture = FALSE; 816 849 infoPtr->TLbtnState = PGF_INVISIBLE; 817 850 infoPtr->BRbtnState = PGF_INVISIBLE; 818 851 infoPtr->direction = -1; 819 852 820 if (dwStyle & PGS_AUTOSCROLL)821 FIXME("[%04x] Autoscroll style is not implemented yet.\n", hwnd);822 853 if (dwStyle & PGS_DRAGNDROP) 823 FIXME("[% 04x] Drag and Drop style is not implemented yet.\n", hwnd);854 FIXME("[%p] Drag and Drop style is not implemented yet.\n", hwnd); 824 855 /* 825 856 * If neither horizontal nor vertical style specified, default to vertical. … … 852 883 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 853 884 LPRECT lpRect = (LPRECT)lParam; 854 RECT rcChildw, rcmyw, wnrc, l brc, rbrc;885 RECT rcChildw, rcmyw, wnrc, ltrc, rbrc; 855 886 POINT cursor; 856 887 BOOL resizeClient = FALSE; … … 860 891 /* 861 892 * lParam points to a RECT struct. On entry, the struct 862 * contains the proposed wnd rectangle for the window. 893 * contains the proposed wnd rectangle for the window. 863 894 * On exit, the struct should contain the screen 864 895 * coordinates of the corresponding window's client area. 865 896 */ 866 897 867 898 DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam); 868 899 … … 882 913 scrollRange = infoPtr->nWidth - (rcmyw.right - rcmyw.left); 883 914 884 TRACE("nPos=%d, scrollrange=%d, nWidth=%d, myw=(%d,%d)-(%d,%d)\n", 885 infoPtr->nPos, scrollRange, infoPtr->nWidth, 886 rcmyw.left, rcmyw.top, rcmyw.right, rcmyw.bottom); 915 TRACE("nPos=%d, scrollrange=%d, nHeigth=%d, myw=(%d,%d)-(%d,%d), cursor=(%ld,%ld)\n", 916 infoPtr->nPos, scrollRange, infoPtr->nHeight, 917 rcmyw.left, rcmyw.top, 918 rcmyw.right, rcmyw.bottom, 919 cursor.x, cursor.y); 887 920 PAGER_GrayAndRestoreBtns(infoPtr, scrollRange, &resizeClient, &repaintBtns); 888 921 PAGER_HideGrayBtns(infoPtr, &resizeClient); … … 890 923 if (PtInRect (&rcmyw, cursor)) { 891 924 GetWindowRect (hwnd, &wnrc); 892 l brc = wnrc;893 l brc.right = lbrc.left + infoPtr->nButtonSize;925 ltrc = wnrc; 926 ltrc.right = ltrc.left + infoPtr->nButtonSize; 894 927 rbrc = wnrc; 895 928 rbrc.left = rbrc.right - infoPtr->nButtonSize; 896 TRACE("horz l brect=(%d,%d)-(%d,%d), rb rect=(%d,%d)-(%d,%d)\n",897 l brc.left, lbrc.top, lbrc.right, lbrc.bottom,929 TRACE("horz lt rect=(%d,%d)-(%d,%d), rb rect=(%d,%d)-(%d,%d)\n", 930 ltrc.left, ltrc.top, ltrc.right, ltrc.bottom, 898 931 rbrc.left, rbrc.top, rbrc.right, rbrc.bottom); 899 if (PtInRect (&l brc, cursor) && infoPtr->TLbtnState)932 if (PtInRect (<rc, cursor) && infoPtr->TLbtnState) 900 933 RedrawWindow (hwnd, 0, 0, RDW_INVALIDATE | RDW_ERASE); 901 934 if (PtInRect (&rbrc, cursor) && infoPtr->BRbtnState) … … 909 942 else 910 943 { 911 /* native does: (from trace of IE4 opening "Favorites" frame) 944 /* native does: (from trace of IE4 opening "Favorites" frame) 912 945 * DefWindowProc 913 946 * WM_NOITFY PGN_CALCSIZE w/ dwFlag=2 … … 929 962 scrollRange = infoPtr->nHeight - (rcmyw.bottom - rcmyw.top); 930 963 931 TRACE("nPos=%d, scrollrange=%d, nHeigth=%d, myw=(%d,%d)-(%d,%d) \n",964 TRACE("nPos=%d, scrollrange=%d, nHeigth=%d, myw=(%d,%d)-(%d,%d), cursor=(%ld,%ld)\n", 932 965 infoPtr->nPos, scrollRange, infoPtr->nHeight, 933 966 rcmyw.left, rcmyw.top, 934 rcmyw.right, rcmyw.bottom); 967 rcmyw.right, rcmyw.bottom, 968 cursor.x, cursor.y); 935 969 PAGER_GrayAndRestoreBtns(infoPtr, scrollRange, &resizeClient, &repaintBtns); 936 970 PAGER_HideGrayBtns(infoPtr, &resizeClient); … … 949 983 950 984 GetWindowRect (hwnd, &wnrc); 951 l brc = wnrc;952 l brc.right = lbrc.left + infoPtr->nButtonSize;985 ltrc = wnrc; 986 ltrc.right = ltrc.left + infoPtr->nButtonSize; 953 987 rbrc = wnrc; 954 988 rbrc.left = rbrc.right - infoPtr->nButtonSize; 955 TRACE("vert l brect=(%d,%d)-(%d,%d), rb rect=(%d,%d)-(%d,%d)\n",956 l brc.left, lbrc.top, lbrc.right, lbrc.bottom,989 TRACE("vert lt rect=(%d,%d)-(%d,%d), rb rect=(%d,%d)-(%d,%d)\n", 990 ltrc.left, ltrc.top, ltrc.right, ltrc.bottom, 957 991 rbrc.left, rbrc.top, rbrc.right, rbrc.bottom); 958 if (PtInRect (&l brc, cursor) && infoPtr->TLbtnState)992 if (PtInRect (<rc, cursor) && infoPtr->TLbtnState) 959 993 RedrawWindow (hwnd, 0, 0, RDW_INVALIDATE | RDW_ERASE); 960 994 if (PtInRect (&rbrc, cursor) && infoPtr->BRbtnState) … … 970 1004 } 971 1005 972 TRACE("[% 04x] client rect set to %dx%d at (%d,%d) BtnState[%d,%d]\n",1006 TRACE("[%p] client rect set to %dx%d at (%d,%d) BtnState[%d,%d]\n", 973 1007 hwnd, lpRect->right-lpRect->left, lpRect->bottom-lpRect->top, 974 1008 lpRect->left, lpRect->top, … … 1013 1047 bHorizontal, TRUE, infoPtr->TLbtnState); 1014 1048 PAGER_DrawButton(hdc, infoPtr->clrBk, rcBottomRight, 1015 bHorizontal, FALSE, infoPtr->BRbtnState); 1049 bHorizontal, FALSE, infoPtr->BRbtnState); 1016 1050 1017 1051 ReleaseDC( hwnd, hdc ); … … 1019 1053 } 1020 1054 1021 static INT 1055 static INT 1022 1056 PAGER_HitTest (HWND hwnd, LPPOINT pt) 1023 1057 { … … 1030 1064 if (PtInRect(&clientRect, *pt)) 1031 1065 { 1032 /* TRACE("HTCLIENT\n"); */1066 TRACE("HTCLIENT\n"); 1033 1067 return HTCLIENT; 1034 1068 } … … 1040 1074 if (pt->x < clientRect.left) 1041 1075 { 1042 /* TRACE("HTLEFT\n"); */1076 TRACE("HTLEFT\n"); 1043 1077 return HTLEFT; 1044 1078 } … … 1048 1082 if (pt->y < clientRect.top) 1049 1083 { 1050 /* TRACE("HTTOP\n"); */1084 TRACE("HTTOP\n"); 1051 1085 return HTTOP; 1052 1086 } … … 1060 1094 if (pt->x > clientRect.right) 1061 1095 { 1062 /* TRACE("HTRIGHT\n"); */1096 TRACE("HTRIGHT\n"); 1063 1097 return HTRIGHT; 1064 1098 } … … 1068 1102 if (pt->y > clientRect.bottom) 1069 1103 { 1070 /* TRACE("HTBOTTOM\n"); */1104 TRACE("HTBOTTOM\n"); 1071 1105 return HTBOTTOM; 1072 1106 } … … 1074 1108 } 1075 1109 1076 /* TRACE("HTNOWHERE\n"); */1110 TRACE("HTNOWHERE\n"); 1077 1111 return HTNOWHERE; 1078 1112 } … … 1081 1115 PAGER_NCHitTest (HWND hwnd, WPARAM wParam, LPARAM lParam) 1082 1116 { 1083 POINT pt = { SLOWORD(lParam), SHIWORD(lParam) }; 1117 POINT pt; 1118 1119 pt.x = SLOWORD(lParam); 1120 pt.y = SHIWORD(lParam); 1121 1084 1122 ScreenToClient (hwnd, &pt); 1085 1123 return PAGER_HitTest(hwnd, &pt); … … 1110 1148 if (notCaptured) 1111 1149 { 1112 TRACKMOUSEEVENT trackinfo; 1113 1114 TRACE("[%04x] SetCapture\n", hwnd); 1115 SetCapture(hwnd); 1116 1117 trackinfo.cbSize = sizeof(TRACKMOUSEEVENT); 1118 trackinfo.dwFlags = TME_QUERY; 1119 trackinfo.hwndTrack = hwnd; 1120 trackinfo.dwHoverTime = HOVER_DEFAULT; 1121 1122 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */ 1123 _TrackMouseEvent(&trackinfo); 1124 1125 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */ 1126 if(!(trackinfo.dwFlags & TME_LEAVE)) { 1127 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */ 1128 1129 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */ 1130 /* and can properly deactivate the hot button */ 1131 _TrackMouseEvent(&trackinfo); 1132 } 1133 1134 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 1150 PAGER_CaptureandTrack(infoPtr, hwnd); 1151 1152 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 1135 1153 } 1136 1154 … … 1146 1164 KillTimer (hwnd, TIMERID2); 1147 1165 1148 TRACE("[% 04x] ReleaseCapture\n", hwnd);1166 TRACE("[%p] ReleaseCapture\n", hwnd); 1149 1167 ReleaseCapture(); 1168 infoPtr->bCapture = FALSE; 1150 1169 1151 1170 /* Notify parent of released mouse capture */ … … 1167 1186 1168 1187 static LRESULT 1188 PAGER_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam) 1189 { 1190 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 1191 POINT clpt, pt; 1192 RECT wnrect, TLbtnrect, BRbtnrect, *btnrect = NULL; 1193 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 1194 BOOL topLeft = FALSE; 1195 INT btnstate = 0; 1196 INT hit; 1197 HDC hdc; 1198 1199 pt.x = SLOWORD(lParam); 1200 pt.y = SHIWORD(lParam); 1201 1202 TRACE("[%p] to (%ld,%ld)\n", hwnd, pt.x, pt.y); 1203 ClientToScreen(hwnd, &pt); 1204 GetWindowRect(hwnd, &wnrect); 1205 if (PtInRect(&wnrect, pt)) { 1206 TLbtnrect = wnrect; 1207 BRbtnrect = wnrect; 1208 if (dwStyle & PGS_HORZ) { 1209 TLbtnrect.right = TLbtnrect.left + infoPtr->nButtonSize; 1210 BRbtnrect.left = BRbtnrect.right - infoPtr->nButtonSize; 1211 } 1212 else { 1213 TLbtnrect.bottom = TLbtnrect.top + infoPtr->nButtonSize; 1214 BRbtnrect.top = BRbtnrect.bottom - infoPtr->nButtonSize; 1215 } 1216 1217 clpt = pt; 1218 MapWindowPoints(0, hwnd, &clpt, 1); 1219 hit = PAGER_HitTest(hwnd, &clpt); 1220 if (hit == HTLEFT || hit == HTTOP) { 1221 topLeft = TRUE; 1222 btnrect = &TLbtnrect; 1223 infoPtr->TLbtnState = PGF_DEPRESSED; 1224 btnstate = infoPtr->TLbtnState; 1225 } 1226 else if (hit == HTRIGHT || hit == HTBOTTOM) { 1227 topLeft = FALSE; 1228 btnrect = &BRbtnrect; 1229 infoPtr->BRbtnState = PGF_DEPRESSED; 1230 btnstate = infoPtr->BRbtnState; 1231 } 1232 1233 /* If in one of the buttons the capture and draw buttons */ 1234 if (btnrect) { 1235 TRACE("[%p] draw btn (%d,%d)-(%d,%d), Capture %s, style %08lx\n", 1236 hwnd, btnrect->left, btnrect->top, 1237 btnrect->right, btnrect->bottom, 1238 (infoPtr->bCapture) ? "TRUE" : "FALSE", 1239 dwStyle); 1240 if (!infoPtr->bCapture) 1241 PAGER_CaptureandTrack(infoPtr, hwnd); 1242 if (dwStyle & PGS_AUTOSCROLL) 1243 SetTimer(hwnd, TIMERID1, 0x3e, 0); 1244 MapWindowPoints(0, hwnd, (LPPOINT)btnrect, 2); 1245 hdc = GetWindowDC(hwnd); 1246 /* OffsetRect(wnrect, 0 | 1, 0 | 1) */ 1247 PAGER_DrawButton(hdc, infoPtr->clrBk, *btnrect, 1248 PAGER_IsHorizontal(hwnd), topLeft, btnstate); 1249 ReleaseDC(hwnd, hdc); 1250 return DefWindowProcA (hwnd, WM_MOUSEMOVE, wParam, lParam); 1251 } 1252 } 1253 1254 /* If we think we are captured, then do release */ 1255 if (infoPtr->bCapture) { 1256 infoPtr->bCapture = FALSE; 1257 1258 if (GetCapture() == hwnd) { 1259 ReleaseCapture(); 1260 /* Notify parent of released mouse capture */ 1261 { 1262 NMHDR nmhdr; 1263 ZeroMemory (&nmhdr, sizeof (NMHDR)); 1264 nmhdr.hwndFrom = hwnd; 1265 nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1266 nmhdr.code = NM_RELEASEDCAPTURE; 1267 SendMessageA (GetParent(hwnd), WM_NOTIFY, 1268 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); 1269 } 1270 } 1271 if (IsWindow(hwnd)) 1272 KillTimer(hwnd, TIMERID1); 1273 } 1274 return DefWindowProcA (hwnd, WM_MOUSEMOVE, wParam, lParam); 1275 } 1276 1277 static LRESULT 1169 1278 PAGER_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam) 1170 1279 { 1171 1280 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 1172 1281 BOOL repaintBtns = FALSE; 1173 POINT pt = { SLOWORD(lParam), SHIWORD(lParam) };1282 POINT pt; 1174 1283 INT hit; 1175 1284 1176 TRACE("[%04x]\n", hwnd); 1177 1285 pt.x = SLOWORD(lParam); 1286 pt.y = SHIWORD(lParam); 1287 1288 TRACE("[%p] at (%d,%d)\n", hwnd, SLOWORD(lParam), SHIWORD(lParam)); 1289 1178 1290 hit = PAGER_HitTest(hwnd, &pt); 1179 1291 … … 1183 1295 repaintBtns = infoPtr->TLbtnState != PGF_DEPRESSED; 1184 1296 infoPtr->TLbtnState = PGF_DEPRESSED; 1185 SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 1297 SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 1186 1298 } 1187 1299 else if (hit == HTRIGHT || hit == HTBOTTOM) … … 1189 1301 repaintBtns = infoPtr->BRbtnState != PGF_DEPRESSED; 1190 1302 infoPtr->BRbtnState = PGF_DEPRESSED; 1191 SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 1303 SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 1192 1304 } 1193 1305 1194 1306 if (repaintBtns) 1195 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 1307 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 1196 1308 1197 1309 switch(hit) 1198 1310 { 1199 1311 case HTLEFT: 1200 TRACE("[% 04x] PGF_SCROLLLEFT\n", hwnd);1312 TRACE("[%p] PGF_SCROLLLEFT\n", hwnd); 1201 1313 PAGER_Scroll(hwnd, PGF_SCROLLLEFT); 1202 1314 break; 1203 1315 case HTTOP: 1204 TRACE("[% 04x] PGF_SCROLLUP\n", hwnd);1316 TRACE("[%p] PGF_SCROLLUP\n", hwnd); 1205 1317 PAGER_Scroll(hwnd, PGF_SCROLLUP); 1206 1318 break; 1207 1319 case HTRIGHT: 1208 TRACE("[% 04x] PGF_SCROLLRIGHT\n", hwnd);1320 TRACE("[%p] PGF_SCROLLRIGHT\n", hwnd); 1209 1321 PAGER_Scroll(hwnd, PGF_SCROLLRIGHT); 1210 1322 break; 1211 1323 case HTBOTTOM: 1212 TRACE("[% 04x] PGF_SCROLLDOWN\n", hwnd);1324 TRACE("[%p] PGF_SCROLLDOWN\n", hwnd); 1213 1325 PAGER_Scroll(hwnd, PGF_SCROLLDOWN); 1214 1326 break; … … 1224 1336 { 1225 1337 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 1226 TRACE("[% 04x]\n", hwnd);1338 TRACE("[%p]\n", hwnd); 1227 1339 1228 1340 KillTimer (hwnd, TIMERID1); … … 1232 1344 PAGER_UpdateBtns(hwnd, infoPtr, -1, FALSE); 1233 1345 1346 return 0; 1347 } 1348 1349 static LRESULT 1350 PAGER_NCLButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam) 1351 { 1352 POINT pt; 1353 1354 pt.x = SLOWORD(lParam); 1355 pt.y = SHIWORD(lParam); 1356 1357 TRACE("[%p] at (%d,%d)\n", hwnd, SLOWORD(lParam), SHIWORD(lParam)); 1358 MapWindowPoints(0, hwnd, &pt, 1); 1359 lParam = MAKELONG(pt.x, pt.y); 1360 return PAGER_LButtonDown (hwnd, wParam, lParam); 1361 } 1362 1363 static LRESULT 1364 PAGER_Timer (HWND hwnd, WPARAM wParam) 1365 { 1366 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 1367 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 1368 INT dir; 1369 1370 /* if initial timer, kill it and start the repeat timer */ 1371 if (wParam == TIMERID1) { 1372 if (PAGER_IsHorizontal(hwnd)) { 1373 dir = (infoPtr->TLbtnState & PGF_DEPRESSED) ? 1374 PGF_SCROLLLEFT : PGF_SCROLLRIGHT; 1375 } 1376 else { 1377 dir = (infoPtr->TLbtnState & PGF_DEPRESSED) ? 1378 PGF_SCROLLUP : PGF_SCROLLDOWN; 1379 } 1380 TRACE("[%p] TIMERID1: style=%08lx, dir=%d\n", hwnd, dwStyle, dir); 1381 KillTimer(hwnd, TIMERID1); 1382 SetTimer(hwnd, TIMERID1, REPEAT_DELAY, 0); 1383 if (dwStyle & PGS_AUTOSCROLL) { 1384 PAGER_Scroll(hwnd, dir); 1385 SetWindowPos(hwnd, 0,0,0,0,0, 1386 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | 1387 SWP_NOZORDER | SWP_NOACTIVATE); 1388 } 1389 return 0; 1390 1391 } 1392 1393 TRACE("[%p] TIMERID2: dir=%d\n", hwnd, infoPtr->direction); 1394 KillTimer(hwnd, TIMERID2); 1395 if (infoPtr->direction > 0) { 1396 PAGER_Scroll(hwnd, infoPtr->direction); 1397 SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0); 1398 } 1234 1399 return 0; 1235 1400 } … … 1288 1453 1289 1454 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 1290 TRACE("[% 04x] %dx%d\n", hwnd, LOWORD(lParam),HIWORD(lParam));1455 TRACE("[%p] %dx%d\n", hwnd, SLOWORD(lParam), SHIWORD(lParam)); 1291 1456 1292 1457 if (PAGER_IsHorizontal(hwnd)) 1293 infoPtr->nHeight = HIWORD(lParam);1458 infoPtr->nHeight = SHIWORD(lParam); 1294 1459 else 1295 infoPtr->nWidth = LOWORD(lParam);1460 infoPtr->nWidth = SLOWORD(lParam); 1296 1461 1297 1462 return PAGER_RecalcSize(hwnd); … … 1334 1499 case PGM_RECALCSIZE: 1335 1500 return PAGER_RecalcSize(hwnd); 1336 1501 1337 1502 case PGM_SETBKCOLOR: 1338 1503 return PAGER_SetBkColor (hwnd, wParam, lParam); … … 1382 1547 if (infoPtr->bForward && infoPtr->hwndChild) 1383 1548 PostMessageA(infoPtr->hwndChild, WM_MOUSEMOVE, wParam, lParam); 1384 return TRUE;1549 return PAGER_MouseMove (hwnd, wParam, lParam); 1385 1550 1386 1551 case WM_MOUSELEAVE: 1387 return PAGER_MouseLeave (hwnd, wParam, lParam); 1552 return PAGER_MouseLeave (hwnd, wParam, lParam); 1553 1554 case WM_NCLBUTTONDOWN: 1555 return PAGER_NCLButtonDown (hwnd, wParam, lParam); 1388 1556 1389 1557 case WM_LBUTTONDOWN: 1390 1558 return PAGER_LButtonDown (hwnd, wParam, lParam); 1391 1559 1560 case WM_NCLBUTTONUP: 1392 1561 case WM_LBUTTONUP: 1393 1562 return PAGER_LButtonUp (hwnd, wParam, lParam); … … 1397 1566 /* 1398 1567 case WM_PAINT: 1399 return PAGER_Paint (hwnd, wParam); 1568 return PAGER_Paint (hwnd, wParam); 1400 1569 */ 1401 1570 case WM_TIMER: 1402 /* if initial timer, kill it and start the repeat timer */ 1403 if (wParam == TIMERID1) 1404 { 1405 KillTimer(hwnd, TIMERID1); 1406 SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0); 1407 } 1408 1409 KillTimer(hwnd, TIMERID2); 1410 if (infoPtr->direction > 0) 1411 { 1412 PAGER_Scroll(hwnd, infoPtr->direction); 1413 SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0); 1414 } 1415 break; 1571 return PAGER_Timer (hwnd, wParam); 1416 1572 1417 1573 case WM_NOTIFY: … … 1440 1596 wndClass.hbrBackground = 0; 1441 1597 wndClass.lpszClassName = WC_PAGESCROLLERA; 1442 1598 1443 1599 RegisterClassA (&wndClass); 1444 1600 } … … 1450 1606 UnregisterClassA (WC_PAGESCROLLERA, (HINSTANCE)NULL); 1451 1607 } 1452
Note:
See TracChangeset
for help on using the changeset viewer.