Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » ColorScheme for individual cells
ColorScheme for individual cells [message #36150] |
Sat, 05 May 2012 13:57 |
piotr5
Messages: 107 Registered: November 2005
|
Experienced Member |
|
|
I had to modify ArrayCtrl.h and ArrayCtrl.cpp, to achieve what I want:
in ArrayCtrl.cpp I changed the lines marked with "+":
const Display& ArrayCtrl::GetCellInfo(int i, int j, bool f0,
Value& v, Color& fg, Color& bg, dword& st)
{
...
}
if(hasfocus)
st |= Display::FOCUS;
+ bg = BGColorInfo(i,j);
if(nobg)
bg = Null;
+ fg = FGColorInfo(i,j);
if((st & Display::SELECT) ||
!multiselect && (st & Display::CURSOR) && !nocursor ||
drop) {
...
ArrayCtrl::ArrayCtrl() {
+ ColorScheme=NULL;
in ArrayCtrl.h I added to the class ArrayCtrl:
public:
struct BGFGFunc {
virtual Color& BG (const ArrayCtrl* a, int i, int j) const=0;
virtual Color& FG (const ArrayCtrl* a, int i, int j) const=0;
};
BGFGFunc *ColorScheme;
protected:
const Color& BGColorInfo(int i, int j) const
{return ColorScheme ? ColorScheme->BG(this,i,j) :
(i & 1 ? evenpaper : oddpaper);}
const Color& FGColorInfo(int i, int j) const
{return ColorScheme ? ColorScheme->FG(this,i,j) :
(i & 1 ? evenink : oddink);}
has anybody suggestions how to do that any better?
as for application, I'd like to add duplicate entries into the array, and when they get selected all duplicates get selected too. but of course the user would like to see up front if a duplicate exists, so I colour them differently...
I did think about achieving the same with some richer text-display, but replacing the display for each cell seems a bit of overkill for this simple goal. any other ideas?
[Updated on: Sat, 05 May 2012 21:14] Report message to a moderator
|
|
|
|
|
Re: ColorScheme for individual cells [message #36274 is a reply to message #36267] |
Thu, 17 May 2012 18:10 |
nixnixnix
Messages: 415 Registered: February 2007 Location: Kelowna, British Columbia
|
Senior Member |
|
|
I don't see why you would need to change UPP code but perhaps I don't fully appreciate what you're trying to do. I override the Display class and add it to the ArrayCtrl using ArrayCtrl::SetDisplay().
I'll have to step aside and let someone with more UPP chops take it from here as I clearly don't get the issue. Seems to me like you can easily do everything you need to with Display.
Best regards,
Nick
|
|
|
Goto Forum:
Current Time: Sat Apr 20 11:44:07 CEST 2024
Total time taken to generate the page: 0.03562 seconds
|