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-2013, 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. -- 
  32. --  Gtk_Scrolled_Window is a Gtk_Bin child: it's a container the accepts a 
  33. --  single child widget. Gtk_Scrolled_Window adds scrollbars to the child 
  34. --  widget. 
  35. -- 
  36. --  The scrolled window can work in two ways. Some widgets have native 
  37. --  scrolling support; these widgets have "slots" for Gtk_Adjustment objects. 
  38. --  The scrolled window installs Gtk_Adjustment objects in the child window's 
  39. --  slots using the "set_scroll_adjustments" signal (Conceptually, these 
  40. --  widgets implement a "Scrollable" interface). 
  41. -- 
  42. --  The second way to use the scrolled window is useful with widgets that lack 
  43. --  the "set_scroll_adjustments" signal. The Gtk_Viewport widget acts as a 
  44. --  proxy, implementing scrollability for child widgets that lack their own 
  45. --  scrolling capabilities. 
  46. -- 
  47. --  If a widget has native scrolling abilities, it can be added to the 
  48. --  Gtk_Scrolled_Window with Gtk.Container.Add. If a widget does not, you must 
  49. --  first add the widget to a Gtk_Viewport, then add the Gtk_Viewport to the 
  50. --  scrolled window. The convenience function Add_With_Viewport does exactly 
  51. --  this, so you can ignore the presence of the viewport. 
  52. -- 
  53. --  If you want to create your own new widget type that can be inserted 
  54. --  directly into a scrolled_window, you need to specify a signal for 
  55. --  Set_Scroll_Adjustments in the call to Glib.Object.Initialize_Class_Record. 
  56. -- 
  57. --  </description> 
  58. --  <c_version>2.16.6</c_version> 
  59. --  <group>Scrolling</group> 
  60. --  <testgtk>create_scrolled.adb</testgtk> 
  61. --  <screenshot>gtk-scrolled_window</screenshot> 
  62.  
  63. with Glib.Properties; 
  64. with Gtk.Adjustment; use Gtk.Adjustment; 
  65. with Gtk.Bin; 
  66. with Gtk.Enums; 
  67. with Gtk.Scrollbar; 
  68. with Gtk.Widget; 
  69.  
  70. package Gtk.Scrolled_Window is 
  71.  
  72.    type Gtk_Scrolled_Window_Record is new Bin.Gtk_Bin_Record with private; 
  73.    type Gtk_Scrolled_Window is access all Gtk_Scrolled_Window_Record'Class; 
  74.  
  75.    procedure Gtk_New 
  76.      (Scrolled_Window : out Gtk_Scrolled_Window; 
  77.       Hadjustment     : Gtk_Adjustment := null; 
  78.       Vadjustment     : Gtk_Adjustment := null); 
  79.    --  Create a new scrolled window. 
  80.    --  The two arguments are the scrolled window's horizontal and vertical 
  81.    --  adjustments; these will be shared with the scrollbars and the child 
  82.    --  widget to keep the bars in sync with the child. Usually you want to use 
  83.    --  the default value Null_Adjustment for the adjustments, which will cause 
  84.    --  the scrolled window to create them for you. 
  85.  
  86.    procedure Initialize 
  87.      (Scrolled_Window : access Gtk_Scrolled_Window_Record'Class; 
  88.       Hadjustment     : Gtk_Adjustment := null; 
  89.       Vadjustment     : Gtk_Adjustment := null); 
  90.    --  Internal initialization function. 
  91.    --  See the section "Creating your own widgets" in the documentation. 
  92.  
  93.    function Get_Type return Gtk.Gtk_Type; 
  94.    --  Return the internal value associated with a Gtk_Scrolled_Window. 
  95.  
  96.    procedure Set_Hadjustment 
  97.      (Scrolled_Window : access Gtk_Scrolled_Window_Record; 
  98.       Hadjustment     : Gtk_Adjustment); 
  99.    function Get_Hadjustment 
  100.      (Scrolled_Window : access Gtk_Scrolled_Window_Record) 
  101.       return Gtk_Adjustment; 
  102.    --  Set the Gtk_Adjustment for the horizontal scrollbar. 
  103.    --  This adjustment is used to connect the horizontal scrollbar to the child 
  104.    --  widget's horizontal scroll functionality. 
  105.  
  106.    procedure Set_Vadjustment 
  107.      (Scrolled_Window : access Gtk_Scrolled_Window_Record; 
  108.       Vadjustment     : Gtk_Adjustment); 
  109.    function Get_Vadjustment 
  110.      (Scrolled_Window : access Gtk_Scrolled_Window_Record) 
  111.       return Gtk_Adjustment; 
  112.    --  Set the Gtk_Adjustment for the vertical scrollbar. 
  113.    --  This adjustment is used to connect the vertical scrollbar to the child 
  114.    --  widget's vertical scroll functionality. 
  115.  
  116.    function Get_Hscrollbar 
  117.      (Scrolled_Window : access Gtk_Scrolled_Window_Record) 
  118.       return Gtk.Scrollbar.Gtk_Scrollbar; 
  119.    --  Returns the horizontal scrollbar, or null if it doesn't have one. 
  120.  
  121.    function Get_Vscrollbar 
  122.      (Scrolled_Window : access Gtk_Scrolled_Window_Record) 
  123.       return Gtk.Scrollbar.Gtk_Scrollbar; 
  124.    --  Returns the vertical scrollbar, or null if it doesn't have one. 
  125.  
  126.    procedure Set_Policy 
  127.      (Scrolled_Window    : access Gtk_Scrolled_Window_Record; 
  128.       H_Scrollbar_Policy : Enums.Gtk_Policy_Type; 
  129.       V_Scrollbar_Policy : Enums.Gtk_Policy_Type); 
  130.    procedure Get_Policy 
  131.      (Scrolled_Window    : access Gtk_Scrolled_Window_Record; 
  132.       H_Scrollbar_Policy : out Enums.Gtk_Policy_Type; 
  133.       V_Scrollbar_Policy : out Enums.Gtk_Policy_Type); 
  134.    --  Set the scrollbar policy for the horizontal and vertical scrollbars. 
  135.    --  It determines when the scrollbar should appear; it is a value 
  136.    --  from the Gtk_Policy_Type enumeration. If Policy_Always, the scrollbar is 
  137.    --  always present; if Policy_Never, the scrollbar is never present; if 
  138.    --  Policy_Automatic, the scrollbar is present only if needed (that is, if 
  139.    --  the slider part of the bar would be smaller than the trough - the 
  140.    --  display is larger than the page size). 
  141.  
  142.    procedure Set_Placement 
  143.      (Scrolled_Window  : access Gtk_Scrolled_Window_Record; 
  144.       Window_Placement : Gtk.Enums.Gtk_Corner_Type); 
  145.    function Get_Placement 
  146.      (Scrolled_Window  : access Gtk_Scrolled_Window_Record) 
  147.       return Gtk.Enums.Gtk_Corner_Type; 
  148.    --  Determine or return the location of the widget with respect to the 
  149.    --  scrollbars. The default is Corner_Top_Left. 
  150.  
  151.    procedure Unset_Placement 
  152.      (Scrolled_Window : access Gtk_Scrolled_Window_Record); 
  153.    --  Unsets the placement of the contents with respect to the scrollbars 
  154.    --  for the scrolled window. If no window placement is set for a scrolled 
  155.    --  window, it obeys the "gtk-scrolled-window-placement" XSETTING. 
  156.  
  157.    procedure Set_Shadow_Type 
  158.      (Scrolled_Window : access Gtk_Scrolled_Window_Record; 
  159.       Shadow_Type     : Gtk.Enums.Gtk_Shadow_Type); 
  160.    function Get_Shadow_Type 
  161.      (Scrolled_Window : access Gtk_Scrolled_Window_Record) 
  162.       return Gtk.Enums.Gtk_Shadow_Type; 
  163.    --  Change the type of shadow drawn around the contents of Scrolled_Window. 
  164.  
  165.    procedure Add_With_Viewport 
  166.      (Scrolled_Window : access Gtk_Scrolled_Window_Record; 
  167.       Child           : access Gtk.Widget.Gtk_Widget_Record'Class); 
  168.    --  Used to add children without native scrolling capabilities. 
  169.    --  This is simply a convenience function; it is equivalent to adding the 
  170.    --  unscrollable child to a viewport, then adding the viewport to the 
  171.    --  scrolled window. If a child has native scrolling, use Gtk.Container.Add 
  172.    --  instead of this function. 
  173.    -- 
  174.    --  The viewport scrolls the child by moving its Gdk_Window, and takes the 
  175.    --  size of the child to be the size of its toplevel Gdk_Window. This will 
  176.    --  be very wrong for most widgets that support native scrolling; for 
  177.    --  example, if you add a Gtk_Clist with a viewport, the whole widget will 
  178.    --  scroll, including the column headings. Thus Gtk_Clist supports scrolling 
  179.    --  already, and should not be used with the GtkViewport proxy. 
  180.    -- 
  181.    --  A widget supports scrolling natively if it contains a valid 
  182.    --  "set_scroll_adjustments" signal. 
  183.  
  184.    ---------------- 
  185.    -- Properties -- 
  186.    ---------------- 
  187.    --  The following properties are defined for this widget. See 
  188.    --  Glib.Properties for more information on properties. 
  189.  
  190.    --  <properties> 
  191.    --  Name:  Hadjustment_Property 
  192.    --  Type:  Object 
  193.    --  Descr: The GtkAdjustment for the horizontal position 
  194.    -- 
  195.    --  Name:  Hscrollbar_Policy_Property 
  196.    --  Type:  Enum 
  197.    --  Descr: When the horizontal scrollbar is displayed 
  198.    -- 
  199.    --  Name:  Shadow_Type_Property 
  200.    --  Type:  Enum 
  201.    --  Descr: Style of bevel around the contents 
  202.    -- 
  203.    --  Name:  Vadjustment_Property 
  204.    --  Type:  Object 
  205.    --  Descr: The GtkAdjustment for the vertical position 
  206.    -- 
  207.    --  Name:  Vscrollbar_Policy_Property 
  208.    --  Type:  Enum 
  209.    --  Descr: When the vertical scrollbar is displayed 
  210.    -- 
  211.    --  Name:  Window_Placement_Property 
  212.    --  Type:  Enum 
  213.    --  Descr: Where the contents are located with respect to the scrollbars 
  214.    -- 
  215.    --  Name:  Window_Placement_Set_Property 
  216.    --  Type:  Boolean 
  217.    --  Descr: Whether "window-placement" should be used to determine the 
  218.    --         location of the contents with respect to the scrollbars. 
  219.    -- 
  220.    --  </properties> 
  221.  
  222.    Hadjustment_Property       : constant Glib.Properties.Property_Object; 
  223.    Hscrollbar_Policy_Property : constant Gtk.Enums.Property_Gtk_Policy_Type; 
  224.    Shadow_Type_Property       : constant Gtk.Enums.Property_Gtk_Shadow_Type; 
  225.    Vadjustment_Property       : constant Glib.Properties.Property_Object; 
  226.    Vscrollbar_Policy_Property : constant Gtk.Enums.Property_Gtk_Policy_Type; 
  227.    Window_Placement_Property  : constant Gtk.Enums.Property_Gtk_Shadow_Type; 
  228.    Window_Placement_Set_Property : constant Glib.Properties.Property_Boolean; 
  229.  
  230.    ---------------------- 
  231.    -- Style Properties -- 
  232.    ---------------------- 
  233.    --  The following properties can be changed through the gtk theme and 
  234.    --  configuration files, and retrieved through Gtk.Widget.Style_Get_Property 
  235.  
  236.    --  <style_properties> 
  237.    --  Name:  Scrollbar_Spacing_Property 
  238.    --  Type:  Int 
  239.    --  Descr: Number of pixels between the scrollbars and the scrolled window 
  240.    -- 
  241.    --  Name:  Scrollbars_Within_Bevel_Property 
  242.    --  Type:  Boolean 
  243.    --  Descr: Place scrollbars within the scrolled window's bevel 
  244.    -- 
  245.    --  </style_properties> 
  246.  
  247.    Scrollbar_Spacing_Property : constant Glib.Properties.Property_Int; 
  248.    Scrollbars_Within_Bevel_Property : 
  249.      constant Glib.Properties.Property_Boolean; 
  250.  
  251.    ------------- 
  252.    -- Signals -- 
  253.    ------------- 
  254.  
  255.    --  <signals> 
  256.    --  The following new signals are defined for this widget: 
  257.    -- 
  258.    --  - "scroll_child" 
  259.    --    procedure Handler 
  260.    --       (Window     : access Gtk_Scrolled_Window_Record'Class; 
  261.    --        Typ        : Gtk_Scroll_Type; 
  262.    --        Horizontal : Gboolean); 
  263.    --    You should emit this signal to request a scrolling of the child. This 
  264.    --    signal is almost never needed directly, unless you connect it to a 
  265.    --    key binding. 
  266.    --    The boolean is used to further qualify Scroll_Start and Scroll_End, 
  267.    --    which do not have horizontal and vertical variants. 
  268.    -- 
  269.    --  - "move_focus_out" 
  270.    --    procedure Handler 
  271.    --       (Window     : access Gtk_Scrolled_Window_Record'Class; 
  272.    --        Direction  : Gtk_Direction_Type); 
  273.    --    Request that the keyboard focus be moved. You almost never have to 
  274.    --    emit this signal yourself, unless you are binding it to a key for 
  275.    --    user interaction. You do not need to connect to this signal 
  276.    --  </signals> 
  277.  
  278.    Signal_Move_Focus_Out : constant Glib.Signal_Name := "move_focus_out"; 
  279.    Signal_Scroll_Child   : constant Glib.Signal_Name := "scroll_child"; 
  280.  
  281. private 
  282.    type Gtk_Scrolled_Window_Record is new Bin.Gtk_Bin_Record with null record; 
  283.  
  284.    Hadjustment_Property       : constant Glib.Properties.Property_Object := 
  285.      Glib.Properties.Build ("hadjustment"); 
  286.    Hscrollbar_Policy_Property : constant Gtk.Enums.Property_Gtk_Policy_Type := 
  287.      Gtk.Enums.Build ("hscrollbar-policy"); 
  288.    Shadow_Type_Property       : constant Gtk.Enums.Property_Gtk_Shadow_Type := 
  289.      Gtk.Enums.Build ("shadow-type"); 
  290.    Vadjustment_Property       : constant Glib.Properties.Property_Object := 
  291.      Glib.Properties.Build ("vadjustment"); 
  292.    Vscrollbar_Policy_Property : constant Gtk.Enums.Property_Gtk_Policy_Type := 
  293.      Gtk.Enums.Build ("vscrollbar-policy"); 
  294.    Window_Placement_Property  : constant Gtk.Enums.Property_Gtk_Shadow_Type := 
  295.      Gtk.Enums.Build ("window-placement"); 
  296.    Window_Placement_Set_Property : constant Glib.Properties.Property_Boolean := 
  297.      Glib.Properties.Build ("window-placement-set"); 
  298.  
  299.    Scrollbars_Within_Bevel_Property : 
  300.      constant Glib.Properties.Property_Boolean := 
  301.      Glib.Properties.Build ("scrollbars-within-bevel"); 
  302.    Scrollbar_Spacing_Property : constant Glib.Properties.Property_Int := 
  303.      Glib.Properties.Build ("scrollbar-spacing"); 
  304.  
  305.    pragma Import (C, Get_Type, "gtk_scrolled_window_get_type"); 
  306. end Gtk.Scrolled_Window;