Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » How to Setup ArrayCtrl colors ?
How to Setup ArrayCtrl colors ? [message #16874] |
Fri, 18 July 2008 19:20  |
|
How to Setup ArrayCtrl colors?
I need to setup ArrayCtrl color and current line color.
SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
|
|
|
|
|
Re: How to Setup ArrayCtrl colors ? [message #18461 is a reply to message #16907] |
Thu, 02 October 2008 06:44   |
|
Solved.
SColorPaper_Write(Color(205,205,205));
SColorHighlight_Write(Color(85,85,85));
SColorHighlightText_Write(Color(255,255,255));
static HeaderCtrl::Style s = HeaderCtrl::StyleDefault();
s.look[0] = Color(130,125,125);
types.HeaderObject().SetStyle(s);
types.OddRowColor(Color(205,205,205),Color(85,85,85));
types.EvenRowColor(Color(205,205,205),Color(85,85,85));
types.GridColor(Color(80,80,80));
SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
|
|
|
Re: How to Setup ArrayCtrl colors ? [message #18577 is a reply to message #18461] |
Fri, 10 October 2008 10:06   |
TeCNoYoTTa
Messages: 138 Registered: July 2008 Location: Egypt
|
Experienced Member |

|
|
sergeynikitin wrote on Thu, 02 October 2008 06:44 | Solved.
SColorPaper_Write(Color(205,205,205));
SColorHighlight_Write(Color(85,85,85));
SColorHighlightText_Write(Color(255,255,255));
static HeaderCtrl::Style s = HeaderCtrl::StyleDefault();
s.look[0] = Color(130,125,125);
types.HeaderObject().SetStyle(s);
types.OddRowColor(Color(205,205,205),Color(85,85,85));
types.EvenRowColor(Color(205,205,205),Color(85,85,85));
types.GridColor(Color(80,80,80));
|
can you explain more .......where must i put this code ??
|
|
|
|
Re: How to Setup ArrayCtrl colors ? [message #18579 is a reply to message #18578] |
Fri, 10 October 2008 12:41   |
Oblivion
Messages: 1204 Registered: August 2007
|
Senior Contributor |
|
|
Quote: |
i want to set a color and then add a row with this color then change it and add another row with another color ......how can i do that ?
|
You can use Display structure and SetDisplay() method to set column colors and content:
First you should add a Display object. For example:
struct Column1Display : Display {
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
{
w.DrawRect(r, Color(500,0,0));
}
};
struct Column2Display : Display {
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
{
w.DrawRect(r, Color(0,500,0));
}
};
Then, Set the Display of the column, using ArrayCtrl::Column::SetDisplay() or Array::SetDisplay() in your constructor or wherever you instantiate your ArrayCtrl object:
MyApp::MyApp()
{
//.....
//.....
MyArray.AddColumn("Column 1").SetDisplay(Single<Column1Display>());
MyArray.AddColumn("Column 2").SetDisplay(Single<Column2Display>());
}
This will set the "column 1" and "column 2" colors. You can set other columns' displays as such. As you may have noticed, by using the Display structure you can also do other specific operations on a single column (eg, adding images, changing background, fonts, etc.). Display also has a virtual PaintBackground() method which you can set background seperately See Display structure for more information.
Regards.
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Fri, 10 October 2008 13:08] Report message to a moderator
|
|
|
Re: How to Setup ArrayCtrl colors ? [message #18581 is a reply to message #18579] |
Fri, 10 October 2008 13:23   |
TeCNoYoTTa
Messages: 138 Registered: July 2008 Location: Egypt
|
Experienced Member |

|
|
Oblivion wrote on Fri, 10 October 2008 12:41 |
Quote: |
i want to set a color and then add a row with this color then change it and add another row with another color ......how can i do that ?
|
You can use Display structure and SetDisplay() method to set column colors and content:
First you should add a Display object. For example:
struct Column1Display : Display {
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
{
w.DrawRect(r, Color(500,0,0));
}
};
struct Column2Display : Display {
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
{
w.DrawRect(r, Color(0,500,0));
}
};
Then, Set the Display of the column, using ArrayCtrl::Column::SetDisplay() or Array::SetDisplay() in your constructor or wherever you instantiate your ArrayCtrl object:
MyApp::MyApp()
{
//.....
//.....
MyArray.AddColumn("Column 1").SetDisplay(Single<Column1Display>());
MyArray.AddColumn("Column 2").SetDisplay(Single<Column2Display>());
}
This will set the "column 1" and "column 2" colors. You can set other columns' displays as such. As you may have noticed, by using the Display structure you can also do other specific operations on a single column (eg, adding images, changing background, fonts, etc.). Display also has a virtual PaintBackground() method which you can set background seperately See Display structure for more information.
Regards.
|
thanxxxxxxxxx alot ......but i think that you are talking about columns colors ......but i want to color rows background not columns
thx again
|
|
|
|
|
|
|
|
|
Re: How to Setup ArrayCtrl colors ? [message #18589 is a reply to message #18588] |
Fri, 10 October 2008 16:15   |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
You can set the display for individual cells in an ArrayCtrl with
void SetDisplay(int i, int col, const Display& d);
then you just have to iterate through the columns to set each cell on a row.
And an easier way of getting colored displays:
template <const int COLOR>
class ColorDisplayTemplate : public Display
{
virtual void Paint(Draw& w, const Rect& r, const Value& q,
Color ink, Color paper, dword style) const
{ StdDisplay().Paint(w, r, q, ink, Color::FromRaw(COLOR), style); }
};
const Display &RedDisplay() { return Single< ColorDisplayTemplate<RGB(255, 0, 0)> >(); }
const Display &BlueDisplay() { return Single< ColorDisplayTemplate<RGB(0, 0, 255)> >(); }
const Display &GreenDisplay() { return Single< ColorDisplayTemplate<RGB(0, 255, 0)> >(); }
A template? Is not it a bit brutal? 
What about a nice little Color attribute (and perhaps global variables instead of Single)?
Mirek
[Updated on: Sat, 11 October 2008 00:10] by Moderator Report message to a moderator
|
|
|
|
Re: How to Setup ArrayCtrl colors ? [message #18594 is a reply to message #18591] |
Fri, 10 October 2008 21:29   |
Oblivion
Messages: 1204 Registered: August 2007
|
Senior Contributor |
|
|
Quote: |
thanks alot ....... but this dont color the whole cell
it leaves some parts uncolored .....how can i fix this problem ??
|
That part is background. You should handle background too. Same as Paint (You can safely apply the below code to Mrjt's code).
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
{
w.DrawRect(r, SColorInfo);
w.DrawText(r.left, r.top, q.ToString());
}
virtual void PaintBackground(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
{
w.DrawRect(r, SColorInfo);
}
}
But if you paint background manually, you should handle "highlighted state" of cell manually too.
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Fri, 10 October 2008 21:33] Report message to a moderator
|
|
|
|
|
Re: How to Setup ArrayCtrl colors ? [message #18790 is a reply to message #18755] |
Tue, 21 October 2008 09:50   |
|
How do I change the color of the paper only on the current window.
I tried
SColorPaper_Write (color (205205205)),
however, change the background color of the full application.
I need to change the color of the paper at 1 window.
SetDisplay - is not suitable as it will not change the background color ArrayCtrl where no lines.
SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
[Updated on: Tue, 21 October 2008 09:55] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon Apr 28 17:59:34 CEST 2025
Total time taken to generate the page: 0.04346 seconds
|