how to use the function of PgDrawILineCx ()

I want to draw a line in ptraw .when I press the button of a dialog
int PgDrawILineCx( void *dc, int x1, int y1, int x2, int y2 );
I don’t know what’s dc. I hava a try ABW_PtRaw1.but when I press the
button, the whole program exit.
who can help me . Thanks!

/////////////
PgDrawILine() work on the current draw context
PgDrawILineCx() work on the given context dc
////////////

dxwang <dxwang@mail.ustc.edu-dot-cn.no-spam.invalid> wrote:

I want to draw a line in ptraw .when I press the button of a dialog
int PgDrawILineCx( void *dc, int x1, int y1, int x2, int y2 );
I don’t know what’s dc. I hava a try ABW_PtRaw1.but when I press the
button, the whole program exit.
who can help me . Thanks!

/////////////
PgDrawILine() work on the current draw context
PgDrawILineCx() work on the given context dc
////////////

Your program is likely crashing because an ABW_* variable isn’t a draw
context. A draw context defines where the draw stream goes to, but
in a general way (e.g. to the screen or to a printer), not to a specific
widget.

If you want to draw something in a PtRaw widget, you need to damage the
widget and let its drawing function display the line. (You might need
some scheme to let the widget know where you want the line to go if it’s
at all arbitrary.) See the Raw Drawing and Animation chapter of the
Photon Programmer’s Guide.


Steve Reid stever@qnx.com
Technical Editor
QNX Software Systems

if ABW_PtRaw1 isn’t right. what should it is ? THANKS

dxwang <dxwang@mail.ustc.edu-dot-cn.no-spam.invalid> wrote:

if ABW_PtRaw1 isn’t right. what should it is ? THANKS

If you want to use the default draw context (which is likely), pass NULL.


Steve Reid stever@qnx.com
Technical Editor
QNX Software Systems

my problem is : firstly press a toolbar button then a dialog pops
up. there is a OK button on the dialog, (when I press this ok
button,I hope to draw line on the ptraw ,ptraw is in the ptpane). but
now when I press the OK ,the whole program exit. so I guess that 's
the wrong of the use of the fisrt parameter . if I use PgDrawILine()
,it draw the line in the pop-up dialog, not in the ptraw. So I
consider to use PgDrawILineCx(). but I don’t know how to use the
first parameter .

Okay, without seeing your code, I don’t know what you are doing exactly,
but here is what I think you are doing:

You have a raw widget in a panel in your base window
You have a button in your dialog with a callback attached to it.
In the button callback you call PgDrawILine.

What you should be doing is:

You have a raw draw callback attached to your raw widget. In there you
place the call to PgDrawILine. Seeing as how you only want it drawn if
the button in the dialog has been pressed you probably want to do
something like:

if (dialogButtonPressed == TRUE ) {
PgDrawILine(…);
}

On the button in the dialog you have a activate callback.
In that activate callback you do the following:

dialogButtonPressed = TRUE;
PtDamageWidget (ABW_PtRaw1);

This should draw your line in your PtRawWidget. If it doesn’t and it
still draws on the Dialog, you may need to set the region before you do
any drawing in your raw widget draw callback. You would do it this way:

PgSetRegion ( PtWidgetRid ( ABW_PtRaw1));

Thanks,
Rodney


dxwang wrote:

my problem is : firstly press a toolbar button then a dialog pops
up. there is a OK button on the dialog, (when I press this ok
button,I hope to draw line on the ptraw ,ptraw is in the ptpane). but
now when I press the OK ,the whole program exit. so I guess that 's
the wrong of the use of the fisrt parameter . if I use PgDrawILine()
,it draw the line in the pop-up dialog, not in the ptraw. So I
consider to use PgDrawILineCx(). but I don’t know how to use the
first parameter .

Hello

My bad…the PgSetRegion is not to be used at all. If your line is
being draw in the wrong place, we’ll have to investigate.

Thanks,
Rodney


Rodney Dowdall wrote:

Okay, without seeing your code, I don’t know what you are doing exactly,
but here is what I think you are doing:

You have a raw widget in a panel in your base window
You have a button in your dialog with a callback attached to it.
In the button callback you call PgDrawILine.

What you should be doing is:

You have a raw draw callback attached to your raw widget. In there you
place the call to PgDrawILine. Seeing as how you only want it drawn if
the button in the dialog has been pressed you probably want to do
something like:

if (dialogButtonPressed == TRUE ) {
PgDrawILine(…);
}

On the button in the dialog you have a activate callback.
In that activate callback you do the following:

dialogButtonPressed = TRUE;
PtDamageWidget (ABW_PtRaw1);

This should draw your line in your PtRawWidget. If it doesn’t and it
still draws on the Dialog, you may need to set the region before you do
any drawing in your raw widget draw callback. You would do it this way:

PgSetRegion ( PtWidgetRid ( ABW_PtRaw1));

Thanks,
Rodney


dxwang wrote:
my problem is : firstly press a toolbar button then a dialog pops
up. there is a OK button on the dialog, (when I press this ok
button,I hope to draw line on the ptraw ,ptraw is in the ptpane). but
now when I press the OK ,the whole program exit. so I guess that 's
the wrong of the use of the fisrt parameter . if I use PgDrawILine()
,it draw the line in the pop-up dialog, not in the ptraw. So I
consider to use PgDrawILineCx(). but I don’t know how to use the
first parameter .

Rodney Dowdall :
IN PtRaw.c, all the line is drawed by PgDrawILine(x,y,x1,y1)
manually . not use ptsetresource(…DATA.).
so I cann’t understand PtDamageWidget (ABW_PtRaw1);
do you have some codes about ptraw? if you have, please put some
codes there. Thanks!

dxwang wrote:

Rodney Dowdall :
IN PtRaw.c, all the line is drawed by PgDrawILine(x,y,x1,y1)
manually . not use ptsetresource(…DATA.).
so I cann’t understand PtDamageWidget (ABW_PtRaw1);
do you have some codes about ptraw? if you have, please put some
codes there. Thanks!

Here is a link to the raw drawing and animation documentation:

http://www.qnx.com/developers/docs/6.3.0SP2/photon/prog_guide/draw.html

Plus in this newsgroup if you go to conversation on Raw Drawing help,
you should be able to get some tips from there. Why don’t you post what
you have already?

Thanks,
Rodney

:slight_smile: because I just want to test the function of pgdrawlinecx in ptraw .
and until now I still didn’t read the Raw Drawing and Animation
docs.
now I begin to read. after that. I will descript this in details.

Thanks

I have solved it . Thanks !