(* Copyright (C) 1989, 1990 Digital Equipment Corporation *) (* All rights reserved. *) (* See the file COPYRIGHT for a full description. *) (* File: xlist.i3 *) (* Last modified on Thu Apr 12 00:12:51 1990 by muller *) (* modified on Fri Feb 16 16:13:59 1990 by jerome *) (*==============================================================*) (* The X11 R4 Interface for Modula 3 *) (* *) (* The Athena Widgets Set Example (re)coded in Modula3 *) (*==============================================================*) (* * This example demostrates how to use the Athena List widget. * * November 30, 1989 - Chris D. Peterson *) (* * $XConsortium: xlist.c,v 1.4 89/12/15 19:37:22 kit Exp $ * * Copyright 1989 Massachusetts Institute of Technology * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. M.I.T. makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T. * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *) UNSAFE MODULE xlist EXPORTS Main; FROM M3toC IMPORT TtoS, StoT, argc, argv; IMPORT Fmt, Stdio, Wr, Cstdlib, Xrm, Xt, XtN, Xaw; (* Function Name: Syntax * Description: Prints the calling syntax for this program to stdout. * Arguments: app_con - the application context. * call - the name of the application. * Returns: none - exits tho. *) PROCEDURE Syntax (app_con: Xt.AppContext; call: Xt.String) = BEGIN Xt.DestroyApplicationContext (app_con); Wr.PutText (Stdio.stdout, "Usage: " & StoT (call) & "\n"); Cstdlib.exit (1); END Syntax; (* Function Name: Activate * Description: Called when a list item has been selected. * Arguments: w, client_data- *** UNUSED ***. * call_data - a pointer to the list info structure. * Returns: *) PROCEDURE Activate (<*UNUSED*> w: Xt.Widget; <*UNUSED*> client_data: ADDRESS; call_data: ADDRESS) = VAR item : Xaw.ListReturnStructStar; BEGIN item := LOOPHOLE (call_data, Xaw.ListReturnStructStar); Wr.PutText (Stdio.stdout, "Selected item " & Fmt.Int (item^.list_index) & ", \"" & StoT (item^.string) & "\".\n"); END Activate; VAR args := NEW (Xt.ArgList); items := NEW (Xt.StringList); app_con: Xt.AppContext; root: Xt.Widget; list: Xt.Widget; BEGIN root := Xt.AppInitialize(app_con, TtoS ("Xlist"), NIL, 0, argc, argv); (* * Check to see that all arguments were processed, and if not then * report an error and exit. *) IF (argc # 1) THEN Syntax (app_con, argv[0]) END; items[0] := TtoS ("first list entry"); items[1] := TtoS ("second list entry"); items[2] := TtoS ("third list entry"); items[3] := TtoS ("fourth list entry"); items[4] := NIL; args[0] := Xt.Arg { XtN.list, items}; list := Xt.CreateManagedWidget (TtoS ("list"), Xaw.listWidgetClass, root, args, 1); Xt.AddCallback(list, XtN.callback, Activate); Xt.RealizeWidget (root); Xt.AppMainLoop (app_con); END xlist.