Ignore:
Timestamp:
Dec 19, 1999, 11:32:12 AM (26 years ago)
Author:
achimha
Message:

updated to WINE 991212 level

File:
1 edited

Legend:

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

    r1793 r2131  
    1 /* $Id: treeview.c,v 1.19 1999-11-21 14:00:48 achimha Exp $ */
     1/* $Id: treeview.c,v 1.20 1999-12-19 10:32:12 achimha Exp $ */
    22/* Treeview control
    33 *
     
    4242 */
    4343
    44 /* WINE 991114 level */
     44/* WINE 991212 level */
    4545
    4646#include <string.h>
     
    433433  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    434434  INT cx,cy,prevHeight=infoPtr->uItemHeight;
    435   HDC hdc;
    436435
    437436//  TRACE (treeview,"\n");
    438437  if (wParam==-1) {
    439         hdc=GetDC (hwnd);
    440438        infoPtr->uItemHeight=-1;
    441439        return prevHeight;
     
    482480
    483481static LRESULT
     482TREEVIEW_GetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
     483{
     484  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     485
     486  TRACE("\n");
     487  return (LRESULT) infoPtr->clrInsertMark;
     488}
     489
     490static LRESULT
     491TREEVIEW_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
     492{
     493  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     494  COLORREF prevColor=infoPtr->clrInsertMark;
     495
     496  TRACE("%d %ld\n",wParam,lParam);
     497  infoPtr->clrInsertMark=(COLORREF) lParam;
     498  return (LRESULT) prevColor;
     499}
     500
     501static LRESULT
     502TREEVIEW_SetInsertMark (HWND hwnd, WPARAM wParam, LPARAM lParam)
     503{
     504  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     505
     506  FIXME("%d %ld\n",wParam,lParam);
     507  if (!TREEVIEW_ValidItem (infoPtr, (HTREEITEM)lParam)) return 0;
     508  FIXME("%d %ld\n",wParam,lParam);
     509
     510  infoPtr->insertBeforeorAfter=(BOOL) wParam;
     511  infoPtr->insertMarkItem=(HTREEITEM) lParam;
     512  TREEVIEW_Refresh (hwnd);
     513  return 1;
     514}
     515
     516static LRESULT
    484517TREEVIEW_SetTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
    485518{
     
    533566  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    534567  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    535   INT   center,xpos,cx,cy, cditem, drawmode;
     568  INT   center,xpos,cx,cy, cditem;
    536569  HFONT hOldFont;
    537570  UINT  uTextJustify = DT_LEFT;
     
    547580  //TRACE ("cdmode:%x\n",infoPtr->cdmode);
    548581  if (infoPtr->cdmode & CDRF_NOTIFYITEMDRAW) {
    549                 drawmode=CDDS_ITEMPREPAINT;
    550 
    551                 if (infoPtr->cdmode & CDRF_NOTIFYSUBITEMDRAW)
    552                   drawmode|=CDDS_SUBITEM;
    553 
    554                 cditem=TREEVIEW_SendCustomDrawItemNotify (hwnd, hdc, wineItem, drawmode);
    555 
    556 //              TRACE (treeview,"cditem:%d\n",cditem);
     582                cditem = TREEVIEW_SendCustomDrawItemNotify(hwnd, hdc,
     583                             wineItem, CDDS_ITEMPREPAINT);
    557584
    558585                if (cditem & CDRF_SKIPDEFAULT)
     
    670697  }
    671698
    672   /*
    673    * Display the image assiciated with this item
     699  /* 
     700   * Display the image associated with this item
    674701   */
    675702  xpos += 13; /* update position */
     
    678705    HIMAGELIST *himlp = NULL;
    679706
    680           if (infoPtr->himlNormal)
     707   /* State images are displayed to the left of the Normal image
     708    * image number is in state; zero should be `display no image'.
     709    * FIXME: that last sentence looks like it needs some checking.
     710    */
     711        if (infoPtr->himlState)
     712        himlp=&infoPtr->himlState;
     713        imageIndex=wineItem->state>>12;
     714        imageIndex++;          /* yeah, right */
     715        TRACE ("imindex:%d\n",imageIndex);
     716    if ((himlp) && (imageIndex))
     717    {
     718          imageIndex--;       /* see FIXME */
     719      ImageList_Draw ( *himlp, imageIndex, hdc, xpos-2, r.top+1, ILD_NORMAL);
     720          ImageList_GetIconSize (*himlp, &cx, &cy);
     721          wineItem->statebitmap.left=xpos-2;
     722          wineItem->statebitmap.right=xpos-2+cx;
     723          wineItem->statebitmap.top=r.top+1;
     724          wineItem->statebitmap.bottom=r.top+1+cy;
     725          xpos+=cx;
     726    }
     727       
     728                /* Now, draw the normal image; can be either selected or
     729                 * non-selected image.
     730                 */
     731
     732        himlp=NULL;
     733        if (infoPtr->himlNormal)
    681734      himlp=&infoPtr->himlNormal; /* get the image list */
    682735
    683         if ( (wineItem->state & TVIS_SELECTED) &&
    684          (wineItem->iSelectedImage)) {
    685 
    686       /* State images are displayed to the left of the Normal image*/
    687       if (infoPtr->himlState)
    688         himlp=&infoPtr->himlState;
    689 
     736    imageIndex = wineItem->iImage;
     737        if ( (wineItem->state & TVIS_SELECTED) &&
     738         (wineItem->iSelectedImage)) {
     739       
    690740      /* The item is curently selected */
    691                   if (wineItem->iSelectedImage == I_IMAGECALLBACK)
    692                         TREEVIEW_SendDispInfoNotify (
    693           hwnd,
    694           wineItem,
    695           TVN_GETDISPINFO,
    696           TVIF_SELECTEDIMAGE);
    697 
    698       imageIndex = wineItem->iSelectedImage;
    699 
    700           } else {
    701       /* This item is not selected */
    702                   if (wineItem->iImage == I_IMAGECALLBACK)
    703                           TREEVIEW_SendDispInfoNotify (
    704           hwnd,
    705           wineItem,
    706           TVN_GETDISPINFO,
    707           TVIF_IMAGE);
     741                  if (wineItem->iSelectedImage == I_IMAGECALLBACK)
     742                        TREEVIEW_SendDispInfoNotify
     743                                        (hwnd, wineItem, TVN_GETDISPINFO, TVIF_SELECTEDIMAGE);
     744
     745          imageIndex = wineItem->iSelectedImage;
     746          } else {
     747      /* The item is not selected */
     748                  if (wineItem->iImage == I_IMAGECALLBACK)
     749                          TREEVIEW_SendDispInfoNotify
     750                                        (hwnd, wineItem, TVN_GETDISPINFO, TVIF_IMAGE);
    708751
    709752      imageIndex = wineItem->iImage;
    710         }
    711 
    712     if (himlp)
    713     {
    714       /* We found an image to display? Draw it. */
    715         ImageList_Draw (
    716         *himlp,
    717         wineItem->iImage,
    718         hdc,
    719         xpos-2,
    720         r.top+1,
    721         ILD_NORMAL);
    722 
    723           ImageList_GetIconSize (*himlp, &cx, &cy);
    724           xpos+=cx;
     753        }
     754 
     755    if (himlp)         
     756    {
     757      ImageList_Draw ( *himlp, imageIndex, hdc, xpos-2, r.top+1, ILD_NORMAL);
     758          ImageList_GetIconSize (*himlp, &cx, &cy);
     759          wineItem->bitmap.left=xpos-2;
     760          wineItem->bitmap.right=xpos-2+cx;
     761          wineItem->bitmap.top=r.top+1;
     762          wineItem->bitmap.bottom=r.top+1+cy;
     763          xpos+=cx;
    725764    }
    726765  }
    727766
    728   /*
    729    * Display the text assiciated with this item
     767
     768  /*
     769   * Display the text associated with this item
    730770   */
    731771  r.left=xpos;
    732   if ((wineItem->mask & TVIF_TEXT) && (wineItem->pszText))
     772  if ((wineItem->mask & TVIF_TEXT) && (wineItem->pszText)) 
    733773  {
    734774    COLORREF oldBkColor = 0;
     
    739779    r.right -= 3;
    740780
    741     wineItem->text.left  = r.left;
     781    wineItem->text.left  = r.left; 
    742782    wineItem->text.right = r.right;
    743783    wineItem->text.top   = r.top;
    744784    wineItem->text.bottom= r.bottom;
    745785
    746     if (wineItem->state & (TVIS_SELECTED | TVIS_DROPHILITED) ) {
    747       oldBkMode    = SetBkMode   (hdc, OPAQUE);
    748       oldBkColor   = SetBkColor  (hdc, GetSysColor( COLOR_HIGHLIGHT));
    749       oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_HIGHLIGHTTEXT));
    750     }
    751     else
    752     {
    753       oldBkMode    = SetBkMode(hdc, TRANSPARENT);
    754       oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_WINDOWTEXT));
    755     }
    756 
    757786    if (wineItem->pszText== LPSTR_TEXTCALLBACKA) {
    758 //      TRACE (treeview,"LPSTR_TEXTCALLBACK\n");
     787      TRACE("LPSTR_TEXTCALLBACK\n");
    759788      TREEVIEW_SendDispInfoNotify (hwnd, wineItem, TVN_GETDISPINFO, TVIF_TEXT);
    760789    }
    761790
     791/* Yep, there are some things that need to be straightened out here.
     792   Removing the comments around the setTextColor does not give the right
     793   results. Dito FillRect.
     794*/
     795
     796       
     797/*    GetTextExtentPoint32A (hdc, wineItem->pszText,
     798                                        strlen (wineItem->pszText), &size); */
     799       
     800/*    FillRect ( hdc, &wineItem->text, GetSysColorBrush (infoPtr->clrBk));
     801 */
     802   
     803
     804    if (!(cditem & CDRF_NOTIFYPOSTPAINT) &&
     805        (wineItem->state & (TVIS_SELECTED | TVIS_DROPHILITED)) ) {
     806        oldBkMode    = SetBkMode  (hdc, OPAQUE);
     807        oldBkColor   = SetBkColor  (hdc, GetSysColor( COLOR_HIGHLIGHT));
     808        oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_HIGHLIGHTTEXT));
     809        } else {
     810        oldBkMode    = SetBkMode  (hdc, TRANSPARENT);
     811                oldBkColor   = SetBkColor (hdc, infoPtr->clrBk);
     812 /*         oldTextColor = SetTextColor(hdc, infoPtr->clrText);  */
     813        }
     814
     815
     816
    762817    /* Draw it */
    763     DrawTextA (
    764       hdc,
    765       wineItem->pszText,
    766       lstrlenA(wineItem->pszText),
    767       &wineItem->text,
    768       uTextJustify | DT_VCENTER | DT_SINGLELINE );
     818    DrawTextA ( hdc,
     819      wineItem->pszText,
     820      lstrlenA(wineItem->pszText),
     821      &wineItem->text,
     822      uTextJustify | DT_VCENTER | DT_SINGLELINE );
    769823
    770824    /* Obtain the text coordinate */
    771825    DrawTextA (
    772       hdc,
    773       wineItem->pszText,
    774       lstrlenA(wineItem->pszText),
    775       &wineItem->text,
    776       uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT);
     826      hdc, 
     827      wineItem->pszText, 
     828      lstrlenA(wineItem->pszText), 
     829      &wineItem->text, 
     830      uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT); 
    777831
    778832    /* Restore the hdc state */
     
    785839
    786840    /* Draw the box arround the selected item */
    787     if (wineItem->state & TVIS_SELECTED )
     841    if (wineItem->state & TVIS_SELECTED ) 
    788842    {
    789       HPEN  hnewPen     = CreatePen(PS_DOT, 0, GetSysColor(COLOR_WINDOWTEXT) );
    790       HPEN  hOldPen     = SelectObject( hdc, hnewPen );
     843      HPEN  hNewPen     = CreatePen(PS_DOT, 0, GetSysColor(COLOR_WINDOWTEXT) );
     844      HPEN  hOldPen     = SelectObject( hdc, hNewPen );
    791845      POINT points[4];
    792 
     846     
    793847      points[0].x = wineItem->text.left-1;
    794       points[0].y = wineItem->text.top+1;
     848      points[0].y = wineItem->text.top+1; 
    795849      points[1].x = wineItem->text.right;
    796       points[1].y = wineItem->text.top+1;
     850      points[1].y = wineItem->text.top+1; 
    797851      points[2].x = wineItem->text.right;
    798       points[2].y = wineItem->text.bottom;
     852      points[2].y = wineItem->text.bottom; 
    799853      points[3].x = wineItem->text.left-1;
    800854      points[3].y = wineItem->text.bottom;
    801855
    802       Polyline (hdc,points,4);
    803 
    804       DeleteObject(hnewPen);
     856      Polyline (hdc,points,4); 
     857
     858      DeleteObject(hNewPen);
    805859      SelectObject(hdc, hOldPen);
    806860    }
    807861  }
    808862
    809   if (cditem & CDRF_NOTIFYPOSTPAINT)
    810                 TREEVIEW_SendCustomDrawItemNotify (hwnd, hdc, wineItem, CDDS_ITEMPOSTPAINT);
     863  /* Draw insertion mark if necessary */
     864
     865  if (infoPtr->insertMarkItem)
     866                TRACE ("item:%d,mark:%d\n", (int)wineItem->hItem,
     867                               (int) infoPtr->insertMarkItem);
     868  if (wineItem->hItem==infoPtr->insertMarkItem) {
     869                HPEN hNewPen, hOldPen;
     870                int offset;
     871
     872                hNewPen = CreatePen(PS_SOLID, 2, infoPtr->clrInsertMark);
     873                hOldPen = SelectObject( hdc, hNewPen );
     874       
     875                if (infoPtr->insertBeforeorAfter)
     876                        offset=wineItem->text.top+1;
     877                else
     878                        offset=wineItem->text.bottom-1;
     879
     880                MoveToEx (hdc, wineItem->text.left, offset-3, NULL);
     881                LineTo (hdc, wineItem->text.left, offset+3);
     882
     883                MoveToEx (hdc, wineItem->text.left, offset, NULL);
     884                LineTo (hdc, r.right-2, offset);
     885
     886                MoveToEx (hdc, r.right-2, offset+3, NULL);
     887                LineTo (hdc, r.right-2, offset-3);
     888
     889        DeleteObject(hNewPen);
     890
     891        SelectObject(hdc, hOldPen);
     892        }
     893
     894  if (cditem & CDRF_NOTIFYPOSTPAINT) {
     895                cditem=TREEVIEW_SendCustomDrawItemNotify
     896                       (hwnd, hdc, wineItem, CDDS_ITEMPOSTPAINT);
     897                TRACE("postpaint:cditem-app returns 0x%x\n",cditem);
     898        }
    811899
    812900  SelectObject (hdc, hOldFont);
     
    832920
    833921  /*
    834    * retrive the item ptr
     922   * retrieve the item ptr
    835923   */
    836924  iItem = (HTREEITEM *) lParam;
     
    909997
    910998  if (tvItem->mask & TVIF_STATE) {
    911         wineItem->state=tvItem->state & tvItem->stateMask;
     999                TRACE ("prevstate,state,mask:%x,%x,%x\n",wineItem->state,tvItem->state,
     1000tvItem->stateMask);
     1001        wineItem->state&= ~tvItem->stateMask;
     1002                wineItem->state|= (tvItem->state & tvItem->stateMask);
     1003                wineItem->stateMask|= tvItem->stateMask; 
    9121004  }
    9131005
     
    17641856          aChild = &infoPtr->items[(INT)infoPtr->TopRootItem];
    17651857
     1858        /* lookup the text if using LPSTR_TEXTCALLBACKs */
     1859        if (wineItem->pszText==LPSTR_TEXTCALLBACKA) {
     1860          TREEVIEW_SendDispInfoNotify (hwnd, wineItem, TVN_GETDISPINFO, TVIF_TEXT);
     1861        }
     1862
    17661863        /* Iterate the parent children to see where we fit in */
    17671864        while ( aChild != NULL )
    17681865        {
    1769           INT comp = strcmp(wineItem->pszText, aChild->pszText);
     1866          INT comp;
     1867
     1868          /* lookup the text if using LPSTR_TEXTCALLBACKs */
     1869          if (aChild->pszText==LPSTR_TEXTCALLBACKA) {
     1870            TREEVIEW_SendDispInfoNotify (hwnd, aChild, TVN_GETDISPINFO, TVIF_TEXT);
     1871          }
     1872
     1873          comp = strcmp(wineItem->pszText, aChild->pszText);
    17701874          if ( comp < 0 )  /* we are smaller than the current one */
    17711875          {
     
    21532257{
    21542258    TREEVIEW_INFO *infoPtr;
    2155         LOGFONTA logFont;
     2259        DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     2260        LOGFONTA logFont;
    21562261    TEXTMETRICA tm;
    2157         HDC hdc;
    2158 
    2159 //    TRACE (treeview,"wnd %x\n",hwnd);
     2262        HDC hdc;
     2263 
     2264    TRACE("wnd %x, style %lx\n",hwnd,dwStyle);
    21602265      /* allocate memory for info structure */
    2161       infoPtr = (TREEVIEW_INFO *) COMCTL32_Alloc (sizeof(TREEVIEW_INFO));
    2162 
    2163      SetWindowLongA( hwnd, 0, (DWORD)infoPtr);
     2266    infoPtr = (TREEVIEW_INFO *) COMCTL32_Alloc (sizeof(TREEVIEW_INFO));
     2267
     2268    SetWindowLongA( hwnd, 0, (DWORD)infoPtr);
    21642269
    21652270    if (infoPtr == NULL) {
    2166 //              ERR (treeview, "could not allocate info memory!\n");
    2167                 return 0;
     2271                ERR("could not allocate info memory!\n");
     2272                return 0;
    21682273    }
    21692274
    21702275    if ((TREEVIEW_INFO*) GetWindowLongA( hwnd, 0) != infoPtr) {
    2171 //              ERR (treeview, "pointer assignment error!\n");
    2172                 return 0;
     2276                ERR("pointer assignment error!\n");
     2277                return 0;
    21732278    }
    21742279
    2175         hdc=GetDC (hwnd);
     2280        hdc=GetDC (hwnd);
    21762281
    21772282    /* set default settings */
    21782283    infoPtr->uInternalStatus=0;
    21792284    infoPtr->uNumItems=0;
    2180     infoPtr->clrBk = GetSysColor (COLOR_WINDOW);
    2181     infoPtr->clrText = GetSysColor (COLOR_BTNTEXT);
     2285    infoPtr->clrBk   = GetSysColor (COLOR_WINDOW);
     2286    infoPtr->clrText = GetSysColor (COLOR_WINDOWTEXT);
    21822287    infoPtr->clrLine = GetSysColor (COLOR_WINDOWTEXT);
     2288    infoPtr->clrInsertMark = GetSysColor (COLOR_BTNTEXT);
    21832289    infoPtr->cy = 0;
    21842290    infoPtr->cx = 0;
     
    21862292    infoPtr->himlNormal = NULL;
    21872293    infoPtr->himlState = NULL;
    2188     infoPtr->uItemHeight = -1;
     2294        infoPtr->uItemHeight = -1;
    21892295    GetTextMetricsA (hdc, &tm);
    21902296    infoPtr->hFont = GetStockObject (DEFAULT_GUI_FONT);
    2191     GetObjectA (infoPtr->hFont, sizeof (LOGFONTA), &logFont);
    2192     logFont.lfWeight=FW_BOLD;
     2297        GetObjectA (infoPtr->hFont, sizeof (LOGFONTA), &logFont);
     2298        logFont.lfWeight=FW_BOLD;
    21932299    infoPtr->hBoldFont = CreateFontIndirectA (&logFont);
    2194 
     2300   
    21952301    infoPtr->items = NULL;
    21962302    infoPtr->selectedItem=0;
    2197     infoPtr->clrText=-1;        /* use system color */
     2303    infoPtr->clrText=-1;        /* use system color */
    21982304    infoPtr->dropItem=0;
     2305        infoPtr->insertMarkItem=0;
     2306        infoPtr->insertBeforeorAfter=0;
    21992307    infoPtr->pCallBackSort=NULL;
    2200     infoPtr->uScrollTime = 300; /* milliseconds */
    2201 
    2202     // @@@PH 1999/11/05
    2203     infoPtr->wpEditOrig = NULL; /* no subclass */
    2204 
    2205 /*
    2206     infoPtr->hwndNotify = GetParent32 (hwnd);
    2207     infoPtr->bTransparent = ( GetWindowLongA( hwnd, GWL_STYLE) & TBSTYLE_FLAT);
    2208 */
    2209 
    2210         infoPtr->hwndToolTip=0;
    2211     if (!( GetWindowLongA( hwnd, GWL_STYLE) & TVS_NOTOOLTIPS)) {   /* Create tooltip control */
    2212                 TTTOOLINFOA ti;
    2213 
    2214                 infoPtr->hwndToolTip =
    2215                         CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
     2308    infoPtr->uScrollTime = 300;  /* milliseconds */
     2309
     2310        infoPtr->hwndToolTip=0;
     2311    if (!(dwStyle & TVS_NOTOOLTIPS)) {   /* Create tooltip control */
     2312                TTTOOLINFOA ti;
     2313
     2314                infoPtr->hwndToolTip = 
     2315                        CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
    22162316                   CW_USEDEFAULT, CW_USEDEFAULT,
    22172317                   CW_USEDEFAULT, CW_USEDEFAULT,
     
    22312331        }
    22322332
    2233                 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     2333                ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    22342334        ti.cbSize   = sizeof(TTTOOLINFOA);
    22352335        ti.uFlags   = TTF_IDISHWND | TTF_TRACK | TTF_TRANSPARENT ;
     
    22422342    }
    22432343
    2244         infoPtr->hwndEdit = CreateWindowExA (
    2245                           WS_EX_LEFT,
     2344   // @@@PH 1999/11/05
     2345    infoPtr->wpEditOrig = NULL; /* no subclass */
     2346
     2347        infoPtr->hwndEdit = CreateWindowExA (
     2348                          WS_EX_LEFT,
    22462349                          "EDIT",
    22472350                          0,
    2248                           WS_CHILD | WS_BORDER | ES_AUTOHSCROLL |
     2351                          WS_CHILD | WS_BORDER | ES_AUTOHSCROLL | 
    22492352                          ES_WANTRETURN | ES_LEFT,
    22502353                          0, 0, 0, 0,
    2251                           hwnd,
     2354                          hwnd, 
    22522355                          0,0,0); /* FIXME: (HMENU)IDTVEDIT,pcs->hInstance,0);*/
    22532356
    22542357  SendMessageA ( infoPtr->hwndEdit, WM_SETFONT, infoPtr->hFont, FALSE);
    2255         infoPtr->wpEditOrig = (WNDPROC)SetWindowLongA (
     2358        infoPtr->wpEditOrig = (WNDPROC)SetWindowLongA (
    22562359                                    infoPtr->hwndEdit,
    2257                                     GWL_WNDPROC,
    2258                                     (LONG) TREEVIEW_Edit_SubclassProc);
    2259 
     2360                                    GWL_WNDPROC,
     2361                                                                (LONG) TREEVIEW_Edit_SubclassProc);
     2362
     2363  if (dwStyle & TVS_CHECKBOXES) {       
     2364                HBITMAP hbmLoad;
     2365                int nIndex;
     2366
     2367                infoPtr->himlState =
     2368             ImageList_Create (16, 16,ILC_COLOR|ILC_MASK, 15, 1);
     2369
     2370                hbmLoad = LoadBitmapA (COMCTL32_hModule, MAKEINTRESOURCEA(IDT_CHECK));
     2371                TRACE ("%x\n",hbmLoad);
     2372        nIndex = ImageList_AddMasked (infoPtr->himlState, hbmLoad, CLR_DEFAULT);
     2373                TRACE ("%d\n",nIndex);
     2374                DeleteObject (hbmLoad);
     2375        }
    22602376  ReleaseDC (hwnd, hdc);
    22612377  return 0;
     
    25402656 DWORD dwDrawStage,dwItemSpec;
    25412657 UINT uItemState;
     2658 INT retval;
    25422659
    25432660 dwDrawStage=CDDS_ITEM | uItemDrawState;
     
    25692686//                dwDrawStage, hdc, dwItemSpec, uItemState);
    25702687
    2571  return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY,
    2572                                (WPARAM) GetWindowLongA( hwnd, GWL_ID), (LPARAM)&nmcdhdr);
     2688 retval=SendMessageA (GetParent (hwnd), WM_NOTIFY,
     2689                 (WPARAM) GetWindowLongA( hwnd, GWL_ID), (LPARAM)&nmcdhdr);
     2690
     2691 infoPtr->clrText=nmcdhdr.clrText;
     2692 infoPtr->clrBk  =nmcdhdr.clrTextBk;
     2693 return (BOOL) retval;
    25732694}
    25742695
     
    27642885
    27652886  wineItem=TREEVIEW_HitTestPoint (hwnd, lpht->pt);
    2766   if (!wineItem) {
     2887  if (!wineItem) { 
    27672888    lpht->flags=TVHT_NOWHERE;
    27682889    return 0;
    27692890  }
    27702891
    2771   /* FIXME: implement other flags
    2772    * Assign the appropriate flags depending on the click location
    2773    * Intitialize flags before to "|=" it...
    2774    */
    27752892  lpht->flags=0;
    27762893
    2777   if (x < wineItem->expandBox.left)
    2778   {
     2894  if (x < wineItem->expandBox.left) {
    27792895    lpht->flags |= TVHT_ONITEMINDENT;
    2780   }
    2781   else if ( ( x >= wineItem->expandBox.left) &&
    2782             ( x <= wineItem->expandBox.right))
    2783   {
     2896        goto done;
     2897  }
     2898  if ( PtInRect ( &wineItem->expandBox, lpht->pt)) {
    27842899    lpht->flags |= TVHT_ONITEMBUTTON;
    2785   }
    2786   else if (x < wineItem->rect.right)
    2787   {
    2788     lpht->flags |= TVHT_ONITEMLABEL;
    2789   }
    2790   else
    2791   {
    2792     lpht->flags|=TVHT_ONITEMRIGHT;
    2793   }
    2794 
     2900        goto done;
     2901  }
     2902  if ( PtInRect ( &wineItem->bitmap, lpht->pt)) {
     2903        lpht->flags |= TVHT_ONITEMICON;
     2904    goto done;
     2905  }
     2906  if ( PtInRect ( &wineItem->statebitmap, lpht->pt)) {
     2907        lpht->flags |= TVHT_ONITEMSTATEICON;
     2908    goto done;
     2909  }
     2910  if ( PtInRect ( &wineItem->text, lpht->pt)) {
     2911    lpht->flags |= TVHT_ONITEMLABEL;   
     2912        goto done;
     2913  }
     2914 
     2915  lpht->flags|=TVHT_ONITEMRIGHT;
     2916 
     2917
     2918done:
    27952919  lpht->hItem=wineItem->hItem;
     2920  TRACE ("(%ld,%ld):result %x\n",lpht->pt.x,lpht->pt.y,lpht->flags);
    27962921
    27972922  return (LRESULT) wineItem->hItem;
     
    29183043  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    29193044  INT           iItem;
    2920   TREEVIEW_ITEM *editItem;
     3045  TREEVIEW_ITEM *wineItem;
    29213046  TVHITTESTINFO ht;
    2922 
     3047 
    29233048  ht.pt.x = (INT)LOWORD(lParam);
    29243049  ht.pt.y = (INT)HIWORD(lParam);
    2925 
    2926 //  TRACE (treeview,"\n");
     3050 
     3051  TRACE("\n");
    29273052
    29283053  /* Return true to cancel default behaviour */
     
    29323057  /* Get the item */
    29333058  iItem = TREEVIEW_HitTest (hwnd, (LPARAM) &ht);
    2934   if (!iItem)
     3059  TRACE ("%d\n",iItem);
     3060  if (!iItem)
    29353061    return 0;
    29363062
    2937   editItem = TREEVIEW_ValidItem(infoPtr, (HTREEITEM)iItem);
    2938 
     3063  wineItem = TREEVIEW_ValidItem(infoPtr, (HTREEITEM)iItem);
     3064 
    29393065  infoPtr->uInternalStatus &= ~(TV_LDRAG | TV_LDRAGGING);
    29403066
    2941   /*
    2942    * If the style allow editing and the node is already selected
     3067  /* 
     3068   * If the style allow editing and the node is already selected 
    29433069   * and the click occured on the item label...
    29443070   */
    2945   if ( ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_EDITLABELS ) &&
    2946        ( editItem->state & TVIS_SELECTED ) &&
     3071  if ( ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_EDITLABELS ) && 
     3072       ( wineItem->state & TVIS_SELECTED ) &&
    29473073       ( ht.flags & TVHT_ONITEMLABEL ))
    29483074  {
    29493075    if ( infoPtr->editItem == 0 ) /* If we are not curently editing */
    29503076    {
    2951                 if ( TREEVIEW_SendDispInfoNotify(  /* Return true to cancel edition */
    2952               hwnd,
    2953               editItem,
    2954               TVN_BEGINLABELEDIT,
     3077                if ( TREEVIEW_SendDispInfoNotify(  /* Return true to cancel edition */
     3078              hwnd, 
     3079              wineItem,
     3080              TVN_BEGINLABELEDIT, 
    29553081              0))
    29563082      {
    2957         return 0;
     3083        return 0; 
    29583084      }
    2959 
    2960 //              TRACE(treeview,"Edit started for %s.\n", editItem->pszText);
    2961                 infoPtr->editItem = editItem->hItem;
    2962 
    2963                 SetWindowPos (
    2964         infoPtr->hwndEdit,
    2965         HWND_TOP,
    2966         editItem->text.left - 2,
    2967         editItem->text.top  - 1,
    2968         editItem->text.right  - editItem->text.left + 20 ,
    2969         editItem->text.bottom - editItem->text.top  + 3,
     3085 
     3086                TRACE("Edit started for %s.\n", wineItem->pszText);
     3087                infoPtr->editItem = wineItem->hItem;
     3088 
     3089                SetWindowPos (
     3090        infoPtr->hwndEdit, 
     3091        HWND_TOP, 
     3092        wineItem->text.left - 2,
     3093        wineItem->text.top  - 1,
     3094        wineItem->text.right  - wineItem->text.left + 20 ,
     3095        wineItem->text.bottom - wineItem->text.top  + 3,
    29703096        SWP_DRAWFRAME );
    2971 
    2972                 SetWindowTextA( infoPtr->hwndEdit, editItem->pszText );
     3097 
     3098                SetWindowTextA( infoPtr->hwndEdit, wineItem->pszText );
    29733099      SendMessageA  ( infoPtr->hwndEdit, EM_SETSEL, 0, -1 );
    2974                 SetFocus      ( infoPtr->hwndEdit);
    2975       ShowWindow    ( infoPtr->hwndEdit, SW_SHOW);
     3100                SetFocus      ( infoPtr->hwndEdit);
     3101      ShowWindow    ( infoPtr->hwndEdit, SW_SHOW); 
    29763102    }
    29773103  }
     
    29823108  else if ( ht.flags & (TVHT_ONITEMLABEL | TVHT_ONITEMICON))
    29833109  {
    2984     TREEVIEW_DoSelectItem (
    2985       hwnd,
    2986       TVGN_CARET,
    2987       (HTREEITEM)iItem,
    2988       TVC_BYMOUSE);
    2989   }
    2990 
     3110    TREEVIEW_DoSelectItem ( hwnd, TVGN_CARET, (HTREEITEM)iItem, TVC_BYMOUSE);
     3111  }
     3112
     3113  if (ht.flags & TVHT_ONITEMSTATEICON) {
     3114        DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     3115
     3116       
     3117        if (dwStyle & TVS_CHECKBOXES) {      /* TVS_CHECKBOXES requires _us_ */
     3118                        int state;                                       /* to toggle the current state */
     3119                        state=1-(wineItem->state>>12);
     3120                        TRACE ("state:%x\n", state);
     3121                        wineItem->state&= ~TVIS_STATEIMAGEMASK;
     3122                        wineItem->state|=state<<12;
     3123                        TRACE ("state:%x\n", wineItem->state);
     3124                        TREEVIEW_QueueRefresh (hwnd);
     3125                }
     3126  }
    29913127  return 0;
    29923128}
     
    30693205
    30703206 if (!dragItem) return 0;
     3207
     3208 if (dragItem->pszText==LPSTR_TEXTCALLBACKA) {
     3209     TREEVIEW_SendDispInfoNotify (hwnd, dragItem, TVN_GETDISPINFO, TVIF_TEXT);
     3210 }
    30713211 itemtxt=dragItem->pszText;
    30723212
     
    36463786                return TREEVIEW_SetToolTips (hwnd, wParam);
    36473787
    3648         case TVM_SETINSERTMARK:
    3649 //                      FIXME (treeview, "Unimplemented msg TVM_SETINSERTMARK\n");
    3650                 return 0;
     3788        case TVM_SETINSERTMARK:
     3789                return TREEVIEW_SetInsertMark (hwnd,wParam, lParam);
    36513790
    36523791        case TVM_SETITEMHEIGHT:
     
    36833822                return TREEVIEW_SetLineColor (hwnd,wParam, lParam);
    36843823
    3685         case TVM_SETINSERTMARKCOLOR:
    3686 //                      FIXME (treeview, "Unimplemented msg TVM_SETINSERTMARKCOLOR\n");
    3687                 return 0;
    3688 
    3689         case TVM_SETUNICODEFORMAT:
    3690 //                      FIXME (treeview, "Unimplemented msg TVM_SETUNICODEFORMAT\n");
    3691                 return 0;
     3824        case TVM_SETINSERTMARKCOLOR:
     3825                return TREEVIEW_SetInsertMarkColor (hwnd,wParam, lParam);
     3826 
     3827        case TVM_GETINSERTMARKCOLOR:
     3828                return TREEVIEW_GetInsertMarkColor (hwnd,wParam, lParam);
    36923829
    36933830        case TVM_GETUNICODEFORMAT:
Note: See TracChangeset for help on using the changeset viewer.