Draw function in custom widget

We are experiencing problems with a custom widget we have developed
in that a it seems to create a ghost image of itself which is displaced
from the actual location and which will disappear if the screen (or area)
is redrawn. The widget is question is derived from a PtLabel widget and
the draw function sets the Pt_ARG_TEXT_STRING and Pt_ARG_COLOR resources
of itself using PtSetResources before calling PtSuperClassDraw(PtLabel,…)
to have the PtLabel to do the actual draw.

My question is, is it legitimate to do this inside a Draw function?
I cannot find any documentation that it is not, but none of the example
or contributed widgets seem to do this. If not, how else can the PtLabel
text be changed inside the derived widget?

Will Parsons

Hello Will,

This isn’t the way to be changing the resources from within the widgets draw
function. The best way to do this would be to use the pointer to the class
containing the resource you need to change. It’s best to look at the widgets
draw function as write only.

For example if you have in you draw function:
PtLabelWidget_t *label = (PtLabelWidget_t *) widget;

You could use:
label->string = “Your string”;

Regards,
Dave B.



“Will Parsons” <wbp@alfa.eng.sun.com> wrote in message
news:aesrj4$6fp$1@inn.qnx.com

We are experiencing problems with a custom widget we have developed
in that a it seems to create a ghost image of itself which is displaced
from the actual location and which will disappear if the screen (or area)
is redrawn. The widget is question is derived from a PtLabel widget and
the draw function sets the Pt_ARG_TEXT_STRING and Pt_ARG_COLOR resources
of itself using PtSetResources before calling
PtSuperClassDraw(PtLabel,…)
to have the PtLabel to do the actual draw.

My question is, is it legitimate to do this inside a Draw function?
I cannot find any documentation that it is not, but none of the example
or contributed widgets seem to do this. If not, how else can the PtLabel
text be changed inside the derived widget?

Will Parsons

Your suggestion seems to work, but may I then conclude that Photon does
not treat string resources of this sort as dynamically allocated? I.e.,
if I have:

static char buffer[80] = “some string”;

label->string = buffer;

that Photon will not try to free ‘buffer’ when the widget is destroyed?

Applications support <apps@qnx.com> wrote:

Hello Will,

This isn’t the way to be changing the resources from within the widgets draw
function. The best way to do this would be to use the pointer to the class
containing the resource you need to change. It’s best to look at the widgets
draw function as write only.

For example if you have in you draw function:
PtLabelWidget_t *label = (PtLabelWidget_t *) widget;

You could use:
label->string = “Your string”;

Regards,
Dave B.



“Will Parsons” <> wbp@alfa.eng.sun.com> > wrote in message
news:aesrj4$6fp$> 1@inn.qnx.com> …
We are experiencing problems with a custom widget we have developed
in that a it seems to create a ghost image of itself which is displaced
from the actual location and which will disappear if the screen (or area)
is redrawn. The widget is question is derived from a PtLabel widget and
the draw function sets the Pt_ARG_TEXT_STRING and Pt_ARG_COLOR resources
of itself using PtSetResources before calling
PtSuperClassDraw(PtLabel,…)
to have the PtLabel to do the actual draw.

My question is, is it legitimate to do this inside a Draw function?
I cannot find any documentation that it is not, but none of the example
or contributed widgets seem to do this. If not, how else can the PtLabel
text be changed inside the derived widget?

Will Parsons

Will Parsons <wbp@alfa.eng.sun.com> wrote:

Your suggestion seems to work, but may I then conclude that Photon does
not treat string resources of this sort as dynamically allocated? I.e.,
if I have:

static char buffer[80] = “some string”;

label->string = buffer;

that Photon will not try to free ‘buffer’ when the widget is destroyed?

Applications support <> apps@qnx.com> > wrote:
Hello Will,

This isn’t the way to be changing the resources from within the widgets draw
function. The best way to do this would be to use the pointer to the class
containing the resource you need to change. It’s best to look at the widgets
draw function as write only.

For example if you have in you draw function:
PtLabelWidget_t *label = (PtLabelWidget_t *) widget;

You could use:
label->string = “Your string”;

Regards,
Dave B.

I suspect that label->string must be dynamically allocated, so assigning
a static string will not work. Can anyone confirm this? If so, I would
assume that label->string must be freed before being re-assigned?

“Will Parsons” <> wbp@alfa.eng.sun.com> > wrote in message
news:aesrj4$6fp$> 1@inn.qnx.com> …
We are experiencing problems with a custom widget we have developed
in that a it seems to create a ghost image of itself which is displaced
from the actual location and which will disappear if the screen (or area)
is redrawn. The widget is question is derived from a PtLabel widget and
the draw function sets the Pt_ARG_TEXT_STRING and Pt_ARG_COLOR resources
of itself using PtSetResources before calling
PtSuperClassDraw(PtLabel,…)
to have the PtLabel to do the actual draw.

My question is, is it legitimate to do this inside a Draw function?
I cannot find any documentation that it is not, but none of the example
or contributed widgets seem to do this. If not, how else can the PtLabel
text be changed inside the derived widget?

Will Parsons