How to use the divider widget

All of my photon programming until now has been simple process control, i.e.
push a button, send a message.

I need to display a kind of a real time status screen that is larger than
physically fits on the screen. I wanted to use a divider widget to allow
the user to adjust comulm widths of both column headings and a scrollable
list area.

Basically I want the same kind of behaviour that pfm has on the right side
of its screen, including the scroll bar if necessary.

I’m lost. What do I need to put inside of what?


Bill Caroselli - Sattel Global Networks
1-818-709-6201 ext 122

Previously, Bill Caroselli wrote in qdn.public.qnx4.photon:

All of my photon programming until now has been simple process control, i.e.
push a button, send a message.

I need to display a kind of a real time status screen that is larger than
physically fits on the screen. I wanted to use a divider widget to allow
the user to adjust comulm widths of both column headings and a scrollable
list area.

Basically I want the same kind of behaviour that pfm has on the right side
of its screen, including the scroll bar if necessary.

I’m lost. What do I need to put inside of what?

Put the PtDivider inside a PtList. Put PtButtons into the Divider,
one per column. PtList “knows” that a PtDivider goes on top, and
defines column widths. Add text lines to the PtList with embedded
characters. The PtList will treat the character as a
colunt separator, and will space the output according to the widths of
the buttons. The PtDivider will automatically make the PtButtons
resizable.

Cheers,
Andrew

Thank you Andrew.

Your answer was clear and to the point, and it worked.

I’m just curious. I went back again and tried to find this information in
the on-line docs and couldn’t find it. Am I just blind as a bat (my family
would agree here) or does this need to be more conspicuous?


Bill Caroselli - Sattel Global Networks
1-818-709-6201 ext 122



“Andrew Thomas” <Andrew@cogent.ca> wrote in message
news:Voyager.010410132047.815126D@andrewhome.cogent.ca

Put the PtDivider inside a PtList. Put PtButtons into the Divider,
one per column. PtList “knows” that a PtDivider goes on top, and
defines column widths. Add text lines to the PtList with embedded
TAB> characters. The PtList will treat the character as a
colunt separator, and will space the output according to the widths of
the buttons. The PtDivider will automatically make the PtButtons
resizable.

It’s in the documentation of PtList, right on top, “Displaying items in
columns”
Markus

“Bill Caroselli” <Bill@Sattel.com> wrote in message
news:9bho0o$ego$1@inn.qnx.com

Thank you Andrew.

Your answer was clear and to the point, and it worked.

I’m just curious. I went back again and tried to find this information in
the on-line docs and couldn’t find it. Am I just blind as a bat (my
family
would agree here) or does this need to be more conspicuous?


Bill Caroselli - Sattel Global Networks
1-818-709-6201 ext 122



“Andrew Thomas” <> Andrew@cogent.ca> > wrote in message
news:> Voyager.010410132047.815126D@andrewhome.cogent.ca> …
Put the PtDivider inside a PtList. Put PtButtons into the Divider,
one per column. PtList “knows” that a PtDivider goes on top, and
defines column widths. Add text lines to the PtList with embedded
TAB> characters. The PtList will treat the character as a
colunt separator, and will space the output according to the widths of
the buttons. The PtDivider will automatically make the PtButtons
resizable.

OK. Let me push my luck here.

Suppose I wanted to add a PtToggleButton to each list item. Can that be
done? Or am I trying to put a square peg in a round hole.

I know I can get a callback when the line is selected and pop up a dialog,
but I can wish can’t I?


Bill Caroselli - Sattel Global Networks
1-818-709-6201 ext 122



“Andrew Thomas” <Andrew@cogent.ca> wrote in message
news:Voyager.010410132047.815126D@andrewhome.cogent.ca

Previously, Bill Caroselli wrote in qdn.public.qnx4.photon:
All of my photon programming until now has been simple process control,
i.e.
push a button, send a message.

I need to display a kind of a real time status screen that is larger
than
physically fits on the screen. I wanted to use a divider widget to
allow
the user to adjust comulm widths of both column headings and a
scrollable
list area.

Basically I want the same kind of behaviour that pfm has on the right
side
of its screen, including the scroll bar if necessary.

I’m lost. What do I need to put inside of what?

Put the PtDivider inside a PtList. Put PtButtons into the Divider,
one per column. PtList “knows” that a PtDivider goes on top, and
defines column widths. Add text lines to the PtList with embedded
TAB> characters. The PtList will treat the character as a
colunt separator, and will space the output according to the widths of
the buttons. The PtDivider will automatically make the PtButtons
resizable.

Cheers,
Andrew

Bill Caroselli <Bill@sattel.com> wrote:

OK. Let me push my luck here.

Suppose I wanted to add a PtToggleButton to each list item. Can that be
done? Or am I trying to put a square peg in a round hole.

Not a PtToggleButton (list items are not widgets), but you can have
columns in your widget that display an image instead of a string and
let you toggle the image when you click. Vmail does that.

You will need to use a PtTree rather than a PtList, and it requires some
code to set it up – here’s more or less how you do it:

1
Set the Pt_LIST_COLUMN_NO_STRING flag in PtGenList column attributes
(Pt_ARG_LIST_COLUMN_ATTR) for each column that will display images.
This will prevent text from being drawn on top of images.

Remember that a tab character in an item’s string will skip over a
column flagged as Pt_LIST_COLUMN_NO_STRING. For instance: if the
second column has the flag set, you only need one tab character
between the strings for the first and the third column.

static const PtListColumnAttributes_t latrs[] = {
{ Pt_LIST_COLUMN_LEFT },
{ Pt_LIST_COLUMN_CENTER | Pt_LIST_COLUMN_NO_STRING }
};

PtSetResource( ABW_tree, Pt_ARG_LIST_COLUMN_ATTR, latrs, sizeof(latrs) / sizeof(latrs[0]) );

2
Set up an array of image pointers for each column and an array of
tree column attributes (Pt_ARG_TREE_COLUMN_ATTR).

static const PhImage_t *images[3] = { &image1, &image2, &image3 };

static const PtTreeColumnAttributes_t tatrs[] = {
{ NULL, 0, Pt_TREE_COLUMN_NOCB }, // This column has no images
{ images, sizeof(images) / sizeof(images[0]),
Pt_TREE_COLUMN_NOSELECT,
Pt_LIST_ITEM_FLAG_USER1 | Pt_LIST_ITEM_FLAG_USER2
}
};

PtSetResource( ABW_tree, Pt_ARG_LIST_COLUMN_ATTR, tatrs, sizeof(tatrs) / sizeof(tatrs[0]) );

3
Optionally, write an image selector function and attach it to the
Pt_ARG_TREE_COLUMN_IMGFUN resource. This function takes a tree
item, a column index, and a column attributes structure, and returns
an index into the column’s image array (return -1 for no image).
You don’t need this function if you don’t need more than two states
per column (i.e. either two images to choose from or one image that
can be either present or absent) and you’re using an item flag to
distinguish between these two states.

static int image_selector(
PtWidget_t *widget, PtTreeItem_t *item,
PtTreeColumnAttributes_t const *cattr, unsigned cindex
) {
unsigned const flags = item->gen.list.flags;
int result = -1;
if ( cindex == 1 ) {
// (We don’t really need to check if cindex is one
// because we only have one column that displays images.)
// This column has three images and four possible states
// (no image is the fourth state).
// The function returns -1 for no image and 0, 1, or 2 to pick an image
if ( flags & Pt_LIST_ITEM_FLAG_USER2 )
result += 2;
if ( flags & Pt_LIST_ITEM_FLAG_USER1 )
result += 1;
}
return result;
}

PtSetResource( ABW_tree, Pt_ARG_TREE_COLUMN_IMGFUN, image_selector, 0 );


4
Optionally, attach a Pt_CB_TREE_COLUMN_SEL callback that will both
notify you when the user clicks on a column and will allow you to
control how the item’s state changes. For instance, the following
callback will make your items cycle through the four possible
states:

static int column_cb( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) {
PtTreeCallback_t *tcb = cbinfo->cbdata;
if ( tcb->column == 1 ) {
if ( tcb->new_flags & Pt_LIST_ITEM_FLAG_USER1 )
tcb->new_flags ^= Pt_LIST_ITEM_FLAG_USER2;
}
return Pt_CONTINUE;
}

\

Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.