1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/tooltip.h
3 // Purpose: wxToolTip class - tooltip control
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1999 Robert Roebling, Vadim Zeitlin
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_MSW_TOOLTIP_H_
13 #define _WX_MSW_TOOLTIP_H_
15 #include "wx/object.h"
16 #include "wx/gdicmn.h"
18 class WXDLLIMPEXP_FWD_CORE wxWindow
;
20 class WXDLLIMPEXP_CORE wxToolTip
: public wxObject
24 wxToolTip(const wxString
&tip
);
27 // ctor used by wxStatusBar to associate a tooltip to a portion of
28 // the status bar window:
29 wxToolTip(wxWindow
* win
, unsigned int id
,
30 const wxString
&tip
, const wxRect
& rc
);
34 void SetTip(const wxString
& tip
);
35 const wxString
& GetTip() const { return m_text
; }
37 // the window we're associated with
38 void SetWindow(wxWindow
*win
);
39 wxWindow
*GetWindow() const { return m_window
; }
41 // controlling tooltip behaviour: globally change tooltip parameters
42 // enable or disable the tooltips globally
43 static void Enable(bool flag
);
44 // set the delay after which the tooltip appears
45 static void SetDelay(long milliseconds
);
46 // set the delay after which the tooltip disappears or how long the
47 // tooltip remains visible
48 static void SetAutoPop(long milliseconds
);
49 // set the delay between subsequent tooltips to appear
50 static void SetReshow(long milliseconds
);
51 // set maximum width for the new tooltips: -1 disables wrapping
52 // entirely, 0 restores the default behaviour
53 static void SetMaxWidth(int width
);
55 // implementation only from now on
56 // -------------------------------
58 // should be called in response to WM_MOUSEMOVE
59 static void RelayEvent(WXMSG
*msg
);
61 // add a window to the tooltip control
62 void Add(WXHWND hwnd
);
64 // remove any tooltip from the window
65 static void Remove(WXHWND hwnd
, unsigned int id
, const wxRect
& rc
);
67 // the rect we're associated with
68 void SetRect(const wxRect
& rc
);
69 const wxRect
& GetRect() const { return m_rect
; }
72 // the one and only one tooltip control we use - never access it directly
73 // but use GetToolTipCtrl() which will create it when needed
74 static WXHWND ms_hwndTT
;
76 // create the tooltip ctrl if it doesn't exist yet and return its HWND
77 static WXHWND
GetToolTipCtrl();
79 // new tooltip maximum width, defaults to min(display width, 400)
80 static int ms_maxWidth
;
82 // remove this tooltip from the tooltip control
85 wxString m_text
; // tooltip text
86 wxWindow
* m_window
; // window we're associated with
87 wxRect m_rect
; // the rect of the window for which this tooltip is shown
88 // (or a rect with width/height == 0 to show it for the entire window)
89 unsigned int m_id
; // the id of this tooltip (ignored when m_rect width/height is 0)
91 DECLARE_ABSTRACT_CLASS(wxToolTip
)
92 wxDECLARE_NO_COPY_CLASS(wxToolTip
);
95 #endif // _WX_MSW_TOOLTIP_H_