home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / fj / maillis / xwindow / 17550 < prev    next >
Encoding:
Internet Message Format  |  1992-11-17  |  6.7 KB

  1. Path: sparky!uunet!stanford.edu!sun-barr!sh.wide!wnoc-tyo-news!scslwide!wsgw!wsservra!daemon
  2. From: holcomb@csugrad.cs.vt.edu (David Holcomb)
  3. Newsgroups: fj.mail-lists.x-window
  4. Subject: Dialog w/multiple inputs
  5. Message-ID: <1992Nov17.135840.21610@sm.sony.co.jp>
  6. Date: 17 Nov 92 13:58:40 GMT
  7. Sender: daemon@sm.sony.co.jp (The devil himself)
  8. Distribution: fj
  9. Organization: Virginia Tech Computer Science Dept, Blacksburg, VA
  10. Lines: 135
  11. Approved: michael@sm.sony.co.jp
  12.  
  13. Date: 15 Nov 92 04:08:28 GMT
  14. Message-Id: <Bxqou4.G0n@csugrad.cs.vt.edu>
  15. Newsgroups: comp.windows.x
  16. Sender: xpert-request@expo.lcs.mit.edu
  17.  
  18. Question 1:
  19. -----------
  20. I would like to create a widget like a dialog widget, but with more
  21. than one text input field.  The dialog widget, as near as I can tell,
  22. will only allow me to add the following items to the dialog box that
  23. pops up on the screen:
  24.      1) One text label (XtNlabel, as set by XtSetArg)
  25.      2) One input text string line (the actual dialogWidget
  26.              from which the string will be retrieved)
  27.      3) Any number of buttons on the last line (added using
  28.              XawDialogAddButton)
  29.  
  30. The following code will only allow me to build (create) a dialog box
  31. of the following format:
  32.   (note:  spec_label is the text string displayed at the top of the
  33.      dialog box, and the underscore in the inner box represents the
  34.      cursor)
  35.  
  36.    +--------------------------------------------------------------------------+
  37.    | Enter: ObjectName Xrotation Yrotation Zrotation  Xcenter Ycenter Zcenter |
  38.    | +------------------------------+                                         |
  39.    | |_                             |                                         |
  40.    | +------------------------------+                                         |
  41.    | +====+ +========+                                                        |
  42.    | | Ok | | Cancel |                                                        |
  43.    | +====+ +========+                                                        |
  44.    +--------------------------------------------------------------------------+
  45.  
  46.    Here's the code: (it is invoked as a callback when a menu is chosen)
  47.  
  48. static    void
  49. showrotate(spec_label)
  50. String    spec_label;
  51. {
  52.     Widget        trans;
  53.     Cardinal    n;
  54.     Arg        args[5];
  55.     Widget        dialog;
  56.     
  57.     n = 0;
  58.     XtSetArg(args[0],XtNx, 50); n++;
  59.     XtSetArg(args[1],XtNy, 100); n++;
  60.         trans = XtCreatePopupShell("Rotate Input Shell",
  61.                   transientShellWidgetClass, form, args,n);
  62.     n = 0;
  63.     XtSetArg(args[0],XtNvalue, " "); n++;
  64.     XtSetArg(args[1],XtNlabel, spec_label ); n++;
  65.     dialog = XtCreateManagedWidget("dialog6",dialogWidgetClass, 
  66.                   trans, args, n );
  67.     XawDialogAddButton(dialog,"Ok",get_direction_info,
  68.            (XtPointer) dialog );
  69.     XawDialogAddButton(dialog,"cancel",noinfo, (XtPointer) dialog );
  70.     XtPopup(trans,XtGrabExclusive);
  71. }
  72.  
  73.    The variable form is global and it comes from my main program.  It is
  74.    defined  as follows:
  75.  
  76.     /* Create a root widget */
  77.         top = XtInitialize(argv[0], "Project 1", NULL, ZERO,&argc, argv );
  78.     /* Create a form widget */
  79.     form = XtCreateManagedWidget("form",formWidgetClass,top,NULL,0);
  80.  
  81.    Now, the format of the dialog I would like to have is as follows:
  82.  
  83.    +-------------------------------------------------------------------------+
  84.    | ROTATE about X, Y, and/or Z axes:                                       | 
  85.    |                                                                         | 
  86.    |                 +----------------------+                                |
  87.    |    Object Name: | obj1                 |                                |
  88.    |                 +----------------------+                                |
  89.    |    Rotation Order (int):  Center of Rotation (float):  Degrees: (float) |
  90.    |      +---+                  +-------+                    +-----+        |
  91.    |      |   | X                |    20 | X                  |     | X      |
  92.    |      +---+                  +-------+                    +-----+        |
  93.    |      +---+                  +-------+                    +-----+        |
  94.    |      | 1 | Y                |   330 | Y                  |-135 | Y      |
  95.    |      +---+                  +-------+                    +-----+        |
  96.    |      +---+                  +-------+                    +-----+        |
  97.    |      | 2 | Z                |   -35 | Z                  | 45  | Z      |
  98.    |      +---+                  +-------+                    +-----+        |
  99.    | +====+ +========+                                                       |
  100.    | | Ok | | Cancel |                                                       |
  101.    | +====+ +========+                                                       |
  102.    +-------------------------------------------------------------------------+
  103.           This example means:  Rotate obj1 about center (20,330,-35)
  104.                                Rotate in the following order:
  105.                                1) Rotate about y-axis -135 degrees
  106.                                2) Rotate about z-axis   45 degrees
  107.                                3) Don't rotate about the x-axis
  108.  
  109.  
  110.    On this dialog box, there are 10 dialog input lines.  I'm not really sure
  111.    how I can add all these widgets to the trans popup shell, and still be able
  112.    to read all the inputs with one callback from the Ok button.  (In other
  113.    words, I think I know how I can make 10 Ok buttons, where each one calls
  114.    the same, or nearly the same, callback routine.)
  115.  
  116. Question 2:
  117. -----------
  118. Also, do I HAVE to use
  119.     String    info = XawDialogGetValueString(dialog);
  120. to retrieve the input from each dialog in the window?  I was thinking there
  121. may be a built-in way to determine if the input was valid (int or float or
  122. string) before allowing the callback to be invoked.  Then, once the callback
  123. was invoked, all I would have to check would be the bounds (min and max
  124. range of values allowed) of the input.  This is just a curiosity question.
  125. I know how to parse the string after I get it in the callback.  I'm just
  126. hoping there is a way to make the code simpler by removing unnecessary
  127. evels of detail.
  128.  
  129. Comment:
  130. --------
  131. If the suggestion for me is to grab some widget library somewhere that does
  132. complex dialogs such as this, that solution would work fine with me.  
  133. However, I would also like to know how to do this without resorting to
  134. such a solution.  (I would like to learn how to build this puppy from 
  135. scratch.  For now, a quick, temporary solution is okay.)
  136.  
  137. My Setup:
  138. ---------
  139. I do not have access to Motif.  I am running A/UX 3.0 w/X11R4 and the Athena
  140. Widget Set on a Mac II w/5 megs RAM.  A/UX is installed on a 210 meg
  141. external hard drive, and so I have the full release of A/UX and X11 (in other
  142. words, it all fits).
  143.  
  144. I would be much obliged for any and all help.
  145.  
  146. David Holcomb
  147. holcomb@csugrad.cs.vt.edu
  148.