aboutsummaryrefslogtreecommitdiff
path: root/generic/Text.c
diff options
context:
space:
mode:
authorlecoanet2002-02-18 16:03:54 +0000
committerlecoanet2002-02-18 16:03:54 +0000
commit6b36f92065f054abd810d956169a87180677d4f7 (patch)
treed2d16c8be93c67d15670eccce326dba5276acda1 /generic/Text.c
parent67dd05047282a179b5fac88564bb3494a69ecd23 (diff)
downloadtkzinc-6b36f92065f054abd810d956169a87180677d4f7.zip
tkzinc-6b36f92065f054abd810d956169a87180677d4f7.tar.gz
tkzinc-6b36f92065f054abd810d956169a87180677d4f7.tar.bz2
tkzinc-6b36f92065f054abd810d956169a87180677d4f7.tar.xz
Passage des couleurs en gradients pour uniformiser
Diffstat (limited to 'generic/Text.c')
-rw-r--r--generic/Text.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/generic/Text.c b/generic/Text.c
index f341de5..e506794 100644
--- a/generic/Text.c
+++ b/generic/Text.c
@@ -82,8 +82,7 @@ typedef struct _TextItemStruct {
ZnPoint pos;
ZnAnchor anchor;
ZnAnchor connection_anchor;
- ZnColor color;
- int alpha;
+ ZnGradient *color;
char *text;
Pixmap fill_pattern;
ZnFont font;
@@ -108,11 +107,9 @@ static ZnAttrConfig text_attrs[] = {
{ ZN_CONFIG_JUSTIFY, "-alignment", NULL,
Tk_Offset(TextItemStruct, alignment), 0,
ZN_COORDS_FLAG|ZN_LAYOUT_FLAG, False },
- { ZN_CONFIG_ALPHA, "-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,
+ { ZN_CONFIG_GRADIENT, "-color", NULL,
Tk_Offset(TextItemStruct, color), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-composerotation", NULL,
Tk_Offset(TextItemStruct, header.flags), COMPOSE_ROTATION_BIT,
@@ -191,8 +188,7 @@ Init(Item item,
text->fill_pattern = ZnUnspecifiedPattern;
text->anchor = ZnAnchorNW;
text->connection_anchor = ZnAnchorSW;
- text->color = ZnGetColorByValue(wi->win, wi->fore_color);
- text->alpha = 100;
+ text->color = ZnGetGradientByValue(wi->fore_gradient);
text->alignment = ZnJustifyLeft;
text->font = Tk_GetFont(wi->interp, wi->win, Tk_NameOfFont(wi->font));
text->width = 0;
@@ -231,7 +227,7 @@ Clone(Item item)
text->fill_pattern = Tk_GetBitmap(wi->interp, wi->win,
Tk_NameOfBitmap(wi->dpy, text->fill_pattern));
}
- text->color = ZnGetColorByValue(wi->win, text->color);
+ text->color = ZnGetGradientByValue(text->color);
text->font = Tk_GetFont(wi->interp, wi->win, Tk_NameOfFont(text->font));
if (text->text_info) {
@@ -267,7 +263,7 @@ Destroy(Item item)
Tk_FreeBitmap(wi->dpy, text->fill_pattern);
text->fill_pattern = ZnUnspecifiedPattern;
}
- ZnFreeColor(text->color);
+ ZnFreeGradient(text->color);
Tk_FreeFont(text->font);
if (text->text_info) {
@@ -708,7 +704,7 @@ Draw(Item item)
* Setup the gc to render the text and draw it.
*/
values.font = ZnFontId(text->font);
- values.foreground = ZnPixel(text->color);
+ values.foreground = ZnPixel(ZnGetGradientColor(text->color, 0, NULL));
gc_mask = GCFont | GCForeground;
if (text->fill_pattern != ZnUnspecifiedPattern) {
values.fill_style = FillStippled;
@@ -771,6 +767,8 @@ Render(Item item)
TextItem text = (TextItem) item;
TextLineInfo lines, lines_ptr;
int i, num_lines, num_chars;
+ XColor *color;
+ int alpha;
if (!text->text_info) {
return;
@@ -784,8 +782,9 @@ Render(Item item)
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glColor4us(text->color->red, text->color->green,
- text->color->blue, text->alpha*wi->alpha/100*65535/100);
+ color = ZnGetGradientColor(text->color, 0, &alpha);
+ alpha = ZnComposeAlpha(alpha, wi->alpha);
+ glColor4us(color->red, color->green, color->blue, alpha);
glBindTexture(GL_TEXTURE_2D, text->txf->texobj);
lines = (TextLineInfo) ZnListArray(text->text_info);