From 3b897823aa1166ce91a08f87515654e2be8eaafd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Thu, 22 Jan 2004 18:45:19 +0000 Subject: [PATCH] Sync with Wine-20040121 svn path=/trunk/; revision=7825 --- reactos/lib/comctl32/animate.c | 13 ++- reactos/lib/comctl32/imagelist.c | 2 +- reactos/lib/comctl32/rebar.c | 144 ++++++++++++++++++++++++------- reactos/lib/comctl32/tab.c | 2 +- reactos/lib/comctl32/treeview.c | 14 +-- 5 files changed, 129 insertions(+), 46 deletions(-) diff --git a/reactos/lib/comctl32/animate.c b/reactos/lib/comctl32/animate.c index 35c126fefec..0297d4d43ee 100644 --- a/reactos/lib/comctl32/animate.c +++ b/reactos/lib/comctl32/animate.c @@ -899,10 +899,15 @@ static LRESULT WINAPI ANIMATE_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP { ANIMATE_INFO* infoPtr = ANIMATE_GetInfoPtr(hWnd); - /* the animation isn't playing, don't paint */ - if(!infoPtr->uTimer && !infoPtr->hThread) - /* default paint handling */ - return DefWindowProcA(hWnd, uMsg, wParam, lParam); + /* the animation isn't playing, or has not decompressed + * (and displayed) the first frame yet, don't paint + */ + if ((!infoPtr->uTimer && !infoPtr->hThread) || + !infoPtr->hbmPrevFrame) + { + /* default paint handling */ + return DefWindowProcA(hWnd, uMsg, wParam, lParam); + } if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) infoPtr->hbrushBG = (HBRUSH)SendMessageA(infoPtr->hwndNotify, diff --git a/reactos/lib/comctl32/imagelist.c b/reactos/lib/comctl32/imagelist.c index 78d33ab03de..dbcfb07eaf2 100644 --- a/reactos/lib/comctl32/imagelist.c +++ b/reactos/lib/comctl32/imagelist.c @@ -1652,7 +1652,7 @@ ImageList_LoadImageW (HINSTANCE hi, LPCWSTR lpbmp, INT cx, INT cGrow, if (uType == IMAGE_BITMAP) { BITMAP bmp; - GetObjectA (handle, sizeof(BITMAP), &bmp); + GetObjectW (handle, sizeof(BITMAP), &bmp); /* To match windows behavior, if cx is set to zero and the flag DI_DEFAULTSIZE is specified, cx becomes the diff --git a/reactos/lib/comctl32/rebar.c b/reactos/lib/comctl32/rebar.c index dc096f1ed6b..66f758fdf36 100644 --- a/reactos/lib/comctl32/rebar.c +++ b/reactos/lib/comctl32/rebar.c @@ -2090,25 +2090,42 @@ REBAR_ValidateBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand) } -static void +static BOOL REBAR_CommonSetupBand (HWND hwnd, LPREBARBANDINFOA lprbbi, REBAR_BAND *lpBand) /* Function: This routine copies the supplied values from */ /* user input (lprbbi) to the internal band structure. */ + /* It returns true if something changed and false if not. */ { + BOOL bChanged = FALSE; + lpBand->fMask |= lprbbi->fMask; - if (lprbbi->fMask & RBBIM_STYLE) + if( (lprbbi->fMask & RBBIM_STYLE) && + (lpBand->fStyle != lprbbi->fStyle ) ) + { lpBand->fStyle = lprbbi->fStyle; - - if (lprbbi->fMask & RBBIM_COLORS) { - lpBand->clrFore = lprbbi->clrFore; - lpBand->clrBack = lprbbi->clrBack; + bChanged = TRUE; } - if (lprbbi->fMask & RBBIM_IMAGE) - lpBand->iImage = lprbbi->iImage; + if( (lprbbi->fMask & RBBIM_COLORS) && + ( ( lpBand->clrFore != lprbbi->clrFore ) || + ( lpBand->clrBack != lprbbi->clrBack ) ) ) + { + lpBand->clrFore = lprbbi->clrFore; + lpBand->clrBack = lprbbi->clrBack; + bChanged = TRUE; + } - if (lprbbi->fMask & RBBIM_CHILD) { + if( (lprbbi->fMask & RBBIM_IMAGE) && + ( lpBand->iImage != lprbbi->iImage ) ) + { + lpBand->iImage = lprbbi->iImage; + bChanged = TRUE; + } + + if( (lprbbi->fMask & RBBIM_CHILD) && + (lprbbi->hwndChild != lpBand->hwndChild ) ) + { if (lprbbi->hwndChild) { lpBand->hwndChild = lprbbi->hwndChild; lpBand->hwndPrevParent = @@ -2123,9 +2140,21 @@ REBAR_CommonSetupBand (HWND hwnd, LPREBARBANDINFOA lprbbi, REBAR_BAND *lpBand) lpBand->hwndChild = 0; lpBand->hwndPrevParent = 0; } + bChanged = TRUE; } - if (lprbbi->fMask & RBBIM_CHILDSIZE) { + if( (lprbbi->fMask & RBBIM_CHILDSIZE) && + ( (lpBand->cxMinChild != lprbbi->cxMinChild) || + (lpBand->cyMinChild != lprbbi->cyMinChild ) || + ( (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) && + ( (lpBand->cyChild != lprbbi->cyChild ) || + (lpBand->cyMaxChild != lprbbi->cyMaxChild ) || + (lpBand->cyIntegral != lprbbi->cyIntegral ) ) ) || + ( (lprbbi->cbSize < sizeof (REBARBANDINFOA)) && + ( (lpBand->cyChild || + lpBand->cyMaxChild || + lpBand->cyIntegral ) ) ) ) ) + { lpBand->cxMinChild = lprbbi->cxMinChild; lpBand->cyMinChild = lprbbi->cyMinChild; if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) { @@ -2139,28 +2168,55 @@ REBAR_CommonSetupBand (HWND hwnd, LPREBARBANDINFOA lprbbi, REBAR_BAND *lpBand) lpBand->cyMaxChild = 0; lpBand->cyIntegral = 0; } + bChanged = TRUE; } - if (lprbbi->fMask & RBBIM_SIZE) + if( (lprbbi->fMask & RBBIM_SIZE) && + (lpBand->cx != lprbbi->cx ) ) + { lpBand->cx = lprbbi->cx; + bChanged = TRUE; + } - if (lprbbi->fMask & RBBIM_BACKGROUND) + if( (lprbbi->fMask & RBBIM_BACKGROUND) && + ( lpBand->hbmBack != lprbbi->hbmBack ) ) + { lpBand->hbmBack = lprbbi->hbmBack; + bChanged = TRUE; + } - if (lprbbi->fMask & RBBIM_ID) + if( (lprbbi->fMask & RBBIM_ID) && + (lpBand->wID != lprbbi->wID ) ) + { lpBand->wID = lprbbi->wID; + bChanged = TRUE; + } /* check for additional data */ if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) { - if (lprbbi->fMask & RBBIM_IDEALSIZE) + if( (lprbbi->fMask & RBBIM_IDEALSIZE) && + ( lpBand->cxIdeal != lprbbi->cxIdeal ) ) + { lpBand->cxIdeal = lprbbi->cxIdeal; + bChanged = TRUE; + } - if (lprbbi->fMask & RBBIM_LPARAM) + if( (lprbbi->fMask & RBBIM_LPARAM) && + (lpBand->lParam != lprbbi->lParam ) ) + { lpBand->lParam = lprbbi->lParam; + bChanged = TRUE; + } - if (lprbbi->fMask & RBBIM_HEADERSIZE) + if( (lprbbi->fMask & RBBIM_HEADERSIZE) && + (lpBand->cxHeader != lprbbi->cxHeader ) ) + { lpBand->cxHeader = lprbbi->cxHeader; + bChanged = TRUE; + } } + + return bChanged; } static LRESULT @@ -3430,11 +3486,19 @@ REBAR_MoveBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) } +/* return TRUE if two strings are different */ +static BOOL +REBAR_strdifW( LPCWSTR a, LPCWSTR b ) +{ + return ( (a && !b) || (b && !a) || (a && b && lstrcmpW(a, b) ) ); +} + static LRESULT REBAR_SetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam; REBAR_BAND *lpBand; + BOOL bChanged; if (lprbbi == NULL) return FALSE; @@ -3449,27 +3513,39 @@ REBAR_SetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) /* set band information */ lpBand = &infoPtr->bands[(UINT)wParam]; - REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand); + bChanged = REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand); if (lprbbi->fMask & RBBIM_TEXT) { - if (lpBand->lpText) { - Free (lpBand->lpText); - lpBand->lpText = NULL; - } - if (lprbbi->lpText) { - INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 ); + LPWSTR wstr = NULL; + + if (lprbbi->lpText) + { + INT len; + len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 ); if (len > 1) - { - lpBand->lpText = (LPWSTR)Alloc (len*sizeof(WCHAR)); - MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len ); - } - } + wstr = (LPWSTR)Alloc (len*sizeof(WCHAR)); + if (wstr) + MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, wstr, len ); + } + if (REBAR_strdifW(lpBand->lpText, wstr)) { + if (lpBand->lpText) { + Free (lpBand->lpText); + lpBand->lpText = NULL; + } + if (wstr) { + lpBand->lpText = wstr; + wstr = NULL; + } + bChanged = TRUE; + } + if (wstr) + Free (wstr); } REBAR_ValidateBand (infoPtr, lpBand); REBAR_DumpBand (infoPtr); - if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) { + if (bChanged && (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE))) { REBAR_Layout (infoPtr, NULL, TRUE, FALSE); InvalidateRect(infoPtr->hwndSelf, 0, 1); } @@ -3477,12 +3553,12 @@ REBAR_SetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) return TRUE; } - static LRESULT REBAR_SetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam; REBAR_BAND *lpBand; + BOOL bChanged; if (lprbbi == NULL) return FALSE; @@ -3497,8 +3573,9 @@ REBAR_SetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) /* set band information */ lpBand = &infoPtr->bands[(UINT)wParam]; - REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand); - if (lprbbi->fMask & RBBIM_TEXT) { + bChanged = REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand); + if( (lprbbi->fMask & RBBIM_TEXT) && + REBAR_strdifW( lpBand->lpText, lprbbi->lpText ) ) { if (lpBand->lpText) { Free (lpBand->lpText); lpBand->lpText = NULL; @@ -3511,13 +3588,14 @@ REBAR_SetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) strcpyW (lpBand->lpText, lprbbi->lpText); } } + bChanged = TRUE; } REBAR_ValidateBand (infoPtr, lpBand); REBAR_DumpBand (infoPtr); - if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) { + if ( bChanged && (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) ) { REBAR_Layout (infoPtr, NULL, TRUE, FALSE); InvalidateRect(infoPtr->hwndSelf, 0, 1); } diff --git a/reactos/lib/comctl32/tab.c b/reactos/lib/comctl32/tab.c index 59ad29a765e..7d1f1b90b6e 100644 --- a/reactos/lib/comctl32/tab.c +++ b/reactos/lib/comctl32/tab.c @@ -1060,7 +1060,7 @@ static void TAB_SetupScrolling( * list and ignores scrolling and selection. * It also uses the current font to determine the height of the tab row and * it checks if all the tabs fit in the client area of the window. If they - * dont, a scrolling control is added. + * don't, a scrolling control is added. */ static void TAB_SetItemBounds (HWND hwnd) { diff --git a/reactos/lib/comctl32/treeview.c b/reactos/lib/comctl32/treeview.c index 40964c57dbb..1c1caec0c77 100644 --- a/reactos/lib/comctl32/treeview.c +++ b/reactos/lib/comctl32/treeview.c @@ -1161,7 +1161,7 @@ TREEVIEW_DoSetItemT(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem, static LRESULT TREEVIEW_InsertItemT(TREEVIEW_INFO *infoPtr, const TVINSERTSTRUCTW *ptdi, BOOL isW) { - const TVITEMEXW *tvItem = &ptdi->DUMMYUNIONNAME.itemex; + const TVITEMEXW *tvItem = &ptdi->u.itemex; HTREEITEM insertAfter; TREEVIEW_ITEM *newItem, *parentItem; BOOL bTextUpdated = FALSE; @@ -1440,8 +1440,7 @@ TREEVIEW_RemoveTree(TREEVIEW_INFO *infoPtr) static LRESULT TREEVIEW_DeleteItem(TREEVIEW_INFO *infoPtr, HTREEITEM wineItem) { - TREEVIEW_ITEM *oldSelection = infoPtr->selectedItem; - TREEVIEW_ITEM *newSelection = oldSelection; + TREEVIEW_ITEM *newSelection = NULL; TREEVIEW_ITEM *newFirstVisible = NULL; TREEVIEW_ITEM *parent, *prev = NULL; BOOL visible = FALSE; @@ -1476,6 +1475,9 @@ TREEVIEW_DeleteItem(TREEVIEW_INFO *infoPtr, HTREEITEM wineItem) newSelection = wineItem->nextSibling; else if (wineItem->parent != infoPtr->root) newSelection = wineItem->parent; + else + newSelection = wineItem->prevSibling; + TRACE("newSelection = %p\n", newSelection); } if (infoPtr->firstVisible == wineItem) @@ -1494,13 +1496,11 @@ TREEVIEW_DeleteItem(TREEVIEW_INFO *infoPtr, HTREEITEM wineItem) TREEVIEW_RemoveItem(infoPtr, wineItem); } - /* Don't change if somebody else already has. */ - if (oldSelection == infoPtr->selectedItem) + /* Don't change if somebody else already has (infoPtr->selectedItem is cleared by FreeItem). */ + if (!infoPtr->selectedItem && newSelection) { if (TREEVIEW_ValidItem(infoPtr, newSelection)) TREEVIEW_DoSelectItem(infoPtr, TVGN_CARET, newSelection, TVC_UNKNOWN); - else - infoPtr->selectedItem = 0; } /* Validate insertMark dropItem.