Changeset 1565 for trunk/src


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

comctl32 merged with WINE 991031

Location:
trunk/src/comctl32
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/comctl32.def

    r496 r1565  
    1 ; $Id: comctl32.def,v 1.11 1999-08-14 16:13:09 cbratschi Exp $
     1; $Id: comctl32.def,v 1.12 1999-11-02 21:44:01 achimha Exp $
    22LIBRARY COMCTL32 INITINSTANCE
    33DESCRIPTION 'COMCTL32 Common Controls Library'
     
    122122  StrToIntA           = _COMCTL32_StrToIntA@4      @357
    123123
     124  COMCTL32_StrCmpNIW  = _COMCTL32_StrCmpNIW@12     @361
     125
    124126  DPA_EnumCallback    = _DPA_EnumCallback@12       @385
    125127  DPA_DestroyCallback = _DPA_DestroyCallback@12    @386
  • trunk/src/comctl32/comctl32undoc.c

    r1058 r1565  
    1 /* $Id: comctl32undoc.c,v 1.12 1999-09-26 11:01:08 achimha Exp $ */
     1/* $Id: comctl32undoc.c,v 1.13 1999-11-02 21:44:01 achimha Exp $ */
    22/*
    33 * Undocumented functions from COMCTL32.DLL
     
    1212 */
    1313
    14 /* WINE 990923 level */
     14/* WINE 991031 level */
    1515
    1616/* CB: todo
     
    13341334    v = lpPtrs[(int)(l+r)/2];
    13351335    do {
    1336         while ((pfnCompare)(lpPtrs[i], v, lParam) > 0) i++;
    1337         while ((pfnCompare)(lpPtrs[j], v, lParam) < 0) j--;
     1336        while ((pfnCompare)(lpPtrs[i], v, lParam) < 0) i++;
     1337        while ((pfnCompare)(lpPtrs[j], v, lParam) > 0) j--;
    13381338        if (i <= j)
    13391339        {
     
    18511851
    18521852/**************************************************************************
     1853 * StrCmpNIW [COMCTL32.361]
     1854 *
     1855 */
     1856INT WINAPI COMCTL32_StrCmpNIW( LPCWSTR lpStr1, LPCWSTR lpStr2, int nChar) {
     1857//  FIXME("(%s, %s, %i): stub\n", debugstr_w(lpStr1), debugstr_w(lpStr2), nChar);
     1858  return 0;
     1859}
     1860
     1861/**************************************************************************
    18531862 * StrRChrA [COMCTL32.351]
    18541863 *
  • trunk/src/comctl32/listview.c

    r1431 r1565  
    3434 *   LISTVIEW_GetISearchString : not implemented
    3535 *   LISTVIEW_GetBkImage : not implemented
    36  *   LISTVIEW_EditLabel : REPORT (need to implement a timer)
    3736 *   LISTVIEW_GetColumnOrderArray : not implemented
    3837 *   LISTVIEW_SetColumnOrderArray : not implemented
     
    4443 */
    4544
    46 /* WINE 990923 level */
     45/* WINE 991031 level */
    4746
    4847#include <string.h>
     
    8079/* default column width for items in list display mode */
    8180#define DEFAULT_COLUMN_WIDTH 96
     81
     82/* Increment size of the horizontal scroll bar */
     83#define REPORT_HSCROLL_INC_SIZE 10
    8284
    8385/*
     
    9193/* retrieve the number of items in the listview */
    9294#define GETITEMCOUNT(infoPtr) ((infoPtr)->hdpaItems->nItemCount)
     95
     96/* Some definitions for inline edit control */   
     97typedef BOOL (*EditlblCallback)(HWND, LPSTR, DWORD);
     98
     99HWND CreateEditLabel(LPCSTR text, DWORD style, INT x, INT y,
     100        INT width, INT height, HWND parent, HINSTANCE hinst,
     101        EditlblCallback EditLblCb, DWORD param);
     102 
     103typedef struct tagEDITLABEL_ITEM
     104{
     105    WNDPROC EditWndProc;
     106    DWORD param;
     107    EditlblCallback EditLblCb;
     108} EDITLABEL_ITEM;
    93109
    94110/*
     
    129145static BOOL LISTVIEW_ToggleSelection(HWND, INT);
    130146static VOID LISTVIEW_UnsupportedStyles(LONG lStyle);
    131 
    132 /***
    133  * DESCRIPTION:
    134  * Update the scrollbars. This functions should be called whenever
     147static HWND LISTVIEW_EditLabelA(HWND hwnd, INT nItem);
     148static BOOL LISTVIEW_EndEditLabel(HWND hwnd, LPSTR pszText, DWORD nItem);
     149static LRESULT LISTVIEW_Command(HWND hwnd, WPARAM wParam, LPARAM lParam);
     150
     151/*************************************************************************
     152 * LISTVIEW_UpdateHeaderSize [Internal]
     153 *
     154 * Function to resize the header control
     155 *
     156 * PARAMS
     157 *     hwnd             [I] handle to a window
     158 *     nNewScrollPos    [I] Scroll Pos to Set
     159 *     nOldScrollPos    [I] Previous Scroll Pos
     160 *
     161 * RETURNS
     162 *     nothing
     163 *
     164 * NOTES
     165 */
     166static VOID LISTVIEW_UpdateHeaderSize(HWND hwnd, INT nNewScrollPos, INT nOldScrollPos)
     167{
     168    LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
     169    INT nDiff = nOldScrollPos-nNewScrollPos;
     170    RECT winRect;
     171    POINT point[2];
     172
     173    GetWindowRect(infoPtr->hwndHeader, &winRect);
     174    point[0].x = winRect.left;
     175    point[0].y = winRect.top;
     176    point[1].x = winRect.right;
     177    point[1].y = winRect.bottom;
     178
     179    MapWindowPoints(HWND_DESKTOP, hwnd, point, 2);
     180    point[0].x += (nDiff * REPORT_HSCROLL_INC_SIZE );
     181    point[1].x -= point[0].x;
     182
     183    SetWindowPos(infoPtr->hwndHeader,0,
     184        point[0].x,point[0].y,point[1].x,point[1].y,
     185        SWP_NOZORDER | SWP_NOACTIVATE);
     186}
     187
     188/***
     189 * DESCRIPTION:
     190 * Update the scrollbars. This functions should be called whenever
    135191 * the content, size or view changes.
    136  *
     192 * 
    137193 * PARAMETER(S):
    138194 * [I] HWND : window handle
     
    143199static VOID LISTVIEW_UpdateScroll(HWND hwnd)
    144200{
    145   LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
     201  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 
    146202  LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
    147203  UINT uView =  lStyle & LVS_TYPEMASK;
     
    160216    {
    161217      /* calculate new scrollbar range */
    162       INT nHiddenItemCount = GETITEMCOUNT(infoPtr) - nCountPerPage;
    163       if (nHiddenItemCount % nCountPerColumn == 0)
    164       {
    165         scrollInfo.nMax = nHiddenItemCount / nCountPerColumn;
     218      if((GETITEMCOUNT(infoPtr) % nCountPerPage) == 0)
     219      {
     220          scrollInfo.nMax = GETITEMCOUNT(infoPtr) / nCountPerPage * LISTVIEW_GetCountPerRow(hwnd)-1;
    166221      }
    167222      else
    168223      {
    169         scrollInfo.nMax = nHiddenItemCount / nCountPerColumn + 1;
    170       }
    171 
     224          scrollInfo.nMax = (GETITEMCOUNT(infoPtr) / nCountPerPage)* LISTVIEW_GetCountPerRow(hwnd);
     225      }
     226     
    172227      scrollInfo.nPos = ListView_GetTopIndex(hwnd) / nCountPerColumn;
    173       /*scrollInfo.nPage = LISTVIEW_GetCountPerRow(hwnd);*/
    174       scrollInfo.fMask = SIF_RANGE | SIF_POS /*| SIF_PAGE*/;
     228      scrollInfo.nPage = LISTVIEW_GetCountPerRow(hwnd);
     229      scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
    175230      SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE);
    176231    }
     
    180235      if (lStyle & WS_HSCROLL)
    181236      {
    182         ShowScrollBar(hwnd, SB_HORZ, FALSE);
     237        ShowScrollBar(hwnd, SB_HORZ, FALSE);
    183238      }
    184239    }
     
    186241  else if (uView == LVS_REPORT)
    187242  {
     243    RECT clientRect;
    188244    /* update vertical scrollbar */
    189245    scrollInfo.nMin = 0;
    190     scrollInfo.nMax = GETITEMCOUNT(infoPtr) - LISTVIEW_GetCountPerColumn(hwnd);
     246    scrollInfo.nMax = GETITEMCOUNT(infoPtr) - 1;
    191247    scrollInfo.nPos = ListView_GetTopIndex(hwnd);
    192     /*scrollInfo.nPage = nCountPerColumn;*/
    193     scrollInfo.fMask = SIF_RANGE | SIF_POS /*| SIF_PAGE*/;
     248    scrollInfo.nPage = LISTVIEW_GetCountPerColumn(hwnd);
     249    scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
    194250    SetScrollInfo(hwnd, SB_VERT, &scrollInfo, TRUE);
    195251
    196252    /* update horizontal scrollbar */
    197 /*     if (infoPtr->nItemWidth > nListWidth) */
    198 /*     { */
    199 /*       scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; */
    200 /*       SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); */
    201 /*     } */
    202 
    203     /* horizontal scrolling has not been implemented yet! I experienced some
    204        problems when performing child window scrolling. */
     253    infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd);
     254    GetClientRect(hwnd, &clientRect);
     255
     256    if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) == FALSE)
     257    {
     258      scrollInfo.nPos = 0;
     259    }
     260    scrollInfo.nMin = 0;
     261    scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE  ;
     262    scrollInfo.nPage = (clientRect.right - clientRect.left) / REPORT_HSCROLL_INC_SIZE;
     263    scrollInfo.nMax = infoPtr->nItemWidth;
     264
     265    /* Check to see if we need the scroll bar */
     266    if(scrollInfo.nMax < 0)
     267    {
     268      scrollInfo.nMax = 0;
     269    }
     270    else
     271    {
     272      /* Even up the max */
     273      scrollInfo.nMax -= (scrollInfo.nMax % REPORT_HSCROLL_INC_SIZE);
     274      scrollInfo.nMax = (scrollInfo.nMax / REPORT_HSCROLL_INC_SIZE)-1;
     275    }
     276    /* Set the scroll pos to the max if the current scroll pos is greater */
     277    if((scrollInfo.nPos+scrollInfo.nPage) > scrollInfo.nMax
     278        && scrollInfo.nMax > scrollInfo.nPage)
     279    {
     280      UINT nOldScrollPos = scrollInfo.nPos;
     281      scrollInfo.nPos = scrollInfo.nMax;
     282      SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE);
     283      GetScrollInfo(hwnd, SB_HORZ, &scrollInfo);
     284      LISTVIEW_UpdateHeaderSize(hwnd, scrollInfo.nPos, nOldScrollPos);
     285    }
     286    else
     287    {
     288        SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE);
     289    }
    205290  }
    206291  else
     
    233318          scrollInfo.nPos = 0;
    234319        }
    235 
     320 
    236321        if (nHiddenWidth % nScrollPosWidth == 0)
    237322        {
    238           scrollInfo.nMax = nHiddenWidth / nScrollPosWidth;
     323          scrollInfo.nMax = nHiddenWidth / nScrollPosWidth; 
    239324        }
    240325        else
    241326        {
    242           scrollInfo.nMax = nHiddenWidth / nScrollPosWidth + 1;
    243         }
    244 
     327          scrollInfo.nMax = nHiddenWidth / nScrollPosWidth + 1; 
     328        }
     329         
    245330        scrollInfo.nMin = 0;
    246         /*scrollInfo.nPage = 10;*/
    247         scrollInfo.fMask = SIF_RANGE | SIF_POS /*| SIF_PAGE*/;
     331        scrollInfo.nPage = 10;
     332        scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
    248333        SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE);
    249334      }
     
    279364        if (nHiddenHeight % nScrollPosHeight == 0)
    280365        {
    281           scrollInfo.nMax = nHiddenHeight / nScrollPosHeight;
     366          scrollInfo.nMax = nHiddenHeight / nScrollPosHeight; 
    282367        }
    283368        else
    284369        {
    285           scrollInfo.nMax = nHiddenHeight / nScrollPosHeight + 1;
     370          scrollInfo.nMax = nHiddenHeight / nScrollPosHeight + 1; 
    286371        }
    287372
    288373        scrollInfo.nMin = 0;
    289         /*scrollInfo.nPage = 10;*/
    290         scrollInfo.fMask = SIF_RANGE | SIF_POS /*| SIF_PAGE*/;
     374        scrollInfo.nPage = 10;
     375        scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
    291376        SetScrollInfo(hwnd, SB_VERT, &scrollInfo, TRUE);
    292377      }
     
    17751860  }
    17761861
     1862  /* Don't bother painting item being edited */
     1863  if (infoPtr->lpeditItem && lvItem.state & LVIS_FOCUSED)
     1864      return;
     1865
    17771866  if ((lvItem.state & LVIS_SELECTED) && (infoPtr->bFocus != FALSE))
    17781867  {
     
    19222011 * DESCRIPTION:
    19232012 * Draws listview items when in report display mode.
    1924  *
    1925  * PARAMETER(S):
    1926  * [I] HWND : window handle
    1927  * [I] HDC : device context handle
     2013 * 
     2014 * PARAMETER(S):
     2015 * [I] HWND : window handle
     2016 * [I] HDC : device context handle 
    19282017 *
    19292018 * RETURN:
     
    19332022{
    19342023  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd,0);
     2024  SCROLLINFO scrollInfo;
    19352025  INT nDrawPosY = infoPtr->rcList.top;
    19362026  INT nColumnCount;
     
    19402030  INT nLast;
    19412031
     2032  ZeroMemory(&scrollInfo, sizeof(SCROLLINFO));
     2033  scrollInfo.cbSize = sizeof(SCROLLINFO);
     2034  scrollInfo.fMask = SIF_POS;
     2035
    19422036  nItem = ListView_GetTopIndex(hwnd);
    19432037
     
    19552049      rcItem.top = nDrawPosY;
    19562050      rcItem.bottom = rcItem.top + infoPtr->nItemHeight;
     2051
     2052      /* Offset the Scroll Bar Pos */
     2053      if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE)
     2054      {
     2055        rcItem.left -= (scrollInfo.nPos * REPORT_HSCROLL_INC_SIZE);
     2056        rcItem.right -= (scrollInfo.nPos * REPORT_HSCROLL_INC_SIZE);
     2057      }
     2058
    19572059      if (j == 0)
    19582060      {
    1959         LISTVIEW_DrawItem(hwnd, hdc, nItem, rcItem);
    1960       }
    1961       else
     2061        LISTVIEW_DrawItem(hwnd, hdc, nItem, rcItem); 
     2062      }
     2063      else 
    19622064      {
    19632065        LISTVIEW_DrawSubItem(hwnd, hdc, nItem, j, rcItem);
    19642066      }
    19652067    }
    1966 
     2068   
    19672069    nDrawPosY += infoPtr->nItemHeight;
    19682070  }
     
    20702172 * DESCRIPTION:
    20712173 * Draws listview items when in list display mode.
    2072  *
    2073  * PARAMETER(S):
    2074  * [I] HWND : window handle
    2075  * [I] HDC : device context handle
     2174 * 
     2175 * PARAMETER(S):
     2176 * [I] HWND : window handle
     2177 * [I] HDC : device context handle 
    20762178 *
    20772179 * RETURN:
     
    20862188  INT nColumnCount;
    20872189  INT nCountPerColumn;
    2088 
     2190  INT nItemWidth = LISTVIEW_GetItemWidth(hwnd);
     2191  INT nItemHeight = LISTVIEW_GetItemHeight(hwnd);
     2192 
    20892193  /* get number of fully visible columns */
    20902194  nColumnCount = LISTVIEW_GetColumnCount(hwnd);
     
    20992203        return;
    21002204
    2101       rcItem.top = j * infoPtr->nItemHeight;
    2102       rcItem.left = i * infoPtr->nItemWidth;
    2103       rcItem.bottom = rcItem.top + infoPtr->nItemHeight;
    2104       rcItem.right = rcItem.left + infoPtr->nItemWidth;
     2205      rcItem.top = j * nItemHeight;
     2206      rcItem.left = i * nItemWidth;
     2207      rcItem.bottom = rcItem.top + nItemHeight;
     2208      rcItem.right = rcItem.left + nItemWidth;
    21052209      LISTVIEW_DrawItem(hwnd, hdc, nItem, rcItem);
    21062210    }
     
    24592563 * DESCRIPTION:
    24602564 * Removes a column from the listview control.
    2461  *
     2565 * 
    24622566 * PARAMETER(S):
    24632567 * [I] HWND : window handle
     
    24732577  UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
    24742578  BOOL bResult = FALSE;
    2475 
     2579 
    24762580  if (Header_DeleteItem(infoPtr->hwndHeader, nColumn) != FALSE)
    24772581  {
    24782582    bResult = LISTVIEW_RemoveColumn(infoPtr->hdpaItems, nColumn);
     2583
     2584    /* Need to reset the item width when deleting a column */
     2585    infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd);
    24792586
    24802587    /* reset scroll parameters */
     
    25922699}
    25932700
    2594 /* LISTVIEW_EditLabel */
     2701/***
     2702 * DESCRIPTION:
     2703 * Return edit control handle of current edit label
     2704 *
     2705 * PARAMETER(S):
     2706 * [I] HWND : window handle
     2707 *
     2708 * RETURN:
     2709 *   SUCCESS : HWND
     2710 *   FAILURE : 0
     2711 */
     2712static LRESULT LISTVIEW_GetEditControl(hwnd)
     2713{
     2714  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
     2715  return infoPtr->hwndEdit;
     2716}
     2717
     2718
     2719/***
     2720 * DESCRIPTION:
     2721 * Callback implementation for editlabel control
     2722 *
     2723 * PARAMETER(S):
     2724 * [I] HWND : window handle
     2725 * [I] LPSTR : modified text
     2726 * [I] DWORD : item index
     2727 *
     2728 * RETURN:
     2729 *   SUCCESS : TRUE
     2730 *   FAILURE : FALSE
     2731 */
     2732
     2733static BOOL LISTVIEW_EndEditLabel(HWND hwnd, LPSTR pszText, DWORD nItem)
     2734{
     2735  NMLVDISPINFOA dispInfo;
     2736  LISTVIEW_ITEM *lpItem;
     2737  INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);
     2738  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
     2739  HDPA hdpaSubItems;
     2740 
     2741  ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOA));
     2742
     2743  if (NULL == (hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem)))
     2744          return FALSE;
     2745
     2746  if (NULL == (lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0)))
     2747          return FALSE;
     2748
     2749  dispInfo.hdr.hwndFrom = hwnd;
     2750  dispInfo.hdr.idFrom = nCtrlId;
     2751  dispInfo.hdr.code = LVN_ENDLABELEDITA;
     2752  dispInfo.item.mask = 0;
     2753  dispInfo.item.iItem = nItem;
     2754  dispInfo.item.state = lpItem->state;
     2755  dispInfo.item.stateMask = 0;
     2756  dispInfo.item.pszText = pszText;
     2757  dispInfo.item.cchTextMax = pszText ? strlen(pszText) : 0;
     2758  dispInfo.item.iImage = lpItem->iImage;
     2759  dispInfo.item.lParam = lpItem->lParam;
     2760
     2761  ListView_Notify(GetParent(hwnd), nCtrlId, &dispInfo);
     2762  infoPtr->hwndEdit = 0;
     2763  infoPtr->lpeditItem = NULL;
     2764
     2765  return TRUE;
     2766}
     2767
     2768/***
     2769 * DESCRIPTION:
     2770 * Begin in place editing of specified list view item
     2771 *
     2772 * PARAMETER(S):
     2773 * [I] HWND : window handle
     2774 * [I] INT : item index
     2775 *
     2776 * RETURN:
     2777 *   SUCCESS : TRUE
     2778 *   FAILURE : FALSE
     2779 */
     2780
     2781static HWND LISTVIEW_EditLabelA(HWND hwnd, INT nItem)
     2782{
     2783  NMLVDISPINFOA dispInfo;
     2784  RECT rect;
     2785  LISTVIEW_ITEM *lpItem;
     2786  HWND hedit;
     2787  HINSTANCE hinst = GetWindowLongA(hwnd, GWL_HINSTANCE);
     2788  INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);
     2789  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
     2790  HDPA hdpaSubItems;
     2791 
     2792  if (~GetWindowLongA(hwnd, GWL_STYLE) & LVS_EDITLABELS)
     2793      return FALSE;
     2794
     2795  ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOA));
     2796  if (NULL == (hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem)))
     2797          return 0;
     2798
     2799  if (NULL == (lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0)))
     2800          return 0;
     2801
     2802  dispInfo.hdr.hwndFrom = hwnd;
     2803  dispInfo.hdr.idFrom = nCtrlId;
     2804  dispInfo.hdr.code = LVN_BEGINLABELEDITA;
     2805  dispInfo.item.mask = 0;
     2806  dispInfo.item.iItem = nItem;
     2807  dispInfo.item.state = lpItem->state;
     2808  dispInfo.item.stateMask = 0;
     2809  dispInfo.item.pszText = lpItem->pszText;
     2810  dispInfo.item.cchTextMax = strlen(lpItem->pszText);
     2811  dispInfo.item.iImage = lpItem->iImage;
     2812  dispInfo.item.lParam = lpItem->lParam;
     2813
     2814  if (ListView_LVNotify(GetParent(hwnd), nCtrlId, &dispInfo))
     2815          return 0;
     2816
     2817  rect.left = LVIR_LABEL;
     2818  if (!LISTVIEW_GetItemRect(hwnd, nItem, &rect))
     2819          return 0;
     2820 
     2821 if (!(hedit = CreateEditLabel(dispInfo.item.pszText , WS_VISIBLE,
     2822                 rect.left, rect.top, rect.right - rect.left + 15,
     2823                 rect.bottom - rect.top,
     2824                 hwnd, hinst, LISTVIEW_EndEditLabel, nItem)))
     2825         return 0;
     2826
     2827  infoPtr->hwndEdit = hedit;
     2828  infoPtr->lpeditItem = lpItem;
     2829  SetFocus(hedit);
     2830  SendMessageA(hedit, EM_SETSEL, 0, -1);
     2831
     2832  return hedit;
     2833}
    25952834
    25962835/***
     
    33233562                Str_SetPtrA(&lpItem->pszText, dispInfo.item.pszText);
    33243563              }
    3325               lpLVItem->pszText = dispInfo.item.pszText;
     3564              strncpy(lpLVItem->pszText, dispInfo.item.pszText, lpLVItem->cchTextMax);
    33263565            }
    33273566            else if (lpLVItem->mask & LVIF_TEXT)
    33283567            {
    3329               lpLVItem->pszText = lpItem->pszText;
     3568              strncpy(lpLVItem->pszText, lpItem->pszText, lpLVItem->cchTextMax);
    33303569            }
    33313570
     
    34183657                   Str_SetPtrA(&lpSubItem->pszText, dispInfo.item.pszText);
    34193658              }
    3420               lpLVItem->pszText = dispInfo.item.pszText;
     3659              strncpy(lpLVItem->pszText, dispInfo.item.pszText, lpLVItem->cchTextMax);
    34213660            }
    34223661            else if (lpLVItem->mask & LVIF_TEXT)
    34233662            {
    3424               lpLVItem->pszText = lpSubItem->pszText;
     3663              strncpy(lpLVItem->pszText, lpSubItem->pszText, lpLVItem->cchTextMax);
    34253664            }
    34263665          }
     
    45364775                             (WPARAM)nColumn, (LPARAM)&hdi);
    45374776
     4777    /* Need to reset the item width when inserting a new column */
     4778    infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd);
     4779
    45384780    LISTVIEW_UpdateScroll(hwnd);
    45394781    InvalidateRect(hwnd, NULL, FALSE);
     
    54585700  infoPtr->iconSpacing.cy = GetSystemMetrics(SM_CYICONSPACING);
    54595701  ZeroMemory(&infoPtr->rcList, sizeof(RECT));
     5702  infoPtr->hwndEdit = 0;
     5703  infoPtr->lpeditItem = NULL;
    54605704
    54615705  /* get default font (icon title) */
     
    55645808 * DESCRIPTION:
    55655809 * Performs vertical scrolling.
    5566  *
     5810 * 
    55675811 * PARAMETER(S):
    55685812 * [I] HWND : window handle
    55695813 * [I] INT : scroll code
    5570  * [I] SHORT : current scroll position if scroll code is SB_THIMBPOSITION
     5814 * [I] SHORT : current scroll position if scroll code is SB_THIMBPOSITION 
    55715815 *             or SB_THUMBTRACK.
    55725816 * [I] HWND : scrollbar control window handle
     
    55785822                                HWND hScrollWnd)
    55795823{
    5580   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
    55815824  SCROLLINFO scrollInfo;
    55825825
    55835826  ZeroMemory(&scrollInfo, sizeof(SCROLLINFO));
    55845827  scrollInfo.cbSize = sizeof(SCROLLINFO);
    5585   scrollInfo.fMask = /*SIF_PAGE |*/ SIF_POS | SIF_RANGE;
    5586 
     5828  scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
     5829 
    55875830  if (GetScrollInfo(hwnd, SB_VERT, &scrollInfo) != FALSE)
    55885831  {
     
    55965839      }
    55975840    break;
    5598 
     5841   
    55995842    case SB_LINEDOWN:
    56005843      if (scrollInfo.nPos < scrollInfo.nMax)
     
    56035846      }
    56045847      break;
    5605 
     5848     
    56065849    case SB_PAGEUP:
    56075850      if (scrollInfo.nPos > scrollInfo.nMin)
    56085851      {
    5609         INT nPage = 0;
    5610 
    5611         if (uView == LVS_REPORT)
    5612         {
    5613           nPage = LISTVIEW_GetCountPerColumn(hwnd);
    5614         }
    5615         else if ((uView == LVS_ICON) || (uView == LVS_SMALLICON))
    5616         {
    5617           nPage = 10;
    5618         }
    5619 
    5620         if (scrollInfo.nPos >= nPage)
    5621         {
    5622           scrollInfo.nPos -= nPage;
     5852
     5853        if (scrollInfo.nPos >= scrollInfo.nPage)
     5854        {
     5855          scrollInfo.nPos -= scrollInfo.nPage;
    56235856        }
    56245857        else
     
    56285861      }
    56295862      break;
    5630 
     5863     
    56315864    case SB_PAGEDOWN:
    56325865      if (scrollInfo.nPos < scrollInfo.nMax)
    56335866      {
    5634         INT nPage = 0;
    5635 
    5636         if (uView == LVS_REPORT)
    5637         {
    5638           nPage = LISTVIEW_GetCountPerColumn(hwnd);
    5639         }
    5640         else if ((uView == LVS_ICON) || (uView == LVS_SMALLICON))
    5641         {
    5642           nPage = 10;
    5643         }
    5644 
    5645         if (scrollInfo.nPos <= scrollInfo.nMax - nPage)
    5646         {
    5647           scrollInfo.nPos += nPage;
     5867        if (scrollInfo.nPos <= scrollInfo.nMax - scrollInfo.nPage)
     5868        {
     5869          scrollInfo.nPos += scrollInfo.nPage;
    56485870        }
    56495871        else
     
    56545876      break;
    56555877
    5656     case SB_THUMBPOSITION:
     5878    case SB_THUMBTRACK:
     5879        scrollInfo.nPos = nCurrentPos;
    56575880      break;
    56585881    }
     
    56625885      scrollInfo.fMask = SIF_POS;
    56635886      SetScrollInfo(hwnd, SB_VERT, &scrollInfo, TRUE);
    5664       InvalidateRect(hwnd, NULL, FALSE);
    5665     }
    5666   }
    5667 
     5887      InvalidateRect(hwnd, NULL, TRUE);
     5888    }
     5889  }
     5890   
    56685891  return 0;
    56695892}
     
    56725895 * DESCRIPTION:
    56735896 * Performs horizontal scrolling.
    5674  *
     5897 * 
    56755898 * PARAMETER(S):
    56765899 * [I] HWND : window handle
    56775900 * [I] INT : scroll code
    5678  * [I] SHORT : current scroll position if scroll code is SB_THIMBPOSITION
     5901 * [I] SHORT : current scroll position if scroll code is SB_THIMBPOSITION 
    56795902 *             or SB_THUMBTRACK.
    56805903 * [I] HWND : scrollbar control window handle
     
    56865909                                HWND hScrollWnd)
    56875910{
    5688   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
    56895911  SCROLLINFO scrollInfo;
    56905912
    56915913  ZeroMemory(&scrollInfo, sizeof(SCROLLINFO));
    56925914  scrollInfo.cbSize = sizeof(SCROLLINFO);
    5693   scrollInfo.fMask = /*SIF_PAGE |*/ SIF_POS | SIF_RANGE;
    5694 
     5915  scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
     5916 
    56955917  if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE)
    56965918  {
     
    57055927      }
    57065928      break;
    5707 
     5929   
    57085930    case SB_LINERIGHT:
    57095931      if (scrollInfo.nPos < scrollInfo.nMax)
     
    57125934      }
    57135935      break;
    5714 
     5936     
    57155937    case SB_PAGELEFT:
    57165938      if (scrollInfo.nPos > scrollInfo.nMin)
    57175939      {
    5718         INT nPage = 0;
    5719 
    5720         if (uView == LVS_LIST)
    5721         {
    5722           nPage = LISTVIEW_GetCountPerRow(hwnd);
    5723         }
    5724         else if ((uView == LVS_ICON) || (uView == LVS_SMALLICON))
    5725         {
    5726           nPage = 10;
    5727         }
    5728 
    5729         if (scrollInfo.nPos >= nPage)
    5730         {
    5731           scrollInfo.nPos -= nPage;
     5940        if (scrollInfo.nPos >= scrollInfo.nPage)
     5941        {
     5942          scrollInfo.nPos -= scrollInfo.nPage;
    57325943        }
    57335944        else
     
    57375948      }
    57385949      break;
    5739 
     5950     
    57405951    case SB_PAGERIGHT:
    57415952      if (scrollInfo.nPos < scrollInfo.nMax)
    57425953      {
    5743         INT nPage = 0;
    5744 
    5745         if (uView == LVS_LIST)
    5746         {
    5747           nPage = LISTVIEW_GetCountPerRow(hwnd);
    5748         }
    5749         else if ((uView == LVS_ICON) || (uView == LVS_SMALLICON))
    5750         {
    5751           nPage = 10;
    5752         }
    5753 
    5754         if (scrollInfo.nPos <= scrollInfo.nMax - nPage)
    5755         {
    5756           scrollInfo.nPos += nPage;
     5954        if (scrollInfo.nPos <= scrollInfo.nMax - scrollInfo.nPage)
     5955        {
     5956          scrollInfo.nPos += scrollInfo.nPage;
    57575957        }
    57585958        else
     
    57635963      break;
    57645964
    5765     case SB_THUMBPOSITION:
     5965    case SB_THUMBTRACK:
     5966        scrollInfo.nPos = nCurrentPos;
    57665967      break;
    57675968    }
     
    57695970    if (nOldScrollPos != scrollInfo.nPos)
    57705971    {
     5972      UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
    57715973      scrollInfo.fMask = SIF_POS;
    57725974      SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE);
    5773       InvalidateRect(hwnd, NULL, FALSE);
    5774     }
    5775   }
    5776 
     5975      scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
     5976      GetScrollInfo(hwnd, SB_HORZ, &scrollInfo);
     5977      if(uView == LVS_REPORT)
     5978      {
     5979          LISTVIEW_UpdateHeaderSize(hwnd, scrollInfo.nPos, nOldScrollPos);
     5980      }
     5981      InvalidateRect(hwnd, NULL, TRUE);
     5982    }
     5983  }
     5984   
    57775985  return 0;
    57785986}
     
    61466354 * DESCRIPTION:
    61476355 * Handles notifications from children.
    6148  *
     6356 * 
    61496357 * PARAMETER(S):
    61506358 * [I] HWND : window handle
    61516359 * [I] INT : control identifier
    61526360 * [I] LPNMHDR : notification information
    6153  *
     6361 * 
    61546362 * RETURN:
    61556363 * Zero
     
    61586366{
    61596367  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
    6160 
    6161   if (lpnmh->hwndFrom == infoPtr->hwndHeader)
     6368 
     6369  if (lpnmh->hwndFrom == infoPtr->hwndHeader) 
    61626370  {
    61636371    /* handle notification from header control */
     
    61656373    {
    61666374      infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd);
    6167       InvalidateRect(hwnd, NULL, FALSE);
    6168     }
     6375      InvalidateRect(hwnd, NULL, TRUE);
     6376    }
     6377    else if(lpnmh->code ==  HDN_ITEMCLICKA)
     6378    {
     6379        /* Handle sorting by Header Column */
     6380        NMLISTVIEW nmlv;
     6381        LPNMHEADERA pnmHeader = (LPNMHEADERA) lpnmh;
     6382        LONG lCtrlId = GetWindowLongA(hwnd, GWL_ID);
     6383
     6384        ZeroMemory(&nmlv, sizeof(NMLISTVIEW));
     6385        nmlv.hdr.hwndFrom = hwnd;
     6386        nmlv.hdr.idFrom = lCtrlId;
     6387        nmlv.hdr.code = LVN_COLUMNCLICK;
     6388        nmlv.iItem = -1;
     6389        nmlv.iSubItem = pnmHeader->iItem;
     6390       
     6391        ListView_LVNotify(GetParent(hwnd),lCtrlId, &nmlv);
     6392
     6393    }
     6394    else if(lpnmh->code == NM_RELEASEDCAPTURE)
     6395    {
     6396      /* Idealy this should be done in HDN_ENDTRACKA
     6397       * but since SetItemBounds in Header.c is called after
     6398       * the notification is sent, it is neccessary to handle the
     6399       * update of the scroll bar here (Header.c works fine as it is,
     6400       * no need to disturb it)
     6401       */
     6402      LISTVIEW_UpdateScroll(hwnd);
     6403      InvalidateRect(hwnd, NULL, TRUE);
     6404    }
     6405
    61696406  }
    61706407
     
    66736910    return LISTVIEW_DeleteItem(hwnd, (INT)wParam);
    66746911
    6675 /*      case LVM_EDITLABEL: */
     6912  case LVM_EDITLABELW:
     6913  case LVM_EDITLABELA:
     6914    return LISTVIEW_EditLabelA(hwnd, (INT)wParam);
    66766915
    66776916  case LVM_ENSUREVISIBLE:
     
    67056944    return LISTVIEW_GetCountPerPage(hwnd);
    67066945
    6707 /*      case LVM_GETEDITCONTROL: */
     6946  case LVM_GETEDITCONTROL:
     6947    return LISTVIEW_GetEditControl(hwnd);
     6948
    67086949  case LVM_GETEXTENDEDLISTVIEWSTYLE:
    67096950    return LISTVIEW_GetExtendedListViewStyle(hwnd);
     
    68897130
    68907131/*      case WM_CHAR: */
    6891 /*      case WM_COMMAND: */
     7132  case WM_COMMAND:
     7133    return LISTVIEW_Command(hwnd, wParam, lParam);
    68927134
    68937135  case WM_CREATE:
     
    70387280}
    70397281
     7282/***
     7283 * DESCRIPTION:
     7284 * Handle any WM_COMMAND messages
     7285 *
     7286 * PARAMETER(S):
     7287 *
     7288 * RETURN:
     7289 */
     7290static LRESULT LISTVIEW_Command(HWND hwnd, WPARAM wParam, LPARAM lParam)
     7291{
     7292    switch (HIWORD(wParam))
     7293    {
     7294        case EN_UPDATE:
     7295        {
     7296            /*
     7297             * Adjust the edit window size
     7298             */
     7299            char buffer[1024];
     7300            LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
     7301            HDC           hdc      = GetDC(infoPtr->hwndEdit);
     7302            RECT          rect;
     7303            SIZE          sz;
     7304
     7305            GetWindowTextA(infoPtr->hwndEdit, buffer, 1024);
     7306            GetWindowRect(infoPtr->hwndEdit, &rect);
     7307            if (GetTextExtentPoint32A(hdc, buffer, strlen(buffer), &sz))
     7308            {
     7309                    SetWindowPos (
     7310                infoPtr->hwndEdit,
     7311                HWND_TOP,
     7312                0,
     7313                0,
     7314                sz.cx + 15,
     7315                rect.bottom - rect.top,
     7316                SWP_DRAWFRAME|SWP_NOMOVE);
     7317            }
     7318            ReleaseDC(hwnd, hdc);
     7319
     7320            break;
     7321        }
     7322
     7323        default:
     7324          return SendMessageA (GetParent (hwnd), WM_COMMAND, wParam, lParam);
     7325    }
     7326
     7327    return 0;
     7328}
     7329
     7330
     7331/***
     7332 * DESCRIPTION:
     7333 * Subclassed edit control windproc function
     7334 *
     7335 * PARAMETER(S):
     7336 *
     7337 * RETURN:
     7338 */
     7339LRESULT CALLBACK EditLblWndProc(HWND hwnd, UINT uMsg,
     7340        WPARAM wParam, LPARAM lParam)
     7341{
     7342    BOOL cancel = TRUE;
     7343    EDITLABEL_ITEM *einfo =
     7344    (EDITLABEL_ITEM *) GetWindowLongA(hwnd, GWL_USERDATA);
     7345
     7346    switch (uMsg)
     7347    {
     7348        case WM_KILLFOCUS:
     7349            break;
     7350
     7351        case WM_CHAR:
     7352            if (VK_RETURN == (INT)wParam)
     7353            {
     7354                cancel = FALSE;
     7355                break;
     7356            }
     7357            else if (VK_ESCAPE == (INT)wParam)
     7358                break;
     7359
     7360        default:
     7361            return CallWindowProcA(einfo->EditWndProc, hwnd,
     7362                        uMsg, wParam, lParam);
     7363    }
     7364
     7365    SetWindowLongA(hwnd, GWL_WNDPROC, (LONG)einfo->EditWndProc);
     7366    if (einfo->EditLblCb)
     7367    {
     7368        char *buffer  = NULL;
     7369
     7370        if (!cancel)
     7371        {
     7372            int len = 1 + GetWindowTextLengthA(hwnd);
     7373
     7374            if (len > 1)
     7375            {
     7376                if (NULL != (buffer = (char *)COMCTL32_Alloc(len*sizeof(char))))
     7377                {
     7378                    GetWindowTextA(hwnd, buffer, len);
     7379                }
     7380            }
     7381        }
     7382           
     7383        einfo->EditLblCb(GetParent(hwnd), buffer, einfo->param);
     7384
     7385        if (buffer)
     7386            COMCTL32_Free(buffer);
     7387    }
     7388
     7389    COMCTL32_Free(einfo);
     7390    PostMessageA(hwnd, WM_CLOSE, 0, 0);
     7391    return TRUE;
     7392}
     7393
     7394
     7395/***
     7396 * DESCRIPTION:
     7397 * Creates a subclassed edit cotrol
     7398 *
     7399 * PARAMETER(S):
     7400 *
     7401 * RETURN:
     7402 */
     7403HWND CreateEditLabel(LPCSTR text, DWORD style, INT x, INT y,
     7404        INT width, INT height, HWND parent, HINSTANCE hinst,
     7405        EditlblCallback EditLblCb, DWORD param)
     7406{
     7407    HWND hedit;
     7408    EDITLABEL_ITEM *einfo;
     7409 
     7410    if (NULL == (einfo = COMCTL32_Alloc(sizeof(EDITLABEL_ITEM))))
     7411        return 0;
     7412
     7413    style |= WS_CHILDWINDOW|WS_CLIPSIBLINGS|ES_LEFT|WS_BORDER;
     7414    if (!(hedit = CreateWindowA("Edit", text, style, x, y, width, height,
     7415                    parent, 0, hinst, 0)))
     7416    {
     7417        COMCTL32_Free(einfo);
     7418        return 0;
     7419    }
     7420
     7421    einfo->param = param;
     7422    einfo->EditLblCb = EditLblCb;
     7423    einfo->EditWndProc = (WNDPROC)SetWindowLongA(hedit,
     7424          GWL_WNDPROC, (LONG) EditLblWndProc);
     7425
     7426    SetWindowLongA(hedit, GWL_USERDATA, (LONG)einfo);
     7427
     7428    return hedit;
     7429}
  • trunk/src/comctl32/propsheet.c

    r1402 r1565  
    1 /* $Id: propsheet.c,v 1.10 1999-10-22 18:04:11 sandervl Exp $ */
     1/* $Id: propsheet.c,v 1.11 1999-11-02 21:44:02 achimha Exp $ */
    22/*
    33 * Property Sheets
     
    1313 */
    1414
    15 /* WINE 990923 level */
     15/* WINE 991031 level */
    1616
    1717/* CB: Odin problems:
     
    117117static void PROPSHEET_SetFinishTextA(HWND hwndDlg, LPCSTR lpszText);
    118118static void PROPSHEET_SetTitleA(HWND hwndDlg, DWORD dwStyle, LPCSTR lpszText);
     119static BOOL PROPSHEET_CanSetCurSel(HWND hwndDlg);
    119120static BOOL PROPSHEET_SetCurSel(HWND hwndDlg,
    120121                                int index,
     
    214215    HGLOBAL hTemplate = LoadResource(lppsp->hInstance,
    215216                                     hResource);
    216      pTemplate = (LPDLGTEMPLATEA)LockResource(hTemplate);
     217    pTemplate = (LPDLGTEMPLATEA)LockResource(hTemplate);
    217218  }
    218219
     
    265266      p += lstrlenW( (LPCWSTR)p ) + 1;
    266267      break;
    267   }
     268  } 
    268269
    269270  /* class */
     
    283284  /* Extract the caption */
    284285  psInfo->proppage[index].pszText = (LPCWSTR)p;
    285 //  TRACE(propsheet, "Tab %d %s\n",index,debugstr_w((LPCWSTR)p));
     286//  TRACE("Tab %d %s\n",index,debugstr_w((LPCWSTR)p));
    286287  p += lstrlenW((LPCWSTR)p) + 1;
    287288
    288289  if (dwFlags & PSP_USETITLE)
    289290  {
    290 //AH: todo
    291 //    psInfo->proppage[index].pszText = HEAP_strdupAtoW(GetProcessHeap(),
    292 //                                                      0,
    293 //                                                      lppsp->pszTitle);
     291    if ( !HIWORD( lppsp->pszTitle ) )
     292    {
     293      char szTitle[256];
     294     
     295      if ( !LoadStringA( lppsp->hInstance, (UINT) lppsp->pszTitle, szTitle, 256 ) )
     296        return FALSE;
     297
     298//AH: TODO     
     299//      psInfo->proppage[index].pszText = HEAP_strdupAtoW( GetProcessHeap(),
     300//                                                       0, szTitle );
     301    }
     302//AH: TODO
     303//    else
     304//      psInfo->proppage[index].pszText = HEAP_strdupAtoW(GetProcessHeap(),
     305//                                                      0,
     306//                                                      lppsp->pszTitle);
    294307  }
    295308
     
    297310   * Build the image list for icons
    298311   */
    299   if ((dwFlags & PSP_USEHICON) || (dwFlags & PSP_USEICONID))
     312  if ((dwFlags & PSP_USEHICON) || (dwFlags & PSP_USEICONID)) 
    300313  {
    301314    HICON hIcon;
     
    876889  PropPageInfo* ppInfo = psInfo->proppage;
    877890  PADDING_INFO padding;
    878   HWND hwndAfter;
    879 
    880 //  TRACE(propsheet, "index %d\n", index);
     891
     892  TRACE("index %d\n", index);
    881893
    882894  if (ppshpage->dwFlags & PSP_DLGINDIRECT)
     
    908920    pTemplate->style &= ~WS_POPUP;
    909921    pTemplate->style &= ~WS_DISABLED;
    910 
    911922  }
    912923
     
    917928
    918929  hwndPage = CreateDialogIndirectParamA(ppshpage->hInstance,
    919                                         pTemplate,
    920                                         hwndParent,
    921                                         ppshpage->pfnDlgProc,
    922                                         (LPARAM)ppshpage);
     930                                        pTemplate,
     931                                        hwndParent,
     932                                        ppshpage->pfnDlgProc,
     933                                        (LPARAM)ppshpage);
    923934
    924935  ppInfo[index].hwndPage = hwndPage;
     
    932943
    933944  if (psInfo->ppshheader->dwFlags & PSH_WIZARD)
    934   {
    935     GetWindowRect(hwndParent, &rc);
    936945    padding = PROPSHEET_GetPaddingInfoWizard(hwndParent);
    937     hwndAfter = hwndParent;
    938   }
    939946  else
    940947  {
     
    946953    SendMessageA(hwndTabCtrl, TCM_ADJUSTRECT, FALSE, (LPARAM)&rc);
    947954    padding = PROPSHEET_GetPaddingInfo(hwndParent);
    948     hwndAfter = HWND_TOP;
    949   }
    950 
    951   SetWindowPos(hwndPage, hwndAfter,
     955  }
     956
     957  SetWindowPos(hwndPage, HWND_TOP,
    952958               rc.left + padding.x,
    953959               rc.top + padding.y,
     
    10381044                                                    PropSheetInfoStr);
    10391045
     1046  hdr.hwndFrom = hwndDlg;
    10401047  hdr.code = PSN_WIZNEXT;
    10411048
     
    10441051  msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr);
    10451052
    1046 //  TRACE("msg result %ld\n", msgResult);
     1053  TRACE("msg result %ld\n", msgResult);
    10471054
    10481055  if (msgResult == -1)
    10491056    return FALSE;
    10501057
    1051   PROPSHEET_SetCurSel(hwndDlg, psInfo->active_page + 1, 0);
     1058  if(PROPSHEET_CanSetCurSel(hwndDlg) != FALSE)
     1059  {
     1060    PROPSHEET_SetCurSel(hwndDlg, psInfo->active_page + 1, 0);
     1061  }
    10521062
    10531063  return TRUE;
     
    10651075                                                    PropSheetInfoStr);
    10661076
     1077  hdr.hwndFrom = hwndDlg;
    10671078  hdr.code = PSN_WIZFINISH;
    10681079
     
    10711082  msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr);
    10721083
    1073 //  TRACE("msg result %ld\n", msgResult);
     1084  TRACE("msg result %ld\n", msgResult);
    10741085
    10751086  if (msgResult != 0)
     
    12061217  PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
    12071218                                                    PropSheetInfoStr);
    1208 
     1219  if ( !psInfo ) return;
    12091220  for (i = 0; i < psInfo->nPages; i++)
    12101221  {
     
    12591270}
    12601271
     1272/*************************************************************************
     1273 * BOOL PROPSHEET_CanSetCurSel [Internal]
     1274 *
     1275 * Test weither the current page can be changed by sending a PSN_KILLACTIVE
     1276 *
     1277 * PARAMS
     1278 *     hwndDlg        [I] handle to a Dialog hWnd
     1279 *
     1280 * RETURNS
     1281 *     TRUE if Current Selection can change
     1282 *
     1283 * NOTES
     1284 */
     1285static BOOL PROPSHEET_CanSetCurSel(HWND hwndDlg)
     1286{
     1287  PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
     1288                                                    PropSheetInfoStr);
     1289  HWND hwndPage;
     1290  NMHDR hdr;
     1291
     1292  if (!psInfo)
     1293    return FALSE;
     1294
     1295  /*
     1296   * Notify the current page.
     1297   */
     1298  hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
     1299
     1300  hdr.hwndFrom = hwndDlg;
     1301  hdr.code = PSN_KILLACTIVE;
     1302
     1303  return !SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr);
     1304}
     1305
    12611306/******************************************************************************
    12621307 *            PROPSHEET_SetCurSel
     
    12721317  NMHDR hdr;
    12731318
    1274   /*
    1275    * Notify the current page.
    1276    */
    12771319  hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
    12781320
    12791321  hdr.hwndFrom = hwndDlg;
    1280   hdr.code = PSN_KILLACTIVE;
    1281 
    1282   if (SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr))
    1283     return FALSE;
    1284 
    12851322  /*
    12861323   * hpage takes precedence over index.
     
    12921329    if (index == -1)
    12931330    {
    1294       //TRACE("Could not find page to remove!\n");
     1331      TRACE("Could not find page to remove!\n");
    12951332      return FALSE;
    12961333    }
     
    13101347    result = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr);
    13111348    /*
    1312      * TODO: check return value.
     1349     * TODO: check return value. 
    13131350     */
    13141351  }
     
    14691506  psInfo->nPages++;
    14701507
    1471   return FALSE;
     1508  return TRUE;
    14721509}
    14731510
     
    14821519                                                     PropSheetInfoStr);
    14831520  HWND hwndTabControl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
    1484   PropPageInfo* oldPages = psInfo->proppage;
    1485 
     1521  PropPageInfo* oldPages;
     1522
     1523  if (!psInfo) {
     1524    FIXME("No psInfo for propertysheet at windows 0x%04x, returning FALSE...\n", hwndDlg);
     1525    return FALSE;
     1526  }
     1527  oldPages = psInfo->proppage;
    14861528  /*
    14871529   * hpage takes precedence over index.
     
    14901532  {
    14911533    index = PROPSHEET_GetPageIndex(hpage, psInfo);
    1492 
    1493     if (index == -1)
     1534  }
     1535
     1536  /* Make shure that index is within range */
     1537  if (index < 0 || index >= psInfo->nPages)
    14941538    {
    1495 //      TRACE(propsheet, "Could not find page to remove!\n");
     1539      TRACE("Could not find page to remove!\n");
    14961540      return FALSE;
    14971541    }
    1498   }
    1499 
    1500 //  TRACE(propsheet, "total pages %d removing page %d active page %d\n",
    1501 //        psInfo->nPages, index, psInfo->active_page);
     1542
     1543  TRACE("total pages %d removing page %d active page %d\n",
     1544        psInfo->nPages, index, psInfo->active_page);
    15021545  /*
    15031546   * Check if we're removing the active page.
     
    15201563    else
    15211564    {
    1522 //      TRACE(propsheet, "Removing the only page, close the dialog!\n");
     1565      TRACE("Removing the only page, close the dialog!\n");
    15231566
    15241567      if (psInfo->isModeless)
     
    15341577    psInfo->active_page--;
    15351578
     1579  /* Destroy page dialog window.
     1580   * If it's last page in modal dialog, it has been destroyed by EndDialog
     1581   */
     1582  if (psInfo->isModeless || psInfo->nPages > 1)
     1583     DestroyWindow(psInfo->proppage[index].hwndPage);
     1584 
    15361585  /* Remove the tab */
    15371586  SendMessageA(hwndTabControl, TCM_DELETEITEM, index, 0);
     
    15401589  psInfo->proppage = COMCTL32_Alloc(sizeof(PropPageInfo) * psInfo->nPages);
    15411590
    1542   if (index > 0)
     1591  if (index > 0) 
    15431592    memcpy(&psInfo->proppage[0], &oldPages[0], index * sizeof(PropPageInfo));
    15441593
     
    17641813      GetWindowTextA(hwnd, psInfo->strPropertiesFor, MAX_CAPTION_LENGTH);
    17651814
     1815      PROPSHEET_CreateTabControl(hwnd, psInfo);
     1816
    17661817      if (psInfo->ppshheader->dwFlags & PSH_WIZARD)
    17671818      {
     
    17801831      else
    17811832      {
    1782         PROPSHEET_CreateTabControl(hwnd, psInfo);
    1783 
    17841833        if (PROPSHEET_IsTooSmall(hwnd, psInfo))
    17851834        {
     
    17891838      }
    17901839
     1840      if (psInfo->useCallback)
     1841             (*(psInfo->ppshheader->pfnCallback))(hwnd,
     1842                                              PSCB_INITIALIZED, (LPARAM)0);
     1843
    17911844      ppshpage = PROPSHEET_GetPSPPage(psInfo, psInfo->active_page);     
    17921845      PROPSHEET_CreatePage(hwnd, psInfo->active_page, psInfo, ppshpage, TRUE);
     
    17971850      SetPropA(hwnd, PropSheetInfoStr, (HANDLE)psInfo);
    17981851
    1799       PROPSHEET_SetTitleA(hwnd,
    1800                           psInfo->ppshheader->dwFlags,
    1801                           psInfo->ppshheader->pszCaption);
     1852
     1853      if (!HIWORD(psInfo->ppshheader->pszCaption) &&
     1854              psInfo->ppshheader->hInstance)
     1855      {
     1856         char szText[256];
     1857
     1858         if (LoadStringA(psInfo->ppshheader->hInstance,
     1859                 (UINT)psInfo->ppshheader->pszCaption, szText, 255))
     1860            PROPSHEET_SetTitleA(hwnd, psInfo->ppshheader->dwFlags, szText);
     1861      }
     1862      else
     1863      {
     1864         PROPSHEET_SetTitleA(hwnd, psInfo->ppshheader->dwFlags,
     1865                         psInfo->ppshheader->pszCaption);
     1866      }
    18021867
    18031868      return TRUE;
     
    18841949      }
    18851950
     1951      if(pnmh->code == TCN_SELCHANGING)
     1952      {
     1953        BOOL bRet = PROPSHEET_CanSetCurSel(hwnd);
     1954        SetWindowLongA(hwnd, DWL_MSGRESULT, !bRet);
     1955        return TRUE;
     1956      }
     1957
     1958
    18861959      return 0;
    18871960    }
     
    19221995      BOOL msgResult;
    19231996
    1924       msgResult = PROPSHEET_SetCurSel(hwnd,
    1925                                       (int)wParam,
    1926                                       (HPROPSHEETPAGE)lParam);
     1997      msgResult = PROPSHEET_CanSetCurSel(hwnd);
     1998      if(msgResult != FALSE)
     1999      {
     2000        msgResult = PROPSHEET_SetCurSel(hwnd,
     2001                                       (int)wParam,
     2002                                       (HPROPSHEETPAGE)lParam);
     2003      }
    19272004
    19282005      SetWindowLongA(hwnd, DWL_MSGRESULT, msgResult);
     
    19832060
    19842061    case PSM_ADDPAGE:
    1985       PROPSHEET_AddPage(hwnd, (HPROPSHEETPAGE)lParam);
     2062    {
     2063      /*
     2064       * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
     2065       *       a return value. This is not true. PSM_ADDPAGE returns TRUE
     2066       *       on success or FALSE otherwise, as specified on MSDN Online.
     2067       *       Also see the MFC code for
     2068       *       CPropertySheet::AddPage(CPropertyPage* pPage).
     2069       */
     2070
     2071      BOOL msgResult = PROPSHEET_AddPage(hwnd, (HPROPSHEETPAGE)lParam);
     2072
     2073      SetWindowLongA(hwnd, DWL_MSGRESULT, msgResult);
     2074
    19862075      return TRUE;
     2076    }
    19872077
    19882078    case PSM_REMOVEPAGE:
     
    19922082    case PSM_ISDIALOGMESSAGE:
    19932083    {
    1994 //      FIXME("Unimplemented msg PSM_ISDIALOGMESSAGE\n");
     2084      FIXME("Unimplemented msg PSM_ISDIALOGMESSAGE\n");
    19952085      return 0;
    19962086    }
     
    20092099
    20102100    case PSM_SETTITLEW:
    2011 //        FIXME("Unimplemented msg PSM_SETTITLE32W\n");
     2101        FIXME("Unimplemented msg PSM_SETTITLE32W\n");
    20122102        return 0;
    20132103    case PSM_SETCURSELID:
    2014 //        FIXME("Unimplemented msg PSM_SETCURSELID\n");
     2104        FIXME("Unimplemented msg PSM_SETCURSELID\n");
    20152105        return 0;
    20162106    case PSM_SETFINISHTEXTW:
    2017 //        FIXME("Unimplemented msg PSM_SETFINISHTEXT32W\n");
     2107        FIXME("Unimplemented msg PSM_SETFINISHTEXT32W\n");
    20182108        return 0;
    20192109
  • trunk/src/comctl32/rsrc.rc

    r1424 r1565  
    55
    66IDD_PROPSHEET DIALOG DISCARDABLE 0, 0, 292, 159
    7 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
     7STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE
    88CAPTION "Properties for "
    99FONT 8, "MS Sans Serif"
     
    1414  PUSHBUTTON    "Help",   IDHELP,235,138,50,14
    1515  CONTROL       "Tab",    IDC_TABCONTROL,"SysTabControl32",WS_CLIPSIBLINGS,7,7,278,125
     16END
     17
     18
     19IDD_WIZARD DIALOG DISCARDABLE 0, 0, 292, 159
     20STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE
     21CAPTION "Wizard"
     22FONT 8, "MS Sans Serif"
     23BEGIN
     24  DEFPUSHBUTTON "Finish",  IDC_FINISH_BUTTON,121,138,50,14
     25  DEFPUSHBUTTON "&Next >", IDC_NEXT_BUTTON,121,138,50,14
     26  PUSHBUTTON    "< &Back", IDC_BACK_BUTTON,71,138,50,14
     27  PUSHBUTTON    "Cancel",  IDCANCEL,178,138,50,14
     28  PUSHBUTTON    "Help",    IDHELP,235,138,50,14
     29  LTEXT         "",        IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN
     30  CONTROL       "Tab",     IDC_TABCONTROL,"SysTabControl32",WS_CLIPSIBLINGS | WS_DISABLED,7,7,258,5
    1631END
    1732
  • trunk/src/comctl32/tab.c

    r1431 r1565  
    1 /* $Id: tab.c,v 1.15 1999-10-24 22:49:47 sandervl Exp $ */
     1/* $Id: tab.c,v 1.16 1999-11-02 21:44:03 achimha Exp $ */
    22/*
    33 * Tab control
     
    1515 */
    1616
    17 /* WINE 990823 level */
     17/* WINE 991031 level */
    1818
    1919#include <string.h>
     
    115115  INT iItem=(INT) wParam;
    116116  INT prevItem;
    117 
     117 
    118118  prevItem=-1;
    119119  if ((iItem >= 0) && (iItem < infoPtr->uNumItem)) {
    120120    prevItem=infoPtr->iSelected;
    121121      infoPtr->iSelected=iItem;
     122      TAB_EnsureSelectionVisible(hwnd, infoPtr);
     123      TAB_InvalidateTabArea(hwnd, infoPtr);
    122124  }
    123125  return prevItem;
     
    376378{
    377379  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
     380  POINT pt;
     381  INT newItem,dummy;
    378382
    379383  if (infoPtr->hwndToolTip)
    380384    TAB_RelayEvent (infoPtr->hwndToolTip, hwnd,
    381                     WM_LBUTTONDOWN, wParam, lParam);
     385                    WM_LBUTTONDOWN, wParam, lParam);
    382386
    383387  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_FOCUSONBUTTONDOWN ) {
    384388    SetFocus (hwnd);
     389  }
     390
     391  if (infoPtr->hwndToolTip)
     392    TAB_RelayEvent (infoPtr->hwndToolTip, hwnd,
     393                    WM_LBUTTONDOWN, wParam, lParam);
     394 
     395  pt.x = (INT)LOWORD(lParam);
     396  pt.y = (INT)HIWORD(lParam);
     397 
     398  newItem=TAB_InternalHitTest (hwnd, infoPtr,pt,&dummy);
     399 
     400  TRACE("On Tab, item %d\n", newItem);
     401   
     402  if ( (newItem!=-1) &&
     403       (infoPtr->iSelected != newItem) )
     404  {
     405    if (TAB_SendSimpleNotify(hwnd, TCN_SELCHANGING)!=TRUE)
     406    {
     407      infoPtr->iSelected = newItem;
     408      infoPtr->uFocus    = newItem;
     409      TAB_SendSimpleNotify(hwnd, TCN_SELCHANGE);
     410
     411      TAB_EnsureSelectionVisible(hwnd, infoPtr);
     412
     413      TAB_InvalidateTabArea(hwnd, infoPtr);
     414    }
    385415  }
    386416  return 0;
  • trunk/src/comctl32/toolbar.c

    r1431 r1565  
    1 /* $Id: toolbar.c,v 1.16 1999-10-24 22:49:47 sandervl Exp $ */
     1/* $Id: toolbar.c,v 1.17 1999-11-02 21:44:03 achimha Exp $ */
    22/*
    33 * Toolbar control
     
    2626 *   - Microsofts controlspy examples.
    2727 */
     28
     29/* WINE 991031 level */
    2830
    2931/* CB: Odin32/WINE bugs
     
    34613463}
    34623464
     3465static LRESULT
     3466TOOLBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
     3467{
     3468    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     3469
     3470    return infoPtr->hFont;
     3471}
    34633472
    34643473static LRESULT
     
    41254134            return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
    41264135
    4127 /*      case WM_GETFONT: */
     4136        case WM_GETFONT:
     4137                return TOOLBAR_GetFont (hwnd, wParam, lParam);
     4138
    41284139/*      case WM_KEYDOWN: */
    41294140/*      case WM_KILLFOCUS: */
  • trunk/src/comctl32/tooltips.c

    r1431 r1565  
    1 /* $Id: tooltips.c,v 1.15 1999-10-24 22:49:49 sandervl Exp $ */
     1/* $Id: tooltips.c,v 1.16 1999-11-02 21:44:03 achimha Exp $ */
    22/*
    33 * Tool tip control
     
    2222*/
    2323
    24 /* WINE 990923 level */
     24/* WINE 991031 level */
    2525
    2626#include <string.h>
     
    253253}
    254254
     255static VOID
     256TOOLTIPS_CalcTipSize (HWND hwnd, TOOLTIPS_INFO *infoPtr, LPSIZE lpSize)
     257{
     258    HDC hdc;
     259    HFONT hOldFont;
     260    UINT uFlags = DT_EXTERNALLEADING | DT_CALCRECT;
     261    RECT rc = {0, 0, 0, 0};
     262
     263    if (infoPtr->nMaxTipWidth > -1) {
     264        rc.right = infoPtr->nMaxTipWidth;
     265        uFlags |= DT_WORDBREAK;
     266    }
     267    if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX)
     268        uFlags |= DT_NOPREFIX;
     269//    TRACE("\"%s\"\n", debugstr_w(infoPtr->szTipText));
     270
     271    hdc = GetDC (hwnd);
     272    hOldFont = SelectObject (hdc, infoPtr->hFont);
     273    DrawTextW (hdc, infoPtr->szTipText, -1, &rc, uFlags);
     274    SelectObject (hdc, hOldFont);
     275    ReleaseDC (hwnd, hdc);
     276
     277    lpSize->cx = rc.right - rc.left + 4 +
     278                 infoPtr->rcMargin.left + infoPtr->rcMargin.right;
     279    lpSize->cy = rc.bottom - rc.top + 4 +
     280                 infoPtr->rcMargin.bottom + infoPtr->rcMargin.top;
     281}
    255282
    256283static VOID
     
    258285{
    259286    TTTOOL_INFO *toolPtr;
    260     RECT rect;
     287    RECT rect, wndrect;
     288    SIZE size;
    261289    HDC  hdc;
    262290    NMHDR  hdr;
    263291
    264     if (infoPtr->nTool == -1)
    265     {
    266 //      TRACE (tooltips, "invalid tool (-1)!\n");
    267         return;
     292    if (infoPtr->nTool == -1) {
     293        TRACE("invalid tool (-1)!\n");
     294        return;
    268295    }
    269296
    270297    infoPtr->nCurrentTool = infoPtr->nTool;
    271298
    272 //    TRACE (tooltips, "Show tooltip pre %d!\n", infoPtr->nTool);
    273     TOOLTIPS_GetTipText(hwnd,infoPtr,infoPtr->nCurrentTool);
    274 
    275     if (infoPtr->szTipText[0] == '\0')
    276     {
    277         infoPtr->nCurrentTool = -1;
    278         return;
    279     }
    280 
    281 //    TRACE (tooltips, "Show tooltip %d!\n", infoPtr->nCurrentTool);
     299    TRACE("Show tooltip pre %d!\n", infoPtr->nTool);
     300
     301    TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nCurrentTool);
     302
     303    if (infoPtr->szTipText[0] == L'\0') {
     304        infoPtr->nCurrentTool = -1;
     305        return;
     306    }
     307
     308    TRACE("Show tooltip %d!\n", infoPtr->nCurrentTool);
    282309    toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
    283310
     
    285312    hdr.idFrom = toolPtr->uId;
    286313    hdr.code = TTN_SHOW;
    287     SendMessageA(toolPtr->hwnd,WM_NOTIFY,
    288                     (WPARAM)toolPtr->uId,(LPARAM)&hdr);
    289 
    290 //    TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
    291 
    292     TOOLTIPS_CalcTipRect(hwnd,infoPtr,toolPtr,&rect);
    293 
    294     SetWindowPos (hwnd,HWND_TOP,rect.left,rect.top,
    295                     rect.right-rect.left,rect.bottom-rect.top,
    296                     SWP_SHOWWINDOW | SWP_NOACTIVATE);
     314    SendMessageA (toolPtr->hwnd, WM_NOTIFY,
     315                    (WPARAM)toolPtr->uId, (LPARAM)&hdr);
     316
     317//    TRACE("\"%s\"\n", debugstr_w(infoPtr->szTipText));
     318
     319    TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size);
     320    TRACE("size %d - %d\n", size.cx, size.cy);
     321
     322    if (toolPtr->uFlags & TTF_CENTERTIP) {
     323        RECT rc;
     324
     325        if (toolPtr->uFlags & TTF_IDISHWND)
     326            GetWindowRect ((HWND)toolPtr->uId, &rc);
     327        else {
     328            rc = toolPtr->rect;
     329            MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rc, 2);
     330        }
     331        rect.left = (rc.left + rc.right - size.cx) / 2;
     332        rect.top  = rc.bottom + 2;
     333    }
     334    else {
     335        GetCursorPos ((LPPOINT)&rect);
     336        rect.top += 20;
     337    }
     338
     339    TRACE("pos %d - %d\n", rect.left, rect.top);
     340
     341    rect.right = rect.left + size.cx;
     342    rect.bottom = rect.top + size.cy;
     343
     344    /* check position */
     345    wndrect.right = GetSystemMetrics( SM_CXSCREEN );
     346    if( rect.right > wndrect.right ) {
     347           rect.left -= rect.right - wndrect.right + 2;
     348           rect.right = wndrect.right - 2;
     349    }
     350    wndrect.bottom = GetSystemMetrics( SM_CYSCREEN );
     351    if( rect.bottom > wndrect.bottom ) {
     352        RECT rc;
     353
     354        if (toolPtr->uFlags & TTF_IDISHWND)
     355            GetWindowRect ((HWND)toolPtr->uId, &rc);
     356        else {
     357            rc = toolPtr->rect;
     358            MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rc, 2);
     359        }   
     360        rect.bottom = rc.top - 2;
     361        rect.top = rect.bottom - size.cy;
     362    }
     363
     364    AdjustWindowRectEx (&rect, GetWindowLongA (hwnd, GWL_STYLE),
     365                        FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE));
     366
     367    SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top,
     368                    rect.right - rect.left, rect.bottom - rect.top,
     369                    SWP_SHOWWINDOW | SWP_NOACTIVATE);
    297370
    298371    /* repaint the tooltip */
    299     hdc = GetDC(hwnd);
    300     TOOLTIPS_Refresh(hwnd,hdc);
    301     ReleaseDC(hwnd,hdc);
    302 
    303     SetTimer (hwnd,ID_TIMERPOP,infoPtr->nAutoPopTime,0);
     372    hdc = GetDC (hwnd);
     373    TOOLTIPS_Refresh (hwnd, hdc);
     374    ReleaseDC (hwnd, hdc);
     375
     376    SetTimer (hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0);
    304377}
    305378
  • 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.