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