FUNCTIONS GT

GTI_CONTENTSCALE

Return the scale used to draw the content

Syntax

Signature
GtInfo( GTI_CONTENTSCALE ) --> nScale

Arguments

GTI_CONTENTSCALE

The selector, from gtinfo.ch.

Return value

The factor between the logical pixels of the program and the pixels of the display.

Description

In GTWVT it equals GTI_DISPLAYSCALE.

Notes

Supported by GTWVT, GTSDL3, GTXWC and GTGLFW. On other terminals the result is NIL.

Compare content scale and physical output size after moving the window between displays.

Example

GTI_CONTENTSCALE.prg
#include "inkey.ch"
#include "gtinfo.ch"

#if OS_LINUX
   REQUEST GTXWC
#else
   REQUEST GTWVT
#endif

PROCEDURE Main()

   LOCAL nScale, nWidth, nHeight, nKey

   DO WHILE .T.
      nScale := GtInfo( GTI_CONTENTSCALE )
      nWidth := GtInfo( GTI_OUTPUTWIDTH )
      nHeight := GtInfo( GTI_OUTPUTHEIGHT )
      IF ValType( nScale ) != "N"
         OutStd( "Content scale is unavailable.", Eol() )
         EXIT
      ENDIF

      Scroll()
      DispOutAt( 1, 2, "Content scale: " + LTrim( Str( nScale, 6, 2 ) ) )
      IF ValType( nWidth ) == "N" .AND. ValType( nHeight ) == "N"
         DispOutAt( 2, 2, "Output: " + LTrim( Str( nWidth ) ) + " x " + LTrim( Str( nHeight ) ) + " px" )
      ENDIF
      DispOutAt( 4, 2, "Move the window to another display. R refreshes, Esc exits." )
      nKey := Inkey( 10, INKEY_KEYBOARD )
      IF nKey != Asc( "R" ) .AND. nKey != Asc( "r" )
         EXIT
      ENDIF
   ENDDO

RETURN

Output

See also