home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!acorn!ixi!ixi!pd
- From: pd@x.co.uk (Paul Davey)
- Newsgroups: comp.windows.x.motif
- Subject: Re: Can Primitive widgets be parents?
- Message-ID: <PD.92Jul28130156@herts.x.co.uk>
- Date: 28 Jul 92 13:01:56 GMT
- References: <l7454fINN3r0@phakt.usc.edu>
- Sender: paul@x.co.uk (Paul Davey)
- Organization: IXI Ltd.
- Lines: 78
- In-Reply-To: whe@usc.edu's message of 26 Jul 92 02:57:19 GMT
-
- >>>>> On 26 Jul 92 02:57:19 GMT, whe@usc.edu (Wei He) said:
- Wei> NNTP-Posting-Host: phakt.usc.edu
-
- Wei> Hi:
- Wei> Can Primitive widgets be parents?
- Wei> In O'Reilly Volume Six - Motif Programming Manual p.165, prompt_dlg.c, There
- Wei> is a satement:
-
- Wei> dialog = XmCreatePromptDialog(pb, "prompt", args, 2);
-
- Wei> pb is a PushButton, OK, PushButton is a Primitive widget, How can it be the
- Wei> parent of Dialog?
-
- Yes this is allowed, basically because Motif is hiding things in an
- attempt to make them easier.
-
- Dialogs and Menus (Popup and Pulldown) may be attached to any widget
- (but not gadgets).
-
- This is because these calls (XmCreate*Dialog, XmCreatePulldownMenu aand
- XmCreatePopupMenu) create shell widgets as children of the
- ``psuedo-parent'' (my term for what is in this case the PushButton).
-
- The subsiduary widgets (the real dialog and menus) are made children of
- the new shell widget.
-
- The shell widget is needed so that the subsiduary window can be a
- child of the root window and so extend outside the main window of the
- application. Shell widgets don't have to have parents.
-
- The psuedo-parent is needed to allow:
- 1) resources to be looked up relative to some existing widget.
- 2) the shell destroy callbacks to be called when the application exits.
-
- You needed usually access the shell widgets but if you need to you can
- find their id with XtParent.
-
- menu_shell = XtParent(dialog);
-
-
- Wei> And in the same page, they create two buttons, but with same widget name
- Wei> "button":
-
- Wei> Widget button;
-
- Wei> button = XtVaCreateManagedWidget("PushMe-1", xmPushButtonWidgetClass,
- Wei> parent, NULL);
- Wei> button = XtVaCreateManagedWidget("PushMe-2", xmPushButtonWidgetClass,
- Wei> parent, NULL);
-
- Wei> Is this allowed in Motif 1.1?
-
- Actually the *names* of these widgets are distinct (``PushMe-1'' and
- ``PushMe-2''). The widget address is stored in the variable ``button''.
-
- All the example means is the first value of button is not saved in a variable
- and can not be accessed again directly.
-
- compare:
-
- len = strlen("Hello ");
- len = strlen("world");
-
-
- Widget names need not be unique either (although they usually are). It is
- sometimes usefull to give widgets the same name so that they pickup the same
- resource database information for instance even when they do not share the
- same class.
-
- Widget should be given names starting with a lowercase letter, Uppercase is
- reserved for classes.
-
- Widget button;
-
- button = XtVaCreateManagedWidget("pushMe", xmToggleButtonWidgetClass,
- parent, NULL);
- button = XtVaCreateManagedWidget("pushMe", xmPushButtonWidgetClass,
- parent, NULL);
-
-
-
- --
- Regards, pd@x.co.uk IXI Ltd.
- Paul Davey pd@ixi.uucp 62-74 Burleigh St.
- ...!uunet!ixi!pd Cambridge, U.K.
- "These _are_ interesting times" +44 223 462 131 CB1 1OJ
-