[comp.sys.mac.hypercard] Saving and Printing Two Cards

tim@hoptoad.uucp (Tim Maroney) (03/04/90)

Here's a slightly strange question.  I have a stack which needs to have
save and print functionality added.  The images of two cards, or the
cards themselves, are what is to be saved or printed.

Obviously, it's no problem to save the image of one card, or to copy
two cards and paste them into a new stack.  But a user-friendly way
of printing two cards doesn't seem to exist.  I want them always to
be printed two to a page, one above the other, without the user having
to give any magic incantations in the middle of the process.

(1)  Save the two cards to a new stack.  Once in the stack, give the
command "doMenu Print Stack..."  Problem: requires user to set printing
mode in middle of process.  Another problem:  Probably quite slow to
create a new stack and copy two cards over.

(2)  Use Export Paint to save the card images to MacPaint files, then
use an XCMD to print the two files together (possibly merging them into
a single file first).  MacPaint files are easy to work with.  Problem:
this requires user to select two file names for a printing operation.
I would really rather not patch Standard File just to avoid a file
name fetch from the user!

(3)  Use an XCMD to save the two card images into a single MacPaint
file, then print using another XCMD if desired, or just save the file
for a save operation.  Problem:  This requires a no-no, using CopyBits
to extract the card images from the screen.  (The XCMD would take
arguments for the card ids, go to the first, CopyBits from the card
window's BitMap into the top half of the MacPaint image, go to the
second, copy the card image into the lower half of the MacPaint image.)
I am leaning strongly towards this idea, as it gives me control over
every phase of the operation and I can make the user interface do
exactly what I want; however, will this blow up on color systems or
strange monitors?
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

"The Diabolonian position is new to the London playgoer of today, but not to
 lovers of serious literature.  From Prometheus to the Wagnerian Siegfried,
 some enemy of the gods, unterrified champion of those oppressed by them, has
 always towered among the heroes of the loftiest poetry."
    - Shaw, "On Diabolonian Ethics"

jdevoto@Apple.COM (Jeanne A. E. DeVoto) (03/04/90)

In article <10558@hoptoad.uucp> tim@hoptoad.uucp (Tim Maroney) writes:
>Here's a slightly strange question.  I have a stack which needs to have
>save and print functionality added.  The images of two cards, or the
>cards themselves, are what is to be saved or printed.
>
>Obviously, it's no problem to save the image of one card, or to copy
>two cards and paste them into a new stack.  But a user-friendly way
>of printing two cards doesn't seem to exist.  I want them always to
>be printed two to a page, one above the other, without the user having
>to give any magic incantations in the middle of the process.

Here's what you do for printing:
  on mouseUp
    open printing      -- start saving up for a print job
    print card "first card to print"
    print card "second card to print"
    close printing     -- print the job
  end mouseUp

This prints the two cards on the same page, one above the other. The print
job respects the settings in the Print Stack dialog. If you want the user to
have access to the dialog, use "open printing with dialog" instead of
"open printing".
-- 
====== jeanne a. e. devoto ========================================
 jdevoto@apple.com  |  You may not distribute this article under a
 jdevoto@well.UUCP  |  compilation copyright without my permission.
___________________________________________________________________
 Apple Computer and I are not authorized  |        CI$: 72411,165
 to speak for each other.                 |  AppleLink: SQA.TEST

tim@hoptoad.uucp (Tim Maroney) (03/05/90)

In article <10558@hoptoad.uucp> tim@hoptoad.uucp (Tim Maroney) writes:
>>But a user-friendly way
>>of printing two cards doesn't seem to exist.  I want them always to
>>be printed two to a page, one above the other, without the user having
>>to give any magic incantations in the middle of the process.

In article <39171@apple.Apple.COM> jdevoto@Apple.COM (Jeanne A. E. DeVoto)
writes:
>  on mouseUp
>    open printing      -- start saving up for a print job
>    print card "first card to print"
>    print card "second card to print"
>    close printing     -- print the job
>  end mouseUp
>
>This prints the two cards on the same page, one above the other. The print
>job respects the settings in the Print Stack dialog.

Thanks, but I don't *want* to respect the settings in the print stack
dialog.  I want to always use the setting "Print full size cards",
regardless of what the user may have recently selected.  If someone
prints my whole stack using half-size cards from the "Print stack"
command, then won't your script print half-size cards -- or one per
page if that was what was last selected, or whatever the current
setting is?

Also, any comments on stealing card bitmaps from the windows?
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

"I am of the opinion that my life belongs to the whole community, and as long
 as I live it is my privilege to do for it whatever I can." -- Shaw

tim@hoptoad.uucp (Tim Maroney) (03/05/90)

In article <39171@apple.Apple.COM> jdevoto@Apple.COM (Jeanne A. E. DeVoto)
writes:
>>    open printing      -- start saving up for a print job
>>    print card "first card to print"
>>    print card "second card to print"
>>    close printing     -- print the job

In article <10599@hoptoad.uucp> tim@hoptoad.UUCP (Tim Maroney) writes:
>If someone
>prints my whole stack using half-size cards from the "Print stack"
>command, then won't your script print half-size cards -- or one per
>page if that was what was last selected, or whatever the current
>setting is?

An easy experiment has verified that this is the case.  Setting
"quarter size cards" in the Print Stack dialog causes the next
execution of Jeanne's script to use that setting, creating an incorrect
page.  The current Print Stack dialog settings are stored somewhere in
the HyperCard stack file, not in a resource, so an XCMD can't get at
them.  So, this is not a solution.

Longtime readers of this group know that my main complaint with
HyperTalk is that objects have too many inaccessible properties.  The
Print Stack dialog settings of a stack now join this list of annoying
hidden properties.  Just think -- with these properties, my problem
would be trivial ("set the pageCards of this stack to fullSize");
without them, the problem is nearly insoluble in a user-friendly and
software-compatible way.

My proposed rule of thumb for Apple's HyperTalk development when I
raised this point was that "If you need to keep track of something in
an internal data structure describing an object, you need to put it
into HyperTalk as a property."  This latest experience seems to confirm
that idea.
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

"May the Lord open your eyes and heart so that you may understand him more
 clearer."  -- Patrick Harubin, pgh@cs.duke.edu, soc.religion.islam

jdevoto@Apple.COM (Jeanne A. E. DeVoto) (03/06/90)

In article <10599@hoptoad.uucp> tim@hoptoad.UUCP (Tim Maroney) writes:
[Tim wants a way to print two cards on the same page under script control]

[I suggest the following:
  on mouseUp
    open printing      -- start saving up for a print job
    print card "first card to print"
    print card "second card to print"
    close printing     -- print the job
  end mouseUp
This prints the two cards on the same page, one above the other. The print
job respects the settings in the Print Stack dialog.]

[Tim points out that the user may do a Print Stack, thus changing the
settings, and then his scripted print will use those settings rather than
the ones he wants.]

OK, how about this? Make sure the stack is set up for the settings you
want to use, then put the following in the stack script:

  on doMenu theItem
    if theItem is "Print Stack..." then
      set the cantModify of this stack to true
      send "doMenu Print Stack..." to HyperCard
      set the cantModify of this stack to false
    else
      pass doMenu
    end if
  end doMenu

This lets the user set whatever settings are desired, but since cantModify
is on, the setting changes aren't permanent.

Of course, this isn't as versatile as letting you set the Print parameters
from HyperTalk, but it'll work if you only need to use one set of
parameters.

>Also, any comments on stealing card bitmaps from the windows?

Nothing leaps to mind. If all you need is the picture, you could always
do a Select All/Copy Picture and then use an XCMD to grab the scrap, I
suppose. I'll think about it.

>"I am of the opinion that my life belongs to the whole community, and as long
> as I live it is my privilege to do for it whatever I can." -- Shaw

Hmmm....
-- 
====== jeanne a. e. devoto ========================================
 jdevoto@apple.com  |  You may not distribute this article under a
 jdevoto@well.UUCP  |  compilation copyright without my permission.
___________________________________________________________________
 Apple Computer and I are not authorized  |        CI$: 72411,165
 to speak for each other.                 |  AppleLink: SQA.TEST

tim@hoptoad.uucp (Tim Maroney) (03/07/90)

In article <39224@apple.Apple.COM> jdevoto@Apple.COM (Jeanne A. E. DeVoto)
writes:
>[Tim points out that the user may do a Print Stack, thus changing the
>settings, and then his scripted print will use those settings rather than
>the ones he wants.]
>
>OK, how about this? Make sure the stack is set up for the settings you
>want to use, then put the following in the stack script:
>
>  on doMenu theItem
>    if theItem is "Print Stack..." then
>      set the cantModify of this stack to true
>      send "doMenu Print Stack..." to HyperCard
>      set the cantModify of this stack to false
>    else
>      pass doMenu
>    end if
>  end doMenu
>
>This lets the user set whatever settings are desired, but since cantModify
>is on, the setting changes aren't permanent.

It works (thanks), but it requires one more piece in the stack script:

on idle
  if cantModify of this stack then set cantModify of this stack to false
  pass idle
end idle

Otherwise, interrupting the Print Stack also interrupts the script, and
the stack remains locked.  I wonder how much of a performance hit I'm
looking at from this idle handler?  (Or for that matter, from adding
yet another "else if" to my main doMenu handler?)

>Of course, this isn't as versatile as letting you set the Print parameters
>from HyperTalk, but it'll work if you only need to use one set of
>parameters.

Yes.  However, as you may recall, when I first raised the hidden
properties issue, my objection to it was that the programmer was forced
to do straightforward things in roundabout ways.  This is a perfect
example.  I hope this problem is addressed in HyperCard 2.0.

>>Also, any comments on stealing card bitmaps from the windows?
>
>Nothing leaps to mind. If all you need is the picture, you could always
>do a Select All/Copy Picture and then use an XCMD to grab the scrap, I
>suppose. I'll think about it.

Nope, I need the whole card, from two separate cards, not just the
pictures.  I can't get two card images without two Standard File
dialogs, though, unless I use an XCMD to grab the bits with CopyBits or
use an XCMD to patch the Standard File Package trap, both of which are
nasty.  You can't say "doMenu Export File... with <filename>".
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

FROM THE FOOL FILE:
"Those Mayas were sacrificing not only pagan children, but baptized
 Christian children, for crying out loud!  And they were carrying out
 those sacrifices, those barbarities, with great savagery, without
 giving the victims the benefit of the humane types of death that the
 European Church accorded even to heretics and witches during that
 century, such as burning at the stake."
		-- Matthew Rosenblatt, rec.arts.books