summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/spinbox.n14
-rw-r--r--generic/tkBind.c10
-rw-r--r--generic/tkImgPhInstance.c3
-rw-r--r--generic/tkImgPhoto.c50
-rw-r--r--generic/tkText.c12
-rw-r--r--generic/tkTextDisp.c12
-rw-r--r--generic/tkTextIndex.c2
-rw-r--r--generic/tkTextTag.c5
-rw-r--r--generic/tkWindow.c3
-rw-r--r--library/demos/en.msg2
-rw-r--r--library/demos/nl.msg4
-rw-r--r--macosx/tkMacOSXDraw.c9
-rw-r--r--macosx/tkMacOSXWindowEvent.c4
-rw-r--r--tests/imgPhoto.test17
-rw-r--r--tests/textDisp.test6
-rw-r--r--win/tkWinClipboard.c11
-rw-r--r--win/tkWinFont.c51
-rw-r--r--win/tkWinMenu.c46
18 files changed, 139 insertions, 122 deletions
diff --git a/doc/spinbox.n b/doc/spinbox.n
index 330bb17..acf06d6 100644
--- a/doc/spinbox.n
+++ b/doc/spinbox.n
@@ -217,15 +217,19 @@ were editing the spinbox widget from). It is also recommended to not set an
associated \fB\-textvariable\fR during validation, as that can cause the
spinbox widget to become out of sync with the \fB\-textvariable\fR.
.PP
-Also, the \fBvalidate\fR option will set itself to \fBnone\fR when the
-spinbox value gets changed because of adjustment of \fBfrom\fR or \fBto\fR
-and the \fBvalidateCommand\fR returns false. For instance
+Also, the \fB-validate\fR option will set itself to \fBnone\fR when the
+spinbox value gets changed because of adjustment of \fB-from\fR or \fB-to\fR
+and the \fB-validatecommand\fR returns false. For instance
.CS
\fIspinbox pathName \-from 1 \-to 10 \-validate all \-vcmd {return 0}\fR
.CE
-will in fact set the \fBvalidate\fR option to \fBnone\fR because the default
-value for the spinbox gets changed (due to the \fBfrom\fR and \fBto\fR
+will in fact set the \fB-validate\fR option to \fBnone\fR because the default
+value for the spinbox gets changed (due to the \fB-from\fR and \fB-to\fR
options) to a value not accepted by the validation script.
+.PP
+Moreover, forced validation is performed when invoking any spinbutton of
+the spinbox. If the validation script returns false in this situation,
+then the \fB-validate\fR option will be automatically set to \fBnone\fR.
.SH "WIDGET COMMAND"
.PP
The \fBspinbox\fR command creates a new Tcl command whose
diff --git a/generic/tkBind.c b/generic/tkBind.c
index d3fdc96..567c51f 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -1260,6 +1260,16 @@ Tk_BindEvent(
}
}
+ /*
+ * Ignore event types which are not in flagArray and all zeroes there.
+ * Most notably, NoExpose events can fill the ring buffer and disturb
+ * (thus masking out) event sequences of interest.
+ */
+
+ if ((eventPtr->type >= TK_LASTEVENT) || !flagArray[eventPtr->type]) {
+ return;
+ }
+
dispPtr = ((TkWindow *) tkwin)->dispPtr;
bindInfoPtr = winPtr->mainPtr->bindInfo;
diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c
index bd152f2..98aaeab 100644
--- a/generic/tkImgPhInstance.c
+++ b/generic/tkImgPhInstance.c
@@ -721,8 +721,7 @@ TkImgPhotoFree(
PhotoInstance *instancePtr = clientData;
ColorTable *colorPtr;
- instancePtr->refCount -= 1;
- if (instancePtr->refCount > 0) {
+ if (instancePtr->refCount-- > 1) {
return;
}
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index 3e03f3d..1bd0142 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -409,7 +409,8 @@ ImgPhotoCmd(
Tk_PhotoImageBlock block;
Tk_Window tkwin;
Tk_PhotoImageFormat *imageFormat;
- int imageWidth, imageHeight, matched, length, oldformat = 0;
+ size_t length;
+ int imageWidth, imageHeight, matched, oldformat = 0;
Tcl_Channel chan;
Tk_PhotoHandle srcHandle;
ThreadSpecificData *tsdPtr =
@@ -446,12 +447,13 @@ ImgPhotoCmd(
Tcl_WrongNumArgs(interp, 2, objv, "option");
return TCL_ERROR;
}
- arg = Tcl_GetStringFromObj(objv[2], &length);
- if (strncmp(arg,"-data", (unsigned) length) == 0) {
+ arg = Tcl_GetString(objv[2]);
+ length = objv[2]->length;
+ if (strncmp(arg,"-data", length) == 0) {
if (masterPtr->dataString) {
Tcl_SetObjResult(interp, masterPtr->dataString);
}
- } else if (strncmp(arg,"-format", (unsigned) length) == 0) {
+ } else if (strncmp(arg,"-format", length) == 0) {
if (masterPtr->format) {
Tcl_SetObjResult(interp, masterPtr->format);
}
@@ -495,9 +497,10 @@ ImgPhotoCmd(
return TCL_OK;
} else if (objc == 3) {
- const char *arg = Tcl_GetStringFromObj(objv[2], &length);
+ const char *arg = Tcl_GetString(objv[2]);
- if (length > 1 && !strncmp(arg, "-data", (unsigned) length)) {
+ length = objv[2]->length;
+ if (length > 1 && !strncmp(arg, "-data", length)) {
Tcl_AppendResult(interp, "-data {} {} {}", NULL);
if (masterPtr->dataString) {
/*
@@ -511,7 +514,7 @@ ImgPhotoCmd(
}
return TCL_OK;
} else if (length > 1 &&
- !strncmp(arg, "-format", (unsigned) length)) {
+ !strncmp(arg, "-format", length)) {
Tcl_AppendResult(interp, "-format {} {} {}", NULL);
if (masterPtr->format) {
/*
@@ -1489,7 +1492,8 @@ ParseSubcommandOptions(
* TK_PHOTO_COMPOSITE_* constants. */
NULL
};
- int index, c, bit, currentBit, length;
+ size_t length;
+ int index, c, bit, currentBit;
int values[4], numValues, maxValues, argIndex;
const char *option, *expandedOption, *needed;
const char *const *listPtr;
@@ -1501,7 +1505,8 @@ ParseSubcommandOptions(
* optPtr->name.
*/
- expandedOption = option = Tcl_GetStringFromObj(objv[index], &length);
+ expandedOption = option = Tcl_GetString(objv[index]);
+ length = objv[index]->length;
if (option[0] != '-') {
if (optPtr->name == NULL) {
optPtr->name = objv[index];
@@ -1519,7 +1524,7 @@ ParseSubcommandOptions(
currentBit = 1;
for (listPtr = optionNames; *listPtr != NULL; ++listPtr) {
if ((c == *listPtr[0])
- && (strncmp(option, *listPtr, (size_t) length) == 0)) {
+ && (strncmp(option, *listPtr, length) == 0)) {
expandedOption = *listPtr;
if (bit != 0) {
goto unknownOrAmbiguousOption;
@@ -1535,7 +1540,11 @@ ParseSubcommandOptions(
*/
if (!(allowedOptions & bit)) {
- goto unknownOrAmbiguousOption;
+ if (optPtr->name != NULL) {
+ goto unknownOrAmbiguousOption;
+ }
+ optPtr->name = objv[index];
+ continue;
}
/*
@@ -1765,7 +1774,8 @@ ImgPhotoConfigureMaster(
const char *oldFileString, *oldPaletteString;
Tcl_Obj *oldData, *data = NULL, *oldFormat, *format = NULL;
Tcl_Obj *tempdata, *tempformat;
- int length, i, j, result, imageWidth, imageHeight, oldformat;
+ size_t length;
+ int i, j, result, imageWidth, imageHeight, oldformat;
double oldGamma;
Tcl_Channel chan;
Tk_PhotoImageFormat *imageFormat;
@@ -1773,10 +1783,11 @@ ImgPhotoConfigureMaster(
args = ckalloc((objc + 1) * sizeof(char *));
for (i = 0, j = 0; i < objc; i++,j++) {
- args[j] = Tcl_GetStringFromObj(objv[i], &length);
+ args[j] = Tcl_GetString(objv[i]);
+ length = objv[i]->length;
if ((length > 1) && (args[j][0] == '-')) {
if ((args[j][1] == 'd') &&
- !strncmp(args[j], "-data", (size_t) length)) {
+ !strncmp(args[j], "-data", length)) {
if (++i < objc) {
data = objv[i];
j--;
@@ -1789,7 +1800,7 @@ ImgPhotoConfigureMaster(
return TCL_ERROR;
}
} else if ((args[j][1] == 'f') &&
- !strncmp(args[j], "-format", (size_t) length)) {
+ !strncmp(args[j], "-format", length)) {
if (++i < objc) {
format = objv[i];
j--;
@@ -1852,9 +1863,10 @@ ImgPhotoConfigureMaster(
* Force into ByteArray format, which most (all) image handlers will
* use anyway. Empty length means ignore the -data option.
*/
+ int bytesize;
- (void) Tcl_GetByteArrayFromObj(data, &length);
- if (length) {
+ (void) Tcl_GetByteArrayFromObj(data, &bytesize);
+ if (bytesize) {
Tcl_IncrRefCount(data);
} else {
data = NULL;
@@ -1870,8 +1882,8 @@ ImgPhotoConfigureMaster(
* object.
*/
- (void) Tcl_GetStringFromObj(format, &length);
- if (length) {
+ (void) Tcl_GetString(format);
+ if (format->length) {
Tcl_IncrRefCount(format);
} else {
format = NULL;
diff --git a/generic/tkText.c b/generic/tkText.c
index 412a7f2..6ff1db9 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -1570,8 +1570,7 @@ TextWidgetObjCmd(
}
done:
- textPtr->refCount--;
- if (textPtr->refCount == 0) {
+ if (textPtr->refCount-- <= 1) {
ckfree(textPtr);
}
return result;
@@ -1964,9 +1963,7 @@ DestroyText(
* portion of the text widget.
*/
- sharedTextPtr->refCount--;
-
- if (sharedTextPtr->refCount > 0) {
+ if (sharedTextPtr->refCount-- > 1) {
TkBTreeRemoveClient(sharedTextPtr->tree, textPtr);
/*
@@ -2042,13 +2039,12 @@ DestroyText(
}
textPtr->tkwin = NULL;
- textPtr->refCount--;
Tcl_DeleteCommandFromToken(textPtr->interp, textPtr->widgetCmd);
if (textPtr->afterSyncCmd){
Tcl_DecrRefCount(textPtr->afterSyncCmd);
textPtr->afterSyncCmd = NULL;
}
- if (textPtr->refCount == 0) {
+ if (textPtr->refCount-- <= 1) {
ckfree(textPtr);
}
}
@@ -5526,7 +5522,7 @@ RunAfterSyncCmd(
* The widget has been deleted. Don't do anything.
*/
- if (--textPtr->refCount == 0) {
+ if (textPtr->refCount-- <= 1) {
ckfree((char *) textPtr);
}
return;
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 4b7b0db..371e910 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -3005,7 +3005,7 @@ AsyncUpdateLineMetrics(
* The widget has been deleted, or is not mapped. Don't do anything.
*/
- if (--textPtr->refCount == 0) {
+ if (textPtr->refCount-- <= 1) {
ckfree(textPtr);
}
return;
@@ -3080,8 +3080,7 @@ AsyncUpdateLineMetrics(
GenerateWidgetViewSyncEvent(textPtr, 1);
- textPtr->refCount--;
- if (textPtr->refCount == 0) {
+ if (textPtr->refCount-- <= 1) {
ckfree(textPtr);
}
return;
@@ -4163,7 +4162,7 @@ DisplayText(
textPtr->refCount++;
dInfoPtr->flags &= ~REPICK_NEEDED;
TkTextPickCurrent(textPtr, &textPtr->pickEvent);
- if (--textPtr->refCount == 0) {
+ if (textPtr->refCount-- <= 1) {
ckfree(textPtr);
goto end;
}
@@ -4299,8 +4298,9 @@ DisplayText(
if (TkScrollWindow(textPtr->tkwin, dInfoPtr->scrollGC, dInfoPtr->x,
oldY, dInfoPtr->maxX-dInfoPtr->x, height, 0, y-oldY,
damageRgn)) {
+#ifndef MAC_OSX_TK
TextInvalidateRegion(textPtr, damageRgn);
-
+#endif
}
numCopies++;
TkDestroyRegion(damageRgn);
@@ -6752,7 +6752,7 @@ AsyncUpdateYScrollbar(
GetYView(textPtr->interp, textPtr, 1);
}
- if (--textPtr->refCount == 0) {
+ if (textPtr->refCount-- <= 1) {
ckfree(textPtr);
}
}
diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c
index d227bd8..faa1afd 100644
--- a/generic/tkTextIndex.c
+++ b/generic/tkTextIndex.c
@@ -87,7 +87,7 @@ FreeTextIndexInternalRep(
TkTextIndex *indexPtr = GET_TEXTINDEX(indexObjPtr);
if (indexPtr->textPtr != NULL) {
- if (--indexPtr->textPtr->refCount == 0) {
+ if (indexPtr->textPtr->refCount-- <= 1) {
/*
* The text widget has been deleted and we need to free it now.
*/
diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c
index dd3127d..d9329f5 100644
--- a/generic/tkTextTag.c
+++ b/generic/tkTextTag.c
@@ -1258,8 +1258,7 @@ TkTextFreeTag(
if (textPtr != tagPtr->textPtr) {
Tcl_Panic("Tag being deleted from wrong widget");
}
- textPtr->refCount--;
- if (textPtr->refCount == 0) {
+ if (textPtr->refCount-- <= 1) {
ckfree(textPtr);
}
tagPtr->textPtr = NULL;
@@ -1522,7 +1521,7 @@ TkTextBindProc(
}
done:
- if (--textPtr->refCount == 0) {
+ if (textPtr->refCount-- <= 1) {
ckfree(textPtr);
}
}
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index 5855b7c..20b4f20 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.c
@@ -1479,8 +1479,7 @@ Tk_DestroyWindow(
winPtr->mainPtr->deletionEpoch++;
}
- winPtr->mainPtr->refCount--;
- if (winPtr->mainPtr->refCount == 0) {
+ if (winPtr->mainPtr->refCount-- <= 1) {
register const TkCmd *cmdPtr;
/*
diff --git a/library/demos/en.msg b/library/demos/en.msg
index e364c81..05d4a64 100644
--- a/library/demos/en.msg
+++ b/library/demos/en.msg
@@ -18,7 +18,7 @@
::msgcat::mcset en "Demo code: %s"
::msgcat::mcset en "About Widget Demo"
::msgcat::mcset en "Tk widget demonstration application"
-::msgcat::mcset en "Copyright \u00a9 %s"
+::msgcat::mcset en "Copyright © %s"
::msgcat::mcset en "
@@title
Tk Widget Demonstrations
diff --git a/library/demos/nl.msg b/library/demos/nl.msg
index 61832d8..cd52630 100644
--- a/library/demos/nl.msg
+++ b/library/demos/nl.msg
@@ -18,9 +18,9 @@
::msgcat::mcset nl "Demo code: %s" "Code van Demo %s"
::msgcat::mcset nl "About Widget Demo" "Over deze demonstratie"
::msgcat::mcset nl "Tk widget demonstration" "Demonstratie van Tk widgets"
-::msgcat::mcset nl "Copyright \u00a9 %s"
+::msgcat::mcset nl "Copyright © %s"
-::msgcat::mcset nl "Tk Widget Demonstrations" "Demostratie van Tk widgets"
+::msgcat::mcset nl "Tk Widget Demonstrations" "Demonstratie van Tk widgets"
::msgcat::mcset nl "This application provides a front end for several short scripts" \
"Dit programma is een schil rond enkele korte scripts waarmee"
::msgcat::mcset nl "that demonstrate what you can do with Tk widgets. Each of the" \
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c
index 474ed41..5ca8bfe 100644
--- a/macosx/tkMacOSXDraw.c
+++ b/macosx/tkMacOSXDraw.c
@@ -1527,12 +1527,6 @@ TkScrollWindow(
srcRect = CGRectMake(x, y, width, height);
dstRect = CGRectOffset(srcRect, dx, dy);
- /* Expand the rectangles slightly to avoid degeneracies. */
- srcRect.origin.y -= 1;
- srcRect.size.height += 2;
- dstRect.origin.y += 1;
- dstRect.size.height -= 2;
-
/* Compute the damage. */
dmgRgn = HIShapeCreateMutableWithRect(&srcRect);
extraRgn = HIShapeCreateWithRect(&dstRect);
@@ -1571,9 +1565,6 @@ TkScrollWindow(
int oldMode = Tcl_SetServiceMode(TCL_SERVICE_NONE);
[view generateExposeEvents:dmgRgn childrenOnly:1];
Tcl_SetServiceMode(oldMode);
-
- /* Belt and suspenders: make the AppKit request a redraw
- when it gets control again. */
}
} else {
dmgRgn = HIShapeCreateEmpty();
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index a669a8a..4672586 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -357,8 +357,8 @@ GenerateUpdates(
event.xany.window = Tk_WindowId(winPtr);
event.xany.display = Tk_Display(winPtr);
event.type = Expose;
- event.xexpose.x = damageBounds.origin.x - bounds.origin.x;
- event.xexpose.y = damageBounds.origin.y - bounds.origin.y;
+ event.xexpose.x = damageBounds.origin.x;
+ event.xexpose.y = damageBounds.origin.y;
event.xexpose.width = damageBounds.size.width;
event.xexpose.height = damageBounds.size.height;
event.xexpose.count = 0;
diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test
index e85f512..e93dab4 100644
--- a/tests/imgPhoto.test
+++ b/tests/imgPhoto.test
@@ -797,6 +797,23 @@ test imgPhoto-4.73 {ImgPhotoCmd procedure: copy with -compositingrule} -setup {
} -cleanup {
image delete photo1 photo2
} -result {0,2 1,1 2,0}
+test imgPhoto-4.74 {ImgPhotoCmd procedure: put option error handling} -setup {
+ image create photo photo1
+} -body {
+ photo1 put {{white}} -to 10 10 20 20 {{white}}
+} -cleanup {
+ image delete photo1
+} -returnCodes 1 -result {wrong # args: should be "photo1 put data ?-option value ...?"}
+test imgPhoto-4.75 {<photo> read command: filename starting with '-'} -constraints {
+ hasTeapotPhoto
+} -body {
+ file copy -force $teapotPhotoFile -teapotPhotoFile
+ image create photo photo1
+ photo1 read -teapotPhotoFile
+} -cleanup {
+ image delete photo1
+ file delete ./-teapotPhotoFile
+} -result {}
test imgPhoto-5.1 {ImgPhotoGet/Free procedures, shared instances} -constraints {
hasTeapotPhoto
diff --git a/tests/textDisp.test b/tests/textDisp.test
index d3de2d8..8342c46 100644
--- a/tests/textDisp.test
+++ b/tests/textDisp.test
@@ -1952,13 +1952,15 @@ test textDisp-15.8 {Scrolling near end of window} {
.tf.f.t insert end "\nLine $i"
}
update ; after 1000 ; update
+ set refind [.tf.f.t index @0,[winfo height .tf.f.t]]
# Should scroll and should not crash!
.tf.f.t yview scroll 1 unit
# Check that it has scrolled
- set res [.tf.f.t index @0,[expr [winfo height .tf.f.t] - 15]]
+ set newind [.tf.f.t index @0,[winfo height .tf.f.t]]
+ set res [.tf.f.t compare $newind > $refind]
destroy .tf
set res
-} {12.0}
+} {1}
.t configure -wrap char
.t delete 1.0 end
diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c
index 200883f..929070b 100644
--- a/win/tkWinClipboard.c
+++ b/win/tkWinClipboard.c
@@ -414,16 +414,7 @@ UpdateClipboard(
OpenClipboard(hwnd);
EmptyClipboard();
- /*
- * CF_UNICODETEXT is only supported on NT, but it it is prefered when
- * possible.
- */
-
- if (TkWinGetPlatformId() != VER_PLATFORM_WIN32_WINDOWS) {
- SetClipboardData(CF_UNICODETEXT, NULL);
- } else {
- SetClipboardData(CF_TEXT, NULL);
- }
+ SetClipboardData(CF_UNICODETEXT, NULL);
CloseClipboard();
TkWinUpdatingClipboard(FALSE);
}
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index 860451b..f342f7c 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -262,16 +262,7 @@ void
TkpFontPkgInit(
TkMainInfo *mainPtr) /* The application being created. */
{
- if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) {
- /*
- * If running NT, then we will be calling some Unicode functions
- * explictly. So, even if the Tcl system encoding isn't Unicode, make
- * sure we convert to/from the Unicode char set.
- */
-
- systemEncoding = TkWinGetUnicodeEncoding();
- }
-
+ systemEncoding = TkWinGetUnicodeEncoding();
TkWinSetupSystemFonts(mainPtr);
}
@@ -760,14 +751,14 @@ TkpGetFontAttrsForChar(
* character */
FontFamily *familyPtr = thisSubFontPtr->familyPtr;
HFONT oldfont; /* Saved font from the device context */
- TEXTMETRICA tm; /* Font metrics of the selected subfont */
+ TEXTMETRIC tm; /* Font metrics of the selected subfont */
/*
* Get the font attributes.
*/
oldfont = SelectObject(hdc, thisSubFontPtr->hFont0);
- GetTextMetricsA(hdc, &tm);
+ GetTextMetrics(hdc, &tm);
SelectObject(hdc, oldfont);
ReleaseDC(fontPtr->hwnd, hdc);
faPtr->family = familyPtr->faceName;
@@ -1118,7 +1109,7 @@ Tk_DrawChars(
HBRUSH oldBrush, stipple;
HBITMAP oldBitmap, bitmap;
HDC dcMem;
- TEXTMETRICA tm;
+ TEXTMETRIC tm;
SIZE size;
if (twdPtr->type != TWD_BITMAP) {
@@ -1145,7 +1136,7 @@ Tk_DrawChars(
*/
GetTextExtentPointA(dcMem, source, numBytes, &size);
- GetTextMetricsA(dcMem, &tm);
+ GetTextMetrics(dcMem, &tm);
size.cx -= tm.tmOverhang;
bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
oldBitmap = SelectObject(dcMem, bitmap);
@@ -1184,7 +1175,7 @@ Tk_DrawChars(
} else {
HBITMAP oldBitmap, bitmap;
HDC dcMem;
- TEXTMETRICA tm;
+ TEXTMETRIC tm;
SIZE size;
dcMem = CreateCompatibleDC(dc);
@@ -1199,7 +1190,7 @@ Tk_DrawChars(
*/
GetTextExtentPointA(dcMem, source, numBytes, &size);
- GetTextMetricsA(dcMem, &tm);
+ GetTextMetrics(dcMem, &tm);
size.cx -= tm.tmOverhang;
bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
oldBitmap = SelectObject(dcMem, bitmap);
@@ -1266,7 +1257,7 @@ TkDrawAngledChars(
HBRUSH oldBrush, stipple;
HBITMAP oldBitmap, bitmap;
HDC dcMem;
- TEXTMETRICA tm;
+ TEXTMETRIC tm;
SIZE size;
if (twdPtr->type != TWD_BITMAP) {
@@ -1293,7 +1284,7 @@ TkDrawAngledChars(
*/
GetTextExtentPointA(dcMem, source, numBytes, &size);
- GetTextMetricsA(dcMem, &tm);
+ GetTextMetrics(dcMem, &tm);
size.cx -= tm.tmOverhang;
bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
oldBitmap = SelectObject(dcMem, bitmap);
@@ -1332,7 +1323,7 @@ TkDrawAngledChars(
} else {
HBITMAP oldBitmap, bitmap;
HDC dcMem;
- TEXTMETRICA tm;
+ TEXTMETRIC tm;
SIZE size;
dcMem = CreateCompatibleDC(dc);
@@ -1347,7 +1338,7 @@ TkDrawAngledChars(
*/
GetTextExtentPointA(dcMem, source, numBytes, &size);
- GetTextMetricsA(dcMem, &tm);
+ GetTextMetrics(dcMem, &tm);
size.cx -= tm.tmOverhang;
bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
oldBitmap = SelectObject(dcMem, bitmap);
@@ -1454,17 +1445,25 @@ MultiFontTextOut(
Tcl_DString runString;
const char *p, *end, *next;
SubFont *lastSubFontPtr, *thisSubFontPtr;
- TEXTMETRICA tm;
+ TEXTMETRIC tm;
lastSubFontPtr = &fontPtr->subFontArray[0];
oldFont = SelectFont(hdc, fontPtr, lastSubFontPtr, angle);
- GetTextMetricsA(hdc, &tm);
+ GetTextMetrics(hdc, &tm);
end = source + numBytes;
for (p = source; p < end; ) {
next = p + TkUtfToUniChar(p, &ch);
thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr);
- if (thisSubFontPtr != lastSubFontPtr) {
+
+ /*
+ * The drawing API has a limit of 32767 pixels in one go.
+ * To avoid spending time on a rare case we do not measure each char,
+ * instead we limit to drawing chunks of 200 bytes since that works
+ * well in practice.
+ */
+
+ if ((thisSubFontPtr != lastSubFontPtr) || (p-source > 200)) {
if (p > source) {
familyPtr = lastSubFontPtr->familyPtr;
Tcl_UtfToExternalDString(familyPtr->encoding, source,
@@ -1482,7 +1481,7 @@ MultiFontTextOut(
lastSubFontPtr = thisSubFontPtr;
source = p;
SelectFont(hdc, fontPtr, lastSubFontPtr, angle);
- GetTextMetricsA(hdc, &tm);
+ GetTextMetrics(hdc, &tm);
}
p = next;
}
@@ -1560,7 +1559,7 @@ InitFont(
HDC hdc;
HWND hwnd;
HFONT oldFont;
- TEXTMETRICA tm;
+ TEXTMETRIC tm;
Window window;
TkFontMetrics *fmPtr;
Tcl_Encoding encoding;
@@ -1573,7 +1572,7 @@ InitFont(
hdc = GetDC(hwnd);
oldFont = SelectObject(hdc, hFont);
- GetTextMetricsA(hdc, &tm);
+ GetTextMetrics(hdc, &tm);
/*
* On any version NT, there may fonts with international names. Use the
diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c
index 8e14669..3cf7c10 100644
--- a/win/tkWinMenu.c
+++ b/win/tkWinMenu.c
@@ -900,7 +900,7 @@ TkWinMenuProc(
LRESULT lResult;
if (!TkWinHandleMenuEvent(&hwnd, &message, &wParam, &lParam, &lResult)) {
- lResult = DefWindowProcA(hwnd, message, wParam, lParam);
+ lResult = DefWindowProc(hwnd, message, wParam, lParam);
}
return lResult;
}
@@ -999,7 +999,7 @@ TkWinEmbeddedMenuProc(
}
default:
- lResult = DefWindowProcA(hwnd, message, wParam, lParam);
+ lResult = DefWindowProc(hwnd, message, wParam, lParam);
break;
}
return lResult;
@@ -2036,33 +2036,33 @@ TkWinMenuKeyObjCmd(
if (eventPtr->type == KeyPress) {
switch (keySym) {
case XK_Alt_L:
- scanCode = MapVirtualKeyA(VK_LMENU, 0);
- CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)),
+ scanCode = MapVirtualKey(VK_LMENU, 0);
+ CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)),
WM_SYSKEYDOWN, VK_MENU,
(int) (scanCode << 16) | (1 << 29));
break;
case XK_Alt_R:
- scanCode = MapVirtualKeyA(VK_RMENU, 0);
- CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)),
+ scanCode = MapVirtualKey(VK_RMENU, 0);
+ CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)),
WM_SYSKEYDOWN, VK_MENU,
(int) (scanCode << 16) | (1 << 29) | (1 << 24));
break;
case XK_F10:
- scanCode = MapVirtualKeyA(VK_F10, 0);
- CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)),
+ scanCode = MapVirtualKey(VK_F10, 0);
+ CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)),
WM_SYSKEYDOWN, VK_F10, (int) (scanCode << 16));
break;
default:
virtualKey = XKeysymToKeycode(winPtr->display, keySym);
- scanCode = MapVirtualKeyA(virtualKey, 0);
+ scanCode = MapVirtualKey(virtualKey, 0);
if (0 != scanCode) {
XKeyEvent xkey = eventPtr->xkey;
- CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)),
+ CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)),
WM_SYSKEYDOWN, virtualKey,
(int) ((scanCode << 16) | (1 << 29)));
if (xkey.nbytes > 0) {
for (i = 0; i < xkey.nbytes; i++) {
- CallWindowProcA(DefWindowProcA,
+ CallWindowProc(DefWindowProc,
Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSCHAR,
xkey.trans_chars[i],
(int) ((scanCode << 16) | (1 << 29)));
@@ -2073,28 +2073,28 @@ TkWinMenuKeyObjCmd(
} else if (eventPtr->type == KeyRelease) {
switch (keySym) {
case XK_Alt_L:
- scanCode = MapVirtualKeyA(VK_LMENU, 0);
- CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)),
+ scanCode = MapVirtualKey(VK_LMENU, 0);
+ CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)),
WM_SYSKEYUP, VK_MENU, (int) (scanCode << 16)
| (1 << 29) | (1 << 30) | (1 << 31));
break;
case XK_Alt_R:
- scanCode = MapVirtualKeyA(VK_RMENU, 0);
- CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)),
+ scanCode = MapVirtualKey(VK_RMENU, 0);
+ CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)),
WM_SYSKEYUP, VK_MENU, (int) (scanCode << 16) | (1 << 24)
| (0x111 << 29) | (1 << 30) | (1 << 31));
break;
case XK_F10:
- scanCode = MapVirtualKeyA(VK_F10, 0);
- CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)),
+ scanCode = MapVirtualKey(VK_F10, 0);
+ CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)),
WM_SYSKEYUP, VK_F10,
(int) (scanCode << 16) | (1 << 30) | (1 << 31));
break;
default:
virtualKey = XKeysymToKeycode(winPtr->display, keySym);
- scanCode = MapVirtualKeyA(virtualKey, 0);
+ scanCode = MapVirtualKey(virtualKey, 0);
if (0 != scanCode) {
- CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)),
+ CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)),
WM_SYSKEYUP, virtualKey, (int) ((scanCode << 16)
| (1 << 29) | (1 << 30) | (1 << 31)));
}
@@ -3199,7 +3199,7 @@ SetDefaults(
HDC scratchDC;
int bold = 0;
int italic = 0;
- TEXTMETRICA tm;
+ TEXTMETRIC tm;
int pointSize;
HFONT menuFont;
/* See: [Bug #3239768] tk8.4.19 (and later) WIN32 menu font support */
@@ -3239,7 +3239,7 @@ SetDefaults(
&nc.metrics, 0);
menuFont = CreateFontIndirect(&nc.metrics.lfMenuFont);
SelectObject(scratchDC, menuFont);
- GetTextMetricsA(scratchDC, &tm);
+ GetTextMetrics(scratchDC, &tm);
GetTextFaceA(scratchDC, LF_FACESIZE, faceName);
pointSize = MulDiv(tm.tmHeight - tm.tmInternalLeading,
72, GetDeviceCaps(scratchDC, LOGPIXELSY));
@@ -3295,9 +3295,7 @@ SetDefaults(
*/
showMenuAccelerators = TRUE;
- if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) {
- SystemParametersInfoA(SPI_GETKEYBOARDCUES, 0, &showMenuAccelerators, 0);
- }
+ SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &showMenuAccelerators, 0);
}
/*