home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / windows / x / motif / 5623 < prev    next >
Encoding:
Text File  |  1992-08-14  |  3.8 KB  |  126 lines

  1. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!wupost!cs.utexas.edu!sun-barr!male.EBay.Sun.COM!exodus.Eng.Sun.COM!sun!amdcad!weitek!pyramid!infmx!proberts
  2. From: proberts@informix.com (Paul Roberts)
  3. Newsgroups: comp.windows.x.motif
  4. Subject: Popup displays and GCS
  5. Message-ID: <1992Aug14.172507.19950@informix.com>
  6. Date: 14 Aug 92 17:25:07 GMT
  7. Sender: news@informix.com (Usenet News)
  8. Organization: Informix Software, Inc.
  9. Lines: 114
  10. Originator: proberts@moose
  11.  
  12.  
  13. I have been creating pop up dialogs along the model suggested by Young p. 114
  14. and can get things to work reasonably well with a few exceptions.  Basicly
  15. I code the following:
  16.  
  17. main()
  18. {
  19.    Widget toplevel;
  20.    Widget form;
  21.    Widget button;
  22.    Widget dialog;
  23.  
  24.    toplevel = XtInitialize( argv[0], "fred", NULL, 0, &argc, argv);
  25.  
  26.    form =  XtCreateManagedWidget( "form", xmFormWidgetClass, toplevel, al, ac);
  27.  
  28.    button = XtCreateManageddWidget( "button", xmPushButtonWidgetClass, 
  29.                                     form, al, ac);
  30.  
  31.    dialog = create_dialog( toplevel );
  32.  
  33.    XtAddCallback( button, XmNactivateCallback, show_dialog, dialog);
  34.  
  35.    XtRealizeWidget( toplevel );
  36.  
  37.    XtMainLoop();
  38.  
  39. } /* end main */
  40.  
  41. Show dialog is just XtManageChild(dialog) like Young p. 115
  42.  
  43. Create dialog is along the lines of:
  44.  
  45. Widget create_dialog( parent )
  46. Widget parent;
  47. {
  48.    Widget local_dialog;
  49.  
  50.    /* logo resources */
  51.    XGCValues   arrow_val;
  52.    pixmap_data arrow_pd;
  53.    Widget      arrow;
  54.  
  55.    local_dialog = XmCreateFormDialog( parent, "dialog", al, ac);
  56.  
  57.    /*-- create a arrow image  --*/
  58.    ac = 0;
  59.    arrow = XtCreateManagedWidget( "arrow",
  60.                                xmDrawingAreaWidgetClass, local_dialog, al,ac);
  61.  
  62.    /* Use the forground and background colors of the logo to
  63.       create a graphics context */
  64.    ac = 0;
  65.    XtSetArg (al[ac], XtNforeground, &downHead_val.foreground); ac++;
  66.    XtSetArg (al[ac], XtNbackground, &downHead_val.background); ac++;
  67.    XtGetValues (downHead, al, ac);
  68.    arrow_pd.gc = XtGetGC (arrow, GCForeground|GCBackground,
  69.                             &arrow_val);
  70.  
  71.    arrow_pd.width  = arrow_width;
  72.    arrow_pd.height = arrow_height;
  73.    arrow_pd.pix = create_pixmap(arrow, arrow_pd.gc, arrow_bits,                          arrow_width, arrow_height);
  74.  
  75.   XtAddCallback (arrow, XmNexposeCallback, redisplay, &arrow_pd);
  76.   XtAddCallback (arrow, XmNresizeCallback, resize, &arrow_pd);
  77.  
  78.  
  79.    /* add buttons and text widgets and stuff as above */
  80.  
  81.    return local_dialog;
  82.  
  83. } /* end create_dialog() */
  84.  
  85.  
  86. Problem 1)
  87.  
  88. I can't seem to get a handle on the graphics contexts of the dialog.
  89. I want to add a bit map and used Young p. 191 as an example.  create_pixmap()
  90. and picmap_data are defined as he has it and this works fine at the main
  91. level.
  92.  
  93. Things will compile fine, however when the call back is run I get:
  94.  
  95. X Error of failed request:  BadGC (invalid GC parameter)
  96.   Major opcode of failed request:  56 (X_ChangeGC)
  97.   Resource id in failed request:  0xf7800128
  98.   Serial number of failed request:  465
  99.   Current serial number in output stream:  515
  100.  
  101.  
  102. and the program crashes.
  103.  
  104. Problem 2)
  105.  
  106. This might be related to problem 1, but I don't have a good grasp on the 
  107. hearatige of my dialog box.  I set the resources in a file that my xenvironment
  108. is set to.  So to set my dialog box I would thing something like:
  109.  
  110. fred.dialog.width: 100
  111.  
  112. would set the width to 100, but it dosn't quite work.
  113.  
  114. fred*dialog.width: 100
  115.  
  116. works fine.  Something about changing . for * 
  117.  
  118.  
  119. Anyhow, any new insight into this problem would be greatly appreciated.
  120.  
  121.  
  122. +-----------------------------------------------------------------------------+
  123. | "Just a Pedantics major from Berkeley" |            Randy McFarland         |
  124. |                        - Spalding Gray | mcfar@sunfse.ese.lmsc.lockheed.com |
  125. +-----------------------------------------------------------------------------+
  126.