aboutsummaryrefslogtreecommitdiff
path: root/generic/Item.c
diff options
context:
space:
mode:
authorlecoanet2001-03-15 09:18:48 +0000
committerlecoanet2001-03-15 09:18:48 +0000
commit7c3b3cdbf6df58fc41609bb09787b46eac00027c (patch)
treef93da08d8c41aaad9c7a3a2d9228efc6b000cd86 /generic/Item.c
parent93d20b815cc0f3c73c19dc1a0f026aa9d80c616d (diff)
downloadtkzinc-7c3b3cdbf6df58fc41609bb09787b46eac00027c.zip
tkzinc-7c3b3cdbf6df58fc41609bb09787b46eac00027c.tar.gz
tkzinc-7c3b3cdbf6df58fc41609bb09787b46eac00027c.tar.bz2
tkzinc-7c3b3cdbf6df58fc41609bb09787b46eac00027c.tar.xz
Int�gration GLX.
Suppression (compilation conditionnelle) de l'utilisation de Tcl_Merge en Perl. On se rapproche un peu plus d'un traitement unifi� Perl et Tcl. Correction du dimensionnement automatique du champ autour d'un texte, on ajoute qq pixels de padding. La correction touche �galement le positionnement du texte dans le champ. Suppression de l'utilisation de ZnListDo, Du coup cela corrige un core dump lorsque l'on d�truit des items d�pendants (cf waypoints). Correction du traitement du clipping des champs. Le clipping est maintenant r�aliser correctement (pas trop petit) et uniquement quand il faut. Avant on clippait plus que n�cessaire, sans que cela ait d'incidence sur le rendu.
Diffstat (limited to 'generic/Item.c')
-rw-r--r--generic/Item.c138
1 files changed, 88 insertions, 50 deletions
diff --git a/generic/Item.c b/generic/Item.c
index 1a08044..1a15218 100644
--- a/generic/Item.c
+++ b/generic/Item.c
@@ -33,6 +33,9 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
+#ifdef GLX
+#include <GL/glu.h>
+#endif
#include "Item.h"
#include "Types.h"
@@ -285,7 +288,7 @@ AttributesInfo(Item item,
entries[2] = NewBooleanObj(desc->read_only ? 1 : 0);
entries[3] = NewStringObj("");
entries[4] = AttributeToObj(wi, record, desc, buffer);
-#ifdef PTK
+#ifdef PTK0
l = Tcl_Merge(5, entries);
Tcl_SetObjResult(wi->interp, l);
#else
@@ -293,7 +296,7 @@ AttributesInfo(Item item,
#endif
}
else {
-#ifdef PTK
+#ifdef PTK0
Tcl_Obj *o;
#endif
l = Tcl_GetObjResult(wi->interp);
@@ -303,7 +306,7 @@ AttributesInfo(Item item,
entries[2] = NewBooleanObj(desc->read_only ? 1 : 0);
entries[3] = NewStringObj("");
entries[4] = AttributeToObj(wi, record, desc, buffer);
-#ifdef PTK
+#ifdef PTK0
o = NULL;
LangSetArg(&o, Tcl_Merge(5, entries));
Tcl_ListObjAppendElement(wi->interp, l, o);
@@ -1210,7 +1213,7 @@ AttributeToObj(WidgetInfo *wi,
char *str = "";
Tcl_Obj *o, *objs[4];
int i;
-#ifdef PTK
+#ifdef PTK0
Tcl_Obj **tmp=NULL;
#endif
@@ -1233,13 +1236,13 @@ AttributeToObj(WidgetInfo *wi,
int num_pats=0;
Pixmap *pats;
-#ifndef PTK
+#ifndef PTK0
result = Tcl_NewListObj(0, NULL);
#endif
if (*((ZnList *) valp)) {
pats = (Pixmap *) ZnListArray(*((ZnList *) valp));
num_pats = ZnListSize(*((ZnList *) valp));
-#ifdef PTK
+#ifdef PTK0
tmp = (Tcl_Obj **) ZnMalloc(num_pats * sizeof(Tcl_Obj *));
#endif
for (i = 0; i < num_pats; i++) {
@@ -1249,14 +1252,14 @@ AttributeToObj(WidgetInfo *wi,
else {
o = NewStringObj("");
}
-#ifdef PTK
+#ifdef PTK0
tmp[i] = o;
#else
Tcl_ListObjAppendElement(wi->interp, result, o);
#endif
}
}
-#ifdef PTK
+#ifdef PTK0
result = Tcl_Merge(num_pats, tmp);
ZnFree(tmp);
#endif
@@ -1267,17 +1270,17 @@ AttributeToObj(WidgetInfo *wi,
int num_tags=0;
Tk_Uid *tags;
-#ifndef PTK
+#ifndef PTK0
result = Tcl_NewListObj(0, NULL);
#endif
if (*((ZnList *) valp)) {
tags = (Tk_Uid *) ZnListArray(*((ZnList *) valp));
num_tags = ZnListSize(*((ZnList *) valp));
-#ifdef PTK
+#ifdef PTK0
tmp = (Tcl_Obj **) ZnMalloc(num_tags * sizeof(Tcl_Obj *));
#endif
for (i = 0; i < num_tags; i++) {
-#ifdef PTK
+#ifdef PTK0
tmp[i] = NewStringObj(tags[i]);
#else
Tcl_ListObjAppendElement(wi->interp, result,
@@ -1285,7 +1288,7 @@ AttributeToObj(WidgetInfo *wi,
#endif
}
}
-#ifdef PTK
+#ifdef PTK0
result = Tcl_Merge(num_tags, tmp);
ZnFree(tmp);
#endif
@@ -1430,7 +1433,7 @@ AttributeToObj(WidgetInfo *wi,
{
objs[0] = NewDoubleObj(((ZnPoint *) valp)->x);
objs[1] = NewDoubleObj(((ZnPoint *) valp)->y);
-#ifdef PTK
+#ifdef PTK0
result = Tcl_Merge(2, objs);
#else
result = Tcl_NewListObj(2, objs);
@@ -1443,7 +1446,7 @@ AttributeToObj(WidgetInfo *wi,
objs[1] = NewDoubleObj(((ZnRect *) valp)->y);
objs[2] = NewDoubleObj(((ZnRect *) valp)->w);
objs[3] = NewDoubleObj(((ZnRect *) valp)->h);
-#ifdef PTK
+#ifdef PTK0
result = Tcl_Merge(4, objs);
#else
result = Tcl_NewListObj(4, objs);
@@ -1762,7 +1765,10 @@ ComputeFieldAttachment(FieldSet field_set,
real_width = (ZnDim) icon_width;
}
if (len) {
- text_width = (ZnDim) ZnTextWidth(field_ptr->font, field_ptr->text, len);
+ /*
+ * The 4 extra pixels are needed for border and padding.
+ */
+ text_width = (ZnDim) ZnTextWidth(field_ptr->font, field_ptr->text, len) + 4;
real_width = text_width < real_width ? real_width : text_width;
}
real_width += (ZnDim) width_spec;
@@ -2134,10 +2140,10 @@ ComputeFieldTextLocation(Field field_ptr,
switch (field_ptr->alignment) {
case ZnJustifyLeft:
- text_bbox->orig.x = bbox->orig.x;
+ text_bbox->orig.x = bbox->orig.x + 2;
break;
case ZnJustifyRight:
- text_bbox->orig.x = bbox->corner.x - w - 1;
+ text_bbox->orig.x = bbox->corner.x - w - 2;
break;
default:
text_bbox->orig.x = (bbox->orig.x + bbox->corner.x - w) / 2;
@@ -2357,27 +2363,26 @@ InsertDependentItem(Item item)
*
**********************************************************************************
*/
-static int CmpItem(void *item1,
- void *item2)
-{
- return (item1 == item2);
-}
-
static void
ExtractDependentItem(Item item)
{
GroupItem group = (GroupItem) item->parent;
- int index;
+ int index, num_items;
+ Item *deps;
if (!group || !group->dependents) {
return;
}
- index = ZnListDo(group->dependents, item, CmpItem);
- if (index >= 0) {
- ZnListDelete(group->dependents, index);
- if (ZnListSize(group->dependents) == 0) {
- ZnListFree(group->dependents);
- group->dependents = NULL;
+ num_items = ZnListSize(group->dependents);
+ deps = (Item *) ZnListArray(group->dependents);
+ for (index = 0; index < num_items; index++) {
+ if (deps[index]->id == item->id) {
+ ZnListDelete(group->dependents, index);
+ if (ZnListSize(group->dependents) == 0) {
+ ZnListFree(group->dependents);
+ group->dependents = NULL;
+ break;
+ }
}
}
}
@@ -4040,7 +4045,8 @@ DrawFields(FieldSet field_set)
ZnBBox pm_bbox, clip_pm_bbox;
ZnBool restore = False;
ZnDim lwidth, lheight;
-
+ ZnReal val;
+
if (field_set->label_format && LabelFormatNumFields(field_set->label_format)) {
bbox.orig = field_set->label_pos;
GetLabelBBox(field_set, &lwidth, &lheight);
@@ -4085,22 +4091,38 @@ DrawFields(FieldSet field_set)
IntersectBBox(&clip_bbox, &pm_bbox, &clip_pm_bbox);
/* we must call XSetClipRectangles only if it's required */
- if (clip_bbox.orig.x != bbox.orig.x || clip_bbox.orig.y != bbox.orig.y ||
- clip_bbox.corner.x != bbox.corner.x || clip_bbox.corner.y != bbox.corner.y ||
- clip_text_bbox.orig.x != text_bbox.orig.x ||
- clip_text_bbox.orig.y != text_bbox.orig.y ||
- clip_text_bbox.corner.x != text_bbox.corner.x ||
- clip_text_bbox.corner.y != text_bbox.corner.y ||
- clip_pm_bbox.orig.x != pm_bbox.orig.x ||
- clip_pm_bbox.orig.y != pm_bbox.orig.y ||
- clip_pm_bbox.corner.x != pm_bbox.corner.x ||
- clip_pm_bbox.corner.y != pm_bbox.corner.y) {
+ val = clip_bbox.orig.x - bbox.orig.x;
+ restore = val > 0;
+ val = clip_bbox.orig.y - bbox.orig.y;
+ restore |= val > 0;
+ val = clip_bbox.corner.x - bbox.corner.x;
+ restore |= val < 0;
+ val = clip_bbox.corner.y - bbox.corner.y;
+ restore |= val < 0;
+ val = clip_text_bbox.orig.x - text_bbox.orig.x;
+ restore |= val > 0;
+ val = clip_text_bbox.orig.y - text_bbox.orig.y;
+ restore |= val > 0;
+ val = clip_text_bbox.corner.x - text_bbox.corner.x;
+ restore |= val < 0;
+ val = clip_text_bbox.corner.y - text_bbox.corner.y;
+ restore |= val < 0;
+ val = clip_pm_bbox.orig.x - pm_bbox.orig.x;
+ restore |= val > 0;
+ val = clip_pm_bbox.orig.y - pm_bbox.orig.y;
+ restore |= val > 0;
+ val = clip_pm_bbox.corner.x - pm_bbox.corner.x;
+ restore |= val < 0;
+ val = clip_pm_bbox.corner.y - pm_bbox.corner.y;
+ restore |= val < 0;
+ /*restore = True;*/
+ if (restore) {
/* we must clip. */
+ /*printf("clip\n");*/
pts[0] = clip_bbox.orig;
pts[1] = clip_bbox.corner;
POLY_CONTOUR1(&poly, pts, 2);
PushClip(wi, &poly, True, True);
- restore = True;
}
/*
@@ -4612,10 +4634,6 @@ Repair(WidgetInfo *wi)
POLY_CONTOUR1(&poly, pts, 2);
PushClip(wi, &poly, True, True);
-#ifdef PERFOS
- XStartChrono(draw_time, wi->dpy, wi->draw_buffer);
- /*StartChrono(int_draw_time);*/
-#endif
if (wi->render) {
#ifdef LIBART
/* if (wi->tile == ZnUnspecifiedImage) {
@@ -4634,6 +4652,30 @@ Repair(WidgetInfo *wi)
wi->top_group->class->Render(wi->top_group);
RGBToXImage(wi, r.x, r.y, r.width, r.height);
#endif
+#ifdef GLX
+ /* Set the viewport (should be moved to the resize code) */
+ /*glViewport(0, 0, (GLsizei) Tk_Width(wi->win), (GLsizei) Tk_Height(wi->win));*/
+ glViewport(wi->inset, wi->inset,
+ (GLsizei) Tk_Width(wi->win) - 2*wi->inset,
+ (GLsizei) Tk_Height(wi->win) - 2*wi->inset);
+ /* Set the base coord system to the X device coord system. */
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluOrtho2D(0.0, (GLdouble) Tk_Width(wi->win),
+ (GLdouble) Tk_Height(wi->win), 0.0);
+
+ /* Clear the GL buffers. */
+ glClearColor(wi->back_color->red/65536.0, wi->back_color->green/65536.0,
+ wi->back_color->blue/65536.0, 0.0);
+ glClearStencil(0);
+ glClear(GL_COLOR_BUFFER_BIT);
+ glEnable(GL_BLEND);
+ glEnable(GL_LINE_SMOOTH);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ wi->top_group->class->Render(wi->top_group);
+ glFlush();
+#endif
}
else {
/* Fill the background of the double buffer pixmap. */
@@ -4657,10 +4699,6 @@ Repair(WidgetInfo *wi)
/*printf("Drawing\n");*/
wi->top_group->class->Draw(wi->top_group);
}
-#ifdef PERFOS
- /*StopChrono(int_draw_time);*/
- XStopChrono(draw_time, wi->dpy, wi->draw_buffer);
-#endif
PopClip(wi, True);
}