aboutsummaryrefslogtreecommitdiff
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/Map.c196
1 files changed, 103 insertions, 93 deletions
diff --git a/generic/Map.c b/generic/Map.c
index a05b13d..7afa2b6 100644
--- a/generic/Map.c
+++ b/generic/Map.c
@@ -58,7 +58,7 @@ typedef struct _MapItemStruct {
/* Public data */
ZnBool filled;
- Pixmap fill_pattern;
+ ZnImage fill_pattern;
ZnGradient *color;
ZnFont text_font; /* null value -> use zn_map_text_font */
char *map_info_name;
@@ -78,7 +78,7 @@ typedef struct _MapItemStruct {
ZnList symbols;
ZnList texts;
#ifdef GLX
- TexFont *txf;
+ ZnTexFontInfo *tfi;
#endif
} MapItemStruct, *MapItem;
@@ -86,6 +86,9 @@ typedef struct _MapItemStruct {
static ZnAttrConfig map_attrs[] = {
{ ZN_CONFIG_GRADIENT, "-color", NULL,
Tk_Offset(MapItemStruct, color), 0, ZN_DRAW_FLAG, False },
+ { ZN_CONFIG_BOOL, "-composealpha", NULL,
+ Tk_Offset(MapItemStruct, header.flags), COMPOSE_ALPHA_BIT,
+ ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-composerotation", NULL,
Tk_Offset(MapItemStruct, header.flags), COMPOSE_ROTATION_BIT,
ZN_COORDS_FLAG, False },
@@ -94,7 +97,7 @@ static ZnAttrConfig map_attrs[] = {
ZN_COORDS_FLAG, False },
{ ZN_CONFIG_BOOL, "-filled", NULL,
Tk_Offset(MapItemStruct, filled), 1, ZN_COORDS_FLAG, False },
- { ZN_CONFIG_PATTERN, "-fillpattern", NULL,
+ { ZN_CONFIG_BITMAP, "-fillpattern", NULL,
Tk_Offset(MapItemStruct, fill_pattern), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_FONT, "-font", NULL,
Tk_Offset(MapItemStruct, text_font), 0, ZN_COORDS_FLAG, False },
@@ -106,10 +109,10 @@ static ZnAttrConfig map_attrs[] = {
ZN_DRAW_FLAG|ZN_REPICK_FLAG, False },
{ ZN_CONFIG_BOOL, "-sensitive", NULL,
Tk_Offset(MapItemStruct, header.flags), SENSITIVE_BIT, ZN_REPICK_FLAG, False },
- { ZN_CONFIG_PATTERNS, "-symbols", NULL,
+ { ZN_CONFIG_BITMAP_LIST, "-symbols", NULL,
Tk_Offset(MapItemStruct, symbol_patterns), 0,
ZN_COORDS_FLAG, False },
- { ZN_CONFIG_TAGS, "-tags", NULL,
+ { ZN_CONFIG_TAG_LIST, "-tags", NULL,
Tk_Offset(MapItemStruct, header.tags), 0, 0, False },
{ ZN_CONFIG_BOOL, "-visible", NULL,
Tk_Offset(MapItemStruct, header.flags), VISIBLE_BIT,
@@ -201,16 +204,21 @@ Init(Item item,
SET(item->flags, VISIBLE_BIT);
CLEAR(item->flags, SENSITIVE_BIT);
+ SET(item->flags, COMPOSE_ALPHA_BIT);
SET(item->flags, COMPOSE_ROTATION_BIT);
SET(item->flags, COMPOSE_SCALE_BIT);
item->part_sensitive = 0;
item->priority = DEFAULT_MAP_PRIORITY;
map->filled = False;
- map->fill_pattern = ZnUnspecifiedPattern;
+ map->fill_pattern = ZnUnspecifiedImage;
map->symbol_patterns = NULL;
map->color = ZnGetGradientByValue(wi->fore_color);
map->text_font = Tk_GetFont(wi->interp, wi->win,
Tk_NameOfFont(wi->map_text_font));
+#ifdef GLX
+ map->tfi = ZnGetTexFont(wi, map->text_font);
+#endif
+
map->map_info_name = "";
map->map_info = NULL;
@@ -225,9 +233,6 @@ Init(Item item,
map->marks = NULL;
map->symbols = NULL;
map->texts = NULL;
-#ifdef GLX
- map->txf = NULL;
-#endif
return ZN_OK;
}
@@ -296,21 +301,22 @@ Clone(Item item)
map->color = ZnGetGradientByValue(map->color);
map->text_font = Tk_GetFont(wi->interp, wi->win, Tk_NameOfFont(map->text_font));
- if (map->fill_pattern != ZnUnspecifiedPattern) {
- map->fill_pattern = Tk_GetBitmap(wi->interp, wi->win,
- Tk_NameOfBitmap(wi->dpy, map->fill_pattern));
+#ifdef GLX
+ map->tfi = ZnGetTexFont(wi, map->text_font);
+#endif
+ if (map->fill_pattern != ZnUnspecifiedImage) {
+ map->fill_pattern = ZnGetImageByValue(map->fill_pattern);
}
if (map->symbol_patterns) {
- Pixmap *pats, *new_pats;
- int i, num_pats;
+ ZnImage *pats, *new_pats;
+ int i, num_pats;
- pats = (Pixmap *) ZnListArray(map->symbol_patterns);
+ pats = ZnListArray(map->symbol_patterns);
num_pats = ZnListSize(map->symbol_patterns);
- map->symbol_patterns = ZnListNew(num_pats, sizeof(Pixmap));
- new_pats = (Pixmap *) ZnListArray(map->symbol_patterns);
+ map->symbol_patterns = ZnListNew(num_pats, sizeof(ZnImage));
+ new_pats = ZnListArray(map->symbol_patterns);
for (i = 0; i < num_pats; i++) {
- new_pats[i] = Tk_GetBitmap(wi->interp, wi->win,
- Tk_NameOfBitmap(wi->dpy, pats[i]));
+ new_pats[i] = ZnGetImageByValue(pats[i]);
}
}
}
@@ -332,17 +338,23 @@ Destroy(Item item)
FreeLists(map);
ZnFreeGradient(map->color);
Tk_FreeFont(map->text_font);
- if (map->fill_pattern != ZnUnspecifiedPattern) {
- Tk_FreeBitmap(item->wi->dpy, map->fill_pattern);
+#ifdef GLX
+ if (map->tfi) {
+ ZnFreeTexFont(map->tfi);
+ }
+#endif
+ if (map->fill_pattern != ZnUnspecifiedImage) {
+ ZnFreeImage(map->fill_pattern);
+ map->fill_pattern = ZnUnspecifiedImage;
}
if (map->symbol_patterns) {
- Pixmap *pats;
- int i, num_pats;
+ ZnImage *pats;
+ int i, num_pats;
- pats = (Pixmap *) ZnListArray(map->symbol_patterns);
+ pats = ZnListArray(map->symbol_patterns);
num_pats = ZnListSize(map->symbol_patterns);
for (i = 0; i < num_pats; i++) {
- Tk_FreeBitmap(item->wi->dpy, pats[i]);
+ ZnFreeImage(pats[i]);
}
ZnListFree(map->symbol_patterns);
}
@@ -370,11 +382,25 @@ Configure(Item item,
{
WidgetInfo *wi = item->wi;
MapItem map = (MapItem) item;
+#ifdef GLX
+ ZnFont old_font = map->text_font;
+#endif
if (ZnConfigureAttributes(wi, item, map_attrs, argc, argv, flags) == ZN_ERROR) {
return ZN_ERROR;
}
+#ifdef GLX
+ if (old_font != map->text_font) {
+ if (map->tfi) {
+ ZnFreeTexFont(map->tfi);
+ }
+ map->tfi = ZnGetTexFont(wi, map->text_font);
+ if (!map->tfi) {
+ return ZN_ERROR;
+ }
+ }
+#endif
if (ISSET(*flags, ZN_MAP_INFO_FLAG)) {
MapInfoId map_info;
ZnBool error = False;
@@ -636,8 +662,8 @@ ComputeCoordinates(Item item,
symbols = (ZnPoint *) ZnListArray(map->symbols);
texts = (ZnPoint *) ZnListArray(map->texts);
- if (num_marks && (wi->map_distance_symbol != ZnUnspecifiedPattern)) {
- Tk_SizeOfBitmap(wi->dpy, wi->map_distance_symbol, &sym_w2, &sym_h2);
+ if (num_marks && (wi->map_distance_symbol != ZnUnspecifiedImage)) {
+ ZnSizeOfImage(wi->map_distance_symbol, &sym_w2, &sym_h2);
sym_w2 = (sym_w2+1)/2;
sym_h2 = (sym_h2+1)/2;
}
@@ -720,7 +746,7 @@ ComputeCoordinates(Item item,
num_points++;
vectors[num_points] = to;
num_points++;
- if (wi->map_distance_symbol != ZnUnspecifiedPattern) {
+ if (wi->map_distance_symbol != ZnUnspecifiedImage) {
MapInfoGetMarks(map_info, i, &new_marks, &n_new_marks);
for (j = 0; j < n_new_marks; j++) {
/*
@@ -844,8 +870,8 @@ ComputeCoordinates(Item item,
/* If map is filled, only the vectors description is valid. */
if (!map->filled) {
if (map->symbol_patterns) {
- Pixmap sym, *syms = (Pixmap *) ZnListArray(map->symbol_patterns);
- int num_syms = ZnListSize(map->symbol_patterns);
+ ZnImage sym, *syms = ZnListArray(map->symbol_patterns);
+ int num_syms = ZnListSize(map->symbol_patterns);
cnt = MapInfoNumSymbols(map_info);
for (i = 0; i < cnt; i++) {
@@ -854,8 +880,8 @@ ComputeCoordinates(Item item,
tmp_from.y = y_from_w;
ZnTransformPoint(wi->current_transfo, &tmp_from, &symbols[i]);
sym = syms[symbol%num_syms];
- if (sym != ZnUnspecifiedPattern) {
- Tk_SizeOfBitmap(wi->dpy, sym, &sym_w2, &sym_h2);
+ if (sym != ZnUnspecifiedImage) {
+ ZnSizeOfImage(sym, &sym_w2, &sym_h2);
sym_w2 = (sym_w2+1)/2;
sym_h2 = (sym_h2+1)/2;
AddPointToBBox(&item->item_bounding_box,
@@ -954,10 +980,7 @@ ComputeCoordinates(Item item,
static int
ToArea(Item item,
- ZnBBox *area,
- Tk_Uid tag_uid,
- int enclosed,
- ZnBool report)
+ ZnToArea ta)
{
return -1;
}
@@ -995,13 +1018,13 @@ Draw(Item item)
if (map->filled) {
if (ZnListSize(map->vectors) || ZnListSize(map->arcs)) {
- if (map->fill_pattern == ZnUnspecifiedPattern) { /* Fill solid */
+ if (map->fill_pattern == ZnUnspecifiedImage) { /* Fill solid */
values.fill_style = FillSolid;
XChangeGC(wi->dpy, wi->gc, GCFillStyle | GCForeground, &values);
}
else { /* Fill stippled */
values.fill_style = FillStippled;
- values.stipple = map->fill_pattern;
+ values.stipple = ZnImagePixmap(map->fill_pattern, NULL);
XChangeGC(wi->dpy, wi->gc,
GCFillStyle | GCStipple | GCForeground, &values);
}
@@ -1028,7 +1051,7 @@ Draw(Item item)
else { /* Not filled */
if (ZnListSize(map->vectors)) {
- SetLineStyle(wi, LINE_SIMPLE);
+ ZnSetLineStyle(wi, LINE_SIMPLE);
values.fill_style = FillSolid;
values.line_width = 0;
XChangeGC(wi->dpy, wi->gc,
@@ -1056,7 +1079,7 @@ Draw(Item item)
}
if (ZnListSize(map->dashed_vectors)) {
- SetLineStyle(wi, LINE_DASHED);
+ ZnSetLineStyle(wi, LINE_DASHED);
values.fill_style = FillSolid;
values.line_width = 0;
XChangeGC(wi->dpy, wi->gc, GCFillStyle | GCLineWidth | GCForeground, &values);
@@ -1081,7 +1104,7 @@ Draw(Item item)
}
if (ZnListSize(map->dotted_vectors)) {
- SetLineStyle(wi, LINE_DOTTED);
+ ZnSetLineStyle(wi, LINE_DOTTED);
values.fill_style = FillSolid;
values.line_width = 0;
XChangeGC(wi->dpy, wi->gc,
@@ -1107,7 +1130,7 @@ Draw(Item item)
}
if (ZnListSize(map->mixed_vectors)) {
- SetLineStyle(wi, LINE_MIXED);
+ ZnSetLineStyle(wi, LINE_MIXED);
values.fill_style = FillSolid;
values.line_width = 0;
XChangeGC(wi->dpy, wi->gc, GCFillStyle | GCLineWidth | GCForeground, &values);
@@ -1132,8 +1155,8 @@ Draw(Item item)
}
if (ZnListSize(map->arcs)) {
-
- SetLineStyle(wi, LINE_SIMPLE);
+
+ ZnSetLineStyle(wi, LINE_SIMPLE);
values.fill_style = FillSolid;
values.line_width = 0;
XChangeGC(wi->dpy, wi->gc, GCFillStyle | GCLineWidth | GCForeground, &values);
@@ -1147,7 +1170,7 @@ Draw(Item item)
if (ZnListSize(map->dashed_arcs)) {
- SetLineStyle(wi, LINE_DASHED);
+ ZnSetLineStyle(wi, LINE_DASHED);
values.fill_style = FillSolid;
values.line_width = 0;
XChangeGC(wi->dpy, wi->gc, GCFillStyle | GCLineWidth | GCForeground, &values);
@@ -1162,7 +1185,7 @@ Draw(Item item)
if (ZnListSize(map->dotted_arcs)) {
- SetLineStyle(wi, LINE_DOTTED);
+ ZnSetLineStyle(wi, LINE_DOTTED);
values.fill_style = FillSolid;
values.line_width = 0;
XChangeGC(wi->dpy, wi->gc, GCFillStyle | GCLineWidth | GCForeground, &values);
@@ -1177,7 +1200,7 @@ Draw(Item item)
if (ZnListSize(map->mixed_arcs)) {
- SetLineStyle(wi, LINE_MIXED);
+ ZnSetLineStyle(wi, LINE_MIXED);
values.fill_style = FillSolid;
values.line_width = 0;
XChangeGC(wi->dpy, wi->gc, GCFillStyle | GCLineWidth | GCForeground, &values);
@@ -1209,26 +1232,26 @@ Draw(Item item)
}
if (ZnListSize(map->symbols) || ZnListSize(map->marks)) {
- int w, h, ox, oy;
- Pixmap sym;
+ int w, h, ox, oy;
+ ZnImage sym;
values.fill_style = FillStippled;
XChangeGC(wi->dpy, wi->gc, GCFillStyle, &values);
if (map->symbol_patterns) {
- Pixmap *syms = (Pixmap *) ZnListArray(map->symbol_patterns);
- int num_syms = ZnListSize(map->symbol_patterns);
+ ZnImage *syms = ZnListArray(map->symbol_patterns);
+ int num_syms = ZnListSize(map->symbol_patterns);
cnt = ZnListSize(map->symbols);
- points = (ZnPoint *) ZnListArray(map->symbols);
+ points = ZnListArray(map->symbols);
for (i = 0; i < cnt; i++) {
MapInfoGetSymbol(map_info, i, NULL, NULL, NULL, &(tmp_str[0]));
sym = syms[tmp_str[0]%num_syms];
- if (sym != ZnUnspecifiedPattern) {
- Tk_SizeOfBitmap(wi->dpy, sym, &w, &h);
+ if (sym != ZnUnspecifiedImage) {
+ ZnSizeOfImage(sym, &w ,&h);
ox = points[i].x-w/2;
oy = points[i].y-h/2;
- values.stipple = sym;
+ values.stipple = ZnImagePixmap(sym, NULL);
values.ts_x_origin = ox;
values.ts_y_origin = oy;
XChangeGC(wi->dpy, wi->gc,
@@ -1238,11 +1261,11 @@ Draw(Item item)
}
}
- if (wi->map_distance_symbol != ZnUnspecifiedPattern) {
- Tk_SizeOfBitmap(wi->dpy, wi->map_distance_symbol, &w, &h);
+ if (wi->map_distance_symbol != ZnUnspecifiedImage) {
+ ZnSizeOfImage(wi->map_distance_symbol, &w, &h);
cnt = ZnListSize(map->marks);
- points = (ZnPoint *) ZnListArray(map->marks);
- values.stipple = wi->map_distance_symbol;
+ points = ZnListArray(map->marks);
+ values.stipple = ZnImagePixmap(wi->map_distance_symbol, NULL);
XChangeGC(wi->dpy, wi->gc, GCStipple, &values);
for (i = 0; i < cnt; i++) {
ox = points[i].x-w/2;
@@ -1278,9 +1301,9 @@ Render(Item item)
unsigned int i, cnt;
int line_width, new_width;
XColor *color;
- int alpha;
+ int alpha, w, h;
- if (map->map_info == NULL) {
+ if (!map->map_info) {
return;
}
@@ -1290,10 +1313,10 @@ Render(Item item)
glColor4us(color->red, color->green, color->blue, alpha);
if (map->filled) {
if (ZnListSize(map->vectors) || ZnListSize(map->arcs)) {
- if (map->fill_pattern != ZnUnspecifiedPattern) {
+ if (map->fill_pattern != ZnUnspecifiedImage) {
/* Fill stippled */
glEnable(GL_POLYGON_STIPPLE);
- glPolygonStipple(GetBitmapMask(wi->dpy, map->fill_pattern)->pixels);
+ glPolygonStipple(ZnImagePattern(map->fill_pattern, NULL));
}
cnt = ZnListSize(map->vectors);
if (cnt) {
@@ -1308,7 +1331,7 @@ Render(Item item)
if (ZnListSize(map->vectors)) {
line_width = 1;
glLineWidth(line_width);
- SetLineStyle(wi, LINE_SIMPLE);
+ ZnSetLineStyle(wi, LINE_SIMPLE);
cnt = ZnListSize(map->vectors);
points = ZnListArray(map->vectors);
glBegin(GL_LINES);
@@ -1329,7 +1352,7 @@ Render(Item item)
if (ZnListSize(map->dashed_vectors)) {
line_width = 1;
glLineWidth(line_width);
- SetLineStyle(wi, LINE_DASHED);
+ ZnSetLineStyle(wi, LINE_DASHED);
cnt = ZnListSize(map->dashed_vectors);
points = ZnListArray(map->dashed_vectors);
glBegin(GL_LINES);
@@ -1351,7 +1374,7 @@ Render(Item item)
if (ZnListSize(map->dotted_vectors)) {
line_width = 1;
glLineWidth(line_width);
- SetLineStyle(wi, LINE_DOTTED);
+ ZnSetLineStyle(wi, LINE_DOTTED);
cnt = ZnListSize(map->dotted_vectors);
points = ZnListArray(map->dotted_vectors);
glBegin(GL_LINES);
@@ -1373,7 +1396,7 @@ Render(Item item)
if (ZnListSize(map->mixed_vectors)) {
line_width = 1;
glLineWidth(line_width);
- SetLineStyle(wi, LINE_MIXED);
+ ZnSetLineStyle(wi, LINE_MIXED);
cnt = ZnListSize(map->mixed_vectors);
points = ZnListArray(map->mixed_vectors);
glBegin(GL_LINES);
@@ -1419,57 +1442,49 @@ Render(Item item)
glDisable(GL_LINE_STIPPLE);
}
- if (ZnListSize(map->texts)) {
- if (!map->txf) {
- map->txf = GetTexFont(wi->win, map->text_font);
- }
+ if (ZnListSize(map->texts) && map->tfi) {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glBindTexture(GL_TEXTURE_2D, map->txf->texobj);
+ glBindTexture(GL_TEXTURE_2D, ZnTexFontTex(map->tfi));
cnt = ZnListSize(map->texts);
- points = (ZnPoint *) ZnListArray(map->texts);
+ points = ZnListArray(map->texts);
for (i = 0; i < cnt; i++, points++) {
glPushMatrix();
MapInfoGetText(map_info, i, NULL, NULL, NULL, NULL, NULL, &text);
glTranslatef(points->x, points->y, 0.0);
- txfRenderString(map->txf, text, strlen(text));
+ ZnRenderString(map->tfi, text, strlen(text));
glPopMatrix();
}
glDisable(GL_TEXTURE_2D);
}
if (map->symbol_patterns) {
- Pixmap sym, *syms = ZnListArray(map->symbol_patterns);
- int w, h, num_syms = ZnListSize(map->symbol_patterns);
+ ZnImage sym, *syms = ZnListArray(map->symbol_patterns);
+ int w, h, num_syms = ZnListSize(map->symbol_patterns);
cnt = ZnListSize(map->symbols);
points = ZnListArray(map->symbols);
for (i = 0; i < cnt; i++) {
MapInfoGetSymbol(map_info, i, NULL, NULL, NULL, &(tmp_str[0]));
sym = syms[tmp_str[0]%num_syms];
- if (sym != ZnUnspecifiedPattern) {
- Tk_SizeOfBitmap(wi->dpy, sym, &w, &h);
+ if (sym != ZnUnspecifiedImage) {
+ ZnSizeOfImage(sym, &w, &h);
p.x = points[i].x-(w+1.0)/2.0;
p.y = points[i].y-(h+1.0)/2.0;
- RenderImage(wi, (ImageBits *) GetBitmapTexture(wi->dpy, sym),
- map->color, &p, True);
+ ZnRenderImage(wi, sym, map->color, &p, True);
}
}
}
- if (wi->map_distance_symbol != ZnUnspecifiedPattern) {
- ImageBits *im_bits = (ImageBits *) GetBitmapTexture(wi->dpy,
- wi->map_distance_symbol);
- int w, h;
-
- Tk_SizeOfBitmap(wi->dpy, wi->map_distance_symbol, &w, &h);
+ if (wi->map_distance_symbol != ZnUnspecifiedImage) {
+ ZnSizeOfImage(wi->map_distance_symbol, &w, &h);
cnt = ZnListSize(map->marks);
points = ZnListArray(map->marks);
for (i = 0; i < cnt; i++, points++) {
p.x = points->x-(w+1)/2;
p.y = points->y-(h+1)/2;
- RenderImage(wi, im_bits, map->color, &p, True);
+ ZnRenderImage(wi, wi->map_distance_symbol, map->color, &p, True);
}
}
}
@@ -1507,11 +1522,7 @@ IsSensitive(Item item,
*/
static double
Pick(Item item,
- ZnPoint *p,
- Item start_item,
- int aperture,
- Item *a_item,
- int *part)
+ ZnPick ps)
{
return 1e40;
}
@@ -1563,7 +1574,6 @@ PostScript(Item item,
static ItemClassStruct MAP_ITEM_CLASS = {
sizeof(MapItemStruct),
- False, /* has_fields */
0, /* num_parts */
False, /* has_anchors */
"map",