2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: cshelp.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxHelpProvider
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxHelpProvider
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
wxHelpProvider is an abstract class used by a program implementing
|
2008-03-22 10:57:53 -04:00
|
|
|
context-sensitive help to show the help text for the given window.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
The current help provider must be explicitly set by the application using
|
2008-04-14 01:36:08 -04:00
|
|
|
Set().
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{help}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxContextHelp, wxContextHelpButton, wxSimpleHelpProvider,
|
2008-03-22 10:57:53 -04:00
|
|
|
wxHelpControllerHelpProvider, wxWindow::SetHelpText(),
|
|
|
|
wxWindow::GetHelpTextAtPoint()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
class wxHelpProvider
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Virtual destructor for any base class.
|
|
|
|
*/
|
2008-04-14 01:36:08 -04:00
|
|
|
virtual ~wxHelpProvider();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-22 10:57:53 -04:00
|
|
|
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.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2016-05-04 16:45:56 -04:00
|
|
|
virtual void AddHelp(wxWindow* window, const wxString& text);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-22 10:57:53 -04:00
|
|
|
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.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Unlike some other classes, the help provider is not created on demand.
|
2008-03-22 10:57:53 -04:00
|
|
|
This must be explicitly done by the application using Set().
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-22 10:57:53 -04:00
|
|
|
static wxHelpProvider* Get();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
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.
|
|
|
|
*/
|
2016-05-04 16:45:56 -04:00
|
|
|
virtual wxString GetHelp(const wxWindow* window) = 0;
|
2008-03-22 10:57:53 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-03-22 10:57:53 -04:00
|
|
|
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.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2016-05-04 16:45:56 -04:00
|
|
|
virtual void RemoveHelp(wxWindow* window);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-22 10:57:53 -04:00
|
|
|
Set the current, application-wide help provider.
|
|
|
|
|
|
|
|
@return Pointer to previous help provider or @NULL if there wasn't any.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-22 10:57:53 -04:00
|
|
|
static wxHelpProvider* Set(wxHelpProvider* helpProvider);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-22 10:57:53 -04:00
|
|
|
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.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2016-05-04 16:45:56 -04:00
|
|
|
virtual bool ShowHelp(wxWindow* window);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-22 10:57:53 -04:00
|
|
|
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
|
2008-04-14 01:36:08 -04:00
|
|
|
the help doesn't depend on the position.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param window
|
2008-03-09 08:33:59 -04:00
|
|
|
Window to show help text for.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param point
|
2008-03-09 08:33:59 -04:00
|
|
|
Coordinates of the mouse at the moment of help event emission.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param origin
|
2008-03-09 08:33:59 -04:00
|
|
|
Help event origin, see wxHelpEvent::GetOrigin.
|
2008-04-14 01:36:08 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if help was shown, or @false if no help was available
|
|
|
|
for this window.
|
2008-04-14 01:36:08 -04:00
|
|
|
|
2008-04-21 06:34:23 -04:00
|
|
|
@since 2.7.0
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2016-05-04 16:45:56 -04:00
|
|
|
virtual bool ShowHelpAtPoint(wxWindow* window, const wxPoint& point,
|
2008-09-24 19:29:43 -04:00
|
|
|
wxHelpEvent::Origin origin);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxHelpControllerHelpProvider
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
wxHelpControllerHelpProvider is an implementation of wxHelpProvider which
|
2008-03-22 10:57:53 -04:00
|
|
|
supports both context identifiers and plain text help strings. If the help
|
2008-04-14 01:36:08 -04:00
|
|
|
text is an integer, it is passed to wxHelpController::DisplayContextPopup().
|
2008-03-22 10:57:53 -04:00
|
|
|
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().
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{help}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxHelpProvider, wxSimpleHelpProvider, wxContextHelp,
|
2008-03-22 10:57:53 -04:00
|
|
|
wxWindow::SetHelpText(), wxWindow::GetHelpTextAtPoint()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxHelpControllerHelpProvider : public wxSimpleHelpProvider
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-03-22 10:57:53 -04:00
|
|
|
Note that the instance doesn't own the help controller. The help
|
|
|
|
controller should be deleted separately.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxHelpControllerHelpProvider(wxHelpControllerBase* hc = NULL);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the help controller associated with this help provider.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxHelpControllerBase* GetHelpController() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the help controller associated with this help provider.
|
|
|
|
*/
|
|
|
|
void SetHelpController(wxHelpControllerBase* hc);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxContextHelp
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class changes the cursor to a query and puts the application into a
|
2008-03-22 10:57:53 -04:00
|
|
|
'context-sensitive help mode'. When the user left-clicks on a window
|
2011-01-06 14:52:14 -05:00
|
|
|
within the specified window, a @c wxEVT_HELP event is sent to that control,
|
2008-03-22 10:57:53 -04:00
|
|
|
and the application may respond to it by popping up some help.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
For example:
|
|
|
|
@code
|
|
|
|
wxContextHelp contextHelp(myWindow);
|
|
|
|
@endcode
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
There are a couple of ways to invoke this behaviour implicitly:
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-22 15:09:09 -04:00
|
|
|
- Use the wxDIALOG_EX_CONTEXTHELP style for a dialog (Windows only). This
|
2008-03-22 10:57:53 -04:00
|
|
|
will put a question mark in the titlebar, and Windows will put the
|
|
|
|
application into context-sensitive help mode automatically, with further
|
|
|
|
programming.
|
|
|
|
|
2008-03-22 15:09:09 -04:00
|
|
|
- Create a wxContextHelpButton, whose predefined behaviour is
|
2008-03-22 10:57:53 -04:00
|
|
|
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).
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2016-02-23 07:05:44 -05:00
|
|
|
Note that on OS X, the cursor does not change when in context-sensitive
|
2008-03-08 08:52:38 -05:00
|
|
|
help mode.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{help}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxHelpEvent, wxHelpController, wxContextHelpButton
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxContextHelp : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructs a context help object, calling BeginContextHelp() if
|
2008-03-09 08:33:59 -04:00
|
|
|
@a doNow is @true (the default).
|
2008-04-14 01:36:08 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
If @a window is @NULL, the top window is used.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxContextHelp(wxWindow* window = NULL, bool doNow = true);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destroys the context help object.
|
|
|
|
*/
|
2008-09-22 15:01:17 -04:00
|
|
|
virtual ~wxContextHelp();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-22 10:57:53 -04:00
|
|
|
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
|
2008-09-24 19:29:43 -04:00
|
|
|
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.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-24 19:29:43 -04:00
|
|
|
bool BeginContextHelp(wxWindow* window);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-22 10:57:53 -04:00
|
|
|
Ends context-sensitive help mode. Not normally called by the
|
|
|
|
application.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool EndContextHelp();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxContextHelpButton
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Instances of this class may be used to add a question mark button that when
|
2008-03-22 10:57:53 -04:00
|
|
|
pressed, puts the application into context-help mode. It does this by
|
2011-01-06 14:52:14 -05:00
|
|
|
creating a wxContextHelp object which itself generates a @c wxEVT_HELP event
|
2008-03-22 10:57:53 -04:00
|
|
|
when the user clicks on a window.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
On Windows, you may add a question-mark icon to a dialog by use of the
|
2008-03-22 10:57:53 -04:00
|
|
|
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.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{help}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxBitmapButton, wxContextHelp
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxContextHelpButton : public wxBitmapButton
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor, creating and showing a context help button.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
Parent window. Must not be @NULL.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param id
|
2008-03-09 08:33:59 -04:00
|
|
|
Button identifier. Defaults to wxID_CONTEXT_HELP.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
Button position.
|
2009-04-21 07:21:36 -04:00
|
|
|
If ::wxDefaultPosition is specified then a default position is chosen.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param size
|
2019-01-30 11:28:08 -05:00
|
|
|
Button size.
|
|
|
|
If ::wxDefaultSize is specified then the button is sized appropriately
|
2009-04-21 07:21:36 -04:00
|
|
|
for the question mark bitmap.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
Window style.
|
2008-04-14 01:36:08 -04:00
|
|
|
|
|
|
|
@remarks
|
|
|
|
Normally you only need pass the parent window to the constructor, and
|
|
|
|
use the defaults for the remaining parameters.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxContextHelpButton(wxWindow* parent,
|
|
|
|
wxWindowID id = wxID_CONTEXT_HELP,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2018-07-21 08:42:06 -04:00
|
|
|
long style = 0);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxSimpleHelpProvider
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
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.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{help}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxHelpProvider, wxHelpControllerHelpProvider, wxContextHelp,
|
2008-03-22 10:57:53 -04:00
|
|
|
wxWindow::SetHelpText()(, wxWindow::GetHelpTextAtPoint()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxSimpleHelpProvider : public wxHelpProvider
|
|
|
|
{
|
|
|
|
public:
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|