File: cshelp.h

package info (click to toggle)
wxpython3.0 3.0.2.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 482,760 kB
  • ctags: 518,293
  • sloc: cpp: 2,127,226; python: 294,045; makefile: 51,942; ansic: 19,033; sh: 3,013; xml: 1,629; perl: 17
file content (296 lines) | stat: -rw-r--r-- 9,731 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
/////////////////////////////////////////////////////////////////////////////
// Name:        cshelp.h
// Purpose:     interface of wxHelpProvider
// Author:      wxWidgets team
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

/**
    @class wxHelpProvider

    wxHelpProvider is an abstract class used by a program implementing
    context-sensitive help to show the help text for the given window.

    The current help provider must be explicitly set by the application using
    Set().

    @library{wxcore}
    @category{help}

    @see wxContextHelp, wxContextHelpButton, wxSimpleHelpProvider,
         wxHelpControllerHelpProvider, wxWindow::SetHelpText(),
         wxWindow::GetHelpTextAtPoint()
*/
class wxHelpProvider
{
public:
    /**
        Virtual destructor for any base class.
    */
    virtual ~wxHelpProvider();

    /**
        Associates the text with the given window.

        @remarks
        Although all help providers have these functions to allow making
        wxWindow::SetHelpText() work, not all of them implement the functions.
    */
    virtual void AddHelp(wxWindowBase* window, const wxString& text);

    /**
        Associates the text with the given ID.

        This help text will be shown for all windows with ID @a id, unless they
        have more specific help text associated using the other AddHelp()
        prototype.  May be used to set the same help string for all Cancel
        buttons in the application, for example.

        @remarks
        Although all help providers have these functions to allow making
        wxWindow::SetHelpText() work, not all of them implement the functions.
    */
    virtual void AddHelp(wxWindowID id, const wxString& text);

    /**
        Returns pointer to help provider instance.

        Unlike some other classes, the help provider is not created on demand.
        This must be explicitly done by the application using Set().
    */
    static wxHelpProvider* Get();

    /**
        This version associates the given text with all windows with this id.
        May be used to set the same help string for all Cancel buttons in
        the application, for example.
    */
    virtual wxString GetHelp(const wxWindowBase* window) = 0;

    /**
        Removes the association between the window pointer and the help text.
        This is called by the wxWindow destructor. Without this, the table of
        help strings will fill up and when window pointers are reused, the
        wrong help string will be found.
    */
    virtual void RemoveHelp(wxWindowBase* window);

    /**
        Set the current, application-wide help provider.

        @return Pointer to previous help provider or @NULL if there wasn't any.
    */
    static wxHelpProvider* Set(wxHelpProvider* helpProvider);

    /**
        Shows help for the given window.

        Override this function if the help doesn't depend on the exact position
        inside the window, otherwise you need to override ShowHelpAtPoint().
        Returns @true if help was shown, or @false if no help was available for
        this window.
    */
    virtual bool ShowHelp(wxWindowBase* window);

    /**
        This function may be overridden to show help for the window when it
        should depend on the position inside the window, By default this method
        forwards to ShowHelp(), so it is enough to only implement the latter if
        the help doesn't depend on the position.

        @param window
            Window to show help text for.
        @param point
            Coordinates of the mouse at the moment of help event emission.
        @param origin
            Help event origin, see wxHelpEvent::GetOrigin.

        @return @true if help was shown, or @false if no help was available
                for this window.

        @since 2.7.0
    */
    virtual bool ShowHelpAtPoint(wxWindowBase* window, const wxPoint& point,
                                 wxHelpEvent::Origin origin);
};



/**
    @class wxHelpControllerHelpProvider

    wxHelpControllerHelpProvider is an implementation of wxHelpProvider which
    supports both context identifiers and plain text help strings. If the help
    text is an integer, it is passed to wxHelpController::DisplayContextPopup().
    Otherwise, it shows the string in a tooltip as per wxSimpleHelpProvider. If
    you use this with a wxCHMHelpController instance on windows, it will use
    the native style of tip window instead of wxTipWindow.

    You can use the convenience function wxContextId() to convert an integer
    context id to a string for passing to wxWindow::SetHelpText().

    @library{wxcore}
    @category{help}

    @see wxHelpProvider, wxSimpleHelpProvider, wxContextHelp,
         wxWindow::SetHelpText(), wxWindow::GetHelpTextAtPoint()
*/
class wxHelpControllerHelpProvider : public wxSimpleHelpProvider
{
public:
    /**
        Note that the instance doesn't own the help controller. The help
        controller should be deleted separately.
    */
    wxHelpControllerHelpProvider(wxHelpControllerBase* hc = NULL);

    /**
        Returns the help controller associated with this help provider.
    */
    wxHelpControllerBase* GetHelpController() const;

    /**
        Sets the help controller associated with this help provider.
    */
    void SetHelpController(wxHelpControllerBase* hc);
};



/**
    @class wxContextHelp

    This class changes the cursor to a query and puts the application into a
    'context-sensitive help mode'.  When the user left-clicks on a window
    within the specified window, a @c wxEVT_HELP event is sent to that control,
    and the application may respond to it by popping up some help.

    For example:
    @code
    wxContextHelp contextHelp(myWindow);
    @endcode

    There are a couple of ways to invoke this behaviour implicitly:

    - Use the wxDIALOG_EX_CONTEXTHELP style for a dialog (Windows only). This
      will put a question mark in the titlebar, and Windows will put the
      application into context-sensitive help mode automatically, with further
      programming.

    - Create a wxContextHelpButton, whose predefined behaviour is
      to create a context help object.  Normally you will write your application
      so that this button is only added to a dialog for non-Windows platforms
      (use wxDIALOG_EX_CONTEXTHELP on Windows).

    Note that on Mac OS X, the cursor does not change when in context-sensitive
    help mode.

    @library{wxcore}
    @category{help}

    @see wxHelpEvent, wxHelpController, wxContextHelpButton
*/
class wxContextHelp : public wxObject
{
public:
    /**
        Constructs a context help object, calling BeginContextHelp() if
        @a doNow is @true (the default).

        If @a window is @NULL, the top window is used.
    */
    wxContextHelp(wxWindow* window = NULL, bool doNow = true);

    /**
        Destroys the context help object.
    */
    virtual ~wxContextHelp();

    /**
        Puts the application into context-sensitive help mode. @a window is the
        window which will be used to catch events; if @NULL, the top window
        will be used.

        Returns @true if the application was successfully put into
        context-sensitive help mode.
        This function only returns when the event loop has finished.
    */
    bool BeginContextHelp(wxWindow* window);

    /**
        Ends context-sensitive help mode. Not normally called by the
        application.
    */
    bool EndContextHelp();
};



/**
    @class wxContextHelpButton

    Instances of this class may be used to add a question mark button that when
    pressed, puts the application into context-help mode. It does this by
    creating a wxContextHelp object which itself generates a @c wxEVT_HELP event
    when the user clicks on a window.

    On Windows, you may add a question-mark icon to a dialog by use of the
    wxDIALOG_EX_CONTEXTHELP extra style, but on other platforms you will have
    to add a button explicitly, usually next to OK, Cancel or similar buttons.

    @library{wxcore}
    @category{help}

    @see wxBitmapButton, wxContextHelp
*/
class wxContextHelpButton : public wxBitmapButton
{
public:
    /**
        Constructor, creating and showing a context help button.

        @param parent
            Parent window. Must not be @NULL.
        @param id
            Button identifier. Defaults to wxID_CONTEXT_HELP.
        @param pos
            Button position.
            If ::wxDefaultPosition is specified then a default position is chosen.
        @param size
            Button size. 
            If ::wxDefaultSize is specified then the button is sized appropriately 
            for the question mark bitmap.
        @param style
            Window style.

        @remarks
        Normally you only need pass the parent window to the constructor, and
        use the defaults for the remaining parameters.
    */
    wxContextHelpButton(wxWindow* parent,
                        wxWindowID id = wxID_CONTEXT_HELP,
                        const wxPoint& pos = wxDefaultPosition,
                        const wxSize& size = wxDefaultSize,
                        long style = wxBU_AUTODRAW);
};


/**
    @class wxSimpleHelpProvider

    wxSimpleHelpProvider is an implementation of wxHelpProvider which supports
    only plain text help strings, and shows the string associated with the
    control (if any) in a tooltip.

    @library{wxcore}
    @category{help}

    @see wxHelpProvider, wxHelpControllerHelpProvider, wxContextHelp,
         wxWindow::SetHelpText()(, wxWindow::GetHelpTextAtPoint()
*/
class wxSimpleHelpProvider : public wxHelpProvider
{
public:

};