diff options
Diffstat (limited to 'generic/tkZinc.c')
-rw-r--r-- | generic/tkZinc.c | 144 |
1 files changed, 94 insertions, 50 deletions
diff --git a/generic/tkZinc.c b/generic/tkZinc.c index 4232e96..3eecd3d 100644 --- a/generic/tkZinc.c +++ b/generic/tkZinc.c @@ -234,6 +234,8 @@ static Tk_ConfigSpec config_specs[] = { "1", Tk_Offset(ZnWInfo, track_manage_history), 0, NULL}, {TK_CONFIG_INT, "-trackmanagedhistorysize", "trackManagedHistorySize", "TrackManagedHistorySize", "6", Tk_Offset(ZnWInfo, track_managed_history_size), 0, NULL}, + {TK_CONFIG_CUSTOM, "-tracksymbol", "trackSymbol", "TrackSymbol", + "AtcSymbol15", Tk_Offset(ZnWInfo, track_symbol), TK_CONFIG_NULL_OK, &bitmapOption}, {TK_CONFIG_PIXELS, "-width", "width", "Width", "10c", Tk_Offset(ZnWInfo, opt_width), 0, NULL}, {TK_CONFIG_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand", @@ -289,14 +291,15 @@ static Tk_ConfigSpec config_specs[] = { #define TILE_SPEC 26 #define MANAGE_HISTORY_SPEC 27 #define MANAGED_HISTORY_SIZE_SPEC 28 -#define WIDTH_SPEC 29 -#define X_SCROLL_CMD_SPEC 30 -#define X_SCROLL_INCREMENT_SPEC 31 -#define Y_SCROLL_CMD_SPEC 32 -#define Y_SCROLL_INCREMENT_SPEC 33 -#define BBOXES_SPEC 34 -#define BBOXES_COLOR_SPEC 35 -#define LIGHT_ANGLE_SPEC 36 +#define TRACK_SYMBOL_SPEC 29 +#define WIDTH_SPEC 30 +#define X_SCROLL_CMD_SPEC 31 +#define X_SCROLL_INCREMENT_SPEC 32 +#define Y_SCROLL_CMD_SPEC 33 +#define Y_SCROLL_INCREMENT_SPEC 34 +#define BBOXES_SPEC 35 +#define BBOXES_COLOR_SPEC 36 +#define LIGHT_ANGLE_SPEC 37 static void CmdDeleted _ANSI_ARGS_((ClientData client_data)); @@ -450,25 +453,39 @@ ZnBitmapParse(ClientData client_data __unused, char *value = (char *) ovalue; #endif ZnWInfo *wi = (ZnWInfo*) widget_rec; + ZnBool is_bmap = True; prev_image = *image_ptr; if ((value != NULL) && (*value != '\0')) { - image = ZnGetBitmap(wi, value); - if (image == NULL) { + image = ZnGetImage(wi, value, NULL, NULL); + if ((image == ZnUnspecifiedImage) || + ! (is_bmap = ZnImageIsBitmap(image))) { + if (!is_bmap) { + ZnFreeImage(image, NULL, NULL); + } return TCL_ERROR; } if (prev_image != NULL) { - ZnFreeImage(prev_image); + ZnFreeImage(prev_image, NULL, NULL); } *image_ptr = image; } else if (prev_image != NULL) { - ZnFreeImage(prev_image); + ZnFreeImage(prev_image, NULL, NULL); *image_ptr = NULL; } + return TCL_OK; } +static void +ZnImageUpdate(void *client_data) +{ + ZnWInfo *wi = (ZnWInfo*) client_data; + + ZnDamageAll(wi); +} + static int ZnImageParse(ClientData client_data __unused, Tcl_Interp *interp __unused, @@ -488,17 +505,17 @@ ZnImageParse(ClientData client_data __unused, prev_image = *image_ptr; if ((value != NULL) && (*value != '\0')) { - image = ZnGetImage(wi, value); + image = ZnGetImage(wi, value, ZnImageUpdate, wi); if (image == NULL) { return TCL_ERROR; } if (prev_image != NULL) { - ZnFreeImage(prev_image); + ZnFreeImage(prev_image, ZnImageUpdate, wi); } *image_ptr = image; } else if (prev_image != NULL) { - ZnFreeImage(prev_image); + ZnFreeImage(prev_image, ZnImageUpdate, wi); *image_ptr = NULL; } return TCL_OK; @@ -707,7 +724,8 @@ ZincObjCmd(ClientData client_data, /* Main window associated with wi->gl_visual = NULL; # endif #endif - wi->map_distance_symbol = None; + wi->map_distance_symbol = ZnUnspecifiedImage; + wi->track_symbol = ZnUnspecifiedImage; wi->cursor = None; wi->hot_item = ZN_NO_ITEM; wi->hot_prev = ZN_NO_ITEM; @@ -943,7 +961,6 @@ ZincObjCmd(ClientData client_data, /* Main window associated with #else Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(tkwin), -1)); #endif - return TCL_OK; } @@ -2067,7 +2084,7 @@ LayoutItems(ZnWInfo *wi, /*ZnItem item;*/ #ifdef PTK static char *layout_cmd_strings[] = { -#else + #else static CONST char *layout_cmd_strings[] = { #endif "align", "grid", "position", "scale", "space", NULL @@ -2325,7 +2342,12 @@ UpdateScrollbars(ZnWInfo *wi) CLEAR(wi->flags, ZN_UPDATE_SCROLLBARS); if (wi->x_scroll_cmd != NULL) { fractions = ScrollFractions(x_origin, x_origin + width, scroll_xo, scroll_xc); +#ifdef PTK + /* Need some more work */ + result = LangDoCallback(interp, x_scroll_cmd, 0, 1, " %L", fractions); +#else result = Tcl_VarEval(interp, x_scroll_cmd, " ", Tcl_GetString(fractions), NULL); +#endif Tcl_DecrRefCount(fractions); if (result != TCL_OK) { Tcl_BackgroundError(interp); @@ -2336,7 +2358,12 @@ UpdateScrollbars(ZnWInfo *wi) if (y_scroll_cmd != NULL) { fractions = ScrollFractions(y_origin, y_origin + height, scroll_yo, scroll_yc); +#ifdef PTK + /* Need some more work */ + result = LangDoCallback(interp, y_scroll_cmd, 0, 1, " %L", fractions); +#else result = Tcl_VarEval(interp, y_scroll_cmd, " ", Tcl_GetString(fractions), NULL); +#endif Tcl_DecrRefCount(fractions); if (result != TCL_OK) { Tcl_BackgroundError(interp); @@ -5446,7 +5473,6 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */ { #define CONFIG_PROBE(offset) (ISSET(config_specs[offset].specFlags, \ TK_CONFIG_OPTION_SPECIFIED)) - ZnBBox bbox; ZnBool init; int render; @@ -5504,10 +5530,7 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */ } } if (CONFIG_PROBE(BACK_COLOR_SPEC) || CONFIG_PROBE(LIGHT_ANGLE_SPEC)) { - bbox.orig.x = bbox.orig.y = 0; - bbox.corner.x = wi->width; - bbox.corner.y = wi->height; - ZnDamage(wi, &bbox); + ZnDamageAll(wi); } if (CONFIG_PROBE(RELIEF_SPEC)) { ZnNeedRedisplay(wi); @@ -5516,10 +5539,7 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */ wi->inset = wi->border_width + wi->highlight_width; if (CONFIG_PROBE(BORDER_WIDTH_SPEC) || CONFIG_PROBE(HIGHLIGHT_THICKNESS_SPEC)) { - bbox.orig.x = bbox.orig.y = 0; - bbox.corner.x = wi->width; - bbox.corner.y = wi->height; - ZnDamage(wi, &bbox); + ZnDamageAll(wi); } if (CONFIG_PROBE(SPEED_VECTOR_LENGTH_SPEC) || CONFIG_PROBE(MANAGE_HISTORY_SPEC) || @@ -5529,6 +5549,10 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */ if (CONFIG_PROBE(MAP_DISTANCE_SYMBOL_SPEC)) { ZnITEM.InvalidateItems(wi->top_group, ZnMap); } + if (CONFIG_PROBE(TRACK_SYMBOL_SPEC)) { + ZnITEM.InvalidateItems(wi->top_group, ZnTrack); + ZnITEM.InvalidateItems(wi->top_group, ZnWayPoint); + } /* * Request the new geometry. @@ -5540,10 +5564,7 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */ } if (CONFIG_PROBE(TILE_SPEC)) { - bbox.orig.x = bbox.orig.y = 0; - bbox.corner.x = wi->width; - bbox.corner.y = wi->height; - ZnDamage(wi, &bbox); + ZnDamageAll(wi); } /* @@ -5699,12 +5720,7 @@ Focus(ZnWInfo *wi, } #ifdef GL_DAMAGE if (wi->render) { - ZnBBox bbox; - - bbox.orig.x = bbox.orig.y = 0; - bbox.corner.x = Tk_Width(wi->win); - bbox.corner.y = Tk_Height(wi->win); - ZnDamage(wi, &bbox); + ZnDamageAll(wi); } #endif } @@ -5759,7 +5775,7 @@ Event(ClientData client_data, /* Information about widget. */ if (!wi->font_tfi) { wi->font_tfi = ZnGetTexFont(wi, wi->font); } - if (wi->map_font_tfi) { + if (!wi->map_font_tfi) { wi->map_font_tfi = ZnGetTexFont(wi, wi->map_text_font); } @@ -5776,6 +5792,8 @@ Event(ClientData client_data, /* Information about widget. */ wi->max_line_width); fprintf(stderr, "Max antialiased point size: %g\n", wi->max_point_width); + fprintf(stderr, "Max texture size: %d\n", + wi->max_tex_size); } ZnGLRelease(wi); @@ -5916,7 +5934,11 @@ Event(ClientData client_data, /* Information about widget. */ if (wi->win != NULL) { wi->win = NULL; CLEAR(wi->flags, ZN_REALIZED); +#ifdef PTK + Lang_DeleteWidget(wi->interp, wi->cmd); +#else Tcl_DeleteCommandFromToken(wi->interp, wi->cmd); +#endif } if (ISSET(wi->flags, ZN_UPDATE_PENDING)) { Tcl_CancelIdleCall(Redisplay, (ClientData) wi); @@ -6424,12 +6446,7 @@ Bind(ClientData client_data, /* Information about widget. */ * enough to make the bug unnoticed. */ if (wi->render) { - ZnBBox bbox; - - bbox.orig.x = bbox.orig.y = 0; - bbox.corner.x = Tk_Width(wi->win); - bbox.corner.y = Tk_Height(wi->win); - ZnDamage(wi, &bbox); + ZnDamageAll(wi); } #endif @@ -6679,9 +6696,11 @@ Destroy(char *mem_ptr) /* Info about the widget. */ #ifdef GL if (wi->font_tfi) { ZnFreeTexFont(wi->font_tfi); + wi->font_tfi = NULL; } if (wi->map_font_tfi) { ZnFreeTexFont(wi->map_font_tfi); + wi->map_font_tfi = NULL; } #endif /* @@ -6695,6 +6714,7 @@ Destroy(char *mem_ptr) /* Info about the widget. */ for (num = 0; num < ZN_NUM_ALPHA_STEPS; num++) { if (wi->alpha_stipples[num] != None) { Tk_FreeBitmap(wi->dpy, wi->alpha_stipples[num]); + wi->alpha_stipples[num] = None; } } @@ -6718,10 +6738,20 @@ Destroy(char *mem_ptr) /* Info about the widget. */ /* Free the tile */ if (wi->tile != ZnUnspecifiedImage) { - ZnFreeImage(wi->tile); + ZnFreeImage(wi->tile, ZnImageUpdate, wi); wi->tile = ZnUnspecifiedImage; } + /* Free the symbols */ + if (wi->map_distance_symbol != ZnUnspecifiedImage) { + ZnFreeImage(wi->map_distance_symbol, NULL, NULL); + wi->map_distance_symbol = ZnUnspecifiedImage; + } + if (wi->track_symbol != ZnUnspecifiedImage) { + ZnFreeImage(wi->track_symbol, NULL, NULL); + wi->track_symbol = ZnUnspecifiedImage; + } + /* Free the double buffer pixmap/image */ if (wi->draw_buffer) { Tk_FreePixmap(wi->dpy, wi->draw_buffer); @@ -6815,6 +6845,17 @@ ZnDamage(ZnWInfo *wi, wi->damaged_area.corner.y);*/ } +void +ZnDamageAll(ZnWInfo *wi) +{ + ZnBBox bbox; + + bbox.orig.x = bbox.orig.y = 0; + bbox.corner.x = Tk_Width(wi->win); + bbox.corner.y = Tk_Height(wi->win); + ZnDamage(wi, &bbox); +} + static void ClampDamageArea(ZnWInfo *wi) { @@ -7283,7 +7324,7 @@ InitZinc(Tcl_Interp *interp) { if (inited) { return; } - + /* * Add the specific bitmaps. */ @@ -7348,6 +7389,13 @@ InitZinc(Tcl_Interp *interp) { dot_uid = Tk_GetUid("."); star_uid = Tk_GetUid("*"); + /* + * Initialise Overlap manager library. + */ +#ifdef OM + OmInit(); +#endif + inited = True; } @@ -7401,10 +7449,6 @@ Tkzinc_Init(Tcl_Interp *interp) /* Used for error reporting. */ Tcl_CreateObjCommand(interp, "videomap", ZnVideomapObjCmd, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); - /* - * Initialise Overlap manager library. - */ - OmInit(); #ifndef PTK if (Tcl_PkgProvide(interp, "Tkzinc", VERSION) == TCL_ERROR) { |