Page 1 of 2

Presentation space in main window of xdemo.

Posted: Fri May 19, 2017 7:15 am
by skiman
Hi,

I want to use some GRA functions to create some graphics in my main window. I don't succeed to define the correct presentation space.
At line 190 I added the following to xdemo.prg.

Code: Select all

aLineAttrib := Array( GRA_AL_COUNT )
aLineAttrib[GRA_AL_WIDTH] := 3
aLineAttrib[GRA_AL_COLOR] := 28555199
oPS     := XbpPresSpace():new()  // it looks as creating a presentation space doesn't work.
graSetAttrLine( oPS, aLineAttrib )
oPs:lockPS()
graLine( oPS, { 50,50 },{  500,500 }  )	
oPs:unlockPS()
I'm getting the following error:

Code: Select all

Error BASE/2220
Description : Object has no method with this name
Operation : lockPS
Thread ID : 1
Anyone with a solution for this?

Re: Presentation space in main window of xdemo.

Posted: Fri May 19, 2017 7:41 am
by rdonnay
Chris -

If you want to paint Gra() functions you need to do it after the dialog window is created.
You are trying to do this before the window is created.
This is possible by using DCGRA* commands added to the GetList but I would suggest doing it as below because you can then call any Gra*() functions you wish.

Add the following to your DCREAD GUI EVAL code block:

Code: Select all

  o:drawingArea:paint := {|a,b,o|PaintGraStuff(o)} 
Add the following function:

Code: Select all

STATIC FUNCTION PaintGraStuff( oDrawingArea )

LOCAL aLineAttrib, oPS

aLineAttrib := Array( GRA_AL_COUNT )
aLineAttrib[GRA_AL_WIDTH] := 3
aLineAttrib[GRA_AL_COLOR] := 28555199
oPS := oDrawingArea:lockPS()
graSetAttrLine( oPS, aLineAttrib )
graLine( oPS, { 50,50 },{  500,500 }  )
oDrawingArea:unlockPS()

RETURN nil

Re: Presentation space in main window of xdemo.

Posted: Fri May 19, 2017 8:21 am
by skiman
Hi Roger,

Thanks, this works.

I want to create some kind of organigram with buttons and lines between them. I was planning to use GRALINE to draw lines from the center of one button to another button. Since I'm using rounded corners, some part of the line disappears as soon as the button receives focus.

Also when opening another dialog in another thread, the line appears on that dialog as soon as you move this. See below for the result.

It looks as this will be not so easy to implement. Adding a line clause to the dcpushbuttonXp method could be a solution, I will check this. I suppose the presentation space should be the workarea of the parent in that case.

Re: Presentation space in main window of xdemo.

Posted: Fri May 19, 2017 8:48 am
by rdonnay
I didn't test for that.

You are correct.
I am seeing the same problem.
This may take some work to figure out how to prevent this.

Re: Presentation space in main window of xdemo.

Posted: Fri May 19, 2017 8:56 am
by rdonnay
This works for me. Put a STATIC on the main window and draw on the static instead of the dialog drawingArea.

Code: Select all

@ 5,5 DCSTATIC TYPE XBPSTATIC_TYPE_TEXT OBJECT oGraStatic SIZE 400,400 PIXEL ;
      EVAL {|o|o:paint := {|a,b,o|PaintGraStuff(o)}}

Re: Presentation space in main window of xdemo.

Posted: Fri May 19, 2017 9:11 am
by skiman
Roger,

I created a menusystem with pushbuttons, and now I would like to connect the different buttons with a line.
menusystem.PNG
menusystem.PNG (26.51 KiB) Viewed 14713 times
If I could add a LINE to the dcpushbuttonxp command, this could work. I can add the graline to the draw method.

The oPS that is used in the pushbuttonxp:draw() method is for the space that is reserved for the button. I can't draw on another position.

Re: Presentation space in main window of xdemo.

Posted: Fri May 19, 2017 9:39 am
by rdonnay
The oPS that is used in the pushbuttonxp:draw() method is for the space that is reserved for the button. I can't draw on another position.
Yes, this is correct.

I'm not sure what you want to do.

Re: Presentation space in main window of xdemo.

Posted: Fri May 19, 2017 9:42 am
by skiman
rdonnay wrote:
Yes, this is correct.

I'm not sure what you want to do.
I want to connect the buttons with a line. This way it would show which buttons are related to each other. See it as an organigram.

Re: Presentation space in main window of xdemo.

Posted: Fri May 19, 2017 9:49 am
by rdonnay
I understand that but I don't understand why you would want to add it to the dcpushbutton command.

You will need to draw the lines on the drawingarea of the window which contains the pushbuttons.

Re: Presentation space in main window of xdemo.

Posted: Fri May 19, 2017 10:00 am
by skiman
The following problem arise.

When you HOVER above the button, the :draw() method is called. The corners are also 'repainted' and this will erase the line that should appear there. If the line could be drawn during the draw method of the button, maybe it could be solved.
line_in_corner.PNG
line_in_corner.PNG (2.95 KiB) Viewed 14710 times
You can see that the line is 'overpainted' by the draw method of the button. This would work if radius is set to zero so the result are square buttons.