/***************************************************************************
**
**    $Header:   D:/PICSLDV/SRC/LOG/DIAGNO/INFOEDIT.CPP   1.8   09 Jan 1997 14:28:08   ZJRD  $
**
**    $Log:   D:/PICSLDV/SRC/LOG/DIAGNO/INFOEDIT.CPP  $
** 
**    Rev 1.8   09 Jan 1997 14:28:08   ZJRD
** No change.
** 
**    Rev 1.7   13 Dec 1996 11:23:24   ZJRD
** No change.
** 
**    Rev 1.6   22 Nov 1996 11:04:20   ZJRD
** No change.
** 
**    Rev 1.5   11 Nov 1996 12:51:38   ZJRD
** No change.
** 
**    Rev 1.4   06 Nov 1996 13:03:24   ZJRD
** No change.
** 
**    Rev 1.3   02 Nov 1996 09:50:50   ZJRD
** No change.
** 
**    Rev 1.2   30 Oct 1996 12:53:36   ZJRD
** No change.
** 
**    Rev 1.1   28 Oct 1996 09:46:02   ZJRD
** PIC/SLD Version 0.92
** 
****************************************************************************/

/***************************************************************************
**
** File name : infoedit.cpp
** Author:John Zhou
** Description:
**    class CInfoList
**
**
**    Finished date: 1996.10
**
**
**    Copyright (C) 1995 Microtek International, Inc.
**    All Rights Reserved
**
****************************************************************************/

/********************** for class C251DADMem *******************************/ 
// 
//	CLASS NAME : CInfoEdit
//
//  HEAD FILE  : DAD251.H
//
/**************************************************************************/  
#include "stdafx.h"
#include "infoedit.h"

BEGIN_MESSAGE_MAP(CInfoList, CListBox)
	//{{AFX_MSG_MAP(CInfoList)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CCodeList overload function

void CInfoList::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
	// Get DC.
    CDC* pDC = CDC::FromHandle(lpDIS->hDC);
    pDC->SelectStockObject(ANSI_FIXED_FONT);
    
    TEXTMETRIC tm;
    pDC->GetTextMetrics(&tm);
    int nFontWidth(tm.tmAveCharWidth);
    int nFontHeight(tm.tmHeight + tm.tmExternalLeading);

	// Draw the text line.
    char* pObj = (char*)lpDIS->itemData;

    if ( lpDIS->itemAction & ODA_DRAWENTIRE ) {
		CRect rect(lpDIS->rcItem);
        CString strLine = pObj;
        
        char cpTmp2[128];
		strcpy(cpTmp2,strLine.GetBuffer(strLine.GetLength()+2));
		strLine.MakeUpper();	
		                            
		strLine = "";           
		int nLenTmp = strlen(cpTmp2);
		for(int i2=0;i2<nLenTmp;i2++) {
			if('\t' != cpTmp2[i2] && '\n' != cpTmp2[i2]) strLine += cpTmp2[i2];
		}
        
        if( -1 != strLine.Find("ERROR") ) {
			pDC->SetTextColor(RGB(255,0,0));
		} else {
			pDC->SetTextColor(RGB(0,0,0));
		}
		
		pDC->TextOut(rect.left, rect.top, strLine);
    }

}

void CInfoList::MeasureItem(LPMEASUREITEMSTRUCT lpMIS)
{
	// Get the line height.
    CDC* pDC = GetDC();
    pDC->SelectStockObject(ANSI_FIXED_FONT);
    
    TEXTMETRIC tm;
    pDC->GetTextMetrics(&tm);
    int nFontWidth(tm.tmAveCharWidth);
    int nFontHeight(tm.tmHeight + tm.tmExternalLeading);

    ReleaseDC(pDC);

	// Set the line height.
	lpMIS->itemHeight = nFontHeight;
}


/////////////////////////////////////////////////////////////////////////////
// CCodeList common routine

int CInfoList::AddLine(char* pLine)
{
	// Add to a listbox.
	return AddString((LPCSTR)pLine);
}

