]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/cshelp.h
few details fixed
[wxWidgets.git] / interface / wx / cshelp.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: cshelp.h
e54c96f1 3// Purpose: interface of wxHelpProvider
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxHelpProvider
7c913512 11
23324ae1 12 wxHelpProvider is an abstract class used by a program implementing
d155b6f4 13 context-sensitive help to show the help text for the given window.
7c913512 14
23324ae1 15 The current help provider must be explicitly set by the application using
dc215c81 16 Set().
7c913512 17
23324ae1
FM
18 @library{wxcore}
19 @category{help}
7c913512 20
e54c96f1 21 @see wxContextHelp, wxContextHelpButton, wxSimpleHelpProvider,
d155b6f4
VS
22 wxHelpControllerHelpProvider, wxWindow::SetHelpText(),
23 wxWindow::GetHelpTextAtPoint()
23324ae1 24*/
7c913512 25class wxHelpProvider
23324ae1
FM
26{
27public:
28 /**
29 Virtual destructor for any base class.
30 */
dc215c81 31 virtual ~wxHelpProvider();
23324ae1
FM
32
33 /**
d155b6f4
VS
34 Associates the text with the given window.
35
36 @remarks
37 Although all help providers have these functions to allow making
38 wxWindow::SetHelpText() work, not all of them implement the functions.
23324ae1 39 */
d155b6f4 40 virtual void AddHelp(wxWindowBase* window, const wxString& text);
23324ae1
FM
41
42 /**
d155b6f4
VS
43 Associates the text with the given ID.
44
45 This help text will be shown for all windows with ID @a id, unless they
46 have more specific help text associated using the other AddHelp()
47 prototype. May be used to set the same help string for all Cancel
48 buttons in the application, for example.
49
50 @remarks
51 Although all help providers have these functions to allow making
52 wxWindow::SetHelpText() work, not all of them implement the functions.
53 */
54 virtual void AddHelp(wxWindowID id, const wxString& text);
55
56 /**
57 Returns pointer to help provider instance.
58
23324ae1 59 Unlike some other classes, the help provider is not created on demand.
d155b6f4 60 This must be explicitly done by the application using Set().
23324ae1 61 */
d155b6f4 62 static wxHelpProvider* Get();
23324ae1 63
23324ae1
FM
64 /**
65 This version associates the given text with all windows with this id.
66 May be used to set the same help string for all Cancel buttons in
67 the application, for example.
68 */
d155b6f4
VS
69 virtual wxString GetHelp(const wxWindowBase* window);
70
23324ae1 71 /**
d155b6f4
VS
72 Removes the association between the window pointer and the help text.
73 This is called by the wxWindow destructor. Without this, the table of
74 help strings will fill up and when window pointers are reused, the
75 wrong help string will be found.
23324ae1 76 */
d155b6f4 77 virtual void RemoveHelp(wxWindowBase* window);
23324ae1
FM
78
79 /**
d155b6f4
VS
80 Set the current, application-wide help provider.
81
82 @return Pointer to previous help provider or @NULL if there wasn't any.
23324ae1 83 */
d155b6f4 84 static wxHelpProvider* Set(wxHelpProvider* helpProvider);
23324ae1
FM
85
86 /**
d155b6f4
VS
87 Shows help for the given window.
88
89 Override this function if the help doesn't depend on the exact position
90 inside the window, otherwise you need to override ShowHelpAtPoint().
91 Returns @true if help was shown, or @false if no help was available for
92 this window.
23324ae1 93 */
d155b6f4 94 virtual bool ShowHelp(wxWindowBase* window);
23324ae1
FM
95
96 /**
d155b6f4
VS
97 This function may be overridden to show help for the window when it
98 should depend on the position inside the window, By default this method
99 forwards to ShowHelp(), so it is enough to only implement the latter if
dc215c81 100 the help doesn't depend on the position.
3c4f71cc 101
7c913512 102 @param window
4cc4bfaf 103 Window to show help text for.
7c913512 104 @param point
4cc4bfaf 105 Coordinates of the mouse at the moment of help event emission.
7c913512 106 @param origin
4cc4bfaf 107 Help event origin, see wxHelpEvent::GetOrigin.
dc215c81 108
d29a9a8a
BP
109 @return @true if help was shown, or @false if no help was available
110 for this window.
dc215c81 111
1e24c2af 112 @since 2.7.0
23324ae1 113 */
d155b6f4 114 virtual bool ShowHelpAtPoint(wxWindowBase* window, const wxPoint point,
dc215c81 115 wxHelpEvent::Origin origin);
23324ae1
FM
116};
117
118
e54c96f1 119
23324ae1
FM
120/**
121 @class wxHelpControllerHelpProvider
7c913512 122
23324ae1 123 wxHelpControllerHelpProvider is an implementation of wxHelpProvider which
d155b6f4 124 supports both context identifiers and plain text help strings. If the help
dc215c81 125 text is an integer, it is passed to wxHelpController::DisplayContextPopup().
d155b6f4
VS
126 Otherwise, it shows the string in a tooltip as per wxSimpleHelpProvider. If
127 you use this with a wxCHMHelpController instance on windows, it will use
128 the native style of tip window instead of wxTipWindow.
129
130 You can use the convenience function wxContextId() to convert an integer
131 context id to a string for passing to wxWindow::SetHelpText().
7c913512 132
23324ae1
FM
133 @library{wxcore}
134 @category{help}
7c913512 135
e54c96f1 136 @see wxHelpProvider, wxSimpleHelpProvider, wxContextHelp,
d155b6f4 137 wxWindow::SetHelpText(), wxWindow::GetHelpTextAtPoint()
23324ae1
FM
138*/
139class wxHelpControllerHelpProvider : public wxSimpleHelpProvider
140{
141public:
142 /**
d155b6f4
VS
143 Note that the instance doesn't own the help controller. The help
144 controller should be deleted separately.
23324ae1 145 */
4cc4bfaf 146 wxHelpControllerHelpProvider(wxHelpControllerBase* hc = NULL);
23324ae1
FM
147
148 /**
149 Returns the help controller associated with this help provider.
150 */
328f5751 151 wxHelpControllerBase* GetHelpController() const;
23324ae1
FM
152
153 /**
154 Sets the help controller associated with this help provider.
155 */
156 void SetHelpController(wxHelpControllerBase* hc);
157};
158
159
e54c96f1 160
23324ae1
FM
161/**
162 @class wxContextHelp
7c913512 163
23324ae1 164 This class changes the cursor to a query and puts the application into a
d155b6f4
VS
165 'context-sensitive help mode'. When the user left-clicks on a window
166 within the specified window, a wxEVT_HELP event is sent to that control,
167 and the application may respond to it by popping up some help.
7c913512 168
23324ae1 169 For example:
23324ae1
FM
170 @code
171 wxContextHelp contextHelp(myWindow);
172 @endcode
7c913512 173
23324ae1 174 There are a couple of ways to invoke this behaviour implicitly:
7c913512 175
dd634f27 176 - Use the wxDIALOG_EX_CONTEXTHELP style for a dialog (Windows only). This
d155b6f4
VS
177 will put a question mark in the titlebar, and Windows will put the
178 application into context-sensitive help mode automatically, with further
179 programming.
180
dd634f27 181 - Create a wxContextHelpButton, whose predefined behaviour is
d155b6f4
VS
182 to create a context help object. Normally you will write your application
183 so that this button is only added to a dialog for non-Windows platforms
184 (use wxDIALOG_EX_CONTEXTHELP on Windows).
7c913512 185
23324ae1
FM
186 Note that on Mac OS X, the cursor does not change when in context-sensitive
187 help mode.
7c913512 188
23324ae1
FM
189 @library{wxcore}
190 @category{help}
7c913512 191
e54c96f1 192 @see wxHelpEvent, wxHelpController, wxContextHelpButton
23324ae1
FM
193*/
194class wxContextHelp : public wxObject
195{
196public:
197 /**
198 Constructs a context help object, calling BeginContextHelp() if
4cc4bfaf 199 @a doNow is @true (the default).
dc215c81 200
4cc4bfaf 201 If @a window is @NULL, the top window is used.
23324ae1 202 */
4cc4bfaf 203 wxContextHelp(wxWindow* window = NULL, bool doNow = true);
23324ae1
FM
204
205 /**
206 Destroys the context help object.
207 */
208 ~wxContextHelp();
209
210 /**
d155b6f4
VS
211 Puts the application into context-sensitive help mode. @a window is the
212 window which will be used to catch events; if @NULL, the top window
213 will be used. Returns @true if the application was successfully put
214 into context-sensitive help mode. This function only returns when the
215 event loop has finished.
23324ae1 216 */
4cc4bfaf 217 bool BeginContextHelp(wxWindow* window = NULL);
23324ae1
FM
218
219 /**
d155b6f4
VS
220 Ends context-sensitive help mode. Not normally called by the
221 application.
23324ae1
FM
222 */
223 bool EndContextHelp();
224};
225
226
e54c96f1 227
23324ae1
FM
228/**
229 @class wxContextHelpButton
7c913512 230
23324ae1 231 Instances of this class may be used to add a question mark button that when
d155b6f4
VS
232 pressed, puts the application into context-help mode. It does this by
233 creating a wxContextHelp object which itself generates a wxEVT_HELP event
234 when the user clicks on a window.
7c913512 235
23324ae1 236 On Windows, you may add a question-mark icon to a dialog by use of the
d155b6f4
VS
237 wxDIALOG_EX_CONTEXTHELP extra style, but on other platforms you will have
238 to add a button explicitly, usually next to OK, Cancel or similar buttons.
7c913512 239
23324ae1
FM
240 @library{wxcore}
241 @category{help}
7c913512 242
e54c96f1 243 @see wxBitmapButton, wxContextHelp
23324ae1
FM
244*/
245class wxContextHelpButton : public wxBitmapButton
246{
247public:
d155b6f4
VS
248 /// Default constructor.
249 wxContextHelpButton();
250
23324ae1
FM
251 /**
252 Constructor, creating and showing a context help button.
3c4f71cc 253
7c913512 254 @param parent
4cc4bfaf 255 Parent window. Must not be @NULL.
7c913512 256 @param id
4cc4bfaf 257 Button identifier. Defaults to wxID_CONTEXT_HELP.
7c913512 258 @param pos
4cc4bfaf 259 Button position.
7c913512 260 @param size
dc215c81 261 Button size. If wxDefaultSize is specified then the button is sized
4cc4bfaf 262 appropriately for the question mark bitmap.
7c913512 263 @param style
4cc4bfaf 264 Window style.
dc215c81
BP
265
266 @remarks
267 Normally you only need pass the parent window to the constructor, and
268 use the defaults for the remaining parameters.
23324ae1 269 */
7c913512
FM
270 wxContextHelpButton(wxWindow* parent,
271 wxWindowID id = wxID_CONTEXT_HELP,
272 const wxPoint& pos = wxDefaultPosition,
273 const wxSize& size = wxDefaultSize,
274 long style = wxBU_AUTODRAW);
23324ae1
FM
275};
276
277
278/**
279 @class wxSimpleHelpProvider
7c913512 280
23324ae1
FM
281 wxSimpleHelpProvider is an implementation of wxHelpProvider which supports
282 only plain text help strings, and shows the string associated with the
283 control (if any) in a tooltip.
7c913512 284
23324ae1
FM
285 @library{wxcore}
286 @category{help}
7c913512 287
e54c96f1 288 @see wxHelpProvider, wxHelpControllerHelpProvider, wxContextHelp,
d155b6f4 289 wxWindow::SetHelpText()(, wxWindow::GetHelpTextAtPoint()
23324ae1
FM
290*/
291class wxSimpleHelpProvider : public wxHelpProvider
292{
293public:
7c913512 294
23324ae1 295};
e54c96f1 296