#ifndef __BLOP_ARROW_H__
#define __BLOP_ARROW_H__

#include "grob.h"
#include "length.h"
#include "color.h"

namespace blop
{
    class container;

    class arrow : public grob
    {
    private:
	length from_x_, from_y_, to_x_, to_y_;
	length head_length_, head_width_,linewidth_;
	double head_angle_;
	color  color_;

    public:

	// =-=-=-  Constructor: color=black, linewidth=LW =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

	arrow();


	// =-=-=- Set the beginning and enpoints =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

	arrow &from(const length &x, const length &y) {from_x_ = x; from_y_ = y; return *this;}
	arrow &to  (const length &x, const length &y) {to_x_ = x; to_y_ = y; return *this;}


	// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
	// Read the beginning and endpoints

	const length &from_x() const { return from_x_; }
	const length &from_y() const { return from_y_; }
	const length &to_x()   const { return to_x_;   }
	const length &to_y()   const { return to_y_;   }


	// =-=-=- Static functions, creating a new arrow, and adding it =-=-=-=-=-=-=-=-=-=-=-=-
	// to the current frame, pad or canvas, respectively, from (x1,y1) to (x2,y2)
	// the 4th function, 'draw' accepts one more parameter (the first), which specifies
	// the container, into which the arrow should be added (the 'fdraw', 'pdraw' and 'cdraw'
	// functions call this function with frame::current(), pad::current() and canvas::current()
	// as the first argument) (see design-concepts.html#mknew )

	static arrow &fdraw(const length &x1, const length &y1, const length &x2, const length &y2);
	static arrow &pdraw(const length &x1, const length &y1, const length &x2, const length &y2);
	static arrow &cdraw(const length &x1, const length &y1, const length &x2, const length &y2);
	static arrow &draw (container *parent,
			    const length &x1, const length &y1, const length &x2, const length &y2);



	// =-=-=- Set or read the linewidth =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

	arrow &linewidth(const length &l)   { linewidth_ = l; return *this; }
	arrow &lw(const length &l)          { return linewidth(l); }
	const length &linewidth() const     { return linewidth_; }


	// =-=-=- Set or read the headangle =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

	arrow &headangle(double d);
	arrow &ha(double d) {return headangle(d); }
	double headangle() const {return head_angle_; }


	// =-=-=- Set or read the headlength -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

	arrow &headlength(const length &l) { head_length_ = l; return *this;}
	arrow &hl(const length &l) {return headlength(l);}
	const length &headlength() const {return head_length_; }


	void prepare_for_draw();
	void print(terminal *);
    };
}


#endif