Author: cwittich Date: Wed Mar 5 16:45:09 2008 New Revision: 32570
URL: http://svn.reactos.org/svn/reactos?rev=3D32570&view=3Drev Log: partial sync to wine
Modified: trunk/reactos/dll/win32/user32/controls/listbox.c
Modified: trunk/reactos/dll/win32/user32/controls/listbox.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/cont= rols/listbox.c?rev=3D32570&r1=3D32569&r2=3D32570&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/reactos/dll/win32/user32/controls/listbox.c (original) +++ trunk/reactos/dll/win32/user32/controls/listbox.c Wed Mar 5 16:45:09 2= 008 @@ -15,13 +15,13 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 U= SA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, U= SA * * NOTES * * This code was audited for completeness against the documented features * of Comctl32.dll version 6.0 on Oct. 9, 2004, by Dimitrie O. Paun. - * + * =
* Unless otherwise noted, we believe this code to be complete, as per * the specification mentioned above. * If you discover missing features, or bugs, please note them below. @@ -86,7 +86,7 @@ UINT style; /* Window style */ INT width; /* Window width */ INT height; /* Window height */ - LB_ITEMDATA *items; /* Array of items */ + LB_ITEMDATA *items; /* Array of items */ INT nb_items; /* Number of items */ INT top_item; /* Top visible item */ INT selected_item; /* Selected item */ @@ -104,8 +104,8 @@ BOOL captured; /* Is mouse captured? */ BOOL in_focus; HFONT font; /* Current font */ - LCID locale; /* Current locale for string comparisons= */ - LPHEADCOMBO lphc; /* ComboLBox */ + LCID locale; /* Current locale for string comparisons */ + LPHEADCOMBO lphc; /* ComboLBox */ LONG UIState; } LB_DESCR; =
@@ -142,7 +142,7 @@ static LRESULT WINAPI ListBoxWndProcA( HWND hwnd, UINT msg, WPARAM wParam,= LPARAM lParam ); static LRESULT WINAPI ListBoxWndProcW( HWND hwnd, UINT msg, WPARAM wParam,= LPARAM lParam ); =
-static LRESULT LISTBOX_GetItemRect( LB_DESCR *descr, INT index, RECT *rect= ); +static LRESULT LISTBOX_GetItemRect( const LB_DESCR *descr, INT index, RECT= *rect ); =
/********************************************************************* * listbox class descriptor @@ -227,7 +227,7 @@ * * Return the current page size */ -static INT LISTBOX_GetCurrentPageSize( LB_DESCR *descr ) +static INT LISTBOX_GetCurrentPageSize( const LB_DESCR *descr ) { INT i, height; if (!(descr->style & LBS_OWNERDRAWVARIABLE)) return descr->page_size; @@ -245,7 +245,7 @@ * * Return the maximum possible index for the top of the listbox. */ -static INT LISTBOX_GetMaxTopIndex( LB_DESCR *descr ) +static INT LISTBOX_GetMaxTopIndex( const LB_DESCR *descr ) { INT max, page; =
@@ -392,7 +392,7 @@ =
if (abs(diff) < descr->height) ScrollWindowEx( descr->self, 0, diff, NULL, NULL, 0, NULL, - SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN= ); + SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN ); else scroll =3D FALSE; } @@ -461,8 +461,8 @@ TRACE("[%p]: changing height %d -> %d\n", descr->self, descr->height, descr->height - remaining ); SetWindowPos( descr->self, 0, 0, 0, rect.right - rect.left, - rect.bottom - rect.top - remaining, - SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE ); + rect.bottom - rect.top - remaining, + SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE ); return; } } @@ -484,7 +484,7 @@ * Get the rectangle enclosing an item, in listbox client coordinates. * Return 1 if the rectangle is (partially) visible, 0 if hidden, -1 on er= ror. */ -static LRESULT LISTBOX_GetItemRect( LB_DESCR *descr, INT index, RECT *rect= ) +static LRESULT LISTBOX_GetItemRect( const LB_DESCR *descr, INT index, RECT= *rect ) { /* Index <=3D 0 is legal even on empty listboxes */ if (index && (index >=3D descr->nb_items)) @@ -542,7 +542,7 @@ * * Return the item nearest from point (x,y) (in client coordinates). */ -static INT LISTBOX_GetItemFromPoint( LB_DESCR *descr, INT x, INT y ) +static INT LISTBOX_GetItemFromPoint( const LB_DESCR *descr, INT x, INT y ) { INT index =3D descr->top_item; =
@@ -732,8 +732,8 @@ if (!IsWindowVisible(descr->self)) return; if (descr->style & LBS_NOREDRAW) { - descr->style |=3D LBS_DISPLAYCHANGED; - return; + descr->style |=3D LBS_DISPLAYCHANGED; + return; } if (LISTBOX_GetItemRect( descr, index, &rect ) !=3D 1) return; if (!(hdc =3D GetDCEx( descr->self, 0, DCX_CACHE ))) return; @@ -948,6 +948,7 @@ return exact ? -1 : max; } =
+ /*********************************************************************** * LISTBOX_FindFileStrPos * @@ -1059,10 +1060,10 @@ /*********************************************************************** * LISTBOX_GetSelCount */ -static LRESULT LISTBOX_GetSelCount( LB_DESCR *descr ) +static LRESULT LISTBOX_GetSelCount( const LB_DESCR *descr ) { INT i, count; - LB_ITEMDATA *item =3D descr->items; + const LB_ITEMDATA *item =3D descr->items; =
if (!(descr->style & LBS_MULTIPLESEL) || (descr->style & LBS_NOSEL)) @@ -1077,10 +1078,10 @@ /*********************************************************************** * LISTBOX_GetSelItems16 */ -static LRESULT LISTBOX_GetSelItems16( LB_DESCR *descr, INT16 max, LPINT16 = array ) +static LRESULT LISTBOX_GetSelItems16( const LB_DESCR *descr, INT16 max, LP= INT16 array ) { INT i, count; - LB_ITEMDATA *item =3D descr->items; + const LB_ITEMDATA *item =3D descr->items; =
if (!(descr->style & LBS_MULTIPLESEL)) return LB_ERR; for (i =3D count =3D 0; (i < descr->nb_items) && (count < max); i++, i= tem++) @@ -1093,10 +1094,10 @@ /*********************************************************************** * LISTBOX_GetSelItems */ -static LRESULT LISTBOX_GetSelItems( LB_DESCR *descr, INT max, LPINT array ) +static LRESULT LISTBOX_GetSelItems( const LB_DESCR *descr, INT max, LPINT = array ) { INT i, count; - LB_ITEMDATA *item =3D descr->items; + const LB_ITEMDATA *item =3D descr->items; =
if (!(descr->style & LBS_MULTIPLESEL)) return LB_ERR; for (i =3D count =3D 0; (i < descr->nb_items) && (count < max); i++, i= tem++) @@ -1140,8 +1141,7 @@ rect.bottom =3D rect.top + descr->item_height; ExtTextOutW( hdc, 0, 0, ETO_OPAQUE | ETO_CLIPPED, &rect, NULL, 0, NULL ); - LISTBOX_PaintItem( descr, hdc, &rect, descr->focus_item, - ODA_FOCUS, FALSE ); + LISTBOX_PaintItem( descr, hdc, &rect, descr->focus_item, ODA_FOCUS= , FALSE ); rect.top =3D rect.bottom; } =
@@ -1263,9 +1263,9 @@ /*********************************************************************** * LISTBOX_GetItemHeight */ -static LRESULT LISTBOX_GetItemHeight( LB_DESCR *descr, INT index ) -{ - if (descr->style & LBS_OWNERDRAWVARIABLE) +static LRESULT LISTBOX_GetItemHeight( const LB_DESCR *descr, INT index ) +{ + if (descr->style & LBS_OWNERDRAWVARIABLE && descr->nb_items > 0) { if ((index < 0) || (index >=3D descr->nb_items)) { @@ -1281,11 +1281,10 @@ /*********************************************************************** * LISTBOX_SetItemHeight */ -static LRESULT LISTBOX_SetItemHeight( LB_DESCR *descr, INT index, - INT height, BOOL repaint ) +static LRESULT LISTBOX_SetItemHeight( LB_DESCR *descr, INT index, INT heig= ht, BOOL repaint ) { if (height > MAXBYTE) - return -1; + return -1; =
if (!height) height =3D 1; =
@@ -1346,8 +1345,7 @@ /*********************************************************************** * LISTBOX_SetHorizontalExtent */ -static LRESULT LISTBOX_SetHorizontalExtent( LB_DESCR *descr, - INT extent ) +static LRESULT LISTBOX_SetHorizontalExtent( LB_DESCR *descr, INT extent ) { if (!descr->horz_extent || (descr->style & LBS_MULTICOLUMN)) return LB_OKAY; @@ -1412,8 +1410,7 @@ * * Make sure that a given item is partially or fully visible. */ -static void LISTBOX_MakeItemVisible( LB_DESCR *descr, INT index, - BOOL fully ) +static void LISTBOX_MakeItemVisible( LB_DESCR *descr, INT index, BOOL full= y ) { INT top; =
@@ -1452,8 +1449,7 @@ * index must be between 0 and descr->nb_items-1, or LB_ERR is returned. * */ -static LRESULT LISTBOX_SetCaretIndex( LB_DESCR *descr, INT index, - BOOL fully_visible ) +static LRESULT LISTBOX_SetCaretIndex( LB_DESCR *descr, INT index, BOOL ful= ly_visible ) { INT oldfocus =3D descr->focus_item; =
@@ -1561,8 +1557,7 @@ * * Change the caret position and extend the selection to the new caret. */ -static void LISTBOX_MoveCaret( LB_DESCR *descr, INT index, - BOOL fully_visible ) +static void LISTBOX_MoveCaret( LB_DESCR *descr, INT index, BOOL fully_visi= ble ) { TRACE("old focus %d, index %d\n", descr->focus_item, index); =
@@ -1810,11 +1805,11 @@ if (index =3D=3D descr->selected_item) descr->selected_item =3D -1; else if (index < descr->selected_item) - { + { descr->selected_item--; if (ISWIN31) /* win 31 do not change the selected item number = */ LISTBOX_SetSelection( descr, descr->selected_item + 1, TRUE= , FALSE); - } + } } =
if (descr->focus_item >=3D descr->nb_items) @@ -2105,8 +2100,7 @@ /*********************************************************************** * LISTBOX_HandleLButtonDown */ -static LRESULT LISTBOX_HandleLButtonDown( LB_DESCR *descr, - DWORD keys, INT x, INT y ) +static LRESULT LISTBOX_HandleLButtonDown( LB_DESCR *descr, DWORD keys, INT= x, INT y ) { INT index =3D LISTBOX_GetItemFromPoint( descr, x, y ); =
@@ -2200,7 +2194,7 @@ * PARAMS * pWnd [I] The windows internal structure * pDescr [I] The ListBox internal structure - * wParam [I] Key Flag (WM_LBUTTONDOWN doc for more info) + * keys [I] Key Flag (WM_LBUTTONDOWN doc for more info) * x [I] X Mouse Coordinate * y [I] Y Mouse Coordinate * @@ -2211,8 +2205,7 @@ * This function is only to be used when a ListBox is a ComboListBox */ =
-static LRESULT LISTBOX_HandleLButtonDownCombo( LB_DESCR *pDescr, - UINT msg, DWORD keys, INT x= , INT y) +static LRESULT LISTBOX_HandleLButtonDownCombo( LB_DESCR *descr, UINT msg, = DWORD keys, INT x, INT y) { RECT clientRect, screenRect; POINT mousePos; @@ -2220,18 +2213,18 @@ mousePos.x =3D x; mousePos.y =3D y; =
- GetClientRect(pDescr->self, &clientRect); + GetClientRect(descr->self, &clientRect); =
if(PtInRect(&clientRect, mousePos)) { /* MousePos is in client, resume normal processing */ if (msg =3D=3D WM_LBUTTONDOWN) { - pDescr->lphc->droppedIndex =3D pDescr->nb_items ? pDescr->selec= ted_item : -1; - return LISTBOX_HandleLButtonDown( pDescr, keys, x, y); - } - else if (pDescr->style & LBS_NOTIFY) - SEND_NOTIFICATION( pDescr, LBN_DBLCLK ); + descr->lphc->droppedIndex =3D descr->nb_items ? descr->selected= _item : -1; + return LISTBOX_HandleLButtonDown( descr, keys, x, y); + } + else if (descr->style & LBS_NOTIFY) + SEND_NOTIFICATION( descr, LBN_DBLCLK ); } else { @@ -2242,20 +2235,20 @@ screenMousePos =3D mousePos; hWndOldCapture =3D GetCapture(); ReleaseCapture(); - GetWindowRect(pDescr->self, &screenRect); - ClientToScreen(pDescr->self, &screenMousePos); + GetWindowRect(descr->self, &screenRect); + ClientToScreen(descr->self, &screenMousePos); =
if(!PtInRect(&screenRect, screenMousePos)) { - LISTBOX_SetCaretIndex( pDescr, pDescr->lphc->droppedIndex, FAL= SE ); - LISTBOX_SetSelection( pDescr, pDescr->lphc->droppedIndex, FALS= E, FALSE ); - COMBO_FlipListbox( pDescr->lphc, FALSE, FALSE ); + LISTBOX_SetCaretIndex( descr, descr->lphc->droppedIndex, FALSE= ); + LISTBOX_SetSelection( descr, descr->lphc->droppedIndex, FALSE,= FALSE ); + COMBO_FlipListbox( descr->lphc, FALSE, FALSE ); } else { /* Check to see the NC is a scrollbar */ INT nHitTestType=3D0; - LONG style =3D GetWindowLongW( pDescr->self, GWL_STYLE ); + LONG style =3D GetWindowLongW( descr->self, GWL_STYLE ); /* Check Vertical scroll bar */ if (style & WS_VSCROLL) { @@ -2275,8 +2268,8 @@ =
if(nHitTestType !=3D 0) { - SendMessageW(pDescr->self, WM_NCLBUTTONDOWN, nHitTestType, - MAKELONG(screenMousePos.x, screenMousePos.y)); + SendMessageW(descr->self, WM_NCLBUTTONDOWN, nHitTestType, + MAKELONG(screenMousePos.x, screenMousePos.y)); } /* Resume the Capture after scrolling is complete */ @@ -2312,8 +2305,7 @@ * Handle scrolling upon a timer event. * Return TRUE if scrolling should continue. */ -static LRESULT LISTBOX_HandleTimer( LB_DESCR *descr, - INT index, TIMER_DIRECTION dir ) +static LRESULT LISTBOX_HandleTimer( LB_DESCR *descr, INT index, TIMER_DIRE= CTION dir ) { switch(dir) { @@ -2416,7 +2408,7 @@ INT caret =3D -1; BOOL bForceSelection =3D TRUE; /* select item pointed to by focus_item= */ if ((IS_MULTISELECT(descr)) || (descr->selected_item =3D=3D descr->foc= us_item)) - bForceSelection =3D FALSE; /* only for single select list */ + bForceSelection =3D FALSE; /* only for single select list */ =
if (descr->style & LBS_WANTKEYBOARDINPUT) { @@ -2577,7 +2569,7 @@ GetClientRect( hwnd, &rect ); descr->self =3D hwnd; descr->owner =3D GetParent( descr->self ); - descr->style =3D GetWindowLongA( descr->self, GWL_STYLE ); + descr->style =3D GetWindowLongW( descr->self, GWL_STYLE ); descr->width =3D rect.right - rect.left; descr->height =3D rect.bottom - rect.top; descr->items =3D NULL; @@ -2806,11 +2798,11 @@ #endif case LB_DELETESTRING: if (LISTBOX_RemoveItem( descr, wParam) !=3D LB_ERR) - return descr->nb_items; + return descr->nb_items; else { - SetLastError(ERROR_INVALID_INDEX); - return LB_ERR; + SetLastError(ERROR_INVALID_INDEX); + return LB_ERR; } =
#ifndef __REACTOS__ @@ -2870,15 +2862,13 @@ case LB_GETCURSEL16: #endif case LB_GETCURSEL: - if (descr->nb_items=3D=3D0) - return LB_ERR; + if (descr->nb_items =3D=3D 0) + return LB_ERR; if (!IS_MULTISELECT(descr)) - return descr->selected_item; - /* else */ - if (descr->selected_item!=3D-1) - return descr->selected_item; - /* else */ - return descr->focus_item; + return descr->selected_item; + if (descr->selected_item !=3D -1) + return descr->selected_item; + return descr->focus_item; /* otherwise, if the user tries to move the selection with the = */ /* arrow keys, we will give the application something to choke on = */ #ifndef __REACTOS__ @@ -3167,7 +3157,7 @@ /* according to Win16 docs, DDL_DRIVES should make DDL_EXCLUSIVE * be set automatically (this is different in Win32) */ if (wParam & DDL_DRIVES) wParam |=3D DDL_EXCLUSIVE; - lParam =3D (LPARAM)MapSL(lParam); + lParam =3D (LPARAM)MapSL(lParam); /* fall through */ #endif case LB_DIR: @@ -3300,7 +3290,7 @@ return LISTBOX_HandleLButtonDownCombo(descr, msg, wParam, (INT16)LOWORD(lParam), (INT16)HIWORD(lParam) ); - return LISTBOX_HandleLButtonDown(descr, wParam, + return LISTBOX_HandleLButtonDown( descr, wParam, (INT16)LOWORD(lParam), (INT16)HIWORD(lParam) ); case WM_LBUTTONDBLCLK: @@ -3331,7 +3321,7 @@ LISTBOX_HandleMouseMove( descr, mousePos.x, mousePos.y); =
descr->captured =3D captured; - } + } =
else if (GetCapture() =3D=3D descr->self) { LISTBOX_HandleMouseMove( descr, (INT16)LOWORD(lParam), @@ -3439,7 +3429,7 @@ =
default: if ((msg >=3D WM_USER) && (msg < 0xc000)) - WARN("[%p]: unknown msg %04x wp %08x lp %08lx\n", + WARN("[%p]: unknown msg %04x wp %08lx lp %08lx\n", hwnd, msg, wParam, lParam ); } =