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