From fac1e95139d80426a974579b0f6c6c46f20107db Mon Sep 17 00:00:00 2001 From: lecoanet Date: Thu, 29 Nov 2001 10:31:41 +0000 Subject: Transfer� le dessin du relief et du highlight de focus dans Item.c (Repair). Supprim� les ressources pour la bordure 3D remplac�e par un gradient relief. --- generic/tkZinc.c | 135 +++++++++++++++++++------------------------------------ 1 file changed, 45 insertions(+), 90 deletions(-) (limited to 'generic/tkZinc.c') diff --git a/generic/tkZinc.c b/generic/tkZinc.c index 712b646..7b1affb 100644 --- a/generic/tkZinc.c +++ b/generic/tkZinc.c @@ -64,10 +64,9 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ " #include #ifdef GLX #include +#include #endif -/*#define PRINT_CONFIG*/ - #if 0 typedef struct TagSearch { WidgetInfo *wi; @@ -147,8 +146,8 @@ 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_BORDER, "-backcolor", "backColor", "BackColor", - "#c3c3c3", Tk_Offset(WidgetInfo, bg_border), 0}, + {TK_CONFIG_COLOR, "-backcolor", "backColor", "BackColor", + "#c3c3c3", Tk_Offset(WidgetInfo, back_color), 0}, {TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor", "", Tk_Offset(WidgetInfo, cursor), TK_CONFIG_NULL_OK}, {TK_CONFIG_FONT, "-font", "font", "Font", @@ -395,7 +394,9 @@ ZincObjCmd(ClientData client_data, /* Main window associated with if (glXQueryVersion(wi->dpy, &major_op, &minor_op)) { if ((major_op == 1) && (minor_op >= 1)) { #if 1 - printf("GLX version %d.%d\n", major_op, minor_op); + if (wi->render) { + printf("GLX version %d.%d\n", major_op, minor_op); + } #endif wi->has_glx = True; } @@ -426,9 +427,9 @@ ZincObjCmd(ClientData client_data, /* Main window associated with wi->binding_table = 0; wi->realized = False; wi->update_pending = 0; - wi->bg_border = NULL; - wi->back_color = NULL; /* back_color will be initialized by Configure */ wi->fore_color = NULL; + wi->back_color = NULL; + wi->relief_grad = NULL; wi->bbox_color = NULL; wi->draw_bboxes = 0; wi->light_angle = 120; @@ -540,7 +541,7 @@ ZincObjCmd(ClientData client_data, /* Main window associated with if (wi->render) { #ifdef GLX if (wi->has_glx) { -#ifdef PRINT_CONFIG +#ifdef GLX_PRINT_CONFIG int val; #endif int attribs[] = { GLX_RGBA, @@ -562,7 +563,7 @@ ZincObjCmd(ClientData client_data, /* Main window associated with wi->render = False; } else { -#ifdef PRINT_CONFIG +#ifdef GLX_PRINT_CONFIG printf(" Visual : 0x%x, ", (int) wi->gl_visual->visualid); glXGetConfig(wi->dpy, wi->gl_visual, GLX_RGBA, &val); printf("RGBA : %d, ", val); @@ -2180,7 +2181,7 @@ Contour(WidgetInfo *wi, if (!shape->class->GetContours) { ZnTriStrip tristrip; /* - * If there is no GetContours mrthod try to use + * If there is no GetContours method try to use * the GetClipVertices. It works only for simple * shapes (i.e tose returning a bounding box). */ @@ -4211,9 +4212,13 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */ wi->pick_aperture = 0; } - wi->back_color = Tk_3DBorderColor(wi->bg_border); - Tk_SetBackgroundFromBorder(wi->win, wi->bg_border); - + if (CONFIG_PROBE(BACK_COLOR_SPEC) || !wi->relief_grad) { + Tk_SetWindowBackground(wi->win, ZnPixel(wi->back_color)); + if (wi->relief_grad) { + ZnFreeGradient(wi->relief_grad); + } + wi->relief_grad = ZnGetReliefGradient(interp, wi->win, ZnNameOfColor(wi->back_color)); + } if (CONFIG_PROBE(BACK_COLOR_SPEC) || CONFIG_PROBE(LIGHT_ANGLE_SPEC)) { bbox.orig.x = bbox.orig.y = 0; bbox.corner.x = wi->width; @@ -4376,6 +4381,10 @@ Focus(WidgetInfo *wi, if (wi->text_info.focus_item != ZN_NO_ITEM) { ITEM.Invalidate(wi->text_info.focus_item, ZN_COORDS_FLAG); } + /*printf("focus %s\n", got_focus ? "in" : "out");*/ + if (wi->highlight_width > 0) { + ZnNeedRedisplay(wi); + } } @@ -4403,7 +4412,7 @@ Event(ClientData client_data, /* Information about widget. */ WidgetInfo *wi = (WidgetInfo *) client_data; /*printf("=============== DEBUT %s EVENT ==================\n", - event->type == MapNotify ? "MAP": + event->type == MapNotify ? "MAP": event->type == Expose? "EXPOSE" : event->type == ConfigureNotify ? "CONFIGURE" : event->type == DestroyNotify ? "DESTROY" : @@ -4411,8 +4420,8 @@ Event(ClientData client_data, /* Information about widget. */ if (event->type == MapNotify) { if (!wi->gc) { wi->realized = True; -#ifdef GLX if (wi->render) { +#ifdef GLX GLfloat r[2]; glXMakeCurrent(wi->dpy, ZnWindowId(wi->win), wi->gl_context); @@ -4422,14 +4431,15 @@ Event(ClientData client_data, /* Information about widget. */ /*glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, r);*/ glGetFloatv(GL_SMOOTH_POINT_SIZE_RANGE, r); wi->max_point_width = r[1]; -#ifdef PRINT_CONFIG +#ifdef GLX_PRINT_CONFIG printf("OpenGL version %s\n", (char *) glGetString(GL_VERSION)); 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)); -#endif - } #endif +#endif + } + /* * Get the work GC and suppress GraphicExpose * and NoExpose events reception. @@ -4463,7 +4473,7 @@ Event(ClientData client_data, /* Information about widget. */ else if (event->type == Expose) { ZnBBox bbox; ZnDim width, height; - + bbox.orig.x = (((XExposeEvent*) event)->x - wi->inset); bbox.orig.y = (((XExposeEvent*) event)->y - wi->inset); width = ((XExposeEvent*) event)->width; @@ -4500,21 +4510,20 @@ Event(ClientData client_data, /* Information about widget. */ * need such change, it can bind a handler on . */ else if (event->type == ConfigureNotify) { - ZnDim w, h; + ZnDim int_width, int_height; ZnBBox bbox; - + /* w = ((XConfigureEvent*) event)->width-2*wi->inset; h = ((XConfigureEvent*) event)->height-2*wi->inset;*/ - w = Tk_Width(wi->win)-2*wi->inset; - h = Tk_Height(wi->win)-2*wi->inset; + int_width = Tk_Width(wi->win)-2*wi->inset; + int_height = Tk_Height(wi->win)-2*wi->inset; - if ((wi->width != w) || (wi->height != h)) { - /*printf("reallocating double buffer\n");*/ + if ((wi->width != int_width) || (wi->height != int_height)) { bbox.orig.x = bbox.orig.y = 0; - bbox.corner.x = MAX(wi->width, w); - bbox.corner.y = MAX(wi->height, h); - wi->opt_width = wi->width = w; - wi->opt_height = wi->height = h; + bbox.corner.x = MAX(wi->width, int_width); + bbox.corner.y = MAX(wi->height, int_height); + wi->opt_width = wi->width = int_width; + wi->opt_height = wi->height = int_height; ITEM_P.ResetTransformStack(wi); ITEM_P.Damage(wi, &bbox); @@ -4524,9 +4533,10 @@ Event(ClientData client_data, /* Information about widget. */ * Reallocate the double buffer pixmap/image. */ if (!wi->render) { + /*printf("reallocating double buffer\n");*/ XFreePixmap(wi->dpy, wi->draw_buffer); wi->draw_buffer = XCreatePixmap(wi->dpy, RootWindowOfScreen(wi->screen), - wi->width, wi->height, + int_width, int_height, DefaultDepthOfScreen(wi->screen)); } } @@ -5325,6 +5335,8 @@ Destroy(char *mem_ptr) /* Info about the widget. */ ZnListFree(wi->work_doubles); #endif ZnListFree(wi->work_xpts); + + ZnFreeGradient(wi->relief_grad); FreeChrono(wi->total_draw_chrono); FreeChrono(wi->this_draw_chrono); @@ -5356,9 +5368,6 @@ static void Redisplay(ClientData client_data) /* Information about the widget. */ { WidgetInfo *wi = (WidgetInfo *) client_data; - ZnBBox merge; - Tk_Window tkwin; - XRectangle r; wi->update_pending = 0; if (!wi->realized || !Tk_IsMapped(wi->win)) { @@ -5387,6 +5396,8 @@ Redisplay(ClientData client_data) /* Information about the widget. */ * for Tcl_Preserve/Tcl_Release. */ if (ISSET(wi->events_flags, INTERNAL_NEED_REPICK)) { + Tk_Window tkwin; + Tcl_Preserve((ClientData) wi); CLEAR(wi->events_flags, INTERNAL_NEED_REPICK); PickCurrentItem(wi, &wi->pick_event); @@ -5402,43 +5413,10 @@ Redisplay(ClientData client_data) /* Information about the widget. */ ISSET(wi->events_flags, INTERNAL_NEED_REPICK)); /* - * Merge the repaired area with the exposed area. - */ - ResetBBox(&merge); - CopyBBox(&wi->damaged_area, &merge); - wi->damaged_area_w = wi->damaged_area.corner.x-wi->damaged_area.orig.x; - wi->damaged_area_h = wi->damaged_area.corner.y-wi->damaged_area.orig.y; - AddBBoxToBBox(&merge, &wi->exposed_area); - /* * Repair the scene where it is no longer up to date, * then send the merged area back to the screen. */ - if (!IsEmptyBBox(&merge)) { - if (wi->render || !IsEmptyBBox(&wi->damaged_area)) { - ITEM_P.Repair(wi); - } - - BBox2XRect(&merge, &r); - if (wi->render) { -#ifdef GLX - /* Switch the GL buffers. */ - glXSwapBuffers(wi->dpy, ZnWindowId(wi->win)); - /* - * Wait the end of GL update if we need to do some X - * drawing (specifically borders and highlight). - */ - if ((wi->border_width > 0) || - (wi->highlight_width > 0)) { - glXWaitGL(); - } -#endif - } - else { - 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); - } - } + ITEM_P.Repair(wi); /* * Reset the exposed & damaged areas. @@ -5446,29 +5424,6 @@ Redisplay(ClientData client_data) /* Information about the widget. */ ResetBBox(&wi->exposed_area); ResetBBox(&wi->damaged_area); - /* - * Redraw the borders. - */ - if (wi->border_width > 0) { - /*printf("win size %d %d\n", Tk_Width(wi->win), Tk_Height(wi->win));*/ - Tk_Draw3DRectangle(wi->win, ZnWindowId(wi->win), wi->bg_border, - wi->highlight_width, wi->highlight_width, - Tk_Width(wi->win) - 2*wi->highlight_width, - Tk_Height(wi->win) - 2*wi->highlight_width, - wi->border_width, wi->relief); - - } - if (wi->highlight_width > 0) { - GC gc; - if (wi->text_info.got_focus) { - gc = Tk_GCForColor(wi->highlight_color, Tk_WindowId(wi->win)); - } - else { - gc = Tk_GCForColor(wi->highlight_bg_color, Tk_WindowId(wi->win)); - } - Tk_DrawFocusHighlight(wi->win, gc, wi->highlight_width, Tk_WindowId(wi->win)); - } - if (wi->monitoring) { XStopChrono(wi->total_draw_chrono, wi->dpy, ZnWindowId(wi->win)); XStopChrono(wi->this_draw_chrono, wi->dpy, ZnWindowId(wi->win)); -- cgit v1.1