package Claw.Draw is
    --
    -- CLAW - Class Library for Ada and Windows.
    --
    -- This package contains the Drawing actions.
    --
    -- Copyright 1996, 1997  R.R. Software, Inc.
    -- P.O. Box 1512, Madison WI  53701
    -- All rights reserved.
    --

    pragma Elaborate_Body; -- Insure that the body is elaborated before anyone
                           -- can call CLAW.

    -- Line drawing:

    function Get_Current_Position(Easel : Claw.Root_Canvas_Type'Class)
    return Point_Type;
        -- Returns the current position for the canvas object.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.

    procedure Set_Current_Position(Easel : in Claw.Root_Canvas_Type'Class;
                                   New_Pos : in Point_Type);
        -- Sets the current position for the canvas object.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.

    procedure Line_to(Easel : in Claw.Root_Canvas_Type'Class;
                      Pos  : in Point_Type);
        -- Draws a line from the current position to Pos with the
        -- current pen.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.

    procedure Angle_Arc (Canvas:	in Claw.Root_Canvas_Type'Class;
			 Center:	in Claw.Point_Type;
			 Radius:	in Natural;
			 Start_Angle,
			 Sweep_Angle:	in Float);
	--
	-- Draws a line segment and an arc. The line segment is drawn from
	-- the current position to the beginning of the arc. The arc is drawn
	-- along the perimeter of a circle with the given radius and center.
	-- The length of the arc is defined by the given start and sweep
	-- angles.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.
	--

    procedure Arc_To (Canvas:		in Claw.Root_Canvas_Type'Class;
		      Upper_Left,
		      Lower_Right,
		      Radial_1,
		      Radial_2:		in Claw.Point_Type);
	--
	-- Draws an elliptical arc.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.
	--

    type Arc_Direction_Type is (COUNTERCLOCKWISE, CLOCKWISE);
    for Arc_Direction_Type use (COUNTERCLOCKWISE => 1, CLOCKWISE => 2);
    for Arc_Direction_Type'Size use Int'Size;

    function Get_Arc_Direction (Canvas:	    in Claw.Root_Canvas_Type'Class)
			return Arc_Direction_Type;
	--
	-- Returns the current arc direction for the specified Canvas. Arc
	-- and rectangle functions use the arc direction.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.
	--

    procedure Poly_Bezier (Canvas:	in Claw.Root_Canvas_Type'Class;
			   Points:	in Claw.Point_List_Type);
	--
	-- Draws one or more Bezier curves.
	--
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.
	--

    procedure Poly_Bezier_To (Canvas:	in Claw.Root_Canvas_Type'Class;
			      Points:	in Claw.Point_List_Type);
	--
	-- Draws one or more Bezier curves.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.
	--

    type Poly_Draw_Id_Type is private;
    CLOSEFIGURE: constant Poly_Draw_Id_Type;
    LINETO     : constant Poly_Draw_Id_Type;
    BEZIERTO   : constant Poly_Draw_Id_Type;
    MOVETO     : constant Poly_Draw_Id_Type;

    type Poly_Draw_Id_List is array (Integer range <>) of aliased Poly_Draw_Id_Type;

    function "+" (Left, Right : in Poly_Draw_Id_Type) return Poly_Draw_Id_Type;

    function "-" (Left, Right : in Poly_Draw_Id_Type) return Poly_Draw_Id_Type;

    function ">=" (Left, Right : in Poly_Draw_Id_Type) return Boolean;
        -- Read  A >= B   as   A includes B
	-- I.e. each set style in B is also in A.

    procedure Poly_Draw (Canvas:	in Claw.Root_Canvas_Type'Class;
			 Points:	in Claw.Point_List_Type;
			 Identifiers:	in Poly_Draw_Id_List);
	--
	-- Draws a set of line segments and Bezier curves.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.
	--

    procedure Poly_Line (Canvas:	in Claw.Root_Canvas_Type'Class;
			 Endpoints:  	in Claw.Point_List_Type);
	--
	-- Draws a series of line segments by connecting the points in the
	-- specified array.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.
	--

    procedure Poly_Line_To (Canvas:	    in Claw.Root_Canvas_Type'Class;
			    Endpoints:	    in Claw.Point_List_Type);
	--
	-- Draws one or more straight lines.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.
	--

    type Polyline_Values is array (Integer range <>) of aliased Natural;

    procedure Poly_Polyline (Canvas:	    in Claw.Root_Canvas_Type'Class;
			     Points:	    in Claw.Point_List_Type;
			     Values:	    in Polyline_Values);
	--
	-- Draws multiple series of connected line segments.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.
	--

    procedure Set_Arc_Direction (Canvas:	in Claw.Root_Canvas_Type'Class;
    				 Arc_Direction:	in Arc_Direction_Type);
	--
	-- Sets the drawing direction to be used for arc and rectangle
	-- functions.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.
	--

    -- Object drawing routines:

    procedure Ellipse(Easel : in Claw.Root_Canvas_Type'Class;
                      Rect  : in Rectangle_Type);
        -- Draws an Ellipse inside of Rect with the current pen,
        -- and filling the interior with the current brush.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.

    procedure Arc    (Easel   : in Claw.Root_Canvas_Type'Class;
                      Rect    : in Rectangle_Type;
                      Start_P : in Point_Type;
                      End_P   : in Point_Type);
        -- Draws a Arc from Start to End, inside of Rect.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.

    procedure Chord  (Easel   : in Claw.Root_Canvas_Type'Class;
                      Rect    : in Rectangle_Type;
                      Start_P : in Point_Type;
                      End_P   : in Point_Type);
        -- Draws a Chord from Start to End, inside of Rect.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.

    procedure Pie    (Easel   : in Claw.Root_Canvas_Type'Class;
                      Rect    : in Rectangle_Type;
                      Start_P : in Point_Type;
                      End_P   : in Point_Type);
        -- Draws a Pie piece from Start to End, inside of Rect.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.

    procedure Rectangle (Easel : in Claw.Root_Canvas_Type'Class;
                         Rect  : in Rectangle_Type);
        -- Draws a rectangle in Rect with the current pen,
        -- and filling the interior with the current brush.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.

    procedure Round_Rectangle (Easel   : in Claw.Root_Canvas_Type'Class;
                               Rect    : in Rectangle_Type;
                               E_Size  : in Claw.Size_Type);
        -- Draws a rectangle in Rect with rounded corners,
        -- with the current pen, and filling the interior with
        -- the current brush.  E_Size determines how round the corners are;
	-- it specifies the size of ellipse used.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.

    procedure Polygon (Canvas:	    in Claw.Root_Canvas_Type'Class;
		       Vertices:    in Claw.Point_List_Type);
	--
	-- Draws a polygon consisting of two or more vertices connected by
	-- straight lines. The polygon is outlined by using the current pen
	-- and filled by using the current brush and polygon fill mode.
	-- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.
	--

    type Count_List_Type is array (Integer range <>) of Integer;
	--For passing in Poly_Counts below

    procedure Poly_Polygon (Canvas:	    in Claw.Root_Canvas_Type'Class;
			    Vertices:	    in Claw.Point_List_Type;
			    Poly_Counts:    in Count_List_Type);
	--
	-- Draws a series of closed polygons. Each polygon is outlined by
	-- using the current pen and filled by using the current brush and
	-- polygon fill mode. The polygons drawn by this function can overlap.
	-- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.
	--

    function Get_Polygon_Fill_Mode (Canvas:    in Claw.Root_Canvas_Type'Class) return Claw.Codes.Fill_Modes;
	--
	-- Grabs the current polygon fill mode.
	--
	-- Raises Windows_Error if there is a problem.
	--

    procedure Set_Polygon_Fill_Mode (Canvas:    in Claw.Root_Canvas_Type'Class;
				     Mode:      in Claw.Codes.Fill_Modes);
	--
	-- Sets the polygon fill mode for functions that fill polygons.
	--
	-- Raises Windows_Error if there is a problem.
	--

    procedure Focus_Rectangle (Easel : in Claw.Root_Canvas_Type'Class;
                               Rect  : in Rectangle_Type);
        -- Draws a rectangle in Rect with the appropriate style for a
	-- focus rectangle.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.
	-- Note: Focus rectangles are drawn with an XOR function, so they can
	-- be removed by calling this routine a second time.

    -- Text routines:

    procedure Put (Easel    : in Claw.Root_Canvas_Type'Class;
                   Position : in Point_Type;
                   Text     : in String);
        -- Writes the Text at the specified position.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.

    procedure Put (Easel    : in Claw.Root_Canvas_Type'Class;
                   Position : in Point_Type;
                   Text     : in String;
		   Clipping_Area : in Rectangle_Type;
		   Clip	    : in Boolean := False;
		   Opaque   : in Boolean := False);
        -- Writes the Text at the specified position.
	-- If Clip is true, clips the text to the specified rectangle.
	-- If Opaque is true, fills the rectangle with the background color.
        -- Raises:
        --      Not_Valid_Error if the canvas object is not valid.
        --      Windows_Error if Windows generates an error.

private

    type Poly_Draw_Id_Type is new Byte;
    for Poly_Draw_Id_Type'Size use 8;
    CLOSEFIGURE : constant Poly_Draw_Id_Type := 1;
    LINETO      : constant Poly_Draw_Id_Type := 2;
    BEZIERTO    : constant Poly_Draw_Id_Type := 4;
    MOVETO      : constant Poly_Draw_Id_Type := 6;

end Claw.Draw;