Problem with compound string with tabs in a dialog - Motif

This is a discussion on Problem with compound string with tabs in a dialog - Motif ; Hi, I want to have tabbed output in the message part of a dialog. I am trying to do this in the simplest way, but I can't get it to work. I cobbled the included example from the "Motif Programming ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Problem with compound string with tabs in a dialog

  1. Problem with compound string with tabs in a dialog

    Hi,

    I want to have tabbed output in the message part of a dialog. I am
    trying to do this in the simplest way, but I can't get it to work. I
    cobbled the included example from the "Motif Programming Manual, VOLUME
    SIX A". If anybody can see where I'm going wrong, I would appreciate a
    response. My alternative is to go to a custom dialog, using a table or
    something like that. Maybe even a fixed font with spaces to line things
    up. I can get tabs to work in a label, but not the dialog as below.

    -jim

    ---cut here---cut here---cut here---cut here---cut here---cut here
    /*
    (sun SUNWspro, Motif Version 2.1.0) cc junk.c -lXm -lXt
    (linux Motif Version 2.2.2) gcc junk.c -L/usr/X11R6/lib -lXm -lXt
    */

    #include
    #include

    Widget PostDialog (Widget parent, int dialog_type, char *msg){
    Widget dialog;
    XmString text;

    // tabs
    const int MAX_COLUMNS = 5;
    XmTab tabs[MAX_COLUMNS];
    XmTabList tablist;
    XmRendition rendition;
    XmRenderTable rtable;
    int n,i;
    Arg args[5];

    /* Create tab stops */
    for (i = 0; i < MAX_COLUMNS; i++) {
    tabs[i] = XmTabCreate((float)1.5, XmINCHES,
    ((i == 0) ? XmABSOLUTE : XmRELATIVE),
    XmALIGNMENT_BEGINNING, ".");
    }
    /* Create the XmTabList from the XmTab objects */
    tablist = XmTabListInsertTabs(NULL, tabs, XtNumber(tabs), 0);

    dialog = XmCreateMessageDialog (parent, "dialog", NULL, 0);
    text = XmStringGenerate(msg,NULL, XmCHARSET_TEXT, NULL);
    XtVaSetValues (dialog,
    XmNdialogType, dialog_type,
    XmNmessageString, text,
    NULL);
    /* Create an XmRendition that uses the XmTabList */
    n = 0;
    XtSetArg(args[n], XmNtabList, tablist); n++;
    rendition = XmRenditionCreate(dialog, XmFONTLIST_DEFAULT_TAG,args, n);
    rtable = XmRenderTableAddRenditions(NULL,&rendition,1,XmMERGE_NEW);
    XtVaSetValues (dialog, XmNrenderTable, rtable, NULL);
    XmStringFree (text);
    XtManageChild (dialog);
    return dialog;
    }

    int main(int argc, char **argv){
    Widget shell, label;
    XtAppContext app;

    /* Create a shell. */

    shell = XtAppInitialize(&app, "Rendition", NULL, 0,
    &argc, argv, NULL, NULL, 0);

    PostDialog(shell, XmDIALOG_MESSAGE, "message\nmessage2\tmessage3");

    XtRealizeWidget(shell);
    XtAppMainLoop(app);
    return 1;
    }

    ---cut here---cut here---cut here---cut here---cut here---cut here

  2. Re: Problem with compound string with tabs in a dialog



    Jim Graf wrote:
    >
    > Hi,
    >
    > I want to have tabbed output in the message part of a dialog. I am
    > trying to do this in the simplest way, but I can't get it to work. I
    > cobbled the included example from the "Motif Programming Manual, VOLUME
    > SIX A". If anybody can see where I'm going wrong, I would appreciate a
    > response. My alternative is to go to a custom dialog, using a table or
    > something like that. Maybe even a fixed font with spaces to line things
    > up. I can get tabs to work in a label, but not the dialog as below.
    >
    > -jim
    >
    > ---cut here---cut here---cut here---cut here---cut here---cut here
    > /*
    > (sun SUNWspro, Motif Version 2.1.0) cc junk.c -lXm -lXt
    > (linux Motif Version 2.2.2) gcc junk.c -L/usr/X11R6/lib -lXm -lXt
    > */
    >
    > #include
    > #include
    >
    > Widget PostDialog (Widget parent, int dialog_type, char *msg){
    > Widget dialog;
    > XmString text;
    >
    > // tabs
    > const int MAX_COLUMNS = 5;
    > XmTab tabs[MAX_COLUMNS];
    > XmTabList tablist;
    > XmRendition rendition;
    > XmRenderTable rtable;
    > int n,i;
    > Arg args[5];
    >
    > /* Create tab stops */
    > for (i = 0; i < MAX_COLUMNS; i++) {
    > tabs[i] = XmTabCreate((float)1.5, XmINCHES,
    > ((i == 0) ? XmABSOLUTE : XmRELATIVE),
    > XmALIGNMENT_BEGINNING, ".");
    > }
    > /* Create the XmTabList from the XmTab objects */
    > tablist = XmTabListInsertTabs(NULL, tabs, XtNumber(tabs), 0);
    >
    > dialog = XmCreateMessageDialog (parent, "dialog", NULL, 0);
    > text = XmStringGenerate(msg,NULL, XmCHARSET_TEXT, NULL);
    > XtVaSetValues (dialog,
    > XmNdialogType, dialog_type,
    > XmNmessageString, text,
    > NULL);
    > /* Create an XmRendition that uses the XmTabList */
    > n = 0;
    > XtSetArg(args[n], XmNtabList, tablist); n++;
    > rendition = XmRenditionCreate(dialog, XmFONTLIST_DEFAULT_TAG,args, n);
    > rtable = XmRenderTableAddRenditions(NULL,&rendition,1,XmMERGE_NEW);
    > XtVaSetValues (dialog, XmNrenderTable, rtable, NULL);


    Try setting the XmNrendertable resource of the label child of the
    dialog, not the dialog itself:

    XtVaSetValues( XmMessageBoxGetChild(dialog,
    XmDIALOG_MESSAGE_LABEL),
    XmNrenderTable, rtable, NULL);

    > XmStringFree (text);
    > XtManageChild (dialog);
    > return dialog;
    > }
    >
    > int main(int argc, char **argv){
    > Widget shell, label;
    > XtAppContext app;
    >
    > /* Create a shell. */
    >
    > shell = XtAppInitialize(&app, "Rendition", NULL, 0,
    > &argc, argv, NULL, NULL, 0);
    >
    > PostDialog(shell, XmDIALOG_MESSAGE, "message\nmessage2\tmessage3");
    >
    > XtRealizeWidget(shell);
    > XtAppMainLoop(app);
    > return 1;
    > }
    >
    > ---cut here---cut here---cut here---cut here---cut here---cut here



    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Technical Architect, Common User Interface Services
    M/S 2R-94 (206)544-5225

+ Reply to Thread