Example #1
0
File: light.c Project: Thump/sceda
static void
Light_Intensity_Callback(Widget w, XtPointer cl, XtPointer ca)
{
	String	int_string;
	double	r = 0.0;
	double	g = 0.0;
	double	b = 0.0;
	int		num_args;
	InstanceList	elmt;

	XtPopdown(light_shell);

	int_string = XawDialogGetValueString(light_dialog);

	num_args = sscanf(int_string, "%lf %lf %lf", &r, &g, &b);
	if ( num_args < 3 )
		g = b = r;

	for ( elmt = instances ; elmt ; elmt = elmt->next )
		if ( elmt->the_instance->o_parent->b_class == light_obj )
		{
			((LightInfoPtr)elmt->the_instance->o_attribs)->red = r;
			((LightInfoPtr)elmt->the_instance->o_attribs)->green = g;
			((LightInfoPtr)elmt->the_instance->o_attribs)->blue = b;
		}

	changed_scene = TRUE;

	if ( spotlight_after )
		Set_Spotlight_Attributes(instances, arealight_after);
	else if ( arealight_after )
		Set_Arealight_Attributes(instances);

}
Example #2
0
File: light.c Project: Thump/sceda
/*	void
**	Set_Ambient_Callback(Widget w, XtPointer cl, XtPointer ca)
**	Sets the ambient light from the dialog shell.
*/
static void
Set_Ambient_Callback(Widget w, XtPointer cl, XtPointer ca)
{
	String	ambient_text;
	double	r, g, b;
	int		num_args;

	XtPopdown(ambient_light_shell);

	ambient_text = XawDialogGetValueString(ambient_dialog);

	num_args = sscanf(ambient_text, "%lf %lf %lf", &r, &g, &b);
	ambient_light.red = (short)(MAX_UNSIGNED_SHORT * r);
	if ( num_args < 2 )
		ambient_light.green = ambient_light.red;
	else
		ambient_light.green = (short)(MAX_UNSIGNED_SHORT * g);
	if ( num_args < 3 )
		ambient_light.blue = ambient_light.red;
	else
		ambient_light.blue = (short)(MAX_UNSIGNED_SHORT * b);

	changed_scene = TRUE;

}
/*ARGSUSED*/
static void
AcceptSaveFile(Widget w, XEvent *e, String *argv, Cardinal *argc)
{
    char    *filename;
    Boolean success;
    Arg	    args[1];

    filename = XawDialogGetValueString (fileDialog);
    success = XawAsciiSaveAsFile (XawTextGetSource (text), filename);
    XtPopdown (fileDialogShell);
    if (!success)
    {
	char	*failMessage;

	XtAsprintf (&failMessage, "Can't open file \"%s\"", filename);
	XtSetArg (args[0], XtNlabel, failMessage);
	XtSetValues (failDialog, args, 1);
	CenterWidgetOnEvent (failDialogShell, e);
	XtPopup (failDialogShell, XtGrabNone);
	XtFree (failMessage);
    }
    else
    {
	if (currentClip->filename)
	    free (currentClip->filename);
	currentClip->filename = malloc (strlen (filename) + 1);
	if (currentClip->filename)
	    strcpy (currentClip->filename, filename);
    }
}
Example #4
0
static
void AcceptAction (Widget widget, XEvent *event,
		   String *params, Cardinal *num_params)
{
    (*promptfunction)(XawDialogGetValueString(promptDialog));
    CancelAction (widget, event, params, num_params);
}
Example #5
0
static void DoSave (Widget w)
	{ char *sname;
	  XtPopdown (save_popup);
	  sname = XawDialogGetValueString (save_dialog);
	  save_unparse_buffer (sname);
	  save_cont ();
	};
Example #6
0
static void doSave (Widget w,
	XtPointer client_data,
	XtPointer callData __attribute__((unused)))
{
  String saveName;
  int    err;
  char	 msg[256];
  
  ViewData *view = client_data;

  saveName = XawDialogGetValueString(XtParent(w));
  strcpy(view->fileName, saveName);
  WriteGridToFile((Grid *)view->grid, view->fileName, &err);
  if (err) {
    sprintf(msg, "Unable to save file %s: C error code %d", saveName, err);
    setMessageLine(msg);
    XtWarning(msg);
  } else {
    XtVaSetValues(XtShell(w), XtNtitle, view->fileName, NULL);
    gridHasChanged = False;
    XtPopdown(saveChangesPopup);
    XtDestroyWidget(saveChangesPopup);
    /* MUST do this, otherwise save dialog loops forever */
    saveChangesPopup = NULL;
  }
}
Example #7
0
void
PopdownDialog(Dialog popup, String *answer)
{
    if (answer)
	*answer = XawDialogGetValueString(popup->dialog_widget);

    XtPopdown(popup->shell_widget);
}
Example #8
0
static void DoLoad ()
	{ char *sname;
	  XtPopdown (load_popup);
	  FinishEditorActions ();
	  sname = XawDialogGetValueString (load_dialog);
	  load_parsebuffer (sname);
	  UpdateEditorWidgets ();
	};
Example #9
0
File: simud.c Project: chinacat/rs
void ShowResProgOK()
{
   char tmpstr[TEMPSTRINGLEN];


   strcpy(tmpstr, XawDialogGetValueString(dialog[11]));
   strcpy(RESNAME, tmpstr);
   ShowResProgCancel();
   ShowResProg0();          /* in simug.c */
}
Example #10
0
/*******************************************************************************
          Name:        IntSave
          Description: Eexecutes CLIPS' bsave, save-facts, or save functions
          Arguments:  w - Dialog Widget
                       client_data - Not Used
                       call_data - Not Used
          Returns:     None
*******************************************************************************/
void IntSave(
  Widget w,
  XtPointer client_data, 
  XtPointer call_data)
  {
  char *filename = XawDialogGetValueString(XtParent(w));

  switch(file_item)
    {
    case SAVEBINARY:
      PrintRouter("wclips", "(bsave ");
      SetCommandString("(bsave");
      AppendCommandString("\"");
      PrintRouter("wclips", "\"");
      AppendCommandString(filename);
      PrintRouter("wclips", filename);
      AppendCommandString("\"");
      PrintRouter("wclips", "\"");
      AppendCommandString(")\n");
      PrintRouter("wclips", ")\n");
      quit_get_event = True;
    break;

    case SAVEFACTS:
      PrintRouter("wclips", "(save-facts ");
      SetCommandString("(save-facts");
      AppendCommandString("\"");
      PrintRouter("wclips", "\"");
      AppendCommandString(filename);
      PrintRouter("wclips", filename);
      AppendCommandString("\"");
      PrintRouter("wclips", "\"");
      AppendCommandString(")\n");
      PrintRouter("wclips", ")\n");
      quit_get_event = True;
    break;

    case SAVERULES:
      PrintRouter("wclips", "(save ");
      SetCommandString("(save");
      AppendCommandString("\"");
      PrintRouter("wclips", "\"");
      AppendCommandString(filename);
      PrintRouter("wclips", filename);
      AppendCommandString("\"");
      PrintRouter("wclips", "\"");
      AppendCommandString(")\n");
      PrintRouter("wclips", ")\n");
      quit_get_event = True;
    break;
    }

  XtDestroyWidget(XtParent(XtParent(w)));
  }
Example #11
0
static void
read_assm_file_action (Widget w, XtPointer client_data, XtPointer call_data)
{
  Widget dialog = (Widget) client_data;
  String value = XawDialogGetValueString (dialog);

  free (program_file_name);
  program_file_name = str_copy (value);
  command_line = program_file_name;
  read_file (program_file_name);

  destroy_popup_prompt (NULL, (XtPointer) dialog, (XtPointer) NULL);
}
Example #12
0
/*******************************************************************************
          Name:        printMatch
          Description: Simulates callbacks for dialog widget
          Arguments:  w - Dialog widget
                       client_data - Dialog widget
                       call_data - Not Used
          Returns:     None
*******************************************************************************/
static void printMatch(
  Widget w,
  XtPointer client_data, 
  XtPointer call_data)
{
  Boolean tempFlag;
  String aString = XawDialogGetValueString(XtParent(w));
  int length = strlen((char*)client_data);

  AppendCommandString(&(aString[length]));
  PrintRouter("stdin",&(aString[length]));
  XtDestroyWidget(XtParent(XtParent(XtParent(w))));
}
Example #13
0
static char *
SearchString(ManpageGlobals * man_globals)
{
    Widget dialog;

    dialog = XtNameToWidget(man_globals->search_widget, DIALOG);
    if (dialog != NULL)
        return (XawDialogGetValueString(dialog));

    PopupWarning(man_globals,
                 "Could not get the search string, no search will be performed.");
    return (NULL);
}
Example #14
0
File: simud.c Project: chinacat/rs
void WriteResProgOK()
{
   char tmpstr[TEMPSTRINGLEN];


   strcpy(tmpstr, XawDialogGetValueString(dialog[10]));
   strcpy(RESNAME, tmpstr);
   WriteResProgCancel();
   strcpy(tmpstr, "(writelpp (residual-program) \"");
   strcat(tmpstr, RESNAME);
   strcat(tmpstr, "\")");
   SendToSimilix(tmpstr);
}
Example #15
0
File: simud.c Project: chinacat/rs
void BindResProgOK()
{
   char tmpstr[TEMPSTRINGLEN];


   strcpy(tmpstr, XawDialogGetValueString(dialog[15]));
   strcpy(VARNAME, tmpstr);

   BindResProgCancel();
   strcpy(tmpstr, "(define ");
   strcat(tmpstr, VARNAME);
   strcat(tmpstr, " (residual-program))");
   SendToSimilix(tmpstr);
}
Example #16
0
static void
delete_breakpoint_action (Widget w, XtPointer client_data, XtPointer call_data)
{
  Widget dialog = (Widget) client_data;
  String value = XawDialogGetValueString (dialog);
  mem_addr addr;

  free (breakpoint_addr);
  breakpoint_addr = str_copy (value);
  addr = strtoul (value, NULL, 0);

  delete_breakpoint (addr);

  destroy_popup_prompt (NULL, (XtPointer) dialog, (XtPointer) NULL);
}
Example #17
0
static void
add_breakpoint_action (Widget w, XtPointer client_data, XtPointer call_data)
{
  Widget dialog = (Widget) client_data;
  String value = XawDialogGetValueString (dialog);
  mem_addr addr;

  free (breakpoint_addr);
  breakpoint_addr = str_copy (value);

  while (*breakpoint_addr == ' ') breakpoint_addr++;
  if (isdigit (*breakpoint_addr))
    addr = strtoul (value, NULL, 0);
  else
    addr = find_symbol_address (breakpoint_addr);

  add_breakpoint (addr);

  destroy_popup_prompt (NULL, (XtPointer) dialog, (XtPointer) NULL);
}
Example #18
0
/*******************************************************************************
          Name:        printMatchForTextEdit
          Description: Simulates callbacks for dialog widget
          Arguments:  w - Dialog widget
                       client_data - Dialog widget
                       call_data - Not Used
          Returns:     None
*******************************************************************************/
static void printMatchForTextEdit(
  Widget w,
  XtPointer client_data, 
  XtPointer call_data)
{
  XawTextBlock text;
  String aString = XawDialogGetValueString(XtParent(w));
  Widget text_widget = (Widget)client_data;
  int length;

  length = strlen(completionString);
  text.firstPos = 0;
  text.length  = strlen(&(aString[length]));
  text.ptr  = &(aString[length]);
  XawTextReplace(text_widget,
                 XawTextGetInsertionPoint(text_widget),
                 XawTextGetInsertionPoint(text_widget),&text);
  XawTextSetInsertionPoint(text_widget,
                     XawTextGetInsertionPoint(text_widget) + text.length);
  XtDestroyWidget(XtParent(XtParent(XtParent(w))));
}
Example #19
0
File: em_menu.c Project: Exim/exim
XtActionProc dialogAction(Widget w, XEvent *event, String *ss, Cardinal *c)
{
uschar *s = US XawDialogGetValueString(dialog_widget);

w = w;      /* Keep picky compilers happy */
event = event;
ss = ss;
c = c;

XtPopdown((Widget)dialog_shell);
XtDestroyWidget((Widget)dialog_shell);
while (isspace(*s)) s++;
if (s[0] != 0)
  {
  if (actioned_message[0] != 0)
    ActOnMessage(actioned_message, action_required, s);
  else
    NonMessageDialogue(s);    /* When called from somewhere else */
  }
return NULL;
}
Example #20
0
/* Callback for "OK" button on trace popup */
static void
tracefile_callback(Widget w, XtPointer client_data, XtPointer call_data _is_unused)
{
	char *tfn = CN;
	int devfd = -1;
#if defined(X3270_DISPLAY) /*[*/
	int pipefd[2];
	Boolean just_piped = False;
#endif /*]*/
	char *buf;

#if defined(X3270_DISPLAY) /*[*/
	if (w)
		tfn = XawDialogGetValueString((Widget)client_data);
	else
#endif /*]*/
		tfn = (char *)client_data;
	tfn = do_subst(tfn, DS_VARS | DS_TILDE | DS_UNIQUE);
	if (strchr(tfn, '\'') ||
	    ((int)strlen(tfn) > 0 && tfn[strlen(tfn)-1] == '\\')) {
		popup_an_error("Illegal file name: %s", tfn);
		Free(tfn);
		goto done;
	}

	tracef_max = 0;

	if (!strcmp(tfn, "stdout")) {
		tracef = stdout;
	} else {
#if defined(X3270_DISPLAY) /*[*/
		FILE *pipefile = NULL;

		if (!strcmp(tfn, "none") || !tfn[0]) {
			just_piped = True;
			if (!appres.trace_monitor) {
				popup_an_error("Must specify a trace file "
				    "name");
				free(tfn);
				goto done;
			}
		}

		if (appres.trace_monitor) {
			if (pipe(pipefd) < 0) {
				popup_an_errno(errno, "pipe() failed");
				Free(tfn);
				goto done;
			}
			pipefile = fdopen(pipefd[1], "w");
			if (pipefile == NULL) {
				popup_an_errno(errno, "fdopen() failed");
				(void) close(pipefd[0]);
				(void) close(pipefd[1]);
				Free(tfn);
				goto done;
			}
			(void) SETLINEBUF(pipefile);
			(void) fcntl(pipefd[1], F_SETFD, 1);
		}

		if (just_piped) {
			tracef = pipefile;
		} else
#endif /*]*/
		{
		    	Boolean append = False;

#if defined(X3270_DISPLAY) /*[*/
			tracef_pipe = pipefile;
#endif /*]*/
			/* Get the trace file maximum. */
			get_tracef_max();

			/* Open and configure the file. */
			if ((devfd = get_devfd(tfn)) >= 0)
				tracef = fdopen(dup(devfd), "a");
			else if (!strncmp(tfn, ">>", 2)) {
			    	append = True;
				tracef = fopen(tfn + 2, "a");
			} else
				tracef = fopen(tfn, "w");
			if (tracef == (FILE *)NULL) {
				popup_an_errno(errno, "%s", tfn);
#if defined(X3270_DISPLAY) /*[*/
				fclose(tracef_pipe);
				(void) close(pipefd[0]);
				(void) close(pipefd[1]);
#endif /*]*/
				Free(tfn);
				goto done;
			}
			tracef_size = ftello(tracef);
			Replace(tracefile_name,
				NewString(append? tfn + 2: tfn));
			(void) SETLINEBUF(tracef);
#if !defined(_WIN32) /*[*/
			(void) fcntl(fileno(tracef), F_SETFD, 1);
#endif /*]*/
		}
	}

#if defined(X3270_DISPLAY) /*[*/
	/* Start the monitor window */
	if (tracef != stdout && appres.trace_monitor) {
		switch (tracewindow_pid = fork_child()) {
		    case 0:	/* child process */
			{
				char cmd[64];

				(void) snprintf(cmd, sizeof(cmd), "cat <&%d",
					pipefd[0]);
				(void) execlp("xterm", "xterm",
				    "-title", just_piped? "trace": tfn,
				    "-sb", "-e", "/bin/sh", "-c",
				    cmd, CN);
			}
			(void) perror("exec(xterm) failed");
			_exit(1);
		    default:	/* parent */
			(void) close(pipefd[0]);
			++children;
			break;
		    case -1:	/* error */
			popup_an_errno(errno, "fork() failed");
			break;
		}
	}
#endif /*]*/

#if defined(_WIN32) && defined(C3270) /*[*/
	/* Start the monitor window. */
	if (tracef != stdout && appres.trace_monitor && is_installed) {
		STARTUPINFO startupinfo;
		PROCESS_INFORMATION process_information;
		char *path;
		char *args;

	    	(void) memset(&startupinfo, '\0', sizeof(STARTUPINFO));
		startupinfo.cb = sizeof(STARTUPINFO);
		startupinfo.lpTitle = tfn;
		(void) memset(&process_information, '\0',
			      sizeof(PROCESS_INFORMATION));
		path = xs_buffer("%scatf.exe", instdir);
		args = xs_buffer("\"%scatf.exe\" \"%s\"", instdir, tfn);
		if (CreateProcess(
		    path,
		    args,
		    NULL,
		    NULL,
		    FALSE,
		    CREATE_NEW_CONSOLE,
		    NULL,
		    NULL,
		    &startupinfo,
		    &process_information) == 0) {
		    	popup_an_error("CreateProcess(%s) failed: %s",
				path, win32_strerror(GetLastError()));
			Free(path);
			Free(args);
		} else {
			Free(path);
		    	Free(args);
			tracewindow_handle = process_information.hProcess;
			CloseHandle(process_information.hThread);
		}
	}
#endif /*]*/

	Free(tfn);

	/* We're really tracing, turn the flag on. */
	appres.toggle[trace_reason].value = True;
	appres.toggle[trace_reason].changed = True;
	menubar_retoggle(&appres.toggle[trace_reason], trace_reason);

	/* Display current status. */
	buf = create_tracefile_header("started");
	do_ts = False;
	wtrace("%s", buf);
	Free(buf);

done:
#if defined(X3270_DISPLAY) /*[*/
	if (w)
		XtPopdown(trace_shell);
#endif /*]*/
	return;
}