Audacity  3.0.3
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
ToolBar Class Referenceabstract

Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed. More...

#include <ToolBar.h>

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

Public Types

using Holder = wxWindowPtr< ToolBar >
 

Public Member Functions

 ToolBar (AudacityProject &project, int type, const TranslatableString &label, const wxString &section, bool resizable=false)
 
virtual ~ToolBar ()
 
bool AcceptsFocus () const override
 
virtual void SetToDefaultSize ()
 
virtual void Create (wxWindow *parent)
 
virtual void EnableDisableButtons ()=0
 
virtual void ReCreateButtons ()
 
void UpdatePrefs () override
 
virtual void RegenerateTooltips ()=0
 
int GetType ()
 
TranslatableString GetTitle ()
 
TranslatableString GetLabel ()
 
wxString GetSection ()
 
ToolDockGetDock ()
 
void SetLabel (const TranslatableString &label)
 
virtual void SetDocked (ToolDock *dock, bool pushed)
 
virtual bool Expose (bool show=true)
 
bool IsResizable () const
 
bool IsVisible () const
 
bool IsDocked () const
 
bool IsPositioned ()
 
void SetVisible (bool bVisible)
 
void SetPositioned ()
 
virtual int GetInitialWidth ()
 Resizable toolbars should implement these. More...
 
virtual int GetMinToolbarWidth ()
 
virtual wxSize GetDockedSize ()
 
wxSize GetSmartDockedSize ()
 
virtual void ResizingDone ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Static Public Member Functions

static AButtonMakeButton (wxWindow *parent, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxWindowID id, wxPoint placement, bool processdownevents, wxSize size)
 
static void MakeAlternateImages (AButton &button, int idx, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxSize size)
 
static void SetButtonToolTip (AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
 
static void MakeButtonBackgroundsSmall ()
 
static void MakeButtonBackgroundsLarge ()
 

Protected Member Functions

void SetButton (bool down, AButton *button)
 
wxBoxSizer * GetSizer ()
 
void Add (wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
 
void Add (wxSizer *sizer, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void Add (int width, int height, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void AddSpacer (int size=14)
 
void AddStretchSpacer (int prop=1)
 
void Detach (wxWindow *window)
 
void Detach (wxSizer *sizer)
 
void Updated ()
 
int GetResizeGrabberWidth ()
 Returns the width in pixels of the resizer element. More...
 
virtual void Populate ()=0
 
virtual void Repaint (wxDC *dc)=0
 
void OnErase (wxEraseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
void OnMouseEvents (wxMouseEvent &event)
 
- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 
 PrefsListener ()
 
virtual ~PrefsListener ()
 

Static Protected Member Functions

static void MakeMacRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
static void MakeRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
- Static Protected Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 

Protected Attributes

AudacityProjectmProject
 
TranslatableString mLabel
 
wxString mSection
 
int mType
 

Private Member Functions

void SetLabel (const wxString &label) override
 
void Init (wxWindow *parent, int type, const wxString &title, const wxString &label)
 

Private Attributes

wxWindow * mParent
 
GrabbermGrabber
 
ToolBarResizermResizer
 
wxBoxSizer * mHSizer
 
bool mVisible
 
bool mResizable
 
bool mPositioned
 

Friends

class ToolBarResizer
 

Detailed Description

Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed.

Definition at line 95 of file ToolBar.h.

Member Typedef Documentation

◆ Holder

using ToolBar::Holder = wxWindowPtr<ToolBar>

Definition at line 102 of file ToolBar.h.

Constructor & Destructor Documentation

◆ ToolBar()

ToolBar::ToolBar ( AudacityProject project,
int  type,
const TranslatableString label,
const wxString &  section,
bool  resizable = false 
)

Definition at line 330 of file ToolBar.cpp.

335 : wxPanelWrapper()
336 , mProject{ project }
337 {
338  // Save parameters
339  mType = type;
340  mLabel = label;
341  mSection = section;
342  mResizable = resizable;
343 
344  // Initialize everything
345  mParent = NULL;
346  mHSizer = NULL;
347  mVisible = false;
348  mPositioned = false;
349 
350  mGrabber = NULL;
351  mResizer = NULL;
352  SetId(mType);
353 }

◆ ~ToolBar()

ToolBar::~ToolBar ( )
virtual

Definition at line 358 of file ToolBar.cpp.

359 {
360 }

Member Function Documentation

◆ AcceptsFocus()

bool ToolBar::AcceptsFocus ( ) const
inlineoverride

Definition at line 109 of file ToolBar.h.

109 { return false; };

◆ Add() [1/3]

void ToolBar::Add ( int  width,
int  height,
int  proportion = 0,
int  flag = 0,
int  border = 0,
wxObject *  userData = NULL 
)
protected

Definition at line 718 of file ToolBar.cpp.

724 {
725  mHSizer->Add( width,
726  height,
727  proportion,
728  flag,
729  border,
730  userData );
731 }

References flag, and mHSizer.

◆ Add() [2/3]

void ToolBar::Add ( wxSizer *  sizer,
int  proportion = 0,
int  flag = 0,
int  border = 0,
wxObject *  userData = NULL 
)
protected

Definition at line 702 of file ToolBar.cpp.

707 {
708  mHSizer->Add( sizer,
709  proportion,
710  flag,
711  border,
712  userData );
713 }

References flag, and mHSizer.

◆ Add() [3/3]

void ToolBar::Add ( wxWindow *  window,
int  proportion = 0,
int  flag = wxALIGN_TOP,
int  border = 0,
wxObject *  userData = NULL 
)
protected

Definition at line 686 of file ToolBar.cpp.

691 {
692  mHSizer->Add( window,
693  proportion,
694  flag,
695  border,
696  userData );
697 }

References flag, and mHSizer.

Referenced by EditToolBar::AddButton(), ScrubbingToolBar::AddButton(), TranscriptionToolBar::AddButton(), ControlToolBar::ArrangeButtons(), DeviceToolBar::Populate(), MeterToolBar::Populate(), MixerToolBar::Populate(), SelectionBar::Populate(), TimeToolBar::Populate(), ToolsToolBar::Populate(), and TranscriptionToolBar::Populate().

Here is the caller graph for this function:

◆ AddSpacer()

void ToolBar::AddSpacer ( int  size = 14)
protected

Definition at line 736 of file ToolBar.cpp.

737 {
738  mHSizer->AddSpacer( size );
739 }

References mHSizer, and size.

Referenced by EditToolBar::AddSeparator().

Here is the caller graph for this function:

◆ AddStretchSpacer()

void ToolBar::AddStretchSpacer ( int  prop = 1)
protected

Definition at line 744 of file ToolBar.cpp.

745 {
746  mHSizer->AddStretchSpacer( prop );
747 }

References mHSizer.

◆ Create()

void ToolBar::Create ( wxWindow *  parent)
virtual

Reimplemented in TranscriptionToolBar, ToolsToolBar, SpectralSelectionBar, SelectionBar, ScrubbingToolBar, MixerToolBar, MeterToolBar, EditToolBar, DeviceToolBar, and ControlToolBar.

Definition at line 475 of file ToolBar.cpp.

476 {
477  // Save parameters
478  mParent = parent;
479 
480  // Create the window and label it
482  mType,
483  wxDefaultPosition,
484  wxDefaultSize,
485  wxNO_BORDER | wxTAB_TRAVERSAL,
486  GetTitle() );
488 
489  // Go do the rest of the creation
490  ReCreateButtons();
491 
492  // ToolManager depends on this appearing to be visible for proper dock construction
493  mVisible = true;
494 }

References wxPanelWrapper::Create(), GetLabel(), GetTitle(), mParent, mType, mVisible, ReCreateButtons(), and wxPanelWrapper::SetLabel().

Referenced by ControlToolBar::Create(), DeviceToolBar::Create(), EditToolBar::Create(), MeterToolBar::Create(), MixerToolBar::Create(), ScrubbingToolBar::Create(), SelectionBar::Create(), ToolsToolBar::Create(), TranscriptionToolBar::Create(), and ToolManager::ReadConfig().

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

◆ Detach() [1/2]

void ToolBar::Detach ( wxSizer *  sizer)
protected

Definition at line 760 of file ToolBar.cpp.

761 {
762  mHSizer->Detach( sizer );
763 }

References mHSizer.

◆ Detach() [2/2]

void ToolBar::Detach ( wxWindow *  window)
protected

Definition at line 752 of file ToolBar.cpp.

753 {
754  mHSizer->Detach( window );
755 }

References mHSizer.

Referenced by ControlToolBar::ArrangeButtons(), and ControlToolBar::ReCreateButtons().

Here is the caller graph for this function:

◆ EnableDisableButtons()

virtual void ToolBar::EnableDisableButtons ( )
pure virtual

Implemented in TranscriptionToolBar, ToolsToolBar, TimeToolBar, SpectralSelectionBar, SelectionBar, ScrubbingToolBar, MixerToolBar, MeterToolBar, EditToolBar, DeviceToolBar, and ControlToolBar.

Referenced by ToolManager::Reset(), and ProjectAudioManager::Stop().

Here is the caller graph for this function:

◆ Expose()

bool ToolBar::Expose ( bool  show = true)
virtual

Reimplemented in MeterToolBar.

Definition at line 444 of file ToolBar.cpp.

445 {
446  bool was = mVisible;
447 
448  SetVisible( show );
449 
450  if( IsDocked() )
451  {
452  Show( show );
453  if( show )
454  {
455  Refresh();
456  }
457  }
458  else
459  {
460  wxWindow * pParent = GetParent();
461  if( !IsPositioned() && show ){
462  SetPositioned();
463  pParent->CentreOnParent();
464  pParent->Move( pParent->GetPosition() + wxSize( mType*10, mType*10 ));
465  }
466  pParent->Show( show );
467  }
468 
469  return was;
470 }

References IsDocked(), IsPositioned(), mType, mVisible, SetPositioned(), and SetVisible().

Referenced by MeterToolBar::Expose(), ToolDock::Expose(), and ToolManager::Expose().

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

◆ GetDock()

ToolDock * ToolBar::GetDock ( )

Definition at line 630 of file ToolBar.cpp.

631 {
632  return dynamic_cast<ToolDock*>(GetParent());
633 }

Referenced by ToolManager::DoneDragging(), ToolManager::Expose(), IsDocked(), ReCreateButtons(), ToolManager::Reset(), Updated(), and ToolManager::WriteConfig().

Here is the caller graph for this function:

◆ GetDockedSize()

virtual wxSize ToolBar::GetDockedSize ( )
inlinevirtual

Reimplemented in TimeToolBar, and MeterToolBar.

Definition at line 145 of file ToolBar.h.

145 { return GetMinSize(); }

Referenced by ToolDock::Dock().

Here is the caller graph for this function:

◆ GetInitialWidth()

virtual int ToolBar::GetInitialWidth ( )
inlinevirtual

Resizable toolbars should implement these.

Reimplemented in TranscriptionToolBar, TimeToolBar, MixerToolBar, MeterToolBar, and DeviceToolBar.

Definition at line 143 of file ToolBar.h.

143 { return -1; }

Referenced by SetToDefaultSize().

Here is the caller graph for this function:

◆ GetLabel()

TranslatableString ToolBar::GetLabel ( )

Definition at line 374 of file ToolBar.cpp.

375 {
376  return mLabel;
377 }

References mLabel.

Referenced by Create(), and GetTitle().

Here is the caller graph for this function:

◆ GetMinToolbarWidth()

virtual int ToolBar::GetMinToolbarWidth ( )
inlinevirtual

Reimplemented in TranscriptionToolBar, TimeToolBar, MixerToolBar, MeterToolBar, and DeviceToolBar.

Definition at line 144 of file ToolBar.h.

144 { return GetInitialWidth(); }

Referenced by ReCreateButtons().

Here is the caller graph for this function:

◆ GetResizeGrabberWidth()

int ToolBar::GetResizeGrabberWidth ( )
protected

Returns the width in pixels of the resizer element.

Definition at line 955 of file ToolBar.cpp.

956 {
957  return RWIDTH;
958 }

References RWIDTH.

◆ GetSection()

wxString ToolBar::GetSection ( )

Definition at line 382 of file ToolBar.cpp.

383 {
384  return mSection;
385 }

References mSection.

Referenced by ToolManager::ReadConfig(), and ToolManager::WriteConfig().

Here is the caller graph for this function:

◆ GetSizer()

wxBoxSizer * ToolBar::GetSizer ( )
protected

Definition at line 678 of file ToolBar.cpp.

679 {
680  return mHSizer;
681 }

References mHSizer.

Referenced by ControlToolBar::ArrangeButtons(), MeterToolBar::OnSize(), TimeToolBar::OnSize(), and TimeToolBar::SetResizingLimits().

Here is the caller graph for this function:

◆ GetSmartDockedSize()

wxSize ToolBar::GetSmartDockedSize ( )

Definition at line 503 of file ToolBar.cpp.

504 {
505  const int tbs = toolbarSingle + toolbarGap;
506  wxSize sz = GetSize();
507  // 46 is the size where we switch from expanded to compact.
508  if( sz.y < 46 )
509  sz.y = tbs-1;
510  else
511  sz.y = 2 * tbs -1;
512  return sz;
513 }

References toolbarGap, and toolbarSingle.

Referenced by MeterToolBar::GetDockedSize().

Here is the caller graph for this function:

◆ GetTitle()

TranslatableString ToolBar::GetTitle ( )

Definition at line 365 of file ToolBar.cpp.

366 {
367  /* i18n-hint: %s will be replaced by the name of the kind of toolbar.*/
368  return XO("Audacity %s Toolbar").Format( GetLabel() );
369 }

References GetLabel(), and XO.

Referenced by Create(), SetDocked(), and UpdatePrefs().

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

◆ GetType()

int ToolBar::GetType ( )

Definition at line 390 of file ToolBar.cpp.

391 {
392  return mType;
393 }

References mType.

Referenced by ToolDock::VisitLayout().

Here is the caller graph for this function:

◆ Init()

void ToolBar::Init ( wxWindow *  parent,
int  type,
const wxString &  title,
const wxString &  label 
)
private

◆ IsDocked()

bool ToolBar::IsDocked ( ) const

Definition at line 423 of file ToolBar.cpp.

424 {
425  return const_cast<ToolBar*>(this)->GetDock() != nullptr;
426 }

References GetDock().

Referenced by Expose(), ToolManager::Expose(), ToolManager::IsVisible(), ToolManager::OnGrabber(), ToolFrame::OnMotion(), ReCreateButtons(), ToolManager::Reset(), TimeToolBar::SetResizingLimits(), Updated(), and ToolManager::WriteConfig().

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

◆ IsPositioned()

bool ToolBar::IsPositioned ( )
inline

Definition at line 137 of file ToolBar.h.

137 { return mPositioned; };

Referenced by Expose(), and ToolManager::WriteConfig().

Here is the caller graph for this function:

◆ IsResizable()

bool ToolBar::IsResizable ( ) const

Definition at line 415 of file ToolBar.cpp.

416 {
417  return mResizable;
418 }

References mResizable.

Referenced by ToolFrame::OnMotion(), ToolFrame::OnPaint(), ReCreateButtons(), and ToolManager::Reset().

Here is the caller graph for this function:

◆ IsVisible()

bool ToolBar::IsVisible ( ) const

Definition at line 431 of file ToolBar.cpp.

432 {
433  return mVisible;
434 }

References mVisible.

Referenced by ToolDock::Dock(), ToolManager::IsVisible(), and ToolBarConfiguration::Write().

Here is the caller graph for this function:

◆ MakeAlternateImages()

void ToolBar::MakeAlternateImages ( AButton button,
int  idx,
teBmps  eUp,
teBmps  eDown,
teBmps  eHilite,
teBmps  eDownHi,
teBmps  eStandardUp,
teBmps  eStandardDown,
teBmps  eDisabled,
wxSize  size 
)
static

Definition at line 873 of file ToolBar.cpp.

882 {
883  // wxMax to cater for case of image being bigger than the button.
884  int xoff = wxMax( 0, (size.GetWidth() - theTheme.Image(eStandardUp).GetWidth())/2);
885  int yoff = wxMax( 0, (size.GetHeight() - theTheme.Image(eStandardUp).GetHeight())/2);
886 
887  typedef std::unique_ptr<wxImage> wxImagePtr;
888  wxImagePtr up (OverlayImage(eUp, eStandardUp, xoff, yoff));
889  wxImagePtr hilite (OverlayImage(eHilite, eStandardUp, xoff, yoff));
890  wxImagePtr down (OverlayImage(eDown, eStandardDown, xoff + 1, yoff + 1));
891  wxImagePtr downHi (OverlayImage(eDownHi, eStandardDown, xoff + 1, yoff + 1));
892  wxImagePtr disable (OverlayImage(eUp, eDisabled, xoff, yoff));
893 
894  button.SetAlternateImages(idx, *up, *hilite, *down, *downHi, *disable);
895 }

References ThemeBase::Image(), OverlayImage(), AButton::SetAlternateImages(), size, and theTheme.

Referenced by ControlToolBar::MakeAlternateImages(), TranscriptionToolBar::MakeAlternateImages(), and AdornedRulerPanel::ReCreateButtons().

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

◆ MakeButton()

AButton * ToolBar::MakeButton ( wxWindow *  parent,
teBmps  eUp,
teBmps  eDown,
teBmps  eHilite,
teBmps  eDownHi,
teBmps  eStandardUp,
teBmps  eStandardDown,
teBmps  eDisabled,
wxWindowID  id,
wxPoint  placement,
bool  processdownevents,
wxSize  size 
)
static

Makes a button and its four different state bitmaps

Parameters
parentParent window for the button.
eUpBackground for when button is Up.
eDownBackground for when button is Down.
eHiliteBackground for when button is Hilit.
eStandardUpForeground when enabled, up.
eStandardDownForeground when enabled, down.
eDisabledForeground when disabled.
idWindows Id.
placementPlacement position
processdowneventstrue iff button handles down events.
sizeSize of the background.

Definition at line 840 of file ToolBar.cpp.

852 {
853  // wxMax to cater for case of image being bigger than the button.
854  int xoff = wxMax( 0, (size.GetWidth() - theTheme.Image(eStandardUp).GetWidth())/2);
855  int yoff = wxMax( 0, (size.GetHeight() - theTheme.Image(eStandardUp).GetHeight())/2);
856 
857  typedef std::unique_ptr<wxImage> wxImagePtr;
858  wxImagePtr up2 (OverlayImage(eUp, eStandardUp, xoff, yoff));
859  wxImagePtr hilite2 (OverlayImage(eHilite, eStandardUp, xoff, yoff));
860  wxImagePtr down2 (OverlayImage(eDown, eStandardDown, xoff + 1, yoff + 1));
861  wxImagePtr downHi2 (OverlayImage(eDownHi, eStandardDown, xoff + 1, yoff + 1));
862  wxImagePtr disable2 (OverlayImage(eUp, eDisabled, xoff, yoff));
863 
864  wxASSERT(parent); // to justify safenew
865  AButton * button =
866  safenew AButton(parent, id, placement, size, *up2, *hilite2, *down2, *downHi2,
867  *disable2, processdownevents);
868 
869  return button;
870 }

References ThemeBase::Image(), OverlayImage(), safenew, size, and theTheme.

Referenced by EditToolBar::AddButton(), ScrubbingToolBar::AddButton(), TranscriptionToolBar::AddButton(), ControlToolBar::MakeButton(), ToolsToolBar::MakeTool(), and AdornedRulerPanel::ReCreateButtons().

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

◆ MakeButtonBackgroundsLarge()

void ToolBar::MakeButtonBackgroundsLarge ( )
static

Definition at line 776 of file ToolBar.cpp.

777 {
778 
779  bool bUseAqua = false;
780 
781 #ifdef EXPERIMENTAL_THEME_PREFS
782  gPrefs->Read( wxT("/GUI/ShowMac"), &bUseAqua, false);
783 #endif
784 
785 #ifdef USE_AQUA_THEME
786  bUseAqua = !bUseAqua;
787 #endif
788 
789  if( bUseAqua ){
790  MakeMacRecoloredImage( bmpRecoloredUpLarge, bmpMacUpButton );
791  MakeMacRecoloredImage( bmpRecoloredDownLarge, bmpMacDownButton );
792  MakeMacRecoloredImage( bmpRecoloredUpHiliteLarge, bmpMacHiliteUpButton );
793  MakeMacRecoloredImage( bmpRecoloredHiliteLarge, bmpMacHiliteButton );
794  } else {
795  MakeRecoloredImage( bmpRecoloredUpLarge, bmpUpButtonLarge );
796  MakeRecoloredImage( bmpRecoloredDownLarge, bmpDownButtonLarge );
797  MakeRecoloredImage( bmpRecoloredUpHiliteLarge, bmpHiliteUpButtonLarge );
798  MakeRecoloredImage( bmpRecoloredHiliteLarge, bmpHiliteButtonLarge );
799  }
800 }

References gPrefs, MakeMacRecoloredImage(), and MakeRecoloredImage().

Referenced by ControlToolBar::Populate().

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

◆ MakeButtonBackgroundsSmall()

void ToolBar::MakeButtonBackgroundsSmall ( )
static

Definition at line 802 of file ToolBar.cpp.

803 {
804 
805  bool bUseAqua = false;
806 
807 #ifdef EXPERIMENTAL_THEME_PREFS
808  gPrefs->Read( wxT("/GUI/ShowMac"), &bUseAqua, false);
809 #endif
810 
811 #ifdef USE_AQUA_THEME
812  bUseAqua = !bUseAqua;
813 #endif
814 
815  if( bUseAqua ){
816  MakeMacRecoloredImage( bmpRecoloredUpSmall, bmpMacUpButtonSmall );
817  MakeMacRecoloredImage( bmpRecoloredDownSmall, bmpMacDownButtonSmall );
818  MakeMacRecoloredImage( bmpRecoloredUpHiliteSmall, bmpMacHiliteUpButtonSmall );
819  MakeMacRecoloredImage( bmpRecoloredHiliteSmall, bmpMacHiliteButtonSmall );
820  } else {
821  MakeRecoloredImage( bmpRecoloredUpSmall, bmpUpButtonSmall );
822  MakeRecoloredImage( bmpRecoloredDownSmall, bmpDownButtonSmall );
823  MakeRecoloredImage( bmpRecoloredUpHiliteSmall, bmpHiliteUpButtonSmall );
824  MakeRecoloredImage( bmpRecoloredHiliteSmall, bmpHiliteButtonSmall );
825  }
826 }

References gPrefs, MakeMacRecoloredImage(), and MakeRecoloredImage().

Referenced by EditToolBar::Populate(), ScrubbingToolBar::Populate(), ToolsToolBar::Populate(), TranscriptionToolBar::Populate(), and AdornedRulerPanel::ReCreateButtons().

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

◆ MakeMacRecoloredImage()

void ToolBar::MakeMacRecoloredImage ( teBmps  eBmpOut,
teBmps  eBmpIn 
)
staticprotected

Definition at line 765 of file ToolBar.cpp.

766 {
767  theTheme.ReplaceImage( eBmpOut, &theTheme.Image( eBmpIn ));
768 }

References ThemeBase::Image(), ThemeBase::ReplaceImage(), and theTheme.

Referenced by MakeButtonBackgroundsLarge(), MakeButtonBackgroundsSmall(), and MakeRecoloredImage().

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

◆ MakeRecoloredImage()

void ToolBar::MakeRecoloredImage ( teBmps  eBmpOut,
teBmps  eBmpIn 
)
staticprotected

Definition at line 770 of file ToolBar.cpp.

771 {
772  // Don't recolour the buttons...
773  MakeMacRecoloredImage( eBmpOut, eBmpIn );
774 }

References MakeMacRecoloredImage().

Referenced by MakeButtonBackgroundsLarge(), and MakeButtonBackgroundsSmall().

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

◆ OnErase()

void ToolBar::OnErase ( wxEraseEvent &  event)
protected

Definition at line 929 of file ToolBar.cpp.

930 {
931  // Ignore it to prevent flashing
932 }

◆ OnMouseEvents()

void ToolBar::OnMouseEvents ( wxMouseEvent &  event)
protected

Definition at line 948 of file ToolBar.cpp.

949 {
950  // Do this hack so scrubber can detect mouse drags anywhere
951  event.ResumePropagation(wxEVENT_PROPAGATE_MAX);
952  event.Skip();
953 }

◆ OnPaint()

void ToolBar::OnPaint ( wxPaintEvent &  event)
protected

Definition at line 937 of file ToolBar.cpp.

938 {
939  wxPaintDC dc( this );
940 
941  // Themed background colour.
942  dc.SetBackground( wxBrush( theTheme.Colour( clrMedium ) ) );
943  dc.Clear();
944 
945  Repaint( &dc );
946 }

References ThemeBase::Colour(), Repaint(), and theTheme.

Here is the call graph for this function:

◆ Populate()

virtual void ToolBar::Populate ( )
protectedpure virtual

Implemented in TranscriptionToolBar, ToolsToolBar, TimeToolBar, SpectralSelectionBar, SelectionBar, ScrubbingToolBar, MixerToolBar, MeterToolBar, EditToolBar, DeviceToolBar, and ControlToolBar.

Referenced by ReCreateButtons().

Here is the caller graph for this function:

◆ ReCreateButtons()

void ToolBar::ReCreateButtons ( )
virtual

Reimplemented in MeterToolBar, and ControlToolBar.

Definition at line 516 of file ToolBar.cpp.

517 {
518  wxSize sz3 = GetSize();
519  //wxLogDebug( "x:%i y:%i",sz3.x, sz3.y);
520 
521  // SetSizer(NULL) detaches mHSizer and deletes it.
522  // Do not use Detach() here, as that attempts to detach mHSizer from itself!
523  SetSizer( NULL );
524 
525  // Get rid of any children we may have
526  DestroyChildren();
527  mGrabber = NULL;
528  mResizer = NULL;
529  SetLayoutDirection(wxLayout_LeftToRight);
530 
531  // Refresh the background before populating
532  if (!IsDocked())
533  {
534  GetParent()->Refresh();
535  }
536 
537  {
538  // Create the main sizer
539  auto ms = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
540 
541  // Create the grabber and add it to the main sizer
542  mGrabber = safenew Grabber(this, mType);
543  ms->Add(mGrabber, 0, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP | wxRIGHT, 1);
544 
545  // Use a box sizer for laying out controls
546  ms->Add((mHSizer = safenew wxBoxSizer(wxHORIZONTAL)), 1, wxEXPAND);
547 
548  // Go add all the rest of the gadgets
549  Populate();
550 
551  // Add some space for the resize border
552  if (IsResizable())
553  {
554  // Create the resizer and add it to the main sizer
556  ms->Add(mResizer, 0, wxEXPAND | wxALIGN_TOP | wxLEFT, 1);
557  mResizer->SetToolTip(_("Click and drag to resize toolbar"));
558  }
559 
560  // Set dock after possibly creating resizer.
561  // (Re)Establish dock state
562  SetDocked(GetDock(), false);
563 
564  // Set the sizer
565  SetSizerAndFit(ms.release());
566  }
567 
568  // Recalculate the height to be a multiple of toolbarSingle
569  const int tbs = toolbarSingle + toolbarGap;
570  wxSize sz = GetSize();
571  sz.y = ( ( ( sz.y + tbs -1) / tbs ) * tbs ) - 1;
572 
573  // Set the true AND minimum sizes and do final layout
574  if(IsResizable())
575  {
576  // JKC we're going to allow all resizable toolbars to be resized
577  // to 1 unit high, typically 27 pixels.
578  wxSize sz2 = sz;
579  sz2.SetWidth(GetMinToolbarWidth());
580  sz2.y = tbs -1;
581  SetMinSize(sz2);
582 
583  // sz2 is now the minimum size.
584  // sz3 is the size we were.
585 
586  // We're recreating buttons, and we want to preserve original size.
587  // But not if that makes the size too small.
588 
589  // Size at least as big as minimum.
590  if( sz3.y < sz2.y )
591  sz3.y = sz2.y;
592  if( sz3.x < sz2.x )
593  sz3.x = sz2.x;
594  SetSize(sz3);
595  }
596  else
597  {
598  SetInitialSize(sz);
599  }
600  Layout();
601 }

References _, GetDock(), GetMinToolbarWidth(), IsDocked(), IsResizable(), mGrabber, mHSizer, mResizer, mType, Populate(), safenew, SetDocked(), toolbarGap, ToolBarResizer, and toolbarSingle.

Referenced by Create(), ProjectWindow::OnThemeChange(), SelectionBar::OnUpdate(), ControlToolBar::ReCreateButtons(), MeterToolBar::ReCreateButtons(), and ToolManager::Reset().

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

◆ RegenerateTooltips()

virtual void ToolBar::RegenerateTooltips ( )
pure virtual

◆ Repaint()

virtual void ToolBar::Repaint ( wxDC *  dc)
protectedpure virtual

Implemented in ControlToolBar.

Referenced by OnPaint().

Here is the caller graph for this function:

◆ ResizingDone()

virtual void ToolBar::ResizingDone ( )
inlinevirtual

Reimplemented in TimeToolBar.

Definition at line 186 of file ToolBar.h.

186 {};

Referenced by ToolBarResizer::OnLeftUp(), and ToolManager::ReadConfig().

Here is the caller graph for this function:

◆ SetButton()

void ToolBar::SetButton ( bool  down,
AButton button 
)
protected

Definition at line 914 of file ToolBar.cpp.

915 {
916  if( down )
917  {
918  button->PushDown();
919  }
920  else
921  {
922  button->PopUp();
923  }
924 }

References AButton::PopUp(), and AButton::PushDown().

Here is the call graph for this function:

◆ SetButtonToolTip()

void ToolBar::SetButtonToolTip ( AudacityProject project,
AButton button,
const ComponentInterfaceSymbol  commands[],
size_t  nCommands 
)
static

Definition at line 897 of file ToolBar.cpp.

900 {
901  TranslatableString result;
902  const auto project = &theProject;
903  const auto commandManager =
904  project ? &CommandManager::Get( *project ) : nullptr;
905  if (commandManager)
906  result =
907  commandManager->DescribeCommandsAndShortcuts(commands, nCommands);
908  button.SetToolTip( result );
909 }

References CommandManager::Get(), and AButton::SetToolTip().

Referenced by ScrubbingToolBar::DoRegenerateTooltips(), EditToolBar::ForAllButtons(), ControlToolBar::RegenerateTooltips(), ToolsToolBar::RegenerateTooltips(), TranscriptionToolBar::RegenerateTooltips(), and AdornedRulerPanel::UpdateButtonStates().

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

◆ SetDocked()

void ToolBar::SetDocked ( ToolDock dock,
bool  pushed 
)
virtual

Reimplemented in TimeToolBar, and MeterToolBar.

Definition at line 638 of file ToolBar.cpp.

639 {
640  // Remember it
641 // mDock = dock;
642 
643  // Change the tooltip of the grabber
644 #if wxUSE_TOOLTIPS
646 #endif
647 
648  // Set the grabber button state
649  mGrabber->PushButton( pushed );
650 
651  if (mResizer)
652  {
653  mResizer->Show(dock != NULL);
654  Layout();
655  }
656 }

References GetTitle(), mGrabber, mResizer, Grabber::PushButton(), and Grabber::SetToolTip().

Referenced by ToolDock::Dock(), ToolManager::DoneDragging(), ToolManager::HandleEscapeKey(), ToolManager::OnMouse(), ToolManager::ReadConfig(), ReCreateButtons(), ToolManager::Reset(), MeterToolBar::SetDocked(), TimeToolBar::SetDocked(), and ToolManager::UndockBar().

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

◆ SetLabel() [1/2]

void ToolBar::SetLabel ( const TranslatableString label)

Definition at line 405 of file ToolBar.cpp.

406 {
407  // Only this overload is publicly accessible when you have a pointer to
408  // Toolbar or a subclass of it
409  mLabel = label;
410 }

References label, and mLabel.

◆ SetLabel() [2/2]

void ToolBar::SetLabel ( const wxString &  label)
overrideprivate

Definition at line 398 of file ToolBar.cpp.

399 {
400  // Probably shouldn't reach this overload, but perhaps virtual function
401  // dispatch will take us here from a pointer to the wxPanel base class
402  mLabel = Verbatim( label );
403 }

References label, mLabel, and Verbatim().

Referenced by ControlToolBar::UpdatePrefs(), DeviceToolBar::UpdatePrefs(), EditToolBar::UpdatePrefs(), MeterToolBar::UpdatePrefs(), MixerToolBar::UpdatePrefs(), ScrubbingToolBar::UpdatePrefs(), SelectionBar::UpdatePrefs(), TimeToolBar::UpdatePrefs(), and TranscriptionToolBar::UpdatePrefs().

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

◆ SetPositioned()

void ToolBar::SetPositioned ( )
inline

Definition at line 139 of file ToolBar.h.

139 { mPositioned = true;};

Referenced by Expose(), ToolManager::ReadConfig(), and ToolManager::UndockBar().

Here is the caller graph for this function:

◆ SetToDefaultSize()

void ToolBar::SetToDefaultSize ( )
virtual

Reimplemented in TimeToolBar.

Definition at line 496 of file ToolBar.cpp.

496  {
497  wxSize sz;
498  sz.SetHeight( -1 );
499  sz.SetWidth( GetInitialWidth());
500  SetSize( sz );
501 }

References GetInitialWidth().

Referenced by ToolManager::Reset().

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

◆ SetVisible()

void ToolBar::SetVisible ( bool  bVisible)

Definition at line 436 of file ToolBar.cpp.

437 {
438  mVisible = bVisible;
439 }

References mVisible.

Referenced by Expose(), and ToolManager::ReadConfig().

Here is the caller graph for this function:

◆ Updated()

void ToolBar::Updated ( )
protected

Definition at line 661 of file ToolBar.cpp.

662 {
663  if( IsDocked() )
664  GetDock()->Updated();
665  else
666  // Bug 2120. Changing the choice also changes the size of the toolbar so
667  // we need to update the client size, even if undocked.
668  // If modifying/improving this, remember to test both changing the choice,
669  // and clicking on the choice but not actually changing it.
670  GetParent()->SetClientSize( GetSize() + wxSize( 2,2));
671  //wxCommandEvent e( EVT_TOOLBAR_UPDATED, GetId() );
672  //GetParent()->GetEventHandler()->AddPendingEvent( e );
673 }

References GetDock(), IsDocked(), and ToolDock::Updated().

Referenced by SelectionBar::OnUpdate(), TimeToolBar::OnUpdate(), ToolBarResizer::ResizeBar(), TimeToolBar::ResizingDone(), SelectionBar::SelectionModeUpdated(), TimeToolBar::SetDocked(), TimeToolBar::SetToDefaultSize(), ControlToolBar::UpdatePrefs(), and MixerToolBar::UpdatePrefs().

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

◆ UpdatePrefs()

void ToolBar::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Reimplemented in TranscriptionToolBar, and ToolsToolBar.

Definition at line 605 of file ToolBar.cpp.

606 {
607 #if wxUSE_TOOLTIPS
608  // Change the tooltip of the grabber
609  if ( mGrabber )
610  {
612  }
613 
614  // Change the tooltip of the resizer
615  if ( mResizer )
616  {
617  mResizer->SetToolTip( _("Click and drag to resize toolbar") );
618  wxSizeEvent e;
619  GetParent()->GetEventHandler()->AddPendingEvent( e );
620  GetParent()->Refresh();
621  }
622 #endif
623 
624  return;
625 }

References _, GetTitle(), mGrabber, mResizer, and Grabber::SetToolTip().

Referenced by ControlToolBar::UpdatePrefs(), DeviceToolBar::UpdatePrefs(), EditToolBar::UpdatePrefs(), MeterToolBar::UpdatePrefs(), MixerToolBar::UpdatePrefs(), ScrubbingToolBar::UpdatePrefs(), SelectionBar::UpdatePrefs(), TimeToolBar::UpdatePrefs(), ToolsToolBar::UpdatePrefs(), and TranscriptionToolBar::UpdatePrefs().

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

Friends And Related Function Documentation

◆ ToolBarResizer

friend class ToolBarResizer
friend

Definition at line 258 of file ToolBar.h.

Referenced by ReCreateButtons().

Member Data Documentation

◆ mGrabber

Grabber* ToolBar::mGrabber
private

Definition at line 244 of file ToolBar.h.

Referenced by ReCreateButtons(), SetDocked(), and UpdatePrefs().

◆ mHSizer

wxBoxSizer* ToolBar::mHSizer
private

Definition at line 247 of file ToolBar.h.

Referenced by Add(), AddSpacer(), AddStretchSpacer(), Detach(), GetSizer(), and ReCreateButtons().

◆ mLabel

TranslatableString ToolBar::mLabel
protected

Definition at line 236 of file ToolBar.h.

Referenced by GetLabel(), and SetLabel().

◆ mParent

wxWindow* ToolBar::mParent
private

Definition at line 242 of file ToolBar.h.

Referenced by Create().

◆ mPositioned

bool ToolBar::mPositioned
private

Definition at line 251 of file ToolBar.h.

◆ mProject

AudacityProject& ToolBar::mProject
protected

◆ mResizable

bool ToolBar::mResizable
private

Definition at line 250 of file ToolBar.h.

Referenced by IsResizable().

◆ mResizer

ToolBarResizer* ToolBar::mResizer
private

Definition at line 245 of file ToolBar.h.

Referenced by ReCreateButtons(), SetDocked(), and UpdatePrefs().

◆ mSection

wxString ToolBar::mSection
protected

Definition at line 237 of file ToolBar.h.

Referenced by GetSection().

◆ mType

int ToolBar::mType
protected

Definition at line 238 of file ToolBar.h.

Referenced by Create(), Expose(), GetType(), and ReCreateButtons().

◆ mVisible

bool ToolBar::mVisible
private

Definition at line 249 of file ToolBar.h.

Referenced by Create(), Expose(), IsVisible(), and SetVisible().


The documentation for this class was generated from the following files:
size
size_t size
Definition: ffmpeg-2.3.6-single-header.h:412
toolbarGap
#define toolbarGap
Definition: ToolBar.h:64
ToolBar::Populate
virtual void Populate()=0
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
ToolBar::MakeRecoloredImage
static void MakeRecoloredImage(teBmps eBmpOut, teBmps eBmpIn)
Definition: ToolBar.cpp:770
ToolDock
A dynamic panel where a ToolBar can be docked.
Definition: ToolDock.h:290
flag
static std::once_flag flag
Definition: WaveformView.cpp:1119
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
AButton
A wxButton with mouse-over behaviour.
Definition: AButton.h:25
wxPanelWrapper::SetLabel
void SetLabel(const TranslatableString &label)
Definition: wxPanelWrapper.cpp:46
ToolBar::mProject
AudacityProject & mProject
Definition: ToolBar.h:235
AButton::PopUp
void PopUp()
Definition: AButton.cpp:605
ToolBar::mResizable
bool mResizable
Definition: ToolBar.h:250
ToolDock::Updated
void Updated()
Definition: ToolDock.cpp:853
ToolBar::GetTitle
TranslatableString GetTitle()
Definition: ToolBar.cpp:365
ToolBar::mVisible
bool mVisible
Definition: ToolBar.h:249
XO
#define XO(s)
Definition: Internat.h:31
ToolBar::mSection
wxString mSection
Definition: ToolBar.h:237
OverlayImage
std::unique_ptr< wxImage > OverlayImage(wxImage *background, wxImage *foreground, wxImage *mask, int xoff, int yoff)
Definition: ImageManipulation.cpp:105
ToolBar::ReCreateButtons
virtual void ReCreateButtons()
Definition: ToolBar.cpp:516
ToolBar::mParent
wxWindow * mParent
Definition: ToolBar.h:242
Grabber
The widget to the left of a ToolBar that allows it to be dragged around to NEW positions.
Definition: Grabber.h:103
ToolBar::GetLabel
TranslatableString GetLabel()
Definition: ToolBar.cpp:374
ThemeBase::ReplaceImage
void ReplaceImage(int iIndex, wxImage *pImage)
Replaces both the image and the bitmap.
Definition: Theme.cpp:1098
ToolBar::mLabel
TranslatableString mLabel
Definition: ToolBar.h:236
AButton::SetAlternateImages
void SetAlternateImages(unsigned idx, ImageRoll up, ImageRoll over, ImageRoll down, ImageRoll overDown, ImageRoll dis)
Definition: AButton.cpp:304
Grabber::SetToolTip
void SetToolTip(const TranslatableString &toolTip)
Definition: Grabber.cpp:110
ToolBar::IsPositioned
bool IsPositioned()
Definition: ToolBar.h:137
label
TranslatableString label
Definition: Tags.cpp:756
ToolBar::mPositioned
bool mPositioned
Definition: ToolBar.h:251
ToolBar::mType
int mType
Definition: ToolBar.h:238
ToolBar::SetPositioned
void SetPositioned()
Definition: ToolBar.h:139
ToolBar::Repaint
virtual void Repaint(wxDC *dc)=0
Grabber::PushButton
void PushButton(bool state)
Definition: Grabber.cpp:188
ThemeBase::Image
wxImage & Image(int iIndex)
Definition: Theme.cpp:1083
AButton::PushDown
void PushDown()
Definition: AButton.cpp:597
RWIDTH
#define RWIDTH
ToolBarResizer.
Definition: ToolBar.cpp:65
ToolBar::GetDock
ToolDock * GetDock()
Definition: ToolBar.cpp:630
ToolBar::mHSizer
wxBoxSizer * mHSizer
Definition: ToolBar.h:247
ToolBar::IsResizable
bool IsResizable() const
Definition: ToolBar.cpp:415
ToolBar::GetInitialWidth
virtual int GetInitialWidth()
Resizable toolbars should implement these.
Definition: ToolBar.h:143
ToolBar::mGrabber
Grabber * mGrabber
Definition: ToolBar.h:244
ToolBar::IsDocked
bool IsDocked() const
Definition: ToolBar.cpp:423
theTheme
THEME_API Theme theTheme
Definition: Theme.cpp:79
ToolBar::MakeMacRecoloredImage
static void MakeMacRecoloredImage(teBmps eBmpOut, teBmps eBmpIn)
Definition: ToolBar.cpp:765
ToolBar::GetMinToolbarWidth
virtual int GetMinToolbarWidth()
Definition: ToolBar.h:144
_
#define _(s)
Definition: Internat.h:75
wxPanelWrapper::wxPanelWrapper
wxPanelWrapper()
Definition: wxPanelWrapper.h:44
Verbatim
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Definition: TranslatableString.h:321
ToolBar
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed.
Definition: ToolBar.h:98
wxPanelWrapper::Create
bool Create(wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
Definition: wxPanelWrapper.h:59
ThemeBase::Colour
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1057
AButton::SetToolTip
void SetToolTip(const TranslatableString &toolTip)
Definition: AButton.cpp:269
ToolBar::SetDocked
virtual void SetDocked(ToolDock *dock, bool pushed)
Definition: ToolBar.cpp:638
CommandManager::Get
static CommandManager & Get(AudacityProject &project)
Definition: CommandManager.cpp:207
ToolBar::SetVisible
void SetVisible(bool bVisible)
Definition: ToolBar.cpp:436
safenew
#define safenew
Definition: MemoryX.h:10
ToolBar::mResizer
ToolBarResizer * mResizer
Definition: ToolBar.h:245
toolbarSingle
#define toolbarSingle
Definition: ToolBar.h:59
ToolBar::ToolBarResizer
friend class ToolBarResizer
Definition: ToolBar.h:258