diff --git a/reactos/include/wine/commctrl.h b/reactos/include/wine/commctrl.h index fccd7791b88..b7f8ff630b4 100644 --- a/reactos/include/wine/commctrl.h +++ b/reactos/include/wine/commctrl.h @@ -1,5 +1,4 @@ -/* $Id $ - * +/* * Compatibility header * * This header is wrapper to allow compilation of Wine DLLs under ReactOS @@ -59,6 +58,18 @@ typedef LPFINDINFOW LPLVFINDINFOW; #define HDM_SETBITMAPMARGIN (HDM_FIRST+20) #define HDM_GETBITMAPMARGIN (HDM_FIRST+21) -#define FLATSB_CLASSA "flatsb_class32" +#define SB_SETBORDERS (WM_USER+5) + +#define FLATSB_CLASSA "flatsb_class32" +#define DRAGLISTMSGSTRINGA "commctrl_DragListMsg" +#if defined(__GNUC__) +# define DRAGLISTMSGSTRINGW (const WCHAR []){ 'c','o','m','m','c','t','r','l', \ + '_','D','r','a','g','L','i','s','t','M','s','g',0 } +#elif defined(_MSC_VER) +# define DRAGLISTMSGSTRINGW L"commctrl_DragListMsg" +#else +static const WCHAR DRAGLISTMSGSTRINGW[] = { 'c','o','m','m','c','t','r','l', \ + '_','D','r','a','g','L','i','s','t','M','s','g',0 }; +#endif #endif /* __WINE_COMMCTRL_H */ diff --git a/reactos/lib/comctl32/comctl32.spec b/reactos/lib/comctl32/comctl32.spec index 90eca7d7ab0..9ea8766c8b3 100644 --- a/reactos/lib/comctl32/comctl32.spec +++ b/reactos/lib/comctl32/comctl32.spec @@ -101,10 +101,10 @@ 402 stdcall -noname FindMRUStringW(long wstr ptr) 403 stdcall -noname EnumMRUListW(long long ptr long) 404 stdcall -noname CreateMRUListLazyW(ptr long long long) -410 stdcall SetWindowSubclass(long ptr long long) -411 stdcall GetWindowSubclass(long ptr long ptr) -412 stdcall RemoveWindowSubclass(long ptr long) -413 stdcall DefSubclassProc(long long long long) +410 stdcall -noname SetWindowSubclass(long ptr long long) +411 stdcall -noname GetWindowSubclass(long ptr long ptr) +412 stdcall -noname RemoveWindowSubclass(long ptr long) +413 stdcall -noname DefSubclassProc(long long long long) 414 stdcall -noname MirrorIcon(ptr ptr) 415 stdcall DrawTextWrap(long wstr long ptr long) user32.DrawTextW 416 stdcall DrawTextExPrivWrap(long wstr long ptr long ptr) user32.DrawTextExW diff --git a/reactos/lib/comctl32/comctl_Es.rc b/reactos/lib/comctl32/comctl_Es.rc index 837a9e9ebd6..feb479b5451 100644 --- a/reactos/lib/comctl32/comctl_Es.rc +++ b/reactos/lib/comctl32/comctl_Es.rc @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -LANGUAGE LANG_SPANISH, SUBLANG_DEFAULT +LANGUAGE LANG_SPANISH, SUBLANG_NEUTRAL IDD_PROPSHEET DIALOG DISCARDABLE 0, 0, 220, 140 STYLE DS_CONTEXTHELP | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE diff --git a/reactos/lib/comctl32/draglist.c b/reactos/lib/comctl32/draglist.c index bc1deea5054..4a9d619f07b 100644 --- a/reactos/lib/comctl32/draglist.c +++ b/reactos/lib/comctl32/draglist.c @@ -42,10 +42,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(commctrl); -/* for compiler compatibility we only accept literal ASCII strings */ -#undef TEXT -#define TEXT(string) string - #define DRAGLIST_SUBCLASSID 0 #define DRAGLIST_SCROLLPERIOD 200 #define DRAGLIST_TIMERID 666 @@ -95,7 +91,7 @@ static LRESULT DragList_Notify(HWND hwndLB, UINT uNotification) } /* cleans up after dragging */ -static inline void DragList_EndDrag(HWND hwnd, DRAGLISTDATA * data) +static void DragList_EndDrag(HWND hwnd, DRAGLISTDATA * data) { KillTimer(hwnd, DRAGLIST_TIMERID); ReleaseCapture(); @@ -207,12 +203,12 @@ DragList_SubclassWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, */ BOOL WINAPI MakeDragList (HWND hwndLB) { - DRAGLISTDATA * data = Alloc(sizeof(DRAGLISTDATA)); + DRAGLISTDATA *data = Alloc(sizeof(DRAGLISTDATA)); TRACE("(%p)\n", hwndLB); if (!uDragListMessage) - uDragListMessage = RegisterWindowMessageA(DRAGLISTMSGSTRING); + uDragListMessage = RegisterWindowMessageW(DRAGLISTMSGSTRINGW); return SetWindowSubclass(hwndLB, DragList_SubclassWindowProc, DRAGLIST_SUBCLASSID, (DWORD_PTR)data); } @@ -301,14 +297,14 @@ INT WINAPI LBItemFromPt (HWND hwndLB, POINT pt, BOOL bAutoScroll) ScreenToClient (hwndLB, &pt); GetClientRect (hwndLB, &rcClient); - nIndex = (INT)SendMessageA (hwndLB, LB_GETTOPINDEX, 0, 0); + nIndex = (INT)SendMessageW (hwndLB, LB_GETTOPINDEX, 0, 0); if (PtInRect (&rcClient, pt)) { /* point is inside -- get the item index */ while (TRUE) { - if (SendMessageA (hwndLB, LB_GETITEMRECT, nIndex, (LPARAM)&rcClient) == LB_ERR) + if (SendMessageW (hwndLB, LB_GETITEMRECT, nIndex, (LPARAM)&rcClient) == LB_ERR) return -1; if (PtInRect (&rcClient, pt)) @@ -338,7 +334,7 @@ INT WINAPI LBItemFromPt (HWND hwndLB, POINT pt, BOOL bAutoScroll) dwLastScrollTime = dwScrollTime; - SendMessageA (hwndLB, LB_SETTOPINDEX, (WPARAM)nIndex, 0); + SendMessageW (hwndLB, LB_SETTOPINDEX, (WPARAM)nIndex, 0); } return -1; diff --git a/reactos/lib/comctl32/header.c b/reactos/lib/comctl32/header.c index 03b80845264..601a0c886fe 100644 --- a/reactos/lib/comctl32/header.c +++ b/reactos/lib/comctl32/header.c @@ -324,9 +324,19 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack) } else tx = 0; - ImageList_DrawEx(infoPtr->himl, phdi->iImage, hdc, r.left + tx + 2*infoPtr->iMargin, - r.top + (r.bottom-r.top-infoPtr->himl->cy)/2, infoPtr->himl->cx, r.bottom-r.top, - CLR_DEFAULT, CLR_DEFAULT, 0); + + if (tx < (r.right-r.left - infoPtr->himl->cx - GetSystemMetrics(SM_CXEDGE))) + ImageList_DrawEx(infoPtr->himl, phdi->iImage, hdc, r.left + tx + 2*infoPtr->iMargin, + r.top + (r.bottom-r.top-infoPtr->himl->cy)/2, infoPtr->himl->cx, r.bottom-r.top, + CLR_DEFAULT, CLR_DEFAULT, 0); + else { + INT x = max(r.right - infoPtr->iMargin - infoPtr->himl->cx, r.left); + INT cx = min(infoPtr->himl->cx, r.right-r.left - GetSystemMetrics(SM_CXEDGE)); + ImageList_DrawEx(infoPtr->himl, phdi->iImage, hdc, x , + r.top + (r.bottom-r.top-infoPtr->himl->cy)/2, cx, r.bottom-r.top, + CLR_DEFAULT, CLR_DEFAULT, 0); + r.right -= infoPtr->himl->cx - infoPtr->iMargin; + } } if (((phdi->fmt & HDF_STRING) @@ -1203,10 +1213,8 @@ HEADER_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) { lpItem->iOrder = phdi->iOrder; } - else - lpItem->iOrder = nItem; - HEADER_SendHeaderNotify (hwnd, HDN_ITEMCHANGEDA, nItem, phdi->mask); + HEADER_SendHeaderNotify (hwnd, HDN_ITEMCHANGEDA, nItem, phdi->mask); HEADER_SetItemBounds (hwnd); @@ -1270,10 +1278,8 @@ HEADER_SetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam) { lpItem->iOrder = phdi->iOrder; } - else - lpItem->iOrder = nItem; - HEADER_SendHeaderNotify(hwnd, HDN_ITEMCHANGEDW, nItem, phdi->mask); + HEADER_SendHeaderNotify(hwnd, HDN_ITEMCHANGEDW, nItem, phdi->mask); HEADER_SetItemBounds (hwnd); diff --git a/reactos/lib/comctl32/imagelist.c b/reactos/lib/comctl32/imagelist.c index 37f7def4b5e..db098b2cc11 100644 --- a/reactos/lib/comctl32/imagelist.c +++ b/reactos/lib/comctl32/imagelist.c @@ -1577,84 +1577,28 @@ ImageList_GetImageRect (HIMAGELIST himl, INT i, LPRECT lpRect) * * Creates an image list from a bitmap, icon or cursor. * - * PARAMS - * hi [I] instance handle - * lpbmp [I] name or id of the image - * cx [I] width of each image - * cGrow [I] number of images to expand - * clrMask [I] mask color - * uType [I] type of image to load - * uFlags [I] loading flags - * - * RETURNS - * Success: handle to the loaded image list - * Failure: NULL - * * SEE - * LoadImage () + * ImageList_LoadImageW () */ HIMAGELIST WINAPI ImageList_LoadImageA (HINSTANCE hi, LPCSTR lpbmp, INT cx, INT cGrow, COLORREF clrMask, UINT uType, UINT uFlags) { - HIMAGELIST himl = NULL; - HANDLE handle; - INT nImageCount; + HIMAGELIST himl; + LPWSTR lpbmpW; + DWORD len; - handle = LoadImageA (hi, lpbmp, uType, 0, 0, uFlags); - if (!handle) { - ERR("Error loading image!\n"); - return NULL; - } + if (!HIWORD(lpbmp)) + return ImageList_LoadImageW(hi, (LPCWSTR)lpbmp, cx, cGrow, clrMask, + uType, uFlags); - if (uType == IMAGE_BITMAP) { - BITMAP bmp; - GetObjectA (handle, sizeof(BITMAP), &bmp); - - /* To match windows behavior, if cx is set to zero and - the flag DI_DEFAULTSIZE is specified, cx becomes the - system metric value for icons. If the flag is not specified - the function sets the size to the height of the bitmap */ - if (cx == 0) - { - if (uFlags & DI_DEFAULTSIZE) - cx = GetSystemMetrics (SM_CXICON); - else - cx = bmp.bmHeight; - } - - nImageCount = bmp.bmWidth / cx; - - himl = ImageList_Create (cx, bmp.bmHeight, ILC_MASK | ILC_COLOR, - nImageCount, cGrow); - if (!himl) { - DeleteObject (handle); - return NULL; - } - ImageList_AddMasked (himl, (HBITMAP)handle, clrMask); - } - else if ((uType == IMAGE_ICON) || (uType == IMAGE_CURSOR)) { - ICONINFO ii; - BITMAP bmp; - - GetIconInfo (handle, &ii); - GetObjectA (ii.hbmColor, sizeof(BITMAP), (LPVOID)&bmp); - himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, - ILC_MASK | ILC_COLOR, 1, cGrow); - if (!himl) { - DeleteObject (ii.hbmColor); - DeleteObject (ii.hbmMask); - DeleteObject (handle); - return NULL; - } - ImageList_Add (himl, ii.hbmColor, ii.hbmMask); - DeleteObject (ii.hbmColor); - DeleteObject (ii.hbmMask); - } - - DeleteObject (handle); + len = MultiByteToWideChar(CP_ACP, 0, lpbmp, -1, NULL, 0); + lpbmpW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, lpbmp, -1, lpbmpW, len); + himl = ImageList_LoadImageW(hi, lpbmpW, cx, cGrow, clrMask, uType, uFlags); + HeapFree(GetProcessHeap(), 0, lpbmpW); return himl; } @@ -1683,7 +1627,7 @@ ImageList_LoadImageA (HINSTANCE hi, LPCSTR lpbmp, INT cx, INT cGrow, HIMAGELIST WINAPI ImageList_LoadImageW (HINSTANCE hi, LPCWSTR lpbmp, INT cx, INT cGrow, - COLORREF clrMask, UINT uType, UINT uFlags) + COLORREF clrMask, UINT uType, UINT uFlags) { HIMAGELIST himl = NULL; HANDLE handle; @@ -1726,7 +1670,7 @@ ImageList_LoadImageW (HINSTANCE hi, LPCWSTR lpbmp, INT cx, INT cGrow, BITMAP bmp; GetIconInfo (handle, &ii); - GetObjectW (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp); + GetObjectW (ii.hbmColor, sizeof(BITMAP), (LPVOID)&bmp); himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, ILC_MASK | ILC_COLOR, 1, cGrow); if (!himl) { diff --git a/reactos/lib/comctl32/listview.c b/reactos/lib/comctl32/listview.c index 23875cf9df0..e35c4f57582 100644 --- a/reactos/lib/comctl32/listview.c +++ b/reactos/lib/comctl32/listview.c @@ -6276,7 +6276,7 @@ static BOOL LISTVIEW_SetBkColor(LISTVIEW_INFO *infoPtr, COLORREF clrBk) if (infoPtr->clrBk != CLR_NONE) DeleteObject(infoPtr->hBkBrush); infoPtr->clrBk = clrBk; if (clrBk == CLR_NONE) - infoPtr->hBkBrush = (HBRUSH)GetClassLongW(infoPtr->hwndSelf, GCL_HBRBACKGROUND); + infoPtr->hBkBrush = (HBRUSH)GetClassLongPtrW(infoPtr->hwndSelf, GCLP_HBRBACKGROUND); else infoPtr->hBkBrush = CreateSolidBrush(clrBk); LISTVIEW_InvalidateList(infoPtr); @@ -8253,6 +8253,7 @@ static LRESULT LISTVIEW_HeaderNotification(LISTVIEW_INFO *infoPtr, const NMHEADE lpColumnInfo->rcHeader.right += dx; LISTVIEW_ScrollColumns(infoPtr, lpnmh->iItem + 1, dx); + LISTVIEW_UpdateItemSize(infoPtr); if (uView == LVS_REPORT && is_redrawing(infoPtr)) { /* this trick works for left aligned columns only */ diff --git a/reactos/lib/comctl32/rebar.c b/reactos/lib/comctl32/rebar.c index b01295bf0ef..1b0f4a793cc 100644 --- a/reactos/lib/comctl32/rebar.c +++ b/reactos/lib/comctl32/rebar.c @@ -134,7 +134,7 @@ typedef struct SIZE offChild; /* x,y offset if child is not FIXEDSIZE */ UINT uMinHeight; - INT iRow; /* row this band assigned to */ + INT iRow; /* zero-based index of the row this band assigned to */ UINT fStatus; /* status flags, reset only by _Validate */ UINT fDraw; /* drawing flags, reset only by _Layout */ UINT uCDret; /* last return from NM_CUSTOMDRAW */ @@ -360,8 +360,14 @@ static VOID REBAR_DumpBandInfo( LPREBARBANDINFOA pB) { if( !TRACE_ON(rebar) ) return; - TRACE("band info: ID=%u, size=%u, child=%p, clrF=0x%06lx, clrB=0x%06lx\n", - pB->wID, pB->cbSize, pB->hwndChild, pB->clrFore, pB->clrBack); + TRACE("band info: "); + if (pB->fMask & RBBIM_ID); + TRACE("ID=%u, ", pB->wID); + TRACE("size=%u, child=%p", pB->cbSize, pB->hwndChild); + if (pB->fMask & RBBIM_COLORS) + TRACE(", clrF=0x%06lx, clrB=0x%06lx", pB->clrFore, pB->clrBack); + TRACE("\n"); + TRACE("band info: mask=0x%08x (%s)\n", pB->fMask, REBAR_FmtMask(pB->fMask)); if (pB->fMask & RBBIM_STYLE) TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle)); @@ -403,8 +409,14 @@ REBAR_DumpBand (REBAR_INFO *iP) (iP->NtfUnicode)?"TRUE":"FALSE", (iP->DoRedraw)?"TRUE":"FALSE"); for (i = 0; i < iP->uNumBands; i++) { pB = &iP->bands[i]; - TRACE("band # %u: ID=%u, child=%p, row=%u, clrF=0x%06lx, clrB=0x%06lx\n", - i, pB->wID, pB->hwndChild, pB->iRow, pB->clrFore, pB->clrBack); + TRACE("band # %u:", i); + if (pB->fMask & RBBIM_ID); + TRACE(" ID=%u", pB->wID); + if (pB->fMask & RBBIM_CHILD) + TRACE(" child=%p", pB->hwndChild); + if (pB->fMask & RBBIM_COLORS) + TRACE(" clrF=0x%06lx clrB=0x%06lx", pB->clrFore, pB->clrBack); + TRACE("\n"); TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask)); if (pB->fMask & RBBIM_STYLE) TRACE("band # %u: style=0x%08x (%s)\n", @@ -1419,7 +1431,7 @@ REBAR_Layout (REBAR_INFO *infoPtr, LPRECT lpRect, BOOL notify, BOOL resetclient) clientcx, clientcy, adjcx, adjcy); x = initx; y = inity; - row = 1; + row = 0; cx = 0; mcy = 0; rowstart = 0; @@ -1560,7 +1572,7 @@ REBAR_Layout (REBAR_INFO *infoPtr, LPRECT lpRect, BOOL notify, BOOL resetclient) } if (infoPtr->uNumBands) - infoPtr->uNumRows = row; + infoPtr->uNumRows = row + 1; /* ******* End Phase 1 - all bands on row at minimum size ******* */ @@ -1583,7 +1595,7 @@ REBAR_Layout (REBAR_INFO *infoPtr, LPRECT lpRect, BOOL notify, BOOL resetclient) /* now adjust all rectangles by using the height found above */ xy = 0; - row = 1; + row = 0; for (i=0; iuNumBands; i++) { lpBand = &infoPtr->bands[i]; if (HIDDENBAND(lpBand)) continue; @@ -1759,6 +1771,7 @@ REBAR_Layout (REBAR_INFO *infoPtr, LPRECT lpRect, BOOL notify, BOOL resetclient) if( !(lpBand->fDraw&DRAW_LAST_IN_ROW) ) continue; + /* FIXME: this next line is wrong, but fixing it to be inverted causes IE's sidebars to be the wrong size */ if (lpBand->fMask & RBBS_VARIABLEHEIGHT) continue; if (((INT)lpBand->cyMaxChild < 1) || ((INT)lpBand->cyIntegral < 1)) { @@ -1943,7 +1956,7 @@ REBAR_ValidateBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand) infoPtr->fStatus |= BAND_NEEDS_LAYOUT; /* Header is where the image, text and gripper exist */ - /* in the band and preceed the child window. */ + /* in the band and precede the child window. */ /* count number of non-FIXEDSIZE and non-Hidden bands */ nonfixed = 0; diff --git a/reactos/lib/comctl32/status.c b/reactos/lib/comctl32/status.c index d5b94c44ae2..bd4898cd303 100644 --- a/reactos/lib/comctl32/status.c +++ b/reactos/lib/comctl32/status.c @@ -79,6 +79,9 @@ typedef struct BOOL NtfUnicode; /* notify format */ STATUSWINDOWPART part0; /* simple window */ STATUSWINDOWPART* parts; + INT horizontalBorder; + INT verticalBorder; + INT horizontalGap; } STATUS_INFO; /* @@ -159,28 +162,24 @@ STATUSBAR_DrawPart (STATUS_INFO *infoPtr, HDC hdc, STATUSWINDOWPART *part, int i DrawEdge(hdc, &r, border, BF_RECT|BF_ADJUST); - if (part->style & SBT_OWNERDRAW) - { - DRAWITEMSTRUCT dis; + if (part->style & SBT_OWNERDRAW) { + DRAWITEMSTRUCT dis; - dis.CtlID = GetWindowLongPtrW (infoPtr->Self, GWLP_ID); - dis.itemID = itemID; - dis.hwndItem = infoPtr->Self; - dis.hDC = hdc; - dis.rcItem = r; - dis.itemData = (INT)part->text; - SendMessageW (infoPtr->Notify, WM_DRAWITEM, (WPARAM)dis.CtlID, (LPARAM)&dis); - } - else - { - if (part->hIcon) - { - INT cy = r.bottom - r.top; + dis.CtlID = GetWindowLongPtrW (infoPtr->Self, GWLP_ID); + dis.itemID = itemID; + dis.hwndItem = infoPtr->Self; + dis.hDC = hdc; + dis.rcItem = r; + dis.itemData = (INT)part->text; + SendMessageW (infoPtr->Notify, WM_DRAWITEM, (WPARAM)dis.CtlID, (LPARAM)&dis); + } else { + if (part->hIcon) { + INT cy = r.bottom - r.top; - r.left += 2; - DrawIconEx (hdc, r.left, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL); - r.left += cy; - } + r.left += 2; + DrawIconEx (hdc, r.left, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL); + r.left += cy; + } DrawStatusTextW (hdc, &r, part->text, SBT_NOBORDERS); } } @@ -213,12 +212,11 @@ STATUSBAR_RefreshPart (STATUS_INFO *infoPtr, HDC hdc, STATUSWINDOWPART *part, in if (infoPtr->clrBk != CLR_DEFAULT) DeleteObject (hbrBk); - if (GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP) - { - RECT rect; + if (GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP) { + RECT rect; - GetClientRect (infoPtr->Self, &rect); - STATUSBAR_DrawSizeGrip (hdc, &rect); + GetClientRect (infoPtr->Self, &rect); + STATUSBAR_DrawSizeGrip (hdc, &rect); } } @@ -240,19 +238,19 @@ STATUSBAR_Refresh (STATUS_INFO *infoPtr, HDC hdc) GetClientRect (infoPtr->Self, &rect); if (infoPtr->clrBk != CLR_DEFAULT) - hbrBk = CreateSolidBrush (infoPtr->clrBk); + hbrBk = CreateSolidBrush (infoPtr->clrBk); else - hbrBk = GetSysColorBrush (COLOR_3DFACE); + hbrBk = GetSysColorBrush (COLOR_3DFACE); FillRect(hdc, &rect, hbrBk); hOldFont = SelectObject (hdc, infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont); if (infoPtr->simple) { - STATUSBAR_RefreshPart (infoPtr, hdc, &infoPtr->part0, 0); + STATUSBAR_RefreshPart (infoPtr, hdc, &infoPtr->part0, 0); } else { - for (i = 0; i < infoPtr->numParts; i++) { - STATUSBAR_RefreshPart (infoPtr, hdc, &infoPtr->parts[i], i); - } + for (i = 0; i < infoPtr->numParts; i++) { + STATUSBAR_RefreshPart (infoPtr, hdc, &infoPtr->parts[i], i); + } } SelectObject (hdc, hOldFont); @@ -278,7 +276,8 @@ STATUSBAR_SetPartBounds (STATUS_INFO *infoPtr) GetClientRect (infoPtr->Self, &rect); TRACE("client wnd size is %ld,%ld - %ld,%ld\n", rect.left, rect.top, rect.right, rect.bottom); - rect.top += VERT_BORDER; + rect.left += infoPtr->horizontalBorder; + rect.top += infoPtr->verticalBorder; /* set bounds for simple rectangle */ infoPtr->part0.bound = rect; @@ -292,7 +291,7 @@ STATUSBAR_SetPartBounds (STATUS_INFO *infoPtr) if (i == 0) r->left = 0; else - r->left = infoPtr->parts[i-1].bound.right + HORZ_GAP; + r->left = infoPtr->parts[i-1].bound.right + infoPtr->horizontalGap; if (part->x == -1) r->right = rect.right; else @@ -331,12 +330,25 @@ STATUSBAR_Relay2Tip (STATUS_INFO *infoPtr, UINT uMsg, static BOOL -STATUSBAR_GetBorders (INT out[]) +STATUSBAR_GetBorders (STATUS_INFO *infoPtr, INT out[]) { TRACE("\n"); - out[0] = HORZ_BORDER; /* horizontal border width */ - out[1] = VERT_BORDER; /* vertical border width */ - out[2] = HORZ_GAP; /* width of border between rectangles */ + out[0] = infoPtr->horizontalBorder; + out[1] = infoPtr->verticalBorder; + out[2] = infoPtr->horizontalGap; + + return TRUE; +} + + +static BOOL +STATUSBAR_SetBorders (STATUS_INFO *infoPtr, INT in[]) +{ + TRACE("\n"); + infoPtr->horizontalBorder = in[0]; + infoPtr->verticalBorder = in[1]; + infoPtr->horizontalGap = in[2]; + InvalidateRect(infoPtr->Self, NULL, FALSE); return TRUE; } @@ -560,13 +572,13 @@ STATUSBAR_SetMinHeight (STATUS_INFO *infoPtr, INT height) RECT parent_rect; GetClientRect (infoPtr->Notify, &parent_rect); - infoPtr->height = height + VERT_BORDER; + infoPtr->height = height + infoPtr->verticalBorder; width = parent_rect.right - parent_rect.left; x = parent_rect.left; y = parent_rect.bottom - infoPtr->height; MoveWindow (infoPtr->Self, parent_rect.left, - parent_rect.bottom - infoPtr->height, - width, infoPtr->height, TRUE); + parent_rect.bottom - infoPtr->height, + width, infoPtr->height, TRUE); STATUSBAR_SetPartBounds (infoPtr); } @@ -728,8 +740,7 @@ STATUSBAR_SetTipTextA (STATUS_INFO *infoPtr, INT id, LPSTR text) ti.uId = id; ti.hinst = 0; ti.lpszText = text; - SendMessageA (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTA, - 0, (LPARAM)&ti); + SendMessageA (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTA, 0, (LPARAM)&ti); } return 0; @@ -747,8 +758,7 @@ STATUSBAR_SetTipTextW (STATUS_INFO *infoPtr, INT id, LPWSTR text) ti.uId = id; ti.hinst = 0; ti.lpszText = text; - SendMessageW (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTW, - 0, (LPARAM)&ti); + SendMessageW (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTW, 0, (LPARAM)&ti); } return 0; @@ -838,6 +848,9 @@ STATUSBAR_WMCreate (HWND hwnd, LPCREATESTRUCTA lpCreate) infoPtr->simple = FALSE; infoPtr->clrBk = CLR_DEFAULT; infoPtr->hFont = 0; + infoPtr->horizontalBorder = HORZ_BORDER; + infoPtr->verticalBorder = VERT_BORDER; + infoPtr->horizontalGap = HORZ_GAP; i = SendMessageW(infoPtr->Notify, WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY); infoPtr->NtfUnicode = (i == NFR_UNICODE); @@ -929,7 +942,7 @@ STATUSBAR_WMCreate (HWND hwnd, LPCREATESTRUCTA lpCreate) if (!(dwStyle & CCS_NORESIZE)) { /* don't resize wnd if it doesn't want it ! */ GetClientRect (infoPtr->Notify, &rect); width = rect.right - rect.left; - infoPtr->height = textHeight + 4 + VERT_BORDER; + infoPtr->height = textHeight + 4 + infoPtr->verticalBorder; SetWindowPos(hwnd, 0, lpCreate->x, lpCreate->y - 1, width, infoPtr->height, SWP_NOZORDER); STATUSBAR_SetPartBounds (infoPtr); @@ -1069,8 +1082,7 @@ STATUSBAR_WMSize (STATUS_INFO *infoPtr, WORD flags) /* Need to resize width to match parent */ TRACE("flags %04x\n", flags); - if (flags != SIZE_RESTORED && flags != SIZE_MAXIMIZED) - { + if (flags != SIZE_RESTORED && flags != SIZE_MAXIMIZED) { WARN("flags MUST be SIZE_RESTORED or SIZE_MAXIMIZED\n"); return FALSE; } @@ -1129,7 +1141,7 @@ StatusWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) switch (msg) { case SB_GETBORDERS: - return STATUSBAR_GetBorders ((INT *)lParam); + return STATUSBAR_GetBorders (infoPtr, (INT *)lParam); case SB_GETICON: return (LRESULT)STATUSBAR_GetIcon (infoPtr, nPart); @@ -1162,6 +1174,9 @@ StatusWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case SB_ISSIMPLE: return infoPtr->simple; + case SB_SETBORDERS: + return STATUSBAR_SetBorders (infoPtr, (INT *)lParam); + case SB_SETBKCOLOR: return STATUSBAR_SetBkColor (infoPtr, (COLORREF)lParam); diff --git a/reactos/lib/comctl32/string.c b/reactos/lib/comctl32/string.c index e5f28ab2e45..b9aa285cc8f 100644 --- a/reactos/lib/comctl32/string.c +++ b/reactos/lib/comctl32/string.c @@ -421,7 +421,7 @@ INT WINAPI StrCmpNW(LPCWSTR lpszStr, LPCWSTR lpszComp, INT iLen) /************************************************************************** * StrRChrA [COMCTL32.351] * - * Find the last occurence of a character in string. + * Find the last occurrence of a character in string. * * PARAMS * lpszStr [I] String to search in @@ -572,7 +572,7 @@ LPWSTR WINAPI StrChrIW(LPCWSTR lpszStr, WCHAR ch) /************************************************************************* * StrRStrIA [COMCTL32.372] * - * Find the last occurence of a substring within a string. + * Find the last occurrence of a substring within a string. * * PARAMS * lpszStr [I] String to search in @@ -580,7 +580,7 @@ LPWSTR WINAPI StrChrIW(LPCWSTR lpszStr, WCHAR ch) * lpszSearch [I] String to look for * * RETURNS - * The last occurence lpszSearch within lpszStr, or NULL if not found. + * The last occurrence lpszSearch within lpszStr, or NULL if not found. */ LPSTR WINAPI StrRStrIA(LPCSTR lpszStr, LPCSTR lpszEnd, LPCSTR lpszSearch) { @@ -709,7 +709,7 @@ int WINAPI StrCSpnIW(LPCWSTR lpszStr, LPCWSTR lpszMatch) /************************************************************************** * StrRChrIA [COMCTL32.368] * - * Find the last occurence of a character in string, ignoring case. + * Find the last occurrence of a character in string, ignoring case. * * PARAMS * lpszStr [I] String to search in diff --git a/reactos/lib/comctl32/syslink.c b/reactos/lib/comctl32/syslink.c index 3567c96a3a4..34402f3a6f8 100644 --- a/reactos/lib/comctl32/syslink.c +++ b/reactos/lib/comctl32/syslink.c @@ -513,7 +513,7 @@ static VOID SYSLINK_RepaintLink (SYSLINK_INFO *infoPtr, PDOC_ITEM DocItem) /*********************************************************************** * SYSLINK_GetLinkItemByIndex - * Retreives a document link by it's index + * Retrieves a document link by its index */ static PDOC_ITEM SYSLINK_GetLinkItemByIndex (SYSLINK_INFO *infoPtr, int iLink) { @@ -532,7 +532,7 @@ static PDOC_ITEM SYSLINK_GetLinkItemByIndex (SYSLINK_INFO *infoPtr, int iLink) /*********************************************************************** * SYSLINK_GetFocusLink - * Retreives the link that has the LIS_FOCUSED bit + * Retrieves the link that has the LIS_FOCUSED bit */ static PDOC_ITEM SYSLINK_GetFocusLink (SYSLINK_INFO *infoPtr, int *LinkId) { diff --git a/reactos/lib/comctl32/tab.c b/reactos/lib/comctl32/tab.c index a4b843c5520..8fb27e89d85 100644 --- a/reactos/lib/comctl32/tab.c +++ b/reactos/lib/comctl32/tab.c @@ -59,7 +59,7 @@ typedef struct * leftmost item (the leftmost item, 0, would have a * "left" member of 0 in this rectangle) * - * additionally the top member hold the row number + * additionally the top member holds the row number * and bottom is unused and should be 0 */ BYTE extra[1]; /* Space for caller supplied info, variable size */ } TAB_ITEM; @@ -69,6 +69,7 @@ typedef struct typedef struct { + HWND hwnd; /* Tab control window */ HWND hwndNotify; /* notification window (parent) */ UINT uNumItem; /* number of tab items */ UINT uNumRows; /* number of tab rows */ @@ -126,20 +127,17 @@ typedef struct /****************************************************************************** * Prototypes */ -static void TAB_Refresh (HWND hwnd, HDC hdc); -static void TAB_InvalidateTabArea(HWND hwnd, TAB_INFO* infoPtr); -static void TAB_EnsureSelectionVisible(HWND hwnd, TAB_INFO* infoPtr); -static void TAB_DrawItem(HWND hwnd, HDC hdc, INT iItem); -static void TAB_DrawItemInterior(HWND hwnd, HDC hdc, INT iItem, RECT* drawRect); +static void TAB_InvalidateTabArea(TAB_INFO *); +static void TAB_EnsureSelectionVisible(TAB_INFO *); +static void TAB_DrawItemInterior(TAB_INFO *, HDC, INT, RECT*); static BOOL -TAB_SendSimpleNotify (HWND hwnd, UINT code) +TAB_SendSimpleNotify (const TAB_INFO *infoPtr, UINT code) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); NMHDR nmhdr; - nmhdr.hwndFrom = hwnd; - nmhdr.idFrom = GetWindowLongPtrW(hwnd, GWLP_ID); + nmhdr.hwndFrom = infoPtr->hwnd; + nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwnd, GWLP_ID); nmhdr.code = code; return (BOOL) SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, @@ -203,11 +201,8 @@ TAB_DumpItemInternal(TAB_INFO *infoPtr, UINT iItem) /* RETURNS * the index of the selected tab, or -1 if no tab is selected. */ -static LRESULT -TAB_GetCurSel (HWND hwnd) +static inline LRESULT TAB_GetCurSel (const TAB_INFO *infoPtr) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - return infoPtr->iSelected; } @@ -217,10 +212,9 @@ TAB_GetCurSel (HWND hwnd) * we have not to return negative value * TODO * test for windows */ -static LRESULT -TAB_GetCurFocus (HWND hwnd) +static inline LRESULT +TAB_GetCurFocus (const TAB_INFO *infoPtr) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); if (infoPtr->uFocus<0) { FIXME("we have not to return negative value"); @@ -229,79 +223,66 @@ TAB_GetCurFocus (HWND hwnd) return infoPtr->uFocus; } -static LRESULT -TAB_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam) +static inline LRESULT TAB_GetToolTips (const TAB_INFO *infoPtr) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - if (infoPtr == NULL) return 0; return (LRESULT)infoPtr->hwndToolTip; } -static LRESULT -TAB_SetCurSel (HWND hwnd,WPARAM wParam) +static inline LRESULT TAB_SetCurSel (TAB_INFO *infoPtr, INT iItem) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - INT iItem = (INT)wParam; - INT prevItem; + INT prevItem = -1; - prevItem = -1; - if ((iItem >= 0) && (iItem < infoPtr->uNumItem)) { - prevItem=infoPtr->iSelected; + if (iItem >= 0 && iItem < infoPtr->uNumItem) { + prevItem=infoPtr->iSelected; infoPtr->iSelected=iItem; - TAB_EnsureSelectionVisible(hwnd, infoPtr); - TAB_InvalidateTabArea(hwnd, infoPtr); + TAB_EnsureSelectionVisible(infoPtr); + TAB_InvalidateTabArea(infoPtr); } return prevItem; } -static LRESULT -TAB_SetCurFocus (HWND hwnd,WPARAM wParam) +static LRESULT TAB_SetCurFocus (TAB_INFO *infoPtr, INT iItem) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - INT iItem=(INT) wParam; + if (iItem < 0 || iItem >= infoPtr->uNumItem) return 0; - if ((iItem < 0) || (iItem >= infoPtr->uNumItem)) return 0; - - if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS) { + if (GetWindowLongA(infoPtr->hwnd, GWL_STYLE) & TCS_BUTTONS) { FIXME("Should set input focus\n"); } else { int oldFocus = infoPtr->uFocus; if (infoPtr->iSelected != iItem || oldFocus == -1 ) { infoPtr->uFocus = iItem; if (oldFocus != -1) { - if (!TAB_SendSimpleNotify(hwnd, TCN_SELCHANGING)) { + if (!TAB_SendSimpleNotify(infoPtr, TCN_SELCHANGING)) { infoPtr->iSelected = iItem; - TAB_SendSimpleNotify(hwnd, TCN_SELCHANGE); + TAB_SendSimpleNotify(infoPtr, TCN_SELCHANGE); } else infoPtr->iSelected = iItem; - TAB_EnsureSelectionVisible(hwnd, infoPtr); - TAB_InvalidateTabArea(hwnd, infoPtr); + TAB_EnsureSelectionVisible(infoPtr); + TAB_InvalidateTabArea(infoPtr); } } } return 0; } -static LRESULT -TAB_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam) +static inline LRESULT +TAB_SetToolTips (TAB_INFO *infoPtr, HWND hwndToolTip) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - - if (infoPtr == NULL) return 0; - infoPtr->hwndToolTip = (HWND)wParam; + if (infoPtr) + infoPtr->hwndToolTip = hwndToolTip; return 0; } -static LRESULT -TAB_SetPadding (HWND hwnd, WPARAM wParam, LPARAM lParam) +static inline LRESULT +TAB_SetPadding (TAB_INFO *infoPtr, LPARAM lParam) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - - if (infoPtr == NULL) return 0; - infoPtr->uHItemPadding_s=LOWORD(lParam); - infoPtr->uVItemPadding_s=HIWORD(lParam); + if (infoPtr) + { + infoPtr->uHItemPadding_s=LOWORD(lParam); + infoPtr->uVItemPadding_s=HIWORD(lParam); + } return 0; } @@ -315,14 +296,13 @@ TAB_SetPadding (HWND hwnd, WPARAM wParam, LPARAM lParam) * if it is completely outside the client area. */ static BOOL TAB_InternalGetItemRect( - HWND hwnd, - TAB_INFO* infoPtr, + const TAB_INFO* infoPtr, INT itemIndex, RECT* itemRect, RECT* selectedRect) { RECT tmpItemRect,clientRect; - LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); + LONG lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); /* Perform a sanity check and a trivial visibility check. */ if ( (infoPtr->uNumItem <= 0) || @@ -341,7 +321,7 @@ static BOOL TAB_InternalGetItemRect( *itemRect = TAB_GetItem(infoPtr,itemIndex)->rect; /* calculate the times bottom and top based on the row */ - GetClientRect(hwnd, &clientRect); + GetClientRect(infoPtr->hwnd, &clientRect); if ((lStyle & TCS_BOTTOM) && (lStyle & TCS_VERTICAL)) { @@ -440,10 +420,10 @@ static BOOL TAB_InternalGetItemRect( return TRUE; } -static BOOL TAB_GetItemRect(HWND hwnd, WPARAM wParam, LPARAM lParam) +static inline BOOL +TAB_GetItemRect(TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { - return TAB_InternalGetItemRect(hwnd, TAB_GetInfoPtr(hwnd), (INT)wParam, - (LPRECT)lParam, (LPRECT)NULL); + return TAB_InternalGetItemRect(infoPtr, (INT)wParam, (LPRECT)lParam, (LPRECT)NULL); } /****************************************************************************** @@ -451,11 +431,8 @@ static BOOL TAB_GetItemRect(HWND hwnd, WPARAM wParam, LPARAM lParam) * * This method is called to handle keyboard input */ -static LRESULT TAB_KeyUp( - HWND hwnd, - WPARAM keyCode) +static LRESULT TAB_KeyUp(TAB_INFO* infoPtr, WPARAM keyCode) { - TAB_INFO* infoPtr = TAB_GetInfoPtr(hwnd); int newItem = -1; switch (keyCode) @@ -471,18 +448,18 @@ static LRESULT TAB_KeyUp( /* * If we changed to a valid item, change the selection */ - if ((newItem >= 0) && - (newItem < infoPtr->uNumItem) && - (infoPtr->uFocus != newItem)) + if (newItem >= 0 && + newItem < infoPtr->uNumItem && + infoPtr->uFocus != newItem) { - if (!TAB_SendSimpleNotify(hwnd, TCN_SELCHANGING)) + if (!TAB_SendSimpleNotify(infoPtr, TCN_SELCHANGING)) { infoPtr->iSelected = newItem; infoPtr->uFocus = newItem; - TAB_SendSimpleNotify(hwnd, TCN_SELCHANGE); + TAB_SendSimpleNotify(infoPtr, TCN_SELCHANGE); - TAB_EnsureSelectionVisible(hwnd, infoPtr); - TAB_InvalidateTabArea(hwnd, infoPtr); + TAB_EnsureSelectionVisible(infoPtr); + TAB_InvalidateTabArea(infoPtr); } } @@ -495,21 +472,15 @@ static LRESULT TAB_KeyUp( * This method is called whenever the focus goes in or out of this control * it is used to update the visual state of the control. */ -static LRESULT TAB_FocusChanging( - HWND hwnd, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) +static VOID TAB_FocusChanging(const TAB_INFO *infoPtr) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); RECT selectedRect; BOOL isVisible; /* * Get the rectangle for the item. */ - isVisible = TAB_InternalGetItemRect(hwnd, - infoPtr, + isVisible = TAB_InternalGetItemRect(infoPtr, infoPtr->uFocus, NULL, &selectedRect); @@ -523,17 +494,11 @@ static LRESULT TAB_FocusChanging( TRACE("invalidate (%ld,%ld)-(%ld,%ld)\n", selectedRect.left,selectedRect.top, selectedRect.right,selectedRect.bottom); - InvalidateRect(hwnd, &selectedRect, TRUE); + InvalidateRect(infoPtr->hwnd, &selectedRect, TRUE); } - - /* - * Don't otherwise disturb normal behavior. - */ - return DefWindowProcW (hwnd, uMsg, wParam, lParam); } static INT TAB_InternalHitTest ( - HWND hwnd, TAB_INFO* infoPtr, POINT pt, UINT* flags) @@ -544,7 +509,7 @@ static INT TAB_InternalHitTest ( for (iCount = 0; iCount < infoPtr->uNumItem; iCount++) { - TAB_InternalGetItemRect(hwnd, infoPtr, iCount, &rect, NULL); + TAB_InternalGetItemRect(infoPtr, iCount, &rect, NULL); if (PtInRect(&rect, pt)) { @@ -557,13 +522,10 @@ static INT TAB_InternalHitTest ( return -1; } -static LRESULT -TAB_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam) +static inline LRESULT +TAB_HitTest (TAB_INFO *infoPtr, LPTCHITTESTINFO lptest) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - LPTCHITTESTINFO lptest = (LPTCHITTESTINFO) lParam; - - return TAB_InternalHitTest (hwnd, infoPtr, lptest->pt, &lptest->flags); + return TAB_InternalHitTest (infoPtr, lptest->pt, &lptest->flags); } /****************************************************************************** @@ -578,77 +540,75 @@ TAB_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam) * FIXME: WM_NCHITTEST handling correct ? Fix it if you know that Windows * doesn't do it that way. Maybe depends on tab control styles ? */ -static LRESULT -TAB_NCHitTest (HWND hwnd, LPARAM lParam) +static inline LRESULT +TAB_NCHitTest (TAB_INFO *infoPtr, LPARAM lParam) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); POINT pt; UINT dummyflag; pt.x = LOWORD(lParam); pt.y = HIWORD(lParam); - ScreenToClient(hwnd, &pt); + ScreenToClient(infoPtr->hwnd, &pt); - if (TAB_InternalHitTest(hwnd, infoPtr, pt, &dummyflag) == -1) + if (TAB_InternalHitTest(infoPtr, pt, &dummyflag) == -1) return HTTRANSPARENT; else return HTCLIENT; } static LRESULT -TAB_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam) +TAB_LButtonDown (TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); POINT pt; INT newItem, dummy; if (infoPtr->hwndToolTip) - TAB_RelayEvent (infoPtr->hwndToolTip, hwnd, + TAB_RelayEvent (infoPtr->hwndToolTip, infoPtr->hwnd, WM_LBUTTONDOWN, wParam, lParam); - if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_FOCUSONBUTTONDOWN ) { - SetFocus (hwnd); + if (GetWindowLongA(infoPtr->hwnd, GWL_STYLE) & TCS_FOCUSONBUTTONDOWN ) { + SetFocus (infoPtr->hwnd); } if (infoPtr->hwndToolTip) - TAB_RelayEvent (infoPtr->hwndToolTip, hwnd, + TAB_RelayEvent (infoPtr->hwndToolTip, infoPtr->hwnd, WM_LBUTTONDOWN, wParam, lParam); pt.x = (INT)LOWORD(lParam); pt.y = (INT)HIWORD(lParam); - newItem = TAB_InternalHitTest (hwnd, infoPtr, pt, &dummy); + newItem = TAB_InternalHitTest (infoPtr, pt, &dummy); TRACE("On Tab, item %d\n", newItem); - if ((newItem != -1) && (infoPtr->iSelected != newItem)) + if (newItem != -1 && infoPtr->iSelected != newItem) { - if (!TAB_SendSimpleNotify(hwnd, TCN_SELCHANGING)) + if (!TAB_SendSimpleNotify(infoPtr, TCN_SELCHANGING)) { infoPtr->iSelected = newItem; infoPtr->uFocus = newItem; - TAB_SendSimpleNotify(hwnd, TCN_SELCHANGE); + TAB_SendSimpleNotify(infoPtr, TCN_SELCHANGE); - TAB_EnsureSelectionVisible(hwnd, infoPtr); + TAB_EnsureSelectionVisible(infoPtr); - TAB_InvalidateTabArea(hwnd, infoPtr); + TAB_InvalidateTabArea(infoPtr); } } return 0; } -static LRESULT -TAB_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam) +static inline LRESULT +TAB_LButtonUp (const TAB_INFO *infoPtr) { - TAB_SendSimpleNotify(hwnd, NM_CLICK); + TAB_SendSimpleNotify(infoPtr, NM_CLICK); return 0; } -static LRESULT -TAB_RButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam) +static inline LRESULT +TAB_RButtonDown (const TAB_INFO *infoPtr) { - TAB_SendSimpleNotify(hwnd, NM_RCLICK); + TAB_SendSimpleNotify(infoPtr, NM_RCLICK); return 0; } @@ -661,20 +621,20 @@ TAB_RButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam) * only calls TAB_DrawItemInterior for the single specified item. */ static void -TAB_DrawLoneItemInterior(HWND hwnd, TAB_INFO* infoPtr, int iItem) +TAB_DrawLoneItemInterior(TAB_INFO* infoPtr, int iItem) { - HDC hdc = GetDC(hwnd); + HDC hdc = GetDC(infoPtr->hwnd); RECT r, rC; /* Clip UpDown control to not draw over it */ if (infoPtr->needsScrolling) { - GetWindowRect(hwnd, &rC); + GetWindowRect(infoPtr->hwnd, &rC); GetWindowRect(infoPtr->hwndUpDown, &r); ExcludeClipRect(hdc, r.left - rC.left, r.top - rC.top, r.right - rC.left, r.bottom - rC.top); } - TAB_DrawItemInterior(hwnd, hdc, iItem, NULL); - ReleaseDC(hwnd, hdc); + TAB_DrawItemInterior(infoPtr, hdc, iItem, NULL); + ReleaseDC(infoPtr->hwnd, hdc); } /****************************************************************************** @@ -716,7 +676,7 @@ TAB_HotTrackTimerProc /* Redraw iHotTracked to look normal */ INT iRedraw = infoPtr->iHotTracked; infoPtr->iHotTracked = -1; - TAB_DrawLoneItemInterior(hwnd, infoPtr, iRedraw); + TAB_DrawLoneItemInterior(infoPtr, iRedraw); /* Kill this timer */ KillTimer(hwnd, TAB_HOTTRACK_TIMER); @@ -743,14 +703,12 @@ TAB_HotTrackTimerProc static void TAB_RecalcHotTrack ( - HWND hwnd, + TAB_INFO* infoPtr, const LPARAM* pos, int* out_redrawLeave, int* out_redrawEnter ) { - TAB_INFO* infoPtr = TAB_GetInfoPtr(hwnd); - int item = -1; @@ -759,7 +717,7 @@ TAB_RecalcHotTrack if (out_redrawEnter != NULL) *out_redrawEnter = -1; - if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_HOTTRACK) + if (GetWindowLongA(infoPtr->hwnd, GWL_STYLE) & TCS_HOTTRACK) { POINT pt; UINT flags; @@ -767,7 +725,7 @@ TAB_RecalcHotTrack if (pos == NULL) { GetCursorPos(&pt); - ScreenToClient(hwnd, &pt); + ScreenToClient(infoPtr->hwnd, &pt); } else { @@ -775,7 +733,7 @@ TAB_RecalcHotTrack pt.y = HIWORD(*pos); } - item = TAB_InternalHitTest(hwnd, infoPtr, pt, &flags); + item = TAB_InternalHitTest(infoPtr, pt, &flags); } if (item != infoPtr->iHotTracked) @@ -789,7 +747,7 @@ TAB_RecalcHotTrack if (item < 0) { /* Kill timer which forces recheck of mouse pos */ - KillTimer(hwnd, TAB_HOTTRACK_TIMER); + KillTimer(infoPtr->hwnd, TAB_HOTTRACK_TIMER); } } else @@ -797,7 +755,7 @@ TAB_RecalcHotTrack /* Start timer so we recheck mouse pos */ UINT timerID = SetTimer ( - hwnd, + infoPtr->hwnd, TAB_HOTTRACK_TIMER, TAB_HOTTRACK_TIMER_INTERVAL, TAB_HotTrackTimerProc @@ -824,25 +782,23 @@ TAB_RecalcHotTrack * Handles the mouse-move event. Updates tooltips. Updates hot-tracking. */ static LRESULT -TAB_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam) +TAB_MouseMove (TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { int redrawLeave; int redrawEnter; - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - if (infoPtr->hwndToolTip) - TAB_RelayEvent (infoPtr->hwndToolTip, hwnd, + TAB_RelayEvent (infoPtr->hwndToolTip, infoPtr->hwnd, WM_LBUTTONDOWN, wParam, lParam); /* Determine which tab to highlight. Redraw tabs which change highlight ** status. */ - TAB_RecalcHotTrack(hwnd, &lParam, &redrawLeave, &redrawEnter); + TAB_RecalcHotTrack(infoPtr, &lParam, &redrawLeave, &redrawEnter); if (redrawLeave != -1) - TAB_DrawLoneItemInterior(hwnd, infoPtr, redrawLeave); + TAB_DrawLoneItemInterior(infoPtr, redrawLeave); if (redrawEnter != -1) - TAB_DrawLoneItemInterior(hwnd, infoPtr, redrawEnter); + TAB_DrawLoneItemInterior(infoPtr, redrawEnter); return 0; } @@ -854,15 +810,14 @@ TAB_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam) * the window rectangle given the requested display rectangle. */ static LRESULT TAB_AdjustRect( - HWND hwnd, + TAB_INFO *infoPtr, WPARAM fLarger, LPRECT prc) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - DWORD lStyle = GetWindowLongA(hwnd, GWL_STYLE); + DWORD lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); LONG *iRightBottom, *iLeftTop; - TRACE ("hwnd=%p fLarger=%d (%ld,%ld)-(%ld,%ld)\n", hwnd, fLarger, prc->left, prc->top, prc->right, prc->bottom); + TRACE ("hwnd=%p fLarger=%d (%ld,%ld)-(%ld,%ld)\n", infoPtr->hwnd, fLarger, prc->left, prc->top, prc->right, prc->bottom); if(lStyle & TCS_VERTICAL) { @@ -916,13 +871,11 @@ static LRESULT TAB_AdjustRect( * perform the scrolling operation on the tab control. */ static LRESULT TAB_OnHScroll( - HWND hwnd, + TAB_INFO *infoPtr, int nScrollCode, int nPos, HWND hwndScroll) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - if(nScrollCode == SB_THUMBPOSITION && nPos != infoPtr->leftmostVisible) { if(nPos < infoPtr->leftmostVisible) @@ -930,8 +883,8 @@ static LRESULT TAB_OnHScroll( else infoPtr->leftmostVisible++; - TAB_RecalcHotTrack(hwnd, NULL, NULL, NULL); - TAB_InvalidateTabArea(hwnd, infoPtr); + TAB_RecalcHotTrack(infoPtr, NULL, NULL, NULL); + TAB_InvalidateTabArea(infoPtr); SendMessageW(infoPtr->hwndUpDown, UDM_SETPOS, 0, MAKELONG(infoPtr->leftmostVisible, 0)); } @@ -1061,10 +1014,9 @@ static void TAB_SetupScrolling( * it checks if all the tabs fit in the client area of the window. If they * don't, a scrolling control is added. */ -static void TAB_SetItemBounds (HWND hwnd) +static void TAB_SetItemBounds (TAB_INFO *infoPtr) { - TAB_INFO* infoPtr = TAB_GetInfoPtr(hwnd); - LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); + LONG lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); TEXTMETRICA fontMetrics; UINT curItem; INT curItemLeftPos; @@ -1082,7 +1034,7 @@ static void TAB_SetItemBounds (HWND hwnd) * We need to get text information so we need a DC and we need to select * a font. */ - hdc = GetDC(hwnd); + hdc = GetDC(infoPtr->hwnd); hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT); hOldFont = SelectObject (hdc, hFont); @@ -1091,7 +1043,7 @@ static void TAB_SetItemBounds (HWND hwnd) * We will base the rectangle calculations on the client rectangle * of the control. */ - GetClientRect(hwnd, &clientRect); + GetClientRect(infoPtr->hwnd, &clientRect); /* if TCS_VERTICAL then swap the height and width so this code places the tabs along the top of the rectangle and we can just rotate them after @@ -1242,7 +1194,7 @@ static void TAB_SetItemBounds (HWND hwnd) infoPtr->needsScrolling = FALSE; infoPtr->leftmostVisible = 0; } - TAB_SetupScrolling(hwnd, infoPtr, &clientRect); + TAB_SetupScrolling(infoPtr->hwnd, infoPtr, &clientRect); /* Set the number of rows */ infoPtr->uNumRows = curItemRowCount; @@ -1404,26 +1356,25 @@ static void TAB_SetItemBounds (HWND hwnd) } } - TAB_EnsureSelectionVisible(hwnd,infoPtr); - TAB_RecalcHotTrack(hwnd, NULL, NULL, NULL); + TAB_EnsureSelectionVisible(infoPtr); + TAB_RecalcHotTrack(infoPtr, NULL, NULL, NULL); /* Cleanup */ SelectObject (hdc, hOldFont); - ReleaseDC (hwnd, hdc); + ReleaseDC (infoPtr->hwnd, hdc); } static void TAB_EraseTabInterior ( - HWND hwnd, + TAB_INFO* infoPtr, HDC hdc, INT iItem, RECT* drawRect ) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); + LONG lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); HBRUSH hbr = CreateSolidBrush (comctl32_color.clrBtnFace); BOOL deleteBrush = TRUE; RECT rTemp = *drawRect; @@ -1484,14 +1435,13 @@ TAB_EraseTabInterior static void TAB_DrawItemInterior ( - HWND hwnd, + TAB_INFO* infoPtr, HDC hdc, INT iItem, RECT* drawRect ) { - TAB_INFO* infoPtr = TAB_GetInfoPtr(hwnd); - LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); + LONG lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); RECT localRect; @@ -1509,7 +1459,7 @@ TAB_DrawItemInterior /* * Get the rectangle for the item. */ - isVisible = TAB_InternalGetItemRect(hwnd, infoPtr, iItem, &itemRect, &selectedRect); + isVisible = TAB_InternalGetItemRect(infoPtr, iItem, &itemRect, &selectedRect); if (!isVisible) return; @@ -1600,11 +1550,11 @@ TAB_DrawItemInterior drawRect->left, drawRect->top, drawRect->right, drawRect->bottom); /* Clear interior */ - TAB_EraseTabInterior (hwnd, hdc, iItem, drawRect); + TAB_EraseTabInterior (infoPtr, hdc, iItem, drawRect); /* Draw the focus rectangle */ if (!(lStyle & TCS_FOCUSNEVER) && - (GetFocus() == hwnd) && + (GetFocus() == infoPtr->hwnd) && (iItem == infoPtr->uFocus) ) { RECT rFocus = *drawRect; @@ -1638,7 +1588,7 @@ TAB_DrawItemInterior /* * if owner draw, tell the owner to draw */ - if ((lStyle & TCS_OWNERDRAWFIXED) && GetParent(hwnd)) + if ((lStyle & TCS_OWNERDRAWFIXED) && GetParent(infoPtr->hwnd)) { DRAWITEMSTRUCT dis; UINT id; @@ -1654,7 +1604,7 @@ TAB_DrawItemInterior /* * get the control id */ - id = (UINT)GetWindowLongPtrW( hwnd, GWLP_ID ); + id = (UINT)GetWindowLongPtrW( infoPtr->hwnd, GWLP_ID ); /* * put together the DRAWITEMSTRUCT @@ -1668,7 +1618,7 @@ TAB_DrawItemInterior dis.itemState |= ODS_SELECTED; if (infoPtr->uFocus == iItem) dis.itemState |= ODS_FOCUS; - dis.hwndItem = hwnd; /* */ + dis.hwndItem = infoPtr->hwnd; dis.hDC = hdc; CopyRect(&dis.rcItem,drawRect); dis.itemData = (ULONG_PTR)TAB_GetItem(infoPtr, iItem)->extra; @@ -1891,12 +1841,11 @@ TAB_DrawItemInterior * This method is used to draw a single tab into the tab control. */ static void TAB_DrawItem( - HWND hwnd, + TAB_INFO *infoPtr, HDC hdc, INT iItem) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); + LONG lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); RECT itemRect; RECT selectedRect; BOOL isVisible; @@ -1908,8 +1857,7 @@ static void TAB_DrawItem( /* * Get the rectangle for the item. */ - isVisible = TAB_InternalGetItemRect(hwnd, - infoPtr, + isVisible = TAB_InternalGetItemRect(infoPtr, iItem, &itemRect, &selectedRect); @@ -1921,7 +1869,7 @@ static void TAB_DrawItem( /* Clip UpDown control to not draw over it */ if (infoPtr->needsScrolling) { - GetWindowRect(hwnd, &rC); + GetWindowRect(infoPtr->hwnd, &rC); GetWindowRect(infoPtr->hwndUpDown, &rUD); ExcludeClipRect(hdc, rUD.left - rC.left, rUD.top - rC.top, rUD.right - rC.left, rUD.bottom - rC.top); } @@ -1965,7 +1913,7 @@ static void TAB_DrawItem( * state. */ if (iItem == infoPtr->iSelected) { RECT rect; - GetClientRect (hwnd, &rect); + GetClientRect (infoPtr->hwnd, &rect); clRight = rect.right; clBottom = rect.bottom; r = selectedRect; @@ -2188,7 +2136,7 @@ static void TAB_DrawItem( TAB_DumpItemInternal(infoPtr, iItem); /* This modifies r to be the text rectangle. */ - TAB_DrawItemInterior(hwnd, hdc, iItem, &r); + TAB_DrawItemInterior(infoPtr, hdc, iItem, &r); } } @@ -2198,13 +2146,12 @@ static void TAB_DrawItem( * This method is used to draw the raised border around the tab control * "content" area. */ -static void TAB_DrawBorder (HWND hwnd, HDC hdc) +static void TAB_DrawBorder (TAB_INFO *infoPtr, HDC hdc) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); RECT rect; - DWORD lStyle = GetWindowLongA(hwnd, GWL_STYLE); + DWORD lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); - GetClientRect (hwnd, &rect); + GetClientRect (infoPtr->hwnd, &rect); /* * Adjust for the style @@ -2233,9 +2180,8 @@ static void TAB_DrawBorder (HWND hwnd, HDC hdc) * * This method repaints the tab control.. */ -static void TAB_Refresh (HWND hwnd, HDC hdc) +static void TAB_Refresh (TAB_INFO *infoPtr, HDC hdc) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); HFONT hOldFont; INT i; @@ -2244,10 +2190,10 @@ static void TAB_Refresh (HWND hwnd, HDC hdc) hOldFont = SelectObject (hdc, infoPtr->hFont); - if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS) + if (GetWindowLongA(infoPtr->hwnd, GWL_STYLE) & TCS_BUTTONS) { for (i = 0; i < infoPtr->uNumItem; i++) - TAB_DrawItem (hwnd, hdc, i); + TAB_DrawItem (infoPtr, hdc, i); } else { @@ -2255,39 +2201,33 @@ static void TAB_Refresh (HWND hwnd, HDC hdc) for (i = 0; i < infoPtr->uNumItem; i++) { if (i != infoPtr->iSelected) - TAB_DrawItem (hwnd, hdc, i); + TAB_DrawItem (infoPtr, hdc, i); } /* Now, draw the border, draw it before the selected item * since the selected item overwrites part of the border. */ - TAB_DrawBorder (hwnd, hdc); + TAB_DrawBorder (infoPtr, hdc); /* Then, draw the selected item */ - TAB_DrawItem (hwnd, hdc, infoPtr->iSelected); + TAB_DrawItem (infoPtr, hdc, infoPtr->iSelected); /* If we haven't set the current focus yet, set it now. * Only happens when we first paint the tab controls */ if (infoPtr->uFocus == -1) - TAB_SetCurFocus(hwnd, infoPtr->iSelected); + TAB_SetCurFocus(infoPtr, infoPtr->iSelected); } SelectObject (hdc, hOldFont); } -static DWORD -TAB_GetRowCount (HWND hwnd ) +static inline DWORD TAB_GetRowCount (const TAB_INFO *infoPtr) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - return infoPtr->uNumRows; } -static LRESULT -TAB_SetRedraw (HWND hwnd, WPARAM wParam) +static inline LRESULT TAB_SetRedraw (TAB_INFO *infoPtr, BOOL doRedraw) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - - infoPtr->DoRedraw=(BOOL) wParam; + infoPtr->DoRedraw = doRedraw; return 0; } @@ -2298,11 +2238,10 @@ TAB_SetRedraw (HWND hwnd, WPARAM wParam) * visible by scrolling until it is. */ static void TAB_EnsureSelectionVisible( - HWND hwnd, TAB_INFO* infoPtr) { INT iSelected = infoPtr->iSelected; - LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); + LONG lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); INT iOrigLeftmostVisible = infoPtr->leftmostVisible; /* set the items row to the bottommost row or topmost row depending on @@ -2356,7 +2295,7 @@ static void TAB_EnsureSelectionVisible( } } } - TAB_RecalcHotTrack(hwnd, NULL, NULL, NULL); + TAB_RecalcHotTrack(infoPtr, NULL, NULL, NULL); } } @@ -2379,7 +2318,7 @@ static void TAB_EnsureSelectionVisible( UINT i; /* Calculate the part of the client area that is visible */ - GetClientRect(hwnd, &r); + GetClientRect(infoPtr->hwnd, &r); width = r.right; GetClientRect(infoPtr->hwndUpDown, &r); @@ -2405,7 +2344,7 @@ static void TAB_EnsureSelectionVisible( } if (infoPtr->leftmostVisible != iOrigLeftmostVisible) - TAB_RecalcHotTrack(hwnd, NULL, NULL, NULL); + TAB_RecalcHotTrack(infoPtr, NULL, NULL, NULL); SendMessageW(infoPtr->hwndUpDown, UDM_SETPOS, 0, MAKELONG(infoPtr->leftmostVisible, 0)); @@ -2418,24 +2357,22 @@ static void TAB_EnsureSelectionVisible( * tabs. It is called when the state of the control changes and needs * to be redisplayed */ -static void TAB_InvalidateTabArea( - HWND hwnd, - TAB_INFO* infoPtr) +static void TAB_InvalidateTabArea(TAB_INFO* infoPtr) { RECT clientRect, rInvalidate, rAdjClient; - DWORD lStyle = GetWindowLongA(hwnd, GWL_STYLE); + DWORD lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); INT lastRow = infoPtr->uNumRows - 1; RECT rect; if (lastRow < 0) return; - GetClientRect(hwnd, &clientRect); + GetClientRect(infoPtr->hwnd, &clientRect); rInvalidate = clientRect; rAdjClient = clientRect; - TAB_AdjustRect(hwnd, 0, &rAdjClient); + TAB_AdjustRect(infoPtr, 0, &rAdjClient); - TAB_InternalGetItemRect(hwnd, infoPtr, infoPtr->uNumItem-1 , &rect, NULL); + TAB_InternalGetItemRect(infoPtr, infoPtr->uNumItem-1 , &rect, NULL); if ((lStyle & TCS_BOTTOM) && (lStyle & TCS_VERTICAL)) { rInvalidate.left = rAdjClient.right; @@ -2475,44 +2412,42 @@ static void TAB_InvalidateTabArea( rInvalidate.left, rInvalidate.top, rInvalidate.right, rInvalidate.bottom); - InvalidateRect(hwnd, &rInvalidate, TRUE); + InvalidateRect(infoPtr->hwnd, &rInvalidate, TRUE); } -static LRESULT -TAB_Paint (HWND hwnd, WPARAM wParam) +static inline LRESULT TAB_Paint (TAB_INFO *infoPtr, HDC hdcPaint) { HDC hdc; PAINTSTRUCT ps; - if (wParam == 0) + if (hdcPaint) + hdc = hdcPaint; + else { - hdc = BeginPaint (hwnd, &ps); + hdc = BeginPaint (infoPtr->hwnd, &ps); TRACE("erase %d, rect=(%ld,%ld)-(%ld,%ld)\n", ps.fErase, ps.rcPaint.left,ps.rcPaint.top,ps.rcPaint.right,ps.rcPaint.bottom); - } else { - hdc = (HDC)wParam; } - - TAB_Refresh (hwnd, hdc); - if(!wParam) - EndPaint (hwnd, &ps); + TAB_Refresh (infoPtr, hdc); + + if (!hdcPaint) + EndPaint (infoPtr->hwnd, &ps); return 0; } static LRESULT -TAB_InsertItemAW (HWND hwnd, WPARAM wParam, LPARAM lParam, BOOL bUnicode) +TAB_InsertItemAW (TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnicode) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); TAB_ITEM *item; TCITEMA *pti; INT iItem; RECT rect; - GetClientRect (hwnd, &rect); - TRACE("Rect: %p T %li, L %li, B %li, R %li\n", hwnd, + GetClientRect (infoPtr->hwnd, &rect); + TRACE("Rect: %p T %li, L %li, B %li, R %li\n", infoPtr->hwnd, rect.top, rect.left, rect.bottom, rect.right); pti = (TCITEMA *)lParam; @@ -2582,23 +2517,22 @@ TAB_InsertItemAW (HWND hwnd, WPARAM wParam, LPARAM lParam, BOOL bUnicode) else memset(item->extra, 0, infoPtr->cbInfo); - TAB_SetItemBounds(hwnd); + TAB_SetItemBounds(infoPtr); if (infoPtr->uNumItem > 1) - TAB_InvalidateTabArea(hwnd, infoPtr); + TAB_InvalidateTabArea(infoPtr); else - InvalidateRect(hwnd, NULL, TRUE); + InvalidateRect(infoPtr->hwnd, NULL, TRUE); TRACE("[%p]: added item %d %s\n", - hwnd, iItem, debugstr_w(item->pszText)); + infoPtr->hwnd, iItem, debugstr_w(item->pszText)); return iItem; } static LRESULT -TAB_SetItemSize (HWND hwnd, WPARAM wParam, LPARAM lParam) +TAB_SetItemSize (TAB_INFO *infoPtr, LPARAM lParam) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); + LONG lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); LONG lResult = 0; BOOL bNeedPaint = FALSE; @@ -2624,60 +2558,56 @@ TAB_SetItemSize (HWND hwnd, WPARAM wParam, LPARAM lParam) if (bNeedPaint) { - TAB_SetItemBounds(hwnd); - RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW); + TAB_SetItemBounds(infoPtr); + RedrawWindow(infoPtr->hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW); } - + return lResult; } -static LRESULT -TAB_SetMinTabWidth (HWND hwnd, LPARAM lParam) +static inline LRESULT TAB_SetMinTabWidth (TAB_INFO *infoPtr, INT cx) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - INT cx = (INT)lParam; - INT oldcx; + INT oldcx = 0; + + TRACE("(%p,%d)\n", infoPtr, cx); if (infoPtr) { oldcx = infoPtr->tabMinWidth; infoPtr->tabMinWidth = (cx==-1)?DEFAULT_TAB_WIDTH:cx; - } else - return 0; + } return oldcx; } -static LRESULT -TAB_HighlightItem (HWND hwnd, WPARAM wParam, LPARAM lParam) +static inline LRESULT +TAB_HighlightItem (TAB_INFO *infoPtr, INT iItem, BOOL fHighlight) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - INT iItem = (INT)wParam; - BOOL fHighlight = (BOOL)LOWORD(lParam); + LPDWORD lpState; - if ((infoPtr) && (iItem>=0) && (iItemuNumItem)) { - if (fHighlight) - TAB_GetItem(infoPtr, iItem)->dwState |= TCIS_HIGHLIGHTED; - else - TAB_GetItem(infoPtr, iItem)->dwState &= ~TCIS_HIGHLIGHTED; - } else + TRACE("(%p,%d,%s)\n", infoPtr, iItem, fHighlight ? "true" : "false"); + + if (!infoPtr || iItem < 0 || iItem >= infoPtr->uNumItem) return FALSE; + + lpState = &TAB_GetItem(infoPtr, iItem)->dwState; + + if (fHighlight) + *lpState |= TCIS_HIGHLIGHTED; + else + *lpState &= ~TCIS_HIGHLIGHTED; return TRUE; } static LRESULT -TAB_SetItemAW (HWND hwnd, WPARAM wParam, LPARAM lParam, BOOL bUnicode) +TAB_SetItemAW (TAB_INFO *infoPtr, INT iItem, LPTCITEMA tabItem, BOOL bUnicode) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - TCITEMA *tabItem; TAB_ITEM *wineItem; - INT iItem; - iItem = (INT)wParam; - tabItem = (LPTCITEMA)lParam; + TRACE("(%p,%d,%p,%s)\n", infoPtr, iItem, tabItem, bUnicode ? "true" : "false"); - TRACE("%d %p\n", iItem, tabItem); - if ((iItem<0) || (iItem>=infoPtr->uNumItem)) return FALSE; + if (iItem < 0 || iItem >= infoPtr->uNumItem) + return FALSE; if (bUnicode) TAB_DumpItemExternalW((TCITEMW *)tabItem, iItem); @@ -2712,33 +2642,26 @@ TAB_SetItemAW (HWND hwnd, WPARAM wParam, LPARAM lParam, BOOL bUnicode) } /* Update and repaint tabs */ - TAB_SetItemBounds(hwnd); - TAB_InvalidateTabArea(hwnd,infoPtr); + TAB_SetItemBounds(infoPtr); + TAB_InvalidateTabArea(infoPtr); return TRUE; } -static LRESULT -TAB_GetItemCount (HWND hwnd, WPARAM wParam, LPARAM lParam) +static inline LRESULT TAB_GetItemCount (const TAB_INFO *infoPtr) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - return infoPtr->uNumItem; } static LRESULT -TAB_GetItemAW (HWND hwnd, WPARAM wParam, LPARAM lParam, BOOL bUnicode) +TAB_GetItemAW (TAB_INFO *infoPtr, INT iItem, LPTCITEMA tabItem, BOOL bUnicode) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - TCITEMA *tabItem; - TAB_ITEM *wineItem; - INT iItem; + TAB_ITEM *wineItem; - iItem = (INT)wParam; - tabItem = (LPTCITEMA)lParam; - TRACE("\n"); - if ((iItem<0) || (iItem>=infoPtr->uNumItem)) + TRACE("(%p,%d,%p,%s)\n", infoPtr, iItem, tabItem, bUnicode ? "true" : "false"); + + if (iItem < 0 || iItem >= infoPtr->uNumItem) return FALSE; wineItem = TAB_GetItem(infoPtr, iItem); @@ -2772,19 +2695,18 @@ TAB_GetItemAW (HWND hwnd, WPARAM wParam, LPARAM lParam, BOOL bUnicode) } -static LRESULT -TAB_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam) +static LRESULT TAB_DeleteItem (TAB_INFO *infoPtr, INT iItem) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - INT iItem = (INT) wParam; BOOL bResult = FALSE; + TRACE("(%p, %d)\n", infoPtr, iItem); + if ((iItem >= 0) && (iItem < infoPtr->uNumItem)) { TAB_ITEM *item = TAB_GetItem(infoPtr, iItem); LPBYTE oldItems = (LPBYTE)infoPtr->items; - TAB_InvalidateTabArea(hwnd, infoPtr); + TAB_InvalidateTabArea(infoPtr); if ((item->mask & TCIF_TEXT) && item->pszText) Free(item->pszText); @@ -2796,7 +2718,7 @@ TAB_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam) infoPtr->items = NULL; if (infoPtr->iHotTracked >= 0) { - KillTimer(hwnd, TAB_HOTTRACK_TIMER); + KillTimer(infoPtr->hwnd, TAB_HOTTRACK_TIMER); infoPtr->iHotTracked = -1; } } @@ -2831,7 +2753,7 @@ TAB_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam) infoPtr->iSelected = -1; /* Reposition and repaint tabs */ - TAB_SetItemBounds(hwnd); + TAB_SetItemBounds(infoPtr); bResult = TRUE; } @@ -2839,86 +2761,64 @@ TAB_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam) return bResult; } -static LRESULT -TAB_DeleteAllItems (HWND hwnd, WPARAM wParam, LPARAM lParam) +static inline LRESULT TAB_DeleteAllItems (TAB_INFO *infoPtr) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - + TRACE("(%p)\n", infoPtr); while (infoPtr->uNumItem) - TAB_DeleteItem (hwnd, 0, 0); + TAB_DeleteItem (infoPtr, 0); return TRUE; } -static LRESULT -TAB_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam) +static inline LRESULT TAB_GetFont (const TAB_INFO *infoPtr) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - - TRACE("\n"); + TRACE("(%p) returning %p\n", infoPtr, infoPtr->hFont); return (LRESULT)infoPtr->hFont; } -static LRESULT -TAB_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam) - +static inline LRESULT TAB_SetFont (TAB_INFO *infoPtr, HFONT hNewFont) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); + TRACE("(%p,%p)\n", infoPtr, hNewFont); - TRACE("%x %lx\n",wParam, lParam); + infoPtr->hFont = hNewFont; - infoPtr->hFont = (HFONT)wParam; + TAB_SetItemBounds(infoPtr); - TAB_SetItemBounds(hwnd); - - TAB_InvalidateTabArea(hwnd, infoPtr); + TAB_InvalidateTabArea(infoPtr); return 0; } -static LRESULT -TAB_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam) +static inline LRESULT TAB_GetImageList (const TAB_INFO *infoPtr) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - TRACE("\n"); return (LRESULT)infoPtr->himl; } -static LRESULT -TAB_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam) +static inline LRESULT TAB_SetImageList (TAB_INFO *infoPtr, HIMAGELIST himlNew) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - HIMAGELIST himlPrev; - + HIMAGELIST himlPrev = infoPtr->himl; TRACE("\n"); - himlPrev = infoPtr->himl; - infoPtr->himl= (HIMAGELIST)lParam; + infoPtr->himl = himlNew; return (LRESULT)himlPrev; } -static LRESULT -TAB_GetUnicodeFormat (HWND hwnd) +static inline LRESULT TAB_GetUnicodeFormat (const TAB_INFO *infoPtr) { - TAB_INFO *infoPtr = TAB_GetInfoPtr (hwnd); return infoPtr->bUnicode; } -static LRESULT -TAB_SetUnicodeFormat (HWND hwnd, WPARAM wParam) +static inline LRESULT TAB_SetUnicodeFormat (TAB_INFO *infoPtr, BOOL bUnicode) { - TAB_INFO *infoPtr = TAB_GetInfoPtr (hwnd); BOOL bTemp = infoPtr->bUnicode; - infoPtr->bUnicode = (BOOL)wParam; + infoPtr->bUnicode = bUnicode; return bTemp; } -static LRESULT -TAB_Size (HWND hwnd, WPARAM wParam, LPARAM lParam) - +static inline LRESULT TAB_Size (TAB_INFO *infoPtr) { /* I'm not really sure what the following code was meant to do. This is what it is doing: @@ -2945,17 +2845,16 @@ TAB_Size (HWND hwnd, WPARAM wParam, LPARAM lParam) } */ /* Recompute the size/position of the tabs. */ - TAB_SetItemBounds (hwnd); + TAB_SetItemBounds (infoPtr); /* Force a repaint of the control. */ - InvalidateRect(hwnd, NULL, TRUE); + InvalidateRect(infoPtr->hwnd, NULL, TRUE); return 0; } -static LRESULT -TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) +static LRESULT TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) { TAB_INFO *infoPtr; TEXTMETRICA fontMetrics; @@ -2967,6 +2866,7 @@ TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) SetWindowLongA(hwnd, 0, (DWORD)infoPtr); + infoPtr->hwnd = hwnd; infoPtr->hwndNotify = ((LPCREATESTRUCTW)lParam)->hwndParent; infoPtr->uNumItem = 0; infoPtr->uNumRows = 0; @@ -3050,9 +2950,8 @@ TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) } static LRESULT -TAB_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) +TAB_Destroy (TAB_INFO *infoPtr) { - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); UINT iItem; if (!infoPtr) @@ -3073,19 +2972,16 @@ TAB_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) DestroyWindow(infoPtr->hwndUpDown); if (infoPtr->iHotTracked >= 0) - KillTimer(hwnd, TAB_HOTTRACK_TIMER); + KillTimer(infoPtr->hwnd, TAB_HOTTRACK_TIMER); Free (infoPtr); - SetWindowLongA(hwnd, 0, 0); + SetWindowLongA(infoPtr->hwnd, 0, 0); return 0; } -static LRESULT -TAB_SetItemExtra (HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - INT cbInfo = wParam; - +static inline LRESULT +TAB_SetItemExtra (TAB_INFO *infoPtr, INT cbInfo) +{ if (!infoPtr || cbInfo <= 0) return FALSE; @@ -3105,92 +3001,92 @@ TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); TRACE("hwnd=%p msg=%x wParam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam); - if (!TAB_GetInfoPtr(hwnd) && (uMsg != WM_CREATE)) + if (!infoPtr && (uMsg != WM_CREATE)) return DefWindowProcW (hwnd, uMsg, wParam, lParam); switch (uMsg) { case TCM_GETIMAGELIST: - return TAB_GetImageList (hwnd, wParam, lParam); + return TAB_GetImageList (infoPtr); case TCM_SETIMAGELIST: - return TAB_SetImageList (hwnd, wParam, lParam); + return TAB_SetImageList (infoPtr, (HIMAGELIST)lParam); case TCM_GETITEMCOUNT: - return TAB_GetItemCount (hwnd, wParam, lParam); + return TAB_GetItemCount (infoPtr); case TCM_GETITEMA: case TCM_GETITEMW: - return TAB_GetItemAW (hwnd, wParam, lParam, uMsg == TCM_GETITEMW); + return TAB_GetItemAW (infoPtr, (INT)wParam, (LPTCITEMA)lParam, uMsg == TCM_GETITEMW); case TCM_SETITEMA: case TCM_SETITEMW: - return TAB_SetItemAW (hwnd, wParam, lParam, uMsg == TCM_SETITEMW); + return TAB_SetItemAW (infoPtr, (INT)wParam, (LPTCITEMA)lParam, uMsg == TCM_SETITEMW); case TCM_DELETEITEM: - return TAB_DeleteItem (hwnd, wParam, lParam); + return TAB_DeleteItem (infoPtr, (INT)wParam); case TCM_DELETEALLITEMS: - return TAB_DeleteAllItems (hwnd, wParam, lParam); + return TAB_DeleteAllItems (infoPtr); case TCM_GETITEMRECT: - return TAB_GetItemRect (hwnd, wParam, lParam); + return TAB_GetItemRect (infoPtr, wParam, lParam); case TCM_GETCURSEL: - return TAB_GetCurSel (hwnd); + return TAB_GetCurSel (infoPtr); case TCM_HITTEST: - return TAB_HitTest (hwnd, wParam, lParam); + return TAB_HitTest (infoPtr, (LPTCHITTESTINFO)lParam); case TCM_SETCURSEL: - return TAB_SetCurSel (hwnd, wParam); + return TAB_SetCurSel (infoPtr, (INT)wParam); case TCM_INSERTITEMA: case TCM_INSERTITEMW: - return TAB_InsertItemAW (hwnd, wParam, lParam, uMsg == TCM_INSERTITEMW); + return TAB_InsertItemAW (infoPtr, wParam, lParam, uMsg == TCM_INSERTITEMW); case TCM_SETITEMEXTRA: - return TAB_SetItemExtra (hwnd, wParam, lParam); + return TAB_SetItemExtra (infoPtr, (int)wParam); case TCM_ADJUSTRECT: - return TAB_AdjustRect (hwnd, (BOOL)wParam, (LPRECT)lParam); + return TAB_AdjustRect (infoPtr, (BOOL)wParam, (LPRECT)lParam); case TCM_SETITEMSIZE: - return TAB_SetItemSize (hwnd, wParam, lParam); + return TAB_SetItemSize (infoPtr, lParam); case TCM_REMOVEIMAGE: FIXME("Unimplemented msg TCM_REMOVEIMAGE\n"); return 0; case TCM_SETPADDING: - return TAB_SetPadding (hwnd, wParam, lParam); + return TAB_SetPadding (infoPtr, lParam); case TCM_GETROWCOUNT: - return TAB_GetRowCount(hwnd); + return TAB_GetRowCount(infoPtr); case TCM_GETUNICODEFORMAT: - return TAB_GetUnicodeFormat (hwnd); + return TAB_GetUnicodeFormat (infoPtr); case TCM_SETUNICODEFORMAT: - return TAB_SetUnicodeFormat (hwnd, wParam); + return TAB_SetUnicodeFormat (infoPtr, (BOOL)wParam); case TCM_HIGHLIGHTITEM: - return TAB_HighlightItem (hwnd, wParam, lParam); + return TAB_HighlightItem (infoPtr, (INT)wParam, (BOOL)LOWORD(lParam)); case TCM_GETTOOLTIPS: - return TAB_GetToolTips (hwnd, wParam, lParam); + return TAB_GetToolTips (infoPtr); case TCM_SETTOOLTIPS: - return TAB_SetToolTips (hwnd, wParam, lParam); + return TAB_SetToolTips (infoPtr, (HWND)wParam); case TCM_GETCURFOCUS: - return TAB_GetCurFocus (hwnd); + return TAB_GetCurFocus (infoPtr); case TCM_SETCURFOCUS: - return TAB_SetCurFocus (hwnd, wParam); + return TAB_SetCurFocus (infoPtr, (INT)wParam); case TCM_SETMINTABWIDTH: - return TAB_SetMinTabWidth(hwnd, lParam); + return TAB_SetMinTabWidth(infoPtr, (INT)lParam); case TCM_DESELECTALL: FIXME("Unimplemented msg TCM_DESELECTALL\n"); @@ -3205,49 +3101,49 @@ TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return 0; case WM_GETFONT: - return TAB_GetFont (hwnd, wParam, lParam); + return TAB_GetFont (infoPtr); case WM_SETFONT: - return TAB_SetFont (hwnd, wParam, lParam); + return TAB_SetFont (infoPtr, (HFONT)wParam); case WM_CREATE: return TAB_Create (hwnd, wParam, lParam); case WM_NCDESTROY: - return TAB_Destroy (hwnd, wParam, lParam); + return TAB_Destroy (infoPtr); case WM_GETDLGCODE: return DLGC_WANTARROWS | DLGC_WANTCHARS; case WM_LBUTTONDOWN: - return TAB_LButtonDown (hwnd, wParam, lParam); + return TAB_LButtonDown (infoPtr, wParam, lParam); case WM_LBUTTONUP: - return TAB_LButtonUp (hwnd, wParam, lParam); + return TAB_LButtonUp (infoPtr); case WM_NOTIFY: return SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam); case WM_RBUTTONDOWN: - return TAB_RButtonDown (hwnd, wParam, lParam); + return TAB_RButtonDown (infoPtr); case WM_MOUSEMOVE: - return TAB_MouseMove (hwnd, wParam, lParam); + return TAB_MouseMove (infoPtr, wParam, lParam); case WM_PAINT: - return TAB_Paint (hwnd, wParam); + return TAB_Paint (infoPtr, (HDC)wParam); case WM_SIZE: - return TAB_Size (hwnd, wParam, lParam); + return TAB_Size (infoPtr); case WM_SETREDRAW: - return TAB_SetRedraw (hwnd, wParam); + return TAB_SetRedraw (infoPtr, (BOOL)wParam); case WM_HSCROLL: - return TAB_OnHScroll(hwnd, (int)LOWORD(wParam), (int)HIWORD(wParam), (HWND)lParam); + return TAB_OnHScroll(infoPtr, (int)LOWORD(wParam), (int)HIWORD(wParam), (HWND)lParam); case WM_STYLECHANGED: - TAB_SetItemBounds (hwnd); + TAB_SetItemBounds (infoPtr); InvalidateRect(hwnd, NULL, TRUE); return 0; @@ -3257,19 +3153,21 @@ TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_KILLFOCUS: case WM_SETFOCUS: - return TAB_FocusChanging(hwnd, uMsg, wParam, lParam); + TAB_FocusChanging(infoPtr); + break; /* Don't disturb normal focus behavior */ case WM_KEYUP: - return TAB_KeyUp(hwnd, wParam); + return TAB_KeyUp(infoPtr, wParam); case WM_NCHITTEST: - return TAB_NCHitTest(hwnd, lParam); + return TAB_NCHitTest(infoPtr, lParam); default: - if ((uMsg >= WM_USER) && (uMsg < WM_APP)) + if (uMsg >= WM_USER && uMsg < WM_APP) WARN("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam); - return DefWindowProcW(hwnd, uMsg, wParam, lParam); + break; } + return DefWindowProcW(hwnd, uMsg, wParam, lParam); } diff --git a/reactos/lib/comctl32/treeview.c b/reactos/lib/comctl32/treeview.c index b7320f14e1b..0c4a5cc4e73 100644 --- a/reactos/lib/comctl32/treeview.c +++ b/reactos/lib/comctl32/treeview.c @@ -2386,7 +2386,9 @@ TREEVIEW_DrawItem(TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *wineItem) /* The custom draw handler can query the text rectangle, * so get ready. */ - TREEVIEW_ComputeTextWidth(infoPtr, wineItem, hdc); + /* should already be known, set to 0 when changed */ + if (!wineItem->textWidth) + TREEVIEW_ComputeTextWidth(infoPtr, wineItem, hdc); cditem = 0; @@ -3084,6 +3086,9 @@ TREEVIEW_Collapse(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem, { UINT action = TVE_COLLAPSE | (bRemoveChildren ? TVE_COLLAPSERESET : 0); BOOL bSetSelection, bSetFirstVisible; + RECT scrollRect; + LONG scrollDist = 0; + TREEVIEW_ITEM *nextItem = NULL, *tmpItem; TRACE("TVE_COLLAPSE %p %s\n", wineItem, TREEVIEW_ItemName(wineItem)); @@ -3107,6 +3112,20 @@ TREEVIEW_Collapse(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem, bSetFirstVisible = (infoPtr->firstVisible != NULL && TREEVIEW_IsChildOf(wineItem, infoPtr->firstVisible)); + tmpItem = wineItem; + while (tmpItem) + { + if (tmpItem->nextSibling) + { + nextItem = tmpItem->nextSibling; + break; + } + tmpItem = tmpItem->parent; + } + + if (nextItem) + scrollDist = nextItem->rect.top; + if (bRemoveChildren) { INT old_cChildren = wineItem->cChildren; @@ -3131,8 +3150,8 @@ TREEVIEW_Collapse(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem, TREEVIEW_RecalculateVisibleOrder(infoPtr, wineItem); - TREEVIEW_SetFirstVisible(infoPtr, bSetFirstVisible ? wineItem - : infoPtr->firstVisible, TRUE); + if (nextItem) + scrollDist = -(scrollDist - nextItem->rect.top); if (bSetSelection) { @@ -3141,12 +3160,29 @@ TREEVIEW_Collapse(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem, infoPtr->selectedItem->state &= ~TVIS_SELECTED; wineItem->state |= TVIS_SELECTED; infoPtr->selectedItem = wineItem; - - TREEVIEW_EnsureVisible(infoPtr, wineItem, FALSE); } TREEVIEW_UpdateScrollBars(infoPtr); - TREEVIEW_Invalidate(infoPtr, NULL); + + scrollRect.left = 0; + scrollRect.right = infoPtr->clientWidth; + scrollRect.bottom = infoPtr->clientHeight; + + if (nextItem) + { + scrollRect.top = nextItem->rect.top; + + ScrollWindowEx (infoPtr->hwnd, 0, scrollDist, &scrollRect, NULL, + NULL, NULL, SW_ERASE | SW_INVALIDATE); + TREEVIEW_Invalidate(infoPtr, wineItem); + } else { + scrollRect.top = wineItem->rect.top; + InvalidateRect(infoPtr->hwnd, &scrollRect, TRUE); + } + + TREEVIEW_SetFirstVisible(infoPtr, + bSetFirstVisible ? wineItem : infoPtr->firstVisible, + TRUE); return TRUE; } @@ -3155,11 +3191,30 @@ static BOOL TREEVIEW_Expand(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem, BOOL bExpandPartial, BOOL bUser) { + LONG scrollDist; + LONG orgNextTop = 0; + RECT scrollRect; + TREEVIEW_ITEM *nextItem, *tmpItem; + TRACE("\n"); if (wineItem->state & TVIS_EXPANDED) return TRUE; + tmpItem = wineItem; nextItem = NULL; + while (tmpItem) + { + if (tmpItem->nextSibling) + { + nextItem = tmpItem->nextSibling; + break; + } + tmpItem = tmpItem->parent; + } + + if (nextItem) + orgNextTop = nextItem->rect.top; + TRACE("TVE_EXPAND %p %s\n", wineItem, TREEVIEW_ItemName(wineItem)); if (bUser || ((wineItem->cChildren != 0) && @@ -3194,6 +3249,22 @@ TREEVIEW_Expand(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem, TREEVIEW_UpdateSubTree(infoPtr, wineItem); TREEVIEW_UpdateScrollBars(infoPtr); + scrollRect.left = 0; + scrollRect.bottom = infoPtr->treeHeight; + scrollRect.right = infoPtr->clientWidth; + if (nextItem) + { + scrollDist = nextItem->rect.top - orgNextTop; + scrollRect.top = orgNextTop; + + ScrollWindowEx (infoPtr->hwnd, 0, scrollDist, &scrollRect, NULL, + NULL, NULL, SW_ERASE | SW_INVALIDATE); + TREEVIEW_Invalidate (infoPtr, wineItem); + } else { + scrollRect.top = wineItem->rect.top; + InvalidateRect(infoPtr->hwnd, &scrollRect, FALSE); + } + /* Scroll up so that as many children as possible are visible. * This fails when expanding causes an HScroll bar to appear, but we * don't know that yet, so the last item is obscured. */ @@ -3226,8 +3297,6 @@ TREEVIEW_Expand(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem, } } - TREEVIEW_Invalidate(infoPtr, NULL); - return TRUE; } @@ -4735,7 +4804,7 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs) infoPtr->uIndent = MINIMUM_INDENT; infoPtr->selectedItem = 0; infoPtr->focusedItem = 0; - /* hotItem? */ + infoPtr->hotItem = 0; infoPtr->firstVisible = 0; infoPtr->maxVisibleOrder = 0; infoPtr->dropItem = 0; @@ -5435,7 +5504,10 @@ TREEVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return TREEVIEW_MouseLeave(infoPtr); case WM_MOUSEMOVE: - return TREEVIEW_MouseMove(infoPtr, wParam, lParam); + if (infoPtr->dwStyle & TVS_TRACKSELECT) + return TREEVIEW_MouseMove(infoPtr, wParam, lParam); + else + return 0; case WM_NOTIFY: return TREEVIEW_Notify(infoPtr, wParam, lParam); diff --git a/reactos/w32api/include/winuser.h b/reactos/w32api/include/winuser.h index 11aa8218899..cc261865b4d 100644 --- a/reactos/w32api/include/winuser.h +++ b/reactos/w32api/include/winuser.h @@ -605,6 +605,13 @@ extern "C" { #define GCL_MENUNAME (-8) #define GCL_STYLE (-26) #define GCL_WNDPROC (-24) +#define GCLP_HBRBACKGROUND (-10) +#define GCLP_HCURSOR (-12) +#define GCLP_HICON (-14) +#define GCLP_HICONSM (-34) +#define GCLP_HMODULE (-16) +#define GCLP_MENUNAME (-8) +#define GCLP_WNDPROC (-24) #if 0 /* This is supposed to be defined by the program using it not defined in the w32api headers. I've left it here for documentation purposes. @@ -3420,6 +3427,13 @@ BOOL WINAPI GetClassInfoW(HINSTANCE,LPCWSTR,LPWNDCLASSW); BOOL WINAPI GetClassInfoExW(HINSTANCE,LPCWSTR,LPWNDCLASSEXW); DWORD WINAPI GetClassLongA(HWND,int); DWORD WINAPI GetClassLongW(HWND,int); +#ifdef _WIN64 +LONG_PTR WINAPI GetClassLongPtrA(HWND,int); +LONG_PTR WINAPI GetClassLongPtrW(HWND,int); +#else +#define GetClassLongPtrA GetClassLongA +#define GetClassLongPtrW GetClassLongW +#endif int WINAPI GetClassNameA(HWND,LPSTR,int); int WINAPI GetClassNameW(HWND,LPWSTR,int); WORD WINAPI GetClassWord(HWND,int);