Ejemplo n.º 1
0
void 
BWCopy(Widget w, Position at_x, Position at_y, int value)
{
    BitmapWidget BW = (BitmapWidget) w;
    XImage *storage;
    char *storage_data;
    Dimension width, height;

    if (QuerySet(BW->bitmap.mark.from_x, BW->bitmap.mark.from_y)) {

	width = BW->bitmap.mark.to_x - BW->bitmap.mark.from_x + 1;
	height = BW->bitmap.mark.to_y - BW->bitmap.mark.from_y + 1;
	
	storage_data = CreateCleanData(Length(width, height));

	storage = CreateBitmapImage(BW, storage_data, width, height);

	CopyImageData(BW->bitmap.image, storage,
		      BW->bitmap.mark.from_x,  BW->bitmap.mark.from_y,
		      BW->bitmap.mark.to_x,  BW->bitmap.mark.to_y,
		      0, 0);

	DrawImageData(BW, storage, at_x, at_y, value);

	DestroyBitmapImage(&storage);
    }
}
Ejemplo n.º 2
0
void 
BWStore(Widget w)
{
    BitmapWidget BW = (BitmapWidget) w;
    Dimension width, height;
    char *storage_data;

    if (QuerySet(BW->bitmap.mark.from_x, BW->bitmap.mark.from_y)) {

	DestroyBitmapImage(&BW->bitmap.storage);

	width = BW->bitmap.mark.to_x - BW->bitmap.mark.from_x + 1;
	height = BW->bitmap.mark.to_y - BW->bitmap.mark.from_y + 1;
	
	storage_data = CreateCleanData(Length(width, height));

	BW->bitmap.storage = CreateBitmapImage(BW,
					       storage_data,
					       width, height);

	CopyImageData(BW->bitmap.image, BW->bitmap.storage,
		      BW->bitmap.mark.from_x,  BW->bitmap.mark.from_y,
		      BW->bitmap.mark.to_x,  BW->bitmap.mark.to_y,
		      0, 0);
    }
}
Ejemplo n.º 3
0
/* ARGSUSED */
static void
SelectionCallback(Widget w, XtPointer cldat, Atom *selection, Atom *type,
		  XtPointer val, unsigned long *length, int *format)
{
    XPointer value = (XPointer)val;
    BitmapWidget BW = (BitmapWidget) w;
    Pixmap *pixmap;

   switch (*type) {

    case XA_BITMAP:
    case XA_PIXMAP:
	DestroyBitmapImage(&BW->bitmap.storage);
	pixmap = (Pixmap *) value;
	BW->bitmap.storage = GetImage(BW, *pixmap);
	XFree((char *)pixmap);
	break;

    default:
	XtWarning(" selection request failed.  BitmapWidget");
	break;
    }

    BW->bitmap.selection.limbo = FALSE;
}
Ejemplo n.º 4
0
/* ARGSUSED */
static Boolean
ConvertSelection(Widget w, Atom *selection, Atom *target, Atom *type,
		 XtPointer *val_ret, unsigned long *length, int *format)
{
    XPointer *value = (XPointer *)val_ret;
    BitmapWidget BW = (BitmapWidget) w;
    Pixmap *pixmap;
    char *data;
    XImage *image;
    Dimension width, height;

    switch (*target) {

/*  XA_TARGETS undefined ?!?

    case XA_TARGETS:
	*type = XA_ATOM;
	*value = (XPointer) bitmapClassRec.bitmap_class.targets;
	*length = bitmapClassRec.bitmap_class.num_targets;
	*format = 32;
	return True;

*/

    case XA_BITMAP:
    case XA_PIXMAP:
	if (BWQueryMarked(w)) {
	  width = BW->bitmap.mark.to_x - BW->bitmap.mark.from_x + 1;
	  height = BW->bitmap.mark.to_y - BW->bitmap.mark.from_y + 1;
	  data = CreateCleanData(Length(width, height));
	  image = CreateBitmapImage(BW, data, width, height);
	  CopyImageData(BW->bitmap.image, image,
			BW->bitmap.mark.from_x, BW->bitmap.mark.from_y,
			BW->bitmap.mark.to_x, BW->bitmap.mark.to_y, 0, 0);
	  pixmap = (Pixmap *) XtMalloc(sizeof(Pixmap));
	  *pixmap = GetPixmap(BW, image);
	  DestroyBitmapImage(&image);
	}
	else if (BWQueryStored(w)) {
	  pixmap = (Pixmap *) XtMalloc(sizeof(Pixmap));
	  *pixmap = GetPixmap(BW, BW->bitmap.storage);
	}
	else return False;
	*type = XA_PIXMAP;
	*value = (XPointer) pixmap;
	*length = 1;
	*format = 32;
	return True;

    default:
	return False;
    }
}
Ejemplo n.º 5
0
void 
BWFold(Widget w)
{
    BitmapWidget BW = (BitmapWidget) w;
    Position x, y, new_x, new_y;
    Dimension horiz, vert;
    char *storage_data;
    XImage *storage;
	
    storage_data = CreateCleanData(Length(BW->bitmap.image->width, 
					  BW->bitmap.image->height));

    storage = CreateBitmapImage(BW, storage_data, 
				(Dimension) BW->bitmap.image->width, 
				(Dimension) BW->bitmap.image->height);

    TransferImageData(BW->bitmap.image, storage);

    BW->bitmap.fold ^= True;
    horiz = (BW->bitmap.image->width + BW->bitmap.fold) / 2;
    vert = (BW->bitmap.image->height + BW->bitmap.fold) / 2;
    
    for (x = 0; x < BW->bitmap.image->width; x++)
	for (y = 0; y < BW->bitmap.image->height; y++) {
	    new_x = (int)(x + horiz) % (int)BW->bitmap.image->width;
	    new_y = (int)(y + vert) % (int)BW->bitmap.image->height;
	    if(GetBit(BW->bitmap.image, new_x, new_y) != 
	       GetBit(storage, x, y))
		InvertPoint(BW, new_x, new_y);
	}
    
    DestroyBitmapImage(&storage);

    if (QuerySet(BW->bitmap.hot.x, BW->bitmap.hot.y))
      BWSetHotSpot(w, 
		   (Position) 
		   ((int)(BW->bitmap.hot.x+horiz)
		    %(int)BW->bitmap.image->width),
		   (Position)
		   ((int)(BW->bitmap.hot.y+vert)
		    %(int)BW->bitmap.image->height)
		   );
}