1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  GtkOffscreenWindow is strictly intended to be used for obtaining snapshots 
  26. --  of widgets that are not part of a normal widget hierarchy. Since 
  27. --  Gtk.Offscreen_Window.Gtk_Offscreen_Window is a toplevel widget you cannot 
  28. --  obtain snapshots of a full window with it since you cannot pack a toplevel 
  29. --  widget in another toplevel. 
  30. -- 
  31. --  The idea is to take a widget and manually set the state of it, add it to a 
  32. --  GtkOffscreenWindow and then retrieve the snapshot as a cairo_surface_t or 
  33. --  Gdk.Pixbuf.Gdk_Pixbuf. 
  34. -- 
  35. --  GtkOffscreenWindow derives from Gtk.Window.Gtk_Window only as an 
  36. --  implementation detail. Applications should not use any API specific to 
  37. --  Gtk.Window.Gtk_Window to operate on this object. It should be treated as a 
  38. --  Gtk.Bin.Gtk_Bin that has no parent widget. 
  39. -- 
  40. --  When contained offscreen widgets are redrawn, GtkOffscreenWindow will emit 
  41. --  a Gtk.Widget.Gtk_Widget::damage-event signal. 
  42. -- 
  43. --  </description> 
  44. pragma Ada_2005; 
  45.  
  46. pragma Warnings (Off, "*is already use-visible*"); 
  47. with Cairo;         use Cairo; 
  48. with Gdk.Pixbuf;    use Gdk.Pixbuf; 
  49. with Glib;          use Glib; 
  50. with Glib.Types;    use Glib.Types; 
  51. with Gtk.Buildable; use Gtk.Buildable; 
  52. with Gtk.Window;    use Gtk.Window; 
  53.  
  54. package Gtk.Offscreen_Window is 
  55.  
  56.    type Gtk_Offscreen_Window_Record is new Gtk_Window_Record with null record; 
  57.    type Gtk_Offscreen_Window is access all Gtk_Offscreen_Window_Record'Class; 
  58.  
  59.    ------------------ 
  60.    -- Constructors -- 
  61.    ------------------ 
  62.  
  63.    procedure Gtk_New (Self : out Gtk_Offscreen_Window); 
  64.    procedure Initialize 
  65.       (Self : not null access Gtk_Offscreen_Window_Record'Class); 
  66.    --  Creates a toplevel container widget that is used to retrieve snapshots 
  67.    --  of widgets without showing them on the screen. 
  68.    --  Since: gtk+ 2.20 
  69.  
  70.    function Gtk_Offscreen_Window_New return Gtk_Offscreen_Window; 
  71.    --  Creates a toplevel container widget that is used to retrieve snapshots 
  72.    --  of widgets without showing them on the screen. 
  73.    --  Since: gtk+ 2.20 
  74.  
  75.    function Get_Type return Glib.GType; 
  76.    pragma Import (C, Get_Type, "gtk_offscreen_window_get_type"); 
  77.  
  78.    ------------- 
  79.    -- Methods -- 
  80.    ------------- 
  81.  
  82.    function Get_Pixbuf 
  83.       (Self : not null access Gtk_Offscreen_Window_Record) 
  84.        return Gdk.Pixbuf.Gdk_Pixbuf; 
  85.    --  Retrieves a snapshot of the contained widget in the form of a 
  86.    --  Gdk.Pixbuf.Gdk_Pixbuf. This is a new pixbuf with a reference count of 1, 
  87.    --  and the application should unreference it once it is no longer needed. 
  88.    --  Since: gtk+ 2.20 
  89.  
  90.    function Get_Surface 
  91.       (Self : not null access Gtk_Offscreen_Window_Record) 
  92.        return Cairo.Cairo_Surface; 
  93.    --  Retrieves a snapshot of the contained widget in the form of a 
  94.    --  cairo_surface_t. If you need to keep this around over window resizes 
  95.    --  then you should add a reference to it. 
  96.    --  Since: gtk+ 2.20 
  97.  
  98.    ---------------- 
  99.    -- Interfaces -- 
  100.    ---------------- 
  101.    --  This class implements several interfaces. See Glib.Types 
  102.    -- 
  103.    --  - "Buildable" 
  104.  
  105.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  106.      (Gtk.Buildable.Gtk_Buildable, Gtk_Offscreen_Window_Record, Gtk_Offscreen_Window); 
  107.    function "+" 
  108.      (Widget : access Gtk_Offscreen_Window_Record'Class) 
  109.    return Gtk.Buildable.Gtk_Buildable 
  110.    renames Implements_Gtk_Buildable.To_Interface; 
  111.    function "-" 
  112.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  113.    return Gtk_Offscreen_Window 
  114.    renames Implements_Gtk_Buildable.To_Object; 
  115.  
  116. end Gtk.Offscreen_Window;