[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
This commit is contained in:
parent
d5475beb3e
commit
19befa9797
|
@ -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);
|
||||
|
|
|
@ -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<WPARAM>(_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<WPARAM>(_hFont), 0);
|
||||
|
||||
reSizeTo(_rc);
|
||||
return _rc;
|
||||
|
|
|
@ -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<WPARAM>(_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;
|
||||
|
|
|
@ -216,9 +216,7 @@ private :
|
|||
{
|
||||
imgStyle = ILD_TRANSPARENT;
|
||||
textColor = black;
|
||||
|
||||
HFONT selectedFont = (HFONT)::GetStockObject(SYSTEM_FONT);
|
||||
::SelectObject(hDC, selectedFont);
|
||||
::SelectObject(hDC, _taskList.GetFontSelected());
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue