PictDocument.h

/*
    File:       PictDocument.h
 
    Contains:   Header file for the Picture Document routines
 
    Written by: Forrest Tanaka  
 
    Copyright:  Copyright © 1988-1999 by Apple Computer, Inc., All Rights Reserved.
 
                You may incorporate this Apple sample source code into your program(s) without
                restriction. This Apple sample source code has been provided "AS IS" and the
                responsibility for its operation is yours. You are not permitted to redistribute
                this Apple sample source code as "Apple sample source code" after having made
                changes. If you're going to re-distribute the source, we require that you make
                it clear in the source that the code was descended from Apple sample source
                code, but that you've made changes.
 
    Change History (most recent first):
                7/13/1999   Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
                
 
*/
#ifndef __PICTDOCUMENT__
#define __PICTDOCUMENT__
 
 
#ifndef THINK_C
#ifndef __WINDOWS__
#include <Windows.h>
#endif
 
#ifndef __FILES__
#include <Files.h>
#endif
#endif
 
/******************************************************************************\
* NAME & SYNOPSIS:
* FindPictDoc: Find the Picture Document window for a specific file
*
* PARAMETERS:
* FSSpecPtr fileSpec: Specification of file to search for
*
* DEFINITION:
* FindPictDoc finds the Picture Document window associated with the file
* specified by fileSpec.  A pointer to this window is returned.  If no matching
* Picture Document window could be found, then nil is returned.
*
* RETURN VALUES:
* Result: Pointer to the Picture Document window thatÕs associated with the file
*         thatÕs specified by the fileSpec parameter.
\******************************************************************************/
 
WindowPtr FindPictDoc(
    FSSpecPtr fileSpec);
 
 
/******************************************************************************\
* NAME & SYNOPSIS:
* NextPictDocWindow: Return a pointer to the next Picture Document window
*
* PARAMETERS:
* WindowPtr aWindow: Window to start search from, or nil if want front-most
*
* DEFINITION:
* This routine returns a pointer to the first Picture Document window in the
* window list AFTER the window specified by aWindow.  If aWindow is nil, then
* NextPictDocWindow returns a pointer to the first Picture Document window in
* the window list (ie the front-most Picture Document window.  If no Picture 
* Document windows could be found, then nil is returned.
*
* RETURN VALUES:
* Result: Pointer to the Picture Document window thatÕs after the window thatÕs
*         specified by the aWindow parameter.  If aWindow is nil, a pointer to
*         the front-most Picture Document window is returned.
\******************************************************************************/
 
WindowPtr NextPictDocWindow(
    WindowPtr aWindow);
 
 
/******************************************************************************\
* NAME & SYNOPSIS:
* IsPictDocWindow: Is a window a Picture Document window?
*
* PARAMETERS:
* WindowPtr aWindow: Window to test for Picture Document-ness
*
* DEFINITION:
* When it needs to be determined whether a window is a Picture Document window
* or not, this routine is called.  It returns true if aWindow is a Picture
* Document window, or false if not.  If aWindow is nil, then false is returned.
*
* RETURN VALUES:
* Result: Boolean true if the aWindow parameter refers to a Picture Document
*         window; false if not.
\******************************************************************************/
 
Boolean IsPictDocWindow(
    WindowPtr aWindow);
 
 
/******************************************************************************\
* NAME & SYNOPSIS:
* DrawPictDoc: Draw the contents of a Picture Document
*
* PARAMETERS:
* WindowPtr docWindow: Ptr to Picture Document window being drawn
*
* DEFINITION:
* The contents of the Picture Document window specified by docWindow are
* drawn into the window.  The contents include the image, the scroll bars, and
* the grow icon.  This routine is called in response to update events.
*
* RETURN VALUES:
* None
\******************************************************************************/
 
void DrawPictDoc(
    WindowPtr docWindow);
 
 
/******************************************************************************\
* NAME & SYNOPSIS:
* ClickPictDoc: Handle a mouse click in a Picture Document window
*
* PARAMETERS:
* WindowPtr   docWindow:   Pointer to Picture Document window that was clicked
* EventRecord *clickEvent: Event that recorded the mouse click
*
* DEFINITION:
* Whenever thereÕs a mouse-down event in a Picture Document window, this routine
* is called to handle the mouse click.  There are two cases in which there can
* be a mouse click in a Picture Document window and ClickPictDoc is not called:
* if the title bar of a window is clicked, DoWindowDrag in ColorReset.c is
* called to let the user move the window; if the grow icon is clicked,
* GrowPictDoc, defined below, is called to let the user change the size of the
* window.
*
* ClickPictDoc handles mouse clicks in the image within the Picture Document
* window by letting the user draw paint into the image.  Clicks in either of the
* two scroll bars are handled by scrolling the image in the way that the user
* wants.
*
* RETURN VALUES:
* None
\******************************************************************************/
 
void ClickPictDoc(
    WindowPtr   docWindow,
    EventRecord *clickEvent);
 
 
/******************************************************************************\
* NAME & SYNOPSIS:
* GrowPictDoc: Let the user change the size of a Picture Document window
*
* PARAMETERS:
* WindowPtr   docWindow:   Picture Document window thatÕs to be grown
* EventRecord *clickEvent: Mouse down event
*
* DEFINITION:
* GrowPictDoc is called whenever thereÕs a click in the grow icon of a Picture
* Document window.  It lets the user grow and shrink the window until he or she
* lets go of the mouse button.  The Picture Document window is then updated for
* the new size of the window.
*
* DESCRIPTION:
* GrowWindow is called with a boundary rectangle that specifies that the window
* has a minimum size of kMinWindowSize (defined at the top of this source file)
* and a maximum size thatÕs the size of the image.  After the user releases the
* mouse button, SizeWindow is called to change the size of the window, and
* ResizePictDoc (defined below) is called to update the Picture Document to the
* new size.
*
* RETURN VALUES:
* None
\******************************************************************************/
 
void GrowPictDoc(
    WindowPtr   docWindow,
    EventRecord *clickEvent);
 
 
/******************************************************************************\
* NAME & SYNOPSIS:
* ActivatePictDoc: Activate or deactivate a Picture Document window
*
* PARAMETERS:
* WindowPtr docWindow:      Picture Document window thatÕs being (de)activated
* Boolean   becomingActive: True if window is becoming active; false otherwise
*
* DEFINITION:
* ActivatePictDoc is called whenever a Picture Document window is activated or
* deactivated.  This is just to handle the visual aspects of window activation,
* such as hiding or showing the grow icon and the scroll bars.
*
* RETURN VALUES:
* None
\******************************************************************************/
 
void ActivatePictDoc(
    WindowPtr docWindow,
    Boolean   becomingActive);
 
 
/******************************************************************************\
* NAME & SYNOPSIS:
* FixPictDocMenus: Enable or check menus for Picture Documents
*
* PARAMETERS:
* WindowPtr docWindow: Picture Document to apply menu dimming to
*
* DEFINITION:
* FixPictDocMenus is called whenever the state of the menus associated with a
* Picture Document window is changed, like when a Picture Document is opened, or
* if some state of the Picture Document has changed.  FixPictDocMenus only
* enables or checks menu items; it doesnÕt disable or uncheck items.  Disabling
* and unchecking is handled in MenuHandler.c.
*
* RETURN VALUES:
* None
\******************************************************************************/
 
void FixPictDocMenus(
    WindowPtr docWindow);
 
 
/******************************************************************************\
* NAME & SYNOPSIS:
* DoOpenPictDoc: Open a new Picture Document
*
* PARAMETERS:
* None
*
* DEFINITION:
* When the user chooses OpenÉ from the file menu to open an existing Picture
* Document file (really a PICT file).  The user is asked which PICT file to
* open, and then a new window appears with the picture displayed in it.  A
* pointer to this window is returned.  If the Picture Document couldnÕt be
* opened for some reason, an alert is displayed which tells the user what went
* wrong, and no Picture Document window is opened.
*
* If the Picture Document is already open from another application, then it
* canÕt be opened from this application, and an alert is given to the user.  If
* the Picture Document is already open within this application, then that
* documentÕs window is simply activated and its pointer is returned.
*
* RETURN VALUES:
* Result: Pointer to the new Picture Document window.  If a Picture Document
*         window couldnÕt be created, nil is returned.
\******************************************************************************/
 
WindowPtr DoOpenPictDoc(void);
 
 
/******************************************************************************\
* NAME & SYNOPSIS:
* DoSaveAsPictDoc: Save a new Picture Document
*
* PARAMETERS:
* WindowPtr docWindow: Pointer to Picture Document window being saved
*
* DEFINITION:
* This routine is called when the user chooses Save AsÉ from the File menu.  It
* saves a new Picture Document as a PICT file.
*
* RETURN VALUES:
* None
\******************************************************************************/
 
void DoSaveAsPictDoc(
    WindowPtr docWindow);
 
 
/******************************************************************************\
* NAME & SYNOPSIS:
* DoClosePictDoc: Close a Picture Document window
*
* PARAMETERS:
* WindowPtr docWindow: Pointer to Picture Document window being closed
*
* DEFINITION:
* This routine closes the Picture Document window specified by the
* docWindow parameter.  All memory associated with the window is disposed
* of and the window is closed.  At this time, true is always returned.
*
* RETURN VALUES:
* Result: Always true
\******************************************************************************/
 
Boolean DoClosePictDoc(
    WindowPtr docWindow);
 
 
/******************************************************************************\
* NAME & SYNOPSIS:
* ChooseBrushColor: Choose a color for the brush
*
* PARAMETERS:
* WindowPtr docWindow: Window whose brush color is to be chosen
*
* DEFINITION:
* When the user chooses Brush ColorÉÊfrom the Color menu, this routine is called
* to present the Color Picker to the user so that he or she can choose a new
* color for the brush.
*
* RETURN VALUES:
* None
\******************************************************************************/
 
void ChooseBrushColor(
    WindowPtr docWindow);
    
pascal void ScrollActionProc(
    ControlHandle control, /* Handle to clicked control */
    short         part);   /* Part number of clicked control part */
 
pascal void InfoBits(
    BitMapPtr srcBits,
    Rect      *srcRect,
    Rect      *dstRect,
    short     mode,
    RgnHandle maskRgn);
    
pascal void FileGetPic(
    Ptr   dataPtr,
    short byteCount);
 
pascal void FilePutPic(
    Ptr   dataPtr,
    short byteCount);
 
 
 
#endif