Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » How to set the color of a row
How to set the color of a row [message #7713] Tue, 16 January 2007 21:46 Go to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

this question regards both arrayctrl and gridctrl.
I know how to set the background color of a cell by using SetDisplay. But what to do to set the background color of a row?

Luigi
Re: How to set the color of a row [message #7714 is a reply to message #7713] Tue, 16 January 2007 22:29 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

forlano wrote on Tue, 16 January 2007 15:46

Hello,

this question regards both arrayctrl and gridctrl.
I know how to set the background color of a cell by using SetDisplay. But what to do to set the background color of a row?

Luigi



GridCtrl:

grid.GetRow(22).Bg(Red);
Re: How to set the color of a row [message #7727 is a reply to message #7714] Wed, 17 January 2007 12:06 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
unodgs wrote on Tue, 16 January 2007 22:29

forlano wrote on Tue, 16 January 2007 15:46

Hello,

this question regards both arrayctrl and gridctrl.
I know how to set the background color of a cell by using SetDisplay. But what to do to set the background color of a row?

Luigi



GridCtrl:

grid.GetRow(22).Bg(Red);


I've used it at runtime, not in the constructor, and I discovered that was necessary to add the instruction grid.Repaint() to see the new color. I guess this is normal.

Luigi
Re: How to set the color of a row [message #7728 is a reply to message #7727] Wed, 17 January 2007 12:28 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

forlano wrote on Wed, 17 January 2007 06:06

unodgs wrote on Tue, 16 January 2007 22:29



GridCtrl:

grid.GetRow(22).Bg(Red);


I've used it at runtime, not in the constructor, and I discovered that was necessary to add the instruction grid.Repaint() to see the new color. I guess this is normal.

Luigi


I think it has to be change. Bg and similar functions should refresh the grid. Calling Repaint is not optimal as it recalculate rows/columns (if needed) positions and repaint the whole content.
I used Bg mainly in callbacks where calling refresh is not necessary as outer functions that call callbacks do this.
Anyway it will be fixed before final release.

PS: It's better to call RefreshRow(int n) instead of Repaint
Re: How to set the color of a row [message #34272 is a reply to message #7727] Mon, 07 November 2011 16:27 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

I used

grid.GetRow(x).Bg(Red);

to set red the color of some row of a gridctrl where the rows are white and blu depending of their parity
( grid.ColorRows().EvenColor(SColorText, Blend(SColorMark, SColorPaper, 220)); ) .
The red color depend of the value in a coloumn. So in some case the cell need to be set at its default color.
How to remove the red color and leave the default color?

Thanks,
Luigi

[Updated on: Mon, 07 November 2011 16:41]

Report message to a moderator

Re: How to set the color of a row [message #34314 is a reply to message #7713] Fri, 11 November 2011 14:12 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
forlano wrote on Tue, 16 January 2007 15:46

Hello,

this question regards both arrayctrl and gridctrl.
I know how to set the background color of a cell by using SetDisplay. But what to do to set the background color of a row?

Luigi



ArrayCtrl: set background color to all cells of row Wink

Anyway, it is as well possible and often more practical to use AttrText.

Mirek
Re: How to set the color of a row [message #34317 is a reply to message #34314] Fri, 11 November 2011 14:42 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
mirek wrote on Fri, 11 November 2011 14:12

forlano wrote on Tue, 16 January 2007 15:46

Hello,

this question regards both arrayctrl and gridctrl.
I know how to set the background color of a cell by using SetDisplay. But what to do to set the background color of a row?

Luigi



ArrayCtrl: set background color to all cells of row Wink

Anyway, it is as well possible and often more practical to use AttrText.

Mirek


Hello Mirek,

thank you for the reply. I am afraid you have answered to an old question Smile.
The newest question regarded GridCtrl and how to remove at runtime a previously assigned color so that the default is applied. Perhaps for it I must wait Daniel.

Regards,
Luigi
Re: How to set the color of a row [message #34319 is a reply to message #34317] Fri, 11 November 2011 15:20 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
forlano wrote on Fri, 11 November 2011 08:42

mirek wrote on Fri, 11 November 2011 14:12

forlano wrote on Tue, 16 January 2007 15:46

Hello,

this question regards both arrayctrl and gridctrl.
I know how to set the background color of a cell by using SetDisplay. But what to do to set the background color of a row?

Luigi



ArrayCtrl: set background color to all cells of row Wink

Anyway, it is as well possible and often more practical to use AttrText.

Mirek


Hello Mirek,

thank you for the reply. I am afraid you have answered to an old question Smile.
The newest question regarded GridCtrl and how to remove at runtime a previously assigned color so that the default is applied. Perhaps for it I must wait Daniel.

Regards,
Luigi


Ah I see. That is why I do not think it is a good idea to 'recycle' existing threads Smile

Mirek
Re: How to set the color of a row [message #34322 is a reply to message #34317] Fri, 11 November 2011 20:55 Go to previous message
Didier is currently offline  Didier
Messages: 680
Registered: November 2008
Location: France
Contributor
Hi Forlano,

I had to do something approaching and I used a gridDisplay for it:

class BgColorGridDisplay : public GridDisplay
{
	private:
		Color _bg; //(140, 140, 140);
	public:
	
	BgColorGridDisplay(const Color color)
	: _bg(color)
	{}
	 
	virtual void Paint(Draw &w, int x, int y, int cx, int cy, const Value &val, dword style,
			           Color &fg, Color &bg, Font &fnt, bool found = false, int fs = 0, int fe = 0)
   {
       if (found)
       {
	       GridDisplay::Paint(w,x,y,cx,cy,val,style,fg,bg,fnt,found,fs,fe);
       }
       else
       {
    	   GridDisplay::Paint(w,x,y,cx,cy,val,style,fg,_bg,fnt,found,fs,fe);
       }
   }
};


You can either remove the display to restore original color or enhance it to keep it form overwriting original color.

tabGrid.dataGrid.AddColumn("ColName", 110).SetDisplay( greyBgDisplay )


I use it in order to change bkgnd colour of only some columns while others are changed on cell value just like you.
Previous Topic: ArrayCtrl speedy writes cause crashing...why?
Next Topic: GridCtrl: master detail interactions
Goto Forum:
  


Current Time: Thu Mar 28 11:32:57 CET 2024

Total time taken to generate the page: 0.01132 seconds