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