root / trunk / install / launcher / izpack-launcher-1.3_linux / src / wx / include / wx / cshelp.h @ 6834
History | View | Annotate | Download (6.05 KB)
1 |
/////////////////////////////////////////////////////////////////////////////
|
---|---|
2 |
// Name: wx/cshelp.h
|
3 |
// Purpose: Context-sensitive help support classes
|
4 |
// Author: Julian Smart, Vadim Zeitlin
|
5 |
// Modified by:
|
6 |
// Created: 08/09/2000
|
7 |
// RCS-ID: $Id: cshelp.h 6834 2006-08-24 08:23:24Z jmvivo $
|
8 |
// Copyright: (c) 2000 Julian Smart, Vadim Zeitlin
|
9 |
// Licence: wxWindows licence
|
10 |
/////////////////////////////////////////////////////////////////////////////
|
11 |
|
12 |
#ifndef _WX_CSHELPH__
|
13 |
#define _WX_CSHELPH__
|
14 |
|
15 |
#include "wx/defs.h" |
16 |
|
17 |
#if wxUSE_HELP
|
18 |
|
19 |
#include "wx/help.h" |
20 |
#include "wx/bmpbuttn.h" |
21 |
|
22 |
// ----------------------------------------------------------------------------
|
23 |
// classes used to implement context help UI
|
24 |
// ----------------------------------------------------------------------------
|
25 |
|
26 |
/*
|
27 |
* wxContextHelp
|
28 |
* Invokes context-sensitive help. When the user
|
29 |
* clicks on a window, a wxEVT_HELP event will be sent to that
|
30 |
* window for the application to display help for.
|
31 |
*/
|
32 |
|
33 |
class WXDLLEXPORT wxContextHelp : public wxObject |
34 |
{ |
35 |
public:
|
36 |
wxContextHelp(wxWindow* win = NULL, bool beginHelp = TRUE); |
37 |
virtual ~wxContextHelp(); |
38 |
|
39 |
bool BeginContextHelp(wxWindow* win);
|
40 |
bool EndContextHelp();
|
41 |
|
42 |
bool EventLoop();
|
43 |
bool DispatchEvent(wxWindow* win, const wxPoint& pt); |
44 |
|
45 |
void SetStatus(bool status) { m_status = status; } |
46 |
|
47 |
protected:
|
48 |
bool m_inHelp;
|
49 |
bool m_status; // TRUE if the user left-clicked |
50 |
|
51 |
private:
|
52 |
DECLARE_DYNAMIC_CLASS(wxContextHelp) |
53 |
}; |
54 |
|
55 |
/*
|
56 |
* wxContextHelpButton
|
57 |
* You can add this to your dialogs (especially on non-Windows platforms)
|
58 |
* to put the application into context help mode.
|
59 |
*/
|
60 |
|
61 |
class WXDLLEXPORT wxContextHelpButton : public wxBitmapButton |
62 |
{ |
63 |
public:
|
64 |
wxContextHelpButton(wxWindow* parent, |
65 |
wxWindowID id = wxID_CONTEXT_HELP, |
66 |
const wxPoint& pos = wxDefaultPosition,
|
67 |
const wxSize& size = wxDefaultSize,
|
68 |
long style = wxBU_AUTODRAW);
|
69 |
|
70 |
void OnContextHelp(wxCommandEvent& event);
|
71 |
|
72 |
private:
|
73 |
DECLARE_CLASS(wxContextHelpButton) |
74 |
DECLARE_EVENT_TABLE() |
75 |
}; |
76 |
|
77 |
// ----------------------------------------------------------------------------
|
78 |
// classes used to implement context help support
|
79 |
// ----------------------------------------------------------------------------
|
80 |
|
81 |
// wxHelpProvider is an abstract class used by the program implementing context help to
|
82 |
// show the help text (or whatever: it may be HTML page or anything else) for
|
83 |
// the given window.
|
84 |
//
|
85 |
// The current help provider must be explicitly set by the application using
|
86 |
// wxHelpProvider::Set().
|
87 |
class WXDLLEXPORT wxHelpProvider |
88 |
{ |
89 |
public:
|
90 |
// get/set the current (application-global) help provider (Set() returns
|
91 |
// the previous one)
|
92 |
static wxHelpProvider *Set(wxHelpProvider *helpProvider)
|
93 |
{ |
94 |
wxHelpProvider *helpProviderOld = ms_helpProvider; |
95 |
ms_helpProvider = helpProvider; |
96 |
return helpProviderOld;
|
97 |
} |
98 |
|
99 |
// unlike some other class, the help provider is not created on demand,
|
100 |
// this must be explicitly done by the application
|
101 |
static wxHelpProvider *Get() { return ms_helpProvider; } |
102 |
|
103 |
// get the help string (whose interpretation is help provider dependent
|
104 |
// except that empty string always means that no help is associated with
|
105 |
// the window) for this window
|
106 |
virtual wxString GetHelp(const wxWindowBase *window) = 0; |
107 |
|
108 |
// do show help for the given window (uses GetHelp() internally if
|
109 |
// applicable), return TRUE if it was done or FALSE if no help available
|
110 |
// for this window
|
111 |
virtual bool ShowHelp(wxWindowBase *window) = 0; |
112 |
|
113 |
// associate the text with the given window or id: although all help
|
114 |
// providers have these functions to allow making wxWindow::SetHelpText()
|
115 |
// work, not all of them implement them
|
116 |
virtual void AddHelp(wxWindowBase *window, const wxString& text); |
117 |
|
118 |
// this version associates the given text with all window with this id
|
119 |
// (may be used to set the same help string for all [Cancel] buttons in
|
120 |
// the application, for example)
|
121 |
virtual void AddHelp(wxWindowID id, const wxString& text); |
122 |
|
123 |
// removes the association
|
124 |
virtual void RemoveHelp(wxWindowBase* window);
|
125 |
|
126 |
// virtual dtor for any base class
|
127 |
virtual ~wxHelpProvider(); |
128 |
|
129 |
private:
|
130 |
static wxHelpProvider *ms_helpProvider;
|
131 |
}; |
132 |
|
133 |
// wxSimpleHelpProvider is an implementation of wxHelpProvider which supports
|
134 |
// only plain text help strings and shows the string associated with the
|
135 |
// control (if any) in a tooltip
|
136 |
class WXDLLEXPORT wxSimpleHelpProvider : public wxHelpProvider |
137 |
{ |
138 |
public:
|
139 |
// implement wxHelpProvider methods
|
140 |
virtual wxString GetHelp(const wxWindowBase *window);
|
141 |
virtual bool ShowHelp(wxWindowBase *window);
|
142 |
virtual void AddHelp(wxWindowBase *window, const wxString& text); |
143 |
virtual void AddHelp(wxWindowID id, const wxString& text); |
144 |
virtual void RemoveHelp(wxWindowBase* window);
|
145 |
|
146 |
protected:
|
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 |
|
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.
|
157 |
class WXDLLEXPORT wxHelpControllerHelpProvider : public wxSimpleHelpProvider |
158 |
{ |
159 |
public:
|
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 |
|
171 |
protected:
|
172 |
wxHelpControllerBase* m_helpController; |
173 |
}; |
174 |
|
175 |
// Convenience function for turning context id into wxString
|
176 |
WXDLLEXPORT wxString wxContextId(int id);
|
177 |
|
178 |
#endif // wxUSE_HELP |
179 |
|
180 |
#endif // _WX_CSHELPH__ |
181 |
|