Ignore:
Timestamp:
Nov 2, 1999, 10:44:04 PM (26 years ago)
Author:
achimha
Message:

comctl32 merged with WINE 991031

File:
1 edited

Legend:

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

    r1444 r1565  
    1 /* $Id: treeview.c,v 1.12 1999-10-25 19:37:21 phaller Exp $ */
     1/* $Id: treeview.c,v 1.13 1999-11-02 21:44:04 achimha Exp $ */
    22/* Treeview control
    33 *
     
    4242 */
    4343
     44/* WINE 991031 level */
     45
    4446#include <string.h>
    4547#include "winbase.h"
     
    495497{
    496498  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    497 
    498 //  TRACE (treeview,"\n");
    499   return (LRESULT) infoPtr->clrText;
     499       
     500  TRACE("\n");
     501  return (LRESULT) infoPtr->clrBk;
    500502}
    501503
     
    506508  COLORREF prevColor=infoPtr->clrBk;
    507509
    508 //  TRACE (treeview,"\n");
     510  TRACE("\n");
    509511  infoPtr->clrBk=(COLORREF) lParam;
    510512  return (LRESULT) prevColor;
     
    515517{
    516518  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    517 
    518 //  TRACE (treeview,"\n");
    519   return (LRESULT) infoPtr->clrBk;
     519       
     520  TRACE("\n");
     521  return (LRESULT) infoPtr->clrText;
    520522}
    521523
     
    947949{
    948950    TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    949         TEXTMETRICA tm;
    950         HBRUSH hbrBk;
     951        TEXTMETRICA tm;
     952        HBRUSH hbrBk;
    951953    RECT rect;
    952         HDC hdc;
     954        HDC hdc;
    953955    INT iItem, indent, x, y, cx, height, itemHeight;
    954956    INT viewtop,viewbottom,viewleft,viewright;
    955957    TREEVIEW_ITEM *wineItem, *prevItem;
    956958
    957 //    TRACE (treeview,"\n");
    958 
    959         hdc=GetDC (hwnd);
     959    TRACE("\n");
     960
     961        hdc=GetDC (hwnd);
    960962
    961963    if (infoPtr->Timer & TV_REFRESH_TIMER_SET) {
    962                 KillTimer (hwnd, TV_REFRESH_TIMER);
    963                 infoPtr->Timer &= ~TV_REFRESH_TIMER_SET;
     964                KillTimer (hwnd, TV_REFRESH_TIMER);
     965                infoPtr->Timer &= ~TV_REFRESH_TIMER_SET;
    964966    }
    965967
    966 
     968   
    967969    GetClientRect (hwnd, &rect);
    968970    if ((rect.left-rect.right ==0) || (rect.top-rect.bottom==0)) return;
    969971
    970     infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify
    971                                                 (hwnd, CDDS_PREPAINT, hdc, rect);
    972 
    973         if (infoPtr->cdmode==CDRF_SKIPDEFAULT) {
    974                   ReleaseDC (hwnd, hdc);
    975                   return;
    976         }
    977 
    978         infoPtr->uVisibleHeight= rect.bottom-rect.top;
    979         infoPtr->uVisibleWidth= rect.right-rect.left;
     972    infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify 
     973                                                (hwnd, CDDS_PREPAINT, hdc, rect);
     974
     975        if (infoPtr->cdmode==CDRF_SKIPDEFAULT) {
     976                  ReleaseDC (hwnd, hdc);
     977                  return;
     978        }
     979
     980        infoPtr->uVisibleHeight= rect.bottom-rect.top;
     981        infoPtr->uVisibleWidth= rect.right-rect.left;
    980982
    981983    viewtop=infoPtr->cy;
     
    984986    viewright=infoPtr->cx + rect.right-rect.left;
    985987
    986 
    987 
    988988    /* draw background */
    989 
    990     hbrBk = GetSysColorBrush (COLOR_WINDOW);
     989   
     990    hbrBk = CreateSolidBrush (infoPtr->clrBk);
    991991    FillRect(hdc, &rect, hbrBk);
    992 
     992    DeleteObject(hbrBk);
    993993
    994994    iItem=(INT)infoPtr->TopRootItem;
     
    997997    indent=0;
    998998    x=y=0;
    999 //    TRACE (treeview, "[%d %d %d %d]\n",viewtop,viewbottom,viewleft,viewright);
     999    TRACE("[%d %d %d %d]\n",viewtop,viewbottom,viewleft,viewright);
    10001000
    10011001    while (iItem) {
    1002                 prevItem=wineItem;
     1002                prevItem=wineItem;
    10031003        wineItem= & infoPtr->items[iItem];
    1004                 wineItem->iLevel=indent;
     1004                wineItem->iLevel=indent;
    10051005
    10061006        ImageList_GetIconSize (infoPtr->himlNormal, &cx, &itemHeight);
    10071007        if (infoPtr->uItemHeight>itemHeight)
    1008                     itemHeight=infoPtr->uItemHeight;
    1009 
    1010             GetTextMetricsA (hdc, &tm);
    1011             if ((tm.tmHeight + tm.tmExternalLeading) > itemHeight)
    1012                      itemHeight=tm.tmHeight + tm.tmExternalLeading;
    1013 
    1014         infoPtr->uRealItemHeight=itemHeight;
     1008                    itemHeight=infoPtr->uItemHeight;
     1009
     1010            GetTextMetricsA (hdc, &tm);
     1011            if ((tm.tmHeight + tm.tmExternalLeading) > itemHeight)
     1012                     itemHeight=tm.tmHeight + tm.tmExternalLeading;
     1013
     1014        infoPtr->uRealItemHeight=itemHeight;   
    10151015
    10161016
    10171017/* FIXME: remove this in later stage  */
    10181018/*
    1019 //              if (wineItem->pszText!=LPSTR_TEXTCALLBACK32A)
    1020 //              TRACE (treeview, "%d %d [%d %d %d %d] (%s)\n",y,x,
    1021 //                      wineItem->rect.top, wineItem->rect.bottom,
    1022 //                      wineItem->rect.left, wineItem->rect.right,
    1023 //                      wineItem->pszText);
    1024 //              else
    1025 //              TRACE (treeview, "%d [%d %d %d %d] (CALLBACK)\n",
    1026 //                              wineItem->hItem,
    1027 //                              wineItem->rect.top, wineItem->rect.bottom,
    1028 //                              wineItem->rect.left, wineItem->rect.right);
     1019                if (wineItem->pszText!=LPSTR_TEXTCALLBACK32A)
     1020                TRACE (treeview, "%d %d [%d %d %d %d] (%s)\n",y,x,
     1021                        wineItem->rect.top, wineItem->rect.bottom,
     1022                        wineItem->rect.left, wineItem->rect.right,
     1023                        wineItem->pszText);
     1024                else
     1025                TRACE (treeview, "%d [%d %d %d %d] (CALLBACK)\n",
     1026                                wineItem->hItem,
     1027                                wineItem->rect.top, wineItem->rect.bottom,
     1028                                wineItem->rect.left, wineItem->rect.right);
    10291029*/
    10301030
    1031                 height=itemHeight * wineItem->iIntegral +1;
    1032                 if ((y >= viewtop) && (y <= viewbottom) &&
    1033                 (x >= viewleft  ) && (x <= viewright)) {
    1034                                 wineItem->visible = TRUE;
    1035                         wineItem->rect.top = y - infoPtr->cy + rect.top;
    1036                         wineItem->rect.bottom = wineItem->rect.top + height ;
    1037                         wineItem->rect.left = x - infoPtr->cx + rect.left;
    1038                         wineItem->rect.right = rect.right;
    1039                         if (!infoPtr->firstVisible)
    1040                                 infoPtr->firstVisible=wineItem->hItem;
    1041                 TREEVIEW_DrawItem (hwnd, hdc, wineItem);
    1042                 }
    1043                 else {
    1044                         wineItem->visible   = FALSE;
    1045                         wineItem->rect.left = wineItem->rect.top    = 0;
    1046                         wineItem->rect.right= wineItem->rect.bottom = 0;
    1047                         wineItem->text.left = wineItem->text.top    = 0;
    1048                         wineItem->text.right= wineItem->text.bottom = 0;
    1049                 }
    1050 
    1051                 /* look up next item */
    1052 
    1053                 if ((wineItem->firstChild) && (wineItem->state & TVIS_EXPANDED)) {
    1054                         iItem=(INT)wineItem->firstChild;
    1055                         indent++;
    1056                         x+=infoPtr->uIndent;
    1057                         if (x>infoPtr->uTotalWidth)
    1058                                 infoPtr->uTotalWidth=x;
    1059                 }
    1060                 else {
    1061                         iItem=(INT)wineItem->sibling;
    1062                         while ((!iItem) && (indent>0)) {
    1063                                 indent--;
    1064                                 x-=infoPtr->uIndent;
    1065                                 prevItem=wineItem;
    1066                                 wineItem=&infoPtr->items[(INT)wineItem->parent];
    1067                                 iItem=(INT)wineItem->sibling;
    1068                         }
    1069                 }
     1031                height=itemHeight * wineItem->iIntegral +1;
     1032                if ((y >= viewtop) && (y <= viewbottom) &&
     1033                (x >= viewleft  ) && (x <= viewright)) {
     1034                                wineItem->visible = TRUE;
     1035                        wineItem->rect.top = y - infoPtr->cy + rect.top;
     1036                        wineItem->rect.bottom = wineItem->rect.top + height ;
     1037                        wineItem->rect.left = x - infoPtr->cx + rect.left;
     1038                        wineItem->rect.right = rect.right;
     1039                        if (!infoPtr->firstVisible)
     1040                                infoPtr->firstVisible=wineItem->hItem;
     1041                TREEVIEW_DrawItem (hwnd, hdc, wineItem);
     1042                }
     1043                else {
     1044                        wineItem->visible   = FALSE;
     1045                        wineItem->rect.left = wineItem->rect.top    = 0;
     1046                        wineItem->rect.right= wineItem->rect.bottom = 0;
     1047                        wineItem->text.left = wineItem->text.top    = 0;
     1048                        wineItem->text.right= wineItem->text.bottom = 0;
     1049                }
     1050
     1051                /* look up next item */
     1052       
     1053                if ((wineItem->firstChild) && (wineItem->state & TVIS_EXPANDED)) {
     1054                        iItem=(INT)wineItem->firstChild;
     1055                        indent++;
     1056                        x+=infoPtr->uIndent;
     1057                        if (x>infoPtr->uTotalWidth)     
     1058                                infoPtr->uTotalWidth=x;
     1059                }
     1060                else {
     1061                        iItem=(INT)wineItem->sibling;
     1062                        while ((!iItem) && (indent>0)) {
     1063                                indent--;
     1064                                x-=infoPtr->uIndent;
     1065                                prevItem=wineItem;
     1066                                wineItem=&infoPtr->items[(INT)wineItem->parent];
     1067                                iItem=(INT)wineItem->sibling;
     1068                        }
     1069                }
    10701070        y +=height;
    1071     }                           /* while */
     1071    }                           /* while */
    10721072
    10731073/* FIXME: infoPtr->uTotalWidth should also take item label into account */
     
    10761076    infoPtr->uTotalHeight=y;
    10771077    if (y >= (viewbottom-viewtop)) {
    1078                 if (!(infoPtr->uInternalStatus & TV_VSCROLL))
    1079                         ShowScrollBar (hwnd, SB_VERT, TRUE);
    1080                 infoPtr->uInternalStatus |=TV_VSCROLL;
    1081                 SetScrollRange (hwnd, SB_VERT, 0,
    1082                                         y - infoPtr->uVisibleHeight, FALSE);
    1083                 SetScrollPos (hwnd, SB_VERT, infoPtr->cy, TRUE);
    1084         }
     1078                if (!(infoPtr->uInternalStatus & TV_VSCROLL))
     1079                        ShowScrollBar (hwnd, SB_VERT, TRUE);
     1080                infoPtr->uInternalStatus |=TV_VSCROLL;
     1081                SetScrollRange (hwnd, SB_VERT, 0,
     1082                                        y - infoPtr->uVisibleHeight, FALSE);
     1083                SetScrollPos (hwnd, SB_VERT, infoPtr->cy, TRUE);
     1084        }
    10851085    else {
    1086                 if (infoPtr->uInternalStatus & TV_VSCROLL)
    1087                         ShowScrollBar (hwnd, SB_VERT, FALSE);
    1088                 infoPtr->uInternalStatus &= ~TV_VSCROLL;
    1089         }
    1090 
    1091 
    1092         if (infoPtr->cdmode & CDRF_NOTIFYPOSTPAINT)
    1093         infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify
    1094                                                                 (hwnd, CDDS_POSTPAINT, hdc, rect);
     1086                if (infoPtr->uInternalStatus & TV_VSCROLL)
     1087                        ShowScrollBar (hwnd, SB_VERT, FALSE);
     1088                infoPtr->uInternalStatus &= ~TV_VSCROLL;
     1089        }
     1090
     1091
     1092        if (infoPtr->cdmode & CDRF_NOTIFYPOSTPAINT)
     1093        infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify
     1094                                                                (hwnd, CDDS_POSTPAINT, hdc, rect);
    10951095
    10961096    ReleaseDC (hwnd, hdc);
    1097 //    TRACE (treeview,"done\n");
     1097    TRACE("done\n");
    10981098}
    10991099
     
    17331733     switch ((DWORD) ptdi->hInsertAfter) {
    17341734                case (DWORD) TVI_FIRST:
     1735                        if (sibItem==wineItem) break;
    17351736                        if (wineItem->parent) {
    17361737                                wineItem->sibling=parentItem->firstChild;
Note: See TracChangeset for help on using the changeset viewer.