[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 greenBlue = RGB(192, 128, 64);
|
||||||
const COLORREF darkYellow = RGB(0xFF, 0xC0, 0);
|
const COLORREF darkYellow = RGB(0xFF, 0xC0, 0);
|
||||||
const COLORREF yellow = RGB(0xFF, 0xFF, 0);
|
const COLORREF yellow = RGB(0xFF, 0xFF, 0);
|
||||||
|
const COLORREF lightYellow = RGB(0xFF, 0xFF, 0xD5);
|
||||||
const COLORREF cyan = RGB(0, 0xFF, 0xFF);
|
const COLORREF cyan = RGB(0, 0xFF, 0xFF);
|
||||||
const COLORREF orange = RGB(0xFF, 0x80, 0x00);
|
const COLORREF orange = RGB(0xFF, 0x80, 0x00);
|
||||||
const COLORREF purple = RGB(0x80, 0x00, 0xFF);
|
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_SetImageList(_hSelf, hImaLst, LVSIL_SMALL);
|
||||||
|
|
||||||
ListView_SetItemState(_hSelf, _currentIndex, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
|
ListView_SetItemState(_hSelf, _currentIndex, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
|
||||||
ListView_SetBkColor(_hSelf, veryLiteGrey);
|
ListView_SetBkColor(_hSelf, lightYellow);
|
||||||
ListView_SetTextBkColor(_hSelf, veryLiteGrey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RECT TaskList::adjustSize()
|
RECT TaskList::adjustSize()
|
||||||
@ -87,21 +86,24 @@ RECT TaskList::adjustSize()
|
|||||||
const int imgWidth = rc.right - rc.left;
|
const int imgWidth = rc.right - rc.left;
|
||||||
const int marge = 30;
|
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++)
|
for (int i = 0 ; i < _nbItem ; i++)
|
||||||
{
|
{
|
||||||
TCHAR buf[MAX_PATH];
|
TCHAR buf[MAX_PATH];
|
||||||
ListView_GetItemText(_hSelf, i, 0, buf, MAX_PATH);
|
ListView_GetItemText(_hSelf, i, 0, buf, MAX_PATH);
|
||||||
int width = ListView_GetStringWidth(_hSelf, buf);
|
int width = ListView_GetStringWidth(_hSelf, buf);
|
||||||
|
if (width > maxwidth)
|
||||||
if (width > (_rc.right - _rc.left))
|
maxwidth = width;
|
||||||
_rc.right = _rc.left + width + imgWidth + marge;
|
|
||||||
|
|
||||||
_rc.bottom += rc.bottom - rc.top;
|
_rc.bottom += rc.bottom - rc.top;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
_rc.right = maxwidth + imgWidth + marge;
|
||||||
// additional space for horizontal scroll-bar
|
::SendMessage(_hSelf, WM_SETFONT, reinterpret_cast<WPARAM>(_hFont), 0);
|
||||||
_rc.bottom += rc.bottom - rc.top;
|
|
||||||
|
|
||||||
reSizeTo(_rc);
|
reSizeTo(_rc);
|
||||||
return _rc;
|
return _rc;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
class TaskList : public Window
|
class TaskList : public Window
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TaskList() : Window(), _currentIndex(0) {
|
TaskList() : Window(), _currentIndex(0), _hFont(NULL), _hFontSelected(NULL) {
|
||||||
_rc.left = 0;
|
_rc.left = 0;
|
||||||
_rc.top = 0;
|
_rc.top = 0;
|
||||||
_rc.right = 150;
|
_rc.right = 150;
|
||||||
@ -41,6 +41,8 @@ public:
|
|||||||
virtual void destroy(){
|
virtual void destroy(){
|
||||||
if (_hFont)
|
if (_hFont)
|
||||||
DeleteObject(_hFont);
|
DeleteObject(_hFont);
|
||||||
|
if (_hFontSelected)
|
||||||
|
DeleteObject(_hFontSelected);
|
||||||
::DestroyWindow(_hSelf);
|
::DestroyWindow(_hSelf);
|
||||||
_hSelf = NULL;
|
_hSelf = NULL;
|
||||||
};
|
};
|
||||||
@ -50,26 +52,36 @@ public:
|
|||||||
void setFont(TCHAR *fontName, size_t fontSize) {
|
void setFont(TCHAR *fontName, size_t fontSize) {
|
||||||
if (_hFont)
|
if (_hFont)
|
||||||
::DeleteObject(_hFont);
|
::DeleteObject(_hFont);
|
||||||
|
if (_hFontSelected)
|
||||||
|
::DeleteObject(_hFontSelected);
|
||||||
|
|
||||||
_hFont = ::CreateFont( fontSize, 0, 0, 0,
|
_hFont = ::CreateFont(fontSize, 0, 0, 0,
|
||||||
FW_NORMAL,
|
FW_NORMAL,
|
||||||
0, 0, 0, 0,
|
0, 0, 0, 0,
|
||||||
0, 0, 0, 0,
|
0, 0, 0, 0,
|
||||||
fontName);
|
fontName);
|
||||||
|
|
||||||
|
_hFontSelected = ::CreateFont(fontSize, 0, 0, 0,
|
||||||
|
FW_BOLD,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
fontName);
|
||||||
|
|
||||||
if (_hFont)
|
if (_hFont)
|
||||||
::SendMessage(_hSelf, WM_SETFONT, reinterpret_cast<WPARAM>(_hFont), 0);
|
::SendMessage(_hSelf, WM_SETFONT, reinterpret_cast<WPARAM>(_hFont), 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
RECT adjustSize();
|
RECT adjustSize();
|
||||||
int getCurrentIndex() const {
|
int getCurrentIndex() const {return _currentIndex;}
|
||||||
return _currentIndex;
|
|
||||||
};
|
|
||||||
int updateCurrentIndex();
|
int updateCurrentIndex();
|
||||||
|
|
||||||
HIMAGELIST getImgLst() const {
|
HIMAGELIST getImgLst() const {
|
||||||
return ListView_GetImageList(_hSelf, LVSIL_SMALL);
|
return ListView_GetImageList(_hSelf, LVSIL_SMALL);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
HFONT GetFontSelected() {return _hFontSelected;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
WNDPROC _defaultProc;
|
WNDPROC _defaultProc;
|
||||||
@ -80,6 +92,7 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
HFONT _hFont;
|
HFONT _hFont;
|
||||||
|
HFONT _hFontSelected;
|
||||||
int _nbItem;
|
int _nbItem;
|
||||||
int _currentIndex;
|
int _currentIndex;
|
||||||
RECT _rc;
|
RECT _rc;
|
||||||
|
@ -216,9 +216,7 @@ private :
|
|||||||
{
|
{
|
||||||
imgStyle = ILD_TRANSPARENT;
|
imgStyle = ILD_TRANSPARENT;
|
||||||
textColor = black;
|
textColor = black;
|
||||||
|
::SelectObject(hDC, _taskList.GetFontSelected());
|
||||||
HFONT selectedFont = (HFONT)::GetStockObject(SYSTEM_FONT);
|
|
||||||
::SelectObject(hDC, selectedFont);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user