Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
NumericEditor Class Reference

wxGridCellEditor for the NumericTextCtrl. More...

#include <Grid.h>

Inheritance diagram for NumericEditor:
[legend]
Collaboration diagram for NumericEditor:
[legend]

Public Member Functions

 NumericEditor (NumericConverter::Type type, const NumericFormatSymbol &format, double rate)
 
 ~NumericEditor ()
 
void Create (wxWindow *parent, wxWindowID id, wxEvtHandler *handler) override
 
bool IsAcceptedKey (wxKeyEvent &event) override
 
void SetSize (const wxRect &rect) override
 
void BeginEdit (int row, int col, wxGrid *grid) override
 
bool EndEdit (int row, int col, const wxGrid *grid, const wxString &oldval, wxString *newval) override
 
void ApplyEdit (int row, int col, wxGrid *grid) override
 
void Reset () override
 
NumericFormatSymbol GetFormat () const
 
double GetRate () const
 
void SetFormat (const NumericFormatSymbol &format)
 
void SetRate (double rate)
 
wxGridCellEditor * Clone () const override
 
wxString GetValue () const override
 
NumericTextCtrlGetNumericTextControl () const
 

Private Attributes

NumericFormatSymbol mFormat
 
double mRate
 
NumericConverter::Type mType
 
double mOld
 
wxString mOldString
 
wxString mValueAsString
 

Detailed Description

wxGridCellEditor for the NumericTextCtrl.

Definition at line 37 of file Grid.h.

Constructor & Destructor Documentation

◆ NumericEditor()

NumericEditor::NumericEditor ( NumericConverter::Type  type,
const NumericFormatSymbol format,
double  rate 
)

Definition at line 121 of file Grid.cpp.

123{
124 mType = type;
125 mFormat = format;
126 mRate = rate;
127 mOld = 0.0;
128}
int format
Definition: ExportPCM.cpp:53
NumericFormatSymbol mFormat
Definition: Grid.h:74
NumericConverter::Type mType
Definition: Grid.h:76
double mOld
Definition: Grid.h:77
double mRate
Definition: Grid.h:75

References format, mFormat, mOld, mRate, and mType.

◆ ~NumericEditor()

NumericEditor::~NumericEditor ( )

Definition at line 130 of file Grid.cpp.

131{
132}

Member Function Documentation

◆ ApplyEdit()

void NumericEditor::ApplyEdit ( int  row,
int  col,
wxGrid *  grid 
)
override

Definition at line 192 of file Grid.cpp.

193{
194 grid->GetTable()->SetValue(row, col, mValueAsString);
195}
wxString mValueAsString
Definition: Grid.h:79

References mValueAsString.

◆ BeginEdit()

void NumericEditor::BeginEdit ( int  row,
int  col,
wxGrid *  grid 
)
override

Definition at line 164 of file Grid.cpp.

165{
166 wxGridTableBase *table = grid->GetTable();
167
168 mOldString = table->GetValue(row, col);
169 mOldString.ToDouble(&mOld);
170
171 auto control = GetNumericTextControl();
172 control->SetValue(mOld);
173 control->EnableMenu();
174
175 control->SetFocus();
176}
wxString mOldString
Definition: Grid.h:78
NumericTextCtrl * GetNumericTextControl() const
Definition: Grid.h:69

References GetNumericTextControl(), mOld, and mOldString.

Here is the call graph for this function:

◆ Clone()

wxGridCellEditor * NumericEditor::Clone ( ) const
override

Definition at line 214 of file Grid.cpp.

215{
217}
#define safenew
Definition: MemoryX.h:10
wxGridCellEditor for the NumericTextCtrl.
Definition: Grid.h:38

References mFormat, mRate, mType, and safenew.

◆ Create()

void NumericEditor::Create ( wxWindow *  parent,
wxWindowID  id,
wxEvtHandler *  handler 
)
override

Definition at line 134 of file Grid.cpp.

135{
136 wxASSERT(parent); // to justify safenew
137 auto control = safenew NumericTextCtrl(
138 parent, wxID_ANY,
139 mType,
140 mFormat,
141 mOld,
142 mRate,
144 .AutoPos(true)
145 .InvalidValue(mType == NumericTextCtrl::FREQUENCY,
147 );
148 m_control = control;
149
150 wxGridCellEditor::Create(parent, id, handler);
151}
static const int UndefinedFrequency
Options & AutoPos(bool enable)

References NumericTextCtrl::Options::AutoPos(), NumericConverter::FREQUENCY, cloud::audiocom::anonymous_namespace{AuthorizationHandler.cpp}::handler, mFormat, mOld, mRate, mType, safenew, and SelectedRegion::UndefinedFrequency.

Here is the call graph for this function:

◆ EndEdit()

bool NumericEditor::EndEdit ( int  row,
int  col,
const wxGrid *  grid,
const wxString &  oldval,
wxString *  newval 
)
override

Definition at line 179 of file Grid.cpp.

180{
181 double newtime = GetNumericTextControl()->GetValue();
182 bool changed = newtime != mOld;
183
184 if (changed) {
185 mValueAsString = wxString::Format(wxT("%g"), newtime);
186 *newval = mValueAsString;
187 }
188
189 return changed;
190}
wxT("CloseDown"))

References GetNumericTextControl(), NumericConverter::GetValue(), mOld, mValueAsString, and wxT().

Here is the call graph for this function:

◆ GetFormat()

NumericFormatSymbol NumericEditor::GetFormat ( ) const

Definition at line 224 of file Grid.cpp.

225{
226 return mFormat;
227}

References mFormat.

Referenced by NumericRenderer::Draw(), and NumericRenderer::GetBestSize().

Here is the caller graph for this function:

◆ GetNumericTextControl()

NumericTextCtrl * NumericEditor::GetNumericTextControl ( ) const
inline

Definition at line 69 of file Grid.h.

70 { return static_cast<NumericTextCtrl *>(m_control); }

Referenced by BeginEdit(), EndEdit(), GetValue(), and Reset().

Here is the caller graph for this function:

◆ GetRate()

double NumericEditor::GetRate ( ) const

Definition at line 229 of file Grid.cpp.

230{
231 return mRate;
232}

References mRate.

Referenced by NumericRenderer::Draw(), and NumericRenderer::GetBestSize().

Here is the caller graph for this function:

◆ GetValue()

wxString NumericEditor::GetValue ( ) const
override

Definition at line 219 of file Grid.cpp.

220{
221 return wxString::Format(wxT("%g"), GetNumericTextControl()->GetValue());
222}
wxString GetValue() const override
Definition: Grid.cpp:219

References GetNumericTextControl(), GetValue(), and wxT().

Referenced by NumericRenderer::Draw(), NumericRenderer::GetBestSize(), and GetValue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsAcceptedKey()

bool NumericEditor::IsAcceptedKey ( wxKeyEvent &  event)
override

Definition at line 202 of file Grid.cpp.

203{
204 if (wxGridCellEditor::IsAcceptedKey(event)) {
205 if (event.GetKeyCode() == WXK_RETURN) {
206 return true;
207 }
208 }
209
210 return false;
211}

◆ Reset()

void NumericEditor::Reset ( )
override

Definition at line 197 of file Grid.cpp.

198{
200}
void SetValue(double newValue)

References GetNumericTextControl(), mOld, and NumericTextCtrl::SetValue().

Here is the call graph for this function:

◆ SetFormat()

void NumericEditor::SetFormat ( const NumericFormatSymbol format)

Definition at line 234 of file Grid.cpp.

235{
236 mFormat = format;
237}

References format, and mFormat.

Referenced by LabelDialog::TransferDataToWindow().

Here is the caller graph for this function:

◆ SetRate()

void NumericEditor::SetRate ( double  rate)

Definition at line 239 of file Grid.cpp.

240{
241 mRate = rate;
242}

References mRate.

Referenced by LabelDialog::TransferDataToWindow().

Here is the caller graph for this function:

◆ SetSize()

void NumericEditor::SetSize ( const wxRect &  rect)
override

Definition at line 153 of file Grid.cpp.

154{
155 wxSize size = m_control->GetSize();
156
157 // Always center...looks bad otherwise
158 int x = rect.x + ((rect.width / 2) - (size.x / 2)) + 1;
159 int y = rect.y + ((rect.height / 2) - (size.y / 2)) + 1;
160
161 m_control->Move(x, y);
162}

References size.

Member Data Documentation

◆ mFormat

NumericFormatSymbol NumericEditor::mFormat
private

Definition at line 74 of file Grid.h.

Referenced by Clone(), Create(), GetFormat(), NumericEditor(), and SetFormat().

◆ mOld

double NumericEditor::mOld
private

Definition at line 77 of file Grid.h.

Referenced by BeginEdit(), Create(), EndEdit(), NumericEditor(), and Reset().

◆ mOldString

wxString NumericEditor::mOldString
private

Definition at line 78 of file Grid.h.

Referenced by BeginEdit().

◆ mRate

double NumericEditor::mRate
private

Definition at line 75 of file Grid.h.

Referenced by Clone(), Create(), GetRate(), NumericEditor(), and SetRate().

◆ mType

NumericConverter::Type NumericEditor::mType
private

Definition at line 76 of file Grid.h.

Referenced by Clone(), Create(), and NumericEditor().

◆ mValueAsString

wxString NumericEditor::mValueAsString
private

Definition at line 79 of file Grid.h.

Referenced by ApplyEdit(), and EndEdit().


The documentation for this class was generated from the following files: