]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/tooltip.h
Dramatically optimise inserting many items in wxGenericListCtrl.
[wxWidgets.git] / include / wx / msw / tooltip.h
CommitLineData
3a19e16d 1///////////////////////////////////////////////////////////////////////////////
623d5f80 2// Name: wx/msw/tooltip.h
3a19e16d
VZ
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
65571936 9// Licence: wxWindows licence
3a19e16d
VZ
10///////////////////////////////////////////////////////////////////////////////
11
20ceebaa
MW
12#ifndef _WX_MSW_TOOLTIP_H_
13#define _WX_MSW_TOOLTIP_H_
14
4a6b1d28 15#include "wx/object.h"
e1bdb16a 16#include "wx/gdicmn.h"
4a6b1d28 17
b5dbe15d 18class WXDLLIMPEXP_FWD_CORE wxWindow;
0ce0f1e9 19class wxToolTipOtherWindows;
623d5f80 20
53a2db12 21class WXDLLIMPEXP_CORE wxToolTip : public wxObject
3a19e16d
VZ
22{
23public:
24 // ctor & dtor
25 wxToolTip(const wxString &tip);
26 virtual ~wxToolTip();
03647350 27
6418ad5e
FM
28 // ctor used by wxStatusBar to associate a tooltip to a portion of
29 // the status bar window:
03647350 30 wxToolTip(wxWindow* win, unsigned int id,
6418ad5e 31 const wxString &tip, const wxRect& rc);
3a19e16d
VZ
32
33 // accessors
34 // tip text
35 void SetTip(const wxString& tip);
36 const wxString& GetTip() const { return m_text; }
37
38 // the window we're associated with
39 void SetWindow(wxWindow *win);
40 wxWindow *GetWindow() const { return m_window; }
41
16f6dfd8 42 // controlling tooltip behaviour: globally change tooltip parameters
3a19e16d 43 // enable or disable the tooltips globally
16f6dfd8 44 static void Enable(bool flag);
3a19e16d 45 // set the delay after which the tooltip appears
16f6dfd8 46 static void SetDelay(long milliseconds);
be8b4385
VZ
47 // set the delay after which the tooltip disappears or how long the
48 // tooltip remains visible
becac1ef
VZ
49 static void SetAutoPop(long milliseconds);
50 // set the delay between subsequent tooltips to appear
51 static void SetReshow(long milliseconds);
be8b4385
VZ
52 // set maximum width for the new tooltips: -1 disables wrapping
53 // entirely, 0 restores the default behaviour
54 static void SetMaxWidth(int width);
3a19e16d 55
8614c467
VZ
56 // implementation only from now on
57 // -------------------------------
58
6418ad5e 59 // should be called in response to WM_MOUSEMOVE
4453b38d 60 static void RelayEvent(WXMSG *msg);
3a19e16d 61
1306e7d6
VZ
62 // add a window to the tooltip control
63 void Add(WXHWND hwnd);
64
0c5405b7 65 // remove any tooltip from the window
6418ad5e
FM
66 static void Remove(WXHWND hwnd, unsigned int id, const wxRect& rc);
67
0ce0f1e9
VZ
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.
6418ad5e 71 void SetRect(const wxRect& rc);
0c5405b7 72
3a19e16d 73private:
0ce0f1e9
VZ
74 // Adds a window other than our main m_window to this tooltip.
75 void DoAddOtherWindow(WXHWND hWnd);
76
77 // Perform the specified operation for the given window only.
78 void DoSetTip(WXHWND hWnd);
79 void DoRemove(WXHWND hWnd);
80
81 // Call the given function for all windows we're associated with.
82 void DoForAllWindows(void (wxToolTip::*func)(WXHWND));
83
84
8614c467
VZ
85 // the one and only one tooltip control we use - never access it directly
86 // but use GetToolTipCtrl() which will create it when needed
f048e32f
VZ
87 static WXHWND ms_hwndTT;
88
89 // create the tooltip ctrl if it doesn't exist yet and return its HWND
8614c467 90 static WXHWND GetToolTipCtrl();
3a19e16d 91
be8b4385
VZ
92 // new tooltip maximum width, defaults to min(display width, 400)
93 static int ms_maxWidth;
94
3a19e16d
VZ
95 // remove this tooltip from the tooltip control
96 void Remove();
97
98 wxString m_text; // tooltip text
0ce0f1e9
VZ
99 wxWindow* m_window; // main window we're associated with
100 wxToolTipOtherWindows *m_others; // other windows associated with it or NULL
6418ad5e
FM
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)
b342f8f0
RD
104
105 DECLARE_ABSTRACT_CLASS(wxToolTip)
c0c133e1 106 wxDECLARE_NO_COPY_CLASS(wxToolTip);
3a19e16d 107};
d098a357 108
20ceebaa 109#endif // _WX_MSW_TOOLTIP_H_