]> git.saurik.com Git - wxWidgets.git/blame - include/wx/cshelp.h
Make an image block beore writing it, if there's no data in the block
[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
68379eaf 9// Licence: wxWindows licence
fb6261e9
JS
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_CSHELPH__
13#define _WX_CSHELPH__
14
fb6261e9
JS
15#include "wx/defs.h"
16
17#if wxUSE_HELP
18
56029a74 19#include "wx/help.h"
ae500232 20
ba8c1601 21#include "wx/hashmap.h"
ae500232 22#if wxUSE_BMPBUTTON
fb6261e9 23#include "wx/bmpbuttn.h"
ae500232 24#endif
fb6261e9 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 39public:
68379eaf 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 52 bool m_inHelp;
68379eaf 53 bool m_status; // true if the user left-clicked
bd83cb56
VZ
54
55private:
56 DECLARE_DYNAMIC_CLASS(wxContextHelp)
fb6261e9
JS
57};
58
ae500232 59#if wxUSE_BMPBUTTON
fb6261e9
JS
60/*
61 * wxContextHelpButton
62 * You can add this to your dialogs (especially on non-Windows platforms)
63 * to put the application into context help mode.
64 */
65
bd83cb56 66class WXDLLEXPORT wxContextHelpButton : public wxBitmapButton
fb6261e9
JS
67{
68public:
bd83cb56
VZ
69 wxContextHelpButton(wxWindow* parent,
70 wxWindowID id = wxID_CONTEXT_HELP,
71 const wxPoint& pos = wxDefaultPosition,
72 const wxSize& size = wxDefaultSize,
73 long style = wxBU_AUTODRAW);
fb6261e9
JS
74
75 void OnContextHelp(wxCommandEvent& event);
76
bd83cb56 77private:
fc7a2a60 78 DECLARE_DYNAMIC_CLASS_NO_COPY(wxContextHelpButton)
fb6261e9
JS
79 DECLARE_EVENT_TABLE()
80};
81
ae500232
JS
82#endif
83
bd83cb56
VZ
84// ----------------------------------------------------------------------------
85// classes used to implement context help support
86// ----------------------------------------------------------------------------
87
5100cabf 88// wxHelpProvider is an abstract class used by the program implementing context help to
bd83cb56
VZ
89// show the help text (or whatever: it may be HTML page or anything else) for
90// the given window.
91//
92// The current help provider must be explicitly set by the application using
93// wxHelpProvider::Set().
94class WXDLLEXPORT wxHelpProvider
95{
96public:
97 // get/set the current (application-global) help provider (Set() returns
98 // the previous one)
99 static wxHelpProvider *Set(wxHelpProvider *helpProvider)
100 {
101 wxHelpProvider *helpProviderOld = ms_helpProvider;
102 ms_helpProvider = helpProvider;
103 return helpProviderOld;
104 }
105
106 // unlike some other class, the help provider is not created on demand,
107 // this must be explicitly done by the application
108 static wxHelpProvider *Get() { return ms_helpProvider; }
109
110 // get the help string (whose interpretation is help provider dependent
111 // except that empty string always means that no help is associated with
112 // the window) for this window
113 virtual wxString GetHelp(const wxWindowBase *window) = 0;
114
115 // do show help for the given window (uses GetHelp() internally if
68379eaf 116 // applicable), return true if it was done or false if no help available
bd83cb56
VZ
117 // for this window
118 virtual bool ShowHelp(wxWindowBase *window) = 0;
119
120 // associate the text with the given window or id: although all help
121 // providers have these functions to allow making wxWindow::SetHelpText()
122 // work, not all of them implement them
123 virtual void AddHelp(wxWindowBase *window, const wxString& text);
124
125 // this version associates the given text with all window with this id
126 // (may be used to set the same help string for all [Cancel] buttons in
127 // the application, for example)
128 virtual void AddHelp(wxWindowID id, const wxString& text);
129
53e112a0
JS
130 // removes the association
131 virtual void RemoveHelp(wxWindowBase* window);
132
bd83cb56
VZ
133 // virtual dtor for any base class
134 virtual ~wxHelpProvider();
135
136private:
137 static wxHelpProvider *ms_helpProvider;
138};
139
871192ce 140WX_DECLARE_EXPORTED_HASH_MAP( wxUIntPtr, wxString, wxIntegerHash,
3f5c62f9 141 wxIntegerEqual, wxSimpleHelpProviderHashMap );
ba8c1601 142
bd83cb56
VZ
143// wxSimpleHelpProvider is an implementation of wxHelpProvider which supports
144// only plain text help strings and shows the string associated with the
145// control (if any) in a tooltip
146class WXDLLEXPORT wxSimpleHelpProvider : public wxHelpProvider
147{
148public:
149 // implement wxHelpProvider methods
150 virtual wxString GetHelp(const wxWindowBase *window);
151 virtual bool ShowHelp(wxWindowBase *window);
152 virtual void AddHelp(wxWindowBase *window, const wxString& text);
153 virtual void AddHelp(wxWindowID id, const wxString& text);
53e112a0 154 virtual void RemoveHelp(wxWindowBase* window);
bd83cb56
VZ
155
156protected:
157 // we use 2 hashes for storing the help strings associated with windows
158 // and the ids
871192ce
MW
159 wxSimpleHelpProviderHashMap m_hashWindows,
160 m_hashIds;
bd83cb56
VZ
161};
162
5100cabf
JS
163// wxHelpControllerHelpProvider is an implementation of wxHelpProvider which supports
164// both context identifiers and plain text help strings. If the help text is an integer,
165// it is passed to wxHelpController::DisplayContextPopup. Otherwise, it shows the string
166// in a tooltip as per wxSimpleHelpProvider.
167class WXDLLEXPORT wxHelpControllerHelpProvider : public wxSimpleHelpProvider
168{
169public:
170 // Note that it doesn't own the help controller. The help controller
171 // should be deleted separately.
172 wxHelpControllerHelpProvider(wxHelpControllerBase* hc = (wxHelpControllerBase*) NULL);
173
174 // implement wxHelpProvider methods
175 virtual bool ShowHelp(wxWindowBase *window);
176
177 // Other accessors
178 void SetHelpController(wxHelpControllerBase* hc) { m_helpController = hc; }
179 wxHelpControllerBase* GetHelpController() const { return m_helpController; }
180
181protected:
182 wxHelpControllerBase* m_helpController;
22f3361e
VZ
183
184 DECLARE_NO_COPY_CLASS(wxHelpControllerHelpProvider)
5100cabf
JS
185};
186
187// Convenience function for turning context id into wxString
4e28924c 188WXDLLEXPORT wxString wxContextId(int id);
5100cabf 189
56029a74
VZ
190#endif // wxUSE_HELP
191
bd83cb56
VZ
192#endif // _WX_CSHELPH__
193