summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tkEntry.c33
-rw-r--r--generic/tkFont.c27
-rw-r--r--generic/tkInt.h4
-rw-r--r--generic/ttk/ttkEntry.c39
4 files changed, 85 insertions, 18 deletions
diff --git a/generic/tkEntry.c b/generic/tkEntry.c
index 9c53769..27bcfe1 100644
--- a/generic/tkEntry.c
+++ b/generic/tkEntry.c
@@ -1727,18 +1727,14 @@ DisplayEntry(
}
}
- /*
- * Draw the text in two pieces: first the unselected portion, then the
- * selected portion on top of it.
- */
-
- Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC,
- entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
- entryPtr->leftIndex, entryPtr->numChars);
-
if (showSelection && (entryPtr->state != STATE_DISABLED)
&& (entryPtr->selTextGC != entryPtr->textGC)
&& (entryPtr->selectFirst < entryPtr->selectLast)) {
+
+ /*
+ * Draw the selected and unselected portions separately.
+ */
+
int selFirst;
if (entryPtr->selectFirst < entryPtr->leftIndex) {
@@ -1746,9 +1742,28 @@ DisplayEntry(
} else {
selFirst = entryPtr->selectFirst;
}
+ if (entryPtr->leftIndex < selFirst) {
+ Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC,
+ entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
+ entryPtr->leftIndex, selFirst);
+ }
Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->selTextGC,
entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
selFirst, entryPtr->selectLast);
+ if (entryPtr->selectLast < entryPtr->numChars) {
+ Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC,
+ entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
+ entryPtr->selectLast, entryPtr->numChars);
+ }
+ } else {
+
+ /*
+ * Draw the entire visible text
+ */
+
+ Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC,
+ entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
+ entryPtr->leftIndex, entryPtr->numChars);
}
if (entryPtr->type == TK_SPINBOX) {
diff --git a/generic/tkFont.c b/generic/tkFont.c
index 0ec79a6..3a06719 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.c
@@ -2304,6 +2304,10 @@ Tk_DrawTextLayout(
* draw from the given text item. A number < 0
* means to draw all characters. */
{
+#if 0
+ /* Use TkDrawAngledTextLayout() implementation */
+ TkDrawAngledTextLayout(display, drawable, gc, layout, x, y, 0.0, firstChar, lastChar);
+#else
TextLayout *layoutPtr = (TextLayout *) layout;
int i, numDisplayChars, drawX;
const char *firstByte, *lastByte;
@@ -2333,8 +2337,14 @@ Tk_DrawTextLayout(
numDisplayChars = lastChar;
}
lastByte = Tcl_UtfAtIndex(chunkPtr->start, numDisplayChars);
+#if TK_DRAW_IN_CONTEXT
+ TkpDrawCharsInContext(display, drawable, gc, layoutPtr->tkfont,
+ chunkPtr->start, chunkPtr->numBytes, firstChar,
+ numDisplayChars - firstChar, x+chunkPtr->x, y+chunkPtr->y);
+#else /* !TK_DRAW_IN_CONTEXT */
Tk_DrawChars(display, drawable, gc, layoutPtr->tkfont, firstByte,
lastByte - firstByte, x+chunkPtr->x+drawX, y+chunkPtr->y);
+#endif /* TK_DRAW_IN_CONTEXT */
}
firstChar -= chunkPtr->numChars;
lastChar -= chunkPtr->numChars;
@@ -2343,6 +2353,7 @@ Tk_DrawTextLayout(
}
chunkPtr++;
}
+#endif /* Use TkDrawAngledTextLayout() implementation */
}
void
@@ -2395,6 +2406,21 @@ TkDrawAngledTextLayout(
numDisplayChars = lastChar;
}
lastByte = Tcl_UtfAtIndex(chunkPtr->start, numDisplayChars);
+#if TK_DRAW_IN_CONTEXT
+ dx = cosA * (chunkPtr->x) + sinA * (chunkPtr->y);
+ dy = -sinA * (chunkPtr->x) + cosA * (chunkPtr->y);
+ if (angle == 0.0) {
+ TkpDrawCharsInContext(display, drawable, gc,
+ layoutPtr->tkfont, chunkPtr->start, chunkPtr->numBytes,
+ firstChar, numDisplayChars - firstChar,
+ (int)(x + dx), (int)(y + dy));
+ } else {
+ TkpDrawAngledCharsInContext(display, drawable, gc,
+ layoutPtr->tkfont, chunkPtr->start, chunkPtr->numBytes,
+ firstChar, numDisplayChars - firstChar,
+ x+dx, y+dy, angle);
+ }
+#else /* !TK_DRAW_IN_CONTEXT */
dx = cosA * (chunkPtr->x + drawX) + sinA * (chunkPtr->y);
dy = -sinA * (chunkPtr->x + drawX) + cosA * (chunkPtr->y);
if (angle == 0.0) {
@@ -2405,6 +2431,7 @@ TkDrawAngledTextLayout(
TkDrawAngledChars(display, drawable, gc, layoutPtr->tkfont,
firstByte, lastByte - firstByte, x+dx, y+dy, angle);
}
+#endif /* TK_DRAW_IN_CONTEXT */
}
firstChar -= chunkPtr->numChars;
lastChar -= chunkPtr->numChars;
diff --git a/generic/tkInt.h b/generic/tkInt.h
index 8f958ab..2f9efe8 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -1231,6 +1231,10 @@ MODULE_SCOPE void TkpDrawCharsInContext(Display * display,
Drawable drawable, GC gc, Tk_Font tkfont,
const char *source, int numBytes, int rangeStart,
int rangeLength, int x, int y);
+MODULE_SCOPE void TkpDrawAngledCharsInContext(Display * display,
+ Drawable drawable, GC gc, Tk_Font tkfont,
+ const char *source, int numBytes, int rangeStart,
+ int rangeLength, double x, double y, double angle);
MODULE_SCOPE int TkpMeasureCharsInContext(Tk_Font tkfont,
const char *source, int numBytes, int rangeStart,
int rangeLength, int maxLength, int flags,
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c
index 96f3cf2..05b4c3b 100644
--- a/generic/ttk/ttkEntry.c
+++ b/generic/ttk/ttkEntry.c
@@ -1274,16 +1274,27 @@ static void EntryDisplay(void *clientData, Drawable d)
/* Draw the text:
*/
gc = EntryGetGC(entryPtr, es.foregroundObj, clipRegion);
- Tk_DrawTextLayout(
- Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout,
- entryPtr->entry.layoutX, entryPtr->entry.layoutY,
- leftIndex, rightIndex);
- XSetClipMask(Tk_Display(tkwin), gc, None);
- Tk_FreeGC(Tk_Display(tkwin), gc);
-
- /* Overwrite the selected portion (if any) in the -selectforeground color:
- */
if (showSelection) {
+
+ /* Draw the selected and unselected portions separately.
+ */
+ if (leftIndex < selFirst) {
+ Tk_DrawTextLayout(
+ Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout,
+ entryPtr->entry.layoutX, entryPtr->entry.layoutY,
+ leftIndex, selFirst);
+ }
+ if (selLast < rightIndex) {
+ Tk_DrawTextLayout(
+ Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout,
+ entryPtr->entry.layoutX, entryPtr->entry.layoutY,
+ selLast, rightIndex);
+ }
+ XSetClipMask(Tk_Display(tkwin), gc, None);
+ Tk_FreeGC(Tk_Display(tkwin), gc);
+
+ /* Draw the selected portion in the -selectforeground color:
+ */
gc = EntryGetGC(entryPtr, es.selForegroundObj, clipRegion);
Tk_DrawTextLayout(
Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout,
@@ -1291,6 +1302,16 @@ static void EntryDisplay(void *clientData, Drawable d)
selFirst, selLast);
XSetClipMask(Tk_Display(tkwin), gc, None);
Tk_FreeGC(Tk_Display(tkwin), gc);
+ } else {
+
+ /* Draw the entire visible text
+ */
+ Tk_DrawTextLayout(
+ Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout,
+ entryPtr->entry.layoutX, entryPtr->entry.layoutY,
+ leftIndex, rightIndex);
+ XSetClipMask(Tk_Display(tkwin), gc, None);
+ Tk_FreeGC(Tk_Display(tkwin), gc);
}
/* Drop the region. Note that we have to manually remove the reference to