7.5.1 Creating a FileSelectionDialog
The convenience function for creating a FileSelectionDialog is XmCreateFileSelectionDialog(). The
routine is declared in <Xm/FileSB.h>. The function creates a FileSelectionBox widget and its DialogShell parent and
returns the FileSelectionBox. Alternatively, you can create a FileSelectionBox widget using either
XmCreateFileSelectionBox() or XtVaCreateWidget() with the widget class specified as
xmFileSelectionBoxWidgetClass. In this case, you could use the widget as part of a larger interface, or put
it in a DialogShell yourself.
the source code demonstrates how a FileSelectionDialog can be created. This program produces the dialog shown in
the figure. The intent of the program is to display a single FileSelectionDialog and print the selection that is made. We
will provide a more realistic example shortly. For now, you should notice how little code is actually required to create
the dialog. XtSetLanguageProc() is only available in X11R5; there is no corresponding function in X11R4.
XmStringCreateLocalized() is only available in -Motif 1.2; XmStringCreateSimple() is the
cor-re-sponding function in -Motif 1.1. XmFONTLIST_DEFAULT_TAG replaces XmSTRING_DEFAULT_CHARSET
in -Motif 1.2.
/* show_files.c −− introduce FileSelectionDialog; print the file
* selected by the user.
*/
#include <Xm/FileSB.h>
main(argc, argv)
int argc;
char *argv[];
{
Widget toplevel, text_w, dialog;
XtAppContext app;
extern void exit(), echo_file();
XtSetLanguageProc (NULL, NULL, NULL); ...