1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --   Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet   -- 
  5. --                Copyright (C) 2000-2010 AdaCore                    -- 
  6. --                                                                   -- 
  7. -- This library is free software; you can redistribute it and/or     -- 
  8. -- modify it under the terms of the GNU General Public               -- 
  9. -- License as published by the Free Software Foundation; either      -- 
  10. -- version 2 of the License, or (at your option) any later version.  -- 
  11. --                                                                   -- 
  12. -- This library is distributed in the hope that it will be useful,   -- 
  13. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  14. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  15. -- General Public License for more details.                          -- 
  16. --                                                                   -- 
  17. -- You should have received a copy of the GNU General Public         -- 
  18. -- License along with this library; if not, write to the             -- 
  19. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  20. -- Boston, MA 02111-1307, USA.                                       -- 
  21. --                                                                   -- 
  22. -- As a special exception, if other files instantiate generics from  -- 
  23. -- this unit, or you link this unit with other files to produce an   -- 
  24. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  25. -- executable to be covered by the GNU General Public License. This  -- 
  26. -- exception does not however invalidate any other reasons why the   -- 
  27. -- executable file  might be covered by the  GNU Public License.     -- 
  28. ----------------------------------------------------------------------- 
  29.  
  30. --  <description> 
  31. --  The Gtk_Image widget displays a graphical image. The image is typically 
  32. --  created using Gdk.Image.Gdk_New. 
  33. -- 
  34. --  The pixels in a Gtk_Image may be manipulated by the application after 
  35. --  creation, as Gtk_Image store the pixel data on the client side. If you wish 
  36. --  to store the pixel data on the server side (thus not allowing manipulation 
  37. --  of the data after creation) you should use Gtk_Pixmap. 
  38. --  </description> 
  39. --  <c_version>2.16.6</c_version> 
  40. --  <group>Display widgets</group> 
  41. --  <screenshot>gtk-image</screenshot> 
  42.  
  43. with Glib.G_Icon; 
  44. with Glib.Properties; 
  45. with Gdk.Bitmap; 
  46. with Gdk.Pixbuf; 
  47. with Gdk.Pixmap; 
  48. with Gdk.Image; 
  49. with Gtk.Enums; 
  50. with Gtk.Icon_Factory; 
  51. with Gtk.Misc; 
  52. with GNAT.Strings; 
  53. with Glib.Generic_Properties; 
  54.  
  55. package Gtk.Image is 
  56.  
  57.    type Gtk_Image_Record is new Gtk.Misc.Gtk_Misc_Record with private; 
  58.    type Gtk_Image is access all Gtk_Image_Record'Class; 
  59.  
  60.    type Gtk_Image_Type is 
  61.      (Image_Empty, 
  62.       Image_Pixmap, 
  63.       Image_Image, 
  64.       Image_Pixbuf, 
  65.       Image_Stock, 
  66.       Image_Icon_Set, 
  67.       Image_Animation, 
  68.       Image_Icon_Name, 
  69.       Image_Gicon); 
  70.    pragma Convention (C, Gtk_Image_Type); 
  71.  
  72.    procedure Gtk_New    (Image : out Gtk_Image); 
  73.    procedure Initialize (Image : access Gtk_Image_Record'Class); 
  74.    --  Creates a new empty image 
  75.  
  76.    procedure Gtk_New 
  77.      (Image : out Gtk_Image; 
  78.       Val   : Gdk.Image.Gdk_Image; 
  79.       Mask  : Gdk.Bitmap.Gdk_Bitmap); 
  80.    procedure Initialize 
  81.      (Image : access Gtk_Image_Record'Class; 
  82.       Val   : Gdk.Image.Gdk_Image; 
  83.       Mask  : Gdk.Bitmap.Gdk_Bitmap); 
  84.    --  Creates or initializes an image 
  85.  
  86.    procedure Gtk_New 
  87.      (Image  : out Gtk_Image; 
  88.       Pixmap : Gdk.Pixmap.Gdk_Pixmap; 
  89.       Mask   : Gdk.Bitmap.Gdk_Bitmap); 
  90.    procedure Initialize 
  91.      (Image  : access Gtk_Image_Record'Class; 
  92.       Pixmap : Gdk.Pixmap.Gdk_Pixmap; 
  93.       Mask   : Gdk.Bitmap.Gdk_Bitmap); 
  94.    --  Creates or initializes an image from its components 
  95.  
  96.    procedure Gtk_New 
  97.      (Image    : out Gtk_Image; 
  98.       Filename : String); 
  99.    procedure Initialize 
  100.      (Image    : access Gtk_Image_Record'Class; 
  101.       Filename : String); 
  102.    --  Creates or initializes an image from a file 
  103.  
  104.    procedure Gtk_New 
  105.      (Image  : out Gtk_Image; 
  106.       Pixbuf : Gdk.Pixbuf.Gdk_Pixbuf); 
  107.    procedure Initialize 
  108.      (Image  : access Gtk_Image_Record'Class; 
  109.       Pixbuf : Gdk.Pixbuf.Gdk_Pixbuf); 
  110.    --  Creates or initializes an image from an existing pixbuf 
  111.  
  112.    procedure Gtk_New 
  113.      (Image    : out Gtk_Image; 
  114.       Stock_Id : String; 
  115.       Size     : Gtk.Enums.Gtk_Icon_Size); 
  116.    procedure Initialize 
  117.      (Image    : access Gtk_Image_Record'Class; 
  118.       Stock_Id : String; 
  119.       Size     : Gtk.Enums.Gtk_Icon_Size); 
  120.    --  Creates or initializes an image from one of the predefined images of 
  121.    --  gtk+ (see gtk-stock.ads). The image will be scaled to the appropriate 
  122.    --  format. 
  123.  
  124.    procedure Gtk_New 
  125.      (Image    : out Gtk_Image; 
  126.       Icon_Set : Gtk.Icon_Factory.Gtk_Icon_Set; 
  127.       Size     : Gtk.Enums.Gtk_Icon_Size); 
  128.    procedure Initialize 
  129.      (Image    : access Gtk_Image_Record'Class; 
  130.       Icon_Set : Gtk.Icon_Factory.Gtk_Icon_Set; 
  131.       Size     : Gtk.Enums.Gtk_Icon_Size); 
  132.    --  Creates or initializes an image from a set of icons 
  133.  
  134.    procedure Gtk_New 
  135.      (Image     : out Gtk_Image; 
  136.       Animation : Gdk.Pixbuf.Gdk_Pixbuf_Animation); 
  137.    procedure Initialize 
  138.      (Image     : access Gtk_Image_Record'Class; 
  139.       Animation : Gdk.Pixbuf.Gdk_Pixbuf_Animation); 
  140.    --  Create or initializes a GtkImage displaying the given animation. 
  141.  
  142.    procedure Gtk_New_From_Icon_Name 
  143.      (Image     : out Gtk_Image; 
  144.       Icon_Name : String; 
  145.       Size      : Gtk.Enums.Gtk_Icon_Size); 
  146.    procedure Initialize_From_Icon_Name 
  147.      (Image     : access Gtk_Image_Record'Class; 
  148.       Icon_Name : String; 
  149.       Size      : Gtk.Enums.Gtk_Icon_Size); 
  150.    --  Creates or initialized an image displaying an icon from the current icon 
  151.    --  theme. If the icon name isn't known, a "broken image" icon will be 
  152.    --  displayed instead. If the current icon theme is changed, the icon will 
  153.    --  be updated appropriately. 
  154.  
  155.    procedure Gtk_New_From_Gicon 
  156.      (Image  : out Gtk_Image; 
  157.       Icon   : Glib.G_Icon.G_Icon; 
  158.       Size   : Gtk.Enums.Gtk_Icon_Size); 
  159.    procedure Initialize_From_Gicon 
  160.      (Image  : access Gtk_Image_Record'Class; 
  161.       Icon   : Glib.G_Icon.G_Icon; 
  162.       Size   : Gtk.Enums.Gtk_Icon_Size); 
  163.    --  Creates a Gtk_Image displaying an icon from the current icon theme. 
  164.    --  If the icon name isn't known, a "broken image" icon will be 
  165.    --  displayed instead.  If the current icon theme is changed, the icon 
  166.    --  will be updated appropriately. 
  167.  
  168.    function Get_Type return Glib.GType; 
  169.    --  Return the internal value associated with a Gtk_Image. 
  170.  
  171.    procedure Set 
  172.      (Image  : access Gtk_Image_Record; 
  173.       Pixmap : Gdk.Pixmap.Gdk_Pixmap; 
  174.       Mask   : Gdk.Bitmap.Gdk_Bitmap); 
  175.    procedure Get 
  176.      (Image  : access Gtk_Image_Record; 
  177.       Pixmap : out Gdk.Pixmap.Gdk_Pixmap; 
  178.       Mask   : out Gdk.Bitmap.Gdk_Bitmap); 
  179.    --  Set or Get the values of a Gtk_Image. 
  180.    --  Mask indicates which parts of the image should be transparent. 
  181.  
  182.    procedure Set 
  183.      (Image : access Gtk_Image_Record; 
  184.       Val   : Gdk.Image.Gdk_Image; 
  185.       Mask  : Gdk.Bitmap.Gdk_Bitmap); 
  186.    procedure Get 
  187.      (Image : access Gtk_Image_Record; 
  188.       Val   : out Gdk.Image.Gdk_Image; 
  189.       Mask  : out Gdk.Bitmap.Gdk_Bitmap); 
  190.    --  Set or Get the value of a Gtk_Image. 
  191.    --  Mask indicates which parts of the image should be transparent. 
  192.  
  193.    procedure Set (Image : access Gtk_Image_Record; File : String); 
  194.  
  195.    procedure Set 
  196.      (Image : access Gtk_Image_Record; Pixbuf : Gdk.Pixbuf.Gdk_Pixbuf); 
  197.    function Get (Image : access Gtk_Image_Record) return Gdk.Pixbuf.Gdk_Pixbuf; 
  198.    --  Set or get the image stored in Image 
  199.  
  200.    procedure Set 
  201.      (Image    : access Gtk_Image_Record; 
  202.       Stock_Id : String; 
  203.       Size     : Gtk.Enums.Gtk_Icon_Size); 
  204.    function Get 
  205.      (Image : access Gtk_Image_Record; 
  206.       Size  : access Gtk.Enums.Gtk_Icon_Size) return String; 
  207.    --  Set or get the image stored in Image 
  208.  
  209.    procedure Set 
  210.      (Image    : access Gtk_Image_Record; 
  211.       Icon_Set : Gtk.Icon_Factory.Gtk_Icon_Set; 
  212.       Size     : Gtk.Enums.Gtk_Icon_Size); 
  213.    procedure Get 
  214.      (Image    : access Gtk_Image_Record; 
  215.       Icon_Set : out Gtk.Icon_Factory.Gtk_Icon_Set; 
  216.       Size     : out Gtk.Enums.Gtk_Icon_Size); 
  217.    --  Set or get the image stored in Image 
  218.  
  219.    procedure Set 
  220.      (Image     : access Gtk_Image_Record; 
  221.       Animation : Gdk.Pixbuf.Gdk_Pixbuf_Animation); 
  222.    function Get 
  223.      (Image : access Gtk_Image_Record) return Gdk.Pixbuf.Gdk_Pixbuf_Animation; 
  224.    --  Get the Pixbuf Animation being displayed by the given Image. The 
  225.    --  reference counter for the returned animation is not incremented. This 
  226.    --  must be done separately if needed. 
  227.  
  228.    procedure Set 
  229.      (Image : access Gtk_Image_Record; 
  230.       Icon  : Glib.G_Icon.G_Icon; 
  231.       Size  : Gtk.Enums.Gtk_Icon_Size); 
  232.    procedure Get 
  233.      (Image : access Gtk_Image_Record; 
  234.       Icon  : out Glib.G_Icon.G_Icon; 
  235.       Size  : out Gtk.Enums.Gtk_Icon_Size); 
  236.    --  Sets/Gets the G_Icon and size being displayed by the Gtk_Image. 
  237.    --  For Get, the storage type of the image must be Image_Empty or 
  238.    --  Image_Gicon (see Get_Storage_Type).  The caller of the Get 
  239.    --  subprogram does not own a reference to the returned G_Icon. 
  240.  
  241.    function Get_Storage_Type 
  242.      (Image : access Gtk_Image_Record) return Gtk_Image_Type; 
  243.    --  Indicates how the image was created 
  244.  
  245.    procedure Clear (Image : access Gtk_Image_Record); 
  246.    --  Resets the image to be empty. 
  247.  
  248.    procedure Set_From_Icon_Name 
  249.      (Image     : access Gtk_Image_Record; 
  250.       Icon_Name : String; 
  251.       Size      : Gtk.Enums.Gtk_Icon_Size); 
  252.    procedure Get_Icon_Name 
  253.      (Image : access Gtk_Image_Record; 
  254.       Name  : out GNAT.Strings.String_Access; 
  255.       Size  : out Gtk.Enums.Gtk_Icon_Size); 
  256.    --  Gets the icon name and size being displayed by the image 
  257.    --  The storage type of the image must be Image_Empty or Image_Icon_Name. 
  258.    --  The returned string must be freed by the caller. 
  259.  
  260.    procedure Set_Pixel_Size 
  261.      (Image : access Gtk_Image_Record; Pixel_Size : Gint); 
  262.    function Get_Pixel_Size (Image : access Gtk_Image_Record) return Gint; 
  263.    --  Sets or Gets the pixel size used for named icons. 
  264.    --  If the pixel size is set to a value different from -1, it is used 
  265.    --  instead of the icon size set by Set_From_Icon_Name. 
  266.  
  267.    ---------------- 
  268.    -- Properties -- 
  269.    ---------------- 
  270.  
  271.    --  <properties> 
  272.    --  The following properties are defined for this widget. See 
  273.    --  Glib.Properties for more information on properties. 
  274.    -- 
  275.    --  Name:  File_Property 
  276.    --  Type:  String 
  277.    --  Descr: Filename to load and display 
  278.    -- 
  279.    --  Name:  Gicon_Property 
  280.    --  Type:  Object 
  281.    --  Descr: The GIcon being displayed 
  282.    -- 
  283.    --  Name:  Icon_Name_Property 
  284.    --  Type:  String 
  285.    --  Descr: The name of the icon from the icon theme 
  286.    -- 
  287.    --  Name:  Icon_Set_Property 
  288.    --  Type:  Boxed 
  289.    --  Descr: Icon set to display 
  290.    -- 
  291.    --  Name:  Icon_Size_Property 
  292.    --  Type:  Int 
  293.    --  Descr: Symbolic size to use for stock icon, icon set or named icon 
  294.    -- 
  295.    --  Name:  Image_Property 
  296.    --  Type:  Object 
  297.    --  Descr: A GdkImage to display 
  298.    -- 
  299.    --  Name:  Mask_Property 
  300.    --  Type:  Object 
  301.    --  Descr: Mask bitmap to use with GdkImage or GdkPixmap 
  302.    -- 
  303.    --  Name:  Pixbuf_Property 
  304.    --  Type:  Object 
  305.    --  Descr: A GdkPixbuf to display 
  306.    -- 
  307.    --  Name:  Pixbuf_Animation_Property 
  308.    --  Type:  Object 
  309.    --  Descr: GdkPixbufAnimation to display 
  310.    -- 
  311.    --  Name:  Pixel_Size_Property 
  312.    --  Type:  Int 
  313.    --  Descr: Pixel size to use for named icon 
  314.    -- 
  315.    --  Name:  Pixmap_Property 
  316.    --  Type:  Object 
  317.    --  Descr: A GdkPixmap to display 
  318.    -- 
  319.    --  Name:  Stock_Property 
  320.    --  Type:  String 
  321.    --  Descr: Stock ID for a stock image to display 
  322.    -- 
  323.    --  Name:  Storage_Type_Property 
  324.    --  Type:  Enum 
  325.    --  Descr: The representation being used for image data 
  326.    -- 
  327.    --  </properties> 
  328.  
  329.    package Image_Type_Properties is new 
  330.      Glib.Generic_Properties.Generic_Internal_Discrete_Property 
  331.        (Gtk_Image_Type); 
  332.    type Property_Image_Type is new Image_Type_Properties.Property; 
  333.  
  334.    File_Property             : constant Glib.Properties.Property_String; 
  335.    Gicon_Property            : constant Glib.Properties.Property_Object; 
  336.    Icon_Name_Property        : constant Glib.Properties.Property_String; 
  337.    --   Icon_Set_Property         : constant Glib.Properties.Property_Boxed; 
  338.    Icon_Size_Property        : constant Glib.Properties.Property_Int; 
  339.    Image_Property            : constant Glib.Properties.Property_Object; 
  340.    Mask_Property             : constant Glib.Properties.Property_Object; 
  341.    Pixbuf_Property           : constant Glib.Properties.Property_Object; 
  342.    Pixbuf_Animation_Property : constant Glib.Properties.Property_Object; 
  343.    Pixel_Size_Property       : constant Glib.Properties.Property_Int; 
  344.    Pixmap_Property           : constant Glib.Properties.Property_Object; 
  345.    Stock_Property            : constant Glib.Properties.Property_String; 
  346.    Storage_Type_Property     : constant Property_Image_Type; 
  347.  
  348.    ------------- 
  349.    -- Signals -- 
  350.    ------------- 
  351.  
  352.    --  <signals> 
  353.    --  The following new signals are defined for this widget: 
  354.    --  </signals> 
  355.  
  356. private 
  357.    type Gtk_Image_Record is new Gtk.Misc.Gtk_Misc_Record with null record; 
  358.  
  359.    File_Property      : constant Glib.Properties.Property_String := 
  360.      Glib.Properties.Build ("file"); 
  361.    Gicon_Property     : constant Glib.Properties.Property_Object := 
  362.      Glib.Properties.Build ("gicon"); 
  363.    Icon_Name_Property : constant Glib.Properties.Property_String := 
  364.      Glib.Properties.Build ("icon-name"); 
  365.    --  Icon_Set_Property  : constant Glib.Properties.Property_Boxed := 
  366.    --    Glib.Properties.Build ("icon-set"); 
  367.    Icon_Size_Property  : constant Glib.Properties.Property_Int := 
  368.      Glib.Properties.Build ("icon-size"); 
  369.    Image_Property      : constant Glib.Properties.Property_Object := 
  370.      Glib.Properties.Build ("image"); 
  371.    Mask_Property       : constant Glib.Properties.Property_Object := 
  372.      Glib.Properties.Build ("mask"); 
  373.    Pixbuf_Property     : constant Glib.Properties.Property_Object := 
  374.      Glib.Properties.Build ("pixbuf"); 
  375.    Pixbuf_Animation_Property : constant Glib.Properties.Property_Object := 
  376.      Glib.Properties.Build ("pixbuf-animation"); 
  377.    Pixel_Size_Property : constant Glib.Properties.Property_Int := 
  378.      Glib.Properties.Build ("pixel-size"); 
  379.    Pixmap_Property     : constant Glib.Properties.Property_Object := 
  380.      Glib.Properties.Build ("pixmap"); 
  381.    Stock_Property      : constant Glib.Properties.Property_String := 
  382.      Glib.Properties.Build ("stock"); 
  383.    Storage_Type_Property : constant Property_Image_Type := 
  384.      Build ("storage-type"); 
  385.  
  386.    pragma Import (C, Get_Type, "gtk_image_get_type"); 
  387. end Gtk.Image; 
  388.  
  389. --  These subprograms never had a binding, are now obsolescent anyway 
  390. --  No binding: gtk_image_get 
  391. --  No binding: gtk_image_set