Ignore:
Timestamp:
Feb 22, 2000, 6:11:41 PM (26 years ago)
Author:
cbratschi
Message:

Corel 20000212, TREEVIEW_Sort fix, CCBase

File:
1 edited

Legend:

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

    r2835 r2858  
    1 /* $Id: treeview.c,v 1.29 2000-02-20 18:29:58 cbratschi Exp $ */
     1/* $Id: treeview.c,v 1.30 2000-02-22 17:11:41 cbratschi Exp $ */
    22/* Treeview control
    33 *
     
    4747#include "commctrl.h"
    4848#include "comctl32.h"
     49#include "ccbase.h"
    4950#include "treeview.h"
    5051
     
    20022003  INT            cChildren;
    20032004  HTREEITEM      hti;
    2004   BOOL root;
     2005  BOOL root = FALSE;
    20052006
    20062007  /* Obtain the TVSORTBC struct */
     
    26902691
    26912692  /* allocate memory for info structure */
    2692   infoPtr = (TREEVIEW_INFO *) COMCTL32_Alloc (sizeof(TREEVIEW_INFO));
    2693 
    2694   SetWindowLongA( hwnd, 0, (DWORD)infoPtr);
     2693  infoPtr = (TREEVIEW_INFO*)initControl(hwnd,sizeof(TREEVIEW_INFO));
    26952694
    26962695  if (infoPtr == NULL) return 0;
    2697 
    2698   if ((TREEVIEW_INFO*)GetWindowLongA(hwnd,0) != infoPtr) return 0;
    26992696
    27002697  hdc = GetDC(hwnd);
     
    27022699  /* set default settings */
    27032700  infoPtr->uInternalStatus = TV_CALCALL;
    2704   if (IsWindowUnicode(hwnd)) infoPtr->uInternalStatus |= TV_UNICODE;
    27052701  infoPtr->uNumItems = 0;
    27062702  infoPtr->clrBk   = GetSysColor (COLOR_WINDOW);
     
    28092805   DeleteObject(infoPtr->hBoldFont);
    28102806   COMCTL32_Free(infoPtr->pszISearch);
    2811    COMCTL32_Free (infoPtr);
     2807   doneControl(hwnd);
    28122808
    28132809   return 0;
     
    29062902  TREEVIEW_ITEM  *wineItem;
    29072903  HWND parent = GetParent(hwnd);
    2908   BOOL unicode = IsWindowUnicode(parent),rc;
    29092904  CHAR *oldText = NULL,*newText = NULL;
     2905  BOOL rc;
    29102906
    29112907  ZeroMemory(&nmhdr,sizeof(NMTREEVIEWW));
     
    29232919    nmhdr.itemOld.stateMask = wineItem->stateMask;
    29242920    nmhdr.itemOld.iImage    = wineItem->iImage;
    2925     if (!unicode)
     2921    if (infoPtr->header.uNotifyFormat == NFR_ANSI)
    29262922    {
    29272923      if (!wineItem->pszText) nmhdr.itemOld.pszText = NULL; else
     
    29492945    nmhdr.itemNew.stateMask = wineItem->stateMask;
    29502946    nmhdr.itemNew.iImage    = wineItem->iImage;
    2951     if (!unicode)
     2947    if (infoPtr->header.uNotifyFormat == NFR_ANSI)
    29522948    {
    29532949      if (!wineItem->pszText) nmhdr.itemOld.pszText = NULL; else
     
    29702966  nmhdr.ptDrag.y = 0;
    29712967
    2972   if (unicode)
    2973     rc = (BOOL)SendMessageW(parent,WM_NOTIFY,(WPARAM)GetWindowLongW(hwnd,GWL_ID),(LPARAM)&nmhdr);
    2974   else
    2975     rc = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)GetWindowLongA(hwnd,GWL_ID),(LPARAM)&nmhdr);
     2968  rc = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr);
    29762969
    29772970  if (oldText) COMCTL32_Free(oldText);
     
    30103003TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem, UINT code, UINT what)
    30113004{
     3005  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    30123006  NMTVDISPINFOW tvdi;
    30133007  BOOL retval;
    30143008  WCHAR *buf;
    30153009  HWND parent = GetParent(hwnd);
    3016   BOOL unicode = IsWindowUnicode(parent);
    30173010
    30183011  tvdi.hdr.hwndFrom     = hwnd;
     
    30233016  tvdi.item.state       = wineItem->state;
    30243017  tvdi.item.lParam      = wineItem->lParam;
    3025   tvdi.item.pszText     = COMCTL32_Alloc(128*(unicode? sizeof(WCHAR):sizeof(char)));
     3018  tvdi.item.pszText     = COMCTL32_Alloc(128*((infoPtr->header.uNotifyFormat == NFR_UNICODE) ? sizeof(WCHAR):sizeof(char)));
    30263019  tvdi.item.cchTextMax = 128;
    30273020  buf = tvdi.item.pszText;
    30283021
    3029   if (unicode)
    3030     retval = (BOOL)SendMessageW(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi);
    3031   else
    3032     retval = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi);
     3022  retval = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi);
    30333023
    30343024  /* Ignore posible changes */
     
    30383028  if (what & TVIF_TEXT)
    30393029  {
    3040     if (unicode)
     3030    if (infoPtr->header.uNotifyFormat == NFR_UNICODE)
    30413031    {
    30423032      wineItem->pszText = tvdi.item.pszText;
     
    30693059
    30703060  if (what & TVIF_SELECTEDIMAGE)
    3071                 wineItem->iSelectedImage = tvdi.item.iSelectedImage;
     3061    wineItem->iSelectedImage = tvdi.item.iSelectedImage;
    30723062  if (what & TVIF_IMAGE)
    3073                 wineItem->iImage         = tvdi.item.iImage;
     3063    wineItem->iImage         = tvdi.item.iImage;
    30743064  if (what & TVIF_CHILDREN)
    3075                 wineItem->cChildren      = tvdi.item.cChildren;
    3076 
    3077  return retval;
     3065    wineItem->cChildren      = tvdi.item.cChildren;
     3066
     3067  return retval;
    30783068}
    30793069
     
    30863076  LPNMCUSTOMDRAW nmcd;
    30873077
    3088   nmcd= & nmcdhdr.nmcd;
     3078  nmcd =& nmcdhdr.nmcd;
    30893079  nmcd->hdr.hwndFrom = hwnd;
    30903080  nmcd->hdr.idFrom =  GetWindowLongA( hwnd, GWL_ID);
     
    34523442  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    34533443  HWND parent = GetParent(hwnd);
    3454   BOOL unicode = IsWindowUnicode(parent);
    34553444  BOOL bCommit;
    34563445  WCHAR *textW = NULL;
     
    34793468    //}
    34803469
    3481     if (unicode) tvdi.item.pszText = textW; else
     3470    if (infoPtr->header.uNotifyFormat == NFR_UNICODE) tvdi.item.pszText = textW; else
    34823471    {
    34833472      INT len = iLength+1;
     
    34953484  }
    34963485
    3497   if (unicode)
    3498     bCommit=(BOOL)SendMessageW(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi);
    3499   else
    3500     bCommit=(BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi);
     3486  bCommit = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi);
    35013487
    35023488  if (!bCancel && bCommit) /* Apply the changes */
    35033489  {
    3504     if (!unicode)
     3490    if (infoPtr->header.uNotifyFormat == NFR_ANSI)
    35053491      lstrcpynAtoW(textW,textA,iLength+1);
    35063492    if (lstrcmpW(textW,editedItem->pszText) != 0)
     
    36463632        NMTVGETINFOTIPW tvgit;
    36473633        HWND parent = GetParent(hwnd);
    3648         BOOL unicode = IsWindowUnicode(parent);
    36493634
    36503635        tvgit.hdr.hwndFrom = hwnd;
    36513636        tvgit.hdr.idFrom   =  GetWindowLongA(hwnd,GWL_ID);
    3652         tvgit.hdr.code     = unicode ? TVN_GETINFOTIPW:TVN_GETINFOTIPA;
    3653         tvgit.pszText    = COMCTL32_Alloc(unicode ? INFOTIPSIZE*sizeof(WCHAR):INFOTIPSIZE*sizeof(CHAR));
     3637        tvgit.hdr.code     = (infoPtr->header.uNotifyFormat == NFR_UNICODE) ? TVN_GETINFOTIPW:TVN_GETINFOTIPA;
     3638        tvgit.pszText    = COMCTL32_Alloc((infoPtr->header.uNotifyFormat == NFR_UNICODE) ? INFOTIPSIZE*sizeof(WCHAR):INFOTIPSIZE*sizeof(CHAR));
    36543639        tvgit.cchTextMax = INFOTIPSIZE;
    36553640        tvgit.hItem      = item->hItem;
    36563641        tvgit.lParam     = item->lParam;
    36573642
    3658         if (unicode)
     3643        SendMessageA(parent,WM_NOTIFY,(WPARAM)tvgit.hdr.idFrom,(LPARAM)&tvgit);
     3644        if (infoPtr->header.uNotifyFormat == NFR_UNICODE)
    36593645        {
    3660           SendMessageW(parent,WM_NOTIFY,(WPARAM)tvgit.hdr.idFrom,(LPARAM)&tvgit);
    36613646          text = tvgit.pszText;
    36623647        } else
    36633648        {
    3664           SendMessageA(parent,WM_NOTIFY,(WPARAM)tvgit.hdr.idFrom,(LPARAM)&tvgit);
    36653649          text = COMCTL32_Alloc(tvgit.cchTextMax*sizeof(WCHAR));
    36663650          lstrcpyAtoW(text,(LPSTR)tvgit.pszText);
     
    45984582}
    45994583
    4600 static LRESULT TREEVIEW_GetUnicodeFormat(HWND hwnd,WPARAM wParam,LPARAM lParam)
    4601 {
    4602   TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    4603 
    4604   return infoPtr->uInternalStatus & TV_UNICODE;
    4605 }
    4606 
    4607 static LRESULT TREEVIEW_SetUnicodeFormat(HWND hwnd,WPARAM wParam,LPARAM lParam)
    4608 {
    4609   TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    4610   BOOL oldFormat = infoPtr->uInternalStatus & TV_UNICODE;
    4611 
    4612   if (wParam)
    4613     infoPtr->uInternalStatus |= TV_UNICODE;
    4614   else
    4615     infoPtr->uInternalStatus &= ~TV_UNICODE;
    4616 
    4617   return oldFormat;
    4618 }
    4619 
    46204584static LRESULT WINAPI
    46214585TREEVIEW_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
     
    47604724        case TVM_GETINSERTMARKCOLOR:
    47614725                return TREEVIEW_GetInsertMarkColor (hwnd,wParam, lParam);
    4762 
    4763         case TVM_GETUNICODEFORMAT:
    4764                 return TREEVIEW_GetUnicodeFormat(hwnd,wParam,lParam);
    4765 
    4766         case TVM_SETUNICODEFORMAT:
    4767                 return TREEVIEW_SetUnicodeFormat(hwnd,wParam,lParam);
    47684726
    47694727        case WM_COMMAND:
     
    48534811              //  FIXME (treeview, "Unknown msg %04x wp=%08x lp=%08lx\n",
    48544812              //     uMsg, wParam, lParam);
    4855             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     4813            return defComCtl32ProcA(hwnd,uMsg,wParam,lParam);
    48564814      }
    48574815    return 0;
Note: See TracChangeset for help on using the changeset viewer.