RapaGUI has full support for high-DPI displays. Normally, RapaGUI handles everything automatically for you so that your application should look the same regardless of the monitor's DPI setting. This is achieved by handling all position and size values in device-independent pixels which makes RapaGUI applications scale nicely to different monitor DPI settings. Furthermore, RapaGUI will automatically scale all raster graphics, e.g. button images set using Button.Icon, to fit to the monitor's DPI setting.
Note that RapaGUI's automatic scaling of raster graphics could lead to images becoming blurry on high-DPI monitors. You can change that by either providing sets of images for different DPI settings instead of just a single image or by using vector images that can be scaled with no losses in quality to any size.
For example, let's suppose you want to add a 32x32px icon to your button using the Button.Icon attribute. If you set Button.Icon to a raster brush and the user's monitor has a DPI scaling of 200% activated, RapaGUI will scale the image to 64x64px which will look blurry. So you could either set Button.Icon to the identifier of a vector brush or you could create a Hollywood icon, add 32x32px and 64x64px images (and possibly more) to it, and then pass this icon to Button.Icon.
Note that in that case you'll also have to set the Button.IconType attribute
to Icon
to tell RapaGUI that you've passed the identifier of an icon instead of a
brush, which is the default type for Button.Icon. In that case, RapaGUI
will use the 32x32px image inside the icon in case the monitor has no DPI scaling
activated or it will use the 64x64px image in case the monitor has a DPI scaling of
200% activated. If the DPI scaling is something between 100% and 200%, RapaGUI will
scale the image inside the icon whose size is closest to the desired target size.
By default, all widgets that support images expect you to pass Hollywood brushes.
If you always want to pass Hollywood icons instead, you can also set the global
attribute Application.UseIcons to True
. This will change the default
of all tags accepting images from Hollywood brushes to Hollywood icons.
As described above, when providing images to RapaGUI using Hollywood brushes that
contain raster data, RapaGUI will automatically scale those raster brushes to fit to the
current monitor's DPI settings. If you don't want that, you can set the ScaleGUI
tag to False
when you @REQUIRE
the RapaGUI plugin. See Initializing RapaGUI for details.
Bilinear interpolation during scaling can be turned off by setting the InterpolateGUI
tag to False
on @REQUIRE
. Alternatively, automatic image scaling can also be configured
on a per-widget basis. For example, for button images you can control automatic image
scaling by setting the Button.IconScale tag.
Also, all Hollywood widgets will be automatically scaled to
fit to the current monitor's DPI settings. If you don't want that, you can set the ScaleHollywood
tag to False
when you @REQUIRE
the RapaGUI plugin. See Initializing RapaGUI for details.
Bilinear interpolation during scaling can be enabled by setting the InterpolateHollywood
tag to True
on @REQUIRE
.
With Scrollcanvas class the dimensions you specify in Scrollcanvas.VirtWidth
and Scrollcanvas.VirtHeight are in device-independent pixels by default and
RapaGUI will automatically apply the system's scale factor to the contents drawn by the Scrollcanvas.Paint
function. If you want to have fine-tuned control, you can set the Scrollcanvas.AutoScale
attribute to False
. In that case, Scrollcanvas.VirtWidth and Scrollcanvas.VirtHeight
are interpreted as physical pixels and no auto scaling will be done so that your paint function can
draw high resolutions graphics without any quality loss due to scaling.
Finally, keep in mind that you explicitly have to enable DPI-aware mode on Windows
if you want your application to support high-DPI modes natively. This can be done
by setting the DPIAware
tag in the @OPTIONS
preprocessor command to True
, e.g.
@OPTIONS {DPIAware = True} |
If you don't do that, your application won't be DPI-aware which means that Windows
will run it in a special compatibility mode. In this compatibility mode, Windows
will scale your application to match the monitor's DPI setting but this will lead
to a blurry appearance. That's why it is suggested to set DPIAware
to True
, as
shown above.
Note that on Linux you should use the GTK+ 3 version of RapaGUI if you want to support high-DPI modes because GTK+ 2 doesn't support high-DPI modes very well.