Ignore:
Timestamp:
Jun 16, 1999, 10:25:45 PM (26 years ago)
Author:
cbratschi
Message:

comctl32 wine conversion bugs fixed
trackbar: TRACKBAR_Draw prototype

File:
1 edited

Legend:

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

    r94 r110  
    1 /* $Id: treeview.c,v 1.3 1999-06-10 16:22:03 achimha Exp $ */
     1/* $Id: treeview.c,v 1.4 1999-06-16 20:25:44 cbratschi Exp $ */
    22/* Treeview control
    33 *
     
    66 * Copyright 1999 Sylvain St-Germain
    77 * Copyright 1999 Achim Hasenmueller
     8 * Copyright 1999 Christoph Bratschi
    89 *
    910 *
    1011 * TODO:
    1112 *   Using DPA to store the item ptr would be good.
    12  *   Node label edition is implemented but something appened in wine in the 
     13 *   Node label edition is implemented but something appened in wine in the
    1314 *   two last weeks of march 99 that broke it.
    14  *   refreshtreeview:   
    15                 -small array containing info about positions.
    16                 -better implementation of RefreshItem:
     15 *   refreshtreeview:
     16                -small array containing info about positions.
     17                -better implementation of RefreshItem:
    1718              1) draw lines between parents
    1819              2) draw items
    19                           3) draw lines from parent<->items.
    20                 -implement partial drawing?
     20                          3) draw lines from parent<->items.
     21                -implement partial drawing?
    2122 *  -drag&drop: TVM_CREATEDRAGIMAGE should create drag bitmap.
    2223 *  -scrollbars: horizontal scrollbar doesn't work.
     
    2627 *   FIXME: check fontsize. (uRealItemHeight)
    2728 *          test focusItem  (redraw in different color)
    28                         uHotItem
    29                         Edit: needs timer
    30                                   better implementation.
     29                        uHotItem
     30                        Edit: needs timer
     31                                  better implementation.
    3132 *   WM_HSCROLL is broken.
    3233 *   use separate routine to get item text/image.
    33  * 
     34 *
    3435 *   Separate drawing/calculation.
    3536 *
    3637 * FIXMEs  (for personal use)
    37     Expand:             -ctlmacro expands twice ->toggle.
    38    -DblClick:   ctlmacro.exe's NM_DBLCLK seems to go wrong (returns FALSE).
    39    -treehelper: stack corruption makes big window. 
    40              
     38    Expand:             -ctlmacro expands twice ->toggle.
     39   -DblClick:   ctlmacro.exe's NM_DBLCLK seems to go wrong (returns FALSE).
     40   -treehelper: stack corruption makes big window.
     41
    4142 */
    4243
     
    5455 * has no side effects in this file.
    5556 */
    56 #define tv_test_bit(nr,bf)      (((LPBYTE)bf)[nr>>3]&(1<<(nr&7)))
    57 #define tv_set_bit(nr,bf)       ((LPBYTE)bf)[nr>>3]|=(1<<(nr&7))
    58 #define tv_clear_bit(nr,bf)     ((LPBYTE)bf)[nr>>3]&=~(1<<(nr&7))
     57#define tv_test_bit(nr,bf)      (((LPBYTE)bf)[nr>>3]&(1<<(nr&7)))
     58#define tv_set_bit(nr,bf)       ((LPBYTE)bf)[nr>>3]|=(1<<(nr&7))
     59#define tv_clear_bit(nr,bf)     ((LPBYTE)bf)[nr>>3]&=~(1<<(nr&7))
    5960
    6061
     
    6566TREEVIEW_SendSimpleNotify (HWND hwnd, UINT code);
    6667static BOOL
    67 TREEVIEW_SendTreeviewNotify (HWND hwnd, UINT code, UINT action, 
    68                         HTREEITEM oldItem, HTREEITEM newItem);
     68TREEVIEW_SendTreeviewNotify (HWND hwnd, UINT code, UINT action,
     69                        HTREEITEM oldItem, HTREEITEM newItem);
    6970static BOOL
    70 TREEVIEW_SendTreeviewDnDNotify (HWND hwnd, UINT code, HTREEITEM dragItem, 
    71                         POINT pt);
     71TREEVIEW_SendTreeviewDnDNotify (HWND hwnd, UINT code, HTREEITEM dragItem,
     72                        POINT pt);
    7273static BOOL
    73 TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem, 
    74                         UINT code, UINT what);
     74TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem,
     75                        UINT code, UINT what);
    7576static BOOL
    7677TREEVIEW_SendCustomDrawNotify (HWND hwnd, DWORD dwDrawStage, HDC hdc,
    77                         RECT rc);
     78                        RECT rc);
    7879static BOOL
    7980TREEVIEW_SendCustomDrawItemNotify (HWND hwnd, HDC hdc,
     
    8586
    8687static LRESULT CALLBACK
    87 TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, 
    88                                                         LPARAM lParam);
     88TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam,
     89                                                        LPARAM lParam);
    8990
    9091LRESULT WINAPI
     
    9495
    9596
    96 /* helper functions. Work with the assumption that validity of operands 
     97/* helper functions. Work with the assumption that validity of operands
    9798   is checked beforehand, and that tree state is valid.  */
    9899
    99 /* FIXME: MS documentation says `GetNextVisibleItem' returns NULL 
     100/* FIXME: MS documentation says `GetNextVisibleItem' returns NULL
    100101   if not succesfull'. Probably only applies to derefencing infoPtr
    101102   (ie we are offered a valid treeview structure)
    102    and not whether there is a next `visible' child. 
     103   and not whether there is a next `visible' child.
    103104   FIXME: check other failures.
    104105 */
     
    111112  HTREEITEM  handle)
    112113{
    113   if ((!handle) || (handle>infoPtr->uMaxHandle)) 
     114  if ((!handle) || (handle>infoPtr->uMaxHandle))
    114115    return NULL;
    115116
    116   if (tv_test_bit ((INT)handle, infoPtr->freeList)) 
     117  if (tv_test_bit ((INT)handle, infoPtr->freeList))
    117118    return NULL;
    118119
     
    130131  TREEVIEW_ITEM *wineItem = tvItem;
    131132
    132   /* 
    133    * Get this item last sibling 
     133  /*
     134   * Get this item last sibling
    134135   */
    135   while (wineItem->sibling) 
    136           wineItem=& infoPtr->items [(INT)wineItem->sibling];
    137 
    138   /* 
     136  while (wineItem->sibling)
     137          wineItem=& infoPtr->items [(INT)wineItem->sibling];
     138
     139  /*
    139140   * If the last sibling has expanded children, restart.
    140141   */
    141142  if ( ( wineItem->cChildren > 0 ) && ( wineItem->state & TVIS_EXPANDED) )
    142143    return TREEVIEW_GetLastListItem(
    143              infoPtr, 
     144             infoPtr,
    144145             &(infoPtr->items[(INT)wineItem->firstChild]));
    145146
     
    148149
    149150/***************************************************************************
    150  * This method returns the previous physical item in the list not 
     151 * This method returns the previous physical item in the list not
    151152 * considering the tree hierarchy.
    152153 */
    153154static TREEVIEW_ITEM *TREEVIEW_GetPrevListItem(
    154   TREEVIEW_INFO *infoPtr, 
     155  TREEVIEW_INFO *infoPtr,
    155156  TREEVIEW_ITEM *tvItem)
    156157{
    157   if (tvItem->upsibling) 
     158  if (tvItem->upsibling)
    158159  {
    159     /* 
     160    /*
    160161     * This item has a upsibling, get the last item.  Since, GetLastListItem
    161162     * first looks at siblings, we must feed it with the first child.
    162163     */
    163164    TREEVIEW_ITEM *upItem = &infoPtr->items[(INT)tvItem->upsibling];
    164    
     165
    165166    if ( ( upItem->cChildren > 0 ) && ( upItem->state & TVIS_EXPANDED) )
    166       return TREEVIEW_GetLastListItem( 
    167                infoPtr, 
     167      return TREEVIEW_GetLastListItem(
     168               infoPtr,
    168169               &infoPtr->items[(INT)upItem->firstChild]);
    169170    else
     
    175176     * this item does not have a upsibling, get the parent
    176177     */
    177     if (tvItem->parent) 
     178    if (tvItem->parent)
    178179      return &infoPtr->items[(INT)tvItem->parent];
    179180  }
     
    184185
    185186/***************************************************************************
    186  * This method returns the next physical item in the treeview not 
     187 * This method returns the next physical item in the treeview not
    187188 * considering the tree hierarchy.
    188189 */
    189190static TREEVIEW_ITEM *TREEVIEW_GetNextListItem(
    190   TREEVIEW_INFO *infoPtr, 
     191  TREEVIEW_INFO *infoPtr,
    191192  TREEVIEW_ITEM *tvItem)
    192193{
    193194  TREEVIEW_ITEM *wineItem = NULL;
    194195
    195   /* 
     196  /*
    196197   * If this item has children and is expanded, return the first child
    197198   */
    198   if ((tvItem->firstChild) && (tvItem->state & TVIS_EXPANDED)) 
    199                 return (& infoPtr->items[(INT)tvItem->firstChild]);
     199  if ((tvItem->firstChild) && (tvItem->state & TVIS_EXPANDED))
     200                return (& infoPtr->items[(INT)tvItem->firstChild]);
    200201
    201202
     
    203204   * try to get the sibling
    204205   */
    205   if (tvItem->sibling) 
    206                 return (& infoPtr->items[(INT)tvItem->sibling]);
     206  if (tvItem->sibling)
     207                return (& infoPtr->items[(INT)tvItem->sibling]);
    207208
    208209  /*
     
    212213  while (wineItem->parent) {
    213214    wineItem=& infoPtr->items [(INT)wineItem->parent];
    214         if (wineItem->sibling)
     215        if (wineItem->sibling)
    215216      return (& infoPtr->items [(INT)wineItem->sibling]);
    216   } 
    217 
    218   return NULL; 
     217  }
     218
     219  return NULL;
    219220}
    220221
    221222/***************************************************************************
    222  * This method returns the nth item starting at the given item.  It returns 
     223 * This method returns the nth item starting at the given item.  It returns
    223224 * the last item (or first) we we run out of items.
    224225 *
     
    227228 */
    228229static TREEVIEW_ITEM *TREEVIEW_GetListItem(
    229   TREEVIEW_INFO *infoPtr, 
     230  TREEVIEW_INFO *infoPtr,
    230231  TREEVIEW_ITEM *tvItem,
    231232  LONG          count)
     
    241242    {
    242243      /* Keep a pointer to the previous in case we ask for more than we got */
    243       previousItem = wineItem; 
     244      previousItem = wineItem;
    244245      wineItem     = TREEVIEW_GetNextListItem(infoPtr, wineItem);
    245     } 
     246    }
    246247
    247248    if (wineItem == NULL)
     
    254255    {
    255256      /* Keep a pointer to the previous in case we ask for more than we got */
    256       previousItem = wineItem; 
     257      previousItem = wineItem;
    257258      wineItem = TREEVIEW_GetPrevListItem(infoPtr, wineItem);
    258259    }
     
    267268}
    268269
    269  
     270
    270271/***************************************************************************
    271  * This method 
     272 * This method
    272273 */
    273274static void TREEVIEW_RemoveAllChildren(
     
    277278 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    278279 TREEVIEW_ITEM *killItem;
    279  INT    kill;
    280  
     280 INT    kill;
     281
    281282 kill=(INT)parentItem->firstChild;
    282283 while (kill) {
    283         tv_set_bit ( kill, infoPtr->freeList);
    284         killItem=& infoPtr->items[kill];
    285         if (killItem->pszText!=LPSTR_TEXTCALLBACKA)
    286                 COMCTL32_Free (killItem->pszText);
    287         TREEVIEW_SendTreeviewNotify (hwnd, TVN_DELETEITEM, 0, (HTREEITEM)kill, 0);
    288         if (killItem->firstChild)
    289                         TREEVIEW_RemoveAllChildren (hwnd, killItem);
    290         kill=(INT)killItem->sibling;
     284        tv_set_bit ( kill, infoPtr->freeList);
     285        killItem=& infoPtr->items[kill];
     286        if (killItem->pszText!=LPSTR_TEXTCALLBACKA)
     287                COMCTL32_Free (killItem->pszText);
     288        TREEVIEW_SendTreeviewNotify (hwnd, TVN_DELETEITEM, 0, (HTREEITEM)kill, 0);
     289        if (killItem->firstChild)
     290                        TREEVIEW_RemoveAllChildren (hwnd, killItem);
     291        kill=(INT)killItem->sibling;
    291292 }
    292293
    293294 if (parentItem->cChildren>0) {
    294         infoPtr->uNumItems -= parentItem->cChildren;
    295         parentItem->firstChild = 0;
    296         parentItem->cChildren  = 0;
     295        infoPtr->uNumItems -= parentItem->cChildren;
     296        parentItem->firstChild = 0;
     297        parentItem->cChildren  = 0;
    297298 }
    298299
     
    312313 infoPtr->uNumItems--;
    313314 parentItem=NULL;
    314  if (wineItem->pszText!=LPSTR_TEXTCALLBACKA) 
    315         COMCTL32_Free (wineItem->pszText);
     315 if (wineItem->pszText!=LPSTR_TEXTCALLBACKA)
     316        COMCTL32_Free (wineItem->pszText);
    316317
    317318 TREEVIEW_SendTreeviewNotify (hwnd, TVN_DELETEITEM, 0, (HTREEITEM)iItem, 0);
    318319
    319  if (wineItem->firstChild) 
    320         TREEVIEW_RemoveAllChildren (hwnd,wineItem);
     320 if (wineItem->firstChild)
     321        TREEVIEW_RemoveAllChildren (hwnd,wineItem);
    321322
    322323 if (wineItem->parent) {
    323         parentItem=& infoPtr->items [(INT)wineItem->parent];
    324         switch (parentItem->cChildren) {
    325                 case I_CHILDRENCALLBACK:
    326 //                              FIXME (treeview,"we don't handle I_CHILDRENCALLBACK yet\n");
    327                                 break;
    328                 case 1:
    329                         parentItem->cChildren=0;
    330                         parentItem->firstChild=0;   
    331                         return;
    332                 default:
    333                         parentItem->cChildren--;
    334                         if ((INT)parentItem->firstChild==iItem)
    335                                 parentItem->firstChild=wineItem->sibling;
    336                 }
     324        parentItem=& infoPtr->items [(INT)wineItem->parent];
     325        switch (parentItem->cChildren) {
     326                case I_CHILDRENCALLBACK:
     327//                              FIXME (treeview,"we don't handle I_CHILDRENCALLBACK yet\n");
     328                                break;
     329                case 1:
     330                        parentItem->cChildren=0;
     331                        parentItem->firstChild=0;
     332                        return;
     333                default:
     334                        parentItem->cChildren--;
     335                        if ((INT)parentItem->firstChild==iItem)
     336                                parentItem->firstChild=wineItem->sibling;
     337                }
    337338 }
    338339
    339  if (iItem==(INT)infoPtr->TopRootItem) 
    340         infoPtr->TopRootItem=(HTREEITEM)wineItem->sibling;
     340 if (iItem==(INT)infoPtr->TopRootItem)
     341        infoPtr->TopRootItem=(HTREEITEM)wineItem->sibling;
    341342 if (wineItem->upsibling) {
    342         upsiblingItem=& infoPtr->items [(INT)wineItem->upsibling];
    343         upsiblingItem->sibling=wineItem->sibling;
     343        upsiblingItem=& infoPtr->items [(INT)wineItem->upsibling];
     344        upsiblingItem->sibling=wineItem->sibling;
    344345 }
    345346 if (wineItem->sibling) {
    346         siblingItem=& infoPtr->items [(INT)wineItem->sibling];
    347         siblingItem->upsibling=wineItem->upsibling;
     347        siblingItem=& infoPtr->items [(INT)wineItem->sibling];
     348        siblingItem->upsibling=wineItem->upsibling;
    348349 }
    349350}
     
    356357
    357358static void TREEVIEW_RemoveTree (HWND hwnd)
    358                                            
     359
    359360{
    360361 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     
    362363 int i;
    363364
    364  for (i=1; i<=(INT)infoPtr->uMaxHandle; i++) 
    365         if (!tv_test_bit (i, infoPtr->freeList)) {
    366                 killItem=& infoPtr->items [i]; 
    367                 if (killItem->pszText!=LPSTR_TEXTCALLBACKA)
    368                         COMCTL32_Free (killItem->pszText);
    369                 TREEVIEW_SendTreeviewNotify
    370                                         (hwnd, TVN_DELETEITEM, 0, killItem->hItem, 0);
    371                 }
     365 for (i=1; i<=(INT)infoPtr->uMaxHandle; i++)
     366        if (!tv_test_bit (i, infoPtr->freeList)) {
     367                killItem=& infoPtr->items [i];
     368                if (killItem->pszText!=LPSTR_TEXTCALLBACKA)
     369                        COMCTL32_Free (killItem->pszText);
     370                TREEVIEW_SendTreeviewNotify
     371                                        (hwnd, TVN_DELETEITEM, 0, killItem->hItem, 0);
     372                }
    372373
    373374 if (infoPtr->uNumPtrsAlloced) {
     
    377378        infoPtr->uNumPtrsAlloced=0;
    378379        infoPtr->uMaxHandle=0;
    379     }   
     380    }
    380381}
    381382
     
    394395  if (infoPtr==NULL) return 0;
    395396
    396   if ((INT)wParam == TVSIL_NORMAL) 
    397         return (LRESULT) infoPtr->himlNormal;
    398   if ((INT)wParam == TVSIL_STATE) 
    399         return (LRESULT) infoPtr->himlState;
     397  if ((INT)wParam == TVSIL_NORMAL)
     398        return (LRESULT) infoPtr->himlNormal;
     399  if ((INT)wParam == TVSIL_STATE)
     400        return (LRESULT) infoPtr->himlState;
    400401
    401402  return 0;
     
    410411//    TRACE (treeview,"\n");
    411412    switch ((INT)wParam) {
    412         case TVSIL_NORMAL:
    413             himlTemp = infoPtr->himlNormal;
    414             infoPtr->himlNormal = (HIMAGELIST)lParam;
    415             return (LRESULT)himlTemp;
    416 
    417         case TVSIL_STATE:
    418             himlTemp = infoPtr->himlState;
    419             infoPtr->himlState = (HIMAGELIST)lParam;
    420             return (LRESULT)himlTemp;
     413        case TVSIL_NORMAL:
     414            himlTemp = infoPtr->himlNormal;
     415            infoPtr->himlNormal = (HIMAGELIST)lParam;
     416            return (LRESULT)himlTemp;
     417
     418        case TVSIL_STATE:
     419            himlTemp = infoPtr->himlState;
     420            infoPtr->himlState = (HIMAGELIST)lParam;
     421            return (LRESULT)himlTemp;
    421422    }
    422423
     
    435436//  TRACE (treeview,"\n");
    436437  if (wParam==-1) {
    437         hdc=GetDC (hwnd);
    438         infoPtr->uItemHeight=-1;
    439         return prevHeight;
     438        hdc=GetDC (hwnd);
     439        infoPtr->uItemHeight=-1;
     440        return prevHeight;
    440441  }
    441442
     
    446447
    447448  if (!( GetWindowLongA( hwnd, GWL_STYLE) & TVS_NONEVENHEIGHT))
    448         infoPtr->uItemHeight = (INT) wParam & 0xfffffffe;
     449        infoPtr->uItemHeight = (INT) wParam & 0xfffffffe;
    449450  return prevHeight;
    450451}
     
    454455{
    455456  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    456  
     457
    457458//  TRACE (treeview,"\n");
    458459  return infoPtr->uItemHeight;
    459460}
    460  
     461
    461462static LRESULT
    462463TREEVIEW_SetTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
     
    474475{
    475476  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    476        
     477
    477478//  TRACE (treeview,"\n");
    478479  return (LRESULT) infoPtr->clrText;
     
    494495{
    495496  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    496        
     497
    497498//  TRACE (treeview,"\n");
    498499  return (LRESULT) infoPtr->clrBk;
     
    500501
    501502
    502 /* cdmode: custom draw mode as received from app. in first NMCUSTOMDRAW 
     503/* cdmode: custom draw mode as received from app. in first NMCUSTOMDRAW
    503504           notification */
    504505
     
    516517  RECT  r;
    517518
    518  
    519   if (wineItem->state & TVIS_BOLD) 
    520         hOldFont = SelectObject (hdc, infoPtr->hBoldFont);
    521   else 
    522         hOldFont = SelectObject (hdc, infoPtr->hFont);
     519
     520  if (wineItem->state & TVIS_BOLD)
     521        hOldFont = SelectObject (hdc, infoPtr->hBoldFont);
     522  else
     523        hOldFont = SelectObject (hdc, infoPtr->hFont);
    523524
    524525  cditem=0;
    525526  if (infoPtr->cdmode & CDRF_NOTIFYITEMDRAW) {
    526                 drawmode=CDDS_ITEMPREPAINT;
    527 
    528                 if (infoPtr->cdmode & CDRF_NOTIFYSUBITEMDRAW)
     527                drawmode=CDDS_ITEMPREPAINT;
     528
     529                if (infoPtr->cdmode & CDRF_NOTIFYSUBITEMDRAW)
    529530      drawmode|=CDDS_SUBITEM;
    530531
    531                 cditem=TREEVIEW_SendCustomDrawItemNotify (hwnd, hdc, wineItem, drawmode);
    532 
    533 //              TRACE (treeview,"cditem:%d\n",cditem);
    534 
    535                 if (cditem & CDRF_SKIPDEFAULT)
    536                         return;
    537         }
    538 
    539   /* 
    540    * Set drawing starting points 
     532                cditem=TREEVIEW_SendCustomDrawItemNotify (hwnd, hdc, wineItem, drawmode);
     533
     534//              TRACE (treeview,"cditem:%d\n",cditem);
     535
     536                if (cditem & CDRF_SKIPDEFAULT)
     537                        return;
     538        }
     539
     540  /*
     541   * Set drawing starting points
    541542   */
    542543  r      = wineItem->rect;               /* this item rectangle */
     
    544545  xpos   = r.left + TREEVIEW_LEFT_MARGIN;/* horizontal starting point */
    545546
    546   /* 
    547    * Display the tree hierarchy 
     547  /*
     548   * Display the tree hierarchy
    548549   */
    549   if ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASLINES) 
     550  if ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASLINES)
    550551  {
    551     /* 
    552      * Write links to parent node 
     552    /*
     553     * Write links to parent node
    553554     * we draw the L starting from the child to the parent
    554555     *
     
    557558     * points[2] is attached to the parent or the up sibling
    558559     */
    559     if ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_LINESATROOT) 
     560    if ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_LINESATROOT)
    560561    {
    561562      TREEVIEW_ITEM *upNode    = NULL;
    562         BOOL  hasParentOrSibling = TRUE;
     563        BOOL  hasParentOrSibling = TRUE;
    563564      RECT  upRect             = {0,0,0,0};
    564565      HPEN  hOldPen, hnewPen;
    565         POINT points[3];
    566       /* 
     566        POINT points[3];
     567      /*
    567568       * determine the target location of the line at root, either be linked
    568569       * to the up sibling or to the parent node.
    569570       */
    570571      if (wineItem->upsibling)
    571         upNode  = TREEVIEW_ValidItem (infoPtr, wineItem->upsibling);
     572        upNode  = TREEVIEW_ValidItem (infoPtr, wineItem->upsibling);
    572573      else if (wineItem->parent)
    573         upNode  = TREEVIEW_ValidItem (infoPtr, wineItem->parent);
     574        upNode  = TREEVIEW_ValidItem (infoPtr, wineItem->parent);
    574575      else
    575576        hasParentOrSibling = FALSE;
     
    582583        points[2].x = points[1].x = upRect.left+8;
    583584        points[0].x = points[2].x + 10;
    584         points[2].y = upRect.bottom-3;     
     585        points[2].y = upRect.bottom-3;
    585586        points[1].y = points[0].y = center;
    586587      }
    587588      else
    588589      {
    589         points[2].x = points[1].x = 8 + (20*wineItem->iLevel); 
    590         points[2].y = ( upNode->cChildren == 0) ? 
     590        points[2].x = points[1].x = 8 + (20*wineItem->iLevel);
     591        points[2].y = ( upNode->cChildren == 0) ?
    591592                        upRect.top :        /* is linked to the "L" above */
    592                         ( wineItem->upsibling != NULL) ? 
     593                        ( wineItem->upsibling != NULL) ?
    593594                          upRect.bottom-3:  /* is linked to an icon       */
    594595                          upRect.bottom+1;  /* is linked to a +/- box     */
    595596        points[1].y = points[0].y = center;
    596         points[0].x = points[1].x + 10; 
     597        points[0].x = points[1].x + 10;
    597598      }
    598    
    599       /* 
     599
     600      /*
    600601       * Get a doted pen
    601        */ 
     602       */
    602603      hnewPen = CreatePen(PS_DOT, 0, GetSysColor(COLOR_WINDOWTEXT) );
    603604      hOldPen = SelectObject( hdc, hnewPen );
    604  
     605
    605606      if (hasParentOrSibling)
    606         Polyline (hdc,points,3); 
     607        Polyline (hdc,points,3);
    607608      else
    608         Polyline (hdc,points,2); 
    609      
     609        Polyline (hdc,points,2);
     610
    610611      DeleteObject(hnewPen);
    611612      SelectObject(hdc, hOldPen);
     
    613614  }
    614615
    615   /* 
     616  /*
    616617   * Display the (+/-) signs
    617618   */
     
    619620    xpos+=(5*wineItem->iLevel);
    620621
    621   if (( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASBUTTONS) && 
     622  if (( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASBUTTONS) &&
    622623      ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASLINES))
    623624  {
    624           if ( (wineItem->cChildren) ||
    625                (wineItem->cChildren == I_CHILDRENCALLBACK))
     625          if ( (wineItem->cChildren) ||
     626               (wineItem->cChildren == I_CHILDRENCALLBACK))
    626627    {
    627628      /* Setup expand box coordinate to facilitate the LMBClick handling */
     
    631632      wineItem->expandBox.bottom = center+5;
    632633
    633                 Rectangle (
    634         hdc, 
    635         wineItem->expandBox.left, 
    636         wineItem->expandBox.top , 
    637         wineItem->expandBox.right, 
     634                Rectangle (
     635        hdc,
     636        wineItem->expandBox.left,
     637        wineItem->expandBox.top ,
     638        wineItem->expandBox.right,
    638639        wineItem->expandBox.bottom);
    639640
    640                 MoveToEx (hdc, xpos-2, center, NULL);
    641                 LineTo   (hdc, xpos+3, center);
    642  
    643                 if (!(wineItem->state & TVIS_EXPANDED)) {
    644                         MoveToEx (hdc, xpos,   center-2, NULL);
    645                         LineTo   (hdc, xpos,   center+3);
    646           }
     641                MoveToEx (hdc, xpos-2, center, NULL);
     642                LineTo   (hdc, xpos+3, center);
     643
     644                if (!(wineItem->state & TVIS_EXPANDED)) {
     645                        MoveToEx (hdc, xpos,   center-2, NULL);
     646                        LineTo   (hdc, xpos,   center+3);
     647          }
    647648    }
    648649  }
    649650
    650   /* 
     651  /*
    651652   * Display the image assiciated with this item
    652653   */
     
    656657    HIMAGELIST *himlp = NULL;
    657658
    658           if (infoPtr->himlNormal)
     659          if (infoPtr->himlNormal)
    659660      himlp=&infoPtr->himlNormal; /* get the image list */
    660661
    661         if ( (wineItem->state & TVIS_SELECTED) &&
    662          (wineItem->iSelectedImage)) { 
    663        
     662        if ( (wineItem->state & TVIS_SELECTED) &&
     663         (wineItem->iSelectedImage)) {
     664
    664665      /* State images are displayed to the left of the Normal image*/
    665       if (infoPtr->himlState) 
     666      if (infoPtr->himlState)
    666667        himlp=&infoPtr->himlState;
    667668
    668669      /* The item is curently selected */
    669                   if (wineItem->iSelectedImage == I_IMAGECALLBACK)
    670                         TREEVIEW_SendDispInfoNotify (
    671           hwnd, 
    672           wineItem, 
    673           TVN_GETDISPINFO, 
     670                  if (wineItem->iSelectedImage == I_IMAGECALLBACK)
     671                        TREEVIEW_SendDispInfoNotify (
     672          hwnd,
     673          wineItem,
     674          TVN_GETDISPINFO,
    674675          TVIF_SELECTEDIMAGE);
    675676
    676677      imageIndex = wineItem->iSelectedImage;
    677678
    678           } else {
     679          } else {
    679680      /* This item is not selected */
    680                   if (wineItem->iImage == I_IMAGECALLBACK)
    681                           TREEVIEW_SendDispInfoNotify (
    682           hwnd, 
    683           wineItem, 
    684           TVN_GETDISPINFO, 
     681                  if (wineItem->iImage == I_IMAGECALLBACK)
     682                          TREEVIEW_SendDispInfoNotify (
     683          hwnd,
     684          wineItem,
     685          TVN_GETDISPINFO,
    685686          TVIF_IMAGE);
    686687
    687688      imageIndex = wineItem->iImage;
    688         }
    689  
     689        }
     690
    690691    if (himlp)
    691     { 
     692    {
    692693      /* We found an image to display? Draw it. */
    693         ImageList_Draw (
    694         *himlp, 
     694        ImageList_Draw (
     695        *himlp,
    695696        wineItem->iImage,
    696         hdc, 
    697         xpos-2, 
    698         r.top+1, 
     697        hdc,
     698        xpos-2,
     699        r.top+1,
    699700        ILD_NORMAL);
    700701
    701           ImageList_GetIconSize (*himlp, &cx, &cy);
    702           xpos+=cx;
     702          ImageList_GetIconSize (*himlp, &cx, &cy);
     703          xpos+=cx;
    703704    }
    704705  }
    705706
    706   /* 
     707  /*
    707708   * Display the text assiciated with this item
    708709   */
    709710  r.left=xpos;
    710   if ((wineItem->mask & TVIF_TEXT) && (wineItem->pszText)) 
     711  if ((wineItem->mask & TVIF_TEXT) && (wineItem->pszText))
    711712  {
    712713    COLORREF oldBkColor = 0;
     
    717718    r.right -= 3;
    718719
    719     wineItem->text.left  = r.left; 
     720    wineItem->text.left  = r.left;
    720721    wineItem->text.right = r.right;
    721722    wineItem->text.top   = r.top;
     
    726727      oldBkColor   = SetBkColor  (hdc, GetSysColor( COLOR_HIGHLIGHT));
    727728      oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_HIGHLIGHTTEXT));
    728     } 
    729     else 
     729    }
     730    else
    730731    {
    731732      oldBkMode    = SetBkMode(hdc, TRANSPARENT);
     
    740741    /* Draw it */
    741742    DrawTextA (
    742       hdc, 
    743       wineItem->pszText, 
    744       lstrlenA(wineItem->pszText), 
    745       &wineItem->text, 
    746       uTextJustify | DT_VCENTER | DT_SINGLELINE ); 
     743      hdc,
     744      wineItem->pszText,
     745      lstrlenA(wineItem->pszText),
     746      &wineItem->text,
     747      uTextJustify | DT_VCENTER | DT_SINGLELINE );
    747748
    748749    /* Obtain the text coordinate */
    749750    DrawTextA (
    750       hdc, 
    751       wineItem->pszText, 
    752       lstrlenA(wineItem->pszText), 
    753       &wineItem->text, 
    754       uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT); 
     751      hdc,
     752      wineItem->pszText,
     753      lstrlenA(wineItem->pszText),
     754      &wineItem->text,
     755      uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT);
    755756
    756757    /* Restore the hdc state */
     
    763764
    764765    /* Draw the box arround the selected item */
    765     if (wineItem->state & TVIS_SELECTED ) 
     766    if (wineItem->state & TVIS_SELECTED )
    766767    {
    767768      HPEN  hnewPen     = CreatePen(PS_DOT, 0, GetSysColor(COLOR_WINDOWTEXT) );
    768769      HPEN  hOldPen     = SelectObject( hdc, hnewPen );
    769770      POINT points[4];
    770      
     771
    771772      points[0].x = wineItem->text.left-1;
    772       points[0].y = wineItem->text.top+1; 
     773      points[0].y = wineItem->text.top+1;
    773774      points[1].x = wineItem->text.right;
    774       points[1].y = wineItem->text.top+1; 
     775      points[1].y = wineItem->text.top+1;
    775776      points[2].x = wineItem->text.right;
    776       points[2].y = wineItem->text.bottom; 
     777      points[2].y = wineItem->text.bottom;
    777778      points[3].x = wineItem->text.left-1;
    778779      points[3].y = wineItem->text.bottom;
    779780
    780       Polyline (hdc,points,4); 
     781      Polyline (hdc,points,4);
    781782
    782783      DeleteObject(hnewPen);
     
    786787
    787788  if (cditem & CDRF_NOTIFYPOSTPAINT)
    788                 TREEVIEW_SendCustomDrawItemNotify (hwnd, hdc, wineItem, CDDS_ITEMPOSTPAINT);
     789                TREEVIEW_SendCustomDrawItemNotify (hwnd, hdc, wineItem, CDDS_ITEMPOSTPAINT);
    789790
    790791  SelectObject (hdc, hOldFont);
     
    800801
    801802//  TRACE (treeview,"\n");
    802   /* 
     803  /*
    803804   * validate parameters
    804805   */
    805   if ( (infoPtr==NULL) || (lpRect == NULL) ) 
     806  if ( (infoPtr==NULL) || (lpRect == NULL) )
    806807    return FALSE;
    807808
    808   if (infoPtr->Timer & TV_REFRESH_TIMER_SET)         
    809                 TREEVIEW_Refresh (hwnd);        /* we want a rect for the current view */
    810  
    811   /* 
     809  if (infoPtr->Timer & TV_REFRESH_TIMER_SET)
     810                TREEVIEW_Refresh (hwnd);        /* we want a rect for the current view */
     811
     812  /*
    812813   * retrive the item ptr
    813    */ 
     814   */
    814815  iItem = (HTREEITEM *) lParam;
    815816  wineItem = TREEVIEW_ValidItem (infoPtr, *iItem);
    816   if ((!wineItem) || (!wineItem->visible)) 
     817  if ((!wineItem) || (!wineItem->visible))
    817818    return FALSE;
    818819
    819   /* 
    820    * If wParam is TRUE return the text size otherwise return 
    821    * the whole item size       
     820  /*
     821   * If wParam is TRUE return the text size otherwise return
     822   * the whole item size
    822823   */
    823824  if ((INT) wParam) {
    824         lpRect->left      = wineItem->text.left;
    825     lpRect->right         = wineItem->text.right;
    826     lpRect->bottom      = wineItem->text.bottom;
    827     lpRect->top     = wineItem->text.top;
     825        lpRect->left      = wineItem->text.left;
     826    lpRect->right         = wineItem->text.right;
     827    lpRect->bottom      = wineItem->text.bottom;
     828    lpRect->top     = wineItem->text.top;
    828829  } else {
    829     lpRect->left          = wineItem->rect.left;
    830     lpRect->right         = wineItem->rect.right;
     830    lpRect->left          = wineItem->rect.left;
     831    lpRect->right         = wineItem->rect.right;
    831832    lpRect->bottom  = wineItem->rect.bottom;
    832     lpRect->top     = wineItem->rect.top;
    833   }
    834 
    835 //  TRACE (treeview,"[L:%d R:%d T:%d B:%d]\n", 
     833    lpRect->top     = wineItem->rect.top;
     834  }
     835
     836//  TRACE (treeview,"[L:%d R:%d T:%d B:%d]\n",
    836837//      lpRect->left,lpRect->right,
    837 //                      lpRect->top,lpRect->bottom);
     838//                      lpRect->top,lpRect->bottom);
    838839
    839840  return TRUE;
     
    875876
    876877  if (tvItem->mask & TVIF_INTEGRAL) {
    877         wineItem->iIntegral=tvItem->iIntegral; 
     878        wineItem->iIntegral=tvItem->iIntegral;
    878879//        FIXME (treeview," TVIF_INTEGRAL not supported yet\n");
    879880  }
     
    892893
    893894  if (tvItem->mask & TVIF_TEXT) {
    894                 if (tvItem->pszText!=LPSTR_TEXTCALLBACKA) {
     895                if (tvItem->pszText!=LPSTR_TEXTCALLBACKA) {
    895896        len=lstrlenA (tvItem->pszText);
    896         if (len>wineItem->cchTextMax) 
    897                         wineItem->pszText= COMCTL32_ReAlloc (wineItem->pszText, len+1);
     897        if (len>wineItem->cchTextMax)
     898                        wineItem->pszText= COMCTL32_ReAlloc (wineItem->pszText, len+1);
    898899        lstrcpynA (wineItem->pszText, tvItem->pszText,len);
    899                 } else {
    900                         if (wineItem->cchTextMax) {
    901                                 COMCTL32_Free (wineItem->pszText);
    902                                 wineItem->cchTextMax=0;
    903                         }
    904                 wineItem->pszText=LPSTR_TEXTCALLBACKA;
    905                 }
     900                } else {
     901                        if (wineItem->cchTextMax) {
     902                                COMCTL32_Free (wineItem->pszText);
     903                                wineItem->cchTextMax=0;
     904                        }
     905                wineItem->pszText=LPSTR_TEXTCALLBACKA;
     906                }
    906907   }
    907908
     
    918919{
    919920    TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    920         TEXTMETRICA tm;
    921         HBRUSH hbrBk;
     921        TEXTMETRICA tm;
     922        HBRUSH hbrBk;
    922923    RECT rect;
    923         HDC hdc;
     924        HDC hdc;
    924925    INT iItem, indent, x, y, cx, height, itemHeight;
    925926    INT viewtop,viewbottom,viewleft,viewright;
     
    928929//    TRACE (treeview,"\n");
    929930
    930         hdc=GetDC (hwnd);
     931        hdc=GetDC (hwnd);
    931932
    932933    if (infoPtr->Timer & TV_REFRESH_TIMER_SET) {
    933                 KillTimer (hwnd, TV_REFRESH_TIMER);
    934                 infoPtr->Timer &= ~TV_REFRESH_TIMER_SET;
     934                KillTimer (hwnd, TV_REFRESH_TIMER);
     935                infoPtr->Timer &= ~TV_REFRESH_TIMER_SET;
    935936    }
    936937
    937    
     938
    938939    GetClientRect (hwnd, &rect);
    939940    if ((rect.left-rect.right ==0) || (rect.top-rect.bottom==0)) return;
    940941
    941     infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify 
    942                                                 (hwnd, CDDS_PREPAINT, hdc, rect);
    943 
    944         if (infoPtr->cdmode==CDRF_SKIPDEFAULT) {
    945                   ReleaseDC (hwnd, hdc);
    946                   return;
    947         }
    948 
    949         infoPtr->uVisibleHeight= rect.bottom-rect.top;
    950         infoPtr->uVisibleWidth= rect.right-rect.left;
     942    infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify
     943                                                (hwnd, CDDS_PREPAINT, hdc, rect);
     944
     945        if (infoPtr->cdmode==CDRF_SKIPDEFAULT) {
     946                  ReleaseDC (hwnd, hdc);
     947                  return;
     948        }
     949
     950        infoPtr->uVisibleHeight= rect.bottom-rect.top;
     951        infoPtr->uVisibleWidth= rect.right-rect.left;
    951952
    952953    viewtop=infoPtr->cy;
     
    958959
    959960    /* draw background */
    960    
     961
    961962    hbrBk = GetSysColorBrush (COLOR_WINDOW);
    962963    FillRect(hdc, &rect, hbrBk);
     
    971972
    972973    while (iItem) {
    973                 prevItem=wineItem;
     974                prevItem=wineItem;
    974975        wineItem= & infoPtr->items[iItem];
    975                 wineItem->iLevel=indent;
     976                wineItem->iLevel=indent;
    976977
    977978        ImageList_GetIconSize (infoPtr->himlNormal, &cx, &itemHeight);
    978979        if (infoPtr->uItemHeight>itemHeight)
    979                     itemHeight=infoPtr->uItemHeight;
    980 
    981             GetTextMetricsA (hdc, &tm);
    982             if ((tm.tmHeight + tm.tmExternalLeading) > itemHeight)
    983                      itemHeight=tm.tmHeight + tm.tmExternalLeading;
    984 
    985         infoPtr->uRealItemHeight=itemHeight;   
     980                    itemHeight=infoPtr->uItemHeight;
     981
     982            GetTextMetricsA (hdc, &tm);
     983            if ((tm.tmHeight + tm.tmExternalLeading) > itemHeight)
     984                     itemHeight=tm.tmHeight + tm.tmExternalLeading;
     985
     986        infoPtr->uRealItemHeight=itemHeight;
    986987
    987988
    988989/* FIXME: remove this in later stage  */
    989990/*
    990 //              if (wineItem->pszText!=LPSTR_TEXTCALLBACK32A)
    991 //              TRACE (treeview, "%d %d [%d %d %d %d] (%s)\n",y,x,
    992 //                      wineItem->rect.top, wineItem->rect.bottom,
    993 //                      wineItem->rect.left, wineItem->rect.right,
    994 //                      wineItem->pszText);
    995 //              else
    996 //              TRACE (treeview, "%d [%d %d %d %d] (CALLBACK)\n",
    997 //                              wineItem->hItem,
    998 //                              wineItem->rect.top, wineItem->rect.bottom,
    999 //                              wineItem->rect.left, wineItem->rect.right);
     991//              if (wineItem->pszText!=LPSTR_TEXTCALLBACK32A)
     992//              TRACE (treeview, "%d %d [%d %d %d %d] (%s)\n",y,x,
     993//                      wineItem->rect.top, wineItem->rect.bottom,
     994//                      wineItem->rect.left, wineItem->rect.right,
     995//                      wineItem->pszText);
     996//              else
     997//              TRACE (treeview, "%d [%d %d %d %d] (CALLBACK)\n",
     998//                              wineItem->hItem,
     999//                              wineItem->rect.top, wineItem->rect.bottom,
     1000//                              wineItem->rect.left, wineItem->rect.right);
    10001001*/
    10011002
    1002                 height=itemHeight * wineItem->iIntegral +1;
    1003                 if ((y >= viewtop) && (y <= viewbottom) &&
    1004                 (x >= viewleft  ) && (x <= viewright)) {
    1005                                 wineItem->visible = TRUE;
    1006                         wineItem->rect.top = y - infoPtr->cy + rect.top;
    1007                         wineItem->rect.bottom = wineItem->rect.top + height ;
    1008                         wineItem->rect.left = x - infoPtr->cx + rect.left;
    1009                         wineItem->rect.right = rect.right;
    1010                         if (!infoPtr->firstVisible)
    1011                                 infoPtr->firstVisible=wineItem->hItem;
    1012                 TREEVIEW_DrawItem (hwnd, hdc, wineItem);
    1013                 }
    1014                 else {
    1015                         wineItem->visible   = FALSE;
    1016                         wineItem->rect.left = wineItem->rect.top    = 0;
    1017                         wineItem->rect.right= wineItem->rect.bottom = 0;
    1018                         wineItem->text.left = wineItem->text.top    = 0;
    1019                         wineItem->text.right= wineItem->text.bottom = 0;
    1020                 }
    1021 
    1022                 /* look up next item */
    1023        
    1024                 if ((wineItem->firstChild) && (wineItem->state & TVIS_EXPANDED)) {
    1025                         iItem=(INT)wineItem->firstChild;
    1026                         indent++;
    1027                         x+=infoPtr->uIndent;
    1028                         if (x>infoPtr->uTotalWidth)     
    1029                                 infoPtr->uTotalWidth=x;
    1030                 }
    1031                 else {
    1032                         iItem=(INT)wineItem->sibling;
    1033                         while ((!iItem) && (indent>0)) {
    1034                                 indent--;
    1035                                 x-=infoPtr->uIndent;
    1036                                 prevItem=wineItem;
    1037                                 wineItem=&infoPtr->items[(INT)wineItem->parent];
    1038                                 iItem=(INT)wineItem->sibling;
    1039                         }
    1040                 }
     1003                height=itemHeight * wineItem->iIntegral +1;
     1004                if ((y >= viewtop) && (y <= viewbottom) &&
     1005                (x >= viewleft  ) && (x <= viewright)) {
     1006                                wineItem->visible = TRUE;
     1007                        wineItem->rect.top = y - infoPtr->cy + rect.top;
     1008                        wineItem->rect.bottom = wineItem->rect.top + height ;
     1009                        wineItem->rect.left = x - infoPtr->cx + rect.left;
     1010                        wineItem->rect.right = rect.right;
     1011                        if (!infoPtr->firstVisible)
     1012                                infoPtr->firstVisible=wineItem->hItem;
     1013                TREEVIEW_DrawItem (hwnd, hdc, wineItem);
     1014                }
     1015                else {
     1016                        wineItem->visible   = FALSE;
     1017                        wineItem->rect.left = wineItem->rect.top    = 0;
     1018                        wineItem->rect.right= wineItem->rect.bottom = 0;
     1019                        wineItem->text.left = wineItem->text.top    = 0;
     1020                        wineItem->text.right= wineItem->text.bottom = 0;
     1021                }
     1022
     1023                /* look up next item */
     1024
     1025                if ((wineItem->firstChild) && (wineItem->state & TVIS_EXPANDED)) {
     1026                        iItem=(INT)wineItem->firstChild;
     1027                        indent++;
     1028                        x+=infoPtr->uIndent;
     1029                        if (x>infoPtr->uTotalWidth)
     1030                                infoPtr->uTotalWidth=x;
     1031                }
     1032                else {
     1033                        iItem=(INT)wineItem->sibling;
     1034                        while ((!iItem) && (indent>0)) {
     1035                                indent--;
     1036                                x-=infoPtr->uIndent;
     1037                                prevItem=wineItem;
     1038                                wineItem=&infoPtr->items[(INT)wineItem->parent];
     1039                                iItem=(INT)wineItem->sibling;
     1040                        }
     1041                }
    10411042        y +=height;
    1042     }                           /* while */
     1043    }                           /* while */
    10431044
    10441045/* FIXME: infoPtr->uTotalWidth should also take item label into account */
     
    10471048    infoPtr->uTotalHeight=y;
    10481049    if (y >= (viewbottom-viewtop)) {
    1049                 if (!(infoPtr->uInternalStatus & TV_VSCROLL))
    1050                         ShowScrollBar (hwnd, SB_VERT, TRUE);
    1051                 infoPtr->uInternalStatus |=TV_VSCROLL;
    1052                 SetScrollRange (hwnd, SB_VERT, 0,
    1053                                         y - infoPtr->uVisibleHeight, FALSE);
    1054                 SetScrollPos (hwnd, SB_VERT, infoPtr->cy, TRUE);
    1055         }
     1050                if (!(infoPtr->uInternalStatus & TV_VSCROLL))
     1051                        ShowScrollBar (hwnd, SB_VERT, TRUE);
     1052                infoPtr->uInternalStatus |=TV_VSCROLL;
     1053                SetScrollRange (hwnd, SB_VERT, 0,
     1054                                        y - infoPtr->uVisibleHeight, FALSE);
     1055                SetScrollPos (hwnd, SB_VERT, infoPtr->cy, TRUE);
     1056        }
    10561057    else {
    1057                 if (infoPtr->uInternalStatus & TV_VSCROLL)
    1058                         ShowScrollBar (hwnd, SB_VERT, FALSE);
    1059                 infoPtr->uInternalStatus &= ~TV_VSCROLL;
    1060         }
    1061 
    1062 
    1063         if (infoPtr->cdmode & CDRF_NOTIFYPOSTPAINT)
    1064         infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify
    1065                                                                 (hwnd, CDDS_POSTPAINT, hdc, rect);
     1058                if (infoPtr->uInternalStatus & TV_VSCROLL)
     1059                        ShowScrollBar (hwnd, SB_VERT, FALSE);
     1060                infoPtr->uInternalStatus &= ~TV_VSCROLL;
     1061        }
     1062
     1063
     1064        if (infoPtr->cdmode & CDRF_NOTIFYPOSTPAINT)
     1065        infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify
     1066                                                                (hwnd, CDDS_POSTPAINT, hdc, rect);
    10661067
    10671068    ReleaseDC (hwnd, hdc);
     
    10701071
    10711072
    1072 static LRESULT 
     1073static LRESULT
    10731074TREEVIEW_HandleTimer (HWND hwnd, WPARAM wParam, LPARAM lParam)
    10741075{
     
    10791080
    10801081  switch (wParam) {
    1081         case TV_REFRESH_TIMER:
    1082                 KillTimer (hwnd, TV_REFRESH_TIMER);
    1083                 infoPtr->Timer &= ~TV_REFRESH_TIMER_SET;
     1082        case TV_REFRESH_TIMER:
     1083                KillTimer (hwnd, TV_REFRESH_TIMER);
     1084                infoPtr->Timer &= ~TV_REFRESH_TIMER_SET;
    10841085    InvalidateRect(hwnd, NULL, FALSE);
    1085                 return 0;
    1086         case TV_EDIT_TIMER:
    1087                 KillTimer (hwnd, TV_EDIT_TIMER);
    1088                 infoPtr->Timer &= ~TV_EDIT_TIMER_SET;
    1089                 return 0;
    1090         default:
    1091 //              ERR (treeview,"got unknown timer\n");
    1092                 break;
     1086                return 0;
     1087        case TV_EDIT_TIMER:
     1088                KillTimer (hwnd, TV_EDIT_TIMER);
     1089                infoPtr->Timer &= ~TV_EDIT_TIMER_SET;
     1090                return 0;
     1091        default:
     1092//              ERR (treeview,"got unknown timer\n");
     1093                break;
    10931094 }
    1094                
     1095
    10951096 return 1;
    10961097}
     
    11051106// TRACE (treeview,"\n");
    11061107 if (infoPtr->Timer & TV_REFRESH_TIMER_SET) {
    1107         KillTimer (hwnd, TV_REFRESH_TIMER);
     1108        KillTimer (hwnd, TV_REFRESH_TIMER);
    11081109 }
    11091110
     
    11291130
    11301131   if (tvItem->mask & TVIF_CHILDREN) {
    1131 //              if (TVIF_CHILDREN==I_CHILDRENCALLBACK)
    1132 //                      FIXME (treeview,"I_CHILDRENCALLBACK not supported\n");
     1132//              if (TVIF_CHILDREN==I_CHILDRENCALLBACK)
     1133//                      FIXME (treeview,"I_CHILDRENCALLBACK not supported\n");
    11331134        tvItem->cChildren=wineItem->cChildren;
    11341135   }
     
    11431144
    11441145   if (tvItem->mask & TVIF_INTEGRAL) {
    1145         tvItem->iIntegral=wineItem->iIntegral; 
    1146 //              FIXME (treeview," TVIF_INTEGRAL not supported yet\n");
     1146        tvItem->iIntegral=wineItem->iIntegral;
     1147//              FIXME (treeview," TVIF_INTEGRAL not supported yet\n");
    11471148   }
    11481149
     
    11601161
    11611162   if (tvItem->mask & TVIF_TEXT) {
    1162         if (wineItem->pszText == LPSTR_TEXTCALLBACKA) {
    1163             tvItem->pszText = LPSTR_TEXTCALLBACKA;  /* FIXME:send notification? */
    1164 //              ERR (treeview," GetItem called with LPSTR_TEXTCALLBACK\n");
    1165         }
    1166         else if (wineItem->pszText) {
    1167             lstrcpynA (tvItem->pszText, wineItem->pszText, tvItem->cchTextMax);
    1168         }
     1163        if (wineItem->pszText == LPSTR_TEXTCALLBACKA) {
     1164            tvItem->pszText = LPSTR_TEXTCALLBACKA;  /* FIXME:send notification? */
     1165//              ERR (treeview," GetItem called with LPSTR_TEXTCALLBACK\n");
     1166        }
     1167        else if (wineItem->pszText) {
     1168            lstrcpynA (tvItem->pszText, wineItem->pszText, tvItem->cchTextMax);
     1169        }
    11691170   }
    11701171
    1171 //  TRACE(treeview,"item %d<%p>, txt %p, img %p, action %x\n", 
     1172//  TRACE(treeview,"item %d<%p>, txt %p, img %p, action %x\n",
    11721173//    iItem,
    1173 //    tvItem, 
    1174 //    tvItem->pszText, 
    1175 //    & tvItem->iImage, 
     1174//    tvItem,
     1175//    tvItem->pszText,
     1176//    & tvItem->iImage,
    11761177//    tvItem->mask);
    11771178
     
    11971198  retval=0;
    11981199  switch (flag) {
    1199         case TVGN_ROOT: retval=(INT)infoPtr->TopRootItem;
    1200                                         break;
    1201         case TVGN_CARET:retval=(INT)infoPtr->selectedItem;
    1202                                         break;
    1203         case TVGN_FIRSTVISIBLE:
    1204                                 TREEVIEW_Refresh (hwnd);       
     1200        case TVGN_ROOT: retval=(INT)infoPtr->TopRootItem;
     1201                                        break;
     1202        case TVGN_CARET:retval=(INT)infoPtr->selectedItem;
     1203                                        break;
     1204        case TVGN_FIRSTVISIBLE:
     1205                                TREEVIEW_Refresh (hwnd);
    12051206/* FIXME:we should only recalculate, not redraw */
    1206                                         retval=(INT)infoPtr->firstVisible;
    1207                                         break;
    1208         case TVGN_DROPHILITE:
    1209                                         retval=(INT)infoPtr->dropItem;
    1210                                         break;
    1211         }
     1207                                        retval=(INT)infoPtr->firstVisible;
     1208                                        break;
     1209        case TVGN_DROPHILITE:
     1210                                        retval=(INT)infoPtr->dropItem;
     1211                                        break;
     1212        }
    12121213  if (retval) {
    1213 //              TRACE (treeview,"flags:%x, returns %u\n", flag, retval);
    1214                 return retval;
    1215   }
    1216  
     1214//              TRACE (treeview,"flags:%x, returns %u\n", flag, retval);
     1215                return retval;
     1216  }
     1217
    12171218  wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)iItem);
    12181219  returnItem = NULL;
    12191220  if (!wineItem) return FALSE;
    12201221
    1221   switch (flag) {
    1222         case TVGN_NEXT: retval=(INT)wineItem->sibling;
    1223                                         break;
    1224         case TVGN_PREVIOUS:     
    1225                                         retval=(INT)wineItem->upsibling;
    1226                                         break;
    1227         case TVGN_PARENT:
    1228                                         retval=(INT)wineItem->parent;
    1229                                         break;
    1230         case TVGN_CHILD:
    1231                                         retval=(INT)wineItem->firstChild;
    1232                                         break;
    1233         case TVGN_LASTVISIBLE: 
    1234                                         returnItem=TREEVIEW_GetLastListItem (infoPtr,wineItem);
    1235                                         break;
    1236         case TVGN_NEXTVISIBLE: 
    1237                                         returnItem=TREEVIEW_GetNextListItem (infoPtr,wineItem);
    1238                                         break;
    1239         case TVGN_PREVIOUSVISIBLE:
    1240                                         returnItem=TREEVIEW_GetPrevListItem (infoPtr, wineItem);
    1241                                         break;
    1242         default:        //      FIXME (treeview,"Unknown msg %x,item %x\n", flag,iItem);
    1243                                         break;
    1244         }
     1222  switch (flag) {
     1223        case TVGN_NEXT: retval=(INT)wineItem->sibling;
     1224                                        break;
     1225        case TVGN_PREVIOUS:
     1226                                        retval=(INT)wineItem->upsibling;
     1227                                        break;
     1228        case TVGN_PARENT:
     1229                                        retval=(INT)wineItem->parent;
     1230                                        break;
     1231        case TVGN_CHILD:
     1232                                        retval=(INT)wineItem->firstChild;
     1233                                        break;
     1234        case TVGN_LASTVISIBLE:
     1235                                        returnItem=TREEVIEW_GetLastListItem (infoPtr,wineItem);
     1236                                        break;
     1237        case TVGN_NEXTVISIBLE:
     1238                                        returnItem=TREEVIEW_GetNextListItem (infoPtr,wineItem);
     1239                                        break;
     1240        case TVGN_PREVIOUSVISIBLE:
     1241                                        returnItem=TREEVIEW_GetPrevListItem (infoPtr, wineItem);
     1242                                        break;
     1243        default:        //      FIXME (treeview,"Unknown msg %x,item %x\n", flag,iItem);
     1244                                        break;
     1245        }
    12451246
    12461247  if (returnItem) {
    1247 //                TRACE (treeview,"flags:%x, item %d;returns %d\n", flag, iItem,
    1248 //                                                      (INT)returnItem->hItem);
    1249                   return (INT)returnItem->hItem;
     1248//                TRACE (treeview,"flags:%x, item %d;returns %d\n", flag, iItem,
     1249//                                                      (INT)returnItem->hItem);
     1250                  return (INT)returnItem->hItem;
    12501251  }
    12511252
     
    12651266
    12661267/***************************************************************************
    1267  * This method does the chaining of the insertion of a treeview item 
     1268 * This method does the chaining of the insertion of a treeview item
    12681269 * before an item.
    12691270 */
    12701271static void TREEVIEW_InsertBefore(
    12711272    TREEVIEW_INFO *infoPtr,
    1272     TREEVIEW_ITEM *newItem, 
     1273    TREEVIEW_ITEM *newItem,
    12731274    TREEVIEW_ITEM *sibling,
    12741275    TREEVIEW_ITEM *parent)
     
    12851286
    12861287  if (sibling != NULL) /* Insert before this sibling for this parent */
    1287   { 
     1288  {
    12881289    /* Store the new item sibling up sibling and sibling tem handle */
    12891290    siblingHandle   = sibling->hItem;
     
    12921293    if ( (INT)sibling->upsibling != 0 )
    12931294      upSibling = &infoPtr->items[(INT)sibling->upsibling];
    1294  
     1295
    12951296    /* Adjust the sibling pointer */
    12961297    sibling->upsibling = newItem->hItem;
    1297    
     1298
    12981299    /* Adjust the new item pointers */
    12991300    newItem->upsibling = upSiblingHandle;
    13001301    newItem->sibling   = siblingHandle;
    1301    
     1302
    13021303    /* Adjust the up sibling pointer */
    1303     if ( upSibling != NULL )       
     1304    if ( upSibling != NULL )
    13041305      upSibling->sibling = newItem->hItem;
    13051306    else
     
    13121313
    13131314/***************************************************************************
    1314  * This method does the chaining of the insertion of a treeview item 
     1315 * This method does the chaining of the insertion of a treeview item
    13151316 * after an item.
    13161317 */
    13171318static void TREEVIEW_InsertAfter(
    13181319    TREEVIEW_INFO *infoPtr,
    1319     TREEVIEW_ITEM *newItem, 
     1320    TREEVIEW_ITEM *newItem,
    13201321    TREEVIEW_ITEM *upSibling,
    13211322    TREEVIEW_ITEM *parent)
     
    13321333
    13331334  if (upSibling != NULL) /* Insert after this upsibling for this parent */
    1334   { 
     1335  {
    13351336    /* Store the new item up sibling and sibling item handle */
    13361337    upSiblingHandle = upSibling->hItem;
     
    13391340    if ( (INT)upSibling->sibling != 0 )
    13401341      sibling = &infoPtr->items[(INT)upSibling->sibling];
    1341  
     1342
    13421343    /* Adjust the up sibling pointer */
    13431344    upSibling->sibling = newItem->hItem;
    1344    
     1345
    13451346    /* Adjust the new item pointers */
    13461347    newItem->upsibling = upSiblingHandle;
    13471348    newItem->sibling   = siblingHandle;
    1348    
     1349
    13491350    /* Adjust the sibling pointer */
    1350     if ( sibling != NULL )       
    1351       sibling->upsibling = newItem->hItem; 
     1351    if ( sibling != NULL )
     1352      sibling->upsibling = newItem->hItem;
    13521353    /*
    1353     else 
    1354       newItem is the last of the level, nothing else to do 
     1354    else
     1355      newItem is the last of the level, nothing else to do
    13551356    */
    13561357  }
     
    13621363 * Forward the DPA local callback to the treeview owner callback
    13631364 */
    1364 static INT WINAPI TREEVIEW_CallBackCompare( 
    1365   LPVOID first, 
    1366   LPVOID second, 
     1365static INT WINAPI TREEVIEW_CallBackCompare(
     1366  LPVOID first,
     1367  LPVOID second,
    13671368  LPARAM tvInfoPtr)
    13681369{
     
    13801381 */
    13811382LRESULT WINAPI TREEVIEW_SortChildrenCB(
    1382   HWND   hwnd, 
    1383   WPARAM wParam, 
     1383  HWND   hwnd,
     1384  WPARAM wParam,
    13841385  LPARAM lParam)
    13851386{
     
    13901391  infoPtr->pCallBackSort = (LPTVSORTCB)lParam;
    13911392
    1392   /* Obtain the parent node to sort */ 
     1393  /* Obtain the parent node to sort */
    13931394  sortMe = &infoPtr->items[ (INT)infoPtr->pCallBackSort->hParent ];
    13941395
    13951396  /* Make sure there is something to sort */
    1396   if ( sortMe->cChildren > 1 ) 
     1397  if ( sortMe->cChildren > 1 )
    13971398  {
    13981399    /* pointer organization */
     
    14081409
    14091410    /* Build the list of item to sort */
    1410     do 
     1411    do
    14111412    {
    14121413      DPA_InsertPtr(
    14131414        sortList,              /* the list */
    14141415        sortMe->cChildren+1,   /* force the insertion to be an append */
    1415         itemPtr);              /* the ptr to store */   
     1416        itemPtr);              /* the ptr to store */
    14161417
    14171418      /* Get the next sibling */
     
    14221423    /* let DPA perform the sort activity */
    14231424    DPA_Sort(
    1424       sortList,                  /* what  */ 
     1425      sortList,                  /* what  */
    14251426      TREEVIEW_CallBackCompare,  /* how   */
    14261427      hwnd);                     /* owner */
    14271428
    1428     /* 
    1429      * Reorganized TREEVIEW_ITEM structures. 
     1429    /*
     1430     * Reorganized TREEVIEW_ITEM structures.
    14301431     * Note that we know we have at least two elements.
    14311432     */
    14321433
    14331434    /* Get the first item and get ready to start... */
    1434     item = DPA_GetPtr(sortList, count++);   
     1435    item = DPA_GetPtr(sortList, count++);
    14351436    while ( (nextItem = DPA_GetPtr(sortList, count++)) != NULL )
    14361437    {
     
    14501451
    14511452      /* get ready for the next one */
    1452       prevItem = item; 
     1453      prevItem = item;
    14531454      item     = nextItem;
    14541455    }
    14551456
    14561457    /* the last item is pointed to by item and never has a sibling */
    1457     ((TREEVIEW_ITEM*)item)->sibling = NULL; 
     1458    ((TREEVIEW_ITEM*)item)->sibling = NULL;
    14581459
    14591460    DPA_Destroy(sortList);
     
    14651466
    14661467
    1467 /* the method used below isn't the most memory-friendly, but it avoids 
    1468    a lot of memory reallocations */ 
     1468/* the method used below isn't the most memory-friendly, but it avoids
     1469   a lot of memory reallocations */
    14691470
    14701471/* BTW: we waste handle 0; 0 is not an allowed handle. */
     
    14761477  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    14771478  TVINSERTSTRUCTA  *ptdi;
    1478   TVITEMEXA     *tvItem;
     1479  TVITEMEXA     *tvItem;
    14791480  TREEVIEW_ITEM *wineItem, *parentItem, *prevsib, *sibItem;
    1480   INT           iItem,listItems,i,len;
    1481  
     1481  INT           iItem,listItems,i,len;
     1482
    14821483  /* Item to insert */
    14831484  ptdi = (LPTVINSERTSTRUCTA) lParam;
    14841485
    1485         /* check if memory is available */
     1486        /* check if memory is available */
    14861487
    14871488  if (infoPtr->uNumPtrsAlloced==0) {
     
    14891490        infoPtr->freeList= COMCTL32_Alloc ((1+(TVITEM_ALLOC>>5)) * sizeof (INT));
    14901491        infoPtr->uNumPtrsAlloced=TVITEM_ALLOC;
    1491         infoPtr->TopRootItem=(HTREEITEM)1;
     1492        infoPtr->TopRootItem=(HTREEITEM)1;
    14921493   }
    14931494
    1494   /* 
    1495    * Reallocate contiguous space for items 
     1495  /*
     1496   * Reallocate contiguous space for items
    14961497   */
    14971498  if (infoPtr->uNumItems == (infoPtr->uNumPtrsAlloced-1) ) {
    1498         TREEVIEW_ITEM *oldItems = infoPtr->items;
    1499         INT *oldfreeList = infoPtr->freeList;
    1500 
    1501         infoPtr->uNumPtrsAlloced*=2;
     1499        TREEVIEW_ITEM *oldItems = infoPtr->items;
     1500        INT *oldfreeList = infoPtr->freeList;
     1501
     1502        infoPtr->uNumPtrsAlloced*=2;
    15021503    infoPtr->items = COMCTL32_Alloc (infoPtr->uNumPtrsAlloced*sizeof (TREEVIEW_ITEM));
    15031504    infoPtr->freeList= COMCTL32_Alloc ((1+(infoPtr->uNumPtrsAlloced>>5))*sizeof (INT));
     
    15081509                    infoPtr->uNumPtrsAlloced>>6 * sizeof(INT));
    15091510
    1510     COMCTL32_Free (oldItems); 
    1511     COMCTL32_Free (oldfreeList); 
     1511    COMCTL32_Free (oldItems);
     1512    COMCTL32_Free (oldfreeList);
    15121513   }
    15131514
    1514   /* 
     1515  /*
    15151516   * Reset infoPtr structure with new stat according to current TV picture
    15161517   */
    15171518  iItem=0;
    15181519  infoPtr->uNumItems++;
    1519   if ((INT)infoPtr->uMaxHandle==(infoPtr->uNumItems-1))  { 
    1520         iItem=infoPtr->uNumItems;
    1521         infoPtr->uMaxHandle = (HTREEITEM)((INT)infoPtr->uMaxHandle + 1);
    1522   } else {                                      /* check freelist */
    1523         for (i=0; i<infoPtr->uNumPtrsAlloced>>5; i++) {
    1524                 if (infoPtr->freeList[i]) {
     1520  if ((INT)infoPtr->uMaxHandle==(infoPtr->uNumItems-1))  {
     1521        iItem=infoPtr->uNumItems;
     1522        infoPtr->uMaxHandle = (HTREEITEM)((INT)infoPtr->uMaxHandle + 1);
     1523  } else {                                      /* check freelist */
     1524        for (i=0; i<infoPtr->uNumPtrsAlloced>>5; i++) {
     1525                if (infoPtr->freeList[i]) {
    15251526// WHAT IS FFS? NOT IN VAC++ C LIBRARY!!!
    1526 //                      iItem=ffs (infoPtr->freeList[i])-1;
     1527//                      iItem=ffs (infoPtr->freeList[i])-1;
    15271528//
    1528                         tv_clear_bit(iItem,&infoPtr->freeList[i]);
    1529                         iItem+=i<<5;
    1530                         break;
    1531                 }
    1532     } 
    1533   }
    1534 
    1535 //  if (TRACE_ON(treeview)) { 
    1536 //    for (i=0; i<infoPtr->uNumPtrsAlloced>>5; i++) 
    1537 //          TRACE (treeview,"%8x\n",infoPtr->freeList[i]);
     1529                        tv_clear_bit(iItem,&infoPtr->freeList[i]);
     1530                        iItem+=i<<5;
     1531                        break;
     1532                }
     1533    }
     1534  }
     1535
     1536//  if (TRACE_ON(treeview)) {
     1537//    for (i=0; i<infoPtr->uNumPtrsAlloced>>5; i++)
     1538//          TRACE (treeview,"%8x\n",infoPtr->freeList[i]);
    15381539//  }
    15391540
    15401541//  if (!iItem) ERR (treeview, "Argh -- can't find free item.\n");
    15411542
    1542   /* 
    1543    * Find the parent item of the new item 
    1544    */ 
     1543  /*
     1544   * Find the parent item of the new item
     1545   */
    15451546  tvItem= & ptdi->DUMMYUNIONNAME.itemex;
    15461547  wineItem=& infoPtr->items[iItem];
     
    15481549  if ((ptdi->hParent==TVI_ROOT) || (ptdi->hParent==0)) {
    15491550    parentItem       = NULL;
    1550     wineItem->parent = 0; 
     1551    wineItem->parent = 0;
    15511552    sibItem          = &infoPtr->items [(INT)infoPtr->TopRootItem];
    15521553    listItems        = infoPtr->uNumItems;
    15531554  }
    15541555  else  {
    1555         parentItem = &infoPtr->items[(INT)ptdi->hParent];
    1556  
     1556        parentItem = &infoPtr->items[(INT)ptdi->hParent];
     1557
    15571558    /* Do the insertion here it if it's the only item of this parent */
    1558         if (!parentItem->firstChild)
    1559                 parentItem->firstChild=(HTREEITEM)iItem;
    1560  
    1561         wineItem->parent = ptdi->hParent;
    1562         sibItem          = &infoPtr->items [(INT)parentItem->firstChild];
    1563         parentItem->cChildren++;
    1564         listItems        = parentItem->cChildren;
    1565   }
    1566 
    1567  
    1568   /* NOTE: I am moving some setup of the wineItem object that was initialy 
    1569    *       done at the end of the function since some of the values are 
    1570    *       required by the Callback sorting 
     1559        if (!parentItem->firstChild)
     1560                parentItem->firstChild=(HTREEITEM)iItem;
     1561
     1562        wineItem->parent = ptdi->hParent;
     1563        sibItem          = &infoPtr->items [(INT)parentItem->firstChild];
     1564        parentItem->cChildren++;
     1565        listItems        = parentItem->cChildren;
     1566  }
     1567
     1568
     1569  /* NOTE: I am moving some setup of the wineItem object that was initialy
     1570   *       done at the end of the function since some of the values are
     1571   *       required by the Callback sorting
    15711572   */
    15721573
    1573   if (tvItem->mask & TVIF_TEXT) 
     1574  if (tvItem->mask & TVIF_TEXT)
    15741575  {
    15751576    /*
     
    15771578     * when the insertion are ordered
    15781579     */
    1579     if (tvItem->pszText!=LPSTR_TEXTCALLBACKA) 
     1580    if (tvItem->pszText!=LPSTR_TEXTCALLBACKA)
    15801581    {
    1581 //      TRACE (treeview,"(%p,%s)\n", &tvItem->pszText, tvItem->pszText); 
     1582//      TRACE (treeview,"(%p,%s)\n", &tvItem->pszText, tvItem->pszText);
    15821583      len = lstrlenA (tvItem->pszText)+1;
    15831584      wineItem->pszText= COMCTL32_Alloc (len+1);
     
    15851586      wineItem->cchTextMax=len;
    15861587    }
    1587     else 
     1588    else
    15881589    {
    15891590//      TRACE (treeview,"LPSTR_TEXTCALLBACK\n");
     
    15931594  }
    15941595
    1595   if (tvItem->mask & TVIF_PARAM) 
     1596  if (tvItem->mask & TVIF_PARAM)
    15961597    wineItem->lParam=tvItem->lParam;
    15971598
    15981599
    1599   wineItem->upsibling=0;  /* needed in case we're the first item in a list */ 
    1600   wineItem->sibling=0;     
     1600  wineItem->upsibling=0;  /* needed in case we're the first item in a list */
     1601  wineItem->sibling=0;
    16011602  wineItem->firstChild=0;
    16021603  wineItem->hItem=(HTREEITEM)iItem;
     
    16061607
    16071608     switch ((DWORD) ptdi->hInsertAfter) {
    1608                 case (DWORD) TVI_FIRST:
    1609                         if (wineItem->parent) {
    1610                                 wineItem->sibling=parentItem->firstChild;
    1611                                 parentItem->firstChild=(HTREEITEM)iItem;
    1612                         } else {
    1613                                 wineItem->sibling=infoPtr->TopRootItem;
    1614                                 infoPtr->TopRootItem=(HTREEITEM)iItem;
    1615                         }
    1616                         sibItem->upsibling=(HTREEITEM)iItem;
    1617                         break;
    1618 
    1619                 case (DWORD) TVI_SORT: 
    1620           if (sibItem==wineItem)
    1621         /* 
    1622          * This item is the first child of the level and it 
    1623          * has already been inserted 
    1624          */               
    1625         break; 
     1609                case (DWORD) TVI_FIRST:
     1610                        if (wineItem->parent) {
     1611                                wineItem->sibling=parentItem->firstChild;
     1612                                parentItem->firstChild=(HTREEITEM)iItem;
     1613                        } else {
     1614                                wineItem->sibling=infoPtr->TopRootItem;
     1615                                infoPtr->TopRootItem=(HTREEITEM)iItem;
     1616                        }
     1617                        sibItem->upsibling=(HTREEITEM)iItem;
     1618                        break;
     1619
     1620                case (DWORD) TVI_SORT:
     1621          if (sibItem==wineItem)
     1622        /*
     1623         * This item is the first child of the level and it
     1624         * has already been inserted
     1625         */
     1626        break;
    16261627      else
    16271628      {
    1628         TREEVIEW_ITEM *aChild        = 
     1629        TREEVIEW_ITEM *aChild        =
    16291630          &infoPtr->items[(INT)parentItem->firstChild];
    1630  
     1631
    16311632        TREEVIEW_ITEM *previousChild = NULL;
    16321633        BOOL bItemInserted           = FALSE;
    1633  
     1634
    16341635        /* Iterate the parent children to see where we fit in */
    16351636        while ( aChild != NULL )
     
    16481649                        ? NULL               /* if there is no more sibling */
    16491650                        : &infoPtr->items[(INT)aChild->sibling];
    1650  
     1651
    16511652            /* Look at the next item */
    16521653            continue;
     
    16541655          else if ( comp == 0 )
    16551656          {
    1656             /* 
    1657              * An item with this name is already existing, therefore, 
    1658              * we add after the one we found 
     1657            /*
     1658             * An item with this name is already existing, therefore,
     1659             * we add after the one we found
    16591660             */
    16601661            TREEVIEW_InsertAfter(infoPtr, wineItem, aChild, parentItem);
     
    16631664          }
    16641665        }
    1665      
    1666         /* 
     1666
     1667        /*
    16671668         * we reach the end of the child list and the item as not
    16681669         * yet been inserted, therefore, insert it after the last child.
     
    16701671        if ( (! bItemInserted ) && (aChild == NULL) )
    16711672          TREEVIEW_InsertAfter(infoPtr, wineItem, previousChild, parentItem);
    1672  
     1673
    16731674        break;
    16741675      }
    16751676
    16761677
    1677                 case (DWORD) TVI_LAST: 
    1678                         if (sibItem==wineItem) break;
    1679                         while (sibItem->sibling) {
    1680                                 prevsib=sibItem;
    1681                                 sibItem=&infoPtr->items [(INT)sibItem->sibling];
    1682                         }
    1683                         sibItem->sibling=(HTREEITEM)iItem;
    1684                         wineItem->upsibling=sibItem->hItem;
    1685                         break;
    1686                 default:
    1687                         while ((sibItem->sibling) && (sibItem->hItem!=ptdi->hInsertAfter))
    1688                                 {
    1689                                 prevsib=sibItem;
     1678                case (DWORD) TVI_LAST:
     1679                        if (sibItem==wineItem) break;
     1680                        while (sibItem->sibling) {
     1681                                prevsib=sibItem;
     1682                                sibItem=&infoPtr->items [(INT)sibItem->sibling];
     1683                        }
     1684                        sibItem->sibling=(HTREEITEM)iItem;
     1685                        wineItem->upsibling=sibItem->hItem;
     1686                        break;
     1687                default:
     1688                        while ((sibItem->sibling) && (sibItem->hItem!=ptdi->hInsertAfter))
     1689                                {
     1690                                prevsib=sibItem;
    16901691                sibItem=&infoPtr->items [(INT)sibItem->sibling];
    16911692              }
    1692                         if (sibItem->hItem!=ptdi->hInsertAfter) {
    1693 //                      ERR (treeview, "tried to insert item after nonexisting handle.\n");
    1694                         break;
    1695                         }
    1696                         prevsib=sibItem;
    1697                         if (sibItem->sibling) {
    1698                 sibItem=&infoPtr->items [(INT)sibItem->sibling];
    1699                                 sibItem->upsibling=(HTREEITEM)iItem;
    1700                                 wineItem->sibling=sibItem->hItem;
    1701                         }
    1702                         prevsib->sibling=(HTREEITEM)iItem;
    1703                         wineItem->upsibling=prevsib->hItem;
    1704                         break;
    1705         }
    1706    }   
     1693                        if (sibItem->hItem!=ptdi->hInsertAfter) {
     1694//                      ERR (treeview, "tried to insert item after nonexisting handle.\n");
     1695                        break;
     1696                        }
     1697                        prevsib=sibItem;
     1698                        if (sibItem->sibling) {
     1699                sibItem=&infoPtr->items [(INT)sibItem->sibling];
     1700                                sibItem->upsibling=(HTREEITEM)iItem;
     1701                                wineItem->sibling=sibItem->hItem;
     1702                        }
     1703                        prevsib->sibling=(HTREEITEM)iItem;
     1704                        wineItem->upsibling=prevsib->hItem;
     1705                        break;
     1706        }
     1707   }
    17071708
    17081709
    17091710/* Fill in info structure */
    17101711
    1711 //   TRACE (treeview,"new item %d; parent %d, mask %x\n", iItem, 
    1712 //                      (INT)wineItem->parent,tvItem->mask);
     1712//   TRACE (treeview,"new item %d; parent %d, mask %x\n", iItem,
     1713//                      (INT)wineItem->parent,tvItem->mask);
    17131714
    17141715   wineItem->mask=tvItem->mask;
    1715    wineItem->iIntegral=1; 
     1716   wineItem->iIntegral=1;
    17161717
    17171718   if (tvItem->mask & TVIF_CHILDREN) {
    1718         wineItem->cChildren=tvItem->cChildren;
    1719 //       if (tvItem->cChildren==I_CHILDRENCALLBACK)
    1720 //                      FIXME (treeview," I_CHILDRENCALLBACK not supported\n");
    1721         }
     1719        wineItem->cChildren=tvItem->cChildren;
     1720//       if (tvItem->cChildren==I_CHILDRENCALLBACK)
     1721//                      FIXME (treeview," I_CHILDRENCALLBACK not supported\n");
     1722        }
    17221723
    17231724  wineItem->expandBox.left   = 0; /* Initialize the expandBox */
     
    17261727  wineItem->expandBox.bottom = 0;
    17271728
    1728    if (tvItem->mask & TVIF_IMAGE) 
    1729         wineItem->iImage=tvItem->iImage;
    1730 
    1731                 /* If the application sets TVIF_INTEGRAL without
    1732                         supplying a TVITEMEX structure, it's toast */
    1733 
    1734    if (tvItem->mask & TVIF_INTEGRAL) 
    1735                 wineItem->iIntegral=tvItem->iIntegral;   
    1736 
    1737    if (tvItem->mask & TVIF_SELECTEDIMAGE) 
    1738         wineItem->iSelectedImage=tvItem->iSelectedImage;
     1729   if (tvItem->mask & TVIF_IMAGE)
     1730        wineItem->iImage=tvItem->iImage;
     1731
     1732                /* If the application sets TVIF_INTEGRAL without
     1733                        supplying a TVITEMEX structure, it's toast */
     1734
     1735   if (tvItem->mask & TVIF_INTEGRAL)
     1736                wineItem->iIntegral=tvItem->iIntegral;
     1737
     1738   if (tvItem->mask & TVIF_SELECTEDIMAGE)
     1739        wineItem->iSelectedImage=tvItem->iSelectedImage;
    17391740
    17401741   if (tvItem->mask & TVIF_STATE) {
    1741 //     TRACE(treeview, "Changing item state from %d to %d\n", 
    1742 //       wineItem->state, 
     1742//     TRACE(treeview, "Changing item state from %d to %d\n",
     1743//       wineItem->state,
    17431744//       tvItem->state);
    1744         wineItem->state=tvItem->state;
    1745         wineItem->stateMask=tvItem->stateMask;
     1745        wineItem->state=tvItem->state;
     1746        wineItem->stateMask=tvItem->stateMask;
    17461747   }
    17471748
     
    17671768
    17681769  if (lParam == (INT)TVI_ROOT) {
    1769         TREEVIEW_RemoveTree (hwnd);
     1770        TREEVIEW_RemoveTree (hwnd);
    17701771  } else {
    1771         iItem= (INT) lParam;
    1772         wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)iItem);
    1773         if (!wineItem) return FALSE;
     1772        iItem= (INT) lParam;
     1773        wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)iItem);
     1774        if (!wineItem) return FALSE;
    17741775//    TRACE (treeview,"%s\n",wineItem->pszText);
    1775         TREEVIEW_RemoveItem (hwnd, wineItem);
     1776        TREEVIEW_RemoveItem (hwnd, wineItem);
    17761777  }
    17771778
     
    17971798  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    17981799  INT newIndent;
    1799    
     1800
    18001801//  TRACE (treeview,"\n");
    18011802  newIndent=(INT) wParam;
    18021803  if (newIndent < MINIMUM_INDENT) newIndent=MINIMUM_INDENT;
    18031804  infoPtr->uIndent=newIndent;
    1804  
     1805
    18051806  return 0;
    18061807}
     
    18421843
    18431844LRESULT CALLBACK
    1844 TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, 
    1845                                                         LPARAM lParam)
    1846 {
    1847   switch (uMsg) 
     1845TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam,
     1846                                                        LPARAM lParam)
     1847{
     1848  switch (uMsg)
    18481849  {
    1849     case WM_ERASEBKGND: 
     1850    case WM_ERASEBKGND:
    18501851    {
    18511852      RECT rc;
     
    18791880{
    18801881//  TRACE (treeview, "%x %ld\n",wParam, lParam);
    1881  
    1882   switch (HIWORD(wParam)) 
     1882
     1883  switch (HIWORD(wParam))
    18831884  {
    1884                 case EN_UPDATE:
     1885                case EN_UPDATE:
    18851886    {
    1886       /* 
    1887        * Adjust the edit window size 
     1887      /*
     1888       * Adjust the edit window size
    18881889       */
    18891890      TREEVIEW_INFO *infoPtr  = TREEVIEW_GetInfoPtr(hwnd);
     
    18961897      {
    18971898        LONG newWidth = (iLength * tm.tmAveCharWidth) + 15;
    1898            
    1899                 SetWindowPos (
     1899
     1900                SetWindowPos (
    19001901          infoPtr->hwndEdit,
    1901           HWND_TOP, 
    1902           editItem->text.left - 2, 
     1902          HWND_TOP,
     1903          editItem->text.left - 2,
    19031904          editItem->text.top  - 1,
    19041905          newWidth,
     
    19121913
    19131914    case EN_KILLFOCUS:
    1914 /*      TREEVIEW_EndEditLabelNow(hwnd, (WPARAM)FALSE, 0); 
     1915/*      TREEVIEW_EndEditLabelNow(hwnd, (WPARAM)FALSE, 0);
    19151916*/
    19161917      break;
     
    19291930  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    19301931
    1931   if (infoPtr->bAutoSize) 
     1932  if (infoPtr->bAutoSize)
    19321933  {
    19331934    infoPtr->bAutoSize = FALSE;
     
    19361937  infoPtr->bAutoSize = TRUE;
    19371938
    1938   if (wParam == SIZE_RESTORED) 
     1939  if (wParam == SIZE_RESTORED)
    19391940  {
    19401941    infoPtr->uTotalWidth  = LOWORD (lParam);
    1941         infoPtr->uTotalHeight = HIWORD (lParam);
     1942        infoPtr->uTotalHeight = HIWORD (lParam);
    19421943  } else {
    1943 //      FIXME (treeview,"WM_SIZE flag %x %lx not handled\n", wParam, lParam);
     1944//      FIXME (treeview,"WM_SIZE flag %x %lx not handled\n", wParam, lParam);
    19441945  }
    19451946
     
    19561957
    19571958//  TRACE (treeview,"(%x %lx)\n",wParam,lParam);
    1958  
    1959   if (wParam & (GWL_STYLE)) 
    1960         SetWindowLongA( hwnd, GWL_STYLE, lpss->styleNew);
    1961   if (wParam & (GWL_EXSTYLE)) 
    1962         SetWindowLongA( hwnd, GWL_STYLE, lpss->styleNew);
     1959
     1960  if (wParam & (GWL_STYLE))
     1961        SetWindowLongA( hwnd, GWL_STYLE, lpss->styleNew);
     1962  if (wParam & (GWL_EXSTYLE))
     1963        SetWindowLongA( hwnd, GWL_STYLE, lpss->styleNew);
    19631964
    19641965  return 0;
     
    19691970{
    19701971    TREEVIEW_INFO *infoPtr;
    1971         LOGFONTA logFont;
     1972        LOGFONTA logFont;
    19721973    TEXTMETRICA tm;
    1973         HDC hdc;
    1974  
     1974        HDC hdc;
     1975
    19751976//    TRACE (treeview,"wnd %x\n",hwnd);
    19761977      /* allocate memory for info structure */
     
    19801981
    19811982    if (infoPtr == NULL) {
    1982 //              ERR (treeview, "could not allocate info memory!\n");
    1983                 return 0;
     1983//              ERR (treeview, "could not allocate info memory!\n");
     1984                return 0;
    19841985    }
    19851986
    19861987    if ((TREEVIEW_INFO*) GetWindowLongA( hwnd, 0) != infoPtr) {
    1987 //              ERR (treeview, "pointer assignment error!\n");
    1988                 return 0;
     1988//              ERR (treeview, "pointer assignment error!\n");
     1989                return 0;
    19891990    }
    19901991
    1991         hdc=GetDC (hwnd);
     1992        hdc=GetDC (hwnd);
    19921993
    19931994    /* set default settings */
     
    20012002    infoPtr->himlNormal = NULL;
    20022003    infoPtr->himlState = NULL;
    2003         infoPtr->uItemHeight = -1;
     2004        infoPtr->uItemHeight = -1;
    20042005    GetTextMetricsA (hdc, &tm);
    20052006    infoPtr->hFont = GetStockObject (DEFAULT_GUI_FONT);
    2006         GetObjectA (infoPtr->hFont, sizeof (LOGFONTA), &logFont);
    2007         logFont.lfWeight=FW_BOLD;
     2007        GetObjectA (infoPtr->hFont, sizeof (LOGFONTA), &logFont);
     2008        logFont.lfWeight=FW_BOLD;
    20082009    infoPtr->hBoldFont = CreateFontIndirectA (&logFont);
    2009    
     2010
    20102011    infoPtr->items = NULL;
    20112012    infoPtr->selectedItem=0;
    2012     infoPtr->clrText=-1;        /* use system color */
     2013    infoPtr->clrText=-1;        /* use system color */
    20132014    infoPtr->dropItem=0;
    20142015    infoPtr->pCallBackSort=NULL;
     
    20192020*/
    20202021
    2021         infoPtr->hwndToolTip=0;
     2022        infoPtr->hwndToolTip=0;
    20222023    if (!( GetWindowLongA( hwnd, GWL_STYLE) & TVS_NOTOOLTIPS)) {   /* Create tooltip control */
    2023                 TTTOOLINFOA ti;
    2024 
    2025                 infoPtr->hwndToolTip = 
    2026                         CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
     2024                TTTOOLINFOA ti;
     2025
     2026                infoPtr->hwndToolTip =
     2027                        CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
    20272028                   CW_USEDEFAULT, CW_USEDEFAULT,
    20282029                   CW_USEDEFAULT, CW_USEDEFAULT,
     
    20422043        }
    20432044
    2044                 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     2045                ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    20452046        ti.cbSize   = sizeof(TTTOOLINFOA);
    20462047        ti.uFlags   = TTF_IDISHWND | TTF_TRACK | TTF_TRANSPARENT ;
     
    20532054    }
    20542055
    2055         infoPtr->hwndEdit = CreateWindowExA (
    2056                           WS_EX_LEFT, 
     2056        infoPtr->hwndEdit = CreateWindowExA (
     2057                          WS_EX_LEFT,
    20572058                          "EDIT",
    20582059                          0,
    2059                           WS_CHILD | WS_BORDER | ES_AUTOHSCROLL | 
     2060                          WS_CHILD | WS_BORDER | ES_AUTOHSCROLL |
    20602061                          ES_WANTRETURN | ES_LEFT,
    20612062                          0, 0, 0, 0,
    2062                           hwnd, 
     2063                          hwnd,
    20632064                          0,0,0); /* FIXME: (HMENU)IDTVEDIT,pcs->hInstance,0);*/
    20642065
    20652066  SendMessageA ( infoPtr->hwndEdit, WM_SETFONT, infoPtr->hFont, FALSE);
    2066         infoPtr->wpEditOrig = (WNDPROC)SetWindowLongA (
     2067        infoPtr->wpEditOrig = (WNDPROC)SetWindowLongA (
    20672068                                    infoPtr->hwndEdit,
    2068                                     GWL_WNDPROC, 
    2069                                                                 (LONG) TREEVIEW_Edit_SubclassProc);
     2069                                    GWL_WNDPROC,
     2070                                                                (LONG) TREEVIEW_Edit_SubclassProc);
    20702071
    20712072  ReleaseDC (hwnd, hdc);
     
    20752076
    20762077
    2077 static LRESULT 
    2078 TREEVIEW_Destroy (HWND hwnd) 
     2078static LRESULT
     2079TREEVIEW_Destroy (HWND hwnd)
    20792080{
    20802081   TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    2081      
     2082
    20822083//   TRACE (treeview,"\n");
    20832084   TREEVIEW_RemoveTree (hwnd);
    2084    if (infoPtr->Timer & TV_REFRESH_TIMER_SET) 
     2085   if (infoPtr->Timer & TV_REFRESH_TIMER_SET)
    20852086        KillTimer (hwnd, TV_REFRESH_TIMER);
    2086    if (infoPtr->hwndToolTip) 
    2087                 DestroyWindow (infoPtr->hwndToolTip);
     2087   if (infoPtr->hwndToolTip)
     2088                DestroyWindow (infoPtr->hwndToolTip);
    20882089
    20892090   COMCTL32_Free (infoPtr);
     
    21042105        EndPaint (hwnd, &ps);
    21052106//    TRACE (treeview,"done\n");
    2106      
     2107
    21072108    return DefWindowProcA (hwnd, WM_PAINT, wParam, lParam);
    21082109}
     
    21422143
    21432144
    2144  
     2145
    21452146/* Notifications */
    21462147
    2147  
     2148
    21482149
    21492150
     
    21662167
    21672168static BOOL
    2168 TREEVIEW_SendTreeviewNotify (HWND hwnd, UINT code, UINT action, 
    2169                         HTREEITEM oldItem, HTREEITEM newItem)
     2169TREEVIEW_SendTreeviewNotify (HWND hwnd, UINT code, UINT action,
     2170                        HTREEITEM oldItem, HTREEITEM newItem)
    21702171
    21712172{
     
    21752176
    21762177//  TRACE (treeview,"code:%x action:%x olditem:%x newitem:%x\n",
    2177 //                code,action,(INT)oldItem,(INT)newItem);
     2178//                code,action,(INT)oldItem,(INT)newItem);
    21782179  nmhdr.hdr.hwndFrom = hwnd;
    21792180  nmhdr.hdr.idFrom =  GetWindowLongA( hwnd, GWL_ID);
     
    21812182  nmhdr.action = action;
    21822183  if (oldItem) {
    2183         wineItem=& infoPtr->items[(INT)oldItem];
    2184         nmhdr.itemOld.mask              = wineItem->mask;
    2185         nmhdr.itemOld.hItem             = wineItem->hItem;
    2186         nmhdr.itemOld.state             = wineItem->state;
    2187         nmhdr.itemOld.stateMask = wineItem->stateMask;
    2188         nmhdr.itemOld.iImage    = wineItem->iImage;
    2189         nmhdr.itemOld.pszText   = wineItem->pszText;
    2190         nmhdr.itemOld.cchTextMax= wineItem->cchTextMax;
    2191         nmhdr.itemOld.iImage    = wineItem->iImage;
    2192         nmhdr.itemOld.iSelectedImage    = wineItem->iSelectedImage;
    2193         nmhdr.itemOld.cChildren = wineItem->cChildren;
    2194         nmhdr.itemOld.lParam    = wineItem->lParam;
     2184        wineItem=& infoPtr->items[(INT)oldItem];
     2185        nmhdr.itemOld.mask              = wineItem->mask;
     2186        nmhdr.itemOld.hItem             = wineItem->hItem;
     2187        nmhdr.itemOld.state             = wineItem->state;
     2188        nmhdr.itemOld.stateMask = wineItem->stateMask;
     2189        nmhdr.itemOld.iImage    = wineItem->iImage;
     2190        nmhdr.itemOld.pszText   = wineItem->pszText;
     2191        nmhdr.itemOld.cchTextMax= wineItem->cchTextMax;
     2192        nmhdr.itemOld.iImage    = wineItem->iImage;
     2193        nmhdr.itemOld.iSelectedImage    = wineItem->iSelectedImage;
     2194        nmhdr.itemOld.cChildren = wineItem->cChildren;
     2195        nmhdr.itemOld.lParam    = wineItem->lParam;
    21952196  }
    21962197
    21972198  if (newItem) {
    2198         wineItem=& infoPtr->items[(INT)newItem];
    2199         nmhdr.itemNew.mask              = wineItem->mask;
    2200         nmhdr.itemNew.hItem             = wineItem->hItem;
    2201         nmhdr.itemNew.state             = wineItem->state;
    2202         nmhdr.itemNew.stateMask = wineItem->stateMask;
    2203         nmhdr.itemNew.iImage    = wineItem->iImage;
    2204         nmhdr.itemNew.pszText   = wineItem->pszText;
    2205         nmhdr.itemNew.cchTextMax= wineItem->cchTextMax;
    2206         nmhdr.itemNew.iImage    = wineItem->iImage;
    2207         nmhdr.itemNew.iSelectedImage    = wineItem->iSelectedImage;
    2208         nmhdr.itemNew.cChildren = wineItem->cChildren;
    2209         nmhdr.itemNew.lParam    = wineItem->lParam;
     2199        wineItem=& infoPtr->items[(INT)newItem];
     2200        nmhdr.itemNew.mask              = wineItem->mask;
     2201        nmhdr.itemNew.hItem             = wineItem->hItem;
     2202        nmhdr.itemNew.state             = wineItem->state;
     2203        nmhdr.itemNew.stateMask = wineItem->stateMask;
     2204        nmhdr.itemNew.iImage    = wineItem->iImage;
     2205        nmhdr.itemNew.pszText   = wineItem->pszText;
     2206        nmhdr.itemNew.cchTextMax= wineItem->cchTextMax;
     2207        nmhdr.itemNew.iImage    = wineItem->iImage;
     2208        nmhdr.itemNew.iSelectedImage    = wineItem->iSelectedImage;
     2209        nmhdr.itemNew.cChildren = wineItem->cChildren;
     2210        nmhdr.itemNew.lParam    = wineItem->lParam;
    22102211  }
    22112212
     
    22192220
    22202221static BOOL
    2221 TREEVIEW_SendTreeviewDnDNotify (HWND hwnd, UINT code, HTREEITEM dragItem, 
    2222                                                                 POINT pt)
     2222TREEVIEW_SendTreeviewDnDNotify (HWND hwnd, UINT code, HTREEITEM dragItem,
     2223                                                                POINT pt)
    22232224{
    22242225  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     
    22332234  nmhdr.action = 0;
    22342235  wineItem=& infoPtr->items[(INT)dragItem];
    2235   nmhdr.itemNew.mask    = wineItem->mask;
    2236   nmhdr.itemNew.hItem   = wineItem->hItem;
    2237   nmhdr.itemNew.state   = wineItem->state;
    2238   nmhdr.itemNew.lParam  = wineItem->lParam;
     2236  nmhdr.itemNew.mask    = wineItem->mask;
     2237  nmhdr.itemNew.hItem   = wineItem->hItem;
     2238  nmhdr.itemNew.state   = wineItem->state;
     2239  nmhdr.itemNew.lParam  = wineItem->lParam;
    22392240
    22402241  nmhdr.ptDrag.x = pt.x;
     
    22492250
    22502251static BOOL
    2251 TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem, 
    2252                                                                 UINT code, UINT what)
     2252TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem,
     2253                                                                UINT code, UINT what)
    22532254{
    22542255  NMTVDISPINFOA tvdi;
     
    22612262//    (INT)wineItem->state);
    22622263
    2263   tvdi.hdr.hwndFrom     = hwnd;
    2264   tvdi.hdr.idFrom       =  GetWindowLongA( hwnd, GWL_ID);
    2265   tvdi.hdr.code         = code;
    2266   tvdi.item.mask        = what;
    2267   tvdi.item.hItem       = wineItem->hItem;
    2268   tvdi.item.state       = wineItem->state;
    2269   tvdi.item.lParam      = wineItem->lParam;
     2264  tvdi.hdr.hwndFrom     = hwnd;
     2265  tvdi.hdr.idFrom       =  GetWindowLongA( hwnd, GWL_ID);
     2266  tvdi.hdr.code         = code;
     2267  tvdi.item.mask        = what;
     2268  tvdi.item.hItem       = wineItem->hItem;
     2269  tvdi.item.state       = wineItem->state;
     2270  tvdi.item.lParam      = wineItem->lParam;
    22702271  tvdi.item.pszText = COMCTL32_Alloc (128*sizeof(char));
    22712272  buf = tvdi.item.pszText;
    22722273
    22732274  retval=(BOOL)SendMessageA (
    2274                   GetParent(hwnd), 
     2275                  GetParent(hwnd),
    22752276                  WM_NOTIFY,
    2276                   (WPARAM)tvdi.hdr.idFrom, 
     2277                  (WPARAM)tvdi.hdr.idFrom,
    22772278                  (LPARAM)&tvdi);
    22782279
    22792280  if (what & TVIF_TEXT) {
    2280                 wineItem->pszText        = tvdi.item.pszText;
    2281                 if (buf==tvdi.item.pszText) {
    2282                         wineItem->cchTextMax = 128;
    2283                 } else {
    2284 //                      TRACE (treeview,"user-supplied buffer\n");
    2285                         COMCTL32_Free (buf);
    2286                         wineItem->cchTextMax = 0;
    2287                 }
    2288         }
    2289   if (what & TVIF_SELECTEDIMAGE) 
    2290                 wineItem->iSelectedImage = tvdi.item.iSelectedImage;
    2291   if (what & TVIF_IMAGE) 
    2292                 wineItem->iImage         = tvdi.item.iImage;
    2293   if (what & TVIF_CHILDREN) 
    2294                 wineItem->cChildren      = tvdi.item.cChildren;
     2281                wineItem->pszText        = tvdi.item.pszText;
     2282                if (buf==tvdi.item.pszText) {
     2283                        wineItem->cchTextMax = 128;
     2284                } else {
     2285//                      TRACE (treeview,"user-supplied buffer\n");
     2286                        COMCTL32_Free (buf);
     2287                        wineItem->cchTextMax = 0;
     2288                }
     2289        }
     2290  if (what & TVIF_SELECTEDIMAGE)
     2291                wineItem->iSelectedImage = tvdi.item.iSelectedImage;
     2292  if (what & TVIF_IMAGE)
     2293                wineItem->iImage         = tvdi.item.iImage;
     2294  if (what & TVIF_CHILDREN)
     2295                wineItem->cChildren      = tvdi.item.cChildren;
    22952296
    22962297 return retval;
     
    23012302static BOOL
    23022303TREEVIEW_SendCustomDrawNotify (HWND hwnd, DWORD dwDrawStage, HDC hdc,
    2303                         RECT rc)
     2304                        RECT rc)
    23042305{
    23052306  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     
    23142315  nmcd->hdr.code   = NM_CUSTOMDRAW;
    23152316  nmcd->dwDrawStage= dwDrawStage;
    2316   nmcd->hdc                = hdc;
     2317  nmcd->hdc                = hdc;
    23172318  nmcd->rc.left    = rc.left;
    23182319  nmcd->rc.right   = rc.right;
     
    23372338static BOOL
    23382339TREEVIEW_SendCustomDrawItemNotify (HWND hwnd, HDC hdc,
    2339                         TREEVIEW_ITEM *wineItem, UINT uItemDrawState)
     2340                        TREEVIEW_ITEM *wineItem, UINT uItemDrawState)
    23402341{
    23412342 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     
    23442345 DWORD dwDrawStage,dwItemSpec;
    23452346 UINT uItemState;
    2346  
     2347
    23472348 dwDrawStage=CDDS_ITEM | uItemDrawState;
    23482349 dwItemSpec=(DWORD)wineItem->hItem;
    23492350 uItemState=0;
    23502351 if (wineItem->hItem==infoPtr->selectedItem) uItemState|=CDIS_SELECTED;
    2351  if (wineItem->hItem==infoPtr->focusItem)        uItemState|=CDIS_FOCUS;
     2352 if (wineItem->hItem==infoPtr->focusItem)        uItemState|=CDIS_FOCUS;
    23522353 if (wineItem->hItem==infoPtr->hotItem)      uItemState|=CDIS_HOT;
    23532354
     
    23572358 nmcd->hdr.code   = NM_CUSTOMDRAW;
    23582359 nmcd->dwDrawStage= dwDrawStage;
    2359  nmcd->hdc                = hdc;
     2360 nmcd->hdc                = hdc;
    23602361 nmcd->rc.left    = wineItem->rect.left;
    23612362 nmcd->rc.right   = wineItem->rect.right;
     
    23712372
    23722373// TRACE (treeview,"drawstage:%lx hdc:%x item:%lx, itemstate:%x\n",
    2373 //                dwDrawStage, hdc, dwItemSpec, uItemState);
     2374//                dwDrawStage, hdc, dwItemSpec, uItemState);
    23742375
    23752376 return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY,
     
    23802381
    23812382/* Note:If the specified item is the child of a collapsed parent item,
    2382    the parent's list of child items is (recursively) expanded to reveal the 
    2383    specified item. This is mentioned for TREEVIEW_SelectItem; don't 
     2383   the parent's list of child items is (recursively) expanded to reveal the
     2384   specified item. This is mentioned for TREEVIEW_SelectItem; don't
    23842385   know if it also applies here.
    23852386*/
     
    23922393  UINT flag;
    23932394  INT expand;
    2394  
     2395
    23952396  flag = (UINT) wParam;
    23962397  expand = (INT) lParam;
     
    23982399  wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)expand);
    23992400
    2400   if (!wineItem) 
     2401  if (!wineItem)
    24012402    return 0;
    2402   if (!wineItem->cChildren) 
     2403  if (!wineItem->cChildren)
    24032404    return 0;
    24042405
    2405 //  TRACE (treeview,"For (%s) flags:%x item:%d state:%d\n", 
     2406//  TRACE (treeview,"For (%s) flags:%x item:%d state:%d\n",
    24062407//    wineItem->pszText,
    2407 //    flag, 
     2408//    flag,
    24082409//    expand,
    24092410//    wineItem->state);
     
    24162417  if (flag == TVE_TOGGLE) {    /* FIXME: check exact behaviour here */
    24172418   flag &= ~TVE_TOGGLE;    /* ie: bitwise ops or 'case' ops */
    2418    if (wineItem->state & TVIS_EXPANDED) 
     2419   if (wineItem->state & TVIS_EXPANDED)
    24192420     flag |= TVE_COLLAPSE;
    24202421   else
     
    24222423  }
    24232424
    2424   switch (flag) 
     2425  switch (flag)
    24252426  {
    2426     case TVE_COLLAPSERESET: 
     2427    case TVE_COLLAPSERESET:
    24272428//      TRACE(treeview, "  case TVE_COLLAPSERESET\n");
    2428       if (!wineItem->state & TVIS_EXPANDED) 
     2429      if (!wineItem->state & TVIS_EXPANDED)
    24292430        return 0;
    24302431
     
    24332434       break;
    24342435
    2435     case TVE_COLLAPSE: 
     2436    case TVE_COLLAPSE:
    24362437//      TRACE(treeview, "  case TVE_COLLAPSE\n");
    2437       if (!wineItem->state & TVIS_EXPANDED) 
     2438      if (!wineItem->state & TVIS_EXPANDED)
    24382439        return 0;
    24392440
     
    24412442      break;
    24422443
    2443     case TVE_EXPAND: 
     2444    case TVE_EXPAND:
    24442445//      TRACE(treeview, "  case TVE_EXPAND\n");
    2445       if (wineItem->state & TVIS_EXPANDED) 
     2446      if (wineItem->state & TVIS_EXPANDED)
    24462447        return 0;
    24472448
    24482449//      TRACE(treeview, "  is not expanded...\n");
    2449      
    2450       if (!(wineItem->state & TVIS_EXPANDEDONCE)) 
    2451       { 
     2450
     2451      if (!(wineItem->state & TVIS_EXPANDEDONCE))
     2452      {
    24522453//        TRACE(treeview, "  and has never been expanded...\n");
    24532454        wineItem->state |= TVIS_EXPANDED;
     
    24552456        /* this item has never been expanded */
    24562457        if (TREEVIEW_SendTreeviewNotify (
    2457               hwnd, 
    2458               TVN_ITEMEXPANDING, 
    2459               TVE_EXPAND, 
    2460               0, 
     2458              hwnd,
     2459              TVN_ITEMEXPANDING,
     2460              TVE_EXPAND,
     2461              0,
    24612462              (HTREEITEM)expand))
    24622463        {
    24632464//          TRACE(treeview, "  TVN_ITEMEXPANDING returned TRUE, exiting...\n");
    2464           return FALSE;   
     2465          return FALSE;
    24652466        }
    24662467
    24672468        /* FIXME
    24682469         * Since the TVN_ITEMEXPANDING message may has caused the parent to
    2469          * insert new items which in turn may have cause items placeholder 
    2470          * reallocation, I reassign the current item pointer so we have 
    2471          * something valid to work with... 
    2472          * However, this should not be necessary, 
     2470         * insert new items which in turn may have cause items placeholder
     2471         * reallocation, I reassign the current item pointer so we have
     2472         * something valid to work with...
     2473         * However, this should not be necessary,
    24732474         * investigation required in TREEVIEW_InsertItemA
    24742475         */
    24752476        wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)expand);
    2476         if (! wineItem) 
    2477         { 
    2478 //          ERR(treeview, 
     2477        if (! wineItem)
     2478        {
     2479//          ERR(treeview,
    24792480//            "Catastropic situation, cannot retreive item #%d\n",
    24802481//            expand);
     
    24862487
    24872488        TREEVIEW_SendTreeviewNotify (
    2488           hwnd, 
    2489           TVN_ITEMEXPANDED, 
    2490           TVE_EXPAND, 
    2491           0, 
     2489          hwnd,
     2490          TVN_ITEMEXPANDED,
     2491          TVE_EXPAND,
     2492          0,
    24922493          (HTREEITEM)expand);
    24932494
     
    25102511  }
    25112512
    2512 //  TRACE(treeview, "Exiting, Item %d state is now %d...\n", 
    2513 //    expand, 
     2513//  TRACE(treeview, "Exiting, Item %d state is now %d...\n",
     2514//    expand,
    25142515//    wineItem->state);
    2515  
     2516
    25162517  TREEVIEW_QueueRefresh (hwnd);
    25172518  return TRUE;
     
    25352536 while ((wineItem!=NULL) && (pt.y > wineItem->rect.bottom))
    25362537       wineItem=TREEVIEW_GetNextListItem (infoPtr,wineItem);
    2537        
    2538  if (!wineItem) 
    2539         return NULL;
     2538
     2539 if (!wineItem)
     2540        return NULL;
    25402541
    25412542 return wineItem;
     
    25682569
    25692570  wineItem=TREEVIEW_HitTestPoint (hwnd, lpht->pt);
    2570   if (!wineItem) { 
     2571  if (!wineItem) {
    25712572    lpht->flags=TVHT_NOWHERE;
    25722573    return 0;
     
    25742575
    25752576  /* FIXME: implement other flags
    2576    * Assign the appropriate flags depending on the click location 
    2577    * Intitialize flags before to "|=" it... 
     2577   * Assign the appropriate flags depending on the click location
     2578   * Intitialize flags before to "|=" it...
    25782579   */
    25792580  lpht->flags=0;
    25802581
    2581   if (x < wineItem->expandBox.left) 
     2582  if (x < wineItem->expandBox.left)
    25822583  {
    25832584    lpht->flags |= TVHT_ONITEMINDENT;
    2584   } 
    2585   else if ( ( x >= wineItem->expandBox.left) && 
     2585  }
     2586  else if ( ( x >= wineItem->expandBox.left) &&
    25862587            ( x <= wineItem->expandBox.right))
    25872588  {
    25882589    lpht->flags |= TVHT_ONITEMBUTTON;
    25892590  }
    2590   else if (x < wineItem->rect.right) 
     2591  else if (x < wineItem->rect.right)
    25912592  {
    2592     lpht->flags |= TVHT_ONITEMLABEL;   
    2593   } 
     2593    lpht->flags |= TVHT_ONITEMLABEL;
     2594  }
    25942595  else
    25952596  {
    25962597    lpht->flags|=TVHT_ONITEMRIGHT;
    25972598  }
    2598  
     2599
    25992600  lpht->hItem=wineItem->hItem;
    26002601
     
    26122613  if ( ! (BOOL)wParam ) /* wParam is set to true to cancel the edition */
    26132614  {
    2614                 if ( TREEVIEW_SendDispInfoNotify(  /* return true to cancel edition */
    2615            hwnd, 
     2615                if ( TREEVIEW_SendDispInfoNotify(  /* return true to cancel edition */
     2616           hwnd,
    26162617           editedItem,
    2617            TVN_ENDLABELEDIT, 
     2618           TVN_ENDLABELEDIT,
    26182619           0))
    26192620    {
    26202621      bRevert = TRUE;
    2621       bReturn = FALSE; 
     2622      bReturn = FALSE;
    26222623    }
    26232624  }
     
    26292630    bReturn      = FALSE;
    26302631
    2631     if (iLength == 0) 
     2632    if (iLength == 0)
    26322633    {
    26332634//      ERR( treeview, "Problem retreiving new item label.");
     
    26352636    else if (iLength >= 1023)
    26362637    {
    2637 //      ERR( treeview, 
     2638//      ERR( treeview,
    26382639//        "Insuficient space to retrieve new item label, new label ignored.");
    26392640    }
     
    26462647      {
    26472648        LPSTR tmpLabel = COMCTL32_Alloc( iLength+1 );
    2648  
     2649
    26492650//        if ( tmpLabel == NULL )
    2650 //          ERR( treeview, 
     2651//          ERR( treeview,
    26512652//            "OutOfMemory, cannot allocate space for label");
    26522653//        else
     
    26602661    }
    26612662
    2662                 ShowWindow(infoPtr->hwndEdit, SW_HIDE);
    2663                 EnableWindow(infoPtr->hwndEdit, FALSE);
     2663                ShowWindow(infoPtr->hwndEdit, SW_HIDE);
     2664                EnableWindow(infoPtr->hwndEdit, FALSE);
    26642665    infoPtr->editItem = 0;
    26652666  }
     
    26842685  if (!wineItem) return 0;
    26852686//  TRACE (treeview,"item %d \n",(INT)wineItem->hItem);
    2686  
     2687
    26872688  if (TREEVIEW_SendSimpleNotify (hwnd, NM_DBLCLK)!=TRUE) {     /* FIXME!*/
    2688         TREEVIEW_Expand (hwnd, (WPARAM) TVE_TOGGLE, (LPARAM) wineItem->hItem);
     2689        TREEVIEW_Expand (hwnd, (WPARAM) TVE_TOGGLE, (LPARAM) wineItem->hItem);
    26892690 }
    26902691 return TRUE;
     
    27132714    infoPtr->uInternalStatus|=TV_LDRAG;
    27142715  }
    2715  
     2716
    27162717  return 0;
    27172718}
     
    27242725  TREEVIEW_ITEM *editItem;
    27252726  TVHITTESTINFO ht;
    2726  
     2727
    27272728  ht.pt.x = (INT)LOWORD(lParam);
    27282729  ht.pt.y = (INT)HIWORD(lParam);
    2729  
     2730
    27302731//  TRACE (treeview,"\n");
    27312732
     
    27362737  /* Get the item */
    27372738  iItem = TREEVIEW_HitTest (hwnd, (LPARAM) &ht);
    2738   if (!iItem) 
     2739  if (!iItem)
    27392740    return 0;
    27402741
    27412742  editItem = TREEVIEW_ValidItem(infoPtr, (HTREEITEM)iItem);
    2742  
     2743
    27432744  infoPtr->uInternalStatus &= ~(TV_LDRAG | TV_LDRAGGING);
    27442745
    2745   /* 
    2746    * If the style allow editing and the node is already selected 
     2746  /*
     2747   * If the style allow editing and the node is already selected
    27472748   * and the click occured on the item label...
    27482749   */
    2749   if ( ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_EDITLABELS ) && 
     2750  if ( ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_EDITLABELS ) &&
    27502751       ( editItem->state & TVIS_SELECTED ) &&
    27512752       ( ht.flags & TVHT_ONITEMLABEL ))
     
    27532754    if ( infoPtr->editItem == 0 ) /* If we are not curently editing */
    27542755    {
    2755                 if ( TREEVIEW_SendDispInfoNotify(  /* Return true to cancel edition */
    2756               hwnd, 
    2757               editItem, 
    2758               TVN_BEGINLABELEDIT, 
     2756                if ( TREEVIEW_SendDispInfoNotify(  /* Return true to cancel edition */
     2757              hwnd,
     2758              editItem,
     2759              TVN_BEGINLABELEDIT,
    27592760              0))
    27602761      {
    2761         return 0; 
     2762        return 0;
    27622763      }
    2763  
    2764 //              TRACE(treeview,"Edit started for %s.\n", editItem->pszText);
    2765                 infoPtr->editItem = editItem->hItem;
    2766  
    2767                 SetWindowPos (
    2768         infoPtr->hwndEdit, 
    2769         HWND_TOP, 
    2770         editItem->text.left - 2, 
     2764
     2765//              TRACE(treeview,"Edit started for %s.\n", editItem->pszText);
     2766                infoPtr->editItem = editItem->hItem;
     2767
     2768                SetWindowPos (
     2769        infoPtr->hwndEdit,
     2770        HWND_TOP,
     2771        editItem->text.left - 2,
    27712772        editItem->text.top  - 1,
    27722773        editItem->text.right  - editItem->text.left + 20 ,
    27732774        editItem->text.bottom - editItem->text.top  + 3,
    27742775        SWP_DRAWFRAME );
    2775  
    2776                 SetWindowTextA( infoPtr->hwndEdit, editItem->pszText );
     2776
     2777                SetWindowTextA( infoPtr->hwndEdit, editItem->pszText );
    27772778      SendMessageA  ( infoPtr->hwndEdit, EM_SETSEL, 0, -1 );
    2778                 SetFocus      ( infoPtr->hwndEdit);
    2779       ShowWindow    ( infoPtr->hwndEdit, SW_SHOW); 
     2779                SetFocus      ( infoPtr->hwndEdit);
     2780      ShowWindow    ( infoPtr->hwndEdit, SW_SHOW);
    27802781    }
    27812782  }
     
    27872788  {
    27882789    TREEVIEW_DoSelectItem (
    2789       hwnd, 
    2790       TVGN_CARET, 
    2791       (HTREEITEM)iItem, 
     2790      hwnd,
     2791      TVGN_CARET,
     2792      (HTREEITEM)iItem,
    27922793      TVC_BYMOUSE);
    27932794  }
     
    28352836
    28362837 if (infoPtr->uInternalStatus & TV_LDRAG) {
    2837         TREEVIEW_SendTreeviewDnDNotify (hwnd, TVN_BEGINDRAG, hotItem->hItem, pt);
    2838         infoPtr->uInternalStatus &= ~TV_LDRAG;
    2839         infoPtr->uInternalStatus |= TV_LDRAGGING;
    2840         infoPtr->dropItem=hotItem->hItem;
    2841         return 0;
     2838        TREEVIEW_SendTreeviewDnDNotify (hwnd, TVN_BEGINDRAG, hotItem->hItem, pt);
     2839        infoPtr->uInternalStatus &= ~TV_LDRAG;
     2840        infoPtr->uInternalStatus |= TV_LDRAGGING;
     2841        infoPtr->dropItem=hotItem->hItem;
     2842        return 0;
    28422843 }
    28432844
    28442845 if (infoPtr->uInternalStatus & TV_RDRAG) {
    2845         TREEVIEW_SendTreeviewDnDNotify (hwnd, TVN_BEGINRDRAG, hotItem->hItem, pt);
    2846         infoPtr->uInternalStatus &= ~TV_RDRAG;
    2847         infoPtr->uInternalStatus |= TV_RDRAGGING;
    2848         infoPtr->dropItem=hotItem->hItem;
    2849         return 0;
     2846        TREEVIEW_SendTreeviewDnDNotify (hwnd, TVN_BEGINRDRAG, hotItem->hItem, pt);
     2847        infoPtr->uInternalStatus &= ~TV_RDRAG;
     2848        infoPtr->uInternalStatus |= TV_RDRAGGING;
     2849        infoPtr->dropItem=hotItem->hItem;
     2850        return 0;
    28502851 }
    2851  
     2852
    28522853 return 0;
    28532854}
     
    28672868 HFONT hOldFont;
    28682869 char    *itemtxt;
    2869  
     2870
    28702871// TRACE (treeview,"\n");
    28712872 if (!(infoPtr->himlNormal))  return 0;
    28722873 dragItem=TREEVIEW_ValidItem (infoPtr, (HTREEITEM) lParam);
    2873  
     2874
    28742875 if (!dragItem) return 0;
    28752876 itemtxt=dragItem->pszText;
     
    28772878 hwtop=GetDesktopWindow ();
    28782879 htopdc= GetDC (hwtop);
    2879  hdc=CreateCompatibleDC (htopdc); 
    2880  
     2880 hdc=CreateCompatibleDC (htopdc);
     2881
    28812882 hOldFont=SelectObject (hdc, infoPtr->hFont);
    28822883 GetTextExtentPoint32A (hdc, itemtxt, lstrlenA (itemtxt), &size);
     
    29242925  wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)newSelect);
    29252926
    2926 //  TRACE (treeview,"Entering item %d, flag %x, cause %x, state %d\n", 
    2927 //    (INT)newSelect, 
    2928 //    action, 
     2927//  TRACE (treeview,"Entering item %d, flag %x, cause %x, state %d\n",
     2928//    (INT)newSelect,
     2929//    action,
    29292930//    cause,
    29302931//    wineItem->state);
     
    29322933  if ( (wineItem) && (wineItem->parent))
    29332934  {
    2934     /* 
    2935      * If the item has a collapse parent expand the parent so he 
    2936      * can expose the item 
     2935    /*
     2936     * If the item has a collapse parent expand the parent so he
     2937     * can expose the item
    29372938     */
    29382939    TREEVIEW_ITEM *parentItem = TREEVIEW_ValidItem (infoPtr, wineItem->parent);
    2939     if ( !(parentItem->state & TVIS_EXPANDED)) 
     2940    if ( !(parentItem->state & TVIS_EXPANDED))
    29402941      TREEVIEW_Expand (hwnd, TVE_EXPAND, (LPARAM) wineItem->parent);
    29412942  }
    29422943
    2943   switch (action) 
     2944  switch (action)
    29442945  {
    2945     case TVGN_CARET: 
     2946    case TVGN_CARET:
    29462947      prevSelect=(INT)infoPtr->selectedItem;
    29472948
    2948       if ((HTREEITEM)prevSelect==newSelect) 
     2949      if ((HTREEITEM)prevSelect==newSelect)
    29492950        return FALSE;
    29502951
    29512952      prevItem= TREEVIEW_ValidItem (infoPtr, (HTREEITEM)prevSelect);
    29522953
    2953       if (newSelect) 
     2954      if (newSelect)
    29542955        if (TREEVIEW_SendTreeviewNotify(
    2955               hwnd, 
    2956               TVN_SELCHANGING, 
    2957               cause, 
    2958               (HTREEITEM)prevSelect, 
    2959               (HTREEITEM)newSelect)) 
     2956              hwnd,
     2957              TVN_SELCHANGING,
     2958              cause,
     2959              (HTREEITEM)prevSelect,
     2960              (HTREEITEM)newSelect))
    29602961          return FALSE;       /* FIXME: OK? */
    2961    
    2962       if (prevItem) 
     2962
     2963      if (prevItem)
    29632964        prevItem->state &= ~TVIS_SELECTED;
    2964       if (wineItem) 
     2965      if (wineItem)
    29652966        wineItem->state |=  TVIS_SELECTED;
    29662967
     
    29682969
    29692970      TREEVIEW_SendTreeviewNotify(
    2970         hwnd, 
    2971         TVN_SELCHANGED, 
     2971        hwnd,
     2972        TVN_SELCHANGED,
    29722973        cause,
    29732974        (HTREEITEM)prevSelect,
     
    29762977      break;
    29772978
    2978     case TVGN_DROPHILITE: 
     2979    case TVGN_DROPHILITE:
    29792980      prevItem= TREEVIEW_ValidItem (infoPtr, infoPtr->dropItem);
    29802981
    2981       if (prevItem) 
     2982      if (prevItem)
    29822983        prevItem->state &= ~TVIS_DROPHILITED;
    29832984
    29842985      infoPtr->dropItem=(HTREEITEM)newSelect;
    29852986
    2986       if (wineItem) 
     2987      if (wineItem)
    29872988        wineItem->state |=TVIS_DROPHILITED;
    29882989
     
    29932994      break;
    29942995 }
    2995  
     2996
    29962997 TREEVIEW_QueueRefresh (hwnd);
    29972998
     
    30103011
    30113012
    3012    
     3013
    30133014static LRESULT
    30143015TREEVIEW_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
     
    30333034
    30343035// TRACE (treeview,"%x %lx\n",wParam, lParam);
    3035  
     3036
    30363037 infoPtr->hFont = (HFONT)wParam;
    30373038
     
    30463047 GetTextMetricsA (hdc, &tm);
    30473048 height= tm.tmHeight + tm.tmExternalLeading;
    3048  if (height>infoPtr->uRealItemHeight) 
    3049         infoPtr->uRealItemHeight=height;
     3049 if (height>infoPtr->uRealItemHeight)
     3050        infoPtr->uRealItemHeight=height;
    30503051 SelectObject (hdc, hOldFont);
    30513052 ReleaseDC (0, hdc);
    30523053
    3053  if (lParam)   
    3054         TREEVIEW_QueueRefresh (hwnd);
    3055  
     3054 if (lParam)
     3055        TREEVIEW_QueueRefresh (hwnd);
     3056
    30563057 return 0;
    30573058}
     
    30703071
    30713072  switch (LOWORD (wParam)) {
    3072         case SB_LINEUP:
    3073                         if (!infoPtr->cy) return FALSE;
    3074                         infoPtr->cy -= infoPtr->uRealItemHeight;
    3075                         if (infoPtr->cy < 0) infoPtr->cy=0;
    3076                         break;
    3077         case SB_LINEDOWN:
    3078                         maxHeight=infoPtr->uTotalHeight-infoPtr->uVisibleHeight;
    3079                         if (infoPtr->cy == maxHeight) return FALSE;
    3080                         infoPtr->cy += infoPtr->uRealItemHeight;
    3081                         if (infoPtr->cy > maxHeight)
    3082                                 infoPtr->cy = maxHeight;
    3083                         break;
    3084         case SB_PAGEUP:
    3085                         if (!infoPtr->cy) return FALSE;
    3086                         infoPtr->cy -= infoPtr->uVisibleHeight;
    3087                         if (infoPtr->cy < 0) infoPtr->cy=0;
    3088                         break;
    3089         case SB_PAGEDOWN:
    3090                         maxHeight=infoPtr->uTotalHeight-infoPtr->uVisibleHeight;
    3091                         if (infoPtr->cy == maxHeight) return FALSE;
    3092                         infoPtr->cy += infoPtr->uVisibleHeight;
     3073        case SB_LINEUP:
     3074                        if (!infoPtr->cy) return FALSE;
     3075                        infoPtr->cy -= infoPtr->uRealItemHeight;
     3076                        if (infoPtr->cy < 0) infoPtr->cy=0;
     3077                        break;
     3078        case SB_LINEDOWN:
     3079                        maxHeight=infoPtr->uTotalHeight-infoPtr->uVisibleHeight;
     3080                        if (infoPtr->cy == maxHeight) return FALSE;
     3081                        infoPtr->cy += infoPtr->uRealItemHeight;
     3082                        if (infoPtr->cy > maxHeight)
     3083                                infoPtr->cy = maxHeight;
     3084                        break;
     3085        case SB_PAGEUP:
     3086                        if (!infoPtr->cy) return FALSE;
     3087                        infoPtr->cy -= infoPtr->uVisibleHeight;
     3088                        if (infoPtr->cy < 0) infoPtr->cy=0;
     3089                        break;
     3090        case SB_PAGEDOWN:
     3091                        maxHeight=infoPtr->uTotalHeight-infoPtr->uVisibleHeight;
     3092                        if (infoPtr->cy == maxHeight) return FALSE;
     3093                        infoPtr->cy += infoPtr->uVisibleHeight;
    30933094            if (infoPtr->cy > maxHeight)
    30943095                infoPtr->cy = maxHeight;
    3095                         break;
    3096         case SB_THUMBTRACK:
    3097                         infoPtr->cy = HIWORD (wParam);
    3098                         break;
    3099                        
    3100   }
    3101  
     3096                        break;
     3097        case SB_THUMBTRACK:
     3098                        infoPtr->cy = HIWORD (wParam);
     3099                        break;
     3100
     3101  }
     3102
    31023103  TREEVIEW_QueueRefresh (hwnd);
    31033104  return TRUE;
     
    31053106
    31063107static LRESULT
    3107 TREEVIEW_HScroll (HWND hwnd, WPARAM wParam, LPARAM lParam) 
     3108TREEVIEW_HScroll (HWND hwnd, WPARAM wParam, LPARAM lParam)
    31083109{
    31093110  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     
    31113112
    31123113//  TRACE (treeview,"wp %lx, lp %x\n", lParam, wParam);
    3113        
     3114
    31143115  if (!infoPtr->uInternalStatus & TV_HSCROLL) return FALSE;
    31153116
    31163117  switch (LOWORD (wParam)) {
    3117         case SB_LINEUP:
    3118                         if (!infoPtr->cx) return FALSE;
    3119                         infoPtr->cx -= infoPtr->uRealItemHeight;
    3120                         if (infoPtr->cx < 0) infoPtr->cx=0;
    3121                         break;
    3122         case SB_LINEDOWN:
    3123                         maxWidth=infoPtr->uTotalWidth-infoPtr->uVisibleWidth;
    3124                         if (infoPtr->cx == maxWidth) return FALSE;
    3125                         infoPtr->cx += infoPtr->uRealItemHeight; /*FIXME */
    3126                         if (infoPtr->cx > maxWidth)
    3127                                 infoPtr->cx = maxWidth;
    3128                         break;
    3129         case SB_PAGEUP:
    3130                         if (!infoPtr->cx) return FALSE;
    3131                         infoPtr->cx -= infoPtr->uVisibleWidth;
    3132                         if (infoPtr->cx < 0) infoPtr->cx=0;
    3133                         break;
    3134         case SB_PAGEDOWN:
    3135                         maxWidth=infoPtr->uTotalWidth-infoPtr->uVisibleWidth;
    3136                         if (infoPtr->cx == maxWidth) return FALSE;
    3137                         infoPtr->cx += infoPtr->uVisibleWidth;
     3118        case SB_LINEUP:
     3119                        if (!infoPtr->cx) return FALSE;
     3120                        infoPtr->cx -= infoPtr->uRealItemHeight;
     3121                        if (infoPtr->cx < 0) infoPtr->cx=0;
     3122                        break;
     3123        case SB_LINEDOWN:
     3124                        maxWidth=infoPtr->uTotalWidth-infoPtr->uVisibleWidth;
     3125                        if (infoPtr->cx == maxWidth) return FALSE;
     3126                        infoPtr->cx += infoPtr->uRealItemHeight; /*FIXME */
     3127                        if (infoPtr->cx > maxWidth)
     3128                                infoPtr->cx = maxWidth;
     3129                        break;
     3130        case SB_PAGEUP:
     3131                        if (!infoPtr->cx) return FALSE;
     3132                        infoPtr->cx -= infoPtr->uVisibleWidth;
     3133                        if (infoPtr->cx < 0) infoPtr->cx=0;
     3134                        break;
     3135        case SB_PAGEDOWN:
     3136                        maxWidth=infoPtr->uTotalWidth-infoPtr->uVisibleWidth;
     3137                        if (infoPtr->cx == maxWidth) return FALSE;
     3138                        infoPtr->cx += infoPtr->uVisibleWidth;
    31383139            if (infoPtr->cx > maxWidth)
    31393140                infoPtr->cx = maxWidth;
    3140                         break;
    3141         case SB_THUMBTRACK:
    3142                         infoPtr->cx = HIWORD (wParam);
    3143                         break;
    3144                        
    3145   }
    3146  
     3141                        break;
     3142        case SB_THUMBTRACK:
     3143                        infoPtr->cx = HIWORD (wParam);
     3144                        break;
     3145
     3146  }
     3147
    31473148  TREEVIEW_QueueRefresh (hwnd);
    31483149  return TRUE;
     
    31593160 INT           prevSelect      = (INT)infoPtr->selectedItem;
    31603161
    3161  TREEVIEW_ITEM *prevItem       = 
    3162     (prevSelect != 0 ) ? 
     3162 TREEVIEW_ITEM *prevItem       =
     3163    (prevSelect != 0 ) ?
    31633164      TREEVIEW_ValidItem (infoPtr, (HTREEITEM)prevSelect) :
    31643165      NULL;
     
    31683169// TRACE (treeview,"%x %lx\n",wParam, lParam);
    31693170
    3170  if (prevSelect == 0) 
     3171 if (prevSelect == 0)
    31713172   return FALSE;
    31723173
    31733174 switch (wParam) {
    3174         case VK_UP:
    3175                 newItem=TREEVIEW_GetPrevListItem (infoPtr, prevItem);
    3176 
    3177                 if (!newItem)
    3178                         newItem=& infoPtr->items[(INT)infoPtr->TopRootItem];
     3175        case VK_UP:
     3176                newItem=TREEVIEW_GetPrevListItem (infoPtr, prevItem);
     3177
     3178                if (!newItem)
     3179                        newItem=& infoPtr->items[(INT)infoPtr->TopRootItem];
    31793180
    31803181    hNewSelection = newItem->hItem;
     
    31833184      scrollNeeds = SB_LINEUP;
    31843185
    3185                 break;
    3186 
    3187         case VK_DOWN:
    3188                 newItem=TREEVIEW_GetNextListItem (infoPtr, prevItem);
    3189 
    3190                 if (!newItem)
     3186                break;
     3187
     3188        case VK_DOWN:
     3189                newItem=TREEVIEW_GetNextListItem (infoPtr, prevItem);
     3190
     3191                if (!newItem)
    31913192      newItem=prevItem;
    31923193
     
    31963197      scrollNeeds = SB_LINEDOWN;
    31973198
    3198                 break;
    3199 
    3200         case VK_HOME:
    3201                 newItem       = &infoPtr->items[(INT)infoPtr->TopRootItem];
     3199                break;
     3200
     3201        case VK_HOME:
     3202                newItem       = &infoPtr->items[(INT)infoPtr->TopRootItem];
    32023203    hNewSelection = newItem->hItem;
    32033204    cyChangeNeeds = 0;
    3204                 break;
    3205 
    3206         case VK_END:
    3207                 newItem       = &infoPtr->items[(INT)infoPtr->TopRootItem];
    3208                 newItem       = TREEVIEW_GetLastListItem (infoPtr, newItem);
     3205                break;
     3206
     3207        case VK_END:
     3208                newItem       = &infoPtr->items[(INT)infoPtr->TopRootItem];
     3209                newItem       = TREEVIEW_GetLastListItem (infoPtr, newItem);
    32093210    hNewSelection = newItem->hItem;
    32103211
     
    32123213      cyChangeNeeds = infoPtr->uTotalHeight-infoPtr->uVisibleHeight;
    32133214
    3214                 break;
    3215 
    3216         case VK_LEFT:
     3215                break;
     3216
     3217        case VK_LEFT:
    32173218    if ( (prevItem->cChildren > 0) && (prevItem->state & TVIS_EXPANDED) )
    32183219    {
    32193220      TREEVIEW_Expand(hwnd, TVE_COLLAPSE, prevSelect );
    32203221    }
    3221     else if ((INT)prevItem->parent) 
     3222    else if ((INT)prevItem->parent)
    32223223    {
    32233224      newItem = (& infoPtr->items[(INT)prevItem->parent]);
    3224       if (! newItem->visible) 
     3225      if (! newItem->visible)
    32253226        /* FIXME find a way to make this item the first visible... */
    3226         newItem = NULL; 
     3227        newItem = NULL;
    32273228
    32283229      hNewSelection = newItem->hItem;
     
    32313232    break;
    32323233
    3233         case VK_RIGHT:
    3234     if ( ( prevItem->cChildren > 0)  || 
     3234        case VK_RIGHT:
     3235    if ( ( prevItem->cChildren > 0)  ||
    32353236         ( prevItem->cChildren == I_CHILDRENCALLBACK))
    32363237    {
     
    32573258
    32583259  case VK_PRIOR:
    3259    
    3260                 newItem=TREEVIEW_GetListItem(
    3261               infoPtr, 
     3260
     3261                newItem=TREEVIEW_GetListItem(
     3262              infoPtr,
    32623263              prevItem,
    32633264              -1*(TREEVIEW_GetVisibleCount(hwnd,0,0)-3));
    3264                 if (!newItem)
     3265                if (!newItem)
    32653266      newItem=prevItem;
    3266  
     3267
    32673268    hNewSelection = newItem->hItem;
    32683269
     
    32703271      scrollNeeds = SB_PAGEUP;
    32713272
    3272                 break;
     3273                break;
    32733274
    32743275  case VK_NEXT:
    3275                 newItem=TREEVIEW_GetListItem(
    3276               infoPtr, 
     3276                newItem=TREEVIEW_GetListItem(
     3277              infoPtr,
    32773278              prevItem,
    32783279              TREEVIEW_GetVisibleCount(hwnd,0,0)-3);
    32793280
    3280                 if (!newItem)
     3281                if (!newItem)
    32813282      newItem=prevItem;
    32823283
     
    32863287      scrollNeeds = SB_PAGEDOWN;
    32873288
    3288                 break;
    3289 
    3290         case VK_BACK:
    3291 
    3292         case VK_RETURN:
     3289                break;
     3290
     3291        case VK_BACK:
     3292
     3293        case VK_RETURN:
    32933294
    32943295  default:
    3295 //              FIXME (treeview, "%x not implemented\n", wParam);
    3296                 break;
     3296//              FIXME (treeview, "%x not implemented\n", wParam);
     3297                break;
    32973298 }
    32983299
    3299   if (hNewSelection) 
     3300  if (hNewSelection)
    33003301  {
    3301 /* 
     3302/*
    33023303    This works but does not send notification...
    33033304
     
    33083309*/
    33093310
    3310     if ( TREEVIEW_DoSelectItem( 
    3311            hwnd, 
    3312            TVGN_CARET, 
    3313            (HTREEITEM)hNewSelection, 
     3311    if ( TREEVIEW_DoSelectItem(
     3312           hwnd,
     3313           TVGN_CARET,
     3314           (HTREEITEM)hNewSelection,
    33143315           TVC_BYKEYBOARD))
    33153316    {
     
    33173318      if (scrollNeeds != -1)
    33183319        TREEVIEW_VScroll(hwnd, scrollNeeds, 0);
    3319  
     3320
    33203321      if (cyChangeNeeds != -1)
    33213322        infoPtr->cy = cyChangeNeeds;
    33223323
    3323       /* FIXME: Something happen in the load the in the two weeks before 
    3324          april 1st 1999 which makes this SetFocus mandatory otherwise, the focus 
     3324      /* FIXME: Something happen in the load the in the two weeks before
     3325         april 1st 1999 which makes this SetFocus mandatory otherwise, the focus
    33253326         is lost... However the SetFocus should not be required...*/
    3326                
     3327
    33273328      SetFocus(hwnd);
    33283329    }
     
    33373338{
    33383339    switch (uMsg) {
    3339         case TVM_INSERTITEMA:
     3340        case TVM_INSERTITEMA:
    33403341          return TREEVIEW_InsertItemA (hwnd, wParam, lParam);
    33413342
    3342         case TVM_INSERTITEMW:
    3343 //                      FIXME (treeview, "Unimplemented msg TVM_INSERTITEM32W\n");
    3344                 return 0;
    3345 
    3346         case TVM_DELETEITEM:
    3347                 return TREEVIEW_DeleteItem (hwnd, wParam, lParam);
    3348 
    3349         case TVM_EXPAND:
    3350                 return TREEVIEW_Expand (hwnd, wParam, lParam);
    3351 
    3352         case TVM_GETITEMRECT:
    3353                 return TREEVIEW_GetItemRect (hwnd, wParam, lParam);
    3354 
    3355         case TVM_GETCOUNT:
    3356                 return TREEVIEW_GetCount (hwnd, wParam, lParam);
    3357 
    3358         case TVM_GETINDENT:
    3359                 return TREEVIEW_GetIndent (hwnd);
    3360 
    3361         case TVM_SETINDENT:
    3362                 return TREEVIEW_SetIndent (hwnd, wParam);
    3363 
    3364         case TVM_GETIMAGELIST:
    3365                 return TREEVIEW_GetImageList (hwnd, wParam, lParam);
    3366 
    3367                 case TVM_SETIMAGELIST:
    3368                 return TREEVIEW_SetImageList (hwnd, wParam, lParam);
    3369 
    3370         case TVM_GETNEXTITEM:
    3371                 return TREEVIEW_GetNextItem (hwnd, wParam, lParam);
    3372 
    3373         case TVM_SELECTITEM:
    3374                 return TREEVIEW_SelectItem (hwnd, wParam, lParam);
    3375 
    3376         case TVM_GETITEMA:
    3377                 return TREEVIEW_GetItemA (hwnd, wParam, lParam);
    3378 
    3379         case TVM_GETITEMW:
    3380 //                      FIXME (treeview, "Unimplemented msg TVM_GETITEM32W\n");
    3381                 return 0;
    3382 
    3383         case TVM_SETITEMA:
    3384                 return TREEVIEW_SetItemA (hwnd, wParam, lParam);
    3385 
    3386         case TVM_SETITEMW:
    3387 //                      FIXME (treeview, "Unimplemented msg TVM_SETITEMW\n");
    3388                 return 0;
    3389 
    3390         case TVM_EDITLABELA:
    3391 //                      FIXME (treeview, "Unimplemented msg TVM_EDITLABEL32A \n");
    3392                 return 0;
    3393 
    3394         case TVM_EDITLABELW:
    3395 //                      FIXME (treeview, "Unimplemented msg TVM_EDITLABEL32W \n");
    3396                 return 0;
    3397 
    3398         case TVM_GETEDITCONTROL:
    3399                 return TREEVIEW_GetEditControl (hwnd);
    3400 
    3401         case TVM_GETVISIBLECOUNT:
    3402                 return TREEVIEW_GetVisibleCount (hwnd, wParam, lParam);
    3403 
    3404         case TVM_HITTEST:
    3405                 return TREEVIEW_HitTest (hwnd, lParam);
    3406 
    3407         case TVM_CREATEDRAGIMAGE:
    3408                 return TREEVIEW_CreateDragImage (hwnd, wParam, lParam);
    3409  
    3410         case TVM_SORTCHILDREN:
    3411 //                      FIXME (treeview, "Unimplemented msg TVM_SORTCHILDREN\n");
    3412                 return 0;
    3413  
    3414         case TVM_ENSUREVISIBLE:
    3415 //                      FIXME (treeview, "Unimplemented msg TVM_ENSUREVISIBLE\n");
    3416                 return 0;
    3417  
    3418         case TVM_SORTCHILDRENCB:
    3419                 return TREEVIEW_SortChildrenCB(hwnd, wParam, lParam);
    3420  
    3421         case TVM_ENDEDITLABELNOW:
    3422                 return TREEVIEW_EndEditLabelNow (hwnd, wParam, lParam);
    3423  
    3424         case TVM_GETISEARCHSTRINGA:
    3425 //                      FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRING32A\n");
    3426                 return 0;
    3427  
    3428         case TVM_GETISEARCHSTRINGW:
    3429 //                      FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRING32W\n");
    3430                 return 0;
    3431  
    3432         case TVM_GETTOOLTIPS:
    3433                 return TREEVIEW_GetToolTips (hwnd);
    3434 
    3435         case TVM_SETTOOLTIPS:
    3436                 return TREEVIEW_SetToolTips (hwnd, wParam);
    3437  
    3438         case TVM_SETINSERTMARK:
    3439 //                      FIXME (treeview, "Unimplemented msg TVM_SETINSERTMARK\n");
    3440                 return 0;
    3441  
    3442         case TVM_SETITEMHEIGHT:
    3443                 return TREEVIEW_SetItemHeight (hwnd, wParam);
    3444  
    3445         case TVM_GETITEMHEIGHT:
    3446                 return TREEVIEW_GetItemHeight (hwnd);
    3447  
    3448         case TVM_SETBKCOLOR:
    3449                 return TREEVIEW_SetBkColor (hwnd, wParam, lParam);
    3450        
    3451         case TVM_SETTEXTCOLOR:
    3452                 return TREEVIEW_SetTextColor (hwnd, wParam, lParam);
    3453  
    3454         case TVM_GETBKCOLOR:
    3455                 return TREEVIEW_GetBkColor (hwnd);
    3456  
    3457         case TVM_GETTEXTCOLOR:
    3458                 return TREEVIEW_GetTextColor (hwnd);
    3459  
    3460         case TVM_SETSCROLLTIME:
    3461 //                      FIXME (treeview, "Unimplemented msg TVM_SETSCROLLTIME\n");
    3462                 return 0;
    3463  
    3464         case TVM_GETSCROLLTIME:
    3465 //                      FIXME (treeview, "Unimplemented msg TVM_GETSCROLLTIME\n");
    3466                 return 0;
    3467  
    3468         case TVM_SETINSERTMARKCOLOR:
    3469 //                      FIXME (treeview, "Unimplemented msg TVM_SETINSERTMARKCOLOR\n");
    3470                 return 0;
    3471  
    3472         case TVM_SETUNICODEFORMAT:
    3473 //                      FIXME (treeview, "Unimplemented msg TVM_SETUNICODEFORMAT\n");
    3474                 return 0;
    3475  
    3476         case TVM_GETUNICODEFORMAT:
    3477 //                      FIXME (treeview, "Unimplemented msg TVM_GETUNICODEFORMAT\n");
    3478                 return 0;
    3479  
    3480                 case WM_COMMAND:
    3481                         return TREEVIEW_Command (hwnd, wParam, lParam);
    3482  
    3483                 case WM_CREATE:
    3484                         return TREEVIEW_Create (hwnd, wParam, lParam);
    3485  
    3486                 case WM_DESTROY:
    3487                         return TREEVIEW_Destroy (hwnd);
    3488  
    3489 /*              case WM_ENABLE: */
    3490  
    3491                 case WM_ERASEBKGND:
    3492                         return TREEVIEW_EraseBackground (hwnd, wParam, lParam);
    3493  
    3494                 case WM_GETDLGCODE:
    3495                 return DLGC_WANTARROWS | DLGC_WANTCHARS;
    3496  
    3497                 case WM_PAINT:
    3498                 return TREEVIEW_Paint (hwnd, wParam, lParam);
    3499  
    3500                 case WM_GETFONT:
    3501                 return TREEVIEW_GetFont (hwnd, wParam, lParam);
    3502 
    3503                 case WM_SETFONT:
    3504                 return TREEVIEW_SetFont (hwnd, wParam, lParam);
    3505  
    3506                 case WM_KEYDOWN:
    3507                         return TREEVIEW_KeyDown (hwnd, wParam, lParam);
    3508  
    3509  
    3510                 case WM_SETFOCUS:
    3511                         return TREEVIEW_SetFocus (hwnd, wParam, lParam);
    3512 
    3513                 case WM_KILLFOCUS:
    3514                         return TREEVIEW_KillFocus (hwnd, wParam, lParam);
    3515  
    3516  
    3517                 case WM_LBUTTONDOWN:
    3518                         return TREEVIEW_LButtonDown (hwnd, wParam, lParam);
    3519 
    3520                 case WM_LBUTTONUP:
    3521                         return TREEVIEW_LButtonUp (hwnd, wParam, lParam);
    3522  
    3523                 case WM_LBUTTONDBLCLK:
    3524                         return TREEVIEW_LButtonDoubleClick (hwnd, wParam, lParam);
    3525  
    3526                 case WM_RBUTTONDOWN:
    3527                         return TREEVIEW_RButtonDown (hwnd, wParam, lParam);
    3528 
    3529                 case WM_RBUTTONUP:
    3530                         return TREEVIEW_RButtonUp (hwnd, wParam, lParam);
    3531 
    3532                 case WM_MOUSEMOVE:
    3533                         return TREEVIEW_MouseMove (hwnd, wParam, lParam);
    3534  
    3535  
    3536 /*              case WM_SYSCOLORCHANGE: */
    3537                 case WM_STYLECHANGED:
    3538                         return TREEVIEW_StyleChanged (hwnd, wParam, lParam);
    3539 
    3540 /*              case WM_SETREDRAW: */
    3541  
    3542                 case WM_TIMER:
    3543                         return TREEVIEW_HandleTimer (hwnd, wParam, lParam);
    3544  
    3545                 case WM_SIZE:
    3546                         return TREEVIEW_Size (hwnd, wParam,lParam);
    3547 
    3548                 case WM_HSCROLL:
    3549                         return TREEVIEW_HScroll (hwnd, wParam, lParam);
    3550                 case WM_VSCROLL:
    3551                         return TREEVIEW_VScroll (hwnd, wParam, lParam);
    3552  
    3553                 case WM_DRAWITEM:
    3554 //                      printf ("drawItem\n");
    3555                         return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    3556  
    3557                 default:
    3558                 if (uMsg >= WM_USER)
    3559 //              FIXME (treeview, "Unknown msg %04x wp=%08x lp=%08lx\n",
    3560 //                   uMsg, wParam, lParam);
    3561             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     3343        case TVM_INSERTITEMW:
     3344//                      FIXME (treeview, "Unimplemented msg TVM_INSERTITEM32W\n");
     3345                return 0;
     3346
     3347        case TVM_DELETEITEM:
     3348                return TREEVIEW_DeleteItem (hwnd, wParam, lParam);
     3349
     3350        case TVM_EXPAND:
     3351                return TREEVIEW_Expand (hwnd, wParam, lParam);
     3352
     3353        case TVM_GETITEMRECT:
     3354                return TREEVIEW_GetItemRect (hwnd, wParam, lParam);
     3355
     3356        case TVM_GETCOUNT:
     3357                return TREEVIEW_GetCount (hwnd, wParam, lParam);
     3358
     3359        case TVM_GETINDENT:
     3360                return TREEVIEW_GetIndent (hwnd);
     3361
     3362        case TVM_SETINDENT:
     3363                return TREEVIEW_SetIndent (hwnd, wParam);
     3364
     3365        case TVM_GETIMAGELIST:
     3366                return TREEVIEW_GetImageList (hwnd, wParam, lParam);
     3367
     3368                case TVM_SETIMAGELIST:
     3369                return TREEVIEW_SetImageList (hwnd, wParam, lParam);
     3370
     3371        case TVM_GETNEXTITEM:
     3372                return TREEVIEW_GetNextItem (hwnd, wParam, lParam);
     3373
     3374        case TVM_SELECTITEM:
     3375                return TREEVIEW_SelectItem (hwnd, wParam, lParam);
     3376
     3377        case TVM_GETITEMA:
     3378                return TREEVIEW_GetItemA (hwnd, wParam, lParam);
     3379
     3380        case TVM_GETITEMW:
     3381//                      FIXME (treeview, "Unimplemented msg TVM_GETITEM32W\n");
     3382                return 0;
     3383
     3384        case TVM_SETITEMA:
     3385                return TREEVIEW_SetItemA (hwnd, wParam, lParam);
     3386
     3387        case TVM_SETITEMW:
     3388//                      FIXME (treeview, "Unimplemented msg TVM_SETITEMW\n");
     3389                return 0;
     3390
     3391        case TVM_EDITLABELA:
     3392//                      FIXME (treeview, "Unimplemented msg TVM_EDITLABEL32A \n");
     3393                return 0;
     3394
     3395        case TVM_EDITLABELW:
     3396//                      FIXME (treeview, "Unimplemented msg TVM_EDITLABEL32W \n");
     3397                return 0;
     3398
     3399        case TVM_GETEDITCONTROL:
     3400                return TREEVIEW_GetEditControl (hwnd);
     3401
     3402        case TVM_GETVISIBLECOUNT:
     3403                return TREEVIEW_GetVisibleCount (hwnd, wParam, lParam);
     3404
     3405        case TVM_HITTEST:
     3406                return TREEVIEW_HitTest (hwnd, lParam);
     3407
     3408        case TVM_CREATEDRAGIMAGE:
     3409                return TREEVIEW_CreateDragImage (hwnd, wParam, lParam);
     3410
     3411        case TVM_SORTCHILDREN:
     3412//                      FIXME (treeview, "Unimplemented msg TVM_SORTCHILDREN\n");
     3413                return 0;
     3414
     3415        case TVM_ENSUREVISIBLE:
     3416//                      FIXME (treeview, "Unimplemented msg TVM_ENSUREVISIBLE\n");
     3417                return 0;
     3418
     3419        case TVM_SORTCHILDRENCB:
     3420                return TREEVIEW_SortChildrenCB(hwnd, wParam, lParam);
     3421
     3422        case TVM_ENDEDITLABELNOW:
     3423                return TREEVIEW_EndEditLabelNow (hwnd, wParam, lParam);
     3424
     3425        case TVM_GETISEARCHSTRINGA:
     3426//                      FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRING32A\n");
     3427                return 0;
     3428
     3429        case TVM_GETISEARCHSTRINGW:
     3430//                      FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRING32W\n");
     3431                return 0;
     3432
     3433        case TVM_GETTOOLTIPS:
     3434                return TREEVIEW_GetToolTips (hwnd);
     3435
     3436        case TVM_SETTOOLTIPS:
     3437                return TREEVIEW_SetToolTips (hwnd, wParam);
     3438
     3439        case TVM_SETINSERTMARK:
     3440//                      FIXME (treeview, "Unimplemented msg TVM_SETINSERTMARK\n");
     3441                return 0;
     3442
     3443        case TVM_SETITEMHEIGHT:
     3444                return TREEVIEW_SetItemHeight (hwnd, wParam);
     3445
     3446        case TVM_GETITEMHEIGHT:
     3447                return TREEVIEW_GetItemHeight (hwnd);
     3448
     3449        case TVM_SETBKCOLOR:
     3450                return TREEVIEW_SetBkColor (hwnd, wParam, lParam);
     3451
     3452        case TVM_SETTEXTCOLOR:
     3453                return TREEVIEW_SetTextColor (hwnd, wParam, lParam);
     3454
     3455        case TVM_GETBKCOLOR:
     3456                return TREEVIEW_GetBkColor (hwnd);
     3457
     3458        case TVM_GETTEXTCOLOR:
     3459                return TREEVIEW_GetTextColor (hwnd);
     3460
     3461        case TVM_SETSCROLLTIME:
     3462//                      FIXME (treeview, "Unimplemented msg TVM_SETSCROLLTIME\n");
     3463                return 0;
     3464
     3465        case TVM_GETSCROLLTIME:
     3466//                      FIXME (treeview, "Unimplemented msg TVM_GETSCROLLTIME\n");
     3467                return 0;
     3468
     3469        case TVM_SETINSERTMARKCOLOR:
     3470//                      FIXME (treeview, "Unimplemented msg TVM_SETINSERTMARKCOLOR\n");
     3471                return 0;
     3472
     3473        case TVM_SETUNICODEFORMAT:
     3474//                      FIXME (treeview, "Unimplemented msg TVM_SETUNICODEFORMAT\n");
     3475                return 0;
     3476
     3477        case TVM_GETUNICODEFORMAT:
     3478//                      FIXME (treeview, "Unimplemented msg TVM_GETUNICODEFORMAT\n");
     3479                return 0;
     3480
     3481                case WM_COMMAND:
     3482                        return TREEVIEW_Command (hwnd, wParam, lParam);
     3483
     3484                case WM_CREATE:
     3485                        return TREEVIEW_Create (hwnd, wParam, lParam);
     3486
     3487                case WM_DESTROY:
     3488                        return TREEVIEW_Destroy (hwnd);
     3489
     3490/*              case WM_ENABLE: */
     3491
     3492                case WM_ERASEBKGND:
     3493                        return TREEVIEW_EraseBackground (hwnd, wParam, lParam);
     3494
     3495                case WM_GETDLGCODE:
     3496                return DLGC_WANTARROWS | DLGC_WANTCHARS;
     3497
     3498                case WM_PAINT:
     3499                return TREEVIEW_Paint (hwnd, wParam, lParam);
     3500
     3501                case WM_GETFONT:
     3502                return TREEVIEW_GetFont (hwnd, wParam, lParam);
     3503
     3504                case WM_SETFONT:
     3505                return TREEVIEW_SetFont (hwnd, wParam, lParam);
     3506
     3507                case WM_KEYDOWN:
     3508                        return TREEVIEW_KeyDown (hwnd, wParam, lParam);
     3509
     3510
     3511                case WM_SETFOCUS:
     3512                        return TREEVIEW_SetFocus (hwnd, wParam, lParam);
     3513
     3514                case WM_KILLFOCUS:
     3515                        return TREEVIEW_KillFocus (hwnd, wParam, lParam);
     3516
     3517
     3518                case WM_LBUTTONDOWN:
     3519                        return TREEVIEW_LButtonDown (hwnd, wParam, lParam);
     3520
     3521                case WM_LBUTTONUP:
     3522                        return TREEVIEW_LButtonUp (hwnd, wParam, lParam);
     3523
     3524                case WM_LBUTTONDBLCLK:
     3525                        return TREEVIEW_LButtonDoubleClick (hwnd, wParam, lParam);
     3526
     3527                case WM_RBUTTONDOWN:
     3528                        return TREEVIEW_RButtonDown (hwnd, wParam, lParam);
     3529
     3530                case WM_RBUTTONUP:
     3531                        return TREEVIEW_RButtonUp (hwnd, wParam, lParam);
     3532
     3533                case WM_MOUSEMOVE:
     3534                        return TREEVIEW_MouseMove (hwnd, wParam, lParam);
     3535
     3536
     3537/*              case WM_SYSCOLORCHANGE: */
     3538                case WM_STYLECHANGED:
     3539                        return TREEVIEW_StyleChanged (hwnd, wParam, lParam);
     3540
     3541/*              case WM_SETREDRAW: */
     3542
     3543                case WM_TIMER:
     3544                        return TREEVIEW_HandleTimer (hwnd, wParam, lParam);
     3545
     3546                case WM_SIZE:
     3547                        return TREEVIEW_Size (hwnd, wParam,lParam);
     3548
     3549                case WM_HSCROLL:
     3550                        return TREEVIEW_HScroll (hwnd, wParam, lParam);
     3551                case WM_VSCROLL:
     3552                        return TREEVIEW_VScroll (hwnd, wParam, lParam);
     3553
     3554                case WM_DRAWITEM:
     3555//                      printf ("drawItem\n");
     3556                        return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     3557
     3558                default:
     3559//                if (uMsg >= WM_USER)
     3560//              FIXME (treeview, "Unknown msg %04x wp=%08x lp=%08lx\n",
     3561//                   uMsg, wParam, lParam);
     3562            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    35623563      }
    35633564    return 0;
     
    35823583    wndClass.hbrBackground = 0;
    35833584    wndClass.lpszClassName = WC_TREEVIEWA;
    3584  
     3585
    35853586    RegisterClassA (&wndClass);
    35863587}
     
    35913592{
    35923593    if (GlobalFindAtomA (WC_TREEVIEWA))
    3593         UnregisterClassA (WC_TREEVIEWA, (HINSTANCE)NULL);
    3594 }
    3595 
     3594        UnregisterClassA (WC_TREEVIEWA, (HINSTANCE)NULL);
     3595}
     3596
Note: See TracChangeset for help on using the changeset viewer.