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. --  A Gtk.Style.Gtk_Style object encapsulates the information that provides 
  26. --  the look and feel for a widget. 
  27. -- 
  28. --  <warning> In GTK+ 3.0, GtkStyle has been deprecated and replaced by 
  29. --  Gtk.Style_Context.Gtk_Style_Context. </warning> 
  30. --  Each Gtk.Widget.Gtk_Widget has an associated Gtk.Style.Gtk_Style object 
  31. --  that is used when rendering that widget. Also, a Gtk.Style.Gtk_Style holds 
  32. --  information for the five possible widget states though not every widget 
  33. --  supports all five states; see Gtk.Enums.Gtk_State_Type. 
  34. -- 
  35. --  Usually the Gtk.Style.Gtk_Style for a widget is the same as the default 
  36. --  style that is set by GTK+ and modified the theme engine. 
  37. -- 
  38. --  Usually applications should not need to use or modify the 
  39. --  Gtk.Style.Gtk_Style of their widgets. 
  40. -- 
  41. --  </description> 
  42. pragma Ada_2005; 
  43.  
  44. pragma Warnings (Off, "*is already use-visible*"); 
  45. with Cairo;           use Cairo; 
  46. with Gdk;             use Gdk; 
  47. with Gdk.Color;       use Gdk.Color; 
  48. with Glib;            use Glib; 
  49. with Glib.Object;     use Glib.Object; 
  50. with Glib.Properties; use Glib.Properties; 
  51. with Glib.Values;     use Glib.Values; 
  52. with Gtk.Enums;       use Gtk.Enums; 
  53.  
  54. package Gtk.Style is 
  55.  
  56.    type Gtk_Style_Record is new GObject_Record with null record; 
  57.    type Gtk_Style is access all Gtk_Style_Record'Class; 
  58.  
  59.    type Gtk_Border is record 
  60.       Left : Gint16; 
  61.       Right : Gint16; 
  62.       Top : Gint16; 
  63.       Bottom : Gint16; 
  64.    end record; 
  65.    pragma Convention (C, Gtk_Border); 
  66.  
  67.    function From_Object_Free (B : access Gtk_Border) return Gtk_Border; 
  68.    pragma Inline (From_Object_Free); 
  69.    --  A struct that specifies a border around a rectangular area that can be 
  70.    --  of different width on each side. 
  71.  
  72.    ------------------ 
  73.    -- Constructors -- 
  74.    ------------------ 
  75.  
  76.    procedure Gtk_New (Style : out Gtk_Style); 
  77.    procedure Initialize (Style : not null access Gtk_Style_Record'Class); 
  78.    --  Creates a new Gtk.Style.Gtk_Style. 
  79.  
  80.    function Gtk_Style_New return Gtk_Style; 
  81.    --  Creates a new Gtk.Style.Gtk_Style. 
  82.  
  83.    function Get_Type return Glib.GType; 
  84.    pragma Import (C, Get_Type, "gtk_style_get_type"); 
  85.  
  86.    procedure Gtk_New (Self : out Gtk_Border); 
  87.    --  Allocates a new Gtk.Style.Gtk_Border structure and initializes its 
  88.    --  elements to zero. 
  89.    --  Since: gtk+ 2.14 
  90.  
  91.    function Gtk_Border_New return Gtk_Border; 
  92.    --  Allocates a new Gtk.Style.Gtk_Border structure and initializes its 
  93.    --  elements to zero. 
  94.    --  Since: gtk+ 2.14 
  95.  
  96.    function Border_Get_Type return Glib.GType; 
  97.    pragma Import (C, Border_Get_Type, "gtk_border_get_type"); 
  98.  
  99.    ------------- 
  100.    -- Methods -- 
  101.    ------------- 
  102.  
  103.    procedure Apply_Default_Background 
  104.       (Style      : not null access Gtk_Style_Record; 
  105.        Cr         : Cairo.Cairo_Context; 
  106.        Window     : Gdk.Gdk_Window; 
  107.        State_Type : Gtk.Enums.Gtk_State_Type; 
  108.        X          : Gint; 
  109.        Y          : Gint; 
  110.        Width      : Gint; 
  111.        Height     : Gint); 
  112.    pragma Obsolescent (Apply_Default_Background); 
  113.    --  Deprecated since 3.0, Use Gtk.Style_Context.Gtk_Style_Context instead 
  114.  
  115.    function Attach 
  116.       (Style  : not null access Gtk_Style_Record; 
  117.        Window : Gdk.Gdk_Window) return Gtk_Style; 
  118.    pragma Obsolescent (Attach); 
  119.    --  Attaches a style to a window; this process allocates the colors and 
  120.    --  creates the GC's for the style - it specializes it to a particular 
  121.    --  visual. The process may involve the creation of a new style if the style 
  122.    --  has already been attached to a window with a different style and visual. 
  123.    --  Since this function may return a new object, you have to use it in the 
  124.    --  following way: 'style = gtk_style_attach (style, window)' 
  125.    --  Deprecated since 3.0, Use Gtk.Widget.Style_Attach instead 
  126.    --  "window": a Gdk.Gdk_Window. 
  127.  
  128.    function Copy (Style : not null access Gtk_Style_Record) return Gtk_Style; 
  129.    pragma Obsolescent (Copy); 
  130.    --  Creates a copy of the passed in Gtk.Style.Gtk_Style object. 
  131.    --  Deprecated since 3.0, Use Gtk.Style_Context.Gtk_Style_Context instead 
  132.  
  133.    procedure Detach (Style : not null access Gtk_Style_Record); 
  134.    pragma Obsolescent (Detach); 
  135.    --  Detaches a style from a window. If the style is not attached to any 
  136.    --  windows anymore, it is unrealized. See Gtk.Style.Attach. 
  137.    --  Deprecated since 3.0, Use Gtk.Style_Context.Gtk_Style_Context instead 
  138.  
  139.    procedure Get_Style_Property 
  140.       (Style         : not null access Gtk_Style_Record; 
  141.        Widget_Type   : GType; 
  142.        Property_Name : UTF8_String; 
  143.        Value         : in out Glib.Values.GValue); 
  144.    --  Queries the value of a style property corresponding to a widget class 
  145.    --  is in the given style. 
  146.    --  Since: gtk+ 2.16 
  147.    --  "widget_type": the GType of a descendant of Gtk.Widget.Gtk_Widget 
  148.    --  "property_name": the name of the style property to get 
  149.    --  "value": a Glib.Values.GValue where the value of the property being 
  150.    --  queried will be stored 
  151.  
  152.    function Has_Context 
  153.       (Style : not null access Gtk_Style_Record) return Boolean; 
  154.    --  Returns whether Style has an associated 
  155.    --  Gtk.Style_Context.Gtk_Style_Context. 
  156.    --  Since: gtk+ 3.0 
  157.  
  158.    procedure Lookup_Color 
  159.       (Style      : not null access Gtk_Style_Record; 
  160.        Color_Name : UTF8_String; 
  161.        Color      : out Gdk.Color.Gdk_Color; 
  162.        Found      : out Boolean); 
  163.    pragma Obsolescent (Lookup_Color); 
  164.    --  Looks up Color_Name in the style's logical color mappings, filling in 
  165.    --  Color and returning True if found, otherwise returning False. Do not 
  166.    --  cache the found mapping, because it depends on the Gtk.Style.Gtk_Style 
  167.    --  and might change when a theme switch occurs. 
  168.    --  Since: gtk+ 2.10 
  169.    --  Deprecated since 3.0, Use Gtk.Style_Context.Lookup_Color instead 
  170.    --  "color_name": the name of the logical color to look up 
  171.    --  "color": the Gdk.Color.Gdk_Color to fill in 
  172.  
  173.    procedure Set_Background 
  174.       (Style      : not null access Gtk_Style_Record; 
  175.        Window     : Gdk.Gdk_Window; 
  176.        State_Type : Gtk.Enums.Gtk_State_Type); 
  177.    pragma Obsolescent (Set_Background); 
  178.    --  Sets the background of Window to the background color or pixmap 
  179.    --  specified by Style for the given state. 
  180.    --  Deprecated since 3.0, Use Gtk.Style_Context.Set_Background instead 
  181.    --  "window": a Gdk.Gdk_Window 
  182.    --  "state_type": a state 
  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.    Context_Property : constant Glib.Properties.Property_Object; 
  191.    --  Type: Gtk.Style_Context.Gtk_Style_Context 
  192.  
  193.    ------------- 
  194.    -- Signals -- 
  195.    ------------- 
  196.  
  197.    type Cb_Gtk_Style_Void is not null access procedure (Self : access Gtk_Style_Record'Class); 
  198.  
  199.    type Cb_GObject_Void is not null access procedure 
  200.      (Self : access Glib.Object.GObject_Record'Class); 
  201.  
  202.    Signal_Realize : constant Glib.Signal_Name := "realize"; 
  203.    procedure On_Realize 
  204.       (Self  : not null access Gtk_Style_Record; 
  205.        Call  : Cb_Gtk_Style_Void; 
  206.        After : Boolean := False); 
  207.    procedure On_Realize 
  208.       (Self  : not null access Gtk_Style_Record; 
  209.        Call  : Cb_GObject_Void; 
  210.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  211.        After : Boolean := False); 
  212.    --  Emitted when the style has been initialized for a particular visual. 
  213.    --  Connecting to this signal is probably seldom useful since most of the 
  214.    --  time applications and widgets only deal with styles that have been 
  215.    --  already realized. 
  216.  
  217.    Signal_Unrealize : constant Glib.Signal_Name := "unrealize"; 
  218.    procedure On_Unrealize 
  219.       (Self  : not null access Gtk_Style_Record; 
  220.        Call  : Cb_Gtk_Style_Void; 
  221.        After : Boolean := False); 
  222.    procedure On_Unrealize 
  223.       (Self  : not null access Gtk_Style_Record; 
  224.        Call  : Cb_GObject_Void; 
  225.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  226.        After : Boolean := False); 
  227.    --  Emitted when the aspects of the style specific to a particular visual 
  228.    --  is being cleaned up. A connection to this signal can be useful if a 
  229.    --  widget wants to cache objects as object data on Gtk.Style.Gtk_Style. 
  230.    --  This signal provides a convenient place to free such cached objects. 
  231.  
  232. private 
  233.    Context_Property : constant Glib.Properties.Property_Object := 
  234.      Glib.Properties.Build ("context"); 
  235. end Gtk.Style;