PtGenListUnselect in PtRawList

Hi,
Is it possible to use PtGenListUnselect() in a PtRawlist’ selection
callback with Pt_ARG_SELECTION_MODE = Pt_MULTIPLE.

What to do if nothing happens?

Alain.

Alain Bonnefoy <alain.bonnefoy@icbt.com> wrote:

Is it possible to use PtGenListUnselect() in a PtRawlist’ selection
callback with Pt_ARG_SELECTION_MODE = Pt_MULTIPLE.

It should be… I presume it doesn’t work for you – does it seem to
depend on selection subtype (BROWSE vs FINAL vs CANCEL) or event type
(PRESS vs RELEASE vs KEY)?

What are the values of item->flags just before and just after the call
to PtGenListUnselect()?


Wojtek Lerch QNX Software Systems Ltd.

It was because I didn’t do it when Pt_LIST_SELECTION_FINAL

I have another problem; does PgSetFillColor() really taken in account in
a list’s draw function?

Would it be possible to get a different background color for each line?

Alain.


Wojtek Lerch a écrit:

Alain Bonnefoy <> alain.bonnefoy@icbt.com> > wrote:


Is it possible to use PtGenListUnselect() in a PtRawlist’ selection
callback with Pt_ARG_SELECTION_MODE = Pt_MULTIPLE.



It should be… I presume it doesn’t work for you – does it seem to
depend on selection subtype (BROWSE vs FINAL vs CANCEL) or event type
(PRESS vs RELEASE vs KEY)?

What are the values of item->flags just before and just after the call
to PtGenListUnselect()?

Alain Bonnefoy <alain.bonnefoy@icbt.com> wrote:

I have another problem; does PgSetFillColor() really taken in account in
a list’s draw function?

I don’t know – it’s a PtRawList, and you wrote the draw function,
didn’t you?..

Would it be possible to get a different background color for each line?

Sure, you just need to draw each line with a different background colour! :slight_smile:

If you use PtGenListDrawBackground() to draw the background, you can
tell it not to draw any background behind unselected items, by making
sure that the Pt_GEN_LIST_NO_BACKGROUND flag is unset in
Pt_ARG_RAWLIST_GFLAGS. This will allow you to draw a rectangle in your
favourite colour and then call PtGenListDrawBackground() to draw the
blue “focus” box around it. Or just draw the focus box yourself.

But this won’t work for selected items. If you need to change the
background colour of selected items, you’ll have to set the
Pt_GEN_LIST_NO_BACKGROUND flag and stuff your chosen colour into
basic->fill_color and glist->selection_fill_color before calling
PtGenListDrawBackground(). (But set the fill color back afterwadrs,
because it affects stuff like borders, margins, etc.)

In 6.3, you will be able to override the font and colours of each item
by associating an “item attributes” structure with it. PtGenList will
have a new method, and PtRawList will have a new function-pointer
resource, to tell the PtGenListDrawXXXX convenience functions what
attributes to use to draw an item.

Hi Wojtek,

Wojtek Lerch a écrit:

Alain Bonnefoy <> alain.bonnefoy@icbt.com> > wrote:


I have another problem; does PgSetFillColor() really taken in account in
a list’s draw function?



I don’t know – it’s a PtRawList, and you wrote the draw function,
didn’t you?..



Would it be possible to get a different background color for each line?



Sure, you just need to draw each line with a different background colour! > :slight_smile:


looks cool!



If you use PtGenListDrawBackground() to draw the background, you can
tell it not to draw any background behind unselected items, by making
sure that the Pt_GEN_LIST_NO_BACKGROUND flag is unset in
Pt_ARG_RAWLIST_GFLAGS.

I suppose you mean set no?



This will allow you to draw a rectangle in your
favourite colour and then call PtGenListDrawBackground() to draw the
blue “focus” box around it. Or just draw the focus box yourself.


But this won’t work for selected items.

?!? The PtRawList don’t tell about a different meanning about select items:


Pt_GEN_LIST_NO_BACKGROUND
If set, the Draw function doesn’t draw the background (under the
items) or margins.

Maybe the doc should precise it?

If you need to change the
background colour of selected items, you’ll have to set the
Pt_GEN_LIST_NO_BACKGROUND flag and stuff your chosen colour into
basic->fill_color and glist->selection_fill_color before calling
PtGenListDrawBackground(). (But set the fill color back afterwadrs,
because it affects stuff like borders, margins, etc.)

In 6.3, you will be able to override the font and colours of each item
by associating an “item attributes” structure with it. PtGenList will
have a new method, and PtRawList will have a new function-pointer
resource, to tell the PtGenListDrawXXXX convenience functions what
attributes to use to draw an item.



Well, according to what I understood, I set the

Pt_GEN_LIST_NO_BACKGROUND flag.
But I had to test if the items is selected to skip it. First I tried to
put the PtGenListDrawBackground to not take care about this, but
selected items background color was not good! strange no?

This is my draw func:

void cb_RawList_users_draw(PtWidget_t *widget, PtGenListItem_t *items,
unsigned index, unsigned nitems, PhRect_t *where){
short item_height = items->size.h;
unsigned n = index;

PtGenListDrawBackground(widget,items,nitems,where,0,0,0,0);

do {
short bot;

bot = where->ul.y +item_height;
if (items->flags & Pt_LIST_ITEM_DAMAGED) {
PgColor_t fg, bg;
where->lr.y = bot - 1;
PtGenListGetColors(widget,items , &fg, &bg);
PgSetTextColor(fg);
if (items->flags & Pt_LIST_ITEM_SELECTED) {
PgSetFillColor(bg);
} else {
if (n & 1) {
PgSetFillColor(PgRGB(255, 255, 200));
} else {
PgSetFillColor(PgRGB(255, 255, 150));
}
PgDrawRect(where, Pg_DRAW_FILL);
}
PtGenListDrawString(widget, ((user_list_t
*)items)->user_access.item_text, where, 0, 0);
n++;
}
where->ul.y = bot;
items = items->next;
} while ( --nitems );
}

Thanks a lot Wojtek,

Alain.

Alain Bonnefoy wrote:

Wojtek Lerch a écrit:
If you use PtGenListDrawBackground() to draw the background, you can
tell it not to draw any background behind unselected items, by making
sure that the Pt_GEN_LIST_NO_BACKGROUND flag is unset in
Pt_ARG_RAWLIST_GFLAGS.

I suppose you mean set no?

No. Setting the flag tells the widget that your draw-item function will
draw solid background behind each item, and therefore there’s no need
for the widget to worry about the background. If you unset the flag,
the widget will draw the entire background in one PgDrawRect() call
before calling your draw-item function.

If the flag is unset, PtGenListDrawBackground() will assume that the
background is already filled with the fill colour and doesn’t have to be
drawn again unless it needs to have a diffent colour (i.e. the item is
selected). It the flag is set, it’ll assume that the background needs
to be drawn regardless of whether the item is selected or not.

This will allow you to draw a rectangle in your
favourite colour and then call PtGenListDrawBackground() to draw the
blue “focus” box around it. Or just draw the focus box yourself.


But this won’t work for selected items.

?!? The PtRawList don’t tell about a different meanning about select items:

There is no different meaning, unless you call
PtGenListDrawBackground(). And PtGenListDrawBackground() just makes
sure that the background looks the way it normally looks for regular
PtLists and PtTrees.


Pt_GEN_LIST_NO_BACKGROUND
If set, the Draw function doesn’t draw the background (under the
items) or margins.

Maybe the doc should precise it?

Maybe… It is talking about drawing one big rectangle in the widget’s
fill colour.