Ignore:
Timestamp:
Feb 17, 2000, 6:26:51 PM (26 years ago)
Author:
cbratschi
Message:

COMCTL32 5.80 changes

File:
1 edited

Legend:

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

    r2806 r2814  
    1 /* $Id: treeview.c,v 1.26 2000-02-16 17:22:19 cbratschi Exp $ */
     1/* $Id: treeview.c,v 1.27 2000-02-17 17:26:51 cbratschi Exp $ */
    22/* Treeview control
    33 *
     
    2222 *
    2323 * Status: in progress
    24  * Version: 5.00
     24 * Version: 5.80
    2525 */
    2626
     
    3333/* CB: todo
    3434
    35  - bug in SetScrollInfo/ShowScrollBar: WM_SIZE and WM_NCPAINT problems
     35 - bug in SetScrollInfo/ShowScrollBar: WM_SIZE and WM_NCPAINT problems (i.e. RegEdit)
     36 - WM_HSCROLL: some rects are wrong
     37 - TVS_FULLROWSELECT
     38 - TVS_SINGLEEXPAND
     39 - TVS_TRACKSELECT (called hottrack)
     40 - TVS_INFOTIP, TVS_NOTOOLTIPS and tooltip support
     41 - WM_ENABLE: draw disabled control
    3642*/
    3743
     
    447453{
    448454  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    449   INT cx,cy,prevHeight=infoPtr->uItemHeight;
    450 
    451 //  TRACE (treeview,"\n");
    452   if (wParam==-1) {
    453         infoPtr->uItemHeight=-1;
    454         return prevHeight;
     455  INT cx,cy,prevHeight = infoPtr->uItemHeight;
     456
     457  if (wParam==-1)
     458  {
     459    infoPtr->uItemHeight = -1;
     460
     461    return prevHeight;
    455462  }
    456463
    457464  ImageList_GetIconSize (infoPtr->himlNormal, &cx, &cy);
    458465
    459   if (wParam>cy) cy=wParam;
    460   infoPtr->uItemHeight=cy;
    461 
    462   if (!( GetWindowLongA( hwnd, GWL_STYLE) & TVS_NONEVENHEIGHT))
    463         infoPtr->uItemHeight = (INT) wParam & 0xfffffffe;
     466  if (wParam > cy) cy = wParam;
     467  infoPtr->uItemHeight = cy;
     468
     469  if (!(GetWindowLongA(hwnd, GWL_STYLE) & TVS_NONEVENHEIGHT))
     470    if (infoPtr->uItemHeight & 0x1) infoPtr->uItemHeight += 1;
     471
    464472  return prevHeight;
    465473}
     
    470478  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    471479
    472 //  TRACE (treeview,"\n");
    473480  return infoPtr->uItemHeight;
    474481}
     
    606613//pen must be selected!
    607614
    608 static void TREEVIEW_DrawVLines(HDC hdc,TREEVIEW_INFO *infoPtr,TREEVIEW_ITEM *wineItem)
     615static void TREEVIEW_DrawVLines(HDC hdc,TREEVIEW_INFO *infoPtr,TREEVIEW_ITEM *item)
    609616{
    610617  POINT points[2];
    611618  INT center;
    612619
    613   center = (wineItem->rect.top+wineItem->rect.bottom)/2;
     620  center = (item->rect.top+item->rect.bottom)/2;
    614621//INT cChildren = TREEVIEW_HasChildren(hwnd,wineItem);
    615   if ((wineItem->iLevel == 0) && !wineItem->upsibling && wineItem->sibling)
    616   {
    617     TREEVIEW_ITEM *lastItem = &infoPtr->items[(INT)wineItem->sibling];
     622  if ((item->iLevel == 0) && !item->upsibling && item->sibling)
     623  {
     624    TREEVIEW_ITEM *lastItem = &infoPtr->items[(INT)item->sibling];
    618625
    619626    while (lastItem->sibling) lastItem = &infoPtr->items[(INT)lastItem->sibling];
     
    629636  }
    630637
    631   if (wineItem->firstChild && (wineItem->state & TVIS_EXPANDED))
    632   {
    633     TREEVIEW_ITEM *lastItem = &infoPtr->items[(INT)wineItem->firstChild];
     638  if (item->firstChild && (item->state & TVIS_EXPANDED))
     639  {
     640    TREEVIEW_ITEM *lastItem = &infoPtr->items[(INT)item->firstChild];
    634641
    635642    while (lastItem->sibling) lastItem = &infoPtr->items[(INT)lastItem->sibling];
    636643
    637644    points[0].y = (lastItem->upsibling != NULL) ?
    638                    wineItem->rect.bottom-3:  /* is linked to an icon       */
    639                    wineItem->rect.bottom+1;  /* is linked to a +/- box     */
    640     points[1].x = points[0].x = 28+20*wineItem->iLevel-infoPtr->cx;
     645                   item->rect.bottom-3:  /* is linked to an icon       */
     646                   item->rect.bottom+1;  /* is linked to a +/- box     */
     647    points[1].x = points[0].x = 28+20*item->iLevel-infoPtr->cx;
    641648    points[1].y = (lastItem->rect.top+lastItem->rect.bottom)/2;  /* is linked to a +/- box     */
    642649#ifdef OS2LINEHACK
     
    649656
    650657static void
    651 TREEVIEW_DrawItem(HWND hwnd,HDC hdc,TREEVIEW_ITEM *wineItem,DWORD dwStyle,TREEVIEW_INFO *infoPtr)
    652 {
    653   INT   center,xpos,cx,cy, cditem;
     658TREEVIEW_DrawItem(HWND hwnd,HDC hdc,TREEVIEW_ITEM *item,DWORD dwStyle,TREEVIEW_INFO *infoPtr)
     659{
     660  INT   center,cditem;
    654661  HFONT hOldFont;
    655   UINT  uTextJustify = DT_LEFT;
    656   RECT  r;
    657 
    658   if (!wineItem->calculated) TREEVIEW_CalcItem(hwnd,hdc,dwStyle,infoPtr,wineItem);
    659 
    660   if (wineItem->state & TVIS_BOLD)
    661     hOldFont = SelectObject (hdc, infoPtr->hBoldFont);
     662
     663  if (!item->calculated) TREEVIEW_CalcItem(hwnd,hdc,dwStyle,infoPtr,item);
     664
     665  if (item->state & TVIS_BOLD)
     666    hOldFont = SelectObject(hdc,infoPtr->hBoldFont);
    662667  else
    663     hOldFont = SelectObject (hdc, infoPtr->hFont);
     668    hOldFont = SelectObject(hdc,infoPtr->hFont);
    664669
    665670  cditem = 0;
     
    667672  if (infoPtr->cdmode & CDRF_NOTIFYITEMDRAW)
    668673  {
    669     cditem = TREEVIEW_SendCustomDrawItemNotify(hwnd, hdc, wineItem, CDDS_ITEMPREPAINT);
     674    cditem = TREEVIEW_SendCustomDrawItemNotify(hwnd, hdc, item, CDDS_ITEMPREPAINT);
    670675
    671676    if (cditem & CDRF_SKIPDEFAULT) return;
     
    677682   * Set drawing starting points
    678683   */
    679   r      = wineItem->rect;               /* this item rectangle */
    680   center = (r.top+r.bottom)/2;           /* this item vertical center */
    681   xpos   = r.left + TREEVIEW_LEFT_MARGIN;/* horizontal starting point */
     684  center = (item->rect.top+item->rect.bottom)/2; /* this item vertical center */
    682685
    683686  /*
     
    704707      hOldPen = SelectObject(hdc,hnewPen);
    705708
    706       TREEVIEW_DrawVLines(hdc,infoPtr,wineItem);
     709      TREEVIEW_DrawVLines(hdc,infoPtr,item);
    707710
    708711      /*
     
    710713       * to the up sibling or to the parent node.
    711714       */
    712       if (wineItem->upsibling)
    713         upNode  = TREEVIEW_ValidItem (infoPtr, wineItem->upsibling);
    714       else if (wineItem->parent)
    715         upNode  = TREEVIEW_ValidItem (infoPtr, wineItem->parent);
     715      if (item->upsibling)
     716        upNode  = TREEVIEW_ValidItem (infoPtr, item->upsibling);
     717      else if (item->parent)
     718        upNode  = TREEVIEW_ValidItem (infoPtr, item->parent);
    716719
    717720      if (upNode) upRect = upNode->rect;
    718721
    719       if (wineItem->iLevel == 0)
     722      if (item->iLevel == 0)
    720723      {
    721724        points[1].x = upRect.left+8;
     
    724727      } else
    725728      {
    726         points[1].x = 8+(20*wineItem->iLevel)-infoPtr->cx;
     729        points[1].x = 8+(20*item->iLevel)-infoPtr->cx;
    727730        points[1].y = points[0].y = center;
    728731        points[0].x = points[1].x + 10;
     
    745748   * Display the (+/-) signs
    746749   */
    747   if (wineItem->iLevel != 0)/*  update position only for non root node */
    748     xpos += 5*wineItem->iLevel;
    749 
    750750  if ((dwStyle & TVS_HASBUTTONS) && (dwStyle & TVS_HASLINES))
    751751  {
    752     if (TREEVIEW_HasChildren(hwnd, wineItem))
    753     {
    754       Rectangle(hdc,wineItem->expandBox.left,wineItem->expandBox.top,wineItem->expandBox.right,wineItem->expandBox.bottom);
    755 
    756       MoveToEx (hdc, xpos-2, center, NULL);
    757       LineTo   (hdc, xpos+3, center);
    758 
    759       if (!(wineItem->state & TVIS_EXPANDED))
    760       {
    761         MoveToEx (hdc, xpos,   center-2, NULL);
    762         LineTo   (hdc, xpos,   center+3);
     752    if (TREEVIEW_HasChildren(hwnd,item))
     753    {
     754      INT vCenter = (item->expandBox.top+item->expandBox.bottom)/2;
     755      INT hCenter = (item->expandBox.right+item->expandBox.left)/2;
     756
     757      Rectangle(hdc,item->expandBox.left,item->expandBox.top,item->expandBox.right,item->expandBox.bottom);
     758
     759      MoveToEx(hdc,item->expandBox.left+2,vCenter,NULL);
     760      LineTo(hdc,item->expandBox.right-2,vCenter);
     761
     762      if (!(item->state & TVIS_EXPANDED))
     763      {
     764        MoveToEx(hdc,hCenter,item->expandBox.top+2,NULL);
     765        LineTo(hdc,hCenter,item->expandBox.bottom-2);
    763766      }
    764767    }
     
    768771   * Display the image associated with this item
    769772   */
    770   xpos += 13; /* update position */
    771   if (wineItem->mask & (TVIF_IMAGE|TVIF_SELECTEDIMAGE))
     773  if ((item->mask & (TVIF_IMAGE | TVIF_SELECTEDIMAGE)) || (dwStyle & TVS_CHECKBOXES))
    772774  {
    773775    INT        imageIndex;
     
    779781     */
    780782    if (infoPtr->himlState)
    781       himlp=&infoPtr->himlState;
    782     imageIndex=wineItem->state >> 12;
    783 
    784     if ((himlp) && (imageIndex))
     783      himlp =& infoPtr->himlState;
     784    imageIndex = item->state >> 12;
     785
     786    if (himlp && imageIndex)
    785787    {
    786788      imageIndex--;       /* see FIXME */
    787       ImageList_Draw ( *himlp, imageIndex, hdc, xpos-2, r.top+1, ILD_NORMAL);
    788       xpos += wineItem->statebitmap.right-wineItem->statebitmap.left;
     789      ImageList_Draw(*himlp,imageIndex,hdc,item->statebitmap.left,item->statebitmap.top,ILD_NORMAL);
    789790    }
    790791
     
    793794     */
    794795
    795     himlp=NULL;
     796    himlp = NULL;
    796797    if (infoPtr->himlNormal)
    797       himlp=&infoPtr->himlNormal; /* get the image list */
    798 
    799     imageIndex = wineItem->iImage;
    800     if ( (wineItem->state & TVIS_SELECTED) &&
    801          (wineItem->iSelectedImage))
    802     {
    803 
     798      himlp = &infoPtr->himlNormal; /* get the image list */
     799
     800    imageIndex = item->iImage;
     801    if ((item->state & TVIS_SELECTED) && item->iSelectedImage)
     802    {
    804803      /* The item is curently selected */
    805       if (wineItem->iSelectedImage == I_IMAGECALLBACK)
    806         TREEVIEW_SendDispInfoNotify(hwnd, wineItem, TVN_GETDISPINFO, TVIF_SELECTEDIMAGE);
    807 
    808       imageIndex = wineItem->iSelectedImage;
     804      if (item->iSelectedImage == I_IMAGECALLBACK)
     805        TREEVIEW_SendDispInfoNotify(hwnd, item, TVN_GETDISPINFO, TVIF_SELECTEDIMAGE);
     806
     807      imageIndex = item->iSelectedImage;
    809808    } else
    810809    {
    811810      /* The item is not selected */
    812       if (wineItem->iImage == I_IMAGECALLBACK)
    813         TREEVIEW_SendDispInfoNotify(hwnd, wineItem, TVN_GETDISPINFO, TVIF_IMAGE);
    814 
    815       imageIndex = wineItem->iImage;
     811      if (item->iImage == I_IMAGECALLBACK)
     812        TREEVIEW_SendDispInfoNotify(hwnd, item, TVN_GETDISPINFO, TVIF_IMAGE);
     813
     814      imageIndex = item->iImage;
    816815    }
    817816
     
    820819      int ovlIdx = 0;
    821820
    822       if(wineItem->stateMask & TVIS_OVERLAYMASK)
    823         ovlIdx = wineItem->state & TVIS_OVERLAYMASK;
    824 
    825       ImageList_Draw ( *himlp, imageIndex, hdc, xpos-2, r.top+1, ILD_NORMAL|ovlIdx);
    826       xpos += wineItem->bitmap.right-wineItem->bitmap.left;
     821      if(item->stateMask & TVIS_OVERLAYMASK)
     822        ovlIdx = item->state & TVIS_OVERLAYMASK;
     823
     824      ImageList_Draw(*himlp,imageIndex,hdc,item->bitmap.left,item->bitmap.top,ILD_NORMAL | ovlIdx);
    827825    }
    828826  }
     
    832830   */
    833831  /* Don't paint item's text if it's being edited */
    834   if (!infoPtr->hwndEdit || (infoPtr->editItem != wineItem->hItem))
    835   {
    836     r.left=xpos;
    837     if ((wineItem->mask & TVIF_TEXT) && (wineItem->pszText))
    838     {
     832  if (!infoPtr->hwndEdit || (infoPtr->editItem != item->hItem))
     833  {
     834    if ((item->mask & TVIF_TEXT) && (item->pszText))
     835    {
     836      UINT  uTextJustify = DT_LEFT;
    839837      COLORREF oldTextColor = 0;
    840838      INT      oldBkMode;
     
    842840      BOOL     inFocus = GetFocus() == hwnd;
    843841
    844       r.left += 3;
    845       r.right -= 3;
    846842      oldBkMode = SetBkMode(hdc, TRANSPARENT);
    847843
     
    852848       * - Otherwise - don't fill background
    853849       */
    854        if ((wineItem->state & TVIS_DROPHILITED) ||
    855            ((wineItem->state & TVIS_SELECTED) &&
    856             (inFocus || (GetWindowLongA( hwnd, GWL_STYLE) & TVS_SHOWSELALWAYS))))
    857        {
    858            if ((wineItem->state & TVIS_DROPHILITED) || inFocus)
    859            {
    860                hbrBk = CreateSolidBrush(GetSysColor( COLOR_HIGHLIGHT));
    861                oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_HIGHLIGHTTEXT));
    862            }
    863            else
    864            {
    865                hbrBk = CreateSolidBrush(GetSysColor( COLOR_BTNFACE));
    866 
    867                if (infoPtr->clrText == -1)
    868                    oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_WINDOWTEXT));
    869                else
    870                    oldTextColor = SetTextColor(hdc, infoPtr->clrText);
    871            }
     850      if ((item->state & TVIS_DROPHILITED) ||
     851          ((item->state & TVIS_SELECTED) &&
     852          (inFocus || (GetWindowLongA( hwnd, GWL_STYLE) & TVS_SHOWSELALWAYS))))
     853      {
     854        if ((item->state & TVIS_DROPHILITED) || inFocus)
     855        {
     856          hbrBk = CreateSolidBrush(GetSysColor( COLOR_HIGHLIGHT));
     857          oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_HIGHLIGHTTEXT));
     858        } else
     859        {
     860          hbrBk = CreateSolidBrush(GetSysColor( COLOR_BTNFACE));
     861
     862          if (infoPtr->clrText == -1)
     863            oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_WINDOWTEXT));
     864          else
     865            oldTextColor = SetTextColor(hdc, infoPtr->clrText);
     866        }
     867      } else
     868      {
     869        if (infoPtr->clrText == -1)
     870          oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_WINDOWTEXT));
     871        else
     872          oldTextColor = SetTextColor(hdc, infoPtr->clrText);
    872873      }
    873       else
    874       {
    875           if (infoPtr->clrText == -1)
    876               oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_WINDOWTEXT));
    877           else
    878               oldTextColor = SetTextColor(hdc, infoPtr->clrText);
     874
     875      if (item->pszText == LPSTR_TEXTCALLBACKW)
     876        TREEVIEW_SendDispInfoNotify (hwnd, item, TVN_GETDISPINFO, TVIF_TEXT);
     877
     878      if (hbrBk)
     879      {
     880        FillRect(hdc, &item->text, hbrBk);
     881        DeleteObject(hbrBk);
    879882      }
    880883
    881       if (wineItem->pszText == LPSTR_TEXTCALLBACKW)
    882         TREEVIEW_SendDispInfoNotify (hwnd, wineItem, TVN_GETDISPINFO, TVIF_TEXT);
    883 
    884       if (hbrBk)
    885       {
    886           FillRect(hdc, &wineItem->text, hbrBk);
    887           DeleteObject(hbrBk);
    888       }
    889 
    890       wineItem->text.left += 2;
     884      item->text.left += 2;
    891885
    892886      /* Draw it */
    893887      DrawTextW ( hdc,
    894         wineItem->pszText,
    895         lstrlenW(wineItem->pszText),
    896         &wineItem->text,
     888        item->pszText,
     889        lstrlenW(item->pszText),
     890        &item->text,
    897891        uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
    898892
    899        wineItem->text.left -= 2;
     893      item->text.left -= 2;
    900894
    901895      /* Restore the hdc state */
     
    903897
    904898      /* Draw the box arround the selected item */
    905       if (wineItem->state & TVIS_SELECTED)
     899      if (item->state & TVIS_SELECTED)
    906900      {
    907901        HPEN  hNewPen     = CreatePen(PS_DOT, 0, GetSysColor(COLOR_WINDOWTEXT) );
     
    910904        POINT points[5];
    911905
    912         points[4].x = points[0].x = wineItem->text.left;
    913         points[4].y = points[0].y = wineItem->text.top;
    914         points[1].x = wineItem->text.right-1 ;
    915         points[1].y = wineItem->text.top;
    916         points[2].x = wineItem->text.right-1;
    917         points[2].y = wineItem->text.bottom-1;
    918         points[3].x = wineItem->text.left;
    919         points[3].y = wineItem->text.bottom-1;
     906        points[4].x = points[0].x = item->text.left;
     907        points[4].y = points[0].y = item->text.top;
     908        points[1].x = item->text.right-1 ;
     909        points[1].y = item->text.top;
     910        points[2].x = item->text.right-1;
     911        points[2].y = item->text.bottom-1;
     912        points[3].x = item->text.left;
     913        points[3].y = item->text.bottom-1;
    920914
    921915        Polyline (hdc,points,5);
     
    927921
    928922      if (oldBkMode != TRANSPARENT)
    929           SetBkMode(hdc, oldBkMode);
     923        SetBkMode(hdc, oldBkMode);
    930924    }
    931925  }
     
    936930  //              TRACE ("item:%d,mark:%d\n", (int)wineItem->hItem,
    937931  //                             (int) infoPtr->insertMarkItem);
    938   if (wineItem->hItem==infoPtr->insertMarkItem)
     932  if (item->hItem == infoPtr->insertMarkItem)
    939933  {
    940934    HPEN hNewPen, hOldPen;
     
    945939
    946940    if (infoPtr->insertBeforeorAfter)
    947       offset=wineItem->text.top+1;
     941      offset = item->text.top+1;
    948942    else
    949       offset=wineItem->text.bottom-1;
    950 
    951     MoveToEx (hdc, wineItem->text.left, offset-3, NULL);
    952     LineTo (hdc, wineItem->text.left, offset+3);
    953 
    954     MoveToEx (hdc, wineItem->text.left, offset, NULL);
    955     LineTo (hdc, r.right-2, offset);
    956 
    957     MoveToEx (hdc, r.right-2, offset+3, NULL);
    958     LineTo (hdc, r.right-2, offset-3);
     943      offset = item->text.bottom-1;
     944
     945    MoveToEx(hdc,item->text.left, offset-3, NULL);
     946    LineTo(hdc,item->text.left, offset+3);
     947
     948    MoveToEx(hdc,item->text.left,offset,NULL);
     949    LineTo(hdc,item->text.right-2,offset);
     950
     951    MoveToEx(hdc,item->text.right-2, offset+3, NULL);
     952    LineTo(hdc,item->text.right-2, offset-3);
    959953
    960954    DeleteObject(hNewPen);
     
    964958
    965959  if (cditem & CDRF_NOTIFYPOSTPAINT)
    966   {
    967     cditem = TREEVIEW_SendCustomDrawItemNotify(hwnd, hdc, wineItem, CDDS_ITEMPOSTPAINT);
    968     //TRACE("postpaint:cditem-app returns 0x%x\n",cditem);
    969   }
     960    cditem = TREEVIEW_SendCustomDrawItemNotify(hwnd, hdc, item, CDDS_ITEMPOSTPAINT);
    970961
    971962  SelectObject (hdc, hOldFont);
     
    11541145    } else
    11551146    {
    1156       rect.left += TREEVIEW_LEFT_MARGIN;
    1157       if (item->iLevel != 0) rect.left += (5*item->iLevel);
    1158       rect.left += 15;
     1147      DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
     1148
     1149      //redraw text and image
     1150      if (((item->mask & (TVIF_IMAGE | TVIF_SELECTEDIMAGE)) || (dwStyle & TVS_CHECKBOXES)) && (item->iSelectedImage != item->iImage))
     1151      {
     1152        rect.left += TREEVIEW_LEFT_MARGIN;
     1153        if (item->iLevel != 0) rect.left += (5*item->iLevel);
     1154        rect.left += 15;
     1155      } else rect = item->text;
    11591156    }
    11601157
     
    11941191  xpos += 13; /* update position */
    11951192
    1196   if (item->mask & (TVIF_IMAGE | TVIF_SELECTEDIMAGE))
     1193  if ((item->mask & (TVIF_IMAGE | TVIF_SELECTEDIMAGE)) || (dwStyle & TVS_CHECKBOXES))
    11971194  {
    11981195    INT        imageIndex,cx,cy;
     
    12721269    item->text.bottom= r.bottom;
    12731270
    1274     if (item->pszText== LPSTR_TEXTCALLBACKW)
    1275     {
    1276       //TRACE("LPSTR_TEXTCALLBACK\n");
     1271    if (item->pszText == LPSTR_TEXTCALLBACKW)
    12771272      TREEVIEW_SendDispInfoNotify (hwnd, item, TVN_GETDISPINFO, TVIF_TEXT);
    1278     }
    12791273
    12801274    if (!hdc)
     
    13411335  GetTextMetricsA (hdc, &tm);
    13421336  itemHeight = MAX(tm.tmHeight+tm.tmExternalLeading,itemHeight);
     1337  if (!(dwStyle & TVS_NONEVENHEIGHT))
     1338    if (itemHeight & 0x1) itemHeight += 1; //important for PS_DOT pen!
    13431339  infoPtr->uRealItemHeight = itemHeight;
    13441340  infoPtr->uTotalWidth = 0;
     
    13621358      item->rect.bottom = item->rect.top+height;
    13631359      item->rect.left   = x-infoPtr->cx;
    1364       item->rect.right  = rect.right;
     1360      item->rect.right  = rect.right; //dummy
    13651361      TREEVIEW_CalcItem(hwnd,hdc,dwStyle,infoPtr,item);
    13661362    } else
     
    15301526
    15311527    if (infoPtr->cdmode == CDRF_SKIPDEFAULT) return;
    1532 
    1533     /* draw background */
    1534 
    1535     hbrBk = CreateSolidBrush (infoPtr->clrBk);
    1536     FillRect(hdc, &rect, hbrBk);
    1537     DeleteObject(hbrBk);
    15381528
    15391529    //draw items
     
    24812471static LRESULT
    24822472TREEVIEW_GetToolTips (HWND hwnd)
    2483 
    2484 {
    2485  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    2486 
    2487  return infoPtr->hwndToolTip;
     2473{
     2474  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     2475
     2476  return infoPtr->hwndToolTip;
    24882477}
    24892478
     
    24912480static LRESULT
    24922481TREEVIEW_SetToolTips (HWND hwnd, WPARAM wParam)
    2493 
    2494 {
    2495  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    2496  HWND prevToolTip;
    2497 
    2498  prevToolTip=infoPtr->hwndToolTip;
    2499  infoPtr->hwndToolTip= (HWND) wParam;
    2500 
    2501  return prevToolTip;
     2482{
     2483  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     2484  HWND prevToolTip;
     2485
     2486  prevToolTip = infoPtr->hwndToolTip;
     2487  infoPtr->hwndToolTip = (HWND)wParam;
     2488
     2489  return prevToolTip;
    25022490}
    25032491
     
    26472635  {
    26482636    if (TREEVIEW_CalcItems(hwnd,0,infoPtr))
    2649       TREEVIEW_Refresh(hwnd);
    2650   }
    2651 
    2652   return 0;
    2653 }
    2654 
     2637      TREEVIEW_Refresh(hwnd); //because size redraw isn't set
     2638  }
     2639
     2640  return TRUE;
     2641}
    26552642
    26562643static LRESULT
     
    26582645{
    26592646  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     2647
     2648  if (infoPtr->hwndEdit) SetFocus(hwnd);
    26602649
    26612650  //CB: todo: check styles
     
    26662655}
    26672656
     2657static LRESULT
     2658TREEVIEW_SysColorChange(HWND hwnd,WPARAM wParam,LPARAM lParam)
     2659{
     2660  TREEVIEW_Refresh(hwnd);
     2661
     2662  return DefWindowProcA(hwnd,WM_SYSCOLORCHANGE,wParam,lParam);
     2663}
    26682664
    26692665static LRESULT
    26702666TREEVIEW_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
    26712667{
    2672     TREEVIEW_INFO *infoPtr;
    2673         DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    2674         LOGFONTA logFont;
    2675     TEXTMETRICA tm;
    2676         HDC hdc;
    2677 
    2678     //TRACE("wnd %x, style %lx\n",hwnd,dwStyle);
    2679       /* allocate memory for info structure */
    2680     infoPtr = (TREEVIEW_INFO *) COMCTL32_Alloc (sizeof(TREEVIEW_INFO));
    2681 
    2682     SetWindowLongA( hwnd, 0, (DWORD)infoPtr);
    2683 
    2684     if (infoPtr == NULL) {
    2685                 //ERR("could not allocate info memory!\n");
    2686                 return 0;
     2668  TREEVIEW_INFO *infoPtr;
     2669  DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     2670  LOGFONTA logFont;
     2671  TEXTMETRICA tm;
     2672  HDC hdc;
     2673
     2674  /* allocate memory for info structure */
     2675  infoPtr = (TREEVIEW_INFO *) COMCTL32_Alloc (sizeof(TREEVIEW_INFO));
     2676
     2677  SetWindowLongA( hwnd, 0, (DWORD)infoPtr);
     2678
     2679  if (infoPtr == NULL) return 0;
     2680
     2681  if ((TREEVIEW_INFO*)GetWindowLongA(hwnd,0) != infoPtr) return 0;
     2682
     2683  hdc = GetDC(hwnd);
     2684
     2685  /* set default settings */
     2686  infoPtr->uInternalStatus = 0;
     2687  if (IsWindowUnicode(hwnd)) infoPtr->uInternalStatus |= TV_UNICODE;
     2688  infoPtr->uNumItems=0;
     2689  infoPtr->clrBk   = GetSysColor (COLOR_WINDOW);
     2690  infoPtr->clrLine = GetSysColor (COLOR_WINDOWTEXT);
     2691  infoPtr->clrInsertMark = GetSysColor (COLOR_BTNTEXT);
     2692  infoPtr->cy = 0;
     2693  infoPtr->cx = 0;
     2694  infoPtr->uIndent = 15;
     2695  infoPtr->himlNormal = NULL;
     2696  infoPtr->himlState = NULL;
     2697  infoPtr->uItemHeight = -1;
     2698  GetTextMetricsA (hdc, &tm);
     2699  infoPtr->hFont = GetStockObject (DEFAULT_GUI_FONT);
     2700  GetObjectA (infoPtr->hFont, sizeof (LOGFONTA), &logFont);
     2701  logFont.lfWeight=FW_BOLD;
     2702  infoPtr->hBoldFont = CreateFontIndirectA (&logFont);
     2703
     2704  infoPtr->items = NULL;
     2705  infoPtr->selectedItem = 0;
     2706  infoPtr->clrText=-1;        /* use system color */
     2707  infoPtr->dropItem=0;
     2708  infoPtr->insertMarkItem=0;
     2709  infoPtr->insertBeforeorAfter=0;
     2710  infoPtr->pCallBackSort=NULL;
     2711  infoPtr->uScrollTime = 300;  /* milliseconds */
     2712  infoPtr->hwndEdit = 0;
     2713
     2714  infoPtr->hwndToolTip=0;
     2715  if (!(dwStyle & TVS_NOTOOLTIPS))
     2716  {
     2717    /* Create tooltip control */
     2718    TTTOOLINFOA ti;
     2719
     2720    infoPtr->hwndToolTip =
     2721      CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
     2722                       CW_USEDEFAULT, CW_USEDEFAULT,
     2723                       CW_USEDEFAULT, CW_USEDEFAULT,
     2724                       hwnd, 0, 0, 0);
     2725
     2726    /* Send NM_TOOLTIPSCREATED notification */
     2727    if (infoPtr->hwndToolTip)
     2728    {
     2729      NMTOOLTIPSCREATED nmttc;
     2730
     2731      nmttc.hdr.hwndFrom = hwnd;
     2732      nmttc.hdr.idFrom =  GetWindowLongA( hwnd, GWL_ID);
     2733      nmttc.hdr.code = NM_TOOLTIPSCREATED;
     2734      nmttc.hwndToolTips = infoPtr->hwndToolTip;
     2735
     2736      SendMessageA (GetParent(hwnd),WM_NOTIFY,(WPARAM)GetWindowLongA(hwnd,GWL_ID),(LPARAM)&nmttc);
    26872737    }
    26882738
    2689     if ((TREEVIEW_INFO*) GetWindowLongA( hwnd, 0) != infoPtr) {
    2690                 //ERR("pointer assignment error!\n");
    2691                 return 0;
    2692     }
    2693 
    2694         hdc=GetDC (hwnd);
    2695 
    2696     /* set default settings */
    2697     infoPtr->uInternalStatus = 0;
    2698     infoPtr->uNumItems=0;
    2699     infoPtr->clrBk   = GetSysColor (COLOR_WINDOW);
    2700     infoPtr->clrLine = GetSysColor (COLOR_WINDOWTEXT);
    2701     infoPtr->clrInsertMark = GetSysColor (COLOR_BTNTEXT);
    2702     infoPtr->cy = 0;
    2703     infoPtr->cx = 0;
    2704     infoPtr->uIndent = 15;
    2705     infoPtr->himlNormal = NULL;
    2706     infoPtr->himlState = NULL;
    2707     infoPtr->uItemHeight = -1;
    2708     GetTextMetricsA (hdc, &tm);
    2709     infoPtr->hFont = GetStockObject (DEFAULT_GUI_FONT);
    2710     GetObjectA (infoPtr->hFont, sizeof (LOGFONTA), &logFont);
    2711     logFont.lfWeight=FW_BOLD;
    2712     infoPtr->hBoldFont = CreateFontIndirectA (&logFont);
    2713 
    2714     infoPtr->items = NULL;
    2715     infoPtr->selectedItem = 0;
    2716     infoPtr->clrText=-1;        /* use system color */
    2717     infoPtr->dropItem=0;
    2718     infoPtr->insertMarkItem=0;
    2719     infoPtr->insertBeforeorAfter=0;
    2720     infoPtr->pCallBackSort=NULL;
    2721     infoPtr->uScrollTime = 300;  /* milliseconds */
    2722     infoPtr->hwndEdit = 0;
    2723 
    2724 /*
    2725     infoPtr->hwndNotify = GetParent32 (hwnd);
    2726     infoPtr->bTransparent = ( GetWindowLongA( hwnd, GWL_STYLE) & TBSTYLE_FLAT);
    2727 */
    2728 
    2729     infoPtr->hwndToolTip=0;
    2730     if (!(dwStyle & TVS_NOTOOLTIPS)) {   /* Create tooltip control */
    2731                 TTTOOLINFOA ti;
    2732 
    2733                 infoPtr->hwndToolTip =
    2734                         CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
    2735                    CW_USEDEFAULT, CW_USEDEFAULT,
    2736                    CW_USEDEFAULT, CW_USEDEFAULT,
    2737                    hwnd, 0, 0, 0);
    2738 
    2739         /* Send NM_TOOLTIPSCREATED notification */
    2740         if (infoPtr->hwndToolTip) {
    2741             NMTOOLTIPSCREATED nmttc;
    2742 
    2743             nmttc.hdr.hwndFrom = hwnd;
    2744             nmttc.hdr.idFrom =  GetWindowLongA( hwnd, GWL_ID);
    2745             nmttc.hdr.code = NM_TOOLTIPSCREATED;
    2746             nmttc.hwndToolTips = infoPtr->hwndToolTip;
    2747 
    2748             SendMessageA (GetParent (hwnd), WM_NOTIFY,
    2749                 (WPARAM) GetWindowLongA( hwnd, GWL_ID), (LPARAM)&nmttc);
    2750         }
    2751 
    2752                 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    2753         ti.cbSize   = sizeof(TTTOOLINFOA);
    2754         ti.uFlags   = TTF_IDISHWND | TTF_TRACK | TTF_TRANSPARENT ;
    2755         ti.hwnd     = hwnd;
    2756         ti.uId      = 0;
    2757         ti.lpszText = "Test"; /* LPSTR_TEXTCALLBACK; */
    2758         SetRectEmpty (&ti.rect);
    2759 
    2760         SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA, 0, (LPARAM)&ti);
    2761     }
    2762 
    2763   if (dwStyle & TVS_CHECKBOXES) {
    2764                 HBITMAP hbmLoad;
    2765                 int nIndex;
    2766 
    2767                 infoPtr->himlState =
    2768              ImageList_Create (16, 16,ILC_COLOR|ILC_MASK, 15, 1);
    2769 
    2770                 hbmLoad = LoadBitmapA (COMCTL32_hModule, MAKEINTRESOURCEA(IDT_CHECK));
    2771                 //TRACE ("%x\n",hbmLoad);
    2772         nIndex = ImageList_AddMasked (infoPtr->himlState, hbmLoad, CLR_DEFAULT);
    2773                 //TRACE ("%d\n",nIndex);
    2774                 DeleteObject (hbmLoad);
    2775         }
     2739    ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     2740    ti.cbSize   = sizeof(TTTOOLINFOA);
     2741    ti.uFlags   = TTF_IDISHWND | TTF_TRACK | TTF_TRANSPARENT;
     2742    ti.hwnd     = hwnd;
     2743    ti.uId      = 0;
     2744    ti.lpszText = "Test"; /* LPSTR_TEXTCALLBACK; */
     2745    SetRectEmpty (&ti.rect);
     2746
     2747    SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA, 0, (LPARAM)&ti);
     2748  }
     2749
     2750  if (dwStyle & TVS_CHECKBOXES)
     2751  {
     2752    HBITMAP hbmLoad;
     2753    int nIndex;
     2754
     2755    infoPtr->himlState = ImageList_Create (16, 16,ILC_COLOR | ILC_MASK, 15, 1);
     2756
     2757    //CB: MSDN docu says: uses DrawFrameControl
     2758    hbmLoad = LoadBitmapA (COMCTL32_hModule, MAKEINTRESOURCEA(IDT_CHECK));
     2759    nIndex = ImageList_AddMasked (infoPtr->himlState, hbmLoad, CLR_DEFAULT);
     2760    DeleteObject (hbmLoad);
     2761  }
    27762762  ReleaseDC (hwnd, hdc);
     2763
    27772764  return 0;
    27782765}
    2779 
    2780 
    27812766
    27822767static LRESULT
     
    28462831}
    28472832
     2833static LRESULT TREEVIEW_Enable(HWND hwnd,WPARAM wParam,LPARAM lParam)
     2834{
     2835  TREEVIEW_Refresh(hwnd);
     2836
     2837  return DefWindowProcA(hwnd,WM_ENABLE,wParam,lParam);
     2838}
     2839
    28482840static LRESULT
    28492841TREEVIEW_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
     
    28532845    RECT rect;
    28542846
    2855 //    TRACE (treeview,"\n");
    28562847    GetClientRect (hwnd, &rect);
    28572848    FillRect ((HDC)wParam, &rect, hBrush);
    28582849    DeleteObject (hBrush);
     2850
    28592851    return TRUE;
     2852}
     2853
     2854static LRESULT TREEVIEW_GetDlgCode(HWND hwnd,WPARAM wParam,LPARAM lParam)
     2855{
     2856  return DLGC_WANTARROWS | DLGC_WANTCHARS;
    28602857}
    28612858
     
    31753172  expand = (INT)lParam;
    31763173
    3177   wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)expand);
     3174  wineItem = TREEVIEW_ValidItem (infoPtr,(HTREEITEM)expand);
    31783175
    31793176  if (!wineItem)
     
    32633260      }
    32643261      break;
     3262
    32653263    default:
    32663264      return FALSE;
     
    33193317  }
    33203318
    3321   lpht->flags=0;
     3319  lpht->flags = 0;
    33223320
    33233321  if (x < wineItem->expandBox.left) {
     
    33423340  }
    33433341
    3344   lpht->flags|=TVHT_ONITEMRIGHT;
    3345 
     3342  lpht->flags |= TVHT_ONITEMRIGHT;
    33463343
    33473344done:
    33483345  lpht->hItem = wineItem->hItem;
    3349   //TRACE ("(%ld,%ld):result %x\n",lpht->pt.x,lpht->pt.y,lpht->flags);
    33503346
    33513347  return (LRESULT) wineItem->hItem;
     
    33623358  TEXTMETRICA textMetric;
    33633359
    3364   //TRACE("%d %d\n",(INT)hwnd, (INT)hItem);
    33653360  if (!editItem)
    33663361    return FALSE;
     
    33693364    return infoPtr->hwndEdit;
    33703365
    3371         /* Make shure that edit item is selected */
     3366  /* Make shure that edit item is selected */
    33723367
    33733368  TREEVIEW_DoSelectItem ( hwnd, TVGN_CARET, hItem, TVC_UNKNOWN);
    33743369
    33753370  if (editItem->pszText == LPSTR_TEXTCALLBACKW)
    3376                 TREEVIEW_SendDispInfoNotify (hwnd, editItem, TVN_GETDISPINFO, TVIF_TEXT);
     3371    TREEVIEW_SendDispInfoNotify (hwnd, editItem, TVN_GETDISPINFO, TVIF_TEXT);
    33773372
    33783373  hdc = GetDC(hwnd);
    3379     /* Select the font to get appropriate metric dimensions */
     3374  /* Select the font to get appropriate metric dimensions */
    33803375  if(infoPtr->hFont != 0)
    33813376  {
     
    35993594  wineItem = &infoPtr->items [(INT)hitinfo.hItem];
    36003595
    3601   if (TREEVIEW_SendSimpleNotify (hwnd, NM_DBLCLK)!=TRUE) {     /* FIXME!*/
    3602         TREEVIEW_Expand (hwnd, (WPARAM) TVE_TOGGLE, (LPARAM) wineItem->hItem);
    3603  }
     3596  //MSDN documentation says: stop on non zero. but this isn't true in this case
     3597  if (!TREEVIEW_SendSimpleNotify (hwnd, NM_DBLCLK))
     3598    TREEVIEW_Expand (hwnd, (WPARAM) TVE_TOGGLE, (LPARAM) wineItem->hItem);
     3599
    36043600 return TRUE;
     3601}
     3602
     3603static LRESULT TREEVIEW_MouseMove(HWND hwnd,WPARAM wParam,LPARAM lParam)
     3604{
     3605  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     3606  TVHITTESTINFO ht;
     3607  TREEVIEW_ITEM *item;
     3608
     3609  ht.pt.x = (INT)LOWORD(lParam);
     3610  ht.pt.y = (INT)HIWORD(lParam);
     3611
     3612  if (!TREEVIEW_HitTest(hwnd,&ht)) return 0;
     3613
     3614  if (ht.hItem)
     3615  {
     3616    item = &infoPtr->items[(INT)ht.hItem];
     3617  }
     3618
     3619  return 0;
    36053620}
    36063621
     
    36123627  BOOL bTrack;
    36133628  DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    3614 
    36153629
    36163630  /* If Edit control is active - kill it and return.
     
    36293643
    36303644  TREEVIEW_HitTest (hwnd,&ht);
    3631   //TRACE("item %d \n", (INT)ht.hItem);
    36323645
    36333646  bTrack = (ht.flags & TVHT_ONITEM) && !(dwStyle & TVS_DISABLEDRAGDROP);
     
    36553668  if(TREEVIEW_SendSimpleNotify (hwnd, NM_CLICK))
    36563669     goto setfocus;
     3670
     3671//CB: todo: check ht.flags for WM_HSCROLL!
    36573672
    36583673  /*
     
    36793694     if (dwStyle & TVS_CHECKBOXES)  /* TVS_CHECKBOXES requires _us_ */
    36803695     {                              /* to toggle the current state  */
    3681         int state;
    3682         TREEVIEW_ITEM *wineItem;
    3683 
    3684         wineItem = TREEVIEW_ValidItem(infoPtr, ht.hItem);
    3685 
    3686                         state=1-(wineItem->state>>12);
    3687                         //TRACE ("state:%x\n", state);
    3688                         wineItem->state&= ~TVIS_STATEIMAGEMASK;
    3689                         wineItem->state|=state<<12;
    3690                         //TRACE ("state:%x\n", wineItem->state);
    3691                         //CB: todo: optimize
    3692                         TREEVIEW_QueueRefresh (hwnd);
    3693           }
     3696       int state;
     3697       TREEVIEW_ITEM *wineItem;
     3698
     3699       wineItem = TREEVIEW_ValidItem(infoPtr, ht.hItem);
     3700
     3701       state = 1-(wineItem->state>>12);
     3702       wineItem->state &= ~TVIS_STATEIMAGEMASK;
     3703       wineItem->state |= state<<12;
     3704       if (wineItem->visible)
     3705       {
     3706         TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE);
     3707         InvalidateRect(hwnd,&wineItem->statebitmap,TRUE);
     3708       }
     3709     }
    36943710  }
    36953711
     
    37323748
    37333749        return 0;
     3750}
     3751
     3752static LRESULT TREEVIEW_RButtonDoubleClick(HWND hwnd,WPARAM wParam,LPARAM lParam)
     3753{
     3754  TREEVIEW_SendSimpleNotify(hwnd,NM_RDBLCLK);
     3755
     3756  return DefWindowProcA(hwnd,WM_RBUTTONDBLCLK,wParam,lParam);
    37343757}
    37353758
     
    38173840    while (parent && !(parent->state & TVIS_EXPANDED))
    38183841    {
    3819       TREEVIEW_Expand(hwnd,TVE_EXPAND,(LPARAM)parent);
     3842      TREEVIEW_Expand(hwnd,TVE_EXPAND,(LPARAM)parent->hItem);
    38203843      parent = TREEVIEW_ValidItem(infoPtr,parent->parent);
    38213844    }
     
    38963919          TREEVIEW_CalcItems(hwnd,0,infoPtr);
    38973920
    3898         ScrollWindowEx(hwnd,0,-scrollY,NULL,NULL,0,NULL,SW_INVALIDATE);
     3921        ScrollWindowEx(hwnd,0,-scrollY,NULL,NULL,0,NULL,SW_INVALIDATE | SW_SCROLLCHILDREN | (infoPtr->uScrollTime << 16));
    38993922      }
    39003923
     
    39683991  int lastPos = infoPtr->cy;
    39693992
    3970   if (!infoPtr->uInternalStatus & TV_VSCROLL) return FALSE;
    3971 
    3972   if(infoPtr->hwndEdit)
    3973     SetFocus(hwnd);
    3974 
    3975   switch (LOWORD (wParam)) {
    3976         case SB_LINEUP:
    3977                         if (!infoPtr->cy) return FALSE;
    3978                         infoPtr->cy -= infoPtr->uRealItemHeight;
    3979                         if (infoPtr->cy < 0) infoPtr->cy=0;
    3980                         break;
    3981         case SB_LINEDOWN:
    3982                         maxHeight=infoPtr->uTotalHeight-infoPtr->uVisibleHeight;
    3983                         if (infoPtr->cy == maxHeight) return FALSE;
    3984                         infoPtr->cy += infoPtr->uRealItemHeight;
    3985                         if (infoPtr->cy > maxHeight)
    3986                           infoPtr->cy = maxHeight;
    3987                         break;
    3988         case SB_PAGEUP:
    3989                         if (!infoPtr->cy) return FALSE;
    3990                         infoPtr->cy -= infoPtr->uVisibleHeight;
    3991                         if (infoPtr->cy < 0) infoPtr->cy=0;
    3992                         break;
    3993         case SB_PAGEDOWN:
    3994                         maxHeight=infoPtr->uTotalHeight-infoPtr->uVisibleHeight;
    3995                         if (infoPtr->cy == maxHeight) return FALSE;
    3996                         infoPtr->cy += infoPtr->uVisibleHeight;
    3997                         if (infoPtr->cy > maxHeight)
    3998                           infoPtr->cy = maxHeight;
    3999                         break;
    4000         case SB_THUMBTRACK:
    4001                         infoPtr->cy = HIWORD (wParam);
    4002                         break;
    4003 
     3993  if (!(infoPtr->uInternalStatus & TV_VSCROLL)) return FALSE;
     3994
     3995  switch (LOWORD (wParam))
     3996  {
     3997    case SB_LINEUP:
     3998      if (!infoPtr->cy) return FALSE;
     3999      infoPtr->cy -= infoPtr->uRealItemHeight;
     4000      if (infoPtr->cy < 0) infoPtr->cy = 0;
     4001      break;
     4002
     4003    case SB_LINEDOWN:
     4004      maxHeight = infoPtr->uTotalHeight-infoPtr->uVisibleHeight;
     4005      if (maxHeight <= 0) return FALSE;
     4006      if (infoPtr->cy == maxHeight) return FALSE;
     4007      infoPtr->cy += infoPtr->uRealItemHeight;
     4008      if (infoPtr->cy > maxHeight)
     4009        infoPtr->cy = maxHeight;
     4010      break;
     4011
     4012    case SB_PAGEUP:
     4013      if (!infoPtr->cy) return FALSE;
     4014      infoPtr->cy -= infoPtr->uVisibleHeight;
     4015      if (infoPtr->cy < 0) infoPtr->cy = 0;
     4016      break;
     4017
     4018    case SB_PAGEDOWN:
     4019      maxHeight = infoPtr->uTotalHeight-infoPtr->uVisibleHeight;
     4020      if (maxHeight <= 0) return FALSE;
     4021      if (infoPtr->cy == maxHeight) return FALSE;
     4022      infoPtr->cy += infoPtr->uVisibleHeight;
     4023      if (infoPtr->cy > maxHeight)
     4024        infoPtr->cy = maxHeight;
     4025      break;
     4026
     4027    case SB_THUMBTRACK:
     4028      maxHeight = infoPtr->uTotalHeight-infoPtr->uVisibleHeight;
     4029      if (maxHeight <= 0) return FALSE;
     4030      infoPtr->cy = HIWORD(wParam);
     4031      if (infoPtr->cy < 0) infoPtr->cy = 0;
     4032      if (infoPtr->cy > maxHeight) infoPtr->cy = maxHeight;
     4033      break;
     4034
     4035    default:
     4036      return FALSE;
    40044037  }
    40054038
     
    40084041    if (!TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE))
    40094042      TREEVIEW_CalcItems(hwnd,0,infoPtr);
    4010     ScrollWindowEx(hwnd,0,lastPos-infoPtr->cy,NULL,NULL,0,NULL,SW_INVALIDATE);
    4011   }
    4012 
    4013   return TRUE;
     4043    ScrollWindowEx(hwnd,0,lastPos-infoPtr->cy,NULL,NULL,0,NULL,SW_INVALIDATE | SW_SCROLLCHILDREN | (infoPtr->uScrollTime << 16));
     4044
     4045    return TRUE;
     4046  }
     4047
     4048  return FALSE;
    40144049}
    40154050
     
    40214056  int lastPos = infoPtr->cx;
    40224057
    4023   //TRACE (treeview,"wp %lx, lp %x\n", lParam, wParam);
    4024 
    4025   if (!infoPtr->uInternalStatus & TV_HSCROLL) return FALSE;
    4026 
    4027   if(infoPtr->hwndEdit)
    4028     SetFocus(hwnd);
    4029 
    4030   switch (LOWORD (wParam)) {
    4031         case SB_LINEUP:
    4032                         if (!infoPtr->cx) return FALSE;
    4033                         infoPtr->cx -= infoPtr->uRealItemHeight;
    4034                         if (infoPtr->cx < 0) infoPtr->cx=0;
    4035                         break;
    4036         case SB_LINEDOWN:
    4037                         maxWidth=infoPtr->uTotalWidth-infoPtr->uVisibleWidth;
    4038                         if (infoPtr->cx == maxWidth) return FALSE;
    4039                         infoPtr->cx += infoPtr->uRealItemHeight; /*FIXME */
    4040                         if (infoPtr->cx > maxWidth)
    4041                                 infoPtr->cx = maxWidth;
    4042                         break;
    4043         case SB_PAGEUP:
    4044                         if (!infoPtr->cx) return FALSE;
    4045                         infoPtr->cx -= infoPtr->uVisibleWidth;
    4046                         if (infoPtr->cx < 0) infoPtr->cx=0;
    4047                         break;
    4048         case SB_PAGEDOWN:
    4049                         maxWidth=infoPtr->uTotalWidth-infoPtr->uVisibleWidth;
    4050                         if (infoPtr->cx == maxWidth) return FALSE;
    4051                         infoPtr->cx += infoPtr->uVisibleWidth;
    4052             if (infoPtr->cx > maxWidth)
    4053                 infoPtr->cx = maxWidth;
    4054                         break;
    4055         case SB_THUMBTRACK:
    4056                         infoPtr->cx = HIWORD (wParam);
    4057                         break;
    4058 
     4058  if (!(infoPtr->uInternalStatus & TV_HSCROLL)) return FALSE;
     4059
     4060  switch (LOWORD (wParam))
     4061  {
     4062    case SB_LINEUP:
     4063      if (!infoPtr->cx) return FALSE;
     4064      infoPtr->cx -= infoPtr->uRealItemHeight;
     4065      if (infoPtr->cx < 0) infoPtr->cx = 0;
     4066      break;
     4067
     4068    case SB_LINEDOWN:
     4069      maxWidth = infoPtr->uTotalWidth-infoPtr->uVisibleWidth;
     4070      if (maxWidth <= 0) return FALSE;
     4071      if (infoPtr->cx == maxWidth) return FALSE;
     4072      infoPtr->cx += infoPtr->uRealItemHeight; /*FIXME */
     4073      if (infoPtr->cx > maxWidth)
     4074        infoPtr->cx = maxWidth;
     4075      break;
     4076
     4077    case SB_PAGEUP:
     4078      if (!infoPtr->cx) return FALSE;
     4079      infoPtr->cx -= infoPtr->uVisibleWidth;
     4080      if (infoPtr->cx < 0) infoPtr->cx = 0;
     4081      break;
     4082
     4083    case SB_PAGEDOWN:
     4084      maxWidth = infoPtr->uTotalWidth-infoPtr->uVisibleWidth;
     4085      if (maxWidth <= 0) return FALSE;
     4086      if (infoPtr->cx == maxWidth) return FALSE;
     4087      infoPtr->cx += infoPtr->uVisibleWidth;
     4088      if (infoPtr->cx > maxWidth)
     4089        infoPtr->cx = maxWidth;
     4090      break;
     4091
     4092    case SB_THUMBTRACK:
     4093      maxWidth = infoPtr->uTotalWidth-infoPtr->uVisibleWidth;
     4094      if (maxWidth <= 0) return FALSE;
     4095      infoPtr->cx = HIWORD(wParam);
     4096      if (infoPtr->cx < 0) infoPtr->cx = 0;
     4097      if (infoPtr->cx > maxWidth) infoPtr->cx = maxWidth;
     4098      break;
     4099
     4100    default:
     4101      return FALSE;
    40594102  }
    40604103
     
    40634106    if (!TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE))
    40644107      TREEVIEW_CalcItems(hwnd,0,infoPtr);
    4065     ScrollWindowEx(hwnd,lastPos-infoPtr->cx,0,NULL,NULL,0,NULL,SW_INVALIDATE);
    4066   }
    4067 
    4068   return TRUE;
     4108    ScrollWindowEx(hwnd,lastPos-infoPtr->cx,0,NULL,NULL,0,NULL,SW_INVALIDATE | SW_SCROLLCHILDREN | (infoPtr->uScrollTime << 16));
     4109
     4110    return TRUE;
     4111  }
     4112
     4113  return FALSE;
    40694114}
    40704115
     
    41124157      NULL;
    41134158  TREEVIEW_ITEM *newItem        = NULL;
     4159  BOOL control;
    41144160
    41154161  TREEVIEW_SendKeyDownNotify(hwnd,TVN_KEYDOWN,wParam);
     4162
     4163  control = GetKeyState(VK_CONTROL) & 0x8000;
     4164
     4165  if (control)
     4166  {
     4167    DWORD scrollMsg = 0;
     4168    BOOL horz = FALSE;
     4169
     4170    switch (wParam)
     4171    {
     4172      case VK_UP:
     4173//CB: todo: VK_UP doesn't work
     4174        scrollMsg = SB_LINELEFT;
     4175        break;
     4176
     4177      case VK_DOWN:
     4178        scrollMsg = SB_LINERIGHT;
     4179        break;
     4180
     4181      case VK_LEFT:
     4182        scrollMsg = SB_LINELEFT;
     4183        horz = TRUE;
     4184        break;
     4185
     4186      case VK_RIGHT:
     4187        scrollMsg = SB_LINERIGHT;
     4188        horz = TRUE;
     4189        break;
     4190
     4191      case VK_PRIOR:
     4192        scrollMsg = SB_PAGELEFT;
     4193        break;
     4194
     4195      case VK_NEXT:
     4196        scrollMsg = SB_PAGERIGHT;
     4197        break;
     4198    }
     4199    if (scrollMsg)
     4200    {
     4201      SendMessageA(hwnd,horz ? WM_HSCROLL:WM_VSCROLL,MAKELONG(scrollMsg,0),0);
     4202      return TRUE;
     4203    }
     4204  }
    41164205
    41174206  if (prevSelect == 0)
     
    41664255
    41674256      break;
     4257
    41684258    case VK_RIGHT:
    41694259      if (TREEVIEW_HasChildren(hwnd, prevItem))
     
    42174307      break;
    42184308
     4309    case VK_RETURN:
     4310      TREEVIEW_SendSimpleNotify(hwnd,NM_RETURN);
     4311      break;
     4312
    42194313    case VK_BACK:
    4220     case VK_RETURN:
    42214314
    42224315    default:
     
    42434336{
    42444337  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     4338
    42454339  return infoPtr->uScrollTime;
    42464340}
     
    42744368    while (parent && !(parent->state & TVIS_EXPANDED))
    42754369    {
    4276       TREEVIEW_Expand(hwnd,TVE_EXPAND,(LPARAM)parent);
     4370      TREEVIEW_Expand(hwnd,TVE_EXPAND,(LPARAM)parent->hItem);
    42774371      parent = TREEVIEW_ValidItem(infoPtr,parent->parent);
    42784372    }
     
    42914385    infoPtr->cy += scrollY;
    42924386    TREEVIEW_CalcItems(hwnd,0,infoPtr);
    4293     ScrollWindowEx(hwnd,0,-scrollY,NULL,NULL,0,NULL,SW_INVALIDATE);
     4387    ScrollWindowEx(hwnd,0,-scrollY,NULL,NULL,0,NULL,SW_INVALIDATE | SW_SCROLLCHILDREN | (infoPtr->uScrollTime << 16));
    42944388
    42954389    return TRUE;
     
    43014395static LRESULT TREEVIEW_GetISearchString(HWND hwnd,LPSTR lpsz,BOOL unicode)
    43024396{
    4303   //CB: todo
     4397  //CB: todo: MSDN documentation is useless
    43044398
    43054399  return 0;
     4400}
     4401
     4402static LRESULT TREEVIEW_SetCursor(HWND hwnd,WPARAM wParam,LPARAM lParam)
     4403{
     4404  TREEVIEW_SendSimpleNotify(hwnd,NM_SETCURSOR); //CB: todo: result
     4405
     4406  return DefWindowProcA(hwnd,WM_SETCURSOR,wParam,lParam);
     4407}
     4408
     4409static LRESULT TREEVIEW_GetUnicodeFormat(HWND hwnd,WPARAM wParam,LPARAM lParam)
     4410{
     4411  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     4412
     4413  return infoPtr->uInternalStatus & TV_UNICODE;
     4414}
     4415
     4416static LRESULT TREEVIEW_SetUnicodeFormat(HWND hwnd,WPARAM wParam,LPARAM lParam)
     4417{
     4418  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     4419  BOOL oldFormat = infoPtr->uInternalStatus & TV_UNICODE;
     4420
     4421  if (wParam)
     4422    infoPtr->uInternalStatus |= TV_UNICODE;
     4423  else
     4424    infoPtr->uInternalStatus &= ~TV_UNICODE;
     4425
     4426  return oldFormat;
    43064427}
    43074428
     
    44504571
    44514572        case TVM_GETUNICODEFORMAT:
    4452 //                      FIXME (treeview, "Unimplemented msg TVM_GETUNICODEFORMAT\n");
    4453                 return 0;
     4573                return TREEVIEW_GetUnicodeFormat(hwnd,wParam,lParam);
     4574
     4575        case TVM_SETUNICODEFORMAT:
     4576                return TREEVIEW_SetUnicodeFormat(hwnd,wParam,lParam);
    44544577
    44554578        case WM_COMMAND:
     
    44594582                return TREEVIEW_Destroy (hwnd);
    44604583
    4461 /*      case WM_ENABLE: */
     4584        case WM_ENABLE:
     4585                return TREEVIEW_Enable(hwnd,wParam,lParam);
    44624586
    44634587        case WM_ERASEBKGND:
     
    44654589
    44664590        case WM_GETDLGCODE:
    4467                 return DLGC_WANTARROWS | DLGC_WANTCHARS;
     4591                return TREEVIEW_GetDlgCode(hwnd,wParam,lParam);
    44684592
    44694593        case WM_PAINT:
     
    44854609                return TREEVIEW_KillFocus (hwnd, wParam, lParam);
    44864610
     4611        case WM_MOUSEMOVE:
     4612                return TREEVIEW_MouseMove(hwnd,wParam,lParam);
     4613
    44874614        case WM_LBUTTONDOWN:
    44884615                return TREEVIEW_LButtonDown (hwnd, wParam, lParam);
     
    44944621                return TREEVIEW_RButtonDown (hwnd, wParam, lParam);
    44954622
     4623        case WM_RBUTTONDBLCLK:
     4624                return TREEVIEW_RButtonDoubleClick(hwnd,wParam,lParam);
     4625
    44964626        case WM_STYLECHANGED:
    44974627                return TREEVIEW_StyleChanged (hwnd, wParam, lParam);
    44984628
    4499 /*      case WM_SYSCOLORCHANGE: */
     4629        case WM_SYSCOLORCHANGE:
     4630                return TREEVIEW_SysColorChange(hwnd,wParam,lParam);
     4631
     4632        case WM_SETCURSOR:
     4633                return TREEVIEW_SetCursor(hwnd,wParam,lParam);
    45004634
    45014635        case WM_SETREDRAW:
Note: See TracChangeset for help on using the changeset viewer.