Kevin Ryde
and 1 contributors

NAME

Gtk2::Ex::Xor -- shared support for drawing with XOR

DESCRIPTION

This is support code shared by Gtk2::Ex::CrossHair and Gtk2::Ex::Lasso.

Both those add-ons draw using an "xor" onto the pixels in a widget (hence the dist name), using a value that flips between the widget background and the cross or lasso line colour. Drawing like this is fast and portable, though doing it as an add-on can potentially clash with what the widget does natively.

  • A single dominant background colour is assumed. Often shades of grey or similar will end up with a contrasting line but there's no guarantee of that.

  • The background colour is taken from the widget Gtk2::Style "bg" for normal widgets, or from "base" for text widgets Gtk2::Entry and Gtk2::TextView. Goo::Canvas is recognised as using "base" too.

  • Expose events are watched and xoring redone, though it assumes the widget will redraw only the exposed region, as opposed to a full window redraw. Clipping in a redraw is usually what you want, especially if the display might not have the X double-buffering extension.

  • For multi-window widgets it's necessary to figure out which subwindow is the one to draw on. The xoring recognises the "bin" window of Gtk2::Layout (which includes Gnome2::Canvas), the "text" subwindow of Gtk2::TextView, and the secret subwindows of Gtk2::Entry and Goo::Canvas.

  • The SyncCall mechanism is used to protect against flooding the server with more drawing than it can keep up with. Each motion event would only result in a few drawing requests, but it's still easy to overload the server if it sends a lot of motions or if it's not very fast at drawing wide lines. The effect of SyncCall is to delay further drawing until hearing back from the server that the previous has completed.

SEE ALSO

Gtk2::Ex::CrossHair, Gtk2::Ex::Lasso

HOME PAGE

http://user42.tuxfamily.org/gtk2-ex-xor/index.html

LICENSE

Copyright 2007, 2008, 2009, 2010 Kevin Ryde

Gtk2-Ex-Xor is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Gtk2-Ex-Xor is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Gtk2-Ex-Xor. If not, see http://www.gnu.org/licenses/.