1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/tooltip.h
3 // Purpose: wxToolTip class - tooltip control
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 1999 Robert Roebling, Vadim Zeitlin
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_MSW_TOOLTIP_H_
12 #define _WX_MSW_TOOLTIP_H_
14 #include "wx/object.h"
15 #include "wx/gdicmn.h"
17 class WXDLLIMPEXP_FWD_CORE wxWindow
;
18 class wxToolTipOtherWindows
;
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 AddOtherWindow(WXHWND hwnd
);
64 // remove any tooltip from the window
65 static void Remove(WXHWND hwnd
, unsigned int id
, const wxRect
& rc
);
67 // Set the rectangle we're associated with. This rectangle is only used for
68 // the main window, not any sub-windows added with Add() so in general it
69 // makes sense to use it for tooltips associated with a single window only.
70 void SetRect(const wxRect
& rc
);
73 // Adds a window other than our main m_window to this tooltip.
74 void DoAddHWND(WXHWND hWnd
);
76 // Perform the specified operation for the given window only.
77 void DoSetTip(WXHWND hWnd
);
78 void DoRemove(WXHWND hWnd
);
80 // Call the given function for all windows we're associated with.
81 void DoForAllWindows(void (wxToolTip::*func
)(WXHWND
));
84 // the one and only one tooltip control we use - never access it directly
85 // but use GetToolTipCtrl() which will create it when needed
86 static WXHWND ms_hwndTT
;
88 // create the tooltip ctrl if it doesn't exist yet and return its HWND
89 static WXHWND
GetToolTipCtrl();
91 // new tooltip maximum width, defaults to min(display width, 400)
92 static int ms_maxWidth
;
94 // remove this tooltip from the tooltip control
97 wxString m_text
; // tooltip text
98 wxWindow
* m_window
; // main window we're associated with
99 wxToolTipOtherWindows
*m_others
; // other windows associated with it or NULL
100 wxRect m_rect
; // the rect of the window for which this tooltip is shown
101 // (or a rect with width/height == 0 to show it for the entire window)
102 unsigned int m_id
; // the id of this tooltip (ignored when m_rect width/height is 0)
104 DECLARE_ABSTRACT_CLASS(wxToolTip
)
105 wxDECLARE_NO_COPY_CLASS(wxToolTip
);
108 #endif // _WX_MSW_TOOLTIP_H_