diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/Text.c | 58 |
1 files changed, 55 insertions, 3 deletions
diff --git a/generic/Text.c b/generic/Text.c index 0db7618..489cd82 100644 --- a/generic/Text.c +++ b/generic/Text.c @@ -46,6 +46,7 @@ #include "Types.h" #include "WidgetInfo.h" #include "tkZinc.h" +#include "Image.h" static const char rcsid[] = "$Imagine: Text.c,v 1.13 1997/05/15 11:35:46 lecoanet Exp $"; @@ -82,6 +83,7 @@ typedef struct _TextItemStruct { ZnAnchor anchor; ZnAnchor connection_anchor; ZnColor color; + int alpha; char *text; Pixmap fill_pattern; ZnFont font; @@ -96,6 +98,7 @@ typedef struct _TextItemStruct { int insert_index; ZnList text_info; int max_width; + FontBitmap *fb; } TextItemStruct, *TextItem; @@ -103,6 +106,8 @@ static ZnAttrConfig text_attrs[] = { { ZN_CONFIG_JUSTIFY, "-alignment", NULL, Tk_Offset(TextItemStruct, alignment), 0, ZN_COORDS_FLAG|ZN_LAYOUT_FLAG, False }, + { ZN_CONFIG_UINT, "-alpha", NULL, + Tk_Offset(TextItemStruct, alpha), 0, ZN_DRAW_FLAG, False }, { ZN_CONFIG_ANCHOR, "-anchor", NULL, Tk_Offset(TextItemStruct, anchor), 0, ZN_COORDS_FLAG, False }, { ZN_CONFIG_COLOR, "-color", NULL, @@ -185,10 +190,12 @@ Init(Item item, text->anchor = ZnAnchorNW; text->connection_anchor = ZnAnchorSW; text->color = ZnGetColorByValue(wi->win, wi->fore_color); + text->alpha = 255; text->alignment = ZnJustifyLeft; text->font = Tk_GetFont(wi->interp, wi->win, Tk_NameOfFont(wi->font)); text->width = 0; text->spacing = 0; + text->fb = NULL; text->insert_index = 0; CLEAR(text->flags, UNDERLINED); @@ -279,9 +286,12 @@ Configure(Item item, Tcl_Obj *CONST argv[], int *flags) { - Item old_connected; - + Item old_connected; + ZnFont old_font; + TextItem text = (TextItem) item; + old_connected = item->connected_item; + old_font = text->font; if (ITEM_P.ConfigureAttributes((char *) item, -1, argc, argv, flags) == ZN_ERROR) { return ZN_ERROR; } @@ -299,7 +309,10 @@ Configure(Item item, item->connected_item = old_connected; } } - + if (old_font != text->font) { + text->fb = NULL; + } + return ZN_OK; } @@ -735,6 +748,44 @@ Draw(Item item) } } } + + +/* +********************************************************************************** + * + * Render -- + * + ********************************************************************************** + */ +static void +Render(Item item) +{ + WidgetInfo *wi = item->wi; + TextItem text = (TextItem) item; + TextLineInfo lines, lines_ptr; + int i, num_lines; + int tmp_x, tmp_y; + int color; + + color = (((text->color->red & 0xff00) << 16) | + ((text->color->green & 0xff00) << 8) | + (text->color->blue & 0xff00) | + (text->alpha & 0xff)); + lines = (TextLineInfo) ZnListArray(text->text_info); + num_lines = ZnListSize(text->text_info); + if (!text->fb) { + text->fb = GetFontBitmap(wi->win, text->font); + } + + for (i = 0, lines_ptr = lines; i < num_lines; i++, lines_ptr++) { + tmp_x = (int)(text->pos_dev.x + lines_ptr->text_origin.x); + tmp_y = (int)(text->pos_dev.y + lines_ptr->text_origin.y) - text->fb->ascent; + rgb_text(wi->buf.buf, wi->buf.ox, wi->buf.oy, + wi->buf.cx, wi->buf.cy, wi->buf.rowstride, + lines_ptr->start, lines_ptr->num_chars, + tmp_x, tmp_y, text->fb, color); + } +} /* @@ -1273,6 +1324,7 @@ static ItemClassStruct TEXT_ITEM_CLASS = { ComputeCoordinates, ToArea, Draw, + Render, IsSensitive, Pick, NULL, /* PickVertex */ |