+ // TODO: Replace with resize() call
+ unsigned int cellCountMax = column+1;
+
+ for ( unsigned int i=m_cells.size(); i<cellCountMax; i++ )
+ m_cells.push_back(defaultCell);
+ }
+}
+
+void wxPGProperty::SetCell( int column,
+ const wxPGCell& cell )
+{
+ EnsureCells(column);
+
+ m_cells[column] = cell;
+}
+
+void wxPGProperty::AdaptiveSetCell( unsigned int firstCol,
+ unsigned int lastCol,
+ const wxPGCell& cell,
+ const wxPGCell& srcData,
+ wxPGCellData* unmodCellData,
+ FlagType ignoreWithFlags,
+ bool recursively )
+{
+ //
+ // Sets cell in memory optimizing fashion. That is, if
+ // current cell data matches unmodCellData, we will
+ // simply get reference to data from cell. Otherwise,
+ // cell information from srcData is merged into current.
+ //
+
+ if ( !(m_flags & ignoreWithFlags) && !IsRoot() )
+ {
+ EnsureCells(lastCol);
+
+ for ( unsigned int col=firstCol; col<=lastCol; col++ )
+ {
+ if ( m_cells[col].GetData() == unmodCellData )
+ {
+ // Data matches... use cell directly
+ m_cells[col] = cell;
+ }
+ else
+ {
+ // Data did not match... merge valid information
+ m_cells[col].MergeFrom(srcData);
+ }
+ }
+ }
+
+ if ( recursively )
+ {
+ for ( unsigned int i=0; i<GetChildCount(); i++ )
+ Item(i)->AdaptiveSetCell( firstCol,
+ lastCol,
+ cell,
+ srcData,
+ unmodCellData,
+ ignoreWithFlags,
+ recursively );
+ }
+}
+
+const wxPGCell& wxPGProperty::GetCell( unsigned int column ) const
+{
+ if ( m_cells.size() > column )
+ return m_cells[column];
+
+ wxPropertyGrid* pg = GetGrid();
+
+ if ( IsCategory() )
+ return pg->GetCategoryDefaultCell();
+
+ return pg->GetPropertyDefaultCell();
+}
+
+wxPGCell& wxPGProperty::GetCell( unsigned int column )
+{
+ EnsureCells(column);
+ return m_cells[column];
+}
+
+void wxPGProperty::SetBackgroundColour( const wxColour& colour,
+ bool recursively )
+{
+ wxPGProperty* firstProp = this;
+
+ //
+ // If category is tried to set recursively, skip it and only
+ // affect the children.
+ if ( recursively )
+ {
+ while ( firstProp->IsCategory() )
+ {
+ if ( !firstProp->GetChildCount() )
+ return;
+ firstProp = firstProp->Item(0);
+ }
+ }
+
+ wxPGCell& firstCell = firstProp->GetCell(0);
+ wxPGCellData* firstCellData = firstCell.GetData();
+
+ wxPGCell newCell(firstCell);
+ newCell.SetBgCol(colour);
+ wxPGCell srcCell;
+ srcCell.SetBgCol(colour);
+
+ AdaptiveSetCell( 0,
+ GetParentState()->GetColumnCount()-1,
+ newCell,
+ srcCell,
+ firstCellData,
+ recursively ? wxPG_PROP_CATEGORY : 0,
+ recursively );
+}
+
+void wxPGProperty::SetTextColour( const wxColour& colour,
+ bool recursively )
+{
+ wxPGProperty* firstProp = this;
+
+ //
+ // If category is tried to set recursively, skip it and only
+ // affect the children.
+ if ( recursively )
+ {
+ while ( firstProp->IsCategory() )
+ {
+ if ( !firstProp->GetChildCount() )
+ return;
+ firstProp = firstProp->Item(0);
+ }
+ }
+
+ wxPGCell& firstCell = firstProp->GetCell(0);
+ wxPGCellData* firstCellData = firstCell.GetData();
+
+ wxPGCell newCell(firstCell);
+ newCell.SetFgCol(colour);
+ wxPGCell srcCell;
+ srcCell.SetFgCol(colour);
+
+ AdaptiveSetCell( 0,
+ GetParentState()->GetColumnCount()-1,
+ newCell,
+ srcCell,
+ firstCellData,
+ recursively ? wxPG_PROP_CATEGORY : 0,
+ recursively );