OSDN Git Service

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