home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / x / volume13 / xrainbow / part02 < prev    next >
Internet Message Format  |  1991-06-27  |  80KB

  1. Path: uunet!lll-winken!sun-barr!cronkite!newstop!exodus!maxine.WPI.EDU
  2. From: daven@maxine.WPI.EDU (Dave Nedde)
  3. Newsgroups: comp.sources.x
  4. Subject: v13i064: xrainbow, Part02/05
  5. Message-ID: <15964@exodus.Eng.Sun.COM>
  6. Date: 28 Jun 91 01:04:24 GMT
  7. References: <csx-13i063-xrainbow@uunet.UU.NET>
  8. Sender: news@exodus.Eng.Sun.COM
  9. Lines: 2432
  10. Approved: argv@sun.com
  11.  
  12. Submitted-by: daven@maxine.WPI.EDU (Dave Nedde)
  13. Posting-number: Volume 13, Issue 64
  14. Archive-name: xrainbow/part02
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then unpack
  18. # it by saving it into a file and typing "sh file".  To overwrite existing
  19. # files, type "sh file -c".  You can also feed this as standard input via
  20. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  21. # will see the following message at the end:
  22. #        "End of archive 2 (of 5)."
  23. # Contents:  xrainbow/Wc1_05/Wc/Makefile xrainbow/Wc1_05/Wc/WcActions.c
  24. #   xrainbow/Wc1_05/Wc/WcCallb.c xrainbow/X11/Xaw_d/DrawingAP.h
  25. #   xrainbow/X11/Xaw_d/Imakefile xrainbow/include/Wc
  26. #   xrainbow/include/X11 xrainbow/include/X11/Xaw_d xrainbow/main
  27. #   xrainbow/main/patchlevel.h
  28. # Wrapped by daven@ash on Mon Jun  3 12:33:21 1991
  29. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  30. if test -f 'xrainbow/Wc1_05/Wc/Makefile' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'xrainbow/Wc1_05/Wc/Makefile'\"
  32. else
  33. echo shar: Extracting \"'xrainbow/Wc1_05/Wc/Makefile'\" \(10482 characters\)
  34. sed "s/^X//" >'xrainbow/Wc1_05/Wc/Makefile' <<'END_OF_FILE'
  35. X# Makefile generated by imake - do not edit!
  36. X# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $
  37. X#
  38. X# The cpp used on this machine replaces all newlines and multiple tabs and
  39. X# spaces in a macro expansion with a single space.  Imake tries to compensate
  40. X# for this, but is not always successful.
  41. X#
  42. X
  43. X###########################################################################
  44. X# Makefile generated from "Imake.tmpl" and </tmp/IIf.a03937>
  45. X# $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $
  46. X#
  47. X# Platform-specific parameters may be set in the appropriate .cf
  48. X# configuration files.  Site-wide parameters may be set in the file
  49. X# site.def.  Full rebuilds are recommended if any parameters are changed.
  50. X#
  51. X# If your C preprocessor doesn't define any unique symbols, you'll need
  52. X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  53. X# "make Makefile", "make Makefiles", or "make World").
  54. X#
  55. X# If you absolutely can't get imake to work, you'll need to set the
  56. X# variables at the top of each Makefile as well as the dependencies at the
  57. X# bottom (makedepend will do this automatically).
  58. X#
  59. X
  60. X###########################################################################
  61. X# platform-specific configuration parameters - edit sun.cf to change
  62. X
  63. X# platform:  $XConsortium: sun.cf,v 1.38 89/12/23 16:10:10 jim Exp $
  64. X# operating system:  SunOS 4.1
  65. X
  66. X###########################################################################
  67. X# site-specific configuration parameters - edit site.def to change
  68. X
  69. X# site:  $XConsortium: site.def,v 1.21 89/12/06 11:46:50 jim Exp $
  70. X
  71. X            SHELL = /bin/sh
  72. X
  73. X              TOP = ../../.
  74. X      CURRENT_DIR = ./Wc1_05/Wc
  75. X
  76. X               AR = ar cq
  77. X  BOOTSTRAPCFLAGS =
  78. X               CC = cc
  79. X
  80. X         COMPRESS = compress
  81. X              CPP = /lib/cpp $(STD_CPP_DEFINES)
  82. X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
  83. X          INSTALL = install
  84. X               LD = ld
  85. X             LINT = lint
  86. X      LINTLIBFLAG = -C
  87. X         LINTOPTS = -axz
  88. X               LN = ln -s
  89. X             MAKE = make
  90. X               MV = mv
  91. X               CP = cp
  92. X           RANLIB = ranlib
  93. X  RANLIBINSTFLAGS =
  94. X               RM = rm -f
  95. X     STD_INCLUDES =
  96. X  STD_CPP_DEFINES =
  97. X      STD_DEFINES =
  98. X EXTRA_LOAD_FLAGS =
  99. X  EXTRA_LIBRARIES =
  100. X             TAGS = ctags
  101. X
  102. X    SHAREDCODEDEF = -DSHAREDCODE
  103. X         SHLIBDEF = -DSUNSHLIB
  104. X
  105. X    PROTO_DEFINES =
  106. X
  107. X     INSTPGMFLAGS =
  108. X
  109. X     INSTBINFLAGS = -m 0755
  110. X     INSTUIDFLAGS = -m 4755
  111. X     INSTLIBFLAGS = -m 0664
  112. X     INSTINCFLAGS = -m 0444
  113. X     INSTMANFLAGS = -m 0444
  114. X     INSTDATFLAGS = -m 0444
  115. X    INSTKMEMFLAGS = -m 4755
  116. X
  117. X          DESTDIR =
  118. X
  119. X     TOP_INCLUDES = -I$(INCROOT)
  120. X
  121. X      CDEBUGFLAGS = -O
  122. X        CCOPTIONS =
  123. X      COMPATFLAGS = -DXAW_BC
  124. X
  125. X      ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES)
  126. X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS)
  127. X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
  128. X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
  129. X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  130. X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)
  131. X   LDCOMBINEFLAGS = -X -r
  132. X
  133. X        MACROFILE = sun.cf
  134. X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
  135. X
  136. X    IMAKE_DEFINES =
  137. X
  138. X         IRULESRC = $(CONFIGDIR)
  139. X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
  140. X
  141. X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
  142. X            $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
  143. X            $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
  144. X
  145. X###########################################################################
  146. X# X Window System Build Parameters
  147. X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
  148. X
  149. X###########################################################################
  150. X# X Window System make variables; this need to be coordinated with rules
  151. X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
  152. X
  153. X          PATHSEP = /
  154. X        USRLIBDIR = $(DESTDIR)/usr/lib
  155. X           BINDIR = $(DESTDIR)/usr/bin/X11
  156. X          INCROOT = $(DESTDIR)/usr/include
  157. X     BUILDINCROOT = $(TOP)
  158. X      BUILDINCDIR = $(BUILDINCROOT)/X11
  159. X      BUILDINCTOP = ..
  160. X           INCDIR = $(INCROOT)/X11
  161. X           ADMDIR = $(DESTDIR)/usr/adm
  162. X           LIBDIR = $(USRLIBDIR)/X11
  163. X        CONFIGDIR = $(LIBDIR)/config
  164. X       LINTLIBDIR = $(USRLIBDIR)/lint
  165. X
  166. X          FONTDIR = $(LIBDIR)/fonts
  167. X         XINITDIR = $(LIBDIR)/xinit
  168. X           XDMDIR = $(LIBDIR)/xdm
  169. X           AWMDIR = $(LIBDIR)/awm
  170. X           TWMDIR = $(LIBDIR)/twm
  171. X           GWMDIR = $(LIBDIR)/gwm
  172. X          MANPATH = $(DESTDIR)/usr/man
  173. X    MANSOURCEPATH = $(MANPATH)/man
  174. X           MANDIR = $(MANSOURCEPATH)n
  175. X        LIBMANDIR = $(MANSOURCEPATH)3
  176. X      XAPPLOADDIR = $(LIBDIR)/app-defaults
  177. X
  178. X        SOXLIBREV = 4.2
  179. X          SOXTREV = 4.0
  180. X         SOXAWREV = 4.0
  181. X        SOOLDXREV = 4.0
  182. X         SOXMUREV = 4.0
  183. X        SOXEXTREV = 4.0
  184. X
  185. X       FONTCFLAGS = -t
  186. X
  187. X     INSTAPPFLAGS = $(INSTDATFLAGS)
  188. X
  189. X            IMAKE = imake
  190. X           DEPEND = makedepend
  191. X              RGB = rgb
  192. X            FONTC = bdftosnf
  193. X        MKFONTDIR = mkfontdir
  194. X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier.sh
  195. X
  196. X        CONFIGSRC = $(TOP)/config
  197. X        CLIENTSRC = $(TOP)/clients
  198. X          DEMOSRC = $(TOP)/demos
  199. X           LIBSRC = $(TOP)/lib
  200. X          FONTSRC = $(TOP)/fonts
  201. X       INCLUDESRC = $(TOP)/X11
  202. X        SERVERSRC = $(TOP)/server
  203. X          UTILSRC = $(TOP)/util
  204. X        SCRIPTSRC = $(UTILSRC)/scripts
  205. X       EXAMPLESRC = $(TOP)/examples
  206. X       CONTRIBSRC = $(TOP)/../contrib
  207. X           DOCSRC = $(TOP)/doc
  208. X           RGBSRC = $(TOP)/rgb
  209. X        DEPENDSRC = $(UTILSRC)/makedepend
  210. X         IMAKESRC = $(CONFIGSRC)
  211. X         XAUTHSRC = $(LIBSRC)/Xau
  212. X          XLIBSRC = $(LIBSRC)/X
  213. X           XMUSRC = $(LIBSRC)/Xmu
  214. X       TOOLKITSRC = $(LIBSRC)/Xt
  215. X       AWIDGETSRC = $(LIBSRC)/Xaw
  216. X       OLDXLIBSRC = $(LIBSRC)/oldX
  217. X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
  218. X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  219. X     MKFONTDIRSRC = $(FONTSRC)/mkfontdir
  220. X     EXTENSIONSRC = $(TOP)/extensions
  221. X
  222. X  DEPEXTENSIONLIB = $(USRLIBDIR)/libXext.a
  223. X     EXTENSIONLIB =  -lXext
  224. X
  225. X          DEPXLIB = $(DEPEXTENSIONLIB)
  226. X             XLIB = $(EXTENSIONLIB) -lX11
  227. X
  228. X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
  229. X         XAUTHLIB =  -lXau
  230. X
  231. X        DEPXMULIB =
  232. X           XMULIB = -lXmu
  233. X
  234. X       DEPOLDXLIB =
  235. X          OLDXLIB = -loldX
  236. X
  237. X      DEPXTOOLLIB =
  238. X         XTOOLLIB = -lXt
  239. X
  240. X        DEPXAWLIB =
  241. X           XAWLIB = -lXaw
  242. X
  243. X LINTEXTENSIONLIB = $(USRLIBDIR)/llib-lXext.ln
  244. X         LINTXLIB = $(USRLIBDIR)/llib-lX11.ln
  245. X          LINTXMU = $(USRLIBDIR)/llib-lXmu.ln
  246. X        LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln
  247. X          LINTXAW = $(USRLIBDIR)/llib-lXaw.ln
  248. X
  249. X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
  250. X
  251. X         DEPLIBS1 = $(DEPLIBS)
  252. X         DEPLIBS2 = $(DEPLIBS)
  253. X         DEPLIBS3 = $(DEPLIBS)
  254. X
  255. X###########################################################################
  256. X# Imake rules for building libraries, programs, scripts, and data files
  257. X# rules:  $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $
  258. X
  259. X###########################################################################
  260. X# start of Imakefile
  261. X
  262. X###########################################################################
  263. X# Imake rules for building and installing libraries, programs,
  264. X# apps-defaults, and other data files.  Unlike Imake.rules, these
  265. X# rules allow files to be installed anywhere.
  266. X#
  267. X# These rules *override* rules of the same name defined in Imake.rules!!
  268. X#
  269. X# New variables:
  270. X#    INSTBIN        default to $BINDIR - programs installed here
  271. X#    INSTMAN        default to $MANDIR - man pages installed here
  272. X#    INSTAPP        default to $XAPPLOADDIR - apps-defaults files go here
  273. X#
  274. X# David E. Smyth: Install.rules Wed Jan  2 07:12:10 PST 1991
  275. X
  276. X###########################################################################
  277. X# Makefile defines for Widget Creation Library distribution.
  278. X# David E. Smyth: Wc.tmpl Wed Jan  2 07:44:04 PST 1991
  279. X
  280. X      INSTLIB = $(LIBDIR)
  281. X      INSTLIN = $(LINTLIBDIR)
  282. X      INSTINC = $(INCDIR)
  283. X      INSTBIN = $(BINDIR)
  284. X      INSTMAN = $(MANDIR)
  285. X      INSTAPP = $(XAPPLOADDIR)
  286. X
  287. X   WCTOPDIR = .
  288. X
  289. X      WCLIB = -L$(INSTLIB) -lWc
  290. X      XPLIB = -L$(INSTLIB) -lXp
  291. X     XMPLIB = -L$(INSTLIB) -lXmp
  292. X
  293. X    SoWcRev = 1.05
  294. X
  295. X# Imakefile for libWc
  296. X# This file is derived from mit/lib/Xt/Imakefile
  297. X
  298. XCDEBUGFLAGS= -g
  299. X
  300. X# If you are building libWc to run on top of an Xt older
  301. X# than X11R4, then you must add Xt4GetResL.o to the list
  302. X# of object files built into libWc.
  303. X# Just define 0 to 1 (see ../Wc.tmpl) and it will build properly.
  304. X
  305. X    APP_DEFINES = -DXAPPLOADDIR=\"$(XAPPLOADDIR)$(PATHSEP)\"
  306. X
  307. XHEADERS = WcCreate.h WcCreateP.h
  308. X
  309. XSRCS = \
  310. X    WcActions.c \
  311. X    WcCallb.c \
  312. X    WcConvert.c \
  313. X    WcCreate.c \
  314. X    WcName.c \
  315. X    WcReg.c \
  316. X    WcRegXt.c \
  317. X    $(OLD_XT_SRCS)
  318. X
  319. XOBJS = \
  320. X    WcActions.o \
  321. X    WcCallb.o \
  322. X    WcConvert.o \
  323. X    WcCreate.o \
  324. X    WcName.o \
  325. X    WcReg.o \
  326. X    WcRegXt.o \
  327. X    $(OLD_XT_OBJS)
  328. X
  329. Xall::
  330. X
  331. Xall:: libWc.a
  332. X
  333. XlibWc.a: $(OBJS)
  334. X    $(RM) $@
  335. X    $(AR) $@ $(OBJS)
  336. X    $(RANLIB) $@
  337. X
  338. Xinstall:: libWc.a
  339. X    $(INSTALL) -c $(INSTLIBFLAGS) libWc.a $(INSTLIB)
  340. X    $(RANLIB) $(RANLIBINSTFLAGS) $(INSTLIB)/libWc.a
  341. X
  342. Xlintlib:: llib-lWc.ln
  343. X
  344. Xllib-lWc.ln: $(SRCS)
  345. X    $(RM) $@
  346. X    $(LINT) $(LINTLIBFLAG)Wc $(LINTFLAGS) $(SRCS)
  347. X
  348. Xinstall.ln:: llib-lWc.ln
  349. X    $(INSTALL) -c $(INSTLIBFLAGS) llib-lWc.ln $(INSTLIN)
  350. X
  351. Xinstall::
  352. X    $(MKDIRHIER) $(INSTINC)/Wc
  353. X
  354. Xinstall:: $(HEADERS)
  355. X    @case '${MFLAGS}' in *[i]*) set +e;; esac; \
  356. X    for i in $(HEADERS); do \
  357. X    (set -x; $(INSTALL) -c $(INSTALLFLAGS) $$i $(INSTINC)/Wc); \
  358. X    done
  359. X
  360. Xdepend::
  361. X    $(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
  362. X
  363. Xlint:
  364. X    $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
  365. Xlint1:
  366. X    $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
  367. X
  368. X###########################################################################
  369. X# common rules for all Makefiles - do not edit
  370. X
  371. Xemptyrule::
  372. X
  373. Xclean::
  374. X    $(RM_CMD) \#*
  375. X
  376. XMakefile::
  377. X    -@if [ -f Makefile ]; then \
  378. X    echo "    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
  379. X    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  380. X    else exit 0; fi
  381. X    $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
  382. X
  383. Xtags::
  384. X    $(TAGS) -w *.[ch]
  385. X    $(TAGS) -xw *.[ch] > TAGS
  386. X
  387. X###########################################################################
  388. X# empty rules for directories that do not have SUBDIRS - do not edit
  389. X
  390. Xinstall::
  391. X    @echo "install in $(CURRENT_DIR) done"
  392. X
  393. Xinstall.man::
  394. X    @echo "install.man in $(CURRENT_DIR) done"
  395. X
  396. XMakefiles::
  397. X
  398. Xincludes::
  399. X
  400. X###########################################################################
  401. X# dependencies generated by makedepend
  402. X
  403. END_OF_FILE
  404. if test 10482 -ne `wc -c <'xrainbow/Wc1_05/Wc/Makefile'`; then
  405.     echo shar: \"'xrainbow/Wc1_05/Wc/Makefile'\" unpacked with wrong size!
  406. fi
  407. # end of 'xrainbow/Wc1_05/Wc/Makefile'
  408. fi
  409. if test -f 'xrainbow/Wc1_05/Wc/WcActions.c' -a "${1}" != "-c" ; then 
  410.   echo shar: Will not clobber existing file \"'xrainbow/Wc1_05/Wc/WcActions.c'\"
  411. else
  412. echo shar: Extracting \"'xrainbow/Wc1_05/Wc/WcActions.c'\" \(13852 characters\)
  413. sed "s/^X//" >'xrainbow/Wc1_05/Wc/WcActions.c' <<'END_OF_FILE'
  414. X/*
  415. X** Copyright (c) 1990 Rodney J. Whitby
  416. X**
  417. X** This file was derived from work performed by David E. Smyth under the
  418. X** following copyright:
  419. X**
  420. X*******************************************************************************
  421. X** Copyright (c) 1990 David E. Smyth
  422. X**
  423. X** This file was derived from work performed by Martin Brunecky at
  424. X** Auto-trol Technology Corporation, Denver, Colorado, under the
  425. X** following copyright:
  426. X**
  427. X*******************************************************************************
  428. X* Copyright 1990 by Auto-trol Technology Corporation, Denver, Colorado.
  429. X*
  430. X*                        All Rights Reserved
  431. X*
  432. X* Permission to use, copy, modify, and distribute this software and its
  433. X* documentation for any purpose and without fee is hereby granted, provided
  434. X* that the above copyright notice appears on all copies and that both the
  435. X* copyright and this permission notice appear in supporting documentation
  436. X* and that the name of Auto-trol not be used in advertising or publicity
  437. X* pertaining to distribution of the software without specific, prior written
  438. X* permission.
  439. X*
  440. X* Auto-trol disclaims all warranties with regard to this software, including
  441. X* all implied warranties of merchantability and fitness, in no event shall
  442. X* Auto-trol be liable for any special, indirect or consequential damages or
  443. X* any damages whatsoever resulting from loss of use, data or profits, whether
  444. X* in an action of contract, negligence or other tortious action, arising out
  445. X* of or in connection with the use or performance of this software.
  446. X*******************************************************************************
  447. X**
  448. X** Redistribution and use in source and binary forms are permitted
  449. X** provided that the above copyright notice and this paragraph are
  450. X** duplicated in all such forms and that any documentation, advertising
  451. X** materials, and other materials related to such distribution and use
  452. X** acknowledge that the software was developed by David E. Smyth.  The
  453. X** name of David E. Smyth may not be used to endorse or promote products
  454. X** derived from this software without specific prior written permission.
  455. X** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  456. X** WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  457. X** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  458. X**
  459. X*/
  460. X
  461. X/*
  462. X* SCCS_data: @(#)WcActions.c 1.1 ( 19 Nov 90 )
  463. X*
  464. X* Subsystem_group:
  465. X*
  466. X*     Widget Creation Library
  467. X*
  468. X* Module_description:
  469. X*
  470. X*     This module contains the convenience actions used to create and 
  471. X*     manage a widget tree using the Xrm databse.
  472. X*
  473. X*     Several convenience actions are provided with the package, allowing 
  474. X*     deferred widget creation, control (manage/unmanage) and other utility
  475. X*     functions.
  476. X*
  477. X* Module_interface_summary: 
  478. X*
  479. X*     Convenience Actions:
  480. X*
  481. X* Module_history:
  482. X*                                                  
  483. X*   All actions and the action registration routine were made by
  484. X*   Rod Whitby following about 30 June 1990.
  485. X*
  486. X* Design_notes:
  487. X*
  488. X*******************************************************************************
  489. X*/
  490. X/*
  491. X*******************************************************************************
  492. X* Include_files.
  493. X*******************************************************************************
  494. X*/
  495. X
  496. X#include <X11/Intrinsic.h>
  497. X#include "WcCreate.h"
  498. X#include "WcCreateP.h"
  499. X
  500. X/*
  501. X*******************************************************************************
  502. X* Private_type_declarations.
  503. X*******************************************************************************
  504. X*/
  505. X
  506. X/*
  507. X*******************************************************************************
  508. X* Private_macro_definitions.
  509. X*******************************************************************************
  510. X*/
  511. X
  512. X/*
  513. X*******************************************************************************
  514. X* Private_data_definitions.
  515. X*******************************************************************************
  516. X*/
  517. X
  518. Xstatic char msg[1024];
  519. X
  520. X/*
  521. X*******************************************************************************
  522. X* Private_function_declarations.
  523. X*******************************************************************************
  524. X*/
  525. X
  526. X#define COMMAS 1
  527. X#define NO_COMMAS 0
  528. X
  529. Xstatic char* AllocAndBuildString( params, num_params, commas )
  530. X    char *params[];
  531. X    int  *num_params;
  532. X    int   commas;
  533. X{
  534. X    char *data;
  535. X    int   len, i;
  536. X
  537. X    for ( len = 0, i = 0; i < *num_params; i++ )
  538. X        len += strlen( params[i] ) + 1;
  539. X
  540. X    data = XtMalloc(len + 1);
  541. X
  542. X    (void)strcpy(data, params[0]);
  543. X    for ( i = 1; i < *num_params; i++ )
  544. X    {
  545. X    if (commas)
  546. X        strcat(data, ",");
  547. X    else
  548. X        strcat(data, " ");
  549. X        (void)strcat(data, params[i]);
  550. X    }
  551. X    return data;
  552. X}
  553. X
  554. Xstatic void SendToCallback( callback, w, params, num_params, min_reqd, commas )
  555. X    XtCallbackProc callback;
  556. X    Widget         w;
  557. X    char          *params[];
  558. X    int           *num_params;
  559. X    int            min_reqd;
  560. X    int            commas;
  561. X{
  562. X    char* data;
  563. X
  564. X    if ( *num_params < min_reqd )
  565. X    {
  566. X    callback( w, "", NULL );
  567. X    return;
  568. X    }
  569. X
  570. X    data = AllocAndBuildString( params, num_params, commas );
  571. X
  572. X    callback( w, data, NULL );
  573. X    XtFree(data);
  574. X}
  575. X
  576. X/*
  577. X*******************************************************************************
  578. X* Public_action_function_declarations.
  579. X*******************************************************************************
  580. X*/
  581. X
  582. X/*
  583. X    -- Create Dynamic Children from Xrm Database
  584. X*******************************************************************************
  585. X    WcCreateChildrenACT( parent, child [, child ... ] )
  586. X*/
  587. Xvoid    WcCreateChildrenACT( w, event, params, num_params )
  588. X    Widget      w;
  589. X    XEvent     *event;
  590. X    String     *params;
  591. X    Cardinal   *num_params;
  592. X{
  593. X    SendToCallback( WcCreateChildrenCB, w, params, num_params, 2, COMMAS );
  594. X}
  595. X
  596. X/*
  597. X    -- Create Dynamic Popup Children from Xrm Database
  598. X*******************************************************************************
  599. X    WcCreatePopupsACT( parent, child [, child ... ] )
  600. X*/
  601. Xvoid    WcCreatePopupsACT( w, event, params, num_params )
  602. X    Widget      w;
  603. X    XEvent     *event;
  604. X    String     *params;
  605. X    Cardinal   *num_params;
  606. X{
  607. X    SendToCallback( WcCreatePopupsCB, w, params, num_params, 2, COMMAS );
  608. X}
  609. X
  610. X/*
  611. X    -- Manage or Unmanage named widget(s)
  612. X*******************************************************************************
  613. X    WcManageACT  ( widget_path [, widget_path ... ] )
  614. X    WcUnmanageACT( widget_path [, widget_path ... ] )
  615. X*/
  616. Xvoid    WcManageACT( w, event, params, num_params )
  617. X    Widget    w;
  618. X    XEvent   *event;
  619. X    String   *params;
  620. X    Cardinal *num_params;
  621. X{
  622. X    SendToCallback( WcManageCB, w, params, num_params, 1, COMMAS );
  623. X}
  624. X
  625. Xvoid    WcUnmanageACT( w, event, params, num_params )
  626. X    Widget    w;
  627. X    XEvent   *event;
  628. X    String   *params;
  629. X    Cardinal *num_params;
  630. X{
  631. X    SendToCallback( WcUnmanageCB, w, params, num_params, 1, COMMAS );
  632. X}
  633. X
  634. X/*
  635. X    -- Manage or unamange named children action
  636. X*******************************************************************************
  637. X    WcManageChildrenACT  ( parent, child [, child ... ] )
  638. X    WcUnmanageChildrenACT( parent, child [, child ... ] )
  639. X*/
  640. Xvoid    WcManageChildrenACT( w, event, params, num_params )
  641. X    Widget    w;
  642. X    XEvent   *event;
  643. X    String   *params;
  644. X    Cardinal *num_params;
  645. X{
  646. X    SendToCallback( WcManageChildrenCB, w, params, num_params, 2, COMMAS );
  647. X}
  648. X
  649. Xvoid    WcUnmanageChildrenACT( w, event, params, num_params )
  650. X    Widget    w;
  651. X    XEvent   *event;
  652. X    String   *params;
  653. X    Cardinal *num_params;
  654. X{
  655. X    SendToCallback( WcUnmanageChildrenCB, w, params, num_params, 2, COMMAS );
  656. X}
  657. X
  658. X/*
  659. X    -- Destroy named children action
  660. X*******************************************************************************
  661. X    WcDestroyACT( widget_path [, widget_path ... ] )
  662. X*/
  663. Xvoid    WcDestroyACT( w, event, params, num_params )
  664. X    Widget    w;
  665. X    XEvent   *event;
  666. X    String   *params;
  667. X    Cardinal *num_params;
  668. X{
  669. X    SendToCallback( WcDestroyCB, w, params, num_params, 1, COMMAS );
  670. X}
  671. X
  672. X/*
  673. X    -- Set Resource Value on Widget
  674. X*******************************************************************************
  675. X    WcSetValueACT( widget_path.res_name: res_val )
  676. X*/
  677. Xvoid    WcSetValueACT( w, event, params, num_params )
  678. X    Widget    w;
  679. X    XEvent   *event;
  680. X    String   *params;
  681. X    Cardinal *num_params;
  682. X{
  683. X    /* note: blanks are optional, so we really don't know how many params 
  684. X    ** we get from the translation manager: anything from 1 to 3. 
  685. X    */
  686. X    SendToCallback( WcSetValueCB, w, params, num_params, 1, NO_COMMAS );
  687. X}
  688. X
  689. X/*
  690. X    -- Set Resource Value on Widget
  691. X*******************************************************************************
  692. X    WcSetTypeValueACT( widget_path.res_name: type, res_val )
  693. X*/
  694. Xvoid    WcSetTypeValueACT( w, event, params, num_params )
  695. X    Widget    w;
  696. X    XEvent   *event;
  697. X    String   *params;
  698. X    Cardinal *num_params;
  699. X{
  700. X    SendToCallback( WcSetTypeValueCB, w, params, num_params, 1, NO_COMMAS );
  701. X}
  702. X
  703. X/*
  704. X    -- Change sensitivity of widgets.
  705. X*******************************************************************************
  706. X    WcSetSensitiveACT  ( widget_path [, widget_path ... ] )
  707. X    WcSetInsensitiveACT( widget_path [, widget_path ... ] )
  708. X*/
  709. Xvoid    WcSetSensitiveACT( w, event, params, num_params )
  710. X    Widget    w;
  711. X    XEvent   *event;
  712. X    String   *params;
  713. X    Cardinal *num_params;
  714. X{
  715. X    SendToCallback( WcSetSensitiveCB, w, params, num_params, 1, COMMAS );
  716. X}
  717. X
  718. Xvoid    WcSetInsensitiveACT( w, event, params, num_params )
  719. X    Widget    w;
  720. X    XEvent   *event;
  721. X    String   *params;
  722. X    Cardinal *num_params;
  723. X{
  724. X    SendToCallback( WcSetInsensitiveCB, w, params, num_params, 1, COMMAS );
  725. X}
  726. X
  727. X/*
  728. X    -- Load Resource File
  729. X*******************************************************************************
  730. X    WcLoadResourceFileACT( file_name )
  731. X*/
  732. Xvoid    WcLoadResourceFileACT( w, event, params, num_params )
  733. X    Widget    w;
  734. X    XEvent   *event;
  735. X    String   *params;
  736. X    Cardinal *num_params;
  737. X{
  738. X    SendToCallback( WcLoadResourceFileCB, w, params, num_params, 1, COMMAS );
  739. X}
  740. X
  741. X/*
  742. X    -- WcTraceAction
  743. X*******************************************************************************
  744. X    WcTraceACT( [ annotation ] )
  745. X*/
  746. Xvoid    WcTraceACT( w, event, params, num_params )
  747. X    Widget    w;
  748. X    XEvent   *event;
  749. X    String   *params;
  750. X    Cardinal *num_params;
  751. X{
  752. X    SendToCallback( WcTraceCB, w, params, num_params, 1, COMMAS );
  753. X}
  754. X
  755. X/*
  756. X  -- Popup and Popdown named widget
  757. X*******************************************************************************
  758. X    WcPopupACT    ( widget_path )
  759. X    WcPopupGrabACT( widget_path )
  760. X    WcPopdownACT  ( widget_path )
  761. X*/
  762. Xvoid    WcPopupACT( w, event, params, num_params )
  763. X    Widget    w;
  764. X    XEvent   *event;
  765. X    String   *params;
  766. X    Cardinal *num_params;
  767. X{
  768. X    SendToCallback( WcPopupCB, w, params, num_params, 1, COMMAS );
  769. X}
  770. X
  771. Xvoid    WcPopupGrabACT( w, event, params, num_params )
  772. X    Widget    w;
  773. X    XEvent   *event;
  774. X    String   *params;
  775. X    Cardinal *num_params;
  776. X{
  777. X    SendToCallback( WcPopupGrabCB, w, params, num_params, 1, COMMAS );
  778. X}
  779. X
  780. Xvoid    WcPopdownACT( w, event, params, num_params )
  781. X    Widget    w;
  782. X    XEvent   *event;
  783. X    String   *params;
  784. X    Cardinal *num_params;
  785. X{
  786. X    SendToCallback( WcPopdownCB, w, params, num_params, 1, COMMAS );
  787. X}
  788. X
  789. X/*
  790. X  -- Map and Unmap named widget
  791. X*******************************************************************************
  792. X    WcMapACT  ( widget_path )
  793. X    WcUnmapACT( widget_path )
  794. X*/
  795. Xvoid    WcMapACT( w, event, params, num_params )
  796. X    Widget    w;
  797. X    XEvent   *event;
  798. X    String   *params;
  799. X    Cardinal *num_params;
  800. X{
  801. X    SendToCallback( WcMapCB, w, params, num_params, 1, COMMAS );
  802. X}
  803. X
  804. Xvoid    WcUnmapACT( w, event, params, num_params )
  805. X    Widget    w;
  806. X    XEvent   *event;
  807. X    String   *params;
  808. X    Cardinal *num_params;
  809. X{
  810. X    SendToCallback( WcUnmapCB, w, params, num_params, 1, COMMAS );
  811. X}
  812. X
  813. X/*
  814. X    -- Invoke shell command
  815. X*******************************************************************************
  816. X    WcSystemACT( any shell command line )
  817. X*/
  818. Xvoid    WcSystemACT( w, event, params, num_params )
  819. X    Widget    w;
  820. X    XEvent   *event;
  821. X    String   *params;
  822. X    Cardinal *num_params;
  823. X{
  824. X    SendToCallback( WcSystemCB, w, params, num_params, 1, NO_COMMAS );
  825. X}
  826. X
  827. X/*
  828. X    -- Exit the application
  829. X*******************************************************************************
  830. X    WcExitACT( [ integer_exit_code ] )
  831. X*/
  832. Xvoid    WcExitACT( w, event, params, num_params )
  833. X    Widget    w;
  834. X    XEvent   *event;
  835. X    String   *params;
  836. X    Cardinal *num_params;
  837. X{
  838. X    SendToCallback( WcExitCB, w, params, num_params, 1, COMMAS );
  839. X}
  840. X
  841. X/*
  842. X  -- WcRegisterWcActions
  843. X*******************************************************************************
  844. X   Convenience routine, registering all standard actions in one application
  845. X   call.   Called from WcWidgetCreation(), so application usually never needs
  846. X   to call this.
  847. X*/
  848. X
  849. Xvoid WcRegisterWcActions ( app )
  850. XXtAppContext app;
  851. X{
  852. X    static XtActionsRec WcActions[] = {
  853. X      {"WcCreateChildrenACT",    WcCreateChildrenACT    },
  854. X      {"WcCreatePopupsACT",    WcCreatePopupsACT    },
  855. X      {"WcManageACT",        WcManageACT        },
  856. X      {"WcUnmanageACT",        WcUnmanageACT        },
  857. X      {"WcManageChildrenACT",    WcManageChildrenACT    },
  858. X      {"WcUnmanageChildrenACT",    WcUnmanageChildrenACT    },
  859. X      {"WcDestroyACT",        WcDestroyACT        },
  860. X      {"WcSetValueACT",        WcSetValueACT        },
  861. X      {"WcSetTypeValueACT",    WcSetTypeValueACT    },
  862. X      {"WcSetSensitiveACT",    WcSetSensitiveACT    },
  863. X      {"WcSetInsensitiveACT",    WcSetInsensitiveACT    },
  864. X      {"WcLoadResourceFileACT",    WcLoadResourceFileACT    },
  865. X      {"WcTraceACT",        WcTraceACT        },
  866. X      {"WcPopupACT",        WcPopupACT        },
  867. X      {"WcPopupGrabACT",    WcPopupGrabACT        },
  868. X      {"WcPopdownACT",        WcPopdownACT        },
  869. X      {"WcMapACT",        WcMapACT        },
  870. X      {"WcUnmapACT",        WcUnmapACT        },
  871. X      {"WcSystemACT",        WcSystemACT        },
  872. X      {"WcExitACT",        WcExitACT        },
  873. X    };
  874. X
  875. X    ONCE_PER_XtAppContext( app );
  876. X
  877. X    XtAppAddActions(app, WcActions, XtNumber(WcActions));
  878. X}
  879. END_OF_FILE
  880. if test 13852 -ne `wc -c <'xrainbow/Wc1_05/Wc/WcActions.c'`; then
  881.     echo shar: \"'xrainbow/Wc1_05/Wc/WcActions.c'\" unpacked with wrong size!
  882. fi
  883. # end of 'xrainbow/Wc1_05/Wc/WcActions.c'
  884. fi
  885. if test -f 'xrainbow/Wc1_05/Wc/WcCallb.c' -a "${1}" != "-c" ; then 
  886.   echo shar: Will not clobber existing file \"'xrainbow/Wc1_05/Wc/WcCallb.c'\"
  887. else
  888. echo shar: Extracting \"'xrainbow/Wc1_05/Wc/WcCallb.c'\" \(46686 characters\)
  889. sed "s/^X//" >'xrainbow/Wc1_05/Wc/WcCallb.c' <<'END_OF_FILE'
  890. X/*
  891. X** Copyright (c) 1990 David E. Smyth
  892. X**
  893. X** This file was derived from work performed by Martin Brunecky at
  894. X** Auto-trol Technology Corporation, Denver, Colorado, under the
  895. X** following copyright:
  896. X**
  897. X*******************************************************************************
  898. X* Copyright 1990 by Auto-trol Technology Corporation, Denver, Colorado.
  899. X*
  900. X*                        All Rights Reserved
  901. X*
  902. X* Permission to use, copy, modify, and distribute this software and its
  903. X* documentation for any purpose and without fee is hereby granted, provided
  904. X* that the above copyright notice appears on all copies and that both the
  905. X* copyright and this permission notice appear in supporting documentation
  906. X* and that the name of Auto-trol not be used in advertising or publicity
  907. X* pertaining to distribution of the software without specific, prior written
  908. X* permission.
  909. X*
  910. X* Auto-trol disclaims all warranties with regard to this software, including
  911. X* all implied warranties of merchantability and fitness, in no event shall
  912. X* Auto-trol be liable for any special, indirect or consequential damages or
  913. X* any damages whatsoever resulting from loss of use, data or profits, whether
  914. X* in an action of contract, negligence or other tortious action, arising out
  915. X* of or in connection with the use or performance of this software.
  916. X*******************************************************************************
  917. X**
  918. X** Redistribution and use in source and binary forms are permitted
  919. X** provided that the above copyright notice and this paragraph are
  920. X** duplicated in all such forms and that any documentation, advertising
  921. X** materials, and other materials related to such distribution and use
  922. X** acknowledge that the software was developed by David E. Smyth.  The
  923. X** name of David E. Smyth may not be used to endorse or promote products
  924. X** derived from this software without specific prior written permission.
  925. X** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  926. X** WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  927. X** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  928. X**
  929. X*/
  930. X
  931. X/*
  932. X* SCCS_data: @(#)WcCallb.c 1.1 ( 19 Nov 90 )
  933. X*
  934. X* Subsystem_group:
  935. X*
  936. X*     Widget Creation Library
  937. X*
  938. X* Module_description:
  939. X*
  940. X*     This module contains the convenience callbacks used to create and 
  941. X*     manage a widget tree using the Xrm databse.
  942. X*
  943. X*     Several convenience callbacks are provided with the package, allowing 
  944. X*     deferred widget creation, control (manage/unmanage) and other utility
  945. X*     functions.
  946. X*
  947. X* Module_interface_summary: 
  948. X*
  949. X*     Convenience Callbacks:
  950. X*
  951. X* Module_history:
  952. X*                                                  
  953. X*   Several of the callbacks and the callback registration routine were
  954. X*   originally written by Martin Brunecky at Auto-Trol, between about
  955. X*   the first of February 1990 until about 18 April 1990.
  956. X*
  957. X*   Additional callbacks and modifications to all callbacks and the
  958. X*   callback registration routine were made by David Smyth at Jet
  959. X*   Propulsion Laboratories following about 15 March 1990.
  960. X*
  961. X*   WcLoadResourceFileCB enhanced to remember which resource files have
  962. X*   been loaded (by resource file name, not complete path name).  It now
  963. X*   handles absolute pathnames starting at root or tilda, or uses the
  964. X*   same search path algorithm used bu GetAppDefaults in X11R4 Xt.  I.e.,
  965. X*   it uses XUSERFILESEARCHPATH, the user's home directory, and XAPPLRESDIR 
  966. X*   in the same way that XtR4 does when it gets user's application defaults.  
  967. X*   This code basically mimics GetAppUserDefaults() in mit/lib/Xt/Initialize.c
  968. X
  969. X* Design_notes:
  970. X*
  971. X*   For VMS, we could have used LIB$FIND_IMAGE_SYMBOL and use dynamic
  972. X*   (runtime) binding. But since most UNIX systems lack such capability,
  973. X*   we stick to the concept of "registration" routines.
  974. X*
  975. X*   All these callbacks could probably be declared as static.  They
  976. X*   were not because applications may want to link them to widgets
  977. X*   via C code.  
  978. X*
  979. X*   When Motif runs on release 4 Intrinsics, then all argument parsing
  980. X*   should be replaced with coverters, so conversions get cached.  This
  981. X*   will improve performance, especially for pop-ups.
  982. X*
  983. X*******************************************************************************
  984. X*/
  985. X/*
  986. X*******************************************************************************
  987. X* Include_files.
  988. X*******************************************************************************
  989. X*/
  990. X
  991. X#include <X11/Intrinsic.h>
  992. X#include "WcCreate.h"
  993. X#include "WcCreateP.h"
  994. X
  995. X#include <pwd.h>    /* to determine home dir for WcLoadResourceFileCB */
  996. X
  997. X/*
  998. X*******************************************************************************
  999. X* Private_type_declarations.
  1000. X*******************************************************************************
  1001. X*/
  1002. X
  1003. X/*
  1004. X*******************************************************************************
  1005. X* Private_macro_definitions.
  1006. X*******************************************************************************
  1007. X*/
  1008. X
  1009. X/*
  1010. X*******************************************************************************
  1011. X* Private_data_definitions.
  1012. X*******************************************************************************
  1013. X*/
  1014. X
  1015. X/* NOTE: These are shared arrays because they are large: i.e.,
  1016. X** this is a performance optimization intended to reduce page
  1017. X** faults which can occur while making large extensions to the
  1018. X** stack space.  Wait a minute: wouldn't this just happen
  1019. X** once, and then the stack space is alloc'd?  Yes, but a
  1020. X** huge stack space runs the risk of getting swapped, which causes
  1021. X** page faults.  This is probably a nit-picky sort of optimization.
  1022. X** Remember that D.Smyth is an old sys programmer from the stone
  1023. X** ages, and pity him instead of flaming him.
  1024. X** Be careful when filling msg not to call any funcs in here, 
  1025. X** so the message does not get garbled.
  1026. X*/
  1027. X
  1028. Xstatic char    msg[MAX_ERRMSG];
  1029. Xstatic char    cleanName[MAX_PATHNAME];
  1030. Xstatic Widget    widget_list[MAX_CHILDREN];
  1031. X
  1032. X/*
  1033. X*******************************************************************************
  1034. X* Private_function_declarations.
  1035. X*******************************************************************************
  1036. X*/
  1037. X
  1038. Xextern char*          getenv();
  1039. Xextern int            getuid();
  1040. Xextern struct passwd* getpwuid();
  1041. Xextern struct passwd* getpwnam();
  1042. X
  1043. X/* 
  1044. X    -- Find Home Directory
  1045. X*******************************************************************************
  1046. X    Used by WcLoadResourceFileCB.
  1047. X    Argument can be THIS_USER (a NULL) or can be a user's name.
  1048. X    The character string returned is in static storage, as returned
  1049. X    by getpwnam().
  1050. X*/
  1051. X
  1052. X#define THIS_USER ((char*)0)
  1053. X
  1054. Xstatic char* HomeDirectory( user )
  1055. X    char* user;
  1056. X{
  1057. X    struct passwd *pw;
  1058. X    char* homeDir = NULL;
  1059. X
  1060. X    if ( user == THIS_USER || *user == '\0' )
  1061. X    {
  1062. X    homeDir = getenv("HOME");
  1063. X
  1064. X        if (homeDir == NULL)
  1065. X        {
  1066. X            char* thisUser = getenv("USER");
  1067. X
  1068. X            if (thisUser == NULL)
  1069. X                pw = getpwuid( getuid() );
  1070. X            else
  1071. X                pw = getpwnam( thisUser );
  1072. X            if (pw)
  1073. X                homeDir = pw->pw_dir;
  1074. X        }
  1075. X    }
  1076. X    else
  1077. X    {
  1078. X    /* some other user */
  1079. X    pw = getpwnam( user );
  1080. X    if (pw)
  1081. X        homeDir = pw->pw_dir;
  1082. X    }
  1083. X    return homeDir;
  1084. X}
  1085. X
  1086. X/*
  1087. X    -- Build Default User Serach Path suitable for XtResolvePathname
  1088. X*******************************************************************************
  1089. X    Used by WcLoadResourceFileCB.
  1090. X    Argument can be THIS_USER (a NULL) or can be a user's name.
  1091. X    Returns a pointer to static storage.
  1092. X*/
  1093. X
  1094. Xstatic char* DefaultUserSearchPath( user )
  1095. X    char* user;
  1096. X{
  1097. X    static char spath[3*MAX_PATHNAME + 80];
  1098. X
  1099. X    char* xApplResDir = getenv("XAPPLRESDIR");
  1100. X    char* homeDir     = HomeDirectory( user );
  1101. X
  1102. X    if (xApplResDir && homeDir)
  1103. X    {
  1104. X        sprintf( spath, "%s/%%L/%%N:%s/%%l/%%N:%s/%%N:%s/%%N",
  1105. X                xApplResDir, xApplResDir, xApplResDir, homeDir );
  1106. X    }
  1107. X    else if (xApplResDir)
  1108. X    {
  1109. X        sprintf( spath, "%s/%%L/%%N:%s/%%l/%%N:%s/%%N",
  1110. X                xApplResDir, xApplResDir, xApplResDir );
  1111. X    }
  1112. X    else if (homeDir)
  1113. X    {
  1114. X    sprintf( spath, "%s/%%L/%%N:%s/%%l/%%N:%s/%%N",
  1115. X        homeDir, homeDir, homeDir );
  1116. X    }
  1117. X    else
  1118. X    {
  1119. X    return NULL;
  1120. X    }
  1121. X    return spath;
  1122. X}
  1123. X
  1124. X/*
  1125. X*******************************************************************************
  1126. X* Public_callback_function_declarations.
  1127. X*******************************************************************************
  1128. X    The client data argument of callbacks MUST be a null terminated
  1129. X    string.  If client == (char*)0 this is an error.  The correct way
  1130. X    to pass no client information is *client == '\0'. The CvtStringToCallback
  1131. X    converter which actually causes these functions to be called (adds
  1132. X    these functions to widget's callback lists) does ensure that the
  1133. X    client data is a proper null terminated string.
  1134. X
  1135. X    Callbacks are not intended to be re-entrant nor recursive.  Many of
  1136. X    these use static buffers.
  1137. X*******************************************************************************
  1138. X*/
  1139. X
  1140. X/*
  1141. X    -- Create Dynamically Created Children from Xrm Database
  1142. X*******************************************************************************
  1143. X    This callback creates one or more specified children of a parent widget.
  1144. X    If parent name is `this' then widget invoking callback is used as the
  1145. X    parent.  Parent name can also be a wildcarded path name.  Child names
  1146. X    must be single part, specific children of the parent. Client data format:
  1147. X
  1148. X             parent, child [,child] ...
  1149. X    
  1150. X    This callback is used for deferred sub-tree creation, where named child
  1151. X    creation has been postponed because it was not included in a wcChildren
  1152. X    resource value.
  1153. X*/
  1154. X
  1155. Xstatic void CreateKids();
  1156. X
  1157. Xvoid WcCreateChildrenCB ( w, parent_children, unused )
  1158. X    Widget w;
  1159. X    char* parent_children;    /* parent + list of named children */
  1160. X    caddr_t unused;        /* call data from widget, not used */
  1161. X{
  1162. X    CreateKids(w, parent_children, "WcCreateChildrenCB", WcCreateNamedChildren);
  1163. X}
  1164. X
  1165. Xvoid WcCreatePopupsCB ( w, parent_children, unused )
  1166. X    Widget w;
  1167. X    char* parent_children;      /* parent + list of named children */
  1168. X    caddr_t unused;             /* call data from widget, not used */
  1169. X{
  1170. X    CreateKids(w, parent_children, "WcCreatePopupsCB", WcCreateNamedPopups );
  1171. X}
  1172. X
  1173. Xstatic void CreateKids ( w, parent_children, caller, CreateFunc )
  1174. X    Widget w;
  1175. X    char* parent_children;      /* parent + list of named children */
  1176. X    char* caller;        /* name of calling CB func        */
  1177. X    PtrFuncVoid CreateFunc;
  1178. X{
  1179. X    char*    children;
  1180. X    Widget    parent;
  1181. X
  1182. X    if ( *parent_children == NUL ) 
  1183. X    {
  1184. X    XtWarning(
  1185. X            "%s ( ) - Failed \n\
  1186. X             Usage: %s ( parent, child [, child ] ...) \n\
  1187. X                    Name of parent can be `this' or wildcarded pathname, \n\
  1188. X                    Name of child must be single part name from parent. \n\
  1189. X             Problem: No widget names provided.",
  1190. X        caller, caller);
  1191. X    return;
  1192. X    }
  1193. X
  1194. X    children = WcCleanName( parent_children, cleanName );
  1195. X
  1196. X    children = WcSkipWhitespace_Comma( children );
  1197. X
  1198. X    if ((Widget)NULL == (parent = WcFullNameToWidget( w, cleanName )) )
  1199. X    {
  1200. X    sprintf( msg,
  1201. X            "%s (%s) - Failed \n\
  1202. X             Usage: %s ( parent, child [, child ] ...) \n\
  1203. X                    Name of parent can be `this' or wildcarded pathname, \n\
  1204. X                    Name of child must be single part name from parent. \n\
  1205. X             Problem: Parent widget named `%s' not found.",
  1206. X        caller, parent_children, caller, cleanName);
  1207. X    XtWarning( msg );
  1208. X    return;
  1209. X    }
  1210. X
  1211. X    if (*children == NUL)
  1212. X    {
  1213. X        sprintf( msg,
  1214. X            "%s (%s) - Failed \n\
  1215. X             Usage: %s ( parent, child [, child ] ...) \n\
  1216. X                    Name of parent can be `this' or wildcarded pathname, \n\
  1217. X                    Name of child must be single part name from parent. \n\
  1218. X             Problem: No children names provided.",
  1219. X        caller, parent_children, caller );
  1220. X    XtWarning( msg );
  1221. X        return;
  1222. X    }
  1223. X
  1224. X    (*CreateFunc) ( parent, children );
  1225. X}
  1226. X
  1227. X/******************************************************************************
  1228. X**  Manage or Unmanage named widget(s)
  1229. X*******************************************************************************
  1230. X    This callback translates string passed in as client data into one or more
  1231. X    widget ids, and manages or unmanages it or them.  Client data format:
  1232. X    name [, name] ...
  1233. X    Name can include `this' and other path names.
  1234. X******************************************************************************/
  1235. X
  1236. X#ifdef FUNCTION_PROTOTYPES
  1237. Xstatic void ManageOrUnmanage( Widget, char*, char*, void (*proc)() );
  1238. X#else
  1239. Xstatic void ManageOrUnmanage();
  1240. X#endif
  1241. X
  1242. Xvoid WcManageCB ( w, widgetNames, unused )
  1243. X    Widget w;
  1244. X    char* widgetNames;
  1245. X    caddr_t unused;        /* call data from widget, not used */
  1246. X{
  1247. X    ManageOrUnmanage( w, widgetNames, "WcManageCB", XtManageChildren );
  1248. X}
  1249. X
  1250. Xvoid WcUnmanageCB ( w, widgetNames, unused )
  1251. X    Widget w;
  1252. X    char* widgetNames;
  1253. X    caddr_t unused;             /* call data from widget, not used */
  1254. X{
  1255. X    ManageOrUnmanage( w, widgetNames, "WcUnmanageCB", XtUnmanageChildren );
  1256. X}
  1257. X
  1258. Xstatic void ManageOrUnmanage ( w, widgetNames, callbackName, proc )
  1259. X    Widget w;
  1260. X    char* widgetNames;
  1261. X    char* callbackName;
  1262. X    void (*proc)();
  1263. X{
  1264. X    int         numWidgets = 0;
  1265. X    char*       s = widgetNames;
  1266. X
  1267. X    while (*s && numWidgets < MAX_CHILDREN)
  1268. X    {
  1269. X        s = WcCleanName ( s, cleanName );
  1270. X        s = WcSkipWhitespace_Comma ( s );
  1271. X        if ( widget_list[numWidgets] = WcFullNameToWidget ( w, cleanName ) )
  1272. X            numWidgets++;
  1273. X        else
  1274. X        {
  1275. X            sprintf(msg,
  1276. X            "%s (%s) - Widget `%s' ignored \n\
  1277. X             Usage:   %s ( widget_name [, widget_name] ... ) \n\
  1278. X             Problem: Could not find widget named `%s'.",
  1279. X             callbackName, widgetNames, cleanName, callbackName, cleanName);
  1280. X            XtWarning( msg );
  1281. X        }
  1282. X    }
  1283. X    if (numWidgets >= MAX_CHILDREN)
  1284. X    {
  1285. X    sprintf(msg,
  1286. X            "%s (%s) - Failed \n\
  1287. X             Usage:   %s ( widget_name [, widget_name] ... ) \n\
  1288. X             Problem: Too many widgets (more than MAX_CHILDREN).",
  1289. X             callbackName, widgetNames, callbackName);
  1290. X    XtWarning( msg );
  1291. X    numWidgets = 0;
  1292. X    }
  1293. X
  1294. X    if ( numWidgets )
  1295. X        /* proc is either XtManageChildren or XtUnmanageChildren */
  1296. X        proc ( widget_list, numWidgets );
  1297. X}
  1298. X
  1299. X/*
  1300. X    -- Manage or unamange named children callback
  1301. X*******************************************************************************
  1302. X    These callbacks translates a string passed in as client data into a parent
  1303. X    widget id, and names of children of that parent.  If parent name is
  1304. X    `this' then widget invoking callback is used as the parent.  Parent
  1305. X    name can also be a wildcarded path name.  Child names must be single
  1306. X    part, specific children of the parent. Client data format:
  1307. X
  1308. X             parent, child [,child] ...
  1309. X
  1310. X    This callback can be used as an alternate for WcManageCB but it is
  1311. X    really intended to be used to manage/unmanage children of widgets 
  1312. X    which have multiple instances, and where the parent name is `this'.
  1313. X*/
  1314. X#ifdef FUNCTION_PROTOTYPES
  1315. Xstatic void ManageOrUnmanageChildren( Widget, char*, char*, void (*proc)() );
  1316. X#else
  1317. Xstatic void ManageOrUnmanageChildren();
  1318. X#endif
  1319. X
  1320. Xvoid WcManageChildrenCB ( w, parent_children, unused )
  1321. X    Widget     w;
  1322. X    char*    parent_children;/* client data, list of named children  */
  1323. X    caddr_t    unused;        /* call data from widget        */
  1324. X{
  1325. X    ManageOrUnmanageChildren( w, parent_children, 
  1326. X                "WcManageChildrenCB", XtManageChildren );
  1327. X}
  1328. X
  1329. Xvoid WcUnmanageChildrenCB ( w, parent_children, unused )
  1330. X    Widget      w;
  1331. X    char*       parent_children;/* client data, list of named children  */
  1332. X    caddr_t     unused;         /* call data from widget                */
  1333. X{
  1334. X    ManageOrUnmanageChildren( w, parent_children,
  1335. X                                "WcUnmanageChildrenCB", XtUnmanageChildren );
  1336. X}
  1337. X
  1338. Xstatic void ManageOrUnmanageChildren( w, parent_children, callbackName, proc )
  1339. X    Widget w;
  1340. X    char* parent_children;      /* client data, list of named children  */
  1341. X    char* callbackName;        /* WcManageChildrenCB or WcUnmanageChildrenCB */
  1342. X    void (*proc)();        /* XtManageChildren or XtUnmanageChildren */
  1343. X{
  1344. X    int             numWidgets = 0;
  1345. X    char*        next;
  1346. X    Widget        parent;
  1347. X
  1348. X    if ( *parent_children == NUL )
  1349. X    {
  1350. X        sprintf(msg,
  1351. X            "%s ( ) - Failed \n\
  1352. X             Usage: %s ( parent, child [, child ] ...) \n\
  1353. X                    Name of parent can be `this' or wildcarded pathname, \n\
  1354. X                    Name of child must be single part name from parent. \n\
  1355. X             Problem: No widget names provided.",
  1356. X        callbackName, callbackName);
  1357. X    XtWarning( msg );
  1358. X        return;
  1359. X    }
  1360. X
  1361. X    next = WcCleanName( parent_children, cleanName );
  1362. X    if ((Widget)NULL == (parent = WcFullNameToWidget( w, cleanName )) )
  1363. X    {
  1364. X        sprintf( msg,
  1365. X            "%s (%s) - Failed \n\
  1366. X             Usage: %s ( parent, child [, child ] ...) \n\
  1367. X                    Name of parent can be `this' or wildcarded pathname, \n\
  1368. X                    Name of child must be single part name from parent. \n\
  1369. X             Problem: Parent widget named `%s' not found.",
  1370. X            callbackName, parent_children, callbackName, cleanName);
  1371. X        XtWarning( msg );
  1372. X        return;
  1373. X    }
  1374. X
  1375. X    while (*next && numWidgets < MAX_CHILDREN)
  1376. X    {
  1377. X        next = WcCleanName( next, cleanName );
  1378. X    if (widget_list[numWidgets] = WcChildNameToWidget( parent, cleanName ))
  1379. X        numWidgets++;
  1380. X    else
  1381. X    {
  1382. X        sprintf( msg,
  1383. X            "%s (%s) - Child `%s' ignored \n\
  1384. X             Usage: %s ( parent, child [, child ] ...) \n\
  1385. X                    Name of parent can be `this' or wildcarded pathname, \n\
  1386. X                    Name of child must be single part name from parent. \n\
  1387. X             Problem: Child widget named `%s' not found.",
  1388. X        callbackName, parent_children, callbackName, cleanName);
  1389. X        XtWarning( msg );
  1390. X    }
  1391. X    }
  1392. X
  1393. X    if (numWidgets >= MAX_CHILDREN)
  1394. X    {
  1395. X        sprintf(msg,
  1396. X            "%s (%s) - Failed \n\
  1397. X             Usage: %s ( parent, child [, child ] ...) \n\
  1398. X                    Name of parent can be `this' or wildcarded pathname, \n\
  1399. X                    Name of child must be single part name from parent. \n\
  1400. X             Problem: Too many widgets (more than MAX_CHILDREN).",
  1401. X             callbackName, parent_children, callbackName);
  1402. X        XtWarning( msg );
  1403. X        numWidgets = 0;
  1404. X    }
  1405. X
  1406. X    if ( numWidgets )
  1407. X        /* proc is either XtManageChildren or XtUnmanageChildren */
  1408. X        proc ( widget_list, numWidgets );
  1409. X}
  1410. X
  1411. X/*
  1412. X    -- Destroy named children callback
  1413. X*******************************************************************************
  1414. X    This callback translates string passed in as client data into a widget id
  1415. X    and destroys it. A comma separated list of widgets can be specified.
  1416. X    `this' means the invoking widget.
  1417. X*/
  1418. X
  1419. Xvoid WcDestroyCB ( w, widgetNames, unused )
  1420. X    Widget  w;
  1421. X    char*   widgetNames;    /* client data, widgets to be destroyed */
  1422. X    caddr_t unused;        /* call data from widget, not used    */
  1423. X{
  1424. X    int        widget_count = MAX_CHILDREN;
  1425. X    char*    unConvertedNames;
  1426. X    int         i;
  1427. X
  1428. X    unConvertedNames = WcNamesToWidgetList ( w, widgetNames, 
  1429. X                    widget_list, &widget_count );
  1430. X    if ( unConvertedNames[0] != NUL )
  1431. X    {
  1432. X    sprintf(msg,
  1433. X            "WcDestroyCB (%s) \n\
  1434. X             Usage: WcDestroyCB ( widget [, widget ] ...) \n\
  1435. X                    Name of widget can be `this' or wildcarded pathname. \n\
  1436. X            Problem: No widgets found named %s.",
  1437. X             widgetNames, unConvertedNames);
  1438. X        XtWarning( msg );
  1439. X    }
  1440. X
  1441. X    for (i=0; i<widget_count; i++)
  1442. X       XtDestroyWidget ( widget_list[i] );
  1443. X}
  1444. X
  1445. X/*
  1446. X    -- Parse name_res_resVal into name, res, resVal
  1447. X*******************************************************************************
  1448. X    This is a private function to WcSetValueCB()
  1449. X*/
  1450. X
  1451. Xstatic void 
  1452. XParseNameResResVal( name_res_resVal, target_name, resource, res_val )
  1453. X    char* name_res_resVal;    /* input */
  1454. X    char* target_name;        /* output */
  1455. X    char* resource;        /* output */
  1456. X    char* res_val;        /* output */
  1457. X{
  1458. X    register char *d,*s;
  1459. X
  1460. X    s = name_res_resVal;
  1461. X    /* copy from name_res_resVal into target_name[],
  1462. X    ** ignore initial whitespace, stop at trailing `:'  
  1463. X    ** Then backup to get final segment, the resource name
  1464. X    */
  1465. X    for ( s = name_res_resVal ; *s && *s <= ' ' ; s++ )
  1466. X    ;    /* skip initial whitespace */
  1467. X    for ( d = target_name ; *s && *s != ':' ; s++, d++ )
  1468. X    *d = *s;
  1469. X    for ( ; target_name < d && (*d != '.' && *d != '*') ; s--, d-- )
  1470. X    ;
  1471. X    *d = NUL;
  1472. X
  1473. X    /* OK, now target_name is null terminated.
  1474. X    ** s points at final `.' or `*' in name_resName, 
  1475. X    ** now we copy to resource[].
  1476. X    */
  1477. X    for ( s++, d = resource ; *s && *s != ':' ; s++, d++ )
  1478. X        *d = *s;
  1479. X    *d = NUL;
  1480. X
  1481. X    /* OK, now resource is null terminated.
  1482. X    ** s points at the `:' now we skip whitespace and the rest is value
  1483. X    ** until we hit the NUL terminator.
  1484. X    */
  1485. X    for (s++ ; *s && *s <= ' ' ; s++ )
  1486. X        ;       /* skip initial whitespace */
  1487. X    for (d = res_val ; *s ; s++, d++ )
  1488. X    *d = *s;
  1489. X    do
  1490. X    *d = NUL;    /* null terminate, delete trailing whitespace */
  1491. X    while (*--d <= ' ');
  1492. X}
  1493. X
  1494. X/*
  1495. X   -- Set Resource Value on Widget
  1496. X*******************************************************************************
  1497. X    This callback sets a resource value on the named widget.
  1498. X
  1499. X    The client data argument has a format:
  1500. X
  1501. X        target_widget_name.resource_name: resource value
  1502. X
  1503. X    The special resource value of "this" means "this widget."  Typically,
  1504. X    using "this" as the resource value is used to set the "XmNdefaultButton"
  1505. X    resource on a XmbulletinBoard, "menuBar", "workArea", etc on XmMainWindows,
  1506. X    the subMenuId resource on menuBar cascade buttons, and so on.
  1507. X
  1508. X    Just about everything this function does is related to providing
  1509. X    nice error messages.
  1510. X*/
  1511. X
  1512. Xvoid WcSetValueCB ( w, name_res_resVal, unused )
  1513. X    Widget  w;  
  1514. X    char*   name_res_resVal;        /* client data: name.resName: resVal */
  1515. X    caddr_t unused;            /* call data from wudget, not used   */
  1516. X{
  1517. X    /* Note: static buffers make this routine NON-REENTRANT!! */
  1518. X    static char    target_name[MAX_XRMSTRING];
  1519. X    static char    resource[MAX_XRMSTRING];
  1520. X    static char    res_val[MAX_XRMSTRING];
  1521. X
  1522. X    Widget    target;
  1523. X    Widget    res_widget;
  1524. X    char*    res_type;    /* must be XtFree'd */
  1525. X
  1526. X    ParseNameResResVal( name_res_resVal, target_name, resource, res_val );
  1527. X
  1528. X    /* Check for syntax error: if any of the strings are null, wrongo!
  1529. X    */
  1530. X    if ( target_name[0] == NUL || resource[0] == NUL || res_val[0] == NUL )
  1531. X    {
  1532. X        char *missing;
  1533. X
  1534. X        if (target_name[0] == NUL) missing = "target_widget_name";
  1535. X        else if (resource[0] == NUL) missing = "res_name";
  1536. X        else if (res_val[0] == NUL) missing = "res_value";
  1537. X
  1538. X        sprintf ( msg,
  1539. X            "WcSetValueCB (%s) - Failed \n\
  1540. X             Usage:   WcSetValueCB( target_widget_name.res_name: res_value ) \n\
  1541. X             Problem: Missing %s argument.",
  1542. X            name_res_resVal, missing );
  1543. X        XtWarning( msg ); 
  1544. X    return;
  1545. X    }
  1546. X
  1547. X    /* See if we can find the target widget */
  1548. X    if (! (target = WcFullNameToWidget( w, target_name )) )
  1549. X    {
  1550. X        sprintf ( msg,
  1551. X            "WcSetValueCB (%s)  \n\
  1552. X             Usage:   WcSetValueCB( target_widget_name.res_name: res_value ) \n\
  1553. X             Problem: Could not find widget named `%s'",
  1554. X             name_res_resVal, target_name );
  1555. X        XtWarning( msg );
  1556. X        return;
  1557. X    }
  1558. X
  1559. X    /* Make certain widget has this resource type */
  1560. X    if (! (res_type = WcGetResourceType( target, resource )) )
  1561. X    {
  1562. X    sprintf ( msg,
  1563. X            "WcSetValueCB (%s) - Failed \n\
  1564. X             Usage:   WcSetValueCB( target_widget_name.res_name: res_value ) \n\
  1565. X             Problem: widget %s does not have a resource named %s.",
  1566. X    name_res_resVal, target_name, resource);
  1567. X        XtWarning(msg);
  1568. X    return;
  1569. X    }
  1570. X
  1571. X    /* Try this heuristic: if the resource type has "Widget" somewhere within
  1572. X    ** it, then see if we can convert the resource value to a widget using 
  1573. X    ** WcFullNameToWidget.  This allow relative naming from the calling
  1574. X    ** widget, including `this' or ^^foobar.
  1575. X    ** WcStrStr( res_type, "Widget") returns NULL if "Widget" is not in res_type
  1576. X    ** Note that we must check for both "Widget" and "Window" - we should only
  1577. X    ** check for "Widget" but Motif has a screwed up definition for the
  1578. X    ** menuWidget resource of XmRowColumn widgets.  So, until Motif fixes
  1579. X    ** XmRowColumn.h, we need to check for both...
  1580. X    */
  1581. X    if ( WcStrStr( res_type, "Widget") 
  1582. X      || WcStrStr( res_type, "Window") )  /* wrong: but that's a menuWidget */
  1583. X    {
  1584. X    Widget    res_widget;
  1585. X
  1586. X    if (res_widget = WcFullNameToWidget( w, res_val ))
  1587. X    {
  1588. X        XtVaSetValues( target, resource, res_widget, NULL );
  1589. X        return;
  1590. X    }
  1591. X    }
  1592. X
  1593. X    /* We have the type, so do conversion, and then call XtSetValues. */
  1594. X
  1595. X    WcSetValueFromStringAndType( target, resource, res_val, res_type );
  1596. X    XtFree( res_type );
  1597. X}
  1598. X
  1599. X/*
  1600. X    -- Parse name_res_resType_resVal into name, res, resType, resVal
  1601. X*******************************************************************************
  1602. X    This is a private function to WcSetTypeValueCB()  which *must*
  1603. X    allocate sufficient space for the return values!
  1604. X*/
  1605. X
  1606. Xstatic void 
  1607. XParseNameResResTypeResVal( name_res_resType_resVal, name, res, resType, resVal )
  1608. X    char* name_res_resType_resVal;    /* input */
  1609. X    char* name;                /* output */
  1610. X    char* res;                /* output */
  1611. X    char* resType;            /* output */
  1612. X    char* resVal;            /* output */
  1613. X{
  1614. X    register char *d,*s;
  1615. X
  1616. X    /* copy from name_res_resType_resVal into name[],
  1617. X    ** ignore initial whitespace, stop at trailing `:'  
  1618. X    ** Then backup to get final segment, the resource name
  1619. X    */
  1620. X    for ( s = name_res_resType_resVal ; *s && *s <= ' ' ; s++ )
  1621. X    ;    /* skip initial whitespace */
  1622. X    for ( d = name ; *s && *s != ':' ; s++, d++ )
  1623. X    *d = *s;
  1624. X    for ( ; name < d && (*d != '.' && *d != '*') ; s--, d-- )
  1625. X    ;
  1626. X    *d = NUL;
  1627. X
  1628. X    /* OK, now name is null terminated.
  1629. X    ** s points at final `.' or `*' in name_resName, 
  1630. X    ** now we copy to res[].
  1631. X    */
  1632. X    for ( s++, d = res ; *s && *s != ':' ; s++, d++ )
  1633. X        *d = *s;
  1634. X    *d = NUL;
  1635. X
  1636. X    /* OK, now resource is null terminated.
  1637. X    ** s points at the `:' now we skip whitespace and the next word is Type.
  1638. X    */
  1639. X    for (s++ ; *s && *s <= ' ' ; s++ )
  1640. X        ;       /* skip initial whitespace */
  1641. X    for ( d = resType ; *s && *s > ' ' && *s != ':' && *s != ',' ; s++, d++ )
  1642. X    *d = *s;
  1643. X    *d = NUL;
  1644. X    
  1645. X    /* OK, now resType is null terminated.
  1646. X    ** s points at the `:' or `,' or whitespace.  Skip whitespace and the 
  1647. X    ** rest is resVal until we hit the NUL terminator.
  1648. X    */
  1649. X    for (s++ ; *s && *s <= ' ' ; s++ )
  1650. X        ;       /* skip initial whitespace */
  1651. X    for (d = resVal ; *s ; s++, d++ )
  1652. X    *d = *s;
  1653. X    do
  1654. X    *d = NUL;    /* null terminate, delete trailing whitespace */
  1655. X    while (*--d <= ' ');
  1656. X}
  1657. X
  1658. X/*
  1659. X   -- Set Resource Value on Widget using specific target type info
  1660. X*******************************************************************************
  1661. X    This callback sets a resource value on the named widget.  It exists
  1662. X    so sub-resources can be set.  Specifically, widgets which have
  1663. X    non-widget components (XawText and XmText are classic examples)
  1664. X    can accept resources which are NOT returned by XtGetResourceList
  1665. X    or by XtGetConstraintResourceList.  Probably, this is a bug in
  1666. X    the widget's GetValuesHook.
  1667. X
  1668. X    The client data argument has a format:
  1669. X
  1670. X        target_widget_name.resource_name: resType, resource value
  1671. X
  1672. X    The resource type, unfortunately, *must* be the string represented
  1673. X    by such constants as XmRString or XtRPixel.  Sorry.
  1674. X
  1675. X    The special resource value of "this" means "this widget."  Typically,
  1676. X    using "this" as the resource value is used to set the "XmNdefaultButton"
  1677. X    resource on a XmbulletinBoard, "menuBar", "workArea", etc on XmMainWindows,
  1678. X    the subMenuId resource on menuBar cascade buttons, and so on.
  1679. X
  1680. X    Just about everything this function does is related to providing
  1681. X    nice error messages.
  1682. X*/
  1683. X
  1684. Xvoid WcSetTypeValueCB ( w, name_res_resType_resVal, unused )
  1685. X    Widget  w;  
  1686. X    char*   name_res_resType_resVal;    /* wid.res: type, val    */
  1687. X    caddr_t unused;            /* call data, not used    */
  1688. X{
  1689. X    /* Note: static buffers make this routine NON-REENTRANT!! */
  1690. X    static char    name   [MAX_XRMSTRING];
  1691. X    static char    res    [MAX_XRMSTRING];
  1692. X    static char    resType[MAX_XRMSTRING];
  1693. X    static char    resVal [MAX_XRMSTRING];
  1694. X
  1695. X    Widget    target;
  1696. X
  1697. X    *name = *res = *resType = *resVal = NUL;
  1698. X
  1699. X    ParseNameResResTypeResVal( name_res_resType_resVal, 
  1700. X                name, res, resType, resVal);
  1701. X
  1702. X    /* Check for syntax error: if any of the strings are null, wrongo!
  1703. X    */
  1704. X    if ( *name == NUL || *res == NUL || *resType == NUL || *resVal == NUL )
  1705. X    {
  1706. X        char *missing;
  1707. X
  1708. X        if (     *name    == NUL) missing = "target_widget";
  1709. X        else if (*res     == NUL) missing = "res";
  1710. X    else if (*resType == NUL) missing = "resType";
  1711. X        else if (*resVal  == NUL) missing = "resVal";
  1712. X
  1713. X        sprintf ( msg,
  1714. X            "WcSetTypeValueCB (%s) - Failed \n\
  1715. X             Usage:   WcSetTypeValueCB( target_widget.res: resType, resVal )\n\
  1716. X             Problem: Missing %s argument.",
  1717. X            name_res_resType_resVal, missing );
  1718. X        XtWarning( msg ); 
  1719. X    return;
  1720. X    }
  1721. X
  1722. X    /* See if we can find the target widget */
  1723. X    if (! (target = WcFullNameToWidget( w, name )) )
  1724. X    {
  1725. X        sprintf ( msg,
  1726. X            "WcSetTypeValueCB (%s)  \n\
  1727. X             Usage:   WcSetTypeValueCB( target_widget.res: resType, resVal )\n\
  1728. X             Problem: Could not find widget named `%s'",
  1729. X             name_res_resType_resVal, name );
  1730. X        XtWarning( msg );
  1731. X        return;
  1732. X    }
  1733. X
  1734. X    /* Try this heuristic: if the resource type has "Widget" somewhere within
  1735. X    ** it, then see if we can convert the resource value to a widget using 
  1736. X    ** WcFullNameToWidget.  This allow relative naming from the calling
  1737. X    ** widget, including `this' or ^^foobar.
  1738. X    ** WcStrStr( res_type, "Widget") returns NULL if "Widget" is not in res_type
  1739. X    ** Note that we must check for both "Widget" and "Window" - we should only
  1740. X    ** check for "Widget" but Motif has a screwed up definition for the
  1741. X    ** menuWidget resource of XmRowColumn widgets.  So, until Motif fixes
  1742. X    ** XmRowColumn.h, we need to check for both...
  1743. X    */
  1744. X    if ( WcStrStr( resType, "Widget") 
  1745. X      || WcStrStr( resType, "Window") )  /* wrong: but that's a menuWidget */
  1746. X    {
  1747. X    Widget    res_widget;
  1748. X
  1749. X    if (res_widget = WcFullNameToWidget( w, resVal ))
  1750. X    {
  1751. X        XtVaSetValues( target, res, res_widget, NULL );
  1752. X        return;
  1753. X    }
  1754. X    }
  1755. X
  1756. X    /* We have the type, so do conversion, and then call XtSetValues. */
  1757. X
  1758. X    WcSetValueFromStringAndType( target, res, resVal, resType );
  1759. X}
  1760. X
  1761. X/*
  1762. X    -- Change sensitivity of widgets.
  1763. X*******************************************************************************
  1764. X    This callback translates string passed in as client data into widget ids
  1765. X    and sets each to be sensitve/insensitive. A comma separated list of 
  1766. X    widgets can be specified.  `this' means the invoking widget.  
  1767. X
  1768. X    This callback someday should take care of the problem with text
  1769. X    widgets - they don't get grey when insensitive, which must be a bug.
  1770. X*/
  1771. X
  1772. X#ifdef FUNCTION_PROTOTYPES
  1773. Xstatic void ChangeSensitivity( Widget, char*, char*, int );
  1774. X#else
  1775. Xstatic void ChangeSensitivity();
  1776. X#endif
  1777. X
  1778. Xvoid WcSetSensitiveCB ( w, widgetNames, unused )
  1779. X    Widget  w;
  1780. X    char*   widgetNames;        /* client data, widgets to be destroyed */
  1781. X    caddr_t unused;        /* call data from widget is not used    */
  1782. X{
  1783. X    ChangeSensitivity ( w, widgetNames, "WcSetSensitiveCB", (Boolean)TRUE );
  1784. X}
  1785. X
  1786. Xvoid WcSetInsensitiveCB ( w, widgetNames, unused )
  1787. X    Widget  w;
  1788. X    char*   widgetNames;        /* client data, widgets to be destroyed */
  1789. X    caddr_t unused;             /* call data from widget is not used    */
  1790. X{
  1791. X    ChangeSensitivity ( w, widgetNames, "WcSetInsensitiveCB", (Boolean)FALSE );
  1792. X}
  1793. X
  1794. Xstatic void ChangeSensitivity ( w, widgetNames, callbackName, sensitive )
  1795. X    Widget  w;
  1796. X    char*   widgetNames;        /* client data, widgets to be destroyed */
  1797. X    char*   callbackName;    /* "WcSetSensitiveCB" or "WcSetInsensitiveCB" */
  1798. X    int     sensitive;
  1799. X{
  1800. X    int    widget_count = MAX_CHILDREN;
  1801. X    char*  unConvertedNames;
  1802. X    int    i;
  1803. X
  1804. X    unConvertedNames = WcNamesToWidgetList ( w, widgetNames,
  1805. X                                    widget_list, &widget_count );
  1806. X    if ( unConvertedNames[0] != NUL )
  1807. X    {
  1808. X        sprintf(msg,
  1809. X            "%s (%s) - One or more widget names ignored \n\
  1810. X             Usage: %s ( widget [, widget ] ...) \n\
  1811. X                    Name of widget can be `this' or wildcarded pathname. \n\
  1812. X                    Problem: No widgets found named %s.",
  1813. X             callbackName, widgetNames, callbackName, unConvertedNames);
  1814. X        XtWarning( msg );
  1815. X    }
  1816. X
  1817. X    for (i=0; i<widget_count; i++)
  1818. X    XtSetSensitive ( widget_list[i], sensitive );
  1819. X}
  1820. X
  1821. X/*
  1822. X    -- Load Resource File
  1823. X*******************************************************************************
  1824. X    This callbacks loads specified resource file into application
  1825. X    resource database. It allows to load resources on as-needed
  1826. X    basis, reducing the intitial resource file load overhead. 
  1827. X    The file to load is specified as client data. The directory search 
  1828. X    for the file (should be) the same as for application class resource file.
  1829. X    
  1830. X    To prevent repeated loads of the same file, the callback keeps
  1831. X    track of each filename.  Note that I do not allow a file to be
  1832. X    re-loaded even if it is changed, or if a new file of the same 
  1833. X    name appears on the search path.  This was done for two reasons:
  1834. X    first, it makes the code more portable, as I don't have to depend
  1835. X    upon various system calls.  Second, resources can't be un-written,
  1836. X    so a user might get the wrong impression that a resource specification
  1837. X    can be deleted, and the resource file re-loaded, and something will
  1838. X    happen.  It just isn't so.
  1839. X
  1840. X    NOTE:
  1841. X    The file search list rule used here is a gross simplification of the R3
  1842. X    resource file search mechanism, without the $LANG provision.
  1843. X    I hope I can use R4 soon and do it RIGHT, but I depend on Motif for now,
  1844. X    and do not want to duplicate all the Motif code here.
  1845. X    Here I look into two directories only, which may be defined as environmental
  1846. X    variables:
  1847. X         XAPPLRESDIR  - defaults to "/usr/lib/X11/app-defaults/"
  1848. X     XUSERRESDIR  - defaults to HOME directory
  1849. X*/
  1850. X
  1851. Xvoid WcLoadResourceFileCB ( w,  resFileName, unused )
  1852. X    Widget w;
  1853. X    char*  resFileName;    /* client data, X resources file name */
  1854. X    caddr_t unused;    /* call data,   not used */
  1855. X{
  1856. X    static char        name[MAX_PATHNAME];        /* so not on stack */
  1857. X    XrmQuark        nameQ;
  1858. X    static XrmQuark    nameQuarks[MAX_RES_FILES];    /* initially all 0 */
  1859. X    int            i;
  1860. X    XrmDatabase        rdb;
  1861. X    Display*        dpy = XtDisplay(w);
  1862. X
  1863. X    (void) WcCleanName( resFileName, name );
  1864. X
  1865. X/*  -- check pathname presence */
  1866. X    if ( *name == NUL )
  1867. X    {
  1868. X        XtWarning ( 
  1869. X            "WcLoadResourceFileCB () - Failed \n\
  1870. X             Usage:   WcLoadResourceFileCB( resource_file_name ) \n\
  1871. X             Problem: No file name provided.");
  1872. X        return;
  1873. X    }
  1874. X
  1875. X/*  -- check for repeated load, remember if first load */
  1876. X    nameQ = XrmStringToQuark( name );
  1877. X    i = 0;
  1878. X    while ( nameQuarks[i] && i < MAX_RES_FILES )
  1879. X    {
  1880. X    if ( nameQuarks[i] == nameQ )
  1881. X        return;            /* NB: not an error, its even common */
  1882. X    else
  1883. X        i++;
  1884. X    }
  1885. X    nameQuarks[i] = nameQ;
  1886. X
  1887. X/*  -- See if filename is an absolute pathname from root `/' */
  1888. X    if ( '/' == name[0] )
  1889. X    {
  1890. X    if ((rdb = XrmGetFileDatabase( name )) != NULL )
  1891. X        XrmMergeDatabases (rdb, &(dpy->db) );
  1892. X    else
  1893. X    {
  1894. X        sprintf( msg,
  1895. X            "WcLoadResourceFileCB (%s) - Failed \n\
  1896. X             Usage:   WcLoadResourceFileCB( resource_file_name ) \n\
  1897. X             Problem: file %s is not a readable file.", 
  1898. X        resFileName, name );
  1899. X        XtWarning( msg );
  1900. X    }
  1901. X    return;
  1902. X    }
  1903. X
  1904. X/*  -- See if filename is a pathname from tilda */
  1905. X    if ( '~' == name[0] )
  1906. X    {
  1907. X    char* homeDir;
  1908. X    char  path[ MAX_PATHNAME ];
  1909. X    char  user[ MAX_PATHNAME ];
  1910. X    char* from = &name[1];        /* skip the tilda */
  1911. X    char* to   = &user[0];
  1912. X
  1913. X    while (*from && *from != '/')
  1914. X        *to++ = *from++;
  1915. X    *to = '\0';
  1916. X
  1917. X    /* NB: `user' now contains either a NUL, or the characters 
  1918. X    ** between the `~' and the first `/`.  `from' now points into 
  1919. X    ** `name' after the `~user', right at the `/` 
  1920. X    */
  1921. X
  1922. X    homeDir = HomeDirectory( user );
  1923. X
  1924. X    if( strlen(homeDir) + strlen(from) >= MAX_PATHNAME )
  1925. X    {
  1926. X        sprintf( msg,
  1927. X            "WcLoadResourceFileCB (%s) - Failed \n\
  1928. X             Usage:   WcLoadResourceFileCB( resource_file_name ) \n\
  1929. X             Problem: file %s becomes too long when expanded.",
  1930. X            resFileName, name );
  1931. X            XtWarning( msg );
  1932. X        return;
  1933. X    }
  1934. X
  1935. X    strcpy( path, homeDir );
  1936. X    strcat( path, from );
  1937. X
  1938. X    if ((rdb = XrmGetFileDatabase( path )) != NULL )
  1939. X        XrmMergeDatabases (rdb, &(dpy->db) );
  1940. X        else
  1941. X        {
  1942. X            sprintf( msg,
  1943. X            "WcLoadResourceFileCB (%s) - Failed \n\
  1944. X             Usage:   WcLoadResourceFileCB( resource_file_name ) \n\
  1945. X             Problem: file %s is not a readable file.",
  1946. X            resFileName, path );
  1947. X            XtWarning( msg );
  1948. X        }
  1949. X        return;
  1950. X    }
  1951. X
  1952. X/*  -- Look for file in current working directory.
  1953. X**     Note this handles when name begins with `.'
  1954. X*/
  1955. X
  1956. X    if ((rdb = XrmGetFileDatabase(name)) != NULL )
  1957. X    {
  1958. X        XrmMergeDatabases (rdb, &(dpy->db) );
  1959. X        return;
  1960. X    }
  1961. X
  1962. X
  1963. X#ifdef XtSpecificationRelease
  1964. X    {
  1965. X    /* Use XUSERFILESEARCHPATH, user's home directory, and XAPPLRESDIR 
  1966. X    ** in the same way that XtR4 does when it gets user's application 
  1967. X    ** defaults.  This code basically mimics GetAppUserDefaults() in 
  1968. X    ** mit/lib/Xt/Initialize.c of the X11R4 distribution.  The main
  1969. X    ** difference is that this routine uses the filename argument `name' 
  1970. X    ** instead of the application class name.
  1971. X    */
  1972. X    char* filename;
  1973. X    char* path;
  1974. X    char* xUserFileSearchPath = getenv("XUSERFILESEARCHPATH");
  1975. X
  1976. X    if (xUserFileSearchPath)
  1977. X        path = xUserFileSearchPath;
  1978. X    else
  1979. X        path = DefaultUserSearchPath( THIS_USER );
  1980. X
  1981. X    filename = XtResolvePathname(
  1982. X        dpy,            /* could be used for language    */
  1983. X        "apps-defaults",    /* type, used as sub-directory    */
  1984. X        name,            /* file name            */
  1985. X        NULL,            /* no file name suffix        */
  1986. X        path,            /* search path, may be NULL    */
  1987. X        NULL, 0,        /* no additional path substitutions */
  1988. X        NULL );            /* if the file exists, is readable,
  1989. X                    ** and not a directory, its OK        */
  1990. X    if ((rdb = XrmGetFileDatabase(filename)) != NULL )
  1991. X    {
  1992. X        XrmMergeDatabases (rdb, &(dpy->db) );
  1993. X        return;
  1994. X    }
  1995. X    }
  1996. X
  1997. X#else
  1998. X    {
  1999. X    /* For Motif 1.0, do something really simple and stupid.  Look for the
  2000. X    ** file in XAPPLRESDIR which is defined in the user's environment, or 
  2001. X    ** in XAPPLOADDIR, the site defined directory for applcation defaults 
  2002. X    ** (commonly /usr/lib/X11/app-defaults
  2003. X    */
  2004. X    char  filename[ MAX_PATHNAME ];
  2005. X    char* path = getenv("XAPPLRESDIR");
  2006. X
  2007. X        if ( NULL == path )
  2008. X        path = XAPPLOADDIR;
  2009. X
  2010. X        if( strlen(path) + strlen(name) >= MAX_PATHNAME )
  2011. X        {
  2012. X            sprintf( msg,
  2013. X            "WcLoadResourceFileCB (%s) - Failed \n\
  2014. X             Usage:   WcLoadResourceFileCB( resource_file_name ) \n\
  2015. X             Problem: file %s becomes too long when \n\
  2016. X                      prepended with %s.",
  2017. X            resFileName, name, path );
  2018. X            XtWarning( msg );
  2019. X            return;
  2020. X        }
  2021. X
  2022. X        strcpy ( filename, path );
  2023. X        strcat ( filename, name );
  2024. X
  2025. X        if ((rdb = XrmGetFileDatabase(filename)) != NULL )
  2026. X        {
  2027. X        XrmMergeDatabases (rdb, &(dpy->db) );
  2028. X        return;
  2029. X        }    
  2030. X    }
  2031. X#endif
  2032. X
  2033. X/*  -- warn the user if no file found */
  2034. X    sprintf  ( msg, 
  2035. X            "WcLoadResourceFileCB (%s) - Failed \n\
  2036. X             Usage:   WcLoadResourceFileCB( resource_file_name ) \n\
  2037. X             Problem: Cannot find resource file %s",
  2038. X    resFileName, name );
  2039. X    XtWarning( msg );
  2040. X}
  2041. X
  2042. X/*
  2043. X  -- WcTraceCallback
  2044. X*******************************************************************************
  2045. X    This is a simple traceback callback, used to assist in interface
  2046. X    debugging. The callback prints the invoking wiget pathname and
  2047. X    a specified message on std. output.
  2048. X*/
  2049. X
  2050. Xvoid WcTraceCB ( w, annotation, unused )
  2051. X    Widget w;
  2052. X    char* annotation;    /* client data, traceback annotation */
  2053. X    caddr_t unused;    /* call data,   not used */
  2054. X{
  2055. X    char* name = WcWidgetToFullName( w );
  2056. X    
  2057. X    printf("TraceCB for %s: %s\n", name, annotation );
  2058. X    XtFree( name );
  2059. X}
  2060. X
  2061. X/*
  2062. X  -- Popup named widget
  2063. X*******************************************************************************
  2064. X    These callbacks translate a string passed in as client data into a 
  2065. X    widget id.  
  2066. X
  2067. X    A grab kind value of XtGrabNone has the effect of allowing 
  2068. X    non-modal popups.  This is the preferred type: rarely use modal pop-ups.
  2069. X    This is registered as PopupCB.
  2070. X
  2071. X    A grab kind value of XtGrabExclusive has the effect of grabbing all
  2072. X    application events, allowing modal popups.  This is registered as 
  2073. X    PopupGrabCB.
  2074. X*/
  2075. X
  2076. X#ifdef FUNCTION_PROTOTYPES
  2077. Xstatic void Popup ( Widget, char*, char*, XtGrabKind );
  2078. X#else
  2079. Xstatic void Popup ();
  2080. X#endif
  2081. X
  2082. Xvoid WcPopupCB ( w, name, unused )
  2083. X    Widget      w;
  2084. X    char*       name;
  2085. X    caddr_t    unused;
  2086. X{
  2087. X    Popup ( w, name, "WcPopupCB", XtGrabNone );
  2088. X}
  2089. X
  2090. Xvoid WcPopupGrabCB ( w, name, unused )
  2091. X    Widget      w;
  2092. X    char*       name;
  2093. X    caddr_t     unused;
  2094. X{
  2095. X    Popup ( w, name, "WcPopupGrabCB", XtGrabExclusive );
  2096. X}
  2097. X
  2098. Xstatic void Popup ( w, name, callbackName, grab )
  2099. X    Widget    w;
  2100. X    char*    name;
  2101. X    char*    callbackName;
  2102. X    XtGrabKind    grab;
  2103. X{
  2104. X    Widget      widget;
  2105. X
  2106. X    (void)WcCleanName ( name, cleanName );
  2107. X    widget = WcFullNameToWidget ( w, cleanName );
  2108. X
  2109. X    if (XtIsShell(widget))
  2110. X    {
  2111. X        XtPopup  ( widget, grab );
  2112. X    }
  2113. X    else
  2114. X    {
  2115. X        sprintf( msg,
  2116. X            "%s (%s) - Failed \n\
  2117. X             Usage: %s (shell_widget_name) \n\
  2118. X             Problem: `%s' is not a shell widget.",
  2119. X             callbackName, name, callbackName, cleanName);
  2120. X        XtWarning( msg );
  2121. X    }
  2122. X}
  2123. X
  2124. X/*
  2125. X  -- Popdown named widget
  2126. X*******************************************************************************
  2127. X    This callback translates string passed in as client data into a widget id
  2128. X    and pops-down a popup shell widget.
  2129. X*/
  2130. X
  2131. Xvoid WcPopdownCB ( w, name, unused ) 
  2132. X    Widget    w;
  2133. X    char*    name;
  2134. X    caddr_t    unused;
  2135. X{
  2136. X    Widget      widget;
  2137. X
  2138. X    (void)WcCleanName ( name, cleanName );
  2139. X    widget = WcFullNameToWidget ( w, cleanName );
  2140. X
  2141. X    if (XtIsShell(widget))
  2142. X    {
  2143. X        XtPopdown  ( widget );
  2144. X    }
  2145. X    else
  2146. X    {
  2147. X        sprintf( msg,
  2148. X            "WcPopdownCB (%s) Failed \n\
  2149. X             Usage: WcPopdownCB (shell_widget_name) \n\
  2150. X             Problem: `%s' is not a shell widget.",
  2151. X             name, cleanName);
  2152. X        XtWarning( msg );
  2153. X    }
  2154. X}
  2155. X
  2156. X/*
  2157. X  -- Map and Unmap named widget
  2158. X*******************************************************************************
  2159. X    These callbacks translate a string passed as client data into a widget id
  2160. X    and invokes either XtMapWidget() os XtUnmapWidget() as appropriate.
  2161. X*/
  2162. X
  2163. Xvoid WcMapCB (w, name, unused )
  2164. X    Widget      w;
  2165. X    char*       name;
  2166. X    caddr_t     unused;
  2167. X{
  2168. X    Widget      widget;
  2169. X
  2170. X    (void)WcCleanName ( name, cleanName );
  2171. X    widget = WcFullNameToWidget ( w, cleanName );
  2172. X
  2173. X    if (XtIsShell(widget))
  2174. X    {
  2175. X        XtMapWidget ( widget );
  2176. X    }
  2177. X    else
  2178. X    {
  2179. X        sprintf( msg,
  2180. X            "WcMapCB (%s) Failed \n\
  2181. X             Usage: WcMapCB (shell_widget_name) \n\
  2182. X             Problem: `%s' is not a shell widget.",
  2183. X             name, cleanName);
  2184. X        XtWarning( msg );
  2185. X    }
  2186. X}
  2187. X
  2188. Xvoid WcUnmapCB (w, name, unused )
  2189. X    Widget      w;
  2190. X    char*       name;
  2191. X    caddr_t     unused;
  2192. X{
  2193. X    Widget      widget;
  2194. X
  2195. X    (void)WcCleanName ( name, cleanName );
  2196. X    widget = WcFullNameToWidget ( w, cleanName );
  2197. X
  2198. X    if (XtIsShell(widget))
  2199. X    {
  2200. X        XtUnmapWidget ( widget );
  2201. X    }
  2202. X    else
  2203. X    {
  2204. X        sprintf( msg,
  2205. X            "WcUnmapCB (%s) Failed \n\
  2206. X             Usage: WcUnmapCB (shell_widget_name) \n\
  2207. X             Problem: `%s' is not a shell widget.",
  2208. X             name, cleanName);
  2209. X        XtWarning( msg );
  2210. X    }
  2211. X}
  2212. X
  2213. X/*
  2214. X  -- Invoke shell command
  2215. X*******************************************************************************
  2216. X    Call system().
  2217. X*/
  2218. X
  2219. Xvoid WcSystemCB ( w, shellCmdString, unused )
  2220. X    Widget      w;
  2221. X    char*       shellCmdString;
  2222. X    caddr_t     unused;
  2223. X{
  2224. X    system( shellCmdString );
  2225. X}
  2226. X
  2227. X/*
  2228. X  -- Exit the application
  2229. X*******************************************************************************
  2230. X    Call exit().
  2231. X*/
  2232. X
  2233. Xvoid WcExitCB ( w, exitValString, unused )
  2234. X    Widget    w;
  2235. X    char*    exitValString;
  2236. X    caddr_t    unused;
  2237. X{
  2238. X    int exitval = 0;
  2239. X
  2240. X    /* skip leading garbage before int */
  2241. X    while (*exitValString)
  2242. X    {
  2243. X        if ('0' < *exitValString && *exitValString <= '9')
  2244. X            break; /* found numbers, convert to exitval */
  2245. X        exitValString++;
  2246. X    }
  2247. X
  2248. X    /* convert to int */
  2249. X    while (*exitValString)
  2250. X    {
  2251. X        if ('0' < *exitValString && *exitValString <= '9')
  2252. X        {
  2253. X            exitval = exitval * 10 + (*exitValString - '0');
  2254. X            exitValString++;
  2255. X        }
  2256. X        else
  2257. X            break;  /* ignore trailing garbage */
  2258. X    }
  2259. X
  2260. X    exit( exitval );
  2261. X}
  2262. X
  2263. X/*
  2264. X  -- WcRegisterCreateCallbacks
  2265. X*******************************************************************************
  2266. X   Convenience routine, registering all standard callbacks in one application
  2267. X   call.   Called from WcWidgetCreation(), so application usually never needs
  2268. X   to call this.
  2269. X*/
  2270. X
  2271. Xvoid WcRegisterWcCallbacks ( app )
  2272. XXtAppContext app;
  2273. X{
  2274. X    ONCE_PER_XtAppContext( app );
  2275. X
  2276. X#define RCALL( name, func ) WcRegisterCallback ( app, name, func, NULL )
  2277. X
  2278. X    RCALL( "WcCreateChildrenCB",    WcCreateChildrenCB    );
  2279. X    RCALL( "WcCreatePopupsCB",        WcCreatePopupsCB    );
  2280. X    RCALL( "WcManageCB",        WcManageCB        );
  2281. X    RCALL( "WcUnmanageCB",        WcUnmanageCB        );
  2282. X    RCALL( "WcManageChildrenCB",    WcManageChildrenCB    );
  2283. X    RCALL( "WcUnmanageChildrenCB",    WcUnmanageChildrenCB    );
  2284. X    RCALL( "WcDestroyCB",        WcDestroyCB        );
  2285. X    RCALL( "WcSetValueCB",        WcSetValueCB        );
  2286. X    RCALL( "WcSetTypeValueCB",        WcSetTypeValueCB    );
  2287. X    RCALL( "WcSetSensitiveCB",        WcSetSensitiveCB    );
  2288. X    RCALL( "WcSetInsensitiveCB",    WcSetInsensitiveCB    );
  2289. X    RCALL( "WcLoadResourceFileCB",    WcLoadResourceFileCB    );
  2290. X    RCALL( "WcTraceCB",            WcTraceCB        );
  2291. X    RCALL( "WcPopupCB",            WcPopupCB        );
  2292. X    RCALL( "WcPopupGrabCB",        WcPopupGrabCB        );
  2293. X    RCALL( "WcPopdownCB",        WcPopdownCB        );
  2294. X    RCALL( "WcMapCB",            WcMapCB            );
  2295. X    RCALL( "WcUnmapCB",            WcUnmapCB        );
  2296. X    RCALL( "WcSystemCB",        WcSystemCB        );
  2297. X    RCALL( "WcExitCB",            WcExitCB        );
  2298. X}
  2299. END_OF_FILE
  2300. if test 46686 -ne `wc -c <'xrainbow/Wc1_05/Wc/WcCallb.c'`; then
  2301.     echo shar: \"'xrainbow/Wc1_05/Wc/WcCallb.c'\" unpacked with wrong size!
  2302. fi
  2303. # end of 'xrainbow/Wc1_05/Wc/WcCallb.c'
  2304. fi
  2305. if test -f 'xrainbow/X11/Xaw_d/DrawingAP.h' -a "${1}" != "-c" ; then 
  2306.   echo shar: Will not clobber existing file \"'xrainbow/X11/Xaw_d/DrawingAP.h'\"
  2307. else
  2308. echo shar: Extracting \"'xrainbow/X11/Xaw_d/DrawingAP.h'\" \(1365 characters\)
  2309. sed "s/^X//" >'xrainbow/X11/Xaw_d/DrawingAP.h' <<'END_OF_FILE'
  2310. X/* DrawingArea Private header file */
  2311. X
  2312. X/* Copyright 1990, David Nedde
  2313. X/*
  2314. X/* Permission to use, copy, modify, and distribute this
  2315. X/* software and its documentation for any purpose and without fee
  2316. X/* is granted provided that the above copyright notice appears in all copies.
  2317. X/* It is provided "as is" without express or implied warranty.
  2318. X*/
  2319. X
  2320. X#ifndef _XawDrawingAreaP_h
  2321. X#define _XawDrawingAreaP_h
  2322. X
  2323. X#include "DrawingA.h"
  2324. X#ifdef X11_R3
  2325. X#include <X11/SimpleP.h>
  2326. X#else
  2327. X#include <X11/Xaw/SimpleP.h>
  2328. X#endif
  2329. X
  2330. X/* The drawing area's contribution to the class record */
  2331. Xtypedef struct _DrawingAreaClassPart {
  2332. X  int ignore;
  2333. X} DrawingAreaClassPart;
  2334. X
  2335. X/* Drawing area's full class record */
  2336. Xtypedef struct _DrawingAreaClassRec {
  2337. X    CoreClassPart    core_class;
  2338. X    SimpleClassPart    simple_class;
  2339. X    DrawingAreaClassPart drawing_area;
  2340. X} DrawingAreaClassRec;
  2341. X
  2342. Xextern DrawingAreaClassRec drawingAreaClassRec;
  2343. X
  2344. X/* Resources added and status of drawing area widget */
  2345. Xtypedef struct _XsDrawingAreaPart {
  2346. X  /* Resources */
  2347. X  XtCallbackList    expose_callback;
  2348. X  XtCallbackList    input_callback;
  2349. X  XtCallbackList    motion_callback;
  2350. X  XtCallbackList    resize_callback;
  2351. X} DrawingAreaPart;
  2352. X
  2353. X
  2354. X/* Drawing area's instance record */
  2355. Xtypedef struct _DrawingAreaRec {
  2356. X    CorePart         core;
  2357. X    SimplePart         simple;
  2358. X    DrawingAreaPart  drawing_area;
  2359. X} DrawingAreaRec;
  2360. X
  2361. X#endif /* _XawDrawingAreaP_h */
  2362. END_OF_FILE
  2363. if test 1365 -ne `wc -c <'xrainbow/X11/Xaw_d/DrawingAP.h'`; then
  2364.     echo shar: \"'xrainbow/X11/Xaw_d/DrawingAP.h'\" unpacked with wrong size!
  2365. fi
  2366. # end of 'xrainbow/X11/Xaw_d/DrawingAP.h'
  2367. fi
  2368. if test -f 'xrainbow/X11/Xaw_d/Imakefile' -a "${1}" != "-c" ; then 
  2369.   echo shar: Will not clobber existing file \"'xrainbow/X11/Xaw_d/Imakefile'\"
  2370. else
  2371. echo shar: Extracting \"'xrainbow/X11/Xaw_d/Imakefile'\" \(217 characters\)
  2372. sed "s/^X//" >'xrainbow/X11/Xaw_d/Imakefile' <<'END_OF_FILE'
  2373. X/**/#
  2374. X/**/#   Imakefile for Xaw_d : Dave Nedde (daven@wpi.wpi.edu)
  2375. X/**/#
  2376. X
  2377. X        INCROOT = ../..
  2378. X           SRCS = DrawingA.c
  2379. X
  2380. XNormalLibraryTarget(Xaw_d,DrawingA.o)
  2381. X
  2382. XDependTarget()
  2383. X
  2384. XLintLibraryTarget(Xaw_d,$(SRCS))
  2385. X
  2386. END_OF_FILE
  2387. if test 217 -ne `wc -c <'xrainbow/X11/Xaw_d/Imakefile'`; then
  2388.     echo shar: \"'xrainbow/X11/Xaw_d/Imakefile'\" unpacked with wrong size!
  2389. fi
  2390. # end of 'xrainbow/X11/Xaw_d/Imakefile'
  2391. fi
  2392. if test ! -d 'xrainbow/include/Wc' ; then
  2393.     echo shar: Creating directory \"'xrainbow/include/Wc'\"
  2394.     mkdir 'xrainbow/include/Wc'
  2395. fi
  2396. if test ! -d 'xrainbow/include/X11' ; then
  2397.     echo shar: Creating directory \"'xrainbow/include/X11'\"
  2398.     mkdir 'xrainbow/include/X11'
  2399. fi
  2400. if test ! -d 'xrainbow/include/X11/Xaw_d' ; then
  2401.     echo shar: Creating directory \"'xrainbow/include/X11/Xaw_d'\"
  2402.     mkdir 'xrainbow/include/X11/Xaw_d'
  2403. fi
  2404. if test ! -d 'xrainbow/main' ; then
  2405.     echo shar: Creating directory \"'xrainbow/main'\"
  2406.     mkdir 'xrainbow/main'
  2407. fi
  2408. if test -f 'xrainbow/main/patchlevel.h' -a "${1}" != "-c" ; then 
  2409.   echo shar: Will not clobber existing file \"'xrainbow/main/patchlevel.h'\"
  2410. else
  2411. echo shar: Extracting \"'xrainbow/main/patchlevel.h'\" \(21 characters\)
  2412. sed "s/^X//" >'xrainbow/main/patchlevel.h' <<'END_OF_FILE'
  2413. X#define PATCHLEVEL 0
  2414. END_OF_FILE
  2415. if test 21 -ne `wc -c <'xrainbow/main/patchlevel.h'`; then
  2416.     echo shar: \"'xrainbow/main/patchlevel.h'\" unpacked with wrong size!
  2417. fi
  2418. # end of 'xrainbow/main/patchlevel.h'
  2419. fi
  2420. echo shar: End of archive 2 \(of 5\).
  2421. cp /dev/null ark2isdone
  2422. MISSING=""
  2423. for I in 1 2 3 4 5 ; do
  2424.     if test ! -f ark${I}isdone ; then
  2425.     MISSING="${MISSING} ${I}"
  2426.     fi
  2427. done
  2428. if test "${MISSING}" = "" ; then
  2429.     echo You have unpacked all 5 archives.
  2430.     echo "Please Read README"
  2431.     rm -f ark[1-9]isdone
  2432. else
  2433.     echo You still need to unpack the following archives:
  2434.     echo "        " ${MISSING}
  2435. fi
  2436. ##  End of shell archive.
  2437. exit 0
  2438.  
  2439. --
  2440. Dan Heller
  2441. O'Reilly && Associates       Z-Code Software    Comp-sources-x:
  2442. Senior Writer                President          comp-sources-x@uunet.uu.net
  2443. argv@ora.com                 argv@zipcode.com
  2444.