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 (const FormatterContext &context, NumericConverterType type, const NumericFormatID &format)
 
 ~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
 
NumericFormatID GetFormat () const
 
void SetFormat (const NumericFormatID &format)
 
wxGridCellEditor * Clone () const override
 
wxString GetValue () const override
 
NumericTextCtrlGetNumericTextControl () const
 

Private Attributes

NumericFormatID mFormat
 
NumericConverterType mType
 
double mOld
 
wxString mOldString
 
wxString mValueAsString
 
FormatterContext mContext
 

Detailed Description

wxGridCellEditor for the NumericTextCtrl.

Definition at line 39 of file Grid.h.

Constructor & Destructor Documentation

◆ NumericEditor()

NumericEditor::NumericEditor ( const FormatterContext context,
NumericConverterType  type,
const NumericFormatID format 
)

Definition at line 124 of file Grid.cpp.

127 : mContext { context }
128{
129 mType = std::move(type);
130 mFormat = format;
131 mOld = 0.0;
132}
NumericFormatID mFormat
Definition: Grid.h:74
NumericConverterType mType
Definition: Grid.h:75
FormatterContext mContext
Definition: Grid.h:80
double mOld
Definition: Grid.h:76

References anonymous_namespace{ExportPCM.cpp}::format, mFormat, mOld, and mType.

◆ ~NumericEditor()

NumericEditor::~NumericEditor ( )

Definition at line 134 of file Grid.cpp.

135{
136}

Member Function Documentation

◆ ApplyEdit()

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

Definition at line 195 of file Grid.cpp.

196{
197 grid->GetTable()->SetValue(row, col, mValueAsString);
198}
wxString mValueAsString
Definition: Grid.h:78

References mValueAsString.

◆ BeginEdit()

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

Definition at line 167 of file Grid.cpp.

168{
169 wxGridTableBase *table = grid->GetTable();
170
171 mOldString = table->GetValue(row, col);
172 mOldString.ToDouble(&mOld);
173
174 auto control = GetNumericTextControl();
175 control->SetValue(mOld);
176 control->EnableMenu();
177
178 control->SetFocus();
179}
wxString mOldString
Definition: Grid.h:77
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 217 of file Grid.cpp.

218{
220}
#define safenew
Definition: MemoryX.h:10
wxGridCellEditor for the NumericTextCtrl.
Definition: Grid.h:40

References mContext, mFormat, mType, and safenew.

◆ Create()

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

Definition at line 138 of file Grid.cpp.

139{
140 wxASSERT(parent); // to justify safenew
141 auto control = safenew NumericTextCtrl(mContext,
142 parent, wxID_ANY,
143 mType,
144 mFormat,
145 mOld,
147 .AutoPos(true)
148 .InvalidValue(mType == NumericConverterType_FREQUENCY(),
150 );
151 m_control = control;
152
153 wxGridCellEditor::Create(parent, id, handler);
154}
const NumericConverterType & NumericConverterType_FREQUENCY()
static const int UndefinedFrequency
Options & AutoPos(bool enable)

References NumericTextCtrl::Options::AutoPos(), cloud::audiocom::anonymous_namespace{AuthorizationHandler.cpp}::handler, mContext, mFormat, mOld, mType, NumericConverterType_FREQUENCY(), 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 182 of file Grid.cpp.

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

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

Here is the call graph for this function:

◆ GetFormat()

NumericFormatID NumericEditor::GetFormat ( ) const

Definition at line 227 of file Grid.cpp.

228{
229 return mFormat;
230}

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:

◆ GetValue()

wxString NumericEditor::GetValue ( ) const
override

Definition at line 222 of file Grid.cpp.

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

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 205 of file Grid.cpp.

206{
207 if (wxGridCellEditor::IsAcceptedKey(event)) {
208 if (event.GetKeyCode() == WXK_RETURN) {
209 return true;
210 }
211 }
212
213 return false;
214}

◆ Reset()

void NumericEditor::Reset ( )
override

Definition at line 200 of file Grid.cpp.

201{
203}
void SetValue(double newValue)

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

Here is the call graph for this function:

◆ SetFormat()

void NumericEditor::SetFormat ( const NumericFormatID format)

Definition at line 232 of file Grid.cpp.

233{
234 mFormat = format;
235}

References anonymous_namespace{ExportPCM.cpp}::format, and mFormat.

Referenced by LabelDialog::TransferDataToWindow().

Here is the caller graph for this function:

◆ SetSize()

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

Definition at line 156 of file Grid.cpp.

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

References size.

Member Data Documentation

◆ mContext

FormatterContext NumericEditor::mContext
private

Definition at line 80 of file Grid.h.

Referenced by Clone(), and Create().

◆ mFormat

NumericFormatID 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 76 of file Grid.h.

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

◆ mOldString

wxString NumericEditor::mOldString
private

Definition at line 77 of file Grid.h.

Referenced by BeginEdit().

◆ mType

NumericConverterType NumericEditor::mType
private

Definition at line 75 of file Grid.h.

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

◆ mValueAsString

wxString NumericEditor::mValueAsString
private

Definition at line 78 of file Grid.h.

Referenced by ApplyEdit(), and EndEdit().


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