1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2006 - Stefan Kueng
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
20 #include "ScrollTool.h"
\r
23 CScrollTool::CScrollTool() : m_bInitCalled(false)
\r
27 CScrollTool::~CScrollTool()
\r
32 BEGIN_MESSAGE_MAP(CScrollTool, CWnd)
\r
36 bool CScrollTool::Init(LPPOINT pos, bool bRightAligned /* = false */)
\r
40 // create the tooltip window
\r
41 if (!CreateEx(WS_EX_TOPMOST,
\r
44 TTS_NOPREFIX | TTS_ALWAYSTIP,
\r
56 ti.cbSize = sizeof(TOOLINFO);
\r
57 ti.uFlags = TTF_TRACK;
\r
61 ti.lpszText = _T(" ");
\r
63 // ToolTip control will cover the whole window
\r
70 ::GetCursorPos(&point);
\r
72 SendMessage(TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
\r
74 SendMessage(TTM_TRACKPOSITION, 0, (LPARAM)(DWORD) MAKELONG(point.x, point.y));
\r
75 SendMessage(TTM_TRACKACTIVATE, true, (LPARAM)(LPTOOLINFO) &ti);
\r
76 SendMessage(TTM_TRACKPOSITION, 0, MAKELONG(pos->x, pos->y));
\r
77 m_bRightAligned = bRightAligned;
\r
78 m_bInitCalled = true;
\r
83 void CScrollTool::SetText(LPPOINT pos, const TCHAR * fmt, ...)
\r
88 va_start( marker, fmt );
\r
89 s.FormatV(fmt, marker);
\r
93 if (m_bRightAligned)
\r
96 textsize = pDC->GetTextExtent(s);
\r
100 ti.lpszText = s.GetBuffer();
\r
101 SendMessage(TTM_UPDATETIPTEXT, 0, (LPARAM)(LPTOOLINFO) &ti);
\r
102 SendMessage(TTM_TRACKPOSITION, 0, MAKELONG(pos->x-textsize.cx, pos->y));
\r
106 void CScrollTool::Clear()
\r
110 SendMessage(TTM_DELTOOL, 0, (LPARAM)(LPTOOLINFO) &ti);
\r
113 m_bInitCalled = false;
\r
116 LONG CScrollTool::GetTextWidth(LPCTSTR szText)
\r
118 CDC *pDC = GetDC();
\r
119 CSize textsize = pDC->GetTextExtent(szText, _tcslen(szText));
\r
121 return textsize.cx;
\r