home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / windows / x / motif / 8214 < prev    next >
Encoding:
Internet Message Format  |  1992-12-23  |  2.4 KB

  1. Path: sparky!uunet!vtserf!creatures!csgrad.cs.vt.edu!ramakris
  2. From: ramakris@csgrad.cs.vt.edu (S.Ramakrishnan)
  3. Newsgroups: comp.windows.x.motif
  4. Subject: Re: Centering button in form ?
  5. Message-ID: <3952@creatures.cs.vt.edu>
  6. Date: 24 Dec 92 02:12:06 GMT
  7. References: <1992Dec22.175107.3484@news.dfrf.nasa.gov> <1992Dec23.142215.9700@osf.org>
  8. Sender: usenet@creatures.cs.vt.edu
  9. Organization: VPI&SU Computer Science Department, Blacksburg, VA
  10. Lines: 51
  11.  
  12. In article <1992Dec23.142215.9700@osf.org  > daniel@juliet.osf.org (Daniel Dardailler) writes:
  13.   
  14.   >|>  -------------------------------
  15.   >|> |       ----------------        |
  16.   >|> |      |                |       |
  17.   >|> |       --XmPushButton--        |
  18.   >|>  ------------------------XmForm-
  19.   
  20.   
  21.   >Form does not support center attachment as a resource.
  22.   >You'll need to do some programming.
  23.   >
  24.   >You have to wait for after the Form first layout to be sure everybody
  25.   >got its natural size (the button and the form here).
  26.   >(unless you want to fix the sizes of your widgets, which is very bad).
  27.   >
  28.   >Calling a routine after XtRealize and before the main loop is fine.
  29.   >
  30.   >In this routine, do something like:
  31.   >
  32.   >        n = 0;
  33.   >    XtSetArg (args[n], XmNwidth, &width);  n++;
  34.   >    XtGetValues (push, args, n);
  35.   >
  36.   >    n = 0;
  37.   >    XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION);  n++;
  38.   >    XtSetArg (args[n], XmNleftPosition, 50);  n++;
  39.   >    XtSetArg (args[n], XmNleftOffset, -((int)width)/2);  n++;
  40.   >    XtSetValues (push, args, n);
  41.  
  42. This fragment of code is likely to yield funny results. 
  43. XmNleftPosition indicates not the x-coordinate but the 50th grid 
  44. position where the number of grid elements is set by XmNfractionBase (a
  45. form resource). Setting XmNleftPosition == 50 when XmNfractionBase is not 
  46. set is likely to yield strange results (I wonder if the pushbutton will 
  47. even be seen).
  48.  
  49. Further, when the left attachment type is XmATTACH_POSITION (placement
  50. by grid), specifying XmNleftOffset is meaningless.
  51.  
  52. Coming back to the original problem: trying to centre the *only* child of
  53. a form using XmATTACH_POSITION seems impossible, since the grid
  54. points are computed considering the size of the form at the time of
  55. realization. Since form wraps around its only child tightly,
  56. you are basically defining the positions on the child itself.
  57. Hence you end up trying to position the child on the parent using a grid
  58. that is defined on the child !
  59.  
  60.  
  61. ---
  62. S Ramakrishnan, CS Dept, McBryde Hall, VaTech
  63.