Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!spool.mu.edu!uunet!stan!marvin!toml From: toml@marvin.Solbourne.COM (Tom LaStrange) Newsgroups: comp.windows.x Subject: Re: Reparenting widgets in Xt Intrinsics Message-ID: Date: 28 Feb 91 12:28:58 GMT References: <1991Feb27.161015.12890@viewlogic.com> <11769@adobe.UUCP> Sender: toml@Solbourne.COM (Tom LaStrange) Organization: Solbourne Computer, Inc. Lines: 47 In-Reply-To: asente@adobe.com's message of 28 Feb 91 06:27:11 GMT > The reason Xt mandates top-down widget construction is resources. If you > allowed parentless construction of the widget "fred" and there was a resource > specification: > > mary.bob.thelma.fred.width: 30 > > you would have to recompute fred's resources (or delay computing them) when > the final place in the widget tree was determined. I guarantee that this > two-phase resource resolution would make the current multi-phase creation > look simple by comparison. It also means that the advantage described, that > the parent could know the geometries of all its children when being created, > wouldn't really be an advantage. There could be another resource specification > > mary.bart.thelma.fred.width:50 > > and when "fred" was added to "thelma" the size of "fred" would remain unknown > until "thelma" was added to "bob" or "bart". > We have exactly this situation in OI because it allows dynamic reparenting of objects and does not require a specific order of creation of object hierarchies. We fetch resources on an object when it is associated with a new parent and it's top-level ancestor is parented to the root. We will also re-fetch resources on an object when it is reparented to another object hierarchy and it's new top-level ancestor is on the root. This makes reusing trees of objects very nice. Consider the following resource specifications: application*mary*background: blue application*mary*font: variable application*bart*background: red application*bart*font: 9x15 Then we associated a dialog box to mary. If the top-level ancestor is on the root, the dialog box will be blue with a variable font. If we then move the dialog box so that bart is it's new parent, the dialog box will be red and use a 9x15 font. The OI also allows the programmer to re-fetch resources at any time on an object. The question came up a few days ago where the person wanted to add some resources via XrmPutLineResource and then re-fetch resources. In OI you would simply use the object->update_resources() member function. -- Tom LaStrange toml@Solbourne.COM