#include <origin.h>
#include <GetNBox.h>
#include <xfutils.h>


//put additional include files here

//put your own support static functions here


/*------------------------------------------------------------------------------*
 * Modifications:																*
 *	Folger 03/09/09 QA80-13247 PE_DIR_OPTIONAL_OUTPUT_FOR_FOLDER_AND_PAGE_NAMES	*
 *------------------------------------------------------------------------------*/
 

void pe_dir(const string& name, const string& page, string& oname)
{
	string strName;
	Folder fld = Project.ActiveFolder();
	
	///------ Folger 03/09/09 QA80-13247 PE_DIR_OPTIONAL_OUTPUT_FOR_FOLDER_AND_PAGE_NAMES
	if ( oname )
		oname.Empty();
	///------ End PE_DIR_OPTIONAL_OUTPUT_FOR_FOLDER_AND_PAGE_NAMES
		
	if( page.IsEmpty() && name.IsEmpty() )// no win_type/page_name specified, will show subfolders
	{
		foreach(Folder subpag in fld.Subfolders)
		{
			strName = subpag.GetName();
			///Cheney 2007-7-2 UPDATE_XF_ERR_THROW
			//printf("<Folder> %s\n", strName);
			string strtemp;
			strtemp.Format("<Folder> %s", strName);
			warning_msg_box(strtemp, false, 'R');
			///end UPDATE_XF_ERR_THROW
			///------ Folger 03/09/09 QA80-13247 PE_DIR_OPTIONAL_OUTPUT_FOR_FOLDER_AND_PAGE_NAMES
			if ( oname )
				oname += strtemp + "\r\n";
			///------ End PE_DIR_OPTIONAL_OUTPUT_FOR_FOLDER_AND_PAGE_NAMES
		}
	}
	
	int nWinType = page_type_2_int(page);
	
	PageBase pg;		
	foreach(pg in fld.Pages)
	{
		if( 0 == nWinType || nWinType == pg.GetType() )
		{
			strName = pg.GetName();
			if(!name.IsEmpty())
			{
				if(strName.Match(name, true) )
				{
					///Cheney 2007-7-2 UPDATE_XF_ERR_THROW
					//printf("%s\n", strName);
					warning_msg_box(strName, false, 'R');
					///end UPDATE_XF_ERR_THROW
					///------ Folger 03/09/09 QA80-13247 PE_DIR_OPTIONAL_OUTPUT_FOR_FOLDER_AND_PAGE_NAMES
					if ( oname )
						oname += strName + "\r\n";
					///------ End PE_DIR_OPTIONAL_OUTPUT_FOR_FOLDER_AND_PAGE_NAMES
				}
			}
			///Cheney 2007-7-2 UPDATE_XF_ERR_THROW
			//else printf("%s\n", strName);
			else
			{
				warning_msg_box(strName, false, 'R');
				///------ Folger 03/09/09 QA80-13247 PE_DIR_OPTIONAL_OUTPUT_FOR_FOLDER_AND_PAGE_NAMES
				if ( oname )
					oname += strName + "\r\n";
				///------ End PE_DIR_OPTIONAL_OUTPUT_FOR_FOLDER_AND_PAGE_NAMES
			}
			///end UPDATE_XF_ERR_THROW
		}
	}
	
	///------ Folger 03/09/09 QA80-13247 PE_DIR_OPTIONAL_OUTPUT_FOR_FOLDER_AND_PAGE_NAMES
	if ( oname )
		oname.TrimRight();
	///------ End PE_DIR_OPTIONAL_OUTPUT_FOR_FOLDER_AND_PAGE_NAMES
	
}

//nGetNDialog = 0,1,2, corresponding to the XF GetN dropdown, 0 = dialog is not used
//you can change nRet to be one of XFEVT_PROCEED (defualt), XFEVT_ABORT, XFEVT_PROCEED_NO_DLG or XFEVT_PROCEED_WITH_DLG(when nGetNDialog = 0)
//nGetNDialog = -1 when Ok on GetN dialog to allow handler to preocess <auto> etc variables
//dwCntrl is combination of bits
//LTXF_FROM_GUI_MENU, LTXF_FROM_GUI_PROMPT, LTXF_FROM_AUTO_UPDATE, LTXF_FROM_FUNCTION, LTXF_THEME_USED, LTXF_CHANGE_PARAM
void pe_dir_before_execute(TreeNode& trGetN, int nGetNDialog, int& nRet, int dwCntrl)
{

}
