home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / stk-3.0 / stk-3 / blt-for-STk-3.0 / blt-1.9 / src / bltBell.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-01  |  2.9 KB  |  100 lines

  1. /*
  2.  * bltBell.c --
  3.  *
  4.  * Copyright 1993-1994 by AT&T Bell Laboratories.
  5.  * Permission to use, copy, modify, and distribute this software
  6.  * and its documentation for any purpose and without fee is hereby
  7.  * granted, provided that the above copyright notice appear in all
  8.  * copies and that both that the copyright notice and warranty
  9.  * disclaimer appear in supporting documentation, and that the
  10.  * names of AT&T Bell Laboratories any of their entities not be used
  11.  * in advertising or publicity pertaining to distribution of the
  12.  * software without specific, written prior permission.
  13.  *
  14.  * AT&T disclaims all warranties with regard to this software, including
  15.  * all implied warranties of merchantability and fitness.  In no event
  16.  * shall AT&T be liable for any special, indirect or consequential
  17.  * damages or any damages whatsoever resulting from loss of use, data
  18.  * or profits, whether in an action of contract, negligence or other
  19.  * tortuous action, arising out of or in connection with the use or
  20.  * performance of this software.
  21.  *
  22.  */
  23. #include "blt.h"
  24.  
  25. #ifndef BELL_VERSION
  26. #define BELL_VERSION "1.0"
  27. #endif
  28.  
  29. /*
  30.  *----------------------------------------------------------------------
  31.  *
  32.  * Blt_BellCmd --
  33.  *
  34.  *    This procedure is invoked to process the "bell" Tcl command.
  35.  *    See the user documentation for details on what it does.
  36.  *
  37.  * Results:
  38.  *    A standard Tcl result.
  39.  *
  40.  * Side effects:
  41.  *    None.
  42.  *
  43.  *----------------------------------------------------------------------
  44.  */
  45.  
  46. /* ARGSUSED */
  47. static int
  48. BellCmd(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.     Tk_Window tkwin = (Tk_Window)clientData;
  55.     int percent;
  56.  
  57.     if (argc > 2) {
  58.     Tcl_AppendResult(interp, "wrong # args: should be \"",
  59.         argv[0], " ?volumePercent?\"", (char *)NULL);
  60.     return TCL_ERROR;
  61.     }
  62.     if (argc == 1) {
  63.     percent = 50;        /* Default setting */
  64.     } else if (argc == 2) {
  65.     if (Tcl_GetInt(interp, argv[1], &percent) != TCL_OK) {
  66.         return TCL_ERROR;
  67.     }
  68.     if ((percent < -100) || (percent > 100)) {
  69.         Tcl_AppendResult(interp, "bad volume percentage value \"",
  70.         argv[1], "\"", (char *)NULL);
  71.         return TCL_ERROR;
  72.     }
  73.     }
  74.     XBell(Tk_Display(tkwin), percent);
  75.     return TCL_OK;
  76. }
  77.  
  78. int
  79. Blt_BellInit(interp)
  80.     Tcl_Interp *interp;
  81. {
  82.     Tk_Window tkwin;
  83.  
  84.     if (Blt_FindCmd(interp, "blt_bell", (ClientData *)NULL) == TCL_OK) {
  85.     Tcl_AppendResult(interp, "\"blt_bell\" command already exists",
  86.         (char *)NULL);
  87.     return TCL_ERROR;
  88.     }
  89.     tkwin = Tk_MainWindow(interp);
  90.     if (tkwin == NULL) {
  91.     Tcl_AppendResult(interp, "\"blt_bell\" requires Tk", (char *)NULL);
  92.     return TCL_ERROR;
  93.     }
  94.     Tcl_SetVar2(interp, "blt_versions", "blt_bell", BELL_VERSION,
  95.     TCL_GLOBAL_ONLY);
  96.     Tcl_CreateCommand(interp, "blt_bell", BellCmd, (ClientData)tkwin,
  97.     (Tcl_CmdDeleteProc *)NULL);
  98.     return TCL_OK;
  99. }
  100.