View topic - how to use the function of PgDrawILineCx ()

how to use the function of PgDrawILineCx ()

Read-only archive of qnx.gui (Creating graphical applications within a GUI environment, such as Photon or PhAB) at inn.qnx.com

how to use the function of PgDrawILineCx ()

Postby dxwang » Thu Jun 01, 2006 3:26 am

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
Senior Member
 
Posts: 129
Joined: Mon Sep 27, 2004 1:39 pm

Re: how to use the function of PgDrawILineCx ()

Postby Steve Reid » Thu Jun 01, 2006 1:31 pm

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
------------------------------------------
Steve Reid
 

RE: Re: how to use the function of PgDrawILineCx ()

Postby dxwang » Tue Jun 06, 2006 8:55 am

if ABW_PtRaw1 isn't right. what should it is ? THANKS
dxwang
Senior Member
 
Posts: 129
Joined: Mon Sep 27, 2004 1:39 pm

Re: how to use the function of PgDrawILineCx ()

Postby Steve Reid » Tue Jun 06, 2006 2:15 pm

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
------------------------------------------
Steve Reid
 

RE: Re: how to use the function of PgDrawILineCx ()

Postby dxwang » Wed Jun 07, 2006 2:08 pm

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 .
dxwang
Senior Member
 
Posts: 129
Joined: Mon Sep 27, 2004 1:39 pm

Re: how to use the function of PgDrawILineCx ()

Postby Rodney Dowdall » Wed Jun 07, 2006 4:16 pm

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
 

Re: how to use the function of PgDrawILineCx ()

Postby Rodney Dowdall » Wed Jun 07, 2006 7:25 pm

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
 

RE: Re: how to use the function of PgDrawILineCx ()

Postby dxwang » Fri Jun 09, 2006 1:31 pm

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
Senior Member
 
Posts: 129
Joined: Mon Sep 27, 2004 1:39 pm

Re: how to use the function of PgDrawILineCx ()

Postby Rodney Dowdall » Fri Jun 09, 2006 2:19 pm

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. ... /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
Rodney Dowdall
 

re:how to use the function of PgDrawILineCx ()

Postby dxwang » Sat Jun 10, 2006 2:44 am

:) 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
dxwang
Senior Member
 
Posts: 129
Joined: Mon Sep 27, 2004 1:39 pm

re:how to use the function of PgDrawILineCx ()

Postby dxwang » Thu Jun 15, 2006 1:14 am

I have solved it . Thanks !
dxwang
Senior Member
 
Posts: 129
Joined: Mon Sep 27, 2004 1:39 pm


Return to qnx.gui

Who is online

Users browsing this forum: No registered users and 1 guest