Audacity 3.2.0
CutCopyPasteToolBar.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 CutCopyPasteToolBar.cpp
6
7 ksoze95
8
9 See CutCopyPasteToolBar.h for details
10
11*******************************************************************//*******************************************************************/
29
30
31
32#include "CutCopyPasteToolBar.h"
33
34// For compilers that support precompilation, includes "wx/wx.h".
35#include <wx/wxprec.h>
36
37#include <wx/setup.h> // for wxUSE_* macros
38
39#ifndef WX_PRECOMP
40#include <wx/app.h>
41#include <wx/event.h>
42#include <wx/image.h>
43#include <wx/intl.h>
44#include <wx/sizer.h>
45#include <wx/tooltip.h>
46#endif
47
48#include "AllThemeResources.h"
49#include "ImageManipulation.h"
50#include "../Menus.h"
51#include "Prefs.h"
52#include "Project.h"
53#include "UndoManager.h"
54#include "../widgets/AButton.h"
55
56#include "../commands/CommandContext.h"
57#include "../commands/CommandManager.h"
58#include "../commands/CommandDispatch.h"
59
60#include "ToolManager.h"
61
62enum {
68};
69
70constexpr int first_TB_ID = 21300;
71
73 { TBCutID, wxT("Cut"), XO("Cut") },
74 { TBCopyID, wxT("Copy"), XO("Copy") },
75 { TBPasteID, wxT("Paste"), XO("Paste") },
76 { TBDeleteID, wxT("Delete"), XO("Delete")}
77};
78
80
84
85BEGIN_EVENT_TABLE( CutCopyPasteToolBar, ToolBar )
89 CutCopyPasteToolBar::OnButton )
91
93{
94 return wxT("CutCopyPaste");
95}
96
97//Standard constructor
99: ToolBar(project, XO("Cut/Copy/Paste"), ID())
100, mButtons{ this, project, CutCopyPasteToolbarButtonList, TBNumButtons, first_TB_ID }
101{
102}
103
105{
106}
107
109{
110 return false;
111}
112
114{
115 return true;
116}
117
118void CutCopyPasteToolBar::Create(wxWindow * parent)
119{
120 ToolBar::Create(parent);
121 UpdatePrefs();
122}
123
125 teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
126 int id, const TranslatableString &label, bool toggle)
127{
128 auto r = mButtons.CreateButton(eEnabledUp, eEnabledDown, eDisabled, id, label, toggle);
129 mToolSizer->Add(r);
130}
131
133{
134 SetBackgroundColour( theTheme.Colour( clrMedium ) );
136
137 Add(mToolSizer = safenew wxGridSizer(2, 2, 1, 1));
138
139 /* Buttons */
140 // Tooltips match menu entries.
141 // We previously had longer tooltips which were not more clear.
142 AddButton(bmpCut, bmpCut, bmpCutDisabled, TBCutID,
143 XO("Cut"));
144 AddButton(bmpCopy, bmpCopy, bmpCopyDisabled, TBCopyID,
145 XO("Copy"));
146 AddButton(bmpPaste, bmpPaste, bmpPasteDisabled, TBPasteID,
147 XO("Paste"));
148 AddButton(bmpDelete, bmpDelete, bmpDeleteDisabled, TBDeleteID,
149 XO("Delete"));
150
152
154}
155
157{
159
160 // Set label to pull in language change
161 SetLabel(XO("Cut/Copy/Paste"));
162
163 // Give base class a chance
165}
166
168{
170}
171
173{
175}
176
177void CutCopyPasteToolBar::OnButton(wxCommandEvent & event)
178{
179 mButtons.OnButton(event);
180}
181
183 []( AudacityProject &project ){
184 return ToolBar::Holder{ safenew CutCopyPasteToolBar{ project } }; }
185};
186
187namespace {
189 /* i18n-hint: Clicking this menu item shows the toolbar for editing */
191 wxT("ShowCutCopyPasteTB"),
192 XXO("&Cut/Copy/Paste Toolbar"),
193 { Registry::OrderingHint::After, "ShowEditTB" }
194};
195}
196
wxEVT_COMMAND_BUTTON_CLICKED
wxT("CloseDown"))
END_EVENT_TABLE()
EVT_COMMAND_RANGE(TBCutID+first_TB_ID, TBCutID+first_TB_ID+TBNumButtons - 1, wxEVT_COMMAND_BUTTON_CLICKED, CutCopyPasteToolBar::OnButton) Identifier CutCopyPasteToolBar
Methods for CutCopyPasteToolBar.
@ TBDeleteID
@ TBNumButtons
constexpr int first_TB_ID
static RegisteredToolbarFactory factory
IMPLEMENT_CLASS(CutCopyPasteToolBar, ToolBar)
static const ToolBarButtons::ButtonList CutCopyPasteToolbarButtonList
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
int teBmps
#define safenew
Definition: MemoryX.h:10
TranslatableString label
Definition: TagsEditor.cpp:164
THEME_API Theme theTheme
Definition: Theme.cpp:82
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
A ToolBar that has the cut, copy and paste buttons on it.
bool ShownByDefault() const override
Whether the toolbar should be shown by default. Default implementation returns true.
void EnableDisableButtons() override
bool HideAfterReset() const override
Default implementation returns false.
static Identifier ID()
void OnButton(wxCommandEvent &event)
void AddButton(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, const TranslatableString &label, bool toggle=false)
CutCopyPasteToolBar(AudacityProject &project)
void Create(wxWindow *parent) override
void RegenerateTooltips() override
An explicitly nonlocalized string, not meant for the user to see.
Definition: Identifier.h:22
wxColour & Colour(int iIndex)
void EnableDisableButtons()
void OnButton(wxCommandEvent &event)
void SetEnabled(int id, bool state)
std::vector< Entry > ButtonList
AButton * CreateButton(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, const TranslatableString &label, bool toggle=false)
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed.
Definition: ToolBar.h:74
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:709
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:408
static void MakeButtonBackgroundsSmall()
Definition: ToolBar.cpp:837
void UpdatePrefs() override
Definition: ToolBar.cpp:622
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:492
wxWindowPtr< ToolBar > Holder
Definition: ToolBar.h:78
Holds a msgid for the translation catalog; may also bind format arguments.