home *** CD-ROM | disk | FTP | other *** search
- /* PD_About_Dialog */
-
- /* File name: About_Dialog */
- /* Function: Handle a modal dialog */
- /* History: 3/15/91 Original by Prototyper 3.0 */
-
-
- #include "PCommonMacify.h" /* Common */
- #include "Common_Macify.h" /* Common */
- #include "PUtils_Macify.h" /* General Utilities */
- #include "Utils_Macify.h" /* General Utilities */
-
- #include "PD_About_Dialog.h" /* This file */
- #include "About_Dialog.h" /* The user file */
-
-
- /* ======================================================= */
-
-
- static Boolean ExitDialog; /* Flag used to exit the Dialog */
- static Point MyPt; /* Current list selection point */
- static OSErr MyErr; /* OS error returned */
- static DialogPtr GetSelection; /* Pointer to this dialog */
- static GrafPtr SavedPort; /* Previous grafport */
-
- /* Prototypes */
- /* Filter routine for modal dialog routine */
- static pascal Boolean MyFilter (DialogPtr theDialog ,EventRecord *theEvent,short *itemHit);
-
- /* This is an update routine for non-controls in the dialog */
- /* This is executed after the dialog is uncovered by an alert */
- static void Refresh_Dialog(void); /* Refresh the dialogs non-controls */
-
-
-
- /* ======================================================= */
-
- /* Initialize the modal dialog, globals and call users routine */
-
- void I_PD_About_Dialog()
- {
- Rect tempRect; /* Temporary rectangle */
- short DType; /* Type of dialog item */
- short Index; /* For looping */
- Handle DItem; /* Handle to the dialog item */
- ControlHandle CItem, CTempItem; /* Control handle */
- Str255 sTemp; /* Get text entered, temp holding */
- short itemHit; /* Get selection */
- short temp; /* Get selection, temp holding */
-
-
-
-
- D_Init_About_Dialog();
-
- } /* End of procedure */
-
-
- /* ======================================================= */
-
- /* Filter routine for dialog events */
-
- static pascal Boolean MyFilter (theDialog ,theEvent,itemHit)
- DialogPtr theDialog;
- EventRecord *theEvent;
- short *itemHit;
- {
- Point MyPt; /* Current list selection point */
- Rect tempRect; /* Temporary rectangle */
- short DType; /* Type of dialog item */
- Handle DItem; /* Handle to the dialog item */
- ControlHandle CItem; /* Control handle */
- short chCode; /* Key entered */
- long LTemp; /* Used for time delay */
- char MyCmdKey; /* The command key */
- Boolean CmdDown; /* Flag for command key used */
- Boolean valMyFilter; /* Value to return */
-
-
-
- valMyFilter = D_Filter_About_Dialog(theDialog, theEvent, itemHit);/* Call the user routine */
-
- if ((theEvent->what == updateEvt) && ((WindowPtr)theEvent->message == theDialog))/* Only do on an update */
- {
- BeginUpdate(theDialog); /* Start the update */
- DrawDialog(theDialog); /* Draw the controls */
- valMyFilter = TRUE; /* Pass out this special itemHit number */
- *itemHit = 32000; /* Our special ID */
- }
- if (theEvent->what == mouseDown) /* Only do on a mouse click */
- {
- MyPt = theEvent->where; /* Get the point where the mouse was clicked */
- GlobalToLocal(&MyPt); /* Convert global to local */
-
-
- }
- if (theEvent->what == keyDown)
- {
- chCode = theEvent->message & charCodeMask; /* Get character */
- MyCmdKey = (char)chCode; /* Change to ASCII */
- CmdDown = ((theEvent->modifiers / cmdKey) != 0); /* Get command key state */
- if (CmdDown == TRUE) /* Do if command key was down */
- {
- if ((MyCmdKey == 'x') || (MyCmdKey == 'X'))
- {
- DlgCut(theDialog);
- valMyFilter = TRUE;
- }
- else if ((MyCmdKey =='c') || (MyCmdKey == 'C'))
- {
- DlgCopy(theDialog);
- valMyFilter = TRUE;
- }
- else if ((MyCmdKey =='v') || (MyCmdKey == 'V'))
- {
- DlgPaste(theDialog);
- valMyFilter = TRUE;
- }
- }
- else if ((chCode == 13) || (chCode == 3)) /* CR or Enter */
- {
- valMyFilter = TRUE; /* Flag we got a hit */
- *itemHit = 1; /* Default for CR */
- GetDItem (theDialog ,*itemHit, &DType, &DItem, &tempRect);/* Get the item */
- if (DType == (ctrlItem + btnCtrl)) /* If a button then ... */
- {
- CItem = (ControlHandle)DItem; /* Make it a controlhandle */
- HiliteControl(CItem, 10); /* Hilite it */
- LTemp = TickCount() + 15; /* Flash the button for 1/4 second */
- do
- {}
- while (LTemp > TickCount());
- HiliteControl(CItem, 0); /* UnHilite it */
- }
- }
- }
-
- return(valMyFilter);
- }
-
- /* ======================================================= */
-
-
-
- /* ======================================================= */
-
- /* This is an update routine for non-controls in the dialog */
- /* This is executed after the dialog is uncovered by an alert */
- static void Refresh_Dialog() /* Refresh the dialogs non-controls */
- {
- Rect rTempRect; /* Temp rectangle used for drawing */
- short DType; /* Type of dialog item */
- Handle DItem; /* Handle to the dialog item */
- ControlHandle CItem; /* Control handle */
-
-
-
- SetPort(GetSelection); /* Point to our dialog window */
- rTempRect = tempRect; /* Save the current contents of tempRect */
- GetDItem(GetSelection,Res_Dlg_OK,&DType,&DItem,&tempRect);/* Get the item handle */
- PenSize(3, 3); /* Change pen to draw thick default outline */
- InsetRect(&tempRect, -4, -4); /* Draw outside the button by 1 pixel */
- FrameRoundRect(&tempRect, 16, 16); /* Draw the outline */
- PenSize(1, 1); /* Restore the pen size to the default value */
-
- /* Draw a line, Drawn line1 */
- MoveTo(15,45); /* Horz,vert, Move to starting position */
- LineTo(174,45); /* Horz,vert, Draw to the ending position */
-
- /* Draw a line, Drawn line1-2 */
- MoveTo(15,50); /* Horz,vert, Move to starting position */
- LineTo(174,50); /* Horz,vert, Draw to the ending position */
-
- /* Draw a line, Drawn line1-2-3 */
- MoveTo(15,55); /* Horz,vert, Move to starting position */
- LineTo(174,55); /* Horz,vert, Draw to the ending position */
-
- tempRect = rTempRect; /* Restore the current contents of tempRect */
- TextSize(9);
- TextFont(geneva); /* Select the Font that we want */
- /* Draw a string of text, legalese1 */
- SetRect(&rTempRect, 5,220,380,245);
- GetIndString(sTemp,Res_Dlg_legalese1,1); /* Get the string */
- TextBox(&sTemp[1], sTemp[0], &rTempRect,teJustLeft);
-
- /* Draw a string of text, legalese2 */
- SetRect(&rTempRect, 5,245,355,285);
- GetIndString(sTemp,Res_Dlg_legalese2,1); /* Get the string */
- TextBox(&sTemp[1], sTemp[0], &rTempRect,teJustLeft);
-
- TextSize(12);
- TextFont(systemFont); /* Select the Font that we want */
- TextFace(0); /* Select the style that we want */
-
-
- D_Refresh_About_Dialog(GetSelection); /* Call user refresh routine */
-
- }
-
- /* ======================================================= */
-
-
- void PD_About_Dialog()
- {
- Rect tempRect; /* Temporary rectangle */
- short DType; /* Type of dialog item */
- short Index; /* For looping */
- Handle DItem; /* Handle to the dialog item */
- ControlHandle CItem; /* Control handle */
- ControlHandle CTempItem; /* temp Control handle */
- Str255 sTemp; /* Get text entered, temp holding */
- short itemHit; /* Get selection */
- short temp; /* Get selection, temp holding */
-
-
-
- GetPort(&SavedPort); /* Get the previous grafport */
-
-
- GetSelection = GetNewDialog(Res_D_About_Dialog, NIL, (Ptr)-1);/* Bring in the dialog resource */
- ShowWindow(GetSelection); /* Open a dialog box */
- SelectWindow(GetSelection); /* Lets see it */
- SetPort(GetSelection); /* Prepare to add conditional text */
-
-
- /* Setup initial conditions */
- Refresh_Dialog(); /* Draw any Lists, lines, or rectangles */
-
- ExitDialog = FALSE; /* Do not exit dialog handle loop yet */
-
- D_Setup_About_Dialog(GetSelection); /* Call user Dialog setup routine */
-
- do /* Start of dialog handle loop */
- {
- ModalDialog(&MyFilter, &itemHit); /* Wait until an item is hit */
-
- if (itemHit == 32000) /* Check for update */
- {
- Refresh_Dialog(); /* Draw any Lists, lines, or rectangles*/
- EndUpdate(GetSelection); /* End of the update*/
- }
- else
- {
- GetDItem(GetSelection, itemHit, &DType, &DItem, &tempRect);/* Get item information */
- CItem = (ControlHandle)DItem; /* Get the control handle */
- }
-
- D_Hit_About_Dialog(GetSelection,itemHit,&ExitDialog); /* Let user handle the item hit */
-
- /* Handle it real time */
- if (itemHit ==Res_Dlg_OK) /* Handle the Button being pressed */
- {
- ExitDialog = TRUE; /* Close this dialog, exit */
- }
-
-
- }
- while (ExitDialog == FALSE); /* Handle dialog items until exit selected */
-
-
- D_Exit_About_Dialog(GetSelection); /* Exiting the modal dialog */
-
- SetPort(SavedPort); /* Restore the previous grafport */
-
- DisposDialog(GetSelection); /* Flush the dialog out of memory */
-
-
- } /* End of procedure */
-
-