home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************
- *
- * lprDials.C
- *
- * Modification History :
- *
- ************************************************************************/
-
- #include "LPR.H"
- #include "lprProtos.H"
-
-
- /************************************************************************
- ************************************************************************/
- integer doAbout(Boolean init)
- {
- DialogRecord DialStorg;
- DialogPtr aboutDial;
- WindowPtr aPort;
- integer ItemHit;
-
- GetPort(&aPort);
-
- SetPort( aboutDial = GetNewDialog(AboutDLOG,
- (Ptr)&DialStorg,
- (WindowPtr) -1) );
- ShowWindow(aboutDial);
-
- InstallUserItem(aboutDial, defFrmItm, (ProcPtr)DefaultFrame);
- SetDialText(aboutDial, wSrvrEdit, prt_server);
- SetDialText(aboutDial, wPrtrEdit, prt_name);
- SetDialText(aboutDial, wLoclEdit, my_host);
- SetDialText(aboutDial, wUserEdit, my_user);
- SetDialCtlVal(aboutDial, wSaveChk, (init)?1:0);
-
- ItemHit = 0;
- while ( ItemHit != okBtn )
- {
- ModalDialog(NIL, &ItemHit);
- switch (ItemHit)
- {
- case cancelBtn :
- Exit();
- break;
- case wSrvrEdit :
- break;
- case wPrtrEdit :
- break;
- case wLoclEdit :
- break;
- case wUserEdit :
- break;
- case wSaveChk :
- ToggleDialCtlVal(aboutDial, wSaveChk);
- break;
- }
- }
-
- GetDialText(aboutDial, wSrvrEdit, prt_server);
- GetDialText(aboutDial, wPrtrEdit, prt_name);
- GetDialText(aboutDial, wLoclEdit, my_host);
- GetDialText(aboutDial, wUserEdit, my_user);
-
- if ( GetDialCtlVal(aboutDial, wSaveChk) )
- WritePreferences();
-
- SetPort(aPort);
- CloseDialog(aboutDial);
-
- return ItemHit;
- }
-
- /************************************************************************
- * return FALSE if you want the main event loop to process this event *
- ************************************************************************/
- integer HandleDEvent(EventPtr myEvent)
- {
- DialogPtr whichDial = 0;
- integer itemHit = 0;
- GrafPtr aPort;
- stdWinHand sHand;
-
-
- if (myEvent->what == updateEvt)
- {
- whichDial = (DialogPtr)myEvent->message;
- GetPort(&aPort);
- SetPort(whichDial);
- BeginUpdate(whichDial);
- DrawDialog(whichDial);
- EndUpdate(whichDial);
- SetPort(aPort);
- return FALSE;
- }
-
- DialogSelect(myEvent, &whichDial, &itemHit);
- if (((WindowPeek)whichDial)->windowKind < 0)
- return TRUE; /* a system window, we should never have got here */
-
- GetPort(&aPort);
- SetPort((GrafPtr)whichDial);
-
- sHand = IsAppWindow(whichDial);
-
- switch (myEvent->what)
- {
- case mouseDown :
- if ( sHand && (*sHand)->clickProc )
- return FALSE;
- break;
- case keyDown:
- case autoKey:
- if (myEvent->modifiers & cmdKey)
- return FALSE;
- if ( sHand && (*sHand)->keyProc )
- return FALSE;
- break;
- case activateEvt :
- if ( sHand && (*sHand)->activateProc )
- return FALSE;
- break;
- case updateEvt :
- if ( sHand && (*sHand)->updateProc )
- return FALSE;
- break;
- }
- SetPort(aPort);
-
- return TRUE;
- }
-
-
- /************************************************************************
- ************************************************************************/
- void AlertUser(integer error)
- {
- Str255 message;
- GrafPtr port;
-
- GetPort(&port);
- SetCursor(&arrow);
- GetIndString(message, kErrStrings, error);
- ParamText(message, (StringPtr)"", (StringPtr)"", (StringPtr)"");
-
- Alert(rUserAlert, NIL);
- SetPort(port);
- } /* AlertUser */
-
-
- /************************************************************************
- ************************************************************************/
- integer FileAlert(integer error, integer errNo)
- {
- integer itemHit;
- Str255 message, numb;
- GrafPtr port;
-
- if (!errNo) return 0; /* actualy no error */
-
- GetPort(&port);
-
- SetCursor(&arrow);
- /* type Str255 is an array in MPW 3 */
- GetIndString(message, kErrStrings, error);
- NumToString(errNo, numb);
- ParamText(message, numb, (StringPtr)"", (StringPtr)"");
-
- itemHit = Alert(rFileAlert, NIL);
- SetPort(port);
- return errNo;
- } /* FileAlert */
-
-
-
- /************************************************************************
- ************************************************************************/
- DialogPtr lpr_ban = NIL;
- DialogRecord lpr_rec;
-
- pascal void Clock(DialogPtr dial, integer item);
- pascal void Scaler(DialogPtr dial, integer item);
-
- /************************************************************************
- ************************************************************************/
- pascal void Scaler(DialogPtr dial, integer item)
- {
- Handle hand;
- integer type;
- Rect rect;
- LongInt pct = GetWRefCon(dial);
-
- SetPort(dial);
- GetDItem(dial, item, &type, &hand, &rect);
- FrameRect(&rect);
- InsetRect(&rect, 1, 1);
- rect.right = ( ( (rect.right - rect.left) * pct ) / 100 ) + rect.left;
- FillRect(&rect, gray);
- }
-
- /************************************************************************
- ************************************************************************/
- pascal void Clock(DialogPtr dial, integer item)
- {
- Handle hand;
- integer type;
- Rect rect;
- LongInt tick = Ticks % 360;
- LongInt pat = GetWRefCon(dial);
-
- SetPort(dial);
- GetDItem(dial, item, &type, &hand, &rect);
- PenSize(4, 4);
- FrameOval(&rect);
- InsetRect(&rect, 6, 6);
- EraseArc(&rect, tick, 90);
- FillArc(&rect, tick+ 90, 90, black);
- EraseArc(&rect, tick+180, 90);
- FillArc(&rect, tick+270, 90, black);
-
- PenNormal();
- }
-
- /************************************************************************
- ************************************************************************/
- void LPR_Banner_Up()
- {
- if (lpr_ban) return;
-
- lpr_ban = GetNewDialog(129, &lpr_rec, (WindowPtr) -1L);
-
- if (!lpr_ban) return;
-
- SetWRefCon(lpr_ban, 0);
- InstallUserItem(lpr_ban, 2, (ProcPtr)Scaler);
- DrawDialog(lpr_ban);
- }
-
- /************************************************************************
- ************************************************************************/
- void LPR_Banner_Down()
- {
- if (lpr_ban)
- CloseDialog(lpr_ban);
- lpr_ban = NIL;
- }
-
- /************************************************************************
- ************************************************************************/
- void LPR_Banner_PCent(LongInt done, LongInt want)
- {
- Handle hand;
- integer type;
- Rect rect;
- LongInt percent;
-
- if (!lpr_ban) return;
-
- if (done == 0)
- {
- SetPort(lpr_ban);
- GetDItem(lpr_ban, 2, &type, &hand, &rect);
- EraseRect(&rect);
- rect.top = 36;
- rect.bottom = rect.top + 24;
- rect.right = rect.left + 332;
- SetDItem(lpr_ban, 2, type, hand, &rect);
- InstallUserItem(lpr_ban, 2, (ProcPtr)Scaler);
- }
-
- if (want > 0) percent = (done * 100)/want;
- else percent = 100;
- SetWRefCon(lpr_ban, percent);
- Scaler(lpr_ban, 2);
- }
-
- /************************************************************************
- ************************************************************************/
- Boolean NewMessage(integer which, StringPtr message);
- Boolean NewMessage(integer which, StringPtr message)
- {
- Str255 buffer;
- Byte *b, *m;
- Byte c;
- if (!message) return FALSE;
- GetDialText(lpr_ban, which, buffer);
- b = buffer; m = message;
- c = *b + 1;
- while (c--)
- if (*b++ != *m++) return TRUE;
-
- return FALSE;
- }
-
- /************************************************************************
- ************************************************************************/
- void LPR_Banner_Spin(StringPtr message)
- {
- Handle hand;
- integer type;
- Rect rect;
-
- if (!lpr_ban) return;
- if (NewMessage(1, message))
- {
- SetPort(lpr_ban);
- SetDialText(lpr_ban, 1, message);
- GetDItem(lpr_ban, 2, &type, &hand, &rect);
- EraseRect(&rect);
- rect.top = 25;
- rect.bottom = rect.top + 70;
- rect.right = rect.left + 70;
- SetDItem(lpr_ban, 2, type, hand, &rect);
- InstallUserItem(lpr_ban, 2, (ProcPtr)Clock);
- }
- Clock(lpr_ban, 2);
- }
-
- /************************************************************************
- ************************************************************************/
- void LPR_Banner_Mess(StringPtr message)
- {
- Handle hand;
- integer type;
- Rect rect;
-
- if (!lpr_ban) return;
- if (NewMessage(1, message))
- SetDialText(lpr_ban, 1, message);
- }
-