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

View File

@@ -46,21 +46,19 @@ class TimeEditor final : public wxGridCellEditor
~TimeEditor(); ~TimeEditor();
// Precondition: parent != NULL // 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() override;
void Reset();
wxString GetFormat(); wxString GetFormat();
double GetRate(); double GetRate();
@@ -68,7 +66,7 @@ class TimeEditor final : public wxGridCellEditor
void SetRate(double rate); void SetRate(double rate);
wxGridCellEditor *Clone() const override; wxGridCellEditor *Clone() const override;
wxString GetValue() const; wxString GetValue() const override;
NumericTextCtrl *GetTimeCtrl() const { return (NumericTextCtrl *)m_control; } NumericTextCtrl *GetTimeCtrl() const { return (NumericTextCtrl *)m_control; }
@@ -89,20 +87,22 @@ class TimeEditor final : public wxGridCellEditor
class TimeRenderer final : public wxGridCellRenderer class TimeRenderer final : public wxGridCellRenderer
{ {
public: public:
void Draw(wxGrid &grid, ~TimeRenderer() override;
wxGridCellAttr &attr,
wxDC &dc, void Draw(wxGrid &grid,
const wxRect &rect, wxGridCellAttr &attr,
int row, wxDC &dc,
int col, const wxRect &rect,
bool isSelected); int row,
int col,
bool isSelected) override;
wxSize GetBestSize(wxGrid &grid, wxSize GetBestSize(wxGrid &grid,
wxGridCellAttr &attr, wxGridCellAttr &attr,
wxDC &dc, wxDC &dc,
int row, int row,
int col); int col) override;
wxGridCellRenderer *Clone() const override; wxGridCellRenderer *Clone() const override;
}; };

View File

@@ -160,7 +160,7 @@ class NumericTextCtrl final : public wxControl, public NumericConverter
void SetReadOnly(bool readOnly = true); void SetReadOnly(bool readOnly = true);
void EnableMenu(bool enable = 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. // function has previously been called.
// Maybe you want something other than the default of -1 to indicate the invalid value // 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. // this control returns to the program, so you can specify.