summaryrefslogtreecommitdiffstats
path: root/generic/tkTextDisp.c
diff options
context:
space:
mode:
authordas <das>2007-04-29 02:24:01 (GMT)
committerdas <das>2007-04-29 02:24:01 (GMT)
commit0ee713439182546f0e884ac2db7f83101456d56e (patch)
treeb6b29a677c5c6c642d97f66297edf93f269b37b6 /generic/tkTextDisp.c
parent7614214a0526527a62f6cc88b6560f003397c1a3 (diff)
downloadtk-0ee713439182546f0e884ac2db7f83101456d56e.zip
tk-0ee713439182546f0e884ac2db7f83101456d56e.tar.gz
tk-0ee713439182546f0e884ac2db7f83101456d56e.tar.bz2
* generic/tkCanvas.c: allow -selectforeground option to be None; add
* generic/tkCanvText.c: fallback to fgColor when selFgColor is None * generic/tkEntry.c: (new default on aqua to match native L&F). * generic/tkListbox.c: * generic/tkText.c: * generic/tkCanvas.c: add support for bypassing all of Tk's double * generic/tkEntry.c: buffered drawing into intermediate pixmaps * generic/tkFrame.c: (via TK_NO_DOUBLE_BUFFERING #define), it is * generic/tkListbox.c: unnecessary & wasteful on aqua where all * generic/tkPanedWindow.c: drawing is already double-buffered by the * generic/tkTextDisp.c: window server. (Use of this on other * unix/tkUnixScale.c: platforms would only require implementation of TkpClipDrawableToRect()).
Diffstat (limited to 'generic/tkTextDisp.c')
-rw-r--r--generic/tkTextDisp.c89
1 files changed, 62 insertions, 27 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index ab0a8cf..48897bd 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkTextDisp.c,v 1.14.2.4 2006/09/10 17:07:35 das Exp $
+ * RCS: @(#) $Id: tkTextDisp.c,v 1.14.2.5 2007/04/29 02:24:02 das Exp $
*/
#include "tkPort.h"
@@ -22,6 +22,12 @@
#include "tkWinInt.h"
#endif
+#ifdef TK_NO_DOUBLE_BUFFERING
+#ifdef MAC_OSX_TK
+#include "tkMacOSXInt.h"
+#endif
+#endif /* TK_NO_DOUBLE_BUFFERING */
+
/*
* The following structure describes how to display a range of characters.
* The information is generated by scanning all of the tags associated
@@ -1686,16 +1692,32 @@ DisplayDLine(textPtr, dlPtr, prevPtr, pixmap)
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
Display *display;
int height, x;
+#ifndef TK_NO_DOUBLE_BUFFERING
+ const int y = 0;
+#else
+ const int y = dlPtr->y;
+#endif /* TK_NO_DOUBLE_BUFFERING */
if (dlPtr->chunkPtr == NULL) return;
+ display = Tk_Display(textPtr->tkwin);
+
+ height = dlPtr->height;
+ if ((height + dlPtr->y) > dInfoPtr->maxY) {
+ height = dInfoPtr->maxY - dlPtr->y;
+ }
+
+#ifdef TK_NO_DOUBLE_BUFFERING
+ TkpClipDrawableToRect(display, pixmap, dInfoPtr->x, y,
+ dInfoPtr->maxX - dInfoPtr->x, height);
+#endif /* TK_NO_DOUBLE_BUFFERING */
+
/*
* First, clear the area of the line to the background color for the
* text widget.
*/
- display = Tk_Display(textPtr->tkwin);
- Tk_Fill3DRectangle(textPtr->tkwin, pixmap, textPtr->border, 0, 0,
+ Tk_Fill3DRectangle(textPtr->tkwin, pixmap, textPtr->border, 0, y,
Tk_Width(textPtr->tkwin), dlPtr->height, 0, TK_RELIEF_FLAT);
/*
@@ -1717,7 +1739,7 @@ DisplayDLine(textPtr, dlPtr, prevPtr, pixmap)
chunkPtr = chunkPtr->nextPtr) {
x = chunkPtr->x + dInfoPtr->x - dInfoPtr->curPixelOffset;
if (chunkPtr->displayProc == TkTextInsertDisplayProc) {
- (*chunkPtr->displayProc)(chunkPtr, x, dlPtr->spaceAbove,
+ (*chunkPtr->displayProc)(chunkPtr, x, y + dlPtr->spaceAbove,
dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow,
dlPtr->baseline - dlPtr->spaceAbove, display, pixmap,
dlPtr->y + dlPtr->spaceAbove);
@@ -1757,7 +1779,7 @@ DisplayDLine(textPtr, dlPtr, prevPtr, pixmap)
if (chunkPtr->displayProc != NULL)
(*chunkPtr->displayProc)(chunkPtr, -chunkPtr->width,
- dlPtr->spaceAbove,
+ y + dlPtr->spaceAbove,
dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow,
dlPtr->baseline - dlPtr->spaceAbove, display, pixmap,
dlPtr->y + dlPtr->spaceAbove);
@@ -1765,7 +1787,7 @@ DisplayDLine(textPtr, dlPtr, prevPtr, pixmap)
/* don't call if elide. This tax ok since not very many visible DLine's in
an area, but potentially many elide ones */
if (chunkPtr->displayProc != NULL)
- (*chunkPtr->displayProc)(chunkPtr, x, dlPtr->spaceAbove,
+ (*chunkPtr->displayProc)(chunkPtr, x, y + dlPtr->spaceAbove,
dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow,
dlPtr->baseline - dlPtr->spaceAbove, display, pixmap,
dlPtr->y + dlPtr->spaceAbove);
@@ -1775,6 +1797,7 @@ DisplayDLine(textPtr, dlPtr, prevPtr, pixmap)
}
}
+#ifndef TK_NO_DOUBLE_BUFFERING
/*
* Copy the pixmap onto the screen. If this is the last line on
* the screen then copy a piece of the line, so that it doesn't
@@ -1784,13 +1807,12 @@ DisplayDLine(textPtr, dlPtr, prevPtr, pixmap)
* to get as much of the cursor as possible.
*/
- height = dlPtr->height;
- if ((height + dlPtr->y) > dInfoPtr->maxY) {
- height = dInfoPtr->maxY - dlPtr->y;
- }
XCopyArea(display, pixmap, Tk_WindowId(textPtr->tkwin), dInfoPtr->copyGC,
- dInfoPtr->x, 0, (unsigned) (dInfoPtr->maxX - dInfoPtr->x),
+ dInfoPtr->x, y, (unsigned) (dInfoPtr->maxX - dInfoPtr->x),
(unsigned) height, dInfoPtr->x, dlPtr->y);
+#else
+ TkpClipDrawableToRect(display, pixmap, 0, 0, -1, -1);
+#endif /* TK_NO_DOUBLE_BUFFERING */
linesRedrawn++;
}
@@ -1852,7 +1874,11 @@ DisplayLineBackground(textPtr, dlPtr, prevPtr, pixmap)
int minX, maxX, xOffset;
StyleValues *sValuePtr;
Display *display;
-
+#ifndef TK_NO_DOUBLE_BUFFERING
+ const int y = 0;
+#else
+ const int y = dlPtr->y;
+#endif /* TK_NO_DOUBLE_BUFFERING */
/*
* Pass 1: scan through dlPtr from left to right. For each range of
@@ -1916,15 +1942,15 @@ DisplayLineBackground(textPtr, dlPtr, prevPtr, pixmap)
}
XFillRectangle(display, pixmap, chunkPtr->stylePtr->bgGC,
- leftX + xOffset, 0, (unsigned int) (rightX - leftX),
+ leftX + xOffset, y, (unsigned int) (rightX - leftX),
(unsigned int) dlPtr->height);
if (sValuePtr->relief != TK_RELIEF_FLAT) {
Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border,
- leftX + xOffset, 0, sValuePtr->borderWidth,
+ leftX + xOffset, y, sValuePtr->borderWidth,
dlPtr->height, 1, sValuePtr->relief);
Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border,
rightX - sValuePtr->borderWidth + xOffset,
- 0, sValuePtr->borderWidth, dlPtr->height, 0,
+ y, sValuePtr->borderWidth, dlPtr->height, 0,
sValuePtr->relief);
}
}
@@ -1984,7 +2010,7 @@ DisplayLineBackground(textPtr, dlPtr, prevPtr, pixmap)
chunkPtr->nextPtr->stylePtr)) {
if (!matchLeft && (sValuePtr->relief != TK_RELIEF_FLAT)) {
Tk_3DHorizontalBevel(textPtr->tkwin, pixmap,
- sValuePtr->border, leftX + xOffset, 0,
+ sValuePtr->border, leftX + xOffset, y,
rightX - leftX, sValuePtr->borderWidth, leftXIn,
1, 1, sValuePtr->relief);
}
@@ -2025,7 +2051,7 @@ DisplayLineBackground(textPtr, dlPtr, prevPtr, pixmap)
if (matchLeft && !matchRight) {
if (sValuePtr->relief != TK_RELIEF_FLAT) {
Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border,
- rightX2 - sValuePtr->borderWidth + xOffset, 0,
+ rightX2 - sValuePtr->borderWidth + xOffset, y,
sValuePtr->borderWidth, sValuePtr->borderWidth, 0,
sValuePtr->relief);
}
@@ -2034,11 +2060,11 @@ DisplayLineBackground(textPtr, dlPtr, prevPtr, pixmap)
} else if (!matchLeft && matchRight
&& (sValuePtr->relief != TK_RELIEF_FLAT)) {
Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border,
- rightX2 + xOffset, 0, sValuePtr->borderWidth,
+ rightX2 + xOffset, y, sValuePtr->borderWidth,
sValuePtr->borderWidth, 1, sValuePtr->relief);
Tk_3DHorizontalBevel(textPtr->tkwin, pixmap, sValuePtr->border,
- leftX + xOffset, 0, rightX2 + sValuePtr->borderWidth -leftX,
- sValuePtr->borderWidth, leftXIn, 0, 1,
+ leftX + xOffset, y, rightX2 + sValuePtr->borderWidth -
+ leftX, sValuePtr->borderWidth, leftXIn, 0, 1,
sValuePtr->relief);
}
@@ -2101,7 +2127,7 @@ DisplayLineBackground(textPtr, dlPtr, prevPtr, pixmap)
if (!matchLeft && (sValuePtr->relief != TK_RELIEF_FLAT)) {
Tk_3DHorizontalBevel(textPtr->tkwin, pixmap,
sValuePtr->border, leftX + xOffset,
- dlPtr->height - sValuePtr->borderWidth,
+ y + dlPtr->height - sValuePtr->borderWidth,
rightX - leftX, sValuePtr->borderWidth, leftXIn,
0, 0, sValuePtr->relief);
}
@@ -2128,7 +2154,7 @@ DisplayLineBackground(textPtr, dlPtr, prevPtr, pixmap)
if (sValuePtr->relief != TK_RELIEF_FLAT) {
Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border,
rightX2 - sValuePtr->borderWidth + xOffset,
- dlPtr->height - sValuePtr->borderWidth,
+ y + dlPtr->height - sValuePtr->borderWidth,
sValuePtr->borderWidth, sValuePtr->borderWidth, 0,
sValuePtr->relief);
}
@@ -2137,13 +2163,14 @@ DisplayLineBackground(textPtr, dlPtr, prevPtr, pixmap)
} else if (!matchLeft && matchRight
&& (sValuePtr->relief != TK_RELIEF_FLAT)) {
Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border,
- rightX2 + xOffset, dlPtr->height - sValuePtr->borderWidth,
+ rightX2 + xOffset, y + dlPtr->height -
sValuePtr->borderWidth, sValuePtr->borderWidth,
- 1, sValuePtr->relief);
+ sValuePtr->borderWidth, 1, sValuePtr->relief);
Tk_3DHorizontalBevel(textPtr->tkwin, pixmap, sValuePtr->border,
- leftX + xOffset, dlPtr->height - sValuePtr->borderWidth,
- rightX2 + sValuePtr->borderWidth - leftX,
- sValuePtr->borderWidth, leftXIn, 1, 0, sValuePtr->relief);
+ leftX + xOffset, y + dlPtr->height -
+ sValuePtr->borderWidth, rightX2 + sValuePtr->borderWidth -
+ leftX, sValuePtr->borderWidth, leftXIn, 1, 0,
+ sValuePtr->relief);
}
nextChunk2b:
@@ -2454,9 +2481,13 @@ DisplayText(clientData)
maxHeight = dInfoPtr->maxY;
}
if (maxHeight > 0) {
+#ifndef TK_NO_DOUBLE_BUFFERING
pixmap = Tk_GetPixmap(Tk_Display(textPtr->tkwin),
Tk_WindowId(textPtr->tkwin), Tk_Width(textPtr->tkwin),
maxHeight, Tk_Depth(textPtr->tkwin));
+#else
+ pixmap = Tk_WindowId(textPtr->tkwin);
+#endif /* TK_NO_DOUBLE_BUFFERING */
for (prevPtr = NULL, dlPtr = textPtr->dInfoPtr->dLinePtr;
(dlPtr != NULL) && (dlPtr->y < dInfoPtr->maxY);
prevPtr = dlPtr, dlPtr = dlPtr->nextPtr) {
@@ -2471,7 +2502,9 @@ DisplayText(clientData)
}
DisplayDLine(textPtr, dlPtr, prevPtr, pixmap);
if (dInfoPtr->dLinesInvalidated) {
+#ifndef TK_NO_DOUBLE_BUFFERING
Tk_FreePixmap(Tk_Display(textPtr->tkwin), pixmap);
+#endif /* TK_NO_DOUBLE_BUFFERING */
return;
}
dlPtr->oldY = dlPtr->y;
@@ -2479,7 +2512,9 @@ DisplayText(clientData)
}
/*prevPtr = dlPtr;*/
}
+#ifndef TK_NO_DOUBLE_BUFFERING
Tk_FreePixmap(Tk_Display(textPtr->tkwin), pixmap);
+#endif /* TK_NO_DOUBLE_BUFFERING */
}
/*