TumblerSource/Tumbler_windows.c

//
//      windows.c
//
//      Window handling routines.
//      
//
//      Author:     Nick Thompson & Pablo Fernicola, with thanks to the QuickDraw 3D team
//
//      Copyright © 1992-95 Apple Computer, Inc., All Rights Reserved
//
//
 
 
#include "Tumbler_globals.h"
#include "Tumbler_prototypes.h"
 
#include "Tumbler_windows.h"
#include "Tumbler_camera.h"
#include "Tumbler_offscreen.h"
 
 
//
//  UpdateWindow is called when an update event is received for a docuemnt
//  window.
//
 
void UpdateWindow(WindowPtr theWindow)
 
{
    DocumentPtr theDocument = GetDocumentFromWindow(theWindow) ;
    GrafPtr     savedPort ;
    
    GetPort( &savedPort ) ;
    if(theDocument!=nil) {
        SetPort(theWindow);
        
        BeginUpdate(theWindow);
    
//      EraseRect(&theWindow->portRect);
        DrawOffscreen(theDocument);
        DrawOnscreen(theDocument);
        DoDrawGrowIcon(theWindow);
    
        EndUpdate(theWindow);
    }
    SetPort( savedPort ) ;
}
 
 
//
//  GrowDocumentWindow is called when the user clicks in the growRgn of a
//  document window.
//
 
void GrowDocumentWindow(WindowPtr theWindow, Point thePoint)
 
{   long        result;
    Rect        sizeRect;
    GrafPtr     savedPort ;
 
#ifdef PODIUM_APP
    return ;
#endif
    
    GetPort(&savedPort) ;
    SetPort(theWindow) ;
 
    sizeRect = qd.screenBits.bounds;
    
    if ((result = GrowWindow(theWindow, thePoint, &sizeRect)) == 0)
        return;
        
    SizeWindow(theWindow, LoWord(result), HiWord(result), false);
    
    EraseRect(&theWindow->portRect);
    InvalRect(&theWindow->portRect);
    
    if( ((DocumentPtr ) ((WindowPeek) theWindow)->refCon)->documentGroup )
        AdjustCamera((DocumentPtr ) ((WindowPeek) theWindow)->refCon,
                        theWindow->portRect.right - theWindow->portRect.left,
                        theWindow->portRect.bottom - theWindow->portRect.top);
    
    UpdateWindow(theWindow);
 
    SetPort(savedPort) ;
}
 
 
//-------------------------------------------------------------------------------
//  DoDrawGrowIcon
//
//  Draw the grow icon. We do this in such a way that the scrollbar lines are
//  not drawn. Normally, when the Toolbox routine DrawGrowIcon is called,
//  vertical and horizontal lines are also drawn indicating where the
//  scrollbars will be drawn. We donÕt have scrollbars, so we donÕt want those
//  lines drawn. We avoid them by setting the clipping region of the window to
//  include the grow box only. We then call DrawGrowIcon, and restore the old
//  clipping region before returning.
 
void    DoDrawGrowIcon(WindowPtr theWindow)
{
    Rect        iconRect;
    RgnHandle   oldClip;
 
    // this slows animation for demos down a lot
    // probably should say something like
    // if( gUsingHardware && theDocument->animate)
    if(gUsingHardware) {
        return ;
    }
#ifdef PODIUM_APP
    return ;
#endif
 
    SetPort(theWindow);
    oldClip = NewRgn();
    GetClip(oldClip);
 
    iconRect = theWindow->portRect;
    iconRect.top = iconRect.bottom - 15;
    iconRect.left = iconRect.right - 15;
    ClipRect(&iconRect);
 
    PenNormal();
    DrawGrowIcon(theWindow);
 
    SetClip(oldClip);
    DisposeRgn(oldClip);
}