Lines and rectangles

Lines and rectangles

Postby plantenkennis » Tue Sep 25, 2018 9:35 pm

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

Re: Lines and rectangles

Postby ellano » Wed Sep 26, 2018 1:29 pm

Code: Select all  Expand view
   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  Expand view
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
ellano
 
Posts: 107
Joined: Tue Sep 15, 2009 7:52 am

Re: Lines and rectangles

Postby Antonio Linares » Wed Sep 26, 2018 4:54 pm

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: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Lines and rectangles

Postby Antonio Linares » Thu Sep 27, 2018 6:08 am

René,

New Class TGroup Method SetBorderWidth( nWidth ):
https://bitbucket.org/fivetech/fivemac/commits/a392ba329772acc65c7009bb90a9bcfade9d3ca8
based on new function BoxSetBorderWidth():
https://bitbucket.org/fivetech/fivemac/commits/94fc9ace9ca38ee2fa10a5214c9505fa64faa485

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: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Lines and rectangles

Postby Antonio Linares » Thu Sep 27, 2018 6:20 am

You may use:

oBox:SetBorderType( nType )

where nType is one of the following types:
https://developer.apple.com/documentation/appkit/nsbordertype

#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: 42097
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Lines and rectangles

Postby Antonio Linares » Thu Sep 27, 2018 6:25 am

For rounded corners it seems as we have to subclass from NSBox and override Method drawRect:

https://coredump.uno/questions/28585708/ui-issues-with-custom-nsbox
regards, saludos

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

Re: Lines and rectangles

Postby plantenkennis » Fri Sep 28, 2018 4:42 pm

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
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: Lines and rectangles

Postby mastintin » Sun Sep 30, 2018 9:44 am

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
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Lines and rectangles

Postby plantenkennis » Tue Oct 02, 2018 4:47 am

Hello Mauel,

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

René Koot
User avatar
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands


Return to FiveMac / FivePhone (iPhone, iPad)

Who is online

Users browsing this forum: No registered users and 5 guests