diff options
-rw-r--r-- | generic/tkText.c | 3 | ||||
-rw-r--r-- | generic/tkText.h | 2 | ||||
-rw-r--r-- | generic/tkTextDisp.c | 29 | ||||
-rw-r--r-- | generic/tkTextTag.c | 6 |
4 files changed, 34 insertions, 6 deletions
diff --git a/generic/tkText.c b/generic/tkText.c index 415e0bc..0de648a 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2297,7 +2297,8 @@ ConfigureText( || (textPtr->selTagPtr->overstrikeColor != NULL) || (textPtr->selTagPtr->underlineString != NULL) || (textPtr->selTagPtr->underlineColor != NULL) - || (textPtr->selTagPtr->lMarginColor != NULL)) { + || (textPtr->selTagPtr->lMarginColor != NULL) + || (textPtr->selTagPtr->rMarginColor != NULL)) { textPtr->selTagPtr->affectsDisplay = 1; } TkTextRedrawTag(NULL, textPtr, NULL, NULL, textPtr->selTagPtr, 1); diff --git a/generic/tkText.h b/generic/tkText.h index 22df370..8fab200 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -367,6 +367,8 @@ typedef struct TkTextTag { * means option not specified. */ int rMargin; /* Right margin for text, in pixels. Only * valid if rMarginString is non-NULL. */ + Tk_3DBorder rMarginColor; /* Used for drawing background in right margin. + * NULL means no value specified here. */ 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. diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index c0d6384..c0dc017 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -144,6 +144,7 @@ typedef struct StyleValues { XColor *overstrikeColor; /* Foreground color for overstrike through * text. */ int rMargin; /* Right margin, in pixels. */ + Tk_3DBorder rMarginColor; /* Color of right margin. */ int spacing1; /* Spacing above first dline in text line. */ int spacing2; /* Spacing between lines of dline. */ int spacing3; /* Spacing below last dline in text line. */ @@ -245,6 +246,10 @@ typedef struct DLine { * to the left margin of the display line. */ int lMarginWidth; /* Pixel width of the area corresponding to * the left margin. */ + Tk_3DBorder rMarginColor; /* Background color of the area corresponding + * to the right margin of the display line. */ + int rMarginWidth; /* Pixel width of the area corresponding to + * the right margin. */ int length; /* Total length of line, in pixels. */ TkTextDispChunk *chunkPtr; /* Pointer to first chunk in list of all of * those that are displayed on this line of @@ -770,7 +775,7 @@ GetStyle( int fgPrio, fontPrio, fgStipplePrio; int underlinePrio, elidePrio, justifyPrio, offsetPrio; int lMargin1Prio, lMargin2Prio, rMarginPrio; - int lMarginColorPrio; + int lMarginColorPrio, rMarginColorPrio; int spacing1Prio, spacing2Prio, spacing3Prio; int overstrikePrio, tabPrio, tabStylePrio, wrapPrio; @@ -785,7 +790,7 @@ GetStyle( fgPrio = fontPrio = fgStipplePrio = -1; underlinePrio = elidePrio = justifyPrio = offsetPrio = -1; lMargin1Prio = lMargin2Prio = rMarginPrio = -1; - lMarginColorPrio = -1; + lMarginColorPrio = rMarginColorPrio = -1; spacing1Prio = spacing2Prio = spacing3Prio = -1; overstrikePrio = tabPrio = tabStylePrio = wrapPrio = -1; memset(&styleValues, 0, sizeof(StyleValues)); @@ -933,6 +938,11 @@ GetStyle( styleValues.rMargin = tagPtr->rMargin; rMarginPrio = tagPtr->priority; } + if ((tagPtr->rMarginColor != NULL) + && (tagPtr->priority > rMarginColorPrio)) { + styleValues.rMarginColor = tagPtr->rMarginColor; + rMarginColorPrio = tagPtr->priority; + } if ((tagPtr->spacing1String != NULL) && (tagPtr->priority > spacing1Prio)) { styleValues.spacing1 = tagPtr->spacing1; @@ -1187,6 +1197,8 @@ LayoutDLine( dlPtr->logicalLinesMerged = 0; dlPtr->lMarginColor = NULL; dlPtr->lMarginWidth = 0; + dlPtr->rMarginColor = NULL; + dlPtr->rMarginWidth = 0; /* * This is not necessarily totally correct, where we have merged logical @@ -1774,6 +1786,10 @@ LayoutDLine( dlPtr->height += dlPtr->spaceAbove + dlPtr->spaceBelow; dlPtr->baseline += dlPtr->spaceAbove; dlPtr->lMarginColor = sValuePtr->lMarginColor; + dlPtr->rMarginColor = sValuePtr->rMarginColor; + if (wrapMode != TEXT_WRAPMODE_NONE) { + dlPtr->rMarginWidth = rMargin; + } /* * Recompute line length: may have changed because of justification. @@ -2460,13 +2476,18 @@ DisplayDLine( Tk_Width(textPtr->tkwin), dlPtr->height, 0, TK_RELIEF_FLAT); /* - * Second, draw the background color of the left margin. + * Second, draw the background color of the left and right margins. */ if (dlPtr->lMarginColor != NULL) { int x = dlPtr->lMarginWidth + dInfoPtr->x - dInfoPtr->curXPixelOffset; Tk_Fill3DRectangle(textPtr->tkwin, pixmap, dlPtr->lMarginColor, 0, y, - (x>0?x:0), dlPtr->height, 0, TK_RELIEF_FLAT); + (x>0?x:0), dlPtr->height, 0, TK_RELIEF_FLAT); + } + if (dlPtr->rMarginColor != NULL) { + Tk_Fill3DRectangle(textPtr->tkwin, pixmap, dlPtr->rMarginColor, + dInfoPtr->maxX - dlPtr->rMarginWidth + dInfoPtr->curXPixelOffset, + y, dlPtr->rMarginWidth, dlPtr->height, 0, TK_RELIEF_FLAT); } /* diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index a3e55fc..49d6a50 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -75,6 +75,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = { NULL, -1, Tk_Offset(TkTextTag, reliefString), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-rmargin", NULL, NULL, NULL, -1, Tk_Offset(TkTextTag, rMarginString), TK_OPTION_NULL_OK, 0,0}, + {TK_OPTION_BORDER, "-rmargincolor", NULL, NULL, + NULL, -1, Tk_Offset(TkTextTag, rMarginColor), 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, @@ -545,7 +547,8 @@ TkTextTagCmd( || (tagPtr->overstrikeColor != NULL) || (tagPtr->underlineString != NULL) || (tagPtr->underlineColor != NULL) - || (tagPtr->lMarginColor != NULL)) { + || (tagPtr->lMarginColor != NULL) + || (tagPtr->rMarginColor != NULL)) { tagPtr->affectsDisplay = 1; } if (!newTag) { @@ -1050,6 +1053,7 @@ TkTextCreateTag( tagPtr->overstrikeColor = NULL; tagPtr->rMarginString = NULL; tagPtr->rMargin = 0; + tagPtr->rMarginColor = NULL; tagPtr->selBorder = NULL; tagPtr->selBgStipple = None; tagPtr->selFgColor = NULL; |