#include "ide.h"


FileSelButton::FileSelButton(MODE mode, const char *title)
: mode(mode), title(title)
{
	button.NoWantFocus();
	button.SetImage(CtrlImg::right_arrow());
	button <<= THISBACK(OnAction);
}

void FileSelButton::OnAction()
{
	Ctrl *owner = button.GetParent();
	ASSERT(owner);
	String old = ~*owner;
	if(mode == MODE_DIR)
		ActiveDir(old);
	else
		Set(old);
	if(mode == MODE_OPEN ? ExecuteOpen(title) : mode == MODE_SAVE ? ExecuteSaveAs(title) : ExecuteSelectDir(title))
	{
		*owner <<= Get();
		owner->Action();
	}
}


syntax highlighted by Code2HTML, v. 0.9.1