Audacity  2.2.2
Public Types | Public Member Functions | Static Public Member Functions | 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:
wxPanelWrapper wxTabTraversalWrapper< wxPanel > ControlToolBar DeviceToolBar EditToolBar MeterToolBar MixerToolBar ScrubbingToolBar SelectionBar SpectralSelectionBar ToolsToolBar TranscriptionToolBar

Public Types

using Holder = Destroy_ptr< ToolBar >
 
using LocalizedCommandName = std::pair< wxString, const wxChar * >
 
using LocalizedCommandNameVector = std::vector< LocalizedCommandName >
 

Public Member Functions

 ToolBar (int type, const wxString &label, const wxString &section, bool resizable=false)
 
virtual ~ToolBar ()
 
bool AcceptsFocus () const override
 
virtual void Create (wxWindow *parent)
 
virtual void EnableDisableButtons ()=0
 
virtual void ReCreateButtons ()
 
virtual void UpdatePrefs ()
 
virtual void RegenerateTooltips ()=0
 
int GetType ()
 
wxString GetTitle ()
 
wxString GetLabel ()
 
wxString GetSection ()
 
ToolDockGetDock ()
 
void SetLabel (const wxString &label)
 
void SetDock (ToolDock *dock)
 
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 ()
 
- 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 wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&...args)
 

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 (AButton &button, const LocalizedCommandNameVector &commands)
 

Protected Member Functions

void SetButton (bool down, AButton *button)
 
void MakeMacRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
void MakeRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
void MakeButtonBackgroundsLarge ()
 
void MakeButtonBackgroundsSmall ()
 
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 Attributes

wxString mLabel
 
wxString mSection
 
int mType
 

Private Member Functions

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 87 of file ToolBar.h.

Member Typedef Documentation

Definition at line 92 of file ToolBar.h.

using ToolBar::LocalizedCommandName = std::pair<wxString, const wxChar*>

Definition at line 159 of file ToolBar.h.

Definition at line 160 of file ToolBar.h.

Constructor & Destructor Documentation

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

Definition at line 312 of file ToolBar.cpp.

References label.

316 : wxPanelWrapper()
317 {
318  // Save parameters
319  mType = type;
320  mLabel = label;
321  mSection = section;
322  mResizable = resizable;
323 
324  // Initialize everything
325  mParent = NULL;
326  mHSizer = NULL;
327  mVisible = false;
328  mPositioned = false;
329 
330  mGrabber = NULL;
331  mResizer = NULL;
332 
333  SetId(mType);
334 }
bool mResizable
Definition: ToolBar.h:233
bool mPositioned
Definition: ToolBar.h:234
wxString label
Definition: Tags.cpp:727
wxBoxSizer * mHSizer
Definition: ToolBar.h:230
int mType
Definition: ToolBar.h:221
wxString mLabel
Definition: ToolBar.h:219
wxString mSection
Definition: ToolBar.h:220
Grabber * mGrabber
Definition: ToolBar.h:227
bool mVisible
Definition: ToolBar.h:232
ToolBarResizer * mResizer
Definition: ToolBar.h:228
wxWindow * mParent
Definition: ToolBar.h:225
ToolBar::~ToolBar ( )
virtual

Definition at line 339 of file ToolBar.cpp.

340 {
341 }

Member Function Documentation

bool ToolBar::AcceptsFocus ( ) const
inlineoverride

Definition at line 97 of file ToolBar.h.

97 { return false; };
void ToolBar::Add ( wxWindow *  window,
int  proportion = 0,
int  flag = wxALIGN_TOP,
int  border = 0,
wxObject *  userData = NULL 
)
protected
void ToolBar::Add ( wxSizer *  sizer,
int  proportion = 0,
int  flag = 0,
int  border = 0,
wxObject *  userData = NULL 
)
protected

Definition at line 632 of file ToolBar.cpp.

References mHSizer.

637 {
638  mHSizer->Add( sizer,
639  proportion,
640  flag,
641  border,
642  userData );
643 }
wxBoxSizer * mHSizer
Definition: ToolBar.h:230
void ToolBar::Add ( int  width,
int  height,
int  proportion = 0,
int  flag = 0,
int  border = 0,
wxObject *  userData = NULL 
)
protected

Definition at line 648 of file ToolBar.cpp.

References mHSizer.

654 {
655  mHSizer->Add( width,
656  height,
657  proportion,
658  flag,
659  border,
660  userData );
661 }
wxBoxSizer * mHSizer
Definition: ToolBar.h:230
void ToolBar::AddSpacer ( int  size = 14)
protected

Definition at line 666 of file ToolBar.cpp.

References mHSizer.

Referenced by EditToolBar::AddSeparator().

667 {
668  mHSizer->AddSpacer( size );
669 }
wxBoxSizer * mHSizer
Definition: ToolBar.h:230
void ToolBar::AddStretchSpacer ( int  prop = 1)
protected

Definition at line 674 of file ToolBar.cpp.

References mHSizer.

675 {
676  mHSizer->AddStretchSpacer( prop );
677 }
wxBoxSizer * mHSizer
Definition: ToolBar.h:230
void ToolBar::Create ( wxWindow *  parent)
virtual

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

Definition at line 443 of file ToolBar.cpp.

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

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

444 {
445  // Save parameters
446  mParent = parent;
447 
448  // Create the window and label it
450  mType,
451  wxDefaultPosition,
452  wxDefaultSize,
453  wxNO_BORDER | wxTAB_TRAVERSAL,
454  GetTitle() );
455  wxPanelWrapper::SetLabel( GetLabel() );
456 
457  // Go do the rest of the creation
458  ReCreateButtons();
459 
460  // ToolManager depends on this appearing to be visible for proper dock construction
461  mVisible = true;
462 }
virtual void ReCreateButtons()
Definition: ToolBar.cpp:464
int mType
Definition: ToolBar.h:221
wxString GetLabel()
Definition: ToolBar.cpp:355
bool mVisible
Definition: ToolBar.h:232
wxWindow * mParent
Definition: ToolBar.h:225
wxString GetTitle()
Definition: ToolBar.cpp:346
bool Create(wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
void ToolBar::Detach ( wxWindow *  window)
protected

Definition at line 682 of file ToolBar.cpp.

References mHSizer.

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

683 {
684  mHSizer->Detach( window );
685 }
wxBoxSizer * mHSizer
Definition: ToolBar.h:230
void ToolBar::Detach ( wxSizer *  sizer)
protected

Definition at line 690 of file ToolBar.cpp.

References mHSizer.

691 {
692  mHSizer->Detach( sizer );
693 }
wxBoxSizer * mHSizer
Definition: ToolBar.h:230
virtual void ToolBar::EnableDisableButtons ( )
pure virtual
bool ToolBar::Expose ( bool  show = true)
virtual

Reimplemented in MeterToolBar.

Definition at line 416 of file ToolBar.cpp.

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

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

417 {
418  bool was = mVisible;
419 
420  SetVisible( show );
421 
422  if( IsDocked() )
423  {
424  Show( show );
425  }
426  else
427  {
428  wxWindow * pParent = GetParent();
429  if( !IsPositioned() && show ){
430  SetPositioned();
431  pParent->CentreOnParent();
432  pParent->Move( pParent->GetPosition() + wxSize( mType*10, mType*10 ));
433  }
434  pParent->Show( show );
435  }
436 
437  return was;
438 }
bool IsDocked() const
Definition: ToolBar.cpp:395
void SetVisible(bool bVisible)
Definition: ToolBar.cpp:408
bool IsPositioned()
Definition: ToolBar.h:123
int mType
Definition: ToolBar.h:221
bool mVisible
Definition: ToolBar.h:232
void SetPositioned()
Definition: ToolBar.h:125
ToolDock * ToolBar::GetDock ( )

Definition at line 565 of file ToolBar.cpp.

Referenced by ToolManager::Expose(), IsDocked(), ToolManager::ReadConfig(), ReCreateButtons(), DeviceToolBar::RepositionCombos(), ToolManager::Reset(), Updated(), and ToolManager::WriteConfig().

566 {
567  return dynamic_cast<ToolDock*>(GetParent());
568 }
A dynamic panel where a ToolBar can be docked.
Definition: ToolDock.h:290
virtual wxSize ToolBar::GetDockedSize ( )
inlinevirtual

Reimplemented in MeterToolBar.

Definition at line 131 of file ToolBar.h.

Referenced by ToolDock::Dock().

131 { return GetMinSize(); }
virtual int ToolBar::GetInitialWidth ( )
inlinevirtual

Resizable toolbars should implement these.

Reimplemented in MeterToolBar, and DeviceToolBar.

Definition at line 129 of file ToolBar.h.

Referenced by GetMinToolbarWidth(), and ReCreateButtons().

129 { return -1; }
wxString ToolBar::GetLabel ( )

Definition at line 355 of file ToolBar.cpp.

References mLabel.

Referenced by Create(), and GetTitle().

356 {
357  return mLabel;
358 }
wxString mLabel
Definition: ToolBar.h:219
virtual int ToolBar::GetMinToolbarWidth ( )
inlinevirtual

Reimplemented in MeterToolBar, and DeviceToolBar.

Definition at line 130 of file ToolBar.h.

References GetInitialWidth().

Referenced by ReCreateButtons().

130 { return GetInitialWidth(); }
virtual int GetInitialWidth()
Resizable toolbars should implement these.
Definition: ToolBar.h:129
int ToolBar::GetResizeGrabberWidth ( )
protected

Returns the width in pixels of the resizer element.

Definition at line 894 of file ToolBar.cpp.

References RWIDTH.

Referenced by DeviceToolBar::RepositionCombos().

895 {
896  return RWIDTH;
897 }
#define RWIDTH
ToolBarResizer.
Definition: ToolBar.cpp:64
wxString ToolBar::GetSection ( )

Definition at line 363 of file ToolBar.cpp.

References mSection.

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

364 {
365  return mSection;
366 }
wxString mSection
Definition: ToolBar.h:220
wxBoxSizer * ToolBar::GetSizer ( )
protected

Definition at line 608 of file ToolBar.cpp.

References mHSizer.

Referenced by ControlToolBar::ArrangeButtons(), SpectralSelectionBar::OnChoice(), MeterToolBar::OnSize(), SpectralSelectionBar::Populate(), and SelectionBar::Populate().

609 {
610  return mHSizer;
611 }
wxBoxSizer * mHSizer
Definition: ToolBar.h:230
wxString ToolBar::GetTitle ( )

Definition at line 346 of file ToolBar.cpp.

References _(), and GetLabel().

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

347 {
348  /* i18n-hint: %s will be replaced by the name of the kind of toolbar.*/
349  return wxString::Format( _("Audacity %s Toolbar"), GetLabel() );
350 }
wxString GetLabel()
Definition: ToolBar.cpp:355
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
int ToolBar::GetType ( )

Definition at line 371 of file ToolBar.cpp.

References mType.

Referenced by ToolManager::ReadConfig(), and ToolDock::VisitLayout().

372 {
373  return mType;
374 }
int mType
Definition: ToolBar.h:221
void ToolBar::Init ( wxWindow *  parent,
int  type,
const wxString &  title,
const wxString &  label 
)
private
bool ToolBar::IsDocked ( ) const

Definition at line 395 of file ToolBar.cpp.

References GetDock().

Referenced by ToolManager::Expose(), Expose(), ToolManager::IsVisible(), ToolManager::OnGrabber(), ToolFrame::OnMotion(), DeviceToolBar::RepositionCombos(), ToolManager::Reset(), Updated(), and ToolManager::WriteConfig().

396 {
397  return const_cast<ToolBar*>(this)->GetDock() != nullptr;
398 }
ToolDock * GetDock()
Definition: ToolBar.cpp:565
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed...
Definition: ToolBar.h:87
bool ToolBar::IsPositioned ( )
inline

Definition at line 123 of file ToolBar.h.

References mPositioned.

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

123 { return mPositioned; };
bool mPositioned
Definition: ToolBar.h:234
bool ToolBar::IsResizable ( ) const

Definition at line 387 of file ToolBar.cpp.

References mResizable.

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

388 {
389  return mResizable;
390 }
bool mResizable
Definition: ToolBar.h:233
bool ToolBar::IsVisible ( ) const

Definition at line 403 of file ToolBar.cpp.

References mVisible.

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

404 {
405  return mVisible;
406 }
bool mVisible
Definition: ToolBar.h:232
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 803 of file ToolBar.cpp.

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

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

812 {
813  // wxMax to cater for case of image being bigger than the button.
814  int xoff = wxMax( 0, (size.GetWidth() - theTheme.Image(eStandardUp).GetWidth())/2);
815  int yoff = wxMax( 0, (size.GetHeight() - theTheme.Image(eStandardUp).GetHeight())/2);
816 
817  typedef std::unique_ptr<wxImage> wxImagePtr;
818  wxImagePtr up (OverlayImage(eUp, eStandardUp, xoff, yoff));
819  wxImagePtr hilite (OverlayImage(eHilite, eStandardUp, xoff, yoff));
820  wxImagePtr down (OverlayImage(eDown, eStandardDown, xoff + 1, yoff + 1));
821  wxImagePtr downHi (OverlayImage(eDownHi, eStandardDown, xoff + 1, yoff + 1));
822  wxImagePtr disable (OverlayImage(eUp, eDisabled, xoff, yoff));
823 
824  button.SetAlternateImages(idx, *up, *hilite, *down, *downHi, *disable);
825 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
void SetAlternateImages(unsigned idx, ImageRoll up, ImageRoll over, ImageRoll down, ImageRoll overDown, ImageRoll dis)
Definition: AButton.cpp:232
std::unique_ptr< wxImage > OverlayImage(wxImage *background, wxImage *foreground, wxImage *mask, int xoff, int yoff)
wxImage & Image(int iIndex)
Definition: Theme.cpp:1234
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.
eStandardDownForegrounde when enabled, down.
eDisabledForeground when disabled.
idWindows Id.
placementPlacement position
processdowneventstrue iff button handles down events.
sizeSize of the background.

Definition at line 770 of file ToolBar.cpp.

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

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

782 {
783  // wxMax to cater for case of image being bigger than the button.
784  int xoff = wxMax( 0, (size.GetWidth() - theTheme.Image(eStandardUp).GetWidth())/2);
785  int yoff = wxMax( 0, (size.GetHeight() - theTheme.Image(eStandardUp).GetHeight())/2);
786 
787  typedef std::unique_ptr<wxImage> wxImagePtr;
788  wxImagePtr up2 (OverlayImage(eUp, eStandardUp, xoff, yoff));
789  wxImagePtr hilite2 (OverlayImage(eHilite, eStandardUp, xoff, yoff));
790  wxImagePtr down2 (OverlayImage(eDown, eStandardDown, xoff + 1, yoff + 1));
791  wxImagePtr downHi2 (OverlayImage(eDownHi, eStandardDown, xoff + 1, yoff + 1));
792  wxImagePtr disable2 (OverlayImage(eUp, eDisabled, xoff, yoff));
793 
794  wxASSERT(parent); // to justify safenew
795  AButton * button =
796  safenew AButton(parent, id, placement, size, *up2, *hilite2, *down2, *downHi2,
797  *disable2, processdownevents);
798 
799  return button;
800 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
std::unique_ptr< wxImage > OverlayImage(wxImage *background, wxImage *foreground, wxImage *mask, int xoff, int yoff)
#define safenew
Definition: Audacity.h:223
wxImage & Image(int iIndex)
Definition: Theme.cpp:1234
A wxButton with mouse-over behaviour.
Definition: AButton.h:27
void ToolBar::MakeButtonBackgroundsLarge ( )
protected

Definition at line 706 of file ToolBar.cpp.

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

Referenced by ControlToolBar::Populate().

707 {
708 
709  bool bUseAqua = false;
710 
711 #ifdef EXPERIMENTAL_THEME_PREFS
712  gPrefs->Read( wxT("/GUI/ShowMac"), &bUseAqua, false);
713 #endif
714 
715 #ifdef USE_AQUA_THEME
716  bUseAqua = !bUseAqua;
717 #endif
718 
719  if( bUseAqua ){
720  MakeMacRecoloredImage( bmpRecoloredUpLarge, bmpMacUpButton );
721  MakeMacRecoloredImage( bmpRecoloredDownLarge, bmpMacDownButton );
722  MakeMacRecoloredImage( bmpRecoloredUpHiliteLarge, bmpMacHiliteUpButton );
723  MakeMacRecoloredImage( bmpRecoloredHiliteLarge, bmpMacHiliteButton );
724  } else {
725  MakeRecoloredImage( bmpRecoloredUpLarge, bmpUpButtonLarge );
726  MakeRecoloredImage( bmpRecoloredDownLarge, bmpDownButtonLarge );
727  MakeRecoloredImage( bmpRecoloredUpHiliteLarge, bmpHiliteUpButtonLarge );
728  MakeRecoloredImage( bmpRecoloredHiliteLarge, bmpHiliteButtonLarge );
729  }
730 }
wxFileConfig * gPrefs
Definition: Prefs.cpp:72
void MakeRecoloredImage(teBmps eBmpOut, teBmps eBmpIn)
Definition: ToolBar.cpp:700
void MakeMacRecoloredImage(teBmps eBmpOut, teBmps eBmpIn)
Definition: ToolBar.cpp:695
void ToolBar::MakeButtonBackgroundsSmall ( )
protected

Definition at line 732 of file ToolBar.cpp.

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

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

733 {
734 
735  bool bUseAqua = false;
736 
737 #ifdef EXPERIMENTAL_THEME_PREFS
738  gPrefs->Read( wxT("/GUI/ShowMac"), &bUseAqua, false);
739 #endif
740 
741 #ifdef USE_AQUA_THEME
742  bUseAqua = !bUseAqua;
743 #endif
744 
745  if( bUseAqua ){
746  MakeMacRecoloredImage( bmpRecoloredUpSmall, bmpMacUpButtonSmall );
747  MakeMacRecoloredImage( bmpRecoloredDownSmall, bmpMacDownButtonSmall );
748  MakeMacRecoloredImage( bmpRecoloredUpHiliteSmall, bmpMacHiliteUpButtonSmall );
749  MakeMacRecoloredImage( bmpRecoloredHiliteSmall, bmpMacHiliteButtonSmall );
750  } else {
751  MakeRecoloredImage( bmpRecoloredUpSmall, bmpUpButtonSmall );
752  MakeRecoloredImage( bmpRecoloredDownSmall, bmpDownButtonSmall );
753  MakeRecoloredImage( bmpRecoloredUpHiliteSmall, bmpHiliteUpButtonSmall );
754  MakeRecoloredImage( bmpRecoloredHiliteSmall, bmpHiliteButtonSmall );
755  }
756 }
wxFileConfig * gPrefs
Definition: Prefs.cpp:72
void MakeRecoloredImage(teBmps eBmpOut, teBmps eBmpIn)
Definition: ToolBar.cpp:700
void MakeMacRecoloredImage(teBmps eBmpOut, teBmps eBmpIn)
Definition: ToolBar.cpp:695
void ToolBar::MakeMacRecoloredImage ( teBmps  eBmpOut,
teBmps  eBmpIn 
)
protected

Definition at line 695 of file ToolBar.cpp.

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

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

696 {
697  theTheme.ReplaceImage( eBmpOut, &theTheme.Image( eBmpIn ));
698 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
void ReplaceImage(int iIndex, wxImage *pImage)
Replaces both the image and the bitmap.
Definition: Theme.cpp:1270
wxImage & Image(int iIndex)
Definition: Theme.cpp:1234
void ToolBar::MakeRecoloredImage ( teBmps  eBmpOut,
teBmps  eBmpIn 
)
protected

Definition at line 700 of file ToolBar.cpp.

References MakeMacRecoloredImage().

Referenced by MakeButtonBackgroundsLarge(), and MakeButtonBackgroundsSmall().

701 {
702  // Don't recolour the buttons...
703  MakeMacRecoloredImage( eBmpOut, eBmpIn );
704 }
void MakeMacRecoloredImage(teBmps eBmpOut, teBmps eBmpIn)
Definition: ToolBar.cpp:695
void ToolBar::OnErase ( wxEraseEvent &  event)
protected

Definition at line 858 of file ToolBar.cpp.

859 {
860  // Ignore it to prevent flashing
861 }
void ToolBar::OnMouseEvents ( wxMouseEvent &  event)
protected

Definition at line 887 of file ToolBar.cpp.

888 {
889  // Do this hack so scrubber can detect mouse drags anywhere
890  event.ResumePropagation(wxEVENT_PROPAGATE_MAX);
891  event.Skip();
892 }
void ToolBar::OnPaint ( wxPaintEvent &  event)
protected

Definition at line 866 of file ToolBar.cpp.

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

867 {
868  wxPaintDC dc( (wxWindow *) event.GetEventObject() );
869 
870  // Start with a clean background
871  //
872  // Under GTK, we specifically set the toolbar background to the background
873  // colour in the system theme.
874 #if defined( __WXGTK__ )
875  //dc.SetBackground( wxBrush( wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND ) ) );
876 #endif
877 
878  // Themed background colour.
879  dc.SetBackground( wxBrush( theTheme.Colour( clrMedium ) ) );
880  dc.Clear();
881 
882 #ifdef USE_AQUA_THEME
883  Repaint( &dc );
884 #endif
885 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1208
virtual void Repaint(wxDC *dc)=0
virtual void ToolBar::Populate ( )
protectedpure virtual
void ToolBar::ReCreateButtons ( )
virtual

Reimplemented in ControlToolBar, and MeterToolBar.

Definition at line 464 of file ToolBar.cpp.

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

Referenced by Theme::ApplyUpdatedImages(), Create(), SpectralSelectionBar::OnUpdate(), SelectionBar::OnUpdate(), MeterToolBar::ReCreateButtons(), ControlToolBar::ReCreateButtons(), and ToolManager::Reset().

465 {
466  wxSize sz3 = GetSize();
467  //wxLogDebug( "x:%i y:%i",sz3.x, sz3.y);
468 
469  // SetSizer(NULL) detaches mHSizer and deletes it.
470  // Do not use Detach() here, as that attempts to detach mHSizer from itself!
471  SetSizer( NULL );
472 
473  // Get rid of any children we may have
474  DestroyChildren();
475  mGrabber = NULL;
476  mResizer = NULL;
477 
478  {
479  // Create the main sizer
480  auto ms = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
481 
482  // Create the grabber and add it to the main sizer
483  mGrabber = safenew Grabber(this, mType);
484  ms->Add(mGrabber, 0, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP | wxRIGHT, 1);
485 
486  // Use a box sizer for laying out controls
487  ms->Add((mHSizer = safenew wxBoxSizer(wxHORIZONTAL)), 1, wxEXPAND);
488 
489  // Go add all the rest of the gadgets
490  Populate();
491 
492  // Add some space for the resize border
493  if (IsResizable())
494  {
495  // Create the resizer and add it to the main sizer
497  ms->Add(mResizer, 0, wxEXPAND | wxALIGN_TOP | wxLEFT, 1);
498  mResizer->SetToolTip(_("Click and drag to resize toolbar"));
499  }
500 
501  // Set dock after possibly creating resizer.
502  // (Re)Establish dock state
503  SetDocked(GetDock(), false);
504 
505  // Set the sizer
506  SetSizerAndFit(ms.release());
507  }
508 
509  // Recalculate the height to be a multiple of toolbarSingle
510  const int tbs = toolbarSingle + toolbarGap;
511  wxSize sz = GetSize();
512  sz.y = ( ( ( sz.y + tbs -1) / tbs ) * tbs ) - 1;
513 
514  // Set the true AND minimum sizes and do final layout
515  if(IsResizable())
516  {
517  // JKC we're going to allow all resizable toolbars to be resized
518  // to 1 unit high, typically 27 pixels.
519  wxSize sz2 = sz;
520  sz2.SetWidth(GetMinToolbarWidth());
521  sz2.y = tbs -1;
522  SetMinSize(sz2);
523  // Initial size at least as big as minimum.
524  if( sz3.y < sz2.y )
525  sz3.y = sz2.y;
526  if( sz3.x < sz2.x )
527  sz3.x = GetInitialWidth();
528  //sz.SetWidth();
529  SetSize(sz3);
530  }
531  else
532  {
533  SetInitialSize(sz);
534  }
535  Layout();
536 }
virtual int GetMinToolbarWidth()
Definition: ToolBar.h:130
ToolDock * GetDock()
Definition: ToolBar.cpp:565
virtual int GetInitialWidth()
Resizable toolbars should implement these.
Definition: ToolBar.h:129
#define toolbarGap
Definition: ToolBar.h:59
wxBoxSizer * mHSizer
Definition: ToolBar.h:230
#define toolbarSingle
Definition: ToolBar.h:54
friend class ToolBarResizer
Definition: ToolBar.h:241
#define safenew
Definition: Audacity.h:223
int mType
Definition: ToolBar.h:221
virtual void Populate()=0
Grabber * mGrabber
Definition: ToolBar.h:227
ToolBarResizer * mResizer
Definition: ToolBar.h:228
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
The widget to the left of a ToolBar that allows it to be dragged around to NEW positions.
Definition: Grabber.h:97
bool IsResizable() const
Definition: ToolBar.cpp:387
void SetDocked(ToolDock *dock, bool pushed)
Definition: ToolBar.cpp:573
virtual void ToolBar::RegenerateTooltips ( )
pure virtual
virtual void ToolBar::Repaint ( wxDC *  dc)
protectedpure virtual

Implemented in ControlToolBar.

Referenced by OnPaint().

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

Definition at line 843 of file ToolBar.cpp.

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

844 {
845  if( down )
846  {
847  button->PushDown();
848  }
849  else
850  {
851  button->PopUp();
852  }
853 }
void PopUp()
Definition: AButton.cpp:525
void PushDown()
Definition: AButton.cpp:517
void ToolBar::SetButtonToolTip ( AButton button,
const LocalizedCommandNameVector commands 
)
static

Definition at line 828 of file ToolBar.cpp.

References GetActiveProject().

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

829 {
830  wxString result;
831  const auto project = GetActiveProject();
832  const auto commandManager =
833  project ? project->GetCommandManager() : nullptr;
834  if (commandManager)
835  result =
836  commandManager->DescribeCommandsAndShortcuts(commands);
837  button.SetToolTip(result);
838 }
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:300
void ToolBar::SetDock ( ToolDock dock)
void ToolBar::SetDocked ( ToolDock dock,
bool  pushed 
)

Definition at line 573 of file ToolBar.cpp.

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

Referenced by ToolDock::Dock(), ToolManager::HandleEscapeKey(), ToolManager::OnMouse(), ReCreateButtons(), ToolManager::Reset(), and ToolManager::UndockBar().

574 {
575  // Remember it
576 // mDock = dock;
577 
578  // Change the tooltip of the grabber
579 #if wxUSE_TOOLTIPS
580  mGrabber->SetToolTip( GetTitle() );
581 #endif
582 
583  // Set the grabber button state
584  mGrabber->PushButton( pushed );
585 
586  if (mResizer)
587  {
588  mResizer->Show(dock != NULL);
589  Layout();
590  Fit();
591  }
592 }
Grabber * mGrabber
Definition: ToolBar.h:227
ToolBarResizer * mResizer
Definition: ToolBar.h:228
wxString GetTitle()
Definition: ToolBar.cpp:346
void PushButton(bool state)
Definition: Grabber.cpp:184
void ToolBar::SetLabel ( const wxString &  label)
void ToolBar::SetPositioned ( )
inline

Definition at line 125 of file ToolBar.h.

References mPositioned.

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

125 { mPositioned = true;};
bool mPositioned
Definition: ToolBar.h:234
void ToolBar::SetVisible ( bool  bVisible)

Definition at line 408 of file ToolBar.cpp.

References mVisible.

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

409 {
410  mVisible = bVisible;
411 }
bool mVisible
Definition: ToolBar.h:232
void ToolBar::Updated ( )
protected

Definition at line 597 of file ToolBar.cpp.

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

Referenced by SpectralSelectionBar::OnChoice(), SpectralSelectionBar::OnUpdate(), SelectionBar::OnUpdate(), ToolBarResizer::ResizeBar(), SelectionBar::SelectionModeUpdated(), MixerToolBar::UpdatePrefs(), and ControlToolBar::UpdatePrefs().

598 {
599  if( IsDocked() )
600  GetDock()->Updated();
601  //wxCommandEvent e( EVT_TOOLBAR_UPDATED, GetId() );
602  //GetParent()->GetEventHandler()->AddPendingEvent( e );
603 }
bool IsDocked() const
Definition: ToolBar.cpp:395
ToolDock * GetDock()
Definition: ToolBar.cpp:565
void Updated()
Definition: ToolDock.cpp:854
void ToolBar::UpdatePrefs ( )
virtual

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

Definition at line 540 of file ToolBar.cpp.

References _(), GetTitle(), mGrabber, and mResizer.

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

541 {
542 #if wxUSE_TOOLTIPS
543  // Change the tooltip of the grabber
544  if ( mGrabber )
545  {
546  mGrabber->SetToolTip( GetTitle() );
547  }
548 
549  // Change the tooltip of the resizer
550  if ( mResizer )
551  {
552  mResizer->SetToolTip( _("Click and drag to resize toolbar") );
553  wxSizeEvent e;
554  GetParent()->GetEventHandler()->AddPendingEvent( e );
555  GetParent()->Refresh();
556  }
557 #endif
558 
559  return;
560 }
Grabber * mGrabber
Definition: ToolBar.h:227
ToolBarResizer * mResizer
Definition: ToolBar.h:228
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
wxString GetTitle()
Definition: ToolBar.cpp:346

Friends And Related Function Documentation

friend class ToolBarResizer
friend

Definition at line 241 of file ToolBar.h.

Referenced by ReCreateButtons().

Member Data Documentation

Grabber* ToolBar::mGrabber
private

Definition at line 227 of file ToolBar.h.

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

wxBoxSizer* ToolBar::mHSizer
private

Definition at line 230 of file ToolBar.h.

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

wxString ToolBar::mLabel
protected

Definition at line 219 of file ToolBar.h.

Referenced by GetLabel(), and SetLabel().

wxWindow* ToolBar::mParent
private

Definition at line 225 of file ToolBar.h.

Referenced by Create().

bool ToolBar::mPositioned
private

Definition at line 234 of file ToolBar.h.

Referenced by IsPositioned(), and SetPositioned().

bool ToolBar::mResizable
private

Definition at line 233 of file ToolBar.h.

Referenced by IsResizable().

ToolBarResizer* ToolBar::mResizer
private

Definition at line 228 of file ToolBar.h.

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

wxString ToolBar::mSection
protected

Definition at line 220 of file ToolBar.h.

Referenced by GetSection().

int ToolBar::mType
protected

Definition at line 221 of file ToolBar.h.

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

bool ToolBar::mVisible
private

Definition at line 232 of file ToolBar.h.

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


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