Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » GridCtrl and AttrText
|
Re: GridCtrl and AttrText [message #9052 is a reply to message #9051] |
Sun, 15 April 2007 19:57 |
|
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 |
|
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
Luigi
|
|
|
Re: GridCtrl and AttrText [message #9060 is a reply to message #9058] |
Sun, 15 April 2007 23:48 |
|
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
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
|
It's in uvs now Get it and try it. It should work (it was not tested)
|
|
|
|
Goto Forum:
Current Time: Thu Mar 28 15:24:21 CET 2024
Total time taken to generate the page: 0.01428 seconds
|