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