Version 0 of Images behind text

Updated 2006-03-20 23:12:57

Can the text widget display images, a watermark or thin lines at certain columns? Not yet...

How hard would this be to implement? I don't think it would be too bad. All (or very nearly all) of the text widget's drawing passes through DisplayDLine (tkTextDisp.c). The first thing this routine does is to clear the area of the display line to the widget's background colour:

    /*
  • First, clear the area of the line to the background color for the text
  • widget.
     */

    display = Tk_Display(textPtr->tkwin);
    Tk_Fill3DRectangle(textPtr->tkwin, pixmap, textPtr->border, 0, 0,
            Tk_Width(textPtr->tkwin), dlPtr->height, 0, TK_RELIEF_FLAT);

Every routine from this point on simply draws on top of that pixmap with the background colour already in place.

So, what if we were to insert some extra code in here to allow arbitrary drawing on the 'pixmap' first? We could imagine any of:

1) Allow an image to be specified which will then be tiled onto 'pixmap'

2) Allow a canvas to be specified which will again be tiled onto 'pixmap'

Neither of these should be that hard to implement...

Anyone keen to try?