Reparenting a Widget internally

This forum is read only. No new submissions are accepted.

Questions about motif? Contact us

4 posts / 0 new
Last post
Reparenting a Widget internally

Is it possible to reparent a Widget within its initialization function (in Motif 2.1)? Since Motif 2.1 doesn`t have a tooltip widget, I have created one that is a subclass of XmLabel. I wrote it so that it creates a Shell internally and makes this Shell its parent. The parent of the Shell is the TopLevelShell of the application which I find using the subject of the tooltip Widget. The subject is a Widget resource which, if not set, defaults to the parent of the tooltip Widget. The problem I am having is when I pass in something like a XmManager subclass as the parent of the tooltip Widget. I am doing the following in my initialize function
tnew->core.parent = tnew->tooltip.shell;
Where tnew is the tooltip Widget passed into the initialize function, tooltip is my instance part and tooltip.shell is the shell that I created. During the case where I am passing in the XmManager subclass (this is for testing only...I don`t necessarily think that someone may do this but I don`t know and I want to make the Widget flexible enough to handle this), I get a seg fault. First of all, is this because the Manager subclass is trying to Manage my tooltip as a child and when I change the parent without telling it somehow I am messing up the relationship between parent and child? I realize that I could write a function to do all of this instead of putting it in a Widget but I want to be able to have tooltip delay and popup duration timers and have them be configurable from a resource file, for instance. I am also asking this question because I would like to create a toolbar Widget that can be detached from its parent application and "floated" around in its own Shell. Any help or advice in this matter is greatly appreciated. If you need a better description of any of what I have said, please ask. Thanks.
‹ Finding which Tab is active Icon Data from mwm ›

There is tooltip code as part

There is tooltip code as part of 2.2, in addition to other code which is floating around the Internet. It would likely be easiest to avoid re-inventing the wheel and to upgrade your version of Motif.

I know that as of 2.2,

I know that as of 2.2, Tooltips are part of the toolkit but at this point, my workplace refuses to upgrade (it`s a long story). I`ll look around the internet and see what I can find. In the meantime, no one has answered the overall question Is it possible to reparent a Widget within it`s initialize function?

 

 

No, you cannot do this. Setting xxx->core.parent to a different widget (say, yyy) will cause severe problems. First of all, xxx now thinks that yyy is its parent, but xxx is still in the children list of the original parent, and is not in the children list of the new widget (yyy). And what happens if yyy is not a composite, and thus cannot have children?

In general, a tooltip is usually a transient shell with a label child, with the shell widget`s parent being the shell widget ancestor of the tree for which it is a tip. So for your main dialog, the parent of the tip shell should be your topLevel widget, and for any other dialogs, the parent of the tip shell is the shell parent of the dialog. Then all you have to do is modify the labelString resource of the tip label whenever you determine that a new tip is needed, and move the tip shell to a new position.