Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!cis.ohio-state.edu!ucbvax!vaxa.nerc-murchison.ac.uk!E_CMA From: E_CMA@vaxa.nerc-murchison.ac.uk Newsgroups: comp.windows.x.motif Subject: Re: How do I center a widget inside an XmForm? Message-ID: <9106071143.AA17146@ucbvax.Berkeley.EDU> Date: 7 Jun 91 11:50:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 39 > I've been looking over the dazzling array of attachment options > available in XmForm, but I can't figure out how to position a > child widget (a Label, for instance)in either of the following ways: > > - attach the CENTER of the widget to the CENTER of the form, in > either the x or y dimensions (or both) > > - attach it to an adjoining widget (say, a Button) so that the > CENTER of the Button touches the CENTER of the Label The answer is, you don't. I have found the most effective way to center a label / button/ etc. in a single row is to embed the label in a RowColumn with : XmNorientation = XmHORIZONTAL, XmNborderWidth = 0 ; XmNleftAttachment = XmATTACH_FORM, XmNrightAttachment= XmATTACH_FORM. and XmNentryAlignment = XmALIGNMENT_CENTER. That way the RowColumn stretches with the Form and the Label doesn't. Do this with a Label Gadget and you get a borderless centered title. For general layout, embedding things in Row Colums can result in superior neatness. It also forces all items to be visible so you don't have to worry about resizing your Form if you add another widget. Cheers Carolyn ************************************************************************* * Snailmail: * E_Mail * * * CBS%UK.AC.NERC-MURCHISON.VAXA::E_CMA * * Dr C.M.Allen * JANET: e_cma@uk.ac.nmh.va * * British Geological Survey * * * Murchison House * * * West Mains Road ** * * * * * Edinburgh * Tel: 031-667-1000 x277 from U.K. * * Scotland * * * EH9,3LA * * *************************************************************************