About ImageWriter Bug.txt

Hey!  What the Hell is this?!
 
sample: Bug work-arounds:ImageWriter 6.1/7.0 bug
Language: MPW Pascal 3.2
 
This sample snippet demonstrates how to work around the 'dctb' bug in the ImageWriter II 6.1 and 7.0 drivers.  This bug causes a crash when doing a style (Page Setup) dialog after setting draftBits with PrGeneral.
 
 
Explanation of bug:
 
¥ The AppetizerÉ
 
The ImageWriter driver has always jammed a gray pen pattern into its dialogs' GrafPorts in order to draw disabled items in dithered gray.  Although this is ok with GrafPorts, CGrafPorts have their pen pattern in a different (physical) location.  Stuffing the pattern in a CGrafPort as you would a GrafPort causes a catastrophic crash.
 
¥ The EntreeÉ
 
When items in print dialogs can't be used, they're disabled and therefore grayed out.  As it turns out, setting draftBits mode with PrGeneral disables landscape printing.  Keep in mind that we recommend that developers use PrGeneral before displaying the print dialogs so that their users can see which options are disabled and proceed accordingly.  So, this would mean that Landscape printing would be disabled in the style dialog.
 
¥ The DessertÉ
 
So far, none of this is a problem.  The glitch was actually introduced in the 6.1 version of the ImageWriter driver.  When the driver was revved for the 6.1 release, it (like all the other drivers) was given 'dctb' resources so that its dialogs would look neato-cool.
 
¥ The Pepto-BismolÉ
 
Unfortunately, this causes the Dialog Manager to use a color dialog and therefore a CGrafPort instead of a GrafPort.  When the Landscape icon is disabled, the explosive conditions described above surface.  The result is a Divide by Zero error, Bus Error or the like.  In short, the problem is caused by jamming the gray pen pattern into a CGrafPort, in a very sensitive area.  Liken it to a swift kick in the groin.
 
 
Explanation of work-around:
 
There are a few ways to work around this bug.  The recommended solution follows:
 
 
¥ Do the style dialog before calling PrGeneral.
 
Calling PrGeneral after the dialog will not cause any (code level) problems.  If an option was selected in the dialog which the PrGeneral mode does not support, it will be corrected by PrGeneral.  For example, if Landscape printing was selected on an ImageWriter, and then draftBits mode was set with PrGeneral, the printing orientation would be changed to portrait.
 
While this is good news because it means your code won't crash, it's bad news because the user might get confused.  "I was given the option to print landscape, I selected landscape printing, but the stupid thing printed portrait!!  What a crappy machine!!!!!!! @!&#$$!!!@#$"  ÉThis is not good.
 
The solution is to check for options that are unsupported by draftBits after the style dialog has gone away.  If any are found, tell the user that they'll be ignored, and possibly give 'em the option to go back to the dialog.  The only options that are unsupported in this case are Landscape printing and 50% reduction.  The former can be detected by calling PrGeneral with getRotnOp, but the latter requires banging on the wDev field.  Safe, but requires a disclaimer.  (Someday wDev banging will become illegal.  WeÕll be in touchÉ)
 
Since this whole mess is only necessary on the  6.1 or 7.0 ImageWriter drivers, we should treat all other drivers normally (ie. call PrGeneral then do the style dialog and ignore all other checks.)  The sample code works in this way.  I've submitted this bug to Engineering, so the Cavalry has been notified.  ÉStay tuned.
 
- Dave ÒgdÓ Hersey
  MacDTS
  10/8/91