summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2016-02-09 21:44:23 (GMT)
committerfvogel <fvogelnew1@free.fr>2016-02-09 21:44:23 (GMT)
commit7c5f4b62829c4efa7ee754d566c45a0be0ace440 (patch)
treebd4912b7ebe50ba16c8f957cceb5b9330bfa945e /generic
parent797f245ca2d4aafd6a0f7ad853cccd32a7942171 (diff)
downloadtk-7c5f4b62829c4efa7ee754d566c45a0be0ace440.zip
tk-7c5f4b62829c4efa7ee754d566c45a0be0ace440.tar.gz
tk-7c5f4b62829c4efa7ee754d566c45a0be0ace440.tar.bz2
-overstrikefg tag configuration option: implementation
Diffstat (limited to 'generic')
-rw-r--r--generic/tkText.c1
-rw-r--r--generic/tkText.h2
-rw-r--r--generic/tkTextDisp.c20
-rw-r--r--generic/tkTextTag.c8
4 files changed, 27 insertions, 4 deletions
diff --git a/generic/tkText.c b/generic/tkText.c
index 7010601..19dce65 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -2294,6 +2294,7 @@ ConfigureText(
|| (textPtr->selTagPtr->fgStipple != None)
|| (textPtr->selTagPtr->selFgStipple != None)
|| (textPtr->selTagPtr->overstrikeString != NULL)
+ || (textPtr->selTagPtr->overstrikeColor != NULL)
|| (textPtr->selTagPtr->underlineString != NULL)
|| (textPtr->selTagPtr->underlineColor != NULL)) {
textPtr->selTagPtr->affectsDisplay = 1;
diff --git a/generic/tkText.h b/generic/tkText.h
index 815841c..242785a 100644
--- a/generic/tkText.h
+++ b/generic/tkText.h
@@ -358,6 +358,8 @@ typedef struct TkTextTag {
int overstrike; /* Non-zero means draw horizontal line through
* middle of text. Only valid if
* overstrikeString is non-NULL. */
+ XColor *overstrikeColor; /* Color for the overstrike. NULL means same
+ * color as foreground. */
char *rMarginString; /* -rmargin option string (malloc-ed). NULL
* means option not specified. */
int rMargin; /* Right margin for text, in pixels. Only
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index f246818..b74c6db 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -140,6 +140,8 @@ typedef struct StyleValues {
* baseline of line. */
int overstrike; /* Non-zero means draw overstrike through
* text. */
+ XColor *overstrikeColor; /* Foreground color for overstrike through
+ * text. */
int rMargin; /* Right margin, in pixels. */
int spacing1; /* Spacing above first dline in text line. */
int spacing2; /* Spacing between lines of dline. */
@@ -168,8 +170,9 @@ typedef struct TextStyle {
* referenced in Chunks. */
GC bgGC; /* Graphics context for background. None means
* use widget background. */
- GC ulGC; /* Graphics context for underline. */
GC fgGC; /* Graphics context for foreground. */
+ GC ulGC; /* Graphics context for underline. */
+ GC ovGC; /* Graphics context for overstrike. */
StyleValues *sValuePtr; /* Raw information from which GCs were
* derived. */
Tcl_HashEntry *hPtr; /* Pointer to entry in styleTable. Used to
@@ -782,6 +785,7 @@ GetStyle(
styleValues.relief = TK_RELIEF_FLAT;
styleValues.fgColor = textPtr->fgColor;
styleValues.underlineColor = textPtr->fgColor;
+ styleValues.overstrikeColor = textPtr->fgColor;
styleValues.tkfont = textPtr->tkfont;
styleValues.justify = TK_JUSTIFY_LEFT;
styleValues.spacing1 = textPtr->spacing1;
@@ -906,6 +910,11 @@ GetStyle(
&& (tagPtr->priority > overstrikePrio)) {
styleValues.overstrike = tagPtr->overstrike;
overstrikePrio = tagPtr->priority;
+ if (tagPtr->overstrikeColor != None) {
+ styleValues.overstrikeColor = tagPtr->overstrikeColor;
+ } else if (fgColor != None) {
+ styleValues.overstrikeColor = fgColor;
+ }
}
if ((tagPtr->rMarginString != NULL)
&& (tagPtr->priority > rMarginPrio)) {
@@ -1005,6 +1014,8 @@ GetStyle(
mask = GCForeground;
gcValues.foreground = styleValues.underlineColor->pixel;
stylePtr->ulGC = Tk_GetGC(textPtr->tkwin, mask, &gcValues);
+ gcValues.foreground = styleValues.overstrikeColor->pixel;
+ stylePtr->ovGC = Tk_GetGC(textPtr->tkwin, mask, &gcValues);
stylePtr->sValuePtr = (StyleValues *)
Tcl_GetHashKey(&textPtr->dInfoPtr->styleTable, hPtr);
stylePtr->hPtr = hPtr;
@@ -1048,6 +1059,9 @@ FreeStyle(
if (stylePtr->ulGC != None) {
Tk_FreeGC(textPtr->display, stylePtr->ulGC);
}
+ if (stylePtr->ovGC != None) {
+ Tk_FreeGC(textPtr->display, stylePtr->ovGC);
+ }
Tcl_DeleteHashEntry(stylePtr->hPtr);
ckfree(stylePtr);
}
@@ -7901,7 +7915,7 @@ CharDisplayProc(
Tk_FontMetrics fm;
Tk_GetFontMetrics(sValuePtr->tkfont, &fm);
- TkUnderlineCharsInContext(display, dst, stylePtr->fgGC,
+ TkUnderlineCharsInContext(display, dst, stylePtr->ovGC,
sValuePtr->tkfont, string, numBytes,
ciPtr->baseChunkPtr->x + xDisplacement,
y + baseline - sValuePtr->offset
@@ -7928,7 +7942,7 @@ CharDisplayProc(
Tk_FontMetrics fm;
Tk_GetFontMetrics(sValuePtr->tkfont, &fm);
- Tk_UnderlineChars(display, dst, stylePtr->fgGC, sValuePtr->tkfont,
+ Tk_UnderlineChars(display, dst, stylePtr->ovGC, sValuePtr->tkfont,
string, offsetX,
y + baseline - sValuePtr->offset
- fm.descent - (fm.ascent * 3) / 10,
diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c
index ed0ef98..e268352 100644
--- a/generic/tkTextTag.c
+++ b/generic/tkTextTag.c
@@ -66,6 +66,9 @@ static const Tk_OptionSpec tagOptionSpecs[] = {
{TK_OPTION_STRING, "-overstrike", NULL, NULL,
NULL, -1, Tk_Offset(TkTextTag, overstrikeString),
TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_COLOR, "-overstrikefg", NULL, NULL,
+ NULL, -1, Tk_Offset(TkTextTag, overstrikeColor),
+ TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-relief", NULL, NULL,
NULL, -1, Tk_Offset(TkTextTag, reliefString), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-rmargin", NULL, NULL,
@@ -93,7 +96,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = {
NULL, -1, Tk_Offset(TkTextTag, underlineString),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-underlinefg", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, underlineColor), TK_OPTION_NULL_OK, 0, 0},
+ NULL, -1, Tk_Offset(TkTextTag, underlineColor),
+ TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-wrap", NULL, NULL,
NULL, -1, Tk_Offset(TkTextTag, wrapMode),
TK_OPTION_NULL_OK, wrapStrings, 0},
@@ -536,6 +540,7 @@ TkTextTagCmd(
|| (tagPtr->fgStipple != None)
|| (tagPtr->selFgStipple != None)
|| (tagPtr->overstrikeString != NULL)
+ || (tagPtr->overstrikeColor != NULL)
|| (tagPtr->underlineString != NULL)
|| (tagPtr->underlineColor != NULL)) {
tagPtr->affectsDisplay = 1;
@@ -1038,6 +1043,7 @@ TkTextCreateTag(
tagPtr->offset = 0;
tagPtr->overstrikeString = NULL;
tagPtr->overstrike = 0;
+ tagPtr->overstrikeColor = NULL;
tagPtr->rMarginString = NULL;
tagPtr->rMargin = 0;
tagPtr->selBorder = NULL;