Audacity  2.2.2
Public Member Functions | 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:
ToolBar wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Public Member Functions

 ToolsToolBar ()
 
virtual ~ToolsToolBar ()
 
void UpdatePrefs () override
 
void OnTool (wxCommandEvent &evt)
 
void SetCurrentTool (int tool)
 
int GetCurrentTool () const
 
bool IsDown (int tool) const
 
int GetDownTool ()
 
void Populate () override
 
void Repaint (wxDC *WXUNUSED(dc)) override
 
void EnableDisableButtons () 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 Create (wxWindow *parent)
 
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)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void RegenerateTooltips () override
 
wxImage * MakeToolImage (wxImage *tool, wxImage *mask, int style)
 

Static Private Member Functions

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

Private Attributes

AButtonmTool [numTools]
 
wxGridSizer * mToolSizer
 
int mCurrentTool
 

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 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 that is managed by a global ToolBarStub called gToolsToolBarStub.

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 49 of file ToolsToolBar.h.

Constructor & Destructor Documentation

ToolsToolBar::ToolsToolBar ( )
ToolsToolBar::~ToolsToolBar ( )
virtual

Definition at line 97 of file ToolsToolBar.cpp.

98 {
99 }

Member Function Documentation

void ToolsToolBar::EnableDisableButtons ( )
inlineoverridevirtual

Implements ToolBar.

Definition at line 69 of file ToolsToolBar.h.

69 {};
int ToolsToolBar::GetCurrentTool ( ) const

Gets the currently active tool In Multi-mode this might not return the multi-tool itself since the active tool may be changed by what you hover over.

Definition at line 199 of file ToolsToolBar.cpp.

References mCurrentTool.

Referenced by Track::HitTest().

200 {
201  return mCurrentTool;
202 }
int ToolsToolBar::GetDownTool ( )

Definition at line 240 of file ToolsToolBar.cpp.

References firstTool, IsDown(), and lastTool.

Referenced by AudacityProject::OnNextTool(), and AudacityProject::OnPrevTool().

241 {
242  int tool;
243 
244  for (tool = firstTool; tool <= lastTool; tool++)
245  if (IsDown(tool))
246  return tool;
247 
248  return firstTool; // Should never happen
249 }
bool IsDown(int tool) const
bool ToolsToolBar::IsDown ( int  tool) const

Definition at line 235 of file ToolsToolBar.cpp.

References AButton::IsDown(), and mTool.

Referenced by TrackPanel::DrawTracks(), GetDownTool(), Track::HitTest(), OnTool(), SelectHandle::Preview(), and SetCurrentTool().

236 {
237  return mTool[tool]->IsDown();
238 }
bool IsDown()
Definition: AButton.h:123
AButton * mTool[numTools]
Definition: ToolsToolBar.h:78
AButton * ToolsToolBar::MakeTool ( ToolsToolBar pBar,
teBmps  eTool,
int  id,
const wxChar *  label 
)
staticprivate

Definition at line 158 of file ToolsToolBar.cpp.

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

Referenced by Populate().

161 {
162  AButton *button = ToolBar::MakeButton(pBar,
163  bmpRecoloredUpSmall,
164  bmpRecoloredDownSmall,
165  bmpRecoloredUpHiliteSmall,
166  bmpRecoloredDownSmall, // Not bmpRecoloredHiliteSmall as down is inactive.
167  eTool, eTool, eTool,
168  wxWindowID(id + FirstToolID),
169  wxDefaultPosition, true,
170  theTheme.ImageSize( bmpRecoloredUpSmall ));
171  button->SetLabel( label );
172  pBar->mToolSizer->Add( button );
173  return button;
174 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
wxString label
Definition: Tags.cpp:733
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:769
wxGridSizer * mToolSizer
Definition: ToolsToolBar.h:79
const int FirstToolID
Definition: ToolsToolBar.h:47
A wxButton with mouse-over behaviour.
Definition: AButton.h:28
wxImage* ToolsToolBar::MakeToolImage ( wxImage *  tool,
wxImage *  mask,
int  style 
)
private
void ToolsToolBar::OnTool ( wxCommandEvent &  evt)

Definition at line 251 of file ToolsToolBar.cpp.

References firstTool, FirstToolID, gPrefs, IsDown(), mCurrentTool, mTool, multiTool, numTools, AButton::PopUp(), AButton::PushDown(), and RedrawAllProjects().

252 {
253  mCurrentTool = evt.GetId() - firstTool - FirstToolID;
254  for (int i = 0; i < numTools; i++)
255  if (i == mCurrentTool)
256  mTool[i]->PushDown();
257  else
258  mTool[i]->PopUp();
259 
261 
262  gPrefs->Write(wxT("/GUI/ToolBars/Tools/MultiToolActive"),
263  IsDown(multiTool));
264  gPrefs->Flush();
265 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
void PopUp()
Definition: AButton.cpp:525
AButton * mTool[numTools]
Definition: ToolsToolBar.h:78
void RedrawAllProjects()
Definition: Project.cpp:597
const int FirstToolID
Definition: ToolsToolBar.h:47
bool IsDown(int tool) const
void PushDown()
Definition: AButton.cpp:517
void ToolsToolBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 177 of file ToolsToolBar.cpp.

References _(), ToolBar::Add(), ThemeBase::Colour(), drawTool, envelopeTool, ToolBar::MakeButtonBackgroundsSmall(), MakeTool(), mCurrentTool, mTool, mToolSizer, multiTool, AButton::PushDown(), RegenerateTooltips(), safenew, selectTool, slideTool, theTheme, and zoomTool.

178 {
179  SetBackgroundColour( theTheme.Colour( clrMedium ) );
181  Add(mToolSizer = safenew wxGridSizer(2, 3, 1, 1));
182 
183  /* Tools */
184  mTool[ selectTool ] = MakeTool( this, bmpIBeam, selectTool, _("Selection Tool") );
185  mTool[ envelopeTool ] = MakeTool( this, bmpEnvelope, envelopeTool, _("Envelope Tool") );
186  mTool[ drawTool ] = MakeTool( this, bmpDraw, drawTool, _("Draw Tool") );
187  mTool[ zoomTool ] = MakeTool( this, bmpZoom, zoomTool, _("Zoom Tool") );
188  mTool[ slideTool ] = MakeTool( this, bmpTimeShift, slideTool, _("Slide Tool") );
189  mTool[ multiTool ] = MakeTool( this, bmpMulti, multiTool, _("Multi Tool") );
190 
192 
194 }
void MakeButtonBackgroundsSmall()
Definition: ToolBar.cpp:731
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
AButton * mTool[numTools]
Definition: ToolsToolBar.h:78
#define safenew
Definition: Audacity.h:230
wxGridSizer * mToolSizer
Definition: ToolsToolBar.h:79
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:615
_("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
static AButton * MakeTool(ToolsToolBar *pBar, teBmps eTool, int id, const wxChar *label)
void RegenerateTooltips() override
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
void PushDown()
Definition: AButton.cpp:517
void ToolsToolBar::RegenerateTooltips ( )
overrideprivatevirtual

Implements ToolBar.

Definition at line 101 of file ToolsToolBar.cpp.

References drawTool, envelopeTool, mTool, multiTool, selectTool, ToolBar::SetButtonToolTip(), slideTool, XO, and zoomTool.

Referenced by Populate(), and UpdatePrefs().

102 {
103 
104 // JKC:
105 // Under Win98 Tooltips appear to be buggy, when you have a lot of
106 // tooltip messages flying around. I found that just creating a
107 // twelfth tooltip caused Audacity to crash when it tried to show
108 // any tooltip.
109 //
110 // Win98 does NOT recover from this crash - for any application which is
111 // using tooltips will also crash thereafter... so you must reboot.
112 // Rather weird.
113 //
114 // Getting windows to process more of its stacked up messages seems
115 // to workaround the problem. The problem is not fully understood though
116 // (as of April 2003).
117 
118  // Vaughan, October 2003: Now we're crashing on Win2K if
119  // "Quit when closing last window" is unchecked, when we come back
120  // through here, on either of the wxSafeYield calls.
121  // James confirms that commenting them out does not cause his original problem
122  // to reappear, so they're commented out now.
123  // wxSafeYield(); //Deal with some queued up messages...
124 
125  #if wxUSE_TOOLTIPS
126 
127  static const struct Entry {
128  int tool;
129  wxString commandName;
130  wxString untranslatedLabel;
131  } table[] = {
132  { selectTool, wxT("SelectTool"), XO("Selection Tool") },
133  { envelopeTool, wxT("EnvelopeTool"), XO("Envelope Tool") },
134  { slideTool, wxT("TimeShiftTool"), XO("Time Shift Tool") },
135  { zoomTool, wxT("ZoomTool"), XO("Zoom Tool") },
136  { drawTool, wxT("DrawTool"), XO("Draw Tool") },
137  { multiTool, wxT("MultiTool"), XO("Multi Tool") },
138  };
139 
140  for (const auto &entry : table) {
141  TranslatedInternalString command{
142  entry.commandName, wxGetTranslation(entry.untranslatedLabel) };
143  ToolBar::SetButtonToolTip( *mTool[entry.tool], &command, 1u );
144  }
145 
146  #endif
147 
148  // wxSafeYield();
149  return;
150 }
AButton * mTool[numTools]
Definition: ToolsToolBar.h:78
#define XO(s)
Definition: Internat.h:33
static void SetButtonToolTip(AButton &button, const TranslatedInternalString commands[], size_t nCommands)
Definition: ToolBar.cpp:827
void ToolsToolBar::Repaint ( wxDC *  WXUNUSEDdc)
inlineoverride

Definition at line 68 of file ToolsToolBar.h.

68 {};
void ToolsToolBar::SetCurrentTool ( int  tool)

Sets the currently active tool

Parameters
tool- The index of the tool to be used.

Definition at line 206 of file ToolsToolBar.cpp.

References gPrefs, IsDown(), mCurrentTool, mTool, multiTool, AButton::PopUp(), AButton::PushDown(), and RefreshCursorForAllProjects().

Referenced by AudacityProject::OnNextTool(), AudacityProject::OnPrevTool(), and AudacityProject::SetTool().

207 {
208  //In multi-mode the current tool is shown by the
209  //cursor icon. The buttons are not updated.
210 
211  bool leavingMulticlipMode =
212  IsDown(multiTool) && tool != multiTool;
213 
214  if (leavingMulticlipMode)
215  mTool[multiTool]->PopUp();
216 
217  if (tool != mCurrentTool || leavingMulticlipMode) {
219  mCurrentTool=tool;
221  }
222  //JKC: ANSWER-ME: Why is this RedrawAllProjects() line required?
223  //msmeyer: I think it isn't, we leave it out for 1.3.1 (beta), and
224  // we'll see if anyone complains.
225  // RedrawAllProjects();
226 
227  //msmeyer: But we instruct the projects to handle the cursor shape again
229 
230  gPrefs->Write(wxT("/GUI/ToolBars/Tools/MultiToolActive"),
231  IsDown(multiTool));
232  gPrefs->Flush();
233 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
void PopUp()
Definition: AButton.cpp:525
AButton * mTool[numTools]
Definition: ToolsToolBar.h:78
void RefreshCursorForAllProjects()
Definition: Project.cpp:604
bool IsDown(int tool) const
void PushDown()
Definition: AButton.cpp:517
void ToolsToolBar::UpdatePrefs ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 152 of file ToolsToolBar.cpp.

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

153 {
156 }
virtual void UpdatePrefs()
Definition: ToolBar.cpp:539
void RegenerateTooltips() override

Member Data Documentation

int ToolsToolBar::mCurrentTool
private

Definition at line 80 of file ToolsToolBar.h.

Referenced by GetCurrentTool(), OnTool(), Populate(), and SetCurrentTool().

AButton* ToolsToolBar::mTool[numTools]
private

Definition at line 78 of file ToolsToolBar.h.

Referenced by IsDown(), OnTool(), Populate(), RegenerateTooltips(), and SetCurrentTool().

wxGridSizer* ToolsToolBar::mToolSizer
private

Definition at line 79 of file ToolsToolBar.h.

Referenced by MakeTool(), and Populate().


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