Path: utzoo!utgpu!watserv1!watmath!att!att!pacbell.com!ucsd!usc!apple!agate!linus!philabs!nbc1!nbc1!colin From: colin@nbc1.ge.com (Colin Rafferty) Newsgroups: comp.windows.x.motif Subject: Re: Centering Widgets Message-ID: Date: 28 Nov 90 18:24:02 GMT References: <1990Nov18.103134@lbl.gov> Sender: colin@nbc1.ge.com (Colin Rafferty) Organization: National Broadcasting Company, Inc., New York Lines: 78 In-Reply-To: ctday@lbl.gov's message of 18 Nov 90 18:31:34 GMT In article <1990Nov18.103134@lbl.gov> ctday@lbl.gov (Christopher T. Day) writes: > Is it possible to center a widget in a resizable area using one of > the standard Motif widgets? > ....I don't > want the buttons themselves to change size, just the space between > them. I tried to figure this one out, and it is possible using the form widget. The real trick is to have what I call a "Spot" which is placed where you want the center of the button, and then the button is placed around it. Here is a simple uil module to do it. No C, since I haven't seen a reason to write an interface in C yet. ---------------- begin uil ---------------- module center version = 'V1.0' names = case_sensitive value buttonWidth : 150; value buttonHeight : 50; object Form : XmForm widget { arguments { XmNwidth = buttonWidth; XmNheight = buttonHeight; }; controls { XmSeparator Spot; XmPushButton Button; }; }; object Button : XmPushButton widget { arguments { XmNfontList = Bigfont; XmNlabelString = 'Centered'; XmNleftAttachment = XmATTACH_WIDGET; XmNleftWidget = XmSeparator Spot; XmNleftOffset = - (buttonWidth / 2); XmNrightAttachment = XmATTACH_WIDGET; XmNrightWidget = XmSeparator Spot; XmNrightOffset = - (buttonWidth / 2); XmNtopAttachment = XmATTACH_WIDGET; XmNtopWidget = XmSeparator Spot; XmNtopOffset = - (buttonHeight / 2); XmNbottomAttachment = XmATTACH_WIDGET; XmNbottomWidget = XmSeparator Spot; XmNbottomOffset = - (buttonHeight / 2); }; }; object Spot : XmSeparator widget { arguments { XmNseparatorType = XmNO_LINE; XmNleftAttachment = XmATTACH_POSITION; XmNleftPosition = 50; XmNrightAttachment = XmATTACH_POSITION; XmNrightPosition = 50; XmNtopAttachment = XmATTACH_POSITION; XmNtopPosition = 50; XmNbottomAttachment = XmATTACH_POSITION; XmNbottomPosition = 50; }; }; end module; ---------------- end uil ---------------- //=====================================\/==============================\\ || Colin Owen Rafferty || "Life is so complex, parts || || colin@nbc1.ge.com || of it must be imaginary." || || {philabs,crdgw1,ge-dab}!nbc1!colin || -Tim Thiel || \\=====================================/\==============================//