Page 1 of 1

Lines and rectangles

Posted: Tue Sep 25, 2018 9:35 pm
by plantenkennis
Hello
I can draw a line in a window or on paper using the next code:
@ nRow, nCol LINE HORIZONTAL SIZE oPrn:pageWidth() OF oPrn
But can I set the thickness of the line?

And is there also a code to draw a rectangle, in variations., like rounded corners, different lines (dotted, striped, full..)

Re: Lines and rectangles

Posted: Wed Sep 26, 2018 1:29 pm
by ellano

Code: Select all

    DrawLine( oDlg1,270,540,250,540,0)
...

//---------------- Tracer une ligne entre 2 points avec une couleur définie -----//
Function DrawLine( oDlg1, xFrom, yFrom , xTo , yTo, nColor)
   LOCAL hPen, hOldPen
   LOCAL hDC1 := oDlg1:GetDC()

   hPen := CreatePen( 0, 2, nColor )   // largeur 2
   hOldPen := SelectObject( hDC1, hPen )

   MoveTo( hDC1, yFrom, xFrom )
   LineTo( hDC1, yTo,   xTo)

   SelectObject( hDC1, hOldPen )
   DeleteObject( hPen )
   oDlg1:ReleaseDc()

return NIL
 
If you meant in a report then:

Code: Select all

PrnLandscape()
PRINT oReport NAME "With lines" PREVIEW
DEFINE PEN oPen WIDTH 2 OF oReport
PAGE

nColumn:=oReport:nHorzRes()/132  && 132 columns
nRow:=oReport:nVertRes()/66 
oReport:LINE(7.5*nRow,5*nColumn,7.5*nRow,130*nColum,oPen)
ENDPAGE
ENDPRINT
oPen:END()
RELEASE ALL
Emiliano Llano Díaz

Re: Lines and rectangles

Posted: Wed Sep 26, 2018 4:54 pm
by Antonio Linares
René,

That code is for Windows. We will check for the OSX equivalent

Re: Lines and rectangles

Posted: Thu Sep 27, 2018 6:08 am
by Antonio Linares
René,

New Class TGroup Method SetBorderWidth( nWidth ):
https://bitbucket.org/fivetech/fivemac/ ... fade9d3ca8
based on new function BoxSetBorderWidth():
https://bitbucket.org/fivetech/fivemac/ ... fa64faa485

Example of use:
@ nRow, nCol LINE HORIZONTAL oBox SIZE oPrn:pageWidth() OF oPrn
oBox:SetBorderWidth( 2.3 ) // any decimal value here

New FiveMac libs available from here:
https://bitbucket.org/fivetech/fivemac/src/master/lib/

Re: Lines and rectangles

Posted: Thu Sep 27, 2018 6:20 am
by Antonio Linares
You may use:

oBox:SetBorderType( nType )

where nType is one of the following types:
https://developer.apple.com/documentati ... bordertype

#define bezelBorder 2
#define grooveBorder 3
#define lineBorder 1
#define noBorder 0

Re: Lines and rectangles

Posted: Thu Sep 27, 2018 6:25 am
by Antonio Linares
For rounded corners it seems as we have to subclass from NSBox and override Method drawRect:

https://coredump.uno/questions/28585708 ... stom-nsbox

Re: Lines and rectangles

Posted: Fri Sep 28, 2018 4:42 pm
by plantenkennis
Hello Antonio,

The commands works perfect with GROUP command, but I don't see any changes WITH the LINE?
However, I can use a Group with height 5, that gives a thick line.

The rounded corners are not imporant for me, so if that gives problems at other places, we should not use it.

Re: Lines and rectangles

Posted: Sun Sep 30, 2018 9:44 am
by mastintin
To make it work WITH in NSBox the box type must be NSBoxCustom = 4 .

See Testgrp.prg ....
Change :

@ 60 ,10 LINE HORIZONTAL oline SIZE 372 OF oDlg

to

@ 60, 10 GROUP oline SIZE 372, 5 OF oDlg
oline:setCustom()
oline:setBorderType(1)
oline:setBorderColor(0,255,0,100)
oline:SetBorderWidth( 5 )

anyway , @property NSBorderType borderType is deprecated and It's not advisable use custom lines in views.

Re: Lines and rectangles

Posted: Tue Oct 02, 2018 4:47 am
by plantenkennis
Hello Mauel,

Thank you, this works perfectly for me. This programming tool is getting better every time. I love it.