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 Setup ArrayCtrl colors ?
Re: How to Setup ArrayCtrl colors ? [message #18791 is a reply to message #18790] Tue, 21 October 2008 14:27 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
This is not possible.

I think the closest you could get is to SetNoBackground() on the ArrayCtrl, and set the colour of the cells manually using any of the methods above. Not sure if this will work though.
Re: How to Setup ArrayCtrl colors ? [message #18794 is a reply to message #18791] Tue, 21 October 2008 19:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
In fact, NoBackground makes ArrayCtrl transparent - you can then put some other widget "behind".

If you want a solid color, put StaticRect behind. But it can also be picture or anything else Smile (Not also that StaticRect accepts "chameleon" visuals values, so you can put Image in it directly, with chameleon style hotspots..).

BTW, it also applies to EditFile, LineEdit, DocEdit, ColumnList and TreeCtrl Smile

Mirek

[Updated on: Tue, 21 October 2008 19:01]

Report message to a moderator

Re: How to Setup ArrayCtrl colors ? [message #18799 is a reply to message #18794] Wed, 22 October 2008 01:32 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

Thanks.

SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
Re: How to Setup ArrayCtrl colors ? [message #18811 is a reply to message #16874] Thu, 23 October 2008 19:56 Go to previous messageGo to next message
darki699 is currently offline  darki699
Messages: 3
Registered: October 2008
Location: Hell
Junior Member
sergeynikitin wrote on Fri, 18 July 2008 19:20

How to Setup ArrayCtrl colors?
I need to setup ArrayCtrl color and current line color.



This is pretty simple if you are willing to change ArrayCtrl just a bit... Wink

Step 1: In ArrayCtrl.h add this:
void SetRowDisplay(int i, const Display& d);
void SetColDisplay(int j, const Display& d);


Step 2: In ArrayCtrl.cpp add this:
void ArrayCtrl::SetRowDisplay(int i, const Display& d)
{
	if(i >= 0 && i < GetCount())
		for (int j = 0 ; j < GetSize().cx ; j++)	
			cellinfo.At(i).At(j).Set(d);
	RefreshRow(i);
}

void ArrayCtrl::SetColDisplay(int j, const Display& d)
{
	if (j >= 0 && j < column.GetCount())
		column[j].SetDisplay(d);
}


Step 3: In your program add this:
struct MyJDisplay : Display {
	virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
	{
		PaintBackground(w, r, q, Blend(ink, Color(0,0,0)) , Blend(paper, Color(0,0,0)), style);
		w.DrawText(r.left, r.top, q.ToString());
	}
};

For example... You can choose any color of course, but I really suggest you use Blend unless you want your Selected row to not-show.

and that's about it... Add your SetRowDisplay or SetColDisplay any way you like it. =)
If you want a nice look use this
Quote:


[your ArrayCtrl].AddColumn(column, column, columnSize).Margin(0)


when you add your column.

And an example of how I used it:
 UserMovies.SetRowDisplay(j , Single<MyJDisplay>());	


NJoy and remember that the code is not a god.
If you need to improve it, don't be afraid to add (backup everything first lol)

Darki699

[Updated on: Thu, 23 October 2008 19:57]

Report message to a moderator

Re: How to Setup ArrayCtrl colors ? [message #18940 is a reply to message #18811] Sat, 01 November 2008 23:37 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
darki699 wrote on Thu, 23 October 2008 13:56

sergeynikitin wrote on Fri, 18 July 2008 19:20

How to Setup ArrayCtrl colors?
I need to setup ArrayCtrl color and current line color.



This is pretty simple if you are willing to change ArrayCtrl just a bit... Wink

Step 1: In ArrayCtrl.h add this:
void SetRowDisplay(int i, const Display& d);
void SetColDisplay(int j, const Display& d);


Step 2: In ArrayCtrl.cpp add this:
void ArrayCtrl::SetRowDisplay(int i, const Display& d)
{
	if(i >= 0 && i < GetCount())
		for (int j = 0 ; j < GetSize().cx ; j++)	
			cellinfo.At(i).At(j).Set(d);
	RefreshRow(i);
}

void ArrayCtrl::SetColDisplay(int j, const Display& d)
{
	if (j >= 0 && j < column.GetCount())
		column[j].SetDisplay(d);
}




Or you can also define these as external functions (there is no private/procted stuff needed).

Personally, I would not add these methods to solve this issue, and I CAN DO IT EASILY:)

Mirek
Re: How to Setup ArrayCtrl colors ? [message #25102 is a reply to message #18589] Wed, 10 February 2010 17:36 Go to previous messageGo to next message
whiteman is currently offline  whiteman
Messages: 11
Registered: May 2009
Promising Member
I'm using an arrayctrl, in my application I need to set some cell color and i don't want to use AttrText: is too slow!
I have 200-300 cells and is the user that choose what color want to use, so, I can't use



SetDisplay(row, column, Single<MyColor<RGB(col.R, col.G, col.B)> >())

because an error say me that I must use costant value.
What should I do for set dinamically the color of my grid without
AttrText?
thank you!!
Re: How to Setup ArrayCtrl colors ? [message #25303 is a reply to message #25102] Tue, 16 February 2010 20:53 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
e.g.

.SetDisplay(row, column, ColorDisplay());
.Set(row, column, Color(...));
Previous Topic: Spanning Columns?
Next Topic: Cells appearance and text alignment
Goto Forum:
  


Current Time: Thu Mar 28 10:51:04 CET 2024

Total time taken to generate the page: 0.01372 seconds