Audacity 3.2.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
AButton Class Reference

A wxButton with mouse-over behaviour. More...

#include <AButton.h>

Inheritance diagram for AButton:
[legend]
Collaboration diagram for AButton:
[legend]

Classes

class  Listener
 
struct  Resetter
 

Public Types

enum  Type { TextButton , ImageButton , FrameButton }
 
enum  AButtonState {
  AButtonUp , AButtonOver , AButtonDown , AButtonOverDown ,
  AButtonDis , AButtonStateCount
}
 

Public Member Functions

 AButton (wxWindow *parent=nullptr, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, bool toggle=false)
 
 AButton (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxImage &up, const wxImage &over, const wxImage &down, const wxImage &overDown, const wxImage &dis, bool toggle)
 
virtual ~AButton ()
 
void SetButtonType (Type type)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetLabel (const TranslatableString &label)
 
bool AcceptsFocus () const override
 
bool AcceptsFocusFromKeyboard () const override
 
void SetFocusFromKbd () override
 
void SetImages (const wxImage &up, const wxImage &over, const wxImage &down, const wxImage &overDown, const wxImage &dis)
 
void SetAlternateImages (unsigned idx, const wxImage &up, const wxImage &over, const wxImage &down, const wxImage &overDown, const wxImage &dis)
 
void SetIcon (const wxImage &icon)
 
void SetAlternateIdx (unsigned idx)
 
void FollowModifierKeys ()
 
void SetFocusRect (const wxRect &r)
 
bool IsEnabled () const
 
void Disable ()
 
void Enable ()
 
void SetEnabled (bool state)
 
void PushDown ()
 
void PopUp ()
 
void OnErase (wxEraseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
void OnSize (wxSizeEvent &event)
 
void OnMouseEvent (wxMouseEvent &event)
 
void UpdateStatus ()
 
void OnCaptureLost (wxMouseCaptureLostEvent &event)
 
void OnKeyDown (wxKeyEvent &event)
 
void OnSetFocus (wxFocusEvent &event)
 
void OnKillFocus (wxFocusEvent &event)
 
void OnCharHook (wxKeyEvent &event)
 
bool WasShiftDown ()
 
bool WasControlDown ()
 
bool IsDown ()
 
bool IsDoubleClicked () const
 
void ClearDoubleClicked ()
 
void SetButtonToggles (bool toggler)
 
bool IsToggle () const noexcept
 
void InteractionOver ()
 
void Toggle ()
 
void Click ()
 
void SetShift (bool shift)
 
void SetControl (bool control)
 
wxSize DoGetBestClientSize () const override
 
AButtonState GetState ()
 
void UseDisabledAsDownHiliteImage (bool flag)
 

Static Public Member Functions

static TempAllowFocus TemporarilyAllowFocus ()
 

Private Types

using TempAllowFocus = std::unique_ptr< bool, Resetter >
 

Private Member Functions

bool HasAlternateImages (unsigned idx) const
 
void Init (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, bool toggle)
 

Private Attributes

unsigned mAlternateIdx {0}
 
bool mToggle {false}
 
bool mWasShiftDown {false}
 
bool mWasControlDown {false}
 
bool mCursorIsInWindow {false}
 
bool mButtonIsDown {false}
 
bool mIsClicking {false}
 
bool mEnabled {true}
 
bool mUseDisabledAsDownHiliteImage {false}
 
bool mIsDoubleClicked {false}
 
wxImage mIcon
 
std::vector< std::array< wxImage, AButtonStateCount > > mImages
 
wxRect mFocusRect
 
bool mForceFocusRect {false}
 
std::unique_ptr< ListenermListener
 
Type mType {ImageButton}
 

Static Private Attributes

static bool s_AcceptsFocus { false }
 

Friends

class AButtonAx
 

Detailed Description

A wxButton with mouse-over behaviour.

AButton is a custom button class for Audacity. The main feature it supports that a wxButton does not is mouseovers.

It uses an image for all of its states: up, over, down, and disabled, allowing any sort of customization you want. Currently it does not support transparency effects, so the image musts be rectangular and opaque.

Definition at line 104 of file AButton.h.

Member Typedef Documentation

◆ TempAllowFocus

using AButton::TempAllowFocus = std::unique_ptr<bool, Resetter>
private

Definition at line 243 of file AButton.h.

Member Enumeration Documentation

◆ AButtonState

Enumerator
AButtonUp 
AButtonOver 
AButtonDown 
AButtonOverDown 
AButtonDis 
AButtonStateCount 

Definition at line 226 of file AButton.h.

226 {
227 AButtonUp,
232
234 };
@ AButtonStateCount
Definition: AButton.h:233
@ AButtonUp
Definition: AButton.h:227
@ AButtonDis
Definition: AButton.h:231
@ AButtonOver
Definition: AButton.h:228
@ AButtonDown
Definition: AButton.h:229
@ AButtonOverDown
Definition: AButton.h:230

◆ Type

Enumerator
TextButton 
ImageButton 
FrameButton 

Definition at line 110 of file AButton.h.

111 {
115 };
@ TextButton
Definition: AButton.h:112
@ FrameButton
Definition: AButton.h:114
@ ImageButton
Definition: AButton.h:113

Constructor & Destructor Documentation

◆ AButton() [1/2]

AButton::AButton ( wxWindow *  parent = nullptr,
wxWindowID  id = wxID_ANY,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
bool  toggle = false 
)

Definition at line 117 of file AButton.cpp.

118{
119 Init(parent, id, pos, size, toggle);
120}
void Init(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, bool toggle)
Definition: AButton.cpp:159

References Init(), and size.

Here is the call graph for this function:

◆ AButton() [2/2]

AButton::AButton ( wxWindow *  parent,
wxWindowID  id,
const wxPoint &  pos,
const wxSize &  size,
const wxImage up,
const wxImage over,
const wxImage down,
const wxImage overDown,
const wxImage dis,
bool  toggle 
)

Definition at line 122 of file AButton.cpp.

132{
133 Init(parent, id, pos, size, toggle);
134
135 SetAlternateImages(0, up, over, down, overDown, dis);
136
137 SetMinSize(mImages[0][AButtonUp].GetSize());
138 SetMaxSize(mImages[0][AButtonUp].GetSize());
139}
void SetAlternateImages(unsigned idx, const wxImage &up, const wxImage &over, const wxImage &down, const wxImage &overDown, const wxImage &dis)
Definition: AButton.cpp:210
std::vector< std::array< wxImage, AButtonStateCount > > mImages
Definition: AButton.h:273

References AButtonUp, Init(), mImages, SetAlternateImages(), and size.

Here is the call graph for this function:

◆ ~AButton()

AButton::~AButton ( )
virtual

Definition at line 141 of file AButton.cpp.

142{
143 if(HasCapture())
144 ReleaseMouse();
145}

Member Function Documentation

◆ AcceptsFocus()

bool AButton::AcceptsFocus ( ) const
inlineoverride

Definition at line 146 of file AButton.h.

146{ return s_AcceptsFocus; }
static bool s_AcceptsFocus
Definition: AButton.h:241

◆ AcceptsFocusFromKeyboard()

bool AButton::AcceptsFocusFromKeyboard ( ) const
inlineoverride

Definition at line 147 of file AButton.h.

147{ return mEnabled; }
bool mEnabled
Definition: AButton.h:268

◆ ClearDoubleClicked()

void AButton::ClearDoubleClicked ( )
inline

Definition at line 212 of file AButton.h.

212{ mIsDoubleClicked = false; }
bool mIsDoubleClicked
Definition: AButton.h:270

◆ Click()

void AButton::Click ( )

Definition at line 597 of file AButton.cpp.

598{
599 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetId());
600 event.SetEventObject(this);
601 // Be sure to use SafelyProcessEvent so that exceptions do not propagate
602 // out of DoDefaultAction
603 GetEventHandler()->SafelyProcessEvent(event);
604}
wxEVT_COMMAND_BUTTON_CLICKED

References wxEVT_COMMAND_BUTTON_CLICKED.

Referenced by OnCharHook(), and OnMouseEvent().

Here is the caller graph for this function:

◆ Disable()

void AButton::Disable ( )

Definition at line 560 of file AButton.cpp.

561{
562 // Bug 1565: Tooltips not showing on disabled buttons.
563 // The fix is to NOT tell windows that the button is disabled.
564 // The button's appearance will still change to show it is disabled
565 // since we control that rather than windows.
566#ifndef __WXMSW__
567 wxWindow::Enable(false);
568#endif
569 if (GetCapture()==this)
570 ReleaseMouse();
571 if ( mEnabled ) {
572 mEnabled = false;
573 Refresh(false);
574 }
575}

References mEnabled.

Referenced by TranscriptionToolBar::Create(), AudioSetupToolBar::EnableDisableButtons(), and RealtimeEffectPanel::ResetTrack().

Here is the caller graph for this function:

◆ DoGetBestClientSize()

wxSize AButton::DoGetBestClientSize ( ) const
override

Definition at line 616 of file AButton.cpp.

617{
619 {
620 const auto& image = mImages[mAlternateIdx][AButtonUp];
621 switch(mType)
622 {
623 case FrameButton:
624 {
625 if(!GetLabel().IsEmpty())
626 {
627 const auto border = image.GetSize() / 4;
628
629 wxMemoryDC dc;
630 dc.SetFont(GetFont());
631 auto bestSize = dc.GetTextExtent(GetLabel());
632 if(mIcon.IsOk())
633 {
634 bestSize.x = std::max(bestSize.x, mIcon.GetWidth());
635 bestSize.y = bestSize.y > 0
636 ? bestSize.y + border.y + mIcon.GetHeight()
637 : mIcon.GetHeight();
638 }
639 if(bestSize.x > 0)
640 bestSize.x += border.x * 2;
641 if(bestSize.y > 0)
642 bestSize.y += border.y * 2;
643 return bestSize;
644 }
645 if(mIcon.Ok())
646 return mIcon.GetSize();
647 return image.GetSize();
648 }
649 case TextButton:
650 return {-1, image.GetHeight() };
651 default:
652 return image.GetSize();
653 }
654 }
655 return wxWindow::DoGetBestClientSize();
656}
bool HasAlternateImages(unsigned idx) const
Definition: AButton.cpp:378
Type mType
Definition: AButton.h:280
wxImage mIcon
Definition: AButton.h:272
unsigned mAlternateIdx
Definition: AButton.h:254

References AButtonUp, FrameButton, HasAlternateImages(), mAlternateIdx, mIcon, mImages, mType, and TextButton.

Here is the call graph for this function:

◆ Enable()

void AButton::Enable ( )

Definition at line 551 of file AButton.cpp.

552{
553 bool changed = wxWindow::Enable(true);
554 if ( !mEnabled ) {
555 mEnabled = true;
556 Refresh(false);
557 }
558}

References mEnabled.

Referenced by TranscriptionToolBar::Create(), AudioSetupToolBar::EnableDisableButtons(), and RealtimeEffectPanel::SetTrack().

Here is the caller graph for this function:

◆ FollowModifierKeys()

void AButton::FollowModifierKeys ( )

Definition at line 243 of file AButton.cpp.

244{
245 if(!mListener)
246 mListener = std::make_unique<Listener>(this);
247}
std::unique_ptr< Listener > mListener
Definition: AButton.h:278

References mListener.

Referenced by ControlToolBar::Populate(), and TranscriptionToolBar::Populate().

Here is the caller graph for this function:

◆ GetState()

AButton::AButtonState AButton::GetState ( )

Definition at line 255 of file AButton.cpp.

256{
257 AButtonState state;
258
259 if (!mEnabled && (!mToggle || !mButtonIsDown))
260 return AButtonDis;
261
262 if (mCursorIsInWindow) {
263 if (mToggle) {
264 if (mIsClicking) {
268 }
269 }
270 else {
274 }
275 }
276 }
277 else {
278 if (mIsClicking) {
280 }
281 else {
283 }
284 }
285 }
286 else {
288 }
289
290 return state;
291}
bool mUseDisabledAsDownHiliteImage
Definition: AButton.h:269
bool mButtonIsDown
Definition: AButton.h:266
bool mCursorIsInWindow
Definition: AButton.h:265
AButtonState
Definition: AButton.h:226
bool mIsClicking
Definition: AButton.h:267
bool mToggle
Definition: AButton.h:255

References AButtonDis, AButtonDown, AButtonOver, AButtonOverDown, AButtonUp, mButtonIsDown, mCursorIsInWindow, mEnabled, mIsClicking, mToggle, and mUseDisabledAsDownHiliteImage.

Referenced by OnMouseEvent(), and OnPaint().

Here is the caller graph for this function:

◆ HasAlternateImages()

bool AButton::HasAlternateImages ( unsigned  idx) const
private

Definition at line 378 of file AButton.cpp.

379{
380 if (mImages.size() <= idx)
381 return false;
382
383 const auto &arr = mImages[idx];
384 return (arr[0].Ok() &&
385 arr[1].Ok() &&
386 arr[2].Ok() &&
387 arr[3].Ok() &&
388 arr[4].Ok());
389}
@ Ok
One button.

References mImages.

Referenced by DoGetBestClientSize(), and OnPaint().

Here is the caller graph for this function:

◆ Init()

void AButton::Init ( wxWindow *  parent,
wxWindowID  id,
const wxPoint &  pos,
const wxSize &  size,
bool  toggle 
)
private

Definition at line 159 of file AButton.cpp.

160{
161 SetBackgroundStyle(wxBG_STYLE_PAINT);
162
163 // Bug in wxWidgets 2.8.12: by default pressing Enter on an AButton is interpreted as
164 // a navigation event - move to next control. As a workaround, the style wxWANTS_CHARS
165 // results in all characters being available in the OnKeyDown function below. Note
166 // that OnKeyDown now has to handle navigation.
167 Create(parent, id, pos, size, wxWANTS_CHARS);
168
169 mToggle = toggle;
170
171 mFocusRect = GetClientRect().Deflate( 3, 3 );
172
173#if wxUSE_ACCESSIBILITY
174 SetName( wxT("") );
175 SetAccessible(safenew AButtonAx(this));
176#endif
177}
wxT("CloseDown"))
#define safenew
Definition: MemoryX.h:9
wxRect mFocusRect
Definition: AButton.h:275
friend class AButtonAx
Definition: AButton.h:105

References AButtonAx, mFocusRect, mToggle, safenew, size, and wxT().

Referenced by AButton().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InteractionOver()

void AButton::InteractionOver ( )
inline

Definition at line 218 of file AButton.h.

218{ if( !mToggle ) PopUp();}
void PopUp()
Definition: AButton.cpp:585

◆ IsDoubleClicked()

bool AButton::IsDoubleClicked ( ) const
inline

Definition at line 211 of file AButton.h.

211{ return mIsDoubleClicked; }

◆ IsDown()

bool AButton::IsDown ( )
inline

Definition at line 208 of file AButton.h.

208{ return mButtonIsDown;}

Referenced by ControlToolBar::EnableDisableButtons(), EffectUIHost::OnEnable(), RealtimeEffectPanel::RealtimeEffectPanel(), AudioSetupToolBar::ReCreateButtons(), ControlToolBar::ReCreateButtons(), and ControlToolBar::StateForStatusBar().

Here is the caller graph for this function:

◆ IsEnabled()

bool AButton::IsEnabled ( ) const
inline

Definition at line 179 of file AButton.h.

179{ return mEnabled; }

◆ IsToggle()

bool AButton::IsToggle ( ) const
noexcept

◆ OnCaptureLost()

void AButton::OnCaptureLost ( wxMouseCaptureLostEvent &  event)

Definition at line 473 of file AButton.cpp.

474{
475 wxMouseEvent e(wxEVT_LEFT_UP);
476 e.m_x = -1;
477 e.m_y = -1;
478 OnMouseEvent(e);
479}
void OnMouseEvent(wxMouseEvent &event)
Definition: AButton.cpp:391

References OnMouseEvent().

Here is the call graph for this function:

◆ OnCharHook()

void AButton::OnCharHook ( wxKeyEvent &  event)

Definition at line 505 of file AButton.cpp.

506{
507 switch(event.GetKeyCode())
508 {
509 case WXK_RETURN:
510 case WXK_NUMPAD_ENTER:
511 if( !mEnabled )
512 break;
513 mWasShiftDown = event.ShiftDown();
514 mWasControlDown = event.ControlDown();
515 if(mToggle)
516 {
518 Refresh(false);
519#if wxUSE_ACCESSIBILITY
520 GetAccessible()->NotifyEvent(wxACC_EVENT_OBJECT_NAMECHANGE,
521 this, wxOBJID_CLIENT, wxACC_SELF);
522#endif
523 }
524 Click();
525 break;
526 default:
527 event.Skip();
528 }
529}
bool mWasShiftDown
Definition: AButton.h:262
void Click()
Definition: AButton.cpp:597
bool mWasControlDown
Definition: AButton.h:263

References Click(), mButtonIsDown, mEnabled, mToggle, mWasControlDown, and mWasShiftDown.

Here is the call graph for this function:

◆ OnErase()

void AButton::OnErase ( wxEraseEvent &  event)

Definition at line 362 of file AButton.cpp.

363{
364 // Ignore it to prevent flashing
365}

◆ OnKeyDown()

void AButton::OnKeyDown ( wxKeyEvent &  event)

Definition at line 483 of file AButton.cpp.

484{
485 switch( event.GetKeyCode() )
486 {
487 case WXK_RIGHT:
488 case WXK_DOWN:
489 Navigate(wxNavigationKeyEvent::IsForward);
490 break;
491 case WXK_LEFT:
492 case WXK_UP:
493 Navigate(wxNavigationKeyEvent::IsBackward);
494 break;
495 case WXK_TAB:
496 Navigate(wxNavigationKeyEvent::FromTab | (event.ShiftDown()
497 ? wxNavigationKeyEvent::IsBackward
498 : wxNavigationKeyEvent::IsForward));
499 break;
500 default:
501 event.Skip();
502 }
503}

◆ OnKillFocus()

void AButton::OnKillFocus ( wxFocusEvent &  event)

Definition at line 536 of file AButton.cpp.

537{
538 Refresh( false );
539}

◆ OnMouseEvent()

void AButton::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 391 of file AButton.cpp.

392{
393 wxSize clientSize = GetClientSize();
394 AButtonState prevState = GetState();
395
396 if (event.Entering()) {
397 // Bug 1201: On Mac, unsetting and re-setting the tooltip may be needed
398 // to make it pop up when we want it.
399 auto text = GetToolTipText();
400 UnsetToolTip();
401 wxWindow::SetToolTip(text);
402 mCursorIsInWindow = true;
403 }
404 else if (event.Leaving())
405 mCursorIsInWindow = false;
406 else
408 (event.m_x >= 0 && event.m_y >= 0 &&
409 event.m_x < clientSize.x && event.m_y < clientSize.y);
410
411 if (mEnabled && event.IsButton()) {
412 if (event.ButtonIsDown(wxMOUSE_BTN_LEFT)) {
413 mIsClicking = true;
414 if (event.ButtonDClick())
415 mIsDoubleClicked = true;
416 if( !HasCapture() )
417 CaptureMouse();
418 }
419 else if (mIsClicking) {
420 mIsClicking = false;
421
422 if (HasCapture())
423 ReleaseMouse();
424
426 if (mToggle)
428
429 mWasShiftDown = event.ShiftDown();
430 mWasControlDown = event.ControlDown();
431
432 Click();
433 }
434 }
435 }
436
437 // Only redraw and change tooltips if the state has changed.
438 AButtonState newState = GetState();
439
440 if (newState != prevState) {
441 Refresh(false);
442
444 UpdateStatus();
445 else {
446 auto pProject = FindProjectFromWindow( this );
447 if (pProject)
448 ProjectStatus::Get( *pProject ).Set({});
449 }
450 }
451 else
452 event.Skip();
453}
AudacityProject * FindProjectFromWindow(wxWindow *pWindow)
void UpdateStatus()
Definition: AButton.cpp:455
AButtonState GetState()
Definition: AButton.cpp:255
static ProjectStatus & Get(AudacityProject &project)
void Set(const TranslatableString &msg, StatusBarField field=MainStatusBarField())

References Click(), FindProjectFromWindow(), ProjectStatus::Get(), GetState(), mButtonIsDown, mCursorIsInWindow, mEnabled, mIsClicking, mIsDoubleClicked, mToggle, mWasControlDown, mWasShiftDown, ProjectStatus::Set(), and UpdateStatus().

Referenced by OnCaptureLost().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnPaint()

void AButton::OnPaint ( wxPaintEvent &  event)

Definition at line 293 of file AButton.cpp.

294{
295 wxBufferedPaintDC dc(this);
296
297 dc.SetPen(*wxTRANSPARENT_PEN);
298 dc.SetBrush(GetBackgroundColour());
299 dc.Clear();
300
301 const auto buttonRect = GetClientRect();
303 {
304 AButtonState buttonState = GetState();
305 if(mType == ImageButton)
306 dc.DrawBitmap(mImages[mAlternateIdx][buttonState], buttonRect.GetTopLeft());
307 else if(mType == FrameButton)
308 {
309 wxBitmap bitmap = mImages[mAlternateIdx][buttonState];
310 AColor::DrawFrame(dc, buttonRect, bitmap);
311
312 const auto border = bitmap.GetSize() / 4;
313
314 if(!GetLabel().IsEmpty())
315 {
316 dc.SetFont(GetFont());
317 auto textRect = buttonRect;
318 if(mIcon.IsOk())
319 {
320 auto fontMetrics = dc.GetFontMetrics();
321 auto sumHeight = fontMetrics.height + mIcon.GetHeight() + border.y;
322 dc.DrawBitmap(mIcon,
323 buttonRect.x + (buttonRect.width - mIcon.GetWidth()) / 2,
324 buttonRect.y + (buttonRect.height - sumHeight) / 2);
325 textRect = wxRect(
326 buttonRect.x,
327 buttonRect.y + buttonRect.height / 2 + sumHeight / 2 - fontMetrics.height,
328 buttonRect.width,
329 fontMetrics.height);
330 }
331 dc.SetPen(GetForegroundColour());
332 dc.DrawLabel(GetLabel(), textRect, wxALIGN_CENTER);
333 }
334 else if(mIcon.IsOk())
335 {
336 dc.DrawBitmap(mIcon,
337 buttonRect.x + (buttonRect.width - mIcon.GetWidth()) / 2,
338 buttonRect.y + (buttonRect.height - mIcon.GetHeight()) / 2);
339 }
340 }
341 else
342 {
343 wxBitmap bitmap = mImages[mAlternateIdx][buttonState];
344 AColor::DrawHStretch(dc, GetClientRect(), bitmap);
345 if(!GetLabel().IsEmpty())
346 {
347 dc.SetFont(GetFont());
348 const auto text = TrackArt::TruncateText(dc, GetLabel(), GetClientSize().GetWidth() - 6);
349 if(!text.IsEmpty())
350 {
351 dc.SetPen(GetForegroundColour());
352 dc.DrawLabel(text, GetClientRect(), wxALIGN_CENTER);
353 }
354 }
355 }
356 }
357
358 if(HasFocus())
360}
static void DrawHStretch(wxDC &dc, const wxRect &rect, wxBitmap &bitmap)
Definition: AColor.cpp:308
static void DrawFrame(wxDC &dc, const wxRect &r, wxBitmap &bitmap)
Definition: AColor.cpp:325
static void DrawFocus(wxDC &dc, wxRect &r)
Definition: AColor.cpp:235
AUDACITY_DLL_API wxString TruncateText(wxDC &dc, const wxString &text, const int maxWidth)
Definition: TrackArt.cpp:173

References AColor::DrawFocus(), AColor::DrawFrame(), AColor::DrawHStretch(), FrameButton, GetState(), HasAlternateImages(), ImageButton, mAlternateIdx, mFocusRect, mIcon, mImages, mType, and TrackArt::TruncateText().

Here is the call graph for this function:

◆ OnSetFocus()

void AButton::OnSetFocus ( wxFocusEvent &  event)

Definition at line 531 of file AButton.cpp.

532{
533 Refresh( false );
534}

◆ OnSize()

void AButton::OnSize ( wxSizeEvent &  event)

Definition at line 367 of file AButton.cpp.

368{
369 if (!mForceFocusRect)
370 {
371 mFocusRect = GetClientRect().Deflate( 3, 3 );
372 }
373 Refresh(false);
374}
bool mForceFocusRect
Definition: AButton.h:276

References mFocusRect, and mForceFocusRect.

◆ PopUp()

void AButton::PopUp ( )

◆ PushDown()

void AButton::PushDown ( )

◆ SetAlternateIdx()

void AButton::SetAlternateIdx ( unsigned  idx)

Definition at line 232 of file AButton.cpp.

233{
234 // If alternate-image-state is already correct then
235 // nothing to do (saves repainting button).
236 if( mAlternateIdx == idx )
237 return;
238 mAlternateIdx = idx;
239 Refresh(false);
240 PostSizeEventToParent();
241}

References mAlternateIdx.

Referenced by MixerTrackCluster::OnButton_Mute(), MixerTrackCluster::OnButton_Solo(), ControlToolBar::OnIdle(), ControlToolBar::ReCreateButtons(), ControlToolBar::SetPlay(), TranscriptionToolBar::SetPlaying(), and MixerTrackCluster::UpdateForStateChange().

Here is the caller graph for this function:

◆ SetAlternateImages()

void AButton::SetAlternateImages ( unsigned  idx,
const wxImage up,
const wxImage over,
const wxImage down,
const wxImage overDown,
const wxImage dis 
)

Definition at line 210 of file AButton.cpp.

216{
217 if (1 + idx > mImages.size())
218 mImages.resize(1 + idx);
219 mImages[idx][AButtonUp] = up;
220 mImages[idx][AButtonOver] = over;
221 mImages[idx][AButtonDown] = down;
222 mImages[idx][AButtonOverDown] = overDown;
223 mImages[idx][AButtonDis] = dis;
224}

References AButtonDis, AButtonDown, AButtonOver, AButtonOverDown, AButtonUp, and mImages.

Referenced by AButton(), ToolBar::MakeAlternateImages(), and SetImages().

Here is the caller graph for this function:

◆ SetButtonToggles()

void AButton::SetButtonToggles ( bool  toggler)
inline

Definition at line 214 of file AButton.h.

214{ mToggle = toggler;}

◆ SetButtonType()

void AButton::SetButtonType ( Type  type)

Definition at line 147 of file AButton.cpp.

148{
149 if(mType != type)
150 {
151 mType = type;
152 InvalidateBestSize();
153 Refresh(false);
154 PostSizeEventToParent();
155 }
156}

References mType.

Referenced by AudioSetupToolBar::MakeAudioSetupButton(), SelectionBar::MakeSetupButton(), audacity::cloud::ShareAudioToolbar::MakeShareAudioButton(), and MeterToolBar::Populate().

Here is the caller graph for this function:

◆ SetControl()

void AButton::SetControl ( bool  control)

Definition at line 611 of file AButton.cpp.

612{
613 mWasControlDown = control;
614}

References mWasControlDown.

Referenced by ControlToolBar::SetPlay().

Here is the caller graph for this function:

◆ SetEnabled()

void AButton::SetEnabled ( bool  state)
inline

Definition at line 182 of file AButton.h.

182 {
183 state ? Enable() : Disable();
184 }
void Disable()
Definition: AButton.cpp:560
void Enable()
Definition: AButton.cpp:551

Referenced by audacity::cloud::ShareAudioToolbar::EnableDisableButtons(), ControlToolBar::EnableDisableButtons(), TranscriptionToolBar::EnableDisableButtons(), RealtimeEffectListWindow::ReloadEffectsList(), and TranscriptionToolBar::SetEnabled().

Here is the caller graph for this function:

◆ SetFocusFromKbd()

void AButton::SetFocusFromKbd ( )
override

Definition at line 199 of file AButton.cpp.

200{
201 auto temp = TemporarilyAllowFocus();
202 SetFocus();
203}
static TempAllowFocus TemporarilyAllowFocus()
Definition: AButton.cpp:658
void SetFocus(const WindowPlacement &focus)
Set the window that accepts keyboard input.
Definition: BasicUI.h:384

References BasicUI::SetFocus(), and TemporarilyAllowFocus().

Here is the call graph for this function:

◆ SetFocusRect()

void AButton::SetFocusRect ( const wxRect &  r)

Definition at line 249 of file AButton.cpp.

250{
251 mFocusRect = r;
252 mForceFocusRect = true;
253}

References mFocusRect, and mForceFocusRect.

Referenced by ToolBar::MakeButton().

Here is the caller graph for this function:

◆ SetIcon()

void AButton::SetIcon ( const wxImage icon)

Definition at line 226 of file AButton.cpp.

227{
228 mIcon = icon;
229 Refresh(false);
230}

References mIcon.

Referenced by AudioSetupToolBar::MakeAudioSetupButton(), audacity::cloud::ShareAudioToolbar::MakeShareAudioButton(), and MeterToolBar::Populate().

Here is the caller graph for this function:

◆ SetImages()

void AButton::SetImages ( const wxImage up,
const wxImage over,
const wxImage down,
const wxImage overDown,
const wxImage dis 
)

Definition at line 205 of file AButton.cpp.

206{
207 SetAlternateImages(0, up, over, down, overDown, dis);
208}

References SetAlternateImages().

Referenced by AudioSetupToolBar::MakeAudioSetupButton(), audacity::cloud::ShareAudioToolbar::MakeShareAudioButton(), and MeterToolBar::Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetLabel()

void AButton::SetLabel ( const TranslatableString label)

Definition at line 189 of file AButton.cpp.

190{
191 wxWindow::SetLabel( toolTip.Stripped().Translation() );
192 if(mType == FrameButton)
193 InvalidateBestSize();
194}

References FrameButton, mType, TranslatableString::Stripped(), and TranslatableString::Translation().

Referenced by TranscriptionToolBar::AddButton(), ToolBarButtons::CreateButton(), AudioSetupToolBar::MakeAudioSetupButton(), ToolBar::MakeButton(), audacity::cloud::ShareAudioToolbar::MakeShareAudioButton(), ToolsToolBar::MakeTool(), MeterToolBar::Populate(), and AdornedRulerPanel::UpdateButtonStates().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetShift()

void AButton::SetShift ( bool  shift)

Definition at line 606 of file AButton.cpp.

607{
608 mWasShiftDown = shift;
609}

References mWasShiftDown.

Referenced by ControlToolBar::SetPlay().

Here is the caller graph for this function:

◆ SetToolTip()

void AButton::SetToolTip ( const TranslatableString toolTip)

Definition at line 184 of file AButton.cpp.

185{
186 wxWindow::SetToolTip( toolTip.Stripped().Translation() );
187}
wxString Translation() const
TranslatableString Stripped(unsigned options=MenuCodes) const
non-mutating, constructs another TranslatableString object

References TranslatableString::Stripped(), and TranslatableString::Translation().

Referenced by MeterToolBar::Populate(), TranscriptionToolBar::RegenerateTooltips(), and ToolBar::SetButtonToolTip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TemporarilyAllowFocus()

auto AButton::TemporarilyAllowFocus ( )
static

Definition at line 658 of file AButton.cpp.

658 {
659 s_AcceptsFocus = true;
661}
std::unique_ptr< bool, Resetter > TempAllowFocus
Definition: AButton.h:243

References s_AcceptsFocus.

Referenced by anonymous_namespace{NavigationMenus.cpp}::NextOrPrevFrame(), ToolManager::RestoreFocus(), and SetFocusFromKbd().

Here is the caller graph for this function:

◆ Toggle()

void AButton::Toggle ( )
inline

Definition at line 219 of file AButton.h.

219{ mButtonIsDown ? PopUp() : PushDown();}
void PushDown()
Definition: AButton.cpp:577

◆ UpdateStatus()

void AButton::UpdateStatus ( )

Definition at line 455 of file AButton.cpp.

456{
457 if (mCursorIsInWindow) {
458#if wxUSE_TOOLTIPS // Not available in wxX11
459 // Display the tooltip in the status bar
460 wxToolTip * pTip = this->GetToolTip();
461 if( pTip ) {
462 auto tipText = Verbatim( pTip->GetTip() );
463 if (!mEnabled)
464 tipText.Join( XO("(disabled)"), " " );
465 auto pProject = FindProjectFromWindow( this );
466 if (pProject)
467 ProjectStatus::Get( *pProject ).Set( tipText );
468 }
469#endif
470 }
471}
XO("Cut/Copy/Paste")
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.

References FindProjectFromWindow(), ProjectStatus::Get(), mCursorIsInWindow, mEnabled, ProjectStatus::Set(), Verbatim(), and XO().

Referenced by OnMouseEvent(), and AdornedRulerPanel::UpdateButtonStates().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UseDisabledAsDownHiliteImage()

void AButton::UseDisabledAsDownHiliteImage ( bool  flag)

Definition at line 179 of file AButton.cpp.

180{
182}
static std::once_flag flag

References flag, and mUseDisabledAsDownHiliteImage.

◆ WasControlDown()

bool AButton::WasControlDown ( )

Definition at line 546 of file AButton.cpp.

547{
548 return mWasControlDown;
549}

References mWasControlDown.

Referenced by TranscriptionToolBar::OnPlaySpeed(), and ControlToolBar::PlayDefault().

Here is the caller graph for this function:

◆ WasShiftDown()

bool AButton::WasShiftDown ( )

Definition at line 541 of file AButton.cpp.

542{
543 return mWasShiftDown;
544}

References mWasShiftDown.

Referenced by MixerTrackCluster::OnButton_Mute(), MixerTrackCluster::OnButton_Solo(), ControlToolBar::OnFF(), ControlToolBar::OnRecord(), ControlToolBar::OnRewind(), ControlToolBar::PlayDefault(), and ControlToolBar::ReCreateButtons().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ AButtonAx

friend class AButtonAx
friend

Definition at line 105 of file AButton.h.

Referenced by Init().

Member Data Documentation

◆ mAlternateIdx

unsigned AButton::mAlternateIdx {0}
private

Definition at line 254 of file AButton.h.

Referenced by DoGetBestClientSize(), OnPaint(), and SetAlternateIdx().

◆ mButtonIsDown

bool AButton::mButtonIsDown {false}
private

Definition at line 266 of file AButton.h.

Referenced by GetState(), OnCharHook(), OnMouseEvent(), PopUp(), and PushDown().

◆ mCursorIsInWindow

bool AButton::mCursorIsInWindow {false}
private

Definition at line 265 of file AButton.h.

Referenced by GetState(), OnMouseEvent(), and UpdateStatus().

◆ mEnabled

bool AButton::mEnabled {true}
private

Definition at line 268 of file AButton.h.

Referenced by Disable(), Enable(), GetState(), OnCharHook(), OnMouseEvent(), and UpdateStatus().

◆ mFocusRect

wxRect AButton::mFocusRect
private

Definition at line 275 of file AButton.h.

Referenced by Init(), OnPaint(), OnSize(), and SetFocusRect().

◆ mForceFocusRect

bool AButton::mForceFocusRect {false}
private

Definition at line 276 of file AButton.h.

Referenced by OnSize(), and SetFocusRect().

◆ mIcon

wxImage AButton::mIcon
private

Definition at line 272 of file AButton.h.

Referenced by DoGetBestClientSize(), OnPaint(), and SetIcon().

◆ mImages

std::vector<std::array<wxImage, AButtonStateCount> > AButton::mImages
private

◆ mIsClicking

bool AButton::mIsClicking {false}
private

Definition at line 267 of file AButton.h.

Referenced by GetState(), and OnMouseEvent().

◆ mIsDoubleClicked

bool AButton::mIsDoubleClicked {false}
private

Definition at line 270 of file AButton.h.

Referenced by OnMouseEvent().

◆ mListener

std::unique_ptr<Listener> AButton::mListener
private

Definition at line 278 of file AButton.h.

Referenced by FollowModifierKeys().

◆ mToggle

bool AButton::mToggle {false}
private

Definition at line 255 of file AButton.h.

Referenced by GetState(), Init(), OnCharHook(), and OnMouseEvent().

◆ mType

Type AButton::mType {ImageButton}
private

Definition at line 280 of file AButton.h.

Referenced by DoGetBestClientSize(), OnPaint(), SetButtonType(), and SetLabel().

◆ mUseDisabledAsDownHiliteImage

bool AButton::mUseDisabledAsDownHiliteImage {false}
private

Definition at line 269 of file AButton.h.

Referenced by GetState(), and UseDisabledAsDownHiliteImage().

◆ mWasControlDown

bool AButton::mWasControlDown {false}
private

Definition at line 263 of file AButton.h.

Referenced by OnCharHook(), OnMouseEvent(), SetControl(), and WasControlDown().

◆ mWasShiftDown

bool AButton::mWasShiftDown {false}
private

Definition at line 262 of file AButton.h.

Referenced by OnCharHook(), OnMouseEvent(), SetShift(), and WasShiftDown().

◆ s_AcceptsFocus

bool AButton::s_AcceptsFocus { false }
staticprivate

Definition at line 241 of file AButton.h.

Referenced by TemporarilyAllowFocus().


The documentation for this class was generated from the following files: