Changeset 2852 for trunk/src/user32/listbox.cpp
- Timestamp:
- Feb 21, 2000, 6:25:33 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/listbox.cpp
r2804 r2852 1 /* $Id: listbox.cpp,v 1. 19 2000-02-16 14:34:20 sandervlExp $ */1 /* $Id: listbox.cpp,v 1.20 2000-02-21 17:25:27 cbratschi Exp $ */ 2 2 /* 3 3 * Listbox controls … … 6 6 * Copyright 1999 Christoph Bratschi (ported from WINE) 7 7 * 8 * Corel version: 20000212 8 9 * WINE version: 991212 9 10 */ … … 18 19 #include <misc.h> 19 20 20 #define DBG_LOCALLOG 21 #define DBG_LOCALLOG DBG_listbox 21 22 #include "dbglocal.h" 22 23 … … 81 82 BOOL caret_on; /* Is caret on? */ 82 83 BOOL captured; /* Is mouse captured? */ 84 BOOL in_focus; 83 85 HFONT font; /* Current font */ 84 86 LCID locale; /* Current locale for string comparisons */ … … 172 174 SCROLLINFO info; 173 175 174 if (!(descr->style & WS_VSCROLL)) return; 176 /* Check the listbox scroll bar flags individually before we call 177 SetScrollInfo otherwise when the listbox style is WS_HSCROLL and 178 no WS_VSCROLL, we end up with an uninitialized, visible horizontal 179 scroll bar when we do not need one. 180 if (!(descr->style & WS_VSCROLL)) return; 181 */ 182 175 183 /* It is important that we check descr->style, and not wnd->dwStyle, 176 184 for WS_VSCROLL, as the former is exactly the one passed in … … 194 202 if (descr->style & LBS_DISABLENOSCROLL) 195 203 info.fMask |= SIF_DISABLENOSCROLL; 196 SetScrollInfo( hwnd, SB_HORZ, &info, TRUE ); 204 if (descr->style & WS_HSCROLL) 205 SetScrollInfo( hwnd, SB_HORZ, &info, TRUE ); 197 206 info.nMax = 0; 198 207 info.fMask = SIF_RANGE; 199 SetScrollInfo( hwnd, SB_VERT, &info, TRUE ); 208 if (descr->style & WS_VSCROLL) 209 SetScrollInfo( hwnd, SB_VERT, &info, TRUE ); 200 210 } 201 211 else … … 208 218 if (descr->style & LBS_DISABLENOSCROLL) 209 219 info.fMask |= SIF_DISABLENOSCROLL; 210 211 SetScrollInfo( hwnd, SB_VERT, &info, TRUE );220 if (descr->style & WS_VSCROLL) 221 SetScrollInfo( hwnd, SB_VERT, &info, TRUE ); 212 222 213 223 if (descr->horz_extent) … … 220 230 if (descr->style & LBS_DISABLENOSCROLL) 221 231 info.fMask |= SIF_DISABLENOSCROLL; 222 SetScrollInfo( hwnd, SB_HORZ, &info, TRUE ); 232 if (descr->style & WS_HSCROLL) 233 SetScrollInfo( hwnd, SB_HORZ, &info, TRUE ); 223 234 } 224 235 } … … 314 325 315 326 GetWindowRect( hwnd, &rectWindow ); 316 OffsetRect(&rectWindow, -rectWindow.left, -rectWindow.top);317 327 GetClientRect( hwnd, &rect ); 318 328 329 //CB: todo: doesn't works in ShellAbout dialog 319 330 descr->width = rect.right - rect.left; 320 331 descr->height = rect.bottom - rect.top; … … 479 490 if ((descr->focus_item == index) && 480 491 (descr->caret_on) && 481 ( GetFocus() == hwnd)) dis.itemState |= ODS_FOCUS;492 (descr->in_focus)) dis.itemState |= ODS_FOCUS; 482 493 if (dwStyle & WS_DISABLED) dis.itemState |= ODS_DISABLED; 483 494 dis.itemData = item ? item->data : 0; … … 532 543 if ((descr->focus_item == index) && 533 544 (descr->caret_on) && 534 ( GetFocus() == hwnd)) DrawFocusRect( hdc, rect );545 (descr->in_focus)) DrawFocusRect( hdc, rect ); 535 546 } 536 547 } … … 878 889 879 890 if (!descr->nb_items && (descr->focus_item != -1) && descr->caret_on && 880 ( GetFocus() == hwnd))891 (descr->in_focus)) 881 892 { 882 893 /* Special case for empty listbox: paint focus rect */ … … 1071 1082 static LRESULT LISTBOX_SetColumnWidth( HWND hwnd, LB_DESCR *descr, UINT width) 1072 1083 { 1073 width += 2; /* For left and right margin */1074 1084 if (width == descr->column_width) return LB_OKAY; 1075 1085 //TRACE("[%04x]: new column width = %d\n", … … 1203 1213 if (index == oldfocus) return LB_OKAY; 1204 1214 descr->focus_item = index; 1205 if ((oldfocus != -1) && descr->caret_on && ( GetFocus() == hwnd))1215 if ((oldfocus != -1) && descr->caret_on && (descr->in_focus)) 1206 1216 LISTBOX_RepaintItem( hwnd, descr, oldfocus, ODA_FOCUS ); 1207 1217 1208 1218 LISTBOX_MakeItemVisible( hwnd, descr, index, fully_visible ); 1209 if (descr->caret_on && ( GetFocus() == hwnd))1219 if (descr->caret_on && (descr->in_focus)) 1210 1220 LISTBOX_RepaintItem( hwnd, descr, index, ODA_FOCUS ); 1211 1221 … … 1235 1245 if (index != -1) descr->items[index].selected = TRUE; 1236 1246 descr->selected_item = index; 1237 if (oldsel != -1) LISTBOX_RepaintItem( hwnd, descr, oldsel, 0);1247 if (oldsel != -1) LISTBOX_RepaintItem( hwnd, descr, oldsel, ODA_SELECT); 1238 1248 if (index != -1) LISTBOX_RepaintItem( hwnd, descr, index, ODA_SELECT ); 1239 1249 if (send_notify && descr->nb_items) SEND_NOTIFICATION( hwnd, descr, … … 1440 1450 if (index == -1) index = descr->nb_items - 1; 1441 1451 else if ((index < 0) || (index >= descr->nb_items)) return LB_ERR; 1452 1453 /* We need to Invalidate the original rect intead of the updated one. */ 1454 LISTBOX_InvalidateItems( hwnd, descr, index ); 1455 1442 1456 LISTBOX_DeleteItem( hwnd, descr, index ); 1443 1457 … … 1480 1494 } 1481 1495 } 1482 LISTBOX_InvalidateItems( hwnd, descr, index ); 1496 1483 1497 if (descr->focus_item >= descr->nb_items) 1484 1498 { … … 1733 1747 } 1734 1748 1749 static LRESULT LISTBOX_HandleMouseWheel(HWND hwnd, LB_DESCR *descr,WPARAM wParam, LPARAM lParam ) 1750 { 1751 short gcWheelDelta = 0; 1752 UINT pulScrollLines = 3; 1753 1754 SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0); 1755 1756 gcWheelDelta -= (short) HIWORD(wParam); 1757 1758 if (abs(gcWheelDelta) >= WHEEL_DELTA && pulScrollLines) 1759 { 1760 int cLineScroll = (int) min((UINT) descr->page_size, pulScrollLines); 1761 cLineScroll *= (gcWheelDelta / WHEEL_DELTA); 1762 LISTBOX_SetTopItem( hwnd, descr, descr->top_item + cLineScroll, TRUE ); 1763 } 1764 return 0; 1765 } 1735 1766 1736 1767 /*********************************************************************** … … 1743 1774 //TRACE("[%04x]: lbuttondown %d,%d item %d\n", 1744 1775 // wnd->hwndSelf, x, y, index ); 1745 if (!descr->caret_on && ( GetFocus() == hwnd)) return 0;1776 if (!descr->caret_on && (descr->in_focus)) return 0; 1746 1777 if (index != -1) 1747 1778 { … … 1768 1799 } 1769 1800 1770 if( !descr->lphc ) SetFocus( hwnd ); 1771 else SetFocus( (descr->lphc->hWndEdit) ? descr->lphc->hWndEdit 1801 if (!descr->in_focus) 1802 { 1803 if( !descr->lphc ) SetFocus( hwnd ); 1804 else SetFocus( (descr->lphc->hWndEdit) ? descr->lphc->hWndEdit 1772 1805 : descr->lphc->hwndself ) ; 1806 } 1773 1807 1774 1808 descr->captured = TRUE; … … 2191 2225 descr->tabs = NULL; 2192 2226 descr->caret_on = TRUE; 2227 descr->in_focus = FALSE; 2193 2228 descr->captured = FALSE; 2194 2229 descr->font = 0; … … 2483 2518 return LB_OKAY; 2484 2519 descr->caret_on = TRUE; 2485 if ((descr->focus_item != -1) && ( GetFocus() == hwnd))2520 if ((descr->focus_item != -1) && (descr->in_focus)) 2486 2521 LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS ); 2487 2522 return LB_OKAY; … … 2491 2526 return LB_OKAY; 2492 2527 descr->caret_on = FALSE; 2493 if ((descr->focus_item != -1) && ( GetFocus() == hwnd))2528 if ((descr->focus_item != -1) && (descr->in_focus)) 2494 2529 LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS ); 2495 2530 return LB_OKAY; … … 2528 2563 return 0; 2529 2564 case WM_SETFOCUS: 2565 descr->in_focus = TRUE; 2530 2566 descr->caret_on = TRUE; 2531 2567 if (descr->focus_item != -1) … … 2534 2570 return 0; 2535 2571 case WM_KILLFOCUS: 2572 descr->in_focus = FALSE; 2536 2573 if ((descr->focus_item != -1) && descr->caret_on) 2537 2574 LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS ); … … 2542 2579 case WM_VSCROLL: 2543 2580 return LISTBOX_HandleVScroll( hwnd, descr, wParam, lParam ); 2581 case WM_MOUSEACTIVATE: 2582 return MA_NOACTIVATE; 2583 case WM_MOUSEWHEEL: 2584 if (wParam & (MK_SHIFT | MK_CONTROL)) 2585 return DefWindowProcA( hwnd, msg, wParam, lParam ); 2586 return LISTBOX_HandleMouseWheel( hwnd, descr, wParam, lParam ); 2544 2587 case WM_LBUTTONDOWN: 2545 2588 return LISTBOX_HandleLButtonDown( hwnd, descr, wParam, … … 2650 2693 return LISTBOX_Create( hwnd, lphc ); 2651 2694 case WM_MOUSEMOVE: 2652 if ( CB_GETTYPE(lphc) != CBS_SIMPLE)2695 if (lphc && (CB_GETTYPE(lphc) != CBS_SIMPLE)) 2653 2696 { 2654 2697 POINT mousePos; … … 2691 2734 } 2692 2735 case WM_LBUTTONUP: 2736 if (lphc) 2737 { 2693 2738 POINT mousePos; 2694 2739 RECT clientRect; … … 2719 2764 } 2720 2765 return LISTBOX_HandleLButtonUp( hwnd, descr ); 2766 } 2721 2767 case WM_LBUTTONDOWN: 2722 2768 return LISTBOX_HandleLButtonDownCombo( hwnd, descr, wParam, … … 2727 2773 return FALSE; 2728 2774 case WM_KEYDOWN: 2729 if( CB_GETTYPE(lphc) != CBS_SIMPLE)2775 if(lphc && (CB_GETTYPE(lphc) != CBS_SIMPLE)) 2730 2776 { 2731 2777 /* for some reason(?) Windows makes it possible to … … 2746 2792 return lRet; 2747 2793 case WM_NCDESTROY: 2748 if( CB_GETTYPE(lphc) != CBS_SIMPLE)2794 if(lphc && (CB_GETTYPE(lphc) != CBS_SIMPLE)) 2749 2795 lphc->hWndLBox = 0; 2750 2796 /* fall through */
Note:
See TracChangeset
for help on using the changeset viewer.