robertw@informix.com (Robert Weinberg) (02/01/91)
In article <3074@ac.dal.ca> ireland@ac.dal.ca writes: > >Could someone please post or send me the syntax of the "picture" command. This is really a neat function, and it is not described in The Book, so I hope nobody gets too mad at me for posting the syntax here for people to make better use of HyperCard. The following text is copied from the "Power Tools" stack, which is part of the 5-disk HC2.0 release, available from user groups and Claris. I hope I have not introduced too many errors in my transcribing process, but I don't promise that. *********************************************** This external command allows you to display pictures in an external window. The pictures can come from the clipboard, from PICT resources, or from PICT and MacPaint?- compatible files. You can display color, gray-scale, or black- and-white images. XCMD Syntax: picture picture sourceName [, sourceType [, windowStyle [, visible [, depth ]]]] where: sourceName is a string that evaluates to the name of a PICT or MacPaint-compatible file (for source type file), the name or number of a PICT resource (for source type resource), or any name at all (for source type clipboard). The source name also becomes the name of the picture window. sourceType is one of the following types: file, resource, or clipboard (the default value is file). windowStyle is one of the following window styles: dialog, document, plain, rect, roundRect, shadow, windoid, zoom (the default is zoom). visible is an expression that evaluates to true or false. It determines whether the picture XCMD initially creates a visible or invisible window (you can create an invisible window and set its properties before showing it). The default value is true. depth is a positive integer from 0 to 32 that determines the bit depth of the off-screen buffer that the picture XCMD creates. If the value is 0, the picture XMCD draws directly into the window without creating an off-screen buffer. By drawing directly into a window, the picture XCMD can display pictures in low memory conditions-in fact, it will spool an image to the screen when it can't read the entire picture into memory. A value of 0 also allows the picture XCMD to display animated pictures and format 1 PICTs with color. Unfortunately, drawing directly to a window slows down scrolling and zooming, prevents dithering (with 32-bit QuickDraw), and causes pictures that have custom color tables to display improperly. With bit-depth values between 1 and 32, the picture XCMD rounds down to the nearest power of 2 (1, 2, 4, 8, 16, or 32) and creates an off- screen buffer using the depth specified or the actual depth of the picture, whichever is smaller. For example, you could display an 8-bit color picture with a depth of 4 to save memory (but at the cost of lower resolution). Examples: picture picture "My HD:Paul Klee" picture "Paul Klee",file picture "Paul Klee",resource picture "The ClipBoard",clipboard picture "Paul Klee",file,shadow picture "Paul Klee",file,shadow,false picture "Paul Klee",file,shadow,false,1 -- black and white picture "Paul Klee",file,shadow,true,8 Description: The picture XCMD allows you to display color or gray-scale pictures in an external window (the name of the new picture window appears in the window list returned by the HyperTalk function the windows). It works best if you allocate at least 2 megabytes of application memory to HyperCard in its Get Info dialog box. The picture XCMD sets the value of the HyperTalk function the result to empty if it displays the picture successfully. Otherwise, it sets the result to an error message beginning "Couldn't display picture." If you call picture with no parameters, HyperCard displays the directory dialog box and asks you to locate a file to display. If you cancel the dialog box, picture sets the result to "cancel". Window properties In HyperTalk, you can set the values of the rect, loc, and visible properties of all external windows (as well as show, hide, and close them). The picture XCMD interprets the coordinates for the loc and rect properties relative to the card window. set rect of window "Paul Klee" to "50,50,280,300" set loc of window "Paul Klee" to "90,90" -- move the window only set visible of window "Paul Klee" to true hide window "Paul Klee" show window "Paul Klee" at "90,90" -- move and activate the window close window "Paul Klee" In addition, the picture XCMD supports a set of properties that apply only to its external windows. They are as follows: set [the] globalRect of window pictureWindowName to rect The globalRect property returns or sets the rectangle of a picture window relative to the screen which has the menu bar rather than to the card window. The maximum width for the window is 16384 pixels and the minimum width of the window is 4 pixels (also true for the rect property). set [the] globalLoc of window pictureWindowName to point The globalLoc property returns or sets the location of a picture window relative to the screen which has the menu bar rather than to the card window. Note: With the rect, globalRect, loc, and globalLoc properties, the picture XCMD accepts four literals in addition to rectangles and points: cardScreen (or card) centers the window on the same screen as the card window; largestScreen (or largest) centers the window on the screen with the largest area; deepestScreen (or deepest) centers the window on the screen with greatest bit depth; and mainScreen (or main) centers the window on the screen with the menu bar. When you use any of these literals with the rect or globalRect properties, the picture XCMD centers and zooms the window to the largest window that the specified screen will allow. When you use these literals with the loc or globalLoc properties, the picture XCMD moves the window to the appropriate screen but does not change its size. set [the] scroll of window pictureWindowName to point The scroll property returns or sets the current horizontal and vertical offsets of the portion of the picture currently visible in the window. It only affects the image when the size of the window is smaller than the size of the picture. set [the] dithering of window pictureWindowName to trueOrFalse The dithering property returns or sets whether the picture XCMD dithers the image in the window. It affects images only if you have installed 32-bit QuickDraw in your System Folder. set [the] scale of window pictureWindowName to integer (where integer is in the range [-5..5] ) The scale property returns or sets the magnification of the picture image in the window. At normal size, the scale is 0. Negative numbers show the image at reduced sizes. set [the] zoom of window pictureWindowName to [in | out] The zoom property returns or sets the whether the picture window is zoomed in or out. It only works if the picture window has a zoom box. get [the] pictureWidth of window pictureWindowName The read-only pictureWidth property returns the width of the picture window. get [the] pictureHeight of window pictureWindowName The read-only pictureHeight property returns the height of the picture window. Messages sent by the picture XCMD When the user clicks in a picture window, the picture XCMD sends two messages to the current card, mouseDownInPicture and mouseUpInPicture. Both messages have two parameters, the name of the window and the location of the mouse (in coordinates local to the picture window with scale = 0). You can handle the messages as follows: on mouseDownInPicture windowName, theMouseLoc statements end mouseDownInPicture on mouseUpInPicture windowName, theMouseLoc statements end mouseUpInPicture The picture XCMD also sends an openPicture message to the current card after it creates a new picture window. It sends a closePicture message to the current card when it closes a picture window. One parameter is sent with each of these messages, the name of the window. You can handle them as follows: on openPicture windowName statements end openPicture on closePicture windowName statements end closePicture -- * Rob Weinberg, graphics & publishing ***** Does a falling tree make a sound * * {uunet,pyramid}!infmx!robertw ***** if 1: no one hears it * * => Ask me about me. ***** BUT 2: it is not known that * * => Ask Informix about Informix. ***** no one hears it? *