32#include <wx/dcbuffer.h>
33#include <wx/eventfilter.h>
40#include "../ProjectWindowBase.h"
41#include <wx/tooltip.h>
43#if wxUSE_ACCESSIBILITY
49 AButtonAx(wxWindow * window);
51 virtual ~ AButtonAx();
57 wxAccStatus DoDefaultAction(
int childId)
override;
61 wxAccStatus GetChild(
int childId, wxAccessible** child)
override;
64 wxAccStatus GetChildCount(
int* childCount)
override;
72 wxAccStatus GetDefaultAction(
int childId, wxString *actionName)
override;
75 wxAccStatus GetDescription(
int childId, wxString *description)
override;
81 wxAccStatus GetFocus(
int *childId, wxAccessible **child)
override;
84 wxAccStatus GetHelpText(
int childId, wxString *helpText)
override;
88 wxAccStatus GetKeyboardShortcut(
int childId, wxString *shortcut)
override;
92 wxAccStatus GetLocation(wxRect& rect,
int elementId)
override;
95 wxAccStatus GetName(
int childId, wxString *
name)
override;
98 wxAccStatus GetRole(
int childId, wxAccRole *role)
override;
108 wxAccStatus GetSelections(wxVariant *selections)
override;
111 wxAccStatus GetState(
int childId,
long* state)
override;
115 wxAccStatus GetValue(
int childId, wxString* strValue)
override;
121BEGIN_EVENT_TABLE(
AButton, wxWindow)
135 : public wxEventFilter
141 int FilterEvent(wxEvent &event)
override;
152 wxEvtHandler::AddFilter(
this);
157 wxEvtHandler::RemoveFilter(
this);
162 if (!mButton->IsDown())
170 if (wxGetKeyState(WXK_CONTROL) && mButton->HasAlternateImages(2))
172 else if (wxGetKeyState(WXK_SHIFT) && mButton->HasAlternateImages(1))
177 mButton->SetAlternateIdx(idx);
183 if (event.GetEventType() == wxEVT_KEY_DOWN ||
184 event.GetEventType() == wxEVT_KEY_UP)
186 else if (event.GetEventType() == wxEVT_SET_FOCUS)
207 up, over, down, overDown, dis,
232 Create(parent,
id, pos,
size, wxWANTS_CHARS);
255 SetMinSize(
mImages[0].mArr[0].GetMinSize());
256 SetMaxSize(
mImages[0].mArr[0].GetMaxSize());
258#if wxUSE_ACCESSIBILITY
316 mImages[idx].mArr[3] = overDown;
333 mListener = std::make_unique<Listener>(
this);
387 wxBufferedPaintDC dc(
this);
393 if(
this == wxWindow::FindFocus() )
422 return (arr[0].Ok() &&
431 wxSize clientSize = GetClientSize();
434 if (event.Entering()) {
437 auto text = GetToolTipText();
439 wxWindow::SetToolTip(text);
442 else if (event.Leaving())
446 (
event.m_x >= 0 &&
event.m_y >= 0 &&
447 event.m_x < clientSize.x &&
event.m_y < clientSize.y);
450 if (event.ButtonIsDown(wxMOUSE_BTN_LEFT)) {
452 if (event.ButtonDClick())
480 if (newState != prevState) {
500 wxToolTip * pTip = this->GetToolTip();
502 auto tipText =
Verbatim( pTip->GetTip() );
504 tipText.Join(
XO(
"(disabled)"),
" " );
515 wxMouseEvent e(wxEVT_LEFT_UP);
525 switch( event.GetKeyCode() )
528 Navigate(wxNavigationKeyEvent::IsForward);
531 Navigate(wxNavigationKeyEvent::IsBackward);
534 Navigate(event.ShiftDown()
535 ? wxNavigationKeyEvent::IsBackward
536 : wxNavigationKeyEvent::IsForward);
539 case WXK_NUMPAD_ENTER:
573 bool changed = wxWindow::Enable(
true);
587 wxWindow::Enable(
false);
589 if (GetCapture()==
this)
601 this->Refresh(
false);
610 this->Refresh(
false);
613 if (GetCapture()==
this)
620 event.SetEventObject(
this);
623 GetEventHandler()->SafelyProcessEvent(event);
637 s_AcceptsFocus =
true;
641#if wxUSE_ACCESSIBILITY
643AButtonAx::AButtonAx( wxWindow *window ):
648AButtonAx::~AButtonAx()
656wxAccStatus AButtonAx::DoDefaultAction(
int WXUNUSED(childId))
671wxAccStatus AButtonAx::GetChild(
int childId, wxAccessible** child )
673 if( childId == wxACC_SELF )
686wxAccStatus AButtonAx::GetChildCount(
int* childCount)
700wxAccStatus AButtonAx::GetDefaultAction(
int WXUNUSED(childId), wxString* actionName)
702 *actionName =
_(
"Press" );
708wxAccStatus AButtonAx::GetDescription(
int WXUNUSED(childId), wxString *description )
710 description->clear();
719wxAccStatus AButtonAx::GetFocus(
int* childId, wxAccessible** child)
728wxAccStatus AButtonAx::GetHelpText(
int WXUNUSED(childId), wxString *helpText )
733 wxToolTip *pTip = ab->GetToolTip();
736 *helpText = pTip->GetTip();
743 return wxACC_NOT_SUPPORTED;
749wxAccStatus AButtonAx::GetKeyboardShortcut(
int WXUNUSED(childId), wxString *shortcut )
758wxAccStatus AButtonAx::GetLocation( wxRect& rect,
int WXUNUSED(elementId) )
762 rect = ab->GetRect();
763 rect.SetPosition( ab->GetParent()->ClientToScreen( rect.GetPosition() ) );
769wxAccStatus AButtonAx::GetName(
int WXUNUSED(childId), wxString*
name)
773 *
name = ab->GetName();
776 *
name = ab->GetLabel();
788wxAccStatus AButtonAx::GetRole(
int WXUNUSED(childId), wxAccRole* role)
790 *role = wxROLE_SYSTEM_PUSHBUTTON;
803wxAccStatus AButtonAx::GetSelections( wxVariant * WXUNUSED(selections) )
805 return wxACC_NOT_IMPLEMENTED;
809wxAccStatus AButtonAx::GetState(
int WXUNUSED(childId),
long* state)
816 *state = wxACC_STATE_SYSTEM_PRESSED | wxACC_STATE_SYSTEM_FOCUSABLE;
820 *state = wxACC_STATE_SYSTEM_HOTTRACKED | wxACC_STATE_SYSTEM_FOCUSABLE;
824 *state = wxACC_STATE_SYSTEM_HOTTRACKED | wxACC_STATE_SYSTEM_PRESSED |
825 wxACC_STATE_SYSTEM_FOCUSABLE;
829 *state = wxACC_STATE_SYSTEM_UNAVAILABLE;
833 *state = wxACC_STATE_SYSTEM_FOCUSABLE;
837 *state |= ( ab == wxWindow::FindFocus() ? wxACC_STATE_SYSTEM_FOCUSED : 0 );
844wxAccStatus AButtonAx::GetValue(
int WXUNUSED(childId), wxString* WXUNUSED(strValue))
846 return wxACC_NOT_SUPPORTED;
wxEVT_COMMAND_BUTTON_CLICKED
const TranslatableString name
AudacityProject * FindProjectFromWindow(wxWindow *pWindow)
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
static void DrawFocus(wxDC &dc, wxRect &r)
An ImageRoll is an image that can be expanded to an arbitrary size; it is made up of both fixed piece...
static ProjectStatus & Get(AudacityProject &project)
void Set(const TranslatableString &msg, StatusBarField field=mainStatusBarField)
Holds a msgid for the translation catalog; may also bind format arguments.
wxString Translation() const
TranslatableString Stripped(unsigned options=MenuCodes) const
non-mutating, constructs another TranslatableString object
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...