Subject: -selectbgstipple tag configuration option: implementation

From: fvogel <[email-masked]>
Date: Tue, 9 Feb 2016 21:32:10 +0000

---
 generic/tkText.c     |  1 +
 generic/tkText.h     |  2 ++
 generic/tkTextDisp.c | 10 ++++++++--
 generic/tkTextTag.c  |  4 ++++
 4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/generic/tkText.c b/generic/tkText.c
index 464d4d9..7a2a6d5 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -2288,6 +2288,7 @@ ConfigureText(
 	    || (textPtr->selTagPtr->selBorder != NULL)
 	    || (textPtr->selTagPtr->reliefString != NULL)
 	    || (textPtr->selTagPtr->bgStipple != None)
+	    || (textPtr->selTagPtr->selBgStipple != None)
 	    || (textPtr->selTagPtr->fgColor != NULL)
 	    || (textPtr->selTagPtr->selFgColor != NULL)
 	    || (textPtr->selTagPtr->fgStipple != None)
diff --git a/generic/tkText.h b/generic/tkText.h
index 3056ab8..c8a71b3 100644
--- a/generic/tkText.h
+++ b/generic/tkText.h
@@ -364,6 +364,8 @@ typedef struct TkTextTag {
 				 * valid if rMarginString is non-NULL. */
     Tk_3DBorder selBorder;	/* Used for drawing background for selected text.
 				 * NULL means no value specified here. */
+    Pixmap selBgStipple;	/* Stipple bitmap for background of selected text.
+				 * None means no value specified here. */
     XColor *selFgColor;		/* Foreground color for selected text. NULL means
 				 * no value specified here. */
     char *spacing1String;	/* -spacing1 option string (malloc-ed). NULL
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index e8f8d79..0ccd3c2 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -798,10 +798,12 @@ GetStyle(
 
     for (i = 0 ; i < numTags; i++) {
 	Tk_3DBorder border;
+        Pixmap bgStipple;
         XColor *fgColor;
 
 	tagPtr = tagPtrs[i];
 	border = tagPtr->border;
+        bgStipple = tagPtr->bgStipple;
         fgColor = tagPtr->fgColor;
 
 	/*
@@ -826,6 +828,10 @@ GetStyle(
             border = tagPtr->selBorder;
         }
 
+        if ((tagPtr->selBgStipple != None) && (isSelected)) {
+            bgStipple = tagPtr->selBgStipple;
+        }
+
         if ((tagPtr->selFgColor != None) && (isSelected)) {
             fgColor = tagPtr->selFgColor;
         }
@@ -848,9 +854,9 @@ GetStyle(
 	    styleValues.relief = tagPtr->relief;
 	    reliefPrio = tagPtr->priority;
 	}
-	if ((tagPtr->bgStipple != None)
+	if ((bgStipple != None)
 		&& (tagPtr->priority > bgStipplePrio)) {
-	    styleValues.bgStipple = tagPtr->bgStipple;
+	    styleValues.bgStipple = bgStipple;
 	    bgStipplePrio = tagPtr->priority;
 	}
 	if ((fgColor != None) && (tagPtr->priority > fgPrio)) {
diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c
index 97356ed..86a6e77 100644
--- a/generic/tkTextTag.c
+++ b/generic/tkTextTag.c
@@ -72,6 +72,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = {
 	NULL, -1, Tk_Offset(TkTextTag, rMarginString), TK_OPTION_NULL_OK, 0,0},
     {TK_OPTION_BORDER, "-selectbackground", NULL, NULL,
 	NULL, -1, Tk_Offset(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0},
+    {TK_OPTION_BITMAP, "-selectbgstipple", NULL, NULL,
+	NULL, -1, Tk_Offset(TkTextTag, selBgStipple), TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_COLOR, "-selectforeground", NULL, NULL,
 	NULL, -1, Tk_Offset(TkTextTag, selFgColor), TK_OPTION_NULL_OK, 0, 0},
     {TK_OPTION_STRING, "-spacing1", NULL, NULL,
@@ -524,6 +526,7 @@ TkTextTagCmd(
 		    || (tagPtr->selBorder != NULL)
 		    || (tagPtr->reliefString != NULL)
 		    || (tagPtr->bgStipple != None)
+		    || (tagPtr->selBgStipple != None)
 		    || (tagPtr->fgColor != NULL)
 		    || (tagPtr->selFgColor != NULL)
 		    || (tagPtr->fgStipple != None)
@@ -1032,6 +1035,7 @@ TkTextCreateTag(
     tagPtr->rMarginString = NULL;
     tagPtr->rMargin = 0;
     tagPtr->selBorder = NULL;
+    tagPtr->selBgStipple = None;
     tagPtr->selFgColor = NULL;
     tagPtr->spacing1String = NULL;
     tagPtr->spacing1 = 0;
-- 
cgit v0.12