box align question
Posted:
Sun Apr 09, 2023 12:27 am
by Silvio.Falconi
when I make a box I use
::oPrn:Box(X, Y, Z, K,;
{ nColorBordo, ::SetBorder(nSizeBordo) }, nBackcolor, ;
{cText, oFnt, nColorFont, ::SetAlign(nAlignOriz,nAlignVert) }, ;
"CM" )
on ::SetAlign(nAlignOriz,nAlignVert) I build the string to align/position
but I have only 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
Case nAlignOriz=1
cPosition:="T"
Case nAlignOriz=2
cPosition:="B"
Case nAlignOriz=3
cPosition:=""
Case nAlignVert=1
cAlign:="L"
Case nAlignVert=2
cAlign:="R"
Case nAlignVert=3
cAlign:=""
If I have 3/3 then I have " " and the on box I have problem
How I can make to justify a test in the box ?
Re: box align question
Posted:
Sun Apr 09, 2023 1:41 am
by nageswaragunupudi
If you want center both vertically and horizontally then use "" or nil for cAlign
Re: box align question
Posted:
Fri Apr 14, 2023 12:25 pm
by Silvio.Falconi
nageswaragunupudi wrote:If you want center both vertically and horizontally then use "" or nil for cAlign
on my application I have these options
local aAlign :={"left","right","Center","justified"}
local aPosition :={"on top","on bottom","on center"}
and I make this function
sample SetAlign(1,1) - Code: Select all Expand view
Function SetAlign(nAlignOriz,nAlignVert)
local cPosition
local cAlign
//Position
If nAlignOriz >0
DO CASE
Case nAlignOriz=1
cPosition:="T"
Case nAlignOriz=2
cPosition:="B"
Case nAlignOriz=3
cPosition:=""
ENDCASE
else
cPosition:=""
Endif
//Align
IF nAlignVert>0
DO CASE
Case nAlignVert=1
cAlign:="L"
Case nAlignVert=2
cAlign:="R"
Case nAlignVert=3
cAlign:=""
Case nAlignVert=4
cAlign:=""
ENDCASE
else
cAlign:=""
Endif
return (cPosition+cAlign)
the problem comes when i have the first parameter
equal to 4Nages why not add also this
https://forums.fivetechsupport.com/viewtopic.php?f=6&t=19174&p=100831&hilit=justified&sid=e145c6a55f03012c1d00e6a353d65314&sid=36975723a48188529e6b1af0b5ecab33#p163260 ?
I found also this- Code: Select all Expand view
METHOD JustifyText( cText, nLen, oFont, lPixel ) CLASS TPrinter
local cAuxi:=ALLTRIM(cText), nLenPixel:=0, nSpace:=1
local aWords:={}, i:=0, cSubst:="", cSpell:="", lDone:=.T.
for i = 1 to len(cText)
cSubst := SUBST(cText,i,1)
if cSubst = " "
aadd(aWords,cSpell)
cSpell = ""
endif
cSpell += cSubst
next
if .not.empty(cSpell)
aadd(aWords,cSpell)
endif
if len(aWords)=0 .OR. len(aWords)=1
return cText
endif
if lPixel = nil .or. .not.lPixel
nLenPixel = Max( 0, ( nLen * 10 * ::nHorzRes() / ::nHorzSize() ) - ::nXoffset )
else
nLenPixel = nLen
endif
while .T.
cAuxi = ""
lDone = .F.
for i = 1 to len(aWords)
IF i # len(aWords)
cAuxi += aWords[ i ] + SPACE(nSpace)
ENDIF
next
IF ::GetTextWidth( cAuxi, oFont ) >= nLenPixel
lDone = .T.
EXIT
ENDIF
nSpace ++
enddo
IF lDone
cText = cAuxi
ENDIF
return cText
how it is used
- Code: Select all Expand view
DEFINE FONT oFT12N NAME "Arial" SIZE 0,-11 OF oPrn
cFrase = "Quinto Encontro de FiveWiners em Novembro/2007, espero ver todos presentes!"
nLen = 19 \\ largura do A4 com margens
cJustificado = oPrn:JustifyText(cFrase,nLen,oFT12N)
oPrn:CmSay(01,01,cJustificado,oFT12N,NIL,CLR_BLACK)
and I tried and it make this error I not understood
- Code: Select all Expand view
Application
===========
Path and name: C:\Work\errori\justity\test.Exe (32 bits)
Size: 4,433,920 bytes
Compiler version: Harbour 3.2.0dev (r2104281802)
FiveWin version: FWH 22.03
C compiler version: Borland C++ 5.8.2 (32-bit)
Windows version: 6.2, Build 9200
Time from start: 0 hours 0 mins 0 secs
Error occurred at: 04/14/23, 15:18:29
Error description: Error BASE/1004 Message not found: TPRINTER:JUSTIFYTEXT
Args:
[ 1] = O TPRINTER
Stack Calls
===========
Called from: => __ERRRT_SBASE( 0 )
Called from: ../../../tobject.prg => TPRINTER:ERROR( 0 )
Called from: ../../../tobject.prg => (b)HBOBJECT( 0 )
Called from: ../../../tobject.prg => TPRINTER:MSGNOTFOUND( 0 )
Called from: ../../../tobject.prg => TPRINTER:JUSTIFYTEXT( 0 )
Called from: test.prg => TESTALIGN( 74 )