Tk Source Code

Changes On Branch tip-366
Login

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

Changes In Branch tip-366 Excluding Merge-Ins

This is equivalent to a diff from 89b215ec to 6a84200a

2022-09-27
17:47
Fix [f326f30e82]: DestroyMenuInstance(): clear stale pointer. Patch from Christopher Chavez. check-in: 5c8e8017 user: fvogel tags: trunk, main
10:43
Merge 8.7 Closed-Leaf check-in: 6a84200a user: jan.nijtmans tags: tip-366
10:42
Merge 8.7. Alphabetize options Closed-Leaf check-in: aed03337 user: jan.nijtmans tags: tip-167
10:32
Don't use Tcl_SaveResult() any more check-in: 89b215ec user: jan.nijtmans tags: trunk, main
08:29
Fix [457071937d]. Add back "debugger" command, so - at least - it's usable on older MacOSX machines when compiled in debug mode check-in: 34f65345 user: jan.nijtmans tags: trunk, main
2022-09-26
19:23
Merge 8.7 check-in: 340658ef user: jan.nijtmans tags: tip-366
17:25
Revisions to Tk needed if TIP 640 is adopted. Closed-Leaf check-in: 3cfcff6a user: dgp tags: tip-640

Changes to generic/tkMenubutton.c.

127
128
129
130
131
132
133






134
135
136
137
138
139
140
	DEF_MENUBUTTON_TEXT_VARIABLE, TCL_INDEX_NONE,
	offsetof(TkMenuButton, textVarName), TK_OPTION_NULL_OK, 0, 0},
    {TK_OPTION_INDEX, "-underline", "underline", "Underline",
	TK_OPTION_UNDERLINE_DEF(TkMenuButton, underline), 0},
    {TK_OPTION_STRING, "-width", "width", "Width",
	DEF_MENUBUTTON_WIDTH, TCL_INDEX_NONE, offsetof(TkMenuButton, widthString),
	0, 0, 0},






    {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
	DEF_MENUBUTTON_WRAP_LENGTH, TCL_INDEX_NONE, offsetof(TkMenuButton, wrapLength),
	0, 0, 0},
    {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};

/*







>
>
>
>
>
>







127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
	DEF_MENUBUTTON_TEXT_VARIABLE, TCL_INDEX_NONE,
	offsetof(TkMenuButton, textVarName), TK_OPTION_NULL_OK, 0, 0},
    {TK_OPTION_INDEX, "-underline", "underline", "Underline",
	TK_OPTION_UNDERLINE_DEF(TkMenuButton, underline), 0},
    {TK_OPTION_STRING, "-width", "width", "Width",
	DEF_MENUBUTTON_WIDTH, TCL_INDEX_NONE, offsetof(TkMenuButton, widthString),
	0, 0, 0},
    {TK_OPTION_STRING, "-indwidth", "indWidth", "IndWidth",
	DEF_MENUBUTTON_INDICATORWIDTH, TCL_INDEX_NONE, offsetof(TkMenuButton, indicatorWidthString),
	0, 0, 0},
    {TK_OPTION_STRING, "-indheight", "indHeight", "IndHeight",
	DEF_MENUBUTTON_INDICATORHEIGHT, TCL_INDEX_NONE, offsetof(TkMenuButton, indicatorHeightString),
	0, 0, 0},
    {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
	DEF_MENUBUTTON_WRAP_LENGTH, TCL_INDEX_NONE, offsetof(TkMenuButton, wrapLength),
	0, 0, 0},
    {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};

/*
265
266
267
268
269
270
271


272
273
274
275
276
277
278
279
280
281
282


283
284
285
286
287
288
289
    mbPtr->gray = None;
    mbPtr->disabledGC = NULL;
    mbPtr->stippleGC = NULL;
    mbPtr->leftBearing = 0;
    mbPtr->rightBearing = 0;
    mbPtr->widthString = NULL;
    mbPtr->heightString = NULL;


    mbPtr->width = 0;
    mbPtr->width = 0;
    mbPtr->wrapLength = 0;
    mbPtr->padX = 0;
    mbPtr->padY = 0;
    mbPtr->anchor = TK_ANCHOR_CENTER;
    mbPtr->justify = TK_JUSTIFY_CENTER;
    mbPtr->textLayout = NULL;
    mbPtr->indicatorOn = 0;
    mbPtr->indicatorWidth = 0;
    mbPtr->indicatorHeight = 0;


    mbPtr->direction = DIRECTION_FLUSH;
    mbPtr->cursor = NULL;
    mbPtr->takeFocus = NULL;
    mbPtr->flags = 0;

    Tk_CreateEventHandler(mbPtr->tkwin,
	    ExposureMask|StructureNotifyMask|FocusChangeMask,







>
>











>
>







271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
    mbPtr->gray = None;
    mbPtr->disabledGC = NULL;
    mbPtr->stippleGC = NULL;
    mbPtr->leftBearing = 0;
    mbPtr->rightBearing = 0;
    mbPtr->widthString = NULL;
    mbPtr->heightString = NULL;
    mbPtr->indicatorWidthString = NULL;
    mbPtr->indicatorHeightString = NULL;
    mbPtr->width = 0;
    mbPtr->width = 0;
    mbPtr->wrapLength = 0;
    mbPtr->padX = 0;
    mbPtr->padY = 0;
    mbPtr->anchor = TK_ANCHOR_CENTER;
    mbPtr->justify = TK_JUSTIFY_CENTER;
    mbPtr->textLayout = NULL;
    mbPtr->indicatorOn = 0;
    mbPtr->indicatorWidth = 0;
    mbPtr->indicatorHeight = 0;
    mbPtr->indWidthStore = 0;
    mbPtr->indHeightStore = 0;
    mbPtr->direction = DIRECTION_FLUSH;
    mbPtr->cursor = NULL;
    mbPtr->takeFocus = NULL;
    mbPtr->flags = 0;

    Tk_CreateEventHandler(mbPtr->tkwin,
	    ExposureMask|StructureNotifyMask|FocusChangeMask,
577
578
579
580
581
582
583












584
585
586
587
588
589
590
591








592
593
594
595
596
597
598
	    }
	    if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->heightString,
		    &mbPtr->height) != TCL_OK) {
	    heightError:
		Tcl_AddErrorInfo(interp, "\n    (processing -height option)");
		continue;
	    }












	} else {
	    if (Tcl_GetInt(interp, mbPtr->widthString, &mbPtr->width)
		    != TCL_OK) {
		goto widthError;
	    }
	    if (Tcl_GetInt(interp, mbPtr->heightString, &mbPtr->height)
		    != TCL_OK) {
		goto heightError;








	    }
	}
	break;
    }

    if (!error) {
	Tk_FreeSavedOptions(&savedOptions);







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








>
>
>
>
>
>
>
>







587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
	    }
	    if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->heightString,
		    &mbPtr->height) != TCL_OK) {
	    heightError:
		Tcl_AddErrorInfo(interp, "\n    (processing -height option)");
		continue;
	    }
	    if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->indicatorWidthString,
		    &mbPtr->indWidthStore) != TCL_OK) {
	    indicatorWidthError:
		Tcl_AddErrorInfo(interp, "\n    (processing -indicatorwidth option)");
		continue;
	    }
	    if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->indicatorHeightString,
		    &mbPtr->indHeightStore) != TCL_OK) {
	    indicatorHeightError:
		Tcl_AddErrorInfo(interp, "\n    (processing -indicatorheight option)");
		continue;
	    }
	} else {
	    if (Tcl_GetInt(interp, mbPtr->widthString, &mbPtr->width)
		    != TCL_OK) {
		goto widthError;
	    }
	    if (Tcl_GetInt(interp, mbPtr->heightString, &mbPtr->height)
		    != TCL_OK) {
		goto heightError;
	    }
	    if (Tcl_GetInt(interp, mbPtr->indicatorWidthString, &mbPtr->indWidthStore)
		    != TCL_OK) {
		goto indicatorWidthError;
	    }
	    if (Tcl_GetInt(interp, mbPtr->indicatorHeightString, &mbPtr->indHeightStore)
		    != TCL_OK) {
		goto indicatorHeightError;
	    }
	}
	break;
    }

    if (!error) {
	Tk_FreeSavedOptions(&savedOptions);

Changes to generic/tkMenubutton.h.

119
120
121
122
123
124
125


126
127
128
129
130
131
132
				 * images when disabled. */
    int leftBearing;		/* Distance from text origin to leftmost drawn
				 * pixel (positive means to right). */
    int rightBearing;		/* Amount text sticks right from its
				 * origin. */
    char *widthString;		/* Value of -width option. Malloc'ed. */
    char *heightString;		/* Value of -height option. Malloc'ed. */


    int width, height;		/* If > 0, these specify dimensions to request
				 * for window, in characters for text and in
				 * pixels for bitmaps. In this case the actual
				 * size of the text string or bitmap is
				 * ignored in computing desired window
				 * size. */
    int wrapLength;		/* Line length (in pixels) at which to wrap







>
>







119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
				 * images when disabled. */
    int leftBearing;		/* Distance from text origin to leftmost drawn
				 * pixel (positive means to right). */
    int rightBearing;		/* Amount text sticks right from its
				 * origin. */
    char *widthString;		/* Value of -width option. Malloc'ed. */
    char *heightString;		/* Value of -height option. Malloc'ed. */
    char *indicatorWidthString; /* Value of -indicatorwidth option */
    char *indicatorHeightString;/* Value of -indicatorheight option */
    int width, height;		/* If > 0, these specify dimensions to request
				 * for window, in characters for text and in
				 * pixels for bitmaps. In this case the actual
				 * size of the text string or bitmap is
				 * ignored in computing desired window
				 * size. */
    int wrapLength;		/* Line length (in pixels) at which to wrap
148
149
150
151
152
153
154


155
156
157
158
159
160
161
    int indicatorHeight;	/* Height of indicator in pixels. This same
				 * amount of extra space is also left on each
				 * side of the indicator. 0 if no
				 * indicator. */
    int indicatorWidth;		/* Width of indicator in pixels, including
				 * indicatorHeight in padding on each side. 0
				 * if no indicator. */



    /*
     * Miscellaneous information:
     */

    int compound;		/* Value of -compound option; specifies
				 * whether the menubutton should show both an







>
>







150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
    int indicatorHeight;	/* Height of indicator in pixels. This same
				 * amount of extra space is also left on each
				 * side of the indicator. 0 if no
				 * indicator. */
    int indicatorWidth;		/* Width of indicator in pixels, including
				 * indicatorHeight in padding on each side. 0
				 * if no indicator. */
    int indWidthStore;          /* Unchanging indicator width */
    int indHeightStore;         /* Unchanging indicator height */

    /*
     * Miscellaneous information:
     */

    int compound;		/* Value of -compound option; specifies
				 * whether the menubutton should show both an

Changes to macosx/tkMacOSXDefault.h.

357
358
359
360
361
362
363


364
365
366
367
368
369
370
#define DEF_MENUBUTTON_PADY		"0"
#define DEF_MENUBUTTON_RELIEF		"flat"
#define DEF_MENUBUTTON_STATE		"normal"
#define DEF_MENUBUTTON_TAKE_FOCUS	"0"
#define DEF_MENUBUTTON_TEXT		""
#define DEF_MENUBUTTON_TEXT_VARIABLE	""
#define DEF_MENUBUTTON_WIDTH		"0"


#define DEF_MENUBUTTON_WRAP_LENGTH	"0"

/*
 * Defaults for messages:
 */

#define DEF_MESSAGE_ANCHOR		"center"







>
>







357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
#define DEF_MENUBUTTON_PADY		"0"
#define DEF_MENUBUTTON_RELIEF		"flat"
#define DEF_MENUBUTTON_STATE		"normal"
#define DEF_MENUBUTTON_TAKE_FOCUS	"0"
#define DEF_MENUBUTTON_TEXT		""
#define DEF_MENUBUTTON_TEXT_VARIABLE	""
#define DEF_MENUBUTTON_WIDTH		"0"
#define DEF_MENUBUTTON_INDICATORWIDTH	"0"
#define DEF_MENUBUTTON_INDICATORHEIGHT	"0"
#define DEF_MENUBUTTON_WRAP_LENGTH	"0"

/*
 * Defaults for messages:
 */

#define DEF_MESSAGE_ANCHOR		"center"

Changes to tests/menubut.test.

363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
} -returnCodes error -result {unknown option "-gorp"}
test menubutton-3.6 {ButtonWidgetCmd procedure, "cget" option} -body {
    .mb configure -highlightthickness 3
    .mb cget -highlightthickness
} -result 3
test menubutton-3.7 {ButtonWidgetCmd procedure, "configure" option} -body {
    llength [.mb configure]
} -result 33
test menubutton-3.8 {ButtonWidgetCmd procedure, "configure" option} -body {
    .mb configure -gorp
} -returnCodes error -result {unknown option "-gorp"}
test menubutton-3.9 {ButtonWidgetCmd procedure, "configure" option} -body {
    .mb co -bg #ffffff -fg
} -returnCodes error -result {value for "-fg" missing}
test menubutton-3.10 {ButtonWidgetCmd procedure, "configure" option} -body {







|







363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
} -returnCodes error -result {unknown option "-gorp"}
test menubutton-3.6 {ButtonWidgetCmd procedure, "cget" option} -body {
    .mb configure -highlightthickness 3
    .mb cget -highlightthickness
} -result 3
test menubutton-3.7 {ButtonWidgetCmd procedure, "configure" option} -body {
    llength [.mb configure]
} -result 35
test menubutton-3.8 {ButtonWidgetCmd procedure, "configure" option} -body {
    .mb configure -gorp
} -returnCodes error -result {unknown option "-gorp"}
test menubutton-3.9 {ButtonWidgetCmd procedure, "configure" option} -body {
    .mb co -bg #ffffff -fg
} -returnCodes error -result {value for "-fg" missing}
test menubutton-3.10 {ButtonWidgetCmd procedure, "configure" option} -body {

Changes to unix/tkUnixDefault.h.

329
330
331
332
333
334
335


336
337
338
339
340
341
342
#define DEF_MENUBUTTON_PADY		"3p"
#define DEF_MENUBUTTON_RELIEF		"flat"
#define DEF_MENUBUTTON_STATE		"normal"
#define DEF_MENUBUTTON_TAKE_FOCUS	"0"
#define DEF_MENUBUTTON_TEXT		""
#define DEF_MENUBUTTON_TEXT_VARIABLE	""
#define DEF_MENUBUTTON_WIDTH		"0"


#define DEF_MENUBUTTON_WRAP_LENGTH	"0"

/*
 * Defaults for messages:
 */

#define DEF_MESSAGE_ANCHOR		"center"







>
>







329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
#define DEF_MENUBUTTON_PADY		"3p"
#define DEF_MENUBUTTON_RELIEF		"flat"
#define DEF_MENUBUTTON_STATE		"normal"
#define DEF_MENUBUTTON_TAKE_FOCUS	"0"
#define DEF_MENUBUTTON_TEXT		""
#define DEF_MENUBUTTON_TEXT_VARIABLE	""
#define DEF_MENUBUTTON_WIDTH		"0"
#define DEF_MENUBUTTON_INDICATORWIDTH	"0"
#define DEF_MENUBUTTON_INDICATORHEIGHT	"0"
#define DEF_MENUBUTTON_WRAP_LENGTH	"0"

/*
 * Defaults for messages:
 */

#define DEF_MESSAGE_ANCHOR		"center"

Changes to unix/tkUnixMenubu.c.

448
449
450
451
452
453
454

455




456
457




458
459
460
461
462
463
464
	width += 2*mbPtr->padX;
	height += 2*mbPtr->padY;
    }

    if (mbPtr->indicatorOn) {
	mm = WidthMMOfScreen(Tk_Screen(mbPtr->tkwin));
	pixels = WidthOfScreen(Tk_Screen(mbPtr->tkwin));

	mbPtr->indicatorHeight= (INDICATOR_HEIGHT * pixels)/(10*mm);




	mbPtr->indicatorWidth = (INDICATOR_WIDTH * pixels)/(10*mm)
		+ 2*mbPtr->indicatorHeight;




	width += mbPtr->indicatorWidth;
    } else {
	mbPtr->indicatorHeight = 0;
	mbPtr->indicatorWidth = 0;
    }

    Tk_GeometryRequest(mbPtr->tkwin, (int) (width + 2*mbPtr->inset),







>
|
>
>
>
>
|
|
>
>
>
>







448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
	width += 2*mbPtr->padX;
	height += 2*mbPtr->padY;
    }

    if (mbPtr->indicatorOn) {
	mm = WidthMMOfScreen(Tk_Screen(mbPtr->tkwin));
	pixels = WidthOfScreen(Tk_Screen(mbPtr->tkwin));
	if (mbPtr->indHeightStore == 0) {
	    mbPtr->indicatorHeight = (INDICATOR_HEIGHT * pixels)/(10*mm);
	} else {
	    mbPtr->indicatorHeight = (mbPtr->indHeightStore * pixels)/(10*mm);
	}
	if (mbPtr->indWidthStore == 0) {
	    mbPtr->indicatorWidth = (INDICATOR_WIDTH * pixels)/(10*mm)
		    + 2*mbPtr->indicatorHeight;
	} else {
	    mbPtr->indicatorWidth = (mbPtr->indWidthStore * pixels)/(10*mm)
		    + 2*mbPtr->indicatorHeight;
	}
	width += mbPtr->indicatorWidth;
    } else {
	mbPtr->indicatorHeight = 0;
	mbPtr->indicatorWidth = 0;
    }

    Tk_GeometryRequest(mbPtr->tkwin, (int) (width + 2*mbPtr->inset),

Changes to win/tkWinDefault.h.

331
332
333
334
335
336
337


338
339
340
341
342
343
344
#define DEF_MENUBUTTON_PADY		"3p"
#define DEF_MENUBUTTON_RELIEF		"flat"
#define DEF_MENUBUTTON_STATE		"normal"
#define DEF_MENUBUTTON_TAKE_FOCUS	"0"
#define DEF_MENUBUTTON_TEXT		""
#define DEF_MENUBUTTON_TEXT_VARIABLE	""
#define DEF_MENUBUTTON_WIDTH		"0"


#define DEF_MENUBUTTON_WRAP_LENGTH	"0"

/*
 * Defaults for messages:
 */

#define DEF_MESSAGE_ANCHOR		"center"







>
>







331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
#define DEF_MENUBUTTON_PADY		"3p"
#define DEF_MENUBUTTON_RELIEF		"flat"
#define DEF_MENUBUTTON_STATE		"normal"
#define DEF_MENUBUTTON_TAKE_FOCUS	"0"
#define DEF_MENUBUTTON_TEXT		""
#define DEF_MENUBUTTON_TEXT_VARIABLE	""
#define DEF_MENUBUTTON_WIDTH		"0"
#define DEF_MENUBUTTON_INDICATORWIDTH	"0"
#define DEF_MENUBUTTON_INDICATORHEIGHT	"0"
#define DEF_MENUBUTTON_WRAP_LENGTH	"0"

/*
 * Defaults for messages:
 */

#define DEF_MESSAGE_ANCHOR		"center"