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 >
 

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) override
 
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 TranslatedInternalString commands[], size_t nCommands)
 

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.

Constructor & Destructor Documentation

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

Definition at line 307 of file ToolBar.cpp.

References label.

311 : wxPanelWrapper()
312 {
313  // Save parameters
314  mType = type;
315  mLabel = label;
316  mSection = section;
317  mResizable = resizable;
318 
319  // Initialize everything
320  mParent = NULL;
321  mHSizer = NULL;
322  mVisible = false;
323  mPositioned = false;
324 
325  mGrabber = NULL;
326  mResizer = NULL;
327 
328  SetId(mType);
329 }
bool mResizable
Definition: ToolBar.h:227
bool mPositioned
Definition: ToolBar.h:228
wxString label
Definition: Tags.cpp:727
wxBoxSizer * mHSizer
Definition: ToolBar.h:224
int mType
Definition: ToolBar.h:215
wxString mLabel
Definition: ToolBar.h:213
wxString mSection
Definition: ToolBar.h:214
Grabber * mGrabber
Definition: ToolBar.h:221
bool mVisible
Definition: ToolBar.h:226
ToolBarResizer * mResizer
Definition: ToolBar.h:222
wxWindow * mParent
Definition: ToolBar.h:219
ToolBar::~ToolBar ( )
virtual

Definition at line 334 of file ToolBar.cpp.

335 {
336 }

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 627 of file ToolBar.cpp.

References mHSizer.

632 {
633  mHSizer->Add( sizer,
634  proportion,
635  flag,
636  border,
637  userData );
638 }
wxBoxSizer * mHSizer
Definition: ToolBar.h:224
void ToolBar::Add ( int  width,
int  height,
int  proportion = 0,
int  flag = 0,
int  border = 0,
wxObject *  userData = NULL 
)
protected

Definition at line 643 of file ToolBar.cpp.

References mHSizer.

649 {
650  mHSizer->Add( width,
651  height,
652  proportion,
653  flag,
654  border,
655  userData );
656 }
wxBoxSizer * mHSizer
Definition: ToolBar.h:224
void ToolBar::AddSpacer ( int  size = 14)
protected

Definition at line 661 of file ToolBar.cpp.

References mHSizer.

Referenced by EditToolBar::AddSeparator().

662 {
663  mHSizer->AddSpacer( size );
664 }
wxBoxSizer * mHSizer
Definition: ToolBar.h:224
void ToolBar::AddStretchSpacer ( int  prop = 1)
protected

Definition at line 669 of file ToolBar.cpp.

References mHSizer.

670 {
671  mHSizer->AddStretchSpacer( prop );
672 }
wxBoxSizer * mHSizer
Definition: ToolBar.h:224
void ToolBar::Create ( wxWindow *  parent)
virtual

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

Definition at line 438 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(), SelectionBar::Create(), ControlToolBar::Create(), TranscriptionToolBar::Create(), and EditToolBar::Create().

439 {
440  // Save parameters
441  mParent = parent;
442 
443  // Create the window and label it
445  mType,
446  wxDefaultPosition,
447  wxDefaultSize,
448  wxNO_BORDER | wxTAB_TRAVERSAL,
449  GetTitle() );
450  wxPanelWrapper::SetLabel( GetLabel() );
451 
452  // Go do the rest of the creation
453  ReCreateButtons();
454 
455  // ToolManager depends on this appearing to be visible for proper dock construction
456  mVisible = true;
457 }
virtual void ReCreateButtons()
Definition: ToolBar.cpp:459
int mType
Definition: ToolBar.h:215
wxString GetLabel()
Definition: ToolBar.cpp:350
bool mVisible
Definition: ToolBar.h:226
wxWindow * mParent
Definition: ToolBar.h:219
wxString GetTitle()
Definition: ToolBar.cpp:341
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 677 of file ToolBar.cpp.

References mHSizer.

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

678 {
679  mHSizer->Detach( window );
680 }
wxBoxSizer * mHSizer
Definition: ToolBar.h:224
void ToolBar::Detach ( wxSizer *  sizer)
protected

Definition at line 685 of file ToolBar.cpp.

References mHSizer.

686 {
687  mHSizer->Detach( sizer );
688 }
wxBoxSizer * mHSizer
Definition: ToolBar.h:224
virtual void ToolBar::EnableDisableButtons ( )
pure virtual
bool ToolBar::Expose ( bool  show = true)
virtual

Reimplemented in MeterToolBar.

Definition at line 411 of file ToolBar.cpp.

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

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

412 {
413  bool was = mVisible;
414 
415  SetVisible( show );
416 
417  if( IsDocked() )
418  {
419  Show( show );
420  }
421  else
422  {
423  wxWindow * pParent = GetParent();
424  if( !IsPositioned() && show ){
425  SetPositioned();
426  pParent->CentreOnParent();
427  pParent->Move( pParent->GetPosition() + wxSize( mType*10, mType*10 ));
428  }
429  pParent->Show( show );
430  }
431 
432  return was;
433 }
bool IsDocked() const
Definition: ToolBar.cpp:390
void SetVisible(bool bVisible)
Definition: ToolBar.cpp:403
bool IsPositioned()
Definition: ToolBar.h:121
int mType
Definition: ToolBar.h:215
bool mVisible
Definition: ToolBar.h:226
void SetPositioned()
Definition: ToolBar.h:123
ToolDock * ToolBar::GetDock ( )

Definition at line 560 of file ToolBar.cpp.

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

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

Reimplemented in MeterToolBar.

Definition at line 129 of file ToolBar.h.

Referenced by ToolDock::Dock().

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

Resizable toolbars should implement these.

Reimplemented in MeterToolBar, and DeviceToolBar.

Definition at line 127 of file ToolBar.h.

Referenced by GetMinToolbarWidth(), and ReCreateButtons().

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

Definition at line 350 of file ToolBar.cpp.

References mLabel.

Referenced by Create(), and GetTitle().

351 {
352  return mLabel;
353 }
wxString mLabel
Definition: ToolBar.h:213
virtual int ToolBar::GetMinToolbarWidth ( )
inlinevirtual

Reimplemented in MeterToolBar, and DeviceToolBar.

Definition at line 128 of file ToolBar.h.

References GetInitialWidth().

Referenced by ReCreateButtons().

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

Returns the width in pixels of the resizer element.

Definition at line 889 of file ToolBar.cpp.

References RWIDTH.

890 {
891  return RWIDTH;
892 }
#define RWIDTH
ToolBarResizer.
Definition: ToolBar.cpp:64
wxString ToolBar::GetSection ( )

Definition at line 358 of file ToolBar.cpp.

References mSection.

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

359 {
360  return mSection;
361 }
wxString mSection
Definition: ToolBar.h:214
wxBoxSizer * ToolBar::GetSizer ( )
protected

Definition at line 603 of file ToolBar.cpp.

References mHSizer.

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

604 {
605  return mHSizer;
606 }
wxBoxSizer * mHSizer
Definition: ToolBar.h:224
wxString ToolBar::GetTitle ( )

Definition at line 341 of file ToolBar.cpp.

References _(), and GetLabel().

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

342 {
343  /* i18n-hint: %s will be replaced by the name of the kind of toolbar.*/
344  return wxString::Format( _("Audacity %s Toolbar"), GetLabel() );
345 }
wxString GetLabel()
Definition: ToolBar.cpp:350
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
int ToolBar::GetType ( )

Definition at line 366 of file ToolBar.cpp.

References mType.

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

367 {
368  return mType;
369 }
int mType
Definition: ToolBar.h:215
void ToolBar::Init ( wxWindow *  parent,
int  type,
const wxString &  title,
const wxString &  label 
)
private
bool ToolBar::IsDocked ( ) const

Definition at line 390 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().

391 {
392  return const_cast<ToolBar*>(this)->GetDock() != nullptr;
393 }
ToolDock * GetDock()
Definition: ToolBar.cpp:560
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 121 of file ToolBar.h.

References mPositioned.

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

121 { return mPositioned; };
bool mPositioned
Definition: ToolBar.h:228
bool ToolBar::IsResizable ( ) const

Definition at line 382 of file ToolBar.cpp.

References mResizable.

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

383 {
384  return mResizable;
385 }
bool mResizable
Definition: ToolBar.h:227
bool ToolBar::IsVisible ( ) const

Definition at line 398 of file ToolBar.cpp.

References mVisible.

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

399 {
400  return mVisible;
401 }
bool mVisible
Definition: ToolBar.h:226
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 798 of file ToolBar.cpp.

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

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

807 {
808  // wxMax to cater for case of image being bigger than the button.
809  int xoff = wxMax( 0, (size.GetWidth() - theTheme.Image(eStandardUp).GetWidth())/2);
810  int yoff = wxMax( 0, (size.GetHeight() - theTheme.Image(eStandardUp).GetHeight())/2);
811 
812  typedef std::unique_ptr<wxImage> wxImagePtr;
813  wxImagePtr up (OverlayImage(eUp, eStandardUp, xoff, yoff));
814  wxImagePtr hilite (OverlayImage(eHilite, eStandardUp, xoff, yoff));
815  wxImagePtr down (OverlayImage(eDown, eStandardDown, xoff + 1, yoff + 1));
816  wxImagePtr downHi (OverlayImage(eDownHi, eStandardDown, xoff + 1, yoff + 1));
817  wxImagePtr disable (OverlayImage(eUp, eDisabled, xoff, yoff));
818 
819  button.SetAlternateImages(idx, *up, *hilite, *down, *downHi, *disable);
820 }
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:1251
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 765 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().

777 {
778  // wxMax to cater for case of image being bigger than the button.
779  int xoff = wxMax( 0, (size.GetWidth() - theTheme.Image(eStandardUp).GetWidth())/2);
780  int yoff = wxMax( 0, (size.GetHeight() - theTheme.Image(eStandardUp).GetHeight())/2);
781 
782  typedef std::unique_ptr<wxImage> wxImagePtr;
783  wxImagePtr up2 (OverlayImage(eUp, eStandardUp, xoff, yoff));
784  wxImagePtr hilite2 (OverlayImage(eHilite, eStandardUp, xoff, yoff));
785  wxImagePtr down2 (OverlayImage(eDown, eStandardDown, xoff + 1, yoff + 1));
786  wxImagePtr downHi2 (OverlayImage(eDownHi, eStandardDown, xoff + 1, yoff + 1));
787  wxImagePtr disable2 (OverlayImage(eUp, eDisabled, xoff, yoff));
788 
789  wxASSERT(parent); // to justify safenew
790  AButton * button =
791  safenew AButton(parent, id, placement, size, *up2, *hilite2, *down2, *downHi2,
792  *disable2, processdownevents);
793 
794  return button;
795 }
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:230
wxImage & Image(int iIndex)
Definition: Theme.cpp:1251
A wxButton with mouse-over behaviour.
Definition: AButton.h:28
void ToolBar::MakeButtonBackgroundsLarge ( )
protected

Definition at line 701 of file ToolBar.cpp.

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

Referenced by ControlToolBar::Populate().

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

Definition at line 727 of file ToolBar.cpp.

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

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

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

Definition at line 690 of file ToolBar.cpp.

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

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

691 {
692  theTheme.ReplaceImage( eBmpOut, &theTheme.Image( eBmpIn ));
693 }
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:1287
wxImage & Image(int iIndex)
Definition: Theme.cpp:1251
void ToolBar::MakeRecoloredImage ( teBmps  eBmpOut,
teBmps  eBmpIn 
)
protected

Definition at line 695 of file ToolBar.cpp.

References MakeMacRecoloredImage().

Referenced by MakeButtonBackgroundsLarge(), and MakeButtonBackgroundsSmall().

696 {
697  // Don't recolour the buttons...
698  MakeMacRecoloredImage( eBmpOut, eBmpIn );
699 }
void MakeMacRecoloredImage(teBmps eBmpOut, teBmps eBmpIn)
Definition: ToolBar.cpp:690
void ToolBar::OnErase ( wxEraseEvent &  event)
protected

Definition at line 853 of file ToolBar.cpp.

854 {
855  // Ignore it to prevent flashing
856 }
void ToolBar::OnMouseEvents ( wxMouseEvent &  event)
protected

Definition at line 882 of file ToolBar.cpp.

883 {
884  // Do this hack so scrubber can detect mouse drags anywhere
885  event.ResumePropagation(wxEVENT_PROPAGATE_MAX);
886  event.Skip();
887 }
void ToolBar::OnPaint ( wxPaintEvent &  event)
protected

Definition at line 861 of file ToolBar.cpp.

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

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

Reimplemented in ControlToolBar, and MeterToolBar.

Definition at line 459 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().

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

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

839 {
840  if( down )
841  {
842  button->PushDown();
843  }
844  else
845  {
846  button->PopUp();
847  }
848 }
void PopUp()
Definition: AButton.cpp:525
void PushDown()
Definition: AButton.cpp:517
void ToolBar::SetButtonToolTip ( AButton button,
const TranslatedInternalString  commands[],
size_t  nCommands 
)
static

Definition at line 823 of file ToolBar.cpp.

References GetActiveProject().

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

824 {
825  wxString result;
826  const auto project = GetActiveProject();
827  const auto commandManager =
828  project ? project->GetCommandManager() : nullptr;
829  if (commandManager)
830  result =
831  commandManager->DescribeCommandsAndShortcuts(commands, nCommands);
832  button.SetToolTip(result);
833 }
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
void ToolBar::SetDocked ( ToolDock dock,
bool  pushed 
)

Definition at line 568 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().

569 {
570  // Remember it
571 // mDock = dock;
572 
573  // Change the tooltip of the grabber
574 #if wxUSE_TOOLTIPS
575  mGrabber->SetToolTip( GetTitle() );
576 #endif
577 
578  // Set the grabber button state
579  mGrabber->PushButton( pushed );
580 
581  if (mResizer)
582  {
583  mResizer->Show(dock != NULL);
584  Layout();
585  Fit();
586  }
587 }
Grabber * mGrabber
Definition: ToolBar.h:221
ToolBarResizer * mResizer
Definition: ToolBar.h:222
wxString GetTitle()
Definition: ToolBar.cpp:341
void PushButton(bool state)
Definition: Grabber.cpp:185
void ToolBar::SetLabel ( const wxString &  label)
override
void ToolBar::SetPositioned ( )
inline

Definition at line 123 of file ToolBar.h.

References mPositioned.

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

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

Definition at line 403 of file ToolBar.cpp.

References mVisible.

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

404 {
405  mVisible = bVisible;
406 }
bool mVisible
Definition: ToolBar.h:226
void ToolBar::Updated ( )
protected

Definition at line 592 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().

593 {
594  if( IsDocked() )
595  GetDock()->Updated();
596  //wxCommandEvent e( EVT_TOOLBAR_UPDATED, GetId() );
597  //GetParent()->GetEventHandler()->AddPendingEvent( e );
598 }
bool IsDocked() const
Definition: ToolBar.cpp:390
ToolDock * GetDock()
Definition: ToolBar.cpp:560
void Updated()
Definition: ToolDock.cpp:854
void ToolBar::UpdatePrefs ( )
virtual

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

Definition at line 535 of file ToolBar.cpp.

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

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

536 {
537 #if wxUSE_TOOLTIPS
538  // Change the tooltip of the grabber
539  if ( mGrabber )
540  {
541  mGrabber->SetToolTip( GetTitle() );
542  }
543 
544  // Change the tooltip of the resizer
545  if ( mResizer )
546  {
547  mResizer->SetToolTip( _("Click and drag to resize toolbar") );
548  wxSizeEvent e;
549  GetParent()->GetEventHandler()->AddPendingEvent( e );
550  GetParent()->Refresh();
551  }
552 #endif
553 
554  return;
555 }
Grabber * mGrabber
Definition: ToolBar.h:221
ToolBarResizer * mResizer
Definition: ToolBar.h:222
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxString GetTitle()
Definition: ToolBar.cpp:341

Friends And Related Function Documentation

friend class ToolBarResizer
friend

Definition at line 235 of file ToolBar.h.

Referenced by ReCreateButtons().

Member Data Documentation

Grabber* ToolBar::mGrabber
private

Definition at line 221 of file ToolBar.h.

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

wxBoxSizer* ToolBar::mHSizer
private

Definition at line 224 of file ToolBar.h.

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

wxString ToolBar::mLabel
protected

Definition at line 213 of file ToolBar.h.

Referenced by GetLabel(), and SetLabel().

wxWindow* ToolBar::mParent
private

Definition at line 219 of file ToolBar.h.

Referenced by Create().

bool ToolBar::mPositioned
private

Definition at line 228 of file ToolBar.h.

Referenced by IsPositioned(), and SetPositioned().

bool ToolBar::mResizable
private

Definition at line 227 of file ToolBar.h.

Referenced by IsResizable().

ToolBarResizer* ToolBar::mResizer
private

Definition at line 222 of file ToolBar.h.

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

wxString ToolBar::mSection
protected

Definition at line 214 of file ToolBar.h.

Referenced by GetSection().

int ToolBar::mType
protected

Definition at line 215 of file ToolBar.h.

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

bool ToolBar::mVisible
private

Definition at line 226 of file ToolBar.h.

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


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