📄 panel.h
字号:
// Panel.h
#ifndef __PANEL_H
#define __PANEL_H
#include "Common/MyCom.h"
#include "Windows/DLL.h"
#include "Windows/FileFind.h"
#include "Windows/FileDir.h"
#include "Windows/Synchronization.h"
#include "Windows/Handle.h"
#include "Windows/Control/ToolBar.h"
#include "Windows/Control/ReBar.h"
#include "Windows/Control/ListView.h"
#include "Windows/Control/Static.h"
#include "Windows/Control/Edit.h"
#include "Windows/Control/ComboBox.h"
#include "Windows/Control/Window2.h"
#include "Windows/Control/StatusBar.h"
#include "SysIconUtils.h"
#include "IFolder.h"
#include "ViewSettings.h"
#include "AppState.h"
#include "MyCom2.h"
const int kParentFolderID = 100;
const int kPluginMenuStartID = 1000;
const int kToolbarStartID = 2000;
const int kParentIndex = -1;
struct CPanelCallback
{
virtual void OnTab() = 0;
virtual void SetFocusToPath(int index) = 0;
virtual void OnCopy(bool move, bool copyToSame) = 0;
virtual void OnSetSameFolder() = 0;
virtual void OnSetSubFolder() = 0;
virtual void PanelWasFocused() = 0;
virtual void DragBegin() = 0;
virtual void DragEnd() = 0;
virtual void RefreshTitle(bool always) = 0;
};
void PanelCopyItems();
struct CItemProperty
{
UString Name;
PROPID ID;
VARTYPE Type;
int Order;
bool IsVisible;
UInt32 Width;
};
inline bool operator<(const CItemProperty &a1, const CItemProperty &a2)
{ return (a1.Order < a2.Order); }
inline bool operator==(const CItemProperty &a1, const CItemProperty &a2)
{ return (a1.Order == a2.Order); }
class CItemProperties: public CObjectVector<CItemProperty>
{
public:
int FindItemWithID(PROPID id)
{
for (int i = 0; i < Size(); i++)
if ((*this)[i].ID == id)
return i;
return -1;
}
};
struct CTempFileInfo
{
UString ItemName;
UString FolderPath;
UString FilePath;
NWindows::NFile::NFind::CFileInfoW FileInfo;
void DeleteDirAndFile()
{
NWindows::NFile::NDirectory::DeleteFileAlways(FilePath);
NWindows::NFile::NDirectory::MyRemoveDirectory(FolderPath);
}
};
struct CFolderLink: public CTempFileInfo
{
NWindows::NDLL::CLibrary Library;
CMyComPtr<IFolderFolder> ParentFolder;
bool UsePassword;
UString Password;
UString VirtualPath;
CFolderLink(): UsePassword(false) {}
};
enum MyMessages
{
kShiftSelectMessage = WM_USER + 1,
kReLoadMessage,
kSetFocusToListView,
kOpenItemChanged,
kRefreshStatusBar
};
UString GetFolderPath(IFolderFolder * folder);
class CPanel;
class CMyListView: public NWindows::NControl::CListView
{
public:
WNDPROC _origWindowProc;
CPanel *_panel;
LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
};
/*
class CMyComboBox: public NWindows::NControl::CComboBoxEx
{
public:
WNDPROC _origWindowProc;
CPanel *_panel;
LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
};
*/
class CMyComboBoxEdit: public NWindows::NControl::CEdit
{
public:
WNDPROC _origWindowProc;
CPanel *_panel;
LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
};
struct CSelectedState
{
int FocusedItem;
UString FocusedName;
bool SelectFocused;
UStringVector SelectedNames;
CSelectedState(): FocusedItem(-1), SelectFocused(false) {}
};
class CPanel: public NWindows::NControl::CWindow2
{
CExtToIconMap _extToIconMap;
UINT _baseID;
int _comboBoxID;
UINT _statusBarID;
CAppState *_appState;
bool OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result);
LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
virtual bool OnCreate(CREATESTRUCT *createStruct);
virtual bool OnSize(WPARAM wParam, int xSize, int ySize);
virtual void OnDestroy();
virtual bool OnNotify(UINT controlID, LPNMHDR lParam, LRESULT &result);
void AddComboBoxItem(const UString &name, int iconIndex, int indent, bool addToList);
bool OnComboBoxCommand(UINT code, LPARAM param, LRESULT &result);
LRESULT OnNotifyComboBoxEnter(const UString &s);
bool OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result);
#ifndef _UNICODE
bool OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result);
#endif
bool OnNotifyReBar(LPNMHDR lParam, LRESULT &result);
bool OnNotifyComboBox(LPNMHDR lParam, LRESULT &result);
void OnItemChanged(NMLISTVIEW *item);
bool OnNotifyList(LPNMHDR lParam, LRESULT &result);
void OnDrag(LPNMLISTVIEW nmListView);
bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result);
BOOL OnBeginLabelEdit(LV_DISPINFOW * lpnmh);
BOOL OnEndLabelEdit(LV_DISPINFOW * lpnmh);
void OnColumnClick(LPNMLISTVIEW info);
bool OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result);
public:
HWND _mainWindow;
CPanelCallback *_panelCallback;
void DeleteItems(bool toRecycleBin);
void DeleteItemsInternal(CRecordVector<UInt32> &indices);
void CreateFolder();
void CreateFile();
private:
void ChangeWindowSize(int xSize, int ySize);
void InitColumns();
// void InitColumns2(PROPID sortID);
void InsertColumn(int index);
void SetFocusedSelectedItem(int index, bool select);
void RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
const UStringVector &selectedNames);
void OnShiftSelectMessage();
void OnArrowWithShift();
void OnInsert();
// void OnUpWithShift();
// void OnDownWithShift();
public:
void UpdateSelection();
void SelectSpec(bool selectMode);
void SelectByType(bool selectMode);
void SelectAll(bool selectMode);
void InvertSelection();
private:
// UString GetFileType(UInt32 index);
LRESULT SetItemText(LVITEMW &item);
// CRecordVector<PROPID> m_ColumnsPropIDs;
public:
NWindows::NControl::CReBar _headerReBar;
NWindows::NControl::CToolBar _headerToolBar;
NWindows::NControl::CComboBoxEx _headerComboBox;
UStringVector ComboBoxPaths;
// CMyComboBox _headerComboBox;
CMyComboBoxEdit _comboBoxEdit;
CMyListView _listView;
NWindows::NControl::CStatusBar _statusBar;
bool _lastFocusedIsList;
// NWindows::NControl::CStatusBar _statusBar2;
DWORD _exStyle;
bool _showDots;
bool _showRealFileIcons;
// bool _virtualMode;
// CUIntVector _realIndices;
bool _enableItemChangeNotify;
bool _mySelectMode;
CBoolVector _selectedStatusVector;
CSelectedState _selectedState;
HWND GetParent();
UInt32 GetRealIndex(const LVITEMW &item) const
{
/*
if (_virtualMode)
return _realIndices[item.iItem];
*/
return (UInt32)item.lParam;
}
int GetRealItemIndex(int indexInListView) const
{
/*
if (_virtualMode)
return indexInListView;
*/
LPARAM param;
if (!_listView.GetItemParam(indexInListView, param))
throw 1;
return (int)param;
}
UInt32 _ListViewMode;
int _xSize;
bool _flatMode;
bool _flatModeForDisk;
bool _flatModeForArc;
bool _dontShowMode;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -