<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-15">
<META content="MSHTML 6.00.6000.16674" name=GENERATOR></HEAD>
<BODY style="MARGIN: 4px 4px 1px">
<DIV>Jay:</DIV>
<DIV> </DIV>
<DIV><STRONG>Thanks so much for your work on this issue!!!</STRONG> In my sleep-deprived state I didn't think of switching these fields to be "accessor-based."</DIV>
<DIV> </DIV>
<DIV>I've tested your changes and they seem to work fine for me. I've rebuilt all of cm3 just to make sure there were no compile-time errors.</DIV>
<DIV> </DIV>
<DIV>I also had to adjust my scroll bar implementation on Windows to scale the scroll bar slider. (The slider was not a pixmap and was being drawn based on a default size in millimeters. Since the arrow buttons at the top and bottom of the scroll bar are pixmaps, I had to ensure the slider and margins didn't exceed the width of these pixmaps.) Your procedures in ImageInit made this easy for me. The revised code is now checked into the repository.</DIV>
<DIV> </DIV>
<DIV>
<DIV>I probably need to make the same fix to the slider in the Posix implementation, but since we aren't yet dealing with resolution differences on Posix, maybe it doesn't matter for now. Also, there are no arrow buttons on the Posix scroll bar, so it will probably be okay to just let the slider be the default width in millimeters. The reason I had trouble on Windows was that the slider was wider than the arrow pixmaps when rendered on the hi-res display.</DIV>
<DIV> </DIV>After reflecting on your comments and discussion, I will volunteer with your kind permission to adjust your Image.i3/Image.m3 implementation to be "more in the spirit of Modula-3". Namely, I do think it makes sense to make these fields truly opaque so that access must be governed by the methods. I feel pretty good about the fact that your change didn't break any of the rest of the code in the cm3 tree, so I think there will be few, if any, code breaks in other client code.</DIV>
<DIV> </DIV>
<DIV>Also, I did notice that in ImageInit.m3 you declare a global var "init" but never assign the default value of "FALSE" to this variable before it is tested in the two procedures. Shouldn't this be set to FALSE, or are you relying on something of which I'm unaware? </DIV>
<DIV> </DIV>
<DIV>Also, in ImageInit.m3 you call WinNT.MemoryBarrier(). I looked in the WinNT.i3 file, but there is no comment describing this function. I'm unfamiliar with this function, so I would welcome any explanation you can offer as to what it does.</DIV>
<DIV> </DIV>
<DIV>As for pickles, I don't see how any of your changes would break pickles. The pickler should still be able to pickle these types. Of course, anyone who is using pickles will need to recompile to see the new format, but there should not be any source code changes required.</DIV>
<DIV> </DIV>
<DIV>I also need to thank <STRONG>Daniel</STRONG> for cluing us into the pixmap scaling problem in the first place by pointing out the xres/yres constants of 75.0.</DIV>
<DIV> </DIV>
<DIV>At some point, I do think it makes sense to make a similar set of fixes on Posix because I'm sure that the 75 dpi is not going to be accurate for most modern displays. Of course, we will need to find a way to come up with the right value in a platform-independent way.</DIV>
<DIV> </DIV>
<DIV>Regards,</DIV>
<DIV>Randy<BR><BR>>>> Jay <jayk123@hotmail.com> 8/8/2008 10:05 AM >>><BR><BR>I committed a possible fix here.<BR>Please see how it fairs.<BR><BR>I have a few Modula-3 questions related to the fix.<BR><BR>- Did I have to expose the functions in the .i3 file<BR> that implement the methods? That seems "wrong".<BR><BR><BR> - Could I have used "stronger language opacity" instead<BR> of "informal privacy"? That is, could I have used an<BR> opaque type?<BR><BR> - Will the change break pickles?<BR> "Both" due to the addition of data "or" methods?<BR> ie: What breaks pickles?<BR> Do I need to think in the mindset of<BR> C:<BR> typedef struct {<BR> int a,b;<BR> } foo_t;<BR><BR> foo_t f;<BR> fwrite(&f, sizeof(f), 1, file);<BR><BR> and not breaking such code? <BR> Only if the type is "branded"? Or if types derived from it are branded?<BR> There could be derived types not in the cm3 tree though.<BR> How much do we care about breaking code outside the cm3 tree?<BR> e.g. in this change, I had to change every use of .xres and .yres.<BR> I did that, but only in the code "we have". There could be more out there.<BR> Personally, I get quite frustrated by this issue. I'm very willng to "fix"<BR> and maybe test pretty large amounts of code -- pay the price for fixing things with<BR> "breaking" changes, or else not make the change, but if I don't have the code, I can't.<BR><BR> If this breaks pickles, I can restate the fix in a slightly "weaker" way,<BR> that has some risk of missing code paths, but will likely suffice.<BR><BR> That is, initialize to a distinguished value like 0 or -1<BR> and get rid of the booleans. And, i necessary for pickling,<BR> put the fields back out in "public".<BR><BR><BR>The name of the ImageInit module, I wonder what it should be.<BR><BR><BR> - Jay<BR> <BR><BR><BR>________________________________<BR><BR>Date: Thu, 7 Aug 2008 21:59:07 -0400<BR>From: rcoleburn@scires.com<BR>To: m3devel@elegosoft.com; jayk123@hotmail.com; dabenavidesd@yahoo.es<BR>Subject: RE: [M3devel] pixmap problem (some success)<BR><BR><BR><BR>Jay,<BR><BR><BR><BR>The splash screen is not the major issue. The pixmaps used for boolean choices, radio choices, numerics, etc. get enlarged to the point that some windows won't fit on the screen. Also, it looks really bad--like both a first-grader with a big marker and a college-student with a fine tip pencil worked on the same window.<BR><BR><BR><BR>I've tried very hard to make Trestle/FormsVBT look and act like Windows GUI, but it is indeed different. For example, on menus, you have to hold down the mouse to keep the menu open. All these were small issues 10 years ago, but now they seem to be looming large in the customer's mind.<BR><BR><BR><BR>So, bottom line is that if I can't fix what they deem to be functional problems, they will indeed call for a rewrite.<BR><BR><BR><BR>Now that we've got the typein problem solved (thanks Olaf) and are on track for the pixmap issue, I feel better. I have recently discovered that the numeric keys on the numeric keypad aren't accepted, so I have yet to track that problem down.<BR><BR><BR><BR>As for your idea of using a variable as the default initializer for xres/yres, this is not legal Modula-3. You will get a compile error that the default is not constant. Otherwise, it was a good idea.<BR><BR><BR><BR>Since Raw is an object and objects are created dynamically and new subtypes can be created (inheritance), I think the problem of how to properly set xres/yres is complicated.<BR><BR><BR><BR>Seems like what we need is some way to adjust these fields when the object is created initially. Alas, Raw does not have an init() method!<BR><BR><BR><BR>Regards,<BR><BR>Randy<BR><BR>>>> Jay 8/7/2008 9:35 PM>>><BR><BR>Computing the values is probably easy. It appears we already have the code to do that -- the program I had you run and report the numbers.<BR><BR>It is true there is a *small* problem of computing them early enough, but..yeah, I expect that's just done in the module initializer. I really don't like "global initialization" code ala C++ global constructors/destructors, but Modula-3 is rife with them and they aren't going away, so I'll just pile in a few more bits.<BR><BR>I don't know if is legal Modula-3 code, but if fields can be initialized from globals, that's about all it takes.<BR><BR>SOMETHING LIKE (don't castigate me where I am wrong)<BR>In the platform-independent code, add two private globals:<BR>DefaultXRes : INTEGER;<BR>DefaultYRes : INTEGER;<BR><BR>heck, default them to 75, for the Posix case.<BR><BR>In the platform independent interface, functions to set them:<BR>PROCEDURE SetDefaultXRes(a: INTEGER);<BR>PROCEDURE SetDefaultYRes(a: INTEGER);<BR><BR>Nothing else on Posix, for now.<BR><BR>On Windows, add another module WinImage.m3 that imports Image and just has a module initializer:<BR><BR>BEGIN<BR> Image.SetDefaultXRes(ComputedSomehowNotDifficult());<BR> Image.SetDefaultYRes(ComputedSomehowNotDifficult());<BR>END.<BR><BR>If fields cannot be initialized from globals (or function calls..heh, that has a niceness!), then you have to search out all the uses and change them to function calls, possibly a lot, possibly tedious, definitely a "breaking change", but probably just fine, really.<BR><BR>And then, if fields can be initialized from functions, that'd be better -- that way no module initializer.<BR><BR><BR>Module initializers are "bad" in that they cause a startup cost for "everyone", even if they aren't needed for a particular scenario. It is "best" imho to have constant initialization as much as possible, and where values must be computed, use an explicit function call when needed. You can still cache the values upon first computation.<BR><BR><BR>> would seem that most code must not be computing these, but relying on the default values to be correct.<BR><BR>Or that "most code" doesn't care what the values are, doesn't use them at all.<BR>Like, maybe they are only used for pixmaps and not text or lines?<BR><BR>Anyway, I can't look into this now, but hopefully "soon".<BR>If your customer is antsy, "the problem is mostly understood and a fix will definitely be available soon".<BR>I think "patch Tuesday" is coming up. Let's make it by then? :)<BR><BR><BR>Really, I can't believe they'd call for a rewrite over this small issue.<BR>Presumably they really want the rewrite and are looking for any excuse they can find.<BR>Also, if you removed the "advertising" from the splash screen, they might not have even noticed?<BR>Or, I guess if this is Windows only, the odd look could not be noticed.<BR>But if they also want it on X and you showed it there, and it looked the same on Windows, well...<BR>(Really this is just a general dilemna -- app looks the same as app on all platforms, or app looks like the platform on all platforms.)<BR><BR><BR>- Jay<BR><BR>________________________________<BR><BR>Date: Thu, 7 Aug 2008 20:26:13 -0400<BR>From: rcoleburn@scires.com<BR>To: m3devel@elegosoft.com; jayk123@hotmail.com; dabenavidesd@yahoo.es<BR>Subject: RE: [M3devel] pixmap problem (some success)<BR><BR><BR><BR>Well, I hope to soon share your optimism for "easy".<BR><BR><BR><BR>Since these numbers wind up being default values for the xres/yres and since changing the defaults has made a big difference in the results, it would seem that most code must not be computing these, but relying on the default values to be correct.<BR><BR><BR><BR>Since these numbers may be different for every program run on a different monitor (potentially), the question becomes how to effect a change that will work in all cases without having to recompile vbtkit.<BR><BR><BR><BR>Does this mean we have to track down each use of Image.Raw and put in code to compute the dpi? Or is there some way we can do this during an initialization sequence? but alas, how to deal with the defaults supplied in the declaration?<BR><BR><BR><BR>Regards,<BR><BR>Randy<BR><BR>>>> Jay 8/7/2008 8:16 PM>>><BR><BR>Awesome. I expect it is easy from here. Thanks David!<BR><BR>I *assume* the 75 should have been 86 in the one case,<BR>but close enough that nobody noticed.<BR>So these numbers come pretty directly from the GetDeviceCaps / GetSystemMetrics.<BR><BR>And then X Windows too.<BR>Does anyone have a high DPI monitor running X Windows?<BR>Probably easy enough to do this blind.<BR><BR>I'm trying to ignore the fact that systems have multiple<BR>monitors, with varying dpi. You are supposed to loop your<BR>drawing over monitors and compute what it looks like per-monitor.<BR>I'm just making that up, right? :)<BR><BR>- Jay<BR><BR>________________________________<BR><BR>Date: Thu, 7 Aug 2008 19:42:33 -0400<BR>From: rcoleburn@scires.com<BR>To: m3devel@elegosoft.com; jayk123@hotmail.com; dabenavidesd@yahoo.es<BR>Subject: Re: [M3devel] pixmap problem (some success)<BR><BR><BR><BR>Ok, I solved the Microsoft problem.<BR><BR><BR><BR>Here are the results on Dell M4300 at 1920x1200:<BR><BR><BR><BR>horizonal pixels 1920<BR>veritical pixels SM_CYSCREEN 1200<BR>horizontal millimeters 330<BR>veritical millimeters 206<BR>horizontal pixels per millimeter 5.818182<BR>vertical pixels per millimeter 5.825243<BR>horizontal pixels per inch 147.781818<BR>vertical pixels per inch 147.961165<BR><BR>Wow! these numbers are radically different than the IBM T60 at 1280x1024:<BR><BR><BR><BR>horizonal pixels 1280<BR>veritical pixels SM_CYSCREEN 1024<BR>horizontal millimeters 375<BR>veritical millimeters 300<BR>horizontal pixels per millimeter 3.413333<BR>vertical pixels per millimeter 3.413333<BR>horizontal pixels per inch 86.698667<BR>vertical pixels per inch 86.698667<BR><BR>Now, if you look at the Windows dpi setting for the 1920x1200 machine, it says 96dpi, but this is in the General tab of the Display properties Advanced settings. I suspect this is just the dpi setting applied to fonts.<BR><BR><BR><BR>I tried plugging the numbers into Image.i3 as suggested by Daniel:<BR><BR>TYPE<BR> Raw = OBJECT<BR> width, height: INTEGER;<BR> xres: REAL := 147.781818; (* in pixels per inch *)<BR> yres: REAL := 147.961165; (* in pixels per inch *)<BR> METHODS<BR> get (h, v: INTEGER): Pixel;<BR> set (h, v: INTEGER; pixel: Pixel);<BR> END;<BR><BR>When I do this, my pixmaps look correct on the 1920x1200 display!!!!!<BR><BR><BR><BR>Now, the problem I am faced with is how to come up with a way that the code will work on any type of monitor. I can't edit Image.i3 for every resolution and produce a different binary. Any ideas?<BR><BR><BR><BR>Regards,<BR><BR>Randy<BR><BR><BR>>>> Jay 8/5/2008 9:01 AM>>><BR><BR><BR>Randy, I'm pretty clueless here.<BR>I don't do gui or graphics.<BR>If anyone has a clue, please stand up.<BR>If you can get us code to run, please do.<BR>But I think I need multiple particularly configured machines too.<BR><BR>I'm curious what this code prints on the systems:<BR><BR>#include<BR>#include<BR><BR>int main()<BR>{<BR>int pix_ver = { 0 };<BR>int pix_hor = { 0 };<BR>int mm_hor = { 0 };<BR>int mm_ver = { 0 };<BR>HWND hwnd = { 0 };<BR>HDC hdc = { 0 };<BR><BR>hwnd = GetDesktopWindow();<BR>hdc = GetDC(hwnd);<BR>mm_hor = GetDeviceCaps(hdc, HORZSIZE);<BR>mm_ver = GetDeviceCaps(hdc, VERTSIZE);<BR>pix_hor = GetSystemMetrics(SM_CXSCREEN);<BR>pix_ver = GetSystemMetrics(SM_CYSCREEN);<BR><BR>printf("horizonal pixels %d\n", pix_hor);<BR>printf("veritical pixels SM_CYSCREEN %d\n", pix_ver);<BR>printf("horizontal millimeters %d\n", mm_hor);<BR>printf("veritical millimeters %d\n", mm_ver);<BR><BR>printf("horizontal pixels per millimeter %f\n", (((float) pix_hor) / ((float) mm_hor)));<BR>printf("vertical pixels per millimeter %f\n", (((float) pix_ver) / ((float) mm_ver)));<BR><BR>printf("horizontal pixels per inch %f\n", (((float) pix_hor) / ((float) mm_hor) * 10.0 * 2.54));<BR>printf("vertical pixels per inch %f\n", (((float) pix_ver) / ((float) mm_ver) * 10.0 * 2.54));<BR><BR>return 0;<BR>}<BR><BR><BR>for me:<BR><BR>$ gcc dpi.c -luser32 -lgdi32<BR><BR>jay@jay-win9 /dev2/j/dpi<BR>$ ./a<BR>horizonal pixels 1280<BR>veritical pixels SM_CYSCREEN 800<BR>horizontal millimeters 384<BR>veritical millimeters 240<BR>horizontal pixels per millimeter 3.333333<BR>vertical pixels per millimeter 3.333333<BR>horizontal pixels per inch 84.666667<BR>vertical pixels per inch 84.666667<BR><BR>(Visual C++ is fine:<BR>cl dpi.c user32.lib gdi32.lib<BR>.\dpi<BR>)<BR><BR>I wonder if lying in this code:<BR><BR>Searching for 'GetDeviceCaps'...<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScreenType.m3(25): VAR res := NEW(T); n_colors := GetDeviceCaps (WinGDI.NUMCOLORS);<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScreenType.m3(32): res.depth := GetDeviceCaps(WinGDI.BITSPIXEL); (* John Karnak 8/3/98 *)<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScreenType.m3(68): mm_hor = GetDeviceCaps (WinGDI.HORZSIZE),<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScreenType.m3(69): mm_ver = GetDeviceCaps (WinGDI.VERTSIZE) DO<BR><BR>Searching for 'res.res[Axis.T.'...<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScreenType.m3(71): res.res[Axis.T.Hor] := FLOAT(pix_hor) / FLOAT(mm_hor);<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScreenType.m3(72): res.res[Axis.T.Ver] := FLOAT(pix_ver) / FLOAT(mm_ver);<BR><BR><BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScreenType.m3(89):PROCEDURE GetDeviceCaps (cap: Ctypes.int): INTEGER =<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScreenType.m3(93): res := WinGDI.GetDeviceCaps (hdc, cap);<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScreenType.m3(98): END GetDeviceCaps;<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScrnColorMap.m3(268): cnt := WinGDI.GetDeviceCaps (hdc, WinGDI.NUMCOLORS);<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScrnFont.m3(316): LogicalPixelsPerVertInch := WinGDI.GetDeviceCaps(er.hdc, WinGDI.LOGPIXELSY);<BR>9 occurrence(s) have been found.<BR><BR><BR>Searching for '1000.0'...<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScrnPixmap.m3(463): bmih.biXPelsPerMeter := ROUND (st.res[Axis.T.Hor] * 1000.0);<BR>D:\dev2\cm3.2\m3-ui\ui\src\winvbt\WinScrnPixmap.m3(464): bmih.biYPelsPerMeter := ROUND (st.res[Axis.T.Ver] * 1000.0);<BR><BR><BR>and just claiming 96dpi is the way to go.<BR>Can you try that??<BR><BR><BR>Specifically try setting res.res[Axis.T.Hor] and .Ver to 3.779527559055118.<BR>Or heck to 3.3333 like my laptop has.<BR><BR><BR>Or maybe claiming ignorance and setting biXPelsPerMeter and biYPelsPerMeter to 0???<BR>Claiming ignorance feels better than lying of course. :)<BR><BR>Hm, so throw in also:<BR><BR>printf("LogicalPixelsX %u\n", GetDeviceCaps(hdc, LOGPIXELSX));<BR>printf("LogicalPixelsY %u\n", GetDeviceCaps(hdc, LOGPIXELSY));<BR><BR>I get the magic number 96.<BR><BR>- Jay<BR><BR><BR><BR></DIV></BODY></HTML>