Audacity  2.3.1
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 *******************************************************************//*******************************************************************//**********************************************************************/
22 
23 #include "../Audacity.h"
24 
25 #include <wx/defs.h>
26 
27 #include "HtmlWindow.h"
28 
32 
33 //
34 // Constructor
35 //
36 HtmlWindow::HtmlWindow(wxWindow *parent,
37  wxWindowID id,
38  const wxPoint& pos,
39  const wxSize& size,
40  long style,
41  const wxString& name)
42 : wxHtmlWindow(parent, id, pos, size, style, name)
43 {
44 #if wxUSE_ACCESSIBILITY
45  SetAccessible( safenew HtmlWindowAx( this ) );
46 #endif
47 }
48 
49 //
50 // Destructor
51 //
53 {
54 }
55 
56 #if wxUSE_ACCESSIBILITY
57 
58 HtmlWindowAx::HtmlWindowAx( wxWindow *window ):
59  WindowAccessible( window )
60 {
61 }
62 
63 HtmlWindowAx::~HtmlWindowAx()
64 {
65 }
66 
67 // Retrieves the address of an IDispatch interface for the specified child.
68 // All objects must support this property.
69 wxAccStatus HtmlWindowAx::GetChild( int childId, wxAccessible** child )
70 {
71  if( childId == wxACC_SELF )
72  {
73  *child = this;
74  }
75  else
76  {
77  *child = NULL;
78  }
79 
80  return wxACC_OK;
81 }
82 
83 // Gets the number of children.
84 wxAccStatus HtmlWindowAx::GetChildCount(int* childCount)
85 {
86  *childCount = 0;
87 
88  return wxACC_OK;
89 }
90 
91 // Gets the default action for this object (0) or > 0 (the action for
92 // a child). Return wxACC_OK even if there is no action. actionName
93 // is the action, or the empty string if there is no action. The
94 // retrieved string describes the action that is performed on an
95 // object, not what the object does as a result. For example, a
96 // toolbar button that prints a document has a default action of
97 // "Press" rather than "Prints the current document."
98 wxAccStatus HtmlWindowAx::GetDefaultAction(int WXUNUSED(childId), wxString* actionName)
99 {
100  actionName->Clear();
101 
102  return wxACC_OK;
103 }
104 
105 // Returns the description for this object or a child.
106 wxAccStatus HtmlWindowAx::GetDescription( int WXUNUSED(childId), wxString *description )
107 {
108  description->Clear();
109 
110  return wxACC_OK;
111 }
112 
113 // Gets the window with the keyboard focus.
114 // If childId is 0 and child is NULL, no object in
115 // this subhierarchy has the focus.
116 // If this object has the focus, child should be 'this'.
117 wxAccStatus HtmlWindowAx::GetFocus(int* childId, wxAccessible** child)
118 {
119  *childId = 0;
120  *child = this;
121 
122  return wxACC_OK;
123 }
124 
125 // Returns help text for this object or a child, similar to tooltip text.
126 wxAccStatus HtmlWindowAx::GetHelpText( int WXUNUSED(childId), wxString *helpText )
127 {
128  helpText->Clear();
129 
130  return wxACC_OK;
131 }
132 
133 // Returns the keyboard shortcut for this object or child.
134 // Return e.g. ALT+K
135 wxAccStatus HtmlWindowAx::GetKeyboardShortcut( int WXUNUSED(childId), wxString *shortcut )
136 {
137  shortcut->Clear();
138 
139  return wxACC_OK;
140 }
141 
142 // Returns the rectangle for this object (id = 0) or a child element (id > 0).
143 // rect is in screen coordinates.
144 wxAccStatus HtmlWindowAx::GetLocation( wxRect& rect, int WXUNUSED(elementId) )
145 {
146  HtmlWindow *hw = wxDynamicCast( GetWindow(), HtmlWindow );
147 
148  rect = hw->GetRect();
149  rect.SetPosition( hw->GetParent()->ClientToScreen( rect.GetPosition() ) );
150 
151  return wxACC_OK;
152 }
153 
154 // Gets the name of the specified object.
155 wxAccStatus HtmlWindowAx::GetName(int WXUNUSED(childId), wxString* name)
156 {
157  HtmlWindow *hw = wxDynamicCast( GetWindow(), HtmlWindow );
158 
159  *name = hw->GetName();
160  if( name->IsEmpty() )
161  {
162  *name = hw->GetLabel();
163  }
164 
165  return wxACC_OK;
166 }
167 
168 // Returns a role constant.
169 wxAccStatus HtmlWindowAx::GetRole(int WXUNUSED(childId), wxAccRole* role)
170 {
171  *role = wxROLE_SYSTEM_STATICTEXT;
172 
173  return wxACC_OK;
174 }
175 
176 // Gets a variant representing the selected children
177 // of this object.
178 // Acceptable values:
179 // - a null variant (IsNull() returns TRUE)
180 // - a list variant (GetType() == wxT("list"))
181 // - an integer representing the selected child element,
182 // or 0 if this object is selected (GetType() == wxT("long"))
183 // - a "void*" pointer to a wxAccessible child object
184 wxAccStatus HtmlWindowAx::GetSelections( wxVariant * WXUNUSED(selections) )
185 {
186  return wxACC_NOT_IMPLEMENTED;
187 }
188 
189 // Returns a state constant.
190 wxAccStatus HtmlWindowAx::GetState(int WXUNUSED(childId), long* state)
191 {
192  HtmlWindow *hw = wxDynamicCast( GetWindow(), HtmlWindow );
193 
194  *state = wxACC_STATE_SYSTEM_FOCUSABLE;
195 
196  *state |= ( hw == wxWindow::FindFocus() ? wxACC_STATE_SYSTEM_FOCUSED : 0 );
197 
198  return wxACC_OK;
199 }
200 
201 // Returns a localized string representing the value for the object
202 // or child.
203 wxAccStatus HtmlWindowAx::GetValue(int WXUNUSED(childId), wxString* strValue)
204 {
205  HtmlWindow *hw = wxDynamicCast( GetWindow(), HtmlWindow );
206 
207  *strValue = hw->ToText();
208 
209  return wxACC_OK;
210 }
211 
212 #endif
#define safenew
Definition: Audacity.h:230
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
HtmlWindow Class.
Definition: HtmlWindow.h:39
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:36
const wxChar * name
Definition: Distortion.cpp:94
virtual ~HtmlWindow()
Definition: HtmlWindow.cpp:52