os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/mac/tclMacPanic.c
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/mac/tclMacPanic.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,172 @@
1.4 +/*
1.5 + * tclMacPanic.c --
1.6 + *
1.7 + * Source code for the "Tcl_Panic" library procedure used in "Simple
1.8 + * Shell"; other Mac applications will probably call Tcl_SetPanicProc
1.9 + * to set a more robust application-specific panic procedure.
1.10 + *
1.11 + * Copyright (c) 1993-1994 Lockheed Missle & Space Company, AI Center
1.12 + * Copyright (c) 1995-1996 Sun Microsystems, Inc.
1.13 + *
1.14 + * See the file "license.terms" for information on usage and redistribution
1.15 + * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
1.16 + *
1.17 + * RCS: @(#) $Id: tclMacPanic.c,v 1.6 2001/11/23 01:28:08 das Exp $
1.18 + */
1.19 +
1.20 +
1.21 +#include <Events.h>
1.22 +#include <Controls.h>
1.23 +#include <ControlDefinitions.h>
1.24 +#include <Windows.h>
1.25 +#include <TextEdit.h>
1.26 +#include <Fonts.h>
1.27 +#include <Dialogs.h>
1.28 +#include <Icons.h>
1.29 +#include <Sound.h>
1.30 +#include <stdarg.h>
1.31 +#include <stdio.h>
1.32 +#include <stdlib.h>
1.33 +
1.34 +#include "tclInt.h"
1.35 +#include "tclMacInt.h"
1.36 +
1.37 +/*
1.38 + * constants for panic dialog
1.39 + */
1.40 +#define PANICHEIGHT 150 /* Height of dialog */
1.41 +#define PANICWIDTH 350 /* Width of dialog */
1.42 +#define PANIC_BUTTON_RECT {125, 260, 145, 335} /* Rect for button. */
1.43 +#define PANIC_ICON_RECT {10, 20, 42, 52} /* Rect for icon. */
1.44 +#define PANIC_TEXT_RECT {10, 65, 140, 330} /* Rect for text. */
1.45 +#define ENTERCODE (0x03)
1.46 +#define RETURNCODE (0x0D)
1.47 +
1.48 +
1.49 +/*
1.50 + *----------------------------------------------------------------------
1.51 + *
1.52 + * TclpPanic --
1.53 + *
1.54 + * Displays panic info, then aborts
1.55 + *
1.56 + * Results:
1.57 + * None.
1.58 + *
1.59 + * Side effects:
1.60 + * The process dies, entering the debugger if possible.
1.61 + *
1.62 + *----------------------------------------------------------------------
1.63 + */
1.64 +
1.65 + /* VARARGS ARGSUSED */
1.66 +void
1.67 +TclpPanic TCL_VARARGS_DEF(CONST char *, format)
1.68 +{
1.69 + va_list varg;
1.70 + char msg[256];
1.71 + WindowRef macWinPtr, foundWinPtr;
1.72 + Rect macRect;
1.73 + Rect buttonRect = PANIC_BUTTON_RECT;
1.74 + Rect iconRect = PANIC_ICON_RECT;
1.75 + Rect textRect = PANIC_TEXT_RECT;
1.76 + ControlHandle okButtonHandle;
1.77 + EventRecord event;
1.78 + Handle stopIconHandle;
1.79 + int part;
1.80 + Boolean done = false;
1.81 +
1.82 + va_start(varg, format);
1.83 + vsprintf(msg, format, varg);
1.84 + va_end(varg);
1.85 +
1.86 + /*
1.87 + * Put up an alert without using the Resource Manager (there may
1.88 + * be no resources to load). Use the Window and Control Managers instead.
1.89 + * We want the window centered on the main monitor. The following
1.90 + * should be tested with multiple monitors. Look and see if there is a way
1.91 + * not using qd.screenBits.
1.92 + */
1.93 +
1.94 + macRect.top = (qd.screenBits.bounds.top + qd.screenBits.bounds.bottom)
1.95 + / 2 - (PANICHEIGHT / 2);
1.96 + macRect.bottom = (qd.screenBits.bounds.top + qd.screenBits.bounds.bottom)
1.97 + / 2 + (PANICHEIGHT / 2);
1.98 + macRect.left = (qd.screenBits.bounds.left + qd.screenBits.bounds.right)
1.99 + / 2 - (PANICWIDTH / 2);
1.100 + macRect.right = (qd.screenBits.bounds.left + qd.screenBits.bounds.right)
1.101 + / 2 + (PANICWIDTH / 2);
1.102 +
1.103 + macWinPtr = NewWindow(NULL, &macRect, "\p", true, dBoxProc, (WindowRef) -1,
1.104 + false, 0);
1.105 + if (macWinPtr == NULL) {
1.106 + goto exitNow;
1.107 + }
1.108 +
1.109 + okButtonHandle = NewControl(macWinPtr, &buttonRect, "\pOK", true,
1.110 + 0, 0, 1, pushButProc, 0);
1.111 + if (okButtonHandle == NULL) {
1.112 + CloseWindow(macWinPtr);
1.113 + goto exitNow;
1.114 + }
1.115 +
1.116 + SelectWindow(macWinPtr);
1.117 + SetCursor(&qd.arrow);
1.118 + stopIconHandle = GetIcon(kStopIcon);
1.119 +
1.120 + while (!done) {
1.121 + if (WaitNextEvent(mDownMask | keyDownMask | updateMask,
1.122 + &event, 0, NULL)) {
1.123 + switch(event.what) {
1.124 + case mouseDown:
1.125 + part = FindWindow(event.where, &foundWinPtr);
1.126 +
1.127 + if ((foundWinPtr != macWinPtr) || (part != inContent)) {
1.128 + SysBeep(1);
1.129 + } else {
1.130 + SetPortWindowPort(macWinPtr);
1.131 + GlobalToLocal(&event.where);
1.132 + part = FindControl(event.where, macWinPtr,
1.133 + &okButtonHandle);
1.134 +
1.135 + if ((kControlButtonPart == part) &&
1.136 + (TrackControl(okButtonHandle,
1.137 + event.where, NULL))) {
1.138 + done = true;
1.139 + }
1.140 + }
1.141 + break;
1.142 + case keyDown:
1.143 + switch (event.message & charCodeMask) {
1.144 + case ENTERCODE:
1.145 + case RETURNCODE:
1.146 + HiliteControl(okButtonHandle, 1);
1.147 + HiliteControl(okButtonHandle, 0);
1.148 + done = true;
1.149 + }
1.150 + break;
1.151 + case updateEvt:
1.152 + SetPortWindowPort(macWinPtr);
1.153 + TextFont(systemFont);
1.154 +
1.155 + BeginUpdate(macWinPtr);
1.156 + if (stopIconHandle != NULL) {
1.157 + PlotIcon(&iconRect, stopIconHandle);
1.158 + }
1.159 + TETextBox(msg, strlen(msg), &textRect, teFlushDefault);
1.160 + DrawControls(macWinPtr);
1.161 + EndUpdate(macWinPtr);
1.162 + }
1.163 + }
1.164 + }
1.165 +
1.166 + CloseWindow(macWinPtr);
1.167 +
1.168 + exitNow:
1.169 +#ifdef TCL_DEBUG
1.170 + Debugger();
1.171 +#else
1.172 + abort();
1.173 +#endif
1.174 +}
1.175 +