Proper use of SetTranslation and PgDraw*() functions.

Hi,

I’m trying to do raw drawing into a sub window.

No matter what I try I see:

  1. nothing after the first PgDraw()s when the sub window is created.
  2. the position of the PgDraw()s are relative to the parent window after the
    second PgDraw() (after the first callback).
  3. the position of the PgDraw()s are in the correct place after the third
    attempt (the second callback).
  4. If I switch to a different Photon console then back again the next
    attempt to draw is in the correct place.
  5. If I click on the parent window the next attempt to draw is relative to
    the parent again.

I am trying to get the canvas of the sub-window and do a set translation.
But that isn’t helping. I’m also doing a PgFlush();

What is the proper procedure?

OK. I see that the canvas is not what I need to get.

What do I need to do to make this work?

“Bill Caroselli (Q-TPS)” <QTPS@EarthLink.net> wrote in message
news:aiuqkc$fsr$1@inn.qnx.com

Hi,

I’m trying to do raw drawing into a sub window.

No matter what I try I see:

  1. nothing after the first PgDraw()s when the sub window is created.
  2. the position of the PgDraw()s are relative to the parent window after
    the
    second PgDraw() (after the first callback).
  3. the position of the PgDraw()s are in the correct place after the third
    attempt (the second callback).
  4. If I switch to a different Photon console then back again the next
    attempt to draw is in the correct place.
  5. If I click on the parent window the next attempt to draw is relative to
    the parent again.

I am trying to get the canvas of the sub-window and do a set translation.
But that isn’t helping. I’m also doing a PgFlush();

What is the proper procedure?

Hey Bill

Thant depends on what you mean by “Sub Window”…Are you trying to draw
to a child window ( a completly seperate window then your base window )
or a different section of the window in a raw widget?

Thanks,
Rodney


Bill Caroselli (Q-TPS) wrote:

OK. I see that the canvas is not what I need to get.

What do I need to do to make this work?

“Bill Caroselli (Q-TPS)” <> QTPS@EarthLink.net> > wrote in message
news:aiuqkc$fsr$> 1@inn.qnx.com> …

Hi,

I’m trying to do raw drawing into a sub window.

No matter what I try I see:

  1. nothing after the first PgDraw()s when the sub window is created.
  2. the position of the PgDraw()s are relative to the parent window after

the

second PgDraw() (after the first callback).
3. the position of the PgDraw()s are in the correct place after the third
attempt (the second callback).
4. If I switch to a different Photon console then back again the next
attempt to draw is in the correct place.
5. If I click on the parent window the next attempt to draw is relative to
the parent again.

I am trying to get the canvas of the sub-window and do a set translation.
But that isn’t helping. I’m also doing a PgFlush();

What is the proper procedure?


\

Hey Bill

Are you calling the draw calls from a callback from within the base
window? If you are are you making a call to PgSetRegion? Would it be
possible for you to send some sample code?

Thanks,
Rodney



Bill Caroselli (Q-TPS) wrote:

This is a completely separate window from the base window. Actually what is
happening is this:
base window button press pulls up a dialog.
dialog window put-on press pulls up a new window.
I am trying to draw several bitmaps on this new window (I’m still stuck on
the first one).

The first time I try my PgDrawBitmap() nothing visible shows up anywhere.
The second time I try to draw my bitmap is in a callback after someone has
pressed a button on the new child window. But the bitmap shows up in the
relative position I gave but relative to the dialog window (I think. The
dialog almost perfectly overlays the base window, except for the base window
title bar.) Thereafter the bit map shows up on the child window.

“Rodney Dowdall” <> guisupport@qnx.com> > wrote in message
news:> 3D539B10.3070207@qnx.com> …

Hey Bill

Thant depends on what you mean by “Sub Window”…Are you trying to draw
to a child window ( a completly seperate window then your base window )
or a different section of the window in a raw widget?

Thanks,
Rodney


Bill Caroselli (Q-TPS) wrote:

OK. I see that the canvas is not what I need to get.

What do I need to do to make this work?

“Bill Caroselli (Q-TPS)” <> QTPS@EarthLink.net> > wrote in message
news:aiuqkc$fsr$> 1@inn.qnx.com> …


Hi,

I’m trying to do raw drawing into a sub window.

No matter what I try I see:

  1. nothing after the first PgDraw()s when the sub window is created.
  2. the position of the PgDraw()s are relative to the parent window after

the


second PgDraw() (after the first callback).
3. the position of the PgDraw()s are in the correct place after the

third

attempt (the second callback).
4. If I switch to a different Photon console then back again the next
attempt to draw is in the correct place.
5. If I click on the parent window the next attempt to draw is relative

to

the parent again.

I am trying to get the canvas of the sub-window and do a set

translation.

But that isn’t helping. I’m also doing a PgFlush();

What is the proper procedure?




\

Hey Bill

You do the following:

PhRid_t OldRid;
PhRid_t Widgetrid;

OldRid = PgGetRegion ();
Widgetrid = PtWidgetRid ( ABW_THE_WINDOW_YOU_ARE_DRAWING_TOO );
PtSetRegion ( Widgetrid );
/*Do some drawing */
PtSetRegion ( OldRid );

Thanks,
Rodney

Bill Caroselli (Q-TPS) wrote:

I was not calling PgSetRegion().
When should I do that?

How do I get the region of the new window I’ve just created?

Do I need to restore the old region if a set a new one?

“Rodney Dowdall” <> guisupport@qnx.com> > wrote in message
news:> 3D53B5BF.2050903@qnx.com> …

Hey Bill

Are you calling the draw calls from a callback from within the base
window? If you are are you making a call to PgSetRegion? Would it be
possible for you to send some sample code?

Thanks,
Rodney



Bill Caroselli (Q-TPS) wrote:

This is a completely separate window from the base window. Actually

what is

happening is this:
base window button press pulls up a dialog.
dialog window put-on press pulls up a new window.
I am trying to draw several bitmaps on this new window (I’m still stuck

on

the first one).

The first time I try my PgDrawBitmap() nothing visible shows up

anywhere.

The second time I try to draw my bitmap is in a callback after someone

has

pressed a button on the new child window. But the bitmap shows up in

the

relative position I gave but relative to the dialog window (I think.

The

dialog almost perfectly overlays the base window, except for the base

window

title bar.) Thereafter the bit map shows up on the child window.

“Rodney Dowdall” <> guisupport@qnx.com> > wrote in message
news:> 3D539B10.3070207@qnx.com> …


Hey Bill

Thant depends on what you mean by “Sub Window”…Are you trying to draw
to a child window ( a completly seperate window then your base window )
or a different section of the window in a raw widget?

Thanks,
Rodney


Bill Caroselli (Q-TPS) wrote:


OK. I see that the canvas is not what I need to get.

What do I need to do to make this work?

“Bill Caroselli (Q-TPS)” <> QTPS@EarthLink.net> > wrote in message
news:aiuqkc$fsr$> 1@inn.qnx.com> …



Hi,

I’m trying to do raw drawing into a sub window.

No matter what I try I see:

  1. nothing after the first PgDraw()s when the sub window is created.
  2. the position of the PgDraw()s are relative to the parent window

after

the



second PgDraw() (after the first callback).
3. the position of the PgDraw()s are in the correct place after the

third


attempt (the second callback).
4. If I switch to a different Photon console then back again the next
attempt to draw is in the correct place.
5. If I click on the parent window the next attempt to draw is

relative

to


the parent again.

I am trying to get the canvas of the sub-window and do a set

translation.


But that isn’t helping. I’m also doing a PgFlush();

What is the proper procedure?





\

Hey Bill

I’m not sure if it is mentioned anywhere or not. I’ve just stumbled
across this mysef before and this was how I got around it. It may be
mentioned in the raw drawing chapter. If it’s not I’ll make a PR to
have it added. Something along the line of “Special Note: If you are
trying to draw to a region other than the one you own please use these
calls.”.

Thanks,
Rodney

Bill Caroselli (Q-TPS) wrote:

THANK YOU!

Is this documented anywhere?

I mean I really tried to RTFM. I swear I did. I just couldn’t come up with
this.

I was playing with Graphic Contexts, Setting Translations, and everything
else I could think of.

“Rodney Dowdall” <> guisupport@qnx.com> > wrote in message
news:> 3D53D466.7090604@qnx.com> …

Hey Bill

You do the following:

PhRid_t OldRid;
PhRid_t Widgetrid;

OldRid = PgGetRegion ();
Widgetrid = PtWidgetRid ( ABW_THE_WINDOW_YOU_ARE_DRAWING_TOO );
PtSetRegion ( Widgetrid );
/*Do some drawing */
PtSetRegion ( OldRid );

Thanks,
Rodney

Bill Caroselli (Q-TPS) wrote:

I was not calling PgSetRegion().
When should I do that?

How do I get the region of the new window I’ve just created?

Do I need to restore the old region if a set a new one?

“Rodney Dowdall” <> guisupport@qnx.com> > wrote in message
news:> 3D53B5BF.2050903@qnx.com> …


Hey Bill

Are you calling the draw calls from a callback from within the base
window? If you are are you making a call to PgSetRegion? Would it be
possible for you to send some sample code?

Thanks,
Rodney



Bill Caroselli (Q-TPS) wrote:


This is a completely separate window from the base window. Actually

what is


happening is this:
base window button press pulls up a dialog.
dialog window put-on press pulls up a new window.
I am trying to draw several bitmaps on this new window (I’m still stuck

on


the first one).

The first time I try my PgDrawBitmap() nothing visible shows up

anywhere.


The second time I try to draw my bitmap is in a callback after someone

has


pressed a button on the new child window. But the bitmap shows up in

the


relative position I gave but relative to the dialog window (I think.

The


dialog almost perfectly overlays the base window, except for the base

window


title bar.) Thereafter the bit map shows up on the child window.

“Rodney Dowdall” <> guisupport@qnx.com> > wrote in message
news:> 3D539B10.3070207@qnx.com> …



Hey Bill

Thant depends on what you mean by “Sub Window”…Are you trying to

draw

to a child window ( a completly seperate window then your base

window )

or a different section of the window in a raw widget?

Thanks,
Rodney


Bill Caroselli (Q-TPS) wrote:



OK. I see that the canvas is not what I need to get.

What do I need to do to make this work?

“Bill Caroselli (Q-TPS)” <> QTPS@EarthLink.net> > wrote in message
news:aiuqkc$fsr$> 1@inn.qnx.com> …




Hi,

I’m trying to do raw drawing into a sub window.

No matter what I try I see:

  1. nothing after the first PgDraw()s when the sub window is created.
  2. the position of the PgDraw()s are relative to the parent window

after


the




second PgDraw() (after the first callback).
3. the position of the PgDraw()s are in the correct place after the

third



attempt (the second callback).
4. If I switch to a different Photon console then back again the

next

attempt to draw is in the correct place.
5. If I click on the parent window the next attempt to draw is

relative


to



the parent again.

I am trying to get the canvas of the sub-window and do a set

translation.



But that isn’t helping. I’m also doing a PgFlush();

What is the proper procedure?





\

This is a completely separate window from the base window. Actually what is
happening is this:
base window button press pulls up a dialog.
dialog window put-on press pulls up a new window.
I am trying to draw several bitmaps on this new window (I’m still stuck on
the first one).

The first time I try my PgDrawBitmap() nothing visible shows up anywhere.
The second time I try to draw my bitmap is in a callback after someone has
pressed a button on the new child window. But the bitmap shows up in the
relative position I gave but relative to the dialog window (I think. The
dialog almost perfectly overlays the base window, except for the base window
title bar.) Thereafter the bit map shows up on the child window.

“Rodney Dowdall” <guisupport@qnx.com> wrote in message
news:3D539B10.3070207@qnx.com

Hey Bill

Thant depends on what you mean by “Sub Window”…Are you trying to draw
to a child window ( a completly seperate window then your base window )
or a different section of the window in a raw widget?

Thanks,
Rodney


Bill Caroselli (Q-TPS) wrote:
OK. I see that the canvas is not what I need to get.

What do I need to do to make this work?

“Bill Caroselli (Q-TPS)” <> QTPS@EarthLink.net> > wrote in message
news:aiuqkc$fsr$> 1@inn.qnx.com> …

Hi,

I’m trying to do raw drawing into a sub window.

No matter what I try I see:

  1. nothing after the first PgDraw()s when the sub window is created.
  2. the position of the PgDraw()s are relative to the parent window after

the

second PgDraw() (after the first callback).
3. the position of the PgDraw()s are in the correct place after the
third
attempt (the second callback).
4. If I switch to a different Photon console then back again the next
attempt to draw is in the correct place.
5. If I click on the parent window the next attempt to draw is relative
to
the parent again.

I am trying to get the canvas of the sub-window and do a set
translation.
But that isn’t helping. I’m also doing a PgFlush();

What is the proper procedure?



\

I was not calling PgSetRegion().
When should I do that?

How do I get the region of the new window I’ve just created?

Do I need to restore the old region if a set a new one?

“Rodney Dowdall” <guisupport@qnx.com> wrote in message
news:3D53B5BF.2050903@qnx.com

Hey Bill

Are you calling the draw calls from a callback from within the base
window? If you are are you making a call to PgSetRegion? Would it be
possible for you to send some sample code?

Thanks,
Rodney



Bill Caroselli (Q-TPS) wrote:
This is a completely separate window from the base window. Actually
what is
happening is this:
base window button press pulls up a dialog.
dialog window put-on press pulls up a new window.
I am trying to draw several bitmaps on this new window (I’m still stuck
on
the first one).

The first time I try my PgDrawBitmap() nothing visible shows up
anywhere.
The second time I try to draw my bitmap is in a callback after someone
has
pressed a button on the new child window. But the bitmap shows up in
the
relative position I gave but relative to the dialog window (I think.
The
dialog almost perfectly overlays the base window, except for the base
window
title bar.) Thereafter the bit map shows up on the child window.

“Rodney Dowdall” <> guisupport@qnx.com> > wrote in message
news:> 3D539B10.3070207@qnx.com> …

Hey Bill

Thant depends on what you mean by “Sub Window”…Are you trying to draw
to a child window ( a completly seperate window then your base window )
or a different section of the window in a raw widget?

Thanks,
Rodney


Bill Caroselli (Q-TPS) wrote:

OK. I see that the canvas is not what I need to get.

What do I need to do to make this work?

“Bill Caroselli (Q-TPS)” <> QTPS@EarthLink.net> > wrote in message
news:aiuqkc$fsr$> 1@inn.qnx.com> …


Hi,

I’m trying to do raw drawing into a sub window.

No matter what I try I see:

  1. nothing after the first PgDraw()s when the sub window is created.
  2. the position of the PgDraw()s are relative to the parent window
    after

the


second PgDraw() (after the first callback).
3. the position of the PgDraw()s are in the correct place after the

third

attempt (the second callback).
4. If I switch to a different Photon console then back again the next
attempt to draw is in the correct place.
5. If I click on the parent window the next attempt to draw is
relative

to

the parent again.

I am trying to get the canvas of the sub-window and do a set

translation.

But that isn’t helping. I’m also doing a PgFlush();

What is the proper procedure?





\

THANK YOU!

Is this documented anywhere?

I mean I really tried to RTFM. I swear I did. I just couldn’t come up with
this.

I was playing with Graphic Contexts, Setting Translations, and everything
else I could think of.

“Rodney Dowdall” <guisupport@qnx.com> wrote in message
news:3D53D466.7090604@qnx.com

Hey Bill

You do the following:

PhRid_t OldRid;
PhRid_t Widgetrid;

OldRid = PgGetRegion ();
Widgetrid = PtWidgetRid ( ABW_THE_WINDOW_YOU_ARE_DRAWING_TOO );
PtSetRegion ( Widgetrid );
/*Do some drawing */
PtSetRegion ( OldRid );

Thanks,
Rodney

Bill Caroselli (Q-TPS) wrote:
I was not calling PgSetRegion().
When should I do that?

How do I get the region of the new window I’ve just created?

Do I need to restore the old region if a set a new one?

“Rodney Dowdall” <> guisupport@qnx.com> > wrote in message
news:> 3D53B5BF.2050903@qnx.com> …

Hey Bill

Are you calling the draw calls from a callback from within the base
window? If you are are you making a call to PgSetRegion? Would it be
possible for you to send some sample code?

Thanks,
Rodney



Bill Caroselli (Q-TPS) wrote:

This is a completely separate window from the base window. Actually

what is

happening is this:
base window button press pulls up a dialog.
dialog window put-on press pulls up a new window.
I am trying to draw several bitmaps on this new window (I’m still stuck

on

the first one).

The first time I try my PgDrawBitmap() nothing visible shows up

anywhere.

The second time I try to draw my bitmap is in a callback after someone

has

pressed a button on the new child window. But the bitmap shows up in

the

relative position I gave but relative to the dialog window (I think.

The

dialog almost perfectly overlays the base window, except for the base

window

title bar.) Thereafter the bit map shows up on the child window.

“Rodney Dowdall” <> guisupport@qnx.com> > wrote in message
news:> 3D539B10.3070207@qnx.com> …


Hey Bill

Thant depends on what you mean by “Sub Window”…Are you trying to
draw
to a child window ( a completly seperate window then your base
window )
or a different section of the window in a raw widget?

Thanks,
Rodney


Bill Caroselli (Q-TPS) wrote:


OK. I see that the canvas is not what I need to get.

What do I need to do to make this work?

“Bill Caroselli (Q-TPS)” <> QTPS@EarthLink.net> > wrote in message
news:aiuqkc$fsr$> 1@inn.qnx.com> …



Hi,

I’m trying to do raw drawing into a sub window.

No matter what I try I see:

  1. nothing after the first PgDraw()s when the sub window is created.
  2. the position of the PgDraw()s are relative to the parent window

after

the



second PgDraw() (after the first callback).
3. the position of the PgDraw()s are in the correct place after the

third


attempt (the second callback).
4. If I switch to a different Photon console then back again the
next
attempt to draw is in the correct place.
5. If I click on the parent window the next attempt to draw is

relative

to


the parent again.

I am trying to get the canvas of the sub-window and do a set

translation.


But that isn’t helping. I’m also doing a PgFlush();

What is the proper procedure?






\

Rodney Dowdall <guisupport@qnx.com> wrote:
: Hey Bill

: I’m not sure if it is mentioned anywhere or not. I’ve just stumbled
: across this mysef before and this was how I got around it. It may be
: mentioned in the raw drawing chapter. If it’s not I’ll make a PR to
: have it added. Something along the line of “Special Note: If you are
: trying to draw to a region other than the one you own please use these
: calls.”.

On the other hand, the docs do say that if you need to do any raw drawing,
you should use a raw widget. Wouldn’t it be better to put a raw widget
in the second window and do all the low-level graphics calls in its
draw function?


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems