How to use wxWindow::ConvertDialogToPixels

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Davros
Experienced Solver
Experienced Solver
Posts: 52
Joined: Mon Jan 16, 2006 10:02 pm
Location: England
Contact:

How to use wxWindow::ConvertDialogToPixels

Post by Davros » Tue Jan 31, 2006 6:51 pm

How do I determine initial sizes in "dialog units" rather than pixels?

I see the manual says this about ConvertDialogToPixels:
For the x dimension, the dialog units are multiplied by the average character width and then divided by 4.
For the y dimension, the dialog units are multiplied by the average character height and then divided by 8.
Why divide by 4 or 8? Are these just arbitrary values?

I see ConvertDialogToPixels could be quite useful in scaling windows on different DPI settings. However, how do I arrive suitable dimensions when I am writing my app?

For example, let's suppose I want my window to be approx. 300 pixels wide on my development machine, but also want the window to be scaled suitably on client machines with differing DPIs. Do I just have to arrive at an equivalent width in "dialog units" by trial and error?

As an alternate stratedgy, I could use a #define to specify my development DPI, i.e.

#define BUILDDPI 96

and in my code divide the current screen dpi by this to arrive at a suitable scaling factor. It would have the advantage of yielding a scaling factor of 1 on my development machine, which would make positioning of controls easier.

What's a good DPI scaling stratedgy?
OS: Windows XP
WxWidgets: 2.6.3
Compilers: Code::Blocks(MinGW), VC2005 & BCB5


Image
BigAngryDog.com

Cursor
Earned some good credits
Earned some good credits
Posts: 120
Joined: Sun Aug 29, 2004 3:09 pm
Location: Grenoble, France
Contact:

Post by Cursor » Wed Feb 01, 2006 6:34 am

The DPI (1) is a standard "density of point" measure. For the screen, we must speak about PPI (2) "Pixel per Inch" that is generally 72, 96 or 144.

1 : http://en.wikipedia.org/wiki/Dpi
2 : http://en.wikipedia.org/wiki/Pixels_per_inch
What is little and green, witch go up and down ??
Yoda playing with the force.

Davros
Experienced Solver
Experienced Solver
Posts: 52
Joined: Mon Jan 16, 2006 10:02 pm
Location: England
Contact:

Post by Davros » Wed Feb 01, 2006 7:29 am

Hi,

Thanks for the reply.

>For the screen, we must speak about PPI (2) "Pixel per Inch" that is generally 72, 96 or 144.

While I accept you are right, of course, it certainly is confusing, expecially when my Windows screen settings dialog uses the term "DPI". Hence my confusion.

In any case, my question still stands.

How do I determine initial sizes in "dialog units" rather than pixels?
OS: Windows XP
WxWidgets: 2.6.3
Compilers: Code::Blocks(MinGW), VC2005 & BCB5


Image
BigAngryDog.com

Post Reply