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. --  Gtk.Theming_Engine.Gtk_Theming_Engine is the object used for rendering 
  26. --  themed content in GTK+ widgets. Even though GTK+ has a default 
  27. --  implementation, it can be overridden in CSS files by enforcing a 
  28. --  Gtk.Theming_Engine.Gtk_Theming_Engine object to be loaded as a module. 
  29. -- 
  30. --  In order to implement a theming engine, a 
  31. --  Gtk.Theming_Engine.Gtk_Theming_Engine subclass must be created, alongside 
  32. --  the CSS file that will reference it, the theming engine would be created as 
  33. --  an .so library, and installed in $(gtk-modules-dir)/theming-engines/. 
  34. -- 
  35. --  Gtk.Theming_Engine.Gtk_Theming_Engine<!-- -->s have limited access to the 
  36. --  object they are rendering, the Gtk.Theming_Engine.Gtk_Theming_Engine API 
  37. --  has read-only accessors to the style information contained in the rendered 
  38. --  object's Gtk.Style_Context.Gtk_Style_Context. 
  39. -- 
  40. --  </description> 
  41. pragma Ada_2005; 
  42.  
  43. pragma Warnings (Off, "*is already use-visible*"); 
  44. with Gdk.RGBA;        use Gdk.RGBA; 
  45. with Gdk.Screen;      use Gdk.Screen; 
  46. with Glib;            use Glib; 
  47. with Glib.Object;     use Glib.Object; 
  48. with Glib.Properties; use Glib.Properties; 
  49. with Glib.Values;     use Glib.Values; 
  50. with Gtk.Enums;       use Gtk.Enums; 
  51. with Gtk.Style;       use Gtk.Style; 
  52. with Gtk.Widget;      use Gtk.Widget; 
  53. with Pango.Font;      use Pango.Font; 
  54.  
  55. package Gtk.Theming_Engine is 
  56.  
  57.    type Gtk_Theming_Engine_Record is new GObject_Record with null record; 
  58.    type Gtk_Theming_Engine is access all Gtk_Theming_Engine_Record'Class; 
  59.  
  60.    ------------------ 
  61.    -- Constructors -- 
  62.    ------------------ 
  63.  
  64.    function Get_Type return Glib.GType; 
  65.    pragma Import (C, Get_Type, "gtk_theming_engine_get_type"); 
  66.  
  67.    ------------- 
  68.    -- Methods -- 
  69.    ------------- 
  70.  
  71.    procedure Get_Background_Color 
  72.       (Self  : not null access Gtk_Theming_Engine_Record; 
  73.        State : Gtk.Enums.Gtk_State_Flags; 
  74.        Color : out Gdk.RGBA.Gdk_RGBA); 
  75.    --  Gets the background color for a given state. 
  76.    --  Since: gtk+ 3.0 
  77.    --  "state": state to retrieve the color for 
  78.    --  "color": return value for the background color 
  79.  
  80.    procedure Get_Border 
  81.       (Self   : not null access Gtk_Theming_Engine_Record; 
  82.        State  : Gtk.Enums.Gtk_State_Flags; 
  83.        Border : out Gtk.Style.Gtk_Border); 
  84.    --  Gets the border for a given state as a Gtk.Style.Gtk_Border. 
  85.    --  Since: gtk+ 3.0 
  86.    --  "state": state to retrieve the border for 
  87.    --  "border": return value for the border settings 
  88.  
  89.    procedure Get_Border_Color 
  90.       (Self  : not null access Gtk_Theming_Engine_Record; 
  91.        State : Gtk.Enums.Gtk_State_Flags; 
  92.        Color : out Gdk.RGBA.Gdk_RGBA); 
  93.    --  Gets the border color for a given state. 
  94.    --  Since: gtk+ 3.0 
  95.    --  "state": state to retrieve the color for 
  96.    --  "color": return value for the border color 
  97.  
  98.    procedure Get_Color 
  99.       (Self  : not null access Gtk_Theming_Engine_Record; 
  100.        State : Gtk.Enums.Gtk_State_Flags; 
  101.        Color : out Gdk.RGBA.Gdk_RGBA); 
  102.    --  Gets the foreground color for a given state. 
  103.    --  Since: gtk+ 3.0 
  104.    --  "state": state to retrieve the color for 
  105.    --  "color": return value for the foreground color 
  106.  
  107.    function Get_Direction 
  108.       (Self : not null access Gtk_Theming_Engine_Record) 
  109.        return Gtk.Enums.Gtk_Text_Direction; 
  110.    pragma Obsolescent (Get_Direction); 
  111.    --  Returns the widget direction used for rendering. 
  112.    --  Since: gtk+ 3.0 
  113.    --  Deprecated since 3.8, Use Gtk.Theming_Engine.Get_State and check for 
  114.    --  GTK_STATE_FLAG_DIR_LTR and GTK_STATE_FLAG_DIR_RTL instead. 
  115.  
  116.    function Get_Font 
  117.       (Self  : not null access Gtk_Theming_Engine_Record; 
  118.        State : Gtk.Enums.Gtk_State_Flags) 
  119.        return Pango.Font.Pango_Font_Description; 
  120.    pragma Obsolescent (Get_Font); 
  121.    --  Returns the font description for a given state. 
  122.    --  Since: gtk+ 3.0 
  123.    --  Deprecated since 3.8, Use gtk_theming_engine_get 
  124.    --  "state": state to retrieve the font for 
  125.  
  126.    function Get_Junction_Sides 
  127.       (Self : not null access Gtk_Theming_Engine_Record) 
  128.        return Gtk.Enums.Gtk_Junction_Sides; 
  129.    --  Returns the widget direction used for rendering. 
  130.    --  Since: gtk+ 3.0 
  131.  
  132.    procedure Get_Margin 
  133.       (Self   : not null access Gtk_Theming_Engine_Record; 
  134.        State  : Gtk.Enums.Gtk_State_Flags; 
  135.        Margin : out Gtk.Style.Gtk_Border); 
  136.    --  Gets the margin for a given state as a Gtk.Style.Gtk_Border. 
  137.    --  Since: gtk+ 3.0 
  138.    --  "state": state to retrieve the border for 
  139.    --  "margin": return value for the margin settings 
  140.  
  141.    procedure Get_Padding 
  142.       (Self    : not null access Gtk_Theming_Engine_Record; 
  143.        State   : Gtk.Enums.Gtk_State_Flags; 
  144.        Padding : out Gtk.Style.Gtk_Border); 
  145.    --  Gets the padding for a given state as a Gtk.Style.Gtk_Border. 
  146.    --  Since: gtk+ 3.0 
  147.    --  "state": state to retrieve the padding for 
  148.    --  "padding": return value for the padding settings 
  149.  
  150.    function Get_Path 
  151.       (Self : not null access Gtk_Theming_Engine_Record) 
  152.        return Gtk.Widget.Gtk_Widget_Path; 
  153.    --  Returns the widget path used for style matching. 
  154.    --  Since: gtk+ 3.0 
  155.  
  156.    procedure Get_Property 
  157.       (Self     : not null access Gtk_Theming_Engine_Record; 
  158.        Property : UTF8_String; 
  159.        State    : Gtk.Enums.Gtk_State_Flags; 
  160.        Value    : out Glib.Values.GValue); 
  161.    --  Gets a property value as retrieved from the style settings that apply 
  162.    --  to the currently rendered element. 
  163.    --  Since: gtk+ 3.0 
  164.    --  "property": the property name 
  165.    --  "state": state to retrieve the value for 
  166.    --  "value": return location for the property value, you must free this 
  167.    --  memory using g_value_unset once you are done with it. 
  168.  
  169.    function Get_Screen 
  170.       (Self : not null access Gtk_Theming_Engine_Record) 
  171.        return Gdk.Screen.Gdk_Screen; 
  172.    --  Returns the Gdk.Screen.Gdk_Screen to which Engine currently rendering 
  173.    --  to. 
  174.  
  175.    function Get_State 
  176.       (Self : not null access Gtk_Theming_Engine_Record) 
  177.        return Gtk.Enums.Gtk_State_Flags; 
  178.    --  returns the state used when rendering. 
  179.    --  Since: gtk+ 3.0 
  180.  
  181.    procedure Get_Style_Property 
  182.       (Self          : not null access Gtk_Theming_Engine_Record; 
  183.        Property_Name : UTF8_String; 
  184.        Value         : in out Glib.Values.GValue); 
  185.    --  Gets the value for a widget style property. 
  186.    --  Since: gtk+ 3.0 
  187.    --  "property_name": the name of the widget style property 
  188.    --  "value": Return location for the property value, free with 
  189.    --  g_value_unset after use. 
  190.  
  191.    function Has_Class 
  192.       (Self        : not null access Gtk_Theming_Engine_Record; 
  193.        Style_Class : UTF8_String) return Boolean; 
  194.    --  Returns True if the currently rendered contents have defined the given 
  195.    --  class name. 
  196.    --  Since: gtk+ 3.0 
  197.    --  "style_class": class name to look up 
  198.  
  199.    function Has_Region 
  200.       (Self         : not null access Gtk_Theming_Engine_Record; 
  201.        Style_Region : UTF8_String; 
  202.        Flags        : access Gtk.Enums.Gtk_Region_Flags) return Boolean; 
  203.    --  Returns True if the currently rendered contents have the region 
  204.    --  defined. If Flags_Return is not null, it is set to the flags affecting 
  205.    --  the region. 
  206.    --  Since: gtk+ 3.0 
  207.    --  "style_region": a region name 
  208.    --  "flags": return location for region flags 
  209.  
  210.    function Lookup_Color 
  211.       (Self       : not null access Gtk_Theming_Engine_Record; 
  212.        Color_Name : UTF8_String; 
  213.        Color      : access Gdk.RGBA.Gdk_RGBA) return Boolean; 
  214.    --  Looks up and resolves a color name in the current style's color map. 
  215.    --  "color_name": color name to lookup 
  216.    --  "color": Return location for the looked up color 
  217.  
  218.    function State_Is_Running 
  219.       (Self     : not null access Gtk_Theming_Engine_Record; 
  220.        State    : Gtk.Enums.Gtk_State_Type; 
  221.        Progress : access Gdouble) return Boolean; 
  222.    pragma Obsolescent (State_Is_Running); 
  223.    --  Returns True if there is a transition animation running for the current 
  224.    --  region (see Gtk.Style_Context.Push_Animatable_Region). 
  225.    --  If Progress is not null, the animation progress will be returned there, 
  226.    --  0.0 means the state is closest to being False, while 1.0 means it's 
  227.    --  closest to being True. This means transition animations will run from 0 
  228.    --  to 1 when State is being set to True and from 1 to 0 when it's being set 
  229.    --  to False. 
  230.    --  Since: gtk+ 3.0 
  231.    --  Deprecated since 3.6, Always returns False 
  232.    --  "state": a widget state 
  233.    --  "progress": return location for the transition progress 
  234.  
  235.    --------------- 
  236.    -- Functions -- 
  237.    --------------- 
  238.  
  239.    function Load (Name : UTF8_String) return Gtk_Theming_Engine; 
  240.    --  Loads and initializes a theming engine module from the standard 
  241.    --  directories. 
  242.    --  "name": Theme engine name to load 
  243.  
  244.    ---------------- 
  245.    -- Properties -- 
  246.    ---------------- 
  247.    --  The following properties are defined for this widget. See 
  248.    --  Glib.Properties for more information on properties) 
  249.  
  250.    Name_Property : constant Glib.Properties.Property_String; 
  251.    --  The theming engine name, this name will be used when registering custom 
  252.    --  properties, for a theming engine named "Clearlooks" registering a 
  253.    --  "glossy" custom property, it could be referenced in the CSS file as 
  254.    -- 
  255.    --    -Clearlooks-glossy: true; 
  256.  
  257. private 
  258.    Name_Property : constant Glib.Properties.Property_String := 
  259.      Glib.Properties.Build ("name"); 
  260. end Gtk.Theming_Engine;