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

126 : mContext { context }
127{
128 mType = std::move(type);
129 mFormat = format;
130 mOld = 0.0;
131}
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 133 of file Grid.cpp.

134{
135}

Member Function Documentation

◆ ApplyEdit()

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

Definition at line 194 of file Grid.cpp.

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

References mValueAsString.

◆ BeginEdit()

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

Definition at line 166 of file Grid.cpp.

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

217{
219}
#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 137 of file Grid.cpp.

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

References NumericTextCtrl::Options::AutoPos(), audacity::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 181 of file Grid.cpp.

182{
183 double newtime = GetNumericTextControl()->GetValue();
184 bool changed = newtime != mOld;
185
186 if (changed) {
187 mValueAsString = wxString::Format(wxT("%g"), newtime);
188 *newval = mValueAsString;
189 }
190
191 return changed;
192}
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 226 of file Grid.cpp.

227{
228 return mFormat;
229}

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

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

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

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

◆ Reset()

void NumericEditor::Reset ( )
override

Definition at line 199 of file Grid.cpp.

200{
202}
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 231 of file Grid.cpp.

232{
233 mFormat = format;
234}

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

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

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: