Different Pixel Density in wxWidgets Topic is solved

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
User avatar
Ambush
Knows some wx things
Knows some wx things
Posts: 27
Joined: Mon Jun 12, 2017 6:08 pm

Different Pixel Density in wxWidgets

Post by Ambush » Fri Jul 07, 2017 9:44 am

Hi all,

i was just wandering if wxWidgets takes screen size into account when a control is created, for example
if i create a gui with a number of check boxes and radio button etc, would the check boxes and radio buttons
automatically resize for a 4k or 8k display in the sense that it would need more pixels to look the same size
on a screen with a bigger resolution ?

i realize that i do need to resize bitmap buttons and normal buttons though.

tnx
Last edited by Ambush on Fri Jul 07, 2017 1:26 pm, edited 1 time in total.

User avatar
Ambush
Knows some wx things
Knows some wx things
Posts: 27
Joined: Mon Jun 12, 2017 6:08 pm

Re: Different resolutions in wxWidgets

Post by Ambush » Fri Jul 07, 2017 10:02 am

i just rememberd that wxWidgets uses windows native controls so i am guessing that
windows will make the checkboxes look right on 4k or 8k screens, can anyone confirm this ?

User avatar
doublemax
Moderator
Moderator
Posts: 13323
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Different resolutions in wxWidgets

Post by doublemax » Fri Jul 07, 2017 1:00 pm

First of all, the width*height resolution is not relevant, it's only about the pixel density (DPI/PPI).

In order for native controls to get a correct size, two conditions must be met:
a) When creating the controls, you must not pass an explicit size, but use wxDefaultSize
b) Your application must be marked as "dpi aware" though its manifest
https://blogs.msdn.microsoft.com/chuckw ... t-madness/
( under "High-DPI" )
Use the source, Luke!

User avatar
Ambush
Knows some wx things
Knows some wx things
Posts: 27
Joined: Mon Jun 12, 2017 6:08 pm

Re: Different resolutions in wxWidgets

Post by Ambush » Fri Jul 07, 2017 1:12 pm

tnx v much doublemax

so different size values are only needed for custom drawn controlls to look right on higher density screens.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 1915
Joined: Sun Jan 03, 2010 5:45 pm

Re: Different Pixel Density in wxWidgets

Post by PB » Fri Jul 07, 2017 2:16 pm

Shouldn't (well-written) custom controls be also DPI aware? E.g., wxWindow has several methods to assist with that, see its methods containing words "DIP" or "ScaleFactor".

There is also an issue of per-monitor DPI awareness, there is a PR for it though: https://github.com/wxWidgets/wxWidgets/pull/334

User avatar
Ambush
Knows some wx things
Knows some wx things
Posts: 27
Joined: Mon Jun 12, 2017 6:08 pm

Re: Different Pixel Density in wxWidgets

Post by Ambush » Fri Jul 07, 2017 4:21 pm

thanks PB

i will def look at the dip and scalefactor, the sizing was bugging me a bit and
i was not enjoying the thought of having to try and work out multiple sizes for the custom stuff.

nona
Knows some wx things
Knows some wx things
Posts: 32
Joined: Fri Apr 20, 2018 2:49 pm

Re: Different Pixel Density in wxWidgets

Post by nona » Fri Apr 20, 2018 2:59 pm

I have the same issue when I tried to run my GUI app on recommend resolution 2880 x 1800 Windows 10. It works fine. but when I change the resolution into low like 1920 x 1200 It did not display the whole screen. Is any way to fix it without using scrolled bars or windows.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3164
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Different Pixel Density in wxWidgets

Post by ONEEYEMAN » Fri Apr 20, 2018 5:49 pm

Hi,
Did you use default position and size along with the wxSizer API?

Thank you.

nona
Knows some wx things
Knows some wx things
Posts: 32
Joined: Fri Apr 20, 2018 2:49 pm

Re: Different Pixel Density in wxWidgets

Post by nona » Fri Apr 20, 2018 8:02 pm

Yes, I am using wxFlexGridSizer and wxDefaultPosition, wxDefaultSize.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3164
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Different Pixel Density in wxWidgets

Post by ONEEYEMAN » Fri Apr 20, 2018 8:13 pm

Hi,
Did you use the same on the main frame object? Can you shouw the constructor of it and how you call it from the application OnInit() class?

Thank you.

nona
Knows some wx things
Knows some wx things
Posts: 32
Joined: Fri Apr 20, 2018 2:49 pm

Re: Different Pixel Density in wxWidgets

Post by nona » Fri Apr 20, 2018 8:23 pm

Code: Select all

#include "MY_GUIApp.h"

//(*AppHeaders
#include "Guiboard.h"
#include <wx/image.h>
//*)

IMPLEMENT_APP(MY_GUIApp);

bool MY_GUIApp::OnInit()
{
    //(*AppInitialize
    bool wxsOK = true;
    wxInitAllImageHandlers();
    if ( wxsOK )
    {
    	Guiboard* Frame = new Guiboard(0);
    	Frame->Show();
    	SetTopWindow(Frame);
    }
    //*)
    return wxsOK;
}
Last edited by doublemax on Fri Apr 20, 2018 9:02 pm, edited 1 time in total.
Reason: Added code tags

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3164
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Different Pixel Density in wxWidgets

Post by ONEEYEMAN » Fri Apr 20, 2018 8:55 pm

Hi,
And the constructor of Guiboard class?

Also, please use "code" tags so that people can easily read the code you posted.

Thank you.

P.S.: BTW what compiler do you use?

User avatar
doublemax
Moderator
Moderator
Posts: 13323
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Different Pixel Density in wxWidgets

Post by doublemax » Fri Apr 20, 2018 9:05 pm

Can you show a screenshot?

The way i understand it, you just changed the display resolution to 1920x1200, but left the display scaling as it was before? If there is just enough room on the screen to display your gui at that resolution, there is nothing you can do about it.
Use the source, Luke!

nona
Knows some wx things
Knows some wx things
Posts: 32
Joined: Fri Apr 20, 2018 2:49 pm

Re: Different Pixel Density in wxWidgets

Post by nona » Fri Apr 20, 2018 11:29 pm

doublemax wrote:Can you show a screenshot?

The way i understand it, you just changed the display resolution to 1920x1200, but left the display scaling as it was before? If there is just enough room on the screen to display your gui at that resolution, there is nothing you can do about it.
The issue that I am working on windows 10 with 2880 x 1800 resolution. when I run it on VM or Microsoft surface which the resolution is lower. So the GUI app looks bigger and did not display all its information.

nona
Knows some wx things
Knows some wx things
Posts: 32
Joined: Fri Apr 20, 2018 2:49 pm

Re: Different Pixel Density in wxWidgets

Post by nona » Fri Apr 20, 2018 11:34 pm

ONEEYEMAN wrote:Hi,
And the constructor of Guiboard class?

Also, please use "code" tags so that people can easily read the code you posted.

Thank you.

P.S.: BTW what compiler do you use?
It is big one with a lot of details to copy here which information exactly you need from it?

Post Reply