| 1 |
/* |
| 2 |
* bltBeep.c -- |
| 3 |
* |
| 4 |
* Copyright 1993-1998 Lucent Technologies, Inc. |
| 5 |
* |
| 6 |
* Permission to use, copy, modify, and distribute this software and |
| 7 |
* its documentation for any purpose and without fee is hereby |
| 8 |
* granted, provided that the above copyright notice appear in all |
| 9 |
* copies and that both that the copyright notice and warranty |
| 10 |
* disclaimer appear in supporting documentation, and that the names |
| 11 |
* of Lucent Technologies any of their entities not be used in |
| 12 |
* advertising or publicity pertaining to distribution of the software |
| 13 |
* without specific, written prior permission. |
| 14 |
* |
| 15 |
* Lucent Technologies disclaims all warranties with regard to this |
| 16 |
* software, including all implied warranties of merchantability and |
| 17 |
* fitness. In no event shall Lucent Technologies be liable for any |
| 18 |
* special, indirect or consequential damages or any damages |
| 19 |
* whatsoever resulting from loss of use, data or profits, whether in |
| 20 |
* an action of contract, negligence or other tortuous action, arising |
| 21 |
* out of or in connection with the use or performance of this |
| 22 |
* software. */ |
| 23 |
|
| 24 |
#include "bltInt.h" |
| 25 |
|
| 26 |
#ifndef NO_BEEP |
| 27 |
/* |
| 28 |
*---------------------------------------------------------------------- |
| 29 |
* |
| 30 |
* Blt_BeepCmd -- |
| 31 |
* |
| 32 |
* This procedure is invoked to process the "bell" Tcl command. |
| 33 |
* See the user documentation for details on what it does. |
| 34 |
* |
| 35 |
* Results: |
| 36 |
* A standard Tcl result. |
| 37 |
* |
| 38 |
* Side effects: |
| 39 |
* None. |
| 40 |
* |
| 41 |
*---------------------------------------------------------------------- |
| 42 |
*/ |
| 43 |
|
| 44 |
static Tcl_CmdProc BeepCmd; |
| 45 |
|
| 46 |
/* ARGSUSED */ |
| 47 |
static int |
| 48 |
BeepCmd(clientData, interp, argc, argv) |
| 49 |
ClientData clientData; /* Main window associated with interpreter.*/ |
| 50 |
Tcl_Interp *interp; /* Current interpreter. */ |
| 51 |
int argc; /* Number of arguments. */ |
| 52 |
char **argv; /* Argument strings. */ |
| 53 |
{ |
| 54 |
int percent; |
| 55 |
|
| 56 |
if (argc > 2) { |
| 57 |
Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 58 |
argv[0], " ?volumePercent?\"", (char *)NULL); |
| 59 |
return TCL_ERROR; |
| 60 |
} |
| 61 |
if (argc == 1) { |
| 62 |
percent = 50; /* Default setting */ |
| 63 |
} else if (argc == 2) { |
| 64 |
if (Tcl_GetInt(interp, argv[1], &percent) != TCL_OK) { |
| 65 |
return TCL_ERROR; |
| 66 |
} |
| 67 |
if ((percent < -100) || (percent > 100)) { |
| 68 |
Tcl_AppendResult(interp, "bad volume percentage value \"", |
| 69 |
argv[1], "\"", (char *)NULL); |
| 70 |
return TCL_ERROR; |
| 71 |
} |
| 72 |
} |
| 73 |
XBell(Tk_Display(Tk_MainWindow(interp)), percent); |
| 74 |
return TCL_OK; |
| 75 |
} |
| 76 |
|
| 77 |
int |
| 78 |
Blt_BeepInit(interp) |
| 79 |
Tcl_Interp *interp; |
| 80 |
{ |
| 81 |
static Blt_CmdSpec cmdSpec = |
| 82 |
{"beep", BeepCmd,}; |
| 83 |
|
| 84 |
if (Blt_InitCmd(interp, "blt", &cmdSpec) == NULL) { |
| 85 |
return TCL_ERROR; |
| 86 |
} |
| 87 |
return TCL_OK; |
| 88 |
} |
| 89 |
|
| 90 |
#endif /* NO_BEEP */ |