Ignore:
Timestamp:
Aug 13, 2000, 7:12:40 PM (25 years ago)
Author:
cbratschi
Message:

Corel WINE 20000807 changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/treeview.cpp

    r3970 r4006  
    1 /* $Id: treeview.cpp,v 1.16 2000-08-08 17:05:02 cbratschi Exp $ */
     1/* $Id: treeview.cpp,v 1.17 2000-08-13 17:12:40 cbratschi Exp $ */
    22/* Treeview control
    33 *
     
    1010 * Note that TREEVIEW_INFO * and HTREEITEM are the same thing.
    1111 *
     12 * Note2: All items always! have valid (allocated) pszText field.
     13 *      If item's text == LPSTR_TEXTCALLBACKA/W we allocate buffer
     14 *      of size TEXT_CALLBACK_SIZE in DoSetItem.
     15 *      We use callbackMask to keep track of fields to be updated.
     16 *
    1217 *
    1318 * Status: complete (many things untested)
     
    1722/*
    1823 Most identical with:
    19  - Corel 20000212 level
     24 - Corel 20000807 level
    2025 - (WINE 991212 level)
    2126*/
     
    7176#define MINIMUM_INDENT 19
    7277
    73 #define IDT_CHECK        401 //CB: remove later
    74 
    7578#define CALLBACK_MASK_ALL (TVIF_TEXT|TVIF_CHILDREN|TVIF_IMAGE|TVIF_SELECTEDIMAGE)
    7679
    77 #define STATEIMAGEINDEX(x) (((x) >> 12) & 0x0f)
     80#define STATEIMAGEINDEX(x)   (((x) >> 12) & 0x0f)
    7881#define OVERLAYIMAGEINDEX(x) (((x) >> 8) & 0x0f)
     82#define ISVISIBLE(x)         ((x)->displayed)
     83#define INCLIENT(x)          ((x)->inclient)
    7984
    8085typedef VOID (*TREEVIEW_ItemEnumFunc)(TREEVIEW_INFO *, TREEVIEW_ITEM *,LPVOID);
     
    8792static VOID    TREEVIEW_HideInfoTip(TREEVIEW_INFO *infoPtr);
    8893static LRESULT TREEVIEW_DoSelectItem(TREEVIEW_INFO *, INT, HTREEITEM, INT);
    89 static LRESULT TREEVIEW_EnsureVisible(TREEVIEW_INFO *, HTREEITEM);
     94static LRESULT TREEVIEW_EnsureVisible(TREEVIEW_INFO *,HTREEITEM,BOOL);
    9095static LRESULT TREEVIEW_RButtonUp(TREEVIEW_INFO *, LPPOINT);
    9196static LRESULT TREEVIEW_EndEditLabelNow(TREEVIEW_INFO *infoPtr, BOOL bCancel);
    92 static VOID    TREEVIEW_UpdateScrollBars(TREEVIEW_INFO *infoPtr, BOOL);
    9397static VOID    TREEVIEW_CheckInfoTip(TREEVIEW_INFO *infoPtr);
    9498static VOID    TREEVIEW_ISearch(TREEVIEW_INFO *infoPtr,CHAR ch);
     
    168172    if (item->pszText == LPSTR_TEXTCALLBACKW) return (WCHAR*)L"<callback>";
    169173    if (item->pszText == NULL) return (WCHAR*)L"<null>";
    170     /* It would be nice to check item->callbackMask & TVIF_TEXT here,
    171      * and indicate that this is a callback string, but there is nowhere
    172      * to put that indication. (Or we could be clever, and put it before
    173      * pszText, but that is just too hacky.) */
     174
    174175    return item->pszText;
    175176}
     
    197198TREEVIEW_GetLastListItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem)
    198199{
    199     /*
    200      * Get this item's last sibling
    201      */
    202     while (wineItem->nextSibling)
    203         wineItem = wineItem->nextSibling;
    204 
    205     /*
    206      * If the last sibling has expanded children, restart.
    207      */
    208     if ((wineItem->state & TVIS_EXPANDED) && wineItem->firstChild != NULL)
    209     {
    210         return TREEVIEW_GetLastListItem(infoPtr, wineItem->firstChild);
    211     }
     200    if (!wineItem)
     201       return NULL;
     202
     203    while (wineItem->lastChild)
     204    {
     205       if (wineItem->state & TVIS_EXPANDED)
     206          wineItem = wineItem->lastChild;
     207       else
     208          break;
     209    }
     210
     211    if (wineItem == infoPtr->root)
     212        return NULL;
    212213
    213214    return wineItem;
     
    223224    if (tvItem->prevSibling)
    224225    {
    225         /*
    226          * This item has a prevSibling, get the last item.  Since
    227          * GetLastListItem first looks at siblings, we must feed it with the
    228          * first child.
    229          */
     226        /* This item has a prevSibling, get the last item in the sibling's tree. */
    230227        TREEVIEW_ITEM *upItem = tvItem->prevSibling;
    231228
    232         if ((upItem->state & TVIS_EXPANDED) && upItem->firstChild != NULL)
    233             return TREEVIEW_GetLastListItem(infoPtr, upItem->firstChild);
     229        if ((upItem->state & TVIS_EXPANDED) && upItem->lastChild != NULL)
     230            return TREEVIEW_GetLastListItem(infoPtr, upItem->lastChild);
    234231        else
    235232            return upItem;
     
    237234    else
    238235    {
    239         /*
    240          * this item does not have a prevSibling, get the parent
    241          */
     236        /* this item does not have a prevSibling, get the parent */
    242237        return (tvItem->parent != infoPtr->root) ? tvItem->parent : NULL;
    243238    }
     
    252247TREEVIEW_GetNextListItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *tvItem)
    253248{
    254     assert(infoPtr != NULL);
    255249    assert(tvItem != NULL);
    256250
     
    445439
    446440/* FIXME: need to find out when the flags in uItemState need to be set */
     441
    447442static BOOL
    448443TREEVIEW_SendCustomDrawItemNotify(TREEVIEW_INFO *infoPtr,HDC hdc,TREEVIEW_ITEM *wineItem,UINT uItemDrawState)
     
    457452  dwItemSpec = (DWORD)wineItem;
    458453  uItemState = 0;
    459   if (wineItem == infoPtr->selectedItem)
     454  if (wineItem->state & TVIS_SELECTED)
    460455  {
    461456    uItemState |= CDIS_SELECTED;
    462457    if (GetFocus() == infoPtr->hwnd) uItemState |= CDIS_FOCUS;
    463458  }
    464   if (wineItem == infoPtr->focusItem)
     459  if (wineItem == infoPtr->selectedItem)
    465460    uItemState |= CDIS_FOCUS;
    466461  if (wineItem == infoPtr->hotItem)
     
    487482
    488483static void
    489 TREEVIEW_GetDispInfo(TREEVIEW_INFO *infoPtr,TREEVIEW_ITEM *wineItem,NMTVDISPINFOW* info,UINT mask)
    490 {
    491   info->item.mask = mask;
    492   info->item.hItem = wineItem;
    493   info->item.state = wineItem->state;
    494   info->item.stateMask = 0;
    495   info->item.lParam = wineItem->lParam;
    496 
    497   sendNotify(infoPtr->hwnd,isUnicodeNotify(&infoPtr->header) ? TVN_GETDISPINFOW:TVN_GETDISPINFOA,&info->hdr);
    498 }
    499 
    500 static void
    501484TREEVIEW_UpdateDispInfo(TREEVIEW_INFO *infoPtr,TREEVIEW_ITEM *wineItem,UINT mask)
    502485{
     
    507490  if (mask == 0) return;
    508491
    509   if ((mask & TVIF_TEXT) /*&& (wineItem->cchTextMax < TEXT_CALLBACK_SIZE)*/)
    510   {
    511     wineItem->pszText = (WCHAR*)COMCTL32_ReAlloc(wineItem->pszText,TEXT_CALLBACK_SIZE*sizeof(WCHAR));
    512     wineItem->cchTextMax = TEXT_CALLBACK_SIZE;
    513   }
     492  /* 'state' always contains valid value, as well as 'lParam'.
     493   * All other parameters are uninitialized.
     494   */
    514495
    515496  callback.item.pszText         = wineItem->pszText;
    516497  callback.item.cchTextMax      = wineItem->cchTextMax;
     498  callback.item.mask            = mask;
     499  callback.item.hItem           = wineItem;
     500  callback.item.state           = wineItem->state;
     501  callback.item.lParam = wineItem->lParam;
     502
     503  /*
     504  callback.item.stateMask       = 0;
    517505  callback.item.iImage          = wineItem->iImage;
    518506  callback.item.iSelectedImage  = wineItem->iSelectedImage;
    519507  callback.item.cChildren       = wineItem->cChildren;
    520 
    521   TREEVIEW_GetDispInfo(infoPtr,wineItem,&callback,mask);
     508  */
     509
     510  sendNotify(infoPtr->hwnd,isUnicodeNotify(&infoPtr->header) ? TVN_GETDISPINFOW:TVN_GETDISPINFOA,&callback.hdr);
    522511
    523512  /* It may have changed due to a call to SetItem. */
     
    543532      newText = (WCHAR*)COMCTL32_Alloc(len*sizeof(WCHAR));
    544533      lstrcpyAtoW(newText,(LPSTR)callback.item.pszText);
    545       COMCTL32_Free(wineItem->pszText);
     534      if (wineItem->pszText) COMCTL32_Free(wineItem->pszText);
    546535      wineItem->pszText = newText;
    547536      wineItem->cchTextMax = len;
     
    595584{
    596585    HDC hdc;
    597     HFONT hOldFont;
     586    HFONT hOldFont = 0;
    598587    RECT rect;
    599588
     
    869858        newItem->prevSibling = sibling->prevSibling;
    870859        sibling->prevSibling = newItem;
    871     }
     860    } else newItem->prevSibling = NULL;
    872861
    873862    newItem->nextSibling = sibling;
    874863
    875864    if (parent->firstChild == sibling)
    876     {
    877         newItem->nextSibling = parent->firstChild;
    878865        parent->firstChild = newItem;
    879     }
    880866
    881867    if (parent->lastChild == NULL)
     
    903889        newItem->nextSibling = sibling->nextSibling;
    904890        sibling->nextSibling = newItem;
    905     }
     891    } else newItem->nextSibling = NULL;
    906892
    907893    newItem->prevSibling = sibling;
    908894
    909895    if (parent->lastChild == sibling)
    910     {
    911         newItem->prevSibling = parent->lastChild;
    912896        parent->lastChild = newItem;
    913     }
    914897
    915898    if (parent->firstChild == NULL)
     
    1015998    wineItem->iSelectedImage = tvItem->iSelectedImage;
    1016999
    1017     if (wineItem->iImage == I_IMAGECALLBACK)
     1000    if (wineItem->iSelectedImage == I_IMAGECALLBACK)
    10181001      callbackSet |= TVIF_SELECTEDIMAGE;
    10191002    else
     
    10591042  INT x;
    10601043  TREEVIEW_ITEM *newItem, *parentItem;
     1044  BOOL bTextUpdated = FALSE;
    10611045
    10621046  if (!ptdi) return NULL;
     
    11311115    aChild = parentItem->firstChild;
    11321116
     1117    bTextUpdated = TRUE;
    11331118    TREEVIEW_UpdateDispInfo(infoPtr, newItem, TVIF_TEXT);
    11341119
     
    11501135      {
    11511136        previousChild = aChild;
    1152         aChild = (aChild->nextSibling == 0)     /* This will help us to exit   */
    1153                   ? NULL        /* if there is no more sibling */
     1137
     1138         /* This will help us to exit if there is no more sibling */
     1139        aChild = (aChild->nextSibling == 0)
     1140                  ? NULL
    11541141                  : aChild->nextSibling;
    11551142
     
    12541241TREEVIEW_RemoveItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem)
    12551242{
    1256     TREEVIEW_ITEM *newFirstVisible;
    1257 
    12581243    //TRACE("%p, (%s)\n", wineItem, TREEVIEW_ItemName(wineItem));
    12591244
     
    12951280    TREEVIEW_ITEM *oldSelection = infoPtr->selectedItem;
    12961281    TREEVIEW_ITEM *newSelection = NULL;
     1282    TREEVIEW_ITEM *newFirstVisible = NULL;
     1283    TREEVIEW_ITEM *parent, *prev = NULL;
     1284    BOOL visible = FALSE;
    12971285
    12981286    if (lParam == (LPARAM)TVI_ROOT)
    12991287    {
     1288        parent = infoPtr->root;
    13001289        newSelection = NULL;
     1290        visible = TRUE;
    13011291        TREEVIEW_RemoveTree(infoPtr);
    13021292    }
     
    13091299
    13101300        //TRACE("%p (%s)\n", wineItem, TREEVIEW_ItemName(wineItem));
     1301        parent = wineItem->parent;
     1302
     1303        if (ISVISIBLE(wineItem))
     1304        {
     1305            prev = TREEVIEW_GetPrevListItem(infoPtr, wineItem);
     1306            visible = TRUE;
     1307        }
    13111308
    13121309        if (infoPtr->selectedItem != NULL
     
    13201317        }
    13211318
     1319        if (infoPtr->firstVisible == wineItem)
     1320        {
     1321            if (wineItem->nextSibling)
     1322               newFirstVisible = wineItem->nextSibling;
     1323            else if (wineItem->prevSibling)
     1324               newFirstVisible = wineItem->prevSibling;
     1325            else if (wineItem->parent != infoPtr->root)
     1326               newFirstVisible = wineItem->parent;
     1327        }
     1328        else
     1329            newFirstVisible = infoPtr->firstVisible;
     1330
    13221331        TREEVIEW_RemoveItem(infoPtr, wineItem);
    13231332    }
    13241333
    13251334    /* Don't change if somebody else already has. */
    1326     if (oldSelection == infoPtr->selectedItem
    1327         && TREEVIEW_ValidItem(infoPtr, newSelection))
    1328     {
     1335    if (oldSelection == infoPtr->selectedItem)
     1336    {
     1337      if (TREEVIEW_ValidItem(infoPtr, newSelection))
    13291338        TREEVIEW_DoSelectItem(infoPtr, TVGN_CARET, newSelection, TVC_UNKNOWN);
    1330     }
     1339      else
     1340        infoPtr->selectedItem = 0;
     1341    }
     1342
     1343    /* Validate insertMark dropItem.
     1344     * hotItem ??? - used for comparision only.
     1345     */
     1346    if (!TREEVIEW_ValidItem(infoPtr, infoPtr->insertMarkItem))
     1347        infoPtr->insertMarkItem = 0;
     1348
     1349    if (!TREEVIEW_ValidItem(infoPtr, infoPtr->dropItem))
     1350        infoPtr->dropItem = 0;
     1351
     1352    if (!TREEVIEW_ValidItem(infoPtr, newFirstVisible))
     1353        newFirstVisible = infoPtr->root->firstChild;
    13311354
    13321355    TREEVIEW_VerifyTree(infoPtr);
    13331356
    1334     TREEVIEW_QueueRefresh(infoPtr);
     1357    if (visible)
     1358      TREEVIEW_QueueRefresh(infoPtr);
     1359    else if (INCLIENT(parent) && !TREEVIEW_HasChildren(infoPtr,parent))
     1360      TREEVIEW_RefreshItem(infoPtr,parent,TVIF_CHILDREN);
    13351361
    13361362    return TRUE;
     
    14201446    HIMAGELIST himlNew = (HIMAGELIST)lParam;
    14211447    HIMAGELIST himlOld = 0;
     1448    int oldWidth  = infoPtr->normalImageWidth;
     1449    int oldHeight = infoPtr->normalImageHeight;
    14221450
    14231451    switch (wParam)
     
    14541482    }
    14551483
    1456     infoPtr->uInternalStatus |= TV_CALCALL;
     1484    if ((oldWidth != infoPtr->normalImageWidth) || (oldHeight != infoPtr->normalImageHeight))
     1485      infoPtr->uInternalStatus |= TV_CALCALL;
    14571486    TREEVIEW_QueueRefresh(infoPtr);
    14581487
     
    15261555TREEVIEW_SetFont(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
    15271556{
     1557  UINT uHeight = infoPtr->uItemHeight;
     1558
    15281559  infoPtr->hFont = wParam ? (HFONT)wParam : GetStockObject(SYSTEM_FONT);
    15291560
     
    15321563
    15331564  if (!infoPtr->bHeightSet)
    1534       infoPtr->uItemHeight = TREEVIEW_NaturalHeight(infoPtr);
     1565    infoPtr->uItemHeight = TREEVIEW_NaturalHeight(infoPtr);
    15351566
    15361567  SendMessageA(infoPtr->hwndToolTip,WM_SETFONT,infoPtr->hFont,1);
    1537   infoPtr->uInternalStatus |= TV_CALCALL;
    1538   TREEVIEW_CalcItems(infoPtr);
     1568
     1569  if (uHeight != infoPtr->uItemHeight)
     1570  {
     1571    infoPtr->uInternalStatus |= TV_CALCALL;
     1572    TREEVIEW_CalcItems(infoPtr);
     1573  }
    15391574
    15401575  if (lParam)
     
    16461681{
    16471682    TREEVIEW_ITEM *wineItem;
    1648     const HTREEITEM *pItem = (HTREEITEM *)lParam;
     1683    const HTREEITEM *pItem = (HTREEITEM*)lParam;
    16491684    LPRECT lpRect = (LPRECT)lParam;
    16501685
     
    16521687     * validate parameters
    16531688     */
    1654     if ((pItem == NULL) || (lpRect == NULL))
     1689    if (pItem == NULL)
    16551690        return FALSE;
    16561691
     
    18211856        retval = infoPtr->dropItem;
    18221857        break;
     1858
     1859      case TVGN_LASTVISIBLE:
     1860        retval = TREEVIEW_GetLastListItem(infoPtr,infoPtr->root);
     1861        break;
    18231862    }
    18241863
     
    18481887      case TVGN_CHILD:
    18491888        retval = wineItem->firstChild;
    1850         break;
    1851 
    1852       case TVGN_LASTVISIBLE:
    1853         retval = TREEVIEW_GetLastListItem(infoPtr, wineItem);
    18541889        break;
    18551890
     
    19812016            LONG plussize = (rectsize + 1) * 3 / 4;
    19822017
    1983             HPEN hNewPen = CreatePen(PS_SOLID, 0, infoPtr->clrLine);
    1984             HPEN hOldPen = SelectObject(hdc, hNewPen);
     2018            HPEN hNewPen  = CreatePen(PS_SOLID, 0, infoPtr->clrLine);
     2019            HPEN hOldPen  = SelectObject(hdc, hNewPen);
     2020            HBRUSH hbr    = CreateSolidBrush(infoPtr->clrBk);
     2021            HBRUSH hbrOld = SelectObject(hdc, hbr);
    19852022
    19862023            Rectangle(hdc, centerx - rectsize, centery - rectsize,
    19872024                      centerx + rectsize + 1, centery + rectsize + 1);
     2025
     2026            SelectObject(hdc, hbrOld);
     2027            DeleteObject(hbr);
    19882028
    19892029            SelectObject(hdc, hOldPen);
     
    20712111        if (infoPtr->himlState && imageIndex)
    20722112        {
    2073             ImageList_Draw(infoPtr->himlState, imageIndex - 1, hdc,
     2113            ImageList_Draw(infoPtr->himlState, imageIndex, hdc,
    20742114                           wineItem->stateOffset,
    20752115                           centery - infoPtr->stateImageHeight / 2,
     
    21692209
    21702210            /* Draw the box arround the selected item */
    2171             if ((wineItem->state & TVIS_SELECTED) && inFocus)
     2211            if ((wineItem == infoPtr->selectedItem) && inFocus)
    21722212            {
    21732213                HPEN hNewPen = CreatePen(PS_DOT, 0,
     
    24832523    if (pSort)
    24842524    {
    2485         pfnCompare = TREEVIEW_CallBackCompare;
     2525        pfnCompare = (PFNDPACOMPARE)TREEVIEW_CallBackCompare;
    24862526        lpCompare = (LPARAM)pSort;
    24872527    }
    24882528    else
    24892529    {
    2490         pfnCompare = TREEVIEW_SortOnName;
     2530        pfnCompare = (PFNDPACOMPARE)TREEVIEW_SortOnName;
    24912531        lpCompare = (LPARAM)infoPtr;
    24922532    }
     
    26512691        infoPtr->selectedItem = wineItem;
    26522692
    2653         TREEVIEW_EnsureVisible(infoPtr, wineItem);
     2693        TREEVIEW_EnsureVisible(infoPtr,wineItem,TRUE);
    26542694    }
    26552695
     
    26892729        }
    26902730
     2731        TREEVIEW_SendExpanded(infoPtr, wineItem, TVE_EXPAND);
     2732
    26912733        wineItem->state |= TVIS_EXPANDEDONCE;
    2692 
    2693         TREEVIEW_SendExpanded(infoPtr, wineItem, TVE_EXPAND);
    2694 
    2695         //TRACE("  TVN_ITEMEXPANDED sent...\n");
    26962734    }
    26972735    else
     
    28132851    TREEVIEW_ITEM *wineItem;
    28142852    RECT rect;
    2815     UINT status, x, y;
     2853    UINT status;
     2854    LONG x, y;
    28162855
    28172856    if (!lpht) return 0;
     
    30453084  /* Make shure that edit item is selected */
    30463085
    3047   TREEVIEW_DoSelectItem ( infoPtr, TVGN_CARET, hItem, TVC_UNKNOWN);
     3086  TREEVIEW_DoSelectItem(infoPtr,TVGN_CARET,hItem,TVC_UNKNOWN);
     3087  TREEVIEW_EnsureVisible(infoPtr,hItem,TRUE);
    30483088
    30493089  TREEVIEW_UpdateDispInfo(infoPtr, editItem, TVIF_TEXT);
     
    32793319            if (msg.message == WM_MOUSEMOVE)
    32803320            {
    3281                 pt.x = (INT)LOWORD(msg.lParam);
    3282                 pt.y = (INT)HIWORD(msg.lParam);
     3321                pt.x = (LONG)(INT16)LOWORD(msg.lParam);
     3322                pt.y = (LONG)(INT16)HIWORD(msg.lParam);
    32833323                if (PtInRect(&r, pt))
    32843324                    continue;
     
    33143354  TV_HITTESTINFO hit;
    33153355
    3316   hit.pt.x = (INT)LOWORD(lParam);
    3317   hit.pt.y = (INT)HIWORD(lParam);
     3356  hit.pt.x = (LONG)(INT16)LOWORD(lParam);
     3357  hit.pt.y = (LONG)(INT16)HIWORD(lParam);
     3358
    33183359  SetFocus (infoPtr->hwnd);
    33193360
     
    33573398      case TVHT_ONITEMLABEL:
    33583399      case TVHT_ONITEMICON:
    3359       case TVHT_ONITEMSTATEICON:
    33603400      case TVHT_ONITEMBUTTON:
    33613401        TREEVIEW_Toggle(infoPtr, wineItem, TRUE);
     3402        break;
     3403
     3404      case TVHT_ONITEMSTATEICON:
     3405        if (infoPtr->dwStyle & TVS_CHECKBOXES)
     3406          TREEVIEW_ToggleItemState(infoPtr, wineItem);
     3407        else
     3408          TREEVIEW_Toggle(infoPtr, wineItem, TRUE);
    33623409        break;
    33633410    }
     
    33843431  }
    33853432
    3386   ht.pt.x = (INT)LOWORD(lParam);
    3387   ht.pt.y = (INT)HIWORD(lParam);
     3433  ht.pt.x = (LONG)(INT16)LOWORD(lParam);
     3434  ht.pt.y = (LONG)(INT16)HIWORD(lParam);
    33883435
    33893436  TREEVIEW_HitTest(infoPtr,&ht,FALSE);
     
    34543501   }
    34553502
    3456    ht.pt.x = (INT)LOWORD(lParam);
    3457    ht.pt.y = (INT)HIWORD(lParam);
     3503   ht.pt.x = (LONG)(INT16)LOWORD(lParam);
     3504   ht.pt.y = (LONG)(INT16)HIWORD(lParam);
    34583505
    34593506   TREEVIEW_HitTest(infoPtr,&ht,FALSE);
     
    35893636                                      prevSelect,
    35903637                                      newSelect))
    3591         return FALSE;       /* FIXME: OK? */
     3638        return FALSE;
    35923639
    35933640      if (prevSelect)
     
    36173664
    36183665      TREEVIEW_UnqueueRefresh(infoPtr,TRUE,TRUE);
    3619       TREEVIEW_EnsureVisible(infoPtr,infoPtr->selectedItem);
     3666      TREEVIEW_EnsureVisible(infoPtr,infoPtr->selectedItem,FALSE);
    36203667      if (infoPtr->dwStyle & TVS_FULLROWSELECT)
    36213668      {
     
    37753822/* Scrolling ************************************************************/
    37763823
    3777 static LRESULT TREEVIEW_EnsureVisible(TREEVIEW_INFO *infoPtr,HTREEITEM item)
     3824static LRESULT TREEVIEW_EnsureVisible(TREEVIEW_INFO *infoPtr,HTREEITEM item,BOOL bHScroll)
    37783825{
    37793826  RECT rect;
    3780   INT scrollY;
     3827  INT scrollY = 0,scrollX = 0;
    37813828
    37823829  if (!item) return FALSE;
     
    38073854    mod = scrollY % infoPtr->uItemHeight;
    38083855    if (mod) scrollY += infoPtr->uItemHeight-mod;
    3809   } else return FALSE;
    3810 
    3811   if (scrollY != 0)
     3856  }
     3857
     3858  if (bHScroll)
     3859  {
     3860    if (!item->calculated) TREEVIEW_CalcItem(infoPtr,item,0);
     3861
     3862    if (item->textOffset < rect.left)
     3863      scrollX = item->textOffset-rect.left;
     3864    else if (item->textOffset+item->textWidth > rect.right)
     3865    {
     3866      scrollX = item->textOffset+item->textWidth-rect.right;
     3867      if (scrollX > item->textOffset-rect.left) scrollX = item->textOffset-rect.left;
     3868    }
     3869  }
     3870
     3871  if ((scrollY != 0) || (scrollX != 0))
    38123872  {
    38133873    infoPtr->lefttop.y += scrollY;
     3874    infoPtr->lefttop.x += scrollX;
    38143875    TREEVIEW_CalcItems(infoPtr);
    3815     ScrollWindowEx(infoPtr->hwnd,0,-scrollY,NULL,NULL,0,NULL,SW_INVALIDATE | SW_SCROLLCHILDREN | (infoPtr->uScrollTime << 16));
     3876    ScrollWindowEx(infoPtr->hwnd,-scrollX,-scrollY,NULL,NULL,0,NULL,SW_INVALIDATE | SW_SCROLLCHILDREN | (infoPtr->uScrollTime << 16));
    38163877
    38173878    return TRUE;
     
    40734134  if (infoPtr->dwStyle & TVS_CHECKBOXES)
    40744135  {
    4075     HBITMAP hbmLoad;
     4136    RECT rc;
     4137    HBITMAP hbm, hbmOld;
     4138    HDC hdc;
    40764139    int nIndex;
    40774140
    4078     infoPtr->himlState = ImageList_Create (16, 16,ILC_COLOR | ILC_MASK, 15, 1);
    4079 
    4080     //MSDN docu says: uses DrawFrameControl but never believe what they write
    4081     hbmLoad = LoadBitmapA (COMCTL32_hModule, MAKEINTRESOURCEA(IDT_CHECK));
    4082     nIndex = ImageList_AddMasked (infoPtr->himlState, hbmLoad, CLR_DEFAULT);
    4083     DeleteObject (hbmLoad);
     4141    infoPtr->himlState = ImageList_Create(16,16,ILC_COLOR | ILC_MASK,3,0);
     4142
     4143    hdc = CreateCompatibleDC(0);
     4144    hbm = CreateCompatibleBitmap(hdc, 48, 16);
     4145    hbmOld = SelectObject(hdc, hbm);
     4146
     4147    rc.left  = 0;   rc.top    = 0;
     4148    rc.right = 48;  rc.bottom = 16;
     4149    FillRect(hdc, &rc, (HBRUSH)(COLOR_WINDOW+1));
     4150
     4151    rc.left  = 18;   rc.top    = 2;
     4152    rc.right = 30;   rc.bottom = 14;
     4153    DrawFrameControl(hdc, &rc, DFC_BUTTON,
     4154                     DFCS_BUTTONCHECK|DFCS_FLAT);
     4155
     4156    rc.left  = 34;   rc.right  = 46;
     4157    DrawFrameControl(hdc, &rc, DFC_BUTTON,
     4158                     DFCS_BUTTONCHECK|DFCS_FLAT|DFCS_CHECKED);
     4159
     4160    nIndex = ImageList_AddMasked(infoPtr->himlState, hbm,
     4161                                 GetSysColor(COLOR_WINDOW));
     4162    //TRACE("chckbox index %d\n", nIndex);
     4163    SelectObject(hdc, hbmOld);
     4164    DeleteObject(hbm);
     4165    DeleteDC(hdc);
    40844166
    40854167    infoPtr->stateImageWidth = 16;
     
    41974279
    41984280    case VK_END:
    4199         newSelection = TREEVIEW_GetLastListItem(infoPtr,
    4200                                                 infoPtr->root->lastChild);
     4281        newSelection = TREEVIEW_GetLastListItem(infoPtr,infoPtr->root);
    42014282        break;
    42024283
     
    42714352    if (TREEVIEW_DoSelectItem(infoPtr,TVGN_CARET,newSelection,TVC_BYKEYBOARD))
    42724353    {
    4273       TREEVIEW_EnsureVisible(infoPtr, newSelection);
     4354      TREEVIEW_EnsureVisible(infoPtr,newSelection,FALSE);
    42744355    }
    42754356  }
     
    42934374
    42944375static LRESULT
    4295 TREEVIEW_StyleChanged(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
    4296 {
    4297   //TRACE("(%x %lx)\n", wParam, lParam);
    4298 
     4376TREEVIEW_StyleChanged(TREEVIEW_INFO *infoPtr,WPARAM wParam,LPARAM lParam)
     4377{
    42994378  if (wParam == GWL_STYLE)
    4300     infoPtr->dwStyle = ((LPSTYLESTRUCT)lParam)->styleNew;
     4379  {
     4380    DWORD dwNewStyle = ((LPSTYLESTRUCT)lParam)->styleNew;
     4381
     4382    /* we have to take special care about tooltips */
     4383    if ((infoPtr->dwStyle ^ dwNewStyle) & TVS_NOTOOLTIPS)
     4384    {
     4385      if (infoPtr->dwStyle & TVS_NOTOOLTIPS)
     4386      {
     4387        infoPtr->hwndToolTip = createToolTip(infoPtr->hwnd,TTF_TRACK | TTF_ABSOLUTE | TTF_TRANSPARENT,TRUE);
     4388        SendMessageA(infoPtr->hwndToolTip,WM_SETFONT,infoPtr->hFont,0);
     4389      } else
     4390      {
     4391        DestroyWindow(infoPtr->hwndToolTip);
     4392        infoPtr->hwndToolTip = 0;
     4393      }
     4394    }
     4395
     4396    infoPtr->dwStyle = dwNewStyle;
     4397  }
    43014398
    43024399  if (infoPtr->hwndEdit) SetFocus(infoPtr->hwnd);
     
    47144811  {
    47154812    TREEVIEW_SelectItem(infoPtr,(WPARAM)TVGN_CARET,(LPARAM)nearest);
    4716     TREEVIEW_EnsureVisible(infoPtr,nearest);
     4813    TREEVIEW_EnsureVisible(infoPtr,nearest,FALSE);
    47174814    infoPtr->dwISearchTime = GetTickCount();
    47184815
     
    47294826    infoPtr->uISearchLen = len;
    47304827    TREEVIEW_SelectItem(infoPtr,(WPARAM)TVGN_CARET,(LPARAM)item);
    4731     TREEVIEW_EnsureVisible(infoPtr,item);
     4828    TREEVIEW_EnsureVisible(infoPtr,item,FALSE);
    47324829    infoPtr->dwISearchTime = GetTickCount();
    47334830  } else
     
    48554952
    48564953        case TVM_ENSUREVISIBLE:
    4857           return TREEVIEW_EnsureVisible(infoPtr,(HTREEITEM)lParam);
     4954          return TREEVIEW_EnsureVisible(infoPtr,(HTREEITEM)lParam,TRUE);
    48584955
    48594956        case TVM_SORTCHILDRENCB:
Note: See TracChangeset for help on using the changeset viewer.