summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-05-18 12:19:10 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-05-18 12:19:10 (GMT)
commit87d12d1ccc63df37fd805599bf29388c1d164e36 (patch)
tree3f3352b166163e06c4fa6d647bc34651c34bc1a1
parentbb089fa3ae014082fd1642a5c932f8c0c7422924 (diff)
parent6409149a9a89dbed7c247ed2b0e7e4317277da4a (diff)
downloadtk-87d12d1ccc63df37fd805599bf29388c1d164e36.zip
tk-87d12d1ccc63df37fd805599bf29388c1d164e36.tar.gz
tk-87d12d1ccc63df37fd805599bf29388c1d164e36.tar.bz2
merge trunk.
Make "font actual" return integers, for compatibility.
-rw-r--r--generic/tkFont.c6
-rw-r--r--macosx/tkMacOSXDialog.c50
-rw-r--r--unix/tcl.m445
-rw-r--r--unix/tkUnixButton.c81
-rw-r--r--unix/tkUnixFont.c2
-rw-r--r--win/tkWinDialog.c2
6 files changed, 87 insertions, 99 deletions
diff --git a/generic/tkFont.c b/generic/tkFont.c
index 9a70a65..7b6a759 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.c
@@ -3501,7 +3501,11 @@ GetAttributeInfoObj(
break;
case FONT_SIZE:
- valuePtr = Tcl_NewDoubleObj(faPtr->size);
+ if (faPtr->size >= 0.0) {
+ valuePtr = Tcl_NewIntObj((int)(faPtr->size + 0.5));
+ } else {
+ valuePtr = Tcl_NewIntObj(-(int)(-faPtr->size + 0.5));
+ }
break;
case FONT_WEIGHT:
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index 2670b32..027a8e4 100644
--- a/macosx/tkMacOSXDialog.c
+++ b/macosx/tkMacOSXDialog.c
@@ -6,7 +6,7 @@
* Copyright (c) 1996-1997 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright (c) 2017 Christian Gollwitzer.
+ * Copyright (c) 2017 Christian Gollwitzer.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -34,7 +34,7 @@ typedef struct {
NSMutableArray *fileTypeExtensions; // array of allowed extensions per name, e.g. "txt", "doc"
NSMutableArray *fileTypeLabels; // displayed string, e.g. "Text document (.txt, .doc)"
NSMutableArray *allAllowedExtensions; // set of all allowed extensions
- NSInteger fileTypeIndex; // index of currently selected filter
+ NSInteger fileTypeIndex; // index of currently selected filter
} filepanelFilterInfo;
filepanelFilterInfo filterInfo;
@@ -413,7 +413,7 @@ int parseFileFilters(Tcl_Interp *interp, Tcl_Obj *fileTypesPtr, Tcl_Obj *typeVar
}
filterInfo.doFileTypes = (fl.filters != NULL);
-
+
filterInfo.fileTypeIndex = 0;
filterInfo.fileTypeExtensions = [NSMutableArray array];
filterInfo.fileTypeNames = [NSMutableArray array];
@@ -442,7 +442,7 @@ int parseFileFilters(Tcl_Interp *interp, Tcl_Obj *fileTypesPtr, Tcl_Obj *typeVar
if (![filterInfo.allAllowedExtensions containsObject:extension]) {
[filterInfo.allAllowedExtensions addObject:extension];
}
-
+
[clauseextensions addObject:extension];
[displayextensions addObject:[@"." stringByAppendingString:extension]];
@@ -458,7 +458,7 @@ int parseFileFilters(Tcl_Interp *interp, Tcl_Obj *fileTypesPtr, Tcl_Obj *typeVar
[label appendString:@")"];
[filterInfo.fileTypeLabels addObject:label];
[label release];
-
+
}
/* Check if the typevariable exists and matches one of the names */
@@ -467,21 +467,21 @@ int parseFileFilters(Tcl_Interp *interp, Tcl_Obj *fileTypesPtr, Tcl_Obj *typeVar
if (typeVariablePtr) {
/* extract the variable content as a NSString */
Tcl_Obj *selectedFileTypeObj = Tcl_ObjGetVar2(interp, typeVariablePtr, NULL, TCL_GLOBAL_ONLY);
-
+
/* check that the typevariable exists */
- if (selectedFileTypeObj != NULL) {
+ if (selectedFileTypeObj != NULL) {
const char *selectedFileType = Tcl_GetString(selectedFileTypeObj);
NSString *selectedFileTypeStr = [[NSString alloc] initWithUTF8String:selectedFileType];
NSUInteger index = [filterInfo.fileTypeNames indexOfObject:selectedFileTypeStr];
-
+
if (index != NSNotFound) {
filterInfo.fileTypeIndex = index;
filterInfo.preselectFilter = true;
}
}
- }
+ }
- }
+ }
TkFreeFileFilters(&fl);
return TCL_OK;
@@ -587,9 +587,9 @@ Tk_GetOpenFileObjCmd(
break;
}
}
-
- /* From OSX 10.11, the title string is silently ignored.
- * Prepend the title to the message
+
+ /* From OSX 10.11, the title string is silently ignored.
+ * Prepend the title to the message
* NOTE should be conditional on OSX version, but
* -mmacosx-version-min does not revert this behaviour*/
if (title) {
@@ -610,7 +610,7 @@ Tk_GetOpenFileObjCmd(
}
[openpanel setAllowsMultipleSelection:multiple];
-
+
if (parseFileFilters(interp, fileTypesPtr, typeVariablePtr) != TCL_OK) {
goto end;
}
@@ -630,19 +630,19 @@ Tk_GetOpenFileObjCmd(
[accessoryView addSubview:label];
[accessoryView addSubview:popupButton];
-
+
if (filterInfo.preselectFilter) {
- /* A specific filter was selected from the typevariable. Select it and
+ /* A specific filter was selected from the typevariable. Select it and
* open the accessory view */
[popupButton selectItemAtIndex:filterInfo.fileTypeIndex];
- /* on OSX > 10.11, the optons are not visible by default. Ergo allow all file types
+ /* on OSX > 10.11, the optons are not visible by default. Ergo allow all file types
[openpanel setAllowedFileTypes:filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex]];
*/
[openpanel setAllowedFileTypes:filterInfo.allAllowedExtensions];
} else {
[openpanel setAllowedFileTypes:filterInfo.allAllowedExtensions];
}
-
+
[openpanel setAllowsOtherFileTypes:NO];
[openpanel setAccessoryView:accessoryView];
@@ -658,7 +658,7 @@ Tk_GetOpenFileObjCmd(
}
Tcl_IncrRefCount(cmdObj);
}
-
+
callbackInfo->cmdObj = cmdObj;
callbackInfo->interp = interp;
callbackInfo->multiple = multiple;
@@ -698,8 +698,8 @@ Tk_GetOpenFileObjCmd(
if (parentIsKey) {
[parent makeKeyWindow];
}
-
- if ((typeVariablePtr && (modalReturnCode == NSOKButton)) &&
+
+ if ((typeVariablePtr && (modalReturnCode == NSOKButton)) &&
filterInfo.doFileTypes && filterInfo.userHasSelectedFilter) {
/*
* The -typevariable must be set to the selected file type, if the dialog was not cancelled
@@ -712,7 +712,7 @@ Tk_GetOpenFileObjCmd(
Tcl_NewStringObj([selectedFilter UTF8String], -1), TCL_GLOBAL_ONLY);
}
-
+
end:
return result;
}
@@ -826,7 +826,7 @@ Tk_GetSaveFileObjCmd(
break;
}
}
-
+
if (title) {
[savepanel setTitle:title];
if (message) {
@@ -866,7 +866,7 @@ Tk_GetSaveFileObjCmd(
[accessoryView addSubview:popupButton];
[savepanel setAccessoryView:accessoryView];
-
+
[savepanel setAllowedFileTypes:filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex]];
[savepanel setAllowsOtherFileTypes:NO];
} else if (defaultType) {
@@ -930,7 +930,7 @@ Tk_GetSaveFileObjCmd(
if (parentIsKey) {
[parent makeKeyWindow];
}
-
+
if ((typeVariablePtr && (modalReturnCode == NSOKButton)) && filterInfo.doFileTypes) {
/*
* The -typevariable must be set to the selected file type, if the dialog was not cancelled
diff --git a/unix/tcl.m4 b/unix/tcl.m4
index 41b94ef..fc488e4 100644
--- a/unix/tcl.m4
+++ b/unix/tcl.m4
@@ -1467,44 +1467,21 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
OpenBSD-*)
arch=`arch -s`
case "$arch" in
- vax)
- # Equivalent using configure option --disable-load
- # Step 4 will set the necessary variables
- DL_OBJS=""
- SHLIB_LD_LIBS=""
- LDFLAGS=""
+ alpha|sparc64)
+ SHLIB_CFLAGS="-fPIC"
;;
*)
- case "$arch" in
- alpha|sparc|sparc64)
- SHLIB_CFLAGS="-fPIC"
- ;;
- *)
- SHLIB_CFLAGS="-fpic"
- ;;
- esac
- SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}'
- SHLIB_SUFFIX=".so"
- DL_OBJS="tclLoadDl.o"
- DL_LIBS=""
- AS_IF([test $doRpath = yes], [
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
- LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
- SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}'
- LDFLAGS="-Wl,-export-dynamic"
- ;;
- esac
- case "$arch" in
- vax)
- CFLAGS_OPTIMIZE="-O1"
- ;;
- sh)
- CFLAGS_OPTIMIZE="-O0"
- ;;
- *)
- CFLAGS_OPTIMIZE="-O2"
+ SHLIB_CFLAGS="-fpic"
;;
esac
+ SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}'
+ SHLIB_SUFFIX=".so"
+ AS_IF([test $doRpath = yes], [
+ CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
+ LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
+ SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so${SHLIB_VERSION}'
+ LDFLAGS="-Wl,-export-dynamic"
+ CFLAGS_OPTIMIZE="-O2"
AS_IF([test "${TCL_THREADS}" = "1"], [
# On OpenBSD: Compile with -pthread
# Don't link with -lpthread
diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c
index 1aeefac..6a99124 100644
--- a/unix/tkUnixButton.c
+++ b/unix/tkUnixButton.c
@@ -351,6 +351,47 @@ TkpCreateButton(
*----------------------------------------------------------------------
*/
+static void
+ShiftByOffset(
+ TkButton *butPtr,
+ int relief,
+ int *x, /* shift this x coordinate */
+ int *y, /* shift this y coordinate */
+ int width, /* width of image/text */
+ int height) /* height of image/text */
+{
+ if (relief != TK_RELIEF_RAISED
+ && butPtr->type == TYPE_BUTTON
+ && !Tk_StrictMotif(butPtr->tkwin)) {
+ int shiftX;
+ int shiftY;
+
+ /*
+ * This is an (unraised) button widget, so we offset the text to make
+ * the button appear to move up and down as the relief changes.
+ */
+
+ shiftX = shiftY = (relief == TK_RELIEF_SUNKEN) ? 2 : 1;
+
+ if (relief != TK_RELIEF_RIDGE) {
+ /*
+ * Take back one pixel if the padding is even, otherwise the
+ * content will be displayed too far right/down.
+ */
+
+ if ((Tk_Width(butPtr->tkwin) - width) % 2 == 0) {
+ shiftX -= 1;
+ }
+ if ((Tk_Height(butPtr->tkwin) - height) % 2 == 0) {
+ shiftY -= 1;
+ }
+ }
+
+ *x += shiftX;
+ *y += shiftY;
+ }
+}
+
void
TkpDisplayButton(
ClientData clientData) /* Information about widget. */
@@ -366,10 +407,6 @@ TkpDisplayButton(
int width = 0, height = 0, fullWidth, fullHeight;
int textXOffset, textYOffset;
int haveImage = 0, haveText = 0;
- int offset; /* 1 means this is a button widget, so we
- * offset the text to make the button appear
- * to move up and down as the relief
- * changes. */
int imageWidth, imageHeight;
int imageXOffset = 0, imageYOffset = 0;
/* image information that will be used to
@@ -432,8 +469,6 @@ TkpDisplayButton(
}
}
- offset = (butPtr->type == TYPE_BUTTON) && !Tk_StrictMotif(butPtr->tkwin);
-
/*
* In order to avoid screen flashes, this function redraws the button in a
* pixmap, then copies the pixmap to the screen in a single operation.
@@ -525,17 +560,7 @@ TkpDisplayButton(
butPtr->indicatorSpace + fullWidth, fullHeight, &x, &y);
x += butPtr->indicatorSpace;
-
- x += offset;
- y += offset;
- if (relief == TK_RELIEF_RAISED) {
- x -= offset;
- y -= offset;
- } else if (relief == TK_RELIEF_SUNKEN) {
- x += offset;
- y += offset;
- }
-
+ ShiftByOffset(butPtr, relief, &x, &y, width, height);
imageXOffset += x;
imageYOffset += y;
@@ -593,16 +618,7 @@ TkpDisplayButton(
TkComputeAnchor(butPtr->anchor, tkwin, 0, 0,
butPtr->indicatorSpace + width, height, &x, &y);
x += butPtr->indicatorSpace;
-
- x += offset;
- y += offset;
- if (relief == TK_RELIEF_RAISED) {
- x -= offset;
- y -= offset;
- } else if (relief == TK_RELIEF_SUNKEN) {
- x += offset;
- y += offset;
- }
+ ShiftByOffset(butPtr, relief, &x, &y, width, height);
imageXOffset += x;
imageYOffset += y;
if (butPtr->image != NULL) {
@@ -655,16 +671,7 @@ TkpDisplayButton(
butPtr->textHeight, &x, &y);
x += butPtr->indicatorSpace;
-
- x += offset;
- y += offset;
- if (relief == TK_RELIEF_RAISED) {
- x -= offset;
- y -= offset;
- } else if (relief == TK_RELIEF_SUNKEN) {
- x += offset;
- y += offset;
- }
+ ShiftByOffset(butPtr, relief, &x, &y, width, height);
Tk_DrawTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout,
x, y, 0, -1);
Tk_UnderlineTextLayout(butPtr->display, pixmap, gc,
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c
index a447ec7..e2ce2bc 100644
--- a/unix/tkUnixFont.c
+++ b/unix/tkUnixFont.c
@@ -2773,7 +2773,7 @@ GetScreenFont(
}
*str = '\0';
sprintf(buf, "%.200s-%d-*-*-*-*-*%s", nameList[bestIdx[1]],
- (int)(-wantPtr->fa.size-0.5), rest);
+ (int)(-wantPtr->fa.size+0.5), rest);
*str = '-';
fontStructPtr = XLoadQueryFont(display, buf);
bestScore[1] = INT_MAX;
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index 62400bb..5be6776 100644
--- a/win/tkWinDialog.c
+++ b/win/tkWinDialog.c
@@ -2808,7 +2808,7 @@ Tk_MessageBoxObjCmd(
ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_DString titleBuf, tmpBuf;
- WCHAR *titlePtr, *tmpPtr;
+ const WCHAR *titlePtr, *tmpPtr;
const char *src;
defaultBtn = -1;