From: <no...@so...> - 2001-10-10 12:49:42
|
Patches item #463234, was opened at 2001-09-20 08:25 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=312997&aid=463234&group_id=12997 Category: 03. [*button] and [label] Group: None Status: Open Resolution: None Priority: 5 Submitted By: Christopher Nelson (chris_nelson) Assigned to: Allen Flick (caflick) Summary: Fix 'Windows button height Initial Comment: This patch makes text buttons on 'Windows the right height. The results are entirely empirical; I have no technical reference that leads me to believe this is "correct" code. However, on NT and W98, creating a button with the correct font, gives a button whose height matches native buttons. This patch was created with diff -patch ourlocalfile mychangedfile >thefile.patch so it may or may not be quite the right format. It includes changes to tkWinButton.c and tkWinDefault.h. ---------------------------------------------------------------------- >Comment By: Christopher Nelson (chris_nelson) Date: 2001-10-10 05:49 Message: Logged In: YES user_id=107514 I've basically re-written TkpComputeButtonGeometry. It now seems to do The Right Thing on 'Windows as described in the Microsoft Windows User Experience. Lots of comments included. My co-worker says she understands it! Still, I expect that there could be some tune-ups. Feedback welcome... ---------------------------------------------------------------------- Comment By: Christopher Nelson (chris_nelson) Date: 2001-09-27 05:34 Message: Logged In: YES user_id=107514 Done! I've got button height (and width) correct on NT and 98 for small and large fonts. Patch attached. I'm going to try REALLY HARD to not work on this anymore unless someone finds a problem with the patch. ---------------------------------------------------------------------- Comment By: Christopher Nelson (chris_nelson) Date: 2001-09-26 06:10 Message: Logged In: YES user_id=107514 I'm 90% there. In TkpComputeButtonGeometry in tkWinButton.c, I've got a clause which looks like: /* * Determine if the user is using large fonts or not. * Logical pixels per inch is 96 for small fonts, 120 for large fonts. * 96/72 = 1.33, 120/72 = 1.6. 1.5 is nicely in the middle. */ dc = GetDC(WUZ); relHeight = GetDeviceCaps(dc, LOGPIXELSY) / 72.0; if (relHeight > 1.5) { largeFonts = 1; } else { largeFonts = 0; } /* * The following was determined empirically. It makes buttons * look right. -- CLN, 2001-09-26 */ if (haveText) { if (largeFonts) { width += 19; height += 1; } else { width += 4; height -= 1; } } but I can't figure out how to get an hDC from a TkButton. Is someone knows the ins and outs of Tk on 'Windows better and can provide guidance, I'd appreciate it. ---------------------------------------------------------------------- Comment By: Christopher Nelson (chris_nelson) Date: 2001-09-26 05:10 Message: Logged In: YES user_id=107514 I've gotten a lesson in selecting large fonts. Quixote <don...@bi...> tells me on comp.os.ms-windows.programmer.win32: If using NT, goto Control Panel->Display->Settings and select either Large or Small Fonts from the Font Size combo box. If using Win98, then goto Control Panel->Display->Settings and then click the Advanced button to get to Font Size. Under Win98 you (at least apparently) have more choice in that you can set a percentage of the normal font size. Selecting 100% is the same as Small Fonts and selecting 125% is the same as Large Fonts, but you can choose other percentages. I'm going to see what that does to my patch. ---------------------------------------------------------------------- Comment By: Christopher Nelson (chris_nelson) Date: 2001-09-24 06:37 Message: Logged In: YES user_id=107514 OK. As Bullwinkle used to say, "This time for sure!" This patch changes ONLY tkWinButton.c -- that is, it leaves the default button Y pad at 1 in tkWinDefault.h. There are still a couple of magic numbers but, hey, that's what it needs. On a Citrix NT server with an Solaris Citrix Client and on a W98 PC, I switched to large and extra large fonts. To my great surprise, button text didn't change size in any 'Windows dialog I pulled up. If that's true, then this fix works for large fonts, too, because the button font doesn't change. If I missed something, I'm willing to revisit large fonts if someone tells me what I'm missing. ---------------------------------------------------------------------- Comment By: Christopher Nelson (chris_nelson) Date: 2001-09-21 19:20 Message: Logged In: YES user_id=107514 You're right that leaving a button's default ypad at 1 gives the programmer more flexibility but I can't get rid of the whole clause; the +4 on width is still needed. I'll put the ypad back, remove the +2 on the height, and provide a new patch on Monday. If someone can tell me how to choose "Large Fonts" on 'Windows, I'll do some work to see that things are too horribily ugly with that configuration and these changes. ---------------------------------------------------------------------- Comment By: Peter Spjuth (pspjuth) Date: 2001-09-21 14:51 Message: Logged In: YES user_id=98900 I don't understand why you change the default -pady to 0 and then add hardcoded padding. I'd day skip these lines: if (haveText) { width += 4; height += 2; } and let -padx/y do that job. Thus leave as much freedom as possible to the programmer. Otherwise it looks like a good thing. ---------------------------------------------------------------------- Comment By: Christopher Nelson (chris_nelson) Date: 2001-09-21 06:14 Message: Logged In: YES user_id=107514 Thanks, Donal. As for buttons with images, it made them too wide. I fixed that. Buttons with text were really 1 pixel too short, at least on my system. I fixed that, too. I removed some unnecessary changes (blank lines I'd added inadvertently, etc.) and used your diff line. New patch attached. ---------------------------------------------------------------------- Comment By: Donal K. Fellows (dkf) Date: 2001-09-21 02:31 Message: Logged In: YES user_id=79902 What effect does this have on buttons containing images? (The recommended way of generating patches is by changing into the root of your local copy of the sources checked out of CVS, and by issuing a 'cvs diff -bu >theFile.patch' command. Patches in a particular subdir generated by the same method are not too bad too, but other mechanisms are harder to evaluate.) ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2001-09-20 09:10 Message: Logged In: NO It might be helpful to recreate the patch with 'diff -u -w' so that whitespace is ignored (you seem to have reformatted quite a few things which gets in the way of seeing the actual code changes you've made) and -u (unified) diffs are also a bit easier to evaluate. ---------------------------------------------------------------------- You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=312997&aid=463234&group_id=12997 |