MCPcopy Create free account
hub / github.com/audacity/audacity / MeterButtonAx

Class MeterButtonAx

src/toolbars/MeterToolBar.cpp:43–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41#if wxUSE_ACCESSIBILITY
42
43class MeterButtonAx : public AButtonAx
44{
45 wxWeakRef<MeterPanel> mAssociatedMeterPanel{nullptr};
46 bool mAccSilent{false};
47public:
48
49 MeterButtonAx(AButton& button, MeterPanel& panel)
50 : AButtonAx(&button)
51 , mAssociatedMeterPanel(&panel)
52 { }
53
54 wxAccStatus GetName(int childId, wxString* name) override
55 {
56 if(childId != wxACC_SELF)
57 return wxACC_NOT_IMPLEMENTED;
58
59 if(mAccSilent)
60 *name = wxEmptyString; // Jaws reads nothing, and nvda reads "unknown"
61 else
62 {
63 const auto button = static_cast<AButton*>(GetWindow());
64
65 *name = button->GetName();
66
67 if(const auto panel = mAssociatedMeterPanel.get())
68 {
69 // translations of strings such as " Monitoring " did not
70 // always retain the leading space. Therefore a space has
71 // been added to ensure at least one space, and stop
72 // words from being merged
73 if(panel->IsMonitoring())
74 *name += wxT(" ") + _(" Monitoring ");
75 else if(panel->IsActive())
76 *name += wxT(" ") + _(" Active ");
77
78 const auto dbRange = panel->GetDBRange();
79 if (dbRange != -1)
80 *name += wxT(" ") + wxString::Format(_(" Peak %2.f dB"), panel->GetPeakHold() * dbRange - dbRange);
81 else
82 *name += wxT(" ") + wxString::Format(_(" Peak %.2f "), panel->GetPeakHold());
83
84 if(panel->IsClipping())
85 *name += wxT(" ") + _(" Clipped ");
86 }
87 }
88 return wxACC_OK;
89 }
90
91 wxAccStatus GetRole(int childId, wxAccRole* role) override
92 {
93 if(childId != wxACC_SELF)
94 return wxACC_NOT_IMPLEMENTED;
95
96 if(mAccSilent)
97 *role = wxROLE_NONE; // Jaws and nvda both read nothing
98 else
99 *role = wxROLE_SYSTEM_PUSHBUTTON;
100 return wxACC_OK;

Callers 1

PopulateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected