[ENHANCEMENT] (Author: Pavel Nedev) Resize column Name correctly while hiding column Ext.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1284 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2014-11-02 15:08:18 +00:00
parent 2c9ad7ac27
commit fb4a2dd27d
4 changed files with 50 additions and 24 deletions

View File

@ -3017,27 +3017,27 @@ bool Notepad_plus::removeBufferFromView(BufferID id, int whichOne)
}
else
{
BufferID bufferToActivate = NULL;
if (NppParameters::getInstance()->getNppGUI()._styleMRU) // If Most-Recently-Used mode:
{ // Activate Most-Recently-Used doc:
TaskListInfo taskListInfo;
::SendMessage(_pPublicInterface->getHSelf(), WM_GETTASKLISTINFO, (WPARAM)&taskListInfo, 0);
bufferToActivate = static_cast<BufferID>(taskListInfo._tlfsLst[1]._bufID);
}
else
{ // Activate next doc, otherwise previous if not possible:
int toActivate = 0;
if (active == tabToClose->nbItem() - 1) // If last doc:
{
toActivate = active - 1; // Activate previous doc.
}
else
{
toActivate = active + 1; // Activate next doc.
}
bufferToActivate = tabToClose->getBufferByIndex(toActivate);
}
tabToClose->deletItemAt((size_t)index); //delete first
BufferID bufferToActivate = NULL;
if (NppParameters::getInstance()->getNppGUI()._styleMRU) // If Most-Recently-Used mode:
{ // Activate Most-Recently-Used doc:
TaskListInfo taskListInfo;
::SendMessage(_pPublicInterface->getHSelf(), WM_GETTASKLISTINFO, (WPARAM)&taskListInfo, 0);
bufferToActivate = static_cast<BufferID>(taskListInfo._tlfsLst[1]._bufID);
}
else
{ // Activate next doc, otherwise previous if not possible:
int toActivate = 0;
if (active == tabToClose->nbItem() - 1) // If last doc:
{
toActivate = active - 1; // Activate previous doc.
}
else
{
toActivate = active + 1; // Activate next doc.
}
bufferToActivate = tabToClose->getBufferByIndex(toActivate);
}
tabToClose->deletItemAt((size_t)index); //delete first
activateBuffer(bufferToActivate, whichOne); //then activate. The prevent jumpy tab behaviour
}
}

View File

@ -185,6 +185,7 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA
int width = LOWORD(lParam);
int height = HIWORD(lParam);
::MoveWindow(_fileListView.getHSelf(), 0, 0, width, height, TRUE);
_fileListView.resizeColumns(width);
break;
}

View File

@ -103,10 +103,19 @@ void VerticalFileSwitcherListView::initList()
NppParameters *nppParams = NppParameters::getInstance();
NativeLangSpeaker *pNativeSpeaker = nppParams->getNativeLangSpeaker();
generic_string nameStr = pNativeSpeaker->getAttrNameStr(TEXT("Name"), FS_ROOTNODE, FS_CLMNNAME);
insertColumn(nameStr.c_str(), 150, 0);
bool isExtColumn = !nppParams->getNppGUI()._fileSwitcherWithoutExtColumn;
RECT rc;
::GetClientRect(_hParent, &rc);
int totalWidth = rc.right - rc.left;
generic_string nameStr = pNativeSpeaker->getAttrNameStr(TEXT("Name"), FS_ROOTNODE, FS_CLMNNAME);
//insertColumn(nameStr.c_str(), 150, 0);
insertColumn(nameStr.c_str(), (isExtColumn ? totalWidth - 50 : totalWidth), 0);
//bool isExtColumn = !nppParams->getNppGUI()._fileSwitcherWithoutExtColumn;
if (isExtColumn)
{
generic_string extStr = pNativeSpeaker->getAttrNameStr(TEXT("Ext."), FS_ROOTNODE, FS_CLMNEXT);
@ -334,6 +343,21 @@ void VerticalFileSwitcherListView::insertColumn(const TCHAR *name, int width, in
ListView_InsertColumn(_hSelf, index, &lvColumn);
}
void VerticalFileSwitcherListView::resizeColumns(int totalWidth)
{
NppParameters *nppParams = NppParameters::getInstance();
bool isExtColumn = !nppParams->getNppGUI()._fileSwitcherWithoutExtColumn;
if (isExtColumn)
{
ListView_SetColumnWidth(_hSelf, 0, totalWidth - 50);
ListView_SetColumnWidth(_hSelf, 1, 50);
}
else
{
ListView_SetColumnWidth(_hSelf, 0, totalWidth);
}
}
std::vector<SwitcherFileInfo> VerticalFileSwitcherListView::getSelectedFiles(bool reverse) const
{
std::vector<SwitcherFileInfo> files;

View File

@ -61,6 +61,7 @@ public:
generic_string getFullFilePath(size_t i) const;
void insertColumn(const TCHAR *name, int width, int index);
void resizeColumns(int totalWidth);
void deleteColumn(size_t i) {
ListView_DeleteColumn(_hSelf, i);
};