Ejemplo n.º 1
0
MenuBar::MenuBar ( Widget parent, char *name, unsigned char type ) 
: UIComponent ( name )
{
    // Base widget is a Motif menu bar widget
    
    if(parent == NULL)
	return;

    if( type == XmMENU_POPUP) {
	Arg args[1];
	int i = 0;

	XtSetArg(args[i], XmNwhichButton, theApplication->bMenuButton()); i++;
    	_w = XmCreatePopupMenu( parent, _name, args, i );
//        XtVaSetValues(_w, XmNwhichButton, theApplication->bMenuButton(), NULL);
    } else {
	type = XmMENU_BAR; // Force it to menu bar
    	_w = XmCreateMenuBar ( parent, _name, NULL, 0 );
    }

    printHelpId("_w", _w);
    /* install callback */
    // XtAddCallback(_w, XmNhelpCallback, HelpCB, helpId);
    
    installDestroyHandler();
}
Ejemplo n.º 2
0
Widget CreateMenubar(Widget parent)
{
    Widget
        cascade_w,
        menubar_w,
        menupane_w;

    /* create the menubar (row column) widget */
    menubar_w=XmCreateMenuBar(parent,"menubarw",NULL,0);         

    /* create the File pulldown menu */
    menupane_w=CreateMenu(menubar_w,"filemenu","File",0,NULL);
    CreateMenuItem(menupane_w,"quit","Quit",'Q',
            DoActionCb,"quit");

    /* create the Options pulldown menu */
    menupane_w=CreateMenu(menubar_w,"optionsmenu","Options",0,NULL);
    CreateMenuItem(menupane_w,"editc","Edit Config File",'E',
            DoActionCb,"editc");

    /* create the Help pulldown menu */
    menupane_w=CreateMenu(menubar_w,"helpmenu","Help",0,&cascade_w);
    XtVaSetValues(menubar_w,
        XmNmenuHelpWidget,cascade_w,
        NULL);
    CreateMenuItem(menupane_w,"about","About ...",'A',
            DoActionCb,"about");

    return (menubar_w);
}
Ejemplo n.º 3
0
static Widget 
CreateMainWindowWithMenuBar(Widget toplevel)
{
    Widget	main_window, menu_bar, menu_pane, cascade, button ;
    
    Arg		args[20];	
    Cardinal	n;		
    

    /*	Create MainWindow.
     */
    n = 0;
    main_window = XmCreateMainWindow (toplevel, "main_window", args, n);
    XtManageChild (main_window);
    
    
    /*	Create MenuBar in MainWindow.
     */
    n = 0;
    menu_bar = XmCreateMenuBar (main_window, "menu_bar", args, n); 
    XtManageChild (menu_bar);
    
    /*	Create "File" PulldownMenu.
     */
    n = 0;
    menu_pane = XmCreatePulldownMenu (menu_bar, "menu_pane", args, n);
    
    n = 0;
    button = XmCreatePushButton (menu_pane, "Exit", args, n);
    XtManageChild (button);
    XtAddCallback (button, XmNactivateCallback, QuitCB, NULL);
    
    n = 0;
    XtSetArg (args[n], XmNsubMenuId, menu_pane);  n++;
    cascade = XmCreateCascadeButton (menu_bar, "File", args, n);
    XtManageChild (cascade);
    
    
    /*	Create "Help" PulldownMenu.
     */
    n = 0;
    menu_pane = XmCreatePulldownMenu (menu_bar, "menu_pane3", args, n);
    
    n = 0;
    button = XmCreatePushButton (menu_pane, "Overview", args, n);
    XtManageChild (button);
    XtAddCallback (button, XmNactivateCallback, HelpCB, NULL);
    
    n = 0;
    XtSetArg (args[n], XmNsubMenuId, menu_pane);  n++;
    cascade = XmCreateCascadeButton (menu_bar, "Help", args, n);
    XtManageChild (cascade);
    n = 0;
    XtSetArg (args[n], XmNmenuHelpWidget, cascade);  n++;
    XtSetValues (menu_bar, args, n);
    
    return main_window ;    
}
Ejemplo n.º 4
0
Widget CreateMenuBar(Widget parent, char* name)
{
  Widget menubar;
  Arg args[20];
  int n = 0;
  menubar = XmCreateMenuBar(parent, name, args, n);
  XtManageChild(menubar);
  return menubar;
}
Ejemplo n.º 5
0
static Widget CreateMenuBar(Widget parent, char *name)
{
    Widget widget;

    widget = XmCreateMenuBar(parent, name, NULL, 0);
    XtManageChild(widget);

    return(widget);
}
Ejemplo n.º 6
0
void guitst_createMain ( Widget parent )
/************************************************************************
 * guitst_createMain   	                                                *
 *                                                                      *
 * This function creates the main window				*
 *                                                                      *
 * void	guitst_createMain( parent )					*
 *                                                                      *
 * Input parameters:                                                    *
 *                                                                      *
 *      parent    Widget    parent widget id                        	*
 *                                                                      *
 * Output parameters:                                                   *
 *                      NONE                                            *
 *                                                                      *
 * Return parameters:                                                   *
 *                                                                      *
 ** Log:                                                                *
 *      S. Wang/GSC    10/97	                                        *
 ***********************************************************************/
{
Widget	main_w, button;
Pixel	bg;
long	ii;

/*---------------------------------------------------------------------*/

	main_w = XtVaCreateWidget("mainw_pane",
                        xmPanedWindowWidgetClass, parent,
                        XmNsashWidth,             1,
                        XmNsashHeight,            1,
                        NULL, 0);

	_menuBar = XmCreateMenuBar(main_w, "menubar", NULL, 0);
        XtVaGetValues(parent, XmNbackground, &bg, NULL);
        XtVaSetValues(_menuBar, XmNbackground, bg, NULL);

	/*
	 * create Exit button
	 */

        button = XmCreateCascadeButton( _menuBar, 
					"Exit", NULL, 0 );

        XtVaSetValues( button, XmNbackground, bg, NULL );
        XtManageChild( button );

        XtAddCallback( button, XmNactivateCallback,
         	        guitst_exitCb, (XtPointer)ii );

	XtManageChild( _menuBar );

	guitst_createCanvas( main_w );

	XtManageChild( main_w );

}
Ejemplo n.º 7
0
MainWindow::MainWindow()
    : QtMotifWidget("mainwindow", xmMainWindowWidgetClass, 0)
{
    Widget menubar = XmCreateMenuBar( motifWidget(), const_cast<char*>("menubar"), NULL, 0 );
    Widget filemenu = XmCreatePulldownMenu( menubar, const_cast<char*>("filemenu"), NULL, 0 );
    Widget item;

    item = XtVaCreateManagedWidget( "Motif Dialog...",
                                    xmPushButtonGadgetClass, filemenu,
                                    XmNmnemonic, 'C',
                                    NULL );
    XtAddCallback( item, XmNactivateCallback, motifDialogCallback, this );

    item = XtVaCreateManagedWidget( "Qt Dialog...",
                                    xmPushButtonGadgetClass, filemenu,
                                    XmNmnemonic, 'Q',
                                    NULL );
    XtAddCallback( item, XmNactivateCallback, qtDialogCallback, this );

    item = XtVaCreateManagedWidget( "sep",
                                    xmSeparatorGadgetClass, filemenu,
                                    NULL );

    item = XtVaCreateManagedWidget( "Exit",
                                    xmPushButtonGadgetClass, filemenu,
                                    XmNmnemonic, 'x',
                                    NULL );
    XtAddCallback( item, XmNactivateCallback, quitCallback, this );

    XmString str = XmStringCreateLocalized( const_cast<char*>("File") );
    item = XtVaCreateManagedWidget( "File",
                                    xmCascadeButtonWidgetClass, menubar,
                                    XmNlabelString, str,
                                    XmNmnemonic, 'F',
                                    XmNsubMenuId, filemenu,
                                    NULL );
    XmStringFree( str );

    Arg args[2];
    XtSetArg( args[0], XmNeditMode, XmMULTI_LINE_EDIT );
    Widget texteditor =
        XmCreateScrolledText( motifWidget(), const_cast<char*>("texteditor"),
                              args, 1 );

    XtManageChild( menubar );
    XtManageChild( texteditor );

    // pick a nice default size
    XtVaSetValues( motifWidget(),
                   XmNwidth, 400,
                   XmNheight, 300,
                   NULL );

    setWindowTitle(tr("QtMotif Dialog Example"));

}
Ejemplo n.º 8
0
int
main(int argc, char *argv[]) {
    Widget rc, frame1, label;

    XtSetLanguageProc(NULL, NULL, NULL);

    top = XtVaAppInitialize(&app_context,
                            "Test-prog",
                            NULL, 0,
                            &argc, argv,
                            NULL,
                            NULL);

    main_window =
        XtVaCreateManagedWidget("mainwin", xmMainWindowWidgetClass, top, NULL);

    XmRepTypeInstallTearOffModelConverter();

    menubar = XmCreateMenuBar(main_window, "menubar", NULL, 0);
    XtManageChild(menubar);

    XmMainWindowSetAreas(main_window,menubar,NULL,NULL,NULL,NULL);

    rc = XtVaCreateWidget("rc", xmRowColumnWidgetClass, main_window, NULL);

    XtVaSetValues(main_window, XmNworkWindow, rc, NULL);
    XtManageChild(rc);

    frame1 = XtVaCreateWidget("frame1",
                              xmFrameWidgetClass,
                              rc,
                              NULL);
    XtManageChild(frame1);

    XtRealizeWidget(top);

    label = XtVaCreateManagedWidget("Rampaging Bulldozers",
                                    xmLabelWidgetClass,
                                    frame1,
                                    NULL);

    {
        static XtWidgetGeometry Expected[] = {
            CWWidth | CWHeight            ,   56,   72,   16,   32, 0,0,0, /* mainwin */
            CWWidth | CWHeight | CWX | CWY,    0,    0,   16,   16, 0,0,0, /* menubar */
            CWWidth | CWHeight | CWX | CWY,    0,   16,   16,   16, 0,0,0, /* rc */
            CWWidth | CWHeight | CWX | CWY,    3,    3,   10,    4, 0,0,0, /* frame1 */
            CWWidth | CWHeight | CWX | CWY,    2,    2,    6,    1, 0,0,0, /* Rampaging Bulldozers */
        };
        /* toplevel should be replaced with to correct applicationShell */
        PrintDetails(top, Expected);
    }
    LessTifTestMainLoop(top);

    exit(0);
}
Ejemplo n.º 9
0
int
main(int argc, char **argv)
{
    XtAppContext theApp;
    Widget toplevel, rc;
    Widget cascade1;
    Widget pane1;
    Widget w;

    toplevel = XtVaAppInitialize(&theApp, "test1", NULL, 0,
				 &argc, argv, NULL, NULL);

    rc = XmCreateMenuBar(toplevel, "menubar", NULL, 0);

    pane1 = XmCreatePulldownMenu(rc, "pane1", NULL, 0);

    /* put a tear off button on this pulldown */
    XtVaSetValues(pane1, 
                  XmNtearOffModel, XmTEAR_OFF_ENABLED,
                  NULL);

    cascade1 = XtVaCreateManagedWidget("cascade1", xmCascadeButtonWidgetClass, rc,
		XmNsubMenuId, pane1,
	NULL);

    w = XtVaCreateManagedWidget("button 1", xmPushButtonWidgetClass, pane1, NULL);
    XtAddCallback(w, XmNactivateCallback, Callback, "Activate");
    XtAddCallback(w, XmNarmCallback, Callback, "Arm");
    XtAddCallback(w, XmNdisarmCallback, Callback, "Disarm");

    w = XtVaCreateManagedWidget("button 2", xmPushButtonWidgetClass, pane1, NULL);
    XtAddCallback(w, XmNactivateCallback, Callback, "Activate");
    XtAddCallback(w, XmNarmCallback, Callback, "Arm");
    XtAddCallback(w, XmNdisarmCallback, Callback, "Disarm");

    w = XtVaCreateManagedWidget("button 2", xmSeparatorWidgetClass, pane1, NULL);

    w = XtVaCreateManagedWidget("gadget 3", xmPushButtonGadgetClass, pane1, NULL);
    XtAddCallback(w, XmNactivateCallback, Callback, "Activate");
    XtAddCallback(w, XmNarmCallback, Callback, "Arm");
    XtAddCallback(w, XmNdisarmCallback, Callback, "Disarm");

    XtManageChild(rc);
    XtRealizeWidget(toplevel);
    
{
    static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,   50,   50,   74,   31, 0,0,0, /* menubar */
   CWWidth | CWHeight | CWX | CWY,    5,    5,   64,   21, 0,0,0, /* cascade1 */ 
    };
    PrintDetails(    toplevel ,Expected);
};
   LessTifTestMainLoop(    toplevel );    
    exit(0);
}
Ejemplo n.º 10
0
// Create menubar
bool wxMenuBar::CreateMenuBar(wxFrame* parent)
{
    m_parent = parent; // bleach... override it!
    PreCreation();
    m_parent = NULL;

    if (m_mainWidget)
    {
        XtVaSetValues((Widget) parent->GetMainWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL);
        /*
        if (!XtIsManaged((Widget) m_mainWidget))
        XtManageChild((Widget) m_mainWidget);
        */
        XtMapWidget((Widget) m_mainWidget);
        return true;
    }

    Widget menuBarW = XmCreateMenuBar ((Widget) parent->GetMainWidget(),
                                       wxMOTIF_STR("MenuBar"), NULL, 0);
    m_mainWidget = (WXWidget) menuBarW;

    size_t menuCount = GetMenuCount();
    for (size_t i = 0; i < menuCount; i++)
    {
        wxMenu *menu = GetMenu(i);
        wxString title(m_titles[i]);
        menu->SetButtonWidget(menu->CreateMenu (this, menuBarW, menu, i, title, true));

        if (strcmp (wxStripMenuCodes(title), "Help") == 0)
            XtVaSetValues ((Widget) menuBarW, XmNmenuHelpWidget, (Widget) menu->GetButtonWidget(), NULL);

        // tear off menu support
#if (XmVersion >= 1002)
        if ( menu->IsTearOff() )
        {
            XtVaSetValues(GetWidget(menu),
                          XmNtearOffModel, XmTEAR_OFF_ENABLED,
                          NULL);
            Widget tearOff = XmGetTearOffControl(GetWidget(menu));
            wxDoChangeForegroundColour((Widget) tearOff, m_foregroundColour);
            wxDoChangeBackgroundColour((Widget) tearOff, m_backgroundColour, true);
        }
#endif
    }

    PostCreation();

    XtVaSetValues((Widget) parent->GetMainWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL);
    XtRealizeWidget ((Widget) menuBarW);
    XtManageChild ((Widget) menuBarW);
    SetMenuBarFrame(parent);

    return true;
}
Ejemplo n.º 11
0
void CreateMainW(Widget w, String name)
{
    Widget Form, MenuBar, Label, FileCascade, FileMenu;
    Widget Cascade, CascadeMenu, wch;

    Form = XmCreateForm(w, name, NULL, 0);
    MenuBar = XmCreateMenuBar(Form, "menubar", NULL, 0);
    XtVaSetValues(MenuBar, 
		  XmNtopAttachment, XmATTACH_FORM,
		  XmNleftAttachment, XmATTACH_FORM,
		  XmNrightAttachment, XmATTACH_FORM,
		  NULL);
    Label = XmCreateLabel(Form, "ExtTest Test Application", NULL, 0);
    XtVaSetValues(Label,
		  XmNtopAttachment, XmATTACH_WIDGET,
		  XmNtopWidget, MenuBar,
		  XmNleftAttachment, XmATTACH_FORM,
		  XmNrightAttachment, XmATTACH_FORM,
		  XmNbottomAttachment, XmATTACH_FORM,
		  NULL);
    FileCascade = XmCreateCascadeButton(MenuBar, "File", NULL, 0);
    FileMenu    = XmCreatePulldownMenu(MenuBar, "filemenu", NULL, 0);
    XtVaSetValues(FileCascade, XmNsubMenuId, FileMenu, NULL);

    Cascade = XmCreateCascadeButton(FileMenu, "Cascade", NULL, 0);
    XtManageChild(Cascade);

    XtManageChild(wch = XmCreatePushButton(FileMenu, "Modeless Dialog", NULL, 0));
    XtAddCallback(wch, XmNactivateCallback, DoDialogCB, (XtPointer) XmDIALOG_MODELESS);
    XtManageChild(wch = XmCreatePushButton(FileMenu, "Two Modeless Dialogs", NULL, 0));
    XtAddCallback(wch, XmNactivateCallback, DoDialogCB, (XtPointer) 42);
    XtManageChild(wch = XmCreatePushButton(FileMenu, "Two Modeless Dialogs Cascaded", NULL, 0));
    XtAddCallback(wch, XmNactivateCallback, DoDialogCB, (XtPointer) 43);
    XtManageChild(wch = XmCreatePushButton(FileMenu, "Application Modal Dialog", NULL, 0));
    XtAddCallback(wch, XmNactivateCallback, DoDialogCB, (XtPointer) XmDIALOG_APPLICATION_MODAL);
    XtManageChild(wch = XmCreatePushButton(FileMenu, "Two Application Modal Dialogs", NULL, 0));
    XtAddCallback(wch, XmNactivateCallback, DoDialogCB, (XtPointer) 44);
    XtManageChild(wch = XmCreatePushButton(FileMenu, "Full Application Modal Dialog", NULL, 0));
    XtAddCallback(wch, XmNactivateCallback, DoDialogCB, (XtPointer) XmDIALOG_FULL_APPLICATION_MODAL);

    XtManageChild(XmCreatePushButton(FileMenu, "Quit", NULL, 0));

    CascadeMenu = XmCreatePulldownMenu(FileMenu, "cascademenu", NULL, 0);
    XtVaSetValues(Cascade, XmNsubMenuId, CascadeMenu, NULL);
    XtManageChild(XmCreatePushButton(CascadeMenu, "Test1", NULL, 0));
    XtManageChild(wch = XmCreatePushButton(CascadeMenu, "Test2", NULL, 0));
    XtAddCallback(wch, XmNarmCallback, DumpCB, (XtPointer) NULL);

    XtManageChild(FileCascade);
    XtManageChild(MenuBar);
    XtManageChild(Label);
    XtManageChild(Form);
} /* CreateMainW */
Ejemplo n.º 12
0
void XgraInitializeMenu()

{
  autbegin();

  XgraMenuBar = XmCreateMenuBar( XgraMainWindow,
                                 "XgraMenuBar", NULL, 0 );

  XgraBuildMenus( XgraMenuBar, XgraMainMenu );

  XtManageChild( XgraMenuBar );

  autend();
}
Ejemplo n.º 13
0
void XpatInitializeMenu()

{
  autbegin();

  XpatMenuBar = XmCreateMenuBar( XpatMainWindow,
                                 "XpatMenuBar", NULL, 0 );

  XpatBuildMenus( XpatMenuBar, XpatMainMenu );

  XtManageChild( XpatMenuBar );

  autend();
}
Ejemplo n.º 14
0
void XschInitializeMenu()

{
  autbegin();

  XschMenuBar = XmCreateMenuBar( XschMainWindow,
                                 "XschMenuBar", NULL, 0 );

  XschBuildMenus( XschMenuBar, XschMainMenu );

  XtManageChild( XschMenuBar );

  autend();
}
Ejemplo n.º 15
0
/**************************************************************************
CreateMenus: This function generates the menu bar and the submenus.
**************************************************************************/
void
CreateMenus(Widget parent_of_menu_bar)
{
    XmString   file, help;
    Widget     menubar, FilePullDown, HelpPullDown;
    Widget     overview, quit, Help1;

    /* Create the menubar itself. */
    file = XmStringCreateSimple("File");
    help = XmStringCreateSimple("Help");

    menubar      = (Widget)XmCreateMenuBar(parent_of_menu_bar, "menubar",
                                           NULL, 0);
    FilePullDown = (Widget)XmCreatePulldownMenu(menubar, "FilePullDown",
                   NULL, 0);
    HelpPullDown = (Widget)XmCreatePulldownMenu(menubar, "HelpPullDown",
                   NULL, 0);

    /******************************FILE*********************************/
    XtVaCreateManagedWidget("File", xmCascadeButtonWidgetClass, menubar,
                            XmNlabelString, file,
                            XmNmnemonic, 'F',
                            XmNsubMenuId, FilePullDown,
                            NULL);
    quit = XtVaCreateManagedWidget("Quit", xmPushButtonGadgetClass,
                                   FilePullDown, NULL);
    XtAddCallback(quit, XmNactivateCallback, QuitCB, NULL);


    /******************************HELP*********************************/
    Help1 = XtVaCreateManagedWidget("Help", xmCascadeButtonWidgetClass,
                                    menubar,
                                    XmNlabelString, help,
                                    XmNmnemonic, 'H',
                                    XmNsubMenuId, HelpPullDown,
                                    NULL);
    XtVaSetValues(menubar, XmNmenuHelpWidget, Help1, NULL);
    overview = XtVaCreateManagedWidget("Overview", xmPushButtonGadgetClass,
                                       HelpPullDown, NULL);
    XtAddCallback(overview, XmNactivateCallback, HelpCB, (XtPointer)1);

    XmStringFree(file);
    XmStringFree(help);

    XtManageChild(menubar);
}
Ejemplo n.º 16
0
int
main(int argc, char **argv)
{
    XtAppContext theApp;
    Widget toplevel, rc;
    Widget cascade1;
    Widget pane1;
    Widget w;
    Arg		al[5];
    int		ac;

/* Install converter to make the command line indicated above work */
    XmRepTypeInstallTearOffModelConverter();

/* Toplevel and Menu Bar */
    toplevel = XtVaAppInitialize(&theApp, "test1", NULL, 0, &argc, argv, fallback, NULL);
    rc = XmCreateMenuBar(toplevel, "menubar", NULL, 0);

/* First Menu */
    ac = 0;
    XtSetArg(al[ac], XmNnumColumns, 2); ac++;
    pane1 = XmCreatePulldownMenu(rc, "pane1", al, ac);

    cascade1 = XtVaCreateManagedWidget("cascade1", xmCascadeButtonWidgetClass, rc,
		XmNsubMenuId,	pane1,
	NULL);

    w = XtVaCreateManagedWidget("button1", xmPushButtonWidgetClass, pane1,
	NULL);
    XtAddCallback(w, XmNactivateCallback, MakeDialog, NULL);

    XtManageChild(rc);
    XtRealizeWidget(toplevel);

{
static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,   56,   72,   50,   31, 0,0,0, /* menubar */
   CWWidth | CWHeight | CWX | CWY,    5,    5,   40,   21, 0,0,0, /* cascade1 */
};
/* toplevel should be replaced with to correct applicationShell */
PrintDetails(toplevel, Expected);
}
  LessTifTestMainLoop(toplevel);

    exit(0);
}
Ejemplo n.º 17
0
Archivo: menu.c Proyecto: yhsesq/yhs
/* Function definition */
void create_main_menu(Widget parent)
{
    /* Create the menu bar */
    argcount = 0;   
    menu_bar = XmCreateMenuBar(parent, "Menubar", args, argcount);
    XtManageChild(menu_bar);
    argcount=0;
    /* Attach submenus to it */
    create_file_menu(menu_bar);
    create_preprocessing_menu(menu_bar);
    create_segmentation_menu(menu_bar);
    create_tools_menu(menu_bar); 
    create_feature_menu(menu_bar);
    create_multi_menu(menu_bar);
    create_window_menu(menu_bar);
    create_about_menu(menu_bar);
    create_flasher(menu_bar);
}
Ejemplo n.º 18
0
void structGuiOptionMenu :: f_init (GuiForm parent, int left, int right, int top, int bottom, unsigned long flags)
{
	d_shell = parent -> d_shell;
	d_parent = parent;
	d_options = Ordered_create ();
	#if gtk
		d_widget = gtk_combo_box_new_text ();
		gtk_widget_set_size_request (GTK_WIDGET (d_widget), right - left, bottom - top + 8);
		gtk_fixed_put (GTK_FIXED (parent -> d_widget), GTK_WIDGET (d_widget), left, top - 6);
		gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (d_widget), false);
		GTK_WIDGET_UNSET_FLAGS (d_widget, GTK_CAN_DEFAULT);
	#elif cocoa
		d_widget = (GuiObject) [GuiCocoaOptionMenu alloc];
		v_positionInForm (d_widget, left, right, top, bottom, parent);
		[(GuiCocoaOptionMenu *) d_widget setUserData: this];
		[(NSTextField *) d_widget setBezelStyle: NSRoundedBezelStyle];
		[(NSTextField *) d_widget setBordered: NO];
		[(NSTextField *) d_widget setSelectable: NO];
	#elif motif
		d_xmMenuBar = XmCreateMenuBar (parent -> d_widget, "UiOptionMenu", NULL, 0);
		XtVaSetValues (d_xmMenuBar, XmNx, left - 4, XmNy, top - 4
			#if mac
				- 1
			#endif
			, XmNwidth, right - left + 8, XmNheight, bottom - top + 8, NULL);
		d_xmCascadeButton = XmCreateCascadeButton (d_xmMenuBar, "choice", NULL, 0);
		d_widget = XmCreatePulldownMenu (d_xmMenuBar, "choice", NULL, 0);
		if (flags & GuiMenu_INSENSITIVE)
			XtSetSensitive (d_widget, False);
		XtVaSetValues (d_xmCascadeButton, XmNsubMenuId, d_widget, NULL);
		XtManageChild (d_xmCascadeButton);
		XtVaSetValues (d_xmMenuBar, XmNwidth, right - left + 8, NULL);   // BUG: twice?
		XtVaSetValues (d_xmCascadeButton, XmNx, 4, XmNy, 4, XmNwidth, right - left, XmNheight, bottom - top, NULL);
	#endif

	#if gtk
		g_signal_connect (G_OBJECT (d_widget), "destroy", G_CALLBACK (_guiGtkOptionMenu_destroyCallback), this);
	#elif cocoa
	#elif motif
		XtAddCallback (d_widget, XmNdestroyCallback, _guiMotifOptionMenu_destroyCallback, this);
	#endif
}
Ejemplo n.º 19
0
/*F-------------------------------------------------------------------------
 *  Function:	xGRwidget_menubar_mini ()
 *					-always present menu buttons in graphik part 
 *					-
 *  In:			-parent widget
 *  out:			-
 *  Return:		-
 *---------------------------------------------------------------------------
 */
Widget xGRwidget_menubar_mini( Widget parent )
{
	extern char			*xgrLabelTable[][XGRLABMAXTEXTS];
	extern GRAWIDGETS grawidgets;

	Widget	minimenu, pulldown[8], pullbutton[8], cascadebutton[8];	
	Arg		args[6];
	int		i, n, ac;
	XmString xmstr;

	static ACTCALLBACK actminicallback[] = {
		{BUTTONFILE, BUTTONFILE_CANCEL    },       
		{BUTTONZOOM, BUTTONZOOM_START     },
		{BUTTONZOOM, BUTTONZOOM_ZOOM      },
		{BUTTONZOOM, BUTTONZOOM_LAST      },
		{BUTTONZOOM, BUTTONZOOM_NEXT      },
		{BUTTONHILFE, BUTTONHILFE_GRAPHIK }
	};

	/*---- menubar --------*/
	minimenu = XmCreateMenuBar(parent, GRAPHIKMENUBAR, 0, 0);
	/*---- build an ONE line menu -----------------------------------------*/
	for (i=0;  i<XtNumber(actminicallback);  i++) {
		/*--- pulldown ----*/
		xmstr = XmStringCreateSimple( xgrLabelTable[_GR_MINI_MENU][i]);
		/*-- menubar cascade button -----*/
		ac = 0;
		XtSetArg(args[ac], XmNlabelString,  xmstr);        ac++;
		XtSetArg(args[ac], XmNmnemonic,     ' ');          ac++;
		cascadebutton[i] = XmCreateCascadeButton( minimenu, GRAPHIKPUSHBUTTON, args, ac);
		XtManageChild(cascadebutton[i]); 
		XtAddCallback(cascadebutton[i], XmNactivateCallback,
							(XtCallbackProc)xGRaction, (XtPointer)&actminicallback[i]);
		XmStringFree( xmstr);
	}
	/*---- Help right justified ---------*/
	ac = 0;
	XtSetArg(args[ac], XmNmenuHelpWidget, cascadebutton[XtNumber(actminicallback)-1]);  ac++;
	XtSetValues( minimenu, args, ac);   
	
	return( minimenu);
}
Ejemplo n.º 20
0
Widget 
XmCreateSimpleMenuBar(
        Widget parent,
        String name,
        ArgList args,
        Cardinal arg_count )
{
	Widget rc;
	XmSimpleMenuRec mr;
	_XmWidgetToAppContext(parent);

	_XmAppLock(app);

	XtGetSubresources(parent, &mr, name, XmCSimpleMenuBar,
		SimpleMenuResources, XtNumber(SimpleMenuResources), 
		args, arg_count);

	rc = XmCreateMenuBar(parent, name, args, arg_count);

	EvaluateConvenienceStructure( rc, &mr);

	_XmAppUnlock(app);
	return(rc);
}
Ejemplo n.º 21
0
Widget XmCreateMenuBar_TNK(Widget parent, String name, ArgList arglist,Cardinal argcount) { return XmCreateMenuBar(parent, name, arglist, argcount);}
Ejemplo n.º 22
0
int main(int argc, char **argv)
{
    XtAppContext AppCtx;
    Widget       TopLevel, Main, Menu, Form, Text, PullDownMenu;
    Widget       Cascade, Butt1, Butt3, Butt4, Butt5;
    Widget       Frame, Label, RowCol, w;
    Arg          args[10];
    
    TopLevel = XtVaAppInitialize(&AppCtx, "Demo", NULL, 0, 
                                 &argc, argv, Fallbacks, NULL);
    Main = XmCreateMainWindow(TopLevel, "main", NULL, 0);
    XtManageChild(Main);

    Menu = XmCreateMenuBar(Main, "menu", NULL, 0);
    XtManageChild(Menu);
    XtSetArg(args[0], XmNmnemonic, XK_F);
    Cascade = XmCreateCascadeButton(Menu, "File", args, 1);
    XtManageChild(Cascade);
    PullDownMenu = XmCreatePulldownMenu(Cascade, "filemenu", NULL, 0);

    w = XmCreateToggleButtonPlus(PullDownMenu, "Enjoy it!", NULL, 0);
    XtVaSetValues(w, XmNmnemonic, XK_j, NULL);
    XtManageChild(w);
    XtVaCreateManagedWidget(
        "sepp1", xmSeparatorWidgetClass, PullDownMenu,
        NULL);
    w = XmCreateToggleButtonPlus(PullDownMenu, "One", NULL, 0);
    XtVaSetValues(w, XmNmnemonic, XK_O, XmNindicatorType, XmONE_OF_MANY, NULL);
    XtManageChild(w);
    w = XmCreateToggleButtonPlus(PullDownMenu, "Two", NULL, 0);
    XtVaSetValues(w, XmNmnemonic, XK_T, XmNindicatorType, XmONE_OF_MANY, NULL);
    XtManageChild(w);
    w = XmCreateToggleButtonPlus(PullDownMenu, "Fourtytwo", NULL, 0);
    XtVaSetValues(w, XmNmnemonic, XK_F, XmNindicatorType, XmONE_OF_MANY, NULL);
    XtManageChild(w);
    XtVaCreateManagedWidget(
        "sepp2", xmSeparatorWidgetClass, PullDownMenu,
        NULL);
    Butt1 = XtVaCreateManagedWidget(
        "Exit", xmPushButtonWidgetClass, PullDownMenu,
        XmNmnemonic, XK_E,
        NULL);
    XtAddCallback(Butt1, XmNactivateCallback, 
                  (XtCallbackProc) DummyCallback, NULL);
    
    XtVaSetValues(Cascade, XmNsubMenuId, PullDownMenu, NULL);
    
    Form = XtVaCreateManagedWidget("form", xmFormWidgetClass, Main, NULL);
    Label = XtVaCreateManagedWidget(
        "XmN_OF_MANY", xmLabelWidgetClass, Form, 
	XmNleftAttachment,  XmATTACH_FORM, 
	XmNleftOffset,      24,
	XmNtopAttachment,   XmATTACH_FORM, 
	XmNtopOffset,       8, 
	NULL);
    Frame = XtVaCreateManagedWidget(
        "frame1", xmFrameWidgetClass, Form, 
	XmNleftAttachment,  XmATTACH_FORM, 
	XmNleftOffset,      20, 
	XmNtopAttachment,   XmATTACH_WIDGET, 
	XmNtopWidget,       Label, 
	XmNrightAttachment, XmATTACH_POSITION, 
	XmNrightPosition,   50,
	XmNrightOffset,     4,  
	NULL);
    RowCol = XtVaCreateManagedWidget(
	"RowCol", xmRowColumnWidgetClass, Frame, 
        NULL);

    Butt3 = XmCreateToggleButtonPlus(RowCol, "I like the OSF", NULL, 0);
    XtVaSetValues(Butt3, XmNsensitive, False, NULL);
    XtManageChild(Butt3);
    Butt4 = XmCreateToggleButtonPlus(RowCol, "Support Freeware!", NULL, 0);
    XtVaSetValues(Butt4, XmNset, True, NULL);
    XtManageChild(Butt4);
    Butt5 = XmCreateToggleButtonPlus(RowCol, "New Widgets", NULL, 0);
    XtManageChild(Butt5);

    Label = XtVaCreateManagedWidget(
        "XmONE_OF_MANY", xmLabelWidgetClass, Form, 
	XmNleftAttachment,  XmATTACH_POSITION, 
	XmNleftPosition,    50,
	XmNleftOffset,      4,
	XmNtopAttachment,   XmATTACH_FORM, 
	XmNtopOffset,       8, 
	NULL);
    Frame = XtVaCreateManagedWidget(
        "frame2", xmFrameWidgetClass, Form, 
	XmNleftAttachment,  XmATTACH_POSITION, 
	XmNleftPosition,    50,
	XmNleftOffset,      4, 
	XmNtopAttachment,   XmATTACH_WIDGET, 
	XmNtopWidget,       Label, 
	XmNrightAttachment, XmATTACH_FORM, 
	XmNrightOffset,     20,  
	NULL);
    RowCol = XtVaCreateManagedWidget(
	"RowCol", xmRowColumnWidgetClass, Frame, 
	XmNradioBehavior, True,
        XmNradioAlwaysOne,  True,
        NULL);

    Butt3 = XmCreateToggleButtonPlus(RowCol, "Athena", NULL, 0);
    XtVaSetValues(Butt3, XmNindicatorType, XmONE_OF_MANY, NULL);
    XtManageChild(Butt3);
    Butt4 = XmCreateToggleButtonPlus(RowCol, "OSF/Motif(=Hades)", NULL, 0);
    XtVaSetValues(Butt4, XmNindicatorType, XmONE_OF_MANY, NULL);
    XtManageChild(Butt4);
    Butt5 = XmCreateToggleButtonPlus(RowCol, "Harry's Motif Widgets", NULL, 0);
    XtVaSetValues(Butt5, XmNindicatorType, XmONE_OF_MANY, 
                         XmNset, True, NULL);
    XtManageChild(Butt5);

/*    Label = XtVaCreateManagedWidget(
	"XmNtriState = True", 
	xmLabelWidgetClass, Form, 
	XmNleftAttachment,   XmATTACH_FORM, 
	XmNleftOffset,	     20, 
	XmNtopAttachment,    XmATTACH_WIDGET, 
	XmNtopWidget,        Frame, 
	XmNtopOffset,        8, 
	NULL);

    Frame = XtVaCreateManagedWidget(
        "frame3", xmFrameWidgetClass, Form, 
	XmNleftAttachment,  XmATTACH_FORM, 
	XmNleftOffset,      20, 
	XmNtopAttachment,   XmATTACH_WIDGET, 
	XmNtopWidget,       Label, 
	XmNrightAttachment, XmATTACH_FORM, 
	XmNrightOffset,     20,  
	NULL);

    RowCol = XtVaCreateManagedWidget(
	"RowCol", xmRowColumnWidgetClass, Frame, 
        NULL);
    Butt3 = XtVaCreateManagedWidget(
	"Click on me several times.", xmToggleButtonWidgetClass, RowCol,
        XmNtriState, True,
        XmNset, XmTOGGLE_DONTKNOW, 
	NULL);
*/	
    Text = XtVaCreateManagedWidget(
	"The new xmToggleButtonWidgetClass", 
	xmLabelWidgetClass, Form, 
	XmNleftAttachment,   XmATTACH_FORM, 
	XmNleftOffset,	     20, 
	XmNrightAttachment,  XmATTACH_FORM, 
	XmNrightOffset,	     20, 
	XmNtopAttachment,    XmATTACH_WIDGET, 
	XmNtopWidget,        Frame, 
	XmNtopOffset,        20, 
	XmNbottomAttachment, XmATTACH_FORM, 
	XmNbottomOffset,     20, 
	NULL);

    XmMainWindowSetAreas(Main, Menu, NULL, NULL, NULL, Form);
    XtRealizeWidget(TopLevel);
    
{
    static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,    0,    0,  370,  204, 0,0,0, /* main */
   CWWidth | CWHeight | CWX | CWY,    0,    0,  370,   31, 0,0,0, /* menu */
   CWWidth | CWHeight | CWX | CWY,    5,    5,   40,   21, 0,0,0, /* File */
   CWWidth | CWHeight | CWX | CWY,    0,   31,  370,  173, 0,0,0, /* form */
   CWWidth | CWHeight | CWX | CWY,   24,    8,   70,   17, 0,0,0, /* XmN_OF_MANY */
   CWWidth | CWHeight | CWX | CWY,   20,   25,  161,   91, 0,0,0, /* frame1 */
   CWWidth | CWHeight | CWX | CWY,    2,    2,  157,   87, 0,0,0, /* RowCol */
   CWWidth | CWHeight | CWX | CWY,    3,    3,  151,   25, 0,0,0, /* I like the OSF */
   CWWidth | CWHeight | CWX | CWY,    3,   31,  151,   25, 0,0,0, /* Support Freeware! */
   CWWidth | CWHeight | CWX | CWY,    3,   59,  151,   25, 0,0,0, /* New Widgets */
   CWWidth | CWHeight | CWX | CWY,  189,    8,   82,   17, 0,0,0, /* XmONE_OF_MANY */
   CWWidth | CWHeight | CWX | CWY,  189,   25,  161,   91, 0,0,0, /* frame2 */
   CWWidth | CWHeight | CWX | CWY,    2,    2,  157,   87, 0,0,0, /* RowCol */
   CWWidth | CWHeight | CWX | CWY,    3,    3,  151,   25, 0,0,0, /* Athena */
   CWWidth | CWHeight | CWX | CWY,    3,   31,  151,   25, 0,0,0, /* OSF/Motif(=Hades) */
   CWWidth | CWHeight | CWX | CWY,    3,   59,  151,   25, 0,0,0, /* Harry's Motif Widgets */
   CWWidth | CWHeight | CWX | CWY,   20,  136,  330,   17, 0,0,0, /* The new xmToggleButtonWidgetClass */
};
    PrintDetails(    TopLevel ,Expected);
};
   LessTifTestMainLoop(    TopLevel );
    return 0;   
} /* main */
Ejemplo n.º 23
0
Archivo: textfun.c Proyecto: yhsesq/yhs
void
main(int argc, char *argv[])
{
    int             i;
#ifdef IRIX_5_1_MOTIF_BUG_WORKAROUND
    /*
     * XXX Unfortunately a bug in the IRIX 5.1 Motif shared library
     * causes a BadMatch X protocol error if the SGI look&feel
     * is enabled for this program.  If we detect we are on an
     * IRIX 5.1 system, skip the first two fallback resources which
     * specify using the SGI look&feel.
     */
    struct utsname versionInfo;

    if(uname(&versionInfo) >= 0) {
        if(!strcmp(versionInfo.sysname, "IRIX") &&
	   !strncmp(versionInfo.release, "5.1", 3)) {
    	    toplevel = XtAppInitialize(&app, "Textfun", NULL, 0, &argc, argv,
				       &fallbackResources[2], NULL, 0);
        }
    }
    if(toplevel == NULL) {
        toplevel = XtAppInitialize(&app, "Textfun", NULL, 0, &argc, argv,
			           fallbackResources, NULL, 0);
    }
#else
    toplevel = XtAppInitialize(&app, "Textfun", NULL, 0, &argc, argv,
			       fallbackResources, NULL, 0);
#endif
    dpy = XtDisplay(toplevel);
    /* find an OpenGL-capable RGB visual with depth buffer */
    vi = glXChooseVisual(dpy, DefaultScreen(dpy), dblBuf);
    if (vi == NULL) {
	vi = glXChooseVisual(dpy, DefaultScreen(dpy), snglBuf);
	if (vi == NULL)
	    XtAppError(app, "no RGB visual with depth buffer");
	doubleBuffer = GL_FALSE;
    }
    for (i = 0; i < NUM_FONT_ENTRIES; i++) {
	fontEntry[i].xfont = XLoadQueryFont(dpy, fontEntry[i].xlfd);
	if (i == 0 && !fontEntry[i].xfont)
	    XtAppError(app, "could not get basic font");
    }

    fontEntry[0].fontinfo = SuckGlyphsFromServer(dpy, fontEntry[0].xfont->fid);
    if (!fontEntry[0].fontinfo)
	XtAppError(app, "could not get font glyphs");

    /* create an OpenGL rendering context */
    cx = glXCreateContext(dpy, vi, /* no display list sharing */ None,
			   /* favor direct */ GL_TRUE);
    if (cx == NULL)
	XtAppError(app, "could not create rendering context");

    /* create an X colormap since probably not using default visual */
    cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen),
			   vi->visual, AllocNone);
    XtVaSetValues(toplevel, XtNvisual, vi->visual, XtNdepth, vi->depth,
		  XtNcolormap, cmap, NULL);
    XtAddEventHandler(toplevel, StructureNotifyMask, False,
		      map_state_changed, NULL);
    mainw = XmCreateMainWindow(toplevel, "mainw", NULL, 0);
    XtManageChild(mainw);

    /* create menu bar */
    menubar = XmCreateMenuBar(mainw, "menubar", NULL, 0);
    XtManageChild(menubar);
    /* hack around Xt's ignorance of visuals */
    XtSetArg(menuPaneArgs[0], XmNdepth, DefaultDepthOfScreen(XtScreen(mainw)));
    XtSetArg(menuPaneArgs[1],
	     XmNcolormap, DefaultColormapOfScreen(XtScreen(mainw)));

    /* create File pulldown menu: Quit */
    menupane = XmCreatePulldownMenu(menubar, "menupane", menuPaneArgs, 2);
    btn = XmCreatePushButton(menupane, "Quit", NULL, 0);
    XtAddCallback(btn, XmNactivateCallback, quit, NULL);
    XtManageChild(btn);
    XtSetArg(args[0], XmNsubMenuId, menupane);
    cascade = XmCreateCascadeButton(menubar, "File", args, 1);
    XtManageChild(cascade);

    /* create Options pulldown menu: Motion, Dolly, Rotate, Wobble */
    menupane = XmCreatePulldownMenu(menubar, "menupane", menuPaneArgs, 2);
    btn = XmCreateToggleButton(menupane, "Motion", NULL, 0);
    XtAddCallback(btn, XmNvalueChangedCallback, (XtCallbackProc) toggle, NULL);
    XtManageChild(btn);
    btn = XmCreateToggleButton(menupane, "Dolly", NULL, 0);
    XtAddCallback(btn, XmNvalueChangedCallback, (XtCallbackProc) dolly, NULL);
    XtVaSetValues(btn, XmNset, True, NULL);
    XtManageChild(btn);
    btn = XmCreateToggleButton(menupane, "Rotate", NULL, 0);
    XtAddCallback(btn, XmNvalueChangedCallback, (XtCallbackProc) rotate, NULL);
    XtManageChild(btn);
    btn = XmCreateToggleButton(menupane, "Wobble", NULL, 0);
    XtAddCallback(btn, XmNvalueChangedCallback, (XtCallbackProc) wobble, NULL);
    XtManageChild(btn);
    XtSetArg(args[0], XmNsubMenuId, menupane);
    cascade = XmCreateCascadeButton(menubar, "Options", args, 1);
    XtManageChild(cascade);

    XtSetArg(menuPaneArgs[2], XmNradioBehavior, True);
    XtSetArg(menuPaneArgs[3], XmNradioAlwaysOne, True);
    menupane = XmCreatePulldownMenu(menubar, "menupane", menuPaneArgs, 4);
    XtAddCallback(menupane, XmNentryCallback, (XtCallbackProc) fontSelect, NULL);
    for (i = 0; i < NUM_FONT_ENTRIES; i++) {
	btn = XmCreateToggleButton(menupane, fontEntry[i].name, NULL, 0);
	XtAddCallback(btn, XmNvalueChangedCallback, (XtCallbackProc) neverCalled, &fontEntry[i]);
	if (i == 0)
	    XtVaSetValues(btn, XmNset, True, NULL);
        if (!fontEntry[i].xfont)
	    XtSetSensitive(btn, False);
	XtManageChild(btn);
    }
    XtSetArg(args[0], XmNsubMenuId, menupane);
    cascade = XmCreateCascadeButton(menubar, "Font", args, 1);
    XtManageChild(cascade);

    /* create framed drawing area for OpenGL rendering */
    frame = XmCreateFrame(mainw, "frame", NULL, 0);
    XtManageChild(frame);
    glxarea = XtCreateManagedWidget("glxarea", xmDrawingAreaWidgetClass,
				    frame, NULL, 0);
    XtAddCallback(glxarea, XmNexposeCallback, (XtCallbackProc) draw, NULL);
    XtAddCallback(glxarea, XmNresizeCallback, resize, NULL);
    XtAddCallback(glxarea, XmNinputCallback, input, NULL);
    /* set up application's window layout */
    XmMainWindowSetAreas(mainw, menubar, NULL, NULL, NULL, frame);
    XtRealizeWidget(toplevel);

    /*
     * Once widget is realized (ie, associated with a created X window), we
     * can bind the OpenGL rendering context to the window.
     */
    glXMakeCurrent(dpy, XtWindow(glxarea), cx);
    made_current = GL_TRUE;
    /* setup OpenGL state */
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);
    glClearDepth(1.0);
    glMatrixMode(GL_PROJECTION);
    glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 80);
    glMatrixMode(GL_MODELVIEW);

    MakeCube();

    if (argv[1] != NULL) {
	numMessages = argc - 1;
	messages = &argv[1];
    } else {
	numMessages = NUM_DEFAULT_MESSAGES;
	messages = defaultMessage;
    }

    base = glGenLists(numMessages + 1);
    SetupMessageDisplayList(&fontEntry[0], numMessages, messages);

    tick();

    /* start event processing */
    XtAppMainLoop(app);
}
Ejemplo n.º 24
0
int
main(int argc, char *argv[])
{
    XtAppContext app;
    Widget toplevel, main_w, menubar, cb1, cb2, cb3, pb1, pane1, pane2,
	drawing_a;

    XtSetLanguageProc (NULL, NULL, NULL);

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

    /* Create a MainWindow widget that contains a DrawingArea in
     * its work window. 
     */

    main_w = XtVaCreateManagedWidget ("main_w",
        xmMainWindowWidgetClass, toplevel,
        XmNscrollingPolicy,  XmAUTOMATIC,
        NULL);
    menubar = XmCreateMenuBar (main_w, "menubar", NULL, 0);

    pane1 = XmCreatePulldownMenu (menubar, "pane1", NULL, 0);
    pane2 = XmCreatePulldownMenu (pane1, "pane2", NULL, 0);

    cb1 = XtVaCreateManagedWidget ("cb1",
        xmCascadeButtonGadgetClass, menubar,
        XmNsubMenuId,   pane1,
        NULL);

    cb2 = XtVaCreateManagedWidget ("cb2",
        xmCascadeButtonGadgetClass, pane1,
        XmNsubMenuId,   pane2,
        NULL);

    cb3 = XtVaCreateManagedWidget ("cb3",
        xmCascadeButtonWidgetClass, pane1,
        XmNsubMenuId,   pane2,
        NULL);

    XtAddCallback(cb2, XmNactivateCallback, PrintDimensions, NULL);
    XtAddCallback(cb2, XmNcascadingCallback, PrintDimensions, NULL);


    pb1 = XtVaCreateManagedWidget ("pb1",
        xmPushButtonGadgetClass, pane2,
        NULL);

    XtManageChild (menubar);

    /* Create a DrawingArea -- no actual drawing will be done. */
    drawing_a = XtVaCreateManagedWidget ("drawing_a",
        xmDrawingAreaWidgetClass, main_w,
        XmNwidth, 500,
        XmNheight,500,
        NULL);

    XtRealizeWidget (toplevel);
    

/* Note: the following values are the result of
 * querying the current geometry.
 */
{
static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,  218,  358,  131,  162, 0,0,0, /* main_w */
   CWWidth | CWHeight | CWX | CWY,    4,   35,  100,  100, 0,0,0, /* ClipWindow */
   CWWidth | CWHeight | CWX | CWY,    0,    0,  500,  500, 0,0,0, /* drawing_a */
   CWWidth | CWHeight | CWX | CWY,  112,   31,   19,  108, 0,0,0, /* VertScrollBar */
   CWWidth | CWHeight | CWX | CWY,    0,  143,  108,   19, 0,0,0, /* HorScrollBar */
   CWWidth | CWHeight | CWX | CWY,    0,    0,  131,   31, 0,0,0, /* menubar */
   CWWidth | CWHeight | CWX | CWY,    5,    5,   40,   21, 0,0,0, /* cb1 */
};
/* toplevel should be replaced with to correct applicationShell */
PrintDetails(toplevel, Expected);
}
LessTifTestMainLoop(toplevel);
LessTifTestMainLoop(toplevel);

exit(0);
}
Ejemplo n.º 25
0
/**************************************************************
 * DaCreateGui:
 **************************************************************/
Widget DaCreateGui(char    * name,
		   char    * aclass,
		   int       argc,
		   char   ** argv,
		   Display * display)
{
  Arg args[15];
  Widget widget_array[10];
  int n;

  /***************** object of type : ApplicationShell *****************/
  n = 0;
  /* Setup argc & argv attribute */
  XtSetArg(args[n], XtNargc, argc); n++;
  XtSetArg(args[n], XtNargv, argv); n++;

  widget_array[WI_DAINPUT] = 
    XtAppCreateShell(name, aclass, applicationShellWidgetClass,
		     display, args, n);

  /***************** mainWindow : XmMainWindow *****************/
  widget_array[WI_MAINWINDOW] =
    XmCreateMainWindow(widget_array[WI_DAINPUT], "mainWindow", NULL, 0);

  /***************** menuBar : XmMenuBar *****************/
  widget_array[WI_MENUBAR] =
    XmCreateMenuBar(widget_array[WI_MAINWINDOW], "menuBar", NULL, 0);

  /***************** File : XmCascadeButton *****************/
  widget_array[WI_FILE] =
    XmCreateCascadeButton(widget_array[WI_MENUBAR], "File", NULL, 0);

  /***************** fileMenu : XmPulldownMenu *****************/
  widget_array[WI_FILEMENU] =
    XmCreatePulldownMenu(widget_array[WI_MENUBAR], "fileMenu", NULL, 0);
  {
    Arg args[1];
    XtSetArg(args[0], XmNsubMenuId, widget_array[WI_FILEMENU]);
    XtSetValues(widget_array[WI_FILE], args, 1);
  }

  /***************** Exit : XmPushButton *****************/
  widget_array[WI_EXIT] =
    XmCreatePushButton(widget_array[WI_FILEMENU], "Exit", NULL, 0);

  XtAddCallback(widget_array[WI_EXIT], 
		XmNactivateCallback, DaExit, NULL);

  /***************** Help : XmCascadeButton *****************/
  widget_array[WI_HELP] =
    XmCreateCascadeButton(widget_array[WI_MENUBAR], "Help", NULL, 0);

  /***************** helpMenu : XmPulldownMenu *****************/
  widget_array[WI_HELPMENU] =
    XmCreatePulldownMenu(widget_array[WI_MENUBAR], "helpMenu", NULL, 0);
  {
    Arg args[1];
    XtSetArg(args[0], XmNsubMenuId, widget_array[WI_HELPMENU]);
    XtSetValues(widget_array[WI_HELP], args, 1);
  }

  /***************** Overview : XmPushButton *****************/
  widget_array[WI_OVERVIEW] =
    XmCreatePushButton(widget_array[WI_HELPMENU], "Overview", NULL, 0);

  XtAddCallback(widget_array[WI_OVERVIEW], 
		XmNactivateCallback, DaOverView, NULL);

  /***************** workArea : XmDrawingArea *****************/
  n = 0;
  XtSetArg(args[n], XmNwidth, 300); n++;
  XtSetArg(args[n], XmNheight, 35); n++;
  widget_array[WI_WORKAREA] =
    XmCreateDrawingArea(widget_array[WI_MAINWINDOW], "workArea", args, n);

  /* 
   * Register drawing area for input method support and set input 
   * context values.
   */
  XmImRegister(widget_array[WI_WORKAREA], 0);
  {
    Pixel bg, fg;
    Pixmap bg_pixmap;
    n = 0;
    XtSetArg(args[n], XmNbackground, &bg); n++;
    XtSetArg(args[n], XmNforeground, &fg); n++;
    XtSetArg(args[n], XmNbackgroundPixmap, &bg_pixmap);n++;
    XtGetValues(widget_array[WI_WORKAREA], args, n);
    n = 0;
    XtSetArg(args[n], XmNbackground, bg); n++;
    XtSetArg(args[n], XmNforeground, fg); n++;
    XtSetArg(args[n], XmNbackgroundPixmap, bg_pixmap);n++;
    XmImSetValues(widget_array[WI_WORKAREA], args, n);
  }

  /* 
   * Add event handler for focus events. This is needed for the
   * input method to correctly display the input area.
   */
  XtAddEventHandler(widget_array[WI_WORKAREA], 
		    EnterWindowMask|LeaveWindowMask|FocusChangeMask, 
		    False, DaFocusHandler, NULL);

  XtAddCallback(widget_array[WI_WORKAREA],
		XmNexposeCallback, DaRedrawText, NULL);

  XtAddCallback(widget_array[WI_WORKAREA],
		XmNinputCallback, DaInputText, NULL);

  XtAddCallback(widget_array[WI_WORKAREA],
		XmNresizeCallback, DaResizedText, NULL);


  /***************** menuBar : XmMenuBar *****************/
  n = 0;
  XtSetArg(args[n], XmNmenuHelpWidget, widget_array[WI_HELP]); n++;
  XtSetValues(widget_array[WI_MENUBAR], args, n);


  XtManageChild(widget_array[WI_EXIT]);
  XtManageChild(widget_array[WI_FILE]);
  XtManageChild(widget_array[WI_OVERVIEW]);
  XtManageChild(widget_array[WI_HELP]);
  XtManageChild(widget_array[WI_MENUBAR]);
  XtManageChild(widget_array[WI_WORKAREA]);
  XtManageChild(widget_array[WI_MAINWINDOW]);

  /*
   *   Return the first created widget.
   */
  return widget_array[WI_DAINPUT];
}
Ejemplo n.º 26
0
int
main(int argc, char **argv)
{
    XtAppContext theApp;
    Widget shell, toplevel, menubar, filepane;
    Widget button, button1, button2, sep;
    Widget saveAsPane, button3, button4, button5;
    Widget button6, button7, editpane;
    Widget one, two, three;
    Widget mb;
    XmString xmstr;

    shell = XtVaAppInitialize(&theApp, "mainW", NULL, 0,
				 &argc, argv, NULL, NULL);

    toplevel = XmCreateMainWindow(shell, "MainWindow", NULL, 0);
    XtManageChild(toplevel);

    menubar = XmCreateMenuBar(toplevel,
			      "menuBar",
			      NULL,0);
    XtManageChild(menubar);

    filepane = XmCreatePulldownMenu(menubar,
				    "pane",
				    NULL,0);
    xmstr = XmStringCreateSimple("File");
    
    button = XtVaCreateManagedWidget("File",
				     xmCascadeButtonWidgetClass,
				     menubar,
				     XmNsubMenuId, filepane,
                                     XmNlabelString, xmstr,
				     NULL);

    editpane = XmCreatePulldownMenu(menubar,
				    "pane2",
				    NULL, 0);

    button6 = XtVaCreateManagedWidget("Edit",
				      xmCascadeButtonGadgetClass,
				      menubar,
				      XmNsubMenuId, editpane,
				      NULL);

    button7 = XtVaCreateManagedWidget("Cut",
				      xmPushButtonGadgetClass,
				      editpane,
				      NULL);

    button1 = XtVaCreateManagedWidget("Open",
				      xmPushButtonGadgetClass,
				      filepane,
				      NULL);

    sep = XtVaCreateManagedWidget("sep",
				  xmSeparatorGadgetClass,
                                  filepane,
                                  NULL);

    button2 = XtVaCreateManagedWidget("Close",
				      xmPushButtonWidgetClass,
				      filepane,
				      NULL);

    saveAsPane = XmCreatePulldownMenu(filepane,
				      "save_as",
				      NULL, 0);

    button3 = XtVaCreateManagedWidget("Save As",
				      xmCascadeButtonWidgetClass,
				      filepane,
				      XmNsubMenuId, saveAsPane,
				      NULL);

    button4 = XtVaCreateManagedWidget("MS Word",
				      xmPushButtonWidgetClass,
				      saveAsPane,
				      NULL);

    button5 = XtVaCreateManagedWidget("LaTeX",
				      xmPushButtonWidgetClass,
				      saveAsPane,
				      NULL);

    mb = XtVaCreateManagedWidget("mb", xmMessageBoxWidgetClass, toplevel, NULL);
    XtVaSetValues(toplevel, XmNmessageWindow, mb, NULL);

    one = XtVaCreateManagedWidget("form", xmFormWidgetClass, toplevel,
				  NULL);

    two = XtVaCreateManagedWidget("two", xmPushButtonWidgetClass, one,
				  XmNtopAttachment, XmATTACH_FORM,
				  XmNbottomAttachment, XmATTACH_FORM,
				  XmNleftAttachment, XmATTACH_NONE,
				  XmNrightAttachment, XmATTACH_FORM,
				  NULL);

    three = XtVaCreateManagedWidget("three", xmPushButtonWidgetClass, one,
				    XmNtopAttachment, XmATTACH_FORM,
				    XmNbottomAttachment, XmATTACH_FORM,
				    XmNleftAttachment, XmATTACH_FORM,
				    XmNrightAttachment, XmATTACH_WIDGET,
				    XmNrightWidget, two,
				    NULL);

    XmMainWindowSetAreas(toplevel, menubar, NULL, NULL, NULL, one);

    XtRealizeWidget(shell);

{
static XtWidgetGeometry Expected[] = {
   CWWidth | CWHeight            ,   56,   72,  212,  143, 0,0,0, /* MainWindow */
   CWWidth | CWHeight | CWX | CWY,    0,    0,  212,   31, 0,0,0, /* menuBar */
   CWWidth | CWHeight | CWX | CWY,    5,    5,   40,   21, 0,0,0, /* File */
   CWWidth | CWHeight | CWX | CWY,   45,    5,   40,   21, 0,0,0, /* Edit */
   CWWidth | CWHeight | CWX | CWY,    0,   56,  212,   87, 0,0,0, /* mb */
   CWWidth | CWHeight | CWX | CWY,    0,    0,    4,    4, 0,0,0, /* Symbol */
   CWWidth | CWHeight | CWX | CWY,   10,   10,  192,    4, 0,0,0, /* Message */
   CWWidth | CWHeight | CWX | CWY,    0,   24,  212,    2, 0,0,0, /* Separator */
   CWWidth | CWHeight | CWX | CWY,   10,   36,   64,   41, 0,0,0, /* OK */
   CWWidth | CWHeight | CWX | CWY,   74,   36,   64,   41, 0,0,0, /* Cancel */
   CWWidth | CWHeight | CWX | CWY,  138,   36,   64,   41, 0,0,0, /* Help */
   CWWidth | CWHeight | CWX | CWY,    0,   31,  212,   25, 0,0,0, /* form */
   CWWidth | CWHeight | CWX | CWY,  182,    0,   30,   25, 0,0,0, /* two */
   CWWidth | CWHeight | CWX | CWY,    0,    0,  182,   25, 0,0,0, /* three */
};
/* toplevel should be replaced with to correct applicationShell */
PrintDetails(toplevel, Expected);
}
  LessTifTestMainLoop(shell);

    exit(0);
}
Ejemplo n.º 27
0
Archivo: ssX.c Proyecto: q3k/ski
void scrnInitX(void)
{
    Widget toplevel, control;
    Widget mb, fileMenu, viewMenu, confMenu, helpMenu;
    Widget procFrame = NULL, bboxFrame = NULL;
#ifdef ICON_DEFINED
    Pixmap icon;
#endif
    XmString s;
    Arg args[10];
    unsigned i, n;
    int argc = 0;

    addRegwRsrcOpts();
    addDatwRsrcOpts();
    toplevel = XtAppInitialize(&app_context, "XSki",
			       options, topopts, &argc, NULL,
			       NULL, NULL, 0);
    top_level = toplevel;	/* XXX - temporary for Platform only */
    XtGetApplicationResources(toplevel, &app_data,
			      resources, toprsrc, NULL, 0);
    XtAppAddActions(app_context, actions, XtNumber(actions));
    dpy = XtDisplay(toplevel);

#ifdef ICON_DEFINED
    /* set default icon */
    icon = XCreateBitmapFromData(dpy, RootWindowOfScreen(XtScreen(toplevel)),
				 icon_bits, icon_width, icon_height);
    XtSetArg(args[0], XmNiconPixmap, icon);
    XtSetValues(toplevel, args, 1);
#endif

#if 0
    XSynchronize(dpy, True);
#endif

    /* create control window manager */
    control = XmCreateForm(toplevel, "control", NULL, 0);
    XtManageChild(control);

    /* Control window menubar */
    n = 0;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM);		n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM);	n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM);	n++;
    mb = XmCreateMenuBar(control, "mb", args, n);
    XtManageChild(mb);
    fileMenu = createMBitem(mb, "File");
    viewMenu = createMBitem(mb, "View");
    confMenu = createMBitem(mb, "Configure");
    helpMenu = createMBitem(mb, "Help");

#if 0
    createSubmenuItem(fileMenu, "load", loadCallback);
#else
    createSubmenuItem(fileMenu, "load", 0);
#endif
    createSubmenuItem(fileMenu, "save", 0);
    createSubmenuItem(fileMenu, "trace", 0);
    createSubmenuItem(fileMenu, "traceOn", 0);
    createSubmenuItem(fileMenu, "traceOff", 0);
    createSubmenuItem(fileMenu, "read", 0);
    XtManageChild(XmCreateSeparatorGadget(fileMenu, "", NULL, 0));
    createSubmenuItem(fileMenu, "quit", simCmdCallback);

    createSubmenuItem(viewMenu, "program", programCallback);
    createSubmenuItem(viewMenu, "data", dataCallback);
    createSubmenuItem(viewMenu, "registers", regCallback);
    createSubmenuItem(viewMenu, "cache", 0);
    createSubmenuItem(viewMenu, "tlb", sdtCallback);
    XtManageChild(XmCreateSeparatorGadget(viewMenu, "", NULL, 0));
    createSubmenuItem(viewMenu, "callstack", cstCallback);
    createSubmenuItem(viewMenu, "statistics", 0);
    createSubmenuItem(viewMenu, "breakpoints", blistCallback);
    createSubmenuItem(viewMenu, "branches", 0);
    createSubmenuItem(viewMenu, "symbols", symlistCallback);
    createSubmenuItem(viewMenu, "macros", 0);

#if 0
/* No support for window format yet */
    createSubmenuItem(confMenu, "program", prgFmtCallback);
#else
    createSubmenuItem(confMenu, "program", 0);
#endif

    createSubmenuItem(confMenu, "data", 0);

#if 0
/* No support for window format yet */
    createSubmenuItem(confMenu, "registers", regFmtCallback);
#else
    createSubmenuItem(confMenu, "registers", 0);
#endif

    createSubmenuItem(helpMenu, "context", 0);
    createSubmenuItem(helpMenu, "overview", 0);
    createSubmenuItem(helpMenu, "commands", cmdHelpCallback);
    createSubmenuItem(helpMenu, "product", prodInfoCallback);

    /* Control window processor option menu */
    if (nproc > 1) {
	Widget procMenu, proc[NPROC];

	n = 0;
	XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET);	n++;
	XtSetArg(args[n], XmNtopWidget, mb);			n++;
	XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM);	n++;
	XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM);	n++;
	procFrame = XmCreateFrame(control, "", args, n);
	XtManageChild(procFrame);

	procMenu = XmCreatePulldownMenu(procFrame, "", NULL, 0);
	for (i = 0; i < nproc; i++) {
	    char name[4];

	    (void)sprintf(name, "p%d", i);
	    proc[i] = XmCreatePushButton(procMenu, name, NULL, 0);
	    XtAddCallback(proc[i], XmNactivateCallback,
			  changeCprocCallback, (XtPointer)i);
	}
	XtManageChildren(proc, nproc);
	n = 0;
	XtSetArg(args[n], XmNsubMenuId, procMenu);		n++;
	XtManageChild(XmCreateOptionMenu(procFrame, "procOption", args, n));
    }

    /* Control window button box */
    if (app_data.numButtons) {
	Widget bbox, btns[20];

	/* create button box manager */
	n = 0;
	XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET);		n++;
	XtSetArg(args[n], XmNtopWidget, procFrame ? procFrame : mb);	n++;
	XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM);		n++;
	XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM);		n++;
	bboxFrame = XmCreateFrame(control, "", args, n);
	XtManageChild(bboxFrame);

	/* create button box window */
	bbox = XmCreateRowColumn(bboxFrame, "bbox", NULL, 0);
	XtManageChild(bbox);
	/* create each button */
	for (i = 0; i < app_data.numButtons; i++) {
	    char name[8];

	    (void)sprintf(name, "bb%d", i);
	    btns[i] = XmCreatePushButton(bbox, name, NULL, 0);
	}
	XtManageChildren(btns, app_data.numButtons);
    }

    /* Control window command area */
    n = 0;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET);		n++;
    XtSetArg(args[n], XmNtopWidget,
	     bboxFrame ? bboxFrame : procFrame ? procFrame : mb);	n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM);		n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM);		n++;
    cmd = XmCreateCommand(control, "cmd", args, n);
    XtManageChild(cmd);
    XtAddCallback(cmd, XmNcommandEnteredCallback, simCmdCallback, 0);

    /* command history box */
    n = 0;
    XtSetArg(args[0], XmNinitialFocus, cmd);	n++;
    XtSetValues(control, args, n);
    cmdHist = XmCommandGetChild(cmd, XmDIALOG_HISTORY_LIST);

    /* message window */
    msgs = XmCreateScrolledText(control, "msgs", NULL, 0);
    XtManageChild(msgs);
    n = 0;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET);		n++;
    XtSetArg(args[n], XmNtopWidget, cmd);				n++;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM);		n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM);		n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM);		n++;
    XtSetValues(XtParent(msgs), args, n);

    /* create stop simulation dialog */
	/* Consider changing this to a button.  This would allow other
	   functionality to still be active when simulation is going on.
	   For example, Help, Quit, opening and closing windows, etc. */
    stopsim = XmCreateWorkingDialog(control, "stopsim", NULL, 0);
    n = 0;
    XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL);	n++;
    s = XmStringCreateLocalized("Running...");
    XtSetArg(args[n], XmNdialogTitle, s);				n++;
    s = XmStringCreateLocalized(" icnt: 0 ");
    XtSetArg(args[n], XmNmessageString, s);				n++;
    s = XmStringCreateLocalized("Stop");
    XtSetArg(args[n], XmNcancelLabelString, s);				n++;
    XtSetValues(stopsim, args, n);
    XtAddCallback(stopsim, XmNcancelCallback, stop_execLoopXCB, NULL);
    XtUnmanageChild(XmMessageBoxGetChild(stopsim, XmDIALOG_OK_BUTTON));
    XtUnmanageChild(XmMessageBoxGetChild(stopsim, XmDIALOG_HELP_BUTTON));
    XmStringFree(s);

    /* XXX - This should probably be inside regwInit */
    for (i = 0; i < topregw; i++)
	regwtbl[i].show = app_data.showRs[i];

    /* XXX - This should probably be inside datwInit */
    for (i = 0; i < topdatw; i++)
	datwtbl[i].show = app_data.viewDw[i];

    prgwInit();
    datwInit();
    regwInit();
    if (app_data.viewProg)
	prgwDrawX();
    datwDrawX();
    if (app_data.viewRegs)
	regwDrawX();

    noscreen = NO;
    XtRealizeWidget(toplevel);
}
Ejemplo n.º 28
0
void 
  create_appShell (Display *display, char *app_name, int app_argc, char **app_argv)
{
	Widget children[12];      /* Children to manage */
	Arg al[64];           /* Arg List */
	register int ac = 0;      /* Arg Count */
	char from_s [256];    /* For font list conversion */
	XrmValue from_value, to_value; /* ditto */
	int fg, bg;           /* colour values for pixmaps */ 
	XmString *list_items; /* For list items */
	int list_item;        /* Index for list_items */
	XmString xmstrings[15];    /* temporary storage for XmStrings */
	Widget widget1 = (Widget)NULL;
	Widget widget2 = (Widget)NULL;
	Widget widget3 = (Widget)NULL;
	Widget widget7 = (Widget)NULL;
	Widget widget8 = (Widget)NULL;
	Widget widget9 = (Widget)NULL;
	Widget widget10 = (Widget)NULL;
	Widget widget11 = (Widget)NULL;
	Widget widget12 = (Widget)NULL;
	Widget generateButton = (Widget)NULL;
	Widget deleteButton = (Widget)NULL;
	Widget browseButton = (Widget)NULL;
	Widget widget13 = (Widget)NULL;
	Widget widget14 = (Widget)NULL;
	Widget widget15 = (Widget)NULL;
	Widget widget16 = (Widget)NULL;
	Widget widget17 = (Widget)NULL;
	Widget nameLabel = (Widget)NULL;
	Widget textLabel = (Widget)NULL;
	Widget severityLabel = (Widget)NULL;
	Widget widget25 = (Widget)NULL;
	Widget widget27 = (Widget)NULL;
	Widget widget28 = (Widget)NULL;
	Widget widget29 = (Widget)NULL;
	Widget widget30 = (Widget)NULL;
	Widget widget31 = (Widget)NULL;
	Widget widget32 = (Widget)NULL;
	Widget widget33 = (Widget)NULL;
	Widget moduleLabel = (Widget)NULL;
	Widget widget37 = (Widget)NULL;
	Widget *modbutton;	/* replaces 38-49 */
	Widget categoryLabel = (Widget)NULL;
	Widget descriptionLabel = (Widget)NULL;
	Widget toolMenu = (Widget)NULL;
	Widget toolCascade = (Widget)NULL;
	Widget lockMenu = (Widget)NULL;
	Widget lockCascade = (Widget)NULL;
	Widget unlockButton = (Widget)NULL;
	Widget lockButton = (Widget)NULL;
	int imod;
	XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;
	XtSetArg(al[ac], XmNargc, app_argc); ac++;
	XtSetArg(al[ac], XmNargv, app_argv); ac++;
	appShell = XtAppCreateShell ( app_name, "EditMessage", applicationShellWidgetClass, display, al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNscrollingPolicy, XmAUTOMATIC); ac++;
	widget1 = XmCreateMainWindow ( appShell, "mainWindow", al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNhorizontalScrollBar, &widget2 ); ac++;
	XtSetArg(al[ac], XmNverticalScrollBar, &widget3 ); ac++;
	XtGetValues(widget1, al, ac );
	ac = 0;
	widget7 = XmCreateMenuBar ( widget1, "widget7", al, ac );
	widget9 = XmCreatePulldownMenu ( widget7, "fileMenu", al, ac );
	/*
	XtAddCallback(widget9, XmNunmapCallback, grab_input, NULL);
	*/
	widget10 = XmCreatePushButton ( widget9, "openButton", al, ac );
	widget11 = XmCreatePushButton ( widget9, "newButton", al, ac );
	ac = 0; XtSetArg(al[ac], XmNsensitive, False); ac++;
	widget12 = XmCreatePushButton ( widget9, "saveButton", al, ac );
	ac = 0; XtSetArg(al[ac], XmNsensitive, False); ac++;
	deleteButton = XmCreatePushButton ( widget9, "deleteButton", al, ac );
	ac = 0;
	widget13 = XmCreateSeparator ( widget9, "widget13", al, ac );
	widget14 = XmCreatePushButton ( widget9, "exitButton", al, ac );
	XtSetArg(al[ac], XmNsubMenuId, widget9); ac++;
	widget8 = XmCreateCascadeButton ( widget7, "fileCascade", al, ac );
	ac = 0;
	toolMenu =  XmCreatePulldownMenu ( widget7, "toolMenu", al, ac );
	/*
	XtAddCallback(toolMenu, XmNunmapCallback, grab_input, NULL);
	*/
	generateButton = XmCreatePushButton ( toolMenu, "generateButton", al, ac );
	browseButton = XmCreatePushButton ( toolMenu, "browseButton", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNsubMenuId, toolMenu); ac++;
	toolCascade = XmCreateCascadeButton ( widget7, "toolCascade", al, ac );

	lockMenu = XmCreatePulldownMenu ( widget7, "lockMenu", al, ac );
	/*
	XtAddCallback(widget9, XmNunmapCallback, grab_input, NULL);
	*/
	lockButton = XmCreatePushButton ( lockMenu, "lockButton", al, ac );
	ac = 0; XtSetArg(al[ac], XmNsensitive, False); ac++;
	unlockButton = XmCreatePushButton ( lockMenu, "unlockButton", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNsubMenuId, lockMenu); ac++;
	lockCascade = XmCreateCascadeButton ( widget7, "lockCascade", al, ac );

	ac = 0;
	widget16 = XmCreatePulldownMenu ( widget7, "widget16", al, ac );
	/*
	XtAddCallback(widget16, XmNunmapCallback, grab_input, NULL);
	*/
	XtSetArg(al[ac], XmNsubMenuId, widget16); ac++;
	widget15 = XmCreateCascadeButton ( widget7, "helpCascade", al, ac );

	/* Hand-added */
	XtVaSetValues(widget7, XmNmenuHelpWidget, widget15, NULL);

	ac = 0; 
	widget17 = XmCreateForm ( widget1, "editMsgForm", al, ac );
	XtSetArg(al[ac], XmNwidth, 100); ac++;
	XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
	nameLabel = XmCreateLabel ( widget17, "nameLabel", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
	textLabel = XmCreateLabel ( widget17, "textLabel", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNmaxLength, 20); ac++;
	nameTextField = XmCreateTextField( widget17, "nameTextField", al, ac );
	XtAddCallback(nameTextField, XmNvalueChangedCallback, message_modified,
		      NULL);
	ac = 0;
	XtSetArg(al[ac], XmNmaxLength, 50); ac++;
	msgTextField = XmCreateTextField ( widget17, "msgTextField", al, ac );
	XtAddCallback(msgTextField, XmNvalueChangedCallback, message_modified,
		      NULL);
	ac = 0;
	XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
	severityLabel = XmCreateLabel ( widget17, "severityLabel", al, ac );
	ac = 0;
	severityMenu = XmCreatePulldownMenu ( widget17, "severityPulldown", al, ac );
	/*
	XtAddCallback(severityMenu, XmNunmapCallback, grab_input, NULL);
	*/
	XtSetArg(al[0], XmNuserData, (caddr_t)SEV_DEBUG);
	widget27 = XmCreatePushButton ( severityMenu, "debugButton", al, 1);
	XtSetArg(al[0], XmNuserData, (caddr_t)SEV_INFORM);
	widget28 = XmCreatePushButton ( severityMenu, "informButton", al, 1 );
	XtSetArg(al[0], XmNuserData, (caddr_t)SEV_WARN);
	widget29 = XmCreatePushButton ( severityMenu, "warnButton", al, 1 );
	XtSetArg(al[0], XmNuserData, (caddr_t)SEV_ERROR);
	widget30 = XmCreatePushButton ( severityMenu, "errorButton", al, 1 );
	XtSetArg(al[0], XmNuserData, (caddr_t)SEV_ALARM);
	widget31 = XmCreatePushButton ( severityMenu, "alarmButton", al, 1 );
	XtSetArg(al[0], XmNuserData, (caddr_t)SEV_FATAL);
	widget32 = XmCreatePushButton ( severityMenu, "fatalButton", al, 1 );
	ac = 0;
	XtSetArg(al[ac], XmNuserData, (caddr_t)SEV_UNKNOWN); ac++;
	/* "Unknown" is only allowed if it is found in the DB */
	XtSetArg(al[ac], XmNsensitive, FALSE); ac++;
	widget33 = XmCreatePushButton (severityMenu, "unknownButton", al, ac );

	ac = 0;
	XtSetArg(al[ac], XmNsubMenuId, severityMenu); ac++;
	severityOptionMenu = XmCreateOptionMenu ( widget17, "severityOptionMenu", al, ac );
	ac = 0;
	widget25 = XmOptionButtonGadget ( severityOptionMenu );
	XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
	moduleLabel = XmCreateLabel ( widget17, "moduleLabel", al, ac );
	ac = 0;
	moduleMenu = XmCreatePulldownMenu ( widget17, "moduleMenu", al, ac );
	/*
	XtAddCallback(moduleMenu, XmNunmapCallback, grab_input, NULL);
	*/
	
	/* Create the button for the chosen module as the default.
	   */
	if (strcmp(module_names[0], g_module)) {
	  for (imod=0; imod<nmodule_names; imod++) 
	    if (!strcmp(module_names[imod], g_module)) break;
	  strcpy(module_names[imod], module_names[0]);
	  strcpy(module_names[0], g_module);
	}
	modbutton = (Widget *)XtMalloc(nmodule_names * sizeof(Widget));
	for (imod = 0; imod < nmodule_names; imod++) {
	  XtSetArg(al[0], XmNuserData, module_names[imod]);
	  modbutton[imod] = XmCreatePushButton(moduleMenu, module_names[imod], 
					       al, 1 );
	}
	XtSetArg(al[ac], XmNsubMenuId, moduleMenu); ac++;
	moduleOptionMenu = XmCreateOptionMenu ( widget17, "moduleOptionMenu", al, ac );
	ac = 0;
	widget37 = XmOptionButtonGadget ( moduleOptionMenu );
	XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
	categoryLabel = XmCreateLabel ( widget17, "categoryLabel", al, ac );
	ac = 0;
	categoryTextField = XmCreateTextField ( widget17, "categoryTextField", al, ac );
	XtAddCallback(categoryTextField, XmNvalueChangedCallback, 
		      message_modified, NULL);
	XtSetArg(al[ac], XmNwidth, 101); ac++;
	XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
	descriptionLabel = XmCreateLabel ( widget17, "descriptionLabel", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNmaxLength, 255); ac++;
	descriptionText = XmCreateText ( widget17, "descriptionText", al, ac );
	XtAddCallback(descriptionText, XmNvalueChangedCallback, 
		      message_modified, NULL);
	ac = 0;
	children[ac++] = widget10;
	children[ac++] = widget11;
	children[ac++] = widget12;
	children[ac++] = deleteButton;
	children[ac++] = widget13;
	children[ac++] = widget14;
	XtManageChildren(children, ac);

	ac = 0;
	children[ac++] = generateButton;
	children[ac++] = browseButton;
	XtManageChildren(children, ac);

	ac = 0;
	children[ac++] = unlockButton;
	children[ac++] = lockButton;
	XtManageChildren(children, ac);

	ac = 0;
	children[ac++] = widget8;
	children[ac++] = widget15;
	children[ac++] = toolCascade;
	children[ac++] = lockCascade;
	XtManageChildren(children, ac);

	ac = 0;
	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, nameTextField); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomWidget, nameTextField); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNrightWidget, nameTextField); ac++;
        XtSetValues ( nameLabel,al, ac );

	ac = 0;
	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, msgTextField); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomWidget, msgTextField); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNrightWidget, msgTextField); ac++;
        XtSetValues ( textLabel,al, ac );

	ac = 0;
	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_POSITION); ac++;

        XtSetValues ( nameTextField,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, nameTextField); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNleftWidget, nameTextField); ac++;
        XtSetValues ( msgTextField,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, severityOptionMenu); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomWidget, severityOptionMenu); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNrightWidget, severityOptionMenu); ac++;
        XtSetValues ( severityLabel,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, msgTextField); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNleftWidget, msgTextField); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
        XtSetValues ( severityOptionMenu,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, moduleOptionMenu); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomWidget, moduleOptionMenu); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 0); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNrightWidget, moduleOptionMenu); ac++;
        XtSetValues ( moduleLabel,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, severityOptionMenu); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNleftWidget, severityOptionMenu); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
        XtSetValues ( moduleOptionMenu,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, categoryTextField); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomWidget, categoryTextField); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNrightWidget, categoryTextField); ac++;
        XtSetValues ( categoryLabel,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, moduleOptionMenu); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNleftWidget, moduleOptionMenu); ac++;
        XtSetValues ( categoryTextField,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, descriptionText); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomWidget, descriptionText); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNrightWidget, descriptionText); ac++;
        XtSetValues ( descriptionLabel,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, categoryTextField); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNleftWidget, categoryTextField); ac++;
        XtSetValues ( descriptionText,al, ac );

	XtAddCallback(widget10, XmNactivateCallback, open_message, NULL);
	XtAddCallback(browseButton, XmNactivateCallback, browse_messages, 
		      g_module);
	XtAddCallback(widget11, XmNactivateCallback, new_message, NULL);
	XtAddCallback(widget12, XmNactivateCallback, save_message, NULL);
	XtAddCallback(deleteButton, XmNactivateCallback, delete_message, NULL);
	XtAddCallback(generateButton, XmNactivateCallback, generate_header, NULL);
	XtAddCallback(lockButton, XmNactivateCallback, set_lock, widget9);
	XtAddCallback(unlockButton, XmNactivateCallback, unset_lock, widget9);
	XtAddCallback(widget14, XmNactivateCallback, exit_app, NULL);
	XtAddCallback(widget27, XmNactivateCallback, set_severity, NULL);
	XtAddCallback(widget28, XmNactivateCallback, set_severity, NULL);
	XtAddCallback(widget29, XmNactivateCallback, set_severity, NULL);
	XtAddCallback(widget30, XmNactivateCallback, set_severity, NULL);
	XtAddCallback(widget31, XmNactivateCallback, set_severity, NULL);
	XtAddCallback(widget32, XmNactivateCallback, set_severity, NULL);
	XtAddCallback(widget33, XmNactivateCallback, set_severity, NULL);
	for (imod = 0; imod < nmodule_names; imod++)
	  XtAddCallback(modbutton[imod], XmNactivateCallback, set_module, 
			NULL);
	ac = 0;
	children[ac++] = widget27;
	children[ac++] = widget28;
	children[ac++] = widget29;
	children[ac++] = widget30;
	children[ac++] = widget31;
	children[ac++] = widget32;
	children[ac++] = widget33;
	XtManageChildren(children, ac);
	XtManageChildren(modbutton, nmodule_names);
	ac = 0;
	children[ac++] = nameLabel;
	children[ac++] = textLabel;
	children[ac++] = nameTextField;
	children[ac++] = msgTextField;
	children[ac++] = severityLabel;
	children[ac++] = severityOptionMenu;
	children[ac++] = moduleLabel;
	children[ac++] = moduleOptionMenu;
	children[ac++] = categoryLabel;
	children[ac++] = categoryTextField;
	children[ac++] = descriptionLabel;
	children[ac++] = descriptionText;
	XtManageChildren(children, ac);
	ac = 0;
	XtManageChild ( widget7 );
	XtManageChild ( widget17 );
	XmMainWindowSetAreas(widget1, widget7, (Widget) NULL, widget2, widget3, widget17 );
	XtManageChild ( widget1);
}
Ejemplo n.º 29
0
void CreateUserInterface(Widget parent)
{
    Widget
        frameW,
        main_formW,
        menubarW,

        col1_rcW,
        col2_rcW,

        col3_rcW,
        col4_rcW,

        col5_rcW,
        col6_rcW,

        col7_rcW,
        col8_rcW,

        col9_rcW,
        col10_rcW,
        
        col11_rcW,
        col12_rcW,

        helpW;

    extern MenuItem
        file_items[],
        options_items[],
        help_items[];

    Display
        *display;

    XmFontList
        fontlist;

    XFontStruct
        *font;

    display=XtDisplay (parent);
    font = XLoadQueryFont (display,
   "-b&h-lucidatypewriter-medium-r-normal-sans-14-140-75-75-m-90-iso8859-1");

    if (font == (XFontStruct *) NULL)
    {
        (void) fprintf (stderr," Failed to load font,using fixed!\n");
        font=XLoadQueryFont (display,"fixed");
    }
    else
    {
        fontlist=XmFontListCreate (font,"charset1");

    }
    
    /*
    ** create the main window W
    */
    GmainwW=XtVaCreateManagedWidget("mainww",
        xmMainWindowWidgetClass,parent,
        NULL); 

   /*
   ** create the menubar
   */
   menubarW=XmCreateMenuBar(GmainwW,"menuBar",NULL,0);
   (void) MBuildPulldownMenu(menubarW,"File",'F',file_items);
   (void) MBuildPulldownMenu(menubarW,"Options",'p',options_items);

   helpW=MBuildPulldownMenu(menubarW,"Help",'e',help_items);
   XtVaSetValues(menubarW,
        XmNmenuHelpWidget, helpW,
        NULL);

   XtManageChild(menubarW);

   /*
   ** create a frame for ornamentatl reason
   */
   frameW=XtVaCreateManagedWidget ("framew",
       xmFrameWidgetClass,GmainwW,
       NULL);

   /*
   ** create the main formW
   */
   main_formW=XtVaCreateWidget("mformw",
        xmFormWidgetClass,frameW,
        NULL);
    
    /*
    ** create col1,2 rc widget
    */
    col1_rcW=XtVaCreateWidget ("lrcw",
        xmRowColumnWidgetClass,main_formW,
        XmNleftAttachment,XmATTACH_FORM,
        XmNtopAttachment, XmATTACH_FORM,
        XmNbottomAttachment, XmATTACH_FORM,
        XmNorientation, XmVERTICAL,
        NULL);

    col2_rcW=XtVaCreateWidget ("lrcw",
        xmRowColumnWidgetClass,main_formW,
        XmNleftAttachment,XmATTACH_WIDGET,
        XmNleftWidget,col1_rcW,
        XmNleftOffset,10,
        XmNtopAttachment, XmATTACH_FORM,
        XmNbottomAttachment, XmATTACH_FORM,
        XmNorientation, XmVERTICAL,
        NULL);

    /*
    ** create the col1,2 labels
    */
    Gvalue_labelW[0]=XtVaCreateManagedWidget ("label",
        xmLabelWidgetClass,col1_rcW,
        XmNalignment, XmALIGNMENT_BEGINNING,
        XmNfontList,fontlist,
        NULL);

     Gascii_labelW[0]=XtVaCreateManagedWidget ("label2",
        xmLabelWidgetClass,col2_rcW,
        XmNalignment, XmALIGNMENT_BEGINNING,
        XmNfontList,fontlist,
        NULL);

    /*
    ** create 3,4 rc widgets
    */
     col3_rcW=XtVaCreateWidget ("rcw",
        xmRowColumnWidgetClass,main_formW,
        XmNleftAttachment,XmATTACH_WIDGET,
        XmNleftWidget,col2_rcW,
        XmNleftOffset,15,
        XmNtopAttachment, XmATTACH_FORM,
        XmNbottomAttachment, XmATTACH_FORM,
        XmNorientation, XmVERTICAL,
        NULL); 

     col4_rcW=XtVaCreateWidget ("rcw",
        xmRowColumnWidgetClass,main_formW,
        XmNleftAttachment,XmATTACH_WIDGET,
        XmNleftWidget, col3_rcW,
        XmNleftOffset,10,
        XmNtopAttachment, XmATTACH_FORM,
        XmNbottomAttachment, XmATTACH_FORM,
        XmNorientation, XmVERTICAL,
        NULL);

    /*
    ** create the 3,4 labels
    */

     Gvalue_labelW[1]=XtVaCreateManagedWidget ("label",
        xmLabelWidgetClass,col3_rcW,
        XmNalignment, XmALIGNMENT_BEGINNING,
        XmNfontList,fontlist,
        NULL);
     Gascii_labelW[1]=XtVaCreateManagedWidget ("label2",
        xmLabelWidgetClass,col4_rcW,
        XmNalignment, XmALIGNMENT_BEGINNING,
        XmNfontList,fontlist,
        NULL);

    /*
    ** create the 5,6 rc widgets
    */
     col5_rcW=XtVaCreateWidget ("rcw",
        xmRowColumnWidgetClass,main_formW,
        XmNleftAttachment,XmATTACH_WIDGET,
        XmNleftWidget,col4_rcW,
        XmNleftOffset,15,
        XmNtopAttachment, XmATTACH_FORM,
        XmNbottomAttachment, XmATTACH_FORM,
        XmNorientation, XmVERTICAL,
        NULL); 

     col6_rcW=XtVaCreateWidget ("rcw",
        xmRowColumnWidgetClass,main_formW,
        XmNleftAttachment,XmATTACH_WIDGET,
        XmNleftWidget, col5_rcW,
        XmNleftOffset,10,
        XmNtopAttachment, XmATTACH_FORM,
        XmNbottomAttachment, XmATTACH_FORM,
        XmNorientation, XmVERTICAL,
        NULL);

    /*
    ** create the 5,6 labels
    */

    Gvalue_labelW[2]=XtVaCreateManagedWidget ("label",
        xmLabelWidgetClass,col5_rcW,
        XmNalignment, XmALIGNMENT_BEGINNING,
        XmNfontList,fontlist,
        NULL);
     Gascii_labelW[2]=XtVaCreateManagedWidget ("label2",
        xmLabelWidgetClass,col6_rcW,
        XmNalignment, XmALIGNMENT_BEGINNING,
        XmNfontList,fontlist,
        NULL);


    /*
    ** create the col 7,8 rc widgets
    */

     col7_rcW=XtVaCreateWidget ("rcw",
        xmRowColumnWidgetClass,main_formW,
        XmNleftAttachment,XmATTACH_WIDGET,
        XmNleftWidget,col6_rcW,
        XmNleftOffset,15,
        XmNtopAttachment, XmATTACH_FORM,
        XmNbottomAttachment, XmATTACH_FORM,
        XmNorientation, XmVERTICAL,
        NULL); 

     col8_rcW=XtVaCreateWidget ("rcw",
        xmRowColumnWidgetClass,main_formW,
        XmNleftAttachment,XmATTACH_WIDGET,
        XmNleftWidget, col7_rcW,
        XmNleftOffset,10,
        XmNtopAttachment, XmATTACH_FORM,
        XmNorientation, XmVERTICAL,
        NULL);   

    /*
    ** create col 7,8 labels
    */
    Gvalue_labelW[3]=XtVaCreateManagedWidget ("label",
        xmLabelWidgetClass,col7_rcW,
        XmNalignment, XmALIGNMENT_BEGINNING,
        XmNfontList,fontlist,
        NULL);
     Gascii_labelW[3]=XtVaCreateManagedWidget ("label2",
        xmLabelWidgetClass,col8_rcW,
        XmNalignment, XmALIGNMENT_BEGINNING,
        XmNfontList,fontlist,
        NULL);

    /*
    ** create the col 9,10 rc widgets
    */

     col9_rcW=XtVaCreateWidget ("rcw",
        xmRowColumnWidgetClass,main_formW,
        XmNleftAttachment,XmATTACH_WIDGET,
        XmNleftWidget,col8_rcW,
        XmNleftOffset,15,
        XmNtopAttachment, XmATTACH_FORM,
        XmNbottomAttachment, XmATTACH_FORM,
        XmNorientation, XmVERTICAL,
        NULL); 

     col10_rcW=XtVaCreateWidget ("rcw",
        xmRowColumnWidgetClass,main_formW,
        XmNleftAttachment,XmATTACH_WIDGET,
        XmNleftWidget, col9_rcW,
        XmNleftOffset,10,
        XmNtopAttachment, XmATTACH_FORM,
        XmNbottomAttachment, XmATTACH_FORM,
        XmNorientation, XmVERTICAL,
        NULL);   

    /*
    ** create col 9,10 labels
    */
    Gvalue_labelW[4]=XtVaCreateManagedWidget ("label",
        xmLabelWidgetClass,col9_rcW,
        XmNalignment, XmALIGNMENT_BEGINNING,
        XmNfontList,fontlist,
        NULL);
     Gascii_labelW[4]=XtVaCreateManagedWidget ("label2",
        xmLabelWidgetClass,col10_rcW,
        XmNalignment, XmALIGNMENT_BEGINNING,
        XmNfontList,fontlist,
        NULL);

    /*
    ** create the col 11,12 rc widgets
    */

     col11_rcW=XtVaCreateWidget ("rcw",
        xmRowColumnWidgetClass,main_formW,
        XmNleftAttachment,XmATTACH_WIDGET,
        XmNleftWidget,col10_rcW,
        XmNleftOffset,15,
        XmNtopAttachment, XmATTACH_FORM,
        XmNbottomAttachment, XmATTACH_FORM,
        XmNorientation, XmVERTICAL,
        NULL); 

     col12_rcW=XtVaCreateWidget ("rcw",
        xmRowColumnWidgetClass,main_formW,
        XmNleftAttachment,XmATTACH_WIDGET,
        XmNleftWidget, col11_rcW,
        XmNleftOffset,10,
        XmNtopAttachment, XmATTACH_FORM,
        XmNrightAttachment, XmATTACH_FORM,
        XmNbottomAttachment, XmATTACH_FORM,
        XmNorientation, XmVERTICAL,
        NULL);   

    /*
    ** create col 11,12 labels
    */
    Gvalue_labelW[5]=XtVaCreateManagedWidget ("label",
        xmLabelWidgetClass,col11_rcW,
        XmNalignment, XmALIGNMENT_BEGINNING,
        XmNfontList,fontlist,
        NULL);
     Gascii_labelW[5]=XtVaCreateManagedWidget ("label2",
        xmLabelWidgetClass,col12_rcW,
        XmNalignment, XmALIGNMENT_BEGINNING,
        XmNfontList,fontlist,
        NULL);

    /*
    ** manage the widget not managed yet
    */
    XtManageChild (col12_rcW);
    XtManageChild (col11_rcW);

    XtManageChild (col10_rcW);
    XtManageChild (col9_rcW);

    XtManageChild (col8_rcW);
    XtManageChild (col7_rcW);

    XtManageChild (col6_rcW);
    XtManageChild (col5_rcW);

    XtManageChild (col4_rcW);
    XtManageChild (col3_rcW);

    XtManageChild (col2_rcW);
    XtManageChild (col1_rcW);

    XtManageChild (main_formW);
}
Ejemplo n.º 30
0
Archivo: main.c Proyecto: fjardon/motif
int 
main(int argc, char *argv[])
{
#define MAIN_CHILDREN		3
#define FORM_CHILDREN		3
#define PLANE_CHILDREN		6
#define TRAFFIC_CHILDREN	3
#define SetMenuEntry(k,l,p,d) labels[k]=l;procs[k]=p;private[k]=d;

   Pixmap flying;
   Pixmap parked;
   Pixmap mask;
   Widget theWidgetRoot;
   Widget main_tab[MAIN_CHILDREN];
   Widget from_tab[PLANE_CHILDREN];
   Widget to_tab[TRAFFIC_CHILDREN];
   Widget form_tab[FORM_CHILDREN];
   Widget framed[2];
   Widget entry;
   static char myClass[] = "XmdAirport";
   Arg args[10];
   int n ;
   String labels[4];
   XtCallbackProc procs[4];
   XtPointer private[4];
   XGCValues gcv;
   Airport this;


/*
 * Initialize
 */
   this = (Airport) XtCalloc(sizeof(AirportRec), 1);

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

   theWidgetRoot = XtVaOpenApplication( &this->context, 
                                        myClass, 
				        NULL, 
                                        0, 
                                        &argc, 
                                        argv, 
                                        NULL,
                                        sessionShellWidgetClass, 
				        XmNallowShellResize, True,
                                        NULL);
   
   this->display = XtDisplay(theWidgetRoot);
   FlightAtom = XmInternAtom(this->display, "FLIGHT", False);
   DeleteAtom = XmInternAtom(this->display, "DELETE", False);

   XtGetApplicationResources(theWidgetRoot, &AirportResources,
			     AirportResourcesSpecs, 
			     XtNumber(AirportResourcesSpecs),
			     (ArgList) NULL, 0);

/*
 * Create the Main Window, the menubar and the pulldown menus
 */
   n = 0;
   this->main = XmCreateMainWindow(theWidgetRoot, "main", args, n);

   n = 0;
   main_tab[0] = XmCreateMenuBar(this->main, "menubar", args, n);
   n = 0;
   SetMenuEntry(n, "Exit", 
		(XtCallbackProc) ExitCallback, (XtPointer) this ); n++;
   entry = MenuBarEntry(main_tab[0], "File", labels, procs, private, n);
   n = 0;
   SetMenuEntry(0, "Tutorial",
		(XtCallbackProc) HelpCallback, (XtPointer) this); n++;
   entry = MenuBarEntry(main_tab[0], "Help", labels, procs, private, n);
   n = 0;
   XtSetArg(args[n], XmNmenuHelpWidget, entry); n++;
   XtSetValues(main_tab[0], args, n);

/*
 * Create the Airport widget structure.
 * Two framed radio boxes show state. 
 * A drawing area in the middle show track and planes
 */

   n = 0;
   this->screen_width = WidthOfScreen(XtScreenOfObject(this->main));
   this->screen_height = HeightOfScreen(XtScreenOfObject(this->main));
   XtSetArg(args[n], XmNwidth, this->screen_width*3/7); n++;
   XtSetArg(args[n], XmNresizePolicy, XmRESIZE_NONE); n++;
   main_tab[1] = XmCreateForm(this->main, "airport", args, n);

   n = 0;
   XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; 
   XtSetArg(args[n], XmNbottomAttachment,XmATTACH_FORM); n++; 
   XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM) ; n++;
   form_tab[0] = XmCreateFrame(main_tab[1], "flight", args, n);

   n = 0;
   XtSetArg(args[n], XmNchildType, XmFRAME_TITLE_CHILD); n++;
   framed[0] = XmCreateLabel(form_tab[0], "title", args, n);
   
   n = 0;
   XtSetArg(args[n], XmNchildType, XmFRAME_WORKAREA_CHILD); n++;
   XtSetArg(args[n], XmNresizePolicy, XmRESIZE_GROW); n++;
   XtSetArg(args[n], XmNradioBehavior, True); n++;
   framed[1] = XmCreateRadioBox(form_tab[0], "panel", args, n);
 
   n = 0;
   XtSetArg(args[n], XmNset, True); n++;
   XtSetArg(args[n], XmNvisibleWhenOff, False); n++;
   this->from.departure =
     from_tab[0] = XmCreateToggleButton(framed[1], 
					       "departure", args, n);
   n = 0;
   XtSetArg(args[n], XmNvisibleWhenOff, False); n++;
   this->from.over_ocean =
     from_tab[1] = XmCreateToggleButton(framed[1], 
					       "over_ocean", args, n);
   n = 0;
   XtSetArg(args[n], XmNvisibleWhenOff, False); n++;
   this->from.over_land =
     from_tab[2] = XmCreateToggleButton(framed[1], 
					       "over_land", args, n);
   n = 0;
   XtSetArg(args[n], XmNvisibleWhenOff, False); n++;
   this->from.over_site =     
     from_tab[3] = XmCreateToggleButton(framed[1],
					       "radar", args, n);
   n = 0;
   XtSetArg(args[n], XmNvisibleWhenOff, False); n++;
   this->from.landing =   
     from_tab[4] = XmCreateToggleButton(framed[1], "landing", args, n);

   n = 0;
   XtSetArg(args[n], XmNvisibleWhenOff, False); n++;
   this->from.landed =     
     from_tab[5] = XmCreateToggleButton(framed[1], "landed", args, n);
   XtManageChildren(from_tab, PLANE_CHILDREN);
   XtManageChildren(framed, 2);

/*
 * Create the Airport Traffic control state
 */

   n = 0;
   XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; 
   XtSetArg(args[n], XmNbottomAttachment,XmATTACH_FORM); n++; 
   XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM) ; n++;
   form_tab[1] = XmCreateFrame(main_tab[1], "traffic", args, n);

   n = 0;
   XtSetArg(args[n], XmNchildType, XmFRAME_TITLE_CHILD); n++;
   framed[0] = XmCreateLabel(form_tab[1], "title", args, n);
   
   n = 0;
   XtSetArg(args[n], XmNchildType, XmFRAME_WORKAREA_CHILD); n++;
   XtSetArg(args[n], XmNradioBehavior, True); n++;
   framed[1] = XmCreateRadioBox(form_tab[1], "traffic_box", args, n);
 
   n = 0;
   XtSetArg(args[n], XmNset, True); n++;
   XtSetArg(args[n], XmNvisibleWhenOff, False); n++;
   this->to.leave =     
     to_tab[1] = XmCreateToggleButton(framed[1],
				      "no_traffic", args, n);
   n = 0;
   XtSetArg(args[n], XmNvisibleWhenOff, False); n++;
   this->to.enter =     
     to_tab[0] = XmCreateToggleButton(framed[1],
				      "radar_echo", args, n);
   n = 0;
   XtSetArg(args[n], XmNvisibleWhenOff, False); n++;
   this->to.landing =   
     to_tab[2] = XmCreateToggleButton(framed[1],
				      "landing", args, n);

   XtManageChildren(to_tab, TRAFFIC_CHILDREN);
   XtManageChildren(framed, 2);

/*
 * Create the Airport picture
 */
   n = 0;
   XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; 
   XtSetArg(args[n], XmNbottomAttachment,XmATTACH_FORM); n++; 
   XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET) ; n++;
   XtSetArg(args[n], XmNleftWidget, form_tab[0]) ; n++;
   XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET) ; n++;
   XtSetArg(args[n], XmNrightWidget, form_tab[1]) ; n++;
   this->airport = 
     form_tab[2] = XmCreateDrawingArea(main_tab[1], "da", args, n);
   XtAddCallback(this->airport, XmNexposeCallback,
		 (XtCallbackProc) ShowAirport, (XtPointer) this);
   XtAddCallback(this->airport, XmNresizeCallback,
		 (XtCallbackProc) ResizeAirport, (XtPointer) this);
   XtAddCallback(this->airport, XmNinputCallback,
		 (XtCallbackProc) AirportInput, (XtPointer) this);
/*
 * Create the Airport Message area
 */
	
   n = 0;
   main_tab[2] = XmCreateFrame(this->main, "message", args, n);

   n = 0;
   XtSetArg(args[n], XmNchildType, XmFRAME_TITLE_CHILD); n++;
   framed[0] = XmCreateLabel(main_tab[2], "title", args, n);
   
   n = 0;
   XtSetArg(args[n], XmNchildType, XmFRAME_WORKAREA_CHILD); n++;
   XtSetArg(args[n], XmNvisibleItemCount, 4); n++;
   this->msg_area = XmCreateScrolledList(main_tab[2], "msg_list", args, n);
   XtManageChild(this->msg_area);
   framed[1] = XtParent(this->msg_area);
   XtManageChildren(framed, 2);

   n = 0;
   XtSetArg(args[n], XmNmenuBar, main_tab[0]); n++;
   XtSetArg(args[n], XmNworkWindow, main_tab[1]); n++;
   XtSetArg(args[n], XmNmessageWindow, main_tab[2]); n++;
   XtSetValues(this->main, args, n);
   XtManageChildren(form_tab, FORM_CHILDREN);
   XtManageChildren(main_tab, MAIN_CHILDREN);
   XtManageChild(this->main);

   XtRealizeWidget(theWidgetRoot);
   
/* 
 * Create the drag icon
 */

   parked = XCreateBitmapFromData(this->display,
			   XtWindow(this->main), (char*)plane_bits,
			   plane_width, plane_height);

   flying = XCreateBitmapFromData(this->display,
				  XtWindow(this->main), (char*)flying_bits, 
				  flying_icon_width, flying_icon_height);

   mask = XCreateBitmapFromData(this->display, 
				XtWindow(this->main), (char*)flying_mask_bits, 
				flying_mask_width, flying_mask_height);
   n = 0;
   XtSetArg(args[n], XmNpixmap, flying); n++;
   XtSetArg(args[n], XmNdepth, 1); n++;
   XtSetArg(args[n], XmNmask, mask); n++; 
   XtSetArg(args[n], XmNwidth, flying_icon_width); n++;
   XtSetArg(args[n], XmNheight, flying_icon_height) ; n++;
   this->dragIcon = XmCreateDragIcon(form_tab[2], "drag", args, n);
   if (this->dragIcon  == NULL) {
      printf("cannot create drag icon\n");
      exit(0);
   }
  /* Create GC for drawing planes */
   gcv.function = GXcopy;
   gcv.fill_style = FillOpaqueStippled;
   gcv.stipple = parked;
   gcv.foreground = AirportResources.spot_foreground; 
   gcv.background = AirportResources.spot_background; 
   this->park.gc = XCreateGC(this->display, XtWindow(this->main), 
			     GCFunction|GCStipple|GCFillStyle
			     |GCForeground|GCBackground,
			     &gcv);
   
   gcv.line_style = LineDoubleDash;
   gcv.line_width = AirportResources.track_border_width;
   gcv.fill_style = FillSolid;
   gcv.foreground = AirportResources.track_foreground; 
   gcv.background = AirportResources.track_background; 
   this->track.gc = XCreateGC(this->display, XtWindow(this->main), 
			      GCFunction|GCLineWidth|GCLineStyle
			      |GCFillStyle|GCForeground|GCBackground,
			      &gcv);
   XtAppMainLoop(this->context);

   return 0;    /* make compiler happy */
}