1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-19 23:21:33 +01:00

some safenew, override, remove an unused function, better comment

This commit is contained in:
Paul Licameli
2016-06-27 10:58:08 -04:00
parent c3b4ea165f
commit 8943f682f2
3 changed files with 30 additions and 34 deletions

View File

@@ -81,16 +81,6 @@ void TimeEditor::BeginEdit(int row, int col, wxGrid *grid)
GetTimeCtrl()->SetFocus();
}
bool TimeEditor::EndEdit(int row, int col, wxGrid *grid)
{
wxString newvalue;
bool changed = EndEdit(row, col, grid, mOldString, &newvalue);
if (changed) {
ApplyEdit(row, col, grid);
}
return changed;
}
bool TimeEditor::EndEdit(int WXUNUSED(row), int WXUNUSED(col), const wxGrid *WXUNUSED(grid), const wxString &WXUNUSED(oldval), wxString *newval)
{
double newtime = GetTimeCtrl()->GetValue();
@@ -156,6 +146,10 @@ void TimeEditor::SetRate(double rate)
mRate = rate;
}
TimeRenderer::~TimeRenderer()
{
}
void TimeRenderer::Draw(wxGrid &grid,
wxGridCellAttr &attr,
wxDC &dc,
@@ -392,13 +386,15 @@ Grid::Grid(wxWindow *parent,
GetGridWindow()->SetAccessible(mAx = safenew GridAx(this));
#endif
// RegisterDataType takes ownership of renderer and editor
RegisterDataType(GRID_VALUE_TIME,
new TimeRenderer,
new TimeEditor);
safenew TimeRenderer,
safenew TimeEditor);
RegisterDataType(GRID_VALUE_CHOICE,
new wxGridCellStringRenderer,
new ChoiceEditor);
safenew wxGridCellStringRenderer,
safenew ChoiceEditor);
}
Grid::~Grid()

View File

@@ -46,21 +46,19 @@ class TimeEditor final : public wxGridCellEditor
~TimeEditor();
// Precondition: parent != NULL
void Create(wxWindow *parent, wxWindowID id, wxEvtHandler *handler);
void Create(wxWindow *parent, wxWindowID id, wxEvtHandler *handler) override;
bool IsAcceptedKey(wxKeyEvent &event);
bool IsAcceptedKey(wxKeyEvent &event) override;
void SetSize(const wxRect &rect);
void SetSize(const wxRect &rect) override;
void BeginEdit(int row, int col, wxGrid *grid);
void BeginEdit(int row, int col, wxGrid *grid) override;
bool EndEdit(int row, int col, wxGrid *grid);
bool EndEdit(int row, int col, const wxGrid *grid, const wxString &oldval, wxString *newval) override;
bool EndEdit(int row, int col, const wxGrid *grid, const wxString &oldval, wxString *newval);
void ApplyEdit(int row, int col, wxGrid *grid) override;
void ApplyEdit(int row, int col, wxGrid *grid);
void Reset();
void Reset() override;
wxString GetFormat();
double GetRate();
@@ -68,7 +66,7 @@ class TimeEditor final : public wxGridCellEditor
void SetRate(double rate);
wxGridCellEditor *Clone() const override;
wxString GetValue() const;
wxString GetValue() const override;
NumericTextCtrl *GetTimeCtrl() const { return (NumericTextCtrl *)m_control; }
@@ -89,20 +87,22 @@ class TimeEditor final : public wxGridCellEditor
class TimeRenderer final : public wxGridCellRenderer
{
public:
public:
~TimeRenderer() override;
void Draw(wxGrid &grid,
wxGridCellAttr &attr,
wxDC &dc,
const wxRect &rect,
int row,
int col,
bool isSelected);
bool isSelected) override;
wxSize GetBestSize(wxGrid &grid,
wxGridCellAttr &attr,
wxDC &dc,
int row,
int col);
int col) override;
wxGridCellRenderer *Clone() const override;
};

View File

@@ -160,7 +160,7 @@ class NumericTextCtrl final : public wxControl, public NumericConverter
void SetReadOnly(bool readOnly = true);
void EnableMenu(bool enable = true);
// The text control permits typing '-' to make the value invalid only if this
// The text control permits typing DELETE to make the value invalid only if this
// function has previously been called.
// Maybe you want something other than the default of -1 to indicate the invalid value
// this control returns to the program, so you can specify.