Can you set multiple wxGrid Colum Attributes?
Bob
wxwidgets at gmail.com
Sat Jan 12 19:29:35 PST 2008
On 1/11/08, Petr Smilauer <petrsm at jcu.cz> wrote:
>>> Right, so you are doing both operations at the same time.
>>> What does your "color problem" mean?
>> That the above code is not restoring the grid to the default
>> background color.
>Perhaps a little more detail would help. Restoring from what
>state? You set a different attribute for these columns before?
>using SetColAttr call too, with the same column indices, but
>different Attr object?
I set the grid cell to a different color from the default color,
which works fine:
wxColour color_red =3D wxTheColourDatabase->Find("RED");
m_grid->SetCellBackgroundColour( 0, 0, color_red );
What doesn't seem to work is changing
the background attribute of the entire column back to
the background color. This was with Windows XP,
using the Digital Mars compiler and wx287. I just
tried the code on my home system, Linux, with both
wx287 and wx263, the background color does not change.
I put together a small project with DialogBlocks that
shows the problem if you want to try it.
http://www.unusualresearch.com/GridProblem.zip
It draws a grid coloring one of the cell backgrounds red,
then I expectedthe following code to change the red background
back to the default system 'white' background,
when I pressed the button:
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1
*/
void Grid::OnButton1Click( wxCommandEvent& event )
{
wxColor default_cell_background =3D m_grid->GetDefaultCellBackgroundColour(=
);
wxGridCellAttr *attr =3D new wxGridCellAttr;// Remove all previous backgrou=
nd
colors
attr->SetBackgroundColour( default_cell_background );
m_grid->ClearGrid();
m_grid->SetColAttr( 0, attr );
m_grid->SetCellValue( 0, 1, wxT("<- Color Change?") );
m_grid->AutoSizeColumns();
m_grid->Fit();
}
The color remains red after pressing the button, but the other
grid changes did happen, like the message showing up in cell (0,1),
and the grid being resized.
Am I doing something wrong in the above code, or is the
problem in wxWidgets?
>> The idea of using any framework is to save development time,
>> not use it up. The boss expects this project to ship in his
>> life time, which may exceed mine if it doesn't work. ;-)
>If demands of your boss prevent to set a breapoint at your code
>to fix problems, it is probably time you change job.
I agree completely. I'm 90 miles north of Pittsburgh, PA,
with extensive background in embedded systems design,
if anyone wants a resume.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wx-users/attachments/20080112/6e1=
d8a2b/attachment.htm
More information about the wx-users
mailing list