Ejemplo n.º 1
0
void LFO_ObjectListing::PrepareVars()
{
    int nroot = MenuRootC::rootList.Size();

    oneRoot =  nroot == 1;
    nobj = funcObjList.Size();

    pageObjects.Alloc(nobj);
    objNameIndexes.AllocAndFill(nobj, -1);
    pageObjectNames.SetStringLen(objStrLen);
    pageObjectNames.Alloc(nobj);

    nextPageFO = 0;
    for (int i = 0; i <  nroot; i++)
    {
        MenuRootC& currRoot = *(MenuRootC::rootList[i]);
        rootID = currRoot.shortID;
        for (int j = 0; j <  currRoot.pageLeafs.Size(); j++)
            AddPageToList(*(currRoot.pageLeafs[j]));
    }

    systemObjectNames.SetStringLen(objStrLen);
    systemObjectNames.Alloc(nobj - nextPageFO);
    for (int i = 0; i <  nobj; i++)
        if (objNameIndexes[i] < 0)
        {
            char tempStr[objStrLen];
            MakeString(tempStr, "System::", funcObjList[i]->GetID(), objStrLen);
            ConcatString(tempStr, " #", objStrLen);
            ConcatInt(i, tempStr, objStrLen);
            systemObjectNames += tempStr;
            objNameIndexes[i] = -systemObjectNames.Size();
        }
}
Ejemplo n.º 2
0
void LFO_ObjectListing::AddPageToList(const MenuPageC& currPage)
{
    FuncObjArray pageFO;
    currPage.GetPageFO(pageFO);
    int npageObj = pageFO.Size();

    for (int k = 0; k < npageObj; k++)
    {
        FuncObjC& currObj = *(pageFO[k]);
        const char* colorStr = 0;
        switch (currObj.GetStatus()) {
            case os_OK : {
                break;
            }
            case os_Bad : {
                colorStr =  "<FONT COLOR=RED>";
                break;
            }
            case os_NotSet : {
                colorStr =  "<FONT COLOR=BLUE>";
                break;
            }
            default : {
                colorStr =  "<FONT COLOR=GREEN>";
                break;
            }
        }

        char tempStr[objStrLen];
        MakeString(tempStr, colorStr, currObj.GetID(), "::", currObj.GetType(), "::", currPage.pageID, objStrLen);
        if (!oneRoot)
        {
            ConcatString(tempStr, "::", objStrLen);
            ConcatString(tempStr, rootID, objStrLen);
        }

        int foIndex = funcObjList.FoundAt(&currObj);
        // ConcatString(tempStr, " #", objStrLen);
        // ConcatInt(foIndex, tempStr, objStrLen);

        if (colorStr != 0)
            ConcatString(tempStr, "</FONT>", objStrLen);

        pageObjectNames += tempStr;
        pageObjects += &currObj;

        objNameIndexes[foIndex] = nextPageFO;
        nextPageFO++;
    }

    for (int i = 0; i < currPage.childPages.Size(); i++)
        AddPageToList(*(currPage.childPages[i]));
}
Ejemplo n.º 3
0
/***************************************************
PrintInit
	Initializes and sets up the data that needs to
	be calculated to perform the actual print. Such
	tasks include calcualating the number of pages
	required to print the given range, and the scale.
Params
	pDC - device context for the printer (or print preview)
	pPD - pointer to the print dialog information
	startCol- leftmost column to print on the page
	endCol	- rightmost column to print on the page
	startRow- topmost row to print on the page
	endRow	- bottom most row to print on the page
Return
	number of pages that will be printed
****************************************************/
int CUGPrint::PrintInit(CDC * pDC, CPrintDialog* pPD, int startCol,long startRow,
						int endCol,long endRow)
{
	UNREFERENCED_PARAMETER(pPD);

	ClearPrintList();

	//get a screen device context
	CDC	sDC;
	sDC.CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
	
	//check to see if the request if for printing or print preview
	m_bIsPreview = FALSE;
	SIZE size;
	pDC->SetMapMode(MM_ANISOTROPIC);
	SetWindowExtEx(pDC->m_hDC,1,1,&size);
	if(size.cx != 1){
		m_bIsPreview = TRUE;
		SetWindowExtEx(pDC->m_hDC,size.cx,size.cy,&size);
	}
	
	//get the metrics for the printer
	float paperWidthPX		= (float)pDC->GetDeviceCaps(HORZRES);
	float paperHeightPX		= (float)pDC->GetDeviceCaps(VERTRES);
	float paperWidthMM		= (float)pDC->GetDeviceCaps(HORZSIZE);
	float paperHeightMM		= (float)pDC->GetDeviceCaps(VERTSIZE);
	int virtualWidthPX = (int)( 3.79 * (paperWidthMM - m_printLeftMargin - m_printRightMargin));
	int virtualHeightPX = (int)( 3.78 * (paperHeightMM - m_printTopMargin - m_printBottomMargin));

	//save the scaling values
	m_printVScale = ( (paperHeightPX/paperHeightMM) *
					(paperHeightMM - m_printTopMargin - m_printBottomMargin) ) /
					virtualHeightPX;
	m_printHScale = ( (paperWidthPX/paperWidthMM) *
					(paperWidthMM - m_printLeftMargin - m_printRightMargin) ) /
					virtualWidthPX;

	//save the margins
	m_printLeftMarginPX = (int)((paperWidthPX/paperWidthMM) * m_printLeftMargin);
	m_printTopMarginPX = (int)((paperHeightPX/paperHeightMM) * m_printTopMargin);
	m_printRightMarginPX = (int)(paperWidthPX - (paperWidthPX/paperWidthMM) * m_printRightMargin);
	m_printBottomMarginPX = (int)(paperHeightPX - (paperHeightPX/paperHeightMM) * m_printBottomMargin);
	m_paperWidthPX = (int)paperWidthPX;
	m_paperHeightPX = (int)paperHeightPX;

	//if not print preview, then addjust values by the virtual pixel width
	if(m_bIsPreview == FALSE)
	{
		m_virPixWidth = (int)paperWidthPX / 450;  //300
		m_printVScale /= m_virPixWidth;
		m_printHScale /= m_virPixWidth;
		m_printLeftMarginPX /= m_virPixWidth;
		m_printTopMarginPX /= m_virPixWidth;
		m_printRightMarginPX /= m_virPixWidth;
		m_printBottomMarginPX /= m_virPixWidth;
		m_paperWidthPX /= m_virPixWidth;
		m_paperHeightPX /= m_virPixWidth;
	}

	//get the number of pages wide
	int col,width=0,w;
	int scol = startCol;		//start col for a page
	m_pagesWide = 0;
	
	if(m_printSideHeading)
		width = m_ctrl->GetSH_Width();
	//find the number of pages wide and the number of columns
	//on each page
	for(col =startCol;col <= endCol;col++)
	{
		m_ctrl->GetColWidth(col,&w);		
		width += w;
	
		if(width > virtualWidthPX)
		{
			m_pagesWide++;
			if(m_printSideHeading)
				width = m_ctrl->GetSH_Width();
			else
				width = 0;

			if(w < virtualWidthPX)
				col--;

			//add the column info to the list
			AddPageToList(m_pagesWide,scol,col,0,0);
			scol = col+1;
		}
	}
	
	if(width >0)
	{
		m_pagesWide++;
		//add the column info to the list
		if(col > endCol)
			col = endCol;
		AddPageToList(m_pagesWide,scol,col,0,0);
	}

	//get the number of pages high
	long row;
	long srow = startRow;		//start row for page
	int height=0,h;
	m_pagesHigh = 0;
	
	if(m_printTopHeading)
		height = m_ctrl->GetTH_Height();

	//find the number of pages high and the number of rows
	//on each page
	for(row = startRow;row <=endRow;row++)
	{
		m_ctrl->GetRowHeight(row,&h);
		height += h;
		if(height > virtualHeightPX)
		{
			m_pagesHigh ++;
			if(m_printTopHeading)
				height = m_ctrl->GetTH_Height();
			else 
				height = 0;

			if(h < virtualHeightPX)
				row--;
			
			//add the page information to the list
			int c1,c2;
			long r1,r2;
			int page;
			for(col =1;col<=m_pagesWide;col++)
			{
				//get the col info
				GetPageFromList(col,&c1,&c2,&r1,&r2);
				//update the page info
				page = (m_pagesHigh-1)*m_pagesWide +col;
				AddPageToList(page,c1,c2,srow,row);
			}
			srow = row+1;
		}
	}
	if(height >0)
	{
		m_pagesHigh++;
		//add the page information to the list
		int c1,c2;
		long r1,r2;
		int page;
		for(col =1;col<=m_pagesWide;col++)
		{
			//get the col info
			GetPageFromList(col,&c1,&c2,&r1,&r2);
			//update the page info
			page = (m_pagesHigh-1)*m_pagesWide +col;
			if(row > endRow)
				row = endRow;
			AddPageToList(page,c1,c2,srow,row);
		}
	}

	//return the number of pages in total
	return (m_pagesWide * m_pagesHigh);
}