aboutsummaryrefslogtreecommitdiff
path: root/generic/tkZinc.c
diff options
context:
space:
mode:
authorlecoanet2002-03-15 13:48:49 +0000
committerlecoanet2002-03-15 13:48:49 +0000
commit00fc0514b112c8b6e6c9ddc94366f7df843c2cfa (patch)
treed2c538b1dfc5f2428ce82151f506dff399a2ad8e /generic/tkZinc.c
parentf2de39eb143431730214cce2c9723e250722d5d2 (diff)
downloadtkzinc-00fc0514b112c8b6e6c9ddc94366f7df843c2cfa.zip
tkzinc-00fc0514b112c8b6e6c9ddc94366f7df843c2cfa.tar.gz
tkzinc-00fc0514b112c8b6e6c9ddc94366f7df843c2cfa.tar.bz2
tkzinc-00fc0514b112c8b6e6c9ddc94366f7df843c2cfa.tar.xz
L'option relief est trait�e en interne ainsi que les options de
couleur qui prennent la forme d'un gradient. D�sormais tout est gradient. Suppression du d�calage d'origine qui faisait que la zone des coordonn�es zinc �tait d�cal�e de la valeur de la bordure relief. D�sormais elle correspond � celle de la fen�tre. LE 0,0 �tant alors sous la bordure. Correction d'un bug dans la commande chggroup qui posait probl�me lorsque l'on changeait un groupe de groupe sans ajuster sa position. Correction d'un bug dans la commande numparts qui retournait un booleen � la place d'un entier positif.
Diffstat (limited to 'generic/tkZinc.c')
-rw-r--r--generic/tkZinc.c249
1 files changed, 169 insertions, 80 deletions
diff --git a/generic/tkZinc.c b/generic/tkZinc.c
index f64d131..6d20d36 100644
--- a/generic/tkZinc.c
+++ b/generic/tkZinc.c
@@ -139,6 +139,28 @@ static Tk_Uid neg_paren_uid;
static Tk_Uid tag_val_uid;
static Tk_Uid neg_tag_val_uid;
+static int ZnReliefParse _ANSI_ARGS_((ClientData client_data, Tcl_Interp *interp,
+ Tk_Window tkwin, Tcl_Obj *ovalue,
+ char *widget_rec, int offset));
+static Tcl_Obj *ZnReliefPrint _ANSI_ARGS_((ClientData client_data, Tk_Window tkwin,
+ char *widget_rec, int offset,
+ Tcl_FreeProc **free_proc));
+static int ZnGradientParse _ANSI_ARGS_((ClientData client_data, Tcl_Interp *interp,
+ Tk_Window tkwin, Tcl_Obj *ovalue,
+ char *widget_rec, int offset));
+static Tcl_Obj *ZnGradientPrint _ANSI_ARGS_((ClientData client_data, Tk_Window tkwin,
+ char *widget_rec, int offset,
+ Tcl_FreeProc **free_proc));
+static Tk_CustomOption reliefOption = {
+ ZnReliefParse,
+ ZnReliefPrint,
+ NULL
+};
+static Tk_CustomOption gradientOption = {
+ ZnGradientParse,
+ ZnGradientPrint,
+ NULL
+};
/*
* Information used for argv parsing.
@@ -146,27 +168,27 @@ static Tk_Uid neg_tag_val_uid;
static Tk_ConfigSpec config_specs[] = {
{TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
"2", Tk_Offset(WidgetInfo, border_width), 0},
- {TK_CONFIG_COLOR, "-backcolor", "backColor", "BackColor",
- "#c3c3c3", Tk_Offset(WidgetInfo, back_color), 0},
+ {TK_CONFIG_CUSTOM, "-backcolor", "backColor", "BackColor",
+ "#c3c3c3", Tk_Offset(WidgetInfo, back_color), 0, &gradientOption},
{TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
"", Tk_Offset(WidgetInfo, cursor), TK_CONFIG_NULL_OK},
{TK_CONFIG_FONT, "-font", "font", "Font",
"-adobe-helvetica-bold-r-normal--*-120-*-*-*-*-*-*",
Tk_Offset(WidgetInfo, font), 0},
- {TK_CONFIG_COLOR, "-forecolor", "foreColor", "Foreground",
- "Black", Tk_Offset(WidgetInfo, fore_color), 0},
+ {TK_CONFIG_CUSTOM, "-forecolor", "foreColor", "Foreground",
+ "Black", Tk_Offset(WidgetInfo, fore_color), 0, &gradientOption},
{TK_CONFIG_BOOLEAN, "-fullreshape", "fullReshape", "FullReshape",
"1", Tk_Offset(WidgetInfo, full_reshape), 0},
{TK_CONFIG_PIXELS, "-height", "height", "Height",
"7c", Tk_Offset(WidgetInfo, opt_height), 0},
- {TK_CONFIG_COLOR, "-highlightbackground", "highlightBackground", "HighlightBackground",
- "#c3c3c3", Tk_Offset(WidgetInfo, highlight_bg_color), 0},
- {TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- "Black", Tk_Offset(WidgetInfo, highlight_color), 0},
+ {TK_CONFIG_CUSTOM, "-highlightbackground", "highlightBackground", "HighlightBackground",
+ "#c3c3c3", Tk_Offset(WidgetInfo, highlight_bg_color), 0, &gradientOption},
+ {TK_CONFIG_CUSTOM, "-highlightcolor", "highlightColor", "HighlightColor",
+ "Black", Tk_Offset(WidgetInfo, highlight_color), 0, &gradientOption},
{TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness",
"2", Tk_Offset(WidgetInfo, highlight_width), 0},
- {TK_CONFIG_COLOR, "-insertbackground", "insertBackground", "Foreground",
- "Black", Tk_Offset(WidgetInfo, text_info.insert_color), 0},
+ {TK_CONFIG_CUSTOM, "-insertbackground", "insertBackground", "Foreground",
+ "Black", Tk_Offset(WidgetInfo, text_info.insert_color), 0, &gradientOption},
{TK_CONFIG_INT, "-insertofftime", "insertOffTime", "OffTime",
"300", Tk_Offset(WidgetInfo, insert_off_time), 0},
{TK_CONFIG_INT, "-insertontime", "insertOnTime", "OnTime",
@@ -184,14 +206,14 @@ static Tk_ConfigSpec config_specs[] = {
#endif
{TK_CONFIG_INT, "-pickaperture", "pickAperture", "PickAperture",
"1", Tk_Offset(WidgetInfo, pick_aperture), 0},
- {TK_CONFIG_RELIEF, "-relief", "relief", "Relief",
- "flat", Tk_Offset(WidgetInfo, relief), 0},
+ {TK_CONFIG_CUSTOM, "-relief", "relief", "Relief",
+ "flat", Tk_Offset(WidgetInfo, relief), 0, &reliefOption},
{TK_CONFIG_BOOLEAN, "-render", "render", "Render",
"0", Tk_Offset(WidgetInfo, render), 0},
{TK_CONFIG_BOOLEAN, "-reshape", "reshape", "Reshape",
"1", Tk_Offset(WidgetInfo, reshape), 0},
- {TK_CONFIG_COLOR, "-selectbackground", "selectBackground", "Foreground",
- "#a0a0a0", Tk_Offset(WidgetInfo, text_info.sel_color), 0},
+ {TK_CONFIG_CUSTOM, "-selectbackground", "selectBackground", "Foreground",
+ "#a0a0a0", Tk_Offset(WidgetInfo, text_info.sel_color), 0, &gradientOption},
{TK_CONFIG_DOUBLE, "-speedvectorlength", "speedVectorLength",
"SpeedVectorLength", "3", Tk_Offset(WidgetInfo, speed_vector_length), 0},
{TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus",
@@ -209,8 +231,8 @@ static Tk_ConfigSpec config_specs[] = {
*/
{TK_CONFIG_BOOLEAN, "-drawbboxes", "drawBBoxes",
"DrawBBoxes", "0", Tk_Offset(WidgetInfo, draw_bboxes), 0},
- {TK_CONFIG_COLOR, "-bboxcolor", "bboxColor", "BBoxColor",
- "Pink", Tk_Offset(WidgetInfo, bbox_color), 0},
+ {TK_CONFIG_CUSTOM, "-bboxcolor", "bboxColor", "BBoxColor",
+ "Pink", Tk_Offset(WidgetInfo, bbox_color), 0, &gradientOption},
{TK_CONFIG_INT, "-lightangle", "lightAngle", "LightAngle",
"120", Tk_Offset(WidgetInfo, light_angle), 0},
@@ -290,6 +312,96 @@ Tcl_GetString(Tcl_Obj *obj)
/*
*----------------------------------------------------------------------
*
+ * ZnReliefParse
+ * ZnReliefPrint --
+ * Converters for the -relief option.
+ *
+ *----------------------------------------------------------------------
+ */
+static int
+ZnReliefParse(ClientData client_data,
+ Tcl_Interp *interp,
+ Tk_Window tkwin,
+ Tcl_Obj *ovalue,
+ char *widget_rec,
+ int offset)
+{
+ ReliefStyle *relief_ptr = (ReliefStyle *) (widget_rec + offset);
+ ReliefStyle relief;
+ char *value = Tcl_GetString(ovalue);
+ int result = ZN_OK;
+
+ if (value != NULL) {
+ result = ZnGetRelief((WidgetInfo *) widget_rec, value, &relief);
+ if (result == ZN_OK) {
+ *relief_ptr = relief;
+ }
+ }
+ return result;
+}
+
+static Tcl_Obj *
+ZnReliefPrint(ClientData client_data,
+ Tk_Window tkwin,
+ char *widget_rec,
+ int offset,
+ Tcl_FreeProc **free_proc)
+{
+ ReliefStyle relief = *(ReliefStyle *) (widget_rec + offset);
+ return NewStringObj(ZnNameOfRelief(relief));
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ZnGradientParse
+ * ZnGradientPrint --
+ * Converters for the -*color* options.
+ *
+ *----------------------------------------------------------------------
+ */
+static int
+ZnGradientParse(ClientData client_data,
+ Tcl_Interp *interp,
+ Tk_Window tkwin,
+ Tcl_Obj *ovalue,
+ char *widget_rec,
+ int offset)
+{
+ ZnGradient **grad_ptr = (ZnGradient **) (widget_rec + offset);
+ ZnGradient *grad, *last_grad;
+ char *value = Tcl_GetString(ovalue);
+
+ last_grad = *grad_ptr;
+ if ((value != NULL) && (*value != '\0')) {
+ grad = ZnGetGradient(interp, tkwin, value);
+ if (grad == NULL) {
+ return ZN_ERROR;
+ }
+ if (last_grad != NULL) {
+ ZnFreeGradient(last_grad);
+ }
+ *grad_ptr = grad;
+ }
+ return ZN_OK;
+}
+
+static Tcl_Obj *
+ZnGradientPrint(ClientData client_data,
+ Tk_Window tkwin,
+ char *widget_rec,
+ int offset,
+ Tcl_FreeProc **free_proc)
+{
+ ZnGradient *gradient = *(ZnGradient **) (widget_rec + offset);
+ return NewStringObj(ZnNameOfGradient(gradient));
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
* ZnGetAlphaStipple --
* Need to be handled per screen/dpy toolkit wide, not on a
* widget basis.
@@ -298,7 +410,7 @@ Tcl_GetString(Tcl_Obj *obj)
*/
Pixmap
ZnGetAlphaStipple(WidgetInfo *wi,
- unsigned char val)
+ unsigned char val)
{
if (val >= 255)
return None;
@@ -428,7 +540,6 @@ ZincObjCmd(ClientData client_data, /* Main window associated with
wi->realized = False;
wi->update_pending = 0;
wi->fore_color = NULL;
- wi->fore_gradient = NULL;
wi->back_color = NULL;
wi->relief_grad = NULL;
wi->bbox_color = NULL;
@@ -1689,10 +1800,6 @@ FindArea(WidgetInfo *wi,
}
area.corner.x += 1;
area.corner.y += 1;
- area.orig.x -= wi->inset;
- area.orig.y -= wi->inset;
- area.corner.x -= wi->inset;
- area.corner.y -= wi->inset;
wi->top_group->class->ToArea(wi->top_group, &area, tag_uid, enclosed, False);
@@ -1918,8 +2025,6 @@ FindItems(WidgetInfo *wi,
if (Tcl_GetDoubleFromObj(wi->interp, args[first+2], &p.y) == ZN_ERROR) {
return ZN_ERROR;
}
- p.x -= wi->inset;
- p.y -= wi->inset;
if (argc > first+3) {
if (Tcl_GetIntFromObj(wi->interp, args[first+3], &halo) == ZN_ERROR) {
return ZN_ERROR;
@@ -2663,10 +2768,10 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
}
if (!IsEmptyBBox(&bbox)) {
l = Tcl_GetObjResult(interp);
- Tcl_ListObjAppendElement(interp, l, NewDoubleObj(bbox.orig.x+wi->inset));
- Tcl_ListObjAppendElement(interp, l, NewDoubleObj(bbox.orig.y+wi->inset));
- Tcl_ListObjAppendElement(interp, l, NewDoubleObj(bbox.corner.x+wi->inset));
- Tcl_ListObjAppendElement(interp, l, NewDoubleObj(bbox.corner.y+wi->inset));
+ Tcl_ListObjAppendElement(interp, l, NewDoubleObj(bbox.orig.x));
+ Tcl_ListObjAppendElement(interp, l, NewDoubleObj(bbox.orig.y));
+ Tcl_ListObjAppendElement(interp, l, NewDoubleObj(bbox.corner.x));
+ Tcl_ListObjAppendElement(interp, l, NewDoubleObj(bbox.corner.y));
}
}
break;
@@ -2846,7 +2951,14 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
}
ITEM.RemoveItem(item);
ITEM.InsertItem(item, grp, ZN_NO_ITEM, True);
- ITEM.Invalidate(item, ZN_COORDS_FLAG);
+ /*
+ * The item can be a group in which case we must
+ * use the ZN_TRANSFO_FLAG to force an update of
+ * the children. In all other case ZN_COORDS_FLAG
+ * is enough.
+ */
+ ITEM.Invalidate(item,
+ item->class==ZnGroup?ZN_TRANSFO_FLAG:ZN_COORDS_FLAG);
if (adjust) {
ITEM.SetTransfo(item, this_one);
}
@@ -3514,7 +3626,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
if ((result == ZN_ERROR) || (item == ZN_NO_ITEM)) {
goto error;
}
- l = NewBooleanObj(item->class->num_parts!=0);
+ l = Tcl_NewIntObj(item->class->num_parts);
Tcl_SetObjResult(interp, l);
}
break;
@@ -3910,13 +4022,6 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
}
l = Tcl_GetObjResult(interp);
for (i = 0; i < num_points; i++, p++) {
- /*
- * Need to adjust for the border.
- */
- if (argc != 5) {
- p->x -= wi->inset;
- p->y -= wi->inset;
- }
ZnTransformPoint(this_one, p, &xp);
/*printf("p->x=%g, p->y=%g, xp.x=%g, xp.y=%g\n", p->x, p->y, xp.x, xp.y);*/
Tcl_ListObjAppendElement(interp, l, NewDoubleObj(xp.x));
@@ -4107,8 +4212,6 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
if (Tcl_GetDoubleFromObj(interp, args[4], &p.y) == ZN_ERROR) {
goto error;
}
- p.x -= wi->inset;
- p.y -= wi->inset;
item->class->PickVertex(item, &p, &contour, &vertex, &o_vertex);
l = Tcl_GetObjResult(interp);
Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(contour));
@@ -4205,11 +4308,11 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */
#else
(char **) args, (char *) wi, flags|TK_CONFIG_OBJS) != TCL_OK) {
#endif
- return ZN_ERROR;
+ return TCL_ERROR;
}
if (!init) {
if (wi->render != render) {
- ZnWarning("It is not possible to change the -render option after widget creation.");
+ ZnWarning("It is not possible to change the -render option after widget creation.\n");
}
wi->render = render;
}
@@ -4220,22 +4323,16 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */
if (wi->pick_aperture < 0) {
wi->pick_aperture = 0;
}
- if (CONFIG_PROBE(FORE_COLOR_SPEC) || !wi->fore_gradient) {
- /*
- * Update the default gradient.
- */
- if (wi->fore_gradient) {
- ZnFreeGradient(wi->fore_gradient);
- }
- wi->fore_gradient = ZnGetGradient(wi->interp, wi->win,
- ZnNameOfColor(wi->fore_color));
- }
if (CONFIG_PROBE(BACK_COLOR_SPEC) || !wi->relief_grad) {
- Tk_SetWindowBackground(wi->win, ZnPixel(wi->back_color));
+ XColor *color;
+ int alpha;
+ color = ZnGetGradientColor(wi->back_color, 0, &alpha);
+ Tk_SetWindowBackground(wi->win, ZnPixel(color));
if (wi->relief_grad) {
ZnFreeGradient(wi->relief_grad);
}
- wi->relief_grad = ZnGetReliefGradient(interp, wi->win, ZnNameOfColor(wi->back_color));
+ wi->relief_grad = ZnGetReliefGradient(interp, wi->win,
+ ZnNameOfColor(color), alpha);
}
if (CONFIG_PROBE(BACK_COLOR_SPEC) || CONFIG_PROBE(LIGHT_ANGLE_SPEC)) {
bbox.orig.x = bbox.orig.y = 0;
@@ -4248,15 +4345,6 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */
ZnNeedRedisplay(wi);
}
- /*
- * Update the items in the case borderwidth changed. This change
- * results in a change of the window size which might not be
- * acknowledged by the geometry manager. In this case the actual
- * area available to display items and the global transform are
- * modified.
- * If the changes in geometry are actually performed the code below
- * might be a duplicate effort (done in Event).
- */
wi->inset = wi->border_width + wi->highlight_width;
if (CONFIG_PROBE(BORDER_WIDTH_SPEC) ||
CONFIG_PROBE(HIGHLIGHT_THICKNESS_SPEC)) {
@@ -4264,8 +4352,6 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */
bbox.corner.x = wi->width;
bbox.corner.y = wi->height;
ITEM_P.Damage(wi, &bbox);
- ITEM_P.ResetTransformStack(wi);
- ITEM.Invalidate(wi->top_group, ZN_TRANSFO_FLAG);
}
if (CONFIG_PROBE(SPEED_VECTOR_LENGTH_SPEC) ||
CONFIG_PROBE(MANAGE_HISTORY_SPEC) ||
@@ -4282,8 +4368,7 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */
if (CONFIG_PROBE(WIDTH_SPEC) || CONFIG_PROBE(HEIGHT_SPEC) ||
CONFIG_PROBE(BORDER_WIDTH_SPEC) ||
CONFIG_PROBE(HIGHLIGHT_THICKNESS_SPEC) || !wi->realized) {
- Tk_GeometryRequest(wi->win, wi->opt_width + 2*wi->inset,
- wi->opt_height + 2*wi->inset);
+ Tk_GeometryRequest(wi->win, wi->opt_width, wi->opt_height);
}
if (CONFIG_PROBE(TILE_SPEC)) {
@@ -4463,6 +4548,8 @@ Event(ClientData client_data, /* Information about widget. */
printf(" Moteur de rendu : %s, ", (char *) glGetString(GL_RENDERER));
printf(" Fabriquant : %s\n", (char *) glGetString(GL_VENDOR));
printf(" Extensions présentes : %s\n", (char *) glGetString(GL_EXTENSIONS));
+ printf("Max antialiased line width: %g\n", wi->max_line_width);
+ printf("Max antialiased point size: %g\n", wi->max_point_width);
#endif
#endif
}
@@ -4501,8 +4588,8 @@ Event(ClientData client_data, /* Information about widget. */
ZnBBox bbox;
ZnDim width, height;
- bbox.orig.x = (((XExposeEvent*) event)->x - wi->inset);
- bbox.orig.y = (((XExposeEvent*) event)->y - wi->inset);
+ bbox.orig.x = (((XExposeEvent*) event)->x);
+ bbox.orig.y = (((XExposeEvent*) event)->y);
width = ((XExposeEvent*) event)->width;
height = ((XExposeEvent*) event)->height;
if (bbox.orig.x < 0) {
@@ -4540,10 +4627,8 @@ Event(ClientData client_data, /* Information about widget. */
ZnDim int_width, int_height;
ZnBBox bbox;
- /* w = ((XConfigureEvent*) event)->width-2*wi->inset;
- h = ((XConfigureEvent*) event)->height-2*wi->inset;*/
- int_width = Tk_Width(wi->win)-2*wi->inset;
- int_height = Tk_Height(wi->win)-2*wi->inset;
+ int_width = Tk_Width(wi->win);
+ int_height = Tk_Height(wi->win);
if ((wi->width != int_width) || (wi->height != int_height)) {
bbox.orig.x = bbox.orig.y = 0;
@@ -4858,8 +4943,8 @@ PickCurrentItem(WidgetInfo *wi,
ZnPoint p;
ZnReal dist;
- p.x = wi->pick_event.xcrossing.x-wi->inset;
- p.y = wi->pick_event.xcrossing.y-wi->inset;
+ p.x = wi->pick_event.xcrossing.x;
+ p.y = wi->pick_event.xcrossing.y;
dist = wi->top_group->class->Pick(wi->top_group, &p, NULL, wi->pick_aperture,
&wi->new_item, &wi->new_part);
if (dist != 0.0) {
@@ -5352,7 +5437,7 @@ Destroy(char *mem_ptr) /* Info about the widget. */
Tk_FreeImage(wi->tile);
wi->tile = ZnUnspecifiedImage;
}
-
+
/* Free the double buffer pixmap/image */
if (wi->draw_buffer) {
XFreePixmap(wi->dpy, wi->draw_buffer);
@@ -5366,8 +5451,14 @@ Destroy(char *mem_ptr) /* Info about the widget. */
}
#endif
- if (wi->fore_gradient) {
- ZnFreeGradient(wi->fore_gradient);
+ if (wi->fore_color) {
+ ZnFreeGradient(wi->fore_color);
+ }
+ if (wi->back_color) {
+ ZnFreeGradient(wi->back_color);
+ }
+ if (wi->relief_grad) {
+ ZnFreeGradient(wi->relief_grad);
}
Tcl_DeleteTimerHandler(wi->blink_handler);
@@ -5386,11 +5477,9 @@ Destroy(char *mem_ptr) /* Info about the widget. */
#endif
ZnListFree(wi->work_xpts);
- ZnFreeGradient(wi->relief_grad);
-
FreeChrono(wi->total_draw_chrono);
FreeChrono(wi->this_draw_chrono);
-
+
ZnFree(wi);
/*printf("Destroy ending\n");*/
}