PtTree: individual colors for items

I populate the items in a PtTree widget by a series of calls to
PtTreeCreateItem(my_tree_widge, label, attributes) where label and
attributes are modified for each item. “label” is just a string but
“attributes” is a pointer to a PtTreeItemAttributes_t struct. The
latter contains a PtGenListItemAttrs_t list which, in turn, defines
the font for “label” and the text and fill colors for the cases of
item unselected and selected – the latter via a pair of
PtGenListColorSet_t structs.

My problem: it appears that only one of the font and color set
combinations are applied. Since each element of the tree gets its
very own PtTreeItem_t pointer, I thought each could be given a
specific color to help recognize groups of related items. Not true?
(To deepen the mystery, it isn’t the last-applied PtGenListColorSet_t
nor the first but the second.)

rlb wrote:

I populate the items in a PtTree widget by a series of calls to
PtTreeCreateItem(my_tree_widge, label, attributes) where label and
attributes are modified for each item. “label” is just a string but

“Modified”? PtTreeCreateItem() makes a copy of the string but not the
attributes; you’re not supposed to modify an attributes structure after
you’ve given its address to an item. You’re allocating a new structure
for each item, correct? Reusing the same structure, filled with
different values, for all items is not meant to work.

“attributes” is a pointer to a PtTreeItemAttributes_t struct. The
latter contains a PtGenListItemAttrs_t list which, in turn, defines
the font for “label” and the text and fill colors for the cases of
item unselected and selected – the latter via a pair of
PtGenListColorSet_t structs.

My problem: it appears that only one of the font and color set
combinations are applied. Since each element of the tree gets its
very own PtTreeItem_t pointer, I thought each could be given a
specific color to help recognize groups of related items. Not true?

Yes, that’s the idea, provided you indeed give each item a different
pointer.

(To deepen the mystery, it isn’t the last-applied PtGenListColorSet_t
nor the first but the second.)

This does sound strange…

I hear you…
I’ve already changed the item generation (back) to PtTreeAllocItem()
for the sake of simplicity. Then, when a tree entry is clicked, the
callback function revises Pt_ARG_SELECTION_FILL_COLOR as needed.

So I get the effect I want although I wish font and select/unselect
colors could be set per tree item rather than the PtTree as a whole.

Thanks again Wojtech.

rlb wrote:

So I get the effect I want although I wish font and select/unselect
colors could be set per tree item rather than the PtTree as a whole.

They can. Try the attached application – it should display its tree
items with three different sets of font and colours. Doesn’t it work
for you?

“Try the attached application.”
OK, I know I’m not a Forum super-user but what attachment?

“rlb” <robert.bottemiller@fmcti-dot-com.no-spam.invalid> wrote in message
news:dhcfbh$e8c$1@inn.qnx.com

“Try the attached application.”
OK, I know I’m not a Forum super-user but what attachment?

Well, I’m not a Forum user at all, and have no idea if it allows you to
access attachments; but if you use NNTP to inn.qnx.com directly, you should
see it in your newsreader. Outlook Express under Windows and Mozilla under
Neutrino seem to work for me.

hmm,

Setting text color for unselected and text and background color
selected entries works. However the background for unselected items
is always white.
Do I need to set any special Resources for background color of
unselected items to work?

Regards Tino

Designing a tree entry requires text, its font and pairs of colors for
the text and its background in the unselected and selected cases.
Experimenting with both PhAB widget Resource tab and setting
properties in code, I come to this conclusion:

  1. Specifying the unselected fill color in code doesn’t work. (Right
    you are SmeeAgain.) This is the PgColor_t quantity “fill” in the
    PtGenListColorSet_t struct forming the “unselected colors” slot in a
    PtGenListItemAttrs_t entry inside the PtTreeItemAttributes_t struct
    which is an argument in the PtTreeCreateItem() call.

  2. What you see as the unselected background color is labeled “Color:
    Item Background” in the PhAB widget Resource tab or
    Pt_ARG_TREE_LINE_COLOR in the help balloon.

  3. In the space between tree items, the Resource tab “Color: Fill”
    value (Pt_ARG_FILL_COLOR) seems to be used.

#1 looks like a genuine bug.

rlb wrote:

  1. Specifying the unselected fill color in code doesn’t work. (Right
    you are SmeeAgain.) This is the PgColor_t quantity “fill” in the
    PtGenListColorSet_t struct forming the “unselected colors” slot in a
    PtGenListItemAttrs_t entry inside the PtTreeItemAttributes_t struct
    which is an argument in the PtTreeCreateItem() call.

#1 looks like a genuine bug.

Indeed.