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. --  This package provides support for drawing points, lines, arcs and text onto 
  32. --  what are called 'drawables'. Drawables, as the name suggests, are things 
  33. --  which support drawing onto them, and are either Gdk_Window or 
  34. --  Gdk_Pixmap objects. 
  35. -- 
  36. --  Many of the drawing operations take a Gdk_GC argument, which represents a 
  37. --  graphics context. This Gdk_GC contains a number of drawing attributes such 
  38. --  as foreground color, background color and line width, and is used to 
  39. --  reduce the number of arguments needed for each drawing operation. 
  40. --  See Gdk.GC for more information. 
  41. -- 
  42. --  </description> 
  43. --  <c_version>1.3.6</c_version> 
  44. --  <group>Gdk, the low-level API</group> 
  45.  
  46. with Glib; use Glib; 
  47. with Gdk.Types; 
  48. with Pango.Layout; 
  49.  
  50. package Gdk.Drawable is 
  51.  
  52.    subtype Gdk_Drawable is Gdk.Gdk_Drawable; 
  53.    --  A screen area that can be drawn upon. 
  54.  
  55.    Null_Drawable : constant Gdk_Drawable; 
  56.  
  57.    function Get_Type return Glib.GType; 
  58.    --  Return the internal value associated with a Gdk_Drawable. 
  59.  
  60.    procedure Get_Size 
  61.      (Drawable : Gdk_Drawable; 
  62.       Width    : out Gint; 
  63.       Height   : out Gint); 
  64.    --  Return the width and height of a given drawable. 
  65.  
  66.    procedure Set_Colormap 
  67.      (Drawable : Gdk_Drawable; Colormap : Gdk.Gdk_Colormap); 
  68.  
  69.    function Get_Colormap 
  70.      (Drawable : Gdk_Drawable) return Gdk.Gdk_Colormap; 
  71.  
  72.    function Get_Visual (Drawable : Gdk_Drawable) return Gdk.Gdk_Visual; 
  73.  
  74.    function Get_Depth (Drawable : Gdk_Drawable) return Gint; 
  75.  
  76.    procedure Ref (Drawable : Gdk_Drawable); 
  77.  
  78.    procedure Unref (Drawable : Gdk_Drawable); 
  79.  
  80.    procedure Draw_Point 
  81.      (Drawable : Gdk_Drawable; 
  82.       GC       : Gdk.Gdk_GC; 
  83.       X        : Gint; 
  84.       Y        : Gint); 
  85.    --  Draw a point, using the foreground color and other attributes of the Gc. 
  86.  
  87.    procedure Draw_Line 
  88.      (Drawable : Gdk_Drawable; 
  89.       GC       : Gdk.Gdk_GC; 
  90.       X1       : Gint; 
  91.       Y1       : Gint; 
  92.       X2       : Gint; 
  93.       Y2       : Gint); 
  94.    --  Draw a line, using the foreground color and other attributes of the Gc. 
  95.    --  (X1, Y1) is coordinate of the start point. 
  96.    --  (X2, Y2) is coordinate of the end point. 
  97.  
  98.    procedure Draw_Rectangle 
  99.      (Drawable : Gdk_Drawable; 
  100.       GC       : Gdk.Gdk_GC; 
  101.       Filled   : Boolean := False; 
  102.       X        : Gint; 
  103.       Y        : Gint; 
  104.       Width    : Gint; 
  105.       Height   : Gint); 
  106.    --  Draw a rectangular outline or filled rectangle. 
  107.    --  Note that a rectangle drawn filled is 1 pixel smaller in both dimensions 
  108.    --  than a rectangle outlined. Calling 
  109.    --  Draw_Rectangle (Window, Gc, True, 0, 0, 20, 20) results in a filled 
  110.    --  rectangle 20 pixels wide and 20 pixels high. Calling 
  111.    --  Draw_Rectangle (Window, Gc, False, 0, 0, 20, 20) results in an outlined 
  112.    --  rectangle with corners at (0, 0), (0, 20), (20, 20), and (20, 0), which 
  113.    --  makes it 21 pixels wide and 21 pixels high. 
  114.    -- 
  115.    --  (X, Y) represents the coordinate of the top-left edge of the rectangle. 
  116.  
  117.    procedure Draw_Arc 
  118.      (Drawable : Gdk_Drawable; 
  119.       GC       : Gdk.Gdk_GC; 
  120.       Filled   : Boolean := False; 
  121.       X        : Gint; 
  122.       Y        : Gint; 
  123.       Width    : Gint; 
  124.       Height   : Gint; 
  125.       Angle1   : Gint; 
  126.       Angle2   : Gint); 
  127.    --  Draws an arc or a filled 'pie slice'. 
  128.    --  The arc is defined by the bounding rectangle of the entire ellipse, and 
  129.    --  the start and end angles of the part of the ellipse to be drawn. 
  130.    --  Filled is True if the arc should be filled, producing a 'pie slice'. 
  131.    --  (X, Y) represent the coordinate of the top-left edge of the bounding 
  132.    --  rectangle. 
  133.    --  Angle1 is the start angle of the arc, relative to the 3 o'clock 
  134.    --  position, counter-clockwise, in 1/64ths of a degree. 
  135.    --  Angle2 is the end angle of the arc, relative to angle1, in 1/64ths of a 
  136.    --  degree. 
  137.  
  138.    procedure Draw_Polygon 
  139.      (Drawable : Gdk_Drawable; 
  140.       GC       : Gdk.Gdk_GC; 
  141.       Filled   : Boolean; 
  142.       Points   : Gdk.Types.Gdk_Points_Array); 
  143.    --  Draw an outlined or filled polygon. 
  144.    --  Filled is True if the polygon should be filled. The polygon is closed 
  145.    --  automatically, connecting the last point to the first point if 
  146.    --  necessary. 
  147.    --  Points is an array of Gdk_Point specifying the points making up the 
  148.    --  polygon. 
  149.  
  150.    procedure Draw_Text 
  151.      (Drawable    : Gdk_Drawable; 
  152.       Font        : Gdk.Gdk_Font; 
  153.       GC          : Gdk.Gdk_GC; 
  154.       X           : Gint; 
  155.       Y           : Gint; 
  156.       Text        : UTF8_String); 
  157.    --  Draw a string in the given font or fontset. 
  158.    --  X is the x coordinate of the left edge of the text. 
  159.    --  Y is the y coordinate of the baseline of the text. 
  160.    -- 
  161.    --  You should use Gtk.Widget.Create_Pango_Layout instead to handle 
  162.    --  internationalization. 
  163.  
  164.    procedure Draw_Text 
  165.      (Drawable    : Gdk_Drawable; 
  166.       Font        : Gdk.Gdk_Font; 
  167.       GC          : Gdk.Gdk_GC; 
  168.       X           : Gint; 
  169.       Y           : Gint; 
  170.       Wide_Text   : Gdk.Types.Gdk_WString); 
  171.    --  Draw a wide string in the given font of fontset. 
  172.    --  If the font is a 1-byte font, the string is converted into 1-byte 
  173.    --  characters (discarding the high bytes) before output. 
  174.  
  175.    procedure Draw_Drawable 
  176.      (Drawable : Gdk_Drawable; 
  177.       GC       : Gdk.Gdk_GC; 
  178.       Src      : Gdk_Drawable; 
  179.       Xsrc     : Gint; 
  180.       Ysrc     : Gint; 
  181.       Xdest    : Gint; 
  182.       Ydest    : Gint; 
  183.       Width    : Gint := -1; 
  184.       Height   : Gint := -1); 
  185.    --  Draw a pixmap, or a part of a pixmap, onto another drawable. 
  186.    --  Src is the source Gdk_Drawable to draw. 
  187.    --  Xsrc is the left edge of the source rectangle within Src. 
  188.    --  Ysrc is the top of the source rectangle within Src. 
  189.    --  Xdest is the x coordinate of the destination within Src. 
  190.    --  Ydest is the y coordinate of the destination within Src. 
  191.    --  Width is the width of the area to be copied, or -1 to make the area 
  192.    --  extend to the right edge of the source pixmap. 
  193.    --  Height is the height of the area to be copied, or -1 to make the area 
  194.    --  extend to the bottom edge of the source pixmap. 
  195.  
  196.    procedure Draw_Layout 
  197.      (Drawable : Gdk_Drawable; 
  198.       GC       : Gdk.Gdk_GC; 
  199.       X        : Gint; 
  200.       Y        : Gint; 
  201.       Layout   : Pango.Layout.Pango_Layout); 
  202.    --  Display the layout and its text in Drawable. This method should be 
  203.    --  preferred over Draw_Text. 
  204.  
  205.    procedure Draw_Pixmap 
  206.      (Drawable : Gdk_Drawable; 
  207.       GC       : Gdk.Gdk_GC; 
  208.       Src      : Gdk_Drawable; 
  209.       Xsrc     : Gint; 
  210.       Ysrc     : Gint; 
  211.       Xdest    : Gint; 
  212.       Ydest    : Gint; 
  213.       Width    : Gint := -1; 
  214.       Height   : Gint := -1) renames Draw_Drawable; 
  215.    --  Deprecated, use Draw_Drawable instead. 
  216.  
  217.    procedure Draw_Image 
  218.      (Drawable : Gdk_Drawable; 
  219.       GC       : Gdk.Gdk_GC; 
  220.       Image    : Gdk.Gdk_Image; 
  221.       Xsrc     : Gint; 
  222.       Ysrc     : Gint; 
  223.       Xdest    : Gint; 
  224.       Ydest    : Gint; 
  225.       Width    : Gint := -1; 
  226.       Height   : Gint := -1); 
  227.    --  Draw a Gdk_Image onto a Drawable. 
  228.    --  The depth of the Gdk_Image must match the depth of the Gdk_Drawable. 
  229.    --  Image is the Gdk_Image to draw. 
  230.    --  Xsrc is the left edge of the source rectangle within Image. 
  231.    --  Ysrc is the top of the source rectangle within Image. 
  232.    --  Xdest is the x coordinate of the destination within Drawable. 
  233.    --  Ydest is the y coordinate of the destination within Drawable. 
  234.    --  Width is the width of the area to be copied, or -1 to make the area 
  235.    --  extend to the right edge of image. 
  236.    --  Height is the height of the area to be copied, or -1 to make the area 
  237.    --  extend to the bottom edge of image. 
  238.  
  239.    procedure Draw_Points 
  240.      (Drawable : Gdk_Drawable; 
  241.       GC       : Gdk.Gdk_GC; 
  242.       Points   : Gdk.Types.Gdk_Points_Array); 
  243.    --  Draw a number of points. 
  244.    --  Use the foreground color and other attributes of the Gc. 
  245.  
  246.    procedure Draw_Segments 
  247.      (Drawable : in Gdk_Drawable; 
  248.       GC       : in Gdk.Gdk_GC; 
  249.       Segs     : in Gdk.Types.Gdk_Segments_Array); 
  250.    --  Draw a number of unconnected lines. 
  251.  
  252.    procedure Draw_Lines 
  253.      (Drawable : Gdk_Drawable; 
  254.       GC       : Gdk.Gdk_GC; 
  255.       Points   : Gdk.Types.Gdk_Points_Array); 
  256.    --  Draw a series of lines connecting the given points. 
  257.    --  The way in which joins between lines are drawn is determined by the 
  258.    --  Cap_Style value in the Gdk_GC. This can be set with 
  259.    --  Gdk.Gc.Set_Line_Attributes. 
  260.  
  261.    function Get_Image 
  262.      (Drawable : Gdk_Drawable; 
  263.       X        : Gint; 
  264.       Y        : Gint; 
  265.       Width    : Gint; 
  266.       Height   : Gint) return Gdk_Image; 
  267.  
  268.    function Get_Clip_Region (Drawable : Gdk_Drawable) return Gdk.Gdk_Region; 
  269.  
  270.    function Get_Visible_Region (Drawable : Gdk_Drawable) return Gdk.Gdk_Region; 
  271.  
  272. private 
  273.    Null_Drawable : constant Gdk_Drawable := null; 
  274.    pragma Import (C, Get_Type, "gdk_drawable_get_type"); 
  275.    pragma Import (C, Get_Depth, "gdk_drawable_get_depth"); 
  276.    pragma Import (C, Ref, "gdk_drawable_ref"); 
  277.    pragma Import (C, Unref, "gdk_drawable_unref"); 
  278.    pragma Import (C, Get_Size, "gdk_drawable_get_size"); 
  279.    pragma Import (C, Get_Colormap, "gdk_drawable_get_colormap"); 
  280.    pragma Import (C, Get_Visual, "gdk_drawable_get_visual"); 
  281.    pragma Import (C, Set_Colormap, "gdk_drawable_set_colormap"); 
  282.    pragma Import (C, Draw_Drawable, "gdk_draw_drawable"); 
  283.    pragma Import (C, Draw_Line, "gdk_draw_line"); 
  284.    pragma Import (C, Draw_Point, "gdk_draw_point"); 
  285.    pragma Import (C, Draw_Image, "gdk_draw_image"); 
  286.    pragma Import (C, Get_Image, "gdk_drawable_get_image"); 
  287.    pragma Import (C, Get_Clip_Region, "gdk_drawable_get_clip_region"); 
  288.    pragma Import (C, Get_Visible_Region, "gdk_drawable_get_visible_region"); 
  289. end Gdk.Drawable; 
  290.  
  291. --  <example> 
  292. --  <include>../examples/documentation/draw.adb</include> 
  293. --  </example> 
  294.  
  295. --  missing pango related functions: 
  296. --  gdk_draw_glyphs 
  297. --  gdk_draw_layout_line 
  298. --  gdk_draw_layout_line_with_colors 
  299. --  gdk_draw_layout_with_colors