Beispiel #1
0
BOOL CGlobalObj::bOpenFunctioneditorfile(CString omStrNewCFileName)
{
    BOOL bFileFound = TRUE;

    CFunctionEditorDoc* pDoc = CFunctionEditorBase::pCreateNewDocument(m_eBus);
    // file-attribute information
    if (pDoc != nullptr)
    {
        CEditFrameWnd::sm_eBus = m_eBus;
        struct _tfinddata_t fileinfo;
        // Check if file exists
        if (_tfindfirst( omStrNewCFileName.GetBuffer(MAX_PATH), &fileinfo) == -1L)
        {
            bFileFound = pDoc->bCreateNewDocument(omStrNewCFileName);
        }
        if (bFileFound == TRUE)
        {
            //// Now open the selected file
            pDoc->OnOpenDocument(omStrNewCFileName);
            CMultiDocTemplate* pTemplate = m_pEditorDocTemplate;
            m_pEditFrameWnd = (CEditFrameWnd*)(pTemplate->CreateNewFrame(pDoc, nullptr));

            //If null is passed as parameter the m_pdoc->GetNextView(pos)  will
            // give null value
            if (m_pEditFrameWnd != nullptr)
            {
                ASSERT_KINDOF(CEditFrameWnd, m_pEditFrameWnd);
                pTemplate->InitialUpdateFrame(m_pEditFrameWnd, /*nullptr*/pDoc);
            }
        }
    }
    return bFileFound;
}
Beispiel #2
0
/**
* \brief         Callback function which can be used to close windows during configuration switching
* \param[in]     HWND hwnd, LPARAM lParam
* \return        TRUE
* \authors       Arunkumar Karri
* \date          14.02.2013 Created
*/
BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM /* lParam */)
{
    if ( hwnd )
    {
        CWnd* pWnd = CWnd::FromHandle(hwnd);
        if ( pWnd )
        {
            CRuntimeClass* pRunTimeClass = pWnd->GetRuntimeClass();

            if ( pRunTimeClass )
            {
                if ( pRunTimeClass == RUNTIME_CLASS(CEditFrameWnd) || pRunTimeClass == RUNTIME_CLASS(COutWnd) )
                {
                    /* If any function editor window is open */
                    if ( pRunTimeClass == RUNTIME_CLASS(CEditFrameWnd) )
                    {
                        CEditFrameWnd* pEditWnd = (CEditFrameWnd*)pWnd;
                        CFunctionEditorDoc* pDoc = (CFunctionEditorDoc*)pEditWnd->GetActiveDocument();

                        /* If a function editor window is modified */
                        if ( nullptr != pDoc && pDoc->IsModified() )
                        {
                            /* take confirmation from user for the first time only */
                            if ( g_bReqUserConfirmation )
                            {
                                g_bReqUserConfirmation = false;
                                INT nSelection = ::MessageBox( hwnd, _("Simulation files have been modified. Do You Want to save the Changes?"), _("Modified"), MB_YESNO | MB_ICONQUESTION);

                                switch(nSelection)
                                {
                                    case IDYES:
                                        g_bQueryConfirm = true;
                                        break;
                                    case IDNO:
                                        g_bQueryConfirm = false;
                                        break;
                                }
                            }
                            /* Based on user response, save the simulation files */
                            if ( g_bQueryConfirm )
                            {
                                if (pDoc != nullptr)
                                {
                                    pDoc->OnSaveDocument(pDoc->GetPathName());
                                }
                            }
                        }
                    }
                    /* Destroy the window */
                    pWnd->DestroyWindow();
                }
            }
        }
    }
    return TRUE;
}
Beispiel #3
0
CFunctionEditorDoc* CFunctionEditorBase::pCreateNewDocument(eTYPE_BUS eBus)
{
    CMultiDocTemplate* pTemplate = CGlobalObj::ouGetObj(eBus).m_pEditorDocTemplate;
    // Now open the selected file
    CFunctionEditorDoc *pDoc = (CFunctionEditorDoc*)pTemplate->CreateNewDocument();
    if (pDoc != NULL)
    {
        SBUS_SPECIFIC_INFO sInfo;
        if (bInitBusInfo(sInfo, eBus))
        {
            pDoc->bInitBusSpecificInfo(sInfo);
        }
    }
    return pDoc;
}
Beispiel #4
0
void CGlobalObj::vCloseAllActiveFunctionEditors()
{
	//CFunctionEditorDoc* pDocRet = nullptr;
	CFunctionEditorDoc* pDoc = nullptr;
	if (m_pEditorDocTemplate != nullptr)
	{
		POSITION pos = m_pEditorDocTemplate->GetFirstDocPosition();
		while (pos/*&& !pDocRet*/)
		{
			pDoc = (CFunctionEditorDoc*)m_pEditorDocTemplate->GetNextDoc(pos);
			if (pDoc->IsKindOf(RUNTIME_CLASS(CFunctionEditorDoc)))
			{
				pDoc->OnCloseDocument();
			}
		}
	}
}
Beispiel #5
0
void CFunctionView::UpdateFileViewAndSetModified()
{
    // If document is updated successfully then,
    // update the view
    if ( UpdateFunctionInDocument())
    {
        CFunctionEditorDoc* pDoc = (CFunctionEditorDoc*)CView::GetDocument();
        if ( pDoc != NULL )
        {
            //pomMainFrm->CGlobalObj::podGetFunctionEditorDoc()->Invalidate();
            CFileView* pFileView = CGlobalObj::ouGetObj(m_eBus).podGetFileViewPtr();
            if (pFileView != NULL)
            {
                pFileView->OnUpdate( NULL, 0, NULL );
                pFileView->vGoToLine( m_nStartingLine + m_nCurrentLine );
            }
            pDoc->SetModifiedFlag( TRUE );
        }
    }
}
Beispiel #6
0
CFileView* CGlobalObj::podGetFileViewPtr()
{
    CFileView* pFileView = nullptr;
    CView* pTempView = nullptr;
    BOOL bFound = FALSE;
    //Get the active document and find the CFileView attached to it
    CFunctionEditorDoc* pDoc = podGetFunctionEditorDoc();
    if (pDoc != nullptr)
    {
        POSITION pos = pDoc->GetFirstViewPosition();
        while (pos && !bFound)
        {
            pTempView = pDoc->GetNextView(pos);
            if (pTempView->IsKindOf(RUNTIME_CLASS(CFileView)))
            {
                pFileView = (CFileView*)pTempView;
                bFound = TRUE;
            }
        }
    }
    return pFileView;
}
Beispiel #7
0
CFunctionEditorDoc* CGlobalObj::pGetDocPtrOfFile(CString strTempName)
{
    CString strPath = "";
    CFunctionEditorDoc* pDocRet = nullptr;
    CFunctionEditorDoc* pDoc = nullptr;
    if (m_pEditorDocTemplate != nullptr)
    {
        POSITION pos = m_pEditorDocTemplate->GetFirstDocPosition();
        while (pos && !pDocRet)
        {
            pDoc = (CFunctionEditorDoc*)m_pEditorDocTemplate->GetNextDoc(pos);
            if (pDoc->IsKindOf(RUNTIME_CLASS(CFunctionEditorDoc)))
            {
                strPath = pDoc->GetPathName();
                if (!(strPath.Compare(strTempName)))
                {
                    pDocRet = pDoc;
                }
            }
        }
    }
    return pDocRet;
}
void CExploreMsgSg::OnSelect()
{
    UpdateData(TRUE);


    // Get Main Frame Window Pointer
    CFunctionEditorDoc* pDoc = nullptr;
    // For global variable addition structure is required
    if( m_eSelectType == SEL_GLOBAL_MESSAGE)
    {
        // Same as select message
        m_eSelectType = SEL_MESSAGE;
        // Enable structure definition
        m_bWantStructure = TRUE;
    }


    // Get the Document Object
    if (m_bWantStructure == TRUE)
    {
        pDoc = m_pDoc;
    }

    if ( m_eSelectType == SEL_MESSAGE )
    {
        // Get selected message text
        m_omStrMessageName = m_omStrSelectedItemText =
                                 m_omMsgList.GetItemText( m_nMsgIndex, 0);
        UINT unMsgID = (COMMANUINT)m_omMsgList.GetItemData(m_nMsgIndex);

        if (m_bWantStructure == TRUE)
        {
            // Get the Initialised string from document
            if (pDoc != nullptr)
            {
                //To pass the actual name of message
                int nIndex = m_omStrMessageName.ReverseFind(defMSGID_NAME_START_CHAR);
                if(nIndex != -1)
                {
                    m_omStrSelectedItemText = m_omStrMessageName.Left(nIndex);
                    m_omStrMessageName = m_omStrSelectedItemText;
                }



                CString omStrMsgStructure =
                    pDoc->omStrGetInitialisedMessage(unMsgID,
                                                     m_omStrSelectedItemText,
                                                     MSG_STRUCT_VAR,TRUE,nGetSelChannel(), nGetSelChannel());
                m_omStrSelectedItemText = omStrMsgStructure;
            }
        }
    }
    else
    {
        // User wants signal to be selected
        CString omStrMsg = m_omMsgList.GetItemText(m_nMsgIndex, 0);
        UINT unMsgID = (COMMANUINT)m_omMsgList.GetItemData(m_nMsgIndex);
        int nSgIndex = (COMMANUINT)m_omSignalListBox.GetCurSel();

        if ( nSgIndex != -1 )
        {
            // Get selected signal text
            CString omStrSgName = "";
            m_omSignalListBox.GetText( nSgIndex, omStrSgName );

            if ( m_bWantStructure )
            {
                omStrSgName.Insert( 0, (char)PERIOD );

                ////To pass the actual name of message
                int nIndex = omStrMsg.ReverseFind(defMSGID_NAME_START_CHAR);
                if( nIndex!=0 )
                {
                    omStrMsg = omStrMsg.Left(nIndex);
                }

                if(nullptr != pDoc)
                {
                    // Get the Initialised string from document
                    CString omStrMsgStructure =
                        pDoc->omStrGetInitialisedMessage(unMsgID,
                                                         omStrMsg,
                                                         MSG_STRUCT_VAR,TRUE,nGetSelChannel());
                    // Form the declaration and signal access statements
                    m_omStrSelectedItemText.Format(defFNS_INIT_SIG_FORMAT,
                                                   omStrMsgStructure,
                                                   MSG_STRUCT_VAR,
                                                   defSIGNALMEMBER);
                }
            }
            m_omStrSelectedItemText += omStrSgName;
        }
    }
    CDialog::OnOK();
}
Beispiel #9
0
BOOL CFunctionView::UpdateFunctionInDocument()
{
    BOOL bRetVal    = FALSE;
    POSITION sStart = m_sStartPos;
    if ( sStart != NULL )
    {
        CFunctionEditorDoc* pDoc = (CFunctionEditorDoc*)CView::GetDocument();

        if ( pDoc != NULL )
        {
            SBUS_SPECIFIC_INFO sBusSpecInfo;
            pDoc->bGetBusSpecificInfo(sBusSpecInfo);
            //Construct the Function Footer
            CString omStrFnFooter;
            // If it is global variable then select Global variable footer
            if( m_omStrFnName == GLOBAL_VARIABLES )
            {
                omStrFnFooter = BUS_VAR_FOOTER;
                omStrFnFooter.Replace("PLACE_HODLER_FOR_BUSNAME", sBusSpecInfo.m_omBusName);
            }
            else
            {
                // Select function common footer
                omStrFnFooter = EDITOR_BUS_FN_FOOTER;
                // Form function specific footer
                omStrFnFooter.Replace("PLACE_HODLER_FOR_BUSNAME", sBusSpecInfo.m_omBusName);
                omStrFnFooter.Replace( "PLACE_HODLER_FOR_FUNCTIONNAME",
                                       m_omStrFnName );
            }

            CString omStrLine("");
            // Get the Edit control ref.
            CRichEditCtrl& romEditCtrl = GetRichEditCtrl();
            // get the total lines of code in the rich edit control
            int nLineCount      = romEditCtrl.GetLineCount();
            long lStart, lEnd;
            // Get the cursor position
            romEditCtrl.GetSel(lStart, lEnd);
            // Get the cursor line and save
            m_nCurrentLine = (int) romEditCtrl.LineFromChar(lStart);

            BOOL bDone = FALSE;

            pDoc->m_omSourceCodeTextList.GetNext(sStart);

            POSITION sPos1  = NULL;
            POSITION sPos2  = NULL;
            for( sPos1 = sStart; ( ((sPos2 = sPos1) != NULL) && (!bDone) ); )
            {
                CString omStrDel =
                    pDoc->m_omSourceCodeTextList.GetNext( sPos1 );
                if( omStrDel.Find(omStrFnFooter) >= 0 )
                {
                    bDone = TRUE;
                }
                else
                {
                    pDoc->m_omSourceCodeTextList.RemoveAt( sPos2 );
                }
            }

            BOOL bFirst = TRUE;
            POSITION sPos = m_sStartPos;


            for (int nLineIndex = 0; nLineIndex < nLineCount; nLineIndex++)
            {
                CString omStrNewItem("");

                int nCharIndex  = GetRichEditCtrl().LineIndex(nLineIndex);
                int nLineLength = GetRichEditCtrl().LineLength(nCharIndex);

                nLineLength = ( nLineLength < 4 ) ? 4 : nLineLength;

                GetRichEditCtrl().GetLine(nLineIndex,
                                          omStrNewItem.GetBuffer(nLineLength),
                                          nLineLength);

                omStrNewItem.ReleaseBuffer(nLineLength);
                omStrNewItem.TrimRight();



                if ( bFirst )
                {
                    pDoc->m_omSourceCodeTextList.SetAt(sPos, omStrNewItem);
                    bFirst = FALSE;
                }
                else
                {
                    pDoc->m_omSourceCodeTextList.InsertAfter(
                        sPos, omStrNewItem);
                    pDoc->m_omSourceCodeTextList.GetNext(sPos);
                }


            }
            bRetVal = TRUE;
        }
    }
    return bRetVal;
}
Beispiel #10
0
void CFunctionView::vSetFunctionToEdit(const CString& omStrFunction)
{
    m_omStrFnName = omStrFunction;

    CString omStrFnBody("");
    BOOL bGlobalVar = FALSE;

    m_bIsValidFunction = FALSE;
    m_sStartPos = NULL;
    CFunctionEditorDoc* pDoc = NULL;
    pDoc = (CFunctionEditorDoc*)CView::GetDocument();

    if ( pDoc != NULL )
    {
        SBUS_SPECIFIC_INFO sBusSpecInfo;
        pDoc->bGetBusSpecificInfo(sBusSpecInfo);

        CString omStrFnHeader, omStrFnFooter;
        // If it is a global variable block then set the block
        // with global variable boundary
        if( omStrFunction == GLOBAL_VARIABLES )
        {
            omStrFnHeader = BUS_VAR_HDR;
            omStrFnHeader.Replace("PLACE_HODLER_FOR_BUSNAME", sBusSpecInfo.m_omBusName);

            omStrFnFooter = BUS_VAR_FOOTER;
            omStrFnFooter.Replace("PLACE_HODLER_FOR_BUSNAME", sBusSpecInfo.m_omBusName);

            bGlobalVar = TRUE;
        }
        else
        {
            //Construct the Function Header
            omStrFnHeader = BUS_FN_HDR;
            omStrFnHeader.Replace("PLACE_HODLER_FOR_BUSNAME", sBusSpecInfo.m_omBusName);
            omStrFnHeader.Replace( "PLACE_HODLER_FOR_FUNCTIONNAME",
                                   omStrFunction );
            //Construct the Function Footer
            omStrFnFooter = EDITOR_BUS_FN_FOOTER;
            omStrFnFooter.Replace(_T("PLACE_HODLER_FOR_BUSNAME"), sBusSpecInfo.m_omBusName);
            omStrFnFooter.Replace( _T("PLACE_HODLER_FOR_FUNCTIONNAME"),
                                   omStrFunction );
        }

        POSITION sPos = pDoc->m_omSourceCodeTextList.GetHeadPosition();
        int nLineNumber = 0;

        while ( sPos != NULL )
        {
            //Iterate through the Source Code String-List
            CString omStrLine = pDoc->m_omSourceCodeTextList.GetNext(sPos);
            // Increment the line count
            nLineNumber++;
            //If the current line matches the Function Header...
            //(means the starting of the function we are looking for)
            if ( omStrLine == omStrFnHeader )
            {
                if( bGlobalVar == FALSE)
                {
                    m_nStartingLine = nLineNumber;
                    //Skip Function name and parameters line
                    omStrLine = pDoc->m_omSourceCodeTextList.GetNext(sPos);
                    if (sPos != NULL)
                    {
                        //Get Next line
                        omStrLine = pDoc->m_omSourceCodeTextList.GetNext(sPos);

                        if (sPos != NULL)
                        {
                            //Opening brace indicates start of function body
                            if ( omStrLine.Find('{') != -1 )
                            {
                                //Store the start for later use
                                m_sStartPos = sPos;

                                //Loop through the function body till we encounter
                                //the function footer
                                while ( (sPos != NULL) && ( m_bIsValidFunction != TRUE) )
                                {
                                    omStrLine = pDoc->m_omSourceCodeTextList.GetNext(sPos);
                                    if ( omStrLine.Find(omStrFnFooter) >= 0 )
                                    {
                                        m_bIsValidFunction = TRUE;
                                    }
                                    else
                                    {
                                        omStrFnBody += omStrLine;
                                        omStrFnBody += '\n';
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    //Store the start for later use
                    m_sStartPos = sPos;
                    m_nStartingLine = nLineNumber;

                    while ( (sPos != NULL) && ( omStrLine != omStrFnFooter) )
                    {
                        omStrLine = pDoc->m_omSourceCodeTextList.GetNext(sPos);

                        if ( omStrLine.Find(omStrFnFooter) >= 0 )
                        {
                            m_bIsValidFunction = TRUE;
                        }
                        else
                        {
                            omStrFnBody += omStrLine;
                            omStrFnBody += '\n';
                        }
                    }
                }

            }
        }

        if ( m_bIsValidFunction )           //If a function name is set...
        {
            if ( !omStrFnBody.IsEmpty() )
            {
                //We got to remove the last '\n' that got added
                //when we constructed omStrFnBody from the source lines
                omStrFnBody.TrimRight();
                if ( omStrFnBody.ReverseFind('}') >= 0)
                {

                }
                SetWindowText(omStrFnBody);
                GetRichEditCtrl().SetReadOnly(FALSE);
            }
        }
        else // Display Global Variable
        {
            SetWindowText(omStrFnBody);
            GetRichEditCtrl().SetReadOnly(TRUE);
        }
    }
}
Beispiel #11
0
void COutWnd::OnDbClick()
{
    INT nSelectIndex;
    CString omStrSelectedItem;
    nSelectIndex = m_omListBox.GetCurSel();
    if(nSelectIndex!=LB_ERR )
    {
        CString omStrLineNumber = "";
        INT     nIndex          = 0;
        UINT    unLineNumber    = 0;
        char*   pcStopStr       = nullptr;

        m_omListBox.GetText(nSelectIndex,omStrSelectedItem);
        CString omStrFilePath;
        CString omStrFileName;
        omStrFilePath=omStrSelectedItem;
        while(!(nSelectIndex==0||omStrFilePath==defSTR_BUILD_TRACE_LINE_MARK))
        {
            --nSelectIndex;
            m_omListBox.GetText(nSelectIndex,omStrFilePath);
        }
        if(omStrFilePath==defSTR_BUILD_TRACE_LINE_MARK)
        {
            ++nSelectIndex;
            m_omListBox.GetText(nSelectIndex,omStrFilePath);
            int nNameIndex = omStrFilePath.ReverseFind('\\');
            if(nNameIndex != -1)
            {
                //pGetBusSpecificFunctionEditorDoc(omStrFilePath);
                CFunctionEditorDoc* pDoc = m_pGlobalObj->pGetDocPtrOfFile(omStrFilePath);
                if (pDoc != nullptr)
                {
                    //If file is opened then get its frame and activate it
                    {
                        POSITION pos = pDoc->GetFirstViewPosition();
                        if (pos)
                        {
                            pDoc->GetNextView(pos)->GetParentFrame()->ActivateFrame();
                        }
                    }
                }
                else
                {
                    //If file is not opened then open it
                    if ( !m_pGlobalObj->bOpenFunctioneditorfile(omStrFilePath) )
                    {
                        AfxMessageBox("Specified filename not found!",
                                      MB_OK|MB_ICONINFORMATION);
                    }
                }

                // Find the ':' to get the number after second ':'
                nIndex = omStrSelectedItem.Find(":");
                if(nIndex!=-1)
                {

                    omStrLineNumber = omStrSelectedItem.Right(
                                          omStrSelectedItem.GetLength()-nIndex-1);
                    nIndex          = omStrLineNumber.Find(":");
                    omStrLineNumber = omStrLineNumber.Right(
                                          omStrLineNumber.GetLength()-nIndex-1);

                    omStrLineNumber.TrimLeft();
                    omStrLineNumber.TrimRight();
                    omStrLineNumber = omStrLineNumber.SpanExcluding(":");
                    unLineNumber    = _tcstol((LPCTSTR)omStrLineNumber,
                                              &pcStopStr,10);
                    // Call this function only if the  line number is valid
                    if(unLineNumber!=0)
                    {
                        CFileView* pFileView = m_pGlobalObj->podGetFileViewPtr();
                        if(pFileView != nullptr)
                        {
                            pFileView->vDisplayWarningLineNumber(OUTWND,unLineNumber);
                        }
                    }
                }
                else
                {
                    nIndex = omStrSelectedItem.Find(":");
                    if(nIndex!=-1)
                    {
                        nIndex          = omStrSelectedItem.Find(":");
                        omStrLineNumber = omStrSelectedItem.Right(
                                              omStrSelectedItem.GetLength()-nIndex-1);

                        omStrLineNumber.TrimLeft();
                        omStrLineNumber.TrimRight();
                        omStrLineNumber = omStrLineNumber.
                                          SpanExcluding("\t ");
                        unLineNumber    = _tcstol((LPCTSTR)omStrLineNumber,
                                                  &pcStopStr,
                                                  10);
                        if(unLineNumber!=0)
                        {
                            CFileView* pFileView = m_pGlobalObj->podGetFileViewPtr();

                            if(nullptr != pFileView)
                            {
                                pFileView->vDisplayWarningLineNumber(OUTWND,
                                                                     unLineNumber);
                            }
                        }
                    }
                }
            }
        }
    }
}
Beispiel #12
0
/******************************************************************************
  Function Name    :  OnDraw

  Input(s)         :  CDC* pomDC
  Output           :  -
  Functionality    :  Called by the frame work to update the view.
                      This function gets source code from the document
                      and displays on the view.
                      If warning is specified, it highlight that line
                      with different color.
                      If single line of comment is found, it displays the line
                      with differet color.
  Member of        :  CFileView
  Friend of        :      -

  Author(s)        :
  Date Created     :
******************************************************************************/
void CFileView::OnDraw(CDC* pDC)
{
    // Get document
    CFunctionEditorDoc* pomDoc = omGetDocument();
    ASSERT_VALID(pomDoc);
    // Initialise backend Buffer
    // Get Client rectangle
    // This will give the starting point and size
    CRect omRect;
    GetClientRect(&omRect);
    // Get current scroll position
    CPoint omPoint = GetScrollPosition();
    // Add this walue with Client Rect
    // to get rect from the starting point to the end of scrolling point
    omRect.right += omPoint.x;
    omRect.bottom += omPoint.y;
    // Create Backend Buffer
    /*************************************************************/
    // If backend buffer creation failed it will use Screen DC
    // Directly to avoid showing blank screen
    // The Flag m_bCreateSuccess gives an indication of which DC
    // it is using. If it is TRUE then that is Buffer. If it is
    // FALSE then it is directly drawing on the pDC (screen pr printer DC).
    // No extra check is required to handle create failure
    /************************************************************/
    COffScreenDC  omMemDC(pDC, &omRect);
    CDC* pomDC = nullptr;
    pomDC = &omMemDC;
    if(pomDoc != nullptr)
    {
        char acSourceLineNo[10]  = "";
        long lLineCount          = LONG_INIT;
        long lCurrentWarnLineNum = LONG_INIT;
        int  nTabStopPositions   = INT_INIT;
        BOOL bWarningLine        = FALSE;
        COLORREF    CurrentTextColor   = DWORD_INIT,
                    CurrentBkColor     = DWORD_INIT;

        // Change Font
        CFont  omNewFont;
        CFont* pomOldFont=nullptr;
        BOOL bCommentFound = FALSE;
        BOOL bWithInComment = FALSE;

        // Create font
        BOOL bSuccess = omNewFont.CreateFont(m_nCharHeight,
                                             m_nCharWidth,
                                             DEFAULT_FONT_ESCAPEMENT,
                                             DEFAULT_FONT_ORIENTATION,
                                             FW_NORMAL,
                                             NOT_ITALIC,
                                             NO_UNDERLINE,
                                             NO_STRIKEOUT,
                                             DEFAULT_CHARSET,
                                             OUT_CHARACTER_PRECIS,
                                             CLIP_CHARACTER_PRECIS,
                                             DEFAULT_QUALITY,
                                             DEFAULT_PITCH | FF_MODERN,
                                             DEFAULT_FONT);
        if(bSuccess == TRUE)
        {
            // Select the new font object
            pomOldFont = pomDC -> SelectObject(&omNewFont);

            // Get line count
            lLineCount = pomDoc->dwGetLineCount ();

            // Get warning line number
            lCurrentWarnLineNum = pomDoc->m_lCurrentWarningLineNum;
            nTabStopPositions   = defNO_OF_CHARS_IN_TAB * m_nCharWidth;

            if(lLineCount  > defCOUNT_INIT)
            {
                POSITION Position = pomDoc -> SetPosToFirstLine();
                if( Position!= nullptr)
                {

                    for(long lInt = defCOUNT_INIT; lInt < lLineCount ; lInt++)
                    {
                        int nMargin = MARGIN_FOR_FILE_VIEW;
                        bCommentFound = FALSE;
                        // Set the background mix mode to
                        // tranparent
                        pomDC -> SetBkMode(TRANSPARENT);
                        // Display line number
                        wsprintf(acSourceLineNo,"%lu:",lInt+NEXT_POSITION);

                        CString omStr = (CString)
                                        pomDoc -> pcGetLine(Position);

                        int nIndex = omStr.Find( "/*" );
                        // Starting of comment or already in comment block
                        if (nIndex != -1 || bWithInComment)
                        {
                            if( nIndex == -1 )
                            {
                                nIndex = 0;
                            }

                            pomDC -> SetTextColor(DIALOG_COLOR);

                            // if comment is in betn the line,
                            // get uncommented chars
                            CString omStrTemp =
                                omStr.Left( nIndex );

                            // set uncommented char to blue
                            pomDC -> SetTextColor(BLUE_COLOR);

                            pomDC -> TextOut(DEFAULT_X_POS,
                                             (m_nCharHeight * (lInt+INCR_LEN)),
                                             acSourceLineNo);

                            pomDC -> TabbedTextOut(
                                ( nMargin) * m_nCharWidth,
                                (m_nCharHeight * (lInt+INCR_LEN)),
                                omStrTemp,
                                TAB_POSITION,
                                &nTabStopPositions,
                                TAB_ORIGIN);

                            nMargin += nIndex;
                            // Get commented text and set different color
                            pomDC -> SetTextColor(DIALOG_COLOR);
                            omStrTemp =
                                omStr.Right( omStr.GetLength() - (nIndex));
                            nIndex = omStrTemp.Find( "*/" );
                            omStr = "";

                            if ( nIndex != -1 )
                            {
                                // Set the comment flag to true
                                bWithInComment = FALSE;
                                omStr = omStrTemp.Right(
                                            omStrTemp.GetLength() - (nIndex+2));
                                omStrTemp = omStrTemp.Left( nIndex+2 );
                            }
                            else
                            {
                                // Reset the comment flag
                                bWithInComment = TRUE;
                            }

                            pomDC -> TextOut(DEFAULT_X_POS,
                                             (m_nCharHeight * (lInt+INCR_LEN)),
                                             acSourceLineNo);
                            pomDC -> TabbedTextOut(
                                ( nMargin) * m_nCharWidth,
                                (m_nCharHeight * (lInt+INCR_LEN)),
                                omStrTemp,
                                TAB_POSITION,
                                &nTabStopPositions,
                                TAB_ORIGIN);

                            nMargin += nIndex+2;
                            pomDC -> SetTextColor(BLUE_COLOR);
                        }
                        //else
                        {
                            nIndex = omStr.Find( "//" );
                            if (nIndex != -1 )
                            {
                                pomDC -> SetTextColor(DIALOG_COLOR);
                                // if comment is in betn the line,
                                // get uncommented chars
                                CString omStrTemp = omStr.Left( nIndex );
                                // set uncommented char to blue
                                pomDC -> SetTextColor(BLUE_COLOR);
                                pomDC -> TextOut(DEFAULT_X_POS,
                                                 (m_nCharHeight * (lInt+INCR_LEN)),
                                                 acSourceLineNo);
                                pomDC -> TabbedTextOut(
                                    ( nMargin) * m_nCharWidth,
                                    (m_nCharHeight * (lInt+INCR_LEN)),
                                    omStrTemp,
                                    TAB_POSITION,
                                    &nTabStopPositions,
                                    TAB_ORIGIN);
                                nMargin += nIndex;
                                // Get commented text and set different color
                                pomDC -> SetTextColor(DIALOG_COLOR);
                                omStrTemp =
                                    omStr.Right( omStr.GetLength() - (nIndex));

                                omStr = "";
                                pomDC -> TextOut(DEFAULT_X_POS,
                                                 (m_nCharHeight * (lInt+INCR_LEN)),
                                                 acSourceLineNo);
                                pomDC -> TabbedTextOut(
                                    ( nMargin) * m_nCharWidth,
                                    (m_nCharHeight * (lInt+INCR_LEN)),
                                    omStrTemp,
                                    TAB_POSITION,
                                    &nTabStopPositions,
                                    TAB_ORIGIN);

                                nMargin += nIndex + 2;
                                pomDC -> SetTextColor(BLUE_COLOR);
                            }
                            else
                            {
                                pomDC -> SetTextColor(BLUE_COLOR);
                            }
                        }

                        if(lCurrentWarnLineNum == lInt+NEXT_POSITION)
                        {
                            bWarningLine = TRUE;

                            // Get & save current color settings
                            CurrentTextColor = pomDC -> GetTextColor();
                            CurrentBkColor = pomDC -> GetBkColor();
                            // Set the background mix mode to
                            // opaque
                            pomDC -> SetBkMode(OPAQUE);

                            // Display the warning line in WHITE with RED
                            // Background
                            pomDC -> SetBkColor(RED_COLOR);
                            pomDC -> SetTextColor(WHITE_COLOR);
                        }

                        pomDC -> TextOut(DEFAULT_X_POS,
                                         (m_nCharHeight * (lInt+INCR_LEN)),
                                         acSourceLineNo);
                        pomDC -> TabbedTextOut(
                            nMargin * m_nCharWidth,
                            (m_nCharHeight * (lInt+INCR_LEN)),
                            omStr,
                            TAB_POSITION,
                            &nTabStopPositions,
                            TAB_ORIGIN);

                        // Restore normal display colors and background
                        // mix mode
                        if(bWarningLine == TRUE)
                        {
                            pomDC -> SetTextColor(CurrentTextColor);
                            pomDC -> SetBkColor(CurrentBkColor);
                            pomDC -> SetBkMode(TRANSPARENT);
                            bWarningLine = FALSE;
                        }

                    }// End of  for(long lInt = defCOUNT_INIT; lInt < lLin....

                }// End of if( Position!= nullptr)
            }// End of if(lLineCount  > defCOUNT_INIT)

            pomDC -> SelectObject(pomOldFont);
            omNewFont.DeleteObject();
        }
    } // end of if(pomDoc != nullptr)
}
Beispiel #13
0
BOOL CMsgHandlerDlg::OnInitDialog() 
{
    CDialog::OnInitDialog();
    
    vInitDlgWithBusSpecNames();
    m_odEditMsgIDTo.EnableWindow(FALSE);
    m_omListMsgName.EnableWindow(FALSE);
    m_odEditMsgIDFrom.EnableWindow(FALSE);
    m_odEditMsgID.EnableWindow(TRUE);
    m_omButtonApply.EnableWindow(FALSE);
    m_omButtonOK.EnableWindow(FALSE);
    m_odEditMsgID.vSetSigned(FALSE);

    m_odEditMsgIDTo.vSetSigned(FALSE);
    m_odEditMsgIDFrom.vSetSigned(FALSE);
    CheckDlgButton(IDC_RBTN_MSG_ID,BST_CHECKED);
    // Get all the message names of active DB
    
    CFunctionEditorDoc* pDoc = CGlobalObj::ouGetObj(m_eBus).podGetFunctionEditorDoc();
    CStringArray* pomStrArray = NULL;
    if (pDoc != NULL)
    {
        pomStrArray = pDoc->omStrGetMessageHandlerPrototypes();
    }
    if(pomStrArray != NULL )
    {
        POSITION pos = CGlobalObj::ouGetObj(m_eBus).m_odMsgNameMsgCodeList.GetHeadPosition();
        //UINT unNoOfMessages = ouGetMsgSignal().unGetNumerOfMessages();
        while (pos != NULL)
        {
            SMSG_NAME_CODE& sMsgNameCode = CGlobalObj::ouGetObj(m_eBus).m_odMsgNameMsgCodeList.
                                                            GetNext(pos);
            bAddMessageNameInListBox(pomStrArray, sMsgNameCode.m_omMsgName);
        }
    }

    //if ( unNoOfMessages > 0 )
    {
        
        //COMMENTED BY AK******************
        //ouGetMsgSignal().omStrListGetMessageNames(omMessageNames);

        //CMainFrame* pMainFrame = NULL;
        //pMainFrame             = (CMainFrame*)AfxGetMainWnd();
        //if(pMainFrame != NULL )
        //{

        //    CFunctionEditorDoc* pDoc = pMainFrame->CGlobalObj::podGetFunctionEditorDoc();
        //    if(pDoc != NULL )
        //    {

        //        CStringArray* pomStrArray = NULL;
        //        pomStrArray = pDoc->omStrGetMessageHandlerPrototypes();
        //        if(pomStrArray != NULL )
        //        {
        //            POSITION pos = omMessageNames.GetHeadPosition();
        //            // Insert every message name into the message list box
        //            CString omStrMsgName = _T("");

        //            while ( pos != NULL )
        //            {
        //
        //                omStrMsgName = omMessageNames.GetNext(pos);
        //                bAddMessageNameInListBox(pomStrArray,omStrMsgName);
        //  
        //            }
        //        }
        //    }
        //}
    }
    return TRUE;  // return TRUE unless you set the focus to a control
                  // EXCEPTION: OCX Property Pages should return FALSE
}
Beispiel #14
0
void CMsgHandlerDlg::OnCbtnMsgHandlerApply() 
{

    BOOL bValidateSelection = FALSE;
    UpdateData(TRUE);
    m_omButtonApply.EnableWindow(FALSE);
    m_omButtonOK.EnableWindow(FALSE);
    // Get document pointer
    CFunctionEditorDoc* pDoc = CGlobalObj::ouGetObj(m_eBus).podGetFunctionEditorDoc();
    if (NULL != pDoc)
    {
        SBUS_SPECIFIC_INFO sBusSpecInfo;
        pDoc->bGetBusSpecificInfo(sBusSpecInfo);
        // Validate user selections
        bValidateSelection = bValidateUserSelection(pDoc); 
        if (bValidateSelection == TRUE)
        {
            CString omFunc = CGlobalObj::omGetBusSpecMsgHndlrName(m_eBus);;
            // Add to function editor
            CString omSelectedText = _T("");

            omSelectedText = BUS_FN_HDR; // Start comment section: init
            omSelectedText.Replace(_T("PLACE_HODLER_FOR_BUSNAME"), 
                             sBusSpecInfo.m_omBusName); // Replace the bus name

            omFunc += m_omStrSelectedItemText;
            omSelectedText.Replace( _T("PLACE_HODLER_FOR_FUNCTIONNAME"),
                omFunc );
            pDoc->m_omSourceCodeTextList.AddTail( omSelectedText );
            // Form the function prototype
            omSelectedText  = m_omStrSelectedItemText;
            int nIndex = -1;
            

            // Get the type and set the parameter type
            BOOL bIsMsgSpecificHandler = FALSE;
            //Find out whether the Msg handler is DatabaseMsgName type or ID type
            CString omMsgHandlerType = CGlobalObj::ouGetObj(m_eBus).m_omMsgStructName;
            nIndex = omSelectedText.Find(defSTR_MSG_SPECIFIC_HANDLER);
            
            if( nIndex != -1 )
            {
                bIsMsgSpecificHandler = TRUE;
                // For database message type is equal same as msg name
                omMsgHandlerType = omSelectedText.Mid( nIndex +
                                                     defMESSAGE_NAME_INDEX );
            }
            CString omStrParamtype;
            
            if (bIsMsgSpecificHandler == TRUE && (m_eBus == CAN))
            {
                omStrParamtype = omMsgHandlerType;
            }
            else// For Msg ID, Range and generic messages the type is sTCANDATA
            {
                omStrParamtype = CGlobalObj::ouGetObj(m_eBus).m_omMsgStructName;
            }
            CString omFormatString = m_eBus == CAN ? defDEFAULT_MSG_HANDLER_CODE_CAN : defDEFAULT_MSG_HANDLER_CODE;
            omSelectedText.Format(  omFormatString,
                                    CGlobalObj::omGetBusSpecMsgHndlrName(sBusSpecInfo.m_eBus),
                                    omSelectedText,   // Fun name
                                    omStrParamtype ); // Parameter type

            pDoc->m_omSourceCodeTextList.AddTail( omSelectedText );

            CString omStrPrototype = omSelectedText;
            // Add to tree view
            CFnsTreeView* pomTreeView = CGlobalObj::ouGetObj(m_eBus).podGetFuncsTreeViewPtr();
            if(pomTreeView != NULL )
            {
                // Add the prototype to the tree view
                CTreeCtrl& omTree = pomTreeView->GetTreeCtrl();
                HTREEITEM hItem = omTree.GetSelectedItem();
                HTREEITEM hNew = 
                    omTree.InsertItem( omSelectedText, hItem);
                omTree.SetItemImage( hNew, 5, 5 );
                omTree.SelectItem( hNew );
                // Form the body of the function
                omSelectedText = "{";
                pDoc->m_omSourceCodeTextList.AddTail( omSelectedText );
                if (CGlobalObj::ouGetObj(m_eBus).m_omMsgStructName.IsEmpty())
                {
                    ASSERT(FALSE);
                }
                omSelectedText = defTODO;
                pDoc->m_omSourceCodeTextList.AddTail( omSelectedText );

                // Form the function footer
                omSelectedText = BUS_FN_FOOTER;
                omSelectedText.Replace(_T("PLACE_HODLER_FOR_BUSNAME"), sBusSpecInfo.m_omBusName);
                omSelectedText.Replace( _T("PLACE_HODLER_FOR_FUNCTIONNAME"),
                    omFunc );

                pDoc->m_omSourceCodeTextList.AddTail( omSelectedText );

                CStringArray* pMsgArray = 
                    pDoc->omStrGetMessageHandlerPrototypes();
                if ( pMsgArray != NULL )
                {
                    pMsgArray->Add( omStrPrototype );
                }
                pDoc->UpdateAllViews( NULL );
                pDoc->SetModifiedFlag( TRUE );
            }
        }
    }
    m_omStrSelectedItemText = _T("");
    BOOL bButtonChecked  = FALSE;
    bButtonChecked =  IsDlgButtonChecked(IDC_RBTN_MSG_NAME);
    if(bButtonChecked != FALSE )
    {
         m_omListMsgName.SetCurSel(-1);
    }
}