1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-01 16:19:43 +02:00

Follow wxWidgets argument conventions for other window factories

This commit is contained in:
Paul Licameli 2017-10-24 09:18:27 -04:00
parent 5e10ec0def
commit aa72cae61b
10 changed files with 73 additions and 60 deletions

View File

@ -129,12 +129,13 @@ void ControlToolBar::Create(wxWindow * parent)
// This is a convenience function that allows for button creation in
// MakeButtons() with fewer arguments
AButton *ControlToolBar::MakeButton(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
AButton *ControlToolBar::MakeButton(ControlToolBar *pBar,
teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
int id,
bool processdownevents,
const wxChar *label)
{
AButton *r = ToolBar::MakeButton(this,
AButton *r = ToolBar::MakeButton(pBar,
bmpRecoloredUpLarge, bmpRecoloredDownLarge, bmpRecoloredUpHiliteLarge, bmpRecoloredHiliteLarge,
eEnabledUp, eEnabledDown, eDisabled,
wxWindowID(id),
@ -170,10 +171,10 @@ void ControlToolBar::Populate()
SetBackgroundColour( theTheme.Colour( clrMedium ) );
MakeButtonBackgroundsLarge();
mPause = MakeButton(bmpPause, bmpPause, bmpPauseDisabled,
mPause = MakeButton(this, bmpPause, bmpPause, bmpPauseDisabled,
ID_PAUSE_BUTTON, true, _("Pause"));
mPlay = MakeButton( bmpPlay, bmpPlay, bmpPlayDisabled,
mPlay = MakeButton(this, bmpPlay, bmpPlay, bmpPlayDisabled,
ID_PLAY_BUTTON, true, _("Play"));
MakeAlternateImages(*mPlay, 1, bmpLoop, bmpLoop, bmpLoopDisabled);
MakeAlternateImages(*mPlay, 2,
@ -184,16 +185,16 @@ void ControlToolBar::Populate()
bmpSeek, bmpSeek, bmpSeekDisabled);
mPlay->FollowModifierKeys();
mStop = MakeButton( bmpStop, bmpStop, bmpStopDisabled ,
mStop = MakeButton(this, bmpStop, bmpStop, bmpStopDisabled ,
ID_STOP_BUTTON, false, _("Stop"));
mRewind = MakeButton(bmpRewind, bmpRewind, bmpRewindDisabled,
mRewind = MakeButton(this, bmpRewind, bmpRewind, bmpRewindDisabled,
ID_REW_BUTTON, false, _("Skip to Start"));
mFF = MakeButton(bmpFFwd, bmpFFwd, bmpFFwdDisabled,
mFF = MakeButton(this, bmpFFwd, bmpFFwd, bmpFFwdDisabled,
ID_FF_BUTTON, false, _("Skip to End"));
mRecord = MakeButton(bmpRecord, bmpRecord, bmpRecordDisabled,
mRecord = MakeButton(this, bmpRecord, bmpRecord, bmpRecordDisabled,
ID_RECORD_BUTTON, false, _("Record"));
bool bPreferNewTrack;

View File

@ -120,7 +120,9 @@ class ControlToolBar final : public ToolBar {
private:
AButton *MakeButton(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
static AButton *MakeButton(
ControlToolBar *pBar,
teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
int id,
bool processdownevents,
const wxChar *label);

View File

@ -98,14 +98,15 @@ void EditToolBar::AddSeparator()
/// MakeButtons() with fewer arguments
/// Very similar to code in ControlToolBar...
AButton *EditToolBar::AddButton(
EditToolBar *pBar,
teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
int id,
const wxChar *label,
bool toggle)
{
AButton *&r = mButtons[id];
AButton *&r = pBar->mButtons[id];
r = ToolBar::MakeButton(this,
r = ToolBar::MakeButton(pBar,
bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
eEnabledUp, eEnabledDown, eDisabled,
wxWindowID(id),
@ -117,7 +118,7 @@ AButton *EditToolBar::AddButton(
// JKC: Unlike ControlToolBar, does not have a focus rect. Shouldn't it?
// r->SetFocusRect( r->GetRect().Deflate( 4, 4 ) );
Add( r, 0, wxALIGN_CENTER );
pBar->Add( r, 0, wxALIGN_CENTER );
return r;
}
@ -129,28 +130,28 @@ void EditToolBar::Populate()
/* Buttons */
// Tooltips slightly more verbose than the menu entries are.
AddButton(bmpCut, bmpCut, bmpCutDisabled, ETBCutID,
AddButton(this, bmpCut, bmpCut, bmpCutDisabled, ETBCutID,
_("Cut selection"));
AddButton(bmpCopy, bmpCopy, bmpCopyDisabled, ETBCopyID,
AddButton(this, bmpCopy, bmpCopy, bmpCopyDisabled, ETBCopyID,
_("Copy selection"));
AddButton(bmpPaste, bmpPaste, bmpPasteDisabled, ETBPasteID,
AddButton(this, bmpPaste, bmpPaste, bmpPasteDisabled, ETBPasteID,
_("Paste"));
AddButton(bmpTrim, bmpTrim, bmpTrimDisabled, ETBTrimID,
AddButton(this, bmpTrim, bmpTrim, bmpTrimDisabled, ETBTrimID,
_("Trim audio outside selection"));
AddButton(bmpSilence, bmpSilence, bmpSilenceDisabled, ETBSilenceID,
AddButton(this, bmpSilence, bmpSilence, bmpSilenceDisabled, ETBSilenceID,
_("Silence audio selection"));
AddSeparator();
AddButton(bmpUndo, bmpUndo, bmpUndoDisabled, ETBUndoID,
AddButton(this, bmpUndo, bmpUndo, bmpUndoDisabled, ETBUndoID,
_("Undo"));
AddButton(bmpRedo, bmpRedo, bmpRedoDisabled, ETBRedoID,
AddButton(this, bmpRedo, bmpRedo, bmpRedoDisabled, ETBRedoID,
_("Redo"));
AddSeparator();
#ifdef OPTION_SYNC_LOCK_BUTTON
AddButton(bmpSyncLockTracksUp, bmpSyncLockTracksDown, bmpSyncLockTracksUp, ETBSyncLockID,
AddButton(this, bmpSyncLockTracksUp, bmpSyncLockTracksDown, bmpSyncLockTracksUp, ETBSyncLockID,
_("Sync-Lock Tracks"), true);
AddSeparator();
@ -158,17 +159,17 @@ void EditToolBar::Populate()
// Tooltips match menu entries.
// We previously had longer tooltips which were not more clear.
AddButton(bmpZoomIn, bmpZoomIn, bmpZoomInDisabled, ETBZoomInID,
AddButton(this, bmpZoomIn, bmpZoomIn, bmpZoomInDisabled, ETBZoomInID,
_("Zoom In"));
AddButton(bmpZoomOut, bmpZoomOut, bmpZoomOutDisabled, ETBZoomOutID,
AddButton(this, bmpZoomOut, bmpZoomOut, bmpZoomOutDisabled, ETBZoomOutID,
_("Zoom Out"));
AddButton(bmpZoomSel, bmpZoomSel, bmpZoomSelDisabled, ETBZoomSelID,
AddButton(this, bmpZoomSel, bmpZoomSel, bmpZoomSelDisabled, ETBZoomSelID,
_("Zoom to Selection"));
AddButton(bmpZoomFit, bmpZoomFit, bmpZoomFitDisabled, ETBZoomFitID,
AddButton(this, bmpZoomFit, bmpZoomFit, bmpZoomFitDisabled, ETBZoomFitID,
_("Fit to Width"));
#ifdef EXPERIMENTAL_ZOOM_TOGGLE_BUTTON
AddButton(bmpZoomToggle, bmpZoomToggle, bmpZoomToggleDisabled, ETBZoomToggleID,
AddButton(this, bmpZoomToggle, bmpZoomToggle, bmpZoomToggleDisabled, ETBZoomToggleID,
_("Zoom Toggle"));
#endif
@ -190,7 +191,7 @@ void EditToolBar::Populate()
#if defined(EXPERIMENTAL_EFFECTS_RACK)
AddSeparator();
AddButton(bmpEditEffects, bmpEditEffects, bmpEditEffects, ETBEffectsID,
AddButton(this, bmpEditEffects, bmpEditEffects, bmpEditEffects, ETBEffectsID,
_("Show Effects Rack"), true);
#endif

View File

@ -86,7 +86,9 @@ class EditToolBar final : public ToolBar {
private:
AButton *AddButton(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
static AButton *AddButton(
EditToolBar *pBar,
teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
int id, const wxChar *label, bool toggle = false);
void AddSeparator();

View File

@ -76,15 +76,16 @@ void ScrubbingToolBar::Create(wxWindow * parent)
/// MakeButtons() with fewer arguments
/// Very similar to code in ControlToolBar...
AButton *ScrubbingToolBar::AddButton
(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
(ScrubbingToolBar *pBar,
teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
int id,
const wxChar *label,
bool toggle)
{
AButton *&r = mButtons[id];
AButton *&r = pBar->mButtons[id];
r = ToolBar::MakeButton
(this,
(pBar,
bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
eEnabledUp, eEnabledDown, eDisabled,
wxWindowID(id),
@ -96,7 +97,7 @@ AButton *ScrubbingToolBar::AddButton
// JKC: Unlike ControlToolBar, does not have a focus rect. Shouldn't it?
// r->SetFocusRect( r->GetRect().Deflate( 4, 4 ) );
Add( r, 0, wxALIGN_CENTER );
pBar->Add( r, 0, wxALIGN_CENTER );
return r;
}
@ -107,11 +108,11 @@ void ScrubbingToolBar::Populate()
MakeButtonBackgroundsSmall();
/* Buttons */
AddButton(bmpScrub, bmpScrub, bmpScrubDisabled, STBScrubID,
AddButton(this, bmpScrub, bmpScrub, bmpScrubDisabled, STBScrubID,
_("Scrub"), true);
AddButton(bmpSeek, bmpSeek, bmpSeekDisabled, STBSeekID,
AddButton(this, bmpSeek, bmpSeek, bmpSeekDisabled, STBSeekID,
_("Seek"), true);
AddButton(bmpToggleScrubRuler, bmpToggleScrubRuler, bmpToggleScrubRuler,
AddButton(this, bmpToggleScrubRuler, bmpToggleScrubRuler, bmpToggleScrubRuler,
STBRulerID,
_("Scrub Ruler"), true);

View File

@ -56,8 +56,10 @@ public:
private:
AButton *AddButton(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
int id, const wxChar *label, bool toggle = false);
static AButton *AddButton(
ScrubbingToolBar *pBar,
teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
int id, const wxChar *label, bool toggle = false);
void MakeButtons();

View File

@ -155,10 +155,11 @@ void ToolsToolBar::UpdatePrefs()
ToolBar::UpdatePrefs();
}
AButton * ToolsToolBar::MakeTool( teBmps eTool,
AButton * ToolsToolBar::MakeTool(
ToolsToolBar *pBar, teBmps eTool,
int id, const wxChar *label)
{
AButton *button = ToolBar::MakeButton(this,
AButton *button = ToolBar::MakeButton(pBar,
bmpRecoloredUpSmall,
bmpRecoloredDownSmall,
bmpRecoloredUpHiliteSmall,
@ -168,7 +169,7 @@ AButton * ToolsToolBar::MakeTool( teBmps eTool,
wxDefaultPosition, true,
theTheme.ImageSize( bmpRecoloredUpSmall ));
button->SetLabel( label );
mToolSizer->Add( button );
pBar->mToolSizer->Add( button );
return button;
}
@ -180,12 +181,12 @@ void ToolsToolBar::Populate()
Add(mToolSizer = safenew wxGridSizer(2, 3, 1, 1));
/* Tools */
mTool[ selectTool ] = MakeTool( bmpIBeam, selectTool, _("Selection Tool") );
mTool[ envelopeTool ] = MakeTool( bmpEnvelope, envelopeTool, _("Envelope Tool") );
mTool[ drawTool ] = MakeTool( bmpDraw, drawTool, _("Draw Tool") );
mTool[ zoomTool ] = MakeTool( bmpZoom, zoomTool, _("Zoom Tool") );
mTool[ slideTool ] = MakeTool( bmpTimeShift, slideTool, _("Slide Tool") );
mTool[ multiTool ] = MakeTool( bmpMulti, multiTool, _("Multi Tool") );
mTool[ selectTool ] = MakeTool( this, bmpIBeam, selectTool, _("Selection Tool") );
mTool[ envelopeTool ] = MakeTool( this, bmpEnvelope, envelopeTool, _("Envelope Tool") );
mTool[ drawTool ] = MakeTool( this, bmpDraw, drawTool, _("Draw Tool") );
mTool[ zoomTool ] = MakeTool( this, bmpZoom, zoomTool, _("Zoom Tool") );
mTool[ slideTool ] = MakeTool( this, bmpTimeShift, slideTool, _("Slide Tool") );
mTool[ multiTool ] = MakeTool( this, bmpMulti, multiTool, _("Multi Tool") );
mTool[mCurrentTool]->PushDown();

View File

@ -70,7 +70,8 @@ class ToolsToolBar final : public ToolBar {
void RegenerateTooltips() override;
wxImage *MakeToolImage(wxImage *tool, wxImage *mask, int style);
AButton *MakeTool(teBmps eTool, int id, const wxChar *label);
static AButton *MakeTool(
ToolsToolBar *pBar, teBmps eTool, int id, const wxChar *label);
AButton *mTool[numTools];
wxGridSizer *mToolSizer;

View File

@ -137,13 +137,14 @@ void TranscriptionToolBar::Create(wxWindow * parent)
/// MakeButtons() with fewer arguments
/// Very similar to code in ControlToolBar...
AButton *TranscriptionToolBar::AddButton(
TranscriptionToolBar *pBar,
teBmps eFore, teBmps eDisabled,
int id,
const wxChar *label)
{
AButton *&r = mButtons[id];
AButton *&r = pBar->mButtons[id];
r = ToolBar::MakeButton(this,
r = ToolBar::MakeButton(pBar,
bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall,bmpRecoloredHiliteSmall,
eFore, eFore, eDisabled,
wxWindowID(id),
@ -155,7 +156,7 @@ AButton *TranscriptionToolBar::AddButton(
// JKC: Unlike ControlToolBar, does not have a focus rect. Shouldn't it?
// r->SetFocusRect( r->GetRect().Deflate( 4, 4 ) );
Add( r, 0, wxALIGN_CENTER );
pBar->Add( r, 0, wxALIGN_CENTER );
return r;
}
@ -177,7 +178,7 @@ void TranscriptionToolBar::Populate()
// Very similar to code in EditToolBar
MakeButtonBackgroundsSmall();
AddButton(bmpPlay, bmpPlayDisabled, TTB_PlaySpeed,
AddButton(this, bmpPlay, bmpPlayDisabled, TTB_PlaySpeed,
_("Play at selected speed"));
MakeAlternateImages(bmpLoop, bmpLoopDisabled, TTB_PlaySpeed, 1);
MakeAlternateImages(bmpCutPreview, bmpCutPreviewDisabled, TTB_PlaySpeed, 2);
@ -212,23 +213,23 @@ void TranscriptionToolBar::Populate()
// If we need these strings translated, then search and replace
// TRANSLATBLE by _ and remove this #define.
#define TRANSLATABLE( x ) wxT( x )
AddButton(bmpTnStartOn, bmpTnStartOnDisabled, TTB_StartOn,
AddButton(this, bmpTnStartOn, bmpTnStartOnDisabled, TTB_StartOn,
TRANSLATABLE("Adjust left selection to next onset"));
AddButton(bmpTnEndOn, bmpTnEndOnDisabled, TTB_EndOn,
AddButton(this, bmpTnEndOn, bmpTnEndOnDisabled, TTB_EndOn,
TRANSLATABLE("Adjust right selection to previous offset"));
AddButton(bmpTnStartOff, bmpTnStartOffDisabled, TTB_StartOff,
AddButton(this, bmpTnStartOff, bmpTnStartOffDisabled, TTB_StartOff,
TRANSLATABLE("Adjust left selection to next offset"));
AddButton(bmpTnEndOff, bmpTnEndOffDisabled, TTB_EndOff,
AddButton(this, bmpTnEndOff, bmpTnEndOffDisabled, TTB_EndOff,
TRANSLATABLE("Adjust right selection to previous onset"));
AddButton(bmpTnSelectSound, bmpTnSelectSoundDisabled, TTB_SelectSound,
AddButton(this, bmpTnSelectSound, bmpTnSelectSoundDisabled, TTB_SelectSound,
TRANSLATABLE("Select region of sound around cursor"));
AddButton(bmpTnSelectSilence, bmpTnSelectSilenceDisabled, TTB_SelectSilence,
AddButton(this, bmpTnSelectSilence, bmpTnSelectSilenceDisabled, TTB_SelectSilence,
TRANSLATABLE("Select region of silence around cursor"));
AddButton(bmpTnAutomateSelection, bmpTnAutomateSelectionDisabled, TTB_AutomateSelection,
AddButton(this, bmpTnAutomateSelection, bmpTnAutomateSelectionDisabled, TTB_AutomateSelection,
TRANSLATABLE("Automatically make labels from words"));
AddButton(bmpTnMakeTag, bmpTnMakeTagDisabled, TTB_MakeLabel,
AddButton(this, bmpTnMakeTag, bmpTnMakeTagDisabled, TTB_MakeLabel,
TRANSLATABLE("Add label at selection"));
AddButton(bmpTnCalibrate, bmpTnCalibrateDisabled, TTB_Calibrate,
AddButton(this, bmpTnCalibrate, bmpTnCalibrateDisabled, TTB_Calibrate,
TRANSLATABLE("Calibrate voicekey"));
mSensitivitySlider = safenew ASlider(this,

View File

@ -122,7 +122,8 @@ class TranscriptionToolBar final : public ToolBar {
private:
void InitializeTranscriptionToolBar();
AButton *AddButton(
static AButton *AddButton(
TranscriptionToolBar *pBar,
teBmps eFore, teBmps eDisabled,
int id,
const wxChar *label);