Changeset 6644 for trunk/src/comctl32/pager.c
- Timestamp:
- Sep 5, 2001, 2:05:03 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/pager.c
r6380 r6644 1 /* $Id: pager.c,v 1.9 2001-09-05 12:05:01 bird Exp $ */ 1 2 /* 2 3 * Pager control … … 39 40 INT nPos; /* scroll position */ 40 41 INT nWidth; /* from child wnd's response to PGN_CALCSIZE */ 41 INT nHeight; /* from child wnd's response to PGN_CALCSIZE */ 42 INT nHeight; /* from child wnd's response to PGN_CALCSIZE */ 42 43 BOOL bForward; /* forward WM_MOUSEMOVE msgs to the contained wnd */ 43 44 INT TLbtnState; /* state of top or left btn */ … … 57 58 #define REPEAT_DELAY 50 58 59 59 /* the horizontal arrows are: 60 /* the horizontal arrows are: 60 61 * 61 62 * 01234 01234 … … 66 67 * 5 ** ** 67 68 * 6 * * 68 * 7 69 * 7 69 70 * 70 71 */ … … 74 75 INT x, y, w, h; 75 76 HPEN hOldPen; 76 77 77 78 w = r.right - r.left + 1; 78 79 h = r.bottom - r.top + 1; … … 107 108 } 108 109 109 /* the vertical arrows are: 110 /* the vertical arrows are: 110 111 * 111 112 * 01234567 01234567 112 * 1****** ** 113 * 1****** ** 113 114 * 2 **** **** 114 115 * 3 ** ****** … … 121 122 INT x, y, w, h; 122 123 HPEN hOldPen; 123 124 124 125 w = r.right - r.left + 1; 125 126 h = r.bottom - r.top + 1; … … 165 166 166 167 if ((rc.right - rc.left <= 0) || (rc.bottom - rc.top <= 0)) 167 return; 168 return; 168 169 169 170 hBrush = CreateSolidBrush(clrBk); … … 172 173 FillRect(hdc, &rc, hBrush); 173 174 174 if (btnState == PGF_HOT) 175 if (btnState == PGF_HOT) 175 176 { 176 177 DrawEdge( hdc, &rc, BDR_RAISEDINNER, BF_RECT); … … 180 181 PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft); 181 182 } 182 else if (btnState == PGF_NORMAL) 183 else if (btnState == PGF_NORMAL) 183 184 { 184 185 DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT); … … 188 189 PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft); 189 190 } 190 else if (btnState == PGF_DEPRESSED) 191 else if (btnState == PGF_DEPRESSED) 191 192 { 192 193 DrawEdge( hdc, &rc, BDR_SUNKENOUTER, BF_RECT); … … 196 197 PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft); 197 198 } 198 else if (btnState == PGF_GRAYED) 199 else if (btnState == PGF_GRAYED) 199 200 { 200 201 DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT); … … 233 234 PAGER_GetButtonState (HWND hwnd, WPARAM wParam, LPARAM lParam) 234 235 { 235 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 236 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 236 237 LRESULT btnState = PGF_INVISIBLE; 237 238 INT btn = (INT)lParam; … … 250 251 PAGER_GetPos(HWND hwnd) 251 252 { 252 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 253 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 253 254 TRACE("[%04x] returns %d\n", hwnd, infoPtr->nPos); 254 255 return (LRESULT)infoPtr->nPos; … … 258 259 PAGER_GetButtonSize(HWND hwnd) 259 260 { 260 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 261 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 261 262 TRACE("[%04x] returns %d\n", hwnd, infoPtr->nButtonSize); 262 263 return (LRESULT)infoPtr->nButtonSize; … … 266 267 PAGER_GetBorder(HWND hwnd) 267 268 { 268 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 269 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 269 270 TRACE("[%04x] returns %d\n", hwnd, infoPtr->nBorder); 270 271 return (LRESULT)infoPtr->nBorder; … … 274 275 PAGER_GetBkColor(HWND hwnd) 275 276 { 276 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 277 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 277 278 TRACE("[%04x] returns %06lx\n", hwnd, infoPtr->clrBk); 278 279 return (LRESULT)infoPtr->clrBk; 279 280 } 280 281 281 static void 282 PAGER_CalcSize (HWND hwnd, INT* size, BOOL getWidth) 282 static void 283 PAGER_CalcSize (HWND hwnd, INT* size, BOOL getWidth) 283 284 { 284 285 NMPGCALCSIZE nmpgcs; … … 333 334 infoPtr->nHeight = wndSize; 334 335 335 TRACE("[%04x] SWP %dx%d at (%d,%d)\n", hwnd, 336 TRACE("[%04x] SWP %dx%d at (%d,%d)\n", hwnd, 336 337 infoPtr->nWidth, infoPtr->nHeight, 337 338 0, -nPos); … … 379 380 } 380 381 381 static void 382 static void 382 383 PAGER_GrayAndRestoreBtns(PAGER_INFO* infoPtr, INT scrollRange, 383 384 BOOL* needsResize, BOOL* needsRepaint) … … 416 417 417 418 418 static void 419 static void 419 420 PAGER_NormalizeBtns(PAGER_INFO* infoPtr, BOOL* needsRepaint) 420 421 { … … 432 433 } 433 434 434 static void 435 static void 435 436 PAGER_HideGrayBtns(PAGER_INFO* infoPtr, BOOL* needsResize) 436 437 { … … 464 465 465 466 if (resizeClient) /* initiate NCCalcSize to resize client wnd */ 466 SetWindowPos(hwnd, 0,0,0,0,0, 467 SetWindowPos(hwnd, 0,0,0,0,0, 467 468 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | 468 469 SWP_NOZORDER | SWP_NOACTIVATE); 469 470 470 471 if (repaintBtns) 471 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 472 } 473 474 static LRESULT 472 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 473 } 474 475 static LRESULT 475 476 PAGER_SetPos(HWND hwnd, INT newPos, BOOL fromBtnPress) 476 477 { … … 518 519 } 519 520 520 static void 521 static void 521 522 PAGER_SetFixedWidth(HWND hwnd, PAGER_INFO* infoPtr) 522 523 { … … 544 545 545 546 /* adjust non-scrollable dimension to fit the child */ 546 SetWindowPos(hwnd, 0, 0,0, infoPtr->nWidth, h, 547 SetWindowPos(hwnd, 0, 0,0, infoPtr->nWidth, h, 547 548 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER); 548 549 549 550 550 551 TRACE("[%04x] infoPtr->nWidth set to %d\n", 551 552 } 553 554 static void 552 hwnd, infoPtr->nWidth); 553 } 554 555 static void 555 556 PAGER_SetFixedHeight(HWND hwnd, PAGER_INFO* infoPtr) 556 557 { … … 578 579 579 580 /* adjust non-scrollable dimension to fit the child */ 580 SetWindowPos(hwnd, 0, 0,0, w, infoPtr->nHeight, 581 SetWindowPos(hwnd, 0, 0,0, w, infoPtr->nHeight, 581 582 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER); 582 583 583 584 TRACE("[%04x] infoPtr->nHeight set to %d\n", 584 585 hwnd, infoPtr->nHeight); 585 586 } 586 587 … … 601 602 PAGER_SetPos(hwnd, 0, FALSE); 602 603 } 603 else 604 else 604 605 { 605 606 PAGER_UpdateBtns(hwnd, infoPtr, scrollRange, TRUE); … … 700 701 nmpgScroll.hdr.code = PGN_SCROLL; 701 702 702 GetWindowRect(hwnd, &rcWnd); 703 GetClientRect(hwnd, &nmpgScroll.rcParent); 703 GetWindowRect(hwnd, &rcWnd); 704 GetClientRect(hwnd, &nmpgScroll.rcParent); 704 705 nmpgScroll.iXpos = nmpgScroll.iYpos = 0; 705 706 nmpgScroll.iDir = dir; … … 716 717 } 717 718 nmpgScroll.iScroll -= 2*infoPtr->nButtonSize; 718 719 719 720 SendMessageA (hwnd, WM_NOTIFY, 720 721 (WPARAM)nmpgScroll.hdr.idFrom, (LPARAM)&nmpgScroll); 721 722 722 723 TRACE("[%04x] PGN_SCROLL returns iScroll=%d\n", hwnd, nmpgScroll.iScroll); 723 724 … … 769 770 FIXME("[%04x] Drag and Drop style is not implemented yet.\n", hwnd); 770 771 /* 771 772 773 774 772 * If neither horizontal nor vertical style specified, default to vertical. 773 * This is probably not necessary, since the style may be set later on as 774 * the control is initialized, but just in case it isn't, set it here. 775 */ 775 776 if (!(dwStyle & PGS_HORZ) && !(dwStyle & PGS_VERT)) 776 777 { … … 800 801 /* 801 802 * lParam points to a RECT struct. On entry, the struct 802 * contains the proposed wnd rectangle for the window. 803 * contains the proposed wnd rectangle for the window. 803 804 * On exit, the struct should contain the screen 804 805 * coordinates of the corresponding window's client area. 805 806 */ 806 807 807 808 if (PAGER_IsHorizontal(hwnd)) 808 809 { 809 810 if (infoPtr->TLbtnState) /* != PGF_INVISIBLE */ 810 811 lpRect->left += infoPtr->nButtonSize; 811 if (infoPtr->BRbtnState) 812 if (infoPtr->BRbtnState) 812 813 lpRect->right -= infoPtr->nButtonSize; 813 814 } … … 863 864 bHorizontal, TRUE, infoPtr->TLbtnState); 864 865 PAGER_DrawButton(hdc, infoPtr->clrBk, rcBottomRight, 865 bHorizontal, FALSE, infoPtr->BRbtnState); 866 bHorizontal, FALSE, infoPtr->BRbtnState); 866 867 867 868 ReleaseDC( hwnd, hdc ); … … 869 870 } 870 871 871 static INT 872 static INT 872 873 PAGER_HitTest (HWND hwnd, LPPOINT pt) 873 874 { … … 976 977 if(!(trackinfo.dwFlags & TME_LEAVE)) { 977 978 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */ 978 979 979 980 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */ 980 981 /* and can properly deactivate the hot button */ … … 982 983 } 983 984 984 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 985 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 985 986 } 986 987 … … 1025 1026 1026 1027 TRACE("[%04x]\n", hwnd); 1027 1028 1028 1029 hit = PAGER_HitTest(hwnd, &pt); 1029 1030 … … 1033 1034 repaintBtns = infoPtr->TLbtnState != PGF_DEPRESSED; 1034 1035 infoPtr->TLbtnState = PGF_DEPRESSED; 1035 SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 1036 SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 1036 1037 } 1037 1038 else if (hit == HTRIGHT || hit == HTBOTTOM) … … 1039 1040 repaintBtns = infoPtr->BRbtnState != PGF_DEPRESSED; 1040 1041 infoPtr->BRbtnState = PGF_DEPRESSED; 1041 SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 1042 SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 1042 1043 } 1043 1044 1044 1045 if (repaintBtns) 1045 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 1046 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 1046 1047 1047 1048 switch(hit) … … 1130 1131 1131 1132 if (!infoPtr && (uMsg != WM_CREATE)) 1132 1133 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 1133 1134 1134 1135 switch (uMsg) … … 1156 1157 case PGM_RECALCSIZE: 1157 1158 return PAGER_RecalcSize(hwnd); 1158 1159 1159 1160 case PGM_SETBKCOLOR: 1160 1161 return PAGER_SetBkColor (hwnd, wParam, lParam); … … 1204 1205 if (infoPtr->bForward && infoPtr->hwndChild) 1205 1206 PostMessageA(infoPtr->hwndChild, WM_MOUSEMOVE, wParam, lParam); 1206 return TRUE; 1207 return TRUE; 1207 1208 1208 1209 case WM_MOUSELEAVE: 1209 return PAGER_MouseLeave (hwnd, wParam, lParam); 1210 return PAGER_MouseLeave (hwnd, wParam, lParam); 1210 1211 1211 1212 case WM_LBUTTONDOWN: … … 1219 1220 /* 1220 1221 case WM_PAINT: 1221 return PAGER_Paint (hwnd, wParam); 1222 return PAGER_Paint (hwnd, wParam); 1222 1223 */ 1223 1224 case WM_TIMER: … … 1233 1234 { 1234 1235 PAGER_Scroll(hwnd, infoPtr->direction); 1235 SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0); 1236 SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0); 1236 1237 } 1237 1238 break; … … 1266 1267 wndClass.hbrBackground = 0; 1267 1268 wndClass.lpszClassName = WC_PAGESCROLLERA; 1268 1269 1269 1270 RegisterClassA (&wndClass); 1270 1271 }
Note:
See TracChangeset
for help on using the changeset viewer.