Example #1
0
static void
create_menu_translation_tables()
{
    if (!menu_translation_table) {
        menu_translation_table = XtParseTranslationTable(menu_translations);
        menu_entry_translation_table
            = XtParseTranslationTable(menu_entry_translations);
        menu_del_translation_table
            = XtParseTranslationTable("<Message>WM_PROTOCOLS: menu_delete()");
    }
}
Example #2
0
File: proj.c Project: juddy/edcde
/*
 * Enable project window actions
 */
static void
enable_proj_actions(
    Widget widget
)
{
    if (proj_transtbl == NULL)
    {
	String	   translations;
        int        len;

	len = strlen(base_translations) + 1;

	if (AB_btn1_transfer == True) /* Button2 can be used for ADJUST */
            len += strlen(btn2_adjust_translations);

        translations = (String)util_malloc(len*sizeof(char));
        if (translations == NULL)
            return; /* yikes */

	strcpy(translations, base_translations);
        if (AB_btn1_transfer == True) /* Button2 can be used for ADJUST */ 
	    strcat(translations, btn2_adjust_translations);

	proj_transtbl = XtParseTranslationTable(translations);

	util_free(translations);
    }

    /* enable build mode behavior */
    XtVaSetValues(widget, 
		XtNtranslations, proj_transtbl,
        	NULL);
}
Example #3
0
/*
 * Initialize SubPopup(color)
 */
void InitSubPopupColor()
{
  int i;
  char buf[4];
  Pixmap checkmarkBitmap;
  String trans2 =
    "<Leave>:  SubPopdown(pctop)";

  checkmarkBitmap = XCreateBitmapFromData(XtDisplay(toplevel),
					  XDefaultRootWindow(XtDisplay(toplevel)),
					  coloritem_bits,
					  coloritem_width,coloritem_height);

  pcTop = Xt_P("pctop" ,simpleMenuWidgetClass,toplevel,NULL);
          Xt_W("pcline",smeLineObjectClass   ,pcTop   ,XtNlineWidth,2,NULL);

  for(i=0;i<POPUP_COLOR_NITEM;i++) {
    sprintf(buf,"pc%1d",i);
    pc[i] = Xt_W(buf,smeBSBObjectClass,pcTop,NULL);

    XtVaSetValues(pc[i],
		  XtNleftBitmap,checkmarkBitmap,
		  XtNleftMargin,72,
		  XtNlabel,"",
		  NULL);
    XtAddCallback(pc[i],XtNcallback,(XtCallbackProc)SelectColor,(XtPointer)i);
  }

  XtOverrideTranslations(pcTop,XtParseTranslationTable(trans2));
}
Example #4
0
File: em_menu.c Project: Exim/exim
void create_dialog(uschar *label, uschar *value)
{
Arg warg[4];
Dimension x, y, xx, yy;
XtTranslations pop_trans;
Widget text;

/* Get the position of a reference widget so the dialog box can be put
near to it. */

get_pos_args[0].value = (XtArgVal)(&x);
get_pos_args[1].value = (XtArgVal)(&y);
XtGetValues(dialog_ref_widget, get_pos_args, 2);

/* When this is not a message_specific thing, the position of the reference
widget is relative to the window. Get the position of the top level widget and
add to the position. */

if (dialog_ref_widget != menushell)
  {
  get_pos_args[0].value = (XtArgVal)(&xx);
  get_pos_args[1].value = (XtArgVal)(&yy);
  XtGetValues(toplevel_widget, get_pos_args, 2);
  x += xx;
  y += yy;
  }

/* Create a transient shell for the dialog box. */

XtSetArg(warg[0], XtNtransientFor, queue_widget);
XtSetArg(warg[1], XtNx, x + 50);
XtSetArg(warg[2], XtNy, y + 50);
XtSetArg(warg[3], XtNallowShellResize, True);
dialog_shell = XtCreatePopupShell("forDialog", transientShellWidgetClass,
   toplevel_widget, warg, 4);

/* Create the dialog box. */

dialog_arg[0].value = (XtArgVal)label;
dialog_arg[1].value = (XtArgVal)value;
dialog_widget = XtCreateManagedWidget("dialog", dialogWidgetClass, dialog_shell,
  dialog_arg, XtNumber(dialog_arg));

/* Get the text widget from within the dialog box, give it the keyboard focus,
make it wider than the default, and override its translations to make Return
call the dialog action function. */

text = XtNameToWidget(dialog_widget, "value");
XawTextSetInsertionPoint(text, Ustrlen(value));
XtSetKeyboardFocus(dialog_widget, text);
xs_SetValues(text, 1, "width", 200);
pop_trans = XtParseTranslationTable(
  "<Key>Return:         dialogAction()\n");
XtOverrideTranslations(text, pop_trans);

/* Pop the thing up. */

XtPopup(dialog_shell, XtGrabExclusive);
XFlush(X_display);
}
Example #5
0
int
main (int argc, char **argv)
{
    XtAppContext xtcontext;
    Widget toplevel;

    ProgramName = argv[0];

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

    toplevel = XtAppInitialize(&xtcontext, "XBiff", options, XtNumber (options),
			       &argc, argv, NULL, NULL, 0);
    if (argc != 1) Usage ();

    /*
     * This is a hack so that f.delete will do something useful in this
     * single-window application.
     */
    wm_delete_window = XInternAtom (XtDisplay(toplevel), "WM_DELETE_WINDOW",
                                    False);
    XtAppAddActions (xtcontext, xbiff_actions, XtNumber(xbiff_actions));
    XtOverrideTranslations(toplevel,
		   XtParseTranslationTable ("<Message>WM_PROTOCOLS: quit()"));

    (void) XtCreateManagedWidget ("mailbox", mailboxWidgetClass, toplevel,
				  NULL, 0);
    XtRealizeWidget (toplevel);
    (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel),
                            &wm_delete_window, 1);
    XtAppMainLoop (xtcontext);

    return 0;
}
Example #6
0
/* AddToggleWidget will create a managed ToggleWidget in a radio_group,
   and set translation tables for correct behavior.
   Set radio_group to NULL to create the first widget in the group. */
Widget AddToggleWidget(
      String name,
      Widget parent,
      Widget radio_group,
      XtPointer radio_data,
      ArgList args,
      Cardinal num_args) {
  static String translation_table =
    "<EnterWindow>:        highlight(Always) \n \
     <LeaveWindow>:        unhighlight() \n \
     <Btn1Down>,<Btn1Up>:        set() notify()";
  static XtTranslations toggle_translations;

  Widget tw;
  Arg tw_args[2];
  Cardinal i;

  if(!toggle_translations)
    toggle_translations = XtParseTranslationTable(translation_table);

  i = 0;
  XtSetArg(tw_args[i], XtNradioData, radio_data); i++;
  XtSetArg(tw_args[i], XtNradioGroup, radio_group); i++;
  tw = XtCreateManagedWidget(name, toggleWidgetClass, parent, tw_args, i);
  
  XtSetValues(tw, args, num_args);
  XtOverrideTranslations(tw, toggle_translations);
  return(tw);
}
static int motSetDragSourceAttrib(Ihandle* ih, const char* value)
{
  Widget w = (Widget)iupAttribGet(ih, "_IUPMOT_DND_WIDGET");
  if (!w)
    w = ih->handle;

  if(iupStrBoolean(value))
  {
    char dragTranslations[] = "#override <Btn2Down>: iupStartDrag()";
    static int do_rec = 0;

    if (!do_rec)
    {
      XtActionsRec rec = {"iupStartDrag", (XtActionProc)motDragStart};
      XtAppAddActions(iupmot_appcontext, &rec, 1);
      do_rec = 1;
    }
    XtOverrideTranslations(w, XtParseTranslationTable(dragTranslations));

    XtVaSetValues(w, XmNuserData, ih, NULL);  /* Warning: always check if this affects other controls */
  }
  else
    iupmotDisableDragSource(w);

  return 1;
}
Example #8
0
Widget
xaw_create_menu_widgets(Widget parent)
{
    /* hack to disable the magnifier in the panel: */
    XtTranslations panel_translations = XtParseTranslationTable("#augment <ButtonPress>:");

    XtAppAddActions(XtWidgetToApplicationContext(parent), menu_actions, XtNumber(menu_actions));

    line_widget = XtVaCreateWidget("line", widgetClass, parent,
                                   XtNbackground, (XtArgVal)resource.fore_Pixel,
                                   XtNwidth, (XtArgVal)1,
                                   XtNfromHoriz, (XtArgVal)globals.widgets.vport_widget,
                                   XtNborderWidth, (XtArgVal)0,
                                   XtNtop, (XtArgVal)XtChainTop,
                                   XtNbottom, (XtArgVal)XtChainBottom,
                                   XtNleft, (XtArgVal)XtChainRight,
                                   XtNright, (XtArgVal)XtChainRight,
                                   NULL);
    panel_widget = XtVaCreateWidget("panel", compositeWidgetClass, parent,
                                    XtNborderWidth, (XtArgVal)0,
                                    XtNfromHoriz, (XtArgVal)line_widget,
                                    XtNtranslations, (XtArgVal)panel_translations,
                                    XtNtop, (XtArgVal)XtChainTop,
                                    XtNbottom, (XtArgVal)XtChainBottom,
                                    XtNleft, (XtArgVal)XtChainRight,
                                    XtNright, (XtArgVal)XtChainRight,
                                    NULL);
    return panel_widget;
}
Example #9
0
Widget make_text_widget(char *name, Widget parent, Arg *args, int n)
{
  /* white background when active, emacs translations */
  /* used only for comment widget in file data box (snd-xfile.c), but needs to be in this file to pick up actions etc */
  Widget df;
  if (!actions_loaded) 
    {
      XtAppAddActions(MAIN_APP(ss), acts, NUM_ACTS); 
      actions_loaded = true;
    }
  XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++;
  /* XmNblinkRate 0 turns off the cursor blink */
  XtSetArg(args[n], XmNcursorPositionVisible, false); n++;
  XtSetArg(args[n], XmNhighlightThickness, 1); n++;
  df = XmCreateScrolledText(parent, name, args, n);
  XtManageChild(df);
  XtAddCallback(df, XmNfocusCallback, textfield_focus_callback, NULL);
  XtAddCallback(df, XmNlosingFocusCallback, textfield_unfocus_callback, NULL);
  XtAddEventHandler(df, EnterWindowMask, false, mouse_enter_text_callback, NULL);
  XtAddEventHandler(df, LeaveWindowMask, false, mouse_leave_text_callback, NULL);
  if (!transTable3) 
    transTable3 = XtParseTranslationTable(TextTrans3);
  XtOverrideTranslations(df, transTable3);
  return(df);
}
Example #10
0
PRIVATE void CreateLido ()
{
	Widget	sink;
	Arg	args[10];
	int	n;

      /* Create a new toplevel Shell */
	n = 0;
	if (LidoGeometry[0] != '\0')
	{
		XtSetArg (args[n], XtNgeometry, LidoGeometry); n++;
	}
	XtSetArg (args[n], XtNtitle, Res.lido_name); n++;
	LidoTop = XtCreatePopupShell ("lido", topLevelShellWidgetClass,
						Toplevel, args, n);

      /* Create the Text Widget */
	n = 0;
	XtSetArg (args[n], XtNtype, XawAsciiFile); n++;
	XtSetArg (args[n], XtNstring, Res.lido_name); n++;
	LidoText = XtCreateManagedWidget ("lidoText", asciiTextWidgetClass,
						LidoTop, args, n);

      /* Realize the new top level Widget */
	XtPopup (LidoTop, XtGrabNone);

      /*
       * This is a hack so that wm_delete_window will close the rule graph window.
       */
       
        /* Register Actions */
       XtAppAddActions (XtWidgetToApplicationContext(LidoTop), lido_actions, XtNumber(lido_actions));

       XtOverrideTranslations(LidoTop, 
		    XtParseTranslationTable ("<Message>WM_PROTOCOLS: close()"));
       
       wm_delete_window = XInternAtom (XtDisplay(LidoTop), "WM_DELETE_WINDOW", False);
       
       XSetWMProtocols (XtDisplay(LidoTop), XtWindow(LidoTop),
			    &wm_delete_window, 1);


      /* Try to find text sink */
	sink = XtNameToWidget (LidoTop, AsciiTextSinkName);
	if (sink == NULL)
	{
/* Don't give warnings... XtNameToWidget has never worked!
		fprintf (stderr,"%s: Couldn't find window of LIDO text.\n",
				ProgName);
		fprintf (stderr, "Menu will not work in LIDO window.\n");
*/
		return;
	}
	
      /* Register a passive grab for menu-popup */
	XGrabButton (XtDisplay (sink), AnyButton, AnyModifier, 
		XtWindow (sink), TRUE, ButtonPressMask|ButtonReleaseMask,
		GrabModeAsync, GrabModeAsync, None, None);
}
Example #11
0
void 
launch_about(Widget w, XtPointer closure, XtPointer call_data)
{
    DeclareArgs(10);
    Widget    form, icon, ok;
    Position  x, y;
    char	  info[400];

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

    /* don't make more than one */
    if (!help_popup) {

	/* get the position of the help button */
	XtTranslateCoords(w, (Position) 0, (Position) 0, &x, &y);
	FirstArg(XtNx, x);
	NextArg(XtNy, y);
	help_popup = XtCreatePopupShell("About Xfig",transientShellWidgetClass,
				tool, Args, ArgCount);
	XtOverrideTranslations(help_popup,
			   XtParseTranslationTable(about_translations));
	XtAppAddActions(tool_app, about_actions, XtNumber(about_actions));

	FirstArg(XtNborderWidth, 0);
	form = XtCreateManagedWidget("help_form", formWidgetClass, help_popup,
				Args, ArgCount);
	/* put the xfig icon in a label and another label saying which version this is */
	FirstArg(XtNbitmap, fig_icon);
	NextArg(XtNinternalHeight, 0);
	NextArg(XtNinternalWidth, 0);
	NextArg(XtNborderWidth, 0);
	icon = XtCreateManagedWidget("xfig_icon", labelWidgetClass, form, Args, ArgCount);

	/* make up some information */
	strcpy(info,xfig_version);
	strcat(info,"\n  Parts Copyright \251 1989-2013 by Brian V. Smith ([email protected])");
	strcat(info,"\n  Parts Copyright \251 1991 by Paul King");
	strcat(info,"\n  Copyright \251 1985-1988 by Supoj Sutanthavibul");
	strcat(info,"\n  See source files and man pages for other copyrights");

	FirstArg(XtNlabel, info);
	NextArg(XtNfromHoriz, icon);
	NextArg(XtNhorizDistance, 20);
	NextArg(XtNborderWidth, 0);
	XtCreateManagedWidget("xfig_icon", labelWidgetClass, form, Args, ArgCount);

	FirstArg(XtNlabel, " Ok ");
	NextArg(XtNwidth, 50);
	NextArg(XtNheight, 30);
	NextArg(XtNfromVert, icon);
	NextArg(XtNvertDistance, 20);
	ok = XtCreateManagedWidget("help_ok", commandWidgetClass, form, Args, ArgCount);
	XtAddCallback(ok, XtNcallback, help_ok, (XtPointer) NULL);
    }
    XtPopup(help_popup,XtGrabNone);
    (void) XSetWMProtocols(tool_d, XtWindow(help_popup), &wm_delete_window, 1);
}
Example #12
0
void ui_set_drive_menu(int drive, ui_menu_entry_t *flipmenu)
{
    char *leftmenuname;
    int i;
    Widget w;
    int num_app_shells = get_num_shells();

    if (drive < 0 || drive >= NUM_DRIVES) {
        return;
    }

    leftmenuname = lib_msprintf("leftDrive%iMenu", drive + 8);
    if (flipmenu != NULL) {
        w = ui_menu_create(leftmenuname, flipmenu, NULL);
        left_drive_menu[drive] = w;
    }

    if (!drive_menu_translations[drive]) {
        char *translation_table;
        char number[16];
        char *rightmenuname;

        sprintf(number, "%d", drive);
        rightmenuname = lib_msprintf("rightDrive%iMenu", drive + 8);

        translation_table = util_concat(
                "<Btn1Down>: "
                        "XawPositionSimpleMenu(", leftmenuname, ") "
                        "XtMenuPopup(", leftmenuname, ")\n",
                "Meta Shift <KeyDown>z: "
                        "FakeButton(1) "
                        "XawPositionSimpleMenu(", leftmenuname, ") "
                        "XtMenuPopup(", leftmenuname, ")\n",
                "<Btn3Down>: "
                        "RebuildDiskMenu(", number, ",", rightmenuname, ") "
                        "XawPositionSimpleMenu(", rightmenuname, ") "
                        "XtMenuPopup(", rightmenuname, ")\n",
                "Meta Shift <KeyDown>x: "
                        "RebuildDiskMenu(", number, ",", rightmenuname, ") "
                        "FakeButton(3) "
                        "XawPositionSimpleMenu(", rightmenuname, ") "
                        "XtMenuPopup(", rightmenuname, ")\n",
                NULL);
        drive_menu_translations[drive] =
                                XtParseTranslationTable(translation_table);
        lib_free(translation_table);
        lib_free(rightmenuname);

    }

    for (i = 0; i < num_app_shells; i++) {
        XtOverrideTranslations(app_shells[i].
                                        drive_widgets[drive].track_label,
                               drive_menu_translations[drive]);
    }

    lib_free(leftmenuname);
}
Example #13
0
static void make_command_widget(int height)
{
  if (!listener_text)
    {
      Arg args[32];
      Widget wv, wh;
      int n;

      if (!actions_loaded) {XtAppAddActions(MAIN_APP(ss), acts, NUM_ACTS); actions_loaded = true;}

      n = attach_all_sides(args, 0);
      XtSetArg(args[n], XmNheight, height); n++;
      if ((sound_style(ss) == SOUNDS_IN_NOTEBOOK) || (sound_style(ss) == SOUNDS_HORIZONTAL))
	listener_pane = XtCreateManagedWidget("frm", xmFormWidgetClass, SOUND_PANE_BOX(ss), args, n);
      else listener_pane = XtCreateManagedWidget("frm", xmFormWidgetClass, SOUND_PANE(ss), args, n);
      /* this widget is not redundant at least in Metroworks Motif */

      n = 0;
      XtSetArg(args[n], XmNbackground, ss->sgx->listener_color); n++;
      XtSetArg(args[n], XmNforeground, ss->sgx->listener_text_color); n++;
      if (ss->sgx->listener_fontlist) {XtSetArg(args[n], XM_FONT_RESOURCE, ss->sgx->listener_fontlist); n++;}
      n = attach_all_sides(args, n);
      XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++;
      XtSetArg(args[n], XmNskipAdjust, true); n++;
      XtSetArg(args[n], XmNvalue, listener_prompt(ss)); n++;
      XtSetArg(args[n], XmNpendingDelete, false); n++; /* don't cut selection upon paste */
      XtSetArg(args[n], XmNpositionIndex, XmLAST_POSITION); n++;
      XtSetArg(args[n], XmNhighlightThickness, 1); n++;
      listener_text = XmCreateScrolledText(listener_pane, "lisp-listener", args, n);
      ss->sgx->listener_pane = listener_text;

      XtVaSetValues(MAIN_SHELL(ss), XmNallowShellResize, false, NULL);

      XtManageChild(listener_text);
      XmTextSetCursorPosition(listener_text, 1);
      if (!transTable4) 
	transTable4 = XtParseTranslationTable(TextTrans4);
      XtOverrideTranslations(listener_text, transTable4);
      printout_end = 0;
      XtAddCallback(listener_text, XmNactivateCallback, command_return_callback, NULL);
      XtAddCallback(listener_text, XmNmodifyVerifyCallback, command_modify_callback, NULL);
      XtAddCallback(listener_text, XmNmotionVerifyCallback, command_motion_callback, NULL);

      lisp_window = XtParent(listener_text);
      XtAddEventHandler(lisp_window, EnterWindowMask, false, listener_focus_callback, NULL);
      XtAddEventHandler(lisp_window, LeaveWindowMask, false, listener_unfocus_callback, NULL);
      
      XmChangeColor(lisp_window, ss->sgx->basic_color);
      XtVaGetValues(lisp_window, XmNverticalScrollBar, &wv, XmNhorizontalScrollBar, &wh, NULL);
      XmChangeColor(wv, ss->sgx->basic_color);
      XmChangeColor(wh, ss->sgx->basic_color);
      map_over_children(SOUND_PANE(ss), color_sashes);

      if (auto_resize(ss))
	XtVaSetValues(MAIN_SHELL(ss), XmNallowShellResize, true, NULL);
    }
}
Example #14
0
/*
 * Function:
 *	AddInsertFileChildren
 *
 * Parameters:
 *	form - form widget for the insert dialog widget
 *	ptr  - pointer to the initial string for the Text Widget
 *	tw   - main text widget
 *
 * Description:
 *	Adds all children to the InsertFile dialog widget.
 */
static void
AddInsertFileChildren(Widget form, char *ptr, Widget tw)
{
    Arg args[10];
    Cardinal num_args;
    Widget label, text, cancel, insert;
    XtTranslations trans;

    num_args = 0;
    XtSetArg(args[num_args], XtNlabel, INSERT_FILE);	num_args++;
    XtSetArg(args[num_args], XtNleft, XtChainLeft);	num_args++;
    XtSetArg(args[num_args], XtNright, XtChainLeft);	num_args++;
    XtSetArg(args[num_args], XtNresizable, True);	num_args++;
    XtSetArg(args[num_args], XtNborderWidth, 0);	num_args++;
    label = XtCreateManagedWidget(LABEL_NAME, labelWidgetClass, form,
				  args, num_args);
  
    num_args = 0;
    XtSetArg(args[num_args], XtNfromVert, label);	num_args++;
    XtSetArg(args[num_args], XtNleft, XtChainLeft);	num_args++;
    XtSetArg(args[num_args], XtNright, XtChainRight);	num_args++;
    XtSetArg(args[num_args], XtNeditType, XawtextEdit);	num_args++;
    XtSetArg(args[num_args], XtNresizable, True);	num_args++;
    XtSetArg(args[num_args], XtNstring, ptr);		num_args++;
    text = XtCreateManagedWidget(TEXT_NAME, asciiTextWidgetClass, form,
				 args, num_args);

    num_args = 0;
    XtSetArg(args[num_args], XtNlabel, "Insert File");	num_args++;
    XtSetArg(args[num_args], XtNfromVert, text);	num_args++;
    XtSetArg(args[num_args], XtNleft, XtChainLeft);	num_args++;
    XtSetArg(args[num_args], XtNright, XtChainLeft);	num_args++;
    insert = XtCreateManagedWidget("insert", commandWidgetClass, form,
				   args, num_args);

    num_args = 0;
    XtSetArg(args[num_args], XtNlabel, "Cancel");	num_args++;
    XtSetArg(args[num_args], XtNfromVert, text);	num_args++;
    XtSetArg(args[num_args], XtNfromHoriz, insert);	num_args++;
    XtSetArg(args[num_args], XtNleft, XtChainLeft);	num_args++;
    XtSetArg(args[num_args], XtNright, XtChainLeft);	num_args++;
    cancel = XtCreateManagedWidget(DISMISS_NAME, commandWidgetClass, form,
				   args, num_args);

    XtAddCallback(cancel, XtNcallback, PopdownFileInsert, (XtPointer)tw);
    XtAddCallback(insert, XtNcallback, DoInsert, (XtPointer)tw);

    XtSetKeyboardFocus(form, text);

    /*
     * Bind <CR> to insert file
     */
    trans = XtParseTranslationTable("<Key>Return:InsertFileAction()");
    XtOverrideTranslations(text, trans);
}
Example #15
0
File: xsm.c Project: aosm/X11
void
SetWM_DELETE_WINDOW(Widget widget, String delAction)
{
    char translation[64];

    sprintf (translation, "<Message>WM_PROTOCOLS: %s", delAction);
    XtOverrideTranslations (widget, XtParseTranslationTable (translation));

    XSetWMProtocols (XtDisplay(widget), XtWindow (widget),
	&wmDeleteAtom, 1);
}
void iupmotDisableDragSource(Widget w)
{
  char dragTranslations[] = "#override <Btn2Down>: iupDoNothing()";
  static int do_nothing_rec = 0;
  if (!do_nothing_rec)
  {
    XtActionsRec rec = {"iupDoNothing", (XtActionProc)motDoNothing};
    XtAppAddActions(iupmot_appcontext, &rec, 1);
    do_nothing_rec = 1;
  }
  XtOverrideTranslations(w, XtParseTranslationTable(dragTranslations));
}
Example #17
0
/* if the window manager closes the window, tell the
   window manager to send a message to xt. xt will
   call the wm_quit callback.
*/
void grab_window_quit(Widget top)
{
    XtOverrideTranslations
	(TopLevel, XtParseTranslationTable ("<Message>WM_PROTOCOLS: wm_quit()"));

    /* http://www.lemoda.net/c/xlib-wmclose/ */
    static Atom wm_delete_window;
    wm_delete_window = XInternAtom(XtDisplay(top), "WM_DELETE_WINDOW",
				   False);
    (void) XSetWMProtocols (XtDisplay(top), XtWindow(top),
                            &wm_delete_window, 1);
}
Example #18
0
/*
** This routine kludges around the problem of backspace not being mapped
** correctly when Motif is used between a server with a delete key in
** the traditional typewriter backspace position and a client that
** expects a backspace key in that position.  Though there are three
** distinct levels of key re-mapping in effect when a user is running
** a Motif application, none of these is really appropriate or effective
** for eliminating the delete v.s. backspace problem.  Our solution is,
** sadly, to eliminate the forward delete functionality of the delete key
** in favor of backwards delete for both keys.  So as not to prevent the
** user or the application from applying other translation table re-mapping,
** we apply re-map the key as a post-processing step, applied after widget
** creation.  As a result, the re-mapping necessarily becomes embedded
** throughout an application (wherever text widgets are created), and
** within library routines, including the Nirvana utility library.  To
** make this remapping optional, the SetDeleteRemap function provides a
** way for an application to turn this functionality on and off.  It is
** recommended that applications that use this routine provide an
** application resource called remapDeleteKey so savvy users can get
** their forward delete functionality back.
*/
void RemapDeleteKey(Widget w)
{
    static XtTranslations table = NULL;
    static char *translations =
    	"~Shift~Ctrl~Meta~Alt<Key>osfDelete: delete-previous-character()\n";

    if (RemapDeleteEnabled) {
    	if (table == NULL)
    	    table = XtParseTranslationTable(translations);
    	XtOverrideTranslations(w, table);
    }
}
Example #19
0
void readDTIcons(void)
{
 FILE *fp;
 AppRec app;
 char *name, *directory, *fname, *icon, *push_action, *drop_action, *xp, *yp;
 char s[MAXAPPSTRINGLEN];
 int i, p, x, y;

 XtAppAddActions(app_context, icon_actions, XtNumber(icon_actions));
 trans = XtParseTranslationTable(icon_translations);

 dticons_blocked = False;

 if (stat(resources.dticon_file, &dticons_stats) ||
     !(fp = fopen(resources.dticon_file, "r")))
 {
     dticons_readable = False;
     error(getAnyShell(), "Cannot read desktop icons from", resources.dticon_file);
     return;
 }

 dticons_readable = True;

 for (i=0; (p = parseIcon(fp, &name, &directory, &fname, &icon, &push_action, &drop_action, &xp, &yp)) > 0; i++)
 {
     dtIcons = (DTIconRec **) XTREALLOC(dtIcons, (i+1) * sizeof(DTIconRec *));
     app.name = XtNewString(strparse(s, name, "\\:"));
     app.directory = XtNewString(strparse(s, directory, "\\:"));
     app.fname = XtNewString(strparse(s, fname, "\\:"));
     app.icon = XtNewString(strparse(s, icon, "\\:"));
     app.push_action = XtNewString(strparse(s, push_action, "\\:"));
     app.drop_action = XtNewString(strparse(s, drop_action, "\\:"));
     app.objType = getObjectType(app.push_action);
     app.remove_file = False;
     if ((x = atoi(strparse(s, xp, "\\:"))) < 0)
	 x += winInfo.rootWidth - DTICONWIDTH;
     if ((y = atoi(strparse(s, yp, "\\:"))) < 0)
	 y += winInfo.rootHeight - DTICONHEIGHT;

     dtIcons[i] = createDTIcon(getAnyShell(), &app, x, y);
     dtIcons[i]->save = True;
     displayDTIcon(dtIcons[i]);
 }
 
 if (p == -1)
     error(getAnyShell(), "Error reading desktop icons from", resources.dticon_file);

 n_dtIcons = i;

 if (fclose(fp))
     sysError(getAnyShell(), "Error reading desktop icons:");
}
Example #20
0
void add_completer_to_textfield(Widget w, int completer)
{
  /* used to make file selection dialog act like other text field widgets */
  if (!actions_loaded) 
    {
      XtAppAddActions(MAIN_APP(ss), acts, NUM_ACTS); 
      actions_loaded = true;
    }
  if (!transTable2) 
    transTable2 = XtParseTranslationTable(TextTrans2);
  XtOverrideTranslations(w, transTable2);
  add_completer_widget(w, completer);
}
Example #21
0
void
fe_InitRemoteServer (Display *dpy)
{
  static Boolean done = False;
  static XtActionsRec actions [] =
    { { "HandleMozillaCommand", fe_property_change_action } };

  if (done) return;
  done = True;
  fe_init_atoms (dpy);

  XtAppAddActions (fe_XtAppContext, actions, countof (actions));

  fe_prop_translations =
    XtParseTranslationTable ("<PropertyNotify>: HandleMozillaCommand()");
}
Example #22
0
bool wxDialog::XmDoCreateTLW(wxWindow* parent,
                             wxWindowID WXUNUSED(id),
                             const wxString& WXUNUSED(title),
                             const wxPoint& WXUNUSED(pos),
                             const wxSize& WXUNUSED(size),
                             long WXUNUSED(style),
                             const wxString& name)
{
    Widget parentWidget = (Widget) 0;
    if( parent )
        parentWidget = (Widget) parent->GetTopWidget();
    if( !parent )
        parentWidget = (Widget) wxTheApp->GetTopLevelWidget();

    wxASSERT_MSG( (parentWidget != (Widget) 0),
                  "Could not find a suitable parent shell for dialog." );

    Arg args[2];
    XtSetArg (args[0], XmNdefaultPosition, False);
    XtSetArg (args[1], XmNautoUnmanage, False);
    Widget dialogShell =
        XmCreateBulletinBoardDialog( parentWidget,
                                     name.char_str(),
                                     args, 2);
    m_mainWidget = (WXWidget) dialogShell;

    // We don't want margins, since there is enough elsewhere.
    XtVaSetValues( dialogShell,
                   XmNmarginHeight,   0,
                   XmNmarginWidth,    0,
                   XmNresizePolicy, XmRESIZE_NONE,
                   NULL ) ;

    XtTranslations ptr ;
    XtOverrideTranslations(dialogShell,
        ptr = XtParseTranslationTable("<Configure>: resize()"));
    XtFree((char *)ptr);

    XtRealizeWidget(dialogShell);

    wxAddWindowToTable( (Widget)m_mainWidget, this );

    return true;
}
Example #23
0
File: Core.c Project: aosm/X11libs
static void CoreClassPartInitialize(
    register WidgetClass wc)
{
    /* We don't need to check for null super since we'll get to object
       eventually, and it had better define them!  */

    register WidgetClass super = wc->core_class.superclass;

    LOCK_PROCESS;
    if (wc->core_class.realize == XtInheritRealize) {
	wc->core_class.realize = super->core_class.realize;
    }

    if (wc->core_class.accept_focus == XtInheritAcceptFocus) {
	wc->core_class.accept_focus = super->core_class.accept_focus;
    }

    if (wc->core_class.display_accelerator == XtInheritDisplayAccelerator) {
	wc->core_class.display_accelerator =
		super->core_class.display_accelerator;
    }

    if (wc->core_class.tm_table == (char *) XtInheritTranslations) {
	wc->core_class.tm_table =
		wc->core_class.superclass->core_class.tm_table;
    } else if (wc->core_class.tm_table != NULL) {
	wc->core_class.tm_table =
	      (String)XtParseTranslationTable(wc->core_class.tm_table);
    }

    if (wc->core_class.actions != NULL) {
	Boolean inPlace;

	if (wc->core_class.version == XtVersionDontCheck)
	    inPlace = True;
	else
	    inPlace = (wc->core_class.version < XtVersion) ? False : True;

	/* Compile the action table into a more efficient form */
        wc->core_class.actions = (XtActionList) _XtInitializeActionData(
	    wc->core_class.actions, wc->core_class.num_actions, inPlace);
    }
    UNLOCK_PROCESS;
}
Example #24
0
int Ginitgraphics (void) {
    argn = 0;
#if defined(FEATURE_NEXTAW) || defined(FEATURE_XAW3D)
    if (!(Groot = XtAppInitialize (
        &appcontext, "LEFTY", NULL, 0, &argn, NULL, props, NULL, 0
    )))
#else
    if (!(Groot = XtAppInitialize (
        &appcontext, "LEFTY", NULL, 0, &argn, NULL, NULL, NULL, 0
    )))
#endif
        Gerr (POS, G_ERRINITFAILED);
    XtAppAddActions (appcontext, actiontable, XtNumber (actiontable));
    Gtweoltable = XtParseTranslationTable (deftweoltrans);
    Gqwpoptable = XtParseTranslationTable (defqwpoptrans);
    Glwanytable = XtParseTranslationTable (deflwanytrans);
    Gcwanytable = XtParseTranslationTable (defcwanytrans);
    Gqwdeltable = XtParseTranslationTable (defqwdeltrans);
    Gwmdeltable = XtParseTranslationTable (defwmdeltrans);
    XtRegisterGrabAction (
        Glwbutaction, True,
        ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync
    );
    XtRegisterGrabAction (
        Gcwbutaction, True,
        ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync
    );
    Gdisplay = XtDisplay (Groot);
    Gscreenn = DefaultScreen (Gdisplay);
    Gdepth = DefaultDepth (Gdisplay, Gscreenn);
    deffont = XLoadQueryFont (Gdisplay, "fixed");
    Gxfd = ConnectionNumber (Gdisplay);
    Gqwdelatom = XInternAtom (Gdisplay, "WM_DELETE_WINDOW", False);
    Gwmdelatom = XInternAtom (Gdisplay, "WM_DELETE_WINDOW", False);
    Gpopdownflag = FALSE;
    Glazyq.flag = 0;
    Gbufp = Marrayalloc ((long) BUFINCR * BUFSIZE);
    Gbufn = BUFINCR;
    Gppp = Marrayalloc ((long) PPINCR * PPSIZE);
    Gppn = PPINCR;
    Gfontp = Marrayalloc ((long) FONTSIZE);
    Gfontn = 1;
    Gfontp[0].name = strdup ("default");
    if (!Gdefaultfont)
        Gfontp[0].font = deffont;
    else if (Gdefaultfont[0] != '\000')
        Gfontp[0].font = XLoadQueryFont (Gdisplay, Gdefaultfont);
    else
        Gfontp[0].font = NULL;
    return 0;
}
Example #25
0
File: light.c Project: Thump/sceda
static void
Create_Light_Dialog()
{
	Arg	args[3];
	int	n;

	n = 0;
	XtSetArg(args[n], XtNtitle, "Intensity");	n++;
	XtSetArg(args[n], XtNallowShellResize, TRUE);	n++;
	light_shell =  XtCreatePopupShell("lightShell",
						transientShellWidgetClass, main_window.shell, args, n);

	n = 0;
	XtSetArg(args[n], XtNlabel, "Light Intensity");	n++;
	XtSetArg(args[n], XtNvalue, "");					n++;
	light_dialog = XtCreateManagedWidget("lightDialog", dialogWidgetClass,
							light_shell, args, n);

	XawDialogAddButton(light_dialog, "Done", Light_Intensity_Callback, NULL);
	XawDialogAddButton(light_dialog, "Cancel", Cancel_Light_Callback,
						(XtPointer)light_shell);

	XtOverrideTranslations(XtNameToWidget(light_dialog, "value"),
		XtParseTranslationTable(":<Key>Return: Light_Action()"));

	XtVaSetValues(XtNameToWidget(light_dialog, "label"),
				  XtNborderWidth, 0, NULL);
#if ( USE_ROUNDED_BUTTONS == 1 )
	XtVaSetValues(XtNameToWidget(light_dialog, "Done"),
				  XtNshapeStyle, XmuShapeRoundedRectangle,
				  XtNcornerRoundPercent, 30,
				  XtNhighlightThickness, 2,
				  NULL);
	XtVaSetValues(XtNameToWidget(light_dialog, "Cancel"),
				  XtNshapeStyle, XmuShapeRoundedRectangle,
				  XtNcornerRoundPercent, 30,
				  XtNhighlightThickness, 2,
				  NULL);
#endif

	XtRealizeWidget(light_shell);
}
Example #26
0
/* if the window manager closes the window, tell the
   window manager to send a message to xt. xt will
   call the wm_quit callback.
*/
void grab_window_quit(Widget top)
{
    XtAppContext app = XtWidgetToApplicationContext(top);
    /* if the user closes the window
       the Window Manager will call our quit() function
    */
    /* xorg/app/oclock/oclock.c */
    static XtActionsRec actions[] = {
        {"quit",	wm_quit}
    };
    XtAppAddActions
	(app, actions, XtNumber(actions));
    XtOverrideTranslations
	(TopLevel, XtParseTranslationTable ("<Message>WM_PROTOCOLS: quit()"));
    Atom wm_delete_window;
    wm_delete_window = XInternAtom(XtDisplay(top), "WM_DELETE_WINDOW",
				   False);
    (void) XSetWMProtocols (XtDisplay(top), XtWindow(top),
                            &wm_delete_window, 1);
}
Example #27
0
Widget ui_menu_create(const char *menu_name, ...)
{
    Widget w;
    ui_menu_entry_t *list;
    va_list ap;

    w = ui_create_shell(_ui_top_level, menu_name, simpleMenuWidgetClass);
    XtAddCallback(w, XtNpopupCallback, menu_popup_callback, NULL);
    XtAddCallback(w, XtNpopdownCallback, menu_popdown_callback, NULL);

    /*
     * We want to be able to have either kind of menu:
     * stay-up when we release the mouse button before moving
     * (it starts on the edge of the menu).
     */
    if (!menu_translations) {
        menu_translations = XtParseTranslationTable(
            "<Motion>: Moved() highlight() PositionSubmenu()\n"
            "<LeaveWindow>: Unhighlight()\n"
            "<BtnUp>: ButtonUp()\n"     /* may do Select() depending on mode */
            "<KeyDown>Down: NextItem()\n"
            "<KeyDown>Up: PrevItem()\n"
            "<KeyDown>Left: ExitSubmenu()\n"
            "<KeyDown>Right: EnterSubmenu()\n"
            "<KeyDown>Return: Select()\n"
            "<KeyDown>space: Select(1)\n"
            "<KeyDown>Escape: Popdownsubmenus() XtMenuPopdown() unhighlight()\n"
          );
    }
    XtOverrideTranslations(w, menu_translations);

    va_start(ap, menu_name);
    while ((list = va_arg(ap, ui_menu_entry_t *)) != NULL) {
        ui_add_items_to_shell(w, 1, list);
    }
    va_end(ap);

    return w;
}
Example #28
0
/*
 * Initialize SubPopup(font)
 */
void InitSubPopupFont()
{
  int i;
  char buf[4];
  String trans2 =
    "<Leave>:  SubPopdown(pftop)";

  pfTop = Xt_P("pftop" ,simpleMenuWidgetClass,toplevel,NULL);
          Xt_W("pfline",smeLineObjectClass   ,pfTop   ,XtNlineWidth,2,NULL);

  for(i=0;i<POPUP_FONT_NITEM;i++) {
    sprintf(buf,"pf%1d",i);
    pf[i] = Xt_W(buf,smeBSBObjectClass,pfTop,
		 XtNleftMargin,16,
		 XtNrightMargin,16,
		 NULL);

    XtAddCallback(pf[i],XtNcallback,(XtCallbackProc)SelectFont,(XtPointer)i);
  }

  XtOverrideTranslations(pfTop,XtParseTranslationTable(trans2));
}
Example #29
0
static void motListEnableDragDrop(Widget w)
{
  Atom atomListItem = XInternAtom(iupmot_display, "LIST_ITEM", False);
  Atom importList[1];
  Arg args[40];
  int num_args = 0;
  char dragTranslations[] = "#override <Btn2Down>: iupListStartDrag()";
  static int do_rec = 0;
  if (!do_rec)
  {
    XtActionsRec rec = {"iupListStartDrag", (XtActionProc)motListDragStart};
    XtAppAddActions(iupmot_appcontext, &rec, 1);
    do_rec = 1;
  }
  XtOverrideTranslations(w, XtParseTranslationTable(dragTranslations));

  importList[0] = atomListItem;
  iupMOT_SETARG(args, num_args, XmNimportTargets, importList);
  iupMOT_SETARG(args, num_args, XmNnumImportTargets, 1);
  iupMOT_SETARG(args, num_args, XmNdropSiteOperations, XmDROP_MOVE|XmDROP_COPY);
  iupMOT_SETARG(args, num_args, XmNdropProc, motListDropProc);
  XmDropSiteRegister(w, args, num_args);
}
Example #30
0
/*
 * Initialize Popup menu
 */
void InitPopup()
{
  int i;
  String trans =
    "<Btn3Motion>: highlight() SubPopup()\n\
    ";

  /* Initialize Popup menu */
  popup    = Xt_P("popup",simpleMenuWidgetClass,toplevel,NULL);
             Xt_W("pmLine"  ,smeLineObjectClass,popup,XtNlineWidth,2,NULL);
  pmAbout  = Xt_W("pmAbout" , smeBSBObjectClass,popup,NULL);
             Xt_W("pmLine"  ,smeLineObjectClass,popup,NULL);
  pmNew    = Xt_W("pmNew"   , smeBSBObjectClass,popup,NULL);
  pmLoad   = Xt_W("pmLoad"  , smeBSBObjectClass,popup,NULL);
  pmSave   = Xt_W("pmSave"  , smeBSBObjectClass,popup,NULL);
  pmClose  = Xt_W("pmClose" , smeBSBObjectClass,popup,NULL);
             Xt_W("pmLine"  ,smeLineObjectClass,popup,NULL);
  pmFont   = Xt_W("pmFont"  , smeBSBObjectClass,popup,NULL);
  pmColor  = Xt_W("pmColor" , smeBSBObjectClass,popup,NULL);
  pmIcon   = Xt_W("pmIcon"  , smeBSBObjectClass,popup,NULL);
  pmDup    = Xt_W("pmDup"   , smeBSBObjectClass,popup,NULL);
             Xt_W("pmLine"  ,smeLineObjectClass,popup,NULL);
  pmQuit   = Xt_W("pmQuit"  , smeBSBObjectClass,popup,NULL);

  XtAddCallback(pmAbout ,XtNcallback,(XtCallbackProc)About        ,(XtPointer)NULL);
  XtAddCallback(pmNew   ,XtNcallback,(XtCallbackProc)MakeVisWindow,(XtPointer)NULL);
  XtAddCallback(pmLoad  ,XtNcallback,(XtCallbackProc)FileDialog   ,(XtPointer)Fload);
  XtAddCallback(pmSave  ,XtNcallback,(XtCallbackProc)FileDialog   ,(XtPointer)Fsave);
  XtAddCallback(pmClose ,XtNcallback,(XtCallbackProc)DeleteWindow ,(XtPointer)NULL);
  XtAddCallback(pmFont  ,XtNcallback,(XtCallbackProc)SelectFont   ,(XtPointer)NULL);
  XtAddCallback(pmColor ,XtNcallback,(XtCallbackProc)SelectColor  ,(XtPointer)NULL);
  XtAddCallback(pmIcon  ,XtNcallback,(XtCallbackProc)Iconify      ,(XtPointer)NULL);
  XtAddCallback(pmDup   ,XtNcallback,(XtCallbackProc)Duplicate    ,(XtPointer)NULL);
  XtAddCallback(pmQuit  ,XtNcallback,(XtCallbackProc)Quit         ,(XtPointer)NULL);

  XtOverrideTranslations(popup,XtParseTranslationTable(trans));
}