os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/mac/tclMacPanic.c
Update contrib.
4 * Source code for the "Tcl_Panic" library procedure used in "Simple
5 * Shell"; other Mac applications will probably call Tcl_SetPanicProc
6 * to set a more robust application-specific panic procedure.
8 * Copyright (c) 1993-1994 Lockheed Missle & Space Company, AI Center
9 * Copyright (c) 1995-1996 Sun Microsystems, Inc.
11 * See the file "license.terms" for information on usage and redistribution
12 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 * RCS: @(#) $Id: tclMacPanic.c,v 1.6 2001/11/23 01:28:08 das Exp $
20 #include <ControlDefinitions.h>
32 #include "tclMacInt.h"
35 * constants for panic dialog
37 #define PANICHEIGHT 150 /* Height of dialog */
38 #define PANICWIDTH 350 /* Width of dialog */
39 #define PANIC_BUTTON_RECT {125, 260, 145, 335} /* Rect for button. */
40 #define PANIC_ICON_RECT {10, 20, 42, 52} /* Rect for icon. */
41 #define PANIC_TEXT_RECT {10, 65, 140, 330} /* Rect for text. */
42 #define ENTERCODE (0x03)
43 #define RETURNCODE (0x0D)
47 *----------------------------------------------------------------------
51 * Displays panic info, then aborts
57 * The process dies, entering the debugger if possible.
59 *----------------------------------------------------------------------
62 /* VARARGS ARGSUSED */
64 TclpPanic TCL_VARARGS_DEF(CONST char *, format)
68 WindowRef macWinPtr, foundWinPtr;
70 Rect buttonRect = PANIC_BUTTON_RECT;
71 Rect iconRect = PANIC_ICON_RECT;
72 Rect textRect = PANIC_TEXT_RECT;
73 ControlHandle okButtonHandle;
75 Handle stopIconHandle;
79 va_start(varg, format);
80 vsprintf(msg, format, varg);
84 * Put up an alert without using the Resource Manager (there may
85 * be no resources to load). Use the Window and Control Managers instead.
86 * We want the window centered on the main monitor. The following
87 * should be tested with multiple monitors. Look and see if there is a way
88 * not using qd.screenBits.
91 macRect.top = (qd.screenBits.bounds.top + qd.screenBits.bounds.bottom)
92 / 2 - (PANICHEIGHT / 2);
93 macRect.bottom = (qd.screenBits.bounds.top + qd.screenBits.bounds.bottom)
94 / 2 + (PANICHEIGHT / 2);
95 macRect.left = (qd.screenBits.bounds.left + qd.screenBits.bounds.right)
96 / 2 - (PANICWIDTH / 2);
97 macRect.right = (qd.screenBits.bounds.left + qd.screenBits.bounds.right)
98 / 2 + (PANICWIDTH / 2);
100 macWinPtr = NewWindow(NULL, &macRect, "\p", true, dBoxProc, (WindowRef) -1,
102 if (macWinPtr == NULL) {
106 okButtonHandle = NewControl(macWinPtr, &buttonRect, "\pOK", true,
107 0, 0, 1, pushButProc, 0);
108 if (okButtonHandle == NULL) {
109 CloseWindow(macWinPtr);
113 SelectWindow(macWinPtr);
114 SetCursor(&qd.arrow);
115 stopIconHandle = GetIcon(kStopIcon);
118 if (WaitNextEvent(mDownMask | keyDownMask | updateMask,
122 part = FindWindow(event.where, &foundWinPtr);
124 if ((foundWinPtr != macWinPtr) || (part != inContent)) {
127 SetPortWindowPort(macWinPtr);
128 GlobalToLocal(&event.where);
129 part = FindControl(event.where, macWinPtr,
132 if ((kControlButtonPart == part) &&
133 (TrackControl(okButtonHandle,
134 event.where, NULL))) {
140 switch (event.message & charCodeMask) {
143 HiliteControl(okButtonHandle, 1);
144 HiliteControl(okButtonHandle, 0);
149 SetPortWindowPort(macWinPtr);
150 TextFont(systemFont);
152 BeginUpdate(macWinPtr);
153 if (stopIconHandle != NULL) {
154 PlotIcon(&iconRect, stopIconHandle);
156 TETextBox(msg, strlen(msg), &textRect, teFlushDefault);
157 DrawControls(macWinPtr);
158 EndUpdate(macWinPtr);
163 CloseWindow(macWinPtr);