Home > Archive > Tcl > July 2005 > XSetClipMask on Windows?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
XSetClipMask on Windows?
|
|
| Eckhard Lehmann 2005-07-24, 8:59 pm |
| Hi,
I am about to write an TkCanvas Item, which should draw lines onto the
canvas in a special area. However, the lines can go outside this area,
and if they do, I don't want to see the parts of the lines which are
outside. It looks like:
+------------------------------+
| |
| /** |
| +-----------+ | -> The canvas
| | /* | |
| | / |-----------> the viewable area inside the
canvas
| +-----------+ |
| / |
| |
+------------------------------+
* the line: visible part inside the viewable area
** also part of the line: part outside the viewable area, should not
be visible
On linux and any system with native X11 I can use the functions
XSetClipMask() and XSetClipOrigin() to define a Pixmap as viewable
area. This pixmap was allocated before with depth 1 and the
width/height of the desired viewable area. When I draw the lines with
XDrawLines() onto the canvas display later, only the line parts inside
the ClipMask are visible.
But this does not work on windows - XSetClipMask and XSetClipOrigin do
exist in Tk, but they are not usable to restrict the viewable area -
it does not matter whether I call the functions or not, I see always
all parts of the lines.
Is there any other posibility with Tk on Windows, to define viewable
areas, like the XSetClipMask function? How can I achieve this
functionality for Tk canvas items? Thank you much in advance for any
hint.
Eckhard
| |
| Kevin Kenny 2005-07-24, 8:59 pm |
| Eckhard Lehmann wrote:
> I am about to write an TkCanvas Item, which should draw lines onto the
> canvas in a special area. However, the lines can go outside this area,
> and if they do, I don't want to see the parts of the lines which are
> outside.
Will anything else be drawn in this special viewport? If not, an easier
approach would to be use [$theCanvas create window] to make another
canvas inside the first, and draw in that. Alas, there's no current way
to make the inner canvas transparent, or this would solve the whole
problem.
That *does* suggest a way to proceed on Windows, though, doesn't it?
It might be easier to find a way to add transparent backgrounds to
widgets there than to implement clipping in Tk's Xlib emulation layer.
--
73 de ke9tv/2, Kevin
| |
| Jeff Hobbs 2005-07-24, 8:59 pm |
| Eckhard Lehmann wrote:
> Is there any other posibility with Tk on Windows, to define viewable
> areas, like the XSetClipMask function? How can I achieve this
> functionality for Tk canvas items? Thank you much in advance for any
> hint.
Look at the tktable sources in generic/tkTable.c for the
#define NO_XSETCLIP. Somewhere in TableDisplay you will
find some heinous #if code for WIN32 that does clipping
using Win32 APIs in a manner that works with Tk. I take
no responsibility for whatever damage you do with it. ;)
--
Jeff Hobbs, The Tcl Guy
http://www.ActiveState.com/, a division of Sophos
| |
| Eckhard Lehmann 2005-07-24, 8:59 pm |
| Jeff Hobbs <jeffh@removethis.activestate.com> wrote in message news:<42DEA126.7070700@removethis.activestate.com>...
> Eckhard Lehmann wrote:
>
> Look at the tktable sources in generic/tkTable.c for the
> #define NO_XSETCLIP. Somewhere in TableDisplay you will
> find some heinous #if code for WIN32 that does clipping
> using Win32 APIs in a manner that works with Tk. I take
> no responsibility for whatever damage you do with it. ;)
The #ifdef's for native WIN32 code does not work. Using that approach,
only the clipped area is drawn. The rest of the canvas takes the
background of whatever applications are running and part of the
desktop background picture.
But the #define NO_XSETCLIP has given a very good hint. An offline
Pixmap is created with the size of the Tk_Canvas and the viewable area
from the canvas is copied to it using XCopyArea(). Then, the lines are
drawn onto the offline Pixmap. Afterwards the offline Pixmap with the
drawn lines and viewable area is copied back onto the Canvas, taking
care on the size. Probably not the cleanest solution compared to
XSetClipMask(), but a working and smart one... ;-)
Thank you very much!
Eckhard
|
|
|
|
|