To Nages : other problem with oPrn:Box
Posted: Thu Nov 11, 2021 10:35 am
I have problem when I must centered a TEXT
oPrn:Box(nRow,nCol,nHeight+nRow,nWidth, { cColorborder, nTipoBorder }, cBackborder, ;
{ cTesto, oFnt, nColorFont, cAlign }, ;
"CM" )
you wrote me this
"TL" : TopLeft
"TR" : TopRight
"T" : Top Center
"BL" : Bottom Left
"BR" : Bottom Right
"B" : Bottom Center
"L" : Left Vert Center
"R" : Right Vert Center
I have this problem
on the table I insert these coordinates

Then I insert the position and the align
cAlign:= String_Align (nAlign,nPosition)
and now I have cAlign:= String_Align (1,3) but I tried also with other positions
and I have this result

I wish centered the text on the box
in my opinion it is not enough to have alone
"T" : Top Center
"B" : Bottom Center
but i hope you find a solution to enter the central position
"C" : center that is, neither top nor bottom
How we can resolve it ?
I made a small test to undestand the problem ,How I can to move the text on center of the box?

the test
Working arround
I understood there is not a solution but only solution could be this
Build two box
One with border and no text
one without box and the text
result

This solution seems like bullshit to me because I would have to insert two records for every time I have to center a text inside a box
oPrn:Box(nRow,nCol,nHeight+nRow,nWidth, { cColorborder, nTipoBorder }, cBackborder, ;
{ cTesto, oFnt, nColorFont, cAlign }, ;
"CM" )
you wrote me this
"TL" : TopLeft
"TR" : TopRight
"T" : Top Center
"BL" : Bottom Left
"BR" : Bottom Right
"B" : Bottom Center
"L" : Left Vert Center
"R" : Right Vert Center
I have this problem
on the table I insert these coordinates

Then I insert the position and the align
cAlign:= String_Align (nAlign,nPosition)
Code: Select all | Expand
Function String_Align (nAlign,nPosition)
local cPosition,cAlign
//position
DO CASE
Case nPosizione=1
cPosition:="T"
Case nPosizione=2
cPosition:="B"
Case nPosizione=3
cPosition:=""
ENDCASE
//align
DO CASE
Case nAlign=1
cAlign:="L"
Case nAlign=2
cAlign:="R"
Case nAlign=3
cAlign:=""
ENDCASE
return alltrim(cPosition+cAlign)
and now I have cAlign:= String_Align (1,3) but I tried also with other positions
and I have this result

I wish centered the text on the box
in my opinion it is not enough to have alone
"T" : Top Center
"B" : Bottom Center
but i hope you find a solution to enter the central position
"C" : center that is, neither top nor bottom
How we can resolve it ?
I made a small test to undestand the problem ,How I can to move the text on center of the box?

the test
Code: Select all | Expand
#include "fivewin.ch"
Function test()
local oPrn
local nRiga := 20.80
local nColonna := 1
local nAltezza := 0.70
local nlarghezza := 19.00
local cColorBordo:=CLR_BLACK
local ntipobordo:=0.01
local cBackbordo:=CLR_WHITE
local cTesto := "Descrizione esenzione"
local oFnt
local nColorFont:= CLR_BLACK
local nAllinea :=3
local nPosizione:=1
local cAlign:= TypeAlign (nAllinea,nPosizione)
oPrn:=PrintBegin("test",.F.,.t.,,.T.)
oPrn:SetPortrait()
PageBegin()
oFnt:=TFont():New("Arial",0,-6,.F.,.f. ,,,,.f.,,,,,,,oPrn)
oPrn:Box(nRiga,nColonna,nAltezza+nRiga,nlarghezza, { cColorbordo, nTipoBordo }, cBackbordo, ;
{ cTesto, oFnt, nColorFont, cAlign }, ;
"CM" )
oFnt:end()
PageEnd()
PrintEnd()
RETURN NIL
Function TypeAlign (nAllinea,nPosizione)
local cPosition,cAlign
/*
"TL" : TopLeft
"TR" : TopRight
"T" : Top Center
"BL" : Bottom Left
"BR" : Bottom Right
"B" : Bottom Center
"L" : Left Vert Center
"R" : Right Vert Center
*/
//position
DO CASE
Case nPosizione=1
cPosition:="T"
Case nPosizione=2
cPosition:="B"
Case nPosizione=3
cPosition:=""
ENDCASE
//align
DO CASE
Case nAllinea=1
cAlign:="L"
Case nAllinea=2
cAlign:="R"
Case nAllinea=3
cAlign:=""
ENDCASE
return alltrim(cPosition+cAlign)
//------------------------------------------------------------//
Working arround
I understood there is not a solution but only solution could be this
Build two box
One with border and no text
one without box and the text
Code: Select all | Expand
#include "fivewin.ch"
Function test()
local oPrn
local nRiga := 20.80
local nColonna := 1
local nAltezza := 0.70
local nlarghezza := 19.00
local cColorBordo:=CLR_BLACK
local ntipobordo:=0.01
local cBackbordo:=CLR_WHITE
local cTesto := ""
local oFnt
local nColorFont:= CLR_BLACK
local nAllinea :=3
local nPosizione:=1
local cAlign:= TypeAlign (nAllinea,nPosizione)
oPrn:=PrintBegin("test",.F.,.t.,,.T.)
oPrn:SetPortrait()
PageBegin()
oFnt:=TFont():New("Arial",0,-6,.F.,.f. ,,,,.f.,,,,,,,oPrn)
//first Box
oPrn:Box(nRiga,nColonna,nAltezza+nRiga,nlarghezza, { cColorbordo, nTipoBordo }, cBackbordo, ;
{ cTesto, oFnt, nColorFont, cAlign }, ;
"CM" )
//second Box
nRiga := 21.05
cTesto := "Descrizione esenzione"
oPrn:Box(nRiga,nColonna,nAltezza+nRiga,nlarghezza, {"", 0 }, "", ;
{ cTesto, oFnt, nColorFont, cAlign }, ;
"CM" )
oFnt:end()
PageEnd()
PrintEnd()
RETURN NIL
Function TypeAlign (nAllinea,nPosizione)
local cPosition,cAlign
/*
"TL" : TopLeft
"TR" : TopRight
"T" : Top Center
"BL" : Bottom Left
"BR" : Bottom Right
"B" : Bottom Center
"L" : Left Vert Center
"R" : Right Vert Center
*/
//position
DO CASE
Case nPosizione=1
cPosition:="T"
Case nPosizione=2
cPosition:="B"
Case nPosizione=3
cPosition:=""
ENDCASE
//align
DO CASE
Case nAllinea=1
cAlign:="L"
Case nAllinea=2
cAlign:="R"
Case nAllinea=3
cAlign:=""
ENDCASE
return alltrim(cPosition+cAlign)
//------------------------------------------------------------//
result

This solution seems like bullshit to me because I would have to insert two records for every time I have to center a text inside a box
