Changeset 3243 for trunk/src/shell32/shlview.cpp
- Timestamp:
- Mar 26, 2000, 6:34:57 PM (25 years ago)
- 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:28cbratschi Exp $ */1 /* $Id: shlview.cpp,v 1.9 2000-03-26 16:34:54 cbratschi Exp $ */ 2 2 /* 3 3 * ShellView 4 4 * 5 * Copyright 2000 Christoph Bratschi (cbratschi@datacomm.ch) 6 * 5 7 * Copyright 1998,1999 <juergen.schmied@metronet.de> 6 8 * 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 23 32 */ 24 33 … … 83 92 84 93 extern struct ICOM_VTABLE(IShellView) svvt; 94 85 95 extern struct ICOM_VTABLE(IOleCommandTarget) ctvt; 86 96 #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); 88 98 89 99 extern struct ICOM_VTABLE(IDropTarget) dtvt; 90 100 #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); 92 102 93 103 extern struct ICOM_VTABLE(IDropSource) dsvt; 94 104 #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); 96 106 97 107 extern struct ICOM_VTABLE(IViewObject) vovt; 98 108 #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); 100 110 101 111 /* ListView Header ID's */ 102 #define LISTVIEW_COLUMN_NAME 0103 #define LISTVIEW_COLUMN_SIZE 1104 #define LISTVIEW_COLUMN_TYPE 2105 #define LISTVIEW_COLUMN_TIME 3106 #define LISTVIEW_COLUMN_ATTRIB 4112 #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 107 117 //CB: todo: drive view! 108 118 … … 215 225 return ret; 216 226 } 217 /********************************************************** 218 219 * ##### helperfunctions for initializing the view #####220 * /221 /********************************************************** 222 * set the toolbar buttons227 228 /********************************************************** 229 * set the toolbar of the filedialog buttons 230 * 231 * - activates the buttons from the shellbrowser according to 232 * the view state 223 233 */ 224 234 static void CheckToolbar(IShellViewImpl * This) … … 242 252 243 253 /********************************************************** 254 * 255 * ##### helperfunctions for initializing the view ##### 256 */ 257 258 /********************************************************** 244 259 * change the style of the listview control 245 260 */ … … 257 272 * ShellView_CreateList() 258 273 * 274 * - creates the list view window 259 275 */ 260 276 static BOOL ShellView_CreateList (IShellViewImpl * This) … … 275 291 } 276 292 277 if (This->FolderSettings.fFlags & &FWF_AUTOARRANGE) dwStyle |= LVS_AUTOARRANGE;293 if (This->FolderSettings.fFlags & FWF_AUTOARRANGE) dwStyle |= LVS_AUTOARRANGE; 278 294 /*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; 280 300 281 301 This->hWndList=CreateWindowExA( WS_EX_CLIENTEDGE, … … 292 312 return FALSE; 293 313 294 This->ListViewSortInfo.bIsAscending = TRUE;295 This->ListViewSortInfo.nHeaderID = -1;296 This->ListViewSortInfo.nLastHeaderID = -1;297 298 314 /* 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 299 323 return TRUE; 300 324 } … … 302 326 * ShellView_InitList() 303 327 * 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 308 329 */ 309 330 static BOOL ShellView_InitList(IShellViewImpl * This) … … 409 430 /* Sort by Time: Folders or Files can be sorted */ 410 431 411 if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TIME)432 if(pSortInfo->nHeaderID == FILEDIALOG_COLUMN_TIME) 412 433 { 413 434 _ILGetFileDateTime(pItemIdList1, &fd1); … … 416 437 } 417 438 /* 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) 419 440 { 420 _ILGet AttributeStr(pItemIdList1, strName1, MAX_PATH);421 _ILGet AttributeStr(pItemIdList2, strName2, MAX_PATH);441 _ILGetFileAttributes(pItemIdList1, strName1, MAX_PATH); 442 _ILGetFileAttributes(pItemIdList2, strName2, MAX_PATH); 422 443 nDiff = strcmp(strName1, strName2); 423 444 } 424 445 /* 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) 426 447 { 427 448 /* Sort by Text */ … … 431 452 } 432 453 /* Sort by File Size, Only valid for Files */ 433 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_SIZE)454 else if(pSortInfo->nHeaderID == FILEDIALOG_COLUMN_SIZE) 434 455 { 435 456 nDiff = (INT)(_ILGetFileSize(pItemIdList1, NULL, 0) - _ILGetFileSize(pItemIdList2, NULL, 0)); 436 457 } 437 458 /* Sort by File Type, Only valid for Files */ 438 else if(pSortInfo->nHeaderID == LISTVIEW_COLUMN_TYPE)459 else if(pSortInfo->nHeaderID == FILEDIALOG_COLUMN_TYPE) 439 460 { 440 461 /* Sort by Type */ … … 465 486 * ShellView_FillList() 466 487 * 467 * NOTES 468 * internal 488 * - gets the objectlist from the shellfolder 489 * - sorts the list 490 * - fills the list into the view 469 491 */ 470 492 … … 540 562 /*turn the listview's redrawing back on and force it to draw*/ 541 563 SendMessageA(This->hWndList, WM_SETREDRAW, TRUE, 0); 542 InvalidateRect(This->hWndList, NULL, TRUE);543 UpdateWindow(This->hWndList);544 564 545 565 IEnumIDList_Release(pEnumIDList); /* destroy the list*/ … … 777 797 ZeroMemory(&cmi, sizeof(cmi)); 778 798 cmi.cbSize = sizeof(cmi); 779 cmi.hwnd = This->hWnd Parent;799 cmi.hwnd = This->hWnd; 780 800 cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand); 781 801 IContextMenu_InvokeCommand(pContextMenu, &cmi); … … 1017 1037 break; 1018 1038 1039 case ID_NEWFOLDER: 1040 PostMessageA (GetParent (This->hWnd), WM_COMMAND, ID_NEWFOLDER, 0L); 1041 break; 1042 1043 1019 1044 default: 1020 1045 TRACE("-- COMMAND 0x%04lx unhandled\n", dwCmdID); 1021 1046 } 1022 1047 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 */ 1066 static 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; 1023 1135 } 1024 1136 … … 1106 1218 1107 1219 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 } 1110 1225 break; 1111 1226 … … 1143 1258 1144 1259 case LVN_BEGINLABELEDITA: 1260 return FALSE; 1261 1145 1262 case LVN_ENDLABELEDITA: 1146 FIXME("labeledit\n"); 1147 break; 1263 { 1264 return ShellView_OnEndLabelEdit(This,lpdi); 1265 } 1148 1266 1149 1267 default: … … 1329 1447 static HRESULT WINAPI IShellView_fnTranslateAccelerator(IShellView * iface,LPMSG lpmsg) 1330 1448 { 1449 #if 0 1331 1450 ICOM_THIS(IShellViewImpl, iface); 1332 1451 1333 #if 01334 1452 FIXME("(%p)->(%p: hwnd=%x msg=%x lp=%lx wp=%x) stub\n",This,lpmsg, lpmsg->hwnd, lpmsg->message, lpmsg->lParam, lpmsg->wParam); 1335 1453 #endif … … 1531 1649 } 1532 1650 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 */ 1533 1668 static 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; 1539 1741 } 1540 1742
Note:
See TracChangeset
for help on using the changeset viewer.