aboutsummaryrefslogtreecommitdiff
path: root/generic/Item.c
diff options
context:
space:
mode:
authorlecoanet2002-01-22 10:43:00 +0000
committerlecoanet2002-01-22 10:43:00 +0000
commit2f9376ea0859e8d442fb54a485ed959557c9f8eb (patch)
tree3e1366720610ecb4111d048e473d81bb20f0d323 /generic/Item.c
parent47e0af9d913947e54d35b9bcade9a395749abd62 (diff)
downloadtkzinc-2f9376ea0859e8d442fb54a485ed959557c9f8eb.zip
tkzinc-2f9376ea0859e8d442fb54a485ed959557c9f8eb.tar.gz
tkzinc-2f9376ea0859e8d442fb54a485ed959557c9f8eb.tar.bz2
tkzinc-2f9376ea0859e8d442fb54a485ed959557c9f8eb.tar.xz
Ajoute le type d'attribut liste de couleurs.
Ajout de la classe d'item Triangles. D�placement du code de dessin de la bordure dans Repair. Le changement de contexte GL se fait �galement dans Repair.
Diffstat (limited to 'generic/Item.c')
-rw-r--r--generic/Item.c168
1 files changed, 152 insertions, 16 deletions
diff --git a/generic/Item.c b/generic/Item.c
index a2d159f..44a07e8 100644
--- a/generic/Item.c
+++ b/generic/Item.c
@@ -154,8 +154,10 @@ ZnAttrConfig field_attrs[] = {
static char *attribute_type_strings[] = {
"",
"color",
+ "colors",
"boolean",
"pattern",
+ "patterns",
"text",
"font",
"border",
@@ -174,10 +176,8 @@ static char *attribute_type_strings[] = {
"unsignedint",
"point",
"rectangle",
- "patterns",
"anchor",
"tags",
- "points",
"mapinfo",
"image",
"leaderanchors",
@@ -185,7 +185,7 @@ static char *attribute_type_strings[] = {
"capstyle",
"gradient",
"window",
- "alpha"
+ "alpha",
};
@@ -399,6 +399,88 @@ ConfigureAttributes(char *record,
}
break;
}
+ case ZN_CONFIG_COLORS:
+ {
+ ZnList new_color_list = NULL;
+ ZnGradientColor *colors;
+ int num_colors, j, k;
+ Tcl_Obj **elems;
+ char *color_ptr;
+
+ if (Tcl_ListObjGetElements(wi->interp, args[i+1],
+ &num_colors, &elems) == ZN_ERROR) {
+ Tcl_AppendResult(wi->interp,
+ " color list expected for attribute \"",
+ Tcl_GetString(args[i]), "\"", NULL);
+ return ZN_ERROR;
+ }
+ if (num_colors) {
+ new_color_list = ZnListNew(num_colors, sizeof(ZnGradientColor));
+ ZnListAssertSize(new_color_list, num_colors);
+ colors = ZnListArray(new_color_list);
+ for (j = 0; j < num_colors; j++) {
+ str = Tcl_GetString(elems[j]);
+ if (strlen(str) != 0) {
+ color_ptr = strchr(str, ':');
+ if (color_ptr) {
+ *color_ptr = 0;
+ }
+ colors[j].shades[0] = ZnGetColor(wi->interp, wi->win, Tk_GetUid(str));
+ if (color_ptr) {
+ *color_ptr = ':';
+ }
+ if (!colors[j].shades[0]) {
+ Tcl_AppendResult(wi->interp, " unknown color \"", str,
+ "\" in color list", NULL);
+ colors_err:
+ for (k = 0; k < j; k++) {
+ ZnFreeColor(colors[k].shades[0]);
+ }
+ ZnListFree(new_color_list);
+ return ZN_ERROR;
+ }
+ if (color_ptr) {
+ colors[j].alpha = atoi(color_ptr+1);
+ if (colors[j].alpha > 100) {
+ colors[j].alpha = 100;
+ }
+ }
+ else {
+ colors[j].alpha = 100;
+ }
+ }
+ else {
+ if (j == 0) {
+ Tcl_AppendResult(wi->interp, " first color must not be void", NULL);
+ goto colors_err;
+ }
+ else {
+ colors[j].alpha = colors[j-1].alpha;
+ colors[j].shades[0] = ZnGetColorByValue(wi->win, colors[j-1].shades[0]);
+ }
+ }
+ }
+ }
+ if (*((ZnList *) valp)) {
+ num_colors = ZnListSize(*((ZnList *) valp));
+ colors = ZnListArray(*((ZnList *) valp));
+ for (j = 0; j < num_colors; j++) {
+ if (colors[j].shades[0]) {
+ ZnFreeColor(colors[j].shades[0]);
+ }
+ }
+ ZnListFree(*((ZnList *) valp));
+ *((ZnList *) valp) = new_color_list;
+ *flags |= desc->flags;
+ }
+ else {
+ if (new_color_list) {
+ *((ZnList *) valp) = new_color_list;
+ *flags |= desc->flags;
+ }
+ }
+ break;
+ }
case ZN_CONFIG_GRADIENT:
{
ZnGradient *g;
@@ -479,7 +561,7 @@ ConfigureAttributes(char *record,
if (num_pats) {
new_pat_list = ZnListNew(num_pats, sizeof(Pixmap));
ZnListAssertSize(new_pat_list, num_pats);
- pats = (Pixmap *) ZnListArray(new_pat_list);
+ pats = ZnListArray(new_pat_list);
for (j = 0; j < num_pats; j++) {
str = Tcl_GetString(elems[j]);
if (strlen(str) != 0) {
@@ -501,7 +583,7 @@ ConfigureAttributes(char *record,
}
if (*((ZnList *) valp)) {
num_pats = ZnListSize(*((ZnList *) valp));
- pats = (Pixmap *) ZnListArray(*((ZnList *) valp));
+ pats = ZnListArray(*((ZnList *) valp));
for (j = 0; j < num_pats; j++) {
if (pats[j] != ZnUnspecifiedPattern) {
Tk_FreeBitmap(wi->dpy, pats[j]);
@@ -1202,6 +1284,30 @@ AttributeToObj(WidgetInfo *wi,
Tcl_SetStringObj(result, str, strlen(str));
}
break;
+ case ZN_CONFIG_COLORS:
+ {
+ int num_colors;
+ ZnGradientColor *colors;
+
+ if (*((ZnList *) valp)) {
+ colors = ZnListArray(*((ZnList *) valp));
+ num_colors = ZnListSize(*((ZnList *) valp));
+
+ for (i = 0; i < num_colors; i++) {
+ if (colors[i].alpha != 100) {
+ sprintf(buffer, "%s:%d",
+ ZnNameOfColor(colors[i].shades[0]),
+ colors[i].alpha);
+ o = NewStringObj(buffer);
+ }
+ else {
+ o = NewStringObj(ZnNameOfColor(colors[i].shades[0]));
+ }
+ Tcl_ListObjAppendElement(wi->interp, result, o);
+ }
+ }
+ }
+ break;
case ZN_CONFIG_GRADIENT:
if (*((ZnGradient **) valp)) {
str = ZnNameOfGradient(*((ZnGradient **) valp));
@@ -1625,6 +1731,7 @@ GlobalModuleInit()
AddItemClass(ZnArc);
AddItemClass(ZnCurve);
AddItemClass(ZnBezier);
+ AddItemClass(ZnTriangles);
AddItemClass(ZnGroup);
AddItemClass(ZnIcon);
AddItemClass(ZnText);
@@ -3347,7 +3454,7 @@ PopClip(WidgetInfo *wi,
}
#endif
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- glStencilFunc(GL_EQUAL, num_clips, 0xFF);
+ glStencilFunc(GL_EQUAL, num_clips, 0xFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
#endif
}
@@ -4486,6 +4593,7 @@ RenderField(WidgetInfo *wi,
color = field_ptr->border_color;
glColor4us(color->red, color->green, color->blue, alpha2);
glLineWidth(1);
+ SetLineStyle(wi, LINE_SIMPLE);
glBegin(GL_LINES);
if (field_ptr->border_edges & LEFT_BORDER) {
glVertex2f(bbox->orig.x, bbox->orig.y);
@@ -4701,6 +4809,18 @@ Damage(WidgetInfo *wi,
if (wi->damaged_area.orig.y < 0) {
wi->damaged_area.orig.y = 0;
}
+ if (wi->damaged_area.corner.x < 0) {
+ wi->damaged_area.corner.x = 0;
+ }
+ if (wi->damaged_area.corner.y < 0) {
+ wi->damaged_area.corner.y = 0;
+ }
+ if (wi->damaged_area.orig.x > wi->width) {
+ wi->damaged_area.orig.x = wi->width;
+ }
+ if (wi->damaged_area.orig.y > wi->height) {
+ wi->damaged_area.orig.y = wi->height;
+ }
if (wi->damaged_area.corner.x > wi->width) {
wi->damaged_area.corner.x = wi->width;
}
@@ -4749,7 +4869,9 @@ Repair(WidgetInfo *wi)
if (wi->render) {
#ifdef GLX
ZnReal int_width, int_height;
-
+
+ glXMakeCurrent(wi->dpy, ZnWindowId(wi->win), wi->gl_context);
+
glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH);
#if 0
@@ -4792,6 +4914,7 @@ Repair(WidgetInfo *wi)
glColor4us(wi->highlight_bg_color->red, wi->highlight_bg_color->green,
wi->highlight_bg_color->blue, 65535);
}
+
glBegin(GL_QUAD_STRIP);
glVertex2f(0.0, 0.0);
glVertex2f(wi->highlight_width, wi->highlight_width);
@@ -4832,6 +4955,10 @@ Repair(WidgetInfo *wi)
glEnable(GL_SCISSOR_TEST);
/*
+ * Merge the exposed area.
+ */
+ AddBBoxToBBox(&wi->damaged_area, &wi->exposed_area);
+ /*
* Set the damaged area as the scissor area.
*/
wi->damaged_area.orig.x = REAL_TO_INT(wi->damaged_area.orig.x);
@@ -4856,7 +4983,7 @@ Repair(WidgetInfo *wi)
* Clear the GL buffers.
*/
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
-
+
/*
* Setup the background tile if needed.
*/
@@ -4876,6 +5003,7 @@ Repair(WidgetInfo *wi)
/* Switch the GL buffers. */
glXSwapBuffers(wi->dpy, ZnWindowId(wi->win));
+
/*
* Wait the end of GL update if we need to synchronize
* to monitor perfs.
@@ -4890,7 +5018,7 @@ Repair(WidgetInfo *wi)
ZnBBox merge;
/*
- * Merge the repaired area with the exposed area.
+ * Merge the damaged area with the exposed area.
*/
ResetBBox(&merge);
CopyBBox(&wi->damaged_area, &merge);
@@ -4957,20 +5085,28 @@ Repair(WidgetInfo *wi)
&r, wi->border_width);
wi->draw_buffer = save;
}
- if ((wi->highlight_width > 0) && !wi->render) {
+ if (wi->highlight_width > 0) {
XRectangle r[4];
XSetForeground(wi->dpy, wi->gc,
ZnPixel(wi->text_info.got_focus ?
wi->highlight_color :
wi->highlight_bg_color));
- r[0].x = r[0].y = r[1].x = r[2].x = 0;
+ XSetFillStyle(wi->dpy, wi->gc, FillSolid);
+ r[0].x = r[0].y = 0;
r[0].width = Tk_Width(wi->win);
- r[1].y = Tk_Height(wi->win) - wi->highlight_width;
- r[1].width = Tk_Width(wi->win);
- r[0].height = r[1].height = r[3].y = r[2].y = r[2].width = r[3].width = wi->highlight_width;
- r[3].height = r[2].height = Tk_Height(wi->win) - 2*wi->highlight_width;
- r[3].x = Tk_Width(wi->win) - wi->highlight_width;
+ r[0].height = wi->highlight_width;
+ r[1].x = Tk_Width(wi->win) - wi->highlight_width;
+ r[1].y = 0;
+ r[1].width = wi->highlight_width;
+ r[1].height = Tk_Height(wi->win);
+ r[2].x = 0;
+ r[2].y = Tk_Height(wi->win) - wi->highlight_width;
+ r[2].width = Tk_Width(wi->win);
+ r[2].height = wi->highlight_width;
+ r[3].x = r[3].y = 0;
+ r[3].width = wi->highlight_width;
+ r[3].height = Tk_Height(wi->win);
XFillRectangles(wi->dpy, ZnWindowId(wi->win), wi->gc, r, 4);
}
}