//..............................................................................
//
// Ninja GUI base declarations
//

namespace gui {

//..............................................................................

// colors

// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

bitflag enum ColorFlags
{
	Transparent  = 0x80000000,
	Index        = 0x40000000,
	IndexMask    = 0x0fffffff,
}

// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

enum StdColor
{
	Black        = 0x000000,
	White        = 0xffffff,
	Gray         = 0x808080,
	Red          = 0x800000,
	Green        = 0x008000,
	Blue         = 0x000080,
	Purple       = 0x800080,
	Cyan         = 0x008080,

	LightRed     = 0xff0000,
	LightGreen   = 0x00ff00,
	LightBlue    = 0x0000ff,
	LightPurple  = 0xff00ff,
	LightCyan    = 0x00ffff,

	PastelGray   = 0xefefef,
	PastelRed    = 0xffe4e1,
	PastelOrange = 0xfffacd,
	PastelYellow = 0xffffc0,
	PastelGreen  = 0xe1fada,
	PastelCyan   = 0xcdfaff,
	PastelBlue   = 0xe2edff,
	PastelPurple = 0xe2dafd,
}

uint_t rgb (
	uint8_t r,
	uint8_t g,
	uint8_t b
	)
{
	return (r << 16) + (g << 8) + b;
}

//..............................................................................

// text

// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

bitflag enum FontFlags
{
	Bold,
	Italic,
	Underline,
	Strikeout,

	Transparent,
}

// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

struct TextAttr
{
	uint_t m_textColor;
	uint_t m_backColor;
	FontFlags m_fontFlags;
}

//..............................................................................

// icons

opaque class Icon
{
	construct (char const* fileName);
}

//..............................................................................

// actions

opaque class Action
{
	construct (
		char const* text,
		Icon* icon = null
		);

	bool autoget property m_isVisible;
	bool autoget property m_isEnabled;
	bool autoget property m_isCheckable;
	bool autoget bindable property m_isChecked;

	char const* autoget property m_text;
	Icon* autoget property m_icon;

	event m_onTriggered ();
}

//..............................................................................

// combo box

opaque class ComboBox
{
	bool autoget property m_isVisible;
	bool autoget property m_isEnabled;
	bool autoget property m_isEditable;

	property m_editText
	{
		char const* autoget m_value;
		set (char const* value);
		bindable alias m_onPropChanged = m_onChanged;
	}

	char const* autoget property m_toolTipText;
	uint_t autoget property m_backgroundColor;

	destruct ();

	void adjustSizeToContents ();

	size_t addItem (
		char const* text,
		variant data = null
		)
	{
		return insertItem (-1, text, data);
	}

	size_t insertItem (
		size_t index,
		char const* text,
		variant data = null
		);

	bool removeItem (size_t index);
	void clear ();

	char const* property m_itemText (size_t index);
	variant property m_itemData (size_t index);

	size_t m_itemCount;

	property m_currentIndex
	{
		size_t autoget m_value;
		set (size_t value);
		alias bindable event m_onPropChanged () = m_onChanged;
	}

	property m_currentText
	{
		char const* get ();
		alias bindable event m_onPropChanged () = m_onChanged;
	}

	property m_currentData
	{
		variant get ();
		alias bindable event m_onPropChanged () = m_onChanged;
	}

	event m_onChanged ();
	event m_onEnter ();
}

//..............................................................................

// toolbar

opaque class ToolBar
{
	destruct ();

	addAction (Action* action);
	addLabel (char const* pText);
	ComboBox* addComboBox (uint_t width = 0);  // 0 = default, -1 = stretch
	addSeparator ();
}

//..............................................................................

// menu

opaque class Menu
{
	addAction (Action* action);
	addSeparator ();

	destruct ();
}

//..............................................................................

// statusbar

opaque class StatusPane
{
	bool autoget property m_isVisible;
	bool autoget property m_isEnabled;
	char const* autoget property m_text;
	uint_t autoget property m_width;
	uint_t autoget property m_color;
}

opaque class StatusBar
{
	destruct ();

	displayMessage (
		char const* text,
		uint_t timeout = 3000
		);

	size_t readonly m_paneCount;
	StatusPane* const property m_pane (size_t index);

	StatusPane* addPane (
		char const* text = null,
		uint_t width = 0 // 0 = default
		);
}

//..............................................................................

} // namespace gui {
