diff --git a/PowerEditor/src/ScitillaComponent/colors.h b/PowerEditor/src/ScitillaComponent/colors.h index 158c6dff8..c10065f7e 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 8ac27f3ae..830628c29 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 647ef4c2b..2485a404d 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 6d29f3414..32041574a 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()); } //