aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlecoanet2001-10-12 07:34:52 +0000
committerlecoanet2001-10-12 07:34:52 +0000
commitc4224a166868400e19211a5d7c66ec5c5bc72679 (patch)
tree5402dca8de0c3f098aaa2d51d829c857c371cdf4
parent98066111fff9ffbe7be2b9bad541583f8d402b41 (diff)
downloadtkzinc-c4224a166868400e19211a5d7c66ec5c5bc72679.zip
tkzinc-c4224a166868400e19211a5d7c66ec5c5bc72679.tar.gz
tkzinc-c4224a166868400e19211a5d7c66ec5c5bc72679.tar.bz2
tkzinc-c4224a166868400e19211a5d7c66ec5c5bc72679.tar.xz
Suppression du code LIBART.
Ajout du rendu GL.
-rw-r--r--generic/Text.c85
1 files changed, 51 insertions, 34 deletions
diff --git a/generic/Text.c b/generic/Text.c
index b8e7336..dd220d5 100644
--- a/generic/Text.c
+++ b/generic/Text.c
@@ -98,8 +98,8 @@ typedef struct _TextItemStruct {
int insert_index;
ZnList text_info;
int max_width;
-#ifdef LIBART
- FontBitmap *fb;
+#ifdef GLX
+ TexFont *txf;
#endif
} TextItemStruct, *TextItem;
@@ -108,7 +108,7 @@ 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,
+ { 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 },
@@ -192,15 +192,14 @@ Init(Item item,
text->anchor = ZnAnchorNW;
text->connection_anchor = ZnAnchorSW;
text->color = ZnGetColorByValue(wi->win, wi->fore_color);
- text->alpha = 255;
+ text->alpha = 100;
text->alignment = ZnJustifyLeft;
text->font = Tk_GetFont(wi->interp, wi->win, Tk_NameOfFont(wi->font));
text->width = 0;
text->spacing = 0;
-#ifdef LIBART
- text->fb = NULL;
+#ifdef GLX
+ text->txf = NULL;
#endif
-
text->insert_index = 0;
CLEAR(text->flags, UNDERLINED);
CLEAR(text->flags, OVERSTRIKED);
@@ -313,11 +312,6 @@ Configure(Item item,
item->connected_item = old_connected;
}
}
-#ifdef LIBART
- if (old_font != text->font) {
- text->fb = NULL;
- }
-#endif
return ZN_OK;
}
@@ -382,7 +376,6 @@ ComputeCoordinates(Item item,
char *scan;
int wrap, line_index, prev_num_lines;
- /*printf("layout\n");*/
text->max_width = 0;
if (text->text_info != NULL) {
prev_num_lines = ZnListSize(text->text_info);
@@ -540,6 +533,10 @@ ToArea(Item item,
ZnBBox line_bbox;
ZnPoint o;
+ if (!text->text_info) {
+ return -1;
+ }
+
lines = (TextLineInfo) ZnListArray(text->text_info);
num_lines = ZnListSize(text->text_info);
Tk_GetFontMetrics(text->font, &fm);
@@ -594,7 +591,10 @@ Draw(Item item)
int underline_thickness, underline_pos=0, overstrike_pos=0;
int sel_first_line=-1, sel_last_line=-1, cursor_line=-1;
int sel_start_offset=0, sel_stop_offset=0, cursor_offset=0;
-
+
+ if (!text->text_info) {
+ return;
+ }
lines = (TextLineInfo) ZnListArray(text->text_info);
num_lines = ZnListSize(text->text_info);
Tk_GetFontMetrics(text->font, &fm);
@@ -766,32 +766,41 @@ Draw(Item item)
static void
Render(Item item)
{
-#ifdef LIBART
+#ifdef GLX
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);
+ int i, num_lines, num_chars;
+
+ if (!text->text_info) {
+ return;
}
+ if (!text->txf) {
+ text->txf = GetTexFont(wi->win, text->font);
+ }
+ 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*65535/100);
+ glBindTexture(GL_TEXTURE_2D, text->txf->texobj);
+
+ lines = (TextLineInfo) ZnListArray(text->text_info);
+ num_lines = ZnListSize(text->text_info);
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);
+ num_chars = lines_ptr->num_chars;
+ while (lines_ptr->start[num_chars-1] == '\n') {
+ num_chars--;
+ }
+ glPushMatrix();
+ glTranslatef(text->pos_dev.x + lines_ptr->text_origin.x,
+ text->pos_dev.y + lines_ptr->text_origin.y,
+ 0.0);
+ txfRenderString(text->txf, lines_ptr->start, num_chars);
+ glPopMatrix();
}
+ glDisable(GL_TEXTURE_2D);
#endif
}
@@ -991,6 +1000,10 @@ PointToChar(Item item,
TextLineInfo lines, p;
Tk_FontMetrics fm;
+ if (!text->text_info) {
+ return 0;
+ }
+
x -= text->pos_dev.x;
y -= text->pos_dev.y;
@@ -1186,6 +1199,10 @@ DeleteChars(Item item,
int count;
char *new;
+ if (!text->text_info) {
+ return;
+ }
+
if (first < 0) {
first = 0;
}
@@ -1293,7 +1310,7 @@ Selection(Item item,
return 0;
}
strncpy(chars, text->text + wi->text_info.sel_first + offset, (size_t) count);
- chars[count] = '\0';
+ chars[count] = 0;
return count;
}