Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
NumericRenderer Class Referencefinal

wxGridCellRenderer for the NumericTextCtrl. More...

#include <Grid.h>

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

Public Member Functions

 NumericRenderer (const FormatterContext &context, NumericConverterType type)
 
 ~NumericRenderer () override
 
void Draw (wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, const wxRect &rect, int row, int col, bool isSelected) override
 
wxSize GetBestSize (wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, int row, int col) override
 
wxGridCellRenderer * Clone () const override
 

Private Attributes

NumericConverterType mType
 
FormatterContext mContext
 

Detailed Description

wxGridCellRenderer for the NumericTextCtrl.

Definition at line 87 of file Grid.h.

Constructor & Destructor Documentation

◆ NumericRenderer()

NumericRenderer::NumericRenderer ( const FormatterContext context,
NumericConverterType  type 
)
inline

Definition at line 90 of file Grid.h.

91 : mType { std::move(type) }
92 , mContext { context }
93 {
94 }
FormatterContext mContext
Definition: Grid.h:115
NumericConverterType mType
Definition: Grid.h:114

◆ ~NumericRenderer()

NumericRenderer::~NumericRenderer ( )
override

Definition at line 236 of file Grid.cpp.

237{
238}

Member Function Documentation

◆ Clone()

wxGridCellRenderer * NumericRenderer::Clone ( ) const
override

Definition at line 330 of file Grid.cpp.

331{
333}
#define safenew
Definition: MemoryX.h:10
wxGridCellRenderer for the NumericTextCtrl.
Definition: Grid.h:88

References mContext, mType, and safenew.

◆ Draw()

void NumericRenderer::Draw ( wxGrid &  grid,
wxGridCellAttr &  attr,
wxDC &  dc,
const wxRect &  rect,
int  row,
int  col,
bool  isSelected 
)
override

Definition at line 240 of file Grid.cpp.

247{
248 wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
249
250 wxGridTableBase *table = grid.GetTable();
251 NumericEditor *ne =
252 static_cast<NumericEditor *>(grid.GetCellEditor(row, col));
253 wxString tstr;
254
255 if (ne) {
256 double value;
257
258 table->GetValue(row, col).ToDouble(&value);
259
260 NumericTextCtrl tt(mContext, &grid, wxID_ANY,
261 mType,
262 ne->GetFormat(),
263 value,
265 wxPoint(10000, 10000)); // create offscreen
266 tstr = tt.GetString();
267
268 ne->DecRef();
269 }
270
271 dc.SetBackgroundMode(wxTRANSPARENT);
272
273 if (grid.IsEnabled())
274 {
275 if (isSelected)
276 {
277 dc.SetTextBackground(grid.GetSelectionBackground());
278 dc.SetTextForeground(grid.GetSelectionForeground());
279 }
280 else
281 {
282 dc.SetTextBackground(attr.GetBackgroundColour());
283 dc.SetTextForeground(attr.GetTextColour());
284 }
285 }
286 else
287 {
288 dc.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
289 dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
290 }
291
292 dc.SetFont(attr.GetFont());
293
294 int hAlign, vAlign;
295
296 attr.GetAlignment(&hAlign, &vAlign);
297
298 grid.DrawTextRectangle(dc, tstr, rect, hAlign, vAlign);
299}
wxGridCellEditor for the NumericTextCtrl.
Definition: Grid.h:40
wxString GetValue() const override
Definition: Grid.cpp:221
NumericFormatID GetFormat() const
Definition: Grid.cpp:226
Options & AutoPos(bool enable)

References NumericTextCtrl::Options::AutoPos(), NumericEditor::GetFormat(), NumericConverter::GetString(), NumericEditor::GetValue(), mContext, and mType.

Here is the call graph for this function:

◆ GetBestSize()

wxSize NumericRenderer::GetBestSize ( wxGrid &  grid,
wxGridCellAttr &  attr,
wxDC &  dc,
int  row,
int  col 
)
override

Definition at line 301 of file Grid.cpp.

306{
307 wxGridTableBase *table = grid.GetTable();
308 NumericEditor *ne =
309 static_cast<NumericEditor *>(grid.GetCellEditor(row, col));
310 wxSize sz;
311
312 if (ne) {
313 double value;
314 table->GetValue(row, col).ToDouble(&value);
315 NumericTextCtrl tt(mContext, &grid, wxID_ANY,
316 mType,
317 ne->GetFormat(),
318 value,
320 wxPoint(10000, 10000)); // create offscreen
321 sz = tt.GetSize();
322
323 ne->DecRef();
324 }
325
326 return sz;
327}

References NumericTextCtrl::Options::AutoPos(), NumericEditor::GetFormat(), NumericEditor::GetValue(), mContext, and mType.

Here is the call graph for this function:

Member Data Documentation

◆ mContext

FormatterContext NumericRenderer::mContext
private

Definition at line 115 of file Grid.h.

Referenced by Clone(), Draw(), and GetBestSize().

◆ mType

NumericConverterType NumericRenderer::mType
private

Definition at line 114 of file Grid.h.

Referenced by Clone(), Draw(), and GetBestSize().


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