[comp.windows.x] X Windows, Toolkits

ramesh@artecon.artecon.uucp (Ramesh S Rao) (03/17/89)

We have printed out the documents that come
with the X Window System. In the Widgets
docs, however, the documentation is not
quite clear on the ViewPort and Dialog
widgets.

Has anyone out there used these in programs?
Any sample programs, suggestions etc will
be greatly appreciated.

Thanks in advance.
			-- Ramesh & others.

Please reply to :
			...!hp-sdd!artecon!ramesh

kit@ATHENA.MIT.EDU (Chris D. Peterson) (03/18/89)

> We have printed out the documents that come
> with the X Window System. In the Widgets
> docs, however, the documentation is not
> quite clear on the ViewPort and Dialog
> widgets.

Yea, well that is what happens when a bunch of programmers get 
together to write documentation :-)

> Has anyone out there used these in programs?

You could say that :-)

> Any sample programs, suggestions etc will
> be greatly appreciated.

Okay how about one of each.

Enclosed is a short example of the use of the Dialog widget, I was
using it for testing a while back.

The Viewport widget is used to allow a widget to be scrolled.  This 
functionality is used extensivly in xmh, you can demonstrate the 
user interface by resizing one of the panes containing buttons to
be smaller than its default.  To use the Viewport just create it
inbetween what would be the child and parent if you were not planning
to use a Viewport.  It is important to remember that the Viewport widget
only understands how to deal with one child.  In xmh for example a box widget
is used as the child of the Viewport and the buttons are placed into that.
There are three options to the Viewport widget that are important they are
XtNallowVert and XtNallowHoriz which tell the viewport to use a scroll
bar in this direction, and XtNforceBars which will force the scrollbars
to always be visable on the display.  Normally scrollbars will only be 
displayed if they are needed.


I hope this helps.

						Chris D. Peterson     
						MIT X Consortium /
						Project Athena 

Net:	kit@athena.mit.edu		
Phone: (617) 253 - 1326			
USMail: MIT - Room E40-321
	77 Massachusetts Ave.		
	Cambridge, MA 02139		

-------------- cut here ----------------------

#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Dialog.h>

void
main(argc,argv)
char ** argv;
int argc;
{
    Widget top, dia;
    Arg a[1];

    XtSetArg (a[0], XtNvalue, "foo bar baz");
    top = XtInitialize ("", "test", (XrmOptionDescRec *)NULL, 0, &argc, argv);

    dia = XtCreateManagedWidget ("dialog", dialogWidgetClass, top,
        (ArgList) a, (Cardinal) 1);

    XtDialogAddButton(dia, "foo", NULL, NULL);
    XtDialogAddButton(dia, "bar", NULL, NULL);
    XtRealizeWidget(top);
    XtMainLoop();
}