1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-03 17:39:25 +02:00

Move class SliderAx into WindowAccessible.* ...

... so ScienFilter.cpp doesn't depend on Equalization.h
This commit is contained in:
Paul Licameli 2019-03-31 12:29:08 -04:00
parent 48b184f072
commit 10568f8a46
6 changed files with 264 additions and 279 deletions

View File

@ -3654,198 +3654,3 @@ void EditCurvesDialog::OnListSelectionChange( wxListEvent & )
FindWindowById(id, this)->Enable(enable);
}
#if wxUSE_ACCESSIBILITY
SliderAx::SliderAx(wxWindow * window, const wxString &fmt) :
WindowAccessible( window )
{
mParent = window;
mFmt = fmt;
}
SliderAx::~SliderAx()
{
}
// Retrieves the address of an IDispatch interface for the specified child.
// All objects must support this property.
wxAccStatus SliderAx::GetChild( int childId, wxAccessible** child )
{
if( childId == wxACC_SELF )
{
*child = this;
}
else
{
*child = NULL;
}
return wxACC_OK;
}
// Gets the number of children.
wxAccStatus SliderAx::GetChildCount(int* childCount)
{
*childCount = 3;
return wxACC_OK;
}
// Gets the default action for this object (0) or > 0 (the action for a child).
// Return wxACC_OK even if there is no action. actionName is the action, or the empty
// string if there is no action.
// The retrieved string describes the action that is performed on an object,
// not what the object does as a result. For example, a toolbar button that prints
// a document has a default action of "Press" rather than "Prints the current document."
wxAccStatus SliderAx::GetDefaultAction( int WXUNUSED(childId), wxString *actionName )
{
actionName->clear();
return wxACC_OK;
}
// Returns the description for this object or a child.
wxAccStatus SliderAx::GetDescription( int WXUNUSED(childId), wxString *description )
{
description->clear();
return wxACC_OK;
}
// Gets the window with the keyboard focus.
// If childId is 0 and child is NULL, no object in
// this subhierarchy has the focus.
// If this object has the focus, child should be 'this'.
wxAccStatus SliderAx::GetFocus(int* childId, wxAccessible** child)
{
*childId = 0;
*child = this;
return wxACC_OK;
}
// Returns help text for this object or a child, similar to tooltip text.
wxAccStatus SliderAx::GetHelpText( int WXUNUSED(childId), wxString *helpText )
{
helpText->clear();
return wxACC_OK;
}
// Returns the keyboard shortcut for this object or child.
// Return e.g. ALT+K
wxAccStatus SliderAx::GetKeyboardShortcut( int WXUNUSED(childId), wxString *shortcut )
{
shortcut->clear();
return wxACC_OK;
}
// Returns the rectangle for this object (id = 0) or a child element (id > 0).
// rect is in screen coordinates.
wxAccStatus SliderAx::GetLocation( wxRect& rect, int WXUNUSED(elementId) )
{
wxSlider *s = wxDynamicCast( GetWindow(), wxSlider );
rect = s->GetRect();
rect.SetPosition( s->GetParent()->ClientToScreen( rect.GetPosition() ) );
return wxACC_OK;
}
// Gets the name of the specified object.
wxAccStatus SliderAx::GetName(int WXUNUSED(childId), wxString* name)
{
wxSlider *s = wxDynamicCast( GetWindow(), wxSlider );
*name = s->GetName();
return wxACC_OK;
}
// Returns a role constant.
wxAccStatus SliderAx::GetRole(int childId, wxAccRole* role)
{
switch( childId )
{
case 0:
*role = wxROLE_SYSTEM_SLIDER;
break;
case 1:
case 3:
*role = wxROLE_SYSTEM_PUSHBUTTON;
break;
case 2:
*role = wxROLE_SYSTEM_INDICATOR;
break;
}
return wxACC_OK;
}
// Gets a variant representing the selected children
// of this object.
// Acceptable values:
// - a null variant (IsNull() returns TRUE)
// - a list variant (GetType() == wxT("list"))
// - an integer representing the selected child element,
// or 0 if this object is selected (GetType() == wxT("long"))
// - a "void*" pointer to a wxAccessible child object
wxAccStatus SliderAx::GetSelections( wxVariant * WXUNUSED(selections) )
{
return wxACC_NOT_IMPLEMENTED;
}
// Returns a state constant.
wxAccStatus SliderAx::GetState(int childId, long* state)
{
wxSlider *s = wxDynamicCast( GetWindow(), wxSlider );
switch( childId )
{
case 0:
*state = wxACC_STATE_SYSTEM_FOCUSABLE;
break;
case 1:
if( s->GetValue() == s->GetMin() )
{
*state = wxACC_STATE_SYSTEM_INVISIBLE;
}
break;
case 3:
if( s->GetValue() == s->GetMax() )
{
*state = wxACC_STATE_SYSTEM_INVISIBLE;
}
break;
}
// Do not use mSliderIsFocused is not set until after this method
// is called.
*state |= ( s == wxWindow::FindFocus() ? wxACC_STATE_SYSTEM_FOCUSED : 0 );
return wxACC_OK;
}
// Returns a localized string representing the value for the object
// or child.
wxAccStatus SliderAx::GetValue(int childId, wxString* strValue)
{
wxSlider *s = wxDynamicCast( GetWindow(), wxSlider );
if( childId == 0 )
{
strValue->Printf( mFmt, s->GetValue() );
return wxACC_OK;
}
return wxACC_NOT_SUPPORTED;
}
#endif

View File

@ -387,78 +387,4 @@ private:
DECLARE_EVENT_TABLE()
};
#if wxUSE_ACCESSIBILITY
class SliderAx final : public WindowAccessible
{
public:
SliderAx(wxWindow * window, const wxString &fmt);
virtual ~ SliderAx();
// Retrieves the address of an IDispatch interface for the specified child.
// All objects must support this property.
wxAccStatus GetChild(int childId, wxAccessible** child) override;
// Gets the number of children.
wxAccStatus GetChildCount(int* childCount) override;
// Gets the default action for this object (0) or > 0 (the action for a child).
// Return wxACC_OK even if there is no action. actionName is the action, or the empty
// string if there is no action.
// The retrieved string describes the action that is performed on an object,
// not what the object does as a result. For example, a toolbar button that prints
// a document has a default action of "Press" rather than "Prints the current document."
wxAccStatus GetDefaultAction(int childId, wxString *actionName) override;
// Returns the description for this object or a child.
wxAccStatus GetDescription(int childId, wxString *description) override;
// Gets the window with the keyboard focus.
// If childId is 0 and child is NULL, no object in
// this subhierarchy has the focus.
// If this object has the focus, child should be 'this'.
wxAccStatus GetFocus(int *childId, wxAccessible **child) override;
// Returns help text for this object or a child, similar to tooltip text.
wxAccStatus GetHelpText(int childId, wxString *helpText) override;
// Returns the keyboard shortcut for this object or child.
// Return e.g. ALT+K
wxAccStatus GetKeyboardShortcut(int childId, wxString *shortcut) override;
// Returns the rectangle for this object (id = 0) or a child element (id > 0).
// rect is in screen coordinates.
wxAccStatus GetLocation(wxRect& rect, int elementId) override;
// Gets the name of the specified object.
wxAccStatus GetName(int childId, wxString *name) override;
// Returns a role constant.
wxAccStatus GetRole(int childId, wxAccRole *role) override;
// Gets a variant representing the selected children
// of this object.
// Acceptable values:
// - a null variant (IsNull() returns TRUE)
// - a list variant (GetType() == wxT("list"))
// - an integer representing the selected child element,
// or 0 if this object is selected (GetType() == wxT("long"))
// - a "void*" pointer to a wxAccessible child object
wxAccStatus GetSelections(wxVariant *selections) override;
// Returns a state constant.
wxAccStatus GetState(int childId, long* state) override;
// Returns a localized string representing the value for the object
// or child.
wxAccStatus GetValue(int childId, wxString* strValue) override;
private:
wxWindow *mParent;
wxString mFmt;
};
#endif // wxUSE_ACCESSIBILITY
#endif

View File

@ -62,8 +62,7 @@ a graph for EffectScienFilter.
#include "../WaveTrack.h"
#include "../widgets/valnum.h"
#include "../widgets/ErrorDialog.h"
#include "Equalization.h" // For SliderAx
#include "../widgets/Ruler.h"
#if !defined(M_PI)
#define PI = 3.1415926535897932384626433832795

View File

@ -173,12 +173,4 @@ private:
DECLARE_EVENT_TABLE()
};
#if wxUSE_ACCESSIBILITY
// ScienceFilter and Equalisation effects both need SliderAx class.
// For now it is declared and defined in Equalisation effect.
// TODO: Move it to its own file.
#endif // wxUSE_ACCESSIBILITY
#endif

View File

@ -39,4 +39,197 @@ wxAccStatus WindowAccessible::GetName(int childId, wxString* name)
return wxACC_OK;
}
#include <wx/slider.h>
SliderAx::SliderAx(wxWindow * window, const wxString &fmt) :
WindowAccessible( window )
{
mParent = window;
mFmt = fmt;
}
SliderAx::~SliderAx()
{
}
// Retrieves the address of an IDispatch interface for the specified child.
// All objects must support this property.
wxAccStatus SliderAx::GetChild( int childId, wxAccessible** child )
{
if( childId == wxACC_SELF )
{
*child = this;
}
else
{
*child = NULL;
}
return wxACC_OK;
}
// Gets the number of children.
wxAccStatus SliderAx::GetChildCount(int* childCount)
{
*childCount = 3;
return wxACC_OK;
}
// Gets the default action for this object (0) or > 0 (the action for a child).
// Return wxACC_OK even if there is no action. actionName is the action, or the empty
// string if there is no action.
// The retrieved string describes the action that is performed on an object,
// not what the object does as a result. For example, a toolbar button that prints
// a document has a default action of "Press" rather than "Prints the current document."
wxAccStatus SliderAx::GetDefaultAction( int WXUNUSED(childId), wxString *actionName )
{
actionName->clear();
return wxACC_OK;
}
// Returns the description for this object or a child.
wxAccStatus SliderAx::GetDescription( int WXUNUSED(childId), wxString *description )
{
description->clear();
return wxACC_OK;
}
// Gets the window with the keyboard focus.
// If childId is 0 and child is NULL, no object in
// this subhierarchy has the focus.
// If this object has the focus, child should be 'this'.
wxAccStatus SliderAx::GetFocus(int* childId, wxAccessible** child)
{
*childId = 0;
*child = this;
return wxACC_OK;
}
// Returns help text for this object or a child, similar to tooltip text.
wxAccStatus SliderAx::GetHelpText( int WXUNUSED(childId), wxString *helpText )
{
helpText->clear();
return wxACC_OK;
}
// Returns the keyboard shortcut for this object or child.
// Return e.g. ALT+K
wxAccStatus SliderAx::GetKeyboardShortcut( int WXUNUSED(childId), wxString *shortcut )
{
shortcut->clear();
return wxACC_OK;
}
// Returns the rectangle for this object (id = 0) or a child element (id > 0).
// rect is in screen coordinates.
wxAccStatus SliderAx::GetLocation( wxRect& rect, int WXUNUSED(elementId) )
{
wxSlider *s = wxDynamicCast( GetWindow(), wxSlider );
rect = s->GetRect();
rect.SetPosition( s->GetParent()->ClientToScreen( rect.GetPosition() ) );
return wxACC_OK;
}
// Gets the name of the specified object.
wxAccStatus SliderAx::GetName(int WXUNUSED(childId), wxString* name)
{
wxSlider *s = wxDynamicCast( GetWindow(), wxSlider );
*name = s->GetName();
return wxACC_OK;
}
// Returns a role constant.
wxAccStatus SliderAx::GetRole(int childId, wxAccRole* role)
{
switch( childId )
{
case 0:
*role = wxROLE_SYSTEM_SLIDER;
break;
case 1:
case 3:
*role = wxROLE_SYSTEM_PUSHBUTTON;
break;
case 2:
*role = wxROLE_SYSTEM_INDICATOR;
break;
}
return wxACC_OK;
}
// Gets a variant representing the selected children
// of this object.
// Acceptable values:
// - a null variant (IsNull() returns TRUE)
// - a list variant (GetType() == wxT("list"))
// - an integer representing the selected child element,
// or 0 if this object is selected (GetType() == wxT("long"))
// - a "void*" pointer to a wxAccessible child object
wxAccStatus SliderAx::GetSelections( wxVariant * WXUNUSED(selections) )
{
return wxACC_NOT_IMPLEMENTED;
}
// Returns a state constant.
wxAccStatus SliderAx::GetState(int childId, long* state)
{
wxSlider *s = wxDynamicCast( GetWindow(), wxSlider );
switch( childId )
{
case 0:
*state = wxACC_STATE_SYSTEM_FOCUSABLE;
break;
case 1:
if( s->GetValue() == s->GetMin() )
{
*state = wxACC_STATE_SYSTEM_INVISIBLE;
}
break;
case 3:
if( s->GetValue() == s->GetMax() )
{
*state = wxACC_STATE_SYSTEM_INVISIBLE;
}
break;
}
// Do not use mSliderIsFocused is not set until after this method
// is called.
*state |= ( s == wxWindow::FindFocus() ? wxACC_STATE_SYSTEM_FOCUSED : 0 );
return wxACC_OK;
}
// Returns a localized string representing the value for the object
// or child.
wxAccStatus SliderAx::GetValue(int childId, wxString* strValue)
{
wxSlider *s = wxDynamicCast( GetWindow(), wxSlider );
if( childId == 0 )
{
strValue->Printf( mFmt, s->GetValue() );
return wxACC_OK;
}
return wxACC_NOT_SUPPORTED;
}
#endif // wxUSE_ACCESSIBILITY

View File

@ -27,5 +27,75 @@ public:
};
class SliderAx final : public WindowAccessible
{
public:
SliderAx(wxWindow * window, const wxString &fmt);
virtual ~ SliderAx();
// Retrieves the address of an IDispatch interface for the specified child.
// All objects must support this property.
wxAccStatus GetChild(int childId, wxAccessible** child) override;
// Gets the number of children.
wxAccStatus GetChildCount(int* childCount) override;
// Gets the default action for this object (0) or > 0 (the action for a child).
// Return wxACC_OK even if there is no action. actionName is the action, or the empty
// string if there is no action.
// The retrieved string describes the action that is performed on an object,
// not what the object does as a result. For example, a toolbar button that prints
// a document has a default action of "Press" rather than "Prints the current document."
wxAccStatus GetDefaultAction(int childId, wxString *actionName) override;
// Returns the description for this object or a child.
wxAccStatus GetDescription(int childId, wxString *description) override;
// Gets the window with the keyboard focus.
// If childId is 0 and child is NULL, no object in
// this subhierarchy has the focus.
// If this object has the focus, child should be 'this'.
wxAccStatus GetFocus(int *childId, wxAccessible **child) override;
// Returns help text for this object or a child, similar to tooltip text.
wxAccStatus GetHelpText(int childId, wxString *helpText) override;
// Returns the keyboard shortcut for this object or child.
// Return e.g. ALT+K
wxAccStatus GetKeyboardShortcut(int childId, wxString *shortcut) override;
// Returns the rectangle for this object (id = 0) or a child element (id > 0).
// rect is in screen coordinates.
wxAccStatus GetLocation(wxRect& rect, int elementId) override;
// Gets the name of the specified object.
wxAccStatus GetName(int childId, wxString *name) override;
// Returns a role constant.
wxAccStatus GetRole(int childId, wxAccRole *role) override;
// Gets a variant representing the selected children
// of this object.
// Acceptable values:
// - a null variant (IsNull() returns TRUE)
// - a list variant (GetType() == wxT("list"))
// - an integer representing the selected child element,
// or 0 if this object is selected (GetType() == wxT("long"))
// - a "void*" pointer to a wxAccessible child object
wxAccStatus GetSelections(wxVariant *selections) override;
// Returns a state constant.
wxAccStatus GetState(int childId, long* state) override;
// Returns a localized string representing the value for the object
// or child.
wxAccStatus GetValue(int childId, wxString* strValue) override;
private:
wxWindow *mParent;
wxString mFmt;
};
#endif // wxUSE_ACCESSIBILITY
#endif // __AUDACITY_WINDOW_ACCESSIBLE__