示例#1
0
void		TMDIChild::InitFrm(WorkSpace	*	workSpace, IParseEngine * engine)
{
    m_ParseEngine = engine;
    m_WorkSpace = workSpace;
    m_WorkSpace->GetFileManager()->BindView(lvWorkSpace);
    m_bTreeModify = false;
    m_WorkSpace->Open();

    SetModify();


    //初始化
    m_ParseTree = new ParseTree(m_ParseEngine, m_WorkSpace->GetClassManager());

    if(lvWorkSpace->Items->Count == 0)
    {
        actNewVersionExecute(NULL);
    }
    else
    {
        lvWorkSpace->ItemIndex = 0;
        LoadCurWork();
    }


    //绑定树控件
    m_ParseTree->BindView(tvParseTree->Items);

    m_bFastParseMode = false;
    m_FastParsePos = 0;

    String      structName = workSpace->GetStructName();
    if(structName != "")
    {
        bool  needAddStruct = true;
        for(int i=0; i<workSpace->GetClassManager()->GetClassCount(); i++)
        {
            if(workSpace->GetClassManager()->GetClassDataByIndex(i)->GetName() == structName)
            {
                needAddStruct = false;
                break;
            }
        }

        if(needAddStruct)
        {
            ClassData *curClass = m_WorkSpace->GetClassManager()->AddClass();
            curClass->Init(structName, workSpace->GetComment());
            int index = m_WorkSpace->GetClassManager()->GetClassIndexByClassData(curClass);
            RefreshAllClassView();
            lvAllClasses->ItemIndex = index;
            lvAllClassesClick(NULL);
        }
    }
}
示例#2
0
void __fastcall 	TMDIChild::FastParseExecute(TObject *Sender)
{
    TMenuItem * selMenu = (TMenuItem * )Sender;
    String typeName = selMenu->Caption;

    //修正typeName
    if(selMenu->Caption == "-")
        return;

    if(typeName.Pos("["))
        typeName = LeftString(typeName, "[");

    ClassData * curClass = GetCurParseClass();

//	bool	haveResult = false;
    String 	defaultName;
    if(curClass == NULL)
    {
        //当前无结构体, 新建结构体
        int classCount = m_WorkSpace->GetClassManager()->GetClassCount();
        defaultName = FormatStr("tagUnNamedStruct%d", classCount);

        curClass = m_WorkSpace->GetClassManager()->AddClass();
        curClass->Init(defaultName, "");
        RefreshAllClassView();
    }

    String arrayVar;
    if(selMenu->Tag == 0)
        arrayVar = "";
    else
        arrayVar = IntToStr(selMenu->Tag);

    ClassMember * curMember = curClass->AddMember();
    defaultName = FormatStr("UnKnown%d", m_ParseTree->GetSize() + m_FastParsePos);

    curMember->Init(typeName, defaultName, "", arrayVar);

    m_ParseTree->BindClass(curClass);
    ExpandFirstNode();
    ParseData(false);

    tagSelRect	selRect;
    if(GetTreeSelRect(selRect) == false)
        return;
    GotoPosition(selRect.SelStart + selRect.SelLength);
}