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

📄 configtool.cpp

📁 ecos实时嵌入式操作系统
💻 CPP
📖 第 1 页 / 共 4 页
字号:
            wxString msg;            msg.Printf("%s is neither a project file nor a valid repository.", (const wxChar*) filenameToOpen1);            wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);            return FALSE;        }        // Look at the second file, if any        if (parser.GetParamCount() > 1)        {            if (ext2 == "ecc" || ext2 == "ECC")            {                if (wxFileExists(filenameToOpen2))                {                    if (gotSavefile)                    {                        wxString msg;                        msg.Printf("%s is a second save file -- please supply only one.", (const wxChar*) filenameToOpen2);                        wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);                        return FALSE;                    }                                        gotSavefile = TRUE;                    saveFile = filenameToOpen2;                }                else                {                    wxString msg;                    msg.Printf("%s is not a valid file.", (const wxChar*) filenameToOpen2);                    wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);                    return FALSE;                }            }            else if (!gotSavefile && wxDirExists(filenameToOpen2) && FindSaveFileInDir(filenameToOpen2, tmpSaveFile))            {                saveFile = tmpSaveFile;                gotSavefile = TRUE;            }            else if ((name2 == wxT("ecos") && ext2 == wxT("db") && wxFileExists(filenameToOpen2)) || wxDirExists(filenameToOpen2))            {                if (gotRepository)                {                    wxString msg;                    msg.Printf("%s is a second repository -- please supply only one.", (const wxChar*) filenameToOpen2);                    wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);                    return FALSE;                }                                           // It's a repository (we hope).                if (name1 == wxT("ecos") && ext1 == wxT("db"))                {                    // Go two steps up                    filenameToOpen2 = wxPathOnly(filenameToOpen2);                    filenameToOpen2 = wxPathOnly(filenameToOpen2);                }                else                {                    // If it's the packages directory, we need to strip off                    // a directory                    wxString eccPath(filenameToOpen2 + wxString(wxFILE_SEP_PATH) + wxT("ecc"));                                        // Don't strip off ecc if it's the CVS repository (with ecc below it)                    if (name2 == wxT("packages") || (name2 == wxT("ecc") && !wxDirExists(eccPath)))                        filenameToOpen2 = wxPathOnly(filenameToOpen2);                }                                repositoryDir = filenameToOpen2;                gotRepository = TRUE;            }            else            {                wxString msg;                msg.Printf("%s is neither a project file nor a valid repository.", (const wxChar*) filenameToOpen2);                wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);                return FALSE;            }        }                // Now we have looked at the two files and decided what they are; let's        // act on it.        if (gotRepository)        {            GetSettings().m_strRepository = repositoryDir;        }        if (!gotSavefile)        {            // See if there's a save file in the current dir            if (FindSaveFileInDir(currentDir, saveFile))                gotSavefile = TRUE;        }        if (gotSavefile)        {            // The repository will be loaded from m_strRepository, possibly set above.            m_docManager->CreateDocument(saveFile, wxDOC_SILENT);        }        else        {            // Create a new file            m_docManager->CreateDocument(wxString(""), wxDOC_NEW);        }        if (compileHelpOnly)        {            if (!gotRepository)            {                wxString msg;                msg.Printf(wxT("Please specify a repository when using the --compile-help option."));                wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);                return FALSE;            }            ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();            if (doc)            {                if (!doc->RebuildHelpIndex(TRUE))                {                    wxString msg;                    msg.Printf(wxT("Sorry, there was a problem compiling the help index."));                    wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);                    return FALSE;                }            }            else            {                wxString msg;                msg.Printf(wxT("Sorry, there was no current document when compiling the help index."));                wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);                return FALSE;            }            // Return FALSE in order to quit the application            return FALSE;        }    }    else    {        if (GetSettings().m_strRepository.IsEmpty()) // first invocation by this user        {            // we have no clues as to the location of the repository so            // test for ../../packages relative to the configtool location            wxFileName repository = wxFileName (m_appDir, wxEmptyString);            repository.Normalize(); // remove trailing "./" if present            repository.RemoveDir (repository.GetDirCount()-1);            repository.RemoveDir (repository.GetDirCount()-1);            repository.AppendDir (wxT("packages"));            if (repository.DirExists()) // we've found a repository            {                repository.RemoveDir (repository.GetDirCount()-1);                GetSettings().m_strRepository = repository.GetFullPath();            }        }        m_docManager->CreateDocument(wxString(""), wxDOC_NEW);    }    return TRUE;}// Load resources from diskbool ecApp::LoadResources(){    wxFileSystem::AddHandler(new wxMemoryFSHandler);//    LoadBitmapResource(m_splashScreenBitmap, wxT("splash16.png"), wxBITMAP_TYPE_PNG, FALSE);//    wxBitmap bitmap1, bitmap2, bitmap3;//    LoadBitmapResource(bitmap1, wxT("ecoslogo.png"), wxBITMAP_TYPE_PNG, TRUE);//    LoadBitmapResource(bitmap2, wxT("ecoslogosmall.png"), wxBITMAP_TYPE_PNG, TRUE);//    LoadBitmapResource(bitmap3, wxT("rhlogo.png"), wxBITMAP_TYPE_PNG, TRUE);//    wxString aboutText;//    LoadTextResource(aboutText, wxT("about.htm"), TRUE);//    VersionStampSplashScreen();    return TRUE;}// Load resources from zip resource file or diskbool ecApp::LoadBitmapResource(wxBitmap& bitmap, const wxString& filename, int bitmapType, bool addToMemoryFS){    wxString archive(GetFullAppPath(wxT("configtool.bin")));#if wxUSE_STREAMS && wxUSE_ZIPSTREAM && wxUSE_ZLIB    wxFSFile* file = m_fileSystem->OpenFile(archive + wxString(wxT("#zip:")) + filename);    if (file)    {        wxInputStream* stream = file->GetStream();                wxImage image(* stream, bitmapType);        bitmap = image.ConvertToBitmap();                delete file;    }#endif#ifdef __WXMSW__    if (!bitmap.Ok())        bitmap.LoadFile(filename, wxBITMAP_TYPE_BMP_RESOURCE);#endif    if (!bitmap.Ok() && wxFileExists(GetFullAppPath(filename)))        bitmap.LoadFile(GetFullAppPath(filename), bitmapType);    if (bitmap.Ok() && addToMemoryFS)        wxMemoryFSHandler::AddFile(filename, bitmap, bitmapType);    return bitmap.Ok();}// Load resources from zip resource file or diskbool ecApp::LoadTextResource(wxString& text, const wxString& filename, bool addToMemoryFS){    wxString archive(GetFullAppPath(wxT("configtool.bin")));    bool success = FALSE;#if wxUSE_STREAMS && wxUSE_ZIPSTREAM && wxUSE_ZLIB    wxFSFile* file = m_fileSystem->OpenFile(archive + wxString(wxT("#zip:")) + filename);    if (file)    {        wxInputStream* stream = file->GetStream();        char* buf = text.GetWriteBuf(stream->GetSize() + 1);        stream->Read((void*) buf, stream->GetSize());        buf[stream->GetSize()] = 0;        text.UngetWriteBuf();        success = TRUE;                delete file;    }#endif    if (!success && wxFileExists(GetFullAppPath(filename)))    {        wxFileInputStream str(GetFullAppPath(filename));        char* buf = text.GetWriteBuf(str.GetSize() + 1);        str.Read((void*) buf, str.GetSize());        buf[str.GetSize()] = 0;        text.UngetWriteBuf();        success = TRUE;    }    if (success && addToMemoryFS)        wxMemoryFSHandler::AddFile(filename, text);    return success;}// Get a text resource from the memory filesystembool ecApp::GetMemoryTextResource(const wxString& filename, wxString& text){    wxString s(wxString(wxT("memory:")) + filename);    wxFSFile* file = wxGetApp().GetFileSystem()->OpenFile(s);    if (file)    {        wxInputStream* stream = file->GetStream();        char* buf = text.GetWriteBuf(stream->GetSize() + 1);        stream->Read((void*) buf, stream->GetSize());        buf[stream->GetSize()] = 0;        text.UngetWriteBuf();        delete file;        return TRUE;    }    else        return FALSE;}// Version-stamp the splash screenbool ecApp::VersionStampSplashScreen(){    if (m_splashScreenBitmap.Ok())    {        wxMemoryDC dc;        dc.SelectObject(m_splashScreenBitmap);        wxColour textColour(19, 49, 4);        dc.SetTextForeground(textColour);        dc.SetBackgroundMode(wxTRANSPARENT);        dc.SetFont(wxFont(11, wxSWISS, wxNORMAL, wxBOLD, FALSE));        // Bottom left of area to start drawing at        wxString verString;        verString.Printf("%s", ecCONFIGURATION_TOOL_VERSION);        int x = 339; int y = 231;#ifdef __WXMSW__        y += 5; // For some reason#endif        int w, h;        dc.GetTextExtent(verString, & w, & h);        dc.DrawText(verString, x, y - h);        dc.SelectObject(wxNullBitmap);        return TRUE;    }    else        return FALSE;}// Initialize window settings objectbool ecApp::InitializeWindowSettings(bool beforeWindowConstruction){    wxWindowSettings& settings = GetSettings().m_windowSettings;    ecMainFrame* frame = GetMainFrame();    if (beforeWindowConstruction)    {        settings.Add(wxT("Configuration"));               settings.Add(wxT("Short Description"));        settings.Add(wxT("Output"));        settings.Add(wxT("Properties"));        settings.Add(wxT("Conflicts"));    }    else    {        wxArrayPtrVoid arr;        arr.Add(frame->GetTreeCtrl());        arr.Add(frame->GetValueWindow());        settings.SetWindows(wxT("Configuration"), arr);        settings.SetWindow(wxT("Short Description"), frame->GetShortDescriptionWindow());        settings.SetWindow(wxT("Output"), frame->GetOutputWindow());        settings.SetWindow(wxT("Properties"), frame->GetPropertyListWindow());        settings.SetWindow(wxT("Conflicts"), frame->GetConflictsWindow());    }    return TRUE;}bool ecApp::InitializeHelpController(){    if (m_helpController)        delete m_helpController;    m_helpController = new wxHelpController;    if (!m_helpController->Initialize(GetHelpFile()))    {        // TODO        return FALSE;    }    else    {        // Tell the help controller where the repository documentation is.        // For now, just keep this to myself since it uses hacks to wxWin        ecConfigToolDoc* doc = GetConfigToolDoc();        // No longer using relative paths#if 0        if (doc)        {            wxString htmlDir = wxString(doc->GetRepository()) + wxString(wxT("/doc/html"));            if (!wxDirExists(htmlDir))                htmlDir = wxString(doc->GetRepository()) + wxString(wxT("/doc"));            htmlDir += wxString(wxT("/"));            wxGetApp().GetHelpController().SetBookBasePath(htmlDir);        }#endif        return TRUE;    }}// Check if there is a (unique) .ecc file in dirbool ecApp::FindSaveFileInDir(const wxString& dir, wxString& saveFile){    wxDir fileFind;        if (!fileFind.Open(dir))        return FALSE;        wxString wildcard = wxT(".ecc");       wxString filename;    bool found = fileFind.GetFirst (& filename, wildcard);    if (found)    {        // Fail if there was more than one matching file.        wxString filename2;        if (fileFind.GetNext (& filename2))            return FALSE;        else        {

⌨️ 快捷键说明

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