home *** CD-ROM | disk | FTP | other *** search
- /*
- * statwind.c - routines to manage status dialog window
- */
-
- #include "RevRdist.h"
- #include <TransSkelProto.h>
-
- DialogPtr StatusDialog;
-
- static void setAppearance (Integer, int);
- static void statEvent (Integer, EventRecord *);
- static void statClobber (void);
-
-
-
-
- /*
- *=========================================================================
- * setStat (s) - adjust status window dialog based on global variables
- * entry: Flags, Pause set
- *=========================================================================
- */
- void
- setStat ()
- {
- if (StatusDialog)
- {
- /*
- * Show/hide, activate/deactivate
- * the reboot text
- * the please wait text
- * the Pause and Continue buttons
- */
- setAppearance (STS_REBOOT, (Flags & DB_STARTUP));
- setAppearance (STS_WAIT, (Pause != S_IDLE));
- setAppearance (STS_PAUSE, (Pause == S_RUNNING));
- setAppearance (STS_CONT, (Pause == S_PAUSED));
- setAppearance (STS_CANCEL, (Pause != S_IDLE));
- if (Pause == S_RUNNING && Watch)
- SetCursor (*Watch);
- else
- InitCursor ();
- }
- }
-
-
-
-
- /*
- *=========================================================================
- * setAppearance (itemNo, f) - visible appearance of item in status dialog
- * entry: itemNo = dialog item number to set
- * f = true to make active/visible, false to make inactive/hidden
- *=========================================================================
- */
- void
- setAppearance (itemNo, f)
- Integer itemNo;
- int f;
- {
- Integer itemType; /* for GetDItem call */
- Handle item; /* " */
- Rect r; /* " */
- Integer val, val2; /* temp */
- Str255 str;
-
- #define OUTASIGHT 0x1000 /* amount to move item to hide it */
-
- GetDItem (StatusDialog, itemNo, &itemType, &item, &r);
- val = itemType & ~itemDisable;
- switch (val)
- {
- case ctrlItem+btnCtrl:
- /*
- * Use HiliteControl on buttons
- */
- val = f ? 0 : 255;
- HiliteControl ((ControlHandle)item, val);
- break;
-
- case statText:
- /*
- * For static text, hide it by moving it offscreen
- */
- val = f ? 0 : OUTASIGHT;
- val2 = r.top & OUTASIGHT;
- if (val != val2)
- {
- GetIText (item, str);
- SetIText (item, (SP)"\p");
- r.top ^= OUTASIGHT;
- SetDItem (StatusDialog, itemNo, itemType, item, &r);
- SetIText (item, str);
- }
- break;
- }
- }
-
-
-
- /*
- *=========================================================================
- * showstat () - put up status window
- * entry: skelmain() active
- *=========================================================================
- */
- void
- showstat ()
- {
- register Integer itemNo; /* index to dialog items */
- Integer itemType; /* for GetDItem call */
- Handle item; /* " */
- Rect r; /* " */
-
- StatusDialog = GetNewDialog (RSRC_BASE+WIND_STATUS, nil, (WindowPtr) -1L);
- if (StatusDialog == nil)
- return;
- setStat (); /* enable/disable as appropriate */
- SkelDialog (StatusDialog, statEvent, nil, statClobber);
- TextFont (1);
- ShowWindow ((WindowPtr) StatusDialog);
- }
-
-
-
- /*
- *=========================================================================
- * statClobber () - get rid of the status dialog resources
- *=========================================================================
- */
- void
- statClobber ()
- {
- if (StatusDialog)
- DisposDialog (StatusDialog);
- StatusDialog = nil;
- }
-
-
- /*
- *=========================================================================
- * statEvent (itemNo, theEvent) - handle events in status dialog
- * entry: itemNo = the item number in dialog
- * theEvent = ptr to event record significant to dialog
- *=========================================================================
- */
- void
- statEvent (itemNo, theEvent)
- Integer itemNo;
- EventRecord * theEvent;
- {
-
- switch (itemNo)
- {
- case STS_PAUSE: /* Pause button */
- if (Pause == S_RUNNING)
- Pause = S_PAUSED;
- setStat ();
- break;
-
- case STS_CANCEL: /* Cancel button */
- Quit = true;
- /* Fall into ... */
-
- case STS_CONT: /* Continue button */
- if (Pause == S_PAUSED)
- Pause = S_RUNNING;
- setStat ();
- break;
- }
- }
-
-
- static Longint msgtime; /* the time of the last msg */
- /*
- *=========================================================================
- * statMsg (s) - set status window message
- * entry: s = StringPtr of message text
- *=========================================================================
- */
- void
- statMsg (s)
- StringPtr s;
- {
- Integer itemType; /* for GetDItem call */
- Handle item; /* " */
- Rect r; /* " */
-
- if (StatusDialog)
- {
- GetDItem (StatusDialog, STS_STATUS, &itemType, &item, &r);
- if ((itemType & ~itemDisable) == statText)
- SetIText (item, s);
- msgtime = TickCount ();
- }
- }
-
-
-
- /*
- *=========================================================================
- * statMsgClr () - clear status window message
- *=========================================================================
- */
- void
- statMsgClr ()
- {
- if (TickCount () > msgtime + 2*60)
- statMsg ((SP)"\p");
- }