(* Copyright (C) 1989, 1990 Digital Equipment Corporation *) (* All rights reserved. *) (* See the file COPYRIGHT for a full description. *) (* File: xbuttonbox.i3 *) (* Last modified on Thu Apr 12 00:13:50 1990 by muller *) (* modified on Thu Feb 15 12:25:26 1990 by jerome *) (*==============================================================*) (* The X11 R4 Interface for Modula 3 *) (* *) (* The Athena Widgets Set Example (re)coded in Modula3 *) (*==============================================================*) (* * This an example of how to create a composite widget with children * The composite used is a box widget. * * User events are handled through callback routines. * * November 27, 1989 - Chris D. Peterson *) (* * $XConsortium: xbuttonbox.c,v 1.16 89/12/15 19:33:10 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. *) MODULE xbuttonbox 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) & " [ -vspace ] [ -hspace ]\n"); Cstdlib.exit (1); END Syntax; (* Function Name: Quit * Description: This function quits the application. * Arguments: w - the widget * call_data - ** UNUSED ** * client_data - ** UNUSED ** * Returns: none *) PROCEDURE Quit (w: Xt.Widget; <*UNUSED*> client_data, call_data: ADDRESS) = BEGIN Xt.DestroyApplicationContext (Xt.WidgetToApplicationContext (w)); Cstdlib.exit (0); END Quit; VAR fb_res := NEW (Xt.FallbackResList); options := NEW (Xrm.OptionDescList); app_con: Xt.AppContext; root, box, command: Xt.Widget; BEGIN fb_res[0] := TtoS ("*Command.Label: " & "Click the left mouse button here to quit"); fb_res[1] := NIL; options[0] := Xrm.OptionDescRec{ TtoS ("-hspace"), TtoS ("*Box.hSpace"), Xrm.optionSepArg, NIL}; options[1] := Xrm.OptionDescRec{ TtoS ("-vspace"), TtoS ("*Box.vSpace"), Xrm.optionSepArg, NIL}; root := Xt.AppInitialize(app_con, TtoS ("Xbuttonbox"), options, 2, argc, argv, fb_res); IF (argc # 1) THEN Syntax (app_con, argv[0]) END; (* * Create a Box widget and put all children in that box widget. * * Unlike the Shell widget a Box widget can accept more than one child. * By using boxes and other composites it is possible to create an * arbitrarily complex application with hundreds or event thousands of * widgets. *) box := Xt.CreateManagedWidget (TtoS ("box"), Xaw.boxWidgetClass, root); (* * Put a command widget in the box. *) command := Xt.CreateManagedWidget (TtoS ("command"), Xaw.commandWidgetClass, box); Xt.AddCallback(command, XtN.callback, Quit); (* * Put 10 Label widget children in the Box. *) FOR i:= 0 TO 9 DO EVAL Xt.CreateManagedWidget (TtoS ("label " & Fmt.Int (i)), Xaw.labelWidgetClass, box); END; Xt.RealizeWidget (root); Xt.AppMainLoop (app_con); END xbuttonbox.