added new log filter (for subject)
[TortoiseGit.git] / src / Utils / MiscUI / Balloon.h
blobd3d02cf873cdd29288bc950d4e918c76ba570fbe
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
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 #include "gradient.h"
22 #include "htmlformatter.h"
23 #include "cursor.h"
25 //The styles
26 #define BALLOON_ANCHOR 0x0001
27 #define BALLOON_SHADOW 0x0002
28 #define BALLOON_ROUNDED 0x0004
29 #define BALLOON_RSA 0x0007
30 #define BALLOON_VCENTER_ALIGN 0x0008
31 #define BALLOON_BOTTOM_ALIGN 0x0010
32 #define BALLOON_CLOSEBUTTON 0x0020
34 //The behaviors
35 #define BALLOON_MULTIPLE_SHOW 0x0001 //Multiple show for single control
36 #define BALLOON_TRACK_MOUSE 0x0002 //ToolTip follows the mouse cursor
37 #define BALLOON_DIALOG 0x0004 //Shown as a dialog instead of a tooltip
38 #define BALLOON_DIALOG_DESTROY 0x0008 //delete the object after window is destroyed. Use carefully!
40 //The masks
41 #define BALLOON_MASK_STYLES 0x0001 //The styles for the tooltip gets from the structures
42 #define BALLOON_MASK_EFFECT 0x0002 //The background's type for the tooltip gets from the structures
43 #define BALLOON_MASK_COLORS 0x0004 //The background's colors for the tooltip gets from the structures
44 #define BALLOON_MASK_DIRECTION 0x0008 //The align for the tooltip gets from the structures
45 #define BALLOON_MASK_BEHAVIOUR 0x0010 //The behavior for the tooltip gets from the structures
47 /**
48 * \ingroup Utils
49 * BALLOON_INFO structure.
51 typedef struct tagBALLOON_INFO
53 HICON hIcon; ///<The icon of the tooltip
54 CString sBalloonTip; ///<The string of the tooltip
55 UINT nMask; ///<The mask
56 UINT nStyles; ///<The tool tip's styles
57 UINT nDirection; ///<Direction display the tooltip relate cursor point
58 UINT nEffect; ///<The color's type or effects
59 UINT nBehaviour; ///<The tool tip's behavior
60 COLORREF crBegin; ///<Begin Color
61 COLORREF crMid; ///<Mid Color
62 COLORREF crEnd; ///<End Color
64 tagBALLOON_INFO(); ///<proper initialization of all members
65 } BALLOON_INFO;
67 /**
68 * \ingroup Utils
69 * This structure is sent to with the notify messages.
71 typedef struct tagNM_BALLOON_DISPLAY {
72 NMHDR hdr;
73 CPoint * pt;
74 CWnd * pWnd;
75 BALLOON_INFO * bi;
76 } NM_BALLOON_DISPLAY;
78 #define BALLOON_CLASSNAME _T("CBalloon") // Window class name
79 #define UDM_TOOLTIP_FIRST (WM_USER + 100)
80 #define UDM_TOOLTIP_DISPLAY (UDM_TOOLTIP_FIRST) //User has changed the data
82 /**
83 * \ingroup Utils
84 * Shows Balloons with info text in it. Either as Tooltips or as modeless dialog boxes.
85 * Several options are available to customize the look and behavior of the balloons.
86 * Since this class inherits CHTMLFormatter you can use all the tags CHTMLFormatter
87 * provides to format the text.
88 * Please refer to the documentation of the methods for details.\n
89 * \image html "balloon_box.jpg"
90 * \image html "balloon_tooltip.jpg"
92 * To use the dialog balloons just call the static methods:
93 * \code
94 * CWnd* ctrl = GetDlgItem(IDC_EDITBOX);
95 * CRect rt;
96 * ctrl->GetWindowRect(rt);
97 * CPoint point = CPoint((rt.left+rt.right)/2, (rt.top+rt.bottom)/2);
98 * CBalloon::ShowBalloon(NULL, point,
99 * "this is a <b>Message Balloon</b>\n<hr=100%>\n<ct=0x0000FF>Warning! Warning!</ct>\nSomething unexpected happened",
100 * TRUE, IDI_EXCLAMATION);
101 * \endcode
103 * To use the tooltips, declare an object of CBalloon as a member of your dialog class:
104 * \code
105 * CBalloon m_tooltips;
106 * \code
107 * In your OnInitDialog() method add the tooltips and modify them as you like:
108 * \code
109 * m_tooltips.Create(this); //initializes the tooltips
110 * m_tooltips.AddTool(IDC_BUTTON, "this button does nothing");
111 * m_tooltips.AddTool(IDC_EDITBOX, "enter a value here", IDI_ICON);
112 * m_tooltips.SetEffectBk(GetDlgItem(IDC_EDITBOX), CBalloon::BALLOON_EFFECT_HGRADIENT); //only affects the edit box tooltip
113 * m_tooltips.SetGradientColors(0x80ffff, 0x000000, 0xffff80);
114 * \endcode
115 * and last you have to override the PreTranslateMessage() method of your dialog box:
116 * \code
117 * BOOL CMyDialog::PreTranslateMessage(MSG* pMsg)
119 * m_tooltips.RelayEvent(pMsg);
120 * return CDialog::PreTranslateMessage(pMsg);
122 * \endcode
124 class CBalloon : public CWnd, public CHTMLFormatter
126 // Construction
127 public:
128 virtual BOOL Create(CWnd* pParentWnd);
129 CBalloon();
130 virtual ~CBalloon();
132 // Attributes
133 public:
134 enum { XBLSZ_ROUNDED_CX = 0,
135 XBLSZ_ROUNDED_CY,
136 XBLSZ_MARGIN_CX,
137 XBLSZ_MARGIN_CY,
138 XBLSZ_SHADOW_CX,
139 XBLSZ_SHADOW_CY,
140 XBLSZ_WIDTH_ANCHOR,
141 XBLSZ_HEIGHT_ANCHOR,
142 XBLSZ_MARGIN_ANCHOR,
143 XBLSZ_BORDER_CX,
144 XBLSZ_BORDER_CY,
145 XBLSZ_BUTTON_MARGIN_CX,
146 XBLSZ_BUTTON_MARGIN_CY,
148 XBLSZ_MAX_SIZES
151 enum { BALLOON_COLOR_FG = 0,
152 BALLOON_COLOR_BK_BEGIN,
153 BALLOON_COLOR_BK_MID,
154 BALLOON_COLOR_BK_END,
155 BALLOON_COLOR_SHADOW, // Color for the shadow
156 BALLOON_COLOR_BORDER, // Color for border of the tooltip
158 BALLOON_MAX_COLORS
161 enum { BALLOON_LEFT_TOP = 0,
162 BALLOON_RIGHT_TOP,
163 BALLOON_LEFT_BOTTOM,
164 BALLOON_RIGHT_BOTTOM,
166 BALLOON_MAX_DIRECTIONS
169 enum { BALLOON_EFFECT_SOLID = 0,
170 BALLOON_EFFECT_HGRADIENT,
171 BALLOON_EFFECT_VGRADIENT,
172 BALLOON_EFFECT_HCGRADIENT,
173 BALLOON_EFFECT_VCGRADIENT,
174 BALLOON_EFFECT_3HGRADIENT,
175 BALLOON_EFFECT_3VGRADIENT,
177 BALLOON_MAX_EFFECTS
181 // Operations
182 public:
184 // Overrides
185 // ClassWizard generated virtual function overrides
186 //{{AFX_VIRTUAL(XToolTip)
187 public:
188 virtual BOOL PreTranslateMessage(MSG* pMsg);
189 //}}AFX_VIRTUAL
191 // Implementation
192 public:
193 /** \name Balloon Dialogs
194 * static methods to show a balloon like a modeless dialog
196 //@{
198 * Pops up a balloon like a modeless dialog to inform the user in
199 * a non disturbing way like with a normal MessageBox().
200 * \image html "balloon_box.jpg"
201 * An example of when to use such balloons is in a dialog box where
202 * the user can enter values. If one or several values are outside
203 * of valid ranges then just pop up a balloon. That way the user
204 * knows exactly \b where the wrong value is (if the balloon is
205 * placed so that the anchor points to the edit box) and also
206 * doesn't have to press "OK" to close the box.
208 * \param pWnd the parent window. Or NULL if no parent window is available.
209 * \param pt the point where the anchor should point to. For example if you
210 * want to point to an edit box the point would be:
211 * \code
212 * CWnd* ctrl = GetDlgItem(IDC_EDITBOX);
213 * CRect rt;
214 * ctrl->GetWindowRect(rt);
215 * CPoint point = CPoint((rt.left+rt.right)/2, (rt.top+rt.bottom)/2);
216 * \endcode
217 * \param nIdText the string ID of the text to show. The ID has to be in your resources.
218 * \param sText the string to show.
219 * \param showCloseButton If TRUE, then the balloon has a close button in the upper right corner. That also
220 * makes the balloon to show up until the user presses the close button.\n
221 * If FALSE, then the balloon will be closed after a timeout of 5 seconds or as soon as the user clicks anywhere
222 * on the balloon.
223 * \param hIcon a handle of an icon.
224 * \param nIdIcon an ID of an icon which has to be in your resources.
225 * \param szIcon a name of an icon. Either a path to an icon file or one of
226 * the following system icons:\n
227 * - IDI_APPLICATION
228 * - IDI_ERROR
229 * - IDI_HAND
230 * - IDI_EXCLAMATION
231 * - IDI_WARNING
232 * - IDI_QUESTION
233 * - IDI_WINLOGO
234 * - IDI_INFORMATION
235 * - IDI_ASTERISK
236 * - IDI_QUESTION
238 * \param nDirection the direction to where the dialog should be drawn. Defaults to BALLOON_RIGHT_TOP.
239 * - BALLOON_LEFT_TOP
240 * - BALLOON_RIGHT_TOP
241 * - BALLOON_LEFT_BOTTOM
242 * - BALLOON_RIGHT_BOTTOM
244 * \param nEffect specifies how to draw the background. Defaults to BALLOON_EFFECT_SOLID.
245 * - BALLOON_EFFECT_SOLID one color for the background. The default is the standard windows color for tooltip backgrounds.
246 * - BALLOON_EFFECT_HGRADIENT draws a horizontal gradient from crStart to crEnd
247 * - BALLOON_EFFECT_VGRADIENT draws a vertical gradient from crStart to crEnd
248 * - BALLOON_EFFECT_HCGRADIENT draws a horizontal gradient from crStart to crEnd to crStart
249 * - BALLOON_EFFECT_VCGRADIENT draws a vertical gradient from crStart to crEnd to crStart
250 * - BALLOON_EFFECT_3HGRADIENT draws a horizontal gradient from crStart to crMid to crEnd
251 * - BALLOON_EFFECT_3VGRADIENT draws a vertical gradient from crStart to crMid to crEnd
253 * \param crStart the starting color for gradients
254 * \param crMid the middle color for three colored gradients
255 * \param crEnd the end color for gradients
258 * \overload ShowBalloon(CWnd * pWnd, CPoint pt, UINT nIdText, BOOL showCloseButton, UINT nIdIcon, UINT nDirection = BALLOON_RIGHT_TOP, UINT nEffect = BALLOON_EFFECT_SOLID, COLORREF crStart = NULL, COLORREF crMid = NULL, COLORREF crEnd = NULL);
260 static void ShowBalloon(
261 CWnd * pWnd, CPoint pt, const CString& sText, BOOL showCloseButton, HICON hIcon,
262 UINT nDirection = BALLOON_RIGHT_TOP, UINT nEffect = BALLOON_EFFECT_SOLID,
263 COLORREF crStart = NULL, COLORREF crMid = NULL, COLORREF crEnd = NULL);
265 * \overload ShowBalloon(CWnd * pWnd, CPoint pt, UINT nIdText, BOOL showCloseButton, LPCTSTR szIcon);
267 static void ShowBalloon(CWnd * pWnd, CPoint pt, UINT nIdText, BOOL showCloseButton, LPCTSTR szIcon);
268 //@}
270 /**
271 * Helper function to return the center point of a dialog control
272 * Useful for passing to ShowBalloon
274 static CPoint GetCtrlCentre(CWnd* pDlgWnd, UINT ctrlId);
276 /** \name ToolTips
277 * handling of tooltips.
279 //@{
280 //@{
282 * Adds a tooltip for a windows element to the internal list.
283 * \param pWnd pointer to a windows element.
284 * \param nIdWnd an ID of a dialog resource.
285 * \param nIdText an ID of a string dialog resource to use as the tooltip text.
286 * \param sBalloontipText string for the tooltip.
287 * \param hIcon handle for an icon to show on the tooltip.
288 * \param nIdIcon a resource ID for an icon to show on the tooltip.
289 * \param bi pointer to a BALLOON_IFNO structure.
291 void AddTool(CWnd * pWnd, UINT nIdText, HICON hIcon = NULL); //Adds tool
292 void AddTool(CWnd * pWnd, UINT nIdText, UINT nIdIcon); //Adds tool
293 void AddTool(CWnd * pWnd, const CString& sBalloonTipText, HICON hIcon = NULL); //Adds tool
294 void AddTool(CWnd * pWnd, const CString& sBalloonTipText, UINT nIdIcon); //Adds tool
295 void AddTool(int nIdWnd, UINT nIdText, HICON hIcon = NULL); //Adds tool
296 void AddTool(int nIdWnd, UINT nIdText, UINT nIdIcon); //Adds tool
297 void AddTool(int nIdWnd, const CString& sBalloonTipText, HICON hIcon = NULL); //Adds tool
298 void AddTool(int nIdWnd, const CString& sBalloonTipText, UINT nIdIcon); //Adds tool
299 void AddTool(CWnd * pWnd, BALLOON_INFO & bi); //Adds tool
300 //@}
303 * Gets the text and the icon handle of a specific tooltip.
304 * \param pWnd pointer to the tooltip window
305 * \param sBalloonTipText the returned tooltip text
306 * \param hIcon the returned icon handle
307 * \param bi pointer to the returned BALLOON_INFO structure.
308 * \return TRUE if the tooltip exists.
310 BOOL GetTool(CWnd * pWnd, CString & sBalloonTipText, HICON & hIcon) const; //Gets the tool tip's text
311 BOOL GetTool(CWnd * pWnd, BALLOON_INFO & bi) const; //Gets tool
314 * Removes a specific tooltip from the internal list.
315 * \param pWnd pointer to the tooltip window
317 void RemoveTool(CWnd * pWnd); //Removes specified tool
320 * Removes all tooltips from the internal list.
322 void RemoveAllTools(); // Removes all tools
323 //@}
325 /** \name Styles
326 * handling of tooltip appearance styles.
327 * The following styles are available:
328 * - BALLOON_ANCHOR the balloon is drawn with an anchor
329 * - BALLOON_SHADOW the balloon is drawn with a SE shadow
330 * - BALLOON_ROUNDED the balloon has round corners. For tooltips like the standard windows ones disable this style.
331 * - BALLOON_RSA combines BALLOON_ANCHOR, BALLOON_SHADOW and BALLOON_ROUNDED. This is the default.
332 * - BALLOON_VCENTER_ALIGN
333 * - BALLOON_BOTTOM_ALIGN
334 * - BALLOON_CLOSEBUTTON the balloon has a close button in the upper right corner.
336 //@{
338 * sets styles for either all tooltips or specific ones.
339 * \param nStyles the styles to set.
340 * \param pWnd pointer to the tooltip window or NULL if the styles should affect all tooltips.
342 void SetStyles(DWORD nStyles, CWnd * pWnd = NULL); //Sets New Style
344 * Modifies existing styles.
345 * \param nAddStyles the styles to add.
346 * \param nRemoveStyles the styles to remove
347 * \param pWnd pointer to the tooltip window or NULL if the styles should affect all tooltips.
349 void ModifyStyles(DWORD nAddStyles, DWORD nRemoveStyles, CWnd * pWnd = NULL); //Modifies styles
351 * returns the current styles for the tooltip.
352 * \param pWnd pointer to the tooltip window or NULL if the global styles are needed.
354 DWORD GetStyles(CWnd * pWnd = NULL) const; //Gets current Styles
356 * Resets the styles to the default values.
357 * \param pWnd pointer to the tooltip window or NULL if the styles should affect all tooltips.
359 void SetDefaultStyles(CWnd * pWnd = NULL); //Sets default styles
360 //@}
362 /** \name Colors
363 * different color settings. The following elements have colors:
364 * - BALLOON_COLOR_FG the foreground text color. Default is black.
365 * - BALLOON_COLOR_BK_BEGIN the background color and the first color in gradients.
366 * - BALLOON_COLOR_BK_MID the middle color for gradients.
367 * - BALLOON_COLOR_BK_END the end color for gradients.
368 * - BALLOON_COLOR_SHADOW the color of the shadow
369 * - BALLOON_COLOR_BORDER the color for the balloon border
371 //@{
373 * Sets the color for a balloon element.
374 * \param nIndex the element to set the color.
375 * \param crColor the color.
377 void SetColor(int nIndex, COLORREF crColor); //Sets the color
379 * Returns the color of a balloon element.
381 COLORREF GetColor(int nIndex) const; //Gets the color
383 * Resets all colors to default values.
385 void SetDefaultColors(); //Sets default colors
387 * Sets the colors used in the background gradients.
388 * \param crBegin first color
389 * \param crMid middle color
390 * \param crEnd end color
391 * \param pWnd pointer to the tooltip window or NULL if the settings are global.
393 void SetGradientColors(COLORREF crBegin, COLORREF crMid, COLORREF crEnd, CWnd * pWnd = NULL); //Sets the gradient's colors
395 * Returns the colors used in the background gradients.
396 * \param pWnd pointer to the tooltip window or NULL if the global settings are needed.
398 void GetGradientColors(COLORREF & crBegin, COLORREF & crMid, COLORREF & crEnd, CWnd * pWnd = NULL) const; //Gets the gradient's colors
399 //@}
402 /** \name Masks
403 * Manipulate masks of tooltips. Masks are used to define styles, effects, colors and the like for single
404 * tooltips and not only for all tooltips.
405 * Whatever mask is set for a specific tooltip means that this tooltip has its own version of those settings
406 * and ignores the global settings.\n
407 * The following masks are available:
408 * - BALLOON_MASK_STYLES masks out the styles
409 * - BALLOON_MASK_EFFECT masks out the effects
410 * - BALLOON_MASK_COLORS masks out the colors
411 * - BALLOON_MASK_DIRECTION masks out the direction
412 * - BALLOON_MASK_BEHAVIOUR masks out the behavior
414 * The functions either set, modify or read out the masks for specific tooltip windows.
416 //@{
417 void SetMaskTool(CWnd * pWnd, UINT nMask = 0);
418 void ModifyMaskTool(CWnd * pWnd, UINT nAddMask, UINT nRemoveMask);
419 UINT GetMaskTool(CWnd * pWnd) const;
420 //@}
422 /** \name Effects
423 * Use these methods to manipulate background effects of the tooltip. The following
424 * effects are available.
425 * - BALLOON_EFFECT_SOLID one color for the background. The default is the standard windows color for tooltip backgrounds.
426 * - BALLOON_EFFECT_HGRADIENT draws a horizontal gradient from crStart to crEnd
427 * - BALLOON_EFFECT_VGRADIENT draws a vertical gradient from crStart to crEnd
428 * - BALLOON_EFFECT_HCGRADIENT draws a horizontal gradient from crStart to crEnd to crStart
429 * - BALLOON_EFFECT_VCGRADIENT draws a vertical gradient from crStart to crEnd to crStart
430 * - BALLOON_EFFECT_3HGRADIENT draws a horizontal gradient from crStart to crMid to crEnd
431 * - BALLOON_EFFECT_3VGRADIENT draws a vertical gradient from crStart to crMid to crEnd
433 //@{
434 void SetEffectBk(UINT nEffect, CWnd * pWnd = NULL);
435 UINT GetEffectBk(CWnd * pWnd = NULL) const;
436 //@}
438 /** \name Notification
439 * Gets or sets if the parent or any other window should get notification messages from
440 * the tooltips.
442 //@{
443 void SetNotify(HWND hWnd);
444 void SetNotify(BOOL bParentNotify = TRUE);
445 BOOL GetNotify() const; //Is enabled notification
446 //@}
448 /** \name Delaytimes
449 * Gets or sets the delay times for the tooltips.
450 * - TTDT_AUTOPOP time in milliseconds until the tooltip automatically closes.
451 * - TTDT_INITIAL time in milliseconds until the tooltip appears when the mouse pointer is over a control.
453 //@{
454 void SetDelayTime(DWORD dwDuration, UINT nTime);
455 UINT GetDelayTime(DWORD dwDuration) const;
456 //@}
459 /** \name Direction
460 * Gets or sets the direction of the balloons.
461 * - BALLOON_LEFT_TOP
462 * - BALLOON_RIGHT_TOP
463 * - BALLOON_LEFT_BOTTOM
464 * - BALLOON_RIGHT_BOTTOM
466 //@{
467 void SetDirection(UINT nDirection = BALLOON_RIGHT_TOP, CWnd * pWnd = NULL);
468 UINT GetDirection(CWnd * pWnd = NULL) const;
469 //@}
471 /** \name Behavior
472 * Gets or sets the behavior of the balloons.
473 * - BALLOON_MULTIPLE_SHOW if this is set then the tooltip will appear again if the mouse pointer is still over the same control.
474 * - BALLOON_TRACK_MOUSE if set then the tooltip will follow the mouse pointer
475 * - BALLOON_DIALOG the balloon is shown as a dialog instead of a tooltip, i.e. it won't close when the mouse pointer leaves the control.
476 * - BALLOON_DIALOG_DESTROY the object itself is destroyed when the balloon is closed. Use this \b very carefully!
478 //@{
479 void SetBehaviour(UINT nBehaviour = 0, CWnd * pWnd = NULL);
480 UINT GetBehaviour(CWnd * pWnd = NULL) const;
481 //@}
483 /** \name Fonts
484 * Font settings for the balloon text.
486 //@{
487 BOOL SetFont(CFont & font); //set font
488 BOOL SetFont(LPLOGFONT lf); //set font
489 BOOL SetFont(LPCTSTR lpszFaceName, int nSizePoints = 8,
490 BOOL bUnderline = FALSE, BOOL bBold = FALSE,
491 BOOL bStrikeOut = FALSE, BOOL bItalic = FALSE); //set font
492 void SetDefaultFont(); //set default fonts
493 void GetFont(CFont & font) const;
494 void GetFont(LPLOGFONT lf) const;
495 //@}
498 * Call this method from CDialog::PreTranslateMessage(pMsg).
500 void RelayEvent(MSG* pMsg);
503 * Hide tooltip immediately.
505 void Pop();
508 * Shows a tooltip immediately.
510 void DisplayToolTip(CPoint * pt = NULL);
511 void DisplayToolTip(CPoint * pt, CRect * rect);
513 // Generated message map functions
514 protected:
515 void SetSize(int nSizeIndex, UINT nValue);
516 UINT GetSize(int nSizeIndex) const;
517 void SetDefaultSizes();
519 void Redraw(BOOL bRedraw = TRUE);
520 void KillTimers(UINT nIDTimer = NULL);
522 void SetNewToolTip(CWnd * pWnd);
523 void GetMonitorWorkArea(const CPoint& sourcePoint, CRect& monitorRect) const;
526 * Finds the child window to which the point belongs
527 * \param point the point to look for the child window
528 * \return the pointer to the child window, or NULL if there is now window
530 HWND GetChildWindowFromPoint(CPoint & point) const;
531 BOOL IsCursorInToolTip() const;
532 inline BOOL IsVisible() const { return ((GetStyle() & WS_VISIBLE) == WS_VISIBLE); }
534 CSize GetTooltipSize(const CString& str); //Gets max rectangle for display tooltip text
535 CSize GetSizeIcon(HICON hIcon) const;
536 void CalculateInfoBoxRect(CPoint * pt, CRect * rect);
538 LPLOGFONT GetSystemToolTipFont() const;
540 int GetNextHorizDirection(int nDirection) const;
541 int GetNextVertDirection(int nDirection) const;
542 BOOL TestHorizDirection(int x, int cx, const CRect& monitorRect, int nDirection, LPRECT rect);
543 BOOL TestVertDirection(int y, int cy, const CRect& monitorRect, int nDirection, LPRECT rect);
545 CRect GetWindowRegion(CRgn * rgn, CSize sz, CPoint pt) const;
547 LRESULT SendNotify(CWnd * pWnd, CPoint * pt, BALLOON_INFO & bi);
549 void OnDraw(CDC * pDC, CRect rect);
550 void OnDrawBackground(CDC * pDC, CRect * pRect);
552 virtual void PostNcDestroy();
553 afx_msg void OnPaint();
554 afx_msg void OnTimer(UINT_PTR nIDEvent);
555 afx_msg void OnDestroy();
556 afx_msg void OnKillFocus(CWnd* pNewWnd);
557 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
558 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
559 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
560 DECLARE_MESSAGE_MAP()
561 protected:
562 enum { BALLOON_SHOW = 0x100, //the identifier of the timer for show the tooltip
563 BALLOON_HIDE = 0x101 //the identifier of the timer for hide the tooltip
566 CMap<HWND, HWND, BALLOON_INFO, BALLOON_INFO> m_ToolMap; //Tool Maps
568 HWND m_hNotifyWnd; // Handle to window for notification about change data
569 CWnd * m_pParentWnd; // The pointer to the parent window
570 HWND m_hCurrentWnd;
571 HWND m_hDisplayedWnd;
572 UINT m_nLastDirection;
575 LOGFONT m_LogFont; // Current font in use
577 //Default setting
578 COLORREF m_crColor [BALLOON_MAX_COLORS]; //The indexing colors
579 UINT m_nSizes [XBLSZ_MAX_SIZES]; //All sizes
580 UINT m_nStyles;
581 UINT m_nDirection;
582 UINT m_nEffect;
583 UINT m_nBehaviour; //The tool tip's behavior
585 UINT m_nTimeAutoPop;
586 UINT m_nTimeInitial;
588 //The properties of the current tooltip
589 CPoint m_ptOriginal;
591 CRgn m_rgnBalloon;
592 CRgn m_rgnShadow;
594 CSize m_szBalloonIcon; //the size of the current icon
595 CSize m_szBalloonText; //the size of the tool tip's text
596 CSize m_szCloseButton;
598 CRect m_rtCloseButton; //the rect for the close button
599 BOOL m_bButtonPushed;
601 CCursor m_Cursor;
603 BALLOON_INFO m_pToolInfo; //info of the current tooltip