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