#ifndef BUTTONBAR_H_INCLUDED
#define BUTTONBAR_H__INCLUDED

#include <xsi_toolcontext.h>
#ifndef linux
#define WIN32_LEAN_AND_MEAN
#include <windows.h> // Needed for OpenGL on windows
#endif

#include <stdarg.h>
#include <string.h>
#include <time.h>
#include <vector>

#include "ToolButtonBarButton.h"
#include "ogl_primitives.h"

using namespace XSI; 
using namespace std;

////////////////////////////////////////////////////////////////////////////////
//
// Pie Menu class
//
////////////////////////////////////////////////////////////////////////////////

class ButtonBar {
public:
	struct		spoint { LONG x,y;};

	ButtonBar();
	~ButtonBar();
	void		Setup( LONG in_prevButtoncount, LONG in_totalButtonCount,CString in_folderpath, CString in_pluginPath, bool in_enum, CStringArray in_buttonNames,bool l_drawOutline = true );
	void		Cleanup();
	void		SetSelection(ToolContext &in_ctxt, LONG mousex,LONG mousey);
	void		SetSelection(LONG in_index); 
	void		SetSelected(LONG in_index, bool in_flag) { if (in_index < m_buttonCount) m_buttons[in_index].SetSelected(in_flag);};
	LONG		GetSelectionIndex() {return m_selectedIndex;}
	void		Draw( ToolContext &in_ctxt );
	bool		IsPointInside( ToolContext &in_ctxt, LONG x, LONG y, LONG &out_index ) const;
	bool		IsSelected(LONG in_index) { if (in_index < m_buttonCount) return m_buttons[in_index].IsSelected(); else return false;};

private: // Implementation
	void	AddButtons(CStringArray in_buttonNames);
	void	CleanButtonSelectionData(bool setflag);
private: // Data
	CString			m_folderpath;	//button graphics
	CString			m_pluginPath;	

	LONG			m_buttonCount;		// Total number of buttons in this button bar
	LONG			m_buttonTotalCount;	// total number of buttons in the line, used for positioning
	LONG			m_prevButtonCount;	/* no of buttons before this bar*/
	LONG			m_selectedIndex;
	bool			m_enum;				//true if only 1 button can be active at a time
	bool			m_drawOutline;
	vector<ToolButtonBarButton> m_buttons;
};

#endif // BUTTONBAR_H_ INCLUDED
