home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume8 / wcl / part01 next >
Encoding:
Internet Message Format  |  1990-07-06  |  62.4 KB

  1. Path: uunet!jarthur!usc!cs.utexas.edu!sun-barr!newstop!sun!devvax.Jpl.Nasa.Gov
  2. From: david@devvax.Jpl.Nasa.Gov (David E. Smyth)
  3. Newsgroups: comp.sources.x
  4. Subject: v08i031: wcl - Widget Creation Library, Part01/06
  5. Message-ID: <138457@sun.Eng.Sun.COM>
  6. Date: 6 Jul 90 07:40:07 GMT
  7. Sender: news@sun.Eng.Sun.COM
  8. Lines: 1780
  9. Approved: argv@sun.com
  10.  
  11. Submitted-by: david@devvax.Jpl.Nasa.Gov (David E. Smyth)
  12. Posting-number: Volume 8, Issue 31
  13. Archive-name: wcl/part01
  14.  
  15. # to unbundle, "sh" this file -- DO NOT use csh
  16. #  SHAR archive format.  Archive created Tue Jul 3 16:47:51 PDT 1990
  17. echo x - 1stREADME
  18. sed 's/^X//' > 1stREADME <<'+FUNKY+STUFF+'
  19. XThe Widget Creation Library Distribution
  20. X----------------------------------------
  21. X
  22. XThe Widget Creation Library is a cleanup and enhancement of Martin
  23. XBrunecky's second posting of WsXc.
  24. X
  25. XThe emphasis of the cleanup was to provide a separation of functionality
  26. Xand declarations between source and include files, to make the naming
  27. Xconcise and unique, and to reduce the complexity of the interface between
  28. Xthe library and the application (it was pretty darn good already).
  29. X
  30. XThe emphasis of the enhancements were to add clear(er) warning and
  31. Xerror messages, add more utility callbacks, and to provide a few simple
  32. Xfunctions which make writing callbacks and converters a little easier.
  33. X
  34. XOne of the guiding principles was and is KISS.  This is intended to
  35. Xbe a very small library which provides very big gains in productivity
  36. Xfor programmers developing applications using the various widget
  37. Xsets based on the Xt Intrinsics.  A large number of the total lines
  38. Xof code provide error messages.  The rest is quite straight forward.
  39. X
  40. XThis directory contains files which make up libWc, the Widget Creation
  41. XLibrary, Ari, the Athena Resource Interpreter, and Mri, the Motif
  42. XResource Interpreter.
  43. X
  44. XAuthors
  45. X-------
  46. X
  47. XMartin Brunecky at Auto-trol Technology, Denver (marbru@auto-trol.UUCP)
  48. Xwrote the initial code and posted it to comp.windows.x with the title
  49. XPOOR MAN's UIL - WsXc.
  50. X
  51. XDavid Harrison of the UC Berkeley Electronics Research Lab
  52. X(davidh@ic.Berkeley.EDU or ...!ucbvax!ucbcad!davidh) wrote a very
  53. Xuseful Table widget.  It is so good I've included it with this
  54. Xdistribution.  It is separately available from archive sites.  See
  55. XTableREADME.ANNOUNCE and TableREADME.FIRST for information on this
  56. Xwidget.  I made very minor edits to make it work with Motif, and I
  57. Xfixed exactly one minor bug.
  58. X
  59. XRod Whitby of Austek Microsystems Pty. Ltd. in Adelaide, Australia
  60. X(rwhitby@adl.austek.oz.au) wrote the Imakefile, the XCalP example, the
  61. XWcRegIntrinsic.c file, and caught several bugs.
  62. X
  63. XThe rest was done by me, and here is my standard .sig:
  64. X
  65. X-------------------------------------------------------------------------
  66. XDavid Smyth                david@jpl-devvax.jpl.nasa.gov
  67. XSenior Software Engineer,        seismo!cit-vax!jpl-devvax!david
  68. XX and Object Guru.            (818)393-0983
  69. XJet Propulsion Lab, M/S 230-103, 4800 Oak Grove Drive, Pasadena, CA 91109
  70. X-------------------------------------------------------------------------
  71. X
  72. X
  73. X
  74. XREADME Files and Documentation
  75. X------------------------------
  76. X
  77. XThe *README files provide minimal documentation.  I think you will
  78. Xfind the comments in the source files useful.  Also, several
  79. Xexample resource files are provided with extensive comments.
  80. X
  81. XA real manual is actually being written, but it won't be available
  82. Xfor a month at least, probably not until September 1990.
  83. X
  84. XMakefiles
  85. X---------
  86. X
  87. XAn Imakefile is provided.  The Makefile can be built predictably:
  88. X
  89. X    % make Makefile
  90. X
  91. XYou may then build the delivery using this Makefile:
  92. X
  93. X    % make -f Makefile
  94. X
  95. XSeveral very simple makefiles are provided.  A driver makefile, called
  96. X`makefile' builds the Makefile using Imake, and can also be used to
  97. Xbuild the delivery for those who don't have or use Imake. The driver
  98. Xmakefile causes each of the targets to be built using separate
  99. Xmakefiles:  libWc.a is built with makefile_libWc, Mri is built with
  100. Xmakefile_Mri, and so on.
  101. X
  102. XThe intent is this: after one uses the Ari or Mri resource interpreters
  103. Xto build a prototype, one can start hacking with the desired interpreter
  104. Xand its separate makefile.
  105. X
  106. XGnu Make will be used in the future.
  107. X
  108. XBuilding The Distribution 
  109. X-------------------------
  110. X
  111. XIf you have Imake, you can build the distribution very simply.
  112. XYou may have to edit the `makefile' if you don't have Motif:
  113. Xsimply comment out line 109 which should be this one:
  114. X
  115. X    IMAKE_DEFINES = -DHAVE_MOTIF
  116. X
  117. XThen, build like other X clients and libraries:
  118. X
  119. X    % make Makefile
  120. X    % make -f Makefile
  121. X
  122. XOtherwise, you may have to set the CC, CFLAGS, and LDFLAGS macros in
  123. Xeach of the makefiles.  The makefiles work for gcc and SunOS cc when
  124. Xthe Motif libraries are installed as recommended by ICS, and when the X
  125. Xlibraries are installed reasonably.  As provided, they use gcc.
  126. X
  127. XThe easiest thing to do is simply this:
  128. X
  129. X    % make
  130. X
  131. Xwhich causes all the libraries and executables to be built.
  132. X
  133. XIf you change any of the source files, you will notice that you
  134. Xmust first remove the targets (App, Ari, and Mri) in order to
  135. Xmake anything re-build.  Do it like this:
  136. X
  137. X    % make again
  138. X
  139. Xwhich removes these targets, recompiles minimally, but of course
  140. Xre-links whether or not they really needed it.  Hey, it's not perfect,
  141. Xbut it's simple.
  142. X
  143. XIf you want things to run quickly and the library to be small,
  144. Xbuild the executables and libraries with debug flags off and
  145. Xoptimization turned on:
  146. X
  147. X    % make optimal
  148. X
  149. XTesting The Distribution
  150. X------------------------
  151. X
  152. XI have included a simple test csh script which executes all of the
  153. Xexample programs.  After you build, the test program will execute
  154. Xwhich ever or the executable targets it finds.  Just do the following:
  155. X
  156. X    % test
  157. X
  158. XWidget Creation Library
  159. X-----------------------
  160. X
  161. XThe makefiles build two versions of the library: one works quite well
  162. Xwith the Motif 1.0 widget set and uses the Motif 1.0 Intrinsics.  This
  163. Xversion is called libWcm.a, following ICS's naming convention.  The
  164. Xother version works with the Athena widget set and the X11R4 Xt
  165. XIntrinsics in general.  It is called libWc.a  
  166. X
  167. XWhen Motif 1.1 is
  168. Xreleased, it should link against the latter include file without any
  169. Xproblems.  I got the following message from Mike Yee at OSF regarding
  170. Xthis release of Mri and the Widget Creation Library:
  171. X
  172. X    Good News!  Mri is up and running under Motif 1.1!  It only required
  173. X    minor changes in the makefiles and the removal of references to
  174. X    compositeObjectClass which does not exist in the R4 intrinsics.  It
  175. X    a pretty nifty program.  Thanks for sending it.
  176. X
  177. XI applied his fixes to this release.
  178. X
  179. XMri and Ari Widget Resource Interpreters
  180. X----------------------------------------
  181. X
  182. XThere are also two "interpreters" which allow widget based user
  183. Xinterfaces to be developed and to have a few useful behaviors.  These
  184. Xinterpreters are intended to be useful for prototyping.  
  185. X
  186. XAri is the Athena Resource Interpreter, and it knows about all the
  187. XAthena widgets.  Mri is the Motif Resource Interpreter, and is knows
  188. Xabout all the Motif widgets.  Both interpreters also know about the
  189. Xvery useful Table widget, which is described in the files Table*.
  190. X
  191. XEach interpreter consists of a main() procedure, and a function which
  192. Xregisters all the known widget types.  Mri consists of Mri.c and
  193. XMriRegMotif.c while Ari consists of Ari.c and AriRegAthena.c.  The
  194. Xregistration files are intended to be independent.
  195. X
  196. XIt should be a simple task to build a single interpreter which knows
  197. Xabout every widget on earth, but if you don't have shared libs, the
  198. Xresulting executable is HUGE.
  199. X
  200. XSeveral resource files are provided for each of the interpreters.  They
  201. Xare named Ari<nn>.<description> and Mri<nn>.<description>.  To try 
  202. Xout the interpreters (after you build them), do the following:
  203. X
  204. X    % alias se setenv XENVIRONMENT
  205. X    % se Ari01.HelloWorld
  206. X    % Ari
  207. X    % se Mri07.PDWidgets
  208. X    % Mri
  209. X
  210. XThe resource files are intended to be tutorials, so they are heavily
  211. Xcommented and they explore various topics you may find interesting.
  212. X
  213. XOnce an interface is prototyped using Mri or Ari, one can take the
  214. XMri or Ari source files and makefiles and evolve them into applications.
  215. X
  216. XApp - A Sample Application
  217. X--------------------------
  218. X
  219. XThe program App is exactly one such example application.  The 
  220. Xfiles Ari.c and makefile_Ari were gradually modified as additional
  221. Xbehaviors were defined, registered with the Wc library, and bound
  222. Xto the appropriate widgets within the App01.Everything resource file.
  223. X
  224. XIf you look at App.c, you will notice that main() is very minimal.
  225. XThe application is really defined by its resource file (the look
  226. Xand feel) and the callbacks (the behavior).  Notice that the
  227. Xcallbacks use several routines provided by the Wc library.  They
  228. Xwill be introduced in another README file.
  229. X
  230. XAfter you build App, you can try it out as follows:
  231. X
  232. X    % se App01.Everything
  233. X    % App
  234. +FUNKY+STUFF+
  235. echo '-rw-r--r--  1 david        8217 Jul  3 16:13 1stREADME    (as sent)'
  236. chmod u=rw,g=r,o=r 1stREADME
  237. ls -l 1stREADME
  238. echo x - 2ndREADME
  239. sed 's/^X//' > 2ndREADME <<'+FUNKY+STUFF+'
  240. XWhat Every Application Needs
  241. X----------------------------
  242. X
  243. XAll applications should include the public header file, should
  244. Xcreate the application shell, and should call WcCreateWidgets().
  245. XThey should also include an external decl for either MriRegisterMotif
  246. Xor AriRegisterAthena(), depending on the widget set desired.
  247. X
  248. XHere is an absolute minimal Motif based application:
  249. X
  250. X/********* Cut Here ********/
  251. X#include <Xm/Xm.h>
  252. X#include <WidgetCreation.h>
  253. X
  254. Xextern void MriRegisterMotif();
  255. X
  256. Xmain( argc, argv )
  257. X    int   argc;
  258. X    char* argv[];
  259. X{
  260. X    XtAppContext app;
  261. X    Widget appShell;
  262. X
  263. X    appShell = XtInitialize( "app", "App", NULL, 0, &argc, argv);
  264. X
  265. X    app = XtWidgetToApplicationContext(appShell);
  266. X
  267. X    MriRegisterMotif ( app );
  268. X
  269. X    WcWidgetCreation ( appShell );
  270. X
  271. X    XtRealizeWidget ( appShell );
  272. X    XtMainLoop ( );
  273. X}
  274. X
  275. X/********* That's all, folks! ********/
  276. X
  277. XA minimal Athena application differs slightly due to the different
  278. Xinclude files and the different widget registration routine:
  279. X
  280. X#include <X11/Intrinsic.h>
  281. X#include <WidgetCreate.h>
  282. X
  283. Xextern void AriRegisterAthena();
  284. X
  285. Xmain( argc, argv )
  286. X    int   argc;
  287. X    char* argv[];
  288. X{
  289. X    XtAppContext app;
  290. X    Widget appShell;
  291. X
  292. X    appShell = XtInitialize( "app", "App", NULL, 0, &argc, argv);
  293. X
  294. X    app = XtWidgetToApplicationContext(appShell);
  295. X
  296. X    AriRegisterAthena ( app );
  297. X
  298. X    WcWidgetCreation ( appShell );
  299. X
  300. X    XtRealizeWidget ( appShell );
  301. X    XtMainLoop ( );
  302. X}
  303. X
  304. X/********* That's all, folks! ********/
  305. X
  306. XAs you can see, every application needs as a minimum to invoke either
  307. XMriRegisterMotif() or AriRegisterAthena(), and WcWidgetCreation().
  308. +FUNKY+STUFF+
  309. echo '-rw-r--r--  1 david        1603 Jun 28 09:12 2ndREADME    (as sent)'
  310. chmod u=rw,g=r,o=r 2ndREADME
  311. ls -l 2ndREADME
  312. echo x - 3rdREADME
  313. sed 's/^X//' > 3rdREADME <<'+FUNKY+STUFF+'
  314. XWidget Creation Resources
  315. X-------------------------
  316. X
  317. XThe Widget Creation Library allows user interfaces to be completely
  318. Xdefined within a resource file: the widget heirarchy, widget types,
  319. Xand bindings of widget callback lists to callback functions are 
  320. Xspecified in the resource file using Wc* resources.
  321. X
  322. XThe following is the complete set of resources which are
  323. Xinterpreted by the Widget Creation Library:
  324. X
  325. X     ...widget.wcChildren:     childName1, childName2, ...
  326. X     ...widget.wcClass:        classPointerName
  327. X     ...widget.wcClassName:    className
  328. X     ...widget.wcConstructor:  constructorFunctionName
  329. X     ...widget.wcTrace:        true/false (default = false)
  330. X     ...widget.wcManaged:      true/false (default = true)
  331. X     ...widget.wcCallback:     callback1(args), callback2(args), ...
  332. X     ...widget.wcDeferred:     true/false (default = false)
  333. X
  334. XIn all cases, the Widget Creation resource names can be
  335. Xspecified as Wc<name> or wc<name>, with the capitalized
  336. Xform having looser binding (representing the resource class).
  337. X
  338. XWidget Creation Library Standard Callbacks
  339. X------------------------------------------
  340. X
  341. XThe set of callbacks provided map VERY closely to Xt functions, and
  342. Xuse the standard resource syntax in all cases where it makes sense:
  343. X
  344. X    WcSetValueCB( <resource spec LHS>: <any legal resource value> )
  345. X
  346. Xso you can cut and paste the arguments and names.  Note, however, that
  347. Xwidget class names won't affect any already existing widgets!  You
  348. Xshould generally use the widget instance names.  Real examples:
  349. X
  350. X  *push.activateCallback: WcSetValueCB( *push.activateCallback: WcExitCB(1) ), \
  351. X                          WcSetValueCB( *push.labelString:      Goodbye! )
  352. X
  353. X  *fileMenu.wcCallback:   WcSetValueCB(*file.subMenuId: this)
  354. X
  355. XBelow is a complete list of callbacks which are registered by Wc whenever
  356. Xyou call WcWidgetCreation.  The "arguments" are prototypes of what one puts
  357. Xin a resouce file.  The terms mean:
  358. X
  359. X   parent       name of widget, full path or wildcarded.
  360. X   child        name of child starting from the parent widget.
  361. X   widget       see parent
  362. X   resLHS       <resource spec LHS>
  363. X   resRHS       <any legal resource value>
  364. X
  365. X    WcCreateChildrenCB   ( parent, child [, child] ... )
  366. X    WcManageChildrenCB   ( parent, child [, child] ... )
  367. X    WcUnmanageChildrenCB ( parent, child [, child] ... )
  368. X
  369. X    WcManageCB         ( widget [, widget] ... )
  370. X    WcUnmanageCB       ( widget [, widget] ... )
  371. X    WcDestroyCB        ( widget [, widget] ... )
  372. X    WcSetSensitiveCB   ( widget [, widget] ... )
  373. X    WcSetInsensitiveCB ( widget [, widget] ... )
  374. X
  375. X    WcPopupCB     ( widget )
  376. X    WcPopupGrabCB ( widget )
  377. X    WcPopdownCB   ( widget )
  378. X
  379. X    WcSetValueCB ( resLHS: resRHS )
  380. X    
  381. X    WcLoadResourceFileCB ( filename )
  382. X    
  383. X    WcExitCB ( exitValue )
  384. X
  385. XIn all cases, the name of a widget can be `this' which means
  386. X`the widget which invoked this callback'.  Its a useful shorthand.
  387. +FUNKY+STUFF+
  388. echo '-rw-r--r--  1 david        2912 Jun 28 09:12 3rdREADME    (as sent)'
  389. chmod u=rw,g=r,o=r 3rdREADME
  390. ls -l 3rdREADME
  391. echo x - 4thREADME
  392. sed 's/^X//' > 4thREADME <<'+FUNKY+STUFF+'
  393. XWidget Creation Functions
  394. X-------------------------
  395. X
  396. XTwo include files are provided which declare the functions and
  397. Xsupporting data types used by the Widget Creation Library.  Many
  398. Xapplicationsshould only need to include WidgetCreation.h which
  399. Xcontains what can be considered "public" function declarations.
  400. X
  401. XIf you are writing additional resource converters, or sophisticated
  402. Xcallbacks, you will probably want to include WidgetCreationP.h
  403. Xwhich contains what can be considered "private" function declarations
  404. Xas well as typedefs for several datatypes used by the Widget Creation
  405. XLibrary.
  406. X
  407. XWidget Set Registration Functions
  408. X---------------------------------
  409. X
  410. XTwo non-library functions are also provided in separate files:
  411. X
  412. XMriRegMotif.c contains the single function MriRegisterMotif().  This
  413. Xfunction lets the Wc library know about all the Motif widget class
  414. Xnames (like XmPushButtonGadget), class pointers (like
  415. XxmPushButtonGadgetClass), and convenience constructors (like
  416. XXmCreatePushButtonGadget).
  417. X
  418. XAriRegAthena.c contains the single function AriRegisterAthena().  This
  419. Xfunction lets the Wc library know about all the Athena widget class
  420. Xnamed (like Command), and class pointers (like commandWidgetClass).
  421. X
  422. XWcWidgetCreation() - see WcCreateFunc.c
  423. X------------------
  424. X
  425. XThis function takes a Widget as its only argument.  A widget tree
  426. Xrooted at the widget is created from the Xrm database.  This widget
  427. Xis called the root widget in this discussion, but it can really be any
  428. Xwidget.
  429. X
  430. XThe Xrm database is usually loaded as a matter of course by calling
  431. XXtInitialize().  It is possible to load the resource database directly,
  432. Xusing XrmGetFileDatabase() and XrmMergeDatabases().  See the function
  433. XWcLoadResourceFileCB in the file WcCallbacks.c for an example.
  434. X
  435. XWcWidgetCreation() obtains the wcChildren resource from the widget.
  436. XIf it is non-null, WcWidgetCreation() attempts to create each of 
  437. Xthe named children.  For each child, it obtains the wcClass, wcClassName,
  438. XwcConstructor, wcDeferred, wcTrace, wcManaged, wcCallback, and wcChildren 
  439. Xresources.  If the child's creation is to be deferred (its wcDeferred
  440. Xresource is True) then the child is not created.
  441. X
  442. XOtherwise, it uses the wcClass, wcClassName, or wcConstructor resource
  443. Xto create the child widget.  If the widget's wcTrace resource is True,
  444. Xa message is printed to stdout indicating the full pathname and widget
  445. Xclass of the new widget.  If the widget's wcCallback resource is defined, 
  446. Xthen the callback list in invoked.  If the widget has any children
  447. Xlisted in its wcChildren resource, then they are each created in turn.
  448. X
  449. XAll widgets whose wcManaged resource is True (the default) are managed
  450. Xtogether with a single call to XtManageChildren().
  451. X
  452. XNote that WcWidgetCreation() does a depth first creation, and that
  453. Xthe order of creation is controlled by the order of the names in the
  454. XwcChildren resource.
  455. X
  456. XNote also that the use of constructors may provide some suprises: in
  457. Xmany cases, a constructor returns a widget which has a parent widget
  458. Xinserted.  This will cause XtWarning messages if such widgets are
  459. Xmanaged:
  460. X
  461. X    Warning: not all widgets have same parent in XtManageChildren()
  462. X
  463. XSimply don't manage these widgets.  This is usually the correct thing to
  464. Xdo anyway, because the guilty constructors are XmCreatePulldownMenu,
  465. XXmCreateWarningDialog, and the like.  In these cases, you usually want
  466. Xthem to start out unmanaged, and manage them as a result of some button
  467. Xcallback.
  468. X
  469. XIf you really DO want such a widget to be managed originally, you will hace
  470. Xto still set its wcManaged resource to be False, and manage it using the
  471. XwcCallback creation-time-callback, like this:
  472. X
  473. X    *foo.wcConstructor: XmCreateFileSelectionBox
  474. X    *foo.wcManaged:    False
  475. X    *foo.wcCallback:    WcManageCB( this )
  476. X
  477. XThat's why they are so frequently called `confusion functions' instead
  478. Xof `convenience functions.'
  479. X
  480. XWcRegisterCallback() - see WcRegister.c
  481. X--------------------
  482. X
  483. XProbably all of your useful applications will require your own
  484. Xcallbacks.  These callbacks are registered with the Widget Creation
  485. XLibrary's string-to-callback converter using WcRegisterCallback().
  486. X
  487. XIn fact, this function is used by Wc itself to register the standard Wc
  488. Xsupplied callbacks, such as WcSetValueCB and WcExitCB.  See the
  489. Xfunction WcRegisterWcCallbacks() at the end of WcCallbacks.c to see how
  490. XWc uses this function internally.
  491. X
  492. XWcRegisterClassPtr() - see WcRegister.c
  493. X--------------------
  494. X
  495. XThis function is used to tell the Widget Creation Library about a
  496. Xwidget class pointer which can be used within XtCreateWidget().  The
  497. Xname of the widget class pointer is passed in as a string (for example,
  498. X"xmPushButtonWidgetClass").  This string value can be provided as the
  499. XwcClass resource value within a resource file.
  500. X
  501. XWcRegisterClassName() - see WcRegister.c
  502. X---------------------
  503. X
  504. XThis function is used to tell the Widget Creation Library about a
  505. Xwidget class name.  The name is mapped to a widget class pointer which
  506. Xcan be used within XtCreateWidget().  The name of the widget class  is
  507. Xpassed in as a string (for example, "xmPushButton").  This string value
  508. Xcan be provided as the wcClassName resource value within a resource
  509. Xfile.
  510. X
  511. XWcRegisterConstructor()  - see WcRegister.c
  512. X-----------------------
  513. X
  514. XThis function is used to tell the Widget Creation Library about a
  515. Xwidget constructor.  The name of the constructor is passed in as a
  516. Xstring (for example, "XmCreatePushButton").  This string value can be
  517. Xprovided as the wcConstructor resource value within a resource file.
  518. +FUNKY+STUFF+
  519. echo '-rw-r--r--  1 david        5511 Jun 28 09:12 4thREADME    (as sent)'
  520. chmod u=rw,g=r,o=r 4thREADME
  521. ls -l 4thREADME
  522. echo x - 5thREADME
  523. sed 's/^X//' > 5thREADME <<'+FUNKY+STUFF+'
  524. XWriting Callback Functions
  525. X--------------------------
  526. X
  527. XYour application will consist of two fairly independent parts: the
  528. Xresource file which describes the look and alot of the feel of the
  529. Xapplication, and the callbacks which you write in C (of course,
  530. Xyou can use languages other than C, but C is probably the easiest).
  531. X
  532. XIn order to bind the widgets created due to resource specifications
  533. Xto your callbacks implemented in C, you need to write the callbacks
  534. Xso they adhere to the standard Xt callback proc typedef, and you
  535. Xneed to register your callbacks with the Widget Creation Library's
  536. Xstring-to-callback converter.
  537. X
  538. XXtCallbackProc
  539. X--------------
  540. X
  541. XAs defined by the XtIntrinsics, widget callback procedures must match
  542. Xthis typedef:
  543. X
  544. Xtypedef void (*XtCallbackProc)(
  545. X#if NeedFunctionPrototypes
  546. X    Widget              /* widget */,
  547. X    XtPointer           /* closure */,  /* data the application registered */
  548. X    XtPointer           /* call_data */ /* callback specific data */
  549. X#endif
  550. X);
  551. X
  552. XHere is an example callback proc which does nothing with its
  553. Xarguments:
  554. X
  555. Xvoid MyExitCB ( w, ignored, unused )
  556. X    Widget      w;
  557. X    caddr_t     ignored;
  558. X    caddr_t     unused;
  559. X{
  560. X    exit();
  561. X}
  562. X
  563. XYou must register this function with the Widget Creation Library
  564. Xbefore creating any widgets which might want to bind to it.
  565. XIn general, register your callbacks after calling XtInitialize()
  566. Xand before calling WcCreateWidgets().  Here is an example of
  567. Xhow you register a callback:
  568. X
  569. X#define RCALL( name, func ) WcRegisterCallback ( app, name, func, NULL )
  570. X
  571. X    RCALL( "MyExitCB", MyExitCB );
  572. X
  573. XAll registered callbacks can be bound to widget callback resources
  574. Xwithin the resource database.  For example:
  575. X
  576. X    *foo.activateCallback: MyExitCB
  577. X
  578. XMost callbacks really want to do something with the data they
  579. Xget as arguments.  The closure data, often called client data,
  580. Xcan be specified as a string within the resource database.
  581. XThe string is passed as the second argument.  For example:
  582. X
  583. Xvoid WcSystemCB ( w, shellCmdString, unused )
  584. X    Widget      w;
  585. X    char*       shellCmdString;
  586. X    caddr_t     unused;
  587. X{
  588. X    system( shellCmdString );
  589. X}
  590. X
  591. XNote that leading and trailign whitespace is NOT filtered out before
  592. Xthe callback gets it.  For example, the resource specification:
  593. X
  594. X    *foo.activateCallback: WcSystemCB( echo Howdy )
  595. X
  596. Xpasses the string " echo Howdy " to the callback.  The resource 
  597. Xspecification:
  598. X
  599. X    *foo.activateCallback: WcSystemCB( echo Howdy \
  600. X                and hello thar)
  601. X
  602. Xpasses the string " echo Howdy \t\t\t\tand hello thar" (where `\t' means
  603. Xthe tab character) to the callback.  Since the callbacks usually need
  604. Xto parse these argument strings, several Widget Creation Library
  605. Xfunctions are provided in the hope of making your life easier:
  606. X
  607. Xchar* WcCleanName( char* src, char* clean )
  608. X-------------------------------------------
  609. X
  610. XThis takes two pointers to char as arguments.  The leading whitespace
  611. Xcharacters from src are skipped, and then all characters up to but
  612. Xnot including a whitespace are copied into the buffer pointed to by
  613. Xclean.  Note the caller must provide storage for clean.  The function
  614. Xreturns a pointer to the first whitespace following what got copied
  615. Xto clean, so this function may be used in a loop.
  616. X
  617. XWidget WcFullNameToWidget ( Widget ref, char* name )
  618. X----------------------------------------------------
  619. X
  620. XThis function needs to have a pointer to a widget which is
  621. Xanywhere within the same widget tree as the name is to be resolved
  622. Xinto.  For example, one may need to get the actual widget which is
  623. Xnamed by "*Foo*bar.glorp"  The ref widget is used to find the root of
  624. Xthe widget tree, and start the name search from there.
  625. X
  626. XThe name can be any name which the resource manager can
  627. Xresolve, but the last component MUST be a widget instance
  628. Xname, it cannot be a widget class name.
  629. X
  630. XAmbiguous names are resolved as done by XtNameToWidget() upon
  631. Xwhich WcFullNameToWidget() is derived.
  632. X
  633. XVery frequently, one gets a name from an argument list using
  634. XWcCleanName() and then passes that name on to WcFullNameToWidget
  635. Xin order to manipulate that widget.  For example:
  636. X
  637. Xvoid MyPopupCB( w, name, unused )
  638. X    Widget  w;
  639. X    char*   name;
  640. X    caddr_t unused;
  641. X{
  642. X    Widget widget;
  643. X    char   clean[MAX_XRMNAME];
  644. X
  645. X    (void)WcCleanName ( name, cleanName );
  646. X    widget = WcFullNameToWidget ( w, cleanName );
  647. X
  648. X    if (XtIsShell(widget))
  649. X     XtPopup  ( widget, XtGrabNonexclusive );
  650. X}
  651. X
  652. XEfficiency Considerations
  653. X-------------------------
  654. X
  655. XI know parsing string arguments on every callback invocation is not so
  656. Xincredibly efficient.  When Motif runs on Xt release 4, then I will
  657. Xre-write the string-to-widget converter so it caches the results, and
  658. Xthen callbacks can invoke the caching converter.
  659. X
  660. XAlso, if you are very interested in performance for a real application
  661. X(after you have fleshed out the interface using Ari or Mri), you
  662. Xshould write additional callbacks which are more intelligent, and
  663. Xdetect being called repeatedly from the same widget with the same
  664. Xargument.
  665. X
  666. XYou may want to consider using the XrmQuark functions for keeping
  667. Xtrack of strings as well.  XrmQuarks are effectively indexes into
  668. Xa string symbol table kept by Xrm (part of Xlib).  Doing comparisions
  669. Xand assingments using Quarks is substantially faster at run-time than
  670. Xusing character strings.  XrmQuarkToString() and XrmStringToQuark()
  671. Xare used to convert between Quarks and Strings.
  672. +FUNKY+STUFF+
  673. echo '-rw-r--r--  1 david        5369 Jun 28 09:12 5thREADME    (as sent)'
  674. chmod u=rw,g=r,o=r 5thREADME
  675. ls -l 5thREADME
  676. echo x - App.c
  677. sed 's/^X//' > App.c <<'+FUNKY+STUFF+'
  678. X/*
  679. X** Copyright (c) 1990 David E. Smyth
  680. X**
  681. X** Redistribution and use in source and binary forms are permitted
  682. X** provided that the above copyright notice and this paragraph are
  683. X** duplicated in all such forms and that any documentation, advertising
  684. X** materials, and other materials related to such distribution and use
  685. X** acknowledge that the software was developed by David E. Smyth.  The
  686. X** name of David E. Smyth may not be used to endorse or promote products
  687. X** derived from this software without specific prior written permission.
  688. X** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  689. X** WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  690. X** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  691. X**
  692. X*/
  693. X
  694. X/******************************************************************************
  695. X**
  696. X** SCCS_data: @(#)Ari.c 1.0 ( 19 June 1990 )
  697. X**
  698. X** Description:    This file contains a sample application which uses
  699. X**        Athena widgets.  The example functionally mimics the
  700. X**        xwidgets.c example provided in examples/Xaw on the
  701. X**        X11R4 tape from MIT.  The Widget Creation library
  702. X**        is used.
  703. X**
  704. X**              Several application specific callbacks are registered
  705. X**        with the Wc library, and bound to the interface by
  706. X**        specifications within the application resource file.
  707. X**
  708. X**        Note that this application has NO fallback resources.
  709. X**        Since the resource file actually defines the complete
  710. X**        widget tree, the resource file(s) MUST be found,
  711. X**        eliminating the raison d'etre of the fallbacks.
  712. X**
  713. X** Notes:    This program uses the Xrm (X resource management) database
  714. X**        for widget tree definition and management.
  715. X**
  716. X******************************************************************************/
  717. X
  718. X/******************************************************************************
  719. X**   Include_files.
  720. X******************************************************************************/
  721. X
  722. X/*  -- Minimum include files to use WidgetCreate Library */
  723. X#include <X11/Intrinsic.h>
  724. X#include <WidgetCreate.h>
  725. X
  726. X/*  -- application specific include files */
  727. X#include <stdio.h>
  728. X#include <ctype.h>
  729. X#include <X11/Xaw/Dialog.h>
  730. X#include <X11/StringDefs.h>
  731. X
  732. X/******************************************************************************
  733. X**  Private Functions
  734. X******************************************************************************/
  735. X
  736. Xextern void AriRegisterAthena ();
  737. X
  738. X/*
  739. X    -- Tied to Dialog `Okay' button
  740. X******************************************************************************
  741. X    Adds an entry to the List widget whose name is passed as clientData.
  742. X*/
  743. X
  744. Xstatic void MyOkayCB( widget, widgetName, unused )
  745. X    Widget  widget;
  746. X    char*   widgetName;
  747. X    caddr_t unused;
  748. X{
  749. X    Widget list_widget = WcFullNameToWidget( widget, widgetName );
  750. X    static String * list = NULL;
  751. X    static int num_items = 0, allocated_items = 0;
  752. X
  753. X    if (num_items == allocated_items) {
  754. X        allocated_items += 10;
  755. X        list = (String *) XtRealloc(list, sizeof(String) * allocated_items);
  756. X    }
  757. X
  758. X    /*
  759. X     * The value returned by XawDialogGetValueString() does not remain good
  760. X     * forever so we must store is somewhere.  This creates a memory leak
  761. X     * since I don't remember these values, and free them later.  I know about
  762. X     * it, but it doesn't seem worth fixing in this example.
  763. X     */
  764. X
  765. X    list[num_items++] = XtNewString(XawDialogGetValueString(XtParent(widget)));
  766. X    XawListChange(list_widget, list, num_items, 0, True);
  767. X}
  768. X
  769. X/*
  770. X    -- MyQuitCB
  771. X******************************************************************************
  772. X    This function destroys the widget tree.
  773. X*/
  774. X
  775. Xstatic void MyQuitCB( widget, widgetName, ignored )
  776. X    Widget  widget;
  777. X    char*   widgetName;
  778. X    caddr_t ignored;
  779. X{
  780. X    Widget condemmed = WcFullNameToWidget( widget, widgetName );
  781. X    fprintf(stderr, "MyQuitCB(%s)\n", widgetName );
  782. X    if (condemmed == NULL)
  783. X        XtDestroyWidget( WcRootWidget( widget ) );
  784. X    else
  785. X    XtDestroyWidget( condemmed );
  786. X}
  787. X
  788. X/*
  789. X    -- MyTimeSinceTouchedCB  Tied to the strip chart widget.
  790. X******************************************************************************
  791. X    This function returns the number of 10s of seconds since the user
  792. X    caused an event in this application.  
  793. X    Note that the StripChart requires a return value.
  794. X*/
  795. X
  796. Xstatic void MyTimeSinceTouchedCB( widget, ignored, value_ptr )
  797. X    Widget  widget;
  798. X    caddr_t ignored;
  799. X    double* value_ptr;
  800. X{
  801. X    double *value = (double *) value_ptr;
  802. X    static double old_value = 0.0;
  803. X    static Time old_stamp = 1;
  804. X    Time new_stamp;
  805. X
  806. X    new_stamp = XtLastTimestampProcessed( XtDisplay( widget ) );
  807. X
  808. X    if (old_stamp != new_stamp) 
  809. X    {
  810. X        old_stamp = new_stamp;
  811. X        old_value = 0.0;
  812. X    }
  813. X    else 
  814. X    {
  815. X        Arg args[1];
  816. X        int update;
  817. X
  818. X        XtSetArg(args[0], XtNupdate, &update);
  819. X        XtGetValues(widget, args, 1);
  820. X        old_value += (double) update / 10.0;
  821. X    }
  822. X
  823. X    *value = old_value;
  824. X}
  825. X
  826. X/*
  827. X    -- MyCountCB  Tied to button, increments counter and displays.
  828. X******************************************************************************
  829. X   The argument is interpreted as a widget which must be a label.
  830. X   The count, after being incremented, is displayed in this label
  831. X   widget.  (Actually, it may be anything derived from Label).
  832. X*/
  833. X
  834. Xstatic void MyCountCB( widget, widgetName, ignored )
  835. X    Widget  widget;
  836. X    char*   widgetName;
  837. X    caddr_t ignored;
  838. X{
  839. X    Arg arg[1];
  840. X    char text[10];
  841. X    static int count = 0;
  842. X
  843. X    sprintf( text, " %d ", ++count );
  844. X    XtSetArg( arg[0], XtNlabel, text );
  845. X    XtSetValues( WcFullNameToWidget( widget, widgetName ), arg, 1 );
  846. X}
  847. X
  848. X/*
  849. X    -- MyThumbedCB  Tied to scrollbar's jumpProc
  850. X******************************************************************************
  851. X    Prints location of the thumb as a percentage of the height of the
  852. X    scrollbar into the labe widget named by the widgetName argument.
  853. X*/
  854. X
  855. Xstatic void MyThumbedCB( widget, widgetName, top_ptr )
  856. X    Widget  widget;
  857. X    char*   widgetName;    /* string from resource database (resource file) */
  858. X    float*  top_ptr;    /* scrollbar callback call data:  a pointer to a float
  859. X            ** containing the location of the scrollbar's thumb.
  860. X            */
  861. X{
  862. X    Widget label = WcFullNameToWidget( widget, widgetName );
  863. X    Arg args[1];
  864. X    char message[BUFSIZ];
  865. X
  866. X    sprintf( message, " Thumbed to %d%% ", (int)((*top_ptr)*100) );
  867. X    XtSetArg( args[0], XtNlabel, message );
  868. X    XtSetValues( label, args, 1 );
  869. X}
  870. X
  871. X/*
  872. X    -- MyScrolledCB  Tied to scrollbar's scrollProc
  873. X******************************************************************************
  874. X    Prints location of the pointer into the named label widget.
  875. X*/
  876. X
  877. Xstatic void MyScrolledCB( widget, widgetName, num_pixels )
  878. X    Widget  widget;
  879. X    char*   widgetName; /* string from resource database (resource file) */
  880. X    int*    num_pixels;    /* scrollbar callback call data:  the number of
  881. X            ** pixels the bar has been scrolled.
  882. X            */
  883. X{
  884. X    Widget label = WcFullNameToWidget( widget, widgetName );
  885. X    Arg args[1];
  886. X    char message[BUFSIZ];
  887. X
  888. X    sprintf( message, " Scrolled at %d pixels", num_pixels);
  889. X    XtSetArg( args[0], XtNlabel, message );
  890. X    XtSetValues( label, args, 1 );
  891. X}
  892. X
  893. X/*
  894. X    -- MyDestroyedCB  Destroy callback of application shell
  895. X******************************************************************************
  896. X    This is a Destroy callback that prints the name of the destroyed widget.
  897. X*/
  898. X
  899. Xstatic void MyDestroyedCB( widget, ignored, unused )
  900. X    Widget widget;
  901. X    caddr_t ignored;
  902. X    caddr_t unused;
  903. X{
  904. X    fprintf( stderr, "Widget %s now destroyed.\n", WcWidgetToFullName(widget));
  905. X}
  906. X
  907. X/*
  908. X    -- RegisterApplicationCallbacks
  909. X******************************************************************************
  910. X    Register all the callbacks which define the application's behaviors.
  911. X*/
  912. X
  913. Xstatic void RegisterApplicationCallbacks ( app )
  914. X    XtAppContext app;
  915. X{
  916. X#define RCALL( name, func ) WcRegisterCallback ( app, name, func, NULL );
  917. X
  918. X    RCALL( "MyOkayCB",            MyOkayCB        );
  919. X    RCALL( "MyQuitCB",            MyQuitCB        );
  920. X    RCALL( "MyTimeSinceTouchedCB",    MyTimeSinceTouchedCB    );
  921. X    RCALL( "MyCountCB",            MyCountCB        );
  922. X    RCALL( "MyThumbedCB",        MyThumbedCB        );
  923. X    RCALL( "MyScrolledCB",        MyScrolledCB        );
  924. X    RCALL( "MyDestroyedCB",        MyDestroyedCB        );
  925. X}
  926. X
  927. X/******************************************************************************
  928. X*   MAIN function
  929. X******************************************************************************/
  930. X
  931. Xmain ( argc, argv )
  932. X    int argc;
  933. X    char* argv[];
  934. X{   
  935. X    char*        appClass;
  936. X    XtAppContext app;
  937. X    Widget       appShell;
  938. X
  939. X    appClass = (char*) XtMalloc ( strlen ( argv[0] ) + 1 );
  940. X    strcpy (appClass, argv[0]);
  941. X    /* initialize first letter to make class, or first two if
  942. X    ** first is already capitalized, or don't worry about it.
  943. X    */
  944. X    if (islower(appClass[0]))
  945. X    appClass[0] = toupper(appClass[0]);
  946. X    else if (islower(appClass[1]))
  947. X        appClass[1] = toupper(appClass[1]);
  948. X    
  949. X    /* With the Athena widgets, we MUST register the Wc
  950. X    ** converters first, so WcCvtStringToWidget is invoked
  951. X    ** instead of the far less useful XmuCvtStringToWidget.
  952. X    */
  953. X    WcAddConverters(NULL);
  954. X
  955. X    /*  -- Intialize Toolkit creating the application shell */
  956. X    appShell = XtInitialize ( 
  957. X    argv[0], appClass,        /* app name and class */
  958. X    NULL, 0,             /* description of cmd line options */
  959. X    &argc, argv 
  960. X    );
  961. X    app = XtWidgetToApplicationContext(appShell);
  962. X
  963. X    /*  -- Register all application specific callbacks and widget classes */
  964. X    RegisterApplicationCallbacks ( app );
  965. X
  966. X    /*  -- Register all Athena widget classes */
  967. X    AriRegisterAthena ( app );
  968. X
  969. X    /*  -- Create widget tree below toplevel shell using Xrm database */
  970. X    WcWidgetCreation ( appShell );
  971. X
  972. X    /*  -- Realize the widget tree and enter the main application loop */
  973. X    XtRealizeWidget ( appShell );
  974. X    XtMainLoop ( );
  975. X}
  976. +FUNKY+STUFF+
  977. echo '-rw-r--r--  1 david        9821 Jun 28 09:12 App.c    (as sent)'
  978. chmod u=rw,g=r,o=r App.c
  979. ls -l App.c
  980. echo x - App01.Everything
  981. sed 's/^X//' > App01.Everything <<'+FUNKY+STUFF+'
  982. X#ifdef Xrm_COMMENT
  983. X----------------------------------------------------------------------
  984. X
  985. XThis demos is intended to show something about every single
  986. XAthena widget.  At least one of each is instantiated.  This
  987. Xexample is derived from xwidgets.c in X11R4/examples/Xaw
  988. X
  989. XNote that we do not bind the destroy callback to the application
  990. Xshell.  This is because the Wc converters are not registered yet
  991. Xwhen the application shell is created by XtInitialize.  We get
  992. Xfunctionally identical results by binding the destroyCallback of
  993. Xthe application shell's only child.
  994. X
  995. XThere is nothing which prevents the Wc converters from being
  996. Xregistered early, except that most programmers would rather take
  997. Xadvantage of XtInitialize() rather than programming an equivalent
  998. Xsequence of Xt... calls themselves.
  999. X
  1000. X----------------------------------------------------------------------
  1001. X#endif
  1002. X
  1003. X# Think of these as fallback resources
  1004. X#
  1005. X
  1006. X*input:                  True
  1007. X
  1008. XApp.wcChildren:        paned
  1009. X
  1010. X#
  1011. X# Most of the widgets are children of the paned window.
  1012. X#
  1013. X
  1014. X*paned.wcClass:        panedWidgetClass
  1015. X*paned.wcChildren:    quit, label, dialog, viewport, form, \
  1016. X            box, stripChart, text, box2, textFile
  1017. X*Paned.width:           350
  1018. X*paned.destroyCallback:    MyDestroyedCB()
  1019. X
  1020. X*quit.wcClass:        commandWidgetClass
  1021. X*quit.callback:        MyQuitCB( App )
  1022. X*quit.font:        -*-courier-bold-r-*-240-*
  1023. X
  1024. X*label.wcClass:        labelWidgetClass
  1025. X*label.label:           At least one of each Athena Widget.
  1026. X*label.font:        *lucida-bold-i-*-240-*
  1027. X
  1028. X#
  1029. X# A Dialog with an Ok button which changes the list
  1030. X# contents when pressed via the MyOkayCB() callback.
  1031. X#
  1032. X
  1033. X*dialog.wcClass:    dialogWidgetClass
  1034. X*dialog.wcChildren:    command
  1035. X*Dialog*Font:        *times-bold-i-*-180-*
  1036. X*Dialog.label:          I am a Dialog widget.
  1037. X*Dialog.label.font:    *new century schoolbook-bold-r-*-180-*
  1038. X*Dialog.value:          Enter new value here.
  1039. X*Dialog*resizable:      True
  1040. X
  1041. X*Dialog.command.wcClass:    commandWidgetClass
  1042. X*Dialog*command*label:        ok
  1043. X*Dialog*command*callback:    MyOkayCB( *list )
  1044. X
  1045. X#
  1046. X# A Viewport with a List child
  1047. X#
  1048. X
  1049. X*viewport.wcClass:    viewportWidgetClass
  1050. X*viewport.wcChildren:    list
  1051. X*Viewport*allowVert:    True
  1052. X
  1053. X*list.wcClass:        listWidgetClass
  1054. X*list*Font:        *new century schoolbook-bold-i-*-140-*
  1055. X
  1056. X#
  1057. X# Create a Form with Buttons Including a MenuButton with Menu
  1058. X#
  1059. X
  1060. X#*form*wcTrace:        True
  1061. X
  1062. X*form.wcClass:        formWidgetClass
  1063. X*form.wcChildren:    formLabel, command, toggle, menuButton, menu
  1064. X*Form*resizable:    True
  1065. X*form*Font:        *lucidabright-demibold-*-180-*
  1066. X
  1067. X*form.formLabel.wcClass:    labelWidgetClass
  1068. X*Form*formLabel.label:        0
  1069. X
  1070. X*form.command.wcClass:        commandWidgetClass
  1071. X*form.command.fromHoriz:    *formLabel
  1072. X*form.command.callback:        MyCountCB( *formLabel )
  1073. X
  1074. X*form.toggle.wcClass:        toggleWidgetClass
  1075. X*form.toggle.fromHoriz:        *form.command
  1076. X*form.toggle.callback:        MyCountCB( *formLabel )
  1077. X
  1078. X*form.menuButton.wcClass:    menuButtonWidgetClass
  1079. X*form.menuButton.fromHoriz:    *form.toggle
  1080. X
  1081. X*menu.wcClass:            simpleMenuWidgetClass
  1082. X*menu.wcManaged:        False
  1083. X*menu.wcChildren:        menuEntry1, menuEntry2, menuLine, \
  1084. X                menuEntry3, menuEntry4, menuEntry5
  1085. X
  1086. X*menuEntry1.wcClass:    smeBSBObjectClass
  1087. X*menuEntry2.wcClass:    smeBSBObjectClass
  1088. X*menuEntry3.wcClass:    smeBSBObjectClass
  1089. X*menuEntry4.wcClass:    smeBSBObjectClass
  1090. X*menuEntry5.wcClass:    smeBSBObjectClass
  1091. X*menuLine.wcClass:    smeLineObjectClass
  1092. X
  1093. X#
  1094. X# Create a box with a clock and a logo.
  1095. X#
  1096. X
  1097. X*Box*allowResize:        True
  1098. X*box.wcClass:        boxWidgetClass
  1099. X*box.wcChildren:    clock, logo
  1100. X
  1101. X*clock.wcClass:        clockWidgetClass
  1102. X*logo.wcClass:        logoWidgetClass
  1103. X
  1104. X#
  1105. X# Create a Box widget with a label and a scrollbar.
  1106. X#
  1107. X
  1108. X*box2.wcClass:        boxWidgetClass
  1109. X*box2.wcChildren:    scrollbar, scroll_label
  1110. X
  1111. X*scrollbar.wcClass:    scrollbarWidgetClass
  1112. X*scrollbar.jumpProc:    MyThumbedCB(*scroll_label)
  1113. X*scrollbar.scrollProc:    MyScrolledCB(*scroll_label)
  1114. X*scrollbar*orientation:  horizontal
  1115. X*scrollbar*length:       100
  1116. X
  1117. X*scroll_label.wcClass:    labelWidgetClass
  1118. X*scroll_label.Font:    *-charter-bold-i-*-180-*
  1119. X
  1120. X#
  1121. X# Create a strip chart  Note that we
  1122. X# need to exit, not destroy, with SriptCharts,
  1123. X# because there is a bug in StripChart`DestroyGC.
  1124. X#
  1125. X
  1126. X*stripChart.wcClass:    stripChartWidgetClass
  1127. X*stripChart.getValue:    MyTimeSinceTouchedCB
  1128. X*StripChart*update:      1
  1129. X*StripChart*jumpScroll:  1
  1130. X*StripChart.destroyCallback: WcExitCB
  1131. X
  1132. X#
  1133. X# Text widget
  1134. X#
  1135. X
  1136. X*text.wcClass:        asciiTextWidgetClass
  1137. X*text*height:            75
  1138. X*text*string:            Look ma, a text widget!
  1139. X*text*editType:          edit
  1140. X*text*scrollVertical:    whenNeeded
  1141. X*text*scrollHorizonal:   whenNeeded
  1142. X*text*Font:         *-lucidatypewriter-bold-r-*-190-*
  1143. X
  1144. X#
  1145. X# Text widget tied to a file
  1146. X#
  1147. X
  1148. X*textFile.wcClass:    asciiTextWidgetClass
  1149. X*textFile*type:          file
  1150. X*textFile*string:        /etc/motd
  1151. X*textFile*scrollVertical:    whenNeeded
  1152. X*textFile*scrollHorizonal:   whenNeeded
  1153. X*textFile*height:        75
  1154. X*textFile*Font:          *clean-medium-r-*-150-*
  1155. +FUNKY+STUFF+
  1156. echo '-rw-r--r--  1 david        4777 Jul  3 14:43 App01.Everything    (as sent)'
  1157. chmod u=rw,g=r,o=r App01.Everything
  1158. ls -l App01.Everything
  1159. echo x - Ari.c
  1160. sed 's/^X//' > Ari.c <<'+FUNKY+STUFF+'
  1161. X/*
  1162. X** Copyright (c) 1990 David E. Smyth
  1163. X**
  1164. X** Redistribution and use in source and binary forms are permitted
  1165. X** provided that the above copyright notice and this paragraph are
  1166. X** duplicated in all such forms and that any documentation, advertising
  1167. X** materials, and other materials related to such distribution and use
  1168. X** acknowledge that the software was developed by David E. Smyth.  The
  1169. X** name of David E. Smyth may not be used to endorse or promote products
  1170. X** derived from this software without specific prior written permission.
  1171. X** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  1172. X** WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  1173. X** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1174. X**
  1175. X*/
  1176. X
  1177. X/******************************************************************************
  1178. X**
  1179. X** SCCS_data: @(#)Ari.c 1.0 ( 19 June 1990 )
  1180. X**
  1181. X** Description:    This file contains main() for a Athena Resource Interpreter
  1182. X**        which allows prototype interfaces to be built from
  1183. X**        resource files.  The Widget Creation library is used.
  1184. X**
  1185. X**              Besides the Athena widgets, Ari also knows about Table
  1186. X**              widgets, simply because they are so dang useful!
  1187. X**
  1188. X** Notes:    This program uses the Xrm (X resource management) database
  1189. X**        for widget tree definition and management.  This program
  1190. X**        is dependent on the Athena widget set only because the
  1191. X**        Athena classes and constructors are registered, which
  1192. X**        causes the Athena libs to be linked in.  Someday I'll
  1193. X**        get a shared lib version of Motif and the Athena widgets,
  1194. X**        and even the OpenLook widget set, and then there will
  1195. X**        be no reason that widgets could not be mixed and matched.
  1196. X**        Doing that without shared libs makes for a HUGE executable.
  1197. X**
  1198. X******************************************************************************/
  1199. X
  1200. X/******************************************************************************
  1201. X**   Include_files.
  1202. X******************************************************************************/
  1203. X
  1204. X#include <X11/Intrinsic.h>
  1205. X#include <ctype.h>
  1206. X#include <WidgetCreate.h>
  1207. X
  1208. X#include <Table.h>
  1209. X
  1210. X/******************************************************************************
  1211. X**  Private Functions
  1212. X******************************************************************************/
  1213. X
  1214. Xextern void AriRegisterAthena ();
  1215. X
  1216. Xstatic void RegisterTable ( app )
  1217. X    XtAppContext app;
  1218. X{
  1219. X#define RCN( name, class ) WcRegisterClassName ( app, name, class );
  1220. X#define RCP( name, class ) WcRegisterClassPtr  ( app, name, class );
  1221. X
  1222. X    RCN( "Table",        tableWidgetClass );
  1223. X    RCP( "tableWidgetClass",    tableWidgetClass );
  1224. X
  1225. X#undef  RCN
  1226. X#undef  RCP
  1227. X}
  1228. X
  1229. X/******************************************************************************
  1230. X*   MAIN function
  1231. X******************************************************************************/
  1232. X
  1233. Xmain ( argc, argv )
  1234. X    int   argc;
  1235. X    char* argv[];
  1236. X{   
  1237. X    char*        appClass;
  1238. X    XtAppContext app;
  1239. X    Widget       appShell;
  1240. X
  1241. X    appClass = (char*) XtMalloc ( strlen ( argv[0] ) + 1 );
  1242. X    strcpy (appClass, argv[0]);
  1243. X    /* initialize first letter to make class, or first two if
  1244. X    ** first is already capitalized, or don't worry about it.
  1245. X    */
  1246. X    if (islower(appClass[0]))
  1247. X    appClass[0] = toupper(appClass[0]);
  1248. X    else if (islower(appClass[1]))
  1249. X        appClass[1] = toupper(appClass[1]);
  1250. X    
  1251. X    /*  -- Intialize Toolkit creating the application shell */
  1252. X    appShell = XtInitialize ( 
  1253. X    argv[0], appClass,        /* app name and class */
  1254. X    NULL, 0,             /* description of cmd line options */
  1255. X    &argc, argv 
  1256. X    );
  1257. X    app = XtWidgetToApplicationContext(appShell);
  1258. X
  1259. X    /*  -- Register all application specific callbacks and widget classes */
  1260. X    RegisterTable ( app );
  1261. X
  1262. X    /*  -- Register all Athena widget classes */
  1263. X    AriRegisterAthena ( app );
  1264. X
  1265. X    /*  -- Create widget tree below toplevel shell using Xrm database */
  1266. X    WcWidgetCreation ( appShell );
  1267. X
  1268. X    /*  -- Realize the widget tree and enter the main application loop */
  1269. X    XtRealizeWidget ( appShell );
  1270. X    XtMainLoop ( );
  1271. X}
  1272. +FUNKY+STUFF+
  1273. echo '-rw-r--r--  1 david        4026 Jul  2 16:13 Ari.c    (as sent)'
  1274. chmod u=rw,g=r,o=r Ari.c
  1275. ls -l Ari.c
  1276. echo x - Ari01.HelloWorld
  1277. sed 's/^X//' > Ari01.HelloWorld <<'+FUNKY+STUFF+'
  1278. X#ifdef Xrm_COMMENT
  1279. X----------------------------------------------------------------------
  1280. X
  1281. XThis resource file represents a very basic application: a single
  1282. Xbutton which, when pressed, causes the application to exit.
  1283. X
  1284. XNote that you can use familiar constructs such as #ifdef-endif
  1285. Xpairs, and C style /* comments */.  `#' as a first character
  1286. Xalso works, because it really indicates a cpp directive, and
  1287. Xcpp quitely ignores (does not pass on) any unrecognized directives.
  1288. X
  1289. X----------------------------------------------------------------------
  1290. X#endif
  1291. X
  1292. XAri.wcChildren:        command
  1293. X
  1294. X*command.wcClass:    commandWidgetClass
  1295. X*command.Label:        Click the left mouse button here
  1296. X*command.callback:    WcExitCB
  1297. +FUNKY+STUFF+
  1298. echo '-rw-r--r--  1 david         691 Jun 28 09:12 Ari01.HelloWorld    (as sent)'
  1299. chmod u=rw,g=r,o=r Ari01.HelloWorld
  1300. ls -l Ari01.HelloWorld
  1301. echo x - Ari02.Scrollbar
  1302. sed 's/^X//' > Ari02.Scrollbar <<'+FUNKY+STUFF+'
  1303. X#ifdef Xrm_COMMENT
  1304. X----------------------------------------------------------------------
  1305. X
  1306. XThis provides similar functionality as that shown by the Xaw example
  1307. Xnamed xscroll, which demonstrates how to use the Scrollbar widget.
  1308. X
  1309. X----------------------------------------------------------------------
  1310. X#endif
  1311. X
  1312. XAri.wcChildren:        box
  1313. X
  1314. X*box.wcClassName:    Box
  1315. X*Box*allowResize:    True
  1316. X*box.wcChildren:    quit, scrollbar
  1317. X
  1318. X*quit.wcClass:        commandWidgetClass
  1319. X*quit.Label:        Quit
  1320. X*quit.callback:        WcExitCB
  1321. X
  1322. X*scrollbar.wcClass:    scrollbarWidgetClass
  1323. X*scrollbar.orientation:    horizontal
  1324. X*scrollbar.topOfThumb:  0.5
  1325. X*scrollbar.length:    200
  1326. X*scrollbar.jumpProc:    WcSystemCB(echo Jumped)
  1327. X*scrollbar.scrollProc:    WcSystemCB( echo Scrolled)
  1328. X
  1329. +FUNKY+STUFF+
  1330. echo '-rw-r--r--  1 david         712 Jul  3 16:31 Ari02.Scrollbar    (as sent)'
  1331. chmod u=rw,g=r,o=r Ari02.Scrollbar
  1332. ls -l Ari02.Scrollbar
  1333. echo x - Ari03.Box
  1334. sed 's/^X//' > Ari03.Box <<'+FUNKY+STUFF+'
  1335. X#ifdef Xrm_COMMENT
  1336. X----------------------------------------------------------------------
  1337. X
  1338. XThis provides similar functionality as that shown by the Xaw example
  1339. Xnamed xbuttonbox.  The Box widget is used to introduce the programmer to
  1340. Xa widget hierarchy.
  1341. X
  1342. XUnlike the Shell widget a Box widget can accept more than one child.
  1343. XBy using boxes and other composites it is possible to create an
  1344. Xarbitrarily complex application with hundreds or event thousands of
  1345. Xwidgets.
  1346. X
  1347. X----------------------------------------------------------------------
  1348. X#endif
  1349. X
  1350. XAri.wcChildren:        box
  1351. X
  1352. X*box.wcClassName:    Box
  1353. X*box.wcChildren:    quit, \
  1354. X            lab1, lab2, lab3, lab4, lab5, \
  1355. X            lab6, lab7, lab8, lab9, lab10
  1356. X
  1357. X*quit.wcClassName:    Command
  1358. X*quit.callback:        WcExitCB
  1359. X*Command.Label:    Click the left mouse button here to quit
  1360. X
  1361. X*lab1.wcClass:        labelWidgetClass
  1362. X*lab2.wcClass:          labelWidgetClass
  1363. X*lab3.wcClass:          labelWidgetClass
  1364. X*lab4.wcClass:          labelWidgetClass
  1365. X*lab5.wcClass:          labelWidgetClass
  1366. X*lab6.wcClass:          labelWidgetClass
  1367. X*lab7.wcClass:          labelWidgetClass
  1368. X*lab8.wcClass:          labelWidgetClass
  1369. X*lab9.wcClass:          labelWidgetClass
  1370. X*lab10.wcClass:         labelWidgetClass
  1371. +FUNKY+STUFF+
  1372. echo '-rw-r--r--  1 david        1198 Jun 28 09:12 Ari03.Box    (as sent)'
  1373. chmod u=rw,g=r,o=r Ari03.Box
  1374. ls -l Ari03.Box
  1375. echo x - Ari04.Boxes
  1376. sed 's/^X//' > Ari04.Boxes <<'+FUNKY+STUFF+'
  1377. X#ifdef Xrm_COMMENT
  1378. X----------------------------------------------------------------------
  1379. X
  1380. XThis provides similar functionality as that shown by the Xaw example
  1381. Xnamed xboxes.  This an example of how to create nested composite widgets.
  1382. X
  1383. XNote that the interface is written so the scrolling viewport
  1384. Xwidget is easily deleted.  If the user does not want the viewport,
  1385. Xthen the Ari.wcChildren: resource can be changed to be outerbox
  1386. Xinstead of view.  This can be done in the user's apps-defaults file,
  1387. Xor by command line options (-xrm "Ari.wcChldren: view").
  1388. X
  1389. X----------------------------------------------------------------------
  1390. X#endif
  1391. X
  1392. XAri.wcChildren:        view
  1393. X#Ari.wcChildren:    outerbox
  1394. X
  1395. XAri.view.wcClass:    viewportWidgetClass
  1396. XAri.view.wcChildren:    outerbox
  1397. X
  1398. X*outerbox.wcClassName:    Box
  1399. X*outerbox.wcChildren:    quit, \
  1400. X                        lab1, lab2, lab3, lab4, lab5, \
  1401. X                        lab6, lab7, lab8, lab9, lab10 \
  1402. X            innerbox
  1403. X
  1404. X*innerbox.wcClassName:    Box
  1405. X*innerbox.wcChildren:    lab1, lab2, lab3, lab4, lab5, \
  1406. X                        lab6, lab7, lab8, lab9, lab10
  1407. X
  1408. X*quit.wcClassName:    Command
  1409. X*quit.callback:        WcExitCB
  1410. X*Command.Label:    Click the left mouse button here to quit
  1411. X
  1412. X*lab1.wcClass:        labelWidgetClass
  1413. X*lab2.wcClass:          labelWidgetClass
  1414. X*lab3.wcClass:          labelWidgetClass
  1415. X*lab4.wcClass:          labelWidgetClass
  1416. X*lab5.wcClass:          labelWidgetClass
  1417. X*lab6.wcClass:          labelWidgetClass
  1418. X*lab7.wcClass:          labelWidgetClass
  1419. X*lab8.wcClass:          labelWidgetClass
  1420. X*lab9.wcClass:          labelWidgetClass
  1421. X*lab10.wcClass:         labelWidgetClass
  1422. X
  1423. +FUNKY+STUFF+
  1424. echo '-rw-r--r--  1 david        1586 Jun 28 09:12 Ari04.Boxes    (as sent)'
  1425. chmod u=rw,g=r,o=r Ari04.Boxes
  1426. ls -l Ari04.Boxes
  1427. echo x - AriRegAthena.c
  1428. sed 's/^X//' > AriRegAthena.c <<'+FUNKY+STUFF+'
  1429. X/*
  1430. X** Copyright (c) 1990 David E. Smyth
  1431. X**
  1432. X** Redistribution and use in source and binary forms are permitted
  1433. X** provided that the above copyright notice and this paragraph are
  1434. X** duplicated in all such forms and that any documentation, advertising
  1435. X** materials, and other materials related to such distribution and use
  1436. X** acknowledge that the software was developed by David E. Smyth.  The
  1437. X** name of David E. Smyth may not be used to endorse or promote products
  1438. X** derived from this software without specific prior written permission.
  1439. X** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  1440. X** WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  1441. X** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1442. X**
  1443. X*/
  1444. X
  1445. X/*
  1446. X* SCCS_data: @(#)AriRegAthena.c 1.0 ( 19 June 1990 )
  1447. X*
  1448. X* Subsystem_group:
  1449. X*
  1450. X*     Widget Creation Library - Athena Resource Interpreter
  1451. X*
  1452. X* Module_description:
  1453. X*
  1454. X*     This module contains registration routine for all Athena
  1455. X*     widget constructors and classes.  
  1456. X*
  1457. X* Module_interface_summary: 
  1458. X*
  1459. X*     void AriRegisterAthena ( XtAppContext app )
  1460. X*
  1461. X* Module_history:
  1462. X*                                                  
  1463. X*   mm/dd/yy  initials  function  action
  1464. X*   --------  --------  --------  ---------------------------------------------
  1465. X*   06/19/90  D.Smyth   all      create.
  1466. X*
  1467. X* Design_notes:
  1468. X*
  1469. X*******************************************************************************
  1470. X*/
  1471. X/*
  1472. X*******************************************************************************
  1473. X* Include_files.
  1474. X*******************************************************************************
  1475. X*/
  1476. X#ifndef MOTIF
  1477. X
  1478. X#include <X11/Xatom.h>
  1479. X#include <X11/Intrinsic.h>
  1480. X#include <X11/StringDefs.h>
  1481. X
  1482. X#include <X11/Xaw/AsciiText.h>
  1483. X#include <X11/Xaw/Box.h>
  1484. X#include <X11/Xaw/Clock.h>
  1485. X#include <X11/Xaw/Command.h>
  1486. X#include <X11/Xaw/Dialog.h>
  1487. X#include <X11/Xaw/Form.h>
  1488. X#include <X11/Xaw/Grip.h>
  1489. X#include <X11/Xaw/Label.h>
  1490. X#include <X11/Xaw/List.h>
  1491. X#include <X11/Xaw/Logo.h>
  1492. X#include <X11/Xaw/MenuButton.h>
  1493. X#include <X11/Xaw/Scrollbar.h>
  1494. X#include <X11/Xaw/SimpleMenu.h>
  1495. X#include <X11/Xaw/SmeBSB.h>
  1496. X#include <X11/Xaw/SmeLine.h>
  1497. X#include <X11/Xaw/StripChart.h>
  1498. X#include <X11/Xaw/Paned.h>
  1499. X#include <X11/Xaw/Toggle.h>
  1500. X#include <X11/Xaw/Viewport.h>
  1501. X
  1502. X#include <X11/Xaw/Cardinals.h>
  1503. X
  1504. Xvoid AriRegisterAthena ( app )
  1505. X    XtAppContext app;
  1506. X{
  1507. X
  1508. X#define RCN( name, class ) WcRegisterClassName ( app, name, class );
  1509. X#define RCP( name, class ) WcRegisterClassPtr  ( app, name, class );
  1510. X
  1511. X    /* -- register all Athena widget classes */
  1512. X    /* Simple Widgets (Chapt 3) */
  1513. X    RCN("Command",            commandWidgetClass    );
  1514. X    RCP("commandWidgetClass",        commandWidgetClass    );
  1515. X    RCN("Grip",                gripWidgetClass        );
  1516. X    RCP("gripWidgetClass",        gripWidgetClass        );
  1517. X    RCN("Label",            labelWidgetClass    );
  1518. X    RCP("labelWidgetClass",        labelWidgetClass    );
  1519. X    RCN("List",                listWidgetClass        );
  1520. X    RCP("listWidgetClass",        listWidgetClass        );
  1521. X    RCN("Scrollbar",            scrollbarWidgetClass    );
  1522. X    RCP("scrollbarWidgetClass",        scrollbarWidgetClass    );
  1523. X    RCN("Simple",            simpleWidgetClass    );
  1524. X    RCP("simpleWidgetClass",        simpleWidgetClass    );
  1525. X    RCN("StripChart",            stripChartWidgetClass    );
  1526. X    RCP("stripChartWidgetClass",    stripChartWidgetClass    );
  1527. X    RCN("Toggle",            toggleWidgetClass    );
  1528. X    RCP("toggleWidgetClass",        toggleWidgetClass    );
  1529. X
  1530. X    /* Menus (Chapt 4) */
  1531. X    RCN("SimpleMenu",            simpleMenuWidgetClass    );
  1532. X    RCP("simpleMenuWidgetClass",    simpleMenuWidgetClass    );
  1533. X    RCN("SmeBSB",            smeBSBObjectClass    );
  1534. X    RCP("smeBSBObjectClass",        smeBSBObjectClass    );
  1535. X    RCN("SmeLine",            smeLineObjectClass    );
  1536. X    RCP("smeLineObjectClass",        smeLineObjectClass    );
  1537. X    RCN("Sme",                smeObjectClass        );
  1538. X    RCP("smeObjectClass",        smeObjectClass        );
  1539. X    RCN("MenuButton",            menuButtonWidgetClass    );
  1540. X    RCP("menuButtonWidgetClass",    menuButtonWidgetClass    );
  1541. X
  1542. X    /* Text Widgets (Chapt 5) */
  1543. X    RCN("AsciiText",            asciiTextWidgetClass    ); /* NB name */
  1544. X    RCP("asciiTextWidgetClass",        asciiTextWidgetClass    );
  1545. X    RCN("AsciiSrc",            asciiSrcObjectClass    );
  1546. X    RCP("asciiSrcObjectClass",        asciiSrcObjectClass    );
  1547. X    RCN("AsciiSink",            asciiSinkObjectClass    );
  1548. X    RCP("asciiSinkObjectClass",        asciiSinkObjectClass    );
  1549. X    RCN("Text",                textWidgetClass        );
  1550. X    RCP("textWidgetClass",        textWidgetClass        );
  1551. X
  1552. X    /* Composite and Constraint Widgets (Chapt 6) */
  1553. X    RCN("Box",                boxWidgetClass        );
  1554. X    RCP("boxWidgetClass",        boxWidgetClass        );
  1555. X    RCN("Dialog",            dialogWidgetClass    );
  1556. X    RCP("dialogWidgetClass",        dialogWidgetClass    );
  1557. X    RCN("Form",                formWidgetClass        );
  1558. X    RCP("formWidgetClass",        formWidgetClass        );
  1559. X    RCN("Paned",            panedWidgetClass    );
  1560. X    RCP("panedWidgetClass",        panedWidgetClass    );
  1561. X    RCN("Viewport",            viewportWidgetClass    );
  1562. X    RCP("viewportWidgetClass",        viewportWidgetClass    );
  1563. X
  1564. X    /* Other Interestng Widgets (not in ref manual) */
  1565. X    RCN("ClockWidget",            clockWidgetClass    );
  1566. X    RCP("clockWidgetClass",        clockWidgetClass    );
  1567. X    RCN("LogoWidget",            logoWidgetClass        );
  1568. X    RCP("logoWidgetClass",        logoWidgetClass        );
  1569. X
  1570. X#undef RCN
  1571. X#undef RCP
  1572. X}
  1573. X#endif !MOTIF
  1574. +FUNKY+STUFF+
  1575. echo '-rw-r--r--  1 david        5054 Jun 28 09:12 AriRegAthena.c    (as sent)'
  1576. chmod u=rw,g=r,o=r AriRegAthena.c
  1577. ls -l AriRegAthena.c
  1578. echo x - COPY
  1579. sed 's/^X//' > COPY <<'+FUNKY+STUFF+'
  1580. X/*
  1581. X** Copyright (c) 1990 David E. Smyth
  1582. X**
  1583. X** Redistribution and use in source and binary forms are permitted
  1584. X** provided that the above copyright notice and this paragraph are
  1585. X** duplicated in all such forms and that any documentation, advertising
  1586. X** materials, and other materials related to such distribution and use
  1587. X** acknowledge that the software was developed by David E. Smyth.  The
  1588. X** name of David E. Smyth may not be used to endorse or promote products
  1589. X** derived from this software without specific prior written permission.
  1590. X** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  1591. X** WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  1592. X** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1593. X**
  1594. X*/
  1595. +FUNKY+STUFF+
  1596. echo '-rw-r--r--  1 david         746 Jun 28 09:12 COPY    (as sent)'
  1597. chmod u=rw,g=r,o=r COPY
  1598. ls -l COPY
  1599. echo x - COPY_DERIVED
  1600. sed 's/^X//' > COPY_DERIVED <<'+FUNKY+STUFF+'
  1601. X/*
  1602. X** Copyright (c) 1990 David E. Smyth
  1603. X**
  1604. X** This file was derived from work performed by Martin Brunecky at
  1605. X** Auto-trol Technology Corporation, Denver, Colorado, under the
  1606. X** following copyright:
  1607. X**
  1608. X*******************************************************************************
  1609. X* Copyright 1990 by Auto-trol Technology Corporation, Denver, Colorado.
  1610. X*
  1611. X*                        All Rights Reserved
  1612. X*
  1613. X* Permission to use, copy, modify, and distribute this software and its
  1614. X* documentation for any purpose and without fee is hereby granted, provided
  1615. X* that the above copyright notice appears on all copies and that both the
  1616. X* copyright and this permission notice appear in supporting documentation
  1617. X* and that the name of Auto-trol not be used in advertising or publicity
  1618. X* pertaining to distribution of the software without specific, prior written
  1619. X* permission.
  1620. X*
  1621. X* Auto-trol disclaims all warranties with regard to this software, including
  1622. X* all implied warranties of merchantability and fitness, in no event shall
  1623. X* Auto-trol be liable for any special, indirect or consequential damages or
  1624. X* any damages whatsoever resulting from loss of use, data or profits, whether
  1625. X* in an action of contract, negligence or other tortious action, arising out
  1626. X* of or in connection with the use or performance of this software.
  1627. X*******************************************************************************
  1628. X**
  1629. X** Redistribution and use in source and binary forms are permitted
  1630. X** provided that the above copyright notice and this paragraph are
  1631. X** duplicated in all such forms and that any documentation, advertising
  1632. X** materials, and other materials related to such distribution and use
  1633. X** acknowledge that the software was developed by David E. Smyth.  The
  1634. X** name of David E. Smyth may not be used to endorse or promote products
  1635. X** derived from this software without specific prior written permission.
  1636. X** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  1637. X** WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  1638. X** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  1639. X**
  1640. X*/
  1641. +FUNKY+STUFF+
  1642. echo '-rw-r--r--  1 david        2102 Jun 28 09:12 COPY_DERIVED    (as sent)'
  1643. chmod u=rw,g=r,o=r COPY_DERIVED
  1644. ls -l COPY_DERIVED
  1645. echo x - Imakefile
  1646. sed 's/^X//' > Imakefile <<'+FUNKY+STUFF+'
  1647. X        SYSLIBS = -lm
  1648. X# INSTALLLIBDIR = $(USRLIBDIR)
  1649. X  INSTALLLIBDIR = $(HOME)/$(HOSTTYPE)/lib
  1650. X# INSTALLINCDIR = $(INCDIR)/Wc
  1651. X  INSTALLINCDIR = $(HOME)/$(HOSTTYPE)/include/X11/Wc
  1652. X
  1653. X          WCLIB = -L. -lWc
  1654. X       DEPWCLIB = ./libWc.a
  1655. X
  1656. X       INCLUDES = -I. -I$(INSTALLINCDIR)
  1657. X        DEFINES = -DNO_ALLOCA
  1658. X
  1659. X    CDEBUGFLAGS = -g -Bstatic -DDEBUG
  1660. X
  1661. X# Rules for XCalP
  1662. X
  1663. X       XCALP_LIBS = $(WCLIB) XawClientLibs
  1664. X    XCALP_DEPLIBS = $(DEPWCLIB) XawClientDepLibs
  1665. X
  1666. X       XCALP_SRCS = XCalP.c AriRegAthena.c WcRegIntrinsic.c
  1667. X       XCALP_OBJS = XCalP.o AriRegAthena.o WcRegIntrinsic.o
  1668. X
  1669. XAllTarget(XCalP)
  1670. XNormalProgramTarget(XCalP, $(XCALP_OBJS), $(XCALP_DEPLIBS), $(XCALP_LIBS), $(SYSLIBS))
  1671. X
  1672. X# Rules for App
  1673. X
  1674. X       APP_LIBS = $(WCLIB) XawClientLibs
  1675. X    APP_DEPLIBS = $(DEPWCLIB) XawClientDepLibs
  1676. X
  1677. X       APP_SRCS = App.c AriRegAthena.c
  1678. X       APP_OBJS = App.o AriRegAthena.o
  1679. X
  1680. XAllTarget(App)
  1681. XNormalProgramTarget(App, $(APP_OBJS), $(APP_DEPLIBS), $(APP_LIBS), $(SYSLIBS))
  1682. X
  1683. X# Rules for Ari
  1684. X
  1685. X       ARI_LIBS = $(WCLIB) XawClientLibs
  1686. X    ARI_DEPLIBS = $(DEPWCLIB) XawClientDepLibs
  1687. X
  1688. X       ARI_SRCS = Ari.c AriRegAthena.c Table.c
  1689. X       ARI_OBJS = Ari.o AriRegAthena.o Table.o
  1690. X
  1691. XAllTarget(Ari)
  1692. XNormalProgramTarget(Ari, $(ARI_OBJS), $(ARI_DEPLIBS), $(ARI_LIBS), $(SYSLIBS))
  1693. X
  1694. X LIBWC_INSTINCS = WidgetCreate.h
  1695. X     LIBWC_INCS = $(LIBWC_INSTINCS) WidgetCreateP.h
  1696. X     LIBWC_SRCS = WcCreateFunc.c WcCallbacks.c WcConverters.c WcNameFuncs.c \
  1697. X          WcRegister.c WcActions.c 
  1698. X     LIBWC_OBJS = WcCreateFunc.o WcCallbacks.o WcConverters.o WcNameFuncs.o \
  1699. X          WcRegister.o WcActions.o
  1700. X  LIBWC_DEFINES = 
  1701. X
  1702. XNormalLibraryObjectRule()
  1703. X
  1704. XNormalLibraryTarget(Wc, $(LIBWC_OBJS))
  1705. XInstallLibrary(Wc, $(INSTALLLIBDIR))
  1706. XMakeDirectories(install, $(INSTALLINCDIR))
  1707. XInstallMultipleFlags($(LIBWC_INSTINCS), $(INSTALLINCDIR), $(INSTINCFLAGS))
  1708. X
  1709. X#ifdef HAVE_MOTIF
  1710. X
  1711. X# Rules for Mri
  1712. X
  1713. X       MRI_LIBS = $(WCLIB) $(MOTIFLIB) XawClientLibs
  1714. X    MRI_DEPLIBS = $(DEPWCLIB) $(DEPMOTIFLIB) XawClientDepLibs
  1715. X
  1716. X       MOTIFLIB = -lXtm
  1717. X    DEPMOTIFLIB = $(USRLIBDIR)/libXtm.a
  1718. X
  1719. X       MRI_SRCS = Mri.c MriRegMotif.c Table.c
  1720. X       MRI_OBJS = Mri.o MriRegMotif.o Table_m.o
  1721. X   MRI_INCLUDES = -I/usr/include/Xm
  1722. X TABLEM_DEFINES = -DX11R4 -DMOTIF
  1723. X    MRI_DEFINES = -DMOTIF
  1724. X
  1725. XTable_m.o: Table.c
  1726. X    $(RM) $@
  1727. X    $(CC) -c $(CFLAGS) $(TABLEM_DEFINES) $(MRI_INCLUDES) Table.c \
  1728. X        -o Table_m.o
  1729. X
  1730. XMri.o: Mri.c
  1731. X    $(RM) $@
  1732. X    $(CC) -c $(CFLAGS) $(MRI_DEFINES) $(MRI_INCLUDES) $*.c
  1733. X
  1734. XMriRegMotif.o: MriRegMotif.c
  1735. X    $(RM) $@
  1736. X    $(CC) -c $(CFLAGS) $(MRI_DEFINES) $(MRI_INCLUDES) $*.c
  1737. X
  1738. XAllTarget(Mri)
  1739. XNormalProgramTarget(Mri, $(MRI_OBJS), $(MRI_DEPLIBS), $(MRI_LIBS), $(SYSLIBS))
  1740. X
  1741. XLIBWCM_INSTINCS = WidgetCreate.h
  1742. X    LIBWCM_INCS = $(LIBWCM_INSTINCS) WidgetCreateP.h
  1743. X    LIBWCM_SRCS = WcCreateFunc.c WcCallbacks.c WcConverters.c WcNameFuncs.c \
  1744. X          WcRegister.c WcActions.c
  1745. X    LIBWCM_OBJS = WcmCreateFunc.o WcmCallbacks.o WcmConverters.o \
  1746. X          WcmNameFuncs.o WcmRegister.o WcmActions.o
  1747. XLIBCWM_INCLUDES = -I/usr/include/Xm
  1748. X LIBWCM_DEFINES = -DMOTIF
  1749. X
  1750. XWcmCreateFunc.o: WcCreateFunc.c
  1751. X    $(RM) $@
  1752. X     $(CC) -c $(CFLAGS) $(LIBWCM_DEFINES) $(LIBWCM_INCLUDES) \
  1753. X        WcCreateFunc.c -o WcmCreateFunc.o
  1754. XWcmCallbacks.o: WcCallbacks.c
  1755. X    $(RM) $@
  1756. X    $(CC) -c $(CFLAGS) $(LIBWCM_DEFINES) $(LIBWCM_INCLUDES) \
  1757. X        WcCallbacks.c  -o WcmCallbacks.o
  1758. XWcmConverters.o: WcConverters.c
  1759. X    $(RM) $@
  1760. X    $(CC) -c $(CFLAGS) $(LIBWCM_DEFINES) $(LIBWCM_INCLUDES) \
  1761. X        WcConverters.c -o WcmConverters.o
  1762. XWcmNameFuncs.o: WcNameFuncs.c
  1763. X    $(RM) $@
  1764. X    $(CC) -c $(CFLAGS) $(LIBWCM_DEFINES) $(LIBWCM_INCLUDES) \
  1765. X        WcNameFuncs.c  -o WcmNameFuncs.o
  1766. XWcmRegister.o: WcRegister.c
  1767. X    $(RM) $@
  1768. X    $(CC) -c $(CFLAGS) $(LIBWCM_DEFINES) $(LIBWCM_INCLUDES) \
  1769. X        WcRegister.c   -o WcmRegister.o
  1770. XWcmActions.o: WcActions.c
  1771. X    $(RM) $@
  1772. X    $(CC) -c $(CFLAGS) $(LIBWCM_DEFINES) $(LIBWCM_INCLUDES) \
  1773. X        WcActions.c    -o WcmActions.o
  1774. X
  1775. XNormalLibraryTarget(Wcm, $(LIBWCM_OBJS))
  1776. XInstallLibrary(Wcm, $(INSTALLLIBDIR))
  1777. XMakeDirectories(install, $(INSTALLINCDIR))
  1778. XInstallMultipleFlags($(LIBWCM_INSTINCS), $(INSTALLINCDIR), $(INSTINCFLAGS))
  1779. X
  1780. X#endif
  1781. +FUNKY+STUFF+
  1782. echo '-rw-r--r--  1 david        3969 Jul  2 12:38 Imakefile    (as sent)'
  1783. chmod u=rw,g=r,o=r Imakefile
  1784. ls -l Imakefile
  1785. exit 0
  1786.  
  1787. dan
  1788. ----------------------------------------------------
  1789. O'Reilly && Associates   argv@sun.com / argv@ora.com
  1790. Opinions expressed reflect those of the author only.
  1791.