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

  1. Newsgroups: comp.sources.x
  2. From: jch@okimicro.oki.com (Jan Hardenbergh)
  3. Subject: v20i018:  pexdraw - A PEX drawing program, Part08/14
  4. Message-ID: <1993Jun8.150155.19095@sparky.imd.sterling.com>
  5. X-Md4-Signature: 6d28d5e2ef9404b38c8cd2e0070dbd0a
  6. Sender: chris@sparky.imd.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Tue, 8 Jun 1993 15:01:55 GMT
  9. Approved: chris@sparky.imd.sterling.com
  10.  
  11. Submitted-by: jch@okimicro.oki.com (Jan Hardenbergh)
  12. Posting-number: Volume 20, Issue 18
  13. Archive-name: pexdraw/part08
  14. Environment: X11R5, PEX
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then feed it
  18. # into a shell via "sh file" or similar.  To overwrite existing files,
  19. # type "sh file -c".
  20. # Contents:  util/pexutdb.c util/pexutdb.h
  21. # Wrapped by chris@sparky on Tue Jun  8 09:46:33 1993
  22. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  23. echo If this archive is complete, you will see the following message:
  24. echo '          "shar: End of archive 8 (of 14)."'
  25. if test -f 'util/pexutdb.c' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'util/pexutdb.c'\"
  27. else
  28.   echo shar: Extracting \"'util/pexutdb.c'\" \(23453 characters\)
  29.   sed "s/^X//" >'util/pexutdb.c' <<'END_OF_FILE'
  30. X/* $Header: pexutdb.c,v 500.1.200.1 93/03/17 13:50:51 rj Exp $ */
  31. X
  32. X/******************************************************************************/
  33. X/*  (c) Copyright Hewlett-Packard Company, 1992,  Fort Collins, Colorado      */
  34. X/*                                                                            */
  35. X/*                            All Rights Reserved                             */
  36. X/*                                                                            */
  37. X/*  Permission to use, copy, modify, and distribute this software and its     */
  38. X/*  documentation for any purpose and without fee is hereby granted provided  */
  39. X/*  that the above copyright notices appear in all copies and that both the   */
  40. X/*  copyright notices and this permission notice appear in supporting         */
  41. X/*  documentation, and that the name of Hewlett-Packard not be used in        */
  42. X/*  advertising or publicity pertaining to distribution of the software       */
  43. X/*  without specific, written prior permission.                               */
  44. X/*                                                                            */
  45. X/*  HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS         */
  46. X/*  SOFTWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
  47. X/*  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  Hewlett-Packard    */
  48. X/*  shall not be liable for errors contained herein or direct, indirect,      */
  49. X/*  special, incidental or consequential damages in connection with the       */
  50. X/*  furnishing, performance or use of this software.                          */
  51. X/*                                                                            */
  52. X/******************************************************************************/
  53. X
  54. X/******************************************************************************/
  55. X/*                                                                            */
  56. X/* Module:  PEXlib Double-Buffer Utilities                                    */
  57. X/*                                                                            */
  58. X/* File Content:                                                              */
  59. X/*   This file contains source code for the PEXlib double-buffer utilities.   */
  60. X/*                                                                            */
  61. X/******************************************************************************/
  62. X
  63. X
  64. X/*
  65. X** Include files
  66. X*/
  67. X#include <X11/PEX5/PEXlib.h>
  68. X#include "pexutext.h"
  69. X
  70. X#ifndef MBX_HEADER_FILE_NOT_INSTALLED /* [ */
  71. X#include <X11/extensions/multibuf.h>
  72. X#endif /* !MBX_HEADER_FILE_NOT_INSTALLED ] */
  73. X#include "pexutdbint.h"
  74. X#include "pexutdb.h"
  75. X
  76. X
  77. X/*
  78. X** Global internal data
  79. X*/
  80. Xstatic PEXUtDBData *pexutdb_last = (PEXUtDBData *)NULL;  /* modified by       */
  81. X                                                         /* LOOKUP_NODE macro */
  82. X                                                         /* and PEXUtDBConfig */
  83. X
  84. X
  85. X
  86. X/******************************************************************************/
  87. X/*                                                                            */
  88. X/* PEXUtDBConfig                                                              */
  89. X/*                                                                            */
  90. X/******************************************************************************/
  91. X
  92. Xint PEXUtDBConfig( dpy, win, db_on, bg_color, db_x, drw_id_return )
  93. X    Display             *dpy;
  94. X    Window              win;
  95. X    int                 db_on;
  96. X    XColor              *bg_color;
  97. X    int                 db_x;
  98. X    Drawable            *drw_id_return;
  99. X{
  100. X    PEXUtDBData         *ptr;
  101. X    PEXExtensionInfo    *pexinfo;
  102. X    XWindowAttributes   wattrs;
  103. X    unsigned long       count, rmsk;
  104. X    PEXRenderingTarget  *target;
  105. X    XGCValues           gcvals;
  106. X    PEXRendererAttributes rattrs;
  107. X    
  108. X
  109. X    /*
  110. X    ** verify that the PEX server is major version 5
  111. X    */
  112. X    pexinfo = PEXGetExtensionInfo( dpy );
  113. X    if ( pexinfo == (PEXExtensionInfo *)NULL )
  114. X        return( PEXUTDBNODB );
  115. X    if ( pexinfo->major_version != 5 )
  116. X        return( PEXUTDBNOTPEX5 );
  117. X
  118. X    /*
  119. X    ** if a node for the window already exists, use it
  120. X    */
  121. X    LOOKUP_NODE( ptr, win, dpy );
  122. X    if ( ptr == (PEXUtDBData *)NULL ) {
  123. X        /*
  124. X        ** if no node found, and trying to turn off double-buffering,
  125. X        ** return successfully since double-buffering is off by default
  126. X        */
  127. X        if ( ! db_on ) {
  128. X        if ( drw_id_return != (Drawable *)NULL )
  129. X                *drw_id_return = win;
  130. X            return( PEXUTDBOKAY );
  131. X        }
  132. X        /*
  133. X        ** otherwise, we need to add a new node
  134. X        */
  135. X        ptr = add_node( win, dpy );
  136. X        if ( ptr == (PEXUtDBData *)NULL )
  137. X            return( PEXUTDBNOMEM );
  138. X        pexutdb_last = ptr;
  139. X    } else {
  140. X    /*
  141. X    ** if we're turning double-buffering on, and it's already on, just
  142. X    ** verify the configuration is same as before (i.e. db_x is the same)
  143. X    ** and set the new bg_color
  144. X    */
  145. X    if ( db_on ) {
  146. X        if ( db_x != ptr->db_x ) {
  147. X        PEXUtDBConfig( dpy, win, False, bg_color, 0, drw_id_return );
  148. X        return( PEXUtDBConfig( dpy, win, True, bg_color, db_x,
  149. X                       drw_id_return ) );
  150. X        } else {
  151. X                if ( ptr->db_type == PEXUTDBMBX ) {
  152. X                    gcvals.foreground = bg_color->pixel;
  153. X                    XChangeGC( dpy, ptr->gc, GCForeground, &gcvals );
  154. X                    XSetWindowBackground( dpy, win, bg_color->pixel );
  155. X                    if ( ptr->render_to_front )
  156. X                        *drw_id_return = ptr->buffers[(ptr->back_buffer ^ 0x1)];
  157. X            else
  158. X                        *drw_id_return = ptr->buffers[ptr->back_buffer];
  159. X                } else {
  160. X                    if ( ptr->db_type == PEXUTDBESC ) {
  161. X#ifndef HP_MULTIPLE_RENDERERS_BUG_NOT_FIXED /* [ */
  162. X                        rattrs.background_color.type = PEXColorTypeRGB;
  163. X                        rattrs.background_color.value.rgb.red   =
  164. X                                                     (float)bg_color->red/65535;
  165. X                        rattrs.background_color.value.rgb.green =
  166. X                                                   (float)bg_color->green/65535;
  167. X                        rattrs.background_color.value.rgb.blue  =
  168. X                                                    (float)bg_color->blue/65535;
  169. X                        rmsk = PEXRABackgroundColor;
  170. X                        PEXChangeRenderer( dpy, ptr->renderer, rmsk, &rattrs );
  171. X#endif /* HP_MULTIPLE_RENDERERS_BUG_NOT_FIXED ] */
  172. X                        *drw_id_return = win;
  173. X            } else {
  174. X                        gcvals.foreground = bg_color->pixel;
  175. X                        XChangeGC( dpy, ptr->gc, GCForeground, &gcvals );
  176. X                        XSetWindowBackground( dpy, win, bg_color->pixel );
  177. X                        *drw_id_return = ptr->pixmap;
  178. X            }
  179. X        }
  180. X
  181. X        return( PEXUTDBOKAY );
  182. X        }
  183. X    }
  184. X    }
  185. X
  186. X    /*
  187. X    ** if we're turning double-buffering off, delete the node
  188. X    */
  189. X    if ( ! db_on ) {
  190. X        /*
  191. X        ** free up resources
  192. X        */
  193. X        if ( ptr->db_type == PEXUTDBMBX ) {
  194. X            XmbufDestroyBuffers( dpy, win );
  195. X            XFreeGC( dpy, ptr->gc );
  196. X        } else {
  197. X            if ( ptr->db_type == PEXUTDBESC ) {
  198. X                esEscapeDblBuffer dbesc;
  199. X
  200. X                dbesc.drawable = win;
  201. X                dbesc.bufferMode = ES_RENDERER_SINGLEBUFFER;
  202. X                PEXEscape( dpy, ES_ESCAPE_DBLBUFFER,
  203. X                           sizeof( esEscapeDblBuffer ), (PEXPointer)&dbesc );
  204. X#ifndef HP_MULTIPLE_RENDERERS_BUG_NOT_FIXED /* [ */
  205. X                PEXFreeRenderer( dpy, ptr->renderer );
  206. X#endif /* HP_MULTIPLE_RENDERERS_BUG_NOT_FIXED ] */
  207. X            } else {
  208. X                /*
  209. X                ** assume pixmap is used
  210. X                */
  211. X                XFreePixmap( dpy, ptr->pixmap );
  212. X                XFreeGC( dpy, ptr->gc );
  213. X            }
  214. X        }
  215. X
  216. X        /*
  217. X        ** delete the node and return
  218. X        */
  219. X        delete_node( win, dpy );
  220. X    if ( drw_id_return != (Drawable *)NULL )
  221. X            *drw_id_return = win;
  222. X        pexutdb_last = (PEXUtDBData *)NULL;
  223. X        return( PEXUTDBOKAY );
  224. X    }
  225. X
  226. X    /*
  227. X    ** okay, we now know we're turning on double-buffering; so do it!
  228. X    */
  229. X
  230. X    /*
  231. X    ** initialize the node
  232. X    */
  233. X    ptr->window = win;
  234. X    ptr->display = dpy;
  235. X    ptr->render_to_front = False;
  236. X    ptr->db_x = db_x = ( db_x ? True : False ); /* map value to True or False */
  237. X    ptr->renderer = None;
  238. X    ptr->clear_renderer = False;
  239. X    ptr->pixmap = None;
  240. X    ptr->gc = None;
  241. X    ptr->width = 0;                /* width, height and depth not used unless */
  242. X    ptr->height = 0;               /* using pixmaps for double-buffering      */
  243. X    ptr->depth = 0;
  244. X
  245. X    /*
  246. X    ** get the window attributes
  247. X    */
  248. X    if ( ! XGetWindowAttributes( dpy, win, &wattrs ) )
  249. X        return( PEXUTDBNODB );
  250. X
  251. X
  252. X    /*
  253. X    ** try MBX
  254. X    */
  255. X    {
  256. X        int first_event, first_error, num;
  257. X        
  258. X    /*
  259. X    ** If the server version is 5.0, assume PEX can render to buffer
  260. X    ** targets if the MBX extension is available
  261. X    ** If the server version is 5.1, verify that PEX can render to buffer
  262. X    ** targets if the MBX extension is available
  263. X    */
  264. X        if ( ( pexinfo->minor_version == 0 ) ||
  265. X             ( ( pexinfo->minor_version >= 1 ) &&
  266. X               PEXMatchRenderingTargets( dpy, win, wattrs.depth,
  267. X                                         PEXBufferDrawable, wattrs.visual, 1,
  268. X                                         &count, &target ) &&
  269. X               ( count == 1 ) ) ) {
  270. X            if ( XmbufQueryExtension( dpy, &first_event, &first_error ) ) {
  271. X                num = XmbufCreateBuffers( dpy, win, 2,
  272. X                                          MultibufferUpdateActionUndefined,
  273. X                                          MultibufferUpdateHintFrequent,
  274. X                                          ptr->buffers );
  275. X                if ( num == 2 ) {
  276. X                    ptr->back_buffer = 1;  /* buffers[0] is the one displayed */
  277. X                    gcvals.foreground = bg_color->pixel;
  278. X                    ptr->gc = XCreateGC( dpy, win, GCForeground, &gcvals );
  279. X                    if ( ptr->gc ) {
  280. X                        XSetWindowBackground( dpy, win, bg_color->pixel );
  281. X                        XFillRectangle( dpy, ptr->buffers[ptr->back_buffer],
  282. X                    ptr->gc, 0, 0, ptr->width, ptr->height);
  283. X                        ptr->db_type = PEXUTDBMBX;
  284. X                        *drw_id_return = ptr->buffers[ptr->back_buffer];
  285. X                        return( PEXUTDBOKAY );
  286. X                    } else
  287. X                        XmbufDestroyBuffers( dpy, win );
  288. X                }
  289. X            }
  290. X        }
  291. X    }
  292. X    
  293. X    /*
  294. X    ** MBX not available, so try double-buffer escapes
  295. X    */
  296. X    if ( ! db_x ) {
  297. X
  298. X        if ( ( pexinfo->minor_version >= 1 ) ||
  299. X         (strncmp( pexinfo->vendor_name, "SunPEX 2.0", 10 ) == 0 ) ) {
  300. X
  301. X            int                     enumtypes, i, hpfnd, esfnd;
  302. X            unsigned long           *ptrtocnts, rpllen;
  303. X            PEXEnumTypeDesc         *ptrtoinfo;
  304. X            esEscapeDblBuffer       dbesc;
  305. X            esEscapeSwapBufferContent sbcesc;
  306. X            char                    *rpl;
  307. X
  308. X        
  309. X            enumtypes = PEXETEscape;
  310. X            if ( PEXGetEnumTypeInfo( dpy, win, 1, &enumtypes, PEXETIndex,
  311. X                                     &ptrtocnts, &ptrtoinfo ) ) {
  312. X                hpfnd = esfnd = False;
  313. X                for ( i = 0;  i < *ptrtocnts;  i++ ) {
  314. X                    if ( (short)ptrtoinfo[i].index ==
  315. X                         (short)ES_ESCAPE_ET_DBLBUFFER )
  316. X                        esfnd = True;           /* assume rest of E&S escapes */
  317. X                    if ( (short)ptrtoinfo[i].index ==
  318. X                    (short)HP_ESCAPE_ET_SETRENDERINGBUFFER )
  319. X                        hpfnd = True;
  320. X                }
  321. X                if ( esfnd ) {
  322. X                    dbesc.drawable = win;
  323. X                    dbesc.bufferMode = ES_RENDERER_DBLBUFFER;
  324. X                    PEXEscape( dpy, ES_ESCAPE_DBLBUFFER,
  325. X                               sizeof( esEscapeDblBuffer ),
  326. X                               (PEXPointer)&dbesc );
  327. X#ifndef HP_MULTIPLE_RENDERERS_BUG_NOT_FIXED /* [ */
  328. X                    /*
  329. X                    ** set up renderer attributes and create a PEX renderer
  330. X                    */
  331. X                    rattrs.background_color.type = PEXColorTypeRGB;
  332. X                    rattrs.background_color.value.rgb.red   =
  333. X                                                     (float)bg_color->red/65535;
  334. X                    rattrs.background_color.value.rgb.green =
  335. X                                                   (float)bg_color->green/65535;
  336. X                    rattrs.background_color.value.rgb.blue  =
  337. X                                                    (float)bg_color->blue/65535;
  338. X                    rattrs.clear_image = True;
  339. X                    rmsk = ( PEXRABackgroundColor | PEXRAClearImage );
  340. X                    ptr->renderer =
  341. X                   PEXCreateRenderer( dpy, win, rmsk, &rattrs );
  342. X                    /*
  343. X                    ** find out if swapping buffers will clear the back buffer
  344. X                    */
  345. X                    sbcesc.drawable = win;
  346. X                    rpl = PEXEscapeWithReply( dpy, ES_ESCAPE_SWAPBUFFERCONTENT,
  347. X                                            sizeof( esEscapeSwapBufferContent ),
  348. X                                            (PEXPointer)&sbcesc, &rpllen );
  349. X                    if ( ( rpllen != 4 ) ||
  350. X             ( ( rpllen == 4 ) && ( (*(unsigned long *)rpl) !=
  351. X                                  ES_DB_SWAP_CONTENT_CLEAR_TO_BACKGROUND ) ) ) {
  352. X                        PEXBeginRendering( dpy, win, ptr->renderer );
  353. X                        PEXEndRendering( dpy, ptr->renderer, True );
  354. X                        ptr->clear_renderer = True;
  355. X                    } else {
  356. X                        ptr->clear_renderer = False;
  357. X            }
  358. X            if ( rpl != NULL )
  359. X                XFree( rpl );
  360. X#endif /* HP_MULTIPLE_RENDERERS_BUG_NOT_FIXED ] */
  361. X            if ( hpfnd )
  362. X            ptr->front_supported = True;
  363. X            else
  364. X            ptr->front_supported = False;
  365. X                    ptr->db_type = PEXUTDBESC;   /* note escapes are used */
  366. X                    *drw_id_return = win;
  367. X                    return( PEXUTDBOKAY );
  368. X                }
  369. X            }
  370. X        }
  371. X    }
  372. X    
  373. X    /*
  374. X    ** last resort, pixmaps
  375. X    **
  376. X    ** If the server version is 5.0, assume PEX can render to pixmap targets
  377. X    ** If the server version is 5.1, verify that PEX can render to pixmaps
  378. X    */
  379. X    if ( ( pexinfo->minor_version == 0 ) ||
  380. X         ( ( pexinfo->minor_version >= 1 ) &&
  381. X           PEXMatchRenderingTargets( dpy, win, wattrs.depth,
  382. X                                     PEXPixmapDrawable, wattrs.visual, 1,
  383. X                                     &count, &target ) &&
  384. X           ( count == 1 ) ) ) {
  385. X        /*
  386. X        ** set up the window attributes for use later
  387. X        */
  388. X        ptr->width = wattrs.width;
  389. X        ptr->height = wattrs.height;
  390. X        ptr->depth = wattrs.depth;
  391. X        ptr->pixmap = XCreatePixmap( dpy, ptr->window, ptr->width, ptr->height,
  392. X                                     ptr->depth );
  393. X        if ( ptr->pixmap ) {
  394. X            gcvals.foreground = bg_color->pixel;
  395. X            ptr->gc = XCreateGC( dpy, ptr->pixmap, GCForeground, &gcvals );
  396. X            if ( ptr->gc ) {
  397. X                XSetWindowBackground( dpy, win, bg_color->pixel );
  398. X                XFillRectangle( dpy, ptr->pixmap, ptr->gc,
  399. X                                0, 0, ptr->width, ptr->height );
  400. X                *drw_id_return = ptr->pixmap;
  401. X                return( PEXUTDBOKAY );
  402. X            } else
  403. X                XFreePixmap( dpy, ptr->pixmap );
  404. X        }
  405. X    }
  406. X    
  407. X    /*
  408. X    ** nothing is available, so clean up and return failure
  409. X    */
  410. X    delete_node( win, dpy );
  411. X    pexutdb_last = (PEXUtDBData *)NULL;
  412. X    return( PEXUTDBNODB );
  413. X}
  414. X
  415. X
  416. X
  417. X/******************************************************************************/
  418. X/*                                                                            */
  419. X/* PEXUtDBSwap                                                                */
  420. X/*                                                                            */
  421. X/******************************************************************************/
  422. X
  423. XDrawable PEXUtDBSwap( dpy, win, clear )
  424. X    Display     *dpy;
  425. X    Window      win;
  426. X    int         clear;
  427. X{
  428. X    PEXUtDBData *ptr;
  429. X    
  430. X    LOOKUP_NODE( ptr, win, dpy );
  431. X    if ( ptr == (PEXUtDBData *)NULL )
  432. X        return( win );
  433. X    
  434. X    /*
  435. X    ** swap the buffers
  436. X    */
  437. X
  438. X    if ( ptr->db_type == PEXUTDBMBX ) {
  439. X        XmbufDisplayBuffers( dpy, 1, &( ptr->buffers[ptr->back_buffer] ), 0, 0);
  440. X        ptr->back_buffer = ( ptr->back_buffer ^ 0x1 );
  441. X        if ( clear )
  442. X            XFillRectangle( dpy, ptr->buffers[ptr->back_buffer], ptr->gc,
  443. X                0, 0, ptr->width, ptr->height );
  444. X        if ( ptr->render_to_front )
  445. X            return( ptr->buffers[( ptr->back_buffer ^ 0x1 )] );
  446. X        return( ptr->buffers[ptr->back_buffer] );
  447. X    }
  448. X
  449. X    if ( ptr->db_type == PEXUTDBESC ) {
  450. X        esEscapeSwapBuffer sbesc;
  451. X
  452. X        sbesc.drawable = win;
  453. X        PEXEscape( dpy, ES_ESCAPE_SWAPBUFFER, sizeof( esEscapeSwapBuffer ),
  454. X                   (PEXPointer)&sbesc );
  455. X#ifndef HP_MULTIPLE_RENDERERS_BUG_NOT_FIXED /* [ */
  456. X        if ( clear && ptr->clear_renderer ) {
  457. X            PEXBeginRendering( dpy, win, ptr->renderer );
  458. X            PEXEndRendering( dpy, ptr->renderer, True );
  459. X        }
  460. X#endif /* HP_MULTIPLE_RENDERERS_BUG_NOT_FIXED ] */
  461. X        return( win );
  462. X    }
  463. X
  464. X    /*
  465. X    ** assume pixmap is used
  466. X    */
  467. X    XCopyArea( dpy, ptr->pixmap, win, ptr->gc, 0, 0, ptr->width, ptr->height,
  468. X               0, 0 );
  469. X    if ( clear )
  470. X        XFillRectangle( dpy, ptr->pixmap, ptr->gc, 0, 0, ptr->width,
  471. X                        ptr->height );
  472. X    if ( ptr->render_to_front )
  473. X        return( win );
  474. X    return( ptr->pixmap );
  475. X}
  476. X
  477. X
  478. X
  479. X/******************************************************************************/
  480. X/*                                                                            */
  481. X/* PEXUtDBClear                                                               */
  482. X/*                                                                            */
  483. X/******************************************************************************/
  484. X
  485. Xint PEXUtDBClear( dpy, win )
  486. X    Display     *dpy;
  487. X    Window      win;
  488. X{
  489. X    PEXUtDBData *ptr;
  490. X    Drawable    drw;
  491. X    
  492. X    LOOKUP_NODE( ptr, win, dpy );
  493. X    if ( ptr == (PEXUtDBData *)NULL ) {
  494. X        XClearWindow( dpy, win );
  495. X        return( PEXUTDBOKAY );
  496. X    }
  497. X    
  498. X    /*
  499. X    ** clear the back buffer
  500. X    */
  501. X
  502. X    if ( ptr->db_type == PEXUTDBESC ) {
  503. X        /*
  504. X        ** NOTE: this is slow; it is documented that
  505. X        **       applications should not do this
  506. X        */
  507. X#ifndef HP_MULTIPLE_RENDERERS_BUG_NOT_FIXED /* [ */
  508. X        if ( ptr->render_to_front ) {
  509. X            PEXUtDBFront( dpy, win, False, &drw );
  510. X            PEXBeginRendering( dpy, win, ptr->renderer );
  511. X            PEXEndRendering( dpy, ptr->renderer, True );
  512. X            PEXUtDBFront( dpy, win, True, &drw );
  513. X        } else {
  514. X            PEXBeginRendering( dpy, win, ptr->renderer );
  515. X            PEXEndRendering( dpy, ptr->renderer, True );
  516. X        }
  517. X#else /* HP_MULTIPLE_RENDERERS_BUG_NOT_FIXED ][ */
  518. X        return( PEXUTDBFAIL );
  519. X#endif /* HP_MULTIPLE_RENDERERS_BUG_NOT_FIXED ] */
  520. X    } else {
  521. X        if ( ptr->db_type == PEXUTDBMBX )
  522. X            XFillRectangle( dpy, ptr->buffers[ptr->back_buffer], ptr->gc,
  523. X                0, 0, ptr->width, ptr->height );
  524. X        else
  525. X            /*
  526. X            ** assume pixmap is used
  527. X            */
  528. X            XFillRectangle( dpy, ptr->pixmap, ptr->gc,
  529. X                0, 0, ptr->width, ptr->height );
  530. X    }
  531. X
  532. X    return( PEXUTDBOKAY );
  533. X}
  534. X
  535. X
  536. X
  537. X/******************************************************************************/
  538. X/*                                                                            */
  539. X/* PEXUtDBFront                                                               */
  540. X/*                                                                            */
  541. X/******************************************************************************/
  542. X
  543. Xint PEXUtDBFront( dpy, win, front, drw_id_return )
  544. X    Display     *dpy;
  545. X    Window      win;
  546. X    int         front;
  547. X    Drawable    *drw_id_return;
  548. X{
  549. X    PEXUtDBData *ptr;
  550. X    
  551. X    LOOKUP_NODE( ptr, win, dpy );
  552. X    if ( ptr == (PEXUtDBData *)NULL ) {
  553. X    *drw_id_return = win;
  554. X        return( PEXUTDBOKAY );
  555. X    }
  556. X
  557. X    /*
  558. X    ** first, verify that rendering to the front buffer is supported
  559. X    */
  560. X    if ( ! ptr->front_supported )
  561. X    return( PEXUTDBNOSUPPORT );
  562. X
  563. X    
  564. X    /*
  565. X    ** configure the window for rendering to the
  566. X    **    front (if front == True)
  567. X    ** or
  568. X    **    back (if front == False)
  569. X    */
  570. X
  571. X    front = ( front ? True : False );           /* map value to True or False */
  572. X
  573. X    if ( ptr->db_type == PEXUTDBMBX ) {
  574. X        ptr->render_to_front = front;
  575. X        if ( front )
  576. X            *drw_id_return = ptr->buffers[( ptr->back_buffer ^ 0x1 )];
  577. X    else
  578. X            *drw_id_return = ptr->buffers[ptr->back_buffer];
  579. X    return( PEXUTDBOKAY );
  580. X    }
  581. X
  582. X    if ( ptr->db_type == PEXUTDBESC ) {
  583. X        if ( ptr->render_to_front != front ) {
  584. X            hpEscapeSetRenderingBuffer srbesc;
  585. X
  586. X            ptr->render_to_front = front;
  587. X            srbesc.drawable = win;
  588. X            srbesc.render_to_front_buffer = front;
  589. X            PEXEscape( dpy, HP_ESCAPE_SETRENDERINGBUFFER,
  590. X                       sizeof( hpEscapeSetRenderingBuffer ),
  591. X                       (PEXPointer)&srbesc );
  592. X        }
  593. X    *drw_id_return = win;
  594. X        return( PEXUTDBOKAY );
  595. X    }
  596. X
  597. X    /*
  598. X    ** assume pixmap is used
  599. X    */
  600. X    ptr->render_to_front = front;
  601. X    if ( front )
  602. X        *drw_id_return = win;
  603. X    else
  604. X        *drw_id_return = ptr->pixmap;
  605. X    return( PEXUTDBOKAY );
  606. X}
  607. X
  608. X
  609. X
  610. X/******************************************************************************/
  611. X/*                                                                            */
  612. X/* PEXUtDBResize                                                              */
  613. X/*                                                                            */
  614. X/******************************************************************************/
  615. X
  616. XDrawable PEXUtDBResize( dpy, win )
  617. X    Display           *dpy;
  618. X    Window            win;
  619. X{
  620. X    PEXUtDBData       *ptr;
  621. X    XWindowAttributes wattrs;
  622. X    
  623. X    LOOKUP_NODE( ptr, win, dpy );
  624. X    if ( ptr == (PEXUtDBData *)NULL )
  625. X        return( win );
  626. X    
  627. X    /*
  628. X    ** reconfigure the window for the new size
  629. X    */
  630. X
  631. X    if ( ptr->db_type == PEXUTDBMBX ) {
  632. X        if ( ptr->render_to_front )
  633. X            return( ptr->buffers[( ptr->back_buffer ^ 0x1 )] );
  634. X        return( ptr->buffers[ptr->back_buffer] );
  635. X    }
  636. X
  637. X    if ( ptr->db_type == PEXUTDBESC )
  638. X        return( win );
  639. X
  640. X    /*
  641. X    ** assume pixmap is used
  642. X    */
  643. X    XFreePixmap( dpy, ptr->pixmap );
  644. X
  645. X    /*
  646. X    ** get new window attributes
  647. X    */
  648. X    if ( ! XGetWindowAttributes( dpy, win, &wattrs ) )
  649. X        return( None );
  650. X    ptr->width = wattrs.width;
  651. X    ptr->height = wattrs.height;
  652. X    ptr->depth = wattrs.depth;
  653. X
  654. X    /*
  655. X    ** create new pixmap
  656. X    */
  657. X    ptr->pixmap = XCreatePixmap( dpy, ptr->window, ptr->width, ptr->height,
  658. X                                 ptr->depth );
  659. X    if ( ptr->pixmap ) {
  660. X        if ( ptr->render_to_front )
  661. X            return( win );
  662. X        return( ptr->pixmap );
  663. X    }
  664. X
  665. X    /*
  666. X    ** failed to allocate new pixmap, clean up and return failure
  667. X    */
  668. X    XFreeGC( dpy, ptr->gc );
  669. X    delete_node( win, dpy );
  670. X    pexutdb_last = (PEXUtDBData *)NULL;
  671. X    return( None );
  672. X}
  673. END_OF_FILE
  674.   if test 23453 -ne `wc -c <'util/pexutdb.c'`; then
  675.     echo shar: \"'util/pexutdb.c'\" unpacked with wrong size!
  676.   fi
  677.   # end of 'util/pexutdb.c'
  678. fi
  679. if test -f 'util/pexutdb.h' -a "${1}" != "-c" ; then 
  680.   echo shar: Will not clobber existing file \"'util/pexutdb.h'\"
  681. else
  682.   echo shar: Extracting \"'util/pexutdb.h'\" \(30692 characters\)
  683.   sed "s/^X//" >'util/pexutdb.h' <<'END_OF_FILE'
  684. X/* $Header: pexutdb.h,v 500.1.200.1 93/03/17 14:14:35 rj Exp $ */
  685. X
  686. X/******************************************************************************/
  687. X/*  (c) Copyright Hewlett-Packard Company, 1992,  Fort Collins, Colorado      */
  688. X/*                                                                            */
  689. X/*                            All Rights Reserved                             */
  690. X/*                                                                            */
  691. X/*  Permission to use, copy, modify, and distribute this software and its     */
  692. X/*  documentation for any purpose and without fee is hereby granted provided  */
  693. X/*  that the above copyright notices appear in all copies and that both the   */
  694. X/*  copyright notices and this permission notice appear in supporting         */
  695. X/*  documentation, and that the name of Hewlett-Packard not be used in        */
  696. X/*  advertising or publicity pertaining to distribution of the software       */
  697. X/*  without specific, written prior permission.                               */
  698. X/*                                                                            */
  699. X/*  HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS         */
  700. X/*  SOFTWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
  701. X/*  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  Hewlett-Packard    */
  702. X/*  shall not be liable for errors contained herein or direct, indirect,      */
  703. X/*  special, incidental or consequential damages in connection with the       */
  704. X/*  furnishing, performance or use of this software.                          */
  705. X/*                                                                            */
  706. X/******************************************************************************/
  707. X
  708. X/******************************************************************************/
  709. X/*                                                                            */
  710. X/* Module:  PEXlib Double-Buffer Utilities (see file pexutdb.c for more info) */
  711. X/*                                                                            */
  712. X/* Module Description:                                                        */
  713. X/*   This set of functions provide a portable interface to double-buffering.  */
  714. X/*   The utilities support the use of the Multi-Buffering extension to X      */
  715. X/*   (MBX), the PEX escapes defined by Hewlett-Packard and Evans & Sutherland */
  716. X/*   and the use of pixmaps.                                                  */
  717. X/*                                                                            */
  718. X/*   The utilities first attempt to use MBX.  If MBX is not available, then   */
  719. X/*   the double-buffer escapes are attempted.  Pixmaps are the last option.   */
  720. X/*                                                                            */
  721. X/* User Functions:                                                            */
  722. X/*   PEXUtDBConfig  - configure a window for double-buffering                 */
  723. X/*   PEXUtDBSwap    - swap the window buffers and clear the back buffer       */
  724. X/*   PEXUtDBClear   - clear the window back buffer                            */
  725. X/*   PEXUtDBFront   - reconfigure the window to render in the front buffer    */
  726. X/*   PEXUtDBResize  - resize window buffers                                   */
  727. X/*                                                                            */
  728. X/* File Content:                                                              */
  729. X/*   This file contains constants for application use with the PEXlib         */
  730. X/*   double-buffer utilities.                                                 */
  731. X/*                                                                            */
  732. X/*                                                                            */
  733. X/* Other Documentation:                                                       */
  734. X/*   Title:     "Double-Buffering Utilities for PEXlib"                       */
  735. X/*   Author:    Jeff Stevenson; Hewlett-Packard Co.                           */
  736. X/*   Dated:     November 6, 1992                                              */
  737. X/*                                                                            */
  738. X/******************************************************************************/
  739. X
  740. X
  741. X#ifndef _PEXUTDB_H_ /* [ */
  742. X#define _PEXUTDB_H_
  743. X
  744. X
  745. X#ifndef NeedFunctionPrototypes
  746. X#if defined(FUNCPROTO) || defined(__STDC__) || \
  747. X    defined(__cplusplus) || defined(c_plusplus)
  748. X#define NeedFunctionPrototypes  1
  749. X#else
  750. X#define NeedFunctionPrototypes  0
  751. X#endif /* FUNCPROTO, __STDC__, __cplusplus, c_plusplus */
  752. X#endif /* NeedFunctionPrototypes */
  753. X
  754. X
  755. X#ifdef __cplusplus   /* do not leave open across includes */
  756. Xextern "C" {         /* for C++ V2.0 */
  757. X#endif
  758. X
  759. X
  760. X/*
  761. X** constants for PEXUtDBConfig
  762. X*/
  763. X#define PEXUTDBOKAY     0               /* PEXUtDBConfig was successful       */
  764. X#define PEXUTDBNODB     1               /* double-buffer not supported        */
  765. X#define PEXUTDBNODBX    2               /* double-buffer not supported for X  */
  766. X#define PEXUTDBNOTPEX5  3               /* PEX extension major version not 5  */
  767. X#define PEXUTDBNOMEM    4               /* memory allocation error in utility */
  768. X
  769. X/*
  770. X** constants for PEXUtDBFront
  771. X*/
  772. X/* reuse PEXUTDBOKAY defined above */    /* PEXUtDBFront was successful       */
  773. X#define PEXUTDBNOSUPPORT 1               /* render to front buf not supported */
  774. X#define PEXUTDBFAIL      2               /* other failure in PEXUtDBFront     */
  775. X
  776. X
  777. X
  778. X/*
  779. X** define NULL, if necessary
  780. X*/
  781. X#ifndef NULL /* [ */
  782. X#define NULL 0
  783. X#endif /* NULL  ] */
  784. X
  785. X
  786. X/*
  787. X** function declarations
  788. X*/
  789. X
  790. X/******************************************************************************/
  791. X/*                                                                            */
  792. X/* Function:                                                                  */
  793. X/*   PEXUtDBConfig  - configure a window for double-buffering                 */
  794. X/*                                                                            */
  795. X/* Description:                                                               */
  796. X/*   The PEXUtDBConfig function configures the specified window for double-   */
  797. X/*   buffered rendering (if db_on == True) or configures the specified window */
  798. X/*   for single-buffered rendering (if db_on == False). The utilities support */
  799. X/*   double-buffered rendering for PEX primitives, and if requested (db_x ==  */
  800. X/*   True), for X and PEX primitives together.                                */
  801. X/*                                                                            */
  802. X/*   If the window is configured for double-buffering, the back buffer is     */
  803. X/*   cleared to the specified background color.                               */
  804. X/*                                                                            */
  805. X/* Returns:                                                                   */
  806. X/*   The function returns a value of zero (PEXUTDBOKAY) if it is successful;  */
  807. X/*   a non-zero return value indicates failure. The following are the meaning */
  808. X/*   of the different non-zero return values:                                 */
  809. X/*                                                                            */
  810. X/*     * A return value of PEXUTDBNODB means that double-buffering was        */
  811. X/*       requested (db_on == True), but double-buffering is not supported for */
  812. X/*       this window.                                                         */
  813. X/*                                                                            */
  814. X/*     * A return value of PEXUTDBNODBX means that double-buffered rendering  */
  815. X/*       for both X and PEX was requested (db_x == True), but is not          */
  816. X/*       supported for this window. If acceptable, the application should     */
  817. X/*       retry with db_x set to False which will double-buffer only PEX       */
  818. X/*       rendering.                                                           */
  819. X/*                                                                            */
  820. X/*     * A return value of PEXUTDBNOT5 means that the PEX server major        */
  821. X/*       version was not 5. These utilities are designed only to work with    */
  822. X/*       5.0 and 5.1 compatible servers.                                      */
  823. X/*                                                                            */
  824. X/*     * A return value of PEXUTDBNOMEM means that the utilities ran out of   */
  825. X/*       memory.                                                              */
  826. X/*                                                                            */
  827. X/* Arguments:                                                                 */
  828. X/*   dpy, win       - The dpy and win arguments specify the display and       */
  829. X/*                    window (respectively) to be configured.                 */
  830. X/*                                                                            */
  831. X/*   db_on          - db_on indicates whether the window is configured for    */
  832. X/*                    double-buffering (db_on == True) or single-buffering    */
  833. X/*                    (db_on == False).                                       */
  834. X/*                                                                            */
  835. X/*   bg_color       - bg_color specifies the background color values used     */
  836. X/*                    when clearing and should be the same color as the       */
  837. X/*                    window's background. The application must ensure that   */
  838. X/*                    both the pixel value and the red, green and blue values */
  839. X/*                    are valid in bg_color. These values should have been    */
  840. X/*                    set or computed during window creation and              */
  841. X/*                    configuration. (One way to obtain the pixel value is    */
  842. X/*                    XAllocColor which returns the pixel value for a         */
  843. X/*                    specified red, green and blue color triplet. One way to */
  844. X/*                    obtain the triplet values is XQueryColor which return   */
  845. X/*                    the red, green and blue component values for a          */
  846. X/*                    specified pixel value. There are other methods          */
  847. X/*                    available in Xlib depending on the application needs.)  */
  848. X/*                                                                            */
  849. X/*   db_x           - db_x indicates whether the application requires the     */
  850. X/*                    double-buffered rendering to support both X and PEX.  A */
  851. X/*                    value of True forces the use of a mechanism that will   */
  852. X/*                    support both X and PEX double-buffered rendering.       */
  853. X/*                                                                            */
  854. X/*   drw_id_return  - drw_id_return is a pointer to a drawable identifier.    */
  855. X/*                    This is the drawable identifier to be used for          */
  856. X/*                    subsequent rendering calls for X and PEX. For example,  */
  857. X/*                    this drawable identifier should be used for             */
  858. X/*                    PEXBeginRendering or PEXRenderNetwork, as well as for X */
  859. X/*                    rendering calls like XDrawLine. The returned value is a */
  860. X/*                    Null pointer if the function is unsuccessful.           */
  861. X/*                                                                            */
  862. X/* Restrictions:                                                              */
  863. X/*   If it is necessary to ensure that all actions have completed before      */
  864. X/*   proceeding, the application should call XSync after calling              */
  865. X/*   PEXUtDBConfig.                                                           */
  866. X/*                                                                            */
  867. X/*   This function assumes that PEXInitialize has been called for the         */
  868. X/*   specified display argument.                                              */
  869. X/*                                                                            */
  870. X/*   Renderer clip lists do not affect the clear operation. The entire back   */
  871. X/*   buffer is cleared.                                                       */
  872. X/*                                                                            */
  873. X/*   If the PEX server is version 5.0, and MBX is not available, pixmaps are  */
  874. X/*   the only other option. However, there is no way to determine if a 5.0    */
  875. X/*   PEX server supports rendering into pixmaps. In this case, PEXUtDBConfig  */
  876. X/*   will configure the window for double-buffering via pixmap, but the       */
  877. X/*   application should be prepared to receive an error from the first        */
  878. X/*   PEXBeginRendering or PEXRenderNetwork with the drawable identifier       */
  879. X/*   returned from PEXUtDBConfig. If an error does result, that error is the  */
  880. X/*   application's indication that double-buffering is not supported for the  */
  881. X/*   specified window.                                                        */
  882. X/*                                                                            */
  883. X/******************************************************************************/
  884. Xextern int PEXUtDBConfig(
  885. X#if NeedFunctionPrototypes
  886. X    Display *           /* dpy */,
  887. X    Window              /* win */,
  888. X    int                 /* db_on */,
  889. X    XColor *            /* bg_color */,
  890. X    int                 /* db_x */,
  891. X    Drawable *          /* drw_id_return */
  892. X#endif
  893. X);
  894. X
  895. X/******************************************************************************/
  896. X/*                                                                            */
  897. X/* Function:                                                                  */
  898. X/*   PEXUtDBSwap    - swap the window buffers and clear the back buffer       */
  899. X/*                                                                            */
  900. X/* Description:                                                               */
  901. X/*   The PEXUtDBSwap function will swap the buffers of a window which is      */
  902. X/*   configured for double-buffering. If the window is not configured for     */
  903. X/*   double-buffering, the function will clear the window (if clear == True)  */
  904. X/*   and return the specified window identifier.                              */
  905. X/*                                                                            */
  906. X/*   Swapping the buffers means that the currently displayed buffer (i.e.,    */
  907. X/*   the front buffer) is hidden, and the currently non-displayed buffer      */
  908. X/*   (i.e., the back buffer) is made visible. After this operation, the front */
  909. X/*   and back buffers have swapped positions (i.e., the old front became the  */
  910. X/*   new back, and the old back become the new front).                        */
  911. X/*                                                                            */
  912. X/*   If PEXUtDBFront was called with front == True prior to PEXUtDBSwap, the  */
  913. X/*   returned drawable identifier is the identifier of the front buffer.      */
  914. X/*   Otherwise, the returned drawable identifier is the identifier of the     */
  915. X/*   back buffer.                                                             */
  916. X/*                                                                            */
  917. X/*   On PEX 5.1 servers, the best way to clear the back buffer is to clear    */
  918. X/*   during the next PEXBeginRendering or PEXRenderNetwork with the drawable  */
  919. X/*   identifier returned. (This is done by setting the renderer's clear_image */
  920. X/*   flag to True.)  In this case, the clear argument to PEXUtDBSwap should   */
  921. X/*   be False.                                                                */
  922. X/*                                                                            */
  923. X/*   On PEX 5.0 servers, the back buffer should be cleared by setting the     */
  924. X/*   clear argument to True, unless the application wants to render into the  */
  925. X/*   back buffer without clearing.                                            */
  926. X/*                                                                            */
  927. X/*   PEXUtDBClear is also provided to clear the back buffer independently of  */
  928. X/*   swapping the buffers. However, there are some restrictions on when it    */
  929. X/*   can be called (see PEXUtDBClear).                                        */
  930. X/*                                                                            */
  931. X/* Returns:                                                                   */
  932. X/*   The function returns a value of None if it is unsuccessful; otherwise,   */
  933. X/*   the drawable identifier to be used for subsequent rendering calls is     */
  934. X/*   returned. See also the description of the drw_id_return argument for     */
  935. X/*   PEXUtDBConfig.                                                           */
  936. X/*                                                                            */
  937. X/* Arguments:                                                                 */
  938. X/*   dpy, win      - The dpy and win arguments specify the display and window */
  939. X/*                   for which buffers are swapped.                           */
  940. X/*                                                                            */
  941. X/*   clear         - The clear argument indicates whether to clear the new    */
  942. X/*                   back buffer after the buffers are swapped.               */
  943. X/*                                                                            */
  944. X/* Restrictions:                                                              */
  945. X/*   If it is necessary to ensure that all actions have completed before      */
  946. X/*   proceeding, the application should call XSync after calling PEXUtDBSwap. */
  947. X/*                                                                            */
  948. X/*   This function should not be called with a window into which PEX is       */
  949. X/*   rendering. PEXEndRendering should be called prior to PEXUtDBSwap.        */
  950. X/*                                                                            */
  951. X/*   Renderer clip lists do not affect the clear operation. The entire back   */
  952. X/*   buffer is cleared.                                                       */
  953. X/*                                                                            */
  954. X/******************************************************************************/
  955. Xextern Drawable PEXUtDBSwap(
  956. X#if NeedFunctionPrototypes
  957. X    Display *           /* dpy */,
  958. X    Window              /* win */,
  959. X    int                 /* clear */
  960. X#endif
  961. X);
  962. X
  963. X/******************************************************************************/
  964. X/*                                                                            */
  965. X/* Function:                                                                  */
  966. X/*   PEXUtDBClear   - clear the window back buffer                            */
  967. X/*                                                                            */
  968. X/* Description:                                                               */
  969. X/*   The PEXUtDBClear function will clear the back buffer associated with the */
  970. X/*   specified window. If the window is not configured for double-buffering,  */
  971. X/*   the function will clear the window.                                      */
  972. X/*                                                                            */
  973. X/*   On PEX 5.1 servers, the best way to clear the back buffer is to clear    */
  974. X/*   during PEXBeginRendering or PEXRenderNetwork with the drawable           */
  975. X/*   identifier of the back buffer. (This is done by setting the renderer's   */
  976. X/*   clear_image flag to True.)                                               */
  977. X/*                                                                            */
  978. X/*   On PEX 5.0 servers, the back buffer can also be cleared by setting the   */
  979. X/*   clear argument in PEXUtDBSwap to True.                                   */
  980. X/*                                                                            */
  981. X/* Returns:                                                                   */
  982. X/*   The function returns a value of zero if it is successful; otherwise, a   */
  983. X/*   non-zero value is returned.                                              */
  984. X/*                                                                            */
  985. X/* Arguments:                                                                 */
  986. X/*   dpy, win      - The dpy and win arguments specify the display and window */
  987. X/*                   for which the back buffer is cleared.                    */
  988. X/*                                                                            */
  989. X/* Restrictions:                                                              */
  990. X/*   TODO: UPDATE PER SPEC                                                    */
  991. X/*   If it is necessary to ensure that all actions have completed before      */
  992. X/*   proceeding, the application should call XSync after calling PEXUtDBClear.*/
  993. X/*                                                                            */
  994. X/*   This function should not be called with a window into which PEX is       */
  995. X/*   rendering. PEXEndRendering should be called prior to PEXUtDBClear.       */
  996. X/*                                                                            */
  997. X/*   Renderer clip lists do not affect the clear operation. The entire back   */
  998. X/*   buffer is cleared.                                                       */
  999. X/*                                                                            */
  1000. X/******************************************************************************/
  1001. Xextern int PEXUtDBClear(
  1002. X#if NeedFunctionPrototypes
  1003. X    Display *           /* dpy */,
  1004. X    Window              /* win */
  1005. X#endif
  1006. X);
  1007. X
  1008. X/******************************************************************************/
  1009. X/*                                                                            */
  1010. X/* Function:                                                                  */
  1011. X/*   PEXUtDBFront   - reconfigure the window to render in the front buffer    */
  1012. X/*                                                                            */
  1013. X/* Description:                                                               */
  1014. X/*   The PEXUtDBFront function configures a window, which is already          */
  1015. X/*   configured for double-buffering, to render into the displayed buffer     */
  1016. X/*   (i.e., the front buffer) if front == True. If the window is not          */
  1017. X/*   configured for double-buffering, the function will simply return the     */
  1018. X/*   specified window identifier.                                             */
  1019. X/*                                                                            */
  1020. X/* Returns:                                                                   */
  1021. X/*   The function returns a value of zero (PEXUTDBOKAY) if it is successful;  */
  1022. X/*   a non-zero return value indicates failure. The following are the meaning */
  1023. X/*   of the different non-zero return values:                                 */
  1024. X/*                                                                            */
  1025. X/*    * A return value of PEXUTDBNOSUPPORT means that rendering to the front  */
  1026. X/*      buffer is not supported on the specified drawable. The application    */
  1027. X/*      can still accomplish rendering to the front buffer by turning double- */
  1028. X/*      buffering off via PEXUtDBConfig. See the Restrictions below.          */
  1029. X/*                                                                            */
  1030. X/*    * A return value of PEXUTDBFAIL means that rendering to the front       */
  1031. X/*      buffer is supported, but the function failed to enable rendering to   */
  1032. X/*      the front buffer for some reason.                                     */
  1033. X/*                                                                            */
  1034. X/* Arguments:                                                                 */
  1035. X/*   dpy, win      - The dpy and win arguments specify the display and window */
  1036. X/*                   for which buffers are to be configured.                  */
  1037. X/*                                                                            */
  1038. X/*   front         - front indicates whether the window is configured to      */
  1039. X/*                   render into the front (i.e. the displayed or visible)    */
  1040. X/*                   buffer. A value of False means the window is configured  */
  1041. X/*                   to render into the back (i.e. the non-visible buffer).   */
  1042. X/*                   A value of True means the window is configured to render */
  1043. X/*                   into the front buffer.                                   */
  1044. X/*                                                                            */
  1045. X/*   drw_id_return - drw_id_return is a pointer to a drawable identifier.     */
  1046. X/*                   This is the drawable identifier to be used for           */
  1047. X/*                   subsequent rendering calls for X and PEX. For example,   */
  1048. X/*                   this drawable identifier should be used for              */
  1049. X/*                   PEXBeginRendering or PEXRenderNetwork, as well as for X  */
  1050. X/*                   rendering calls like XDrawLine. The returned value is a  */
  1051. X/*                   Null pointer if the function is unsuccessful.            */
  1052. X/*                                                                            */
  1053. X/* Restrictions:                                                              */
  1054. X/*   If it is necessary to ensure that all actions have completed before      */
  1055. X/*   proceeding, the application should call XSync after calling PEXUtDBFront.*/
  1056. X/*                                                                            */
  1057. X/*   This function should not be called with a window into which PEX is       */
  1058. X/*   rendering. PEXEndRendering should be called prior to PEXUtDBFront. If    */
  1059. X/*   the application desires to render into the front buffer with out         */
  1060. X/*   clearing, and the PEX server is version 5.1, the renderer's clear_image  */
  1061. X/*   flag should be set to False before calling PEXBeginRendering.            */
  1062. X/*                                                                            */
  1063. X/*   PEXUtFront may not succeed on all devices. However, if PEXUtDBFront does */
  1064. X/*   fail, rendering to the front buffer can still be accomplished by turning */
  1065. X/*   double-buffering off via PEXUtDBConfig. It is recommended that the       */
  1066. X/*   application first call PEXUtDBFront since, if it is supported, it is     */
  1067. X/*   mostly likely a higher performance method than switching double-         */
  1068. X/*   buffering on and off with PEXUtDBConfig.                                 */
  1069. X/*                                                                            */
  1070. X/******************************************************************************/
  1071. Xextern int PEXUtDBFront(
  1072. X#if NeedFunctionPrototypes
  1073. X    Display *           /* dpy */,
  1074. X    Window              /* win */,
  1075. X    int                 /* front */,
  1076. X    Drawable *          /* drw_id_return */
  1077. X#endif
  1078. X);
  1079. X
  1080. X/******************************************************************************/
  1081. X/*                                                                            */
  1082. X/* Function:                                                                  */
  1083. X/*   PEXUtDBResize  - resize window buffers                                   */
  1084. X/*                                                                            */
  1085. X/* Description:                                                               */
  1086. X/*   The PEXUtDBResize function will resize buffers associated with a window  */
  1087. X/*   that is configured for double-buffering. If the window is not configured */
  1088. X/*   for double-buffering, the function will simply return the specified      */
  1089. X/*   window identifier.                                                       */
  1090. X/*                                                                            */
  1091. X/*   The application must handle window events and call this utility function */
  1092. X/*   at the appropriate time to handle window resize.                         */
  1093. X/*                                                                            */
  1094. X/*   The content of the buffers is not guaranteed to be preserved after the   */
  1095. X/*   resize. The best practice for interoperability is to redraw the image    */
  1096. X/*   after a window resize.                                                   */
  1097. X/*                                                                            */
  1098. X/*   If PEXUtDBFront was called with front == True prior to PEXUtDBResize,    */
  1099. X/*   the returned drawable identifier is the identifier of the front buffer.  */
  1100. X/*   Otherwise, the returned drawable identifier is the identifier of the     */
  1101. X/*   back buffer.                                                             */
  1102. X/*                                                                            */
  1103. X/* Returns:                                                                   */
  1104. X/*   The function returns a value of None if it is unsuccessful; otherwise,   */
  1105. X/*   the drawable identifier to be used for subsequent rendering calls is     */
  1106. X/*   returned. See also the description of the drw_id_return argument for     */
  1107. X/*   PEXUtDBConfig.                                                           */
  1108. X/*                                                                            */
  1109. X/* Arguments:                                                                 */
  1110. X/*   dpy, win      - The dpy and win arguments specify the display and window */
  1111. X/*                   for which buffers are resized.                           */
  1112. X/*                                                                            */
  1113. X/* Restrictions:                                                              */
  1114. X/*   If it is necessary to ensure that all actions have completed before      */
  1115. X/*   proceeding, the application should call XSync after calling              */
  1116. X/*   PEXUtDBResize.                                                           */
  1117. X/*                                                                            */
  1118. X/*   This function should not be called with a window into which PEX is       */
  1119. X/*   rendering. PEXEndRendering should be called prior to PEXUtDBResize.      */
  1120. X/*                                                                            */
  1121. X/******************************************************************************/
  1122. Xextern Drawable PEXUtDBResize(
  1123. X#if NeedFunctionPrototypes
  1124. X    Display *           /* dpy */,
  1125. X    Window              /* win */
  1126. X#endif
  1127. X);
  1128. X
  1129. X
  1130. X#ifdef __cplusplus
  1131. X}                    /* for C++ V2.0 */
  1132. X#endif
  1133. X
  1134. X
  1135. X#endif /* _PEXUTDB_H_ ] */
  1136. END_OF_FILE
  1137.   if test 30692 -ne `wc -c <'util/pexutdb.h'`; then
  1138.     echo shar: \"'util/pexutdb.h'\" unpacked with wrong size!
  1139.   fi
  1140.   # end of 'util/pexutdb.h'
  1141. fi
  1142. echo shar: End of archive 8 \(of 14\).
  1143. cp /dev/null ark8isdone
  1144. MISSING=""
  1145. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
  1146.     if test ! -f ark${I}isdone ; then
  1147.     MISSING="${MISSING} ${I}"
  1148.     fi
  1149. done
  1150. if test "${MISSING}" = "" ; then
  1151.     echo You have unpacked all 14 archives.
  1152.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1153.     echo "concatentating pexdraw.c ..."
  1154.     cat pexdrawc.? > pexdraw.c
  1155.     rm pexdrawc.?
  1156.     echo "concatentating pexdraw.uil ..."
  1157.     cat pexdrawu.? > pexdraw.uil
  1158.     rm pexdrawu.?
  1159.     echo "concatentating teapot.c ..."
  1160.     rm teapotc.?
  1161. else
  1162.     echo You still must unpack the following archives:
  1163.     echo "        " ${MISSING}
  1164. fi
  1165. exit 0
  1166. exit 0 # Just in case...
  1167. -- 
  1168.   // chris@IMD.Sterling.COM       | Send comp.sources.x submissions to:
  1169. \X/  Amiga - The only way to fly! |    sources-x@imd.sterling.com
  1170.  "It's intuitively obvious to the |
  1171.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  1172.