]> git.saurik.com Git - wxWidgets.git/blame - include/wx/cshelp.h
added wxRTTI macros to wxPopupComboWindow and wxPopupTransientWindow
[wxWidgets.git] / include / wx / cshelp.h
CommitLineData
fb6261e9 1/////////////////////////////////////////////////////////////////////////////
bd83cb56
VZ
2// Name: wx/cshelp.h
3// Purpose: Context-sensitive help support classes
4// Author: Julian Smart, Vadim Zeitlin
fb6261e9
JS
5// Modified by:
6// Created: 08/09/2000
7// RCS-ID: $Id$
bd83cb56 8// Copyright: (c) 2000 Julian Smart, Vadim Zeitlin
fb6261e9
JS
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_CSHELPH__
13#define _WX_CSHELPH__
14
15#ifdef __GNUG__
bd83cb56 16 #pragma interface "cshelp.h"
fb6261e9
JS
17#endif
18
19#include "wx/defs.h"
20
21#if wxUSE_HELP
22
56029a74 23#include "wx/help.h"
fb6261e9
JS
24#include "wx/bmpbuttn.h"
25
bd83cb56
VZ
26// ----------------------------------------------------------------------------
27// classes used to implement context help UI
28// ----------------------------------------------------------------------------
29
fb6261e9
JS
30/*
31 * wxContextHelp
32 * Invokes context-sensitive help. When the user
33 * clicks on a window, a wxEVT_HELP event will be sent to that
34 * window for the application to display help for.
35 */
36
bd83cb56 37class WXDLLEXPORT wxContextHelp : public wxObject
fb6261e9 38{
fb6261e9
JS
39public:
40 wxContextHelp(wxWindow* win = NULL, bool beginHelp = TRUE);
bd83cb56 41 virtual ~wxContextHelp();
fb6261e9
JS
42
43 bool BeginContextHelp(wxWindow* win);
44 bool EndContextHelp();
45
46 bool EventLoop();
47 bool DispatchEvent(wxWindow* win, const wxPoint& pt);
48
49 void SetStatus(bool status) { m_status = status; }
50
51protected:
fb6261e9
JS
52 bool m_inHelp;
53 bool m_status; // TRUE if the user left-clicked
bd83cb56
VZ
54
55private:
56 DECLARE_DYNAMIC_CLASS(wxContextHelp)
fb6261e9
JS
57};
58
59/*
60 * wxContextHelpButton
61 * You can add this to your dialogs (especially on non-Windows platforms)
62 * to put the application into context help mode.
63 */
64
bd83cb56 65class WXDLLEXPORT wxContextHelpButton : public wxBitmapButton
fb6261e9
JS
66{
67public:
bd83cb56
VZ
68 wxContextHelpButton(wxWindow* parent,
69 wxWindowID id = wxID_CONTEXT_HELP,
70 const wxPoint& pos = wxDefaultPosition,
71 const wxSize& size = wxDefaultSize,
72 long style = wxBU_AUTODRAW);
fb6261e9
JS
73
74 void OnContextHelp(wxCommandEvent& event);
75
bd83cb56 76private:
fb6261e9
JS
77 DECLARE_CLASS(wxContextHelpButton)
78 DECLARE_EVENT_TABLE()
79};
80
bd83cb56
VZ
81// ----------------------------------------------------------------------------
82// classes used to implement context help support
83// ----------------------------------------------------------------------------
84
5100cabf 85// wxHelpProvider is an abstract class used by the program implementing context help to
bd83cb56
VZ
86// show the help text (or whatever: it may be HTML page or anything else) for
87// the given window.
88//
89// The current help provider must be explicitly set by the application using
90// wxHelpProvider::Set().
91class WXDLLEXPORT wxHelpProvider
92{
93public:
94 // get/set the current (application-global) help provider (Set() returns
95 // the previous one)
96 static wxHelpProvider *Set(wxHelpProvider *helpProvider)
97 {
98 wxHelpProvider *helpProviderOld = ms_helpProvider;
99 ms_helpProvider = helpProvider;
100 return helpProviderOld;
101 }
102
103 // unlike some other class, the help provider is not created on demand,
104 // this must be explicitly done by the application
105 static wxHelpProvider *Get() { return ms_helpProvider; }
106
107 // get the help string (whose interpretation is help provider dependent
108 // except that empty string always means that no help is associated with
109 // the window) for this window
110 virtual wxString GetHelp(const wxWindowBase *window) = 0;
111
112 // do show help for the given window (uses GetHelp() internally if
113 // applicable), return TRUE if it was done or FALSE if no help available
114 // for this window
115 virtual bool ShowHelp(wxWindowBase *window) = 0;
116
117 // associate the text with the given window or id: although all help
118 // providers have these functions to allow making wxWindow::SetHelpText()
119 // work, not all of them implement them
120 virtual void AddHelp(wxWindowBase *window, const wxString& text);
121
122 // this version associates the given text with all window with this id
123 // (may be used to set the same help string for all [Cancel] buttons in
124 // the application, for example)
125 virtual void AddHelp(wxWindowID id, const wxString& text);
126
127 // virtual dtor for any base class
128 virtual ~wxHelpProvider();
129
130private:
131 static wxHelpProvider *ms_helpProvider;
132};
133
134// wxSimpleHelpProvider is an implementation of wxHelpProvider which supports
135// only plain text help strings and shows the string associated with the
136// control (if any) in a tooltip
137class WXDLLEXPORT wxSimpleHelpProvider : public wxHelpProvider
138{
139public:
140 // implement wxHelpProvider methods
141 virtual wxString GetHelp(const wxWindowBase *window);
142 virtual bool ShowHelp(wxWindowBase *window);
143 virtual void AddHelp(wxWindowBase *window, const wxString& text);
144 virtual void AddHelp(wxWindowID id, const wxString& text);
145
146protected:
147 // we use 2 hashes for storing the help strings associated with windows
148 // and the ids
149 wxStringHashTable m_hashWindows,
150 m_hashIds;
151};
152
5100cabf
JS
153// wxHelpControllerHelpProvider is an implementation of wxHelpProvider which supports
154// both context identifiers and plain text help strings. If the help text is an integer,
155// it is passed to wxHelpController::DisplayContextPopup. Otherwise, it shows the string
156// in a tooltip as per wxSimpleHelpProvider.
157class WXDLLEXPORT wxHelpControllerHelpProvider : public wxSimpleHelpProvider
158{
159public:
160 // Note that it doesn't own the help controller. The help controller
161 // should be deleted separately.
162 wxHelpControllerHelpProvider(wxHelpControllerBase* hc = (wxHelpControllerBase*) NULL);
163
164 // implement wxHelpProvider methods
165 virtual bool ShowHelp(wxWindowBase *window);
166
167 // Other accessors
168 void SetHelpController(wxHelpControllerBase* hc) { m_helpController = hc; }
169 wxHelpControllerBase* GetHelpController() const { return m_helpController; }
170
171protected:
172 wxHelpControllerBase* m_helpController;
173};
174
175// Convenience function for turning context id into wxString
4e28924c 176WXDLLEXPORT wxString wxContextId(int id);
5100cabf 177
56029a74
VZ
178#endif // wxUSE_HELP
179
bd83cb56
VZ
180#endif // _WX_CSHELPH__
181