Esempio n. 1
0
/****************************************************************
...
*****************************************************************/
void city_dialog_update_citizens(struct city_dialog *pdialog)
{
  int i, n;
  struct city *pcity=pdialog->pcity;
    
  for(i=0, n=0; n<pcity->ppl_happy[4] && i<NO_CITIZENS_SHOWN; n++, i++)
    if(pdialog->citizen_type[i]!=5 &&  pdialog->citizen_type[i]!=6) {
      pdialog->citizen_type[i]=5+i%2;
      xaw_set_bitmap(pdialog->citizen_labels[i], 
		     get_citizen_pixmap(pdialog->citizen_type[i]));
      XtSetSensitive(pdialog->citizen_labels[i], FALSE);
      XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
    }

  for(n=0; n<pcity->ppl_content[4] && i<NO_CITIZENS_SHOWN; n++, i++)
    if(pdialog->citizen_type[i]!=3 && pdialog->citizen_type[i]!=4) {
      pdialog->citizen_type[i]=3+i%2;
      xaw_set_bitmap(pdialog->citizen_labels[i], 
		     get_citizen_pixmap(pdialog->citizen_type[i]));
      XtSetSensitive(pdialog->citizen_labels[i], FALSE);
      XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
    }
      
  for(n=0; n<pcity->ppl_unhappy[4] && i<NO_CITIZENS_SHOWN; n++, i++)
    if(pdialog->citizen_type[i]!=7) {
      xaw_set_bitmap(pdialog->citizen_labels[i], get_citizen_pixmap(7));
      pdialog->citizen_type[i]=7;
      XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
      XtSetSensitive(pdialog->citizen_labels[i], FALSE);
    }
      
  for(n=0; n<pcity->ppl_elvis && i<NO_CITIZENS_SHOWN; n++, i++)
    if(pdialog->citizen_type[i]!=0) {
      xaw_set_bitmap(pdialog->citizen_labels[i], get_citizen_pixmap(0));
      pdialog->citizen_type[i]=0;
      XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
      XtAddCallback(pdialog->citizen_labels[i], XtNcallback, elvis_callback,
		    (XtPointer)pdialog);
      XtSetSensitive(pdialog->citizen_labels[i], TRUE);
    }

  
  for(n=0; n<pcity->ppl_scientist && i<NO_CITIZENS_SHOWN; n++, i++)
    if(pdialog->citizen_type[i]!=1) {
      xaw_set_bitmap(pdialog->citizen_labels[i], get_citizen_pixmap(1));
      pdialog->citizen_type[i]=1;
      XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
      XtAddCallback(pdialog->citizen_labels[i], XtNcallback, scientist_callback,
		    (XtPointer)pdialog);
      XtSetSensitive(pdialog->citizen_labels[i], TRUE);
    }
  
  for(n=0; n<pcity->ppl_taxman && i<NO_CITIZENS_SHOWN; n++, i++)
    if(pdialog->citizen_type[i]!=2) {
      xaw_set_bitmap(pdialog->citizen_labels[i], get_citizen_pixmap(2));
      pdialog->citizen_type[i]=2;
      XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
      XtAddCallback(pdialog->citizen_labels[i], XtNcallback, taxman_callback,
		    (XtPointer)pdialog);
      XtSetSensitive(pdialog->citizen_labels[i], TRUE);
    }
  
  for(; i<NO_CITIZENS_SHOWN; i++) {
    xaw_set_bitmap(pdialog->citizen_labels[i], None);
    XtSetSensitive(pdialog->citizen_labels[i], FALSE);
    XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
  }
}
Esempio n. 2
0
/*
 * Initialize a term_data
 */
static errr term_data_init(term_data *td, Widget topLevel,
                           int key_buf, String name,
                           ArgList widget_arg, Cardinal widget_arg_no, int i)
{
  Widget parent;
  term *t = &td->t;
  
  int cols = 80;
  int rows = 24;
  
  char buf[80];
  cptr str;
  
  cptr font;

  int val;
  
  /* Create the shell widget */
  parent = XtCreatePopupShell(name, topLevelShellWidgetClass, topLevel,
			      NULL, 0);
  
  /* Window specific cols */
  sprintf(buf, "ANGBAND_X11_COLS_%d", i);
  str = getenv(buf);
  val = (str != NULL) ? atoi(str) : -1;
  if (val > 0) cols = val;
  
  /* Window specific rows */
  sprintf(buf, "ANGBAND_X11_ROWS_%d", i);
  str = getenv(buf);
  val = (str != NULL) ? atoi(str) : -1;
  if (val > 0) rows = val;
  
  /* Hack the main window must be at least 80x24 */
  if (i == 0)
    {
      if (cols < 80) cols = 80;
      if (rows < 24) rows = 24;
    }
  
  /* Reset the initial size */
  widget_arg[0].value = rows;
  widget_arg[1].value = cols;
  
  /* Create the interior widget */
  td->widget = (AngbandWidget)
    XtCreateManagedWidget(name, angbandWidgetClass,
			  parent, widget_arg, widget_arg_no);
  
  /* Initialize the term (full size) */
  term_init(t, cols, rows, key_buf);
  
  /* Use a "soft" cursor */
  t->soft_cursor = TRUE;
  
  /* Erase with "white space" */
  t->attr_blank = TERM_WHITE;
  t->char_blank = ' ';
  
  /* Hooks */
  t->xtra_hook = Term_xtra_xaw;
  t->curs_hook = Term_curs_xaw;
  t->bigcurs_hook = Term_bigcurs_xaw;
  t->wipe_hook = Term_wipe_xaw;
  t->text_hook = Term_text_xaw;
  t->xchar_hook = Term_xchar_xaw;
  
  /* Save the data */
  t->data = td;
  
  /* Register the keypress event handler */
  XtAddEventHandler((Widget)td->widget, KeyPressMask,
		    False, (XtEventHandler) handle_event, td);
  
  /* Redraw callback */
  XtAddCallback((Widget)td->widget, XtNredrawCallback,
		react_redraw, td);
  
  /* Realize the widget */
  XtRealizeWidget(parent);

  /* Have we redefined the font? */
  if (streq(td->widget->angband.font, DEFAULT_X11_FONT))
    {
      XFontStruct *fnt;
      
      /* Window specific font name */
      sprintf(buf, "ANGBAND_X11_FONT_%d", i);

      /* Check environment for that font */
      font = getenv(buf);

      /* Check environment for "base" font */
      if (!font) font = getenv("ANGBAND_X11_FONT");

      /* No environment variables, use default font */
      if (!font)
	{
	  switch (i)
	    {
	    case 0:
	      {
		font = DEFAULT_X11_FONT_0;
	      }
	      break;
	    case 1:
	      {
		font = DEFAULT_X11_FONT_1;
	      }
	      break;
	    case 2:
	      {
		font = DEFAULT_X11_FONT_2;
	      }
	      break;
	    case 3:
	      {
		font = DEFAULT_X11_FONT_3;
	      }
	      break;
	    case 4:
	      {
		font = DEFAULT_X11_FONT_4;
	      }
	      break;
	    case 5:
	      {
		font = DEFAULT_X11_FONT_5;
	      }
	      break;
	    case 6:
	      {
		font = DEFAULT_X11_FONT_6;
	      }
	      break;
	    case 7:
	      {
		font = DEFAULT_X11_FONT_7;
	      }
	      break;
	    default:
	      {
		font = DEFAULT_X11_FONT;
	      }
	    }
	}
      
      /* Check if the font exists */
      fnt = getFont(td->widget, (String) font, FALSE);
      
      /* The font didn't exist */
      if (fnt == NULL)
	{
	  XtWarning("Couldn't find the requested font!");
	}
      else
	{
	  int height, width;
	  
	  /* Free the old font */
	  XFreeFont(XtDisplay((Widget)td->widget), td->widget->angband.fnt);
	  
	  /* Update font information */
	  td->widget->angband.fontheight = fnt->ascent + fnt->descent;
	  td->widget->angband.fontwidth = fnt->max_bounds.width;
	  
	  if (use_bigtile)
	    td->widget->angband.tilewidth = 2 * td->widget->angband.fontwidth;
	  else
	    td->widget->angband.tilewidth = td->widget->angband.fontwidth;
	  
	  td->widget->angband.fontascent = fnt->ascent;
	  
	  for (i = 0; i < NUM_COLORS; i++)
	    {
	      /* Be sure the correct font is ready */
	      XSetFont(XtDisplay((Widget)td->widget),
		       td->widget->angband.gc[i], fnt->fid);
	    }
	  
	  /* Get the window shape */
	  height = (td->widget->angband.start_rows *
		    td->widget->angband.fontheight +
		    2 * td->widget->angband.internal_border);
	  width = (td->widget->angband.start_columns *
		   td->widget->angband.fontwidth +
		   2 * td->widget->angband.internal_border);
	  
	  /* Request a change to the new shape */
	  if (XtMakeResizeRequest((Widget)td->widget,
				  width, height, NULL, NULL) == XtGeometryNo)
	    {
	      /* Not allowed */
	      XtWarning("Size change denied!");
	    }
	  else
	    {
	      /* Recalculate size hints */
	      calculateSizeHints(td->widget);
	    }
	}
    }
  
  /* Make it visible */
  XtPopup(parent, XtGrabNone);
  
  /* Activate (important) */
  Term_activate(t);
  
  Resize_term(td->widget);
  
  return 0;
}
Esempio n. 3
0
static int motListSetValueAttrib(Ihandle* ih, const char* value)
{
  if (ih->data->has_editbox)
  {
    Widget cbedit;
    XtVaGetValues(ih->handle, XmNtextField, &cbedit, NULL);
    if (!value) value = "";

    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", "1"); /* disable callbacks */

    XmTextFieldSetString(cbedit, (char*)value);

    iupAttribSetStr(ih, "_IUPMOT_DISABLE_TEXT_CB", NULL);
  }
  else 
  {
    if (ih->data->is_dropdown)
    {
      int pos;
      if (iupStrToInt(value, &pos)==1)
      {
        XtRemoveCallback(ih->handle, XmNselectionCallback, (XtCallbackProc)motListComboBoxSelectionCallback, (XtPointer)ih);

        XtVaSetValues(ih->handle, XmNselectedPosition, pos-1, NULL);  /* IUP starts at 1 */
        iupAttribSetInt(ih, "_IUPLIST_OLDVALUE", pos);

        XtAddCallback(ih->handle, XmNselectionCallback, (XtCallbackProc)motListComboBoxSelectionCallback, (XtPointer)ih);
      }
    }
    else
    {
      if (!ih->data->is_multiple)
      {
        int pos;
        if (iupStrToInt(value, &pos)==1)
        {
          XmListSelectPos(ih->handle, pos, FALSE);   /* XmListSelectPos starts at 1 */
          iupAttribSetInt(ih, "_IUPLIST_OLDVALUE", pos);
        }
        else
        {
          XmListDeselectAllItems(ih->handle);
          iupAttribSetStr(ih, "_IUPLIST_OLDVALUE", NULL);
        }
      }
      else
      {
        /* User has changed a multiple selection on a simple list. */
	      int i, count, len;

        /* Clear all selections */
        XmListDeselectAllItems(ih->handle);

        if (!value)
        {
          iupAttribSetStr(ih, "_IUPLIST_OLDVALUE", NULL);
          return 0;
        }

        XtVaGetValues(ih->handle, XmNitemCount, &count, NULL);
        len = strlen(value);
        if (len < count) 
          count = len;

        XtVaSetValues(ih->handle, XmNselectionPolicy, XmMULTIPLE_SELECT, NULL);

        /* update selection list */
        for (i = 0; i<count; i++)
        {
          if (value[i]=='+')
            XmListSelectPos(ih->handle, i+1, False);  /* XmListSelectPos starts at 1 */
        }

        XtVaSetValues(ih->handle, XmNselectionPolicy, XmEXTENDED_SELECT, 
                                  XmNselectionMode, XmNORMAL_MODE, NULL);  /* must also restore this */
        iupAttribStoreStr(ih, "_IUPLIST_OLDVALUE", value);
      }
    }
  }

  return 0;
}
Esempio n. 4
0
void create_netcdfs_popup(Widget, XtPointer, XtPointer)
{
    int x, y;
    static Widget top, dialog;
    Widget wbut, lab, rc, rcl, rc1, rc2, form;
    Arg args[3];

    set_wait_cursor();
    if (top == NULL)
    {
        char *label1[5];
        Widget but1[5];

        label1[0] = (char *)"Accept";
        label1[1] = (char *)"Files...";
        label1[2] = (char *)"Update";
        label1[3] = (char *)"Query";
        label1[4] = (char *)"Close";
        XmGetPos(app_shell, 0, &x, &y);
#ifdef HAVE_MFHDF
        top = XmCreateDialogShell(app_shell, (char *)"netCDF/HDF", NULL, 0);
#else
#ifdef HAVE_NETCDF
        top = XmCreateDialogShell(app_shell, (char *)"netCDF", NULL, 0);
#endif
#endif
        handle_close(top);
        XtVaSetValues(top, XmNx, x, XmNy, y, NULL);
        dialog = XmCreateRowColumn(top, (char *)"dialog_rc", NULL, 0);

        /*
         form = XmCreateForm(dialog, "form", NULL, 0);
      */
        form = XmCreateRowColumn(dialog, (char *)"form", NULL, 0);
        XtVaSetValues(form,
                      XmNpacking, XmPACK_COLUMN,
                      XmNnumColumns, 1,
                      XmNorientation, XmHORIZONTAL,
                      XmNisAligned, True,
                      XmNadjustLast, False,
                      XmNentryAlignment, XmALIGNMENT_END,
                      NULL);

        XtSetArg(args[0], XmNlistSizePolicy, XmRESIZE_IF_POSSIBLE);
        XtSetArg(args[1], XmNvisibleItemCount, 5);

        rc1 = XmCreateRowColumn(form, (char *)"rc1", NULL, 0);
        lab = XmCreateLabel(rc1, (char *)"Select set X:", NULL, 0);
        XtManageChild(lab);
        netcdf_listx_item = XmCreateScrolledList(rc1, (char *)"list", args, 2);
        XtManageChild(netcdf_listx_item);
        XtManageChild(rc1);

        rc2 = XmCreateRowColumn(form, (char *)"rc2", NULL, 0);
        lab = XmCreateLabel(rc2, (char *)"Select set Y:", NULL, 0);
        XtManageChild(lab);
        netcdf_listy_item = XmCreateScrolledList(rc2, (char *)"list", args, 2);
        XtManageChild(netcdf_listy_item);
        XtManageChild(rc2);

        XtManageChild(form);

        netcdf_file_item = CreateTextItem2(dialog, 30, "netCDF file:");
        netcdf_set_item = CreateSetChoice(dialog, "Read to set:", maxplot, 4);
        netcdf_auto_item = XmCreateToggleButton(dialog, "Autoscale on read", NULL, 0);
        XtManageChild(netcdf_auto_item);

        XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, dialog, NULL);

        CreateCommandButtons(dialog, 5, but1, label1);
        XtAddCallback(but1[0], XmNactivateCallback, (XtCallbackProc)do_netcdf_proc,
                      (XtPointer)NULL);
        XtAddCallback(but1[1], XmNactivateCallback, (XtCallbackProc)create_netcdffiles_popup,
                      (XtPointer)NULL);
        XtAddCallback(but1[2], XmNactivateCallback, (XtCallbackProc)do_netcdfupdate_proc,
                      (XtPointer)NULL);
        XtAddCallback(but1[3], XmNactivateCallback, (XtCallbackProc)do_netcdfquery_proc,
                      (XtPointer)NULL);
        XtAddCallback(but1[4], XmNactivateCallback, (XtCallbackProc)destroy_dialog,
                      (XtPointer)top);

        XtManageChild(dialog);
        netcdf_frame = top;
        if (strlen(netcdf_name))
        {
            xv_setstr(netcdf_file_item, netcdf_name);
        }
    }
    update_netcdfs();
    XtRaise(top);
    unset_wait_cursor();
}
Esempio n. 5
0
static Widget create_list_dialog(Widget parent, char *fname, ANTS *a,
                                 Arg *args, int nargs)
{
    int n;
    Arg wargs[10];
    Widget form, label, listDialog, sep, cancel, all, reset;
    static KLUDGE shit;
    
    n = 0;
    XtSetArg(wargs[n], XmNautoUnmanage, FALSE); n++;
    XtSetArg(wargs[n], XmNtitle, "Read POPS files"); n++;
    form = XmCreateFormDialog(parent, "form", wargs, n);
    a->form = form;
    
    label = XtCreateManagedWidget(fname, xmLabelWidgetClass,
                                  form, NULL, 0);
    
    listDialog = XmCreateScrolledList(form, "list", args, nargs);
    XtManageChild(listDialog);

    sep = XtVaCreateManagedWidget("separator", xmSeparatorWidgetClass,
				                  form, XmNseparatorType,
				                  XmSHADOW_ETCHED_IN, NULL);
    cancel = XtCreateManagedWidget(BUTT_CANCEL, xmPushButtonWidgetClass,
                                   form, NULL, 0);

    XtVaSetValues(form, XmNdefaultButton, cancel, NULL);
    
    all  = XtCreateManagedWidget("Select all", xmPushButtonWidgetClass,
                                 form, NULL, 0);
    shit.w = listDialog;
    shit.n = a->nscans;
    
    reset  = XtCreateManagedWidget("Unselect all", xmPushButtonWidgetClass,
                                   form, NULL, 0);
    XtAddCallback(cancel, XmNactivateCallback,
                  (XtCallbackProc)cancel_pops_dialog, a);
    XtAddCallback(reset, XmNactivateCallback,
                  (XtCallbackProc)reset_pops_dialog, &shit);
    XtAddCallback(all, XmNactivateCallback,
                  (XtCallbackProc)all_pops_dialog, &shit);
    
    n = 0;
    XtSetArg(wargs[n], XmNtopAttachment,     XmATTACH_FORM); n++;
    XtSetArg(wargs[n], XmNtopOffset,         10); n++;
    XtSetArg(wargs[n], XmNleftAttachment,    XmATTACH_FORM); n++;
    XtSetArg(wargs[n], XmNleftOffset,        10); n++;
    XtSetArg(wargs[n], XmNrightAttachment,   XmATTACH_FORM); n++;
    XtSetArg(wargs[n], XmNrightOffset,       10); n++;
    XtSetValues(XtParent(listDialog), wargs, n);
    n = 0;
    XtSetArg(wargs[n], XmNtopAttachment,     XmATTACH_WIDGET); n++;
    XtSetArg(wargs[n], XmNtopWidget,         XtParent(listDialog)); n++;
    XtSetArg(wargs[n], XmNtopOffset,         10); n++;
    XtSetArg(wargs[n], XmNleftAttachment,    XmATTACH_FORM); n++;
    XtSetArg(wargs[n], XmNleftOffset,        10); n++;
    XtSetArg(wargs[n], XmNrightAttachment,   XmATTACH_FORM); n++;
    XtSetArg(wargs[n], XmNrightOffset,       10); n++;
    XtSetValues(label, wargs, n);
    n = 0;
    XtSetArg(wargs[n], XmNtopAttachment,     XmATTACH_WIDGET); n++;
    XtSetArg(wargs[n], XmNtopWidget,         label); n++;
    XtSetArg(wargs[n], XmNtopOffset,         10); n++;
    XtSetArg(wargs[n], XmNleftAttachment,    XmATTACH_FORM); n++;
    XtSetArg(wargs[n], XmNleftOffset,        1); n++;
    XtSetArg(wargs[n], XmNrightAttachment,   XmATTACH_FORM); n++;
    XtSetArg(wargs[n], XmNrightOffset,       1); n++;
    XtSetValues(sep, wargs, n);
    n = 0;
    XtSetArg(wargs[n], XmNtopAttachment,     XmATTACH_WIDGET); n++;
    XtSetArg(wargs[n], XmNtopWidget,         sep); n++;
    XtSetArg(wargs[n], XmNtopOffset,         20); n++;
    XtSetArg(wargs[n], XmNleftAttachment,    XmATTACH_FORM); n++;
    XtSetArg(wargs[n], XmNleftOffset,        30); n++;
    XtSetArg(wargs[n], XmNbottomAttachment,  XmATTACH_FORM); n++;
    XtSetArg(wargs[n], XmNbottomOffset,      10); n++;
    XtSetValues(cancel, wargs, n);
    n = 0;
    XtSetArg(wargs[n], XmNtopAttachment,     XmATTACH_WIDGET); n++;
    XtSetArg(wargs[n], XmNtopWidget,         sep); n++;
    XtSetArg(wargs[n], XmNtopOffset,         20); n++;
    XtSetArg(wargs[n], XmNleftAttachment,    XmATTACH_WIDGET); n++;
    XtSetArg(wargs[n], XmNleftWidget,        cancel); n++;
    XtSetArg(wargs[n], XmNleftOffset,        20); n++;
    XtSetArg(wargs[n], XmNbottomAttachment,  XmATTACH_FORM); n++;
    XtSetArg(wargs[n], XmNbottomOffset,      10); n++;
    XtSetValues(reset, wargs, n);
    n = 0;
    XtSetArg(wargs[n], XmNtopAttachment,     XmATTACH_WIDGET); n++;
    XtSetArg(wargs[n], XmNtopWidget,         sep); n++;
    XtSetArg(wargs[n], XmNtopOffset,         20); n++;
    XtSetArg(wargs[n], XmNleftAttachment,    XmATTACH_WIDGET); n++;
    XtSetArg(wargs[n], XmNleftWidget,        reset); n++;
    XtSetArg(wargs[n], XmNleftOffset,        10); n++;
    XtSetArg(wargs[n], XmNbottomAttachment,  XmATTACH_FORM); n++;
    XtSetArg(wargs[n], XmNbottomOffset,      10); n++;
    XtSetValues(all, wargs, n);
    
    ManageDialogCenteredOnPointer(form);

    return listDialog;
}
Esempio n. 6
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;
}
Esempio n. 7
0
int main(int argc, String argv[])
{
    XmString         str;
    Boolean          Trav;
    XtAppContext     AppContext;

#if (XmREVISION > 1)
    XtSetLanguageProc(NULL,NULL,NULL); 
#endif
    TopLevel = XtAppInitialize(&AppContext, "XFontSelDemo", NULL, 0, 
#if (XmREVISION > 1)
        		       &argc, 
#else
                               (Cardinal *) &argc,
#endif
        		       argv, NULL, NULL, 0);
 
    Form = XtVaCreateManagedWidget("form", xmFormWidgetClass, TopLevel, NULL);
    str = XmStringCreateLtoR("Click to quit", XmSTRING_DEFAULT_CHARSET);
    Button = XtVaCreateManagedWidget("quit", xmPushButtonWidgetClass, Form, 
			XmNlabelString, str, 
			XmNleftAttachment, XmATTACH_FORM, 
			XmNleftOffset, 8, 
			XmNtopAttachment,  XmATTACH_FORM, 
			XmNtopOffset, 8, 
			NULL);
    XmStringFree(str);
    XtAddCallback(Button, XmNactivateCallback, (XtCallbackProc) QuitCB, NULL);

    Sepp = XtVaCreateManagedWidget("separator1", xmSeparatorWidgetClass, Form, 
			XmNleftAttachment, XmATTACH_FORM, 
			XmNrightAttachment, XmATTACH_FORM,
			XmNtopAttachment, XmATTACH_WIDGET, 
			XmNtopOffset, 8, 
			XmNtopWidget, Button, 
			NULL); 
			
    str = XmStringCreateLtoR("Choose one:", XmSTRING_DEFAULT_CHARSET);
    ComboBox1 = XtVaCreateManagedWidget("combobox1", xmComboBoxWidgetClass, Form, 
			XmNeditable, False,
			XmNsorted, True,  
			XmNleftAttachment, XmATTACH_FORM, 
			XmNleftOffset, 8, 
			XmNrightAttachment, XmATTACH_FORM,
			XmNrightOffset, 8, 
			XmNtopAttachment, XmATTACH_WIDGET, 
			XmNtopOffset, 8, 
			XmNtopWidget, Sepp, 
			XmNshowLabel, True, 
			XmNlabelString, str,
			NULL);
    XmStringFree(str);
    /* Put string unordered into the combo box! They'll get sorted
     * by the box.
     */
    str = XmStringCreateLtoR("William the conquerior", XmSTRING_DEFAULT_CHARSET);
    XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str);
    str = XmStringCreateLtoR("Karl der Gro\337e", XmSTRING_DEFAULT_CHARSET);
    XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str);
    str = XmStringCreateLtoR("Henry VIII & his chicken band", XmSTRING_DEFAULT_CHARSET);
    XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str);
    str = XmStringCreateLtoR("Louis XIV", XmSTRING_DEFAULT_CHARSET);
    XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str);
    str = XmStringCreateLtoR("Louis de Funes", XmSTRING_DEFAULT_CHARSET);
    XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str);
    str = XmStringCreateLtoR("Helmut Kohl", XmSTRING_DEFAULT_CHARSET);
    XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str);
    str = XmStringCreateLtoR("James Major", XmSTRING_DEFAULT_CHARSET);
    XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str);
    str = XmStringCreateLtoR("James Bond", XmSTRING_DEFAULT_CHARSET);
    XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str);
    str = XmStringCreateLtoR("Billy Boy (M$ Windoze)", XmSTRING_DEFAULT_CHARSET);
    XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str);
    str = XmStringCreateLtoR("Francois Mitterand", XmSTRING_DEFAULT_CHARSET);
    XmComboBoxAddItem(ComboBox1, str, 0);
    XmComboBoxSelectItem(ComboBox1, str, False);
    XmStringFree(str);

    str = XmStringCreateLtoR("Choose/edit:", XmSTRING_DEFAULT_CHARSET);
    ComboBox2 = XtVaCreateManagedWidget("combobox2", xmComboBoxWidgetClass, Form, 
			XmNeditable, True,
			XmNsorted, True,  
			XmNleftAttachment, XmATTACH_FORM, 
			XmNleftOffset, 8, 
			XmNrightAttachment, XmATTACH_FORM,
			XmNrightOffset, 8, 
			XmNtopAttachment, XmATTACH_WIDGET, 
			XmNtopOffset, 8, 
			XmNtopWidget, ComboBox1, 
			XmNshowLabel, True, 
			XmNlabelString, str, 
			NULL);
    str = XmStringCreateLtoR("item can be edited after choosing it", XmSTRING_DEFAULT_CHARSET);
    XmComboBoxAddItem(ComboBox2, str, 0); XmStringFree(str);
    str = XmStringCreateLtoR("just to fill the list", XmSTRING_DEFAULT_CHARSET);
    XmComboBoxAddItem(ComboBox2, str, 0); XmStringFree(str);
    str = XmStringCreateLtoR("so it contains more entries", XmSTRING_DEFAULT_CHARSET);
    XmComboBoxAddItem(ComboBox2, str, 0); XmStringFree(str);

    str = XmStringCreateLtoR("Static ComboBox:", XmSTRING_DEFAULT_CHARSET);
    ComboBox3 = XtVaCreateManagedWidget("combobox3", xmComboBoxWidgetClass, Form, 
			XmNeditable, True,
			XmNstaticList, True,
			XmNsorted, False,
			XmNcolumns, 30,  
			XmNleftAttachment, XmATTACH_FORM, 
			XmNleftOffset, 8, 
			XmNrightAttachment, XmATTACH_FORM,
			XmNrightOffset, 8, 
			XmNtopAttachment, XmATTACH_WIDGET,
			XmNtopOffset, 8, 
			XmNtopWidget, ComboBox2, 
			XmNshowLabel, True, 
			XmNlabelString, str, 
			NULL);
    XmStringFree(str);
    str = XmStringCreateLtoR("ComboBox (noneditable)", XmSTRING_DEFAULT_CHARSET);
    XmComboBoxAddItem(ComboBox3, str, 0); XmStringFree(str);
    str = XmStringCreateLtoR("ComboBox (editable)", XmSTRING_DEFAULT_CHARSET);
    XmComboBoxAddItem(ComboBox3, str, 0); XmStringFree(str);
    str = XmStringCreateLtoR("ComboBox (editable & static List)", XmSTRING_DEFAULT_CHARSET);
    XmComboBoxAddItem(ComboBox3, str, 0); XmStringFree(str);
    str = XmStringCreateLtoR("Center widget", XmSTRING_DEFAULT_CHARSET);
    XmComboBoxAddItem(ComboBox3, str, 0); XmStringFree(str);
    str = XmStringCreateLtoR("The ButtonFace Library", XmSTRING_DEFAULT_CHARSET);
    XmComboBoxAddItem(ComboBox3, str, 0); XmStringFree(str); 

    Sepp = XtVaCreateManagedWidget("separator", xmSeparatorWidgetClass, Form, 
			XmNleftAttachment, XmATTACH_FORM, 
			XmNrightAttachment, XmATTACH_FORM,
			XmNtopAttachment, XmATTACH_WIDGET, 
			XmNtopOffset, 8, 
			XmNtopWidget, ComboBox3, 
			NULL); 

    str = XmStringCreateLtoR(
"xmComboBoxWidgetClass Demo\n\nby Harald Albrecht\n\n\
[email protected]", XmSTRING_DEFAULT_CHARSET); 
    Label = XtVaCreateManagedWidget("label", xmLabelWidgetClass, Form, 
			XmNlabelString, str, 
			XmNleftAttachment, XmATTACH_FORM, 
			XmNleftOffset, 80, 
			XmNrightAttachment, XmATTACH_FORM, 
			XmNrightOffset, 80, 
			XmNbottomAttachment, XmATTACH_FORM, 
			XmNbottomOffset, 24, 
			XmNtopAttachment, XmATTACH_WIDGET, 
			XmNtopWidget, Sepp, 
			XmNtopOffset, 24, 
			NULL); 
    XmStringFree(str);

    XtRealizeWidget(TopLevel);

    XtAppMainLoop(AppContext);
    return 0; /* Never will reach this */
} /* main */
Esempio n. 8
0
void ui_load_lightspanel()
{
  int	     n;
  Widget     lightsform,
	     lightsadd,
	     lightsdel,
	     ColButton,
	     HideButton;
  char	     buf[100];

  mib_Widget *lightsload;
  static char Lights[] = "Lights";

/*****************************************************************************/

  ui_make_panel_and_form(Lights, Root, True, True, &lightsform);

/*lightsload = mib_load_interface(lightsform, "interface/Lights.mib",
		MI_FROMFILE);*/
  lightsload = mib_load_interface(lightsform, Root,
		MI_FROMSTRING);
 
  XtManageChild(lightsform);

/*****************************************************************************/

  ColButton  = mib_find_name(lightsload, "ColorButton")->me;
  HideButton = mib_find_name(lightsload, "HideButton")->me;
  lightslist = mib_find_name(lightsload, "LightsList")->me;
  lintensity = mib_find_name(lightsload, "IntensityScale")->me;
  ltoggle    = mib_find_name(lightsload, "LightsToggle")->me;
  lightsadd  = mib_find_name(lightsload, "AddButton")->me;
  lightsdel  = mib_find_name(lightsload, "DeleteButton")->me;

  XtAddCallback(ColButton, XmNactivateCallback, (XtCallbackProc) color_light,
			(XtPointer) NULL);
  XtAddCallback(HideButton, XmNactivateCallback,
			(XtCallbackProc) ui_hide, (XtPointer) Lights);
  XtAddCallback(lightslist, XmNbrowseSelectionCallback,
			(XtCallbackProc) select_light, (XtPointer) &lintensity);
  XtAddCallback(lintensity, XmNdragCallback, (XtCallbackProc) intensity_light,
			(XtPointer) NULL);
  XtAddCallback(lintensity, XmNvalueChangedCallback,
			(XtCallbackProc) intensity_light, (XtPointer) NULL);
  XtAddCallback(ltoggle, XmNvalueChangedCallback, (XtCallbackProc) toggle_lights,
			(XtPointer) NULL);
  XtAddCallback(lightsadd, XmNactivateCallback, (XtCallbackProc) light_add,
			(XtPointer) NULL);
  XtAddCallback(lightsdel, XmNactivateCallback, (XtCallbackProc) light_del,
			(XtPointer) NULL);

/*****************************************************************************/
/* Initialize Panel Variables */

  lights[0] = "ambient";
  for (n = 1; n <= MAXLIGHTS; ++n)
  {
    sprintf(buf, "light %1d", n);
    lights[n] = strdup(buf);
  }
  ui_build_browser(lightslist, light_count(), lights);

}
Esempio n. 9
0
/* -------------------------------------------------------------------- */
void SpecWinUp(Widget w, XtPointer client, XtPointer call)
{
  int	i, nSets;
  bool	saveState = Freeze;
  XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *)call;

  static bool firstTime = true;

  /* If this is 'unset' from one of the ToggleButtons, then bail.
   */
  if (cb && cb->reason == XmCR_VALUE_CHANGED && cb->set == false)
    return;

  if (NumberDataSets < 1)
    return;

  if ((long)client > 1 && NumberDataSets < 2)
    {
    HandleError("Co-PSD requires two data sets.", Interactive, IRET);
    return;
    }

  WaitCursor(MainWindow);
  WaitCursor(ControlWindow);

  if (client)
    psd[0].display = (long)client;

  if (firstTime)
    {
    CreateSpectrumWindow();
    initPlotGC(&specPlot);
    }
  else
    WaitCursor(SpectrumWindow);

  for (i = 0; i < 6; ++i)
    if (i == psd[0].display - 1)
      XmToggleButtonSetState(typeButts[i], true, false);
    else
      XmToggleButtonSetState(typeButts[i], false, false);

  Freeze = true;
  psd[0].frequency = dataSet[0].nPoints / NumberSeconds;
  psd[0].freqPerBin = (double)psd[0].frequency / (psd[0].M << 1);

  switch (psd[0].display)
    {
    case SPECTRA:
      XtSetSensitive(pmOptButt[1], true);
      XtSetSensitive(pmOptButt[2], true);
      XtSetSensitive(pmOptButt[3], true);

      nSets = std::min(NumberDataSets, MAX_PSD);

      for (i = 1; i < nSets; ++i)
        {
        psd[i].frequency = dataSet[i].nPoints / NumberSeconds;
        psd[i].freqPerBin = (double)psd[i].frequency / (psd[i].M << 1);
        }

      ComputeSpectrum();
      break;

    case COSPECTRA:
    case QUADRATURE:
    case RATIO:
      XtSetSensitive(pmOptButt[1], false);
      XtSetSensitive(pmOptButt[2], true);
      XtSetSensitive(pmOptButt[3], true);
      ComputeCoSpectrum();
      break;

    case COHERENCE:
    case PHASE:
      XtSetSensitive(pmOptButt[1], false);
      XtSetSensitive(pmOptButt[2], false);
      XtSetSensitive(pmOptButt[3], false);
      ComputeCoSpectrum();
      break;

    default:
      fprintf(stderr, "SpecWinUp: Invalid spectral display.\n");
      return;
    }

  Freeze = saveState;

  specPlot.windowOpen = true;
  XtManageChild(SpectrumWindow);
  XtPopup(XtParent(SpectrumWindow), XtGrabNone);

  if (firstTime)
    {
    WaitCursor(SpectrumWindow);
    ResizeSpecWindow(NULL, NULL, NULL);
    setDefaults();

    XtAddCallback(specPlot.canvas, XmNexposeCallback,
				(XtCallbackProc)PlotSpectrum, NULL);
    XtAddCallback(specPlot.canvas, XmNresizeCallback,
				(XtCallbackProc)ResizeSpecWindow, NULL);
    XtAddCallback(specPlot.canvas, XmNresizeCallback,
				(XtCallbackProc)PlotSpectrum, NULL);

    firstTime = false;
    }

  PlotSpectrum(NULL, NULL, NULL);

  if (AsciiWinOpen)
    SetASCIIdata(NULL, NULL, NULL);

  PointerCursor(MainWindow);
  PointerCursor(ControlWindow);
  PointerCursor(SpectrumWindow);

}   /* END SPECWINUP */
Esempio n. 10
0
File: simud.c Progetto: chinacat/rs
void PostUnfolding()
{
   Position x, y;
   Cardinal n = 0;
   Arg args[12];
   Widget name1, name2, buttonOK, buttonCancel, buttonHelp;


   if (shellFlag == True)
      XtDestroyWidget(dialogShell);
   dialogShell = CreateShell();

   n = 0;
   XtSetArg(args[n], XtNx, &x); n++;
   XtSetArg(args[n], XtNy, &y); n++;
   XtGetValues(dialogShell, args, n);

   radio4 = XtVaCreateManagedWidget("radio4", boxWidgetClass,
			 	   dialogShell,
                                   XtNx, x,
                                   XtNy, y,
                                   XtNwidth, 250,
                                   XtNheight, 100,
                                   NULL);
   n = 0;
   XtSetArg(args[n], XtNborderWidth, 0); n++;
   XtSetArg(args[n], XtNlabel, POSTUNFDLABEL); n++;
   name1 = XtCreateManagedWidget("name1", labelWidgetClass, radio4, args, n);
   XtVaSetValues(name1, XtNfont, font1Struct, NULL);

   n = 0;
   if (punfdFlag == True)
   {
      XtSetArg(args[n], XtNstate, True); n++;
   }
   XtSetArg(args[n], XtNlabel, "On"); n++;
   punfdOn = XtCreateManagedWidget("On", toggleWidgetClass, radio4, args, n);
   XtVaSetValues(punfdOn, XtNfont, font1Struct, NULL);

   n = 0;
   XtSetArg(args[n], XtNborderWidth, 0); n++;
   XtSetArg(args[n], XtNlabel, POSTUNFDLABEL); n++;
   name2 = XtCreateManagedWidget("name2", labelWidgetClass, radio4, args, n);
   XtVaSetValues(name2, XtNfont, font1Struct, NULL);

   n = 0;
   if (punfdFlag == False)
   {
      XtSetArg(args[n], XtNstate, True); n++;
   }
   XtSetArg(args[n], XtNlabel, "Off"); n++;

   punfdOff = XtCreateManagedWidget("Off", toggleWidgetClass, radio4, args, n);
   XtVaSetValues(punfdOff, XtNfont, font1Struct, NULL);

   XtVaSetValues(punfdOn, XtNradioGroup, punfdOff, NULL);
   XtVaSetValues(punfdOff, XtNradioGroup, punfdOn, NULL);

   buttonOK = XtCreateManagedWidget("OK", commandWidgetClass, radio4, NULL, 0);
   XtVaSetValues(buttonOK, XtNfont, font1Struct, NULL);

   buttonCancel = XtCreateManagedWidget("Cancel", commandWidgetClass, radio4,
				        NULL, 0);
   XtVaSetValues(buttonCancel, XtNfont, font1Struct, NULL);

   buttonHelp = XtCreateManagedWidget("Help", commandWidgetClass, radio4,
				      NULL, 0);
   XtVaSetValues(buttonHelp, XtNfont, font1Struct, NULL);

   XtAddCallback(buttonOK, XtNcallback, PostUnfoldingOK, NULL);
   XtAddCallback(buttonCancel, XtNcallback, PostUnfoldingCancel, NULL);
   XtAddCallback(buttonHelp, XtNcallback, PostUnfoldingHelp, NULL);

   XtPopup(dialogShell, XtGrabNone);
   shellFlag = True;
}
Esempio n. 11
0
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);
  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 (!iupAttribGetInt(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,
                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) 
    {
      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 file_list = XmFileSelectionBoxGetChild(filebox, XmDIALOG_LIST);
      XtAddCallback(file_list, XmNbrowseSelectionCallback, (XtCallbackProc)motFileDlgBrowseSelectionCallback, (XtPointer)ih);

      if (iupAttribGetInt(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);
      }
    }
  }

  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 (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;
}
Esempio n. 12
0
File: simud.c Progetto: chinacat/rs
void VerboseSpecialization()
{
   Position x, y;
   Cardinal n = 0;
   Arg args[12];
   Widget name1, name2, name3, buttonOK, buttonCancel, buttonHelp;


   if (shellFlag == True)
      XtDestroyWidget(dialogShell);
   dialogShell = CreateShell();

   n = 0;
   XtSetArg(args[n], XtNx, &x); n++;
   XtSetArg(args[n], XtNy, &y); n++;
   XtGetValues(dialogShell, args, n);

   radio2 = XtVaCreateManagedWidget("radio2", boxWidgetClass,
			 	   dialogShell,
                                   XtNx, x,
                                   XtNy, y,
                                   XtNwidth, 250,
                                   XtNheight, 100,
                                   NULL);
   n = 0;
   XtSetArg(args[n], XtNborderWidth, 0); n++;
   XtSetArg(args[n], XtNlabel, VERBOSESPECLABEL1); n++;
   name1 = XtCreateManagedWidget("name1", labelWidgetClass, radio2, args, n);
   XtVaSetValues(name1, XtNfont, font1Struct, NULL);

   n = 0;
   if (vspecFlag == SIMUZERO)
   {
      XtSetArg(args[n], XtNstate, True); n++;
   }
   XtSetArg(args[n], XtNlabel, "0"); n++;
   vspec0 = XtCreateManagedWidget("0", toggleWidgetClass, radio2, args, n);
   XtVaSetValues(vspec0, XtNfont, font1Struct, NULL);

   n = 0;
   XtSetArg(args[n], XtNborderWidth, 0); n++;
   XtSetArg(args[n], XtNlabel, VERBOSESPECLABEL2); n++;
   name2 = XtCreateManagedWidget("name2", labelWidgetClass, radio2, args, n);
   XtVaSetValues(name2, XtNfont, font1Struct, NULL);

   n = 0;
   if (vspecFlag == SIMUONE)
   {
      XtSetArg(args[n], XtNstate, True); n++;
   }
   XtSetArg(args[n], XtNlabel, "1"); n++;
   vspec1 = XtCreateManagedWidget("1", toggleWidgetClass, radio2, args, n);
   XtVaSetValues(vspec1, XtNfont, font1Struct, NULL);

   n = 0;
   XtSetArg(args[n], XtNborderWidth, 0); n++;
   XtSetArg(args[n], XtNlabel, VERBOSESPECLABEL3); n++;
   name3 = XtCreateManagedWidget("name3", labelWidgetClass, radio2, args, n);
   XtVaSetValues(name3, XtNfont, font1Struct, NULL);

   n = 0;
   if (vspecFlag == SIMUTWO)
   {
      XtSetArg(args[n], XtNstate, True); n++;
   }
   XtSetArg(args[n], XtNlabel, "2"); n++;
   vspec2 = XtCreateManagedWidget("2", toggleWidgetClass, radio2, args, n);
   XtVaSetValues(vspec2, XtNfont, font1Struct, NULL);

   XtVaSetValues(vspec0, XtNradioGroup, vspec1, NULL);
   XtVaSetValues(vspec1, XtNradioGroup, vspec0, NULL);
   XtVaSetValues(vspec2, XtNradioGroup, vspec1, NULL);

   buttonOK = XtCreateManagedWidget("OK", commandWidgetClass, radio2, NULL, 0);
   XtVaSetValues(buttonOK, XtNfont, font1Struct, NULL);

   buttonCancel = XtCreateManagedWidget("Cancel", commandWidgetClass, radio2,
				        NULL, 0);
   XtVaSetValues(buttonCancel, XtNfont, font1Struct, NULL);

   buttonHelp = XtCreateManagedWidget("Help", commandWidgetClass, radio2,
				      NULL, 0);
   XtVaSetValues(buttonHelp, XtNfont, font1Struct, NULL);

   XtAddCallback(buttonOK, XtNcallback, VerboseSpecializationOK, NULL);
   XtAddCallback(buttonCancel, XtNcallback, VerboseSpecializationCancel, NULL);
   XtAddCallback(buttonHelp, XtNcallback, VerboseSpecializationHelp, NULL);

   XtPopup(dialogShell, XtGrabNone);
   shellFlag = True;

}
Esempio n. 13
0
static Widget
_Uxbuild_groupNamesForm()
{
    Widget _UxParent;


    /* Creation of groupNamesForm */
    _UxParent = UxParent;
    if (_UxParent == NULL) {
	_UxParent = XtVaCreatePopupShell("groupNamesForm_shell",
				       topLevelShellWidgetClass, UxTopLevel,
					 XmNx, 330,
					 XmNy, 380,
					 XmNwidth, 620,
					 XmNheight, 300,
					 XmNshellUnitType, XmPIXELS,
					 XmNtitle, "groupNamesForm",
					 XmNiconName, "groupNamesForm",
					 NULL);

    }
    groupNamesForm = XtVaCreateManagedWidget("groupNamesForm",
					     xmFormWidgetClass,
					     _UxParent,
					     XmNwidth, 620,
					     XmNheight, 300,
					     XmNresizePolicy, XmRESIZE_NONE,
					     XmNunitType, XmPIXELS,
					     NULL);
    UxPutContext(groupNamesForm, (char *) UxGroupNamesFormContext);


    /* Creation of label10 */
    label10 = XtVaCreateManagedWidget("label10",
				      xmLabelWidgetClass,
				      groupNamesForm,
				      XmNx, 30,
				      XmNy, 140,
				      XmNwidth, 190,
				      XmNheight, 30,
				      RES_CONVERT(XmNlabelString, "Group"),
				      NULL);
    UxPutContext(label10, (char *) UxGroupNamesFormContext);


    /* Creation of label11 */
    label11 = XtVaCreateManagedWidget("label11",
				      xmLabelWidgetClass,
				      groupNamesForm,
				      XmNx, 30,
				      XmNy, 180,
				      XmNwidth, 190,
				      XmNheight, 30,
				XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
				      XmNleftOffset, 0,
				      XmNleftWidget, label10,
				      XmNtopAttachment, XmATTACH_WIDGET,
				      XmNtopOffset, 15,
				      XmNtopWidget, label10,
			 RES_CONVERT(XmNlabelString, "Application (Title)"),
				      NULL);
    UxPutContext(label11, (char *) UxGroupNamesFormContext);


    /* Creation of wGroupTxt */
    wGroupTxt = XtVaCreateManagedWidget("wGroupTxt",
					xmTextFieldWidgetClass,
					groupNamesForm,
					XmNwidth, 340,
					XmNx, 260,
					XmNy, 120,
					XmNheight, 40,
					XmNleftAttachment, XmATTACH_WIDGET,
					XmNleftOffset, 15,
					XmNleftWidget, label10,
				 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
					XmNtopOffset, 0,
					XmNtopWidget, label10,
					NULL);
    UxPutContext(wGroupTxt, (char *) UxGroupNamesFormContext);


    /* Creation of wApplicationTxt */
    wApplicationTxt = XtVaCreateManagedWidget("wApplicationTxt",
					      xmTextFieldWidgetClass,
					      groupNamesForm,
					      XmNwidth, 340,
					      XmNx, 260,
					      XmNy, 180,
					      XmNheight, 40,
					 XmNleftAttachment, XmATTACH_WIDGET,
					      XmNleftOffset, 15,
					      XmNleftWidget, label10,
				 XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
					      XmNtopOffset, 0,
					      XmNtopWidget, label11,
					      NULL);
    UxPutContext(wApplicationTxt, (char *) UxGroupNamesFormContext);


    /* Creation of pushButton10 */
    pushButton10 = XtVaCreateManagedWidget("pushButton10",
					   xmPushButtonWidgetClass,
					   groupNamesForm,
					   XmNx, 110,
					   XmNy, 240,
					   XmNwidth, 130,
					   XmNheight, 50,
					 RES_CONVERT(XmNlabelString, "Add"),
					   NULL);
    XtAddCallback(pushButton10, XmNactivateCallback,
		  (XtCallbackProc) activateCB_pushButton10,
		  (XtPointer) UxGroupNamesFormContext);

    UxPutContext(pushButton10, (char *) UxGroupNamesFormContext);


    /* Creation of pushButton11 */
    pushButton11 = XtVaCreateManagedWidget("pushButton11",
					   xmPushButtonWidgetClass,
					   groupNamesForm,
					   XmNx, 370,
					   XmNy, 240,
					   XmNwidth, 130,
					   XmNheight, 50,
				      RES_CONVERT(XmNlabelString, "Delete"),
					   NULL);
    XtAddCallback(pushButton11, XmNactivateCallback,
		  (XtCallbackProc) activateCB_pushButton11,
		  (XtPointer) UxGroupNamesFormContext);

    UxPutContext(pushButton11, (char *) UxGroupNamesFormContext);


    /* Creation of bulletinBoard1 */
    bulletinBoard1 = XtVaCreateManagedWidget("bulletinBoard1",
					     xmBulletinBoardWidgetClass,
					     groupNamesForm,
					     XmNresizePolicy, XmRESIZE_NONE,
					     XmNwidth, 600,
					     XmNheight, 110,
					     XmNx, 10,
					     XmNy, 10,
					     XmNnoResize, TRUE,
					     NULL);
    UxPutContext(bulletinBoard1, (char *) UxGroupNamesFormContext);


    /* Creation of scrolledWindowList4 */
    scrolledWindowList4 = XtVaCreateManagedWidget("scrolledWindowList4",
						xmScrolledWindowWidgetClass,
						  bulletinBoard1,
				  XmNscrollingPolicy, XmAPPLICATION_DEFINED,
						XmNvisualPolicy, XmVARIABLE,
					XmNscrollBarDisplayPolicy, XmSTATIC,
						  XmNshadowThickness, 0,
						  XmNx, 10,
						  XmNy, 10,
						  NULL);
    UxPutContext(scrolledWindowList4, (char *) UxGroupNamesFormContext);


    /* Creation of wGroupGroupList */
    wGroupGroupList = XtVaCreateManagedWidget("wGroupGroupList",
					      xmListWidgetClass,
					      scrolledWindowList4,
					      XmNwidth, 280,
					      XmNheight, 90,
					      XmNlistSizePolicy, XmCONSTANT,
					      NULL);
    XtAddCallback(wGroupGroupList, XmNbrowseSelectionCallback,
		  (XtCallbackProc) browseSelectionCB_wGroupGroupList,
		  (XtPointer) UxGroupNamesFormContext);

    UxPutContext(wGroupGroupList, (char *) UxGroupNamesFormContext);


    /* Creation of scrolledWindowList5 */
    scrolledWindowList5 = XtVaCreateManagedWidget("scrolledWindowList5",
						xmScrolledWindowWidgetClass,
						  bulletinBoard1,
				  XmNscrollingPolicy, XmAPPLICATION_DEFINED,
						XmNvisualPolicy, XmVARIABLE,
					XmNscrollBarDisplayPolicy, XmSTATIC,
						  XmNshadowThickness, 0,
						  XmNx, 300,
						  XmNy, 10,
						  NULL);
    UxPutContext(scrolledWindowList5, (char *) UxGroupNamesFormContext);


    /* Creation of wGroupTitleList */
    wGroupTitleList = XtVaCreateManagedWidget("wGroupTitleList",
					      xmListWidgetClass,
					      scrolledWindowList5,
					      XmNwidth, 280,
					      XmNheight, 90,
					      XmNlistSizePolicy, XmCONSTANT,
					      NULL);
    XtAddCallback(wGroupTitleList, XmNbrowseSelectionCallback,
		  (XtCallbackProc) browseSelectionCB_wGroupTitleList,
		  (XtPointer) UxGroupNamesFormContext);

    UxPutContext(wGroupTitleList, (char *) UxGroupNamesFormContext);


    XtAddCallback(groupNamesForm, XmNdestroyCallback,
		  (XtCallbackProc) UxDestroyContextCB,
		  (XtPointer) UxGroupNamesFormContext);


    return (groupNamesForm);
}
Esempio n. 14
0
static void
create_month_panels(Calendar *c)
{
	Day *d = (Day *)c->view->day_info;
	Arg al[20];
	int ac;

	ac=0;
	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
        XtSetArg(al[ac], XmNtopWidget, c->canvas); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_POSITION); ac++;
        XtSetArg(al[ac], XmNrightPosition, 40); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
        XtSetArg(al[ac], XmNleftOffset, 2); ac++;
        XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_POSITION); ac++;
        XtSetArg(al[ac], XmNbottomPosition, 95); ac++;
        XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	d->panel_form = XmCreateForm(c->form, "quarter", al, ac);


	ac=0;
        XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
        XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_POSITION); ac++;
        XtSetArg(al[ac], XmNbottomPosition, 33); ac++;
        XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNmonth, month(previousmonth(c->view->date))); ac++;
	XtSetArg(al[ac], XmNyear, year(previousmonth(c->view->date))); ac++;
        d->month_panels[0] = XmCreateMonthPanel(d->panel_form, "lastMonth", al, ac);
        XtAddCallback(d->month_panels[0], XmNactivateCallback,
                        day_btn_cb, (XtPointer) c);
	XtAddCallback(d->month_panels[0], XmNhelpCallback, 
			(XtCallbackProc)help_view_cb, NULL);

	ac=0;
        XtSetArg(al[ac], XmNtopAttachment, XmATTACH_POSITION); ac++;
	XtSetArg(al[ac], XmNtopPosition, 33); ac++;
        XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_POSITION); ac++;
        XtSetArg(al[ac], XmNbottomPosition, 66); ac++;
        XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNmonth, month(c->view->date)); ac++;
	XtSetArg(al[ac], XmNyear, year(c->view->date)); ac++;
        d->month_panels[1] = XmCreateMonthPanel(d->panel_form, "thisMonth", al, ac);
        XtAddCallback(d->month_panels[1], XmNactivateCallback,
                        day_btn_cb, (XtPointer) c);
	XtAddCallback(d->month_panels[1], XmNhelpCallback, 
			(XtCallbackProc)help_view_cb, NULL);

	ac=0;
        XtSetArg(al[ac], XmNtopAttachment, XmATTACH_POSITION); ac++;
        XtSetArg(al[ac], XmNtopPosition, 66); ac++;
        XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
        XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
        XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNmonth, month(nextmonth(c->view->date))); ac++;
	XtSetArg(al[ac], XmNyear, year(nextmonth(c->view->date))); ac++;
        d->month_panels[2] = XmCreateMonthPanel(d->panel_form, "nextMonth", al, ac);
        XtAddCallback(d->month_panels[2], XmNactivateCallback,
                        day_btn_cb, (XtPointer) c);
	XtAddCallback(d->month_panels[2], XmNhelpCallback, 
			(XtCallbackProc)help_view_cb, NULL);

	ManageChildren(d->panel_form);

}
Esempio n. 15
0
/****************************************************************
...
*****************************************************************/
void create_rates_dialog(void)
{
  Widget rates_form, rates_label;
  Widget rates_ok_command, rates_cancel_command;
  

  rates_dialog_shell = XtCreatePopupShell("ratespopup", 
					  transientShellWidgetClass,
					  toplevel, NULL, 0);

  rates_form = XtVaCreateManagedWidget("ratesform", 
				       formWidgetClass, 
				       rates_dialog_shell, NULL);   

  rates_label = XtVaCreateManagedWidget("rateslabel", 
					labelWidgetClass, 
					rates_form, NULL);   
  
  rates_tax_label = XtVaCreateManagedWidget("ratestaxlabel", 
					    labelWidgetClass, 
					    rates_form, NULL);

  rates_tax_scroll = XtVaCreateManagedWidget("ratestaxscroll", 
					     scrollbarWidgetClass, 
					     rates_form,
					     NULL);

  rates_tax_toggle = XtVaCreateManagedWidget("ratestaxtoggle", 
					     toggleWidgetClass, 
					     rates_form,
					     NULL);
    
  rates_lux_label = XtVaCreateManagedWidget("ratesluxlabel", 
					    labelWidgetClass, 
					    rates_form, NULL);

  rates_lux_scroll = XtVaCreateManagedWidget("ratesluxscroll", 
					     scrollbarWidgetClass, 
					     rates_form,
					     NULL);

  rates_lux_toggle = XtVaCreateManagedWidget("ratesluxtoggle", 
					     toggleWidgetClass, 
					     rates_form,
					     NULL);
  
  rates_sci_label = XtVaCreateManagedWidget("ratesscilabel", 
					    labelWidgetClass, 
					    rates_form, NULL);

  rates_sci_scroll = XtVaCreateManagedWidget("ratessciscroll", 
					     scrollbarWidgetClass, 
					     rates_form,
					     NULL);
  
  rates_sci_toggle = XtVaCreateManagedWidget("ratesscitoggle", 
					     toggleWidgetClass, 
					     rates_form,
					     NULL);
  
  rates_ok_command = XtVaCreateManagedWidget("ratesokcommand", 
					     commandWidgetClass,
					     rates_form,
					     NULL);

  rates_cancel_command = XtVaCreateManagedWidget("ratescancelcommand", 
						 commandWidgetClass,
						 rates_form,
						 NULL);

  XtAddCallback(rates_ok_command, XtNcallback, 
		rates_ok_command_callback, NULL);
  XtAddCallback(rates_cancel_command, XtNcallback, 
		rates_cancel_command_callback, NULL);

  XtAddCallback(rates_tax_scroll, XtNjumpProc, 
		rates_scroll_jump_callback, NULL);
  XtAddCallback(rates_tax_scroll, XtNscrollProc,
		rates_scroll_scroll_callback, NULL);

  
  XtAddCallback(rates_lux_scroll, XtNjumpProc, 
		rates_scroll_jump_callback, NULL);
  XtAddCallback(rates_lux_scroll, XtNscrollProc,
		rates_scroll_scroll_callback, NULL);

  
  XtAddCallback(rates_sci_scroll, XtNjumpProc, 
		rates_scroll_jump_callback, NULL);
  XtAddCallback(rates_sci_scroll, XtNscrollProc,
		rates_scroll_scroll_callback, NULL);

  XtRealizeWidget(rates_dialog_shell);

  
  rates_tax_value=-1;
  rates_lux_value=-1;
  rates_sci_value=-1;
  
  rates_set_values(game.player_ptr->economic.tax, 0,
		   game.player_ptr->economic.luxury, 0,
		   game.player_ptr->economic.science, 0);
}
Esempio n. 16
0
/* -------------------------------------------------------------------- */
static void CreateSpectrumWindow()
{
  Widget	optRC, frame, plRC, rc, RC[8], b[8], pb;
  Cardinal	n;
  Arg		args[8];


  if (SpectrumWindow)
    return;

  n = 0;
  SpecShell = XtCreatePopupShell("specShell", topLevelShellWidgetClass,
              AppShell, args, n);

  n = 0;
  SpectrumWindow = XmCreateForm(SpecShell, "specForm", args, n);


  /* RC for Options.
   */
  n = 0;
  XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  optRC = XmCreateRowColumn(SpectrumWindow, "specOptForm", args, n);
  XtManageChild(optRC);


  /* Command buttons.
   */
  n = 0;
  XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
  XtSetArg(args[n], XmNrightWidget, optRC); n++;
  frame = XmCreateFrame(SpectrumWindow, "buttonFrame", args, n);
  XtManageChild(frame);

  n = 0;
  rc = XmCreateRowColumn(frame, "buttonRC", args, n);
  XtManageChild(rc);

  n = 0;
  b[0] = XmCreatePushButton(rc, "dismissButton", args, n);
  b[1] = XmCreatePushButton(rc, "printButton", args, n);
  b[2] = XmCreatePushButton(rc, "parmsButton", args, n);
  b[3] = XmCreatePushButton(rc, "savepngButton", args, n);
  XtManageChildren(b, 4);
  XtAddCallback(b[0], XmNactivateCallback, SpecWinDown, NULL);
  XtAddCallback(b[1], XmNactivateCallback, specPostScript, NULL);
  XtAddCallback(b[2], XmNactivateCallback, EditSpecParms, NULL);
#ifdef PNG
  XtAddCallback(b[3], XmNactivateCallback, SavePNGspec, NULL);
#endif



  /* Create Graphics Canvas
  */
  n = 0;
  XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  XtSetArg(args[n], XmNtopWidget, frame); n++;
  XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
  XtSetArg(args[n], XmNrightWidget, optRC); n++;
  specPlot.canvas = XmCreateDrawingArea(SpectrumWindow, "specCanvas", args,n);
  XtManageChild(specPlot.canvas);



  n = 0;
  frame = XmCreateFrame(optRC, "specDefsFrame", args, 0);
  XtManageChild(frame);

  n = 0;
  RC[0] = XmCreateRadioBox(frame, "specTypeRB", args, n);

  n = 0;
  typeButts[0] = XmCreateToggleButton(RC[0], "Spectrum", args, n);
  typeButts[1] = XmCreateToggleButton(RC[0], "Co-Spectrum", args, n);
  typeButts[2] = XmCreateToggleButton(RC[0], "Quadrature", args, n);
  typeButts[3] = XmCreateToggleButton(RC[0], "Coherence", args, n);
  typeButts[4] = XmCreateToggleButton(RC[0], "Phase", args, n);
  typeButts[5] = XmCreateToggleButton(RC[0], "Spectral ratio", args, n);
  XtManageChildren(typeButts, 6);

  XtAddCallback(typeButts[0],XmNvalueChangedCallback,SpecWinUp,(XtPointer)SPECTRA);
  XtAddCallback(typeButts[1],XmNvalueChangedCallback,SpecWinUp,(XtPointer)COSPECTRA);
  XtAddCallback(typeButts[2],XmNvalueChangedCallback,SpecWinUp,(XtPointer)QUADRATURE);
  XtAddCallback(typeButts[3],XmNvalueChangedCallback,SpecWinUp,(XtPointer)COHERENCE);
  XtAddCallback(typeButts[4],XmNvalueChangedCallback,SpecWinUp,(XtPointer)PHASE);
  XtAddCallback(typeButts[5],XmNvalueChangedCallback,SpecWinUp,(XtPointer)RATIO);


  /* Optional stuff.  PreFilter, SegLen, Window, Detrend menus.
   */
  n = 0;
  frame = XmCreateFrame(optRC, "specDefsFrame", args, 0);
  XtManageChild(frame);

  n = 0;
  RC[1] = XmCreateRowColumn(frame, "specDefsRC", args, n);

  dtOpMenu = CreateDropDownMenu(RC[1], "dtOpMenu", detrendInfo);
  slOpMenu = CreateDropDownMenu(RC[1], "slOpMenu", segLenInfo);
  winOpMenu = CreateDropDownMenu(RC[1], "winOpMenu", windowInfo);

  n = 0;
  XtSetArg(args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
  pb = XmCreatePushButton(RC[1], "Recompute", args, n);
  XtManageChild(pb);
  XtAddCallback(pb, XmNactivateCallback, SpecWinUp, NULL);



  /* Variance widgets.
   */
  n = 0;
  frame = XmCreateFrame(optRC, "specDefsFrame", args, 0);
  XtManageChild(frame);

  XtManageChild(XmCreateLabel(frame, "fluxLabel", args, n));

  n = 0;
  RC[2] = XmCreateRowColumn(frame, "plRCv", args, n);

  plRC = XmCreateRowColumn(RC[2], "plRC", args, n);
  XtManageChild(XmCreateLabel(plRC, "Start freq", args, n));
  sFreq = XmCreateTextField(plRC, "fluxFreq", args, n);
  XtManageChild(XmCreateLabel(plRC, "Hz", args, n));
  XtManageChild(plRC);
  XtManageChild(sFreq);
  XtAddCallback(sFreq, XmNlosingFocusCallback, ValidateFloat, (XtPointer)"%g");
  XtAddCallback(sFreq, XmNlosingFocusCallback, ComputeBandLimitedVariance,NULL);
  XtAddCallback(sFreq, XmNlosingFocusCallback, (XtCallbackProc)PlotSpectrum, NULL);

  plRC = XmCreateRowColumn(RC[2], "plRC", args, n);
  XtManageChild(XmCreateLabel(plRC, "End freq", args, n));
  eFreq = XmCreateTextField(plRC, "fluxFreq", args, n);
  XtManageChild(XmCreateLabel(plRC, "Hz", args, n));
  XtManageChild(plRC);
  XtManageChild(eFreq);
  XtAddCallback(eFreq, XmNlosingFocusCallback, ValidateFloat, (XtPointer)"%g");
  XtAddCallback(eFreq, XmNlosingFocusCallback, ComputeBandLimitedVariance,NULL);
  XtAddCallback(eFreq, XmNlosingFocusCallback, (XtCallbackProc)PlotSpectrum, NULL);

  XmTextFieldSetString(sFreq, "0.0");
  XmTextFieldSetString(eFreq, "5000.0");


  /* Plot Methods.
   */
  n = 0;
  frame = XmCreateFrame(optRC, "specDefsFrame", args, 0);
  XtManageChild(frame);

  XtManageChild(XmCreateLabel(frame, "plotMethodLabel", args, n));

  n = 0;
  RC[3] = XmCreateRowColumn(frame, "plRCv", args, n);

  n = 0;
  pmOptButt[0] = XmCreateToggleButton(RC[3], "Grid", args,n);
  pmOptButt[1] = XmCreateToggleButton(RC[3], "-5/3 (-2/3 x f) slope line", args,n);
  pmOptButt[2] = XmCreateToggleButton(RC[3], "Multiply output by frequency", args,n);
  pmOptButt[3] = XmCreateToggleButton(RC[3], "Multiply output by freq^(5/3)", args,n);
  pmOptButt[4] = XmCreateToggleButton(RC[3], "Wave number scale", args,n);
  pmOptButt[5] = XmCreateToggleButton(RC[3], "Wave length scale", args,n);
  XtManageChildren(pmOptButt, 6);

  XtAddCallback(pmOptButt[0], XmNvalueChangedCallback, ToggleSpecGrid, NULL);
  XtAddCallback(pmOptButt[0], XmNvalueChangedCallback, (XtCallbackProc)PlotSpectrum, NULL);
  XtAddCallback(pmOptButt[1], XmNvalueChangedCallback, (XtCallbackProc)PlotSpectrum, NULL);
  XtAddCallback(pmOptButt[2], XmNvalueChangedCallback, ToggleMultByFreq, NULL);
  XtAddCallback(pmOptButt[2], XmNvalueChangedCallback, (XtCallbackProc)PlotSpectrum, NULL);
  XtAddCallback(pmOptButt[3], XmNvalueChangedCallback, ToggleMultByFreq, NULL);
  XtAddCallback(pmOptButt[3], XmNvalueChangedCallback, (XtCallbackProc)PlotSpectrum, NULL);
  XtAddCallback(pmOptButt[4], XmNvalueChangedCallback, ToggleWaveNumberScale, NULL);
  XtAddCallback(pmOptButt[4], XmNvalueChangedCallback, (XtCallbackProc)PlotSpectrum, NULL);
  XtAddCallback(pmOptButt[5], XmNvalueChangedCallback, ToggleWaveLengthScale, NULL);
  XtAddCallback(pmOptButt[5], XmNvalueChangedCallback, (XtCallbackProc)PlotSpectrum, NULL);

  XmToggleButtonSetState(pmOptButt[1], true, false);



  /* Equal-log interval averaging
   */
  n = 0;
  frame = XmCreateFrame(optRC, "eliaFrame", args, 0);
  XtManageChild(frame);

  n = 0;
  RC[4] = XmCreateRowColumn(frame, "plRCv", args, n);

  n = 0;
  pmOptButt[6] = XmCreateToggleButton(RC[4], "Equal-log interval averaging", args,n);
  XtManageChild(pmOptButt[6]);
  XtAddCallback(pmOptButt[6], XmNvalueChangedCallback, (XtCallbackProc)PlotSpectrum, NULL);

  n = 0;
  plRC = XmCreateRowColumn(RC[4], "plRC", args, n);
  XtManageChild(plRC);

  XtManageChild(XmCreateLabel(plRC, "Total number points", args, n));
  eliaText = XmCreateTextField(plRC, "eliaText", args, n);
  XtManageChild(eliaText);
  XmTextFieldSetString(eliaText, "30");

  XtAddCallback(eliaText, XmNlosingFocusCallback, ValidateInteger, NULL);
  XtAddCallback(eliaText, XmNlosingFocusCallback, (XtCallbackProc)PlotSpectrum, NULL);


  /* Time shift.
   */
  n = 0;
  frame = XmCreateFrame(optRC, "specDefsFrame", args, 0);
  XtManageChild(frame);

  n = 0;
  RC[5] = XmCreateRowColumn(frame, "plRC", args, n);

  XtManageChild(XmCreateLabel(RC[5], "Time shift", args, n));
  tShift = XmCreateTextField(RC[5], "timeShift", args, n);
  XtManageChild(tShift);

  XtAddCallback(tShift, XmNlosingFocusCallback, ValidateInteger, NULL);
  XtAddCallback(tShift, XmNlosingFocusCallback, SpecWinUp, NULL);

  XtManageChild(XmCreateLabel(RC[5], "milliseconds", args, n));


  XtManageChild(RC[0]); XtManageChild(RC[1]);
  XtManageChild(RC[2]); XtManageChild(RC[3]);
  XtManageChild(RC[4]); XtManageChild(RC[5]);

}	/* END CREATESPECTRUMWINDOW */
Esempio n. 17
0
/******************************************************
  audioSetupCreateDialog
******************************************************/
static void audioSetupCreateDialog(Widget menuButton)
{
    Widget audioSetupDialogShell;
    Widget form,form1;
    Widget filename;
    Widget scale;
    Widget button;
    Widget toggleButton;
    Widget frame, rowcol;
    Widget label;
    Pixel textBackground;
    XmString string;
    static ActionAreaItem audioSetup_items[] = {
         { "Dismiss", audioSetupDismissCallback, NULL} };
    ALINK      *area;

    if (!audioSetup.paudioInfo) initAudioSetup();

    textBackground = bg_pixel[3];

    XtVaGetValues(menuButton, XmNuserData, &area, NULL);

    if (audioSetup.audioSetupDialog){
        if (XtIsManaged(audioSetup.audioSetupDialog)) return;
        else XtManageChild(audioSetup.audioSetupDialog);
    }

    audioSetupDialogShell = XtVaCreatePopupShell("ALH Audio Setup",
        transientShellWidgetClass, area->toplevel, NULL, 0);

    /* Modify the window manager menu "close" callback */
    {
        Atom         WM_DELETE_WINDOW;
        XtVaSetValues(audioSetupDialogShell,
            XmNdeleteResponse, XmDO_NOTHING, NULL);
        WM_DELETE_WINDOW = XmInternAtom(XtDisplay(audioSetupDialogShell),
            "WM_DELETE_WINDOW", False);
        XmAddWMProtocolCallback(audioSetupDialogShell,WM_DELETE_WINDOW,
            (XtCallbackProc)audioSetupDismissCallback, (XtPointer)menuButton);
    }

    form = XtVaCreateWidget("audioSetupDialog",
        xmFormWidgetClass, audioSetupDialogShell,
        NULL);
    audioSetup.audioSetupDialog = form;

    string = XmStringCreateSimple("Audio Beep Output Port");
    label = XtVaCreateManagedWidget("audioOutputLabel",
        xmLabelGadgetClass,        form,
        XmNlabelString,            string,
        XmNtopAttachment,          XmATTACH_FORM,
        XmNtopWidget,              form,
        NULL);
    XmStringFree(string);

    frame = XtVaCreateWidget("frame",
        xmFrameWidgetClass, form,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              label,
        XmNleftAttachment,         XmATTACH_FORM,
        XmNrightAttachment,        XmATTACH_FORM,
        NULL);

    rowcol = XtVaCreateWidget("rowcol",
        xmRowColumnWidgetClass, frame,
        XmNspacing,         0,
        XmNmarginWidth,     10,
        XmNmarginHeight,    10,
        XmNradioBehavior,    TRUE,
        XmNbackground,      textBackground,
        NULL);

    toggleButton = XtVaCreateManagedWidget("None (Use keyboard speaker)",
        xmToggleButtonGadgetClass, rowcol,
        XmNmarginHeight,     0,
        XmNbackground,      textBackground,
        NULL);
    XmToggleButtonSetState(toggleButton,
        ((audioSetup.port==AUDIO_NONE)?TRUE:FALSE),FALSE);
    XtAddCallback(toggleButton, XmNvalueChangedCallback,
        audioSetupOutputChangeCallback, (XtPointer)AUDIO_NONE);

    toggleButton = XtVaCreateManagedWidget("Internal speaker",
        xmToggleButtonGadgetClass, rowcol,
        XmNmarginHeight,     0,
        XmNbackground,      textBackground,
        NULL);
    XmToggleButtonSetState(toggleButton,
        ((audioSetup.port==AUDIO_SPEAKER)?TRUE:FALSE),FALSE);
    XtAddCallback(toggleButton, XmNvalueChangedCallback,
        audioSetupOutputChangeCallback, (XtPointer)AUDIO_SPEAKER);

    toggleButton = XtVaCreateManagedWidget("Headphone",
        xmToggleButtonGadgetClass, rowcol,
        XmNmarginHeight,     0,
        XmNbackground,      textBackground,
        NULL);
    XmToggleButtonSetState(toggleButton,
        ((audioSetup.port==AUDIO_HEADPHONE)?TRUE:FALSE),FALSE);
    XtAddCallback(toggleButton, XmNvalueChangedCallback,
        audioSetupOutputChangeCallback, (XtPointer)AUDIO_HEADPHONE);

    toggleButton = XtVaCreateManagedWidget("Line out",
        xmToggleButtonGadgetClass, rowcol,
        XmNmarginHeight,     0,
        XmNbackground,      textBackground,
        NULL);
    XmToggleButtonSetState(toggleButton,
        ((audioSetup.port==AUDIO_LINE_OUT)?TRUE:FALSE),FALSE);
    XtAddCallback(toggleButton, XmNvalueChangedCallback,
        audioSetupOutputChangeCallback, (XtPointer)AUDIO_LINE_OUT);

    XtManageChild(rowcol);
    XtManageChild(frame);

    string = XmStringCreateSimple("Audio Source");
    label = XtVaCreateManagedWidget("audioAudioSourceLabel",
        xmLabelGadgetClass,        form,
        XmNlabelString,            string,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              frame,
        NULL);
    XmStringFree(string);

    frame = XtVaCreateWidget("frame",
        xmFrameWidgetClass, form,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              label,
        XmNleftAttachment,         XmATTACH_FORM,
        XmNrightAttachment,        XmATTACH_FORM,
        NULL);

    audioSetup.audioSourceFrameWidget = frame;
    if (audioSetup.port==AUDIO_NONE) XtSetSensitive(frame, FALSE);
    else XtSetSensitive(frame, TRUE);

    rowcol = XtVaCreateWidget("rowcol",
        xmRowColumnWidgetClass, frame,
        XmNspacing,          0,
        XmNmarginWidth,      10,
        XmNmarginHeight,     10,
        XmNradioBehavior,    TRUE,
        XmNbackground,     textBackground,
        NULL);

    toggleButton = XtVaCreateManagedWidget("alh internal Hi pitch beep",
        xmToggleButtonGadgetClass, rowcol,
        XmNmarginHeight,     0,
        XmNbackground,      textBackground,
        /*1XmNalignment,XmALIGNMENT_CENTER*/
        NULL);
    XmToggleButtonSetState(toggleButton,
        ((audioSetup.audioSource==AUDIO_SOURCE_HI)?TRUE:FALSE),FALSE);
    XtAddCallback(toggleButton, XmNvalueChangedCallback,
        audioSetupAudioSourceChangeCallback, (XtPointer)AUDIO_SOURCE_HI);

    toggleButton = XtVaCreateManagedWidget("alh internal Lo pitch beep",
        xmToggleButtonGadgetClass, rowcol,
        XmNmarginHeight,     0,
        XmNbackground,      textBackground,
        NULL);
    XmToggleButtonSetState(toggleButton,
        ((audioSetup.audioSource==AUDIO_SOURCE_LO)?TRUE:FALSE),FALSE);
    XtAddCallback(toggleButton, XmNvalueChangedCallback,
        audioSetupAudioSourceChangeCallback, (XtPointer)AUDIO_SOURCE_LO);

    toggleButton = XtVaCreateManagedWidget("Au/u-law (.au) file",
        xmToggleButtonGadgetClass, rowcol,
        XmNmarginHeight,     0,
        XmNbackground,      textBackground,
        NULL);
    XmToggleButtonSetState(toggleButton,
        ((audioSetup.audioSource==AUDIO_SOURCE_FILE)?TRUE:FALSE),FALSE);
    XtAddCallback(toggleButton, XmNvalueChangedCallback,
        audioSetupAudioSourceChangeCallback, (XtPointer)AUDIO_SOURCE_FILE);

    XtManageChild(rowcol);
    XtManageChild(frame);

    string = XmStringCreateSimple("Au/u-law (.au) filename");
    label = XtVaCreateManagedWidget("audioFilenamelabel",
        xmLabelGadgetClass,        form,
        XmNlabelString,            string,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              frame,
        NULL);
    XmStringFree(string);

    button = XtVaCreateManagedWidget("Browse",
        xmPushButtonWidgetClass, form,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              frame,
        XmNleftAttachment,         XmATTACH_WIDGET,
        XmNleftWidget,             label,
        XmNrightAttachment,        XmATTACH_FORM,
        XmNshadowThickness,        1,
        NULL);

    filename = XtVaCreateManagedWidget("filename",
        xmTextFieldWidgetClass, form,
        XmNbackground,      textBackground,
        XmNtopAttachment,   XmATTACH_WIDGET,
        XmNtopWidget,       button,
        XmNleftAttachment,  XmATTACH_FORM,
        XmNrightAttachment, XmATTACH_FORM,
        NULL);

    XtAddCallback(button, XmNactivateCallback,
        audioSetupFilenameBrowseCallback, filename);

    XmTextFieldSetString(filename,audioSetup.paudioInfo->filename);

    XtAddCallback(filename, XmNactivateCallback,
        audioSetupFilenameChangeCallback, NULL);

    string = XmStringCreateSimple("Audio Beep Volume");
    label = XtVaCreateManagedWidget("audioVolumelabel",
        xmLabelGadgetClass,        form,
        XmNlabelString,            string,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              filename,
        NULL);
    XmStringFree(string);

    frame = XtVaCreateWidget("frame",
        xmFrameWidgetClass, form,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              label,
        XmNleftAttachment,         XmATTACH_FORM,
        XmNrightAttachment,        XmATTACH_FORM,
        NULL);

    scale = XtVaCreateManagedWidget("VolumeScale",
        xmScaleWidgetClass, frame,
        XmNmaximum,          AUDIO_MAX_GAIN,
        XmNminimum,          AUDIO_MIN_GAIN,
        XmNvalue,            audioSetup.volume,
        XmNshowValue,        True,
        XmNorientation,      XmHORIZONTAL,
        XmNbackground,      textBackground,
        NULL);
    XtAddCallback(scale, XmNvalueChangedCallback,
        audioSetupVolumeChangeCallback, NULL);

    XtManageChild(frame);

    string = XmStringCreateSimple("Test Beep");
    label = XtVaCreateManagedWidget("audioTestlabel",
        xmLabelGadgetClass,        form,
        XmNlabelString,            string,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              frame,
        XmNleftAttachment,         XmATTACH_FORM,
        NULL);
    XmStringFree(string);

    button = XtVaCreateManagedWidget("Beep",
        xmPushButtonWidgetClass, form,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              label,
        XmNleftAttachment,         XmATTACH_FORM,
        XmNrightAttachment,        XmATTACH_FORM,
        XmNshadowThickness,        2,
        NULL);
    XtAddCallback(button, XmNactivateCallback,
        audioSetupTestBeepCallback, NULL);

    /* Set the client data "Dismiss" button's callbacks. */
    audioSetup_items[0].data = (XtPointer)menuButton;

    form1 = createActionButtons(form, audioSetup_items,
        XtNumber(audioSetup_items));
    if (form1) XtVaSetValues(form1,
        XmNtopAttachment,          XmATTACH_WIDGET,
        XmNtopWidget,              button,
        XmNleftAttachment,         XmATTACH_FORM,
        XmNrightAttachment,        XmATTACH_FORM,
        NULL);

    XtManageChild(form);
    XtRealizeWidget(audioSetupDialogShell);
}
Esempio n. 18
0
/******************************************************
  createActionDialog
******************************************************/
void createActionDialog(Widget parent,int dialogType,char *message1,
XtCallbackProc okCallback,XtPointer okParm,XtPointer userParm)
{
	static Widget         dialog = 0; /* make it static for reuse */
	XmString              str,str1,str2,str3;
	static XtCallbackProc oldOkCallback = 0;
	static XtPointer      oldOkParm = 0;

	if (dialog && XtIsManaged(dialog)) XtUnmanageChild(dialog);
	if (!dialogType ) return;

	/* destroy runtimeToplevel dialog so dialog is positioned properly */
	if ( parent && dialog &&
	    XtParent(XtParent(dialog)) != parent) {
		XtDestroyWidget(dialog);
		dialog = 0;
	}

	if (!dialog) {
		dialog = XmCreateMessageDialog(parent, "Dialog", NULL, 0);
		XtSetSensitive(XmMessageBoxGetChild(dialog,XmDIALOG_HELP_BUTTON),FALSE);
		XtAddCallback(dialog,XmNcancelCallback,(XtCallbackProc) XtUnmanageChild,NULL);

	} else {
		XtRemoveCallback(dialog,XmNokCallback,oldOkCallback,(XtPointer)oldOkParm);
	}

	switch(dialogType) {
	case XmDIALOG_WARNING:
		str = XmStringCreateSimple("WarningDialog");
		break;
	case XmDIALOG_ERROR:
		str = XmStringCreateSimple("ErrorDialog");
		break;
	case XmDIALOG_INFORMATION:
		str = XmStringCreateSimple("InformationDialog");
		break;
	case XmDIALOG_MESSAGE:
		str = XmStringCreateSimple("MessageDialog");
		break;
	case XmDIALOG_QUESTION:
		str = XmStringCreateSimple("QuestionDialog");
		break;
	case XmDIALOG_WORKING:
		str = XmStringCreateSimple("WorkingDialog");
		break;
	default:
		str = XmStringCreateSimple("InformationDialog");
		break;
	}

	str1 = XmStringCreateLtoR("ALH ",XmFONTLIST_DEFAULT_TAG);
	str3 = XmStringConcat(str1,str);

	str2=XmStringCreateLtoR(message1,XmSTRING_DEFAULT_CHARSET);
	XtVaSetValues(dialog,
	    XmNuserData,      userParm,
	    XmNdialogType,  dialogType,
	    XmNdialogTitle, str3,
	    XmNmessageString, str2,
	    (XtPointer)NULL);
	XmStringFree(str);
	XmStringFree(str2);

	XtAddCallback(dialog,XmNokCallback,okCallback,okParm);
	oldOkCallback = okCallback;
	oldOkParm = okParm;

	XtManageChild(dialog);
	XFlush(display);
	/*
	     XmUpdateDisplay(dialog);
	*/
	return;
}
Esempio n. 19
0
int main (int argc, char *argv[])
{
    Widget topWidget;
    Widget mainForm;
    Widget userForm;

    /* Menu Stuff */
    Widget menuBar, helpMenu;

    static String fallback_resources[] = { 
    	"*sgiMode: True",
    	"*useSchemes: all",
    	NULL }; 

    topWidget = XtVaAppInitialize(&nebulaIrcAppContext, "Nebula IRC",
	    NULL, 0, /* no command line options */
	    &argc, argv,
	    fallback_resources, /* fallback resource list */
	    NULL);

    mainWindow = XtVaCreateManagedWidget("main_window",
    	xmMainWindowWidgetClass, topWidget,
    	XmNcommandWindowLocation, XmCOMMAND_BELOW_WORKSPACE,
	XmNwidth, 600,
	XmNheight, 500,
    	NULL);

    /* create menu bar */
    {
	XmString fileMenuStr, userMenuStr, helpMenuStr;
	
    	fileMenuStr = XM_STRING_CREATE("File");
	userMenuStr = XM_STRING_CREATE("User");
    	helpMenuStr = XM_STRING_CREATE("Help");

    	menuBar = XmVaCreateSimpleMenuBar(mainWindow, "menubar",
    	    XmVaCASCADEBUTTON, fileMenuStr, 'F',
	    XmVaCASCADEBUTTON, userMenuStr, 'U',
    	    NULL);

    	XmStringFree(fileMenuStr);
	XmStringFree(userMenuStr);
    	XmStringFree(helpMenuStr);
    }
    
    /* File Menu */
    {
    	XmString prefStr;
    	XmString saveConvStr;
	XmString quitStr;
    	
    	prefStr = XM_STRING_CREATE("Preferences...");
	saveConvStr = XM_STRING_CREATE("Save Conversation...");
    	quitStr = XM_STRING_CREATE("Quit");
    	XmVaCreateSimplePulldownMenu(menuBar, "file_menu", 0,
    	    fileMenuCall,
	    XmVaPUSHBUTTON, prefStr, 'P', NULL, NULL,
	    XmVaPUSHBUTTON, saveConvStr, 'S', NULL, NULL,
    	    XmVaPUSHBUTTON, quitStr, 'Q', NULL, NULL,
    	    NULL);
    	XmStringFree(prefStr);
	XmStringFree(saveConvStr);
	XmStringFree(quitStr);
    }
    /* User Menu */
    {
    	XmString whoisStr;
    	XmString versionStr;
	XmString opStr;
	XmString deopStr;
    	
    	whoisStr = XM_STRING_CREATE("Whois");
	versionStr = XM_STRING_CREATE("Client version");
    	opStr = XM_STRING_CREATE("Op");
	deopStr = XM_STRING_CREATE("Deop");
    	XmVaCreateSimplePulldownMenu(menuBar, "user_menu", 1,
    	    userMenuCall,
	    XmVaPUSHBUTTON, whoisStr, 'W', NULL, NULL,
	    XmVaPUSHBUTTON, versionStr, '\0', NULL, NULL,
    	    XmVaPUSHBUTTON, opStr, 'O', NULL, NULL,
	    XmVaPUSHBUTTON, deopStr, 'D', NULL, NULL,
    	    NULL);
    	XmStringFree(whoisStr);
	XmStringFree(versionStr);
	XmStringFree(opStr);
	XmStringFree(deopStr);
    }
    /* Help Menu */
    {
	XmString helpCommandStr;
	XmString aboutStr;
	
	helpCommandStr = XM_STRING_CREATE("Commands...");
	aboutStr = XM_STRING_CREATE("About...");
   	helpMenu = XtVaCreateManagedWidget("Help",
    	    xmCascadeButtonWidgetClass, menuBar,
    	    XmNmnemonic, 'H',
    	    NULL);
   	XmVaCreateSimplePulldownMenu(menuBar, "Help", 2,
    	    helpMenuCall,
    	    XmVaPUSHBUTTON, aboutStr, 'A', NULL, NULL,
	    XmVaPUSHBUTTON, helpCommandStr, 'C', NULL, NULL,
    	    NULL);
	XmStringFree(helpCommandStr);
	XmStringFree(aboutStr);

	/* now set the help button */
    	XtVaSetValues(menuBar, XmNmenuHelpWidget, helpMenu, NULL);
    }
    
    /* now manage the menu bar */ 
    XtManageChild(menuBar);
    
    /* create a form */
    mainForm = XtVaCreateWidget("form", xmFormWidgetClass, mainWindow, XmNfractionBase, 3, NULL);

    /* vertical split user form */
    userForm = XtVaCreateWidget("userform", xmFormWidgetClass, mainForm,
    	    XmNfractionBase, 5,
	    XmNtopAttachment, XmATTACH_FORM,
	    XmNleftAttachment, XmATTACH_FORM,
	    XmNbottomAttachment, XmATTACH_FORM,
	    XmNrightAttachment, XmATTACH_FORM,
	    NULL);
    
    /* output area */
    {
   	Arg args[12];

    	XtSetArg(args[0], XmNeditable, False);
	XtSetArg(args[1], XmNeditMode, XmMULTI_LINE_EDIT);
	XtSetArg(args[2], XmNscrollHorizontal, False);
	XtSetArg(args[3], XmNwordWrap, True);
	XtSetArg(args[4], XmNtopAttachment, XmATTACH_POSITION);
	XtSetArg(args[5], XmNtopPosition, 0);
	XtSetArg(args[6], XmNbottomAttachment, XmATTACH_POSITION);
	XtSetArg(args[7], XmNbottomPosition, 5);
	XtSetArg(args[8], XmNleftAttachment, XmATTACH_POSITION);
	XtSetArg(args[9], XmNleftPosition, 0);
	XtSetArg(args[10], XmNrightAttachment, XmATTACH_POSITION);
	XtSetArg(args[11], XmNrightPosition, 4);
    	outputArea = XmCreateScrolledText(userForm, "output", args, 12);
	
	if (outputArea == NULL)
	    perror("outputArea: ");
	XtManageChild(outputArea);
    }
    
    /* user list at left */
    {
    	Arg args[9];
	
    	XtSetArg(args[0], XmNtopAttachment, XmATTACH_POSITION);
	XtSetArg(args[1], XmNtopPosition, 0);
	XtSetArg(args[2], XmNbottomAttachment, XmATTACH_POSITION);
	XtSetArg(args[3], XmNbottomPosition, 5);
	XtSetArg(args[4], XmNleftAttachment, XmATTACH_POSITION);
	XtSetArg(args[5], XmNleftPosition, 4);
	XtSetArg(args[6], XmNrightAttachment, XmATTACH_POSITION);
	XtSetArg(args[7], XmNrightPosition, 5);
	XtSetArg(args[8], XmNselectionPolicy, XmSINGLE_SELECT);
    	userList = XmCreateScrolledList(userForm, "list", args, 9);
	XtAddCallback(userList, XmNsingleSelectionCallback, userListSelectCbk, NULL);
	XtManageChild(userList);
    }
    XtManageChild(userForm);
    XtManageChild(mainForm);
    
    /* Command line area */
    commandInput = XtVaCreateWidget("command",
    	xmTextFieldWidgetClass, mainWindow,
    	XmNmaxLength, MAX_INPUT_LEN,
    	NULL);
    XtAddCallback(commandInput, XmNactivateCallback, commandInputCall, NULL);
    XtManageChild(commandInput);
    
    XtVaSetValues(mainWindow,
	    XmNmenuBar, menuBar,
	    XmNworkWindow, mainForm,
	    XmNcommandWindow, commandInput,
	    NULL);
    
    XtManageChild(mainWindow);
    XtRealizeWidget(topWidget);

    /* initialize System Status */
    sysState.isConnected = NO;
    
    /* get some preferences */
    getStartupPrefs(mainWindow);
    
    /* set focus to input area */
    /* For Motif 1.0 we should use _XmGrabTheFocus(target) according to FAQ */
    XmProcessTraversal(commandInput, XmTRAVERSE_CURRENT);
    
    /* initialize hostname and system info */
    /* should switch back to ARCHOS if uname not available */
    {
    	struct utsname sysInfo;
	char           tempName[2*SYSINFO_LEN];
	
    	gethostname(sysState.myHostName, MAXHOSTNAMELEN);
    	uname(&sysInfo);
	sprintf(tempName, "%s %s running on %s", sysInfo.sysname, sysInfo.release, sysInfo.machine);
	tempName[SYSINFO_LEN] = '\0';
	strcpy(sysState.systemInfo, tempName);
    }
    
    /* get the user login name from unix */
    {
        char *tempName;

        tempName = getenv("USER");
        if (tempName == NULL)
            tempName = getenv("LOGNAME");
        if (strlen(tempName) > MAX_NAME_LEN || tempName == NULL)
        {
            strcpy(sysState.myUnixname, "joesmith");
            printf("Failed to get a proper Unix login name. Using: %s\n", sysState.myUnixname); 
        }
        strcpy(sysState.myUnixname, tempName);
    }
 
    /* create unmanaged dialogs */
    createAboutBox(mainWindow);
    createCommandsHelpBox(mainWindow);  
    
    while(1)
    {
    	XEvent theEvent;
	XtAppNextEvent(nebulaIrcAppContext, &theEvent);
	XtDispatchEvent(&theEvent);
    }
}
Esempio n. 20
0
/******************************************************
  Error message popup
******************************************************/
void errMsg(const char *fmt, ...)
{
	XmString cstring,cstringOld,cstringNew;
	va_list vargs;
	static char lstring[1024];  /* DANGER: Fixed buffer size */
	static int warningboxMessages = 0;
	int nargs=10;
	Arg args[10];
    size_t len;
    struct tm * tms;
    time_t timeofday;

    timeofday = time(0L);
    tms = localtime(&timeofday);
    len = strftime(lstring,TIME_SIZE,"%Y/%m/%d %H:%M ",tms);
	va_start(vargs,fmt);
	vsprintf(&lstring[TIME_SIZE-1],fmt,vargs);
	va_end(vargs);

	if(lstring[TIME_SIZE-1] == '\0') return;

	alLogOpModMessage(0,0,&lstring[TIME_SIZE-1]);

	if (_no_error_popup) {
		return;
	}

	if (warningbox) {

		if (warningboxMessages > 30) return;

		cstring=XmStringCreateLtoR(lstring,XmSTRING_DEFAULT_CHARSET);
		XtVaGetValues(warningbox, XmNmessageString, &cstringOld, NULL);
		cstringNew = XmStringConcat(cstringOld,cstring);
		XmStringFree(cstring);
		XmStringFree(cstringOld);
		if (warningboxMessages == 30){
			cstring=XmStringCreateLtoR(
				"\nOnly first 30 messages are displayed and logged\n",
				XmSTRING_DEFAULT_CHARSET);
			cstringOld = cstringNew;
			cstringNew = XmStringConcat(cstringOld,cstring);
			XmStringFree(cstring);
			XmStringFree(cstringOld);
		}
		XtVaSetValues(warningbox, XmNmessageString, cstringNew, NULL);
		XmStringFree(cstringNew);
		warningboxMessages += 1;
		XtManageChild(warningbox);
	} else {
		XBell(display,50); 
		XBell(display,50); 
		XBell(display,50);
		cstring=XmStringCreateLtoR(lstring,XmSTRING_DEFAULT_CHARSET);
		nargs=0;
		XtSetArg(args[nargs],XmNtitle,"ALH Warning"); 
		nargs++;
		XtSetArg(args[nargs],XmNmessageString,cstring); 
		nargs++;
		warningbox=XmCreateWarningDialog(topLevelShell,"warningMessage",
		    args,nargs);
		XmStringFree(cstring);
		XtDestroyWidget(XmMessageBoxGetChild(warningbox,XmDIALOG_CANCEL_BUTTON));
		XtDestroyWidget(XmMessageBoxGetChild(warningbox,XmDIALOG_HELP_BUTTON));
		/*XtAddCallback(warningbox,XmNokCallback,logMessageString,NULL);*/
		XtAddCallback(warningbox,XmNokCallback,killWidget,NULL);
		warningboxMessages = 1;
		XtManageChild(warningbox);
	}
}
Esempio n. 21
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();
}
Esempio n. 22
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);
}
Esempio n. 23
0
int main( int argc, char *argv [] )
{
  Widget form;
  Widget frame;
  Widget frame_rowcol;
  Widget control_rowcol;
  Widget rowcol;
  Widget button;
  Widget faa_button1;
  Widget faa_button2;
  Widget label;
  Widget media_toggle;
  Widget faa_channel_toggle;
  Arg args[ 16 ];
  int n;

  /* Initialization HCI. */

  HCI_init( argc, argv, HCI_SAVE_ADAPT_TASK );

  Top_widget = HCI_get_top_widget();

  /* Add redundancy information if site FAA redundant */

  if( HCI_get_system() == HCI_FAA_SYSTEM )
  {
    channel_number = ORPGRED_channel_num( ORPGRED_MY_CHANNEL );
  }

  /* Set args for all toggle buttons. */

  n = 0;
  XtSetArg( args [n], XmNforeground, hci_get_read_color( TEXT_FOREGROUND ));
  n++;
  XtSetArg( args [n], XmNbackground, hci_get_read_color( BACKGROUND_COLOR1 ));
  n++;
  XtSetArg( args [n], XmNfontList, hci_get_fontlist (LIST));
  n++;
  XtSetArg( args [n], XmNpacking, XmPACK_TIGHT);
  n++;
  XtSetArg( args [n], XmNorientation, XmHORIZONTAL );
  n++;

  /* Use a form widget to be used as the manager for widgets *
   * in the top level window.                                */

  form = XtVaCreateManagedWidget( "form",
           xmFormWidgetClass,	Top_widget,
           XmNbackground,	hci_get_read_color( BACKGROUND_COLOR1 ),
           NULL );

  /* Use a rowcolumn widget at the top to manage the Close button. */

  control_rowcol = XtVaCreateManagedWidget( "control_rowcol",
       xmRowColumnWidgetClass,	form,
       XmNbackground,		hci_get_read_color( BACKGROUND_COLOR1 ),
       XmNorientation,		XmHORIZONTAL,
       XmNpacking,		XmPACK_TIGHT,
       XmNtopAttachment,	XmATTACH_FORM,
       XmNleftAttachment,	XmATTACH_FORM,
       XmNrightAttachment,	XmATTACH_FORM,
       NULL );

  button = XtVaCreateManagedWidget( "Close",
          xmPushButtonWidgetClass, control_rowcol,
          XmNforeground,	hci_get_read_color( BUTTON_FOREGROUND ),
          XmNbackground,	hci_get_read_color( BUTTON_BACKGROUND ),
          XmNfontList,		hci_get_fontlist( LIST ),
          NULL );

  XtAddCallback( button,
                 XmNactivateCallback, save_adapt_close, NULL );

  /* Build the widgets for saving adaptation data. */

  frame = XtVaCreateManagedWidget( "frame",
          xmFrameWidgetClass,     form,
          XmNtopAttachment,       XmATTACH_WIDGET,
          XmNtopWidget,           control_rowcol,
          XmNleftAttachment,      XmATTACH_FORM,
          XmNrightAttachment,     XmATTACH_FORM,
          XmNbottomAttachment,    XmATTACH_FORM,
          NULL );

  frame_rowcol = XtVaCreateManagedWidget( "frame_rowcol",
          xmRowColumnWidgetClass, frame,
          XmNbackground,          hci_get_read_color( BACKGROUND_COLOR1 ),                XmNorientation,         XmVERTICAL,
          XmNpacking,             XmPACK_TIGHT,
          XmNnumColumns,          1,
          XmNentryAlignment,      XmALIGNMENT_CENTER,
          NULL );

  /* If this is an FAA system, build toggle button to let *
   * user choose channel one or channel two.              */

  if( HCI_get_system() == HCI_FAA_SYSTEM )
  {
    rowcol = XtVaCreateManagedWidget( "faa_rowcol",
          xmRowColumnWidgetClass, frame_rowcol,
          XmNbackground,          hci_get_read_color( BACKGROUND_COLOR1 ),
          XmNorientation,         XmHORIZONTAL,
          XmNpacking,             XmPACK_TIGHT,
          XmNnumColumns,          1,
          XmNentryAlignment,      XmALIGNMENT_CENTER,
          NULL );

    label = XtVaCreateManagedWidget( "FAA Channel: ",
          xmLabelWidgetClass,	rowcol,
          XmNforeground,	hci_get_read_color( TEXT_FOREGROUND ),
          XmNbackground,	hci_get_read_color( BACKGROUND_COLOR1 ),
          XmNfontList,		hci_get_fontlist( LIST ),
          NULL );

    faa_channel_toggle = XmCreateRadioBox( rowcol, "faa_channel", args, n );

    faa_button1 = XtVaCreateManagedWidget( "RPGA 1",
        xmToggleButtonWidgetClass,	faa_channel_toggle,
        XmNselectColor,			hci_get_read_color( WHITE ),
        XmNforeground,			hci_get_read_color( TEXT_FOREGROUND ),
        XmNbackground,			hci_get_read_color( BACKGROUND_COLOR1 ),
        XmNfontList,			hci_get_fontlist( LIST ),
        XmNset,				True,
        NULL);

    XtAddCallback( faa_button1,
                   XmNarmCallback,  faa_channel_toggle_callback,
                   (XtPointer) 1 );

    faa_button2 = XtVaCreateManagedWidget( "RPGA 2",
        xmToggleButtonWidgetClass,	faa_channel_toggle,
        XmNselectColor,			hci_get_read_color( WHITE ),
        XmNforeground,			hci_get_read_color( TEXT_FOREGROUND ),
        XmNbackground,			hci_get_read_color( BACKGROUND_COLOR1 ),
        XmNfontList,			hci_get_fontlist( LIST ),
        XmNset,				False,
        NULL);

    XtAddCallback( faa_button2,
                   XmNarmCallback,  faa_channel_toggle_callback,
                   (XtPointer) 2 );

    if( channel_number == 1 )
    {
      XtVaSetValues( faa_button1, XmNset, True, NULL );
      XtVaSetValues( faa_button2, XmNset, False, NULL );
    }
    else if( channel_number == 2 )
    {
      XtVaSetValues( faa_button1, XmNset, False, NULL );
      XtVaSetValues( faa_button2, XmNset, True, NULL );
    }

    XtManageChild( faa_channel_toggle );
  }

  if( ! ORPGMISC_is_operational() )
  {
    /* Build the toggle for selecting media type. */

    rowcol = XtVaCreateManagedWidget( "media_rowcol",
            xmRowColumnWidgetClass, frame_rowcol,
            XmNbackground,          hci_get_read_color( BACKGROUND_COLOR1 ),
            XmNorientation,         XmHORIZONTAL,
            XmNpacking,             XmPACK_TIGHT,
            XmNnumColumns,          1,
            XmNentryAlignment,      XmALIGNMENT_CENTER,
            NULL );

    label = XtVaCreateManagedWidget( "Select Media:   ",
            xmLabelWidgetClass,   rowcol,
            XmNforeground,        hci_get_read_color( TEXT_FOREGROUND ),
            XmNbackground,        hci_get_read_color( BACKGROUND_COLOR1 ),
            XmNfontList,          hci_get_fontlist( LIST ),
            NULL );

    media_toggle = XmCreateRadioBox( rowcol, "media_toggle", args, n );
  
    button = XtVaCreateManagedWidget( "Floppy",
        xmToggleButtonWidgetClass,      media_toggle,
        XmNselectColor,                 hci_get_read_color( WHITE ),
        XmNforeground,                  hci_get_read_color( TEXT_FOREGROUND ),
        XmNbackground,                  hci_get_read_color( BACKGROUND_COLOR1 ),
        XmNfontList,                    hci_get_fontlist( LIST ),
        XmNset,                         False,
        NULL);

    XtAddCallback( button,
                   XmNarmCallback,  media_toggle_callback,
                   (XtPointer) HCI_FLOPPY_MEDIA_FLAG );

    button = XtVaCreateManagedWidget( "CD",
        xmToggleButtonWidgetClass,      media_toggle,
        XmNselectColor,                 hci_get_read_color( WHITE ),
        XmNforeground,                  hci_get_read_color( TEXT_FOREGROUND ),
        XmNbackground,                  hci_get_read_color( BACKGROUND_COLOR1 ),
        XmNfontList,                    hci_get_fontlist( LIST ),
        XmNset,                         True,
      NULL);

    XtAddCallback( button,
                   XmNarmCallback,  media_toggle_callback,
                   (XtPointer) HCI_CD_MEDIA_FLAG );

    XtManageChild( media_toggle );
  }

  /* Build "Start" button to actually start the process. */

  rowcol = XtVaCreateManagedWidget( "start_rowcol",
        xmRowColumnWidgetClass, frame_rowcol,
        XmNbackground,          hci_get_read_color( BACKGROUND_COLOR1 ),
        XmNorientation,         XmHORIZONTAL,
        XmNpacking,             XmPACK_TIGHT,
        XmNnumColumns,          1,
        XmNentryAlignment,      XmALIGNMENT_CENTER,
        NULL );

  label = XtVaCreateManagedWidget( "Insert Media into Media Drive and Click",
          xmLabelWidgetClass,	rowcol,
          XmNforeground,	hci_get_read_color( TEXT_FOREGROUND ),
          XmNbackground,	hci_get_read_color( BACKGROUND_COLOR1 ),
          XmNfontList,		hci_get_fontlist( LIST ),
          NULL );

  start_button = XtVaCreateManagedWidget( "Start",
          xmPushButtonWidgetClass, rowcol,
          XmNforeground,	hci_get_read_color( BUTTON_FOREGROUND ),
          XmNbackground,	hci_get_read_color( BUTTON_BACKGROUND ),
          XmNfontList,		hci_get_fontlist( LIST ),
          NULL );

  XtAddCallback( start_button,
                 XmNactivateCallback, save_adapt_start, NULL );

  XtRealizeWidget( Top_widget );

  /* Start HCI loop. */

  HCI_start( timer_proc, HCI_ONE_AND_HALF_SECOND, NO_RESIZE_HCI );

  return 0;
}
Esempio n. 24
0
/****************************************************************************
 * Function:	    void DisplayMan()
 *
 * Parameters:      
 *
 * Return Value:    Void.
 *
 * Purpose: 	    Displays a UNIX man page in a quick help dialog.
 *
 ****************************************************************************/
void DisplayMan(
    Widget  parent,
    char    *man)

{

  Arg  args[20];
  int    n;
  Widget helpWidget;
  char *title;

  XmUpdateDisplay(topLevel);
 


  if (manWidget == NULL)
    {    
      /* Create the QuickHelpDialog widget for help on help */
      title = XtNewString(man);
 
      n =0;
      XtSetArg (args[n], XmNuseAsyncGeometry, True);         n++;
      XtSetArg (args[n], XmNtitle, title);                   n++;
      XtSetArg (args[n], DtNhelpType,DtHELP_TYPE_MAN_PAGE); n++; 
      XtSetArg (args[n], DtNmanPage, man);                   n++;
      manWidget = DtCreateHelpQuickDialog(topLevel,"manBox", args, n);
      XtFree((char*) title);


      XtAddCallback(manWidget, DtNcloseCallback,
                    CloseMainCB, (XtPointer) manWidget);
 
      /* Add the popup position callback to our man dialog */
      XtAddCallback (XtParent(manWidget), XmNpopupCallback,
                    (XtCallbackProc)HelpMapCB, 
                    (XtPointer)topLevel);
 



      /* We do not want a help button for now so we unmap it */     
      helpWidget = DtHelpQuickDialogGetChild (manWidget,
                              DtHELP_QUICK_HELP_BUTTON);
      XtUnmanageChild (helpWidget);

      XtManageChild(manWidget);  
    }
  else
    {
       TurnOnHourGlass(manWidget);
  
       /* We already have a quick help dialog so re-use it */
       n = 0;
       XtSetArg (args[n], DtNhelpType,DtHELP_TYPE_MAN_PAGE); n++; 
       XtSetArg (args[n], DtNmanPage, man);                   n++;
     
       XtSetValues(manWidget, args, n);
       

       title = XtNewString(man);
       n = 0;
       XtSetArg (args[n], XmNtitle, title);                   n++;
       XtSetValues(XtParent(manWidget), args, n);
       XtFree((char*) title);

       XtManageChild(manWidget); 
       XtMapWidget(XtParent(manWidget));    
       XRaiseWindow(XtDisplay(parent), XtWindow(XtParent(manWidget)));
       TurnOffHourGlass(manWidget);       

     }

}
Esempio n. 25
0
int open_ants(Widget w, char *fn, char *cmd)
{
    Widget list;
    Arg wargs[10];
    XmString *xmstr;
    char *p;
    string stmp, buf, user;
    int i, n, nindx, df, rec=0, bl_len;
    int err;
    size_t size;
    FILE *pdf;
    static ANTS ants;
    
    void send_line();
    char *getScanStr();
    
    strcpy(dfilname, fn);
    strcpy(stmp, fn);
    
    p = strtok(stmp, "/");
    while (p) {
        strcpy(buf, p);
        p = strtok(NULL, "/");
    }
    
    sscanf(buf, "DF%2d%4d.%s", &df, &bl_len, user);
    
    if (bl_len == 0) bl_len = 3;

    pdf = OpenDfil(df, bl_len, user, dfilname);
    if (!pdf) {
        sprintf(buf, "Open POPS file: cannot open dfile %s.", dfilname);
        send_line(buf);
        return 1;
    }
    
    nindx = ReadDfilIndex(pdf, indx);
    if (nindx <= 0) {
        if (nindx == 0) {
            sprintf(buf, "Open POPS file: dfile %s is empty.", dfilname);
        } else {
            sprintf(buf, "Open POPS file: dfile %s is corrupt.", dfilname);
        }
        send_line(buf);
        fclose(pdf);
        return 1;
    }
    
    i = 0;
    while (i < 500 && indx[i] != 0) {
        i++;
    }
    nindx = i;
    
    sprintf(buf, "POPS dfile %s (%d scans) is opened.", dfilname, nindx);
    send_line(buf);
    
    size = (size_t)(bl_len*DFILBLOCK)*sizeof(DFWORD);
    if (!itwh)
        itwh = (DFWORD *)malloc(size);
    else
        itwh = (DFWORD *)realloc(itwh, size);
    if (!itwh) {
        sprintf(buf, "Open POPS -- can't allocate itwh[%d]",
                bl_len*DFILBLOCK);
        send_line(buf);
        fclose(pdf);
        return 1;
    }
    
    strcpy(type_of_seq, cmd);
    
    if (strcmp(cmd, "mapants2") == 0 ||
        strcmp(cmd, "ants2")    == 0 ||
        strcmp(cmd, "seqants2") == 0 ||
        strcmp(cmd, "appmapants2") == 0 ||
        strcmp(cmd, "appseqants2") == 0)
        rec = 1;

    ants.pdf    = pdf;
    ants.bl_len = bl_len;
    ants.df     = df;
    ants.rec    = rec;
    ants.fname  = dfilname;
    ants.nscans = nindx;
    
    xmstr = (XmString *) XtMalloc(nindx * sizeof(XmString));
    if (!xmstr) {
        sprintf(buf, "Open POPS -- can't allocate xmstr[%d]", nindx);
        send_line(buf);
        fclose(pdf);
        return 1;
    }

    for (i=0; i<nindx; i++) {
        err = GetDfilBlock(pdf, i+1, bl_len, itwh);
        if (err != 0) {
            sprintf(buf, "Open POPS -- can't read read block %d", i+1);
            send_line(buf);
            fclose(pdf);
            return ret_open_ants(xmstr, nindx, err);
        }
        filltwh(&OnScan, &XScan, rec); 
        OnScan.Slength = HEADER + 2*OnScan.NChannel;
        xmstr[i] = MKSTRING(getScanStr(i));
    }

    n = 0;
    if (nindx > 0) {
        XtSetArg(wargs[n], XmNitemCount, nindx); n++;
        XtSetArg(wargs[n], XmNitems, xmstr); n++;
        if (nindx <= 30) {
            XtSetArg(wargs[n], XmNvisibleItemCount, nindx); n++;
        } else {
            XtSetArg(wargs[n], XmNvisibleItemCount, 30); n++;
        }
    }
    XtSetArg(wargs[n], XmNfontList, gp->flist10); n++;
    if (strncmp(cmd, "mapants", 7)==0 ||
        strncmp(cmd, "seqants", 7)==0 ||
        strncmp(cmd, "appmapants", 10)==0 ||
        strncmp(cmd, "appseqants", 10)==0) {
        XtSetArg(wargs[n], XmNselectionPolicy, XmEXTENDED_SELECT); n++;
    }
    
    list = create_list_dialog(w, dfilname, &ants, wargs, n);

    if (strncmp(cmd, "mapants", 7)==0 ||
        strncmp(cmd, "seqants", 7)==0 ||
        strncmp(cmd, "appmapants", 10)==0 ||
        strncmp(cmd, "appseqants", 10)==0) {
        XtAddCallback(list, XmNextendedSelectionCallback,
                      (XtCallbackProc)selectCB, &ants);
        XtAddCallback(list, XmNmultipleSelectionCallback,
                      (XtCallbackProc)selectCB, &ants);
    } else
        XtAddCallback(list, XmNbrowseSelectionCallback,
                      (XtCallbackProc)selectCB, &ants);

    return ret_open_ants(xmstr, nindx, 0);
}
Esempio n. 26
0
/****************************************************************************
 * Function:	    void DisplayTopic(
 *                              Widget parent,
 *                              char *helpVolume,
 *                              char *locationId)
 *
 * Parameters:      
 *
 * Return Value:    Void.
 *
 * Purpose: 	    Creats and displays a new help dialog w/the requested help
 *                  volume and topic.
 *
 ****************************************************************************/
void DisplayTopic(
    Widget  parent,
    char    *helpVolume,
    char    *locationId)

{
  Arg	 	args[10];	
  int           n;

 CacheListStruct *pCurrentNode = NULL;
  Boolean       cachedNode = FALSE;


  /* Get a inuse node if we have one or a Cached one */
  cachedNode = GetFromCache(parent, &pCurrentNode);


  /* If we got a free one from the Cache, use it */
  /* Set Values on current free one, then map it */
  if (cachedNode)
    {
       n = 0;
       XtSetArg (args[n], XmNtitle, "HelpDemo Help");          n++;
       if (helpVolume != NULL)
         {
           XtSetArg (args[n],DtNhelpVolume,helpVolume);     n++; 
         }
       XtSetArg (args[n], DtNlocationId,locationId);        n++;
       XtSetValues(pCurrentNode->helpDialog, args, n);
  
       XtManageChild(pCurrentNode->helpDialog);    
       XtMapWidget(XtParent(pCurrentNode->helpDialog));
     }
   else
     {
       while (!XtIsSubclass(parent, applicationShellWidgetClass))
         parent = XtParent(parent);
     


        /* Build a new one in our cached list */
        n = 0;
        XtSetArg (args[n], XmNtitle, "Helpdemo Help");          n++;
       if (helpVolume != NULL)
         {
           XtSetArg (args[n],DtNhelpVolume,helpVolume);     n++; 
         }
        XtSetArg (args[n], DtNlocationId,locationId);        n++;
        pCurrentNode->helpDialog =  
                   DtCreateHelpDialog(parent, "helpWidget", args, n);


        XtAddCallback(pCurrentNode->helpDialog, DtNhyperLinkCallback,
                       ProcessLinkCB, NULL);
             
        XtAddCallback(pCurrentNode->helpDialog, DtNcloseCallback,
                      CloseHelpCB, (XtPointer) pCurrentNode->helpDialog);

        XtManageChild(pCurrentNode->helpDialog);    
        XtMapWidget(XtParent(pCurrentNode->helpDialog));
     }
}
Esempio n. 27
0
static int motListMapMethod(Ihandle* ih)
{
  int num_args = 0;
  Arg args[30];
  Widget parent = iupChildTreeGetNativeParentHandle(ih);
  char* child_id = iupDialogGetChildIdStr(ih);

  if (ih->data->is_dropdown || ih->data->has_editbox)
  {
    /* could not set XmNmappedWhenManaged to False because the list and the edit box where not displayed */
    /* iupMOT_SETARG(args, num_args, XmNmappedWhenManaged, False); */
    iupMOT_SETARG(args, num_args, XmNx, 0);  /* x-position */
    iupMOT_SETARG(args, num_args, XmNy, 0);  /* y-position */
    iupMOT_SETARG(args, num_args, XmNwidth, 10);  /* default width to avoid 0 */
    iupMOT_SETARG(args, num_args, XmNheight, 10); /* default height to avoid 0 */
    iupMOT_SETARG(args, num_args, XmNmarginHeight, 0);
    iupMOT_SETARG(args, num_args, XmNmarginWidth, 0);

    if (iupAttribGetBoolean(ih, "CANFOCUS"))
      iupMOT_SETARG(args, num_args, XmNtraversalOn, True);
    else
      iupMOT_SETARG(args, num_args, XmNtraversalOn, False);

    iupMOT_SETARG(args, num_args, XmNnavigationType, XmTAB_GROUP);
    iupMOT_SETARG(args, num_args, XmNhighlightThickness, 2);
    iupMOT_SETARG(args, num_args, XmNshadowThickness, 2);

    if (ih->data->has_editbox)
    {
      if (ih->data->is_dropdown)
        iupMOT_SETARG(args, num_args, XmNcomboBoxType, XmDROP_DOWN_COMBO_BOX);  /* hidden-list+edit */
      else
        iupMOT_SETARG(args, num_args, XmNcomboBoxType, XmCOMBO_BOX);  /* visible-list+edit */
    }
    else
      iupMOT_SETARG(args, num_args, XmNcomboBoxType, XmDROP_DOWN_LIST);   /* hidden-list */

    /* XmComboBoxWidget inherits from XmManager, 
       so it is a container with the actual list inside */

    ih->handle = XtCreateManagedWidget(
      child_id,  /* child identifier */
      xmComboBoxWidgetClass, /* widget class */
      parent,                      /* widget parent */
      args, num_args);
  }
  else
  {
    Widget sb_win;

    /* Create the scrolled window */

    iupMOT_SETARG(args, num_args, XmNmappedWhenManaged, False);  /* not visible when managed */
    iupMOT_SETARG(args, num_args, XmNscrollingPolicy, XmAPPLICATION_DEFINED);
    iupMOT_SETARG(args, num_args, XmNvisualPolicy, XmVARIABLE);
    iupMOT_SETARG(args, num_args, XmNscrollBarDisplayPolicy, XmSTATIC);   /* can NOT be XmAS_NEEDED because XmAPPLICATION_DEFINED */
    iupMOT_SETARG(args, num_args, XmNspacing, 0); /* no space between scrollbars and text */
    iupMOT_SETARG(args, num_args, XmNborderWidth, 0);
    iupMOT_SETARG(args, num_args, XmNshadowThickness, 0);
    
    sb_win = XtCreateManagedWidget(
      child_id,  /* child identifier */
      xmScrolledWindowWidgetClass, /* widget class */
      parent,                      /* widget parent */
      args, num_args);

    if (!sb_win)
      return IUP_ERROR;

    parent = sb_win;
    child_id = "list";

    /* Create the list */

    num_args = 0;
    iupMOT_SETARG(args, num_args, XmNx, 0);  /* x-position */
    iupMOT_SETARG(args, num_args, XmNy, 0);  /* y-position */
    iupMOT_SETARG(args, num_args, XmNwidth, 10);  /* default width to avoid 0 */
    iupMOT_SETARG(args, num_args, XmNheight, 10); /* default height to avoid 0 */

    if (iupAttribGetBoolean(ih, "CANFOCUS"))
      iupMOT_SETARG(args, num_args, XmNtraversalOn, True);
    else
      iupMOT_SETARG(args, num_args, XmNtraversalOn, False);

    iupMOT_SETARG(args, num_args, XmNnavigationType, XmTAB_GROUP);
    iupMOT_SETARG(args, num_args, XmNhighlightThickness, 2);
    iupMOT_SETARG(args, num_args, XmNshadowThickness, 2);

    iupMOT_SETARG(args, num_args, XmNlistMarginHeight, 0);  /* default padding */
    iupMOT_SETARG(args, num_args, XmNlistMarginWidth, 0);
    iupMOT_SETARG(args, num_args, XmNlistSpacing, 0);
    iupMOT_SETARG(args, num_args, XmNlistSizePolicy, XmCONSTANT);  /* don't grow to fit, add scrollbar */

    if (ih->data->is_multiple)
      iupMOT_SETARG(args, num_args, XmNselectionPolicy, XmEXTENDED_SELECT);
    else
      iupMOT_SETARG(args, num_args, XmNselectionPolicy, XmBROWSE_SELECT);

    if (iupAttribGetBoolean(ih, "AUTOHIDE"))
      iupMOT_SETARG(args, num_args, XmNscrollBarDisplayPolicy, XmAS_NEEDED);
    else
      iupMOT_SETARG(args, num_args, XmNscrollBarDisplayPolicy, XmSTATIC);

    ih->handle = XtCreateManagedWidget(
      child_id,          /* child identifier */
      xmListWidgetClass, /* widget class */
      parent,            /* widget parent */
      args, num_args);
  }

  if (!ih->handle)
    return IUP_ERROR;

  ih->serial = iupDialogGetChildId(ih); /* must be after using the string */

  if (ih->data->is_dropdown || ih->data->has_editbox)
  {
    Widget cbedit, cblist;
    XtVaGetValues(ih->handle, XmNtextField, &cbedit, NULL);
    XtVaGetValues(ih->handle, XmNlist, &cblist, NULL);

    XtAddEventHandler(cbedit, FocusChangeMask, False, (XtEventHandler)iupmotFocusChangeEvent, (XtPointer)ih);
    XtAddEventHandler(cbedit, EnterWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih);
    XtAddEventHandler(cbedit, LeaveWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih);
    XtAddCallback(cbedit, XmNhelpCallback, (XtCallbackProc)iupmotHelpCallback, (XtPointer)ih);

    XtAddCallback(ih->handle, XmNselectionCallback, (XtCallbackProc)motListComboBoxSelectionCallback, (XtPointer)ih);

    if (iupStrBoolean(IupGetGlobal("INPUTCALLBACKS")))
      XtAddEventHandler(cbedit, PointerMotionMask, False, (XtEventHandler)iupmotDummyPointerMotionEvent, NULL);

    if (ih->data->has_editbox)
    {
      XtAddEventHandler(cbedit, KeyPressMask, False, (XtEventHandler)motListEditKeyPressEvent, (XtPointer)ih);
      XtAddCallback(cbedit, XmNmodifyVerifyCallback, (XtCallbackProc)motListEditModifyVerifyCallback, (XtPointer)ih);
      XtAddCallback(cbedit, XmNmotionVerifyCallback, (XtCallbackProc)motListEditMotionVerifyCallback, (XtPointer)ih);
      XtAddCallback(cbedit, XmNvalueChangedCallback, (XtCallbackProc)motListEditValueChangedCallback, (XtPointer)ih);

      iupAttribSetStr(ih, "_IUPMOT_DND_WIDGET", (char*)cbedit);
    }
    else
      XtAddEventHandler(cbedit, KeyPressMask, False, (XtEventHandler)iupmotKeyPressEvent, (XtPointer)ih);

    if (ih->data->is_dropdown)
    {
      XtVaSetValues(ih->handle, XmNvisibleItemCount, 5, NULL);
      XtAddCallback(XtParent(XtParent(cblist)), XmNpopupCallback, (XtCallbackProc)motListDropDownPopupCallback, (XtPointer)ih);
      XtAddCallback(XtParent(XtParent(cblist)), XmNpopdownCallback, (XtCallbackProc)motListDropDownPopdownCallback, (XtPointer)ih);
    }
    else
    {
      XtAddCallback(cblist, XmNdefaultActionCallback, (XtCallbackProc)motListDefaultActionCallback, (XtPointer)ih);
      XtAddEventHandler(cblist, PointerMotionMask, False, (XtEventHandler)iupmotPointerMotionEvent, (XtPointer)ih);
      XtAddEventHandler(cblist, ButtonPressMask|ButtonReleaseMask, False, (XtEventHandler)iupmotButtonPressReleaseEvent, (XtPointer)ih);

      /* Disable Drag Source */
      iupmotDisableDragSource(cblist);
    }
  }
  else
  {
    iupAttribSetStr(ih, "_IUP_EXTRAPARENT", (char*)parent);
    XtVaSetValues(parent, XmNworkWindow, ih->handle, NULL);

    XtAddEventHandler(ih->handle, FocusChangeMask, False, (XtEventHandler)iupmotFocusChangeEvent, (XtPointer)ih);
    XtAddEventHandler(ih->handle, EnterWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih);
    XtAddEventHandler(ih->handle, LeaveWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih);
    XtAddEventHandler(ih->handle, KeyPressMask, False, (XtEventHandler)iupmotKeyPressEvent, (XtPointer)ih);
    XtAddEventHandler(ih->handle, PointerMotionMask, False, (XtEventHandler)iupmotPointerMotionEvent, (XtPointer)ih);
    XtAddEventHandler(ih->handle, ButtonPressMask|ButtonReleaseMask, False, (XtEventHandler)iupmotButtonPressReleaseEvent, (XtPointer)ih);

    XtAddCallback(ih->handle, XmNhelpCallback, (XtCallbackProc)iupmotHelpCallback, (XtPointer)ih);
    XtAddCallback (ih->handle, XmNbrowseSelectionCallback, (XtCallbackProc)motListBrowseSelectionCallback, (XtPointer)ih);
    XtAddCallback (ih->handle, XmNextendedSelectionCallback, (XtCallbackProc)motListExtendedSelectionCallback, (XtPointer)ih);
    XtAddCallback (ih->handle, XmNdefaultActionCallback, (XtCallbackProc)motListDefaultActionCallback, (XtPointer)ih);
  }

  /* initialize the widget */
  if (ih->data->is_dropdown || ih->data->has_editbox)
    XtRealizeWidget(ih->handle);
  else
    XtRealizeWidget(parent);

  /* Enable internal drag and drop support */
  if(ih->data->show_dragdrop && !ih->data->is_dropdown && !ih->data->is_multiple)
  {   
    motListEnableDragDrop(ih->handle);
    XtVaSetValues(ih->handle, XmNuserData, ih, NULL);  /* to be used in motListDragStart and motListDragTransferProc */
  }
  else
    iupmotDisableDragSource(ih->handle);  /* Disable Drag Source */

  if (IupGetGlobal("_IUP_RESET_TXTCOLORS"))
  {
    iupmotSetGlobalColorAttrib(ih->handle, XmNbackground, "TXTBGCOLOR");
    iupmotSetGlobalColorAttrib(ih->handle, XmNforeground, "TXTFGCOLOR");
    IupSetGlobal("_IUP_RESET_TXTCOLORS", NULL);
  }

  IupSetCallback(ih, "_IUP_XY2POS_CB", (Icallback)motListConvertXYToPos);

  iupListSetInitialItems(ih);

  return IUP_NOERROR;
}
Esempio n. 28
0
/****************************************************************************
 * Function:	    void DisplayVersion(
 *                              Widget parent,
 *                              char *helpVolume,
 *                              char *locationId)
 *
 * Parameters:      
 *
 * Return Value:    Void.
 *
 * Purpose: 	    Displays the version dialog for the helpdemo program.
 *
 ****************************************************************************/
void DisplayVersion (
    Widget  parent,
    char    *helpVolume,
    char    *locationId)

{
  Arg	 	args[10];	
  int           n;
  Widget        printWidget;
  Widget        helpWidget;
  Widget        backWidget;

 
  if (versionMain != NULL)
    {
       n = 0;
       XtSetArg (args[n], XmNtitle, "Helpdemo Version Dialog");          n++;
       if (helpVolume != NULL)
         {
           XtSetArg (args[n],DtNhelpVolume,helpVolume);     n++; 
         }
       XtSetArg (args[n], DtNlocationId,locationId);        n++;
       XtSetValues(versionMain, args, n);
  
       XtManageChild(versionMain);    
       
     }
   else
     {
       while (!XtIsSubclass(parent, applicationShellWidgetClass))
         parent = XtParent(parent);
     

        /* Build a new one in our cached list */
        n = 0;
        XtSetArg (args[n], XmNtitle, "Helpdemo Version Dialog");       n++;
       if (helpVolume != NULL)
         {
           XtSetArg (args[n],DtNhelpVolume,helpVolume);     n++; 
         }
        XtSetArg (args[n], DtNlocationId,locationId);        n++;
	XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC);  n++;
        versionMain = DtCreateHelpQuickDialog(parent,"versionWidget",args,n);

        XtAddCallback(versionMain, DtNcloseCallback,
                      CloseMainCB, (XtPointer) versionMain);


        /* We do not want a print button for now so we unmap it */     
        printWidget = DtHelpQuickDialogGetChild (versionMain, 
                                         DtHELP_QUICK_PRINT_BUTTON);
        XtUnmanageChild (printWidget);
  

        /* We do not want a help button for now so we unmap it */     
        helpWidget = DtHelpQuickDialogGetChild (versionMain, 
                                        DtHELP_QUICK_HELP_BUTTON);
        XtUnmanageChild (helpWidget);
  
        backWidget = DtHelpQuickDialogGetChild (versionMain, 
                                        DtHELP_QUICK_BACK_BUTTON);
        XtUnmanageChild (backWidget);

        XtManageChild(versionMain);    
        
     }
}
Esempio n. 29
0
void 
popup_search_panel(void)
{
    static Boolean actions_added = False;
    Widget below = None;
    Widget form, label, dismiss_button;
    int rx,ry;

    /* turn off Compose key LED */
    setCompLED(0);

    /* don't paste if in the middle of drawing/editing */
    if (check_action_on())
	return;

    /* don't make another one if one already exists */
    if (search_panel) {
	return;
    }

    put_msg("Search & Replace");

    get_pointer_root_xy(&rx, &ry);

    FirstArg(XtNx, (Position) rx);
    NextArg(XtNy, (Position) ry);
    NextArg(XtNcolormap, tool_cm);
    NextArg(XtNtitle, "Xfig: Search & Replace");
    
    search_panel = XtCreatePopupShell("search_panel",
				transientShellWidgetClass, tool,
				Args, ArgCount);
    XtOverrideTranslations(search_panel,
		XtParseTranslationTable(search_panel_translations));
    if (!actions_added) {
	XtAppAddActions(tool_app, search_actions, XtNumber(search_actions));
	actions_added = True;
    }
    
    form = XtCreateManagedWidget("form", formWidgetClass, search_panel, NULL, 0) ;
    
    FirstArg(XtNlabel, "  Search for:");
    NextArg(XtNborderWidth, 0);
    NextArg(XtNtop, XtChainTop);
    NextArg(XtNbottom, XtChainTop);
    NextArg(XtNleft, XtChainLeft);
    NextArg(XtNright, XtChainLeft);
    label = XtCreateManagedWidget("search_lab", labelWidgetClass,
				form, Args, ArgCount);
    
    FirstArg(XtNfromHoriz, label);
    NextArg(XtNeditType, XawtextEdit);
    NextArg(XtNwidth, 200);
    NextArg(XtNtop, XtChainTop);
    NextArg(XtNbottom, XtChainTop);
    NextArg(XtNleft, XtChainLeft);
    NextArg(XtNright, XtChainLeft);
    search_text_widget = XtCreateManagedWidget("search_text", asciiTextWidgetClass,
				form, Args, ArgCount);
    XtOverrideTranslations(search_text_widget,
			XtParseTranslationTable(search_text_translations));

    /* search button */

    FirstArg(XtNlabel, "Search ");
    NextArg(XtNfromHoriz, search_text_widget);
    NextArg(XtNtop, XtChainTop);
    NextArg(XtNbottom, XtChainTop);
    NextArg(XtNleft, XtChainLeft);
    NextArg(XtNright, XtChainLeft);
    search_button = XtCreateManagedWidget("search", commandWidgetClass,
				form, Args, ArgCount);
    XtAddCallback(search_button, XtNcallback,
                (XtCallbackProc) search_and_replace_text, (XtPointer) NULL);
  
    (void) CreateCheckbutton("Case sensitive", "case_sensitive", 
			form, NULL, search_button, MANAGE, SMALL_CHK, &case_sensitive, 0, 0);
    below = label;

    FirstArg(XtNfromVert, below);
    NextArg(XtNvertDistance, 6);
    NextArg(XtNborderWidth, 0);
    NextArg(XtNlabel, "Replace with:");
    NextArg(XtNtop, XtChainTop);
    NextArg(XtNbottom, XtChainTop);
    NextArg(XtNleft, XtChainLeft);
    NextArg(XtNright, XtChainLeft);
    replace_text_label = XtCreateManagedWidget("replace_lab", labelWidgetClass,
				form, Args, ArgCount);

    FirstArg(XtNfromVert, below);
    NextArg(XtNvertDistance, 6);
    NextArg(XtNfromHoriz, replace_text_label);
    NextArg(XtNeditType, XawtextEdit);
    NextArg(XtNwidth, 200);
    NextArg(XtNtop, XtChainTop);
    NextArg(XtNbottom, XtChainTop);
    NextArg(XtNleft, XtChainLeft);
    NextArg(XtNright, XtChainLeft);
    replace_text_widget = XtCreateManagedWidget("replace_text", asciiTextWidgetClass,
				form, Args, ArgCount);
    XtOverrideTranslations(replace_text_widget,
				XtParseTranslationTable(replace_text_translations));
    
    FirstArg(XtNfromVert, below);
    NextArg(XtNfromHoriz, replace_text_widget);
    NextArg(XtNlabel, "Replace");
    NextArg(XtNtop, XtChainTop);
    NextArg(XtNbottom, XtChainTop);
    NextArg(XtNleft, XtChainLeft);
    NextArg(XtNright, XtChainLeft);
    do_replace_button = XtCreateManagedWidget("do_replace", commandWidgetClass,
				form, Args, ArgCount);
    XtAddCallback(do_replace_button, XtNcallback,
			(XtCallbackProc) do_replace, (XtPointer) NULL);

    FirstArg(XtNfromVert, below);
    NextArg(XtNfromHoriz, do_replace_button);
    NextArg(XtNlabel, "UPDATE  settings");
    NextArg(XtNtop, XtChainTop);
    NextArg(XtNbottom, XtChainTop);
    NextArg(XtNleft, XtChainLeft);
    NextArg(XtNright, XtChainLeft);
    do_update_button = XtCreateManagedWidget("dismiss", commandWidgetClass,
				form, Args, ArgCount);
    XtAddCallback(do_update_button, XtNcallback,
			(XtCallbackProc) do_update, (XtPointer) NULL);

    below = replace_text_widget;

    /* make a label to report if no match for search */

    FirstArg(XtNlabel, "Enter search string and press \"Search\"");
    NextArg(XtNfromVert, below);
    NextArg(XtNjustify, XtJustifyLeft);
    NextArg(XtNwidth, SEARCH_WIDTH);
    NextArg(XtNheight, 20);
    NextArg(XtNtop, XtChainTop);
    NextArg(XtNbottom, XtChainTop);
    NextArg(XtNleft, XtChainLeft);
    NextArg(XtNright, XtChainLeft);
    search_msg_win = XtCreateManagedWidget("search_msg_win", labelWidgetClass, 
		    form, Args, ArgCount);
    
    below = search_msg_win;

    /* make a text window to hold search results */

    FirstArg(XtNwidth, SEARCH_WIDTH);
    NextArg(XtNfromVert, below);
    NextArg(XtNheight, 200);
    NextArg(XtNeditType, XawtextRead);
    NextArg(XtNdisplayCaret, False);
    NextArg(XtNscrollHorizontal, XawtextScrollWhenNeeded);
    NextArg(XtNscrollVertical, XawtextScrollAlways);
    NextArg(XtNtop, XtChainTop);
    NextArg(XtNbottom, XtChainBottom);
    NextArg(XtNleft, XtChainLeft);
    NextArg(XtNright, XtChainLeft);
    search_results_win = XtCreateManagedWidget("search_results_win", asciiTextWidgetClass,
			form, Args, ArgCount);
    XtOverrideTranslations(search_results_win,
				XtParseTranslationTable(search_results_translations));
    
    below = search_results_win;

    /* make a dismiss button */

    FirstArg(XtNfromVert, below);
    NextArg(XtNlabel, "Dismiss");
    NextArg(XtNtop, XtChainBottom);
    NextArg(XtNbottom, XtChainBottom);
    NextArg(XtNleft, XtChainLeft);
    NextArg(XtNright, XtChainLeft);
    dismiss_button = XtCreateManagedWidget("dismiss", commandWidgetClass,
				form, Args, ArgCount);
    XtAddCallback(dismiss_button, XtNcallback,
			(XtCallbackProc) search_panel_dismiss, (XtPointer) NULL);

    /* make update/replace buttons insensitive to start */
    XtSetSensitive(replace_text_label, False);
    XtSetSensitive(do_replace_button, False);
    XtSetSensitive(do_update_button, False);

    XtPopup(search_panel, XtGrabNone);

    XSetWMProtocols(tool_d, XtWindow(search_panel), &wm_delete_window, 1);
    set_cmap(XtWindow(search_panel));
}
Esempio n. 30
0
/****************************************************************
...
*****************************************************************/
struct city_dialog *create_city_dialog(struct city *pcity, int make_modal)
{
  int i;
  struct city_dialog *pdialog;
  Pixmap icon_pixmap; 
  
  pdialog=(struct city_dialog *)malloc(sizeof(struct city_dialog));
  pdialog->pcity=pcity;

  pdialog->shell=XtVaCreatePopupShell(pcity->name,
				      make_modal ? transientShellWidgetClass :
				      topLevelShellWidgetClass,
				      toplevel, 
				      XtNallowShellResize, True, 
				      NULL);
  
  pdialog->main_form=
    XtVaCreateManagedWidget("citymainform", 
			    formWidgetClass, 
			    pdialog->shell, 
			    NULL);

  pdialog->cityname_label=
    XtVaCreateManagedWidget("citynamelabel", 
			    labelWidgetClass,
			    pdialog->main_form,
			    NULL);

  pdialog->citizen_labels[0]=
    XtVaCreateManagedWidget("citizenlabels",
			    commandWidgetClass,
			    pdialog->main_form,
			    XtNfromVert, 
			    pdialog->cityname_label,
			    XtNbitmap, get_citizen_pixmap(2),
			    NULL);


  for(i=1; i<NO_CITIZENS_SHOWN; i++)
    pdialog->citizen_labels[i]=
    XtVaCreateManagedWidget("citizenlabels",
			    commandWidgetClass,
			    pdialog->main_form,
			    XtNfromVert, 
			    pdialog->cityname_label,
			    XtNfromHoriz, 
			    (XtArgVal)pdialog->citizen_labels[i-1],
			    XtNbitmap, get_citizen_pixmap(2),
			    NULL);
    
  pdialog->sub_form=
    XtVaCreateManagedWidget("citysubform", 
			    formWidgetClass, 
			    pdialog->main_form, 
			    XtNfromVert, 
			    (XtArgVal)pdialog->citizen_labels[0],
			    NULL);


  pdialog->production_label=
    XtVaCreateManagedWidget("cityprodlabel", 
			    labelWidgetClass,
			    pdialog->sub_form,
			    NULL);

  pdialog->output_label=
    XtVaCreateManagedWidget("cityoutputlabel", 
			    labelWidgetClass,
			    pdialog->sub_form,
			    XtNfromVert, 
			    (XtArgVal)pdialog->production_label,
			    NULL);

  pdialog->storage_label=
    XtVaCreateManagedWidget("citystoragelabel", 
			    labelWidgetClass,
			    pdialog->sub_form,
			    XtNfromVert, 
			    (XtArgVal)pdialog->output_label,
			    NULL);

  pdialog->polution_label=
    XtVaCreateManagedWidget("citypolutionlabel", 
			    labelWidgetClass,
			    pdialog->sub_form,
			    XtNfromVert, 
			    (XtArgVal)pdialog->storage_label,
			    NULL);
  
  
  pdialog->map_canvas=
    XtVaCreateManagedWidget("citymapcanvas", 
			    xfwfcanvasWidgetClass,
			    pdialog->sub_form,
			    "exposeProc", 
			    (XtArgVal)city_map_canvas_expose,
			    "exposeProcData", 
			    (XtArgVal)pdialog,
			    XtNfromHoriz, 
			    (XtArgVal)pdialog->production_label,
			    NULL);

  
  pdialog->building_label=
    XtVaCreateManagedWidget("citybuildinglabel",
			    labelWidgetClass,
			    pdialog->sub_form,
			    XtNfromHoriz, 
			    (XtArgVal)pdialog->map_canvas,
			    NULL);
  
  pdialog->progress_label=
    XtVaCreateManagedWidget("cityprogresslabel",
			    labelWidgetClass,
			    pdialog->sub_form,
			    XtNfromHoriz, 
			    (XtArgVal)pdialog->map_canvas,
			    XtNfromVert, 
			    pdialog->building_label,
			    NULL);

  pdialog->buy_command=
    XtVaCreateManagedWidget("citybuycommand", 
			    commandWidgetClass,
			    pdialog->sub_form,
			    XtNfromVert, 
			    pdialog->building_label,
			    XtNfromHoriz, 
			    (XtArgVal)pdialog->progress_label,
			    NULL);


  pdialog->change_command=
    XtVaCreateManagedWidget("citychangecommand", 
			    commandWidgetClass,
			    pdialog->sub_form,
			    XtNfromVert, 
			    pdialog->building_label,
			    XtNfromHoriz, 
			    (XtArgVal)pdialog->buy_command,
			    NULL);
  
  pdialog->improvement_viewport=
    XtVaCreateManagedWidget("cityimprovview", 
			    viewportWidgetClass,
			    pdialog->sub_form,
			    XtNfromHoriz, 
			    (XtArgVal)pdialog->map_canvas,
			    XtNfromVert, 
			    pdialog->progress_label,
			    NULL);


  pdialog->improvement_list=
    XtVaCreateManagedWidget("cityimprovlist", 
			    listWidgetClass,
			    pdialog->improvement_viewport,
			    XtNforceColumns, 1,
			    XtNdefaultColumns,1, 
			    XtNlist, (XtArgVal)dummy_improvement_list,
			    XtNverticalList, False,
			    NULL);

  pdialog->sell_command=
    XtVaCreateManagedWidget("citysellcommand", 
			    commandWidgetClass,
			    pdialog->sub_form,
			    XtNfromVert, 
			    pdialog->improvement_viewport,
			    XtNfromHoriz, 
			    (XtArgVal)pdialog->map_canvas,
			    NULL);
  
  icon_pixmap = XCreateBitmapFromData(display,
				      RootWindowOfScreen(XtScreen(toplevel)),
				      cityicon_bits,
				      cityicon_width, cityicon_height);

  pdialog->support_unit_label=
    XtVaCreateManagedWidget("supportunitlabel",
			    labelWidgetClass,
			    pdialog->main_form,
			    XtNfromVert, 
			    pdialog->sub_form,
			    NULL);

  pdialog->support_unit_pixcomms[0]=
    XtVaCreateManagedWidget("supportunitcanvas",
			    pixcommWidgetClass,
			    pdialog->main_form,
			    XtNfromVert, 
			    pdialog->support_unit_label,
			    NULL);
  pdialog->support_unit_ids[0]=-1;


  for(i=1; i<NO_UNITS_SHOWN; i++) {
    pdialog->support_unit_pixcomms[i]=
      XtVaCreateManagedWidget("supportunitcanvas",
			      pixcommWidgetClass,
			      pdialog->main_form,
			      XtNfromVert, 
			      pdialog->support_unit_label,
			      XtNfromHoriz, 
			      (XtArgVal)pdialog->support_unit_pixcomms[i-1],
			      XtNinternalHeight, 0,
			      NULL);
    pdialog->support_unit_ids[i]=-1;
  }
    

  pdialog->present_unit_label=
    XtVaCreateManagedWidget("presentunitlabel",
			    labelWidgetClass,
			    pdialog->main_form,
			    XtNfromVert, 
			    pdialog->support_unit_pixcomms[0],
			    NULL);

  pdialog->present_unit_pixcomms[0]=
    XtVaCreateManagedWidget("presentunitcanvas",
			    pixcommWidgetClass,
			    pdialog->main_form,
			    XtNfromVert, 
			    pdialog->present_unit_label,
			    NULL);
  pdialog->present_unit_ids[0]=-1;

  for(i=1; i<NO_UNITS_SHOWN; i++) {
    pdialog->present_unit_pixcomms[i]=
      XtVaCreateManagedWidget("presentunitcanvas",
			      pixcommWidgetClass,
			      pdialog->main_form,
			      XtNfromVert, 
			      pdialog->present_unit_label,
			      XtNfromHoriz, 
			      (XtArgVal)pdialog->support_unit_pixcomms[i-1],
			      NULL);
    pdialog->present_unit_ids[i]=-1;
  }
    

  XtVaSetValues(pdialog->shell, XtNiconPixmap, icon_pixmap, NULL);

  pdialog->close_command=
    XtVaCreateManagedWidget("cityclosecommand", 
			    commandWidgetClass,
			    pdialog->main_form,
			    XtNfromVert, 
			    pdialog->present_unit_pixcomms[0],
			    NULL);

  pdialog->rename_command=
    XtVaCreateManagedWidget("cityrenamecommand", 
			    commandWidgetClass,
			    pdialog->main_form,
			    XtNfromVert, 
			    pdialog->present_unit_pixcomms[0],
			    XtNfromHoriz,
			    pdialog->close_command,
			    NULL);

  pdialog->trade_command=
    XtVaCreateManagedWidget("citytradecommand", 
			    commandWidgetClass,
			    pdialog->main_form,
			    XtNfromVert, 
			    pdialog->present_unit_pixcomms[0],
			    XtNfromHoriz,
			    pdialog->rename_command,
			    NULL);
  
  XtAddCallback(pdialog->sell_command, XtNcallback, sell_callback,
		(XtPointer)pdialog);

  XtAddCallback(pdialog->buy_command, XtNcallback, buy_callback,
		(XtPointer)pdialog);

  XtAddCallback(pdialog->change_command, XtNcallback, change_callback,
		(XtPointer)pdialog);
  
  XtAddCallback(pdialog->close_command, XtNcallback, close_callback,
		(XtPointer)pdialog);

  XtAddCallback(pdialog->rename_command, XtNcallback, rename_callback,
		(XtPointer)pdialog);

  XtAddCallback(pdialog->trade_command, XtNcallback, trade_callback,
		(XtPointer)pdialog);

  genlist_insert(&dialog_list, pdialog, 0);

  for(i=0; i<B_LAST+1; i++)
    pdialog->improvlist_names_ptrs[i]=0;

  for(i=0; i<NO_CITIZENS_SHOWN; i++)
    pdialog->citizen_type[i]=-1;

  
  XtRealizeWidget(pdialog->shell);

  refresh_city_dialog(pdialog->pcity);

  if(make_modal)
    XtSetSensitive(toplevel, FALSE);
  
  pdialog->is_modal=make_modal;
  
  return pdialog;
}