/*
* FX Editor Window Class
* @version 7-11-06
* @author Joseph 'Pcjoe' Florencio
*/

#pragma warning (disable:4786)
#pragma warning (disable:4530)

#ifndef FXEDITORWINDOW_H
#define FXEDITORWINDOW_H
#include <VGUI_Panel.h>
#include <VGUI_TablePanel.h>
#include <VGUI_HeaderPanel.h>
#include <VGUI_TextGrid.h>
#include <VGUI_Label.h>
#include <string>
#include <map>
using namespace std;

/*
* Image Panel Class, Customized for windows label
*/
class CManagedWindow;
class CImagePanelCustomW : public CImagePanel
{
public:
	/*
	* Constructors
	*/
	CImagePanelCustomW( string strImage, TILE_DIR tile_dir=PANELTILE_NONE, int x=0, int y=0, int wide=0, int tall=0 )
		: CImagePanel( strImage, tile_dir,x,y,wide,tall ), m_pWindow(NULL) { }
	CImagePanelCustomW( Image *pImage, TILE_DIR tile_dir=PANELTILE_NONE, int x=0, int y=0, int wide=0, int tall=0 )
		: CImagePanel( pImage, tile_dir,x,y,wide,tall ) { }

	// Paint
	virtual void paint();

	/*
	* Accessors/Mutators
	*/
	void setWindow( CManagedWindow *pWindow ) { m_pWindow = pWindow; }
	CManagedWindow *getWindow( void ) { return m_pWindow; }
protected:
	CManagedWindow *m_pWindow;
};

/*
* Window Drag Input Signal
*/
class CHandler_WindowDrag : public InputSignal
{
public:
	void mousePressed(MouseCode code,Panel* panel);
	void mouseReleased(MouseCode code,Panel* panel);

	void cursorEntered(Panel *panel) { }
	void cursorExited(Panel* panel) { }
	void cursorMoved(int x,int y,Panel* panel) {};
	void mouseDoublePressed(MouseCode code,Panel* panel) {};
	void mouseWheeled(int delta,Panel* panel) {};
	void keyPressed(KeyCode code,Panel* panel) {};
	void keyTyped(KeyCode code,Panel* panel) {};
	void keyReleased(KeyCode code,Panel* panel) {};
	void keyFocusTicked(Panel* panel) {};
};

/*
* Window Minimize Input Signal
*/
class CHandler_WindowMinimize : public InputSignal
{
public:
	void mouseReleased(MouseCode code,Panel* panel);

	void mousePressed(MouseCode code,Panel* panel) {}
	void cursorEntered(Panel *panel) { }
	void cursorExited(Panel* panel) { }
	void cursorMoved(int x,int y,Panel* panel) {};
	void mouseDoublePressed(MouseCode code,Panel* panel) {};
	void mouseWheeled(int delta,Panel* panel) {};
	void keyPressed(KeyCode code,Panel* panel) {};
	void keyTyped(KeyCode code,Panel* panel) {};
	void keyReleased(KeyCode code,Panel* panel) {};
	void keyFocusTicked(Panel* panel) {};
};

/*
* Window Close Input Signal
*/
class CHandler_WindowClose : public InputSignal
{
public:
	void mouseReleased(MouseCode code,Panel* panel);

	void mousePressed(MouseCode code,Panel* panel) {}
	void cursorEntered(Panel *panel) { }
	void cursorExited(Panel* panel) { }
	void cursorMoved(int x,int y,Panel* panel) {};
	void mouseDoublePressed(MouseCode code,Panel* panel) {};
	void mouseWheeled(int delta,Panel* panel) {};
	void keyPressed(KeyCode code,Panel* panel) {};
	void keyTyped(KeyCode code,Panel* panel) {};
	void keyReleased(KeyCode code,Panel* panel) {};
	void keyFocusTicked(Panel* panel) {};
};


/*
* Managed Window Class
*/
class CWindowTab;
class CManagedWindow : public CTransparentPanel
{
	friend CWindowTab;
public:
	/*
	* Constructor
	*/
	CManagedWindow(int x, int y, int wide, int tall, string title="", bool exitEnabled=true, bool minEnabled=true);

	// Resize to content panel
	virtual void resizeToContent( void );

	// Resize content panel to fit in window
	virtual void resizeContentToWindow( void );

	// HACK HACK: Paint background used as a 'think' function for dragging
	virtual void paintBackground( void );

	// Enable Drag
	virtual void enableDrag( void );

	// Disable Drag
	virtual void disableDrag( void );

	// Keep on Screen (Push back to on screen if panel lies outside of screen bounds)
	virtual void keepOnScreen( void );

	// Is Minimized
	virtual bool isMinimized( void );

	// Minimize
	virtual void minimize( void );

	// Maximize
	virtual void maximize( void );

	// To front (pushes the child to the front)
	virtual void toFront( void );

	// Close cleanup
	virtual void close( void );

	/*
	* Accessors/Mutators
	*/
	void setTitleBar( CImagePanelCustomW *pIP ) { m_pTitleBar = pIP; }
	CImagePanelCustomW *getTitleBar( void ) { return m_pTitleBar; }

	void setTitleLabel( TextImage *pTI ) { m_pTitleLabel = pTI; }
	TextImage *getTitleLabel( void ) { return m_pTitleLabel; }

	void setExitButton( CFadeImageButton *pBtn ) { m_pExitBtn = pBtn; }
	CFadeImageButton *getExitButton ( void ) { return m_pExitBtn; }

	void setMinimizeButton( CFadeImageButton *pBtn ) { m_pMinimizeBtn = pBtn; }
	CFadeImageButton *getMinimizeButton ( void ) { return m_pMinimizeBtn; }

	void setContentPanel( CTransparentPanel *pPanel ) { m_pContentPanel = pPanel; }
	CTransparentPanel *getContentPanel( void ) { return m_pContentPanel; }

	void setDragged( bool dragged ) { m_bDragged = dragged; }
	bool getDragged( void ) { return m_bDragged; }

	void setDraggedStart( Vector2D vec ) { m_vecDraggedStart = vec; }
	Vector2D getDraggedStart( void ) { return m_vecDraggedStart; }

protected:
	CImagePanelCustomW *m_pTitleBar;
	TextImage *m_pTitleLabel;
	CFadeImageButton *m_pExitBtn;
	CFadeImageButton *m_pMinimizeBtn;
	CTransparentPanel *m_pContentPanel;
	bool m_bDragged;
	Vector2D m_vecDraggedStart;
};

#endif