Import Tk 8.6.11

This commit is contained in:
Steve Dower
2021-03-30 00:54:10 +01:00
parent 42c69189d9
commit 070b8750b0
403 changed files with 21608 additions and 16269 deletions

View File

@@ -95,6 +95,8 @@ static void PulseDefaultButtonProc(ClientData clientData);
const Tk_ClassProcs tkpButtonProcs = {
sizeof(Tk_ClassProcs), /* size */
TkButtonWorldChanged, /* worldChangedProc */
NULL,
NULL
};
static int bCount;
@@ -143,7 +145,7 @@ TkButton *
TkpCreateButton(
Tk_Window tkwin)
{
MacButton *macButtonPtr = ckalloc(sizeof(MacButton));
MacButton *macButtonPtr = (MacButton *)ckalloc(sizeof(MacButton));
Tk_CreateEventHandler(tkwin, ActivateMask,
ButtonEventProc, macButtonPtr);
@@ -186,22 +188,12 @@ TkpDisplayButton(
DrawParams* dpPtr = &macButtonPtr->drawParams;
int needhighlight = 0;
if (butPtr->flags & BUTTON_DELETED) {
return;
}
butPtr->flags &= ~REDRAW_PENDING;
if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
return;
}
pixmap = (Pixmap) Tk_WindowId(tkwin);
/*
* Set up clipping region. Make sure the we are using the port
* for this button, or we will set the wrong window's clip.
*/
TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin));
if (TkMacOSXComputeButtonDrawParams(butPtr, dpPtr)) {
macButtonPtr->useTkText = 0;
} else {
@@ -332,39 +324,40 @@ TkpComputeButtonGeometry(
haveText = 1;
}
if (haveImage && haveText) { /* Image and Text */
switch ((enum compound) butPtr->compound) {
case COMPOUND_TOP:
case COMPOUND_BOTTOM:
/*
* Image is above or below text.
*/
if (haveImage) {
if (haveText) { /* Image and Text */
switch ((enum compound) butPtr->compound) {
case COMPOUND_TOP:
case COMPOUND_BOTTOM:
/*
* Image is above or below text.
*/
height += txtHeight + butPtr->padY;
width = (width > txtWidth ? width : txtWidth);
break;
case COMPOUND_LEFT:
case COMPOUND_RIGHT:
/*
* Image is left or right of text.
*/
height += txtHeight + butPtr->padY;
width = (width > txtWidth ? width : txtWidth);
break;
case COMPOUND_LEFT:
case COMPOUND_RIGHT:
/*
* Image is left or right of text.
*/
width += txtWidth + 2*butPtr->padX;
height = (height > txtHeight ? height : txtHeight);
break;
case COMPOUND_CENTER:
/*
* Image and text are superimposed.
*/
width += txtWidth + 2*butPtr->padX;
height = (height > txtHeight ? height : txtHeight);
break;
case COMPOUND_CENTER:
/*
* Image and text are superimposed.
*/
width = (width > txtWidth ? width : txtWidth);
height = (height > txtHeight ? height : txtHeight);
break;
default:
break;
width = (width > txtWidth ? width : txtWidth);
height = (height > txtHeight ? height : txtHeight);
break;
default:
break;
}
}
width += butPtr->indicatorSpace;
} else if (haveImage) { /* Image only */
/* Image with or without text */
width = butPtr->width > 0 ? butPtr->width : width + butPtr->indicatorSpace;
height = butPtr->height > 0 ? butPtr->height : height;
if (butPtr->type == TYPE_BUTTON) {
@@ -399,7 +392,7 @@ TkpComputeButtonGeometry(
width += butPtr->inset*2;
height += butPtr->inset*2;
if ([NSApp macMinorVersion] == 6) {
if ([NSApp macOSVersion] == 100600) {
width += 12;
}
if (mbPtr->btnkind == kThemePushButton) {
@@ -465,7 +458,7 @@ DrawButtonImageAndText(
pixmap = (Pixmap) Tk_WindowId(tkwin);
if (butPtr->image != None) {
if (butPtr->image != NULL) {
Tk_SizeOfImage(butPtr->image, &width, &height);
haveImage = 1;
} else if (butPtr->bitmap != None) {
@@ -481,7 +474,7 @@ DrawButtonImageAndText(
}
haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0);
if (haveImage && haveText) { /* Image and Text */
if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { /* Image and Text */
int x, y;
switch ((enum compound) butPtr->compound) {
@@ -726,7 +719,7 @@ TkpDestroyButton(
static void
TkMacOSXDrawButton(
MacButton *mbPtr, /* Mac button. */
GC gc, /* The GC we are drawing into - needed for
TCL_UNUSED(GC), /* The GC we are drawing into - needed for
* the bevel button */
Pixmap pixmap) /* The pixmap we are drawing into - needed
* for the bevel button */
@@ -751,7 +744,7 @@ TkMacOSXDrawButton(
ButtonBackgroundDrawCB(&cntrRect, mbPtr, 32, true);
if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) {
if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, &dc)) {
return;
}
@@ -784,7 +777,7 @@ TkMacOSXDrawButton(
ButtonContentDrawCB(&contHIRec, mbPtr->btnkind, &mbPtr->drawinfo,
(MacButton *) mbPtr, 32, true);
} else {
if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) {
if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, &dc)) {
return;
}
@@ -812,10 +805,10 @@ TkMacOSXDrawButton(
static void
ButtonBackgroundDrawCB(
const HIRect *btnbounds,
TCL_UNUSED(const HIRect *),
MacButton *ptr,
SInt16 depth,
Boolean isColorDev)
TCL_UNUSED(SInt16),
TCL_UNUSED(Boolean))
{
MacButton *mbPtr = (MacButton *) ptr;
TkButton *butPtr = (TkButton *) mbPtr;
@@ -864,12 +857,12 @@ ButtonBackgroundDrawCB(
*/
static void
ButtonContentDrawCB (
const HIRect * btnbounds,
ThemeButtonKind kind,
const HIThemeButtonDrawInfo *drawinfo,
TCL_UNUSED(const HIRect *),
TCL_UNUSED(ThemeButtonKind),
TCL_UNUSED(const HIThemeButtonDrawInfo *),
MacButton *ptr,
SInt16 depth,
Boolean isColorDev)
TCL_UNUSED(SInt16),
TCL_UNUSED(Boolean))
{
TkButton *butPtr = (TkButton *) ptr;
Tk_Window tkwin = butPtr->tkwin;
@@ -1047,7 +1040,14 @@ TkMacOSXComputeButtonParams(
if (drawinfo->state != kThemeStatePressed) {
drawinfo->adornment |= kThemeAdornmentDefault;
}
if (!mbPtr->defaultPulseHandler) {
/*
* Older macOS systems (10.9 and earlier) use an animation to
* indicate the active button. This is simulated by redrawing
* the button periodically.
*/
if (!mbPtr->defaultPulseHandler && ([NSApp macOSVersion] <= 100900)) {
mbPtr->defaultPulseHandler = Tcl_CreateTimerHandler(
PULSE_TIMER_MSECS, PulseDefaultButtonProc, butPtr);
}
@@ -1177,6 +1177,13 @@ PulseDefaultButtonProc(ClientData clientData)
MacButton *mbPtr = clientData;
TkpDisplayButton(clientData);
/*
* Fix 40ada90762: any idle calls to TkpDisplayButton need to be canceled
* in case the button is destroyed and has its data freed before the idle
* event is handled (DestroyButton only cancels calls when REDRAW_PENDING
* is set, which is not the case after calling TkpDisplayButton directly).
*/
Tcl_CancelIdleCall(TkpDisplayButton, clientData);
mbPtr->defaultPulseHandler = Tcl_CreateTimerHandler(
PULSE_TIMER_MSECS, PulseDefaultButtonProc, clientData);
}