예제 #1
0
BOOL CCrystalTextBuffer::InternalDeleteText(CCrystalTextView *pSource, int nStartLine, int nStartChar, int nEndLine, int nEndChar)
{
	ASSERT(m_bInit);	//	Text buffer not yet initialized.
						//	You must call InitNew() or LoadFromFile() first!
	ASSERT(nStartLine >= 0 && nStartLine < m_aLines.GetSize());
	ASSERT(nStartChar >= 0 && nStartChar <= m_aLines[nStartLine].m_nLength);
	ASSERT(nEndLine >= 0 && nEndLine < m_aLines.GetSize());
	ASSERT(nEndChar >= 0 && nEndChar <= m_aLines[nEndLine].m_nLength);
	ASSERT(nStartLine < nEndLine || nStartLine == nEndLine && nStartChar < nEndChar);
	if (m_bReadOnly)
		return FALSE;

	CDeleteContext context;
	context.m_ptStart.y = nStartLine;
	context.m_ptStart.x = nStartChar;
	context.m_ptEnd.y = nEndLine;
	context.m_ptEnd.x = nEndChar;
	if (nStartLine == nEndLine)
	{
		SLineInfo &li = m_aLines[nStartLine];
		if (nEndChar < li.m_nLength)
		{
			memcpy(li.m_pcLine + nStartChar, li.m_pcLine + nEndChar,
					sizeof(TCHAR) * (li.m_nLength - nEndChar));
		}
		li.m_nLength -= (nEndChar - nStartChar);

		UpdateViews(pSource, &context, UPDATE_SINGLELINE | UPDATE_HORZRANGE, nStartLine);
	}
	else
	{
		int nRestCount = m_aLines[nEndLine].m_nLength - nEndChar;
		LPTSTR pszRestChars = NULL;
		if (nRestCount > 0)
		{
			pszRestChars = new TCHAR[nRestCount];
			memcpy(pszRestChars, m_aLines[nEndLine].m_pcLine + nEndChar, nRestCount * sizeof(TCHAR));
		}

		int nDelCount = nEndLine - nStartLine;
		for (int L = nStartLine + 1; L <= nEndLine; L ++)
			delete m_aLines[L].m_pcLine;
		m_aLines.RemoveAt(nStartLine + 1, nDelCount);

		//	nEndLine is no more valid
		m_aLines[nStartLine].m_nLength = nStartChar;
		if (nRestCount > 0)
		{
			AppendLine(nStartLine, pszRestChars, nRestCount);
			delete pszRestChars;
		}

		UpdateViews(pSource, &context, UPDATE_HORZRANGE | UPDATE_VERTRANGE, nStartLine);
	}

	if (! m_bModified)
		SetModified(TRUE);
	return TRUE;
}
예제 #2
0
void CCrystalTextBuffer::SetLineFlag(int nLine, DWORD dwFlag, BOOL bSet, BOOL bRemoveFromPreviousLine /*= TRUE*/)
{
	ASSERT(m_bInit);	//	Text buffer not yet initialized.
						//	You must call InitNew() or LoadFromFile() first!
	int nFlagIndex = ::FlagToIndex(dwFlag);
	if (nFlagIndex < 0)
	{
		ASSERT(FALSE);		//	Invalid flag passed in
		return;
	}

	if (nLine == -1)
	{
		ASSERT(! bSet);
		nLine = FindLineWithFlag(dwFlag);
		if (nLine == -1)
			return;
		bRemoveFromPreviousLine = FALSE;
	}

	DWORD dwNewFlags = m_aLines[nLine].m_dwFlags;
	if (bSet)
		dwNewFlags = dwNewFlags | dwFlag;
	else
		dwNewFlags = dwNewFlags & ~dwFlag;

	if (m_aLines[nLine].m_dwFlags != dwNewFlags)
	{
		if (bRemoveFromPreviousLine)
		{
			int nPrevLine = FindLineWithFlag(dwFlag);
			if (bSet)
			{
				if (nPrevLine >= 0)
				{
					ASSERT((m_aLines[nPrevLine].m_dwFlags & dwFlag) != 0);
					m_aLines[nPrevLine].m_dwFlags &= ~dwFlag;
					UpdateViews(NULL, NULL, UPDATE_SINGLELINE | UPDATE_FLAGSONLY, nPrevLine);
				}
			}
			else
			{
				ASSERT(nPrevLine == nLine);
			}
		}

		m_aLines[nLine].m_dwFlags = dwNewFlags;
		UpdateViews(NULL, NULL, UPDATE_SINGLELINE | UPDATE_FLAGSONLY, nLine);
	}
}
예제 #3
0
void CApplicationImpl::NewItem(int nModuleId, int nParentId, LPCTSTR szName, LPCTSTR szContent)
{
	if (szContent == NULL || szContent[0] == 0)
	{
		ThrowError(_T("Empty content"));
	}
	CModule* pModule = CModuleLoader::Get().FindModule(nModuleId);
	assert(pModule != NULL);
	if (pModule == NULL)
	{
		ThrowError(strutils::format(_T("Module with %d id not found"), nModuleId).c_str());
	}
	if (nParentId == 0)
	{
		int nCurModuleId = m_spMainView->GetCurModule()->GetId();
		if (nCurModuleId == nModuleId)
		{
			nParentId = m_spMainView->GetCurFolder();
		}
		else
		{
			nParentId = m_spMainView->GetRootFolder(nModuleId);
		}
	}
	int nNewItemId = CItems::New(szName, szContent, nParentId, FALSE, nModuleId);
	pModule->pModuleInfo->OnNewItem(nNewItemId, nParentId);
		
	UpdateViews(UNM_ITEM_ADDED, nNewItemId, nParentId);
}
BOOL CPostcodeCityBrowse::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
{
	if (nID == PostcodeEditID && nCode == EN_CHANGE) {
		UpdateViews();
	}
	return 0;
	// return CWnd ::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
BOOL CParseAddressBrowse::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
{
	if (nID == ParseButtonID) {
		UpdateViews();
	}
	return 0;
	// return CWnd ::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
void SECEditView::MySetScrollPos(int fnBar, int iPos, BOOL bRedraw)
{
	// Call the base class
	SECEditCore<CView>::MySetScrollPos(fnBar, iPos, bRedraw);
	if(m_pSplitterParent)
	{
		if((this == (CView*)m_pSplitterParent->GetActivePane()) && !m_bScrollMessage)
			UpdateViews(this, OE_SYNCH_SPLITTERS);
	}
}
예제 #7
0
BOOL CApplicationImpl::IsDataFileOpened()
{
	if (m_spDataFile.is_null())
		return FALSE;

	CString csFileName = m_spDataFile->GetFileName();
	if (!csFileName.IsEmpty())
	{
		UpdateViews(UNM_FILE_OPENED, (WPARAM)m_spDataFile->GetFileName());
		return TRUE;
	}
	return FALSE;
}
/*virtual*/ void EldritchFramework::RefreshDisplay( const bool Fullscreen, const uint DisplayWidth, const uint DisplayHeight )
{
	PRINTF( "EldritchFramework::RefreshDisplay\n" );

	Framework3D::RefreshDisplay( Fullscreen, DisplayWidth, DisplayHeight );

	m_TargetManager->CreateTargets( DisplayWidth, DisplayHeight );

	UpdateViews();

	ASSERT( m_Game );
	m_Game->RefreshRTDependentSystems();

	CreateBuckets();
}
예제 #9
0
BOOL CCrystalTextBuffer::InitNew(int nCrlfStyle /*= CRLF_STYLE_DOS*/)
{
	ASSERT(! m_bInit);
	ASSERT(m_aLines.GetSize() == 0);
	ASSERT(nCrlfStyle >= 0 && nCrlfStyle <= 2);
	InsertLine(_T(""));
	m_bInit = TRUE;
	m_bReadOnly = FALSE;
	m_nCRLFMode = nCrlfStyle;
	m_bModified = FALSE;
	m_nSyncPosition = m_nUndoPosition = 0;
	m_bUndoGroup = m_bUndoBeginGroup = FALSE;
	m_nUndoBufSize = UNDO_BUF_SIZE;
	ASSERT(m_aUndoBuf.GetSize() == 0);
	UpdateViews(NULL, NULL, UPDATE_RESET);
	return TRUE;
}
예제 #10
0
/*virtual*/ void EldritchFramework::SetResolution(const uint DisplayWidth,
                                                  const uint DisplayHeight) {
  PRINTF("EldritchFramework::SetResolution\n");

  m_DisplayWidth = DisplayWidth;
  m_DisplayHeight = DisplayHeight;

  Framework3D::SetResolution(DisplayWidth, DisplayHeight);

  m_TargetManager->CreateTargets(DisplayWidth, DisplayHeight);

  UpdateViews();

  ASSERT(m_Game);
  m_Game->RefreshRTDependentSystems();

  CreateBuckets();
}
예제 #11
0
void CAddinApp::OnCommand(UINT id)
{
	switch (id)
	{
	case ID_ShowSheetWindow:
		{
			IVWindowPtr window = GetValidActiveWindow(visDrawing);

			if (!window)
				return;

			ShowShapeSheetWatchWindow(window, !IsShapeSheetWatchWindowShown(window));
			break;
		}

	case ID_AddWatch:
		{
			IVWindowPtr sheet_window = GetValidActiveWindow(visSheet);

			if (!sheet_window)
				return;

			IVCellPtr selected_cell = sheet_window->GetSelectedCell();
			if (selected_cell)
			{
				IVWindowPtr window = FindDocumentWindow(selected_cell);

				if (window)
				{
					CVisioFrameWnd* wnd = 
						ShowShapeSheetWatchWindow(window, true);

					GetViewSettings()->AddCellMask(selected_cell->Name);
					UpdateViews(UpdateOption_Hilight|UpdateOption_UseKey);
				}
			}
		}
	}
}
예제 #12
0
void CApplicationImpl::OpenDataFile(const CString& csFileName)
{ 
	if (!IsDataFileOpened(csFileName))
	{
		Database::IDataFile* pTempDataFile = GetDatabase()->OpenDataFile(csFileName);
		try
		{
			if (pTempDataFile->IsEmpty())
			{
				CreateDefaultContent(pTempDataFile);
			}
			else
			{
				CheckContent(pTempDataFile);
			}

			CheckModules(pTempDataFile);

			if (!m_spDataFile.is_null())
			{
				GetDatabase()->CloseDataFile(m_spDataFile.get());
			}
			m_spDataFile = pTempDataFile;

			m_mru.AddToList(m_spDataFile->GetFileName());
			m_mru.WriteToRegistry(GetOptionsPath(_T("Application")));

			UpdateViews(UNM_FILE_OPENED, (WPARAM)m_spDataFile->GetFileName());
		}
		catch(...)
		{
			// close new opened temp data file and throw exception up
			GetDatabase()->CloseDataFile(pTempDataFile);
			throw;
		}
	}
}
예제 #13
0
BOOL CCrystalTextBuffer::InternalInsertText(CCrystalTextView *pSource, int nLine, int nPos, LPCTSTR pszText, int &nEndLine, int &nEndChar)
{
	ASSERT(m_bInit);	//	Text buffer not yet initialized.
						//	You must call InitNew() or LoadFromFile() first!
//	ASSERT(nLine >= 0 && nLine < m_aLines.GetSize());
//	ASSERT(nPos >= 0 && nPos <= m_aLines[nLine].m_nLength);
	if (m_bReadOnly)
		return FALSE;

	CInsertContext context;
	context.m_ptStart.x = nPos;
	context.m_ptStart.y = nLine;

	int nRestCount = m_aLines[nLine].m_nLength - nPos;
	LPTSTR pszRestChars = NULL;
	if (nRestCount > 0)
	{
		pszRestChars = new TCHAR[nRestCount];
		memcpy(pszRestChars, m_aLines[nLine].m_pcLine + nPos, nRestCount * sizeof(TCHAR));
		m_aLines[nLine].m_nLength = nPos;
	}

	int nCurrentLine = nLine;
	BOOL bNewLines = FALSE;
	int nTextPos;
	for (;;)
	{
		nTextPos = 0;
		while (pszText[nTextPos] != 0 && pszText[nTextPos] != _T('\r'))
			nTextPos ++;

		if (nCurrentLine == nLine)
		{
			AppendLine(nLine, pszText, nTextPos);
		}
		else
		{
			InsertLine(pszText, nTextPos, nCurrentLine);
			bNewLines = TRUE;
		}

		if (pszText[nTextPos] == 0)
		{
			nEndLine = nCurrentLine;
			nEndChar = m_aLines[nCurrentLine].m_nLength;
			AppendLine(nCurrentLine, pszRestChars, nRestCount);
			break;
		}

		nCurrentLine ++;
		nTextPos ++;

		if (pszText[nTextPos] == _T('\n'))
		{
			nTextPos ++;
		}
		else
		{
			ASSERT(FALSE);			//	Invalid line-end format passed
		}

		pszText += nTextPos;
	}

	if (pszRestChars != NULL)
		delete pszRestChars;

	context.m_ptEnd.x = nEndChar;
	context.m_ptEnd.y = nEndLine;

	if (bNewLines)
		UpdateViews(pSource, &context, UPDATE_HORZRANGE | UPDATE_VERTRANGE, nLine);
	else
		UpdateViews(pSource, &context, UPDATE_SINGLELINE | UPDATE_HORZRANGE, nLine);

	if (! m_bModified)
		SetModified(TRUE);
	return TRUE;
}
 void JumpPointController::Update(float deltaTime)
 {
     UpdateViews(deltaTime);
 }
예제 #15
0
void
AccountConfigView::AttachedToWindow()
{
	UpdateViews();
	fNameControl->SetTarget(this);
}
예제 #16
0
BOOL CCrystalTextBuffer::LoadFromFile(LPCTSTR pszFileName, int nCrlfStyle /*= CRLF_STYLE_AUTOMATIC*/)
{
	ASSERT(! m_bInit);
	ASSERT(m_aLines.GetSize() == 0);

	HANDLE hFile = NULL;
	int nCurrentMax = 256;
	char *pcLineBuf = new char[nCurrentMax];

	BOOL bSuccess = FALSE;
	__try
	{
		DWORD dwFileAttributes = ::GetFileAttributes(pszFileName);
		if (dwFileAttributes == (DWORD) -1)
			__leave;

		hFile = ::CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
					OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
		if (hFile == INVALID_HANDLE_VALUE)
			__leave;

		int nCurrentLength = 0;

		const DWORD dwBufSize = 32768;
		char *pcBuf = (char *) _alloca(dwBufSize);
		DWORD dwCurSize;
		if (! ::ReadFile(hFile, pcBuf, dwBufSize, &dwCurSize, NULL))
			__leave;

		if (nCrlfStyle == CRLF_STYLE_AUTOMATIC)
		{
			//	Try to determine current CRLF mode
			for (DWORD I = 0; I < dwCurSize; I ++)
			{
				if (pcBuf[I] == _T('\x0a'))
					break;
			}
			if (I == dwCurSize)
			{
				//	By default (or in the case of empty file), set DOS style
				nCrlfStyle = CRLF_STYLE_DOS;
			}
			else
			{
				//	Otherwise, analyse the first occurance of line-feed character
				if (I > 0 && pcBuf[I - 1] == _T('\x0d'))
				{
					nCrlfStyle = CRLF_STYLE_DOS;
				}
				else
				{
					if (I < dwCurSize - 1 && pcBuf[I + 1] == _T('\x0d'))
						nCrlfStyle = CRLF_STYLE_UNIX;
					else
						nCrlfStyle = CRLF_STYLE_MAC;
				}
			}
		}

		ASSERT(nCrlfStyle >= 0 && nCrlfStyle <= 2);
		m_nCRLFMode = nCrlfStyle;
		const char *crlf = crlfs[nCrlfStyle];

		m_aLines.SetSize(0, 4096);

		DWORD dwBufPtr = 0;
		int nCrlfPtr = 0;
		USES_CONVERSION;
		while (dwBufPtr < dwCurSize)
		{
			int c = pcBuf[dwBufPtr];
			dwBufPtr ++;
			if (dwBufPtr == dwCurSize && dwCurSize == dwBufSize)
			{
				if (! ::ReadFile(hFile, pcBuf, dwBufSize, &dwCurSize, NULL))
					__leave;
				dwBufPtr = 0;
			}

			pcLineBuf[nCurrentLength] = (char) c;
			nCurrentLength ++;
			if (nCurrentLength == nCurrentMax)
			{
				//	Reallocate line buffer
				nCurrentMax += 256;
				char *pcNewBuf = new char[nCurrentMax];
				memcpy(pcNewBuf, pcLineBuf, nCurrentLength);
				delete pcLineBuf;
				pcLineBuf = pcNewBuf;
			}

			if ((char) c == crlf[nCrlfPtr])
			{
				nCrlfPtr ++;
				if (crlf[nCrlfPtr] == 0)
				{
					pcLineBuf[nCurrentLength - nCrlfPtr] = 0;
					InsertLine(A2T(pcLineBuf));
					nCurrentLength = 0;
					nCrlfPtr = 0;
				}
			}
			else
				nCrlfPtr = 0;
		}

		pcLineBuf[nCurrentLength] = 0;
		InsertLine(A2T(pcLineBuf));

		ASSERT(m_aLines.GetSize() > 0);		//	At least one empty line must present

		m_bInit = TRUE;
		m_bReadOnly = (dwFileAttributes & FILE_ATTRIBUTE_READONLY) != 0;
		m_bModified = FALSE;
		m_bUndoGroup = m_bUndoBeginGroup = FALSE;
		m_nUndoBufSize = UNDO_BUF_SIZE;
		m_nSyncPosition = m_nUndoPosition = 0;
		ASSERT(m_aUndoBuf.GetSize() == 0);
		bSuccess = TRUE;

		UpdateViews(NULL, NULL, UPDATE_RESET);
	}
	__finally
	{
		if (pcLineBuf != NULL)
			delete pcLineBuf;
		if (hFile != NULL)
			::CloseHandle(hFile);
	}
	return bSuccess;
}
예제 #17
0
// ============================================================================
void CVisualMSThread::ShowApp()
{
    m_pMainWnd->ShowWindow(SW_SHOW);
    m_pMainWnd->UpdateWindow();
    UpdateViews();
}
///	\brief	select object in the editor 
///	\param	hashName - hash of the object name
void CStateMachineEditor::SelectObject(IHashString *name)
{
	UpdateViews(name, &CStateMachineEditorView::SelectObject);
}
예제 #19
0
int CApplicationImpl::AddFolder(LPCTSTR szFolderName, int nParentId)
{
	int nId = CItems::New(szFolderName, _T(""), nParentId, TRUE);
	UpdateViews(UNM_FOLDER_ADDED, nId, nParentId);
	return nId;
}
예제 #20
0
void DiffSideBySidePanel::Diff()
{
    wxFileName fnLeft(m_filePickerLeft->GetPath());
    wxFileName fnRIght(m_filePickerRight->GetPath());

    if(!fnLeft.Exists()) {
        ::wxMessageBox(wxString() << _("Left Side File:\n") << fnLeft.GetFullPath() << _(" does not exist!"),
                       "CodeLite",
                       wxICON_ERROR | wxCENTER | wxOK);
        return;
    }

    if(!fnRIght.Exists()) {
        ::wxMessageBox(wxString() << _("Right Side File:\n") << fnRIght.GetFullPath() << _(" does not exist!"),
                       "CodeLite",
                       wxICON_ERROR | wxCENTER | wxOK);
        return;
    }

    // Cleanup
    DoClean();

    // Prepare the views
    PrepareViews();

    // Prepare the diff
    clDTL d;
    d.Diff(m_filePickerLeft->GetPath(),
           m_filePickerRight->GetPath(),
           m_config.IsSingleViewMode() ? clDTL::kOnePane : clDTL::kTwoPanes);
    const clDTL::LineInfoVec_t& resultLeft = d.GetResultLeft();
    const clDTL::LineInfoVec_t& resultRight = d.GetResultRight();
    m_sequences = d.GetSequences();

    if(m_sequences.empty()) {
        // Files are the same !
        m_stcLeft->SetReadOnly(false);
        m_stcRight->SetReadOnly(false);

        m_stcLeft->LoadFile(fnLeft.GetFullPath());
        m_stcRight->LoadFile(fnRIght.GetFullPath());

        m_stcLeft->SetSavePoint();
        m_stcRight->SetSavePoint();

        m_stcLeft->SetReadOnly(true);
        m_stcRight->SetReadOnly(true);
        return;
    }

    m_cur_sequence = 0; // the first line of the sequence

    // Create 2 strings "left" and "right"
    wxString leftContent, rightContent;

    // The left pane is always the one with the deletions "-"
    for(size_t i = 0; i < resultLeft.size(); ++i) {
        if(resultLeft.at(i).m_type == clDTL::LINE_ADDED) {
            leftContent << resultLeft.at(i).m_line;
            m_leftGreenMarkers.push_back(i);

        } else if(resultLeft.at(i).m_type == clDTL::LINE_REMOVED) {
            leftContent << resultLeft.at(i).m_line;
            m_leftRedMarkers.push_back(i);

        } else if(resultLeft.at(i).m_type == clDTL::LINE_PLACEHOLDER) {
            // PLACEHOLDER
            leftContent << resultLeft.at(i).m_line;
            m_leftPlaceholdersMarkers.push_back(i);

        } else {
            // COMMON
            leftContent << resultLeft.at(i).m_line;
        }
    }

    // The right pane is always with the new additions "+"
    for(size_t i = 0; i < resultRight.size(); ++i) {
        if(resultRight.at(i).m_type == clDTL::LINE_REMOVED) {
            rightContent << resultRight.at(i).m_line;
            m_rightRedMarkers.push_back(i);

        } else if(resultRight.at(i).m_type == clDTL::LINE_ADDED) {
            rightContent << resultRight.at(i).m_line;
            m_rightGreenMarkers.push_back(i);

        } else if(resultRight.at(i).m_type == clDTL::LINE_PLACEHOLDER) {
            rightContent << resultRight.at(i).m_line;
            m_rightPlaceholdersMarkers.push_back(i);

        } else {
            // COMMON
            rightContent << resultRight.at(i).m_line;
        }
    }
    UpdateViews(leftContent, rightContent);
    m_stcLeft->SetSavePoint();
    m_stcRight->SetSavePoint();

    // Select the first diff
    wxRibbonButtonBarEvent dummy;
    m_cur_sequence = -1;
    OnNextDiffSequence(dummy);
}