//..............................................................................
//
// Ninja UI - actions (QT-style model)
//

import "ui_Icon.jnc"

namespace ui {

//! \addtogroup api-ui
//! @{

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

enum InsertActionPos {
	Tail = 0,
	Head,
	BeforeCurrentHead,
	Default = Tail
}

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

opaque class Action {
	bool autoget property m_isVisible;
	bool autoget property m_isEnabled;
	bool autoget property m_isCheckable;
	bool bindable autoget property m_isChecked;

	Icon* autoget property m_icon;
	string_t autoget property m_text;
	string_t autoget property m_toolTip;

	event m_onTriggered();

	construct(
		Icon* icon,
		string_t text,
		void function* onTriggered() = null
	) {
		initialize(icon, text, onTriggered);
	}

	construct(
		string_t iconFileName,
		string_t text,
		void function* onTriggered() = null
	) {
		initialize(new Icon(iconFileName), text, onTriggered);
	}

	construct(
		string_t text,
		void function* onTriggered() = null
	) {
		initialize(null, text, onTriggered);
	}

	destruct();

protected:
	void initialize(
		Icon* icon,
		string_t text
	);

	void initialize(
		Icon* icon,
		string_t text,
		void function* onTriggered()
	) {
		initialize(icon, text);
		if (onTriggered)
			m_onTriggered += onTriggered;
	}
}

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

//! @}

} // namespace ui
