Description
This widget is generally put on the sides of a drawing area to help the
user measure distances. It indicates the current position of the mouse
cursor within the drawing area, and can be graduated in multiple units.
Types
-
type Gtk_Hruler is Gtk_Ruler;
-
type Gtk_Hruler_Record is Gtk_Ruler_Record;
-
type Gtk_Ruler is access all Gtk_Ruler_Record'Class;
-
-
type Gtk_Vruler is Gtk_Ruler;
-
type Gtk_Vruler_Record is Gtk_Ruler_Record;
Subprograms
-
procedure Gtk_New_Hruler (Ruler : out Gtk_Ruler);
procedure Initialize_Hruler (Ruler : access Gtk_Ruler_Record'Class);
-
procedure Gtk_New_Vruler (Ruler : out Gtk_Ruler);
procedure Initialize_Vruler (Ruler : access Gtk_Ruler_Record'Class);
-
-
procedure Set_Metric
(Ruler : access Gtk_Ruler_Record;
Metric : Gtk_Metric_Type);
function Get_Metric
(Ruler : access Gtk_Ruler_Record) return Gtk_Metric_Type;
-
procedure Set_Range
(Ruler : access Gtk_Ruler_Record;
Lower : Gdouble;
Upper : Gdouble;
Position : Gdouble;
Max_Size : Gdouble);
procedure Get_Range
(Ruler : access Gtk_Ruler_Record;
Lower : out Gdouble;
Upper : out Gdouble;
Position : out Gdouble;
Max_Size : out Gdouble);
-
procedure Draw_Ticks (Ruler : access Gtk_Ruler_Record);
procedure Draw_Pos (Ruler : access Gtk_Ruler_Record);
Testgtk source code
This code is part of testgtk, a demo application packaged with GtkAda. Testgtk demonstrates the various widgets of GtkAda
-----------------------------------------------------------------------
-- GtkAda - Ada95 binding for the Gimp Toolkit --
-- --
-- Copyright (C) 1998-1999 --
-- Emmanuel Briot, Joel Brobecker and Arnaud Charlet --
-- --
-- This library 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 2 of the License, or (at your option) any later version. --
-- --
-- This library 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 this library; if not, write to the --
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, --
-- Boston, MA 02111-1307, USA. --
-- --
--
--
--
--
--
--
--
-----------------------------------------------------------------------
with Glib;
use Glib;
with Gdk.Event;
use Gdk.Event;
with Gtk.Drawing_Area;
use Gtk.Drawing_Area;
with Gtk.Enums;
use Gtk.Enums;
with Gtk.Object;
use Gtk.Object;
with Gtk.Ruler;
use Gtk.Ruler;
with Gtk.Handlers;
use Gtk.Handlers;
with Gtk.Table;
use Gtk.Table;
with Gtk.Widget;
use Gtk.Widget;
with Gtk;
use Gtk;
package body Create_Rulers
is
package Motion_Cb
is new Handlers.Return_Callback
(Gtk_Widget_Record, Gint);
----------
-- Help --
----------
function Help
return String
is
begin
return "The @bGtk_Ruler@B widget
is used to display the cursor"
& " coordinates
in an image. Note that to
use it, you need to modify"
& " the event mask
of the widget to allow
for @bPointer_Motion_Mask@B"
& " events.";
end Help;
---------
-- Run --
---------
procedure Run (Frame :
access Gtk.Frame.Gtk_Frame_Record'Class)
is
Ruler : Gtk_Ruler;
Table : Gtk_Table;
Darea : Gtk_Drawing_Area;
begin
Set_Label (Frame, "Ruler");
Gtk_New (Table, 2, 2, False);
Add (Frame, Table);
Gtk_New (Darea);
Unrealize (Darea);
Set_Events (Darea, Pointer_Motion_Mask + Pointer_Motion_Hint_Mask);
Attach
(Table, Darea, 1, 2, 1, 2,
Expand + Enums.Fill, Expand + Enums.Fill, 0, 0);
Gtk_New_Hruler (Ruler);
Set_Range (Ruler, 5.0, 15.0, 0.0, 20.0);
Motion_Cb.Object_Connect
(Gtk_Object (Darea), "motion_notify_event",
Motion_Cb.To_Marshaller (Default_Motion_Notify_Event'Access),
Slot_Object => Ruler);
Attach
(Table, Ruler, 1, 2, 0, 1, Expand + Enums.Fill, Enums.Fill, 0, 0);
Gtk_New_Vruler (Ruler);
Set_Range (Ruler, 5.0, 15.0, 0.0, 20.0);
Motion_Cb.Object_Connect
(Gtk_Object (Darea), "motion_notify_event",
Motion_Cb.To_Marshaller (Default_Motion_Notify_Event'Access),
Slot_Object => Ruler);
Attach
(Table, Ruler, 0, 1, 1, 2, Enums.Fill, Expand + Enums.Fill, 0, 0);
Show_All (Frame);
end Run;
end Create_Rulers;