summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tk.h8
-rw-r--r--generic/tk3d.c18
-rw-r--r--generic/tk3d.h4
-rw-r--r--generic/tkBind.c4
-rw-r--r--generic/tkBusy.c9
-rw-r--r--generic/tkButton.c32
-rw-r--r--generic/tkButton.h2
-rw-r--r--generic/tkCanvArc.c40
-rw-r--r--generic/tkCanvBmap.c6
-rw-r--r--generic/tkCanvImg.c2
-rw-r--r--generic/tkCanvLine.c12
-rw-r--r--generic/tkCanvPoly.c38
-rw-r--r--generic/tkCanvText.c26
-rw-r--r--generic/tkCanvUtil.c4
-rw-r--r--generic/tkCanvas.c19
-rw-r--r--generic/tkCanvas.h2
-rw-r--r--generic/tkColor.c10
-rw-r--r--generic/tkColor.h2
-rw-r--r--generic/tkConfig.c12
-rw-r--r--generic/tkCursor.c6
-rw-r--r--generic/tkEntry.c38
-rw-r--r--generic/tkEntry.h4
-rw-r--r--generic/tkEvent.c4
-rw-r--r--generic/tkFocus.c70
-rw-r--r--generic/tkFrame.c8
-rw-r--r--generic/tkGrab.c7
-rw-r--r--generic/tkImage.c2
-rw-r--r--generic/tkImgBmap.c14
-rw-r--r--generic/tkImgGIF.c1
-rw-r--r--generic/tkImgPhInstance.c2
-rw-r--r--generic/tkInt.decls2
-rw-r--r--generic/tkIntPlatDecls.h4
-rw-r--r--generic/tkListbox.c16
-rw-r--r--generic/tkMain.c4
-rw-r--r--generic/tkMenu.c27
-rw-r--r--generic/tkMenu.h14
-rw-r--r--generic/tkMenuDraw.c126
-rw-r--r--generic/tkMenubutton.c26
-rw-r--r--generic/tkMenubutton.h2
-rw-r--r--generic/tkMessage.c10
-rw-r--r--generic/tkOldConfig.c12
-rw-r--r--generic/tkPanedWindow.c16
-rw-r--r--generic/tkPlace.c8
-rw-r--r--generic/tkRectOval.c39
-rw-r--r--generic/tkScale.c63
-rw-r--r--generic/tkScale.h5
-rw-r--r--generic/tkScrollbar.c2
-rw-r--r--generic/tkScrollbar.h2
-rw-r--r--generic/tkSquare.c6
-rw-r--r--generic/tkText.c17
-rw-r--r--generic/tkText.h6
-rw-r--r--generic/tkTextDisp.c112
-rw-r--r--generic/tkTextTag.c2
-rw-r--r--generic/tkWindow.c2
-rw-r--r--generic/ttk/ttkClassicTheme.c2
-rw-r--r--generic/ttk/ttkDefaultTheme.c2
-rw-r--r--generic/ttk/ttkEntry.c12
-rw-r--r--generic/ttk/ttkLabel.c2
-rw-r--r--generic/ttk/ttkState.c6
59 files changed, 477 insertions, 476 deletions
diff --git a/generic/tk.h b/generic/tk.h
index 6f1c98a..f106f1c 100644
--- a/generic/tk.h
+++ b/generic/tk.h
@@ -587,7 +587,11 @@ typedef void (Tk_ClassWorldChangedProc) (ClientData instanceData);
typedef void (Tk_ClassModalProc) (Tk_Window tkwin, XEvent *eventPtr);
typedef struct Tk_ClassProcs {
+#if TCL_MAJOR_VERSION > 8
+ size_t size;
+#else
unsigned int size;
+#endif
Tk_ClassWorldChangedProc *worldChangedProc;
/* Procedure to invoke when the widget needs
* to respond in some way to a change in the
@@ -617,7 +621,7 @@ typedef struct Tk_ClassProcs {
#define Tk_GetClassProc(procs, which) \
(((procs) == NULL) ? NULL : \
- (((procs)->size <= Tk_Offset(Tk_ClassProcs, which)) ? NULL:(procs)->which))
+ (((procs)->size <= (size_t)Tk_Offset(Tk_ClassProcs, which)) ? NULL:(procs)->which))
/*
* Each geometry manager (the packer, the placer, etc.) is represented by a
@@ -1481,6 +1485,7 @@ typedef struct Tk_ElementSpec {
*----------------------------------------------------------------------
*/
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
#define TK_READABLE TCL_READABLE
#define TK_WRITABLE TCL_WRITABLE
#define TK_EXCEPTION TCL_EXCEPTION
@@ -1514,6 +1519,7 @@ typedef struct Tk_ElementSpec {
#define Tk_FreeProc Tcl_FreeProc
#define Tk_Preserve Tcl_Preserve
#define Tk_Release Tcl_Release
+#endif
/* Removed Tk_Main, use macro instead */
#if defined(_WIN32) || defined(__CYGWIN__)
diff --git a/generic/tk3d.c b/generic/tk3d.c
index 0fa061e..92a7803 100644
--- a/generic/tk3d.c
+++ b/generic/tk3d.c
@@ -236,9 +236,9 @@ Tk_Get3DBorder(
borderPtr->darkColorPtr = NULL;
borderPtr->lightColorPtr = NULL;
borderPtr->shadow = None;
- borderPtr->bgGC = None;
- borderPtr->darkGC = None;
- borderPtr->lightGC = None;
+ borderPtr->bgGC = NULL;
+ borderPtr->darkGC = NULL;
+ borderPtr->lightGC = NULL;
borderPtr->hashPtr = hashPtr;
borderPtr->nextPtr = existingBorderPtr;
Tcl_SetHashValue(hashPtr, borderPtr);
@@ -374,7 +374,7 @@ Tk_3DBorderGC(
{
TkBorder * borderPtr = (TkBorder *) border;
- if ((borderPtr->lightGC == None) && (which != TK_3D_FLAT_GC)) {
+ if ((borderPtr->lightGC == NULL) && (which != TK_3D_FLAT_GC)) {
TkpGetShadows(borderPtr, tkwin);
}
if (which == TK_3D_FLAT_GC) {
@@ -391,7 +391,7 @@ Tk_3DBorderGC(
* compilers happy.
*/
- return (GC) None;
+ return NULL;
}
/*
@@ -439,13 +439,13 @@ Tk_Free3DBorder(
if (borderPtr->shadow != None) {
Tk_FreeBitmap(display, borderPtr->shadow);
}
- if (borderPtr->bgGC != None) {
+ if (borderPtr->bgGC != NULL) {
Tk_FreeGC(display, borderPtr->bgGC);
}
- if (borderPtr->darkGC != None) {
+ if (borderPtr->darkGC != NULL) {
Tk_FreeGC(display, borderPtr->darkGC);
}
- if (borderPtr->lightGC != None) {
+ if (borderPtr->lightGC != NULL) {
Tk_FreeGC(display, borderPtr->lightGC);
}
if (prevPtr == borderPtr) {
@@ -765,7 +765,7 @@ Tk_Draw3DPolygon(
int i, lightOnLeft, dx, dy, parallel, pointsSeen;
Display *display = Tk_Display(tkwin);
- if (borderPtr->lightGC == None) {
+ if (borderPtr->lightGC == NULL) {
TkpGetShadows(borderPtr, tkwin);
}
diff --git a/generic/tk3d.h b/generic/tk3d.h
index f574de7..d36b95e 100644
--- a/generic/tk3d.h
+++ b/generic/tk3d.h
@@ -54,10 +54,10 @@ typedef struct TkBorder {
GC bgGC; /* Used (if necessary) to draw areas in the
* background color. */
GC darkGC; /* Used to draw darker parts of the border.
- * None means the shadow colors haven't been
+ * NULL means the shadow colors haven't been
* allocated yet.*/
GC lightGC; /* Used to draw lighter parts of the border.
- * None means the shadow colors haven't been
+ * NULL means the shadow colors haven't been
* allocated yet. */
Tcl_HashEntry *hashPtr; /* Entry in borderTable (needed in order to
* delete structure). */
diff --git a/generic/tkBind.c b/generic/tkBind.c
index 469725e..953d936 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -84,7 +84,7 @@ typedef union {
*/
#ifndef TK_MAC_OSX
- #define EVENT_BUFFER_SIZE 45
+ #define EVENT_BUFFER_SIZE 90
#else
#define EVENT_BUFFER_SIZE 30
#endif
@@ -3587,7 +3587,7 @@ DoWarp(
if (dispPtr->warpWindow) {
Tcl_Release(dispPtr->warpWindow);
- dispPtr->warpWindow = None;
+ dispPtr->warpWindow = NULL;
}
dispPtr->flags &= ~TK_DISPLAY_IN_WARP;
}
diff --git a/generic/tkBusy.c b/generic/tkBusy.c
index 97fa13d..4dee047 100644
--- a/generic/tkBusy.c
+++ b/generic/tkBusy.c
@@ -519,7 +519,8 @@ CreateBusy(
Tk_Window tkRef) /* Window hosting the busy window */
{
Busy *busyPtr;
- int length, x, y;
+ size_t length;
+ int x, y;
const char *fmt;
char *name;
Tk_Window tkBusy, tkChild, tkParent;
@@ -568,7 +569,7 @@ CreateBusy(
busyPtr->height = Tk_Height(tkRef);
busyPtr->x = Tk_X(tkRef);
busyPtr->y = Tk_Y(tkRef);
- busyPtr->cursor = None;
+ busyPtr->cursor = NULL;
Tk_SetClass(tkBusy, "Busy");
busyPtr->optionTable = Tk_CreateOptionTable(interp, busyOptionSpecs);
if (Tk_InitOptions(interp, busyPtr, busyPtr->optionTable,
@@ -598,7 +599,7 @@ CreateBusy(
*/
Tk_ManageGeometry(tkBusy, &busyMgrInfo, busyPtr);
- if (busyPtr->cursor != None) {
+ if (busyPtr->cursor != NULL) {
Tk_DefineCursor(tkBusy, busyPtr->cursor);
}
@@ -643,7 +644,7 @@ ConfigureBusy(
return TCL_ERROR;
}
if (busyPtr->cursor != oldCursor) {
- if (busyPtr->cursor == None) {
+ if (busyPtr->cursor == NULL) {
Tk_UndefineCursor(busyPtr->tkBusy);
} else {
Tk_DefineCursor(busyPtr->tkBusy, busyPtr->cursor);
diff --git a/generic/tkButton.c b/generic/tkButton.c
index f8944fe..e05fbe2 100644
--- a/generic/tkButton.c
+++ b/generic/tkButton.c
@@ -710,12 +710,12 @@ ButtonCreate(
butPtr->normalFg = NULL;
butPtr->activeFg = NULL;
butPtr->disabledFg = NULL;
- butPtr->normalTextGC = None;
- butPtr->activeTextGC = None;
- butPtr->disabledGC = None;
- butPtr->stippleGC = None;
+ butPtr->normalTextGC = NULL;
+ butPtr->activeTextGC = NULL;
+ butPtr->disabledGC = NULL;
+ butPtr->stippleGC = NULL;
butPtr->gray = None;
- butPtr->copyGC = None;
+ butPtr->copyGC = NULL;
butPtr->widthPtr = NULL;
butPtr->width = 0;
butPtr->heightPtr = NULL;
@@ -740,7 +740,7 @@ ButtonCreate(
butPtr->onValuePtr = NULL;
butPtr->offValuePtr = NULL;
butPtr->tristateValuePtr = NULL;
- butPtr->cursor = None;
+ butPtr->cursor = NULL;
butPtr->takeFocusPtr = NULL;
butPtr->commandPtr = NULL;
butPtr->flags = 0;
@@ -981,22 +981,22 @@ DestroyButton(
if (butPtr->tristateImage != NULL) {
Tk_FreeImage(butPtr->tristateImage);
}
- if (butPtr->normalTextGC != None) {
+ if (butPtr->normalTextGC != NULL) {
Tk_FreeGC(butPtr->display, butPtr->normalTextGC);
}
- if (butPtr->activeTextGC != None) {
+ if (butPtr->activeTextGC != NULL) {
Tk_FreeGC(butPtr->display, butPtr->activeTextGC);
}
- if (butPtr->disabledGC != None) {
+ if (butPtr->disabledGC != NULL) {
Tk_FreeGC(butPtr->display, butPtr->disabledGC);
}
- if (butPtr->stippleGC != None) {
+ if (butPtr->stippleGC != NULL) {
Tk_FreeGC(butPtr->display, butPtr->stippleGC);
}
if (butPtr->gray != None) {
Tk_FreeBitmap(butPtr->display, butPtr->gray);
}
- if (butPtr->copyGC != None) {
+ if (butPtr->copyGC != NULL) {
Tk_FreeGC(butPtr->display, butPtr->copyGC);
}
if (butPtr->textLayout != NULL) {
@@ -1367,7 +1367,7 @@ TkButtonWorldChanged(
gcValues.graphics_exposures = False;
mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures;
newGC = Tk_GetGC(butPtr->tkwin, mask, &gcValues);
- if (butPtr->normalTextGC != None) {
+ if (butPtr->normalTextGC != NULL) {
Tk_FreeGC(butPtr->display, butPtr->normalTextGC);
}
butPtr->normalTextGC = newGC;
@@ -1377,7 +1377,7 @@ TkButtonWorldChanged(
gcValues.background = Tk_3DBorderColor(butPtr->activeBorder)->pixel;
mask = GCForeground | GCBackground | GCFont;
newGC = Tk_GetGC(butPtr->tkwin, mask, &gcValues);
- if (butPtr->activeTextGC != None) {
+ if (butPtr->activeTextGC != NULL) {
Tk_FreeGC(butPtr->display, butPtr->activeTextGC);
}
butPtr->activeTextGC = newGC;
@@ -1389,7 +1389,7 @@ TkButtonWorldChanged(
* Create the GC that can be used for stippling
*/
- if (butPtr->stippleGC == None) {
+ if (butPtr->stippleGC == NULL) {
gcValues.foreground = gcValues.background;
mask = GCForeground;
if (butPtr->gray == None) {
@@ -1415,12 +1415,12 @@ TkButtonWorldChanged(
gcValues.foreground = gcValues.background;
}
newGC = Tk_GetGC(butPtr->tkwin, mask, &gcValues);
- if (butPtr->disabledGC != None) {
+ if (butPtr->disabledGC != NULL) {
Tk_FreeGC(butPtr->display, butPtr->disabledGC);
}
butPtr->disabledGC = newGC;
- if (butPtr->copyGC == None) {
+ if (butPtr->copyGC == NULL) {
butPtr->copyGC = Tk_GetGC(butPtr->tkwin, 0, &gcValues);
}
diff --git a/generic/tkButton.h b/generic/tkButton.h
index 7ed464f..7e04fb9 100644
--- a/generic/tkButton.h
+++ b/generic/tkButton.h
@@ -235,7 +235,7 @@ typedef struct {
* Miscellaneous information:
*/
- Tk_Cursor cursor; /* Value of -cursor option: if not None,
+ Tk_Cursor cursor; /* Value of -cursor option: if not NULL,
* specifies current cursor for window. */
Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the
* C code, but used by keyboard traversal
diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c
index 85a0bab..d2daa17 100644
--- a/generic/tkCanvArc.c
+++ b/generic/tkCanvArc.c
@@ -299,7 +299,7 @@ CreateArc(
arcPtr->activeFillStipple = None;
arcPtr->disabledFillStipple = None;
arcPtr->style = PIESLICE_STYLE;
- arcPtr->fillGC = None;
+ arcPtr->fillGC = NULL;
arcPtr->height = 0;
/*
@@ -508,9 +508,9 @@ ConfigureArc(
mask |= GCCapStyle;
newGC = Tk_GetGC(tkwin, mask, &gcValues);
} else {
- newGC = None;
+ newGC = NULL;
}
- if (arcPtr->outline.gc != None) {
+ if (arcPtr->outline.gc != NULL) {
Tk_FreeGC(Tk_Display(tkwin), arcPtr->outline.gc);
}
arcPtr->outline.gc = newGC;
@@ -542,9 +542,9 @@ ConfigureArc(
}
if (arcPtr->style == ARC_STYLE) {
- newGC = None;
+ newGC = NULL;
} else if (color == NULL) {
- newGC = None;
+ newGC = NULL;
} else {
gcValues.foreground = color->pixel;
if (arcPtr->style == CHORD_STYLE) {
@@ -560,7 +560,7 @@ ConfigureArc(
}
newGC = Tk_GetGC(tkwin, mask, &gcValues);
}
- if (arcPtr->fillGC != None) {
+ if (arcPtr->fillGC != NULL) {
Tk_FreeGC(Tk_Display(tkwin), arcPtr->fillGC);
}
arcPtr->fillGC = newGC;
@@ -717,7 +717,7 @@ DeleteArc(
if (arcPtr->disabledFillStipple != None) {
Tk_FreeBitmap(display, arcPtr->disabledFillStipple);
}
- if (arcPtr->fillGC != None) {
+ if (arcPtr->fillGC != NULL) {
Tk_FreeGC(display, arcPtr->fillGC);
}
}
@@ -848,7 +848,7 @@ ComputeArcBbox(
* drawn) and add one extra pixel just for safety.
*/
- if (arcPtr->outline.gc == None) {
+ if (arcPtr->outline.gc == NULL) {
tmp = 1;
} else {
tmp = (int) ((width + 1.0)/2.0 + 1);
@@ -947,7 +947,7 @@ DisplayArc(
* window servers to crash and should be a no-op anyway.
*/
- if ((arcPtr->fillGC != None) && (extent != 0)) {
+ if ((arcPtr->fillGC != NULL) && (extent != 0)) {
if (stipple != None) {
int w = 0;
int h = 0;
@@ -981,7 +981,7 @@ DisplayArc(
XSetTSOrigin(display, arcPtr->fillGC, 0, 0);
}
}
- if (arcPtr->outline.gc != None) {
+ if (arcPtr->outline.gc != NULL) {
Tk_ChangeOutlineGC(canvas, itemPtr, &(arcPtr->outline));
if (extent != 0) {
@@ -1019,13 +1019,13 @@ DisplayArc(
} else {
if (arcPtr->style == CHORD_STYLE) {
TkFillPolygon(canvas, arcPtr->outlinePtr, CHORD_OUTLINE_PTS,
- display, drawable, arcPtr->outline.gc, None);
+ display, drawable, arcPtr->outline.gc, NULL);
} else if (arcPtr->style == PIESLICE_STYLE) {
TkFillPolygon(canvas, arcPtr->outlinePtr, PIE_OUTLINE1_PTS,
- display, drawable, arcPtr->outline.gc, None);
+ display, drawable, arcPtr->outline.gc, NULL);
TkFillPolygon(canvas, arcPtr->outlinePtr + 2*PIE_OUTLINE1_PTS,
PIE_OUTLINE2_PTS, display, drawable,
- arcPtr->outline.gc, None);
+ arcPtr->outline.gc, NULL);
}
}
@@ -1131,12 +1131,12 @@ ArcToPoint(
return dist;
}
- if ((arcPtr->fillGC != None) || (arcPtr->outline.gc == None)) {
+ if ((arcPtr->fillGC != NULL) || (arcPtr->outline.gc == NULL)) {
filled = 1;
} else {
filled = 0;
}
- if (arcPtr->outline.gc == None) {
+ if (arcPtr->outline.gc == NULL) {
width = 0.0;
}
@@ -1258,12 +1258,12 @@ ArcToArea(
}
}
- if ((arcPtr->fillGC != None) || (arcPtr->outline.gc == None)) {
+ if ((arcPtr->fillGC != NULL) || (arcPtr->outline.gc == NULL)) {
filled = 1;
} else {
filled = 0;
}
- if (arcPtr->outline.gc == None) {
+ if (arcPtr->outline.gc == NULL) {
width = 0.0;
}
@@ -1997,7 +1997,7 @@ ArcToPostscript(
* arc.
*/
- if (arcPtr->fillGC != None) {
+ if (arcPtr->fillGC != NULL) {
Tcl_AppendPrintfToObj(psObj,
"matrix currentmatrix\n"
"%.15g %.15g translate %.15g %.15g scale\n",
@@ -2026,7 +2026,7 @@ ArcToPostscript(
}
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
- if (arcPtr->outline.gc != None) {
+ if (arcPtr->outline.gc != NULL) {
Tcl_AppendToObj(psObj, "grestore gsave\n", -1);
}
} else {
@@ -2038,7 +2038,7 @@ ArcToPostscript(
* If there's an outline for the arc, draw it.
*/
- if (arcPtr->outline.gc != None) {
+ if (arcPtr->outline.gc != NULL) {
Tcl_AppendPrintfToObj(psObj,
"matrix currentmatrix\n"
"%.15g %.15g translate %.15g %.15g scale\n",
diff --git a/generic/tkCanvBmap.c b/generic/tkCanvBmap.c
index d7d54f4..b9de07b 100644
--- a/generic/tkCanvBmap.c
+++ b/generic/tkCanvBmap.c
@@ -189,7 +189,7 @@ TkcCreateBitmap(
bmapPtr->bgColor = NULL;
bmapPtr->activeBgColor = NULL;
bmapPtr->disabledBgColor = NULL;
- bmapPtr->gc = None;
+ bmapPtr->gc = NULL;
/*
* Process the arguments to fill in the item record. Only 1 (list) or 2 (x
@@ -372,7 +372,7 @@ ConfigureBitmap(
}
if (bitmap == None) {
- newGC = None;
+ newGC = NULL;
} else {
gcValues.foreground = fgColor->pixel;
mask = GCForeground;
@@ -385,7 +385,7 @@ ConfigureBitmap(
}
newGC = Tk_GetGC(tkwin, mask, &gcValues);
}
- if (bmapPtr->gc != None) {
+ if (bmapPtr->gc != NULL) {
Tk_FreeGC(Tk_Display(tkwin), bmapPtr->gc);
}
bmapPtr->gc = newGC;
diff --git a/generic/tkCanvImg.c b/generic/tkCanvImg.c
index 899741a..70b9c79 100644
--- a/generic/tkCanvImg.c
+++ b/generic/tkCanvImg.c
@@ -449,7 +449,7 @@ ComputeImageBbox(
x = (int) (imgPtr->x + ((imgPtr->x >= 0) ? 0.5 : - 0.5));
y = (int) (imgPtr->y + ((imgPtr->y >= 0) ? 0.5 : - 0.5));
- if ((state == TK_STATE_HIDDEN) || (image == None)) {
+ if ((state == TK_STATE_HIDDEN) || (image == NULL)) {
imgPtr->header.x1 = imgPtr->header.x2 = x;
imgPtr->header.y1 = imgPtr->header.y2 = y;
return;
diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c
index 087aa56..b6c845d 100644
--- a/generic/tkCanvLine.c
+++ b/generic/tkCanvLine.c
@@ -296,7 +296,7 @@ CreateLine(
linePtr->coordPtr = NULL;
linePtr->capStyle = CapButt;
linePtr->joinStyle = JoinRound;
- linePtr->arrowGC = None;
+ linePtr->arrowGC = NULL;
linePtr->arrow = ARROWS_NONE;
linePtr->arrowShapeA = (float)8.0;
linePtr->arrowShapeB = (float)10.0;
@@ -521,12 +521,12 @@ ConfigureLine(
#endif
arrowGC = Tk_GetGC(tkwin, mask, &gcValues);
} else {
- newGC = arrowGC = None;
+ newGC = arrowGC = NULL;
}
- if (linePtr->outline.gc != None) {
+ if (linePtr->outline.gc != NULL) {
Tk_FreeGC(Tk_Display(tkwin), linePtr->outline.gc);
}
- if (linePtr->arrowGC != None) {
+ if (linePtr->arrowGC != NULL) {
Tk_FreeGC(Tk_Display(tkwin), linePtr->arrowGC);
}
linePtr->outline.gc = newGC;
@@ -611,7 +611,7 @@ DeleteLine(
if (linePtr->coordPtr != NULL) {
ckfree(linePtr->coordPtr);
}
- if (linePtr->arrowGC != None) {
+ if (linePtr->arrowGC != NULL) {
Tk_FreeGC(display, linePtr->arrowGC);
}
if (linePtr->firstArrowPtr != NULL) {
@@ -840,7 +840,7 @@ DisplayLine(
int numPoints;
Tk_State state = itemPtr->state;
- if ((!linePtr->numPoints) || (linePtr->outline.gc == None)) {
+ if (!linePtr->numPoints || (linePtr->outline.gc == NULL)) {
return;
}
diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c
index b4ef098..6a8f865 100644
--- a/generic/tkCanvPoly.c
+++ b/generic/tkCanvPoly.c
@@ -273,7 +273,7 @@ CreatePolygon(
polyPtr->fillStipple = None;
polyPtr->activeFillStipple = None;
polyPtr->disabledFillStipple = None;
- polyPtr->fillGC = None;
+ polyPtr->fillGC = NULL;
polyPtr->smooth = NULL;
polyPtr->splineSteps = 12;
polyPtr->autoClosed = 0;
@@ -478,9 +478,9 @@ ConfigurePolygon(
mask |= GCCapStyle|GCJoinStyle;
newGC = Tk_GetGC(tkwin, mask, &gcValues);
} else {
- newGC = None;
+ newGC = NULL;
}
- if (polyPtr->outline.gc != None) {
+ if (polyPtr->outline.gc != NULL) {
Tk_FreeGC(Tk_Display(tkwin), polyPtr->outline.gc);
}
polyPtr->outline.gc = newGC;
@@ -504,7 +504,7 @@ ConfigurePolygon(
}
if (color == NULL) {
- newGC = None;
+ newGC = NULL;
} else {
gcValues.foreground = color->pixel;
mask = GCForeground;
@@ -518,13 +518,13 @@ ConfigurePolygon(
* Mac OS X CG drawing needs access to the outline linewidth
* even for fills (as linewidth controls antialiasing).
*/
- gcValues.line_width = polyPtr->outline.gc != None ?
+ gcValues.line_width = polyPtr->outline.gc != NULL ?
polyPtr->outline.gc->line_width : 0;
mask |= GCLineWidth;
#endif
newGC = Tk_GetGC(tkwin, mask, &gcValues);
}
- if (polyPtr->fillGC != None) {
+ if (polyPtr->fillGC != NULL) {
Tk_FreeGC(Tk_Display(tkwin), polyPtr->fillGC);
}
polyPtr->fillGC = newGC;
@@ -590,7 +590,7 @@ DeletePolygon(
if (polyPtr->disabledFillStipple != None) {
Tk_FreeBitmap(display, polyPtr->disabledFillStipple);
}
- if (polyPtr->fillGC != None) {
+ if (polyPtr->fillGC != NULL) {
Tk_FreeGC(display, polyPtr->fillGC);
}
}
@@ -694,7 +694,7 @@ ComputePolygonBbox(
}
}
- if (polyPtr->outline.gc != None) {
+ if (polyPtr->outline.gc != NULL) {
tsoffset = &polyPtr->outline.tsoffset;
if (tsoffset) {
if (tsoffset->flags & TK_OFFSET_INDEX) {
@@ -836,11 +836,11 @@ TkFillPolygon(
* allocated.
*/
- if (gc != None && numPoints > 3) {
+ if (gc != NULL && numPoints > 3) {
XFillPolygon(display, drawable, gc, pointPtr, numPoints, Complex,
CoordModeOrigin);
}
- if (outlineGC != None) {
+ if (outlineGC != NULL) {
XDrawLines(display, drawable, outlineGC, pointPtr, numPoints,
CoordModeOrigin);
}
@@ -881,9 +881,9 @@ DisplayPolygon(
Pixmap stipple = polyPtr->fillStipple;
double linewidth = polyPtr->outline.width;
- if (((polyPtr->fillGC == None) && (polyPtr->outline.gc == None)) ||
+ if (((polyPtr->fillGC == NULL) && (polyPtr->outline.gc == NULL)) ||
(polyPtr->numPoints < 1) ||
- (polyPtr->numPoints < 3 && polyPtr->outline.gc == None)) {
+ (polyPtr->numPoints < 3 && polyPtr->outline.gc == NULL)) {
return;
}
@@ -911,7 +911,7 @@ DisplayPolygon(
* reset the offset when done, since the GC is supposed to be read-only.
*/
- if ((stipple != None) && (polyPtr->fillGC != None)) {
+ if ((stipple != None) && (polyPtr->fillGC != NULL)) {
Tk_TSOffset *tsoffset = &polyPtr->tsoffset;
int w = 0, h = 0;
int flags = tsoffset->flags;
@@ -973,11 +973,11 @@ DisplayPolygon(
}
numPoints = polyPtr->smooth->coordProc(canvas, polyPtr->coordPtr,
polyPtr->numPoints, polyPtr->splineSteps, pointPtr, NULL);
- if (polyPtr->fillGC != None) {
+ if (polyPtr->fillGC != NULL) {
XFillPolygon(display, drawable, polyPtr->fillGC, pointPtr,
numPoints, Complex, CoordModeOrigin);
}
- if (polyPtr->outline.gc != None) {
+ if (polyPtr->outline.gc != NULL) {
XDrawLines(display, drawable, polyPtr->outline.gc, pointPtr,
numPoints, CoordModeOrigin);
}
@@ -986,7 +986,7 @@ DisplayPolygon(
}
}
Tk_ResetOutlineGC(canvas, itemPtr, &polyPtr->outline);
- if ((stipple != None) && (polyPtr->fillGC != None)) {
+ if ((stipple != None) && (polyPtr->fillGC != NULL)) {
XSetTSOrigin(display, polyPtr->fillGC, 0, 0);
}
}
@@ -1299,7 +1299,7 @@ PolygonToPoint(
if (bestDist <= 0.0) {
goto donepoint;
}
- if ((polyPtr->outline.gc != None) && (polyPtr->joinStyle == JoinRound)) {
+ if ((polyPtr->outline.gc != NULL) && (polyPtr->joinStyle == JoinRound)) {
dist = bestDist - radius;
if (dist <= 0.0) {
bestDist = 0.0;
@@ -1309,7 +1309,7 @@ PolygonToPoint(
}
}
- if ((polyPtr->outline.gc == None) || (width <= 1)) {
+ if ((polyPtr->outline.gc == NULL) || (width <= 1)) {
goto donepoint;
}
@@ -1515,7 +1515,7 @@ PolygonToArea(
goto donearea;
}
- if (polyPtr->outline.gc == None) {
+ if (polyPtr->outline.gc == NULL) {
goto donearea;
}
diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c
index 7c088b5..c918399 100644
--- a/generic/tkCanvText.c
+++ b/generic/tkCanvText.c
@@ -269,9 +269,9 @@ CreateText(
textPtr->textLayout = NULL;
textPtr->actualWidth = 0;
textPtr->drawOrigin[0] = textPtr->drawOrigin[1] = 0.0;
- textPtr->gc = None;
- textPtr->selTextGC = None;
- textPtr->cursorOffGC = None;
+ textPtr->gc = NULL;
+ textPtr->selTextGC = NULL;
+ textPtr->cursorOffGC = NULL;
textPtr->sine = 0.0;
textPtr->cosine = 1.0;
@@ -447,7 +447,7 @@ ConfigureText(
}
}
- newGC = newSelGC = None;
+ newGC = newSelGC = NULL;
if (textPtr->tkfont != NULL) {
gcValues.font = Tk_FontId(textPtr->tkfont);
mask = GCFont;
@@ -472,11 +472,11 @@ ConfigureText(
}
newSelGC = Tk_GetGC(tkwin, mask|GCForeground, &gcValues);
}
- if (textPtr->gc != None) {
+ if (textPtr->gc != NULL) {
Tk_FreeGC(Tk_Display(tkwin), textPtr->gc);
}
textPtr->gc = newGC;
- if (textPtr->selTextGC != None) {
+ if (textPtr->selTextGC != NULL) {
Tk_FreeGC(Tk_Display(tkwin), textPtr->selTextGC);
}
textPtr->selTextGC = newSelGC;
@@ -491,9 +491,9 @@ ConfigureText(
}
newGC = Tk_GetGC(tkwin, GCForeground, &gcValues);
} else {
- newGC = None;
+ newGC = NULL;
}
- if (textPtr->cursorOffGC != None) {
+ if (textPtr->cursorOffGC != NULL) {
Tk_FreeGC(Tk_Display(tkwin), textPtr->cursorOffGC);
}
textPtr->cursorOffGC = newGC;
@@ -592,13 +592,13 @@ DeleteText(
}
Tk_FreeTextLayout(textPtr->textLayout);
- if (textPtr->gc != None) {
+ if (textPtr->gc != NULL) {
Tk_FreeGC(display, textPtr->gc);
}
- if (textPtr->selTextGC != None) {
+ if (textPtr->selTextGC != NULL) {
Tk_FreeGC(display, textPtr->selTextGC);
}
- if (textPtr->cursorOffGC != None) {
+ if (textPtr->cursorOffGC != NULL) {
Tk_FreeGC(display, textPtr->cursorOffGC);
}
}
@@ -820,7 +820,7 @@ DisplayCanvText(
}
}
- if (textPtr->gc == None) {
+ if (textPtr->gc == NULL) {
return;
}
@@ -932,7 +932,7 @@ DisplayCanvText(
Tk_Fill3DPolygon(Tk_CanvasTkwin(canvas), drawable,
textInfoPtr->insertBorder, points, 4,
textInfoPtr->insertBorderWidth, TK_RELIEF_RAISED);
- } else if (textPtr->cursorOffGC != None) {
+ } else if (textPtr->cursorOffGC != NULL) {
/*
* Redraw the background over the area of the cursor, even
* though the cursor is turned off. This guarantees that the
diff --git a/generic/tkCanvUtil.c b/generic/tkCanvUtil.c
index 09ce98c..6ce671d 100644
--- a/generic/tkCanvUtil.c
+++ b/generic/tkCanvUtil.c
@@ -961,7 +961,7 @@ void
Tk_CreateOutline(
Tk_Outline *outline) /* Outline structure to be filled in. */
{
- outline->gc = None;
+ outline->gc = NULL;
outline->width = 1.0;
outline->activeWidth = 0.0;
outline->disabledWidth = 0.0;
@@ -1002,7 +1002,7 @@ Tk_DeleteOutline(
Display *display, /* Display containing window. */
Tk_Outline *outline)
{
- if (outline->gc != None) {
+ if (outline->gc != NULL) {
Tk_FreeGC(display, outline->gc);
}
if ((unsigned) ABS(outline->dash.number) > sizeof(char *)) {
diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c
index 18585d2..f3778a6 100644
--- a/generic/tkCanvas.c
+++ b/generic/tkCanvas.c
@@ -625,7 +625,7 @@ Tk_CanvasObjCmd(
canvasPtr->highlightBgColorPtr = NULL;
canvasPtr->highlightColorPtr = NULL;
canvasPtr->inset = 0;
- canvasPtr->pixmapGC = None;
+ canvasPtr->pixmapGC = NULL;
canvasPtr->width = None;
canvasPtr->height = None;
canvasPtr->confine = 0;
@@ -671,7 +671,7 @@ Tk_CanvasObjCmd(
canvasPtr->scanYOrigin = 0;
canvasPtr->hotPtr = NULL;
canvasPtr->hotPrevPtr = NULL;
- canvasPtr->cursor = None;
+ canvasPtr->cursor = NULL;
canvasPtr->takeFocus = NULL;
canvasPtr->pixelsPerMM = WidthOfScreen(Tk_Screen(newWin));
canvasPtr->pixelsPerMM /= WidthMMOfScreen(Tk_Screen(newWin));
@@ -2135,7 +2135,7 @@ DestroyCanvas(
*/
Tcl_DeleteHashTable(&canvasPtr->idTable);
- if (canvasPtr->pixmapGC != None) {
+ if (canvasPtr->pixmapGC != NULL) {
Tk_FreeGC(canvasPtr->display, canvasPtr->pixmapGC);
}
expr = canvasPtr->bindTagExprs;
@@ -2209,7 +2209,7 @@ ConfigureCanvas(
gcValues.foreground = Tk_3DBorderColor(canvasPtr->bgBorder)->pixel;
newGC = Tk_GetGC(canvasPtr->tkwin,
GCFunction|GCGraphicsExposures|GCForeground, &gcValues);
- if (canvasPtr->pixmapGC != None) {
+ if (canvasPtr->pixmapGC != NULL) {
Tk_FreeGC(canvasPtr->display, canvasPtr->pixmapGC);
}
canvasPtr->pixmapGC = newGC;
@@ -2769,21 +2769,10 @@ DrawCanvas(
* colours and place them in the photo block. Perhaps we could
* just not bother with the alpha byte because we are using
* TK_PHOTO_COMPOSITE_SET later?
- * ***Windows: We have to swap the red and blue values. The
- * XImage storage is B - G - R - A which becomes a 32bit ARGB
- * quad. However the visual mask is a 32bit ABGR quad. And
- * Tk_PhotoPutBlock() wants R-G-B-A which is a 32bit ABGR quad.
- * If the visual mask was correct there would be no need to
- * swap anything here.
*/
-#ifdef _WIN32
-#define R_OFFSET 2
-#define B_OFFSET 0
-#else
#define R_OFFSET 0
#define B_OFFSET 2
-#endif
blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x + R_OFFSET] =
(unsigned char)((pixel & visualPtr->red_mask) >> rshift);
blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x +1] =
diff --git a/generic/tkCanvas.h b/generic/tkCanvas.h
index b8b1b46..e2221a8 100644
--- a/generic/tkCanvas.h
+++ b/generic/tkCanvas.h
@@ -206,7 +206,7 @@ typedef struct TkCanvas {
* Miscellaneous information:
*/
- Tk_Cursor cursor; /* Current cursor for window, or None. */
+ Tk_Cursor cursor; /* Current cursor for window, or NULL. */
char *takeFocus; /* Value of -takefocus option; not used in the
* C code, but used by keyboard traversal
* scripts. Malloc'ed, but may be NULL. */
diff --git a/generic/tkColor.c b/generic/tkColor.c
index 9d5e157..3a82545 100644
--- a/generic/tkColor.c
+++ b/generic/tkColor.c
@@ -245,7 +245,7 @@ Tk_GetColor(
*/
tkColPtr->magic = COLOR_MAGIC;
- tkColPtr->gc = None;
+ tkColPtr->gc = NULL;
tkColPtr->screen = Tk_Screen(tkwin);
tkColPtr->colormap = Tk_Colormap(tkwin);
tkColPtr->visual = Tk_Visual(tkwin);
@@ -326,7 +326,7 @@ Tk_GetColorByValue(
tkColPtr = TkpGetColorByValue(tkwin, colorPtr);
tkColPtr->magic = COLOR_MAGIC;
- tkColPtr->gc = None;
+ tkColPtr->gc = NULL;
tkColPtr->screen = Tk_Screen(tkwin);
tkColPtr->colormap = valueKey.colormap;
tkColPtr->visual = Tk_Visual(tkwin);
@@ -436,7 +436,7 @@ Tk_GCForColor(
Tcl_Panic("Tk_GCForColor called with bogus color");
}
- if (tkColPtr->gc == None) {
+ if (tkColPtr->gc == NULL) {
gcValues.foreground = tkColPtr->color.pixel;
tkColPtr->gc = XCreateGC(DisplayOfScreen(tkColPtr->screen), drawable,
GCForeground, &gcValues);
@@ -490,9 +490,9 @@ Tk_FreeColor(
* longer any objects referencing it.
*/
- if (tkColPtr->gc != None) {
+ if (tkColPtr->gc != NULL) {
XFreeGC(DisplayOfScreen(screen), tkColPtr->gc);
- tkColPtr->gc = None;
+ tkColPtr->gc = NULL;
}
TkpFreeColor(tkColPtr);
diff --git a/generic/tkColor.h b/generic/tkColor.h
index d5bde9d..bcd71fe 100644
--- a/generic/tkColor.h
+++ b/generic/tkColor.h
@@ -32,7 +32,7 @@ typedef struct TkColor {
* COLOR_MAGIC. */
GC gc; /* Simple gc with this color as foreground
* color and all other fields defaulted. May
- * be None. */
+ * be NULL. */
Screen *screen; /* Screen where this color is valid. Used to
* delete it, and to find its display. */
Colormap colormap; /* Colormap from which this entry was
diff --git a/generic/tkConfig.c b/generic/tkConfig.c
index 46300d3..b9499e5 100644
--- a/generic/tkConfig.c
+++ b/generic/tkConfig.c
@@ -799,11 +799,11 @@ DoObjConfig(
Tk_Cursor newCursor;
if (nullOK && ObjectIsEmpty(valuePtr)) {
- newCursor = None;
+ newCursor = NULL;
valuePtr = NULL;
} else {
newCursor = Tk_AllocCursorFromObj(interp, tkwin, valuePtr);
- if (newCursor == None) {
+ if (newCursor == NULL) {
return TCL_ERROR;
}
}
@@ -861,7 +861,7 @@ DoObjConfig(
if (nullOK && ObjectIsEmpty(valuePtr)) {
valuePtr = NULL;
- newWin = None;
+ newWin = NULL;
} else {
if (TkGetWindowFromObj(interp, tkwin, valuePtr,
&newWin) != TCL_OK) {
@@ -1663,9 +1663,9 @@ FreeResources(
break;
case TK_OPTION_CURSOR:
if (internalFormExists) {
- if (*((Tk_Cursor *) internalPtr) != None) {
+ if (*((Tk_Cursor *) internalPtr) != NULL) {
Tk_FreeCursor(Tk_Display(tkwin), *((Tk_Cursor *) internalPtr));
- *((Tk_Cursor *) internalPtr) = None;
+ *((Tk_Cursor *) internalPtr) = NULL;
}
} else if (objPtr != NULL) {
Tk_FreeCursorFromObj(tkwin, objPtr);
@@ -1936,7 +1936,7 @@ GetObjectForOption(
case TK_OPTION_CURSOR: {
Tk_Cursor cursor = *((Tk_Cursor *) internalPtr);
- if (cursor != None) {
+ if (cursor != NULL) {
objPtr = Tcl_NewStringObj(
Tk_NameOfCursor(Tk_Display(tkwin), cursor), -1);
}
diff --git a/generic/tkCursor.c b/generic/tkCursor.c
index afdf6dd..76bbc89 100644
--- a/generic/tkCursor.c
+++ b/generic/tkCursor.c
@@ -150,7 +150,7 @@ Tk_AllocCursorFromObj(
cursorPtr = TkcGetCursor(interp, tkwin, Tcl_GetString(objPtr));
objPtr->internalRep.twoPtrValue.ptr1 = cursorPtr;
if (cursorPtr == NULL) {
- return None;
+ return NULL;
}
cursorPtr->objRefCount++;
return cursorPtr->cursor;
@@ -190,7 +190,7 @@ Tk_GetCursor(
TkCursor *cursorPtr = TkcGetCursor(interp, tkwin, string);
if (cursorPtr == NULL) {
- return None;
+ return NULL;
}
return cursorPtr->cursor;
}
@@ -388,7 +388,7 @@ Tk_GetCursorFromData(
error:
Tcl_DeleteHashEntry(dataHashPtr);
- return None;
+ return NULL;
}
/*
diff --git a/generic/tkEntry.c b/generic/tkEntry.c
index 8a69010..7e94d9b 100644
--- a/generic/tkEntry.c
+++ b/generic/tkEntry.c
@@ -536,20 +536,20 @@ Tk_EntryObjCmd(
entryPtr->selectFirst = -1;
entryPtr->selectLast = -1;
- entryPtr->cursor = None;
+ entryPtr->cursor = NULL;
entryPtr->exportSelection = 1;
entryPtr->justify = TK_JUSTIFY_LEFT;
entryPtr->relief = TK_RELIEF_FLAT;
entryPtr->state = STATE_NORMAL;
entryPtr->displayString = entryPtr->string;
entryPtr->inset = XPAD;
- entryPtr->textGC = None;
- entryPtr->selTextGC = None;
- entryPtr->highlightGC = None;
+ entryPtr->textGC = NULL;
+ entryPtr->selTextGC = NULL;
+ entryPtr->highlightGC = NULL;
entryPtr->avgWidth = 1;
entryPtr->validate = VALIDATE_NONE;
- entryPtr->placeholderGC = None;
+ entryPtr->placeholderGC = NULL;
/*
* Keep a hold of the associated tkwin until we destroy the entry,
@@ -1047,10 +1047,10 @@ DestroyEntry(
EntryTextVarProc, entryPtr);
entryPtr->flags &= ~ENTRY_VAR_TRACED;
}
- if (entryPtr->textGC != None) {
+ if (entryPtr->textGC != NULL) {
Tk_FreeGC(entryPtr->display, entryPtr->textGC);
}
- if (entryPtr->selTextGC != None) {
+ if (entryPtr->selTextGC != NULL) {
Tk_FreeGC(entryPtr->display, entryPtr->selTextGC);
}
Tcl_DeleteTimerHandler(entryPtr->insertBlinkHandler);
@@ -1446,7 +1446,7 @@ EntryWorldChanged(
ClientData instanceData) /* Information about widget. */
{
XGCValues gcValues;
- GC gc = None;
+ GC gc = NULL;
unsigned long mask;
Tk_3DBorder border;
XColor *colorPtr;
@@ -1498,7 +1498,7 @@ EntryWorldChanged(
gcValues.graphics_exposures = False;
mask = GCForeground | GCFont | GCGraphicsExposures;
gc = Tk_GetGC(entryPtr->tkwin, mask, &gcValues);
- if (entryPtr->textGC != None) {
+ if (entryPtr->textGC != NULL) {
Tk_FreeGC(entryPtr->display, entryPtr->textGC);
}
entryPtr->textGC = gc;
@@ -1508,7 +1508,7 @@ EntryWorldChanged(
}
mask = GCForeground | GCFont | GCGraphicsExposures;
gc = Tk_GetGC(entryPtr->tkwin, mask, &gcValues);
- if (entryPtr->placeholderGC != None) {
+ if (entryPtr->placeholderGC != NULL) {
Tk_FreeGC(entryPtr->display, entryPtr->placeholderGC);
}
entryPtr->placeholderGC = gc;
@@ -1521,7 +1521,7 @@ EntryWorldChanged(
gcValues.font = Tk_FontId(entryPtr->tkfont);
mask = GCForeground | GCFont;
gc = Tk_GetGC(entryPtr->tkwin, mask, &gcValues);
- if (entryPtr->selTextGC != None) {
+ if (entryPtr->selTextGC != NULL) {
Tk_FreeGC(entryPtr->display, entryPtr->selTextGC);
}
entryPtr->selTextGC = gc;
@@ -2541,9 +2541,9 @@ EntryEventProc(
} else if ((elem == SEL_BUTTONDOWN) || (elem == SEL_BUTTONUP)) {
cursor = sbPtr->bCursor;
} else {
- cursor = None;
+ cursor = NULL;
}
- if (cursor != None) {
+ if (cursor != NULL) {
Tk_DefineCursor(entryPtr->tkwin, cursor);
} else {
Tk_UndefineCursor(entryPtr->tkwin);
@@ -3717,22 +3717,22 @@ Tk_SpinboxObjCmd(
entryPtr->selectFirst = -1;
entryPtr->selectLast = -1;
- entryPtr->cursor = None;
+ entryPtr->cursor = NULL;
entryPtr->exportSelection = 1;
entryPtr->justify = TK_JUSTIFY_LEFT;
entryPtr->relief = TK_RELIEF_FLAT;
entryPtr->state = STATE_NORMAL;
entryPtr->displayString = entryPtr->string;
entryPtr->inset = XPAD;
- entryPtr->textGC = None;
- entryPtr->selTextGC = None;
- entryPtr->highlightGC = None;
+ entryPtr->textGC = NULL;
+ entryPtr->selTextGC = NULL;
+ entryPtr->highlightGC = NULL;
entryPtr->avgWidth = 1;
entryPtr->validate = VALIDATE_NONE;
sbPtr->selElement = SEL_NONE;
sbPtr->curElement = SEL_NONE;
- sbPtr->bCursor = None;
+ sbPtr->bCursor = NULL;
sbPtr->repeatDelay = 400;
sbPtr->repeatInterval = 100;
sbPtr->fromValue = 0.0;
@@ -3742,7 +3742,7 @@ Tk_SpinboxObjCmd(
sbPtr->bdRelief = TK_RELIEF_FLAT;
sbPtr->buRelief = TK_RELIEF_FLAT;
- entryPtr->placeholderGC = None;
+ entryPtr->placeholderGC = NULL;
/*
* Keep a hold of the associated tkwin until we destroy the spinbox,
diff --git a/generic/tkEntry.h b/generic/tkEntry.h
index e74b52b..c81563c 100644
--- a/generic/tkEntry.h
+++ b/generic/tkEntry.h
@@ -82,7 +82,7 @@ typedef struct {
* in readonly state, plus used for
* background. */
int borderWidth; /* Width of 3-D border around window. */
- Tk_Cursor cursor; /* Current cursor for window, or None. */
+ Tk_Cursor cursor; /* Current cursor for window, or NULL. */
int exportSelection; /* Non-zero means tie internal entry selection
* to X selection. */
Tk_Font tkfont; /* Information about text font, or NULL. */
@@ -205,7 +205,7 @@ typedef struct {
Tk_3DBorder activeBorder; /* Used for drawing border around active
* buttons. */
Tk_3DBorder buttonBorder; /* Used for drawing border around buttons. */
- Tk_Cursor bCursor; /* cursor for buttons, or None. */
+ Tk_Cursor bCursor; /* cursor for buttons, or NULL. */
int bdRelief; /* 3-D effect: TK_RELIEF_RAISED, etc. */
int buRelief; /* 3-D effect: TK_RELIEF_RAISED, etc. */
char *command; /* Command to invoke for spin buttons. NULL
diff --git a/generic/tkEvent.c b/generic/tkEvent.c
index d058e7c..891f667 100644
--- a/generic/tkEvent.c
+++ b/generic/tkEvent.c
@@ -1368,7 +1368,7 @@ Tk_HandleEvent(
* handle CreateNotify events, so we gotta pass 'em through.
*/
- if ((ip.winPtr != None)
+ if ((ip.winPtr != NULL)
&& ((mask != SubstructureNotifyMask)
|| (eventPtr->type == CreateNotify))) {
TkBindEventProc(winPtr, eventPtr);
@@ -1439,7 +1439,7 @@ TkEventDeadWindow(
ipPtr->nextHandler = NULL;
}
if (ipPtr->winPtr == winPtr) {
- ipPtr->winPtr = None;
+ ipPtr->winPtr = NULL;
}
}
ckfree(handlerPtr);
diff --git a/generic/tkFocus.c b/generic/tkFocus.c
index 60f631d..c621bf9 100644
--- a/generic/tkFocus.c
+++ b/generic/tkFocus.c
@@ -551,12 +551,17 @@ TkSetFocusWin(
return;
}
+ /*
+ * Get the current focus window with the same display and application
+ * as winPtr.
+ */
+
displayFocusPtr = FindDisplayFocusInfo(winPtr->mainPtr, winPtr->dispPtr);
/*
- * If force is set, we should make sure we grab the focus regardless of
- * the current focus window since under Windows, we may need to take
- * control away from another application.
+ * Do nothing if the window already has focus and force is not set. If
+ * force is set, we need to grab the focus, since under Windows or macOS
+ * this may involve taking control away from another application.
*/
if (winPtr == displayFocusPtr->focusWinPtr && !force) {
@@ -564,14 +569,15 @@ TkSetFocusWin(
}
/*
- * Find the top-level window for winPtr, then find (or create) a record
- * for the top-level. Also see whether winPtr and all its ancestors are
+ * Find the toplevel window for winPtr, then find (or create) a record
+ * for the toplevel. Also see whether winPtr and all its ancestors are
* mapped.
*/
allMapped = 1;
for (topLevelPtr = winPtr; ; topLevelPtr = topLevelPtr->parentPtr) {
if (topLevelPtr == NULL) {
+
/*
* The window is being deleted. No point in worrying about giving
* it the focus.
@@ -588,11 +594,11 @@ TkSetFocusWin(
}
/*
- * If the new focus window isn't mapped, then we can't focus on it (X will
- * generate an error, for example). Instead, create an event handler that
- * will set the focus to this window once it gets mapped. At the same
- * time, delete any old handler that might be around; it's no longer
- * relevant.
+ * If any ancestor of the new focus window isn't mapped, then we can't set
+ * focus for it (X will generate an error, for example). Instead, create
+ * an event handler that will set the focus to this window once it gets
+ * mapped. At the same time, delete any old handler that might be around;
+ * it's no longer relevant.
*/
if (displayFocusPtr->focusOnMapPtr != NULL) {
@@ -623,30 +629,38 @@ TkSetFocusWin(
}
tlFocusPtr->focusWinPtr = winPtr;
- /*
- * Reset the window system's focus window and generate focus events, with
- * two special cases:
- *
- * 1. If the application is embedded and doesn't currently have the focus,
- * don't set the focus directly. Instead, see if the embedding code can
- * claim the focus from the enclosing container.
- * 2. Otherwise, if the application doesn't currently have the focus,
- * don't change the window system's focus unless it was already in this
- * application or "force" was specified.
- */
+ if (topLevelPtr->flags & TK_EMBEDDED) {
+
+ /*
+ * We are assigning focus to an embedded toplevel. The platform
+ * specific function TkpClaimFocus needs to handle the job of
+ * assigning focus to the container, since we have no way to find the
+ * contaiuner.
+ */
- if ((topLevelPtr->flags & TK_EMBEDDED)
- && (displayFocusPtr->focusWinPtr == NULL)) {
TkpClaimFocus(topLevelPtr, force);
} else if ((displayFocusPtr->focusWinPtr != NULL) || force) {
+
/*
- * Generate events to shift focus between Tk windows. We do this
- * regardless of what TkpChangeFocus does with the real X focus so
- * that Tk widgets track focus commands when there is no window
- * manager. GenerateFocusEvents will set up a serial number marker so
- * we discard focus events that are triggered by the ChangeFocus.
+ * If we are forcing removal of focus from a container hosting a
+ * toplevel from a different application, clear the focus in that
+ * application.
*/
+
+ if (force) {
+ TkWindow *focusPtr = winPtr->dispPtr->focusPtr;
+ if (focusPtr && focusPtr->mainPtr != winPtr->mainPtr) {
+ DisplayFocusInfo *displayFocusPtr2 = FindDisplayFocusInfo(
+ focusPtr->mainPtr, focusPtr->dispPtr);
+ displayFocusPtr2->focusWinPtr = NULL;
+ }
+ }
+ /*
+ * Call the platform specific function TkpChangeFocus to move the
+ * window manager's focus to a new toplevel.
+ */
+
serial = TkpChangeFocus(TkpGetWrapperWindow(topLevelPtr), force);
if (serial != 0) {
displayFocusPtr->focusSerial = serial;
diff --git a/generic/tkFrame.c b/generic/tkFrame.c
index 53c019c..392799e 100644
--- a/generic/tkFrame.c
+++ b/generic/tkFrame.c
@@ -663,13 +663,13 @@ CreateFrame(
framePtr->type = type;
framePtr->colormap = colormap;
framePtr->relief = TK_RELIEF_FLAT;
- framePtr->cursor = None;
+ framePtr->cursor = NULL;
if (framePtr->type == TYPE_LABELFRAME) {
Labelframe *labelframePtr = (Labelframe *) framePtr;
labelframePtr->labelAnchor = LABELANCHOR_NW;
- labelframePtr->textGC = None;
+ labelframePtr->textGC = NULL;
}
/*
@@ -866,7 +866,7 @@ DestroyFrame(
if (framePtr->type == TYPE_LABELFRAME) {
Tk_FreeTextLayout(labelframePtr->textLayout);
- if (labelframePtr->textGC != None) {
+ if (labelframePtr->textGC != NULL) {
Tk_FreeGC(framePtr->display, labelframePtr->textGC);
}
}
@@ -1122,7 +1122,7 @@ FrameWorldChanged(
gcValues.graphics_exposures = False;
gc = Tk_GetGC(tkwin, GCForeground | GCFont | GCGraphicsExposures,
&gcValues);
- if (labelframePtr->textGC != None) {
+ if (labelframePtr->textGC != NULL) {
Tk_FreeGC(framePtr->display, labelframePtr->textGC);
}
labelframePtr->textGC = gc;
diff --git a/generic/tkGrab.c b/generic/tkGrab.c
index c37b6be..ff5d083 100644
--- a/generic/tkGrab.c
+++ b/generic/tkGrab.c
@@ -426,12 +426,7 @@ Tk_Grab(
}
Tk_MakeWindowExist(tkwin);
-#ifndef MAC_OSX_TK
- if (!grabGlobal)
-#else
- if (0)
-#endif /* MAC_OSX_TK */
- {
+ if (!grabGlobal) {
Window dummy1, dummy2;
int dummy3, dummy4, dummy5, dummy6;
unsigned int state;
diff --git a/generic/tkImage.c b/generic/tkImage.c
index 359d6c6..32e09c0 100644
--- a/generic/tkImage.c
+++ b/generic/tkImage.c
@@ -775,7 +775,7 @@ Tk_PostscriptImage(
gcValues.foreground = WhitePixelOfScreen(Tk_Screen(tkwin));
newGC = Tk_GetGC(tkwin, GCForeground, &gcValues);
- if (newGC != None) {
+ if (newGC != NULL) {
XFillRectangle(Tk_Display(tkwin), pmap, newGC, 0, 0,
(unsigned) width, (unsigned) height);
Tk_FreeGC(Tk_Display(tkwin), newGC);
diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c
index 80b1c9c..a3a94f9 100644
--- a/generic/tkImgBmap.c
+++ b/generic/tkImgBmap.c
@@ -427,9 +427,9 @@ ImgBmapConfigureInstance(
}
gc = Tk_GetGC(instancePtr->tkwin, mask, &gcValues);
} else {
- gc = None;
+ gc = NULL;
}
- if (instancePtr->gc != None) {
+ if (instancePtr->gc != NULL) {
Tk_FreeGC(Tk_Display(instancePtr->tkwin), instancePtr->gc);
}
instancePtr->gc = gc;
@@ -441,10 +441,10 @@ ImgBmapConfigureInstance(
* it clear that this instance cannot be displayed. Then report the error.
*/
- if (instancePtr->gc != None) {
+ if (instancePtr->gc != NULL) {
Tk_FreeGC(Tk_Display(instancePtr->tkwin), instancePtr->gc);
}
- instancePtr->gc = None;
+ instancePtr->gc = NULL;
Tcl_AppendObjToErrorInfo(masterPtr->interp, Tcl_ObjPrintf(
"\n (while configuring image \"%s\")", Tk_NameOfImage(
masterPtr->tkMaster)));
@@ -848,7 +848,7 @@ ImgBmapGet(
instancePtr->bg = NULL;
instancePtr->bitmap = None;
instancePtr->mask = None;
- instancePtr->gc = None;
+ instancePtr->gc = NULL;
instancePtr->nextPtr = masterPtr->instancePtr;
masterPtr->instancePtr = instancePtr;
ImgBmapConfigureInstance(instancePtr);
@@ -902,7 +902,7 @@ ImgBmapDisplay(
* creating the image instance so it can't be displayed.
*/
- if (instancePtr->gc == None) {
+ if (instancePtr->gc == NULL) {
return;
}
@@ -972,7 +972,7 @@ ImgBmapFree(
if (instancePtr->mask != None) {
Tk_FreePixmap(display, instancePtr->mask);
}
- if (instancePtr->gc != None) {
+ if (instancePtr->gc != NULL) {
Tk_FreeGC(display, instancePtr->gc);
}
if (instancePtr->masterPtr->instancePtr == instancePtr) {
diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c
index 5c29622..e3fe8f6 100644
--- a/generic/tkImgGIF.c
+++ b/generic/tkImgGIF.c
@@ -1364,6 +1364,7 @@ ReadImage(
}
pixelPtr = imagePtr + (ypos) * len * ((transparent>=0)?4:3);
}
+
/*
* Now read until the final zero byte.
* It was observed that there might be 1 length blocks
diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c
index 1dc8840..f67ab36 100644
--- a/generic/tkImgPhInstance.c
+++ b/generic/tkImgPhInstance.c
@@ -1589,7 +1589,7 @@ TkImgDisposeInstance(
if (instancePtr->pixels != None) {
Tk_FreePixmap(instancePtr->display, instancePtr->pixels);
}
- if (instancePtr->gc != None) {
+ if (instancePtr->gc != NULL) {
Tk_FreeGC(instancePtr->display, instancePtr->gc);
}
if (instancePtr->imagePtr != NULL) {
diff --git a/generic/tkInt.decls b/generic/tkInt.decls
index 04eecf6..3a3cbc7 100644
--- a/generic/tkInt.decls
+++ b/generic/tkInt.decls
@@ -1016,7 +1016,7 @@ declare 47 aqua {
Tk_Window TkMacOSXGetCapture(void)
}
declare 49 aqua {
- Window TkGetTransientMaster(TkWindow *winPtr)
+ Tk_Window TkGetTransientMaster(TkWindow *winPtr)
}
declare 50 aqua {
int TkGenerateButtonEvent(int x, int y, Window window, unsigned int state)
diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h
index 9bc76c0..4162396 100644
--- a/generic/tkIntPlatDecls.h
+++ b/generic/tkIntPlatDecls.h
@@ -243,7 +243,7 @@ EXTERN int TkpIsWindowFloating(void *window);
EXTERN Tk_Window TkMacOSXGetCapture(void);
/* Slot 48 is reserved */
/* 49 */
-EXTERN Window TkGetTransientMaster(TkWindow *winPtr);
+EXTERN Tk_Window TkGetTransientMaster(TkWindow *winPtr);
/* 50 */
EXTERN int TkGenerateButtonEvent(int x, int y, Window window,
unsigned int state);
@@ -392,7 +392,7 @@ typedef struct TkIntPlatStubs {
int (*tkpIsWindowFloating) (void *window); /* 46 */
Tk_Window (*tkMacOSXGetCapture) (void); /* 47 */
void (*reserved48)(void);
- Window (*tkGetTransientMaster) (TkWindow *winPtr); /* 49 */
+ Tk_Window (*tkGetTransientMaster) (TkWindow *winPtr); /* 49 */
int (*tkGenerateButtonEvent) (int x, int y, Window window, unsigned int state); /* 50 */
void (*tkGenWMDestroyEvent) (Tk_Window tkwin); /* 51 */
void (*tkMacOSXSetDrawingEnabled) (TkWindow *winPtr, int flag); /* 52 */
diff --git a/generic/tkListbox.c b/generic/tkListbox.c
index b3b8ce7..3a0237c 100644
--- a/generic/tkListbox.c
+++ b/generic/tkListbox.c
@@ -542,13 +542,13 @@ Tk_ListboxObjCmd(
listPtr->itemAttrTable = ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(listPtr->itemAttrTable, TCL_ONE_WORD_KEYS);
listPtr->relief = TK_RELIEF_RAISED;
- listPtr->textGC = None;
- listPtr->selFgColorPtr = None;
- listPtr->selTextGC = None;
+ listPtr->textGC = NULL;
+ listPtr->selFgColorPtr = NULL;
+ listPtr->selTextGC = NULL;
listPtr->fullLines = 1;
listPtr->xScrollUnit = 1;
listPtr->exportSelection = 1;
- listPtr->cursor = None;
+ listPtr->cursor = NULL;
listPtr->state = STATE_NORMAL;
listPtr->gray = None;
listPtr->justify = TK_JUSTIFY_LEFT;
@@ -1489,10 +1489,10 @@ DestroyListbox(
* Tk_FreeOptions handle all the standard option-related stuff.
*/
- if (listPtr->textGC != None) {
+ if (listPtr->textGC != NULL) {
Tk_FreeGC(listPtr->display, listPtr->textGC);
}
- if (listPtr->selTextGC != None) {
+ if (listPtr->selTextGC != NULL) {
Tk_FreeGC(listPtr->display, listPtr->selTextGC);
}
if (listPtr->gray != None) {
@@ -1792,7 +1792,7 @@ ListboxWorldChanged(
gcValues.font = Tk_FontId(listPtr->tkfont);
gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues);
- if (listPtr->textGC != None) {
+ if (listPtr->textGC != NULL) {
Tk_FreeGC(listPtr->display, listPtr->textGC);
}
listPtr->textGC = gc;
@@ -1803,7 +1803,7 @@ ListboxWorldChanged(
gcValues.font = Tk_FontId(listPtr->tkfont);
mask = GCForeground | GCFont;
gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues);
- if (listPtr->selTextGC != None) {
+ if (listPtr->selTextGC != NULL) {
Tk_FreeGC(listPtr->display, listPtr->selTextGC);
}
listPtr->selTextGC = gc;
diff --git a/generic/tkMain.c b/generic/tkMain.c
index ffcaecf..eb311ff 100644
--- a/generic/tkMain.c
+++ b/generic/tkMain.c
@@ -37,7 +37,7 @@ extern int TkCygwinMainEx(int, char **, Tcl_AppInitProc *, Tcl_Interp *);
* The default prompt used when the user has not overridden it.
*/
-#define DEFAULT_PRIMARY_PROMPT "% "
+static const char DEFAULT_PRIMARY_PROMPT[] = "% ";
/*
* This file can be compiled on Windows in UNICODE mode, as well as
@@ -512,7 +512,7 @@ Prompt(
chan = Tcl_GetStdChannel(TCL_STDOUT);
if (chan != NULL) {
Tcl_WriteChars(chan, DEFAULT_PRIMARY_PROMPT,
- strlen(DEFAULT_PRIMARY_PROMPT));
+ sizeof(DEFAULT_PRIMARY_PROMPT) - 1);
}
}
} else {
diff --git a/generic/tkMenu.c b/generic/tkMenu.c
index 14d89cd..dd29d79 100644
--- a/generic/tkMenu.c
+++ b/generic/tkMenu.c
@@ -458,7 +458,7 @@ Tk_MenuObjCmd(
Tk_PathName(menuPtr->tkwin), MenuWidgetObjCmd, menuPtr,
MenuCmdDeletedProc);
menuPtr->active = -1;
- menuPtr->cursorPtr = None;
+ menuPtr->cursorPtr = NULL;
menuPtr->masterMenuPtr = menuPtr;
menuPtr->menuType = UNKNOWN_TYPE;
TkMenuInitializeDrawingFields(menuPtr);
@@ -873,32 +873,37 @@ MenuWidgetObjCmd(
break;
}
case MENU_POST: {
- int x, y;
+ int x, y, index = -1;
- if (objc != 4) {
- Tcl_WrongNumArgs(interp, 2, objv, "x y");
+ if (objc != 4 && objc != 5) {
+ Tcl_WrongNumArgs(interp, 2, objv, "x y ?index?");
goto error;
}
if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK)
|| (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK)) {
goto error;
}
+ if (objc == 5) {
+ if (TkGetMenuIndex(interp, menuPtr, objv[4], 0, &index) != TCL_OK) {
+ goto error;
+ }
+ }
/*
- * Tearoff menus are posted differently on Mac and Windows than
- * non-tearoffs. TkpPostMenu does not actually map the menu's window
- * on those platforms, and popup menus have to be handled specially.
- * Also, menubar menues are not intended to be posted (bug 1567681,
- * 2160206).
+ * Tearoff menus are the same as ordinary menus on the Mac and are
+ * posted differently on Windows than non-tearoffs. TkpPostMenu
+ * does not actually map the menu's window on those platforms, and
+ * popup menus have to be handled specially. Also, menubar menus are
+ * not intended to be posted (bug 1567681, 2160206).
*/
if (menuPtr->menuType == MENUBAR) {
Tcl_AppendResult(interp, "a menubar menu cannot be posted", NULL);
return TCL_ERROR;
} else if (menuPtr->menuType != TEAROFF_MENU) {
- result = TkpPostMenu(interp, menuPtr, x, y);
+ result = TkpPostMenu(interp, menuPtr, x, y, index);
} else {
- result = TkPostTearoffMenu(interp, menuPtr, x, y);
+ result = TkpPostTearoffMenu(interp, menuPtr, x, y, index);
}
break;
}
diff --git a/generic/tkMenu.h b/generic/tkMenu.h
index 6d51a72..8e25059 100644
--- a/generic/tkMenu.h
+++ b/generic/tkMenu.h
@@ -75,8 +75,8 @@ typedef struct TkMenuEntry {
* of character to underline (-1 means don't
* underline anything). */
Tcl_Obj *underlinePtr; /* Index of character to underline. */
- Tcl_Obj *bitmapPtr; /* Bitmap to display in menu entry, or None.
- * If not None then label is ignored. */
+ Tcl_Obj *bitmapPtr; /* Bitmap to display in menu entry, or NULL.
+ * If not NULL then label is ignored. */
Tcl_Obj *imagePtr; /* Name of image to display, or NULL. If not
* NULL, bitmap, text, and textVarName are
* ignored. */
@@ -175,7 +175,7 @@ typedef struct TkMenuEntry {
* NULL means use overall disabledGC from menu
* structure. See comments for disabledFg in
* menu structure for more information. */
- GC indicatorGC; /* For drawing indicators. None means use GC
+ GC indicatorGC; /* For drawing indicators. NULL means use GC
* from menu. */
/*
@@ -340,7 +340,7 @@ typedef struct TkMenu {
Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the
* C code, but used by keyboard traversal
* scripts. Malloc'ed, but may be NULL. */
- Tcl_Obj *cursorPtr; /* Current cursor for window, or None. */
+ Tcl_Obj *cursorPtr; /* Current cursor for window, or NULL. */
Tcl_Obj *postCommandPtr; /* Used to detect cycles in cascade hierarchy
* trees when preprocessing postcommands on
* some platforms. See PostMenu for more
@@ -521,7 +521,7 @@ MODULE_SCOPE int TkPostCommand(TkMenu *menuPtr);
MODULE_SCOPE int TkPostSubmenu(Tcl_Interp *interp, TkMenu *menuPtr,
TkMenuEntry *mePtr);
MODULE_SCOPE int TkPostTearoffMenu(Tcl_Interp *interp, TkMenu *menuPtr,
- int x, int y);
+ int x, int y);
MODULE_SCOPE int TkPreprocessMenu(TkMenu *menuPtr);
MODULE_SCOPE void TkRecomputeMenu(TkMenu *menuPtr);
@@ -544,7 +544,9 @@ MODULE_SCOPE void TkpMenuInit(void);
MODULE_SCOPE int TkpMenuNewEntry(TkMenuEntry *mePtr);
MODULE_SCOPE int TkpNewMenu(TkMenu *menuPtr);
MODULE_SCOPE int TkpPostMenu(Tcl_Interp *interp, TkMenu *menuPtr,
- int x, int y);
+ int x, int y, int index);
+MODULE_SCOPE int TkpPostTearoffMenu(Tcl_Interp *interp, TkMenu *menuPtr,
+ int x, int y, int index);
MODULE_SCOPE void TkpSetWindowMenuBar(Tk_Window tkwin, TkMenu *menuPtr);
#endif /* _TKMENU */
diff --git a/generic/tkMenuDraw.c b/generic/tkMenuDraw.c
index 3f492db..bd00d38 100644
--- a/generic/tkMenuDraw.c
+++ b/generic/tkMenuDraw.c
@@ -43,12 +43,12 @@ void
TkMenuInitializeDrawingFields(
TkMenu *menuPtr) /* The menu we are initializing. */
{
- menuPtr->textGC = None;
+ menuPtr->textGC = NULL;
menuPtr->gray = None;
- menuPtr->disabledGC = None;
- menuPtr->activeGC = None;
- menuPtr->indicatorGC = None;
- menuPtr->disabledImageGC = None;
+ menuPtr->disabledGC = NULL;
+ menuPtr->activeGC = NULL;
+ menuPtr->indicatorGC = NULL;
+ menuPtr->disabledImageGC = NULL;
menuPtr->totalWidth = menuPtr->totalHeight = 0;
}
@@ -79,10 +79,10 @@ TkMenuInitializeEntryDrawingFields(
mePtr->y = 0;
mePtr->indicatorSpace = 0;
mePtr->labelWidth = 0;
- mePtr->textGC = None;
- mePtr->activeGC = None;
- mePtr->disabledGC = None;
- mePtr->indicatorGC = None;
+ mePtr->textGC = NULL;
+ mePtr->activeGC = NULL;
+ mePtr->disabledGC = NULL;
+ mePtr->indicatorGC = NULL;
}
/*
@@ -106,22 +106,22 @@ void
TkMenuFreeDrawOptions(
TkMenu *menuPtr)
{
- if (menuPtr->textGC != None) {
+ if (menuPtr->textGC != NULL) {
Tk_FreeGC(menuPtr->display, menuPtr->textGC);
}
- if (menuPtr->disabledImageGC != None) {
+ if (menuPtr->disabledImageGC != NULL) {
Tk_FreeGC(menuPtr->display, menuPtr->disabledImageGC);
}
if (menuPtr->gray != None) {
Tk_FreeBitmap(menuPtr->display, menuPtr->gray);
}
- if (menuPtr->disabledGC != None) {
+ if (menuPtr->disabledGC != NULL) {
Tk_FreeGC(menuPtr->display, menuPtr->disabledGC);
}
- if (menuPtr->activeGC != None) {
+ if (menuPtr->activeGC != NULL) {
Tk_FreeGC(menuPtr->display, menuPtr->activeGC);
}
- if (menuPtr->indicatorGC != None) {
+ if (menuPtr->indicatorGC != NULL) {
Tk_FreeGC(menuPtr->display, menuPtr->indicatorGC);
}
}
@@ -147,16 +147,16 @@ void
TkMenuEntryFreeDrawOptions(
TkMenuEntry *mePtr)
{
- if (mePtr->textGC != None) {
+ if (mePtr->textGC != NULL) {
Tk_FreeGC(mePtr->menuPtr->display, mePtr->textGC);
}
- if (mePtr->disabledGC != None) {
+ if (mePtr->disabledGC != NULL) {
Tk_FreeGC(mePtr->menuPtr->display, mePtr->disabledGC);
}
- if (mePtr->activeGC != None) {
+ if (mePtr->activeGC != NULL) {
Tk_FreeGC(mePtr->menuPtr->display, mePtr->activeGC);
}
- if (mePtr->indicatorGC != None) {
+ if (mePtr->indicatorGC != NULL) {
Tk_FreeGC(mePtr->menuPtr->display, mePtr->indicatorGC);
}
}
@@ -205,7 +205,7 @@ TkMenuConfigureDrawOptions(
gcValues.background = Tk_3DBorderColor(border)->pixel;
newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCBackground|GCFont,
&gcValues);
- if (menuPtr->textGC != None) {
+ if (menuPtr->textGC != NULL) {
Tk_FreeGC(menuPtr->display, menuPtr->textGC);
}
menuPtr->textGC = newGC;
@@ -233,7 +233,7 @@ TkMenuConfigureDrawOptions(
}
}
newGC = Tk_GetGC(menuPtr->tkwin, mask, &gcValues);
- if (menuPtr->disabledGC != None) {
+ if (menuPtr->disabledGC != NULL) {
Tk_FreeGC(menuPtr->display, menuPtr->disabledGC);
}
menuPtr->disabledGC = newGC;
@@ -249,7 +249,7 @@ TkMenuConfigureDrawOptions(
newGC = Tk_GetGC(menuPtr->tkwin,
GCForeground|GCFillStyle|GCStipple, &gcValues);
}
- if (menuPtr->disabledImageGC != None) {
+ if (menuPtr->disabledImageGC != NULL) {
Tk_FreeGC(menuPtr->display, menuPtr->disabledImageGC);
}
menuPtr->disabledImageGC = newGC;
@@ -262,7 +262,7 @@ TkMenuConfigureDrawOptions(
gcValues.background = Tk_3DBorderColor(activeBorder)->pixel;
newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCBackground|GCFont,
&gcValues);
- if (menuPtr->activeGC != None) {
+ if (menuPtr->activeGC != NULL) {
Tk_FreeGC(menuPtr->display, menuPtr->activeGC);
}
menuPtr->activeGC = newGC;
@@ -273,7 +273,7 @@ TkMenuConfigureDrawOptions(
gcValues.background = Tk_3DBorderColor(border)->pixel;
newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCBackground|GCFont,
&gcValues);
- if (menuPtr->indicatorGC != None) {
+ if (menuPtr->indicatorGC != NULL) {
Tk_FreeGC(menuPtr->display, menuPtr->indicatorGC);
}
menuPtr->indicatorGC = newGC;
@@ -385,24 +385,24 @@ TkMenuConfigureEntryDrawOptions(
GCForeground|GCBackground|GCFont|GCGraphicsExposures,
&gcValues);
} else {
- newGC = None;
- newActiveGC = None;
- newDisabledGC = None;
- newIndicatorGC = None;
+ newGC = NULL;
+ newActiveGC = NULL;
+ newDisabledGC = NULL;
+ newIndicatorGC = NULL;
}
- if (mePtr->textGC != None) {
+ if (mePtr->textGC != NULL) {
Tk_FreeGC(menuPtr->display, mePtr->textGC);
}
mePtr->textGC = newGC;
- if (mePtr->activeGC != None) {
+ if (mePtr->activeGC != NULL) {
Tk_FreeGC(menuPtr->display, mePtr->activeGC);
}
mePtr->activeGC = newActiveGC;
- if (mePtr->disabledGC != None) {
+ if (mePtr->disabledGC != NULL) {
Tk_FreeGC(menuPtr->display, mePtr->disabledGC);
}
mePtr->disabledGC = newDisabledGC;
- if (mePtr->indicatorGC != None) {
+ if (mePtr->indicatorGC != NULL) {
Tk_FreeGC(menuPtr->display, mePtr->indicatorGC);
}
mePtr->indicatorGC = newIndicatorGC;
@@ -807,9 +807,8 @@ TkMenuImageProc(
*
* TkPostTearoffMenu --
*
- * Posts a menu on the screen. Used to post tearoff menus. On Unix, all
- * menus are posted this way. Adjusts the menu's position so that it fits
- * on the screen, and maps and raises the menu.
+ * Posts a tearoff menu on the screen. Adjusts the menu's position so
+ * that it fits on the screen, and maps and raises the menu.
*
* Results:
* Returns a standard Tcl Error.
@@ -827,64 +826,7 @@ TkPostTearoffMenu(
int x, int y) /* The root X,Y coordinates where we are
* posting */
{
- int vRootX, vRootY, vRootWidth, vRootHeight;
- int result;
-
- TkActivateMenuEntry(menuPtr, -1);
- TkRecomputeMenu(menuPtr);
- result = TkPostCommand(menuPtr);
- if (result != TCL_OK) {
- return result;
- }
-
- /*
- * The post commands could have deleted the menu, which means we are dead
- * and should go away.
- */
-
- if (menuPtr->tkwin == NULL) {
- return TCL_OK;
- }
-
- /*
- * Adjust the position of the menu if necessary to keep it visible on the
- * screen. There are two special tricks to make this work right:
- *
- * 1. If a virtual root window manager is being used then the coordinates
- * are in the virtual root window of menuPtr's parent; since the menu
- * uses override-redirect mode it will be in the *real* root window for
- * the screen, so we have to map the coordinates from the virtual root
- * (if any) to the real root. Can't get the virtual root from the menu
- * itself (it will never be seen by the wm) so use its parent instead
- * (it would be better to have an an option that names a window to use
- * for this...).
- * 2. The menu may not have been mapped yet, so its current size might be
- * the default 1x1. To compute how much space it needs, use its
- * requested size, not its actual size.
- */
-
- Tk_GetVRootGeometry(Tk_Parent(menuPtr->tkwin), &vRootX, &vRootY,
- &vRootWidth, &vRootHeight);
- vRootWidth -= Tk_ReqWidth(menuPtr->tkwin);
- if (x > vRootX + vRootWidth) {
- x = vRootX + vRootWidth;
- }
- if (x < vRootX) {
- x = vRootX;
- }
- vRootHeight -= Tk_ReqHeight(menuPtr->tkwin);
- if (y > vRootY + vRootHeight) {
- y = vRootY + vRootHeight;
- }
- if (y < vRootY) {
- y = vRootY;
- }
- Tk_MoveToplevelWindow(menuPtr->tkwin, x, y);
- if (!Tk_IsMapped(menuPtr->tkwin)) {
- Tk_MapWindow(menuPtr->tkwin);
- }
- TkWmRestackToplevel((TkWindow *) menuPtr->tkwin, Above, NULL);
- return TCL_OK;
+ return TkpPostTearoffMenu(interp, menuPtr, x, y, -1);
}
/*
diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c
index 125fe72..fa5b63f 100644
--- a/generic/tkMenubutton.c
+++ b/generic/tkMenubutton.c
@@ -279,11 +279,11 @@ Tk_MenubuttonObjCmd(
mbPtr->normalFg = NULL;
mbPtr->activeFg = NULL;
mbPtr->disabledFg = NULL;
- mbPtr->normalTextGC = None;
- mbPtr->activeTextGC = None;
+ mbPtr->normalTextGC = NULL;
+ mbPtr->activeTextGC = NULL;
mbPtr->gray = None;
- mbPtr->disabledGC = None;
- mbPtr->stippleGC = None;
+ mbPtr->disabledGC = NULL;
+ mbPtr->stippleGC = NULL;
mbPtr->leftBearing = 0;
mbPtr->rightBearing = 0;
mbPtr->widthString = NULL;
@@ -300,7 +300,7 @@ Tk_MenubuttonObjCmd(
mbPtr->indicatorWidth = 0;
mbPtr->indicatorHeight = 0;
mbPtr->direction = DIRECTION_FLUSH;
- mbPtr->cursor = None;
+ mbPtr->cursor = NULL;
mbPtr->takeFocus = NULL;
mbPtr->flags = 0;
@@ -443,16 +443,16 @@ DestroyMenuButton(
if (mbPtr->image != NULL) {
Tk_FreeImage(mbPtr->image);
}
- if (mbPtr->normalTextGC != None) {
+ if (mbPtr->normalTextGC != NULL) {
Tk_FreeGC(mbPtr->display, mbPtr->normalTextGC);
}
- if (mbPtr->activeTextGC != None) {
+ if (mbPtr->activeTextGC != NULL) {
Tk_FreeGC(mbPtr->display, mbPtr->activeTextGC);
}
- if (mbPtr->disabledGC != None) {
+ if (mbPtr->disabledGC != NULL) {
Tk_FreeGC(mbPtr->display, mbPtr->disabledGC);
}
- if (mbPtr->stippleGC != None) {
+ if (mbPtr->stippleGC != NULL) {
Tk_FreeGC(mbPtr->display, mbPtr->stippleGC);
}
if (mbPtr->gray != None) {
@@ -690,7 +690,7 @@ TkMenuButtonWorldChanged(
gcValues.graphics_exposures = False;
mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures;
gc = Tk_GetGC(mbPtr->tkwin, mask, &gcValues);
- if (mbPtr->normalTextGC != None) {
+ if (mbPtr->normalTextGC != NULL) {
Tk_FreeGC(mbPtr->display, mbPtr->normalTextGC);
}
mbPtr->normalTextGC = gc;
@@ -699,7 +699,7 @@ TkMenuButtonWorldChanged(
gcValues.background = Tk_3DBorderColor(mbPtr->activeBorder)->pixel;
mask = GCForeground | GCBackground | GCFont;
gc = Tk_GetGC(mbPtr->tkwin, mask, &gcValues);
- if (mbPtr->activeTextGC != None) {
+ if (mbPtr->activeTextGC != NULL) {
Tk_FreeGC(mbPtr->display, mbPtr->activeTextGC);
}
mbPtr->activeTextGC = gc;
@@ -710,7 +710,7 @@ TkMenuButtonWorldChanged(
* Create the GC that can be used for stippling
*/
- if (mbPtr->stippleGC == None) {
+ if (mbPtr->stippleGC == NULL) {
gcValues.foreground = gcValues.background;
mask = GCForeground;
if (mbPtr->gray == None) {
@@ -736,7 +736,7 @@ TkMenuButtonWorldChanged(
gcValues.foreground = gcValues.background;
}
gc = Tk_GetGC(mbPtr->tkwin, mask, &gcValues);
- if (mbPtr->disabledGC != None) {
+ if (mbPtr->disabledGC != NULL) {
Tk_FreeGC(mbPtr->display, mbPtr->disabledGC);
}
mbPtr->disabledGC = gc;
diff --git a/generic/tkMenubutton.h b/generic/tkMenubutton.h
index e8dc12f..1dbacb3 100644
--- a/generic/tkMenubutton.h
+++ b/generic/tkMenubutton.h
@@ -170,7 +170,7 @@ typedef struct {
* "left" and "right" will pop the menu left
* or right, and the active item will be next
* to the button. */
- Tk_Cursor cursor; /* Current cursor for window, or None. */
+ Tk_Cursor cursor; /* Current cursor for window, or NULL. */
char *takeFocus; /* Value of -takefocus option; not used in the
* C code, but used by keyboard traversal
* scripts. Malloc'ed, but may be NULL. */
diff --git a/generic/tkMessage.c b/generic/tkMessage.c
index c009fe7..306572e 100644
--- a/generic/tkMessage.c
+++ b/generic/tkMessage.c
@@ -256,11 +256,11 @@ Tk_MessageObjCmd(
MessageCmdDeletedProc);
msgPtr->optionTable = optionTable;
msgPtr->relief = TK_RELIEF_FLAT;
- msgPtr->textGC = None;
+ msgPtr->textGC = NULL;
msgPtr->anchor = TK_ANCHOR_CENTER;
msgPtr->aspect = 150;
msgPtr->justify = TK_JUSTIFY_LEFT;
- msgPtr->cursor = None;
+ msgPtr->cursor = NULL;
Tk_SetClass(msgPtr->tkwin, "Message");
Tk_SetClassProcs(msgPtr->tkwin, &messageClass, msgPtr);
@@ -398,7 +398,7 @@ DestroyMessage(
* Tk_FreeConfigOptions handle all the standard option-related stuff.
*/
- if (msgPtr->textGC != None) {
+ if (msgPtr->textGC != NULL) {
Tk_FreeGC(msgPtr->display, msgPtr->textGC);
}
if (msgPtr->textLayout != NULL) {
@@ -525,7 +525,7 @@ MessageWorldChanged(
ClientData instanceData) /* Information about widget. */
{
XGCValues gcValues;
- GC gc = None;
+ GC gc = NULL;
Tk_FontMetrics fm;
Message *msgPtr = instanceData;
@@ -536,7 +536,7 @@ MessageWorldChanged(
gcValues.font = Tk_FontId(msgPtr->tkfont);
gcValues.foreground = msgPtr->fgColorPtr->pixel;
gc = Tk_GetGC(msgPtr->tkwin, GCForeground | GCFont, &gcValues);
- if (msgPtr->textGC != None) {
+ if (msgPtr->textGC != NULL) {
Tk_FreeGC(msgPtr->display, msgPtr->textGC);
}
msgPtr->textGC = gc;
diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c
index 4473a3e..d83c30b 100644
--- a/generic/tkOldConfig.c
+++ b/generic/tkOldConfig.c
@@ -481,16 +481,16 @@ DoConfig(
Tk_Cursor newCursor, oldCursor;
if (nullValue) {
- newCursor = None;
+ newCursor = NULL;
} else {
uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value);
newCursor = Tk_GetCursor(interp, tkwin, uid);
- if (newCursor == None) {
+ if (newCursor == NULL) {
return TCL_ERROR;
}
}
oldCursor = *((Tk_Cursor *) ptr);
- if (oldCursor != None) {
+ if (oldCursor != NULL) {
Tk_FreeCursor(Tk_Display(tkwin), oldCursor);
}
*((Tk_Cursor *) ptr) = newCursor;
@@ -842,7 +842,7 @@ FormatConfigValue(
case TK_CONFIG_ACTIVE_CURSOR: {
Tk_Cursor cursor = *((Tk_Cursor *) ptr);
- if (cursor != None) {
+ if (cursor != NULL) {
result = Tk_NameOfCursor(Tk_Display(tkwin), cursor);
}
break;
@@ -1027,9 +1027,9 @@ Tk_FreeOptions(
break;
case TK_CONFIG_CURSOR:
case TK_CONFIG_ACTIVE_CURSOR:
- if (*((Tk_Cursor *) ptr) != None) {
+ if (*((Tk_Cursor *) ptr) != NULL) {
Tk_FreeCursor(display, *((Tk_Cursor *) ptr));
- *((Tk_Cursor *) ptr) = None;
+ *((Tk_Cursor *) ptr) = NULL;
}
}
}
diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c
index c0bbf5f..faec67a 100644
--- a/generic/tkPanedWindow.c
+++ b/generic/tkPanedWindow.c
@@ -448,9 +448,9 @@ Tk_PanedWindowObjCmd(
pwPtr->optionTable = pwOpts->pwOptions;
pwPtr->slaveOpts = pwOpts->slaveOpts;
pwPtr->relief = TK_RELIEF_RAISED;
- pwPtr->gc = None;
- pwPtr->cursor = None;
- pwPtr->sashCursor = None;
+ pwPtr->gc = NULL;
+ pwPtr->cursor = NULL;
+ pwPtr->sashCursor = NULL;
/*
* Keep a hold of the associated tkwin until we destroy the widget,
@@ -862,7 +862,7 @@ ConfigureSlaves(
index = -1;
haveLoc = 0;
- if (options.after != None) {
+ if (options.after != NULL) {
tkwin = options.after;
haveLoc = 1;
for (i = 0; i < pwPtr->numSlaves; i++) {
@@ -871,7 +871,7 @@ ConfigureSlaves(
break;
}
}
- } else if (options.before != None) {
+ } else if (options.before != NULL) {
tkwin = options.before;
haveLoc = 1;
for (i = 0; i < pwPtr->numSlaves; i++) {
@@ -1304,7 +1304,7 @@ PanedWindowWorldChanged(
gcValues.background = Tk_3DBorderColor(pwPtr->background)->pixel;
newGC = Tk_GetGC(pwPtr->tkwin, GCBackground, &gcValues);
- if (pwPtr->gc != None) {
+ if (pwPtr->gc != NULL) {
Tk_FreeGC(pwPtr->display, pwPtr->gc);
}
pwPtr->gc = newGC;
@@ -2044,10 +2044,10 @@ Unlink(
for (i = 0; i < masterPtr->numSlaves; i++) {
if (masterPtr->slaves[i]->before == slavePtr->tkwin) {
- masterPtr->slaves[i]->before = None;
+ masterPtr->slaves[i]->before = NULL;
}
if (masterPtr->slaves[i]->after == slavePtr->tkwin) {
- masterPtr->slaves[i]->after = None;
+ masterPtr->slaves[i]->after = NULL;
}
}
diff --git a/generic/tkPlace.c b/generic/tkPlace.c
index b225e26..08d5c8e 100644
--- a/generic/tkPlace.c
+++ b/generic/tkPlace.c
@@ -395,7 +395,7 @@ CreateSlave(
slavePtr = ckalloc(sizeof(Slave));
memset(slavePtr, 0, sizeof(Slave));
slavePtr->tkwin = tkwin;
- slavePtr->inTkwin = None;
+ slavePtr->inTkwin = NULL;
slavePtr->anchor = TK_ANCHOR_NW;
slavePtr->borderMode = BM_INSIDE;
slavePtr->optionTable = table;
@@ -1185,6 +1185,12 @@ PlaceRequestProc(
if ((slavePtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH))
&& (slavePtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT))) {
+ /*
+ * Send a ConfigureNotify to indicate that the size change
+ * request was rejected.
+ */
+
+ TkDoConfigureNotify((TkWindow *)(slavePtr->tkwin));
return;
}
masterPtr = slavePtr->masterPtr;
diff --git a/generic/tkRectOval.c b/generic/tkRectOval.c
index 4d48fe7..359d3ef 100644
--- a/generic/tkRectOval.c
+++ b/generic/tkRectOval.c
@@ -258,7 +258,7 @@ CreateRectOval(
rectOvalPtr->fillStipple = None;
rectOvalPtr->activeFillStipple = None;
rectOvalPtr->disabledFillStipple = None;
- rectOvalPtr->fillGC = None;
+ rectOvalPtr->fillGC = NULL;
/*
* Process the arguments to fill in the item record.
@@ -466,9 +466,9 @@ ConfigureRectOval(
mask |= GCCapStyle;
newGC = Tk_GetGC(tkwin, mask, &gcValues);
} else {
- newGC = None;
+ newGC = NULL;
}
- if (rectOvalPtr->outline.gc != None) {
+ if (rectOvalPtr->outline.gc != NULL) {
Tk_FreeGC(Tk_Display(tkwin), rectOvalPtr->outline.gc);
}
rectOvalPtr->outline.gc = newGC;
@@ -500,7 +500,7 @@ ConfigureRectOval(
}
if (color == NULL) {
- newGC = None;
+ newGC = NULL;
} else {
gcValues.foreground = color->pixel;
if (stipple != None) {
@@ -515,14 +515,13 @@ ConfigureRectOval(
* Mac OS X CG drawing needs access to the outline linewidth even for
* fills (as linewidth controls antialiasing).
*/
-
- gcValues.line_width = rectOvalPtr->outline.gc != None ?
+ gcValues.line_width = rectOvalPtr->outline.gc != NULL ?
rectOvalPtr->outline.gc->line_width : 0;
mask |= GCLineWidth;
#endif
newGC = Tk_GetGC(tkwin, mask, &gcValues);
}
- if (rectOvalPtr->fillGC != None) {
+ if (rectOvalPtr->fillGC != NULL) {
Tk_FreeGC(Tk_Display(tkwin), rectOvalPtr->fillGC);
}
rectOvalPtr->fillGC = newGC;
@@ -595,7 +594,7 @@ DeleteRectOval(
if (rectOvalPtr->disabledFillStipple != None) {
Tk_FreeBitmap(display, rectOvalPtr->disabledFillStipple);
}
- if (rectOvalPtr->fillGC != None) {
+ if (rectOvalPtr->fillGC != NULL) {
Tk_FreeGC(display, rectOvalPtr->fillGC);
}
}
@@ -664,7 +663,7 @@ ComputeRectOvalBbox(
rectOvalPtr->bbox[0] = tmpX;
}
- if (rectOvalPtr->outline.gc == None) {
+ if (rectOvalPtr->outline.gc == NULL) {
/*
* The Win32 switch was added for 8.3 to solve a problem with ovals
* leaving traces on bottom and right of 1 pixel. This may not be the
@@ -878,7 +877,7 @@ DisplayRectOval(
}
}
- if (rectOvalPtr->fillGC != None) {
+ if (rectOvalPtr->fillGC != NULL) {
if (fillStipple != None) {
Tk_TSOffset *tsoffset;
int w = 0, h = 0;
@@ -922,7 +921,7 @@ DisplayRectOval(
}
}
- if (rectOvalPtr->outline.gc != None) {
+ if (rectOvalPtr->outline.gc != NULL) {
Tk_ChangeOutlineGC(canvas, itemPtr, &(rectOvalPtr->outline));
if (rectOvalPtr->header.typePtr == &tkRectangleType) {
XDrawRectangle(display, drawable, rectOvalPtr->outline.gc,
@@ -993,7 +992,7 @@ RectToPoint(
y1 = rectPtr->bbox[1];
x2 = rectPtr->bbox[2];
y2 = rectPtr->bbox[3];
- if (rectPtr->outline.gc != None) {
+ if (rectPtr->outline.gc != NULL) {
inc = width/2.0;
x1 -= inc;
y1 -= inc;
@@ -1009,7 +1008,7 @@ RectToPoint(
if ((pointPtr[0] >= x1) && (pointPtr[0] < x2)
&& (pointPtr[1] >= y1) && (pointPtr[1] < y2)) {
- if ((rectPtr->fillGC != None) || (rectPtr->outline.gc == None)) {
+ if ((rectPtr->fillGC != NULL) || (rectPtr->outline.gc == NULL)) {
return 0.0;
}
xDiff = pointPtr[0] - x1;
@@ -1105,8 +1104,8 @@ OvalToPoint(
}
- filled = ovalPtr->fillGC != None;
- if (ovalPtr->outline.gc == None) {
+ filled = ovalPtr->fillGC != NULL;
+ if (ovalPtr->outline.gc == NULL) {
width = 0.0;
filled = 1;
}
@@ -1161,7 +1160,7 @@ RectToArea(
}
halfWidth = width/2.0;
- if (rectPtr->outline.gc == None) {
+ if (rectPtr->outline.gc == NULL) {
halfWidth = 0.0;
}
@@ -1171,7 +1170,7 @@ RectToArea(
|| (areaPtr[1] >= (rectPtr->bbox[3] + halfWidth))) {
return -1;
}
- if ((rectPtr->fillGC == None) && (rectPtr->outline.gc != None)
+ if ((rectPtr->fillGC == NULL) && (rectPtr->outline.gc != NULL)
&& (areaPtr[0] >= (rectPtr->bbox[0] + halfWidth))
&& (areaPtr[1] >= (rectPtr->bbox[1] + halfWidth))
&& (areaPtr[2] <= (rectPtr->bbox[2] - halfWidth))
@@ -1239,7 +1238,7 @@ OvalToArea(
*/
halfWidth = width/2.0;
- if (ovalPtr->outline.gc == None) {
+ if (ovalPtr->outline.gc == NULL) {
halfWidth = 0.0;
}
oval[0] = ovalPtr->bbox[0] - halfWidth;
@@ -1256,8 +1255,8 @@ OvalToArea(
* return "outside".
*/
- if ((result == 0) && (ovalPtr->outline.gc != None)
- && (ovalPtr->fillGC == None)) {
+ if ((result == 0) && (ovalPtr->outline.gc != NULL)
+ && (ovalPtr->fillGC == NULL)) {
double centerX, centerY, height;
double xDelta1, yDelta1, xDelta2, yDelta2;
diff --git a/generic/tkScale.c b/generic/tkScale.c
index 8b016a2..216fd02 100644
--- a/generic/tkScale.c
+++ b/generic/tkScale.c
@@ -270,11 +270,11 @@ Tk_ScaleObjCmd(
scalePtr->activeBorder = NULL;
scalePtr->sliderRelief = TK_RELIEF_RAISED;
scalePtr->troughColorPtr = NULL;
- scalePtr->troughGC = None;
- scalePtr->copyGC = None;
+ scalePtr->troughGC = NULL;
+ scalePtr->copyGC = NULL;
scalePtr->tkfont = NULL;
scalePtr->textColorPtr = NULL;
- scalePtr->textGC = None;
+ scalePtr->textGC = NULL;
scalePtr->relief = TK_RELIEF_FLAT;
scalePtr->highlightWidth = 0;
scalePtr->highlightBorder = NULL;
@@ -291,7 +291,7 @@ Tk_ScaleObjCmd(
scalePtr->vertTroughX = 0;
scalePtr->vertLabelX = 0;
scalePtr->fontHeight = 0;
- scalePtr->cursor = None;
+ scalePtr->cursor = NULL;
scalePtr->takeFocusPtr = NULL;
scalePtr->flags = NEVER_SET;
@@ -518,13 +518,13 @@ DestroyScale(
NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
ScaleVarProc, scalePtr);
}
- if (scalePtr->troughGC != None) {
+ if (scalePtr->troughGC != NULL) {
Tk_FreeGC(scalePtr->display, scalePtr->troughGC);
}
- if (scalePtr->copyGC != None) {
+ if (scalePtr->copyGC != NULL) {
Tk_FreeGC(scalePtr->display, scalePtr->copyGC);
}
- if (scalePtr->textGC != None) {
+ if (scalePtr->textGC != NULL) {
Tk_FreeGC(scalePtr->display, scalePtr->textGC);
}
Tk_FreeConfigOptions((char *) scalePtr, scalePtr->optionTable,
@@ -611,7 +611,7 @@ ConfigureScale(
TCL_GLOBAL_ONLY);
if ((valuePtr != NULL) &&
(Tcl_GetDoubleFromObj(NULL, valuePtr, &value) == TCL_OK)) {
- scalePtr->value = TkRoundToResolution(scalePtr, value);
+ scalePtr->value = TkRoundValueToResolution(scalePtr, value);
}
}
@@ -620,10 +620,10 @@ ConfigureScale(
* orientation and creating GCs.
*/
- scalePtr->fromValue = TkRoundToResolution(scalePtr,
+ scalePtr->fromValue = TkRoundValueToResolution(scalePtr,
scalePtr->fromValue);
- scalePtr->toValue = TkRoundToResolution(scalePtr, scalePtr->toValue);
- scalePtr->tickInterval = TkRoundToResolution(scalePtr,
+ scalePtr->toValue = TkRoundValueToResolution(scalePtr, scalePtr->toValue);
+ scalePtr->tickInterval = TkRoundIntervalToResolution(scalePtr,
scalePtr->tickInterval);
/*
@@ -729,7 +729,7 @@ ScaleWorldChanged(
gcValues.foreground = scalePtr->troughColorPtr->pixel;
gc = Tk_GetGC(scalePtr->tkwin, GCForeground, &gcValues);
- if (scalePtr->troughGC != None) {
+ if (scalePtr->troughGC != NULL) {
Tk_FreeGC(scalePtr->display, scalePtr->troughGC);
}
scalePtr->troughGC = gc;
@@ -737,12 +737,12 @@ ScaleWorldChanged(
gcValues.font = Tk_FontId(scalePtr->tkfont);
gcValues.foreground = scalePtr->textColorPtr->pixel;
gc = Tk_GetGC(scalePtr->tkwin, GCForeground | GCFont, &gcValues);
- if (scalePtr->textGC != None) {
+ if (scalePtr->textGC != NULL) {
Tk_FreeGC(scalePtr->display, scalePtr->textGC);
}
scalePtr->textGC = gc;
- if (scalePtr->copyGC == None) {
+ if (scalePtr->copyGC == NULL) {
gcValues.graphics_exposures = False;
scalePtr->copyGC = Tk_GetGC(scalePtr->tkwin, GCGraphicsExposures,
&gcValues);
@@ -1119,10 +1119,14 @@ TkEventuallyRedrawScale(
/*
*--------------------------------------------------------------
*
- * TkRoundToResolution --
+ * TkRoundValueToResolution, TkRoundIntervalToResolution --
*
* Round a given floating-point value to the nearest multiple of the
* scale's resolution.
+ * TkRoundValueToResolution rounds an absolute value based on the from
+ * value as a reference.
+ * TkRoundIntervalToResolution rounds a relative value without
+ * reference, i.e. it rounds an interval.
*
* Results:
* The return value is the rounded result.
@@ -1134,7 +1138,16 @@ TkEventuallyRedrawScale(
*/
double
-TkRoundToResolution(
+TkRoundValueToResolution(
+ TkScale *scalePtr, /* Information about scale widget. */
+ double value) /* Value to round. */
+{
+ return TkRoundIntervalToResolution(scalePtr, value - scalePtr->fromValue)
+ + scalePtr->fromValue;
+}
+
+double
+TkRoundIntervalToResolution(
TkScale *scalePtr, /* Information about scale widget. */
double value) /* Value to round. */
{
@@ -1147,13 +1160,13 @@ TkRoundToResolution(
rounded = scalePtr->resolution * tick;
rem = value - rounded;
if (rem < 0) {
- if (rem <= -scalePtr->resolution/2) {
- rounded = (tick - 1.0) * scalePtr->resolution;
- }
+ if (rem <= -scalePtr->resolution/2) {
+ rounded = (tick - 1.0) * scalePtr->resolution;
+ }
} else {
- if (rem >= scalePtr->resolution/2) {
- rounded = (tick + 1.0) * scalePtr->resolution;
- }
+ if (rem >= scalePtr->resolution/2) {
+ rounded = (tick + 1.0) * scalePtr->resolution;
+ }
}
return rounded;
}
@@ -1238,7 +1251,7 @@ ScaleVarProc(
resultStr = "can't assign non-numeric value to scale variable";
ScaleSetVariable(scalePtr);
} else {
- scalePtr->value = TkRoundToResolution(scalePtr, value);
+ scalePtr->value = TkRoundValueToResolution(scalePtr, value);
/*
* This code is a bit tricky because it sets the scale's value before
@@ -1282,7 +1295,7 @@ TkScaleSetValue(
int invokeCommand) /* Non-zero means invoked -command option to
* notify of new value, 0 means don't. */
{
- value = TkRoundToResolution(scalePtr, value);
+ value = TkRoundValueToResolution(scalePtr, value);
if ((value < scalePtr->fromValue)
^ (scalePtr->toValue < scalePtr->fromValue)) {
value = scalePtr->fromValue;
@@ -1402,7 +1415,7 @@ TkScalePixelToValue(
}
value = scalePtr->fromValue +
value * (scalePtr->toValue - scalePtr->fromValue);
- return TkRoundToResolution(scalePtr, value);
+ return TkRoundValueToResolution(scalePtr, value);
}
/*
diff --git a/generic/tkScale.h b/generic/tkScale.h
index d0be190..296620d 100644
--- a/generic/tkScale.h
+++ b/generic/tkScale.h
@@ -151,7 +151,7 @@ typedef struct TkScale {
*/
int fontHeight; /* Height of scale font. */
- Tk_Cursor cursor; /* Current cursor for window, or None. */
+ Tk_Cursor cursor; /* Current cursor for window, or NULL. */
Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the
* C code, but used by keyboard traversal
* scripts. May be NULL. */
@@ -219,7 +219,8 @@ typedef struct TkScale {
*/
MODULE_SCOPE void TkEventuallyRedrawScale(TkScale *scalePtr, int what);
-MODULE_SCOPE double TkRoundToResolution(TkScale *scalePtr, double value);
+MODULE_SCOPE double TkRoundValueToResolution(TkScale *scalePtr, double value);
+MODULE_SCOPE double TkRoundIntervalToResolution(TkScale *scalePtr, double value);
MODULE_SCOPE TkScale * TkpCreateScale(Tk_Window tkwin);
MODULE_SCOPE void TkpDestroyScale(TkScale *scalePtr);
MODULE_SCOPE void TkpDisplayScale(ClientData clientData);
diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c
index 02fb740..030767b 100644
--- a/generic/tkScrollbar.c
+++ b/generic/tkScrollbar.c
@@ -187,7 +187,7 @@ Tk_ScrollbarObjCmd(
#endif /* TK_NO_DEPRECATED */
scrollPtr->firstFraction = 0.0;
scrollPtr->lastFraction = 0.0;
- scrollPtr->cursor = None;
+ scrollPtr->cursor = NULL;
scrollPtr->takeFocus = NULL;
scrollPtr->flags = 0;
diff --git a/generic/tkScrollbar.h b/generic/tkScrollbar.h
index 99f16a4..f7c39c8 100644
--- a/generic/tkScrollbar.h
+++ b/generic/tkScrollbar.h
@@ -123,7 +123,7 @@ typedef struct TkScrollbar {
* Miscellaneous information:
*/
- Tk_Cursor cursor; /* Current cursor for window, or None. */
+ Tk_Cursor cursor; /* Current cursor for window, or NULL. */
char *takeFocus; /* Value of -takefocus option; not used in the
* C code, but used by keyboard traversal
* scripts. Malloc'ed, but may be NULL. */
diff --git a/generic/tkSquare.c b/generic/tkSquare.c
index 2a64dbb..e40a684 100644
--- a/generic/tkSquare.c
+++ b/generic/tkSquare.c
@@ -169,7 +169,7 @@ SquareObjCmd(
squarePtr->widgetCmd = Tcl_CreateObjCommand(interp,
Tk_PathName(squarePtr->tkwin), SquareWidgetObjCmd, squarePtr,
SquareDeletedProc);
- squarePtr->gc = None;
+ squarePtr->gc = NULL;
squarePtr->optionTable = optionTable;
if (Tk_InitOptions(interp, squarePtr, optionTable, tkwin)
@@ -335,7 +335,7 @@ SquareConfigure(
Tk_SetWindowBackground(squarePtr->tkwin,
Tk_3DBorderColor(bgBorder)->pixel);
Tcl_GetBooleanFromObj(NULL, squarePtr->doubleBufferPtr, &doubleBuffer);
- if ((squarePtr->gc == None) && (doubleBuffer)) {
+ if ((squarePtr->gc == NULL) && doubleBuffer) {
XGCValues gcValues;
gcValues.function = GXcopy;
gcValues.graphics_exposures = False;
@@ -400,7 +400,7 @@ SquareObjEventProc(
if (squarePtr->tkwin != NULL) {
Tk_FreeConfigOptions((char *) squarePtr, squarePtr->optionTable,
squarePtr->tkwin);
- if (squarePtr->gc != None) {
+ if (squarePtr->gc != NULL) {
Tk_FreeGC(squarePtr->display, squarePtr->gc);
}
squarePtr->tkwin = NULL;
diff --git a/generic/tkText.c b/generic/tkText.c
index 280eec8..fc63992 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -406,7 +406,6 @@ static Tcl_Obj * TextGetText(const TkText *textPtr,
static void GenerateModifiedEvent(TkText *textPtr);
static void GenerateUndoStackEvent(TkText *textPtr);
static void UpdateDirtyFlag(TkSharedText *sharedPtr);
-static void RunAfterSyncCmd(ClientData clientData);
static void TextPushUndoAction(TkText *textPtr,
Tcl_Obj *undoString, int insert,
const TkTextIndex *index1Ptr,
@@ -587,7 +586,7 @@ CreateWidget(
textPtr->state = TK_TEXT_STATE_NORMAL;
textPtr->relief = TK_RELIEF_FLAT;
- textPtr->cursor = None;
+ textPtr->cursor = NULL;
textPtr->charWidth = 1;
textPtr->charHeight = 10;
textPtr->wrapMode = TEXT_WRAPMODE_CHAR;
@@ -1544,7 +1543,7 @@ TextWidgetObjCmd(
textPtr->afterSyncCmd = cmd;
} else {
textPtr->afterSyncCmd = cmd;
- Tcl_DoWhenIdle(RunAfterSyncCmd, (ClientData) textPtr);
+ Tcl_DoWhenIdle(TkTextRunAfterSyncCmd, (ClientData) textPtr);
}
break;
} else if (objc != 2) {
@@ -1556,7 +1555,7 @@ TextWidgetObjCmd(
Tcl_DecrRefCount(textPtr->afterSyncCmd);
}
textPtr->afterSyncCmd = NULL;
- TkTextUpdateLineMetrics(textPtr, 1,
+ TkTextUpdateLineMetrics(textPtr, 0,
TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr), -1);
break;
}
@@ -2275,7 +2274,7 @@ ConfigureText(
textPtr->selTagPtr->affectsDisplay = 0;
textPtr->selTagPtr->affectsDisplayGeometry = 0;
if ((textPtr->selTagPtr->elideString != NULL)
- || (textPtr->selTagPtr->tkfont != None)
+ || (textPtr->selTagPtr->tkfont != NULL)
|| (textPtr->selTagPtr->justifyString != NULL)
|| (textPtr->selTagPtr->lMargin1String != NULL)
|| (textPtr->selTagPtr->lMargin2String != NULL)
@@ -5587,7 +5586,7 @@ UpdateDirtyFlag(
/*
*----------------------------------------------------------------------
*
- * RunAfterSyncCmd --
+ * TkTextRunAfterSyncCmd --
*
* This function is called by the event loop and executes the command
* scheduled by [.text sync -command $cmd].
@@ -5601,8 +5600,8 @@ UpdateDirtyFlag(
*----------------------------------------------------------------------
*/
-static void
-RunAfterSyncCmd(
+void
+TkTextRunAfterSyncCmd(
ClientData clientData) /* Information about text widget. */
{
register TkText *textPtr = clientData;
@@ -5623,7 +5622,7 @@ RunAfterSyncCmd(
code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd, TCL_EVAL_GLOBAL);
if (code == TCL_ERROR) {
Tcl_AddErrorInfo(textPtr->interp, "\n (text sync)");
- Tcl_BackgroundError(textPtr->interp);
+ Tcl_BackgroundException(textPtr->interp, TCL_ERROR);
}
Tcl_Release((ClientData) textPtr->interp);
Tcl_DecrRefCount(textPtr->afterSyncCmd);
diff --git a/generic/tkText.h b/generic/tkText.h
index 5e84fd5..8fb4134 100644
--- a/generic/tkText.h
+++ b/generic/tkText.h
@@ -677,7 +677,7 @@ typedef struct TkText {
/* Color for drawing traversal highlight area
* when highlight is off. */
XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
- Tk_Cursor cursor; /* Current cursor for window, or None. */
+ Tk_Cursor cursor; /* Current cursor for window, or NULL. */
XColor *fgColor; /* Default foreground color for text. */
Tk_Font tkfont; /* Default font for displaying text. */
int charWidth; /* Width of average character in default
@@ -1080,7 +1080,7 @@ MODULE_SCOPE int TkTextGetObjIndex(Tcl_Interp *interp, TkText *textPtr,
MODULE_SCOPE int TkTextSharedGetObjIndex(Tcl_Interp *interp,
TkSharedText *sharedTextPtr, Tcl_Obj *idxPtr,
TkTextIndex *indexPtr);
-MODULE_SCOPE const TkTextIndex *TkTextGetIndexFromObj(Tcl_Interp *interp,
+MODULE_SCOPE const TkTextIndex *TkTextGetIndexFromObj(Tcl_Interp *interp,
TkText *textPtr, Tcl_Obj *objPtr);
MODULE_SCOPE TkTextTabArray *TkTextGetTabs(Tcl_Interp *interp,
TkText *textPtr, Tcl_Obj *stringPtr);
@@ -1169,7 +1169,7 @@ MODULE_SCOPE int TkTextYviewCmd(TkText *textPtr, Tcl_Interp *interp,
int objc, Tcl_Obj *const objv[]);
MODULE_SCOPE void TkTextWinFreeClient(Tcl_HashEntry *hPtr,
TkTextEmbWindowClient *client);
-
+MODULE_SCOPE void TkTextRunAfterSyncCmd(ClientData clientData);
#endif /* _TKTEXT */
/*
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 0ad9ead..66ff744 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -491,13 +491,15 @@ static TkTextDispChunk *baseCharChunkPtr = NULL;
* different character might be under the mouse
* cursor now). Need to recompute the current
* character before the next redisplay.
+ * OUT_OF_SYNC 1 means that the last <<WidgetViewSync>> event had
+ * value 0, indicating that the widget is out of sync.
*/
#define DINFO_OUT_OF_DATE 1
#define REDRAW_PENDING 2
#define REDRAW_BORDERS 4
#define REPICK_NEEDED 8
-
+#define OUT_OF_SYNC 16
/*
* Action values for FreeDLines:
*
@@ -658,7 +660,7 @@ TkTextCreateDInfo(
dInfoPtr = ckalloc(sizeof(TextDInfo));
Tcl_InitHashTable(&dInfoPtr->styleTable, sizeof(StyleValues)/sizeof(int));
dInfoPtr->dLinePtr = NULL;
- dInfoPtr->copyGC = None;
+ dInfoPtr->copyGC = NULL;
gcValues.graphics_exposures = True;
dInfoPtr->scrollGC = Tk_GetGC(textPtr->tkwin, GCGraphicsExposures,
&gcValues);
@@ -675,7 +677,7 @@ TkTextCreateDInfo(
dInfoPtr->scanTotalYScroll = 0;
dInfoPtr->scanMarkY = 0;
dInfoPtr->dLinesInvalidated = 0;
- dInfoPtr->flags = DINFO_OUT_OF_DATE;
+ dInfoPtr->flags = 0;
dInfoPtr->topPixelOffset = 0;
dInfoPtr->newTopPixelOffset = 0;
dInfoPtr->currentMetricUpdateLine = -1;
@@ -722,7 +724,7 @@ TkTextFreeDInfo(
FreeDLines(textPtr, dInfoPtr->dLinePtr, NULL, DLINE_UNLINK);
Tcl_DeleteHashTable(&dInfoPtr->styleTable);
- if (dInfoPtr->copyGC != None) {
+ if (dInfoPtr->copyGC != NULL) {
Tk_FreeGC(textPtr->display, dInfoPtr->copyGC);
}
Tk_FreeGC(textPtr->display, dInfoPtr->scrollGC);
@@ -854,7 +856,7 @@ GetStyle(
border = tagPtr->selBorder;
}
- if ((tagPtr->selFgColor != None) && (isSelected)) {
+ if ((tagPtr->selFgColor != NULL) && isSelected) {
fgColor = tagPtr->selFgColor;
}
@@ -881,11 +883,11 @@ GetStyle(
styleValues.bgStipple = tagPtr->bgStipple;
bgStipplePrio = tagPtr->priority;
}
- if ((fgColor != None) && (tagPtr->priority > fgPrio)) {
+ if ((fgColor != NULL) && (tagPtr->priority > fgPrio)) {
styleValues.fgColor = fgColor;
fgPrio = tagPtr->priority;
}
- if ((tagPtr->tkfont != None) && (tagPtr->priority > fontPrio)) {
+ if ((tagPtr->tkfont != NULL) && (tagPtr->priority > fontPrio)) {
styleValues.tkfont = tagPtr->tkfont;
fontPrio = tagPtr->priority;
}
@@ -923,9 +925,9 @@ GetStyle(
&& (tagPtr->priority > overstrikePrio)) {
styleValues.overstrike = tagPtr->overstrike;
overstrikePrio = tagPtr->priority;
- if (tagPtr->overstrikeColor != None) {
+ if (tagPtr->overstrikeColor != NULL) {
styleValues.overstrikeColor = tagPtr->overstrikeColor;
- } else if (fgColor != None) {
+ } else if (fgColor != NULL) {
styleValues.overstrikeColor = fgColor;
}
}
@@ -968,9 +970,9 @@ GetStyle(
&& (tagPtr->priority > underlinePrio)) {
styleValues.underline = tagPtr->underline;
underlinePrio = tagPtr->priority;
- if (tagPtr->underlineColor != None) {
+ if (tagPtr->underlineColor != NULL) {
styleValues.underlineColor = tagPtr->underlineColor;
- } else if (fgColor != None) {
+ } else if (fgColor != NULL) {
styleValues.underlineColor = fgColor;
}
}
@@ -1017,7 +1019,7 @@ GetStyle(
}
stylePtr->bgGC = Tk_GetGC(textPtr->tkwin, mask, &gcValues);
} else {
- stylePtr->bgGC = None;
+ stylePtr->bgGC = NULL;
}
mask = GCFont;
gcValues.font = Tk_FontId(styleValues.tkfont);
@@ -1067,16 +1069,16 @@ FreeStyle(
/* Information about style to free. */
{
if (stylePtr->refCount-- <= 1) {
- if (stylePtr->bgGC != None) {
+ if (stylePtr->bgGC != NULL) {
Tk_FreeGC(textPtr->display, stylePtr->bgGC);
}
- if (stylePtr->fgGC != None) {
+ if (stylePtr->fgGC != NULL) {
Tk_FreeGC(textPtr->display, stylePtr->fgGC);
}
- if (stylePtr->ulGC != None) {
+ if (stylePtr->ulGC != NULL) {
Tk_FreeGC(textPtr->display, stylePtr->ulGC);
}
- if (stylePtr->ovGC != None) {
+ if (stylePtr->ovGC != NULL) {
Tk_FreeGC(textPtr->display, stylePtr->ovGC);
}
Tcl_DeleteHashEntry(stylePtr->hPtr);
@@ -2681,7 +2683,7 @@ DisplayLineBackground(
if ((chunkPtr->nextPtr == NULL) && (rightX < maxX)) {
rightX = maxX;
}
- if (chunkPtr->stylePtr->bgGC != None) {
+ if (chunkPtr->stylePtr->bgGC != NULL) {
/*
* Not visible - bail out now.
*/
@@ -3063,16 +3065,19 @@ AsyncUpdateLineMetrics(
* We have looped over all lines, so we're done. We must release our
* refCount on the widget (the timer token was already set to NULL
* above). If there is a registered aftersync command, run that first.
+ * Cancel any pending idle task which would try to run the command
+ * after the afterSyncCmd pointer had been set to NULL.
*/
if (textPtr->afterSyncCmd) {
int code;
+ Tcl_CancelIdleCall(TkTextRunAfterSyncCmd, textPtr);
Tcl_Preserve((ClientData) textPtr->interp);
code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd,
TCL_EVAL_GLOBAL);
if (code == TCL_ERROR) {
Tcl_AddErrorInfo(textPtr->interp, "\n (text sync)");
- Tcl_BackgroundError(textPtr->interp);
+ Tcl_BackgroundException(textPtr->interp, TCL_ERROR);
}
Tcl_Release((ClientData) textPtr->interp);
Tcl_DecrRefCount(textPtr->afterSyncCmd);
@@ -3084,7 +3089,6 @@ AsyncUpdateLineMetrics(
* with its internal data (actually it will be after the next trip
* through the event loop, because the widget redraws at idle-time).
*/
-
GenerateWidgetViewSyncEvent(textPtr, 1);
if (textPtr->refCount-- <= 1) {
@@ -3108,8 +3112,14 @@ AsyncUpdateLineMetrics(
* GenerateWidgetViewSyncEvent --
*
* Send the <<WidgetViewSync>> event related to the text widget
- * line metrics asynchronous update.
- * This is equivalent to:
+ * line metrics asynchronous update. These events should only
+ * be sent when the sync status has changed. So this function
+ * compares the requested state with the state saved in the
+ * TkText structure, and only generates the event if they are
+ * different. This means that it is safe to call this function
+ * at any time when the state is known.
+ *
+ * If an event is sent, the effect is equivalent to:
* event generate $textWidget <<WidgetViewSync>> -data $s
* where $s is the sync status: true (when the widget view is in
* sync with its internal data) or false (when it is not).
@@ -3125,9 +3135,12 @@ AsyncUpdateLineMetrics(
static void
GenerateWidgetViewSyncEvent(
- TkText *textPtr, /* Information about text widget. */
- Bool InSync) /* true if in sync, false otherwise */
+ TkText *textPtr, /* Information about text widget. */
+ Bool InSync) /* true if becoming in sync, false otherwise */
{
+ Bool NewSyncState = (InSync != 0); /* ensure 0 or 1 value */
+ Bool OldSyncState = !(textPtr->dInfoPtr->flags & OUT_OF_SYNC);
+
/*
* OSX 10.14 needs to be told to display the window when the Text Widget
* is in sync. (That is, to run DisplayText inside of the drawRect
@@ -3140,8 +3153,15 @@ GenerateWidgetViewSyncEvent(
FORCE_DISPLAY(textPtr->tkwin);
}
- TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync",
- Tcl_NewBooleanObj(InSync));
+ if (NewSyncState != OldSyncState) {
+ if (NewSyncState) {
+ textPtr->dInfoPtr->flags &= ~OUT_OF_SYNC;
+ } else {
+ textPtr->dInfoPtr->flags |= OUT_OF_SYNC;
+ }
+ TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync",
+ Tcl_NewBooleanObj(NewSyncState));
+ }
}
/*
@@ -3184,6 +3204,9 @@ TkTextUpdateLineMetrics(
TkTextLine *linePtr = NULL;
int count = 0;
int totalLines = TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr);
+ int fullUpdateRequested = (lineNum == 0 &&
+ endLine == totalLines &&
+ doThisMuch == -1);
if (totalLines == 0) {
/*
@@ -3194,6 +3217,7 @@ TkTextUpdateLineMetrics(
}
while (1) {
+
/*
* Get a suitable line.
*/
@@ -3220,6 +3244,8 @@ TkTextUpdateLineMetrics(
*/
if (textPtr->dInfoPtr->metricEpoch == TCL_AUTO_LENGTH && lineNum == endLine) {
+
+
/*
* We have looped over all lines, so we're done.
*/
@@ -3243,10 +3269,12 @@ TkTextUpdateLineMetrics(
if (TkBTreeLinePixelEpoch(textPtr, linePtr)
== textPtr->dInfoPtr->lineMetricUpdateEpoch) {
+
/*
* This line is already up to date. That means there's nothing
* to do here.
*/
+
} else if (doThisMuch == -1) {
count += 8 * TkTextUpdateOneLine(textPtr, linePtr, 0,NULL,0);
} else {
@@ -3268,6 +3296,7 @@ TkTextUpdateLineMetrics(
indexPtr = &textPtr->dInfoPtr->metricIndex;
pixelHeight = textPtr->dInfoPtr->metricPixelHeight;
} else {
+
/*
* We must reset the partial line height calculation data
* here, so we don't use it when it is out of date.
@@ -3291,6 +3320,7 @@ TkTextUpdateLineMetrics(
pixelHeight, indexPtr, 1);
if (indexPtr->linePtr == linePtr) {
+
/*
* We didn't complete the logical line, because it
* produced very many display lines, which must be because
@@ -3299,6 +3329,7 @@ TkTextUpdateLineMetrics(
*/
if (pixelHeight == 0) {
+
/*
* These have already been stored, unless we just
* started the new line.
@@ -3320,6 +3351,7 @@ TkTextUpdateLineMetrics(
textPtr->dInfoPtr->metricEpoch = -1;
}
} else {
+
/*
* We must never recalculate the height of the last artificial
* line. It must stay at zero, and if we recalculate it, it will
@@ -3344,13 +3376,17 @@ TkTextUpdateLineMetrics(
}
}
if (doThisMuch == -1) {
+
/*
- * If we were requested to provide a full update, then also update the
- * scrollbar.
+ * If we were requested to update the entire range, then also update
+ * the scrollbar.
*/
GetYView(textPtr->interp, textPtr, 1);
}
+ if (fullUpdateRequested) {
+ GenerateWidgetViewSyncEvent(textPtr, 1);
+ }
return lineNum;
}
@@ -3519,8 +3555,12 @@ TextInvalidateLineMetrics(
textPtr->refCount++;
dInfoPtr->lineUpdateTimer = Tcl_CreateTimerHandler(1,
AsyncUpdateLineMetrics, textPtr);
- GenerateWidgetViewSyncEvent(textPtr, 0);
}
+
+ /*
+ * The widget is out of sync: send a <<WidgetViewSync>> event.
+ */
+ GenerateWidgetViewSyncEvent(textPtr, 0);
}
/*
@@ -4537,7 +4577,7 @@ DisplayText(
dlPtr->spaceAbove,
dlPtr->height-dlPtr->spaceAbove-dlPtr->spaceBelow,
dlPtr->baseline - dlPtr->spaceAbove, NULL,
- (Drawable) None, dlPtr->y + dlPtr->spaceAbove);
+ None, dlPtr->y + dlPtr->spaceAbove);
}
}
}
@@ -5173,7 +5213,7 @@ TkTextRelayoutWindow(
gcValues.graphics_exposures = False;
newGC = Tk_GetGC(textPtr->tkwin, GCGraphicsExposures, &gcValues);
- if (dInfoPtr->copyGC != None) {
+ if (dInfoPtr->copyGC != NULL) {
Tk_FreeGC(textPtr->display, dInfoPtr->copyGC);
}
dInfoPtr->copyGC = newGC;
@@ -5262,9 +5302,7 @@ TkTextRelayoutWindow(
inSync = 0;
}
- if (!inSync) {
- GenerateWidgetViewSyncEvent(textPtr, 0);
- }
+ GenerateWidgetViewSyncEvent(textPtr, inSync);
}
}
@@ -6289,11 +6327,7 @@ TkTextPendingsync(
{
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
- return (
- (!(dInfoPtr->flags & REDRAW_PENDING) &&
- (dInfoPtr->metricEpoch == TCL_AUTO_LENGTH) &&
- (dInfoPtr->lastMetricUpdateLine == dInfoPtr->currentMetricUpdateLine)) ?
- 0 : 1);
+ return ((dInfoPtr->flags & OUT_OF_SYNC) != 0);
}
/*
@@ -7987,7 +8021,7 @@ CharDisplayProc(
*/
if (!sValuePtr->elide && (numBytes > offsetBytes)
- && (stylePtr->fgGC != None)) {
+ && (stylePtr->fgGC != NULL)) {
#if TK_DRAW_IN_CONTEXT
int start = ciPtr->baseOffset + offsetBytes;
int len = ciPtr->numBytes - offsetBytes;
diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c
index 0a749c4..e20bf58 100644
--- a/generic/tkTextTag.c
+++ b/generic/tkTextTag.c
@@ -516,7 +516,7 @@ TkTextTagCmd(
tagPtr->affectsDisplay = 0;
tagPtr->affectsDisplayGeometry = 0;
if ((tagPtr->elideString != NULL)
- || (tagPtr->tkfont != None)
+ || (tagPtr->tkfont != NULL)
|| (tagPtr->justifyString != NULL)
|| (tagPtr->lMargin1String != NULL)
|| (tagPtr->lMargin2String != NULL)
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index 23c0891..3d91927 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.c
@@ -2089,7 +2089,7 @@ void
Tk_UndefineCursor(
Tk_Window tkwin) /* Window to manipulate. */
{
- Tk_DefineCursor(tkwin, None);
+ Tk_DefineCursor(tkwin, NULL);
}
void
diff --git a/generic/ttk/ttkClassicTheme.c b/generic/ttk/ttkClassicTheme.c
index 117d928..48e856e 100644
--- a/generic/ttk/ttkClassicTheme.c
+++ b/generic/ttk/ttkClassicTheme.c
@@ -6,8 +6,6 @@
*/
#include "tkInt.h"
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
#include "ttkTheme.h"
#define DEFAULT_BORDERWIDTH "2"
diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c
index 6d0b29b..e4bfeca 100644
--- a/generic/ttk/ttkDefaultTheme.c
+++ b/generic/ttk/ttkDefaultTheme.c
@@ -5,8 +5,6 @@
*/
#include "tkInt.h"
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
#include "ttkTheme.h"
#if defined(_WIN32)
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c
index 32491dd..49b6553 100644
--- a/generic/ttk/ttkEntry.c
+++ b/generic/ttk/ttkEntry.c
@@ -9,8 +9,6 @@
*/
#include "tkInt.h"
-#include <X11/Xatom.h>
-
#include "ttkTheme.h"
#include "ttkWidget.h"
@@ -357,7 +355,7 @@ EntryFetchSelection(
ClientData clientData, int offset, char *buffer, int maxBytes)
{
Entry *entryPtr = clientData;
- size_t byteCount;
+ int byteCount;
const char *string;
const char *selStart, *selEnd;
@@ -371,7 +369,7 @@ EntryFetchSelection(
selEnd = Tcl_UtfAtIndex(selStart,
entryPtr->entry.selectLast - entryPtr->entry.selectFirst);
byteCount = selEnd - selStart - offset;
- if (byteCount > (size_t)maxBytes) {
+ if (byteCount > maxBytes) {
/* @@@POSSIBLE BUG: Can transfer partial UTF-8 sequences. Is this OK? */
byteCount = maxBytes;
}
@@ -1179,7 +1177,7 @@ static GC EntryGetGC(Entry *entryPtr, Tcl_Obj *colorObj, TkRegion clip)
mask |= GCForeground;
}
gc = Tk_GetGC(entryPtr->core.tkwin, mask, &gcValues);
- if (clip != None) {
+ if (clip != NULL) {
TkSetRegion(Tk_Display(entryPtr->core.tkwin), gc, clip);
}
return gc;
@@ -1290,7 +1288,7 @@ static void EntryDisplay(void *clientData, Drawable d)
cursorX = field.x + field.width - cursorWidth;
}
- gc = EntryGetGC(entryPtr, es.insertColorObj, None);
+ gc = EntryGetGC(entryPtr, es.insertColorObj, NULL);
XFillRectangle(Tk_Display(tkwin), d, gc,
cursorX, cursorY, cursorWidth, cursorHeight);
Tk_FreeGC(Tk_Display(tkwin), gc);
@@ -1336,7 +1334,7 @@ static void EntryDisplay(void *clientData, Drawable d)
* it from the Xft guts (if they're being used).
*/
#ifdef HAVE_XFT
- TkUnixSetXftClipRegion(None);
+ TkUnixSetXftClipRegion(NULL);
#endif
TkDestroyRegion(clipRegion);
}
diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c
index 91be033..d7a1f93 100644
--- a/generic/ttk/ttkLabel.c
+++ b/generic/ttk/ttkLabel.c
@@ -182,7 +182,7 @@ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b)
if (clipRegion != NULL) {
#ifdef HAVE_XFT
- TkUnixSetXftClipRegion(None);
+ TkUnixSetXftClipRegion(NULL);
#endif
XSetClipMask(Tk_Display(tkwin), gc1, None);
XSetClipMask(Tk_Display(tkwin), gc2, None);
diff --git a/generic/ttk/ttkState.c b/generic/ttk/ttkState.c
index 7ac6740..9e5cf4b 100644
--- a/generic/ttk/ttkState.c
+++ b/generic/ttk/ttkState.c
@@ -129,7 +129,7 @@ static void StateSpecUpdateString(Tcl_Obj *objPtr)
unsigned int mask = onbits | offbits;
Tcl_DString result;
int i;
- size_t len;
+ int len;
Tcl_DStringInit(&result);
@@ -145,14 +145,14 @@ static void StateSpecUpdateString(Tcl_Obj *objPtr)
len = Tcl_DStringLength(&result);
if (len) {
/* 'len' includes extra trailing ' ' */
- objPtr->bytes = Tcl_Alloc(len);
+ objPtr->bytes = ckalloc(len);
objPtr->length = len-1;
strncpy(objPtr->bytes, Tcl_DStringValue(&result), len-1);
objPtr->bytes[len-1] = '\0';
} else {
/* empty string */
objPtr->length = 0;
- objPtr->bytes = Tcl_Alloc(1);
+ objPtr->bytes = ckalloc(1);
*objPtr->bytes = '\0';
}