setting parameters for wxGridCellFloatRenderer seems to work

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6358 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2000-02-29 19:30:26 +00:00
parent 0b190b0f6a
commit e72b421324
2 changed files with 53 additions and 12 deletions

View File

@ -131,6 +131,9 @@ public:
// left to the derived classes
virtual void SetParameters(const wxString& params);
// create a new object which is the copy of this one
virtual wxGridCellRenderer *Clone() const = 0;
protected:
// virtual dtor for any base class - private because only DecRef() can
// delete us
@ -162,6 +165,9 @@ public:
wxDC& dc,
int row, int col);
virtual wxGridCellRenderer *Clone() const
{ return new wxGridCellStringRenderer; }
protected:
// set the text colours before drawing
void SetTextColoursAndFont(wxGrid& grid,
@ -192,6 +198,9 @@ public:
wxDC& dc,
int row, int col);
virtual wxGridCellRenderer *Clone() const
{ return new wxGridCellNumberRenderer; }
protected:
wxString GetString(wxGrid& grid, int row, int col);
};
@ -223,6 +232,8 @@ public:
// parameters string format is "width[,precision]"
virtual void SetParameters(const wxString& params);
virtual wxGridCellRenderer *Clone() const;
protected:
wxString GetString(wxGrid& grid, int row, int col);
@ -252,6 +263,9 @@ public:
wxDC& dc,
int row, int col);
virtual wxGridCellRenderer *Clone() const
{ return new wxGridCellBoolRenderer; }
private:
static wxSize ms_sizeCheckMark;
};

View File

@ -1216,6 +1216,16 @@ wxGridCellFloatRenderer::wxGridCellFloatRenderer(int width, int precision)
SetPrecision(precision);
}
wxGridCellRenderer *wxGridCellFloatRenderer::Clone() const
{
wxGridCellFloatRenderer *renderer = new wxGridCellFloatRenderer;
renderer->m_width = m_width;
renderer->m_precision = m_precision;
renderer->m_format = m_format;
return renderer;
}
wxString wxGridCellFloatRenderer::GetString(wxGrid& grid, int row, int col)
{
wxGridTableBase *table = grid.GetTable();
@ -6937,22 +6947,39 @@ wxGrid::GetDefaultEditorForType(const wxString& typeName) const
wxGridCellRenderer*
wxGrid::GetDefaultRendererForType(const wxString& typeName) const
{
// the first part of the typename is the "real" type, anything after ':'
// are the parameters for the renderer
wxString type = typeName.BeforeFirst(_T(':'));
int index = m_typeRegistry->FindDataType(type);
// first try to find an exact match
wxGridCellRenderer *renderer;
int index = m_typeRegistry->FindDataType(typeName);
if ( index == wxNOT_FOUND )
{
wxFAIL_MSG(wxT("Unknown data type name"));
// then try to construct a renderer from the base name and parameters
// following it
return NULL;
// the first part of the typename is the "real" type, anything after ':'
// are the parameters for the renderer
index = m_typeRegistry->FindDataType(typeName.BeforeFirst(_T(':')));
if ( index == wxNOT_FOUND )
{
wxFAIL_MSG(wxT("Unknown data type name"));
return NULL;
}
renderer = m_typeRegistry->GetRenderer(index);
wxGridCellRenderer *rendererOld = renderer;
renderer = renderer->Clone();
rendererOld->DecRef();
// do it even if there are no parameters to reset them to defaults
renderer->SetParameters(typeName.AfterFirst(_T(':')));
// register the new typename
m_typeRegistry->RegisterDataType(typeName, renderer, NULL);
}
else
{
renderer = m_typeRegistry->GetRenderer(index);
}
wxGridCellRenderer *renderer = m_typeRegistry->GetRenderer(index);
// do it even if there are no parameters to reset them to defaults
renderer->SetParameters(typeName.AfterFirst(_T(':')));
return renderer;
}