david@jpl-devvax.jpl.nasa.gov (David E. Smyth) (12/18/90)
Submitted-by: david@jpl-devvax.jpl.nasa.gov (David E. Smyth) Posting-number: Volume 10, Issue 54 Archive-name: wcl/part06 # to unbundle, "sh" this file -- DO NOT use csh # SHAR archive format. Archive created Fri Oct 19 09:32:53 PDT 1990 echo x - MD.c sed 's/^X//' > MD.c <<'+FUNKY+STUFF+' X/* X** Copyright (c) 1990 David E. Smyth X** X** Redistribution and use in source and binary forms are permitted X** provided that the above copyright notice and this paragraph are X** duplicated in all such forms and that any documentation, advertising X** materials, and other materials related to such distribution and use X** acknowledge that the software was developed by David E. Smyth. The X** name of David E. Smyth may not be used to endorse or promote products X** derived from this software without specific prior written permission. X** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED X** WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF X** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. X** X*/ X X/****************************************************************************** X** X** SCCS_data: @(#)MD.c 1.04 ( 30 September 1990 ) X** X** Description: This file contains main() for an example demonstrating X** how to support multiple displays. This file is derived X** from Mri.c, and which allows prototype interfaces to be X** built from resource files. The Widget Creation library X** is used. X** X** Note that a real application would probably want to keep X** the multiple displays syncronized. The only way to do X** that is to specifically cause each widget to update all X** the other widgets. This takes PROGRAMMING!!! X** X******************************************************************************* X** Include_files. X******************************************************************************/ X X#ifdef MOTIF X#include <Xm/Xm.h> X#else X#include <X11/Intrinsic.h> X#endif X#include <X11/Shell.h> X#include <ctype.h> X#include <WcCreate.h> X#include <WcCreateP.h> /* for callback convenience funcs */ X X#include <Table.h> X X/****************************************************************************** X** Global Application Data X******************************************************************************/ X Xint gargc; Xchar** gargv; X Xchar* appName; Xchar* appClass; XXtAppContext app; X Xstatic char msg[MAX_ERRMSG]; X X/****************************************************************************** X** Private Functions X******************************************************************************/ X X#ifdef MOTIF Xextern void MriRegisterMotif(); X#define REGISTER_WIDGET_SET MriRegisterMotif X#else Xextern void AriRegisterAthena (); X#define REGISTER_WIDGET_SET AriRegisterAthena X#endif X X/* X -- Open a new display, build another widget tree on that display. X****************************************************************************** X*/ X Xstatic void NewWidgetTreeOnDisplay( this, name, ignored ) X Widget this; X char* name; /* display name from res file */ X caddr_t ignored; X{ X static char clean[128]; /* display name w/o leading & trailing junk */ X int i; X int largc; X char** largv; X Display* dpy; X Widget newShell; X Arg args[3]; X X /* -- get clean display name by stripping leading & trailing whitespace */ X (void)WcCleanName( name, clean ); X X /* -- make local copy of global argc and argv */ X largc = gargc; X largv = (char**)XtMalloc( (gargc+1) * sizeof(char*) ); X for (i = 0 ; i < gargc ; i++) X largv[i] = gargv[i]; X largv[i] = NULL; X X /* -- open display, build Xrdb, add to app context */ X dpy = XtOpenDisplay( X app, clean, appName, appClass, NULL, 0, &largc, largv ); X if (dpy == NULL) X { X sprintf( msg, "NewWidgetTreeOnDisplay( %s ) failed:\ X Could not open display %s", clean, clean); X XtWarning( msg ); X return; X } X X /* -- create new shell on new display */ X /* these args are exactly what XtAppInitialize sets. */ X i = 0; X /* XtSetArg(args[i], XtNscreen, DefaultScreenOfDisplay(dpy)); i++; */ X XtSetArg(args[i], XtNargc, largc); i++; X XtSetArg(args[i], XtNargv, largv); i++; X X newShell = XtAppCreateShell( X appName, appClass, X applicationShellWidgetClass, X dpy, X args, i ); X if (newShell == NULL) X { X sprintf( msg, "NewWidgetTreeOnDisplay( %s ) failed:\ X Could not create new application shell.", clean); X XtWarning( msg ); X return; X } X X /* -- create widget tree under this new application shell */ X WcWidgetCreation ( newShell ); X X /* -- Realize the widget tree and return to the main application loop */ X XtRealizeWidget ( newShell ); X return; X} X X/* X -- Kill a widget tree on a display, close that display. X****************************************************************************** X*/ X Xstatic void KillWidgetTreeOnDisplay( this, notused, ignored ) X Widget this; X caddr_t notused; X caddr_t ignored; X{ X Display* dpy = XtDisplay(this); X XtDestroyWidget( WcRootWidget(this) ); X XtCloseDisplay ( dpy ); X} X X/* X -- Register Table widget and application specific callbacks. X****************************************************************************** X*/ X Xstatic void RegisterApplication ( app ) X XtAppContext app; X{ X#define RCN( name, class ) WcRegisterClassName ( app, name, class ); X#define RCP( name, class ) WcRegisterClassPtr ( app, name, class ); X#define RCB( name, func ) WcRegisterCallback ( app, name, func, NULL ); X X /* -- register widget classes */ X RCN( "Table", tableWidgetClass ); X RCP( "tableWidgetClass", tableWidgetClass ); X X /* -- register callbacks to open a new display */ X RCB( "NewWidgetTreeOnDisplay", NewWidgetTreeOnDisplay ); X RCB( "KillWidgetTreeOnDisplay", KillWidgetTreeOnDisplay ); X X#undef RCN X#undef RCP X#undef RCB X} X X/****************************************************************************** X* MAIN function X******************************************************************************/ X Xmain ( argc, argv ) X int argc; X char* argv[]; X{ X int i; X Widget appShell; X X /* make copies of argc and argv for later use in NewWidgetTreeOnDisplay */ X gargc = argc; X gargv = (char**)XtMalloc( (argc+1) * sizeof(char*) ); X for (i = 0 ; i < argc ; i++) X gargv[i] = argv[i]; X gargv[i] = NULL; X X appName = argv[0]; X appClass = (char*) XtMalloc ( strlen ( argv[0] ) + 1 ); X strcpy (appClass, argv[0]); X /* initialize first letter to make class, or first two if X ** first is already capitalized, or don't worry about it. X */ X if (islower(appClass[0])) X appClass[0] = toupper(appClass[0]); X else if (islower(appClass[1])) X appClass[1] = toupper(appClass[1]); X X /* -- Intialize Toolkit creating the application shell */ X appShell = XtInitialize ( X appName, appClass, /* app name and class */ X NULL, 0, /* description of cmd line options */ X &argc, argv X ); X app = XtWidgetToApplicationContext(appShell); X X /* -- Register all application specific callbacks and widget classes */ X RegisterApplication ( app ); X X /* -- Register all classes and constructors for desired widget set */ X REGISTER_WIDGET_SET ( app ); X X /* -- Create widget tree below toplevel shell using Xrm database */ X WcWidgetCreation ( appShell ); X X /* -- Realize the widget tree and enter the main application loop */ X XtRealizeWidget ( appShell ); X XtMainLoop ( ); X} +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 7234 Oct 12 09:57 MD.c (as sent)' chmod u=rw,g=r,o=r MD.c ls -l MD.c echo x - Mri.c sed 's/^X//' > Mri.c <<'+FUNKY+STUFF+' X/* X** Copyright (c) 1990 David E. Smyth X** X** Redistribution and use in source and binary forms are permitted X** provided that the above copyright notice and this paragraph are X** duplicated in all such forms and that any documentation, advertising X** materials, and other materials related to such distribution and use X** acknowledge that the software was developed by David E. Smyth. The X** name of David E. Smyth may not be used to endorse or promote products X** derived from this software without specific prior written permission. X** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED X** WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF X** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. X** X*/ X X/****************************************************************************** X** X** SCCS_data: @(#)Mri.c 1.0 ( 19 June 1990 ) X** X** Description: This file contains main() for a Motif Resource Interpreter X** which allows prototype interfaces to be built from X** resource files. The Widget Creation library is used. X** X** Besides the Motif widgets, Mri also knows about Table X** widgets, simply because they are so dang useful! X** X** Notes: This program uses the Xrm (X resource management) database X** for widget tree definition and management. This program X** is dependent on the Motif widget set only because the X** Motif classes and constructors are registered, which X** causes the Motif libs to be linked in. Someday I'll X** get a shared lib version of Motif and the Athena widgets, X** and even the OpenLook widget set, and then there will X** be no reason that widgets could not be mixed and matched. X** Doing that without shared libs makes for a HUGE executable. X** X******************************************************************************/ X X/****************************************************************************** X** Include_files. X******************************************************************************/ X X#include <Xm/Xm.h> X#include <ctype.h> X#include <WcCreate.h> X X#include <Table.h> X X/****************************************************************************** X** Private Functions X******************************************************************************/ X Xextern void MriRegisterMotif(); X Xstatic void RegisterTable ( app ) X XtAppContext app; X{ X#define RCN( name, class ) WcRegisterClassName ( app, name, class ); X#define RCP( name, class ) WcRegisterClassPtr ( app, name, class ); X X /* -- register widget classes */ X RCN( "Table", tableWidgetClass ); X RCP( "tableWidgetClass", tableWidgetClass ); X X#undef RCN X#undef RCP X} X X/****************************************************************************** X* MAIN function X******************************************************************************/ X Xmain ( argc, argv ) X int argc; X char* argv[]; X{ X char* appClass; X XtAppContext app; X Widget appShell; X X appClass = (char*) XtMalloc ( strlen ( argv[0] ) + 1 ); X strcpy (appClass, argv[0]); X /* initialize first letter to make class, or first two if X ** first is already capitalized, or don't worry about it. X */ X if (islower(appClass[0])) X appClass[0] = toupper(appClass[0]); X else if (islower(appClass[1])) X appClass[1] = toupper(appClass[1]); X X /* -- Intialize Toolkit creating the application shell */ X appShell = XtInitialize ( X argv[0], appClass, /* app name and class */ X NULL, 0, /* description of cmd line options */ X &argc, argv X ); X app = XtWidgetToApplicationContext(appShell); X X /* -- Register all application specific callbacks and widget classes */ X RegisterTable ( app ); X X /* -- Register all Motif classes and constructors */ X MriRegisterMotif ( app ); X X /* -- Create widget tree below toplevel shell using Xrm database */ X WcWidgetCreation ( appShell ); X X /* -- Realize the widget tree and enter the main application loop */ X XtRealizeWidget ( appShell ); X XtMainLoop ( ); X} +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 4088 Aug 6 09:36 Mri.c (as sent)' chmod u=rw,g=r,o=r Mri.c ls -l Mri.c echo x - MriRegAll.c sed 's/^X//' > MriRegAll.c <<'+FUNKY+STUFF+' X/* X** Copyright (c) 1990 David E. Smyth X** X** This file was derived from work performed by Martin Brunecky at X** Auto-trol Technology Corporation, Denver, Colorado, under the X** following copyright: X** X******************************************************************************* X* Copyright 1990 by Auto-trol Technology Corporation, Denver, Colorado. X* X* All Rights Reserved X* X* Permission to use, copy, modify, and distribute this software and its X* documentation for any purpose and without fee is hereby granted, provided X* that the above copyright notice appears on all copies and that both the X* copyright and this permission notice appear in supporting documentation X* and that the name of Auto-trol not be used in advertising or publicity X* pertaining to distribution of the software without specific, prior written X* permission. X* X* Auto-trol disclaims all warranties with regard to this software, including X* all implied warranties of merchantability and fitness, in no event shall X* Auto-trol be liable for any special, indirect or consequential damages or X* any damages whatsoever resulting from loss of use, data or profits, whether X* in an action of contract, negligence or other tortious action, arising out X* of or in connection with the use or performance of this software. X******************************************************************************* X** X** Redistribution and use in source and binary forms are permitted X** provided that the above copyright notice and this paragraph are X** duplicated in all such forms and that any documentation, advertising X** materials, and other materials related to such distribution and use X** acknowledge that the software was developed by David E. Smyth. The X** name of David E. Smyth may not be used to endorse or promote products X** derived from this software without specific prior written permission. X** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED X** WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF X** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. X** X*/ X X/* X* SCCS_data: @(#)MriRegAll.c 1.0 ( 19 June 1990 ) X* X* This module contains registration routine for all Motif X* widget/gadget constructors and classes. X* X* Module_interface_summary: X* X* void MriRegisterMotif ( XtAppContext app ) X* X******************************************************************************* X*/ X X#include <Xm/Xm.h> X X#include <Xm/ArrowB.h> X#include <Xm/ArrowBG.h> X#include <Xm/BulletinB.h> X#include <Xm/CascadeB.h> X#include <Xm/CascadeBG.h> X#include <Xm/Command.h> X#include <Xm/DialogS.h> X#include <Xm/DrawingA.h> X#include <Xm/DrawnB.h> X#include <Xm/FileSB.h> X#include <Xm/Form.h> X#include <Xm/Frame.h> X#include <Xm/Label.h> X#include <Xm/LabelG.h> X#include <Xm/List.h> X#include <Xm/MainW.h> X#include <Xm/MenuShell.h> X#include <Xm/MessageB.h> X#include <Xm/PanedW.h> X#include <Xm/PushB.h> X#include <Xm/PushBG.h> X#include <Xm/RowColumn.h> X#include <Xm/Scale.h> X#include <Xm/ScrollBar.h> X#include <Xm/ScrolledW.h> X#include <Xm/SelectioB.h> X#include <Xm/SeparatoG.h> X#include <Xm/Separator.h> X#include <Xm/Text.h> X#include <Xm/ToggleB.h> X#include <Xm/ToggleBG.h> X Xvoid MriRegisterMotif ( app ) X XtAppContext app; X{ X#define RCO( name, func ) WcRegisterConstructor ( app, name, func ) X#define RCN( name, class ) WcRegisterClassName ( app, name, class ) X#define RCP( name, class ) WcRegisterClassPtr ( app, name, class ) X X/* -- register all Motif constructors */ X RCO( "XmCreateArrowButton", XmCreateArrowButton ); X RCO( "XmCreateArrowButtonGadget", XmCreateArrowButtonGadget ); X RCO( "XmCreateBulletinBoard", XmCreateBulletinBoard ); X RCO( "XmCreateBulletinBoardDialog", XmCreateBulletinBoardDialog ); X RCO( "XmCreateCascadeButton", XmCreateCascadeButton ); X RCO( "XmCreateCascadeButtonGadget", XmCreateCascadeButtonGadget ); X RCO( "XmCreateCommand", XmCreateCommand ); X RCO( "XmCreateDialogShell", XmCreateDialogShell ); X RCO( "XmCreateDrawingArea", XmCreateDrawingArea ); X RCO( "XmCreateDrawnButton", XmCreateDrawnButton ); X RCO( "XmCreateErrorDialog", XmCreateErrorDialog ); X RCO( "XmCreateFileSelectionBox", XmCreateFileSelectionBox ); X RCO( "XmCreateFileSelectionDialog", XmCreateFileSelectionDialog ); X RCO( "XmCreateForm", XmCreateForm ); X RCO( "XmCreateFormDialog", XmCreateFormDialog ); X RCO( "XmCreateFrame", XmCreateFrame ); X RCO( "XmCreateInformationDialog", XmCreateInformationDialog ); X RCO( "XmCreateLabel", XmCreateLabel ); X RCO( "XmCreateLabelGadget", XmCreateLabelGadget ); X RCO( "XmCreateList", XmCreateList ); X RCO( "XmCreateMainWindow", XmCreateMainWindow ); X RCO( "XmCreateMenuBar", XmCreateMenuBar ); X RCO( "XmCreateMenuShell", XmCreateMenuShell ); X RCO( "XmCreateMessageBox", XmCreateMessageBox ); X RCO( "XmCreateMessageDialog", XmCreateMessageDialog ); X RCO( "XmCreateOptionMenu", XmCreateOptionMenu ); X RCO( "XmCreatePanedWindow", XmCreatePanedWindow ); X RCO( "XmCreatePopupMenu", XmCreatePopupMenu ); X RCO( "XmCreatePromptDialog", XmCreatePromptDialog ); X RCO( "XmCreatePulldownMenu", XmCreatePulldownMenu ); X RCO( "XmCreatePushButton", XmCreatePushButton ); X RCO( "XmCreatePushButtonGadget", XmCreatePushButtonGadget ); X RCO( "XmCreateQuestionDialog", XmCreateQuestionDialog ); X RCO( "XmCreateRadioBox", XmCreateRadioBox ); X RCO( "XmCreateRowColumn", XmCreateRowColumn ); X RCO( "XmCreateScale", XmCreateScale ); X RCO( "XmCreateScrollBar", XmCreateScrollBar ); X RCO( "XmCreateScrolledList", XmCreateScrolledList ); X RCO( "XmCreateScrolledText", XmCreateScrolledText ); X RCO( "XmCreateScrolledWindow", XmCreateScrolledWindow ); X RCO( "XmCreateSelectionBox", XmCreateSelectionBox ); X RCO( "XmCreateSelectionDialog", XmCreateSelectionDialog ); X RCO( "XmCreateSeparator", XmCreateSeparator ); X RCO( "XmCreateSeparatorGadget", XmCreateSeparatorGadget ); X RCO( "XmCreateText", XmCreateText ); X RCO( "XmCreateToggleButton", XmCreateToggleButton ); X RCO( "XmCreateToggleButtonGadget", XmCreateToggleButtonGadget ); X RCO( "XmCreateWarningDialog", XmCreateWarningDialog ); X RCO( "XmCreateWorkingDialog", XmCreateWorkingDialog ); X X/* -- register Motif widget classes */ X RCP("xmArrowButtonWidgetClass", xmArrowButtonWidgetClass ); X RCN("XmArrowButton", xmArrowButtonWidgetClass ); X RCP("xmArrowButtonGadgetClass", xmArrowButtonGadgetClass ); X RCN("XmArrowButtonGadget", xmArrowButtonGadgetClass ); X RCP("xmBulletinBoardWidgetClass", xmBulletinBoardWidgetClass ); X RCN("XmBulletinBoard", xmBulletinBoardWidgetClass ); X RCP("xmCascadeButtonWidgetClass", xmCascadeButtonWidgetClass ); X RCN("XmCascadeButton", xmCascadeButtonWidgetClass ); X RCP("xmCascadeButtonGadgetClass", xmCascadeButtonGadgetClass ); X RCN("XmCascadeButtonGadget", xmCascadeButtonGadgetClass ); X RCP("xmCommandWidgetClass", xmCommandWidgetClass ); X RCN("XmCommand", xmCommandWidgetClass ); X RCP("xmDialogShellWidgetClass", xmDialogShellWidgetClass ); X RCN("XmDialogShell", xmDialogShellWidgetClass ); X RCP("xmDrawingAreaWidgetClass", xmDrawingAreaWidgetClass ); X RCN("XmDrawingArea", xmDrawingAreaWidgetClass ); X RCP("xmDrawnButtonWidgetClass", xmDrawnButtonWidgetClass ); X RCN("XmDrawnButton", xmDrawnButtonWidgetClass ); X RCP("xmFileSelectionBoxWidgetClass", xmFileSelectionBoxWidgetClass ); X RCN("XmFileSelectionBox", xmFileSelectionBoxWidgetClass ); X RCP("xmFormWidgetClass", xmFormWidgetClass ); X RCN("XmForm", xmFormWidgetClass ); X RCP("xmFrameWidgetClass", xmFrameWidgetClass ); X RCN("XmFrame", xmFrameWidgetClass ); X RCP("xmGadgetClass", xmGadgetClass ); X RCN("XmGadget", xmGadgetClass ); X RCP("xmLabelWidgetClass", xmLabelWidgetClass ); X RCN("XmLabel", xmLabelWidgetClass ); X RCP("xmLabelGadgetClass", xmLabelGadgetClass ); X RCN("XmLabelGadget", xmLabelGadgetClass ); X RCP("xmListWidgetClass", xmListWidgetClass ); X RCN("XmList", xmListWidgetClass ); X RCP("xmMainWindowWidgetClass", xmMainWindowWidgetClass ); X RCN("XmMainWindow", xmMainWindowWidgetClass ); X RCP("xmManagerWidgetClass", xmManagerWidgetClass ); X RCN("XmManager", xmManagerWidgetClass ); X RCP("xmMenuShellWidgetClass", xmMenuShellWidgetClass ); X RCN("XmMenuShell", xmMenuShellWidgetClass ); X RCP("xmMessageBoxWidgetClass", xmMessageBoxWidgetClass ); X RCN("XmMessageBox", xmMessageBoxWidgetClass ); X RCP("xmPanedWindowWidgetClass", xmPanedWindowWidgetClass ); X RCN("XmPanedWindow", xmPanedWindowWidgetClass ); X RCP("xmPrimitiveWidgetClass", xmPrimitiveWidgetClass ); X RCN("XmPrimitive", xmPrimitiveWidgetClass ); X RCP("xmPushButtonWidgetClass", xmPushButtonWidgetClass ); X RCN("XmPushButton", xmPushButtonWidgetClass ); X RCP("xmPushButtonGadgetClass", xmPushButtonGadgetClass ); X RCN("XmPushButtonGadget", xmPushButtonGadgetClass ); X RCP("xmRowColumnWidgetClass", xmRowColumnWidgetClass ); X RCN("XmRowColumn", xmRowColumnWidgetClass ); X RCP("xmScaleWidgetClass", xmScaleWidgetClass ); X RCN("XmScale", xmScaleWidgetClass ); X RCP("xmScrollBarWidgetClass", xmScrollBarWidgetClass ); X RCN("XmScrollBar", xmScrollBarWidgetClass ); X RCP("xmScrolledWindowWidgetClass", xmScrolledWindowWidgetClass ); X RCN("XmScrolledWindow", xmScrolledWindowWidgetClass ); X RCP("xmSelectionBoxWidgetClass", xmSelectionBoxWidgetClass ); X RCN("XmSelectionBox", xmSelectionBoxWidgetClass ); X RCP("xmSeparatorWidgetClass", xmSeparatorWidgetClass ); X RCN("XmSeparator", xmSeparatorWidgetClass ); X RCP("xmSeparatorGadgetClass", xmSeparatorGadgetClass ); X RCN("XmSeparatorGadget", xmSeparatorGadgetClass ); X RCP("xmTextWidgetClass", xmTextWidgetClass ); X RCN("XmText", xmTextWidgetClass ); X RCP("xmToggleButtonWidgetClass", xmToggleButtonWidgetClass ); X RCN("XmToggleButton", xmToggleButtonWidgetClass ); X RCP("xmToggleButtonGadgetClass", xmToggleButtonGadgetClass ); X RCN("XmToggleButtonGadget", xmToggleButtonGadgetClass ); X X#undef RCO X#undef RCN X#undef RCP X} +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 9953 Aug 6 09:36 MriRegAll.c (as sent)' chmod u=rw,g=r,o=r MriRegAll.c ls -l MriRegAll.c exit 0 dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only. -- dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only.