appletzoom.c

Go to the documentation of this file.
00001 
00002 /*  $Id: appletzoom.c 355 2005-01-11 22:48:55Z andreradke $    */
00003 
00004 /* copyright 1991-96 UserLand Software, Inc. All Rights Reserved.*/
00005 
00006 
00007 #include "appletdefs.h"
00008 #include "appletquickdraw.h"
00009 #include "appletzoom.h"
00010 
00011 #define zoomfixer 65536L
00012 
00013 #define zoomsteps 16
00014 
00015 Fixed zoomfract;
00016 
00017 
00018 
00019 
00020 static short zoomblend (short i1, short i2) {
00021 
00022     Fixed smallFix,bigFix,tempFix;
00023 
00024     smallFix = zoomfixer * i1;
00025     
00026     bigFix = zoomfixer * i2;
00027     
00028     tempFix = FixMul (zoomfract, bigFix) + FixMul (zoomfixer-zoomfract, smallFix);
00029     
00030     return (FixRound (tempFix));
00031     } /*zoomblend*/
00032     
00033 
00034 static void zoomrect (Rect *smallrect, Rect *bigrect, Boolean zoomup) {
00035 
00036     Fixed factor;
00037     Rect rect1,rect2,rect3,rect4;
00038     GrafPtr savePort,deskPort;
00039     short i;
00040     
00041     GetPort (&savePort);
00042     
00043     OpenPort (deskPort = (GrafPtr) NewPtr (sizeof (GrafPort)));
00044     
00045     InitPort (deskPort);
00046     
00047     SetPort (deskPort);
00048     
00049     PenPat (&quickdrawglobal (gray));
00050     
00051     PenMode (notPatXor);
00052     
00053     if (zoomup) {
00054     
00055         rect1 = *smallrect;
00056         
00057         factor = FixRatio(6,5);
00058         
00059         zoomfract = FixRatio(541,10000);
00060         }
00061     else {
00062         rect1 = *bigrect;
00063         
00064         factor = FixRatio(5,6);
00065         
00066         zoomfract = zoomfixer;
00067         }
00068         
00069     rect2 = rect1;
00070     
00071     rect3 = rect1;
00072     
00073     FrameRect (&rect1);
00074     
00075     for (i = 1; i<= zoomsteps; i++) {
00076     
00077         rect4.left = zoomblend (smallrect->left, bigrect->left);
00078         
00079         rect4.right = zoomblend (smallrect->right, bigrect->right);
00080         
00081         rect4.top = zoomblend (smallrect->top, bigrect->top);
00082         
00083         rect4.bottom = zoomblend (smallrect->bottom, bigrect->bottom);
00084         
00085         FrameRect (&rect4);
00086         
00087         FrameRect (&rect1);
00088         
00089         rect1 = rect2;
00090         
00091         rect2 = rect3;
00092         
00093         rect3 = rect4;
00094          
00095         zoomfract = FixMul (zoomfract,factor);
00096         } /*for*/
00097         
00098     FrameRect (&rect1);
00099     
00100     FrameRect (&rect2);
00101     
00102     FrameRect (&rect3);
00103     
00104     ClosePort (deskPort);
00105     
00106     DisposPtr ((Ptr)deskPort);
00107     
00108     PenNormal ();
00109     
00110     SetPort (savePort);
00111     } /*zoomrect*/
00112     
00113     
00114 void zoomport (WindowPtr w, boolean flup) {
00115 
00116     /*
00117     Zooms the window referenced by "w" either from an inivisible
00118     state to a visible state, or vice versa.  Pass true in the "flup"
00119     boolean parameter to zoom a window to open, an false to zoom
00120     it close.  The WindowPtr must have already been created elsewhere,
00121     and zooming the window invisible only hides the window, it does
00122     not destroy the WindowPtr data.
00123     */
00124     
00125     Rect r1, r2, r3;
00126 
00127     SetPort (w);
00128     
00129     SetRect (&r1, 0, 20, 0, 20);
00130     
00131     r3 = (*w).portRect;
00132     
00133     r2 = r3;
00134     
00135     InsetRect (&r2, (r3.right - r3.left + 20) / 2, (r3.bottom - r3.top + 20) / 2);
00136 
00137     localtoglobalrect (&r2);
00138     
00139     localtoglobalrect (&r3);
00140 
00141     if (flup) {
00142     
00143         zoomrect (&r1, &r2, true);
00144         
00145         zoomrect (&r2, &r3, true);
00146         
00147         ShowWindow (w);
00148         
00149         SetPort (w);
00150         }
00151     else {
00152         HideWindow (w);
00153         
00154         zoomrect (&r2, &r3, false);
00155         
00156         zoomrect (&r1, &r2, false);
00157         }
00158     } /*zoomport*/
00159     
00160     

Generated on Wed May 31 18:19:44 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6