#ifndef FGUI_WIDGET_HEADER
#define FGUI_WIDGET_HEADER




#include <flare_gui/collision_area.h>
#include <allegro_flare/data_attr.h>
#include <allegro_flare/clipboard_win.h> // this should eventually be replaced with a cross-platform clipboard solution



class FGUIParent;
class FGUIScreen;
class MotionManager;
class FontBin;

class FGUIWidget : public DataAttr
{
private:
	static int num_active_widgets;

protected:

	friend class FGUIParent;
	friend class FGUIScreen;
	FGUIParent *parent;
	bool mouse_over, mouse_down_on_over, focused, dragging; // should implement a flag system instead ;)

	// widget *developer* functions:
	virtual void draw_func();
	virtual void primary_timer_func();
	virtual void mouse_axes_func(float x, float y, float dx, float dy);
	virtual void mouse_down_func();
	virtual void mouse_up_func();
	virtual void key_down_func();
	virtual void key_up_func();
	virtual void key_char_func();

public:
	FGUICollisionArea *collision_area;
	FGUIWidget(FGUIParent *parent, FGUICollisionArea *collision_area);
	~FGUIWidget();



	// convience
	placement2d *gimmie_placement();
	FGUIWidget *gimmie_super_parent();
	FGUIScreen *gimmie_super_screen();
	MotionManager *gimmie_motion();
	FontBin *gimmie_fonts();


	// ordering
	void bring_to_front();
	void send_message_to_parent(std::string message);


	// retrieval
	bool is_focused();
	void set_as_focused();
	void set_as_unfocused(); // should be renamed to blur()?


	// widget *user* functions:
	virtual void on_focus();
	virtual void on_blur();

	virtual void on_mouse_enter();
	virtual void on_mouse_leave();
	virtual void on_mouse_move(float x, float y, float dx, float dy);
	virtual void on_mouse_down();
	virtual void on_mouse_up();
	virtual void on_click();
	virtual void on_drag(float x, float y, float dx, float dy);
	virtual void on_drop();

	virtual void on_key_down();
	virtual void on_key_up();
	virtual void on_key_char();

	virtual void on_timer();
	virtual void on_draw();


	static int get_num_active_widgets();
};





#endif