Xfce
Foundation Classes |
|||
« Main Page | Index | |||
RulersRuler widgets are used to indicate the location of the mouse pointer in a given window. A window can have a vertical ruler spanning across its width and a horizontal ruler spanning down its height. A small triangular indicator on the ruler shows the exact location of the pointer relative to the ruler. A ruler must first be created. You can create a horizontal ruler with the following constructors: HRuler(); VRuler(); VRuler(Gtk::MetricType metric); The first horizontal and vertical constructor will create a new ruler with the metric type of Gtk::PIXELS. The last horizontal and vertical constructor will create a new ruler with the specified metric type. Units of measure for rulers can be one of
the following values from
the
Gtk::MetricType enum:
void
set_metric(Gtk::MetricType metric); void
set_range(double lower, double upper, double
position, double max_size); The 'lower' and 'upper' arguments
define the extent of the ruler, and 'max_size' is the largest
possible number that will be displayed. The 'position'
argument defines the initial position of the pointer indicator within
the ruler.
A vertical ruler can span an 800 pixel wide window thus: ruler->set_range(0,
800, 0, 800); The markings displayed on the
ruler will be
from 0
to 800, with a number for every 100 pixels. If instead we wanted the
ruler to range from 7 to 16, we would code like this instead:
ruler->set_range(7,
16, 0, 20); The indicator on the ruler is a small triangular mark that indicates the position of the pointer relative to the ruler. If the ruler is used to follow the mouse pointer, the 'motion_notify_event' signal of the widget should be connected to the 'motion_notify_event' method of the ruler. To follow all mouse movements within a window area, you would use: window->signal_motion_notify_event().connect(ruler,
ruler->gtk_widget_class()->motion_notify_event);
Ruler ExampleThe following example creates a drawing area with a horizontal ruler above it and a vertical ruler to the left of it. The size of the drawing area is 600 pixels wide by 400 pixels high. The horizontal ruler spans from 7 to 13 with a mark every 100 pixels, while the vertical ruler spans from 0 to 400 with a mark every 100 pixels. Placement of the drawing area and the rulers is done using a table.The header file for the Ruler example is <rulers.hh> #include <xfc/main.hh> and the source file is <rulers.cc> #include "rulers.hh" Compiling Ruler
If you compiled and installed XFC yourself, you will find the source
code for Ruler in the
<examples/rulers> source directory along with a Makefile. If
XFC came pre-installed, or you installed it from an RPM package, you
will
find the source code in the
</usr/share/doc/xfcui-X.X/examples/rulers> subdirectory. In
this case you will have to create the Makefile yourself (replace X.X
with the
version number of the libXFCui library you have installed). |
Copyright © 2004-2005 The XFC Development Team | Top |
XFC
4.4 |