diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/Field.c | 109 |
1 files changed, 47 insertions, 62 deletions
diff --git a/generic/Field.c b/generic/Field.c index c80191b..472d895 100644 --- a/generic/Field.c +++ b/generic/Field.c @@ -56,7 +56,6 @@ typedef struct _FieldStruct { /* Public data */ ZnGradient *color; ZnGradient *fill_color; - ZnImage fill_pattern; ZnGradient *border_color; char *text; ZnImage image; @@ -106,7 +105,7 @@ ZnAttrConfig field_attrs[] = { { ZN_CONFIG_BOOL, "-filled", NULL, Tk_Offset(FieldStruct, flags), FILLED_BIT, ZN_COORDS_FLAG, False }, { ZN_CONFIG_BITMAP, "-fillpattern", NULL, - Tk_Offset(FieldStruct, fill_pattern), 0, ZN_DRAW_FLAG, False }, + Tk_Offset(FieldStruct, tile), 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, @@ -828,7 +827,6 @@ InitFields(ZnFieldSet field_set) SET(field->flags, FIELD_SENSITIVE_BIT); CLEAR(field->flags, FILLED_BIT); CLEAR(field->flags, CACHE_OK); - field->fill_pattern = ZnUnspecifiedImage; field->text = NULL; field->image = ZnUnspecifiedImage; field->tile = ZnUnspecifiedImage; @@ -897,9 +895,6 @@ CloneFields(ZnFieldSet field_set) if (field->tile != ZnUnspecifiedImage) { field->tile = ZnGetImageByValue(field->tile); } - 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 GL if (wi->render) { @@ -1112,10 +1107,6 @@ FreeFields(ZnFieldSet field_set) ZnFreeImage(field->tile); field->tile = ZnUnspecifiedImage; } - if (field->fill_pattern != ZnUnspecifiedImage) { - ZnFreeImage(field->fill_pattern); - field->fill_pattern = ZnUnspecifiedImage; - } Tk_FreeFont(field->font); #ifdef GL if (field->tfi) { @@ -1693,18 +1684,18 @@ FieldsEngine(ZnFieldSet field_set, val = fclip_bbox.corner.y - bbox.corner.y; restore |= val < 0; - cursor = -1; + cursor = ((field_set->item == wi->focus_item) && + ((unsigned int) wi->focus_field == i) && + ISSET(wi->flags, ZN_GOT_FOCUS) && ti->cursor_on) ? 0 : -1; sel_start = -1, sel_stop = -1; + ComputeFieldTextLocation(fptr, &bbox, &text_pos, &text_bbox); if (fptr->text) { - if ((field_set->item == wi->focus_item) && - ((unsigned int) wi->focus_field == i) && - ISSET(wi->flags, ZN_GOT_FOCUS) && ti->cursor_on) { + if (cursor != -1) { cursor = Tk_TextWidth(fptr->font, fptr->text, Tcl_UtfAtIndex(fptr->text, fptr->insert_index)-fptr->text); } - ComputeFieldTextLocation(fptr, &bbox, &text_pos, &text_bbox); num_chars = Tcl_NumUtfChars(fptr->text, (int) strlen(fptr->text)); if (num_chars) { if ((field_set->item == ti->sel_item) && ((unsigned int) ti->sel_field == i) && @@ -1804,23 +1795,25 @@ DrawField(ZnWInfo *wi, if (ISSET(fptr->flags, FILLED_BIT)) { values.foreground = ZnPixel(ZnGetGradientColor(fptr->fill_color, 0.0, NULL)); - if (fptr->tile != ZnUnspecifiedImage) { /* Fill tiled */ - values.fill_style = FillTiled; - values.tile = ZnImagePixmap(fptr->tile); - 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 (fptr->fill_pattern != ZnUnspecifiedImage) { /* Fill stippled */ - values.fill_style = FillStippled; - values.stipple = ZnImagePixmap(fptr->fill_pattern); - values.ts_x_origin = (int) bbox->orig.x; - values.ts_y_origin = (int) bbox->orig.y; - XChangeGC(wi->dpy, wi->gc, - GCTileStipXOrigin|GCTileStipYOrigin|GCFillStyle|GCStipple|GCForeground, - &values); + if (fptr->tile != ZnUnspecifiedImage) { + if (!ZnImageIsBitmap(fptr->tile)) { /* Fill tiled */ + values.fill_style = FillTiled; + values.tile = ZnImagePixmap(fptr->tile); + 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 { /* Fill stippled */ + values.fill_style = FillStippled; + values.stipple = ZnImagePixmap(fptr->tile); + values.ts_x_origin = (int) bbox->orig.x; + values.ts_y_origin = (int) bbox->orig.y; + XChangeGC(wi->dpy, wi->gc, + GCTileStipXOrigin|GCTileStipYOrigin|GCFillStyle|GCStipple|GCForeground, + &values); + } } else { /* Fill solid */ values.fill_style = FillSolid; @@ -1903,18 +1896,18 @@ DrawField(ZnWInfo *wi, Tk_DrawChars(wi->dpy, wi->draw_buffer, wi->gc, fptr->font, fptr->text, num_bytes, (int) text_pos->x, (int) text_pos->y); } - if (cursor >= 0) { - values.line_width = ti->insert_width; - values.foreground = ZnPixel(ZnGetGradientColor(ti->insert_color, 0.0, NULL)); - values.fill_style = FillSolid; - XChangeGC(wi->dpy, wi->gc, GCForeground|GCLineWidth|GCFillStyle, &values); - xs = (int) text_bbox->orig.x + cursor; - XDrawLine(wi->dpy, wi->draw_buffer, wi->gc, - xs, (int) text_bbox->orig.y, - xs, (int) text_bbox->corner.y); - } } } + if (cursor >= 0) { + values.line_width = ti->insert_width; + values.foreground = ZnPixel(ZnGetGradientColor(ti->insert_color, 0.0, NULL)); + values.fill_style = FillSolid; + XChangeGC(wi->dpy, wi->gc, GCForeground|GCLineWidth|GCFillStyle, &values); + xs = (int) text_bbox->orig.x + cursor; + XDrawLine(wi->dpy, wi->draw_buffer, wi->gc, + xs, (int) text_bbox->orig.y, + xs, (int) text_bbox->corner.y); + } /* * Draw the border relief. @@ -2027,23 +2020,15 @@ RenderField(ZnWInfo *wi, #endif } else { - if (fptr->tile != ZnUnspecifiedImage) { /* Fill tiled */ + if (fptr->tile != ZnUnspecifiedImage) { /* Fill tiled/stippled */ ZnRenderTile(wi, fptr->tile, fptr->fill_color, FieldRenderCB, bbox, (ZnPoint *) bbox); } else { /* Fill solid */ - if (fptr->fill_pattern != ZnUnspecifiedImage) { /* Fill stippled */ - /* - * Setup polygon stippling. - */ - glEnable(GL_POLYGON_STIPPLE); - glPolygonStipple(ZnImageMask(fptr->fill_pattern, NULL)); - } color = ZnGetGradientColor(fptr->fill_color, 0.0, &alpha); alpha = ZnComposeAlpha(alpha, wi->alpha); glColor4us(color->red, color->green, color->blue, alpha); FieldRenderCB(bbox); - glDisable(GL_POLYGON_STIPPLE); } } } @@ -2093,17 +2078,17 @@ RenderField(ZnWInfo *wi, glPopMatrix(); glDisable(GL_TEXTURE_2D); } - if (cursor >= 0) { - glLineWidth((GLfloat) ti->insert_width); - color = ZnGetGradientColor(ti->insert_color, 0.0, &alpha); - alpha = ZnComposeAlpha(alpha, wi->alpha); - glColor4us(color->red, color->green, color->blue, alpha); - xs = text_bbox->orig.x + cursor; - glBegin(GL_LINES); - glVertex2d(xs, text_bbox->orig.y); - glVertex2d(xs, text_bbox->corner.y); - glEnd(); - } + } + if (cursor >= 0) { + glLineWidth((GLfloat) ti->insert_width); + color = ZnGetGradientColor(ti->insert_color, 0.0, &alpha); + alpha = ZnComposeAlpha(alpha, wi->alpha); + glColor4us(color->red, color->green, color->blue, alpha); + xs = text_bbox->orig.x + cursor; + glBegin(GL_LINES); + glVertex2d(xs, text_bbox->orig.y); + glVertex2d(xs, text_bbox->corner.y); + glEnd(); } } |