Page 1 of 1

control cell attributes from wxGridTableBase descendant

Posted: Thu Mar 29, 2007 4:14 pm
by abench
How to control cell attributes from wxGridTableBase descendant?
I need to control cell attributes directly from successor of wxGridTableBase.
I override GetAttr method and experimenting with different return values of CanHaveAttributes method. Unsuccesfully.

Posted: Thu Mar 29, 2007 6:27 pm
by phlox81

Code: Select all

wxGridCellAttr* DataTable::GetAttr(int row, int col)
{
	if(col < tcivec.size())
	{
		return tcivec[col]->GetAttr();
	}
	return wxGridTableBase::GetAttr(row,col);
}
You need to create an wxGridCellAttr instance for each celltype, and return it.

Posted: Thu Mar 29, 2007 8:22 pm
by abench
phlox81 wrote:

Code: Select all

wxGridCellAttr* DataTable::GetAttr(int row, int col)
{
	if(col < tcivec.size())
	{
		return tcivec[col]->GetAttr();
	}
	return wxGridTableBase::GetAttr(row,col);
}
You need to create an wxGridCellAttr instance for each celltype, and return it.
Which type of DataTable?
wxGrid?
I understand that need to override GetAtrr method of wxGrid class instead of overrideing of GetAttr of wxGridTableBase class?

Posted: Thu Mar 29, 2007 8:24 pm
by phlox81
No, you need to overwrite the method in the wxGridTable class.

Posted: Fri Mar 30, 2007 5:08 pm
by abench
[quote="phlox81"]No, you need to overwrite the method in the wxGridTable class.[/quote

I override this method (see first message). Don't dont work. What I must do except overriding wxGridBase::GetAttr? May be additional activities or sending messages are need ?c

Posted: Thu Apr 12, 2007 2:26 pm
by ddv
return wxGridTableBase::GetAttr(row,col);
I don't which version of wx you are using. I am on 2.6.3 and there is a bug in the doc which says:
wxGridCellAttr* GetAttr(int row, int col)
when in fact in the sources:
wxGridCellAttr* GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind)
You need to use this last form.