⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wxsproject.cpp

📁 非常好用的可移植的多平台C/C++源代码编辑器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    else if ( Type == _T("Frame") )
    {
        Res = new wxsFrameRes(this,EditMode,ClassName,RealFileName,SourceName,HeaderName,XrcName);
    }

    if ( !Res )
    {
        Manager::Get()->GetMessageManager()->Log(_("Couldn't create new resource"));
        return;
    }

    Res->Load();

    // Validating and correcting resource

    Res->UpdateWidgetsVarNameId();
    if ( !Res->CheckBaseProperties(true) )
    {
    	wxMessageBox(wxString::Format(_("Corrected some invalid properties for resource '%s'.\n"),Res->GetResourceName().c_str()));
    	Res->NotifyChange();
    }

    if ( Type == _T("Dialog") )
    {
        Dialogs.push_back((wxsDialogRes*)Res);
    }
    else if ( Type == _T("Panel") )
    {
        Panels.push_back((wxsPanelRes*)Res);
    }
    else if ( Type == _T("Frame") )
    {
        Frames.push_back((wxsFrameRes*)Res);
    }

    SetModified(true);
}

bool wxsProject::CheckProjFileExists(const wxString& FileName)
{
    if ( !Project ) return false;
    return Project->GetFileByFilename(FileName) != NULL;
}

TiXmlDocument* wxsProject::GenerateXml()
{
    if ( !Project ) return NULL;
    if ( Integration != Integrated ) return NULL;

    TiXmlDocument* Doc = new TiXmlDocument();
    TiXmlNode* Elem = Doc->InsertEndChild(TiXmlElement("wxsmith"));

    for ( DialogListI i = Dialogs.begin(); i!=Dialogs.end(); ++i )
    {
        TiXmlElement Dlg(XML_DIALOG_STR);
        wxsDialogRes* Sett = *i;
        wxFileName WxsFile(Sett->GetWxsFile());
        WxsFile.MakeRelativeTo(WorkingPath.GetPath());
        Dlg.SetAttribute(XML_FNAME_STR,WxsFile.GetFullPath().mb_str());
        Dlg.SetAttribute(XML_CNAME_STR,Sett->GetClassName().mb_str());
        Dlg.SetAttribute(XML_SFILE_STR,Sett->GetSourceFile().mb_str());
        Dlg.SetAttribute(XML_HFILE_STR,Sett->GetHeaderFile().mb_str());
        Dlg.SetAttribute(XML_XRCFILE_STR,Sett->GetXrcFile().mb_str());
        Dlg.SetAttribute(XML_EDITMODE_STR,Sett->GetEditMode()==wxsResSource?"Source":"Xrc");
        Elem->InsertEndChild(Dlg);
    }

    for ( FrameListI i = Frames.begin(); i!=Frames.end(); ++i )
    {
        TiXmlElement Frm(XML_FRAME_STR);
        wxsFrameRes* Sett = *i;
        wxFileName WxsFile(Sett->GetWxsFile());
        WxsFile.MakeRelativeTo(WorkingPath.GetPath());
        Frm.SetAttribute(XML_FNAME_STR,WxsFile.GetFullPath().mb_str());
        Frm.SetAttribute(XML_CNAME_STR,Sett->GetClassName().mb_str());
        Frm.SetAttribute(XML_SFILE_STR,Sett->GetSourceFile().mb_str());
        Frm.SetAttribute(XML_HFILE_STR,Sett->GetHeaderFile().mb_str());
        Frm.SetAttribute(XML_XRCFILE_STR,Sett->GetWxsFile().mb_str());
        Frm.SetAttribute(XML_EDITMODE_STR,Sett->GetEditMode()==wxsResSource?"Source":"Xrc");
        Elem->InsertEndChild(Frm);
    }

    for ( PanelListI i = Panels.begin(); i!=Panels.end(); ++i )
    {
        TiXmlElement Pan(XML_PANEL_STR);
        wxsPanelRes* Sett = *i;
        wxFileName WxsFile(Sett->GetWxsFile());
        WxsFile.MakeRelativeTo(WorkingPath.GetPath());
        Pan.SetAttribute(XML_FNAME_STR,WxsFile.GetFullPath().mb_str());
        Pan.SetAttribute(XML_CNAME_STR,Sett->GetClassName().mb_str());
        Pan.SetAttribute(XML_SFILE_STR,Sett->GetSourceFile().mb_str());
        Pan.SetAttribute(XML_HFILE_STR,Sett->GetHeaderFile().mb_str());
        Pan.SetAttribute(XML_XRCFILE_STR,Sett->GetWxsFile().mb_str());
        Pan.SetAttribute(XML_EDITMODE_STR,Sett->GetEditMode()==wxsResSource?"Source":"Xrc");
        Elem->InsertEndChild(Pan);
    }

    return Doc;
}

void wxsProject::SaveProject()
{

    if ( Integration != Integrated ) return;
    if ( !GetModified() ) return;

    WorkingPath.SetName(wxSmithMainConfigFile);
    WorkingPath.SetExt(_T(""));
    WorkingPath.Assign(WorkingPath.GetFullPath());  // Reparsing path

    TiXmlDocument* Doc = GenerateXml();

    if ( Doc )
    {
        Doc->SaveFile(WorkingPath.GetFullPath().mb_str());
        delete Doc;
    }

    SetModified(false);
}

void wxsProject::DeleteDialog(wxsDialogRes* Resource)
{
    if ( DuringClear ) return;

    DialogListI i;
    for ( i=Dialogs.begin(); i!=Dialogs.end(); ++i ) if ( *i == Resource ) break;
    if ( i == Dialogs.end() ) return;
    Dialogs.erase(i);
}

void wxsProject::DeleteFrame(wxsFrameRes* Resource)
{
    if ( DuringClear ) return;

    FrameListI i;
    for ( i=Frames.begin(); i!=Frames.end(); ++i ) if ( *i == Resource ) break;
    if ( i == Frames.end() ) return;
    Frames.erase(i);
}

void wxsProject::DeletePanel(wxsPanelRes* Resource)
{
    if ( DuringClear ) return;

    PanelListI i;
    for ( i=Panels.begin(); i!=Panels.end(); ++i ) if ( *i == Resource ) break;
    if ( i == Panels.end() ) return;
    Panels.erase(i);
}

wxString wxsProject::GetInternalFileName(const wxString& FileName)
{
	wxFileName Path = WorkingPath;
    Path.SetName(FileName);
    Path.SetExt(_T(""));
    Path.Assign(Path.GetFullPath());  // Reparsing path
    return Path.GetFullPath();
}

wxString wxsProject::GetProjectFileName(const wxString& FileName)
{
	wxFileName Path = ProjectPath;
    Path.SetName(FileName);
    Path.SetExt(_T(""));
    Path.Assign(Path.GetFullPath());
    return Path.GetFullPath();
}

bool wxsProject::AddSmithConfig()
{
    if ( GetIntegration() != NotWxsProject ) return false;

    if ( ! wxFileName::Mkdir(WorkingPath.GetPath(wxPATH_GET_VOLUME),0744,wxPATH_MKDIR_FULL) )
    {
        wxMessageBox(_("Couldn't create wxsmith directory in main projet's path"),_("Error"),wxOK|wxICON_ERROR);
        return false;
    }

    Integration = Integrated;

    SetModified(true);
    SaveProject();

    BuildTree(wxsTREE(),TreeItem);

    return true;
}

void wxsProject::AddDialog(wxsDialogRes* Dialog)
{
    if ( !Dialog ) return;
    Dialogs.push_back(Dialog);
    Dialog->BuildTree(wxsTREE(), DialogId, true);
    SetModified(true);
}

void wxsProject::AddFrame(wxsFrameRes* Frame)
{
    if ( !Frame ) return;
    Frames.push_back(Frame);
    Frame->BuildTree(wxsTREE(), FrameId, true);
    SetModified(true);
}

void wxsProject::AddPanel(wxsPanelRes* Panel)
{
    if ( !Panel ) return;
    Panels.push_back(Panel);
    Panel->BuildTree(wxsTREE(), PanelId, true);
    SetModified(true);
}

wxsResource* wxsProject::FindResource(const wxString& Name)
{
    for ( DialogListI i = Dialogs.begin(); i!=Dialogs.end(); ++i )
    {
        if ( (*i)->GetResourceName() == Name ) return *i;
    }

    for ( FrameListI i = Frames.begin(); i!=Frames.end(); ++i )
    {
        if ( (*i)->GetResourceName() == Name ) return *i;
    }

    for ( PanelListI i = Panels.begin(); i!=Panels.end(); ++i )
    {
        if ( (*i)->GetResourceName() == Name ) return *i;
    }

    return NULL;

}

void wxsProject::SendEventToEditors(wxEvent& event)
{
    for ( DialogListI i = Dialogs.begin(); i!=Dialogs.end(); ++i )
    {
        if ( (*i)->GetEditor() )
        {
        	(*i)->GetEditor()->ProcessEvent(event);
        }
    }

    for ( FrameListI i = Frames.begin(); i!=Frames.end(); ++i )
    {
        if ( (*i)->GetEditor() )
        {
        	(*i)->GetEditor()->ProcessEvent(event);
        }
    }

    for ( PanelListI i = Panels.begin(); i!=Panels.end(); ++i )
    {
        if ( (*i)->GetEditor() )
        {
        	(*i)->GetEditor()->ProcessEvent(event);
        }
    }
}

wxsResourceTreeData::~wxsResourceTreeData()
{
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -