Tk Source Code

Changes On Branch bug-bc602049ab
Login
EuroTcl/OpenACS 11 - 12 JULY 2024, VIENNA

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch bug-bc602049ab Excluding Merge-Ins

This is equivalent to a diff from 59025499 to 8e549bfe

2022-09-04
13:55
Fix [bc602049ab]: Treeview with custom background expands when switching themes. Thanks to Peter Spjuth. check-in: e4182be9 user: fvogel tags: core-8-6-branch
2022-08-30
10:38
Fix [1088807fff]: Aqua: canvPs-3.1 panic. This was fixed when [424773a00c] got fixed, now just remove the constraint in canvPS-3.1. Thanks to Christopher Chavez. check-in: 30d9e590 user: fvogel tags: core-8-6-branch
2022-08-29
20:52
Document that image elements used as background images should use -width 0 and -height 0. Closed-Leaf check-in: 8e549bfe user: fvogel tags: bug-bc602049ab
20:23
Give -width 0 -height 0 to the image element created, so that it does not take any space in the treeview size computation. check-in: 54804a28 user: fvogel tags: bug-bc602049ab
18:58
Fix [1088807fff]: Aqua: canvPs-3.1 panic. This was fixed when [424773a00c] got fixed, now just remove the constraint in canvPS-3.1. Thanks to Christopher Chavez. Closed-Leaf check-in: 5d1a8f5e user: fvogel tags: bug-1088807fff
2022-08-26
07:26
Let's see if this really fixes [ead70921a9], or that - maybe - it's better to do something different about it (might be better limit the different approach in 8.7+). Addendum: this commit doesn't work! Closed-Leaf check-in: 67a20e4e user: jan.nijtmans tags: bug-ead70921a9
2022-08-25
20:38
Fix [bc602049ab]: Treeview with custom background expands when switching themes. check-in: d507fe93 user: fvogel tags: bug-bc602049ab
2022-08-23
09:19
Merge 8.6 check-in: 62aeec8a user: jan.nijtmans tags: trunk, main
09:17
Run Tk testcases on ubuntu-20.04 for now (some are failing on ubuntu-22.04) check-in: 59025499 user: jan.nijtmans tags: core-8-6-branch
09:13
Run GITHUB actions testcases with tcl 8.5 -> 8.6 (since ubuntu 20.04 doesn't have tcl8.5-dev package any more) check-in: e9394419 user: jan.nijtmans tags: core-8-5-branch
2022-08-22
20:36
Github action: ubuntu-20.04 -> ubuntu-22.04 check-in: 809eca9f user: jan.nijtmans tags: core-8-6-branch

Changes to doc/ttk_image.n.

75
76
77
78
79
80
81



82
83
84
85
86
87
88
89
90
91
92
93
94
95
or vertically (\fB\-sticky ns\fR),
subregions of the image are replicated to fill the parcel
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).



.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
    [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)
.SH KEYWORDS
style, theme, appearance, pixmap theme, image







>
>
>






|







75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
or vertically (\fB\-sticky ns\fR),
subregions of the image are replicated to fill the parcel
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]
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)
.SH KEYWORDS
style, theme, appearance, pixmap theme, image

Changes to generic/ttk/ttkImage.c.

245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/*------------------------------------------------------------------------
 * +++ Image element definition.
 */

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 */
    Ttk_Sticky sticky;		/* -stickiness specification */
    Ttk_Padding border;		/* Fixed border region */
    Ttk_Padding padding;	/* Internal padding */

#if TILE_07_COMPAT
    Ttk_ResourceCache cache;	/* Resource cache for images */
    Ttk_StateMap imageMap;	/* State-based lookup table for images */







|







245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/*------------------------------------------------------------------------
 * +++ Image element definition.
 */

typedef struct {		/* ClientData for image elements */
    Ttk_ImageSpec *imageSpec;	/* Image(s) to use */
    int minWidth;		/* 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
    Ttk_ResourceCache cache;	/* Resource cache for images */
    Ttk_StateMap imageMap;	/* State-based lookup table for images */

Changes to generic/ttk/ttkTreeview.c.

237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
    /* Temporary storage for cell data
     */
    Tcl_Obj 	*data;
} TreeColumn;

static void InitColumn(TreeColumn *column)
{
    column->width = 200;
    column->minWidth = 20;
    column->stretch = 1;
    column->idObj = 0;
    column->anchorObj = 0;

    column->headingState = 0;
    column->headingObj = 0;
    column->headingImageObj = 0;







|
|







237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
    /* Temporary storage for cell data
     */
    Tcl_Obj 	*data;
} TreeColumn;

static void InitColumn(TreeColumn *column)
{
    column->width = atoi(DEF_COLWIDTH);
    column->minWidth = atoi(DEF_MINWIDTH);
    column->stretch = 1;
    column->idObj = 0;
    column->anchorObj = 0;

    column->headingState = 0;
    column->headingObj = 0;
    column->headingImageObj = 0;

Changes to generic/ttk/ttkWidget.c.

110
111
112
113
114
115
116













117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
    }

    if (!(corePtr->flags & REDISPLAY_PENDING)) {
	Tcl_DoWhenIdle(DrawWidget, corePtr);
	corePtr->flags |= REDISPLAY_PENDING;
    }
}














/* TtkResizeWidget --
 * 	Recompute widget size, schedule geometry propagation and redisplay.
 */
void TtkResizeWidget(WidgetCore *corePtr)
{
    if (corePtr->flags & WIDGET_DESTROYED) {
	return;
    }

    SizeChanged(corePtr);
    TtkRedisplayWidget(corePtr);
}

/* TtkWidgetChangeState --
 * 	Set / clear the specified bits in the 'state' flag,
 */
void TtkWidgetChangeState(WidgetCore *corePtr,
    unsigned int setBits, unsigned int clearBits)







>
>
>
>
>
>
>
>
>
>
>
>
>










|
<







110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140

141
142
143
144
145
146
147
    }

    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)
{
    if (corePtr->flags & WIDGET_DESTROYED) {
	return;
    }

    WidgetWorldChanged(corePtr);

}

/* TtkWidgetChangeState --
 * 	Set / clear the specified bits in the 'state' flag,
 */
void TtkWidgetChangeState(WidgetCore *corePtr,
    unsigned int setBits, unsigned int clearBits)
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
	    corePtr->state |= TTK_STATE_HOVER;
	    TtkRedisplayWidget(corePtr);
	    break;
	case VirtualEvent: {
	    const char *name = ((XVirtualEvent *)eventPtr)->name;
	    if ((name != NULL) && !strcmp("ThemeChanged", name)) {
		(void)UpdateLayout(corePtr->interp, corePtr);
		SizeChanged(corePtr);
		TtkRedisplayWidget(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 */
};

/*
 * TtkWidgetConstructorObjCmd --
 *	General-purpose widget constructor command implementation.
 *	ClientData is a WidgetSpec *.
 */







|
<









<
<
<
<
<
<
<
<
<
<
<
<
<


|
|
|







317
318
319
320
321
322
323
324

325
326
327
328
329
330
331
332
333













334
335
336
337
338
339
340
341
342
343
344
345
	    corePtr->state |= TTK_STATE_HOVER;
	    TtkRedisplayWidget(corePtr);
	    break;
	case VirtualEvent: {
	    const char *name = ((XVirtualEvent *)eventPtr)->name;
	    if ((name != NULL) && !strcmp("ThemeChanged", name)) {
		(void)UpdateLayout(corePtr->interp, corePtr);
		WidgetWorldChanged(corePtr);

	    }
	    break;
	}
	default:
	    /* can't happen... */
	    break;
    }
}














static Tk_ClassProcs widgetClassProcs = {
    sizeof(Tk_ClassProcs),	/* size */
    WidgetWorldChanged,		/* worldChangedProc */
    NULL,			/* createProc */
    NULL			/* modalProc */
};

/*
 * TtkWidgetConstructorObjCmd --
 *	General-purpose widget constructor command implementation.
 *	ClientData is a WidgetSpec *.
 */

Changes to tests/ttk/treeview.test.

918
919
920
921
922
923
924























925
926
    .tv configure -displaycolumns {bar colC colA colB}
    update idletasks ; # no slack anymore because the widget resizes (shrinks)
    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}
























tcltest::cleanupTests







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
    .tv configure -displaycolumns {bar colC colA colB}
    update idletasks ; # no slack anymore because the widget resizes (shrinks)
    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