12#ifndef __AUDACITY_BUTTON__
13#define __AUDACITY_BUTTON__
26#if wxUSE_ACCESSIBILITY
32 AButtonAx(wxWindow * window);
34 virtual ~ AButtonAx();
40 wxAccStatus DoDefaultAction(
int childId)
override;
44 wxAccStatus GetChild(
int childId, wxAccessible** child)
override;
47 wxAccStatus GetChildCount(
int* childCount)
override;
55 wxAccStatus GetDefaultAction(
int childId, wxString *actionName)
override;
58 wxAccStatus GetDescription(
int childId, wxString *description)
override;
64 wxAccStatus GetFocus(
int *childId, wxAccessible **child)
override;
67 wxAccStatus GetHelpText(
int childId, wxString *helpText)
override;
71 wxAccStatus GetKeyboardShortcut(
int childId, wxString *shortcut)
override;
75 wxAccStatus GetLocation(wxRect& rect,
int elementId)
override;
78 wxAccStatus GetName(
int childId, wxString *
name)
override;
81 wxAccStatus GetRole(
int childId, wxAccRole *role)
override;
91 wxAccStatus GetSelections(wxVariant *selections)
override;
94 wxAccStatus GetState(
int childId,
long* state)
override;
98 wxAccStatus GetValue(
int childId, wxString* strValue)
override;
104class AUDACITY_DLL_API
AButton :
public wxWindow {
105 friend class AButtonAx;
117 AButton(wxWindow* parent =
nullptr,
118 wxWindowID
id = wxID_ANY,
119 const wxPoint& pos = wxDefaultPosition,
120 const wxSize&
size = wxDefaultSize,
121 bool toggle =
false);
138 void SetButtonType(Type type);
149 void SetFocusFromKbd()
override;
152 void SetImages(
const wxImage& up,
160 void SetAlternateImages(
unsigned idx,
167 void SetIcon(
const wxImage& icon);
170 void SetAlternateIdx(
unsigned idx);
175 void FollowModifierKeys();
177 void SetFocusRect(
const wxRect & r);
183 state ? Enable() : Disable();
189 void OnErase(wxEraseEvent & event);
190 void OnPaint(wxPaintEvent & event);
191 void OnSize(wxSizeEvent & event);
192 void OnMouseEvent(wxMouseEvent & event);
198 void OnCaptureLost(wxMouseCaptureLostEvent & event);
199 void OnKeyDown(wxKeyEvent & event);
200 void OnSetFocus(wxFocusEvent & event);
201 void OnKillFocus(wxFocusEvent & event);
202 void OnCharHook(wxKeyEvent& event);
206 bool WasControlDown();
218 void InteractionOver(){
if( !mToggle ) PopUp();}
219 void Toggle(){ mButtonIsDown ? PopUp() : PushDown();}
221 void SetShift(
bool shift);
222 void SetControl(
bool control);
224 wxSize DoGetBestClientSize()
const override;
236 AButtonState GetState();
238 void UseDisabledAsDownHiliteImage(
bool flag);
242 struct Resetter {
void operator () (
bool *p)
const {
if(p) *p =
false; } };
250 bool HasAlternateImages(
unsigned idx)
const;
252 void Init(wxWindow* parent, wxWindowID
id,
const wxPoint& pos,
const wxSize&
size,
bool toggle);
254 unsigned mAlternateIdx{0};
262 bool mWasShiftDown {
false};
263 bool mWasControlDown {
false};
265 bool mCursorIsInWindow{
false};
266 bool mButtonIsDown{
false};
267 bool mIsClicking{
false};
269 bool mUseDisabledAsDownHiliteImage{
false};
270 bool mIsDoubleClicked{
false};
273 std::vector<std::array<wxImage, AButtonStateCount>>
mImages;
276 bool mForceFocusRect{
false};
284 DECLARE_EVENT_TABLE()
const TranslatableString name
static void OnSize(wxSizeEvent &evt)
Holds a msgid for the translation catalog; may also bind format arguments.
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...