コード例 #1
0
void CChannels::Copy(CChannels* pcData)
{
	//This assumes channels is not initialised.

	masChannelOffsets.Init(1);
	masChannelOffsets.Copy(&pcData->masChannelOffsets);
	miSize = pcData->miSize;
	miByteStride = pcData->miByteStride;
	miBitStride = pcData->miBitStride;
	mbOnlyBasicTypes = pcData->mbOnlyBasicTypes;
	mabData.Init(1);
	mabData.Copy(&pcData->mabData);
	mpvUserData = pcData->mpvUserData;
	if (IsUserAllocated())
	{
		mpvDataCache = mpvUserData;
	}
	else
	{
		mpvDataCache = mabData.GetData();
	}
	if (pcData->IsChanging())
	{
		BeginChange();
		mpsChangingDesc->iSize = pcData->mpsChangingDesc->iSize;
		mpsChangingDesc->pvUserData = pcData->mpsChangingDesc->pvUserData;
		mpsChangingDesc->asAddedChannels.Copy(&pcData->mpsChangingDesc->asAddedChannels);
		mpsChangingDesc->asRemovedChannels.Copy(&pcData->mpsChangingDesc->asRemovedChannels);
	}
}
コード例 #2
0
void CChannels::Init(CChannels* pcSource)
{
	CChannel*			psSource;
	int					i;

	Init();
	BeginChange();

	for (i = 0; i < pcSource->masChannelOffsets.NumElements(); i++)
	{
		psSource = pcSource->masChannelOffsets.Get(i);
		AddChannel(psSource->iChannel, psSource->eType, psSource->bReverse);
	}

	SetSize(pcSource->miSize);
	EndChange();
}
コード例 #3
0
void CChannels::Init(int iSize, EPrimitiveTypes eType, int iFirst, ...)
{
	va_list					vaMarker;
	int						iCount;
	int						i;

	Init();
	iCount = 0;
	i = iFirst;

	BeginChange();
	va_start(vaMarker, iFirst);
	while (i != -1)
	{
		AddChannel(i, eType);
		iCount++;
		i = va_arg(vaMarker, int);
	}
	va_end(vaMarker);

	SetSize(iSize);
	EndChange();
}
コード例 #4
0
ファイル: TreeViewModel.cpp プロジェクト: prestocore/browser
/***********************************************************************************
**
**	TreeViewModel::OnTreeChanging
**
***********************************************************************************/
void TreeViewModel::OnTreeChanging(OpTreeModel* tree_model)
{
	BeginChange();
	DeleteAll();
	// EndChange will be called in OnTreeChanged
}
コード例 #5
0
void OpDocumentEdit::EditAction(OpInputAction* action)
{
	DEBUG_CHECKER(TRUE);
	SelectionBoundaryPoint anchor, focus;
	if (m_doc->GetHtmlDocument())
		m_doc->GetHtmlDocument()->GetSelection(anchor, focus);
	HTML_Element* old_caret_helm = m_caret.GetElement();
	INT32 old_caret_ofs = m_caret.GetOffset();
#ifdef INTERNAL_SPELLCHECK_SUPPORT
	SpellWordInfoObject old_info;
#endif // INTERNAL_SPELLCHECK_SUPPORT

	switch (action->GetAction())
	{
		case OpInputAction::ACTION_NEXT_CHARACTER_SPATIAL:
			m_caret.MoveSpatial(TRUE);
			break;
		case OpInputAction::ACTION_PREVIOUS_CHARACTER_SPATIAL:
			m_caret.MoveSpatial(FALSE);
			break;

		case OpInputAction::ACTION_RANGE_GO_TO_START:
		case OpInputAction::ACTION_GO_TO_START:
			m_caret.Place(OpWindowCommander::CARET_DOCUMENT_HOME);
			break;

		case OpInputAction::ACTION_RANGE_GO_TO_LINE_START:
		case OpInputAction::ACTION_GO_TO_LINE_START:
			m_caret.Place(GetRTL() ? OpWindowCommander::CARET_LINE_END : OpWindowCommander::CARET_LINE_HOME);
			break;

		case OpInputAction::ACTION_RANGE_GO_TO_END:
		case OpInputAction::ACTION_GO_TO_END:
			m_caret.Place(OpWindowCommander::CARET_DOCUMENT_END);
			break;

		case OpInputAction::ACTION_RANGE_GO_TO_LINE_END:
		case OpInputAction::ACTION_GO_TO_LINE_END:
			m_caret.Place(GetRTL() ? OpWindowCommander::CARET_LINE_HOME : OpWindowCommander::CARET_LINE_END);
			break;

		case OpInputAction::ACTION_RANGE_PAGE_UP:
		case OpInputAction::ACTION_PAGE_UP:
			m_caret.Place(OpWindowCommander::CARET_PAGEUP);
			break;
		case OpInputAction::ACTION_RANGE_PAGE_DOWN:
		case OpInputAction::ACTION_PAGE_DOWN:
			m_caret.Place(OpWindowCommander::CARET_PAGEDOWN);
			break;

		case OpInputAction::ACTION_RANGE_NEXT_CHARACTER:
		case OpInputAction::ACTION_NEXT_CHARACTER:
			if (m_selection.HasContent() && !action->IsRangeAction())
			{
				TextSelection* text_selection = m_doc->GetTextSelection();
				m_caret.Place(text_selection->GetEndSelectionPoint());
			}
			else
			{
				// Move action moves in visual order. Range action moves in logical order but reversed if RTL.
				BOOL forward = TRUE;
				if (/*action->IsRangeAction() && */GetRTL())
					forward = !forward;
				m_caret.Move(forward, FALSE/*, !action->IsRangeAction()*/);
			}
			break;
		case OpInputAction::ACTION_RANGE_PREVIOUS_CHARACTER:
		case OpInputAction::ACTION_PREVIOUS_CHARACTER:
			if (m_selection.HasContent() && !action->IsRangeAction())
			{
				TextSelection* text_selection = m_doc->GetTextSelection();
				m_caret.Place(text_selection->GetStartSelectionPoint());
			}
			else
			{
				// Move action moves in visual order. Range action moves in logical order but reversed if RTL.
				BOOL forward = FALSE;
				if (/*action->IsRangeAction() && */GetRTL())
					forward = !forward;
				m_caret.Move(forward, FALSE/*, !action->IsRangeAction()*/);
			}
			break;

		case OpInputAction::ACTION_RANGE_NEXT_WORD:
		case OpInputAction::ACTION_NEXT_WORD:
			m_caret.Move(TRUE, TRUE);
			break;
		case OpInputAction::ACTION_RANGE_PREVIOUS_WORD:
		case OpInputAction::ACTION_PREVIOUS_WORD:
			m_caret.Move(FALSE, TRUE);
			break;

		case OpInputAction::ACTION_NEXT_LINE_SPATIAL:
		case OpInputAction::ACTION_RANGE_NEXT_LINE:
		case OpInputAction::ACTION_NEXT_LINE:
			m_caret.Place(OpWindowCommander::CARET_DOWN);
			break;
		case OpInputAction::ACTION_PREVIOUS_LINE_SPATIAL:
		case OpInputAction::ACTION_RANGE_PREVIOUS_LINE:
		case OpInputAction::ACTION_PREVIOUS_LINE:
			m_caret.Place(OpWindowCommander::CARET_UP);
			break;

		case OpInputAction::ACTION_DELETE_WORD:
		case OpInputAction::ACTION_BACKSPACE_WORD:
		case OpInputAction::ACTION_DELETE_TO_END_OF_LINE:
		case OpInputAction::ACTION_DELETE:
		case OpInputAction::ACTION_BACKSPACE:
			if (m_readonly)
				break;
			if (m_layout_modifier.IsActive())
			{
				m_layout_modifier.Delete();
				break;
			}
			m_caret.LockUpdatePos(TRUE);
			if (!m_selection.HasContent())
			{
#ifdef INTERNAL_SPELLCHECK_SUPPORT
				old_info.Set(m_caret.GetElement());
#endif // INTERNAL_SPELLCHECK_SUPPORT
				m_caret.SetNotRemoveWhenMoveIfUntouched();
				switch(action->GetAction())
				{
				case OpInputAction::ACTION_DELETE_WORD:
					m_caret.Move(TRUE, TRUE);
					break;
				case OpInputAction::ACTION_BACKSPACE_WORD:
					m_caret.Move(FALSE, TRUE);
					break;
				case OpInputAction::ACTION_DELETE_TO_END_OF_LINE:
					m_caret.Place(OpWindowCommander::CARET_LINE_END);
					break;
				case OpInputAction::ACTION_DELETE:
					m_caret.Move(TRUE, FALSE);
					break;
				case OpInputAction::ACTION_BACKSPACE:
					m_caret.Move(FALSE, FALSE);
					break;
				}
				HTML_Element* anchor_elm;
				int anchor_offset;
				TextSelection::ConvertPointToOldStyle(anchor, anchor_elm, anchor_offset);
				m_selection.SelectToCaret(anchor_elm, anchor_offset);
			}
			if (m_selection.HasContent())
			{
				m_selection.RemoveContent();
#ifdef INTERNAL_SPELLCHECK_SUPPORT
				DoSpellWordInfoUpdate(&old_info);
#endif // INTERNAL_SPELLCHECK_SUPPORT
			}
			else
			{
				HTML_Element* list = GetParentListElm(m_caret.GetElement());
				if (list && action->GetAction() == OpInputAction::ACTION_BACKSPACE && (m_body_is_root || list->IsContentEditable(TRUE)))
				{
					HTML_Element* new_caret_helm = NULL;
					int new_caret_ofs = 0;
					GetNearestCaretPos(list, &new_caret_helm, &new_caret_ofs, FALSE, FALSE);

					HTML_Element* root = m_doc->GetCaret()->GetContainingElementActual(list);
					BeginChange(root, CHANGE_FLAGS_ALLOW_APPEND);

					DeleteElement(list);
					ReflowAndUpdate();
					if (new_caret_helm)
						m_caret.Place(new_caret_helm, new_caret_ofs);
					else
						m_caret.PlaceFirst(root);
					EndChange(root);
				}
			}
			m_caret.LockUpdatePos(FALSE);
			if (m_listener)
				m_listener->OnTextChanged();
			break;

		case OpInputAction::ACTION_CONVERT_HEX_TO_UNICODE:
			{
				if (m_caret.GetElement()->Parent()->GetIsPseudoElement())
					// Don't let us do something in pseudoelements.
					break;
				if (!m_caret.IsElementEditable(m_caret.GetElement()))
					// Don't let us do something in elements with contentEditable false.
					break;

				// Extract the text of the current element
				OpString string;
				int text_len = m_caret.GetElement()->GetTextContentLength() + 1;
				if (!string.Reserve(text_len))
					break;
				if (OpStatus::IsError(m_caret.GetElement()->GetTextContent(string.DataPtr(), text_len)))
					break;
				int hex_start = 0;

				// Find the hex string
				if (UnicodePoint charcode = ConvertHexToUnicode(0, m_caret.GetOffset(), hex_start, string.CStr()))
				{
					// Remove the hex string
					m_undo_stack.BeginGroup();
#ifdef INTERNAL_SPELLCHECK_SUPPORT
					old_info.Set(m_caret.GetElement());
#endif // INTERNAL_SPELLCHECK_SUPPORT
					m_caret.SetNotRemoveWhenMoveIfUntouched();
					SelectionBoundaryPoint hex_start_point(old_caret_helm, hex_start);
					HTML_Element* hex_start_elm;
					int hex_start_offset;
					TextSelection::ConvertPointToOldStyle(hex_start_point, hex_start_elm, hex_start_offset);
					m_selection.SelectToCaret(hex_start_elm, hex_start_offset);
//					m_caret.Set(old_caret_helm, old_caret_ofs);
					m_selection.RemoveContent();
#ifdef INTERNAL_SPELLCHECK_SUPPORT
					DoSpellWordInfoUpdate(&old_info);
#endif // INTERNAL_SPELLCHECK_SUPPORT

					// Insert the new text
					uni_char instr[3] = { 0, 0, 0 }; /* ARRAY OK 2011-11-07 peter */
					int len = Unicode::WriteUnicodePoint(instr, charcode);
					m_caret.LockUpdatePos(TRUE);

#ifdef INTERNAL_SPELLCHECK_SUPPORT
					BOOL was_delayed_misspell = FALSE;
#endif // INTERNAL_SPELLCHECK_SUPPORT
					BOOL has_content = m_selection.HasContent();
					if (GetDoc()->GetCaretPainter()->GetOverstrike() && !has_content)
					{
						m_caret.Move(TRUE, FALSE);
						if (IsFriends(old_caret_helm, m_caret.GetElement()))
							m_selection.SelectToCaret(old_caret_helm, old_caret_ofs);
						m_caret.Set(old_caret_helm, old_caret_ofs);
					}
#ifdef INTERNAL_SPELLCHECK_SUPPORT
					else if(!has_content && !m_layout_modifier.IsActive() && m_delay_misspell_word_info)
						was_delayed_misspell = TRUE;
#endif // INTERNAL_SPELLCHECK_SUPPORT

					InsertText(instr, len, TRUE);
					m_undo_stack.EndGroup();

					m_caret.LockUpdatePos(FALSE);
#ifdef INTERNAL_SPELLCHECK_SUPPORT
					if(m_spell_session)
						PossiblyDelayMisspell(was_delayed_misspell);
					m_doc_has_changed = FALSE;
#endif // INTERNAL_SPELLCHECK_SUPPORT

					if (m_listener)
						m_listener->OnTextChanged();
				}

				break;
			}

		case OpInputAction::ACTION_TOGGLE_STYLE_BOLD:
			execCommand(OP_DOCUMENT_EDIT_COMMAND_BOLD);
			if (m_listener)
				m_listener->OnTextChanged();
			break;
		case OpInputAction::ACTION_TOGGLE_STYLE_ITALIC:
			execCommand(OP_DOCUMENT_EDIT_COMMAND_ITALIC);
			if (m_listener)
				m_listener->OnTextChanged();
			break;
		case OpInputAction::ACTION_TOGGLE_STYLE_UNDERLINE:
			execCommand(OP_DOCUMENT_EDIT_COMMAND_UNDERLINE);
			if (m_listener)
				m_listener->OnTextChanged();
			break;
		case OpInputAction::ACTION_LOWLEVEL_KEY_PRESSED:
		{
			if (m_readonly)
				break;
			OpKey::Code key = action->GetActionKeyCode();

			if (!m_caret.GetElement())
				// Nowhere to put the input.
				break;
			if (m_caret.GetElement()->Parent()->GetIsPseudoElement())
				// Don't let us do something in pseudoelements.
				break;
			if (!m_caret.IsElementEditable(m_caret.GetElement()))
				// Don't let us do something in elements with contentEditable false.
				break;

			if (key == OP_KEY_ENTER)
			{
				BOOL new_paragraph = action->GetShiftKeys() & SHIFTKEY_SHIFT ? FALSE : TRUE;
				BOOL break_list = TRUE;
#ifdef DOCUMENT_EDIT_USE_PARAGRAPH_BREAK
				break_list = new_paragraph;
#endif // DOCUMENT_EDIT_USE_PARAGRAPH_BREAK
				InsertBreak(break_list, new_paragraph);
			}
			else if (key == OP_KEY_TAB)
			{
				// FIX: if we don't use wrap_pre, we can't do this! we have to insert nbspaces then.
				uni_char instr[2] = { 9, 0 };
				InsertText(instr, 1, TRUE);
			}
			else
			{
				m_caret.LockUpdatePos(TRUE);

#ifdef INTERNAL_SPELLCHECK_SUPPORT
				BOOL was_delayed_misspell = FALSE;
#endif // INTERNAL_SPELLCHECK_SUPPORT
				BOOL has_content = m_selection.HasContent();
				if (GetDoc()->GetCaretPainter()->GetOverstrike() && !has_content)
				{
					m_caret.Move(TRUE, FALSE);
					if (IsFriends(old_caret_helm, m_caret.GetElement()))
						m_selection.SelectToCaret(old_caret_helm, old_caret_ofs);
					m_caret.Set(old_caret_helm, old_caret_ofs);
				}
#ifdef INTERNAL_SPELLCHECK_SUPPORT
				else if(!has_content && !m_layout_modifier.IsActive() && m_delay_misspell_word_info)
					was_delayed_misspell = TRUE;
#endif // INTERNAL_SPELLCHECK_SUPPORT

				const uni_char *key_value = action->GetKeyValue();
				if (key_value)
					InsertText(key_value, uni_strlen(key_value), TRUE);

				m_caret.LockUpdatePos(FALSE);
#ifdef INTERNAL_SPELLCHECK_SUPPORT
				if(m_spell_session)
					PossiblyDelayMisspell(was_delayed_misspell);
				m_doc_has_changed = FALSE;
#endif // INTERNAL_SPELLCHECK_SUPPORT
			}
			if (m_listener)
				m_listener->OnTextChanged();
			break;
		}
	}

	if (action->IsRangeAction() && anchor.GetElement())
	{
		HTML_Element* anchor_elm;
		int anchor_offset;
		TextSelection::ConvertPointToOldStyle(anchor, anchor_elm, anchor_offset);
		m_selection.SelectToCaret(anchor_elm, anchor_offset);
	}
	else if (action->IsMoveAction())
		m_selection.SelectNothing();

	BOOL IsUpDownAction(int action); // widgets/OpMultiEdit.cpp
	if (!IsUpDownAction(action->GetAction()))
		m_caret.UpdateWantedX();

	ScrollIfNeeded();
}