control cell attributes from wxGridTableBase descendant Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
abench
In need of some credit
In need of some credit
Posts: 3
Joined: Tue Mar 20, 2007 6:52 pm

control cell attributes from wxGridTableBase descendant

Post by abench » Thu Mar 29, 2007 4:14 pm

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.

phlox81
wxWorld Domination!
wxWorld Domination!
Posts: 1387
Joined: Thu Aug 18, 2005 7:49 pm
Location: Germany
Contact:

Post by phlox81 » Thu Mar 29, 2007 6:27 pm

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.

abench
In need of some credit
In need of some credit
Posts: 3
Joined: Tue Mar 20, 2007 6:52 pm

Post by abench » Thu Mar 29, 2007 8:22 pm

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?

phlox81
wxWorld Domination!
wxWorld Domination!
Posts: 1387
Joined: Thu Aug 18, 2005 7:49 pm
Location: Germany
Contact:

Post by phlox81 » Thu Mar 29, 2007 8:24 pm

No, you need to overwrite the method in the wxGridTable class.

abench
In need of some credit
In need of some credit
Posts: 3
Joined: Tue Mar 20, 2007 6:52 pm

Post by abench » Fri Mar 30, 2007 5:08 pm

[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

ddv
Knows some wx things
Knows some wx things
Posts: 25
Joined: Mon Dec 18, 2006 4:23 pm

Post by ddv » Thu Apr 12, 2007 2:26 pm

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.

Post Reply