david@devvax.Jpl.Nasa.Gov (David E. Smyth) (07/06/90)
Submitted-by: david@devvax.Jpl.Nasa.Gov (David E. Smyth) Posting-number: Volume 8, Issue 31 Archive-name: wcl/part01 # to unbundle, "sh" this file -- DO NOT use csh # SHAR archive format. Archive created Tue Jul 3 16:47:51 PDT 1990 echo x - 1stREADME sed 's/^X//' > 1stREADME <<'+FUNKY+STUFF+' XThe Widget Creation Library Distribution X---------------------------------------- X XThe Widget Creation Library is a cleanup and enhancement of Martin XBrunecky's second posting of WsXc. X XThe emphasis of the cleanup was to provide a separation of functionality Xand declarations between source and include files, to make the naming Xconcise and unique, and to reduce the complexity of the interface between Xthe library and the application (it was pretty darn good already). X XThe emphasis of the enhancements were to add clear(er) warning and Xerror messages, add more utility callbacks, and to provide a few simple Xfunctions which make writing callbacks and converters a little easier. X XOne of the guiding principles was and is KISS. This is intended to Xbe a very small library which provides very big gains in productivity Xfor programmers developing applications using the various widget Xsets based on the Xt Intrinsics. A large number of the total lines Xof code provide error messages. The rest is quite straight forward. X XThis directory contains files which make up libWc, the Widget Creation XLibrary, Ari, the Athena Resource Interpreter, and Mri, the Motif XResource Interpreter. X XAuthors X------- X XMartin Brunecky at Auto-trol Technology, Denver (marbru@auto-trol.UUCP) Xwrote the initial code and posted it to comp.windows.x with the title XPOOR MAN's UIL - WsXc. X XDavid Harrison of the UC Berkeley Electronics Research Lab X(davidh@ic.Berkeley.EDU or ...!ucbvax!ucbcad!davidh) wrote a very Xuseful Table widget. It is so good I've included it with this Xdistribution. It is separately available from archive sites. See XTableREADME.ANNOUNCE and TableREADME.FIRST for information on this Xwidget. I made very minor edits to make it work with Motif, and I Xfixed exactly one minor bug. X XRod Whitby of Austek Microsystems Pty. Ltd. in Adelaide, Australia X(rwhitby@adl.austek.oz.au) wrote the Imakefile, the XCalP example, the XWcRegIntrinsic.c file, and caught several bugs. X XThe rest was done by me, and here is my standard .sig: X X------------------------------------------------------------------------- XDavid Smyth david@jpl-devvax.jpl.nasa.gov XSenior Software Engineer, seismo!cit-vax!jpl-devvax!david XX and Object Guru. (818)393-0983 XJet Propulsion Lab, M/S 230-103, 4800 Oak Grove Drive, Pasadena, CA 91109 X------------------------------------------------------------------------- X X X XREADME Files and Documentation X------------------------------ X XThe *README files provide minimal documentation. I think you will Xfind the comments in the source files useful. Also, several Xexample resource files are provided with extensive comments. X XA real manual is actually being written, but it won't be available Xfor a month at least, probably not until September 1990. X XMakefiles X--------- X XAn Imakefile is provided. The Makefile can be built predictably: X X % make Makefile X XYou may then build the delivery using this Makefile: X X % make -f Makefile X XSeveral very simple makefiles are provided. A driver makefile, called X`makefile' builds the Makefile using Imake, and can also be used to Xbuild the delivery for those who don't have or use Imake. The driver Xmakefile causes each of the targets to be built using separate Xmakefiles: libWc.a is built with makefile_libWc, Mri is built with Xmakefile_Mri, and so on. X XThe intent is this: after one uses the Ari or Mri resource interpreters Xto build a prototype, one can start hacking with the desired interpreter Xand its separate makefile. X XGnu Make will be used in the future. X XBuilding The Distribution X------------------------- X XIf you have Imake, you can build the distribution very simply. XYou may have to edit the `makefile' if you don't have Motif: Xsimply comment out line 109 which should be this one: X X IMAKE_DEFINES = -DHAVE_MOTIF X XThen, build like other X clients and libraries: X X % make Makefile X % make -f Makefile X XOtherwise, you may have to set the CC, CFLAGS, and LDFLAGS macros in Xeach of the makefiles. The makefiles work for gcc and SunOS cc when Xthe Motif libraries are installed as recommended by ICS, and when the X Xlibraries are installed reasonably. As provided, they use gcc. X XThe easiest thing to do is simply this: X X % make X Xwhich causes all the libraries and executables to be built. X XIf you change any of the source files, you will notice that you Xmust first remove the targets (App, Ari, and Mri) in order to Xmake anything re-build. Do it like this: X X % make again X Xwhich removes these targets, recompiles minimally, but of course Xre-links whether or not they really needed it. Hey, it's not perfect, Xbut it's simple. X XIf you want things to run quickly and the library to be small, Xbuild the executables and libraries with debug flags off and Xoptimization turned on: X X % make optimal X XTesting The Distribution X------------------------ X XI have included a simple test csh script which executes all of the Xexample programs. After you build, the test program will execute Xwhich ever or the executable targets it finds. Just do the following: X X % test X XWidget Creation Library X----------------------- X XThe makefiles build two versions of the library: one works quite well Xwith the Motif 1.0 widget set and uses the Motif 1.0 Intrinsics. This Xversion is called libWcm.a, following ICS's naming convention. The Xother version works with the Athena widget set and the X11R4 Xt XIntrinsics in general. It is called libWc.a X XWhen Motif 1.1 is Xreleased, it should link against the latter include file without any Xproblems. I got the following message from Mike Yee at OSF regarding Xthis release of Mri and the Widget Creation Library: X X Good News! Mri is up and running under Motif 1.1! It only required X minor changes in the makefiles and the removal of references to X compositeObjectClass which does not exist in the R4 intrinsics. It X a pretty nifty program. Thanks for sending it. X XI applied his fixes to this release. X XMri and Ari Widget Resource Interpreters X---------------------------------------- X XThere are also two "interpreters" which allow widget based user Xinterfaces to be developed and to have a few useful behaviors. These Xinterpreters are intended to be useful for prototyping. X XAri is the Athena Resource Interpreter, and it knows about all the XAthena widgets. Mri is the Motif Resource Interpreter, and is knows Xabout all the Motif widgets. Both interpreters also know about the Xvery useful Table widget, which is described in the files Table*. X XEach interpreter consists of a main() procedure, and a function which Xregisters all the known widget types. Mri consists of Mri.c and XMriRegMotif.c while Ari consists of Ari.c and AriRegAthena.c. The Xregistration files are intended to be independent. X XIt should be a simple task to build a single interpreter which knows Xabout every widget on earth, but if you don't have shared libs, the Xresulting executable is HUGE. X XSeveral resource files are provided for each of the interpreters. They Xare named Ari<nn>.<description> and Mri<nn>.<description>. To try Xout the interpreters (after you build them), do the following: X X % alias se setenv XENVIRONMENT X % se Ari01.HelloWorld X % Ari X % se Mri07.PDWidgets X % Mri X XThe resource files are intended to be tutorials, so they are heavily Xcommented and they explore various topics you may find interesting. X XOnce an interface is prototyped using Mri or Ari, one can take the XMri or Ari source files and makefiles and evolve them into applications. X XApp - A Sample Application X-------------------------- X XThe program App is exactly one such example application. The Xfiles Ari.c and makefile_Ari were gradually modified as additional Xbehaviors were defined, registered with the Wc library, and bound Xto the appropriate widgets within the App01.Everything resource file. X XIf you look at App.c, you will notice that main() is very minimal. XThe application is really defined by its resource file (the look Xand feel) and the callbacks (the behavior). Notice that the Xcallbacks use several routines provided by the Wc library. They Xwill be introduced in another README file. X XAfter you build App, you can try it out as follows: X X % se App01.Everything X % App +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 8217 Jul 3 16:13 1stREADME (as sent)' chmod u=rw,g=r,o=r 1stREADME ls -l 1stREADME echo x - 2ndREADME sed 's/^X//' > 2ndREADME <<'+FUNKY+STUFF+' XWhat Every Application Needs X---------------------------- X XAll applications should include the public header file, should Xcreate the application shell, and should call WcCreateWidgets(). XThey should also include an external decl for either MriRegisterMotif Xor AriRegisterAthena(), depending on the widget set desired. X XHere is an absolute minimal Motif based application: X X/********* Cut Here ********/ X#include <Xm/Xm.h> X#include <WidgetCreation.h> X Xextern void MriRegisterMotif(); X Xmain( argc, argv ) X int argc; X char* argv[]; X{ X XtAppContext app; X Widget appShell; X X appShell = XtInitialize( "app", "App", NULL, 0, &argc, argv); X X app = XtWidgetToApplicationContext(appShell); X X MriRegisterMotif ( app ); X X WcWidgetCreation ( appShell ); X X XtRealizeWidget ( appShell ); X XtMainLoop ( ); X} X X/********* That's all, folks! ********/ X XA minimal Athena application differs slightly due to the different Xinclude files and the different widget registration routine: X X#include <X11/Intrinsic.h> X#include <WidgetCreate.h> X Xextern void AriRegisterAthena(); X Xmain( argc, argv ) X int argc; X char* argv[]; X{ X XtAppContext app; X Widget appShell; X X appShell = XtInitialize( "app", "App", NULL, 0, &argc, argv); X X app = XtWidgetToApplicationContext(appShell); X X AriRegisterAthena ( app ); X X WcWidgetCreation ( appShell ); X X XtRealizeWidget ( appShell ); X XtMainLoop ( ); X} X X/********* That's all, folks! ********/ X XAs you can see, every application needs as a minimum to invoke either XMriRegisterMotif() or AriRegisterAthena(), and WcWidgetCreation(). +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 1603 Jun 28 09:12 2ndREADME (as sent)' chmod u=rw,g=r,o=r 2ndREADME ls -l 2ndREADME echo x - 3rdREADME sed 's/^X//' > 3rdREADME <<'+FUNKY+STUFF+' XWidget Creation Resources X------------------------- X XThe Widget Creation Library allows user interfaces to be completely Xdefined within a resource file: the widget heirarchy, widget types, Xand bindings of widget callback lists to callback functions are Xspecified in the resource file using Wc* resources. X XThe following is the complete set of resources which are Xinterpreted by the Widget Creation Library: X X ...widget.wcChildren: childName1, childName2, ... X ...widget.wcClass: classPointerName X ...widget.wcClassName: className X ...widget.wcConstructor: constructorFunctionName X ...widget.wcTrace: true/false (default = false) X ...widget.wcManaged: true/false (default = true) X ...widget.wcCallback: callback1(args), callback2(args), ... X ...widget.wcDeferred: true/false (default = false) X XIn all cases, the Widget Creation resource names can be Xspecified as Wc<name> or wc<name>, with the capitalized Xform having looser binding (representing the resource class). X XWidget Creation Library Standard Callbacks X------------------------------------------ X XThe set of callbacks provided map VERY closely to Xt functions, and Xuse the standard resource syntax in all cases where it makes sense: X X WcSetValueCB( <resource spec LHS>: <any legal resource value> ) X Xso you can cut and paste the arguments and names. Note, however, that Xwidget class names won't affect any already existing widgets! You Xshould generally use the widget instance names. Real examples: X X *push.activateCallback: WcSetValueCB( *push.activateCallback: WcExitCB(1) ), \ X WcSetValueCB( *push.labelString: Goodbye! ) X X *fileMenu.wcCallback: WcSetValueCB(*file.subMenuId: this) X XBelow is a complete list of callbacks which are registered by Wc whenever Xyou call WcWidgetCreation. The "arguments" are prototypes of what one puts Xin a resouce file. The terms mean: X X parent name of widget, full path or wildcarded. X child name of child starting from the parent widget. X widget see parent X resLHS <resource spec LHS> X resRHS <any legal resource value> X X WcCreateChildrenCB ( parent, child [, child] ... ) X WcManageChildrenCB ( parent, child [, child] ... ) X WcUnmanageChildrenCB ( parent, child [, child] ... ) X X WcManageCB ( widget [, widget] ... ) X WcUnmanageCB ( widget [, widget] ... ) X WcDestroyCB ( widget [, widget] ... ) X WcSetSensitiveCB ( widget [, widget] ... ) X WcSetInsensitiveCB ( widget [, widget] ... ) X X WcPopupCB ( widget ) X WcPopupGrabCB ( widget ) X WcPopdownCB ( widget ) X X WcSetValueCB ( resLHS: resRHS ) X X WcLoadResourceFileCB ( filename ) X X WcExitCB ( exitValue ) X XIn all cases, the name of a widget can be `this' which means X`the widget which invoked this callback'. Its a useful shorthand. +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 2912 Jun 28 09:12 3rdREADME (as sent)' chmod u=rw,g=r,o=r 3rdREADME ls -l 3rdREADME echo x - 4thREADME sed 's/^X//' > 4thREADME <<'+FUNKY+STUFF+' XWidget Creation Functions X------------------------- X XTwo include files are provided which declare the functions and Xsupporting data types used by the Widget Creation Library. Many Xapplicationsshould only need to include WidgetCreation.h which Xcontains what can be considered "public" function declarations. X XIf you are writing additional resource converters, or sophisticated Xcallbacks, you will probably want to include WidgetCreationP.h Xwhich contains what can be considered "private" function declarations Xas well as typedefs for several datatypes used by the Widget Creation XLibrary. X XWidget Set Registration Functions X--------------------------------- X XTwo non-library functions are also provided in separate files: X XMriRegMotif.c contains the single function MriRegisterMotif(). This Xfunction lets the Wc library know about all the Motif widget class Xnames (like XmPushButtonGadget), class pointers (like XxmPushButtonGadgetClass), and convenience constructors (like XXmCreatePushButtonGadget). X XAriRegAthena.c contains the single function AriRegisterAthena(). This Xfunction lets the Wc library know about all the Athena widget class Xnamed (like Command), and class pointers (like commandWidgetClass). X XWcWidgetCreation() - see WcCreateFunc.c X------------------ X XThis function takes a Widget as its only argument. A widget tree Xrooted at the widget is created from the Xrm database. This widget Xis called the root widget in this discussion, but it can really be any Xwidget. X XThe Xrm database is usually loaded as a matter of course by calling XXtInitialize(). It is possible to load the resource database directly, Xusing XrmGetFileDatabase() and XrmMergeDatabases(). See the function XWcLoadResourceFileCB in the file WcCallbacks.c for an example. X XWcWidgetCreation() obtains the wcChildren resource from the widget. XIf it is non-null, WcWidgetCreation() attempts to create each of Xthe named children. For each child, it obtains the wcClass, wcClassName, XwcConstructor, wcDeferred, wcTrace, wcManaged, wcCallback, and wcChildren Xresources. If the child's creation is to be deferred (its wcDeferred Xresource is True) then the child is not created. X XOtherwise, it uses the wcClass, wcClassName, or wcConstructor resource Xto create the child widget. If the widget's wcTrace resource is True, Xa message is printed to stdout indicating the full pathname and widget Xclass of the new widget. If the widget's wcCallback resource is defined, Xthen the callback list in invoked. If the widget has any children Xlisted in its wcChildren resource, then they are each created in turn. X XAll widgets whose wcManaged resource is True (the default) are managed Xtogether with a single call to XtManageChildren(). X XNote that WcWidgetCreation() does a depth first creation, and that Xthe order of creation is controlled by the order of the names in the XwcChildren resource. X XNote also that the use of constructors may provide some suprises: in Xmany cases, a constructor returns a widget which has a parent widget Xinserted. This will cause XtWarning messages if such widgets are Xmanaged: X X Warning: not all widgets have same parent in XtManageChildren() X XSimply don't manage these widgets. This is usually the correct thing to Xdo anyway, because the guilty constructors are XmCreatePulldownMenu, XXmCreateWarningDialog, and the like. In these cases, you usually want Xthem to start out unmanaged, and manage them as a result of some button Xcallback. X XIf you really DO want such a widget to be managed originally, you will hace Xto still set its wcManaged resource to be False, and manage it using the XwcCallback creation-time-callback, like this: X X *foo.wcConstructor: XmCreateFileSelectionBox X *foo.wcManaged: False X *foo.wcCallback: WcManageCB( this ) X XThat's why they are so frequently called `confusion functions' instead Xof `convenience functions.' X XWcRegisterCallback() - see WcRegister.c X-------------------- X XProbably all of your useful applications will require your own Xcallbacks. These callbacks are registered with the Widget Creation XLibrary's string-to-callback converter using WcRegisterCallback(). X XIn fact, this function is used by Wc itself to register the standard Wc Xsupplied callbacks, such as WcSetValueCB and WcExitCB. See the Xfunction WcRegisterWcCallbacks() at the end of WcCallbacks.c to see how XWc uses this function internally. X XWcRegisterClassPtr() - see WcRegister.c X-------------------- X XThis function is used to tell the Widget Creation Library about a Xwidget class pointer which can be used within XtCreateWidget(). The Xname of the widget class pointer is passed in as a string (for example, X"xmPushButtonWidgetClass"). This string value can be provided as the XwcClass resource value within a resource file. X XWcRegisterClassName() - see WcRegister.c X--------------------- X XThis function is used to tell the Widget Creation Library about a Xwidget class name. The name is mapped to a widget class pointer which Xcan be used within XtCreateWidget(). The name of the widget class is Xpassed in as a string (for example, "xmPushButton"). This string value Xcan be provided as the wcClassName resource value within a resource Xfile. X XWcRegisterConstructor() - see WcRegister.c X----------------------- X XThis function is used to tell the Widget Creation Library about a Xwidget constructor. The name of the constructor is passed in as a Xstring (for example, "XmCreatePushButton"). This string value can be Xprovided as the wcConstructor resource value within a resource file. +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 5511 Jun 28 09:12 4thREADME (as sent)' chmod u=rw,g=r,o=r 4thREADME ls -l 4thREADME echo x - 5thREADME sed 's/^X//' > 5thREADME <<'+FUNKY+STUFF+' XWriting Callback Functions X-------------------------- X XYour application will consist of two fairly independent parts: the Xresource file which describes the look and alot of the feel of the Xapplication, and the callbacks which you write in C (of course, Xyou can use languages other than C, but C is probably the easiest). X XIn order to bind the widgets created due to resource specifications Xto your callbacks implemented in C, you need to write the callbacks Xso they adhere to the standard Xt callback proc typedef, and you Xneed to register your callbacks with the Widget Creation Library's Xstring-to-callback converter. X XXtCallbackProc X-------------- X XAs defined by the XtIntrinsics, widget callback procedures must match Xthis typedef: X Xtypedef void (*XtCallbackProc)( X#if NeedFunctionPrototypes X Widget /* widget */, X XtPointer /* closure */, /* data the application registered */ X XtPointer /* call_data */ /* callback specific data */ X#endif X); X XHere is an example callback proc which does nothing with its Xarguments: X Xvoid MyExitCB ( w, ignored, unused ) X Widget w; X caddr_t ignored; X caddr_t unused; X{ X exit(); X} X XYou must register this function with the Widget Creation Library Xbefore creating any widgets which might want to bind to it. XIn general, register your callbacks after calling XtInitialize() Xand before calling WcCreateWidgets(). Here is an example of Xhow you register a callback: X X#define RCALL( name, func ) WcRegisterCallback ( app, name, func, NULL ) X X RCALL( "MyExitCB", MyExitCB ); X XAll registered callbacks can be bound to widget callback resources Xwithin the resource database. For example: X X *foo.activateCallback: MyExitCB X XMost callbacks really want to do something with the data they Xget as arguments. The closure data, often called client data, Xcan be specified as a string within the resource database. XThe string is passed as the second argument. For example: X Xvoid WcSystemCB ( w, shellCmdString, unused ) X Widget w; X char* shellCmdString; X caddr_t unused; X{ X system( shellCmdString ); X} X XNote that leading and trailign whitespace is NOT filtered out before Xthe callback gets it. For example, the resource specification: X X *foo.activateCallback: WcSystemCB( echo Howdy ) X Xpasses the string " echo Howdy " to the callback. The resource Xspecification: X X *foo.activateCallback: WcSystemCB( echo Howdy \ X and hello thar) X Xpasses the string " echo Howdy \t\t\t\tand hello thar" (where `\t' means Xthe tab character) to the callback. Since the callbacks usually need Xto parse these argument strings, several Widget Creation Library Xfunctions are provided in the hope of making your life easier: X Xchar* WcCleanName( char* src, char* clean ) X------------------------------------------- X XThis takes two pointers to char as arguments. The leading whitespace Xcharacters from src are skipped, and then all characters up to but Xnot including a whitespace are copied into the buffer pointed to by Xclean. Note the caller must provide storage for clean. The function Xreturns a pointer to the first whitespace following what got copied Xto clean, so this function may be used in a loop. X XWidget WcFullNameToWidget ( Widget ref, char* name ) X---------------------------------------------------- X XThis function needs to have a pointer to a widget which is Xanywhere within the same widget tree as the name is to be resolved Xinto. For example, one may need to get the actual widget which is Xnamed by "*Foo*bar.glorp" The ref widget is used to find the root of Xthe widget tree, and start the name search from there. X XThe name can be any name which the resource manager can Xresolve, but the last component MUST be a widget instance Xname, it cannot be a widget class name. X XAmbiguous names are resolved as done by XtNameToWidget() upon Xwhich WcFullNameToWidget() is derived. X XVery frequently, one gets a name from an argument list using XWcCleanName() and then passes that name on to WcFullNameToWidget Xin order to manipulate that widget. For example: X Xvoid MyPopupCB( w, name, unused ) X Widget w; X char* name; X caddr_t unused; X{ X Widget widget; X char clean[MAX_XRMNAME]; X X (void)WcCleanName ( name, cleanName ); X widget = WcFullNameToWidget ( w, cleanName ); X X if (XtIsShell(widget)) X XtPopup ( widget, XtGrabNonexclusive ); X} X XEfficiency Considerations X------------------------- X XI know parsing string arguments on every callback invocation is not so Xincredibly efficient. When Motif runs on Xt release 4, then I will Xre-write the string-to-widget converter so it caches the results, and Xthen callbacks can invoke the caching converter. X XAlso, if you are very interested in performance for a real application X(after you have fleshed out the interface using Ari or Mri), you Xshould write additional callbacks which are more intelligent, and Xdetect being called repeatedly from the same widget with the same Xargument. X XYou may want to consider using the XrmQuark functions for keeping Xtrack of strings as well. XrmQuarks are effectively indexes into Xa string symbol table kept by Xrm (part of Xlib). Doing comparisions Xand assingments using Quarks is substantially faster at run-time than Xusing character strings. XrmQuarkToString() and XrmStringToQuark() Xare used to convert between Quarks and Strings. +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 5369 Jun 28 09:12 5thREADME (as sent)' chmod u=rw,g=r,o=r 5thREADME ls -l 5thREADME echo x - App.c sed 's/^X//' > App.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: @(#)Ari.c 1.0 ( 19 June 1990 ) X** X** Description: This file contains a sample application which uses X** Athena widgets. The example functionally mimics the X** xwidgets.c example provided in examples/Xaw on the X** X11R4 tape from MIT. The Widget Creation library X** is used. X** X** Several application specific callbacks are registered X** with the Wc library, and bound to the interface by X** specifications within the application resource file. X** X** Note that this application has NO fallback resources. X** Since the resource file actually defines the complete X** widget tree, the resource file(s) MUST be found, X** eliminating the raison d'etre of the fallbacks. X** X** Notes: This program uses the Xrm (X resource management) database X** for widget tree definition and management. X** X******************************************************************************/ X X/****************************************************************************** X** Include_files. X******************************************************************************/ X X/* -- Minimum include files to use WidgetCreate Library */ X#include <X11/Intrinsic.h> X#include <WidgetCreate.h> X X/* -- application specific include files */ X#include <stdio.h> X#include <ctype.h> X#include <X11/Xaw/Dialog.h> X#include <X11/StringDefs.h> X X/****************************************************************************** X** Private Functions X******************************************************************************/ X Xextern void AriRegisterAthena (); X X/* X -- Tied to Dialog `Okay' button X****************************************************************************** X Adds an entry to the List widget whose name is passed as clientData. X*/ X Xstatic void MyOkayCB( widget, widgetName, unused ) X Widget widget; X char* widgetName; X caddr_t unused; X{ X Widget list_widget = WcFullNameToWidget( widget, widgetName ); X static String * list = NULL; X static int num_items = 0, allocated_items = 0; X X if (num_items == allocated_items) { X allocated_items += 10; X list = (String *) XtRealloc(list, sizeof(String) * allocated_items); X } X X /* X * The value returned by XawDialogGetValueString() does not remain good X * forever so we must store is somewhere. This creates a memory leak X * since I don't remember these values, and free them later. I know about X * it, but it doesn't seem worth fixing in this example. X */ X X list[num_items++] = XtNewString(XawDialogGetValueString(XtParent(widget))); X XawListChange(list_widget, list, num_items, 0, True); X} X X/* X -- MyQuitCB X****************************************************************************** X This function destroys the widget tree. X*/ X Xstatic void MyQuitCB( widget, widgetName, ignored ) X Widget widget; X char* widgetName; X caddr_t ignored; X{ X Widget condemmed = WcFullNameToWidget( widget, widgetName ); X fprintf(stderr, "MyQuitCB(%s)\n", widgetName ); X if (condemmed == NULL) X XtDestroyWidget( WcRootWidget( widget ) ); X else X XtDestroyWidget( condemmed ); X} X X/* X -- MyTimeSinceTouchedCB Tied to the strip chart widget. X****************************************************************************** X This function returns the number of 10s of seconds since the user X caused an event in this application. X Note that the StripChart requires a return value. X*/ X Xstatic void MyTimeSinceTouchedCB( widget, ignored, value_ptr ) X Widget widget; X caddr_t ignored; X double* value_ptr; X{ X double *value = (double *) value_ptr; X static double old_value = 0.0; X static Time old_stamp = 1; X Time new_stamp; X X new_stamp = XtLastTimestampProcessed( XtDisplay( widget ) ); X X if (old_stamp != new_stamp) X { X old_stamp = new_stamp; X old_value = 0.0; X } X else X { X Arg args[1]; X int update; X X XtSetArg(args[0], XtNupdate, &update); X XtGetValues(widget, args, 1); X old_value += (double) update / 10.0; X } X X *value = old_value; X} X X/* X -- MyCountCB Tied to button, increments counter and displays. X****************************************************************************** X The argument is interpreted as a widget which must be a label. X The count, after being incremented, is displayed in this label X widget. (Actually, it may be anything derived from Label). X*/ X Xstatic void MyCountCB( widget, widgetName, ignored ) X Widget widget; X char* widgetName; X caddr_t ignored; X{ X Arg arg[1]; X char text[10]; X static int count = 0; X X sprintf( text, " %d ", ++count ); X XtSetArg( arg[0], XtNlabel, text ); X XtSetValues( WcFullNameToWidget( widget, widgetName ), arg, 1 ); X} X X/* X -- MyThumbedCB Tied to scrollbar's jumpProc X****************************************************************************** X Prints location of the thumb as a percentage of the height of the X scrollbar into the labe widget named by the widgetName argument. X*/ X Xstatic void MyThumbedCB( widget, widgetName, top_ptr ) X Widget widget; X char* widgetName; /* string from resource database (resource file) */ X float* top_ptr; /* scrollbar callback call data: a pointer to a float X ** containing the location of the scrollbar's thumb. X */ X{ X Widget label = WcFullNameToWidget( widget, widgetName ); X Arg args[1]; X char message[BUFSIZ]; X X sprintf( message, " Thumbed to %d%% ", (int)((*top_ptr)*100) ); X XtSetArg( args[0], XtNlabel, message ); X XtSetValues( label, args, 1 ); X} X X/* X -- MyScrolledCB Tied to scrollbar's scrollProc X****************************************************************************** X Prints location of the pointer into the named label widget. X*/ X Xstatic void MyScrolledCB( widget, widgetName, num_pixels ) X Widget widget; X char* widgetName; /* string from resource database (resource file) */ X int* num_pixels; /* scrollbar callback call data: the number of X ** pixels the bar has been scrolled. X */ X{ X Widget label = WcFullNameToWidget( widget, widgetName ); X Arg args[1]; X char message[BUFSIZ]; X X sprintf( message, " Scrolled at %d pixels", num_pixels); X XtSetArg( args[0], XtNlabel, message ); X XtSetValues( label, args, 1 ); X} X X/* X -- MyDestroyedCB Destroy callback of application shell X****************************************************************************** X This is a Destroy callback that prints the name of the destroyed widget. X*/ X Xstatic void MyDestroyedCB( widget, ignored, unused ) X Widget widget; X caddr_t ignored; X caddr_t unused; X{ X fprintf( stderr, "Widget %s now destroyed.\n", WcWidgetToFullName(widget)); X} X X/* X -- RegisterApplicationCallbacks X****************************************************************************** X Register all the callbacks which define the application's behaviors. X*/ X Xstatic void RegisterApplicationCallbacks ( app ) X XtAppContext app; X{ X#define RCALL( name, func ) WcRegisterCallback ( app, name, func, NULL ); X X RCALL( "MyOkayCB", MyOkayCB ); X RCALL( "MyQuitCB", MyQuitCB ); X RCALL( "MyTimeSinceTouchedCB", MyTimeSinceTouchedCB ); X RCALL( "MyCountCB", MyCountCB ); X RCALL( "MyThumbedCB", MyThumbedCB ); X RCALL( "MyScrolledCB", MyScrolledCB ); X RCALL( "MyDestroyedCB", MyDestroyedCB ); 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 /* With the Athena widgets, we MUST register the Wc X ** converters first, so WcCvtStringToWidget is invoked X ** instead of the far less useful XmuCvtStringToWidget. X */ X WcAddConverters(NULL); 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 RegisterApplicationCallbacks ( app ); X X /* -- Register all Athena widget classes */ X AriRegisterAthena ( 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 9821 Jun 28 09:12 App.c (as sent)' chmod u=rw,g=r,o=r App.c ls -l App.c echo x - App01.Everything sed 's/^X//' > App01.Everything <<'+FUNKY+STUFF+' X#ifdef Xrm_COMMENT X---------------------------------------------------------------------- X XThis demos is intended to show something about every single XAthena widget. At least one of each is instantiated. This Xexample is derived from xwidgets.c in X11R4/examples/Xaw X XNote that we do not bind the destroy callback to the application Xshell. This is because the Wc converters are not registered yet Xwhen the application shell is created by XtInitialize. We get Xfunctionally identical results by binding the destroyCallback of Xthe application shell's only child. X XThere is nothing which prevents the Wc converters from being Xregistered early, except that most programmers would rather take Xadvantage of XtInitialize() rather than programming an equivalent Xsequence of Xt... calls themselves. X X---------------------------------------------------------------------- X#endif X X# Think of these as fallback resources X# X X*input: True X XApp.wcChildren: paned X X# X# Most of the widgets are children of the paned window. X# X X*paned.wcClass: panedWidgetClass X*paned.wcChildren: quit, label, dialog, viewport, form, \ X box, stripChart, text, box2, textFile X*Paned.width: 350 X*paned.destroyCallback: MyDestroyedCB() X X*quit.wcClass: commandWidgetClass X*quit.callback: MyQuitCB( App ) X*quit.font: -*-courier-bold-r-*-240-* X X*label.wcClass: labelWidgetClass X*label.label: At least one of each Athena Widget. X*label.font: *lucida-bold-i-*-240-* X X# X# A Dialog with an Ok button which changes the list X# contents when pressed via the MyOkayCB() callback. X# X X*dialog.wcClass: dialogWidgetClass X*dialog.wcChildren: command X*Dialog*Font: *times-bold-i-*-180-* X*Dialog.label: I am a Dialog widget. X*Dialog.label.font: *new century schoolbook-bold-r-*-180-* X*Dialog.value: Enter new value here. X*Dialog*resizable: True X X*Dialog.command.wcClass: commandWidgetClass X*Dialog*command*label: ok X*Dialog*command*callback: MyOkayCB( *list ) X X# X# A Viewport with a List child X# X X*viewport.wcClass: viewportWidgetClass X*viewport.wcChildren: list X*Viewport*allowVert: True X X*list.wcClass: listWidgetClass X*list*Font: *new century schoolbook-bold-i-*-140-* X X# X# Create a Form with Buttons Including a MenuButton with Menu X# X X#*form*wcTrace: True X X*form.wcClass: formWidgetClass X*form.wcChildren: formLabel, command, toggle, menuButton, menu X*Form*resizable: True X*form*Font: *lucidabright-demibold-*-180-* X X*form.formLabel.wcClass: labelWidgetClass X*Form*formLabel.label: 0 X X*form.command.wcClass: commandWidgetClass X*form.command.fromHoriz: *formLabel X*form.command.callback: MyCountCB( *formLabel ) X X*form.toggle.wcClass: toggleWidgetClass X*form.toggle.fromHoriz: *form.command X*form.toggle.callback: MyCountCB( *formLabel ) X X*form.menuButton.wcClass: menuButtonWidgetClass X*form.menuButton.fromHoriz: *form.toggle X X*menu.wcClass: simpleMenuWidgetClass X*menu.wcManaged: False X*menu.wcChildren: menuEntry1, menuEntry2, menuLine, \ X menuEntry3, menuEntry4, menuEntry5 X X*menuEntry1.wcClass: smeBSBObjectClass X*menuEntry2.wcClass: smeBSBObjectClass X*menuEntry3.wcClass: smeBSBObjectClass X*menuEntry4.wcClass: smeBSBObjectClass X*menuEntry5.wcClass: smeBSBObjectClass X*menuLine.wcClass: smeLineObjectClass X X# X# Create a box with a clock and a logo. X# X X*Box*allowResize: True X*box.wcClass: boxWidgetClass X*box.wcChildren: clock, logo X X*clock.wcClass: clockWidgetClass X*logo.wcClass: logoWidgetClass X X# X# Create a Box widget with a label and a scrollbar. X# X X*box2.wcClass: boxWidgetClass X*box2.wcChildren: scrollbar, scroll_label X X*scrollbar.wcClass: scrollbarWidgetClass X*scrollbar.jumpProc: MyThumbedCB(*scroll_label) X*scrollbar.scrollProc: MyScrolledCB(*scroll_label) X*scrollbar*orientation: horizontal X*scrollbar*length: 100 X X*scroll_label.wcClass: labelWidgetClass X*scroll_label.Font: *-charter-bold-i-*-180-* X X# X# Create a strip chart Note that we X# need to exit, not destroy, with SriptCharts, X# because there is a bug in StripChart`DestroyGC. X# X X*stripChart.wcClass: stripChartWidgetClass X*stripChart.getValue: MyTimeSinceTouchedCB X*StripChart*update: 1 X*StripChart*jumpScroll: 1 X*StripChart.destroyCallback: WcExitCB X X# X# Text widget X# X X*text.wcClass: asciiTextWidgetClass X*text*height: 75 X*text*string: Look ma, a text widget! X*text*editType: edit X*text*scrollVertical: whenNeeded X*text*scrollHorizonal: whenNeeded X*text*Font: *-lucidatypewriter-bold-r-*-190-* X X# X# Text widget tied to a file X# X X*textFile.wcClass: asciiTextWidgetClass X*textFile*type: file X*textFile*string: /etc/motd X*textFile*scrollVertical: whenNeeded X*textFile*scrollHorizonal: whenNeeded X*textFile*height: 75 X*textFile*Font: *clean-medium-r-*-150-* +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 4777 Jul 3 14:43 App01.Everything (as sent)' chmod u=rw,g=r,o=r App01.Everything ls -l App01.Everything echo x - Ari.c sed 's/^X//' > Ari.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: @(#)Ari.c 1.0 ( 19 June 1990 ) X** X** Description: This file contains main() for a Athena Resource Interpreter X** which allows prototype interfaces to be built from X** resource files. The Widget Creation library is used. X** X** Besides the Athena widgets, Ari 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 Athena widget set only because the X** Athena classes and constructors are registered, which X** causes the Athena 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 <X11/Intrinsic.h> X#include <ctype.h> X#include <WidgetCreate.h> X X#include <Table.h> X X/****************************************************************************** X** Private Functions X******************************************************************************/ X Xextern void AriRegisterAthena (); 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 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 Athena widget classes */ X AriRegisterAthena ( 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 4026 Jul 2 16:13 Ari.c (as sent)' chmod u=rw,g=r,o=r Ari.c ls -l Ari.c echo x - Ari01.HelloWorld sed 's/^X//' > Ari01.HelloWorld <<'+FUNKY+STUFF+' X#ifdef Xrm_COMMENT X---------------------------------------------------------------------- X XThis resource file represents a very basic application: a single Xbutton which, when pressed, causes the application to exit. X XNote that you can use familiar constructs such as #ifdef-endif Xpairs, and C style /* comments */. `#' as a first character Xalso works, because it really indicates a cpp directive, and Xcpp quitely ignores (does not pass on) any unrecognized directives. X X---------------------------------------------------------------------- X#endif X XAri.wcChildren: command X X*command.wcClass: commandWidgetClass X*command.Label: Click the left mouse button here X*command.callback: WcExitCB +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 691 Jun 28 09:12 Ari01.HelloWorld (as sent)' chmod u=rw,g=r,o=r Ari01.HelloWorld ls -l Ari01.HelloWorld echo x - Ari02.Scrollbar sed 's/^X//' > Ari02.Scrollbar <<'+FUNKY+STUFF+' X#ifdef Xrm_COMMENT X---------------------------------------------------------------------- X XThis provides similar functionality as that shown by the Xaw example Xnamed xscroll, which demonstrates how to use the Scrollbar widget. X X---------------------------------------------------------------------- X#endif X XAri.wcChildren: box X X*box.wcClassName: Box X*Box*allowResize: True X*box.wcChildren: quit, scrollbar X X*quit.wcClass: commandWidgetClass X*quit.Label: Quit X*quit.callback: WcExitCB X X*scrollbar.wcClass: scrollbarWidgetClass X*scrollbar.orientation: horizontal X*scrollbar.topOfThumb: 0.5 X*scrollbar.length: 200 X*scrollbar.jumpProc: WcSystemCB(echo Jumped) X*scrollbar.scrollProc: WcSystemCB( echo Scrolled) X +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 712 Jul 3 16:31 Ari02.Scrollbar (as sent)' chmod u=rw,g=r,o=r Ari02.Scrollbar ls -l Ari02.Scrollbar echo x - Ari03.Box sed 's/^X//' > Ari03.Box <<'+FUNKY+STUFF+' X#ifdef Xrm_COMMENT X---------------------------------------------------------------------- X XThis provides similar functionality as that shown by the Xaw example Xnamed xbuttonbox. The Box widget is used to introduce the programmer to Xa widget hierarchy. X XUnlike the Shell widget a Box widget can accept more than one child. XBy using boxes and other composites it is possible to create an Xarbitrarily complex application with hundreds or event thousands of Xwidgets. X X---------------------------------------------------------------------- X#endif X XAri.wcChildren: box X X*box.wcClassName: Box X*box.wcChildren: quit, \ X lab1, lab2, lab3, lab4, lab5, \ X lab6, lab7, lab8, lab9, lab10 X X*quit.wcClassName: Command X*quit.callback: WcExitCB X*Command.Label: Click the left mouse button here to quit X X*lab1.wcClass: labelWidgetClass X*lab2.wcClass: labelWidgetClass X*lab3.wcClass: labelWidgetClass X*lab4.wcClass: labelWidgetClass X*lab5.wcClass: labelWidgetClass X*lab6.wcClass: labelWidgetClass X*lab7.wcClass: labelWidgetClass X*lab8.wcClass: labelWidgetClass X*lab9.wcClass: labelWidgetClass X*lab10.wcClass: labelWidgetClass +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 1198 Jun 28 09:12 Ari03.Box (as sent)' chmod u=rw,g=r,o=r Ari03.Box ls -l Ari03.Box echo x - Ari04.Boxes sed 's/^X//' > Ari04.Boxes <<'+FUNKY+STUFF+' X#ifdef Xrm_COMMENT X---------------------------------------------------------------------- X XThis provides similar functionality as that shown by the Xaw example Xnamed xboxes. This an example of how to create nested composite widgets. X XNote that the interface is written so the scrolling viewport Xwidget is easily deleted. If the user does not want the viewport, Xthen the Ari.wcChildren: resource can be changed to be outerbox Xinstead of view. This can be done in the user's apps-defaults file, Xor by command line options (-xrm "Ari.wcChldren: view"). X X---------------------------------------------------------------------- X#endif X XAri.wcChildren: view X#Ari.wcChildren: outerbox X XAri.view.wcClass: viewportWidgetClass XAri.view.wcChildren: outerbox X X*outerbox.wcClassName: Box X*outerbox.wcChildren: quit, \ X lab1, lab2, lab3, lab4, lab5, \ X lab6, lab7, lab8, lab9, lab10 \ X innerbox X X*innerbox.wcClassName: Box X*innerbox.wcChildren: lab1, lab2, lab3, lab4, lab5, \ X lab6, lab7, lab8, lab9, lab10 X X*quit.wcClassName: Command X*quit.callback: WcExitCB X*Command.Label: Click the left mouse button here to quit X X*lab1.wcClass: labelWidgetClass X*lab2.wcClass: labelWidgetClass X*lab3.wcClass: labelWidgetClass X*lab4.wcClass: labelWidgetClass X*lab5.wcClass: labelWidgetClass X*lab6.wcClass: labelWidgetClass X*lab7.wcClass: labelWidgetClass X*lab8.wcClass: labelWidgetClass X*lab9.wcClass: labelWidgetClass X*lab10.wcClass: labelWidgetClass X +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 1586 Jun 28 09:12 Ari04.Boxes (as sent)' chmod u=rw,g=r,o=r Ari04.Boxes ls -l Ari04.Boxes echo x - AriRegAthena.c sed 's/^X//' > AriRegAthena.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* SCCS_data: @(#)AriRegAthena.c 1.0 ( 19 June 1990 ) X* X* Subsystem_group: X* X* Widget Creation Library - Athena Resource Interpreter X* X* Module_description: X* X* This module contains registration routine for all Athena X* widget constructors and classes. X* X* Module_interface_summary: X* X* void AriRegisterAthena ( XtAppContext app ) X* X* Module_history: X* X* mm/dd/yy initials function action X* -------- -------- -------- --------------------------------------------- X* 06/19/90 D.Smyth all create. X* X* Design_notes: X* X******************************************************************************* X*/ X/* X******************************************************************************* X* Include_files. X******************************************************************************* X*/ X#ifndef MOTIF X X#include <X11/Xatom.h> X#include <X11/Intrinsic.h> X#include <X11/StringDefs.h> X X#include <X11/Xaw/AsciiText.h> X#include <X11/Xaw/Box.h> X#include <X11/Xaw/Clock.h> X#include <X11/Xaw/Command.h> X#include <X11/Xaw/Dialog.h> X#include <X11/Xaw/Form.h> X#include <X11/Xaw/Grip.h> X#include <X11/Xaw/Label.h> X#include <X11/Xaw/List.h> X#include <X11/Xaw/Logo.h> X#include <X11/Xaw/MenuButton.h> X#include <X11/Xaw/Scrollbar.h> X#include <X11/Xaw/SimpleMenu.h> X#include <X11/Xaw/SmeBSB.h> X#include <X11/Xaw/SmeLine.h> X#include <X11/Xaw/StripChart.h> X#include <X11/Xaw/Paned.h> X#include <X11/Xaw/Toggle.h> X#include <X11/Xaw/Viewport.h> X X#include <X11/Xaw/Cardinals.h> X Xvoid AriRegisterAthena ( app ) X XtAppContext app; X{ X X#define RCN( name, class ) WcRegisterClassName ( app, name, class ); X#define RCP( name, class ) WcRegisterClassPtr ( app, name, class ); X X /* -- register all Athena widget classes */ X /* Simple Widgets (Chapt 3) */ X RCN("Command", commandWidgetClass ); X RCP("commandWidgetClass", commandWidgetClass ); X RCN("Grip", gripWidgetClass ); X RCP("gripWidgetClass", gripWidgetClass ); X RCN("Label", labelWidgetClass ); X RCP("labelWidgetClass", labelWidgetClass ); X RCN("List", listWidgetClass ); X RCP("listWidgetClass", listWidgetClass ); X RCN("Scrollbar", scrollbarWidgetClass ); X RCP("scrollbarWidgetClass", scrollbarWidgetClass ); X RCN("Simple", simpleWidgetClass ); X RCP("simpleWidgetClass", simpleWidgetClass ); X RCN("StripChart", stripChartWidgetClass ); X RCP("stripChartWidgetClass", stripChartWidgetClass ); X RCN("Toggle", toggleWidgetClass ); X RCP("toggleWidgetClass", toggleWidgetClass ); X X /* Menus (Chapt 4) */ X RCN("SimpleMenu", simpleMenuWidgetClass ); X RCP("simpleMenuWidgetClass", simpleMenuWidgetClass ); X RCN("SmeBSB", smeBSBObjectClass ); X RCP("smeBSBObjectClass", smeBSBObjectClass ); X RCN("SmeLine", smeLineObjectClass ); X RCP("smeLineObjectClass", smeLineObjectClass ); X RCN("Sme", smeObjectClass ); X RCP("smeObjectClass", smeObjectClass ); X RCN("MenuButton", menuButtonWidgetClass ); X RCP("menuButtonWidgetClass", menuButtonWidgetClass ); X X /* Text Widgets (Chapt 5) */ X RCN("AsciiText", asciiTextWidgetClass ); /* NB name */ X RCP("asciiTextWidgetClass", asciiTextWidgetClass ); X RCN("AsciiSrc", asciiSrcObjectClass ); X RCP("asciiSrcObjectClass", asciiSrcObjectClass ); X RCN("AsciiSink", asciiSinkObjectClass ); X RCP("asciiSinkObjectClass", asciiSinkObjectClass ); X RCN("Text", textWidgetClass ); X RCP("textWidgetClass", textWidgetClass ); X X /* Composite and Constraint Widgets (Chapt 6) */ X RCN("Box", boxWidgetClass ); X RCP("boxWidgetClass", boxWidgetClass ); X RCN("Dialog", dialogWidgetClass ); X RCP("dialogWidgetClass", dialogWidgetClass ); X RCN("Form", formWidgetClass ); X RCP("formWidgetClass", formWidgetClass ); X RCN("Paned", panedWidgetClass ); X RCP("panedWidgetClass", panedWidgetClass ); X RCN("Viewport", viewportWidgetClass ); X RCP("viewportWidgetClass", viewportWidgetClass ); X X /* Other Interestng Widgets (not in ref manual) */ X RCN("ClockWidget", clockWidgetClass ); X RCP("clockWidgetClass", clockWidgetClass ); X RCN("LogoWidget", logoWidgetClass ); X RCP("logoWidgetClass", logoWidgetClass ); X X#undef RCN X#undef RCP X} X#endif !MOTIF +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 5054 Jun 28 09:12 AriRegAthena.c (as sent)' chmod u=rw,g=r,o=r AriRegAthena.c ls -l AriRegAthena.c echo x - COPY sed 's/^X//' > COPY <<'+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*/ +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 746 Jun 28 09:12 COPY (as sent)' chmod u=rw,g=r,o=r COPY ls -l COPY echo x - COPY_DERIVED sed 's/^X//' > COPY_DERIVED <<'+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*/ +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 2102 Jun 28 09:12 COPY_DERIVED (as sent)' chmod u=rw,g=r,o=r COPY_DERIVED ls -l COPY_DERIVED echo x - Imakefile sed 's/^X//' > Imakefile <<'+FUNKY+STUFF+' X SYSLIBS = -lm X# INSTALLLIBDIR = $(USRLIBDIR) X INSTALLLIBDIR = $(HOME)/$(HOSTTYPE)/lib X# INSTALLINCDIR = $(INCDIR)/Wc X INSTALLINCDIR = $(HOME)/$(HOSTTYPE)/include/X11/Wc X X WCLIB = -L. -lWc X DEPWCLIB = ./libWc.a X X INCLUDES = -I. -I$(INSTALLINCDIR) X DEFINES = -DNO_ALLOCA X X CDEBUGFLAGS = -g -Bstatic -DDEBUG X X# Rules for XCalP X X XCALP_LIBS = $(WCLIB) XawClientLibs X XCALP_DEPLIBS = $(DEPWCLIB) XawClientDepLibs X X XCALP_SRCS = XCalP.c AriRegAthena.c WcRegIntrinsic.c X XCALP_OBJS = XCalP.o AriRegAthena.o WcRegIntrinsic.o X XAllTarget(XCalP) XNormalProgramTarget(XCalP, $(XCALP_OBJS), $(XCALP_DEPLIBS), $(XCALP_LIBS), $(SYSLIBS)) X X# Rules for App X X APP_LIBS = $(WCLIB) XawClientLibs X APP_DEPLIBS = $(DEPWCLIB) XawClientDepLibs X X APP_SRCS = App.c AriRegAthena.c X APP_OBJS = App.o AriRegAthena.o X XAllTarget(App) XNormalProgramTarget(App, $(APP_OBJS), $(APP_DEPLIBS), $(APP_LIBS), $(SYSLIBS)) X X# Rules for Ari X X ARI_LIBS = $(WCLIB) XawClientLibs X ARI_DEPLIBS = $(DEPWCLIB) XawClientDepLibs X X ARI_SRCS = Ari.c AriRegAthena.c Table.c X ARI_OBJS = Ari.o AriRegAthena.o Table.o X XAllTarget(Ari) XNormalProgramTarget(Ari, $(ARI_OBJS), $(ARI_DEPLIBS), $(ARI_LIBS), $(SYSLIBS)) X X LIBWC_INSTINCS = WidgetCreate.h X LIBWC_INCS = $(LIBWC_INSTINCS) WidgetCreateP.h X LIBWC_SRCS = WcCreateFunc.c WcCallbacks.c WcConverters.c WcNameFuncs.c \ X WcRegister.c WcActions.c X LIBWC_OBJS = WcCreateFunc.o WcCallbacks.o WcConverters.o WcNameFuncs.o \ X WcRegister.o WcActions.o X LIBWC_DEFINES = X XNormalLibraryObjectRule() X XNormalLibraryTarget(Wc, $(LIBWC_OBJS)) XInstallLibrary(Wc, $(INSTALLLIBDIR)) XMakeDirectories(install, $(INSTALLINCDIR)) XInstallMultipleFlags($(LIBWC_INSTINCS), $(INSTALLINCDIR), $(INSTINCFLAGS)) X X#ifdef HAVE_MOTIF X X# Rules for Mri X X MRI_LIBS = $(WCLIB) $(MOTIFLIB) XawClientLibs X MRI_DEPLIBS = $(DEPWCLIB) $(DEPMOTIFLIB) XawClientDepLibs X X MOTIFLIB = -lXtm X DEPMOTIFLIB = $(USRLIBDIR)/libXtm.a X X MRI_SRCS = Mri.c MriRegMotif.c Table.c X MRI_OBJS = Mri.o MriRegMotif.o Table_m.o X MRI_INCLUDES = -I/usr/include/Xm X TABLEM_DEFINES = -DX11R4 -DMOTIF X MRI_DEFINES = -DMOTIF X XTable_m.o: Table.c X $(RM) $@ X $(CC) -c $(CFLAGS) $(TABLEM_DEFINES) $(MRI_INCLUDES) Table.c \ X -o Table_m.o X XMri.o: Mri.c X $(RM) $@ X $(CC) -c $(CFLAGS) $(MRI_DEFINES) $(MRI_INCLUDES) $*.c X XMriRegMotif.o: MriRegMotif.c X $(RM) $@ X $(CC) -c $(CFLAGS) $(MRI_DEFINES) $(MRI_INCLUDES) $*.c X XAllTarget(Mri) XNormalProgramTarget(Mri, $(MRI_OBJS), $(MRI_DEPLIBS), $(MRI_LIBS), $(SYSLIBS)) X XLIBWCM_INSTINCS = WidgetCreate.h X LIBWCM_INCS = $(LIBWCM_INSTINCS) WidgetCreateP.h X LIBWCM_SRCS = WcCreateFunc.c WcCallbacks.c WcConverters.c WcNameFuncs.c \ X WcRegister.c WcActions.c X LIBWCM_OBJS = WcmCreateFunc.o WcmCallbacks.o WcmConverters.o \ X WcmNameFuncs.o WcmRegister.o WcmActions.o XLIBCWM_INCLUDES = -I/usr/include/Xm X LIBWCM_DEFINES = -DMOTIF X XWcmCreateFunc.o: WcCreateFunc.c X $(RM) $@ X $(CC) -c $(CFLAGS) $(LIBWCM_DEFINES) $(LIBWCM_INCLUDES) \ X WcCreateFunc.c -o WcmCreateFunc.o XWcmCallbacks.o: WcCallbacks.c X $(RM) $@ X $(CC) -c $(CFLAGS) $(LIBWCM_DEFINES) $(LIBWCM_INCLUDES) \ X WcCallbacks.c -o WcmCallbacks.o XWcmConverters.o: WcConverters.c X $(RM) $@ X $(CC) -c $(CFLAGS) $(LIBWCM_DEFINES) $(LIBWCM_INCLUDES) \ X WcConverters.c -o WcmConverters.o XWcmNameFuncs.o: WcNameFuncs.c X $(RM) $@ X $(CC) -c $(CFLAGS) $(LIBWCM_DEFINES) $(LIBWCM_INCLUDES) \ X WcNameFuncs.c -o WcmNameFuncs.o XWcmRegister.o: WcRegister.c X $(RM) $@ X $(CC) -c $(CFLAGS) $(LIBWCM_DEFINES) $(LIBWCM_INCLUDES) \ X WcRegister.c -o WcmRegister.o XWcmActions.o: WcActions.c X $(RM) $@ X $(CC) -c $(CFLAGS) $(LIBWCM_DEFINES) $(LIBWCM_INCLUDES) \ X WcActions.c -o WcmActions.o X XNormalLibraryTarget(Wcm, $(LIBWCM_OBJS)) XInstallLibrary(Wcm, $(INSTALLLIBDIR)) XMakeDirectories(install, $(INSTALLINCDIR)) XInstallMultipleFlags($(LIBWCM_INSTINCS), $(INSTALLINCDIR), $(INSTINCFLAGS)) X X#endif +FUNKY+STUFF+ echo '-rw-r--r-- 1 david 3969 Jul 2 12:38 Imakefile (as sent)' chmod u=rw,g=r,o=r Imakefile ls -l Imakefile exit 0 dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only.