home *** CD-ROM | disk | FTP | other *** search
-
- /*⌐ Copyright 1988-1991 UserLand Software, Inc. All Rights Reserved.*/
-
-
- #include "appletinternal.h"
- #include "ops.h"
- #include "quickdraw.h"
- #include "appletmain.h"
- #include "about.h"
-
-
- #ifdef MPWC
-
- #include <toolutils.h>
- #include <osevents.h>
-
- #endif
-
-
-
- #define aboutlistnumber 128
-
- #define zoomfixer 65536L
-
- #define zoomsteps 16
-
- Fixed zoomfract;
-
- WindowPtr aboutwindow = nil;
-
-
-
-
-
- static short zoomblend (short i1, short i2) {
-
- Fixed smallFix,bigFix,tempFix;
-
- smallFix = zoomfixer * i1;
-
- bigFix = zoomfixer * i2;
-
- tempFix = FixMul (zoomfract, bigFix) + FixMul (zoomfixer-zoomfract, smallFix);
-
- return (FixRound (tempFix));
- } /*zoomblend*/
-
-
- static void zoomrect (Rect *smallrect, Rect *bigrect, Boolean zoomup) {
-
- Fixed factor;
- Rect rect1,rect2,rect3,rect4;
- GrafPtr savePort,deskPort;
- short i;
-
- GetPort (&savePort);
-
- OpenPort (deskPort = (GrafPtr) NewPtr (sizeof (GrafPort)));
-
- InitPort (deskPort);
-
- SetPort (deskPort);
-
- PenPat (quickdrawglobal (gray));
-
- PenMode (notPatXor);
-
- if (zoomup) {
-
- rect1 = *smallrect;
-
- factor = FixRatio(6,5);
-
- zoomfract = FixRatio(541,10000);
- }
- else {
- rect1 = *bigrect;
-
- factor = FixRatio(5,6);
-
- zoomfract = zoomfixer;
- }
-
- rect2 = rect1;
-
- rect3 = rect1;
-
- FrameRect (&rect1);
-
- for (i = 1; i<= zoomsteps; i++) {
-
- rect4.left = zoomblend (smallrect->left, bigrect->left);
-
- rect4.right = zoomblend (smallrect->right, bigrect->right);
-
- rect4.top = zoomblend (smallrect->top, bigrect->top);
-
- rect4.bottom = zoomblend (smallrect->bottom, bigrect->bottom);
-
- FrameRect (&rect4);
-
- FrameRect (&rect1);
-
- rect1 = rect2;
-
- rect2 = rect3;
-
- rect3 = rect4;
-
- zoomfract = FixMul (zoomfract,factor);
- } /*for*/
-
- FrameRect (&rect1);
-
- FrameRect (&rect2);
-
- FrameRect (&rect3);
-
- ClosePort (deskPort);
-
- DisposPtr ((Ptr)deskPort);
-
- PenNormal ();
-
- SetPort (savePort);
- } /*zoomrect*/
-
-
- static void zoomport (WindowPtr w, boolean flup) {
-
- /*
- Zooms the window referenced by "w" either from an inivisible
- state to a visible state, or vice versa. Pass true in the "flup"
- boolean parameter to zoom a window to open, an false to zoom
- it close. The WindowPtr must have already been created elsewhere,
- and zooming the window invisible only hides the window, it does
- not destroy the WindowPtr data.
- */
-
- Rect r1, r2, r3;
-
- SetPort (w);
-
- SetRect (&r1, 0, 20, 0, 20);
-
- r3 = (*w).portRect;
-
- r2 = r3;
-
- InsetRect (&r2, (r3.right - r3.left + 20) / 2, (r3.bottom - r3.top + 20) / 2);
-
- localtoglobalrect (&r2);
-
- localtoglobalrect (&r3);
-
- if (flup) {
-
- zoomrect (&r1, &r2, true);
-
- zoomrect (&r2, &r3, true);
-
- ShowWindow (w);
-
- SetPort (w);
- }
- else {
- HideWindow (w);
-
- zoomrect (&r2, &r3, false);
-
- zoomrect (&r1, &r2, false);
- }
- } /*zoomport*/
-
-
- #define doline(x)\
- \
- MoveTo (r.left + (r.right - r.left - StringWidth (x)) / 2, linev); \
- \
- DrawString (x); \
- \
- linev += lineinc;
-
-
- static void drawabout (WindowPtr w) {
-
- register short i;
- register short linev = 24;
- register short lineinc = 14;
- bigstring lines [6];
- Rect r;
-
- for (i = 0; i <= 5; i++)
- GetIndString (lines [i], aboutlistnumber, i + 1);
-
- r = (*w).portRect;
-
- InsetRect (&r, 4, 4);
-
- TextFont (systemFont);
-
- TextSize (12);
-
- doline (lines [0]);
-
- TextFont (geneva);
-
- TextSize (9);
-
- doline (lines [1]);
-
- linev += lineinc; /*skip a line*/
-
- doline (lines [2]);
-
- doline (lines [3]);
-
- MoveTo (r.left + 4, r.bottom - 6);
-
- DrawString (lines [4]);
-
- MoveTo (r.right - StringWidth (lines [5]) - 4, r.bottom - 6);
-
- DrawString (lines [5]);
- } /*drawabout*/
-
-
- void openabout (Boolean flzoom) { /*can also be called to implement the splash window*/
-
- Rect r;
-
- SetRect (&r, 0, 0, 340, 120);
-
- pushmacport (aboutwindow = NewWindow (nil, &r, (ConstStr255Param)"\p", false, altDBoxProc, (WindowPtr) -1, false, 0));
-
- centerwindow ((DialogPtr) aboutwindow, quickdrawglobal (screenBits).bounds);
-
- if (flzoom)
- zoomport (aboutwindow, true);
- else
- ShowWindow (aboutwindow);
-
- drawabout (aboutwindow);
- } /*openabout*/
-
-
- void closeabout (Boolean flzoom) {
-
- if (aboutwindow != nil) {
-
- HideWindow (aboutwindow);
-
- if (flzoom)
- zoomport (aboutwindow, false);
- else
- HideWindow (aboutwindow);
-
- DisposeWindow (aboutwindow);
-
- aboutwindow = nil;
-
- popmacport ();
- }
- } /*closeabout*/
-
-
- static boolean aboutwindowopen (void) {
-
- return (aboutwindow != nil);
- } /*aboutwindowopen*/
-
-
- static boolean abouthandleevent (EventRecord ev, boolean *boxgoesaway) {
-
- /*
- return true if the event is consumed, false if not.
-
- set boxgoesaway to true if the event should cause the about box to disappear.
- */
-
- *boxgoesaway = false;
-
- switch (ev.what) {
-
- case keyDown: case autoKey: {
-
- register char ch = ev.message & charCodeMask;
-
- if ((ch == chreturn) || (ch == chenter)) {
-
- *boxgoesaway = true;
-
- return (true); /*event consumed*/
- }
-
- break;
- }
-
- case mouseDown: {
- WindowPtr w;
-
- FindWindow (ev.where, &w);
-
- if (w != aboutwindow) /*event definitely not consumed*/
- return (false);
-
- if (w == FrontWindow ())
- *boxgoesaway = true;
- else
- SelectWindow (w);
-
- return (true); /*event consumed*/
- }
-
- case updateEvt: {
- register WindowPtr eventwindow = (WindowPtr) (ev.message);
-
- if (eventwindow != aboutwindow)
- return (false); /*event not consumed*/
-
- /*handle update, we might be using a screen saver*/
-
- pushmacport (eventwindow);
-
- BeginUpdate (eventwindow);
-
- drawabout (eventwindow);
-
- EndUpdate (eventwindow);
-
- popmacport ();
-
- return (true); /*event consumed, don't get rid of the about box*/
- }
-
- case activateEvt:
- return (true); /*event consumed, don't get rid of the about box*/
- } /*switch*/
-
- return (false); /*event not consumed*/
- } /*abouthandleevent*/
-
-
- void aboutcommand (void) {
-
- EventRecord ev;
- boolean flexitabout = false;
-
- openabout (true);
-
- while (!flexitabout) {
-
- WaitNextEvent (everyEvent, &ev, 1, nil);
-
- if (!abouthandleevent (ev, &flexitabout)) { /*event not consumed by about box*/
-
- if (!maineventhandler (ev)) { /*user pressed cmd-period or Quit from file menu*/
-
- flexitabout = true;
- }
- }
- } /*while*/
-
- closeabout (true);
- } /*aboutcommand*/
-
-
-
-
-