diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/Field.c | 305 |
1 files changed, 135 insertions, 170 deletions
diff --git a/generic/Field.c b/generic/Field.c index c1f49a0..bbbcd80 100644 --- a/generic/Field.c +++ b/generic/Field.c @@ -59,11 +59,11 @@ typedef struct _FieldStruct { /* Public data */ ZnGradient *color; ZnGradient *fill_color; - Pixmap fill_pattern; + ZnImage fill_pattern; ZnGradient *border_color; char *text; - char *image_name; - char *tile_name; + ZnImage image; + ZnImage tile; ZnFont font; unsigned short flags; Border border_edges; @@ -73,8 +73,6 @@ typedef struct _FieldStruct { AutoAlign auto_alignment; /* Private data */ - ZnImage image; - ZnImage tile; ZnGradient *gradient; ZnPoint *grad_geo; short orig_x; @@ -84,7 +82,7 @@ typedef struct _FieldStruct { FieldSet field_set; /* Only used by the image update callbacks */ int insert_index; #ifdef GLX - TexFont *txf; + ZnTexFontInfo *tfi; #endif } FieldStruct, *Field; @@ -95,14 +93,14 @@ typedef struct _FieldStruct { * the leader that might protude if not clipped by the text. */ ZnAttrConfig field_attrs[] = { - { ZN_CONFIG_JUSTIFY, "-alignment", NULL, + { ZN_CONFIG_ALIGNMENT, "-alignment", NULL, Tk_Offset(FieldStruct, alignment), 0, ZN_DRAW_FLAG, False }, - { ZN_CONFIG_AUTO_JUSTIFY, "-autoalignment", NULL, + { ZN_CONFIG_AUTO_ALIGNMENT, "-autoalignment", NULL, Tk_Offset(FieldStruct, auto_alignment), 0, ZN_DRAW_FLAG, False }, { ZN_CONFIG_GRADIENT, "-backcolor", NULL, Tk_Offset(FieldStruct, fill_color), 0, ZN_DRAW_FLAG|ZN_BORDER_FLAG, False }, - { ZN_CONFIG_BORDER, "-border", NULL, + { ZN_CONFIG_EDGE_LIST, "-border", NULL, Tk_Offset(FieldStruct, border_edges), 0, ZN_DRAW_FLAG, False }, { ZN_CONFIG_GRADIENT, "-bordercolor", NULL, Tk_Offset(FieldStruct, border_color), 0, ZN_DRAW_FLAG, False }, @@ -110,13 +108,13 @@ ZnAttrConfig field_attrs[] = { Tk_Offset(FieldStruct, color), 0, ZN_DRAW_FLAG, False }, { ZN_CONFIG_BOOL, "-filled", NULL, Tk_Offset(FieldStruct, flags), FILLED_BIT, ZN_COORDS_FLAG, False }, - { ZN_CONFIG_PATTERN, "-fillpattern", NULL, + { ZN_CONFIG_BITMAP, "-fillpattern", NULL, Tk_Offset(FieldStruct, fill_pattern), 0, ZN_DRAW_FLAG, False }, { ZN_CONFIG_FONT, "-font", NULL, Tk_Offset(FieldStruct, font), 0, ZN_COORDS_FLAG|ZN_CLFC_FLAG, False }, { ZN_CONFIG_IMAGE, "-image", NULL, - Tk_Offset(FieldStruct, image_name), 0, - ZN_COORDS_FLAG|ZN_IMAGE_FLAG|ZN_CLFC_FLAG, False }, + Tk_Offset(FieldStruct, image), 0, + ZN_COORDS_FLAG|ZN_CLFC_FLAG, False }, { ZN_CONFIG_RELIEF, "-relief", NULL, Tk_Offset(FieldStruct, relief), 0, ZN_DRAW_FLAG, False }, { ZN_CONFIG_DIM, "-reliefthickness", NULL, @@ -124,11 +122,10 @@ ZnAttrConfig field_attrs[] = { { ZN_CONFIG_BOOL, "-sensitive", NULL, Tk_Offset(FieldStruct, flags), FIELD_SENSITIVE_BIT, ZN_REPICK_FLAG, False }, - { ZN_CONFIG_TEXT, "-text", NULL, + { ZN_CONFIG_STRING, "-text", NULL, Tk_Offset(FieldStruct, text), 0, ZN_COORDS_FLAG|ZN_CLFC_FLAG, False }, { ZN_CONFIG_IMAGE, "-tile", NULL, - Tk_Offset(FieldStruct, tile_name), 0, - ZN_COORDS_FLAG|ZN_TILE_FLAG, False }, + Tk_Offset(FieldStruct, tile), 0, ZN_COORDS_FLAG, False }, { ZN_CONFIG_BOOL, "-visible", NULL, Tk_Offset(FieldStruct, flags), FIELD_VISIBLE_BIT, ZN_COORDS_FLAG|ZN_CLFC_FLAG, False }, /* Keep ZN_COORDS_FLAG here */ @@ -194,7 +191,7 @@ ComputeFieldAttachment(FieldSet field_set, if ((field_ptr->image != ZnUnspecifiedImage) && ((x_dim == LF_DIM_ICON) || (y_dim == LF_DIM_ICON) || (x_dim == LF_DIM_AUTO) || (y_dim == LF_DIM_AUTO))) { - Tk_SizeOfImage(field_ptr->image, &icon_width, &icon_height); + ZnSizeOfImage(field_ptr->image, &icon_width, &icon_height); } switch (x_dim) { @@ -425,6 +422,9 @@ ClearFieldCache(FieldSet field_set, char x_attach, y_attach, x_dim, y_dim; short width_spec, height_spec; + if (!field_set->num_fields) { + return; + } if (field < 0) { for (i = 0; i < field_set->num_fields; i++) { CLEAR(field_set->fields[i].flags, CACHE_OK); @@ -791,64 +791,6 @@ LeaderToLabel(FieldSet field_set, /* ********************************************************************************** * - * FieldImageChange -- - * - ********************************************************************************** - */ -static void -FieldImageChange(ClientData client_data, - int x, - int y, - int width, - int height, - int image_width, - int image_height) -{ - Field field = (Field) client_data; - int i; - ZnBBox bbox; - - if (field->image != ZnUnspecifiedImage) { - i = (((char *)field) - ((char *)field->field_set->fields))/sizeof(FieldStruct); - GetFieldBBox(field->field_set, i, &bbox); - ZnDamage(field->field_set->item->wi, &bbox); - ClearFieldCache(field->field_set, i); - } -} - - -/* - ********************************************************************************** - * - * FieldTileChange -- - * - ********************************************************************************** - */ -static void -FieldTileChange(ClientData client_data, - int x, - int y, - int width, - int height, - int image_width, - int image_height) -{ - Field field = (Field) client_data; - int i; - ZnBBox bbox; - - if (field->tile != ZnUnspecifiedImage) { - i = (((char *)field) - ((char *)field->field_set->fields))/sizeof(FieldStruct); - InvalidateImage(field->tile_name); - GetFieldBBox(field->field_set, i, &bbox); - ZnDamage(field->field_set->item->wi, &bbox); - } -} - - -/* - ********************************************************************************** - * * InitFields -- * * Perform the init of each field in a FieldSet. The number of such @@ -885,13 +827,17 @@ InitFields(FieldSet field_set) SET(field->flags, FIELD_SENSITIVE_BIT); CLEAR(field->flags, FILLED_BIT); CLEAR(field->flags, CACHE_OK); - field->fill_pattern = ZnUnspecifiedPattern; + field->fill_pattern = ZnUnspecifiedImage; field->text = ""; field->image = ZnUnspecifiedImage; - field->image_name = ""; field->tile = ZnUnspecifiedImage; - field->tile_name = ""; field->font = Tk_GetFont(wi->interp, wi->win, Tk_NameOfFont(wi->font)); +#ifdef GLX + field->tfi = NULL; + if (wi->render) { + field->tfi = ZnGetTexFont(wi, field->font); + } +#endif field->border_edges = NO_BORDER; field->alignment = ZnJustifyLeft; field->auto_alignment.automatic = False; @@ -902,9 +848,6 @@ InitFields(FieldSet field_set) field->gradient = NULL; field->grad_geo = NULL; -#ifdef GLX - field->txf = NULL; -#endif } field_set->label_pos.x = field_set->label_pos.y = 0.0; field_set->label_width = field_set->label_height = -1.0; @@ -926,13 +869,13 @@ CloneFields(FieldSet field_set) unsigned int i, num_fields; char *text; - if (field_set->label_format) { - field_set->label_format = LabelFormatDuplicate(field_set->label_format); - } num_fields = field_set->num_fields; if (!num_fields) { return; } + if (field_set->label_format) { + field_set->label_format = LabelFormatDuplicate(field_set->label_format); + } fields_ret = (Field) ZnMalloc(num_fields*sizeof(FieldStruct)); memcpy(fields_ret, field_set->fields, num_fields*sizeof(FieldStruct)); field_set->fields = fields_ret; @@ -948,24 +891,20 @@ CloneFields(FieldSet field_set) field->grad_geo = grad_geo; } if (field->image != ZnUnspecifiedImage) { - text = ZnMalloc((strlen(field->image_name) + 1) * sizeof(char)); - strcpy(text, field->image_name); - field->image_name = text; - field->image = Tk_GetImage(wi->interp, wi->win, field->image_name, - FieldImageChange, (ClientData) field); + field->image = ZnGetImageByValue(field->image); } if (field->tile != ZnUnspecifiedImage) { - text = ZnMalloc((strlen(field->tile_name) + 1) * sizeof(char)); - strcpy(text, field->tile_name); - field->tile_name = text; - field->tile = Tk_GetImage(wi->interp, wi->win, field->tile_name, - FieldTileChange, (ClientData) field); + field->tile = ZnGetImageByValue(field->tile); } - if (field->fill_pattern != ZnUnspecifiedPattern) { - field->fill_pattern = Tk_GetBitmap(wi->interp, wi->win, - Tk_NameOfBitmap(wi->dpy, field->fill_pattern)); + if (field->fill_pattern != ZnUnspecifiedImage) { + field->fill_pattern = ZnGetImageByValue(field->fill_pattern); } field->font = Tk_GetFont(wi->interp, wi->win, Tk_NameOfFont(field->font)); +#ifdef GLX + if (wi->render) { + field->tfi = ZnGetTexFont(wi, field->font); + } +#endif field->color = ZnGetGradientByValue(field->color); field->fill_color = ZnGetGradientByValue(field->fill_color); field->border_color = ZnGetGradientByValue(field->border_color); @@ -988,7 +927,7 @@ CloneFields(FieldSet field_set) */ static int ConfigureField(FieldSet fs, - unsigned int field, + int field, int argc, Tcl_Obj *CONST argv[], int *flags) @@ -1003,8 +942,8 @@ ConfigureField(FieldSet fs, ZnFont old_font; #endif - if (field >= fs->num_fields) { - Tcl_AppendResult(wi->interp, "invalid field index \"", NULL); + if ((field == ZN_NO_PART) || (field >= fs->num_fields)) { + Tcl_AppendResult(wi->interp, "invalid field index", NULL); return ZN_ERROR; } @@ -1044,7 +983,17 @@ ConfigureField(FieldSet fs, #ifdef GLX if (old_font != field_ptr->font) { - field_ptr->txf = NULL; + if (field_ptr->tfi) { + ZnFreeTexFont(field_ptr->tfi); + } + if (wi->render) { + field_ptr->tfi = ZnGetTexFont(wi, field_ptr->font); + if (!field_ptr->tfi) { + Tcl_AppendResult(wi->interp, "impossible to get the texture for font \"", + Tk_NameOfFont(field_ptr->font), "\"", NULL); + return ZN_ERROR; + } + } } #endif @@ -1069,20 +1018,6 @@ ConfigureField(FieldSet fs, } } - if (ISSET(*flags, ZN_IMAGE_FLAG)) { - if (ValidateImage(wi, field_ptr, field_ptr->image_name, FieldImageChange, - &field_ptr->image, "field -image") == ZN_ERROR) { - return ZN_ERROR; - } - } - - if (ISSET(*flags, ZN_TILE_FLAG)) { - if (ValidateImage(wi, field_ptr, field_ptr->tile_name, FieldTileChange, - &field_ptr->tile, "field -tile") == ZN_ERROR) { - return ZN_ERROR; - } - } - /* * This is done here to limit the redraw to the area of the * modified fields. @@ -1111,11 +1046,11 @@ ConfigureField(FieldSet fs, */ static int QueryField(FieldSet fs, - unsigned int field, + int field, int argc, Tcl_Obj *CONST argv[]) { - if (field >= fs->num_fields) { + if ((field == ZN_NO_PART) || (field >= fs->num_fields)) { Tcl_AppendResult(fs->item->wi->interp, "invalid field index \"", NULL); return ZN_ERROR; } @@ -1139,7 +1074,6 @@ QueryField(FieldSet fs, static void FreeFields(FieldSet field_set) { - WidgetInfo *wi = field_set->item->wi; unsigned int i, num_fields; Field field; @@ -1161,25 +1095,23 @@ FreeFields(FieldSet field_set) ZnFree(field->grad_geo); } if (field->image != ZnUnspecifiedImage) { - Tk_FreeImage(field->image); + ZnFreeImage(field->image); field->image = ZnUnspecifiedImage; } - if (strlen(field->image_name) != 0) { - ZnFree(field->image_name); - } if (field->tile != ZnUnspecifiedImage) { - Tk_FreeImage(field->tile); + ZnFreeImage(field->tile); field->tile = ZnUnspecifiedImage; } - if (strlen(field->tile_name) != 0) { - ZnFree(field->tile_name); - } - if (field->fill_pattern != ZnUnspecifiedPattern) { - Tk_FreeBitmap(wi->dpy, field->fill_pattern); - field->fill_pattern = ZnUnspecifiedPattern; + if (field->fill_pattern != ZnUnspecifiedImage) { + ZnFreeImage(field->fill_pattern); + field->fill_pattern = ZnUnspecifiedImage; } - /*printf("freeing a font\n");*/ Tk_FreeFont(field->font); +#ifdef GLX + if (field->tfi) { + ZnFreeTexFont(field->tfi); + } +#endif ZnFreeGradient(field->color); ZnFreeGradient(field->fill_color); ZnFreeGradient(field->border_color); @@ -1209,7 +1141,7 @@ FieldPointToChar(FieldSet fs, int x, int y) { - Field field_ptr = &fs->fields[field]; + Field field_ptr; int num_chars = strlen(field_ptr->text); ZnBBox f_bbox, t_bbox; ZnPoint t_orig; @@ -1219,6 +1151,7 @@ FieldPointToChar(FieldSet fs, return 0; } + field_ptr = &fs->fields[field]; GetFieldBBox(fs, field, &f_bbox); ComputeFieldTextLocation(field_ptr, &f_bbox, &t_orig, &t_bbox); @@ -1299,7 +1232,7 @@ FieldIndex(FieldSet fs, double tmp; char *end, *p; - if (field == ZN_NO_PART) { + if ((field == ZN_NO_PART) || (field >= fs->num_fields)) { *index = 0; return ZN_OK; } @@ -1400,7 +1333,7 @@ FieldInsertChars(FieldSet fs, int length; char *new; - if (field == ZN_NO_PART) { + if ((field == ZN_NO_PART) || (field >= fs->num_fields)) { return False; } @@ -1446,7 +1379,7 @@ FieldDeleteChars(FieldSet fs, int count, num_chars; char *new; - if (field == ZN_NO_PART) { + if ((field == ZN_NO_PART) || (field >= fs->num_fields)) { return False; } @@ -1498,7 +1431,7 @@ FieldCursor(FieldSet fs, Field field_ptr; int num_chars; - if (field == ZN_NO_PART) { + if ((field == ZN_NO_PART) || (field >= fs->num_fields)) { return; } @@ -1527,7 +1460,7 @@ FieldSelection(FieldSet fs, int count, num_chars; TextInfo *ti; - if (field == ZN_NO_PART) { + if ((field == ZN_NO_PART) || (field >= fs->num_fields)) { return 0; } @@ -1566,9 +1499,9 @@ ComputeFieldImageLocation(Field field_ptr, ZnBBox *bbox, ZnBBox *pm_bbox) { - int width, height; + int width, height; - Tk_SizeOfImage(field_ptr->image, &width, &height); + ZnSizeOfImage(field_ptr->image, &width, &height); pm_bbox->orig.y = (bbox->orig.y + bbox->corner.y - height) / 2; pm_bbox->corner.y = pm_bbox->orig.y + height; @@ -1614,6 +1547,10 @@ FieldsEngine(FieldSet field_set, int cursor = -1; int sel_start = -1, sel_stop = -1; + if (!field_set->num_fields) { + return; + } + if (field_set->label_format && LabelFormatNumFields(field_set->label_format)) { bbox.orig.x = REAL_TO_INT(field_set->label_pos.x); bbox.orig.y = REAL_TO_INT(field_set->label_pos.y); @@ -1702,7 +1639,7 @@ FieldsEngine(FieldSet field_set, /*restore = True;*/ if (restore) { /* we must clip. */ - /*printf("clip\n");*/ + /*printf("clip: %d\n", i);*/ pts[0] = fclip_bbox.orig; pts[1] = fclip_bbox.corner; TRI_STRIP1(&tristrip, pts, 2); @@ -1744,7 +1681,13 @@ DrawField(WidgetInfo *wi, XGCValues values; XRectangle r; int j, xs, num_chars; + int pw, ph, fw, fh; + Region clip_region; + ZnBool simple; + Pixmap pixmap, mask_pmap; + BBox2XRect(bbox, &r); + /* * Draw the background. */ @@ -1752,19 +1695,17 @@ DrawField(WidgetInfo *wi, values.foreground = ZnPixel(ZnGetGradientColor(field_ptr->fill_color, 0.0, NULL)); if (field_ptr->tile != ZnUnspecifiedImage) { /* Fill tiled */ - Pixmap pmap = GetImagePixmap(wi->win, field_ptr->tile_name, - field_ptr->tile, NULL); values.fill_style = FillTiled; - values.tile = pmap; + values.tile = ZnImagePixmap(field_ptr->tile, NULL); values.ts_x_origin = (int) bbox->orig.x; values.ts_y_origin = (int) bbox->orig.y; XChangeGC(wi->dpy, wi->gc, GCTileStipXOrigin|GCTileStipYOrigin|GCFillStyle|GCTile, &values); } - else if (field_ptr->fill_pattern != ZnUnspecifiedPattern) { /* Fill stippled */ + else if (field_ptr->fill_pattern != ZnUnspecifiedImage) { /* Fill stippled */ values.fill_style = FillStippled; - values.stipple = field_ptr->fill_pattern; + values.stipple = ZnImagePixmap(field_ptr->fill_pattern, NULL); values.ts_x_origin = (int) bbox->orig.x; values.ts_y_origin = (int) bbox->orig.y; XChangeGC(wi->dpy, wi->gc, @@ -1775,7 +1716,6 @@ DrawField(WidgetInfo *wi, values.fill_style = FillSolid; XChangeGC(wi->dpy, wi->gc, GCForeground|GCFillStyle, &values); } - BBox2XRect(bbox, &r); XFillRectangle(wi->dpy, wi->draw_buffer, wi->gc, r.x, r.y, r.width, r.height); } @@ -1790,12 +1730,31 @@ DrawField(WidgetInfo *wi, * Draw the image. */ if (field_ptr->image != ZnUnspecifiedImage) { - Tk_RedrawImage(field_ptr->image, - 0, 0, - REAL_TO_INT(pm_bbox->corner.x - pm_bbox->orig.x), - REAL_TO_INT(pm_bbox->corner.y - pm_bbox->orig.y), - wi->draw_buffer, - pm_bbox->orig.x, pm_bbox->orig.y); + pixmap = ZnImagePixmap(field_ptr->image, &mask_pmap); + if (mask_pmap != ZnUnspecifiedImage) { + ZnCurrentClip(wi, &clip_region, NULL, &simple); + XSetClipMask(wi->dpy, wi->gc, mask_pmap); + XSetClipOrigin(wi->dpy, wi->gc, pm_bbox->orig.x, pm_bbox->orig.y); + } + /* + * The image is clipped on the field boundary. + * This is needed to be compatible with image coming with + * a clip mask. The image clip mask resets the clip area in + * the GC, so we must fake the field clipping in the copyarea. + */ + pw = REAL_TO_INT(pm_bbox->corner.x - pm_bbox->orig.x); + ph = REAL_TO_INT(pm_bbox->corner.y - pm_bbox->orig.y); + fw = REAL_TO_INT(bbox->corner.x - bbox->orig.x); + fh = REAL_TO_INT(bbox->corner.y - bbox->orig.y); + XCopyArea(wi->dpy, pixmap, wi->draw_buffer, wi->gc, + REAL_TO_INT(bbox->orig.x-pm_bbox->orig.x), + REAL_TO_INT(bbox->orig.y-pm_bbox->orig.y), + MIN(pw, fw), MIN(ph, fh), + MAX(bbox->orig.x, pm_bbox->orig.x), + MAX(bbox->orig.y, pm_bbox->orig.y)); + if (mask_pmap != ZnUnspecifiedImage) { + XSetRegion(wi->dpy, wi->gc, clip_region); + } } } else { @@ -1832,13 +1791,12 @@ DrawField(WidgetInfo *wi, } } - BBox2XRect(bbox, &r); /* * Draw the border relief. */ if ((field_ptr->relief != RELIEF_FLAT) && (field_ptr->relief_thickness > 1)) { - DrawRectangleRelief(wi, field_ptr->relief, field_ptr->gradient, - &r, (unsigned int) field_ptr->relief_thickness); + ZnDrawRectangleRelief(wi, field_ptr->relief, field_ptr->gradient, + &r, (unsigned int) field_ptr->relief_thickness); } /* @@ -1944,16 +1902,16 @@ RenderField(WidgetInfo *wi, } else { if (field_ptr->tile != ZnUnspecifiedImage) { /* Fill tiled */ - RenderTile(wi, GetImageTexture(wi->win, field_ptr->tile_name, field_ptr->tile), - field_ptr->fill_color, FieldRenderCB, bbox, (ZnPoint *) bbox); + ZnRenderTile(wi, field_ptr->tile, field_ptr->fill_color, FieldRenderCB, bbox, + (ZnPoint *) bbox); } else { /* Fill solid */ - if (field_ptr->fill_pattern != ZnUnspecifiedPattern) { /* Fill stippled */ + if (field_ptr->fill_pattern != ZnUnspecifiedImage) { /* Fill stippled */ /* * Setup polygon stippling. */ glEnable(GL_POLYGON_STIPPLE); - glPolygonStipple(GetBitmapMask(wi->dpy, field_ptr->fill_pattern)->pixels); + glPolygonStipple(ZnImagePattern(field_ptr->fill_pattern, NULL)); } color = ZnGetGradientColor(field_ptr->fill_color, 0.0, &alpha); alpha = ZnComposeAlpha(alpha, wi->alpha); @@ -1975,9 +1933,7 @@ RenderField(WidgetInfo *wi, * Draw the image. */ if (field_ptr->image != ZnUnspecifiedImage) { - RenderImage(wi, GetImageTexture(wi->win, field_ptr->image_name, - field_ptr->image), - field_ptr->fill_color, &(pm_bbox->orig), False); + ZnRenderImage(wi, field_ptr->image, field_ptr->fill_color, &(pm_bbox->orig), False); } } else { @@ -1986,10 +1942,7 @@ RenderField(WidgetInfo *wi, */ num_chars = strlen(field_ptr->text); if (num_chars) { - if (!field_ptr->txf) { - field_ptr->txf = GetTexFont(wi->win, field_ptr->font); - } - if (field_ptr->txf) { + if (field_ptr->tfi) { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); if (sel_start >= 0) { color = ZnGetGradientColor(ti->sel_color, 0, &alpha); @@ -2007,10 +1960,10 @@ RenderField(WidgetInfo *wi, color = ZnGetGradientColor(field_ptr->color, 0, &alpha); alpha = ZnComposeAlpha(alpha, wi->alpha); glColor4us(color->red, color->green, color->blue, alpha); - glBindTexture(GL_TEXTURE_2D, field_ptr->txf->texobj); + glBindTexture(GL_TEXTURE_2D, ZnTexFontTex(field_ptr->tfi)); glPushMatrix(); glTranslatef(text_pos->x, text_pos->y, 0.0); - txfRenderString(field_ptr->txf, field_ptr->text, num_chars); + ZnRenderString(field_ptr->tfi, field_ptr->text, num_chars); glPopMatrix(); glDisable(GL_TEXTURE_2D); if (cursor >= 0) { @@ -2044,8 +1997,8 @@ RenderField(WidgetInfo *wi, p[3].x = p[2].x; p[3].y = p[0].y; p[4] = p[0]; - RenderPolygonRelief(wi, field_ptr->relief, field_ptr->gradient, - False, p, 5, field_ptr->relief_thickness); + ZnRenderPolygonRelief(wi, field_ptr->relief, field_ptr->gradient, + False, p, 5, field_ptr->relief_thickness); } /* @@ -2053,9 +2006,10 @@ RenderField(WidgetInfo *wi, */ if (field_ptr->border_edges != NO_BORDER) { color = ZnGetGradientColor(field_ptr->border_color, 0, &alpha); + alpha = ZnComposeAlpha(alpha, wi->alpha); glColor4us(color->red, color->green, color->blue, alpha); - glLineWidth(1); - SetLineStyle(wi, LINE_SIMPLE); + glLineWidth(1.5); + ZnSetLineStyle(wi, LINE_SIMPLE); glBegin(GL_LINES); if (field_ptr->border_edges & LEFT_BORDER) { glVertex2f(bbox->orig.x, bbox->orig.y); @@ -2137,6 +2091,10 @@ FieldsPick(FieldSet field_set, int i, best_field = 0; double new_dist, dist = 1e40; + if (!field_set->num_fields) { + return dist; + } + if (field_set->label_format) { for (i = LabelFormatNumFields(field_set->label_format)-1; i >= 0; i--) { field_ptr = &field_set->fields[i]; @@ -2185,6 +2143,10 @@ FieldsToArea(FieldSet field_set, int i; ZnBool first_done = False; + if (!field_set->num_fields) { + return inside; + } + for (i = LabelFormatNumFields(field_set->label_format)-1; i >= 0; i--) { field_ptr = &field_set->fields[i]; @@ -2226,6 +2188,9 @@ SetFieldsAutoAlign(FieldSet fs, int i; Field field; + if (!fs->num_fields) { + return; + } if ((alignment >= AA_LEFT) && (alignment <= AA_RIGHT)) { for (i = 0; i < fs->num_fields; i++) { field = &fs->fields[i]; |