From fb4a2dd27dedb6aee993a053bc2b9c1fdea878d1 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sun, 2 Nov 2014 15:08:18 +0000 Subject: [PATCH] [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 --- PowerEditor/src/Notepad_plus.cpp | 42 +++++++++---------- .../VerticalFileSwitcher.cpp | 1 + .../VerticalFileSwitcherListView.cpp | 30 +++++++++++-- .../VerticalFileSwitcherListView.h | 1 + 4 files changed, 50 insertions(+), 24 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index edb16e2ce..13e97d094 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -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(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(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 } } diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp index 1123bcc23..a5532f58b 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp @@ -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; } diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp index e90702992..ba9bb981f 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp @@ -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 VerticalFileSwitcherListView::getSelectedFiles(bool reverse) const { std::vector files; diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.h b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.h index 50884ac70..35b383bb1 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.h +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.h @@ -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); };