diff options
Diffstat (limited to 'unix')
-rw-r--r-- | unix/Makefile.in | 70 | ||||
-rw-r--r-- | unix/tkUnixDefault.h | 6 | ||||
-rw-r--r-- | unix/tkUnixRFont.c | 85 |
3 files changed, 113 insertions, 48 deletions
diff --git a/unix/Makefile.in b/unix/Makefile.in index b48df8b..0efa439 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -358,19 +358,20 @@ CANV_OBJS = tkCanvas.o tkCanvArc.o tkCanvBmap.o tkCanvImg.o \ IMAGE_OBJS = tkImage.o tkImgBmap.o tkImgGIF.o tkImgPNG.o tkImgPPM.o \ tkImgPhoto.o tkImgPhInstance.o tkImgListFormat.o -TEXT_OBJS = tkText.o tkTextBTree.o tkTextDisp.o tkTextImage.o tkTextIndex.o \ - tkTextMark.o tkTextTag.o tkTextWind.o +TEXT_OBJS = tkText.o tkTextBTree.o tkTextDisp.o tkTextImage.o \ + tkTextIndex.o tkTextLineBreak.o tkTextMark.o tkTextTag.o \ + tkTextTagSet.o tkTextUndo.o tkTextWind.o # either tkUnixFont.o (default) or tkUnixRFont.o (if --enable-xft) # FONT_OBJS = @UNIX_FONT_OBJS@ -GENERIC_OBJS = tk3d.o tkArgv.o tkAtom.o tkBind.o tkBitmap.o tkBusy.o \ - tkClipboard.o \ - tkCmds.o tkColor.o tkConfig.o tkConsole.o tkCursor.o tkError.o \ - tkEvent.o tkFocus.o tkFont.o tkGet.o tkGC.o tkGeometry.o tkGrab.o \ - tkGrid.o tkMain.o tkObj.o tkOldConfig.o tkOption.o tkPack.o tkPlace.o \ - tkSelect.o tkStyle.o tkUndo.o tkUtil.o tkVisual.o tkWindow.o +GENERIC_OBJS = tk3d.o tkArgv.o tkAtom.o tkBind.o tkBitmap.o tkBitField.o \ + tkBusy.o tkClipboard.o tkCmds.o tkColor.o tkConfig.o tkConsole.o \ + tkCursor.o tkError.o tkEvent.o tkFocus.o tkFont.o tkGet.o tkGC.o \ + tkGeometry.o tkGrab.o tkGrid.o tkIntSet.o tkMain.o tkObj.o tkOldConfig.o \ + tkOption.o tkPack.o tkPlace.o tkRangeList.o tkSelect.o tkStyle.o \ + tkUtil.o tkVisual.o tkWindow.o TTK_OBJS = \ ttkBlink.o ttkButton.o ttkCache.o ttkClamTheme.o ttkClassicTheme.o \ @@ -420,8 +421,8 @@ TTK_DECLS = \ GENERIC_SRCS = \ $(GENERIC_DIR)/tk3d.c $(GENERIC_DIR)/tkArgv.c \ $(GENERIC_DIR)/tkAtom.c $(GENERIC_DIR)/tkBind.c \ - $(GENERIC_DIR)/tkBitmap.c $(GENERIC_DIR)/tkBusy.c \ - $(GENERIC_DIR)/tkClipboard.c \ + $(GENERIC_DIR)/tkBitField.c $(GENERIC_DIR)/tkBitmap.c \ + $(GENERIC_DIR)/tkBusy.c $(GENERIC_DIR)/tkClipboard.c \ $(GENERIC_DIR)/tkCmds.c $(GENERIC_DIR)/tkColor.c \ $(GENERIC_DIR)/tkConfig.c $(GENERIC_DIR)/tkCursor.c \ $(GENERIC_DIR)/tkError.c $(GENERIC_DIR)/tkEvent.c \ @@ -429,10 +430,11 @@ GENERIC_SRCS = \ $(GENERIC_DIR)/tkGet.c $(GENERIC_DIR)/tkGC.c \ $(GENERIC_DIR)/tkGeometry.c $(GENERIC_DIR)/tkGrab.c \ $(GENERIC_DIR)/tkGrid.c $(GENERIC_DIR)/tkConsole.c \ + $(GENERIC_DIR)/tkIntSet.c \ $(GENERIC_DIR)/tkMain.c $(GENERIC_DIR)/tkOption.c \ $(GENERIC_DIR)/tkPack.c $(GENERIC_DIR)/tkPlace.c \ $(GENERIC_DIR)/tkSelect.c $(GENERIC_DIR)/tkStyle.c \ - $(GENERIC_DIR)/tkUndo.c $(GENERIC_DIR)/tkUtil.c \ + $(GENERIC_DIR)/tkUtil.c \ $(GENERIC_DIR)/tkVisual.c $(GENERIC_DIR)/tkWindow.c \ $(GENERIC_DIR)/tkButton.c $(GENERIC_DIR)/tkObj.c \ $(GENERIC_DIR)/tkEntry.c $(GENERIC_DIR)/tkFrame.c \ @@ -450,11 +452,13 @@ GENERIC_SRCS = \ $(GENERIC_DIR)/tkImgBmap.c $(GENERIC_DIR)/tkImgGIF.c \ $(GENERIC_DIR)/tkImgPNG.c $(GENERIC_DIR)/tkImgPPM.c \ $(GENERIC_DIR)/tkImgPhoto.c $(GENERIC_DIR)/tkImgPhInstance.c \ - $(GENERIC_DIR)/tkImgListFormat.c $(GENERIC_DIR)/tkText.c \ - $(GENERIC_DIR)/tkTextBTree.c $(GENERIC_DIR)/tkTextDisp.c \ - $(GENERIC_DIR)/tkTextImage.c \ - $(GENERIC_DIR)/tkTextIndex.c $(GENERIC_DIR)/tkTextMark.c \ - $(GENERIC_DIR)/tkTextTag.c $(GENERIC_DIR)/tkTextWind.c \ + $(GENERIC_DIR)/tkImgListFormat.c $(GENERIC_DIR)/tkRangeList.c \ + $(GENERIC_DIR)/tkText.c $(GENERIC_DIR)/tkTextBTree.c \ + $(GENERIC_DIR)/tkTextDisp.c $(GENERIC_DIR)/tkTextImage.c \ + $(GENERIC_DIR)/tkTextIndex.c $(GENERIC_DIR)/tkTextLineBreak.c \ + $(GENERIC_DIR)/tkTextMark.c $(GENERIC_DIR)/tkTextTag.c \ + $(GENERIC_DIR)/tkTextTagSet.c $(GENERIC_DIR)/tkTextUndo.c \ + $(GENERIC_DIR)/tkTextWind.c \ $(GENERIC_DIR)/tkOldConfig.c $(GENERIC_DIR)/tkOldTest.c \ $(GENERIC_DIR)/tkSquare.c $(GENERIC_DIR)/tkTest.c \ $(GENERIC_DIR)/tkStubInit.c @@ -943,6 +947,9 @@ tkAtom.o: $(GENERIC_DIR)/tkAtom.c tkBind.o: $(GENERIC_DIR)/tkBind.c $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkBind.c +tkBitField.o: $(GENERIC_DIR)/tkBitField.c + $(CC) -std=c99 -c $(CC_SWITCHES) $(GENERIC_DIR)/tkBitField.c + tkBitmap.o: $(GENERIC_DIR)/tkBitmap.c $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkBitmap.c @@ -1126,32 +1133,47 @@ tkImgPhInstance.o: $(GENERIC_DIR)/tkImgPhInstance.c $(GENERIC_DIR)/tkImgPhoto.h tkOldTest.o: $(GENERIC_DIR)/tkOldTest.c $(CC) -c $(APP_CC_SWITCHES) $(GENERIC_DIR)/tkOldTest.c +tkRangeList.o: $(GENERIC_DIR)/tkRangeList.c + $(CC) -std=c99 -c $(CC_SWITCHES) $(GENERIC_DIR)/tkRangeList.c + +tkIntSet.o: $(GENERIC_DIR)/tkIntSet.c + $(CC) -std=c99 -c $(CC_SWITCHES) $(GENERIC_DIR)/tkIntSet.c + tkTest.o: $(GENERIC_DIR)/tkTest.c $(CC) -c $(APP_CC_SWITCHES) $(GENERIC_DIR)/tkTest.c tkText.o: $(GENERIC_DIR)/tkText.c - $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkText.c + $(CC) -std=c99 -c $(CC_SWITCHES) $(GENERIC_DIR)/tkText.c tkTextBTree.o: $(GENERIC_DIR)/tkTextBTree.c - $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkTextBTree.c + $(CC) -std=c99 -c $(CC_SWITCHES) $(GENERIC_DIR)/tkTextBTree.c tkTextDisp.o: $(GENERIC_DIR)/tkTextDisp.c - $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkTextDisp.c + $(CC) -std=c99 -c $(CC_SWITCHES) $(GENERIC_DIR)/tkTextDisp.c tkTextImage.o: $(GENERIC_DIR)/tkTextImage.c - $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkTextImage.c + $(CC) -std=c99 -c $(CC_SWITCHES) $(GENERIC_DIR)/tkTextImage.c tkTextIndex.o: $(GENERIC_DIR)/tkTextIndex.c - $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkTextIndex.c + $(CC) -std=c99 -c $(CC_SWITCHES) $(GENERIC_DIR)/tkTextIndex.c + +tkTextLineBreak.o: $(GENERIC_DIR)/tkTextLineBreak.c + $(CC) -std=c99 -c $(CC_SWITCHES) $(GENERIC_DIR)/tkTextLineBreak.c tkTextMark.o: $(GENERIC_DIR)/tkTextMark.c - $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkTextMark.c + $(CC) -std=c99 -c $(CC_SWITCHES) $(GENERIC_DIR)/tkTextMark.c tkTextTag.o: $(GENERIC_DIR)/tkTextTag.c - $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkTextTag.c + $(CC) -std=c99 -c $(CC_SWITCHES) $(GENERIC_DIR)/tkTextTag.c + +tkTextTagSet.o: $(GENERIC_DIR)/tkTextTagSet.c + $(CC) -std=c99 -c $(CC_SWITCHES) $(GENERIC_DIR)/tkTextTagSet.c + +tkTextUndo.o: $(GENERIC_DIR)/tkTextUndo.c + $(CC) -std=c99 -c $(CC_SWITCHES) $(GENERIC_DIR)/tkTextUndo.c tkTextWind.o: $(GENERIC_DIR)/tkTextWind.c - $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkTextWind.c + $(CC) -std=c99 -c $(CC_SWITCHES) $(GENERIC_DIR)/tkTextWind.c tkStubInit.o: $(GENERIC_DIR)/tkStubInit.c $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkStubInit.c diff --git a/unix/tkUnixDefault.h b/unix/tkUnixDefault.h index 2c3854d..424ba94 100644 --- a/unix/tkUnixDefault.h +++ b/unix/tkUnixDefault.h @@ -19,6 +19,7 @@ * NORMAL_BG - Normal background color. * ACTIVE_BG - Background color when widget is active. * SELECT_BG - Background color for selected text. + * SELECT_FG - Foreground color for selected text. * TROUGH - Background color for troughs in scales and scrollbars. * INDICATOR - Color for indicator when button is selected. * DISABLED - Foreground color when widget is disabled. @@ -30,6 +31,7 @@ #define NORMAL_BG "#d9d9d9" #define ACTIVE_BG "#ececec" #define SELECT_BG "#c3c3c3" +#define SELECT_FG BLACK #define TROUGH "#b3b3b3" #define CHECK_INDICATOR WHITE #define MENU_INDICATOR BLACK @@ -486,7 +488,9 @@ #define DEF_TEXT_PADX "1" #define DEF_TEXT_PADY "1" #define DEF_TEXT_RELIEF "sunken" -#define DEF_TEXT_INACTIVE_SELECT_COLOR SELECT_BG +#define DEF_TEXT_INACTIVE_SELECT_BG_COLOR SELECT_BG +#define DEF_TEXT_INACTIVE_SELECT_FG_COLOR SELECT_FG +#define DEF_TEXT_INACTIVE_SELECT_COLOR_DISABLED "0" #define DEF_TEXT_SELECT_COLOR SELECT_BG #define DEF_TEXT_SELECT_MONO BLACK #define DEF_TEXT_SELECT_BD_COLOR "0" diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index ccf77a3..4f7f6f3 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -14,6 +14,14 @@ #include <X11/Xft/Xft.h> #include <ctype.h> +/* needed for backport to 8.5 */ +#ifndef ROUND16 +# define ROUND16(x) ((short) floor((x) + 0.5)) +#endif +#ifndef PI +# define PI 3.14159265358979323846 +#endif + #define MAX_CACHED_COLORS 16 typedef struct { @@ -614,11 +622,24 @@ TkpGetSubFonts( *---------------------------------------------------------------------- */ +/* we need backward compatibility */ +#if TK_MAJOR_VERSION == 8 && TK_MINOR_VERSION < 7 +# define UNICHAR Tcl_UniChar +# define TkUtfToUniChar Tcl_UtfToUniChar +#else /* if !(TK_MAJOR_VERSION == 8 && TK_MINOR_VERSION < 7) */ +# define UNICHAR int +# if TCL_UTF_MAX > 4 +# define TkUtfToUniChar Tcl_UtfToUniChar +# else /* if TCL_UTF_MAX <= 4 */ +extern int TkUtfToUniChar(const char *src, int *chPtr); +# endif /* TCL_UTF_MAX > 4 */ +#endif /* TK_MAJOR_VERSION == 8 && TK_MINOR_VERSION < 7 */ + void TkpGetFontAttrsForChar( Tk_Window tkwin, /* Window on the font's display */ Tk_Font tkfont, /* Font to query */ - int c, /* Character of interest */ + UNICHAR c, /* Character of interest */ TkFontAttributes *faPtr) /* Output: Font attributes */ { UnixFtFont *fontPtr = (UnixFtFont *) tkfont; @@ -671,7 +692,7 @@ Tk_MeasureChars( curByte = 0; sawNonSpace = 0; while (numBytes > 0) { - int unichar; + UNICHAR unichar; clen = TkUtfToUniChar(source, &unichar); c = (FcChar32) unichar; @@ -859,6 +880,10 @@ Tk_DrawChars( ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + if (maxCoord <= y) { + return; /* nothing to draw */ + } + if (fontPtr->ftDraw == 0) { #if DEBUG_FONTSEL printf("Switch to drawable 0x%x\n", drawable); @@ -879,7 +904,7 @@ Tk_DrawChars( XftDrawSetClip(fontPtr->ftDraw, tsdPtr->clipRegion); } nspec = 0; - while (numBytes > 0 && x <= maxCoord && y <= maxCoord) { + while (numBytes > 0) { XftFont *ftFont; FcChar32 c; @@ -896,19 +921,25 @@ Tk_DrawChars( ftFont = GetFont(fontPtr, c, 0.0); if (ftFont) { - specs[nspec].font = ftFont; + int cx = x; + int cy = y; + specs[nspec].glyph = XftCharIndex(fontPtr->display, ftFont, c); - specs[nspec].x = x; - specs[nspec].y = y; XftGlyphExtents(fontPtr->display, ftFont, &specs[nspec].glyph, 1, &metrics); - x += metrics.xOff; - y += metrics.yOff; - nspec++; - if (nspec == NUM_SPEC) { - XftDrawGlyphFontSpec(fontPtr->ftDraw, xftcolor, - specs, nspec); - nspec = 0; + if ((x += metrics.xOff) >= maxCoord + || (y += metrics.yOff) >= maxCoord) { + break; + } + if (metrics.xOff > 0 && cx >= 0 && cy >= 0) { + specs[nspec].font = ftFont; + specs[nspec].x = cx; + specs[nspec].y = cy; + if (++nspec == NUM_SPEC) { + XftDrawGlyphFontSpec(fontPtr->ftDraw, xftcolor, + specs, nspec); + nspec = 0; + } } } } @@ -1011,8 +1042,7 @@ TkDrawAngledChars( currentFtFont = NULL; originX = originY = 0; /* lint */ - while (numBytes > 0 && x <= maxCoord && x >= minCoord && y <= maxCoord - && y >= minCoord) { + while (numBytes > 0 && x >= minCoord && y >= minCoord) { XftFont *ftFont; FcChar32 c; @@ -1050,8 +1080,17 @@ TkDrawAngledChars( XftGlyphExtents(fontPtr->display, currentFtFont, glyphs, nglyph, &metrics); nglyph = 0; - x += metrics.xOff; - y += metrics.yOff; + /* + * Breaking at this place is sub-optimal, but the whole algorithm + * has a design problem, the choice of NUM_SPEC is arbitrary, and so + * the inter-glyph spacing will look arbitrary. This algorithm + * has to draw the whole string at once (or whole blocks with same + * font), this requires a dynamic 'glyphs' array. In case of overflow + * the array has to be divided until the maximal string will fit. (GC) + */ + if ((x += metrics.xOff) >= maxCoord || (y += metrics.yOff) >= maxCoord) { + break; + } } currentFtFont = ftFont; } @@ -1087,8 +1126,7 @@ TkDrawAngledChars( XftDrawSetClip(fontPtr->ftDraw, tsdPtr->clipRegion); } nspec = 0; - while (numBytes > 0 && x <= maxCoord && x >= minCoord - && y <= maxCoord && y >= minCoord) { + while (numBytes > 0 && x >= minCoord && y >= minCoord) { XftFont *ftFont, *ft0Font; FcChar32 c; @@ -1112,10 +1150,11 @@ TkDrawAngledChars( specs[nspec].y = ROUND16(y); XftGlyphExtents(fontPtr->display, ft0Font, &specs[nspec].glyph, 1, &metrics); - x += metrics.xOff*cosA + metrics.yOff*sinA; - y += metrics.yOff*cosA - metrics.xOff*sinA; - nspec++; - if (nspec == NUM_SPEC) { + if ((x += metrics.xOff*cosA + metrics.yOff*sinA) > maxCoord + || (y += metrics.yOff*cosA - metrics.xOff*sinA) > maxCoord) { + break; + } + if (++nspec == NUM_SPEC) { XftDrawGlyphFontSpec(fontPtr->ftDraw, xftcolor, specs, nspec); nspec = 0; |