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 "Prefs.h"
51#include "Project.h"
52#include "UndoManager.h"
53#include "../widgets/AButton.h"
54
55#include "CommandContext.h"
56#include "CommandManager.h"
57#include "../commands/CommandDispatch.h"
58
59#include "ToolManager.h"
60
61enum {
67};
68
69constexpr int first_TB_ID = 21300;
70
72 { TBCutID, wxT("Cut"), XO("Cut") },
73 { TBCopyID, wxT("Copy"), XO("Copy") },
74 { TBPasteID, wxT("Paste"), XO("Paste") },
75 { TBDeleteID, wxT("Delete"), XO("Delete")}
76};
77
79
83
84BEGIN_EVENT_TABLE( CutCopyPasteToolBar, ToolBar )
88 CutCopyPasteToolBar::OnButton )
90
92{
93 return wxT("CutCopyPaste");
94}
95
96//Standard constructor
98: ToolBar(project, XO("Cut/Copy/Paste"), ID())
100{
101}
102
104{
105}
106
108{
109 return false;
110}
111
113{
114 return true;
115}
116
117void CutCopyPasteToolBar::Create(wxWindow * parent)
118{
119 ToolBar::Create(parent);
120 UpdatePrefs();
121}
122
124 teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
125 int id, const TranslatableString &label, bool toggle)
126{
127 auto r = mButtons.CreateButton(eEnabledUp, eEnabledDown, eDisabled, id, label, toggle);
128 mToolSizer->Add(r);
129}
130
132{
133 SetBackgroundColour( theTheme.Colour( clrMedium ) );
135
136 Add(mToolSizer = safenew wxGridSizer(2, 2, toolbarSpacing, toolbarSpacing),
137 0, wxALIGN_CENTRE | wxALL, toolbarSpacing);
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
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:165
const auto project
THEME_API Theme theTheme
Definition: Theme.cpp:82
static constexpr auto toolbarSpacing
Preferred spacing between inner toolbar elements.
Definition: ToolBar.h:57
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:73
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:819
void UpdatePrefs() override
Definition: ToolBar.cpp:622
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:492
wxWindowPtr< ToolBar > Holder
Definition: ToolBar.h:77
Holds a msgid for the translation catalog; may also bind format arguments.