widget center alignment problem

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

Questions about motif? Contact us

5 posts / 0 new
Last post
widget center alignment problem

Submitted by orank on Mon, 12/03/2001 - 14:36. Developers
Hi , I hope someone can help me with this, its probably a simple question but for me its new

I have a form containing 3 widgets Ok ,Reset , Cancel , on the button , I located the buttons like this
Ok attached bottom and left
Cancel attached Button and Right
I want to locate the Reset Button in the middle and to keep it in the middle if the form resizes.
If I attach it left to the Ok and Right to the Cancel the Reset button resizes its width with the form resizes. How can I make it with a const size and still in the middle (button) of the form.

Thanks a lot to any one who can answer this . . .
All The Best
oran

ICS_support

Oh, oh! This was in the Motif Puzzle Book.

If I recall correctly, the best solution was to use the XmATTACH_POSITION settings and set the positions on the middle button to be the appropriate percentage i.e. XmNleftPosition is 40 and XmNrightPosition is 60. I think you can actually use XmATTACH_SELF if you really want a const size.

What you`re describing is tough because the Form does alignments by the edges of objects, not by their centers, but this solution should give you pretty much what you want.

orank

Hi ,
after a few tests I used the folowing code

Widget FormReset = XtVaCreateManagedWidget
("Reset",
xmPushButtonWidgetClass, Form,
XmNleftAttachment ,XmATTACH_POSITION,
XmNleftPosition ,37,
XmNrightAttachment ,XmATTACH_POSITION,
XmNrightPosition ,60,
XmNbottomAttachment , XmATTACH_FORM,
XmNbottomOffset , 5,
NULL);

this gave me a widget that changes very little when the form is resized and it keeps its middle postion on the form thank to the position attachment.

thank you very much for the help. .
All The Best

Anonymous

Hi!

Another way to do it is like following.
You create SelectionBox possibly with list and
textfield unmanaged, then manage in your gui
part as "work area", and use it`s three or four
standard buttons as You like. You can even add more buttons there and they shall be pretty-placed too under government of SelectionBox.
I had some kind of form in my case, and it looked pretty well.

ICS_support

Yes, the TemplateDialog and its ilk do this. Good point.