From 19befa9797ef61e7a806a21a13e0138b513eb0f6 Mon Sep 17 00:00:00 2001 From: Yuval Date: Sat, 25 Apr 2009 10:39:25 +0000 Subject: [PATCH] [BUG_FIXED] Fixed two bugs when calculating the width of the TeskList (document list when pressing ctrl+tab or right-click + mouse wheel. 1. max width was not calculated correctly 2. style of selected file font (bold) wasn't taken into consideration also - changed background color to light yellow instead of light gray. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@463 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/ScitillaComponent/colors.h | 1 + .../src/WinControls/TaskList/TaskList.cpp | 22 ++++++++++-------- .../src/WinControls/TaskList/TaskList.h | 23 +++++++++++++++---- .../src/WinControls/TaskList/TaskListDlg.h | 4 +--- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/PowerEditor/src/ScitillaComponent/colors.h b/PowerEditor/src/ScitillaComponent/colors.h index 158c6dff..c10065f7 100644 --- a/PowerEditor/src/ScitillaComponent/colors.h +++ b/PowerEditor/src/ScitillaComponent/colors.h @@ -45,6 +45,7 @@ const COLORREF brown = RGB(128, 64, 0); //const COLORREF greenBlue = RGB(192, 128, 64); const COLORREF darkYellow = RGB(0xFF, 0xC0, 0); const COLORREF yellow = RGB(0xFF, 0xFF, 0); +const COLORREF lightYellow = RGB(0xFF, 0xFF, 0xD5); const COLORREF cyan = RGB(0, 0xFF, 0xFF); const COLORREF orange = RGB(0xFF, 0x80, 0x00); const COLORREF purple = RGB(0x80, 0x00, 0xFF); diff --git a/PowerEditor/src/WinControls/TaskList/TaskList.cpp b/PowerEditor/src/WinControls/TaskList/TaskList.cpp index 8ac27f3a..830628c2 100644 --- a/PowerEditor/src/WinControls/TaskList/TaskList.cpp +++ b/PowerEditor/src/WinControls/TaskList/TaskList.cpp @@ -76,8 +76,7 @@ void TaskList::init(HINSTANCE hInst, HWND parent, HIMAGELIST hImaLst, int nbItem ListView_SetImageList(_hSelf, hImaLst, LVSIL_SMALL); ListView_SetItemState(_hSelf, _currentIndex, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED); - ListView_SetBkColor(_hSelf, veryLiteGrey); - ListView_SetTextBkColor(_hSelf, veryLiteGrey); + ListView_SetBkColor(_hSelf, lightYellow); } RECT TaskList::adjustSize() @@ -87,21 +86,24 @@ RECT TaskList::adjustSize() const int imgWidth = rc.right - rc.left; const int marge = 30; + // Temporary set "selected" font to get the worst case widths + ::SendMessage(_hSelf, WM_SETFONT, reinterpret_cast(_hFontSelected), 0); + int maxwidth = -1; + + _rc.left = 0; + _rc.top = 0; + _rc.bottom = 0; for (int i = 0 ; i < _nbItem ; i++) { TCHAR buf[MAX_PATH]; ListView_GetItemText(_hSelf, i, 0, buf, MAX_PATH); int width = ListView_GetStringWidth(_hSelf, buf); - - if (width > (_rc.right - _rc.left)) - _rc.right = _rc.left + width + imgWidth + marge; - + if (width > maxwidth) + maxwidth = width; _rc.bottom += rc.bottom - rc.top; - } - - // additional space for horizontal scroll-bar - _rc.bottom += rc.bottom - rc.top; + _rc.right = maxwidth + imgWidth + marge; + ::SendMessage(_hSelf, WM_SETFONT, reinterpret_cast(_hFont), 0); reSizeTo(_rc); return _rc; diff --git a/PowerEditor/src/WinControls/TaskList/TaskList.h b/PowerEditor/src/WinControls/TaskList/TaskList.h index 647ef4c2..2485a404 100644 --- a/PowerEditor/src/WinControls/TaskList/TaskList.h +++ b/PowerEditor/src/WinControls/TaskList/TaskList.h @@ -29,7 +29,7 @@ class TaskList : public Window { public: - TaskList() : Window(), _currentIndex(0) { + TaskList() : Window(), _currentIndex(0), _hFont(NULL), _hFontSelected(NULL) { _rc.left = 0; _rc.top = 0; _rc.right = 150; @@ -41,6 +41,8 @@ public: virtual void destroy(){ if (_hFont) DeleteObject(_hFont); + if (_hFontSelected) + DeleteObject(_hFontSelected); ::DestroyWindow(_hSelf); _hSelf = NULL; }; @@ -50,26 +52,36 @@ public: void setFont(TCHAR *fontName, size_t fontSize) { if (_hFont) ::DeleteObject(_hFont); + if (_hFontSelected) + ::DeleteObject(_hFontSelected); - _hFont = ::CreateFont( fontSize, 0, 0, 0, + _hFont = ::CreateFont(fontSize, 0, 0, 0, FW_NORMAL, 0, 0, 0, 0, 0, 0, 0, 0, fontName); + + _hFontSelected = ::CreateFont(fontSize, 0, 0, 0, + FW_BOLD, + 0, 0, 0, 0, + 0, 0, 0, 0, + fontName); + if (_hFont) ::SendMessage(_hSelf, WM_SETFONT, reinterpret_cast(_hFont), 0); }; RECT adjustSize(); - int getCurrentIndex() const { - return _currentIndex; - }; + int getCurrentIndex() const {return _currentIndex;} int updateCurrentIndex(); HIMAGELIST getImgLst() const { return ListView_GetImageList(_hSelf, LVSIL_SMALL); }; + + HFONT GetFontSelected() {return _hFontSelected;} + protected: WNDPROC _defaultProc; @@ -80,6 +92,7 @@ protected: }; HFONT _hFont; + HFONT _hFontSelected; int _nbItem; int _currentIndex; RECT _rc; diff --git a/PowerEditor/src/WinControls/TaskList/TaskListDlg.h b/PowerEditor/src/WinControls/TaskList/TaskListDlg.h index 6d29f341..32041574 100644 --- a/PowerEditor/src/WinControls/TaskList/TaskListDlg.h +++ b/PowerEditor/src/WinControls/TaskList/TaskListDlg.h @@ -216,9 +216,7 @@ private : { imgStyle = ILD_TRANSPARENT; textColor = black; - - HFONT selectedFont = (HFONT)::GetStockObject(SYSTEM_FONT); - ::SelectObject(hDC, selectedFont); + ::SelectObject(hDC, _taskList.GetFontSelected()); } //