diff --git a/src/AboutDialog.h b/src/AboutDialog.h index 2f7a73c00..ff8e2fb8a 100644 --- a/src/AboutDialog.h +++ b/src/AboutDialog.h @@ -52,6 +52,7 @@ class AboutDialog:public wxDialog { void OnOK(wxCommandEvent & event); + wxBoxSizer *topsizer; wxStaticBitmap *icon; DECLARE_EVENT_TABLE() diff --git a/src/LabelDialog.cpp b/src/LabelDialog.cpp index 8689ae7a8..8bc0cba52 100644 --- a/src/LabelDialog.cpp +++ b/src/LabelDialog.cpp @@ -105,42 +105,38 @@ LabelDialog::LabelDialog(wxWindow *parent, { SetName(GetTitle()); - { - // Create the main sizer - auto vs = std::make_unique(wxVERTICAL); + // Create the main sizer + wxBoxSizer *vs = new wxBoxSizer(wxVERTICAL); - // A little instruction - wxStaticText *instruct = - safenew wxStaticText(this, - wxID_ANY, - _("Press F2 or double click to edit cell contents.")); - instruct->SetName(instruct->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) - vs->Add(instruct, - 0, - wxALIGN_LEFT | wxALL, - 5); + // A little instruction + wxStaticText *instruct = + safenew wxStaticText(this, + wxID_ANY, + _("Press F2 or double click to edit cell contents.")); + instruct->SetName(instruct->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) + vs->Add(instruct, + 0, + wxALIGN_LEFT | wxALL, + 5); - // Create the main sizer - mGrid = new Grid(this, wxID_ANY); - vs->Add(mGrid, 1, wxEXPAND | wxALL, 5); + // Create the main sizer + mGrid = new Grid(this, wxID_ANY); + vs->Add(mGrid, 1, wxEXPAND | wxALL, 5); - // Create the action buttons - { - auto hs = std::make_unique(wxHORIZONTAL); - hs->Add(safenew wxButton(this, ID_INSERTA, _("Insert &After")), 1, wxCENTER | wxALL, 5); - hs->Add(safenew wxButton(this, ID_INSERTB, _("Insert &Before")), 1, wxCENTER | wxALL, 5); - hs->Add(safenew wxButton(this, ID_REMOVE, _("&Remove")), 1, wxCENTER | wxALL, 5); - hs->Add(safenew wxButton(this, ID_IMPORT, _("&Import...")), 1, wxCENTER | wxALL, 5); - hs->Add(safenew wxButton(this, ID_EXPORT, _("&Export...")), 1, wxCENTER | wxALL, 5); - vs->Add(hs.release(), 0, wxEXPAND | wxCENTER | wxALL, 5); - } + // Create the action buttons + wxBoxSizer *hs = new wxBoxSizer(wxHORIZONTAL); + hs->Add(safenew wxButton(this, ID_INSERTA, _("Insert &After")), 1, wxCENTER | wxALL, 5); + hs->Add(safenew wxButton(this, ID_INSERTB, _("Insert &Before")), 1, wxCENTER | wxALL, 5); + hs->Add(safenew wxButton(this, ID_REMOVE, _("&Remove")), 1, wxCENTER | wxALL, 5); + hs->Add(safenew wxButton(this, ID_IMPORT, _("&Import...")), 1, wxCENTER | wxALL, 5); + hs->Add(safenew wxButton(this, ID_EXPORT, _("&Export...")), 1, wxCENTER | wxALL, 5); + vs->Add(hs, 0, wxEXPAND | wxCENTER | wxALL, 5); - // Create the exit buttons - vs->Add(CreateStdButtonSizer(this, eCancelButton | eOkButton).release(), 0, wxEXPAND); + // Create the exit buttons + vs->Add(CreateStdButtonSizer(this, eCancelButton|eOkButton), 0, wxEXPAND); - // Make it so - SetSizer(vs.release()); - } + // Make it so + SetSizer(vs); // Build the initial (empty) grid mGrid->CreateGrid(0, Col_Max); diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index a4eaf1f19..009e923d8 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -1002,7 +1002,7 @@ MixerBoard::MixerBoard(AudacityProject* pProject, mScrolledWindow->SetVirtualSize(size); /* This doesn't work to make the mScrolledWindow automatically resize, so do it explicitly in OnSize. - auto pBoxSizer = std::make_unique(wxVERTICAL); + wxBoxSizer* pBoxSizer = new wxBoxSizer(wxVERTICAL); pBoxSizer->Add(mScrolledWindow, 0, wxExpand, 0); this->SetAutoLayout(true); this->SetSizer(pBoxSizer); diff --git a/src/Project.cpp b/src/Project.cpp index 09a9203fe..cbf5d54d9 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -927,7 +927,7 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id, wxDefaultPosition, wxDefaultSize, wxNO_BORDER); - mMainPanel->SetSizer( safenew wxBoxSizer(wxVERTICAL) ); + mMainPanel->SetSizer( new wxBoxSizer(wxVERTICAL) ); pPage = mMainPanel; // Set the colour here to the track panel background to avoid // flicker when Audacity starts up. @@ -937,17 +937,13 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id, //pPage->SetBackgroundColour( theTheme.Colour( clrDark )); #endif - wxBoxSizer *bs; - { - auto ubs = std::make_unique(wxVERTICAL); - bs = ubs.get(); - bs->Add(mToolManager->GetTopDock(), 0, wxEXPAND | wxALIGN_TOP); - bs->Add(mRuler, 0, wxEXPAND); - bs->Add(pPage, 1, wxEXPAND); - bs->Add(mToolManager->GetBotDock(), 0, wxEXPAND); - SetAutoLayout(true); - SetSizer(ubs.release()); - } + wxBoxSizer *bs = new wxBoxSizer( wxVERTICAL ); + bs->Add( mToolManager->GetTopDock(), 0, wxEXPAND | wxALIGN_TOP ); + bs->Add( mRuler, 0, wxEXPAND ); + bs->Add( pPage, 1, wxEXPAND ); + bs->Add( mToolManager->GetBotDock(), 0, wxEXPAND ); + SetAutoLayout( true ); + SetSizer( bs ); bs->Layout(); // The right hand side translates to NEW TrackPanel(... in normal @@ -976,37 +972,33 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id, // keyboard focus problems. pPage->MoveBeforeInTabOrder(mToolManager->GetTopDock()); - bs = (wxBoxSizer *)pPage->GetSizer(); + bs = (wxBoxSizer *) pPage->GetSizer(); - { - // Top horizontal grouping - auto hs = std::make_unique(wxHORIZONTAL); + wxBoxSizer *hs; + wxBoxSizer *vs; - // Track panel - hs->Add(mTrackPanel, 1, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP); + // Top horizontal grouping + hs = new wxBoxSizer( wxHORIZONTAL ); - { - // Vertical grouping - auto vs = std::make_unique(wxVERTICAL); + // Track panel + hs->Add( mTrackPanel, 1, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP ); - // Vertical scroll bar - vs->Add(mVsbar, 1, wxEXPAND | wxALIGN_TOP); - hs->Add(vs.release(), 0, wxEXPAND | wxALIGN_TOP); - } + // Vertical grouping + vs = new wxBoxSizer( wxVERTICAL ); - bs->Add(hs.release(), 1, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP); - } + // Vertical scroll bar + vs->Add( mVsbar, 1, wxEXPAND | wxALIGN_TOP ); + hs->Add( vs, 0, wxEXPAND | wxALIGN_TOP ); + bs->Add( hs, 1, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP ); - { - // Bottom horizontal grouping - auto hs = std::make_unique(wxHORIZONTAL); + // Bottom horizontal grouping + hs = new wxBoxSizer( wxHORIZONTAL ); - // Bottom scrollbar - hs->Add(mTrackPanel->GetLeftOffset() - 1, 0); - hs->Add(mHsbar, 1, wxALIGN_BOTTOM); - hs->Add(mVsbar->GetSize().GetWidth(), 0); - bs->Add(hs.release(), 0, wxEXPAND | wxALIGN_LEFT); - } + // Bottom scrollbar + hs->Add( mTrackPanel->GetLeftOffset() - 1, 0 ); + hs->Add( mHsbar, 1, wxALIGN_BOTTOM ); + hs->Add( mVsbar->GetSize().GetWidth(), 0 ); + bs->Add( hs, 0, wxEXPAND | wxALIGN_LEFT ); // Lay it out pPage->SetAutoLayout(true); diff --git a/src/ShuttleGui.cpp b/src/ShuttleGui.cpp index 77c6b1214..98f9a36cd 100644 --- a/src/ShuttleGui.cpp +++ b/src/ShuttleGui.cpp @@ -707,7 +707,7 @@ wxStaticBox * ShuttleGuiBase::StartStatic(const wxString &Str, int iProp) Str ); pBox->SetLabel( Str ); pBox->SetName(wxStripMenuCodes(Str)); - mpSubSizer = std::make_unique( + mpSubSizer = new wxStaticBoxSizer( pBox, wxVERTICAL ); miSizerProp = iProp; @@ -973,7 +973,7 @@ void ShuttleGuiBase::StartHorizontalLay( int PositionFlags, int iProp) if( mShuttleMode != eIsCreating ) return; miSizerProp=iProp; - mpSubSizer = std::make_unique( wxHORIZONTAL ); + mpSubSizer = new wxBoxSizer( wxHORIZONTAL ); UpdateSizersCore( false, PositionFlags | wxALL ); } @@ -989,7 +989,7 @@ void ShuttleGuiBase::StartVerticalLay(int iProp) if( mShuttleMode != eIsCreating ) return; miSizerProp=iProp; - mpSubSizer = std::make_unique( wxVERTICAL ); + mpSubSizer = new wxBoxSizer( wxVERTICAL ); UpdateSizers(); } @@ -1004,7 +1004,7 @@ void ShuttleGuiBase::StartMultiColumn(int nCols, int PositionFlags) { if( mShuttleMode != eIsCreating ) return; - mpSubSizer = std::make_unique( nCols ); + mpSubSizer = new wxFlexGridSizer( nCols ); UpdateSizersCore( false, PositionFlags | wxALL ); } @@ -1935,16 +1935,16 @@ void ShuttleGuiBase::UpdateSizersCore(bool bPrepend, int Flags) { // When adding sizers into sizers, don't add a border. // unless it's a static box sizer. - wxSizer *const pSubSizer = mpSubSizer.get(); - if (wxDynamicCast(pSubSizer, wxStaticBoxSizer)) + if( wxDynamicCast( mpSubSizer, wxStaticBoxSizer )) { - mpSizer->Add( mpSubSizer.release(), miSizerProp, Flags , miBorder); + mpSizer->Add( mpSubSizer,miSizerProp, Flags , miBorder); } else { - mpSizer->Add( mpSubSizer.release(), miSizerProp, Flags ,0);//miBorder); + mpSizer->Add( mpSubSizer,miSizerProp, Flags ,0);//miBorder); } - mpSizer = pSubSizer; + mpSizer = mpSubSizer; + mpSubSizer = NULL; PushSizer(); } mpLastWind = mpWind; @@ -2116,7 +2116,7 @@ AttachableScrollBar * ShuttleGui::AddAttachableScrollBar( long style ) return pAttachableScrollBar; } -std::unique_ptr CreateStdButtonSizer(wxWindow *parent, long buttons, wxWindow *extra) +wxSizer *CreateStdButtonSizer(wxWindow *parent, long buttons, wxWindow *extra) { wxASSERT(parent != NULL); // To justify safenew @@ -2136,7 +2136,7 @@ std::unique_ptr CreateStdButtonSizer(wxWindow *parent, long buttons, wx } wxButton *b = NULL; - auto bs = std::make_unique(); + wxStdDialogButtonSizer *bs = new wxStdDialogButtonSizer(); if( buttons & eOkButton ) { @@ -2226,8 +2226,9 @@ std::unique_ptr CreateStdButtonSizer(wxWindow *parent, long buttons, wx bs->Insert( lastLastSpacer + 1, b, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin ); } - std::unique_ptr s = std::make_unique( wxVERTICAL ); - s->Add( bs.release(), 1, wxEXPAND | wxALL, 7 ); + wxSizer * s; + s = new wxBoxSizer( wxVERTICAL ); + s->Add( bs, 1, wxEXPAND | wxALL, 7 ); s->Add( 0, 3 ); // a little extra space return s; diff --git a/src/ShuttleGui.h b/src/ShuttleGui.h index 95c1d06ba..af83a19e0 100644 --- a/src/ShuttleGui.h +++ b/src/ShuttleGui.h @@ -313,7 +313,7 @@ protected: // Proportion set by user rather than default. int miPropSetByUser; - std::unique_ptr mpSubSizer; + wxSizer * mpSubSizer; wxSizer * mpSizer; wxWindow * mpParent; wxWindow * mpWind; @@ -358,7 +358,7 @@ enum eCloseID = wxID_CANCEL }; -AUDACITY_DLL_API std::unique_ptr CreateStdButtonSizer( wxWindow *parent, +AUDACITY_DLL_API wxSizer *CreateStdButtonSizer( wxWindow *parent, long buttons = eOkButton | eCancelButton, wxWindow *extra = NULL ); diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index f39752e3b..774bd52f2 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -2887,179 +2887,175 @@ int EffectUIHost::ShowModal() bool EffectUIHost::Initialize() { + wxBoxSizer *vs = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *hs = new wxBoxSizer(wxHORIZONTAL); + EffectPanel *w = safenew EffectPanel(this); + + // Try to give the window a sensible default/minimum size + w->SetMinSize(wxSize(wxMax(600, mParent->GetSize().GetWidth() * 2 / 3), + mParent->GetSize().GetHeight() / 2)); + + mDisableTransport = !gAudioIO->IsAvailable(mProject); + mPlaying = gAudioIO->IsStreamActive(); // not exactly right, but will suffice + mCapturing = gAudioIO->IsStreamActive() && gAudioIO->GetNumCaptureChannels() > 0; + + if (!mClient->PopulateUI(w)) { - auto vs = std::make_unique(wxVERTICAL); - { - auto hs = std::make_unique(wxHORIZONTAL); + return false; + } - // Try to give the window a sensible default/minimum size - w->SetMinSize(wxSize(wxMax(600, mParent->GetSize().GetWidth() * 2 / 3), - mParent->GetSize().GetHeight() / 2)); + hs->Add(w, 1, wxEXPAND); + vs->Add(hs, 1, wxEXPAND); - mDisableTransport = !gAudioIO->IsAvailable(mProject); - mPlaying = gAudioIO->IsStreamActive(); // not exactly right, but will suffice - mCapturing = gAudioIO->IsStreamActive() && gAudioIO->GetNumCaptureChannels() > 0; + wxPanel *buttonPanel = safenew wxPanel(this, wxID_ANY); + wxPanel *const bar = safenew wxPanel(buttonPanel, wxID_ANY); - if (!mClient->PopulateUI(w)) - { - return false; - } + // This fools NVDA into not saying "Panel" when the dialog gets focus + bar->SetName(wxT("\a")); + bar->SetLabel(wxT("\a")); - hs->Add(w, 1, wxEXPAND); - vs->Add(hs.release(), 1, wxEXPAND); - } + wxBoxSizer *bs = new wxBoxSizer(wxHORIZONTAL); - wxPanel *buttonPanel = safenew wxPanel(this, wxID_ANY); - wxPanel *const bar = safenew wxPanel(buttonPanel, wxID_ANY); + mSupportsRealtime = mEffect->SupportsRealtime(); + mIsGUI = mClient->IsGraphicalUI(); + mIsBatch = mEffect->IsBatchProcessing(); - // This fools NVDA into not saying "Panel" when the dialog gets focus - bar->SetName(wxT("\a")); - bar->SetLabel(wxT("\a")); + wxBitmapButton *bb; - wxBoxSizer *bs = new wxBoxSizer(wxHORIZONTAL); - - mSupportsRealtime = mEffect->SupportsRealtime(); - mIsGUI = mClient->IsGraphicalUI(); - mIsBatch = mEffect->IsBatchProcessing(); - - wxBitmapButton *bb; - - int margin = 0; + int margin = 0; #if defined(__WXMAC__) - margin = 3; // I'm sure it's needed because of the order things are created... + margin = 3; // I'm sure it's needed because of the order things are created... #endif + if (!mIsGUI) + { + wxASSERT(bar); // To justify safenew + mMenuBtn = safenew wxButton(bar, kMenuID, _("&Manage")); + bs->Add(mMenuBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); + } + else + { + wxASSERT(bar); // To justify safenew + mMenuBtn = safenew wxBitmapButton(bar, kMenuID, CreateBitmap(effect_menu_xpm, true, false)); +#if defined(__WXMAC__) + mMenuBtn->SetName(_("&Manage")); +#else + mMenuBtn->SetLabel(_("&Manage")); +#endif + bs->Add(mMenuBtn); + } + mMenuBtn->SetToolTip(_("Manage presets and options")); + + bs->Add(5, 5); + + if (!mIsBatch) + { if (!mIsGUI) { - wxASSERT(bar); // To justify safenew - mMenuBtn = safenew wxButton(bar, kMenuID, _("&Manage")); - bs->Add(mMenuBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); + if (mSupportsRealtime) + { + wxASSERT(bar); // To justify safenew + mPlayToggleBtn = safenew wxButton(bar, kPlayID, _("Start &Playback")); + mPlayToggleBtn->SetToolTip(_("Start and stop playback")); + bs->Add(mPlayToggleBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); + } + else if (mEffect->GetType() != EffectTypeAnalyze) + { + wxASSERT(bar); // To justify safenew + mPlayToggleBtn = safenew wxButton(bar, kPlayID, _("&Preview")); + mPlayToggleBtn->SetToolTip(_("Preview effect")); + bs->Add(mPlayToggleBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); + } } else { + mPlayBM = CreateBitmap(effect_play_xpm, true, false); + mPlayDisabledBM = CreateBitmap(effect_play_disabled_xpm, true, false); + mStopBM = CreateBitmap(effect_stop_xpm, true, false); + mStopDisabledBM = CreateBitmap(effect_stop_disabled_xpm, true, false); wxASSERT(bar); // To justify safenew - mMenuBtn = safenew wxBitmapButton(bar, kMenuID, CreateBitmap(effect_menu_xpm, true, false)); + bb = safenew wxBitmapButton(bar, kPlayID, mPlayBM); + bb->SetBitmapDisabled(mPlayDisabledBM); + mPlayBtn = bb; + bs->Add(mPlayBtn); + if (!mSupportsRealtime) + { + mPlayBtn->SetToolTip(_("Preview effect")); #if defined(__WXMAC__) - mMenuBtn->SetName(_("&Manage")); + mPlayBtn->SetName(_("Preview effect")); #else - mMenuBtn->SetLabel(_("&Manage")); + mPlayBtn->SetLabel(_("&Preview effect")); #endif - bs->Add(mMenuBtn); + } } - mMenuBtn->SetToolTip(_("Manage presets and options")); - bs->Add(5, 5); - - if (!mIsBatch) + if (mSupportsRealtime) { if (!mIsGUI) { - if (mSupportsRealtime) - { - wxASSERT(bar); // To justify safenew - mPlayToggleBtn = safenew wxButton(bar, kPlayID, _("Start &Playback")); - mPlayToggleBtn->SetToolTip(_("Start and stop playback")); - bs->Add(mPlayToggleBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); - } - else if (mEffect->GetType() != EffectTypeAnalyze) - { - wxASSERT(bar); // To justify safenew - mPlayToggleBtn = safenew wxButton(bar, kPlayID, _("&Preview")); - mPlayToggleBtn->SetToolTip(_("Preview effect")); - bs->Add(mPlayToggleBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); - } + wxASSERT(bar); // To justify safenew + mRewindBtn = safenew wxButton(bar, kRewindID, _("Skip &Backward")); + bs->Add(mRewindBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); } else { - mPlayBM = CreateBitmap(effect_play_xpm, true, false); - mPlayDisabledBM = CreateBitmap(effect_play_disabled_xpm, true, false); - mStopBM = CreateBitmap(effect_stop_xpm, true, false); - mStopDisabledBM = CreateBitmap(effect_stop_disabled_xpm, true, false); wxASSERT(bar); // To justify safenew - bb = safenew wxBitmapButton(bar, kPlayID, mPlayBM); - bb->SetBitmapDisabled(mPlayDisabledBM); - mPlayBtn = bb; - bs->Add(mPlayBtn); - if (!mSupportsRealtime) - { - mPlayBtn->SetToolTip(_("Preview effect")); + bb = safenew wxBitmapButton(bar, kRewindID, CreateBitmap(effect_rewind_xpm, true, true)); + bb->SetBitmapDisabled(CreateBitmap(effect_rewind_disabled_xpm, true, true)); + mRewindBtn = bb; #if defined(__WXMAC__) - mPlayBtn->SetName(_("Preview effect")); + mRewindBtn->SetName(_("Skip &Backward")); #else - mPlayBtn->SetLabel(_("&Preview effect")); + mRewindBtn->SetLabel(_("Skip &Backward")); #endif - } + bs->Add(mRewindBtn); } + mRewindBtn->SetToolTip(_("Skip backward")); - if (mSupportsRealtime) + if (!mIsGUI) { - if (!mIsGUI) - { - wxASSERT(bar); // To justify safenew - mRewindBtn = safenew wxButton(bar, kRewindID, _("Skip &Backward")); - bs->Add(mRewindBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); - } - else - { - wxASSERT(bar); // To justify safenew - bb = safenew wxBitmapButton(bar, kRewindID, CreateBitmap(effect_rewind_xpm, true, true)); - bb->SetBitmapDisabled(CreateBitmap(effect_rewind_disabled_xpm, true, true)); - mRewindBtn = bb; -#if defined(__WXMAC__) - mRewindBtn->SetName(_("Skip &Backward")); -#else - mRewindBtn->SetLabel(_("Skip &Backward")); -#endif - bs->Add(mRewindBtn); - } - mRewindBtn->SetToolTip(_("Skip backward")); - - if (!mIsGUI) - { - wxASSERT(bar); // To justify safenew - mFFwdBtn = safenew wxButton(bar, kFFwdID, _("Skip &Forward")); - bs->Add(mFFwdBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); - } - else - { - wxASSERT(bar); // To justify safenew - bb = safenew wxBitmapButton(bar, kFFwdID, CreateBitmap(effect_ffwd_xpm, true, true)); - bb->SetBitmapDisabled(CreateBitmap(effect_ffwd_disabled_xpm, true, true)); - mFFwdBtn = bb; -#if defined(__WXMAC__) - mFFwdBtn->SetName(_("Skip &Foreward")); -#else - mFFwdBtn->SetLabel(_("Skip &Foreward")); -#endif - bs->Add(mFFwdBtn); - } - mFFwdBtn->SetToolTip(_("Skip forward")); - - bs->Add(5, 5); - - mEnableCb = safenew wxCheckBox(bar, kEnableID, _("&Enable")); - mEnableCb->SetValue(mEnabled); - mEnableCb->SetName(_("Enable")); - bs->Add(mEnableCb, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); + wxASSERT(bar); // To justify safenew + mFFwdBtn = safenew wxButton(bar, kFFwdID, _("Skip &Forward")); + bs->Add(mFFwdBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); } + else + { + wxASSERT(bar); // To justify safenew + bb = safenew wxBitmapButton(bar, kFFwdID, CreateBitmap(effect_ffwd_xpm, true, true)); + bb->SetBitmapDisabled(CreateBitmap(effect_ffwd_disabled_xpm, true, true)); + mFFwdBtn = bb; +#if defined(__WXMAC__) + mFFwdBtn->SetName(_("Skip &Foreward")); +#else + mFFwdBtn->SetLabel(_("Skip &Foreward")); +#endif + bs->Add(mFFwdBtn); + } + mFFwdBtn->SetToolTip(_("Skip forward")); + + bs->Add(5, 5); + + mEnableCb = safenew wxCheckBox(bar, kEnableID, _("&Enable")); + mEnableCb->SetValue(mEnabled); + mEnableCb->SetName(_("Enable")); + bs->Add(mEnableCb, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); } - - bar->SetSizerAndFit(bs); - - long buttons = eApplyButton + eCloseButton; - if (mEffect->mUIDebug) - { - buttons += eDebugButton; - } - - buttonPanel->SetSizer(CreateStdButtonSizer(buttonPanel, buttons, bar).release()); - vs->Add(buttonPanel, 0, wxEXPAND); - - SetSizer(vs.release()); } + bar->SetSizerAndFit(bs); + + long buttons = eApplyButton + eCloseButton; + if (mEffect->mUIDebug) + { + buttons += eDebugButton; + } + + buttonPanel->SetSizer(CreateStdButtonSizer(buttonPanel, buttons, bar)); + vs->Add(buttonPanel, 0, wxEXPAND); + + SetSizer(vs); Layout(); Fit(); Center(); diff --git a/src/effects/EffectRack.cpp b/src/effects/EffectRack.cpp index 01889ad95..2bdaf48b6 100644 --- a/src/effects/EffectRack.cpp +++ b/src/effects/EffectRack.cpp @@ -104,12 +104,10 @@ EffectRack::EffectRack() mRemovePushed = CreateBitmap(remove_16x16_xpm, false, true); mRemoveRaised = CreateBitmap(remove_16x16_xpm, true, true); - { - auto bs = std::make_unique(wxVERTICAL); - mPanel = safenew wxPanel(this, wxID_ANY); - bs->Add(mPanel, 1, wxEXPAND); - SetSizer(bs.release()); - } + wxBoxSizer *bs = new wxBoxSizer(wxVERTICAL); + mPanel = safenew wxPanel(this, wxID_ANY); + bs->Add(mPanel, 1, wxEXPAND); + SetSizer(bs); wxBoxSizer *hs = new wxBoxSizer(wxHORIZONTAL); wxASSERT(mPanel); // To justify safenew @@ -120,19 +118,17 @@ EffectRack::EffectRack() hs->AddStretchSpacer(); hs->Add(safenew wxToggleButton(mPanel, wxID_CLEAR, _("&Bypass")), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - { - auto bs = std::make_unique(wxVERTICAL); - bs->Add(hs, 0, wxEXPAND); - bs->Add(safenew wxStaticLine(mPanel, wxID_ANY), 0, wxEXPAND); + bs = new wxBoxSizer(wxVERTICAL); + bs->Add(hs, 0, wxEXPAND); + bs->Add(safenew wxStaticLine(mPanel, wxID_ANY), 0, wxEXPAND); - mMainSizer = new wxFlexGridSizer(7); - mMainSizer->AddGrowableCol(6); - mMainSizer->SetHGap(0); - mMainSizer->SetVGap(0); - bs->Add(mMainSizer, 1, wxEXPAND); + mMainSizer = new wxFlexGridSizer(7); + mMainSizer->AddGrowableCol(6); + mMainSizer->SetHGap(0); + mMainSizer->SetVGap(0); + bs->Add(mMainSizer, 1, wxEXPAND); - mPanel->SetSizer(bs.release()); - } + mPanel->SetSizer(bs); wxString oldPath = gPrefs->GetPath(); gPrefs->SetPath(wxT("/EffectsRack")); diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index e5448f6c8..0da16c3ba 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -2825,14 +2825,12 @@ void VSTEffect::BuildFancy() return; } - { - auto mainSizer = std::make_unique(wxVERTICAL); + wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); - mainSizer->Add(mControl, 0, wxALIGN_CENTER); + mainSizer->Add(mControl, 0, wxALIGN_CENTER); - mParent->SetMinSize(wxDefaultSize); - mParent->SetSizer(mainSizer.release()); - } + mParent->SetMinSize(wxDefaultSize); + mParent->SetSizer(mainSizer); NeedEditIdle(true); @@ -2843,126 +2841,119 @@ void VSTEffect::BuildFancy() void VSTEffect::BuildPlain() { + wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); wxASSERT(mParent); // To justify safenew wxScrolledWindow *const scroller = safenew wxScrolledWindow(mParent, - wxID_ANY, - wxDefaultPosition, - wxDefaultSize, - wxVSCROLL | wxTAB_TRAVERSAL); + wxID_ANY, + wxDefaultPosition, + wxDefaultSize, + wxVSCROLL | wxTAB_TRAVERSAL); - { - auto mainSizer = std::make_unique(wxVERTICAL); + // Try to give the window a sensible default/minimum size + scroller->SetMinSize(wxSize(wxMax(600, mParent->GetSize().GetWidth() * 2 / 3), + mParent->GetSize().GetHeight() / 2)); + scroller->SetScrollRate(0, 20); - // Try to give the window a sensible default/minimum size - scroller->SetMinSize(wxSize(wxMax(600, mParent->GetSize().GetWidth() * 2 / 3), - mParent->GetSize().GetHeight() / 2)); - scroller->SetScrollRate(0, 20); + // This fools NVDA into not saying "Panel" when the dialog gets focus + scroller->SetName(wxT("\a")); + scroller->SetLabel(wxT("\a")); - // This fools NVDA into not saying "Panel" when the dialog gets focus - scroller->SetName(wxT("\a")); - scroller->SetLabel(wxT("\a")); - - mainSizer->Add(scroller, 1, wxEXPAND | wxALL, 5); - mParent->SetSizer(mainSizer.release()); - } + mainSizer->Add(scroller, 1, wxEXPAND | wxALL, 5); + mParent->SetSizer(mainSizer); mNames = new wxStaticText *[mAEffect->numParams]; mSliders = new wxSlider *[mAEffect->numParams]; mDisplays = new wxStaticText *[mAEffect->numParams]; mLabels = new wxStaticText *[mAEffect->numParams]; + wxSizer *paramSizer = new wxStaticBoxSizer(wxVERTICAL, scroller, _("Effect Settings")); + + wxFlexGridSizer *gridSizer = new wxFlexGridSizer(4, 0, 0); + gridSizer->AddGrowableCol(1); + + // Add the duration control for generators + if (GetType() == EffectTypeGenerate) { - auto paramSizer = std::make_unique(wxVERTICAL, scroller, _("Effect Settings")); - - { - auto gridSizer = std::make_unique(4, 0, 0); - gridSizer->AddGrowableCol(1); - - // Add the duration control for generators - if (GetType() == EffectTypeGenerate) - { - wxControl *item = safenew wxStaticText(scroller, 0, _("Duration:")); - gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); - mDuration = safenew - NumericTextCtrl(NumericConverter::TIME, - scroller, - ID_Duration, - mHost->GetDurationFormat(), - mHost->GetDuration(), - mSampleRate, - wxDefaultPosition, - wxDefaultSize, - true); - mDuration->SetName(_("Duration")); - mDuration->EnableMenu(); - gridSizer->Add(mDuration, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - gridSizer->Add(1, 1, 0); - gridSizer->Add(1, 1, 0); - } - - // Find the longest parameter name. - int namew = 0; - int w; - int h; - for (int i = 0; i < mAEffect->numParams; i++) - { - wxString text = GetString(effGetParamName, i); - - if (text.Right(1) != wxT(':')) - { - text += wxT(':'); - } - - scroller->GetTextExtent(text, &w, &h); - if (w > namew) - { - namew = w; - } - } - - scroller->GetTextExtent(wxT("HHHHHHHH"), &w, &h); - - for (int i = 0; i < mAEffect->numParams; i++) - { - mNames[i] = safenew wxStaticText(scroller, - wxID_ANY, - wxEmptyString, - wxDefaultPosition, - wxSize(namew, -1), - wxALIGN_RIGHT | wxST_NO_AUTORESIZE); - gridSizer->Add(mNames[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); - - mSliders[i] = safenew wxSlider(scroller, - ID_Sliders + i, - 0, - 0, - 1000, - wxDefaultPosition, - wxSize(200, -1)); - gridSizer->Add(mSliders[i], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5); - - mDisplays[i] = safenew wxStaticText(scroller, - wxID_ANY, - wxEmptyString, - wxDefaultPosition, - wxSize(w, -1), - wxALIGN_RIGHT | wxST_NO_AUTORESIZE); - gridSizer->Add(mDisplays[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); - - mLabels[i] = safenew wxStaticText(scroller, - wxID_ANY, - wxEmptyString, - wxDefaultPosition, - wxSize(w, -1), - wxALIGN_LEFT | wxST_NO_AUTORESIZE); - gridSizer->Add(mLabels[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5); - } - - paramSizer->Add(gridSizer.release(), 1, wxEXPAND | wxALL, 5); - } - scroller->SetSizer(paramSizer.release()); + wxControl *item = safenew wxStaticText(scroller, 0, _("Duration:")); + gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + mDuration = safenew + NumericTextCtrl(NumericConverter::TIME, + scroller, + ID_Duration, + mHost->GetDurationFormat(), + mHost->GetDuration(), + mSampleRate, + wxDefaultPosition, + wxDefaultSize, + true); + mDuration->SetName(_("Duration")); + mDuration->EnableMenu(); + gridSizer->Add(mDuration, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); + gridSizer->Add(1, 1, 0); + gridSizer->Add(1, 1, 0); } + // Find the longest parameter name. + int namew = 0; + int w; + int h; + for (int i = 0; i < mAEffect->numParams; i++) + { + wxString text = GetString(effGetParamName, i); + + if (text.Right(1) != wxT(':')) + { + text += wxT(':'); + } + + scroller->GetTextExtent(text, &w, &h); + if (w > namew) + { + namew = w; + } + } + + scroller->GetTextExtent(wxT("HHHHHHHH"), &w, &h); + + for (int i = 0; i < mAEffect->numParams; i++) + { + mNames[i] = safenew wxStaticText(scroller, + wxID_ANY, + wxEmptyString, + wxDefaultPosition, + wxSize(namew, -1), + wxALIGN_RIGHT | wxST_NO_AUTORESIZE); + gridSizer->Add(mNames[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + + mSliders[i] = safenew wxSlider(scroller, + ID_Sliders + i, + 0, + 0, + 1000, + wxDefaultPosition, + wxSize(200, -1)); + gridSizer->Add(mSliders[i], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5); + + mDisplays[i] = safenew wxStaticText(scroller, + wxID_ANY, + wxEmptyString, + wxDefaultPosition, + wxSize(w, -1), + wxALIGN_RIGHT | wxST_NO_AUTORESIZE); + gridSizer->Add(mDisplays[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + + mLabels[i] = safenew wxStaticText(scroller, + wxID_ANY, + wxEmptyString, + wxDefaultPosition, + wxSize(w, -1), + wxALIGN_LEFT | wxST_NO_AUTORESIZE); + gridSizer->Add(mLabels[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5); + } + + paramSizer->Add(gridSizer, 1, wxEXPAND | wxALL, 5); + scroller->SetSizer(paramSizer); + RefreshParameters(); mSliders[0]->SetFocus(); diff --git a/src/effects/ladspa/LadspaEffect.cpp b/src/effects/ladspa/LadspaEffect.cpp index 10a7707c8..5ab9a4d6c 100644 --- a/src/effects/ladspa/LadspaEffect.cpp +++ b/src/effects/ladspa/LadspaEffect.cpp @@ -1164,293 +1164,285 @@ bool LadspaEffect::PopulateUI(wxWindow *parent) memset(mFields, 0, mData->PortCount * sizeof(wxTextCtrl *)); + wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); + wxASSERT(mParent); // To justify safenew wxScrolledWindow *const w = safenew wxScrolledWindow(mParent, - wxID_ANY, - wxDefaultPosition, - wxDefaultSize, - wxVSCROLL | wxTAB_TRAVERSAL); + wxID_ANY, + wxDefaultPosition, + wxDefaultSize, + wxVSCROLL | wxTAB_TRAVERSAL); + w->SetScrollRate(0, 20); + // This fools NVDA into not saying "Panel" when the dialog gets focus + w->SetName(wxT("\a")); + w->SetLabel(wxT("\a")); + + mainSizer->Add(w, 1, wxEXPAND); + mParent->SetSizer(mainSizer); + + wxSizer *marginSizer = new wxBoxSizer(wxVERTICAL); + + if (mNumInputControls) { - auto mainSizer = std::make_unique(wxVERTICAL); - wxASSERT(mParent); // To justify safenew - w->SetScrollRate(0, 20); + wxStaticBoxSizer *paramSizer = new wxStaticBoxSizer(wxVERTICAL, w, _("Effect Settings")); - // This fools NVDA into not saying "Panel" when the dialog gets focus - w->SetName(wxT("\a")); - w->SetLabel(wxT("\a")); + wxFlexGridSizer *gridSizer = new wxFlexGridSizer(5, 0, 0); + gridSizer->AddGrowableCol(3); - mainSizer->Add(w, 1, wxEXPAND); - mParent->SetSizer(mainSizer.release()); - } + wxControl *item; - wxSizer *marginSizer; - { - auto uMarginSizer = std::make_unique(wxVERTICAL); - marginSizer = uMarginSizer.get(); - - if (mNumInputControls) + // Add the duration control for generators + if (GetType() == EffectTypeGenerate) { - auto paramSizer = std::make_unique(wxVERTICAL, w, _("Effect Settings")); + item = safenew wxStaticText(w, 0, _("Duration:")); + gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + mDuration = safenew + NumericTextCtrl(NumericConverter::TIME, + w, + ID_Duration, + mHost->GetDurationFormat(), + mHost->GetDuration(), + mSampleRate, + wxDefaultPosition, + wxDefaultSize, + true); + mDuration->SetName(_("Duration")); + mDuration->EnableMenu(); + gridSizer->Add(mDuration, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); + gridSizer->Add(1, 1, 0); + gridSizer->Add(1, 1, 0); + gridSizer->Add(1, 1, 0); + } - auto gridSizer = std::make_unique(5, 0, 0); - gridSizer->AddGrowableCol(3); - - wxControl *item; - - // Add the duration control for generators - if (GetType() == EffectTypeGenerate) + for (unsigned long p = 0; p < mData->PortCount; p++) + { + LADSPA_PortDescriptor d = mData->PortDescriptors[p]; + if (LADSPA_IS_PORT_AUDIO(d) || LADSPA_IS_PORT_OUTPUT(d)) { - item = safenew wxStaticText(w, 0, _("Duration:")); - gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); - mDuration = safenew - NumericTextCtrl(NumericConverter::TIME, - w, - ID_Duration, - mHost->GetDurationFormat(), - mHost->GetDuration(), - mSampleRate, - wxDefaultPosition, - wxDefaultSize, - true); - mDuration->SetName(_("Duration")); - mDuration->EnableMenu(); - gridSizer->Add(mDuration, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - gridSizer->Add(1, 1, 0); - gridSizer->Add(1, 1, 0); - gridSizer->Add(1, 1, 0); + continue; } - for (unsigned long p = 0; p < mData->PortCount; p++) + wxString labelText = LAT1CTOWX(mData->PortNames[p]); + item = safenew wxStaticText(w, 0, labelText + wxT(":")); + gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + + wxString fieldText; + LADSPA_PortRangeHint hint = mData->PortRangeHints[p]; + + if (LADSPA_IS_HINT_TOGGLED(hint.HintDescriptor)) { - LADSPA_PortDescriptor d = mData->PortDescriptors[p]; - if (LADSPA_IS_PORT_AUDIO(d) || LADSPA_IS_PORT_OUTPUT(d)) - { - continue; - } + mToggles[p] = safenew wxCheckBox(w, ID_Toggles + p, wxT("")); + mToggles[p]->SetName(labelText); + mToggles[p]->SetValue(mInputControls[p] > 0); + gridSizer->Add(mToggles[p], 0, wxALL, 5); - wxString labelText = LAT1CTOWX(mData->PortNames[p]); - item = safenew wxStaticText(w, 0, labelText + wxT(":")); - gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + gridSizer->Add(1, 1, 0); + gridSizer->Add(1, 1, 0); + gridSizer->Add(1, 1, 0); + continue; + } - wxString fieldText; - LADSPA_PortRangeHint hint = mData->PortRangeHints[p]; + wxString bound; + float lower = -FLT_MAX; + float upper = FLT_MAX; + bool haslo = false; + bool hashi = false; + bool forceint = false; - if (LADSPA_IS_HINT_TOGGLED(hint.HintDescriptor)) - { - mToggles[p] = safenew wxCheckBox(w, ID_Toggles + p, wxT("")); - mToggles[p]->SetName(labelText); - mToggles[p]->SetValue(mInputControls[p] > 0); - gridSizer->Add(mToggles[p], 0, wxALL, 5); + if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor)) + { + lower = hint.LowerBound; + haslo = true; + } - gridSizer->Add(1, 1, 0); - gridSizer->Add(1, 1, 0); - gridSizer->Add(1, 1, 0); - continue; - } + if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor)) + { + upper = hint.UpperBound; + hashi = true; + } - wxString bound; - float lower = -FLT_MAX; - float upper = FLT_MAX; - bool haslo = false; - bool hashi = false; - bool forceint = false; + if (LADSPA_IS_HINT_SAMPLE_RATE(hint.HintDescriptor)) + { + lower *= mSampleRate; + upper *= mSampleRate; + forceint = true; + } - if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor)) - { - lower = hint.LowerBound; - haslo = true; - } + // Limit to the UI precision + lower = ceilf(lower * 1000000.0) / 1000000.0; + upper = floorf(upper * 1000000.0) / 1000000.0; + mInputControls[p] = roundf(mInputControls[p] * 1000000.0) / 1000000.0; - if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor)) - { - upper = hint.UpperBound; - hashi = true; - } + if (haslo && mInputControls[p] < lower) + { + mInputControls[p] = lower; + } - if (LADSPA_IS_HINT_SAMPLE_RATE(hint.HintDescriptor)) - { - lower *= mSampleRate; - upper *= mSampleRate; - forceint = true; - } + if (hashi && mInputControls[p] > upper) + { + mInputControls[p] = lower; + } - // Limit to the UI precision - lower = ceilf(lower * 1000000.0) / 1000000.0; - upper = floorf(upper * 1000000.0) / 1000000.0; - mInputControls[p] = roundf(mInputControls[p] * 1000000.0) / 1000000.0; - - if (haslo && mInputControls[p] < lower) - { - mInputControls[p] = lower; - } - - if (hashi && mInputControls[p] > upper) - { - mInputControls[p] = lower; - } - - // Don't specify a value at creation time. This prevents unwanted events - // being sent to the OnTextCtrl() handler before the associated slider - // has been created. - mFields[p] = safenew wxTextCtrl(w, ID_Texts + p); - mFields[p]->SetName(labelText); - gridSizer->Add(mFields[p], 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - - wxString str; - if (haslo) - { - if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint) - { - str.Printf(wxT("%d"), (int)(lower + 0.5)); - } - else - { - str = Internat::ToDisplayString(lower); - } - item = safenew wxStaticText(w, 0, str); - gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); - } - else - { - gridSizer->Add(1, 1, 0); - } - - mSliders[p] = safenew wxSlider(w, ID_Sliders + p, - 0, 0, 1000, - wxDefaultPosition, - wxSize(200, -1)); - mSliders[p]->SetName(labelText); - gridSizer->Add(mSliders[p], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5); - - if (hashi) - { - if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint) - { - str.Printf(wxT("%d"), (int)(upper + 0.5)); - } - else - { - str = Internat::ToDisplayString(upper); - } - item = safenew wxStaticText(w, 0, str); - gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5); - } - else - { - gridSizer->Add(1, 1, 0); - } + // Don't specify a value at creation time. This prevents unwanted events + // being sent to the OnTextCtrl() handler before the associated slider + // has been created. + mFields[p] = safenew wxTextCtrl(w, ID_Texts + p); + mFields[p]->SetName(labelText); + gridSizer->Add(mFields[p], 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); + wxString str; + if (haslo) + { if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint) { - fieldText.Printf(wxT("%d"), (int)(mInputControls[p] + 0.5)); - - IntegerValidator vld(&mInputControls[p]); - vld.SetRange(haslo ? lower : INT_MIN, - hashi ? upper : INT_MAX); - mFields[p]->SetValidator(vld); + str.Printf(wxT("%d"), (int)(lower + 0.5)); } else { - fieldText = Internat::ToDisplayString(mInputControls[p]); - - // > 12 decimal places can cause rounding errors in display. - FloatingPointValidator vld(6, &mInputControls[p]); - vld.SetRange(lower, upper); - - // Set number of decimal places - if (upper - lower < 10.0) - { - vld.SetStyle(NUM_VAL_THREE_TRAILING_ZEROES); - } - else if (upper - lower < 100.0) - { - vld.SetStyle(NUM_VAL_TWO_TRAILING_ZEROES); - } - else - { - vld.SetStyle(NUM_VAL_ONE_TRAILING_ZERO); - } - - mFields[p]->SetValidator(vld); + str = Internat::ToDisplayString(lower); } - - // Set the textctrl value. This will trigger an event so OnTextCtrl() - // can update the slider. - mFields[p]->SetValue(fieldText); - } - - paramSizer->Add(gridSizer.release(), 0, wxEXPAND | wxALL, 5); - marginSizer->Add(paramSizer.release(), 0, wxEXPAND | wxALL, 5); - } - - if (mNumOutputControls > 0) - { - auto paramSizer = std::make_unique(wxVERTICAL, w, _("Effect Output")); - - auto gridSizer = std::make_unique(2, 0, 0); - gridSizer->AddGrowableCol(1); - - wxControl *item; - - for (unsigned long p = 0; p < mData->PortCount; p++) - { - LADSPA_PortDescriptor d = mData->PortDescriptors[p]; - if (LADSPA_IS_PORT_AUDIO(d) || LADSPA_IS_PORT_INPUT(d)) - { - continue; - } - - wxString labelText = LAT1CTOWX(mData->PortNames[p]); - item = safenew wxStaticText(w, 0, labelText + wxT(":")); + item = safenew wxStaticText(w, 0, str); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); - - LADSPA_PortRangeHint hint = mData->PortRangeHints[p]; - - wxString bound; - float lower = 0.0; - float upper = 1.0; - bool haslo = false; - bool hashi = false; - bool forceint = false; - - if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor)) - { - lower = hint.LowerBound; - haslo = true; - } - - if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor)) - { - upper = hint.UpperBound; - hashi = true; - } - - if (LADSPA_IS_HINT_SAMPLE_RATE(hint.HintDescriptor)) - { - lower *= mSampleRate; - upper *= mSampleRate; - forceint = true; - } - - // Limit to the UI precision - lower = ceilf(lower * 1000000.0) / 1000000.0; - upper = floorf(upper * 1000000.0) / 1000000.0; - mInputControls[p] = roundf(mInputControls[p] * 1000000.0) / 1000000.0; - - mMeters[p] = safenew LadspaEffectMeter(w, mOutputControls[p], lower, upper); - mMeters[p]->SetName(labelText); - gridSizer->Add(mMeters[p], 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 5); + } + else + { + gridSizer->Add(1, 1, 0); } - paramSizer->Add(gridSizer.release(), 0, wxEXPAND | wxALL, 5); - marginSizer->Add(paramSizer.release(), 0, wxEXPAND | wxALL, 5); + mSliders[p] = safenew wxSlider(w, ID_Sliders + p, + 0, 0, 1000, + wxDefaultPosition, + wxSize(200, -1)); + mSliders[p]->SetName(labelText); + gridSizer->Add(mSliders[p], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5); + + if (hashi) + { + if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint) + { + str.Printf(wxT("%d"), (int)(upper + 0.5)); + } + else + { + str = Internat::ToDisplayString(upper); + } + item = safenew wxStaticText(w, 0, str); + gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5); + } + else + { + gridSizer->Add(1, 1, 0); + } - RefreshControls(true); + if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint) + { + fieldText.Printf(wxT("%d"), (int)(mInputControls[p] + 0.5)); + + IntegerValidator vld(&mInputControls[p]); + vld.SetRange(haslo ? lower : INT_MIN, + hashi ? upper : INT_MAX); + mFields[p]->SetValidator(vld); + } + else + { + fieldText = Internat::ToDisplayString(mInputControls[p]); + + // > 12 decimal places can cause rounding errors in display. + FloatingPointValidator vld(6, &mInputControls[p]); + vld.SetRange(lower, upper); + + // Set number of decimal places + if (upper - lower < 10.0) + { + vld.SetStyle(NUM_VAL_THREE_TRAILING_ZEROES); + } + else if (upper - lower < 100.0) + { + vld.SetStyle(NUM_VAL_TWO_TRAILING_ZEROES); + } + else + { + vld.SetStyle(NUM_VAL_ONE_TRAILING_ZERO); + } + + mFields[p]->SetValidator(vld); + } + + // Set the textctrl value. This will trigger an event so OnTextCtrl() + // can update the slider. + mFields[p]->SetValue(fieldText); } - w->SetSizer(uMarginSizer.release()); + paramSizer->Add(gridSizer, 0, wxEXPAND | wxALL, 5); + marginSizer->Add(paramSizer, 0, wxEXPAND | wxALL, 5); } + if (mNumOutputControls > 0 ) + { + wxSizer *paramSizer = new wxStaticBoxSizer(wxVERTICAL, w, _("Effect Output")); + + wxFlexGridSizer *gridSizer = new wxFlexGridSizer(2, 0, 0); + gridSizer->AddGrowableCol(1); + + wxControl *item; + + for (unsigned long p = 0; p < mData->PortCount; p++) + { + LADSPA_PortDescriptor d = mData->PortDescriptors[p]; + if (LADSPA_IS_PORT_AUDIO(d) || LADSPA_IS_PORT_INPUT(d)) + { + continue; + } + + wxString labelText = LAT1CTOWX(mData->PortNames[p]); + item = safenew wxStaticText(w, 0, labelText + wxT(":")); + gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); + + LADSPA_PortRangeHint hint = mData->PortRangeHints[p]; + + wxString bound; + float lower = 0.0; + float upper = 1.0; + bool haslo = false; + bool hashi = false; + bool forceint = false; + + if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor)) + { + lower = hint.LowerBound; + haslo = true; + } + + if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor)) + { + upper = hint.UpperBound; + hashi = true; + } + + if (LADSPA_IS_HINT_SAMPLE_RATE(hint.HintDescriptor)) + { + lower *= mSampleRate; + upper *= mSampleRate; + forceint = true; + } + + // Limit to the UI precision + lower = ceilf(lower * 1000000.0) / 1000000.0; + upper = floorf(upper * 1000000.0) / 1000000.0; + mInputControls[p] = roundf(mInputControls[p] * 1000000.0) / 1000000.0; + + mMeters[p] = safenew LadspaEffectMeter(w, mOutputControls[p], lower, upper); + mMeters[p]->SetName(labelText); + gridSizer->Add(mMeters[p], 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 5); + } + + paramSizer->Add(gridSizer, 0, wxEXPAND | wxALL, 5); + marginSizer->Add(paramSizer, 0, wxEXPAND | wxALL, 5); + + RefreshControls(true); + } + + w->SetSizer(marginSizer); w->Layout(); // Try to give the window a sensible default/minimum size diff --git a/src/effects/lv2/LV2Effect.cpp b/src/effects/lv2/LV2Effect.cpp index 0c229dc77..ede34c53b 100644 --- a/src/effects/lv2/LV2Effect.cpp +++ b/src/effects/lv2/LV2Effect.cpp @@ -1465,11 +1465,11 @@ bool LV2Effect::BuildFancy() wxSizerItem *si = NULL; if (vs) { - auto hs = std::make_unique(wxHORIZONTAL); + wxBoxSizer *hs = new wxBoxSizer(wxHORIZONTAL); if (hs) { si = hs->Add(mContainer, 1, wxCENTER | wxEXPAND); - vs->Add(hs.release(), 0, wxCENTER); + vs->Add(hs, 0, wxCENTER); } } @@ -1578,291 +1578,282 @@ bool LV2Effect::BuildPlain() mSliders = new wxSlider *[ctrlcnt]; mFields = new wxTextCtrl *[ctrlcnt]; - wxSizer *innerSizer; - + wxSizer *outerSizer = new wxBoxSizer(wxVERTICAL); wxASSERT(mParent); // To justify safenew wxScrolledWindow *const w = safenew wxScrolledWindow(mParent, - wxID_ANY, - wxDefaultPosition, - wxDefaultSize, - wxVSCROLL | wxTAB_TRAVERSAL); + wxID_ANY, + wxDefaultPosition, + wxDefaultSize, + wxVSCROLL | wxTAB_TRAVERSAL); + w->SetScrollRate(0, 20); + // This fools NVDA into not saying "Panel" when the dialog gets focus + w->SetName(wxT("\a")); + w->SetLabel(wxT("\a")); + + outerSizer->Add(w, 1, wxEXPAND); + + wxSizer *innerSizer = new wxBoxSizer(wxVERTICAL); + + if (GetType() == EffectTypeGenerate) { - auto outerSizer = std::make_unique(wxVERTICAL); - w->SetScrollRate(0, 20); + // Add the length control + wxSizer *groupSizer = new wxStaticBoxSizer(wxVERTICAL, w, _("Generator")); - // This fools NVDA into not saying "Panel" when the dialog gets focus - w->SetName(wxT("\a")); - w->SetLabel(wxT("\a")); + wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL); + + wxWindow *item = safenew wxStaticText(w, 0, _("&Duration:")); + sizer->Add(item, 0, wxALIGN_CENTER | wxALL, 5); + mDuration = safenew + NumericTextCtrl(NumericConverter::TIME, + w, + ID_Duration, + mHost->GetDurationFormat(), + mHost->GetDuration(), + mSampleRate, + wxDefaultPosition, + wxDefaultSize, + true); + mDuration->SetName(_("Duration")); + mDuration->EnableMenu(); + sizer->Add(mDuration, 0, wxALIGN_CENTER | wxALL, 5); - outerSizer->Add(w, 1, wxEXPAND); + groupSizer->Add(sizer, 0, wxALIGN_CENTER | wxALL, 5); + innerSizer->Add(groupSizer, 0, wxEXPAND | wxALL, 5); + } + mGroups.Sort(); + + for (size_t i = 0, cnt = mGroups.GetCount(); i < cnt; i++) + { + wxString label = mGroups[i]; + if (label.IsEmpty()) { - auto uInnerSizer = std::make_unique(wxVERTICAL); - innerSizer = uInnerSizer.get(); + label = _("Effect Settings"); + } + wxSizer *groupSizer = new wxStaticBoxSizer(wxVERTICAL, w, label); - if (GetType() == EffectTypeGenerate) + wxFlexGridSizer *gridSizer = new wxFlexGridSizer(numCols, 5, 5); + gridSizer->AddGrowableCol(3); + + const wxArrayInt & params = mGroupMap[mGroups[i]]; + for (size_t pi = 0, cnt = params.GetCount(); pi < cnt; pi++) + { + int p = params[pi]; + LV2Port & ctrl = mControls[p]; + wxString labelText = ctrl.mName; + if (!ctrl.mUnits.IsEmpty()) { - // Add the length control - auto groupSizer = std::make_unique(wxVERTICAL, w, _("Generator")); - - auto sizer = std::make_unique(wxHORIZONTAL); - - wxWindow *item = safenew wxStaticText(w, 0, _("&Duration:")); - sizer->Add(item, 0, wxALIGN_CENTER | wxALL, 5); - mDuration = safenew - NumericTextCtrl(NumericConverter::TIME, - w, - ID_Duration, - mHost->GetDurationFormat(), - mHost->GetDuration(), - mSampleRate, - wxDefaultPosition, - wxDefaultSize, - true); - mDuration->SetName(_("Duration")); - mDuration->EnableMenu(); - sizer->Add(mDuration, 0, wxALIGN_CENTER | wxALL, 5); - - groupSizer->Add(sizer.release(), 0, wxALIGN_CENTER | wxALL, 5); - innerSizer->Add(groupSizer.release(), 0, wxEXPAND | wxALL, 5); + labelText += wxT(" (") + ctrl.mUnits + wxT(")"); } - mGroups.Sort(); - - for (size_t i = 0, cnt = mGroups.GetCount(); i < cnt; i++) + if (ctrl.mTrigger) { - wxString label = mGroups[i]; - if (label.IsEmpty()) + gridSizer->Add(1, 1, 0); + + wxASSERT(w); // To justify safenew + wxButton *b = safenew wxButton(w, ID_Triggers + p, labelText); + gridSizer->Add(b, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); + + gridSizer->Add(1, 1, 0); + gridSizer->Add(1, 1, 0); + gridSizer->Add(1, 1, 0); + continue; + } + + wxWindow *item = safenew wxStaticText(w, wxID_ANY, labelText + wxT(":"), + wxDefaultPosition, wxDefaultSize, + wxALIGN_RIGHT); + gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT); + + if (ctrl.mToggle) + { + wxCheckBox *c = safenew wxCheckBox(w, ID_Toggles + p, wxT("")); + c->SetName(labelText); + c->SetValue(ctrl.mVal > 0); + gridSizer->Add(c, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); + + gridSizer->Add(1, 1, 0); + gridSizer->Add(1, 1, 0); + gridSizer->Add(1, 1, 0); + } + else if (ctrl.mEnumeration) // Check before integer + { + int s; + for (s = (int) ctrl.mScaleValues.GetCount() - 1; s >= 0; s--) { - label = _("Effect Settings"); + if (ctrl.mVal >= ctrl.mScaleValues[s]) + { + break; + } } - auto groupSizer = std::make_unique(wxVERTICAL, w, label); - auto gridSizer = std::make_unique(numCols, 5, 5); - gridSizer->AddGrowableCol(3); - - const wxArrayInt & params = mGroupMap[mGroups[i]]; - for (size_t pi = 0, cnt = params.GetCount(); pi < cnt; pi++) + if (s < 0) { - int p = params[pi]; - LV2Port & ctrl = mControls[p]; - wxString labelText = ctrl.mName; - if (!ctrl.mUnits.IsEmpty()) + s = 0; + } + + wxChoice *c = safenew wxChoice(w, ID_Choices + p); + c->SetName(labelText); + c->Append(ctrl.mScaleLabels); + c->SetSelection(s); + gridSizer->Add(c, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); + + gridSizer->Add(1, 1, 0); + gridSizer->Add(1, 1, 0); + gridSizer->Add(1, 1, 0); + } + else if (!ctrl.mInput) + { + gridSizer->Add(1, 1, 0); + gridSizer->Add(1, 1, 0); + LV2EffectMeter *m = safenew LV2EffectMeter(w, ctrl); + gridSizer->Add(m, 0, wxALIGN_CENTER_VERTICAL | wxEXPAND); + gridSizer->Add(1, 1, 0); + } + else + { + mFields[p] = safenew wxTextCtrl(w, ID_Texts + p, wxT("")); + mFields[p]->SetName(labelText); + gridSizer->Add(mFields[p], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); + + float rate = ctrl.mSampleRate ? mSampleRate : 1.0; + + ctrl.mVal = ctrl.mDef; + ctrl.mLo = ctrl.mMin * rate; + ctrl.mHi = ctrl.mMax * rate; + ctrl.mTmp = ctrl.mDef * rate; + + if (ctrl.mInteger) + { + IntegerValidator vld(&ctrl.mTmp); + vld.SetRange(ctrl.mLo, ctrl.mHi); + mFields[p]->SetValidator(vld); + } + else + { + FloatingPointValidator vld(6, &ctrl.mTmp); + vld.SetRange(ctrl.mLo, ctrl.mHi); + + // Set number of decimal places + float range = ctrl.mHi - ctrl.mLo; + int style = range < 10 ? NUM_VAL_THREE_TRAILING_ZEROES : + range < 100 ? NUM_VAL_TWO_TRAILING_ZEROES : + NUM_VAL_ONE_TRAILING_ZERO; + vld.SetStyle(style); + + mFields[p]->SetValidator(vld); + } + + if (ctrl.mHasLo) + { + wxString str; + if (ctrl.mInteger || ctrl.mSampleRate) { - labelText += wxT(" (") + ctrl.mUnits + wxT(")"); + str.Printf(wxT("%d"), lrintf(ctrl.mLo)); } - - if (ctrl.mTrigger) + else { - gridSizer->Add(1, 1, 0); - - wxASSERT(w); // To justify safenew - wxButton *b = safenew wxButton(w, ID_Triggers + p, labelText); - gridSizer->Add(b, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); - - gridSizer->Add(1, 1, 0); - gridSizer->Add(1, 1, 0); - gridSizer->Add(1, 1, 0); - continue; + str = Internat::ToDisplayString(ctrl.mLo); } - - wxWindow *item = safenew wxStaticText(w, wxID_ANY, labelText + wxT(":"), - wxDefaultPosition, wxDefaultSize, - wxALIGN_RIGHT); + item = safenew wxStaticText(w, wxID_ANY, str); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT); + } + else + { + gridSizer->Add(1, 1, 0); + } - if (ctrl.mToggle) + mSliders[p] = safenew wxSlider(w, ID_Sliders + p, + 0, 0, 1000, + wxDefaultPosition, + wxSize(150, -1)); + mSliders[p]->SetName(labelText); + gridSizer->Add(mSliders[p], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND); + + if (ctrl.mHasHi) + { + wxString str; + if (ctrl.mInteger || ctrl.mSampleRate) { - wxCheckBox *c = safenew wxCheckBox(w, ID_Toggles + p, wxT("")); - c->SetName(labelText); - c->SetValue(ctrl.mVal > 0); - gridSizer->Add(c, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); - - gridSizer->Add(1, 1, 0); - gridSizer->Add(1, 1, 0); - gridSizer->Add(1, 1, 0); - } - else if (ctrl.mEnumeration) // Check before integer - { - int s; - for (s = (int)ctrl.mScaleValues.GetCount() - 1; s >= 0; s--) - { - if (ctrl.mVal >= ctrl.mScaleValues[s]) - { - break; - } - } - - if (s < 0) - { - s = 0; - } - - wxChoice *c = safenew wxChoice(w, ID_Choices + p); - c->SetName(labelText); - c->Append(ctrl.mScaleLabels); - c->SetSelection(s); - gridSizer->Add(c, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); - - gridSizer->Add(1, 1, 0); - gridSizer->Add(1, 1, 0); - gridSizer->Add(1, 1, 0); - } - else if (!ctrl.mInput) - { - gridSizer->Add(1, 1, 0); - gridSizer->Add(1, 1, 0); - LV2EffectMeter *m = safenew LV2EffectMeter(w, ctrl); - gridSizer->Add(m, 0, wxALIGN_CENTER_VERTICAL | wxEXPAND); - gridSizer->Add(1, 1, 0); + str.Printf(wxT("%d"), lrintf(ctrl.mHi)); } else { - mFields[p] = safenew wxTextCtrl(w, ID_Texts + p, wxT("")); - mFields[p]->SetName(labelText); - gridSizer->Add(mFields[p], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); - - float rate = ctrl.mSampleRate ? mSampleRate : 1.0; - - ctrl.mVal = ctrl.mDef; - ctrl.mLo = ctrl.mMin * rate; - ctrl.mHi = ctrl.mMax * rate; - ctrl.mTmp = ctrl.mDef * rate; - - if (ctrl.mInteger) - { - IntegerValidator vld(&ctrl.mTmp); - vld.SetRange(ctrl.mLo, ctrl.mHi); - mFields[p]->SetValidator(vld); - } - else - { - FloatingPointValidator vld(6, &ctrl.mTmp); - vld.SetRange(ctrl.mLo, ctrl.mHi); - - // Set number of decimal places - float range = ctrl.mHi - ctrl.mLo; - int style = range < 10 ? NUM_VAL_THREE_TRAILING_ZEROES : - range < 100 ? NUM_VAL_TWO_TRAILING_ZEROES : - NUM_VAL_ONE_TRAILING_ZERO; - vld.SetStyle(style); - - mFields[p]->SetValidator(vld); - } - - if (ctrl.mHasLo) - { - wxString str; - if (ctrl.mInteger || ctrl.mSampleRate) - { - str.Printf(wxT("%d"), lrintf(ctrl.mLo)); - } - else - { - str = Internat::ToDisplayString(ctrl.mLo); - } - item = safenew wxStaticText(w, wxID_ANY, str); - gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT); - } - else - { - gridSizer->Add(1, 1, 0); - } - - mSliders[p] = safenew wxSlider(w, ID_Sliders + p, - 0, 0, 1000, - wxDefaultPosition, - wxSize(150, -1)); - mSliders[p]->SetName(labelText); - gridSizer->Add(mSliders[p], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND); - - if (ctrl.mHasHi) - { - wxString str; - if (ctrl.mInteger || ctrl.mSampleRate) - { - str.Printf(wxT("%d"), lrintf(ctrl.mHi)); - } - else - { - str = Internat::ToDisplayString(ctrl.mHi); - } - item = safenew wxStaticText(w, wxID_ANY, str); - gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); - } - else - { - gridSizer->Add(1, 1, 0); - } + str = Internat::ToDisplayString(ctrl.mHi); } + item = safenew wxStaticText(w, wxID_ANY, str); + gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); } - - groupSizer->Add(gridSizer.release(), 1, wxEXPAND | wxALL, 5); - innerSizer->Add(groupSizer.release(), 0, wxEXPAND | wxALL, 5); - } - - innerSizer->Layout(); - - // Calculate the maximum width of all columns (bypass Generator sizer) - wxArrayInt widths; - widths.Add(0, numCols); - - size_t cnt = innerSizer->GetChildren().GetCount(); - for (size_t i = (GetType() == EffectTypeGenerate); i < cnt; i++) - { - wxSizer *groupSizer = innerSizer->GetItem(i)->GetSizer(); - wxFlexGridSizer *gridSizer = (wxFlexGridSizer *)groupSizer->GetItem((size_t)0)->GetSizer(); - - size_t items = gridSizer->GetChildren().GetCount(); - int cols = gridSizer->GetCols(); - - for (size_t j = 0; j < items; j++) + else { - wxSizerItem *item = gridSizer->GetItem(j); - widths[j % cols] = wxMax(widths[j % cols], item->GetSize().GetWidth()); + gridSizer->Add(1, 1, 0); } } - - // Set each column in all of the groups to the same width. - for (size_t i = (GetType() == EffectTypeGenerate); i < cnt; i++) - { - wxSizer *groupSizer = innerSizer->GetItem(i)->GetSizer(); - wxFlexGridSizer *gridSizer = (wxFlexGridSizer *)groupSizer->GetItem((size_t)0)->GetSizer(); - - size_t items = gridSizer->GetChildren().GetCount(); - int cols = gridSizer->GetCols(); - - for (size_t j = 0; j < items; j++) - { - wxSizerItem *item = gridSizer->GetItem(j); - - int flags = item->GetFlag(); - if (flags & wxEXPAND) - { - continue; - } - - if (flags & wxALIGN_RIGHT) - { - flags = (flags & ~wxALL) | wxLEFT; - } - else - { - flags = (flags & ~wxALL) | wxRIGHT; - } - item->SetFlag(flags); - - item->SetBorder(widths[j % cols] - item->GetMinSize().GetWidth()); - } - } - - w->SetSizer(uInnerSizer.release()); } - mParent->SetSizer(outerSizer.release()); + groupSizer->Add(gridSizer, 1, wxEXPAND | wxALL, 5); + innerSizer->Add(groupSizer, 0, wxEXPAND | wxALL, 5); } + innerSizer->Layout(); + + // Calculate the maximum width of all columns (bypass Generator sizer) + wxArrayInt widths; + widths.Add(0, numCols); + + size_t cnt = innerSizer->GetChildren().GetCount(); + for (size_t i = (GetType() == EffectTypeGenerate); i < cnt; i++) + { + wxSizer *groupSizer = innerSizer->GetItem(i)->GetSizer(); + wxFlexGridSizer *gridSizer = (wxFlexGridSizer *)groupSizer->GetItem((size_t) 0)->GetSizer(); + + size_t items = gridSizer->GetChildren().GetCount(); + int cols = gridSizer->GetCols(); + + for (size_t j = 0; j < items; j++) + { + wxSizerItem *item = gridSizer->GetItem(j); + widths[j % cols] = wxMax(widths[j % cols], item->GetSize().GetWidth()); + } + } + + // Set each column in all of the groups to the same width. + for (size_t i = (GetType() == EffectTypeGenerate); i < cnt; i++) + { + wxSizer *groupSizer = innerSizer->GetItem(i)->GetSizer(); + wxFlexGridSizer *gridSizer = (wxFlexGridSizer *)groupSizer->GetItem((size_t) 0)->GetSizer(); + + size_t items = gridSizer->GetChildren().GetCount(); + int cols = gridSizer->GetCols(); + + for (size_t j = 0; j < items; j++) + { + wxSizerItem *item = gridSizer->GetItem(j); + + int flags = item->GetFlag(); + if (flags & wxEXPAND) + { + continue; + } + + if (flags & wxALIGN_RIGHT) + { + flags = (flags & ~wxALL) | wxLEFT; + } + else + { + flags = (flags & ~wxALL) | wxRIGHT; + } + item->SetFlag(flags); + + item->SetBorder(widths[j % cols] - item->GetMinSize().GetWidth()); + } + } + + w->SetSizer(innerSizer); + mParent->SetSizer(outerSizer); + // Try to give the window a sensible default/minimum size wxSize sz1 = innerSizer->GetMinSize(); wxSize sz2 = mParent->GetMinSize(); diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index 45c074f15..95fe3c21d 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -2242,39 +2242,33 @@ NyquistOutputDialog::NyquistOutputDialog(wxWindow * parent, wxWindowID id, { SetName(GetTitle()); - wxBoxSizer *mainSizer; - { - auto uMainSizer = std::make_unique(wxVERTICAL); - mainSizer = uMainSizer.get(); - wxButton *button; - wxControl *item; + wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *hSizer; + wxButton *button; + wxControl *item; - item = safenew wxStaticText(this, -1, prompt); - item->SetName(prompt); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) - mainSizer->Add(item, 0, wxALIGN_LEFT | wxLEFT | wxTOP | wxRIGHT, 10); + item = safenew wxStaticText(this, -1, prompt); + item->SetName(prompt); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) + mainSizer->Add(item, 0, wxALIGN_LEFT | wxLEFT | wxTOP | wxRIGHT, 10); - // TODO use ShowInfoDialog() instead. - // Beware this dialog MUST work with screen readers. - item = safenew wxTextCtrl(this, -1, message, - wxDefaultPosition, wxSize(400, 200), - wxTE_MULTILINE | wxTE_READONLY); - mainSizer->Add(item, 0, wxALIGN_LEFT | wxALL, 10); + // TODO use ShowInfoDialog() instead. + // Beware this dialog MUST work with screen readers. + item = safenew wxTextCtrl(this, -1, message, + wxDefaultPosition, wxSize(400, 200), + wxTE_MULTILINE | wxTE_READONLY); + mainSizer->Add(item, 0, wxALIGN_LEFT | wxALL, 10); - { - auto hSizer = std::make_unique(wxHORIZONTAL); + hSizer = new wxBoxSizer(wxHORIZONTAL); - /* i18n-hint: In most languages OK is to be translated as OK. It appears on a button.*/ - button = safenew wxButton(this, wxID_OK, _("OK")); - button->SetDefault(); - hSizer->Add(button, 0, wxALIGN_CENTRE | wxALL, 5); + /* i18n-hint: In most languages OK is to be translated as OK. It appears on a button.*/ + button = safenew wxButton(this, wxID_OK, _("OK")); + button->SetDefault(); + hSizer->Add(button, 0, wxALIGN_CENTRE | wxALL, 5); - mainSizer->Add(hSizer.release(), 0, wxALIGN_CENTRE | wxLEFT | wxBOTTOM | wxRIGHT, 5); - } - - SetAutoLayout(true); - SetSizer(uMainSizer.release()); - } + mainSizer->Add(hSizer, 0, wxALIGN_CENTRE | wxLEFT | wxBOTTOM | wxRIGHT, 5); + SetAutoLayout(true); + SetSizer(mainSizer); mainSizer->Fit(this); mainSizer->SetSizeHints(this); } diff --git a/src/export/Export.cpp b/src/export/Export.cpp index a95c06541..445445831 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -1212,41 +1212,34 @@ ExportMixerDialog::ExportMixerDialog( TrackList *tracks, bool selectedOnly, if (maxNumChannels > 32) maxNumChannels = 32; - mMixerSpec = new MixerSpec(numTracks, maxNumChannels); - - wxBoxSizer *vertSizer; - { - auto uVertSizer = std::make_unique(wxVERTICAL); - vertSizer = uVertSizer.get(); + mMixerSpec = new MixerSpec( numTracks, maxNumChannels ); - wxWindow *mixerPanel = safenew ExportMixerPanel(mMixerSpec, mTrackNames, this, - ID_MIXERPANEL, wxDefaultPosition, wxSize(400, -1)); - mixerPanel->SetName(_("Mixer Panel")); - vertSizer->Add(mixerPanel, 1, wxEXPAND | wxALIGN_CENTRE | wxALL, 5); + wxBoxSizer *vertSizer = new wxBoxSizer( wxVERTICAL ); - { - auto horSizer = std::make_unique(wxHORIZONTAL); + wxWindow *mixerPanel = safenew ExportMixerPanel( mMixerSpec, mTrackNames, this, + ID_MIXERPANEL, wxDefaultPosition, wxSize( 400, -1 ) ); + mixerPanel->SetName(_("Mixer Panel")); + vertSizer->Add( mixerPanel, 1, wxEXPAND | wxALIGN_CENTRE | wxALL, 5 ); - wxString label; - label.Printf(_("Output Channels: %2d"), mMixerSpec->GetNumChannels()); - mChannelsText = safenew wxStaticText(this, -1, label); - horSizer->Add(mChannelsText, 0, wxALIGN_LEFT | wxALL, 5); + wxBoxSizer *horSizer = new wxBoxSizer( wxHORIZONTAL ); - wxSlider *channels = safenew wxSlider(this, ID_SLIDER_CHANNEL, - mMixerSpec->GetNumChannels(), 1, mMixerSpec->GetMaxNumChannels(), - wxDefaultPosition, wxSize(300, -1)); - channels->SetName(label); - horSizer->Add(channels, 0, wxEXPAND | wxALL, 5); + wxString label; + label.Printf( _( "Output Channels: %2d" ), mMixerSpec->GetNumChannels() ); + mChannelsText = safenew wxStaticText(this, -1, label); + horSizer->Add( mChannelsText, 0, wxALIGN_LEFT | wxALL, 5 ); - vertSizer->Add(horSizer.release(), 0, wxALIGN_CENTRE | wxALL, 5); - } + wxSlider *channels = safenew wxSlider( this, ID_SLIDER_CHANNEL, + mMixerSpec->GetNumChannels(), 1, mMixerSpec->GetMaxNumChannels(), + wxDefaultPosition, wxSize( 300, -1 ) ); + channels->SetName(label); + horSizer->Add( channels, 0, wxEXPAND | wxALL, 5 ); - vertSizer->Add(CreateStdButtonSizer(this, eCancelButton | eOkButton).release(), 0, wxEXPAND); + vertSizer->Add( horSizer, 0, wxALIGN_CENTRE | wxALL, 5 ); - SetAutoLayout(true); - SetSizer(uVertSizer.release()); - } + vertSizer->Add( CreateStdButtonSizer(this, eCancelButton|eOkButton), 0, wxEXPAND ); + SetAutoLayout( true ); + SetSizer( vertSizer ); vertSizer->Fit( this ); vertSizer->SetSizeHints( this ); diff --git a/src/import/Import.cpp b/src/import/Import.cpp index f11bc0a00..2e8eac3bf 100644 --- a/src/import/Import.cpp +++ b/src/import/Import.cpp @@ -751,24 +751,19 @@ wxDialog( parent, id, title, position, size, style | wxRESIZE_BORDER ) mFile = _mFile; scount = mFile->GetStreamCount(); for (wxInt32 i = 0; i < scount; i++) - mFile->SetStreamUsage(i, FALSE); + mFile->SetStreamUsage(i,FALSE); - wxBoxSizer *vertSizer; - { - auto uVertSizer = std::make_unique(wxVERTICAL); - vertSizer = uVertSizer.get(); + wxBoxSizer *vertSizer = new wxBoxSizer( wxVERTICAL ); + wxArrayString *choices = mFile->GetStreamInfo(); + StreamList = safenew wxListBox(this, -1, wxDefaultPosition, wxDefaultSize, *choices , wxLB_EXTENDED | wxLB_ALWAYS_SB); - wxArrayString *choices = mFile->GetStreamInfo(); - StreamList = safenew wxListBox(this, -1, wxDefaultPosition, wxDefaultSize, *choices, wxLB_EXTENDED | wxLB_ALWAYS_SB); + vertSizer->Add( StreamList, 1, wxEXPAND | wxALIGN_LEFT | wxALL, 5 ); - vertSizer->Add(StreamList, 1, wxEXPAND | wxALIGN_LEFT | wxALL, 5); + vertSizer->Add( CreateStdButtonSizer(this, eCancelButton|eOkButton), 0, wxEXPAND ); - vertSizer->Add(CreateStdButtonSizer(this, eCancelButton | eOkButton).release(), 0, wxEXPAND); + SetAutoLayout( true ); - SetAutoLayout(true); - - SetSizer(uVertSizer.release()); - } + SetSizer( vertSizer ); vertSizer->Fit( this ); diff --git a/src/import/ImportPCM.cpp b/src/import/ImportPCM.cpp index 90b5e3957..1a8b4b220 100644 --- a/src/import/ImportPCM.cpp +++ b/src/import/ImportPCM.cpp @@ -240,8 +240,8 @@ static wxString AskCopyOrEdit() wxDialog dialog(NULL, -1, wxString(_("Warning"))); dialog.SetName(dialog.GetTitle()); - wxBoxSizer *vbox; - dialog.SetSizer(vbox = safenew wxBoxSizer(wxVERTICAL)); + wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); + dialog.SetSizer(vbox); wxStaticText *message = safenew wxStaticText(&dialog, -1, wxString::Format(_("\ When importing uncompressed audio files you can either copy them \ @@ -261,27 +261,19 @@ How do you want to import the current file(s)?"), oldCopyPref == wxT("copy") ? _ wxStaticBox *box = safenew wxStaticBox(&dialog, -1, _("Choose an import method")); box->SetName(box->GetLabel()); + wxStaticBoxSizer *boxsizer = new wxStaticBoxSizer(box, wxVERTICAL); - wxRadioButton *aliasRadio; - wxRadioButton *copyRadio; - wxCheckBox *dontAskNextTimeBox; + wxRadioButton *copyRadio = safenew wxRadioButton(&dialog, -1, _("Make a © of the files before editing (safer)"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); + boxsizer->Add(copyRadio, 0, wxALL); + copyRadio->SetName(wxStripMenuCodes(copyRadio->GetLabel())); - { - auto boxsizer = std::make_unique(box, wxVERTICAL); - - copyRadio = safenew wxRadioButton(&dialog, -1, _("Make a © of the files before editing (safer)"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); - boxsizer->Add(copyRadio, 0, wxALL); - copyRadio->SetName(wxStripMenuCodes(copyRadio->GetLabel())); - - aliasRadio = safenew wxRadioButton(&dialog, -1, _("Read the files &directly from the original (faster)")); - boxsizer->Add(aliasRadio, 0, wxALL); - aliasRadio->SetName(wxStripMenuCodes(aliasRadio->GetLabel())); - - dontAskNextTimeBox = safenew wxCheckBox(&dialog, -1, _("Don't &warn again and always use my choice above")); - boxsizer->Add(dontAskNextTimeBox, 0, wxALL); - vbox->Add(boxsizer.release(), 0, wxALL, 10); - } + wxRadioButton *aliasRadio = safenew wxRadioButton(&dialog, -1, _("Read the files &directly from the original (faster)")); + boxsizer->Add(aliasRadio, 0, wxALL); + aliasRadio->SetName(wxStripMenuCodes(aliasRadio->GetLabel())); + wxCheckBox *dontAskNextTimeBox = safenew wxCheckBox(&dialog, -1, _("Don't &warn again and always use my choice above")); + boxsizer->Add(dontAskNextTimeBox, 0, wxALL); + vbox->Add(boxsizer, 0, wxALL, 10); dontAskNextTimeBox->SetName(wxStripMenuCodes(dontAskNextTimeBox->GetLabel())); diff --git a/src/toolbars/ControlToolBar.cpp b/src/toolbars/ControlToolBar.cpp index 35a268fa1..39fe8fdd3 100644 --- a/src/toolbars/ControlToolBar.cpp +++ b/src/toolbars/ControlToolBar.cpp @@ -282,8 +282,8 @@ void ControlToolBar::ArrangeButtons() Detach( mSizer ); delete mSizer; } - - Add((mSizer = safenew wxBoxSizer(wxHORIZONTAL)), 1, wxEXPAND); + mSizer = new wxBoxSizer( wxHORIZONTAL ); + Add( mSizer, 1, wxEXPAND ); // Start with a little extra space mSizer->Add( 5, 55 ); diff --git a/src/toolbars/MeterToolBar.cpp b/src/toolbars/MeterToolBar.cpp index 492fe4ee0..a4e05a63b 100644 --- a/src/toolbars/MeterToolBar.cpp +++ b/src/toolbars/MeterToolBar.cpp @@ -113,7 +113,8 @@ void MeterToolBar::ReCreateButtons() void MeterToolBar::Populate() { - Add((mSizer = safenew wxGridBagSizer()), 1, wxEXPAND); + mSizer = new wxGridBagSizer(); + Add( mSizer, 1, wxEXPAND ); if( mWhichMeters & kWithRecordMeter ){ //JKC: Record on left, playback on right. Left to right flow diff --git a/src/toolbars/SelectionBar.cpp b/src/toolbars/SelectionBar.cpp index 90a3eb596..3cde5b5cb 100644 --- a/src/toolbars/SelectionBar.cpp +++ b/src/toolbars/SelectionBar.cpp @@ -114,6 +114,7 @@ void SelectionBar::Populate() SetFont(wxFont(9, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); wxFlexGridSizer *mainSizer; + wxBoxSizer *hSizer; /* we don't actually need a control yet, but we want to use it's methods * to do some look-ups, so we'll have to create one. We can't make the @@ -121,7 +122,8 @@ void SelectionBar::Populate() * runtime */ wxString formatName = mListener ? mListener->AS_GetSelectionFormat() : wxString(wxEmptyString); - Add((mainSizer = safenew wxFlexGridSizer(7, 1, 1)), 0, wxALIGN_CENTER_VERTICAL); + mainSizer = new wxFlexGridSizer(7, 1, 1); + Add(mainSizer, 0, wxALIGN_CENTER_VERTICAL); // // Top row (mostly labels) @@ -148,20 +150,19 @@ void SelectionBar::Populate() bool showSelectionLength = false; gPrefs->Read(wxT("/ShowSelectionLength"), &showSelectionLength); - { - auto hSizer = std::make_unique(wxHORIZONTAL); - mRightEndButton = safenew wxRadioButton(this, OnEndRadioID, _("End"), - wxDefaultPosition, wxDefaultSize, - wxRB_GROUP); - mRightEndButton->SetName(_("End")); - mRightEndButton->SetValue(!showSelectionLength); - hSizer->Add(mRightEndButton, - 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5); - mRightLengthButton = safenew wxRadioButton(this, OnLengthRadioID, _("Length")); - mRightLengthButton->SetName(_("Length")); - mRightLengthButton->SetValue(showSelectionLength); - hSizer->Add(mRightLengthButton, - 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); + hSizer = new wxBoxSizer(wxHORIZONTAL); + mRightEndButton = safenew wxRadioButton(this, OnEndRadioID, _("End"), + wxDefaultPosition, wxDefaultSize, + wxRB_GROUP); + mRightEndButton->SetName(_("End")); + mRightEndButton->SetValue(!showSelectionLength); + hSizer->Add(mRightEndButton, + 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5); + mRightLengthButton = safenew wxRadioButton(this, OnLengthRadioID, _("Length")); + mRightLengthButton->SetName(_("Length")); + mRightLengthButton->SetValue(showSelectionLength); + hSizer->Add(mRightLengthButton, + 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); #if defined(__WXMSW__) // Refer to Microsoft KB article 261192 for an explanation as // to why this is needed. We've only experienced it under Win2k @@ -169,13 +170,12 @@ void SelectionBar::Populate() // in for all versions. wxRadioButton* dummyButton = safenew wxRadioButton(this, wxID_ANY, _("hidden"), - wxDefaultPosition, wxDefaultSize, - wxRB_GROUP); + wxDefaultPosition, wxDefaultSize, + wxRB_GROUP); dummyButton->Disable(); dummyButton->Hide(); #endif - mainSizer->Add(hSizer.release(), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); - } + mainSizer->Add(hSizer, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); mainSizer->Add(5, 1); diff --git a/src/toolbars/SpectralSelectionBar.cpp b/src/toolbars/SpectralSelectionBar.cpp index b96915446..6babe45b3 100644 --- a/src/toolbars/SpectralSelectionBar.cpp +++ b/src/toolbars/SpectralSelectionBar.cpp @@ -123,8 +123,8 @@ void SpectralSelectionBar::Populate() ? mListener->SSBL_GetBandwidthSelectionFormatName() : wxString(wxEmptyString); - wxFlexGridSizer *mainSizer; - Add((mainSizer = safenew wxFlexGridSizer(1, 1, 1)), 0, wxALIGN_CENTER_VERTICAL); + wxFlexGridSizer *mainSizer = new wxFlexGridSizer(1, 1, 1); + Add(mainSizer, 0, wxALIGN_CENTER_VERTICAL); // // Top row, choice box @@ -144,44 +144,42 @@ void SpectralSelectionBar::Populate() // Bottom row, split into two columns, each with one control // - { - auto subSizer = std::make_unique(wxHORIZONTAL); + wxBoxSizer *subSizer = new wxBoxSizer(wxHORIZONTAL); - mCenterCtrl = safenew NumericTextCtrl( - NumericConverter::FREQUENCY, this, OnCenterID, frequencyFormatName, 0.0); - mCenterCtrl->SetInvalidValue(SelectedRegion::UndefinedFrequency); - mCenterCtrl->SetName(_("Center Frequency:")); - mCenterCtrl->EnableMenu(); - subSizer->Add(mCenterCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); + mCenterCtrl = safenew NumericTextCtrl( + NumericConverter::FREQUENCY, this, OnCenterID, frequencyFormatName, 0.0); + mCenterCtrl->SetInvalidValue(SelectedRegion::UndefinedFrequency); + mCenterCtrl->SetName(_("Center Frequency:")); + mCenterCtrl->EnableMenu(); + subSizer->Add(mCenterCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); - mWidthCtrl = safenew NumericTextCtrl( - NumericConverter::BANDWIDTH, this, OnWidthID, bandwidthFormatName, 0.0); - mWidthCtrl->SetInvalidValue(-1.0); - mWidthCtrl->SetName(wxString(_("Bandwidth:"))); - mWidthCtrl->EnableMenu(); - subSizer->Add(mWidthCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); + mWidthCtrl = safenew NumericTextCtrl( + NumericConverter::BANDWIDTH, this, OnWidthID, bandwidthFormatName, 0.0); + mWidthCtrl->SetInvalidValue(-1.0); + mWidthCtrl->SetName(wxString(_("Bandwidth:"))); + mWidthCtrl->EnableMenu(); + subSizer->Add(mWidthCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); - mLowCtrl = safenew NumericTextCtrl( - NumericConverter::FREQUENCY, this, OnLowID, frequencyFormatName, 0.0); - mLowCtrl->SetInvalidValue(SelectedRegion::UndefinedFrequency); - mLowCtrl->SetName(_("Low Frequency:")); - mLowCtrl->EnableMenu(); - subSizer->Add(mLowCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); + mLowCtrl = safenew NumericTextCtrl( + NumericConverter::FREQUENCY, this, OnLowID, frequencyFormatName, 0.0); + mLowCtrl->SetInvalidValue(SelectedRegion::UndefinedFrequency); + mLowCtrl->SetName(_("Low Frequency:")); + mLowCtrl->EnableMenu(); + subSizer->Add(mLowCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); - mHighCtrl = safenew NumericTextCtrl( - NumericConverter::FREQUENCY, this, OnHighID, frequencyFormatName, 0.0); - mHighCtrl->SetInvalidValue(SelectedRegion::UndefinedFrequency); - mHighCtrl->SetName(wxString(_("High Frequency:"))); - mHighCtrl->EnableMenu(); - subSizer->Add(mHighCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); + mHighCtrl = safenew NumericTextCtrl( + NumericConverter::FREQUENCY, this, OnHighID, frequencyFormatName, 0.0); + mHighCtrl->SetInvalidValue(SelectedRegion::UndefinedFrequency); + mHighCtrl->SetName(wxString(_("High Frequency:"))); + mHighCtrl->EnableMenu(); + subSizer->Add(mHighCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); - mCenterCtrl->Show(mbCenterAndWidth); - mWidthCtrl->Show(mbCenterAndWidth); - mLowCtrl->Show(!mbCenterAndWidth); - mHighCtrl->Show(!mbCenterAndWidth); + mCenterCtrl->Show(mbCenterAndWidth); + mWidthCtrl->Show(mbCenterAndWidth); + mLowCtrl->Show(!mbCenterAndWidth); + mHighCtrl->Show(!mbCenterAndWidth); - mainSizer->Add(subSizer.release(), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); - } + mainSizer->Add(subSizer, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); mainSizer->Layout(); diff --git a/src/toolbars/ToolBar.cpp b/src/toolbars/ToolBar.cpp index 3843b0030..2c51be010 100644 --- a/src/toolbars/ToolBar.cpp +++ b/src/toolbars/ToolBar.cpp @@ -430,7 +430,8 @@ void ToolBar::ReCreateButtons() ms->Add( mGrabber, 0, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP | wxRIGHT, 1 ); // Use a box sizer for laying out controls - ms->Add((mHSizer = safenew wxBoxSizer(wxHORIZONTAL)), 1, wxEXPAND); + mHSizer = new wxBoxSizer( wxHORIZONTAL ); + ms->Add( mHSizer, 1, wxEXPAND ); // (Re)Establish dock state SetDocked( GetDock(), false ); diff --git a/src/toolbars/ToolManager.cpp b/src/toolbars/ToolManager.cpp index a8cf5d5a6..4c46dfdb4 100644 --- a/src/toolbars/ToolManager.cpp +++ b/src/toolbars/ToolManager.cpp @@ -118,28 +118,25 @@ class ToolFrame:public wxFrame mBar = bar; // Transfer the bar to the ferry - bar->Reparent(this); + bar->Reparent( this ); + // We use a sizer to maintain proper spacing + wxBoxSizer *s = new wxBoxSizer( wxHORIZONTAL ); + + // Add the bar to the sizer + s->Add( bar, 1, wxEXPAND | wxALL, border ); + + // Add space for the resize grabber + if( bar->IsResizable() ) { - // We use a sizer to maintain proper spacing - auto s = std::make_unique(wxHORIZONTAL); - - // Add the bar to the sizer - s->Add(bar, 1, wxEXPAND | wxALL, border); - - // Add space for the resize grabber - if (bar->IsResizable()) - { - s->Add(sizerW, 1); - width += sizerW; - } - - SetSize(width + 2, bar->GetDockedSize().y + 2); - - // Attach the sizer and resize the window to fit - SetSizer(s.release()); + s->Add( sizerW, 1 ); + width += sizerW; } + SetSize( width + 2, bar->GetDockedSize().y + 2 ); + + // Attach the sizer and resize the window to fit + SetSizer( s ); Layout(); // Inform toolbar of change diff --git a/src/toolbars/ToolsToolBar.cpp b/src/toolbars/ToolsToolBar.cpp index fe44ab0e0..8e0dcd4ff 100644 --- a/src/toolbars/ToolsToolBar.cpp +++ b/src/toolbars/ToolsToolBar.cpp @@ -186,7 +186,8 @@ AButton * ToolsToolBar::MakeTool( teBmps eTool, void ToolsToolBar::Populate() { MakeButtonBackgroundsSmall(); - Add(mToolSizer = safenew wxGridSizer(2, 3, 1, 1)); + mToolSizer = new wxGridSizer( 2, 3, 1, 1 ); + Add( mToolSizer ); /* Tools */ mTool[ selectTool ] = MakeTool( bmpIBeam, selectTool, _("Selection Tool") ); diff --git a/src/widgets/ErrorDialog.cpp b/src/widgets/ErrorDialog.cpp index f055b8b7a..8bf5ef118 100644 --- a/src/widgets/ErrorDialog.cpp +++ b/src/widgets/ErrorDialog.cpp @@ -109,33 +109,28 @@ ErrorDialog::ErrorDialog( #if 0 // Original non ShuttleGui based code. // Layout did not look good on Windows. - wxBoxSizer mainSizer; - { - auto uMainSizer = std::make_unique(wxVERTICAL); - mainSizer = uMainSizer.get(); - wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL); - wxBoxSizer *hSizer = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *hSizer = new wxBoxSizer(wxHORIZONTAL); - wxStaticText *statText = safenew wxStaticText(this, -1, message); - mainSizer->Add(statText, 0, wxALIGN_LEFT|wxALL, 5); + wxStaticText *statText = safenew wxStaticText(this, -1, message); + mainSizer->Add(statText, 0, wxALIGN_LEFT|wxALL, 5); - wxButton *help = safenew wxButton(this, wxID_HELP, _("Help")); - hSizer->Add(help, 0, wxALIGN_LEFT|wxALL, 5); + wxButton *help = safenew wxButton(this, wxID_HELP, _("Help")); + hSizer->Add(help, 0, wxALIGN_LEFT|wxALL, 5); - wxButton *ok = safenew wxButton(this, wxID_OK, _("OK")); - ok->SetDefault(); - ok->SetFocus(); - hSizer->Add(ok, 0, wxALIGN_RIGHT|wxALL, 5); + wxButton *ok = safenew wxButton(this, wxID_OK, _("OK")); + ok->SetDefault(); + ok->SetFocus(); + hSizer->Add(ok, 0, wxALIGN_RIGHT|wxALL, 5); - vSizer->Add(hSizer, 0, wxALIGN_CENTER|wxALL, 5); + vSizer->Add(hSizer, 0, wxALIGN_CENTER|wxALL, 5); - mainSizer->Add(vSizer, 0, wxALL, 15 ); - - SetAutoLayout(true); - SetSizer(uMainSizer.release()); - } + mainSizer->Add(vSizer, 0, wxALL, 15 ); + SetAutoLayout(true); + SetSizer(mainSizer); mainSizer->Fit(this); mainSizer->SetSizeHints(this); #endif diff --git a/src/widgets/MultiDialog.cpp b/src/widgets/MultiDialog.cpp index 1548266eb..a1dc12e53 100644 --- a/src/widgets/MultiDialog.cpp +++ b/src/widgets/MultiDialog.cpp @@ -68,78 +68,65 @@ MultiDialog::MultiDialog(wxWindow * pParent, { SetName(GetTitle()); - wxString *buttonLabels; - wxBoxSizer *mainSizer; - { - auto uMainSizer = std::make_unique(wxVERTICAL); - mainSizer = uMainSizer.get(); + wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *iconAndTextSizer = new wxBoxSizer( wxHORIZONTAL ); - { - auto vSizer = std::make_unique(wxVERTICAL); - { - auto iconAndTextSizer = std::make_unique(wxHORIZONTAL); + wxBitmap bitmap = wxArtProvider::GetIcon(wxART_WARNING, + wxART_MESSAGE_BOX); + wxStaticBitmap *icon = safenew wxStaticBitmap(this, -1, bitmap); + iconAndTextSizer->Add( icon, 0, wxCENTER ); - wxBitmap bitmap = wxArtProvider::GetIcon(wxART_WARNING, - wxART_MESSAGE_BOX); - wxStaticBitmap *icon = safenew wxStaticBitmap(this, -1, bitmap); - iconAndTextSizer->Add(icon, 0, wxCENTER); + wxStaticText *statText = safenew wxStaticText(this, -1, message); + statText->SetName(message); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) + iconAndTextSizer->Add(statText, 1, wxCENTER|wxLEFT,15 ); - wxStaticText *statText = safenew wxStaticText(this, -1, message); - statText->SetName(message); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) - iconAndTextSizer->Add(statText, 1, wxCENTER | wxLEFT, 15); - - vSizer->Add(iconAndTextSizer.release(), 0, wxALIGN_LEFT | wxALL, 5); - } + vSizer->Add(iconAndTextSizer, 0, wxALIGN_LEFT|wxALL, 5); - int count = 0; - while (buttons[count])count++; - buttonLabels = new wxString[count]; + int count=0; + while(buttons[count])count++; + wxString *buttonLabels = new wxString[count]; - count = 0; - while (buttons[count]){ - buttonLabels[count] = buttons[count]; - count++; - } - - mRadioBox = safenew wxRadioBox(this, -1, - boxMsg, - wxDefaultPosition, wxDefaultSize, - count, buttonLabels, - 1, wxRA_SPECIFY_COLS); - mRadioBox->SetName(boxMsg); - mRadioBox->SetSelection(0); - vSizer->Add(mRadioBox, 1, wxEXPAND | wxALIGN_CENTER | wxALL, 5); - - - { - auto buttonSizer = std::make_unique(wxHORIZONTAL); - - wxButton* pButton; - if (log) - { - pButton = safenew wxButton(this, ID_SHOW_LOG_BUTTON, _("Show Log for Details")); - buttonSizer->Add(pButton, 0, wxALIGN_LEFT | wxALL, 5); - pButton->SetDefault(); // Encourage user to look at files. - - buttonSizer->AddSpacer(40); - } - - pButton = safenew wxButton(this, wxID_OK, _("OK")); - if (!log) - pButton->SetDefault(); - buttonSizer->Add(pButton, 0, wxALIGN_RIGHT | wxALL, 5); - - vSizer->Add(buttonSizer.release(), 0, wxALIGN_CENTER | wxALL, 5); - } - - mainSizer->Add(vSizer.release(), 0, wxALL, 5); - } - - SetAutoLayout(true); - SetSizer(uMainSizer.release()); + count=0; + while(buttons[count]){ + buttonLabels[count] = buttons[count]; + count++; } + mRadioBox = safenew wxRadioBox(this,-1, + boxMsg, + wxDefaultPosition, wxDefaultSize, + count, buttonLabels, + 1, wxRA_SPECIFY_COLS); + mRadioBox->SetName(boxMsg); + mRadioBox->SetSelection(0); + vSizer->Add(mRadioBox, 1, wxEXPAND | wxALIGN_CENTER | wxALL, 5); + + + wxBoxSizer* buttonSizer = new wxBoxSizer(wxHORIZONTAL); + + wxButton* pButton; + if(log) + { + pButton = safenew wxButton(this, ID_SHOW_LOG_BUTTON, _("Show Log for Details")); + buttonSizer->Add(pButton, 0, wxALIGN_LEFT | wxALL, 5); + pButton->SetDefault(); // Encourage user to look at files. + + buttonSizer->AddSpacer(40); + } + + pButton = safenew wxButton(this, wxID_OK, _("OK")); + if(!log) + pButton->SetDefault(); + buttonSizer->Add(pButton, 0, wxALIGN_RIGHT | wxALL, 5); + + vSizer->Add(buttonSizer, 0, wxALIGN_CENTER | wxALL, 5); + + + mainSizer->Add(vSizer, 0, wxALL, 5); + SetAutoLayout(true); + SetSizer(mainSizer); mainSizer->Fit(this); mainSizer->SetSizeHints(this); delete[] buttonLabels; diff --git a/src/widgets/ProgressDialog.cpp b/src/widgets/ProgressDialog.cpp index d6b4d5c32..c3ee2e154 100644 --- a/src/widgets/ProgressDialog.cpp +++ b/src/widgets/ProgressDialog.cpp @@ -1087,111 +1087,101 @@ bool ProgressDialog::Create(const wxString & title, } SetName(GetTitle()); + wxBoxSizer *v; wxWindow *w; wxSize ds; SetExtraStyle(GetExtraStyle() | wxWS_EX_TRANSIENT); - wxFlexGridSizer *g; - wxBoxSizer *h; + v = new wxBoxSizer(wxVERTICAL); + + mMessage = safenew wxStaticText(this, + wxID_ANY, + message, + wxDefaultPosition, + wxDefaultSize, + wxALIGN_LEFT); + mMessage->SetName(message); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) + v->Add(mMessage, 1, wxEXPAND | wxALL, 10); + ds.y += mMessage->GetSize().y + 20; + + // + // + // + mGauge = safenew wxGauge(this, + wxID_ANY, + 1000, + wxDefaultPosition, + wxDefaultSize, + wxGA_HORIZONTAL); + v->Add(mGauge, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 10); + ds.y += mGauge->GetSize().y + 10; + + // + // + // + wxFlexGridSizer *g = new wxFlexGridSizer(2, 2, 10, 10); + + w = safenew wxStaticText(this, + wxID_ANY, + _("Elapsed Time:"), + wxDefaultPosition, + wxDefaultSize, + wxALIGN_RIGHT); + w->SetName(w->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) + g->Add(w, 0, wxALIGN_RIGHT); + + mElapsed = safenew wxStaticText(this, + wxID_ANY, + wxT("00:00:00"), + wxDefaultPosition, + wxDefaultSize, + wxALIGN_LEFT); + mElapsed->SetName(mElapsed->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) + g->Add(mElapsed, 0, wxALIGN_LEFT); + ds.y += mElapsed->GetSize().y + 10; + + // + // + // + w = safenew wxStaticText(this, + wxID_ANY, + _("Remaining Time:"), + wxDefaultPosition, + wxDefaultSize, + wxALIGN_RIGHT); + w->SetName(w->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) + g->Add(w, 0, wxALIGN_RIGHT); + + mRemaining = safenew wxStaticText(this, + wxID_ANY, + wxT("00:00:00"), + wxDefaultPosition, + wxDefaultSize, + wxALIGN_LEFT); + mRemaining->SetName(mRemaining->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) + g->Add(mRemaining, 0, wxALIGN_LEFT); + + v->Add(g, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT | wxBOTTOM, 10); + ds.y += mRemaining->GetSize().y + 10; + + wxBoxSizer *h = new wxBoxSizer(wxHORIZONTAL); + + if (!(flags & pdlgHideStopButton)) { - auto v = std::make_unique(wxVERTICAL); - - mMessage = safenew wxStaticText(this, - wxID_ANY, - message, - wxDefaultPosition, - wxDefaultSize, - wxALIGN_LEFT); - mMessage->SetName(message); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) - v->Add(mMessage, 1, wxEXPAND | wxALL, 10); - ds.y += mMessage->GetSize().y + 20; - - // - // - // - mGauge = safenew wxGauge(this, - wxID_ANY, - 1000, - wxDefaultPosition, - wxDefaultSize, - wxGA_HORIZONTAL); - v->Add(mGauge, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 10); - ds.y += mGauge->GetSize().y + 10; - - // - // - // - { - auto ug = std::make_unique(2, 2, 10, 10); - g = ug.get(); - - w = safenew wxStaticText(this, - wxID_ANY, - _("Elapsed Time:"), - wxDefaultPosition, - wxDefaultSize, - wxALIGN_RIGHT); - w->SetName(w->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) - g->Add(w, 0, wxALIGN_RIGHT); - - mElapsed = safenew wxStaticText(this, - wxID_ANY, - wxT("00:00:00"), - wxDefaultPosition, - wxDefaultSize, - wxALIGN_LEFT); - mElapsed->SetName(mElapsed->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) - g->Add(mElapsed, 0, wxALIGN_LEFT); - ds.y += mElapsed->GetSize().y + 10; - - // - // - // - w = safenew wxStaticText(this, - wxID_ANY, - _("Remaining Time:"), - wxDefaultPosition, - wxDefaultSize, - wxALIGN_RIGHT); - w->SetName(w->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) - g->Add(w, 0, wxALIGN_RIGHT); - - mRemaining = safenew wxStaticText(this, - wxID_ANY, - wxT("00:00:00"), - wxDefaultPosition, - wxDefaultSize, - wxALIGN_LEFT); - mRemaining->SetName(mRemaining->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) - g->Add(mRemaining, 0, wxALIGN_LEFT); - - v->Add(ug.release(), 0, wxALIGN_CENTER | wxLEFT | wxRIGHT | wxBOTTOM, 10); - } - - ds.y += mRemaining->GetSize().y + 10; - - { - auto uh = std::make_unique(wxHORIZONTAL); - h = uh.get(); - - if (!(flags & pdlgHideStopButton)) - { - w = safenew wxButton(this, wxID_OK, _("Stop")); - h->Add(w, 0, wxRIGHT, 10); - } - - if (!(flags & pdlgHideCancelButton)) - { - w = safenew wxButton(this, wxID_CANCEL, _("Cancel")); - h->Add(w, 0, wxRIGHT, 10); - } - - v->Add(uh.release(), 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 10); - } - - SetSizer(v.release()); + w = safenew wxButton(this, wxID_OK, _("Stop")); + h->Add(w, 0, wxRIGHT, 10); } + + if (!(flags & pdlgHideCancelButton)) + { + w = safenew wxButton(this, wxID_CANCEL, _("Cancel")); + h->Add(w, 0, wxRIGHT, 10); + } + + v->Add(h, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 10); + + SetSizer(v); Layout(); ds.x = wxMax(g->GetSize().x, h->GetSize().x) + 10;