+void wxGridCellAttr::Init(wxGridCellAttr *attrDefault)
+{
+ m_nRef = 1;
+
+ m_isReadOnly = Unset;
+
+ m_renderer = NULL;
+ m_editor = NULL;
+
+ m_attrkind = wxGridCellAttr::Cell;
+
+ SetDefAttr(attrDefault);
+}
+
+wxGridCellAttr *wxGridCellAttr::Clone() const
+{
+ wxGridCellAttr *attr = new wxGridCellAttr(m_defGridAttr);
+
+ if ( HasTextColour() )
+ attr->SetTextColour(GetTextColour());
+ if ( HasBackgroundColour() )
+ attr->SetBackgroundColour(GetBackgroundColour());
+ if ( HasFont() )
+ attr->SetFont(GetFont());
+ if ( HasAlignment() )
+ attr->SetAlignment(m_hAlign, m_vAlign);
+
+ if ( m_renderer )
+ {
+ attr->SetRenderer(m_renderer);
+ m_renderer->IncRef();
+ }
+ if ( m_editor )
+ {
+ attr->SetEditor(m_editor);
+ m_editor->IncRef();
+ }
+
+ if ( IsReadOnly() )
+ attr->SetReadOnly();
+
+ attr->SetKind( m_attrkind );
+
+ return attr;
+}
+
+void wxGridCellAttr::MergeWith(wxGridCellAttr *mergefrom)
+{
+ if ( !HasTextColour() && mergefrom->HasTextColour() )
+ SetTextColour(mergefrom->GetTextColour());
+ if ( !HasBackgroundColour() && mergefrom->HasBackgroundColour() )
+ SetBackgroundColour(mergefrom->GetBackgroundColour());
+ if ( !HasFont() && mergefrom->HasFont() )
+ SetFont(mergefrom->GetFont());
+ if ( !!HasAlignment() && mergefrom->HasAlignment() ){
+ int hAlign, vAlign;
+ mergefrom->GetAlignment( &hAlign, &vAlign);
+ SetAlignment(hAlign, vAlign);
+ }
+
+ // Directly access member functions as GetRender/Editor don't just return
+ // m_renderer/m_editor
+ //
+ // Maybe add support for merge of Render and Editor?
+ if (!HasRenderer() && mergefrom->HasRenderer() )
+ {
+ m_renderer = mergefrom->m_renderer;
+ m_renderer->IncRef();
+ }
+ if ( !HasEditor() && mergefrom->HasEditor() )
+ {
+ m_editor = mergefrom->m_editor;
+ m_editor->IncRef();
+ }
+ if ( !HasReadWriteMode() && mergefrom->HasReadWriteMode() )
+ SetReadOnly(mergefrom->IsReadOnly());
+
+ SetDefAttr(mergefrom->m_defGridAttr);
+}
+