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;
129 AButton(wxWindow* parent =
nullptr,
130 wxWindowID
id = wxID_ANY,
131 const wxPoint& pos = wxDefaultPosition,
132 const wxSize&
size = wxDefaultSize,
133 bool toggle =
false);
150 void SetButtonType(Type type);
151 void SetFrameMid(
int mid);
162 void SetFocusFromKbd()
override;
165 void SetImages(
const wxImage& up,
173 void SetAlternateImages(
unsigned idx,
180 void SetIcon(
const wxImage& icon);
181 void SetIcon(AButtonState state,
const wxImage& icon);
184 void SetAlternateIcon(
unsigned idx,
const wxImage& icon);
185 void SetAlternateIcon(
unsigned idx, AButtonState state,
const wxImage& icon);
186 void SetAlternateIcons(
unsigned idx,
const wxImage& up,
const wxImage& down,
const wxImage& disabled);
189 void SetAlternateIdx(
unsigned idx);
194 void FollowModifierKeys();
196 void SetFocusRect(
const wxRect & r);
202 state ? Enable() : Disable();
208 void OnErase(wxEraseEvent & event);
209 void OnPaint(wxPaintEvent & event);
210 void OnSize(wxSizeEvent & event);
211 void OnMouseEvent(wxMouseEvent & event);
217 void OnCaptureLost(wxMouseCaptureLostEvent & event);
218 void OnKeyDown(wxKeyEvent & event);
219 void OnSetFocus(wxFocusEvent & event);
220 void OnKillFocus(wxFocusEvent & event);
221 void OnCharHook(wxKeyEvent& event);
225 bool WasControlDown();
237 void InteractionOver(){
if( !mToggle ) PopUp();}
238 void Toggle(){ mButtonIsDown ? PopUp() : PushDown();}
240 void SetShift(
bool shift);
241 void SetControl(
bool control);
243 wxSize DoGetBestClientSize()
const override;
245 AButtonState GetState();
247 void UseDisabledAsDownHiliteImage(
bool flag);
251 struct Resetter {
void operator () (
bool *p)
const {
if(p) *p =
false; } };
259 bool HasAlternateImages(
unsigned idx)
const;
261 void Init(wxWindow* parent, wxWindowID
id,
const wxPoint& pos,
const wxSize&
size,
bool toggle);
263 unsigned mAlternateIdx{0};
271 bool mWasShiftDown {
false};
272 bool mWasControlDown {
false};
274 bool mCursorIsInWindow{
false};
275 bool mButtonIsDown{
false};
276 bool mIsClicking{
false};
278 bool mUseDisabledAsDownHiliteImage{
false};
279 bool mIsDoubleClicked{
false};
281 std::vector<std::array<wxImage, AButtonStateCount>>
mIcons;
282 std::vector<std::array<wxImage, AButtonStateCount>>
mImages;
285 bool mForceFocusRect{
false};
294 DECLARE_EVENT_TABLE()
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 ...