Path: utzoo!attcan!uunet!cs.utexas.edu!sun-barr!apple!bloom-beacon!COSMOS.ACS.CALPOLY.EDU!mike From: mike@COSMOS.ACS.CALPOLY.EDU (Mike L Patnode) Newsgroups: comp.windows.x Subject: Re: Reparenting Widgets Message-ID: <8907061845.AA04080@cosmos.acs.calpoly.edu> Date: 6 Jul 89 18:45:22 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 37 > O.K. then, how about a XtCopyWidget() ? This would simpilfy the operation > greatly for those who are trying to do it, as well as reparenting. >>I remain unconvinced. Since this will probabally be slower than creating >>a new widget, why is it useful? You should already have a routine >>lying around your application that creates this widget, I don't see >>any advantage of XCopyWidget() over just calling that piece of application ^^^^^^^^^^^^^^^^^ >>code again to recreate the widget. I think I'm beginning to realize the difference in my philosophy. Everyone else considers most widgets a static object in the program. Since I'm working on a application generator, a widget to me is an object which could be any size, type, or color; have any label or pixmap inside of it; a variety of callbacks and event handlers; as well as extra information. The routines which created the widget and changed its attributes were called in some dynamic order choosen by the user. Hence when I want to call XtCopyWidget() it's because all I have is a widget identifier and I want to copy/move it somewhere else. My current solution is a hash table of widgets which also point to a separate attributes list. Whenever I want to copy a widget, I run though the information in the attributes list, converting it to the appropiate types, build a Args list and recreate the widget. Yuk! This is what I would expect XtCopyWidget to do for me. Now the problem with using the widget's own argslist is that XtGetValues doesn't always work. (try to get the foreground color of a text widget, it took me quite a while to find out where the text went on my copied widgets) Hence, XtCopyWidget would have to use a different method, or else all widgets would have to guarrentee their values. I certainly don't see the routine being easy to write but your right in thinking "If you created it once, why not just destroy it and create it again?" which is what we do, it's just a p.i.t.a. B.T.W: I never lost the text in the text widget, I just couldn't see it!