Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!gatech!emory!stiatl!meo From: meo@stiatl.UUCP (Miles O'Neal) Newsgroups: comp.windows.x Subject: Re: XtReparentWidget Keywords: not this week Message-ID: <3991@stiatl.UUCP> Date: 31 Mar 89 15:09:37 GMT Organization: Sales Technologies Inc., Atlanta, GA Lines: 45 In article <8903300045.AA28710@metasoft.uucp> yong@metasoft.UUCP (Yongdeng Chen) writes: >Hi there, > So I would like to have a function some thing like >XtReparentWidget to move the text widget from one diagram drawing >widget to another. > Has anyone written that function already? > If I want to writing my own function for that, what are >the short cuts, cautions and advises that I should know ? > How messy would that be to write such a function ? > Thanks in advance for your suggestions, advises, and answers! Wouldn't we all like this one! But, alas, "they" say it's major-league non-trivial. A suggestion (proven in real-life use by actual X11 programmers!): 1) You create the TW (textWidget) as a child of root, pointed to by a global variable. 2) Unmap it. 3) Invocation: a) create/map/whatever the new "pseudo-parent" (PP). b) convert the PP-relative (x,y) for the TW to root-relative (x,y). c) using XtSetValues (), stuff the result of (b) into the TW Args. d) add a callback to or override the actions/translations of the TW with a routine specific to the PP that will perform the necessary processing (the TW ptr being in the Widget field of the callback or action routine). e) if you use a callback, be sure that each PP tells the widget to forget the old callback before adding its own. f) map the TW. 4) the code to unmap/destroy/etc the PP needs to also unmap the TW. You might want to perform (3e) at this point as well. Yes, it's a little hackish, but it works, is very flexible, and should work through all versions of X11 until someone does write a reparenter (probably after some serious reworking of Xt widget-instantiation). If you have problems getting the TW to show above the parent, play around with Raising the PW. You may (at least under X11R2, have to also do XFlush's, clear the event queue, etc, before Raising the TW, to assure that some other event (such as MapRaise the PP) doesn't happen after the Map of the TW in such a way as to interfere. -Miles gatech!stiatl!meo