Problem command SAY

Problem command SAY

Postby mauri.menabue » Fri Mar 12, 2021 9:23 am

Good morning everyone

It seems to me that there is a problem in the ADJUST clause of the SAY command, the size of the displayed text is not calculated correctly.
to verify this try the test below.
Thank you

Code: Select all  Expand view

#include "FiveWin.ch"

Function Main

   LOCAL oFont AS OBJECT
   LOCAL oDlg  AS OBJECT
   LOCAL oSay  AS OBJECT
   
   oFont := tFont():new("Tahoma", 0, -12.00 ,,.F.,,,,.F.)

   DEFINE DIALOG oDlg        ;
            SIZE 400,400     ;
           TITLE "Test " + FWVERSION    ;
       TRUEPIXEL             ;
            FONT oFont      
 
    @ 20, 20 SAY oSay VAR "Percentuale detraibilita'" ;
                     SIZE GetTextWidth( 0, "Percentuale detraibilita'", oFont ) , oFont:nHeight * 2 ;
                       OF oDlg ;
                    PIXEL ;
                     FONT oFont ;
                   BORDER  

    @ 60, 20 SAY oSay VAR "Percentuale detraibilita'" ;
                       OF oDlg ;
                    PIXEL ;
                     FONT oFont ;
                   BORDER ;
                   ADJUST                              
 
   ACTIVATE DIALOG oDlg CENTER
   
   oFont:end()

return nil
 
User avatar
mauri.menabue
 
Posts: 155
Joined: Thu Apr 17, 2008 2:38 pm

Re: Problem command SAY

Postby karinha » Fri Mar 12, 2021 12:22 pm

Code: Select all  Expand view

// \samples\MAURI3.PRG

#Include "FiveWin.ch"

FUNCTION Main()

   LOCAL oFont AS OBJECT
   LOCAL oDlg  AS OBJECT
   LOCAL oSay  AS OBJECT
   LOCAL cPercent1, cPercent2, cTitle

   cPercent1 := "Percentuale detraibilita'"
   cPercent2 := "Percentuale detraibilita'"
   cTitle    := "Professional Edition - FiveWin the best!"

   // oFont := tFont():new( "Tahoma", 0, - 12.00,, .F.,,,, .F. ) // .PPO

   DEFINE FONT oFont NAME "Calibri"        SIZE 0,  -14 BOLD     // Normal

   DEFINE DIALOG oDlg SIZE 400, 400 TITLE cTitle TRUEPIXEL FONT oFont        ;
      COLORS CLR_BLACK, CLR_WHITE TRANSPARENT

   oDlg:lHelpIcon := .F.

   @ 20, 20 SAY oSay VAR cPercent1 OF oDlg PIXEL FONT oFont BORDER           ;
      SIZE GetTextWidth( 0, "Percentuale detraibilita'", oFont ),            ;
      oFont:nHeight * 2 UPDATE TRANSPARENT COLORS CLR_CYAN, CLR_WHITE ADJUST
     
   @ 60, 20 SAY oSay VAR cPercent2 OF oDlg PIXEL FONT oFont BORDER           ;
      SIZE 150, 24 UPDATE TRANSPARENT COLORS CLR_HRED, CLR_WHITE ADJUST

   ACTIVATE DIALOG oDlg CENTER

   oFont:End()

RETURN NIL

// FIN
 


Saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7794
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Problem command SAY

Postby mauri.menabue » Fri Mar 12, 2021 4:42 pm

Hi all
The problem depends on whether the dialog is set to PIXEL or TRUEPIXEL,
in the case of pixels the problem is highlighted as you can try from the following test program.
I ask if Antonio can apply the changes back to the bottom of the tsay class test program.

Kind regards
Maurizio Menabue

Code: Select all  Expand view

#include "FiveWin.ch"

Function Main

   LOCAL oFont AS OBJECT
   LOCAL oDlg  AS OBJECT
   LOCAL oSay  AS OBJECT
   
   oFont := tFont():new("Tahoma", 0, -12.00 ,,.F.,,,,.F.)

   DEFINE DIALOG oDlg        ;
            SIZE 400,400     ;
           TITLE "Test " + FWVERSION    ;
           PIXEL             ;
            FONT oFont      
 
    @ 20, 20 SAY oSay ;
             VAR "Percentuale detraibilita' PIXEL" ;
              OF oDlg ;
           PIXEL ;
            FONT oFont ;
           COLOR CLR_HBLUE, CLR_YELLOW;
          ADJUST                              
 
   ACTIVATE DIALOG oDlg CENTER

   DEFINE DIALOG oDlg        ;
            SIZE 400,400     ;
           TITLE "Test " + FWVERSION    ;
           TRUEPIXEL         ;
            FONT oFont      
 
    @ 20, 20 SAY oSay ;
             VAR "Percentuale detraibilita' TRUEPIXEL" ;
              OF oDlg ;
           PIXEL ;
            FONT oFont ;
           COLOR CLR_HBLUE, CLR_YELLOW;
          ADJUST                              
 
   ACTIVATE DIALOG oDlg CENTER
   
   oFont:end()

return nil

*--------------------------------------
*- Piece of code in original class tSay
*--------------------------------------

*-100    DEFAULT nWidth := GetTextWidth( 0, ::cCaption, If( oFont != nil, oFont:hFont,;
*-101           If( oWnd:oFont != nil, oWnd:oFont:hFont,) ) )

*--------------------------------------
*- Piece of code in modified class tSay
*--------------------------------------

*-100   DEFAULT nWidth := (GetTextWidth( 0, ::cCaption, If( oFont != nil, oFont:hFont,;
*-101           If( oWnd:oFont != nil, oWnd:oFont:hFont,) ) ) ) / IF(oWnd:lTruePixel, 1, 2)  <==============


*--------------------------------------
*- Piece of code in original class tSay
*--------------------------------------

*-351   if ! Empty( ::hWnd )
*-352      if ! lAnd( GetWindowLong( ::hWnd, GWL_STYLE ), nOr( SS_LEFT, SS_RIGHT, SS_CENTER ) ) .AND. ::lAdjust
*-353         nWidth = GetTextWidth( 0, ::cCaption, If( ::oFont != nil, ::oFont:hFont,) ) + 20
*-354         if nWidth > ::nWidth
*-355            ::nWidth = nWidth
*-356         endif
*-357      endif
*-358      SetWindowText( ::hWnd, ::cCaption )
*-359   endif

*--------------------------------------
*- Piece of code in modified class tSay
*--------------------------------------

*-351   if ! Empty( ::hWnd )
*-352      if ! lAnd( GetWindowLong( ::hWnd, GWL_STYLE ), nOr( SS_LEFT, SS_RIGHT, SS_CENTER ) ) .AND. ::lAdjust
*-353         nWidth := (GetTextWidth( 0, ::cCaption, If( ::oFont != nil, ::oFont:hFont,) ) + 20) / IF(::oWnd:lTruePixel, 1, 2) <==============
*-354         if nWidth > ::nWidth
*-355            ::nWidth = nWidth
*-356         endif
*-357      endif
*-358      SetWindowText( ::hWnd, ::cCaption )
*-359   endif
 
 
User avatar
mauri.menabue
 
Posts: 155
Joined: Thu Apr 17, 2008 2:38 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 42 guests