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 » GridCtrl and AttrText
GridCtrl and AttrText [message #9051] Sun, 15 April 2007 17:45 Go to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

I'm using AttrText("something") as value in the gridctrl just as I did with the arrayctrl to take advantage of the methods Paper() etc.... But it seems no to work. Is it normal? Are there alternative methods, except display, to easily change the background color of a cell? Need to post a test case?

Thanks,
Luigi
Re: GridCtrl and AttrText [message #9052 is a reply to message #9051] Sun, 15 April 2007 19:57 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

forlano wrote on Sun, 15 April 2007 11:45

Hello,
I'm using AttrText("something") as value in the gridctrl just as I did with the arrayctrl to take advantage of the methods Paper() etc.... But it seems no to work. Is it normal? Are there alternative methods, except display, to easily change the background color of a cell? Need to post a test case?
Thanks,
Luigi


It does not work yet. I will add it in the next snapshot. In the meantime make your own GridDisplay and check in it if passed value type is AttrText. If yes pass furhter (to GridDisplay::Paint() color of ink and paper.
Re: GridCtrl and AttrText [message #9058 is a reply to message #9052] Sun, 15 April 2007 21:56 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
unodgs wrote on Sun, 15 April 2007 19:57


It does not work yet. I will add it in the next snapshot. In the meantime make your own GridDisplay and check in it if passed value type is AttrText.


Sorry, but I've not understood your recipe.
Quote:

If yes pass furhter (to GridDisplay::Paint() color of ink and paper.


I used the following code to color the cell of a column and it works
class ColoredStatus : public GridDisplay
{ public:
    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, int fs, int fe);
	
};

void ColoredStatus::Paint(Draw &w, int x, int y, int cx, int cy, const Value &val, dword style,
				           Color &fg, Color &bg, Font &fnt, bool found, int fs, int fe)
{
    if( StrInt(AsString(val)) >= 2451 )	bg = Color(0, 255, 0);	
    GridDisplay::Paint(w, x, y, cx, cy, val, style, fg, bg, fnt, found, fs, fe);
} 

But now I would like to apply it to others columns, each with its own color. So I would pass to the previous class a parameter and then by a switch select the right color.
But how to do it? Single seems to refuse a parameter.
Otherwise I need to declare 4 similar classes one for each column... or maybe wait until AttrText is operative Smile

Luigi
Re: GridCtrl and AttrText [message #9060 is a reply to message #9058] Sun, 15 April 2007 23:48 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

forlano wrote on Sun, 15 April 2007 15:56


Sorry, but I've not understood your recipe.


That's ok. I should have desctibed it better Smile
Quote:


I used the following code to color the cell of a column and it works
class ColoredStatus : public GridDisplay
{ public:
    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, int fs, int fe);
	
};

void ColoredStatus::Paint(Draw &w, int x, int y, int cx, int cy, const Value &val, dword style,
				           Color &fg, Color &bg, Font &fnt, bool found, int fs, int fe)
{
    if( StrInt(AsString(val)) >= 2451 )	bg = Color(0, 255, 0);	
    GridDisplay::Paint(w, x, y, cx, cy, val, style, fg, bg, fnt, found, fs, fe);
} 

But now I would like to apply it to others columns, each with its own color. So I would pass to the previous class a parameter and then by a switch select the right color.


There is a col variable accesible in GridDisplay class that you can use to deterimine painted column
void ColoredStatus::Paint(Draw &w, int x, int y, int cx, int cy, const Value &val, dword style,
				           Color &fg, Color &bg, Font &fnt, bool found, int fs, int fe)
{
    if( StrInt(AsString(val)) >= 2451 )	bg = Color(0, 255, 0);	
    if(col == 0) bg = Red;
    if(col == 1) bg = Yellow;
    GridDisplay::Paint(w, x, y, cx, cy, val, style, fg, bg, fnt, found, fs, fe);
} 

Quote:


or maybe wait until AttrText is operative Smile


It's in uvs now Smile Get it and try it. It should work (it was not tested) Wink
Re: GridCtrl and AttrText [message #9061 is a reply to message #9060] Mon, 16 April 2007 00:19 Go to previous message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
unodgs wrote on Sun, 15 April 2007 23:48


There is a col variable accesible in GridDisplay class that you can use to determine painted column



Very good, this is what I needed.
Thanks a lot!

Luigi
Previous Topic: GridCtrl and mingw compiler error
Next Topic: SqlArray: mouse selection
Goto Forum:
  


Current Time: Thu Mar 28 15:24:21 CET 2024

Total time taken to generate the page: 0.01428 seconds