home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / windows / x / motif / 5265 < prev    next >
Encoding:
Internet Message Format  |  1992-07-28  |  3.2 KB

  1. Path: sparky!uunet!mcsun!uknet!acorn!ixi!ixi!pd
  2. From: pd@x.co.uk (Paul Davey)
  3. Newsgroups: comp.windows.x.motif
  4. Subject: Re: Can Primitive widgets be parents?
  5. Message-ID: <PD.92Jul28130156@herts.x.co.uk>
  6. Date: 28 Jul 92 13:01:56 GMT
  7. References: <l7454fINN3r0@phakt.usc.edu>
  8. Sender: paul@x.co.uk (Paul Davey)
  9. Organization: IXI Ltd.
  10. Lines: 78
  11. In-Reply-To: whe@usc.edu's message of 26 Jul 92 02:57:19 GMT
  12.  
  13. >>>>> On 26 Jul 92 02:57:19 GMT, whe@usc.edu (Wei He) said:
  14. Wei> NNTP-Posting-Host: phakt.usc.edu
  15.  
  16. Wei> Hi:
  17. Wei>    Can Primitive widgets be parents?
  18. Wei>    In O'Reilly Volume Six - Motif Programming Manual p.165, prompt_dlg.c, There
  19. Wei>    is a satement:
  20.  
  21. Wei>    dialog = XmCreatePromptDialog(pb, "prompt", args, 2);
  22.  
  23. Wei>    pb is a PushButton, OK, PushButton is a Primitive widget, How can it be the 
  24. Wei>    parent of Dialog?
  25.  
  26. Yes this is allowed, basically because Motif is hiding things in an
  27. attempt to make them easier.
  28.  
  29. Dialogs and Menus (Popup and Pulldown) may be attached to any widget
  30. (but not gadgets).
  31.  
  32. This is because these calls (XmCreate*Dialog, XmCreatePulldownMenu aand
  33. XmCreatePopupMenu) create shell widgets as children of the
  34. ``psuedo-parent'' (my term for what is in this case the PushButton).
  35.  
  36. The subsiduary widgets (the real dialog and menus) are made children of
  37. the new shell widget.
  38.  
  39. The shell widget is needed so that the subsiduary window can be a
  40. child of the root window and so extend outside the main window of the
  41. application. Shell widgets don't have to have parents.
  42.  
  43. The psuedo-parent is needed to allow: 
  44.  1) resources to be looked up relative to some existing widget.
  45.  2) the shell destroy callbacks to be called when the application exits.
  46.  
  47. You needed usually access the shell widgets but if you need to you can
  48. find their id with XtParent.
  49.  
  50.     menu_shell = XtParent(dialog);
  51.  
  52.  
  53. Wei>    And in the same page, they create two buttons, but with same widget name
  54. Wei>    "button":
  55.  
  56. Wei>    Widget button;
  57.  
  58. Wei>    button = XtVaCreateManagedWidget("PushMe-1", xmPushButtonWidgetClass, 
  59. Wei>                          parent, NULL);
  60. Wei>    button = XtVaCreateManagedWidget("PushMe-2", xmPushButtonWidgetClass,
  61. Wei>                        parent, NULL);
  62.  
  63. Wei>    Is this allowed in Motif 1.1?
  64.  
  65. Actually the *names* of these widgets are distinct (``PushMe-1'' and
  66. ``PushMe-2''). The widget address is stored in the variable ``button''.
  67.  
  68. All the example means is the first value of button is not saved in a variable
  69. and can not be accessed again directly.
  70.  
  71. compare:
  72.  
  73.     len = strlen("Hello ");
  74.     len = strlen("world");
  75.  
  76.  
  77. Widget names need not be unique either (although they usually are). It is
  78. sometimes usefull to give widgets the same name so that they pickup the same
  79. resource database information for instance even when they do not share the
  80. same class.
  81.  
  82. Widget should be given names starting with a lowercase letter, Uppercase is
  83. reserved for classes.
  84.  
  85.    Widget button;
  86.  
  87.    button = XtVaCreateManagedWidget("pushMe", xmToggleButtonWidgetClass, 
  88.                          parent, NULL);
  89.    button = XtVaCreateManagedWidget("pushMe", xmPushButtonWidgetClass,
  90.                        parent, NULL);
  91.  
  92.  
  93.  
  94. --
  95.  Regards,              pd@x.co.uk           IXI Ltd.
  96.     Paul Davey          pd@ixi.uucp          62-74 Burleigh St.
  97.                   ...!uunet!ixi!pd     Cambridge,  U.K.
  98.  "These _are_ interesting times"  +44 223 462 131      CB1  1OJ
  99.