From ef404bb78ca959bd623d97366158e659f14daaef Mon Sep 17 00:00:00 2001 From: lecoanet Date: Thu, 11 Apr 2002 09:40:35 +0000 Subject: Int�gration de ZnNeedRedisplay dans ZnDamage. -render n'est plus un bool�en: il a trois �tats: 0 pour le rendu X, 1 pour le rendu GL direct (si possible), 2 pour le rendu GL indirect. Toutes les commandes acceptant un param�tre field optionnel comprennent un field index "" comme �tant une absence de param�tre: aucune erreur n'est g�n�r�e et tout se passe comme si le param�tre n'avait pas �t� sp�cifi�. Les commandes 'focus' et 'select item' retournent une liste (item, field) ou "" si pas d'item. La pr�sence de field est garantie (liste de longueur 2) mais peut �tre "", se qui veut dire pas de field. On peut directement utiliser le r�sultat de ces commandes comme param�tres pour les commandes prennant un couple item, field. La commande currentpart prend un param�tre bool�en optionnel qui sp�cifie si elle doit reporter les parties priv�es de l'item ou seulement les fields (elle retourne "" si le pointeur est sur une partie priv�e). Lors d'un chagement de position de curseur il etait inutile de reprendre la g�om�trie de l'item concern�, seulement refaire l'affichage. --- generic/tkZinc.c | 151 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 94 insertions(+), 57 deletions(-) (limited to 'generic/tkZinc.c') diff --git a/generic/tkZinc.c b/generic/tkZinc.c index 01c1554..7706f43 100644 --- a/generic/tkZinc.c +++ b/generic/tkZinc.c @@ -197,7 +197,7 @@ static Tk_ConfigSpec config_specs[] = { "1", Tk_Offset(WidgetInfo, pick_aperture), 0}, {TK_CONFIG_CUSTOM, "-relief", "relief", "Relief", "flat", Tk_Offset(WidgetInfo, relief), 0, &reliefOption}, - {TK_CONFIG_BOOLEAN, "-render", "render", "Render", + {TK_CONFIG_INT, "-render", "render", "Render", "0", Tk_Offset(WidgetInfo, render), 0}, {TK_CONFIG_BOOLEAN, "-reshape", "reshape", "Reshape", "1", Tk_Offset(WidgetInfo, reshape), 0}, @@ -494,7 +494,7 @@ ZincObjCmd(ClientData client_data, /* Main window associated with int minor_op; if (glXQueryVersion(wi->dpy, &major_op, &minor_op)) { if ((major_op == 1) && (minor_op >= 1)) { -#if 1 +#if GLX_PRINT_CONFIG if (wi->render) { printf("GLX version %d.%d\n", major_op, minor_op); } @@ -514,7 +514,7 @@ ZincObjCmd(ClientData client_data, /* Main window associated with wi->has_x_input = XQueryExtension(wi->dpy, "XInputExtension", &major_op, &first_evt, &first_err); wi->reshape = wi->full_reshape = True; - wi->render = False; + wi->render = 0; wi->real_top = None; #ifdef PTK @@ -656,16 +656,19 @@ ZincObjCmd(ClientData client_data, /* Main window associated with /*GLX_ALPHA_SIZE, 8,*/ None }; - wi->gl_visual = glXChooseVisual(wi->dpy, XScreenNumberOfScreen(wi->screen), attribs); + wi->gl_visual = glXChooseVisual(wi->dpy, + XScreenNumberOfScreen(wi->screen), + attribs); if (!wi->gl_visual) { printf("No glx visual\n"); - wi->render = False; + wi->render = 0; } else { - wi->gl_context = glXCreateContext(wi->dpy, wi->gl_visual, NULL, True); + wi->gl_context = glXCreateContext(wi->dpy, wi->gl_visual, + NULL, wi->render==1); if (!wi->gl_context) { printf("No glx context\n"); - wi->render = False; + wi->render = 0; } else { #ifdef GLX_PRINT_CONFIG @@ -3057,11 +3060,19 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */ */ case ZN_W_CURRENTPART: { - if (argc != 2) { - Tcl_WrongNumArgs(interp, 1, args, "currentpart"); + ZnBool only_fields = False; + if ((argc != 2) && (argc != 3)) { + Tcl_WrongNumArgs(interp, 1, args, "currentpart ?onlyFields?"); goto error; } - if ((wi->current_item != ZN_NO_ITEM) && (wi->current_item->class->Part != NULL)) { + if (argc == 3) { + if (Tcl_GetBooleanFromObj(interp, args[2], &only_fields) != ZN_OK) { + goto error; + } + } + if ((wi->current_item != ZN_NO_ITEM) && + (wi->current_item->class->Part != NULL) && + ((wi->current_part >= 0) || !only_fields)) { l = NULL; wi->current_item->class->Part(wi->current_item, &l, &wi->current_part); Tcl_SetObjResult(interp, l); @@ -3083,10 +3094,13 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */ } if (argc == 5) { if (Tcl_GetIntFromObj(interp, args[3], &field) != ZN_OK) { - Tcl_AppendResult(interp, "invalid field index \"", - Tcl_GetString(args[3]), - "\", should be a positive integer", NULL); - goto error; + field = ZN_NO_PART; + if (Tcl_GetString(args[3])[0] != 0) { + Tcl_AppendResult(interp, "invalid field index \"", + Tcl_GetString(args[3]), + "\", should be a positive integer", NULL); + goto error; + } } argc--; args++; @@ -3105,7 +3119,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */ (*item->class->Cursor)(item, field, index); if ((item == wi->focus_item) && (field == wi->focus_field) && wi->text_info.cursor_on) { - ITEM.Invalidate(item, ZN_COORDS_FLAG); + ITEM.Invalidate(item, ZN_DRAW_FLAG); } } } @@ -3128,10 +3142,13 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */ } if (argc == 6) { if (Tcl_GetIntFromObj(interp, args[3], &field) != ZN_OK) { - Tcl_AppendResult(interp, "invalid field index \"", - Tcl_GetString(args[3]), - "\", should be a positive integer", NULL); - goto error; + field = ZN_NO_PART; + if (Tcl_GetString(args[3])[0] != 0) { + Tcl_AppendResult(interp, "invalid field index \"", + Tcl_GetString(args[3]), + "\", should be a positive integer", NULL); + goto error; + } } argc--; args++; @@ -3172,10 +3189,10 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */ if (ti->sel_last >= first) { ti->sel_last -= count; if (ti->sel_last < (first-1)) { - ti->sel_last = (first-1); + ti->sel_last = first-1; } } - if (ti->sel_first > ti->sel_last) { + if (ti->sel_first >= ti->sel_last) { ti->sel_item = ZN_NO_ITEM; ti->sel_field = ZN_NO_PART; } @@ -3271,16 +3288,19 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */ goto error; } item = wi->focus_item; - field = wi->focus_field; if (argc == 2) { + field = wi->focus_field; if (item != ZN_NO_ITEM) { l = Tcl_GetObjResult(interp); Tcl_ListObjAppendElement(interp, l, NewLongObj(item->id)); if (field != ZN_NO_PART) { Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(field)); } + else { + Tcl_ListObjAppendElement(interp, l, NewStringObj("")); + } } - goto done; + break; } if ((item != ZN_NO_ITEM) && (item->class->Cursor != NULL) && (wi->got_focus)) { @@ -3289,19 +3309,21 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */ if (Tcl_GetString(args[2])[0] == 0) { wi->focus_item = ZN_NO_ITEM; wi->focus_field = ZN_NO_PART; - goto done; + break; } if (ZnItemWithTagOrId(wi, args[2], wi->top_group, True, &item, &search_var) == ZN_ERROR) { goto error; } - field = ZN_NO_PART; if (argc == 4) { if (Tcl_GetIntFromObj(interp, args[3], &field) != ZN_OK) { - Tcl_AppendResult(interp, "invalid field index \"", - Tcl_GetString(args[3]), - "\", should be a positive integer", NULL); - goto error; + field = ZN_NO_PART; + if (Tcl_GetString(args[3])[0] != 0) { + Tcl_AppendResult(interp, "invalid field index \"", + Tcl_GetString(args[3]), + "\", should be a positive integer", NULL); + goto error; + } } } wi->focus_item = item; @@ -3486,10 +3508,13 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */ } if (argc == 5) { if (Tcl_GetIntFromObj(interp, args[3], &field) != ZN_OK) { - Tcl_AppendResult(interp, "invalid field index \"", - Tcl_GetString(args[3]), - "\", should be a positive integer", NULL); - goto error; + field = ZN_NO_PART; + if (Tcl_GetString(args[3])[0] != 0) { + Tcl_AppendResult(interp, "invalid field index \"", + Tcl_GetString(args[3]), + "\", should be a positive integer", NULL); + goto error; + } } argc--; args++; @@ -3529,10 +3554,13 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */ } if (argc == 6) { if (Tcl_GetIntFromObj(interp, args[3], &field) != ZN_OK) { - Tcl_AppendResult(interp, "invalid field index \"", - Tcl_GetString(args[3]), - "\", should be a positive integer", NULL); - goto error; + field = ZN_NO_PART; + if (Tcl_GetString(args[3])[0] != 0) { + Tcl_AppendResult(interp, "invalid field index \"", + Tcl_GetString(args[3]), + "\", should be a positive integer", NULL); + goto error; + } } argc--; args++; @@ -3552,7 +3580,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */ /* * Inserting characters invalidates selection indices. */ - if ((ti->sel_item == item) && (ti->sel_field== field)) { + if ((ti->sel_item == item) && (ti->sel_field == field)) { int length = strlen(chars); if (ti->sel_first >= index) { ti->sel_first += length; @@ -3585,10 +3613,13 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */ } if (argc == 5) { if (Tcl_GetIntFromObj(interp, args[3], &field) != ZN_OK) { - Tcl_AppendResult(interp, "invalid field index \"", - Tcl_GetString(args[3]), - "\", should be a positive integer", NULL); - goto error; + field = ZN_NO_PART; + if (Tcl_GetString(args[3])[0] != 0) { + Tcl_AppendResult(interp, "invalid field index \"", + Tcl_GetString(args[3]), + "\", should be a positive integer", NULL); + goto error; + } } argc--; args++; @@ -3617,10 +3648,13 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */ } if ((argc > 3) && (Tcl_GetString(args[3])[0] != '-')) { if (Tcl_GetIntFromObj(interp, args[3], &field) != ZN_OK) { - Tcl_AppendResult(interp, "invalid field index \"", - Tcl_GetString(args[3]), - "\", should be a positive integer", NULL); - goto error; + field = ZN_NO_PART; + if (Tcl_GetString(args[3])[0] != 0) { + Tcl_AppendResult(interp, "invalid field index \"", + Tcl_GetString(args[3]), + "\", should be a positive integer", NULL); + goto error; + } } argc--; args++; @@ -3973,10 +4007,13 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */ if ((argc == 5) || (argc == 6)) { if (argc == 6) { if (Tcl_GetIntFromObj(interp, args[4], &field) != ZN_OK) { - Tcl_AppendResult(interp, "invalid field index \"", - Tcl_GetString(args[4]), - "\", should be a positive integer", NULL); - goto error; + field = ZN_NO_PART; + if (Tcl_GetString(args[4])[0] != 0) { + Tcl_AppendResult(interp, "invalid field index \"", + Tcl_GetString(args[4]), + "\", should be a positive integer", NULL); + goto error; + } } argc--; args++; @@ -4033,7 +4070,9 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */ if (ti->sel_field != ZN_NO_PART) { Tcl_ListObjAppendElement(interp, l, Tcl_NewIntObj(ti->sel_field)); } - Tcl_SetObjResult(interp, l); + else { + Tcl_ListObjAppendElement(interp, l, NewStringObj("")); + } } break; case ZN_SEL_TO: @@ -4409,7 +4448,6 @@ TileChange(ClientData client_data, bbox.corner.x = wi->width; bbox.corner.y = wi->height; ZnDamage(wi, &bbox); - ZnNeedRedisplay(wi); } @@ -4443,7 +4481,8 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */ #define CONFIG_PROBE(offset) (ISSET(config_specs[offset].specFlags, \ TK_CONFIG_OPTION_SPECIFIED)) ZnBBox bbox; - Bool render, init; + ZnBool init; + int render; init = wi->fore_color == NULL; render = wi->render; @@ -4484,7 +4523,6 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */ bbox.corner.x = wi->width; bbox.corner.y = wi->height; ZnDamage(wi, &bbox); - ZnNeedRedisplay(wi); } if (CONFIG_PROBE(RELIEF_SPEC)) { ZnNeedRedisplay(wi); @@ -4526,7 +4564,6 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */ bbox.corner.x = wi->width; bbox.corner.y = wi->height; ZnDamage(wi, &bbox); - ZnNeedRedisplay(wi); } /* @@ -4643,7 +4680,6 @@ Focus(WidgetInfo *wi, bbox.corner.x = Tk_Width(wi->win); bbox.corner.y = Tk_Height(wi->win); ZnDamage(wi, &bbox); - ZnNeedRedisplay(wi); } #endif } @@ -5326,7 +5362,6 @@ Bind(ClientData client_data, /* Information about widget. */ bbox.corner.x = Tk_Width(wi->win); bbox.corner.y = Tk_Height(wi->win); ZnDamage(wi, &bbox); - ZnNeedRedisplay(wi); } #endif @@ -5419,6 +5454,7 @@ SelectTo(Item item, ITEM.Invalidate(ti->sel_item, ZN_DRAW_FLAG); } ti->sel_item = item; + ti->sel_field = field; if ((ti->anchor_item != item) || (ti->anchor_field) != field) { ti->anchor_item = item; @@ -5664,6 +5700,7 @@ ZnDamage(WidgetInfo *wi, wi->damaged_area.orig.y = damage->orig.y; wi->damaged_area.corner.x = damage->corner.x; wi->damaged_area.corner.y = damage->corner.y; + ZnNeedRedisplay(wi); } else { wi->damaged_area.orig.x = MIN(wi->damaged_area.orig.x, damage->orig.x); -- cgit v1.1