Lines and rectangles
- plantenkennis
- Posts: 166
- Joined: Wed Nov 25, 2015 7:13 pm
- Location: the Netherlands
- Contact:
Lines and rectangles
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..)
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
René Koot
Re: Lines and rectangles
Code: Select all | Expand
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
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
- Antonio Linares
- Site Admin
- Posts: 42512
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 73 times
- Contact:
- Antonio Linares
- Site Admin
- Posts: 42512
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 73 times
- Contact:
Re: Lines and rectangles
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/
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/
- Antonio Linares
- Site Admin
- Posts: 42512
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 73 times
- Contact:
Re: Lines and rectangles
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
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
- Antonio Linares
- Site Admin
- Posts: 42512
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 73 times
- Contact:
Re: Lines and rectangles
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
https://coredump.uno/questions/28585708/ui-issues-with-custom-nsbox
- plantenkennis
- Posts: 166
- Joined: Wed Nov 25, 2015 7:13 pm
- Location: the Netherlands
- Contact:
Re: Lines and rectangles
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.
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
René Koot
Re: Lines and rectangles
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.
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.
- plantenkennis
- Posts: 166
- Joined: Wed Nov 25, 2015 7:13 pm
- Location: the Netherlands
- Contact:
Re: Lines and rectangles
Hello Mauel,
Thank you, this works perfectly for me. This programming tool is getting better every time. I love it.
Thank you, this works perfectly for me. This programming tool is getting better every time. I love it.
Kind regards,
René Koot
René Koot