]> git.saurik.com Git - wxWidgets.git/blame - interface/cshelp.h
Send build notification to wx-buildbot mailing list.
[wxWidgets.git] / interface / 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
11 @wxheader{cshelp.h}
7c913512 12
23324ae1
FM
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.
7c913512 16
23324ae1
FM
17 The current help provider must be explicitly set by the application using
18 wxHelpProvider::Set().
7c913512 19
23324ae1
FM
20 @library{wxcore}
21 @category{help}
7c913512 22
e54c96f1 23 @see wxContextHelp, wxContextHelpButton, wxSimpleHelpProvider,
23324ae1
FM
24 wxHelpControllerHelpProvider, wxWindow::SetHelpText, wxWindow::GetHelpTextAtPoint
25*/
7c913512 26class wxHelpProvider
23324ae1
FM
27{
28public:
29 /**
30 Virtual destructor for any base class.
31 */
32 ~wxHelpProvider();
33
34 /**
35 Associates the text with the given window or id. Although all help
7c913512 36 providers have these functions to allow making wxWindow::SetHelpText
23324ae1
FM
37 work, not all of them implement the functions.
38 */
39 void AddHelp(wxWindowBase* window, const wxString& text);
40
41 /**
42 Unlike some other classes, the help provider is not created on demand.
43 This must be explicitly done by the application.
44 */
4cc4bfaf 45 wxHelpProvider* Get();
23324ae1
FM
46
47 //@{
48 /**
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.
52 */
53 wxString GetHelp(const wxWindowBase* window);
7c913512 54 void AddHelp(wxWindowID id, const wxString& text);
23324ae1
FM
55 //@}
56
57 /**
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
60 fill up
61 and when window pointers are reused, the wrong help string will be found.
62 */
63 void RemoveHelp(wxWindowBase* window);
64
65 /**
66 Get/set the current, application-wide help provider. Returns
67 the previous one.
68 */
4cc4bfaf 69 wxHelpProvider* Set(wxHelpProvider* helpProvider);
23324ae1
FM
70
71 /**
72 Shows help for the given window. Override this function if the help doesn't
7c913512 73 depend on the exact position inside the window, otherwise you need to override
23324ae1 74 ShowHelpAtPoint().
23324ae1
FM
75 Returns @true if help was shown, or @false if no help was available for this
76 window.
77 */
78 bool ShowHelp(wxWindowBase* window);
79
80 /**
81 This function may be overridden to show help for the window when it should
7c913512 82 depend on the position inside the window, By default this method forwards to
23324ae1
FM
83 ShowHelp(), so it is enough to only implement
84 the latter if the help doesn't depend on the position.
23324ae1
FM
85 Returns @true if help was shown, or @false if no help was available for this
86 window.
3c4f71cc 87
7c913512 88 @param window
4cc4bfaf 89 Window to show help text for.
7c913512 90 @param point
4cc4bfaf 91 Coordinates of the mouse at the moment of help event emission.
7c913512 92 @param origin
4cc4bfaf 93 Help event origin, see wxHelpEvent::GetOrigin.
23324ae1
FM
94 */
95 bool ShowHelpAtPoint(wxWindowBase* window, const wxPoint point,
96 wxHelpEvent::Origin origin);
97};
98
99
e54c96f1 100
23324ae1
FM
101/**
102 @class wxHelpControllerHelpProvider
103 @wxheader{cshelp.h}
7c913512 104
23324ae1
FM
105 wxHelpControllerHelpProvider is an implementation of wxHelpProvider which
106 supports
107 both context identifiers and plain text help strings. If the help text is an
108 integer,
109 it is passed to wxHelpController::DisplayContextPopup. Otherwise, it shows the
110 string
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.
7c913512 114
23324ae1
FM
115 You can use the convenience function @b wxContextId to convert an integer
116 context
117 id to a string for passing to wxWindow::SetHelpText.
7c913512 118
23324ae1
FM
119 @library{wxcore}
120 @category{help}
7c913512 121
e54c96f1
FM
122 @see wxHelpProvider, wxSimpleHelpProvider, wxContextHelp,
123 wxWindow::SetHelpText, wxWindow::GetHelpTextAtPoint
23324ae1
FM
124*/
125class wxHelpControllerHelpProvider : public wxSimpleHelpProvider
126{
127public:
128 /**
129 Note that the instance doesn't own the help controller. The help controller
130 should be deleted separately.
131 */
4cc4bfaf 132 wxHelpControllerHelpProvider(wxHelpControllerBase* hc = NULL);
23324ae1
FM
133
134 /**
135 Returns the help controller associated with this help provider.
136 */
328f5751 137 wxHelpControllerBase* GetHelpController() const;
23324ae1
FM
138
139 /**
140 Sets the help controller associated with this help provider.
141 */
142 void SetHelpController(wxHelpControllerBase* hc);
143};
144
145
e54c96f1 146
23324ae1
FM
147/**
148 @class wxContextHelp
149 @wxheader{cshelp.h}
7c913512 150
23324ae1
FM
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
154 event is
155 sent to that control, and the application may respond to it by popping up some
156 help.
7c913512 157
23324ae1 158 For example:
7c913512 159
23324ae1
FM
160 @code
161 wxContextHelp contextHelp(myWindow);
162 @endcode
7c913512 163
23324ae1 164 There are a couple of ways to invoke this behaviour implicitly:
7c913512 165
23324ae1
FM
166 Use the wxDIALOG_EX_CONTEXTHELP style for a dialog (Windows only). This will
167 put a question mark
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
172 context help object.
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).
7c913512 176
23324ae1
FM
177 Note that on Mac OS X, the cursor does not change when in context-sensitive
178 help mode.
7c913512 179
23324ae1
FM
180 @library{wxcore}
181 @category{help}
7c913512 182
e54c96f1 183 @see wxHelpEvent, wxHelpController, wxContextHelpButton
23324ae1
FM
184*/
185class wxContextHelp : public wxObject
186{
187public:
188 /**
189 Constructs a context help object, calling BeginContextHelp() if
4cc4bfaf
FM
190 @a doNow is @true (the default).
191 If @a window is @NULL, the top window is used.
23324ae1 192 */
4cc4bfaf 193 wxContextHelp(wxWindow* window = NULL, bool doNow = true);
23324ae1
FM
194
195 /**
196 Destroys the context help object.
197 */
198 ~wxContextHelp();
199
200 /**
4cc4bfaf 201 Puts the application into context-sensitive help mode. @a window is the window
23324ae1 202 which will be used to catch events; if @NULL, the top window will be used.
23324ae1
FM
203 Returns @true if the application was successfully put into context-sensitive
204 help mode.
205 This function only returns when the event loop has finished.
206 */
4cc4bfaf 207 bool BeginContextHelp(wxWindow* window = NULL);
23324ae1
FM
208
209 /**
210 Ends context-sensitive help mode. Not normally called by the application.
211 */
212 bool EndContextHelp();
213};
214
215
e54c96f1 216
23324ae1
FM
217/**
218 @class wxContextHelpButton
219 @wxheader{cshelp.h}
7c913512 220
23324ae1
FM
221 Instances of this class may be used to add a question mark button that when
222 pressed, puts the
223 application into context-help mode. It does this by creating a wxContextHelp
224 object which itself
225 generates a wxEVT_HELP event when the user clicks on a window.
7c913512 226
23324ae1
FM
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.
7c913512 231
23324ae1
FM
232 @library{wxcore}
233 @category{help}
7c913512 234
e54c96f1 235 @see wxBitmapButton, wxContextHelp
23324ae1
FM
236*/
237class wxContextHelpButton : public wxBitmapButton
238{
239public:
240 //@{
241 /**
242 Constructor, creating and showing a context help button.
3c4f71cc 243
7c913512 244 @param parent
4cc4bfaf 245 Parent window. Must not be @NULL.
7c913512 246 @param id
4cc4bfaf 247 Button identifier. Defaults to wxID_CONTEXT_HELP.
7c913512 248 @param pos
4cc4bfaf 249 Button position.
7c913512 250 @param size
4cc4bfaf
FM
251 Button size. If wxDefaultSize is specified then the button is
252 sized
253 appropriately for the question mark bitmap.
7c913512 254 @param style
4cc4bfaf 255 Window style.
23324ae1
FM
256 */
257 wxContextHelpButton();
7c913512
FM
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);
23324ae1
FM
263 //@}
264};
265
266
e54c96f1 267
23324ae1
FM
268/**
269 @class wxSimpleHelpProvider
270 @wxheader{cshelp.h}
7c913512 271
23324ae1
FM
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.
7c913512 275
23324ae1
FM
276 @library{wxcore}
277 @category{help}
7c913512 278
e54c96f1 279 @see wxHelpProvider, wxHelpControllerHelpProvider, wxContextHelp,
23324ae1
FM
280 wxWindow::SetHelpText, wxWindow::GetHelpTextAtPoint
281*/
282class wxSimpleHelpProvider : public wxHelpProvider
283{
284public:
7c913512 285
23324ae1 286};
e54c96f1 287