🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Indu Bingham Thu, 08 Aug 1996 00:00
Dialog Modality
#1
Author: Indu Bingham
Date: Thu, 08 Aug 1996 00:00
219 lines
6442 bytes
Here is the issue:

I have the Information dialog which is the child of the form widget
and the modality XmDIALOG_FULL_APPLICATION_MODAL and
XmDIALOG_PRIMARY_APPLICATION_MODAL does not work but the
XmDIALOG_SYSTEM_MODAL works fine.

But when I create some pushbuttons and popup a dialog with the
activate callback, all the three MODALs work fine.

Is the issue how I invoke the dialog matter, or is this simply a bug
if it is not bug but why does the XmDIALOG_SYSTEM_MODAL work fine in the first
case. 

I have called the first case code bugmodal.c  and the second one the
modal.c

Any ideas relating to this issue appreciated.


-indu
indu@sgi.com

/* bugmodal.c */

#include <Xm/Xm.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>

#include <stdio.h>

#include <Xm/Text.h>
#include <Xm/LabelG.h>
#include <Xm/ToggleB.h>
#include <Xm/PushB.h>
#include <Xm/SeparatoG.h>
#include <Xm/PushBG.h>
#include <Xm/RowColumn.h>
#include <Xm/ScrolledW.h>
#include <Xm/Form.h>
#include <Xm/BulletinB.h>
#include <Xm/MessageB.h>

Widget TopLevelWidget;

extern void startup(Widget);


void main (int argc, char **argv)
{

   XtAppContext app_context;
   Arg wargs[5];
   int n;


   n = 0;
   XtSetArg (wargs[n], XmNtitle, "Test Program"); n++;
   TopLevelWidget = XtAppInitialize (
      &app_context,
      "",
      NULL,
     0,
      &argc, (String *)argv,
      NULL,
      wargs,
      n);
   
   startup(TopLevelWidget);

   XtRealizeWidget (TopLevelWidget);
   XtAppMainLoop (app_context);
}


void startup (Widget parent)
{
   Widget MainForm;
   Widget mb, pb;

   XmString t;

       /* Create Main Form */

        MainForm = XtVaCreateManagedWidget( "MainForm",
                        xmBulletinBoardWidgetClass, parent,
                        XmNdefaultPosition, FALSE,
                        XmNheight, 400,
                        XmNwidth, 700,
                        XmNy, 0,
                        XmNx, 0,
     /*  XmNshadowThickness, 3, Scrolled Window should inherit dynamically */
                        XmNunitType, XmPIXELS,
                        XmNresizePolicy, XmRESIZE_NONE,
                        NULL );

   pb = XtVaCreateManagedWidget("Try to push ME!", 
                          xmPushButtonWidgetClass, MainForm, NULL); 

   /* Create Application modal message dialog. */
   mb = XmCreateInformationDialog(MainForm, "mb", NULL, 0);
   t = XmStringCreateSimple( "You should have to respond first!! Hit it...");

/*
   XtVaSetValues( mb,
     XmNmessageString, t,
     XmNdialogStyle,  XmDIALOG_FULL_APPLICATION_MODAL, NULL);
*/

/* System modal works for 5.3....*/
/*
   XtVaSetValues( mb,
     XmNmessageString, t,
     XmNdialogStyle,  XmDIALOG_SYSTEM_MODAL, NULL);
*/

   XtVaSetValues( mb,
     XmNmessageString, t,
     XmNdialogStyle,  XmDIALOG_PRIMARY_APPLICATION_MODAL, NULL);

   XmStringFree(t);
   XtUnmanageChild(XmMessageBoxGetChild(mb, XmDIALOG_HELP_BUTTON));
   XtManageChild (mb);
   XtPopup (XtParent(mb), XtGrabNone);
}

oooooooooooooooooooooooooo CUT HERE oooooooooooooooooooooooooooooooooooooo

/* Here is the second program called  modal.c */

#include <Xm/RowColumn.h>
#include <Xm/MessageB.h>
#include <Xm/PushB.h>

/* main() --create a pushbutton whose callback pops up a dialog box */
main(argc, argv)
char *argv[];
{
    XtAppContext app;
    Widget toplevel, button, rowcolumn;
    void pushed();

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

    rowcolumn = XtCreateManagedWidget("rowcolumn",
        xmRowColumnWidgetClass, toplevel, NULL, 0);

    button = XtCreateManagedWidget("application-modal",
        xmPushButtonWidgetClass, rowcolumn, NULL, 0);
    XtAddCallback(button, XmNactivateCallback,
        pushed, XmDIALOG_FULL_APPLICATION_MODAL);
    button = XtCreateManagedWidget("primary-modal",
        xmPushButtonWidgetClass, rowcolumn, NULL, 0);
    XtAddCallback(button, XmNactivateCallback,
        pushed, XmDIALOG_PRIMARY_APPLICATION_MODAL);
    button = XtCreateManagedWidget("system-modal",
        xmPushButtonWidgetClass, rowcolumn, NULL, 0);
    XtAddCallback(button, XmNactivateCallback, pushed,
        XmDIALOG_SYSTEM_MODAL);

    XtRealizeWidget(toplevel);
    XtAppMainLoop(app);
}

/* pushed() --the callback routine for the main app's pushbutton.
 * Create either a full-application or system modal dialog box.
 */
void
pushed(w, modality)
Widget w;
unsigned char modality;
{
    static Widget dialog;
    XmString t;
    extern void dlg_callback();

    /* See if we've already created this dialog -- if so,
     * we don't need to create it again.  Just re-pop it up.
     */
    if (!dialog) {
        Arg args[2];
        XmString ok = XmStringCreateSimple("OK");
        XtSetArg(args[0], XmNautoUnmanage, False);
        XtSetArg(args[1], XmNcancelLabelString, ok);
        dialog = XmCreateInformationDialog(w, "notice", args, 2);
        XtAddCallback(dialog, XmNcancelCallback, dlg_callback, NULL);
        XtUnmanageChild(
            XmMessageBoxGetChild(dialog, XmDIALOG_OK_BUTTON));
        XtUnmanageChild(
            XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
    }
    t = XmStringCreateSimple("You must reply to this message now!");
    XtVaSetValues(dialog,
        XmNmessageString,    t,
        XmNdialogStyle,      modality,
        NULL);
    XmStringFree(t);
    XtManageChild(dialog);
   XtManageChild(dialog);
    XtPopup(XtParent(dialog), XtGrabNone);
}

void
dlg_callback(dialog, client_data, cbs)
Widget dialog;
XtPointer client_data;
XmAnyCallbackStruct *cbs;
{
    XtPopdown(XtParent(dialog));
}

-- 
Indu Bingham
http://reality.sgi.com/employees/indu_csd/indu.html
indu@sgi.com

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads