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)
 
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 26 of file AButton.h.

Member Typedef Documentation

◆ TempAllowFocus

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

Definition at line 164 of file AButton.h.

Member Enumeration Documentation

◆ AButtonState

Enumerator
AButtonUp 
AButtonOver 
AButtonDown 
AButtonOverDown 
AButtonDis 
AButtonStateCount 

Definition at line 147 of file AButton.h.

147 {
148 AButtonUp,
153
155 };
@ AButtonStateCount
Definition: AButton.h:154
@ AButtonUp
Definition: AButton.h:148
@ AButtonDis
Definition: AButton.h:152
@ AButtonOver
Definition: AButton.h:149
@ AButtonDown
Definition: AButton.h:150
@ AButtonOverDown
Definition: AButton.h:151

◆ Type

Enumerator
TextButton 
ImageButton 
FrameButton 

Definition at line 32 of file AButton.h.

33 {
37 };
@ TextButton
Definition: AButton.h:34
@ FrameButton
Definition: AButton.h:36
@ ImageButton
Definition: AButton.h:35

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 195 of file AButton.cpp.

196{
197 Init(parent, id, pos, size, toggle);
198}
void Init(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, bool toggle)
Definition: AButton.cpp:237

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 200 of file AButton.cpp.

210{
211 Init(parent, id, pos, size, toggle);
212
213 SetAlternateImages(0, up, over, down, overDown, dis);
214
215 SetMinSize(mImages[0][AButtonUp].GetSize());
216 SetMaxSize(mImages[0][AButtonUp].GetSize());
217}
void SetAlternateImages(unsigned idx, const wxImage &up, const wxImage &over, const wxImage &down, const wxImage &overDown, const wxImage &dis)
Definition: AButton.cpp:288
std::vector< std::array< wxImage, AButtonStateCount > > mImages
Definition: AButton.h:194

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

Here is the call graph for this function:

◆ ~AButton()

AButton::~AButton ( )
virtual

Definition at line 219 of file AButton.cpp.

220{
221 if(HasCapture())
222 ReleaseMouse();
223}

Member Function Documentation

◆ AcceptsFocus()

bool AButton::AcceptsFocus ( ) const
inlineoverride

Definition at line 68 of file AButton.h.

68{ return s_AcceptsFocus; }
static bool s_AcceptsFocus
Definition: AButton.h:162

◆ AcceptsFocusFromKeyboard()

bool AButton::AcceptsFocusFromKeyboard ( ) const
inlineoverride

Definition at line 69 of file AButton.h.

69{ return mEnabled; }
bool mEnabled
Definition: AButton.h:189

◆ ClearDoubleClicked()

void AButton::ClearDoubleClicked ( )
inline

Definition at line 133 of file AButton.h.

133{ mIsDoubleClicked = false; }
bool mIsDoubleClicked
Definition: AButton.h:191

◆ Click()

void AButton::Click ( )

Definition at line 662 of file AButton.cpp.

663{
664 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetId());
665 event.SetEventObject(this);
666 // Be sure to use SafelyProcessEvent so that exceptions do not propagate
667 // out of DoDefaultAction
668 GetEventHandler()->SafelyProcessEvent(event);
669}
wxEVT_COMMAND_BUTTON_CLICKED

References wxEVT_COMMAND_BUTTON_CLICKED.

Referenced by OnKeyDown(), and OnMouseEvent().

Here is the caller graph for this function:

◆ Disable()

void AButton::Disable ( )

Definition at line 625 of file AButton.cpp.

626{
627 // Bug 1565: Tooltips not showing on disabled buttons.
628 // The fix is to NOT tell windows that the button is disabled.
629 // The button's appearance will still change to show it is disabled
630 // since we control that rather than windows.
631#ifndef __WXMSW__
632 wxWindow::Enable(false);
633#endif
634 if (GetCapture()==this)
635 ReleaseMouse();
636 if ( mEnabled ) {
637 mEnabled = false;
638 Refresh(false);
639 }
640}

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 681 of file AButton.cpp.

682{
684 {
685 const auto& image = mImages[mAlternateIdx][AButtonUp];
686 switch(mType)
687 {
688 case FrameButton:
689 {
690 const auto border = image.GetSize() / 4;
691 wxSize bestSize { -1 , -1 };
692 if(!GetLabel().IsEmpty())
693 {
694 wxMemoryDC dc;
695 dc.SetFont(GetFont());
696 bestSize = dc.GetTextExtent(GetLabel());
697 }
698 if(mIcon.IsOk())
699 {
700 bestSize.x = std::max(bestSize.x, mIcon.GetWidth());
701 bestSize.y = bestSize.y > 0
702 ? bestSize.y + border.y + mIcon.GetHeight()
703 : mIcon.GetHeight();
704 }
705 if(bestSize.x > 0)
706 bestSize.x += border.x * 2;
707 if(bestSize.y > 0)
708 bestSize.y += border.y * 2;
709 return bestSize;
710 }
711 case TextButton:
712 return {-1, image.GetHeight() };
713 default:
714 return image.GetSize();
715 }
716 }
717 return wxWindow::DoGetBestClientSize();
718}
bool HasAlternateImages(unsigned idx) const
Definition: AButton.cpp:456
Type mType
Definition: AButton.h:201
wxImage mIcon
Definition: AButton.h:193
unsigned mAlternateIdx
Definition: AButton.h:175

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 616 of file AButton.cpp.

617{
618 bool changed = wxWindow::Enable(true);
619 if ( !mEnabled ) {
620 mEnabled = true;
621 Refresh(false);
622 }
623}

References mEnabled.

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

Here is the caller graph for this function:

◆ FollowModifierKeys()

void AButton::FollowModifierKeys ( )

Definition at line 321 of file AButton.cpp.

322{
323 if(!mListener)
324 mListener = std::make_unique<Listener>(this);
325}
std::unique_ptr< Listener > mListener
Definition: AButton.h:199

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 333 of file AButton.cpp.

334{
335 AButtonState state;
336
337 if (!mEnabled && (!mToggle || !mButtonIsDown))
338 return AButtonDis;
339
340 if (mCursorIsInWindow) {
341 if (mToggle) {
342 if (mIsClicking) {
346 }
347 }
348 else {
352 }
353 }
354 }
355 else {
356 if (mIsClicking) {
358 }
359 else {
361 }
362 }
363 }
364 else {
366 }
367
368 return state;
369}
bool mUseDisabledAsDownHiliteImage
Definition: AButton.h:190
bool mButtonIsDown
Definition: AButton.h:187
bool mCursorIsInWindow
Definition: AButton.h:186
AButtonState
Definition: AButton.h:147
bool mIsClicking
Definition: AButton.h:188
bool mToggle
Definition: AButton.h:176

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 456 of file AButton.cpp.

457{
458 if (mImages.size() <= idx)
459 return false;
460
461 const auto &arr = mImages[idx];
462 return (arr[0].Ok() &&
463 arr[1].Ok() &&
464 arr[2].Ok() &&
465 arr[3].Ok() &&
466 arr[4].Ok());
467}
@ 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 237 of file AButton.cpp.

238{
239 SetBackgroundStyle(wxBG_STYLE_PAINT);
240
241 // Bug in wxWidgets 2.8.12: by default pressing Enter on an AButton is interpreted as
242 // a navigation event - move to next control. As a workaround, the style wxWANTS_CHARS
243 // results in all characters being available in the OnKeyDown function below. Note
244 // that OnKeyDown now has to handle navigation.
245 Create(parent, id, pos, size, wxWANTS_CHARS);
246
247 mToggle = toggle;
248
249 mFocusRect = GetClientRect().Deflate( 3, 3 );
250
251#if wxUSE_ACCESSIBILITY
252 SetName( wxT("") );
253 SetAccessible(safenew AButtonAx(this));
254#endif
255}
wxT("CloseDown"))
#define safenew
Definition: MemoryX.h:10
wxRect mFocusRect
Definition: AButton.h:196
friend class AButtonAx
Definition: AButton.h:27

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 139 of file AButton.h.

139{ if( !mToggle ) PopUp();}
void PopUp()
Definition: AButton.cpp:650

Referenced by EditToolBar::OnButton().

Here is the caller graph for this function:

◆ IsDoubleClicked()

bool AButton::IsDoubleClicked ( ) const
inline

Definition at line 132 of file AButton.h.

132{ return mIsDoubleClicked; }

◆ IsDown()

bool AButton::IsDown ( )
inline

Definition at line 129 of file AButton.h.

129{ return mButtonIsDown;}

Referenced by ControlToolBar::EnableDisableButtons(), 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 101 of file AButton.h.

101{ return mEnabled; }

◆ IsToggle()

bool AButton::IsToggle ( ) const
noexcept

◆ OnCaptureLost()

void AButton::OnCaptureLost ( wxMouseCaptureLostEvent &  event)

Definition at line 551 of file AButton.cpp.

552{
553 wxMouseEvent e(wxEVT_LEFT_UP);
554 e.m_x = -1;
555 e.m_y = -1;
556 OnMouseEvent(e);
557}
void OnMouseEvent(wxMouseEvent &event)
Definition: AButton.cpp:469

References OnMouseEvent().

Here is the call graph for this function:

◆ OnErase()

void AButton::OnErase ( wxEraseEvent &  event)

Definition at line 440 of file AButton.cpp.

441{
442 // Ignore it to prevent flashing
443}

◆ OnKeyDown()

void AButton::OnKeyDown ( wxKeyEvent &  event)

Definition at line 561 of file AButton.cpp.

562{
563 switch( event.GetKeyCode() )
564 {
565 case WXK_RIGHT:
566 case WXK_DOWN:
567 Navigate(wxNavigationKeyEvent::IsForward);
568 break;
569 case WXK_LEFT:
570 case WXK_UP:
571 Navigate(wxNavigationKeyEvent::IsBackward);
572 break;
573 case WXK_TAB:
574 Navigate(wxNavigationKeyEvent::FromTab | (event.ShiftDown()
575 ? wxNavigationKeyEvent::IsBackward
576 : wxNavigationKeyEvent::IsForward));
577 break;
578 case WXK_RETURN:
579 case WXK_NUMPAD_ENTER:
580 if( !mEnabled )
581 break;
582 mWasShiftDown = event.ShiftDown();
583 mWasControlDown = event.ControlDown();
584 if(mToggle)
585 {
587 Refresh(false);
588 }
589 Click();
590 break;
591 default:
592 event.Skip();
593 }
594}
bool mWasShiftDown
Definition: AButton.h:183
void Click()
Definition: AButton.cpp:662
bool mWasControlDown
Definition: AButton.h:184

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

Here is the call graph for this function:

◆ OnKillFocus()

void AButton::OnKillFocus ( wxFocusEvent &  event)

Definition at line 601 of file AButton.cpp.

602{
603 Refresh( false );
604}

◆ OnMouseEvent()

void AButton::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 469 of file AButton.cpp.

470{
471 wxSize clientSize = GetClientSize();
472 AButtonState prevState = GetState();
473
474 if (event.Entering()) {
475 // Bug 1201: On Mac, unsetting and re-setting the tooltip may be needed
476 // to make it pop up when we want it.
477 auto text = GetToolTipText();
478 UnsetToolTip();
479 wxWindow::SetToolTip(text);
480 mCursorIsInWindow = true;
481 }
482 else if (event.Leaving())
483 mCursorIsInWindow = false;
484 else
486 (event.m_x >= 0 && event.m_y >= 0 &&
487 event.m_x < clientSize.x && event.m_y < clientSize.y);
488
489 if (mEnabled && event.IsButton()) {
490 if (event.ButtonIsDown(wxMOUSE_BTN_LEFT)) {
491 mIsClicking = true;
492 if (event.ButtonDClick())
493 mIsDoubleClicked = true;
494 if( !HasCapture() )
495 CaptureMouse();
496 }
497 else if (mIsClicking) {
498 mIsClicking = false;
499
500 if (HasCapture())
501 ReleaseMouse();
502
504 if (mToggle)
506
507 mWasShiftDown = event.ShiftDown();
508 mWasControlDown = event.ControlDown();
509
510 Click();
511 }
512 }
513 }
514
515 // Only redraw and change tooltips if the state has changed.
516 AButtonState newState = GetState();
517
518 if (newState != prevState) {
519 Refresh(false);
520
522 UpdateStatus();
523 else {
524 auto pProject = FindProjectFromWindow( this );
525 if (pProject)
526 ProjectStatus::Get( *pProject ).Set({});
527 }
528 }
529 else
530 event.Skip();
531}
AudacityProject * FindProjectFromWindow(wxWindow *pWindow)
void UpdateStatus()
Definition: AButton.cpp:533
AButtonState GetState()
Definition: AButton.cpp:333
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 371 of file AButton.cpp.

372{
373 wxBufferedPaintDC dc(this);
374
375 dc.SetPen(*wxTRANSPARENT_PEN);
376 dc.SetBrush(GetBackgroundColour());
377 dc.Clear();
378
379 const auto buttonRect = GetClientRect();
381 {
382 AButtonState buttonState = GetState();
383 if(mType == ImageButton)
384 dc.DrawBitmap(mImages[mAlternateIdx][buttonState], buttonRect.GetTopLeft());
385 else if(mType == FrameButton)
386 {
387 wxBitmap bitmap = mImages[mAlternateIdx][buttonState];
388 AColor::DrawFrame(dc, buttonRect, bitmap);
389
390 const auto border = bitmap.GetSize() / 4;
391
392 if(!GetLabel().IsEmpty())
393 {
394 dc.SetFont(GetFont());
395 auto textRect = buttonRect;
396 if(mIcon.IsOk())
397 {
398 auto fontMetrics = dc.GetFontMetrics();
399 auto sumHeight = fontMetrics.height + mIcon.GetHeight() + border.y;
400 dc.DrawBitmap(mIcon,
401 buttonRect.x + (buttonRect.width - mIcon.GetWidth()) / 2,
402 buttonRect.y + (buttonRect.height - sumHeight) / 2);
403 textRect = wxRect(
404 buttonRect.x,
405 buttonRect.y + buttonRect.height / 2 + sumHeight / 2 - fontMetrics.height,
406 buttonRect.width,
407 fontMetrics.height);
408 }
409 dc.SetPen(GetForegroundColour());
410 dc.DrawLabel(GetLabel(), textRect, wxALIGN_CENTER);
411 }
412 else if(mIcon.IsOk())
413 {
414 dc.DrawBitmap(mIcon,
415 buttonRect.x + (buttonRect.width - mIcon.GetWidth() / 2),
416 buttonRect.y + (buttonRect.height - mIcon.GetHeight() / 2));
417 }
418 }
419 else
420 {
421 wxBitmap bitmap = mImages[mAlternateIdx][buttonState];
422 AColor::DrawHStretch(dc, GetClientRect(), bitmap);
423 if(!GetLabel().IsEmpty())
424 {
425 dc.SetFont(GetFont());
426 const auto text = TrackArt::TruncateText(dc, GetLabel(), GetClientSize().GetWidth() - 6);
427 if(!text.IsEmpty())
428 {
429 dc.SetPen(GetForegroundColour());
430 dc.DrawLabel(text, GetClientRect(), wxALIGN_CENTER);
431 }
432 }
433 }
434 }
435
436 if(HasFocus())
438}
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:156

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 596 of file AButton.cpp.

597{
598 Refresh( false );
599}

◆ OnSize()

void AButton::OnSize ( wxSizeEvent &  event)

Definition at line 445 of file AButton.cpp.

446{
447 if (!mForceFocusRect)
448 {
449 mFocusRect = GetClientRect().Deflate( 3, 3 );
450 }
451 Refresh(false);
452}
bool mForceFocusRect
Definition: AButton.h:197

References mFocusRect, and mForceFocusRect.

◆ PopUp()

void AButton::PopUp ( )

◆ PushDown()

void AButton::PushDown ( )

◆ SetAlternateIdx()

void AButton::SetAlternateIdx ( unsigned  idx)

Definition at line 310 of file AButton.cpp.

311{
312 // If alternate-image-state is already correct then
313 // nothing to do (saves repainting button).
314 if( mAlternateIdx == idx )
315 return;
316 mAlternateIdx = idx;
317 Refresh(false);
318 PostSizeEventToParent();
319}

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 288 of file AButton.cpp.

294{
295 if (1 + idx > mImages.size())
296 mImages.resize(1 + idx);
297 mImages[idx][AButtonUp] = up;
298 mImages[idx][AButtonOver] = over;
299 mImages[idx][AButtonDown] = down;
300 mImages[idx][AButtonOverDown] = overDown;
301 mImages[idx][AButtonDis] = dis;
302}

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 135 of file AButton.h.

135{ mToggle = toggler;}

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

Here is the caller graph for this function:

◆ SetButtonType()

void AButton::SetButtonType ( Type  type)

Definition at line 225 of file AButton.cpp.

226{
227 if(mType != type)
228 {
229 mType = type;
230 InvalidateBestSize();
231 Refresh(false);
232 PostSizeEventToParent();
233 }
234}

References mType.

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

Here is the caller graph for this function:

◆ SetControl()

void AButton::SetControl ( bool  control)

Definition at line 676 of file AButton.cpp.

677{
678 mWasControlDown = control;
679}

References mWasControlDown.

Referenced by ControlToolBar::SetPlay().

Here is the caller graph for this function:

◆ SetEnabled()

void AButton::SetEnabled ( bool  state)
inline

Definition at line 104 of file AButton.h.

104 {
105 state ? Enable() : Disable();
106 }
void Disable()
Definition: AButton.cpp:625
void Enable()
Definition: AButton.cpp:616

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

Here is the caller graph for this function:

◆ SetFocusFromKbd()

void AButton::SetFocusFromKbd ( )
override

Definition at line 277 of file AButton.cpp.

278{
279 auto temp = TemporarilyAllowFocus();
280 SetFocus();
281}
static TempAllowFocus TemporarilyAllowFocus()
Definition: AButton.cpp:720

References TemporarilyAllowFocus().

Here is the call graph for this function:

◆ SetFocusRect()

void AButton::SetFocusRect ( const wxRect &  r)

Definition at line 327 of file AButton.cpp.

328{
329 mFocusRect = r;
330 mForceFocusRect = true;
331}

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 304 of file AButton.cpp.

305{
306 mIcon = icon;
307 Refresh(false);
308}

References mIcon.

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

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 283 of file AButton.cpp.

284{
285 SetAlternateImages(0, up, over, down, overDown, dis);
286}

References SetAlternateImages().

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

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 267 of file AButton.cpp.

268{
269 wxWindow::SetLabel( toolTip.Stripped().Translation() );
270 if(mType == FrameButton)
271 InvalidateBestSize();
272}

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

Referenced by EditToolBar::AddButton(), ScrubbingToolBar::AddButton(), TranscriptionToolBar::AddButton(), AudioSetupToolBar::MakeAudioSetupButton(), ToolBar::MakeButton(), cloud::ShareAudioToolbar::MakeShareAudioButton(), ToolsToolBar::MakeTool(), 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 671 of file AButton.cpp.

672{
673 mWasShiftDown = shift;
674}

References mWasShiftDown.

Referenced by ControlToolBar::SetPlay().

Here is the caller graph for this function:

◆ SetToolTip()

void AButton::SetToolTip ( const TranslatableString toolTip)

Definition at line 262 of file AButton.cpp.

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

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

Referenced by 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 720 of file AButton.cpp.

720 {
721 s_AcceptsFocus = true;
723}
std::unique_ptr< bool, Resetter > TempAllowFocus
Definition: AButton.h:164

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 140 of file AButton.h.

140{ mButtonIsDown ? PopUp() : PushDown();}
void PushDown()
Definition: AButton.cpp:642

◆ UpdateStatus()

void AButton::UpdateStatus ( )

Definition at line 533 of file AButton.cpp.

534{
535 if (mCursorIsInWindow) {
536#if wxUSE_TOOLTIPS // Not available in wxX11
537 // Display the tooltip in the status bar
538 wxToolTip * pTip = this->GetToolTip();
539 if( pTip ) {
540 auto tipText = Verbatim( pTip->GetTip() );
541 if (!mEnabled)
542 tipText.Join( XO("(disabled)"), " " );
543 auto pProject = FindProjectFromWindow( this );
544 if (pProject)
545 ProjectStatus::Get( *pProject ).Set( tipText );
546 }
547#endif
548 }
549}
#define XO(s)
Definition: Internat.h:31
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 257 of file AButton.cpp.

258{
260}
static std::once_flag flag

References flag, and mUseDisabledAsDownHiliteImage.

◆ WasControlDown()

bool AButton::WasControlDown ( )

Definition at line 611 of file AButton.cpp.

612{
613 return mWasControlDown;
614}

References mWasControlDown.

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

Here is the caller graph for this function:

◆ WasShiftDown()

bool AButton::WasShiftDown ( )

Definition at line 606 of file AButton.cpp.

607{
608 return mWasShiftDown;
609}

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 27 of file AButton.h.

Referenced by Init().

Member Data Documentation

◆ mAlternateIdx

unsigned AButton::mAlternateIdx {0}
private

Definition at line 175 of file AButton.h.

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

◆ mButtonIsDown

bool AButton::mButtonIsDown {false}
private

Definition at line 187 of file AButton.h.

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

◆ mCursorIsInWindow

bool AButton::mCursorIsInWindow {false}
private

Definition at line 186 of file AButton.h.

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

◆ mEnabled

bool AButton::mEnabled {true}
private

Definition at line 189 of file AButton.h.

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

◆ mFocusRect

wxRect AButton::mFocusRect
private

Definition at line 196 of file AButton.h.

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

◆ mForceFocusRect

bool AButton::mForceFocusRect {false}
private

Definition at line 197 of file AButton.h.

Referenced by OnSize(), and SetFocusRect().

◆ mIcon

wxImage AButton::mIcon
private

Definition at line 193 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 188 of file AButton.h.

Referenced by GetState(), and OnMouseEvent().

◆ mIsDoubleClicked

bool AButton::mIsDoubleClicked {false}
private

Definition at line 191 of file AButton.h.

Referenced by OnMouseEvent().

◆ mListener

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

Definition at line 199 of file AButton.h.

Referenced by FollowModifierKeys().

◆ mToggle

bool AButton::mToggle {false}
private

Definition at line 176 of file AButton.h.

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

◆ mType

Type AButton::mType {ImageButton}
private

Definition at line 201 of file AButton.h.

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

◆ mUseDisabledAsDownHiliteImage

bool AButton::mUseDisabledAsDownHiliteImage {false}
private

Definition at line 190 of file AButton.h.

Referenced by GetState(), and UseDisabledAsDownHiliteImage().

◆ mWasControlDown

bool AButton::mWasControlDown {false}
private

Definition at line 184 of file AButton.h.

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

◆ mWasShiftDown

bool AButton::mWasShiftDown {false}
private

Definition at line 183 of file AButton.h.

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

◆ s_AcceptsFocus

bool AButton::s_AcceptsFocus { false }
staticprivate

Definition at line 162 of file AButton.h.

Referenced by TemporarilyAllowFocus().


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