Ignore:
Timestamp:
Mar 26, 2000, 6:34:57 PM (25 years ago)
Author:
cbratschi
Message:

merged with Corel WINE 20000324

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/shell32/shlview.cpp

    r3217 r3243  
    1 /* $Id: shlview.cpp,v 1.8 2000-03-24 17:17:28 cbratschi Exp $ */
     1/* $Id: shlview.cpp,v 1.9 2000-03-26 16:34:54 cbratschi Exp $ */
    22/*
    33 * ShellView
    44 *
     5 * Copyright 2000 Christoph Bratschi (cbratschi@datacomm.ch)
     6 *
    57 * Copyright 1998,1999                   <juergen.schmied@metronet.de>
    68 *
    7  *  FIXME: when the ShellView_WndProc gets a WM_NCDESTROY should we do a
    8  *  Release() ???
    9  *
    10  *  FIXME: There is still a design problem in this implementation.
    11  * This implementation is more or less ok for file system folders
    12  * but there are many more kinds of folders.
    13  * The shellview is not supposed to know much about the colums
    14  * appearing in the view. To fix this it should use the IShellFolder2
    15  * interface when possible to get the informations dynamically
    16  * this will take a lot of work to implement and wont likely not
    17  * be done in near future
    18  * Please considder this when code new features. Mail me if you
    19  * are in doubt how to do things. (jsch 25/10/99)
    20  *
    21  * FIXME: Set the buttons in the filedialog according to the view state
    22 
     9 * This is the view visualizing the data provied by the shellfolder.
     10 * No direct access to data from pidls should be done from here.
     11 *
     12 * FIXME: There is not jet a official interface defined to manipulate
     13 * the objects shown in the view (rename, move...). This should be
     14 * implemented as additional interface to IShellFolder.
     15 *
     16 * FIXME: The order by part of the background context menu should be
     17 * buily according to the columns shown.
     18 *
     19 * FIXME: Load/Save the view state from/into the stream provied by
     20 * the ShellBrowser
     21 *
     22 * FIXME: CheckToolbar: handle the "new folder" and "folder up" button
     23 *
     24 * FIXME: ShellView_FillList: consider sort orders
     25 *
     26 * FIXME: implement the drag and drop in the old (msg-based) way
     27 *
     28 * FIXME: when the ShellView_WndProc gets a WM_NCDESTROY should we do a
     29 * Release() ???
     30 *
     31 * Corel WINE 20000324 level
    2332 */
    2433
     
    8392
    8493extern struct ICOM_VTABLE(IShellView) svvt;
     94
    8595extern struct ICOM_VTABLE(IOleCommandTarget) ctvt;
    8696#define _IOleCommandTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblOleCommandTarget)))
    87 #define _ICOM_THIS_From_IOleCommandTarget(myClass, name) myClass* This = (myClass*)(((char*)name)-_IOleCommandTarget_Offset);
     97#define _ICOM_THIS_From_IOleCommandTarget(class, name) class* This = (class*)(((char*)name)-_IOleCommandTarget_Offset);
    8898
    8999extern struct ICOM_VTABLE(IDropTarget) dtvt;
    90100#define _IDropTarget_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropTarget)))
    91 #define _ICOM_THIS_From_IDropTarget(myClass, name) myClass* This = (myClass*)(((char*)name)-_IDropTarget_Offset);
     101#define _ICOM_THIS_From_IDropTarget(class, name) class* This = (class*)(((char*)name)-_IDropTarget_Offset);
    92102
    93103extern struct ICOM_VTABLE(IDropSource) dsvt;
    94104#define _IDropSource_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblDropSource)))
    95 #define _ICOM_THIS_From_IDropSource(myClass, name) myClass* This = (myClass*)(((char*)name)-_IDropSource_Offset);
     105#define _ICOM_THIS_From_IDropSource(class, name) class* This = (class*)(((char*)name)-_IDropSource_Offset);
    96106
    97107extern struct ICOM_VTABLE(IViewObject) vovt;
    98108#define _IViewObject_Offset ((int)(&(((IShellViewImpl*)0)->lpvtblViewObject)))
    99 #define _ICOM_THIS_From_IViewObject(myClass, name) myClass* This = (myClass*)(((char*)name)-_IViewObject_Offset);
     109#define _ICOM_THIS_From_IViewObject(class, name) class* This = (class*)(((char*)name)-_IViewObject_Offset);
    100110
    101111/* ListView Header ID's */
    102 #define LISTVIEW_COLUMN_NAME 0
    103 #define LISTVIEW_COLUMN_SIZE 1
    104 #define LISTVIEW_COLUMN_TYPE 2
    105 #define LISTVIEW_COLUMN_TIME 3
    106 #define LISTVIEW_COLUMN_ATTRIB 4
     112#define FILEDIALOG_COLUMN_NAME 0
     113#define FILEDIALOG_COLUMN_SIZE 1
     114#define FILEDIALOG_COLUMN_TYPE 2
     115#define FILEDIALOG_COLUMN_TIME 3
     116#define FILEDIALOG_COLUMN_ATTRIB 4
    107117//CB: todo: drive view!
    108118
     
    215225   return ret;
    216226}
    217 /**********************************************************
    218  *
    219  * ##### helperfunctions for initializing the view #####
    220  */
    221 /**********************************************************
    222  * set the toolbar buttons
     227
     228/**********************************************************
     229 *      set the toolbar of the filedialog buttons
     230 *
     231 * - activates the buttons from the shellbrowser according to
     232 *   the view state
    223233 */
    224234static void CheckToolbar(IShellViewImpl * This)
     
    242252
    243253/**********************************************************
     254 *
     255 * ##### helperfunctions for initializing the view #####
     256 */
     257
     258/**********************************************************
    244259 * change the style of the listview control
    245260 */
     
    257272* ShellView_CreateList()
    258273*
     274* - creates the list view window
    259275*/
    260276static BOOL ShellView_CreateList (IShellViewImpl * This)
     
    275291   }
    276292
    277    if (This->FolderSettings.fFlags && FWF_AUTOARRANGE)  dwStyle |= LVS_AUTOARRANGE;
     293   if (This->FolderSettings.fFlags & FWF_AUTOARRANGE)  dwStyle |= LVS_AUTOARRANGE;
    278294   /*if (This->FolderSettings.fFlags && FWF_DESKTOP); used from explorer*/
    279    if (This->FolderSettings.fFlags && FWF_SINGLESEL) dwStyle |= LVS_SINGLESEL;
     295   if (This->FolderSettings.fFlags & FWF_SINGLESEL) dwStyle |= LVS_SINGLESEL;
     296
     297   This->ListViewSortInfo.bIsAscending = TRUE;
     298   This->ListViewSortInfo.nHeaderID = -1;
     299   This->ListViewSortInfo.nLastHeaderID = -1;
    280300
    281301   This->hWndList=CreateWindowExA( WS_EX_CLIENTEDGE,
     
    292312     return FALSE;
    293313
    294         This->ListViewSortInfo.bIsAscending = TRUE;
    295         This->ListViewSortInfo.nHeaderID = -1;
    296         This->ListViewSortInfo.nLastHeaderID = -1;
    297 
    298314   /*  UpdateShellSettings(); */
     315
     316   /* Bring window to the Top
     317      if there is any user defined template then we cannot
     318      see this list control
     319   */
     320   BringWindowToTop(This->hWnd);
     321   BringWindowToTop(This->hWndList);
     322
    299323   return TRUE;
    300324}
     
    302326* ShellView_InitList()
    303327*
    304 * NOTES
    305 *  FIXME: the headers should depend on the kind of shellfolder
    306 *  thats creating the shellview. this hack implements only the
    307 *  correct headers for a filesystem folder (jsch 25/10/99)
     328* - adds all needed columns to the shellview
    308329*/
    309330static BOOL ShellView_InitList(IShellViewImpl * This)
     
    409430        /* Sort by Time: Folders or Files can be sorted */
    410431
    411         if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TIME)
     432        if(pSortInfo->nHeaderID == FILEDIALOG_COLUMN_TIME)
    412433        {
    413434            _ILGetFileDateTime(pItemIdList1, &fd1);
     
    416437        }
    417438        /* Sort by Attribute: Folder or Files can be sorted */
    418         else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_ATTRIB)
     439        else if(pSortInfo->nHeaderID == FILEDIALOG_COLUMN_ATTRIB)
    419440        {
    420             _ILGetAttributeStr(pItemIdList1, strName1, MAX_PATH);
    421             _ILGetAttributeStr(pItemIdList2, strName2, MAX_PATH);
     441            _ILGetFileAttributes(pItemIdList1, strName1, MAX_PATH);
     442            _ILGetFileAttributes(pItemIdList2, strName2, MAX_PATH);
    422443            nDiff = strcmp(strName1, strName2);
    423444        }
    424445        /* Sort by FileName: Folder or Files can be sorted */
    425         else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_NAME || bIsBothFolder)
     446        else if(pSortInfo->nHeaderID == FILEDIALOG_COLUMN_NAME || bIsBothFolder)
    426447        {
    427448            /* Sort by Text */
     
    431452        }
    432453        /* Sort by File Size, Only valid for Files */
    433         else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_SIZE)
     454        else if(pSortInfo->nHeaderID == FILEDIALOG_COLUMN_SIZE)
    434455        {
    435456            nDiff = (INT)(_ILGetFileSize(pItemIdList1, NULL, 0) - _ILGetFileSize(pItemIdList2, NULL, 0));
    436457        }
    437458        /* Sort by File Type, Only valid for Files */
    438         else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TYPE)
     459        else if(pSortInfo->nHeaderID == FILEDIALOG_COLUMN_TYPE)
    439460        {
    440461            /* Sort by Type */
     
    465486* ShellView_FillList()
    466487*
    467 * NOTES
    468 *  internal
     488* - gets the objectlist from the shellfolder
     489* - sorts the list
     490* - fills the list into the view
    469491*/
    470492
     
    540562   /*turn the listview's redrawing back on and force it to draw*/
    541563   SendMessageA(This->hWndList, WM_SETREDRAW, TRUE, 0);
    542    InvalidateRect(This->hWndList, NULL, TRUE);
    543    UpdateWindow(This->hWndList);
    544564
    545565   IEnumIDList_Release(pEnumIDList); /* destroy the list*/
     
    777797          ZeroMemory(&cmi, sizeof(cmi));
    778798          cmi.cbSize = sizeof(cmi);
    779           cmi.hwnd = This->hWndParent;
     799          cmi.hwnd = This->hWnd;
    780800          cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand);
    781801          IContextMenu_InvokeCommand(pContextMenu, &cmi);
     
    10171037       break;
    10181038
     1039     case ID_NEWFOLDER:
     1040       PostMessageA (GetParent (This->hWnd), WM_COMMAND, ID_NEWFOLDER, 0L);
     1041       break;
     1042
     1043
    10191044     default:
    10201045       TRACE("-- COMMAND 0x%04lx unhandled\n", dwCmdID);
    10211046   }
    10221047   return 0;
     1048}
     1049
     1050/*************************************************************************
     1051 * ShellView_OnEndLabelEdit [Internal]
     1052 *
     1053 * Message handling for LVN_ENDLABELEDIT.  This function will rename a
     1054 * file and rename the pidl to match it's new name.
     1055 *
     1056 * PARAMS
     1057 *     This        [I] ShellView structure
     1058 *     lpdi        [I] Listview Display info struct
     1059 *
     1060 * RETURNS
     1061 *     TRUE if the listview should keep the edit text otherwise FALSE
     1062 *
     1063 * NOTES
     1064 *     This funciton will pop a message box if an error occures
     1065 */
     1066static LRESULT ShellView_OnEndLabelEdit(IShellViewImpl *This, NMLVDISPINFOA *lpdi)
     1067{
     1068    char strOldPath[MAX_PATH];
     1069    char strNewPath[MAX_PATH];
     1070    char strMsgTitle[256];
     1071    char strMsgText[256];
     1072
     1073    LPSTR strDestName;
     1074    BOOL bRet = FALSE;
     1075    LPITEMIDLIST pidl = (LPITEMIDLIST)lpdi->item.lParam;
     1076    DWORD type;
     1077    STRRET   str;
     1078
     1079    if(lpdi->item.pszText != NULL && lpdi->item.cchTextMax > 0)
     1080    {
     1081        strDestName = lpdi->item.pszText;
     1082
     1083        /* Check for valid Destnation Name */
     1084        if(strpbrk(strDestName,"/\\:*?\"<>|") != NULL)
     1085        {
     1086            LoadStringA(shell32_hInstance, IDS_SHV_INVALID_FILENAME_TITLE, strMsgTitle, sizeof(strMsgTitle));
     1087            LoadStringA(shell32_hInstance, IDS_SHV_INVALID_FILENAME, strMsgText, sizeof(strMsgText));
     1088            MessageBoxA(This->hWnd,strMsgText, strMsgTitle, MB_OK | MB_ICONHAND);
     1089            return FALSE;
     1090        }
     1091
     1092        if(SUCCEEDED(IShellFolder_GetDisplayNameOf(This->pSFParent,pidl, SHGDN_NORMAL | SHGDN_FORPARSING, &str)))
     1093        {
     1094            char *pLastSlash;
     1095            StrRetToStrNA(strOldPath, MAX_PATH, &str, pidl);
     1096
     1097
     1098            /* Set the complete path of the new filename */
     1099            strcpy(strNewPath, strOldPath);
     1100            pLastSlash = strrchr(strNewPath, '\\');
     1101            if(pLastSlash != NULL)
     1102            {
     1103              pLastSlash[1] = 0;
     1104            }
     1105            strcat(strNewPath, strDestName);
     1106
     1107            /* Are the string the same */
     1108            if(strcmp(strNewPath, strOldPath) != 0)
     1109            {
     1110                if(MoveFileA(strOldPath, strNewPath) != 0)
     1111                {
     1112                    /* Update the pidl with the new filename */
     1113                    type   = _ILGetDataPointer(pidl)->type;
     1114                    LPSTR pStr = _ILGetTextPointer(type,_ILGetDataPointer(pidl));
     1115                    strcpy(pStr, strDestName);
     1116
     1117                    /* Remove the current selection from the listview */
     1118                    ListView_SetItemState(This->hWndList,lpdi->item.iItem,0,LVIS_SELECTED);
     1119                    bRet = TRUE;
     1120                }
     1121                else
     1122                {
     1123                    /* Cannot move file, so display a message */
     1124                    char pBuffer[256+MAX_PATH];
     1125                    LoadStringA(shell32_hInstance, IDS_SHV_INVALID_MOVE_TITLE, strMsgTitle, sizeof(strMsgTitle));
     1126                    LoadStringA(shell32_hInstance, IDS_SHV_INVALID_MOVE, strMsgText, sizeof(strMsgText));
     1127                    sprintf(pBuffer, strMsgText, strDestName);
     1128                    MessageBoxA(This->hWnd,pBuffer,strMsgTitle, MB_OK | MB_ICONHAND);
     1129                }
     1130            }
     1131        }
     1132
     1133    }
     1134    return bRet;
    10231135}
    10241136
     
    11061218
    11071219     case LVN_ITEMCHANGED:
    1108        TRACE("-- LVN_ITEMCHANGED %p\n",This);
    1109        OnStateChange(This, CDBOSC_SELCHANGE);  /* the browser will get the IDataObject now */
     1220       if (ListView_GetNextItem(This->hWndList, -1, LVNI_FOCUSED) == lpnmlv->iItem)
     1221       {
     1222         TRACE("-- LVN_ITEMCHANGED %p\n",This);
     1223         OnStateChange(This, CDBOSC_SELCHANGE);  /* the browser will get the IDataObject now */
     1224       }
    11101225       break;
    11111226
     
    11431258
    11441259     case LVN_BEGINLABELEDITA:
     1260       return FALSE;
     1261
    11451262     case LVN_ENDLABELEDITA:
    1146         FIXME("labeledit\n");
    1147         break;
     1263       {
     1264         return ShellView_OnEndLabelEdit(This,lpdi);
     1265       }
    11481266
    11491267     default:
     
    13291447static HRESULT WINAPI IShellView_fnTranslateAccelerator(IShellView * iface,LPMSG lpmsg)
    13301448{
     1449#if 0
    13311450   ICOM_THIS(IShellViewImpl, iface);
    13321451
    1333 #if 0
    13341452   FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%lx wp=%x) stub\n",This,lpmsg, lpmsg->hwnd, lpmsg->message, lpmsg->lParam, lpmsg->wParam);
    13351453#endif
     
    15311649}
    15321650
     1651/*************************************************************************
     1652 * IShellView_fnSelectItem
     1653 *
     1654 * Changes the selection state of one or more items within the shell
     1655 * view window.
     1656 *
     1657 * PARAMS
     1658 *     iFace       [I] The IShellView structure
     1659 *     pidlItem    [I] Address of the ITEMIDLIST structure
     1660 *     uFlags      [I] Flag specifying what type of selection to apply.
     1661 *
     1662 * RETURNS
     1663 *  Returns NOERROR if successful otherwise S_FALSE
     1664 *
     1665 * NOTES
     1666 *   CB: can't use ListView_SetItemState return value: MS's macro doesn't return a value
     1667 */
    15331668static HRESULT WINAPI IShellView_fnSelectItem(IShellView * iface, LPCITEMIDLIST pidlItem, UINT uFlags)
    1534 {  ICOM_THIS(IShellViewImpl, iface);
    1535 
    1536    FIXME("(%p)->(pidl=%p, 0x%08x) stub\n",This, pidlItem, uFlags);
    1537 
    1538    return E_NOTIMPL;
     1669{       ICOM_THIS(IShellViewImpl, iface);
     1670
     1671    LVITEMA lvItem;
     1672    int iItem=-1;
     1673    BOOL bIsFound = FALSE;
     1674    HRESULT hResult = NOERROR;
     1675
     1676    /* Find the Listview item index */
     1677    ZeroMemory(&lvItem, sizeof(lvItem));
     1678    lvItem.mask = LVIF_PARAM;
     1679    lvItem.iItem = 0;
     1680    while(ListView_GetItemA(This->hWndList, &lvItem) && !bIsFound)
     1681    {
     1682        if(ILIsEqual((LPCITEMIDLIST)lvItem.lParam, pidlItem))
     1683        {
     1684            iItem = lvItem.iItem;
     1685            bIsFound = TRUE;
     1686        }
     1687        lvItem.iItem++;
     1688    }
     1689
     1690    if(!bIsFound)
     1691    {
     1692        return S_FALSE;
     1693    }
     1694
     1695    /* Perform flag operations */
     1696    if(SVSI_DESELECT & uFlags)
     1697    {
     1698        ListView_SetItemState(This->hWndList,iItem,0,LVIS_SELECTED);
     1699    }
     1700
     1701    if(SVSI_DESELECTOTHERS & uFlags)
     1702    {
     1703        int iOtherItems=-1;
     1704        iOtherItems = ListView_GetNextItem(This->hWndList, iOtherItems, LVNI_ALL);
     1705        while(iOtherItems != -1)
     1706        {
     1707            if(iOtherItems != iItem)
     1708            {
     1709                ListView_SetItemState(This->hWndList,iOtherItems,0,LVIS_SELECTED);
     1710            }
     1711            iOtherItems = ListView_GetNextItem(This->hWndList, iOtherItems, LVNI_ALL);
     1712        }
     1713    }
     1714
     1715    if(SVSI_ENSUREVISIBLE & uFlags)
     1716    {
     1717        if(ListView_EnsureVisible(This->hWndList, iItem, FALSE) != TRUE)
     1718        {
     1719            hResult = S_FALSE;
     1720        }
     1721    }
     1722
     1723    if(SVSI_FOCUSED  & uFlags)
     1724    {
     1725        ListView_SetItemState(This->hWndList,iItem,LVIS_FOCUSED,LVIS_FOCUSED);
     1726    }
     1727
     1728    if(SVSI_SELECT & uFlags)
     1729    {
     1730        ListView_SetItemState(This->hWndList,iItem,LVIS_FOCUSED,LVIS_FOCUSED);
     1731    }
     1732
     1733    if(SVSI_EDIT & uFlags)
     1734    {
     1735        if(ListView_EditLabelA(This->hWndList, iItem) != 0)
     1736        {
     1737            hResult = S_FALSE;
     1738        }
     1739    }
     1740    return NOERROR;
    15391741}
    15401742
Note: See TracChangeset for help on using the changeset viewer.