box align question

box align question

Postby Silvio.Falconi » Sun Apr 09, 2023 12:27 am

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 ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6804
Joined: Thu Oct 18, 2012 7:17 pm

Re: box align question

Postby nageswaragunupudi » Sun Apr 09, 2023 1:41 am

If you want center both vertically and horizontally then use "" or nil for cAlign
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10259
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: box align question

Postby Silvio.Falconi » Fri Apr 14, 2023 12:25 pm

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 4


Nages 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 )
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6804
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 15 guests