diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-10-25 21:06:25 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-10-25 21:06:25 (GMT) |
| commit | 0d5336db012f45753abace489f18f0ca299c6961 (patch) | |
| tree | b1bf3280a9046df99226158978502eeb26f5b0a3 /generic/tkCanvText.c | |
| parent | e97381a6d921de403516d5b761539a450f4af83c (diff) | |
| parent | 1320b8a2a9c1269a345d44d673a7a35707fbbe9c (diff) | |
| download | tk-core-tip-626.zip tk-core-tip-626.tar.gz tk-core-tip-626.tar.bz2 | |
Merge 9.0core-tip-626
Diffstat (limited to 'generic/tkCanvText.c')
| -rw-r--r-- | generic/tkCanvText.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c index 285adcd..e3dbe66 100644 --- a/generic/tkCanvText.c +++ b/generic/tkCanvText.c @@ -54,7 +54,7 @@ typedef struct TextItem { Pixmap activeStipple; /* Stipple bitmap for text, or None. */ Pixmap disabledStipple; /* Stipple bitmap for text, or None. */ char *text; /* Text for item (malloc-ed). */ - int width; /* Width of lines for word-wrap, pixels. Zero + Tcl_Obj *widthObj; /* Width of lines for word-wrap, pixels. Zero * means no word-wrap. */ int underline; /* Index of character to put underline beneath * or INT_MIN for no underlining. */ @@ -209,7 +209,7 @@ static const Tk_ConfigSpec configSpecs[] = { {TK_CONFIG_CUSTOM, "-underline", NULL, NULL, NULL, offsetof(TextItem, underline), TK_CONFIG_NULL_OK, &underlineOption}, {TK_CONFIG_PIXELS, "-width", NULL, NULL, - "0", offsetof(TextItem, width), TK_CONFIG_DONT_SET_DEFAULT, NULL}, + "0", offsetof(TextItem, widthObj), TK_CONFIG_OBJS, NULL}, {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL} }; @@ -346,7 +346,7 @@ CreateText( textPtr->activeStipple = None; textPtr->disabledStipple = None; textPtr->text = NULL; - textPtr->width = 0; + textPtr->widthObj = NULL; textPtr->underline = INT_MIN; textPtr->angle = 0.0; @@ -724,8 +724,12 @@ ComputeTextBbox( } Tk_FreeTextLayout(textPtr->textLayout); + width = 0; + if (textPtr->widthObj) { + Tk_GetPixelsFromObj(NULL, Tk_CanvasTkwin(canvas), textPtr->widthObj, &width); + } textPtr->textLayout = Tk_ComputeTextLayout(textPtr->tkfont, - textPtr->text, textPtr->numChars, textPtr->width, + textPtr->text, textPtr->numChars, width, textPtr->justify, 0, &width, &height); if (state == TK_STATE_HIDDEN || textPtr->color == NULL) { @@ -795,6 +799,8 @@ ComputeTextBbox( */ textInfoPtr = textPtr->textInfoPtr; + Tk_GetPixelsFromObj(NULL, Tk_CanvasTkwin(canvas), (Tcl_Obj *)textInfoPtr->reserved2, &textInfoPtr->insertWidth); + Tk_GetPixelsFromObj(NULL, Tk_CanvasTkwin(canvas), (Tcl_Obj *)textInfoPtr->reserved3, &textInfoPtr->selBorderWidth); fudge = (textInfoPtr->insertWidth + 1) / 2; if (textInfoPtr->selBorderWidth > fudge) { fudge = textInfoPtr->selBorderWidth; @@ -943,6 +949,7 @@ DisplayCanvText( x = xFirst; height = hFirst; + Tk_GetPixelsFromObj(NULL, Tk_CanvasTkwin(canvas), (Tcl_Obj *)textInfoPtr->reserved3, &textInfoPtr->selBorderWidth); for (y = yFirst ; y <= yLast; y += height) { int dx1, dy1, dx2, dy2; double s = textPtr->sine, c = textPtr->cosine; @@ -989,6 +996,7 @@ DisplayCanvText( double s = textPtr->sine, c = textPtr->cosine; XPoint points[4]; + Tk_GetPixelsFromObj(NULL, Tk_CanvasTkwin(canvas), (Tcl_Obj *)textInfoPtr->reserved2, &textInfoPtr->insertWidth); dx1 = x - (textInfoPtr->insertWidth / 2); dy1 = y; dx2 = textInfoPtr->insertWidth; @@ -1005,6 +1013,7 @@ DisplayCanvText( Tk_SetCaretPos(Tk_CanvasTkwin(canvas), points[0].x, points[0].y, height); if (textInfoPtr->cursorOn) { + Tk_GetPixelsFromObj(NULL, Tk_CanvasTkwin(canvas), (Tcl_Obj *)textInfoPtr->reserved1, &textInfoPtr->insertBorderWidth); Tk_Fill3DPolygon(Tk_CanvasTkwin(canvas), drawable, textInfoPtr->insertBorder, points, 4, textInfoPtr->insertBorderWidth, TK_RELIEF_RAISED); |
