This commit is contained in:
Igor Pavlov
2016-05-10 00:00:00 +00:00
committed by Kornel Lesiński
parent c20d013055
commit 66ac98bb02
92 changed files with 2462 additions and 925 deletions

View File

@@ -46,7 +46,7 @@ void CPanelCallbackImp::OnTab()
_app->RefreshTitle();
}
void CPanelCallbackImp::SetFocusToPath(int index)
void CPanelCallbackImp::SetFocusToPath(unsigned index)
{
int newPanelIndex = index;
if (g_App.NumPanels == 1)
@@ -60,10 +60,10 @@ void CPanelCallbackImp::SetFocusToPath(int index)
void CPanelCallbackImp::OnCopy(bool move, bool copyToSame) { _app->OnCopy(move, copyToSame, _index); }
void CPanelCallbackImp::OnSetSameFolder() { _app->OnSetSameFolder(_index); }
void CPanelCallbackImp::OnSetSubFolder() { _app->OnSetSubFolder(_index); }
void CPanelCallbackImp::PanelWasFocused() { _app->SetFocusedPanel(_index); _app->RefreshTitle(_index); }
void CPanelCallbackImp::PanelWasFocused() { _app->SetFocusedPanel(_index); _app->RefreshTitlePanel(_index); }
void CPanelCallbackImp::DragBegin() { _app->DragBegin(_index); }
void CPanelCallbackImp::DragEnd() { _app->DragEnd(); }
void CPanelCallbackImp::RefreshTitle(bool always) { _app->RefreshTitle(_index, always); }
void CPanelCallbackImp::RefreshTitle(bool always) { _app->RefreshTitlePanel(_index, always); }
void CApp::ReloadLang()
{
@@ -115,11 +115,14 @@ void CApp::SetListSettings()
#endif
HRESULT CApp::CreateOnePanel(int panelIndex, const UString &mainPath, const UString &arcFormat,
bool &archiveIsOpened, bool &encrypted)
bool needOpenArc,
bool &archiveIsOpened, bool &encrypted)
{
if (PanelsCreated[panelIndex])
if (Panels[panelIndex].PanelCreated)
return S_OK;
m_PanelCallbackImp[panelIndex].Init(this, panelIndex);
UString path;
if (mainPath.IsEmpty())
{
@@ -128,13 +131,16 @@ HRESULT CApp::CreateOnePanel(int panelIndex, const UString &mainPath, const UStr
}
else
path = mainPath;
int id = 1000 + 100 * panelIndex;
RINOK(Panels[panelIndex].Create(_window, _window,
id, path, arcFormat, &m_PanelCallbackImp[panelIndex], &AppState, archiveIsOpened, encrypted));
PanelsCreated[panelIndex] = true;
return S_OK;
return Panels[panelIndex].Create(_window, _window,
id, path, arcFormat, &m_PanelCallbackImp[panelIndex], &AppState,
needOpenArc,
archiveIsOpened, encrypted);
}
static void CreateToolbar(HWND parent,
NControl::CImageList &imageList,
NControl::CToolBar &toolBar,
@@ -165,6 +171,7 @@ static void CreateToolbar(HWND parent,
toolBar.SetImageList(0, imageList);
}
struct CButtonInfo
{
int CommandID;
@@ -273,9 +280,11 @@ void CApp::SaveToolbarChanges()
MoveSubWindows();
}
void MyLoadMenu();
HRESULT CApp::Create(HWND hwnd, const UString &mainPath, const UString &arcFormat, int xSizes[2], bool &archiveIsOpened, bool &encrypted)
HRESULT CApp::Create(HWND hwnd, const UString &mainPath, const UString &arcFormat, int xSizes[2], bool needOpenArc, bool &archiveIsOpened, bool &encrypted)
{
_window.Attach(hwnd);
@@ -292,9 +301,9 @@ HRESULT CApp::Create(HWND hwnd, const UString &mainPath, const UString &arcForma
ReadToolbar();
ReloadToolbars();
int i;
unsigned i;
for (i = 0; i < kNumPanelsMax; i++)
PanelsCreated[i] = false;
Panels[i].PanelCreated = false;
AppState.Read();
@@ -316,33 +325,52 @@ HRESULT CApp::Create(HWND hwnd, const UString &mainPath, const UString &arcForma
}
for (i = 0; i < kNumPanelsMax; i++)
if (NumPanels > 1 || i == LastFocusedPanel)
{
unsigned panelIndex = i;
if (needOpenArc && LastFocusedPanel == 1)
panelIndex = 1 - i;
bool isMainPanel = (panelIndex == LastFocusedPanel);
if (NumPanels > 1 || isMainPanel)
{
if (NumPanels == 1)
Panels[i]._xSize = xSizes[0] + xSizes[1];
Panels[panelIndex]._xSize = xSizes[0] + xSizes[1];
bool archiveIsOpened2 = false;
bool encrypted2 = false;
bool mainPanel = (i == LastFocusedPanel);
RINOK(CreateOnePanel(i, mainPanel ? mainPath : L"", arcFormat, archiveIsOpened2, encrypted2));
if (mainPanel)
UString path;
if (isMainPanel)
path = mainPath;
RINOK(CreateOnePanel(panelIndex, path, arcFormat,
isMainPanel && needOpenArc,
archiveIsOpened2, encrypted2));
if (isMainPanel)
{
archiveIsOpened = archiveIsOpened2;
encrypted = encrypted2;
if (needOpenArc && !archiveIsOpened2)
return S_OK;
}
}
}
SetFocusedPanel(LastFocusedPanel);
Panels[LastFocusedPanel].SetFocusToList();
return S_OK;
}
HRESULT CApp::SwitchOnOffOnePanel()
{
if (NumPanels == 1)
{
NumPanels++;
bool archiveIsOpened, encrypted;
RINOK(CreateOnePanel(1 - LastFocusedPanel, UString(), UString(), archiveIsOpened, encrypted));
RINOK(CreateOnePanel(1 - LastFocusedPanel, UString(), UString(),
false, // needOpenArc
archiveIsOpened, encrypted));
Panels[1 - LastFocusedPanel].Enable(true);
Panels[1 - LastFocusedPanel].Show(SW_SHOWNORMAL);
}
@@ -530,7 +558,7 @@ static bool IsFsPath(const FString &path)
void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
{
int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
unsigned destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
CPanel &srcPanel = Panels[srcPanelIndex];
CPanel &destPanel = Panels[destPanelIndex];
@@ -854,7 +882,7 @@ int CApp::GetFocusedPanelIndex() const
{
if (hwnd == 0)
return 0;
for (int i = 0; i < kNumPanelsMax; i++)
for (unsigned i = 0; i < kNumPanelsMax; i++)
{
if (PanelsCreated[i] &&
((HWND)Panels[i] == hwnd || Panels[i]._listView == hwnd))
@@ -906,7 +934,7 @@ void CApp::RefreshTitle(bool always)
NWindows::MySetWindowText(_window, path);
}
void CApp::RefreshTitle(int panelIndex, bool always)
void CApp::RefreshTitlePanel(unsigned panelIndex, bool always)
{
if (panelIndex != GetFocusedPanelIndex())
return;

View File

@@ -14,7 +14,7 @@ class CApp;
extern CApp g_App;
extern HWND g_HWND;
const int kNumPanelsMax = 2;
const unsigned kNumPanelsMax = 2;
extern bool g_IsSmallScreen;
@@ -32,15 +32,15 @@ enum
class CPanelCallbackImp: public CPanelCallback
{
CApp *_app;
int _index;
unsigned _index;
public:
void Init(CApp *app, int index)
void Init(CApp *app, unsigned index)
{
_app = app;
_index = index;
}
virtual void OnTab();
virtual void SetFocusToPath(int index);
virtual void SetFocusToPath(unsigned index);
virtual void OnCopy(bool move, bool copyToSame);
virtual void OnSetSameFolder();
virtual void OnSetSubFolder();
@@ -111,8 +111,8 @@ public:
NWindows::CWindow _window;
bool ShowSystemMenu;
// bool ShowDeletedFiles;
int NumPanels;
int LastFocusedPanel;
unsigned NumPanels;
unsigned LastFocusedPanel;
bool ShowStandardToolbar;
bool ShowArchiveToolbar;
@@ -122,7 +122,6 @@ public:
CAppState AppState;
CPanelCallbackImp m_PanelCallbackImp[kNumPanelsMax];
CPanel Panels[kNumPanelsMax];
bool PanelsCreated[kNumPanelsMax];
NWindows::NControl::CImageList _buttonsImageList;
@@ -151,13 +150,13 @@ public:
_dropTargetSpec->App = (this);
}
void SetFocusedPanel(int index)
void SetFocusedPanel(unsigned index)
{
LastFocusedPanel = index;
_dropTargetSpec->TargetPanelIndex = LastFocusedPanel;
}
void DragBegin(int panelIndex)
void DragBegin(unsigned panelIndex)
{
_dropTargetSpec->TargetPanelIndex = (NumPanels > 1) ? 1 - panelIndex : panelIndex;
_dropTargetSpec->SrcPanelIndex = panelIndex;
@@ -174,16 +173,16 @@ public:
void OnSetSameFolder(int srcPanelIndex);
void OnSetSubFolder(int srcPanelIndex);
HRESULT CreateOnePanel(int panelIndex, const UString &mainPath, const UString &arcFormat, bool &archiveIsOpened, bool &encrypted);
HRESULT Create(HWND hwnd, const UString &mainPath, const UString &arcFormat, int xSizes[2], bool &archiveIsOpened, bool &encrypted);
HRESULT CreateOnePanel(int panelIndex, const UString &mainPath, const UString &arcFormat, bool needOpenArc, bool &archiveIsOpened, bool &encrypted);
HRESULT Create(HWND hwnd, const UString &mainPath, const UString &arcFormat, int xSizes[2], bool needOpenArc, bool &archiveIsOpened, bool &encrypted);
void Read();
void Save();
void Release();
// void SetFocus(int panelIndex) { Panels[panelIndex].SetFocusToList(); }
void SetFocusToLastItem() { Panels[LastFocusedPanel].SetFocusToLastRememberedItem(); }
int GetFocusedPanelIndex() const { return LastFocusedPanel; }
bool IsPanelVisible(int index) const { return (NumPanels > 1 || index == LastFocusedPanel); }
unsigned GetFocusedPanelIndex() const { return LastFocusedPanel; }
bool IsPanelVisible(unsigned index) const { return (NumPanels > 1 || index == LastFocusedPanel); }
CPanel &GetFocusedPanel() { return Panels[GetFocusedPanelIndex()]; }
// File Menu
@@ -235,9 +234,9 @@ public:
void RefreshView() { GetFocusedPanel().OnReload(); }
void RefreshAllPanels()
{
for (int i = 0; i < NumPanels; i++)
for (unsigned i = 0; i < NumPanels; i++)
{
int index = i;
unsigned index = i;
if (NumPanels == 1)
index = LastFocusedPanel;
Panels[index].OnReload();
@@ -247,9 +246,9 @@ public:
/*
void SysIconsWereChanged()
{
for (int i = 0; i < NumPanels; i++)
for (unsigned i = 0; i < NumPanels; i++)
{
int index = i;
unsigned index = i;
if (NumPanels == 1)
index = LastFocusedPanel;
Panels[index].SysIconsWereChanged();
@@ -280,7 +279,7 @@ public:
}
void SetPanels_AutoRefresh_Mode()
{
for (int i = 0; i < kNumPanelsMax; i++)
for (unsigned i = 0; i < kNumPanelsMax; i++)
Panels[i].Set_AutoRefresh_Mode(AutoRefresh_Mode);
}
@@ -347,7 +346,7 @@ public:
UString PrevTitle;
void RefreshTitle(bool always = false);
void RefreshTitleAlways() { RefreshTitle(true); }
void RefreshTitle(int panelIndex, bool always = false);
void RefreshTitlePanel(unsigned panelIndex, bool always = false);
void MoveSubWindows();
};

View File

@@ -157,6 +157,7 @@ static bool g_CanChangeSplitter = false;
static UInt32 g_SplitterPos = 0;
static CSplitterPos g_Splitter;
static bool g_PanelsInfoDefined = false;
static bool g_WindowWasCreated = false;
static int g_StartCaptureMousePos;
static int g_StartCaptureSplitterPos;
@@ -238,8 +239,9 @@ static BOOL InitInstance(int nCmdShow)
if (windowPosIsRead)
{
// x = rect.left;
// y = rect.top;
x = info.rect.left;
y = info.rect.top;
xSize = RECT_SIZE_X(info.rect);
ySize = RECT_SIZE_Y(info.rect);
}
@@ -258,6 +260,7 @@ static BOOL InitInstance(int nCmdShow)
info.numPanels = kNumDefaultPanels;
info.currentPanel = 0;
}
g_App.NumPanels = info.numPanels;
g_App.LastFocusedPanel = info.currentPanel;
@@ -832,7 +835,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
needOpenFile = true;
}
HRESULT res = g_App.Create(hWnd, fullPath, g_ArcFormat, xSizes, archiveIsOpened, encrypted);
HRESULT res = g_App.Create(hWnd, fullPath, g_ArcFormat, xSizes,
needOpenFile,
archiveIsOpened, encrypted);
if (res == E_ABORT)
return -1;
@@ -852,6 +857,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
ErrorMessage(message);
return -1;
}
g_WindowWasCreated = true;
// g_SplitterPos = 0;
@@ -867,9 +874,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
RevokeDragDrop(hWnd);
g_App._dropTarget.Release();
g_App.Save();
if (g_WindowWasCreated)
g_App.Save();
g_App.Release();
SaveWindowInfo(hWnd);
if (g_WindowWasCreated)
SaveWindowInfo(hWnd);
g_ExitEventLauncher.Exit(true);
PostQuitMessage(0);

View File

@@ -333,7 +333,7 @@ void CApp::Link()
const UString srcPath = fsPrefix + srcPanel.GetItemPrefix(index);
UString path = srcPath;
{
int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
unsigned destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
CPanel &destPanel = Panels[destPanelIndex];
if (NumPanels > 1)
if (destPanel.IsFSFolder())

View File

@@ -74,6 +74,7 @@ HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
const UString &currentFolderPrefix,
const UString &arcFormat,
CPanelCallback *panelCallback, CAppState *appState,
bool needOpenArc,
bool &archiveIsOpened, bool &encrypted)
{
_mainWindow = mainWindow;
@@ -100,10 +101,15 @@ HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
RINOK(BindToPath(cfp, arcFormat, archiveIsOpened, encrypted));
if (needOpenArc && !archiveIsOpened)
return S_OK;
if (!CreateEx(0, kClassName, 0, WS_CHILD | WS_VISIBLE,
0, 0, _xSize, 260,
parentWindow, (HMENU)(UINT_PTR)id, g_hInstance))
return E_FAIL;
PanelCreated = true;
return S_OK;
}
@@ -525,7 +531,7 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
_statusBar.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID);
// _statusBar2.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID + 1);
int sizes[] = {160, 250, 350, -1};
const int sizes[] = {220, 320, 420, -1};
_statusBar.SetParts(4, sizes);
// _statusBar2.SetParts(5, sizes);
@@ -834,18 +840,20 @@ void CPanel::AddToArchive()
// KillSelection();
}
static UString GetSubFolderNameForExtract(const UString &arcPath)
// function from ContextMenu.cpp
UString GetSubFolderNameForExtract(const UString &arcPath);
static UString GetSubFolderNameForExtract2(const UString &arcPath)
{
UString s = arcPath;
int slashPos = s.ReverseFind_PathSepar();
int dotPos = s.ReverseFind_Dot();
if (dotPos <= slashPos + 1)
s += L'~';
else
int slashPos = arcPath.ReverseFind_PathSepar();
UString s;
UString name = arcPath;
if (slashPos >= 0)
{
s.DeleteFrom(dotPos);
s.TrimRight();
s = arcPath.Left(slashPos + 1);
name = arcPath.Ptr(slashPos + 1);
}
s += GetSubFolderNameForExtract(name);
return s;
}
@@ -885,7 +893,7 @@ void CPanel::ExtractArchives()
UString outFolder = GetFsPath();
if (indices.Size() == 1)
outFolder += GetSubFolderNameForExtract(GetItemRelPath(indices[0]));
outFolder += GetSubFolderNameForExtract2(GetItemRelPath(indices[0]));
else
outFolder += L'*';
outFolder.Add_PathSepar();

View File

@@ -57,7 +57,7 @@ const int kParentIndex = -1;
struct CPanelCallback
{
virtual void OnTab() = 0;
virtual void SetFocusToPath(int index) = 0;
virtual void SetFocusToPath(unsigned index) = 0;
virtual void OnCopy(bool move, bool copyToSame) = 0;
virtual void OnSetSameFolder() = 0;
virtual void OnSetSubFolder() = 0;
@@ -222,6 +222,7 @@ struct CSelectedState
UString FocusedName;
bool SelectFocused;
UStringVector SelectedNames;
CSelectedState(): FocusedItem(-1), SelectFocused(false) {}
};
@@ -377,6 +378,8 @@ public:
bool _thereAreDeletedItems;
bool _markDeletedItems;
bool PanelCreated;
HWND GetParent();
UInt32 GetRealIndex(const LVITEMW &item) const
@@ -460,8 +463,8 @@ public:
HRESULT BindToPathAndRefresh(const UString &path);
void OpenDrivesFolder();
void SetBookmark(int index);
void OpenBookmark(int index);
void SetBookmark(unsigned index);
void OpenBookmark(unsigned index);
void LoadFullPath();
void LoadFullPathAndShow();
@@ -477,7 +480,9 @@ public:
const UString &currentFolderPrefix,
const UString &arcFormat,
CPanelCallback *panelCallback,
CAppState *appState, bool &archiveIsOpened, bool &encrypted);
CAppState *appState,
bool needOpenArc,
bool &archiveIsOpened, bool &encrypted);
void SetFocusToList();
void SetFocusToLastRememberedItem();
@@ -496,6 +501,7 @@ public:
_flatMode(false),
_flatModeForDisk(false),
_flatModeForArc(false),
PanelCreated(false),
// _showNtfsStrems_Mode(false),
// _showNtfsStrems_ModeForDisk(false),

View File

@@ -16,6 +16,7 @@
#include "../Common/ArchiveName.h"
#include "../Common/CompressCall.h"
#include "../Common/ExtractingFilePath.h"
#include "MessagesDialog.h"
@@ -350,7 +351,10 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
if (isFSFolder)
s = GetItemRelPath(index);
else
{
s = GetItemName(index);
s = Get_Correct_FsFile_Name(s);
}
names.Add(fs2us(dirPrefix) + s);
}
if (!CopyNamesToHGlobal(dataObjectSpec->hGlobal, names))
@@ -470,7 +474,7 @@ void CDropTarget::PositionCursor(POINTL ptl)
{
POINT pt2 = pt;
App->_window.ScreenToClient(&pt2);
for (int i = 0; i < kNumPanelsMax; i++)
for (unsigned i = 0; i < kNumPanelsMax; i++)
if (App->IsPanelVisible(i))
if (App->Panels[i].IsEnabled())
if (ChildWindowFromPointEx(App->_window, pt2,
@@ -478,7 +482,7 @@ void CDropTarget::PositionCursor(POINTL ptl)
{
m_Panel = &App->Panels[i];
m_IsAppTarget = false;
if (i == SrcPanelIndex)
if ((int)i == SrcPanelIndex)
{
m_PanelDropIsAllowed = false;
return;

View File

@@ -263,12 +263,12 @@ HRESULT CPanel::BindToPathAndRefresh(const UString &path)
return S_OK;
}
void CPanel::SetBookmark(int index)
void CPanel::SetBookmark(unsigned index)
{
_appState->FastFolders.SetString(index, _currentFolderPrefix);
}
void CPanel::OpenBookmark(int index)
void CPanel::OpenBookmark(unsigned index)
{
BindToPathAndRefresh(_appState->FastFolders.GetString(index));
}

View File

@@ -189,7 +189,7 @@ void CApp::Split()
UString srcPath = srcPanel.GetFsPath() + srcPanel.GetItemPrefix(index);
UString path = srcPath;
int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
unsigned destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
CPanel &destPanel = Panels[destPanelIndex];
if (NumPanels > 1)
if (destPanel.IsFSFolder())
@@ -367,7 +367,7 @@ void CApp::Combine()
UString srcPath = srcPanel.GetFsPath() + srcPanel.GetItemPrefix(index);
UString path = srcPath;
int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
unsigned destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
CPanel &destPanel = Panels[destPanelIndex];
if (NumPanels > 1)
if (destPanel.IsFSFolder())