home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!sun-barr!sh.wide!wnoc-tyo-news!scslwide!wsgw!wsservra!daemon
- From: holcomb@csugrad.cs.vt.edu (David Holcomb)
- Newsgroups: fj.mail-lists.x-window
- Subject: Dialog w/multiple inputs
- Message-ID: <1992Nov17.135840.21610@sm.sony.co.jp>
- Date: 17 Nov 92 13:58:40 GMT
- Sender: daemon@sm.sony.co.jp (The devil himself)
- Distribution: fj
- Organization: Virginia Tech Computer Science Dept, Blacksburg, VA
- Lines: 135
- Approved: michael@sm.sony.co.jp
-
- Date: 15 Nov 92 04:08:28 GMT
- Message-Id: <Bxqou4.G0n@csugrad.cs.vt.edu>
- Newsgroups: comp.windows.x
- Sender: xpert-request@expo.lcs.mit.edu
-
- Question 1:
- -----------
- I would like to create a widget like a dialog widget, but with more
- than one text input field. The dialog widget, as near as I can tell,
- will only allow me to add the following items to the dialog box that
- pops up on the screen:
- 1) One text label (XtNlabel, as set by XtSetArg)
- 2) One input text string line (the actual dialogWidget
- from which the string will be retrieved)
- 3) Any number of buttons on the last line (added using
- XawDialogAddButton)
-
- The following code will only allow me to build (create) a dialog box
- of the following format:
- (note: spec_label is the text string displayed at the top of the
- dialog box, and the underscore in the inner box represents the
- cursor)
-
- +--------------------------------------------------------------------------+
- | Enter: ObjectName Xrotation Yrotation Zrotation Xcenter Ycenter Zcenter |
- | +------------------------------+ |
- | |_ | |
- | +------------------------------+ |
- | +====+ +========+ |
- | | Ok | | Cancel | |
- | +====+ +========+ |
- +--------------------------------------------------------------------------+
-
- Here's the code: (it is invoked as a callback when a menu is chosen)
-
- static void
- showrotate(spec_label)
- String spec_label;
- {
- Widget trans;
- Cardinal n;
- Arg args[5];
- Widget dialog;
-
- n = 0;
- XtSetArg(args[0],XtNx, 50); n++;
- XtSetArg(args[1],XtNy, 100); n++;
- trans = XtCreatePopupShell("Rotate Input Shell",
- transientShellWidgetClass, form, args,n);
- n = 0;
- XtSetArg(args[0],XtNvalue, " "); n++;
- XtSetArg(args[1],XtNlabel, spec_label ); n++;
- dialog = XtCreateManagedWidget("dialog6",dialogWidgetClass,
- trans, args, n );
- XawDialogAddButton(dialog,"Ok",get_direction_info,
- (XtPointer) dialog );
- XawDialogAddButton(dialog,"cancel",noinfo, (XtPointer) dialog );
- XtPopup(trans,XtGrabExclusive);
- }
-
- The variable form is global and it comes from my main program. It is
- defined as follows:
-
- /* Create a root widget */
- top = XtInitialize(argv[0], "Project 1", NULL, ZERO,&argc, argv );
- /* Create a form widget */
- form = XtCreateManagedWidget("form",formWidgetClass,top,NULL,0);
-
- Now, the format of the dialog I would like to have is as follows:
-
- +-------------------------------------------------------------------------+
- | ROTATE about X, Y, and/or Z axes: |
- | |
- | +----------------------+ |
- | Object Name: | obj1 | |
- | +----------------------+ |
- | Rotation Order (int): Center of Rotation (float): Degrees: (float) |
- | +---+ +-------+ +-----+ |
- | | | X | 20 | X | | X |
- | +---+ +-------+ +-----+ |
- | +---+ +-------+ +-----+ |
- | | 1 | Y | 330 | Y |-135 | Y |
- | +---+ +-------+ +-----+ |
- | +---+ +-------+ +-----+ |
- | | 2 | Z | -35 | Z | 45 | Z |
- | +---+ +-------+ +-----+ |
- | +====+ +========+ |
- | | Ok | | Cancel | |
- | +====+ +========+ |
- +-------------------------------------------------------------------------+
- This example means: Rotate obj1 about center (20,330,-35)
- Rotate in the following order:
- 1) Rotate about y-axis -135 degrees
- 2) Rotate about z-axis 45 degrees
- 3) Don't rotate about the x-axis
-
-
- On this dialog box, there are 10 dialog input lines. I'm not really sure
- how I can add all these widgets to the trans popup shell, and still be able
- to read all the inputs with one callback from the Ok button. (In other
- words, I think I know how I can make 10 Ok buttons, where each one calls
- the same, or nearly the same, callback routine.)
-
- Question 2:
- -----------
- Also, do I HAVE to use
- String info = XawDialogGetValueString(dialog);
- to retrieve the input from each dialog in the window? I was thinking there
- may be a built-in way to determine if the input was valid (int or float or
- string) before allowing the callback to be invoked. Then, once the callback
- was invoked, all I would have to check would be the bounds (min and max
- range of values allowed) of the input. This is just a curiosity question.
- I know how to parse the string after I get it in the callback. I'm just
- hoping there is a way to make the code simpler by removing unnecessary
- evels of detail.
-
- Comment:
- --------
- If the suggestion for me is to grab some widget library somewhere that does
- complex dialogs such as this, that solution would work fine with me.
- However, I would also like to know how to do this without resorting to
- such a solution. (I would like to learn how to build this puppy from
- scratch. For now, a quick, temporary solution is okay.)
-
- My Setup:
- ---------
- I do not have access to Motif. I am running A/UX 3.0 w/X11R4 and the Athena
- Widget Set on a Mac II w/5 megs RAM. A/UX is installed on a 210 meg
- external hard drive, and so I have the full release of A/UX and X11 (in other
- words, it all fits).
-
- I would be much obliged for any and all help.
-
- David Holcomb
- holcomb@csugrad.cs.vt.edu
-