Toc Gallery Index Tree Gtk.Ruler

Screenshot

No screeshot

Hierarchy

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_Ruler_Record is new Gtk.Widget.Gtk_Widget_Record with private;
  • 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);
    Creates or initializes a new horizontal ruler
  • procedure Gtk_New_Vruler (Ruler : out Gtk_Ruler);
    procedure Initialize_Vruler (Ruler : access Gtk_Ruler_Record'Class);
    Creates or initializes a new vertical ruler
  • function Get_Type return Gtk.Gtk_Type;
    function Hruler_Get_Type return Gtk.Gtk_Type;
    function Vruler_Get_Type return Gtk.Gtk_Type;
    Return the internal value associated with a Gtk_Ruler.
  • procedure Set_Metric (Ruler : access Gtk_Ruler_Record; Metric : Gtk_Metric_Type);
    function Get_Metric (Ruler : access Gtk_Ruler_Record) return Gtk_Metric_Type;
    Set or get the units used for a Gtk_Ruler. See Set_Metric.
  • 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);
    Retrieve values indicating the range and current position of a Ruler. See Set_Range. Lower: Lower limit of the ruler. Upper: Upper limit of the ruler. Position: Current position of the mark on the ruler. Max_Size: Maximum size of the ruler used when calculating the space to leave for the text.
  • procedure Draw_Ticks (Ruler : access Gtk_Ruler_Record);
    procedure Draw_Pos (Ruler : access Gtk_Ruler_Record);
    ???

Properties

  • Lower_Property
    Double
    Lower limit of ruler
  • Max_Size_Property
    Double
    Maximum size of the ruler
  • Metric_Property
    Enum
    The metric used for the ruler
  • Position_Property
    Double
    Position of mark on the ruler
  • Upper_Property
    Double
    Upper limit of ruler

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;

Alphabetical Index