aboutsummaryrefslogtreecommitdiff
path: root/Mosaic.c
diff options
context:
space:
mode:
Diffstat (limited to 'Mosaic.c')
-rw-r--r--Mosaic.c154
1 files changed, 75 insertions, 79 deletions
diff --git a/Mosaic.c b/Mosaic.c
index 22331ee..9557135 100644
--- a/Mosaic.c
+++ b/Mosaic.c
@@ -38,11 +38,7 @@
#include "Item.h"
#include "Geo.h"
-#ifdef XTOOLKIT
-#include "Radar.h"
-#else
/* PLC : à completer */
-#endif
/*
@@ -56,7 +52,7 @@
static const char rcsid[] = "$Imagine: Mosaic.c,v 1.7 1997/08/11 12:29:18 lecoanet Exp $";
static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ " $";
-static const char invalid_attribute[] = "RadarMosaic : Invalid attribute.";
+static const char invalid_attribute[] = "ZnMosaic : Invalid attribute.";
static const char read_only_attribute[] = "This attribute is read only.";
@@ -77,7 +73,7 @@ typedef struct _MosaicItemStruct {
int tile_size;
int row_count; /* Number of tiles per row */
int column_count; /* Number of tiles per column */
- RadarColor *tile_palette; /* Color palette for tiles */
+ ZnColor *tile_palette; /* Color palette for tiles */
int *color_usage; /* Numbers of merged rectangles */
/* using the corresponding color */
/* in the palette. */
@@ -136,10 +132,10 @@ Clone(Item item)
item->user_data = NULL;
if (mosaic->tile_palette) {
- RadarColor *tile_palette;
+ ZnColor *tile_palette;
- tile_palette = (RadarColor *) RadarMalloc(mosaic->palette_size*sizeof(RadarColor));
- memcpy(tile_palette, mosaic->tile_palette, mosaic->palette_size*sizeof(RadarColor));
+ tile_palette = (ZnColor *) ZnMalloc(mosaic->palette_size*sizeof(ZnColor));
+ memcpy(tile_palette, mosaic->tile_palette, mosaic->palette_size*sizeof(ZnColor));
mosaic->tile_palette = tile_palette;
}
@@ -149,7 +145,7 @@ Clone(Item item)
if (mosaic->color_usage) {
int *color_usage;
- color_usage = (int *) RadarMalloc(mosaic->palette_size*sizeof(int));
+ color_usage = (int *) ZnMalloc(mosaic->palette_size*sizeof(int));
memcpy(color_usage, mosaic->color_usage, mosaic->palette_size*sizeof(int));
mosaic->color_usage = color_usage;
}
@@ -158,7 +154,7 @@ Clone(Item item)
int size = mosaic->row_count*mosaic->column_count*sizeof(unsigned char);
unsigned char *tile_colors;
- tile_colors = (unsigned char *) RadarMalloc(size);
+ tile_colors = (unsigned char *) ZnMalloc(size);
memcpy(tile_colors, mosaic->tile_colors, size);
mosaic->tile_colors = tile_colors;
}
@@ -179,15 +175,15 @@ Remove(Item item)
MosaicItem mosaic = (MosaicItem) item;
if (mosaic->tile_palette) {
- RadarFree(mosaic->tile_palette);
+ ZnFree(mosaic->tile_palette);
}
if (mosaic->color_usage) {
- RadarFree(mosaic->color_usage);
+ ZnFree(mosaic->color_usage);
}
if (mosaic->tile_colors) {
- RadarFree(mosaic->tile_colors);
+ ZnFree(mosaic->tile_colors);
}
}
@@ -202,54 +198,54 @@ Remove(Item item)
static void
Configure(Item item,
- RadarList attrs,
- RadarBool *draw_item,
- RadarBool *draw_label,
- RadarBool *compute_coord,
- RadarBool init)
+ ZnList attrs,
+ ZnBool *draw_item,
+ ZnBool *draw_label,
+ ZnBool *compute_coord,
+ ZnBool init)
{
WidgetInfo *wi = item->wi;
MosaicItem mosaic = (MosaicItem) item;
- RadarAttr *attr;
+ ZnAttr *attr;
unsigned int i, size, num_attrs;
- RadarBool b_value;
+ ZnBool b_value;
unsigned char *tile_colors = NULL;
- RadarColor *tile_palette = NULL;
- RadarBool resize_palette = False;
- RadarBool resize_colors = False;
+ ZnColor *tile_palette = NULL;
+ ZnBool resize_palette = False;
+ ZnBool resize_colors = False;
- num_attrs = RadarListSize(attrs);
+ num_attrs = ZnListSize(attrs);
for (i = 0; i < num_attrs; i++) {
- attr = (RadarAttr *) RadarListAt(attrs, i);
+ attr = (ZnAttr *) ZnListAt(attrs, i);
switch (attr->name) {
ITEM_COMMON_CONFIGURE;
- case RadarItemX:
+ case ZnItemX:
if (mosaic->x != attr->value) {
mosaic->x = attr->value;
*draw_item = *compute_coord = True;
}
break;
- case RadarItemY:
+ case ZnItemY:
if (mosaic->y != attr->value) {
mosaic->y = attr->value;
*draw_item = *compute_coord = True;
}
break;
- case RadarItemTilePalette:
- tile_palette = (RadarColor *) attr->value;
+ case ZnItemTilePalette:
+ tile_palette = (ZnColor *) attr->value;
*draw_item = True;
break;
- case RadarItemTileColors:
+ case ZnItemTileColors:
tile_colors = (unsigned char *) attr->value;
*draw_item = True;
break;
- case RadarItemTileSize:
+ case ZnItemTileSize:
if (attr->value >= 0 &&
mosaic->tile_size != attr->value) {
mosaic->tile_size = attr->value;
@@ -257,14 +253,14 @@ Configure(Item item,
}
break;
- case RadarItemPaletteSize:
+ case ZnItemPaletteSize:
if (attr->value >= 0) {
mosaic->palette_size = attr->value;
resize_palette = True;
}
break;
- case RadarItemRowCount:
+ case ZnItemRowCount:
if (attr->value >= 0 && mosaic->row_count != attr->value) {
mosaic->row_count = attr->value;
resize_colors = True;
@@ -272,7 +268,7 @@ Configure(Item item,
}
break;
- case RadarItemColumnCount:
+ case ZnItemColumnCount:
if (attr->value >= 0 && mosaic->column_count != attr->value) {
mosaic->column_count = attr->value;
resize_colors = True;
@@ -281,27 +277,27 @@ Configure(Item item,
break;
default:
- RadarWarning(invalid_attribute);
+ ZnWarning(invalid_attribute);
break;
}
}
if (tile_palette) {
if (mosaic->tile_palette) {
- RadarFree(mosaic->tile_palette);
+ ZnFree(mosaic->tile_palette);
}
- mosaic->tile_palette = (RadarColor *) RadarMalloc(mosaic->palette_size*sizeof(RadarColor));
- memcpy(mosaic->tile_palette, tile_palette, mosaic->palette_size*sizeof(RadarColor));
+ mosaic->tile_palette = (ZnColor *) ZnMalloc(mosaic->palette_size*sizeof(ZnColor));
+ memcpy(mosaic->tile_palette, tile_palette, mosaic->palette_size*sizeof(ZnColor));
}
else if (resize_palette) {
- tile_palette = (RadarColor *) RadarMalloc(mosaic->palette_size*sizeof(RadarColor));
- memcpy(tile_palette, mosaic->tile_palette, mosaic->palette_size*sizeof(RadarColor));
- RadarFree(mosaic->tile_palette);
+ tile_palette = (ZnColor *) ZnMalloc(mosaic->palette_size*sizeof(ZnColor));
+ memcpy(tile_palette, mosaic->tile_palette, mosaic->palette_size*sizeof(ZnColor));
+ ZnFree(mosaic->tile_palette);
mosaic->tile_palette = tile_palette;
/* The palette size has changed, erase the cached info
* and let the appropriate code fault on it to recreate.
*/
- RadarFree(mosaic->color_usage);
+ ZnFree(mosaic->color_usage);
mosaic->color_usage = NULL;
}
@@ -309,29 +305,29 @@ Configure(Item item,
/* Here we could optimize the damaged area. No
opt should be taken if init or compute_coord.*/
if (mosaic->tile_colors) {
- RadarFree(mosaic->tile_colors);
+ ZnFree(mosaic->tile_colors);
}
size = mosaic->row_count * mosaic->column_count;
- mosaic->tile_colors = (unsigned char *) RadarMalloc(size*sizeof(unsigned char));
+ mosaic->tile_colors = (unsigned char *) ZnMalloc(size*sizeof(unsigned char));
memcpy(mosaic->tile_colors, tile_colors, size*sizeof(unsigned char));
/*
* The color counts might need update, let the code fault on an
* empty cache.
*/
- RadarFree(mosaic->color_usage);
+ ZnFree(mosaic->color_usage);
mosaic->color_usage = NULL;
}
else if (resize_colors) {
size = mosaic->row_count * mosaic->column_count;
- tile_colors = (unsigned char *) RadarMalloc(size*sizeof(unsigned char));
+ tile_colors = (unsigned char *) ZnMalloc(size*sizeof(unsigned char));
memcpy(tile_colors, mosaic->tile_colors, size*sizeof(unsigned char));
- RadarFree(mosaic->tile_colors);
+ ZnFree(mosaic->tile_colors);
mosaic->tile_colors = tile_colors;
/*
* The color counts might need update, let the code fault on an
* empty cache.
*/
- RadarFree(mosaic->color_usage);
+ ZnFree(mosaic->color_usage);
mosaic->color_usage = NULL;
}
}
@@ -347,53 +343,53 @@ Configure(Item item,
static void
Query(Item item,
- RadarList attrs)
+ ZnList attrs)
{
MosaicItem mosaic = (MosaicItem) item;
unsigned int i, num_attrs;
- RadarAttr *attr;
+ ZnAttr *attr;
- num_attrs = RadarListSize(attrs);
+ num_attrs = ZnListSize(attrs);
for (i = 0; i < num_attrs; i++) {
- attr = (RadarAttr *) RadarListAt(attrs, i);
+ attr = (ZnAttr *) ZnListAt(attrs, i);
switch (attr->name) {
ITEM_COMMON_QUERY;
- case RadarItemX:
+ case ZnItemX:
*((int *) attr->value) = mosaic->x;
break;
- case RadarItemY:
+ case ZnItemY:
*((int *) attr->value) = mosaic->y;
break;
- case RadarItemTilePalette:
- *((RadarColor **) attr->value) = mosaic->tile_palette;
+ case ZnItemTilePalette:
+ *((ZnColor **) attr->value) = mosaic->tile_palette;
break;
- case RadarItemTileColors:
+ case ZnItemTileColors:
*((unsigned char **) attr->value) = mosaic->tile_colors;
break;
- case RadarItemTileSize:
+ case ZnItemTileSize:
*((int *) attr->value) = mosaic->tile_size;
break;
- case RadarItemPaletteSize:
+ case ZnItemPaletteSize:
*((int *) attr->value) = mosaic->palette_size;
break;
- case RadarItemRowCount:
+ case ZnItemRowCount:
*((int *) attr->value) = mosaic->row_count;
break;
- case RadarItemColumnCount:
+ case ZnItemColumnCount:
*((int *) attr->value) = mosaic->column_count;
break;
default:
- RadarWarning(invalid_attribute);
+ ZnWarning(invalid_attribute);
break;
}
}
@@ -413,7 +409,7 @@ ComputeCoordinates(Item item)
{
WidgetInfo *wi = item->wi;
MosaicItem mosaic = (MosaicItem) item;
- RadarPos x_dev, y_dev;
+ ZnPos x_dev, y_dev;
ResetBBox(&item->item_bounding_box);
@@ -424,8 +420,8 @@ ComputeCoordinates(Item item)
/* Compute bounding box */
AddPointToBBox(&item->item_bounding_box, x_dev, y_dev);
AddPointToBBox(&item->item_bounding_box,
- x_dev + (RadarPos) LENGTH_TO_DEVICE(wi, mosaic->tile_size * mosaic->column_count),
- y_dev + (RadarPos) LENGTH_TO_DEVICE(wi, mosaic->tile_size * mosaic->row_count));
+ x_dev + (ZnPos) LENGTH_TO_DEVICE(wi, mosaic->tile_size * mosaic->column_count),
+ y_dev + (ZnPos) LENGTH_TO_DEVICE(wi, mosaic->tile_size * mosaic->row_count));
}
@@ -460,12 +456,12 @@ Draw(Item item)
{
WidgetInfo *wi = item->wi;
MosaicItem mosaic = (MosaicItem) item;
- RadarPos delta_x_min, delta_x_max;
- RadarPos delta_y_min, delta_y_max;
- RadarPos x_dev = X_TO_DEVICE(wi, mosaic->x);
- RadarPos y_dev = Y_TO_DEVICE(wi, mosaic->y);
- RadarDim delta_x_dev, delta_y_dev;
- RadarDim offset_x, offset_y;
+ ZnPos delta_x_min, delta_x_max;
+ ZnPos delta_y_min, delta_y_max;
+ ZnPos x_dev = X_TO_DEVICE(wi, mosaic->x);
+ ZnPos y_dev = Y_TO_DEVICE(wi, mosaic->y);
+ ZnDim delta_x_dev, delta_y_dev;
+ ZnDim offset_x, offset_y;
unsigned int start_row, stop_row;
unsigned int start_col, stop_col;
XGCValues values;
@@ -606,8 +602,8 @@ Draw(Item item)
delta_x_dev = LENGTH_TO_DEVICE(wi, mosaic->tile_size * (j+1)) - offset_x;
delta_y_dev = LENGTH_TO_DEVICE(wi, mosaic->tile_size * (i+1)) - offset_y;
rect = &run_cache[current_color][run_cache_index[current_color]];
- rect->x = x_dev + (RadarPos) offset_x;
- rect->y = y_dev + (RadarPos) offset_y;
+ rect->x = x_dev + (ZnPos) offset_x;
+ rect->y = y_dev + (ZnPos) offset_y;
rect->width = delta_x_dev;
rect->height = delta_y_dev;
/* printf("Adding x:%d, y:%d, with:%d, height:%d\n",
@@ -655,12 +651,12 @@ Draw(Item item)
**********************************************************************************
*/
-static RadarBool
+static ZnBool
Pick(Item item,
XPoint *p,
- RadarDim aperture,
- RadarBool closest,
- RadarList items)
+ ZnDim aperture,
+ ZnBool closest,
+ ZnList items)
{
return False;
}
@@ -705,4 +701,4 @@ static ItemClassStruct MOSAIC_ITEM_CLASS = {
PostScript
};
-RadarItemClassId RadarMosaic = (RadarItemClassId) &MOSAIC_ITEM_CLASS;
+ZnItemClassId ZnMosaic = (ZnItemClassId) &MOSAIC_ITEM_CLASS;