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, 1, 1));
137
138 /* Buttons */
139 // Tooltips match menu entries.
140 // We previously had longer tooltips which were not more clear.
141 AddButton(bmpCut, bmpCut, bmpCutDisabled, TBCutID,
142 XO("Cut"));
143 AddButton(bmpCopy, bmpCopy, bmpCopyDisabled, TBCopyID,
144 XO("Copy"));
145 AddButton(bmpPaste, bmpPaste, bmpPasteDisabled, TBPasteID,
146 XO("Paste"));
147 AddButton(bmpDelete, bmpDelete, bmpDeleteDisabled, TBDeleteID,
148 XO("Delete"));
149
151
153}
154
156{
158
159 // Set label to pull in language change
160 SetLabel(XO("Cut/Copy/Paste"));
161
162 // Give base class a chance
164}
165
167{
169}
170
172{
174}
175
176void CutCopyPasteToolBar::OnButton(wxCommandEvent & event)
177{
178 mButtons.OnButton(event);
179}
180
184};
185
186namespace {
188 /* i18n-hint: Clicking this menu item shows the toolbar for editing */
190 wxT("ShowCutCopyPasteTB"),
191 XXO("&Cut/Copy/Paste Toolbar"),
192 { Registry::OrderingHint::After, "ShowEditTB" }
193};
194}
195
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:9
TranslatableString label
Definition: TagsEditor.cpp:165
const auto project
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.