static void createBrowserHeadDump()
{
    Arg args[50];
    int ac;
    XmString s1;
    Widget dismissBtn;

    ac = 0;
    XtSetArg(args[ac], XmNautoUnmanage, False); ac++; 
    XtSetArg(args[ac], XmNresizePolicy, XmRESIZE_NONE); ac++; 
    DumpHeadFormW = XmCreateFormDialog(McfioMainPanelW, "form", args, ac);
    DumpHeadShellW = XtParent(DumpHeadFormW);
    XtVaSetValues(DumpHeadShellW, XmNtitle,
                                "File Header Information", 0);
    AddMotifCloseCallback(XtParent(DumpHeadFormW),
                         (XtCallbackProc)dismissHeadDumpCB, NULL);
                         
                         
    dismissBtn = XtVaCreateManagedWidget("dismissBtn",
    	    xmPushButtonGadgetClass, DumpHeadFormW,
    	    XmNlabelString, s1=XmStringCreateSimple("Dismiss"),
    	    XmNbottomAttachment, XmATTACH_FORM,
    	    XmNbottomOffset, 4,
    	    XmNleftAttachment, XmATTACH_POSITION,
    	    XmNleftPosition, 25,
    	    XmNrightAttachment, XmATTACH_POSITION,
    	    XmNrightPosition, 75, 0);
    XmStringFree(s1);
    XtAddCallback(dismissBtn, XmNactivateCallback,
    	    (XtCallbackProc)dismissHeadDumpCB, NULL); 
    
    ac = 0;
    XtSetArg(args[ac], XmNrows, 8); ac++;
    XtSetArg(args[ac], XmNcolumns, 80); ac++;
    XtSetArg(args[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_POSITION); ac++;
    XtSetArg(args[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomWidget, dismissBtn); ac++;
    XtSetArg(args[ac], XmNdeleteResponse, XmDO_NOTHING); ac++;
    DumpHeadTextW = XmCreateScrolledText(DumpHeadFormW,
                                          "HeaderText", args, ac);
    XtManageChild(DumpHeadTextW);
    XtManageChild(DumpHeadFormW);
}
Exemple #2
0
/*
** Create a new help window displaying a given subject, "topic"
**
** Important hint: If this widget is restructured or the name of the text
** subwidget is changed don't forget to adapt the default translations of the
** help text. They are located in nedit.c, look for 
**   static char *fallbackResources 
**   (currently:  nedit.helpForm.sw.helpText*translations...)
*/
static Widget createHelpPanel(enum HelpTopic topic)
{
    Arg al[50];
    int ac;
    Widget appShell, btn, closeBtn, form, btnFW;
    Widget sw, hScrollBar, vScrollBar;
    XmString st1;
    char * helpText  = NULL;
    char * styleData = NULL;

    ac = 0;
    XtSetArg(al[ac], XmNdeleteResponse, XmDO_NOTHING); ac++;
    appShell = CreateWidget(TheAppShell, "help",
            topLevelShellWidgetClass, al, ac);
    AddSmallIcon(appShell);
    /* With openmotif 2.1.30, a crash may occur when the text widget of the
       help window is (slowly) resized to a zero width. By imposing a 
       minimum _window_ width, we can work around this problem. The minimum 
       width should be larger than the width of the scrollbar. 50 is probably 
       a safe value; this leaves room for a few characters */
    XtVaSetValues(appShell, XtNminWidth, 50, NULL);
    form = XtVaCreateManagedWidget("helpForm", xmFormWidgetClass, appShell,
            NULL);
    XtVaSetValues(form, XmNshadowThickness, 0, NULL);
    
    /* Create the bottom row of buttons */
    btn = XtVaCreateManagedWidget("find", xmPushButtonWidgetClass, form,
            XmNlabelString, st1=XmStringCreateSimple("Find..."),
            XmNmnemonic, 'F',
            XmNbottomAttachment, XmATTACH_FORM,
            XmNleftAttachment, XmATTACH_POSITION,
            XmNleftPosition, 3,
            XmNrightAttachment, XmATTACH_POSITION,
            XmNrightPosition, 25,
            NULL);
    XtAddCallback(btn, XmNactivateCallback, searchHelpCB, appShell);
    XmStringFree(st1);

    btn = XtVaCreateManagedWidget("findAgain", xmPushButtonWidgetClass, form,
            XmNlabelString, st1=XmStringCreateSimple("Find Again"),
            XmNmnemonic, 'A',
            XmNbottomAttachment, XmATTACH_FORM,
            XmNleftAttachment, XmATTACH_POSITION,
            XmNleftPosition, 27,
            XmNrightAttachment, XmATTACH_POSITION,
            XmNrightPosition, 49,
            NULL);
    XtAddCallback(btn, XmNactivateCallback, searchHelpAgainCB, appShell);
    XmStringFree(st1);

    btn = XtVaCreateManagedWidget("print", xmPushButtonWidgetClass, form,
            XmNlabelString, st1=XmStringCreateSimple("Print..."),
            XmNmnemonic, 'P',
            XmNbottomAttachment, XmATTACH_FORM,
            XmNleftAttachment, XmATTACH_POSITION,
            XmNleftPosition, 51,
            XmNrightAttachment, XmATTACH_POSITION,
            XmNrightPosition, 73,
            NULL);
    XtAddCallback(btn, XmNactivateCallback, printCB, appShell);
    XmStringFree(st1);

    closeBtn = XtVaCreateManagedWidget("close",
            xmPushButtonWidgetClass, form,
            XmNlabelString, st1=XmStringCreateSimple("Close"),
            XmNbottomAttachment, XmATTACH_FORM,
            XmNleftAttachment, XmATTACH_POSITION,
            XmNleftPosition, 75,
            XmNrightAttachment, XmATTACH_POSITION,
            XmNrightPosition, 97,
            NULL);
    XtAddCallback(closeBtn, XmNactivateCallback, closeCB, appShell);
    XmStringFree(st1);
            
    /* Create the next row of buttons (for navigation) */
    btn = XtVaCreateManagedWidget("prevTopic", xmPushButtonWidgetClass, form,
            XmNlabelString, st1=XmStringCreateSimple("<< Browse"),
            XmNmnemonic, 'o', 
            XmNbottomAttachment, XmATTACH_WIDGET,
            XmNbottomWidget, closeBtn,
            XmNleftAttachment, XmATTACH_POSITION,
            XmNleftPosition, 51,
            XmNrightAttachment, XmATTACH_POSITION,
            XmNrightPosition, 73,
            NULL);
    XtAddCallback(btn, XmNactivateCallback, prevTopicCB, appShell);
    XmStringFree(st1);

    btn = XtVaCreateManagedWidget("nextTopic", xmPushButtonWidgetClass, form,
            XmNlabelString, st1=XmStringCreateSimple("Browse >>"),
            XmNmnemonic, 'e', 
            XmNbottomAttachment, XmATTACH_WIDGET,
            XmNbottomWidget, closeBtn,
            XmNleftAttachment, XmATTACH_POSITION,
            XmNleftPosition, 75, 
            XmNrightAttachment, XmATTACH_POSITION,
            XmNrightPosition, 97,
            NULL);
    XtAddCallback(btn, XmNactivateCallback, nextTopicCB, appShell);
    XmStringFree(st1);

    btn = XtVaCreateManagedWidget("histBack", xmPushButtonWidgetClass, form,
            XmNlabelString, st1=XmStringCreateSimple("Back"),
            XmNmnemonic, 'B', 
            XmNbottomAttachment, XmATTACH_WIDGET,
            XmNbottomWidget, closeBtn,
            XmNleftAttachment, XmATTACH_POSITION,
            XmNleftPosition, 3,
            XmNrightAttachment, XmATTACH_POSITION,
            XmNrightPosition, 25,
            NULL);
    XtAddCallback(btn, XmNactivateCallback, bwHistoryCB, appShell);
    XmStringFree(st1);

    btnFW = XtVaCreateManagedWidget("histForw", xmPushButtonWidgetClass, form,
            XmNlabelString, st1=XmStringCreateSimple("Forward"),
            XmNmnemonic, 'w', 
            XmNbottomAttachment, XmATTACH_WIDGET,
            XmNbottomWidget, closeBtn,
            XmNleftAttachment, XmATTACH_POSITION,
            XmNleftPosition, 27,
            XmNrightAttachment, XmATTACH_POSITION,
            XmNrightPosition, 49,
            NULL);
    XtAddCallback(btnFW, XmNactivateCallback, fwHistoryCB, appShell);
    XmStringFree(st1);
    
    /* Create a text widget inside of a scrolled window widget */
    sw = XtVaCreateManagedWidget("sw", xmScrolledWindowWidgetClass, form,
            XmNshadowThickness, 2,
            XmNtopAttachment, XmATTACH_FORM,
            XmNleftAttachment, XmATTACH_FORM,
            XmNrightAttachment, XmATTACH_FORM,
            XmNbottomAttachment, XmATTACH_WIDGET,
            XmNbottomWidget, btnFW,
            NULL);
    hScrollBar = XtVaCreateManagedWidget("hScrollBar",
            xmScrollBarWidgetClass, sw,
            XmNorientation, XmHORIZONTAL, 
            XmNrepeatDelay, 10,
            NULL);
    vScrollBar = XtVaCreateManagedWidget("vScrollBar",
            xmScrollBarWidgetClass, sw,
            XmNorientation, XmVERTICAL,
            XmNrepeatDelay, 10,
            NULL);
    /* Make sure the fixed size help font is loaded, such that we can base
       our text widget size calculation on it. */
    loadFontsAndColors(sw, 'A');
    HelpTextPanes[topic] = XtVaCreateManagedWidget("helpText",
            textWidgetClass, sw,
            textNfont, HelpStyleInfo[0].font, /* MUST correspond to 'A' above */
            textNrows, 30,
            textNcolumns, 65,
            textNbacklightCharTypes, NULL,
            textNhScrollBar, hScrollBar,
            textNvScrollBar, vScrollBar,
            textNreadOnly, True,
            textNcontinuousWrap, True,
            textNautoShowInsertPos, True,
            NULL);
    XtVaSetValues(sw, XmNworkWindow, HelpTextPanes[topic],
            XmNhorizontalScrollBar, hScrollBar,
            XmNverticalScrollBar, vScrollBar,
            NULL);
    
    /* Initialize help style information, if it hasn't already been init'd */
    initHelpStyles (HelpTextPanes[topic]);
    
    /* Put together the text to display and separate it into parallel text
       and style data for display by the widget */
    helpText = stitch (HelpTextPanes[topic], HelpText[topic], &styleData);
    
    /* Stuff the text into the widget's text buffer */
    BufSetAll (TextGetBuffer (HelpTextPanes[topic]) , helpText);
    XtFree (helpText);
    
    /* Create a style buffer for the text widget and fill it with the style
       data which was generated along with the text content */
    HelpStyleBuffers[topic] = BufCreate(); 
    BufSetAll(HelpStyleBuffers[topic], styleData);
    XtFree (styleData);
    TextDAttachHighlightData(((TextWidget)HelpTextPanes[topic])->text.textD,
            HelpStyleBuffers[topic], HelpStyleInfo, N_STYLES, '\0', NULL, NULL);
    
    /* This shouldn't be necessary (what's wrong in text.c?) */
    HandleXSelections(HelpTextPanes[topic]);
    
    /* Process dialog mnemonic keys */
    AddDialogMnemonicHandler(form, FALSE);
    
    /* Set the default button */
    XtVaSetValues(form, XmNdefaultButton, closeBtn, NULL);
    XtVaSetValues(form, XmNcancelButton, closeBtn, NULL);
    
    /* realize all of the widgets in the new window */
    RealizeWithoutForcingPosition(appShell);
    
    /* Give the text pane the initial focus */
    XmProcessTraversal(HelpTextPanes[topic], XmTRAVERSE_CURRENT);

    /* Make close command in window menu gracefully prompt for close */
    AddMotifCloseCallback(appShell, (XtCallbackProc)closeCB, appShell);
    
    /* Initialize navigation information, if it hasn't already been init'd */
    initNavigationHistory();
    
    /* Set the window title */
    setHelpWinTitle(appShell, topic);
    
    
#ifdef EDITRES
    XtAddEventHandler (appShell, (EventMask)0, True,
            (XtEventHandler)_XEditResCheckMessages, NULL);
#endif /* EDITRES */
    
    return appShell;
}
static void createBrowserOneDHistPanel(nTuBrowserInfo *nTuBr)
{
    Arg args[50];
    int ac;
    XmString s1, *st1;
    Widget dismissBtn, nbinLabel, lowEdgeLabel, highEdgeLabel, multLabel;
    Widget histForm, ntupleForm, titleLabel, histLabel, ntupleLabel;
    Widget ntupleCatLabel, ntupleTitleLabel;

    ac = 0;
    XtSetArg(args[ac], XmNautoUnmanage, False); ac++; 
    XtSetArg(args[ac], XmNresizePolicy, XmRESIZE_NONE); ac++; 
    OneDHistFormW = XmCreateFormDialog(McfioMainPanelW, "form", args, ac);
    OneDHistShellW = XtParent(OneDHistFormW);
    XtVaSetValues(OneDHistShellW, XmNtitle,
                                "One Dimensional Histogram Utility", 0);
    AddMotifCloseCallback(XtParent(OneDHistFormW),
                         (XtCallbackProc)dismissOneDHistCB, NULL);
                         
   OneDHistCreateW = XtVaCreateManagedWidget("create1DBtn",
    	    xmPushButtonGadgetClass, OneDHistFormW,
    	    XmNlabelString, s1=XmStringCreateSimple("Create"),
    	    XmNbottomAttachment, XmATTACH_FORM,
    	    XmNbottomOffset, 4,
    	    XmNleftAttachment, XmATTACH_POSITION,
    	    XmNleftPosition, 2,
    	    XmNrightAttachment, XmATTACH_POSITION,
    	    XmNrightPosition, 18, 0);
    XmStringFree(s1);
    XtAddCallback( OneDHistCreateW, XmNactivateCallback,
    	    (XtCallbackProc)createOneDHistCB, (nTuBrowserInfo *) nTuBr );
                         
                         
   OneDHistModifyW = XtVaCreateManagedWidget("modify1DBtn",
    	    xmPushButtonGadgetClass, OneDHistFormW,
    	    XmNlabelString, s1=XmStringCreateSimple("Modify"),
    	    XmNbottomAttachment, XmATTACH_FORM,
    	    XmNbottomOffset, 4,
    	    XmNleftAttachment, XmATTACH_POSITION,
    	    XmNleftPosition, 20,
    	    XmNrightAttachment, XmATTACH_POSITION,
    	    XmNrightPosition, 40, 0);
    XmStringFree(s1);
    XtAddCallback( OneDHistModifyW, XmNactivateCallback,
    	    (XtCallbackProc)modifyOneDHistCB, NULL);
    	    
   OneDHistDeleteW = XtVaCreateManagedWidget("delete1DBtn",
    	    xmPushButtonGadgetClass, OneDHistFormW,
    	    XmNlabelString, s1=XmStringCreateSimple("Delete"),
    	    XmNbottomAttachment, XmATTACH_FORM,
    	    XmNbottomOffset, 4,
    	    XmNleftAttachment, XmATTACH_POSITION,
    	    XmNleftPosition, 42,
    	    XmNrightAttachment, XmATTACH_POSITION,
    	    XmNrightPosition, 60, 0);
    XmStringFree(s1);
    XtAddCallback( OneDHistDeleteW, XmNactivateCallback,
    	    (XtCallbackProc)deleteOneDHistCB, NULL);
    	    
    dismissBtn = XtVaCreateManagedWidget("dismissBtn",
    	    xmPushButtonGadgetClass, OneDHistFormW,
    	    XmNlabelString, s1=XmStringCreateSimple("Dismiss"),
    	    XmNbottomAttachment, XmATTACH_FORM,
    	    XmNbottomOffset, 4,
    	    XmNleftAttachment, XmATTACH_POSITION,
    	    XmNleftPosition, 80,
    	    XmNrightAttachment, XmATTACH_POSITION,
    	    XmNrightPosition, 98, 0);
    XmStringFree(s1);
    XtAddCallback(dismissBtn, XmNactivateCallback,
    	    (XtCallbackProc)dismissOneDHistCB, NULL);

    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("Number of bins:"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset,5); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomWidget,OneDHistCreateW); ac++;
    XtSetArg(args[ac], XmNbottomOffset,3); ac++;
    nbinLabel = 
       XmCreateLabelGadget(OneDHistFormW, "num1Dbin", args, ac);
    XmStringFree(s1);
    XtManageChild(nbinLabel);
    
    OneDHistNumBinsW = XtVaCreateManagedWidget("numBin1D",
    	    xmTextWidgetClass, OneDHistFormW,
            XmNcolumns, 5,
            XmNmaxLength, 5,
            XmNeditMode, XmSINGLE_LINE_EDIT,
    	    XmNbottomAttachment, XmATTACH_WIDGET,
    	    XmNbottomWidget,OneDHistCreateW,
    	    XmNbottomOffset,3,
    	    XmNleftAttachment, XmATTACH_WIDGET,
    	    XmNleftWidget,nbinLabel, 0);
    RemapDeleteKey(OneDHistNumBinsW);
    XmTextSetString(OneDHistNumBinsW, "100");
    
    
    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("Low Edge:"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNleftWidget,OneDHistNumBinsW); ac++;
    XtSetArg(args[ac], XmNleftOffset,3); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomWidget,OneDHistCreateW); ac++;
    XtSetArg(args[ac], XmNbottomOffset,3); ac++;
    lowEdgeLabel = 
       XmCreateLabelGadget(OneDHistFormW, "low1Dbin", args, ac);
    XmStringFree(s1);
    XtManageChild(lowEdgeLabel);
    
    OneDHistLowBinW = XtVaCreateManagedWidget("lowEdge1D",
    	    xmTextWidgetClass, OneDHistFormW,
            XmNcolumns, 10,
            XmNmaxLength, 20,
            XmNeditMode, XmSINGLE_LINE_EDIT,
    	    XmNbottomAttachment, XmATTACH_WIDGET,
    	    XmNbottomWidget,OneDHistCreateW,
    	    XmNbottomOffset,3,
    	    XmNleftAttachment, XmATTACH_WIDGET,
    	    XmNleftWidget,lowEdgeLabel, 0);
    RemapDeleteKey(OneDHistLowBinW);
    XmTextSetString(OneDHistLowBinW, "0.");
        	    
    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("High Edge:"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNleftWidget,OneDHistLowBinW); ac++;
    XtSetArg(args[ac], XmNleftOffset,3); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomWidget,OneDHistCreateW); ac++;
    XtSetArg(args[ac], XmNbottomOffset,3); ac++;
    highEdgeLabel = 
       XmCreateLabelGadget(OneDHistFormW, "high1Dbin", args, ac);
    XmStringFree(s1);
    XtManageChild(highEdgeLabel);
    
    OneDHistHighBinW = XtVaCreateManagedWidget("highEdge1D",
    	    xmTextWidgetClass, OneDHistFormW,
            XmNcolumns, 10,
            XmNmaxLength, 20,
            XmNeditMode, XmSINGLE_LINE_EDIT,
    	    XmNbottomAttachment, XmATTACH_WIDGET,
    	    XmNbottomWidget,OneDHistCreateW,
    	    XmNbottomOffset,3,
    	    XmNleftAttachment, XmATTACH_WIDGET,
    	    XmNleftWidget,highEdgeLabel, 0);
    RemapDeleteKey(OneDHistHighBinW);
    XmTextSetString(OneDHistHighBinW, "1.");
    
    
    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("Instance:"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNleftWidget,OneDHistHighBinW); ac++;
    XtSetArg(args[ac], XmNleftOffset,3); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomWidget,OneDHistCreateW); ac++;
    XtSetArg(args[ac], XmNbottomOffset,3); ac++;
    multLabel = 
       XmCreateLabelGadget(OneDHistFormW, "inst1Dlabel", args, ac);
    XmStringFree(s1);
    XtManageChild(multLabel);
    
    OneDHistMultW = XtVaCreateManagedWidget("inst1DTw",
    	    xmTextWidgetClass, OneDHistFormW,
            XmNcolumns, 10,
            XmNmaxLength, 20,
            XmNeditMode, XmSINGLE_LINE_EDIT,
    	    XmNbottomAttachment, XmATTACH_WIDGET,
    	    XmNbottomWidget,OneDHistCreateW,
    	    XmNbottomOffset,3,
    	    XmNleftAttachment, XmATTACH_WIDGET,
    	    XmNleftWidget,multLabel, 0);
    RemapDeleteKey(OneDHistMultW);
    XmTextSetString(OneDHistMultW, "All");
    
    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("Title:"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset,3); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomWidget,OneDHistNumBinsW); ac++;
    XtSetArg(args[ac], XmNbottomOffset,3); ac++;
    titleLabel = 
       XmCreateLabelGadget(OneDHistFormW, "title1Dlabel", args, ac);
    XmStringFree(s1);
    XtManageChild(titleLabel);
    
    OneDHistTitleW = XtVaCreateManagedWidget("title1DTw",
    	    xmTextWidgetClass, OneDHistFormW,
            XmNcolumns, 80,
            XmNmaxLength, 255,
            XmNeditMode, XmSINGLE_LINE_EDIT,
    	    XmNbottomAttachment, XmATTACH_WIDGET,
    	    XmNbottomWidget,OneDHistNumBinsW,
    	    XmNbottomOffset,3,
    	    XmNleftAttachment, XmATTACH_WIDGET,
    	    XmNleftWidget,titleLabel, 0);
    RemapDeleteKey(OneDHistTitleW);
    XmTextSetString(OneDHistTitleW, "Please enter a meaningful title here");
    /*
    ** Now the list of 1D histograms.
    */
    /* Create a form to hold the list and the top label */
    ac = 0;
    XtSetArg(args[ac], XmNmarginHeight, 0); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomWidget, OneDHistTitleW); ac++;
    XtSetArg(args[ac], XmNbottomOffset, 3); ac++;
    XtSetArg(args[ac], XmNleftOffset, 2); ac++;
    XtSetArg(args[ac], XmNtopOffset, 2); ac++;
    histForm = XmCreateForm(OneDHistFormW, "hist1DForm", args, ac);
    XtManageChild(histForm);

    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple(
     "One Dimensional Histogram Listing"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset,3); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    histLabel = 
       XmCreateLabelGadget(histForm, "HIST1Dlabel", args, ac);
    XmStringFree(s1);
    XtManageChild(histLabel);
    
    ac = 0;
    XtSetArg(args[ac], XmNitems, (st1=StringTable(1,
     "No histogram defined                        "))); ac++;
    XtSetArg(args[ac], XmNitemCount, 1); ac++;
    XtSetArg(args[ac], XmNscrollBarDisplayPolicy, XmAS_NEEDED); ac++;
    XtSetArg(args[ac], XmNvisibleItemCount, 10); ac++;
    XtSetArg(args[ac], XmNselectionPolicy, XmBROWSE_SELECT); ac++;
    XtSetArg(args[ac], XmNlistSizePolicy, XmCONSTANT); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNtopWidget, histLabel); ac++;
    XtSetArg(args[ac], XmNtopOffset, 0); ac++;
    XtSetArg(args[ac], XmNleftOffset, 3); ac++;
    XtSetArg(args[ac], XmNbottomOffset, 4); ac++;
    OneDHistHistoListW = XmCreateScrolledList(histForm, "hist1DList", args,ac);
    FreeStringTable(st1);
    XtAddCallback(OneDHistHistoListW, XmNbrowseSelectionCallback,
                  (XtCallbackProc)  oneDHistListCB, NULL);
    XtManageChild(OneDHistHistoListW);
    OneDHistSizeOfList = 10;
    OneDHistNumberListed = 0;
    OneDHistListedIDs = (int *) malloc(sizeof(int) * OneDHistSizeOfList);
    /*
    ** Now the list of Ntuple Variables. Also a few Label to refer to the 
    ** Ntuple category/title listed on the Main panel.
    ** 
    */
    /* Create a form to hold the list and the top label */
    ac = 0;
    XtSetArg(args[ac], XmNmarginHeight, 0); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNleftWidget, histForm); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomWidget, OneDHistTitleW); ac++;
    XtSetArg(args[ac], XmNbottomOffset, 3); ac++;
    XtSetArg(args[ac], XmNleftOffset, 6); ac++;
    XtSetArg(args[ac], XmNtopOffset, 2); ac++;
    ntupleForm = XmCreateForm(OneDHistFormW, "ntu1DForm", args, ac);
    XtManageChild(ntupleForm);

    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("Selected NTuple Synopsis"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset,3); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    ntupleLabel = 
       XmCreateLabelGadget(ntupleForm, "NTU1DDlabel", args, ac);
    XmStringFree(s1);
    XtManageChild(ntupleLabel);
    
    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("Category:"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset, 3); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNtopOffset, 1); ac++;
    XtSetArg(args[ac], XmNtopWidget,ntupleLabel ); ac++;
    ntupleCatLabel = 
       XmCreateLabelGadget(ntupleForm, "NTU1Dlabel", args, ac);
    XmStringFree(s1);
    XtManageChild(ntupleCatLabel);
    
    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("None----------------------"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNleftWidget,ntupleCatLabel ); ac++;
    XtSetArg(args[ac], XmNleftOffset,3); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNtopOffset, 1); ac++;
    XtSetArg(args[ac], XmNtopWidget,ntupleLabel ); ac++;
    OneDHistNtupleCategoryLabelW = 
       XmCreateLabelGadget(ntupleForm, "NTU1DCatlabel", args, ac);
    XmStringFree(s1);
    XtManageChild(OneDHistNtupleCategoryLabelW);
    
    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("Title:"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNleftOffset,3); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNtopWidget, ntupleCatLabel); ac++;
    XtSetArg(args[ac], XmNtopOffset, 1); ac++;
    ntupleTitleLabel = 
       XmCreateLabelGadget(ntupleForm, "NTU1Dlabel", args, ac);
    XmStringFree(s1);
    XtManageChild(ntupleTitleLabel);
    
    ac = 0;
    XtSetArg(args[ac], XmNlabelString, 
     (s1=XmStringCreateSimple("None----------------------"))); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNleftWidget,ntupleCatLabel ); ac++;
    XtSetArg(args[ac], XmNleftOffset,3); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNtopWidget,ntupleCatLabel ); ac++;
    XtSetArg(args[ac], XmNtopOffset, 1); ac++;
    OneDHistNtupleTitleLabelW = 
       XmCreateLabelGadget(ntupleForm, "NTU1DTitlabel", args, ac);
    XmStringFree(s1);
    XtManageChild(OneDHistNtupleTitleLabelW);
    
    ac = 0;
    XtSetArg(args[ac], XmNitems, (st1=StringTable(1, " "))); ac++;
    XtSetArg(args[ac], XmNitemCount, 1); ac++;
    XtSetArg(args[ac], XmNscrollBarDisplayPolicy, XmAS_NEEDED); ac++;
    XtSetArg(args[ac], XmNvisibleItemCount, 10); ac++;
    XtSetArg(args[ac], XmNselectionPolicy, XmBROWSE_SELECT); ac++;
    XtSetArg(args[ac], XmNlistSizePolicy, XmCONSTANT); ac++;
    XtSetArg(args[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
    XtSetArg(args[ac], XmNtopWidget, OneDHistNtupleTitleLabelW); ac++;
    XtSetArg(args[ac], XmNtopOffset, 2); ac++;
    XtSetArg(args[ac], XmNleftOffset, 3); ac++;
    OneDHistVariableListW = XmCreateScrolledList(ntupleForm, "hist1DList", args,ac);
    FreeStringTable(st1);
    XtManageChild(OneDHistVariableListW);
    FirstOneDHistogram = True;
    XtManageChild(OneDHistFormW);
    
    	    
}
char    *FontSel(Widget parent, int showPropFonts, const char *currFont,
            Pixel sampleFG, Pixel sampleBG)
{
    Widget          dialog, form, okButton, cancelButton;
    Widget          styleList, sizeList, fontName, fontList;
    Widget          sizeToggle, propFontToggle = NULL, dispField;
    Widget          nameLabel, sampleLabel;
    Arg             args[MAX_ARGS];
    int             n;
    XmString        tempStr;
    char            bigFont[MAX_FONT_NAME_LEN];
    xfselControlBlkType ctrlBlk;
    Display         *theDisplay;

    ctrlBlk.fontData    = XListFonts(XtDisplay(parent), 
                                     "-*-*-*-*-*-*-*-*-*-*-*-*-*-*", 
                                     MAX_NUM_FONTS, &ctrlBlk.numFonts);
    FindBigFont(&ctrlBlk, bigFont);
    ctrlBlk.oldFont = XLoadQueryFont(XtDisplay(parent), bigFont);
    ctrlBlk.oldFontList = XmFontListCreate(ctrlBlk.oldFont,
                                            XmSTRING_DEFAULT_CHARSET);
    ctrlBlk.sampleFG = sampleFG;
    ctrlBlk.sampleBG = sampleBG;

    dialog  = CreateDialogShell(parent, "Font Selector", args, 0);

    /*  Set up window sizes for form widget */

    n = 0;
    XtSetArg(args[n], XmNautoUnmanage, FALSE); n++;
    XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;

    /*  Create form popup dialog widget */

    form    = XtCreateWidget ("Font Selector", xmFormWidgetClass, dialog, 
                              args, n);

    /*  Create pushbutton widgets */

    n = 0;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
    XtSetArg(args[n], XmNbottomOffset, 4); n++;
    XtSetArg(args[n], XmNtopOffset, 1); n++;
    XtSetArg(args[n], XmNrightPosition, 45); n++;
    XtSetArg(args[n], XmNwidth, 110); n++;
    XtSetArg(args[n], XmNheight, 28); n++;
    XtSetArg(args[n], XmNshowAsDefault, TRUE); n++;
    okButton = XtCreateManagedWidget("OK", xmPushButtonWidgetClass, form,
                                      args, n);

    n = 0;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, okButton); n++;
    XtSetArg(args[n], XmNbottomWidget, okButton); n++;
    XtSetArg(args[n], XmNleftPosition, 55); n++;
    XtSetArg(args[n], XmNwidth, 110); n++;
    XtSetArg(args[n], XmNheight, 28); n++;
    cancelButton = XtCreateManagedWidget("Cancel", xmPushButtonWidgetClass,
                                         form, args, n);

    /*  create font name text widget and the corresponding label */

    n = 0; 
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; 
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++; 
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++; 
    XtSetArg(args[n], XmNbottomWidget, okButton); n++; 
    XtSetArg(args[n], XmNleftPosition, 1); n++; 
    XtSetArg(args[n], XmNrightPosition, 99); n++; 
    XtSetArg(args[n], XmNeditable, True); n++;
    XtSetArg(args[n], XmNeditMode, XmSINGLE_LINE_EDIT); n++;
    XtSetArg(args[n], XmNmaxLength, MAX_FONT_NAME_LEN); n++;
    fontName = XtCreateManagedWidget("fontname", xmTextWidgetClass, form,
                                     args, n);
    RemapDeleteKey(fontName);   /* kludge to handle delete and BS */

    n = 0; 
    tempStr = XmStringCreate("Font Name:", XmSTRING_DEFAULT_CHARSET);
    XtSetArg(args[n], XmNlabelString, tempStr); n++;
    XtSetArg(args[n], XmNmnemonic, 'N'); n++;
    XtSetArg(args[n], XmNuserData, fontName); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++; 
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; 
    XtSetArg(args[n], XmNleftWidget, fontName); n++; 
    XtSetArg(args[n], XmNbottomWidget, fontName); n++;
    XtSetArg(args[n], XmNtopOffset, 1); n++;
    nameLabel = XtCreateManagedWidget("Font Name:", xmLabelWidgetClass,
                                      form, args, n);
    XmStringFree(tempStr);

    /*  create sample display text field widget */

    n = 0;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++; 
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; 
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++; 
    XtSetArg(args[n], XmNrightPosition, 99); n++;
    XtSetArg(args[n], XmNbottomWidget, nameLabel); n++;
    XtSetArg(args[n], XmNleftPosition, 1); n++; 
    XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
    XtSetArg(args[n], XmNvalue, 
            "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789");
            n++;
    XtSetArg(args[n], XmNforeground, sampleFG); n++;
    XtSetArg(args[n], XmNbackground, sampleBG); n++;
    dispField = XtCreateManagedWidget(" ", xmTextFieldWidgetClass, form, 
                                       args, n);

    n = 0; 
    tempStr = XmStringCreate("Sample:", XmSTRING_DEFAULT_CHARSET);
    XtSetArg(args[n], XmNlabelString, tempStr); n++;
    XtSetArg(args[n], XmNmnemonic, 'S'); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++; 
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; 
    XtSetArg(args[n], XmNleftWidget, dispField); n++; 
    XtSetArg(args[n], XmNbottomWidget, dispField); n++;
    XtSetArg(args[n], XmNtopOffset, 1); n++;
    sampleLabel = XtCreateManagedWidget("Font Name:", xmLabelWidgetClass,
            form, args, n);
    XmStringFree(tempStr);

    /*  create toggle buttons */

    n = 0; 
    tempStr = XmStringCreate("Show Size in Points", 
                              XmSTRING_DEFAULT_CHARSET);
    XtSetArg(args[n], XmNlabelString, tempStr); n++;
    XtSetArg(args[n], XmNmnemonic, 'P'); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++; 
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; 
    XtSetArg(args[n], XmNleftPosition, 2); n++; 
    XtSetArg(args[n], XmNtopOffset, 1); n++;
    XtSetArg(args[n], XmNbottomWidget, sampleLabel); n++;
    sizeToggle = XtCreateManagedWidget("sizetoggle", 
                      xmToggleButtonWidgetClass, form, args, n);
    XmStringFree(tempStr);

    if (showPropFonts != ONLY_FIXED)
    {
        n = 0; 
        tempStr = XmStringCreate("Show Proportional Width Fonts", 
                                 XmSTRING_DEFAULT_CHARSET);
        XtSetArg(args[n], XmNlabelString, tempStr); n++;
        XtSetArg(args[n], XmNmnemonic, 'W'); n++;
        XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++; 
        XtSetArg(args[n], XmNtopAttachment, 
                        XmATTACH_OPPOSITE_WIDGET); n++; 
        XtSetArg(args[n], XmNbottomAttachment, 
                        XmATTACH_OPPOSITE_WIDGET); n++; 
        XtSetArg(args[n], XmNrightPosition, 98); n++; 
        XtSetArg(args[n], XmNtopWidget, sizeToggle); n++;
        XtSetArg(args[n], XmNbottomWidget, sizeToggle); n++;
        XtSetArg(args[n], XmNtopOffset, 1); n++;
        propFontToggle = XtCreateManagedWidget("propfonttoggle", 
                            xmToggleButtonWidgetClass, form, args, n);
        XmStringFree(tempStr);
    }

    /*  create scroll list widgets */
    /*  "Font" list */

    n = 0;
    tempStr = XmStringCreate("Font:", XmSTRING_DEFAULT_CHARSET);
    XtSetArg(args[n], XmNlabelString, tempStr); n++;
    XtSetArg(args[n], XmNmnemonic, 'F'); n++; 
    XtSetArg(args[n], XmNtopOffset, 2); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
    XtSetArg(args[n], XmNleftPosition, 1); n++;
    nameLabel = XtCreateManagedWidget("Font:", xmLabelWidgetClass, form, 
                                      args, n);
    XmStringFree(tempStr);

    n = 0;
    XtSetArg(args[n], XmNvisibleItemCount, 15); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
    XtSetArg(args[n], XmNbottomWidget, sizeToggle); n++;
    XtSetArg(args[n], XmNtopWidget, nameLabel); n++;
    XtSetArg(args[n], XmNleftWidget, nameLabel); n++;
    XtSetArg(args[n], XmNrightPosition, 52); n++;
    fontList = XmCreateScrolledList(form, "fontlist", args, n);
    AddMouseWheelSupport(fontList);
    XtManageChild(fontList);
    XtVaSetValues(nameLabel, XmNuserData, fontList, NULL);

    /* "Style" list */

    n = 0;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
    XtSetArg(args[n], XmNtopWidget, nameLabel); n++;
    XtSetArg(args[n], XmNleftOffset, 5); n++;
    XtSetArg(args[n], XmNleftWidget, XtParent(fontList)); n++;
    XtSetArg(args[n], XmNbottomWidget, XtParent(fontList)); n++;
    XtSetArg(args[n], XmNrightPosition, 85); n++;
    styleList = XmCreateScrolledList(form, "stylelist", args, n);
    AddMouseWheelSupport(styleList);
    XtManageChild(styleList);

    n = 0;
    tempStr = XmStringCreate("Style:", XmSTRING_DEFAULT_CHARSET);
    XtSetArg(args[n], XmNmnemonic, 'y'); n++; 
    XtSetArg(args[n], XmNuserData, styleList); n++;
    XtSetArg(args[n], XmNlabelString, tempStr); n++;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNbottomWidget, XtParent(styleList)); n++;
    XtSetArg(args[n], XmNleftWidget, XtParent(styleList)); n++;
    XtCreateManagedWidget("Style:", xmLabelWidgetClass, form, args, n);
    XmStringFree(tempStr);

    /*  "Size" list */

    n = 0;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, nameLabel); n++;
    XtSetArg(args[n], XmNleftWidget, XtParent(styleList)); n++;
    XtSetArg(args[n], XmNbottomWidget, XtParent(fontList)); n++;
    XtSetArg(args[n], XmNleftOffset, 5); n++;
    XtSetArg(args[n], XmNrightPosition, 99); n++;
    sizeList = XmCreateScrolledList(form, "sizelist", args, n);
    AddMouseWheelSupport(sizeList);
    XtManageChild(sizeList);

    n = 0;
    tempStr = XmStringCreate("Size:", XmSTRING_DEFAULT_CHARSET);
    XtSetArg(args[n], XmNlabelString, tempStr); n++;
    XtSetArg(args[n], XmNmnemonic, 'z'); n++; 
    XtSetArg(args[n], XmNuserData, sizeList); n++;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNbottomWidget, XtParent(sizeList)); n++;
    XtSetArg(args[n], XmNleftWidget, XtParent(sizeList)); n++;
    XtCreateManagedWidget("Size:", xmLabelWidgetClass, form, args, n);
    XmStringFree(tempStr);

    /*  update form widgets cancel button */

    n = 0;
    XtSetArg(args[n], XmNcancelButton, cancelButton); n++;
    XtSetValues(form, args, n);


    /*  update application's control block structure */

    ctrlBlk.form            = form;
    ctrlBlk.okButton        = okButton;
    ctrlBlk.cancelButton    = cancelButton;
    ctrlBlk.fontList        = fontList;
    ctrlBlk.styleList       = styleList;
    ctrlBlk.sizeList        = sizeList;
    ctrlBlk.fontNameField   = fontName;
    ctrlBlk.sizeToggle      = sizeToggle;
    if (showPropFonts != ONLY_FIXED)
        ctrlBlk.propFontToggle  = propFontToggle;
    ctrlBlk.dispField       = dispField;
    ctrlBlk.exitFlag        = FALSE;
    ctrlBlk.destroyedFlag   = FALSE;
    ctrlBlk.showPropFonts   = showPropFonts;
    ctrlBlk.showSizeInPixels = TRUE;
    ctrlBlk.sel1            = NULL;
    ctrlBlk.sel2            = NULL;
    ctrlBlk.sel3            = NULL;
    ctrlBlk.fontName        = NULL;

    setupScrollLists(NONE, ctrlBlk);    /* update scroll lists */ 

    if (showPropFonts == PREF_PROP)
        XmToggleButtonSetState(propFontToggle, TRUE, FALSE); 
        
    /*  Register callback functions */

    if (showPropFonts != ONLY_FIXED)
        XtAddCallback(propFontToggle, XmNvalueChangedCallback, 
                (XtCallbackProc)propFontToggleAction, (char *)&ctrlBlk);
    XtAddCallback(sizeToggle, XmNvalueChangedCallback,
            (XtCallbackProc)sizeToggleAction, (char *)&ctrlBlk);
    XtAddCallback(fontList, XmNbrowseSelectionCallback,
            (XtCallbackProc)fontAction, (char *)&ctrlBlk);
    XtAddCallback(styleList, XmNbrowseSelectionCallback,
            (XtCallbackProc)styleAction, (char *)&ctrlBlk);
    XtAddCallback(sizeList, XmNbrowseSelectionCallback,
            (XtCallbackProc)sizeAction, (char *)&ctrlBlk);
    XtAddCallback(okButton, XmNactivateCallback,
            (XtCallbackProc)okAction, (char *)&ctrlBlk);
    XtAddCallback(cancelButton, XmNactivateCallback,
            (XtCallbackProc)cancelAction, (char *)&ctrlBlk);

    /* add event handler to setup input focus at start to scroll list */

    XtAddEventHandler(fontList, FocusChangeMask, FALSE,
            (XtEventHandler)setFocus, (char *)&ctrlBlk);
    XmProcessTraversal(fontList, XmTRAVERSE_CURRENT);

    /*  setup tabgroups */

    XmAddTabGroup(fontList);
    XmAddTabGroup(styleList);
    XmAddTabGroup(sizeList);
    XmAddTabGroup(sizeToggle);
    if (showPropFonts != ONLY_FIXED)
        XmAddTabGroup(propFontToggle);
    XmAddTabGroup(fontName);
    XmAddTabGroup(okButton);
    XmAddTabGroup(cancelButton);

    /* Make sure that we don't try to access the dialog if the user
       destroyed it (possibly indirectly, by destroying the parent). */
    XtAddCallback(dialog, XmNdestroyCallback,
            (XtCallbackProc)destroyCB, (char *)&ctrlBlk);
        
    /*  Link Motif Close option to cancel action */

    AddMotifCloseCallback(dialog, (XtCallbackProc)cancelAction, &ctrlBlk);

    /*  Handle dialog mnemonics  */

    AddDialogMnemonicHandler(form, FALSE);

    /*  Realize Widgets  */

    ManageDialogCenteredOnPointer(form);

    /* set up current font parameters */

    if (currFont[0] != '\0')
        startupFont(&ctrlBlk, currFont); 

    /* Make sure that we can still access the display in case the form
       gets destroyed */
    theDisplay = XtDisplay(form);

    /*  enter event loop */

    while (! ctrlBlk.exitFlag && ! ctrlBlk.destroyedFlag)
        XtAppProcessEvent(XtWidgetToApplicationContext(form), XtIMAll);

    if (! ctrlBlk.destroyedFlag) {
        /* Don't let the callback destroy the font name */
        XtRemoveCallback(dialog, XmNdestroyCallback,
                (XtCallbackProc)destroyCB, (char *)&ctrlBlk);
        XtDestroyWidget(dialog);
    }

    if (ctrlBlk.oldFont != NULL)
    {
        XFreeFont(theDisplay, ctrlBlk.oldFont);
        XmFontListFree(ctrlBlk.oldFontList);
    }

    return(ctrlBlk.fontName);
}
Exemple #5
0
/*
** HandleCustomExistFileSB
**
** Manage a customized file selection box for opening existing files.
** Use this if you want to change the standard file selection dialog
** from the defaults provided in GetExistingFilename, but still
** want take advantage of the button processing, help messages, and
** file checking of GetExistingFilename.
**
**  Arguments:
**
**	Widget  existFileSB   - your custom file selection box widget id
**	char *  filename      - a string to receive the selected filename
**				(this string will not be altered if the
**				user pressed the cancel button)	
**
**  Returns:	GFN_OK	      - file was selected and OK button pressed	
**		GFN_CANCEL    - Cancel button pressed and no returned file
**
*/
int HandleCustomExistFileSB(Widget existFileSB, char *filename)
{
    Boolean   done_with_dialog=False; /* ok to destroy dialog flag	   */
    char      *fileString;            /* C string for file selected        */
    char      *dirString;             /* C string for dir of file selected */
    XmString  cFileString;            /* compound string for file selected */
    XmString  cDir;	              /* compound directory selected	   */
    XmString  cPattern;               /* compound filter pattern	   */
    Widget    help;		      /* help window form dialog	   */
#if XmVersion < 1002
    int       i;
#endif

    XtAddCallback(existFileSB, XmNokCallback, (XtCallbackProc)existOkCB,
    	    &done_with_dialog);
    XtAddCallback(existFileSB, XmNcancelCallback, (XtCallbackProc)existCancelCB,
	    &done_with_dialog);
    AddMotifCloseCallback(XtParent(existFileSB), (XtCallbackProc)existCancelCB,
	    &done_with_dialog);
    help = createPanelHelp(existFileSB, HelpExist, "Selecting Files to Open");
    createErrorDialog(existFileSB);
    XtAddCallback(existFileSB, XmNhelpCallback, (XtCallbackProc)existHelpCB,
    	    (char *)help);
    if (DefaultDirectory != NULL || DefaultPattern != NULL)
    	XtVaSetValues(existFileSB, XmNdirectory, DefaultDirectory,
    		XmNpattern, DefaultPattern, NULL);
#ifndef SGI_CUSTOM
    makeListTypeable(XmFileSelectionBoxGetChild(existFileSB,XmDIALOG_LIST));
    makeListTypeable(XmFileSelectionBoxGetChild(existFileSB,XmDIALOG_DIR_LIST));
#if XmVersion >= 1002
    XtVaSetValues(existFileSB, XmNinitialFocus, XtParent(
    	    XmFileSelectionBoxGetChild(existFileSB, XmDIALOG_LIST)), NULL);
#endif
#endif
    ManageDialogCenteredOnPointer(existFileSB);

#ifndef SGI_CUSTOM
    /* Typing in the directory list is dependent on the list being in the
       same form of alphabetical order expected by the character processing
       routines.  As of about 1.2.3, some Motif libraries seem to have a
       different idea of ordering than is usual for Unix directories.
       To sort them properly, we have to patch the directory and file
       searching routines to re-sort the lists when they change */
    XtVaGetValues(existFileSB, XmNdirSearchProc, &OrigDirSearchProc,
    	    XmNfileSearchProc, &OrigFileSearchProc, NULL);
    XtVaSetValues(existFileSB, XmNdirSearchProc, replacementDirSearchProc,
    	    XmNfileSearchProc, replacementFileSearchProc, NULL);
    sortWidgetList(XmFileSelectionBoxGetChild(existFileSB, XmDIALOG_DIR_LIST));
    sortWidgetList(XmFileSelectionBoxGetChild(existFileSB, XmDIALOG_LIST));
#if XmVersion < 1002
    /* To give file list initial focus, revoke default button status for
       the "OK" button.  Dynamic defaulting will restore it as the default
       button after the keyboard focus is established.  Note the voodoo
       below: calling XmProcess traversal extra times (a recommendation from
       OSF technical support) somehow succeedes in giving the file list focus */
    XtVaSetValues(existFileSB, XmNdefaultButton, NULL, NULL);
    for (i=1; i<30; i++)
    	XmProcessTraversal(XmFileSelectionBoxGetChild(existFileSB,
    		XmDIALOG_LIST), XmTRAVERSE_CURRENT);
#endif
#endif /* SGI_CUSTOM */

    while (!done_with_dialog)
        XtAppProcessEvent(XtWidgetToApplicationContext(existFileSB), XtIMAll);
    
    if (SelectResult == GFN_OK) {
	XtVaGetValues(existFileSB, XmNdirSpec, &cFileString, XmNdirectory,
		&cDir, XmNpattern, &cPattern, NULL);
	/* Undocumented: file selection box widget allocates copies of these
	   strings on getValues calls.  I have risked freeing them to avoid
	   memory leaks, since I assume other developers have made this same
	   realization, therefore OSF can't easily go back and change it */
	if (DefaultDirectory != NULL) XmStringFree(DefaultDirectory);
	if (DefaultPattern != NULL) XmStringFree(DefaultPattern);
	DefaultDirectory = cDir;
	DefaultPattern = cPattern;
	XmStringGetLtoR(cFileString, XmSTRING_DEFAULT_CHARSET, &fileString);
        /* Motif 2.x seem to contain a bug that causes it to return only 
           the relative name of the file in XmNdirSpec when XmNpathMode is set
           to XmPATH_MODE_RELATIVE (through X resources), although the man
           page states that it always returns the full path name. We can
           easily work around this by checking that the first character of the
           file name is a `/'. */
#ifdef VMS
       /* VMS  won't return `/' as the 1st character of the full file spec.
         `:' terminates the device name and is not allowed elsewhere */
        if (strchr(fileString, ':') != NULL) {
#else
        if (fileString[0] == '/') {
#endif        /* VMS */
	    /* The directory name is already present in the file name or
	       the user entered a full path name. */
	    strcpy(filename, fileString);
	} else {
	    /* Concatenate the directory name and the file name */
   	    XmStringGetLtoR(cDir, XmSTRING_DEFAULT_CHARSET, &dirString);
	    strcpy(filename, dirString);
	    strcat(filename, fileString);
  	    XtFree(dirString);
	}
	XmStringFree(cFileString);
	XtFree(fileString);
    }
    /* Destroy the dialog _shell_ iso. the dialog. Normally, this shouldn't
       be necessary as the shell is destroyed automatically when the dialog
       is. However, due to a bug in various Lesstif versions, the latter 
       messes up the grab cascades and leaves new windows without grabs, such
       that they appear to be frozen. */
    XtDestroyWidget(XtParent(existFileSB));
    return SelectResult;
}


/*
** HandleCustomNewFileSB
**
** Manage a customized file selection box for opening new files.
**
**  Arguments:
**
**	Widget  newFileSB     - your custom file selection box widget id
**	char *  filename      - a string to receive the selected filename
**				(this string will not be altered if the
**				user pressed the cancel button)	
**  	char*	defaultName   - default name to be pre-entered in filename
**  	    	    	    	text field.
**
**  Returns:	GFN_OK	      - file was selected and OK button pressed	
**		GFN_CANCEL    - Cancel button pressed and no returned file
**
*/
int HandleCustomNewFileSB(Widget newFileSB, char *filename, char *defaultName)
{
    Boolean   done_with_dialog=False; /* ok to destroy dialog flag	   */
    Widget    help;		      /* help window form dialog	   */
    XmString  cFileString;            /* compound string for file selected */
    XmString  cDir;	              /* compound directory selected	   */
    XmString  cPattern;               /* compound filter pattern	   */
    char      *fileString;            /* C string for file selected        */
    char      *dirString;             /* C string for dir of file selected */
#if XmVersion < 1002
    int       i;
#endif

    XtAddCallback(newFileSB, XmNokCallback, (XtCallbackProc)newFileOKCB,
    	    &done_with_dialog);
    XtAddCallback(newFileSB, XmNcancelCallback, (XtCallbackProc)newFileCancelCB,
	    &done_with_dialog);

#ifndef SGI_CUSTOM
    makeListTypeable(XmFileSelectionBoxGetChild(newFileSB,XmDIALOG_LIST));
    makeListTypeable(XmFileSelectionBoxGetChild(newFileSB,XmDIALOG_DIR_LIST));
#endif
    if (DefaultDirectory != NULL || DefaultPattern != NULL)
    	XtVaSetValues(newFileSB, XmNdirectory, DefaultDirectory,
    		XmNpattern, DefaultPattern, NULL);
    help = createPanelHelp(newFileSB, HelpNew, "Saving a File");
    createYesNoDialog(newFileSB);
    createErrorDialog(newFileSB);
    XtAddCallback(newFileSB, XmNhelpCallback, (XtCallbackProc)newHelpCB, 
    	    (char *)help);
    if (defaultName != NULL) {
	Widget nameField = XmFileSelectionBoxGetChild(newFileSB, XmDIALOG_TEXT);
	XmTextInsert(nameField, XmTextGetLastPosition(nameField), defaultName);
    }
#if XmVersion >= 1002
#ifndef SGI_CUSTOM
    XtVaSetValues(newFileSB, XmNinitialFocus, 
    	    XmFileSelectionBoxGetChild(newFileSB, XmDIALOG_TEXT), NULL);
#else /* SGI_CUSTOM */
    { Widget finder = XmFileSelectionBoxGetChild(newFileSB, SgDIALOG_FINDER);
      if ( finder != NULL )
    	  XtVaSetValues(newFileSB, XmNinitialFocus, finder, NULL);
    }
#endif
#endif
    ManageDialogCenteredOnPointer(newFileSB);

#ifndef SGI_CUSTOM
#if XmVersion < 1002
    /* To give filename text initial focus, revoke default button status for
       the "OK" button.  Dynamic defaulting will restore it as the default
       button after the keyboard focus is established.  Note the voodoo
       below: calling XmProcess traversal FOUR times (a recommendation from
       OSF technical support) somehow succeedes in changing the focus */
    XtVaSetValues(newFileSB, XmNdefaultButton, NULL, NULL);
    for (i=1; i<30; i++)
    	XmProcessTraversal(XmFileSelectionBoxGetChild(newFileSB, XmDIALOG_TEXT),
	    XmTRAVERSE_CURRENT);
#endif

    /* Typing in the directory list is dependent on the list being in the
       same form of alphabetical order expected by the character processing
       routines.  As of about 1.2.3, some Motif libraries seem to have a
       different idea of ordering than is usual for Unix directories.
       To sort them properly, we have to patch the directory and file
       searching routines to re-sort the lists when they change */
    XtVaGetValues(newFileSB, XmNdirSearchProc, &OrigDirSearchProc,
    	    XmNfileSearchProc, &OrigFileSearchProc, NULL);
    XtVaSetValues(newFileSB, XmNdirSearchProc, replacementDirSearchProc,
    	    XmNfileSearchProc, replacementFileSearchProc, NULL);
    sortWidgetList(XmFileSelectionBoxGetChild(newFileSB, XmDIALOG_DIR_LIST));
    sortWidgetList(XmFileSelectionBoxGetChild(newFileSB, XmDIALOG_LIST));
#endif /* SGI_CUSTOM */
    while (!done_with_dialog)
        XtAppProcessEvent (XtWidgetToApplicationContext(newFileSB), XtIMAll);

    if (SelectResult == GFN_OK) {
	/* See note in existing file routines about freeing the values
	   obtained in the following call */
	XtVaGetValues(newFileSB, XmNdirSpec, &cFileString, XmNdirectory,
		&cDir, XmNpattern, &cPattern, NULL);
	if (DefaultDirectory != NULL) XmStringFree(DefaultDirectory);
	if (DefaultPattern != NULL) XmStringFree(DefaultPattern);
	DefaultDirectory = cDir;
	DefaultPattern = cPattern;
	XmStringGetLtoR(cFileString, XmSTRING_DEFAULT_CHARSET, &fileString);
	/* See note in existing file routines about Motif 2.x bug. */
#ifdef VMS
	/* VMS  won't return `/' as the 1st character of the full file spec.
	 `:' terminates the device name and is not allowed elsewhere */
	if (strchr(fileString, ':') != NULL) {
#else
	if (fileString[0] == '/') {
#endif /* VMS */
	    /* The directory name is already present in the file name or
	       the user entered a full path name. */
	    strcpy(filename, fileString);
	} else {
	    /* Concatenate the directory name and the file name */
   	    XmStringGetLtoR(cDir, XmSTRING_DEFAULT_CHARSET, &dirString);
	    strcpy(filename, dirString);
	    strcat(filename, fileString);
  	    XtFree(dirString);
	}
	XmStringFree(cFileString);
	XtFree(fileString);
    }
    XtDestroyWidget(newFileSB);
    return SelectResult;
}

/*
** Return current default directory used by GetExistingFilename.
** Can return NULL if no default directory has been set (meaning
** use the application's current working directory) String must
** be freed by the caller using XtFree.
*/
char *GetFileDialogDefaultDirectory(void)
{
    char *string;
    
    if (DefaultDirectory == NULL)
    	return NULL;
    XmStringGetLtoR(DefaultDirectory, XmSTRING_DEFAULT_CHARSET, &string);
    return string;
}