1/* 2 * tkUnixDialog.c -- 3 * 4 * Contains the Unix implementation of the common dialog boxes: 5 * 6 * Copyright (c) 1996 Sun Microsystems, Inc. 7 * 8 * See the file "license.terms" for information on usage and redistribution 9 * of this file, and for a DISCLAIMER OF ALL WARRANTIES. 10 * 11 * RCS: @(#) $Id$ 12 * 13 */ 14 15#include "tkUnixInt.h" 16 17/* 18 * The wrapper code for Unix is actually set up in library/tk.tcl these days; 19 * the procedure names used here are probably wrong too... 20 */ 21 22#ifdef TK_OBSOLETE_UNIX_DIALOG_WRAPPERS 23 24/* 25 *---------------------------------------------------------------------- 26 * 27 * EvalObjv -- 28 * 29 * Invokes the Tcl procedure with the arguments. 30 * 31 * Results: 32 * Returns the result of the evaluation of the command. 33 * 34 * Side effects: 35 * The command may be autoloaded. 36 * 37 *---------------------------------------------------------------------- 38 */ 39 40static int 41EvalObjv( 42 Tcl_Interp *interp, /* Current interpreter. */ 43 char *cmdName, /* Name of the TCL command to call */ 44 int objc, /* Number of arguments. */ 45 Tcl_Obj *CONST *objv) /* Arguments. */ 46{ 47 Tcl_Obj *cmdObj, **objs; 48 int result; 49 50 cmdObj = Tcl_NewStringObj(cmdName, -1); 51 Tcl_IncrRefCount(cmdObj); 52 objs = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj*) * (unsigned)(objc+1)); 53 objs[0] = cmdObj; 54 memcpy(objs+1, objv, sizeof(Tcl_Obj *) * (unsigned)objc); 55 56 result = Tcl_EvalObjv(interp, objc+1, objs, 0); 57 58 Tcl_DecrRefCount(cmdObj); 59 ckfree((char *) objs); 60 61 return result; 62} 63 64/* 65 *---------------------------------------------------------------------- 66 * 67 * Tk_ChooseColorObjCmd -- 68 * 69 * This procedure implements the color dialog box for the Unix platform. 70 * See the user documentation for details on what it does. 71 * 72 * Results: 73 * See user documentation. 74 * 75 * Side effects: 76 * A dialog window is created the first time this procedure is called. 77 * This window is not destroyed and will be reused the next time the 78 * application invokes the "tk_chooseColor" command. 79 * 80 *---------------------------------------------------------------------- 81 */ 82 83int 84Tk_ChooseColorObjCmd( 85 ClientData clientData, /* Main window associated with interpreter. */ 86 Tcl_Interp *interp, /* Current interpreter. */ 87 int objc, /* Number of arguments. */ 88 Tcl_Obj *CONST *objv) /* Arguments. */ 89{ 90 return EvalObjv(interp, "tk::ColorDialog", objc-1, objv+1); 91} 92 93/* 94 *---------------------------------------------------------------------- 95 * 96 * Tk_GetOpenFileCmd -- 97 * 98 * This procedure implements the "open file" dialog box for the Unix 99 * platform. See the user documentation for details on what it does. 100 * 101 * Results: 102 * See user documentation. 103 * 104 * Side effects: 105 * A dialog window is created the first this procedure is called. This 106 * window is not destroyed and will be reused the next time the 107 * application invokes the "tk_getOpenFile" or "tk_getSaveFile" command. 108 * 109 *---------------------------------------------------------------------- 110 */ 111 112int 113Tk_GetOpenFileObjCmd( 114 ClientData clientData, /* Main window associated with interpreter. */ 115 Tcl_Interp *interp, /* Current interpreter. */ 116 int objc, /* Number of arguments. */ 117 Tcl_Obj *CONST *objv) /* Arguments. */ 118{ 119 Tk_Window tkwin = (Tk_Window)clientData; 120 121 if (Tk_StrictMotif(tkwin)) { 122 return EvalObjv(interp, "tk::MotifOpenFDialog", objc-1, objv+1); 123 } else { 124 return EvalObjv(interp, "tk::OpenFDialog", objc-1, objv+1); 125 } 126} 127 128/* 129 *---------------------------------------------------------------------- 130 * 131 * Tk_GetSaveFileCmd -- 132 * 133 * Same as Tk_GetOpenFileCmd but opens a "save file" dialog box instead. 134 * 135 * Results: 136 * Same as Tk_GetOpenFileCmd. 137 * 138 * Side effects: 139 * Same as Tk_GetOpenFileCmd. 140 * 141 *---------------------------------------------------------------------- 142 */ 143 144int 145Tk_GetSaveFileObjCmd( 146 ClientData clientData, /* Main window associated with interpreter. */ 147 Tcl_Interp *interp, /* Current interpreter. */ 148 int objc, /* Number of arguments. */ 149 Tcl_Obj *CONST *objv) /* Arguments. */ 150{ 151 Tk_Window tkwin = (Tk_Window)clientData; 152 153 if (Tk_StrictMotif(tkwin)) { 154 return EvalObjv(interp, "tk::MotifSaveFDialog", objc-1, objv+1); 155 } else { 156 return EvalObjv(interp, "tk::SaveFDialog", objc-1, objv+1); 157 } 158} 159 160/* 161 *---------------------------------------------------------------------- 162 * 163 * Tk_MessageBoxCmd -- 164 * 165 * This procedure implements the MessageBox window for the Unix 166 * platform. See the user documentation for details on what it does. 167 * 168 * Results: 169 * See user documentation. 170 * 171 * Side effects: 172 * None. The MessageBox window will be destroy before this procedure 173 * returns. 174 * 175 *---------------------------------------------------------------------- 176 */ 177 178int 179Tk_MessageBoxCmd( 180 ClientData clientData, /* Main window associated with interpreter. */ 181 Tcl_Interp *interp, /* Current interpreter. */ 182 int objc, /* Number of arguments. */ 183 Tcl_Obj *CONST *objv) /* Arguments. */ 184{ 185 return EvalObjv(interp, "tk::MessageBox", objc-1, objv+1); 186} 187 188#endif /* TK_OBSOLETE_UNIX_DIALOG_WRAPPERS */ 189 190/* 191 * Local Variables: 192 * mode: c 193 * c-basic-offset: 4 194 * fill-column: 78 195 * End: 196 */ 197