summaryrefslogtreecommitdiffstats
path: root/generic/ttk
diff options
context:
space:
mode:
Diffstat (limited to 'generic/ttk')
-rw-r--r--generic/ttk/ttkEntry.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c
index c4b1b6a..410c60c 100644
--- a/generic/ttk/ttkEntry.c
+++ b/generic/ttk/ttkEntry.c
@@ -10,7 +10,7 @@
#include <string.h>
#include <stdio.h>
-#include <tk.h>
+#include <tkInt.h>
#include <X11/Xatom.h>
#include "ttkTheme.h"
@@ -1123,7 +1123,7 @@ EntryDoLayout(void *recordPtr)
* rightIndex is set to one past the last fully-visible character.
*/
Tk_CharBbox(textLayout, leftIndex, &leftX, NULL, NULL, NULL);
- rightIndex = Tk_PointToChar(textLayout, leftX + textarea.width, 0);
+ rightIndex = Tk_PointToChar(textLayout, leftX + textarea.width, 0)+1;
entryPtr->entry.layoutX = textarea.x - leftX;
}
@@ -1135,13 +1135,14 @@ EntryDoLayout(void *recordPtr)
* Get a GC using the specified foreground color and the entry's font.
* Result must be freed with Tk_FreeGC().
*/
-static GC EntryGetGC(Entry *entryPtr, Tcl_Obj *colorObj)
+static GC EntryGetGC(Entry *entryPtr, Tcl_Obj *colorObj, TkRegion clip)
{
Tk_Window tkwin = entryPtr->core.tkwin;
Tk_Font font = Tk_GetFontFromObj(tkwin, entryPtr->entry.fontObj);
XColor *colorPtr;
unsigned long mask = 0ul;
XGCValues gcValues;
+ GC gc;
gcValues.line_width = 1; mask |= GCLineWidth;
gcValues.font = Tk_FontId(font); mask |= GCFont;
@@ -1149,7 +1150,9 @@ static GC EntryGetGC(Entry *entryPtr, Tcl_Obj *colorObj)
gcValues.foreground = colorPtr->pixel;
mask |= GCForeground;
}
- return Tk_GetGC(entryPtr->core.tkwin, mask, &gcValues);
+ gc = Tk_GetGC(entryPtr->core.tkwin, mask, &gcValues);
+ TkSetRegion(Tk_Display(entryPtr->core.tkwin), gc, clip);
+ return gc;
}
/* EntryDisplay --
@@ -1166,9 +1169,13 @@ static void EntryDisplay(void *clientData, Drawable d)
EntryStyleData es;
GC gc;
int showSelection, showCursor;
+ Ttk_Box textarea;
+ TkRegion clipRegion;
+ XRectangle rect;
EntryInitStyleData(entryPtr, &es);
+ textarea = Ttk_ClientRegion(corePtr->layout, "textarea");
showCursor =
(entryPtr->core.flags & CURSOR_ON) != 0
&& EntryEditable(entryPtr)
@@ -1214,6 +1221,16 @@ static void EntryDisplay(void *clientData, Drawable d)
}
}
+ /* Initialize the clip region:
+ */
+
+ rect.x = textarea.x;
+ rect.y = textarea.y;
+ rect.width = textarea.width;
+ rect.height = textarea.height;
+ clipRegion = TkCreateRegion();
+ TkUnionRectWithRegion(&rect, clipRegion, clipRegion);
+
/* Draw cursor:
*/
if (showCursor) {
@@ -1230,7 +1247,7 @@ static void EntryDisplay(void *clientData, Drawable d)
/* @@@ should: maybe: SetCaretPos even when blinked off */
Tk_SetCaretPos(tkwin, cursorX, cursorY, cursorHeight);
- gc = EntryGetGC(entryPtr, es.insertColorObj);
+ gc = EntryGetGC(entryPtr, es.insertColorObj, clipRegion);
XFillRectangle(Tk_Display(tkwin), d, gc,
cursorX-cursorWidth/2, cursorY, cursorWidth, cursorHeight);
Tk_FreeGC(Tk_Display(tkwin), gc);
@@ -1238,7 +1255,7 @@ static void EntryDisplay(void *clientData, Drawable d)
/* Draw the text:
*/
- gc = EntryGetGC(entryPtr, es.foregroundObj);
+ gc = EntryGetGC(entryPtr, es.foregroundObj, clipRegion);
Tk_DrawTextLayout(
Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout,
entryPtr->entry.layoutX, entryPtr->entry.layoutY,
@@ -1248,13 +1265,14 @@ static void EntryDisplay(void *clientData, Drawable d)
/* Overwrite the selected portion (if any) in the -selectforeground color:
*/
if (showSelection) {
- gc = EntryGetGC(entryPtr, es.selForegroundObj);
+ gc = EntryGetGC(entryPtr, es.selForegroundObj, clipRegion);
Tk_DrawTextLayout(
Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout,
entryPtr->entry.layoutX, entryPtr->entry.layoutY,
selFirst, selLast);
Tk_FreeGC(Tk_Display(tkwin), gc);
}
+ TkDestroyRegion(clipRegion);
}
/*------------------------------------------------------------------------