Tutorial |
||
|
||
|
HRuler(); VRuler(); |
void
set_metric(Gtk::MetricType metric = Gtk::PIXELS); |
void
set_range(double lower, double upper, double
position, double max_size); |
ruler->set_range(0, 800, 0, 800); |
ruler->set_range(7,
16, 0, 20); |
window->sig_motion_notify_event().connect(ruler, ruler->gtk_widget_class()->motion_notify_event); |
#include<inti/main.h> #include <inti/core.h> #include <inti/gtk/ruler.h> using namespace Inti; class RulerWindow : public Gtk::Window { public: RulerWindow(); ~RulerWindow(); }; |
#include"rulers.h" #include <inti/gtk/table.h> #include <inti/gtk/drawingarea.h> #include <inti/bind.h> RulerWindow::RulerWindow() { set_border_width(10); // Create a table for placing the ruler and the drawing area Gtk::Table *table = new Gtk::Table(3, 2); add(*table); Gtk::DrawingArea *area = new Gtk::DrawingArea(600, 400); table->attach(*area, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); area->set_events(GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); // The horizontal ruler goes on top. As the mouse moves across the drawing area, // a motion_notify_event is passed to the appropriate event handler for the ruler. Gtk::HRuler *hruler = new Gtk::HRuler; hruler->set_metric(Gtk::PIXELS); hruler->set_range(7, 13, 0, 20); area->sig_motion_notify_event().connect(hruler, hruler->gtk_widget_class()->motion_notify_event); table->attach(*hruler, 1, 2, 0, 1, Gtk::EXPAND | Gtk::SHRINK | Gtk::FILL, Gtk::FILL); // The vertical ruler goes on the left. As the mouse moves across the drawing area, // a motion_notify_event is passed to the appropriate event handler for the ruler. Gtk::VRuler *vruler = new Gtk::VRuler; vruler->set_metric(Gtk::PIXELS); vruler->set_range(0, 400, 10, 400); area->sig_motion_notify_event().connect(vruler, vruler->gtk_widget_class()->motion_notify_event); table->attach(*vruler, 0, 1, 1, 2, Gtk::FILL, Gtk::EXPAND | Gtk::SHRINK | Gtk::FILL); // Now show everything show_all(); } RulerWindow::~RulerWindow() { } int main (int argc, char *argv[]) { using namespace Main; init(&argc, &argv); RulerWindow window; window.sig_destroy().connect(slot(&Inti::Main::quit)); run(); return 0; } |
|
|||
|
|||