Audacity 3.2.0
HtmlWindow.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 HtmlWindow.cpp
6
7 Leland Lucius
8
9*******************************************************************//*******************************************************************//**********************************************************************/
21
22
23#include "HtmlWindow.h"
24
25#include <wx/setup.h> // for wxUSE_* macros
26#include <wx/defs.h>
27
28#if wxUSE_ACCESSIBILITY
29#include "WindowAccessible.h"
30
31class HtmlWindowAx final : public WindowAccessible
32{
33public:
34 HtmlWindowAx(wxWindow * window);
35
36 virtual ~ HtmlWindowAx();
37
38 // Retrieves the address of an IDispatch interface for the specified child.
39 // All objects must support this property.
40 wxAccStatus GetChild(int childId, wxAccessible** child) override;
41
42 // Gets the number of children.
43 wxAccStatus GetChildCount(int* childCount) override;
44
45 // Gets the default action for this object (0) or > 0 (the action for a child).
46 // Return wxACC_OK even if there is no action. actionName is the action, or the empty
47 // string if there is no action.
48 // The retrieved string describes the action that is performed on an object,
49 // not what the object does as a result. For example, a toolbar button that prints
50 // a document has a default action of "Press" rather than "Prints the current document."
51 wxAccStatus GetDefaultAction(int childId, wxString *actionName) override;
52
53 // Returns the description for this object or a child.
54 wxAccStatus GetDescription(int childId, wxString *description) override;
55
56 // Gets the window with the keyboard focus.
57 // If childId is 0 and child is NULL, no object in
58 // this subhierarchy has the focus.
59 // If this object has the focus, child should be 'this'.
60 wxAccStatus GetFocus(int *childId, wxAccessible **child) override;
61
62 // Returns help text for this object or a child, similar to tooltip text.
63 wxAccStatus GetHelpText(int childId, wxString *helpText) override;
64
65 // Returns the keyboard shortcut for this object or child.
66 // Return e.g. ALT+K
67 wxAccStatus GetKeyboardShortcut(int childId, wxString *shortcut) override;
68
69 // Returns the rectangle for this object (id = 0) or a child element (id > 0).
70 // rect is in screen coordinates.
71 wxAccStatus GetLocation(wxRect& rect, int elementId) override;
72
73 // Gets the name of the specified object.
74 wxAccStatus GetName(int childId, wxString *name) override;
75
76 // Returns a role constant.
77 wxAccStatus GetRole(int childId, wxAccRole *role) override;
78
79 // Gets a variant representing the selected children
80 // of this object.
81 // Acceptable values:
82 // - a null variant (IsNull() returns TRUE)
83 // - a list variant (GetType() == wxT("list"))
84 // - an integer representing the selected child element,
85 // or 0 if this object is selected (GetType() == wxT("long"))
86 // - a "void*" pointer to a wxAccessible child object
87 wxAccStatus GetSelections(wxVariant *selections) override;
88
89 // Returns a state constant.
90 wxAccStatus GetState(int childId, long* state) override;
91
92 // Returns a localized string representing the value for the object
93 // or child.
94 wxAccStatus GetValue(int childId, wxString* strValue) override;
95
96};
97
98#endif // wxUSE_ACCESSIBILITY
99
103
104//
105// Constructor
106//
107HtmlWindow::HtmlWindow(wxWindow *parent,
108 wxWindowID id,
109 const wxPoint& pos,
110 const wxSize& size,
111 long style,
112 const wxString& name)
113: wxHtmlWindow(parent, id, pos, size, style, name)
114{
115#if wxUSE_ACCESSIBILITY
116 SetAccessible( safenew HtmlWindowAx( this ) );
117#endif
118}
119
120//
121// Destructor
122//
124{
125}
126
127#if wxUSE_ACCESSIBILITY
128
129HtmlWindowAx::HtmlWindowAx( wxWindow *window ):
130 WindowAccessible( window )
131{
132}
133
134HtmlWindowAx::~HtmlWindowAx()
135{
136}
137
138// Retrieves the address of an IDispatch interface for the specified child.
139// All objects must support this property.
140wxAccStatus HtmlWindowAx::GetChild( int childId, wxAccessible** child )
141{
142 if( childId == wxACC_SELF )
143 {
144 *child = this;
145 }
146 else
147 {
148 *child = NULL;
149 }
150
151 return wxACC_OK;
152}
153
154// Gets the number of children.
155wxAccStatus HtmlWindowAx::GetChildCount(int* childCount)
156{
157 *childCount = 0;
158
159 return wxACC_OK;
160}
161
162// Gets the default action for this object (0) or > 0 (the action for
163// a child). Return wxACC_OK even if there is no action. actionName
164// is the action, or the empty string if there is no action. The
165// retrieved string describes the action that is performed on an
166// object, not what the object does as a result. For example, a
167// toolbar button that prints a document has a default action of
168// "Press" rather than "Prints the current document."
169wxAccStatus HtmlWindowAx::GetDefaultAction(int WXUNUSED(childId), wxString* actionName)
170{
171 actionName->clear();
172
173 return wxACC_OK;
174}
175
176// Returns the description for this object or a child.
177wxAccStatus HtmlWindowAx::GetDescription( int WXUNUSED(childId), wxString *description )
178{
179 description->clear();
180
181 return wxACC_OK;
182}
183
184// Gets the window with the keyboard focus.
185// If childId is 0 and child is NULL, no object in
186// this subhierarchy has the focus.
187// If this object has the focus, child should be 'this'.
188wxAccStatus HtmlWindowAx::GetFocus(int* childId, wxAccessible** child)
189{
190 *childId = 0;
191 *child = this;
192
193 return wxACC_OK;
194}
195
196// Returns help text for this object or a child, similar to tooltip text.
197wxAccStatus HtmlWindowAx::GetHelpText( int WXUNUSED(childId), wxString *helpText )
198{
199 helpText->clear();
200
201 return wxACC_OK;
202}
203
204// Returns the keyboard shortcut for this object or child.
205// Return e.g. ALT+K
206wxAccStatus HtmlWindowAx::GetKeyboardShortcut( int WXUNUSED(childId), wxString *shortcut )
207{
208 shortcut->clear();
209
210 return wxACC_OK;
211}
212
213// Returns the rectangle for this object (id = 0) or a child element (id > 0).
214// rect is in screen coordinates.
215wxAccStatus HtmlWindowAx::GetLocation( wxRect& rect, int WXUNUSED(elementId) )
216{
217 HtmlWindow *hw = wxDynamicCast( GetWindow(), HtmlWindow );
218
219 rect = hw->GetRect();
220 rect.SetPosition( hw->GetParent()->ClientToScreen( rect.GetPosition() ) );
221
222 return wxACC_OK;
223}
224
225// Gets the name of the specified object.
226wxAccStatus HtmlWindowAx::GetName(int WXUNUSED(childId), wxString* name)
227{
228 HtmlWindow *hw = wxDynamicCast( GetWindow(), HtmlWindow );
229
230 *name = hw->GetName();
231 if( name->empty() )
232 {
233 *name = hw->GetLabel();
234 }
235
236 return wxACC_OK;
237}
238
239// Returns a role constant.
240wxAccStatus HtmlWindowAx::GetRole(int WXUNUSED(childId), wxAccRole* role)
241{
242 *role = wxROLE_SYSTEM_STATICTEXT;
243
244 return wxACC_OK;
245}
246
247// Gets a variant representing the selected children
248// of this object.
249// Acceptable values:
250// - a null variant (IsNull() returns TRUE)
251// - a list variant (GetType() == wxT("list"))
252// - an integer representing the selected child element,
253// or 0 if this object is selected (GetType() == wxT("long"))
254// - a "void*" pointer to a wxAccessible child object
255wxAccStatus HtmlWindowAx::GetSelections( wxVariant * WXUNUSED(selections) )
256{
257 return wxACC_NOT_IMPLEMENTED;
258}
259
260// Returns a state constant.
261wxAccStatus HtmlWindowAx::GetState(int WXUNUSED(childId), long* state)
262{
263 HtmlWindow *hw = wxDynamicCast( GetWindow(), HtmlWindow );
264
265 *state = wxACC_STATE_SYSTEM_FOCUSABLE;
266
267 *state |= ( hw == wxWindow::FindFocus() ? wxACC_STATE_SYSTEM_FOCUSED : 0 );
268
269 return wxACC_OK;
270}
271
272// Returns a localized string representing the value for the object
273// or child.
274wxAccStatus HtmlWindowAx::GetValue(int WXUNUSED(childId), wxString* strValue)
275{
276 HtmlWindow *hw = wxDynamicCast( GetWindow(), HtmlWindow );
277
278 *strValue = hw->ToText();
279
280 return wxACC_OK;
281}
282
283#endif
#define safenew
Definition: MemoryX.h:10
wxString name
Definition: TagsEditor.cpp:166
int id
HtmlWindow Class.
Definition: HtmlWindow.h:37
HtmlWindow(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxHW_DEFAULT_STYLE, const wxString &name=wxT("htmlWindow"))
Methods for HtmlWindow.
Definition: HtmlWindow.cpp:107
virtual ~HtmlWindow()
Definition: HtmlWindow.cpp:123
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
Definition: BasicUI.h:383