home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume21 / xcal / part06 < prev    next >
Encoding:
Text File  |  1993-12-22  |  52.8 KB  |  2,001 lines

  1. Newsgroups: comp.sources.x
  2. From: pc@hillside.co.uk (Peter Collinson)
  3. Subject: v21i081:  xcal - A calendar program for X, Part06/08
  4. Message-ID: <1993Dec21.161812.22168@sparky.sterling.com>
  5. X-Md4-Signature: 78c063c29da489e794522a68449590a4
  6. Sender: chris@sparky.sterling.com (Chris Olson)
  7. Organization: Hillside Systems, 61 Hillside Avenue, Canterbury, Kent CT2 8HA
  8. Date: Tue, 21 Dec 1993 16:18:12 GMT
  9. Approved: chris@sterling.com
  10.  
  11. Submitted-by: pc@hillside.co.uk (Peter Collinson)
  12. Posting-number: Volume 21, Issue 81
  13. Archive-name: xcal/part06
  14. Environment: X11
  15. Supersedes: xcal: Volume 12, Issue 101
  16.  
  17. Xcal is a calendar program. For more details see Part 1 of this posting
  18.  
  19. Part 6 of 8
  20. --shar starts here--
  21. #! /bin/sh
  22. # This is a shell archive.  Remove anything before this line, then unpack
  23. # it by saving it into a file and typing "sh file".  To overwrite existing
  24. # files, type "sh file -c".  You can also feed this as standard input via
  25. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  26. # will see the following message at the end:
  27. #        "End of archive 6 (of 8)."
  28. # Contents:  Makefile.bsdi xcal_memo.c xcal_strip.c
  29. # Wrapped by pc@hillside on Wed Nov 17 11:24:37 1993
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f 'Makefile.bsdi' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'Makefile.bsdi'\"
  33. else
  34. echo shar: Extracting \"'Makefile.bsdi'\" \(14937 characters\)
  35. sed "s/^X//" >'Makefile.bsdi' <<'END_OF_FILE'
  36. X# Makefile generated by imake - do not edit!
  37. X# $XConsortium: imake.c,v 1.65 91/07/25 17:50:17 rws Exp $
  38. X
  39. X# -------------------------------------------------------------------------
  40. X# Makefile generated from "Imake.tmpl" and <Imakefile>
  41. X# $XConsortium: Imake.tmpl,v 1.139 91/09/16 08:52:48 rws Exp $
  42. X#
  43. X# Platform-specific parameters may be set in the appropriate <vendor>.cf
  44. X# configuration files.  Site-specific parameters should be set in the file
  45. X# site.def.  Full rebuilds are recommended if any parameters are changed.
  46. X#
  47. X# If your C preprocessor does not define any unique symbols, you will need
  48. X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  49. X# "make World" the first time).
  50. X#
  51. X
  52. X# -------------------------------------------------------------------------
  53. X# site-specific configuration parameters that need to come before
  54. X# the platform-specific parameters - edit site.def to change
  55. X
  56. X# site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  57. X
  58. X# -------------------------------------------------------------------------
  59. X# platform-specific configuration parameters - edit bsd.cf to change
  60. X
  61. X# platform:  $XConsortium: bsd.cf,v 1.18 91/07/30 12:10:52 rws Exp $
  62. X
  63. X# operating system:             4.3bsd
  64. X
  65. X# -------------------------------------------------------------------------
  66. X# site-specific configuration parameters that go after
  67. X# the platform-specific parameters - edit site.def to change
  68. X
  69. X# site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  70. X
  71. X            SHELL =     /bin/sh
  72. X
  73. X              TOP = .
  74. X      CURRENT_DIR = .
  75. X
  76. X               AR = ar clq
  77. X  BOOTSTRAPCFLAGS =
  78. X               CC = cc
  79. X               AS = as
  80. X
  81. X         COMPRESS = compress
  82. X              CPP =     /usr/bin/cpp $(STD_CPP_DEFINES)
  83. X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
  84. X          INSTALL = install
  85. X               LD = ld
  86. X             LINT = lint
  87. X      LINTLIBFLAG = -C
  88. X         LINTOPTS = -axz
  89. X               LN = ln -s
  90. X             MAKE = make
  91. X               MV = mv
  92. X               CP = cp
  93. X
  94. X           RANLIB = ranlib
  95. X  RANLIBINSTFLAGS =
  96. X
  97. X               RM = rm -f
  98. X            TROFF = groff -Tps
  99. X         MSMACROS = -ms
  100. X              TBL = tbl
  101. X              EQN = eqn
  102. X     STD_INCLUDES =
  103. X  STD_CPP_DEFINES =
  104. X      STD_DEFINES =
  105. X EXTRA_LOAD_FLAGS =
  106. X  EXTRA_LIBRARIES =
  107. X             TAGS = ctags
  108. X
  109. X    PROTO_DEFINES =
  110. X
  111. X     INSTPGMFLAGS = -s
  112. X
  113. X     INSTBINFLAGS = -m 0755
  114. X     INSTUIDFLAGS = -m 4755
  115. X     INSTLIBFLAGS = -m 0644
  116. X     INSTINCFLAGS = -m 0444
  117. X     INSTMANFLAGS = -m 0444
  118. X     INSTDATFLAGS = -m 0444
  119. X    INSTKMEMFLAGS = -m 4755
  120. X
  121. X      PROJECTROOT =  /usr/X11
  122. X
  123. X     TOP_INCLUDES = -I$(INCROOT)
  124. X
  125. X      CDEBUGFLAGS = -O
  126. X        CCOPTIONS =
  127. X
  128. X      ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
  129. X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(DEFINES)
  130. X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
  131. X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
  132. X
  133. X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  134. X
  135. X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS) -L$(USRLIBDIR)
  136. X
  137. X   LDCOMBINEFLAGS = -X -r
  138. X      DEPENDFLAGS =
  139. X
  140. X        MACROFILE = bsd.cf
  141. X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
  142. X
  143. X    IMAKE_DEFINES =
  144. X
  145. X         IRULESRC = $(CONFIGDIR)
  146. X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
  147. X
  148. X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules             $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def             $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
  149. X
  150. X# -------------------------------------------------------------------------
  151. X# X Window System Build Parameters
  152. X# $XConsortium: Project.tmpl,v 1.138.1.1 92/11/11 09:49:19 rws Exp $
  153. X
  154. X# -------------------------------------------------------------------------
  155. X# X Window System make variables; this need to be coordinated with rules
  156. X
  157. X          PATHSEP = /
  158. X        USRLIBDIR =  /usr/X11/lib
  159. X           BINDIR =  /usr/X11/bin
  160. X          INCROOT =  /usr/X11/include
  161. X     BUILDINCROOT = $(TOP)
  162. X      BUILDINCDIR = $(BUILDINCROOT)/X11
  163. X      BUILDINCTOP = ..
  164. X           INCDIR = $(INCROOT)/X11
  165. X           ADMDIR = /usr/adm
  166. X           LIBDIR = $(USRLIBDIR)/X11
  167. X        CONFIGDIR = $(LIBDIR)/config
  168. X       LINTLIBDIR = $(USRLIBDIR)/lint
  169. X
  170. X          FONTDIR = $(LIBDIR)/fonts
  171. X         XINITDIR = $(LIBDIR)/xinit
  172. X           XDMDIR = $(LIBDIR)/xdm
  173. X           TWMDIR = $(LIBDIR)/twm
  174. X          MANPATH =  /usr/X11/man
  175. X    MANSOURCEPATH = $(MANPATH)/man
  176. X        MANSUFFIX = n
  177. X     LIBMANSUFFIX = 3
  178. X           MANDIR = $(MANSOURCEPATH)$(MANSUFFIX)
  179. X        LIBMANDIR = $(MANSOURCEPATH)$(LIBMANSUFFIX)
  180. X           NLSDIR = $(LIBDIR)/nls
  181. X        PEXAPIDIR = $(LIBDIR)/PEX
  182. X      XAPPLOADDIR = $(LIBDIR)/app-defaults
  183. X       FONTCFLAGS = -t
  184. X
  185. X     INSTAPPFLAGS = $(INSTDATFLAGS)
  186. X
  187. X            IMAKE = imake
  188. X           DEPEND = makedepend
  189. X              RGB = rgb
  190. X
  191. X            FONTC = bdftopcf
  192. X
  193. X        MKFONTDIR = mkfontdir
  194. X        MKDIRHIER =     /bin/sh $(BINDIR)/mkdirhier
  195. X
  196. X        CONFIGSRC = $(TOP)/config
  197. X       DOCUTILSRC = $(TOP)/doc/util
  198. X        CLIENTSRC = $(TOP)/clients
  199. X          DEMOSRC = $(TOP)/demos
  200. X           LIBSRC = $(TOP)/lib
  201. X          FONTSRC = $(TOP)/fonts
  202. X       INCLUDESRC = $(TOP)/X11
  203. X        SERVERSRC = $(TOP)/server
  204. X          UTILSRC = $(TOP)/util
  205. X        SCRIPTSRC = $(UTILSRC)/scripts
  206. X       EXAMPLESRC = $(TOP)/examples
  207. X       CONTRIBSRC = $(TOP)/../contrib
  208. X           DOCSRC = $(TOP)/doc
  209. X           RGBSRC = $(TOP)/rgb
  210. X        DEPENDSRC = $(UTILSRC)/makedepend
  211. X         IMAKESRC = $(CONFIGSRC)
  212. X         XAUTHSRC = $(LIBSRC)/Xau
  213. X          XLIBSRC = $(LIBSRC)/X
  214. X           XMUSRC = $(LIBSRC)/Xmu
  215. X       TOOLKITSRC = $(LIBSRC)/Xt
  216. X       AWIDGETSRC = $(LIBSRC)/Xaw
  217. X       OLDXLIBSRC = $(LIBSRC)/oldX
  218. X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
  219. X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  220. X      BDFTOSNFSRC = $(FONTSRC)/clients/bdftosnf
  221. X      BDFTOPCFSRC = $(FONTSRC)/clients/bdftopcf
  222. X     MKFONTDIRSRC = $(FONTSRC)/clients/mkfontdir
  223. X         FSLIBSRC = $(FONTSRC)/lib/fs
  224. X    FONTSERVERSRC = $(FONTSRC)/server
  225. X     EXTENSIONSRC = $(TOP)/extensions
  226. X         XILIBSRC = $(EXTENSIONSRC)/lib/xinput
  227. X        PEXLIBSRC = $(EXTENSIONSRC)/lib/PEXlib
  228. X      PHIGSLIBSRC = $(EXTENSIONSRC)/lib/PEX
  229. X
  230. X  DEPEXTENSIONLIB = $(USRLIBDIR)/libXext.a
  231. X     EXTENSIONLIB =              -lXext
  232. X
  233. X          DEPXLIB = $(DEPEXTENSIONLIB) $(USRLIBDIR)/libX11.a
  234. X             XLIB = $(EXTENSIONLIB)              -lX11
  235. X
  236. X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
  237. X         XAUTHLIB =              -lXau
  238. X      DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a
  239. X         XDMCPLIB =              -lXdmcp
  240. X
  241. X        DEPXMULIB = $(USRLIBDIR)/libXmu.a
  242. X           XMULIB =              -lXmu
  243. X
  244. X       DEPOLDXLIB = $(USRLIBDIR)/liboldX.a
  245. X          OLDXLIB =              -loldX
  246. X
  247. X      DEPXTOOLLIB = $(USRLIBDIR)/libXt.a
  248. X         XTOOLLIB =              -lXt
  249. X
  250. X        DEPXAWLIB = $(USRLIBDIR)/libXaw.a
  251. X           XAWLIB =              -lXaw
  252. X
  253. X        DEPXILIB = $(USRLIBDIR)/libXi.a
  254. X           XILIB =              -lXi
  255. X
  256. X       DEPPEXLIB = $(USRLIBDIR)/libPEX5.a
  257. X          PEXLIB =              -lPEX5
  258. X
  259. X        DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a
  260. X           PHIGSLIB =              -lphigs
  261. X
  262. X       DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a
  263. X          XBSDLIB =              -lXbsd
  264. X
  265. X LINTEXTENSIONLIB = $(LINTLIBDIR)/llib-lXext.ln
  266. X         LINTXLIB = $(LINTLIBDIR)/llib-lX11.ln
  267. X          LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln
  268. X        LINTXTOOL = $(LINTLIBDIR)/llib-lXt.ln
  269. X          LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln
  270. X           LINTXI = $(LINTLIBDIR)/llib-lXi.ln
  271. X          LINTPEX = $(LINTLIBDIR)/llib-lPEX5.ln
  272. X        LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln
  273. X
  274. X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
  275. X
  276. X         DEPLIBS1 = $(DEPLIBS)
  277. X         DEPLIBS2 = $(DEPLIBS)
  278. X         DEPLIBS3 = $(DEPLIBS)
  279. X
  280. X# -------------------------------------------------------------------------
  281. X# Imake rules for building libraries, programs, scripts, and data files
  282. X# rules:  $XConsortium: Imake.rules,v 1.123 91/09/16 20:12:16 rws Exp $
  283. X
  284. X# -------------------------------------------------------------------------
  285. X# start of Imakefile
  286. X
  287. X        DEFINES = -DLONG_IS_32_BITS -DVER_VEC
  288. X
  289. X          SRCS1 = xcal.c xcal_alarm.c xcal_buts.c xcal_days.c xcal_edit.c           xcal_help.c xcal_popup.c xcal_strip.c xcal_memo.c strfdate.c version.c
  290. X
  291. X          OBJS1 = xcal.o xcal_alarm.o xcal_buts.o xcal_days.o xcal_edit.o           xcal_help.o xcal_popup.o xcal_strip.o xcal_memo.o strfdate.o version.o
  292. X
  293. X       PROGRAMS = derived xcal
  294. X   INSTPGMFLAGS = $(INSTBINFLAGS)
  295. X         BINDIR = /usr/local/bin
  296. X
  297. X OBJS = $(OBJS1) $(OBJS2) $(OBJS3)
  298. X SRCS = $(SRCS1) $(SRCS2) $(SRCS3)
  299. X
  300. Xall:: $(PROGRAMS)
  301. X
  302. Xxcal: $(OBJS1) $(DEPLIBS1)
  303. X    $(RM) $@
  304. X    $(CC) -o $@ $(LDOPTIONS) $(OBJS1)  $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) $(LDLIBS)  -lm $(EXTRA_LOAD_FLAGS)
  305. X
  306. Xinstall:: xcal
  307. X    -@if [ -d $(DESTDIR)$(BINDIR) ]; then set +x; \
  308. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(BINDIR)); fi
  309. X    $(INSTALL) -c $(INSTPGMFLAGS)  xcal $(DESTDIR)$(BINDIR)
  310. X
  311. Xinstall.man:: xcal.man
  312. X    -@if [ -d $(DESTDIR)$(MANDIR) ]; then set +x; \
  313. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(MANDIR)); fi
  314. X    $(INSTALL) -c $(INSTMANFLAGS) xcal.man $(DESTDIR)$(MANDIR)/xcal.$(MANSUFFIX)
  315. X
  316. Xdepend::
  317. X    $(DEPEND) $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
  318. X
  319. Xlint:
  320. X    $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
  321. Xlint1:
  322. X    $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
  323. X
  324. Xclean::
  325. X    $(RM) $(PROGRAMS)
  326. X
  327. Xinstall:: XCal.ad
  328. X    -@if [ -d $(DESTDIR)$(XAPPLOADDIR) ]; then set +x; \
  329. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(XAPPLOADDIR)); fi
  330. X    $(INSTALL) -c $(INSTAPPFLAGS) XCal.ad $(DESTDIR)$(XAPPLOADDIR)/XCal
  331. X
  332. Xinstall:: XCal.help
  333. X    $(INSTALL) -c $(INSTDATFLAGS) XCal.help $(DESTDIR) $(XAPPLOADDIR)/XCal.help
  334. X
  335. Xderived:    xcal_help.h xcal_ad.h
  336. X
  337. Xclean::
  338. X    $(RM) xcal_help.h xcal_ad.h
  339. X
  340. Xxcal_help.h:    XCal.help
  341. X    sh C_from_help.sh
  342. X
  343. Xxcal_ad.h:    XCal.ad
  344. X    sh C_from_ad.sh
  345. X
  346. XSUBD=xcalpr xcalev xcal_cal
  347. X
  348. Xall::
  349. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  350. X    for i in $(SUBD) ;\
  351. X    do \
  352. X    (cd $$i ; echo "making" all "in $(CURRENT_DIR)/$$i..."; \
  353. X    $(MAKE) $(MFLAGS) 'CDEBUGFLAGS=$(CDEBUGFLAGS)' all); \
  354. X    done
  355. X
  356. Xclean::
  357. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  358. X    for i in $(SUBD) ;\
  359. X    do \
  360. X    (cd $$i ; echo "cleaning" "in $(CURRENT_DIR)/$$i..."; \
  361. X    $(MAKE) $(MFLAGS) RM_CMD='$(RM_CMD)' clean); \
  362. X    done
  363. X
  364. Xinstall::
  365. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  366. X    for i in $(SUBD) ;\
  367. X    do \
  368. X    (cd $$i ; echo "installing" "in $(CURRENT_DIR)/$$i..."; \
  369. X    $(MAKE) $(MFLAGS) DESTDIR='$(DESTDIR)' install); \
  370. X    done
  371. X
  372. Xinstall.man::
  373. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  374. X    for i in $(SUBD) ;\
  375. X    do \
  376. X    (cd $$i ; echo "installing man pages" "in $(CURRENT_DIR)/$$i..."; \
  377. X    $(MAKE) $(MFLAGS) DESTDIR='$(DESTDIR)' install.man); \
  378. X    done
  379. X
  380. Xdepend::
  381. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  382. X    for i in $(SUBD) ;\
  383. X    do \
  384. X    (cd $$i ; echo "depending" "in $(CURRENT_DIR)/$$i..."; \
  385. X    $(MAKE) $(MFLAGS)  depend); \
  386. X    done
  387. X
  388. XSUBDIRS = pscal
  389. X
  390. Xall::
  391. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  392. X    for i in $(SUBDIRS) ;\
  393. X    do \
  394. X    (cd $$i ; echo "making" all "in $(CURRENT_DIR)/$$i..."; \
  395. X    $(MAKE) $(MFLAGS) 'CDEBUGFLAGS=$(CDEBUGFLAGS)' all); \
  396. X    done
  397. X
  398. Xdepend::
  399. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  400. X    for i in $(SUBDIRS) ;\
  401. X    do \
  402. X    (cd $$i ; echo "depending" "in $(CURRENT_DIR)/$$i..."; \
  403. X    $(MAKE) $(MFLAGS)  depend); \
  404. X    done
  405. X
  406. X# -------------------------------------------------------------------------
  407. X# common rules for all Makefiles - do not edit
  408. X
  409. Xemptyrule::
  410. X
  411. Xclean::
  412. X    $(RM_CMD) "#"*
  413. X
  414. XMakefile::
  415. X    -@if [ -f Makefile ]; then set -x; \
  416. X    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  417. X    else exit 0; fi
  418. X    $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
  419. X
  420. Xtags::
  421. X    $(TAGS) -w *.[ch]
  422. X    $(TAGS) -xw *.[ch] > TAGS
  423. X
  424. X# -------------------------------------------------------------------------
  425. X# rules for building in SUBDIRS - do not edit
  426. X
  427. Xinstall::
  428. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  429. X    for i in $(SUBDIRS) ;\
  430. X    do \
  431. X    (cd $$i ; echo "installing" "in $(CURRENT_DIR)/$$i..."; \
  432. X    $(MAKE) $(MFLAGS) DESTDIR='$(DESTDIR)' install); \
  433. X    done
  434. X
  435. Xinstall.man::
  436. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  437. X    for i in $(SUBDIRS) ;\
  438. X    do \
  439. X    (cd $$i ; echo "installing man pages" "in $(CURRENT_DIR)/$$i..."; \
  440. X    $(MAKE) $(MFLAGS) DESTDIR='$(DESTDIR)' install.man); \
  441. X    done
  442. X
  443. Xclean::
  444. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  445. X    for i in $(SUBDIRS) ;\
  446. X    do \
  447. X    (cd $$i ; echo "cleaning" "in $(CURRENT_DIR)/$$i..."; \
  448. X    $(MAKE) $(MFLAGS) RM_CMD='$(RM_CMD)' clean); \
  449. X    done
  450. X
  451. Xtags::
  452. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  453. X    for i in $(SUBDIRS) ;\
  454. X    do \
  455. X    (cd $$i ; echo "tagging" "in $(CURRENT_DIR)/$$i..."; \
  456. X    $(MAKE) $(MFLAGS) TAGS='$(TAGS)' tags); \
  457. X    done
  458. X
  459. XMakefiles::
  460. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  461. X    for i in $(SUBDIRS) ;\
  462. X    do \
  463. X    echo "making Makefiles in $(CURRENT_DIR)/$$i..."; \
  464. X    case "$$i" in \
  465. X    ./?*/?*/?*/?*) newtop=../../../../ sub=subsubsubsub;; \
  466. X    ./?*/?*/?*) newtop=../../../ sub=subsubsub;; \
  467. X    ./?*/?*)    newtop=../../ sub=subsub;; \
  468. X    ./?*)       newtop=../ sub=sub;; \
  469. X    */?*/?*/?*)    newtop=../../../../ sub=subsubsubsub;; \
  470. X    */?*/?*)    newtop=../../../ sub=subsubsub;; \
  471. X    */?*)       newtop=../../ sub=subsub;; \
  472. X    *)        newtop=../ sub=sub;; \
  473. X    esac; \
  474. X    case "$(TOP)" in \
  475. X    /?*) newtop=  upprefix=  ;; \
  476. X    *) upprefix=../ ;; \
  477. X    esac; \
  478. X    $(MAKE) $${sub}dirMakefiles UPPREFIX=$$upprefix NEWTOP=$$newtop \
  479. X    MAKEFILE_SUBDIR=$$i NEW_CURRENT_DIR=$(CURRENT_DIR)/$$i;\
  480. X    done
  481. X
  482. XsubdirMakefiles:
  483. X    $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak
  484. X    -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then set -x; \
  485. X    $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \
  486. X    else exit 0; fi
  487. X    cd $(MAKEFILE_SUBDIR); $(IMAKE_CMD) -DTOPDIR=$(UPPREFIX)$(TOP) -DCURDIR=$(NEW_CURRENT_DIR); \
  488. X    $(MAKE) $(MFLAGS) Makefiles
  489. X
  490. XsubsubdirMakefiles:
  491. X    $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak
  492. X    -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then set -x; \
  493. X    $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \
  494. X    else exit 0; fi
  495. X    cd $(MAKEFILE_SUBDIR); $(IMAKE_CMD) -DTOPDIR=$(UPPREFIX)$(UPPREFIX)$(TOP) -DCURDIR=$(NEW_CURRENT_DIR); \
  496. X    $(MAKE) $(MFLAGS) Makefiles
  497. X
  498. XsubsubsubdirMakefiles:
  499. X    $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak
  500. X    -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then set -x; \
  501. X    $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \
  502. X    else exit 0; fi
  503. X    cd $(MAKEFILE_SUBDIR); $(IMAKE_CMD) -DTOPDIR=$(UPPREFIX)$(UPPREFIX)$(UPPREFIX)$(TOP) -DCURDIR=$(NEW_CURRENT_DIR); \
  504. X    $(MAKE) $(MFLAGS) Makefiles
  505. X
  506. XsubsubsubsubdirMakefiles:
  507. X    $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak
  508. X    -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then set -x; \
  509. X    $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \
  510. X    else exit 0; fi
  511. X    cd $(MAKEFILE_SUBDIR); $(IMAKE_CMD) -DTOPDIR=$(UPPREFIX)$(UPPREFIX)$(UPPREFIX)$(UPPREFIX)$(TOP) -DCURDIR=$(NEW_CURRENT_DIR); \
  512. X    $(MAKE) $(MFLAGS) Makefiles
  513. X
  514. Xincludes::
  515. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  516. X    for i in $(SUBDIRS) ;\
  517. X    do \
  518. X    (cd $$i ; echo including "in $(CURRENT_DIR)/$$i..."; \
  519. X    $(MAKE) $(MFLAGS)  includes); \
  520. X    done
  521. X
  522. X# -------------------------------------------------------------------------
  523. X# dependencies generated by makedepend
  524. X
  525. END_OF_FILE
  526. if test 14937 -ne `wc -c <'Makefile.bsdi'`; then
  527.     echo shar: \"'Makefile.bsdi'\" unpacked with wrong size!
  528. fi
  529. # end of 'Makefile.bsdi'
  530. fi
  531. if test -f 'xcal_memo.c' -a "${1}" != "-c" ; then 
  532.   echo shar: Will not clobber existing file \"'xcal_memo.c'\"
  533. else
  534. echo shar: Extracting \"'xcal_memo.c'\" \(15581 characters\)
  535. sed "s/^X//" >'xcal_memo.c' <<'END_OF_FILE'
  536. X#ifndef lint
  537. Xstatic char    *sccsid = "@(#)xcal_memo.c    1.22 (Hillside Systems) 10/29/93";
  538. Xstatic char    *copyright = "@(#)Copyright 1989,1990,1993 Peter Collinson, Hillside Systems";
  539. X#endif                /* lint */
  540. X/***
  541. X
  542. X* module name:
  543. X    xcal_memo.c
  544. X* function:
  545. X    Deal with popup memo file
  546. X    A single popup file is stored in a file called
  547. X    memo on the Calendar directory
  548. X* history:
  549. X    Written December 1990
  550. X    Peter Collinson
  551. X    Hillside Systems
  552. X* (C) Copyright: 1989,1990 Hillside Systems/Peter Collinson
  553. X    
  554. X    For full permissions and copyright notice - see xcal.c
  555. X***/
  556. X#include <stdio.h>
  557. X#include <ctype.h>
  558. X#include <X11/Xos.h>
  559. X#include <X11/Intrinsic.h>
  560. X#include <X11/StringDefs.h>
  561. X#include <X11/Shell.h>
  562. X#include <X11/Xaw/AsciiText.h>
  563. X#include <X11/Xaw/Text.h>
  564. X#include <X11/Xaw/Command.h>
  565. X#include <X11/Xaw/Label.h>
  566. X#include <X11/Xaw/Paned.h>
  567. X#include <X11/Xaw/Form.h>
  568. X#include <X11/Xaw/Dialog.h>
  569. X#include "xcal.h"
  570. X
  571. Xstatic XtCallbackRec callbacks[] = {
  572. X    {NULL, NULL},
  573. X    {NULL, NULL}
  574. X};
  575. X#define ClearCallbacks() memset((caddr_t)callbacks, '\0', sizeof (callbacks))
  576. X#define argLD(N,V) { XtSetArg(args[nargs], N, V); nargs++; }
  577. X
  578. X/*
  579. X * Structure for storing relavant data about the memo Edit
  580. X */
  581. Xtypedef struct memoEdit {
  582. X    Widget          m_button;    /* widget of the control button */
  583. X    Widget          m_popup;    /* widget of editor popup */
  584. X    Widget          m_quit;        /* widget of quit button */
  585. X    Widget        m_edit;        /* widget of edit button */
  586. X    Widget        m_help;        /* widget of help button */
  587. X    Widget          m_save;        /* widget of save button */
  588. X    Boolean         m_savesens;    /* state of the save button */
  589. X    Widget          m_display;    /* widget of display title area */
  590. X    Widget          m_text;        /* the text area */
  591. X    Widget          m_today;    /* today's data */
  592. X    Widget          m_weekly;    /* widget of text image of weekly */
  593. X                    /* events */
  594. X    String        m_weeklytext;    /* weekly text */
  595. X    Cardinal        m_size;        /* size of the buffer */
  596. X    char           *m_data;        /* pointer to malloc'ed data buffer */
  597. X} MemoEdit;
  598. X
  599. Xstatic MemoEdit memo;
  600. X
  601. Xstatic String   memoContents;
  602. X
  603. Xextern void     MemoHelp();        /* look in xcal_help.c */
  604. X
  605. X/*
  606. X * Internal routines
  607. X */
  608. Xvoid            MemoPopup();
  609. Xstatic void     CleanMemo();
  610. Xstatic void     MemoCheckExit();
  611. Xstatic void     MCheckDia();
  612. Xstatic Boolean  WriteMemoFile();
  613. Xstatic void    EditToday();
  614. Xstatic int      NewlineCount();
  615. Xstatic String   GetMemoFile();
  616. Xstatic void     SaveMemoEdits();
  617. Xstatic void     MemoTextChanged();
  618. Xstatic void     FinishMemoEditing();
  619. Xstatic void     YesCheck();
  620. Xstatic void     NoCheck();
  621. Xstatic void    AdjustTitleHeight();
  622. X
  623. X/*
  624. X * Callback routine to display the memo file
  625. X */
  626. X
  627. Xvoid
  628. XDoMemo(w, closure, call_data)
  629. X    Widget          w;
  630. X    caddr_t         closure;
  631. X    caddr_t         call_data;
  632. X{
  633. X    static Arg      args[1];
  634. X
  635. X    /*
  636. X     * Make the button become a finish button
  637. X     */
  638. X    memo.m_button = w;
  639. X    callbacks[0].callback = FinishMemoEditing;
  640. X    callbacks[0].closure = NULL;
  641. X    XtSetArg(args[0], XtNcallback, callbacks);
  642. X    XtSetValues(w, args, 1);
  643. X
  644. X    MouseShow(w, False);
  645. X    /*
  646. X     * Get existing memo contents
  647. X     * if the user is polling then re-read the file
  648. X     */
  649. X    if (appResources.update && memoContents != NULL) {
  650. X        XtFree(memoContents);
  651. X        memoContents = NULL;
  652. X    }
  653. X    if (memoContents == NULL)
  654. X        memoContents = GetMemoFile();
  655. X
  656. X    /*
  657. X     * Set up the popup widget for editing
  658. X     */
  659. X    MemoPopup();
  660. X}
  661. X
  662. X
  663. X/*
  664. X * Get old contents from a memo file if any
  665. X */
  666. Xstatic String
  667. XGetMemoFile()
  668. X{
  669. X
  670. X    if (FoundCalendarDir && access(appResources.memoFile, F_OK) == 0)
  671. X        return ReadCalendarFile(NULL, appResources.memoFile);
  672. X    return NULL;
  673. X}
  674. X
  675. X
  676. X/*
  677. X * Do the biz to popup an edit style window
  678. X */
  679. Xvoid
  680. XMemoPopup()
  681. X{
  682. X    Widget          et, lw;
  683. X    Widget          frame;
  684. X    Arg             args[10];
  685. X    Cardinal        nargs;
  686. X    String          str;
  687. X    MonthEntry     *me;
  688. X    Dimension       charHeight;
  689. X
  690. X    /*
  691. X     * set up edit buffer
  692. X     */
  693. X    if (memoContents)
  694. X        memo.m_size = appResources.textbufsz + strlen(memoContents) + 1;
  695. X    else
  696. X        memo.m_size = appResources.textbufsz;
  697. X    memo.m_data = XtMalloc(memo.m_size);
  698. X
  699. X    if (memoContents)
  700. X        strcpy(memo.m_data, memoContents);
  701. X    else
  702. X        *memo.m_data = '\0';
  703. X    memo.m_popup = XtCreatePopupShell("memo", topLevelShellWidgetClass, toplevel, NULL, 0);
  704. X
  705. X    /*
  706. X     * The first title line
  707. X     */
  708. X    et = XtCreateManagedWidget("memoPanel", panedWidgetClass, memo.m_popup, NULL, 0);
  709. X
  710. X    nargs = 0;
  711. X    argLD(XtNshowGrip, False);
  712. X    argLD(XtNskipAdjust, True);
  713. X    argLD(XtNdefaultDistance, 1);
  714. X    frame = XtCreateManagedWidget("title", formWidgetClass, et, args, nargs);
  715. X    /*
  716. X     * containing some buttons for controlling the world
  717. X     */
  718. X    /*
  719. X     * Take label "quit" from resources
  720. X     */
  721. X    callbacks[0].callback = FinishMemoEditing;
  722. X    callbacks[0].closure = NULL;
  723. X    nargs = 0;
  724. X    argLD(XtNcallback, callbacks);
  725. X    argLD(XtNfromHoriz, NULL);
  726. X    argLD(XtNleft, XtChainLeft);
  727. X    argLD(XtNright, XtChainLeft);
  728. X    lw = memo.m_quit = XtCreateManagedWidget("quit", commandWidgetClass, frame, args, nargs);
  729. X
  730. X    /*
  731. X     * Edit todays file from here as well
  732. X     * Take label from resources
  733. X     */
  734. X    callbacks[0].callback = EditToday;
  735. X    callbacks[0].closure = (caddr_t) 0;
  736. X    nargs = 0;
  737. X    argLD(XtNcallback, callbacks);
  738. X    argLD(XtNfromHoriz, lw);
  739. X    argLD(XtNleft, XtChainLeft);
  740. X    argLD( XtNright, XtChainLeft);
  741. X    memo.m_edit = lw = XtCreateManagedWidget("edit", commandWidgetClass, frame, args, nargs);
  742. X
  743. X    /*
  744. X     * If we are dealing with  help then do it now
  745. X     */
  746. X    if (appResources.giveHelp) {
  747. X        /* Take label "help" from resources */
  748. X        callbacks[0].callback = MemoHelp;
  749. X        callbacks[0].closure = (caddr_t) 0;
  750. X        nargs = 0;
  751. X        argLD(XtNcallback, callbacks);
  752. X        argLD(XtNfromHoriz, lw);
  753. X        argLD(XtNleft, XtChainLeft);
  754. X        argLD( XtNright, XtChainLeft);
  755. X        memo.m_help = lw = XtCreateManagedWidget("help", commandWidgetClass, frame, args, nargs);
  756. X    }
  757. X
  758. X    /*
  759. X     * The remaining bit here is a date label
  760. X     */
  761. X    nargs = 0;
  762. X    argLD(XtNlabel, date_area);
  763. X    argLD(XtNborderWidth, 0);
  764. X    argLD(XtNfromHoriz, lw);
  765. X    argLD(XtNfromVert, NULL);
  766. X    argLD(XtNvertDistance, 2);
  767. X    argLD(XtNleft, XtChainLeft);
  768. X    argLD(XtNright, XtChainRight);
  769. X    lw = memo.m_display = XtCreateManagedWidget("date", labelWidgetClass, frame, args, nargs);
  770. X
  771. X    /*
  772. X     * Details for today
  773. X     */
  774. X    me = GetMonthEntry(today.year, today.month);
  775. X    nargs = 0;
  776. X    str = me->me_have[today.day];
  777. X    if (str == NULL)
  778. X        str = "";
  779. X    argLD(XtNstring, str);
  780. X    argLD(XtNdisplayCaret, False);
  781. X    argLD(XtNeditType, XawtextRead);
  782. X    memo.m_today = XtCreateManagedWidget("display", asciiTextWidgetClass, et, args, nargs);
  783. X    {
  784. X        Dimension       height;
  785. X
  786. X        XtSetArg(args[0], XtNheight, &height);
  787. X        XtGetValues(memo.m_today, args, 1);
  788. X        charHeight = height;
  789. X        height = height * NewlineCount(str);
  790. X        XtSetArg(args[0], XtNheight, height);
  791. X        XtSetValues(memo.m_today, args, 1);
  792. X    }
  793. X
  794. X    AdjustTitleHeight(memo.m_quit, memo.m_edit,
  795. X              appResources.giveHelp ? memo.m_help : NULL,
  796. X              memo.m_display);
  797. X
  798. X    /*
  799. X     * Weekly details - the data for today + an edit button
  800. X     * The header to this is a form
  801. X     */
  802. X    nargs = 0;
  803. X    argLD(XtNshowGrip, False);
  804. X    argLD(XtNskipAdjust, True);
  805. X    argLD(XtNdefaultDistance, 1);
  806. X    frame = XtCreateManagedWidget("weeklyMemo", formWidgetClass, et, args, nargs);
  807. X    /*
  808. X     * Take label "edit" from resources
  809. X     */
  810. X    callbacks[0].callback = DoWeekly;
  811. X    callbacks[0].closure = (caddr_t) & memo;
  812. X    nargs = 0;
  813. X    argLD(XtNcallback, callbacks);
  814. X    argLD(XtNfromHoriz, NULL);
  815. X    argLD(XtNleft, XtChainLeft);
  816. X    argLD(XtNright, XtChainLeft);
  817. X    lw = XtCreateManagedWidget("weeklyEdit", commandWidgetClass, frame, args, nargs);
  818. X
  819. X    /*
  820. X     * Say this is a weekly commitment
  821. X     */
  822. X    nargs = 0;
  823. X    argLD(XtNshowGrip, True);
  824. X    argLD(XtNborderWidth, 0);
  825. X    argLD(XtNfromHoriz, MyCalendar ? lw : NULL);
  826. X    argLD(XtNfromVert, NULL);
  827. X    argLD(XtNvertDistance, 2);
  828. X    argLD(XtNleft, XtChainLeft);
  829. X    argLD(XtNright, XtChainRight);
  830. X    lw = XtCreateManagedWidget("weeklyTitle", labelWidgetClass, frame, args, nargs);
  831. X
  832. X    /*
  833. X     * Details for today
  834. X     */
  835. X    nargs = 0;
  836. X    if (memo.m_weeklytext)
  837. X        XtFree(memo.m_weeklytext);
  838. X    memo.m_weeklytext = str = GetWeeklyFile(today.wday);
  839. X    if (str == NULL)
  840. X        str = "";
  841. X    argLD(XtNstring, str);
  842. X    argLD(XtNdisplayCaret, False);
  843. X    argLD(XtNeditType, XawtextRead);
  844. X    if (charHeight)
  845. X        argLD(XtNheight, NewlineCount(str) * charHeight);
  846. X    memo.m_weekly = XtCreateManagedWidget("display", asciiTextWidgetClass, et, args, nargs);
  847. X    /*
  848. X     * Another form with some buttons
  849. X     */
  850. X    nargs = 0;
  851. X    argLD(XtNshowGrip, False);
  852. X    argLD(XtNskipAdjust, True);
  853. X    argLD(XtNdefaultDistance, 1);
  854. X    frame = XtCreateManagedWidget("memoMiddle", formWidgetClass, et, args, nargs);
  855. X    if (MyCalendar) {
  856. X        /*
  857. X         * Take label "save" from resources
  858. X         */
  859. X        callbacks[0].callback = SaveMemoEdits;
  860. X        callbacks[0].closure = (caddr_t) & memo;
  861. X        nargs = 0;
  862. X        argLD(XtNcallback, callbacks);
  863. X        argLD(XtNfromHoriz, NULL);
  864. X        argLD(XtNleft, XtChainLeft);
  865. X        argLD(XtNright, XtChainLeft);
  866. X        argLD(XtNsensitive, False);
  867. X        lw = memo.m_save = XtCreateManagedWidget("save", commandWidgetClass, frame, args, nargs);
  868. X        memo.m_savesens = False;
  869. X    }
  870. X    /*
  871. X     * Say this is a memo edit
  872. X     */
  873. X    nargs = 0;
  874. X    argLD(XtNshowGrip, True);
  875. X    argLD(XtNborderWidth, 0);
  876. X    argLD(XtNfromHoriz, MyCalendar ? lw : NULL);
  877. X    argLD(XtNfromVert, NULL);
  878. X    argLD(XtNvertDistance, 2);
  879. X    argLD(XtNleft, XtChainLeft);
  880. X    argLD(XtNright, XtChainRight);
  881. X    lw = XtCreateManagedWidget("memoTitle", labelWidgetClass, frame, args, nargs);
  882. X
  883. X    /*
  884. X     * The text widget is in the pane below
  885. X     * The Scroll Attributes are controlled from the application
  886. X     * defaults file
  887. X     */
  888. X    callbacks[0].callback = MemoTextChanged;
  889. X    callbacks[0].closure = (caddr_t) & memo;
  890. X    nargs = 0;
  891. X    argLD(XtNstring, memo.m_data);
  892. X    argLD(XtNeditType, XawtextEdit);
  893. X    argLD(XtNlength, memo.m_size);
  894. X    argLD(XtNuseStringInPlace, True);
  895. X    argLD(XtNcallback, callbacks);
  896. X    memo.m_text = XtCreateManagedWidget("memoText", asciiTextWidgetClass, et, args, nargs);
  897. X
  898. X
  899. X    XtPopup(memo.m_popup, XtGrabNone);
  900. X
  901. X}
  902. X
  903. X/*
  904. X * Adjust title line height
  905. X * possibly 4 objects
  906. X */
  907. Xstatic void
  908. XAdjustTitleHeight(quit, edit, help, label)
  909. X    Widget        quit;
  910. X    Widget        edit;
  911. X    Widget        help;
  912. X    Widget        label;
  913. X{
  914. X    int        hq, he, hh, hl;
  915. X    int        max;
  916. X
  917. X    hq = wHeight(quit);
  918. X    he = wHeight(edit);
  919. X    hh = help ? wHeight(help): 0;
  920. X    hl = wHeight(label);
  921. X
  922. X    max = hq;
  923. X    max = (he > max) ? he : max;
  924. X    max = (hh > max) ? hh : max;
  925. X    max = (hl > max) ? hl : max;
  926. X
  927. X    if (hq < max)
  928. X        SetWidgetHeightMax(quit, hq, max);
  929. X    if (he < max)
  930. X        SetWidgetHeightMax(edit, he, max);
  931. X    if (hh & hh < max)
  932. X        SetWidgetHeightMax(help, hh, max);
  933. X    if (hl < max)
  934. X        SetWidgetHeightMax(label, hl, max);
  935. X}
  936. X
  937. X/*
  938. X * This callback starts editing today
  939. X */
  940. Xstatic void
  941. XEditToday(w, closure, call_data)
  942. X    Widget        w;
  943. X    caddr_t         closure;
  944. X    caddr_t         call_data;
  945. X{    
  946. X
  947. X    StartEditing(w, &today, w);
  948. X}
  949. X
  950. X/*
  951. X * Count newlines in a string
  952. X */
  953. Xstatic int
  954. XNewlineCount(str)
  955. X    String          str;
  956. X{
  957. X    register int    sum = 0;
  958. X
  959. X    while (*str)
  960. X        if (*str++ == '\n')
  961. X            sum++;
  962. X    /* Add one line - assume last line does NOT have an nl */
  963. X    sum++;
  964. X    /* ignore a final newline */
  965. X    if (str[-1] == '\n')
  966. X        sum--;
  967. X    if (sum <= 0)
  968. X        sum = 1;
  969. X    return (sum > appResources.maxDisplayLines ? appResources.maxDisplayLines : sum);
  970. X}
  971. X
  972. X/*
  973. X * Entry point from outside when today's text changed
  974. X */
  975. Xvoid
  976. XUpdateMemo()
  977. X{
  978. X    Arg             args[1];
  979. X    String          str;
  980. X    MonthEntry     *me;
  981. X
  982. X    /*
  983. X     * if the button widget is zero then we are displaying nothing
  984. X     */
  985. X    if (memo.m_button == 0)
  986. X        return;
  987. X
  988. X    me = GetMonthEntry(today.year, today.month);
  989. X    str = me->me_have[today.day];
  990. X    if (str == NULL)
  991. X        str = "";
  992. X    XtSetArg(args[0], XtNstring, str);
  993. X    XtSetValues(memo.m_today, args, 1);
  994. X
  995. X    XtSetArg(args[0], XtNlabel, date_area);
  996. X    XtSetValues(memo.m_display, args, 1);
  997. X
  998. X    if (memo.m_weeklytext)
  999. X        XtFree(memo.m_weeklytext);
  1000. X    memo.m_weeklytext = str = GetWeeklyFile(today.wday);
  1001. X    if (str == NULL)
  1002. X        str = "";
  1003. X    XtSetArg(args[0], XtNstring, str);
  1004. X    XtSetValues(memo.m_weekly, args, 1);
  1005. X
  1006. X}
  1007. X
  1008. X/*
  1009. X * Poll call from the alarm timeout
  1010. X */
  1011. Xvoid
  1012. XMemoPoll()
  1013. X{
  1014. X    int             size;
  1015. X    Arg             args[10];
  1016. X    int             nargs;
  1017. X
  1018. X    if (memo.m_button == 0)
  1019. X        return;
  1020. X    if (memo.m_savesens == True)
  1021. X        return;
  1022. X
  1023. X    if (memoContents)
  1024. X        XtFree(memoContents);
  1025. X    memoContents = GetMemoFile();
  1026. X    if (memoContents) {
  1027. X        if (strcmp(memoContents, memo.m_data) == 0)
  1028. X            return;
  1029. X        size = strlen(memoContents) + 1;
  1030. X        if (size > memo.m_size) {
  1031. X            size += appResources.textbufsz;
  1032. X            XtFree(memo.m_data);
  1033. X            memo.m_data = XtMalloc(memo.m_size = size);
  1034. X        }
  1035. X        strcpy(memo.m_data, memoContents);
  1036. X    } else
  1037. X        *memo.m_data = '\0';
  1038. X
  1039. X    nargs = 0;
  1040. X    argLD(XtNstring, memo.m_data);
  1041. X    argLD(XtNlength, memo.m_size);
  1042. X    argLD(XtNuseStringInPlace, True);
  1043. X    XtSetValues(memo.m_text, args, nargs);
  1044. X}
  1045. X
  1046. X/*
  1047. X * Call backs for various buttons
  1048. X */
  1049. X/* ARGSUSED */
  1050. Xstatic void
  1051. XMemoTextChanged(w, closure, call_data)
  1052. X    Widget          w;
  1053. X    caddr_t         closure;
  1054. X    caddr_t         call_data;
  1055. X{
  1056. X    register MemoEdit *memo = (MemoEdit *) closure;
  1057. X
  1058. X    if (MyCalendar) {
  1059. X        memo->m_savesens = True;
  1060. X        XtSetSensitive(memo->m_save, True);
  1061. X    }
  1062. X}
  1063. X
  1064. X/*
  1065. X * Callback routines
  1066. X */
  1067. X/* ARGSUSED */
  1068. Xstatic void
  1069. XSaveMemoEdits(w, closure, call_data)
  1070. X    Widget          w;
  1071. X    caddr_t         closure;
  1072. X    caddr_t         call_data;
  1073. X{
  1074. X    MemoEdit       *memo = (MemoEdit *) closure;
  1075. X
  1076. X    if (WriteMemoFile(memo) == False)
  1077. X        return;
  1078. X    if (memoContents) {
  1079. X        XtFree(memoContents);
  1080. X        memoContents = XtNewString(memo->m_data);
  1081. X    }
  1082. X    memo->m_savesens = False;
  1083. X    XtSetSensitive(memo->m_save, False);
  1084. X}
  1085. X
  1086. X/*
  1087. X * Write the memo file out
  1088. X */
  1089. Xstatic          Boolean
  1090. XWriteMemoFile(memo)
  1091. X    MemoEdit       *memo;
  1092. X{
  1093. X    Cardinal        len = strlen(memo->m_data);
  1094. X    String          fname;
  1095. X    int             fd;
  1096. X
  1097. X    if (len == 0) {
  1098. X        unlink(appResources.memoFile);
  1099. X        return (True);
  1100. X    }
  1101. X    /*
  1102. X     * First let's see if we have to create the toplevel directory
  1103. X     */
  1104. X    if (!NeedTop())
  1105. X        return (False);
  1106. X
  1107. X    fname = appResources.memoFile;
  1108. X
  1109. X    if ((fd = open(fname, O_WRONLY | O_TRUNC | O_CREAT, 0666)) < 0) {
  1110. X        XBell(XtDisplay(toplevel), 0);
  1111. X        fprintf(stderr, "xcal: Could not open %s/%s for writing.\n", MapStem, fname);
  1112. X        perror("xcal: open");
  1113. X        fflush(stderr);
  1114. X        return (False);
  1115. X    }
  1116. X    if (write(fd, memo->m_data, len) != len) {
  1117. X        XBell(XtDisplay(toplevel), 0);
  1118. X        fprintf(stderr, "xcal: Write error %s/%s file.\n", MapStem, fname);
  1119. X        perror("xcal: write");
  1120. X        fflush(stderr);
  1121. X        close(fd);
  1122. X        return (False);
  1123. X    }
  1124. X    close(fd);
  1125. X    return (True);
  1126. X}
  1127. X
  1128. Xstatic void
  1129. XFinishMemoEditing(w, closure, call_data)
  1130. X    Widget          w;
  1131. X    caddr_t         closure;
  1132. X    caddr_t         call_data;
  1133. X{
  1134. X
  1135. X    if (memo.m_savesens == True)
  1136. X        MemoCheckExit();
  1137. X    else
  1138. X        CleanMemo();
  1139. X}
  1140. X
  1141. Xstatic void
  1142. XCleanMemo()
  1143. X{
  1144. X    static Arg      args[1];
  1145. X    static MemoEdit    zerom;
  1146. X
  1147. X    callbacks[0].callback = DoMemo;
  1148. X    callbacks[0].closure = NULL;
  1149. X    XtSetArg(args[0], XtNcallback, callbacks);
  1150. X    XtSetValues(memo.m_button, args, 1);
  1151. X    XtSetSensitive(memo.m_button, True);
  1152. X
  1153. X    MouseShow(memo.m_button, True);
  1154. X    XtPopdown(memo.m_popup);
  1155. X    XtDestroyWidget(memo.m_popup);
  1156. X    XtFree(memo.m_data);
  1157. X    XtFree(memo.m_weeklytext);
  1158. X    memo = zerom;
  1159. X}
  1160. X
  1161. Xstatic void
  1162. XMemoCheckExit()
  1163. X{
  1164. X    DialogPopup(memo.m_quit, MCheckDia, &memo, NULL);
  1165. X}
  1166. X
  1167. Xstatic void
  1168. XMCheckDia(pop, ed)
  1169. X    Widget          pop;
  1170. X    MemoEdit       *ed;
  1171. X{
  1172. X    Widget          dia;
  1173. X
  1174. X    XtSetSensitive(memo.m_quit, False);
  1175. X    XtSetSensitive(memo.m_button, False);
  1176. X    XtSetSensitive(memo.m_save, False);
  1177. X
  1178. X    /* Take "Save file?" from resources */
  1179. X    dia = XtCreateManagedWidget("memocheck", dialogWidgetClass, pop, NULL, 0);
  1180. X    XawDialogAddButton(dia, "yes", YesCheck, ed);
  1181. X    XawDialogAddButton(dia, "no", NoCheck, ed);
  1182. X}
  1183. X
  1184. X/* ARGSUSED */
  1185. Xstatic void
  1186. XYesCheck(w, closure, call_data)
  1187. X    Widget          w;
  1188. X    caddr_t         closure;
  1189. X    caddr_t         call_data;
  1190. X{
  1191. X    SaveMemoEdits(w, closure, call_data);
  1192. X    CleanMemo();
  1193. X
  1194. X    XtDestroyWidget(XtParent(XtParent(w)));
  1195. X}
  1196. X
  1197. X/* ARGSUSED */
  1198. Xstatic void
  1199. XNoCheck(w, closure, call_data)
  1200. X    Widget          w;
  1201. X    caddr_t         closure;
  1202. X    caddr_t         call_data;
  1203. X{
  1204. X    CleanMemo();
  1205. X        XtDestroyWidget(XtParent(XtParent(w)));
  1206. X}
  1207. X
  1208. END_OF_FILE
  1209. if test 15581 -ne `wc -c <'xcal_memo.c'`; then
  1210.     echo shar: \"'xcal_memo.c'\" unpacked with wrong size!
  1211. fi
  1212. # end of 'xcal_memo.c'
  1213. fi
  1214. if test -f 'xcal_strip.c' -a "${1}" != "-c" ; then 
  1215.   echo shar: Will not clobber existing file \"'xcal_strip.c'\"
  1216. else
  1217. echo shar: Extracting \"'xcal_strip.c'\" \(18555 characters\)
  1218. sed "s/^X//" >'xcal_strip.c' <<'END_OF_FILE'
  1219. X#ifndef lint
  1220. Xstatic char    *sccsid = "@(#)xcal_strip.c    3.27 (Hillside Systems) 11/1/93";
  1221. Xstatic char    *copyright = "@(#)Copyright 1989,1990,1993 Peter Collinson, Hillside Systems";
  1222. X#endif                /* lint */
  1223. X/***
  1224. X
  1225. X* module name:
  1226. X    xcal_strip.c
  1227. X* function:
  1228. X    Deal with the popup strip calendars obtained either by
  1229. X    selection and the middle button, or by the < and > buttons
  1230. X    on each strip.
  1231. X* history:
  1232. X    Written November 1989
  1233. X    Peter Collinson
  1234. X    Hillside Systems
  1235. X* (C) Copyright: 1989 Hillside Systems/Peter Collinson
  1236. X    
  1237. X    For full permissions and copyright notice - see xcal.c
  1238. X***/
  1239. X#include <stdio.h>
  1240. X#include <ctype.h>
  1241. X#include <X11/Intrinsic.h>
  1242. X#include <X11/Xatom.h>
  1243. X#include <X11/StringDefs.h>
  1244. X#include <X11/Shell.h>
  1245. X#include <X11/Xaw/Paned.h>
  1246. X#include <X11/Xaw/Viewport.h>
  1247. X#include <X11/Xaw/Command.h>
  1248. X#include <X11/Xaw/Label.h>
  1249. X#include <X11/Xaw/Dialog.h>
  1250. X#include <X11/Xaw/AsciiText.h>
  1251. X#include "xcal.h"
  1252. X
  1253. Xstatic XtCallbackRec callbacks[] = {
  1254. X    {NULL, NULL},
  1255. X    {NULL, NULL},
  1256. X    {NULL, NULL},
  1257. X    {NULL, NULL}
  1258. X};
  1259. X#define ClearCallbacks() memset((caddr_t)callbacks, '\0', sizeof (callbacks))
  1260. X
  1261. XDate            callb;        /* contains date when calendar day button */
  1262. X                /* pressed */
  1263. X
  1264. Xstatic String   defTranslations =
  1265. X"<Btn2Down>: set()\n\
  1266. X    <Btn2Up>: LoadDateAction() unset()";
  1267. X
  1268. X/*
  1269. X *    These translations used to make the middle mouse button
  1270. X *    load a date file from a selection when clicked on a strip
  1271. X */
  1272. X
  1273. X/*
  1274. X * Forward routines local to this file
  1275. X */
  1276. Xstatic void     MakeMonth();
  1277. Xstatic void     DayBack();
  1278. X#ifndef LONG_IS_32_BITS
  1279. Xstatic void     YmBack();
  1280. X#endif
  1281. Xstatic void     StripQuit();
  1282. Xvoid            StripHelp();
  1283. Xvoid            WeeklyHelp();
  1284. X
  1285. X/*
  1286. X * Local routines
  1287. X */
  1288. Xstatic void     MakeNewMonth();
  1289. Xstatic void    LoadDateCallback();
  1290. Xstatic Cardinal DateSum();
  1291. Xstatic void    setStripMax();
  1292. Xstatic Dimension CreateActionBar();
  1293. Xstatic Dimension CreateWeeklyActionBar();
  1294. X
  1295. X#define argLD(N,V) { XtSetArg(args[nargs], N, V); nargs++; }
  1296. X
  1297. X/*
  1298. X * Start a strip calendar happening a callback of left button
  1299. X */
  1300. X/* ARGSUSED */
  1301. Xvoid
  1302. XDoCalendar(w, closure, call_data)
  1303. X    Widget          w;
  1304. X    caddr_t         closure;
  1305. X    caddr_t         call_data;
  1306. X{
  1307. X    NewMonthStrip(&today, NULL);    /* today is global */
  1308. X}
  1309. X
  1310. X/* ARGSUSED */
  1311. Xvoid
  1312. XDoWeekly(w, closure, call_data)
  1313. X    Widget          w;
  1314. X    caddr_t         closure;
  1315. X    caddr_t         call_data;
  1316. X{
  1317. X    Date            thisday;
  1318. X
  1319. X    thisday.day = 0;
  1320. X    thisday.month = 0;
  1321. X    thisday.year = 0;
  1322. X    thisday.wday = 0;
  1323. X    NewMonthStrip(&thisday, w);/* today is global */
  1324. X}
  1325. X
  1326. X
  1327. X/*
  1328. X * Start a strip calendar happening a callback of the > or < buttons in
  1329. X * another strip
  1330. X */
  1331. X/* ARGSUSED */
  1332. Xstatic void
  1333. XMakeNewMonth(w, closure, call_data)
  1334. X    Widget          w;
  1335. X    caddr_t         closure;
  1336. X    caddr_t         call_data;
  1337. X{
  1338. X    Date            thisday;
  1339. X
  1340. X    thisday.year = YrUnpack((Cardinal) closure);
  1341. X    thisday.month = MoUnpack((Cardinal) closure);
  1342. X    thisday.day = today.day;
  1343. X    NewMonthStrip(&thisday, NULL);
  1344. X}
  1345. X
  1346. X/* 
  1347. X *    Do all the X stuff to popup a Strip calendar
  1348. X *    A calendar strip is:
  1349. X *
  1350. X *    Popup ("<month year>")        // Name is the month and the year
  1351. X *     Paned ("<month>")        // Name is the month
  1352. X *       Label ("header")        // optional contains Month Year
  1353. X *     Form ("action")        // < Quit >
  1354. X *        Command ("back")    // contains < 
  1355. X *        Label ("quit")        // contains Quit
  1356. X *        Command ("next")    // contains >
  1357. X *     ViewPort ("viewport")        // Viewport containing strip data
  1358. X *            Paned ("data")        // Panel containing the calendar data
  1359. X *            (Then many of..)
  1360. X *            Form ("<dd DDD>")    // where DDD is the day of the week
  1361. X *            Label ("label")    // contains the string above
  1362. X *            Command ("info")    // contains the text from the file
  1363. X *        
  1364. X */
  1365. Xvoid
  1366. XNewMonthStrip(td, but)
  1367. X    Date           *td;
  1368. X    Widget        but;
  1369. X{
  1370. X    Widget          shell, mon, dw, lw, lwi, form, monvp, mondt;
  1371. X    Arg             args[15];
  1372. X    char            titlestr[256];
  1373. X    char        tbuf[256];
  1374. X    char            iconName[256];
  1375. X    int             type;
  1376. X    MonthEntry     *me;
  1377. X    Instance       *ins;
  1378. X    register int    i;
  1379. X    register Cardinal nargs;
  1380. X    Cardinal        thisDay;
  1381. X    Cardinal        startLoop;
  1382. X    String          dayStr;
  1383. X    Cardinal        numberOfDays;
  1384. X    Boolean         defaultsAreSet = False;
  1385. X    Boolean         markThisMonth = False;
  1386. X    Dimension       labelH, infoH;
  1387. X    Dimension       width;
  1388. X    Dimension    totalHeight;
  1389. X    Dimension    hdrHeight;
  1390. X    Dimension       totalWidth;
  1391. X    static        XtTranslations but2;
  1392. X
  1393. X    type = (td->day == 0) ? ME_WEEKLY : ME_MONTHLY;
  1394. X    hdrHeight = 0;
  1395. X
  1396. X    /*
  1397. X     * There are lots of differences between Months and weekly strips
  1398. X     * here. Later tests are done using a switch structure
  1399. X     */
  1400. X    switch (type) {
  1401. X    case ME_MONTHLY:
  1402. X        FmtDate(td, iconName, sizeof iconName, appResources.stripfmt);
  1403. X        XtSetArg(args[0], XtNiconName, iconName);
  1404. X        shell = XtCreatePopupShell(XtNewString(iconName), topLevelShellWidgetClass, toplevel, args, 1);
  1405. X        ins = RegisterMonth(td->year, td->month, shell);
  1406. X        mon = XtCreateManagedWidget(appResources.mon[td->month], panedWidgetClass, shell, NULL, 0);
  1407. X        thisDay = FirstDay(td->month, td->year);
  1408. X        numberOfDays = NumberOfDays(td->month, td->year);
  1409. X        startLoop = 1;
  1410. X        /*
  1411. X         * Get the map for this year
  1412. X         */
  1413. X        me = GetMonthEntry(td->year, td->month);
  1414. X        /*
  1415. X         * Title bar is month and date
  1416. X         */
  1417. X        FmtDate(td, titlestr, sizeof titlestr, appResources.stripfmt);
  1418. X        /*
  1419. X         * see if we will need to worry about marking today's entry
  1420. X         */
  1421. X        if (appResources.markToday && td->year == today.year && td->month == today.month)
  1422. X            markThisMonth = True;
  1423. X        break;
  1424. X    case ME_WEEKLY:
  1425. X        (void) strcpy(iconName, appResources.weekly);
  1426. X        nargs = 0;
  1427. X        argLD(XtNiconName, iconName);
  1428. X        shell = XtCreatePopupShell(XtNewString(iconName), topLevelShellWidgetClass, toplevel, args, nargs);
  1429. X        if (but && XtIsSubclass(but, commandWidgetClass))
  1430. X            ButtonOff(but, shell);
  1431. X        ins = RegisterMonth(0, 0, shell);
  1432. X        mon = XtCreateManagedWidget(iconName, panedWidgetClass, shell, NULL, 0);
  1433. X        thisDay = 0;
  1434. X        numberOfDays = 6;    /* test is <= */
  1435. X        startLoop = 0;
  1436. X        /*
  1437. X         * Get the map for this year
  1438. X         */
  1439. X        me = GetWeeklyEntry();
  1440. X        /*
  1441. X         * Title bar is from the resources
  1442. X         */
  1443. X        strcpy(titlestr, iconName);
  1444. X        /*
  1445. X         * see if we will need to worry about marking today's entry
  1446. X         */
  1447. X        if (appResources.markToday)
  1448. X            markThisMonth = True;
  1449. X        break;
  1450. X    }
  1451. X    /*
  1452. X     * Find size of title bar by creating the widget and then throwing it
  1453. X     * away
  1454. X     */
  1455. X    DoTemplate(tbuf, sizeof tbuf, appResources.stripfmt);
  1456. X    XtSetArg(args[0], XtNlabel, tbuf);
  1457. X    lw = XtCreateManagedWidget("sizer", labelWidgetClass, shell, args, 1);
  1458. X    XtSetArg(args[0], XtNwidth, &totalWidth);
  1459. X    XtGetValues(lw, args, 1);
  1460. X    XtDestroyWidget(lw);
  1461. X    /*
  1462. X     * Width is affected by a resource value
  1463. X     */
  1464. X    if (appResources.minstripwidth && appResources.minstripwidth > totalWidth)
  1465. X        totalWidth = appResources.minstripwidth;
  1466. X    /*
  1467. X     * Now set the title bar should we need it
  1468. X     */
  1469. X    if (appResources.useWmTitle) {
  1470. X        XtSetArg(args[0], XtNlabel, XtNewString(titlestr));
  1471. X        lw =  XtCreateManagedWidget("header", labelWidgetClass, mon, args, 1);
  1472. X        hdrHeight = wHeight(lw);
  1473. X    }
  1474. X    /*
  1475. X     * Action bar
  1476. X     */
  1477. X    nargs = 0;
  1478. X    argLD(XtNshowGrip, False);
  1479. X    argLD(XtNdefaultDistance, 2);
  1480. X    dw = XtCreateManagedWidget("action", formWidgetClass, mon, args, nargs);
  1481. X
  1482. X    switch (type) {
  1483. X    case ME_MONTHLY:
  1484. X        hdrHeight += CreateActionBar(shell, dw, mon, td);
  1485. X        break;
  1486. X    case ME_WEEKLY:
  1487. X        hdrHeight += CreateWeeklyActionBar(shell, dw);
  1488. X        break;
  1489. X    }
  1490. X    
  1491. X    /*
  1492. X     * Create a Viewport, with a panel inside it
  1493. X     */
  1494. X    nargs = 0;
  1495. X    argLD(XtNshowGrip, False);
  1496. X    argLD(XtNallowVert, True);
  1497. X    monvp = XtCreateManagedWidget("viewport", viewportWidgetClass, mon, args, nargs);
  1498. X    mondt = XtCreateManagedWidget("panel", panedWidgetClass, monvp, NULL, 0);
  1499. X
  1500. X
  1501. X#ifdef    LONG_IS_32_BITS
  1502. X    callbacks[0].callback = DayBack;
  1503. X#else
  1504. X    callbacks[0].callback = YmBack;
  1505. X    callbacks[1].callback = DayBack;
  1506. X#endif
  1507. X    totalHeight = 0;
  1508. X    for (i = startLoop; i <= numberOfDays; i++) {
  1509. X        dayStr = appResources.sday[thisDay];
  1510. X        switch (type) {
  1511. X        case ME_MONTHLY:
  1512. X            (void) sprintf(titlestr, "%2d %s", i, dayStr);
  1513. X            break;
  1514. X        case ME_WEEKLY:
  1515. X            (void) strcpy(titlestr, dayStr);
  1516. X            break;
  1517. X        }
  1518. X#ifdef LONG_IS_32_BITS
  1519. X        callbacks[0].closure = (caddr_t) DatePack(thisDay, i, td->month, td->year);
  1520. X#else
  1521. X        callbacks[0].closure = (caddr_t) DatePack(td->month, td->year);
  1522. X        callbacks[1].closure = (caddr_t) DayPack(thisDay, i);
  1523. X#endif
  1524. X
  1525. X        thisDay = (thisDay + 1) % 7;
  1526. X
  1527. X        /*
  1528. X         * Each line in the strip is form containing label - command
  1529. X         */
  1530. X        nargs = 0;
  1531. X        argLD(XtNshowGrip, False);
  1532. X        argLD(XtNdefaultDistance, 0);
  1533. X        form = XtCreateManagedWidget(dayStr, formWidgetClass, mondt, args, nargs);
  1534. X
  1535. X        nargs = 0;
  1536. X        argLD(XtNlabel, XtNewString(titlestr));
  1537. X        /* a little naughty here */
  1538. X        /* this string memory is lost */
  1539. X        /* on quit */
  1540. X        argLD(XtNborderWidth, 0);
  1541. X        argLD(XtNjustify, XtJustifyLeft);
  1542. X        argLD(XtNfromHoriz, NULL);
  1543. X        argLD(XtNleft, XtChainLeft);
  1544. X        argLD(XtNright, XtChainLeft);
  1545. X
  1546. X        ins->i_day_label[i] = lw = XtCreateManagedWidget("label", labelWidgetClass, form, args, nargs);
  1547. X
  1548. X        /*
  1549. X         * To get a handle on the old values which are lost by
  1550. X         * highlighting we get them after we have created the widget.
  1551. X         * Then we highlight today.
  1552. X         */
  1553. X        if (markThisMonth &&
  1554. X            ((type == ME_MONTHLY && today.day == i) ||
  1555. X             (type == ME_WEEKLY && today.wday == i))) {
  1556. X            nargs = 0;
  1557. X            argLD(XtNforeground, &ins->i_col.fg);
  1558. X            argLD(XtNbackground, &ins->i_col.bg);
  1559. X            argLD(XtNfont, &ins->i_font);
  1560. X            XtGetValues(lw, args, nargs);
  1561. X
  1562. X            nargs = 0;
  1563. X            argLD(XtNforeground, appResources.today.fg);
  1564. X            argLD(XtNbackground, appResources.today.bg);
  1565. X            argLD(XtNfont, appResources.fontToday);
  1566. X            XtSetValues(lw, args, nargs);
  1567. X        }
  1568. X        /*
  1569. X         * Done the first time through
  1570. X         * Gets the width of the line we have just made
  1571. X         */
  1572. X        if (defaultsAreSet == False) {    /* compute text width */
  1573. X            nargs = 0;
  1574. X            argLD(XtNwidth, &width);
  1575. X            argLD(XtNheight, &labelH);
  1576. X            XtGetValues(lw, args, nargs);
  1577. X            defaultsAreSet = True;
  1578. X        }
  1579. X        /*
  1580. X         * Start processing the RHS of the line
  1581. X         * This contains text from the file should any exist
  1582. X         */
  1583. X        nargs = 0;
  1584. X        argLD(XtNborderWidth, 0);
  1585. X        argLD(XtNcallback, callbacks);
  1586. X        argLD(XtNfromHoriz, lw);
  1587. X        argLD(XtNleft, XtChainLeft);
  1588. X        argLD(XtNright, XtChainRight);
  1589. X        argLD(XtNjustify, XtJustifyLeft);
  1590. X        argLD(XtNwidth, totalWidth - width);
  1591. X
  1592. X        if (me->me_have[i]) {
  1593. X            argLD(XtNlabel, me->me_have[i]);
  1594. X        } else {
  1595. X            argLD(XtNlabel, "    ");
  1596. X        }
  1597. X        ins->i_day_info[i] = lwi = XtCreateManagedWidget("info", commandWidgetClass, form, args, nargs);
  1598. X
  1599. X        /* add translations */
  1600. X        if (but2 == NULL) {
  1601. X            but2 = XtParseTranslationTable(defTranslations);
  1602. X        }
  1603. X        XtAugmentTranslations(lwi, but2);
  1604. X
  1605. X        /* deal with height */
  1606. X        infoH = wHeight(lwi);
  1607. X        if (labelH < infoH) {
  1608. X            SetWidgetHeightMax(lw, labelH, infoH);
  1609. X            totalHeight += infoH + 1;
  1610. X        } else if (labelH > infoH) {
  1611. X            SetWidgetHeightMax(lwi, infoH, labelH);
  1612. X            totalHeight += labelH + 1;
  1613. X        }
  1614. X        /*
  1615. X         * cope with 1752
  1616. X         */
  1617. X        if (td->year == 1752 && td->month == 8 && i == 2) {
  1618. X            i = 13;
  1619. X            numberOfDays += 11;    /* giving back the 11 days */
  1620. X        }
  1621. X    }
  1622. X    ClearCallbacks();
  1623. X
  1624. X    /* set up size for viewport scrolling */
  1625. X    setStripMax(monvp, totalHeight, hdrHeight);
  1626. X
  1627. X    /* here we go */
  1628. X    XtPopup(shell, XtGrabNone);
  1629. X}
  1630. X
  1631. X/*
  1632. X * Get the height of the specified widget
  1633. X */
  1634. XDimension
  1635. XwHeight(w)
  1636. X    Widget    w;
  1637. X{
  1638. X    Arg        args[1];
  1639. X    Dimension    H;
  1640. X
  1641. X    XtSetArg(args[0], XtNheight, &H);
  1642. X    XtGetValues(w, args, 1);
  1643. X    return H;
  1644. X}
  1645. X
  1646. X/*
  1647. X * Set the max size of the viewport for the strip
  1648. X */
  1649. Xstatic void
  1650. XsetStripMax(w, stripHeight, hdrHeight)
  1651. X    Widget    w;
  1652. X    Dimension stripHeight;
  1653. X    Dimension hdrHeight;
  1654. X{
  1655. X    Dimension    maxH;
  1656. X    Arg             args[1];
  1657. X
  1658. X    if (appResources.maxstripheight == 0) {
  1659. X        /* remove the hdrHeight here as a guess */
  1660. X        maxH = HeightOfScreen(XtScreen(toplevel));
  1661. X        maxH -= hdrHeight;
  1662. X    }    
  1663. X    else    maxH = appResources.maxstripheight;
  1664. X    maxH -= hdrHeight + 20;
  1665. X    if (stripHeight > maxH) {
  1666. X        XtSetArg(args[0], XtNheight, maxH);
  1667. X        XtSetValues(w, args, 1);
  1668. X    }
  1669. X}
  1670. X/*
  1671. X * Create action bar for normal monthly strip
  1672. X */
  1673. Xstatic Dimension
  1674. XCreateActionBar(shell, dw, mon, td)
  1675. X    Widget          shell;
  1676. X    Widget          dw;
  1677. X    Widget          mon;
  1678. X    Date           *td;
  1679. X{
  1680. X    Widget          lw;
  1681. X    register Cardinal nargs;
  1682. X    Arg             args[8];
  1683. X    Dimension    ht, maxht = 0;
  1684. X
  1685. X    /*
  1686. X     * back one month label "<" from resources
  1687. X     */
  1688. X    callbacks[0].callback = MakeNewMonth;
  1689. X    callbacks[0].closure = (caddr_t) DateSum(td, -1);
  1690. X    nargs = 0;
  1691. X    argLD(XtNcallback, callbacks);
  1692. X    argLD(XtNfromHoriz, NULL);
  1693. X    argLD(XtNleft, XtChainLeft);
  1694. X    argLD(XtNright, XtChainLeft);
  1695. X    lw = XtCreateManagedWidget("back", commandWidgetClass, dw, args, nargs);
  1696. X    maxht = wHeight(lw);
  1697. X    maxht++;
  1698. X    ClearCallbacks();
  1699. X
  1700. X    /*
  1701. X     * Quit button label "quit" from resources
  1702. X     */
  1703. X    callbacks[0].callback = StripQuit;
  1704. X    callbacks[0].closure = (caddr_t) shell;
  1705. X    nargs = 0;
  1706. X    argLD(XtNcallback, callbacks);
  1707. X    argLD(XtNfromHoriz, lw);
  1708. X    argLD(XtNleft, XtChainLeft);
  1709. X    argLD(XtNright, XtChainRight);
  1710. X    lw = XtCreateManagedWidget("quit", commandWidgetClass, dw, args, nargs);
  1711. X    ht = wHeight(lw);
  1712. X    maxht = ht > maxht ? ht : maxht;
  1713. X    ClearCallbacks();
  1714. X
  1715. X    /*
  1716. X     * On one month label ">" from resources
  1717. X     */
  1718. X    callbacks[0].callback = MakeNewMonth;
  1719. X    callbacks[0].closure = (caddr_t) DateSum(td, 1);
  1720. X    nargs = 0;
  1721. X    argLD(XtNcallback, callbacks);
  1722. X    argLD(XtNfromHoriz, lw);
  1723. X    argLD(XtNleft, XtChainRight);
  1724. X    argLD(XtNright, XtChainRight);
  1725. X    lw = XtCreateManagedWidget("next", commandWidgetClass, dw, args, nargs);
  1726. X    ht = wHeight(lw);
  1727. X    maxht = ht > maxht ? ht : maxht;
  1728. X    ClearCallbacks();
  1729. X
  1730. X    /*
  1731. X     * Help button label help from resources
  1732. X     */
  1733. X    if (appResources.giveHelp) {
  1734. X        callbacks[0].callback = StripHelp;
  1735. X        callbacks[0].closure = (caddr_t) 0;
  1736. X        nargs = 0;
  1737. X        argLD(XtNcallback, callbacks);
  1738. X        argLD(XtNshowGrip, False);
  1739. X        lw = XtCreateManagedWidget("help", commandWidgetClass, mon, args, nargs);
  1740. X        maxht += wHeight(lw);
  1741. X        ClearCallbacks();
  1742. X    }
  1743. X    return maxht;
  1744. X}
  1745. X
  1746. X/*
  1747. X * Create action bar for normal monthly strip
  1748. X */
  1749. Xstatic Dimension
  1750. XCreateWeeklyActionBar(shell, dw)
  1751. X    Widget          shell;
  1752. X    Widget          dw;
  1753. X{
  1754. X    Widget          lw;
  1755. X    register Cardinal nargs;
  1756. X    Arg             args[8];
  1757. X    Dimension    ht, maxht = 0;
  1758. X
  1759. X    /*
  1760. X     * Quit button label "quit" from resources
  1761. X     */
  1762. X    callbacks[0].callback = StripQuit;
  1763. X    callbacks[0].closure = (caddr_t) shell;
  1764. X    nargs = 0;
  1765. X    argLD(XtNcallback, callbacks);
  1766. X    argLD(XtNfromHoriz, NULL);
  1767. X    argLD(XtNleft, XtChainLeft);
  1768. X    argLD(XtNright, appResources.giveHelp ? XtChainLeft : XtChainRight);
  1769. X    lw = XtCreateManagedWidget("quit", commandWidgetClass, dw, args, nargs);
  1770. X    maxht = wHeight(lw);
  1771. X    ClearCallbacks();
  1772. X
  1773. X    /*
  1774. X     * Help button label help from resources
  1775. X     */
  1776. X    if (appResources.giveHelp) {
  1777. X        callbacks[0].callback = WeeklyHelp;
  1778. X        callbacks[0].closure = (caddr_t) 0;
  1779. X        nargs = 0;
  1780. X        argLD(XtNcallback, callbacks);
  1781. X        argLD(XtNfromHoriz, lw);
  1782. X        argLD(XtNleft, XtChainLeft);
  1783. X        argLD(XtNright, XtChainRight);
  1784. X        lw = XtCreateManagedWidget("help", commandWidgetClass, dw, args, nargs);
  1785. X        ht = wHeight(lw);
  1786. X        maxht = ht > maxht ? ht : maxht;
  1787. X        ClearCallbacks();
  1788. X    }
  1789. X    return maxht;
  1790. X}
  1791. X
  1792. X/*
  1793. X * Called when the date changes to ensure that the correct day has the
  1794. X * appropriate highlights
  1795. X */
  1796. Xvoid
  1797. XChangeHighlight(old, new)
  1798. X    Date           *old;
  1799. X    Date           *new;
  1800. X{
  1801. X    register Instance *ins;
  1802. X    Arg             args[5];
  1803. X    Cardinal        nargs;
  1804. X
  1805. X    for (ins = FindInstanceList(old); ins; ins = ins->i_next) {
  1806. X        nargs = 0;
  1807. X        argLD(XtNforeground, ins->i_col.fg);
  1808. X        argLD(XtNbackground, ins->i_col.bg);
  1809. X        argLD(XtNfont, ins->i_font);
  1810. X        XtSetValues(ins->i_day_label[old->day], args, nargs);
  1811. X    }
  1812. X
  1813. X    for (ins = FindInstanceList(new); ins; ins = ins->i_next) {
  1814. X        nargs = 0;
  1815. X        argLD(XtNforeground, &ins->i_col.fg);
  1816. X        argLD(XtNbackground, &ins->i_col.bg);
  1817. X        argLD(XtNfont, &ins->i_font);
  1818. X        XtGetValues(ins->i_day_label[new->day], args, nargs);
  1819. X
  1820. X        nargs = 0;
  1821. X        argLD(XtNforeground, appResources.today.fg);
  1822. X        argLD(XtNbackground, appResources.today.bg);
  1823. X        argLD(XtNfont, appResources.fontToday);
  1824. X        XtSetValues(ins->i_day_label[new->day], args, nargs);
  1825. X    }
  1826. X}
  1827. X
  1828. X/*
  1829. X * Called when middle mouse button is clicked on a date box
  1830. X * This gets the current selection and adds it to the file
  1831. X * corresponding to the day.
  1832. X * This allows quick data loading
  1833. X */
  1834. Xvoid
  1835. XLoadDateStrip(w, event, params, numb)
  1836. X        Widget            w;
  1837. X        XSelectionEvent *event;
  1838. X        String         *params;
  1839. X        Cardinal       *numb;
  1840. X{
  1841. X
  1842. X    /* set up to get the selection */
  1843. X    /* I am unconvinced that it should be this easy */
  1844. X    XtGetSelectionValue(w, XA_PRIMARY, XA_STRING,
  1845. X            LoadDateCallback, 0, XtLastTimestampProcessed(XtDisplay(w)));
  1846. X    /* The work is done in the callback routine */
  1847. X}
  1848. X
  1849. Xstatic void
  1850. XLoadDateCallback(w, xcd, sel, seltype, val, len, fmt)
  1851. X    Widget        w;
  1852. X    XtPointer    xcd;
  1853. X    Atom        *sel;
  1854. X    Atom        *seltype;
  1855. X    XtPointer    val;
  1856. X    unsigned long    *len;
  1857. X    int        *fmt;    
  1858. X{    
  1859. X    String        s;
  1860. X    int        n;
  1861. X    Arg             args[1];
  1862. X    Cardinal    v;
  1863. X    XtCallbackRec    *cb;
  1864. X    Date        da;
  1865. X
  1866. X    /* deal with arguments to get the text */
  1867. X    if (*seltype != XA_STRING)
  1868. X        n = 0;
  1869. X    else
  1870. X        n = (*len) * (*fmt/8);
  1871. X    if (n == 0)
  1872. X        return;
  1873. X
  1874. X    s = (String) XtMalloc(n+1);
  1875. X    if (n > 0)
  1876. X        memcpy(s, (char *)val, n);
  1877. X    s[n] = 0;
  1878. X    XtFree(val);
  1879. X
  1880. X    /* get closure data to find the date */
  1881. X    XtSetArg(args[0], XtNcallback, &cb);
  1882. X    XtGetValues(w, args, 1);
  1883. X    v = (Cardinal) cb->closure;
  1884. X    da.month = MoUnpack(v),
  1885. X    da.year = YrUnpack(v);
  1886. X#ifndef LONG_IS_32_BITS
  1887. X    cb++;
  1888. X    v = (Cardinal) cb->closure;
  1889. X#endif
  1890. X    da.day = DyUnpack(v);
  1891. X    da.wday = WdUnpack(v);
  1892. X    /* Add text to day file (code in xcal_edit.c) */
  1893. X    AppendText(w, &da, s);
  1894. X}
  1895. X
  1896. X
  1897. X/*
  1898. X * Call back from a quit button to lose a month strip
  1899. X */
  1900. X/* ARGSUSED */
  1901. Xstatic void
  1902. XStripQuit(w, closure, call_data)
  1903. X    Widget          w;
  1904. X    caddr_t         closure;
  1905. X    caddr_t         call_data;
  1906. X{
  1907. X    XtPopdown((Widget) closure);
  1908. X    XtDestroyWidget((Widget) closure);
  1909. X}
  1910. X
  1911. X
  1912. X/*
  1913. X * Month arithmetic and packing
  1914. X */
  1915. Xstatic          Cardinal
  1916. XDateSum(td, inx)
  1917. X    Date           *td;
  1918. X    int             inx;
  1919. X{
  1920. X    int             m, y;
  1921. X
  1922. X    m = td->month;
  1923. X    y = td->year;
  1924. X    m += inx;
  1925. X    if (m < 0) {
  1926. X        m = 11;
  1927. X        y--;
  1928. X    } else if (m > 11) {
  1929. X        m = 0;
  1930. X        y++;
  1931. X    }
  1932. X#ifdef LONG_IS_32_BITS
  1933. X    return (DatePack(0, 0, m, y));
  1934. X#else
  1935. X    return (DatePack(m, y));
  1936. X#endif
  1937. X}
  1938. X
  1939. X/*
  1940. X * Call back from day selection button press
  1941. X * This is done in two stages if cannot fold dates into a closure
  1942. X */
  1943. X/* ARGSUSED */
  1944. Xstatic void
  1945. XDayBack(w, closure, call_data)
  1946. X    Widget          w;
  1947. X    caddr_t         closure;
  1948. X    caddr_t         call_data;
  1949. X{
  1950. X#ifdef LONG_IS_32_BITS
  1951. X    callb.month = MoUnpack((Cardinal) closure);
  1952. X    callb.year = YrUnpack((Cardinal) closure);
  1953. X#endif
  1954. X    callb.day = DyUnpack((Cardinal) closure);
  1955. X    callb.wday = WdUnpack((Cardinal) closure);
  1956. X    StartEditing(w, &callb, NULL);
  1957. X}
  1958. X
  1959. X#ifndef LONG_IS_32_BITS
  1960. X/* ARGSUSED */
  1961. Xstatic void
  1962. XYmBack(w, closure, call_data)
  1963. X    Widget          w;
  1964. X    caddr_t         closure;
  1965. X    caddr_t         call_data;
  1966. X{
  1967. X    callb.month = MoUnpack((Cardinal) closure);
  1968. X    callb.year = YrUnpack((Cardinal) closure);
  1969. X}
  1970. X#endif
  1971. END_OF_FILE
  1972. if test 18555 -ne `wc -c <'xcal_strip.c'`; then
  1973.     echo shar: \"'xcal_strip.c'\" unpacked with wrong size!
  1974. fi
  1975. # end of 'xcal_strip.c'
  1976. fi
  1977. echo shar: End of archive 6 \(of 8\).
  1978. cp /dev/null ark6isdone
  1979. MISSING=""
  1980. for I in 1 2 3 4 5 6 7 8 ; do
  1981.     if test ! -f ark${I}isdone ; then
  1982.     MISSING="${MISSING} ${I}"
  1983.     fi
  1984. done
  1985. if test "${MISSING}" = "" ; then
  1986.     echo You have unpacked all 8 archives.
  1987.     rm -f ark[1-9]isdone
  1988. else
  1989.     echo You still need to unpack the following archives:
  1990.     echo "        " ${MISSING}
  1991. fi
  1992. ##  End of shell archive.
  1993. exit 0
  1994.  
  1995. exit 0 # Just in case...
  1996. -- 
  1997.   // chris@Sterling.COM           | Send comp.sources.x submissions to:
  1998. \X/  Amiga: The only way to fly!  |    sources-x@sterling.com
  1999.        "It's intuitively obvious to the most casual observer..."
  2000.  GCS d++(--) -p+ c++ !l u++ e+ m+(-) s++/++ n h--- f+ g+++ w+ t++ r+ y+
  2001.