Ejemplo n.º 1
0
char *GetResponse (char *message) {
  char buf[512];
  Widget w, aLabel, rowcol;
  Arg args[16];
  int n;

  if (!responseShell) {
      responseShell = 
	  XtVaCreatePopupShell( "responseShell", xmDialogShellWidgetClass, 
                             theToplevelShell, 
/* width and/or height necessary to force the realizeWidget?? */
XmNwidth, 100, XmNheight, 100,
				XmNdialogType, XmDIALOG_SYSTEM_MODAL, 
				XmNtitle, "Add comment:", NULL);
      /* the XtRealizeWidget is not necessary if we set a width and height? */
      /*XtRealizeWidget (responseShell); */

      XtVaSetValues (responseShell, XmNtitle, "Add comment:", NULL);
      XtAddCallback 
        (responseShell, XmNpopupCallback, (XtCallbackProc) centerMe, NULL);
      XtAddEventHandler (responseShell, VisibilityChangeMask, False, 
						  (XtEventHandler) keepOnTop, NULL);

      responseForm = XtVaCreateWidget
                       ("responseForm",xmFormWidgetClass,responseShell,args,n);

      n = 0;
      XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM);                n++;
      XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM);               n++;
      XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM);              n++;
      XtSetArg (args[n], XmNorientation, XmHORIZONTAL);                   n++;
      aLabel = 
	  XtCreateManagedWidget(message, xmLabelWidgetClass, responseForm,args,n);

      n = 0;
      XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM);               n++;
      XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM);              n++;
      XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM);             n++;
      XtSetArg (args[n], XmNorientation, XmHORIZONTAL);                   n++;
      rowcol = XtCreateManagedWidget
			  ("rowcol",xmRowColumnWidgetClass,responseForm,args,n);
  
      w = XtCreateManagedWidget("Ok", xmPushButtonWidgetClass, rowcol, NULL, 0);
      XtAddCallback
          (w, XmNactivateCallback, (XtCallbackProc)responseCB, (XtPointer)TRUE);
      w = XtCreateManagedWidget("Cancel",xmPushButtonWidgetClass,rowcol,NULL,0);
      XtAddCallback (w, XmNactivateCallback, (XtCallbackProc)responseCB, FALSE);

      n = 0;
      XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET);              n++;
      XtSetArg (args[n], XmNtopWidget, aLabel);                           n++;
      XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM);               n++;
      XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM);              n++;
      XtSetArg (args[n], XmNeditMode,  XmMULTI_LINE_EDIT);                n++;
      XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET);           n++;
      XtSetArg (args[n], XmNbottomWidget, rowcol);                        n++;
      responseText = XtCreateManagedWidget 
	    ("responseText", xmTextWidgetClass, responseForm, args, n);

      w = XtCreateManagedWidget 
	    ("Add Timestamp", xmPushButtonWidgetClass, rowcol, NULL,0);    
	  XtAddCallback 
		(w, XmNactivateCallback, (XtCallbackProc) timestampCB, responseText);

  }
  XtManageChild (responseForm);
  XtPopup (XtParent(responseShell), XtGrabNone);

  answer = UNANSWERED;
  while (answer==UNANSWERED)
    XtAppProcessEvent(theAppContext, XtIMAll);

  return theResponse;
}
Ejemplo n.º 2
0
/*******************************************************************************
     Name DisplayMatchedList
     Description : Called when there are more than one matches for completion
                   command
     
*******************************************************************************/
DisplayMatchedList(
Widget w,
struct symbolMatch *matches)
{
   Widget matchShell,matchForm,matchViewport,
          matchDialog,matchList,cancel;
   int n;

   if(GetMatchList(matches) == 0)
     return(0);
   matchShell = XtCreatePopupShell("Matches",
                                    topLevelShellWidgetClass,
                                    toplevel,
                                    NULL, 0);
   matchForm = XtCreateManagedWidget( "manager_form", formWidgetClass,
                                        matchShell, NULL,0);
  
  XtSetArg(args[0],XtNallowHoriz, True);
  XtSetArg(args[1],XtNallowVert, True); 
  matchViewport = XtCreateManagedWidget("manager_viewport",viewportWidgetClass,
                                        matchForm,NULL, 2);
  n = 0;
  XtSetArg(args[n],XtNlist,item_list);n++;
  matchList = XtCreateManagedWidget("manager_list",
                                       listWidgetClass,
                                       matchViewport,
                                       args,n);
  n = 0;
  XtSetArg(args[n], XtNresizable, True);n++;
  XtSetArg(args[n],XtNlabel,"");n++;
  XtSetArg(args[n], XtNvalue, "");n++;
  XtSetArg(args[n], XtNfromVert, matchViewport);n++;
  XtSetArg(args[n], XtNicon, clips_logo);n++;
  XtSetArg(args[n], XtNleft, XtChainLeft);n++;
  XtSetArg(args[n], XtNright, XtChainRight);n++;
  XtSetArg(args[n], XtNtop, XtChainBottom);n++;
  XtSetArg(args[n], XtNbottom, XtChainBottom);n++;

/* ============================================================= */
/*  If the current active window is clips dialog box then pass   */
/*  the appropriate function to handle the match for the clips   */
/*  dialog; else the funcTion handling the match for the text    */
/*  editor is passed as the callback function.                   */
/* ============================================================= */ 

  if(w == dialog_text)
   {
    matchDialog = XtCreateManagedWidget("match_dialog",
                                      dialogWidgetClass,
                                      matchForm,
                                      args, n);
    XawDialogAddButton(matchDialog, "SELECT",printMatch, (XtPointer)completionString);
   }
  else
   {
     matchDialog = XtCreateManagedWidget("match_editor",
                                      dialogWidgetClass,
                                      matchForm,
                                      args, n);
     XawDialogAddButton(matchDialog, "SELECT",printMatchForTextEdit,(XtPointer)w);
   }
  XawDialogAddButton(matchDialog, "CANCEL", CancelPopupSelect,
                     (XtPointer) matchForm);
  XtAddCallback(matchList, XtNcallback, FileToDialog, (XtPointer) matchDialog);
  XtPopup(matchShell,XtGrabNonexclusive);
}
Ejemplo n.º 3
0
static int motTextMapMethod(Ihandle* ih)
{
  int num_args = 0;
  Arg args[30];
  Widget parent = iupChildTreeGetNativeParentHandle(ih);
  char* child_id = iupDialogGetChildIdStr(ih);
  int spin = 0;
  WidgetClass widget_class = xmTextWidgetClass;

  if (ih->data->is_multiline)
  {
    Widget sb_win;
    int wordwrap = 0;

    if (iupAttribGetBoolean(ih, "WORDWRAP"))
    {
      wordwrap = 1;
      ih->data->sb &= ~IUP_SB_HORIZ;  /* must remove the horizontal scroolbar */
    }

    /******************************/
    /* Create the scrolled window */
    /******************************/

    iupmotSetArg(args, num_args, XmNmappedWhenManaged, False);  /* not visible when managed */
    iupmotSetArg(args, num_args, XmNscrollingPolicy, XmAPPLICATION_DEFINED);
    iupmotSetArg(args, num_args, XmNvisualPolicy, XmVARIABLE);
    iupmotSetArg(args, num_args, XmNscrollBarDisplayPolicy, XmSTATIC);   /* can NOT be XmAS_NEEDED because XmAPPLICATION_DEFINED */
    iupmotSetArg(args, num_args, XmNspacing, 0); /* no space between scrollbars and text */
    iupmotSetArg(args, num_args, XmNborderWidth, 0);
    iupmotSetArg(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 = "text";

    num_args = 0;
    iupmotSetArg(args, num_args, XmNeditMode, XmMULTI_LINE_EDIT);
    if (wordwrap)
      iupmotSetArg(args, num_args, XmNwordWrap, True);
  }
  else
  {
    widget_class = xmTextFieldWidgetClass;

    if (iupAttribGetBoolean(ih, "SPIN"))
    {
      Widget spinbox;

      num_args = 0;
      iupmotSetArg(args, num_args, XmNmappedWhenManaged, False);  /* not visible when managed */
      iupmotSetArg(args, num_args, XmNspacing, 0); /* no space between spin and text */
      iupmotSetArg(args, num_args, XmNborderWidth, 0);
      iupmotSetArg(args, num_args, XmNshadowThickness, 0);
      iupmotSetArg(args, num_args, XmNmarginHeight, 0);
      iupmotSetArg(args, num_args, XmNmarginWidth, 0);
      iupmotSetArg(args, num_args, XmNarrowSize, 8);

      if (iupStrEqualNoCase(iupAttribGetStr(ih, "SPINALIGN"), "LEFT"))
        iupmotSetArg(args, num_args, XmNarrowLayout, XmARROWS_BEGINNING);
      else
        iupmotSetArg(args, num_args, XmNarrowLayout, XmARROWS_END);

      spinbox = XtCreateManagedWidget(
        child_id,  /* child identifier */
        xmSpinBoxWidgetClass, /* widget class */
        parent,                      /* widget parent */
        args, num_args);

      if (!spinbox)
        return IUP_ERROR;

      XtAddCallback(spinbox, XmNmodifyVerifyCallback, (XtCallbackProc)motTextSpinModifyVerifyCallback, (XtPointer)ih);

      parent = spinbox;
      child_id = "text";
      spin = 1;

      if (!iupAttribGetBoolean(ih, "SPINAUTO"))
        iupAttribSetStr(ih, "_IUPMOT_SPIN_NOAUTO", "1");
    }

    num_args = 0;
    iupmotSetArg(args, num_args, XmNeditMode, XmSINGLE_LINE_EDIT);

    if (spin)
    {
      /* Spin Constraints */
      iupmotSetArg(args, num_args, XmNspinBoxChildType, XmNUMERIC);
      iupmotSetArg(args, num_args, XmNminimumValue, 0);
      iupmotSetArg(args, num_args, XmNmaximumValue, 100);
      iupmotSetArg(args, num_args, XmNposition, 0);

      if (iupAttribGetBoolean(ih, "SPINWRAP"))
        iupmotSetArg(args, num_args, XmNwrap, TRUE);
      else
        iupmotSetArg(args, num_args, XmNwrap, FALSE);
    }
    else
    {
      iupmotSetArg(args, num_args, XmNmappedWhenManaged, False);  /* not visible when managed */
    }
  }

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

  iupmotSetArg(args, num_args, XmNmarginHeight, 0);  /* default padding */
  iupmotSetArg(args, num_args, XmNmarginWidth, 0);

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

  iupmotSetArg(args, num_args, XmNnavigationType, XmTAB_GROUP);
  iupmotSetArg(args, num_args, XmNhighlightThickness, 2);
  iupmotSetArg(args, num_args, XmNverifyBell, False);
  iupmotSetArg(args, num_args, XmNspacing, 0);

  if (iupAttribGetBoolean(ih, "BORDER"))
    iupmotSetArg(args, num_args, XmNshadowThickness, 2);
  else
    iupmotSetArg(args, num_args, XmNshadowThickness, 0);

  if (ih->data->is_multiline)
  {
    if (ih->data->sb & IUP_SB_HORIZ)
      iupmotSetArg(args, num_args, XmNscrollHorizontal, True);
    else
      iupmotSetArg(args, num_args, XmNscrollHorizontal, False);

    if (ih->data->sb & IUP_SB_VERT)
      iupmotSetArg(args, num_args, XmNscrollVertical, True);
    else
      iupmotSetArg(args, num_args, XmNscrollVertical, False);
  }

  ih->handle = XtCreateManagedWidget(
    child_id,       /* child identifier */
    widget_class,   /* 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_multiline)
  {
    iupAttribSetStr(ih, "_IUP_EXTRAPARENT", (char*)parent);
    XtVaSetValues(parent, XmNworkWindow, ih->handle, NULL);
  } 
  else if (spin)
    iupAttribSetStr(ih, "_IUP_EXTRAPARENT", (char*)parent);

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

  XtAddCallback(ih->handle, XmNmodifyVerifyCallback, (XtCallbackProc)motTextModifyVerifyCallback, (XtPointer)ih);
  XtAddCallback(ih->handle, XmNmotionVerifyCallback, (XtCallbackProc)motTextMotionVerifyCallback, (XtPointer)ih);
  XtAddCallback(ih->handle, XmNvalueChangedCallback, (XtCallbackProc)motTextValueChangedCallback, (XtPointer)ih);

  /* Disable Drag Source */
  iupmotDisableDragSource(ih->handle);

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

  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)motTextConvertXYToPos);

  return IUP_NOERROR;
}
Ejemplo n.º 4
0
int
main(int argc, char *argv[])
{
    Boolean		exists;
    char		*filename;
    FileAccess		file_access;
    Widget		source;
    XtAppContext	appcon;
    Boolean		show_dir;
    xedit_flist_item	*first_item;
    unsigned int	i, lineno;

    lineno = 0;
    show_dir = FALSE;
    first_item = NULL;

    topwindow = XtAppInitialize(&appcon, "Xedit", NULL, 0, &argc, argv,
				NULL,
				NULL, 0);

    XtAppAddActions(appcon, actions, XtNumber(actions));
    XtOverrideTranslations(topwindow,
			   XtParseTranslationTable("<Message>WM_PROTOCOLS: quit()"));

    XtGetApplicationResources(topwindow, (XtPointer) &app_resources, resources,
			      XtNumber(resources), NULL, 0);

    CurDpy = XtDisplay(topwindow);
    XawSimpleMenuAddGlobalActions(appcon);
    XtRegisterGrabAction(PopupMenu, True,
			 ButtonPressMask | ButtonReleaseMask,
			 GrabModeAsync, GrabModeAsync);

    makeButtonsAndBoxes(topwindow);

    StartHints();
    StartFormatPosition();
    (void)StartHooks(appcon);
    if (position_format_mask == 0) {
	for (i = 0; i < 3; i++)
	    XtRemoveCallback(texts[i], XtNpositionCallback,
			     PositionChanged, NULL);
    }
    XtRealizeWidget(topwindow);

#ifndef __UNIXOS2__
    XeditLispInitialize();
#endif

    options_popup = XtCreatePopupShell("optionsMenu", simpleMenuWidgetClass,
				       topwindow, NULL, 0);
    XtRealizeWidget(options_popup);
    XtAddCallback(XtCreateManagedWidget("ispell", smeBSBObjectClass,
					options_popup, NULL, 0),
		  XtNcallback, IspellCallback, NULL);
    CreateEditPopup();

    wm_delete_window = XInternAtom(XtDisplay(topwindow), "WM_DELETE_WINDOW",
				   False);
    (void)XSetWMProtocols(XtDisplay(topwindow), XtWindow(topwindow),
			  &wm_delete_window, 1);

    /* This first call is just to save the default font and colors */
    UpdateTextProperties(0);

    if (argc > 1) {
	xedit_flist_item	*item;
	Arg			args[2];
	unsigned int		num_args;

	for (i = 1; i < argc; i++) {
	    struct stat st;

	    if (argv[i][0] == '+') {
		char	*endptr;

		lineno = strtol(argv[i], &endptr, 10);
		/* Don't warn about incorrect input? */
		if (*endptr)
		    lineno = 0;
		continue;
	    }

	    filename = ResolveName(argv[i]);
	    if (filename == NULL || FindTextSource(NULL, filename) != NULL)
		continue;

	    num_args = 0;
	    if (stat(filename, &st) == 0 && !S_ISREG(st.st_mode)) {
		if (S_ISDIR(st.st_mode)) {
		    if (!first_item) {
			char path[BUFSIZ + 1];

			strncpy(path, filename, sizeof(path) - 2);
			path[sizeof(path) - 2] = '\0';
			if (*path) {
			    if (path[strlen(path) - 1] != '/')
				strcat(path, "/");
			}
			else
			    strcpy(path, "./");
			XtSetArg(args[0], XtNlabel, "");
			XtSetValues(dirlabel, args, 1);
			SwitchDirWindow(True);
			DirWindowCB(dirwindow, path, NULL);
			show_dir = True;
		    }
		    continue;
		}
	    }

	    switch (file_access = CheckFilePermissions(filename, &exists)) {
	    case NO_READ:
		if (exists)
		    XeditPrintf("File %s exists, and could not be opened for "
				"reading.\n", argv[i]);
		else
		    XeditPrintf("File %s does not exist, and the directory "
				"could not be opened for writing.\n", argv[i]);
		break;
	    case READ_OK:
		XtSetArg(args[num_args], XtNeditType, XawtextRead); num_args++;
		XeditPrintf("File %s opened READ ONLY.\n", argv[i]);
		break;
	    case WRITE_OK:
		XtSetArg(args[num_args], XtNeditType, XawtextEdit); num_args++;
		XeditPrintf("File %s opened read - write.\n", argv[i]);
		break;
	    }
	    if (file_access != NO_READ) {
		int flags;

		if (exists) {
		    flags = EXISTS_BIT;
		    XtSetArg(args[num_args], XtNstring, filename);num_args++;
		}
		else {
		    flags = 0;
		    XtSetArg(args[num_args], XtNstring, NULL);	  num_args++;
		}
		source = XtVaCreateWidget("textSource", international ?
					  multiSrcObjectClass
					  : asciiSrcObjectClass, topwindow,
					  XtNtype, XawAsciiFile,
					  XtNeditType, XawtextEdit,
					  NULL, NULL);
		XtSetValues(source, args, num_args);
		item = AddTextSource(source, argv[i], filename,
				     flags, file_access);
		XtAddCallback(item->source, XtNcallback, SourceChanged,
			      (XtPointer)item);
		if (exists && file_access == WRITE_OK) {
		    item->mode = st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
		    item->mtime = st.st_mtime;
		}
		if (!first_item && !show_dir)
		    first_item = item;
		ResetSourceChanged(item);
	    }
	}
    }

    if (!flist.pixmap && strlen(app_resources.changed_pixmap_name)) {
	XrmValue from, to;

	from.size = strlen(app_resources.changed_pixmap_name);
	from.addr = app_resources.changed_pixmap_name;
	to.size = sizeof(Pixmap);
	to.addr = (XtPointer)&(flist.pixmap);

	XtConvertAndStore(flist.popup, XtRString, &from, XtRBitmap, &to);
    }

    if (first_item == NULL) {
	XtSetKeyboardFocus(topwindow, filenamewindow);
	XtVaSetValues(textwindow, XtNwrap, XawtextWrapLine, NULL);
    }
    else {
	SwitchTextSource(first_item);
	XtSetKeyboardFocus(topwindow, textwindow);
	if (lineno) {
	    XawTextPosition position;

	    source = XawTextGetSource(textwindow);
	    position = RSCAN(XawTextGetInsertionPoint(textwindow),
			     lineno, False);
	    position = LSCAN(position, 1, False);
	    XawTextSetInsertionPoint(textwindow, position);
	}
    }

    XtAppMainLoop(appcon);
    return EXIT_SUCCESS;
}
Ejemplo n.º 5
0
void
#ifdef STANDALONE_SERVER
main (int argc, char *argv[])
{
  unsigned window_size;
  string identity; /* This will be the contents of the identity_atom */
#else /* not STANDALONE_SERVER */
start_server (unsigned window_size, string identity)
{
#endif /* not STANDALONE_SERVER */

  XTextProperty textP;
  Widget viewport_widget;
  int zero = 0;
  
  /* This routine will intercept messages we get.  */
  XtActionsRec actions[] = { { "MessageHandler", message_handler } };
  
  /* Here we assume that all the characters will fit in an em square. 
     (We make further assumptions below.)  The TFM format guarantees
     that the design size is not negative.  Values in the resource
     database override this.  These initial values are only useful if we
     are not standalone, but we reassign just below if we are
     standalone.  */
  Arg geometry_args[]
    = { { XtNheight, window_size },
        { XtNwidth,  window_size },
      };

#ifdef STANDALONE_SERVER
  if (argc == 3)
    {
      window_size = atou (argv[1]);
      geometry_args[0].value = geometry_args[1].value = window_size;
      identity = argv[2];
    }
  else
    {
      fprintf (stderr, "Usage: %s window-size identity.\n", argv[0]);
      exit(0);
    }
#endif /* STANDALONE_SERVER */

  /* We have no fallback resources, and we've already parsed the args.  */
  top_level = XtInitialize (NULL, CLASS_NAME, NULL, 0, &zero, NULL);

  viewport_widget
    = XtCreateManagedWidget ("viewport", viewportWidgetClass, top_level,
	                     NULL, 0); 
  canvas_widget
    = XtCreateManagedWidget ("canvas", labelWidgetClass, viewport_widget,
                             geometry_args, XtNumber (geometry_args));

  XtAddActions (actions, XtNumber (actions));

  XtRealizeWidget (top_level);
  
  display = XtDisplay (top_level);

  foserver_exit_atom = XInternAtom (display, FOSERVER_EXIT_ATOM, False);
  foserver_update_pixmap_atom
    = XInternAtom (display, FOSERVER_UPDATE_PIXMAP_ATOM, False);

  /* Get the identity atom number. Create it if it doesn't exist.  */
  foserver_identity_atom
    = XInternAtom (display, FOSERVER_IDENTITY_ATOM, False);

  textP.value = (unsigned char *) identity; /* Set value.  */
  textP.encoding = XA_STRING;
  textP.format = 8;
  textP.nitems = strlen (identity);
  XSetTextProperty (display, XtWindow (canvas_widget), &textP,
                    foserver_identity_atom);

  /* Process events forever.  */
  XtMainLoop ();
}
Ejemplo n.º 6
0
static int motTabsMapMethod(Ihandle* ih)
{
  int num_args = 0;
  Arg args[30];

  if (!ih->parent)
    return IUP_ERROR;

  /* Core */
  iupmotSetArg(args[num_args++], XmNmappedWhenManaged, False);  /* not visible when managed */
  iupmotSetArg(args[num_args++], XmNx, 0);  /* x-position */
  iupmotSetArg(args[num_args++], XmNy, 0);  /* y-position */
  iupmotSetArg(args[num_args++], XmNwidth, 10);  /* default width to avoid 0 */
  iupmotSetArg(args[num_args++], XmNheight, 10); /* default height to avoid 0 */
  /* Manager */
  iupmotSetArg(args[num_args++], XmNshadowThickness, 0);
  iupmotSetArg(args[num_args++], XmNtraversalOn, True);
  iupmotSetArg(args[num_args++], XmNhighlightThickness, 0);
  /* Notebook */
  iupmotSetArg(args[num_args++], XmNbindingType, XmNONE);
  iupmotSetArg(args[num_args++], XmNbindingWidth, 0);
  iupmotSetArg(args[num_args++], XmNfirstPageNumber, 0);  /* IupTabs index always starts with zero */
  iupmotSetArg(args[num_args++], XmNbackPageSize, 0);
  iupmotSetArg(args[num_args++], XmNbackPageNumber, 1);
  iupmotSetArg(args[num_args++], XmNframeShadowThickness, 2);

  ih->handle = XtCreateManagedWidget(
    iupDialogGetChildIdStr(ih),  /* child identifier */
    xmNotebookWidgetClass,       /* widget class */
    iupChildTreeGetNativeParentHandle(ih), /* widget parent */
    args, num_args);

  if (!ih->handle)
    return IUP_ERROR;
 
  ih->serial = iupDialogGetChildId(ih); /* must be after using the string */

  /* Disable page scroller */
  {
    Widget scroller;
    scroller = XtNameToWidget(ih->handle, "*PageScroller");
    XtUnmanageChild(scroller);
  }

  /* Callbacks */
  XtAddCallback(ih->handle, XmNpageChangedCallback, (XtCallbackProc)motTabsPageChangedCallback, (XtPointer)ih);

  /* update Tab position */
  motTabsUpdateTabType(ih);

  /* current value is now given by the native system */
  iupAttribSetStr(ih, "_IUPTABS_VALUE_HANDLE", NULL);

  /* initialize the widget */
  XtRealizeWidget(ih->handle);

  /* Create pages and tabs */
  if (ih->firstchild)
  {
    Ihandle* child;
    for (child = ih->firstchild; child; child = child->brother)
      motTabsChildAddedMethod(ih, child);
  }

  return IUP_NOERROR;
}
Ejemplo n.º 7
0
Boolean
CreateHelp()
{
  struct stat fileinfo;		/* file information from fstat. */
  FILE * help_file;		/* The stream of the help file. */
  char * help_page;		/* The help text strored in memory. */
  int help_width;		/* The width of the help window. (default). */
  Arg arglist[10];		/* The arglist */
  Cardinal num_args;		/* The number of arguments. */
  Widget pane;			/* The Vpane, that will contain the help info.
				   */
  static XtCallbackRec Callbacks[] = {
    { PopdownHelp, NULL },
    { NULL, NULL },
  };
  
  if (help_widget != NULL)	/* If we already have a help widget. 
				   then do not create one. */
    return(TRUE);

/* Open help_file and read it into memory. */

/*
 * Get file size and allocate a chunk of memory for the file to be 
 * copied into.
 */

  if( (help_file = fopen(help_file_name, "r")) == NULL ) {
    PrintWarning("Could not open help file, NO HELP WILL BE AVALIABLE.");
    return(FALSE);
  }

  if ( stat(help_file_name, &fileinfo) ) {
    PrintWarning("Failure in fstat, NO HELP WILL BE AVALIABLE.");
    return(FALSE);
  }

  /* leave space for the NULL */
  help_page = (char *) malloc(fileinfo.st_size + 1);	

  if (help_page == NULL) {
    PrintWarning(
      "Could not allocate memory for help file, NO HELP WILL BE AVALIABLE.");
    return(FALSE);
  }

/*
 * Copy the file into memory. 
 */
 
  fread(help_page,sizeof(char),fileinfo.st_size,help_file); 
  fclose(help_file);
    
/* put NULL at end of buffer. */

  *(help_page + fileinfo.st_size) = '\0';

/*
 * Help file now loaded in to memory. Create widgets do display it. 
 */

  num_args = 0;
  XtSetArg(arglist[num_args], XtNallowShellResize, TRUE);
  num_args++;

  help_widget = XtCreateApplicationShell("help", applicationShellWidgetClass, 
				   arglist, num_args);

  num_args = 0;
  help_width = DisplayWidth(XtDisplay(help_widget), 
			    DefaultScreen(XtDisplay(help_widget)));
  help_width /= 2;
  XtSetArg(arglist[num_args], XtNwidth, help_width);
  num_args++;

#if XtSpecificationRelease < 4
  pane = XtCreateWidget("Help_VPaned",vPanedWidgetClass,help_widget,
			arglist,num_args);
#else
  pane = XtCreateWidget("Help_Paned",panedWidgetClass,help_widget,
			arglist,num_args);
#endif

  num_args = 0;
  XtSetArg(arglist[num_args], XtNborderWidth, 0);
  num_args++;
  XtSetArg(arglist[num_args], XtNlabel, "Done With Help");
  num_args++;
  XtSetArg(arglist[num_args], XtNcallback, Callbacks);
  num_args++;

  (void) XtCreateManagedWidget("Help_Quit",commandWidgetClass, pane,
			       arglist, num_args);

  num_args = 0;
  XtSetArg(arglist[num_args], XtNborderWidth, 0);
  num_args++;
  XtSetArg(arglist[num_args], XtNstring, help_page);
  num_args++;
#if XtSpecificationRelease < 4
  XtSetArg(arglist[num_args], XtNtextOptions, scrollVertical);
  num_args++;
#else
  XtSetArg(arglist[num_args],XtNscrollVertical,XawtextScrollAlways);
  num_args++;
  XtSetArg(arglist[num_args],XtNscrollHorizontal,XawtextScrollWhenNeeded);
  num_args++;
  XtSetArg(arglist[num_args],XtNuseStringInPlace, TRUE);
  num_args++;
#endif
  /* make the text shown a square box. */
  XtSetArg(arglist[num_args], XtNheight, help_width);
  num_args++;
  

#if XtSpecificationRelease < 4
  (void) XtCreateManagedWidget("Help_Text",asciiStringWidgetClass, pane,
			       arglist, num_args);
#else
  (void) XtCreateManagedWidget("Help_Text",asciiTextWidgetClass, pane,
			       arglist, num_args);
#endif

  XtManageChild(pane);
  XtRealizeWidget(help_widget);
  AddCursor(help_widget,help_cursor);

  return(TRUE);
}
void SelectorRadioInteractor::reloadMenuOptions()
{
    SelectorInstance *si = (SelectorInstance*) this->interactorInstance;
    SelectorNode     *snode = (SelectorNode*)si->getNode();
    int endi, n, i;
    Arg wargs[10];
    Pixel bg, fg;
    Widget button, w;
    int newOptionCnt = si->getOptionCount();
    int oldOptionCnt = this->toggleWidgets.getSize();
    Boolean setting, oldSetting;
    XmString xmstr, oldstr;
    char *cp;

    // reuse existing buttons
    for (i=1; i<=oldOptionCnt; i++) {
        if (i>newOptionCnt) break;
        w = (Widget)this->toggleWidgets.getElement(i);
        char *optname = (char *)si->getOptionNameString(i);
        ASSERT(optname);
        if (snode->isOptionSelected(i))  setting = True;
        else setting = False;
        XtVaGetValues (w, XmNlabelString, &oldstr, XmNset, &oldSetting, NULL);
        if (oldSetting!=setting) XtVaSetValues (w, XmNset, setting, NULL);
        XmStringGetLtoR (oldstr, XmSTRING_DEFAULT_CHARSET, &cp);
        XmStringFree (oldstr);
        if (!XtIsSensitive (w)) XtSetSensitive(w, True);
        if ((!cp)||(strcmp(cp, optname))) {
            xmstr = XmStringCreateLtoR(optname, "canvas");
            XtVaSetValues (w, XmNuserData, i, XmNlabelString, xmstr, NULL);
            XmStringFree (xmstr);
        } else XtVaSetValues (w, XmNuserData, i, NULL);
        if (cp) XtFree(cp);
        delete optname;
    }

    // deal with existing, unneeded buttons
    endi = i;
    for (i=i; i<=oldOptionCnt; i++) {
        w = (Widget)this->toggleWidgets.getElement(endi);
        if ((i==oldOptionCnt) && (newOptionCnt == 0)) {
            xmstr = XmStringCreateLtoR("(empty)", "canvas");
            XtSetSensitive(w, False);
            XtVaSetValues (w, XmNlabelString, xmstr, NULL);
            XmStringFree(xmstr);
            break;
        }
        XtUnmanageChild (w);
        XtDestroyWidget (w);
        this->toggleWidgets.deleteElement(endi);
    }


    // get new buttons if more are needed
    XtVaGetValues (this->toggleRadio, XmNforeground, &fg, XmNbackground, &bg, NULL);
    for (i=i; i<=newOptionCnt; i++) {
        char *optname = (char*)si->getOptionNameString(i);
        Boolean setting;
        ASSERT(optname);
        xmstr = XmStringCreateLtoR(optname, "canvas");
        n = 0;
        XtSetArg(wargs[n], XmNuserData, i); n++;
        XtSetArg(wargs[n], XmNlabelString, xmstr ); n++;
        if (snode->isOptionSelected(i))  setting = True;
        else setting = False;
        XtSetArg(wargs[n], XmNset, setting); n++;
        XtSetArg(wargs[n], XmNbackground, bg); n++;
        XtSetArg(wargs[n], XmNforeground, fg); n++;
        button = XtCreateManagedWidget(optname,
                xmToggleButtonWidgetClass, this->toggleRadio, wargs,n);

        XtAddCallback(button, XmNvalueChangedCallback,
		 (XtCallbackProc)SelectorRadioInteractor_SelectorToggleCB,
		 (XtPointer)this);

        this->appendOptionWidget(button);
        delete optname;
        XmStringFree(xmstr);
    }
    this->resetUserDimensions();
    XtVaSetValues (XtParent(this->toggleRadio), XmNheight, 0, NULL);
}
Ejemplo n.º 9
0
Widget
make_layer_choice(char *label_all, char *label_active, Widget parent, Widget below, Widget beside, int hdist, int vdist)
{
	Widget	 form;

	FirstArg(XtNborderWidth, 0);
	NextArg(XtNfromVert, below);
	NextArg(XtNvertDistance, vdist);
	NextArg(XtNfromHoriz, beside);
	NextArg(XtNhorizDistance, hdist);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	form = XtCreateManagedWidget("layer_choice_form", formWidgetClass,
				parent, Args, ArgCount);

	FirstArg(XtNbitmap, (print_all_layers? sm_check_pm : sm_null_check_pm));
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	NextArg(XtNinternalWidth, 1);
	NextArg(XtNinternalHeight, 1);
	NextArg(XtNlabel, "  ");
	NextArg(XtNsensitive, (print_all_layers? False : True)); /* make opposite button sens */
	NextArg(XtNstate, print_all_layers); 	/* initial state */
	NextArg(XtNradioData, 1);		/* when this is pressed the value is 1 */
	printalltoggle = XtCreateManagedWidget("printalltoggle", toggleWidgetClass,
				form, Args, ArgCount);
	XtAddCallback(printalltoggle, XtNcallback, (XtCallbackProc) switch_print_layers,
					(XtPointer) NULL);

	/* label - " XXXX all layers" */

	FirstArg(XtNlabel, label_all);
	NextArg(XtNborderWidth, 0);
	NextArg(XtNfromHoriz, printalltoggle);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	below = XtCreateManagedWidget("print_all_layers", labelWidgetClass,
				form, Args, ArgCount);

	/* radio for printing only active layers */

	FirstArg(XtNbitmap, (print_all_layers? sm_null_check_pm : sm_check_pm));
	NextArg(XtNfromVert, printalltoggle);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	NextArg(XtNinternalWidth, 1);
	NextArg(XtNinternalHeight, 1);
	NextArg(XtNlabel, "  ");
	NextArg(XtNsensitive, (print_all_layers? True : False)); /* make opposite button sens */
	NextArg(XtNstate, !print_all_layers);	/* initial state */
	NextArg(XtNradioData, 2);		/* when this is pressed the value is 2 */
	NextArg(XtNradioGroup, printalltoggle);	/* this is the other radio button in the group */
	printactivetoggle = XtCreateManagedWidget("printactivetoggle", toggleWidgetClass,
				form, Args, ArgCount);
	XtAddCallback(printactivetoggle, XtNcallback, (XtCallbackProc) switch_print_layers,
					(XtPointer) NULL);

	/* label - "XXXX only active" */

	FirstArg(XtNlabel, label_active);
	NextArg(XtNborderWidth, 0);
	NextArg(XtNfromVert, printalltoggle);
	NextArg(XtNfromHoriz, printactivetoggle);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);	/* make it stay on left side */
	NextArg(XtNright, XtChainLeft);
	below = XtCreateManagedWidget("print_active_layers", labelWidgetClass,
				form, Args, ArgCount);

	/* now make checkbox to compute bounding box for whole figure or only exported part */

	FirstArg(XtNbitmap, (bound_active_layers? sm_check_pm : sm_null_check_pm));
	NextArg(XtNfromVert, printalltoggle);
	NextArg(XtNfromHoriz, below);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	NextArg(XtNinternalWidth, 1);
	NextArg(XtNinternalHeight, 1);
	NextArg(XtNlabel, "  ");
	NextArg(XtNstate, bound_active_layers);	/* initial state */
	boundactivetoggle = XtCreateManagedWidget("boundactivetoggle", toggleWidgetClass,
				form, Args, ArgCount);
	XtAddCallback(boundactivetoggle, XtNcallback, (XtCallbackProc) switch_bound,
					(XtPointer) NULL);

	FirstArg(XtNlabel, "Boundary only active layers");
	NextArg(XtNborderWidth, 0);
	NextArg(XtNfromVert, printalltoggle);
	NextArg(XtNfromHoriz, boundactivetoggle);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);	/* make it stay on left side */
	NextArg(XtNright, XtChainLeft);
	below = XtCreateManagedWidget("bound_active_layers", labelWidgetClass,
				form, Args, ArgCount);
	return form;
}
Ejemplo n.º 10
0
int
main(int argc, char *argv[])
{
    Widget toplevel;
    XtAppContext app_con;
    Widget panel;
    Widget base[XkbNumModifiers];
    Widget latched[XkbNumModifiers];
    Widget locked[XkbNumModifiers];
    Widget effective[XkbNumModifiers];
    Widget compat[XkbNumModifiers];
    Widget baseBox, latchBox, lockBox, effBox, compatBox;
    register int i;
    unsigned bit;
    XkbEvent ev;
    XkbStateRec state;
    static Arg hArgs[] = { {XtNorientation, (XtArgVal) XtorientHorizontal} };
    static Arg vArgs[] = { {XtNorientation, (XtArgVal) XtorientVertical} };
    static Arg onArgs[] = { {XtNon, (XtArgVal) True} };
    static Arg offArgs[] = { {XtNon, (XtArgVal) False} };
    static char *fallback_resources[] = {
        "*Box*background: grey50",
        "*Box*borderWidth: 0",
        "*Box*vSpace: 1",
        NULL
    };

    for (i = 1; i < argc; i++) {
        if (strcmp(argv[i], "-version") == 0) {
            printf("xkbwatch (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION);
            exit(0);
        }
    }

    uSetErrorFile(NullString);
    toplevel = XtOpenApplication(&app_con, "XkbWatch",
                                 options, XtNumber(options), &argc, argv,
                                 fallback_resources,
                                 sessionShellWidgetClass, NULL, ZERO);
    if (toplevel == NULL) {
        uFatalError("Couldn't create application top level\n");
        exit(1);
    }
    inDpy = outDpy = XtDisplay(toplevel);
    if (inDpy) {
        int i1, mn, mj;

        mj = XkbMajorVersion;
        mn = XkbMinorVersion;
        if (!XkbQueryExtension(inDpy, &i1, &evBase, &errBase, &mj, &mn)) {
            uFatalError("Server doesn't support a compatible XKB\n");
            exit(1);
        }
    }
    panel =
        XtCreateManagedWidget("xkbwatch", boxWidgetClass, toplevel, vArgs, 1);
    if (panel == NULL) {
        uFatalError("Couldn't create top level box\n");
        exit(1);
    }
    baseBox = XtCreateManagedWidget("base", boxWidgetClass, panel, hArgs, 1);
    if (baseBox == NULL)
        uFatalError("Couldn't create base modifiers box\n");
    latchBox =
        XtCreateManagedWidget("latched", boxWidgetClass, panel, hArgs, 1);
    if (latchBox == NULL)
        uFatalError("Couldn't create latched modifiers box\n");
    lockBox = XtCreateManagedWidget("locked", boxWidgetClass, panel, hArgs, 1);
    if (lockBox == NULL)
        uFatalError("Couldn't create locked modifiers box\n");
    effBox =
        XtCreateManagedWidget("effective", boxWidgetClass, panel, hArgs, 1);
    if (effBox == NULL)
        uFatalError("Couldn't create effective modifiers box\n");
    compatBox =
        XtCreateManagedWidget("compat", boxWidgetClass, panel, hArgs, 1);
    if (compatBox == NULL)
        uFatalError("Couldn't create compatibility state box\n");
    XkbSelectEvents(inDpy, XkbUseCoreKbd, XkbStateNotifyMask,
                    XkbStateNotifyMask);
    XkbGetState(inDpy, XkbUseCoreKbd, &state);
    for (i = XkbNumModifiers - 1, bit = 0x80; i >= 0; i--, bit >>= 1) {
        ArgList list;

        char buf[30];

        sprintf(buf, "base%d", i);
        if (state.base_mods & bit)
            list = onArgs;
        else
            list = offArgs;
        base[i] = XtCreateManagedWidget(buf, ledWidgetClass, baseBox, list, 1);
        sprintf(buf, "latched%d", i);
        if (state.latched_mods & bit)
            list = onArgs;
        else
            list = offArgs;
        latched[i] =
            XtCreateManagedWidget(buf, ledWidgetClass, latchBox, list, 1);
        sprintf(buf, "locked%d", i);
        if (state.locked_mods & bit)
            list = onArgs;
        else
            list = offArgs;
        locked[i] =
            XtCreateManagedWidget(buf, ledWidgetClass, lockBox, list, 1);
        sprintf(buf, "effective%d", i);
        if (state.mods & bit)
            list = onArgs;
        else
            list = offArgs;
        effective[i] =
            XtCreateManagedWidget(buf, ledWidgetClass, effBox, list, 1);
        sprintf(buf, "compat%d", i);
        if (state.compat_state & bit)
            list = onArgs;
        else
            list = offArgs;
        compat[i] =
            XtCreateManagedWidget(buf, ledWidgetClass, compatBox, list, 1);
    }
    XtRealizeWidget(toplevel);
    while (1) {
        XtAppNextEvent(app_con, &ev.core);
        if (ev.core.type == evBase + XkbEventCode) {
            if (ev.any.xkb_type == XkbStateNotify) {
                unsigned changed;

                if (ev.state.changed & XkbModifierBaseMask) {
                    changed = ev.state.base_mods ^ state.base_mods;
                    state.base_mods = ev.state.base_mods;
                    for (i = 0, bit = 1; i < XkbNumModifiers; i++, bit <<= 1) {
                        if (changed & bit) {
                            ArgList list;

                            if (state.base_mods & bit)
                                list = onArgs;
                            else
                                list = offArgs;
                            XtSetValues(base[i], list, 1);
                        }
                    }
                }
                if (ev.state.changed & XkbModifierLatchMask) {
                    changed = ev.state.latched_mods ^ state.latched_mods;
                    state.latched_mods = ev.state.latched_mods;
                    for (i = 0, bit = 1; i < XkbNumModifiers; i++, bit <<= 1) {
                        if (changed & bit) {
                            ArgList list;

                            if (state.latched_mods & bit)
                                list = onArgs;
                            else
                                list = offArgs;
                            XtSetValues(latched[i], list, 1);
                        }
                    }
                }
                if (ev.state.changed & XkbModifierLockMask) {
                    changed = ev.state.locked_mods ^ state.locked_mods;
                    state.locked_mods = ev.state.locked_mods;
                    for (i = 0, bit = 1; i < XkbNumModifiers; i++, bit <<= 1) {
                        if (changed & bit) {
                            ArgList list;

                            if (state.locked_mods & bit)
                                list = onArgs;
                            else
                                list = offArgs;
                            XtSetValues(locked[i], list, 1);
                        }
                    }
                }
                if (ev.state.changed & XkbModifierStateMask) {
                    changed = ev.state.mods ^ state.mods;
                    state.mods = ev.state.mods;
                    for (i = 0, bit = 1; i < XkbNumModifiers; i++, bit <<= 1) {
                        if (changed & bit) {
                            ArgList list;

                            if (state.mods & bit)
                                list = onArgs;
                            else
                                list = offArgs;
                            XtSetValues(effective[i], list, 1);
                        }
                    }
                }
                if (ev.state.changed & XkbCompatStateMask) {
                    changed = ev.state.compat_state ^ state.compat_state;
                    state.compat_state = ev.state.compat_state;
                    for (i = 0, bit = 1; i < XkbNumModifiers; i++, bit <<= 1) {
                        if (changed & bit) {
                            ArgList list;

                            if (state.compat_state & bit)
                                list = onArgs;
                            else
                                list = offArgs;
                            XtSetValues(compat[i], list, 1);
                        }
                    }
                }
            }
        }
        else
            XtDispatchEvent(&ev.core);
    }
/* BAIL: */
    if (inDpy)
        XCloseDisplay(inDpy);
    if (outDpy != inDpy)
        XCloseDisplay(outDpy);
    inDpy = outDpy = NULL;
    return 0;
}
Ejemplo n.º 11
0
static Widget createContents(Widget parent, SpaceWindow *window,
			     int hasEventBar, char *eventBarText)
{
    Arg    	args[50];
    int    	ac;
    XmString	s1, s2;
    char ctmp[10];
    Widget	form, displayMode, stability, particleType, rotation, stats;
    Widget	formt1, allSliders;
    Widget	controls, trackInfoFrame, trackInfo;
    Widget	scaleFrame, scaleRC, scaleLabel, scaleArea;
    Widget	stabilityLabel, particleTypeLabel;
    Widget	eventCtrlFrame, eventCtrlForm, eventNumLabel, upArrow;
    Widget	eventNumText, downArrow, eventCtrlText;
    Widget	widget, spin;
    Pixel	foreground, background;
    Pixmap	pm;

    /* Create the form onto which everything goes */
    ac = 0;
    XtSetArg(args[ac], XmNmarginHeight, 0); ac++;
    form = XmCreateForm(parent, "form", args, ac);
    XtManageChild(form);
  
    if (hasEventBar) {
        ac = 0;
	XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(args[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	eventCtrlFrame = XmCreateFrame(form, "eventCtrlFrame", args, ac);
	XtManageChild(eventCtrlFrame);
        
        ac = 0;
	eventCtrlForm = XmCreateForm(eventCtrlFrame, "eventCtrlForm", args, ac);
	XtManageChild(eventCtrlForm);
	
        ac = 0;
	XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
	XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING("Event #"))); ac++;
	eventNumLabel = (Widget) XmCreateLabelGadget(
	                         eventCtrlForm, "eventNumLabel",
					    args, ac);
	XmStringFree(s1);
	XtManageChild(eventNumLabel);
	
	ac = 0;
	XtSetArg(args[ac], XmNarrowDirection, XmARROW_UP); ac++;
	XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
	XtSetArg(args[ac], XmNleftWidget, eventNumLabel); ac++;
	upArrow = XmCreateArrowButton(eventCtrlForm, "upArrow", args, ac);
        XtAddCallback(upArrow, XmNactivateCallback,
                      (XtCallbackProc)  nextEvtCB, window); 
	XtManageChild(upArrow);
	
	ac = 0;
	
	sprintf(ctmp,"  %d  ", ac);
	XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING(ctmp))); ac++;
	XtSetArg(args[ac], XmNcolumns, 7); ac++;
	XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(args[ac], XmNleftWidget, upArrow); ac++;
	eventNumText = (Widget) XmCreateLabelGadget(
	                         eventCtrlForm, "eventNumText",
					    args, ac);
/*	eventNumText = XmCreateText(eventCtrlForm, "eventNumText", args, ac); */
	XtManageChild(eventNumText);
	
	ac = 0;
	XtSetArg(args[ac], XmNarrowDirection, XmARROW_DOWN); ac++;
	XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
	XtSetArg(args[ac], XmNleftWidget, eventNumText); ac++;
	downArrow = XmCreateArrowButton(eventCtrlForm, "downArrow", args, ac);
        XtAddCallback(downArrow, XmNactivateCallback,
                      (XtCallbackProc)  previousEvtCB, window); 
	XtManageChild(downArrow);
	
	ac = 0;
	XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING(eventBarText))); ac++;
	XtSetArg(args[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
	eventCtrlText = (Widget) XmCreateLabelGadget(
	                          eventCtrlForm, "eventCtrlText",
					    args, ac);
	XmStringFree(s1);
	XtManageChild(eventCtrlText);
    }
    
    /* Create a Form for the controls along the left edge of window */
    ac = 0;
    if (hasEventBar) {
    	XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    	XtSetArg(args[ac], XmNtopWidget, eventCtrlFrame); ac++;
    } else {
    	XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    }
    controls = XmCreateForm(form, "controls", args, ac);
    XtManageChild(controls);
     
    ac = 0;
    XtSetArg(args[ac], XmNborderWidth, (Dimension)0); ac++;
    XtSetArg(args[ac], XmNpacking, XmPACK_COLUMN); ac++;
    XtSetArg(args[ac], XmNspacing, 0); ac++;
    XtSetArg(args[ac], XmNnumColumns, (short)2); ac++;
    stability = XmCreateRowColumn(controls, "stability", args, ac);
    XtManageChild(stability);
 
    ac = 0;
    XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING("Particle Types"))); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNtopWidget, stability); ac++;
    particleTypeLabel = (Widget) XmCreateLabelGadget(
                                  controls, "particleTypeLabel",
    					    args, ac);
    XmStringFree(s1);
    XtManageChild(particleTypeLabel);

    ac = 0;
    XtSetArg(args[ac], XmNborderWidth, (Dimension)0); ac++;
    XtSetArg(args[ac], XmNpacking, XmPACK_COLUMN); ac++;
    XtSetArg(args[ac], XmNspacing, 0); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNnumColumns, (short)2); ac++;
    XtSetArg(args[ac], XmNtopWidget, particleTypeLabel); ac++;
    particleType = XmCreateRowColumn(controls, "particleType", args, ac);
    XtManageChild(particleType);

 
    ac = 0;
    XtSetArg(args[ac], XmNhighlightThickness, 0); ac++;
    XtSetArg(args[ac], XmNpacking, XmPACK_COLUMN); ac++;
    XtSetArg(args[ac], XmNspacing, 0); ac++;
    XtSetArg(args[ac], XmNorientation, XmHORIZONTAL); ac++;
    if (hasEventBar) {
    	XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    	XtSetArg(args[ac], XmNtopWidget, eventCtrlFrame); ac++;
    } else {
    	XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    }
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNleftWidget, controls); ac++;
    XtSetArg(args[ac], XmNtopOffset, (int)2); ac++;
    XtSetArg(args[ac], XmNleftOffset, (int)0); ac++;
    stats = XmCreateRowColumn(form, "stats", args, ac);
    XtManageChild(stats);

#define TOGGLE_BTN(parent, label, name, cb, set) \
    ac = 0; \
    XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING(label))); ac++; \
    XtSetArg(args[ac], XmNset, set); ac++; \
    XtSetArg(args[ac], XmNmarginHeight, 0); ac++; \
    widget = XmCreateToggleButtonGadget(parent, name, args, ac); \
    XmStringFree(s1); \
    XtAddCallback(widget, XmNvalueChangedCallback, \
                  (XtCallbackProc)  cb, window); \
    XtManageChild(widget); \

    TOGGLE_BTN(stability, "Stable", "stable", stableCB, True);
    TOGGLE_BTN(stability, "Unstable", "unstable", unstableCB, True);
    TOGGLE_BTN(particleType, "Charged", "charged", chargedCB, True);
    TOGGLE_BTN(particleType, "Neutral", "neutral", neutralCB, True);
    TOGGLE_BTN(particleType, "Electrons", "electrons", electronsCB, True);
    TOGGLE_BTN(particleType, "Muons", "muons", muonsCB, True);
    TOGGLE_BTN(particleType, "Neutrinos", "neutrinos", neutrinosCB, True);
    TOGGLE_BTN(particleType, "Gammas", "gammas", gammasCB, True);
    TOGGLE_BTN(particleType, "Quarks/Gluons", "quarks", quarksCB, True);
    TOGGLE_BTN(particleType,"Hadrons", "hadrons", hadronsCB, True);
    TOGGLE_BTN(particleType,"W/Z", "wz", wzCB, True);
    
    /* Do now the slider.. X, Y ,Z translation first. */
    ac = 0;
    XtSetArg(args[ac], XmNborderWidth, (Dimension)0); ac++;
    XtSetArg(args[ac], XmNpacking, XmPACK_COLUMN); ac++;
    XtSetArg(args[ac], XmNspacing, 0); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
/*    XtSetArg(args[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++; */
    XtSetArg(args[ac], XmNnumColumns, (short)1); ac++;
    XtSetArg(args[ac], XmNtopWidget, particleType); ac++;
/*    XtSetArg(args[ac], XmNrightWidget, particleType); ac++; */
    allSliders = XmCreateRowColumn(controls, "allSliders", args, ac);
    XtManageChild(allSliders);
     
                                 
    ac = 0;
    XtSetArg(args[ac], XmNpacking, XmPACK_COLUMN); ac++;
    XtSetArg(args[ac], XmNadjustLast, False); ac++;    
    XtSetArg(args[ac], XmNspacing, 0); ac++;
    XtSetArg(args[ac], XmNnumColumns, (short)5); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNtopWidget, allSliders); ac++;
    rotation = XmCreateRowColumn(controls, "rotation", args, ac);
    XtManageChild(rotation);

     /* Get foreground an background colors for pixmap buttons */
    ac = 0;
    XtSetArg(args[ac], XmNforeground, &foreground); ac++;
    XtSetArg(args[ac], XmNbackground, &background); ac++;
    XtGetValues(controls, args, ac);

#define ROTATE_BTN(pmName, widgetName, cb) \
    pm = XmGetPixmap(XtScreen(parent), pmName, foreground, background); \
    ac = 0; \
    XtSetArg(args[ac], XmNlabelType, XmPIXMAP); ac++; \
    XtSetArg(args[ac], XmNlabelPixmap, pm); ac++; \
    widget = XmCreatePushButtonGadget(rotation, widgetName, args, ac); \
    XtAddCallback(widget, XmNactivateCallback, \
                   (XtCallbackProc)  cb, window); \
    XtManageChild(widget);
    
    ROTATE_BTN("viewRotXPos", "viewRotXPos", viewRotXPosCB) 
    ROTATE_BTN("viewRotYPos", "viewRotYPos", viewRotYPosCB)
    ROTATE_BTN("viewRotZPos", "viewRotZPos", viewRotZPosCB)
    ROTATE_BTN("viewRotXNeg", "viewRotXNeg", viewRotXNegCB)
    ROTATE_BTN("viewRotYNeg", "viewRotYNeg", viewRotYNegCB)
    ROTATE_BTN("viewRotZNeg", "viewRotZNeg", viewRotZNegCB)
    ROTATE_BTN("coordRotXPos", "coordRotXPos", coordRotXPosCB)
    ROTATE_BTN("coordRotYPos", "coordRotYPos", coordRotYPosCB)
    ROTATE_BTN("coordRotZPos", "coordRotZPos", coordRotZPosCB)
    ROTATE_BTN("coordRotXNeg", "coordRotXNeg", coordRotXNegCB)
    ROTATE_BTN("coordRotYNeg", "coordRotYNeg", coordRotYNegCB)
    ROTATE_BTN("coordRotZNeg", "coordRotZNeg", coordRotZNegCB)
    ROTATE_BTN("scaleUp", "scaleUp", scaleUpCB)
    ROTATE_BTN("scaleDown", "scaleDown", scaleDownCB)
    ROTATE_BTN("resetRotation", "resetRotation", resetRotationCB)
 
    ac = 0;
    XtSetArg(args[ac], XmNshadowType, XmSHADOW_IN); ac++;
    XtSetArg(args[ac], XmNshadowThickness, 1); ac++;
    scaleFrame = XmCreateFrame(stats, "scaleFrame", args, ac);
    XtManageChild(scaleFrame);
    trackInfoFrame = XmCreateFrame(stats, "trackInfoFrame", args, ac);
    XtManageChild(trackInfoFrame);
    
    ac = 0;
    XtSetArg(args[ac], XmNpacking, XmPACK_COLUMN); ac++;
    XtSetArg(args[ac], XmNentryAlignment, XmALIGNMENT_CENTER); ac++;
    XtSetArg(args[ac], XmNspacing, 0); ac++;
    scaleRC = XmCreateRowColumn(scaleFrame, "scaleRC", args, ac);
    XtManageChild(scaleRC);

    ac = 0;
    scaleArea = XmCreateDrawingArea(scaleRC, "scaleArea", args, ac);
    XtAddCallback(scaleArea, XmNexposeCallback, 
                    (XtCallbackProc)  scaleExposeCB, window);
    XtManageChild(scaleArea);
    
    ac = 0;
    XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING("x"))); ac++;
    XtSetArg(args[ac], XmNmarginHeight, 0); ac++;
    scaleLabel = (Widget) XmCreateLabelGadget(
                            scaleRC, "scaleLabel", args, ac);
    XmStringFree(s1);
    XtManageChild(scaleLabel);
    
    ac = 0;
    XtSetArg(args[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
    XtSetArg(args[ac], XmNrecomputeSize, False); ac++;
    XtSetArg(args[ac], XmNlabelString, (s1=MKSTRING(
     "00000 tracks, 00000 are stable\nx\nTrack of max. xxxxx is a(n) xxxx"))); ac++;
    trackInfo = (Widget) XmCreateLabelGadget(
                           trackInfoFrame, "trackInfo", args, ac);
    XmStringFree(s1);
    XtManageChild(trackInfo);
    
    ac = 0;
    XtSetArg(args[ac], XmNshowAxes, True); ac++;
    XtSetArg(args[ac], XmNperspectiveOn, True); ac++;
    XtSetArg(args[ac], XmNdoubleBuffer, False); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftWidget, controls); ac++;
    XtSetArg(args[ac], XmNtopWidget, stats); ac++;
    XtSetArg(args[ac], XmNtopOffset, (int)0); ac++;
    XtSetArg(args[ac], XmNbottomOffset, (int)0); ac++;
    XtSetArg(args[ac], XmNleftOffset, (int)0); ac++;
    XtSetArg(args[ac], XmNrightOffset, (int)0); ac++;
    spin = XtCreateManagedWidget("spin", spinWidgetClass, form, args, ac);
    XtAddCallback(spin, XmNresizeCallback, 
                  (XtCallbackProc) resizeCB, window);
    XtAddCallback(spin, XmNredisplayCallback, 
                   (XtCallbackProc) redisplayCB, window);
    XtAddCallback(spin, XmNbtn2Callback,
                   (XtCallbackProc)  spinSelectCB, window);

/* Place now the Sliders, right attached to the spin widget */ 

    formt1 = createSpaceSlider(&window->scaleSliderScale, 
				&window->scaleSliderValue, 
			        allSliders, spin,
			        "scaleScale", "Overall Scale", 
                                SLIDER_MAX, window, scaleCB);  
    formt1 = createSpaceSlider(&window->xTranslSliderScale, 
				&window->xTranslSliderValue, 
			        allSliders, spin,
			        "scaleX", "X transl.", 
                                (SLIDER_MAX/2), window, xTransCB);  
    formt1 = createSpaceSlider(&window->yTranslSliderScale, 
				&window->yTranslSliderValue, 
			        allSliders, spin,
			        "scaleY", "Y transl.", 
                                (SLIDER_MAX/2), window, yTransCB);  
    formt1 = createSpaceSlider(&window->zTranslSliderScale, 
				&window->zTranslSliderValue, 
			        allSliders, spin,
			        "scaleZ", "Z transl.", 
                                (SLIDER_MAX/2), window, zTransCB);  
    formt1 = createSpaceSlider(&window->momToSpaceSliderScale, 
				&window->momToSpaceSliderValue, 
			        allSliders, spin,
			        "momtospace", "P to Dist", 
                               (SLIDER_MAX/10), window, momToSpaceCB);  
    formt1 = createSpaceSlider(&window->longToTrSliderScale, 
				&window->longToTrSliderValue, 
			        allSliders, spin,
			        "LongToTr",
			         "Aspect ratio Long/Tr.          ", 
                                (SLIDER_MAX/10), window, longToTrCB);
/* This last string is in fact constraining the appearance of the widget */
    window->spin = spin;
    window->eventNumText = eventNumText;
    window->eventSelectorLabel = eventCtrlText;
    window->statsLabel = trackInfo;
    window->scaleArea = scaleArea;
    window->scaleLabel = scaleLabel;
    
    window->stable = True;
    window->unstable = True;
    window->charged = True;
    window->neutral = True;
    window->electrons = True;
    window->muons = True;
    window->gammas = True;
    window->neutrinos = True;
    window->quarks = True;
    window->hadrons = True;
    window->wz = True;
    
    return(form);
}
Ejemplo n.º 12
0
/****************************************************************
popup the dialog 10% inside the main-window 
*****************************************************************/
void unit_select_dialog_popup(struct tile *ptile)
{
  int i,n,r;
  char buffer[512];
  Arg args[4];
  int nargs;
  Widget unit_select_all_command, unit_select_close_command;
  Widget firstcolumn=0,column=0;
  Pixel bg;
  struct unit *unit_list[unit_list_size(ptile->units)];

  XtSetSensitive(main_form, FALSE);

  unit_select_dialog_shell =
    I_T(XtCreatePopupShell("unitselectdialogshell", 
			   transientShellWidgetClass,
			   toplevel, NULL, 0));

  unit_select_form = XtVaCreateManagedWidget("unitselectform", 
					     formWidgetClass, 
					     unit_select_dialog_shell, NULL);

  XtVaGetValues(unit_select_form, XtNbackground, &bg, NULL);
  XSetForeground(display, fill_bg_gc, bg);

  n = MIN(MAX_SELECT_UNITS, unit_list_size(ptile->units));
  r = number_of_rows(n);

  fill_tile_unit_list(ptile, unit_list);

  for(i=0; i<n; i++) {
    struct unit *punit = unit_list[i];
    struct unit_type *punittemp=unit_type(punit);
    struct city *pcity;
    struct canvas store;
    
    if(!(i%r))  {
      nargs=0;
      if(i)  { XtSetArg(args[nargs], XtNfromHoriz, column); nargs++;}
      column = XtCreateManagedWidget("column", formWidgetClass,
				     unit_select_form,
				     args, nargs);
      if(!i) firstcolumn=column;
    }

    unit_select_ids[i]=punit->id;

    pcity = player_city_by_number(client_player(), punit->homecity);
    
    fc_snprintf(buffer, sizeof(buffer), "%s(%s)\n%s", 
	    utype_name_translation(punittemp), 
	    pcity ? city_name(pcity) : "",
	    unit_activity_text(punit));

    unit_select_pixmaps[i]=XCreatePixmap(display, XtWindow(map_canvas), 
					 tileset_full_tile_width(tileset), tileset_full_tile_height(tileset),
					 display_depth);

    XFillRectangle(display, unit_select_pixmaps[i], fill_bg_gc,
		   0, 0, tileset_full_tile_width(tileset), tileset_full_tile_height(tileset));
    store.pixmap = unit_select_pixmaps[i];
    put_unit(punit, &store, 0, 0);

    nargs=0;
    XtSetArg(args[nargs], XtNbitmap, (XtArgVal)unit_select_pixmaps[i]);nargs++;
    XtSetArg(args[nargs], XtNsensitive, 
             can_unit_do_activity(punit, ACTIVITY_IDLE));nargs++;
    if(i%r)  {
      XtSetArg(args[nargs], XtNfromVert, unit_select_commands[i-1]); nargs++;
    }
    unit_select_commands[i]=XtCreateManagedWidget("unitselectcommands", 
						  commandWidgetClass,
						  column, args, nargs);

    nargs=0;
    XtSetArg(args[nargs], XtNlabel, (XtArgVal)buffer); nargs++;
    XtSetArg(args[nargs], XtNfromHoriz, unit_select_commands[i]); nargs++;
    if(i%r) {
      XtSetArg(args[nargs], XtNfromVert, unit_select_commands[i-1]); nargs++;
    }
    unit_select_labels[i]=XtCreateManagedWidget("unitselectlabels", 
						labelWidgetClass, 
						column, args, nargs);

    XtAddCallback(unit_select_commands[i],
		  XtNdestroyCallback,free_bitmap_destroy_callback, NULL);
    XtAddCallback(unit_select_commands[i],
                  XtNcallback, unit_select_callback, NULL);
  }

  unit_select_no=i;

  unit_select_close_command =
    I_L(XtVaCreateManagedWidget("unitselectclosecommand", 
				commandWidgetClass,
				unit_select_form,
				XtNfromVert, firstcolumn,
				NULL));

  unit_select_all_command =
    I_L(XtVaCreateManagedWidget("unitselectallcommand", 
				commandWidgetClass,
				unit_select_form,
				XtNfromVert, firstcolumn,
				NULL));

  XtAddCallback(unit_select_close_command, XtNcallback, unit_select_callback, NULL);
  XtAddCallback(unit_select_all_command, XtNcallback, unit_select_all_callback, NULL);

  xaw_set_relative_position(toplevel, unit_select_dialog_shell, 15, 10);
  XtPopup(unit_select_dialog_shell, XtGrabNone);
}
Ejemplo n.º 13
0
main( int argc, char *argv[] )
{
  XtAppContext app_context;
  Widget toplevel, bb, pic, annotation;
  /*Widget button;*/


  toplevel = XtVaAppInitialize( &app_context,
                                "Test",
                                NULL, 0,
                                &argc, argv,
                                fallback_resources,
                                NULL );

  XtAddEventHandler( toplevel,
                     (EventMask)0,
                     True,_XEditResCheckMessages,
                     NULL );

  n = 0;
  XtSetArg( args[n], XmNheight, 400 ); n++;
  XtSetArg( args[n], XmNwidth, 400 ); n++;

  XtSetValues( toplevel, args, n );

  bb = XmCreateDrawingArea( toplevel, "bb", args, n );
  XtManageChild( bb );


  n = 0;
  XtSetArg( args[n], XmNx, 200 ); n++;
  XtSetArg( args[n], XmNy, 100 ); n++;
  annotation = XtCreateManagedWidget( "annotation",
                                      xipAnnotationWidgetClass,
                                      bb,
                                      args, n );
  XtAddCallback( annotation, XipNactivateCallback, activate, NULL );

  n = 0;
  XtSetArg( args[n], XmNx, 0 ); n++;
  XtSetArg( args[n], XmNy, 0 ); n++;
  XtSetArg( args[n], XipNquantisation, True ); n++;
  XtSetArg( args[n], XipNpic, mitkIpPicGet( "../b.pic", NULL ) ); n++;
  pic = XtCreateManagedWidget( "pic",
                               xipPicWidgetClass,
                               bb,
                               args, n );
/**************/
  XtRealizeWidget( toplevel );
/**************/
  {
    mitkIpPicDescriptor *pic;
    _mitkIpPicTagsElement_t *head;
    mitkIpPicTSV_t *tsv;

    pic = mitkIpPicGetTags( "../b.pic",
                        NULL );
    tsv = mitkIpPicQueryTag( pic, "ANNOTATION" );
    if( tsv != NULL )
      {
        head = tsv->value;

        tsv = _mitkIpPicFindTag( head, "TEXT" )->tsv;
        text = malloc( strlen(tsv->value) );
        strcpy( text, tsv->value );
        printf( "%s\n", text );

        tsv = _mitkIpPicFindTag( head, "POSITION" )->tsv;
        x = ((mitkIpUInt4_t *)(tsv->value))[0];
        y = ((mitkIpUInt4_t *)(tsv->value))[1];
        printf( "%i %i\n", x, y );
      }

    mitkIpPicFree( pic );
  }
/**************/
  XtVaSetValues( annotation,
                 XmNx, x,
                 XmNy, y,
                 NULL );
/**************/
  XtAppMainLoop(app_context);
}
Ejemplo n.º 14
0
/*******************************************************************************
          Name:        WatchWindow
          Description: Creates Watch menu
          arguments: 
          Returns:     None
*******************************************************************************/
void WatchWindow(
  Widget w,
  XtPointer client_data,
  XtPointer call_data)

  {
   void *theEnv = GetCurrentEnvironment();
  int n = 0,i;

  Widget Okay,cancel,All,none;
  static char *WidgetName[MAX_WATCH] = {"Compilations","Facts","Rules","Statistics","Activations",
                                        "Focus","Globals","Deffunctions","Generic Functions","Methods",
                                        "Instances","Slots","Messages-handlers","Messages"};

  /* ====================================================== */
  /*  If the watch shell have already existed pop it up,    */
  /*  else create it.                                       */
  /* ====================================================== */

  if(watchShell != NULL)
    {
       for(i = 0; i < MAX_WATCH; i++)
         {
           n = 0;
           if (EnvGetWatchItem(theEnv,WatchName[i]))
             XtSetArg( TheArgs[n],XtNstate,True);
           else
             XtSetArg( TheArgs[n],XtNstate,False);
           n++;
           XtSetValues(watch_widgets[i],TheArgs,n);
         }
       XtPopup(watchShell,XtGrabExclusive);
       return;
    }
  /* ========================================= */
  /*   Create the watch toggle menu            */
  /* ========================================= */

  XtSetArg( TheArgs[n], XtNwidth,250);n++;
  XtSetArg( TheArgs[n], XtNheight,400);n++;
  watchShell = XtCreatePopupShell("Watch Menu",topLevelShellWidgetClass,XtParent(w),NULL,0);
  n = 0;
  watchForm = XtCreateManagedWidget( "watch_form", formWidgetClass,
                                        watchShell, TheArgs,n);
  n = 0;
  XtSetArg(TheArgs[n],XtNwidth,150);n++;
  XtSetArg(TheArgs[n],XtNhorizDistance,15);n++;
  for(i = 0; i < 7;i++)
   {
     if (EnvGetWatchItem(theEnv,WatchName[i]))
        XtSetArg( TheArgs[n],XtNstate,True);
     else
        XtSetArg( TheArgs[n],XtNstate,False);
     n++;
     watch_widgets[i] = XtCreateManagedWidget(WidgetName[i],
                                      toggleWidgetClass,
                                      watchForm,
                                      TheArgs, n);
     n =  2;
     XtSetArg(TheArgs[n],XtNfromVert,watch_widgets[i]);n++;
  }
 n = 1;
 XtSetArg(TheArgs[n],XtNfromHoriz,watch_widgets[0]);n++;
 for(; i < MAX_WATCH ; i++)
  {
      if (EnvGetWatchItem(theEnv,WatchName[i]))
        XtSetArg( TheArgs[n],XtNstate,True);
      else
        XtSetArg( TheArgs[n],XtNstate,False);
      n++;
      watch_widgets[i] = XtCreateManagedWidget(WidgetName[i],
                                      toggleWidgetClass,
                                      watchForm,
                                      TheArgs, n);
      n = 1;
      XtSetArg(TheArgs[n],XtNfromVert,watch_widgets[i]);n++;
      XtSetArg(TheArgs[n],XtNfromHoriz,watch_widgets[i - 7]);n++;
  }
  /* ======================= */
  /* Create the "All" button */
  /* ======================= */

  n = 0;
  XtSetArg(TheArgs[n],XtNcornerRoundPercent,40);n++;
  XtSetArg(TheArgs[n],XtNshapeStyle,XmuShapeRoundedRectangle);n++;
  XtSetArg(TheArgs[n],XtNwidth,150);n++;
  XtSetArg(TheArgs[n],XtNfromVert,watch_widgets[6]);n++;
  XtSetArg(TheArgs[n],XtNvertDistance,31);n++;
  XtSetArg(TheArgs[n],XtNlabel,"All");n++;
  All = XtCreateManagedWidget("watchButton",
                                       commandWidgetClass,
                                        watchForm,
                                        TheArgs, n);
  XtAddCallback(All, XtNcallback, WatchAllCallback, NULL);

  /* ============================= */
  /* Create the "None" button      */
  /* ============================= */

  n = 3;
  XtSetArg(TheArgs[n],XtNfromHoriz,All);n++;
  XtSetArg(TheArgs[n],XtNfromVert,watch_widgets[6]);n++;
  XtSetArg(TheArgs[n],XtNvertDistance,31);n++;
  XtSetArg(TheArgs[n],XtNhorizDistance,30);n++;
  XtSetArg(TheArgs[n],XtNlabel,"None");n++;
  none = XtCreateManagedWidget("watchButton",
                                       commandWidgetClass,
                                        watchForm,TheArgs,n);
  XtAddCallback(none, XtNcallback, WatchNoneCallback, NULL);

  /* ================================ */
  /* Create the "Okay" button         */
  /* ================================ */

  n = 3;
  XtSetArg(TheArgs[n],XtNfromVert,All);n++;
  XtSetArg(TheArgs[n],XtNvertDistance,15);n++;
  XtSetArg(TheArgs[n],XtNlabel,"Okay");n++;
  Okay = XtCreateManagedWidget("watchButton",
                                       commandWidgetClass,
                                        watchForm,
                                        TheArgs, n);
  XtAddCallback(Okay,XtNcallback,OkWatchCallback,(XtPointer)watchForm);

  /* ================================ */
  /*   Create the "Cancel" button     */
  /* ================================ */

  n = 3;
  XtSetArg(TheArgs[n],XtNfromVert,none);n++;
  XtSetArg(TheArgs[n],XtNvertDistance,15);n++;
  XtSetArg(TheArgs[n],XtNfromHoriz,Okay);n++;
  XtSetArg(TheArgs[n],XtNlabel,"Cancel");n++;
  XtSetArg(TheArgs[n],XtNhorizDistance,30);n++;
  cancel = XtCreateManagedWidget("watchButton",
                                       commandWidgetClass,
                                        watchForm,
                                        TheArgs, n);
  XtAddCallback(cancel,XtNcallback,PopdownSelect,(XtPointer)watchForm);
  XtPopup(watchShell,XtGrabExclusive);
  }
Ejemplo n.º 15
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;

	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;

	/* Hack  ox==oy in xaw port */

	/* Window specific inner border offset (ox) */
	sprintf(buf, "ANGBAND_X11_IBOX_%d", i);
	str = getenv(buf);
	val = (str != NULL) ? atoi(str) : -1;
	if (val > 0) widget_arg[6].value = val;

	/* Window specific inner border offset (oy) */
	sprintf(buf, "ANGBAND_X11_IBOY_%d", i);
	str = getenv(buf);
	val = (str != NULL) ? atoi(str) : -1;
	if (val > 0) widget_arg[6].value = val;

	/* 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->wipe_hook = Term_wipe_xaw;
	t->text_hook = Term_text_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;

		/* Check if the font exists */
		fnt = getFont(td->widget, (String) get_default_font(i), 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;
			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;
}
Ejemplo n.º 16
0
void create_print_panel(Widget w)
{
	Widget	    image;
	Widget	    entry,mag_spinner, below, fitpage;
	Pixmap	    p;
	unsigned    long fg, bg;
	char	   *printer_val;
	char	    buf[100];
	char	   *unit;
	int	    ux,uy,lx,ly;
	int	    i,len,maxl;
	float	    mult;

	XtTranslateCoords(tool, (Position) 0, (Position) 0, &xposn, &yposn);

	FirstArg(XtNx, xposn+50);
	NextArg(XtNy, yposn+50);
	NextArg(XtNtitle, "Xfig: Print menu");
	NextArg(XtNcolormap, tool_cm);
	print_popup = XtCreatePopupShell("print_popup",
					 transientShellWidgetClass,
					 tool, Args, ArgCount);
        XtOverrideTranslations(print_popup,
                           XtParseTranslationTable(prn_translations));
        XtAppAddActions(tool_app, prn_actions, XtNumber(prn_actions));

	print_panel = XtCreateManagedWidget("print_panel", formWidgetClass,
					    print_popup, NULL, ZERO);

	/* start with the picture of the printer */

	FirstArg(XtNlabel, "   ");
	NextArg(XtNwidth, printer_ic.width);
	NextArg(XtNheight, printer_ic.height);
	NextArg(XtNborderWidth, 0);
	NextArg(XtNinternalWidth, 0);
	NextArg(XtNinternalHeight, 0);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	image = XtCreateManagedWidget("printer_image", labelWidgetClass,
				      print_panel, Args, ArgCount);
	FirstArg(XtNforeground, &fg);
	NextArg(XtNbackground, &bg);
	GetValues(image);
	p = XCreatePixmapFromBitmapData(tool_d, XtWindow(canvas_sw),
		      printer_ic.bits, printer_ic.width, printer_ic.height,
		      fg, bg, tool_dpth);
	FirstArg(XtNbitmap, p);
	SetValues(image);

	FirstArg(XtNlabel, "Print to PostScript Printer");
	NextArg(XtNfromHoriz, image);
	NextArg(XtNborderWidth, 0);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	(void) XtCreateManagedWidget("print_label", labelWidgetClass,
					print_panel, Args, ArgCount);

	FirstArg(XtNlabel, " Magnification %");
	NextArg(XtNfromVert, image);
	NextArg(XtNborderWidth, 0);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	beside = XtCreateManagedWidget("mag_label", labelWidgetClass,
					print_panel, Args, ArgCount);

	/* make a spinner entry for the mag */
	/* note: this was called "magnification" */
	sprintf(buf, "%.1f", appres.magnification);
	mag_spinner = MakeFloatSpinnerEntry(print_panel, &print_mag_text, "magnification",
				image, beside, update_mag, buf, 0.0, 10000.0, 1.0, 45);

	/* we want to track typing here to update figure size label */

	XtOverrideTranslations(print_mag_text,
			       XtParseTranslationTable(print_translations));

	/* Fit Page to the right of the magnification window */

	FirstArg(XtNlabel, "Fit to Page");
	NextArg(XtNfromVert, image);
	NextArg(XtNfromHoriz, mag_spinner);
	NextArg(XtNborderWidth, INTERNAL_BW);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	fitpage = XtCreateManagedWidget("fitpage", commandWidgetClass,
				       print_panel, Args, ArgCount);
	XtAddEventHandler(fitpage, ButtonReleaseMask, False,
			  (XtEventHandler)fit_page, (XtPointer) NULL);

	/* Figure Size to the right of the fit page window */

	mult = appres.INCHES? PIX_PER_INCH : PIX_PER_CM;
	unit = appres.INCHES? "in": "cm";
	/* get the size of the figure */
	compound_bound(&objects, &lx, &ly, &ux, &uy);
	sprintf(buf, "Fig Size: %.1f%s x %.1f%s      ",
		(float)(ux-lx)/mult*appres.magnification/100.0,unit,
		(float)(uy-ly)/mult*appres.magnification/100.0,unit);
	FirstArg(XtNlabel, buf);
	NextArg(XtNfromVert, image);
	NextArg(XtNfromHoriz, fitpage);
	NextArg(XtNhorizDistance, 5);
	NextArg(XtNborderWidth, 0);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	size_lab = XtCreateManagedWidget("size_label", labelWidgetClass,
					print_panel, Args, ArgCount);

	/* paper size */

	FirstArg(XtNlabel, "      Paper Size");
	NextArg(XtNborderWidth, 0);
	NextArg(XtNfromVert, fitpage);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	beside = XtCreateManagedWidget("papersize_label", labelWidgetClass,
					 print_panel, Args, ArgCount);

	FirstArg(XtNlabel, paper_sizes[appres.papersize].fname);
	NextArg(XtNfromHoriz, beside);
	NextArg(XtNfromVert, fitpage);
	NextArg(XtNborderWidth, INTERNAL_BW);
	NextArg(XtNresizable, True);
	NextArg(XtNrightBitmap, menu_arrow);	/* use menu arrow for pull-down */
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	print_papersize_panel = XtCreateManagedWidget("papersize",
					   menuButtonWidgetClass,
					   print_panel, Args, ArgCount);
	papersize_menu = XtCreatePopupShell("menu", simpleMenuWidgetClass, 
				    print_papersize_panel, NULL, ZERO);

	/* make the menu items */
	for (i = 0; i < XtNumber(paper_sizes); i++) {
	    entry = XtCreateManagedWidget(paper_sizes[i].fname, smeBSBObjectClass, 
					papersize_menu, NULL, ZERO);
	    XtAddCallback(entry, XtNcallback, papersize_select, (XtPointer) i);
	}

	/* Orientation */

	FirstArg(XtNlabel, "     Orientation");
	NextArg(XtNborderWidth, 0);
	NextArg(XtNfromVert, print_papersize_panel);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	beside = XtCreateManagedWidget("orient_label", labelWidgetClass,
					   print_panel, Args, ArgCount);

	FirstArg(XtNfromHoriz, beside);
	NextArg(XtNfromVert, print_papersize_panel);
	NextArg(XtNborderWidth, INTERNAL_BW);
	NextArg(XtNleftBitmap, menu_arrow);	/* use menu arrow for pull-down */
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	print_orient_panel = XtCreateManagedWidget(orient_items[appres.landscape],
					     menuButtonWidgetClass,
					     print_panel, Args, ArgCount);
	make_pulldown_menu(orient_items, XtNumber(orient_items), -1, "",
				      print_orient_panel, orient_select);

	FirstArg(XtNlabel, "Justification");
	NextArg(XtNborderWidth, 0);
	NextArg(XtNfromHoriz, print_orient_panel);
	NextArg(XtNfromVert, print_papersize_panel);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	just_lab = XtCreateManagedWidget("just_label", labelWidgetClass,
					 print_panel, Args, ArgCount);

	FirstArg(XtNlabel, just_items[appres.flushleft? 1 : 0]);
	NextArg(XtNfromHoriz, just_lab);
	NextArg(XtNfromVert, print_papersize_panel);
	NextArg(XtNborderWidth, INTERNAL_BW);
	NextArg(XtNleftBitmap, menu_arrow);	/* use menu arrow for pull-down */
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	print_just_panel = XtCreateManagedWidget("justify",
					   menuButtonWidgetClass,
					   print_panel, Args, ArgCount);
	make_pulldown_menu(just_items, XtNumber(just_items), -1, "",
				    print_just_panel, just_select);

	/* multiple/single page */

	FirstArg(XtNlabel, "           Pages");
	NextArg(XtNborderWidth, 0);
	NextArg(XtNfromVert, print_just_panel);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	beside = XtCreateManagedWidget("multiple_label", labelWidgetClass,
					 print_panel, Args, ArgCount);

	FirstArg(XtNlabel, multiple_pages[appres.multiple? 1:0]);
	NextArg(XtNfromHoriz, beside);
	NextArg(XtNfromVert, print_just_panel);
	NextArg(XtNborderWidth, INTERNAL_BW);
	NextArg(XtNleftBitmap, menu_arrow);	/* use menu arrow for pull-down */
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	print_multiple_panel = XtCreateManagedWidget("multiple_pages",
					   menuButtonWidgetClass,
					   print_panel, Args, ArgCount);
	make_pulldown_menu(multiple_pages, XtNumber(multiple_pages), -1, "",
				    print_multiple_panel, multiple_select);

	FirstArg(XtNlabel, overlap_pages[appres.overlap? 1:0]);
	NextArg(XtNfromHoriz, print_multiple_panel);
	NextArg(XtNfromVert, print_just_panel);
	NextArg(XtNborderWidth, INTERNAL_BW);
	NextArg(XtNleftBitmap, menu_arrow);	/* use menu arrow for pull-down */
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	print_overlap_panel = XtCreateManagedWidget("overlap_pages",
					   menuButtonWidgetClass,
					   print_panel, Args, ArgCount);
	make_pulldown_menu(overlap_pages, XtNumber(overlap_pages), -1, "",
				    print_overlap_panel, overlap_select);

	/* background color */

	FirstArg(XtNlabel, "Background");
	NextArg(XtNfromHoriz, print_overlap_panel);
	NextArg(XtNfromVert, print_just_panel);
	NextArg(XtNborderWidth, 0);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	beside = XtCreateManagedWidget("background_label", labelWidgetClass,
					 print_panel, Args, ArgCount);

	FirstArg(XtNfromHoriz, beside);
	NextArg(XtNfromVert, print_just_panel);
	NextArg(XtNresize, False);
	NextArg(XtNwidth, 80);
	NextArg(XtNborderWidth, INTERNAL_BW);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	print_background_panel = XtCreateManagedWidget("background",
					   menuButtonWidgetClass,
					   print_panel, Args, ArgCount);

	/* now set the color and name in the background button */
	set_but_col(print_background_panel, export_background_color);

	/* make color menu */
	background_menu = make_color_popup_menu(print_background_panel, 
					"Background Color", background_select,
					NO_TRANSP, INCL_BACKG);
	/* grid options */
	FirstArg(XtNlabel, "            Grid");
	NextArg(XtNfromVert, print_background_panel);
	NextArg(XtNborderWidth, 0);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	beside = XtCreateManagedWidget("grid_label", labelWidgetClass,
					    print_panel, Args, ArgCount);
	below = make_grid_options(print_panel, print_background_panel, beside, minor_grid, major_grid,
				&print_grid_minor_menu_button, &print_grid_major_menu_button,
				&print_grid_minor_menu, &print_grid_major_menu,
				&print_grid_minor_text, &print_grid_major_text,
				&print_grid_unit_label,
				print_grid_major_select, print_grid_minor_select);

	/* printer name */

	FirstArg(XtNlabel, "         Printer");
	NextArg(XtNfromVert, below);
	NextArg(XtNborderWidth, 0);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	beside = XtCreateManagedWidget("printer_label", labelWidgetClass,
					    print_panel, Args, ArgCount);
	/*
	 * don't SetValue the XtNstring so the user may specify the default
	 * printer in a resource, e.g.:	 *printer*string: at6
	 */

	FirstArg(XtNwidth, 200);
	NextArg(XtNleftMargin, 4);
	NextArg(XtNfromVert, below);
	NextArg(XtNfromHoriz, beside);
	NextArg(XtNeditType, XawtextEdit);
	NextArg(XtNinsertPosition, 0);
	NextArg(XtNborderWidth, INTERNAL_BW);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	printer_text = XtCreateManagedWidget("printer", asciiTextWidgetClass,
					     print_panel, Args, ArgCount);

	XtOverrideTranslations(printer_text,
			       XtParseTranslationTable(print_translations));

	/* put the printer name in the label if resource isn't set */
	FirstArg(XtNstring, &printer_val);
	GetValues(printer_text);
	/* no printer name specified in resources, get PRINTER environment
	   var and put it into the widget */
	if (emptyname(printer_val)) {
		printer_val=getenv("PRINTER");
		if ((printer_val!=NULL) && strchr(printer_val,'\\')) {
		    buf[0]='\0';
		    len=0;
		    for (i=0; i<strlen(printer_val); i++) {
		    	buf[len++] = printer_val[i];
		    	if (printer_val[i]=='\\')
			    buf[len++]='\\';
		    }
		    buf[len++]='\0';
		    printer_val = buf;
		}
		if (printer_val == NULL) {
			printer_val = "";
		} else {
			FirstArg(XtNstring, printer_val);
			SetValues(printer_text);
		}
	}
	/* parse /etc/printcap for printernames for the pull-down menu */
	numprinters = parse_printcap(printer_names);
	/* find longest name */
	maxl = 0;
	for (i=0; i<numprinters; i++) {
	    len=strlen(printer_names[i]);
	    if (len > maxl) {
		maxl = len;
	    }
	}
	/* make string of blanks the length of the longest printer name */
	buf[0] = '\0';
	for (i=0; i<maxl; i++)
	    strcat(buf," ");
	if (numprinters > 0) {
	    FirstArg(XtNlabel, buf);
	    NextArg(XtNfromHoriz, printer_text);
	    NextArg(XtNfromVert, below);
	    NextArg(XtNborderWidth, INTERNAL_BW);
	    NextArg(XtNleftBitmap, menu_arrow);	/* use menu arrow for pull-down */
	    NextArg(XtNtop, XtChainTop);
	    NextArg(XtNbottom, XtChainTop);
	    NextArg(XtNleft, XtChainLeft);
	    NextArg(XtNright, XtChainLeft);
	    printer_menu_button = XtCreateManagedWidget("printer_names",
					   menuButtonWidgetClass,
					   print_panel, Args, ArgCount);
	    make_pulldown_menu(printer_names, numprinters, -1, "",
				    printer_menu_button, printer_select);
	}

	FirstArg(XtNlabel, "Print Job Params");
	NextArg(XtNfromVert, printer_text);
	NextArg(XtNborderWidth, 0);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	beside = XtCreateManagedWidget("job_params_label", labelWidgetClass,
					    print_panel, Args, ArgCount);
	/*
	 * don't SetValue the XtNstring so the user may specify the default
	 * job parameters in a resource, e.g.:	 *param*string: -K2
	 */

	FirstArg(XtNwidth, 200);
	NextArg(XtNfromVert, printer_text);
	NextArg(XtNfromHoriz, beside);
	NextArg(XtNeditType, XawtextEdit);
	NextArg(XtNinsertPosition, 0);
	NextArg(XtNborderWidth, INTERNAL_BW);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	param_text = XtCreateManagedWidget("job_params", asciiTextWidgetClass,
					     print_panel, Args, ArgCount);

	XtOverrideTranslations(param_text,
			       XtParseTranslationTable(print_translations));

	FirstArg(XtNlabel, "Figures in batch");
	NextArg(XtNfromVert, param_text);
	NextArg(XtNborderWidth, 0);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	beside = XtCreateManagedWidget("num_batch_label", labelWidgetClass,
					    print_panel, Args, ArgCount);
	FirstArg(XtNwidth, 30);
	NextArg(XtNlabel, "  0");
	NextArg(XtNfromVert, param_text);
	NextArg(XtNfromHoriz, beside);
	NextArg(XtNborderWidth, INTERNAL_BW);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	num_batch = XtCreateManagedWidget("num_batch", labelWidgetClass,
					     print_panel, Args, ArgCount);

	FirstArg(XtNlabel, "Dismiss");
	NextArg(XtNfromVert, num_batch);
	NextArg(XtNvertDistance, 10);
	NextArg(XtNhorizDistance, 6);
	NextArg(XtNheight, 35);
	NextArg(XtNborderWidth, INTERNAL_BW);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	dismiss = XtCreateManagedWidget("dismiss", commandWidgetClass,
				       print_panel, Args, ArgCount);
	XtAddEventHandler(dismiss, ButtonReleaseMask, False,
			  (XtEventHandler)print_panel_dismiss, (XtPointer) NULL);

	/* radio for printing all layers */

	beside = make_layer_choice("Print all layers ", "Print only active",
				print_panel, num_batch, dismiss, 6, 6);

	/* print buttons */

	FirstArg(XtNlabel, "Print FIGURE\nto Printer");
	NextArg(XtNfromVert, num_batch);
	NextArg(XtNfromHoriz, beside);
	NextArg(XtNresize, False);	/* must not allow resize because the label changes */
	NextArg(XtNheight, 35);
	NextArg(XtNborderWidth, INTERNAL_BW);
	NextArg(XtNvertDistance, 10);
	NextArg(XtNhorizDistance, 6);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	print = XtCreateManagedWidget("print", commandWidgetClass,
				      print_panel, Args, ArgCount);
	XtAddEventHandler(print, ButtonReleaseMask, False,
			  (XtEventHandler)do_print, (XtPointer) NULL);

	FirstArg(XtNlabel, "Print FIGURE\nto Batch");
	NextArg(XtNfromVert, num_batch);
	NextArg(XtNfromHoriz, print);
	NextArg(XtNheight, 35);
	NextArg(XtNborderWidth, INTERNAL_BW);
	NextArg(XtNvertDistance, 10);
	NextArg(XtNhorizDistance, 6);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	print_batch = XtCreateManagedWidget("print_batch", commandWidgetClass,
				      print_panel, Args, ArgCount);
	XtAddEventHandler(print_batch, ButtonReleaseMask, False,
			  (XtEventHandler)do_print_batch, (XtPointer) NULL);

	FirstArg(XtNlabel, "Clear\nBatch");
	NextArg(XtNfromVert, num_batch);
	NextArg(XtNfromHoriz, print_batch);
	NextArg(XtNheight, 35);
	NextArg(XtNborderWidth, INTERNAL_BW);
	NextArg(XtNvertDistance, 10);
	NextArg(XtNhorizDistance, 6);
	NextArg(XtNtop, XtChainTop);
	NextArg(XtNbottom, XtChainTop);
	NextArg(XtNleft, XtChainLeft);
	NextArg(XtNright, XtChainLeft);
	clear_batch = XtCreateManagedWidget("clear_batch", commandWidgetClass,
				      print_panel, Args, ArgCount);
	XtAddEventHandler(clear_batch, ButtonReleaseMask, False,
			  (XtEventHandler)do_clear_batch, (XtPointer) NULL);

	/* install accelerators for the following functions */
	XtInstallAccelerators(print_panel, dismiss);
	XtInstallAccelerators(print_panel, print_batch);
	XtInstallAccelerators(print_panel, clear_batch);
	XtInstallAccelerators(print_panel, print);
	update_batch_count();

	/* if multiple pages is on, desensitive justification panels */
	if (appres.multiple) {
	    XtSetSensitive(just_lab, False);
	    XtSetSensitive(print_just_panel, False);
	    if (export_just_panel) {
	        XtSetSensitive(just_lab, False);
	        XtSetSensitive(export_just_panel, False);
	    }
	} else {
	    XtSetSensitive(just_lab, True);
	    XtSetSensitive(print_just_panel, True);
	    if (export_just_panel) {
	        XtSetSensitive(just_lab, True);
	        XtSetSensitive(export_just_panel, True);
	    }
	}
}
Ejemplo n.º 17
0
static void motTabsChildAddedMethod(Ihandle* ih, Ihandle* child)
{
  if (IupGetName(child) == NULL)
    iupAttribSetHandleName(child);

  if (ih->handle)
  {
    Widget child_manager;
    Widget tab_button;
    int num_args = 0, pos;
    Arg args[30];
    char *tabtitle, *tabimage, *background;
    Pixel color;

    /* open space for new tab number */
    motTabsUpdatePageNumber(ih);

    pos = IupGetChildPos(ih, child);

    /* Create pages */
    child_manager = XtVaCreateManagedWidget(
                    "child_manager",
                    xmBulletinBoardWidgetClass,
                    ih->handle,
                    /* Core */
                    XmNborderWidth, 0,
                    /* Manager */
                    XmNshadowThickness, 0,
                    XmNnavigationType, XmTAB_GROUP,
                    XmNuserData, child, /* used only in motTabsConfigureNotify  */
                    /* BulletinBoard */
                    XmNmarginWidth, 0,
                    XmNmarginHeight, 0,
                    XmNresizePolicy, XmRESIZE_NONE, /* no automatic resize of children */
                    /* Notebook Constraint */
                    XmNnotebookChildType, XmPAGE,
                    XmNpageNumber, pos,
                    XmNresizable, True,
                    NULL);   

    XtOverrideTranslations(child_manager, XtParseTranslationTable("<Configure>: iupTabsConfigure()"));

    tabtitle = iupAttribGet(child, "TABTITLE");
    if (!tabtitle) tabtitle = iupTabsAttribGetStrId(ih, "TABTITLE", pos);
    tabimage = iupAttribGet(child, "TABIMAGE");
    if (!tabimage) tabimage = iupTabsAttribGetStrId(ih, "TABIMAGE", pos);
    if (!tabtitle && !tabimage)
      tabtitle = "     ";

    /* Create tabs */
    /* Label */
    iupmotSetArg(args[num_args++], XmNlabelType, tabtitle? XmSTRING: XmPIXMAP);
    iupmotSetArg(args[num_args++], XmNmarginHeight, 0);
    iupmotSetArg(args[num_args++], XmNmarginWidth, 0);
    /* Notebook Constraint */
    iupmotSetArg(args[num_args++], XmNnotebookChildType, XmMAJOR_TAB);
    iupmotSetArg(args[num_args++], XmNpageNumber, pos);
    tab_button = XtCreateManagedWidget("tab_button", xmPushButtonWidgetClass, ih->handle, args, num_args);

    /* Disable Drag Source */
    iupmotDisableDragSource(tab_button);

    XtAddEventHandler(tab_button, EnterWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih);
    XtAddEventHandler(tab_button, LeaveWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih);
    XtAddEventHandler(tab_button, FocusChangeMask, False, (XtEventHandler)iupmotFocusChangeEvent, (XtPointer)ih);
    XtAddEventHandler(tab_button, KeyPressMask,    False, (XtEventHandler)iupmotKeyPressEvent, (XtPointer)ih);

    if (tabtitle)
      iupmotSetString(tab_button, XmNlabelString, tabtitle);
    else
    {
      Pixmap pixmap = (Pixmap)iupImageGetImage(tabimage, ih, 0, "TABIMAGE");
      if (pixmap)
        XtVaSetValues(tab_button, XmNlabelPixmap, pixmap, NULL);
    }

    background = iupBaseNativeParentGetBgColorAttrib(ih);
    color = iupmotColorGetPixelStr(background);
    if (color != -1)
      iupmotSetBgColor(child_manager, color);
    else
    {
      Pixmap pixmap = (Pixmap)iupImageGetImage(background, ih, 0, "BACKGROUND");
      if (pixmap)
      {
        XtVaSetValues(child_manager, XmNbackgroundPixmap, pixmap, NULL);
      }
    }

    background = iupAttribGetStr(ih, "BGCOLOR");
    color = iupmotColorGetPixelStr(background);
    if (color != -1)
      iupmotSetBgColor(tab_button, color);

    color = iupmotColorGetPixelStr(IupGetAttribute(ih, "FGCOLOR"));
    XtVaSetValues(tab_button, XmNforeground, color, NULL);

    XtRealizeWidget(child_manager);
    XtRealizeWidget(tab_button);

    iupAttribSetStr(child, "_IUPTAB_CONTAINER", (char*)child_manager);
    iupAttribSetStr(child, "_IUPMOT_TABBUTTON", (char*)tab_button);
    iupAttribSetInt(child, "_IUPMOT_TABNUMBER", pos);
  }
}
Ejemplo n.º 18
0
static int motProgressBarMapMethod(Ihandle* ih)
{
  int num_args = 0;
  Arg args[30];
 
  /* Core */
  iupMOT_SETARG(args, num_args, XmNmappedWhenManaged, False);  /* not visible when managed */
  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 */
  /* Primitive */
  iupMOT_SETARG(args, num_args, XmNtraversalOn, False);
  iupMOT_SETARG(args, num_args, XmNhighlightThickness, 0);
  /* Scale */
  iupMOT_SETARG(args, num_args, XmNminimum,   0);
  iupMOT_SETARG(args, num_args, XmNmaximum, SHRT_MAX);
  iupMOT_SETARG(args, num_args, XmNsliderMark, XmNONE);
  iupMOT_SETARG(args, num_args, XmNsliderVisual, XmTROUGH_COLOR);
  iupMOT_SETARG(args, num_args, XmNeditable, False);
  iupMOT_SETARG(args, num_args, XmNshowValue, XmNONE);

  if (iupStrEqualNoCase(iupAttribGetStr(ih, "ORIENTATION"), "VERTICAL"))
  {
    iupMOT_SETARG(args, num_args, XmNorientation, XmVERTICAL);

    if (ih->currentheight < ih->currentwidth)
    {
      int tmp = ih->currentheight;
      ih->currentheight = ih->currentwidth;
      ih->currentwidth = tmp;
    }
  }
  else
    iupMOT_SETARG(args, num_args, XmNorientation, XmHORIZONTAL);

  if (iupAttribGetBoolean(ih, "MARQUEE"))
  {
    ih->data->marquee = 1;
    ih->data->timer = IupTimer();
    IupSetCallback(ih->data->timer, "ACTION_CB", (Icallback)motProgressBarTimeCb);
    IupSetAttribute(ih->data->timer, "TIME", "100");
    iupAttribSet(ih->data->timer, "_IUP_PROGRESSBAR", (char*)ih);
    iupMOT_SETARG(args, num_args, XmNslidingMode, XmSLIDER);
  }
  else
  {
    iupMOT_SETARG(args, num_args, XmNslidingMode, XmTHERMOMETER);
    ih->data->marquee = 0;
  }
  
  ih->handle = XtCreateManagedWidget(
    iupDialogGetChildIdStr(ih),  /* child identifier */
    xmScaleWidgetClass,          /* widget class */
    iupChildTreeGetNativeParentHandle(ih), /* widget parent */
    args, num_args);

  if (!ih->handle)
    return IUP_ERROR;

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

  XtAddEventHandler(ih->handle, EnterWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih);
  XtAddEventHandler(ih->handle, LeaveWindowMask, False, (XtEventHandler)iupmotEnterLeaveWindowEvent, (XtPointer)ih);

  /* initialize the widget */
  XtRealizeWidget(ih->handle);

  return IUP_NOERROR;
}
Ejemplo n.º 19
0
Widget 
make_queryform(Widget parent,	    /* into whom widget should be placed */
	       const char* msgstr,  /* message string */
	       const char* button,  /* button title */
	       const char* title)   /* form title */
{
    Widget form, text, prev;
    Arg args[10];
    Cardinal n;
    char *shell_geom;
    int x, y, geom_flags;
    unsigned int shell_w, shell_h;
    Dimension max_width, max_height;

    form = XtVaCreateManagedWidget ("form", formWidgetClass, parent, 
				    XtNtitle, button,
				    NULL);

    text = XtVaCreateManagedWidget
	("message", asciiTextWidgetClass, form,
	 XtNleft, XtChainLeft,
	 XtNright, XtChainRight,
	 XtNtop, XtChainTop,
	 XtNbottom, XtChainBottom,
	 XtNdisplayCaret, False,
	 XtNlength, strlen (msgstr),
	 XtNstring, msgstr,
	 NULL);
    /*
     * Did the user specify our geometry?
     * If so, don't bother computing it ourselves, since we will be overridden.
     */
    XtVaGetValues(parent, XtNgeometry, &shell_geom, NULL);
    geom_flags = XParseGeometry(shell_geom, &x, &y, &shell_w, &shell_h);
    if (!(geom_flags & WidthValue && geom_flags & HeightValue))
    {
	Dimension width, height, height_addons = 0;
	Dimension scroll_size, border_width;
	Widget label, scroll;
	Position left, right, top, bottom;
	const char *tmp;
	/*
	 * A Text widget is used for the automatic scroll bars.
	 * But Text widget doesn't automatically compute its size.
	 * The Label widget does that nicely, so we create one and examine it.
	 * This widget is never visible.
	 */
	XtVaGetValues(text, XtNtopMargin, &top, XtNbottomMargin, &bottom,
		      XtNleftMargin, &left, XtNrightMargin, &right, (void*)0);
	label = XtVaCreateWidget("message", labelWidgetClass, form,
				 XtNlabel, msgstr,
				 XtNinternalWidth, (left+right+1)/2,
				 XtNinternalHeight, (top+bottom+1)/2,
				 NULL);
	XtVaGetValues(label, XtNwidth, &width, XtNheight, &height, NULL);
	XtDestroyWidget(label);
	max_width = .7 * WidthOfScreen(XtScreen(text));
	max_height = .7 * HeightOfScreen(XtScreen(text));
	if (width > max_width)
	{
	    width = max_width;
	    /* add in the height of any horizontal scroll bar */
	    scroll = XtVaCreateWidget("hScrollbar", scrollbarWidgetClass, text,
				      XtNorientation, XtorientHorizontal,
				      NULL);
	    XtVaGetValues(scroll, XtNheight, &scroll_size,
			  XtNborderWidth, &border_width, NULL);
	    XtDestroyWidget(scroll);
	    height_addons = scroll_size + border_width;
	}

	/* This fixes the xmessage assumption that the label widget and the
	 * text widget have the same size. In Xaw 7, the text widget has
	 * one extra pixel between lines.
	 * Xmessage is not internationalized, so the code bellow is harmless.
	 */
	tmp = msgstr;
	while (tmp != 0 && *tmp)
	{
	    ++tmp;
	    ++height;
	    tmp = strchr(tmp, '\n');
	}

	if (height > max_height)
	{
	    height = max_height;
	    /* add in the width of any vertical scroll bar */
	    scroll = XtVaCreateWidget("vScrollbar", scrollbarWidgetClass, text,
				      XtNorientation, XtorientVertical, NULL);
	    XtVaGetValues(scroll, XtNwidth, &scroll_size,
			  XtNborderWidth, &border_width, NULL);
	    XtDestroyWidget(scroll);
	    width += scroll_size + border_width;
	}
	height += height_addons;
	XtVaSetValues(text, XtNwidth, width, XtNheight, height, NULL);
    }
    /*
     * Create the buttons
     */
    n = 0;
    XtSetArg (args[n], XtNleft, XtChainLeft); n++;
    XtSetArg (args[n], XtNright, XtChainLeft); n++;
    XtSetArg (args[n], XtNtop, XtChainBottom); n++;
    XtSetArg (args[n], XtNbottom, XtChainBottom); n++;
    XtSetArg (args[n], XtNfromVert, text); n++;
    XtSetArg (args[n], XtNvertDistance, 5); n++;

    prev = 0;
    XtSetArg (args[n], XtNfromHoriz, prev); 
    prev = XtCreateManagedWidget (button, commandWidgetClass,
				      form, args, n);
    XtAddCallback (prev, XtNcallback, handle_button, 0);
    Dimension border;

    XtVaGetValues(prev, XtNborderWidth, &border, NULL);
    border *= 2;
    XtVaSetValues(prev, XtNborderWidth, border, NULL);
    return form;
}
Ejemplo n.º 20
0
Archivo: light.c Proyecto: Thump/sceda
static void
Create_Arealight_Dialog()
{
	Widget	form;
	Widget	labels[3];
	Widget	done, cancel;
	Arg		args[15];
	int		m, n;

	n = 0;
	XtSetArg(args[n], XtNtitle, "Arealight");		n++;
	XtSetArg(args[n], XtNallowShellResize, TRUE);	n++;
	arealight_shell = XtCreatePopupShell("arealightShell",
						transientShellWidgetClass, main_window.shell, args, n);

	n = 0;
	form = XtCreateManagedWidget("arealightForm", formWidgetClass,
								 arealight_shell, args, n);

	/* Common args. */
	m = 0;
	XtSetArg(args[m], XtNleft, XtChainLeft);		m++;
	XtSetArg(args[m], XtNright, XtChainRight);		m++;
	XtSetArg(args[m], XtNtop, XtChainTop);			m++;
	XtSetArg(args[m], XtNbottom, XtChainBottom);	m++;

	/* Intensity label. */
	n = m;
	XtSetArg(args[n], XtNlabel, "Intensity");		n++;
	XtSetArg(args[n], XtNborderWidth, 0);			n++;
	labels[0] = XtCreateManagedWidget("arealightIntensityLabel",
									  labelWidgetClass, form, args, n);

	/* Intensity text. */
	n = m;
	XtSetArg(args[n], XtNeditType, XawtextEdit);		n++;
	XtSetArg(args[n], XtNlength, MAX_STRING_LENGTH);	n++;
	XtSetArg(args[n], XtNuseStringInPlace, TRUE);		n++;
	XtSetArg(args[n], XtNstring, intensity_string);		n++;
	XtSetArg(args[n], XtNfromHoriz, labels[0]);			n++;
	arealight_intensity_text = XtCreateManagedWidget("arealightIntensityText",
					asciiTextWidgetClass, form, args, n);
	XtOverrideTranslations(arealight_intensity_text,
		XtParseTranslationTable(":<Key>Return: no-op(RingBell)"));

	/* Xnum label. */
	n = m;
	XtSetArg(args[n], XtNlabel, "Xnum");						n++;
	XtSetArg(args[n], XtNborderWidth, 0);						n++;
	XtSetArg(args[n], XtNfromVert, arealight_intensity_text);	n++;
	labels[1] = XtCreateManagedWidget("arealightXnumLabel",
									  labelWidgetClass, form, args, n);

	/* Xnum text. */
	n = m;
	XtSetArg(args[n], XtNeditType, XawtextEdit);		n++;
	XtSetArg(args[n], XtNlength, MAX_STRING_LENGTH);	n++;
	XtSetArg(args[n], XtNuseStringInPlace, TRUE);		n++;
	XtSetArg(args[n], XtNstring, xnum_string);			n++;
	XtSetArg(args[n], XtNfromHoriz, labels[1]);			n++;
	XtSetArg(args[n], XtNfromVert, arealight_intensity_text);	n++;
	xnum_text = XtCreateManagedWidget("arealightXnumText",
					asciiTextWidgetClass, form, args, n);
	XtOverrideTranslations(xnum_text,
		XtParseTranslationTable(":<Key>Return: no-op(RingBell)"));

	/* Ynum label. */
	n = m;
	XtSetArg(args[n], XtNlabel, "Ynum");		n++;
	XtSetArg(args[n], XtNborderWidth, 0);		n++;
	XtSetArg(args[n], XtNfromVert, xnum_text);	n++;
	labels[2] = XtCreateManagedWidget("arealightYnumLabel",
									  labelWidgetClass, form, args, n);

	/* Ynum text. */
	n = m;
	XtSetArg(args[n], XtNeditType, XawtextEdit);		n++;
	XtSetArg(args[n], XtNlength, MAX_STRING_LENGTH);	n++;
	XtSetArg(args[n], XtNuseStringInPlace, TRUE);		n++;
	XtSetArg(args[n], XtNstring, ynum_string);			n++;
	XtSetArg(args[n], XtNfromHoriz, labels[2]);			n++;
	XtSetArg(args[n], XtNfromVert, xnum_text);			n++;
	ynum_text = XtCreateManagedWidget("arealightYnumText",
					asciiTextWidgetClass, form, args, n);
	XtOverrideTranslations(ynum_text,
		XtParseTranslationTable(":<Key>Return: no-op(RingBell)"));

	Match_Widths(labels, 3);

	/* The jitter toggle. */
	n = m;
	XtSetArg(args[n], XtNlabel, "Jitter");		n++;
	XtSetArg(args[n], XtNfromVert, ynum_text);	n++;
	jitter_toggle = XtCreateManagedWidget("arealightJitterToggle",
						toggleWidgetClass, form, args, n);

	/* Done and cancel. */
	n = m;
	XtSetArg(args[n], XtNlabel, "Done");			n++;
	XtSetArg(args[n], XtNfromVert, jitter_toggle);	n++;
#if ( USE_ROUNDED_BUTTONS == 1 )
	XtSetArg(args[n], XtNshapeStyle, XmuShapeRoundedRectangle);	n++;
	XtSetArg(args[n], XtNcornerRoundPercent, 30);	n++;
	XtSetArg(args[n], XtNhighlightThickness, 2);	n++;
#endif
	done = XtCreateManagedWidget("arealightDoneCommand", commandWidgetClass,
								 form, args, n);
	XtAddCallback(done, XtNcallback, Arealight_Attributes_Callback, NULL);

	n = m;
	XtSetArg(args[n], XtNlabel, "Cancel");			n++;
	XtSetArg(args[n], XtNfromVert, jitter_toggle);	n++;
	XtSetArg(args[n], XtNfromHoriz, done);			n++;
#if ( USE_ROUNDED_BUTTONS == 1 )
	XtSetArg(args[n], XtNshapeStyle, XmuShapeRoundedRectangle);	n++;
	XtSetArg(args[n], XtNcornerRoundPercent, 30);	n++;
	XtSetArg(args[n], XtNhighlightThickness, 2);	n++;
#endif
	cancel = XtCreateManagedWidget("arealightCancelCommand", commandWidgetClass,
								   form, args, n);
	XtAddCallback(cancel, XtNcallback, Cancel_Light_Callback,
				  (XtPointer)arealight_shell);

	XtRealizeWidget(arealight_shell);
}
Ejemplo n.º 21
0
static int motFrameMapMethod(Ihandle* ih)
{
  char *title;
  int num_args = 0;
  Arg args[20];
  Widget child_manager;

  if (!ih->parent)
    return IUP_ERROR;

  title = iupAttribGet(ih, "TITLE");

  if (title)
    iupAttribSetStr(ih, "_IUPFRAME_HAS_TITLE", "1");
  else
  {
    char* value = iupAttribGetStr(ih, "SUNKEN");
    if (iupStrBoolean(value))
      iupMOT_SETARG(args, num_args, XmNshadowType, XmSHADOW_IN); 
    else
      iupMOT_SETARG(args, num_args, XmNshadowType, XmSHADOW_ETCHED_IN); 

    if (iupAttribGet(ih, "BGCOLOR"))
      iupAttribSetStr(ih, "_IUPFRAME_HAS_BGCOLOR", "1");
  }

  /* Core */
  iupMOT_SETARG(args, num_args, XmNmappedWhenManaged, False);  /* not visible when managed */
  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 */
  /* Manager */
  iupMOT_SETARG(args, num_args, XmNshadowThickness, 2);
  /* Frame */
  iupMOT_SETARG(args, num_args, XmNmarginHeight, 0);  /* no shadow margins */
  iupMOT_SETARG(args, num_args, XmNmarginWidth, 0);  /* no shadow margins */
  
  ih->handle = XtCreateManagedWidget(
    iupDialogGetChildIdStr(ih),  /* child identifier */
    xmFrameWidgetClass,          /* widget class */
    iupChildTreeGetNativeParentHandle(ih), /* widget parent */
    args, num_args);

  if (!ih->handle)
    return IUP_ERROR;

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

  if (title)
  {
    Widget title_label;
    num_args = 0;
    /* Label */
    iupMOT_SETARG(args, num_args, XmNlabelType, XmSTRING); 
    iupMOT_SETARG(args, num_args, XmNmarginHeight, 0);  /* default padding */
    iupMOT_SETARG(args, num_args, XmNmarginWidth, 0);
    /* Frame Constraint */
    iupMOT_SETARG(args, num_args, XmNchildType, XmFRAME_TITLE_CHILD);
    title_label = XtCreateManagedWidget("title_label", xmLabelWidgetClass, ih->handle, args, num_args);
    iupmotSetString(title_label, XmNlabelString, title);
    iupAttribSetStr(ih, "_IUPMOT_FRAMELABEL", (char*)title_label);
  }

  child_manager = XtVaCreateManagedWidget(
              "child_manager",
              xmBulletinBoardWidgetClass,
              ih->handle,
              /* Core */
              XmNborderWidth, 0,
              /* Manager */
              XmNshadowThickness, 0,
              XmNnavigationType, XmTAB_GROUP,
              /* BulletinBoard */
              XmNmarginWidth, 0,
              XmNmarginHeight, 0,
              XmNresizePolicy, XmRESIZE_NONE, /* no automatic resize of children */
              /* Frame Constraint */
              XmNchildType, XmFRAME_WORKAREA_CHILD,
              NULL);

  iupAttribSetStr(ih, "_IUPMOT_FRAMECONTAINER", (char*)child_manager);

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

  /* initialize the widget */
  XtRealizeWidget(ih->handle);

  return IUP_NOERROR;
}
Ejemplo n.º 22
0
    ac = 0;
    XtSetArg (av[ac], XtNtitle, shell_title);
    ac++;
    XtSetArg (av[ac], XtNallowShellResize, True);
    ac++;

    /* Don't allow any geometry request from the user.  */
    XtSetArg (av[ac], XtNgeometry, 0);
    ac++;

    shell = XtCreatePopupShell ("dialog", transientShellWidgetClass,
                                parent, av, ac);
    XtOverrideTranslations (shell, override);

    ac = 0;
    dialog = XtCreateManagedWidget (name, dialogWidgetClass, shell, av, ac);
    override = XtParseTranslationTable (dialogOverride);
    XtOverrideTranslations (dialog, override);

#ifdef HAVE_XFT
    {
        int num;
        Widget *ch = NULL;
        Widget w = 0;
        XtVaGetValues (dialog,
                       XtNnumChildren, &num,
                       XtNchildren, &ch, NULL);
        for (i = 0; i < num; ++i)
        {
            if (!XtIsSubclass (ch[i], commandWidgetClass)
                    && XtIsSubclass (ch[i], labelWidgetClass))
Ejemplo n.º 23
0
static void
makeButtonsAndBoxes(Widget parent)
{
    Widget outer, b_row, viewport;
    Arg arglist[10];
    Cardinal num_args;
    xedit_flist_item *item;
    static char *labelWindow = "labelWindow", *editWindow = "editWindow";
    static char *formWindow = "formWindow", *positionWindow = "positionWindow";

    outer = XtCreateManagedWidget("paned", panedWidgetClass, parent,
				  NULL, ZERO);
 
    b_row = XtCreateManagedWidget("buttons", panedWidgetClass, outer, NULL, ZERO);
    {
	MakeCommandButton(b_row, "quit", DoQuit);
	MakeCommandButton(b_row, "save", DoSave);
	MakeCommandButton(b_row, "load", DoLoad);
	filenamewindow = MakeStringBox(b_row, "filename", NULL);
    }
    hintswindow = XtCreateManagedWidget("bc_label", labelWidgetClass,
					outer, NULL, ZERO);

    num_args = 0;
    XtSetArg(arglist[num_args], XtNeditType, XawtextEdit);		++num_args;
    messwidget = XtCreateManagedWidget("messageWindow", asciiTextWidgetClass,
				       outer, arglist, num_args);

    num_args = 0;
    XtSetArg(arglist[num_args], XtNorientation, XtorientHorizontal);	++num_args;
    hpane = XtCreateManagedWidget("hpane", panedWidgetClass, outer,
				  arglist, num_args);

    num_args = 0;
    XtSetArg(arglist[num_args], XtNorientation, XtorientVertical);	++num_args;
    vpanes[0] = XtCreateManagedWidget("vpane", panedWidgetClass, hpane,
				      arglist, num_args);
    XtSetArg(arglist[num_args], XtNheight, 1);				++num_args;
    XtSetArg(arglist[num_args], XtNwidth, 1);				++num_args;
    vpanes[1] = XtCreateWidget("vpane", panedWidgetClass, hpane,
			       arglist, num_args);

    forms[0] = XtCreateManagedWidget(formWindow, formWidgetClass,
				     vpanes[0], NULL, 0);
    labelwindow = XtCreateManagedWidget(labelWindow,labelWidgetClass,
					forms[0], NULL, 0);
    labels[0] = labelwindow;
    positions[0] = XtCreateManagedWidget(positionWindow,labelWidgetClass,
					 forms[0], NULL, 0);

    forms[2] = XtCreateWidget(formWindow, formWidgetClass,
			      vpanes[1], NULL, 0);
    labels[2] = XtCreateManagedWidget(labelWindow,labelWidgetClass,
				      forms[2], NULL, 0);
    positions[2] = XtCreateManagedWidget(positionWindow,labelWidgetClass,
					 forms[2], NULL, 0);

    num_args = 0;
    XtSetArg(arglist[num_args], XtNtype, XawAsciiFile);			++num_args;
    XtSetArg(arglist[num_args], XtNeditType, XawtextEdit);		++num_args;
    textwindow =  XtCreateManagedWidget(editWindow, asciiTextWidgetClass,
					vpanes[0], arglist, num_args);

    /* Get international resource value form the textwindow */
    num_args = 0;
    XtSetArg(arglist[num_args], XtNinternational, &international);	++num_args;
    XtGetValues(textwindow, arglist, num_args);

    num_args = 0;
    XtSetArg(arglist[num_args], XtNtype, XawAsciiFile);			++num_args;
    XtSetArg(arglist[num_args], XtNeditType, XawtextEdit);		++num_args;
    scratch = XtVaCreateWidget("textSource", international ?
			       multiSrcObjectClass :
			       asciiSrcObjectClass, topwindow,
			       XtNtype, XawAsciiFile,
			       XtNeditType, XawtextEdit,
			       NULL, NULL);
    XtSetValues(scratch, arglist, num_args);

    num_args = 0;
    XtSetArg(arglist[num_args], XtNtextSource, scratch);		++num_args;
    XtSetValues(textwindow, arglist, num_args);

    texts[0] = textwindow;
    num_args = 0;
    XtSetArg(arglist[num_args], XtNtextSource, scratch);		++num_args;
    XtSetArg(arglist[num_args], XtNdisplayCaret, False);		++num_args;
    texts[2] = XtCreateWidget(editWindow, asciiTextWidgetClass,
			      vpanes[1], arglist, num_args);

    forms[1] = XtCreateWidget(formWindow, formWidgetClass,
			      vpanes[0], NULL, 0);
    labels[1] = XtCreateManagedWidget(labelWindow,labelWidgetClass,
				      forms[1], NULL, 0);
    positions[1] = XtCreateManagedWidget(positionWindow,labelWidgetClass,
					 forms[1], NULL, 0);

    texts[1] = XtCreateWidget(editWindow, asciiTextWidgetClass,
			      vpanes[0], arglist, num_args);

    dirlabel = XtCreateWidget("dirlabel", labelWidgetClass,
			      vpanes[1], NULL, 0);
    num_args = 0;
    XtSetArg(arglist[num_args], XtNheight, 1);				++num_args;
    XtSetArg(arglist[num_args], XtNwidth, 1);				++num_args;
    viewport = XtCreateWidget("viewport", viewportWidgetClass,
			      vpanes[1], arglist, num_args);
    dirwindow = XtCreateManagedWidget("dirwindow", listWidgetClass,
				      viewport, NULL, 0);

    item = AddTextSource(scratch, "*scratch*", "*scratch*",
			 0, WRITE_OK);
    item->wrap = XawtextWrapLine;
    item->flags |= WRAP_BIT;
    XtAddCallback(item->source, XtNcallback, SourceChanged,
		  (XtPointer)item);
    ResetSourceChanged(item);
    flist.current = item;

    for (num_args = 0; num_args < 3; num_args++)
	XtAddCallback(texts[num_args], XtNpositionCallback, PositionChanged, NULL);

    for (num_args = 0; num_args < 3; num_args++) {
	XtSetArg(arglist[0], XtNwrap, &wrapmodes[num_args]);
	XtGetValues(texts[num_args], arglist, 1);
    }

    XtAddCallback(dirwindow, XtNcallback, DirWindowCB, NULL);
}
Ejemplo n.º 24
0
void
schedInit (Widget prnt, PgmState * pgm)
{
  Arg arglist[20];
  Cardinal i = 0;
  Widget back, edit, add /*,del */ , sched_list_vp;
  XtCallbackRec cl[2];

  pgm->sched_idx = XAW_LIST_NONE;
  pgm->sched_loaded = 0;

  cl[1].callback = NULL;
  cl[1].closure = NULL;
  cl[0].callback = sched_back;
  cl[0].closure = pgm;

  i = 0;
  XtSetArg (arglist[i], XtNleft, XawChainLeft);
  i++;
  XtSetArg (arglist[i], XtNright, XawChainLeft);
  i++;
  XtSetArg (arglist[i], XtNtop, XawChainTop);
  i++;
  XtSetArg (arglist[i], XtNbottom, XawChainTop);
  i++;
  XtSetArg (arglist[i], XtNcallback, cl);
  i++;
  back = XtCreateManagedWidget ("Back", commandWidgetClass, prnt, arglist, i);

  cl[0].callback = sched_edit;
  cl[0].closure = pgm;
  i = 0;
  XtSetArg (arglist[i], XtNleft, XawChainLeft);
  i++;
  XtSetArg (arglist[i], XtNright, XawChainLeft);
  i++;
  XtSetArg (arglist[i], XtNtop, XawChainTop);
  i++;
  XtSetArg (arglist[i], XtNbottom, XawChainTop);
  i++;
  XtSetArg (arglist[i], XtNcallback, cl);
  i++;
  XtSetArg (arglist[i], XtNfromHoriz, back);
  i++;
  edit = XtCreateManagedWidget ("Edit", commandWidgetClass, prnt, arglist, i);

  cl[0].callback = sched_add;
  cl[0].closure = pgm;
  i = 0;
  XtSetArg (arglist[i], XtNleft, XawChainLeft);
  i++;
  XtSetArg (arglist[i], XtNright, XawChainLeft);
  i++;
  XtSetArg (arglist[i], XtNtop, XawChainTop);
  i++;
  XtSetArg (arglist[i], XtNbottom, XawChainTop);
  i++;
  XtSetArg (arglist[i], XtNcallback, cl);
  i++;
  XtSetArg (arglist[i], XtNfromHoriz, edit);
  i++;
  add = XtCreateManagedWidget ("Add", commandWidgetClass, prnt, arglist, i);

  cl[0].callback = sched_del;
  cl[0].closure = pgm;
  i = 0;
  XtSetArg (arglist[i], XtNleft, XawChainLeft);
  i++;
  XtSetArg (arglist[i], XtNright, XawChainLeft);
  i++;
  XtSetArg (arglist[i], XtNtop, XawChainTop);
  i++;
  XtSetArg (arglist[i], XtNbottom, XawChainTop);
  i++;
  XtSetArg (arglist[i], XtNcallback, cl);
  i++;
  XtSetArg (arglist[i], XtNfromHoriz, add);
  i++;
  /*del= */ XtCreateManagedWidget ("Del", commandWidgetClass, prnt, arglist,
                                   i);

  i = 0;
  XtSetArg (arglist[i], XtNleft, XawChainLeft);
  i++;
  XtSetArg (arglist[i], XtNright, XawChainRight);
  i++;
  XtSetArg (arglist[i], XtNtop, XawChainTop);
  i++;
  XtSetArg (arglist[i], XtNbottom, XawChainBottom);
  i++;
//  XtSetArg(arglist[i],XtNfromHoriz,pos_vp);i++;
  XtSetArg (arglist[i], XtNfromVert, back);
  i++;
  XtSetArg (arglist[i], XtNheight, 200);
  i++;
  XtSetArg (arglist[i], XtNwidth, 490);
  i++;
  XtSetArg (arglist[i], XtNallowVert, True);
  i++;
  sched_list_vp =
    XtCreateManagedWidget ("SchedListVP", viewportWidgetClass, prnt, arglist,
                           i);

  cl[0].callback = sched_list;
  cl[0].closure = pgm;
  i = 0;
  XtSetArg (arglist[i], XtNforceColumns, True);
  i++;
  XtSetArg (arglist[i], XtNdefaultColumns, 1);
  i++;
  XtSetArg (arglist[i], XtNverticalList, True);
  i++;
  XtSetArg (arglist[i], XtNcallback, cl);
  i++;
  pgm->sched_list =
    XtCreateManagedWidget ("SchedList", listWidgetClass, sched_list_vp,
                           arglist, i);
}
Ejemplo n.º 25
0
void make_buttons(struct gui_data *data, Widget trc, Screen * scr)
{
    unsigned int n;
    Arg wargs[10];
    Widget shnames, doexit;

    cd = data;

    /***************** rewind */
    n = 0;
    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
    n++;
    XtSetArg(wargs[n], XmNheight, 30);
    n++;
    XtSetArg(wargs[n], XmNwidth, 30);
    n++;
    rew = XtCreateManagedWidget("rd", xmPushButtonWidgetClass, trc, wargs, n);

    /***************** rplay */
    n = 0;
    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
    n++;
    XtSetArg(wargs[n], XmNheight, 30);
    n++;
    XtSetArg(wargs[n], XmNwidth, 30);
    n++;
    rplay = XtCreateManagedWidget("ry", xmPushButtonWidgetClass,
				  trc, wargs, n);

    /***************** stepb */
    n = 0;
    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
    n++;
    XtSetArg(wargs[n], XmNheight, 30);
    n++;
    XtSetArg(wargs[n], XmNwidth, 30);
    n++;
    stepb = XtCreateManagedWidget("sb", xmPushButtonWidgetClass,
				  trc, wargs, n);

    /***************** stop */
    n = 0;
    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
    n++;
    XtSetArg(wargs[n], XmNheight, 30);
    n++;
    XtSetArg(wargs[n], XmNwidth, 30);
    n++;
    stop = XtCreateManagedWidget("sp", xmPushButtonWidgetClass,
				 trc, wargs, n);

    /***************** stepf */
    n = 0;
    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
    n++;
    XtSetArg(wargs[n], XmNheight, 30);
    n++;
    XtSetArg(wargs[n], XmNwidth, 30);
    n++;
    stepf = XtCreateManagedWidget("sf", xmPushButtonWidgetClass,
				  trc, wargs, n);

    /***************** play */
    n = 0;
    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
    n++;
    XtSetArg(wargs[n], XmNheight, 30);
    n++;
    XtSetArg(wargs[n], XmNwidth, 30);
    n++;
    play = XtCreateManagedWidget("py", xmPushButtonWidgetClass,
				 trc, wargs, n);

    /***************** loop */
    n = 0;
    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
    n++;
    XtSetArg(wargs[n], XmNheight, 30);
    n++;
    XtSetArg(wargs[n], XmNwidth, 30);
    n++;
    loop = XtCreateManagedWidget("lp", xmToggleButtonWidgetClass,
				 trc, wargs, n);

    /***************** swing */
    n = 0;
    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
    n++;
    XtSetArg(wargs[n], XmNheight, 30);
    n++;
    XtSetArg(wargs[n], XmNwidth, 30);
    n++;
    swing = XtCreateManagedWidget("sw", xmToggleButtonWidgetClass,
				  trc, wargs, n);

    /***************** slower */
    n = 0;
    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
    n++;
    XtSetArg(wargs[n], XmNheight, 30);
    n++;
    XtSetArg(wargs[n], XmNwidth, 30);
    n++;
    slower = XtCreateManagedWidget("Sl", xmPushButtonWidgetClass,
				   trc, wargs, n);

    /***************** faster */
    n = 0;
    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
    n++;
    XtSetArg(wargs[n], XmNheight, 30);
    n++;
    XtSetArg(wargs[n], XmNwidth, 30);
    n++;
    faster = XtCreateManagedWidget("Fa", xmPushButtonWidgetClass,
				   trc, wargs, n);

    /***************** shownames */
    n = 0;
    XtSetArg(wargs[n], XmNforeground, BlackPixelOfScreen(scr));
    n++;
    XtSetArg(wargs[n], XmNheight, 30);
    n++;
    XtSetArg(wargs[n], XmNwidth, 30);
    n++;
    XtSetArg(wargs[n], XmNset, TRUE);
    n++;
    shnames = XtCreateManagedWidget("names", xmPushButtonWidgetClass,
				    trc, wargs, n);
    XtAddCallback(shnames, XmNactivateCallback,
		  (XtCallbackProc) names_callback, (XtPointer) NULL);

    n = 0;
    XtSetArg(wargs[n], XmNmarginLeft, 0);
    n++;
    doexit = XtCreateManagedWidget("Exit", xmPushButtonWidgetClass,
				   trc, wargs, n);
    XtAddCallback(doexit, XmNactivateCallback, (XtCallbackProc) exit_callback,
		  (XtPointer) NULL);
}
Ejemplo n.º 26
0
int
main(int argc, char **argv)
{
    char	    *file_name = NULL;
    int		    i;
    XtAppContext    xtcontext;
    Arg		    topLevelArgs[2];
    Widget          entry;

    XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL);

    toplevel = XtAppInitialize(&xtcontext, "Xditview",
			       options, XtNumber (options),
			       &argc, argv, NULL, NULL, 0);
    if (argc > 2)
	Syntax(argv[0]);

    XtAppAddActions(xtcontext, xditview_actions, XtNumber (xditview_actions));
    XtOverrideTranslations
	(toplevel, XtParseTranslationTable ("<Message>WM_PROTOCOLS: Quit()"));

    XtSetArg (topLevelArgs[0], XtNiconPixmap,
	      XCreateBitmapFromData (XtDisplay (toplevel),
				     XtScreen(toplevel)->root,
				     (char *) xdit_bits,
				     xdit_width, xdit_height));
				    
    XtSetArg (topLevelArgs[1], XtNiconMask,
	      XCreateBitmapFromData (XtDisplay (toplevel),
				     XtScreen(toplevel)->root,
				     (char *) xdit_mask_bits, 
				     xdit_mask_width, xdit_mask_height));
    XtSetValues (toplevel, topLevelArgs, 2);
    if (argc > 1)
	file_name = argv[1];

    /*
     * create the popup menu and insert the entries
     */
    popupMenu = XtCreatePopupShell ("popupMenu", simpleMenuWidgetClass, toplevel,
				    NULL, 0);
    for (i = 0; i < XtNumber (popupMenuEntries); i++) {
	entry = XtCreateManagedWidget(popupMenuEntries[i].name, 
				      smeBSBObjectClass, popupMenu,
				      NULL, (Cardinal) 0);
	XtAddCallback(entry, XtNcallback, popupMenuEntries[i].function, NULL);
    }

    paned = XtCreateManagedWidget("paned", panedWidgetClass, toplevel,
				    NULL, (Cardinal) 0);
    menuBar = XtCreateManagedWidget ("menuBar", boxWidgetClass, paned, NULL, 0);

    fileMenuButton = XtCreateManagedWidget ("fileMenuButton", menuButtonWidgetClass,
				    menuBar, NULL, (Cardinal) 0);
    fileMenu = XtCreatePopupShell ("fileMenu", simpleMenuWidgetClass,
				    fileMenuButton, NULL, (Cardinal) 0);
    for (i = 0; i < XtNumber (fileMenuEntries); i++) {
	entry = XtCreateManagedWidget(fileMenuEntries[i].name,
				      smeBSBObjectClass, fileMenu,
				      NULL, (Cardinal) 0);
	XtAddCallback (entry, XtNcallback, fileMenuEntries[i].function, NULL);
    }

    (void) XtCreateManagedWidget ("prevButton", commandWidgetClass,
				  menuBar, NULL, (Cardinal) 0);

    pageNumber = XtCreateManagedWidget("pageNumber", asciiTextWidgetClass,
					menuBar, NULL, (Cardinal) 0);
  
    (void) XtCreateManagedWidget ("nextButton", commandWidgetClass,
				  menuBar, NULL, (Cardinal) 0);

#ifdef NOTDEF
    form = XtCreateManagedWidget ("form", formWidgetClass, paned,
				    NULL, (Cardinal) 0);
    panner = XtCreateManagedWidget ("panner", pannerWidgetClass,
				    form, NULL, 0);
    porthole = XtCreateManagedWidget ("porthole", portholeWidgetClass,
				      form, NULL, 0);
    XtAddCallback(porthole, 
		  XtNreportCallback, PortholeCallback, (XtPointer) panner);
    XtAddCallback(panner, 
		  XtNreportCallback, PannerCallback, (XtPointer) porthole);
#else
    porthole = XtCreateManagedWidget ("viewport", viewportWidgetClass,
				      paned, NULL, 0);
#endif
    dvi = XtCreateManagedWidget ("dvi", dviWidgetClass, porthole, NULL, 0);
    if (file_name)
	VisitFile (file_name, FALSE);
    XtRealizeWidget (toplevel);
    wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW",
				   False);
    (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel),
                            &wm_delete_window, 1);
    XtAppMainLoop(xtcontext);

    return 0;
}
Ejemplo n.º 27
0
/*******************************************************************************
          Name:        FileSelect
          Description: Pops up window in center of the Dialog Window for file
                       selection by user
          Arguments:  None
          Returns:     None
          Contrubuting Programmers:  Albert Leigh - MacDonnell Douglas
                                     Stan Smith - Barrios
                                     some guy upstairs
******************************************************************************/
void FileSelect()
  {
  Widget file_form, file_dialog, view;
    

  /*XDefineCursor(XtDisplay(toplevel),toplevel,XC_watch);*/
  file = XtCreatePopupShell("File",
                            topLevelShellWidgetClass,
                            toplevel,
                            NULL, 0);

  file_form = XtCreateManagedWidget("file_form",
                                    formWidgetClass,
                                    file,
                                    NULL, 0);

  XtSetArg(args[0], XtNforceBars, True);
  XtSetArg(args[1], XtNbottom, XtChainBottom);
  XtSetArg(args[2], XtNheight,150);
  XtSetArg(args[3], XtNallowHoriz,True);
  XtSetArg(args[4],XtNallowVert,True);
  view = XtCreateManagedWidget("view",
                               viewportWidgetClass,
                               file_form,
                               args, 5);

  /* =============================================================== *
   *  Create the Select/Cancel dialog box in the file selection      *
   *  dialog box.                                                    *
   * =============================================================== */

  XtSetArg(args[0], XtNresizable, True);
  XtSetArg(args[1], XtNlabel, "Enter File Name");
  XtSetArg(args[2], XtNvalue, "");
  XtSetArg(args[3], XtNfromVert, view);
  XtSetArg(args[4], XtNicon, clips_logo);
  XtSetArg(args[5], XtNleft, XtChainLeft);
  XtSetArg(args[6], XtNright, XtChainRight);
  XtSetArg(args[7], XtNtop, XtChainBottom);
  XtSetArg(args[8], XtNbottom, XtChainBottom);
  file_dialog = XtCreateManagedWidget("file_dialog",
                                      dialogWidgetClass,
                                      file_form,
                                      args, 9);
  XawDialogAddButton(file_dialog, "SELECT", MenuFunc, (XtPointer) file_dialog);
  XawDialogAddButton(file_dialog, "CANCEL", CancelPopupSelect,
                     (XtPointer) file_form);

  XtSetArg(args[0], XtNfromHoriz, file_dialog);
  XtSetArg(args[1], XtNfromVert, view);

  /* =============================================================== *
   *  Get the path of the current dirrectory                         *
   * =============================================================== */

  if(getwd(path) == NULL)
    printf("Error getting current working directory '%s'\n", path);

  if(path[strlen(path) - 1] != '/')
    strcat(path, "/");

  /* =============================================================== *
   *  Create the file dialog list box                                *
   * =============================================================== */

  XtSetArg(args[0], XtNdefaultColumns, 4);
  XtSetArg(args[1], XtNlist, GetDirectory());
  XtSetArg(args[2], XtNforceColumns, False);
  XtSetArg(args[3], XtNverticalList, True);
  XtSetArg(args[4], XtNinternalWidth, 10);
  file_list = XtCreateManagedWidget("file_dialog",
                                    listWidgetClass,
                                    view,
                                    args, 5);
  XtAddCallback(file_list, XtNcallback, FileToDialog, (XtPointer) file_dialog);

  XtPopup(file, XtGrabNonexclusive);
  /*XDefineCursor(XtDisplay(toplevel),toplevel,None);*/
  }
Ejemplo n.º 28
0
// create a graph editor with panner; return the graph editor widget ID
Widget createPannedGraphEdit(Widget parent, const _XtString name, 
			     ArgList graph_edit_args,
			     Cardinal graph_edit_arg)
{
    Arg args[10];
    int arg = 0;

    string form_name = string(name) + "_form";
    arg = 0;
    XtSetArg(args[arg], ARGSTR(XtNborderWidth),     0); arg++;
    XtSetArg(args[arg], ARGSTR(XtNdefaultDistance), 0); arg++;
    Widget form =
	verify(XtCreateManagedWidget(form_name.chars(), 
				     formWidgetClass, parent, args, arg));

    string panner_name = string(name) + "_panner";
    arg = 0;
    XtSetArg(args[arg], ARGSTR(XtNresize),    False);          arg++;
    XtSetArg(args[arg], ARGSTR(XtNresizable), True);           arg++;
    XtSetArg(args[arg], ARGSTR(XtNbottom),    XawChainBottom); arg++;
    XtSetArg(args[arg], ARGSTR(XtNtop),       XawChainBottom); arg++;
    XtSetArg(args[arg], ARGSTR(XtNleft),      XawChainRight);  arg++;
    XtSetArg(args[arg], ARGSTR(XtNright),     XawChainRight);  arg++;
    Widget panner = 
	verify(XtCreateWidget(panner_name.chars(), 
			      pannerWidgetClass, form, args, arg));

    string porthole_name = string(name) + "_porthole";
    arg = 0;
    XtSetArg(args[arg], ARGSTR(XtNresizable), True);           arg++;
    XtSetArg(args[arg], ARGSTR(XtNbottom),    XawChainBottom); arg++;
    XtSetArg(args[arg], ARGSTR(XtNtop),       XawChainTop);    arg++;
    XtSetArg(args[arg], ARGSTR(XtNleft),      XawChainLeft);   arg++;
    XtSetArg(args[arg], ARGSTR(XtNright),     XawChainRight);  arg++;
    Widget porthole = 
	verify(XtCreateManagedWidget(porthole_name.chars(),
				     pannedGraphEditWidgetClass, 
				     form, args, arg));

    Widget graph_edit = 
	verify(XtCreateManagedWidget(name, graphEditWidgetClass, porthole, 
				     graph_edit_args, graph_edit_arg));
    XtVaSetValues(graph_edit,
		  XtNresizable, True,
		  XtPointer(0));

    // Allow the porthole and the panner to talk to each other
    XtAddCallback(porthole, XtNreportCallback, PortholeCB, XtPointer(panner));
    XtAddCallback(panner, XtNreportCallback, PannerCB, XtPointer(graph_edit));

    // Propagate requested width and height of graph editor to form
    Dimension width, height;
    XtVaGetValues(graph_edit,
		  XtNrequestedWidth, &width,
		  XtNrequestedHeight, &height,
		  XtPointer(0));

    if (width > 0)
	XtVaSetValues(form, XmNwidth, width, XtPointer(0));
    if (height > 0)
	XtVaSetValues(form, XmNheight, height, XtPointer(0));

    return graph_edit;
}
Ejemplo n.º 29
0
int
main(int argc, char *argv[])
{
    Arg args[4];
    Cardinal n;
    XtAppContext xtcontext;
    Widget parent;

    XtSetLanguageProc(NULL, NULL, NULL);

    top = XtAppInitialize( &xtcontext, "XClipboard", table, XtNumber(table),
			  &argc, argv, fallback_resources, NULL, 0);

    XtGetApplicationResources(top, (XtPointer)&userOptions, resources, 
			      XtNumber(resources), NULL, 0);

    XtAppAddActions (xtcontext,
		     xclipboard_actions, XtNumber (xclipboard_actions));
    /* CLIPBOARD_MANAGER is a non-standard mechanism */
    ManagerAtom = XInternAtom(XtDisplay(top), "CLIPBOARD_MANAGER", False);
    ClipboardAtom = XA_CLIPBOARD(XtDisplay(top));
    if (XGetSelectionOwner(XtDisplay(top), ManagerAtom))
	XtError("another clipboard is already running\n");

    parent = XtCreateManagedWidget("form", formWidgetClass, top, NULL, ZERO);
    (void) XtCreateManagedWidget("quit", Command, parent, NULL, ZERO);
    (void) XtCreateManagedWidget("delete", Command, parent, NULL, ZERO);
    (void) XtCreateManagedWidget("new", Command, parent, NULL, ZERO);
    (void) XtCreateManagedWidget("save", Command, parent, NULL, ZERO);
    nextButton = XtCreateManagedWidget("next", Command, parent, NULL, ZERO);
    prevButton = XtCreateManagedWidget("prev", Command, parent, NULL, ZERO);
    indexLabel = XtCreateManagedWidget("index", Label, parent, NULL, ZERO);

    n=0;
    XtSetArg(args[n], XtNtype, XawAsciiString); n++;
    XtSetArg(args[n], XtNeditType, XawtextEdit); n++;
    if (userOptions.wrap) {
	XtSetArg(args[n], XtNwrap, XawtextWrapWord); n++;
	XtSetArg(args[n], XtNscrollHorizontal, False); n++;
    }

    text = XtCreateManagedWidget( "text", Text, parent, args, n);
    
    currentClip = NewClip (text, (ClipPtr) 0);

    set_button_state ();

    fileDialogShell = XtCreatePopupShell("fileDialogShell",
					 transientShellWidgetClass,
					 top, NULL, ZERO);
    fileDialog = XtCreateManagedWidget ("fileDialog", dialogWidgetClass,
					fileDialogShell, NULL, ZERO);
    XawDialogAddButton(fileDialog, "accept", NULL, NULL);
    XawDialogAddButton(fileDialog, "cancel", NULL, NULL);

    failDialogShell = XtCreatePopupShell("failDialogShell",
					 transientShellWidgetClass,
					 top, NULL, ZERO);
    failDialog = XtCreateManagedWidget ("failDialog", dialogWidgetClass,
					failDialogShell, NULL, ZERO);
    XawDialogAddButton (failDialog, "continue", NULL, NULL);

    XtRealizeWidget(top);
    XtRealizeWidget(fileDialogShell);
    XtRealizeWidget(failDialogShell);
    XtOwnSelection(top, ManagerAtom, CurrentTime,
		   RefuseSelection, LoseManager, NULL);
    if (XGetSelectionOwner (XtDisplay(top), ClipboardAtom)) {
	LoseSelection (top, &ClipboardAtom);
    } else {
    	XtOwnSelection(top, ClipboardAtom, CurrentTime,
		       ConvertSelection, LoseSelection, NULL);
    }
    wm_delete_window = XInternAtom(XtDisplay(top), "WM_DELETE_WINDOW", False);
    wm_protocols = XInternAtom(XtDisplay(top), "WM_PROTOCOLS", False);
    (void) XSetWMProtocols(XtDisplay(top), XtWindow(top), &wm_delete_window,1);
    (void) XSetWMProtocols(XtDisplay(top), XtWindow(fileDialogShell),
			   &wm_delete_window,1);
    (void) XSetWMProtocols(XtDisplay(top), XtWindow(failDialogShell),
			   &wm_delete_window,1);
    XtAppMainLoop(xtcontext);
    exit(0);
}
Ejemplo n.º 30
0
/*F--------------------------------------------------------------------------
 *  Function:	xUIpulldown()
 *					-create a pulldown menu recursively
 *  In:			-parameters to create a pulldown
 *  out:			-
 *  Return:		-
 *---------------------------------------------------------------------------
 */
Widget *xUIpulldown( char *title, Widget menubar, MENULIST *menulist, int nitems)
{
	extern MENU menu[];

	Arg		wargs[5];
	int		i, nr;
	Widget	*buttons;
	int		separators=0;
	MENULIST	*pML;						/* direct access to a menulist item */
	XmString		xmStr;


	buttons = (Widget *)XtMalloc(nitems * sizeof(Widget));

	if (title) {
		XtCreateManagedWidget(title, xmLabelWidgetClass, menubar, 0, 0);
		XtCreateManagedWidget(SEPAR, xmSeparatorWidgetClass, menubar, 0, 0);
	}

	/*-- build for as many basic pulldown items ----*/
	for (i=0; i<nitems; i++)
		{
		pML = &menulist[i];
		xmStr = XmStringCreateLtoR(menulist[i].titel, XmSTRING_DEFAULT_CHARSET);
		XtSetArg(wargs[0], XmNlabelString, xmStr );
		XtSetArg(wargs[1], XmNancestorSensitive, menulist[i].status);
		XtSetArg(wargs[2], XmNmnemonic, menulist[i].mnemonic);

		if (!menulist[i].titel)
			{
			/*-- no titel means create a separator ------------------*/
			XtCreateManagedWidget(SEPAR, xmSeparatorWidgetClass, menubar, 0, 0);
			separators++;
			XmStringFree( xmStr);
			}
		else if (menulist[i].func)
			{
			/*-- create normal pushbutton or option/help cascade-button --------*/
			if (menulist[i].anz_subitems == 0)
				{
				/*-- case of option or help ----*/
				buttons[i-separators] = XtCreateWidget( PULLDOWN,
                                    xmCascadeButtonWidgetClass, menubar, wargs, 3);
				}
			else
				{
				buttons[i-separators] = XtCreateWidget( PULLDOWN,
                                    xmPushButtonWidgetClass,    menubar, wargs, 3);
				}
			/*--- last item is help ----*/
			if (i+1==nitems)
				{
				XtSetArg(wargs[0], XmNmenuHelpWidget, buttons[i-separators]);
				XtSetValues(menubar, wargs, 1);
				}
			XtAddCallback(buttons[i-separators], XmNactivateCallback,
							 (XtCallbackProc)menulist[i].func, (XtPointer)menulist[i].data);
			XmStringFree( xmStr);

			/*--- fill menu member "button" with created widget ---------*/
			if (menulist[i].menu == True)    /* grouplist menu */
				{
				nr = (MENU *)menulist[i].data - menu;
				menu[nr].button = buttons[i-separators];
				}
			}
		else if (!menulist[i].submenu)
			{
			/*-- no submenu  then create label leaf -------------*/
			buttons[i-separators] = XtCreateWidget( PULLDOWN,
                                        xmLabelWidgetClass, menubar, wargs, 3);
			XmStringFree( xmStr);
			}
		else
			{
			Widget submenu;
			char tmptit[] = "Submenu";
			menulist[i].submenutitle = tmptit;
			submenu = XmCreatePulldownMenu(menubar, menulist[i].submenutitle, 0, 0);
			XtSetArg(wargs[3], XmNsubMenuId, submenu);
			buttons[i-separators] = XtCreateWidget( PULLDOWN, xmCascadeButtonWidgetClass,
																menubar, wargs, 4);
			/*--- last item is help cascade button ----*/
			if (i+1==nitems)
				{
				XtSetArg(wargs[0], XmNmenuHelpWidget, buttons[i-separators]);
				XtSetValues(menubar, wargs, 1);
				}
			XmStringFree( xmStr);
			/*-- recursion call -----*/
			menulist[i].button = xUIpulldown(NULL, submenu,
														menulist[i].submenu, menulist[i].anz_subitems);
			}
		}/*for*/

	XtManageChildren(buttons, nitems-separators);
	return(buttons);
}