6 #include "../../../../C/Alloc.h"
\r
8 #include "Common/MyCom.h"
\r
10 #include "Windows/DLL.h"
\r
11 #include "Windows/FileDir.h"
\r
12 #include "Windows/FileFind.h"
\r
13 #include "Windows/Handle.h"
\r
14 #include "Windows/Synchronization.h"
\r
16 #include "Windows/Control/ComboBox.h"
\r
17 #include "Windows/Control/Edit.h"
\r
18 #include "Windows/Control/ListView.h"
\r
19 #include "Windows/Control/ReBar.h"
\r
20 #include "Windows/Control/Static.h"
\r
21 #include "Windows/Control/StatusBar.h"
\r
22 #include "Windows/Control/ToolBar.h"
\r
23 #include "Windows/Control/Window2.h"
\r
25 #include "AppState.h"
\r
26 #include "IFolder.h"
\r
28 #include "ProgressDialog2.h"
\r
29 #include "SysIconUtils.h"
\r
31 const int kParentFolderID = 100;
\r
32 const int kPluginMenuStartID = 1000;
\r
33 const int kToolbarStartID = 2000;
\r
35 const int kParentIndex = -1;
\r
38 #define ROOT_FS_FOLDER L"\\"
\r
40 #define ROOT_FS_FOLDER L"C:\\\\"
\r
43 struct CPanelCallback
\r
45 virtual void OnTab() = 0;
\r
46 virtual void SetFocusToPath(int index) = 0;
\r
47 virtual void OnCopy(bool move, bool copyToSame) = 0;
\r
48 virtual void OnSetSameFolder() = 0;
\r
49 virtual void OnSetSubFolder() = 0;
\r
50 virtual void PanelWasFocused() = 0;
\r
51 virtual void DragBegin() = 0;
\r
52 virtual void DragEnd() = 0;
\r
53 virtual void RefreshTitle(bool always) = 0;
\r
56 void PanelCopyItems();
\r
58 struct CItemProperty
\r
68 inline bool operator<(const CItemProperty &a1, const CItemProperty &a2)
\r
69 { return (a1.Order < a2.Order); }
\r
71 inline bool operator==(const CItemProperty &a1, const CItemProperty &a2)
\r
72 { return (a1.Order == a2.Order); }
\r
74 class CItemProperties: public CObjectVector<CItemProperty>
\r
77 int FindItemWithID(PROPID id)
\r
79 for (int i = 0; i < Size(); i++)
\r
80 if ((*this)[i].ID == id)
\r
86 struct CTempFileInfo
\r
91 NWindows::NFile::NFind::CFileInfoW FileInfo;
\r
94 CTempFileInfo(): NeedDelete(false) {}
\r
95 void DeleteDirAndFile() const
\r
99 NWindows::NFile::NDirectory::DeleteFileAlways(FilePath);
\r
100 NWindows::NFile::NDirectory::MyRemoveDirectory(FolderPath);
\r
103 bool WasChanged(const NWindows::NFile::NFind::CFileInfoW &newFileInfo) const
\r
105 return newFileInfo.Size != FileInfo.Size ||
\r
106 CompareFileTime(&newFileInfo.MTime, &FileInfo.MTime) != 0;
\r
110 struct CFolderLink: public CTempFileInfo
\r
112 NWindows::NDLL::CLibrary Library;
\r
113 CMyComPtr<IFolderFolder> ParentFolder;
\r
118 UString VirtualPath;
\r
119 CFolderLink(): UsePassword(false), IsVirtual(false) {}
\r
121 bool WasChanged(const NWindows::NFile::NFind::CFileInfoW &newFileInfo) const
\r
123 return IsVirtual || CTempFileInfo::WasChanged(newFileInfo);
\r
130 kShiftSelectMessage = WM_USER + 1,
\r
132 kSetFocusToListView,
\r
135 kRefreshHeaderComboBox
\r
138 UString GetFolderPath(IFolderFolder * folder);
\r
142 class CMyListView: public NWindows::NControl::CListView
\r
145 WNDPROC _origWindowProc;
\r
147 LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
\r
151 class CMyComboBox: public NWindows::NControl::CComboBoxEx
\r
154 WNDPROC _origWindowProc;
\r
156 LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
\r
159 class CMyComboBoxEdit: public NWindows::NControl::CEdit
\r
162 WNDPROC _origWindowProc;
\r
164 LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
\r
167 struct CSelectedState
\r
170 UString FocusedName;
\r
171 bool SelectFocused;
\r
172 UStringVector SelectedNames;
\r
173 CSelectedState(): FocusedItem(-1), SelectFocused(false) {}
\r
177 #define MY_NMLISTVIEW_NMITEMACTIVATE NMLISTVIEW
\r
179 #define MY_NMLISTVIEW_NMITEMACTIVATE NMITEMACTIVATE
\r
182 class CPanel: public NWindows::NControl::CWindow2
\r
184 CExtToIconMap _extToIconMap;
\r
189 CAppState *_appState;
\r
191 bool OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result);
\r
192 LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
\r
193 virtual bool OnCreate(CREATESTRUCT *createStruct);
\r
194 virtual bool OnSize(WPARAM wParam, int xSize, int ySize);
\r
195 virtual void OnDestroy();
\r
196 virtual bool OnNotify(UINT controlID, LPNMHDR lParam, LRESULT &result);
\r
198 void AddComboBoxItem(const UString &name, int iconIndex, int indent, bool addToList);
\r
200 bool OnComboBoxCommand(UINT code, LPARAM param, LRESULT &result);
\r
204 LRESULT OnNotifyComboBoxEnter(const UString &s);
\r
205 bool OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result);
\r
207 bool OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result);
\r
212 bool OnNotifyReBar(LPNMHDR lParam, LRESULT &result);
\r
213 bool OnNotifyComboBox(LPNMHDR lParam, LRESULT &result);
\r
214 void OnItemChanged(NMLISTVIEW *item);
\r
215 void OnNotifyActivateItems();
\r
216 bool OnNotifyList(LPNMHDR lParam, LRESULT &result);
\r
217 void OnDrag(LPNMLISTVIEW nmListView);
\r
218 bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result);
\r
219 BOOL OnBeginLabelEdit(LV_DISPINFOW * lpnmh);
\r
220 BOOL OnEndLabelEdit(LV_DISPINFOW * lpnmh);
\r
221 void OnColumnClick(LPNMLISTVIEW info);
\r
222 bool OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result);
\r
226 CPanelCallback *_panelCallback;
\r
228 void SysIconsWereChanged() { _extToIconMap.Clear(); }
\r
230 void DeleteItems(bool toRecycleBin);
\r
231 void DeleteItemsInternal(CRecordVector<UInt32> &indices);
\r
232 void CreateFolder();
\r
237 void ChangeWindowSize(int xSize, int ySize);
\r
239 HRESULT InitColumns();
\r
240 // void InitColumns2(PROPID sortID);
\r
241 void InsertColumn(int index);
\r
243 void SetFocusedSelectedItem(int index, bool select);
\r
244 HRESULT RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
\r
245 const UStringVector &selectedNames);
\r
247 void OnShiftSelectMessage();
\r
248 void OnArrowWithShift();
\r
251 // void OnUpWithShift();
\r
252 // void OnDownWithShift();
\r
254 void UpdateSelection();
\r
255 void SelectSpec(bool selectMode);
\r
256 void SelectByType(bool selectMode);
\r
257 void SelectAll(bool selectMode);
\r
258 void InvertSelection();
\r
261 // UString GetFileType(UInt32 index);
\r
262 LRESULT SetItemText(LVITEMW &item);
\r
264 // CRecordVector<PROPID> m_ColumnsPropIDs;
\r
267 NWindows::NControl::CReBar _headerReBar;
\r
268 NWindows::NControl::CToolBar _headerToolBar;
\r
269 NWindows::NControl::
\r
276 UStringVector ComboBoxPaths;
\r
277 // CMyComboBox _headerComboBox;
\r
278 CMyComboBoxEdit _comboBoxEdit;
\r
279 CMyListView _listView;
\r
280 NWindows::NControl::CStatusBar _statusBar;
\r
281 bool _lastFocusedIsList;
\r
282 // NWindows::NControl::CStatusBar _statusBar2;
\r
286 bool _showRealFileIcons;
\r
287 // bool _virtualMode;
\r
288 // CUIntVector _realIndices;
\r
289 bool _enableItemChangeNotify;
\r
290 bool _mySelectMode;
\r
291 CBoolVector _selectedStatusVector;
\r
293 CSelectedState _selectedState;
\r
297 UInt32 GetRealIndex(const LVITEMW &item) const
\r
301 return _realIndices[item.iItem];
\r
303 return (UInt32)item.lParam;
\r
305 int GetRealItemIndex(int indexInListView) const
\r
309 return indexInListView;
\r
312 if (!_listView.GetItemParam(indexInListView, param))
\r
317 UInt32 _ListViewMode;
\r
321 bool _flatModeForDisk;
\r
322 bool _flatModeForArc;
\r
324 bool _dontShowMode;
\r
327 UString _currentFolderPrefix;
\r
329 CObjectVector<CFolderLink> _parentFolders;
\r
330 NWindows::NDLL::CLibrary _library;
\r
331 CMyComPtr<IFolderFolder> _folder;
\r
332 // CMyComPtr<IFolderGetSystemIconIndex> _folderGetSystemIconIndex;
\r
334 UStringVector _fastFolders;
\r
336 void GetSelectedNames(UStringVector &selectedNames);
\r
337 void SaveSelectedState(CSelectedState &s);
\r
338 HRESULT RefreshListCtrl(const CSelectedState &s);
\r
339 HRESULT RefreshListCtrlSaveFocused();
\r
341 UString GetItemName(int itemIndex) const;
\r
342 UString GetItemPrefix(int itemIndex) const;
\r
343 UString GetItemRelPath(int itemIndex) const;
\r
344 UString GetItemFullPath(int itemIndex) const;
\r
345 bool IsItemFolder(int itemIndex) const;
\r
346 UInt64 GetItemSize(int itemIndex) const;
\r
348 ////////////////////////
\r
349 // PanelFolderChange.cpp
\r
351 void SetToRootFolder();
\r
352 HRESULT BindToPath(const UString &fullPath, const UString &arcFormat, bool &archiveIsOpened, bool &encrypted); // can be prefix
\r
353 HRESULT BindToPathAndRefresh(const UString &path);
\r
354 void OpenDrivesFolder();
\r
356 void SetBookmark(int index);
\r
357 void OpenBookmark(int index);
\r
359 void LoadFullPath();
\r
360 void LoadFullPathAndShow();
\r
361 void FoldersHistory();
\r
362 void OpenParentFolder();
\r
363 void CloseOpenFolders();
\r
364 void OpenRootFolder();
\r
367 HRESULT Create(HWND mainWindow, HWND parentWindow,
\r
369 const UString ¤tFolderPrefix,
\r
370 const UString &arcFormat,
\r
371 CPanelCallback *panelCallback,
\r
372 CAppState *appState, bool &archiveIsOpened, bool &encrypted);
\r
373 void SetFocusToList();
\r
374 void SetFocusToLastRememberedItem();
\r
377 void ReadListViewInfo();
\r
378 void SaveListViewInfo();
\r
381 // _virtualMode(flase),
\r
384 _showRealFileIcons(false),
\r
385 _needSaveInfo(false),
\r
386 _startGroupSelect(0),
\r
387 _selectionIsDefined(false),
\r
390 _flatModeForDisk(false),
\r
391 _flatModeForArc(false),
\r
393 _mySelectMode(false),
\r
394 _enableItemChangeNotify(true),
\r
395 _dontShowMode(false)
\r
398 void SetExtendedStyle()
\r
400 if (_listView != 0)
\r
401 _listView.SetExtendedListViewStyle(_exStyle);
\r
405 bool _needSaveInfo;
\r
406 UString _typeIDString;
\r
407 CListViewInfo _listViewInfo;
\r
408 CItemProperties _properties;
\r
409 CItemProperties _visibleProperties;
\r
417 void OnLeftClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate);
\r
418 bool OnRightClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate, LRESULT &result);
\r
419 void ShowColumnsContextMenu(int x, int y);
\r
423 bool OnContextMenu(HANDLE windowHandle, int xPos, int yPos);
\r
425 CMyComPtr<IContextMenu> _sevenZipContextMenu;
\r
426 CMyComPtr<IContextMenu> _systemContextMenu;
\r
427 HRESULT CreateShellContextMenu(
\r
428 const CRecordVector<UInt32> &operatedIndices,
\r
429 CMyComPtr<IContextMenu> &systemContextMenu);
\r
430 void CreateSystemMenu(HMENU menu,
\r
431 const CRecordVector<UInt32> &operatedIndices,
\r
432 CMyComPtr<IContextMenu> &systemContextMenu);
\r
433 void CreateSevenZipMenu(HMENU menu,
\r
434 const CRecordVector<UInt32> &operatedIndices,
\r
435 CMyComPtr<IContextMenu> &sevenZipContextMenu);
\r
436 void CreateFileMenu(HMENU menu,
\r
437 CMyComPtr<IContextMenu> &sevenZipContextMenu,
\r
438 CMyComPtr<IContextMenu> &systemContextMenu,
\r
440 void CreateFileMenu(HMENU menu);
\r
441 bool InvokePluginCommand(int id);
\r
442 bool InvokePluginCommand(int id, IContextMenu *sevenZipContextMenu,
\r
443 IContextMenu *systemContextMenu);
\r
445 void InvokeSystemCommand(const char *command);
\r
451 int _startGroupSelect;
\r
453 bool _selectionIsDefined;
\r
455 int _prevFocusedItem;
\r
458 // void SortItems(int index);
\r
459 void SortItemsWithPropID(PROPID propID);
\r
461 void GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const;
\r
462 void GetOperatedItemIndices(CRecordVector<UInt32> &indices) const;
\r
463 void GetAllItemIndices(CRecordVector<UInt32> &indices) const;
\r
464 void GetOperatedIndicesSmart(CRecordVector<UInt32> &indices) const;
\r
465 // void GetOperatedListViewIndices(CRecordVector<UInt32> &indices) const;
\r
466 void KillSelection();
\r
468 UString GetFolderTypeID() const;
\r
469 bool IsFolderTypeEqTo(const wchar_t *s) const;
\r
470 bool IsRootFolder() const;
\r
471 bool IsFSFolder() const;
\r
472 bool IsFSDrivesFolder() const;
\r
473 bool IsArcFolder() const;
\r
474 bool IsFsOrDrivesFolder() const { return IsFSFolder() || IsFSDrivesFolder(); }
\r
475 bool IsDeviceDrivesPrefix() const { return _currentFolderPrefix == L"\\\\.\\"; }
\r
476 bool IsFsOrPureDrivesFolder() const { return IsFSFolder() || (IsFSDrivesFolder() && !IsDeviceDrivesPrefix()); }
\r
478 UString GetFsPath() const;
\r
479 UString GetDriveOrNetworkPrefix() const;
\r
481 bool DoesItSupportOperations() const;
\r
483 bool _processTimer;
\r
484 bool _processNotify;
\r
486 class CDisableTimerProcessing
\r
488 bool _processTimerMem;
\r
489 bool _processNotifyMem;
\r
494 CDisableTimerProcessing(CPanel &panel): _panel(panel)
\r
500 _processTimerMem = _panel._processTimer;
\r
501 _processNotifyMem = _panel._processNotify;
\r
502 _panel._processTimer = false;
\r
503 _panel._processNotify = false;
\r
507 _panel._processTimer = _processTimerMem;
\r
508 _panel._processNotify = _processNotifyMem;
\r
510 ~CDisableTimerProcessing()
\r
514 CDisableTimerProcessing& operator=(const CDisableTimerProcessing &) {; }
\r
517 // bool _passwordIsDefined;
\r
518 // UString _password;
\r
520 HRESULT RefreshListCtrl();
\r
522 void MessageBoxInfo(LPCWSTR message, LPCWSTR caption);
\r
523 void MessageBox(LPCWSTR message);
\r
524 void MessageBox(LPCWSTR message, LPCWSTR caption);
\r
525 void MessageBoxMyError(LPCWSTR message);
\r
526 void MessageBoxError(HRESULT errorCode, LPCWSTR caption);
\r
527 void MessageBoxError(HRESULT errorCode);
\r
528 void MessageBoxLastError(LPCWSTR caption);
\r
529 void MessageBoxLastError();
\r
531 void MessageBoxErrorForUpdate(HRESULT errorCode, UINT resourceID, UInt32 langID);
\r
533 void MessageBoxErrorLang(UINT resourceID, UInt32 langID);
\r
535 void OpenFocusedItemAsInternal();
\r
536 void OpenSelectedItems(bool internal);
\r
538 void OpenFolderExternal(int index);
\r
540 void OpenFolder(int index);
\r
541 HRESULT OpenParentArchiveFolder();
\r
542 HRESULT OpenItemAsArchive(IInStream *inStream,
\r
543 const CTempFileInfo &tempFileInfo,
\r
544 const UString &virtualFilePath,
\r
545 const UString &arcFormat,
\r
547 HRESULT OpenItemAsArchive(const UString &name, const UString &arcFormat, bool &encrypted);
\r
548 HRESULT OpenItemAsArchive(int index);
\r
549 void OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
\r
551 HRESULT OnOpenItemChanged(const UString &folderPath, const UString &itemName, bool usePassword, const UString &password);
\r
552 LRESULT OnOpenItemChanged(LPARAM lParam);
\r
554 void OpenItem(int index, bool tryInternal, bool tryExternal);
\r
556 void EditItem(int index);
\r
559 void ChangeComment();
\r
561 void SetListViewMode(UInt32 index);
\r
562 UInt32 GetListViewMode() const { return _ListViewMode; }
\r
563 PROPID GetSortID() const { return _sortID; }
\r
565 void ChangeFlatMode();
\r
566 bool GetFlatMode() const { return _flatMode; }
\r
568 void RefreshStatusBar();
\r
569 void OnRefreshStatusBar();
\r
571 void AddToArchive();
\r
573 void GetFilePaths(const CRecordVector<UInt32> &indices, UStringVector &paths);
\r
574 void ExtractArchives();
\r
575 void TestArchives();
\r
577 HRESULT CopyTo(const CRecordVector<UInt32> &indices, const UString &folder,
\r
578 bool moveMode, bool showErrorMessages, UStringVector *messages,
\r
579 bool &usePassword, UString &password);
\r
581 HRESULT CopyTo(const CRecordVector<UInt32> &indices, const UString &folder,
\r
582 bool moveMode, bool showErrorMessages, UStringVector *messages)
\r
584 bool usePassword = false;
\r
586 if (_parentFolders.Size() > 0)
\r
588 const CFolderLink &fl = _parentFolders.Back();
\r
589 usePassword = fl.UsePassword;
\r
590 password = fl.Password;
\r
592 return CopyTo(indices, folder, moveMode, showErrorMessages, messages, usePassword, password);
\r
595 HRESULT CopyFrom(const UString &folderPrefix, const UStringVector &filePaths,
\r
596 bool showErrorMessages, UStringVector *messages);
\r
598 void CopyFromNoAsk(const UStringVector &filePaths);
\r
599 void CopyFromAsk(const UStringVector &filePaths);
\r
601 // empty folderPath means create new Archive to path of first fileName.
\r
602 void DropObject(IDataObject * dataObject, const UString &folderPath);
\r
604 // empty folderPath means create new Archive to path of first fileName.
\r
605 void CompressDropFiles(const UStringVector &fileNames, const UString &folderPath);
\r
607 void RefreshTitle(bool always = false) { _panelCallback->RefreshTitle(always); }
\r
608 void RefreshTitleAlways() { RefreshTitle(true); }
\r
610 UString GetItemsInfoString(const CRecordVector<UInt32> &indices);
\r
617 CMyBuffer(): _data(0) {}
\r
618 operator void *() { return _data; }
\r
619 bool Allocate(size_t size)
\r
623 _data = ::MidAlloc(size);
\r
626 ~CMyBuffer() { ::MidFree(_data); }
\r