Discussion:
[MSEide-MSEgui-talk] Different font and image color selected row in twidgetgrid
Krzysztof
2017-04-09 18:46:10 UTC
Permalink
Hi Martin,

Two questions:
1. How to change font color for selected row in twidgetgrid
(ttreeitemedit)? From tscincontroller. Is there any definded color which I
can override by setcolormapvalue()? Something like cl_gridselectedtext?
2. Is it possible to set different image for selected row in ttreeitemedit?
My icons are dark and I would like to set them as "negative" color when
selected. So it should be also from different timagelist (which I init with
brighter color). Or some trick to do this on the fly when image is painted.

This is only cosmetic, don't bother if this is too much work.

Regards
Martin Schreiber
2017-04-10 11:36:06 UTC
Permalink
Post by Krzysztof
Hi Martin,
1. How to change font color for selected row in twidgetgrid
(ttreeitemedit)? From tscincontroller. Is there any definded color which I
can override by setcolormapvalue()? Something like cl_gridselectedtext?
T*Grid.Datacols has FontSelect and FontActiveNum/FontFocusedNum which select
an item in T*Grid.RowFonts. Please use TSkinController.OnAfterUpdate in order
to set them. If you solely want to change the font color it is also possible
to setup the fonts at design time and to define the color by a user color
(cl_user0..cl_user19) where the rgb value can be defined by
TSkinController.Colors[n]. The designtime rgb-values of cl_user0..cl_user19
can be defined in 'Project'-'Options'-'User Colors'.
Post by Krzysztof
2. Is it possible to set different image for selected row in ttreeitemedit?
My icons are dark and I would like to set them as "negative" color when
selected. So it should be also from different timagelist (which I init with
brighter color). Or some trick to do this on the fly when image is painted.
The selected imagelist item is defined by the sum of
TTreeItemEdit.ItemList.Imnr_* + the image number of the datanode. TimageList
can have a lookup table ("IndexLookup") in order to save duplicate images.
On the fly drawing is possible with grid.DataCols[n].OnBeforeDrawcell,
OnDrawcell and OnAfterDrawcell and T*EditWidget.OnBeforePaint, OnPaint and
OnAfterPaint.

Martin
Krzysztof
2017-04-11 19:45:03 UTC
Permalink
Post by Krzysztof
Post by Krzysztof
2. Is it possible to set different image for selected row in
ttreeitemedit?
Post by Krzysztof
My icons are dark and I would like to set them as "negative" color when
selected. So it should be also from different timagelist (which I init
with
Post by Krzysztof
brighter color). Or some trick to do this on the fly when image is
painted.
The selected imagelist item is defined by the sum of
TTreeItemEdit.ItemList.Imnr_* + the image number of the datanode. TimageList
can have a lookup table ("IndexLookup") in order to save duplicate images.
Can you explain this? Lets say that I have timagelist1 which contain images
for normal grid state, initialized with timagelist1.bitmap.init(cl_black)
or any other color and second timagelist2 which contain exactly same images
but for selected state and are initialized with
timagelist2.bitmap.init(cl_white) or any other color. Now, how to make them
work with grid (ttreeitemedit)? Is it possible to have only one timagelist
and init different color per image, not per whole timagelist? Because I
think that for IndexLookup I have to use only one timagelist.

Note that I'm creating images at runtime with mseftglyphs and base color
cl_black. It depends on user which color scheme he choice (that is why
timagelist.bitmap.init() is called)

P.S. It is really cosmetic think, so don't bother with that. I'm just
curious :)
Martin Schreiber
2017-04-12 06:16:38 UTC
Permalink
Post by Krzysztof
Can you explain this? Lets say that I have timagelist1 which contain images
for normal grid state, initialized with timagelist1.bitmap.init(cl_black)
or any other color and second timagelist2 which contain exactly same images
but for selected state and are initialized with
timagelist2.bitmap.init(cl_white) or any other color. Now, how to make them
work with grid (ttreeitemedit)? Is it possible to have only one timagelist
and init different color per image, not per whole timagelist? Because I
think that for IndexLookup I have to use only one timagelist.
Correct.
Post by Krzysztof
Note that I'm creating images at runtime with mseftglyphs and base color
cl_black. It depends on user which color scheme he choice (that is why
timagelist.bitmap.init() is called)
Instead to fill the whole imagelist pixmap you need to color the individual
images. Example for two colors, every glyph has been added twice:
"
var
co1,co2: colorty;
i1: int32;
bmp1: tmaskedbitmap;
begin
[...] setup co1 and co2

bmp1:= tmaskedbitmap.create(bmk_rgb);
bmp1.options:= [bmo_masked,bmo_graymask];
with timagelist1 do begin
bmp1.size:= size;
for i1:= 0 to count - 1 do begin
getimage(i1,bmp1);
if odd(i1) then begin
bmp1.init(co2);
end
else begin
bmp1.init(co1);
end;
setimage(i1,bmp1);
end;
end;
bmp1.destroy();
end;
"

Martin
Krzysztof
2017-04-12 17:47:12 UTC
Permalink
Great, seems doable but can't understand ttreeitemedit1.itemlist.imnr_X
policy. Can you explain that too?
Martin Schreiber
2017-04-13 04:35:04 UTC
Permalink
Post by Krzysztof
Great, seems doable but can't understand ttreeitemedit1.itemlist.imnr_X
policy. Can you explain that too?
The actual image number is the sum of the node image number and the state
values either direct or the lookup value provided by TImageList.ImageLookup
if it is not empty.
Assume an empty ImageLookup property, ItemList.imnr_selected = 1, -> the image
number of a not selected node is the value in TListItem.imagenr, for a
selected node it is TListItem.imagenr + 1.
Maybe there also should be imnr_active and imnr_focused for you.

Martin
Krzysztof
2017-04-13 11:14:06 UTC
Permalink
Post by Martin Schreiber
The actual image number is the sum of the node image number and the state
values either direct or the lookup value provided by TImageList.ImageLookup
if it is not empty.
Assume an empty ImageLookup property, ItemList.imnr_selected = 1, -> the image
number of a not selected node is the value in TListItem.imagenr, for a
selected node it is TListItem.imagenr + 1
Weird, seems that it is TListItem.imagenr + 2. This is my sets of icons:

type
TIco16 = (
ico16_main, ico16_news, ico16_user, .....

FLibraryNode.imagenr := ord(ico16_main);
ttreeitemedit1.itemlist.insert(0,FLibraryNode);

and selected:
ttreeitemedit1.itemlist.imnr_selected := 1;

but when selecting node then I see icon ico16_user instead of ico16_news.
No other imnr_ are set.

Maybe there also should be imnr_active and imnr_focused for you.


Not necessary (for now ;) )
Martin Schreiber
2017-04-13 11:25:25 UTC
Permalink
Post by Krzysztof
Post by Martin Schreiber
The actual image number is the sum of the node image number and the state
values either direct or the lookup value provided by
TImageList.ImageLookup if it is not empty.
Assume an empty ImageLookup property, ItemList.imnr_selected = 1, -> the image
number of a not selected node is the value in TListItem.imagenr, for a
selected node it is TListItem.imagenr + 1
type
TIco16 = (
ico16_main, ico16_news, ico16_user, .....
FLibraryNode.imagenr := ord(ico16_main);
ttreeitemedit1.itemlist.insert(0,FLibraryNode);
ttreeitemedit1.itemlist.imnr_selected := 1;
but when selecting node then I see icon ico16_user instead of ico16_news.
No other imnr_ are set.
Please send the testcase.

Martin
Krzysztof
2017-04-13 18:56:24 UTC
Permalink
Ok I was able to cut off fragment from my project with a small modify.
Attached
Krzysztof
2017-04-13 19:00:10 UTC
Permalink
Noticed that I had unsaved project before zipping it. Please download again
from attachment
Martin Schreiber
2017-04-14 06:31:27 UTC
Permalink
Post by Krzysztof
Noticed that I had unsaved project before zipping it. Please download again
from attachment
A copy-paste error more than 10 years ago, sorry. Please try again with git
master f003fd1c37fb5a1ff787798d99286249b8a98177.

Martin
Krzysztof
2017-04-14 10:43:01 UTC
Permalink
Thanks a lot! Only one thing left, the expand box aka arrow :D . It it also
possible change image when node is selected? Attached updated example and
screenshot
Martin Schreiber
2017-04-14 11:55:47 UTC
Permalink
Post by Krzysztof
Thanks a lot! Only one thing left, the expand box aka arrow :D . It it also
possible change image when node is selected? Attached updated example and
screenshot
It uses itemlist.colorglyph (not published up to now). I can add
colorglyphactive but it does not help because you change stockobjects.glyphs
from monochrome to rgb where glyph color has no meaning.

Martin
Krzysztof
2017-04-14 15:57:44 UTC
Permalink
Post by Martin Schreiber
Post by Krzysztof
Thanks a lot! Only one thing left, the expand box aka arrow :D . It it
also
Post by Krzysztof
possible change image when node is selected? Attached updated example and
screenshot
It uses itemlist.colorglyph (not published up to now). I can add
colorglyphactive but it does not help because you change
stockobjects.glyphs
from monochrome to rgb where glyph color has no meaning.
Yes, I'm overriding stock glyphs with RGB fontawesome. Is there any other
trick which don't need messup code on your side?
Martin Schreiber
2017-04-14 16:11:20 UTC
Permalink
Post by Krzysztof
Post by Martin Schreiber
Post by Krzysztof
Thanks a lot! Only one thing left, the expand box aka arrow :D . It it
also
Post by Krzysztof
possible change image when node is selected? Attached updated example
and screenshot
It uses itemlist.colorglyph (not published up to now). I can add
colorglyphactive but it does not help because you change
stockobjects.glyphs
from monochrome to rgb where glyph color has no meaning.
Yes, I'm overriding stock glyphs with RGB fontawesome. Is there any other
trick which don't need messup code on your side?
No, I'll need to add imagelist properties to t*itemlist. Should be doable.

Martin
Krzysztof
2017-04-16 00:21:23 UTC
Permalink
Ah and another question. What if some node doesn't have image and should
not have any selected image neither? Is it safe to set:

constructor TDataNode.create(const aowner: tcustomitemlist;
const aparent: ttreelistitem);
begin
inherited create(aowner, aparent);

imagenr := imagelist.count * (-1);
FId := -1;
FFilename := '';
end;
Martin Schreiber
2017-04-16 05:17:03 UTC
Permalink
Post by Krzysztof
Ah and another question. What if some node doesn't have image and should
constructor TDataNode.create(const aowner: tcustomitemlist;
const aparent: ttreelistitem);
begin
inherited create(aowner, aparent);
imagenr := imagelist.count * (-1);
FId := -1;
FFilename := '';
end;
Or
"
imagenr:= -bigint
"

Martin
Krzysztof
2017-04-17 17:59:53 UTC
Permalink
Post by Martin Schreiber
Or
"
imagenr:= -bigint
Right, I just wanted be sure if negative values are not reserved for
something
Martin Schreiber
2017-04-16 07:53:08 UTC
Permalink
Post by Martin Schreiber
Post by Krzysztof
Post by Martin Schreiber
Post by Krzysztof
Thanks a lot! Only one thing left, the expand box aka arrow :D . It it
also
Post by Krzysztof
possible change image when node is selected? Attached updated example
and screenshot
It uses itemlist.colorglyph (not published up to now). I can add
colorglyphactive but it does not help because you change
stockobjects.glyphs
from monochrome to rgb where glyph color has no meaning.
Yes, I'm overriding stock glyphs with RGB fontawesome. Is there any other
trick which don't need messup code on your side?
No, I'll need to add imagelist properties to t*itemlist. Should be doable.
git master 266e2400313faabe0a88a3ff41542a0d904cb5b9 has versions in timagelist
(experimental).
Please do
"
procedure TIconManager.LoadFAIcons;
[...]
for i24:=Low(ICONS_24) to High(ICONS_24) do
_Add(ICONS_24[i24].I, cl_default, 0, 0, ICONS_24[i24].S);
stockobjects.glyphs.versioncount:= 2;
stockobjects.glyphs.bitmaps[1].init(cl_white);
"
and set frmViewTree1:ttreeitemedit1.itemlist.boxglyph_versionactive to 1.

Martin
Krzysztof
2017-04-17 18:02:55 UTC
Permalink
Post by Martin Schreiber
git master 266e2400313faabe0a88a3ff41542a0d904cb5b9 has versions in timagelist
(experimental).
Please do
"
procedure TIconManager.LoadFAIcons;
[...]
for i24:=Low(ICONS_24) to High(ICONS_24) do
_Add(ICONS_24[i24].I, cl_default, 0, 0, ICONS_24[i24].S);
stockobjects.glyphs.versioncount:= 2;
stockobjects.glyphs.bitmaps[1].init(cl_white);
"
and set frmViewTree1:ttreeitemedit1.itemlist.boxglyph_versionactive to 1.
Many thanks! Noticed something strange after this update. See attached
screens. Root lines appears on selected nodes, I don't think they were
earlier
Martin Schreiber
2017-04-18 06:17:39 UTC
Permalink
Post by Krzysztof
Many thanks! Noticed something strange after this update. See attached
screens. Root lines appears on selected nodes, I don't think they were
earlier
There is a new property ttreeitemedit.itemlist.colorlineactive. Please set it
to cl_none.

Martin
Krzysztof
2017-04-19 11:38:43 UTC
Permalink
Post by Martin Schreiber
There is a new property ttreeitemedit.itemlist.colorlineactive. Please set it
to cl_none.
Thanks!

Martin Schreiber
2017-04-14 06:02:09 UTC
Permalink
Post by Martin Schreiber
Post by Krzysztof
Great, seems doable but can't understand ttreeitemedit1.itemlist.imnr_X
policy. Can you explain that too?
The actual image number is the sum of the node image number and the state
values either direct or the lookup value provided by TImageList.ImageLookup
if it is not empty.
Assume an empty ImageLookup property, ItemList.imnr_selected = 1, -> the
image number of a not selected node is the value in TListItem.imagenr, for
a selected node it is TListItem.imagenr + 1.
Maybe there also should be imnr_active and imnr_focused for you.
Done, git master bedb32e46c5eff2f9c5db55bf32d7d2712767e47.

Martin
Loading...