Ejemplo n.º 1
0
int
main(int argc, char **argv)
{
    XtAppContext app;
    XmFontList fontlist;
    XmString xmstr1 = XmStringCreateLtoR("Here\nIs\nA\nLabel", "MY_FONT");
    Atom XA_MWM_MESSAGES, PUNT;
    char buf[256];

    XtSetLanguageProc(NULL, NULL, NULL);

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

    fontlist = XmFontListAppendEntry(NULL,
                                     XmFontListEntryCreate("MY_FONT",
                                             XmFONT_IS_FONT,
                                             XLoadQueryFont(XtDisplay(toplevel),
                                                     "-adobe-helvetica-bold-o-normal--17-0-75-75-p-*-iso8859-1")));

    one = XtVaCreateManagedWidget("One",
                                  xmPushButtonWidgetClass,
                                  toplevel, XmNfontList, fontlist,
                                  XmNlabelString, xmstr1,
                                  XtNborderWidth, 20,
                                  NULL);
    XtAddCallback(one, XmNactivateCallback, cb, NULL);


    XA_MWM_MESSAGES = XmInternAtom(XtDisplay(toplevel), _XA_MWM_MESSAGES, False);
    XmAddWMProtocols(toplevel, &XA_MWM_MESSAGES, 1);
    PUNT = XmInternAtom(XtDisplay(toplevel), "PUNT", False);
    XmAddProtocolCallback(toplevel, XA_MWM_MESSAGES, PUNT, punt, NULL);

    sprintf(buf, MENU, PUNT);
    XtVaSetValues(toplevel, XmNmwmMenu, buf, NULL);

    XtRealizeWidget(toplevel);


    {
        static XtWidgetGeometry Expected[] = {
            CWWidth | CWHeight            ,   50,   50,   57,   84, 0,0,0, /* One */
        };
        PrintDetails(  toplevel ,Expected);
    };
    LessTifTestMainLoop(  toplevel );

    exit(0);
}
Ejemplo n.º 2
0
/*
** Set up closeCB to be called when the user selects close from the
** window menu.  The close menu item usually activates f.kill which
** sends a WM_DELETE_WINDOW protocol request for the window.
*/
void AddMotifCloseCallback(Widget shell, XtCallbackProc closeCB, void *arg)
{
    static Atom wmpAtom, dwAtom = 0;
    Display *display = XtDisplay(shell);

    /* deactivate the built in delete response of killing the application */
    XtVaSetValues(shell, XmNdeleteResponse, XmDO_NOTHING, 0);

    /* add a delete window protocol callback instead */
    if (dwAtom == 0) {
    	wmpAtom = XmInternAtom(display, "WM_PROTOCOLS", TRUE);
    	dwAtom = XmInternAtom(display, "WM_DELETE_WINDOW", TRUE);
    }
    XmAddProtocolCallback(shell, wmpAtom, dwAtom, closeCB, arg);
}
Ejemplo n.º 3
0
void AddDeleteWindowCallback(Widget shell,
			     XtCallbackProc callback, 
			     XtPointer closure)
{
    static Atom WM_DELETE_WINDOW =
	XmInternAtom(XtDisplay(shell), XMST("WM_DELETE_WINDOW"), False);

    // We don't invoke XmAddWMProtocols directly, because this LessTif macro
    // causes a compilation warning with `gcc -Wwrite-strings'.

    static Atom WM_PROTOCOLS = 
	XmInternAtom(XtDisplay(shell), XMST("WM_PROTOCOLS"), FALSE);
    
    XmAddProtocolCallback(shell, WM_PROTOCOLS, WM_DELETE_WINDOW, 
			  callback, closure);
}
Ejemplo n.º 4
0
    static void
add_cancel_action(Widget shell, XtCallbackProc close_callback, void *arg)
{
    static Atom wmp_atom = 0;
    static Atom dw_atom = 0;
    Display *display = XtDisplay(shell);

    /* deactivate the built-in delete response of killing the application */
    XtVaSetValues(shell, XmNdeleteResponse, XmDO_NOTHING, NULL);

    /* add a delete window protocol callback instead */
    if (!dw_atom)
    {
	wmp_atom = XmInternAtom(display, "WM_PROTOCOLS", True);
	dw_atom = XmInternAtom(display, "WM_DELETE_WINDOW", True);
    }
    XmAddProtocolCallback(shell, wmp_atom, dw_atom, close_callback, arg);
}
Ejemplo n.º 5
0
/*
** Create a new event display window
*/
SpaceWindow *CreatePanelSp(Display *display, int setsEventNum,
    int canOpenFiles, int canExit, char *windowTitle, char *eventSelectorText)
{
    Widget appShell, main, menuBar, form;
    SpaceWindow *window;
    static Atom wmpAtom, dwAtom = NULL;
    Arg al[20];
    int type, ac;
    XGCValues values;

    /* Allocate some memory for the new window data structure */
    window = (SpaceWindow *)XtMalloc(sizeof(SpaceWindow));
    
    /* Create an toplevel shell to hold the window */
    ac = 0;
    XtSetArg(al[ac], XmNtitle, windowTitle); ac++;
    XtSetArg(al[ac], XmNdeleteResponse, XmDO_NOTHING); ac++;
    XtSetArg(al[ac], XmNiconName, windowTitle); ac++;
    /* Keep the phase name here, to same valid XDefaults.. */
    appShell = XtAppCreateShell ("phase", "Space",
		applicationShellWidgetClass, display, al, ac);
    	    
    /*
    ** create a main window holding a menu bar and a form with the rest of
    ** the window contents.
    */
    main = XmCreateMainWindow(appShell, "main", NULL, 0);
    XtManageChild(main);
    type = STDHEP_SPACE;
    menuBar = CreateMenuBar(main, (StdHepWindow *) window,
                                   canOpenFiles, canExit, type);
    XtManageChild(menuBar);
    form = createContents(main, window, setsEventNum, eventSelectorText);
    XtManageChild(form);

    /* add the window to the global window list */
    AddToWindowList((StdHepWindow *) window);
    
    /* realize all of the widgets in the new window */
    XtRealizeWidget(appShell);

    /* set up closeCB to be called when the user selects close from the
       window menu.  The close menu item usually activates f.kill which
       sends a WM_DELETE_WINDOW protocol request for the window. */
    if (dwAtom == NULL) {
    	wmpAtom = XmInternAtom(display, "WM_PROTOCOLS", TRUE);
    	dwAtom = XmInternAtom(display, "WM_DELETE_WINDOW", TRUE);
    }
    XmAddProtocolCallback(appShell, wmpAtom, dwAtom, closeCB, window);

    /* initialize window structure, including a read-only graphics contexts
       for drawing in scale area and highlighting in spin widget */
    window->shell = appShell;
    window->selectedTrack = NO_TRACK;
    window->trackWindowShell = NULL;
    window->btnRotationPanel = NULL;
    window->absRotationPanel = NULL;
    window->buttonRotateDegrees = INITIAL_ROT_INCR;
    window->event.nParticles = 0;
    window->event.particles = NULL;
    window->colorcode.nParticles = 0;
    window->colorcode.particles = NULL;
    window->nDetectorSegments = 0;
    window->detectorSegments = NULL;
    ac = 0;
    XtSetArg(al[ac], XmNbackground, &values.background); ac++;
    XtSetArg(al[ac], XmNforeground, &values.foreground); ac++;
    XtGetValues(window->scaleArea, al, ac);
    window->scaleGC =
    	XtGetGC(window->scaleArea, GCForeground|GCBackground, &values);
    window->highlightGC = SpinCopyGC(window->spin);
    XSetLineAttributes(display, window->highlightGC, 5, LineSolid,
    		       CapRound, JoinMiter);
    return window;
}
Ejemplo n.º 6
0
void
main(unsigned int argc, char **argv)
{

	Arg     args[10];
	int     n;
	int		i;

	XmString    message;
	XmString    cancel_label, ok_label, help_label;
	char    message_begin[120];


	n = 0;

    CommonTestInit(argc, argv);

    n = 0;
	XtSetArg(args[n], XmNwidth, 10); n++;
	XtSetArg(args[n], XmNheight, 10); n++;
	XtSetValues(Shell1, args, n);

	XtRealizeWidget(Shell1);

    CommonPause();
    
	XSetErrorHandler(ErrorHandle);
	/*
 	 * Initialize the PIInfo data values
  	 */
	for (i = 0; i < NUM_TESTS; i++)
		PIInfo[i].actual_return = False;

/*
 * Create top level shell widget as parent for test_button widgets
 */
	n = 0;
	XtSetArg(args[n], XtNallowShellResize, TRUE); n++;

	test_top = XtAppCreateShell("test_top",				/* application name */
		 						"Test_top",				/* application class */
		 						topLevelShellWidgetClass,	/* widget class */
		 						display,				/* display */
		 						args, n);				/* arguments */

/*
 * Create button1 widget
 */
	display = XtDisplay(test_top);
	screen = DefaultScreenOfDisplay(display);
	test1_btn1_icon = XCreatePixmapFromBitmapData(display, rootWindow,
								btn1_bits, btn1_width,
								btn1_height,
								CommonGetColor("red"),
								CommonGetColor("yellow"),
								DefaultDepth(display, DefaultScreen(display)));
	test2_btn1_icon = XCreatePixmapFromBitmapData(display, rootWindow,
								btn2_bits, btn2_width,
								btn2_height,
								CommonGetColor("yellow"),
								CommonGetColor("red"),
								DefaultDepth(display, DefaultScreen(display)));
	n = 0;
	XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++;
	XtSetArg(args[n], XmNlabelPixmap, test1_btn1_icon); n++;
	XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
	XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
	test1_btn1 = XmCreatePushButton(test_top, "test1_btn1", args, n);
	XtManageChild(test1_btn1);
	XtRealizeWidget(test_top);

/*
 * Create top level shell widget as parent for test_button2 widget
 */
	n = 0;
	XtSetArg(args[n], XtNallowShellResize, TRUE); n++;

	test_top2 = XtAppCreateShell("test_top2",			/* application name */
		 						"Test_top2",			/* application class */
		 						topLevelShellWidgetClass,	/* widget class */
		 						display,				/* display */
		 						args, n);				/* arguments */

/*
 * Create button2 widget
 */
	n = 0;
	XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++;
	XtSetArg(args[n], XmNlabelPixmap, test2_btn1_icon); n++;
	XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
	XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
	test2_btn1 = XmCreatePushButton(test_top2, "test2_btn1", args, n);
	XtManageChild(test2_btn1);
	XtRealizeWidget(test_top2);

	test_wdw = XtWindow(test_top);
	top_wdw = XtWindow(Shell1);
	test_wdw2 = XtWindow(test_top2);

	XtAddEventHandler(Shell1, NoEventMask, True, CMEventHandler, NULL);
	XtAddEventHandler(test_top, NoEventMask, True, CMEventHandler, NULL);
	XtAddEventHandler(test_top2, NoEventMask, True, CMEventHandler, NULL);

	/*
	 * Move the test_top shell window and the Shell1 window
	 */
	XMoveWindow(display, test_wdw, 100, 100);
	XMoveWindow(display, test_wdw2, 100, 300);

	/*
 	 * set protocols - WM_DELETE_WINDOW
  	 */
	proto_atom = XmInternAtom(display, "WM_PROTOCOLS", False);
	delwin_atom = XmInternAtom(display, "WM_DELETE_WINDOW", False);
	XmAddWMProtocols(test_top, &delwin_atom, 1);

#ifdef	DONT
/*
 * set protocols - WM_SAVE_YOURSELF
 */
		savylf_atom = XmInternAtom(display, "WM_SAVE_YOURSELF", False);
		XmAddWMProtocols(test_top2, &savylf_atom, 1);

/*
 * set protocols - WM_TAKE_FOCUS
 */
		takfoc_atom = XmInternAtom(display, "WM_TAKE_FOCUS", False);
		/* change it on test_wdw2 */
		XChangeProperty(display, test_wdw2,
			proto_atom, 
			proto_atom, 32, PropModeReplace,
			(unsigned char *)&takfoc_atom, 1);
#endif	/* DONT */

    CommonPause();
	iteration++;

	/*
 	 * Check if window is not deleted after f.kill WM_DELETE_WINDOW
  	 */
	ret_stat = XGetWindowAttributes(display, test_wdw, &win_attrs);
	/*
	 * Actual return is if the window is still mapped and
	 * recognizable.
	 */
	PIInfo[PIInfo_DW2].actual_return = ret_stat;

	/*
  	 * set protocols - _MOTIF_WM_MESSAGES
  	 */
	/* add to the menu with the _MOTIF_WM_MENU property */
	strcpy(menu_item, send_msg1);
	menu_atom = XmInternAtom(display, "_MOTIF_WM_MENU", False);
	XChangeProperty(display, test_wdw2, menu_atom, menu_atom, 8, 
					PropModeReplace, (unsigned char *)menu_item, 
					strlen(menu_item) + 1);
    /* add a message acceptance to widget */
	motif_msg_atom = XmInternAtom(display, "_MOTIF_WM_MESSAGES", False);
	XmAddWMProtocols(test_top2, &motif_msg_atom, 1);

	msg_num = MSG_NUMBER;
	XmAddProtocolCallback(test_top2, motif_msg_atom, (Atom)msg_num,
						  HandleMsgCB, NULL);

	PIUnmapWindow(test_wdw2);
	wm_set_hints.flags = (StateHint);
	wm_set_hints.initial_state = NormalState;
	XSetWMHints(display, test_wdw2, &wm_set_hints);
	XMapWindow(display, test_wdw2);
	XMoveWindow(display, test_wdw2, 100, 300);

#ifdef	DONT
/*
 * Iconify test_wdw2, see if save_yourself works
 */
	/*
	 * Unmap the window to change state
	 */
	PIUnmapWindow(test_wdw2);
	/* 
	 * Map the window into iconic state
	 */
	wm_set_hints.flags = (StateHint);
	wm_set_hints.initial_state = IconicState;
	XSetWMHints(display, test_wdw2, &wm_set_hints);
	XMapWindow(display, test_wdw2);
#endif /* DONT */

	CommonPause();
#ifdef SHOW_P899

	iteration++;

	/*
 	 * set protocols - _MOTIF_WM_MENU
  	 */
	/* add to the menu with the _MOTIF_WM_MENU property */
	strcpy(menu_item2, send_msg2);
	XChangeProperty(display, test_wdw2, menu_atom, menu_atom, 8, 
					PropModeAppend, (unsigned char *)menu_item2, 
					strlen(menu_item2) + 1);
	/*
 	 * Turn on acceptance of send_message2
  	 */
	msg_num = MSG_NUMBER2;
	XmAddProtocolCallback(test_top2, motif_msg_atom, (Atom)msg_num,
						  HandleMsg2CB, NULL);
	PIUnmapWindow(test_wdw2);
    wm_set_hints.flags = (StateHint);
	wm_set_hints.initial_state = NormalState;
	XSetWMHints(display, test_wdw2, &wm_set_hints);
	XMapWindow(display, test_wdw2);
	XMoveWindow(display, test_wdw2, 100, 300);

	CommonPause();

#endif /* P899 */
	iteration++;

	/*
 	 * set protocols - _MOTIF_WM_MENU
  	 */
	/* add to the menu with the _MOTIF_WM_MENU property */
	strcpy(menu_item2, send_msg3);
	XChangeProperty(display, test_wdw2, menu_atom, menu_atom, 8, 
					PropModeReplace, (unsigned char *)menu_item2, 
					strlen(menu_item2) + 1);
#ifndef P899
	/*
 	 * Turn on acceptance of send_message2
  	 */
	msg_num = MSG_NUMBER2;
	XmAddProtocolCallback(test_top2, motif_msg_atom, (Atom)msg_num,
						  HandleMsg2CB, NULL);
#endif /* P899 */
	PIUnmapWindow(test_wdw2);
    wm_set_hints.flags = (StateHint);
	wm_set_hints.initial_state = NormalState;
	XSetWMHints(display, test_wdw2, &wm_set_hints);
	XMapWindow(display, test_wdw2);
	XMoveWindow(display, test_wdw2, 100, 300);

	CommonPause();
	iteration++;

/*
 * Put up a message box with the results of the test.
 */
	display_summary(NUM_TESTS, TEST_DESCRIP_LENGTH, PIInfo);

	CommonPause();

/*
 *  Loop and process events.
 */

	XtAppMainLoop(app_context);

}