Author: jimtabor Date: Sun Jun 2 20:48:12 2013 New Revision: 59159
URL: http://svn.reactos.org/svn/reactos?rev=59159&view=rev Log: [User32] - Sync port to 1.5.31.
Modified: trunk/reactos/win32ss/user/user32/controls/listbox.c
Modified: trunk/reactos/win32ss/user/user32/controls/listbox.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/control... ============================================================================== --- trunk/reactos/win32ss/user/user32/controls/listbox.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/controls/listbox.c [iso-8859-1] Sun Jun 2 20:48:12 2013 @@ -27,8 +27,6 @@ * If you discover missing features, or bugs, please note them below. * * TODO: - * - GetListBoxInfo() ReactOS - * - LB_GETLISTBOXINFO ReactOS * - LBS_NODATA ReactOS */
@@ -81,6 +79,7 @@ INT nb_tabs; /* Number of tabs in array */ INT *tabs; /* Array of tabs */ INT avg_char_width; /* Average width of characters */ + INT wheel_remain; /* Left over scroll amount */ BOOL caret_on; /* Is caret on? */ BOOL captured; /* Is mouse captured? */ BOOL in_focus; @@ -291,20 +290,12 @@ if (index < 0) index = 0; if (descr->style & LBS_MULTICOLUMN) index -= index % descr->page_size; if (descr->top_item == index) return LB_OKAY; - if (descr->style & LBS_MULTICOLUMN) - { - INT diff = (descr->top_item - index) / descr->page_size * descr->column_width; - if (scroll && (abs(diff) < descr->width)) - ScrollWindowEx( descr->self, diff, 0, NULL, NULL, 0, NULL, - SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN ); - - else - scroll = FALSE; - } - else if (scroll) + if (scroll) { INT diff; - if (descr->style & LBS_OWNERDRAWVARIABLE) + if (descr->style & LBS_MULTICOLUMN) + diff = (descr->top_item - index) / descr->page_size * descr->column_width; + else if (descr->style & LBS_OWNERDRAWVARIABLE) { INT i; diff = 0; @@ -322,11 +313,8 @@ else diff = (descr->top_item - index) * descr->item_height;
- if (abs(diff) < descr->height) - ScrollWindowEx( descr->self, 0, diff, NULL, NULL, 0, NULL, - SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN ); - else - scroll = FALSE; + ScrollWindowEx( descr->self, 0, diff, NULL, NULL, 0, NULL, + SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN ); } if (!scroll) InvalidateRect( descr->self, NULL, TRUE ); descr->top_item = index; @@ -1774,6 +1762,8 @@ if ((ret = LISTBOX_RemoveItem( descr, (descr->nb_items - 1) )) < 0) return ret; } + + InvalidateRect( descr->self, NULL, TRUE ); return LB_OKAY; }
@@ -1996,18 +1986,24 @@
static LRESULT LISTBOX_HandleMouseWheel(LB_DESCR *descr, SHORT delta ) { - short gcWheelDelta = 0; UINT pulScrollLines = 3;
SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
- gcWheelDelta -= delta; - - if (abs(gcWheelDelta) >= WHEEL_DELTA && pulScrollLines) - { - int cLineScroll = (int) min((UINT) descr->page_size, pulScrollLines); - cLineScroll *= (gcWheelDelta / WHEEL_DELTA); - LISTBOX_SetTopItem( descr, descr->top_item + cLineScroll, TRUE ); + /* if scrolling changes direction, ignore left overs */ + if ((delta < 0 && descr->wheel_remain < 0) || + (delta > 0 && descr->wheel_remain > 0)) + descr->wheel_remain += delta; + else + descr->wheel_remain = delta; + + if (descr->wheel_remain && pulScrollLines) + { + int cLineScroll; + pulScrollLines = min((UINT) descr->page_size, pulScrollLines); + cLineScroll = pulScrollLines * (float)descr->wheel_remain / WHEEL_DELTA; + descr->wheel_remain -= WHEEL_DELTA * cLineScroll / (int)pulScrollLines; + LISTBOX_SetTopItem( descr, descr->top_item - cLineScroll, TRUE ); } return 0; } @@ -2500,6 +2496,7 @@ descr->horz_pos = 0; descr->nb_tabs = 0; descr->tabs = NULL; + descr->wheel_remain = 0; descr->caret_on = lphc ? FALSE : TRUE; if (descr->style & LBS_NOSEL) descr->caret_on = FALSE; descr->in_focus = FALSE; @@ -3009,11 +3006,11 @@ LISTBOX_RepaintItem( descr, descr->focus_item, ODA_FOCUS ); return LB_OKAY;
- case LB_GETLISTBOXINFO: //// ReactOS - if (descr->style & LBS_MULTICOLUMN) - return descr->column_width; + case LB_GETLISTBOXINFO: + if (descr->style & LBS_MULTICOLUMN) //// ReactOS + return descr->page_size * descr->column_width; else - return descr->nb_items; + return descr->page_size;
case WM_DESTROY: return LISTBOX_Destroy( descr ); @@ -3056,6 +3053,7 @@ return 0; case WM_KILLFOCUS: descr->in_focus = FALSE; + descr->wheel_remain = 0; if ((descr->focus_item != -1) && descr->caret_on) LISTBOX_RepaintItem( descr, descr->focus_item, ODA_FOCUS ); SEND_NOTIFICATION( descr, LBN_KILLFOCUS );