1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxHelpProvider class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 wxHelpProvider is an abstract class used by a program implementing
14 context-sensitive help to
15 show the help text for the given window.
17 The current help provider must be explicitly set by the application using
18 wxHelpProvider::Set().
24 wxContextHelp, wxContextHelpButton, wxSimpleHelpProvider,
25 wxHelpControllerHelpProvider, wxWindow::SetHelpText, wxWindow::GetHelpTextAtPoint
31 Virtual destructor for any base class.
36 Associates the text with the given window or id. Although all help
37 providers have these functions to allow making wxWindow::SetHelpText
38 work, not all of them implement the functions.
40 void AddHelp(wxWindowBase
* window
, const wxString
& text
);
43 Unlike some other classes, the help provider is not created on demand.
44 This must be explicitly done by the application.
46 #define wxHelpProvider* Get() /* implementation is private */
50 This version associates the given text with all windows with this id.
51 May be used to set the same help string for all Cancel buttons in
52 the application, for example.
54 wxString
GetHelp(const wxWindowBase
* window
);
55 void AddHelp(wxWindowID id
, const wxString
& text
);
59 Removes the association between the window pointer and the help text. This is
60 called by the wxWindow destructor. Without this, the table of help strings will
62 and when window pointers are reused, the wrong help string will be found.
64 void RemoveHelp(wxWindowBase
* window
);
67 Get/set the current, application-wide help provider. Returns
70 #define wxHelpProvider* Set(wxHelpProvider* helpProvider) /* implementation is private */
73 Shows help for the given window. Override this function if the help doesn't
74 depend on the exact position inside the window, otherwise you need to override
77 Returns @true if help was shown, or @false if no help was available for this
80 bool ShowHelp(wxWindowBase
* window
);
83 This function may be overridden to show help for the window when it should
84 depend on the position inside the window, By default this method forwards to
85 ShowHelp(), so it is enough to only implement
86 the latter if the help doesn't depend on the position.
88 Returns @true if help was shown, or @false if no help was available for this
92 Window to show help text for.
95 Coordinates of the mouse at the moment of help event emission.
98 Help event origin, see wxHelpEvent::GetOrigin.
100 bool ShowHelpAtPoint(wxWindowBase
* window
, const wxPoint point
,
101 wxHelpEvent::Origin origin
);
106 @class wxHelpControllerHelpProvider
109 wxHelpControllerHelpProvider is an implementation of wxHelpProvider which
111 both context identifiers and plain text help strings. If the help text is an
113 it is passed to wxHelpController::DisplayContextPopup. Otherwise, it shows the
115 in a tooltip as per wxSimpleHelpProvider. If you use this with a
116 wxCHMHelpController instance
117 on windows, it will use the native style of tip window instead of wxTipWindow.
119 You can use the convenience function @b wxContextId to convert an integer
121 id to a string for passing to wxWindow::SetHelpText.
127 wxHelpProvider, wxSimpleHelpProvider, wxContextHelp, wxWindow::SetHelpText,
128 wxWindow::GetHelpTextAtPoint
130 class wxHelpControllerHelpProvider
: public wxSimpleHelpProvider
134 Note that the instance doesn't own the help controller. The help controller
135 should be deleted separately.
137 wxHelpControllerHelpProvider(wxHelpControllerBase
* hc
= @NULL
);
140 Returns the help controller associated with this help provider.
142 wxHelpControllerBase
* GetHelpController();
145 Sets the help controller associated with this help provider.
147 void SetHelpController(wxHelpControllerBase
* hc
);
155 This class changes the cursor to a query and puts the application into a
156 'context-sensitive help mode'.
157 When the user left-clicks on a window within the specified window, a wxEVT_HELP
159 sent to that control, and the application may respond to it by popping up some
165 wxContextHelp contextHelp(myWindow);
168 There are a couple of ways to invoke this behaviour implicitly:
170 Use the wxDIALOG_EX_CONTEXTHELP style for a dialog (Windows only). This will
172 in the titlebar, and Windows will put the application into context-sensitive
173 help mode automatically,
174 with further programming.
175 Create a wxContextHelpButton, whose predefined behaviour is to create a
177 Normally you will write your application so that this button is only added to a
178 dialog for non-Windows platforms
179 (use wxDIALOG_EX_CONTEXTHELP on Windows).
181 Note that on Mac OS X, the cursor does not change when in context-sensitive
188 wxHelpEvent, wxHelpController, wxContextHelpButton
190 class wxContextHelp
: public wxObject
194 Constructs a context help object, calling BeginContextHelp() if
195 @e doNow is @true (the default).
197 If @e window is @NULL, the top window is used.
199 wxContextHelp(wxWindow
* window
= @NULL
, bool doNow
= @
true);
202 Destroys the context help object.
207 Puts the application into context-sensitive help mode. @e window is the window
208 which will be used to catch events; if @NULL, the top window will be used.
210 Returns @true if the application was successfully put into context-sensitive
212 This function only returns when the event loop has finished.
214 bool BeginContextHelp(wxWindow
* window
= @NULL
);
217 Ends context-sensitive help mode. Not normally called by the application.
219 bool EndContextHelp();
224 @class wxContextHelpButton
227 Instances of this class may be used to add a question mark button that when
229 application into context-help mode. It does this by creating a wxContextHelp
231 generates a wxEVT_HELP event when the user clicks on a window.
233 On Windows, you may add a question-mark icon to a dialog by use of the
234 wxDIALOG_EX_CONTEXTHELP extra style, but
235 on other platforms you will have to add a button explicitly, usually next to
236 OK, Cancel or similar buttons.
242 wxBitmapButton, wxContextHelp
244 class wxContextHelpButton
: public wxBitmapButton
249 Constructor, creating and showing a context help button.
252 Parent window. Must not be @NULL.
255 Button identifier. Defaults to wxID_CONTEXT_HELP.
261 Button size. If wxDefaultSize is specified then the button is sized
262 appropriately for the question mark bitmap.
267 wxContextHelpButton();
268 wxContextHelpButton(wxWindow
* parent
,
269 wxWindowID id
= wxID_CONTEXT_HELP
,
270 const wxPoint
& pos
= wxDefaultPosition
,
271 const wxSize
& size
= wxDefaultSize
,
272 long style
= wxBU_AUTODRAW
);
278 @class wxSimpleHelpProvider
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.
289 wxHelpProvider, wxHelpControllerHelpProvider, wxContextHelp,
290 wxWindow::SetHelpText, wxWindow::GetHelpTextAtPoint
292 class wxSimpleHelpProvider
: public wxHelpProvider