home *** CD-ROM | disk | FTP | other *** search
- /*****
- *
- * DialogFunc.c
- *
- * This is a support file for "Grant's CGI Framework".
- * Please see the license agreement that accompanies the distribution package
- * for licensing details.
- *
- * Copyright ©1995,1996 by Grant Neufeld
- * grant@acm.com
- * http://arpp.carleton.ca/cgi/framework/
- *
- *****/
-
- #include "MyConfiguration.h"
- #if kCompileWithForeground
-
- #include <Threads.h>
-
- #include "constants.h"
- #include "globals.h"
-
- #include "Events.h"
- #include "WindowInt.h"
-
- #include "DialogFunc.h"
-
-
- /*** LOCAL CONSTANTS ***/
-
- #define kButtonFrameInset -4
- #define kButtonFrameSize 3
-
-
- /*** FUNCTIONS ***/
-
- /* draw the button outline for the specified item */
- pascal void
- DialogDefaultButtonOutline ( DialogPtr theDialog, short itemNumber )
- {
- // #pragma unused(itemNumber)
-
- PenState curPen;
- short itemType;
- Handle itemHandle;
- Rect itemRect;
- short rectCornerRadius;
-
- GetPenState ( &curPen );
- PenNormal ();
-
- // InsetRect ( &itemRect, kButtonFrameInset, kButtonFrameInset );
- // FrameRoundRect ( &itemRect, 16, 16 );
-
- GetDialogItem ( theDialog, kDefaultButtonID, &itemType, &itemHandle, &itemRect );
- if ( (itemHandle != NULL) &&
- ((*(ControlHandle)itemHandle)->contrlHilite != nil) )
- {
- /* control is dimmed - draw in gray */
- PenPat ( &qd.gray );
- }
- else
- {
- PenPat ( &qd.black );
- }
-
- GetDialogItem ( theDialog, itemNumber, &itemType, &itemHandle, &itemRect );
- PenSize ( kButtonFrameSize, kButtonFrameSize );
- rectCornerRadius = ((itemRect.bottom - itemRect.top) / 2) + 2;
- FrameRoundRect ( &itemRect, rectCornerRadius, rectCornerRadius );
-
- SetPenState ( &curPen );
- } /* DialogDefaultButtonOutline */
-
-
-
-
- /* This function responds to update, and activate events, and key presses.
- return, enter, Command-. and esc select the 'OK' button (kDefaultButtonID).
- (There's no Cancel button) */
- pascal Boolean
- defaultAlert1ButtonEventFilter ( DialogPtr theDialog, EventRecord *theEvent, short *itemHit)
- {
- Boolean result;
- char key;
- short itemType;
- Handle itemHandle;
- Rect itemRect;
- long finalTicks;
-
- result = false;
-
- switch ( theEvent->what )
- {
- case keyDown :
- key = (char)( theEvent->message & charCodeMask );
-
- if ( (key == (char)kReturnKey) || (key == (char)kEnterKey) ||
- (key == (char)kEscapeKey) ||
- ((key == (char)kPeriodKey) && (theEvent->modifiers & cmdKey)) )
- {
- GetDialogItem ( theDialog, kDefaultButtonID, &itemType, &itemHandle, &itemRect );
- HiliteControl ( (ControlHandle)itemHandle, 0 );
- Delay ( (long)kVisualDelay, &finalTicks );
- HiliteControl ( (ControlHandle)itemHandle, 0 );
-
- result = true;
- *itemHit = (short)kDefaultButtonID;
- }
- break;
- }
-
- return result;
- } /* defaultAlert1ButtonEventFilter */
-
-
- #endif /* kCompileWithForeground */
-
- /***** EOF *****/
-