aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--generic/Item.c239
1 files changed, 109 insertions, 130 deletions
diff --git a/generic/Item.c b/generic/Item.c
index 067754a..4c52f9c 100644
--- a/generic/Item.c
+++ b/generic/Item.c
@@ -785,15 +785,15 @@ ConfigureAttributes(char *record,
}
case ZN_CONFIG_RELIEF:
{
- int relief;
- if (Tk_GetRelief(wi->interp, Tcl_GetString(args[i+1]), &relief) == ZN_ERROR) {
+ ReliefStyle relief;
+ if (ZnGetRelief(wi, Tcl_GetString(args[i+1]), &relief) == ZN_ERROR) {
Tcl_AppendResult(wi->interp, " relief expected for attribute \"",
Tcl_GetString(args[i]), "\"", NULL);
return ZN_ERROR;
}
if (relief != *((ReliefStyle *) valp)) {
/*printf("valp <0x%X>, flags <0x%X>, relief %d\n", valp, flags, relief);*/
- *((ReliefStyle *) valp) = (ReliefStyle) relief;
+ *((ReliefStyle *) valp) = relief;
*flags |= desc->flags;
}
break;
@@ -999,7 +999,10 @@ ConfigureAttributes(char *record,
switch (desc->type) {
case ZN_CONFIG_ANGLE:
integer = integer % 360;
- if (integer < 0) {
+ if (integer == 0) {
+ integer = 360;
+ }
+ else if (integer < 0) {
integer = 360 + integer;
}
break;
@@ -1154,7 +1157,7 @@ ConfigureAttributes(char *record,
while (*str && (*str == ' ')) {
str++;
}
- while (!*str && (anchor_index < 4)) {
+ while (*str && (anchor_index < 4)) {
switch (*str) {
case '|':
num_tok = sscanf(str, "|%d%n", &anchors[anchor_index], &index);
@@ -1449,7 +1452,7 @@ AttributeToObj(WidgetInfo *wi,
break;
}
case ZN_CONFIG_RELIEF:
- str = Tk_NameOfRelief(*((ReliefStyle *) valp));
+ str = ZnNameOfRelief(*((ReliefStyle *) valp));
Tcl_SetStringObj(result, str, strlen(str));
break;
case ZN_CONFIG_JOIN_STYLE:
@@ -1874,7 +1877,7 @@ ComputeFieldAttachment(FieldSet field_set,
ref_field = x_spec;
field_bbox->orig.x = field_bbox->corner.x = 0;
if ((ref_field < 0) || (ref_field >= num_fields)) {
- ZnWarning ("Attached (x) to an inexistant field geometry");
+ ZnWarning ("Attached (x) to an inexistant field geometry\n");
}
else {
ComputeFieldAttachment(field_set, ref_field, &ref_bbox);
@@ -1928,7 +1931,7 @@ ComputeFieldAttachment(FieldSet field_set,
ref_field = y_spec;
field_bbox->orig.y = field_bbox->corner.y = 0;
if ((ref_field < 0) || (ref_field >= num_fields)) {
- ZnWarning ("Attached (y) to an inexistant field geometry");
+ ZnWarning ("Attached (y) to an inexistant field geometry\n");
}
else {
ComputeFieldAttachment(field_set, ref_field, &ref_bbox);
@@ -3824,9 +3827,9 @@ InitFields(FieldSet field_set)
field = &field_set->fields[i];
field->field_set = field_set;
- field->color = ZnGetGradientByValue(wi->fore_gradient);
- field->fill_color = ZnGetGradient(wi->interp, wi->win, ZnNameOfColor(wi->back_color));
- field->border_color = ZnGetGradientByValue(wi->fore_gradient);
+ field->color = ZnGetGradientByValue(wi->fore_color);
+ field->fill_color = ZnGetGradientByValue(wi->back_color);
+ field->border_color = ZnGetGradientByValue(wi->fore_color);
SET(field->flags, FIELD_VISIBLE_BIT);
SET(field->flags, FIELD_SENSITIVE_BIT);
CLEAR(field->flags, FILLED_BIT);
@@ -3890,14 +3893,14 @@ CloneFields(FieldSet field_set)
}
field->grad_geo = NULL;
- if (strlen(field->image_name) != 0) {
+ if (field->image != ZnUnspecifiedImage) {
text = ZnMalloc((strlen(field->image_name) + 1) * sizeof(char));
strcpy(text, field->image_name);
field->image_name = text;
field->image = Tk_GetImage(wi->interp, wi->win, field->image_name,
FieldImageChange, (ClientData) field);
}
- if (strlen(field->tile_name) != 0) {
+ if (field->tile != ZnUnspecifiedImage) {
text = ZnMalloc((strlen(field->tile_name) + 1) * sizeof(char));
strcpy(text, field->tile_name);
field->tile_name = text;
@@ -3940,7 +3943,9 @@ ConfigureField(FieldSet field_set,
Field field_ptr;
ZnBBox bbox;
WidgetInfo *wi = field_set->wi;
-
+ XColor *color;
+ int alpha;
+
if (field >= field_set->num_fields) {
return ZN_ERROR;
}
@@ -3964,54 +3969,26 @@ ConfigureField(FieldSet field_set,
field_ptr->gradient = NULL;
}
if ((field_ptr->relief != RELIEF_FLAT) && !field_ptr->gradient) {
+ color = ZnGetGradientColor(field_ptr->border_color, 51.0, &alpha);
field_ptr->gradient = ZnGetReliefGradient(wi->interp, wi->win,
- ZnNameOfColor(ZnGetGradientColor(field_ptr->fill_color,
- 50.0, NULL)));
+ ZnNameOfColor(color), alpha);
if (field_ptr->gradient == NULL) {
return ZN_ERROR;
}
}
if (ISSET(*flags, ZN_IMAGE_FLAG)) {
- Tk_Image image;
-
- if (strcmp(field_ptr->image_name, "") != 0) {
- image = Tk_GetImage(wi->interp, wi->win, field_ptr->image_name,
- FieldImageChange, (ClientData) field_ptr);
- if (image == NULL) {
- /*
- * The name will not be in sync with the image in
- * this case.
- */
- return ZN_ERROR;
- }
- }
- else {
- image = ZnUnspecifiedImage;
- }
- if (field_ptr->image != ZnUnspecifiedImage) {
- Tk_FreeImage(field_ptr->image);
+ if (ValidateImage(wi, field_ptr, field_ptr->image_name, FieldImageChange,
+ &field_ptr->image, "field -image") == ZN_ERROR) {
+ return ZN_ERROR;
}
- field_ptr->image = image;
}
if (ISSET(*flags, ZN_TILE_FLAG)) {
- Tk_Image tile;
-
- if (strcmp(field_ptr->tile_name, "") != 0) {
- tile = Tk_GetImage(wi->interp, wi->win, field_ptr->tile_name,
- FieldTileChange, (ClientData) field_ptr);
- if (tile == NULL) {
- return ZN_ERROR;
- }
- }
- else {
- tile = ZnUnspecifiedImage;
- }
- if (field_ptr->tile != ZnUnspecifiedImage) {
- Tk_FreeImage(field_ptr->tile);
+ if (ValidateImage(wi, field_ptr, field_ptr->tile_name, FieldTileChange,
+ &field_ptr->tile, "field -tile") == ZN_ERROR) {
+ return ZN_ERROR;
}
- field_ptr->tile = tile;
}
/*
@@ -4467,7 +4444,7 @@ RenderField(WidgetInfo *wi,
if (ISSET(field_ptr->flags, FILLED_BIT)) {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
if (!ZnGradientFlat(field_ptr->fill_color)) {
-#if 0
+#if 0 /* TODO_GLX Faire le dégradé dans le fond des champs. */
int type = field_ptr->fill_color->type;
ZnBool fast = (type == ZN_AXIAL_GRADIENT) && !field_ptr->grad_geo;
@@ -4499,7 +4476,7 @@ RenderField(WidgetInfo *wi,
}
/*
- * Draw the image and the text, which is in back depends on
+ * Draw the image and the text, which one is in back depends on
* the value of text_on_top.
*/
for (j = 0; j < 2; j++) {
@@ -4555,7 +4532,7 @@ RenderField(WidgetInfo *wi,
p[3].y = p[0].y;
p[4] = p[0];
RenderPolygonRelief(wi, field_ptr->relief, field_ptr->gradient,
- 100, 0, p, 5, field_ptr->relief_thickness);
+ False, p, 5, field_ptr->relief_thickness);
}
/*
@@ -4837,11 +4814,12 @@ Repair(WidgetInfo *wi)
XGCValues values;
ZnPoint pts[2];
ZnTriStrip tristrip;
-
+ XColor *color;
+ ZnReal int_width = Tk_Width(wi->win);
+ ZnReal int_height = Tk_Height(wi->win);
+
if (wi->render) {
#ifdef GLX
- ZnReal int_width, int_height;
-
glXMakeCurrent(wi->dpy, ZnWindowId(wi->win), wi->gl_context);
glEnable(GL_POINT_SMOOTH);
@@ -4855,8 +4833,9 @@ Repair(WidgetInfo *wi)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearStencil(0);
- glClearColor(wi->back_color->red/65536.0, wi->back_color->green/65536.0,
- wi->back_color->blue/65536.0, 0.0);
+ color = ZnGetGradientColor(wi->back_color, 0, NULL);
+ glClearColor(color->red/65536.0, color->green/65536.0,
+ color->blue/65536.0, 0.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
@@ -4865,59 +4844,7 @@ Repair(WidgetInfo *wi)
*/
wi->alpha = 100;
- int_width = Tk_Width(wi->win);
- int_height = Tk_Height(wi->win);
-
- if ((wi->border_width > 0) || (wi->highlight_width > 0)) {
-#ifdef GLX_DAMAGE
- glDisable(GL_SCISSOR_TEST);
-#endif
- glViewport(0, 0, (GLsizei) int_width, int_height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluOrtho2D(0.0, int_width, int_height, 0.0);
- glMatrixMode(GL_MODELVIEW);
- if (wi->highlight_width > 0) {
- if (wi->text_info.got_focus) {
- glColor4us(wi->highlight_color->red, wi->highlight_color->green,
- wi->highlight_color->blue, 65535);
- }
- else {
- 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);
- glVertex2f(Tk_Width(wi->win), 0);
- glVertex2f(Tk_Width(wi->win) - wi->highlight_width, wi->highlight_width);
- glVertex2f(Tk_Width(wi->win), Tk_Height(wi->win));
- glVertex2f(Tk_Width(wi->win) - wi->highlight_width, Tk_Height(wi->win) - wi->highlight_width);
- glVertex2f(0, Tk_Height(wi->win));
- glVertex2f(wi->highlight_width, Tk_Height(wi->win) - wi->highlight_width);
- glVertex2f(0, 0);
- glVertex2f(wi->highlight_width, wi->highlight_width);
- glEnd();
- }
- if (wi->border_width > 0) {
- ZnPoint p[5];
-
- p[4].x = p[4].y = p[3].y = p[1].x = wi->highlight_width;
- p[0] = p[4];
- p[3].x = p[2].x = Tk_Width(wi->win) - wi->highlight_width;
- p[2].y = p[1].y = Tk_Height(wi->win) - wi->highlight_width;
- RenderPolygonRelief(wi, wi->relief, wi->relief_grad,
- 65535, 0, p, 5, wi->border_width);
- }
- }
-
- int_width -= 2*wi->inset;
- int_height -= 2*wi->inset;
- /*
- * Set the viewport and base coord system to the X device coord system.
- */
- glViewport(wi->inset, wi->inset, (GLsizei) int_width, int_height);
+ glViewport(0, 0, (GLsizei) int_width, int_height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, int_width, int_height, 0.0);
@@ -4933,12 +4860,18 @@ Repair(WidgetInfo *wi)
/*
* Set the damaged area as the scissor area.
*/
+ wi->damaged_area.orig.x = MAX(wi->damaged_area.orig.x, wi->inset);
+ wi->damaged_area.orig.y = MAX(wi->damaged_area.orig.y, wi->inset);
+ wi->damaged_area.corner.x = MIN(wi->damaged_area.corner.x,
+ int_width-wi->inset);
+ wi->damaged_area.corner.y = MIN(wi->damaged_area.corner.y,
+ int_height-wi->inset);
wi->damaged_area.orig.x = REAL_TO_INT(wi->damaged_area.orig.x);
wi->damaged_area.orig.y = REAL_TO_INT(wi->damaged_area.orig.y);
wi->damaged_area.corner.x = REAL_TO_INT(wi->damaged_area.corner.x);
wi->damaged_area.corner.y = REAL_TO_INT(wi->damaged_area.corner.y);
- glScissor(wi->inset+wi->damaged_area.orig.x,
- wi->inset+int_height - wi->damaged_area.corner.y,
+ glScissor(wi->damaged_area.orig.x,
+ int_height - wi->damaged_area.corner.y,
wi->damaged_area.corner.x - wi->damaged_area.orig.x,
wi->damaged_area.corner.y - wi->damaged_area.orig.y);
#else
@@ -4946,9 +4879,9 @@ Repair(WidgetInfo *wi)
* We do not use the damaged area for GL rendering,
* set it to the whole area.
*/
- wi->damaged_area.orig.x = wi->damaged_area.orig.y = 0.0;
- wi->damaged_area.corner.x = int_width;
- wi->damaged_area.corner.y = int_height;
+ wi->damaged_area.orig.x = wi->damaged_area.orig.y = wi->inset;
+ wi->damaged_area.corner.x = int_width-wi->inset;
+ wi->damaged_area.corner.y = int_height-wi->inset;
#endif
/*
@@ -4971,10 +4904,51 @@ Repair(WidgetInfo *wi)
}
wi->top_group->class->Render(wi->top_group);
- glFlush();
+ if ((wi->border_width > 0) || (wi->highlight_width > 0)) {
+ int alpha;
+
+#ifdef GLX_DAMAGE
+ glDisable(GL_SCISSOR_TEST);
+#endif
+ if (wi->highlight_width > 0) {
+ if (wi->text_info.got_focus) {
+ color = ZnGetGradientColor(wi->highlight_color, 0, &alpha);
+ }
+ else {
+ color = ZnGetGradientColor(wi->highlight_bg_color, 0, &alpha);
+ }
+ alpha = ZnComposeAlpha(alpha, 100);
+ glColor4us(color->red, color->green, color->blue, alpha);
+
+ glBegin(GL_QUAD_STRIP);
+ glVertex2f(0.0, 0.0);
+ glVertex2f(wi->highlight_width, wi->highlight_width);
+ glVertex2f(int_width, 0);
+ glVertex2f(int_width - wi->highlight_width, wi->highlight_width);
+ glVertex2f(int_width, Tk_Height(wi->win));
+ glVertex2f(int_width - wi->highlight_width, int_height - wi->highlight_width);
+ glVertex2f(0, int_height);
+ glVertex2f(wi->highlight_width, int_height - wi->highlight_width);
+ glVertex2f(0, 0);
+ glVertex2f(wi->highlight_width, wi->highlight_width);
+ glEnd();
+ }
+ if (wi->border_width > 0) {
+ ZnPoint p[5];
+
+ p[4].x = p[4].y = p[3].y = p[1].x = wi->highlight_width;
+ p[0] = p[4];
+ p[3].x = p[2].x = int_width - wi->highlight_width;
+ p[2].y = p[1].y = int_height - wi->highlight_width;
+ RenderPolygonRelief(wi, wi->relief, wi->relief_grad,
+ False, p, 5, wi->border_width);
+ }
+ }
+
/* Switch the GL buffers. */
glXSwapBuffers(wi->dpy, ZnWindowId(wi->win));
+ glFlush();
/*
* Wait the end of GL update if we need to synchronize
@@ -5011,7 +4985,7 @@ Repair(WidgetInfo *wi)
/* Fill the background of the double buffer pixmap. */
if (wi->tile == ZnUnspecifiedImage) {
- values.foreground = ZnPixel(wi->back_color);
+ values.foreground = ZnPixel(ZnGetGradientColor(wi->back_color, 0, NULL));
values.fill_style = FillSolid;
XChangeGC(wi->dpy, wi->gc, GCFillStyle|GCForeground, &values);
}
@@ -5035,10 +5009,14 @@ Repair(WidgetInfo *wi)
/*
* Send the merged area back to screen.
*/
+ merge.orig.x = MAX(merge.orig.x, wi->inset);
+ merge.orig.y = MAX(merge.orig.y, wi->inset);
+ merge.corner.x = MIN(merge.corner.x, int_width-wi->inset);
+ merge.corner.y = MIN(merge.corner.y, int_height-wi->inset);
BBox2XRect(&merge, &r);
XCopyArea(wi->dpy,
wi->draw_buffer, ZnWindowId(wi->win), wi->gc,
- r.x, r.y, r.width, r.height, r.x+wi->inset, r.y+wi->inset);
+ r.x, r.y, r.width, r.height, r.x, r.y);
}
/*
@@ -5051,8 +5029,8 @@ Repair(WidgetInfo *wi)
save = wi->draw_buffer;
wi->draw_buffer = ZnWindowId(wi->win);
r.x = r.y = wi->highlight_width;
- r.width = Tk_Width(wi->win) - 2*wi->highlight_width;
- r.height = Tk_Height(wi->win) - 2*wi->highlight_width;
+ r.width = int_width - 2*wi->highlight_width;
+ r.height = int_height - 2*wi->highlight_width;
DrawRectangleRelief(wi, wi->relief, wi->relief_grad,
&r, wi->border_width);
wi->draw_buffer = save;
@@ -5061,24 +5039,25 @@ Repair(WidgetInfo *wi)
XRectangle r[4];
XSetForeground(wi->dpy, wi->gc,
- ZnPixel(wi->text_info.got_focus ?
- wi->highlight_color :
- wi->highlight_bg_color));
+ ZnPixel(ZnGetGradientColor(wi->text_info.got_focus ?
+ wi->highlight_color :
+ wi->highlight_bg_color,
+ 0, NULL)));
XSetFillStyle(wi->dpy, wi->gc, FillSolid);
r[0].x = r[0].y = 0;
- r[0].width = Tk_Width(wi->win);
+ r[0].width = int_width;
r[0].height = wi->highlight_width;
- r[1].x = Tk_Width(wi->win) - wi->highlight_width;
+ r[1].x = int_width - wi->highlight_width;
r[1].y = 0;
r[1].width = wi->highlight_width;
- r[1].height = Tk_Height(wi->win);
+ r[1].height = int_height;
r[2].x = 0;
- r[2].y = Tk_Height(wi->win) - wi->highlight_width;
- r[2].width = Tk_Width(wi->win);
+ r[2].y = int_height - wi->highlight_width;
+ r[2].width = int_width;
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);
+ r[3].height = int_height;
XFillRectangles(wi->dpy, ZnWindowId(wi->win), wi->gc, r, 4);
}
}