1----------------------------------------------------------------------- 2-- GtkAda - Ada95 binding for the Gimp Toolkit -- 3-- -- 4-- Copyright (C) 1998-1999 -- 5-- Emmanuel Briot, Joel Brobecker and Arnaud Charlet -- 6-- Copyright (C) 2000-2013, AdaCore -- 7-- -- 8-- This library is free software; you can redistribute it and/or -- 9-- modify it under the terms of the GNU General Public -- 10-- License as published by the Free Software Foundation; either -- 11-- version 2 of the License, or (at your option) any later version. -- 12-- -- 13-- This library is distributed in the hope that it will be useful, -- 14-- but WITHOUT ANY WARRANTY; without even the implied warranty of -- 15-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- 16-- General Public License for more details. -- 17-- -- 18-- You should have received a copy of the GNU General Public -- 19-- License along with this library; if not, write to the -- 20-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- 21-- Boston, MA 02111-1307, USA. -- 22-- -- 23-- As a special exception, if other files instantiate generics from -- 24-- this unit, or you link this unit with other files to produce an -- 25-- executable, this unit does not by itself cause the resulting -- 26-- executable to be covered by the GNU General Public License. This -- 27-- exception does not however invalidate any other reasons why the -- 28-- executable file might be covered by the GNU Public License. -- 29----------------------------------------------------------------------- 30 31with Glib; use Glib; 32with Glib.Object; use Glib.Object; 33with Gdk.Event; use Gdk.Event; 34with Gtk.Drawing_Area; use Gtk.Drawing_Area; 35with Gtk.Enums; use Gtk.Enums; 36with Gtk.Ruler; use Gtk.Ruler; 37with Gtk.Handlers; use Gtk.Handlers; 38with Gtk.Table; use Gtk.Table; 39with Gtk.Widget; use Gtk.Widget; 40with Gtk; use Gtk; 41 42package body Create_Rulers is 43 44 package Motion_Cb is new Handlers.Return_Callback 45 (Gtk_Widget_Record, Gint); 46 47 ---------- 48 -- Help -- 49 ---------- 50 51 function Help return String is 52 begin 53 return "The @bGtk_Ruler@B widget is used to display the cursor" 54 & " coordinates in an image. Note that to use it, you need to modify" 55 & " the event mask of the widget to allow for @bPointer_Motion_Mask@B" 56 & " events."; 57 end Help; 58 59 --------- 60 -- Run -- 61 --------- 62 63 procedure Run (Frame : access Gtk.Frame.Gtk_Frame_Record'Class) is 64 Ruler : Gtk_Ruler; 65 Table : Gtk_Table; 66 Darea : Gtk_Drawing_Area; 67 68 begin 69 Set_Label (Frame, "Ruler"); 70 71 Gtk_New (Table, 2, 2, False); 72 Add (Frame, Table); 73 74 Gtk_New (Darea); 75 Unrealize (Darea); 76 Set_Events (Darea, Pointer_Motion_Mask + Pointer_Motion_Hint_Mask); 77 Attach 78 (Table, Darea, 1, 2, 1, 2, 79 Expand + Enums.Fill, Expand + Enums.Fill, 0, 0); 80 81 Gtk_New_Hruler (Ruler); 82 Set_Range (Ruler, 5.0, 15.0, 0.0, 20.0); 83 Motion_Cb.Object_Connect 84 (GObject (Darea), "motion_notify_event", 85 Motion_Cb.To_Marshaller (Default_Motion_Notify_Event'Access), 86 Slot_Object => Ruler); 87 Attach 88 (Table, Ruler, 1, 2, 0, 1, Expand + Enums.Fill, Enums.Fill, 0, 0); 89 90 Gtk_New_Vruler (Ruler); 91 Set_Range (Ruler, 5.0, 15.0, 0.0, 20.0); 92 Motion_Cb.Object_Connect 93 (GObject (Darea), "motion_notify_event", 94 Motion_Cb.To_Marshaller (Default_Motion_Notify_Event'Access), 95 Slot_Object => Ruler); 96 Attach 97 (Table, Ruler, 0, 1, 1, 2, Enums.Fill, Expand + Enums.Fill, 0, 0); 98 99 Show_All (Frame); 100 end Run; 101 102end Create_Rulers; 103