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