FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveMac / FivePhone (iPhone, iPad) Lines and rectangles
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Lines and rectangles
Posted: Tue Sep 25, 2018 09: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
Posts: 107
Joined: Tue Sep 15, 2009 07:52 AM
Re: Lines and rectangles
Posted: Wed Sep 26, 2018 01:29 PM
Code (fw): Select all Collapse
    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 (fw): Select all Collapse
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Lines and rectangles
Posted: Wed Sep 26, 2018 04:54 PM

René,

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Lines and rectangles
Posted: Thu Sep 27, 2018 06: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Lines and rectangles
Posted: Thu Sep 27, 2018 06: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Lines and rectangles
Posted: Thu Sep 27, 2018 06: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
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: Lines and rectangles
Posted: Fri Sep 28, 2018 04: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
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Lines and rectangles
Posted: Sun Sep 30, 2018 09: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.

Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: Lines and rectangles
Posted: Tue Oct 02, 2018 04: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

Continue the discussion