コード例 #1
0
wxString ecUtils::StripExtraWhitespace (const wxString & strInput)
{
    wxString strOutput;
    wxChar* o=strOutput.GetWriteBuf(1+strInput.Len());
    for(const wxChar* c=strInput.GetData();*c;c++){
        if(ecIsSpace(*c)){
            *o++=wxT(' ');
            if (ecIsSpace(c[1])){
                for(c=c+2; ecIsSpace(*c);c++);
                c--;
            }
        } else {
            *o++=*c;
        }
    }
    *o=0;
    strOutput.UngetWriteBuf();
    strOutput.Trim(TRUE);
    strOutput.Trim(FALSE);
    return strOutput;
#if 0    
    wxString strOutput;
    LPTSTR o=strOutput.GetBuffer(1+strInput.GetLength());
    for(LPCTSTR c=strInput;*c;c++){
        if(_istspace(*c)){
            *o++=_TCHAR(' ');
            if (_istspace(c[1])){
                for(c=c+2;_istspace(*c);c++);
                c--;
            }
        } else {
            *o++=*c;
        }
    }
    *o=0;
    strOutput.ReleaseBuffer();
    strOutput.TrimLeft();
    strOutput.TrimRight();
    return strOutput;
#endif
}
コード例 #2
0
ファイル: DrawProgDoc.cpp プロジェクト: kamilWLca/brix
bool DrawProgDoc::OnOpenDocument(const wxString& filename)
{
	INXString filename;
	int len;
	int response;
#ifdef _UNUSED_FUNCTIONS_TO_LOAD_THE_FILE
	CLabLgbBaseApp *pApp = ( CLabLgbBaseApp * ) AfxGetApp();
	double dFreeDiskSpace = pApp->MyGetFreeDiskSpaceMB();
	if (dFreeDiskSpace < DISK_SPACE_WARNING_MB) {
		response = AfxMessageBox("Warning, less than 50MB of free disk space remaining.\nYou may not be able save your work.\nContinue?",MB_YESNO | MB_ICONWARNING);
		if (response == IDNO) {
			return FALSE;
		}
	} else if (dFreeDiskSpace < DISK_SPACE_CRITICAL_MB) {
		AfxMessageBox("Unable to open project, less than 10MB of free disk space remaining.",MB_ICONWARNING);
		return FALSE;
	}
#endif


	// Extract filename
	filename = (INXString)lpszPathName;
	//filename = filename.SpanExcluding(".");
	filename.MakeReverse();
	filename = filename.SpanExcluding("\\");
	filename.MakeReverse();
	// remove .prg to get filename
	len = filename.GetLength() - 4;
	filename = filename.Left(len);

	if (!wxDocument::OnOpenDocument(lpszPathName))
		return FALSE;
	
	// TODO: Add your specialized creation code here
	POSITION pos = GetFirstViewPosition();
	DrawProgView* pView = (DrawProgView*) GetNextView(pos);
	
	if (pFrame->m_wndProjectBar.m_cProjTree.openProject) {
		pProject = pFrame->m_wndProjectBar.m_cProjTree.openProj;
	}
	else {
		pProject = pFrame->m_wndProjectBar.m_cProjTree.GetProjectPtr(pFrame->m_wndProjectBar.m_cProjTree.hSelItem);
	}

	// Check Folder Structure
	INXString csProjDir;

	pProject->pProjMData->initProjFolderMinder(); 

	if(pProject->pProjMData->folderStructureNotOk()){
		AfxMessageBox("Unable to open this project, because the directory structure is invalid");
		return kErr_InvalidFolderStructure;
	}



	// Create DEP, load and initialise
	pDEP = pProject->AddDEP();
	pDEP->LoadProg((INXString)lpszPathName);
	pDEP->InitTagLists();
	pDEP->depFilename = filename;
	// Populate project tree if opening a project. Uses the loaded DEP to populate the tree
	if (pFrame->m_wndProjectBar.m_cProjTree.openProject) {
		pFrame->m_wndProjectBar.m_cProjTree.PopulateProjectTree(pDEP->condata, pProject);
	}
	pDEP->hItem = pFrame->m_wndProjectBar.m_cProjTree.hSelItem;

	// Set the project and DEP pointers in the view
	pView->pProject = pProject;
	pView->pDEP = pDEP;
	pView->RedrawWindow();

	// Need to initialise undo for case when the view is already open
	pView->initUndo();

	return true;
}