NAME
Gtk2::Ex::CrossHair -- crosshair lines drawn following the mouse
SYNOPSIS
use Gtk2::Ex::CrossHair;
my $crosshair = Gtk2::Ex::CrossHair->new (widgets => [$w1,$w2]);
$crosshair->signal_connect (moved => sub { ... });
$crosshair->start ($event);
$crosshair->end ();
OBJECT HIERARCHY
Gtk2::Ex::CrossHair is a subclass of Glib::Object.
Glib::Object
Gtk2::Ex::CrossHair
DESCRIPTION
A CrossHair object draws a horizontal and vertical line through the mouse pointer position on top of one or more widgets' existing contents. This is intended as a visual guide for the user.
+-----------------+
| | |
| | mouse |
| |/ |
| --------+------ |
| | |
| | |
| | |
| | |
+-----------------+
+-----------------+
| | |
| | |
| | |
+-----------------+
The idea is to help see relative positions. For example in a graph the horizontal line helps you see which of two peaks is the higher, and the vertical line can extend down to (or into) an X axis scale to help see where exactly a particular part of the graph lies.
The moved callback lets you update a text status line with a position in figures, etc (if you don't display something like that following the mouse all the time).
While the crosshair is active the mouse cursor is set invisible in the target windows, since the cross is enough feedback and a cursor tends to obscure the lines. This is done with the WidgetCursor mechanism (see Gtk2::Ex::WidgetCursor) and so cooperates with other widget or application uses of that.
The crosshair is drawn using xors in the widget window. See Gtk2::Ex::Xor for notes on this.
FUNCTIONS
Gtk2::Ex::CrossHair->new (key => value, ...)-
Create and return a new CrossHair object. Optional key/value pairs set initial properties as per
Glib::Object->new. Eg.my $ch = Gtk2::Ex::CrossHair->new (widgets => [ $widget ], foreground => 'orange'); $crosshair->start ()$crosshair->start ($event)$crosshair->end ()-
Start or end crosshair display.
For
startif the optional$eventis aGtk2::Gdk::Event::Buttonthen the crosshair is active as long as that button is pressed, otherwise for a keypress, omitted, orundefthen the crosshair is active until explicitly stopped with anendcall.
PROPERTIES
active(boolean)-
True when the crosshair is to be drawn, moved, etc. Turning this on or off is the same as calling
startorendabove (except you can't pass a button press event). widgets(array ofGtk2::Widget)-
An arrayref of widgets to draw on. Often this will be just one widget, but multiple widgets can be given to draw in them all at the same time.
widget(Gtk2::Widget)-
A single widget to operate on. The
widgetandwidgetsproperties access the same underlying set of widgets to operate on, you can set or get whichever best suits. But if there's more than one widget you can't get from the singlewidget. foreground(colour scalar, default undef)-
The colour for the crosshair. This can be
A string colour name or #RGB form per
Gtk2::Gdk::Color->parseA
Gtk2::Gdk::Colorobject.undef(the default) for the widget stylefgforeground colour (see Gtk2::Style).
SIGNALS
- moved (parameters: crosshair, widget, x, y, userdata)
-
Emitted when the crosshair moves to the given
$widgetand X,Y coordinates within that widget (widget relative coordinates).$widgetisundefif the mouse moves outside any of the crosshair widgets.It's worth noting a subtle difference in
movedreporting when a crosshair is activated from a button or from the keyboard. A button press causes an implicit grab and all events are reported to that window.movedgives that widget and an X,Y position possibly outside its window area (eg. negatives). But for a keyboard or programmatic startmovedreports the widget currently containing the mouse, orundefwhen not in any. Usually the button press grab is good thing, it means a dragged button keeps reporting about its original window.
BUGS
no-window widgets don't work properly, but instead should be put in a Gtk2::EventBox and that passed to the crosshair.
SEE ALSO
Gtk2::Ex::Lasso, Gtk2::Ex::Xor, Glib::Object, Gtk2::Ex::WidgetCursor
HOME PAGE
http://www.geocities.com/user42_kevin/gtk2-ex-xor/index.html
LICENSE
Copyright 2007, 2008 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/.