home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume17 / xparty / part01 < prev    next >
Encoding:
Text File  |  1992-03-31  |  50.1 KB  |  1,815 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!zaphod.mps.ohio-state.edu!mips!msi!dcmartin
  3. From: peebles@mips.com (Andrew Peebles)
  4. Subject: v17i044: Xparty - multi-person conference call (MOTIF), Part01/04
  5. Message-ID: <csx-17i044-xparty@uunet.UU.NET>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. Date: Wed, 1 Apr 1992 13:49:53 GMT
  10. Approved: dcmartin@msi.com
  11.  
  12. Submitted-by: peebles@mips.com (Andrew Peebles)
  13. Posting-number: Volume 17, Issue 44
  14. Archive-name: xparty/part01
  15.  
  16. # This is a shell archive (produced by shar 3.49)
  17. # To extract the files from this archive, save it to a file, remove
  18. # everything above the "!/bin/sh" line above, and type "sh file_name".
  19. #
  20. # made 04/01/1992 13:49 UTC by dcmartin@fascet
  21. # Source directory /home/fascet/csx/src/xparty
  22. #
  23. # existing files will NOT be overwritten unless -c is specified
  24. #
  25. # This is part 1 of a multipart archive                                    
  26. # do not concatenate these parts, unpack them in order with /bin/sh        
  27. #
  28. # This shar contains:
  29. # length  mode       name
  30. # ------ ---------- ------------------------------------------
  31. #   3183 -rw-r--r-- Image.c
  32. #    751 -rw-r--r-- Imakefile
  33. #   9335 -rw-r--r-- Makefile
  34. #    335 -rw-r--r-- Makefile.std
  35. #   1245 -rw-r--r-- PromptForString.c
  36. #    439 -rw-r--r-- README
  37. #    939 -rw-r--r-- SetArg.c
  38. #  58120 -rw-r--r-- Table.c
  39. #   2633 -rw-r--r-- Table.h
  40. #   3108 -rw-r--r-- TableP.h
  41. #    983 -rw-r--r-- Warning.c
  42. #   1513 -rw-r--r-- WidgetNames.c
  43. #   1677 -rw-r--r-- XParty
  44. #   2058 -rw-r--r-- image.h
  45. #    275 -rw-r--r-- list.bg
  46. #   6476 -rw-r--r-- message.c
  47. #   5643 -rw-r--r-- operator.c
  48. #  17617 -rw-r--r-- orig_disp.c
  49. #     59 -rw-r--r-- patchlevel.h
  50. #  17408 -rw-r--r-- utils.c
  51. #   2264 -rw-r--r-- xmsg.icon
  52. #   2811 -rw-r--r-- xparty.c
  53. #   9608 -rw-r--r-- xparty.man
  54. #   1373 -rw-r--r-- xphone.h
  55. #
  56. if test -r _shar_seq_.tmp; then
  57.     echo 'Must unpack archives in sequence!'
  58.     echo Please unpack part `cat _shar_seq_.tmp` next
  59.     exit 1
  60. fi
  61. # ============= Image.c ==============
  62. if test -f 'Image.c' -a X"$1" != X"-c"; then
  63.     echo 'x - skipping Image.c (File already exists)'
  64.     rm -f _shar_wnt_.tmp
  65. else
  66. > _shar_wnt_.tmp
  67. echo 'x - extracting Image.c (Text)'
  68. sed 's/^X//' << 'SHAR_EOF' > 'Image.c' &&
  69. /***************************************************************************
  70. X *
  71. X * FILE NAME        : image.c
  72. X *
  73. X * AUTHOR        : Andrew Peebles
  74. X *
  75. X * DESCRIPTION        : Contains Xm routines for pixmap handling
  76. X *
  77. X * VERSIONS        : %W%
  78. X *
  79. X ***************************************************************************/
  80. X
  81. /*
  82. X * standard includes
  83. X */
  84. #include <stdio.h>
  85. #include <X11/Intrinsic.h>
  86. #include <X11/IntrinsicP.h>
  87. #include <Xm/Xm.h>
  88. #include "image.h"
  89. X
  90. /*
  91. X * Function:
  92. X */
  93. Boolean
  94. CreateAndInstallPixmap (bits, width, height, name)
  95. /*
  96. X * Takes arguments from a bitmap include file, creates an image
  97. X * from the data and stores it in the PIXMAP cache under name.
  98. X * These pixmaps can then be retrieved with GetPixmap and used
  99. X * for button labels, etc.
  100. X */
  101. char    *bits;
  102. int    width, height;
  103. char    *name;
  104. {
  105. X    XImage *image;
  106. X
  107. X    image = (XImage *) XtMalloc (sizeof (XImage));
  108. X    image->width = width;
  109. X    image->height = height;
  110. X    image->data = bits;
  111. X    image->depth = 1;
  112. X    image->xoffset = 0;
  113. X    image->format = XYBitmap;
  114. X    image->byte_order = LSBFirst;
  115. X    image->bitmap_unit = 8;
  116. X    image->bitmap_bit_order = LSBFirst;
  117. X    image->bitmap_pad = 8;
  118. X    image->bytes_per_line = (width+7)/8;
  119. X
  120. X    return (XmInstallImage (image, name));
  121. }
  122. X
  123. /*
  124. X * Function:
  125. X */
  126. Pixmap
  127. GetPixmap (w, name)
  128. /*
  129. X * Used to retrieve pixmaps stored in the PIXMAP cache.  Returns
  130. X * a pixmap id.  Uses the pasted in widget to calculate the foreground
  131. X * and background values of the pixmap.
  132. X */
  133. Widget    w;
  134. char    *name;
  135. {
  136. X  Pixmap    p;
  137. X  Arg        args[5];
  138. X  Pixel        f,b;
  139. X
  140. X  XtSetArg (args[0], XmNforeground, &f);
  141. X  XtSetArg (args[1], XmNbackground, &b);
  142. X  XtGetValues (w, args, 2);
  143. X  p = XmGetPixmap (w->core.screen,
  144. X           name,
  145. X           f, b);
  146. X  return (p);
  147. }
  148. X
  149. /*
  150. X * Function:
  151. X */
  152. void
  153. InstallDefaultPixmaps ()
  154. /*
  155. X * Install some default pixmaps in the PIXMAP cache.  These
  156. X * are the dialog pixmaps used by the Motif dialog widget set.
  157. X * They can be retrieved with the function GetPixmap with the
  158. X * following names:
  159. X *
  160. X *    xm_error
  161. X *    xm_warning
  162. X *    xm_question
  163. X *    xm_info
  164. X *    xm_working
  165. X */
  166. {
  167. X  XImage    *image;
  168. X
  169. X  CreateAndInstallPixmap (errorBits,
  170. X              errorWidth,
  171. X              errorHeight,
  172. X              "xm_error");
  173. X
  174. X  CreateAndInstallPixmap (infoBits,
  175. X              infoWidth,
  176. X              infoHeight,
  177. X              "xm_info");
  178. X
  179. X  CreateAndInstallPixmap (questionBits,
  180. X              questionWidth,
  181. X              questionHeight,
  182. X              "xm_question");
  183. X
  184. X  CreateAndInstallPixmap (warningBits,
  185. X              warningWidth,
  186. X              warningHeight,
  187. X              "xm_warning");
  188. X
  189. X  CreateAndInstallPixmap (workingBits,
  190. X              workingWidth,
  191. X              workingHeight,
  192. X              "xm_working");
  193. X
  194. }
  195. X
  196. /*
  197. X * Function:
  198. X */
  199. XXImage *
  200. MakeImage (width, height, data)
  201. /*
  202. X * takes arguments from a bitmap include file and returns an XImage
  203. X * pointer to that data.
  204. X */
  205. int    width, height;
  206. char    *data;
  207. {
  208. X  XImage    *image;
  209. X
  210. X      image = (XImage *) XtMalloc (sizeof (XImage));
  211. X      image->width = width;
  212. X      image->height = height;
  213. X      image->data = data;
  214. X      image->depth = 1;
  215. X      image->xoffset = 0;
  216. X      image->format = XYBitmap;
  217. X      image->byte_order = LSBFirst;
  218. X      image->bitmap_unit = 8;
  219. X      image->bitmap_bit_order = LSBFirst;
  220. X      image->bitmap_pad = 8;
  221. X      image->bytes_per_line = (width+7)/8;
  222. X      return (image);
  223. }
  224. X
  225. SHAR_EOF
  226. chmod 0644 Image.c ||
  227. echo 'restore of Image.c failed'
  228. Wc_c="`wc -c < 'Image.c'`"
  229. test 3183 -eq "$Wc_c" ||
  230.     echo 'Image.c: original size 3183, current size' "$Wc_c"
  231. rm -f _shar_wnt_.tmp
  232. fi
  233. # ============= Imakefile ==============
  234. if test -f 'Imakefile' -a X"$1" != X"-c"; then
  235.     echo 'x - skipping Imakefile (File already exists)'
  236.     rm -f _shar_wnt_.tmp
  237. else
  238. > _shar_wnt_.tmp
  239. echo 'x - extracting Imakefile (Text)'
  240. sed 's/^X//' << 'SHAR_EOF' > 'Imakefile' &&
  241. X       MOTIFLIB = -lXm
  242. X    DEPMOTIFLIB = $(USRLIBDIR)/libXm.a
  243. X
  244. LOCAL_LIBRARIES = $(MOTIFLIB) $(XTOOLLIB) $(XLIB)
  245. X        DEPLIBS = $(DEPMOTIFLIB) $(DEPXTOOLLIB) $(DEPXLIB)
  246. X
  247. X        DEFINES = -D_NO_PROTO
  248. X
  249. X   INSTALLFLAGS = -m 5755
  250. X
  251. X          SRCS = xparty.c \
  252. X          orig_disp.c \
  253. X          utils.c \
  254. X          message.c \
  255. X          operator.c \
  256. X                  Warning.c \
  257. X          SetArg.c \
  258. X          Image.c \
  259. X          PromptForString.c \
  260. X          WidgetNames.c \
  261. X                  Table.c
  262. X
  263. X          OBJS = xparty.o \
  264. X          orig_disp.o \
  265. X          utils.o \
  266. X          message.o \
  267. X          operator.o \
  268. X                  Warning.o \
  269. X          SetArg.o \
  270. X          Image.o \
  271. X          PromptForString.o \
  272. X          WidgetNames.o \
  273. X                  Table.o
  274. X
  275. X       PROGRAMS = xparty
  276. X
  277. all:: $(PROGRAMS)
  278. X
  279. ComplexProgramTarget(xparty)
  280. SHAR_EOF
  281. chmod 0644 Imakefile ||
  282. echo 'restore of Imakefile failed'
  283. Wc_c="`wc -c < 'Imakefile'`"
  284. test 751 -eq "$Wc_c" ||
  285.     echo 'Imakefile: original size 751, current size' "$Wc_c"
  286. rm -f _shar_wnt_.tmp
  287. fi
  288. # ============= Makefile ==============
  289. if test -f 'Makefile' -a X"$1" != X"-c"; then
  290.     echo 'x - skipping Makefile (File already exists)'
  291.     rm -f _shar_wnt_.tmp
  292. else
  293. > _shar_wnt_.tmp
  294. echo 'x - extracting Makefile (Text)'
  295. sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
  296. # Makefile generated by imake - do not edit!
  297. # $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $
  298. X
  299. ###########################################################################
  300. # Makefile generated from "Imake.tmpl" and <Imakefile>
  301. # $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $
  302. #
  303. # Platform-specific parameters may be set in the appropriate .cf
  304. # configuration files.  Site-wide parameters may be set in the file
  305. # site.def.  Full rebuilds are recommended if any parameters are changed.
  306. #
  307. # If your C preprocessor doesn't define any unique symbols, you'll need
  308. # to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  309. # "make Makefile", "make Makefiles", or "make World").
  310. #
  311. # If you absolutely can't get imake to work, you'll need to set the
  312. # variables at the top of each Makefile as well as the dependencies at the
  313. # bottom (makedepend will do this automatically).
  314. #
  315. X
  316. ###########################################################################
  317. # platform-specific configuration parameters - edit sgi.cf to change
  318. X
  319. CRT1 = /usr/lib/crt1.o
  320. CRTN = /usr/lib/crtn.o
  321. X
  322. ###########################################################################
  323. # site-specific configuration parameters - edit site.def to change
  324. X
  325. # site:  $XConsortium: site.def,v 1.21 89/12/06 11:46:50 jim Exp $
  326. X
  327. X        OPTIMIZER = -O2
  328. X
  329. X            SHELL = /bin/sh
  330. X
  331. X              TOP = .
  332. X      CURRENT_DIR = .
  333. X
  334. X               AR = ar scq
  335. X  BOOTSTRAPCFLAGS = "$(OPTIMIZER)"
  336. X               CC = cc
  337. X
  338. X         COMPRESS = compress
  339. X              CPP = /lib/cpp $(STD_CPP_DEFINES)
  340. X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
  341. X          INSTALL = bsdinst.sh
  342. X               LD = ld
  343. X             LINT = lint
  344. X      LINTLIBFLAG = -o
  345. X         LINTOPTS = -ax
  346. X               LN = ln -s
  347. X
  348. X               MV = mv
  349. X               CP = cp
  350. X           RANLIB = /bin/true
  351. X  RANLIBINSTFLAGS =
  352. X               RM = rm -f
  353. X  VENDOR_INCLUDES =
  354. X     STD_INCLUDES =
  355. X  STD_CPP_DEFINES = -DSYSV
  356. X      STD_DEFINES = -DSYSV -DMALLOC_0_RETURNS_NULL
  357. X EXTRA_LOAD_FLAGS =
  358. X  EXTRA_LIBRARIES = -lsun -lmalloc -lc_s
  359. X             TAGS = ctags
  360. X
  361. X    SHAREDCODEDEF = -DSHAREDCODE
  362. X         SHLIBDEF = -DATTSHAREDLIB
  363. X
  364. X    PROTO_DEFINES = -DFUNCPROTO -DNARROWPROTO
  365. X
  366. X     INSTPGMFLAGS = -s
  367. X
  368. X     INSTBINFLAGS = -m 0755
  369. X     INSTUIDFLAGS = -m 4755
  370. X     INSTLIBFLAGS = -m 0664
  371. X     INSTINCFLAGS = -m 0444
  372. X     INSTMANFLAGS = -m 0444
  373. X     INSTDATFLAGS = -m 0444
  374. X    INSTKMEMFLAGS = -m 2755 -g sys
  375. X
  376. X          DESTDIR =
  377. X
  378. X     TOP_INCLUDES = -I$(INCROOT)
  379. X
  380. X      CDEBUGFLAGS = $(OPTIMIZER)
  381. X        CCOPTIONS = -prototypes -cckr -float
  382. X      COMPATFLAGS =
  383. X
  384. X      ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES) $(VENDOR_INCLUDES)
  385. X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS)
  386. X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
  387. X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
  388. X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  389. X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)
  390. X   LDCOMBINEFLAGS = -r
  391. X
  392. X        MACROFILE = sgi.cf
  393. X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
  394. X
  395. X    IMAKE_DEFINES =
  396. X
  397. X         IRULESRC = $(CONFIGDIR)
  398. X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
  399. X
  400. X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
  401. X            $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
  402. X            $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
  403. X
  404. ###########################################################################
  405. # X Window System Build Parameters
  406. # $XConsortium: Project.tmpl,v 1.68 90/07/03 12:14:47 rws Exp $
  407. X
  408. ###########################################################################
  409. # X Window System make variables; this need to be coordinated with rules
  410. # $XConsortium: Project.tmpl,v 1.68 90/07/03 12:14:47 rws Exp $
  411. X
  412. X          PATHSEP = /
  413. X        USRLIBDIR = $(DESTDIR)/usr/lib
  414. X           BINDIR = $(DESTDIR)/usr/bin/X11
  415. X          INCROOT = $(DESTDIR)/usr/include
  416. X     BUILDINCROOT = $(TOP)
  417. X      BUILDINCDIR = $(BUILDINCROOT)/X11
  418. X      BUILDINCTOP = ..
  419. X           INCDIR = $(INCROOT)/X11
  420. X           ADMDIR = $(DESTDIR)/usr/adm
  421. X           LIBDIR = $(USRLIBDIR)/X11
  422. X        CONFIGDIR = $(LIBDIR)/config
  423. X       LINTLIBDIR = $(USRLIBDIR)/lint
  424. X
  425. X          FONTDIR = $(LIBDIR)/fonts
  426. X         XINITDIR = $(LIBDIR)/xinit
  427. X           XDMDIR = $(LIBDIR)/xdm
  428. X           AWMDIR = $(LIBDIR)/awm
  429. X           TWMDIR = $(LIBDIR)/twm
  430. X           GWMDIR = $(LIBDIR)/gwm
  431. X          MANPATH = $(DESTDIR)/usr/man
  432. X    MANSOURCEPATH = $(MANPATH)/man
  433. X           MANDIR = $(MANSOURCEPATH)n
  434. X        LIBMANDIR = $(MANSOURCEPATH)3
  435. X      XAPPLOADDIR = $(LIBDIR)/app-defaults
  436. X
  437. X       FONTCFLAGS = -t
  438. X
  439. X     INSTAPPFLAGS = $(INSTDATFLAGS)
  440. X
  441. X            IMAKE = imake
  442. X           DEPEND = makedepend
  443. X              RGB = rgb
  444. X
  445. X            FONTC = bdftopcf
  446. X
  447. X        MKFONTDIR = mkfontdir
  448. X
  449. X        MKDIRHIER = mkdir -p
  450. X
  451. X        CONFIGSRC = $(TOP)/config
  452. X        CLIENTSRC = $(TOP)/clients
  453. X          DEMOSRC = $(TOP)/demos
  454. X           LIBSRC = $(TOP)/lib
  455. X
  456. X          FONTSRC = $(TOP)/fonts.pcf
  457. X
  458. X       INCLUDESRC = $(TOP)/X11
  459. X        SERVERSRC = $(TOP)/server
  460. X          UTILSRC = $(TOP)/util
  461. X        SCRIPTSRC = $(UTILSRC)/scripts
  462. X       EXAMPLESRC = $(TOP)/examples
  463. X       CONTRIBSRC = $(TOP)/../contrib
  464. X           DOCSRC = $(TOP)/doc
  465. X           RGBSRC = $(TOP)/rgb
  466. X        DEPENDSRC = $(UTILSRC)/makedepend
  467. X         IMAKESRC = $(CONFIGSRC)
  468. X         XAUTHSRC = $(LIBSRC)/Xau
  469. X          XLIBSRC = $(LIBSRC)/X
  470. X           XMUSRC = $(LIBSRC)/Xmu
  471. X       TOOLKITSRC = $(LIBSRC)/Xt
  472. X       AWIDGETSRC = $(LIBSRC)/Xaw
  473. X       OLDXLIBSRC = $(LIBSRC)/oldX
  474. X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
  475. X         XILIBSRC = $(EXTENSIONSRC)/lib/xinput
  476. X      BDFTOSNFSRC = $(FONTSRC)/tools/bdftosnf
  477. X      BDFTOPCFSRC = $(FONTSRC)/tools/bdftopcf
  478. X     MKFONTDIRSRC = $(FONTSRC)/tools/mkfontdir
  479. X     EXTENSIONSRC = $(TOP)/extensions
  480. X
  481. X  DEPEXTENSIONLIB =  $(USRLIBDIR)/libXext.a
  482. X     EXTENSIONLIB =   -lXext
  483. X
  484. X          DEPXLIB = $(DEPEXTENSIONLIB)  $(USRLIBDIR)/libX11_s.a
  485. X             XLIB = $(EXTENSIONLIB)  -lX11_s
  486. X
  487. X      DEPXAUTHLIB =  $(USRLIBDIR)/libXau.a
  488. X         XAUTHLIB =   -lXau
  489. X
  490. X        DEPXMULIB =  $(USRLIBDIR)/libXmu.a
  491. X           XMULIB =   -lXmu
  492. X
  493. X       DEPOLDXLIB =  $(USRLIBDIR)/liboldX.a
  494. X          OLDXLIB =   -loldX
  495. X
  496. X      DEPXTOOLLIB =  $(USRLIBDIR)/libXt_s.a
  497. X         XTOOLLIB =  -lXt_s
  498. X
  499. X        DEPXAWLIB =  $(USRLIBDIR)/libXaw.a
  500. X           XAWLIB =   -lXaw
  501. X
  502. X         DEPXILIB =  $(USRLIBDIR)/libXi.a
  503. X            XILIB =   -lXi
  504. X
  505. X LINTEXTENSIONLIB =  $(LINTLIBDIR)/llib-lXext.ln
  506. X         LINTXLIB =  $(LINTLIBDIR)/llib-lX11.ln
  507. X          LINTXMU =  $(LINTLIBDIR)/llib-lXmu.ln
  508. X        LINTXTOOL =  $(LINTLIBDIR)/llib-lXt.ln
  509. X          LINTXAW =  $(LINTLIBDIR)/llib-lXaw.ln
  510. X
  511. X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
  512. X
  513. X         DEPLIBS1 = $(DEPLIBS)
  514. X         DEPLIBS2 = $(DEPLIBS)
  515. X         DEPLIBS3 = $(DEPLIBS)
  516. X
  517. ###########################################################################
  518. # Imake rules for building libraries, programs, scripts, and data files
  519. # rules:  $XConsortium: Imake.rules,v 1.70 90/05/04 16:57:30 keith Exp $
  520. X
  521. ###########################################################################
  522. # start of Imakefile
  523. X
  524. X       MOTIFLIB = -lXm
  525. X    DEPMOTIFLIB = $(USRLIBDIR)/libXm.a
  526. X
  527. LOCAL_LIBRARIES = $(MOTIFLIB) $(XTOOLLIB) $(XLIB)
  528. X        DEPLIBS = $(DEPMOTIFLIB) $(DEPXTOOLLIB) $(DEPXLIB)
  529. X
  530. X        DEFINES = -D_NO_PROTO
  531. X
  532. X   INSTALLFLAGS = -m 5755
  533. X
  534. X          SRCS = xparty.c \
  535. X          orig_disp.c \
  536. X          utils.c \
  537. X          message.c \
  538. X          operator.c \
  539. X                  Warning.c \
  540. X          SetArg.c \
  541. X          Image.c \
  542. X          PromptForString.c \
  543. X          WidgetNames.c \
  544. X                  Table.c
  545. X
  546. X          OBJS = xparty.o \
  547. X          orig_disp.o \
  548. X          utils.o \
  549. X          message.o \
  550. X          operator.o \
  551. X                  Warning.o \
  552. X          SetArg.o \
  553. X          Image.o \
  554. X          PromptForString.o \
  555. X          WidgetNames.o \
  556. X                  Table.o
  557. X
  558. X       PROGRAMS = xparty
  559. X
  560. all:: $(PROGRAMS)
  561. X
  562. X        PROGRAM = xparty
  563. X
  564. all:: xparty
  565. X
  566. xparty: $(OBJS) $(DEPLIBS)
  567. X     $(RM) $@ ; \
  568. X    $(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
  569. X
  570. install:: xparty
  571. X    $(INSTALL) -c $(INSTPGMFLAGS) $(INSTALLFLAGS) xparty $(BINDIR)
  572. X
  573. install.man:: xparty.man
  574. X    $(INSTALL) -c $(INSTMANFLAGS) xparty.man $(MANDIR)/xparty.n
  575. X
  576. depend::
  577. X    $(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
  578. X
  579. lint:
  580. X    $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
  581. lint1:
  582. X    $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
  583. X
  584. clean::
  585. X    $(RM) $(PROGRAM)
  586. X
  587. ###########################################################################
  588. # common rules for all Makefiles - do not edit
  589. X
  590. emptyrule::
  591. X
  592. clean::
  593. X    $(RM_CMD) \#*
  594. X
  595. Makefile::
  596. X    -@if [ -f Makefile ]; then \
  597. X        echo "    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
  598. X        $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  599. X    else : ; fi ; \
  600. X    $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
  601. X
  602. tags::
  603. X    $(TAGS) -w *.[ch]
  604. X    $(TAGS) -xw *.[ch] > TAGS
  605. X
  606. ###########################################################################
  607. # empty rules for directories that do not have SUBDIRS - do not edit
  608. X
  609. install::
  610. X    @echo "install in $(CURRENT_DIR) done"
  611. X
  612. install.man::
  613. X    @echo "install.man in $(CURRENT_DIR) done"
  614. X
  615. Makefiles::
  616. X
  617. includes::
  618. X
  619. ###########################################################################
  620. # dependencies generated by makedepend
  621. X
  622. SHAR_EOF
  623. chmod 0644 Makefile ||
  624. echo 'restore of Makefile failed'
  625. Wc_c="`wc -c < 'Makefile'`"
  626. test 9335 -eq "$Wc_c" ||
  627.     echo 'Makefile: original size 9335, current size' "$Wc_c"
  628. rm -f _shar_wnt_.tmp
  629. fi
  630. # ============= Makefile.std ==============
  631. if test -f 'Makefile.std' -a X"$1" != X"-c"; then
  632.     echo 'x - skipping Makefile.std (File already exists)'
  633.     rm -f _shar_wnt_.tmp
  634. else
  635. > _shar_wnt_.tmp
  636. echo 'x - extracting Makefile.std (Text)'
  637. sed 's/^X//' << 'SHAR_EOF' > 'Makefile.std' &&
  638. LIBS            = -lXm -lXt -lX11 -lbsd
  639. X
  640. CFLAGS          = -g -DMips -systype sysv -signed -D_NO_PROTO
  641. X
  642. X
  643. NOBJS        = xparty.o orig_disp.o utils.o message.o operator.o \
  644. X                  Warning.o SetArg.o Image.o PromptForString.o WidgetNames.o \
  645. X          Table.o
  646. X
  647. xparty      : $(NOBJS)
  648. X          cc ${CFLAGS} -o xparty ${NOBJS} ${LIBPATHS} ${LIBS}
  649. X
  650. SHAR_EOF
  651. chmod 0644 Makefile.std ||
  652. echo 'restore of Makefile.std failed'
  653. Wc_c="`wc -c < 'Makefile.std'`"
  654. test 335 -eq "$Wc_c" ||
  655.     echo 'Makefile.std: original size 335, current size' "$Wc_c"
  656. rm -f _shar_wnt_.tmp
  657. fi
  658. # ============= PromptForString.c ==============
  659. if test -f 'PromptForString.c' -a X"$1" != X"-c"; then
  660.     echo 'x - skipping PromptForString.c (File already exists)'
  661.     rm -f _shar_wnt_.tmp
  662. else
  663. > _shar_wnt_.tmp
  664. echo 'x - extracting PromptForString.c (Text)'
  665. sed 's/^X//' << 'SHAR_EOF' > 'PromptForString.c' &&
  666. /***************************************************************************
  667. X *
  668. X * FILE NAME        : PromptForString.c
  669. X *
  670. X * AUTHOR        : Andrew Peebles
  671. X *
  672. X * DESCRIPTION        : Special routine for prompting the user for
  673. X *              a string.
  674. X *
  675. X * VERSIONS        : %W%
  676. X *
  677. X ***************************************************************************/
  678. X
  679. /*
  680. X * standard includes
  681. X */
  682. #include <stdio.h>
  683. #include <ctype.h>
  684. X
  685. #include <Xm/SelectioB.h>
  686. X
  687. static XtCallbackRec OK_CB[] = {
  688. X  {NULL,     NULL},
  689. X  {NULL,        NULL},
  690. };
  691. X
  692. X
  693. PromptForString (reference, pmpt, deft, okProc, okData)
  694. Widget    reference;
  695. char    *pmpt;
  696. char    *deft;
  697. int    (*okProc)();
  698. caddr_t    okData;
  699. {
  700. X  Arg    args[10];
  701. X  int    n;
  702. X  Widget prompt, button;
  703. X  XmStringCharSet char_set = (XmStringCharSet) XmSTRING_DEFAULT_CHARSET;
  704. X
  705. X  OK_CB[0].callback = (XtCallbackProc) (*okProc);
  706. X  OK_CB[0].closure  = okData;
  707. X
  708. X  n = SetArgs (args,
  709. X           XmNselectionLabelString, XmStringLtoRCreate (pmpt, char_set),
  710. X           XmNtextString, XmStringLtoRCreate (deft, char_set),
  711. X           XmNokCallback, OK_CB,
  712. X           NULL);
  713. X  prompt = XmCreatePromptDialog (reference,
  714. X                 "PromptForString",
  715. X                 args, n);
  716. X  button = XmSelectionBoxGetChild (prompt, XmDIALOG_HELP_BUTTON);
  717. X  XtUnmanageChild (button);
  718. X  XtManageChild (prompt);
  719. }
  720. X
  721. SHAR_EOF
  722. chmod 0644 PromptForString.c ||
  723. echo 'restore of PromptForString.c failed'
  724. Wc_c="`wc -c < 'PromptForString.c'`"
  725. test 1245 -eq "$Wc_c" ||
  726.     echo 'PromptForString.c: original size 1245, current size' "$Wc_c"
  727. rm -f _shar_wnt_.tmp
  728. fi
  729. # ============= README ==============
  730. if test -f 'README' -a X"$1" != X"-c"; then
  731.     echo 'x - skipping README (File already exists)'
  732.     rm -f _shar_wnt_.tmp
  733. else
  734. > _shar_wnt_.tmp
  735. echo 'x - extracting README (Text)'
  736. sed 's/^X//' << 'SHAR_EOF' > 'README' &&
  737. XXparty is a multi-person conference calling program for Motif.
  738. It operates like talk, but with the capability of having up to ten
  739. people on the `party' line.  It can also be used to send "one way"
  740. messages to users on remote displays.
  741. X
  742. To build:
  743. X
  744. X    unshar the distribution
  745. X    xmkmf
  746. X    make
  747. X
  748. Put the resource file XParty in your $XAPPLRESDIR directory or include it
  749. in your .Xdefaults file.
  750. X
  751. Send problems to:
  752. X
  753. X    Andrew Peebles
  754. X    peebles@mips.com
  755. SHAR_EOF
  756. chmod 0644 README ||
  757. echo 'restore of README failed'
  758. Wc_c="`wc -c < 'README'`"
  759. test 439 -eq "$Wc_c" ||
  760.     echo 'README: original size 439, current size' "$Wc_c"
  761. rm -f _shar_wnt_.tmp
  762. fi
  763. # ============= SetArg.c ==============
  764. if test -f 'SetArg.c' -a X"$1" != X"-c"; then
  765.     echo 'x - skipping SetArg.c (File already exists)'
  766.     rm -f _shar_wnt_.tmp
  767. else
  768. > _shar_wnt_.tmp
  769. echo 'x - extracting SetArg.c (Text)'
  770. sed 's/^X//' << 'SHAR_EOF' > 'SetArg.c' &&
  771. #include <stdio.h>
  772. #include <X11/Xlib.h>
  773. #include <X11/Intrinsic.h>
  774. #include <X11/StringDefs.h>
  775. X
  776. #include <varargs.h>
  777. X
  778. /*
  779. X * Function SetArgs
  780. X *
  781. X * SetArgs fills an ArgList (an array of Args) with a given list of values.
  782. X * The list of values is NULL terminated.
  783. X *
  784. X * SetArgs returns the number of arguments that were set.
  785. X *
  786. X * EXAMPLE USAGE:
  787. X *
  788. X * int n;
  789. X * Arg args[10];
  790. X *
  791. X * n = SetArgs (args,
  792. X *        XmNwidth, 10,
  793. X *        XmNheight, 20,
  794. X *        NULL);
  795. X * XtSetValues (w, args, n);
  796. X */
  797. X
  798. SetArgs(va_alist)
  799. va_dcl
  800. {
  801. X  va_list a;
  802. X
  803. X  /* The first argument is the array to fill. */
  804. X  register ArgList this_arg;
  805. X
  806. X  /* Others are name and value pairs. */
  807. X  String name;
  808. X  
  809. X  /* How many Args have we set? */
  810. X  int count = 0;
  811. X  
  812. X  va_start(a);
  813. X  this_arg = va_arg(a, ArgList);
  814. X  
  815. X  while ((name = va_arg(a, String)) != NULL)
  816. X    {
  817. X      XtSetArg(this_arg[count], name, va_arg(a, XtArgVal));    
  818. X      ++count;
  819. X    }
  820. X  
  821. X  va_end(a);
  822. X  return count;
  823. }
  824. X
  825. X
  826. SHAR_EOF
  827. chmod 0644 SetArg.c ||
  828. echo 'restore of SetArg.c failed'
  829. Wc_c="`wc -c < 'SetArg.c'`"
  830. test 939 -eq "$Wc_c" ||
  831.     echo 'SetArg.c: original size 939, current size' "$Wc_c"
  832. rm -f _shar_wnt_.tmp
  833. fi
  834. # ============= Table.c ==============
  835. if test -f 'Table.c' -a X"$1" != X"-c"; then
  836.     echo 'x - skipping Table.c (File already exists)'
  837.     rm -f _shar_wnt_.tmp
  838. else
  839. > _shar_wnt_.tmp
  840. echo 'x - extracting Table.c (Text)'
  841. sed 's/^X//' << 'SHAR_EOF' > 'Table.c' &&
  842. #define _Table_c
  843. X
  844. /*LINTLIBRARY*/ /* -*-C++-*- */
  845. /*
  846. X * Table - Forms-based composite widget/geometry manager for the X Toolkit
  847. X *
  848. X * David Harrison
  849. X * University of California, Berkeley
  850. X * 1989
  851. X *
  852. X * This file contains the implementation for the Table widget.
  853. X */
  854. X
  855. /* Edit History
  856. X
  857. 02/10/91     marbru     SetValues must copy table.init_layout, if changed
  858. 11/25/90  12 nazgul    Better handling of geometry
  859. 11/08/90   2 schulert    remove include of Xmu.h
  860. 10/31/90   1 schulert    change w->xrm_name to x->core.xrm_name
  861. 10/31/90  10 nazgul    Handle gadgets when formatting is done by name
  862. 09/30/90   9 nazgul    Try not to change the widget if we are going to return
  863. X            XtGeometryAlmost
  864. 09/13/90   7 nazgul    Added #ifdefs so it works with Motif 1.1 as well as 1.0
  865. 08/07/90   5 nazgul    Mon Aug  6 09:41:11 1990 patches from david@jpl-devvax.jpl.nasa.gov
  866. 07/26/90   4 nazgul    Removal of Xmu.h reference (Niels Mayer)
  867. 07/25/90   3 nazgul    Merged in latest patches from the net
  868. 07/15/90   2 nazgul    Now deal with XmText widgets reasonably
  869. X
  870. */
  871. X
  872. #include <X11/IntrinsicP.h>
  873. #include <X11/StringDefs.h>
  874. X
  875. /*#include "WcCreate.h" */
  876. #include "TableP.h"
  877. X
  878. #define INIT_TBL_SIZE    10
  879. #define TBL_CLASS_NAME    "Table"
  880. X
  881. static caddr_t def = (caddr_t) 0;
  882. X
  883. static XtResource resources[] = {
  884. X    { XtNlayout, XtCLayout, XtRPointer, sizeof(caddr_t),
  885. X    XtOffset(TableWidget, table.init_layout), XtRPointer, (caddr_t) &def },
  886. X    { XtNinternalHeight, XtCHeight, XtRDimension, sizeof(Dimension),
  887. X    XtOffset(TableWidget, table.int_height), XtRImmediate, (caddr_t) 0 },
  888. X    { XtNinternalWidth, XtCWidth, XtRDimension, sizeof(Dimension),
  889. X    XtOffset(TableWidget, table.int_width), XtRImmediate, (caddr_t) 0 },
  890. X
  891. X    { XtNcolumnSpacing, XtCSpacing, XtRDimension, sizeof(Dimension),
  892. X    XtOffset(TableWidget, table.col_spacing), XtRImmediate, (caddr_t) 0 },
  893. X    { XtNrowSpacing, XtCSpacing, XtRDimension, sizeof(Dimension),
  894. X    XtOffset(TableWidget, table.row_spacing), XtRImmediate, (caddr_t) 0 },
  895. /* If we want it more motif-like
  896. X    { XmNverticalSpacing, XmCSpacing, XtRDimension, sizeof(Dimension),
  897. X    XtOffset(TableWidget, table.col_spacing), XtRImmediate, (caddr_t) 0 },
  898. X    { XmNhorizontalSpacing, XmCSpacing, XtRDimension, sizeof(Dimension),
  899. X    XtOffset(TableWidget, table.row_spacing), XtRImmediate, (caddr_t) 0 },
  900. */
  901. X    { XtNdefaultOptions, XtCOptions, XtROptions, sizeof(XtTblMask),
  902. X    XtOffset(TableWidget, table.def_options), XtRImmediate, (caddr_t) 0 }
  903. };
  904. X
  905. /* Forward declarations */
  906. static void TblClassInitialize();
  907. static void TblExposeProc();
  908. static void TblInitialize();
  909. static void TblResize();
  910. static XtGeometryResult TblQueryGeometry();
  911. static void TblPositionChild();
  912. static Boolean TblSetValues();
  913. static XtGeometryResult TblGeometryManager();
  914. static void TblChangeManaged();
  915. static Boolean TblFindChild();
  916. static void TblDestroy();
  917. static XtTblMask ParseOpts();
  918. X
  919. X
  920. X
  921. /*
  922. X * Local structures
  923. X */
  924. X
  925. typedef struct _TableLoc {
  926. X    Position ax, ay;        /* Position in array       */
  927. X    Dimension h_span, v_span;    /* Span size in array      */
  928. X    XtTblMask options;        /* Widget position options */
  929. } TableLoc, *TableLocPtr;
  930. X
  931. typedef struct _TableLocEntry {
  932. X    Widget w;
  933. X    TableLoc loc;
  934. } TableLocEntry, *TableLocEntryPtr;
  935. X
  936. struct _TableLocTbl {
  937. X    Cardinal n_layout;        /* Number of layout widgets */
  938. X    Cardinal a_layout;        /* Allocated space          */
  939. X    TableLocEntryPtr locs;    /* Widget locations         */
  940. };
  941. X
  942. struct _TableDefLoc {
  943. X    String w_name;        /* Widget name        */
  944. X    TableLoc loc;        /* Widget information */
  945. };
  946. X
  947. typedef unsigned long TableVecMask;
  948. #define    VEC_MINIMIZE    0x01
  949. X
  950. struct _TableVector {
  951. X    TableVecMask mask;        /* Option mask  */
  952. X    Cardinal value;        /* Size of item */
  953. };
  954. X
  955. X
  956. #if XmVersion > 1000
  957. static XtActionsRec actionsList[] =
  958. {
  959. X    { "Enter",    (XtActionProc)    _XmManagerEnter },
  960. X    { "FocusIn",    (XtActionProc)    _XmManagerFocusIn },
  961. X    { "Arm",    (XtActionProc)    _XmGadgetArm  },
  962. X    { "Activate",    (XtActionProc)    _XmGadgetActivate },
  963. X    { "Help",    (XtActionProc)    _XmManagerHelp },
  964. X    { "Return",    (XtActionProc)    _XmBulletinBoardReturn },
  965. X    { "BulletinBoardReturn", (XtActionProc)    _XmBulletinBoardReturn },
  966. X        { "BulletinBoardCancel", (XtActionProc)    _XmBulletinBoardCancel },
  967. };
  968. #else
  969. static XtActionsRec actionsList[] =
  970. {
  971. X    { "Enter",    (XtActionProc)    _XmManagerEnter },
  972. X    { "FocusIn",    (XtActionProc)    _XmBulletinBoardFocus },
  973. X    { "Arm",    (XtActionProc)    _XmBulletinBoardArm  },
  974. X    { "Activate",    (XtActionProc)    _XmBulletinBoardActivate },
  975. X    { "Help",    (XtActionProc)    _XmBulletinBoardHelp },
  976. X    { "Return",    (XtActionProc)    _XmBulletinBoardReturn },
  977. };
  978. #endif
  979. X
  980. EXTERNDEF TableClassRec tableClassRec = {
  981. X  { /* core_class fields */
  982. #ifdef OLDLEVEL
  983. X    /* superclass      */    (WidgetClass) &compositeClassRec,
  984. #else
  985. X    /* superclass         */    (WidgetClass) &xmBulletinBoardClassRec,
  986. #endif
  987. X    /* class_name         */    TBL_CLASS_NAME,
  988. X    /* widget_size        */    sizeof(TableRec),
  989. X    /* class_initialize   */    TblClassInitialize,
  990. X    /* class_part_init    */    NULL,
  991. X    /* class_inited       */    FALSE,
  992. X    /* initialize         */    TblInitialize,
  993. X    /* initialize_hook    */    NULL,
  994. X    /* realize            */    XtInheritRealize,
  995. X    /* actions            */    actionsList,
  996. X    /* num_actions        */    XtNumber(actionsList),
  997. X    /* resources          */    resources,
  998. X    /* num_resources      */    XtNumber(resources),
  999. X    /* xrm_class          */    NULLQUARK,
  1000. X    /* compress_motion    */    False,
  1001. X    /* compress_exposure  */    TRUE,
  1002. X    /* compress_enterleave*/    False,
  1003. X    /* visible_interest   */    FALSE,
  1004. X    /* destroy            */    TblDestroy,
  1005. X    /* resize             */    TblResize,
  1006. X    /* expose             */    _XmRedisplayGadgets,
  1007. X    /* set_values         */    TblSetValues,
  1008. X    /* set_values_hook    */    NULL,
  1009. X    /* set_values_almost  */    XtInheritSetValuesAlmost,
  1010. X    /* get_values_hook    */    NULL,
  1011. X    /* accept_focus       */    NULL,
  1012. X    /* version            */    XtVersion,
  1013. X    /* callback_private   */    NULL,
  1014. X    /* tm_table           */    XtInheritTranslations,
  1015. X    /* query_geometry     */    TblQueryGeometry,
  1016. X    /* display_accelerator*/    /*XtInheritDisplayAccelerator,*/ NULL,
  1017. X    /* extension          */    NULL
  1018. X  },
  1019. X  { /* composite_class fields */
  1020. X    /* geometry_manager   */   TblGeometryManager,
  1021. X    /* change_managed     */   TblChangeManaged,
  1022. X    /* insert_child       */   XtInheritInsertChild,
  1023. X    /* delete_child       */   XtInheritDeleteChild,
  1024. X    /* extension          */   NULL
  1025. X  },
  1026. #ifndef OLDLEVEL
  1027. { /* constraint_class fields */
  1028. X    /* resource list     */ NULL,
  1029. X    /* num resources    */ 0,
  1030. X    /* constraint size  */ 0,
  1031. X    /* init proc    */ NULL,
  1032. X    /* destroy proc     */ NULL,
  1033. X    /* set values proc  */ NULL,
  1034. X    /* extension     */   NULL
  1035. X  },
  1036. X  { /* manager_class      */
  1037. #if XmVersion > 1000
  1038. X    /* translations       */    XtInheritTranslations,
  1039. X    /* syn_resources      */    NULL,
  1040. X    /* num_syn_resources  */    0,
  1041. X    /* syn_cont_resources */    NULL,
  1042. X    /* num_syn_cont_resources */ 0,
  1043. X    /* parent_process     */    NULL,
  1044. X    /* extension      */    NULL
  1045. #else
  1046. X    /* translations       */    (XtTranslations) _XtInherit,
  1047. X    /* get_resources      */    NULL,
  1048. X    /* num_get_resources  */    0,
  1049. X    /* get_constraint_resources */    NULL,
  1050. X    /* num_get_constraint_resources */    0,
  1051. X    /* extension      */    NULL
  1052. #endif
  1053. X  },
  1054. { /* Bulletin Board */
  1055. X    /* always_install_accelerators */    False,
  1056. #if XmVersion > 1000
  1057. X    /* geo_matrix_create */    NULL,
  1058. X    /* focus_moved_proc */    XtInheritFocusMovedProc,
  1059. #endif
  1060. X    /* extension    */  NULL,
  1061. X  },
  1062. #endif
  1063. X  { /* table_class fields */
  1064. X    /* position_child      */    TblPositionChild,
  1065. X    /* find_child      */    TblFindChild,
  1066. X  }
  1067. };
  1068. X
  1069. EXTERNDEF WidgetClass tableWidgetClass = (WidgetClass) &tableClassRec;
  1070. X
  1071. X
  1072. X
  1073. /*ARGSUSED*/
  1074. static void cvtStrToDefLoc(args, num_args, from, to)
  1075. XXrmValue *args;            /* Arguments to converter */
  1076. Cardinal *num_args;        /* Number of arguments    */
  1077. XXrmValue *from;            /* From type              */
  1078. XXrmValue *to;            /* To type                */
  1079. /*
  1080. X * Converts a string representation into an array of TableDefLoc
  1081. X * structures.
  1082. X */
  1083. {
  1084. X    static caddr_t ptr;
  1085. X    String layout_spec;
  1086. X
  1087. X    if (*num_args != 0) {
  1088. X    XtErrorMsg("cvtStrToDefLoc", "wrongParameters", "XtToolkitError",
  1089. X           "String to layout takes no additional arguments",
  1090. X           (String *) NULL, (Cardinal *) NULL);
  1091. X    }
  1092. X
  1093. X    layout_spec = (String) from->addr;
  1094. X    ptr = XtTblParseLayout(layout_spec);
  1095. X    to->size = sizeof(caddr_t);
  1096. X    to->addr = (caddr_t) &ptr;
  1097. }
  1098. X
  1099. /*ARGSUSED*/
  1100. static void cvtStrToOpts(args, num_args, from, to)
  1101. XXrmValue *args;            /* Arguments to converter */
  1102. Cardinal *num_args;        /* Number of arguments    */
  1103. XXrmValue *from;            /* From type              */
  1104. XXrmValue *to;            /* To type                */
  1105. /*
  1106. X * Converts a string representation into a default options
  1107. X * mask (XtTblMask).
  1108. X */
  1109. {
  1110. X    static XtTblMask mask;
  1111. X    String opt_spec;
  1112. X
  1113. X    if (*num_args != 0) {
  1114. X    XtErrorMsg("cvtStrToOpts", "wrongParameters", "XtToolkitError",
  1115. X           "String to options takes no additional arguments",
  1116. X           (String *) NULL, (Cardinal *) NULL);
  1117. X    }
  1118. X
  1119. X    opt_spec = (String) from->addr;
  1120. X    to->size = sizeof(int);
  1121. X    mask = ParseOpts(opt_spec);
  1122. X    to->addr = (caddr_t) &mask;
  1123. }
  1124. X
  1125. X
  1126. static void TblClassInitialize()
  1127. /*
  1128. X * Adds an appropriate string-to-default widget location table
  1129. X * converter.
  1130. X */
  1131. {
  1132. X    XtAddConverter(XtRString, XtRPointer, cvtStrToDefLoc, NULL, 0);
  1133. X    XtAddConverter(XtRString, XtROptions, cvtStrToOpts, NULL, 0);
  1134. }
  1135. X
  1136. X
  1137. X
  1138. X
  1139. /* 
  1140. X * Table Management Functions
  1141. X *
  1142. X * Default table is a linear null terminated array,  the location
  1143. X * array is a linear dynamic array.  Both should be replaced
  1144. X * with hash tables.
  1145. X */
  1146. X
  1147. static Cardinal LenDefLoc(ptr)
  1148. TableDefLocPtr ptr;
  1149. /*
  1150. X * Returns the length of a DefLoc list.
  1151. X */
  1152. {
  1153. X    Cardinal i;
  1154. X
  1155. X    for (i = 0;  ptr && ptr[i].w_name;  i++) {
  1156. X    /* Null body */
  1157. X    }
  1158. X    return i;
  1159. }
  1160. X
  1161. static TableDefLocPtr CopyDefLoc(ptr)
  1162. TableDefLocPtr ptr;
  1163. /*
  1164. X * Makes a dynamically allocated copy of `ptr'.
  1165. X */
  1166. {
  1167. X    TableDefLocPtr copy;
  1168. X    Cardinal i, len;
  1169. X
  1170. X    len = LenDefLoc(ptr);
  1171. X    if (len) {
  1172. X    copy = (TableDefLocPtr) XtCalloc(len+1, sizeof(struct _TableDefLoc));
  1173. X    for (i = 0;  i < len;  i++) {
  1174. X        copy[i] = ptr[i];
  1175. X    }
  1176. X    copy[i].w_name = (String) 0;
  1177. X    } else {
  1178. X    copy = (TableDefLocPtr) 0;
  1179. X    }
  1180. X    return copy;
  1181. }
  1182. X
  1183. static TableDefLocPtr FindDefLoc(tbl, name)
  1184. TableDefLocPtr tbl;        /* Table to examine */
  1185. String name;            /* Widget name      */
  1186. /*
  1187. X * Scans through `tbl' looking for the name `name'.  Returns
  1188. X * a pointer to the found value or NULL if not found.
  1189. X */
  1190. {
  1191. X    TableDefLocPtr idx;
  1192. X
  1193. X    if (!name) return (TableDefLocPtr) 0;
  1194. X
  1195. X    for (idx = tbl;  idx && idx->w_name;  idx++) {
  1196. X    if (strcmp(idx->w_name, name) == 0) return idx;
  1197. X    }
  1198. X    return (TableDefLocPtr) 0;
  1199. }
  1200. X
  1201. static TableDefLocPtr MergeDefLoc(source, dest)
  1202. TableDefLocPtr source;        /* Original table     */
  1203. TableDefLocPtr dest;        /* Additional entries */
  1204. /*
  1205. X * Returns a table where the entries in `dest' have been
  1206. X * merged with those in `source'.  Similar entries in
  1207. X * `dest' override those in `source'.  The returned
  1208. X * table is allocated.
  1209. X */
  1210. {
  1211. X    TableDefLocPtr result, update;
  1212. X    Cardinal s_len, d_len;
  1213. X    Cardinal i, j;
  1214. X
  1215. X    s_len = LenDefLoc(source);
  1216. X    d_len = LenDefLoc(dest);
  1217. X    result = (TableDefLocPtr)
  1218. X      XtCalloc(s_len + d_len + 1, sizeof(struct _TableDefLoc));
  1219. X    for (i = 0;  i < s_len;  i++) {
  1220. X    result[i] = source[i];
  1221. X    }
  1222. X    /* Add null termination */
  1223. X    result[i].w_name = (String) 0;
  1224. X    /* Now merge the results */
  1225. X    for (j = 0;  j < d_len;  j++) {
  1226. X    if (update = FindDefLoc(result, dest[j].w_name)) {
  1227. X        update->loc = dest[j].loc;
  1228. X    } else {
  1229. X        /* Add to end */
  1230. X        result[i].w_name = dest[j].w_name;
  1231. X        result[i].loc = dest[j].loc;
  1232. X        i += 1;
  1233. X        result[i].w_name = (String) 0;
  1234. X    }
  1235. X    }
  1236. X    return result;
  1237. }
  1238. X
  1239. X
  1240. X
  1241. static TableLocTblPtr TblInitLocTbl()
  1242. /*
  1243. X * Returns a newly allocated location table.  This is implemented
  1244. X * at the moment as dynamic array.  Eventually,  a hash table
  1245. X * will be used.
  1246. X */
  1247. {
  1248. X    TableLocTblPtr rtn;
  1249. X
  1250. X    rtn = (TableLocTblPtr) XtMalloc(sizeof(struct _TableLocTbl));
  1251. X    rtn->n_layout = 0;
  1252. X    rtn->a_layout = INIT_TBL_SIZE;
  1253. X    rtn->locs = (TableLocEntryPtr)
  1254. X      XtCalloc(INIT_TBL_SIZE, sizeof(TableLocEntry));
  1255. X    return rtn;
  1256. }
  1257. X
  1258. static void TblInsertLoc(tbl, w, locp)
  1259. TableLocTblPtr tbl;        /* Table for insertion             */
  1260. Widget w;            /* Subwidget to place              */
  1261. TableLocPtr locp;        /* Widget location information     */
  1262. /*
  1263. X * Inserts an item into the location table.  If there is already
  1264. X * an entry for the widget,  it is replaced by this one.  If there
  1265. X * is no room,  additional room is allocated.
  1266. X */
  1267. {
  1268. X    int i;
  1269. X
  1270. X    for (i = 0;  i < tbl->n_layout;  i++) {
  1271. X    if (tbl->locs[i].w == w) {
  1272. X        tbl->locs[i].loc = *locp;
  1273. X        return;
  1274. X    }
  1275. X    }
  1276. X    /* Not in the table */
  1277. X    if (tbl->n_layout >= tbl->a_layout) {
  1278. X    /* Make more space */
  1279. X    tbl->a_layout += tbl->a_layout;
  1280. X    tbl->locs = (TableLocEntryPtr)
  1281. X      XtRealloc(tbl->locs, tbl->a_layout * sizeof(TableLocEntry));
  1282. X    }
  1283. X    tbl->locs[tbl->n_layout].w = w;
  1284. X    tbl->locs[tbl->n_layout].loc = *locp;
  1285. X    tbl->n_layout += 1;
  1286. }
  1287. X
  1288. static TableLocPtr TblLocLookup(tbl, w)
  1289. TableLocTblPtr tbl;        /* Table for lookup      */
  1290. Widget w;            /* What widget to lookup */
  1291. /*
  1292. X * Looks up widget `w' in the hard widget position table.
  1293. X * Returns NULL if it can't find the widget.
  1294. X */
  1295. {
  1296. X    int i;
  1297. X
  1298. X    for (i = 0;  i < tbl->n_layout;  i++) {
  1299. X    if (tbl->locs[i].w == w) {
  1300. X        return &(tbl->locs[i].loc);
  1301. X    }
  1302. X    }
  1303. X    return (TableLocPtr) 0;
  1304. }
  1305. X
  1306. static void TblFreeLocTbl(tbl)
  1307. TableLocTblPtr tbl;        /* Table to free */
  1308. /*
  1309. X * Frees memory resources of `tbl'.
  1310. X */
  1311. {
  1312. X    XtFree((char *) (tbl->locs));
  1313. X    XtFree((char *) tbl);
  1314. }
  1315. X
  1316. X
  1317. X
  1318. static void TblInitialize(request, new)
  1319. Widget request;            /* Values from resources */
  1320. Widget new;            /* Actual widget         */
  1321. /*
  1322. X * Intializes appropriate fields in instance record.
  1323. X */
  1324. {
  1325. X    TableWidget old = (TableWidget) request;
  1326. X    TableWidget tw = (TableWidget) new;
  1327. X
  1328. X    tw->table.init_layout = CopyDefLoc(old->table.init_layout);
  1329. X    tw->table.layout_db = (TableDefLocPtr) 0;
  1330. X    tw->table.real_layout = TblInitLocTbl();
  1331. X    tw->table.vec_state = INVALID;
  1332. X    tw->table.num_rows = tw->table.num_cols = 0;
  1333. X    tw->table.rows = (TableVecPtr) 0;
  1334. X    tw->table.cols = (TableVecPtr) 0;
  1335. X    tw->table.vec_height = 0;
  1336. X    tw->table.vec_width = 0;
  1337. }
  1338. X
  1339. X
  1340. X
  1341. static TableLocTblPtr GetManaged(nw, wl)
  1342. Cardinal nw;            /* Number of widgets */
  1343. WidgetList wl;            /* Widget list       */
  1344. /*
  1345. X * Returns those widgets in `wl' that are managed and looks
  1346. X * up their table postions.  If no table position is found,
  1347. X * the widget is placed at 0,0 with a span of 1 with no options.
  1348. X */
  1349. {
  1350. X    TableLocTblPtr result;
  1351. X    Cardinal i;
  1352. X
  1353. X    result = TblInitLocTbl();
  1354. X    for (i = 0;  i < nw;  i++) {
  1355. X    if (XtIsManaged(wl[i])) {
  1356. X        if (result->n_layout >= result->a_layout) {
  1357. X        /* Make more space */
  1358. X        result->a_layout += result->a_layout;
  1359. X        result->locs = (TableLocEntryPtr)
  1360. X          XtRealloc(result->locs,
  1361. X                result->a_layout * sizeof(TableLocEntry));
  1362. X        }
  1363. X        result->locs[result->n_layout].w = wl[i];
  1364. X        if (!TblFindChild(wl[i],
  1365. X                  &(result->locs[result->n_layout].loc.ax),
  1366. X                  &(result->locs[result->n_layout].loc.ay),
  1367. X                  &(result->locs[result->n_layout].loc.h_span),
  1368. X                  &(result->locs[result->n_layout].loc.v_span),
  1369. X                  &(result->locs[result->n_layout].loc.options))) {
  1370. X        /* Can't find location -- make one up */
  1371. X        result->locs[result->n_layout].loc.ax = 0;
  1372. X        result->locs[result->n_layout].loc.ay = 0;
  1373. X        result->locs[result->n_layout].loc.h_span = 1;
  1374. X        result->locs[result->n_layout].loc.v_span = 1;
  1375. X        result->locs[result->n_layout].loc.options = 0;
  1376. X        }
  1377. X        result->n_layout += 1;
  1378. X    }
  1379. X    }
  1380. X    return result;
  1381. }
  1382. X
  1383. X
  1384. static Cardinal VecSize(mw, val_func)
  1385. TableLocTblPtr mw;        /* List of managed widgets           */
  1386. void (*val_func)();        /* Returns either row or column info */
  1387. /*
  1388. X * Determines the vector size by examining locations of all
  1389. X * widgets in `mw'.  Basically determines the maximum of loc+span.
  1390. X */
  1391. {
  1392. X    Cardinal i, loc, span;
  1393. X    Cardinal result = 0;
  1394. X    Boolean small_flag;
  1395. X
  1396. X    for (i = 0;  i < mw->n_layout;  i++) {
  1397. X    (*val_func)(&(mw->locs[i]), &loc, &span, &small_flag);
  1398. X    if (result < loc+span) {
  1399. X        result = loc+span;
  1400. X    }
  1401. X    }
  1402. X    return result;
  1403. }
  1404. X
  1405. X
  1406. X
  1407. static void SetVecOptions(mw, val_func, vec)
  1408. TableLocTblPtr mw;        /* Managed widget list */
  1409. void (*val_func)();        /* Row or col info     */
  1410. TableVecPtr vec;        /* Spacing vector      */
  1411. /*
  1412. X * Steps through the list of widgets.  If the widget is marked
  1413. X * as having the small flag set,  it sets all corresponding
  1414. X * options in `vec'.
  1415. X */
  1416. {
  1417. X    Cardinal i, j;
  1418. X    Cardinal loc, span;
  1419. X    Boolean small_flag;
  1420. X
  1421. X    for (i = 0;  i < mw->n_layout;  i++) {
  1422. X    (*val_func)(&(mw->locs[i]), &loc, &span, &small_flag);
  1423. X    if (small_flag) {
  1424. X        for (j = loc;  j < loc+span;  j++) {
  1425. X        vec[j].mask = VEC_MINIMIZE;
  1426. X        }
  1427. X    }
  1428. X    }
  1429. }
  1430. X
  1431. X
  1432. /* Must be set before span_cmp works */
  1433. static void (*span_cmp_val_func)();
  1434. X
  1435. static int span_cmp(a, b)
  1436. char *a, *b;
  1437. /*
  1438. X * Compares items based on span.
  1439. X */
  1440. {
  1441. X    Cardinal loc_a, loc_b;
  1442. X    Cardinal span_a, span_b;
  1443. X    Boolean small_flag;
  1444. X
  1445. X    (*span_cmp_val_func)((TableLocEntryPtr) a, &loc_a, &span_a, &small_flag);
  1446. X    (*span_cmp_val_func)((TableLocEntryPtr) b, &loc_b, &span_b, &small_flag);
  1447. X    return span_a - span_b;
  1448. }
  1449. X
  1450. X
  1451. static Cardinal FindDistrib(loc, span, vec, result)
  1452. Cardinal loc, span;        /* Widget loc and span */
  1453. TableVecPtr vec;        /* Spacing vector     */
  1454. Cardinal *result;        /* Result array       */
  1455. /*
  1456. X * This routine fills in `result' with a list of indices
  1457. X * into the spacing vector suitable for distributing required
  1458. X * space.  Normally,  it skips those items marked as
  1459. X * VEC_MINIMIZE.  However,  if there aren't any non-VEC_MINIMIZE
  1460. X * spaces,  all of them become candidates.
  1461. X */
  1462. {
  1463. X    Cardinal i, count;
  1464. X
  1465. X    count = 0;
  1466. X    for (i = loc;  i < loc+span;  i++) {
  1467. X    if (vec[i].mask & VEC_MINIMIZE) continue;
  1468. X    result[count++] = i;
  1469. X    }
  1470. X    if (count == 0) {
  1471. X    /* Add them all back in */
  1472. X    for (i = loc;  i < loc+span;  i++) {
  1473. X        result[count++] = i;
  1474. X    }
  1475. X    }
  1476. X    return count;
  1477. }
  1478. X
  1479. X
  1480. static void DoDistrib(n_dist, distrib, loc, span, vec, size, inter)
  1481. Cardinal n_dist;        /* Number of distribution points */
  1482. Cardinal *distrib;        /* Indicies into `vec'           */
  1483. Cardinal loc, span;        /* Widget location and span      */
  1484. TableVecPtr vec;        /* Spacing vector                */
  1485. Dimension size;            /* Size of widget                */
  1486. Dimension inter;        /* inter {col,row} spacing     */
  1487. /*
  1488. X * If `size' is larger than the current sum of space in `vec'
  1489. X * specified by `loc' and `span',  the difference in space
  1490. X * is evenly added to each vector entry given by `distrib'.
  1491. X */
  1492. {
  1493. X    Cardinal sum = 0;
  1494. X    Cardinal i;
  1495. X    int diff, amt;
  1496. X
  1497. X    for (i = loc;  i < loc+span;  i++) {
  1498. X    sum += vec[i].value;
  1499. X    }
  1500. X    if (span > 1)
  1501. X    sum += (span-1) * inter;
  1502. X    diff = size - sum;
  1503. X    if (diff > 0) {
  1504. X    /* Distribution required */
  1505. X    amt = diff / n_dist;
  1506. X    for (i = 0;  i < n_dist-1;  i++) {
  1507. X        vec[distrib[i]].value += amt;
  1508. X        diff -= amt;
  1509. X    }
  1510. X    /* Last one deincremented by remaining space */
  1511. X    vec[distrib[i]].value += diff;
  1512. X    }
  1513. }
  1514. X
  1515. X
  1516. X
  1517. X
  1518. static Cardinal CompVector(mw, val_func, size_func, inter, result)
  1519. TableLocTblPtr mw;        /* List of managed widgets with locs */
  1520. void (*val_func)();        /* Returns either row or column info */
  1521. Dimension (*size_func)();    /* Returns desired size of subwidget */
  1522. Dimension inter;        /* inter {row,col} spacing         */
  1523. TableVecPtr *result;        /* Result vector                     */
  1524. /*
  1525. X * This routine computes the values for either the row or column
  1526. X * spacing vector.  The strategy is as follows:
  1527. X *   1. Scan mw and determine number of entrys in result and allocate
  1528. X *   2. Scan list and set appropriate vector flags.
  1529. X *   3. Sort the managed widgets in span order (low to high)
  1530. X *   4. For each item in sorted list:
  1531. X *      A. Determine distribution locations.
  1532. X *      B. Distribute any needed space to locations.
  1533. X * There are some inefficiencies here that could be overcome.
  1534. X */
  1535. {
  1536. X    Cardinal res_num, i;
  1537. X    Cardinal n_dist, *distrib;
  1538. X    Cardinal loc, span;
  1539. X    Boolean small_flag;
  1540. X
  1541. X    res_num = VecSize(mw, val_func);
  1542. X    if (res_num) {
  1543. X    *result = (TableVecPtr) XtCalloc(res_num, sizeof(struct _TableVector));
  1544. X    for (i = 0;  i < res_num;  i++) {
  1545. X        (*result)[i].mask = 0;
  1546. X        (*result)[i].value = 0;
  1547. X    }
  1548. X    SetVecOptions(mw, val_func, *result);
  1549. X
  1550. X    span_cmp_val_func = val_func;
  1551. X    qsort((char *) mw->locs, (int) mw->n_layout,
  1552. X          sizeof(TableLocEntry), span_cmp);
  1553. X
  1554. X    distrib = (Cardinal *) XtCalloc(res_num, sizeof(Cardinal));
  1555. X    for (i = 0;  i < mw->n_layout;  i++) {
  1556. X        (*val_func)(&(mw->locs[i]), &loc, &span, &small_flag);
  1557. X        n_dist = FindDistrib(loc, span, *result, distrib);
  1558. X        DoDistrib(n_dist, distrib, loc, span, *result,
  1559. X              (*size_func)(mw->locs[i].w), inter);
  1560. X    }
  1561. X    return res_num;
  1562. X    } else {
  1563. X    *result = (TableVecPtr) 0;
  1564. X    return 0;
  1565. X    }
  1566. X    /*NOTREACHED*/
  1567. }
  1568. X
  1569. X
  1570. static void ColValues(oneloc, loc, span, small_flag)
  1571. TableLocEntryPtr oneloc;    /* Widget data       */
  1572. Cardinal *loc;            /* Location in array */
  1573. Cardinal *span;            /* Spanning distance */
  1574. Boolean *small_flag;        /* Whether locked    */
  1575. /*
  1576. X * This routine returns column data from `oneloc'.  It is
  1577. X * passed to CompVector when computing the column spacing vector.
  1578. X */
  1579. {
  1580. X    *loc = oneloc->loc.ax;
  1581. X    *span = oneloc->loc.h_span;
  1582. X    *small_flag = oneloc->loc.options & TBL_SM_WIDTH;
  1583. }
  1584. X
  1585. static void RowValues(oneloc, loc, span, small_flag)
  1586. TableLocEntryPtr oneloc;    /* Widget data       */
  1587. Cardinal *loc;            /* Location in array */
  1588. Cardinal *span;            /* Spanning distance */
  1589. Boolean *small_flag;        /* Whether locked    */
  1590. /*
  1591. X * This routine returns row data from `oneloc'.  It is
  1592. X * passed to CompVector when computing the row spacing vector.
  1593. X */
  1594. {
  1595. X    *loc = oneloc->loc.ay;
  1596. X    *span = oneloc->loc.v_span;
  1597. X    *small_flag = oneloc->loc.options & TBL_SM_HEIGHT;
  1598. }
  1599. X
  1600. static Dimension ColSize(w)
  1601. Widget w;            /* Child widget */
  1602. /*
  1603. X * This routine returns the desired width of the widget `w'.
  1604. X * It is used by CompVector when computing the column vector.
  1605. X */
  1606. {
  1607. X    Dimension r_size, r_border;
  1608. X    XtWidgetGeometry child;
  1609. X
  1610. X    r_size = w->core.width;
  1611. X    r_border = w->core.border_width;
  1612. X    (void) XtQueryGeometry(w, (XtWidgetGeometry *) 0, &child);
  1613. X    if (child.request_mode & CWWidth) r_size = child.width;
  1614. X    if (child.request_mode & CWBorderWidth) r_border = child.border_width;
  1615. X    return r_size + r_border + r_border;
  1616. }
  1617. X
  1618. static Dimension RowSize(w)
  1619. Widget w;            /* Child widget */
  1620. /*
  1621. X * This routine returns the desired width of the widget `w'.
  1622. X * It is used by CompVector when computing the column vector.
  1623. X */
  1624. {
  1625. X    Dimension r_size, r_border;
  1626. X    XtWidgetGeometry child;
  1627. X
  1628. X    r_size = w->core.height;
  1629. X    r_border = w->core.border_width;
  1630. X    (void) XtQueryGeometry(w, (XtWidgetGeometry *) 0, &child);
  1631. X    if (child.request_mode & CWHeight) r_size = child.height;
  1632. X    if (child.request_mode & CWBorderWidth) r_border = child.border_width;
  1633. X    return r_size + r_border + r_border;
  1634. }
  1635. X
  1636. X
  1637. X
  1638. /*ARGSUSED*/
  1639. static void TblRecompVectors(tw)
  1640. TableWidget tw;            /* Table widget */
  1641. /*
  1642. X * Recomputes the size vectors in the table widget by
  1643. X * examining the preferred sizes of subwidgets.  The
  1644. X * following fields are modified: num_rows, num_cols,
  1645. X * rows, cols, vec_height, and vec_width.
  1646. X */
  1647. {
  1648. X    TableLocTblPtr managed;
  1649. X    Cardinal i;
  1650. X
  1651. X    /* Free existing vectors */
  1652. X    if (tw->table.cols) XtFree((char *) (tw->table.cols));
  1653. X    tw->table.num_cols = 0;
  1654. X    if (tw->table.rows) XtFree((char *) (tw->table.rows));
  1655. X    tw->table.num_rows = 0;
  1656. X    tw->table.vec_width = tw->table.vec_height = 0;
  1657. X
  1658. X    /* Generate list of managed widgets with locations */
  1659. X    managed = GetManaged(tw->composite.num_children, tw->composite.children);
  1660. X    
  1661. X    /* Handle columns */
  1662. X    tw->table.num_cols = CompVector(managed, ColValues, ColSize,
  1663. X                    tw->table.col_spacing, &(tw->table.cols));
  1664. X    for (i = 0;  i < tw->table.num_cols;  i++) {
  1665. X    tw->table.vec_width += tw->table.cols[i].value;
  1666. X    }
  1667. X      
  1668. X
  1669. X    /* Handle rows */
  1670. X    tw->table.num_rows = CompVector(managed, RowValues, RowSize,
  1671. X                    tw->table.row_spacing, &(tw->table.rows));
  1672. X    for (i = 0;  i < tw->table.num_rows;  i++) {
  1673. X    tw->table.vec_height += tw->table.rows[i].value;
  1674. X    }
  1675. X
  1676. X    TblFreeLocTbl(managed);
  1677. }
  1678. X
  1679. X
  1680. static void TblRequestResize(tw)
  1681. TableWidget tw;            /* Table widget */
  1682. /*
  1683. X * Asks the parent to become the size given by the row and
  1684. X * column vectors.  Precondition: vec_state must be MINIMUM.
  1685. X */
  1686. {
  1687. X    XtGeometryResult rtn;
  1688. X    Dimension act_width, act_height;
  1689. X    Dimension r_width, r_height;
  1690. X
  1691. X    act_width = tw->table.vec_width + 2*tw->table.int_width +
  1692. X      (tw->table.num_cols-1)*tw->table.col_spacing;
  1693. X    act_height = tw->table.vec_height + 2*tw->table.int_height +
  1694. X      (tw->table.num_rows-1)*tw->table.row_spacing;
  1695. X    rtn = XtMakeResizeRequest((Widget) tw, act_width, act_height,
  1696. X                  &r_width, &r_height);
  1697. X    switch (rtn) {
  1698. X    case XtGeometryYes:
  1699. X    case XtGeometryNo:
  1700. X    /* Either case -- no action required */
  1701. X    break;
  1702. X    case XtGeometryAlmost:
  1703. X    if ((r_width >= act_width) &&
  1704. X        (r_height >= act_height)) {
  1705. X        (void) XtMakeResizeRequest((Widget) tw, r_width, r_height,
  1706. X                       (Dimension *) 0, (Dimension *) 0);
  1707. X    }
  1708. X    break;
  1709. X    }
  1710. }
  1711. X
  1712. X
  1713. X
  1714. static void ExtraSpace(num, vec, size)
  1715. Cardinal num;            /* Length of `vec' */
  1716. TableVecPtr vec;        /* Spacing vector  */
  1717. Dimension size;            /* Overall size    */
  1718. /*
  1719. X * If `size' is larger than the sum of all widths in `vec',
  1720. X * the extra space is distributed evenly among appropriate
  1721. X * candidates of `vec'.
  1722. X */
  1723. {
  1724. X    Cardinal i, ndist, sum = 0;
  1725. X    Cardinal *dist;
  1726. X    int diff, amt;
  1727. X
  1728. X    for (i = 0;  i < num;  i++) sum += vec[i].value;
  1729. X    diff = size - sum;
  1730. X    if (diff > 0) {
  1731. X    /* Have to distribute space */
  1732. X    dist = (Cardinal *) XtCalloc(num, sizeof(Cardinal));
  1733. X    ndist = FindDistrib(0, num, vec, dist);
  1734. X    amt = diff/ndist;
  1735. X    for (i = 0;  i < ndist-1;  i++) {
  1736. X        vec[dist[i]].value += amt;
  1737. X        diff -= amt;
  1738. X    }
  1739. X    vec[dist[i]].value += diff;
  1740. X    XtFree((char *) dist);
  1741. X    }
  1742. }
  1743. X
  1744. X
  1745. static Dimension SumVec(loc, span, vec, start, inter, end)
  1746. Position loc, span;        /* Start and length      */
  1747. TableVecPtr vec;        /* Spacing vector        */
  1748. Dimension start;        /* Added before sum      */
  1749. Dimension inter;        /* Added between items   */
  1750. Dimension end;            /* Added after sum       */
  1751. /*
  1752. X * Returns the sum of the space in `vec' from `loc' for length `span'.
  1753. X * Adds in the appropriate padding given by `start', `inter' and `end'.
  1754. X */
  1755. {
  1756. X    Position i;
  1757. X    Dimension sum = 0;
  1758. X
  1759. X    for (i = loc;  i < loc+span;  i++) sum += vec[i].value;
  1760. X    return sum + start + end + ((span >= 0) ? span*inter : 0);
  1761. }
  1762. X
  1763. static void PlaceWidget(w, x, y, width, height, rw, rh, opt)
  1764. Widget w;            /* What widget to place  */
  1765. Position x, y;            /* Location of space     */
  1766. Dimension width, height;    /* Size of space         */
  1767. Dimension rw, rh;        /* Actual size           */
  1768. XXtTblMask opt;            /* Justification options */
  1769. /*
  1770. X * This routine moves the widget `w' inside the space given
  1771. X * by x, y, width, height.  Its location in this space
  1772. X * is determined by looking at the justification options of 
  1773. X * `opt'.
  1774. X */
  1775. {
  1776. X    Position rx, ry;
  1777. X
  1778. X    if (opt & TBL_LEFT) rx = x;
  1779. X    else if (opt & TBL_RIGHT) rx = x + width - rw;
  1780. X    else rx = x + (width-rw)/2;
  1781. X    if (opt & TBL_TOP) ry = y;
  1782. X    else if (opt & TBL_BOTTOM) ry = y + height - rh;
  1783. X    else ry = y + (height-rh)/2;
  1784. #ifdef NOTDEF
  1785. X    rx += w->core.border_width;
  1786. X    ry += w->core.border_width;
  1787. #endif
  1788. X    
  1789. /*    XtMoveWidget(w, rx, ry);*/
  1790. X    _XmMoveObject((RectObj) w, rx, ry);
  1791. }
  1792. X
  1793. X
  1794. static void DoPlace(managed, cvec, rvec, vp, hp, rs, cs)
  1795. TableLocTblPtr managed;        /* List of managed widgets with locs */
  1796. TableVecPtr cvec, rvec;        /* Column and row spacing vector     */
  1797. Dimension vp, hp;        /* Vertical and horizontal padding   */
  1798. Dimension rs, cs;        /* Row and column interspace         */
  1799. /*
  1800. X * This routine places each widget in `managed' according to the
  1801. X * spacing vectors `cvec' and `rvec' and the widget placement
  1802. X * options (justification and resizing).  First,  if allowed,
  1803. SHAR_EOF
  1804. true || echo 'restore of Table.c failed'
  1805. fi
  1806. echo 'End of  part 1'
  1807. echo 'File Table.c is continued in part 2'
  1808. echo 2 > _shar_seq_.tmp
  1809. exit 0
  1810. -- 
  1811. --
  1812. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  1813. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  1814. Sunnyvale, California 94086            at&t: 408/522-9236
  1815.