1. Scaling Euphoria MS Windows applications to font DPI
- Posted by Andrew Katz <Akatz712 at gmail.com> May 17, 2007
- 689 views
Both Judith and Quark have complained about my Magic Designer application looking ugly. And the reason why this is, is because I designed it using my computer display at 96 DPI, and they both have theirs set at 120 DPI. So, I set mine at 120 DPI: Right click on Desktop and select Properties. Click Settings. Click Advanced. Set to Large Size (120 DPI) You will need to restart Windows. This issue is a HUGE one. I have noticed that some applications change and others do not! And some web pages change to the correct DPI and others do not. And in some cases, like Thunderbird email application, the user has the ability to adjust field lengths once they have established their DPI for fonts. With Magic Designer, I had carefully sized things using my standard 96 DPI to maximize the drawing area, for people with a 800 x 600 display. And now that I switched to 120 DPI, I can see where my application fails and where it is ugly. For example, I got Derek to write a status line library for me (he never finished it). And one of the things he does is to size the height based upon the font. lHeight = win:getTextHeight(pParent, "M") + 10 However, the widths of the subfields in my status line are too small in 120 DPI, and the information disappears at times. This is a case of an unusable application (well it really is still usable since one can click buttons, but the proper use is interfered with). The most obvious problem is that text is truncated all over the place (inside of edit fields, label fields, labels of controls, caption of buttons). I found this document online, which discusses how to write applications which scale properly for DPI fonts. They say it is simple, but from the point of view of writing in Euphoria, I do not see it as simple. Take a look at this: http://msdn2.microsoft.com/en-us/library/ms969894.aspx I was thinking of writing 2 versions of my program. One for 120 DPI and one for 96 DPI. And let the user pick which one they will run. But of course, 120 is not the only other possible DPI. Another solution would be for me to detect the DPI on start up and make all of the internal adjustments (which would be the differences between my 96 DPI original version, and my soon to be coded 120 DPI version). How would you recommend I approach this problem? Andy Katz B.S. Computer Science, 1978 Rensselaer Polytechnic Institute (RPI)
2. Re: Scaling Euphoria MS Windows applications to font DPI
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> May 17, 2007
- 634 views
Andrew Katz wrote: > > Both Judith and Quark have complained about my Magic Designer application > looking > ugly. And the reason why this is, is because I designed it using my computer > display at 96 DPI, and they both have theirs set at 120 DPI. So, I set mine > at 120 DPI: > > Right click on Desktop and select Properties. > Click Settings. > Click Advanced. > Set to Large Size (120 DPI) > You will need to restart Windows. > > This issue is a HUGE one. I have noticed that some applications change and > others > do not! And some web pages change to the correct DPI and others do not. And > in some cases, like Thunderbird email application, the user has the ability > to adjust field lengths once they have established their DPI for fonts. > > With Magic Designer, I had carefully sized things using my standard 96 DPI to > maximize the drawing area, for people with a 800 x 600 display. And now that > I switched to 120 DPI, I can see where my application fails and where it is > ugly. > > For example, I got Derek to write a status line library for me (he never > finished > it). And one of the things he does is to size the height based upon the font. > lHeight = win:getTextHeight(pParent, "M") + 10 > However, the widths of the subfields in my status line are too small in 120 > DPI, and the information disappears at times. This is a case of an unusable > application (well it really is still usable since one can click buttons, but > the proper use is interfered with). The most obvious problem is that text is > truncated all over the place (inside of edit fields, label fields, labels of > controls, caption of buttons). > > I found this document online, which discusses how to write applications which > scale properly for DPI fonts. They say it is simple, but from the point of > view > of writing in Euphoria, I do not see it as simple. > > Take a look at this: <a > href="http://msdn2.microsoft.com/en-us/library/ms969894.aspx">http://msdn2.microsoft.com/en-us/library/ms969894.aspx</a> > > I was thinking of writing 2 versions of my program. One for 120 DPI and one > for 96 DPI. And let the user pick which one they will run. But of course, 120 > is not the only other possible DPI. Another solution would be for me to detect > the DPI on start up and make all of the internal adjustments (which would be > the differences between my 96 DPI original version, and my soon to be coded > 120 DPI version). > > How would you recommend I approach this problem? > > Andy Katz > B.S. Computer Science, 1978 > Rensselaer Polytechnic Institute (RPI) I just read the MSDN article, and indeed it is simple. 1/ Always use TrueType fonts; 2/ Express ALL dimensions as screen based values rather than a carefully chosen number of pixels. You'll have to use the system metrics API a lot more. 3/ Make image resourcs scalable (icons, cursors). Make controls resizable and remember their positions, so that the user can tweak things according to his own taste and screen resolutions. win32lib stays close to the Windows API, and specifies most sizes in pixels. Most other toolkits (EiffelVision, GTK,perhaps wxEu) don't even ask for dimensions, they are set based on control texts and padding parameters. I think that is the most complex aspect of writing scalable apps in Eu. It dosn't wrap GDI+, even though this would tremendously help. It would take a total rewrite to do all of this, any takers? CChris
3. Re: Scaling Euphoria MS Windows applications to font DPI
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> May 17, 2007
- 662 views
Andrew Katz wrote: > > Both Judith and Quark have complained about my Magic Designer application > looking > ugly. And the reason why this is, is because I designed it using my computer > display at 96 DPI, and they both have theirs set at 120 DPI. So, I set mine > at 120 DPI: <snip> > How would you recommend I approach this problem? Take a look at XControls, now maintained by Greg Haberek. They have a control that will automatically resize controls. http://www.freewebtown.com/ghaberek/xControls2.zip wxEuphoria uses wxWidgets-based classes called sizers to do a similar task. They're a bit more flexible than the XControls geometry control. Matt
4. Re: Scaling Euphoria MS Windows applications to font DPI
- Posted by Derek Parnell <ddparnell at bigpond.com> May 17, 2007
- 724 views
- Last edited May 18, 2007
Andrew Katz wrote: > > For example, I got Derek to write a status line library for me > (he never finished it). I didn't!? I'm sorry, I thought I had done as much as you asked for. What is still outstanding? -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
5. Re: Scaling Euphoria MS Windows applications to font DPI
- Posted by Pete Stoner <stoner.pete at gmail.com> May 17, 2007
- 662 views
- Last edited May 18, 2007
Andrew Katz wrote: > > Both Judith and Quark have complained about my Magic Designer application > looking > ugly. And the reason why this is, is because I designed it using my computer > display at 96 DPI, and they both have theirs set at 120 DPI. So, I set mine > at 120 DPI: > > Right click on Desktop and select Properties. > Click Settings. > Click Advanced. > Set to Large Size (120 DPI) > You will need to restart Windows. > > This issue is a HUGE one. I have noticed that some applications change and > others > do not! And some web pages change to the correct DPI and others do not. And > in some cases, like Thunderbird email application, the user has the ability > to adjust field lengths once they have established their DPI for fonts. > > With Magic Designer, I had carefully sized things using my standard 96 DPI to > maximize the drawing area, for people with a 800 x 600 display. And now that > I switched to 120 DPI, I can see where my application fails and where it is > ugly. > snipped > > Andy Katz > B.S. Computer Science, 1978 > Rensselaer Polytechnic Institute (RPI) Hi Andy, I've also seen and hate this problem.. I didn't find that particular article so I haven't tried switching fonts. The code below is my (poor!) attempt at a fix, just change your "Create" calls to the dpiCreate. I would be interested in hearing if it helps your application at different DPIs. Note the xGetDeviceCaps function does a divide by 96, this is because I design at that setting, so have your window looking good at 96DPI then try switching to a higher value..
include win32lib.ew global constant Centre = "Centre" -- for correct window centering on screen (win32lib doesn't do this right for child windows - Note UK spelling of 'centre'!!) constant xPARAMS = 1, yPARAMS = 2, cxPARAMS = 3, cyPARAMS = 4, X = 1, Y = 2 atom dc atom cxDpi, cyDpi dc = getDC ( Screen ) cxDpi=(w32Func(xGetDeviceCaps,{dc,LOGPIXELSX})/96) cyDpi=(w32Func(xGetDeviceCaps,{dc,LOGPIXELSY})/96) releaseDC(dc) integer centerScreenX, centerScreenY sequence ScreenSize ScreenSize = getRect(Screen) centerScreenX = floor( ScreenSize[3]/2 ) centerScreenY = floor( ScreenSize[4]/2 ) global function DI(integer Orientation, object pixels) if Orientation = X then return floor(pixels * cxDpi) elsif Orientation = Y then return floor(pixels * cyDpi) end if end function global function dpiCreateEx(integer pControl, sequence caption, atom pOwner, object x, object y, object cx, object cy, object styleFlags, object exFlags ) sequence params sequence IgnoreControls -- controls not needing change params = {x, y, cx, cy} IgnoreControls = {Menu, MenuItem} if not find(pControl, IgnoreControls) then if pControl != Window then -- if control is a Window then leave position stuff alone -- chk for relational positioning i.e. ix X < 1 then -- x position must be a 0.x (%) value so leave alone if integer(x) and x > 1 then params[xPARAMS] = DI(X, x) -- also handle w32lib constant calls like 'Center' and {w32AltEdge. -20} elsif sequence(x) and atom(x[2]) and length(x) = 2 then params[xPARAMS] = x params[xPARAMS][2] = DI(X, x[2]) end if if integer(y) and y > 1 then params[yPARAMS] = DI(Y, y) elsif sequence(y) and atom(y[2]) and length(y) = 2 then params[yPARAMS] = y params[yPARAMS][2] = DI(Y, y[2]) end if end if if integer(cx) and cx > 1 then params[cxPARAMS] = DI(X, cx) elsif sequence(cx) and atom(cx[2]) and length(cx) = 2 then params[cxPARAMS] = cx params[cxPARAMS][2] = DI(X, cx[2]) end if if pControl != SortedCombo then if integer(cy) and cy > 1 then params[cyPARAMS] = DI(Y, cy) elsif sequence(cy) and atom(cy[2]) and length(cy) = 2 then params[cyPARAMS] = cy params[cyPARAMS][2] = DI(Y, cy[2]) end if else params[cyPARAMS] = cy end if end if if pControl = Window then -- if control is a 'centered' Window then center it! if equal(x, Centre) then params[xPARAMS] = centerScreenX - floor( params[cxPARAMS]/2 ) end if if equal(y, Centre) then params[yPARAMS] = centerScreenY - floor( params[cyPARAMS]/2 ) end if end if return createEx( pControl, caption, pOwner, params[xPARAMS], params[yPARAMS], params[cxPARAMS], params[cyPARAMS], styleFlags, exFlags) end function global function dpiCreate(integer pControl, sequence caption, atom pOwner, object x, object y, object cx, object cy, object styleFlags ) return dpiCreateEx( pControl, caption, pOwner, x, y, cx, cy, styleFlags, 0) end function
Regards PeteS
6. Re: Scaling Euphoria MS Windows applications to font DPI
- Posted by C Bouzy <CBouzy at Egisca.com> May 19, 2007
- 666 views
Hi Andrew, I do not think you should worry that much about people who set their DPI higher than 96. Very few people even know how to set their DPI higher than 96 so I don’t see this being a huge issue. I just tried setting my DPI higher and running Nexus Radio, and most of the fonts remained the same except a few fonts that are beyond my control. Try using setFont along with a TrueType font and that should fix the issue. "If you do what you have always done, you will get what you always got."
7. Re: Scaling Euphoria MS Windows applications to font DPI
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> May 19, 2007
- 634 views
C Bouzy wrote: > > Hi Andrew, > > I do not think you should worry that much about people who set their DPI > higher > than 96. Very few people even know how to set their DPI higher than 96 so I > don’t see this being a huge issue. > I just tried setting my DPI higher and running Nexus Radio, and most of the > fonts remained the same except a few fonts that are beyond my control. Try > using > setFont along with a TrueType font and that should fix the issue. > > > "If you do what you have always done, you will get what you always got." You are probably right: not many people will change their DPI. However, the question is: how many machine types are there around with various DPI values? Desktop boxes and laptops, for instance, are not likely to share the same values. I change it on a regular basis, so as to find shortcuts and other files on the desktop which were positioned offscreen under XP. CChris
8. Re: Scaling Euphoria MS Windows applications to font DPI
- Posted by Andrew Katz <Akatz712 at gmail.com> May 19, 2007
- 655 views
CChris wrote: > > C Bouzy wrote: > > > > Hi Andrew, > > > > I do not think you should worry that much about people who set their DPI > > higher > > than 96. Very few people even know how to set their DPI higher than 96 so I > > don’t see this being a huge issue. > > I just tried setting my DPI higher and running Nexus Radio, and most of the > > fonts remained the same except a few fonts that are beyond my control. Try > > using > > setFont along with a TrueType font and that should fix the issue. > > > > > > "If you do what you have always done, you will get what you always got." > > You are probably right: not many people will change their DPI. However, the > question is: how many machine types are there around with various DPI values? > Desktop boxes and laptops, for instance, are not likely to share the same > values. > > I change it on a regular basis, so as to find shortcuts and other files on > the desktop which were positioned offscreen under XP. > > CChris I think you are both mistaken. I was confused at first also. To change the DPI is relatively hidden, and requires a reboot, since a different set of fonts must be loaded. So, it is not something you just do as a toggle. People who know about this usually do it because they have large screens and are far sighted (over 40 years old). It did not bother me since I am near sighted and the over 40 canceled that out for near by seeing. Even though one can see less information at a higher DPI, the characters themselves in True Type fonts are more like laser printer quality. So, in the future when large high density LCDs are the norm for screens, a higher DPI will become the standard. A problem is that if you have a user interface with text which uses the standard Windows font it gets larger in a higher DPI. So, all that careful making everything fit nice in the 96 DPI goes to sh-t in 120 DPI. This problem must be even more of a headache in web design! Andy Katz B.S. Computer Science, 1978 Rensselaer Polytechnic Institute (RPI)
9. Re: Scaling Euphoria MS Windows applications to font DPI
- Posted by C Bouzy <CBouzy at Egisca.com> May 19, 2007
- 659 views
Hello Andrew, I am not sure where I was mistaken and/or confused? The point I was making is that 96 DPI is the standard DPI and users rarely change their DPI to a higher value, so I personally wouldn’t put extra time into coding to be compatible with users who are using higher DPI values. I also wouldn't code my apps to be compatible with operating systems prior to Windows 2000 or users with screen resolutions lower than 1024x768. As I mentioned in my previous post setFont along with a TrueType font should override the users DPI settings. Here are some interesting stats: http://www.w3schools.com/browsers/browsers_stats.asp Use the Next button above the stats to view the stats for OS, Display…etc..etc ~ C Bouzy "If you do what you have always done, you will get what you always got."
10. Re: Scaling Euphoria MS Windows applications to font DPI
- Posted by Andrew Katz <Akatz712 at gmail.com> May 20, 2007
- 634 views
C Bouzy wrote: > > Hello Andrew, > > I am not sure where I was mistaken and/or confused? The point I was making is > that 96 > DPI is the standard DPI and users rarely change their DPI to a higher value, > so I personally > wouldn’t put extra time into coding to be compatible with users who are using > higher > DPI values. I also wouldn't code my apps to be compatible with operating > systems prior > to Windows 2000 or users with screen resolutions lower than 1024x768. As I > mentioned > in my previous post setFont along with a TrueType font should override the > users DPI > settings. Here are some interesting stats: <a > href="http://www.w3schools.com/browsers/browsers_stats.asp">http://www.w3schools.com/browsers/browsers_stats.asp</a> > > Use the Next button above the stats to view the stats for OS, Display…etc..etc > > ~ C Bouzy > > "If you do what you have always done, you will get what you always got." This is very interesting information, and valuable for developers. I developed my program for 800 x 600 screen. But I do require Windows XP (and I assume 2000 works even though I am not sure who uses that). The other thing that is interesting is that I know far more Linux and Mac people than these statistics indicate. When it comes to developers Linux has a larger share, and when it comes to artistic types Mac has a larger share. And my program is related to the arts (as well as mathematics). So, what I did was also develop my program in javascript for the web browser. And I tested it with Firefox, IE, and Opera, all the lastest versions. I did not regression test for IE 6, which is still the most popular browser. I use Firefox, myself. The reason for my concern over DPI is that both of the people in the Euphoria community who I have become closest with (in emails) use 120 DPI. So, I felt an effort in that area was needed. Andy Katz B.S. Computer Science, 1978 Rensselaer Polytechnic Institute (RPI)