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
;
19 class wxToolTipOtherWindows
;
21 class WXDLLIMPEXP_CORE wxToolTip
: public wxObject
25 wxToolTip(const wxString
&tip
);
28 // ctor used by wxStatusBar to associate a tooltip to a portion of
29 // the status bar window:
30 wxToolTip(wxWindow
* win
, unsigned int id
,
31 const wxString
&tip
, const wxRect
& rc
);
35 void SetTip(const wxString
& tip
);
36 const wxString
& GetTip() const { return m_text
; }
38 // the window we're associated with
39 void SetWindow(wxWindow
*win
);
40 wxWindow
*GetWindow() const { return m_window
; }
42 // controlling tooltip behaviour: globally change tooltip parameters
43 // enable or disable the tooltips globally
44 static void Enable(bool flag
);
45 // set the delay after which the tooltip appears
46 static void SetDelay(long milliseconds
);
47 // set the delay after which the tooltip disappears or how long the
48 // tooltip remains visible
49 static void SetAutoPop(long milliseconds
);
50 // set the delay between subsequent tooltips to appear
51 static void SetReshow(long milliseconds
);
52 // set maximum width for the new tooltips: -1 disables wrapping
53 // entirely, 0 restores the default behaviour
54 static void SetMaxWidth(int width
);
56 // implementation only from now on
57 // -------------------------------
59 // should be called in response to WM_MOUSEMOVE
60 static void RelayEvent(WXMSG
*msg
);
62 // add a window to the tooltip control
63 void AddOtherWindow(WXHWND hwnd
);
65 // remove any tooltip from the window
66 static void Remove(WXHWND hwnd
, unsigned int id
, const wxRect
& rc
);
68 // Set the rectangle we're associated with. This rectangle is only used for
69 // the main window, not any sub-windows added with Add() so in general it
70 // makes sense to use it for tooltips associated with a single window only.
71 void SetRect(const wxRect
& rc
);
74 // Adds a window other than our main m_window to this tooltip.
75 void DoAddHWND(WXHWND hWnd
);
77 // Perform the specified operation for the given window only.
78 void DoSetTip(WXHWND hWnd
);
79 void DoRemove(WXHWND hWnd
);
81 // Call the given function for all windows we're associated with.
82 void DoForAllWindows(void (wxToolTip::*func
)(WXHWND
));
85 // the one and only one tooltip control we use - never access it directly
86 // but use GetToolTipCtrl() which will create it when needed
87 static WXHWND ms_hwndTT
;
89 // create the tooltip ctrl if it doesn't exist yet and return its HWND
90 static WXHWND
GetToolTipCtrl();
92 // new tooltip maximum width, defaults to min(display width, 400)
93 static int ms_maxWidth
;
95 // remove this tooltip from the tooltip control
98 wxString m_text
; // tooltip text
99 wxWindow
* m_window
; // main window we're associated with
100 wxToolTipOtherWindows
*m_others
; // other windows associated with it or NULL
101 wxRect m_rect
; // the rect of the window for which this tooltip is shown
102 // (or a rect with width/height == 0 to show it for the entire window)
103 unsigned int m_id
; // the id of this tooltip (ignored when m_rect width/height is 0)
105 DECLARE_ABSTRACT_CLASS(wxToolTip
)
106 wxDECLARE_NO_COPY_CLASS(wxToolTip
);
109 #endif // _WX_MSW_TOOLTIP_H_