Lines and rectangles

Post Reply
User avatar
plantenkennis
Posts: 151
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands
Contact:

Lines and rectangles

Post 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..)
Kind regards,

René Koot
ellano
Posts: 107
Joined: Tue Sep 15, 2009 7:52 am

Re: Lines and rectangles

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Lines and rectangles

Post by Antonio Linares »

René,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Lines and rectangles

Post 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/
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Lines and rectangles

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Lines and rectangles

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
plantenkennis
Posts: 151
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands
Contact:

Re: Lines and rectangles

Post 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.
Kind regards,

René Koot
User avatar
mastintin
Posts: 1502
Joined: Thu May 27, 2010 2:06 pm

Re: Lines and rectangles

Post 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.
User avatar
plantenkennis
Posts: 151
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands
Contact:

Re: Lines and rectangles

Post by plantenkennis »

Hello Mauel,

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

René Koot
Post Reply