Audacity  2.2.2
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
EditToolBar Class Referencefinal

A ToolBar that has the edit buttons on it. More...

#include <EditToolBar.h>

Inheritance diagram for EditToolBar:
ToolBar wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Public Member Functions

 EditToolBar ()
 
virtual ~EditToolBar ()
 
void Create (wxWindow *parent) override
 
void OnButton (wxCommandEvent &event)
 
void Populate () override
 
void Repaint (wxDC *WXUNUSED(dc)) override
 
void EnableDisableButtons () override
 
void UpdatePrefs () override
 
- Public Member Functions inherited from ToolBar
 ToolBar (int type, const wxString &label, const wxString &section, bool resizable=false)
 
virtual ~ToolBar ()
 
bool AcceptsFocus () const override
 
virtual void ReCreateButtons ()
 
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)
 

Private Member Functions

void AddSeparator ()
 
void MakeButtons ()
 
void RegenerateTooltips () override
 
void ForAllButtons (int Action)
 

Static Private Member Functions

static AButtonAddButton (EditToolBar *pBar, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, const wxChar *label, bool toggle=false)
 

Private Attributes

AButtonmButtons [ETBNumButtons]
 
wxImage * upImage
 
wxImage * downImage
 
wxImage * hiliteImage
 

Additional Inherited Members

- Public Types inherited from ToolBar
using Holder = Destroy_ptr< ToolBar >
 
- Static Public Member Functions inherited from ToolBar
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 inherited from ToolBar
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 Repaint (wxDC *dc)=0
 
void OnErase (wxEraseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
void OnMouseEvents (wxMouseEvent &event)
 
- Protected Attributes inherited from ToolBar
wxString mLabel
 
wxString mSection
 
int mType
 

Detailed Description

A ToolBar that has the edit buttons on it.

This class, which is a child of Toolbar, creates the window containing interfaces to commonly-used edit functions that are otherwise only available through menus. The window can be embedded within a normal project window, or within a ToolbarFrame that is managed by a global ToolBarStub called gControlToolBarStub.

All of the controls in this window were custom-written for Audacity - they are not native controls on any platform - however, it is intended that the images could be easily replaced to allow "skinning" or just customization to match the look and feel of each platform.

Definition at line 73 of file EditToolBar.h.

Constructor & Destructor Documentation

EditToolBar::EditToolBar ( )
EditToolBar::~EditToolBar ( )
virtual

Definition at line 84 of file EditToolBar.cpp.

85 {
86 }

Member Function Documentation

AButton * EditToolBar::AddButton ( EditToolBar pBar,
teBmps  eEnabledUp,
teBmps  eEnabledDown,
teBmps  eDisabled,
int  id,
const wxChar *  label,
bool  toggle = false 
)
staticprivate

This is a convenience function that allows for button creation in MakeButtons() with fewer arguments Very similar to code in ControlToolBar...

Definition at line 101 of file EditToolBar.cpp.

References ToolBar::Add(), first_ETB_ID, ThemeBase::ImageSize(), ToolBar::MakeButton(), mButtons, and theTheme.

Referenced by Populate().

107 {
108  AButton *&r = pBar->mButtons[id];
109 
110  r = ToolBar::MakeButton(pBar,
111  bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
112  eEnabledUp, eEnabledDown, eDisabled,
113  wxWindowID(id+first_ETB_ID),
114  wxDefaultPosition,
115  toggle,
116  theTheme.ImageSize( bmpRecoloredUpSmall ));
117 
118  r->SetLabel(label);
119 // JKC: Unlike ControlToolBar, does not have a focus rect. Shouldn't it?
120 // r->SetFocusRect( r->GetRect().Deflate( 4, 4 ) );
121 
122  pBar->Add( r, 0, wxALIGN_CENTER );
123 
124  return r;
125 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
wxString label
Definition: Tags.cpp:727
wxSize ImageSize(int iIndex)
Definition: Theme.cpp:1257
static AButton * 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)
Definition: ToolBar.cpp:765
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:611
AButton * mButtons[ETBNumButtons]
Definition: EditToolBar.h:103
const int first_ETB_ID
Definition: EditToolBar.h:65
A wxButton with mouse-over behaviour.
Definition: AButton.h:28
void EditToolBar::AddSeparator ( )
private

Definition at line 93 of file EditToolBar.cpp.

References ToolBar::AddSpacer().

Referenced by Populate().

94 {
95  AddSpacer();
96 }
void AddSpacer(int size=14)
Definition: ToolBar.cpp:661
void EditToolBar::Create ( wxWindow *  parent)
overridevirtual

Reimplemented from ToolBar.

Definition at line 88 of file EditToolBar.cpp.

References ToolBar::Create().

89 {
90  ToolBar::Create(parent);
91 }
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:438
void EditToolBar::EnableDisableButtons ( )
overridevirtual

Implements ToolBar.

Definition at line 218 of file EditToolBar.cpp.

References ETBActEnableDisable, and ForAllButtons().

219 {
221 }
void ForAllButtons(int Action)
void EditToolBar::ForAllButtons ( int  Action)
private

Definition at line 255 of file EditToolBar.cpp.

References EditToolbarButtonList, ETBActEnableDisable, ETBActTooltips, GetActiveProject(), AudacityProject::GetCommandManager(), CommandManager::GetEnabled(), gPrefs, mButtons, AButton::PopUp(), AButton::PushDown(), ToolBar::SetButtonToolTip(), and AButton::SetEnabled().

Referenced by EnableDisableButtons(), and RegenerateTooltips().

256 {
257  AudacityProject *p;
258  CommandManager* cm = nullptr;
259 
260  if( Action & ETBActEnableDisable ){
261  p = GetActiveProject();
262  if (!p) return;
263  cm = p->GetCommandManager();
264  if (!cm) return;
265 #ifdef OPTION_SYNC_LOCK_BUTTON
266  bool bSyncLockTracks;
267  gPrefs->Read(wxT("/GUI/SyncLockTracks"), &bSyncLockTracks, false);
268 
269  if (bSyncLockTracks)
270  mButtons[ETBSyncLockID]->PushDown();
271  else
272  mButtons[ETBSyncLockID]->PopUp();
273 #endif
274  }
275 
276 
277  for (const auto &entry : EditToolbarButtonList) {
278 #if wxUSE_TOOLTIPS
279  if( Action & ETBActTooltips ){
280  TranslatedInternalString command{
281  entry.commandName, wxGetTranslation(entry.untranslatedLabel) };
282  ToolBar::SetButtonToolTip( *mButtons[entry.tool], &command, 1u );
283  }
284 #endif
285  if (cm) {
286  mButtons[entry.tool]->SetEnabled(cm->GetEnabled(entry.commandName));
287  }
288  }
289 }
bool GetEnabled(const wxString &name)
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
void PopUp()
Definition: AButton.cpp:525
CommandManager * GetCommandManager()
Definition: Project.h:346
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
void SetEnabled(bool state)
Definition: AButton.h:98
CommandManager implements a system for organizing all user-callable commands.
AButton * mButtons[ETBNumButtons]
Definition: EditToolBar.h:103
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
void PushDown()
Definition: AButton.cpp:517
static void SetButtonToolTip(AButton &button, const TranslatedInternalString commands[], size_t nCommands)
Definition: ToolBar.cpp:823
static const struct Entry EditToolbarButtonList[]
void EditToolBar::MakeButtons ( )
private
void EditToolBar::OnButton ( wxCommandEvent &  event)

Definition at line 291 of file EditToolBar.cpp.

References EditToolbarButtonList, first_ETB_ID, GetActiveProject(), AudacityProject::GetCommandManager(), AudacityProject::GetUpdateFlags(), CommandManager::HandleTextualCommand(), AButton::InteractionOver(), mButtons, and NoFlagsSpecifed.

292 {
293  int id = event.GetId()-first_ETB_ID;
294  // Be sure the pop-up happens even if there are exceptions, except for buttons which toggle.
295  auto cleanup = finally( [&] { mButtons[id]->InteractionOver();});
296 
298  if (!p) return;
300  if (!cm) return;
301 
302  auto flags = p->GetUpdateFlags();
303  const CommandContext context( *GetActiveProject() );
304  cm->HandleTextualCommand(EditToolbarButtonList[id].commandName, context, flags, NoFlagsSpecifed);
305 }
void InteractionOver()
Definition: AButton.h:132
bool HandleTextualCommand(const wxString &Str, const CommandContext &context, CommandFlag flags, CommandMask mask)
CommandContext provides addiitonal information to an 'Apply()' command. It provides the project...
CommandManager * GetCommandManager()
Definition: Project.h:346
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
CommandManager implements a system for organizing all user-callable commands.
AButton * mButtons[ETBNumButtons]
Definition: EditToolBar.h:103
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
const int first_ETB_ID
Definition: EditToolBar.h:65
static const struct Entry EditToolbarButtonList[]
CommandFlag GetUpdateFlags(bool checkActive=false)
Definition: Menus.cpp:2181
void EditToolBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 127 of file EditToolBar.cpp.

References _(), AddButton(), AddSeparator(), ThemeBase::Colour(), ETBCopyID, ETBCutID, ETBPasteID, ETBRedoID, ETBSilenceID, ETBTrimID, ETBUndoID, ETBZoomFitID, ETBZoomInID, ETBZoomOutID, ETBZoomSelID, ETBZoomToggleID, ToolBar::MakeButtonBackgroundsSmall(), mButtons, AButton::PushDown(), RegenerateTooltips(), AButton::SetEnabled(), and theTheme.

128 {
129  SetBackgroundColour( theTheme.Colour( clrMedium ) );
131 
132  /* Buttons */
133  // Tooltips slightly more verbose than the menu entries are.
134  AddButton(this, bmpCut, bmpCut, bmpCutDisabled, ETBCutID,
135  _("Cut selection"));
136  AddButton(this, bmpCopy, bmpCopy, bmpCopyDisabled, ETBCopyID,
137  _("Copy selection"));
138  AddButton(this, bmpPaste, bmpPaste, bmpPasteDisabled, ETBPasteID,
139  _("Paste"));
140  AddButton(this, bmpTrim, bmpTrim, bmpTrimDisabled, ETBTrimID,
141  _("Trim audio outside selection"));
142  AddButton(this, bmpSilence, bmpSilence, bmpSilenceDisabled, ETBSilenceID,
143  _("Silence audio selection"));
144 
145  AddSeparator();
146 
147  AddButton(this, bmpUndo, bmpUndo, bmpUndoDisabled, ETBUndoID,
148  _("Undo"));
149  AddButton(this, bmpRedo, bmpRedo, bmpRedoDisabled, ETBRedoID,
150  _("Redo"));
151 
152  AddSeparator();
153 
154 #ifdef OPTION_SYNC_LOCK_BUTTON
155  AddButton(this, bmpSyncLockTracksUp, bmpSyncLockTracksDown, bmpSyncLockTracksUp, ETBSyncLockID,
156  _("Sync-Lock Tracks"), true);
157 
158  AddSeparator();
159 #endif
160 
161  // Tooltips match menu entries.
162  // We previously had longer tooltips which were not more clear.
163  AddButton(this, bmpZoomIn, bmpZoomIn, bmpZoomInDisabled, ETBZoomInID,
164  _("Zoom In"));
165  AddButton(this, bmpZoomOut, bmpZoomOut, bmpZoomOutDisabled, ETBZoomOutID,
166  _("Zoom Out"));
167  AddButton(this, bmpZoomSel, bmpZoomSel, bmpZoomSelDisabled, ETBZoomSelID,
168  _("Zoom to Selection"));
169  AddButton(this, bmpZoomFit, bmpZoomFit, bmpZoomFitDisabled, ETBZoomFitID,
170  _("Fit to Width"));
171 
172 #ifdef EXPERIMENTAL_ZOOM_TOGGLE_BUTTON
173  AddButton(this, bmpZoomToggle, bmpZoomToggle, bmpZoomToggleDisabled, ETBZoomToggleID,
174  _("Zoom Toggle"));
175 #endif
176 
177 
178 
181 #ifdef EXPERIMENTAL_ZOOM_TOGGLE_BUTTON
183 #endif
184 
187  mButtons[ETBPasteID]->SetEnabled(false);
188 
189 #ifdef OPTION_SYNC_LOCK_BUTTON
190  mButtons[ETBSyncLockID]->PushDown();
191 #endif
192 
193 #if defined(EXPERIMENTAL_EFFECTS_RACK)
194  AddSeparator();
195  AddButton(this, bmpEditEffects, bmpEditEffects, bmpEditEffects, ETBEffectsID,
196  _("Show Effects Rack"), true);
197 #endif
198 
200 }
void MakeButtonBackgroundsSmall()
Definition: ToolBar.cpp:727
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
static AButton * AddButton(EditToolBar *pBar, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, const wxChar *label, bool toggle=false)
void AddSeparator()
Definition: EditToolBar.cpp:93
void SetEnabled(bool state)
Definition: AButton.h:98
_("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
AButton * mButtons[ETBNumButtons]
Definition: EditToolBar.h:103
void RegenerateTooltips() override
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
void PushDown()
Definition: AButton.cpp:517
void EditToolBar::RegenerateTooltips ( )
overrideprivatevirtual

Implements ToolBar.

Definition at line 213 of file EditToolBar.cpp.

References ETBActTooltips, and ForAllButtons().

Referenced by Populate(), and UpdatePrefs().

214 {
216 }
void ForAllButtons(int Action)
void EditToolBar::Repaint ( wxDC *  WXUNUSEDdc)
inlineoverride

Definition at line 85 of file EditToolBar.h.

85 {};
void EditToolBar::UpdatePrefs ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 202 of file EditToolBar.cpp.

References _(), RegenerateTooltips(), ToolBar::SetLabel(), and ToolBar::UpdatePrefs().

203 {
205 
206  // Set label to pull in language change
207  SetLabel(_("Edit"));
208 
209  // Give base class a chance
211 }
virtual void UpdatePrefs()
Definition: ToolBar.cpp:535
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:374
_("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
void RegenerateTooltips() override

Member Data Documentation

wxImage* EditToolBar::downImage
private

Definition at line 106 of file EditToolBar.h.

wxImage* EditToolBar::hiliteImage
private

Definition at line 107 of file EditToolBar.h.

AButton* EditToolBar::mButtons[ETBNumButtons]
private

Definition at line 103 of file EditToolBar.h.

Referenced by AddButton(), ForAllButtons(), OnButton(), and Populate().

wxImage* EditToolBar::upImage
private

Definition at line 105 of file EditToolBar.h.


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