aboutsummaryrefslogtreecommitdiff
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/Item.c259
1 files changed, 128 insertions, 131 deletions
diff --git a/generic/Item.c b/generic/Item.c
index 95580d1..a9a5e3a 100644
--- a/generic/Item.c
+++ b/generic/Item.c
@@ -2041,12 +2041,16 @@ GetFieldBBox(FieldSet field_set,
unsigned int index,
ZnBBox *field_bbox)
{
+ ZnReal ox, oy;
+
if (field_set->label_format) {
+ ox = REAL_TO_INT(field_set->label_pos.x);
+ oy = REAL_TO_INT(field_set->label_pos.y);
ComputeFieldAttachment(field_set, index, field_bbox);
- field_bbox->orig.x += field_set->label_pos.x;
- field_bbox->orig.y += field_set->label_pos.y;
- field_bbox->corner.x += field_set->label_pos.x;
- field_bbox->corner.y += field_set->label_pos.y;
+ field_bbox->orig.x += ox;
+ field_bbox->orig.y += oy;
+ field_bbox->corner.x += ox;
+ field_bbox->corner.y += oy;
}
else {
ResetBBox(field_bbox);
@@ -2077,7 +2081,7 @@ ComputeFieldTextLocation(Field field_ptr,
Tk_GetFontMetrics(field_ptr->font, &fm);
w = ZnTextWidth(field_ptr->font, field_ptr->text, strlen(field_ptr->text));
h = fm.ascent + fm.descent;
- text_bbox->orig.y = (bbox->orig.y + bbox->corner.y - h) / 2;
+ text_bbox->orig.y = (bbox->orig.y + bbox->corner.y - h) / 2.0;
text_bbox->corner.y = text_bbox->orig.y + h;
pos->y = text_bbox->orig.y + fm.ascent;
@@ -2089,7 +2093,7 @@ ComputeFieldTextLocation(Field field_ptr,
text_bbox->orig.x = bbox->corner.x - w - 2;
break;
default:
- text_bbox->orig.x = (bbox->orig.x + bbox->corner.x - w) / 2;
+ text_bbox->orig.x = (bbox->orig.x + bbox->corner.x - w) / 2.0;
break;
}
text_bbox->corner.x = text_bbox->orig.x + w;
@@ -2912,7 +2916,7 @@ ComposeTransform(ZnTransfo *transfo,
else {
ZnPoint scale, trans, local_scale, local_trans;
ZnReal local_rot, rot;
- ZnTransfo t, t2;
+ ZnTransfo t, t2;
/*
* Need to decompose the local transform in translation,
@@ -3026,10 +3030,6 @@ PushTransform(WidgetInfo *wi,
ZnTransfo *next_t;
int num_t;
- if (transfo == NULL) {
- return;
- }
-
/*
* Push the current transform and concatenate
* the new transform taking into account the
@@ -3852,8 +3852,7 @@ ConfigureField(FieldSet field_set,
field_ptr->gradient = ZnGetReliefGradient(wi->interp, wi->win,
ZnNameOfColor(ZnGetGradientColor(wi->win,
field_ptr->fill_color,
- 50.0,
- NULL)));
+ 50.0, NULL)));
if (field_ptr->gradient == NULL) {
return ZN_ERROR;
}
@@ -4070,24 +4069,22 @@ FieldsEngine(FieldSet field_set,
ZnReal val;
if (field_set->label_format && LabelFormatNumFields(field_set->label_format)) {
- bbox.orig = field_set->label_pos;
+ bbox.orig.x = REAL_TO_INT(field_set->label_pos.x);
+ bbox.orig.y = REAL_TO_INT(field_set->label_pos.y);
GetLabelBBox(field_set, &lwidth, &lheight);
- bbox.corner.x = field_set->label_pos.x + lwidth;
- bbox.corner.y = field_set->label_pos.y + lheight;
+ bbox.corner.x = bbox.orig.x + lwidth;
+ bbox.corner.y = bbox.orig.y + lheight;
CurrentClip(wi, NULL, &global_clip_box, NULL);
-#if GLX
+
if (!wi->render) {
-#endif
IntersectBBox(global_clip_box, &bbox, &label_clip_box);
if (IsEmptyBBox(&label_clip_box)) {
return;
}
-#if GLX
}
else {
label_clip_box = bbox;
}
-#endif
num = LabelFormatNumFields(field_set->label_format);
for (i = 0; i < num; i++) {
@@ -4350,7 +4347,7 @@ RenderField(WidgetInfo *wi,
XColor *color;
int alpha, alpha2;
- alpha2 = 65535*wi->alpha/100;
+ alpha2 = 100*wi->alpha*65535/100;
/*
* Draw the background.
*/
@@ -4399,7 +4396,7 @@ RenderField(WidgetInfo *wi,
*/
if (field_ptr->image != ZnUnspecifiedImage) {
RenderImage(wi, GetImageTexture(wi->win, field_ptr->image_name, field_ptr->image),
- NULL, 255, &(pm_bbox->orig));
+ NULL, 100, &(pm_bbox->orig));
}
}
else {
@@ -4410,17 +4407,19 @@ RenderField(WidgetInfo *wi,
if (!field_ptr->txf) {
field_ptr->txf = GetTexFont(wi->win, field_ptr->font);
}
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- glEnable(GL_TEXTURE_2D);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- color = field_ptr->color;
- glColor4us(color->red, color->green, color->blue, alpha2);
- glBindTexture(GL_TEXTURE_2D, field_ptr->txf->texobj);
- glPushMatrix();
- glTranslatef(text_pos->x, text_pos->y, 0.0);
- txfRenderString(field_ptr->txf, field_ptr->text, strlen(field_ptr->text));
- glPopMatrix();
- glDisable(GL_TEXTURE_2D);
+ if (field_ptr->txf) {
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ glEnable(GL_TEXTURE_2D);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ color = field_ptr->color;
+ glColor4us(color->red, color->green, color->blue, alpha2);
+ glBindTexture(GL_TEXTURE_2D, field_ptr->txf->texobj);
+ glPushMatrix();
+ glTranslatef(text_pos->x, text_pos->y, 0.0);
+ txfRenderString(field_ptr->txf, field_ptr->text, strlen(field_ptr->text));
+ glPopMatrix();
+ glDisable(GL_TEXTURE_2D);
+ }
}
}
}
@@ -4430,15 +4429,18 @@ RenderField(WidgetInfo *wi,
*/
if ((field_ptr->relief != RELIEF_FLAT) && (field_ptr->relief_thickness > 1)) {
ZnPoint p[5];
- p[0] = bbox->orig;
- p[2] = bbox->corner;
- p[3].x = p[0].x;
- p[3].y = p[2].y;
- p[1].x = p[2].x;
- p[1].y = p[0].y;
+
+ p[0].x = bbox->orig.x;
+ p[0].y = bbox->orig.y;
+ p[2].x = bbox->corner.x;
+ p[2].y = bbox->corner.y;
+ p[1].x = p[0].x;
+ p[1].y = p[2].y;
+ p[3].x = p[2].x;
+ p[3].y = p[0].y;
p[4] = p[0];
RenderPolygonRelief(wi, field_ptr->relief, field_ptr->gradient,
- 255, 0, p, 5, field_ptr->relief_thickness);
+ 100, 0, p, 5, field_ptr->relief_thickness);
}
/*
@@ -4709,107 +4711,102 @@ Repair(WidgetInfo *wi)
ZnPoint pts[2];
ZnPoly poly;
- /* To be done only if we are realized and
- there is something to update. */
- if (wi->realized && !IsEmptyBBox(&wi->damaged_area)) {
-
- if (wi->render) {
+ if (wi->render) {
#ifdef GLX
- ZnReal int_width, int_height;
-
- int_width = Tk_Width(wi->win) - 2*wi->inset;
- int_height = Tk_Height(wi->win) - 2*wi->inset;
-
- /*
- * We do not use the samaged 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;
-
- /* 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) int_width, (GLsizei) int_height);
- /* Set the base coord system to the X device coord system. */
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluOrtho2D(0.0, int_width, int_height, 0.0);
- glMatrixMode(GL_MODELVIEW);
-
- /* 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 | GL_STENCIL_BUFFER_BIT);
- glEnable(GL_BLEND);
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ ZnReal int_width, int_height;
+
+ int_width = Tk_Width(wi->win) - 2*wi->inset;
+ int_height = Tk_Height(wi->win) - 2*wi->inset;
+
+ /*
+ * 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;
+
+ /* 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) int_width, (GLsizei) int_height);
+ /* Set the base coord system to the X device coord system. */
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluOrtho2D(0.0, int_width, int_height, 0.0);
+ glMatrixMode(GL_MODELVIEW);
+
+ /* 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 | GL_STENCIL_BUFFER_BIT);
+ glEnable(GL_BLEND);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+
+ /*
+ * Setup the background tile if needed.
+ */
+ if (wi->tile != ZnUnspecifiedImage) {
+ ZnBBox bbox;
- /*
- * Setup the background tile if needed.
- */
- if (wi->tile != ZnUnspecifiedImage) {
- ZnBBox bbox;
-
- bbox.orig.x = bbox.orig.y = 0.0;
- bbox.corner.x = int_width;
- bbox.corner.y = int_height;
-
- RenderTile(wi, GetImageTexture(wi->win, wi->tile_name, wi->tile),
- NULL, NULL, NULL, (ZnPoint *) &bbox);
- }
- /*
- * Init the composite group alpha.
- */
- wi->alpha = 100;
+ bbox.orig.x = bbox.orig.y = 0.0;
+ bbox.corner.x = int_width;
+ bbox.corner.y = int_height;
- glEnable(GL_POINT_SMOOTH);
- glEnable(GL_LINE_SMOOTH);
+ RenderTile(wi, GetImageTexture(wi->win, wi->tile_name, wi->tile),
+ NULL, NULL, NULL, (ZnPoint *) &bbox);
+ }
+ /*
+ * Init the composite group alpha.
+ */
+ wi->alpha = 100;
+
+ glEnable(GL_POINT_SMOOTH);
+ glEnable(GL_LINE_SMOOTH);
#if 0
- glEnable(GL_POLYGON_SMOOTH); /* expensive ? */
+ glEnable(GL_POLYGON_SMOOTH); /* expensive ? */
#endif
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- wi->top_group->class->Render(wi->top_group);
- glFlush();
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ wi->top_group->class->Render(wi->top_group);
+ glFlush();
#endif
+ }
+ else {
+ /* Set the whole damaged area as clip rect. */
+ wi->damaged_area.orig.x = r.x = REAL_TO_INT(wi->damaged_area.orig.x);
+ wi->damaged_area.orig.y = r.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);
+ r.width = wi->damaged_area.corner.x - wi->damaged_area.orig.x;
+ r.height = wi->damaged_area.corner.y - wi->damaged_area.orig.y;
+ pts[0] = wi->damaged_area.orig;
+ pts[1] = wi->damaged_area.corner;
+ POLY_CONTOUR1(&poly, pts, 2);
+ PushClip(wi, &poly, True, True);
+
+ /* Fill the background of the double buffer pixmap. */
+ if (wi->tile == ZnUnspecifiedImage) {
+ values.foreground = ZnPixel(wi->back_color);
+ values.fill_style = FillSolid;
+ XChangeGC(wi->dpy, wi->gc, GCFillStyle|GCForeground, &values);
}
else {
- /* Set the whole damaged area as clip rect. */
- wi->damaged_area.orig.x = r.x = REAL_TO_INT(wi->damaged_area.orig.x);
- wi->damaged_area.orig.y = r.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);
- r.width = wi->damaged_area.corner.x - wi->damaged_area.orig.x;
- r.height = wi->damaged_area.corner.y - wi->damaged_area.orig.y;
- pts[0] = wi->damaged_area.orig;
- pts[1] = wi->damaged_area.corner;
- POLY_CONTOUR1(&poly, pts, 2);
- PushClip(wi, &poly, True, True);
+ values.fill_style = FillTiled;
+ values.tile = GetImagePixmap(wi->win, wi->tile_name, wi->tile, NULL);
+ values.ts_x_origin = values.ts_y_origin = 0;
+ XChangeGC(wi->dpy, wi->gc,
+ GCFillStyle|GCTile|GCTileStipXOrigin|GCTileStipYOrigin,
+ &values);
+ }
+ /*printf("Repair : filling rectangle: %d %d %d %d\n", r.x, r.y, r.width, r.height);*/
+ XFillRectangle(wi->dpy, wi->draw_buffer, wi->gc, r.x, r.y, r.width, r.height);
- /* Fill the background of the double buffer pixmap. */
- if (wi->tile == ZnUnspecifiedImage) {
- values.foreground = ZnPixel(wi->back_color);
- values.fill_style = FillSolid;
- XChangeGC(wi->dpy, wi->gc, GCFillStyle|GCForeground, &values);
- }
- else {
- values.fill_style = FillTiled;
- values.tile = GetImagePixmap(wi->win, wi->tile_name, wi->tile, NULL);
- values.ts_x_origin = values.ts_y_origin = 0;
- XChangeGC(wi->dpy, wi->gc,
- GCFillStyle|GCTile|GCTileStipXOrigin|GCTileStipYOrigin,
- &values);
- }
- /*printf("Repair : filling rectangle: %d %d %d %d\n", r.x, r.y, r.width, r.height);*/
- XFillRectangle(wi->dpy, wi->draw_buffer, wi->gc, r.x, r.y, r.width, r.height);
-
- /* Draw the items */
- /*printf("Drawing\n");*/
- wi->top_group->class->Draw(wi->top_group);
+ /* Draw the items */
+ /*printf("Drawing\n");*/
+ wi->top_group->class->Draw(wi->top_group);
- PopClip(wi, True);
- }
+ PopClip(wi, True);
}
}