// get renderers for the given row/column header label and the corner
// window: unlike cell renderers, these objects are not reference counted
// and are never NULL so they are returned by reference
- virtual const wxGridColumnHeaderRenderer&
- GetColumnHeaderRenderer(int WXUNUSED(col))
- {
- return m_defaultHeaderRenderers.colRenderer;
- }
-
- virtual const wxGridRowHeaderRenderer&
- GetRowHeaderRenderer(int WXUNUSED(row))
- {
- return m_defaultHeaderRenderers.rowRenderer;
- }
-
- virtual const wxGridCornerHeaderRenderer& GetCornerRenderer()
- {
- return m_defaultHeaderRenderers.cornerRenderer;
- }
+ virtual const wxGridColumnHeaderRenderer& GetColumnHeaderRenderer(int col);
+ virtual const wxGridRowHeaderRenderer& GetRowHeaderRenderer(int row);
+ virtual const wxGridCornerHeaderRenderer& GetCornerRenderer();
private:
void InitData();
wxGridCellAttrProviderData *m_data;
- // this struct simply combines together the default header renderers
- //
- // FIXME-VC6: this struct must be named because of VC6 bug, it fails
- // with error C2639 on this struct declaration without it
- struct DefaultHeaderRenderers
- {
- wxGridColumnHeaderRendererDefault colRenderer;
- wxGridRowHeaderRendererDefault rowRenderer;
- wxGridCornerHeaderRendererDefault cornerRenderer;
- } m_defaultHeaderRenderers;
-
wxDECLARE_NO_COPY_CLASS(wxGridCellAttrProvider);
};
// 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;
const wxGridRowHeaderRenderer&
- rend = m_table->GetAttrProvider()->GetRowHeaderRenderer(row);
+ rend = attrProvider ? attrProvider->GetRowHeaderRenderer(row)
+ : 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()
+ : 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)
+ : gs_defaultHeaderRenderers.colRenderer;
if ( m_nativeColumnLabels )
{