home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Shareware 1999 March
/
PCShareware-3-99.iso
/
IMPLE
/
DJGPP.RAR
/
DJGPP2
/
XLIB-SR0.ZIP
/
SRC
/
XLIBEMU
/
COPYAREA.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-14
|
4KB
|
149 lines
/* $Id: copyarea.c 1.2 1994/01/15 02:12:35 ulrich Exp $ */
/*
* copyarea.c
*
* X library function XCopyArea.
* GC Functions are only partly implemented.
*/
#include "Xlibemu.h"
#ifdef DEBUG
#include <stdio.h>
#endif
extern int _GXfunctionToGrOPER[];
int
XCopyArea(
Display* dpy,
Drawable src,
Drawable dest,
GC gc,
int src_x,
int src_y,
unsigned int width,
unsigned int height,
int dest_x,
int dest_y)
{
int oper;
GrContext *src_mem, *dest_mem;
oper = _GXfunctionToGrOPER[gc->values.function];
switch (src->type) {
case 2:
src_mem = ((Window) src)->context;
break;
case 3:
src_mem = ((Pixmap) src)->context;
break;
default:
return 0;
break;
}
switch (dest->type) {
case 2:
dest_mem = ((Window) dest)->context;
{
int i, dest_x1, dest_y1;
XRectangle rect;
Region region;
BoxPtr pbox;
Window dest_w = (Window) dest;
dest_x1 = dest_w->window_port.x1;
dest_y1 = dest_w->window_port.y1;
rect.x = dest_x1 + dest_x;
rect.y = dest_y1 + dest_y;
rect.width = width;
rect.height = height;
region = XCreateRegion ();
XUnionRectWithRegion (&rect, region, region);
XIntersectRegion (dest_w->visible_region, region, region);
XOffsetRegion (region, -rect.x, -rect.y);
pbox = region->rects;
for (i = region->numRects; --i >= 0; pbox++) {
GrBitBlt (dest_mem,
dest_x + pbox->x1,
dest_y + pbox->y1,
src_mem,
src_x + pbox->x1,
src_y + pbox->y1,
src_x + pbox->x2 - 1,
src_y + pbox->y2 - 1,
oper);
}
XDestroyRegion (region);
if (src->type == 2 && gc->values.graphics_exposures == True) {
int dx, dy;
XEvent xe;
Window src_w = (Window) src;
region = XCreateRegion ();
rect.x = src_w->window_port.x1 + src_x;
rect.y = src_w->window_port.y1 + src_y;
rect.width = width;
rect.height = height;
XUnionRectWithRegion (&rect, region, region);
XSubtractRegion (region, src_w->visible_region, region);
/* move not available src region to dest window */
dx = (dest_x1 + dest_x) - rect.x;
dy = (dest_y1 + dest_y) - rect.y;
XOffsetRegion (region, dx, dy);
XIntersectRegion (dest_w->visible_region, region, region);
pbox = region->rects;
for (i = region->numRects; --i >= 0; pbox++) {
xe.xgraphicsexpose.type = GraphicsExpose;
xe.xgraphicsexpose.send_event = False;
xe.xgraphicsexpose.display = dpy;
xe.xgraphicsexpose.drawable = dest;
xe.xgraphicsexpose.x = pbox->x1 - dest_x1;
xe.xgraphicsexpose.y = pbox->y1 - dest_y1;
xe.xgraphicsexpose.width = pbox->x2 - pbox->x1;
xe.xgraphicsexpose.height = pbox->y2 - pbox->y1;
#if 0
fprintf (stderr, "GE src=%x dest=%x count=%d x1=%d y1=%d x2=%d y2=%d\n",
(int) src, (int) dest, i, b->x1, b->y1, b->x2, b->y2);
#endif
xe.xgraphicsexpose.count = i;
xe.xgraphicsexpose.major_code = X_CopyArea;
xe.xgraphicsexpose.minor_code = 0;
_XEnq (dpy, &xe);
}
if (region->numRects == 0) {
xe.xnoexpose.type = NoExpose;
xe.xnoexpose.send_event = False;
xe.xnoexpose.display = dpy;
xe.xnoexpose.drawable = dest;
xe.xnoexpose.major_code = X_CopyArea;
xe.xnoexpose.minor_code = 0;
_XEnq (dpy, &xe);
}
XDestroyRegion (region);
}
}
break;
case 3:
dest_mem = ((Pixmap) dest)->context;
{
GrBitBlt (dest_mem,
dest_x, dest_y,
src_mem,
src_x, src_y, src_x + width - 1, src_y + height - 1,
oper);
}
break;
default:
return 0;
break;
}
return 1;
}