Changeset 6380 for trunk/src


Ignore:
Timestamp:
Jul 21, 2001, 11:08:03 AM (24 years ago)
Author:
sandervl
Message:

wine resync

Location:
trunk/src/comctl32
Files:
3 added
3 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/LICENSE.TXT

    r2784 r6380  
    1 $Id: LICENSE.TXT,v 1.1 2000-02-14 20:14:46 sandervl Exp $
     1$Id: LICENSE.TXT,v 1.2 2001-07-21 09:07:16 sandervl Exp $
    22@c This is an additional Odin license agreement.
    33@c It supercedes the main Odin license, but is only valid in
    44@c the source directory in which it is present.
    5 @c READ THE SECTION `WARRANTY' BELOW CAREFULLY FOR A STATEMENT ON THE WARRANTY.
    65
    7 You may without charge, royalty or other payment, copy and
    8 distribute copies of this work and derivative works of this work
    9 in source or binary form provided that: (1)
    10 you appropriately publish on each copy an appropriate copyright
    11 notice; (2) faithfully reproduce all prior copyright notices
    12 included in the original work (you may also add your own
    13 copyright notice); and (3) agree to indemnify and hold all prior
    14 authors, copyright holders and licensors of the work harmless
    15 from and against all damages arising from use of the work.
    16  
    17 You may distribute sources of derivative works of the work
    18 provided that (1) (a) all source files of the original work that
    19 have been modified, (b) all source files of the derivative work
    20 that contain any party of the original work, and (c) all source
    21 files of the derivative work that are necessary to compile, link
    22 and run the derivative work without unresolved external calls and
    23 with the same functionality of the original work (``Necessary
    24 Sources'') carry a prominent notice explaining the nature and date
    25 of the modification and/or creation.  You are encouraged to make
    26 the Necessary Sources available under this license in order to
    27 further the development and acceptance of the work.
     6@c This file is processed by GNU's TeXinfo
     7@c If you modify it or move it to another location, make sure that
     8@c TeXinfo works (type `make' in directory documentation).
    289
     10Copyright (c) 1993-2000 the Wine project authors (see the file AUTHORS
     11for a complete list)
    2912
    30 WARRANTY:
     13Permission is hereby granted, free of charge, to any person obtaining a copy
     14of this software and associated documentation files (the "Software"), to deal
     15in the Software without restriction, including without limitation the rights
     16to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     17copies of the Software, and to permit persons to whom the Software is
     18furnished to do so, subject to the following conditions:
    3119
    32 EXCEPT AS OTHERWISE RESTRICTED BY LAW, THIS WORK IS PROVIDED
    33 WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES OF ANY KIND, INCLUDING
    34 BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF FITNESS FOR A
    35 PARTICULAR PURPOSE, MERCHANTABILITY OR TITLE.  EXCEPT AS
    36 OTHERWISE PROVIDED BY LAW, NO AUTHOR, COPYRIGHT HOLDER OR
    37 LICENSOR SHALL BE LIABLE TO YOU FOR DAMAGES OF ANY KIND, EVEN IF
    38 ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
     20The above copyright notice and this permission notice shall be included in
     21all copies or substantial portions of the Software.
     22
     23THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     24IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     25FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
     26COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
     27IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
     28CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  • trunk/src/comctl32/comboex.c

    r5630 r6380  
    1919
    2020/*
    21  * ComboBoxEx control v2 (mod5)
     21 * ComboBoxEx control v2 (mod6)
    2222 *
    2323 * Copyright 1998, 1999 Eric Kohl
     
    6969 *   5. Add support for CB_SETITEMDATA sets LPARAM value from item.
    7070 *
     71 *  mod 6
     72 *   1. Add support for WM_NOTIFYFORMAT (both incoming and outgoing) and do
     73 *      WM_NOTIFY correctly based on results.
     74 *   2. Fix memory leaks of text strings in COMBOEX_WM_DELETEITEM.
     75 *   3. Add routines to handle special cases of NMCBEENDEDIT and NMCOMBOXEX
     76 *      so translation to ANSI is done correctly.
     77 *   4. Fix some issues with COMBOEX_DrawItem.
     78 *
    7179 * Test vehicals were the ControlSpy modules (rebar.exe and comboboxex.exe),
    7280 *  WinRAR, and IE 4.0.
     
    122130    HFONT        font;
    123131    INT          nb_items;         /* Number of items */
    124     BOOL         bUnicode;         /* ASCII (FALSE) or Unicode (TRUE)? */
     132    BOOL         bUnicode;        /* TRUE if this window is Unicode   */
     133    BOOL         NtfUnicode;      /* TRUE if parent wants notify in Unicode */
    125134    CBE_ITEMDATA *edit;            /* item data for edit item */
    126135    CBE_ITEMDATA *items;           /* Array of items */
     
    225234
    226235static INT
    227 COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr, BOOL doW)
     236COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr)
    228237{
    229238
     
    231240    hdr->hwndFrom = infoPtr->hwndSelf;
    232241    hdr->code = code;
    233     if (doW)
     242    if (infoPtr->NtfUnicode)
    234243        return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    235244                             (LPARAM)hdr);
     
    237246        return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    238247                             (LPARAM)hdr);
     248}
     249
     250
     251static INT
     252COMBOEX_NotifyItem (COMBOEX_INFO *infoPtr, INT code, NMCOMBOBOXEXW *hdr)
     253{
     254
     255    /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */
     256
     257    hdr->hdr.idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
     258    hdr->hdr.hwndFrom = infoPtr->hwndSelf;
     259    hdr->hdr.code = code;
     260    if (infoPtr->NtfUnicode)
     261        return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     262                             (LPARAM)hdr);
     263    else {
     264        LPWSTR str, ostr = NULL;
     265        INT ret, len = 0;
     266
     267        if (hdr->ceItem.mask & CBEIF_TEXT) {
     268            ostr = hdr->ceItem.pszText;
     269            str = ostr;
     270            if (!str) str = (LPWSTR)L"";
     271            len = WideCharToMultiByte (CP_ACP, 0, str, -1, 0, 0, NULL, NULL);
     272            if (len > 0) {
     273                hdr->ceItem.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(CHAR));
     274                WideCharToMultiByte (CP_ACP, 0, str, -1, (LPSTR)hdr->ceItem.pszText,
     275                                     len, NULL, NULL);
     276            }
     277        }
     278
     279        ret = SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     280                            (LPARAM)hdr);
     281        if (hdr->ceItem.mask & CBEIF_TEXT) {
     282            if (len > 0)
     283                COMCTL32_Free (hdr->ceItem.pszText);
     284            hdr->ceItem.pszText = ostr;
     285        }
     286        return ret;
     287    }
     288}
     289
     290
     291static INT
     292COMBOEX_NotifyEndEdit (COMBOEX_INFO *infoPtr, NMCBEENDEDITW *hdr, LPWSTR itemText)
     293{
     294
     295    /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */
     296
     297    hdr->hdr.idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
     298    hdr->hdr.hwndFrom = infoPtr->hwndSelf;
     299    hdr->hdr.code = (infoPtr->NtfUnicode) ? CBEN_ENDEDITW : CBEN_ENDEDITA;
     300    if (infoPtr->NtfUnicode)
     301        return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     302                             (LPARAM)hdr);
     303    else {
     304        NMCBEENDEDITA ansi;
     305
     306        memcpy (&ansi.hdr, &hdr->hdr, sizeof(NMHDR));
     307        ansi.fChanged = hdr->fChanged;
     308        ansi.iNewSelection = hdr->iNewSelection;
     309        WideCharToMultiByte (CP_ACP, 0, itemText, -1,
     310                             (LPSTR)&ansi.szText, CBEMAXSTRLEN, NULL, NULL);
     311        ansi.iWhy = hdr->iWhy;
     312        return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     313                             (LPARAM)&ansi);
     314    }
    239315}
    240316
     
    537613    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    538614
    539     TRACE("%s hwnd=0x%x stub!\n",
     615    TRACE("%s hwnd=0x%x\n",
    540616           infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
    541617
     
    617693            strcpyW (item->pszText, str);
    618694        }
     695        else
     696            item->pszText = NULL;
    619697        item->cchTextMax   = cit->cchTextMax;
    620698    }
     
    639717
    640718    COMBOEX_CopyItem (infoPtr, item, &nmcit.ceItem);
    641     COMBOEX_Notify (infoPtr, CBEN_INSERTITEM, (NMHDR *)&nmcit, TRUE);
     719    COMBOEX_NotifyItem (infoPtr, CBEN_INSERTITEM, &nmcit);
    642720
    643721    return index;
     
    833911{
    834912    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    835     BOOL bTemp;
    836 
    837     TRACE("%s hwnd=0x%04x stub!\n",
    838            ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
    839 
    840     bTemp = infoPtr->bUnicode;
     913    BOOL bTemp = infoPtr->bUnicode;
     914
     915    TRACE("to %s hwnd=0x%04x, was %s\n",
     916          ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd,
     917          (bTemp) ? "TRUE" : "FALSE");
     918
    841919    infoPtr->bUnicode = (BOOL)wParam;
    842920
     
    10141092    RECT wnrc1, clrc1, cmbwrc;
    10151093    LONG test;
     1094    INT i;
    10161095
    10171096    /* allocate memory for info structure */
     
    10321111    infoPtr->hwndSelf = hwnd;
    10331112    infoPtr->selected = -1;
     1113
     1114    infoPtr->bUnicode = IsWindowUnicode (hwnd);
     1115
     1116    i = SendMessageA(GetParent (hwnd),
     1117                     WM_NOTIFYFORMAT, hwnd, NF_QUERY);
     1118    if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
     1119        ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
     1120            i);
     1121        i = NFR_ANSI;
     1122    }
     1123    infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
    10341124
    10351125    SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
     
    11861276    WCHAR wintext[520];
    11871277    INT cursel, n, oldItem;
    1188     NMCBEENDEDITA cbeend;
     1278    NMCBEENDEDITW cbeend;
    11891279    DWORD oldflags;
    11901280
     
    12471337
    12481338        if (oldflags & WCBE_ACTEDIT) {
    1249             WideCharToMultiByte (CP_ACP, 0, item->pszText, -1,
    1250                                  cbeend.szText, sizeof(cbeend.szText),
    1251                                  NULL, NULL);
    12521339            cbeend.fChanged = (oldflags & WCBE_EDITCHG);
    12531340            cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     
    12551342            cbeend.iWhy = CBENF_DROPDOWN;
    12561343
    1257             if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
    1258                                 (NMHDR *)&cbeend, FALSE)) {
     1344            if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, item->pszText)) {
    12591345                /* abort the change */
    12601346                TRACE("Notify requested abort of change\n");
     
    13191405                             (LPARAM)hwnd);
    13201406        if (infoPtr->flags & WCBE_ACTEDIT) {
    1321             GetWindowTextA (infoPtr->hwndEdit, cbeend.szText, 260);
     1407            GetWindowTextW (infoPtr->hwndEdit, wintext, 260);
    13221408            cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
    13231409            cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     
    13261412
    13271413            infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
    1328             if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
    1329                                 (NMHDR *)&cbeend, FALSE)) {
     1414            if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) {
    13301415                /* abort the change */
    13311416                TRACE("Notify requested abort of change\n");
     
    13941479
    13951480    COMBOEX_CopyItem (infoPtr, olditem, &nmcit.ceItem);
    1396     COMBOEX_Notify (infoPtr, CBEN_DELETEITEM, (NMHDR *)&nmcit, TRUE);
    1397 
     1481    COMBOEX_NotifyItem (infoPtr, CBEN_DELETEITEM, &nmcit);
     1482
     1483    if (olditem->pszText)
     1484        COMCTL32_Free(olditem->pszText);
    13981485    COMCTL32_Free(olditem);
    13991486
     
    14111498    SIZE txtsize;
    14121499    RECT rect;
     1500    LPWSTR str;
    14131501    int drawimage, drawstate;
    1414     UINT xbase;
     1502    UINT xbase, x, y;
    14151503    UINT xioff = 0;               /* size and spacer of image if any */
    14161504    IMAGEINFO iinfo;
    14171505    INT len;
     1506    COLORREF nbkc, ntxc;
    14181507
    14191508    if (!IsWindowEnabled(infoPtr->hwndCombo)) return 0;
     1509
     1510    /* dump the DRAWITEMSTRUCT if tracing "comboex" but not "message" */
     1511    if (!TRACE_ON(message)) {
     1512        TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
     1513              dis->CtlType, dis->CtlID);
     1514        TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
     1515              dis->itemID, dis->itemAction, dis->itemState);
     1516        TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n",
     1517              dis->hwndItem, dis->hDC, dis->rcItem.left,
     1518              dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
     1519              dis->itemData);
     1520    }
    14201521
    14211522    /* MSDN says:                                                       */
     
    14701571        INT wlen, alen;
    14711572
    1472         if (!infoPtr->hwndEdit) {
    1473             ERR("request to draw edit item, but no edit control exists!\n");
    1474             return 0;
    1475         }
    1476 
    14771573        item = infoPtr->edit;
    1478         /* free previous text of edit item */
    1479         if (item->pszText) {
    1480             COMCTL32_Free(item->pszText);
    1481             item->pszText = 0;
    1482             item->mask &= ~CBEIF_TEXT;
    1483         }
    1484         alen = SendMessageA (infoPtr->hwndEdit, WM_GETTEXT, 260, (LPARAM)&str);
    1485         TRACE("edit control hwndEdit=%0x, text len=%d str=<%s>\n",
    1486               infoPtr->hwndEdit, alen, str);
    1487         if (alen > 0) {
    1488             item->mask |= CBEIF_TEXT;
    1489             wlen = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
    1490             if (wlen > 0) {
    1491                 item->pszText = (LPWSTR)COMCTL32_Alloc ((wlen + 1)*sizeof(WCHAR));
    1492                 MultiByteToWideChar (CP_ACP, 0, str, -1, item->pszText, wlen);
     1574
     1575        if (infoPtr->hwndEdit) {
     1576
     1577            /* free previous text of edit item */
     1578            if (item->pszText) {
     1579                COMCTL32_Free(item->pszText);
     1580                item->pszText = 0;
     1581                item->mask &= ~CBEIF_TEXT;
     1582            }
     1583            alen = SendMessageA (infoPtr->hwndEdit, WM_GETTEXT, 260, (LPARAM)&str);
     1584            TRACE("edit control hwndEdit=%0x, text len=%d str=<%s>\n",
     1585                  infoPtr->hwndEdit, alen, str);
     1586            if (alen > 0) {
     1587                item->mask |= CBEIF_TEXT;
     1588                wlen = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
     1589                if (wlen > 0) {
     1590                    item->pszText = (LPWSTR)COMCTL32_Alloc ((wlen + 1)*sizeof(WCHAR));
     1591                    MultiByteToWideChar (CP_ACP, 0, str, -1, item->pszText, wlen);
     1592                }
    14931593            }
    14941594        }
     
    15061606    }
    15071607
    1508     /* dump the DRAWITEMSTRUCT if tracing "comboex" but not "message" */
    1509     if (!TRACE_ON(message)) {
    1510         TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
    1511               dis->CtlType, dis->CtlID);
    1512         TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
    1513               dis->itemID, dis->itemAction, dis->itemState);
    1514         TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n",
    1515               dis->hwndItem, dis->hDC, dis->rcItem.left,
    1516               dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
    1517               dis->itemData);
    1518     }
    15191608    COMBOEX_DumpItem (item);
    15201609
     
    16011690                            xbase, dis->rcItem.top, drawstate);
    16021691        }
    1603         if ((item->mask & CBEIF_TEXT) && item->pszText) {
    1604             UINT x, y;
    1605             COLORREF nbkc, ntxc;
    1606 
    1607             len = lstrlenW (item->pszText);
    1608             GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize);
    1609             nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
    1610                                 COLOR_HIGHLIGHT : COLOR_WINDOW);
    1611             SetBkColor (dis->hDC, nbkc);
    1612             ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
    1613                                 COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
    1614             SetTextColor (dis->hDC, ntxc);
    1615             x = xbase + xioff;
    1616             y = dis->rcItem.top +
    1617                 (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
    1618             rect.left = x;
    1619             rect.right = x + txtsize.cx;
    1620             rect.top = dis->rcItem.top + 1;
    1621             rect.bottom = dis->rcItem.bottom - 1;
    1622             TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n",
     1692
     1693        /* setup pointer to text to be drawn */
     1694        if ((item->mask & CBEIF_TEXT) && item->pszText)
     1695            str = item->pszText;
     1696        else
     1697            str = (LPWSTR) L"";
     1698
     1699        /* now draw the text */
     1700        len = lstrlenW (str);
     1701        GetTextExtentPointW (dis->hDC, str, len, &txtsize);
     1702        nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
     1703                            COLOR_HIGHLIGHT : COLOR_WINDOW);
     1704        SetBkColor (dis->hDC, nbkc);
     1705        ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
     1706                            COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
     1707        SetTextColor (dis->hDC, ntxc);
     1708        x = xbase + xioff;
     1709        y = dis->rcItem.top +
     1710            (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
     1711        rect.left = x;
     1712        rect.right = x + txtsize.cx;
     1713        rect.top = dis->rcItem.top + 1;
     1714        rect.bottom = dis->rcItem.bottom - 1;
     1715        TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n",
     1716              dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
     1717        ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
     1718                     &rect, str, len, 0);
     1719        if (dis->itemState & ODS_FOCUS) {
     1720            rect.top -= 1;
     1721            rect.bottom += 1;
     1722            rect.left -= 1;
     1723            rect.right += 1;
     1724            TRACE("drawing item %d focus after text, rect=(%d,%d)-(%d,%d)\n",
    16231725                  dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
    1624             ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
    1625                          &rect, item->pszText, len, 0);
    1626             if (dis->itemState & ODS_FOCUS) {
    1627                 rect.top -= 1;
    1628                 rect.bottom += 1;
    1629                 rect.left -= 1;
    1630                 rect.right += 1;
    1631                 TRACE("drawing item %d focus after text, rect=(%d,%d)-(%d,%d)\n",
    1632                       dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
    1633                 DrawFocusRect (dis->hDC, &rect);
    1634             }
     1726            DrawFocusRect (dis->hDC, &rect);
    16351727        }
    16361728        break;
     
    17171809
    17181810static LRESULT
     1811COMBOEX_NotifyFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1812{
     1813    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     1814    INT i;
     1815
     1816    if (lParam == NF_REQUERY) {
     1817        i = SendMessageA(GetParent (hwnd),
     1818                         WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
     1819        if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
     1820            ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
     1821                i);
     1822            i = NFR_ANSI;
     1823        }
     1824        infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
     1825        return (LRESULT)i;
     1826    }
     1827    return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
     1828}
     1829
     1830
     1831static LRESULT
    17191832COMBOEX_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
    17201833{
     
    17391852{
    17401853    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    1741     LRESULT ret;
    17421854    RECT cbx_wrect, cbx_crect, cb_wrect;
    17431855    UINT width, height;
    17441856    WINDOWPOS *wp = (WINDOWPOS *)lParam;
    17451857
    1746     ret = DefWindowProcA (hwnd, WM_WINDOWPOSCHANGING, wParam, lParam);
    17471858    GetWindowRect (hwnd, &cbx_wrect);
    17481859    GetClientRect (hwnd, &cbx_crect);
     
    17881899{
    17891900    COMBOEX_INFO *infoPtr = (COMBOEX_INFO *)GetPropA (hwnd, (LPCSTR)(LONG) ComboExInfo);
    1790     NMCBEENDEDITA cbeend;
     1901    NMCBEENDEDITW cbeend;
     1902    WCHAR edit_text[260];
    17911903    COLORREF nbkc, obkc;
    17921904    HDC hDC;
     
    18271939            INT oldItem, selected;
    18281940            CBE_ITEMDATA *item;
    1829             WCHAR edit_text[260];
    18301941
    18311942            switch ((INT)wParam)
     
    18511962                TRACE("special code for VK_ESCAPE\n");
    18521963
    1853                 GetWindowTextA (infoPtr->hwndEdit, cbeend.szText, 260);
     1964                GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
    18541965
    18551966                infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     
    18591970                cbeend.iWhy = CBENF_ESCAPE;
    18601971
    1861                 if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
    1862                                     (NMHDR *)&cbeend, FALSE)) {
     1972                if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
    18631973                    /* abort the change */
    18641974                    TRACE("Notify requested abort of change\n");
     
    19222032                cbeend.fChanged = TRUE;
    19232033                cbeend.iWhy = CBENF_RETURN;
    1924                 WideCharToMultiByte (CP_ACP, 0, edit_text, -1,
    1925                                      cbeend.szText, sizeof(cbeend.szText),
    1926                                      NULL, NULL);
    1927 
    1928                 if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
    1929                                     (NMHDR *)&cbeend, FALSE)) {
     2034                if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
    19302035                    /* abort the change, restore previous */
    19312036                    TRACE("Notify requested abort of change\n");
     
    19662071            if (infoPtr->flags & WCBE_ACTEDIT) {
    19672072                infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     2073
     2074                GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
    19682075                cbeend.fChanged = FALSE;
    19692076                cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     
    19712078                cbeend.iWhy = CBENF_KILLFOCUS;
    19722079
    1973                 COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
    1974                                 (NMHDR *)&cbeend, FALSE);
     2080                COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text);
    19752081            }
    19762082            /* fall through */
     
    19882094{
    19892095    COMBOEX_INFO *infoPtr = (COMBOEX_INFO *)GetPropA (hwnd, (LPCSTR)(LONG) ComboExInfo);
    1990     NMCBEENDEDITA cbeend;
     2096    NMCBEENDEDITW cbeend;
    19912097    NMMOUSE nmmse;
    19922098    COLORREF nbkc, obkc;
     
    19942100    HWND focusedhwnd;
    19952101    RECT rect;
     2102    WCHAR edit_text[260];
    19962103
    19972104    TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
     
    20422149            nmmse.pt.y = 0;
    20432150            nmmse.dwHitInfo = lParam;
    2044             COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse, FALSE);
     2151            COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse);
    20452152            return CallWindowProcA (infoPtr->prevComboWndProc,
    20462153                                   hwnd, uMsg, wParam, lParam);
     
    20702177                focusedhwnd = GetFocus();
    20712178                if (infoPtr->flags & WCBE_ACTEDIT) {
    2072                     GetWindowTextA (infoPtr->hwndEdit, cbeend.szText, 260);
     2179                    GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
    20732180                    cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
    20742181                    cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     
    20772184
    20782185                    infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
    2079                     if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
    2080                                         (NMHDR *)&cbeend, FALSE)) {
     2186                    if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
    20812187                        /* abort the change */
    20822188                        TRACE("Notify requested abort of change\n");
     
    21112217                SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
    21122218                SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
    2113                 COMBOEX_Notify (infoPtr, CBEN_BEGINEDIT, &hdr, FALSE);
     2219                COMBOEX_Notify (infoPtr, CBEN_BEGINEDIT, &hdr);
    21142220                infoPtr->flags |= WCBE_ACTEDIT;
    21152221                infoPtr->flags &= ~WCBE_EDITCHG; /* no change yet */
     
    22092315COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    22102316{
     2317    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     2318
    22112319    TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
    22122320
     
    23192427
    23202428        case WM_NOTIFY:
    2321             return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
     2429            if (infoPtr->NtfUnicode)
     2430                return SendMessageW (GetParent (hwnd),
     2431                                     uMsg, wParam, lParam);
     2432            else
     2433                return SendMessageA (GetParent (hwnd),
     2434                                     uMsg, wParam, lParam);
    23222435
    23232436
     
    23342447        case WM_MEASUREITEM:
    23352448            return COMBOEX_MeasureItem (hwnd, wParam, lParam);
     2449
     2450        case WM_NOTIFYFORMAT:
     2451            return COMBOEX_NotifyFormat (hwnd, wParam, lParam);
    23362452
    23372453        case WM_SIZE:
  • trunk/src/comctl32/comctl32.def

    r6375 r6380  
    1 ; $Id: comctl32.def,v 1.23 2001-07-20 15:35:30 sandervl Exp $
     1; $Id: comctl32.def,v 1.24 2001-07-21 09:07:16 sandervl Exp $
    22LIBRARY COMCTL32 INITINSTANCE
    33DESCRIPTION 'Odin32 System DLL - ComCtl32 - Common Controls Library'
     
    125125  DSA_DeleteItem      = _DSA_DeleteItem@8          @326
    126126  DSA_DeleteAllItems  = _DSA_DeleteAllItems@4      @327
    127 
    128127  DPA_Create          = _DPA_Create@4              @328
    129128  DPA_Destroy         = _DPA_Destroy@4             @329
     
    144143
    145144  StrChrA             = _COMCTL32_StrChrA@8        @350
     145  StrRChrA            = _COMCTL32_StrRChrA@12      @351
     146  StrCmpNA            = _COMCTL32_StrCmpNA@12      @352
     147  StrCmpNIA           = _COMCTL32_StrCmpNIA@12     @353
     148  StrStrA             = _COMCTL32_StrStrA@8        @354
    146149  StrStrIA            = _COMCTL32_StrStrIA@8       @355
     150  StrCSpnA            = _COMCTL32_StrCSpnA@8       @356
     151  StrChrW             = _COMCTL32_StrChrW@8        @358
    147152  StrToIntA           = _COMCTL32_StrToIntA@4      @357
    148 
    149   COMCTL32_StrCmpNIW  = _COMCTL32_StrCmpNIW@12     @361
     153  StrRChrW            = _COMCTL32_StrRChrW@12      @359
     154  StrCmpNW            = _COMCTL32_StrCmpNW@12      @360
     155  StrCmpNIW           = _COMCTL32_StrCmpNIW@12     @361
     156  StrStrW             = _COMCTL32_StrStrW@8        @362
     157;StrStrIW @363
     158  StrSpnW             = _COMCTL32_StrSpnW@8        @364
     159  StrToIntW           = _COMCTL32_StrToIntW@4      @365
     160;366 stub StrChrIA
     161;367 stub StrChrIW
     162;368 stub StrRChrIA
     163;369 stub StrRChrIW
     164;372 stub StrRStrIA
     165;373 stub StrRStrIW
     166;374 stub StrCSpnIA
     167;375 stub StrCSpnIW
     168;376 stub IntlStrEqWorkerA@16
     169;377 stub IntlStrEqWorkerW@16
    150170
    151171  SmoothScrollWindow  = _SmoothScrollWindow@4      @382
     172;383 stub DoReaderMode@4
     173;384 stub SetPathWordBreakProc@8
    152174
    153175  DPA_EnumCallback    = _DPA_EnumCallback@12       @385
     
    158180                        _COMCTL32_390@16           @390 NONAME
    159181
    160   StrCSpnA            = _COMCTL32_StrCSpnA@8       @356
    161   StrChrW             = _COMCTL32_StrChrW@8        @358
    162   StrCmpNA            = _COMCTL32_StrCmpNA@12      @352
    163   StrCmpNIA           = _COMCTL32_StrCmpNIA@12     @353
    164   StrCmpNW            = _COMCTL32_StrCmpNW@12      @360
    165   StrRChrA            = _COMCTL32_StrRChrA@12      @351
    166   StrRChrW            = _COMCTL32_StrRChrW@12      @359
    167   StrStrA             = _COMCTL32_StrStrA@8        @354
    168   StrStrW             = _COMCTL32_StrStrW@8        @362
    169   StrSpnW             = _COMCTL32_StrSpnW@8        @364
     182;400 stub CreateMRUListW@4
     183;401 stub AddMRUStringW@8
     184;402 stub FindMRUStringW@12
     185;403 stub EnumMRUListW@16
     186;404 stub CreateMRUListLazyW@16
    170187
    171                         _comctl32_410@16           @410 NONAME
    172                         _comctl32_411@12           @411 NONAME
    173                         _comctl32_412@12           @412 NONAME
    174                         _comctl32_413@16           @413 NONAME
     188                        _COMCTL32_410@16           @410 NONAME
     189                        _COMCTL32_411@12           @411 NONAME
     190                        _COMCTL32_412@12           @412 NONAME
     191                        _COMCTL32_413@16           @413 NONAME
    175192                        _COMCTL32_415@20           @415 NONAME
  • trunk/src/comctl32/makefile

    r6375 r6380  
    1 # $Id: makefile,v 1.33 2001-07-20 15:35:30 sandervl Exp $
     1# $Id: makefile,v 1.34 2001-07-21 09:07:17 sandervl Exp $
    22
    33#
     
    5555LIBS = \
    5656$(ODIN32_LIB)/kernel32.lib \
     57$(ODIN32_LIB)/ntdll.lib \
    5758$(ODIN32_LIB)/gdi32.lib \
    5859$(ODIN32_LIB)/user32.lib \
  • trunk/src/comctl32/pager.c

    r5416 r6380  
    4343    INT    TLbtnState; /* state of top or left btn */
    4444    INT    BRbtnState; /* state of bottom or right btn */
    45 
     45    INT    direction;  /* direction of the scroll, (e.g. PGF_SCROLLUP) */
    4646} PAGER_INFO;
    4747
     
    5252#define MIN_ARROW_HEIGHT 5
    5353
     54#define TIMERID1         1
     55#define TIMERID2         2
     56#define INITIAL_DELAY    500
     57#define REPEAT_DELAY     50
    5458
    5559/* the horizontal arrows are:
     
    170174    if (btnState == PGF_HOT)
    171175    {
    172        rc.left++, rc.top++; rc.right++, rc.bottom++;
    173        DrawEdge( hdc, &rc, EDGE_RAISED, BF_RECT);
     176       DrawEdge( hdc, &rc, BDR_RAISEDINNER, BF_RECT);
    174177       if (horz)
    175178           PAGER_DrawHorzArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
    176179       else
    177180           PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
    178        rc.left--, rc.top--; rc.right--, rc.bottom--;
    179181    }
    180182    else if (btnState == PGF_NORMAL)
     
    188190    else if (btnState == PGF_DEPRESSED)
    189191    {
    190        rc.left++, rc.top++;
    191192       DrawEdge( hdc, &rc, BDR_SUNKENOUTER, BF_RECT);
    192193       if (horz)
     
    194195       else
    195196           PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
    196        rc.left--, rc.top--;
    197197    }
    198198    else if (btnState == PGF_GRAYED)
     
    211211           PAGER_DrawVertArrow(hdc, rc, COLOR_3DSHADOW, topLeft);
    212212       }
    213        rc.left--, rc.top--; rc.right--, rc.bottom--;
    214213    }
    215214
     
    478477    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    479478    INT scrollRange = PAGER_GetScrollRange(hwnd, infoPtr);
     479    INT oldPos = infoPtr->nPos;
    480480
    481481    if ((scrollRange <= 0) || (newPos < 0))
     
    488488    TRACE("[%04x] pos=%d\n", hwnd, infoPtr->nPos);
    489489
    490     /* gray and restore btns, and if from WM_SETPOS, hide the gray btns */
    491     PAGER_UpdateBtns(hwnd, infoPtr, scrollRange, !fromBtnPress);
    492     PAGER_PositionChildWnd(hwnd, infoPtr);
     490    if (infoPtr->nPos != oldPos)
     491    {
     492        /* gray and restore btns, and if from WM_SETPOS, hide the gray btns */
     493        PAGER_UpdateBtns(hwnd, infoPtr, scrollRange, !fromBtnPress);
     494        PAGER_PositionChildWnd(hwnd, infoPtr);
     495    }
    493496
    494497    return 0;
     
    567570        delta = wndRect.bottom - wndRect.top - infoPtr->nHeight;
    568571        if (delta > infoPtr->nButtonSize)
    569             infoPtr->nHeight += 4 * infoPtr->nButtonSize / 3;
     572            infoPtr->nHeight += infoPtr->nButtonSize;
    570573        else if (delta > 0)
    571574            infoPtr->nHeight +=  infoPtr->nButtonSize / 3;
     
    594597
    595598        if (scrollRange <= 0)
     599        {
     600            infoPtr->nPos = -1;
    596601            PAGER_SetPos(hwnd, 0, FALSE);
     602        }
    597603        else
    598604        {
     
    673679                     SWP_SHOWWINDOW | SWP_NOSIZE);
    674680
     681        infoPtr->nPos = -1;
    675682        PAGER_SetPos(hwnd, 0, FALSE);
    676683    }
     
    717724        if (nmpgScroll.iScroll > 0)
    718725        {
     726            infoPtr->direction = dir;
     727
    719728            if (dir == PGF_SCROLLLEFT || dir == PGF_SCROLLUP)
    720729                PAGER_SetPos(hwnd, infoPtr->nPos - nmpgScroll.iScroll, TRUE);
     
    722731                PAGER_SetPos(hwnd, infoPtr->nPos + nmpgScroll.iScroll, TRUE);
    723732        }
     733        else
     734            infoPtr->direction = -1;
    724735    }
    725736}
     
    751762    infoPtr->TLbtnState = PGF_INVISIBLE;
    752763    infoPtr->BRbtnState = PGF_INVISIBLE;
     764    infoPtr->direction = -1;
    753765
    754766    if (dwStyle & PGS_AUTOSCROLL)
     
    981993    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    982994
     995    KillTimer (hwnd, TIMERID1);
     996    KillTimer (hwnd, TIMERID2);
     997
    983998    TRACE("[%04x] ReleaseCapture\n", hwnd);
    984999    ReleaseCapture();
     
    10181033        repaintBtns = infoPtr->TLbtnState != PGF_DEPRESSED;
    10191034        infoPtr->TLbtnState = PGF_DEPRESSED;
     1035        SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0);
    10201036    }
    10211037    else if (hit == HTRIGHT || hit == HTBOTTOM)
     
    10231039        repaintBtns = infoPtr->BRbtnState != PGF_DEPRESSED;
    10241040        infoPtr->BRbtnState = PGF_DEPRESSED;
     1041        SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0);
    10251042    }
    10261043
     
    10591076    TRACE("[%04x]\n", hwnd);
    10601077
     1078    KillTimer (hwnd, TIMERID1);
     1079    KillTimer (hwnd, TIMERID2);
     1080
    10611081    /* make PRESSED btns NORMAL but don't hide gray btns */
    10621082    PAGER_UpdateBtns(hwnd, infoPtr, -1, FALSE);
     
    12011221            return PAGER_Paint (hwnd, wParam);
    12021222*/
     1223        case WM_TIMER:
     1224            /* if initial timer, kill it and start the repeat timer */
     1225            if (wParam == TIMERID1)
     1226            {
     1227                KillTimer(hwnd, TIMERID1);
     1228                SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0);
     1229            }
     1230
     1231            KillTimer(hwnd, TIMERID2);
     1232            if (infoPtr->direction > 0)
     1233            {
     1234                PAGER_Scroll(hwnd, infoPtr->direction);
     1235                SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0);         
     1236            }
     1237            break;
     1238
    12031239        case WM_NOTIFY:
    12041240        case WM_COMMAND:
     
    12091245            return defComCtl32ProcA(hwnd, uMsg, wParam, lParam);
    12101246#else
    1211             return DefWindowProcA(hwnd, uMsg, wParam, lParam);
     1247            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    12121248#endif
    12131249    }
  • trunk/src/comctl32/rebar.c

    r5630 r6380  
    11/*
    2  * Rebar control    rev 6e
     2 *
     3 * 2.  At "FIXME:  problem # 2" WinRAR:
     4 *   if "#if 1" then last band draws in separate row
     5 *   if "#if 0" then last band draws in previous row *** just like native ***
     6 *
     7 */
     8#define PROBLEM2 0
     9
     10/*
     11 * Rebar control    rev 7f
    312 *
    413 * Copyright 1998, 1999 Eric Kohl
     
    2837 *     RBS_BANDBORDERS.
    2938 *  rev 6
    30  *  1. Make drawing of rebar attempt to match pixel by pixel with MS. (6a)
    31  *  2. Fix interlock between REBAR_ForceResize and REBAR_Size (AUTO_RESIZE flag) (6a)
    32  *  3. Fix up some of the notifications (RBN_HEIGHTCHANGE). (6a)
    33  *  4. Fix up DeleteBand by hiding child window. (6a)
    34  *  5. Change how band borders are drawn and rects are invalidated. (6b)
    35  *  6. Fix height of bar with only caption text. (6b)
    36  *  7. RBBS_NOGRIPPER trumps RBBS_GRIPPERALWAYS (gripper hidden), but
    37  *     RBBS_GRIPPERALWAYS trumps RBBS_FIXEDSIZE (gripper displays). (6b)
    38  *  8. New algorithim for AdjustBand:
    39  *      For all bands in a row: bands left to right are sized to their "cx"
    40  *      size (if space available). Also use max of (cxHeader+cxMinChild) and
    41  *      cx. (6c)
    42  *  9. New alogrithim for Layout:
    43  *      Insert band in row if cxHeader space is available. If adjustment
    44  *      rect exists, then back out bands in row from last to second into
    45  *      separate rows till "y" adjustment rect equalled or exceeded. (6c)
    46  * 10. Implement vertical drag. (6c)
    47  * 11. Use DeferWindowPos to set child window position. (6c)
    48  * 12. Fixup RBN_CHILDSIZE notify. The rcBand rectangle should start
    49  *     after the header. (6d)
    50  * 13. Flags for DeferWindowPos seem to always be SWP_NOZORDER in the
    51  *     traces. (6d)
    52  * 14. Make handling of ComboBox and ComboBoxEx the same in
    53  *     _MoveChildWindow. (6d)
    54  * 15. Changes in phase 2 of _Layout for WinRAR example. (6e)
    55  * 16. Do notify change size of children for WM_SIZE message. (6e)
    56  * 17. Re-validate first band when second is added (for gripper add). (6e)
     39 *   - Fix or implement notifications for RBN_HEIGHTCHANGE, RBN_CHILDSIZE.
     40 *   - Correct styles RBBS_NOGRIPPER, RBBS_GRIPPERALWAYS, and RBBS_FIXEDSIZE.
     41 *   - Fix algorithm for Layout and AdjustBand.
    5742 *
     43 * rev 7
     44 *  1. Redesign _Layout to better emulate native.
     45 *     a. Flag rebar when a band needs to be (and all bands) need to
     46 *        go through rest of _Layout
     47 *  2. Fix RBN_ENDDRAG contents.
     48 *  3. REBAR_ForceResize changed to handle shrink of client.
     49 * rev 7b
     50 *  4. Support RBBS_HIDDEN in _Layout (phase 2 & 3), _InternalEraseBkgnd,
     51 *     and _InternalHitTest
     52 *  5. Support RBS_VARHEIGHT.
     53 *  6. Rewrite _AdjustBands with new algorithm.
     54 * rev 7c
     55 *  7. Format mask and style with labels.
     56 *  8. Move calls to _ForceResize and _MoveChildWindows into _Layout to
     57 *     centralize processing.
     58 *  9. Pass "infoPtr" to all routines instead of "hwnd" to eliminate extra
     59 *     calls to GetWindowLongA.
     60 * 10. Use _MoveChildWindows in _HandleLRDrag.
     61 * 11. Another rewrite of _AdjustBands with new algorithm.
     62 * 12. Correct drawing of rebar borders and handling of RBS_BORDERS.
     63 * rev 7d
     64 * 13. Support WM_NOTIFYFORMAT (both incoming and outgoing) and do
     65 *     WM_NOTIFY correctly based on results.
     66 * 14. Implement WM_SETREDRAW.
     67 * 15. Native WM_ERASEBKGND draws horz and vert separators between bands and
     68 *     rows, and fills in the background color for each band. The gripper,
     69 *     image, and text for each band is drawn by the WM_PAINT process. Change
     70 *     this code to match.
     71 * rev 7e
     72 * 16. RBBS_FIXEDSIZE should not affect _AdjustBands. (Found by Mike McCormack
     73 *     in WinZip - Thanks!)
     74 * 17. Implement WM_NCCREATE to set necessary additional styles and move most
     75 *     of creation stuff to it like native control.
     76 * 18. WM_SETFONT should redraw only if LOWORD is TRUE.
     77 * 19. Implement WM_NCHITTEST to send notify to parent of NM_NCHITTEST.
     78 * 20. Cleaned up dead and/or testing code.
     79 * 21. Support RB_MOVEBAND.
     80 * 22. Support WM_STYLECHANGED and remove all (or most) of the GetWindowLong
     81 *     for GWL_STYLE.
     82 * 23. Support RB_MINIMIZEBAND.
     83 * 24. RBBS_HIDDEN (and the CCS_VERT+RBBS_NOVERT case) should be supported
     84 *     by all routines now.
     85 * rev 7f
     86 * 25. Fix handling of text color.
     87 * 26. Correct implementation of WM_SETREDRAW to be closer to native.
     88 *     See REBAR_SetRedraw for doc changes of actual vs. MSDN
     89 * 27. Do more implementation of RBS_AUTOSIZE in the WM_SIZE processor.
     90 * 28. Implement RBBS_VARIABLEHEIGHT. Used by IE4.
     91 * 29. Do more testing in WM_SIZE to handle strange cases like native.
    5892 *
    5993 *
    6094 *    Still to do:
    61  *  1. default row height should be the max height of all visible bands
    6295 *  2. Following still not handled: RBBS_FIXEDBMP, RBBS_CHILDEDGE,
    6396 *            RBBS_USECHEVRON
    64  *  3. RBS_VARHEIGHT is assumed to always be on.
    65  *  4. RBBS_HIDDEN (and the CCS_VERT + RBBS_NOVERT case) is not really
    66  *     supported by the following functions:
    67  *      _Layout (phase 2), _InternalEraseBkgnd, _InternalHitTest,
    68  *      _HandleLRDrag
    69  *  5. _HandleLRDrag does not properly position ComboBox or ComboBoxEx
    70  *     children. (See code in _MoveChildWindow.)
    71 
     97 *  3. Following are only partially handled:
     98 *            RBS_AUTOSIZE, RBBS_VARIABLEHEIGHT
     99 *  5. Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
     100 *     to set the size of the separator width (the value SEP_WIDTH_SIZE
     101 *     in here). Should be fixed!!
     102 *  6. The following messages are not implemented:
     103 *        RB_BEGINDRAG, RB_DRAGMOVE, RB_ENDDRAG, RB_GETCOLORSCHEME,
     104 *        RB_GETDROPTARGET, RB_MAXIMIZEBAND,
     105 *        RB_SETCOLORSCHEME, RB_SETPALETTE, RB_SETTOOLTIPS
     106 *        WM_CHARTOITEM, WM_LBUTTONDBLCLK, WM_MEASUREITEM,
     107 *        WM_PALETTECHANGED, WM_PRINTCLIENT, WM_QUERYNEWPALETTE,
     108 *        WM_RBUTTONDOWN, WM_RBUTTONUP,
     109 *        WM_SYSCOLORCHANGE, WM_VKEYTOITEM, WM_WININICHANGE
     110 *  7. The following notifications are not implemented:
     111 *        NM_CUSTOMDRAW, NM_RELEASEDCAPTURE
     112 *        RB_CHEVRONPUSHED, RBN_MINMAX
    72113 */
    73114
     
    75116#include <string.h>
    76117
     118#include "win.h"
    77119#include "winbase.h"
    78120#include "wingdi.h"
    79121#include "wine/unicode.h"
    80122#include "commctrl.h"
     123/* #include "spy.h" */
    81124#include "debugtools.h"
     125
    82126#ifdef __WIN32OS2__
     127#include <winuser.h>
    83128#include "ccbase.h"
    84129#endif
     
    88133typedef struct
    89134{
     135#ifdef __WIN32OS2__
     136    COMCTL32_HEADER header;
     137#endif
    90138    UINT    fStyle;
    91139    UINT    fMask;
     
    94142    INT     iImage;
    95143    HWND    hwndChild;
    96     UINT    cxMinChild;
    97     UINT    cyMinChild;
    98     UINT    cx;
     144    UINT    cxMinChild;     /* valid if _CHILDSIZE */
     145    UINT    cyMinChild;     /* valid if _CHILDSIZE */
     146    UINT    cx;             /* valid if _SIZE */
    99147    HBITMAP hbmBack;
    100148    UINT    wID;
    101     UINT    cyChild;
    102     UINT    cyMaxChild;
    103     UINT    cyIntegral;
     149    UINT    cyChild;        /* valid if _CHILDSIZE */
     150    UINT    cyMaxChild;     /* valid if _CHILDSIZE */
     151    UINT    cyIntegral;     /* valid if _CHILDSIZE */
    104152    UINT    cxIdeal;
    105153    LPARAM    lParam;
     
    107155
    108156    UINT    lcx;            /* minimum cx for band */
     157    UINT    ccx;            /* current cx for band */
    109158    UINT    hcx;            /* maximum cx for band */
    110159    UINT    lcy;            /* minimum cy for band */
     160    UINT    ccy;            /* current cy for band */
    111161    UINT    hcy;            /* maximum cy for band */
    112162
     
    116166    UINT    fStatus;        /* status flags, reset only by _Validate */
    117167    UINT    fDraw;          /* drawing flags, reset only by _Layout */
     168    RECT    rcoldBand;      /* previous calculated band rectangle */
    118169    RECT    rcBand;         /* calculated band rectangle */
    119170    RECT    rcGripper;      /* calculated gripper rectangle */
     
    137188#define DRAW_RIGHTSEP   0x00000010
    138189#define DRAW_BOTTOMSEP  0x00000020
    139 #define DRAW_SEPBOTH    (DRAW_RIGHTSEP | DRAW_BOTTOMSEP)
    140190#define NTF_INVALIDATE  0x01000000
    141 #define NTF_CHILDSIZE   0x02000000
    142191
    143192
    144193typedef struct
    145194{
    146 #ifdef __WIN32OS2__
    147     COMCTL32_HEADER header;
    148 #endif
    149195    COLORREF   clrBk;       /* background color */
    150196    COLORREF   clrText;     /* text color */
     197    COLORREF   clrBtnText;  /* system color for BTNTEXT */
     198    COLORREF   clrBtnFace;  /* system color for BTNFACE */
    151199    HIMAGELIST himl;        /* handle to imagelist */
    152     UINT     uNumBands;   /* number of bands in the rebar */
    153     UINT     uNumRows;    /* number of rows of bands */
     200    UINT     uNumBands;   /* # of bands in rebar (first=0, last=uNumRows-1 */
     201    UINT     uNumRows;    /* # of rows of bands (first=1, last=uNumRows */
     202    HWND     hwndSelf;    /* handle of REBAR window itself */
    154203    HWND     hwndToolTip; /* handle to the tool tip control */
    155204    HWND     hwndNotify;  /* notification window (parent) */
    156205    HFONT    hFont;       /* handle to the rebar's font */
    157206    SIZE     imageSize;   /* image size (image list) */
    158 
     207    DWORD    dwStyle;     /* window style */
    159208    SIZE     calcSize;    /* calculated rebar size */
    160209    SIZE     oldSize;     /* previous calculated rebar size */
    161     BOOL     bUnicode;    /* Unicode flag */
     210    BOOL     bUnicode;    /* TRUE if this window is W type */
     211    BOOL     NtfUnicode;  /* TRUE if parent wants notify in W format */
     212    BOOL     DoRedraw;    /* TRUE to acutally draw bands */
    162213    UINT     fStatus;     /* Status flags (see below)  */
    163214    HCURSOR  hcurArrow;   /* handle to the arrow cursor */
     
    175226
    176227/* fStatus flags */
    177 #define BEGIN_DRAG_ISSUED   1
    178 #define AUTO_RESIZE         2
    179 #define RESIZE_ANYHOW       4
    180 #define NTF_HGHTCHG         8
     228#define BEGIN_DRAG_ISSUED   0x00000001
     229#define AUTO_RESIZE         0x00000002
     230#define RESIZE_ANYHOW       0x00000004
     231#define NTF_HGHTCHG         0x00000008
     232#define BAND_NEEDS_LAYOUT   0x00000010
     233#define BAND_NEEDS_REDRAW   0x00000020
     234#define CREATE_RUNNING      0x00000040
    181235
    182236/* ----   REBAR layout constants. Mostly determined by        ---- */
     
    186240/* vert.). True only if RBS_BANDBORDERS is set                     */
    187241#define SEP_WIDTH_SIZE  2
    188 #define SEP_WIDTH       ((dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
     242#define SEP_WIDTH       ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
    189243
    190244/* Blank (background color) space between Gripper (if present)     */
     
    215269
    216270
    217 /*  The following 4 defines return the proper rcBand element       */
     271/*  The following 6 defines return the proper rcBand element       */
    218272/*  depending on whether CCS_VERT was set.                         */
    219 #define rcBlt(b) ((dwStyle & CCS_VERT) ? b->rcBand.top : b->rcBand.left)
    220 #define rcBrb(b) ((dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right)
    221 #define ircBlt(b) ((dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top)
    222 #define ircBrb(b) ((dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom)
     273#define rcBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.top : b->rcBand.left)
     274#define rcBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right)
     275#define rcBw(b)  ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.bottom - b->rcBand.top) : \
     276                  (b->rcBand.right - b->rcBand.left))
     277#define ircBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top)
     278#define ircBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom)
     279#define ircBw(b)  ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.right - b->rcBand.left) : \
     280                  (b->rcBand.bottom - b->rcBand.top))
    223281
    224282/*  The following define determines if a given band is hidden      */
    225283#define HIDDENBAND(a)  (((a)->fStyle & RBBS_HIDDEN) ||   \
    226                         ((dwStyle & CCS_VERT) &&         \
     284                        ((infoPtr->dwStyle & CCS_VERT) &&         \
    227285                         ((a)->fStyle & RBBS_NOVERT)))
     286
     287/*  The following defines adjust the right or left end of a rectangle */
     288#define READJ(b,i) {if(infoPtr->dwStyle & CCS_VERT) b->rcBand.bottom+=(i); \
     289                    else b->rcBand.right += (i);}
     290#define LEADJ(b,i) {if(infoPtr->dwStyle & CCS_VERT) b->rcBand.top+=(i); \
     291                    else b->rcBand.left += (i);}
    228292
    229293
     
    236300static UINT mindragy = 0;
    237301
     302static char *band_stylename[] = {
     303    "RBBS_BREAK",              /* 0001 */
     304    "RBBS_FIXEDSIZE",          /* 0002 */
     305    "RBBS_CHILDEDGE",          /* 0004 */
     306    "RBBS_HIDDEN",             /* 0008 */
     307    "RBBS_NOVERT",             /* 0010 */
     308    "RBBS_FIXEDBMP",           /* 0020 */
     309    "RBBS_VARIABLEHEIGHT",     /* 0040 */
     310    "RBBS_GRIPPERALWAYS",      /* 0080 */
     311    "RBBS_NOGRIPPER",          /* 0100 */
     312    NULL };
     313
     314static char *band_maskname[] = {
     315    "RBBIM_STYLE",         /*    0x00000001 */
     316    "RBBIM_COLORS",        /*    0x00000002 */
     317    "RBBIM_TEXT",          /*    0x00000004 */
     318    "RBBIM_IMAGE",         /*    0x00000008 */
     319    "RBBIM_CHILD",         /*    0x00000010 */
     320    "RBBIM_CHILDSIZE",     /*    0x00000020 */
     321    "RBBIM_SIZE",          /*    0x00000040 */
     322    "RBBIM_BACKGROUND",    /*    0x00000080 */
     323    "RBBIM_ID",            /*    0x00000100 */
     324    "RBBIM_IDEALSIZE",     /*    0x00000200 */
     325    "RBBIM_LPARAM",        /*    0x00000400 */
     326    "RBBIM_HEADERSIZE",    /*    0x00000800 */
     327    NULL };
     328
     329
     330static CHAR line[200];
     331
     332
     333static CHAR *
     334REBAR_FmtStyle( UINT style)
     335{
     336    INT i = 0;
     337
     338    *line = 0;
     339    while (band_stylename[i]) {
     340        if (style & (1<<i)) {
     341            if (*line != 0) strcat(line, " | ");
     342            strcat(line, band_stylename[i]);
     343        }
     344        i++;
     345    }
     346    return line;
     347}
     348
     349
     350static CHAR *
     351REBAR_FmtMask( UINT mask)
     352{
     353    INT i = 0;
     354
     355    *line = 0;
     356    while (band_maskname[i]) {
     357        if (mask & (1<<i)) {
     358            if (*line != 0) strcat(line, " | ");
     359            strcat(line, band_maskname[i]);
     360        }
     361        i++;
     362    }
     363    return line;
     364}
     365
    238366
    239367static VOID
    240368REBAR_DumpBandInfo( LPREBARBANDINFOA pB)
    241369{
    242         TRACE("band info: ID=%u, size=%u, style=0x%08x, mask=0x%08x, child=%04x\n",
    243           pB->wID, pB->cbSize, pB->fStyle, pB->fMask, pB->hwndChild);
    244         TRACE("band info: cx=%u, xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
    245           pB->cx, pB->cxMinChild,
    246           pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
    247         TRACE("band info: xIdeal=%u, xHeader=%u, lParam=0x%08lx, clrF=0x%06lx, clrB=0x%06lx\n",
    248           pB->cxIdeal, pB->cxHeader, pB->lParam, pB->clrFore, pB->clrBack);
     370    if( !TRACE_ON(rebar) ) return;
     371    TRACE("band info: ID=%u, size=%u, child=%04x, clrF=0x%06lx, clrB=0x%06lx\n",
     372          pB->wID, pB->cbSize, pB->hwndChild, pB->clrFore, pB->clrBack);
     373    TRACE("band info: mask=0x%08x (%s)\n", pB->fMask, REBAR_FmtMask(pB->fMask));
     374    if (pB->fMask & RBBIM_STYLE)
     375        TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle));
     376    if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_HEADERSIZE | RBBIM_LPARAM )) {
     377        TRACE("band info:");
     378        if (pB->fMask & RBBIM_SIZE)
     379            DPRINTF(" cx=%u", pB->cx);
     380        if (pB->fMask & RBBIM_IDEALSIZE)
     381            DPRINTF(" xIdeal=%u", pB->cxIdeal);
     382        if (pB->fMask & RBBIM_HEADERSIZE)
     383            DPRINTF(" xHeader=%u", pB->cxHeader);
     384        if (pB->fMask & RBBIM_LPARAM)
     385            DPRINTF(" lParam=0x%08lx", pB->lParam);
     386        DPRINTF("\n");
     387    }
     388    if (pB->fMask & RBBIM_CHILDSIZE)
     389        TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
     390              pB->cxMinChild,
     391              pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
    249392}
    250393
    251394static VOID
    252 REBAR_DumpBand (HWND hwnd)
    253 {
    254     REBAR_INFO *iP = REBAR_GetInfoPtr (hwnd);
     395REBAR_DumpBand (REBAR_INFO *iP)
     396{
    255397    REBAR_BAND *pB;
    256398    UINT i;
    257399
    258     if( TRACE_ON(rebar) ) {
    259 
    260       TRACE("hwnd=%04x: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
    261         hwnd, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
    262         iP->calcSize.cx, iP->calcSize.cy);
    263       TRACE("hwnd=%04x: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, ihitBand=%d\n",
    264             hwnd, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
    265             iP->dragNow.x, iP->dragNow.y,
    266             iP->ihitBand);
    267       for (i = 0; i < iP->uNumBands; i++) {
     400    if(! TRACE_ON(rebar) ) return;
     401
     402    TRACE("hwnd=%04x: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
     403          iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
     404          iP->calcSize.cx, iP->calcSize.cy);
     405    TRACE("hwnd=%04x: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, ihitBand=%d\n",
     406          iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
     407          iP->dragNow.x, iP->dragNow.y,
     408          iP->ihitBand);
     409    TRACE("hwnd=%04x: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n",
     410          iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE",
     411          (iP->NtfUnicode)?"TRUE":"FALSE", (iP->DoRedraw)?"TRUE":"FALSE");
     412    for (i = 0; i < iP->uNumBands; i++) {
    268413        pB = &iP->bands[i];
    269         TRACE("band # %u: ID=%u, mask=0x%08x, style=0x%08x, child=%04x, row=%u\n",
    270           i, pB->wID, pB->fMask, pB->fStyle, pB->hwndChild, pB->iRow);
    271         TRACE("band # %u: xMin=%u, yMin=%u, cx=%u, yChild=%u, yMax=%u, yIntgl=%u, uMinH=%u,\n",
    272           i, pB->cxMinChild, pB->cyMinChild, pB->cx,
    273           pB->cyChild, pB->cyMaxChild, pB->cyIntegral, pB->uMinHeight);
    274         TRACE("band # %u: header=%u, lcx=%u, hcx=%u, lcy=%u, hcy=%u, offChild=%ld,%ld\n",
    275           i, pB->cxHeader, pB->lcx, pB->hcx, pB->lcy, pB->hcy, pB->offChild.cx, pB->offChild.cy);
     414        TRACE("band # %u: ID=%u, child=%04x, row=%u, clrF=0x%06lx, clrB=0x%06lx\n",
     415              i, pB->wID, pB->hwndChild, pB->iRow, pB->clrFore, pB->clrBack);
     416        TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask));
     417        if (pB->fMask & RBBIM_STYLE)
     418            TRACE("band # %u: style=0x%08x (%s)\n",
     419                  i, pB->fStyle, REBAR_FmtStyle(pB->fStyle));
     420        TRACE("band # %u: uMinH=%u xHeader=%u",
     421              i, pB->uMinHeight, pB->cxHeader);
     422        if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) {
     423            if (pB->fMask & RBBIM_SIZE)
     424                DPRINTF(" cx=%u", pB->cx);
     425            if (pB->fMask & RBBIM_IDEALSIZE)
     426                DPRINTF(" xIdeal=%u", pB->cxIdeal);
     427            if (pB->fMask & RBBIM_LPARAM)
     428                DPRINTF(" lParam=0x%08lx", pB->lParam);
     429        }
     430        DPRINTF("\n");
     431        if (RBBIM_CHILDSIZE)
     432            TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
     433                  i, pB->cxMinChild, pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
     434        TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n",
     435              i, pB->lcx, pB->ccx, pB->hcx, pB->lcy, pB->ccy, pB->hcy, pB->offChild.cx, pB->offChild.cy);
    276436        TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%d,%d)-(%d,%d), Grip=(%d,%d)-(%d,%d)\n",
    277           i, pB->fStatus, pB->fDraw,
    278           pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom,
    279           pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom);
     437              i, pB->fStatus, pB->fDraw,
     438              pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom,
     439              pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom);
    280440        TRACE("band # %u: Img=(%d,%d)-(%d,%d), Txt=(%d,%d)-(%d,%d), Child=(%d,%d)-(%d,%d)\n",
    281           i,
    282           pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom,
    283           pB->rcCapText.left, pB->rcCapText.top, pB->rcCapText.right, pB->rcCapText.bottom,
    284           pB->rcChild.left, pB->rcChild.top, pB->rcChild.right, pB->rcChild.bottom);
    285       }
    286 
    287     }
    288 }
    289 
    290 static INT
    291 REBAR_Notify (HWND hwnd, NMHDR *nmhdr, REBAR_INFO *infoPtr, UINT code)
     441              i,
     442              pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom,
     443              pB->rcCapText.left, pB->rcCapText.top, pB->rcCapText.right, pB->rcCapText.bottom,
     444              pB->rcChild.left, pB->rcChild.top, pB->rcChild.right, pB->rcChild.bottom);
     445    }
     446
     447}
     448
     449
     450static HWND
     451REBAR_GetNotifyParent (REBAR_INFO *infoPtr)
    292452{
    293453    HWND parent, owner;
     
    295455    parent = infoPtr->hwndNotify;
    296456    if (!parent) {
    297         parent = GetParent (hwnd);
    298         owner = GetWindow (hwnd, GW_OWNER);
     457        parent = GetParent (infoPtr->hwndSelf);
     458        owner = GetWindow (infoPtr->hwndSelf, GW_OWNER);
    299459        if (owner) parent = owner;
    300460    }
    301     nmhdr->idFrom = GetDlgCtrlID (hwnd);
    302     nmhdr->hwndFrom = hwnd;
     461    return parent;
     462}
     463
     464
     465static INT
     466REBAR_Notify (NMHDR *nmhdr, REBAR_INFO *infoPtr, UINT code)
     467{
     468    HWND parent;
     469
     470    parent = REBAR_GetNotifyParent (infoPtr);
     471    nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
     472    nmhdr->hwndFrom = infoPtr->hwndSelf;
    303473    nmhdr->code = code;
    304474
    305     return SendMessageA (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
    306                          (LPARAM)nmhdr);
     475    TRACE("window %04x, code=%08x, %s\n", parent, code,
     476          (infoPtr->NtfUnicode) ? "via Unicode" : "via ANSI");
     477
     478    if (infoPtr->NtfUnicode)
     479        return SendMessageW (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
     480                             (LPARAM)nmhdr);
     481    else
     482        return SendMessageA (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
     483                             (LPARAM)nmhdr);
    307484}
    308485
    309486static INT
    310 REBAR_Notify_NMREBAR (HWND hwnd, REBAR_INFO *infoPtr, UINT uBand, UINT code)
     487REBAR_Notify_NMREBAR (REBAR_INFO *infoPtr, UINT uBand, UINT code)
    311488{
    312489    NMREBAR notify_rebar;
     
    330507    }
    331508    notify_rebar.uBand = uBand;
    332     return REBAR_Notify (hwnd, (NMHDR *)&notify_rebar, infoPtr, code);
     509    return REBAR_Notify ((NMHDR *)&notify_rebar, infoPtr, code);
    333510}
    334511
    335512static VOID
    336 REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand, DWORD dwStyle)
    337 {
    338 
    339     /* draw separators on both the bottom and right */
    340     if ((lpBand->fDraw & DRAW_SEPBOTH) == DRAW_SEPBOTH) {
    341         RECT rcSep;
    342         SetRect (&rcSep,
    343                  lpBand->rcBand.left,
    344                  lpBand->rcBand.top,
    345                  lpBand->rcBand.right + SEP_WIDTH_SIZE,
    346                  lpBand->rcBand.bottom + SEP_WIDTH_SIZE);
    347         DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOMRIGHT);
    348         TRACE("drawing band separator both (%d,%d)-(%d,%d)\n",
    349               rcSep.left, rcSep.top, rcSep.right, rcSep.bottom);
    350     }
    351 
    352     /* draw band separator between bands in a row */
    353     if ((lpBand->fDraw & DRAW_SEPBOTH) == DRAW_RIGHTSEP) {
    354         RECT rcSep;
    355         if (dwStyle & CCS_VERT) {
    356             SetRect (&rcSep,
    357                      lpBand->rcBand.left,
    358                      lpBand->rcBand.bottom,
    359                      lpBand->rcBand.right,
    360                      lpBand->rcBand.bottom + SEP_WIDTH_SIZE);
    361             DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM);
    362         }
    363         else {
    364             SetRect (&rcSep,
    365                      lpBand->rcBand.right,
    366                      lpBand->rcBand.top,
    367                      lpBand->rcBand.right + SEP_WIDTH_SIZE,
    368                      lpBand->rcBand.bottom);
    369             DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT);
    370         }
    371         TRACE("drawing band separator right (%d,%d)-(%d,%d)\n",
    372               rcSep.left, rcSep.top, rcSep.right, rcSep.bottom);
    373     }
    374 
    375     /* draw band separator between rows */
    376     if ((lpBand->fDraw & DRAW_SEPBOTH) == DRAW_BOTTOMSEP) {
    377         RECT rcRowSep;
    378         if (dwStyle & CCS_VERT) {
    379             SetRect (&rcRowSep,
    380                      lpBand->rcBand.right,
    381                      lpBand->rcBand.top,
    382                      lpBand->rcBand.right + SEP_WIDTH_SIZE,
    383                      lpBand->rcBand.bottom);
    384             DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT);
    385         }
    386         else {
    387             SetRect (&rcRowSep,
    388                      lpBand->rcBand.left,
    389                      lpBand->rcBand.bottom,
    390                      lpBand->rcBand.right,
    391                      lpBand->rcBand.bottom + SEP_WIDTH_SIZE);
    392             DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM);
    393         }
    394         TRACE ("drawing band separator bottom (%d,%d)-(%d,%d)\n",
    395                rcRowSep.left, rcRowSep.top,
    396                rcRowSep.right, rcRowSep.bottom);
    397     }
     513REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
     514{
     515
    398516
    399517    /* draw gripper */
     
    419537        INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
    420538        COLORREF oldcolor = CLR_NONE;
    421         if (lpBand->clrFore != CLR_NONE)
    422             oldcolor = SetTextColor (hdc, lpBand->clrFore);
     539        oldcolor = SetTextColor (hdc, (lpBand->clrFore != CLR_NONE) ?
     540                                 lpBand->clrFore : infoPtr->clrBtnText);
    423541        DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
    424542                   DT_CENTER | DT_VCENTER | DT_SINGLELINE);
    425543        if (oldBkMode != TRANSPARENT)
    426544            SetBkMode (hdc, oldBkMode);
    427         if (lpBand->clrFore != CLR_NONE)
    428             SetTextColor (hdc, oldcolor);
     545        SetTextColor (hdc, oldcolor);
    429546        SelectObject (hdc, hOldFont);
    430547    }
     
    433550
    434551static VOID
    435 REBAR_Refresh (HWND hwnd, HDC hdc)
    436 {
    437     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     552REBAR_Refresh (REBAR_INFO *infoPtr, HDC hdc)
     553{
    438554    REBAR_BAND *lpBand;
    439555    UINT i, oldrow;
    440     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     556
     557    if (!infoPtr->DoRedraw) return;
    441558
    442559    oldrow = infoPtr->bands[0].iRow;
     
    444561        lpBand = &infoPtr->bands[i];
    445562
    446         if ((lpBand->fStyle & RBBS_HIDDEN) ||
    447             ((dwStyle & CCS_VERT) &&
    448              (lpBand->fStyle & RBBS_NOVERT)))
    449             continue;
     563        if (HIDDENBAND(lpBand)) continue;
    450564
    451565        /* now draw the band */
    452         REBAR_DrawBand (hdc, infoPtr, lpBand, dwStyle);
    453 
    454     }
    455 }
     566        REBAR_DrawBand (hdc, infoPtr, lpBand);
     567
     568    }
     569}
     570
    456571
    457572static void
    458 REBAR_AdjustBands (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
    459                    INT maxx, INT usedx, INT mcy, DWORD dwStyle)
    460      /* Function: This routine distributes the extra space in a row */
    461      /*  by increasing bands from left to right to their "cx" width.*/
    462      /*  Uses "cxHeader"+"cxMinChild" if it is bigger than "cx".    */
     573REBAR_FixVert (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
     574                   INT mcy)
     575     /* Function:                                                    */
     576     /*   Cycle through bands in row and fix height of each band.    */
     577     /*   Also determine whether each band has changed.              */
     578     /* On entry:                                                    */
     579     /*   all bands at desired size.                                 */
     580     /*   start and end bands are *not* hidden                       */
    463581{
    464582    REBAR_BAND *lpBand;
    465     UINT i;
    466     INT j, k;
    467     INT incr, current_width, lastx=0;
    468     RECT oldband;
    469 
    470     TRACE("start=%u, end=%u, max x=%d, used x=%d, max y=%d\n",
    471           rowstart, rowend-1, maxx, usedx, mcy);
    472 
    473     incr = maxx - usedx;
    474 
    475     for (i = rowstart; i<rowend; i++) {
     583    INT i;
     584
     585    for (i = (INT)rowstart; i<=(INT)rowend; i++) {
    476586        lpBand = &infoPtr->bands[i];
    477587        if (HIDDENBAND(lpBand)) continue;
    478         j = 0;
    479         k = 0;
    480         oldband = lpBand->rcBand;
    481 
    482         /* get the current width of the band */
    483         if (dwStyle & CCS_VERT)
    484             current_width = lpBand->rcBand.bottom - lpBand->rcBand.top;
    485         else
    486             current_width = lpBand->rcBand.right - lpBand->rcBand.left;
    487 
    488         /* compute (in "j") the adjustment for this band */
    489         /* FIXME ??? should this not use "cx" and "cxHeader" and "cxMinChild" */
    490         if (!(lpBand->fStyle & RBBS_FIXEDSIZE)) {
    491             if ((lpBand->fMask & RBBIM_SIZE) && (lpBand->cx > 0))
    492                 j = min(lpBand->cx - current_width, incr);
    493             if ((lpBand->fMask & RBBIM_CHILDSIZE) &&
    494                 (lpBand->cxMinChild > 0) &&
    495                 (lpBand->fMask & RBBIM_CHILD) &&
    496                 (lpBand->hwndChild)) {
    497                 k = lpBand->cxHeader + lpBand->cxMinChild - current_width;
    498                 if (k > 0) {
    499                     j = max(k, j);
    500                     j = min(j, incr);
    501                 }
    502             }
    503         }
    504 
    505         incr -= j;
    506 
    507         /* validate values */
    508         if (incr < 0) {
    509             ERR("failed, incr=%d, current_width=%d, j=%d, k=%d\n",
    510                 incr, current_width, j, k);
    511             j -= incr;
    512             incr = 0;
    513         }
    514         if (lastx + j + current_width > maxx) {
    515             ERR("exceeded maximum, lastx=%d, j=%d, current_width=%d\n",
    516                 lastx, j, current_width);
    517             j = maxx - lastx - current_width;
    518             incr = 0;
    519         }
    520 
    521         /* adjust the band rectangle for adding width  */
    522         /* and setting height of all bands in row.     */
    523         if (dwStyle & CCS_VERT) {
    524             lpBand->rcBand.top = lastx;
    525             lpBand->rcBand.bottom = lastx + j + current_width;
    526             if ((lpBand->rcBand.top != oldband.top) ||
    527                 (lpBand->rcBand.bottom != oldband.bottom))
    528                 lpBand->fDraw |= NTF_INVALIDATE;
    529             if (lpBand->rcBand.right != lpBand->rcBand.left + mcy) {
     588
     589        /* adjust height of bands in row to "mcy" value */
     590        if (infoPtr->dwStyle & CCS_VERT) {
     591            if (lpBand->rcBand.right != lpBand->rcBand.left + mcy)
    530592                lpBand->rcBand.right = lpBand->rcBand.left + mcy;
    531                 lpBand->fDraw |= NTF_INVALIDATE;
    532             }
    533593        }
    534594        else {
    535             lpBand->rcBand.left = lastx;
    536             lpBand->rcBand.right = lastx + j + current_width;
    537             if ((lpBand->rcBand.left != oldband.left) ||
    538                 (lpBand->rcBand.right != oldband.right))
    539                 lpBand->fDraw |= NTF_INVALIDATE;
    540             if (lpBand->rcBand.bottom != lpBand->rcBand.top + mcy) {
     595            if (lpBand->rcBand.bottom != lpBand->rcBand.top + mcy)
    541596                lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
    542                 lpBand->fDraw |= NTF_INVALIDATE;
    543             }
    544         }
    545 
    546         /* update to the next band start */
    547         lastx += (j + current_width + SEP_WIDTH);
    548         if (j) {
    549             TRACE("band %d row=%d: changed to (%d,%d)-(%d,%d)\n",
     597
     598        }
     599
     600        /* mark whether we need to invalidate this band and trace */
     601        if ((lpBand->rcoldBand.left !=lpBand->rcBand.left) ||
     602            (lpBand->rcoldBand.top !=lpBand->rcBand.top) ||
     603            (lpBand->rcoldBand.right !=lpBand->rcBand.right) ||
     604            (lpBand->rcoldBand.bottom !=lpBand->rcBand.bottom)) {
     605            lpBand->fDraw |= NTF_INVALIDATE;
     606            TRACE("band %d row=%d: changed to (%d,%d)-(%d,%d) from (%d,%d)-(%d,%d)\n",
    550607                  i, lpBand->iRow,
    551608                  lpBand->rcBand.left, lpBand->rcBand.top,
    552                   lpBand->rcBand.right, lpBand->rcBand.bottom);
    553         }
    554         else {
     609                  lpBand->rcBand.right, lpBand->rcBand.bottom,
     610                  lpBand->rcoldBand.left, lpBand->rcoldBand.top,
     611                  lpBand->rcoldBand.right, lpBand->rcoldBand.bottom);
     612        }
     613        else
    555614            TRACE("band %d row=%d: unchanged (%d,%d)-(%d,%d)\n",
    556615                  i, lpBand->iRow,
    557616                  lpBand->rcBand.left, lpBand->rcBand.top,
    558617                  lpBand->rcBand.right, lpBand->rcBand.bottom);
    559         }
    560     }
    561 
    562     /* if any remaining space then add to the rowstart band */
    563     if (incr > 0) {
    564         lpBand = &infoPtr->bands[rowstart];
    565         lpBand->rcBand.right += incr;
    566         TRACE("band %d row=%d: extended to (%d,%d)-(%d,%d)\n",
    567               rowstart, lpBand->iRow,
    568               lpBand->rcBand.left, lpBand->rcBand.top,
    569               lpBand->rcBand.right, lpBand->rcBand.bottom);
    570         for (i=rowstart+1; i<rowend; i++) {
    571             lpBand = &infoPtr->bands[i];
    572             if (HIDDENBAND(lpBand)) continue;
    573             lpBand->rcBand.left += incr;
    574             lpBand->rcBand.right += incr;
    575             lpBand->fDraw |= NTF_INVALIDATE;
    576         }
    577     }
    578 }
     618    }
     619}
     620
    579621
    580622static void
    581 REBAR_CalcHorzBand (HWND hwnd, REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify, DWORD dwStyle)
     623REBAR_AdjustBands (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
     624                   INT maxx, INT mcy)
     625     /* Function: This routine distributes the extra space in a row. */
     626     /*  See algorithm below.                                        */
     627     /* On entry:                                                    */
     628     /*   all bands @ ->cxHeader size                                */
     629     /*   start and end bands are *not* hidden                       */
     630{
     631    REBAR_BAND *lpBand;
     632    UINT x, xsep, extra, curwidth, fudge;
     633    INT i, last_adjusted;
     634
     635    TRACE("start=%u, end=%u, max x=%d, max y=%d\n",
     636          rowstart, rowend, maxx, mcy);
     637
     638    /* *******************  Phase 1  ************************ */
     639    /* Alg:                                                   */
     640    /*  For each visible band with valid child                */
     641    /*      a. inflate band till either all extra space used  */
     642    /*         or band's ->ccx reached.                       */
     643    /*  If any band modified, add any space left to last band */
     644    /*  adjusted.                                             */
     645    /*                                                        */
     646    /* ****************************************************** */
     647    lpBand = &infoPtr->bands[rowend];
     648    extra = maxx - rcBrb(lpBand);
     649    x = 0;
     650    last_adjusted = 0;
     651    for (i=(INT)rowstart; i<=(INT)rowend; i++) {
     652        lpBand = &infoPtr->bands[i];
     653        if (HIDDENBAND(lpBand)) continue;
     654        xsep = (x == 0) ? 0 : SEP_WIDTH;
     655        curwidth = rcBw(lpBand);
     656
     657        /* set new left/top point */
     658        if (infoPtr->dwStyle & CCS_VERT)
     659            lpBand->rcBand.top = x + xsep;
     660        else
     661            lpBand->rcBand.left = x + xsep;
     662
     663        /* compute new width */
     664        if (lpBand->hwndChild && extra) {
     665            /* set to the "current" band size less the header */
     666            fudge = lpBand->ccx;
     667            last_adjusted = i;
     668            if ((lpBand->fMask & RBBIM_SIZE) && (lpBand->cx > 0) &&
     669                (fudge > curwidth)) {
     670                TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n",
     671                      i, fudge-curwidth, fudge, curwidth, extra);
     672                if ((fudge - curwidth) > extra)
     673                    fudge = curwidth + extra;
     674                extra -= (fudge - curwidth);
     675                curwidth = fudge;
     676            }
     677            else {
     678                TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n",
     679                      i, extra, fudge, curwidth);
     680                curwidth += extra;
     681                extra = 0;
     682            }
     683        }
     684
     685        /* set new right/bottom point */
     686        if (infoPtr->dwStyle & CCS_VERT)
     687            lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
     688        else
     689            lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
     690        TRACE("Phase 1 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
     691              i, lpBand->rcBand.left, lpBand->rcBand.top,
     692              lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
     693        x = rcBrb(lpBand);
     694    }
     695    if ((x >= maxx) || last_adjusted) {
     696        if (x > maxx) {
     697            ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n",
     698                x, maxx,  rowstart, rowend);
     699        }
     700        /* done, so spread extra space */
     701        if (x < maxx) {
     702            fudge = maxx - x;
     703            TRACE("Need to spread %d on last adjusted band %d\n",
     704                fudge, last_adjusted);
     705            for (i=(INT)last_adjusted; i<=(INT)rowend; i++) {
     706                lpBand = &infoPtr->bands[i];
     707                if (HIDDENBAND(lpBand)) continue;
     708
     709                /* set right/bottom point */
     710                if (i != last_adjusted) {
     711                    if (infoPtr->dwStyle & CCS_VERT)
     712                        lpBand->rcBand.top += fudge;
     713                    else
     714                        lpBand->rcBand.left += fudge;
     715                }
     716
     717                /* set left/bottom point */
     718                if (infoPtr->dwStyle & CCS_VERT)
     719                    lpBand->rcBand.bottom += fudge;
     720                else
     721                    lpBand->rcBand.right += fudge;
     722            }
     723        }
     724        TRACE("Phase 1 succeeded, used x=%d\n", x);
     725        REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
     726        return;
     727    }
     728
     729    /* *******************  Phase 2  ************************ */
     730    /* Alg:                                                   */
     731    /*  Find first visible band, put all                      */
     732    /*    extra space there.                                  */
     733    /*                                                        */
     734    /* ****************************************************** */
     735
     736    x = 0;
     737    for (i=(INT)rowstart; i<=(INT)rowend; i++) {
     738        lpBand = &infoPtr->bands[i];
     739        if (HIDDENBAND(lpBand)) continue;
     740        xsep = (x == 0) ? 0 : SEP_WIDTH;
     741        curwidth = rcBw(lpBand);
     742
     743        /* set new left/top point */
     744        if (infoPtr->dwStyle & CCS_VERT)
     745            lpBand->rcBand.top = x + xsep;
     746        else
     747            lpBand->rcBand.left = x + xsep;
     748
     749        /* compute new width */
     750        if (extra) {
     751            curwidth += extra;
     752            extra = 0;
     753        }
     754
     755        /* set new right/bottom point */
     756        if (infoPtr->dwStyle & CCS_VERT)
     757            lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
     758        else
     759            lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
     760        TRACE("Phase 2 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
     761              i, lpBand->rcBand.left, lpBand->rcBand.top,
     762              lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
     763        x = rcBrb(lpBand);
     764    }
     765    if (x >= maxx) {
     766        if (x > maxx) {
     767            ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n",
     768                x, maxx,  rowstart, rowend);
     769        }
     770        /* done, so spread extra space */
     771        TRACE("Phase 2 succeeded, used x=%d\n", x);
     772        REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
     773        return;
     774    }
     775
     776    /* *******************  Phase 3  ************************ */
     777    /* at this point everything is back to ->cxHeader values  */
     778    /* and should not have gotten here.                       */
     779    /* ****************************************************** */
     780
     781    lpBand = &infoPtr->bands[rowstart];
     782    ERR("Serious problem adjusting row %d, start band %d, end band %d\n",
     783        lpBand->iRow, rowstart, rowend);
     784    REBAR_DumpBand (infoPtr);
     785    return;
     786}
     787
     788
     789static void
     790REBAR_CalcHorzBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
    582791     /* Function: this routine initializes all the rectangles in */
    583792     /*  each band in a row to fit in the adjusted rcBand rect.  */
     
    590799
    591800    /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
    592     parenthwnd = GetParent (hwnd);
     801    parenthwnd = GetParent (infoPtr->hwndSelf);
    593802
    594803    for(i=rstart; i<rend; i++){
     
    682891                lpBand->rcChild.left, lpBand->rcChild.top,
    683892                lpBand->rcChild.right, lpBand->rcChild.bottom);
    684           lpBand->fDraw |= NTF_CHILDSIZE;
    685893      }
    686894      if (lpBand->fDraw & NTF_INVALIDATE) {
     
    694902          if (lpBand->fDraw & DRAW_RIGHTSEP) work.right += SEP_WIDTH_SIZE;
    695903          if (lpBand->fDraw & DRAW_BOTTOMSEP) work.bottom += SEP_WIDTH_SIZE;
    696           InvalidateRect(hwnd, &work, TRUE);
     904          InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
    697905      }
    698906
     
    703911
    704912static VOID
    705 REBAR_CalcVertBand (HWND hwnd, REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify, DWORD dwStyle)
     913REBAR_CalcVertBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
    706914     /* Function: this routine initializes all the rectangles in */
    707915     /*  each band in a row to fit in the adjusted rcBand rect.  */
     
    710918    REBAR_BAND *lpBand;
    711919    UINT i, xoff, yoff;
    712     NMREBARCHILDSIZE  rbcz;
    713920    HWND parenthwnd;
    714921    RECT oldChild, work;
    715922
    716     rbcz.hdr.hwndFrom = hwnd;
    717     rbcz.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
    718923    /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
    719     parenthwnd = GetParent (hwnd);
     924    parenthwnd = GetParent (infoPtr->hwndSelf);
    720925
    721926    for(i=rstart; i<rend; i++){
     
    732937            lpBand->fDraw |= DRAW_GRIPPER;
    733938
    734             if (dwStyle & RBS_VERTICALGRIPPER) {
     939            if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) {
    735940                /*  vertical gripper  */
    736941                lpBand->rcGripper.left   += 3;
     
    8251030                  lpBand->rcChild.left, lpBand->rcChild.top,
    8261031                  lpBand->rcChild.right, lpBand->rcChild.bottom);
    827             lpBand->fDraw |= NTF_CHILDSIZE;
    8281032        }
    8291033        if (lpBand->fDraw & NTF_INVALIDATE) {
     
    8371041            if (lpBand->fDraw & DRAW_RIGHTSEP) work.bottom += SEP_WIDTH_SIZE;
    8381042            if (lpBand->fDraw & DRAW_BOTTOMSEP) work.right += SEP_WIDTH_SIZE;
    839             InvalidateRect(hwnd, &work, TRUE);
     1043            InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
    8401044        }
    8411045
     
    8451049
    8461050static VOID
    847 REBAR_Layout (HWND hwnd, LPRECT lpRect, BOOL notify, BOOL resetclient)
     1051REBAR_ForceResize (REBAR_INFO *infoPtr)
     1052     /* Function: This changes the size of the REBAR window to that */
     1053     /*  calculated by REBAR_Layout.                                */
     1054{
     1055    RECT rc;
     1056
     1057    /* TEST TEST TEST */
     1058    GetWindowRect (infoPtr->hwndSelf, &rc);
     1059    /* END TEST END TEST END TEST */
     1060
     1061
     1062    GetClientRect (infoPtr->hwndSelf, &rc);
     1063
     1064    TRACE( " old [%ld x %ld], new [%ld x %ld], client [%d x %d]\n",
     1065           infoPtr->oldSize.cx, infoPtr->oldSize.cy,
     1066           infoPtr->calcSize.cx, infoPtr->calcSize.cy,
     1067           rc.right, rc.bottom);
     1068
     1069    /* If we need to shrink client, then skip size test */
     1070    if ((infoPtr->calcSize.cy >= rc.bottom) &&
     1071        (infoPtr->calcSize.cx >= rc.right)) {
     1072
     1073        /* if size did not change then skip process */
     1074        if ((infoPtr->oldSize.cx == infoPtr->calcSize.cx) &&
     1075            (infoPtr->oldSize.cy == infoPtr->calcSize.cy) &&
     1076            !(infoPtr->fStatus & RESIZE_ANYHOW))
     1077            {
     1078                TRACE("skipping reset\n");
     1079                return;
     1080            }
     1081    }
     1082
     1083    infoPtr->fStatus &= ~RESIZE_ANYHOW;
     1084    /* Set flag to ignore next WM_SIZE message */
     1085    infoPtr->fStatus |= AUTO_RESIZE;
     1086
     1087    rc.left = 0;
     1088    rc.top = 0;
     1089    rc.right  = infoPtr->calcSize.cx;
     1090    rc.bottom = infoPtr->calcSize.cy;
     1091
     1092    InflateRect (&rc, 0, GetSystemMetrics(SM_CYEDGE));
     1093    /* see comments in _NCCalcSize for reason below is not done */
     1094#if 0
     1095    if (GetWindowLongA (infoPtr->hwndSelf, GWL_STYLE) & WS_BORDER) {
     1096        InflateRect (&rc, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
     1097    }
     1098#endif
     1099
     1100    TRACE("setting to (0,0)-(%d,%d)\n",
     1101          rc.right - rc.left, rc.bottom - rc.top);
     1102    SetWindowPos (infoPtr->hwndSelf, 0, 0, 0,
     1103                    rc.right - rc.left, rc.bottom - rc.top,
     1104                    SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW);
     1105}
     1106
     1107
     1108static VOID
     1109REBAR_MoveChildWindows (REBAR_INFO *infoPtr, UINT start, UINT endplus)
     1110{
     1111    REBAR_BAND *lpBand;
     1112    CHAR szClassName[40];
     1113    UINT i;
     1114    NMREBARCHILDSIZE  rbcz;
     1115    NMHDR heightchange;
     1116    HDWP deferpos;
     1117
     1118    if (!(deferpos = BeginDeferWindowPos(infoPtr->uNumBands)))
     1119        ERR("BeginDeferWindowPos returned NULL\n");
     1120
     1121    for (i = start; i < endplus; i++) {
     1122        lpBand = &infoPtr->bands[i];
     1123
     1124        if (HIDDENBAND(lpBand)) continue;
     1125        if (lpBand->hwndChild) {
     1126            TRACE("hwndChild = %x\n", lpBand->hwndChild);
     1127
     1128            /* Always geterate the RBN_CHILDSIZE even it child
     1129                   did not change */
     1130            rbcz.uBand = i;
     1131            rbcz.wID = lpBand->wID;
     1132            rbcz.rcChild = lpBand->rcChild;
     1133            rbcz.rcBand = lpBand->rcBand;
     1134            rbcz.rcBand.left += lpBand->cxHeader;
     1135            REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE);
     1136            if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) {
     1137                TRACE("Child rect changed by NOTIFY for band %u\n", i);
     1138                TRACE("    from (%d,%d)-(%d,%d)  to (%d,%d)-(%d,%d)\n",
     1139                      lpBand->rcChild.left, lpBand->rcChild.top,
     1140                      lpBand->rcChild.right, lpBand->rcChild.bottom,
     1141                      rbcz.rcChild.left, rbcz.rcChild.top,
     1142                      rbcz.rcChild.right, rbcz.rcChild.bottom);
     1143            }
     1144
     1145            GetClassNameA (lpBand->hwndChild, szClassName, 40);
     1146            if (!lstrcmpA (szClassName, "ComboBox") ||
     1147                !lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
     1148                INT nEditHeight, yPos;
     1149                RECT rc;
     1150
     1151                /* special placement code for combo or comboex box */
     1152
     1153
     1154                /* get size of edit line */
     1155                GetWindowRect (lpBand->hwndChild, &rc);
     1156                nEditHeight = rc.bottom - rc.top;
     1157                yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
     1158
     1159                /* center combo box inside child area */
     1160                TRACE("moving child (Combo(Ex)) %04x to (%d,%d) for (%d,%d)\n",
     1161                      lpBand->hwndChild,
     1162                      lpBand->rcChild.left, yPos,
     1163                      lpBand->rcChild.right - lpBand->rcChild.left,
     1164                      nEditHeight);
     1165                deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
     1166                                           lpBand->rcChild.left,
     1167                                           /*lpBand->rcChild.top*/ yPos,
     1168                                           lpBand->rcChild.right - lpBand->rcChild.left,
     1169                                           nEditHeight,
     1170                                           SWP_NOZORDER);
     1171                if (!deferpos)
     1172                    ERR("DeferWindowPos returned NULL\n");
     1173            }
     1174            else {
     1175                TRACE("moving child (Other) %04x to (%d,%d) for (%d,%d)\n",
     1176                      lpBand->hwndChild,
     1177                      lpBand->rcChild.left, lpBand->rcChild.top,
     1178                      lpBand->rcChild.right - lpBand->rcChild.left,
     1179                      lpBand->rcChild.bottom - lpBand->rcChild.top);
     1180                deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
     1181                                           lpBand->rcChild.left,
     1182                                           lpBand->rcChild.top,
     1183                                           lpBand->rcChild.right - lpBand->rcChild.left,
     1184                                           lpBand->rcChild.bottom - lpBand->rcChild.top,
     1185                                           SWP_NOZORDER);
     1186                if (!deferpos)
     1187                    ERR("DeferWindowPos returned NULL\n");
     1188            }
     1189        }
     1190    }
     1191    if (!EndDeferWindowPos(deferpos))
     1192        ERR("EndDeferWindowPos returned NULL\n");
     1193    if (infoPtr->fStatus & NTF_HGHTCHG) {
     1194        infoPtr->fStatus &= ~NTF_HGHTCHG;
     1195        REBAR_Notify (&heightchange, infoPtr, RBN_HEIGHTCHANGE);
     1196    }
     1197}
     1198
     1199
     1200static VOID
     1201REBAR_Layout (REBAR_INFO *infoPtr, LPRECT lpRect, BOOL notify, BOOL resetclient)
    8481202     /* Function: This routine is resposible for laying out all */
    8491203     /*  the bands in a rebar. It assigns each band to a row and*/
    8501204     /*  determines when to start a new row.                    */
    8511205{
    852     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    853     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    8541206    REBAR_BAND *lpBand, *prevBand;
    855     RECT rcClient, rcAdj, rcoldBand;
    856     INT x, y, cx, cxsep, mcy, clientcx, clientcy;
     1207    RECT rcClient, rcAdj;
     1208    INT x, y, cx, cxsep, mmcy, mcy, clientcx, clientcy;
    8571209    INT adjcx, adjcy, row, rightx, bottomy, origheight;
    858     UINT i, rowstartband;
     1210    UINT i, j, rowstart;
    8591211    BOOL dobreak;
    8601212
    861     GetClientRect (hwnd, &rcClient);
     1213    if (!(infoPtr->fStatus & BAND_NEEDS_LAYOUT)) {
     1214        TRACE("no layout done. No band changed.\n");
     1215        REBAR_DumpBand (infoPtr);
     1216        return;
     1217    }
     1218    infoPtr->fStatus &= ~BAND_NEEDS_LAYOUT;
     1219    if (!infoPtr->DoRedraw) infoPtr->fStatus |= BAND_NEEDS_REDRAW;
     1220
     1221    GetClientRect (infoPtr->hwndSelf, &rcClient);
    8621222    TRACE("Client is (%d,%d)-(%d,%d)\n",
    8631223          rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
     
    8821242    }
    8831243
     1244    if (!infoPtr->DoRedraw && (clientcx == 0) && (clientcy == 0)) {
     1245        ERR("no redraw and client is zero, skip layout\n");
     1246        infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
     1247        return;
     1248    }
     1249
    8841250    /* save height of original control */
    885     if (dwStyle & CCS_VERT)
     1251    if (infoPtr->dwStyle & CCS_VERT)
    8861252        origheight = infoPtr->calcSize.cx;
    8871253    else
     
    8911257    /* ******* Start Phase 1 - all bands on row at minimum size ******* */
    8921258
     1259    TRACE("band loop constants, clientcx=%d, clientcy=%d\n",
     1260          clientcx, clientcy);
    8931261    x = 0;
    8941262    y = 0;
     
    8961264    cx = 0;
    8971265    mcy = 0;
     1266    rowstart = 0;
    8981267    prevBand = NULL;
    8991268
     
    9031272        lpBand->iRow = row;
    9041273
    905         if ((lpBand->fStyle & RBBS_HIDDEN) ||
    906             ((dwStyle & CCS_VERT) && (lpBand->fStyle & RBBS_NOVERT)))
    907             continue;
    908 
    909         rcoldBand = lpBand->rcBand;
     1274        if (HIDDENBAND(lpBand)) continue;
     1275
     1276        lpBand->rcoldBand = lpBand->rcBand;
    9101277
    9111278        /* separator from previous band */
    912         cxsep = ( ((dwStyle & CCS_VERT) ? y : x)==0) ? 0 : SEP_WIDTH; 
     1279        cxsep = ( ((infoPtr->dwStyle & CCS_VERT) ? y : x)==0) ? 0 : SEP_WIDTH; 
    9131280
    9141281        /* Header: includes gripper, text, image */
    9151282        cx = lpBand->cxHeader;   
    916         if (lpBand->fStyle & RBBS_FIXEDSIZE) cx += lpBand->lcx;
    917 
    918         if (dwStyle & CCS_VERT)
     1283        if (lpBand->fStyle & RBBS_FIXEDSIZE) cx = lpBand->lcx;
     1284
     1285        if (infoPtr->dwStyle & CCS_VERT)
    9191286            dobreak = (y + cx + cxsep > adjcy);
    9201287        else
     
    9231290        /* This is the check for whether we need to start a new row */
    9241291        if ( ( (lpBand->fStyle & RBBS_BREAK) && (i != 0) ) ||
    925              ( ((dwStyle & CCS_VERT) ? (y != 0) : (x != 0)) && dobreak)) {
     1292             ( ((infoPtr->dwStyle & CCS_VERT) ? (y != 0) : (x != 0)) && dobreak)) {
     1293
     1294            for (j = rowstart; j < i; j++) {
     1295                REBAR_BAND *lpB;
     1296                lpB = &infoPtr->bands[j];
     1297                if (infoPtr->dwStyle & CCS_VERT) {
     1298                    lpB->rcBand.right  = lpB->rcBand.left + mcy;
     1299                }
     1300                else {
     1301                    lpB->rcBand.bottom = lpB->rcBand.top + mcy;
     1302                }
     1303            }
     1304
    9261305            TRACE("Spliting to new row %d on band %u\n", row+1, i);
    927             if (dwStyle & CCS_VERT) {
     1306            if (infoPtr->dwStyle & CCS_VERT) {
    9281307                y = 0;
    9291308                x += (mcy + SEP_WIDTH);
     
    9341313            }
    9351314
    936             /* FIXME: if not RBS_VARHEIGHT then find max */
    9371315            mcy = 0;
    9381316            cxsep = 0;
     
    9401318            lpBand->iRow = row;
    9411319            prevBand = NULL;
     1320            rowstart = i;
    9421321        }
    9431322
     
    9461325        /* if boundary rect specified then limit mcy */
    9471326        if (lpRect) {
    948             if (dwStyle & CCS_VERT) {
     1327            if (infoPtr->dwStyle & CCS_VERT) {
    9491328                if (x+mcy > adjcx) {
    9501329                    mcy = adjcx - x;
     
    9621341        }
    9631342
    964         if (dwStyle & CCS_VERT) {
     1343        TRACE("band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n",
     1344              i, row,
     1345              x, y, cxsep, cx);
     1346        if (infoPtr->dwStyle & CCS_VERT) {
    9651347            /* bound the bottom side if we have a bounding rectangle */
    966             if ((x>0) && (dwStyle & RBS_BANDBORDERS) && prevBand)
    967                 prevBand->fDraw |= DRAW_RIGHTSEP;
    9681348            rightx = clientcx;
    9691349            bottomy = (lpRect) ? min(clientcy, y+cxsep+cx) : y+cxsep+cx;
     
    9731353            lpBand->rcBand.bottom = bottomy;
    9741354            lpBand->uMinHeight = lpBand->lcy;
    975             if (!EqualRect(&rcoldBand, &lpBand->rcBand))
    976                 lpBand->fDraw |= NTF_INVALIDATE;
    9771355            y = bottomy;
    9781356        }
    9791357        else {
    9801358            /* bound the right side if we have a bounding rectangle */
    981             if ((x>0) && (dwStyle & RBS_BANDBORDERS) && prevBand)
    982                 prevBand->fDraw |= DRAW_RIGHTSEP;
    9831359            rightx = (lpRect) ? min(clientcx, x+cxsep+cx) : x+cxsep+cx;
    9841360            bottomy = clientcy;
     
    9881364            lpBand->rcBand.bottom = y + min(mcy, lpBand->lcy+REBARSPACE);
    9891365            lpBand->uMinHeight = lpBand->lcy;
    990             if (!EqualRect(&rcoldBand, &lpBand->rcBand))
    991                 lpBand->fDraw |= NTF_INVALIDATE;
    9921366            x = rightx;
    9931367        }
     
    10001374    } /* for (i = 0; i < infoPtr->uNumBands... */
    10011375
    1002     if (dwStyle & CCS_VERT)
     1376    if (infoPtr->dwStyle & CCS_VERT)
    10031377        x += mcy;
    10041378    else
    10051379        y += mcy;
    10061380
     1381    for (j = rowstart; j < infoPtr->uNumBands; j++) {
     1382        lpBand = &infoPtr->bands[j];
     1383        if (infoPtr->dwStyle & CCS_VERT) {
     1384            lpBand->rcBand.right  = lpBand->rcBand.left + mcy;
     1385        }
     1386        else {
     1387            lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
     1388        }
     1389    }
     1390
    10071391    if (infoPtr->uNumBands)
    10081392        infoPtr->uNumRows = row;
    10091393
    10101394    /* ******* End Phase 1 - all bands on row at minimum size ******* */
     1395
     1396
     1397    /* ******* Start Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
     1398
     1399    mmcy = 0;
     1400    if (!(infoPtr->dwStyle & RBS_VARHEIGHT)) {
     1401        INT xy;
     1402
     1403        /* get the max height of all bands */
     1404        for (i=0; i<infoPtr->uNumBands; i++) {
     1405            lpBand = &infoPtr->bands[i];
     1406            if (HIDDENBAND(lpBand)) continue;
     1407            if (infoPtr->dwStyle & CCS_VERT)
     1408                mmcy = max(mmcy, lpBand->rcBand.right - lpBand->rcBand.left);
     1409            else
     1410                mmcy = max(mmcy, lpBand->rcBand.bottom - lpBand->rcBand.top);
     1411        }
     1412
     1413        /* now adjust all rectangles by using the height found above */
     1414        xy = 0;
     1415        row = 1;
     1416        for (i=0; i<infoPtr->uNumBands; i++) {
     1417            lpBand = &infoPtr->bands[i];
     1418            if (HIDDENBAND(lpBand)) continue;
     1419            if (lpBand->iRow != row)
     1420                xy += (mmcy + SEP_WIDTH);
     1421            if (infoPtr->dwStyle & CCS_VERT) {
     1422                lpBand->rcBand.left = xy;
     1423                lpBand->rcBand.right = xy + mmcy;
     1424            }
     1425            else {
     1426                lpBand->rcBand.top = xy;
     1427                lpBand->rcBand.bottom = xy + mmcy;
     1428            }
     1429        }
     1430
     1431        /* set the x/y values to the correct maximum */
     1432        if (infoPtr->dwStyle & CCS_VERT)
     1433            x = xy + mmcy;
     1434        else
     1435            y = xy + mmcy;
     1436    }
     1437
     1438    /* ******* End Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
    10111439
    10121440
     
    10161444    /*   y/x     current height/width of all rows                    */
    10171445    if (lpRect) {
    1018         INT i, j, prev_rh, current_rh, new_rh, adj_rh;
     1446        INT i, j, prev_rh, new_rh, adj_rh, prev_idx, current_idx;
    10191447        REBAR_BAND *prev, *current, *walk;
    10201448
    1021 /*      if (((dwStyle & CCS_VERT) ? (x < adjcx) : (y < adjcy)) && */
    1022 
    1023         if (((dwStyle & CCS_VERT) ? (adjcx - x > 4) : (adjcy - y > 4)) &&
     1449/* FIXME:  problem # 2 */
     1450        if (((infoPtr->dwStyle & CCS_VERT) ?
     1451#if PROBLEM2
     1452             (x < adjcx) : (y < adjcy)
     1453#else
     1454             (adjcx - x > 4) : (adjcy - y > 4)
     1455#endif
     1456             ) &&
    10241457            (infoPtr->uNumBands > 1)) {
    1025             for (i=infoPtr->uNumBands-2; i>=0; i--) {
     1458            for (i=(INT)infoPtr->uNumBands-2; i>=0; i--) {
    10261459                TRACE("adjcx=%d, adjcy=%d, x=%d, y=%d\n",
    10271460                      adjcx, adjcy, x, y);
     1461
     1462                /* find the current band (starts at i+1) */
     1463                current = &infoPtr->bands[i+1];
     1464                current_idx = i+1;
     1465                while (HIDDENBAND(current)) {
     1466                    i--;
     1467                    if (i < 0) break; /* out of bands */
     1468                    current = &infoPtr->bands[i+1];
     1469                    current_idx = i+1;
     1470                }
     1471                if (i < 0) break; /* out of bands */
     1472
     1473                /* now find the prev band (starts at i) */
    10281474                prev = &infoPtr->bands[i];
    1029                 prev_rh = ircBrb(prev) - ircBlt(prev);
    1030                 current = &infoPtr->bands[i+1];
    1031                 current_rh = ircBrb(current) - ircBlt(current);
     1475                prev_idx = i;
     1476                while (HIDDENBAND(prev)) {
     1477                    i--;
     1478                    if (i < 0) break; /* out of bands */
     1479                    prev = &infoPtr->bands[i];
     1480                    prev_idx = i;
     1481                }
     1482                if (i < 0) break; /* out of bands */
     1483
     1484                prev_rh = ircBw(prev);
    10321485                if (prev->iRow == current->iRow) {
    1033                     new_rh = current->lcy + REBARSPACE;
    1034                     adj_rh = prev_rh + new_rh + SEP_WIDTH - current_rh;
     1486                    new_rh = (infoPtr->dwStyle & RBS_VARHEIGHT) ?
     1487                        current->lcy + REBARSPACE :
     1488                        mmcy;
     1489                    adj_rh = new_rh + SEP_WIDTH;
    10351490                    infoPtr->uNumRows++;
    10361491                    current->fDraw |= NTF_INVALIDATE;
    10371492                    current->iRow++;
    1038                     if (dwStyle & CCS_VERT) {
     1493                    if (infoPtr->dwStyle & CCS_VERT) {
    10391494                        current->rcBand.top = 0;
    10401495                        current->rcBand.bottom = clientcy;
     
    10511506                    }
    10521507                    TRACE("moving band %d to own row at (%d,%d)-(%d,%d)\n",
    1053                           i+1,
     1508                          current_idx,
    10541509                          current->rcBand.left, current->rcBand.top,
    10551510                          current->rcBand.right, current->rcBand.bottom);
    10561511                    TRACE("prev band %d at (%d,%d)-(%d,%d)\n",
    1057                           i,
     1512                          prev_idx,
    10581513                          prev->rcBand.left, prev->rcBand.top,
    10591514                          prev->rcBand.right, prev->rcBand.bottom);
    1060                     TRACE("values: prev_rh=%d, current_rh=%d, new_rh=%d, adj_rh=%d\n",
    1061                           prev_rh, current_rh, new_rh, adj_rh);
     1515                    TRACE("values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",
     1516                          prev_rh, new_rh, adj_rh);
    10621517                    /* for bands below current adjust row # and top/bottom */
    1063                     for (j = i+2; j<infoPtr->uNumBands; j++) {
     1518                    for (j = current_idx+1; j<infoPtr->uNumBands; j++) {
    10641519                        walk = &infoPtr->bands[j];
     1520                        if (HIDDENBAND(walk)) continue;
    10651521                        walk->fDraw |= NTF_INVALIDATE;
    10661522                        walk->iRow++;
    1067                         if (dwStyle & CCS_VERT) {
     1523                        if (infoPtr->dwStyle & CCS_VERT) {
    10681524                            walk->rcBand.left += adj_rh;
    10691525                            walk->rcBand.right += adj_rh;
     
    10741530                        }
    10751531                    }
    1076                     if ((dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy))
     1532                    if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy))
    10771533                        break; /* all done */
    10781534                }
     
    10841540
    10851541
     1542    /* ******* Start Phase 2a - adjust all bands for height full ******* */
     1543    /* assumes that the following variables contain:                 */
     1544    /*   y/x     current height/width of all rows                    */
     1545    /*   clientcy/clientcx     height/width of client area           */
     1546
     1547    /* **** FIXME FIXME FIXME
     1548     *   this does not take into account that more than one band
     1549     *   is in a row!!!!!!!!!
     1550     */
     1551
     1552    if (((infoPtr->dwStyle & CCS_VERT) ? clientcx > x : clientcy > y) &&
     1553        infoPtr->uNumBands) {
     1554        INT diff, i, j;
     1555
     1556        diff = (infoPtr->dwStyle & CCS_VERT) ? clientcx - x : clientcy - y;
     1557        for (i = infoPtr->uNumBands-1; i >= 0; i--) {
     1558            lpBand = &infoPtr->bands[i];
     1559            if(HIDDENBAND(lpBand)) continue;
     1560            if (!lpBand->fMask & RBBS_VARIABLEHEIGHT) continue;
     1561            if (((INT)lpBand->cyMaxChild < 1) ||
     1562                ((INT)lpBand->cyIntegral < 1)) {
     1563                if (lpBand->cyMaxChild + lpBand->cyIntegral == 0) continue;
     1564                ERR("band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
     1565                    i, lpBand->cyMaxChild, lpBand->cyIntegral);
     1566                continue;
     1567            }
     1568            /* j is now the maximum height/width in the client area */
     1569            j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) +
     1570                ircBw(lpBand);
     1571            if (j > lpBand->cyMaxChild + REBARSPACE)
     1572                j = lpBand->cyMaxChild + REBARSPACE;
     1573            diff -= (j - ircBw(lpBand));
     1574            if (infoPtr->dwStyle & CCS_VERT)
     1575                lpBand->rcBand.right = lpBand->rcBand.left + j;
     1576            else
     1577                lpBand->rcBand.bottom = lpBand->rcBand.top + j;
     1578            TRACE("P2a band %d, row %d changed to (%d,%d)-(%d,%d)\n",
     1579                  i, lpBand->iRow,
     1580                  lpBand->rcBand.left, lpBand->rcBand.top,
     1581                  lpBand->rcBand.right, lpBand->rcBand.bottom);
     1582            if (diff <= 0) break;
     1583        }
     1584        if (diff < 0) {
     1585            ERR("allocated more than available, diff=%d\n", diff);
     1586            diff = 0;
     1587        }
     1588        if (infoPtr->dwStyle & CCS_VERT)
     1589            x = clientcx - diff;
     1590        else
     1591            y = clientcy - diff;
     1592    }
     1593
     1594    /* ******* End Phase 2a - adjust all bands for height full ******* */
     1595
    10861596
    10871597    /* ******* Start Phase 3 - adjust all bands for width full ******* */
    10881598
    10891599    if (infoPtr->uNumBands) {
    1090         REBAR_BAND *prev, *current;
     1600        INT bandnum, bandnum_start, bandnum_end;
     1601
    10911602        /* If RBS_BANDBORDERS set then indicate to draw bottom separator */
    1092         if (dwStyle & RBS_BANDBORDERS) {
     1603        /* on all bands in all rows but last row.                        */
     1604        /* Also indicate to draw the right separator for each band in    */
     1605        /* each row but the rightmost band.                              */
     1606        if (infoPtr->dwStyle & RBS_BANDBORDERS) {
     1607            REBAR_BAND *prevband;
     1608            INT currow;
     1609
     1610            prevband = NULL;
     1611            currow = -1;
    10931612            for (i = 0; i < infoPtr->uNumBands; i++) {
    10941613                lpBand = &infoPtr->bands[i];
    10951614                if (HIDDENBAND(lpBand)) continue;
     1615
    10961616                if (lpBand->iRow < infoPtr->uNumRows)
    10971617                    lpBand->fDraw |= DRAW_BOTTOMSEP;
     1618
     1619                if (lpBand->iRow != currow) prevband = NULL;
     1620                currow = lpBand->iRow;
     1621                if (prevband) prevband->fDraw |= DRAW_RIGHTSEP;
     1622                prevband = lpBand;
    10981623            }
    10991624        }
    11001625
    1101         /* Adjust the horizontal and vertical of each band */
    1102         prev = &infoPtr->bands[0];
    1103         current = prev;
    1104         mcy = prev->lcy + REBARSPACE;
    1105         rowstartband = 0;
    1106         for (i=1; i<infoPtr->uNumBands; i++) {
    1107             prev = &infoPtr->bands[i-1];
    1108             current = &infoPtr->bands[i];
    1109             if (prev->iRow != current->iRow) {
    1110                 REBAR_AdjustBands (infoPtr, rowstartband, i,
    1111                                    (dwStyle & CCS_VERT) ? clientcy : clientcx,
    1112                                    rcBrb(prev),
    1113                                    mcy, dwStyle);
    1114                 mcy = 0;
    1115                 rowstartband = i;
     1626        /* Distribute the extra space on the horizontal and adjust  */
     1627        /* all bands in row to same height.                         */
     1628        bandnum = 0;
     1629        for (i=1; i<=infoPtr->uNumRows; i++) {
     1630            bandnum_start = -1;
     1631            bandnum_end = -1;
     1632            mcy = 0;
     1633            TRACE("processing row %d, starting band %d\n", i, bandnum);
     1634            while (TRUE) {
     1635                lpBand = &infoPtr->bands[bandnum];
     1636                if ((bandnum >= infoPtr->uNumBands) ||
     1637                    ((lpBand->iRow != i) &&
     1638                     !HIDDENBAND(lpBand))) {
     1639                    if ((bandnum_start == -1) ||
     1640                        (bandnum_end == -1)) {
     1641                        ERR("logic error? bands=%d, rows=%d, start=%d, end=%d\n",
     1642                            infoPtr->uNumBands, infoPtr->uNumRows,
     1643                            (INT)bandnum_start, (INT)bandnum_end);
     1644                        ERR("  current row=%d, band=%d\n",
     1645                            i, bandnum);
     1646                        break;
     1647                    }
     1648                    REBAR_AdjustBands (infoPtr, bandnum_start, bandnum_end,
     1649                                       (infoPtr->dwStyle & CCS_VERT) ?
     1650                                       clientcy : clientcx, mcy);
     1651                    break;
     1652                }
     1653                if (!HIDDENBAND(lpBand)) {
     1654                    if (bandnum_start == -1) bandnum_start = bandnum;
     1655                    if (bandnum_end < bandnum) bandnum_end = bandnum;
     1656                    if (mcy < ircBw(lpBand))
     1657                        mcy = ircBw(lpBand);
     1658                }
     1659                bandnum++;
     1660                TRACE("point 1, bandnum=%d\n", bandnum);
    11161661            }
    1117             if (mcy < current->lcy + REBARSPACE)
    1118                 mcy = current->lcy + REBARSPACE;
    1119         }
    1120         REBAR_AdjustBands (infoPtr, rowstartband, infoPtr->uNumBands,
    1121                            (dwStyle & CCS_VERT) ? clientcy : clientcx,
    1122                            rcBrb(current),
    1123                            mcy, dwStyle);
     1662            TRACE("point 2, i=%d, numrows=%d, bandnum=%d\n",
     1663                  i, infoPtr->uNumRows, bandnum);
     1664        }
     1665        TRACE("point 3\n");
    11241666
    11251667        /* Calculate the other rectangles in each band */
    1126         if (dwStyle & CCS_VERT) {
    1127             REBAR_CalcVertBand (hwnd, infoPtr, 0, infoPtr->uNumBands,
    1128                                 notify, dwStyle);
     1668        if (infoPtr->dwStyle & CCS_VERT) {
     1669            REBAR_CalcVertBand (infoPtr, 0, infoPtr->uNumBands,
     1670                                notify);
    11291671        }
    11301672        else {
    1131             REBAR_CalcHorzBand (hwnd, infoPtr, 0, infoPtr->uNumBands,
    1132                                 notify, dwStyle);
     1673            REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands,
     1674                                notify);
    11331675        }
    11341676    }
     
    11361678    /* ******* End Phase 3 - adjust all bands for width full ******* */
    11371679
    1138 
    1139     /* FIXME: if not RBS_VARHEIGHT then find max mcy and adj rect*/
    1140 
     1680    /* now compute size of Rebar itself */
    11411681    infoPtr->oldSize = infoPtr->calcSize;
    1142     if (dwStyle & CCS_VERT) {
     1682    if (infoPtr->dwStyle & CCS_VERT) {
    11431683        infoPtr->calcSize.cx = x;
    11441684        infoPtr->calcSize.cy = clientcy;
     
    11541694        if (notify && (y != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
    11551695    }
    1156     REBAR_DumpBand (hwnd);
     1696
     1697    REBAR_DumpBand (infoPtr);
     1698
     1699    REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
     1700
     1701    REBAR_ForceResize (infoPtr);
    11571702}
    11581703
    11591704
    11601705static VOID
    1161 REBAR_ForceResize (HWND hwnd)
    1162      /* Function: This changes the size of the REBAR window to that */
    1163      /*  calculated by REBAR_Layout.                                */
    1164 {
    1165     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    1166     RECT rc;
    1167 
    1168     TRACE( " from [%ld x %ld] to [%ld x %ld]!\n",
    1169            infoPtr->oldSize.cx, infoPtr->oldSize.cy,
    1170            infoPtr->calcSize.cx, infoPtr->calcSize.cy);
    1171 
    1172     /* if size did not change then skip process */
    1173     if ((infoPtr->oldSize.cx == infoPtr->calcSize.cx) &&
    1174         (infoPtr->oldSize.cy == infoPtr->calcSize.cy) &&
    1175         !(infoPtr->fStatus & RESIZE_ANYHOW))
    1176         return;
    1177 
    1178     infoPtr->fStatus &= ~RESIZE_ANYHOW;
    1179     /* Set flag to ignore next WM_SIZE message */
    1180     infoPtr->fStatus |= AUTO_RESIZE;
    1181 
    1182     rc.left = 0;
    1183     rc.top = 0;
    1184     rc.right  = infoPtr->calcSize.cx;
    1185     rc.bottom = infoPtr->calcSize.cy;
    1186 
    1187     if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER) {
    1188         InflateRect (&rc, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
    1189     }
    1190 
    1191     SetWindowPos (hwnd, 0, 0, 0,
    1192                     rc.right - rc.left, rc.bottom - rc.top,
    1193                     SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW);
    1194 }
    1195 
    1196 
    1197 static VOID
    1198 REBAR_MoveChildWindows (HWND hwnd)
    1199 {
    1200     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    1201     REBAR_BAND *lpBand;
    1202     CHAR szClassName[40];
    1203     UINT i;
    1204     NMREBARCHILDSIZE  rbcz;
    1205     NMHDR heightchange;
    1206     HDWP deferpos;
    1207     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    1208 
    1209     if (!(deferpos = BeginDeferWindowPos(8)))
    1210         ERR("BeginDeferWindowPso returned NULL\n");
    1211 
    1212     for (i = 0; i < infoPtr->uNumBands; i++) {
    1213         lpBand = &infoPtr->bands[i];
    1214 
    1215         if (HIDDENBAND(lpBand)) continue;
    1216         if (lpBand->hwndChild) {
    1217             TRACE("hwndChild = %x\n", lpBand->hwndChild);
    1218 
    1219             if (lpBand->fDraw & NTF_CHILDSIZE) {
    1220                 lpBand->fDraw &= ~NTF_CHILDSIZE;
    1221                 rbcz.uBand = i;
    1222                 rbcz.wID = lpBand->wID;
    1223                 rbcz.rcChild = lpBand->rcChild;
    1224                 rbcz.rcBand = lpBand->rcBand;
    1225                 rbcz.rcBand.left += lpBand->cxHeader;
    1226                 REBAR_Notify (hwnd, (NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE);
    1227                 if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) {
    1228                     TRACE("Child rect changed by NOTIFY for band %u\n", i);
    1229                     TRACE("    from (%d,%d)-(%d,%d)  to (%d,%d)-(%d,%d)\n",
    1230                           lpBand->rcChild.left, lpBand->rcChild.top,
    1231                           lpBand->rcChild.right, lpBand->rcChild.bottom,
    1232                           rbcz.rcChild.left, rbcz.rcChild.top,
    1233                           rbcz.rcChild.right, rbcz.rcChild.bottom);
    1234                 }
    1235             }
    1236 
    1237             GetClassNameA (lpBand->hwndChild, szClassName, 40);
    1238             if (!lstrcmpA (szClassName, "ComboBox") ||
    1239                 !lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
    1240                 INT nEditHeight, yPos;
    1241                 RECT rc;
    1242 
    1243                 /* special placement code for combo or comboex box */
    1244 
    1245 
    1246                 /* get size of edit line */
    1247                 GetWindowRect (lpBand->hwndChild, &rc);
    1248                 nEditHeight = rc.bottom - rc.top;
    1249                 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
    1250 
    1251                 /* center combo box inside child area */
    1252                 TRACE("moving child (Combo(Ex)) %04x to (%d,%d)-(%d,%d)\n",
    1253                       lpBand->hwndChild,
    1254                       lpBand->rcChild.left, yPos,
    1255                       lpBand->rcChild.right - lpBand->rcChild.left,
    1256                       nEditHeight);
    1257                 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
    1258                                            lpBand->rcChild.left,
    1259                                            /*lpBand->rcChild.top*/ yPos,
    1260                                            lpBand->rcChild.right - lpBand->rcChild.left,
    1261                                            nEditHeight,
    1262                                            SWP_NOZORDER);
    1263                 if (!deferpos)
    1264                     ERR("DeferWindowPos returned NULL\n");
    1265             }
    1266             else {
    1267                 TRACE("moving child (Other) %04x to (%d,%d)-(%d,%d)\n",
    1268                       lpBand->hwndChild,
    1269                       lpBand->rcChild.left, lpBand->rcChild.top,
    1270                       lpBand->rcChild.right - lpBand->rcChild.left,
    1271                       lpBand->rcChild.bottom - lpBand->rcChild.top);
    1272                 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
    1273                                            lpBand->rcChild.left,
    1274                                            lpBand->rcChild.top,
    1275                                            lpBand->rcChild.right - lpBand->rcChild.left,
    1276                                            lpBand->rcChild.bottom - lpBand->rcChild.top,
    1277                                            SWP_NOZORDER);
    1278                 if (!deferpos)
    1279                     ERR("DeferWindowPos returned NULL\n");
    1280             }
    1281         }
    1282     }
    1283     if (!EndDeferWindowPos(deferpos))
    1284         ERR("EndDeferWindowPos returned NULL\n");
    1285     if (infoPtr->fStatus & NTF_HGHTCHG) {
    1286         infoPtr->fStatus &= ~NTF_HGHTCHG;
    1287         REBAR_Notify (hwnd, &heightchange, infoPtr, RBN_HEIGHTCHANGE);
    1288     }
    1289 }
    1290 
    1291 
    1292 static VOID
    1293 REBAR_ValidateBand (HWND hwnd, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
     1706REBAR_ValidateBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
    12941707     /* Function:  This routine evaluates the band specs supplied */
    12951708     /*  by the user and updates the following 5 fields in        */
     
    12981711    UINT header=0;
    12991712    UINT textheight=0;
    1300     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    13011713
    13021714    lpBand->fStatus = 0;
    13031715    lpBand->lcx = 0;
    13041716    lpBand->lcy = 0;
     1717    lpBand->ccx = 0;
     1718    lpBand->ccy = 0;
    13051719    lpBand->hcx = 0;
    13061720    lpBand->hcy = 0;
     
    13251739    if (lpBand->cxHeader   > 65535) lpBand->cxHeader   = 0;
    13261740
     1741    /* FIXME: probably should only set NEEDS_LAYOUT flag when */
     1742    /*        values change. Till then always set it.         */
     1743    TRACE("setting NEEDS_LAYOUT\n");
     1744    infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
     1745
    13271746    /* Header is where the image, text and gripper exist  */
    13281747    /* in the band and preceed the child window.          */
     
    13341753       ) {
    13351754        lpBand->fStatus |= HAS_GRIPPER;
    1336         if (dwStyle & CCS_VERT)
    1337             if (dwStyle & RBS_VERTICALGRIPPER)
     1755        if (infoPtr->dwStyle & CCS_VERT)
     1756            if (infoPtr->dwStyle & RBS_VERTICALGRIPPER)
    13381757                header += (GRIPPER_HEIGHT + REBAR_PRE_GRIPPER);
    13391758            else
     
    13481767    if ((lpBand->fMask & RBBIM_IMAGE) && (infoPtr->himl)) {
    13491768        lpBand->fStatus |= HAS_IMAGE;
    1350         if (dwStyle & CCS_VERT) {
     1769        if (infoPtr->dwStyle & CCS_VERT) {
    13511770           header += (infoPtr->imageSize.cy + REBAR_POST_IMAGE);
    13521771           lpBand->lcy = infoPtr->imageSize.cx + 2;
     
    13671786        GetTextExtentPoint32W (hdc, lpBand->lpText,
    13681787                               lstrlenW (lpBand->lpText), &size);
    1369         header += ((dwStyle & CCS_VERT) ? (size.cy + REBAR_POST_TEXT) : (size.cx + REBAR_POST_TEXT));
    1370         textheight = (dwStyle & CCS_VERT) ? 0 : size.cy;
     1788        header += ((infoPtr->dwStyle & CCS_VERT) ? (size.cy + REBAR_POST_TEXT) : (size.cx + REBAR_POST_TEXT));
     1789        textheight = (infoPtr->dwStyle & CCS_VERT) ? 0 : size.cy;
    13711790
    13721791        SelectObject (hdc, hOldFont);
     
    13891808    lpBand->offChild.cy = 0;
    13901809    lpBand->lcy = textheight;
     1810    lpBand->ccy = lpBand->lcy;
    13911811    if (lpBand->fMask & RBBIM_CHILDSIZE) {
    13921812        if (!(lpBand->fStyle & RBBS_FIXEDSIZE)) {
     
    13951815        }
    13961816        lpBand->lcx = lpBand->cxMinChild;
     1817
     1818        /* Set the .cy values for CHILDSIZE case */
    13971819        lpBand->lcy = max(lpBand->lcy, lpBand->cyMinChild);
     1820        lpBand->ccy = lpBand->lcy;
    13981821        lpBand->hcy = lpBand->lcy;
    1399         if (lpBand->fStyle & RBBS_VARIABLEHEIGHT) {
    1400             if (lpBand->cyChild != 0xffffffff)
    1401                 lpBand->lcy = max (lpBand->cyChild, lpBand->lcy);
     1822        if (lpBand->cyMaxChild != 0xffffffff) {
    14021823            lpBand->hcy = lpBand->cyMaxChild;
    14031824        }
     1825        if (lpBand->cyChild != 0xffffffff)
     1826            lpBand->ccy = max (lpBand->cyChild, lpBand->lcy);
     1827
    14041828        TRACE("_CHILDSIZE\n");
    14051829    }
    14061830    if (lpBand->fMask & RBBIM_SIZE) {
    1407         lpBand->hcx = max (lpBand->cx, lpBand->lcx);
     1831        lpBand->hcx = max (lpBand->cx-lpBand->cxHeader, lpBand->lcx);
    14081832        TRACE("_SIZE\n");
    14091833    }
    14101834    else
    14111835        lpBand->hcx = lpBand->lcx;
     1836    lpBand->ccx = lpBand->hcx;
     1837
     1838    /* make ->.cx include header size for _Layout */
     1839    lpBand->lcx += lpBand->cxHeader;
     1840    lpBand->ccx += lpBand->cxHeader;
     1841    lpBand->hcx += lpBand->cxHeader;
    14121842
    14131843}
     
    14361866            lpBand->hwndPrevParent =
    14371867                SetParent (lpBand->hwndChild, hwnd);
     1868            /* below in trace fro WinRAR */
     1869            ShowWindow(lpBand->hwndChild, SW_SHOWNOACTIVATE | SW_SHOWNORMAL);
     1870            /* above in trace fro WinRAR */
    14381871        }
    14391872        else {
     
    14841917
    14851918static LRESULT
    1486 REBAR_InternalEraseBkGnd (HWND hwnd, WPARAM wParam, LPARAM lParam, RECT *clip)
    1487      /* Function:  This erases the background rectangle with the  */
    1488      /*  default brush, then with any band that has a different   */
    1489      /*  background color.                                        */
    1490 {
    1491     HBRUSH hbrBackground = GetClassWord(hwnd, GCW_HBRBACKGROUND);
    1492     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    1493     RECT eraserect;
     1919REBAR_InternalEraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, RECT *clip)
     1920     /* Function:  This erases the background rectangle by drawing  */
     1921     /*  each band with its background color (or the default) and   */
     1922     /*  draws each bands right separator if necessary. The row     */
     1923     /*  separators are drawn on the first band of the next row.    */
     1924{
    14941925    REBAR_BAND *lpBand;
    1495     INT i;
    1496 
    1497     if (hbrBackground)
    1498         FillRect( (HDC) wParam, clip, hbrBackground);
    1499 
     1926    INT i, oldrow;
     1927    HDC hdc = (HDC)wParam;
     1928    RECT rect;
     1929    COLORREF old, new;
     1930
     1931    oldrow = -1;
    15001932    for(i=0; i<infoPtr->uNumBands; i++) {
    15011933        lpBand = &infoPtr->bands[i];
    1502         if (lpBand->clrBack != CLR_NONE) {
    1503           if (IntersectRect (&eraserect, clip, &lpBand->rcBand)) {
    1504             /* draw background */
    1505             HBRUSH brh = CreateSolidBrush (lpBand->clrBack);
    1506             TRACE("backround color=0x%06lx, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
    1507                   lpBand->clrBack,
    1508                   lpBand->rcBand.left,lpBand->rcBand.top,
    1509                   lpBand->rcBand.right,lpBand->rcBand.bottom,
    1510                   clip->left, clip->top,
    1511                   clip->right, clip->bottom);
    1512             FillRect ( (HDC)wParam, &eraserect, brh);
    1513             DeleteObject (brh);
    1514           }
    1515         }
     1934        if (HIDDENBAND(lpBand)) continue;
     1935
     1936        /* draw band separator between rows */
     1937        if (lpBand->iRow != oldrow) {
     1938            oldrow = lpBand->iRow;
     1939            if (lpBand->fDraw & DRAW_BOTTOMSEP) {
     1940                RECT rcRowSep;
     1941                rcRowSep = lpBand->rcBand;
     1942                if (infoPtr->dwStyle & CCS_VERT) {
     1943                    rcRowSep.right += SEP_WIDTH_SIZE;
     1944                    rcRowSep.bottom = infoPtr->calcSize.cy;
     1945                    DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT);
     1946                }
     1947                else {
     1948                    rcRowSep.bottom += SEP_WIDTH_SIZE;
     1949                    rcRowSep.right = infoPtr->calcSize.cx;
     1950                    DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM);
     1951                }
     1952                TRACE ("drawing band separator bottom (%d,%d)-(%d,%d)\n",
     1953                       rcRowSep.left, rcRowSep.top,
     1954                       rcRowSep.right, rcRowSep.bottom);
     1955            }
     1956        }
     1957
     1958        /* draw band separator between bands in a row */
     1959        if (lpBand->fDraw & DRAW_RIGHTSEP) {
     1960            RECT rcSep;
     1961            rcSep = lpBand->rcBand;
     1962            if (infoPtr->dwStyle & CCS_VERT) {
     1963                rcSep.bottom += SEP_WIDTH_SIZE;
     1964                DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM);
     1965            }
     1966            else {
     1967                rcSep.right += SEP_WIDTH_SIZE;
     1968                DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT);
     1969            }
     1970            TRACE("drawing band separator right (%d,%d)-(%d,%d)\n",
     1971                  rcSep.left, rcSep.top, rcSep.right, rcSep.bottom);
     1972        }
     1973
     1974        /* draw the actual background */
     1975        if (lpBand->clrBack != CLR_NONE)
     1976            new = lpBand->clrBack;
     1977        else
     1978            new = infoPtr->clrBtnFace;
     1979        rect = lpBand->rcBand;
     1980        old = SetBkColor (hdc, new);
     1981        TRACE("%s backround color=0x%06lx, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
     1982              (lpBand->clrBack == CLR_NONE) ? "std" : "",
     1983              new,
     1984              lpBand->rcBand.left,lpBand->rcBand.top,
     1985              lpBand->rcBand.right,lpBand->rcBand.bottom,
     1986              clip->left, clip->top,
     1987              clip->right, clip->bottom);
     1988        ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0);
     1989        SetBkColor (hdc, old);
    15161990    }
    15171991    return TRUE;
     
    15191993
    15201994static void
    1521 REBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt, UINT *pFlags, INT *pBand)
    1522 {
    1523     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     1995REBAR_InternalHitTest (REBAR_INFO *infoPtr, LPPOINT lpPt, UINT *pFlags, INT *pBand)
     1996{
    15241997    REBAR_BAND *lpBand;
    15251998    RECT rect;
    15261999    INT  iCount;
    15272000
    1528     GetClientRect (hwnd, &rect);
     2001    GetClientRect (infoPtr->hwndSelf, &rect);
    15292002
    15302003    *pFlags = RBHT_NOWHERE;
     
    15432016            for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
    15442017                lpBand = &infoPtr->bands[iCount];
     2018                if (HIDDENBAND(lpBand)) continue;
    15452019                if (PtInRect (&lpBand->rcBand, *lpPt)) {
    15462020                    if (pBand)
     
    15952069}
    15962070
    1597 #define READJ(b,i) {if(dwStyle & CCS_VERT) b->rcBand.bottom+=(i); \
    1598                     else b->rcBand.right += (i);}
    1599 #define LEADJ(b,i) {if(dwStyle & CCS_VERT) b->rcBand.top+=(i); \
    1600                     else b->rcBand.left += (i);}
    1601 
    16022071
    16032072static INT
    1604 REBAR_Shrink (REBAR_BAND *band, INT movement, INT i, DWORD dwStyle)
     2073REBAR_Shrink (REBAR_INFO *infoPtr, REBAR_BAND *band, INT movement, INT i)
    16052074     /* Function:  This attempts to shrink the given band by the  */
    16062075     /*  the amount in "movement". A shrink to the left is indi-  */
     
    16152084    /*       it is then the band does not move.                      */
    16162085
    1617     avail = rcBrb(band) - rcBlt(band) - band->cxHeader - band->lcx;
     2086    avail = rcBw(band) - band->lcx;
    16182087
    16192088    /* now compute the Left End adjustment factor and Right End */
     
    16712140
    16722141static void
    1673 REBAR_HandleLRDrag (HWND hwnd, REBAR_INFO *infoPtr, POINTS *ptsmove, DWORD dwStyle)
     2142REBAR_HandleLRDrag (REBAR_INFO *infoPtr, POINTS *ptsmove)
    16742143     /* Function:  This will implement the functionality of a     */
    16752144     /*  Gripper drag within a row. It will not implement "out-   */
     
    16792148     /*  ****       yet implemented.                        ****  */
    16802149{
    1681     REBAR_BAND *hitBand, *band, *prevband, *mindBand, *maxdBand;
    1682     HDWP deferpos;
    1683     NMREBARCHILDSIZE cs;
     2150    REBAR_BAND *hitBand, *band, *mindBand, *maxdBand;
    16842151    RECT newrect;
    1685     INT imindBand = -1, imaxdBand, ihitBand, i, movement, tempx;
     2152    INT imindBand = -1, imaxdBand, ihitBand, i, movement;
    16862153    INT RHeaderSum = 0, LHeaderSum = 0;
    16872154    INT compress;
     
    16902157
    16912158    if (!(infoPtr->fStatus & BEGIN_DRAG_ISSUED)) {
    1692         if (REBAR_Notify_NMREBAR (hwnd, infoPtr, -1, RBN_BEGINDRAG)) {
     2159        if (REBAR_Notify_NMREBAR (infoPtr, -1, RBN_BEGINDRAG)) {
    16932160            /* Notify returned TRUE - abort drag */
    16942161            infoPtr->dragStart.x = 0;
     
    17172184            /* a one to separate each band.                                */
    17182185            if (i < ihitBand)
    1719                 LHeaderSum += (band->cxHeader + band->lcx + SEP_WIDTH);
     2186                LHeaderSum += (band->lcx + SEP_WIDTH);
    17202187            else
    1721                 RHeaderSum += (band->cxHeader + band->lcx + SEP_WIDTH);
     2188                RHeaderSum += (band->lcx + SEP_WIDTH);
    17222189
    17232190        }
     
    17382205        return; /* should swap bands */
    17392206
    1740     if (dwStyle & CCS_VERT)
     2207    if (infoPtr->dwStyle & CCS_VERT)
    17412208        movement = ptsmove->y - ((hitBand->rcBand.top+REBAR_PRE_GRIPPER) -
    17422209                             infoPtr->ihitoffset);
     
    17492216          movement, ptsmove->x, ptsmove->y, imindBand, ihitBand,
    17502217          imaxdBand, LHeaderSum, RHeaderSum);
    1751     REBAR_DumpBand (hwnd);
     2218    REBAR_DumpBand (infoPtr);
    17522219
    17532220    if (movement < 0) { 
     
    17612228            movement = -compress;
    17622229        }
     2230
    17632231        for (i=ihitBand; i>=imindBand; i--) {
    17642232            band = &infoPtr->bands[i];
     2233            if (HIDDENBAND(band)) continue;
    17652234            if (i == ihitBand) {
    1766                 prevband = &infoPtr->bands[i-1];
    1767                 if (rcBlt(band) - movement <= rcBlt(prevband)) {
    1768                     tempx = movement - (rcBrb(prevband)-rcBlt(band)+1);
    1769                     ERR("movement bad. BUG!! was %d, left=%d, right=%d, setting to %d\n",
    1770                         movement, rcBlt(band), rcBlt(prevband), tempx);
    1771                     movement = tempx;
    1772                 }
    17732235                LEADJ(band, movement)
    17742236            }
    17752237            else
    1776                 movement = REBAR_Shrink (band, movement, i, dwStyle);
     2238                movement = REBAR_Shrink (infoPtr, band, movement, i);
     2239            band->ccx = rcBw(band);
    17772240        }
    17782241    }
    17792242    else {
     2243        BOOL first = TRUE;
    17802244
    17812245        /* ***  Drag right/down *** */
     
    17902254            band = &infoPtr->bands[i];
    17912255            if (HIDDENBAND(band)) continue;
    1792             if (i == ihitBand-1) {
     2256            if (first) {
     2257                first = FALSE;
    17932258                READJ(band, movement)
    17942259            }
    17952260            else
    1796                 movement = REBAR_Shrink (band, movement, i, dwStyle);
     2261                movement = REBAR_Shrink (infoPtr, band, movement, i);
     2262            band->ccx = rcBw(band);
    17972263        }
    17982264    }
    17992265
    18002266    /* recompute all rectangles */
    1801     if (dwStyle & CCS_VERT) {
    1802         REBAR_CalcVertBand (hwnd, infoPtr, imindBand, imaxdBand+1,
    1803                             FALSE, dwStyle);
     2267    if (infoPtr->dwStyle & CCS_VERT) {
     2268        REBAR_CalcVertBand (infoPtr, imindBand, imaxdBand+1,
     2269                            FALSE);
    18042270    }
    18052271    else {
    1806         REBAR_CalcHorzBand (hwnd, infoPtr, imindBand, imaxdBand+1,
    1807                             FALSE, dwStyle);
     2272        REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1,
     2273                            FALSE);
    18082274    }
    18092275
    18102276    TRACE("bands after adjustment, see band # %d, %d\n",
    18112277          imindBand, imaxdBand);
    1812     REBAR_DumpBand (hwnd);
     2278    REBAR_DumpBand (infoPtr);
    18132279
    18142280    SetRect (&newrect,
     
    18182284             maxdBand->rcBand.bottom);
    18192285
    1820     if (!(deferpos = BeginDeferWindowPos (4))) {
    1821         ERR("BeginDeferWindowPos returned NULL\n");
    1822     }
    1823 
    1824     for (i=imindBand; i<=imaxdBand; i++) {
    1825         band = &infoPtr->bands[i];
    1826         if ((band->fMask & RBBIM_CHILD) && band->hwndChild) {
    1827             cs.uBand = i;
    1828             cs.wID = band->wID;
    1829             cs.rcChild = band->rcChild;
    1830             cs.rcBand = band->rcBand;
    1831             cs.rcBand.left += band->cxHeader;
    1832             REBAR_Notify (hwnd, (NMHDR *) &cs, infoPtr, RBN_CHILDSIZE);
    1833             deferpos = DeferWindowPos (deferpos, band->hwndChild, HWND_TOP,
    1834                                        cs.rcChild.left, cs.rcChild.top,
    1835                                        cs.rcChild.right - cs.rcChild.left,
    1836                                        cs.rcChild.bottom - cs.rcChild.top,
    1837                                        SWP_NOZORDER);
    1838             if (!deferpos) {
    1839                 ERR("DeferWindowPos returned NULL\n");
    1840             }
    1841         }
    1842     }
    1843 
    1844     if (!EndDeferWindowPos (deferpos)) {
    1845         ERR("EndDeferWindowPos failed\n");
    1846     }
    1847 
    1848     InvalidateRect (hwnd, &newrect, TRUE);
    1849     UpdateWindow (hwnd);
    1850 
    1851 }
    1852 #undef READJ
    1853 #undef LEADJ
     2286    REBAR_MoveChildWindows (infoPtr, imindBand, imaxdBand+1);
     2287
     2288    InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
     2289    UpdateWindow (infoPtr->hwndSelf);
     2290
     2291}
    18542292
    18552293
     
    18592297
    18602298static LRESULT
    1861 REBAR_DeleteBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1862 {
    1863     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     2299REBAR_DeleteBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     2300{
    18642301    UINT uBand = (UINT)wParam;
    18652302    HWND childhwnd = 0;
     
    18712308    TRACE("deleting band %u!\n", uBand);
    18722309    lpBand = &infoPtr->bands[uBand];
    1873     REBAR_Notify_NMREBAR (hwnd, infoPtr, uBand, RBN_DELETINGBAND);
     2310    REBAR_Notify_NMREBAR (infoPtr, uBand, RBN_DELETINGBAND);
    18742311
    18752312    if (infoPtr->uNumBands == 1) {
     
    19062343        ShowWindow (childhwnd, SW_HIDE);
    19072344
    1908     REBAR_Notify_NMREBAR (hwnd, infoPtr, -1, RBN_DELETEDBAND);
     2345    REBAR_Notify_NMREBAR (infoPtr, -1, RBN_DELETEDBAND);
    19092346
    19102347    /* if only 1 band left the re-validate to possible eliminate gripper */
    19112348    if (infoPtr->uNumBands == 1)
    1912       REBAR_ValidateBand (hwnd, infoPtr, &infoPtr->bands[0]);
    1913 
    1914     REBAR_Layout (hwnd, NULL, TRUE, FALSE);
     2349      REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
     2350
     2351    TRACE("setting NEEDS_LAYOUT\n");
     2352    infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
    19152353    infoPtr->fStatus |= RESIZE_ANYHOW;
    1916     REBAR_ForceResize (hwnd);
    1917     REBAR_MoveChildWindows (hwnd);
     2354    REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
    19182355
    19192356    return TRUE;
     
    19262363
    19272364static LRESULT
    1928 REBAR_GetBandBorders (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1929 {
    1930     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     2365REBAR_GetBandBorders (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     2366{
    19312367    LPRECT lpRect = (LPRECT)lParam;
    19322368    REBAR_BAND *lpBand;
    1933     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    19342369
    19352370    if (!lParam)
     
    19452380    /* difference in size of the control area with and without the     */
    19462381    /* style.  -  GA                                                   */
    1947     if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_BANDBORDERS) {
    1948         if (dwStyle & CCS_VERT) {
     2382    if (infoPtr->dwStyle & RBS_BANDBORDERS) {
     2383        if (infoPtr->dwStyle & CCS_VERT) {
    19492384            lpRect->left = 1;
    19502385            lpRect->top = lpBand->cxHeader + 4;
     
    19622397        lpRect->left = lpBand->cxHeader;
    19632398    }
    1964     FIXME("stub\n");
    19652399    return 0;
    19662400}
     
    19682402
    19692403inline static LRESULT
    1970 REBAR_GetBandCount (HWND hwnd)
    1971 {
    1972     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    1973 
     2404REBAR_GetBandCount (REBAR_INFO *infoPtr)
     2405{
    19742406    TRACE("band count %u!\n", infoPtr->uNumBands);
    19752407
     
    19792411
    19802412static LRESULT
    1981 REBAR_GetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1982 {
    1983     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     2413REBAR_GetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     2414{
    19842415    LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
    19852416    REBAR_BAND *lpBand;
     
    20042435        lprbbi->clrBack = lpBand->clrBack;
    20052436        if (lprbbi->clrBack == CLR_NONE)
    2006             lprbbi->clrBack = GetSysColor (COLOR_BTNFACE);
     2437            lprbbi->clrBack = infoPtr->clrBtnFace;
    20072438    }
    20082439
     
    20662497
    20672498static LRESULT
    2068 REBAR_GetBandInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2069 {
    2070     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     2499REBAR_GetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     2500{
    20712501    LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
    20722502    REBAR_BAND *lpBand;
     
    20912521        lprbbi->clrBack = lpBand->clrBack;
    20922522        if (lprbbi->clrBack == CLR_NONE)
    2093             lprbbi->clrBack = GetSysColor (COLOR_BTNFACE);
     2523            lprbbi->clrBack = infoPtr->clrBtnFace;
    20942524    }
    20952525
     
    21492579
    21502580static LRESULT
    2151 REBAR_GetBarHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2152 {
    2153     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     2581REBAR_GetBarHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     2582{
    21542583    INT nHeight;
    2155     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    2156 
    2157     nHeight = (dwStyle & CCS_VERT) ? infoPtr->calcSize.cx : infoPtr->calcSize.cy;
     2584
     2585    nHeight = (infoPtr->dwStyle & CCS_VERT) ? infoPtr->calcSize.cx : infoPtr->calcSize.cy;
    21582586
    21592587    TRACE("height = %d\n", nHeight);
     
    21642592
    21652593static LRESULT
    2166 REBAR_GetBarInfo (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2167 {
    2168     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     2594REBAR_GetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     2595{
    21692596    LPREBARINFO lpInfo = (LPREBARINFO)lParam;
    21702597
     
    21872614
    21882615inline static LRESULT
    2189 REBAR_GetBkColor (HWND hwnd)
    2190 {
    2191     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     2616REBAR_GetBkColor (REBAR_INFO *infoPtr)
     2617{
    21922618    COLORREF clr = infoPtr->clrBk;
    21932619
    21942620    if (clr == CLR_NONE)
    2195       clr = GetSysColor (COLOR_BTNFACE);
     2621      clr = infoPtr->clrBtnFace;
    21962622
    21972623    TRACE("background color 0x%06lx!\n", clr);
     
    22062632
    22072633static LRESULT
    2208 REBAR_GetPalette (HWND hwnd, WPARAM wParam, LPARAM lParam)
     2634REBAR_GetPalette (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
    22092635{
    22102636    FIXME("empty stub!\n");
     
    22152641
    22162642static LRESULT
    2217 REBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2218 {
    2219     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     2643REBAR_GetRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     2644{
    22202645    INT iBand = (INT)wParam;
    22212646    LPRECT lprc = (LPRECT)lParam;
     
    22382663
    22392664inline static LRESULT
    2240 REBAR_GetRowCount (HWND hwnd)
    2241 {
    2242     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    2243 
     2665REBAR_GetRowCount (REBAR_INFO *infoPtr)
     2666{
    22442667    TRACE("%u\n", infoPtr->uNumRows);
    22452668
     
    22492672
    22502673static LRESULT
    2251 REBAR_GetRowHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2252 {
    2253     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     2674REBAR_GetRowHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     2675{
    22542676    INT iRow = (INT)wParam;
    22552677    int ret = 0;
    22562678    int i, j = 0;
    22572679    REBAR_BAND *lpBand;
    2258     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    22592680
    22602681    for (i=0; i<infoPtr->uNumBands; i++) {
    2261       lpBand = &infoPtr->bands[i];
    2262       if (HIDDENBAND(lpBand)) continue;
    2263       if (lpBand->iRow != iRow) continue;
    2264       if (dwStyle & CCS_VERT)
    2265         j = lpBand->rcBand.right - lpBand->rcBand.left;
    2266       else
    2267         j = lpBand->rcBand.bottom - lpBand->rcBand.top;
    2268       if (j > ret) ret = j;
     2682        lpBand = &infoPtr->bands[i];
     2683        if (HIDDENBAND(lpBand)) continue;
     2684        if (lpBand->iRow != iRow) continue;
     2685        if (infoPtr->dwStyle & CCS_VERT)
     2686            j = lpBand->rcBand.right - lpBand->rcBand.left;
     2687        else
     2688            j = lpBand->rcBand.bottom - lpBand->rcBand.top;
     2689        if (j > ret) ret = j;
    22692690    }
    22702691
     
    22762697
    22772698inline static LRESULT
    2278 REBAR_GetTextColor (HWND hwnd)
    2279 {
    2280     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    2281 
     2699REBAR_GetTextColor (REBAR_INFO *infoPtr)
     2700{
    22822701    TRACE("text color 0x%06lx!\n", infoPtr->clrText);
    22832702
     
    22872706
    22882707inline static LRESULT
    2289 REBAR_GetToolTips (HWND hwnd)
    2290 {
    2291     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     2708REBAR_GetToolTips (REBAR_INFO *infoPtr)
     2709{
    22922710    return infoPtr->hwndToolTip;
    22932711}
     
    22952713
    22962714inline static LRESULT
    2297 REBAR_GetUnicodeFormat (HWND hwnd)
    2298 {
    2299     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     2715REBAR_GetUnicodeFormat (REBAR_INFO *infoPtr)
     2716{
     2717    TRACE("%s hwnd=0x%x\n",
     2718          infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf);
     2719
    23002720    return infoPtr->bUnicode;
    23012721}
     
    23032723
    23042724inline static LRESULT
    2305 REBAR_GetVersion (HWND hwnd)
    2306 {
    2307     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     2725REBAR_GetVersion (REBAR_INFO *infoPtr)
     2726{
    23082727    TRACE("version %d\n", infoPtr->iVersion);
    23092728    return infoPtr->iVersion;
     
    23122731
    23132732static LRESULT
    2314 REBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2315 {
    2316     /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
     2733REBAR_HitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     2734{
    23172735    LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
    23182736
     
    23202738        return -1;
    23212739
    2322     REBAR_InternalHitTest (hwnd, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
     2740    REBAR_InternalHitTest (infoPtr, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
    23232741
    23242742    return lprbht->iBand;
     
    23272745
    23282746static LRESULT
    2329 REBAR_IdToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2330 {
    2331     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     2747REBAR_IdToIndex (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     2748{
    23322749    UINT i;
    23332750
     
    23512768
    23522769static LRESULT
    2353 REBAR_InsertBandA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2354 {
    2355     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     2770REBAR_InsertBandA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     2771{
    23562772    LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
    23572773    UINT uIndex = (UINT)wParam;
     
    24082824    lpBand->hwndPrevParent = 0;
    24092825
    2410     REBAR_CommonSetupBand (hwnd, lprbbi, lpBand);
     2826    REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
    24112827    lpBand->lpText = NULL;
    24122828    if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
     
    24182834    }
    24192835
    2420     REBAR_ValidateBand (hwnd, infoPtr, lpBand);
     2836    REBAR_ValidateBand (infoPtr, lpBand);
    24212837    /* On insert of second band, revalidate band 1 to possible add gripper */
    24222838    if (infoPtr->uNumBands == 2)
    2423         REBAR_ValidateBand (hwnd, infoPtr, &infoPtr->bands[0]);
    2424 
    2425     REBAR_DumpBand (hwnd);
    2426 
    2427     REBAR_Layout (hwnd, NULL, TRUE, FALSE);
    2428     REBAR_ForceResize (hwnd);
    2429     REBAR_MoveChildWindows (hwnd);
     2839        REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
     2840
     2841    REBAR_DumpBand (infoPtr);
     2842
     2843    REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
    24302844
    24312845    return TRUE;
     
    24342848
    24352849static LRESULT
    2436 REBAR_InsertBandW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2437 {
    2438     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     2850REBAR_InsertBandW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     2851{
    24392852    LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
    24402853    UINT uIndex = (UINT)wParam;
     
    24912904    lpBand->hwndPrevParent = 0;
    24922905
    2493     REBAR_CommonSetupBand (hwnd, (LPREBARBANDINFOA)lprbbi, lpBand);
     2906    REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
    24942907    lpBand->lpText = NULL;
    24952908    if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
     
    25012914    }
    25022915
    2503     REBAR_ValidateBand (hwnd, infoPtr, lpBand);
     2916    REBAR_ValidateBand (infoPtr, lpBand);
    25042917    /* On insert of second band, revalidate band 1 to possible add gripper */
    25052918    if (infoPtr->uNumBands == 2)
    2506         REBAR_ValidateBand (hwnd, infoPtr, &infoPtr->bands[0]);
    2507 
    2508     REBAR_DumpBand (hwnd);
    2509 
    2510     REBAR_Layout (hwnd, NULL, TRUE, FALSE);
    2511     REBAR_ForceResize (hwnd);
    2512     REBAR_MoveChildWindows (hwnd);
     2919        REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
     2920
     2921    REBAR_DumpBand (infoPtr);
     2922
     2923    REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
    25132924
    25142925    return TRUE;
     
    25172928
    25182929static LRESULT
    2519 REBAR_MaximizeBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2520 {
    2521 /*    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
    2522 
     2930REBAR_MaximizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     2931{
    25232932    FIXME("(uBand = %u fIdeal = %s) stub\n",
    25242933           (UINT)wParam, lParam ? "TRUE" : "FALSE");
    25252934
    2526  
    25272935    return 0;
     2936
    25282937}
    25292938
    25302939
    25312940static LRESULT
    2532 REBAR_MinimizeBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2533 {
    2534 /*    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
    2535 
    2536     FIXME("(uBand = %u) stub\n", (UINT)wParam);
    2537 
    2538  
    2539     return 0;
     2941REBAR_MinimizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     2942{
     2943    REBAR_BAND *band, *lpBand;
     2944    UINT uBand = (UINT) wParam;
     2945    RECT newrect;
     2946    INT imindBand, imaxdBand, iprevBand, startBand, endBand;
     2947    INT movement, i;
     2948
     2949    /* A "minimize" band is equivalent to "dragging" the gripper
     2950     * of than band to the right till the band is only the size
     2951     * of the cxHeader.
     2952     */
     2953
     2954    /* Validate */
     2955    if ((infoPtr->uNumBands == 0) ||
     2956        ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
     2957        /* error !!! */
     2958        ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
     2959              (INT)uBand, infoPtr->uNumBands);
     2960        return FALSE;
     2961    }
     2962
     2963    /* compute amount of movement and validate */
     2964    lpBand = &infoPtr->bands[uBand];
     2965
     2966    if (infoPtr->dwStyle & CCS_VERT)
     2967        movement = lpBand->rcBand.bottom - lpBand->rcBand.top -
     2968            lpBand->cxHeader;
     2969    else
     2970        movement = lpBand->rcBand.right - lpBand->rcBand.left -
     2971            lpBand->cxHeader;
     2972    if (movement < 0) {
     2973        ERR("something is wrong, band=(%d,%d)-(%d,%d), cxheader=%d\n",
     2974            lpBand->rcBand.left, lpBand->rcBand.top,
     2975            lpBand->rcBand.right, lpBand->rcBand.bottom,
     2976            lpBand->cxHeader);
     2977        return FALSE;
     2978    }
     2979
     2980    imindBand = -1;
     2981    imaxdBand = -1;
     2982    iprevBand = -1; /* to suppress warning message */
     2983
     2984    /* find the first band in row of the one whose is being minimized */
     2985    for (i=0; i<infoPtr->uNumBands; i++) {
     2986        band = &infoPtr->bands[i];
     2987        if (HIDDENBAND(band)) continue;
     2988        if (band->iRow == lpBand->iRow) {
     2989            imaxdBand = i;
     2990            if (imindBand == -1) imindBand = i;
     2991        }
     2992    }
     2993
     2994    /* if the selected band is first in row then need to expand */
     2995    /* next visible band                                        */
     2996    if (imindBand == uBand) {
     2997        band = NULL;
     2998        movement = -movement;
     2999        /* find the first visible band to the right of the selected band */
     3000        for (i=uBand+1; i<=imaxdBand; i++) {
     3001            band = &infoPtr->bands[i];
     3002            if (!HIDDENBAND(band)) {
     3003                iprevBand = i;
     3004                LEADJ(band, movement);
     3005                band->ccx = rcBw(band);
     3006                break;
     3007            }
     3008        }
     3009        /* what case is this */
     3010        if (iprevBand == -1) {
     3011            ERR("no previous visible band\n");
     3012            return FALSE;
     3013        }
     3014        startBand = uBand;
     3015        endBand = iprevBand;
     3016        SetRect (&newrect,
     3017                 lpBand->rcBand.left,
     3018                 lpBand->rcBand.top,
     3019                 band->rcBand.right,
     3020                 band->rcBand.bottom);
     3021    }
     3022    /* otherwise expand previous visible band                   */
     3023    else {
     3024        band = NULL;
     3025        /* find the first visible band to the left of the selected band */
     3026        for (i=uBand-1; i>=imindBand; i--) {
     3027            band = &infoPtr->bands[i];
     3028            if (!HIDDENBAND(band)) {
     3029                iprevBand = i;
     3030                READJ(band, movement);
     3031                band->ccx = rcBw(band);
     3032                break;
     3033            }
     3034        }
     3035        /* what case is this */
     3036        if (iprevBand == -1) {
     3037            ERR("no previous visible band\n");
     3038            return FALSE;
     3039        }
     3040        startBand = iprevBand;
     3041        endBand = uBand;
     3042        SetRect (&newrect,
     3043                 band->rcBand.left,
     3044                 band->rcBand.top,
     3045                 lpBand->rcBand.right,
     3046                 lpBand->rcBand.bottom);
     3047    }
     3048
     3049    REBAR_Shrink (infoPtr, lpBand, movement, uBand);
     3050
     3051    /* recompute all rectangles */
     3052    if (infoPtr->dwStyle & CCS_VERT) {
     3053        REBAR_CalcVertBand (infoPtr, startBand, endBand+1,
     3054                            FALSE);
     3055    }
     3056    else {
     3057        REBAR_CalcHorzBand (infoPtr, startBand, endBand+1,
     3058                            FALSE);
     3059    }
     3060
     3061    TRACE("bands after minimize, see band # %d, %d\n",
     3062          startBand, endBand);
     3063    REBAR_DumpBand (infoPtr);
     3064
     3065    REBAR_MoveChildWindows (infoPtr, startBand, endBand+1);
     3066
     3067    InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
     3068    UpdateWindow (infoPtr->hwndSelf);
     3069    return FALSE;
    25403070}
    25413071
    25423072
    25433073static LRESULT
    2544 REBAR_MoveBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2545 {
    2546 /*    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
    2547 
    2548     FIXME("(iFrom = %u iTof = %u) stub\n",
    2549            (UINT)wParam, (UINT)lParam);
    2550 
    2551  
    2552     return FALSE;
     3074REBAR_MoveBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3075{
     3076    REBAR_BAND *oldBands = infoPtr->bands;
     3077    REBAR_BAND holder;
     3078    UINT uFrom = (UINT)wParam;
     3079    UINT uTo = (UINT)lParam;
     3080
     3081    /* Validate */
     3082    if ((infoPtr->uNumBands == 0) ||
     3083        ((INT)uFrom < 0) || (uFrom >= infoPtr->uNumBands) ||
     3084        ((INT)uTo < 0)   || (uTo >= infoPtr->uNumBands)) {
     3085        /* error !!! */
     3086        ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
     3087              (INT)uFrom, (INT)uTo, infoPtr->uNumBands);
     3088        return FALSE;
     3089    }
     3090
     3091    /* save one to be moved */
     3092    memcpy (&holder, &oldBands[uFrom], sizeof(REBAR_BAND));
     3093
     3094    /* close up rest of bands (psuedo delete) */
     3095    if (uFrom < infoPtr->uNumBands - 1) {
     3096        memcpy (&oldBands[uFrom], &oldBands[uFrom+1],
     3097                (infoPtr->uNumBands - uFrom - 1) * sizeof(REBAR_BAND));
     3098    }
     3099
     3100    /* allocate new space and copy rest of bands into it */
     3101    infoPtr->bands =
     3102        (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND));
     3103
     3104    /* pre insert copy */
     3105    if (uTo > 0) {
     3106        memcpy (&infoPtr->bands[0], &oldBands[0],
     3107                uTo * sizeof(REBAR_BAND));
     3108    }
     3109
     3110    /* set moved band */
     3111    memcpy (&infoPtr->bands[uTo], &holder, sizeof(REBAR_BAND));
     3112
     3113    /* post copy */
     3114    if (uTo < infoPtr->uNumBands - 1) {
     3115        memcpy (&infoPtr->bands[uTo+1], &oldBands[uTo],
     3116                (infoPtr->uNumBands - uTo - 1) * sizeof(REBAR_BAND));
     3117    }
     3118
     3119    COMCTL32_Free (oldBands);
     3120
     3121    TRACE("moved band %d to index %d\n", uFrom, uTo);
     3122    REBAR_DumpBand (infoPtr);
     3123
     3124    infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
     3125    /* **************************************************** */
     3126    /*                                                      */
     3127    /* We do not do a REBAR_Layout here because the native  */
     3128    /* control does not do that. The actual layout and      */
     3129    /* repaint is done by the *next* real action, ex.:      */
     3130    /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc.    */
     3131    /*                                                      */
     3132    /* **************************************************** */
     3133
     3134    return TRUE;
    25533135}
    25543136
    25553137
    25563138static LRESULT
    2557 REBAR_SetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2558 {
    2559     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     3139REBAR_SetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3140{
    25603141    LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
    25613142    REBAR_BAND *lpBand;
     
    25743155    lpBand = &infoPtr->bands[(UINT)wParam];
    25753156
    2576     REBAR_CommonSetupBand (hwnd, lprbbi, lpBand);
     3157    REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
    25773158    if (lprbbi->fMask & RBBIM_TEXT) {
    25783159        if (lpBand->lpText) {
     
    25873168    }
    25883169
    2589     REBAR_ValidateBand (hwnd, infoPtr, lpBand);
    2590 
    2591     REBAR_DumpBand (hwnd);
    2592 
    2593     if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) {
    2594       REBAR_Layout (hwnd, NULL, TRUE, FALSE);
    2595       REBAR_ForceResize (hwnd);
    2596       REBAR_MoveChildWindows (hwnd);
    2597     }
     3170    REBAR_ValidateBand (infoPtr, lpBand);
     3171
     3172    REBAR_DumpBand (infoPtr);
     3173
     3174    if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE))
     3175          REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
    25983176
    25993177    return TRUE;
     
    26023180
    26033181static LRESULT
    2604 REBAR_SetBandInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2605 {
    2606     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     3182REBAR_SetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3183{
    26073184    LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
    26083185    REBAR_BAND *lpBand;
     
    26213198    lpBand = &infoPtr->bands[(UINT)wParam];
    26223199
    2623     REBAR_CommonSetupBand (hwnd, (LPREBARBANDINFOA)lprbbi, lpBand);
     3200    REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
    26243201    if (lprbbi->fMask & RBBIM_TEXT) {
    26253202        if (lpBand->lpText) {
     
    26343211    }
    26353212
    2636     REBAR_ValidateBand (hwnd, infoPtr, lpBand);
    2637 
    2638     REBAR_DumpBand (hwnd);
    2639 
    2640     if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) {
    2641       REBAR_Layout (hwnd, NULL, TRUE, FALSE);
    2642       REBAR_ForceResize (hwnd);
    2643       REBAR_MoveChildWindows (hwnd);
    2644     }
     3213    REBAR_ValidateBand (infoPtr, lpBand);
     3214
     3215    REBAR_DumpBand (infoPtr);
     3216
     3217    if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE))
     3218      REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
    26453219
    26463220    return TRUE;
     
    26493223
    26503224static LRESULT
    2651 REBAR_SetBarInfo (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2652 {
    2653     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     3225REBAR_SetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3226{
    26543227    LPREBARINFO lpInfo = (LPREBARINFO)lParam;
    26553228    REBAR_BAND *lpBand;
     
    26833256    for (i=0; i<infoPtr->uNumBands; i++) {
    26843257        lpBand = &infoPtr->bands[i];
    2685         REBAR_ValidateBand (hwnd, infoPtr, lpBand);
     3258        REBAR_ValidateBand (infoPtr, lpBand);
    26863259    }
    26873260
     
    26913264
    26923265static LRESULT
    2693 REBAR_SetBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2694 {
    2695     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     3266REBAR_SetBkColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3267{
    26963268    COLORREF clrTemp;
    26973269
     
    27103282
    27113283static LRESULT
    2712 REBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2713 {
    2714     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     3284REBAR_SetParent (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3285{
    27153286    HWND hwndTemp = infoPtr->hwndNotify;
    27163287
     
    27223293
    27233294static LRESULT
    2724 REBAR_SetTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2725 {
    2726     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     3295REBAR_SetTextColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3296{
    27273297    COLORREF clrTemp;
    27283298
     
    27403310
    27413311inline static LRESULT
    2742 REBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam)
    2743 {
    2744     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     3312REBAR_SetUnicodeFormat (REBAR_INFO *infoPtr, WPARAM wParam)
     3313{
    27453314    BOOL bTemp = infoPtr->bUnicode;
     3315
     3316    TRACE("to %s hwnd=0x%04x, was %s\n",
     3317          ((BOOL)wParam) ? "TRUE" : "FALSE", infoPtr->hwndSelf,
     3318          (bTemp) ? "TRUE" : "FALSE");
     3319
    27463320    infoPtr->bUnicode = (BOOL)wParam;
    2747     return bTemp;
     3321 
     3322   return bTemp;
    27483323}
    27493324
    27503325
    27513326static LRESULT
    2752 REBAR_SetVersion (HWND hwnd, INT iVersion)
    2753 {
    2754     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     3327REBAR_SetVersion (REBAR_INFO *infoPtr, INT iVersion)
     3328{
    27553329    INT iOldVersion = infoPtr->iVersion;
    27563330
     
    27673341
    27683342static LRESULT
    2769 REBAR_ShowBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2770 {
    2771     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     3343REBAR_ShowBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3344{
    27723345    REBAR_BAND *lpBand;
    27733346
     
    27903363    }
    27913364
    2792     REBAR_Layout (hwnd, NULL, TRUE, FALSE);
    2793     REBAR_ForceResize (hwnd);
    2794     REBAR_MoveChildWindows (hwnd);
     3365    REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
    27953366
    27963367    return TRUE;
     
    27993370
    28003371static LRESULT
    2801 REBAR_SizeToRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
     3372REBAR_SizeToRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
    28023373{
    28033374    LPRECT lpRect = (LPRECT)lParam;
     
    28113382
    28123383    /*  what is going on???? */
    2813     GetWindowRect(hwnd, &t1);
     3384    GetWindowRect(infoPtr->hwndSelf, &t1);
    28143385    TRACE("window rect [%d %d %d %d]\n",
    28153386          t1.left, t1.top, t1.right, t1.bottom);
    2816     GetClientRect(hwnd, &t1);
     3387    GetClientRect(infoPtr->hwndSelf, &t1);
    28173388    TRACE("client rect [%d %d %d %d]\n",
    28183389          t1.left, t1.top, t1.right, t1.bottom);
    28193390
    2820     REBAR_Layout (hwnd, lpRect, TRUE, FALSE);
    2821     REBAR_ForceResize (hwnd);
    2822     REBAR_MoveChildWindows (hwnd);
     3391    /* force full _Layout processing */
     3392    TRACE("setting NEEDS_LAYOUT\n");
     3393    infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
     3394    REBAR_Layout (infoPtr, lpRect, TRUE, FALSE);
     3395    InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
    28233396    return TRUE;
    28243397}
     
    28273400
    28283401static LRESULT
    2829 REBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2830 {
    2831     REBAR_INFO *infoPtr;
     3402REBAR_Create (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3403{
     3404    LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
     3405    RECT wnrc1, clrc1;
     3406
     3407    if (TRACE_ON(rebar)) {
     3408        GetWindowRect(infoPtr->hwndSelf, &wnrc1);
     3409        GetClientRect(infoPtr->hwndSelf, &clrc1);
     3410        TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
     3411              wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
     3412              clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
     3413              cs->x, cs->y, cs->cx, cs->cy);
     3414    }
     3415
     3416    TRACE("created!\n");
     3417    return 0;
     3418}
     3419
     3420
     3421static LRESULT
     3422REBAR_Destroy (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3423{
     3424    REBAR_BAND *lpBand;
     3425    INT i;
     3426
     3427
     3428    /* free rebar bands */
     3429    if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
     3430        /* clean up each band */
     3431        for (i = 0; i < infoPtr->uNumBands; i++) {
     3432            lpBand = &infoPtr->bands[i];
     3433
     3434            /* delete text strings */
     3435            if (lpBand->lpText) {
     3436                COMCTL32_Free (lpBand->lpText);
     3437                lpBand->lpText = NULL;
     3438            }
     3439            /* destroy child window */
     3440            DestroyWindow (lpBand->hwndChild);
     3441        }
     3442
     3443        /* free band array */
     3444        COMCTL32_Free (infoPtr->bands);
     3445        infoPtr->bands = NULL;
     3446    }
     3447
     3448    DeleteObject (infoPtr->hcurArrow);
     3449    DeleteObject (infoPtr->hcurHorz);
     3450    DeleteObject (infoPtr->hcurVert);
     3451    DeleteObject (infoPtr->hcurDrag);
     3452    SetWindowLongA (infoPtr->hwndSelf, 0, 0);
     3453
     3454    /* free rebar info data */
     3455    COMCTL32_Free (infoPtr);
     3456    TRACE("destroyed!\n");
     3457    return 0;
     3458}
     3459
     3460
     3461static LRESULT
     3462REBAR_EraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3463{
     3464    RECT cliprect;
     3465
     3466    if (GetClipBox ( (HDC)wParam, &cliprect))
     3467        return REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &cliprect);
     3468    return 0;
     3469}
     3470
     3471
     3472static LRESULT
     3473REBAR_GetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3474{
     3475    return (LRESULT)infoPtr->hFont;
     3476}
     3477
     3478
     3479static LRESULT
     3480REBAR_LButtonDown (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3481{
     3482    REBAR_BAND *lpBand;
     3483
     3484    /* If InternalHitTest did not find a hit on the Gripper, */
     3485    /* then ignore the button click.                         */
     3486    if (infoPtr->ihitBand == -1) return 0;
     3487
     3488    SetCapture (infoPtr->hwndSelf);
     3489
     3490    /* save off the LOWORD and HIWORD of lParam as initial x,y */
     3491    lpBand = &infoPtr->bands[infoPtr->ihitBand];
     3492    infoPtr->dragStart = MAKEPOINTS(lParam);
     3493    infoPtr->dragNow = infoPtr->dragStart;
     3494    if (infoPtr->dwStyle & CCS_VERT)
     3495        infoPtr->ihitoffset = infoPtr->dragStart.y - (lpBand->rcBand.top+REBAR_PRE_GRIPPER);
     3496    else
     3497        infoPtr->ihitoffset = infoPtr->dragStart.x - (lpBand->rcBand.left+REBAR_PRE_GRIPPER);
     3498
     3499    return 0;
     3500}
     3501
     3502
     3503static LRESULT
     3504REBAR_LButtonUp (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3505{
     3506    NMHDR layout;
     3507    RECT rect;
     3508    INT ihitBand;
     3509
     3510    /* If InternalHitTest did not find a hit on the Gripper, */
     3511    /* then ignore the button click.                         */
     3512    if (infoPtr->ihitBand == -1) return 0;
     3513
     3514    ihitBand = infoPtr->ihitBand;
     3515    infoPtr->dragStart.x = 0;
     3516    infoPtr->dragStart.y = 0;
     3517    infoPtr->dragNow = infoPtr->dragStart;
     3518    infoPtr->ihitBand = -1;
     3519
     3520    ReleaseCapture ();
     3521
     3522    if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) {
     3523        REBAR_Notify((NMHDR *) &layout, infoPtr, RBN_LAYOUTCHANGED);
     3524        REBAR_Notify_NMREBAR (infoPtr, ihitBand, RBN_ENDDRAG);
     3525        infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
     3526    }
     3527
     3528    GetClientRect(infoPtr->hwndSelf, &rect);
     3529    InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
     3530
     3531    return 0;
     3532}
     3533
     3534
     3535static LRESULT
     3536REBAR_MouseMove (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3537{
     3538    REBAR_BAND *band1, *band2;
     3539    POINTS ptsmove;
     3540
     3541    /* Validate entry as hit on Gripper has occured */
     3542    if (GetCapture() != infoPtr->hwndSelf) return 0;
     3543    if (infoPtr->ihitBand == -1) return 0;
     3544
     3545    ptsmove = MAKEPOINTS(lParam);
     3546
     3547    /* if mouse did not move much, exit */
     3548    if ((abs(ptsmove.x - infoPtr->dragNow.x) <= mindragx) &&
     3549        (abs(ptsmove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
     3550
     3551    band1 = &infoPtr->bands[infoPtr->ihitBand-1];
     3552    band2 = &infoPtr->bands[infoPtr->ihitBand];
     3553
     3554    /* Test for valid drag case - must not be first band in row */
     3555    if (infoPtr->dwStyle & CCS_VERT) {
     3556        if ((ptsmove.x < band2->rcBand.left) ||
     3557            (ptsmove.x > band2->rcBand.right) ||
     3558            ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
     3559            FIXME("Cannot drag to other rows yet!!\n");
     3560        }
     3561        else {
     3562            REBAR_HandleLRDrag (infoPtr, &ptsmove);
     3563        }
     3564    }
     3565    else {
     3566        if ((ptsmove.y < band2->rcBand.top) ||
     3567            (ptsmove.y > band2->rcBand.bottom) ||
     3568            ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
     3569            FIXME("Cannot drag to other rows yet!!\n");
     3570        }
     3571        else {
     3572            REBAR_HandleLRDrag (infoPtr, &ptsmove);
     3573        }
     3574    }
     3575    return 0;
     3576}
     3577
     3578
     3579inline static LRESULT
     3580REBAR_NCCalcSize (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3581{
     3582    ((LPRECT)lParam)->top    += GetSystemMetrics(SM_CYEDGE);
     3583    ((LPRECT)lParam)->bottom -= GetSystemMetrics(SM_CYEDGE);
     3584
     3585    /* While the code below seems to be the reasonable way of   */
     3586    /*  handling the WS_BORDER style, the native version (as    */
     3587    /*  of 4.71 seems to only do the above. Go figure!!         */
     3588#if 0
     3589    if (GetWindowLongA (infoPtr->hwndSelf, GWL_STYLE) & WS_BORDER) {
     3590        ((LPRECT)lParam)->left   += GetSystemMetrics(SM_CXEDGE);
     3591        ((LPRECT)lParam)->top    += GetSystemMetrics(SM_CYEDGE);
     3592        ((LPRECT)lParam)->right  -= GetSystemMetrics(SM_CXEDGE);
     3593        ((LPRECT)lParam)->bottom -= GetSystemMetrics(SM_CYEDGE);
     3594    }
     3595#endif
     3596
     3597    return 0;
     3598}
     3599
     3600
     3601static LRESULT
     3602REBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
     3603{
     3604    LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
     3605    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     3606    RECT wnrc1, clrc1;
     3607    INT i;
     3608
     3609    if (infoPtr != NULL) {
     3610        ERR("Strange info structure pointer *not* NULL\n");
     3611        return FALSE;
     3612    }
     3613
     3614    if (TRACE_ON(rebar)) {
     3615        GetWindowRect(hwnd, &wnrc1);
     3616        GetClientRect(hwnd, &clrc1);
     3617        TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
     3618              wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
     3619              clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
     3620              cs->x, cs->y, cs->cx, cs->cy);
     3621    }
    28323622
    28333623    /* allocate memory for info structure */
     
    28413631    /* initialize info structure - initial values are 0 */
    28423632    infoPtr->clrBk = CLR_NONE;
    2843     infoPtr->clrText = GetSysColor (COLOR_BTNTEXT);
     3633    infoPtr->clrText = CLR_NONE;
     3634    infoPtr->clrBtnText = GetSysColor (COLOR_BTNTEXT);
     3635    infoPtr->clrBtnFace = GetSysColor (COLOR_BTNFACE);
    28443636    infoPtr->ihitBand = -1;
    2845 
     3637    infoPtr->hwndSelf = hwnd;
     3638    infoPtr->DoRedraw = TRUE;
    28463639    infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA);
    28473640    infoPtr->hcurHorz  = LoadCursorA (0, IDC_SIZEWEA);
    28483641    infoPtr->hcurVert  = LoadCursorA (0, IDC_SIZENSA);
    28493642    infoPtr->hcurDrag  = LoadCursorA (0, IDC_SIZEA);
    2850 
    28513643    infoPtr->bUnicode = IsWindowUnicode (hwnd);
    2852 
    2853     if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_AUTOSIZE)
    2854         FIXME("style RBS_AUTOSIZE set!\n");
    2855 
    2856 #if 0
    2857     SendMessageA (hwnd, WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
    2858 #endif
    2859 
    2860     TRACE("created!\n");
    2861     return 0;
     3644    infoPtr->fStatus = CREATE_RUNNING;
     3645
     3646    /* issue WM_NOTIFYFORMAT to get unicode status of parent */
     3647    i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
     3648                     WM_NOTIFYFORMAT, hwnd, NF_QUERY);
     3649    if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
     3650        ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
     3651            i);
     3652        i = NFR_ANSI;
     3653    }
     3654    infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
     3655
     3656    /* add necessary styles to the requested styles */
     3657    infoPtr->dwStyle = cs->style | WS_VISIBLE | CCS_TOP;
     3658    SetWindowLongA (hwnd, GWL_STYLE, infoPtr->dwStyle);
     3659
     3660/* native does:
     3661            GetSysColor (numerous);
     3662            GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
     3663            GetStockObject (SYSTEM_FONT);
     3664           *SetWindowLong (hwnd, 0, info ptr);
     3665           *WM_NOTIFYFORMAT;
     3666           *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
     3667                                    WS_VISIBLE = 0x10000000;
     3668                                    CCS_TOP    = 0x00000001;
     3669            SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
     3670            CreateFontIndirect (lfCaptionFont from above);
     3671            GetDC ();
     3672            SelectObject (hdc, fontabove);
     3673            GetTextMetrics (hdc, );    guessing is tmHeight
     3674            SelectObject (hdc, oldfont);
     3675            ReleaseDC ();
     3676            GetWindowRect ();
     3677            MapWindowPoints (0, parent, rectabove, 2);
     3678            GetWindowRect ();
     3679            GetClientRect ();
     3680            ClientToScreen (clientrect);
     3681            SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
     3682 */
     3683    return TRUE;
    28623684}
    28633685
    28643686
    28653687static LRESULT
    2866 REBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2867 {
    2868     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    2869     REBAR_BAND *lpBand;
     3688REBAR_NCHitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3689{
     3690    NMMOUSE nmmouse;
     3691    POINTS shortpt;
     3692    POINT clpt, pt;
    28703693    INT i;
    2871 
    2872 
    2873     /* free rebar bands */
    2874     if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
    2875         /* clean up each band */
    2876         for (i = 0; i < infoPtr->uNumBands; i++) {
    2877             lpBand = &infoPtr->bands[i];
    2878 
    2879             /* delete text strings */
    2880             if (lpBand->lpText) {
    2881                 COMCTL32_Free (lpBand->lpText);
    2882                 lpBand->lpText = NULL;
    2883             }
    2884             /* destroy child window */
    2885             DestroyWindow (lpBand->hwndChild);
    2886         }
    2887 
    2888         /* free band array */
    2889         COMCTL32_Free (infoPtr->bands);
    2890         infoPtr->bands = NULL;
    2891     }
    2892 
    2893     DeleteObject (infoPtr->hcurArrow);
    2894     DeleteObject (infoPtr->hcurHorz);
    2895     DeleteObject (infoPtr->hcurVert);
    2896     DeleteObject (infoPtr->hcurDrag);
    2897 
    2898     /* free rebar info data */
    2899     COMCTL32_Free (infoPtr);
    2900     SetWindowLongA (hwnd, 0, 0);
    2901     TRACE("destroyed!\n");
    2902     return 0;
     3694    UINT scrap;
     3695    LRESULT ret = HTCLIENT;
     3696
     3697    /*
     3698     * Differences from doc at MSDN (as observed with version 4.71 of
     3699     *      comctl32.dll
     3700     * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
     3701     * 2. if band is not identified .dwItemSpec is 0xffffffff.
     3702     * 3. native always seems to return HTCLIENT if notify return is 0.
     3703     */
     3704
     3705    shortpt = MAKEPOINTS (lParam);
     3706    POINTSTOPOINT(pt, shortpt);
     3707    clpt = pt;
     3708    ScreenToClient (infoPtr->hwndSelf, &clpt);
     3709    REBAR_InternalHitTest (infoPtr, &clpt, &scrap,
     3710                           (INT *)&nmmouse.dwItemSpec);
     3711    nmmouse.dwItemData = 0;
     3712    nmmouse.pt = clpt;
     3713    nmmouse.dwHitInfo = 0;
     3714    if ((i = REBAR_Notify((NMHDR *) &nmmouse, infoPtr, NM_NCHITTEST))) {
     3715        TRACE("notify changed return value from %ld to %d\n",
     3716              ret, i);
     3717        ret = (LRESULT) i;
     3718    }
     3719    TRACE("returning %ld, client point (%ld,%ld)\n", ret, clpt.x, clpt.y);
     3720    return ret;
    29033721}
    29043722
    29053723
    29063724static LRESULT
    2907 REBAR_EraseBkGnd (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2908 {
    2909     RECT cliprect;
    2910 
    2911     if (GetClipBox ( (HDC)wParam, &cliprect))
    2912         return REBAR_InternalEraseBkGnd (hwnd, wParam, lParam, &cliprect);
    2913     return 0;
    2914 }
    2915 
    2916 
    2917 static LRESULT
    2918 REBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2919 {
    2920     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    2921 
    2922     return (LRESULT)infoPtr->hFont;
    2923 }
    2924 
    2925 
    2926 static LRESULT
    2927 REBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2928 {
    2929     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    2930     REBAR_BAND *lpBand;
    2931     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    2932 
    2933     /* If InternalHitTest did not find a hit on the Gripper, */
    2934     /* then ignore the button click.                         */
    2935     if (infoPtr->ihitBand == -1) return 0;
    2936 
    2937     SetCapture (hwnd);
    2938 
    2939     /* save off the LOWORD and HIWORD of lParam as initial x,y */
    2940     lpBand = &infoPtr->bands[infoPtr->ihitBand];
    2941     infoPtr->dragStart = MAKEPOINTS(lParam);
    2942     infoPtr->dragNow = infoPtr->dragStart;
    2943     if (dwStyle & CCS_VERT)
    2944         infoPtr->ihitoffset = infoPtr->dragStart.y - (lpBand->rcBand.top+REBAR_PRE_GRIPPER);
    2945     else
    2946         infoPtr->ihitoffset = infoPtr->dragStart.x - (lpBand->rcBand.left+REBAR_PRE_GRIPPER);
    2947 
    2948     return 0;
    2949 }
    2950 
    2951 
    2952 static LRESULT
    2953 REBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2954 {
    2955     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    2956     NMHDR layout;
    2957     RECT rect;
    2958 
    2959     /* If InternalHitTest did not find a hit on the Gripper, */
    2960     /* then ignore the button click.                         */
    2961     if (infoPtr->ihitBand == -1) return 0;
    2962 
    2963     infoPtr->dragStart.x = 0;
    2964     infoPtr->dragStart.y = 0;
    2965     infoPtr->dragNow = infoPtr->dragStart;
    2966     infoPtr->ihitBand = -1;
    2967 
    2968     ReleaseCapture ();
    2969 
    2970     if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) {
    2971         REBAR_Notify(hwnd, (NMHDR *) &layout, infoPtr, RBN_LAYOUTCHANGED);
    2972         REBAR_Notify_NMREBAR (hwnd, infoPtr, -1, RBN_ENDDRAG);
    2973         infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
    2974     }
    2975 
    2976     GetClientRect(hwnd, &rect);
    2977     InvalidateRect(hwnd, NULL, TRUE);
    2978 
    2979     return 0;
    2980 }
    2981 
    2982 
    2983 static LRESULT
    2984 REBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2985 {
    2986     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    2987     REBAR_BAND *band1, *band2;
    2988     POINTS ptsmove;
    2989     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    2990 
    2991     /* Validate entry as hit on Gripper has occured */
    2992     if (GetCapture() != hwnd) return 0;
    2993     if (infoPtr->ihitBand == -1) return 0;
    2994 
    2995     ptsmove = MAKEPOINTS(lParam);
    2996 
    2997     /* if mouse did not move much, exit */
    2998     if ((abs(ptsmove.x - infoPtr->dragNow.x) <= mindragx) &&
    2999         (abs(ptsmove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
    3000 
    3001     band1 = &infoPtr->bands[infoPtr->ihitBand-1];
    3002     band2 = &infoPtr->bands[infoPtr->ihitBand];
    3003 
    3004     /* Test for valid drag case - must not be first band in row */
    3005     if (dwStyle & CCS_VERT) {
    3006         if ((ptsmove.x < band2->rcBand.left) ||
    3007             (ptsmove.x > band2->rcBand.right) ||
    3008             ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
    3009             FIXME("Cannot drag to other rows yet!!\n");
    3010         }
    3011         else {
    3012             REBAR_HandleLRDrag (hwnd, infoPtr, &ptsmove, dwStyle);
    3013         }
    3014     }
    3015     else {
    3016         if ((ptsmove.y < band2->rcBand.top) ||
    3017             (ptsmove.y > band2->rcBand.bottom) ||
    3018             ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
    3019             FIXME("Cannot drag to other rows yet!!\n");
    3020         }
    3021         else {
    3022             REBAR_HandleLRDrag (hwnd, infoPtr, &ptsmove, dwStyle);
    3023         }
    3024     }
    3025     return 0;
    3026 }
    3027 
    3028 
    3029 inline static LRESULT
    3030 REBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
    3031 {
    3032     if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER) {
    3033         ((LPRECT)lParam)->left   += GetSystemMetrics(SM_CXEDGE);
    3034         ((LPRECT)lParam)->top    += GetSystemMetrics(SM_CYEDGE);
    3035         ((LPRECT)lParam)->right  -= GetSystemMetrics(SM_CXEDGE);
    3036         ((LPRECT)lParam)->bottom -= GetSystemMetrics(SM_CYEDGE);
    3037     }
    3038 
    3039     return 0;
    3040 }
    3041 
    3042 
    3043 static LRESULT
    3044 REBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
    3045 {
    3046     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     3725REBAR_NCPaint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3726{
    30473727    RECT rcWindow;
    30483728    HDC hdc;
    30493729
    3050     if (dwStyle & WS_MINIMIZE)
     3730    if (infoPtr->dwStyle & WS_MINIMIZE)
    30513731        return 0; /* Nothing to do */
    30523732
    3053     DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
    3054 
    3055     if (!(hdc = GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW )))
     3733    DefWindowProcA (infoPtr->hwndSelf, WM_NCPAINT, wParam, lParam);
     3734
     3735    if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
    30563736        return 0;
    30573737
    3058     if (dwStyle & WS_BORDER) {
    3059         GetWindowRect (hwnd, &rcWindow);
     3738    if (infoPtr->dwStyle & WS_BORDER) {
     3739        GetWindowRect (infoPtr->hwndSelf, &rcWindow);
    30603740        OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
    3061         DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
    3062     }
    3063 
    3064     ReleaseDC( hwnd, hdc );
     3741        TRACE("rect (%d,%d)-(%d,%d)\n",
     3742              rcWindow.left, rcWindow.top,
     3743              rcWindow.right, rcWindow.bottom);
     3744        /* see comments in _NCCalcSize for reason this is not done */
     3745        /* DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT); */
     3746        DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP | BF_BOTTOM);
     3747    }
     3748
     3749    ReleaseDC( infoPtr->hwndSelf, hdc );
    30653750
    30663751    return 0;
     
    30693754
    30703755static LRESULT
    3071 REBAR_Paint (HWND hwnd, WPARAM wParam, LPARAM lParam)
     3756REBAR_NotifyFormat (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3757{
     3758    INT i;
     3759
     3760    if (lParam == NF_REQUERY) {
     3761        i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
     3762                         WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
     3763        if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
     3764            ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
     3765                i);
     3766            i = NFR_ANSI;
     3767        }
     3768        infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
     3769        return (LRESULT)i;
     3770    }
     3771    return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
     3772}
     3773
     3774
     3775static LRESULT
     3776REBAR_Paint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
    30723777{
    30733778    HDC hdc;
    30743779    PAINTSTRUCT ps;
    3075 
    3076     hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
    3077 
    3078     TRACE("painting (%d,%d)-(%d,%d)\n",
     3780    RECT rc;
     3781
     3782    GetClientRect(infoPtr->hwndSelf, &rc);
     3783    hdc = wParam==0 ? BeginPaint (infoPtr->hwndSelf, &ps) : (HDC)wParam;
     3784
     3785    TRACE("painting (%d,%d)-(%d,%d) client (%d,%d)-(%d,%d)\n",
    30793786          ps.rcPaint.left, ps.rcPaint.top,
    3080           ps.rcPaint.right, ps.rcPaint.bottom);
     3787          ps.rcPaint.right, ps.rcPaint.bottom,
     3788          rc.left, rc.top, rc.right, rc.bottom);
    30813789
    30823790    if (ps.fErase) {
    30833791        /* Erase area of paint if requested */
    3084         REBAR_InternalEraseBkGnd (hwnd, wParam, lParam, &ps.rcPaint);
    3085     }
    3086 
    3087     REBAR_Refresh (hwnd, hdc);
     3792        REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &ps.rcPaint);
     3793    }
     3794
     3795    REBAR_Refresh (infoPtr, hdc);
    30883796    if (!wParam)
    3089         EndPaint (hwnd, &ps);
     3797        EndPaint (infoPtr->hwndSelf, &ps);
    30903798    return 0;
    30913799}
     
    30933801
    30943802static LRESULT
    3095 REBAR_SetCursor (HWND hwnd, WPARAM wParam, LPARAM lParam)
    3096 {
    3097     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    3098     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     3803REBAR_SetCursor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3804{
    30993805    POINT pt;
    31003806    UINT  flags;
     
    31033809
    31043810    GetCursorPos (&pt);
    3105     ScreenToClient (hwnd, &pt);
    3106 
    3107     REBAR_InternalHitTest (hwnd, &pt, &flags, NULL);
     3811    ScreenToClient (infoPtr->hwndSelf, &pt);
     3812
     3813    REBAR_InternalHitTest (infoPtr, &pt, &flags, NULL);
    31083814
    31093815    if (flags == RBHT_GRABBER) {
    3110         if ((dwStyle & CCS_VERT) &&
    3111             !(dwStyle & RBS_VERTICALGRIPPER))
     3816        if ((infoPtr->dwStyle & CCS_VERT) &&
     3817            !(infoPtr->dwStyle & RBS_VERTICALGRIPPER))
    31123818            SetCursor (infoPtr->hcurVert);
    31133819        else
     
    31223828
    31233829static LRESULT
    3124 REBAR_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
    3125 {
    3126     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     3830REBAR_SetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3831{
    31273832    RECT rcClient;
    31283833    REBAR_BAND *lpBand;
     
    31343839    for (i=0; i<infoPtr->uNumBands; i++) {
    31353840        lpBand = &infoPtr->bands[i];
    3136         REBAR_ValidateBand (hwnd, infoPtr, lpBand);
    3137     }
    3138 
    3139 
    3140     if (lParam) {
    3141         GetClientRect (hwnd, &rcClient);
    3142         REBAR_Layout (hwnd, &rcClient, FALSE, TRUE);
    3143         REBAR_ForceResize (hwnd);
    3144         REBAR_MoveChildWindows (hwnd);
     3841        REBAR_ValidateBand (infoPtr, lpBand);
     3842    }
     3843
     3844
     3845    if (LOWORD(lParam)) {
     3846        GetClientRect (infoPtr->hwndSelf, &rcClient);
     3847        REBAR_Layout (infoPtr, &rcClient, FALSE, TRUE);
    31453848    }
    31463849
     
    31493852
    31503853
     3854inline static LRESULT
     3855REBAR_SetRedraw (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3856     /*****************************************************
     3857      *
     3858      * Function;
     3859      *  Handles the WM_SETREDRAW message.
     3860      *
     3861      * Documentation:
     3862      *  According to testing V4.71 of COMCTL32 returns the
     3863      *  *previous* status of the redraw flag (either 0 or -1)
     3864      *  instead of the MSDN documented value of 0 if handled
     3865      *
     3866      *****************************************************/
     3867{
     3868    BOOL oldredraw = infoPtr->DoRedraw;
     3869
     3870    TRACE("set to %s, fStatus=%08x\n",
     3871          (wParam) ? "TRUE" : "FALSE", infoPtr->fStatus);
     3872    infoPtr->DoRedraw = (BOOL) wParam;
     3873    if (wParam) {
     3874        if (infoPtr->fStatus & BAND_NEEDS_REDRAW) {
     3875            REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
     3876            REBAR_ForceResize (infoPtr);
     3877            InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
     3878        }
     3879        infoPtr->fStatus &= ~BAND_NEEDS_REDRAW;
     3880    }
     3881    return (oldredraw) ? -1 : 0;
     3882}
     3883
     3884
    31513885static LRESULT
    3152 REBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
    3153 {
    3154     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     3886REBAR_Size (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3887{
    31553888    RECT rcClient;
    31563889
     
    31583891    if (infoPtr->fStatus & AUTO_RESIZE) {
    31593892        infoPtr->fStatus &= ~AUTO_RESIZE;
    3160         TRACE("AUTO_RESIZE was set, reset, fStatus=%08x\n",
    3161               infoPtr->fStatus);
     3893        TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
     3894              infoPtr->fStatus, lParam);
    31623895        return 0;
    31633896    }
    31643897
    3165     GetClientRect (hwnd, &rcClient);
    3166     if ((lParam == 0) && (rcClient.right == 0) && (rcClient.bottom == 0)) {
    3167       /* native control seems to do this */
    3168       GetClientRect (GetParent(hwnd), &rcClient);
    3169       TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n",
    3170             rcClient.right, rcClient.bottom);
     3898    if (infoPtr->fStatus & CREATE_RUNNING) {
     3899        /* still in CreateWindow */
     3900        RECT rcWin;
     3901
     3902        TRACE("still in CreateWindow\n");
     3903        infoPtr->fStatus &= ~CREATE_RUNNING;
     3904        GetWindowRect ( infoPtr->hwndSelf, &rcWin);
     3905        TRACE("win rect (%d,%d)-(%d,%d)\n",
     3906              rcWin.left, rcWin.top, rcWin.right, rcWin.bottom);
     3907
     3908        if ((lParam == 0) && (rcWin.right-rcWin.left == 0) &&
     3909            (rcWin.bottom-rcWin.top == 0)) {
     3910            /* native control seems to do this */
     3911            GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient);
     3912            TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n",
     3913                  rcClient.right, rcClient.bottom);
     3914        }
     3915        else {
     3916            INT cx, cy;
     3917
     3918            cx = rcWin.right - rcWin.left;
     3919            cy = rcWin.bottom - rcWin.top;
     3920            if ((cx == LOWORD(lParam)) && (cy == HIWORD(lParam))) {
     3921                return 0;
     3922            }
     3923
     3924            /* do the actual WM_SIZE request */
     3925            GetClientRect (infoPtr->hwndSelf, &rcClient);
     3926            TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
     3927                  infoPtr->calcSize.cx, infoPtr->calcSize.cy,
     3928                  LOWORD(lParam), HIWORD(lParam),
     3929                  rcClient.right, rcClient.bottom);
     3930        }
    31713931    }
    31723932    else {
    3173       TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
    3174             infoPtr->calcSize.cx, infoPtr->calcSize.cy,
    3175             LOWORD(lParam), HIWORD(lParam),
    3176             rcClient.right, rcClient.bottom);
    3177     }
    3178 
    3179     REBAR_Layout (hwnd, &rcClient, TRUE, TRUE);
    3180     REBAR_ForceResize (hwnd);
     3933        /* Handle cases when outside of the CreateWindow process */
     3934
     3935        GetClientRect (infoPtr->hwndSelf, &rcClient);
     3936        if ((lParam == 0) && (rcClient.right + rcClient.bottom != 0) &&
     3937            (infoPtr->dwStyle & RBS_AUTOSIZE)) {
     3938            /* on a WM_SIZE to zero and current client not zero and AUTOSIZE */
     3939            /* native seems to use the current client rect for the size      */
     3940            infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
     3941            TRACE("sizing rebar to client (%d,%d) size is zero but AUTOSIZE set\n",
     3942                  rcClient.right, rcClient.bottom);
     3943        }
     3944        else {
     3945            TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
     3946                  infoPtr->calcSize.cx, infoPtr->calcSize.cy,
     3947                  LOWORD(lParam), HIWORD(lParam),
     3948                  rcClient.right, rcClient.bottom);
     3949        }
     3950    }
     3951
     3952    if (infoPtr->dwStyle & RBS_AUTOSIZE) {
     3953        NMRBAUTOSIZE autosize;
     3954
     3955        GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget);
     3956        autosize.fChanged = 0;  /* ??? */
     3957        autosize.rcActual = autosize.rcTarget;  /* ??? */
     3958        REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE);
     3959        TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n",
     3960              autosize.rcTarget.right, autosize.rcTarget.bottom, lParam);
     3961    }
     3962
     3963    if ((infoPtr->calcSize.cx != rcClient.right) ||
     3964        (infoPtr->calcSize.cy != rcClient.bottom))
     3965        infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
     3966
     3967    REBAR_Layout (infoPtr, &rcClient, TRUE, TRUE);
    31813968    infoPtr->fStatus &= ~AUTO_RESIZE;
    3182     REBAR_MoveChildWindows (hwnd);
    31833969
    31843970    return 0;
     3971}
     3972
     3973
     3974static LRESULT
     3975REBAR_StyleChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     3976{
     3977    STYLESTRUCT *ss = (STYLESTRUCT *)lParam;
     3978
     3979    TRACE("current style=%08lx, styleOld=%08lx, style being set to=%08lx\n",
     3980          infoPtr->dwStyle, ss->styleOld, ss->styleNew);
     3981    infoPtr->dwStyle = ss->styleNew;
     3982
     3983    return FALSE;
    31853984}
    31863985
     
    31893988REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    31903989{
    3191     TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
    3192     if (!REBAR_GetInfoPtr (hwnd) && (uMsg != WM_CREATE))
     3990    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
     3991
     3992    TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n",
     3993          hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
     3994    if (!infoPtr && (uMsg != WM_NCCREATE))
    31933995            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    31943996    switch (uMsg)
     
    31973999
    31984000        case RB_DELETEBAND:
    3199             return REBAR_DeleteBand (hwnd, wParam, lParam);
     4001            return REBAR_DeleteBand (infoPtr, wParam, lParam);
    32004002
    32014003/*      case RB_DRAGMOVE: */
     
    32034005
    32044006        case RB_GETBANDBORDERS:
    3205             return REBAR_GetBandBorders (hwnd, wParam, lParam);
     4007            return REBAR_GetBandBorders (infoPtr, wParam, lParam);
    32064008
    32074009        case RB_GETBANDCOUNT:
    3208             return REBAR_GetBandCount (hwnd);
     4010            return REBAR_GetBandCount (infoPtr);
    32094011
    32104012        case RB_GETBANDINFO:    /* obsoleted after IE3, but we have to
    32114013                                   support it anyway. */
    32124014        case RB_GETBANDINFOA:
    3213             return REBAR_GetBandInfoA (hwnd, wParam, lParam);
     4015            return REBAR_GetBandInfoA (infoPtr, wParam, lParam);
    32144016
    32154017        case RB_GETBANDINFOW:
    3216             return REBAR_GetBandInfoW (hwnd, wParam, lParam);
     4018            return REBAR_GetBandInfoW (infoPtr, wParam, lParam);
    32174019
    32184020        case RB_GETBARHEIGHT:
    3219             return REBAR_GetBarHeight (hwnd, wParam, lParam);
     4021            return REBAR_GetBarHeight (infoPtr, wParam, lParam);
    32204022
    32214023        case RB_GETBARINFO:
    3222             return REBAR_GetBarInfo (hwnd, wParam, lParam);
     4024            return REBAR_GetBarInfo (infoPtr, wParam, lParam);
    32234025
    32244026        case RB_GETBKCOLOR:
    3225             return REBAR_GetBkColor (hwnd);
     4027            return REBAR_GetBkColor (infoPtr);
    32264028
    32274029/*      case RB_GETCOLORSCHEME: */
     
    32294031
    32304032        case RB_GETPALETTE:
    3231             return REBAR_GetPalette (hwnd, wParam, lParam);
     4033            return REBAR_GetPalette (infoPtr, wParam, lParam);
    32324034
    32334035        case RB_GETRECT:
    3234             return REBAR_GetRect (hwnd, wParam, lParam);
     4036            return REBAR_GetRect (infoPtr, wParam, lParam);
    32354037
    32364038        case RB_GETROWCOUNT:
    3237             return REBAR_GetRowCount (hwnd);
     4039            return REBAR_GetRowCount (infoPtr);
    32384040
    32394041        case RB_GETROWHEIGHT:
    3240             return REBAR_GetRowHeight (hwnd, wParam, lParam);
     4042            return REBAR_GetRowHeight (infoPtr, wParam, lParam);
    32414043
    32424044        case RB_GETTEXTCOLOR:
    3243             return REBAR_GetTextColor (hwnd);
     4045            return REBAR_GetTextColor (infoPtr);
    32444046
    32454047        case RB_GETTOOLTIPS:
    3246             return REBAR_GetToolTips (hwnd);
     4048            return REBAR_GetToolTips (infoPtr);
    32474049
    32484050        case RB_GETUNICODEFORMAT:
    3249             return REBAR_GetUnicodeFormat (hwnd);
     4051            return REBAR_GetUnicodeFormat (infoPtr);
    32504052
    32514053        case CCM_GETVERSION:
    3252             return REBAR_GetVersion (hwnd);
     4054            return REBAR_GetVersion (infoPtr);
    32534055
    32544056        case RB_HITTEST:
    3255             return REBAR_HitTest (hwnd, wParam, lParam);
     4057            return REBAR_HitTest (infoPtr, wParam, lParam);
    32564058
    32574059        case RB_IDTOINDEX:
    3258             return REBAR_IdToIndex (hwnd, wParam, lParam);
     4060            return REBAR_IdToIndex (infoPtr, wParam, lParam);
    32594061
    32604062        case RB_INSERTBANDA:
    3261             return REBAR_InsertBandA (hwnd, wParam, lParam);
     4063            return REBAR_InsertBandA (infoPtr, wParam, lParam);
    32624064
    32634065        case RB_INSERTBANDW:
    3264             return REBAR_InsertBandW (hwnd, wParam, lParam);
     4066            return REBAR_InsertBandW (infoPtr, wParam, lParam);
    32654067
    32664068        case RB_MAXIMIZEBAND:
    3267             return REBAR_MaximizeBand (hwnd, wParam, lParam);
     4069            return REBAR_MaximizeBand (infoPtr, wParam, lParam);
    32684070
    32694071        case RB_MINIMIZEBAND:
    3270             return REBAR_MinimizeBand (hwnd, wParam, lParam);
     4072            return REBAR_MinimizeBand (infoPtr, wParam, lParam);
    32714073
    32724074        case RB_MOVEBAND:
    3273             return REBAR_MoveBand (hwnd, wParam, lParam);
     4075            return REBAR_MoveBand (infoPtr, wParam, lParam);
    32744076
    32754077        case RB_SETBANDINFOA:
    3276             return REBAR_SetBandInfoA (hwnd, wParam, lParam);
     4078            return REBAR_SetBandInfoA (infoPtr, wParam, lParam);
    32774079
    32784080        case RB_SETBANDINFOW:
    3279             return REBAR_SetBandInfoW (hwnd, wParam, lParam);
     4081            return REBAR_SetBandInfoW (infoPtr, wParam, lParam);
    32804082
    32814083        case RB_SETBARINFO:
    3282             return REBAR_SetBarInfo (hwnd, wParam, lParam);
     4084            return REBAR_SetBarInfo (infoPtr, wParam, lParam);
    32834085
    32844086        case RB_SETBKCOLOR:
    3285             return REBAR_SetBkColor (hwnd, wParam, lParam);
     4087            return REBAR_SetBkColor (infoPtr, wParam, lParam);
    32864088
    32874089/*      case RB_SETCOLORSCHEME: */
    32884090/*      case RB_SETPALETTE: */
    3289 /*          return REBAR_GetPalette (hwnd, wParam, lParam); */
     4091/*          return REBAR_GetPalette (infoPtr, wParam, lParam); */
    32904092
    32914093        case RB_SETPARENT:
    3292             return REBAR_SetParent (hwnd, wParam, lParam);
     4094            return REBAR_SetParent (infoPtr, wParam, lParam);
    32934095
    32944096        case RB_SETTEXTCOLOR:
    3295             return REBAR_SetTextColor (hwnd, wParam, lParam);
     4097            return REBAR_SetTextColor (infoPtr, wParam, lParam);
    32964098
    32974099/*      case RB_SETTOOLTIPS: */
    32984100
    32994101        case RB_SETUNICODEFORMAT:
    3300             return REBAR_SetUnicodeFormat (hwnd, wParam);
     4102            return REBAR_SetUnicodeFormat (infoPtr, wParam);
    33014103
    33024104        case CCM_SETVERSION:
    3303             return REBAR_SetVersion (hwnd, (INT)wParam);
     4105            return REBAR_SetVersion (infoPtr, (INT)wParam);
    33044106
    33054107        case RB_SHOWBAND:
    3306             return REBAR_ShowBand (hwnd, wParam, lParam);
     4108            return REBAR_ShowBand (infoPtr, wParam, lParam);
    33074109
    33084110        case RB_SIZETORECT:
    3309             return REBAR_SizeToRect (hwnd, wParam, lParam);
     4111            return REBAR_SizeToRect (infoPtr, wParam, lParam);
    33104112
    33114113
     
    33144116        case WM_DRAWITEM:
    33154117        case WM_NOTIFY:
    3316             return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
     4118            if (infoPtr->NtfUnicode)
     4119                return SendMessageW (REBAR_GetNotifyParent (infoPtr),
     4120                                     uMsg, wParam, lParam);
     4121            else
     4122                return SendMessageA (REBAR_GetNotifyParent (infoPtr),
     4123                                     uMsg, wParam, lParam);
    33174124
    33184125
     
    33204127
    33214128        case WM_CREATE:
    3322             return REBAR_Create (hwnd, wParam, lParam);
     4129            return REBAR_Create (infoPtr, wParam, lParam);
    33234130
    33244131        case WM_DESTROY:
    3325             return REBAR_Destroy (hwnd, wParam, lParam);
     4132            return REBAR_Destroy (infoPtr, wParam, lParam);
    33264133
    33274134        case WM_ERASEBKGND:
    3328             return REBAR_EraseBkGnd (hwnd, wParam, lParam);
     4135            return REBAR_EraseBkGnd (infoPtr, wParam, lParam);
    33294136
    33304137        case WM_GETFONT:
    3331             return REBAR_GetFont (hwnd, wParam, lParam);
     4138            return REBAR_GetFont (infoPtr, wParam, lParam);
    33324139
    33334140/*      case WM_LBUTTONDBLCLK:  supported according to ControlSpy */
    33344141
    33354142        case WM_LBUTTONDOWN:
    3336             return REBAR_LButtonDown (hwnd, wParam, lParam);
     4143            return REBAR_LButtonDown (infoPtr, wParam, lParam);
    33374144
    33384145        case WM_LBUTTONUP:
    3339             return REBAR_LButtonUp (hwnd, wParam, lParam);
     4146            return REBAR_LButtonUp (infoPtr, wParam, lParam);
    33404147
    33414148/*      case WM_MEASUREITEM:    supported according to ControlSpy */
    33424149
    33434150        case WM_MOUSEMOVE:
    3344             return REBAR_MouseMove (hwnd, wParam, lParam);
     4151            return REBAR_MouseMove (infoPtr, wParam, lParam);
    33454152
    33464153        case WM_NCCALCSIZE:
    3347             return REBAR_NCCalcSize (hwnd, wParam, lParam);
    3348 
    3349 /*      case WM_NCCREATE:       supported according to ControlSpy */
    3350 /*      case WM_NCHITTEST:      supported according to ControlSpy */
     4154            return REBAR_NCCalcSize (infoPtr, wParam, lParam);
     4155
     4156        case WM_NCCREATE:
     4157            return REBAR_NCCreate (hwnd, wParam, lParam);
     4158
     4159        case WM_NCHITTEST:
     4160            return REBAR_NCHitTest (infoPtr, wParam, lParam);
    33514161
    33524162        case WM_NCPAINT:
    3353             return REBAR_NCPaint (hwnd, wParam, lParam);
    3354 
    3355 /*      case WM_NOTIFYFORMAT:   supported according to ControlSpy */
     4163            return REBAR_NCPaint (infoPtr, wParam, lParam);
     4164
     4165        case WM_NOTIFYFORMAT:
     4166            return REBAR_NotifyFormat (infoPtr, wParam, lParam);
    33564167
    33574168        case WM_PAINT:
    3358             return REBAR_Paint (hwnd, wParam, lParam);
     4169            return REBAR_Paint (infoPtr, wParam, lParam);
    33594170
    33604171/*      case WM_PALETTECHANGED: supported according to ControlSpy */
     
    33654176
    33664177        case WM_SETCURSOR:
    3367             return REBAR_SetCursor (hwnd, wParam, lParam);
     4178            return REBAR_SetCursor (infoPtr, wParam, lParam);
    33684179
    33694180        case WM_SETFONT:
    3370             return REBAR_SetFont (hwnd, wParam, lParam);
    3371 
    3372 /*      case WM_SETREDRAW:      supported according to ControlSpy */
     4181            return REBAR_SetFont (infoPtr, wParam, lParam);
     4182
     4183        case WM_SETREDRAW:
     4184            return REBAR_SetRedraw (infoPtr, wParam, lParam);
    33734185
    33744186        case WM_SIZE:
    3375             return REBAR_Size (hwnd, wParam, lParam);
    3376 
    3377 /*      case WM_STYLECHANGED:   supported according to ControlSpy */
     4187            return REBAR_Size (infoPtr, wParam, lParam);
     4188
     4189        case WM_STYLECHANGED:
     4190            return REBAR_StyleChanged (infoPtr, wParam, lParam);
     4191
    33784192/*      case WM_SYSCOLORCHANGE: supported according to ControlSpy */
     4193/*      "Applications that have brushes using the existing system colors
     4194         should delete those brushes and recreate them using the new
     4195         system colors."  per MSDN                                */
     4196
    33794197/*      case WM_VKEYTOITEM:     supported according to ControlSpy */
    33804198/*      case WM_WININICHANGE: */
Note: See TracChangeset for help on using the changeset viewer.