Cleanup
[TortoiseGit.git] / src / Utils / MiscUI / ScrollTool.h
blob46548b2ab3f5724caba2a768411e59d4a6df14f5
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2006 - Stefan Kueng
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
21 /**
22 * \ingroup Utils
23 * Helper class to show a tooltip for e.g. a scrollbar while it is dragged.
24 * Example use:
25 * In the OnVScroll() message handler
26 * \code
27 * switch (nSBCode)
28 * {
29 * case SB_THUMBPOSITION:
30 * m_ScrollTool.Clear();
31 * break;
32 * case SB_THUMBTRACK:
33 * m_ScrollTool.Init(&thumbpoint);
34 * m_ScrollTool.SetText(&thumbpoint, _T("Line: %*ld"), maxchars, nTrackPos);
35 * break;
36 * }
39 class CScrollTool : public CWnd
41 public:
42 CScrollTool();
44 public:
45 /**
46 * Initializes the tooltip control.
47 * \param pos the position in screen coordinates where the tooltip should be shown
48 * \param bRightAligned if set to true, the tooltip is right aligned with pos,
49 * depending on the text width shown in the tooltip
51 bool Init(LPPOINT pos, bool bRightAligned = false);
52 /**
53 * Sets the text which should be shown in the tooltip.
54 * \param pos the position in screen coordinates where the tooltip should be shown
55 * \fmt a format string
57 void SetText(LPPOINT pos, const TCHAR * fmt, ...);
58 /**
59 * Removes the tooltip control.
61 void Clear();
62 /**
63 * Returns the width of \c szText in pixels for the tooltip control
65 LONG GetTextWidth(LPCTSTR szText);
67 virtual ~CScrollTool();
69 protected:
70 DECLARE_MESSAGE_MAP()
71 private:
72 TOOLINFO ti;
73 bool m_bInitCalled;
74 bool m_bRightAligned;