guides:programming:programmers_reference_manual:scalesize

SCALESIZE method

This method takes an unscaled SIZE property and scales it relative to the current scale factor of the form. The "SCALE" methods perform a DIPs to Pixel conversion.

WINDOWS object

scaledSize = exec_Method( @window, "SCALESIZE", origSize )

Moving a control using DIP coordinates on a form with Pixel SCALEUNITS

* // Example - Move a control using DIP coordinates.  we get the current pixel

* //                 size, unscale it so we have the value as it _would_ be at

* //                 96DPI/ScaleFactor 1 (i.e. DIPs), offset it by 10 DIPs, scale

* //                 it back to Pixels and then move it.

* // Get the current scaled size (pixels) - assume we have a SCALEFACTOR of 1.5

ctrlSize = getProperty( myCtrl, "SIZE" )

 

* // Unscale it back to 96DPI/ScaleFactor 1.0 - i.e. to DIPs

ctrlSize = exec_Method( @window, "UNSCALESIZE", ctrlSize )

 

* // Adjust it to whatever we need (assume we want to offset it by 10 DIPs

* // (10 pixels at 96 DPI)

ctrlSize<1> = ctrlSize<1> + 10

ctrlSize<2> = ctrlSize<2> + 10

 

* // And ask the parent form to calculate where it _should_ be using the

* // current scale factor

ctrlSize = exec_Method( @window, "SCALESIZE", ctrlSize )

 

* // and move it using pixels ...

call set_Property_Only( myCtrl, "SIZE", ctrlSize )

The previous example is rather contrived and is really only there to highlight how the methods can be used. Another way of doing this would be to switch to DIPs using the SCALEUNITS property like so:

* // SCALEUNITS property equates - (from PS_WINDOW_EQUATES)

equ PS_SCU_PIXELS$ to 0

equ PS_SCU_DIPS$    to 1

 

* // Set the scaling units to DIPS

scaleUnits = set_PRoperty( @window, "SCALEUNITS", PS_SCU_DIPS$ )

ctrlSize = get_Property( myCtrl, "SIZE" )

 

* // Offset the control by 10 DIPs

ctrlSize<1> = ctrlSize<1> + 10

ctrlSize<2> = ctrlsize<2> + 10

 

call set_Property_Only( myCtrl, "SIZE", ctrlSize )

 

* // and restore the SCALEUNITS

call set_Property_Only( @window, "SCALEUNITS", scaleUnits )
 
 
 
 
  • guides/programming/programmers_reference_manual/scalesize.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1