1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxHelpProvider
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().
23 @see wxContextHelp, wxContextHelpButton, wxSimpleHelpProvider,
24 wxHelpControllerHelpProvider, wxWindow::SetHelpText, wxWindow::GetHelpTextAtPoint
30 Virtual destructor for any base class.
35 Associates the text with the given window or id. Although all help
36 providers have these functions to allow making wxWindow::SetHelpText
37 work, not all of them implement the functions.
39 void AddHelp(wxWindowBase
* window
, const wxString
& text
);
42 Unlike some other classes, the help provider is not created on demand.
43 This must be explicitly done by the application.
45 wxHelpProvider
* Get();
49 This version associates the given text with all windows with this id.
50 May be used to set the same help string for all Cancel buttons in
51 the application, for example.
53 wxString
GetHelp(const wxWindowBase
* window
);
54 void AddHelp(wxWindowID id
, const wxString
& text
);
58 Removes the association between the window pointer and the help text. This is
59 called by the wxWindow destructor. Without this, the table of help strings will
61 and when window pointers are reused, the wrong help string will be found.
63 void RemoveHelp(wxWindowBase
* window
);
66 Get/set the current, application-wide help provider. Returns
69 wxHelpProvider
* Set(wxHelpProvider
* helpProvider
);
72 Shows help for the given window. Override this function if the help doesn't
73 depend on the exact position inside the window, otherwise you need to override
75 Returns @true if help was shown, or @false if no help was available for this
78 bool ShowHelp(wxWindowBase
* window
);
81 This function may be overridden to show help for the window when it should
82 depend on the position inside the window, By default this method forwards to
83 ShowHelp(), so it is enough to only implement
84 the latter if the help doesn't depend on the position.
85 Returns @true if help was shown, or @false if no help was available for this
89 Window to show help text for.
91 Coordinates of the mouse at the moment of help event emission.
93 Help event origin, see wxHelpEvent::GetOrigin.
95 bool ShowHelpAtPoint(wxWindowBase
* window
, const wxPoint point
,
96 wxHelpEvent::Origin origin
);
102 @class wxHelpControllerHelpProvider
105 wxHelpControllerHelpProvider is an implementation of wxHelpProvider which
107 both context identifiers and plain text help strings. If the help text is an
109 it is passed to wxHelpController::DisplayContextPopup. Otherwise, it shows the
111 in a tooltip as per wxSimpleHelpProvider. If you use this with a
112 wxCHMHelpController instance
113 on windows, it will use the native style of tip window instead of wxTipWindow.
115 You can use the convenience function @b wxContextId to convert an integer
117 id to a string for passing to wxWindow::SetHelpText.
122 @see wxHelpProvider, wxSimpleHelpProvider, wxContextHelp,
123 wxWindow::SetHelpText, wxWindow::GetHelpTextAtPoint
125 class wxHelpControllerHelpProvider
: public wxSimpleHelpProvider
129 Note that the instance doesn't own the help controller. The help controller
130 should be deleted separately.
132 wxHelpControllerHelpProvider(wxHelpControllerBase
* hc
= NULL
);
135 Returns the help controller associated with this help provider.
137 wxHelpControllerBase
* GetHelpController() const;
140 Sets the help controller associated with this help provider.
142 void SetHelpController(wxHelpControllerBase
* hc
);
151 This class changes the cursor to a query and puts the application into a
152 'context-sensitive help mode'.
153 When the user left-clicks on a window within the specified window, a wxEVT_HELP
155 sent to that control, and the application may respond to it by popping up some
161 wxContextHelp contextHelp(myWindow);
164 There are a couple of ways to invoke this behaviour implicitly:
166 Use the wxDIALOG_EX_CONTEXTHELP style for a dialog (Windows only). This will
168 in the titlebar, and Windows will put the application into context-sensitive
169 help mode automatically,
170 with further programming.
171 Create a wxContextHelpButton, whose predefined behaviour is to create a
173 Normally you will write your application so that this button is only added to a
174 dialog for non-Windows platforms
175 (use wxDIALOG_EX_CONTEXTHELP on Windows).
177 Note that on Mac OS X, the cursor does not change when in context-sensitive
183 @see wxHelpEvent, wxHelpController, wxContextHelpButton
185 class wxContextHelp
: public wxObject
189 Constructs a context help object, calling BeginContextHelp() if
190 @a doNow is @true (the default).
191 If @a window is @NULL, the top window is used.
193 wxContextHelp(wxWindow
* window
= NULL
, bool doNow
= true);
196 Destroys the context help object.
201 Puts the application into context-sensitive help mode. @a window is the window
202 which will be used to catch events; if @NULL, the top window will be used.
203 Returns @true if the application was successfully put into context-sensitive
205 This function only returns when the event loop has finished.
207 bool BeginContextHelp(wxWindow
* window
= NULL
);
210 Ends context-sensitive help mode. Not normally called by the application.
212 bool EndContextHelp();
218 @class wxContextHelpButton
221 Instances of this class may be used to add a question mark button that when
223 application into context-help mode. It does this by creating a wxContextHelp
225 generates a wxEVT_HELP event when the user clicks on a window.
227 On Windows, you may add a question-mark icon to a dialog by use of the
228 wxDIALOG_EX_CONTEXTHELP extra style, but
229 on other platforms you will have to add a button explicitly, usually next to
230 OK, Cancel or similar buttons.
235 @see wxBitmapButton, wxContextHelp
237 class wxContextHelpButton
: public wxBitmapButton
242 Constructor, creating and showing a context help button.
245 Parent window. Must not be @NULL.
247 Button identifier. Defaults to wxID_CONTEXT_HELP.
251 Button size. If wxDefaultSize is specified then the button is
253 appropriately for the question mark bitmap.
257 wxContextHelpButton();
258 wxContextHelpButton(wxWindow
* parent
,
259 wxWindowID id
= wxID_CONTEXT_HELP
,
260 const wxPoint
& pos
= wxDefaultPosition
,
261 const wxSize
& size
= wxDefaultSize
,
262 long style
= wxBU_AUTODRAW
);
269 @class wxSimpleHelpProvider
272 wxSimpleHelpProvider is an implementation of wxHelpProvider which supports
273 only plain text help strings, and shows the string associated with the
274 control (if any) in a tooltip.
279 @see wxHelpProvider, wxHelpControllerHelpProvider, wxContextHelp,
280 wxWindow::SetHelpText, wxWindow::GetHelpTextAtPoint
282 class wxSimpleHelpProvider
: public wxHelpProvider