Remove some naked new amd delete in: widgets
This commit is contained in:
parent
0bb17c174e
commit
71efb13161
|
@ -8,6 +8,7 @@
|
|||
|
||||
**********************************************************************/
|
||||
|
||||
#include "Audacity.h"
|
||||
#include "Snap.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
|
|
@ -520,23 +520,6 @@ void LWSlider::Init(wxWindow * parent,
|
|||
|
||||
LWSlider::~LWSlider()
|
||||
{
|
||||
if (mBitmap)
|
||||
{
|
||||
delete mBitmap;
|
||||
mBitmap = NULL;
|
||||
}
|
||||
|
||||
if (mThumbBitmap)
|
||||
{
|
||||
delete mThumbBitmap;
|
||||
mThumbBitmap = NULL;
|
||||
}
|
||||
|
||||
delete mpRuler;
|
||||
if (mTipPanel)
|
||||
{
|
||||
delete mTipPanel;
|
||||
}
|
||||
}
|
||||
|
||||
wxWindowID LWSlider::GetId()
|
||||
|
@ -658,18 +641,6 @@ void LWSlider::OnSize( wxSizeEvent & event )
|
|||
|
||||
void LWSlider::Draw(wxDC & paintDC)
|
||||
{
|
||||
if (mBitmap)
|
||||
{
|
||||
delete mBitmap;
|
||||
mBitmap = NULL;
|
||||
}
|
||||
|
||||
if (mThumbBitmap)
|
||||
{
|
||||
delete mThumbBitmap;
|
||||
mThumbBitmap = NULL;
|
||||
}
|
||||
|
||||
// The color we'll use to create the mask
|
||||
wxColour transparentColour(255, 254, 255);
|
||||
|
||||
|
@ -677,7 +648,7 @@ void LWSlider::Draw(wxDC & paintDC)
|
|||
wxMemoryDC dc;
|
||||
|
||||
// Create the bitmap
|
||||
mThumbBitmap = new wxBitmap();
|
||||
mThumbBitmap = std::make_unique<wxBitmap>();
|
||||
mThumbBitmap->Create(mThumbWidth, mThumbHeight, paintDC);
|
||||
dc.SelectObject(*mThumbBitmap);
|
||||
|
||||
|
@ -687,50 +658,49 @@ void LWSlider::Draw(wxDC & paintDC)
|
|||
dc.Clear();
|
||||
#endif
|
||||
|
||||
// Create the graphics contexxt
|
||||
wxGraphicsContext *gc = wxGraphicsContext::Create(dc);
|
||||
|
||||
// For vertical, we use the same downward pointing thumb, but rotate and flip it
|
||||
if (mOrientation == wxVERTICAL)
|
||||
{
|
||||
gc->Translate(0, 3);
|
||||
gc->Scale(1, -1);
|
||||
gc->Rotate((-90 * M_PI) / 180);
|
||||
// Create the graphics contexxt
|
||||
std::unique_ptr<wxGraphicsContext> gc{ wxGraphicsContext::Create(dc) };
|
||||
|
||||
// For vertical, we use the same downward pointing thumb, but rotate and flip it
|
||||
if (mOrientation == wxVERTICAL)
|
||||
{
|
||||
gc->Translate(0, 3);
|
||||
gc->Scale(1, -1);
|
||||
gc->Rotate((-90 * M_PI) / 180);
|
||||
}
|
||||
else
|
||||
{
|
||||
gc->Translate(1.5, 0);
|
||||
}
|
||||
|
||||
// Draw the thumb outline
|
||||
gc->SetBrush(wxBrush(mEnabled ? wxColour(192, 192, 216) : wxColour(238, 238, 238)));
|
||||
gc->SetPen(wxPen(mEnabled ? wxColour(0, 0, 0) : wxColour(119, 119, 119)));
|
||||
gc->DrawLines(WXSIZEOF(outer), outer);
|
||||
|
||||
// The interior is based on whether the slider is enabled or not
|
||||
if (mEnabled)
|
||||
{
|
||||
// Draw the left and top interior components
|
||||
gc->SetPen(wxPen(wxColour(255, 255, 255)));
|
||||
gc->StrokeLines(WXSIZEOF(enabledLeftBegin), enabledLeftBegin, enabledLeftEnd);
|
||||
|
||||
// Draw the right and bottom interior components
|
||||
gc->SetPen(wxPen(wxColour(141, 141, 178)));
|
||||
gc->StrokeLines(WXSIZEOF(enabledRightBegin), enabledRightBegin, enabledRightEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Draw the interior stripes
|
||||
gc->SetPen(wxPen(wxColour(200, 200, 200)));
|
||||
gc->StrokeLines(WXSIZEOF(disabledStripesBegin), disabledStripesBegin, disabledStripesEnd);
|
||||
|
||||
// Draw the right and bottom interior components
|
||||
gc->SetPen(wxPen(wxColour(153, 153, 153)));
|
||||
gc->StrokeLines(WXSIZEOF(disabledRightBegin), disabledRightBegin, disabledRightEnd);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gc->Translate(1.5, 0);
|
||||
}
|
||||
|
||||
// Draw the thumb outline
|
||||
gc->SetBrush(wxBrush(mEnabled ? wxColour(192, 192, 216) : wxColour(238, 238, 238)));
|
||||
gc->SetPen(wxPen(mEnabled ? wxColour(0, 0, 0) : wxColour(119, 119, 119)));
|
||||
gc->DrawLines(WXSIZEOF(outer), outer);
|
||||
|
||||
// The interior is based on whether the slider is enabled or not
|
||||
if (mEnabled)
|
||||
{
|
||||
// Draw the left and top interior components
|
||||
gc->SetPen(wxPen(wxColour(255, 255, 255)));
|
||||
gc->StrokeLines(WXSIZEOF(enabledLeftBegin), enabledLeftBegin, enabledLeftEnd);
|
||||
|
||||
// Draw the right and bottom interior components
|
||||
gc->SetPen(wxPen(wxColour(141, 141, 178)));
|
||||
gc->StrokeLines(WXSIZEOF(enabledRightBegin), enabledRightBegin, enabledRightEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Draw the interior stripes
|
||||
gc->SetPen(wxPen(wxColour(200, 200, 200)));
|
||||
gc->StrokeLines(WXSIZEOF(disabledStripesBegin), disabledStripesBegin, disabledStripesEnd);
|
||||
|
||||
// Draw the right and bottom interior components
|
||||
gc->SetPen(wxPen(wxColour(153, 153, 153)));
|
||||
gc->StrokeLines(WXSIZEOF(disabledRightBegin), disabledRightBegin, disabledRightEnd);
|
||||
}
|
||||
|
||||
// Done with the graphics context and memory DC
|
||||
delete gc;
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
|
||||
#if !defined(__WXMAC__)
|
||||
|
@ -742,7 +712,7 @@ void LWSlider::Draw(wxDC & paintDC)
|
|||
// Now the background bitmap
|
||||
//
|
||||
|
||||
mBitmap = new wxBitmap();
|
||||
mBitmap = std::make_unique<wxBitmap>();
|
||||
mBitmap->Create(mWidth, mHeight, paintDC);
|
||||
dc.SelectObject(*mBitmap);
|
||||
|
||||
|
@ -934,8 +904,7 @@ void LWSlider::ShowTip(bool show)
|
|||
return;
|
||||
}
|
||||
|
||||
delete mTipPanel;
|
||||
mTipPanel = NULL;
|
||||
mTipPanel.reset();
|
||||
}
|
||||
|
||||
CreatePopWin();
|
||||
|
@ -948,21 +917,14 @@ void LWSlider::ShowTip(bool show)
|
|||
if (mTipPanel)
|
||||
{
|
||||
mTipPanel->Hide();
|
||||
delete mTipPanel;
|
||||
mTipPanel = NULL;
|
||||
mTipPanel.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LWSlider::CreatePopWin()
|
||||
{
|
||||
if (mTipPanel)
|
||||
{
|
||||
delete mTipPanel;
|
||||
mTipPanel = NULL;
|
||||
}
|
||||
|
||||
mTipPanel = new TipPanel(mParent, GetMaxTip());
|
||||
mTipPanel = std::make_unique<TipPanel>(mParent, GetMaxTip());
|
||||
}
|
||||
|
||||
void LWSlider::SetPopWinPosition()
|
||||
|
@ -1555,11 +1517,7 @@ void LWSlider::SetEnabled(bool enabled)
|
|||
{
|
||||
mEnabled = enabled;
|
||||
|
||||
if (mThumbBitmap)
|
||||
{
|
||||
delete mThumbBitmap;
|
||||
mThumbBitmap = NULL;
|
||||
}
|
||||
mThumbBitmap.reset();
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
@ -1593,7 +1551,7 @@ ASlider::ASlider( wxWindow * parent,
|
|||
int orientation /*= wxHORIZONTAL*/)
|
||||
: wxPanel( parent, id, pos, size, wxWANTS_CHARS )
|
||||
{
|
||||
mLWSlider = new LWSlider( this,
|
||||
mLWSlider = std::make_unique<LWSlider>( this,
|
||||
name,
|
||||
wxPoint(0,0),
|
||||
size,
|
||||
|
@ -1621,7 +1579,6 @@ ASlider::~ASlider()
|
|||
{
|
||||
if(HasCapture())
|
||||
ReleaseMouse();
|
||||
delete mLWSlider;
|
||||
}
|
||||
|
||||
void ASlider::OnSlider(wxCommandEvent &event)
|
||||
|
|
|
@ -228,15 +228,14 @@ class LWSlider
|
|||
|
||||
wxWindowID mID;
|
||||
|
||||
TipPanel *mTipPanel;
|
||||
std::unique_ptr<TipPanel> mTipPanel;
|
||||
wxString mTipTemplate;
|
||||
|
||||
Ruler* mpRuler;
|
||||
std::unique_ptr<Ruler> mpRuler;
|
||||
|
||||
bool mIsDragging;
|
||||
|
||||
wxBitmap *mBitmap;
|
||||
wxBitmap *mThumbBitmap;
|
||||
std::unique_ptr<wxBitmap> mBitmap, mThumbBitmap;
|
||||
|
||||
// AD: True if this object owns *mThumbBitmap (sometimes mThumbBitmap points
|
||||
// to an object we shouldn't DELETE) -- once we get theming totally right
|
||||
|
@ -311,7 +310,7 @@ public:
|
|||
static TempAllowFocus TemporarilyAllowFocus();
|
||||
|
||||
private:
|
||||
LWSlider *mLWSlider;
|
||||
std::unique_ptr<LWSlider> mLWSlider;
|
||||
bool mSliderIsFocused;
|
||||
wxTimer mTimer;
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ ExpandingToolBar::ExpandingToolBar(wxWindow* parent,
|
|||
mFrameParent(NULL),
|
||||
mDialogParent(NULL),
|
||||
mAreaParent(NULL),
|
||||
mSavedArrangement(NULL),
|
||||
mSavedArrangement{},
|
||||
mDragImage(NULL),
|
||||
mTopLevelParent(NULL)
|
||||
{
|
||||
|
@ -632,13 +632,10 @@ void ExpandingToolBar::FinishMoving()
|
|||
msNoAutoExpandStack--;
|
||||
|
||||
if (mDropTarget == kDummyRect) {
|
||||
mAreaParent->RestoreArrangement(mSavedArrangement);
|
||||
mSavedArrangement = NULL;
|
||||
mAreaParent->RestoreArrangement(std::move(mSavedArrangement));
|
||||
}
|
||||
else {
|
||||
delete mSavedArrangement;
|
||||
mSavedArrangement = NULL;
|
||||
|
||||
mSavedArrangement.reset();
|
||||
mAreaParent->MoveChild(this, mDropTarget);
|
||||
}
|
||||
|
||||
|
@ -1182,9 +1179,9 @@ void ToolBarArea::RemoveChild(ExpandingToolBar *child)
|
|||
}
|
||||
}
|
||||
|
||||
ToolBarArrangement *ToolBarArea::SaveArrangement()
|
||||
std::unique_ptr<ToolBarArrangement> ToolBarArea::SaveArrangement()
|
||||
{
|
||||
ToolBarArrangement *arrangement = new ToolBarArrangement();
|
||||
auto arrangement = std::make_unique<ToolBarArrangement>();
|
||||
int i;
|
||||
|
||||
arrangement->childArray = mChildArray;
|
||||
|
@ -1196,7 +1193,7 @@ ToolBarArrangement *ToolBarArea::SaveArrangement()
|
|||
return arrangement;
|
||||
}
|
||||
|
||||
void ToolBarArea::RestoreArrangement(ToolBarArrangement *arrangement)
|
||||
void ToolBarArea::RestoreArrangement(std::unique_ptr<ToolBarArrangement>&& arrangement)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -1210,7 +1207,7 @@ void ToolBarArea::RestoreArrangement(ToolBarArrangement *arrangement)
|
|||
|
||||
Fit(false, true);
|
||||
|
||||
delete arrangement;
|
||||
arrangement.reset();
|
||||
}
|
||||
|
||||
wxArrayRect ToolBarArea::GetDropTargets()
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#ifndef __AUDACITY_EXPANDING_TOOL_BAR__
|
||||
#define __AUDACITY_EXPANDING_TOOL_BAR__
|
||||
|
||||
#include "../MemoryX.h"
|
||||
#include <wx/defs.h>
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/dynarray.h>
|
||||
|
@ -108,7 +109,7 @@ class ExpandingToolBar final : public wxPanelWrapper
|
|||
ToolBarFrame *mFrameParent;
|
||||
ToolBarDialog *mDialogParent;
|
||||
ToolBarArea *mAreaParent;
|
||||
ToolBarArrangement *mSavedArrangement;
|
||||
std::unique_ptr<ToolBarArrangement> mSavedArrangement;
|
||||
ImageRollPanel *mTargetPanel;
|
||||
wxDragImage *mDragImage;
|
||||
wxWindow *mTopLevelParent;
|
||||
|
@ -217,8 +218,8 @@ class ToolBarArea final : public wxPanelWrapper
|
|||
void AddChild(ExpandingToolBar *child);
|
||||
void RemoveChild(ExpandingToolBar *child);
|
||||
|
||||
ToolBarArrangement *SaveArrangement();
|
||||
void RestoreArrangement(ToolBarArrangement *arrangement);
|
||||
std::unique_ptr<ToolBarArrangement> SaveArrangement();
|
||||
void RestoreArrangement(std::unique_ptr<ToolBarArrangement>&& arrangement);
|
||||
|
||||
wxArrayRect GetDropTargets();
|
||||
void MoveChild(ExpandingToolBar *child, wxRect dropTarget);
|
||||
|
|
|
@ -411,11 +411,11 @@ Grid::Grid(wxWindow *parent,
|
|||
Grid::~Grid()
|
||||
{
|
||||
#if wxUSE_ACCESSIBILITY
|
||||
int cnt = mChildren.GetCount();
|
||||
|
||||
while (cnt) {
|
||||
GridAx *ax = (GridAx *) mChildren[--cnt];
|
||||
delete ax;
|
||||
int cnt = mChildren.size();
|
||||
while (cnt--) {
|
||||
// PRL: I found this loop destroying right-to-left.
|
||||
// Is the sequence of destruction important?
|
||||
mChildren.pop_back();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#ifndef __AUDACITY_WIDGETS_GRID__
|
||||
#define __AUDACITY_WIDGETS_GRID__
|
||||
|
||||
#include "../MemoryX.h"
|
||||
#include <vector>
|
||||
#include <wx/defs.h>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/dynarray.h>
|
||||
|
@ -224,7 +226,7 @@ class Grid final : public wxGrid
|
|||
|
||||
#if wxUSE_ACCESSIBILITY
|
||||
GridAx *mAx;
|
||||
wxArrayPtrVoid mChildren;
|
||||
std::vector<movable_ptr<GridAx>> mChildren;
|
||||
int mObjNdx;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -237,8 +237,8 @@ Meter::Meter(AudacityProject *project,
|
|||
mActive(false),
|
||||
mNumBars(0),
|
||||
mLayoutValid(false),
|
||||
mBitmap(NULL),
|
||||
mIcon(NULL),
|
||||
mBitmap{},
|
||||
mIcon{},
|
||||
mAccSilent(false)
|
||||
{
|
||||
// Suppress warnings about the header file
|
||||
|
@ -316,11 +316,11 @@ Meter::Meter(AudacityProject *project,
|
|||
{
|
||||
if(mIsInput)
|
||||
{
|
||||
mIcon = new wxBitmap(MicMenuNarrow_xpm);
|
||||
mIcon = std::make_unique<wxBitmap>(MicMenuNarrow_xpm);
|
||||
}
|
||||
else
|
||||
{
|
||||
mIcon = new wxBitmap(SpeakerMenuNarrow_xpm);
|
||||
mIcon = std::make_unique<wxBitmap>(SpeakerMenuNarrow_xpm);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -369,10 +369,6 @@ Meter::~Meter()
|
|||
// is active.
|
||||
if (gAudioIO->IsMonitoring())
|
||||
gAudioIO->StopStream();
|
||||
if (mIcon)
|
||||
delete mIcon;
|
||||
if (mBitmap)
|
||||
delete mBitmap;
|
||||
}
|
||||
|
||||
void Meter::UpdatePrefs()
|
||||
|
@ -427,21 +423,16 @@ void Meter::OnErase(wxEraseEvent & WXUNUSED(event))
|
|||
void Meter::OnPaint(wxPaintEvent & WXUNUSED(event))
|
||||
{
|
||||
#if defined(__WXMAC__)
|
||||
wxPaintDC *paintDC = new wxPaintDC(this);
|
||||
auto paintDC = std::make_unique<wxPaintDC>(this);
|
||||
#else
|
||||
wxDC *paintDC = wxAutoBufferedPaintDCFactory(this);
|
||||
std::unique_ptr<wxDC> paintDC{ wxAutoBufferedPaintDCFactory(this) };
|
||||
#endif
|
||||
wxDC & destDC = *paintDC;
|
||||
|
||||
if (mLayoutValid == false)
|
||||
{
|
||||
if (mBitmap)
|
||||
{
|
||||
delete mBitmap;
|
||||
}
|
||||
|
||||
// Create a NEW one using current size and select into the DC
|
||||
mBitmap = new wxBitmap();
|
||||
mBitmap = std::make_unique<wxBitmap>();
|
||||
mBitmap->Create(mWidth, mHeight, destDC);
|
||||
wxMemoryDC dc;
|
||||
dc.SelectObject(*mBitmap);
|
||||
|
@ -664,8 +655,6 @@ void Meter::OnPaint(wxPaintEvent & WXUNUSED(event))
|
|||
wxRect r = mIconRect;
|
||||
AColor::DrawFocus(destDC, r.Inflate(1, 1));
|
||||
}
|
||||
|
||||
delete paintDC;
|
||||
}
|
||||
|
||||
void Meter::OnSize(wxSizeEvent & WXUNUSED(event))
|
||||
|
|
|
@ -261,13 +261,13 @@ class Meter final : public wxPanelWrapper
|
|||
|
||||
bool mLayoutValid;
|
||||
|
||||
wxBitmap *mBitmap;
|
||||
std::unique_ptr<wxBitmap> mBitmap;
|
||||
wxRect mIconRect;
|
||||
wxPoint mLeftTextPos;
|
||||
wxPoint mRightTextPos;
|
||||
wxSize mLeftSize;
|
||||
wxSize mRightSize;
|
||||
wxBitmap *mIcon;
|
||||
std::unique_ptr<wxBitmap> mIcon;
|
||||
wxPen mPen;
|
||||
wxPen mDisabledPen;
|
||||
wxPen mPeakPeakPen;
|
||||
|
|
|
@ -1175,9 +1175,9 @@ NumericTextCtrl::NumericTextCtrl(NumericConverter::Type type,
|
|||
bool autoPos):
|
||||
wxControl(parent, id, pos, size, wxSUNKEN_BORDER | wxWANTS_CHARS),
|
||||
NumericConverter(type, formatName, timeValue, sampleRate),
|
||||
mBackgroundBitmap(NULL),
|
||||
mDigitFont(NULL),
|
||||
mLabelFont(NULL),
|
||||
mBackgroundBitmap{},
|
||||
mDigitFont{},
|
||||
mLabelFont{},
|
||||
mLastField(1),
|
||||
mAutoPos(autoPos)
|
||||
, mType(type)
|
||||
|
@ -1211,12 +1211,6 @@ NumericTextCtrl::NumericTextCtrl(NumericConverter::Type type,
|
|||
|
||||
NumericTextCtrl::~NumericTextCtrl()
|
||||
{
|
||||
if (mBackgroundBitmap)
|
||||
delete mBackgroundBitmap;
|
||||
if (mDigitFont)
|
||||
delete mDigitFont;
|
||||
if (mLabelFont)
|
||||
delete mLabelFont;
|
||||
}
|
||||
|
||||
// Set the focus to the first (left-most) non-zero digit
|
||||
|
@ -1306,12 +1300,9 @@ bool NumericTextCtrl::Layout()
|
|||
int x, pos;
|
||||
|
||||
wxMemoryDC memDC;
|
||||
if (mBackgroundBitmap) {
|
||||
delete mBackgroundBitmap;
|
||||
mBackgroundBitmap = NULL;
|
||||
}
|
||||
|
||||
// Placeholder bitmap so the memDC has something to reference
|
||||
mBackgroundBitmap = new wxBitmap(1, 1);
|
||||
mBackgroundBitmap = std::make_unique<wxBitmap>(1, 1);
|
||||
memDC.SelectObject(*mBackgroundBitmap);
|
||||
|
||||
mDigits.Clear();
|
||||
|
@ -1335,9 +1326,7 @@ bool NumericTextCtrl::Layout()
|
|||
}
|
||||
fontSize--;
|
||||
|
||||
if (mDigitFont)
|
||||
delete mDigitFont;
|
||||
mDigitFont = new wxFont(fontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
mDigitFont = std::make_unique<wxFont>(fontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
memDC.SetFont(*mDigitFont);
|
||||
memDC.GetTextExtent(exampleText, &strW, &strH);
|
||||
mDigitW = strW;
|
||||
|
@ -1345,9 +1334,7 @@ bool NumericTextCtrl::Layout()
|
|||
|
||||
// The label font should be a little smaller
|
||||
fontSize--;
|
||||
if (mLabelFont)
|
||||
delete mLabelFont;
|
||||
mLabelFont = new wxFont(fontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
mLabelFont = std::make_unique<wxFont>(fontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
|
||||
// Figure out the x-position of each field and label in the box
|
||||
x = mBorderLeft;
|
||||
|
@ -1382,8 +1369,7 @@ bool NumericTextCtrl::Layout()
|
|||
|
||||
wxBrush Brush;
|
||||
|
||||
delete mBackgroundBitmap; // Delete placeholder
|
||||
mBackgroundBitmap = new wxBitmap(mWidth + mButtonWidth, mHeight);
|
||||
mBackgroundBitmap = std::make_unique<wxBitmap>(mWidth + mButtonWidth, mHeight);
|
||||
memDC.SelectObject(*mBackgroundBitmap);
|
||||
|
||||
memDC.SetBrush(*wxLIGHT_GREY_BRUSH);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#ifndef __AUDACITY_TIME_TEXT_CTRL__
|
||||
#define __AUDACITY_TIME_TEXT_CTRL__
|
||||
|
||||
#include "../MemoryX.h"
|
||||
#include <wx/defs.h>
|
||||
#include <wx/dynarray.h>
|
||||
#include <wx/event.h>
|
||||
|
@ -193,10 +194,9 @@ private:
|
|||
bool mMenuEnabled;
|
||||
bool mReadOnly;
|
||||
|
||||
wxBitmap *mBackgroundBitmap;
|
||||
std::unique_ptr<wxBitmap> mBackgroundBitmap;
|
||||
|
||||
wxFont *mDigitFont;
|
||||
wxFont *mLabelFont;
|
||||
std::unique_ptr<wxFont> mDigitFont, mLabelFont;
|
||||
int mDigitBoxW;
|
||||
int mDigitBoxH;
|
||||
int mDigitW;
|
||||
|
|
|
@ -1013,11 +1013,7 @@ ProgressDialog::~ProgressDialog()
|
|||
{
|
||||
// Delete the window disabler before hiding the dialog to allow
|
||||
// focus to return to the original window.
|
||||
if (mDisable)
|
||||
{
|
||||
delete mDisable;
|
||||
mDisable = NULL;
|
||||
}
|
||||
mDisable.reset();
|
||||
|
||||
if (IsShown())
|
||||
{
|
||||
|
@ -1261,7 +1257,7 @@ bool ProgressDialog::Create(const wxString & title,
|
|||
// while waiting for Timer Record to start -- and then also
|
||||
// while it's recording, it has a ProgressDialog, so really,
|
||||
// no editing in any project until Timer Record finishes.
|
||||
mDisable = new wxWindowDisabler(this);
|
||||
mDisable = std::make_unique<wxWindowDisabler>(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "../Audacity.h"
|
||||
|
||||
#include "../MemoryX.h"
|
||||
#include <wx/defs.h>
|
||||
#include <wx/evtloop.h>
|
||||
#include <wx/gauge.h>
|
||||
|
@ -113,7 +114,7 @@ private:
|
|||
// This guarantees we have an active event loop...possible during OnInit()
|
||||
wxEventLoopGuarantor mLoop;
|
||||
|
||||
wxWindowDisabler *mDisable;
|
||||
std::unique_ptr<wxWindowDisabler> mDisable;
|
||||
|
||||
wxStaticText *mMessage;
|
||||
int mLastW;
|
||||
|
|
|
@ -105,7 +105,7 @@ wxColour Ruler::mTickColour{ 153, 153, 153 };
|
|||
//
|
||||
|
||||
Ruler::Ruler()
|
||||
: mpNumberScale(0)
|
||||
: mpNumberScale{}
|
||||
{
|
||||
mMin = mHiddenMin = 0.0;
|
||||
mMax = mHiddenMax = 100.0;
|
||||
|
@ -136,9 +136,9 @@ Ruler::Ruler()
|
|||
fontSize = 8;
|
||||
#endif
|
||||
|
||||
mMinorMinorFont = new wxFont(fontSize - 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
mMinorFont = new wxFont(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
mMajorFont = new wxFont(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
|
||||
mMinorMinorFont = std::make_unique<wxFont>(fontSize - 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
mMinorFont = std::make_unique<wxFont>(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
mMajorFont = std::make_unique<wxFont>(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
|
||||
|
||||
mUserFonts = false;
|
||||
|
||||
|
@ -170,9 +170,6 @@ Ruler::~Ruler()
|
|||
Invalidate(); // frees up our arrays
|
||||
if( mUserBits )
|
||||
delete [] mUserBits;//JKC
|
||||
delete mMinorFont;
|
||||
delete mMajorFont;
|
||||
delete mMinorMinorFont;
|
||||
|
||||
if (mMajorLabels)
|
||||
delete[] mMajorLabels;
|
||||
|
@ -180,8 +177,6 @@ Ruler::~Ruler()
|
|||
delete[] mMinorLabels;
|
||||
if (mMinorMinorLabels)
|
||||
delete[] mMinorMinorLabels;
|
||||
|
||||
delete mpNumberScale;
|
||||
}
|
||||
|
||||
void Ruler::SetTwoTone(bool twoTone)
|
||||
|
@ -322,14 +317,13 @@ void Ruler::SetNumberScale(const NumberScale *pScale)
|
|||
{
|
||||
if (!pScale) {
|
||||
if (mpNumberScale) {
|
||||
delete mpNumberScale;
|
||||
mpNumberScale.reset();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!mpNumberScale || *mpNumberScale != *pScale) {
|
||||
delete mpNumberScale;
|
||||
mpNumberScale = new NumberScale(*pScale);
|
||||
mpNumberScale = std::make_unique<NumberScale>(*pScale);
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
@ -1028,17 +1022,11 @@ void Ruler::Update(const TimeTrack* timetrack)// Envelope *speedEnv, long minSpe
|
|||
mDC->GetTextExtent(exampleText, &strW, &strH, &strD, &strL);
|
||||
mLead = strL;
|
||||
|
||||
if (mMajorFont)
|
||||
delete mMajorFont;
|
||||
mMajorFont = new wxFont(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
|
||||
mMajorFont = std::make_unique<wxFont>(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
|
||||
|
||||
if (mMinorFont)
|
||||
delete mMinorFont;
|
||||
mMinorFont = new wxFont(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
mMinorFont = std::make_unique<wxFont>(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
|
||||
if (mMinorMinorFont)
|
||||
delete mMinorMinorFont;
|
||||
mMinorMinorFont = new wxFont(fontSize - 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
mMinorMinorFont = std::make_unique<wxFont>(fontSize - 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
}
|
||||
|
||||
// If ruler is being resized, we could end up with it being too small.
|
||||
|
@ -2013,11 +2001,6 @@ AdornedRulerPanel::~AdornedRulerPanel()
|
|||
if(HasCapture())
|
||||
ReleaseMouse();
|
||||
|
||||
// Done with the snap manager
|
||||
if (mSnapManager) {
|
||||
delete mSnapManager;
|
||||
}
|
||||
|
||||
wxTheApp->Disconnect(EVT_AUDIOIO_CAPTURE,
|
||||
wxCommandEventHandler(AdornedRulerPanel::OnCapture),
|
||||
NULL,
|
||||
|
@ -2424,10 +2407,7 @@ void AdornedRulerPanel::OnMouseEvents(wxMouseEvent &evt)
|
|||
SetCursor(mCursorDefault);
|
||||
mIsWE = false;
|
||||
|
||||
if (mSnapManager) {
|
||||
delete mSnapManager;
|
||||
mSnapManager = NULL;
|
||||
}
|
||||
mSnapManager.reset();
|
||||
|
||||
if(evt.Leaving())
|
||||
return;
|
||||
|
@ -2929,7 +2909,7 @@ void AdornedRulerPanel::DragSelection()
|
|||
void AdornedRulerPanel::HandleSnapping()
|
||||
{
|
||||
if (!mSnapManager) {
|
||||
mSnapManager = new SnapManager(mTracks, mViewInfo);
|
||||
mSnapManager = std::make_unique<SnapManager>(mTracks, mViewInfo);
|
||||
}
|
||||
|
||||
bool snappedPoint, snappedTime;
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#define __AUDACITY_RULER__
|
||||
|
||||
#include "OverlayPanel.h"
|
||||
|
||||
#include "../MemoryX.h"
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/dc.h>
|
||||
|
@ -105,7 +104,7 @@ class AUDACITY_DLL_API Ruler {
|
|||
void SetFonts(const wxFont &minorFont, const wxFont &majorFont, const wxFont &minorMinorFont);
|
||||
struct Fonts { wxFont *major, *minor, *minorMinor; };
|
||||
Fonts GetFonts() const
|
||||
{ return { mMajorFont, mMinorFont, mMinorMinorFont }; }
|
||||
{ return { mMajorFont.get(), mMinorFont.get(), mMinorMinorFont.get() }; }
|
||||
|
||||
// Copies *pScale if it is not NULL
|
||||
void SetNumberScale(const NumberScale *pScale);
|
||||
|
@ -181,8 +180,7 @@ private:
|
|||
int mLengthOld;
|
||||
wxDC *mDC;
|
||||
|
||||
wxFont *mMinorFont, *mMajorFont;
|
||||
wxFont *mMinorMinorFont;
|
||||
std::unique_ptr<wxFont> mMinorFont, mMajorFont, mMinorMinorFont;
|
||||
bool mUserFonts;
|
||||
|
||||
double mMin, mMax;
|
||||
|
@ -240,7 +238,7 @@ private:
|
|||
const ZoomInfo *mUseZoomInfo;
|
||||
int mLeftOffset;
|
||||
|
||||
NumberScale *mpNumberScale;
|
||||
std::unique_ptr<NumberScale> mpNumberScale;
|
||||
};
|
||||
|
||||
class AUDACITY_DLL_API RulerPanel final : public wxPanelWrapper {
|
||||
|
@ -401,7 +399,7 @@ private:
|
|||
double mIndTime;
|
||||
double mQuickPlayPos;
|
||||
|
||||
SnapManager *mSnapManager;
|
||||
std::unique_ptr<SnapManager> mSnapManager;
|
||||
bool mIsSnapped;
|
||||
|
||||
bool mPlayRegionLock;
|
||||
|
|
Loading…
Reference in New Issue