13.3.6 An Example
In this section, we pull together all of the functions we have described in the preceding sections. This example builds
on alpha_list.c, the program that adds items that are input by the user to a ScrolledList in alphabetical order. Using
another Text widget, the user can also search for items in the list. The searching method uses regular expression
pattern−matching functions intrinsic to UNIX systems. the source code shows the new application.
XtSetLanguageProc() is only available in X11R5; there is no corresponding function in X11R4.
XmStringCreateLocalized() is only available in Motif 1.2; XmStringCreateSimple() is the
corresponding function in Motif 1.1. XmFONTLIST_DEFAULT_TAG replaces XmSTRING_DEFAULT_CHARSET in
Motif 1.2.
/* search_list.c −− search for items in a List and select them */
#include <stdio.h>
#include <Xm/List.h>
#include <Xm/LabelG.h>
#include <Xm/Label.h>
#include <Xm/RowColumn.h>
#include <Xm/PanedW.h>
#include <Xm/TextF.h>
main(argc, argv)
int argc;
char *argv[];
{
Widget toplevel, rowcol, list_w, text_w;
XtAppContext app;
Arg args[5];
int n = 0;
XmString label;
void add_item(), search_item();
XtSetLanguageProc (NULL, NULL, NULL);
toplevel = XtVaAppInitialize (&app, "Demos", NULL, 0,
&argc, argv, NULL, NULL);
rowcol = XtVaCreateWidget ("rowcol",
xmPanedWindowWidgetClass, toplevel, NULL);
label = XmStringCreateLocalized ("List:");
XtVaCreateManagedWidget ("list_lable", xmLabelWidgetClass, rowcol,
XmNlabelString, label,
NULL);
XmStringFree (label); ...