summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroehhar <harald.oehlmann@elmicron.de>2020-06-06 18:27:24 (GMT)
committeroehhar <harald.oehlmann@elmicron.de>2020-06-06 18:27:24 (GMT)
commit7b5473e2d5212bcdd88676417c66300f3308f18c (patch)
treeda83eb83f24219ec869921a82837bbbb7f78ce5d
parentbfcb4bfc8122be5094ac6354dc03145e6b123908 (diff)
parent9017a71055f5441adf6512571efb0b4b832d13bb (diff)
downloadtk-7b5473e2d5212bcdd88676417c66300f3308f18c.zip
tk-7b5473e2d5212bcdd88676417c66300f3308f18c.tar.gz
tk-7b5473e2d5212bcdd88676417c66300f3308f18c.tar.bz2
Merge trunk
-rw-r--r--generic/tk.h41
-rw-r--r--generic/tkCanvLine.c12
-rw-r--r--generic/tkCanvPoly.c16
-rw-r--r--generic/tkCanvText.c26
-rw-r--r--generic/tkCanvas.c4
-rw-r--r--generic/tkFont.c10
-rw-r--r--generic/tkInt.decls8
-rw-r--r--generic/tkIntDecls.h36
-rw-r--r--generic/tkListbox.c4
-rw-r--r--generic/tkStubInit.c20
-rw-r--r--generic/tkText.c56
-rw-r--r--generic/tkTextDisp.c40
-rw-r--r--generic/ttk/ttkEntry.c24
-rw-r--r--generic/ttk/ttkNotebook.c48
-rw-r--r--macosx/tkMacOSXInt.h2
-rw-r--r--macosx/tkMacOSXSubwindows.c8
-rw-r--r--macosx/tkMacOSXWindowEvent.c35
-rw-r--r--macosx/tkMacOSXWm.c34
-rw-r--r--unix/tkUnixPort.h2
-rw-r--r--win/tkWinPort.h7
-rw-r--r--win/ttkWinXPTheme.c2
21 files changed, 265 insertions, 170 deletions
diff --git a/generic/tk.h b/generic/tk.h
index cd16ce0..183bce9 100644
--- a/generic/tk.h
+++ b/generic/tk.h
@@ -1047,13 +1047,17 @@ typedef struct Tk_Item {
* lines, circles, etc.) that can form part of a canvas widget.
*/
-#ifdef USE_OLD_CANVAS
+#if defined(USE_OLD_CANVAS) && TCL_MAJOR_VERSION < 9
typedef int (Tk_ItemCreateProc)(Tcl_Interp *interp, Tk_Canvas canvas,
Tk_Item *itemPtr, int argc, char **argv);
typedef int (Tk_ItemConfigureProc)(Tcl_Interp *interp, Tk_Canvas canvas,
Tk_Item *itemPtr, int argc, char **argv, int flags);
typedef int (Tk_ItemCoordProc)(Tcl_Interp *interp, Tk_Canvas canvas,
Tk_Item *itemPtr, int argc, char **argv);
+typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
+ int beforeThis, char *string);
+typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas,
+ Tk_Item *itemPtr, char *indexString, int *indexPtr);
#else
typedef int (Tk_ItemCreateProc)(Tcl_Interp *interp, Tk_Canvas canvas,
Tk_Item *itemPtr, int argc, Tcl_Obj *const objv[]);
@@ -1062,6 +1066,17 @@ typedef int (Tk_ItemConfigureProc)(Tcl_Interp *interp, Tk_Canvas canvas,
int flags);
typedef int (Tk_ItemCoordProc)(Tcl_Interp *interp, Tk_Canvas canvas,
Tk_Item *itemPtr, int argc, Tcl_Obj *const argv[]);
+#if TCL_MAJOR_VERSION > 8
+typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
+ size_t beforeThis, Tcl_Obj *string);
+typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas,
+ Tk_Item *itemPtr, Tcl_Obj *indexString, size_t *indexPtr);
+#else
+typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
+ int beforeThis, Tcl_Obj *string);
+typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas,
+ Tk_Item *itemPtr, Tcl_Obj *indexString, int *indexPtr);
+#endif
#endif /* USE_OLD_CANVAS */
typedef void (Tk_ItemDeleteProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
Display *display);
@@ -1081,39 +1096,21 @@ typedef void (Tk_ItemScaleProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
double scaleY);
typedef void (Tk_ItemTranslateProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
double deltaX, double deltaY);
-#ifdef USE_OLD_CANVAS
-typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas,
- Tk_Item *itemPtr, char *indexString, int *indexPtr);
-#elif TCL_MAJOR_VERSION > 8
-typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas,
- Tk_Item *itemPtr, Tcl_Obj *indexString, size_t *indexPtr);
-#else
-typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas,
- Tk_Item *itemPtr, Tcl_Obj *indexString, int *indexPtr);
-#endif /* USE_OLD_CANVAS */
#if TCL_MAJOR_VERSION > 8
typedef void (Tk_ItemCursorProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
size_t index);
typedef size_t (Tk_ItemSelectionProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
size_t offset, char *buffer, size_t maxBytes);
+typedef void (Tk_ItemDCharsProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
+ size_t first, size_t last);
#else
typedef void (Tk_ItemCursorProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
int index);
typedef int (Tk_ItemSelectionProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
int offset, char *buffer, int maxBytes);
-#endif
-#ifdef USE_OLD_CANVAS
-typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
- int beforeThis, char *string);
-#elif TCL_MAJOR_VERSION > 8
-typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
- size_t beforeThis, Tcl_Obj *string);
-#else
-typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
- int beforeThis, Tcl_Obj *string);
-#endif /* USE_OLD_CANVAS */
typedef void (Tk_ItemDCharsProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
int first, int last);
+#endif
#ifndef __NO_OLD_CONFIG
diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c
index 484f41c..88ddc97 100644
--- a/generic/tkCanvLine.c
+++ b/generic/tkCanvLine.c
@@ -97,7 +97,7 @@ static int LineCoords(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr,
int objc, Tcl_Obj *const objv[]);
static void LineDeleteCoords(Tk_Canvas canvas,
- Tk_Item *itemPtr, int first, int last);
+ Tk_Item *itemPtr, TkSizeT first, TkSizeT last);
static void LineInsert(Tk_Canvas canvas,
Tk_Item *itemPtr, TkSizeT beforeThis, Tcl_Obj *obj);
static int LineToArea(Tk_Canvas canvas,
@@ -1153,8 +1153,8 @@ static void
LineDeleteCoords(
Tk_Canvas canvas, /* Canvas containing itemPtr. */
Tk_Item *itemPtr, /* Item in which to delete characters. */
- int first, /* Index of first character to delete. */
- int last) /* Index of last character to delete. */
+ TkSizeT first, /* Index of first character to delete. */
+ TkSizeT last) /* Index of last character to delete. */
{
LineItem *linePtr = (LineItem *) itemPtr;
int count, i, first1, last1;
@@ -1169,13 +1169,13 @@ LineDeleteCoords(
first &= -2;
last &= -2;
- if (first < 0) {
+ if ((int)first < 0) {
first = 0;
}
- if (last >= length) {
+ if ((int)last >= length) {
last = length-2;
}
- if (first > last) {
+ if ((int)first > (int)last) {
return;
}
if (linePtr->firstArrowPtr != NULL) {
diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c
index f4f0163..88f63e8 100644
--- a/generic/tkCanvPoly.c
+++ b/generic/tkCanvPoly.c
@@ -168,7 +168,7 @@ static int PolygonCoords(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr,
int objc, Tcl_Obj *const objv[]);
static void PolygonDeleteCoords(Tk_Canvas canvas,
- Tk_Item *itemPtr, int first, int last);
+ Tk_Item *itemPtr, TkSizeT first, TkSizeT last);
static void PolygonInsert(Tk_Canvas canvas,
Tk_Item *itemPtr, TkSizeT beforeThis, Tcl_Obj *obj);
static int PolygonToArea(Tk_Canvas canvas,
@@ -1172,23 +1172,23 @@ static void
PolygonDeleteCoords(
Tk_Canvas canvas, /* Canvas containing itemPtr. */
Tk_Item *itemPtr, /* Item in which to delete characters. */
- int first, /* Index of first character to delete. */
- int last) /* Index of last character to delete. */
+ TkSizeT first, /* Index of first character to delete. */
+ TkSizeT last) /* Index of last character to delete. */
{
PolygonItem *polyPtr = (PolygonItem *) itemPtr;
int count, i;
int length = 2*(polyPtr->numPoints - polyPtr->autoClosed);
- while (first >= length) {
+ while ((int)first >= length) {
first -= length;
}
- while (first < 0) {
+ while ((int)first < 0) {
first += length;
}
- while (last >= length) {
+ while ((int)last >= length) {
last -= length;
}
- while (last < 0) {
+ while ((int)last < 0) {
last += length;
}
@@ -1215,7 +1215,7 @@ PolygonDeleteCoords(
polyPtr->coordPtr[i-count] = polyPtr->coordPtr[i];
}
} else {
- for (i=last; i<=first; i++) {
+ for (i=last; i<=(int)first; i++) {
polyPtr->coordPtr[i-last] = polyPtr->coordPtr[i];
}
}
diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c
index 1c8bc04..304e009 100644
--- a/generic/tkCanvText.c
+++ b/generic/tkCanvText.c
@@ -161,7 +161,7 @@ static int TextCoords(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr,
int argc, Tcl_Obj *const objv[]);
static void TextDeleteChars(Tk_Canvas canvas,
- Tk_Item *itemPtr, int first, int last);
+ Tk_Item *itemPtr, TkSizeT first, TkSizeT last);
static void TextInsert(Tk_Canvas canvas,
Tk_Item *itemPtr, TkSizeT beforeThis, Tcl_Obj *obj);
static int TextToArea(Tk_Canvas canvas,
@@ -960,7 +960,7 @@ DisplayCanvText(
* anti-aliasing colors would blend together.
*/
- if ((selFirstChar >= 0) && (textPtr->selTextGC != textPtr->gc)) {
+ if ((selFirstChar != TCL_INDEX_NONE) && (textPtr->selTextGC != textPtr->gc)) {
if (0 < selFirstChar) {
TkDrawAngledTextLayout(display, drawable, textPtr->gc,
textPtr->textLayout, drawableX, drawableY, textPtr->angle,
@@ -1091,9 +1091,9 @@ static void
TextDeleteChars(
Tk_Canvas canvas, /* Canvas containing itemPtr. */
Tk_Item *itemPtr, /* Item in which to delete characters. */
- int first, /* Character index of first character to
+ TkSizeT first, /* Character index of first character to
* delete. */
- int last) /* Character index of last character to delete
+ TkSizeT last) /* Character index of last character to delete
* (inclusive). */
{
TextItem *textPtr = (TextItem *) itemPtr;
@@ -1102,13 +1102,13 @@ TextDeleteChars(
Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr;
text = textPtr->text;
- if (first < 0) {
+ if ((int)first < 0) {
first = 0;
}
- if (last >= (int)textPtr->numChars) {
+ if (last + 1 >= textPtr->numChars + 1) {
last = textPtr->numChars - 1;
}
- if (first > last) {
+ if (first + 1 > last + 1) {
return;
}
charsRemoved = last + 1 - first;
@@ -1132,15 +1132,15 @@ TextDeleteChars(
*/
if (textInfoPtr->selItemPtr == itemPtr) {
- if (textInfoPtr->selectFirst + 1 > (TkSizeT)first + 1) {
+ if (textInfoPtr->selectFirst + 1 > first + 1) {
textInfoPtr->selectFirst -= charsRemoved;
if ((int)textInfoPtr->selectFirst + 1 < (int)first + 1) {
textInfoPtr->selectFirst = first;
}
}
- if (textInfoPtr->selectLast + 1 >= (TkSizeT)first + 1) {
+ if (textInfoPtr->selectLast + 1 >= first + 1) {
textInfoPtr->selectLast -= charsRemoved;
- if (textInfoPtr->selectLast + 1 < (TkSizeT)first) {
+ if (textInfoPtr->selectLast + 1 < first) {
textInfoPtr->selectLast = first - 1;
}
}
@@ -1148,14 +1148,14 @@ TextDeleteChars(
textInfoPtr->selItemPtr = NULL;
}
if ((textInfoPtr->anchorItemPtr == itemPtr)
- && (textInfoPtr->selectAnchor + 1 > (TkSizeT)first + 1)) {
+ && (textInfoPtr->selectAnchor + 1 > first + 1)) {
textInfoPtr->selectAnchor -= charsRemoved;
- if (textInfoPtr->selectAnchor + 1 < (TkSizeT)first + 1) {
+ if (textInfoPtr->selectAnchor + 1 < first + 1) {
textInfoPtr->selectAnchor = first;
}
}
}
- if (textPtr->insertPos + 1 > (TkSizeT)first + 1) {
+ if (textPtr->insertPos + 1 > first + 1) {
textPtr->insertPos -= charsRemoved;
if ((int)textPtr->insertPos + 1 < (int)first + 1) {
textPtr->insertPos = first;
diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c
index 51238a0..89e7f3f 100644
--- a/generic/tkCanvas.c
+++ b/generic/tkCanvas.c
@@ -5849,8 +5849,8 @@ CanvasUpdateScrollbars(
Tcl_DString buf;
/*
- * Save all the relevant values from the canvasPtr, because it might be
- * deleted as part of either of the two calls to Tcl_VarEval below.
+ * Preserve the relevant values from the canvasPtr, because it might be
+ * deleted as part of either of the two calls to Tcl_EvalEx below.
*/
interp = canvasPtr->interp;
diff --git a/generic/tkFont.c b/generic/tkFont.c
index 34f8921..98a10f4 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.c
@@ -13,9 +13,7 @@
#include "tkInt.h"
#include "tkFont.h"
-#if defined(MAC_OSX_TK)
-#include "tkMacOSXInt.h"
-#endif
+
/*
* The following structure is used to keep track of all the fonts that exist
* in the current application. It must be stored in the TkMainInfo for the
@@ -875,18 +873,18 @@ TheWorldHasChanged(
ClientData clientData) /* Info about application's fonts. */
{
TkFontInfo *fiPtr = (TkFontInfo *)clientData;
-#if defined(MAC_OSX_TK)
/*
* On macOS it is catastrophic to recompute all widgets while the
* [NSView drawRect] method is drawing. The best that we can do in
* that situation is to abort the recomputation and hope for the best.
+ * This is ignored on other platforms.
*/
- if (TkpAppIsDrawing()) {
+ if (!TkpWillDrawWidget(NULL)) {
return;
}
-#endif
+
fiPtr->updatePending = 0;
RecomputeWidgets(fiPtr->mainPtr->winPtr);
}
diff --git a/generic/tkInt.decls b/generic/tkInt.decls
index b5e4d3c..df1e9b2 100644
--- a/generic/tkInt.decls
+++ b/generic/tkInt.decls
@@ -641,6 +641,14 @@ declare 185 {
Tcl_Obj *formatString, int *widthPtr, int *heightPtr)
}
+# Support for aqua's inability to draw outside [NSView drawRect:]
+declare 186 aqua {
+ void TkpRedrawWidget(Tk_Window tkwin)
+}
+declare 187 aqua {
+ int TkpWillDrawWidget(Tk_Window tkwin)
+}
+
##############################################################################
diff --git a/generic/tkIntDecls.h b/generic/tkIntDecls.h
index 619e3cf..886964d 100644
--- a/generic/tkIntDecls.h
+++ b/generic/tkIntDecls.h
@@ -562,6 +562,14 @@ EXTERN void TkDrawAngledChars(Display *display,
EXTERN int TkDebugPhotoStringMatchDef(Tcl_Interp *inter,
Tcl_Obj *data, Tcl_Obj *formatString,
int *widthPtr, int *heightPtr);
+#ifdef MAC_OSX_TK /* AQUA */
+/* 186 */
+EXTERN void TkpRedrawWidget(Tk_Window tkwin);
+#endif /* AQUA */
+#ifdef MAC_OSX_TK /* AQUA */
+/* 187 */
+EXTERN int TkpWillDrawWidget(Tk_Window tkwin);
+#endif /* AQUA */
typedef struct TkIntStubs {
int magic;
@@ -780,6 +788,26 @@ typedef struct TkIntStubs {
int (*tkIntersectAngledTextLayout) (Tk_TextLayout layout, int x, int y, int width, int height, double angle); /* 183 */
void (*tkDrawAngledChars) (Display *display, Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int numBytes, double x, double y, double angle); /* 184 */
int (*tkDebugPhotoStringMatchDef) (Tcl_Interp *inter, Tcl_Obj *data, Tcl_Obj *formatString, int *widthPtr, int *heightPtr); /* 185 */
+#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* X11 */
+ void (*reserved186)(void);
+#endif /* X11 */
+#if defined(_WIN32) /* WIN */
+ void (*reserved186)(void);
+#endif /* WIN */
+#ifdef MAC_OSX_TK /* AQUA */
+ void (*reserved186)(void); /* Dummy entry for stubs table backwards compatibility */
+ void (*tkpRedrawWidget) (Tk_Window tkwin); /* 186 */
+#endif /* AQUA */
+#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* X11 */
+ void (*reserved187)(void);
+#endif /* X11 */
+#if defined(_WIN32) /* WIN */
+ void (*reserved187)(void);
+#endif /* WIN */
+#ifdef MAC_OSX_TK /* AQUA */
+ void (*reserved187)(void); /* Dummy entry for stubs table backwards compatibility */
+ int (*tkpWillDrawWidget) (Tk_Window tkwin); /* 187 */
+#endif /* AQUA */
} TkIntStubs;
extern const TkIntStubs *tkIntStubsPtr;
@@ -1154,6 +1182,14 @@ extern const TkIntStubs *tkIntStubsPtr;
(tkIntStubsPtr->tkDrawAngledChars) /* 184 */
#define TkDebugPhotoStringMatchDef \
(tkIntStubsPtr->tkDebugPhotoStringMatchDef) /* 185 */
+#ifdef MAC_OSX_TK /* AQUA */
+#define TkpRedrawWidget \
+ (tkIntStubsPtr->tkpRedrawWidget) /* 186 */
+#endif /* AQUA */
+#ifdef MAC_OSX_TK /* AQUA */
+#define TkpWillDrawWidget \
+ (tkIntStubsPtr->tkpWillDrawWidget) /* 187 */
+#endif /* AQUA */
#endif /* defined(USE_TK_STUBS) */
diff --git a/generic/tkListbox.c b/generic/tkListbox.c
index d190adc..99a5be3 100644
--- a/generic/tkListbox.c
+++ b/generic/tkListbox.c
@@ -3324,7 +3324,7 @@ ListboxUpdateVScrollbar(
/*
* We must hold onto the interpreter from the listPtr because the data at
- * listPtr might be freed as a result of the Tcl_VarEval.
+ * listPtr might be freed as a result of the Tcl_EvalEx.
*/
interp = listPtr->interp;
@@ -3396,7 +3396,7 @@ ListboxUpdateHScrollbar(
/*
* We must hold onto the interpreter because the data referred to at
- * listPtr might be freed as a result of the call to Tcl_VarEval.
+ * listPtr might be freed as a result of the call to Tcl_EvalEx.
*/
interp = listPtr->interp;
diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c
index e52d404..dea8fd6 100644
--- a/generic/tkStubInit.c
+++ b/generic/tkStubInit.c
@@ -495,6 +495,26 @@ static const TkIntStubs tkIntStubs = {
TkIntersectAngledTextLayout, /* 183 */
TkDrawAngledChars, /* 184 */
TkDebugPhotoStringMatchDef, /* 185 */
+#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* X11 */
+ 0, /* 186 */
+#endif /* X11 */
+#if defined(_WIN32) /* WIN */
+ 0, /* 186 */
+#endif /* WIN */
+#ifdef MAC_OSX_TK /* AQUA */
+ 0, /* 186 */ /* Dummy entry for stubs table backwards compatibility */
+ TkpRedrawWidget, /* 186 */
+#endif /* AQUA */
+#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* X11 */
+ 0, /* 187 */
+#endif /* X11 */
+#if defined(_WIN32) /* WIN */
+ 0, /* 187 */
+#endif /* WIN */
+#ifdef MAC_OSX_TK /* AQUA */
+ 0, /* 187 */ /* Dummy entry for stubs table backwards compatibility */
+ TkpWillDrawWidget, /* 187 */
+#endif /* AQUA */
};
static const TkIntPlatStubs tkIntPlatStubs = {
diff --git a/generic/tkText.c b/generic/tkText.c
index 0c4d74c..39be0b7 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -279,10 +279,10 @@ typedef ClientData SearchAddLineProc(int lineNum,
typedef int SearchMatchProc(int lineNum,
struct SearchSpec *searchSpecPtr,
ClientData clientData, Tcl_Obj *theLine,
- int matchOffset, int matchLength);
+ TkSizeT matchOffset, TkSizeT matchLength);
typedef int SearchLineIndexProc(Tcl_Interp *interp,
Tcl_Obj *objPtr, struct SearchSpec *searchSpecPtr,
- int *linePosPtr, int *offsetPosPtr);
+ int *linePosPtr, TkSizeT *offsetPosPtr);
typedef struct SearchSpec {
int exact; /* Whether search is exact or regexp. */
@@ -298,10 +298,10 @@ typedef struct SearchSpec {
int all; /* Whether all or the first match should be
* reported. */
int startLine; /* First line to examine. */
- int startOffset; /* Index in first line to start at. */
+ TkSizeT startOffset1; /* Index in first line to start at. */
int stopLine; /* Last line to examine, or -1 when we search
* all available text. */
- int stopOffset; /* Index to stop at, provided stopLine is not
+ TkSizeT stopOffset1; /* Index to stop at, provided stopLine is not
* -1. */
int numLines; /* Total lines which are available. */
int backwards; /* Searching forwards or backwards. */
@@ -410,8 +410,8 @@ static void TextPushUndoAction(TkText *textPtr,
Tcl_Obj *undoString, int insert,
const TkTextIndex *index1Ptr,
const TkTextIndex *index2Ptr);
-static int TextSearchIndexInLine(const SearchSpec *searchSpecPtr,
- TkTextLine *linePtr, int byteIndex);
+static TkSizeT TextSearchIndexInLine(const SearchSpec *searchSpecPtr,
+ TkTextLine *linePtr, TkSizeT byteIndex);
static int TextPeerCmd(TkText *textPtr, Tcl_Interp *interp,
int objc, Tcl_Obj *const objv[]);
static TkUndoProc TextUndoRedoCallback;
@@ -3425,7 +3425,8 @@ TextFetchSelection(
{
TkText *textPtr = (TkText *)clientData;
TkTextIndex eof;
- int count, chunkSize, offsetInSeg;
+ int count, chunkSize;
+ TkSizeT offsetInSeg;
TkTextSearch search;
TkTextSegment *segPtr;
@@ -3484,12 +3485,10 @@ TextFetchSelection(
*/
while (1) {
- TkSizeT offsetInSeg1;
if (maxBytes == 0) {
goto fetchDone;
}
- segPtr = TkTextIndexToSeg(&textPtr->selIndex, &offsetInSeg1);
- offsetInSeg = offsetInSeg1;
+ segPtr = TkTextIndexToSeg(&textPtr->selIndex, &offsetInSeg);
chunkSize = segPtr->size - offsetInSeg;
if (chunkSize > (int)maxBytes) {
chunkSize = (int)maxBytes;
@@ -4016,7 +4015,7 @@ TextSearchGetLineIndex(
Tcl_Obj *objPtr, /* Contains a textual index like "1.2" */
SearchSpec *searchSpecPtr, /* Contains other search parameters. */
int *linePosPtr, /* For returning the line number. */
- int *offsetPosPtr) /* For returning the text offset in the
+ TkSizeT *offsetPosPtr) /* For returning the text offset in the
* line. */
{
const TkTextIndex *indexPtr;
@@ -4076,35 +4075,36 @@ TextSearchGetLineIndex(
*----------------------------------------------------------------------
*/
-static int
+static TkSizeT
TextSearchIndexInLine(
const SearchSpec *searchSpecPtr,
/* Search parameters. */
TkTextLine *linePtr, /* The line we're looking at. */
- int byteIndex) /* Index into the line. */
+ TkSizeT byteIndex) /* Index into the line. */
{
TkTextSegment *segPtr;
TkTextIndex curIndex;
- int index, leftToScan;
+ TkSizeT index;
+ int leftToScan;
TkText *textPtr = (TkText *)searchSpecPtr->clientData;
index = 0;
curIndex.tree = textPtr->sharedTextPtr->tree;
curIndex.linePtr = linePtr; curIndex.byteIndex = 0;
for (segPtr = linePtr->segPtr, leftToScan = byteIndex;
- leftToScan > 0;
+ leftToScan + 1 > 1;
curIndex.byteIndex += segPtr->size, segPtr = segPtr->nextPtr) {
if ((segPtr->typePtr == &tkTextCharType) &&
(searchSpecPtr->searchElide
|| !TkTextIsElided(textPtr, &curIndex, NULL))) {
- if (leftToScan < (int)segPtr->size) {
+ if (leftToScan + 1 < (int)segPtr->size + 1) {
if (searchSpecPtr->exact) {
index += leftToScan;
} else {
index += Tcl_NumUtfChars(segPtr->body.chars, leftToScan);
}
} else if (searchSpecPtr->exact) {
- index += (int)segPtr->size;
+ index += segPtr->size;
} else {
index += Tcl_NumUtfChars(segPtr->body.chars, -1);
}
@@ -4268,9 +4268,9 @@ TextSearchFoundMatch(
Tcl_Obj *theLine, /* Text from current line, only accessed for
* exact searches, and is allowed to be NULL
* for regexp searches. */
- int matchOffset, /* Offset of found item in utf-8 bytes for
+ TkSizeT matchOffset, /* Offset of found item in utf-8 bytes for
* exact search, Unicode chars for regexp. */
- int matchLength) /* Length also in bytes/chars as per search
+ TkSizeT matchLength) /* Length also in bytes/chars as per search
* type. */
{
TkSizeT numChars;
@@ -4288,7 +4288,7 @@ TextSearchFoundMatch(
*/
if (searchSpecPtr->backwards ^
- (matchOffset >= searchSpecPtr->stopOffset)) {
+ (matchOffset + 1 >= searchSpecPtr->stopOffset1 + 1)) {
return 0;
}
}
@@ -4313,7 +4313,7 @@ TextSearchFoundMatch(
if (searchSpecPtr->strictLimits && lineNum == searchSpecPtr->stopLine) {
if (searchSpecPtr->backwards ^
- ((matchOffset + numChars + 1) > (TkSizeT) searchSpecPtr->stopOffset + 1)) {
+ ((matchOffset + numChars + 1) > searchSpecPtr->stopOffset1 + 1)) {
return 0;
}
}
@@ -5664,7 +5664,7 @@ SearchPerform(
if (searchSpecPtr->lineIndexProc(interp, fromPtr, searchSpecPtr,
&searchSpecPtr->startLine,
- &searchSpecPtr->startOffset) != TCL_OK) {
+ &searchSpecPtr->startOffset1) != TCL_OK) {
return TCL_ERROR;
}
@@ -5695,7 +5695,7 @@ SearchPerform(
if (searchSpecPtr->lineIndexProc(interp, toPtr, searchSpecPtr,
&searchSpecPtr->stopLine,
- &searchSpecPtr->stopOffset) != TCL_OK) {
+ &searchSpecPtr->stopOffset1) != TCL_OK) {
return TCL_ERROR;
}
} else {
@@ -5894,7 +5894,7 @@ SearchCore(
}
if (lineNum == searchSpecPtr->stopLine && searchSpecPtr->backwards) {
- firstOffset = searchSpecPtr->stopOffset;
+ firstOffset = searchSpecPtr->stopOffset1;
} else {
firstOffset = 0;
}
@@ -5928,8 +5928,8 @@ SearchCore(
* Only use the last part of the line.
*/
- if (searchSpecPtr->startOffset > firstOffset) {
- firstOffset = searchSpecPtr->startOffset;
+ if (searchSpecPtr->startOffset1 + 1 > (TkSizeT)firstOffset + 1) {
+ firstOffset = searchSpecPtr->startOffset1;
}
if ((firstOffset >= lastOffset)
&& ((lastOffset != 0) || searchSpecPtr->exact)) {
@@ -5940,8 +5940,8 @@ SearchCore(
* Use only the first part of the line.
*/
- if (searchSpecPtr->startOffset < lastOffset) {
- lastOffset = searchSpecPtr->startOffset;
+ if (searchSpecPtr->startOffset1 + 1 < (TkSizeT)lastOffset + 1) {
+ lastOffset = searchSpecPtr->startOffset1;
}
}
}
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 8acf115..61b0df0 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -16,13 +16,17 @@
#include "tkInt.h"
#include "tkText.h"
-#ifdef MAC_OSX_TK
+#ifdef _WIN32
+#include "tkWinInt.h"
+#elif defined(__CYGWIN__)
+#include "tkUnixInt.h"
+#elif defined(MAC_OSX_TK)
#include "tkMacOSXInt.h"
-#define OK_TO_LOG (!TkpAppIsDrawing())
-#define FORCE_DISPLAY(winPtr) TkpDisplayWindow(winPtr)
-#else
+#define OK_TO_LOG (!TkpWillDrawWidget(textPtr->tkwin))
+#endif
+
+#if !defined(MAC_OSX_TK)
#define OK_TO_LOG 1
-#define FORCE_DISPLAY(winPtr)
#endif
/*
@@ -3151,7 +3155,7 @@ GenerateWidgetViewSyncEvent(
*/
if (!tkTextDebug) {
- FORCE_DISPLAY(textPtr->tkwin);
+ TkpRedrawWidget(textPtr->tkwin);
}
if (NewSyncState != OldSyncState) {
@@ -4171,11 +4175,23 @@ DisplayText(
* warnings. */
Tcl_Interp *interp;
+
+ if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) {
+ /*
+ * The widget has been deleted. Don't do anything.
+ */
+
+ return;
+ }
+
#ifdef MAC_OSX_TK
/*
- * If drawing is disabled, all we need to do is
- * clear the REDRAW_PENDING flag.
+ * If the toplevel is being resized it would be dangerous to try redrawing
+ * the widget. But we can just clear the REDRAW_PENDING flag and return.
+ * This display proc will be called again after the widget has been
+ * reconfigured.
*/
+
TkWindow *winPtr = (TkWindow *)(textPtr->tkwin);
MacDrawable *macWin = winPtr->privatePtr;
if (macWin && (macWin->flags & TK_DO_NOT_DRAW)){
@@ -4184,14 +4200,6 @@ DisplayText(
}
#endif
- if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) {
- /*
- * The widget has been deleted. Don't do anything.
- */
-
- return;
- }
-
interp = textPtr->interp;
Tcl_Preserve(interp);
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c
index aedc384..cbc3b3f 100644
--- a/generic/ttk/ttkEntry.c
+++ b/generic/ttk/ttkEntry.c
@@ -1312,7 +1312,7 @@ static void EntryDisplay(void *clientData, Drawable d)
}
/* Use placeholder text width */
leftIndex = 0;
- TkGetStringFromObj(entryPtr->entry.placeholderObj, &rightIndex);
+ (void)TkGetStringFromObj(entryPtr->entry.placeholderObj, &rightIndex);
} else {
foregroundObj = es.foregroundObj;
}
@@ -1756,7 +1756,7 @@ typedef struct {
Tcl_Obj *postCommandObj;
Tcl_Obj *valuesObj;
Tcl_Obj *heightObj;
- int currentIndex;
+ TkSizeT currentIndex;
} ComboboxPart;
typedef struct {
@@ -1786,7 +1786,7 @@ ComboboxInitialize(Tcl_Interp *interp, void *recordPtr)
{
Combobox *cb = (Combobox *)recordPtr;
- cb->combobox.currentIndex = -1;
+ cb->combobox.currentIndex = TCL_INDEX_NONE;
TtkTrackElementState(&cb->core);
EntryInitialize(interp, recordPtr);
}
@@ -1818,35 +1818,35 @@ static int ComboboxCurrentCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
Combobox *cbPtr = (Combobox *)recordPtr;
- int currentIndex = cbPtr->combobox.currentIndex;
+ TkSizeT currentIndex = cbPtr->combobox.currentIndex;
const char *currentValue = cbPtr->entry.string;
int nValues;
Tcl_Obj **values;
- Tcl_ListObjGetElements(interp,cbPtr->combobox.valuesObj,&nValues,&values);
+ Tcl_ListObjGetElements(interp, cbPtr->combobox.valuesObj, &nValues, &values);
if (objc == 2) {
/* Check if currentIndex still valid:
*/
- if ( currentIndex < 0
- || currentIndex >= nValues
+ if ( currentIndex == TCL_INDEX_NONE
+ || currentIndex >= (TkSizeT)nValues
|| strcmp(currentValue,Tcl_GetString(values[currentIndex]))
)
{
/* Not valid. Check current value against each element in -values:
*/
- for (currentIndex = 0; currentIndex < nValues; ++currentIndex) {
+ for (currentIndex = 0; currentIndex < (TkSizeT)nValues; ++currentIndex) {
if (!strcmp(currentValue,Tcl_GetString(values[currentIndex]))) {
break;
}
}
- if (currentIndex >= nValues) {
+ if (currentIndex >= (TkSizeT)nValues) {
/* Not found */
- currentIndex = -1;
+ currentIndex = TCL_INDEX_NONE;
}
}
cbPtr->combobox.currentIndex = currentIndex;
- Tcl_SetObjResult(interp, Tcl_NewWideIntObj(currentIndex));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj((int)currentIndex));
return TCL_OK;
} else if (objc == 3) {
TkSizeT idx;
@@ -1858,7 +1858,7 @@ static int ComboboxCurrentCommand(
Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_RANGE", NULL);
return TCL_ERROR;
}
- currentIndex = (int)idx;
+ currentIndex = idx;
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"Incorrect index %s", Tcl_GetString(objv[2])));
diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c
index c17f255..7ad46a4 100644
--- a/generic/ttk/ttkNotebook.c
+++ b/generic/ttk/ttkNotebook.c
@@ -94,8 +94,8 @@ typedef struct
Ttk_Manager *mgr; /* Geometry manager */
Tk_OptionTable tabOptionTable; /* Tab options */
Tk_OptionTable paneOptionTable; /* Tab+pane options */
- int currentIndex; /* index of currently selected tab */
- int activeIndex; /* index of currently active tab */
+ TkSizeT currentIndex; /* index of currently selected tab */
+ TkSizeT activeIndex; /* index of currently active tab */
Ttk_Layout tabLayout; /* Sublayout for tabs */
Ttk_Box clientArea; /* Where to pack slave widgets */
@@ -272,7 +272,7 @@ static TkSizeT IdentifyTab(Notebook *nb, int x, int y)
* ActivateTab --
* Set the active tab index, redisplay if necessary.
*/
-static void ActivateTab(Notebook *nb, int index)
+static void ActivateTab(Notebook *nb, TkSizeT index)
{
if (index != nb->notebook.activeIndex) {
nb->notebook.activeIndex = index;
@@ -293,13 +293,13 @@ static Ttk_State TabState(Notebook *nb, TkSizeT index)
Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index);
TkSizeT i = 0;
- if ((int)index == nb->notebook.currentIndex) {
+ if (index == nb->notebook.currentIndex) {
state |= TTK_STATE_SELECTED;
} else {
state &= ~TTK_STATE_FOCUS;
}
- if ((int)index == nb->notebook.activeIndex) {
+ if (index == nb->notebook.activeIndex) {
state |= TTK_STATE_ACTIVE;
}
for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) {
@@ -589,8 +589,8 @@ static void NotebookPlaceSlave(Notebook *nb, TkSizeT slaveIndex)
static void NotebookPlaceSlaves(void *recordPtr)
{
Notebook *nb = (Notebook *)recordPtr;
- int currentIndex = nb->notebook.currentIndex;
- if (currentIndex >= 0) {
+ TkSizeT currentIndex = nb->notebook.currentIndex;
+ if (currentIndex != TCL_INDEX_NONE) {
NotebookDoLayout(nb);
NotebookPlaceSlave(nb, currentIndex);
}
@@ -700,11 +700,11 @@ static void TabRemoved(void *managerData, TkSizeT index)
Notebook *nb = (Notebook *)managerData;
Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index);
- if ((int)index == nb->notebook.currentIndex) {
+ if (index == nb->notebook.currentIndex) {
SelectNearestTab(nb);
}
- if ((int)index < nb->notebook.currentIndex) {
+ if (index + 1 < nb->notebook.currentIndex + 1) {
--nb->notebook.currentIndex;
}
@@ -728,7 +728,7 @@ static int TabRequest(void *managerData, TkSizeT index, int width, int height)
*/
static int AddTab(
Tcl_Interp *interp, Notebook *nb,
- int destIndex, Tk_Window slaveWindow,
+ TkSizeT destIndex, Tk_Window slaveWindow,
int objc, Tcl_Obj *const objv[])
{
Tab *tab;
@@ -759,9 +759,9 @@ static int AddTab(
/* Adjust indices and/or autoselect first tab:
*/
- if (nb->notebook.currentIndex < 0) {
+ if (nb->notebook.currentIndex == TCL_INDEX_NONE) {
SelectTab(nb, destIndex);
- } else if (nb->notebook.currentIndex >= destIndex) {
+ } else if (nb->notebook.currentIndex + 1 >= destIndex + 1) {
++nb->notebook.currentIndex;
}
@@ -940,7 +940,7 @@ static int NotebookInsertCommand(
{
Notebook *nb = (Notebook *)recordPtr;
TkSizeT current = nb->notebook.currentIndex;
- TkSizeT nSlaves1 = Ttk_NumberSlaves(nb->notebook.mgr);
+ TkSizeT nSlaves = Ttk_NumberSlaves(nb->notebook.mgr);
TkSizeT srcIndex, destIndex;
if (objc < 4) {
@@ -985,14 +985,14 @@ static int NotebookInsertCommand(
return TCL_ERROR;
}
- if (destIndex + 1 >= nSlaves1 + 1) {
- destIndex = nSlaves1 - 1;
+ if (destIndex + 1 >= nSlaves + 1) {
+ destIndex = nSlaves - 1;
}
Ttk_ReorderSlave(nb->notebook.mgr, srcIndex, destIndex);
/* Adjust internal indexes:
*/
- nb->notebook.activeIndex = -1;
+ nb->notebook.activeIndex = TCL_INDEX_NONE;
if (current == srcIndex) {
nb->notebook.currentIndex = destIndex;
} else if (destIndex + 1 <= current + 1 && current + 1 < srcIndex + 1) {
@@ -1051,7 +1051,7 @@ static int NotebookHideCommand(
tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index);
tab->state = TAB_STATE_HIDDEN;
- if (index == (TkSizeT)nb->notebook.currentIndex) {
+ if (index == nb->notebook.currentIndex) {
SelectNearestTab(nb);
}
@@ -1151,7 +1151,7 @@ static int NotebookSelectCommand(
Notebook *nb = (Notebook *)recordPtr;
if (objc == 2) {
- if (nb->notebook.currentIndex >= 0) {
+ if (nb->notebook.currentIndex != TCL_INDEX_NONE) {
Tk_Window pane = Ttk_SlaveWindow(
nb->notebook.mgr, nb->notebook.currentIndex);
Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(pane), -1));
@@ -1233,7 +1233,7 @@ static int NotebookTabCommand(
/* If the current tab has become disabled or hidden,
* select the next nondisabled, unhidden one:
*/
- if (index == (TkSizeT)nb->notebook.currentIndex && tab->state != TAB_STATE_NORMAL) {
+ if (index == nb->notebook.currentIndex && tab->state != TAB_STATE_NORMAL) {
SelectNearestTab(nb);
}
@@ -1273,8 +1273,8 @@ static void NotebookInitialize(Tcl_Interp *interp, void *recordPtr)
nb->notebook.tabOptionTable = Tk_CreateOptionTable(interp,TabOptionSpecs);
nb->notebook.paneOptionTable = Tk_CreateOptionTable(interp,PaneOptionSpecs);
- nb->notebook.currentIndex = -1;
- nb->notebook.activeIndex = -1;
+ nb->notebook.currentIndex = TCL_INDEX_NONE;
+ nb->notebook.activeIndex = TCL_INDEX_NONE;
nb->notebook.tabLayout = 0;
nb->notebook.clientArea = Ttk_MakeBox(0,0,1,1);
@@ -1359,8 +1359,8 @@ static void DisplayTab(Notebook *nb, int index, Drawable d)
static void NotebookDisplay(void *clientData, Drawable d)
{
Notebook *nb = (Notebook *)clientData;
- int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr);
- int index;
+ TkSizeT nSlaves = Ttk_NumberSlaves(nb->notebook.mgr);
+ TkSizeT index;
/* Draw notebook background (base layout):
*/
@@ -1374,7 +1374,7 @@ static void NotebookDisplay(void *clientData, Drawable d)
DisplayTab(nb, index, d);
}
}
- if (nb->notebook.currentIndex >= 0) {
+ if (nb->notebook.currentIndex != TCL_INDEX_NONE) {
DisplayTab(nb, nb->notebook.currentIndex, d);
}
}
diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h
index bd669c0..5d03746 100644
--- a/macosx/tkMacOSXInt.h
+++ b/macosx/tkMacOSXInt.h
@@ -196,8 +196,6 @@ MODULE_SCOPE void TkpClipDrawableToRect(Display *display, Drawable d, int x,
MODULE_SCOPE void TkpRetainRegion(Region r);
MODULE_SCOPE void TkpReleaseRegion(Region r);
MODULE_SCOPE void TkpShiftButton(NSButton *button, NSPoint delta);
-MODULE_SCOPE Bool TkpAppIsDrawing(void);
-MODULE_SCOPE void TkpDisplayWindow(Tk_Window tkwin);
MODULE_SCOPE Bool TkTestLogDisplay(void);
MODULE_SCOPE Bool TkMacOSXInDarkMode(Tk_Window tkwin);
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index 611afd7..52927ab 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.c
@@ -699,16 +699,10 @@ XConfigureWindow(
if (value_mask & CWStackMode) {
NSView *view = TkMacOSXDrawableView(macWin);
- Rect bounds;
- NSRect r;
if (view) {
TkMacOSXInvalClipRgns((Tk_Window) winPtr->parentPtr);
- TkMacOSXWinBounds(winPtr, &bounds);
- r = NSMakeRect(bounds.left,
- [view bounds].size.height - bounds.bottom,
- bounds.right - bounds.left, bounds.bottom - bounds.top);
- [view setNeedsDisplayInRect:r];
+ TkpRedrawWidget((Tk_Window) winPtr);
}
}
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index 71e687b..05e2ac2 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -394,26 +394,41 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
/*
*----------------------------------------------------------------------
*
- * TkpAppIsDrawing --
+ * TkpWillDrawWidget --
*
* A widget display procedure can call this to determine whether it is
- * being run inside of the drawRect method. This is needed for some tests,
- * especially of the Text widget, which record data in a global Tcl
- * variable and assume that display procedures will be run in a
- * predictable sequence as Tcl idle tasks.
+ * being run inside of the drawRect method. If not, it may be desirable
+ * for the display procedure to simply clear the REDRAW_PENDING flag
+ * and return. The widget can be recorded in order to schedule a
+ * redraw, via and Expose event, from within drawRect.
+ *
+ * This is also needed for some tests, especially of the Text widget,
+ * which record data in a global Tcl variable and assume that display
+ * procedures will be run in a predictable sequence as Tcl idle tasks.
*
* Results:
- * True only while running the drawRect method of a TKContentView;
+ * True if called from the drawRect method of a TKContentView with
+ * tkwin NULL or pointing to a widget in the current focusView.
*
* Side effects:
- * None
+ * The tkwin parameter may be recorded to handle redrawing the widget
+ * later.
*
*----------------------------------------------------------------------
*/
-MODULE_SCOPE Bool
-TkpAppIsDrawing(void) {
- return [NSApp isDrawing];
+int
+TkpWillDrawWidget(Tk_Window tkwin) {
+ if (![NSApp isDrawing]) {
+ return 0;
+ }
+ if (tkwin) {
+ TkWindow *winPtr = (TkWindow *)tkwin;
+ NSView *view = TkMacOSXDrawableView(winPtr->privatePtr);
+ return (view == [NSView focusView]);
+ } else {
+ return 1;
+ }
}
/*
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index f24b8d4..98100e9 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -6173,28 +6173,40 @@ TkMacOSXMakeRealWindowExist(
/*
*----------------------------------------------------------------------
*
- * TkpDisplayWindow --
+ * TkpRedrawWidget --
*
- * Mark the contentView of this window as needing display so the window
- * will be drawn by the window manager. If this is called within the
- * drawRect method, do nothing.
+ * Mark the bounding rectangle of this widget as needing display so the
+ * widget will be drawn by [NSView drawRect:]. If this is called within
+ * the drawRect method, do nothing.
*
* Results:
* None.
*
* Side effects:
- * The window's contentView is marked as needing display.
+ * The widget's bounding rectangle is marked as dirty.
*
*----------------------------------------------------------------------
*/
-MODULE_SCOPE void
-TkpDisplayWindow(Tk_Window tkwin) {
- if (![NSApp isDrawing]) {
- TkWindow *winPtr = (TkWindow *) tkwin;
- NSWindow *w = TkMacOSXDrawableWindow(winPtr->window);
+void
+TkpRedrawWidget(Tk_Window tkwin) {
+ TkWindow *winPtr = (TkWindow *) tkwin;
+ NSWindow *w;
+ Rect tkBounds;
+ NSRect bounds;
- [[w contentView] setNeedsDisplay: YES];
+ if ([NSApp isDrawing]) {
+ return;
+ }
+ w = TkMacOSXDrawableWindow(winPtr->window);
+ if (w) {
+ NSView *view = [w contentView];
+ TkMacOSXWinBounds(winPtr, &tkBounds);
+ bounds = NSMakeRect(tkBounds.left,
+ [view bounds].size.height - tkBounds.bottom,
+ tkBounds.right - tkBounds.left,
+ tkBounds.bottom - tkBounds.top);
+ [view setNeedsDisplayInRect:bounds];
}
}
diff --git a/unix/tkUnixPort.h b/unix/tkUnixPort.h
index 347c9d8..a72c0fe 100644
--- a/unix/tkUnixPort.h
+++ b/unix/tkUnixPort.h
@@ -149,6 +149,8 @@
#define TkpButtonSetDefaults() {}
#define TkpDestroyButton(butPtr) {}
+#define TkpWillDrawWidget(tkwin) 1
+#define TkpRedrawWidget(tkwin)
#define TkSelUpdateClipboard(a,b) {}
#ifndef __CYGWIN__
#define TkSetPixmapColormap(p,c) {}
diff --git a/win/tkWinPort.h b/win/tkWinPort.h
index 11ecf21..880c952 100644
--- a/win/tkWinPort.h
+++ b/win/tkWinPort.h
@@ -129,4 +129,11 @@
#define TkpCreateNativeBitmap(display, source) None
#define TkpGetNativeAppBitmap(display, name, w, h) None
+/*
+ * Other functions not used under Windows
+ */
+
+#define TkpWillDrawWidget(tkwin) 1
+#define TkpRedrawWidget(tkwin)
+
#endif /* _WINPORT */
diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c
index fec0450..26807f7 100644
--- a/win/ttkWinXPTheme.c
+++ b/win/ttkWinXPTheme.c
@@ -506,7 +506,7 @@ static void GenericElementSize(
if (!(elementData->info->flags & IGNORE_THEMESIZE)) {
result = elementData->procs->GetThemePartSize(
elementData->hTheme,
- elementData->hDC,
+ NULL,
elementData->info->partId,
Ttk_StateTableLookup(elementData->info->statemap, 0),
NULL /*RECT *prc*/,