New Class : TSayjustified

New Class : TSayjustified

Postby Silvio.Falconi » Mon Apr 11, 2016 8:06 pm

I found some function on forum by Antolin and I thinked to converte to a control class
// viewtopic.php?f=6&t=19174


Image


Image


CREATE FIRST A YOUR Fichero.txt or use this
Code: Select all  Expand view
I found some function on forum by Antolin and I make the control class / I found some function on forum by Antolin and I make the control class I found some function on forum by Antolin and / I make the control class I found some function on forum by Antolin and I make the control class I found some function on forum by Antolin and I make the control class/ I found some function on forum by Antolin and I make the control class I found some function on forum by Antolin and I make the control class I found some function on forum by Antolin and I make the control class I found some function on forum by Antolin and I make the control class I found some function on forum by Antolin and I make the control class I found some function on forum by Antolin and I make the control class I found some function on forum by Antolin and I make the control class I found some function on forum by Antolin and I make the control class


use the symbol "/" to make a CRLF into the File text if you want


the test

Code: Select all  Expand view


#include "FiveWin.ch"

Function test()
Local oWnd
Local oSay

 Local  cText  := MemoRead( "Fichero.txt" )
 Local  nlenght := 200
 Local  nLinea  := 10

DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14

DEFINE WINDOW oWnd

osay:=TSayjustified():New(10, 10, oWnd,  250, 200, cText,nLinea, nlenght, oFont)


ACTIVATE WINDOW oWnd
RETURN NIL
 




the class TSayjustified


Code: Select all  Expand view


#include "FiveWin.ch"
#include "Constant.ch"


CLASS TSayjustified  FROM TControl

       DATA  cText           INIT ""
       DATA  nLenght         AS NUMERIC
       DATA  nColorTesto     AS NUMERIC INIT  nRGB( 125, 165, 224 )
       DATA  nLinea          AS NUMERIC
       DATA  aTexto          AS ARRAY   INIT {}
       DATA  lBorder         AS LOGICAL INIT .T.
       DATA  nBorderLine     AS NUMERIC INIT 3
       DATA  oFont
       DATA  nColorBorder    AS NUMERIC INIT  CLR_RED
       DATA  nColorBack      AS NUMERIC INIT  nRGB(  89, 135, 214 )
       DATA  ltransparent    AS LOGICAL INIT .T.


   CLASSDATA lRegistered AS LOGICAL

METHOD New( nTop, nLeft, oWnd,  nWidth, nHeight,cText,nLinea,;
             nlenght, oFont, nColortesto,nBorderLine,lBorder,nColorBack,;
             nColorBorder,lPixel,lTransparent,lDesign, lUpdate ) CONSTRUCTOR
   METHOD ReDefine( nId, oWnd ) CONSTRUCTOR
   METHOD Display() INLINE ::BeginPaint(), ::Paint(), ::EndPaint(), 0
   METHOD Paint()
   METHOD FormatText()
   METHOD PainText()
   METHOD _FillRect( nTop, nLeft, nBottom, nRight, nColor )

ENDCLASS

//----------------------------------------------------------------------------//

METHOD New(nTop, nLeft, oWnd,  nWidth, nHeight,cText,nLinea,;
           nlenght, oFont, nColortesto,nBorderLine,lBorder,nColorBack,;
           nColorBorder,lPixel,lTransparent,lDesign, lUpdate ) CLASS TSayjustified

   DEFAULT nTop     := 0, nLeft := 0           ,;
           oWnd     := GetWndDefault()         ,;
           lPixel   := .t.                     ,;
           nBorderLine := 3                    ,;
           lBorder  := .t.                     ,;
           nWidth   := 400, nHeight := 200     ,;
           nLenght  := 150                     ,;
           nColortesto := CLR_BLACK            ,;
           lTransparent  := .t.                ,;
           lDesign  := .f.                     ,;
           lUpdate  := .f.

   ::nStyle    = nOR( WS_CHILD, WS_VISIBLE, WS_TABSTOP )
   ::nId       = ::GetNewId()
   ::oWnd      = oWnd
   ::ctext     = ctext
   ::nTop      = If( lPixel, nTop, nTop * SAY_CHARPIX_H )
   ::nLeft     = If( lPixel, nLeft, nLeft * SAY_CHARPIX_W )
   ::nBottom   = ::nTop + nHeight - 1
   ::nRight    = ::nLeft + nWidth - 1

   ::oFont     = oFont

   ::nLinea    = nLinea
   ::nColortesto = nColortesto
   ::nLenght     = nLenght
   ::lTransparent  = lTransparent

   ::lDrag     = lDesign
   ::lCaptured = .f.
   ::lUpdate   = lUpdate

   ::nStyle    = nOR( WS_CHILD, WS_VISIBLE,;
                 If( lDesign, nOr( WS_CLIPSIBLINGS, WS_TABSTOP ), 0 )  )

   ::Register( nOR( CS_VREDRAW, CS_HREDRAW ) )

   if ! Empty( oWnd:hWnd )
      ::Create()
      ::Default()
      oWnd:AddControl( Self )
   else
      oWnd:DefControl( Self )
   endif

    if ::lDrag
      ::CheckDots()
   endif

return Self

//----------------------------------------------------------------------------//

METHOD ReDefine( nId, oWnd, cText,nLinea,;
           nlenght, oFont, nColortesto,nBorderLine,lBorder,nColorBack,;
           nColorBorder ) CLASS TSayjustified

   DEFAULT oWnd     := GetWndDefault()         ,;
           nBorderLine := 3                    ,;
           lBorder  := .t.                     ,;
           nLenght  := 200

   ::nId  = nId
   ::oWnd = oWnd


   ::oFont       = oFont
   ::nLinea      = nLinea
   ::nColortesto = nColortesto
   ::nLenght     = nLenght

   ::Register()

   oWnd:DefControl( Self )

return Self

//----------------------------------------------------------------------------//
  METHOD _FillRect( nTop, nLeft, nBottom, nRight, nColor ) CLASS TSayjustified

   LOCAL oBrush, hBru, hOld, nMid

   hBru := CreateSolidBrush( nColor )
   hOld := SelectObject( ::hDC, hBru )

      FillRect( ::hDC, { nTop, nLeft, nBottom, nRight }, hBru )

   SelectObject( ::hDC, hOld )
   DeleteObject( hBru )

   RETURN (Nil)

//----------------------------------------------------------------------------//

 METHOD Paint()      CLASS TSayjustified
    Local aRect       := GetClientRect( ::hWnd )
    Local nMidLine,hPen,hOldPen
    Local hDC      := ::hDC

    * Local aInfo       := ::DispBegin()


  //  IF ::lTransparent

  //     ::DrawPBack( ::hWnd, hDC )

  //    ELSE

         ::_FillRect( aRect[1], aRect[2], aRect[3],aRect[4], ::nColorBack )

 //     ENDIF


    //background



     // create array atexto
    ::FormatText(hDC )



       // paint the text
   ::PainText(hDc,::oFont,::aTexto,::nLenght,::nLinea,::nColorTesto)


    If ::lBorder
      hPen := CreatePen( 0, ::nBorderLine, ::nColorBorder )
      hOldPen := SelectObject( ::hDc, hPen )
      nMidLine := ::nBorderLine / 2
      MoveTo( ::hDC, nMidLine, nMidLine )
      LineTo(::hDC, nMidLine, ::nHeight - nMidLine , hPen )
      LineTo(::hDC, ::nWidth - nMidLine, ::nHeight - nMidLine , hPen )
      LineTo(::hDC, ::nWidth - nMidLine , nMidLine, hPen )
      LineTo(::hDC, nMidLine, nMidLine, 0, hPen )
   ENDIF


   ::oFont:end()
   * ::DispEnd( aInfo )
   return 0
//----------------------------------------------------------------------------//

METHOD FormatText(hDC) CLASS TSayjustified
   LOCAL nCont,nTokn,nCrLf
   LOCAL cWord,cLinea,lFinLin


   cLinea  := ""

   DO WHILE !Empty(::cText)
      lFinLin := .F.
      cLinea  := ""
      cWord  := StrToken(::cText,1)

      IF Left(cWord,2) = CRLF
         ::cText  := SubStr(::cText,3)
         cWord := ""
         cLinea := ""
         lFinLin := .T.
      ENDIF

      nTokn := 0



      DO WHILE !Empty(cWord)
         cWord := StrToken(::cText,1)
         nCrLf  := AT( CRLF, cWord )

          IF cWord="/"     //MORE ...
             cWord := CRLF
             ++nTokn
         ENDIF


         IF nCrLf > 0
            cWord  := Left(cWord,nCrLf-1)
            lFinLin := .T.
         ENDIF

         IF GetTextWidth(hDc,cLinea+cWord,::oFont:hFont) > ::nLenght
            EXIT

         ELSEIF lFinLin
            ::cText := STUFF(::cText,1,LEN(cWord)+2,"")
            cLinea += cWord
            ++nTokn
            EXIT
         ELSE
            ::cText := LTRIM(STUFF(::cText,1,LEN(cWord),""))
            cLinea += cWord+" "
            ++nTokn
         ENDIF



      ENDDO
      AADD( ::aTexto, {RTRIM(cLinea),nTokn,lFinLin} )
   ENDDO

   ATail(::aTexto)[3] := .T.



   return ::aTexto


//----------------------------------------------------------------------------//

   METHOD PainText(hDc,oFont,aText,nWidth,nLinea,nColorTesto)     CLASS TSayjustified
    LOCAL hOldFnt := SelectObject( hDc, oFont:hFont )
    LOCAL nCont,nLong,nExtra

   FOR nCont = 1 TO LEN(aText)
       nLong  := GetTextWidth(hDc,aText[nCont,1],oFont:hFont)
       nExtra := 0

    IF !aText[nCont,3] .AND. Len( aText[nCont,1] ) < (nWidth-nLong)
      nExtra := Min( 4, Int((nWidth-nLong)/Len(aText[nCont,1])) )
      nExtra := SetTextCharacterExtra( hDc, nExtra )
      nLong  := GetTextWidth(hDc,aText[nCont,1],oFont:hFont)
    ENDIF


       IF !aText[nCont,3] .AND. nLong < nWidth
          SetTextJustification(hDc, nWidth-nLong, aText[nCont,2]-1)
       ENDIF


       SetBkMode( hDC, 1 )
       SetTextColor( hDC, nColorTesto )
       ExtTextOut( hDc, nLinea, 22, {nLinea,22,nLinea+16,22+nWidth}, aText[nCont,1],0 )
       nLinea += 18
       SetTextJustification(hDc, 0, 0)
       SetTextCharacterExtra( hDc, nExtra )
   NEXT
   SelectObject( hDc, hOldFnt )

    return nil

 //-----------------------------------------------------------------------------------------//





#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>

HB_FUNC( SETTEXTCHARACTEREXTRA )
   {
   hb_retni( SetTextCharacterExtra( ( HDC ) hb_parnl( 1 ), ( int ) hb_parni( 2 ) ) ) ;
   }

#pragma ENDDUMP





 





Only I have a problem with the method ::DrawPBack( ::hWnd, hDC ) to make the say transparent

any solution ?

please Antonio ?
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: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Re: New Class : TSayjustified

Postby Antonio Linares » Mon Apr 11, 2016 8:51 pm

Have you tried with SetBkMode( hDC, TRANSPARENT ) ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42076
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: New Class : TSayjustified

Postby cuatecatl82 » Mon Apr 11, 2016 10:47 pm

Perfect Work Silvio..
Soluciones y Diseño de Software
Damos Soluciones...

I.S.C. Victor Daniel Cuatecatl Leon
Director y Diseñador de Proyectos

http://www.soldisoft.unlugar.com
http://www.sisa.unlugar.com
danyleon82@hotmail.com
www.facebook.com/victordaniel.cuatecatlleon
User avatar
cuatecatl82
 
Posts: 625
Joined: Wed Mar 14, 2007 6:49 pm
Location: San Cristobal de las Casas, Chiapas México

Re: New Class : TSayjustified

Postby Silvio.Falconi » Tue Apr 12, 2016 9:18 am

Antonio Linares wrote:Have you tried with SetBkMode( hDC, TRANSPARENT ) ?



on method Painttext antolin used SetBkMode( hDC, 1 ) i think perhaps it not need drawpback

but sometimes I have problem with fonts on win 7

do you Know the Antolin mail ? I wish ash some questions ...
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: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Re: New Class : TSayjustified

Postby Silvio.Falconi » Tue Apr 12, 2016 5:26 pm

New release - I found update functions of Antolin on this forum

I change also the Look ( Antolin simulated a Page )


IN THIS RELEASE there is a new data

DATA nCuantos AS NUMERIC INIT 30


this data set the number of the rows to show I set the number init to 30


Code: Select all  Expand view
#include "FiveWin.ch"
#include "Constant.ch"


Function test()
Local oWnd
Local oSay

 Local  cText  := MemoRead( "Fichero.txt" )
 Local  nlenght := 750
 Local  nLinea  := 10
 Local  oFont :=  TFont():New( GetSysFont(), 0, -9,, .t. )

DEFINE WINDOW oWnd

osay:=TSayjustified():New(100, 10, oWnd,  800 , 500 , cText,nLinea, nlenght, oFont)


ACTIVATE WINDOW oWnd

return nil

// I found some function on forum by Antolin and I make the control class
//   viewtopic.php?f=6&t=19174


CLASS TSayjustified  FROM TControl

       DATA  cText           INIT ""
       DATA  nLenght         AS NUMERIC
       DATA  nColorTesto     AS NUMERIC INIT  nRGB( 125, 165, 224 )
       DATA  nLinea          AS NUMERIC
       DATA  aTexto          AS ARRAY   INIT {}
       DATA  lBorder         AS LOGICAL INIT .T.
       DATA  nBorderLine     AS NUMERIC INIT 3
       DATA  oFont
       DATA  nColorBorder    AS NUMERIC INIT  CLR_RED
       DATA  nColorBack      AS NUMERIC INIT  nRGB(  89, 135, 214 )
       DATA  ltransparent    AS LOGICAL INIT .T.
       DATA  nCuantos        AS NUMERIC INIT 30

   CLASSDATA lRegistered AS LOGICAL

   METHOD New( nTop, nLeft, oWnd,  nWidth, nHeight,cText,nLinea,;
             nlenght, oFont, nColortesto,nBorderLine,lBorder,nColorBack,;
             nColorBorder,lPixel,lTransparent,lDesign, lUpdate ) CONSTRUCTOR
   METHOD ReDefine( nId, oWnd ) CONSTRUCTOR
   METHOD Display() INLINE ::BeginPaint(), ::Paint(), ::EndPaint(), 0
   METHOD Paint()
   METHOD FormatText()
   METHOD PainText()
   METHOD _FillRect( nTop, nLeft, nBottom, nRight, nColor )

ENDCLASS
//----------------------------------------------------------------------------//

METHOD New(nRow, nCol, oWnd,  nWidth, nHeight,cText,nLinea,;
           nlenght, oFont, nColortesto,nBorderLine,lBorder,nColorBack,;
           nColorBorder,lPixel,lTransparent,lDesign, lUpdate ) CLASS TSayjustified

   DEFAULT nRow     := 0, nCol := 0           ,;
           oWnd     := GetWndDefault()         ,;
           lPixel   := .t.                     ,;
           nBorderLine := 3                    ,;
           lBorder  := .t.                     ,;
           nWidth   := 400, nHeight := 200     ,;
           nLenght  := 150                     ,;
           nColortesto := CLR_BLACK            ,;
           lTransparent  := .t.                ,;
           lDesign  := .f.                     ,;
           lUpdate  := .f.

   ::nStyle    = nOR( WS_CHILD, WS_VISIBLE, WS_TABSTOP )
   ::nId       = ::GetNewId()
   ::oWnd      = oWnd
   ::ctext     = ctext

   if oFont  = NIL
       ::oFont    = TFont():New( GetSysFont(), 0, -9,, .t. )
   else
      ::oFont     = oFont
   endif

    if ! lPixel
      ::nTop  = nRow * If( oFont != nil, Abs( oFont:nHeight ), SAY_CHARPIX_H ) + 2        // 13
      ::nLeft = nCol * If( oFont != nil, Abs( oFont:nWidth ), SAY_CHARPIX_W )                    // 8
   else
      ::nTop  = nRow
      ::nLeft = nCol
   endif


   ::nBottom   = ::nTop + nHeight - 1
   ::nRight    = ::nLeft + nWidth - 1


   ::nLinea      = nLinea
   ::nColortesto = nColortesto
   ::nLenght     = nLenght
   ::lTransparent  = lTransparent

   ::lDrag     = lDesign
   ::lCaptured = .f.
   ::lUpdate   = lUpdate

   ::nStyle    = nOR( WS_CHILD, WS_VISIBLE,;
                 If( lDesign, nOr( WS_CLIPSIBLINGS, WS_TABSTOP ), 0 )  )

   ::Register( nOR( CS_VREDRAW, CS_HREDRAW ) )

   if ! Empty( oWnd:hWnd )
      ::Create()
      ::Default()
      oWnd:AddControl( Self )
   else
      oWnd:DefControl( Self )
   endif

    if ::lDrag
      ::CheckDots()
   endif

return Self

//----------------------------------------------------------------------------//

METHOD ReDefine( nId, oWnd, cText,nLinea,;
           nlenght, oFont, nColortesto,nBorderLine,lBorder,nColorBack,;
           nColorBorder ) CLASS TSayjustified

   DEFAULT oWnd     := GetWndDefault()         ,;
           nBorderLine := 3                    ,;
           lBorder  := .t.                     ,;
           nLenght  := 200

   ::nId  = nId
   ::oWnd = oWnd


   ::oFont       = oFont
   ::nLinea      = nLinea
   ::nColortesto = nColortesto
   ::nLenght     = nLenght

   ::Register()

   oWnd:DefControl( Self )

return Self

//----------------------------------------------------------------------------//
  METHOD _FillRect( nTop, nLeft, nBottom, nRight, nColor ) CLASS TSayjustified

   LOCAL oBrush, hBru, hOld, nMid

   hBru := CreateSolidBrush( nColor )
   hOld := SelectObject( ::hDC, hBru )

      FillRect( ::hDC, { nTop, nLeft, nBottom, nRight }, hBru )

   SelectObject( ::hDC, hOld )
   DeleteObject( hBru )

   RETURN (Nil)

//----------------------------------------------------------------------------//

 METHOD Paint()      CLASS TSayjustified
    Local aRect       := GetClientRect( ::hWnd )
    Local nMidLine,hPen
    Local hDC      := ::hDC
    LOCAL hOldPen  := SelectObject( ::hDc, GetStockObject( 7 ) )
    LOCAL hOldBush := SelectObject( ::hDc, GetStockObject( 4 ) )
    * Local aInfo       := ::DispBegin()


    // create array atexto
      ::FormatText(::cText,::oFont,::nLenght)


    //background
   Rectangle(::hDc, aRect[1], aRect[2], aRect[3],aRect[4] )
   SelectObject( ::hDc, GetStockObject( 0 ) )
   Rectangle(::hDc, aRect[1]-10, aRect[2]-10, aRect[3]-10,aRect[4]-10 )


       // paint the text
   ::PainText(::oFont,::aTexto,::nLenght,::nLinea,::nColorTesto)


    If ::lBorder
      hPen := CreatePen( 0, ::nBorderLine, ::nColorBorder )
      hOldPen := SelectObject( ::hDc, hPen )
      nMidLine := ::nBorderLine / 2
      MoveTo( ::hDC, nMidLine, nMidLine )
      LineTo(::hDC, nMidLine, ::nHeight - nMidLine , hPen )
      LineTo(::hDC, ::nWidth - nMidLine, ::nHeight - nMidLine , hPen )
      LineTo(::hDC, ::nWidth - nMidLine , nMidLine, hPen )
      LineTo(::hDC, nMidLine, nMidLine, 0, hPen )
   ENDIF

   SelectObject( ::hDc, hOldBush)
   SelectObject( ::hDc, hOldPen )
   ::oFont:end()

   * ::DispEnd( aInfo )
   return 0
//----------------------------------------------------------------------------//


 METHOD FormatText(cFrase,oFont,nAnch) CLASS TSayjustified
 * FUNCTION FormatText(hDc,cFrase,hFnt,nAnch,nCuantos)
   LOCAL cTrozo,cRengl,lFin
   LOCAL nChar := Int(nAnch/GetTextWidth(::hDc,"B",oFont:hFont))-5
   LOCAL aLins := {}
   LOCAL nCrlf := 0
   LOCAL nCnt  := 0
   LOCAL nTok  := 0



       ::aTexto := {}

   *
   DO WHILE !Empty(cFrase) .AND. nCnt < ::nCuantos
      ++nCnt
      lFin   := .F.
      cRengl := ""
      nTok   := 0

      *
      nCrlf  := Len(cFrase)-Len(LTRIM(cFrase))  // POR SI EMPIEZA CON ESPACIOS
      cTrozo := Space(nCrlf)+StrToken(cFrase,1)
      *

      IF Left(cTrozo,2) = CRLF
     cFrase := SubStr(cFrase,3)
     cTrozo := ""
     lFin   := .T.
  ENDIF


  IF GetTextWidth(::hDc,cTrozo,oFont:hFont) > nAnch

     cRengl := Left(cTrozo,nChar)
     cFrase := SubStr(cFrase,nChar+1)
     cTrozo := Left(cFrase,1)


     DO WHILE !( GetTextWidth(::hDc,cRengl+cTrozo,oFont:hFont) > nAnch )
        cRengl := cRengl+cTrozo
        cFrase := SubStr(cFrase,2)
        cTrozo := Left(cFrase,1)
     ENDDO



     IF !Empty(cRengl)
        nTok   := 1
     ENDIF
     cTrozo := ""
      ENDIF
      *


      DO WHILE !Empty(cTrozo) .AND. !Empty(cFrase)
         nCrlf  := Len(cFrase)-Len(LTRIM(cFrase))   // POR SI EMPIEZA CON ESPACIOS
     cTrozo := Space(nCrlf)+StrToken(cFrase,1)
     *
     nCrlf  := AT( CRLF, cTrozo )
     IF nCrlf > 0
        cTrozo := Left(cTrozo,nCrlf-1)
        lFin := .T.
     ENDIF
     *
     IF GetTextWidth(::hDc,cRengl+cTrozo,oFont:hFont) > nAnch
        IF nAnch > 100 .AND. GetTextWidth(::hDc,cRengl,oFont:hFont) < (nAnch*0.75)
           cFrase := cRengl+cFrase
           cRengl := Left(cRengl+cTrozo,nChar)
           cFrase := SubStr(cFrase,LEN(cRengl)+1)
           cTrozo := Left(cFrase,1)


      DO WHILE !( GetTextWidth(::hDc,cRengl+cTrozo,oFont:hFont) > nAnch )
          cRengl := cRengl+cTrozo
          cFrase := SubStr(cFrase,2)
          cTrozo := Left(cFrase,1)
        ENDDO
           ++nTok
        ENDIF
        lFin   := .F.
        cTrozo := ""
     ELSEIF lFin
        cFrase := SubStr(cFrase,LEN(cTrozo)+2+1)    // +2 POR EL CRLF
        cRengl += cTrozo
        cTrozo := ""
        ++nTok
     ELSE
        cFrase := SubStr(cFrase,LEN(cTrozo)+1)
        cRengl += cTrozo
        ++nTok
     ENDIF
     *
     IF Empty(cFrase)   // LA ULTIMA LINEA SIEMPRE HA DE SER FIN DE PARRAFO
        lFin := .T.
     ENDIF
      ENDDO
      *
      nCrlf := Len(cRengl)-Len(LTRIM(cRengl))
      IF nCrlf < 2
     cRengl := ALLTRIM(cRengl)
      ELSE
     cRengl := RTRIM(SubStr(cRengl,2))
      ENDIF
      *
     AADD(::aTexto,{cRengl,nTok,lFin})
  ENDDO

RETURN ::aTexto



//----------------------------------------------------------------------------//

   METHOD PainText(oFont,aText,nWidth,nLinea,nColorTesto)     CLASS TSayjustified
    LOCAL hOldFnt := SelectObject( ::hDc, oFont:hFont )
    LOCAL nCont,nLong,nExtra

   FOR nCont = 1 TO LEN(aText)
       nLong  := GetTextWidth(::hDc,aText[nCont,1],oFont:hFont)
       nExtra := 0

    IF !aText[nCont,3] .AND. Len( aText[nCont,1] ) < (nWidth-nLong)
      nExtra := Min( 4, Int((nWidth-nLong)/Len(aText[nCont,1])) )
      nExtra := SetTextCharacterExtra( ::hDc, nExtra )
      nLong  := GetTextWidth(::hDc,aText[nCont,1],oFont:hFont)
    ENDIF


       IF !aText[nCont,3] .AND. nLong < nWidth
          SetTextJustification(::hDc, nWidth-nLong, aText[nCont,2]-1)
       ENDIF


       SetBkMode( ::hDC, 1 )
       SetTextColor( ::hDC, nColorTesto )
       ExtTextOut( ::hDc, nLinea, 22, {nLinea,22,nLinea+16,22+nWidth}, aText[nCont,1],0 )
       nLinea += 18
       SetTextJustification(::hDc, 0, 0)
       SetTextCharacterExtra( ::hDc, nExtra )
   NEXT
   SelectObject( ::hDc, hOldFnt )

    return nil

 //-----------------------------------------------------------------------------------------//


#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>

HB_FUNC( SETTEXTCHARACTEREXTRA )
   {
   hb_retni( SetTextCharacterExtra( ( HDC ) hb_parnl( 1 ), ( int ) hb_parni( 2 ) ) ) ;
   }

#pragma ENDDUMP


//-----------------------------------------------------------------------------------------//


 





Mr antolin please can write to private mail pls silvio[dot]falconi[at]gmail[dot]com thanks
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: 7048
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 121 guests