From: proberts@informix.com (Paul Roberts)
Newsgroups: comp.windows.x.motif
Subject: Popup displays and GCS
Date: 14 Aug 92 17:25:07 GMT
Organization: Informix Software, Inc.
Originator: proberts@moose


I have been creating pop up dialogs along the model suggested by Young p. 114
and can get things to work reasonably well with a few exceptions.  Basicly
I code the following:

main()
{
   Widget toplevel;
   Widget form;
   Widget button;
   Widget dialog;

   toplevel = XtInitialize( argv[0], "fred", NULL, 0, &argc, argv);

   form =  XtCreateManagedWidget( "form", xmFormWidgetClass, toplevel, al, ac);

   button = XtCreateManageddWidget( "button", xmPushButtonWidgetClass, 
                                    form, al, ac);

   dialog = create_dialog( toplevel );

   XtAddCallback( button, XmNactivateCallback, show_dialog, dialog);

   XtRealizeWidget( toplevel );

   XtMainLoop();

} /* end main */

Show dialog is just XtManageChild(dialog) like Young p. 115

Create dialog is along the lines of:

Widget create_dialog( parent )
Widget parent;
{
   Widget local_dialog;

   /* logo resources */
   XGCValues   arrow_val;
   pixmap_data arrow_pd;
   Widget      arrow;

   local_dialog = XmCreateFormDialog( parent, "dialog", al, ac);

   /*-- create a arrow image  --*/
   ac = 0;
   arrow = XtCreateManagedWidget( "arrow",
                               xmDrawingAreaWidgetClass, local_dialog, al,ac);

   /* Use the forground and background colors of the logo to
      create a graphics context */
   ac = 0;
   XtSetArg (al[ac], XtNforeground, &downHead_val.foreground); ac++;
   XtSetArg (al[ac], XtNbackground, &downHead_val.background); ac++;
   XtGetValues (downHead, al, ac);
   arrow_pd.gc = XtGetGC (arrow, GCForeground|GCBackground,
                            &arrow_val);

   arrow_pd.width  = arrow_width;
   arrow_pd.height = arrow_height;
   arrow_pd.pix = create_pixmap(arrow, arrow_pd.gc, arrow_bits,                          arrow_width, arrow_height);

  XtAddCallback (arrow, XmNexposeCallback, redisplay, &arrow_pd);
  XtAddCallback (arrow, XmNresizeCallback, resize, &arrow_pd);


   /* add buttons and text widgets and stuff as above */

   return local_dialog;

} /* end create_dialog() */


Problem 1)

I can't seem to get a handle on the graphics contexts of the dialog.
I want to add a bit map and used Young p. 191 as an example.  create_pixmap()
and picmap_data are defined as he has it and this works fine at the main
level.
 
Things will compile fine, however when the call back is run I get:

X Error of failed request:  BadGC (invalid GC parameter)
  Major opcode of failed request:  56 (X_ChangeGC)
  Resource id in failed request:  0xf7800128
  Serial number of failed request:  465
  Current serial number in output stream:  515


and the program crashes.

Problem 2)

This might be related to problem 1, but I don't have a good grasp on the 
hearatige of my dialog box.  I set the resources in a file that my xenvironment
is set to.  So to set my dialog box I would thing something like:

fred.dialog.width: 100

would set the width to 100, but it dosn't quite work.

fred*dialog.width: 100

works fine.  Something about changing . for * 


Anyhow, any new insight into this problem would be greatly appreciated.


+-----------------------------------------------------------------------------+
| "Just a Pedantics major from Berkeley" |            Randy McFarland         |
|                        - Spalding Gray | mcfar@sunfse.ese.lmsc.lockheed.com |
+-----------------------------------------------------------------------------+