Exemple #1
0
void domain_menu_init(
  Widget	topl)
{
  Widget	form, file_type_menu, toggle, widget;
  XmString	xmstr;
  Visual	*visual;
  Arg		arg[1];

  /* initialise the globals */
  globals.dmnList = HGUDlpListCreate(NULL);
  globals.currDmnListItem = NULL;
  globals.smoothItr = 1;

  /* get the visual explicitly */
  visual = HGU_XmWidgetToVisual(topl);
  XtSetArg(arg[0], XmNvisual, visual);

  /* create the read domain dialog */
  read_domain_dialog =
    XmCreateFileSelectionDialog(topl,
				"read_domain_dialog", arg, 1);

  /* add the callbacks */
  XtAddCallback(read_domain_dialog, XmNcancelCallback, PopdownCallback, NULL);
  XtManageChild(read_domain_dialog );

  /* add to the save restore list */
  HGU_XmSaveRestoreAddWidget( read_domain_dialog, HGU_XmFSD_SaveFunc,
			     (XtPointer) XtName(topl), NULL, NULL );

  /* create the write domain dialog */
  write_domain_dialog =
    XmCreateFileSelectionDialog(topl,
				"write_domain_dialog", arg, 1);

  /* add the callbacks */
  XtAddCallback(write_domain_dialog, XmNokCallback,
		writeDomainFileCb, (XtPointer) WLZEFF_FORMAT_WLZ);
  XtAddCallback(write_domain_dialog, XmNokCallback, PopdownCallback, NULL);
  XtAddCallback(write_domain_dialog, XmNcancelCallback, PopdownCallback, NULL);
  XtManageChild( write_domain_dialog );

  /* add to the save restore list */
  HGU_XmSaveRestoreAddWidget( write_domain_dialog, HGU_XmFSD_SaveFunc,
			     (XtPointer) XtName(topl), NULL, NULL );

  return;
}
Exemple #2
0
/*
 * Create the wparam Frame and the wparam Panel
 */
void create_wparam_frame(Widget, XtPointer, XtPointer)
{
    Widget fr;

    set_wait_cursor();
    if (wparam_frame == NULL)
    {
        wparam_frame = XmCreateFileSelectionDialog(app_shell, (char *)"wparam_frame", NULL, 0);
        XtVaSetValues(XtParent(wparam_frame), XmNtitle, "Write plot parameters", NULL);
        XtAddCallback(wparam_frame, XmNcancelCallback, (XtCallbackProc)destroy_dialog, wparam_frame);
        XtAddCallback(wparam_frame, XmNokCallback, (XtCallbackProc)wparam_apply_notify_proc, 0);

        /* may not be needed
         handle_close(wparam_frame);
      */

        fr = XmCreateFrame(wparam_frame, (char *)"fr", NULL, 0);
        wparam_panel = XmCreateRowColumn(fr, (char *)"wparam_rc", NULL, 0);
        wparam_choice_item = CreateGraphChoice(wparam_panel, "Write parameters from graph: ", maxgraph, 2);

        XtManageChild(fr);
        XtManageChild(wparam_panel);
    }
    XtRaise(wparam_frame);
    unset_wait_cursor();
}
Exemple #3
0
static void
BrowseCallback(Widget w, XtPointer client_data, XtPointer call_data)
{
#ifdef DEBUG
    printf("%s:BrowseCallback(%d) - %s\n", __FILE__, __LINE__, XtName(w));
#endif
    if (FilePicker_FileSelectionDialog(XtParent(w)) == NULL)
    {
#ifdef DEBUG
	printf("%s:BrowseCallback(%d) - %s creating FSB\n", __FILE__, __LINE__, XtName(w));
#endif
    	if (FilePickerClass_FileSelectionDialog(XtParent(w)) == NULL)
    	{
    	Widget Shell = XtParent(w);

#ifdef DEBUG
	    printf("%s:BrowseCallback(%d) - %s creating class FSB\n", __FILE__, __LINE__, XtName(w));
#endif
	    while (!XtIsShell(Shell)) Shell = XtParent(Shell);
	    FilePickerClass_FileSelectionDialog(XtParent(w)) = XmCreateFileSelectionDialog(Shell, "FilePickerDialog", NULL, 0);
    	}
    	FilePicker_FileSelectionDialog(XtParent(w)) = FilePickerClass_FileSelectionDialog(XtParent(w));
    }
    XtRemoveAllCallbacks(FilePicker_FileSelectionDialog(XtParent(w)), XmNokCallback);
    XtRemoveAllCallbacks(FilePicker_FileSelectionDialog(XtParent(w)), XmNcancelCallback);
    XtAddCallback(FilePicker_FileSelectionDialog(XtParent(w)), XmNokCallback, (XtCallbackProc)BrowseOkCallback, XtParent(w));
    XtAddCallback(FilePicker_FileSelectionDialog(XtParent(w)), XmNcancelCallback, (XtCallbackProc)XtUnmanageChild, NULL);
    XtManageChild(FilePicker_FileSelectionDialog(XtParent(w)));
}
Exemple #4
0
Widget
XsraSelFile(Widget parent, struct filesel_callback *callback)
{
    Widget dialog = XmCreateFileSelectionDialog(parent, "file", NULL, 0);

    XtVaSetValues(XtParent(dialog), XmNtitle, callback->title, NULL);

    XtAddCallback(dialog, XmNokCallback, accept_callback, (XtPointer)callback);
    XtAddCallback(dialog, XmNcancelCallback, cancel_callback, (XtPointer)callback);

    /* When opening a DVI file, offer to open in new window */
    if (callback->must_exist) {
        Widget form, button;
        XmString test;
        form = XtVaCreateManagedWidget("new_window_form", xmFormWidgetClass, dialog, NULL);
        test = XmStringCreateLocalized("Open file in new window");
        button = XtVaCreateManagedWidget(Xdvi_NEW_WINDOW_RADIO_NAME, xmToggleButtonGadgetClass, form,
                                         XmNlabelString, test,
                                         XmNindicatorType, XmN_OF_MANY,
                                         XmNset, resource.filesel_open_new_window,
                                         NULL);
        XmStringFree(test);
        XtAddCallback(button, XmNvalueChangedCallback, cb_open_new_window, (XtPointer)NULL);
    }


    /* We have no help in this window, so hide help button */
    XtUnmanageChild(XmFileSelectionBoxGetChild(dialog, (unsigned char)XmDIALOG_HELP_BUTTON));

    return dialog;
}
Exemple #5
0
void create_savefit_popup(Widget w, XtPointer client_data, XtPointer call_data)
{
    Widget fr, dialog;
    XmString dirmask;
    
    set_wait_cursor();
    
    if (savefit_dialog == NULL) {
	savefit_dialog = XmCreateFileSelectionDialog(app_shell, "savefit_dialog", NULL, 0);
	XtVaSetValues(XtParent(savefit_dialog), XmNtitle, "Save fit parameter file", NULL);
	XtAddCallback(savefit_dialog, XmNcancelCallback, (XtCallbackProc) destroy_dialog, savefit_dialog);
	XtAddCallback(savefit_dialog, XmNokCallback, (XtCallbackProc) do_savefit_proc, 0);
	XtAddCallback(savefit_dialog, XmNhelpCallback, (XtCallbackProc) HelpCB, 
	              (XtPointer) NULL);
	fr = XmCreateFrame(savefit_dialog, "fr", NULL, 0);
	dialog = XmCreateRowColumn(fr, "dialog_rc", NULL, 0);

	save_title_item = CreateTextItem2(dialog, 25, "Title: ");

	XtManageChild(dialog);
	XtManageChild(fr);
    }
    
    XtManageChild(savefit_dialog);
    XtRaise(XtParent(savefit_dialog));
    
    xv_setstr(save_title_item, nonl_opts.title);

    dirmask = XmStringCreateSimple(workingdir);
    XmFileSelectionDoSearch(savefit_dialog, dirmask);
    XmStringFree(dirmask);

    unset_wait_cursor();
}
void LoadData()
{
    static Widget dialog = NULL;
    
   /*
    * Create a file selection dialog if it doesnÕt already exist
    */

    if ( !dialog )
    {
        dialog = XmCreateFileSelectionDialog (  canvas, 
                                               "loadDialog",
                                                NULL, 0 );
        XtAddCallback ( dialog, XmNokCallback, 
                        LoadDataCallback,  ( XtPointer ) NULL );
        XtAddCallback ( dialog, XmNcancelCallback, 
                        CancelDialogCallback,  ( XtPointer ) NULL );
    }
    
   /*
    * Display the dialog
    */

    XtManageChild ( dialog );
}
/* button callbacks */
void PosFileButCB (Widget w, XtPointer clientData, XtPointer callData)
/* File button hit - get info from a file */
{
  ImageDisplay *IDdata;
  XmString     wierdstring;
  Arg          wargs[5]; 

  IDdata = (ImageDisplay *)clientData;

  mark.posfilebox = (Widget) XmCreateFileSelectionDialog (w, "filebox", 
							  NULL, 0);
  XtAddCallback (mark.posfilebox, XmNokCallback, PosFileOKCB, clientData);
  XtAddCallback (mark.posfilebox, XmNcancelCallback, PosFileCancelCB, 
		 clientData);

/* set directory if it is defined */
  if (mark_dir) {
    wierdstring = XmStringCreateSimple (mark_dir->sp);
    XtSetArg (wargs[0], XmNdirectory, wierdstring);
    XtSetValues (mark.posfilebox, wargs, 1);
    XmStringFree(wierdstring);
  }
/* Shazam appear: */
  XtManageChild (mark.posfilebox);
  XtPopup (XtParent (mark.posfilebox), XtGrabNone);
/* all the action is in the callback routine */

/*  XtDestroyWidget (mark.dialog); */
/*  PositionBoxActive = 0;  mark as inactive */
} /* end PosFileButCB */
Exemple #8
0
static void ExportPlotCB(Widget w, XtPointer client_data, XtPointer call_data)
{
    SelectPlotCB(w, client_data, call_data);

    PlotWindowInfo *plot = (PlotWindowInfo *)client_data;

    if (plot->export_dialog == 0)
    {
	Arg args[10];
	Cardinal arg = 0;
	Widget dialog = 
	    verify(XmCreateFileSelectionDialog(plot->shell, 
					       XMST("export_data"), 
					       args, arg));
	plot->export_dialog = dialog;

	Delay::register_shell(dialog);
	XtAddCallback(dialog, XmNokCallback, DoExportCB, client_data);
	XtAddCallback(dialog, XmNcancelCallback, UnmanageThisCB, 
		      XtPointer(dialog));
	XtAddCallback(dialog, XmNhelpCallback, ImmediateHelpCB, XtPointer(0));
    }

    manage_and_raise(plot->export_dialog);
}
Exemple #9
0
void CoWowMotif::CreateFileSelDia( const char *title, void *parent_ctx,
				   void (*file_selected_cb)(void *, char *, wow_eFileSelType),
				   wow_eFileSelType file_type)
{
  Arg args[10];
  XmString ctitle, cdirectory, cpattern;
  char directory[200];
  int i;
  wow_tFileSelCtx ctx;
  Widget help;

  ctx = (wow_tFileSelCtx) calloc( 1, sizeof(*ctx));
  ctx->file_selected_cb = file_selected_cb;
  ctx->parent_ctx = parent_ctx;
  ctx->file_type = file_type;

  ctitle = XmStringCreateLtoR( (char*) title, XmSTRING_DEFAULT_CHARSET);    

  i = 0;
  XtSetArg( args[i], XmNdialogTitle, ctitle); i++;
  XtSetArg( args[i], XmNfileTypeMask, XmFILE_REGULAR); i++;
  XtSetArg( args[i], XmNfileSearchProc, file_search_cb); i++;

  switch( file_type) {
  case wow_eFileSelType_All:
    break;
  case wow_eFileSelType_Dbs:
    dcli_translate_filename( directory, "$pwrp_load/");
    cdirectory = XmStringCreateLtoR( directory, XmSTRING_DEFAULT_CHARSET);
    cpattern = XmStringCreateLtoR( (char*) "*.dbs", XmSTRING_DEFAULT_CHARSET);
    XtSetArg( args[i], XmNdirectory, cdirectory); i++;
    XtSetArg( args[i], XmNpattern, cpattern); i++;
    break;
  case wow_eFileSelType_Wbl:
  case wow_eFileSelType_WblClass:
    dcli_translate_filename( directory, "$pwrp_db/");
    cdirectory = XmStringCreateLtoR( directory, XmSTRING_DEFAULT_CHARSET);
    cpattern = XmStringCreateLtoR( (char*) "*.wb_load", XmSTRING_DEFAULT_CHARSET);
    XtSetArg( args[i], XmNdirectory, cdirectory); i++;
    XtSetArg( args[i], XmNpattern, cpattern); i++;
    break;
  default: ;
  }

  ctx->dialog = XmCreateFileSelectionDialog( m_parent, (char*) "fileseldia", args, i);
  XtAddCallback( ctx->dialog, XmNokCallback, file_ok_cb, ctx);
  XtAddCallback( ctx->dialog, XmNcancelCallback, file_cancel_cb, ctx);

  help = XmFileSelectionBoxGetChild( ctx->dialog, XmDIALOG_HELP_BUTTON);
  XtUnmanageChild( help);
  XtManageChild( ctx->dialog);

  XmStringFree( ctitle);
  XmStringFree( cdirectory);
  XmStringFree( cpattern);
}
// Create a file dialog NAME with DO_SEARCH_FILES and DO_SEARCH_DIRS
// as search procedures for files and directories, respectively, and
// OK_CALLBACK as the procedure called when a file is selected.
static Widget file_dialog(Widget w, const string& name,
			  FileSearchProc do_search_files = 0,
			  FileSearchProc do_search_dirs  = 0,
			  XtCallbackProc ok_callback     = 0)
{
    Delay delay(w);

    Arg args[10];
    int arg = 0;

    string pwd;

    arg = 0;
    if (do_search_files)
    {
	XtSetArg(args[arg], XmNfileSearchProc, do_search_files); arg++;
    }
    if (do_search_dirs)
    {
	XtSetArg(args[arg], XmNdirSearchProc, do_search_dirs); arg++;
    }

    if (remote_gdb())
    {
	static MString xmpwd;
	xmpwd = source_view->pwd();
	XtSetArg(args[arg], XmNdirectory, xmpwd.xmstring()); arg++;
    }

    Widget dialog = 
	verify(XmCreateFileSelectionDialog(w, XMST(name.chars()), args, arg));
    Delay::register_shell(dialog);

    if (ok_callback != 0)
	XtAddCallback(dialog, XmNokCallback,     ok_callback, 0);

    XtAddCallback(dialog, XmNcancelCallback, UnmanageThisCB, 
		  XtPointer(dialog));
    XtAddCallback(dialog, XmNhelpCallback,   ImmediateHelpCB, 0);

    Widget filter = XmFileSelectionBoxGetChild(dialog, XmDIALOG_FILTER_TEXT);
    file_filters += filter;
    if (!current_file_filter.empty())
	XmTextSetString(filter, XMST(current_file_filter.chars()));
    XtAddCallback(filter, XmNvalueChangedCallback, SyncFiltersCB, 0);

    Widget filter_button = 
	XmFileSelectionBoxGetChild(dialog, XmDIALOG_APPLY_BUTTON);
    XtAddCallback(filter_button, XmNactivateCallback, FilterAllCB, 0);
    XtAddCallback(dialog, XmNunmapCallback, ClearStatusCB, 0);

    file_dialogs += dialog;

    return dialog;
}
Exemple #11
0
Fichier : ssX.c Projet : q3k/ski
static void loadCallback(CALLBACK_ARGS)
{
    static Widget fsd = NULL;

    if (!fsd) {
	fsd = XmCreateFileSelectionDialog(cmd, "loadFSD", NULL, 0);
	XtAddCallback(fsd, XmNokCallback, loadOkCallback, fsd);
	XtManageChild(XmCreateToggleButton(fsd, "load_syms", NULL, 0));
    }
    XtManageChild(fsd);
}
Exemple #12
0
void CtrlBox(int argc,  char **argv) {
	XtAppContext app;
       	Widget 	toplevel, box, temp;
       	Widget   buttons[10];
       	int  	nbuttons;
        char*	exitPoint = names[EXIT_PROGRAM];
	if (argc > 1) {
		argv[0] = "Remote";
		if (argc > 2) exitPoint = "Back to PC desktop    ";
	}
	else argv[0] = "Local";
       	argc = 1;

       	toplevel =  XtVaAppInitialize(&app,"CtrlBox",NULL, 0, &argc, argv, NULL, NULL);

       	box = XtVaCreateManagedWidget("box",xmRowColumnWidgetClass, toplevel, NULL);

       	nbuttons = 0;
       	while(names[nbuttons] != 0) {
		if (nbuttons == EXIT_PROGRAM )
		buttons[nbuttons] = XtVaCreateManagedWidget(exitPoint,
                        xmPushButtonWidgetClass, box, NULL, 0);
		else
		buttons[nbuttons] = XtVaCreateManagedWidget(names[nbuttons],
			xmPushButtonWidgetClass, box, NULL, 0);
		XtAddCallback(buttons[nbuttons],XmNactivateCallback, callback,
			&values[nbuttons]);
	    nbuttons++;
	}

	// Create a popup error message dialog; no cancel, no help button 
	errorDialog = XmCreateErrorDialog(box, "errorDialog", NULL, 0);
	temp = XmMessageBoxGetChild(errorDialog, XmDIALOG_CANCEL_BUTTON);
	XtUnmanageChild(temp);
	temp = XmMessageBoxGetChild(errorDialog, XmDIALOG_HELP_BUTTON);
	XtUnmanageChild(temp);

	// Create a popup dialog to get the filename; no help button 
	fileDialog = XmCreateFileSelectionDialog(box, "fileDialog", NULL, 0);
	XtVaSetValues(fileDialog, XmNwidth, 400, NULL);
  	temp = XmFileSelectionBoxGetChild(fileDialog, XmDIALOG_HELP_BUTTON);
  	XtUnmanageChild(temp);

  	XtAddCallback(fileDialog, XmNokCallback, OpenFile, NULL);
	XtAddCallback(fileDialog, XmNcancelCallback, Cancel, NULL);

	XtManageChildren(buttons,nbuttons);
	XtRealizeWidget(toplevel);
        XMoveWindow (XtDisplay(toplevel), XtWindow(toplevel), 0, 0);
	XWarpPointer(XtDisplay(box), None, XtWindow(box), 0, 0, 0, 0, 400, 300);
	XtAppMainLoop(app);
}
Exemple #13
0
void create_rparams_popup(Widget, XtPointer, XtPointer)
{
    set_wait_cursor();
    if (rparams_dialog == NULL)
    {
        rparams_dialog = XmCreateFileSelectionDialog(app_shell, (char *)"rparams_dialog", NULL, 0);
        XtVaSetValues(XtParent(rparams_dialog), XmNtitle, "Read parameters", NULL);
        XtAddCallback(rparams_dialog, XmNcancelCallback, (XtCallbackProc)destroy_dialog, rparams_dialog);
        XtAddCallback(rparams_dialog, XmNokCallback, (XtCallbackProc)do_rparams_proc, 0);
    }
    XtRaise(rparams_dialog);
    unset_wait_cursor();
}
Exemple #14
0
void create_hotfiles_popup(Widget, XtPointer, XtPointer)
{
    static Widget top;

    set_wait_cursor();
    if (top == NULL)
    {
        top = XmCreateFileSelectionDialog(app_shell, (char *)"hotlinks", NULL, 0);
        XtVaSetValues(XtParent(top), XmNtitle, "Select hot link file", NULL);

        XtAddCallback(top, XmNokCallback, (XtCallbackProc)do_hotlinkfile_proc, (XtPointer)top);
        XtAddCallback(top, XmNcancelCallback, (XtCallbackProc)destroy_dialog, (XtPointer)top);
    }
    XtRaise(top);
    unset_wait_cursor();
}
Exemple #15
0
void create_netcdffiles_popup(Widget, XtPointer, XtPointer)
{
    int x, y;
    static Widget top;
    Widget dialog;
    Widget wbut, rc, fr;
    Arg args[2];

    set_wait_cursor();
    if (top == NULL)
    {
        top = XmCreateFileSelectionDialog(app_shell, "netcdfs", NULL, 0);
        XtVaSetValues(XtParent(top), XmNtitle, "Select netCDF file", NULL);

        XtAddCallback(top, XmNokCallback, (XtCallbackProc)do_netcdffile_proc, (XtPointer)top);
        XtAddCallback(top, XmNcancelCallback, (XtCallbackProc)destroy_dialog, (XtPointer)top);
    }
    XtRaise(top);
    unset_wait_cursor();
}
Exemple #16
0
void create_workingdir_popup(Widget w, XtPointer, XtPointer)
{
    XmString str;

    set_wait_cursor();
    if (workingd_dialog == NULL)
    {
        workingd_dialog = XmCreateFileSelectionDialog(app_shell, (char *)"workingd_dialog", NULL, 0);
        XtVaSetValues(XtParent(workingd_dialog), XmNtitle, "Set working directory", NULL);
        XtAddCallback(workingd_dialog, XmNcancelCallback, (XtCallbackProc)destroy_dialog, (XtPointer)workingd_dialog);
        XtAddCallback(workingd_dialog, XmNokCallback, (XtCallbackProc)workingdir_apply_notify_proc, (XtPointer)0);

        /* unmanage unneeded items */
        w = XmFileSelectionBoxGetChild(workingd_dialog, XmDIALOG_LIST);
        XtUnmanageChild(XtParent(w));
        w = XmFileSelectionBoxGetChild(workingd_dialog, XmDIALOG_LIST_LABEL);
        XtUnmanageChild(w);
        w = XmFileSelectionBoxGetChild(workingd_dialog, XmDIALOG_FILTER_LABEL);
        XtUnmanageChild(w);
        w = XmFileSelectionBoxGetChild(workingd_dialog, XmDIALOG_FILTER_TEXT);
        XtUnmanageChild(w);
        w = XmFileSelectionBoxGetChild(workingd_dialog, XmDIALOG_APPLY_BUTTON);
        XtUnmanageChild(w);

        /* save the name of the text item used for definition */
        dir_item = XmFileSelectionBoxGetChild(workingd_dialog, XmDIALOG_TEXT);

        /* Add a callback to the dir list */
        w = XmFileSelectionBoxGetChild(workingd_dialog, XmDIALOG_DIR_LIST);
        XtAddCallback(w, XmNsingleSelectionCallback, (XtCallbackProc)select_dir, (XtPointer)0);
        XtVaSetValues(w, XmNselectionPolicy, XmSINGLE_SELECT, NULL);
    }
    xv_setstr(dir_item, workingdir);
    XtVaSetValues(workingd_dialog, XmNdirectory,
                  str = XmStringCreateLtoR(workingdir, charset), NULL);
    XmFileSelectionDoSearch(workingd_dialog, NULL);
    XmStringFree(str);
    XtRaise(workingd_dialog);
    unset_wait_cursor();
}
Exemple #17
0
void text_save(Widget w, XtPointer client_data, XtPointer call_data)
{
    Widget   child;
    char     *ptr, bufr[256], nam1[256];
    XmString namx;

    if (!savetextdialog) {
        savetextdialog = XmCreateFileSelectionDialog(GetTopShell(w), "textfile", NULL, 0);
        /* Get rid of Help button */
        XtUnmanageChild(XmSelectionBoxGetChild(savetextdialog, XmDIALOG_HELP_BUTTON));
        XtAddCallback(savetextdialog, XmNokCallback, get_textfile, NULL);
        XtAddCallback(savetextdialog, XmNcancelCallback, (XtCallbackProc)XtUnmanageChild, NULL);

        child = XmFileSelectionBoxGetChild(savetextdialog, XmDIALOG_TEXT);
        XtVaGetValues(child, XmNvalue, &ptr, NULL);
    }
    namx = XmStringCreateLocalized(raobsavefilename);
    printf( "Setting Default Output File Name = %s\n", raobsavefilename);
    XtVaSetValues( savetextdialog, XmNdirSpec, namx);

    XtManageChild(savetextdialog);
    XtPopup(XtParent(savetextdialog), XtGrabNone);
}
Exemple #18
0
void getbdffn(Exc_data * ed)
{
    Widget	filesb;
    Arg		args[20];
    Cardinal	n;
    char	*selectlabel;
    XmString	xms;

    selectlabel = GETMESSAGE(2, 2, "BDF file selection");
    n = 0;
    XtSetArg(args[n], XmNtitle, maintitle); n++;
    xms = XmStringCreateLocalized(selectlabel);
    XtSetArg(args[n], XmNselectionLabelString, xms); n++;
    filesb = XmCreateFileSelectionDialog(ed->toplevel, "filesb", args, n);
    XtAddCallback(filesb, XmNokCallback,
		  (XtCallbackProc) filesbokCB,
		  (XtPointer) ed);
    XtAddCallback(filesb, XmNcancelCallback,
		  (XtCallbackProc) filesbcancelCB,
		  (XtPointer) ed);
    XtUnmanageChild(XmFileSelectionBoxGetChild(filesb, XmDIALOG_HELP_BUTTON));
    XtManageChild(filesb);
}
Exemple #19
0
void create_openfit_popup(Widget w, XtPointer client_data, XtPointer call_data)
{
    XmString dirmask;
    
    set_wait_cursor();
    
    if (openfit_dialog == NULL) {
	openfit_dialog = XmCreateFileSelectionDialog(app_shell, "openfit_dialog", NULL, 0);
	XtVaSetValues(XtParent(openfit_dialog), XmNtitle, "Open fit parameter file", NULL);
	XtAddCallback(openfit_dialog, XmNcancelCallback, (XtCallbackProc) destroy_dialog, openfit_dialog);
	XtAddCallback(openfit_dialog, XmNokCallback, (XtCallbackProc) do_openfit_proc, 0);
	XtAddCallback(openfit_dialog, XmNhelpCallback, (XtCallbackProc) HelpCB, 
	              (XtPointer) NULL);
    }
    
    XtManageChild(openfit_dialog);
    XtRaise(XtParent(openfit_dialog));

    dirmask = XmStringCreateSimple(workingdir);
    XmFileSelectionDoSearch(openfit_dialog, dirmask);
    XmStringFree(dirmask);

    unset_wait_cursor();
}
void SaveData()
{
    FILE  *fp;
    static Widget dialog = NULL;
        
   /*
    * Create the dialog if it doesnÕt already exist. Install
    * callbacks for OK and Cancel actions.
    */

    if ( !dialog )
    {
         dialog = XmCreateFileSelectionDialog ( canvas, "saveDialog",
                                                NULL, 0 );

         XtAddCallback ( dialog, XmNokCallback,
                         SaveDataCallback,  ( XtPointer ) NULL );
         XtAddCallback ( dialog, XmNcancelCallback,
                         CancelDialogCallback,  ( XtPointer ) NULL );
     }
        
     XtManageChild ( dialog );

 }
Exemple #21
0
int wxFileDialog::ShowModal()
{
    wxBeginBusyCursor();

    //  static char fileBuf[512];
    Widget parentWidget = (Widget) 0;
    if (m_parent)
        parentWidget = (Widget) m_parent->GetTopWidget();
    else
        parentWidget = (Widget) wxTheApp->GetTopLevelWidget();
    // prepare the arg list
    Display* dpy = XtDisplay(parentWidget);
    Arg args[10];
    int ac = 0;

    if (m_backgroundColour.IsOk())
    {
        wxComputeColours (dpy, & m_backgroundColour, NULL);

        XtSetArg(args[ac], XmNbackground, g_itemColors[wxBACK_INDEX].pixel); ac++;
        XtSetArg(args[ac], XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel); ac++;
        XtSetArg(args[ac], XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel); ac++;
        XtSetArg(args[ac], XmNforeground, g_itemColors[wxFORE_INDEX].pixel); ac++;
    }

    wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);

#if __WXMOTIF20__ && !__WXLESSTIF__
    XtSetArg(args[ac], XmNbuttonRenderTable, font.GetFontTypeC(dpy)); ac++;
    XtSetArg(args[ac], XmNlabelRenderTable, font.GetFontTypeC(dpy)); ac++;
    XtSetArg(args[ac], XmNtextRenderTable, font.GetFontTypeC(dpy)); ac++;
#else
    XtSetArg(args[ac], XmNbuttonFontList, font.GetFontTypeC(dpy)); ac++;
    XtSetArg(args[ac], XmNlabelFontList, font.GetFontTypeC(dpy)); ac++;
    XtSetArg(args[ac], XmNtextFontList, font.GetFontTypeC(dpy)); ac++;
#endif

    Widget fileSel = XmCreateFileSelectionDialog(parentWidget,
                                                 wxMOTIF_STR("file_selector"),
                                                 args, ac);
#define wxFSChild( name ) \
    XmFileSelectionBoxGetChild(fileSel, name)

    XtUnmanageChild(wxFSChild(XmDIALOG_HELP_BUTTON));

    Widget filterWidget = wxFSChild(XmDIALOG_FILTER_TEXT);
    Widget selectionWidget = wxFSChild(XmDIALOG_TEXT);
    Widget dirListWidget = wxFSChild(XmDIALOG_DIR_LIST);
    Widget fileListWidget = wxFSChild(XmDIALOG_LIST);

    // for changing labels
    Widget okWidget = wxFSChild(XmDIALOG_OK_BUTTON);
    Widget applyWidget = wxFSChild(XmDIALOG_APPLY_BUTTON);
    Widget cancelWidget = wxFSChild(XmDIALOG_CANCEL_BUTTON);
    Widget dirlistLabel = wxFSChild(XmDIALOG_DIR_LIST_LABEL);
    Widget filterLabel = wxFSChild(XmDIALOG_FILTER_LABEL);
    Widget listLabel = wxFSChild(XmDIALOG_LIST_LABEL);
    Widget selectionLabel = wxFSChild(XmDIALOG_SELECTION_LABEL);

#undef wxFSChild

    // change labels
    wxXmString btnOK( wxGetStockLabel( wxID_OK, false ) ),
               btnCancel( wxGetStockLabel( wxID_CANCEL, false ) ),
               btnFilter( _("Filter") ), lblFilter( _("Filter") ),
               lblDirectories( _("Directories") ),
               lblFiles( _("Files" ) ), lblSelection( _("Selection") );

    XtVaSetValues( okWidget, XmNlabelString, btnOK(), NULL );
    XtVaSetValues( applyWidget, XmNlabelString, btnFilter(), NULL );
    XtVaSetValues( cancelWidget, XmNlabelString, btnCancel(), NULL );
    XtVaSetValues( dirlistLabel, XmNlabelString, lblDirectories(), NULL );
    XtVaSetValues( filterLabel, XmNlabelString, lblFilter(), NULL );
    XtVaSetValues( listLabel, XmNlabelString, lblFiles(), NULL );
    XtVaSetValues( selectionLabel, XmNlabelString, lblSelection(), NULL );

    Widget shell = XtParent(fileSel);

    if ( !m_message.empty() )
        XtVaSetValues(shell,
                      XmNtitle, (const char*)m_message.mb_str(),
                      NULL);

    if (!m_wildCard.empty())
    {
        // return something understandable by Motif
        wxString wildCard = ParseWildCard( m_wildCard );
        wxString filter;
        if (!m_dir.empty())
            filter = m_dir + wxString("/") + wildCard;
        else
            filter = wildCard;

        XmTextSetString(filterWidget, filter.char_str());
        XmFileSelectionDoSearch(fileSel, NULL);
    }

    // Suggested by Terry Gitnick, 16/9/97, because of change in Motif
    // file selector on Solaris 1.5.1.
    if ( !m_dir.empty() )
    {
        wxXmString thePath( m_dir );

        XtVaSetValues (fileSel,
            XmNdirectory, thePath(),
            NULL);
    }

    wxString entirePath;

    if (!m_dir.empty())
    {
        entirePath = m_dir + wxString("/") + m_fileName;
    }
    else
    {
        entirePath = m_fileName;
    }

    if (!entirePath.empty())
    {
        XmTextSetString(selectionWidget, entirePath.char_str());
    }

    XtAddCallback(fileSel, XmNcancelCallback,
                  (XtCallbackProc)wxFileSelCancel, (XtPointer)NULL);
    XtAddCallback(fileSel, XmNokCallback,
                  (XtCallbackProc)wxFileSelOk, (XtPointer)NULL);
    XtAddCallback(fileSel, XmNunmapCallback,
                  (XtCallbackProc)wxFileSelClose, (XtPointer)this);

    //#if XmVersion > 1000
    // I'm not sure about what you mean with XmVersion.
    // If this is for Motif1.1/Motif1.2, then check XmVersion>=1200
    // (Motif1.1.4 ==> XmVersion 1100 )
    // Nevertheless, I put here a #define, so anyone can choose in (I)makefile.
    //
#if !DEFAULT_FILE_SELECTOR_SIZE
    int width = wxFSB_WIDTH;
    int height = wxFSB_HEIGHT;
    XtVaSetValues(fileSel,
        XmNwidth, width,
        XmNheight, height,
        XmNresizePolicy, XmRESIZE_NONE,
        NULL);
#endif
    wxDoChangeBackgroundColour((WXWidget) filterWidget, *wxWHITE);
    wxDoChangeBackgroundColour((WXWidget) selectionWidget, *wxWHITE);

    wxChangeListBoxColours(this, dirListWidget);
    wxChangeListBoxColours(this, fileListWidget);

    XtManageChild(fileSel);

    m_fileSelectorAnswer = wxEmptyString;
    m_fileSelectorReturned = false;

    wxEndBusyCursor();

    XtAddGrab(XtParent(fileSel), True, False);
    XtAppContext context = (XtAppContext) wxTheApp->GetAppContext();
    XEvent event;
    while (!m_fileSelectorReturned)
    {
        XtAppNextEvent(context, &event);
        XtDispatchEvent(&event);
    }
    XtRemoveGrab(XtParent(fileSel));

    XtUnmapWidget(XtParent(fileSel));
    XtDestroyWidget(XtParent(fileSel));

    // Now process all events, because otherwise
    // this might remain on the screen
    wxFlushEvents(XtDisplay(fileSel));

    m_path = m_fileSelectorAnswer;
    m_fileName = wxFileNameFromPath(m_fileSelectorAnswer);
    m_dir = wxPathOnly(m_path);

    if (m_fileName.empty())
        return wxID_CANCEL;
    else
        return wxID_OK;
}
void pglpfw_create ( Widget parent )
/************************************************************************
 * pglpfw_create							*
 *									*
 * This function creates a file selection dialog box.			*
 *									*
 * void pglpfw_create ( parent )					*
 *									*
 * Input parameters:							*
 *	parent		Widget		Parent widget			*
 *									*
 * Output parameters:							*
 * Return parameters:							*
 *			NONE						*
 *									*
 **									*
 *									* 
 * T. Lee/SAIC		04/02	Created					*
 * T. Piper/SAIC	10/05	declared ii & nn long			*
 ***********************************************************************/
{
    int		toff = 5, ier;
    long	ii, nn;
    char	*open_btnstr[] = {"Open", "Cancel"};
    char	*sort_str[] = {"Name", "Date"};
    Widget	pane, label, frame, sort_label;
    Arg         args[10];
    Cardinal    argcnt;
    XmString    xmpattern; 
    XmStringTable	xmfils;
/*---------------------------------------------------------------------*/

    _fileSelW = XmCreateFormDialog( parent, "Open product", NULL, 0 );
    XtVaSetValues(_fileSelW,
		XmNdialogStyle,		XmDIALOG_APPLICATION_MODAL,
		NULL);

    /*
     * create a parent pane widget
     */
    pane = XtVaCreateWidget("pglpfw_pane",
                    xmPanedWindowWidgetClass, _fileSelW,
                    XmNsashWidth,             1,
                    XmNsashHeight,            1,
                    NULL);

    /*
     * ******** SORT PANE ********
     * create a form widget to hold the sort by toggles
     */
    _sortPaneW = XtVaCreateWidget("pglpfw_form",
                    xmFormWidgetClass, 	      pane,
		    XmNnoResize,     	      TRUE,
		    XmNautoUnmanage, 	      FALSE,
		    XmNfractionBase,          110,
		    NULL );

    sort_label = XmCreateLabel( _sortPaneW, 
    		    "Display Files In Order By:", NULL, 0 );
    XtVaSetValues( sort_label,
		    XmNtopAttachment,         XmATTACH_POSITION,
		    XmNtopPosition,           2,
		    XmNleftAttachment,        XmATTACH_POSITION,
		    XmNleftPosition,          1,
		    XmNrightAttachment,       XmATTACH_POSITION,
		    XmNrightPosition,         60,
		    NULL );
    XtManageChild( sort_label );


    _sortRadioW = XtVaCreateManagedWidget ("sort_radio",
		    xmRowColumnWidgetClass,   _sortPaneW,
		    XmNorientation,           XmVERTICAL,
		    XmNradioBehavior,         True,
		    XmNtopAttachment,         XmATTACH_WIDGET,
		    XmNtopWidget,             sort_label,
		    XmNrightAttachment,       XmATTACH_FORM,
		    XmNleftAttachment,        XmATTACH_FORM,
                    NULL);

    nn = XtNumber (sort_str);
    _sortBy = SORT_BY_NAME;
    _sortBtn = (WidgetList)XtMalloc(nn*sizeof(Widget));

    for (ii = 0; ii < nn; ii++) {
        _sortBtn[ii] = XtVaCreateManagedWidget (sort_str[ii],
		    xmToggleButtonWidgetClass,      _sortRadioW,
                    XmNtraversalOn,                 FALSE,
		    NULL);
	XtAddCallback(_sortBtn[ii], XmNdisarmCallback,
	            pglpfw_sortByCb, (XtPointer) ii);

	XmToggleButtonSetState (_sortBtn[ii], (_sortBy == ii), FALSE);
    }

    XtManageChild(_sortPaneW); 


    /*
     * ******** SELECT PANE ********
     * create a form widget to hold the directory and file lists
     */
    _selectPaneW = XtVaCreateWidget("pglpfw_selectform",
                    xmFormWidgetClass, 	pane,
                    NULL);
    XtVaSetValues( _selectPaneW,
		    XmNnoResize,     TRUE,
		    XmNautoUnmanage, FALSE,
		    NULL );


    /*
     * create the directory list
     */
    label = XmCreateLabel( _selectPaneW, "Select directory:", NULL, 0 );
    XtManageChild( label );
    XtVaSetValues( label,
		    XmNtopAttachment,   XmATTACH_POSITION,
		    XmNtopPosition,     2,
		    XmNleftAttachment,  XmATTACH_POSITION,
		    XmNleftPosition,    1,
		    XmNrightAttachment, XmATTACH_POSITION,
		    XmNrightPosition,   60,
		    NULL );

    frame = XmCreateFrame( _selectPaneW, "_DirSel_frameW", NULL, 0 );
    XtVaSetValues( frame,
		    XmNtopAttachment,    XmATTACH_WIDGET,
		    XmNtopWidget,        label,
		    XmNrightAttachment,  XmATTACH_FORM,
		    XmNleftAttachment,   XmATTACH_FORM,
		    NULL );

    _dirSel_listW = XmCreateScrolledList( frame,
					  "_DirSel_lstW", NULL, 0 );
    XtVaSetValues( _dirSel_listW,
                    XmNvisibleItemCount, VISIBLE_ITEM,
		    NULL );
    XtAddCallback( _dirSel_listW, XmNbrowseSelectionCallback,
 		   pglpfw_selectDirCb, NULL );

    pglpfw_readUsrTbl("lpf.nmap", &_lpfUsrTbl, &ier);

    if (_lpfUsrTbl.nitems > 0) {

        xmfils = (XmStringTable) XtMalloc 
	    (_lpfUsrTbl.nitems * sizeof (XmString *));

        for (ii = 0; ii < _lpfUsrTbl.nitems; ii++) {
	    xmfils[ii] = XmStringCreateLocalized (_lpfUsrTbl.items[ii].title);
        }

        XtVaSetValues (_dirSel_listW,
		       XmNitems,	xmfils,
		       XmNitemCount,	_lpfUsrTbl.nitems,
		       NULL);

        for (ii = 0; ii < _lpfUsrTbl.nitems; ii++) {
	    XmStringFree (xmfils[ii]);
        }
	XtFree ((XtPointer) xmfils);

	/*
	 * hi-light the local directory
	 */
	_dirPos = _lpfUsrTbl.nitems;
    }

    XtManageChild( _dirSel_listW );
    XtManageChild( frame );

    /*
     * create the file list
     */
    label = XmCreateLabel( _selectPaneW, "Select layer product file:", NULL, 0 );
    XtManageChild (label );
    XtVaSetValues (label,
		   XmNtopAttachment,	XmATTACH_WIDGET,
		   XmNtopWidget,	frame,
		   XmNtopOffset,	toff,
		   XmNleftAttachment,	XmATTACH_POSITION,
		   XmNleftPosition,	1,
		   XmNrightAttachment,	XmATTACH_POSITION,
		   XmNrightPosition,	60,
		   NULL );

    frame = XmCreateFrame( _selectPaneW, "_FileSel_frameW", NULL, 0 );
    XtVaSetValues (frame,
		   XmNtopAttachment,	XmATTACH_WIDGET,
		   XmNtopWidget,	label,
		   XmNrightAttachment,	XmATTACH_FORM,
		   XmNleftAttachment,	XmATTACH_FORM,
		   NULL);

    _fileSel_listW = XmCreateScrolledList (frame, "_FileSel_lstW", NULL, 0);

    XtVaSetValues (_fileSel_listW,
		   XmNvisibleItemCount, VISIBLE_ITEM,
		   NULL);

    XtAddCallback (_fileSel_listW, XmNbrowseSelectionCallback,
		   pglpfw_selectCb, NULL);


    XtManageChild (_fileSel_listW);
    XtManageChild (frame);

    XtManageChild(_selectPaneW);

    /*
     * ******** BROWSE PANE ********
     */
    _browseBtnPane = 
	XtVaCreateManagedWidget ("Browse",
				 xmPushButtonWidgetClass,	pane,
				 NULL);
    XtAddCallback(_browseBtnPane, XmNarmCallback,
		  pglpfw_browseBtnCb, (XtPointer) NULL); 



    /*
     * ******** OPEN CONTROL PANE ********
     */
    _openPaneW = 
	(Widget) NxmCtlBtn_create (pane, 1, "pglpfw_open", 
				   XtNumber(open_btnstr), open_btnstr, 
				   (XtCallbackProc)pglpfw_openCtlBtnCb, NULL); 


    XtManageChild(pane);


    /*
     * browse popup
     */

    argcnt = 0;

    xmpattern  = XmStringCreateLocalized(FILE_PATTERN);

    XtSetArg (args[argcnt], XmNpattern, xmpattern); 
    argcnt++;

    XtSetArg (args[argcnt], XmNtitle, "Browse"); 
    argcnt++;

    _browsePopup = XmCreateFileSelectionDialog(parent, "browseBox", 
					       args, argcnt);
    XmStringFree(xmpattern);

    XtAddCallback(_browsePopup, XmNcancelCallback,
		  pglpfw_browseDoneCb, (XtPointer) 0);
    XtAddCallback(_browsePopup, XmNokCallback,
		  pglpfw_browseDoneCb, (XtPointer) 1);

    XtUnmanageChild(XmFileSelectionBoxGetChild(_browsePopup, 
					       XmDIALOG_HELP_BUTTON));

}
Exemple #23
0
void file_menu_init(
  Widget	topl)
{
  Widget	rc, form, toggle;
  Visual	*visual;
  Arg		arg[1];
  char		fileStr[128];
  FILE 		*fp;
  WlzEffFormat	image_type=WLZEFF_FORMAT_WLZ;

  /* set the top-level title */
  set_topl_title(NULL);

  /* get the visual explicitly */
  visual = HGU_XmWidgetToVisual(topl);
  XtSetArg(arg[0], XmNvisual, visual);

  /* create the read-model file selection dialog */
  read_model_dialog = XmCreateFileSelectionDialog(topl,
						  "read_model_dialog", arg, 1);
  XtAddCallback(read_model_dialog, XmNokCallback,
		read_reference_object_cb, (XtPointer) WLZEFF_FORMAT_WLZ);
  XtAddCallback(read_model_dialog, XmNokCallback, PopdownCallback, NULL);
  XtAddCallback( read_model_dialog, XmNcancelCallback, 
		PopdownCallback, NULL);
  XtAddCallback(read_model_dialog, XmNmapCallback,
		FSBPopupCallback, NULL);
  XtManageChild( read_model_dialog );

  /* create the read-obj file selection dialog */
  read_obj_dialog = HGU_XmCreateExtFFObjectFSB(topl, "read_obj_dialog",
					      read_reference_object_cb, NULL);
  if((rc = XtNameToWidget(read_obj_dialog, "*.formatFormRC"))){

    /* add a form to include file type and fill-blanks toggle */
    form = XtVaCreateManagedWidget("read_file_form", xmFormWidgetClass,
				   rc,
				   XmNborderWidth,	0,
				   NULL);

    /* add a fill-blanks toggles */
    toggle = XtVaCreateManagedWidget("fill_blanks", xmToggleButtonGadgetClass,
				     form,
				     XmNindicatorOn, 	True,
				     XmNindicatorType,	XmN_OF_MANY,
				     XmNset,		False,
				     XmNtopAttachment,	XmATTACH_FORM,
				     XmNleftAttachment,	XmATTACH_FORM,
				     NULL);

    toggle = XtVaCreateManagedWidget("min_domain", xmToggleButtonGadgetClass,
				     form,
				     XmNindicatorOn, 	True,
				     XmNindicatorType,	XmN_OF_MANY,
				     XmNset,		True,
				     XmNtopAttachment,	XmATTACH_FORM,
				     XmNleftAttachment,	XmATTACH_WIDGET,
				     XmNleftWidget,	toggle,
				     NULL);
  }

  HGU_XmExtFFObjectFSBSetType(read_obj_dialog, WLZEFF_FORMAT_WLZ);
  XtManageChild( read_obj_dialog );

  /* add to the save restore list */
  HGU_XmSaveRestoreAddWidget( read_obj_dialog, HGU_XmFSD_SaveFunc,
			     (XtPointer) XtName(topl), NULL, NULL );

  /* create the write-obj file selection dialog */
  write_obj_dialog = HGU_XmCreateExtFFObjectFSB(topl, "write_obj_dialog",
					       write_reference_object_cb,
					       NULL);
  HGU_XmExtFFObjectFSBSetType(write_obj_dialog, WLZEFF_FORMAT_WLZ);


  /* initialise the reference file list pulldown */
  if( !globals.sectViewFlg ){
    Widget	cascade;

    if((cascade = XtNameToWidget(globals.topl,
				 "*file_menu*_pulldown*Recent"))){
      globals.resourceFile = (String) 
	AlcMalloc(sizeof(char) * (strlen(getenv("HOME")) + 16));
      sprintf(globals.resourceFile, "%s/%s", getenv("HOME"), ".maRecentFiles");
      globals.fileList = HGU_XmFileListCreateList(globals.resourceFile, NULL);
      HGU_XmFileListResetMenu(globals.fileList, cascade, referenceFileListCb);
    }
  }

  /* add to the save restore list */
  HGU_XmSaveRestoreAddWidget( write_obj_dialog, HGU_XmFSD_SaveFunc,
			     (XtPointer) XtName(topl), NULL, NULL );

  /* create the object properties dialog */
  obj_props_dialog_init( topl );

  globals.file      = NULL;
  globals.obj       = NULL;
  globals.orig_obj  = NULL;
  globals.fb_obj    = NULL;
  globals.origObjExtType = image_type;

  /* setup the theiler directory and menu item - check for stage */
  XtGetApplicationResources(topl, &globals, set_att_res,
			    XtNumber(set_att_res), NULL, 0);

  /* check the logfile */
  if( globals.logfile ){
    if( (globals.logfileFp = fopen(globals.logfile, "w")) == NULL ){
      fprintf(stderr,
	      "MAPaint: something wrong with the logfile %s\n"
	      "Please check name and permissions\n"
	      "Logging not enabled\n\007", globals.logfile);
    }
    else {
      char		timeBuf[16];
      struct hostent 	*hstnt;
      fprintf(stderr, "MAPaint: logging enabled to %s\n", globals.logfile);
      MAPaintLogData("Filename", globals.logfile, 0, NULL);
      MAPaintLogData("User", getenv("USER"), 0, NULL);
#if defined (LINUX2) || defined (DARWIN)
      strcpy(timeBuf, "00/00/00");
#else
      tmpTime = time(NULL);
      cftime(timeBuf, "%d/%m/%Y", &tmpTime);
#endif /* LINUX2 */
      MAPaintLogData("Date", timeBuf, 0, NULL);
#if defined (LINUX2) || defined (DARWIN)
      strcpy(timeBuf, "00.00");
#else
      cftime(timeBuf, "%H.%M", &tmpTime);
#endif /* LINUX2 */
      MAPaintLogData("Time", timeBuf, 0, NULL);
      hstnt = gethostbyname(getenv("HOST"));
      MAPaintLogData("Host", getenv("HOST"), 0, NULL);
      MAPaintLogData("Hostname", hstnt->h_name, 0, NULL);
    }
  }
  else {
    globals.logfileFp = NULL;
  }

  /* check base directory - if the string has come from the resources then
     we need to duplicate it to allow it to be freed
     possibly some memory leakage here */
  /* note: only non-NULL if set by the user, if NULL then attempt to find
     the cdrom or copied data */
  if( globals.base_theiler_dir ){
    globals.base_theiler_dir = AlcStrDup( globals.base_theiler_dir );
  }
/*  else {
    FILE	*pp;*/
    
    /* search for the Theiler mode directory as per the CDROM 
       should search local disc first */
/*#if defined (LINUX2)
    if((pp = popen("find /mnt -maxdepth 4 -name Models", "r"))){
      while( fscanf(pp, "%s", fileStr) != EOF ){
	if( strstr(fileStr, "Models") ){
	  globals.base_theiler_dir = AlcStrDup(fileStr);
	  break;
	}
      }
      pclose(pp);
    }
#elif defined (DARWIN)
    if( (pp = popen("find /Volumes -maxdepth 4 -name Models", "r")) ){
      while( fscanf(pp, "%s", fileStr) != EOF ){
	if( strstr(fileStr, "Models") ){
	  globals.base_theiler_dir = AlcStrDup(fileStr);
	  break;
	}
      }
      pclose(pp);
    }
#elif defined (SUNOS4) || defined (SUNOS5)
    if( pp = popen("find /cdrom -maxdepth 4 -name Models", "r") ){
      while( fscanf(pp, "%s", fileStr) != EOF ){
	if( strstr(fileStr, "Models") ){
	  globals.base_theiler_dir = AlcStrDup(fileStr);
	  break;
	}
      }
      pclose(pp);
    }
#else
    globals.base_theiler_dir = NULL;
#endif
  }*/
  if( globals.theiler_stage ){
    char *tStr;
    if((tStr = theilerString(globals.theiler_stage))){
      globals.theiler_stage = AlcStrDup(tStr);
    }
    else {
      globals.theiler_stage = NULL;
    }
  }
  theiler_menu_init( topl );

  /* check for an initial reference file else check Theiler stage */
  if( initial_reference_file != NULL ){
    WlzObject 	*obj;

    /* open the reference object file and install */
    if( (fp = fopen(initial_reference_file, "r")) ){
      HGU_XmSetHourGlassCursor(topl);
      if((obj = WlzReadObj( fp, NULL ))){
        WlzDomain	domain;
        WlzValues	values;
        WlzObject	*newObj;
	switch( obj->type ){

	case WLZ_2D_DOMAINOBJ:
	  domain.p = WlzMakePlaneDomain(WLZ_PLANEDOMAIN_DOMAIN, 0, 0,
					obj->domain.i->line1,
					obj->domain.i->lastln,
					obj->domain.i->kol1,
					obj->domain.i->lastkl,
					NULL);
	  domain.p->domains[0] = WlzAssignDomain(obj->domain, NULL);
	  values.vox = WlzMakeVoxelValueTb(WLZ_VOXELVALUETABLE_GREY,
					   0, 0, WlzGetBackground(obj, NULL),
					   NULL, NULL);
	  values.vox->values[0] = WlzAssignValues(obj->values, NULL);
	  newObj = WlzMakeMain(WLZ_3D_DOMAINOBJ, domain, values,
			       NULL, NULL, NULL);
	  WlzFreeObj(obj);
	  obj = newObj;
	  globals.origObjType = WLZ_2D_DOMAINOBJ;
	  break;

	case WLZ_3D_DOMAINOBJ:
	  globals.origObjType = WLZ_3D_DOMAINOBJ;
	  break;

	default:
	  HGU_XmUserError(globals.topl,
			  "Read Reference Object:\n"
			  "    The reference object must be a 2- or 3-D woolz\n"
			  "    grey-level image. Please select an alternate\n"
			  "    object",
			  XmDIALOG_FULL_APPLICATION_MODAL);
	  WlzFreeObj( obj );
	  /* set hour glass cursor */
	  HGU_XmUnsetHourGlassCursor(globals.topl);
	  return;

	}
	HGU_XmFileListAddFile(globals.fileList, initial_reference_file,
			      image_type);
	HGU_XmFileListWriteResourceFile(globals.fileList,
					globals.resourceFile);
	MAPaintLogData("ReferenceFile", initial_reference_file, 0, NULL);
	install_paint_reference_object( obj );

	/* set the globals reference file */
	globals.file = initial_reference_file;

	/* set the title of the top-level window */
	set_topl_title(globals.file);
      }
      else {
	/* if it fails to read, check the file name
	   or the file content for special options */
	if( strstr(initial_reference_file, "MAPaint") ){
	  /* standard MAPaint startup */
	  globals.app_name = "MAPaint";
	  /* set the title of the top-level window */
	  set_topl_title(globals.file);
	}
	else if( strstr(initial_reference_file, "SectionView") ){
	  /* restricted section view startup */
	  globals.app_name = "SectionView";
	  globals.sectViewFlg = 1;
	  /* set the title of the top-level window */
	  set_topl_title(globals.file);
	}
	else if( theilerString(initial_reference_file) ){
	  /* load in theiler stage anatomy etc. */
	  globals.app_name = "SectionView";
	  globals.sectViewFlg = 1;
	  set_theiler_stage_cb(topl, theilerString(initial_reference_file),
			       NULL);
	}
	else {
	  char	strBuf[33];
	  /* check the content */
	  rewind(fp);
	  fscanf(fp, "%32s", strBuf);
	  if( strstr(strBuf, "MAPaint") ){
	    /* standard MAPaint startup */
	    globals.app_name = "MAPaint";
	    /* set the title of the top-level window */
	    set_topl_title(globals.file);
	  }
	  else if( strstr(strBuf, "SectionView") ){
	    /* restricted section view startup */
	    globals.app_name = "SectionView";
	    globals.sectViewFlg = 1;
	    /* set the title of the top-level window */
	    set_topl_title(globals.file);
	  }
	  else if( theilerString(strBuf) ){
	    /* load in theiler stage anatomy etc. */
	    globals.app_name = "SectionView";
	    globals.sectViewFlg = 1;
	    set_theiler_stage_cb(topl,
				 theilerString(strBuf),
				 NULL);
	  }
	}

	/* set the globals reference file */
	globals.file = NULL;
      }
      (void) fclose( fp );

      HGU_XmUnsetHourGlassCursor(topl);
    }
  }
  else if( globals.theiler_stage ){
    globals.app_name = "MAPaint";
    set_theiler_stage_cb(topl, theilerString(globals.theiler_stage), NULL);
  }

  /* reset the colormap */
  if( globals.sectViewFlg == 1 ){
    init_paint_cmapstruct(globals.topl);
  }

  /* check for an initial domain file */
  if( initial_domain_file != NULL ){
    WlzObject 	*obj;

    /* open the domain object file and put it in as a 3D feedback option */
    if( (fp = fopen(initial_domain_file, "rb")) ){
      HGU_XmSetHourGlassCursor(topl);
      if((obj = WlzReadObj( fp, NULL ))){
	if( globals.fb_obj ){
	  WlzFreeObj(globals.fb_obj);
	}
	globals.fb_obj = WlzAssignObject(obj, NULL);
	setup_ref_display_list_cb(read_obj_dialog, NULL, NULL);
      }
      (void) fclose( fp );
      HGU_XmUnsetHourGlassCursor(topl);
    }
  }

  return;
}
Exemple #24
0
XSilChessWindow::XSilChessWindow(XtAppContext app, Widget toplevel,
                                 Visual * vsl, int vsldepth, Colormap cmap)
{
	char tmp[512];
	Arg al[10];
	int i;
	XmString xms;

	// Initialize member variables
	App=app;
	TopLevel=toplevel;
	Disp=XtDisplay(TopLevel);
	Vsl=vsl;
	VslDepth=vsldepth;
	CMap=cmap;
	DlgVsl=DefaultVisual(Disp,XScreenNumberOfScreen(XtScreen(TopLevel)));
	DlgVslDepth=DefaultDepth(Disp,XScreenNumberOfScreen(XtScreen(TopLevel)));
	DlgCMap=DefaultColormap(Disp,XScreenNumberOfScreen(XtScreen(TopLevel)));
	PixelSize=(VslDepth<=8 ? 1 : (VslDepth<=16 ? 2 : 4));
	RedMask=Vsl->red_mask;
	GreenMask=Vsl->green_mask;
	BlueMask=Vsl->blue_mask;
	SelX=SelY-1;
	IsSearching=false;
	AbortSearching=false;
	NeedPainting=false;
	IsPainting=false;
	HintWanted=false;
	HintValid=false;

	// Create main window
	MainWin=XtVaCreateManagedWidget(
		"mainWin",xmMainWindowWidgetClass,TopLevel,
		(char*)NULL
	);

	// Create main menu bar
	MainMenu=XmCreateMenuBar(MainWin,(char*)"mainMenu",NULL,0);
	XtManageChild(MainMenu);

	// Create menu item: file
	XtSetArg(al[0],XmNvisual,Vsl);
	XtSetArg(al[1],XmNdepth,VslDepth);
	XtSetArg(al[2],XmNcolormap,CMap);
	FileMenu=XmCreatePulldownMenu(MainMenu,(char*)"fileMenu",al,3);
	BFile=XtVaCreateManagedWidget(
		"file",xmCascadeButtonWidgetClass,MainMenu,
		XmNsubMenuId,FileMenu,
		(char*)NULL
	);

	// Create menu item: file/load
	BFileLoad=XtVaCreateManagedWidget(
		"load",xmPushButtonWidgetClass,FileMenu,
		(char*)NULL
	);
	XtAddCallback(BFileLoad,XmNactivateCallback,HandleCallback,this);

	// Create menu item: file/save
	BFileSave=XtVaCreateManagedWidget(
		"save",xmPushButtonWidgetClass,FileMenu,
		(char*)NULL
	);
	XtAddCallback(BFileSave,XmNactivateCallback,HandleCallback,this);

	// Create menu item: file/exit
	XtVaCreateManagedWidget(
		"separator",xmSeparatorWidgetClass,FileMenu,
		(char*)NULL
	);
	BFileExit=XtVaCreateManagedWidget(
		"exit",xmPushButtonWidgetClass,FileMenu,
		(char*)NULL
	);
	XtAddCallback(BFileExit,XmNactivateCallback,HandleCallback,this);

	// Create menu item: game
	XtSetArg(al[0],XmNvisual,Vsl);
	XtSetArg(al[1],XmNdepth,VslDepth);
	XtSetArg(al[2],XmNcolormap,CMap);
	GameMenu=XmCreatePulldownMenu(MainMenu,(char*)"gameMenu",al,3);
	BGame=XtVaCreateManagedWidget(
		"game",xmCascadeButtonWidgetClass,MainMenu,
		XmNsubMenuId,GameMenu,
		(char*)NULL
	);

	// Create menu item: game/new
	BGameNew=XtVaCreateManagedWidget(
		"new",xmPushButtonWidgetClass,GameMenu,
		(char*)NULL
	);
	XtAddCallback(BGameNew,XmNactivateCallback,HandleCallback,this);

	// Create menu item: game/flip
	BGameFlip=XtVaCreateManagedWidget(
		"flip",xmPushButtonWidgetClass,GameMenu,
		(char*)NULL
	);
	XtAddCallback(BGameFlip,XmNactivateCallback,HandleCallback,this);

	// Create menu item: game/undo
	BGameUndo=XtVaCreateManagedWidget(
		"undo",xmPushButtonWidgetClass,GameMenu,
		(char*)NULL
	);
	XtAddCallback(BGameUndo,XmNactivateCallback,HandleCallback,this);

	// Create menu item: game/list
	BGameList=XtVaCreateManagedWidget(
		"list",xmPushButtonWidgetClass,GameMenu,
		(char*)NULL
	);
	XtAddCallback(BGameList,XmNactivateCallback,HandleCallback,this);

	// Create menu item: computer
	XtSetArg(al[0],XmNvisual,Vsl);
	XtSetArg(al[1],XmNdepth,VslDepth);
	XtSetArg(al[2],XmNcolormap,CMap);
	CompMenu=XmCreatePulldownMenu(MainMenu,(char*)"compMenu",al,3);
	BComp=XtVaCreateManagedWidget(
		"comp",xmCascadeButtonWidgetClass,MainMenu,
		XmNsubMenuId,CompMenu,
		(char*)NULL
	);

	// Create menu item: computer/hint
	BCompHint=XtVaCreateManagedWidget(
		"hint",xmPushButtonWidgetClass,CompMenu,
		(char*)NULL
	);
	XtAddCallback(BCompHint,XmNactivateCallback,HandleCallback,this);

	// Create menu item: computer/depth
	XtSetArg(al[0],XmNvisual,Vsl);
	XtSetArg(al[1],XmNdepth,VslDepth);
	XtSetArg(al[2],XmNcolormap,CMap);
	XtSetArg(al[3],XmNradioBehavior,True);
	DepthMenu=XmCreatePulldownMenu(CompMenu,(char*)"depthMenu",al,4);
	BCompDepth=XtVaCreateManagedWidget(
		"depth",xmCascadeButtonWidgetClass,CompMenu,
		XmNsubMenuId,DepthMenu,
		(char*)NULL
	);

	// Create menu items: computer/depth/1...
	for (i=0; i<=SilChessMachine::MAX_SEARCH_DEPTH; i++) {
		sprintf(tmp,"%d",i);
		BDepth[i]=XtVaCreateManagedWidget(
			tmp,xmToggleButtonWidgetClass,DepthMenu,
			(char*)NULL
		);
		XtAddCallback(BDepth[i],XmNvalueChangedCallback,HandleCallback,this);
	}

	// Create menu item: help
	XtSetArg(al[0],XmNvisual,Vsl);
	XtSetArg(al[1],XmNdepth,VslDepth);
	XtSetArg(al[2],XmNcolormap,CMap);
	HelpMenu=XmCreatePulldownMenu(MainMenu,(char*)"helpMenu",al,3);
	BHelp=XtVaCreateManagedWidget(
		"help",xmCascadeButtonWidgetClass,MainMenu,
		XmNsubMenuId,HelpMenu,
		(char*)NULL
	);
	XtVaSetValues(MainMenu,XmNmenuHelpWidget,BHelp,(char*)NULL);

	// Create menu item: help/about
	BHelpAbout=XtVaCreateManagedWidget(
		"about",xmPushButtonWidgetClass,HelpMenu,
		(char*)NULL
	);
	XtAddCallback(BHelpAbout,XmNactivateCallback,HandleCallback,this);

	// Create a parent for status bar and view
	MainForm=XtVaCreateManagedWidget(
		"mainForm",xmFormWidgetClass,MainWin,
		(char*)NULL
	);

	// Create status line
	StatusFrame=XtVaCreateManagedWidget(
		"statusFrame",xmFrameWidgetClass,MainForm,
		XmNleftAttachment,XmATTACH_FORM,
		XmNrightAttachment,XmATTACH_FORM,
		XmNtopAttachment,XmATTACH_FORM,
		(char*)NULL
	);
	StatusLabel=XtVaCreateManagedWidget(
		"statusLabel",xmLabelWidgetClass,StatusFrame,
		XmNalignment, XmALIGNMENT_BEGINNING,
		(char*)NULL
	);

	// Create the chess board view
	ViewFrame=XtVaCreateManagedWidget(
		"viewFrame",xmFrameWidgetClass,MainForm,
		XmNtopAttachment,XmATTACH_WIDGET,
		XmNtopWidget,StatusFrame,
		XmNleftAttachment,XmATTACH_FORM,
		XmNrightAttachment,XmATTACH_FORM,
		XmNbottomAttachment,XmATTACH_FORM,
		(char*)NULL
	);
	ViewArea=XtVaCreateManagedWidget(
		"viewArea",xmDrawingAreaWidgetClass,ViewFrame,
		XmNtopAttachment,XmATTACH_FORM,
		XmNleftAttachment,XmATTACH_FORM,
		XmNrightAttachment,XmATTACH_FORM,
		XmNbottomAttachment,XmATTACH_FORM,
		(char*)NULL
	);
	XtAddCallback(ViewArea,XmNexposeCallback,HandleCallback,this);
	XtAddCallback(ViewArea,XmNresizeCallback,HandleCallback,this);
	XtAddEventHandler(
		ViewArea,ButtonPressMask|ButtonMotionMask|ButtonReleaseMask|
		StructureNotifyMask,False,HandleEvent,this
	);
	XtVaGetValues(ViewArea,XmNwidth,&ViewWidth,(char*)NULL);
	XtVaGetValues(ViewArea,XmNheight,&ViewHeight,(char*)NULL);
	ViewWin=0;
	ViewGC=NULL;

	// Create dialog: load game
	XtSetArg(al[0],XmNvisual,DlgVsl);
	XtSetArg(al[1],XmNdepth,DlgVslDepth);
	XtSetArg(al[2],XmNcolormap,DlgCMap);
	XtSetArg(al[3],XmNautoUnmanage,True);
	LoadDialog=XmCreateFileSelectionDialog(TopLevel,(char*)"loadDialog",al,4);
	XtAddCallback(LoadDialog,XmNokCallback,HandleCallback,this);
	XtUnmanageChild(XmFileSelectionBoxGetChild(LoadDialog,XmDIALOG_HELP_BUTTON));

	// Create dialog: save game
	XtSetArg(al[0],XmNvisual,DlgVsl);
	XtSetArg(al[1],XmNdepth,DlgVslDepth);
	XtSetArg(al[2],XmNcolormap,DlgCMap);
	XtSetArg(al[3],XmNautoUnmanage, True);
	SaveDialog=XmCreateFileSelectionDialog(TopLevel,(char*)"saveDialog",al,4);
	XtAddCallback(SaveDialog,XmNokCallback,HandleCallback,this);
	XtUnmanageChild(XmFileSelectionBoxGetChild(SaveDialog,XmDIALOG_HELP_BUTTON));

	// Create dialog: file exists, overwrite?
	XtSetArg(al[0],XmNvisual,DlgVsl);
	XtSetArg(al[1],XmNdepth,DlgVslDepth);
	XtSetArg(al[2],XmNcolormap,DlgCMap);
	XtSetArg(al[3],XmNautoUnmanage, True);
	OverwriteDialog=XmCreateWarningDialog(TopLevel,(char*)"overwriteDialog",al,4);
	XtUnmanageChild(XmMessageBoxGetChild(OverwriteDialog,XmDIALOG_HELP_BUTTON));
	XtAddCallback(OverwriteDialog,XmNokCallback,HandleCallback,this);

	// Create dialog: error message
	XtSetArg(al[0],XmNvisual,DlgVsl);
	XtSetArg(al[1],XmNdepth,DlgVslDepth);
	XtSetArg(al[2],XmNcolormap,DlgCMap);
	XtSetArg(al[3],XmNautoUnmanage, True);
	ErrorBox=XmCreateWarningDialog(TopLevel,(char*)"errorBox",al,4);
	XtUnmanageChild(XmMessageBoxGetChild(ErrorBox,XmDIALOG_CANCEL_BUTTON));
	XtUnmanageChild(XmMessageBoxGetChild(ErrorBox,XmDIALOG_HELP_BUTTON));

	// Create dialog: list of moves
	ListDialogPopup=XtVaCreateWidget(
		"listDialog_popup",xmDialogShellWidgetClass,TopLevel,
		XmNvisual,DlgVsl,
		XmNdepth,DlgVslDepth,
		XmNcolormap,DlgCMap,
		(char*)NULL
	);
	ListDialog=XtVaCreateWidget(
		"listDialog",xmFormWidgetClass,ListDialogPopup,
		(char*)NULL
	);
	LDClose=XtVaCreateManagedWidget(
		"close",xmPushButtonWidgetClass,ListDialog,
		XmNleftAttachment,XmATTACH_FORM,
		XmNrightAttachment,XmATTACH_FORM,
		XmNbottomAttachment,XmATTACH_FORM,
		(char*)NULL
	);
	XtAddCallback(LDClose,XmNactivateCallback,HandleCallback,this);
	LDScroll=XtVaCreateManagedWidget(
		"scroll",xmScrolledWindowWidgetClass,ListDialog,
		XmNscrollingPolicy,XmAUTOMATIC,
		XmNscrollBarDisplayPolicy,XmAS_NEEDED,
		XmNleftAttachment,XmATTACH_FORM,
		XmNrightAttachment,XmATTACH_FORM,
		XmNtopAttachment,XmATTACH_FORM,
		XmNbottomAttachment,XmATTACH_WIDGET,
		XmNbottomWidget,LDClose,
		(char*)NULL
	);
	LDList=XtVaCreateManagedWidget(
		"list",xmLabelGadgetClass,LDScroll,
		XmNalignment,XmALIGNMENT_BEGINNING,
		(char*)NULL
	);

	// Create dialog: about
	xms=XmStringCreateLtoR((char*)AboutText,XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[0],XmNvisual,DlgVsl);
	XtSetArg(al[1],XmNdepth,DlgVslDepth);
	XtSetArg(al[2],XmNcolormap,DlgCMap);
	XtSetArg(al[3],XmNautoUnmanage,True);
	XtSetArg(al[4],XmNmessageString,xms);
	XtSetArg(al[5],XmNmessageAlignment,XmALIGNMENT_CENTER);
	AboutDialog=XmCreateMessageDialog(TopLevel,(char*)"aboutDialog",al,6);
	XmStringFree(xms);
	XtUnmanageChild(XmMessageBoxGetChild(AboutDialog,XmDIALOG_CANCEL_BUTTON));
	XtUnmanageChild(XmMessageBoxGetChild(AboutDialog,XmDIALOG_HELP_BUTTON));

	// Set main window areas
	XmMainWindowSetAreas(MainWin,MainMenu,NULL,NULL,NULL,MainForm);

	// Create chess machine
	Machine = new SilChessMachine();

	// Setup ray tracer
	RT.SetViewSize(ViewWidth,ViewHeight);
	RT.SetWorld(Machine);

	// Update all
	UpdateStatusBar();
	UpdateMovesList();
	UpdateView();
	UpdateDepthMenu();
}
Exemple #25
0
void create_local_products ( Widget parent )
{
Arg             args[10];
Cardinal        argcnt, ii;
struct stat     buf;
char            *default_dir, name[150];
Widget          ignorew;
XmStringTable	xmstr;
/*---------------------------------------------------------------------*/
/* Create a popup shell & list widget for the file list. */
        default_dir = (char *)getenv("HOME");
	strcpy(name, default_dir);
	strcat(name , "/meta");

	if ( lstat(name , &buf ) != 0 ) 
		return;

	xmstr = (XmStringTable)XtMalloc(5*sizeof(XmString *));
        argcnt = 0;
        xmstr[argcnt] = XmStringCreateLocalized("Local Products");
	XtSetArg(args[argcnt], XmNtitle, xmstr[argcnt]); 
	argcnt++;
	
        xmstr[argcnt] = XmStringCreateLocalized("Update");
	XtSetArg(args[argcnt], XmNapplyLabelString, xmstr[argcnt]);  
	argcnt++;
        
	xmstr[argcnt] = XmStringCreateLocalized("Close");
        XtSetArg(args[argcnt], XmNcancelLabelString, xmstr[argcnt]);  
	argcnt++;
        
	xmstr[argcnt] = XmStringCreateLocalized(name);
        XtSetArg(args[argcnt], XmNdirectory, xmstr[argcnt]); 
	argcnt++;
        
	xmstr[argcnt] = XmStringCreateLocalized("Select");
        XtSetArg(args[argcnt], XmNokLabelString, xmstr[argcnt]);  
	argcnt++;

        local_toplevel = XmCreateFileSelectionDialog(parent,
                "LocalProduct",args,argcnt);

	for ( ii = 0; ii < argcnt; ii++ ) {
	    XmStringFree( xmstr[ ii ] );
	}	
	XtFree((XtPointer)xmstr);
	
	ignorew = XmFileSelectionBoxGetChild(local_toplevel,
		XmDIALOG_HELP_BUTTON);
	XtUnmanageChild(ignorew);

	ignorew = XmFileSelectionBoxGetChild(local_toplevel,
		XmDIALOG_DIR_LIST);
	XtUnmanageChild(ignorew);

	ignorew = XmFileSelectionBoxGetChild(local_toplevel,
		XmDIALOG_TEXT);
	XtUnmanageChild(ignorew);

	ignorew = XmFileSelectionBoxGetChild(local_toplevel,
		XmDIALOG_SELECTION_LABEL);
	XtUnmanageChild(ignorew);

	ignorew = XmFileSelectionBoxGetChild(local_toplevel,
		XmDIALOG_FILTER_TEXT);
	XtUnmanageChild(ignorew);

	ignorew = XmFileSelectionBoxGetChild(local_toplevel,
		XmDIALOG_FILTER_LABEL);
	XtUnmanageChild(ignorew);

	ignorew = XmFileSelectionBoxGetChild(local_toplevel,
		XmDIALOG_DIR_LIST_LABEL);
	XtUnmanageChild(ignorew);

        XtAddCallback(local_toplevel, XmNokCallback,
			(XtCallbackProc)LocalProduct_Callback, (XtPointer)0);

        XtAddCallback(local_toplevel, XmNcancelCallback,
			(XtCallbackProc)LocalProduct_Callback, (XtPointer)1);

        XtAddCallback(local_toplevel, XmNapplyCallback,
			(XtCallbackProc)LocalProduct_Callback, (XtPointer)2);
}
Exemple #26
0
Widget HGU_XmCreateImageView(
    String	name,
    Widget	parent,
    int		mappingDialogFlg)
{
    Widget	image_form, form, button, text, scrolled_window, canvas;
    HGU_XmImageViewDataStruct	*data;
    String			titleStr;
    XmString			choiceStr;

    /* create the top-level form */
    image_form = XtVaCreateManagedWidget(name, xmFormWidgetClass,
                                         parent,
                                         XmNwidth, 400,
                                         XmNheight, 400,
                                         NULL);
    data = (HGU_XmImageViewDataStruct *)
           AlcCalloc(sizeof(HGU_XmImageViewDataStruct), 1);
    XtVaSetValues(image_form, XmNuserData, data, NULL);
    data->imageForm = image_form;
    data->srcMin = -10000;
    data->srcMax = 10000;
    data->min = -10000;
    data->max = 10000;
    data->Min = 0;
    data->Max = 255;
    data->width = 696;
    data->height = 520;
    data->depth = 12;
    data->byteOrder = 1;
    data->magVal = 1.0;
    data->transType = WLZ_GREYTRANSFORMTYPE_LINEAR;
    data->gamma = 1.0;
    data->invert = 0;
    data->lut.g = (HGU_XmLutGrey *) AlcMalloc(sizeof(HGU_XmLutGrey));
    data->lut.g->lut = NULL;
    data->lut.g->min = data->Min;
    data->lut.g->max = data->Max;

    /* create file-selector dialog */
    XtGetApplicationResources(image_form, &titleStr,
                              HGU_XmImageViewReadTitleResources, 1, NULL, 0);
    data->fileSelector = XmCreateFileSelectionDialog(image_form,
                         "image_select", NULL, 0);
    XtVaSetValues(XtParent(data->fileSelector), XmNtitle, titleStr, NULL);
    XtAddCallback(data->fileSelector, XmNokCallback,
                  HGU_XmImageViewReadImageCb, (XtPointer) data);
    XtAddCallback(data->fileSelector, XmNokCallback,
                  PopdownCallback, NULL);
    XtAddCallback(data->fileSelector, XmNcancelCallback,
                  PopdownCallback, NULL);

    form = XtVaCreateManagedWidget("read_file_form", xmFormWidgetClass,
                                   data->fileSelector,
                                   XmNborderWidth,	0,
                                   NULL);

    /* add a file type selection menu */
    XtGetApplicationResources(image_form, &choiceStr,
                              HGU_XmImageViewReadChoiceResources, 1, NULL, 0);
    data->typeMenu = HGU_XmBuildMenu(form, XmMENU_OPTION,
                                     "file_type", 0, XmTEAR_OFF_DISABLED,
                                     file_type_menu_itemsP);
    XtVaSetValues(data->typeMenu,
                  XmNtopAttachment,	XmATTACH_FORM,
                  XmNleftAttachment,	XmATTACH_FORM,
                  XmNrightAttachment,	XmATTACH_FORM,
                  XmNlabelString, 	choiceStr,
                  NULL);
    XtManageChild(data->typeMenu);

    /* create the mapping dialog */
    XtGetApplicationResources(parent, &titleStr,
                              HGU_XmGreyMappingDialogTitleResources, 1, NULL, 0);
    data->greyMapping = HGU_XmCreateGreyMappingDialog("grey_mapping", parent,
                        data);
    XtVaSetValues(XtParent(data->greyMapping), XmNtitle, titleStr, NULL);

    /* add the button row for mag+, mag-, I/O and re-mapping */
    form = XtVaCreateManagedWidget("image_buttons_form", xmFormWidgetClass,
                                   image_form,
                                   XmNleftAttachment, XmATTACH_FORM,
                                   XmNrightAttachment, XmATTACH_FORM,
                                   XmNbottomAttachment, XmATTACH_FORM,
                                   NULL);
    button = XtVaCreateManagedWidget("Read", xmPushButtonWidgetClass, form,
                                     XmNleftAttachment, XmATTACH_FORM,
                                     XmNtopAttachment, XmATTACH_FORM,
                                     XmNbottomAttachment, XmATTACH_FORM,
                                     NULL);
    XtAddCallback(button, XmNactivateCallback, HGU_XmMapDialogCb,
                  data->fileSelector);
    button = XtVaCreateManagedWidget("Mag+", xmPushButtonWidgetClass, form,
                                     XmNleftAttachment, XmATTACH_WIDGET,
                                     XmNleftWidget, button,
                                     XmNtopAttachment, XmATTACH_FORM,
                                     XmNbottomAttachment, XmATTACH_FORM,
                                     NULL);
    XtAddCallback(button, XmNactivateCallback,
                  HGU_XmImageViewMagPlusCb, data);
    button = XtVaCreateManagedWidget("Mag-", xmPushButtonWidgetClass, form,
                                     XmNleftAttachment, XmATTACH_WIDGET,
                                     XmNleftWidget, button,
                                     XmNtopAttachment, XmATTACH_FORM,
                                     XmNbottomAttachment, XmATTACH_FORM,
                                     NULL);
    XtAddCallback(button, XmNactivateCallback,
                  HGU_XmImageViewMagMinusCb, data);
    text = XtVaCreateManagedWidget("image_fb", xmTextFieldWidgetClass, form,
                                   XmNleftAttachment, XmATTACH_WIDGET,
                                   XmNleftWidget, button,
                                   XmNtopAttachment, XmATTACH_FORM,
                                   XmNbottomAttachment, XmATTACH_FORM,
                                   XmNcolumns, 10,
                                   NULL);
    button = XtVaCreateManagedWidget("Map greys", xmPushButtonWidgetClass,
                                     form,
                                     XmNrightAttachment, XmATTACH_FORM,
                                     XmNtopAttachment, XmATTACH_FORM,
                                     XmNbottomAttachment, XmATTACH_FORM,
                                     NULL);
    XtAddCallback(button, XmNactivateCallback,
                  HGU_XmMapDialogCb, data->greyMapping);

    /* add scrolling window and canvas */
    scrolled_window = XtVaCreateManagedWidget("image_sc",
                      xmScrolledWindowWidgetClass,
                      image_form,
                      XmNscrollingPolicy, XmAUTOMATIC,
                      XmNleftAttachment, XmATTACH_FORM,
                      XmNrightAttachment, XmATTACH_FORM,
                      XmNtopAttachment, XmATTACH_FORM,
                      XmNbottomAttachment, XmATTACH_WIDGET,
                      XmNbottomWidget, form,
                      NULL);
    data->width = 512;
    data->height = 512;
    canvas = XtVaCreateManagedWidget("canvas", xmDrawingAreaWidgetClass,
                                     scrolled_window,
                                     XmNwidth,  data->width,
                                     XmNheight, data->height,
                                     NULL);
    XtAddCallback(canvas, XmNexposeCallback, HGU_XmImageViewCanvasExposeCb, data);
    XtAddCallback(canvas, XmNinputCallback, HGU_XmImageViewCanvasInputCb, data);
    XtAddEventHandler(canvas, PointerMotionMask,
                      False, HGU_XmImageViewCanvasMotionEventHandler, data);
    data->canvas = canvas;


    return image_form;
}
Exemple #27
0
/******************************************************
  Create a fileSelectionBox
******************************************************/
Widget createFileDialog(Widget parent,void *okCallback,XtPointer okParm,
void *cancelCallback,XtPointer cancelParm,XtPointer userParm,
String title,String pattern,String directory)
{
	XmString        Xtitle;
	XmString        Xpattern;
	XmString        Xdirectory;
	XmString        Xcurrentdir=0;
	static Widget   fileselectdialog = 0; /* make it static for reuse */
	static void *oldOk= NULL;
	static void *oldCancel=NULL;
	static XtPointer oldOkParm = 0;
	static XtPointer oldCancelParm = 0;
	static Atom WM_DELETE_WINDOW = 0;
	char file_sel[]="file_sel";

	/* parent = 0 means we want to unmanage the fileSelectdialog */
	if (!parent){
		if (fileselectdialog && XtIsManaged(fileselectdialog))
			XtUnmanageChild(fileselectdialog);
		return(fileselectdialog);
	}

	/* destroy runtimeToplevel fileselectdialog 
	        so we will not have exposure problems */
	if ( parent && fileselectdialog &&
	    XtParent(XtParent(fileselectdialog)) != parent) {
		XtDestroyWidget(fileselectdialog);
		fileselectdialog = 0;
	}

	/* "Open" was selected.  Create a Motif FileSelectionDialog w/callback */
	if (!fileselectdialog) {
		fileselectdialog = XmCreateFileSelectionDialog(parent,
		    file_sel, NULL, 0);
		XtVaSetValues(fileselectdialog,
		    XmNallowShellResize, FALSE,
		    NULL);
		WM_DELETE_WINDOW = XmInternAtom(XtDisplay(fileselectdialog),
		    "WM_DELETE_WINDOW", False);
		XtAddCallback(fileselectdialog,XmNhelpCallback,
		    (XtCallbackProc)helpCallback,(XtPointer)NULL);
	} else {
		XtVaGetValues(fileselectdialog, XmNdirectory, &Xcurrentdir, NULL);
		if (oldOk)     XtRemoveCallback(fileselectdialog,XmNokCallback,
		    (XtCallbackProc)oldOk     ,(XtPointer)oldOkParm);
		if (oldCancel) XtRemoveCallback(fileselectdialog,XmNcancelCallback,
		    (XtCallbackProc)oldCancel ,(XtPointer)oldCancelParm);
		if (oldCancel) XmRemoveWMProtocolCallback(XtParent(fileselectdialog),
		    WM_DELETE_WINDOW,(XtCallbackProc)oldCancel,(XtPointer)oldCancelParm );
	}

	Xtitle=XmStringCreateLtoR(title,XmSTRING_DEFAULT_CHARSET);
	Xpattern=XmStringCreateLtoR(pattern,XmSTRING_DEFAULT_CHARSET);
	if ( !directory  && Xcurrentdir ) Xdirectory = Xcurrentdir;
	else Xdirectory = XmStringCreateLtoR(directory,XmSTRING_DEFAULT_CHARSET);

	XtVaSetValues(fileselectdialog,
	    XmNuserData,      userParm,
	    XmNdialogTitle,   Xtitle,
	    XmNdirectory,     Xdirectory,
	    XmNpattern,       Xpattern,
	    (XtPointer)NULL);

	XmStringFree(Xtitle);
	XmStringFree(Xpattern);
	XmStringFree(Xdirectory);

	XtAddCallback(fileselectdialog,XmNokCallback,
	    (XtCallbackProc)okCallback, (XtPointer)okParm);
	XtAddCallback(fileselectdialog,XmNcancelCallback,
	    (XtCallbackProc)cancelCallback,(XtPointer)cancelParm);
	XmAddWMProtocolCallback(XtParent(fileselectdialog),WM_DELETE_WINDOW,
	    (XtCallbackProc)cancelCallback,(XtPointer)cancelParm );

	oldOk = okCallback;
	oldCancel = cancelCallback;
	oldOkParm = okParm;
	oldCancelParm = cancelParm;

	XtManageChild(fileselectdialog);
	XFlush(display);
	/*
	     XtPopup(XtParent(fileselectdialog), XtGrabNone);
	*/
	return(fileselectdialog);
}
Exemple #28
0
Widget XmCreateFileSelectionDialog_TNK(Widget parent, String name, ArgList arglist,Cardinal argcount) { return XmCreateFileSelectionDialog(parent, name, arglist, argcount);}
Exemple #29
0
void create_file_popup(Widget, XtPointer, XtPointer)
{
    long i;
    Widget lab, rc, rc2, fr, rb, w[3];

    set_wait_cursor();

    if (rdata_dialog == NULL)
    {
        rdata_dialog = XmCreateFileSelectionDialog(app_shell, (char *)"rdata_dialog", NULL, 0);
        XtVaSetValues(XtParent(rdata_dialog), XmNtitle, "Read sets", NULL);
        XtAddCallback(rdata_dialog, XmNcancelCallback, (XtCallbackProc)destroy_dialog, rdata_dialog);
        XtAddCallback(rdata_dialog, XmNokCallback, rdata_proc, 0);

        curtype = XY;

        rc = XmCreateRowColumn(rdata_dialog, (char *)"Read data main RC", NULL, 0);

        fr = XmCreateFrame(rc, (char *)"frame_1", NULL, 0);
        rc2 = XmCreateRowColumn(fr, (char *)"Read data main RC", NULL, 0);
        XtVaSetValues(rc2, XmNorientation, XmHORIZONTAL, NULL);
        read_ftype_item = CreatePanelChoice(rc2, "File format: ", 16,
                                            "X Y",
                                            "X Y1 Y2 ... ",
                                            "IHL",
                                            "Binary",
                                            "X Y DX",
                                            "X Y DY",
                                            "X Y DX1 DX2",
                                            "X Y DY1 DY2",
                                            "X Y DX DY",
                                            "X Y Z",
                                            "X HI LO OPEN CLOSE",
                                            "X Y RADIUS",
                                            "X Y BOX",
                                            "Rawspice",
                                            "X Y BOXPLOT",
                                            NULL, NULL);

        XtManageChild(rc2);
        XtManageChild(fr);

        fr = XmCreateFrame(rc, (char *)"frame_2", NULL, 0);
        rc2 = XmCreateRowColumn(fr, (char *)"Read data main RC", NULL, 0);
        XtVaSetValues(rc2, XmNorientation, XmHORIZONTAL, NULL);
        lab = XmCreateLabel(rc2, (char *)"File Source:", NULL, 0);
        rb = XmCreateRadioBox(rc2, (char *)"radio_box_2", NULL, 0);
        XtVaSetValues(rb, XmNorientation, XmHORIZONTAL, NULL);
        w[0] = XmCreateToggleButton(rb, (char *)"Disk", NULL, 0);
        w[1] = XmCreateToggleButton(rb, (char *)"Pipe", NULL, 0);
        for (i = 0; i < 2; i++)
        {
            XtAddCallback(w[i], XmNvalueChangedCallback, set_src_proc, (XtPointer)i);
        }
        XtManageChild(lab);
        XtManageChild(rb);
        XtManageChildren(w, 2);
        XtManageChild(rc2);
        XtManageChild(fr);
        XmToggleButtonSetState(w[0], True, False);

        fr = XmCreateFrame(rc, (char *)"frame_3", NULL, 0);
        rc2 = XmCreateRowColumn(fr, (char *)"Read data main RC", NULL, 0);
        read_graph_item = CreateGraphChoice(rc2, "Read to graph: ", maxgraph, 1);
        read_auto_item = XmCreateToggleButton(rc2, (char *)"Autoscale on read", NULL, 0);
        XtManageChild(read_auto_item);
        XtManageChild(rc2);
        XtManageChild(fr);
        XtManageChild(rc);

        XtManageChild(rc);
    }
    XtRaise(rdata_dialog);
    unset_wait_cursor();
}
static int motFileDlgPopup(Ihandle* ih, int x, int y)
{
  InativeHandle* parent = iupDialogGetNativeParent(ih);
  Widget filebox, dialog;
  int dialogtype, style = XmDIALOG_FULL_APPLICATION_MODAL;
  IFnss file_cb = NULL;
  Widget preview_canvas = NULL;
  char* value;

  iupAttribSetInt(ih, "_IUPDLG_X", x);   /* used in iupDialogUpdatePosition */
  iupAttribSetInt(ih, "_IUPDLG_Y", y);

  value = iupAttribGetStr(ih, "DIALOGTYPE");
  if (iupStrEqualNoCase(value, "SAVE"))
    dialogtype = IUP_DIALOGSAVE;
  else if (iupStrEqualNoCase(value, "DIR"))
    dialogtype = IUP_DIALOGDIR;
  else
    dialogtype = IUP_DIALOGOPEN;
  iupAttribSetInt(ih, "_IUPDLG_DIALOGTYPE", dialogtype);

  if (parent)
  {
    filebox = XmCreateFileSelectionDialog(parent, "filedialog", NULL, 0);
    dialog = XtParent(filebox);
  }
  else
  {
    dialog = XtAppCreateShell(NULL, "filedialog", topLevelShellWidgetClass, iupmot_display, NULL, 0);
    filebox = XmCreateFileSelectionBox(dialog, "filebox", NULL, 0);
    style = XmDIALOG_MODELESS;
    XtVaSetValues(dialog,
      XmNmwmInputMode, MWM_INPUT_FULL_APPLICATION_MODAL,
      XmNmappedWhenManaged, False,
      XmNsaveUnder, True,
      NULL);
  }
  if (!filebox)
    return IUP_NOERROR;

  if (!iupAttribGetBoolean(ih, "SHOWHIDDEN"))
    XtVaSetValues(filebox, XmNfileFilterStyle, XmFILTER_HIDDEN_FILES, NULL);

  value = iupAttribGet(ih, "TITLE");
  if (!value)
  {
    if (dialogtype == IUP_DIALOGSAVE)
      value = "IUP_SAVEAS";
    else if (dialogtype == IUP_DIALOGOPEN)
      value = "IUP_OPEN";
    else
      value = "IUP_SELECTDIR";
    iupAttribSetStr(ih, "TITLE", iupStrMessageGet(value));
  }
  iupmotSetString(filebox, XmNdialogTitle, value);

  XtVaSetValues(filebox,
                XmNdialogStyle, style,
                XmNautoUnmanage, False,
                XmNresizePolicy, XmRESIZE_GROW,
                NULL);

  if (dialogtype == IUP_DIALOGDIR)
    XtVaSetValues(filebox, XmNfileTypeMask, XmFILE_DIRECTORY, NULL);

  /* just check for the path inside FILE */
  value = iupAttribGet(ih, "FILE");
  if (value && value[0] == '/')
  {
    char* dir = iupStrFileGetPath(value);
    iupAttribStoreStr(ih, "DIRECTORY", dir);
    free(dir);
  }

  /* set XmNdirectory before XmNpattern and before XmNdirSpec */

  value = iupAttribGet(ih, "DIRECTORY");
  if (value)
    iupmotSetString(filebox, XmNdirectory, value);

  value = iupAttribGet(ih, "FILTER");
  if (value)
  {
    char *filter = value;
    char *p = strchr(value, ';');
    if (p) 
    {
      /* Use only the first filter */
      int size = p-value;
      filter = (char*)malloc(size+1);
      memcpy(filter, value, size);
      filter[size] = 0;
    }

    iupmotSetString(filebox, XmNpattern, filter);

    if (filter != value) 
      free(filter);
  }

  value = iupAttribGet(ih, "FILE");
  if (value)
  {
    char* file = value;

    if (value[0] != '/')  /* if does not contains a full path, then add the directory */
    {
      char* cur_dir = NULL;
      char* dir = iupAttribGet(ih, "DIRECTORY");
      if (!dir)
      {
        cur_dir = iupdrvGetCurrentDirectory();
        dir = cur_dir;
      }

      file = iupStrFileMakeFileName(dir, value);

      if (cur_dir)
        free(cur_dir);
    }

  /* clear value before setting. Do not know why we have to do this, 
     but if not cleared it will fail to set the XmNdirSpec value. */
    iupmotSetString(filebox, XmNdirSpec, "");
    iupmotSetString(filebox, XmNdirSpec, file);

    if (file != value)
      free(file);
  }

  if (!IupGetCallback(ih, "HELP_CB"))
    XtUnmanageChild(XmFileSelectionBoxGetChild(filebox, XmDIALOG_HELP_BUTTON));

  XtAddCallback(filebox, XmNokCallback, (XtCallbackProc)motFileDlgCallback, (XtPointer)ih);
  XtAddCallback(filebox, XmNcancelCallback, (XtCallbackProc)motFileDlgCallback, (XtPointer)ih);
  XtAddCallback(filebox, XmNhelpCallback, (XtCallbackProc)motFileDlgHelpCallback, (XtPointer)ih);

  if (dialogtype == IUP_DIALOGDIR)
  {
    Widget new_folder = XtVaCreateManagedWidget("new_folder", xmPushButtonWidgetClass, filebox, 
                                                XmNlabelType, XmSTRING, 
                                                NULL);
    iupmotSetString(new_folder, XmNlabelString, iupStrMessageGet("IUP_CREATEFOLDER"));
    XtAddCallback(new_folder, XmNactivateCallback, (XtCallbackProc)motFileDlgNewFolderCallback, (XtPointer)filebox);
  }
  else
  {
    file_cb = (IFnss)IupGetCallback(ih, "FILE_CB");
    if (file_cb)
    {
      Widget list = XmFileSelectionBoxGetChild(filebox, XmDIALOG_LIST);
      XtAddCallback(list, XmNbrowseSelectionCallback, (XtCallbackProc)motFileDlgBrowseSelectionCallback, (XtPointer)ih);
      list = XmFileSelectionBoxGetChild(filebox, XmDIALOG_DIR_LIST);
      XtAddCallback(list, XmNbrowseSelectionCallback, (XtCallbackProc)motFileDlgBrowseSelectionCallback, (XtPointer)ih);

      if (iupAttribGetBoolean(ih, "SHOWPREVIEW"))
      {
        Widget frame = XtVaCreateManagedWidget("preview_canvas", xmFrameWidgetClass, filebox, 
                                                        XmNshadowType, XmSHADOW_ETCHED_IN,
                                                        NULL);

        preview_canvas = XtVaCreateManagedWidget("preview_canvas", xmDrawingAreaWidgetClass, frame, 
                                                        XmNwidth, 180, 
                                                        XmNheight, 150,
                                                        XmNresizePolicy, XmRESIZE_GROW,
                                                        NULL);

        XtAddCallback(preview_canvas, XmNexposeCallback, (XtCallbackProc)motFileDlgPreviewCanvasExposeCallback, (XtPointer)ih);
        XtAddCallback(preview_canvas, XmNresizeCallback, (XtCallbackProc)motFileDlgPreviewCanvasResizeCallback,  (XtPointer)ih);

        iupAttribSetStr(ih, "_IUPDLG_FILEBOX", (char*)filebox);
      }
    }

    if (iupAttribGetBoolean(ih, "MULTIPLEFILES"))
    {
      Widget wList = XmFileSelectionBoxGetChild(filebox, XmDIALOG_LIST);
      XtVaSetValues(wList, XmNselectionPolicy, XmEXTENDED_SELECT, NULL);

      if (file_cb)
        XtAddCallback(wList, XmNextendedSelectionCallback, (XtCallbackProc)motFileDlgBrowseSelectionCallback, (XtPointer)ih);
    }
  }

  XmAddWMProtocolCallback(dialog, iupmot_wm_deletewindow, motFileDlgCBclose, (XtPointer)ih);
  XtManageChild(filebox);

  XtRealizeWidget(dialog);
  ih->handle = dialog;
  iupDialogUpdatePosition(ih);
  ih->handle = NULL;  /* reset handle */

  if (file_cb)
  {
    if (preview_canvas)
      motFileDlgPreviewCanvasInit(ih, preview_canvas);

    file_cb(ih, NULL, "INIT");
  }

  if (ih->userwidth && ih->userheight)
  {
    XtVaSetValues(dialog,
      XmNwidth, (XtArgVal)(ih->userwidth),
      XmNheight, (XtArgVal)(ih->userheight),
      NULL);
  }

  if (style == XmDIALOG_MODELESS)
    XtPopup(dialog, XtGrabExclusive);

  /* while the user hasn't provided an answer, simulate main loop.
  ** The answer changes as soon as the user selects one of the
  ** buttons and the callback routine changes its value. */
  iupAttribSetStr(ih, "STATUS", NULL);
  while (iupAttribGet(ih, "STATUS") == NULL)
    XtAppProcessEvent(iupmot_appcontext, XtIMAll);

  if (file_cb)
  {
    if (preview_canvas)
      XFreeGC(iupmot_display, (GC)iupAttribGet(ih, "PREVIEWDC"));

    file_cb(ih, NULL, "FINISH");
  }

  if (!iupAttribGet(ih, "_IUP_WM_DELETE"))
  {
    XtUnmanageChild(filebox);

    if (style == XmDIALOG_MODELESS)
    {
      XtPopdown(dialog);
      XtDestroyWidget(dialog);
    }
  }

  return IUP_NOERROR;
}