Index: doc/ttk_image.n ================================================================== --- doc/ttk_image.n +++ doc/ttk_image.n @@ -77,17 +77,20 @@ based on the \fB\-border\fR option. The \fB\-border\fR divides the image into 9 regions: four fixed corners, top and left edges (which may be tiled horizontally), left and right edges (which may be tiled vertically), and the central area (which may be tiled in both directions). +.PP +An image element that is not meant to claim any space (for example when used +as a background image) should use \fB\-width 0\fR and \fB\-height 0\fR. .SH "EXAMPLE" .PP .CS set img1 [image create photo \-file button.png] set img2 [image create photo \-file button-pressed.png] set img3 [image create photo \-file button-active.png] -style element create Button.button image \e +ttk::style element create Button.button image \e [list $img1 pressed $img2 active $img3] \e \-border {2 4} \-sticky we .CE .SH "SEE ALSO" ttk::intro(n), ttk::style(n), ttk_vsapi(n), image(n), photo(n) Index: generic/ttk/ttkImage.c ================================================================== --- generic/ttk/ttkImage.c +++ generic/ttk/ttkImage.c @@ -247,11 +247,11 @@ */ typedef struct { /* ClientData for image elements */ Ttk_ImageSpec *imageSpec; /* Image(s) to use */ int minWidth; /* Minimum width; overrides image width */ - int minHeight; /* Minimum width; overrides image width */ + int minHeight; /* Minimum height; overrides image height */ Ttk_Sticky sticky; /* -stickiness specification */ Ttk_Padding border; /* Fixed border region */ Ttk_Padding padding; /* Internal padding */ #if TILE_07_COMPAT Index: generic/ttk/ttkTreeview.c ================================================================== --- generic/ttk/ttkTreeview.c +++ generic/ttk/ttkTreeview.c @@ -239,12 +239,12 @@ Tcl_Obj *data; } TreeColumn; static void InitColumn(TreeColumn *column) { - column->width = 200; - column->minWidth = 20; + column->width = atoi(DEF_COLWIDTH); + column->minWidth = atoi(DEF_MINWIDTH); column->stretch = 1; column->idObj = 0; column->anchorObj = 0; column->headingState = 0; Index: generic/ttk/ttkWidget.c ================================================================== --- generic/ttk/ttkWidget.c +++ generic/ttk/ttkWidget.c @@ -112,10 +112,23 @@ if (!(corePtr->flags & REDISPLAY_PENDING)) { Tcl_DoWhenIdle(DrawWidget, corePtr); corePtr->flags |= REDISPLAY_PENDING; } } + +/* + * WidgetWorldChanged -- + * Default Tk_ClassWorldChangedProc() for widgets. + * Invoked whenever fonts or other system resources are changed; + * recomputes geometry. + */ +static void WidgetWorldChanged(ClientData clientData) +{ + WidgetCore *corePtr = clientData; + SizeChanged(corePtr); + TtkRedisplayWidget(corePtr); +} /* TtkResizeWidget -- * Recompute widget size, schedule geometry propagation and redisplay. */ void TtkResizeWidget(WidgetCore *corePtr) @@ -122,12 +135,11 @@ { if (corePtr->flags & WIDGET_DESTROYED) { return; } - SizeChanged(corePtr); - TtkRedisplayWidget(corePtr); + WidgetWorldChanged(corePtr); } /* TtkWidgetChangeState -- * Set / clear the specified bits in the 'state' flag, */ @@ -307,39 +319,25 @@ break; case VirtualEvent: { const char *name = ((XVirtualEvent *)eventPtr)->name; if ((name != NULL) && !strcmp("ThemeChanged", name)) { (void)UpdateLayout(corePtr->interp, corePtr); - SizeChanged(corePtr); - TtkRedisplayWidget(corePtr); + WidgetWorldChanged(corePtr); } break; } default: /* can't happen... */ break; } } -/* - * WidgetWorldChanged -- - * Default Tk_ClassWorldChangedProc() for widgets. - * Invoked whenever fonts or other system resources are changed; - * recomputes geometry. - */ -static void WidgetWorldChanged(ClientData clientData) -{ - WidgetCore *corePtr = clientData; - SizeChanged(corePtr); - TtkRedisplayWidget(corePtr); -} - static Tk_ClassProcs widgetClassProcs = { sizeof(Tk_ClassProcs), /* size */ - WidgetWorldChanged, /* worldChangedProc */ - NULL, /* createProc */ - NULL /* modalProc */ + WidgetWorldChanged, /* worldChangedProc */ + NULL, /* createProc */ + NULL /* modalProc */ }; /* * TtkWidgetConstructorObjCmd -- * General-purpose widget constructor command implementation. Index: tests/ttk/treeview.test ================================================================== --- tests/ttk/treeview.test +++ tests/ttk/treeview.test @@ -920,7 +920,30 @@ lappend res [.tv column bar -width] [.tv column colA -width] \ [expr {[winfo width .tv] < $origTreeWidth}] } -cleanup { destroy .tv } -result {60 50 60 50 60 50 1} + +test treeview-bc602049ab "treeview with custom background does not change size when switching themes" -setup { + image create photo tvbg -data { + iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAnXAAAJ1wG + xbhe3AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAACJJREFUOI + 1jPLF9+38GKgImaho2auCogaMGjho4auBQMhAAyR0DXUEyypsAAAAASUVORK5CYII= + } + ttk::style theme create foo-bc602049ab -parent clam -settings { + ttk::style element create Treeview.field image tvbg -width 0 -height 0 + } + ttk::style theme use foo-bc602049ab + pack [ttk::treeview .tv] + update idletasks +} -body { + set g1 [winfo geometry .tv] + ttk::style theme use foo-bc602049ab + update idletasks + set g2 [winfo geometry .tv] + expr {$g1 eq $g2 ? 1 : "$g1 --> $g2"} +} -cleanup { + destroy .tv + image delete tvbg +} -result {1} tcltest::cleanupTests