Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » ArrayCtrl cell color
Re: ArrayCtrl cell color [message #3805 is a reply to message #892] |
Tue, 27 June 2006 20:13 |
|
forlano
Messages: 1185 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
hojtsy wrote on Tue, 07 February 2006 13:43 | Here is a dummy example
#include <CtrlLib/CtrlLib.h>
class NumbersOnRed : public Display
{
public:
static bool numberString(String s);
void PaintBackground(Draw& w, const Rect& r, const Value& q,
Color ink, Color paper, dword style) const;
};
bool NumbersOnRed::numberString(String s)
{
if(s.GetCount() == 0)
return false;
int i = 0;
if(s[0] == '+' || s[0] == '-')
i++;
while(i < s.GetCount() && s[i] >= '0' && s[i] <= '9')
i++;
return i == s.GetCount();
}
void NumbersOnRed::PaintBackground(Draw& w, const Rect& r, const Value& q,
Color ink, Color paper, dword style) const
{
if(IsNumber(q) || (IsString(q) && numberString(AsString(q))))
paper = Color(255, 150, 150);
Display::PaintBackground(w, r, q, ink, paper, style);
}
GUI_APP_MAIN
{
ArrayCtrl array;
array.AddColumn("value").SetDisplay(Single<NumbersOnRed>());
array.Add("test1");
array.Add("2test");
array.Add("3 test");
array.Add("4");
array.Add("test");
array.Add("-99");
TopWindow win;
win.Zoomable().Sizeable();
win.Add(array.SizePos());
win.Run();
}
Intention of PaintBackground is to provide a way for client code to customize the cell background color, including the margin background color, by redefining a method of Display. Previously the margin color was not customizable.
|
Today I used this example to color some cells of my ArrayCtrl. It worked very nice OK and there were no problems... except one detail: why it does work?
I know that is not important to understand to let the things to work... in contrast it is better very often do not know. But I'm very curious. Please forgive me for my silly questions but it is stronger than me to ask:
1) This line is very important:
array.AddColumn("value").SetDisplay(Single<NumbersOnRed>());
Now, SetDisplay is the method with arguments:
SetDisplay(int i¸ int j¸ const Display& d)
Instead I see "Single<NumbersOnRed>()" that does the job... but HOW? What is it?
2) The last stupid question. Is "q" the cell value? Where it has been defined?
Thank you for your patience,
Luigi
PS: if nobody answer I'll not complain
|
|
|
|
|
ArrayCtrl cell color
By: hojtsy on Wed, 01 February 2006 16:29
|
|
|
Re: ArrayCtrl cell color
By: mirek on Wed, 01 February 2006 17:59
|
|
|
Re: ArrayCtrl cell color
By: hojtsy on Thu, 02 February 2006 16:51
|
|
|
Re: ArrayCtrl cell color
By: mirek on Thu, 02 February 2006 20:43
|
|
|
Re: ArrayCtrl cell color
By: hojtsy on Thu, 02 February 2006 21:46
|
|
|
Re: ArrayCtrl cell color
By: mirek on Thu, 02 February 2006 22:10
|
|
|
Re: ArrayCtrl cell color
By: hojtsy on Thu, 02 February 2006 22:46
|
|
|
Re: ArrayCtrl cell color
By: mirek on Thu, 02 February 2006 23:11
|
|
|
Re: ArrayCtrl cell color
By: hojtsy on Fri, 03 February 2006 00:06
|
|
|
Re: ArrayCtrl cell color
By: mirek on Fri, 03 February 2006 14:29
|
|
|
Re: ArrayCtrl cell color
By: hojtsy on Fri, 03 February 2006 15:28
|
|
|
Re: ArrayCtrl cell color
By: mirek on Fri, 03 February 2006 16:38
|
|
|
Re: ArrayCtrl cell color
By: hojtsy on Fri, 03 February 2006 16:48
|
|
|
Re: ArrayCtrl cell color
By: mirek on Fri, 03 February 2006 17:56
|
|
|
Re: ArrayCtrl cell color
By: fudadmin on Mon, 06 February 2006 06:20
|
|
|
Re: ArrayCtrl cell color
By: hojtsy on Tue, 07 February 2006 13:43
|
|
|
Re: ArrayCtrl cell color
By: forlano on Tue, 27 June 2006 20:13
|
|
|
Re: ArrayCtrl cell color
By: hojtsy on Tue, 27 June 2006 22:06
|
|
|
Re: ArrayCtrl cell color
By: forlano on Wed, 28 June 2006 00:49
|
|
|
Re: ArrayCtrl cell color
|
|
|
Re: ArrayCtrl cell color
By: mirek on Wed, 28 June 2006 14:13
|
|
|
Re: ArrayCtrl cell color
By: forlano on Wed, 28 June 2006 16:26
|
|
|
Re: ArrayCtrl cell color
|
|
|
Re: ArrayCtrl cell color
By: mirek on Sun, 19 February 2006 23:48
|
Goto Forum:
Current Time: Tue May 14 08:42:52 CEST 2024
Total time taken to generate the page: 0.02935 seconds
|