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 (NumericConverter::Type 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

NumericConverter::Type mType
 

Detailed Description

wxGridCellRenderer for the NumericTextCtrl.

Definition at line 86 of file Grid.h.

Constructor & Destructor Documentation

◆ NumericRenderer()

NumericRenderer::NumericRenderer ( NumericConverter::Type  type)
inline

Definition at line 89 of file Grid.h.

89: mType{ type } {}
NumericConverter::Type mType
Definition: Grid.h:109

◆ ~NumericRenderer()

NumericRenderer::~NumericRenderer ( )
override

Definition at line 244 of file Grid.cpp.

245{
246}

Member Function Documentation

◆ Clone()

wxGridCellRenderer * NumericRenderer::Clone ( ) const
override

Definition at line 340 of file Grid.cpp.

341{
342 return safenew NumericRenderer{ mType };
343}
#define safenew
Definition: MemoryX.h:10
wxGridCellRenderer for the NumericTextCtrl.
Definition: Grid.h:87

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

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

References NumericTextCtrl::Options::AutoPos(), NumericEditor::GetFormat(), NumericEditor::GetRate(), NumericConverter::GetString(), NumericEditor::GetValue(), 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 310 of file Grid.cpp.

315{
316 wxGridTableBase *table = grid.GetTable();
317 NumericEditor *ne =
318 static_cast<NumericEditor *>(grid.GetCellEditor(row, col));
319 wxSize sz;
320
321 if (ne) {
322 double value;
323 table->GetValue(row, col).ToDouble(&value);
324 NumericTextCtrl tt(&grid, wxID_ANY,
325 mType,
326 ne->GetFormat(),
327 value,
328 ne->GetRate(),
330 wxPoint(10000, 10000)); // create offscreen
331 sz = tt.GetSize();
332
333 ne->DecRef();
334 }
335
336 return sz;
337}

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

Here is the call graph for this function:

Member Data Documentation

◆ mType

NumericConverter::Type NumericRenderer::mType
private

Definition at line 109 of file Grid.h.

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


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