summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2016-02-10 22:51:45 (GMT)
committerfvogel <fvogelnew1@free.fr>2016-02-10 22:51:45 (GMT)
commit30a85a7ace1cf7ea9de7828dfb84fde2af23148b (patch)
treeaf743cc0a7772b00193196604d317ab57ab9c603 /generic
parent74d865bb3e520e131dc6655986fe79141120c2e9 (diff)
downloadtk-30a85a7ace1cf7ea9de7828dfb84fde2af23148b.zip
tk-30a85a7ace1cf7ea9de7828dfb84fde2af23148b.tar.gz
tk-30a85a7ace1cf7ea9de7828dfb84fde2af23148b.tar.bz2
-lmargincolor tag configuration option: implementation
Diffstat (limited to 'generic')
-rw-r--r--generic/tkText.c3
-rw-r--r--generic/tkText.h3
-rw-r--r--generic/tkTextDisp.c26
-rw-r--r--generic/tkTextTag.c6
4 files changed, 36 insertions, 2 deletions
diff --git a/generic/tkText.c b/generic/tkText.c
index 19dce65..415e0bc 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -2296,7 +2296,8 @@ ConfigureText(
|| (textPtr->selTagPtr->overstrikeString != NULL)
|| (textPtr->selTagPtr->overstrikeColor != NULL)
|| (textPtr->selTagPtr->underlineString != NULL)
- || (textPtr->selTagPtr->underlineColor != NULL)) {
+ || (textPtr->selTagPtr->underlineColor != NULL)
+ || (textPtr->selTagPtr->lMarginColor != NULL)) {
textPtr->selTagPtr->affectsDisplay = 1;
}
TkTextRedrawTag(NULL, textPtr, NULL, NULL, textPtr->selTagPtr, 1);
diff --git a/generic/tkText.h b/generic/tkText.h
index 242785a..22df370 100644
--- a/generic/tkText.h
+++ b/generic/tkText.h
@@ -347,6 +347,9 @@ typedef struct TkTextTag {
int lMargin2; /* Left margin for second and later display
* lines of each text line, in pixels. Only
* valid if lMargin2String is non-NULL. */
+ Tk_3DBorder lMarginColor; /* Used for drawing background in left margins.
+ * This is used for both lmargin1 and lmargin2.
+ * NULL means no value specified here. */
char *offsetString; /* -offset option string (malloc-ed). NULL
* means option not specified. */
int offset; /* Vertical offset of text's baseline from
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index b74c6db..c0d6384 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -136,6 +136,7 @@ typedef struct StyleValues {
* line of each text line. */
int lMargin2; /* Left margin, in pixels, for second and
* later display lines of each text line. */
+ Tk_3DBorder lMarginColor; /* Color of left margins (1 and 2). */
int offset; /* Offset in pixels of baseline, relative to
* baseline of line. */
int overstrike; /* Non-zero means draw overstrike through
@@ -240,6 +241,10 @@ typedef struct DLine {
int spaceBelow; /* How much extra space was added to the
* bottom of the line because of spacing
* options. This is included in height. */
+ Tk_3DBorder lMarginColor; /* Background color of the area corresponding
+ * to the left margin of the display line. */
+ int lMarginWidth; /* Pixel width of the area corresponding to
+ * the left 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
@@ -765,6 +770,7 @@ GetStyle(
int fgPrio, fontPrio, fgStipplePrio;
int underlinePrio, elidePrio, justifyPrio, offsetPrio;
int lMargin1Prio, lMargin2Prio, rMarginPrio;
+ int lMarginColorPrio;
int spacing1Prio, spacing2Prio, spacing3Prio;
int overstrikePrio, tabPrio, tabStylePrio, wrapPrio;
@@ -779,6 +785,7 @@ GetStyle(
fgPrio = fontPrio = fgStipplePrio = -1;
underlinePrio = elidePrio = justifyPrio = offsetPrio = -1;
lMargin1Prio = lMargin2Prio = rMarginPrio = -1;
+ lMarginColorPrio = -1;
spacing1Prio = spacing2Prio = spacing3Prio = -1;
overstrikePrio = tabPrio = tabStylePrio = wrapPrio = -1;
memset(&styleValues, 0, sizeof(StyleValues));
@@ -901,6 +908,11 @@ GetStyle(
styleValues.lMargin2 = tagPtr->lMargin2;
lMargin2Prio = tagPtr->priority;
}
+ if ((tagPtr->lMarginColor != NULL)
+ && (tagPtr->priority > lMarginColorPrio)) {
+ styleValues.lMarginColor = tagPtr->lMarginColor;
+ lMarginColorPrio = tagPtr->priority;
+ }
if ((tagPtr->offsetString != NULL)
&& (tagPtr->priority > offsetPrio)) {
styleValues.offset = tagPtr->offset;
@@ -1173,6 +1185,8 @@ LayoutDLine(
dlPtr->nextPtr = NULL;
dlPtr->flags = NEW_LAYOUT | OLD_Y_INVALID;
dlPtr->logicalLinesMerged = 0;
+ dlPtr->lMarginColor = NULL;
+ dlPtr->lMarginWidth = 0;
/*
* This is not necessarily totally correct, where we have merged logical
@@ -1447,6 +1461,7 @@ LayoutDLine(
x = chunkPtr->stylePtr->sValuePtr->lMargin2;
}
+ dlPtr->lMarginWidth = x;
if (wrapMode == TEXT_WRAPMODE_NONE) {
maxX = -1;
} else {
@@ -1758,6 +1773,7 @@ LayoutDLine(
}
dlPtr->height += dlPtr->spaceAbove + dlPtr->spaceBelow;
dlPtr->baseline += dlPtr->spaceAbove;
+ dlPtr->lMarginColor = sValuePtr->lMarginColor;
/*
* Recompute line length: may have changed because of justification.
@@ -2444,6 +2460,16 @@ DisplayDLine(
Tk_Width(textPtr->tkwin), dlPtr->height, 0, TK_RELIEF_FLAT);
/*
+ * Second, draw the background color of the left margin.
+ */
+ 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);
+ }
+
+ /*
* Next, draw background information for the whole line.
*/
diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c
index e268352..a3e55fc 100644
--- a/generic/tkTextTag.c
+++ b/generic/tkTextTag.c
@@ -61,6 +61,8 @@ static const Tk_OptionSpec tagOptionSpecs[] = {
NULL, -1, Tk_Offset(TkTextTag, lMargin1String), TK_OPTION_NULL_OK,0,0},
{TK_OPTION_STRING, "-lmargin2", NULL, NULL,
NULL, -1, Tk_Offset(TkTextTag, lMargin2String), TK_OPTION_NULL_OK,0,0},
+ {TK_OPTION_BORDER, "-lmargincolor", NULL, NULL,
+ NULL, -1, Tk_Offset(TkTextTag, lMarginColor), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-offset", NULL, NULL,
NULL, -1, Tk_Offset(TkTextTag, offsetString), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-overstrike", NULL, NULL,
@@ -542,7 +544,8 @@ TkTextTagCmd(
|| (tagPtr->overstrikeString != NULL)
|| (tagPtr->overstrikeColor != NULL)
|| (tagPtr->underlineString != NULL)
- || (tagPtr->underlineColor != NULL)) {
+ || (tagPtr->underlineColor != NULL)
+ || (tagPtr->lMarginColor != NULL)) {
tagPtr->affectsDisplay = 1;
}
if (!newTag) {
@@ -1039,6 +1042,7 @@ TkTextCreateTag(
tagPtr->lMargin1 = 0;
tagPtr->lMargin2String = NULL;
tagPtr->lMargin2 = 0;
+ tagPtr->lMarginColor = NULL;
tagPtr->offsetString = NULL;
tagPtr->offset = 0;
tagPtr->overstrikeString = NULL;