Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!wuarchive!bcm!convex!gstiehl@convex.com From: gstiehl@pixel.convex.com (Greg Stiehl) Newsgroups: comp.windows.x Subject: Re: A question on Form widgets ... on motif. Message-ID: <1991Feb02.183100.8367@convex.com> Date: 2 Feb 91 18:31:00 GMT References: <1991Feb1.235040.14018@msuinfo.cl.msu.edu> Sender: news@convex.com (news access account) Reply-To: gstiehl@convex.com Distribution: usa Organization: CONVEX Computer Corporation Lines: 70 To: veerabad@frith.egr.msu.edu Nntp-Posting-Host: pixel.convex.com In article <1991Feb1.235040.14018@msuinfo.cl.msu.edu>, veerabad@buster.cps.msu.edu (Vibhu Veerabadrappa) writes: > > I had a problem using the form widget class: > > I created a form widget as a child of the root widget. Under this > form widget, I created some pushbutton widgets as children, and I > tried to space them using the resource file. Specifically, I tried > to position some pushbuttons with respect to the form's right or > top edge, and it works fine. > > I say: > *quit_button.topAttachment: attach_form > > But if I try to specify the position wrt a widget, like: > > *sep1.topAttachment: attach_widget <--- to attach to a widget > *sep1.topWidget: quit_button <--- name of the already created widget, the topWidget resource is expecting a widget ID. So, if you wanted to set it in a resource file, you would have to convert the string "quit_button" to a widget ID. You could do this in a converter routine, provided you have created the "quit_button" widget before you created the "sep1" widget. And you have kept track all possible widgets names and IDs. It is unfortunate (but understandable) that the form widget doesn't attach to widgets by name. > I get an error message when I run the application program. The error > message is something like: > > ... no type converter specified for String to Window convertion > ^^^^^^^^ > > Note that it says String to Window ... which is the first surprise. Yes, that is a surprise. From the resource definition in Form.c, I would expect it to complain about no "String to Immediate". > 1. So I tried to write a String to Window type converter based on the > example in Young's book ... (pg 61) but I do not know what the type > of Window is. I tried %d, but it would not work. You might try String to Immediate, since that is the default type (even though the error message indicates otherwise). Like I said about, type that it is expecting is a widget, so your converstion routine should set the to.addr to the correct widget ID. Provided, of course, that you can figure out what the widget ID of the string is. > > 2. Another surprise is that if I burn the same information in the program > using XtSetValues, it works fine. I'll bet that you are using the widget ID and not the name of the widget. > 3. The problem is only if I try to position wrt a widget. I do not seem to > have any problems with others, like attach_form, attach_position etc. That is because attach_form, attach_position... are constants that can be converted by the Xt resource manager. Whereas widget is dymamic. > Can any of you please let me know if it is a legitimate problem, or am I > doing something wrong. You are not doing anything wrong, what you are doing just isn't supported. At a glance it seems like adding a converter is the correct thing to do. If you are creative enough, you might even be able to forward reference widgets. Of course you will have to keep track of all the widget names and IDs, so that your conversion routine can figure things out. Greg Stiehl (gstiehl@convex.com) Convex -- Graphics Software Group.