Images in Columns of PtTree widget

Hi,
I created a PtTree widget with several columns. I display images in the
columns. Does anybody know how to change the image of a specific column in
a row. It is no problem with text, but I did not find anything in the docs
about images.
Frank

Frank <frank.sczech@soudronic.com> wrote:

I created a PtTree widget with several columns. I display images in the
columns. Does anybody know how to change the image of a specific column in
a row. It is no problem with text, but I did not find anything in the docs
about images.

PtTree chooses the image by calling the image selection function
(Pt_ARG_TREE_COLUMN_IMGFUN). The default function looks at the item’s
flags and the column’s iflags. Typically, you use one of the “user
flags” (Pt_LIST_ITEM_FLAG_USER1…4). When you want to change the image
in an item, just change its flags and call PtTreeDamageItem().

Oops, sorry, there’s no PtTreeDamageItem()… Just call
PtGenTreeDamageItem() instead:

item->gen.list.flags ^= Pt_LIST_ITEM_FLAG_USER1;
PtGenTreeDamageItem( ABW_tree, &item->gen );

Wojtek Lerch wrote:


PtTree chooses the image by calling the image selection function
(Pt_ARG_TREE_COLUMN_IMGFUN). The default function looks at the item’s
flags and the column’s iflags. Typically, you use one of the “user
flags” (Pt_LIST_ITEM_FLAG_USER1…4). When you want to change the image
in an item, just change its flags and call PtTreeDamageItem().

Oops, sorry, there’s no PtTreeDamageItem()… Just call
PtGenTreeDamageItem() instead:

item->gen.list.flags ^= Pt_LIST_ITEM_FLAG_USER1;
PtGenTreeDamageItem( ABW_tree, &item->gen );

Thanks for the input!
Unfortunately this seems to react differently in my software:
When I set the Pt_LIST_ITEM_FLAG_USER1, the first column will be set, if I
set the flag 2, the second column will be set and so on. Funny!
Any ideas?
Cheers,
Frank

Frank <frank.sczech@soudronic.com> wrote:

Wojtek Lerch wrote:



PtTree chooses the image by calling the image selection function
(Pt_ARG_TREE_COLUMN_IMGFUN). The default function looks at the item’s
flags and the column’s iflags. Typically, you use one of the “user
flags” (Pt_LIST_ITEM_FLAG_USER1…4). When you want to change the image
in an item, just change its flags and call PtTreeDamageItem().

Oops, sorry, there’s no PtTreeDamageItem()… Just call
PtGenTreeDamageItem() instead:

item->gen.list.flags ^= Pt_LIST_ITEM_FLAG_USER1;
PtGenTreeDamageItem( ABW_tree, &item->gen );



Thanks for the input!
Unfortunately this seems to react differently in my software:

Um… Differently from what?.. :slight_smile:

When I set the Pt_LIST_ITEM_FLAG_USER1, the first column will be set, if I
set the flag 2, the second column will be set and so on. Funny!

It’s hard to tell whether that’s unexpected or not without seeing the
code that sets up the column attributes.

Wojtek Lerch wrote:


Um… Differently from what?.. > :slight_smile:
From what I expected > :astonished:> )

I expected to set the first column with these flags but as described I set
the column 1 with the flag 1, column 2 with the flag 2…


It’s hard to tell whether that’s unexpected or not without seeing the
code that sets up the column attributes.

Heres my code:

static const PtTreeColumnAttributes_t colAttributes[3] =
{
{images, 4, Pt_TREE_COLUMN_NOCB, Pt_LIST_ITEM_FLAG_USER1},
{images, 4, Pt_TREE_COLUMN_NOCB, Pt_LIST_ITEM_FLAG_USER1},
{images, 4, Pt_TREE_COLUMN_NOCB, Pt_LIST_ITEM_FLAG_USER1},
};
static const PtListColumnAttributes_t colAtt[3] =
{
{Pt_LIST_COLUMN_NO_STRING},
{Pt_LIST_COLUMN_NO_STRING},
{Pt_LIST_COLUMN_NO_STRING},
};

for(int iLoop = 0; iLoop < 3; iLoop++)
{
columnPos[iLoop].from = iLoop * 140;
columnPos[iLoop].to = iLoop * 140 + 140;
pcolumnPos[iLoop] = &columnPos[iLoop];
}

PtSetArg(arg, Pt_ARG_LIST_COLUMN_POS, columnPos, 3);
PtSetResources(ABW_PtOverviewQualResults, 1, arg);
PtSetResource (ABW_PtOverviewQualResults,
Pt_ARG_LIST_COLUMN_ATTR, colAtt, 3);
PtSetResource(ABW_PtOverviewQualResults,
Pt_ARG_TREE_COLUMN_ATTR, colAttributes, 3);

// Now I add Tree Items in a for loop (Missing here)
pTreeSegments[iOrderIdx][iSeamIdx][0]
= PtTreeAllocItem(ABW_PtOverviewQualResults, pchSegment, nSeamOK,
nSeamOK);

//Just for test purposes I set different flags
if(iSeamIdx < 2)
{
pTreeSegments[iOrderIdx][iSeamIdx][0]->gen.list.flags =
Pt_LIST_ITEM_FLAG_USER1;
}
else
{
pTreeSegments[iOrderIdx][iSeamIdx][0]->gen.list.flags =
Pt_LIST_ITEM_FLAG_USER3 | Pt_LIST_ITEM_FLAG_USER2;
}

PtTreeAddFirst(ABW_PtOverviewQualResults
, pTreeSegments[iOrderIdx][iSeamIdx][0]
, pTreeSeams[iOrderIdx][iSeamIdx]);


I just do not now how to access the images of single columns correctly.

Frank

Frank <f@rank.com> wrote:

Wojtek Lerch wrote:



Um… Differently from what?.. > :slight_smile:
From what I expected > :astonished:> )

I expected to set the first column with these flags but as described I set
the column 1 with the flag 1, column 2 with the flag 2…



It’s hard to tell whether that’s unexpected or not without seeing the
code that sets up the column attributes.

Heres my code:

static const PtTreeColumnAttributes_t colAttributes[3] =
{
{images, 4, Pt_TREE_COLUMN_NOCB, Pt_LIST_ITEM_FLAG_USER1},
{images, 4, Pt_TREE_COLUMN_NOCB, Pt_LIST_ITEM_FLAG_USER1},
{images, 4, Pt_TREE_COLUMN_NOCB, Pt_LIST_ITEM_FLAG_USER1},

This tells the widget to use flag 1 for all three columns. That’s not
what you wanted, is it?..

Also, all the columns use the same array of images. That’s fine if you
want every column to use the same set of images; but why do you have
four images in that array? The default image selector function will
never go beyond the first two.

I just do not now how to access the images of single columns correctly.

The easiest way is by assigning a different flag to each column:

static const PtTreeColumnAttributes_t colAttributes[3] =
{
{ images1, 2, Pt_TREE_COLUMN_NOCB, Pt_LIST_ITEM_FLAG_USER1 },
{ images2, 2, Pt_TREE_COLUMN_NOCB, Pt_LIST_ITEM_FLAG_USER2 },
{ images3, 2, Pt_TREE_COLUMN_NOCB, Pt_LIST_ITEM_FLAG_USER3 },