home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume20 / pexdraw / part01 < prev    next >
Encoding:
Text File  |  1993-06-07  |  59.2 KB  |  1,282 lines

  1. Newsgroups: comp.sources.x
  2. From: jch@okimicro.oki.com (Jan Hardenbergh)
  3. Subject: v20i011:  pexdraw - A PEX drawing program, Part01/14
  4. Message-ID: <csx-v20i011=pexdraw.095954@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: dd54a9f29bf8f9af6eeeff44ef45c02c
  6. Sender: chris@sparky.imd.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Tue, 8 Jun 1993 15:00:18 GMT
  9. Approved: chris@sparky.imd.sterling.com
  10.  
  11. Submitted-by: jch@okimicro.oki.com (Jan Hardenbergh)
  12. Posting-number: Volume 20, Issue 11
  13. Archive-name: pexdraw/part01
  14. Environment: X11R5, PEX
  15.  
  16. [ I could not test this program (no PEX) and it did not have a man page ]
  17. [     Chris                                        ]
  18.  
  19. pexdraw is a drawing and exploring program for PEX & PEXlib.
  20.  
  21. I have used it to explore application issues and at times as a test
  22. vehicle.  It also serves as a base of examples for a book to be
  23. published by Prentice Hall. "Building Applications with PEXlib".
  24.  
  25. It will run best on a 5.1 PEX server, but will also run on a 5.0 server
  26. with the Workstation resource.
  27. ------------------------------------------------------
  28. #! /bin/sh
  29. # This is a shell archive.  Remove anything before this line, then feed it
  30. # into a shell via "sh file" or similar.  To overwrite existing files,
  31. # type "sh file -c".
  32. # Contents:  README XMU util util/Imakefile util/pexutcmap.h
  33. # Wrapped by chris@sparky on Tue Jun  8 09:46:30 1993
  34. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  35. echo If this archive is complete, you will see the following message:
  36. echo '          "shar: End of archive 1 (of 14)."'
  37. if test -f 'README' -a "${1}" != "-c" ; then 
  38.   echo shar: Will not clobber existing file \"'README'\"
  39. else
  40.   echo shar: Extracting \"'README'\" \(6441 characters\)
  41.   sed "s/^X//" >'README' <<'END_OF_FILE'
  42. X =S+H= @(#)README    1.5 Oki 93/05/25
  43. XMAY-93
  44. X
  45. Xpexdraw README.
  46. X
  47. Xpexdraw is a drawing and exploring program for PEX & PEXlib.
  48. X
  49. XI have used it to explore application issues and at times as a test
  50. Xvehicle.  It also serves as a base of examples for a book to be
  51. Xpublished by Prentice Hall. "Building Applications with PEXlib".
  52. X
  53. XIt will run best on a 5.1 PEX server, but will also run on a 5.0 server
  54. Xwith the Workstation resource.
  55. X
  56. X
  57. XThis distribution consists of:
  58. X
  59. X-rw-r-----1005/100   4957 May 25 01:53 1993 README
  60. X-r--r-----1005/100  66040 May 24 14:55 1993 pexdraw.c
  61. X-r--r-----1005/100  12694 May 24 14:55 1993 pexdraw.h
  62. X-r--r-----1005/100 113725 May 24 14:55 1993 pexdraw.uil
  63. X-rw-r-----1005/100   3809 May 25 12:53 1993 Imakefile
  64. X-r--r-----1005/100  20761 May 24 14:55 1993 rdr.c
  65. X-r--r-----1005/100  15095 May 24 14:55 1993 wks.c
  66. X-r--r-----1005/100  27419 May 24 14:55 1993 fb.c
  67. X-r--r-----1005/100  43663 May 24 14:55 1993 ui.c
  68. X-r--r-----1005/100  11454 May 24 14:55 1993 ui_x.c
  69. X-r--r-----1005/100  13341 May 11 13:43 1993 init.c
  70. X-rw-r--r--1005/100  17902 May  4 10:48 1993 util/HP.PEXUt
  71. X-r--r-----1005/100   4510 May 25 12:24 1993 rgbc.c
  72. X-r--r-----1005/100  12619 May 25 12:45 1993 plcube.c
  73. X-r--r-----1005/100   3911 May 25 12:25 1993 sofas.c
  74. X-r--r-----1005/100 119825 May 25 12:24 1993 teapot.c
  75. X-r--r-----1005/100  13664 May 25 13:53 1993 plogo.c
  76. Xdrwxr-xr-x1005/1        0 Apr 25 23:50 1993 XMU/std cmap stuff.
  77. X
  78. X
  79. XTO BUILD:
  80. X=========
  81. X
  82. XHopefully you have xmkmf, else use imake.  Since I have included the
  83. XHP DB utilities, you need to make Makefiles, too.
  84. X
  85. XStep 1 make the makefiles:
  86. X  If you have Motif installed, do this:
  87. X  % imake  -I/usr/lib/X11/config -DMOTIF -DUseInstalled
  88. X  Otherwise: 
  89. X  % imake  -I/usr/lib/X11/config -DNO_MOTIF -DUseInstalled
  90. X
  91. X  In either case:
  92. X  % make Makefiles
  93. X
  94. X  %make pexdraw ( or pxd, if no Motif )
  95. X
  96. XTO USE:
  97. X=======
  98. X
  99. Xpexdraw is compose of several tools and several forms.  The tools allow
  100. Xfor direct manipulation of the geometry and viewing paramters.
  101. X
  102. X            Left Button       Middle Button      Right Button
  103. X
  104. XPointer     pickOne*          translateSelected  stretchSelected
  105. XLine        line              line               rotateView
  106. XTriStrip    add point         finish TriStrip    rotateView
  107. XNURBCurve   add point         finish NURBCurve   rotateView
  108. XText        insert text       ..                 rotateView
  109. XPolygon     add point         finish Polygon     rotateView
  110. XCircle      circle            ..                 rotateView
  111. Xview        rotateView        ..                 rotateView
  112. Xzoom        zoomWindow        resetWindow        rotateView
  113. XmodelClip   add model clip    nothing            rotateView
  114. X
  115. XTo walk through the features of pexdraw.
  116. X- use button 1 to sketch in one line.  It is selected
  117. X- sketch in a second line, the first is deselected
  118. X- Pick up the Pointer tool, select the first line
  119. X- Use the button 2 to translate
  120. X- Use the button 3 to stretch
  121. X- Pull down the Edit Menu and delete it
  122. X- Insert a TriStrip - use the SurfaceAttrs Form to make it solid (must Apply)
  123. X- select the Set view item in the Options (Options) menu.
  124. X  set various view paramters and press apply.
  125. X- use the view tool (two circles)
  126. X- Start spinning slowly (this will spin the struct of the selected object, or
  127. X                         if not is selected the structure being created)
  128. X- Stop spinning slowly, by hitting the same menu button
  129. X- Use the Execute menu under File to execute a structure generating 
  130. X  client - plcube, plogo, sofas, rgbc. This will use the UNIX system() call.
  131. X  Select the red line and set the surface properties & spin slow.
  132. X  [ You can now have several objects spinning independently, keep selecting
  133. X    and using the menu, if an object is spinning the menu will turn it off ]
  134. X- Use the execute menu again and insert something else. Select that red line
  135. X  and start spinning. Now use the Spin Option menu items to bring up the
  136. X  spin form. You can change a bunch of stuff about how it is spinning.
  137. X- Delete All
  138. X        
  139. X
  140. X- Delete All
  141. X- use the sphere item in the Options menu to insert a sphere.
  142. X  (sphere alternates between a triStrip Cuboctohedron & a ration NURB surf)
  143. X- pick the blue line
  144. X- select the surfaceAttrs menu, this brings up a form
  145. X- set various attributes
  146. X
  147. X- use the NURBSCurve tool.
  148. X- Use the Change Color option to bring up a RGB slider form.
  149. X- Use the MC tool to insert a model clip plane.
  150. X- You can execute a structure from another structure. 
  151. X  - delete all, Execute sofas, select it, stat it spinning, bring up
  152. X    spin form. Change spin point to -1, -1, -1.
  153. X  - Execute rgbc, now, use the Execute Strux menu item and click on red
  154. X    line of rgbc. Now there are two rgbc . click on the rgbc line again
  155. X    and start it spinning. now change the spin point to -1,-1,-1 and the
  156. X    offset to 1.5, 1.5, 1.5. If you have a fast machine, turn on solid
  157. X    & Gouraud. Now Unpost Strux. the SOAFS is orbitting the end of the 
  158. X    line and the RGBC is orbitting the center of the SOFAS. It's fun.    
  159. X
  160. X
  161. XIf you are running on a PEX 5.1 server you can do a "draw through" select
  162. Xto change colors of objects. This uses the PickAll features.
  163. X
  164. XAll of the lines, tristrips, NURBSCurve & Text obey the translate &
  165. Xstretch.  Ideally, stretch would change the character height & expansion
  166. Xattributes of the test...
  167. X
  168. Xpexdraw expects structures to be in a certan form - see InitStrux.
  169. X
  170. XYou can build a version of pexdraw that does not use Motif, "make pxd".
  171. XThis will use the file ui_x.c instead of ui.c.  ui_x.c is not totally up
  172. Xto date with ui.c, but it will give you something to play with.
  173. X
  174. XCrCmap.c is included due to bugfixes. If you have problems with pexdraw
  175. Xhanging when running against TrueColor or DirectColor visual, build an
  176. Xlink CrCmap.c - If your libXmu is up to date with the patches you should
  177. Xnot need to worry about them.  If you are running against 24 bit servers
  178. Xand you hang, then you need to compile & link the files in XMU
  179. XThese were released in public patch # 20. export.lcs.mit.edu pub/R5/fixes.
  180. XIT WOULD BE BETTER TO GET THIS FROM AN UP TO DATE SOURCE. 
  181. X
  182. Xutil/ contains the HP.PEXUt utilities. These are still in flux and you
  183. Xshould get the latest from export.lcs.mit.edu in /contrib/PEXlib.
  184. X
  185. X
  186. X-Jan "YON" Hardenbergh   jch@oki.com  /  jch@world.std.com  (508)-624-7000
  187. XOki Advanced Products Division,  100 Nickerson Road, Marlborough, MA 01752
  188. X
  189. X"Whatever you can do, or dream you can do, begin it. 
  190. X Boldness has genius, power and magic in it." w h murray.
  191. END_OF_FILE
  192.   if test 6441 -ne `wc -c <'README'`; then
  193.     echo shar: \"'README'\" unpacked with wrong size!
  194.   fi
  195.   # end of 'README'
  196. fi
  197. if test ! -d 'XMU' ; then
  198.     echo shar: Creating directory \"'XMU'\"
  199.     mkdir 'XMU'
  200. fi
  201. if test ! -d 'util' ; then
  202.     echo shar: Creating directory \"'util'\"
  203.     mkdir 'util'
  204. fi
  205. if test -f 'util/Imakefile' -a "${1}" != "-c" ; then 
  206.   echo shar: Will not clobber existing file \"'util/Imakefile'\"
  207. else
  208.   echo shar: Extracting \"'util/Imakefile'\" \(136 characters\)
  209.   sed "s/^X//" >'util/Imakefile' <<'END_OF_FILE'
  210. XINCLUDES = -I.  -I$(TOP) -I$(TOP)/X11/extensions
  211. X
  212. XOBJS = pexutdb.o pexutdbint.o pexutcmap.o pexutcmapint.o pexutcmaphp.o
  213. X
  214. Xall:: $(OBJS)
  215. END_OF_FILE
  216.   if test 136 -ne `wc -c <'util/Imakefile'`; then
  217.     echo shar: \"'util/Imakefile'\" unpacked with wrong size!
  218.   fi
  219.   # end of 'util/Imakefile'
  220. fi
  221. if test -f 'util/pexutcmap.h' -a "${1}" != "-c" ; then 
  222.   echo shar: Will not clobber existing file \"'util/pexutcmap.h'\"
  223. else
  224.   echo shar: Extracting \"'util/pexutcmap.h'\" \(49034 characters\)
  225.   sed "s/^X//" >'util/pexutcmap.h' <<'END_OF_FILE'
  226. X#ifndef PEXUTCMAP_H /* { */
  227. X#define PEXUTCMAP_H
  228. X
  229. X/******************************************************************************/
  230. X/*                                                                            */
  231. X/*  (c) Copyright Hewlett-Packard Company, 1992, Fort Collins, Colorado       */
  232. X/*                                                                            */
  233. X/*                            All Rights Reserved                             */
  234. X/*                                                                            */
  235. X/*  Permission to use, copy, modify, and distribute this software and its     */
  236. X/*  documentation for any purpose and without fee is hereby granted,          */
  237. X/*  provided that the above copyright notices appear in all copies and that   */
  238. X/*  both the copyright notices and this permission notice appear in           */
  239. X/*  supporting documentation, and that the name of Hewlett-Packard not be     */
  240. X/*  used in advertising or publicity pertaining to distribution of the        */
  241. X/*  software without specific, written prior permission.                      */
  242. X/*                                                                            */
  243. X/*  HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS         */
  244. X/*  SOFTWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
  245. X/*  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  Hewlett-Packard    */
  246. X/*  shall not be liable for errors contained herein or direct, indirect,      */
  247. X/*  special, incidental or consequential damages in connection with the       */
  248. X/*  furnishing, performance or use of this software.                          */
  249. X/*                                                                            */
  250. X/******************************************************************************/
  251. X
  252. X/******************************************************************************/
  253. X/*                                                                            */
  254. X/* $Source: /BE700/9.0/gtd/R903/wbuild/PEX5/head/RCS/pexutcmap.h,v $                               */
  255. X/* $Date: 93/03/17 14:14:23 $                                                 */
  256. X/* $Revision: 500.1.200.1 $                                                   */
  257. X/*                                                                            */
  258. X/* Description:                                                               */
  259. X/*   Interface header file for PEXUt colormap/visual utilities.               */
  260. X/*                                                                            */
  261. X/* Notes:                                                                     */
  262. X/*                                                                            */
  263. X/******************************************************************************/
  264. X
  265. X
  266. X#ifndef NeedFunctionPrototypes
  267. X#if defined(FUNCPROTO) || defined(__STDC__) || \
  268. X    defined(__cplusplus) || defined(c_plusplus)
  269. X#define NeedFunctionPrototypes  1
  270. X#else
  271. X#define NeedFunctionPrototypes  0
  272. X#endif /* FUNCPROTO, __STDC__, __cplusplus, c_plusplus */
  273. X#endif /* NeedFunctionPrototypes */
  274. X
  275. X
  276. X#ifdef __cplusplus   /* do not leave open across includes */
  277. Xextern "C" {         /* for C++ V2.0 */
  278. X#endif
  279. X
  280. X
  281. X/*
  282. X    The following structure type is used to specify criteria for
  283. X    selecting a Visual.  The fields are used as follows:
  284. X
  285. X    hard_criteria_mask    a mask of bits for "hard" criteria; that is,
  286. X                for criteria that MUST be met by the Visual;
  287. X                the supported bits are defined below.
  288. X
  289. X    soft_criteria_mask    a mask of bits for "soft" criteria, i.e.
  290. X                criteria that are not required to be met but
  291. X                are "preferred"; supported bits are defined
  292. X                below.
  293. X
  294. X    depth            the criterion value for PEXUtDepth; allowed
  295. X                value is any reasonable Visual depth.
  296. X    
  297. X    min_colors        criterion value for PEXUtMinColors; specifies
  298. X                the minimum number of distinct colors the
  299. X                Visual must support.  Values less than two
  300. X                are illogical, as even monochrome systems have
  301. X                two colors.  The way in which the available 
  302. X                number of colors is computed depends
  303. X                on the Visual class.  When a standard colormap
  304. X                property entry is used, the number of available
  305. X                colors is based on the ramp described in the
  306. X                property.
  307. X
  308. X    min_red            criterion value for (PEXUtMinRed,PEXUtMinGreen,
  309. X    min_green        PEXUtMinBlue) respectively; specify the
  310. X    min_blue        minimum number of (red,green,blue) levels the 
  311. X                Visual must support.  Allowed values are 
  312. X                integer greater than one.
  313. X
  314. X    visual_class        criterion value for PEXUtVisualClass; specifies
  315. X                the X Visual class (one of StaticColor, 
  316. X                PseudoColor, StaticGray, GrayScale, 
  317. X                TrueColor, DirectColor).
  318. X
  319. X    layer            criterion value for PEXUtLayer; one of
  320. X                PEXUtOverlay or PEXUtImage.
  321. X
  322. X    standard_colormap_property     criterion value for 
  323. X                PEXUtStandardColormapProperty; one of True
  324. X                or False.  If True, the Visual must be named
  325. X                in an entry in a standard colormap property
  326. X                in order to satisfy the criterion.
  327. X
  328. X    sharable_colormap    criterion value for PEXUtSharableColormap;
  329. X                one of True or False.  If True, the Visual
  330. X                must be named in a standard colormap property,
  331. X                and furthermore, such Visuals will be favored
  332. X                over Visuals that have higher color resolution.
  333. X
  334. X    double_buffering_capability    criterion value for
  335. X                PEXUtDoubleBufferingCapability; one of
  336. X                PEXUtDbufferNone, PEXUtDbufferPEX, or
  337. X                PEXUtDbufferPEXAndX.  Note that specifying
  338. X                PEXUtDbufferNone "hard" may cause the "best"
  339. X                Visual for PEX rendering to be rejected, since
  340. X                it is likely to be double-buffering-capable.
  341. X
  342. X    color_approx_type    criterion value for PEXUtColorApproxType;
  343. X                one of PEXColorSpace or PEXColorRange.
  344. X                Typically this criterion is only specified if
  345. X                it is PEXColorRange, since most applications
  346. X                need PEXColorSpace.  If specified, the 
  347. X                Visual must be capable of the specifed
  348. X                approximation type.
  349. X*/
  350. X
  351. X
  352. Xtypedef struct {
  353. X    unsigned int        hard_criteria_mask;
  354. X    unsigned int        soft_criteria_mask;
  355. X    unsigned int        depth;
  356. X    int            min_colors;
  357. X    int            min_red;
  358. X    int            min_green;
  359. X    int            min_blue;
  360. X    int            visual_class;
  361. X    int            layer;
  362. X    int            standard_colormap_property;
  363. X    int            sharable_colormap;
  364. X    int            double_buffering_capability;
  365. X    PEXEnumTypeIndex    color_approx_type;
  366. X} PEXUtVisualCriteria;
  367. X
  368. X/*
  369. X    Mask bits for the criteria.
  370. X*/
  371. X
  372. X#define PEXUtDepth            (1L<<0)
  373. X#define PEXUtMinColors            (1L<<1)
  374. X#define PEXUtMinRed            (1L<<2)
  375. X#define PEXUtMinGreen            (1L<<3)
  376. X#define PEXUtMinBlue            (1L<<4)
  377. X#define PEXUtVisualClass        (1L<<5)
  378. X#define PEXUtLayer            (1L<<6)
  379. X#define PEXUtStandardColormapProperty    (1L<<7)
  380. X#define PEXUtSharableColormap        (1L<<8)
  381. X#define PEXUtDoubleBufferingCapability    (1L<<9)
  382. X#define PEXUtColorApproxType        (1L<<10)
  383. X#define PEXUtAllCriteria        (                   \
  384. X                    PEXUtDepth             |\
  385. X                    PEXUtMinColors             |\
  386. X                    PEXUtMinRed             |\
  387. X                    PEXUtMinGreen             |\
  388. X                    PEXUtMinBlue             |\
  389. X                    PEXUtVisualClass         |\
  390. X                    PEXUtLayer             |\
  391. X                    PEXUtStandardColormapProperty     |\
  392. X                    PEXUtSharableColormap         |\
  393. X                    PEXUtDoubleBufferingCapability     |\
  394. X                    PEXUtColorApproxType         \
  395. X                    )
  396. X
  397. X
  398. X/*
  399. X    Values for the layer criterion.
  400. X*/
  401. X
  402. X#define PEXUtOverlay            1
  403. X#define PEXUtImage            2
  404. X
  405. X
  406. X/*
  407. X    Values for the double_buffering_capability crierion.
  408. X*/
  409. X
  410. X#define PEXUtDbufferNone        0
  411. X#define PEXUtDbufferPEX            1
  412. X#define PEXUtDbufferPEXAndX        2
  413. X
  414. X
  415. X/*
  416. X    Values for the integer error codes 
  417. X    returned by the various utilities.
  418. X*/
  419. X
  420. X#define PEXUtModifiedResource        1
  421. X#define PEXUtUnmodifiedResource        0
  422. X#define PEXUtQualifiedSuccess        1
  423. X#define PEXUtSuccess            0
  424. X#define PEXUtCriteriaFailure        -1
  425. X#define PEXUtXFailure            -2
  426. X#define PEXUtPEXFailure            -3
  427. X#define PEXUtAllocFailure        -4
  428. X
  429. X
  430. X
  431. X/*
  432. X    The following structure type is used to specify window size,
  433. X    location, title, and other attributes needed for window
  434. X    creation.  The fields are used as follows:
  435. X
  436. X    attr_mask        mask indicating which attribute values in
  437. X                the attrs substructure are to be used;
  438. X                basically the same attribute mask that
  439. X                would be passed into XCreateWindow, i.e. the
  440. X                bits are CWColormap, CWBorderPixel, etc.
  441. X
  442. X    attrs            attribute values corresponding to attr_mask
  443. X                bits.  Used the same as in XCreateWindow,
  444. X                with the following restrictions:
  445. X
  446. X                PEXUtCreateWindow requires the colormap
  447. X                field to be set, and CWColormap to be present
  448. X                in attr_mask.  PEXUtCreateWindowAndColormap
  449. X                ignores any colormap since it finds or
  450. X                creates one.
  451. X
  452. X                Background_pixel and border_pixel are
  453. X                signficant to PEXUtCreateWindow, but if not
  454. X                present, that utility will look up color values
  455. X                from the Colormap for the window.
  456. X                PEXUtCreateWindowAndColormap always looks up
  457. X                colors so these fields are ignored.
  458. X
  459. X                Background_pixmap and border_pixmap are
  460. X                effective, but may not be compatible with a
  461. X                Colormap that is appropriate for PEX.
  462. X
  463. X                Backing store fields should be used with
  464. X                caution, since many PEX implementations
  465. X                do not support backing store for PEX rendering.
  466. X
  467. X    title            a character string to be assigned as
  468. X                the title of the window.
  469. X
  470. X    size_hints        a structure specfying the size and position
  471. X                of the window, both used in a call to
  472. X                XCreateWindow and passed on to the window
  473. X                manager via XSetNormalHints.  Fields x, y,
  474. X                width, and height should be specified.
  475. X
  476. X    parent            identifier of the parent window.
  477. X
  478. X    border_width        width of the window border in pixels.
  479. X
  480. X    background_color_name    a character string naming a color in the
  481. X                X color database.  This name will be looked
  482. X                up to derive a background color.  If 
  483. X                CWBackgroundPixel is specified to 
  484. X                PEXUtCreateWindow, that pixel value will be
  485. X                used instead.  PEXUtCreateWindowAndColormap    
  486. X                always looks up the color.
  487. X
  488. X    border_color_name    similar to background_color_name except it
  489. X                specifies the border color of the Window.
  490. X*/
  491. X
  492. Xtypedef struct {
  493. X    unsigned long        attr_mask;
  494. X    XSetWindowAttributes    attrs;
  495. X    char            *title;
  496. X    XSizeHints        size_hints;
  497. X    Window            parent;
  498. X    unsigned int        border_width;
  499. X    char            *background_color_name;
  500. X    char            *border_color_name;
  501. X} PEXUtWindowSpecification;
  502. X
  503. X
  504. X
  505. X/******************************************************************************
  506. X *
  507. X * Function:
  508. X *   PEXUtFindVisual -- choose a Visual for PEX and return color setup info
  509. X *                                                                            
  510. X * Description:                                                               
  511. X *   This function attempts to find the "best" Visual supported by a PEX server
  512. X *   that meets a set of criteria specified by the caller.  If it successfully
  513. X *   finds a Visual, it returns colormap and color approximation information
  514. X *   that is predicted to be compatible with the Visual and the PEX 
  515. X *   implementation.  However, in some cases the compatibility is not known in
  516. X *   advance.  PEXUtVerifyColorApproximation (q.v.) can be used to check for
  517. X *   support, but may also be unable to determine server support for a 
  518. X *   particular color approximation setup.  The choice of what is "best" is
  519. X *   a policy decision that cannot be controlled by the caller; it is determined
  520. X *   by the ordering of Renderer targets and by PEX interoperability convention.
  521. X *   
  522. X *   Criteria for Visual selection are specified in the PEXUtVisualCriteria
  523. X *   structure.  Criteria can be "hard" or "soft".  Hard criteria must be met
  524. X *   in order for a Visual to be considered as a candidate; if no Visual meets
  525. X *   all hard criteria, the function returns a failure status.  Soft criteria
  526. X *   are considered when choosing among several candidate Visuals that meet
  527. X *   all the hard criteria.  There is an implicit hard criterion that PEX
  528. X *   supports the Visual as a target (this can only be checked on 5.1 and later
  529. X *   servers).  There is an implicit soft criterion of significant weight:
  530. X *   when several Visuals are qualifed by hard criteria, the utility prefers
  531. X *   the Visual that appears earlier in the target list returned 
  532. X *   PEXMatchRenderingTargets (5.1 and later), or earlier in any other list
  533. X *   established by interoperability convention.  (Currently, an earlier
  534. X *   appearance in one of the standard colormap properties that may be 
  535. X *   searched increases the likelihood of selection.)
  536. X *   
  537. X *   Please see the on-line manual page for a complete description of how
  538. X *   to use the criteria structure.
  539. X *   
  540. X * Returns:                                                                   
  541. X *   The function returns a value of PEXUtSuccess if it is completely 
  542. X *   successful in finding a Visual that meets all hard and soft criteria.
  543. X *   PEXUtQualifiedSuccess is returned if the chosen Visual meets all hard
  544. X *   criteria but not all soft criteria.
  545. X *   
  546. X *   A negative return value indicates failure:
  547. X *   
  548. X *       PEXUtCriteriaFailure means that no Visual was found that meets all
  549. X *    the hard criteria.
  550. X *   
  551. X *       PEXUtXFailure means that an error was encountered in an Xlib call.
  552. X *   
  553. X *       PEXUtPEXFailure means that an error occurred during a PEXlib call.
  554. X *   
  555. X *       PEXUtAllocFailure means that the utility ran out of memory.
  556. X *   
  557. X * On Entry:                                                                 
  558. X *   display        indicates the X connection to use; it is assumed that
  559. X *            PEXInitialize has already been called.
  560. X *                                                                            
  561. X *   screen        is the screen number for which to choose a Visual.
  562. X *                                                                            
  563. X *   criteria        is a pointer to a structure describing the criteria
  564. X *            to be used in Visual selection.
  565. X *                                                                            
  566. X * On Exit:                                                                 
  567. X *   vis_info_return    points to storage allocated by the caller that has 
  568. X *            been written with a description of the chosen Visual.
  569. X *                                                                            
  570. X *   cmap_info_return    points to storage allocated by the caller that has 
  571. X *            been written with a description of an RGB color map
  572. X *            that might be appropriate for PEX rendering.  If a
  573. X *            standard colormap property was used to guide selection,
  574. X *            this is a copy of the entry from the property that
  575. X *            guided the choice, including any Colormap ID that was
  576. X *            present.  Otherwise, it is a description "synthesized"
  577. X *            from the description of the Visual.
  578. X *                                                                            
  579. X *   capx_info_return    points to storage allocated by the caller that has 
  580. X *            been written with a PEX color approximation entry
  581. X *            that is compatible with the Visual and the criteria.
  582. X *            If no color approximation type was specified as a
  583. X *            a criterion, this is typically a PEXColorSpace setup
  584. X *            that matches the cmap_info_return data.  If a color
  585. X *            approximation type was specified, this is an entry
  586. X *            of the appropriate type.
  587. X *                                                                            
  588. X *   unmet_criteria_return    
  589. X *            points to storage allocated by the caller that has 
  590. X *            been written with a combined mask of all hard and
  591. X *            soft criteria that were not met by the chosen Visual.
  592. X *            This parameter is valid when successful or when 
  593. X *            PEXUtCriteriaFailure is returned; it may not valid 
  594. X *            for failure returns.
  595. X *                                                                            
  596. X *   std_prop_atom_return
  597. X *            points to storage allocated by the caller that has 
  598. X *            been written with the Atom for the name of the
  599. X *            standard colormap property that was used in Visual
  600. X *            selection, or None if no property was used.
  601. X *                                                                            
  602. X * Restrictions:                                                              
  603. X *   This function assumes that PEXInitialize has been called for the         
  604. X *   specified display argument.                                              
  605. X *                                                                            
  606. X *   The ability of this procedure to verify that criteria are met depends
  607. X *   on information available from the PEX server, including its support for
  608. X *   various interoperability conventions.  In general, if a hard criterion
  609. X *   cannot be determined to have been satisfied or not, it is considered to
  610. X *   have not been met; if a soft criterion cannot be verified, the utility 
  611. X *   acts as though it had been met but still returns the corresponding bit
  612. X *   in unmet_criteria_return.
  613. X *                                                                            
  614. X ******************************************************************************/
  615. X
  616. Xextern int PEXUtFindVisual (
  617. X#if NeedFunctionPrototypes
  618. X        Display                *display,
  619. X        int                screen,
  620. X        PEXUtVisualCriteria        *criteria,
  621. X        XVisualInfo            *vis_info_return,
  622. X        XStandardColormap        *cmap_info_return,
  623. X        PEXColorApproxEntry        *capx_info_return,
  624. X        unsigned int            *unmet_criteria_return,
  625. X        Atom                *std_prop_atom_return
  626. X#endif
  627. X        );
  628. X
  629. X
  630. X/******************************************************************************
  631. X *
  632. X * Function:
  633. X *   PEXUtGetStandardColormap -- retrieve or generate PEX color information
  634. X *                               for a specified Visual
  635. X *                                                                            
  636. X * Description:                                                               
  637. X *   This function is intended to be used by applications that choose a
  638. X *   Visual by means other than PEXUtFindVisual, but that wish to make use
  639. X *   of PEXUt functions for initializing Colormaps and/or creating Windows.
  640. X *   
  641. X *   Given a Visual chosen by the caller, and presumed to support PEX,
  642. X *   this function attempts to fetch color map and PEX color approximation
  643. X *   information using standard colormap properties as prescribed by PEX
  644. X *   interoperability conventions.  If it cannot find any such information,
  645. X *   it "synthesizes" the information from the Visual description.
  646. X *   
  647. X * Returns:                                                                   
  648. X *   The function returns a value of PEXUtSuccess if it succeeds in
  649. X *   finding or generating the color information.
  650. X *   
  651. X *   A negative return value indicates failure:
  652. X *   
  653. X *       PEXUtXFailure means that an error was encountered in an Xlib call.
  654. X *   
  655. X *       PEXUtAllocFailure means that the utility ran out of memory.
  656. X *   
  657. X * On Entry:                                                                 
  658. X *   display        indicates the X connection to use; it is assumed that
  659. X *            PEXInitialize has already been called.
  660. X *                                                                            
  661. X *   vis_info        is a pointer to a structure describing the Visual.
  662. X *                                                                            
  663. X * On Exit:                                                                 
  664. X *   cmap_info_return    points to storage allocated by the caller that has 
  665. X *            been written with a description of an RGB color map
  666. X *            that might be appropriate for PEX rendering.  If a
  667. X *            standard colormap property entry was found,
  668. X *            this is a copy of the entry from the property,
  669. X *            including any shared Colormap ID that was
  670. X *            present.  Otherwise, it is a description "synthesized"
  671. X *            from the description of the Visual.
  672. X *                                                                            
  673. X *   capx_info_return    points to storage allocated by the caller that has 
  674. X *            been written with a PEX color approximation entry
  675. X *            that is compatible with the Visual.  This is typically 
  676. X *            a PEXColorSpace setup that matches the cmap_info_return
  677. X *            data.  If a color approximation type was specified, 
  678. X *            this is an entry of the appropriate type.
  679. X *                                                                            
  680. X *   std_prop_atom_return
  681. X *            points to storage allocated by the caller that has 
  682. X *            been written with the Atom for the name of the
  683. X *            standard colormap property that was found, if any,
  684. X *            or None if no property entry was found.
  685. X *                                                                            
  686. X ******************************************************************************/
  687. X
  688. Xextern int PEXUtGetStandardColormapInfo (
  689. X#if NeedFunctionPrototypes
  690. X        Display                *display,
  691. X        XVisualInfo            *vis_info,
  692. X        XStandardColormap        *cmap_info_return,
  693. X        PEXColorApproxEntry        *capx_info_return,
  694. X        Atom                *std_prop_atom_return
  695. X#endif
  696. X        );
  697. X
  698. X
  699. X/******************************************************************************
  700. X *
  701. X * Function:
  702. X *   PEXUtVerifyColorApproximation -- determine PEX server support for a
  703. X *                                    particular color approximation entry
  704. X *                                                                            
  705. X * Description:                                                               
  706. X *   This function attempts to verify that a specified PEX color approximation
  707. X *   table entry is supported by the PEX server on a specified Visual.
  708. X *   It uses information about color approximation provided according to
  709. X *   interoperability conventions to make this determination.  (PEX 5.1 has
  710. X *   no inquiries that are sufficient to make the determination.)
  711. X *   
  712. X * Returns:                                                                   
  713. X *   The function returns a value of PEXUtSuccess if it is completely 
  714. X *   successful in determining that the color approximation entry is
  715. X *   supported.  PEXUtQualifiedSuccess is returned if support/non-support
  716. X *   cannot be determined.
  717. X *   
  718. X *   A negative return value indicates failure:
  719. X *   
  720. X *       PEXUtCriteriaFailure means that the utility was able to determine
  721. X *    that the approximation entry is definitely not supported.
  722. X *   
  723. X *       PEXUtXFailure means that an error was encountered in an Xlib call.
  724. X *   
  725. X *       PEXUtPEXFailure means that an error occurred during a PEXlib call.
  726. X *   
  727. X *       PEXUtAllocFailure means that the utility ran out of memory.
  728. X *   
  729. X * On Entry:                                                                 
  730. X *   display        indicates the X connection to use; it is assumed that
  731. X *            PEXInitialize has already been called.
  732. X *                                                                            
  733. X *   capx_info        is a pointer to the PEXColorApproxEntry of interest.
  734. X *                                                                            
  735. X *   vis_info        is a pointer to a structure describing the Visual.
  736. X *                                                                            
  737. X * Restrictions:                                                              
  738. X *   This function assumes that PEXInitialize has been called for the         
  739. X *   specified display argument.                                              
  740. X *                                                                            
  741. X *   The ability of this procedure to verify that criteria are met depends
  742. X *   on information available from the PEX server, including its support for
  743. X *   various interoperability conventions.  If support cannot be determined,
  744. X *   PEXUtQualifiedSuccess is returned so that the application can choose
  745. X *   to go on to attempt a call to PEXSetTableEntries.  The application should
  746. X *   be prepared for an error to be returned during that call in case the
  747. X *   color approximation entry is, in fact, not supported.
  748. X *                                                                            
  749. X ******************************************************************************/
  750. X
  751. Xextern int PEXUtVerifyColorApproximation (
  752. X#if NeedFunctionPrototypes
  753. X        Display                *display,
  754. X        PEXColorApproxEntry        *capx_info,
  755. X        XVisualInfo            *vis_info
  756. X#endif
  757. X        );
  758. X
  759. X
  760. X/******************************************************************************
  761. X *
  762. X * Function:
  763. X *   PEXUtCreateWriteableColormap -- create a read-write Colormap and 
  764. X *                     initialize it for use with a PEX 
  765. X *                     color approximation entry
  766. X *                                                                            
  767. X * Description:                                                               
  768. X *   This function creates a private X Colormap.  The region of the Colormap
  769. X *   that is described in a specified PEX color approximation entry is 
  770. X *   initialized according to the entry; cells outside the region are left
  771. X *   with their default values, in order to reduce color flashing of X clients
  772. X *   that are already using those cells when the new Colormap is installed.
  773. X *   In the case of a PEXColorRange entry, the region is initialized to a
  774. X *   gray ramp.  All cells in the Colormap are read-write for the caller.
  775. X *   
  776. X *   This function should be used by applications that plan to modify cells
  777. X *   in the Colormap, either inside or outside the color approximation region.
  778. X *   For example, if a PEXColorRange entry is to be used, it may be that the
  779. X *   application needs to replace the gray ramp with another set of colors.
  780. X *   If the application only needs to set up a Colormap to match a PEXColorSpace
  781. X *   entry and will not be changing the Colormap contents, it is recommended
  782. X *   that PEXUtCreateColormap be used instead, because it improves the chances
  783. X *   of XAllocColor succeeding on the Colormap.
  784. X *   
  785. X *   Note that some implementations of PEX may require additional adjustments
  786. X *   to the Colormap contents for some configurations.  It is recommended that
  787. X *   PEXUtModifyColormapForVendorDependencies be called after all changes to
  788. X *   the color approximation region are completed.
  789. X *   
  790. X * Returns:                                                                   
  791. X *   The function returns a value of PEXUtSuccess if the Colormap is
  792. X *   successfully allocated and initialized.
  793. X *   
  794. X *   A negative return value indicates failure:
  795. X *   
  796. X *       PEXUtXFailure means that an error was encountered in an Xlib call.
  797. X *   
  798. X *       PEXUtAllocFailure means that the utility ran out of memory.
  799. X *   
  800. X * On Entry:                                                                 
  801. X *   display        indicates the X connection to use.
  802. X *   
  803. X *   vis_info        is a pointer to a structure describing the Visual.
  804. X *                                                                            
  805. X *   capx_info        is a pointer to the PEXColorApproxEntry of interest.
  806. X *                                                                            
  807. X * On Exit:                                                                 
  808. X *   colormap_id_return    points to storage allocated by the caller that has 
  809. X *            been written with the new Colormap ID.
  810. X *                                                                            
  811. X ******************************************************************************/
  812. X
  813. Xextern int PEXUtCreateWriteableColormap (
  814. X#if NeedFunctionPrototypes
  815. X        Display                *display,
  816. X        XVisualInfo            *vis_info,
  817. X        PEXColorApproxEntry        *capx_info,
  818. X        Colormap            *colormap_id_return
  819. X#endif
  820. X        );
  821. X
  822. X
  823. X/******************************************************************************
  824. X *
  825. X * Function:
  826. X *   PEXUtModifyColormapForVendorDependencies -- adjust Colormap contents for
  827. X *                           vendor, device, and configuration idiosyncrasies
  828. X *                                                                            
  829. X * Description:                                                               
  830. X *   This procedure determines if the Visual, PEX color approximation entry, 
  831. X *   and vendor-dependent server and device form a combination that requires
  832. X *   adjustment to the Colormap contents after it has been initialized
  833. X *   according to the standard and interoperability conventions.  Code for
  834. X *   this procedure is expected to be composed of sections contributed by
  835. X *   vendors that have such combinations, so that interoperability is 
  836. X *   well-supported.  If the combination requires adjustment, this procedure
  837. X *   directly modifies the Colormap.  Therefore, the Colormap cells must be
  838. X *   writeable for this client on entry.
  839. X *   
  840. X *   It is recommended that this utility always be called after initialization
  841. X *   of a Colormap to match a color approximation entry, in order to support
  842. X *   interoperability of applications.
  843. X *   
  844. X * Returns:                                                                   
  845. X *   The function returns a value of PEXUtUnmodifiedResource if it did not
  846. X *   need to change the Colormap in any way.  It returns PEXUtModifiedResource
  847. X *   if some adjustments were made.
  848. X *   
  849. X *   A negative return value indicates failure:
  850. X *   
  851. X *       PEXUtXFailure means that an error was encountered in an Xlib call.
  852. X *   
  853. X *       PEXUtPEXFailure means that an error occurred during a PEXlib call.
  854. X *   
  855. X *       PEXUtAllocFailure means that the utility ran out of memory.
  856. X *   
  857. X * On Entry:                                                                 
  858. X *   display        indicates the X connection to use; it is assumed that
  859. X *            PEXInitialize has already been called.
  860. X *                                                                            
  861. X *   colormap_id    is the identifier of the Colormap to adjust; all cells
  862. X *               in the color approximation region are expected to be
  863. X *               writeable.
  864. X *                                                                            
  865. X *   vis_info         a pointer to a structure describing the Visual.
  866. X *                                                                            
  867. X *   capx_info        is a pointer to the PEXColorApproxEntry of interest.
  868. X *                                                                            
  869. X * On Exit:                                                                 
  870. X *   The contents of the Colormap may have been altered.
  871. X *                                                                            
  872. X * Restrictions:                                                              
  873. X *   This function assumes that PEXInitialize has been called for the         
  874. X *   specified display argument.                                              
  875. X *                                                                            
  876. X *   This function may be a no-op for some vendors' servers.  In such cases
  877. X *   it always returns PEXUtUnmodifiedResource.
  878. X *                                                                            
  879. X ******************************************************************************/
  880. X
  881. Xextern int PEXUtModifyColormapForVendorDependencies (
  882. X#if NeedFunctionPrototypes
  883. X        Display                *display,
  884. X        Colormap            colormap_id,
  885. X        XVisualInfo            *vis_info,
  886. X        PEXColorApproxEntry        *capx_info
  887. X#endif
  888. X        );
  889. X
  890. X
  891. X/******************************************************************************
  892. X *
  893. X * Function:
  894. X *   PEXUtCopyColormapAsReadOnly -- create a new Colormap that is a copy of
  895. X *                               an existing one, but usable with XAllocColor
  896. X *                                                                            
  897. X * Description:                                                               
  898. X *   This utility creates a Colormap that is a copy of an existing one that
  899. X *   is assumed to have been initialized for use with a specified PEX color
  900. X *   approximation entry.  As many cells as practical are read-only or 
  901. X *   unallocated in the new Colormap, to improve the chances that XAllocColor
  902. X *   will work with the Colormap.  However, the integrity of the color
  903. X *   approximation region is protected to ensure that no unallocated cells
  904. X *   exist inside the region, since a later XAllocColor could "corrupt" the
  905. X *   region.
  906. X *   
  907. X *   The source Colormap is not freed by this utility.  The caller may choose
  908. X *   to free it if only the new copy will be used.
  909. X *   
  910. X * Returns:                                                                   
  911. X *   The function returns a value of PEXUtSuccess if the new Colormap is
  912. X *   successfully created and initialized.
  913. X *   
  914. X *   A negative return value indicates failure:
  915. X *   
  916. X *       PEXUtXFailure means that an error was encountered in an Xlib call.
  917. X *   
  918. X *       PEXUtAllocFailure means that the utility ran out of memory.
  919. X *   
  920. X * On Entry:                                                                 
  921. X *   display        indicates the X connection to use; it is assumed that
  922. X *            PEXInitialize has already been called.
  923. X *                                                                            
  924. X *   source_cmap_id    is the identifier of the source Colormap to adjust.
  925. X *               It is expected to have been initialized to match
  926. X *               the color approximation entry, and any vendor-dependent
  927. X *               adjustments to have already been made.
  928. X *                                                                            
  929. X *   vis_info         a pointer to a structure describing the Visual.
  930. X *                                                                            
  931. X *   capx_info        is a pointer to the PEXColorApproxEntry for which the
  932. X *               source Colormap is initialized.
  933. X *                                                                            
  934. X * On Exit:                                                                 
  935. X *   cmap_id_return    points to storage allocated by the caller that has 
  936. X *            been written with the new Colormap ID.
  937. X *                                                                            
  938. X ******************************************************************************/
  939. X
  940. Xextern int PEXUtCopyColormapAsReadOnly (
  941. X#if NeedFunctionPrototypes
  942. X        Display                *display,
  943. X        Colormap            source_cmap_id,
  944. X        XVisualInfo            *vis_info,
  945. X        PEXColorApproxEntry        *capx_info,
  946. X        Colormap            *cmap_id_return
  947. X#endif
  948. X        );
  949. X
  950. X
  951. X/******************************************************************************
  952. X *
  953. X * Function:
  954. X *   PEXUtCreateColormap -- create a Colormap and initialize it for
  955. X *                       use with a PEX color approximation entry
  956. X *                                                                            
  957. X * Description:                                                               
  958. X *   This function creates a private X Colormap.  The region of the Colormap
  959. X *   that is described in a specified PEX color approximation entry is 
  960. X *   initialized according to the entry; cells outside the region are left
  961. X *   with their default values, in order to reduce color flashing of X clients
  962. X *   that are already using those cells when the new Colormap is installed.
  963. X *   In the case of a PEXColorRange entry, the region is initialized to a
  964. X *   gray ramp.  As many cells in the Colormap are left read-only or unallocated
  965. X *   as possible, while preserving the integrity of the color approximation
  966. X *   region.  This allows XAllocColor to be used with some success on the
  967. X *   Colormap, although some colors still will not be found by that routine.
  968. X *   
  969. X *   This function is approximately equivalent to the following sequence 
  970. X *   of calls:
  971. X *   
  972. X *       PEXUtCreateWriteableColormap (...,&writeable_cmap_id);
  973. X *       PEXUtModifyColormapForVendorDependencies (...,writeable_cmap_id,...).
  974. X *       PEXUtCopyColormapAsReadOnly (..,writeable_cmap_id,..,&readonly_cmap_id).
  975. X *       XFreeColormap (...,writeable_cmap_id);
  976. X *   
  977. X * Returns:                                                                   
  978. X *   The function returns a value of PEXUtSuccess if the Colormap is
  979. X *   successfully allocated and initialized.
  980. X *   
  981. X *   A negative return value indicates failure:
  982. X *   
  983. X *       PEXUtXFailure means that an error was encountered in an Xlib call.
  984. X *   
  985. X *       PEXUtAllocFailure means that the utility ran out of memory.
  986. X *   
  987. X * On Entry:                                                                 
  988. X *   display        indicates the X connection to use.
  989. X *   
  990. X *   vis_info        is a pointer to a structure describing the Visual.
  991. X *                                                                            
  992. X *   capx_info        is a pointer to the PEXColorApproxEntry of interest.
  993. X *                                                                            
  994. X * On Exit:                                                                 
  995. X *   colormap_id_return    points to storage allocated by the caller that has 
  996. X *            been written with the new Colormap ID.
  997. X *                                                                            
  998. X ******************************************************************************/
  999. X
  1000. Xextern int PEXUtCreateColormap (
  1001. X#if NeedFunctionPrototypes
  1002. X        Display                *display,
  1003. X        XVisualInfo            *vis_info,
  1004. X        PEXColorApproxEntry        *capx_info,
  1005. X        Colormap            *colormap_id_return
  1006. X#endif
  1007. X        );
  1008. X
  1009. X
  1010. X/******************************************************************************
  1011. X *
  1012. X * Function:
  1013. X *   PEXUtCreateWindow -- create a Window using specifed attributes
  1014. X *                                                                            
  1015. X * Description:                                                               
  1016. X *   This function creates a Window in the specified Visual using a
  1017. X *   specified set of attributes.  The window is not mapped; the application
  1018. X *   must take that action when appropriate.  It is intended for use by
  1019. X *   applications that already have chosen a Visual and created a Colormap,
  1020. X *   and only need window creation.  A typical use might be to create 
  1021. X *   additional windows after PEXUtCreateWindowAndColormap has been used to
  1022. X *   create the first one; the windows would all share the same Colormap.
  1023. X *   
  1024. X *   The attributes are specified in a PEXUtWindowSpecification structure.
  1025. X *   For the most part, they are specified and used in the same way as the
  1026. X *   corresponding parameters of XCreateWindow.  However, several restrictions
  1027. X *   are imposed.  Please see the on-line manual page for a complete 
  1028. X *   description of how to use the structure.
  1029. X *   
  1030. X * Returns:                                                                   
  1031. X *   The function returns a value of PEXUtSuccess if it is successful
  1032. X *   in creating the Window.
  1033. X *   
  1034. X *   A negative return value indicates failure:
  1035. X *   
  1036. X *       PEXUtXFailure means that an error was encountered in an Xlib call.
  1037. X *   
  1038. X *       PEXUtAllocFailure means that the utility ran out of memory.
  1039. X *   
  1040. X * On Entry:                                                                 
  1041. X *   display        indicates the X connection to use; it is assumed that
  1042. X *            PEXInitialize has already been called.
  1043. X *                                                                            
  1044. X *   screen        is the screen number on which to creation a Window.
  1045. X *                                                                            
  1046. X *   window_info    is a pointer to a structure describing the attributes
  1047. X *            to be used in Window creation.
  1048. X *                                                                            
  1049. X *   vis_info        is a pointer to a structure describing the Visual.
  1050. X *                                                                            
  1051. X * On Exit:                                                                 
  1052. X *   window_return    points to storage allocated by the caller that has 
  1053. X *            been written with the identifier of the created Window.
  1054. X *                                                                            
  1055. X *   background_color_return    
  1056. X *            points to storage allocated by the caller that has 
  1057. X *            been written with an XColor structure describing
  1058. X *            the color that was chosen for the window background.
  1059. X *            (The background color is specified in the
  1060. X *            window_info structure as a color name, which is 
  1061. X *            looked up in the Colormap specified in 
  1062. X *            window_info->attr.colormap.  This allows a newly
  1063. X *            created Colormap to be used for the Window.
  1064. X *                                                                            
  1065. X ******************************************************************************/
  1066. X
  1067. Xextern int PEXUtCreateWindow (
  1068. X#if NeedFunctionPrototypes
  1069. X        Display                *display,
  1070. X        int                screen,
  1071. X        PEXUtWindowSpecification    *window_info,
  1072. X        XVisualInfo            *vis_info,
  1073. X        Window                *window_return,
  1074. X        XColor                *background_color_return
  1075. X#endif
  1076. X        );
  1077. X
  1078. X
  1079. X/******************************************************************************
  1080. X *
  1081. X * Function:
  1082. X *   PEXUtCreateWindowAndColormap -- choose a Visual, create a Colormap,
  1083. X *                        and create a Window that is ready for
  1084. X *                        PEX rendering
  1085. X *                                                                            
  1086. X * Description:                                                               
  1087. X *   This function attempts to find the "best" Visual supported by a PEX server
  1088. X *   that meets a set of criteria specified by the caller.  If it successfully
  1089. X *   finds a Visual, it determines a color approximation entry to use based
  1090. X *   on the criteria and the selected Visual.  It creates a Colormap in 
  1091. X *   the Visual and initializes it to support the color approximation entry,
  1092. X *   unless a standard colormap property was found that contains a Colormap ID
  1093. X *   AND the sharable_colormap criterion was specified, in which case the.
  1094. X *   shared colormap is used.  Then it creates a Window in the Visual 
  1095. X *   using the chosen Colormap.
  1096. X *                                                                            
  1097. X *   The choice of what is the "best" Visual is a policy decision that
  1098. X *   cannot be controlled by the caller; it is determined by the ordering 
  1099. X *   of Renderer targets and by PEX interoperability convention.
  1100. X *   
  1101. X *   Criteria for Visual selection are specified in the PEXUtVisualCriteria
  1102. X *   structure.  Criteria can be "hard" or "soft".  Hard criteria must be met
  1103. X *   in order for a Visual to be considered as a candidate; if no Visual meets
  1104. X *   all hard criteria, the function returns a failure status.  Soft criteria
  1105. X *   are considered when choosing among several candidate Visuals that meet
  1106. X *   all the hard criteria.  There is an implicit hard criterion that PEX
  1107. X *   supports the Visual as a target (this can only be checked on 5.1 and later
  1108. X *   servers).  There is an implicit soft criterion of significant weight:
  1109. X *   when several Visuals are qualifed by hard criteria, the utility prefers
  1110. X *   the Visual that appears earlier in the target list returned 
  1111. X *   PEXMatchRenderingTargets (5.1 and later), or earlier in any other list
  1112. X *   established by interoperability convention.  (Currently, an earlier
  1113. X *   appearance in one of the standard colormap properties that may be 
  1114. X *   searched increases the likelihood of selection.)
  1115. X *   
  1116. X *   Window attributes are specified in a PEXUtWindowSpecification structure.
  1117. X *   For the most part, they are specified and used in the same way as the
  1118. X *   corresponding parameters of XCreateWindow.  However, several restrictions
  1119. X *   are imposed.  The Window has been mapped when the function returns.
  1120. X *   
  1121. X *   Any created Colormap has as many cells left read-only or unallocated as
  1122. X *   possible, while still preserving the integrity of the color approximation
  1123. X *   region.  This allows XAllocColor to be used with the Colormap.  Typically,
  1124. X *   shared Colormaps also allow use of this function.
  1125. X *   
  1126. X *   Please see the on-line manual page for a complete description of how
  1127. X *   to use the criteria and window attributes structures.
  1128. X *   
  1129. X * Returns:                                                                   
  1130. X *   The function returns a value of PEXUtSuccess if it is completely 
  1131. X *   successful in finding a Visual that meets all hard and soft criteria,
  1132. X *   and in creating the Colormap and Window.  PEXUtQualifiedSuccess is 
  1133. X *   returned if the chosen Visual meets all hard criteria but not all 
  1134. X *   soft criteria.
  1135. X *   
  1136. X *   A negative return value indicates failure:
  1137. X *   
  1138. X *       PEXUtCriteriaFailure means that no Visual was found that meets all
  1139. X *    the hard criteria.
  1140. X *   
  1141. X *       PEXUtXFailure means that an error was encountered in an Xlib call.
  1142. X *   
  1143. X *       PEXUtPEXFailure means that an error occurred during a PEXlib call.
  1144. X *   
  1145. X *       PEXUtAllocFailure means that the utility ran out of memory.
  1146. X *   
  1147. X * On Entry:                                                                 
  1148. X *   display        indicates the X connection to use; it is assumed that
  1149. X *            PEXInitialize has already been called.
  1150. X *                                                                            
  1151. X *   screen        is the screen number for which to choose a Visual.
  1152. X *                                                                            
  1153. X *   criteria        is a pointer to a structure describing the criteria
  1154. X *            to be used in Visual selection.
  1155. X *                                                                            
  1156. X *   window_info    is a pointer to a structure describing the attributes
  1157. X *            to be used in Window creation.
  1158. X *                                                                            
  1159. X * On Exit:                                                                 
  1160. X *   window_return    points to storage allocated by the caller that has 
  1161. X *            been written with the identifier of the created Window.
  1162. X *                                                                            
  1163. X *   vis_info_return    points to storage allocated by the caller that has 
  1164. X *            been written with a description of the chosen Visual.
  1165. X *                                                                            
  1166. X *   cmap_info_return    points to storage allocated by the caller that has 
  1167. X *            been written with a description of an RGB color map
  1168. X *            that might be appropriate for PEX rendering.  If a
  1169. X *            standard colormap property was used to guide selection,
  1170. X *            this is a copy of the entry from the property that
  1171. X *            guided the choice.  Otherwise, it is a description 
  1172. X *            "synthesized" from the description of the Visual.
  1173. X *            The identifier of the Colormap attached to the Window 
  1174. X *            is in cmap_info_return->colormap.
  1175. X *                                                                            
  1176. X *   capx_info_return    points to storage allocated by the caller that has 
  1177. X *            been written with a PEX color approximation entry
  1178. X *            that is compatible with the Visual and the criteria,
  1179. X *            and has been used to initialize any new Colormap.
  1180. X *            If no color approximation type was specified as a
  1181. X *            a criterion, this is typically a PEXColorSpace setup
  1182. X *            that matches the cmap_info_return data.  If a color
  1183. X *            approximation type was specified, this is an entry
  1184. X *            of the appropriate type.
  1185. X *                                                                            
  1186. X *   unmet_criteria_return    
  1187. X *            points to storage allocated by the caller that has 
  1188. X *            been written with a combined mask of all hard and
  1189. X *            soft criteria that were not met by the chosen Visual.
  1190. X *            This parameter is valid when successful or when 
  1191. X *            PEXUtCriteriaFailure is returned; it may not valid 
  1192. X *            for failure returns.
  1193. X *                                                                            
  1194. X *   std_prop_atom_return
  1195. X *            points to storage allocated by the caller that has 
  1196. X *            been written with the Atom for the name of the
  1197. X *            standard colormap property that was used in Visual
  1198. X *            selection, or None if no property was used.
  1199. X *                                                                            
  1200. X *   background_color_return    
  1201. X *            points to storage allocated by the caller that has 
  1202. X *            been written with an XColor structure describing
  1203. X *            the color that was chosen for the window background.
  1204. X *            (The background color is specified in the
  1205. X *            window_info structure as a color name, which is 
  1206. X *            looked up in the Colormap specified in 
  1207. X *            window_info->attr.colormap.  This allows a newly
  1208. X *            created Colormap to be used for the Window.
  1209. X *                                                                            
  1210. X * Restrictions:                                                              
  1211. X *   This function assumes that PEXInitialize has been called for the         
  1212. X *   specified display argument.                                              
  1213. X *                                                                            
  1214. X *   The ability of this procedure to verify that criteria are met depends
  1215. X *   on information available from the PEX server, including its support for
  1216. X *   various interoperability conventions.  In general, if a hard criterion
  1217. X *   cannot be determined to have been satisfied or not, it is considered to
  1218. X *   have not been met; if a soft criterion cannot be verified, the utility 
  1219. X *   acts as though it had been met but still returns the corresponding bit
  1220. X *   in unmet_criteria_return.
  1221. X *                                                                            
  1222. X ******************************************************************************/
  1223. X
  1224. Xextern int PEXUtCreateWindowAndColormap (
  1225. X#if NeedFunctionPrototypes
  1226. X        Display                *display,
  1227. X        int                screen,
  1228. X        PEXUtVisualCriteria        *criteria,
  1229. X        PEXUtWindowSpecification    *window_info,
  1230. X        Window                *window_return,
  1231. X        XVisualInfo            *vis_info_return,
  1232. X        XStandardColormap        *cmap_info_return,
  1233. X        PEXColorApproxEntry        *capx_info_return,
  1234. X        unsigned int            *unmet_criteria_return,
  1235. X        Atom                *std_prop_atom_return,
  1236. X        XColor                *background_color_return
  1237. X#endif
  1238. X        );
  1239. X
  1240. X#ifdef __cplusplus
  1241. X}                    /* for C++ V2.0 */
  1242. X#endif
  1243. X
  1244. X#endif /* } PEXUTCMAP_H */
  1245. END_OF_FILE
  1246.   if test 49034 -ne `wc -c <'util/pexutcmap.h'`; then
  1247.     echo shar: \"'util/pexutcmap.h'\" unpacked with wrong size!
  1248.   fi
  1249.   # end of 'util/pexutcmap.h'
  1250. fi
  1251. echo shar: End of archive 1 \(of 14\).
  1252. cp /dev/null ark1isdone
  1253. MISSING=""
  1254. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
  1255.     if test ! -f ark${I}isdone ; then
  1256.     MISSING="${MISSING} ${I}"
  1257.     fi
  1258. done
  1259. if test "${MISSING}" = "" ; then
  1260.     echo You have unpacked all 14 archives.
  1261.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1262.     echo "concatentating pexdraw.c ..."
  1263.     cat pexdrawc.? > pexdraw.c
  1264.     rm pexdrawc.?
  1265.     echo "concatentating pexdraw.uil ..."
  1266.     cat pexdrawu.? > pexdraw.uil
  1267.     rm pexdrawu.?
  1268.     echo "concatentating teapot.c ..."
  1269.     cat teapotc.? > teapot.c
  1270.     rm teapotc.?
  1271. else
  1272.     echo You still must unpack the following archives:
  1273.     echo "        " ${MISSING}
  1274. fi
  1275. exit 0
  1276. exit 0 # Just in case...
  1277. -- 
  1278.   // chris@IMD.Sterling.COM       | Send comp.sources.x submissions to:
  1279. \X/  Amiga - The only way to fly! |    sources-x@imd.sterling.com
  1280.  "It's intuitively obvious to the |
  1281.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  1282.