home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / amiga / programm / 16080 < prev    next >
Encoding:
Internet Message Format  |  1992-11-19  |  5.9 KB

  1. Path: sparky!uunet!spool.mu.edu!darwin.sura.net!ukma!cs.widener.edu!dsinc!bagate!cbmvax!peter
  2. From: peter@cbmvax.commodore.com (Peter Cherna)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: GRIPE! about refreshing string gadgets
  5. Message-ID: <37149@cbmvax.commodore.com>
  6. Date: 19 Nov 92 14:46:23 GMT
  7. References: <paulk.28zg@terapin.com>
  8. Reply-To: peter@cbmvax.commodore.com (Peter Cherna)
  9. Organization: Commodore-Amiga, Inc.  West Chester, PA.
  10. Lines: 100
  11.  
  12. In article <paulk.28zg@terapin.com> paulk@terapin.com (Paul Kienitz) writes:
  13. >In my current project, I have lots of string gadgets, and sometimes
  14. >they need to be enabled and disabled in response to other input, and
  15. >sometimes they need to have their text contents altered, and sometimes
  16. >both at once.  I've noticed that all versions of Intuition do a LOUSY
  17. >JOB of refreshing string gadgets in different states, when the string
  18. >is shorter than the gadget and I'm also using the 2.x feature of
  19. >having different colors for active and inactive string gadgets.
  20. >Furthermore, different versions mess up in different ways.
  21.  
  22. Intuition does not do a "lousy" job of this at all.  There is a single
  23. buglet that I know of, and it only affects 2.0, not 1.3 or 3.0.  (That
  24. hardly qualifies as "all versions").  This bug involves StringExtend
  25. string gadgets whose background color is set to be other than zero.
  26. If one string gadget is disabled, then all string gadgets earlier in the
  27. list will have some remnant of the ghosting pattern in their container.
  28.  
  29. If you wish to report any other bug, please describe that bug.  Also,
  30. be sure to remove a string gadget from the window before modifying
  31. its contents or the fields of any of its structures.
  32.  
  33. > - Pad the current string in the gadget with spaces so as to
  34. >    completely fill the visible space with text.  Under 2.x, pad it
  35. >    so the terminating nul char falls just after the end of the
  36. >    visible space, under 1.x pad it so the nul is just inside the end
  37. >    or else it will refresh one character space OUTSIDE the
  38. >    boundaries of the gadget.
  39.  
  40. There is a version-based difference in how wide the area to be cleared
  41. will be.  Well-designed gadgets come out the same under all versions,
  42. but ill-specified ones may have their appearance altered depending on
  43. the OS version.  Under 1.3 and earlier, Intuition clears only a whole
  44. number of characters.  If you're using Topaz 8, and you make your gadget
  45. 70 pixels wide, Intuition clears only the largest multiple of the font
  46. width (8 in this case) less than the gadget width.  That would be 64
  47. in this case.
  48.  
  49. Under 2.0 and up, we needed to respect the declared gadget's width.  This
  50. caused too many visual problems, so we only did it for StringExtend gadgets.
  51. The visual problems were caused when someone did something like:
  52.  
  53. (DON'T DO THIS, THIS EXAMPLE IS WRONG)
  54. Declare a topaz 8 string gadget to be 70 pixels wide.  Now observe that
  55. the gadget appears to be only 64 pixels wide.  Make a border suitable
  56. to cover a 64-pixel wide gadget (eg. a box 66 pixels wide).  Now V1.3
  57. only rendered in 64 pixels of the string, so the visuals worked.  2.0
  58. and up tried to use all 70 (as the programmer _requested_), and this overwrote
  59. the borders.  The programmer erred by specifying 70 pixels instead of
  60. 64 for the gadget, or erred by sizing the border to fit a 64 instead of
  61. a 70-pixel wide gadget.
  62.  
  63. This bug was so frequently seen in applications that Intuition grew
  64. Yet Another Kludge, and we only do the right thing (respecting the gadget's
  65. declared width) for StringExtend gadgets, whichwe assume are well-designed,
  66. since they're new for 2.0.  If you add StringExtend to a gadget you designed
  67. in this "ill-specified" way, you must fix your bug.
  68.  
  69. The other thing with width of rendering is that some people got tricky
  70. and allowed the cursor to "hang out" of the edge of the gadget render area.
  71. This was done by specifying a container width of (maxchars+1)*font-width.
  72. So a three-character topaz-8 gadget of width 32 had this property.  (Intuition
  73. used to only blast up to maxchars*fontwidth).  The cursor could actually
  74. exceed the gadget render area, which is bad for a number of reasons.  Such
  75. applications now find that the full 32 pixels will be set to background
  76. color, instead of the former 24.
  77.  
  78. In case people are curious as to why Intuition had to change behavior,
  79. the answer lies in a few areas.  Blasting the gadget's declared width
  80. is required in order to support proportional fonts (and compatibility aside,
  81. is the preferred behavior for monospace fonts too).  Not allowing the
  82. cursor to "hang outside" the render area is required by the way the cursor
  83. is drawn under 2.0 and up, which in turn is mandated by the fact that
  84. modern gadgets must not make "canvas assumptions", that is to say, must
  85. not assume the state of the pixels that it's rendering on top of, unless
  86. it can _ensure_ that state.
  87.  
  88. >    anyway, come to think of it), RefreshGList the gadget a second
  89. >    time with the window rastport's write mask temporarily set to
  90. >    zero.  This lets Intuition know the current string length,
  91. >    without doing any actual rendering.
  92.  
  93. Do you think Intuition is supposed to respect the write mask you set
  94. in your window?  I don't think it's correct for it to do so, and under
  95. 1.3 it accidentally does in some places.  Under 2.0 and up, we've caught
  96. all these cases, and Intuition ensures that it's rendering comes out
  97. how it _needs+ it to be.  Assuming your mask will curtail Intuition's
  98. activity is called "relying on a side-effect".  Relying on a side-effect
  99. is a compatibility bug in your app.
  100.  
  101. Your example code is poking into the StringInfo of a gadget currently
  102. attached to a window.  This is illegal.  You must remove the gadget
  103. from the window before playing with it.
  104.  
  105.      Peter
  106. --
  107. Peter Cherna, User Interface Development Group, Commodore-Amiga, Inc.
  108. {uunet|rutgers}!cbmvax!peter    peter@cbmvax.commodore.com
  109. My opinions do not necessarily represent the opinions of my employer.
  110. "I believe it's bad luck to be superstitious."
  111.  
  112.