home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!vtserf!creatures!csgrad.cs.vt.edu!ramakris
- From: ramakris@csgrad.cs.vt.edu (S.Ramakrishnan)
- Newsgroups: comp.windows.x.motif
- Subject: Re: Centering button in form ?
- Message-ID: <3952@creatures.cs.vt.edu>
- Date: 24 Dec 92 02:12:06 GMT
- References: <1992Dec22.175107.3484@news.dfrf.nasa.gov> <1992Dec23.142215.9700@osf.org>
- Sender: usenet@creatures.cs.vt.edu
- Organization: VPI&SU Computer Science Department, Blacksburg, VA
- Lines: 51
-
- In article <1992Dec23.142215.9700@osf.org > daniel@juliet.osf.org (Daniel Dardailler) writes:
-
- >|> -------------------------------
- >|> | ---------------- |
- >|> | | | |
- >|> | --XmPushButton-- |
- >|> ------------------------XmForm-
-
-
- >Form does not support center attachment as a resource.
- >You'll need to do some programming.
- >
- >You have to wait for after the Form first layout to be sure everybody
- >got its natural size (the button and the form here).
- >(unless you want to fix the sizes of your widgets, which is very bad).
- >
- >Calling a routine after XtRealize and before the main loop is fine.
- >
- >In this routine, do something like:
- >
- > n = 0;
- > XtSetArg (args[n], XmNwidth, &width); n++;
- > XtGetValues (push, args, n);
- >
- > n = 0;
- > XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
- > XtSetArg (args[n], XmNleftPosition, 50); n++;
- > XtSetArg (args[n], XmNleftOffset, -((int)width)/2); n++;
- > XtSetValues (push, args, n);
-
- This fragment of code is likely to yield funny results.
- XmNleftPosition indicates not the x-coordinate but the 50th grid
- position where the number of grid elements is set by XmNfractionBase (a
- form resource). Setting XmNleftPosition == 50 when XmNfractionBase is not
- set is likely to yield strange results (I wonder if the pushbutton will
- even be seen).
-
- Further, when the left attachment type is XmATTACH_POSITION (placement
- by grid), specifying XmNleftOffset is meaningless.
-
- Coming back to the original problem: trying to centre the *only* child of
- a form using XmATTACH_POSITION seems impossible, since the grid
- points are computed considering the size of the form at the time of
- realization. Since form wraps around its only child tightly,
- you are basically defining the positions on the child itself.
- Hence you end up trying to position the child on the parent using a grid
- that is defined on the child !
-
-
- ---
- S Ramakrishnan, CS Dept, McBryde Hall, VaTech
-