Updated 2008-04-03 08:02:56 by tonytraductor

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?

tonytraductor I haven't the slightest idea how to implement that, but, I was looking for something similar just the other day. Actually, I was hoping to be able to alter the alpha/transparency of a text widget, then lay the text widget over an image viewer, for the purposes of making ascii art. If the bg of a text widget could be set to an image, that would produce a similar effect.