// globals
// ----------------------------------------------------------------------------
+namespace
+{
+
//#define DEBUG_ATTR_CACHE
#ifdef DEBUG_ATTR_CACHE
static size_t gs_nAttrCacheHits = 0;
static size_t gs_nAttrCacheMisses = 0;
#endif
+// this struct simply combines together the default header renderers
+//
+// as the renderers ctors are trivial, there is no problem with making them
+// globals
+struct DefaultHeaderRenderers
+{
+ wxGridColumnHeaderRendererDefault colRenderer;
+ wxGridRowHeaderRendererDefault rowRenderer;
+ wxGridCornerHeaderRendererDefault cornerRenderer;
+} gs_defaultHeaderRenderers;
+
+} // anonymous namespace
+
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
}
}
+const wxGridColumnHeaderRenderer&
+wxGridCellAttrProvider::GetColumnHeaderRenderer(int WXUNUSED(col))
+{
+ return gs_defaultHeaderRenderers.colRenderer;
+}
+
+const wxGridRowHeaderRenderer&
+wxGridCellAttrProvider::GetRowHeaderRenderer(int WXUNUSED(row))
+{
+ return gs_defaultHeaderRenderers.rowRenderer;
+}
+
+const wxGridCornerHeaderRenderer& wxGridCellAttrProvider::GetCornerRenderer()
+{
+ return gs_defaultHeaderRenderers.cornerRenderer;
+}
+
// ----------------------------------------------------------------------------
// wxGridTableBase
// ----------------------------------------------------------------------------
if ( GetRowHeight(row) <= 0 || m_rowLabelWidth <= 0 )
return;
+ wxGridCellAttrProvider * const
+ attrProvider = m_table ? m_table->GetAttrProvider() : NULL;
+
+ // notice that an explicit static_cast is needed to avoid a compilation
+ // error with VC7.1 which, for some reason, tries to instantiate (abstract)
+ // wxGridRowHeaderRenderer class without it
const wxGridRowHeaderRenderer&
- rend = m_table->GetAttrProvider()->GetRowHeaderRenderer(row);
+ rend = attrProvider ? attrProvider->GetRowHeaderRenderer(row)
+ : static_cast<const wxGridRowHeaderRenderer&>
+ (gs_defaultHeaderRenderers.rowRenderer);
+
wxRect rect(0, GetRowTop(row), m_rowLabelWidth, GetRowHeight(row));
rend.DrawBorder(*this, dc, rect);
rect.width++;
rect.height++;
+ wxGridCellAttrProvider * const
+ attrProvider = m_table ? m_table->GetAttrProvider() : NULL;
const wxGridCornerHeaderRenderer&
- rend = m_table->GetAttrProvider()->GetCornerRenderer();
+ rend = attrProvider ? attrProvider->GetCornerRenderer()
+ : static_cast<wxGridCornerHeaderRenderer&>
+ (gs_defaultHeaderRenderers.cornerRenderer);
rend.DrawBorder(*this, dc, rect);
}
int colLeft = GetColLeft(col);
wxRect rect(colLeft, 0, GetColWidth(col), m_colLabelHeight);
+ wxGridCellAttrProvider * const
+ attrProvider = m_table ? m_table->GetAttrProvider() : NULL;
const wxGridColumnHeaderRenderer&
- rend = m_table->GetAttrProvider()->GetColumnHeaderRenderer(col);
+ rend = attrProvider ? attrProvider->GetColumnHeaderRenderer(col)
+ : static_cast<wxGridColumnHeaderRenderer&>
+ (gs_defaultHeaderRenderers.colRenderer);
if ( m_nativeColumnLabels )
{