Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
ToolsToolBar Class Referencefinal

A kind of ToolBar with Tools on it. More...

#include <ToolsToolBar.h>

Inheritance diagram for ToolsToolBar:
[legend]
Collaboration diagram for ToolsToolBar:
[legend]

Public Member Functions

 ToolsToolBar (AudacityProject &project)
 
virtual ~ToolsToolBar ()
 
void UpdatePrefs () override
 
void OnTool (wxCommandEvent &evt)
 
void OnToolChanged (wxCommandEvent &evt)
 
void DoToolChanged ()
 
void Populate () override
 
void Repaint (wxDC *WXUNUSED(dc)) override
 
void EnableDisableButtons () override
 
- Public Member Functions inherited from ToolBar
 ToolBar (AudacityProject &project, int type, const TranslatableString &label, const wxString &section, bool resizable=false)
 
virtual ~ToolBar ()
 
bool AcceptsFocus () const override
 
bool AcceptsFocusFromKeyboard () const override
 
virtual void SetToDefaultSize ()
 
virtual void Create (wxWindow *parent)
 
virtual void EnableDisableButtons ()=0
 
virtual void ReCreateButtons ()
 
void UpdatePrefs () override
 
virtual void RegenerateTooltips ()=0
 
int GetType ()
 
TranslatableString GetTitle ()
 
TranslatableString GetLabel ()
 
wxString GetSection ()
 
ToolDockGetDock ()
 
void SetLabel (const TranslatableString &label)
 
virtual 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 ()
 
wxSize GetSmartDockedSize ()
 
virtual void ResizingDone ()
 
- 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 TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Static Public Member Functions

static ToolsToolBarGet (AudacityProject &project)
 
static const ToolsToolBarGet (const AudacityProject &project)
 
- 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 AButtonMakeButton (ToolBar *parent, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, bool processdownevents, const TranslatableString &label)
 
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 (AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
 
static void MakeButtonBackgroundsSmall ()
 
static void MakeButtonBackgroundsLarge ()
 

Private Types

enum  { numTools = 4 }
 

Private Member Functions

void Create (wxWindow *parent) override
 
void RegenerateTooltips () override
 
wxImageMakeToolImage (wxImage *tool, wxImage *mask, int style)
 

Static Private Member Functions

static AButtonMakeTool (ToolsToolBar *pBar, teBmps eTool, int id, const TranslatableString &label)
 

Private Attributes

AButtonmTool [numTools]
 
wxGridSizer * mToolSizer
 
int mCurrentTool
 

Additional Inherited Members

- Public Types inherited from ToolBar
using Holder = wxWindowPtr< ToolBar >
 
- Protected Member Functions inherited from ToolBar
void SetButton (bool down, AButton *button)
 
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 Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdatePrefs ()=0
 
- Static Protected Member Functions inherited from ToolBar
static void MakeMacRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
static void MakeMacRecoloredImageSize (teBmps eBmpOut, teBmps eBmpIn, const wxSize &size)
 
static void MakeRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
static void MakeRecoloredImageSize (teBmps eBmpOut, teBmps eBmpIn, const wxSize &size)
 
- Static Protected Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 
- Protected Attributes inherited from ToolBar
AudacityProjectmProject
 
TranslatableString mLabel
 
wxString mSection
 
int mType
 

Detailed Description

A kind of ToolBar with Tools on it.

This class, which is a child of Toolbar, creates the window containing the tool selection (ibeam, envelope, move, zoom). The window can be embedded within a normal project window, or within a ToolBarFrame.

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.

See also
Themability of Audacity

Definition at line 35 of file ToolsToolBar.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
numTools 

Definition at line 62 of file ToolsToolBar.h.

62{ numTools = 4 };

Constructor & Destructor Documentation

◆ ToolsToolBar()

ToolsToolBar::ToolsToolBar ( AudacityProject project)

◆ ~ToolsToolBar()

ToolsToolBar::~ToolsToolBar ( )
virtual

Definition at line 97 of file ToolsToolBar.cpp.

98{
99 static_assert(
101 "mismatch in number of tools" );
102}

References ToolCodes::numTools, and numTools.

Member Function Documentation

◆ Create()

void ToolsToolBar::Create ( wxWindow *  parent)
overrideprivatevirtual

Reimplemented from ToolBar.

Definition at line 247 of file ToolsToolBar.cpp.

248{
249 ToolBar::Create(parent);
250 UpdatePrefs();
251}
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:484
void UpdatePrefs() override

References ToolBar::Create(), and UpdatePrefs().

Here is the call graph for this function:

◆ DoToolChanged()

void ToolsToolBar::DoToolChanged ( )

Definition at line 231 of file ToolsToolBar.cpp.

232{
233 auto &projectSettings = ProjectSettings::Get( mProject );
234 using namespace ToolCodes;
235 mCurrentTool = projectSettings.GetTool() - firstTool;
236 for (int i = 0; i < numTools; i++)
237 if (i == mCurrentTool)
238 mTool[i]->PushDown();
239 else
240 mTool[i]->PopUp();
241
242 gPrefs->Write(wxT("/GUI/ToolBars/Tools/MultiToolActive"),
243 mTool[multiTool]->IsDown());
244 gPrefs->Flush();
245}
wxT("CloseDown"))
FileConfig * gPrefs
Definition: Prefs.cpp:71
void PushDown()
Definition: AButton.cpp:580
void PopUp()
Definition: AButton.cpp:588
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
static ProjectSettings & Get(AudacityProject &project)
AudacityProject & mProject
Definition: ToolBar.h:251
AButton * mTool[numTools]
Definition: ToolsToolBar.h:63

References ToolCodes::firstTool, FileConfig::Flush(), ProjectSettings::Get(), gPrefs, mCurrentTool, ToolBar::mProject, mTool, ToolCodes::multiTool, numTools, AButton::PopUp(), AButton::PushDown(), and wxT().

Referenced by OnToolChanged(), and Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnableDisableButtons()

void ToolsToolBar::EnableDisableButtons ( )
inlineoverridevirtual

Implements ToolBar.

Definition at line 53 of file ToolsToolBar.h.

53{};

◆ Get() [1/2]

ToolsToolBar & ToolsToolBar::Get ( AudacityProject project)
static

Definition at line 104 of file ToolsToolBar.cpp.

105{
106 auto &toolManager = ToolManager::Get( project );
107 return *static_cast<ToolsToolBar*>( toolManager.GetToolBar(ToolsBarID) );
108}
@ ToolsBarID
Definition: ToolBar.h:73
static ToolManager & Get(AudacityProject &project)
A kind of ToolBar with Tools on it.
Definition: ToolsToolBar.h:35

References ToolManager::Get(), and ToolsBarID.

Referenced by Get(), and anonymous_namespace{ToolsToolBar.cpp}::SetTool().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Get() [2/2]

const ToolsToolBar & ToolsToolBar::Get ( const AudacityProject project)
static

Definition at line 110 of file ToolsToolBar.cpp.

111{
112 return Get( const_cast<AudacityProject&>( project )) ;
113}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
static ToolsToolBar & Get(AudacityProject &project)

References Get().

Here is the call graph for this function:

◆ MakeTool()

AButton * ToolsToolBar::MakeTool ( ToolsToolBar pBar,
teBmps  eTool,
int  id,
const TranslatableString label 
)
staticprivate

Definition at line 172 of file ToolsToolBar.cpp.

175{
176 AButton *button = ToolBar::MakeButton(pBar,
177 bmpRecoloredUpSmall,
178 bmpRecoloredDownSmall,
179 bmpRecoloredUpHiliteSmall,
180 bmpRecoloredDownSmall, // Not bmpRecoloredHiliteSmall as down is inactive.
181 eTool, eTool, eTool,
182 wxWindowID(id + FirstToolID),
183 wxDefaultPosition, true,
184 theTheme.ImageSize( bmpRecoloredUpSmall ));
185 button->SetLabel( label );
186 pBar->mToolSizer->Add( button );
187 return button;
188}
TranslatableString label
Definition: TagsEditor.cpp:163
THEME_API Theme theTheme
Definition: Theme.cpp:82
const int FirstToolID
Definition: ToolsToolBar.h:33
A wxButton with mouse-over behaviour.
Definition: AButton.h:104
void SetLabel(const TranslatableString &label)
Definition: AButton.cpp:192
wxSize ImageSize(int iIndex)
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:861
wxGridSizer * mToolSizer
Definition: ToolsToolBar.h:64

References FirstToolID, ThemeBase::ImageSize(), label, ToolBar::MakeButton(), mToolSizer, AButton::SetLabel(), and theTheme.

Referenced by Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MakeToolImage()

wxImage * ToolsToolBar::MakeToolImage ( wxImage tool,
wxImage mask,
int  style 
)
private

◆ OnTool()

void ToolsToolBar::OnTool ( wxCommandEvent &  evt)

Definition at line 210 of file ToolsToolBar.cpp.

211{
212 // This will cause callback to OnToolChanged
213 auto iTool = evt.GetId() - ToolCodes::firstTool - FirstToolID;
214 auto pButton = mTool[iTool];
215 if (pButton->IsDown())
217 else
218 // Don't stay up
219 pButton->PushDown();
220}
void SetTool(int tool)

References ToolCodes::firstTool, FirstToolID, ProjectSettings::Get(), ToolBar::mProject, mTool, and ProjectSettings::SetTool().

Here is the call graph for this function:

◆ OnToolChanged()

void ToolsToolBar::OnToolChanged ( wxCommandEvent &  evt)

Definition at line 222 of file ToolsToolBar.cpp.

223{
224 evt.Skip(); // Let other listeners hear the event too
225 if (evt.GetInt() != ProjectSettings::ChangedTool)
226 return;
229}
static ProjectWindow & Get(AudacityProject &project)
void RedrawProject(const bool bForceWaveTracks=false)
void DoToolChanged()

References ProjectSettings::ChangedTool, DoToolChanged(), ProjectWindow::Get(), ToolBar::mProject, and ProjectWindow::RedrawProject().

Referenced by EVT_COMMAND_RANGE().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Populate()

void ToolsToolBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 191 of file ToolsToolBar.cpp.

192{
193 SetBackgroundColour( theTheme.Colour( clrMedium ) );
195
196 Add(mToolSizer = safenew wxGridSizer(2, 2, 1, 1));
197
198 /* Tools */
199 using namespace ToolCodes;
200 mTool[ selectTool ] = MakeTool( this, bmpIBeam, selectTool, XO("Selection Tool") );
201 mTool[ envelopeTool ] = MakeTool( this, bmpEnvelope, envelopeTool, XO("Envelope Tool") );
202 mTool[ drawTool ] = MakeTool( this, bmpDraw, drawTool, XO("Draw Tool") );
203 mTool[ multiTool ] = MakeTool( this, bmpMulti, multiTool, XO("Multi-Tool") );
204
206
208}
#define XO(s)
Definition: Internat.h:31
#define safenew
Definition: MemoryX.h:10
wxColour & Colour(int iIndex)
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:695
static void MakeButtonBackgroundsSmall()
Definition: ToolBar.cpp:823
static AButton * MakeTool(ToolsToolBar *pBar, teBmps eTool, int id, const TranslatableString &label)
void RegenerateTooltips() override

References ToolBar::Add(), ThemeBase::Colour(), DoToolChanged(), ToolCodes::drawTool, ToolCodes::envelopeTool, ToolBar::MakeButtonBackgroundsSmall(), MakeTool(), mTool, mToolSizer, ToolCodes::multiTool, RegenerateTooltips(), safenew, ToolCodes::selectTool, theTheme, and XO.

Here is the call graph for this function:

◆ RegenerateTooltips()

void ToolsToolBar::RegenerateTooltips ( )
overrideprivatevirtual

Implements ToolBar.

Definition at line 115 of file ToolsToolBar.cpp.

116{
117
118// JKC:
119// Under Win98 Tooltips appear to be buggy, when you have a lot of
120// tooltip messages flying around. I found that just creating a
121// twelfth tooltip caused Audacity to crash when it tried to show
122// any tooltip.
123//
124// Win98 does NOT recover from this crash - for any application which is
125// using tooltips will also crash thereafter... so you must reboot.
126// Rather weird.
127//
128// Getting windows to process more of its stacked up messages seems
129// to workaround the problem. The problem is not fully understood though
130// (as of April 2003).
131
132 // Vaughan, October 2003: Now we're crashing on Win2K if
133 // "Quit when closing last window" is unchecked, when we come back
134 // through here, on either of the wxSafeYield calls.
135 // James confirms that commenting them out does not cause his original problem
136 // to reappear, so they're commented out now.
137 // wxSafeYield(); //Deal with some queued up messages...
138
139 #if wxUSE_TOOLTIPS
140
141 using namespace ToolCodes;
142
143 static const struct Entry {
144 int tool;
145 CommandID commandName;
146 TranslatableString untranslatedLabel;
147 } table[] = {
148 { selectTool, wxT("SelectTool"), XO("Selection Tool") },
149 { envelopeTool, wxT("EnvelopeTool"), XO("Envelope Tool") },
150 { drawTool, wxT("DrawTool"), XO("Draw Tool") },
151 { multiTool, wxT("MultiTool"), XO("Multi-Tool") },
152 };
153
154 for (const auto &entry : table) {
156 entry.commandName, entry.untranslatedLabel };
158 *mTool[entry.tool], &command, 1u );
159 }
160 #endif
161
162 // wxSafeYield();
163 return;
164}
static ProjectFileIORegistry::AttributeWriterEntry entry
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
static void SetButtonToolTip(AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
Definition: ToolBar.cpp:956
Holds a msgid for the translation catalog; may also bind format arguments.

References ToolCodes::drawTool, entry, ToolCodes::envelopeTool, ToolBar::mProject, mTool, ToolCodes::multiTool, ToolCodes::selectTool, ToolBar::SetButtonToolTip(), wxT(), and XO.

Referenced by Populate(), and UpdatePrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Repaint()

void ToolsToolBar::Repaint ( wxDC *  WXUNUSEDdc)
inlineoverride

Definition at line 52 of file ToolsToolBar.h.

52{};

◆ UpdatePrefs()

void ToolsToolBar::UpdatePrefs ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 166 of file ToolsToolBar.cpp.

167{
170}
void UpdatePrefs() override
Definition: ToolBar.cpp:614

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

Referenced by Create().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mCurrentTool

int ToolsToolBar::mCurrentTool
private

Definition at line 65 of file ToolsToolBar.h.

Referenced by DoToolChanged().

◆ mTool

AButton* ToolsToolBar::mTool[numTools]
private

Definition at line 63 of file ToolsToolBar.h.

Referenced by DoToolChanged(), OnTool(), Populate(), and RegenerateTooltips().

◆ mToolSizer

wxGridSizer* ToolsToolBar::mToolSizer
private

Definition at line 64 of file ToolsToolBar.h.

Referenced by MakeTool(), and Populate().


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