当前位置: 首页>>代码示例>>C++>>正文


C++ ITfRange::ShiftStart方法代码示例

本文整理汇总了C++中ITfRange::ShiftStart方法的典型用法代码示例。如果您正苦于以下问题:C++ ITfRange::ShiftStart方法的具体用法?C++ ITfRange::ShiftStart怎么用?C++ ITfRange::ShiftStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITfRange的用法示例。


在下文中一共展示了ITfRange::ShiftStart方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DoEditSession

STDAPI CInlinePreeditEditSession::DoEditSession(TfEditCookie ec)
{
	std::wstring preedit = _context->preedit.str;

	ITfRange *pRangeComposition = NULL;
	if ((_pComposition->GetRange(&pRangeComposition)) != S_OK)
		goto Exit;

	if ((pRangeComposition->SetText(ec, 0, preedit.c_str(), preedit.length())) != S_OK)
		goto Exit;

	int sel_start = 0, sel_end = 0; /* TODO: Check the availability and correctness of these values */
	for (size_t i = 0; i < _context->preedit.attributes.size(); i++)
		if (_context->preedit.attributes.at(i).type == weasel::HIGHLIGHTED)
		{
			sel_start = _context->preedit.attributes.at(i).range.start;
			sel_end = _context->preedit.attributes.at(i).range.end;
			break;
		}

	/* Set caret */
	LONG cch;
	TF_SELECTION tfSelection;
	pRangeComposition->Collapse(ec, TF_ANCHOR_START);
	pRangeComposition->ShiftEnd(ec, sel_end, &cch, NULL);
	pRangeComposition->ShiftStart(ec, sel_start, &cch, NULL);
	tfSelection.range = pRangeComposition;
	tfSelection.style.ase = TF_AE_NONE;
	tfSelection.style.fInterimChar = FALSE;
	_pContext->SetSelection(ec, 1, &tfSelection);

Exit:
	if (pRangeComposition != NULL)
		pRangeComposition->Release();
	return S_OK;
}
开发者ID:wyrover,项目名称:weasel,代码行数:36,代码来源:Composition.cpp

示例2: _DumpExtent


//.........这里部分代码省略.........

         AddStringToStream(_pMemStream, L"Start Pos\r\n");
         if (SUCCEEDED(pContext->GetStart(ec, &pRange)))
         {
             if (SUCCEEDED(pView->GetTextExt(ec, pRange, &rc, &fClipped)))
             {
                 StringCchPrintf(sz, ARRAYSIZE(sz), L"    (%d, %d, %d, %d) - (%d, %d) %s\r\n", rc.left, rc.top, rc.right, rc.bottom, rc.right - rc.left, rc.bottom - rc.top, fClipped ? L"Clipped" : L"");

                 AddStringToStream(_pMemStream, sz);
                 _rcStartPos = rc;
             }

             pRange->Release();
         }

         AddStringToStream(_pMemStream, L"End Pos\r\n");
         if (SUCCEEDED(pContext->GetEnd(ec, &pRange)))
         {
             if (SUCCEEDED(pView->GetTextExt(ec, pRange, &rc, &fClipped)))
             {
                 StringCchPrintf(sz, ARRAYSIZE(sz), L"    (%d, %d, %d, %d) - (%d, %d) %s\r\n", rc.left, rc.top, rc.right, rc.bottom, rc.right - rc.left, rc.bottom - rc.top, fClipped ? L"Clipped" : L"");

                 AddStringToStream(_pMemStream, sz);
                 _rcEndPos = rc;
             }

             pRange->Release();
         }

         AddStringToStream(_pMemStream, L"Selection Pos\r\n");
         ULONG cFetched;
         if (SUCCEEDED(pContext->GetSelection(ec, 0, 1, &sel, &cFetched)))
         {
             if (sel.range)
             {
                 if (SUCCEEDED(pView->GetTextExt(ec, sel.range, &rc, &fClipped)))
                 {
                     StringCchPrintf(sz, ARRAYSIZE(sz), L"    (%d, %d, %d, %d) - (%d, %d) %s\r\n", rc.left, rc.top, rc.right, rc.bottom, rc.right - rc.left, rc.bottom - rc.top, fClipped ? L"Clipped" : L"");

                     AddStringToStream(_pMemStream, sz);
                     _rcSelection = rc;
                 }
                 AddStringToStream(_pMemStream, L"    ");
                 _DumpRange(ec, sel.range);
                 AddStringToStream(_pMemStream, L"\r\n");
                 sel.range->Release();
             }
         }

         AddStringToStream(_pMemStream, L"Char Pos\r\n");
         if (SUCCEEDED(pContext->GetStart(ec, &pRange)))
         {
             LONG cch;
             memset(&_rcRanges[0] , 0, sizeof(RECT) * ARRAYSIZE(_rcRanges));
             if (SUCCEEDED(pRange->ShiftEnd(ec, 1, &cch, NULL)) && cch)
             {
                 for (int i = 0; i < ARRAYSIZE(_rcRanges); i++)
                 {
                     if (SUCCEEDED(pView->GetTextExt(ec, pRange, &rc, &fClipped)))
                     {
                         StringCchPrintf(sz, ARRAYSIZE(sz), L"    (%d, %d, %d, %d) - (%d, %d) %s", rc.left, rc.top, rc.right, rc.bottom, rc.right - rc.left, rc.bottom - rc.top, fClipped ? L"Clipped" : L"");
                         AddStringToStream(_pMemStream, sz);

                         AddStringToStream(_pMemStream, L" ");
                         ITfRange *pRangeTmp;
                         if (SUCCEEDED(pRange->Clone(&pRangeTmp)))
                         {
                             _DumpRange(ec, pRangeTmp);
                             pRangeTmp->Release();
                         }
                         AddStringToStream(_pMemStream, L"\r\n");

                         OffsetRect(&rc, 0 - _rcView.left, 0 - _rcView.top);
                         _rcRanges[i] = rc;
                     }

                     if (FAILED(pRange->ShiftEnd(ec, 1, &cch, NULL)) || !cch)
                         break;

                     if (FAILED(pRange->ShiftStart(ec, 1, &cch, NULL)) || !cch)
                         break;
                 }

             }
             pRange->Release();
         }

         pView->Release();
    }

    _EnsurePopupWindow();

    if (IsShownExtentVisualWindows())
        _UpdateExtentVisualWindows();

    if (IsShownRangeExtentViewer())
        _UpdateRangeExtentViewer();

    return;
}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:101,代码来源:DumpExtent.cpp

示例3: _SetText

HRESULT CTextService::_SetText(TfEditCookie ec, ITfContext *pContext, const std::wstring &text, LONG cchCursor, LONG cchOkuri, BOOL fixed)
{
	TF_SELECTION tfSelection;
	ULONG cFetched = 0;
	LONG cch, cchRes;

	if(pContext == NULL && _pCandidateList != NULL)	//辞書登録用
	{
		_pCandidateList->_SetText(text, fixed, FALSE, FALSE);
		return S_OK;
	}

	if(!_IsComposing())
	{
		if(!_StartComposition(pContext))
		{
			return S_FALSE;
		}
	}

	if(pContext->GetSelection(ec, TF_DEFAULT_SELECTION, 1, &tfSelection, &cFetched) != S_OK)
	{
		return S_FALSE;
	}

	if(cFetched != 1)
	{
		SafeRelease(&tfSelection.range);
		return S_FALSE;
	}

	ITfRange *pRange;
	if(_IsComposing() && _pComposition->GetRange(&pRange) == S_OK)
	{
		if(_IsRangeCovered(ec, tfSelection.range, pRange))
		{
			pRange->SetText(ec, 0, text.c_str(), (LONG)text.size());

			// shift from end to start.
			// shift over mathematical operators (U+2200-U+22FF) is rejected by OneNote.
			if(cchCursor == 0)
			{
				cchRes = (LONG)cursoridx - (LONG)kana.size();
				if((complement && okuriidx != 0) ||
					(!cx_showmodemark && okuriidx != 0 && cursoridx <= okuriidx && cursoridx < kana.size()))
				{
					cchRes += 1;
				}
			}
			else
			{
				cchRes = cchCursor - (LONG)text.size();
				if(cchRes > 0)
				{
					cchRes = 0;
				}
				else if(cchRes < -(LONG)text.size())
				{
					cchRes = -(LONG)text.size();
				}
			}

			tfSelection.range->ShiftEndToRange(ec, pRange, TF_ANCHOR_END);
			tfSelection.range->ShiftStartToRange(ec, pRange, TF_ANCHOR_END);
			tfSelection.range->ShiftStart(ec, cchRes, &cch, NULL);
			//decide cursor position
			tfSelection.range->Collapse(ec, TF_ANCHOR_START);
			pContext->SetSelection(ec, 1, &tfSelection);

			//composition attribute
			if(!fixed)
			{
				ITfRange *pRangeClone;
				if(pRange->Clone(&pRangeClone) == S_OK)
				{
					pRangeClone->ShiftEndToRange(ec, pRange, TF_ANCHOR_END);
					pRangeClone->ShiftStartToRange(ec, pRange, TF_ANCHOR_START);

					if(cchCursor == 0 || !showentry)
					{
						if(inputkey)
						{
							_SetCompositionDisplayAttributes(ec, pContext, pRangeClone, _gaDisplayAttributeInputMark);
							if(cx_showmodemark)
							{
								pRangeClone->ShiftStart(ec, 1, &cch, NULL);
							}
						}

						if(!display_attribute_series[1] || !inputkey)
						{
							_SetCompositionDisplayAttributes(ec, pContext, pRangeClone, _gaDisplayAttributeInputText);
						}

						if(cchOkuri != 0)
						{
							pRangeClone->ShiftStartToRange(ec, pRange, TF_ANCHOR_START);
							pRangeClone->ShiftStart(ec, cchOkuri, &cch, NULL);
							if(!display_attribute_series[2])
							{
//.........这里部分代码省略.........
开发者ID:murachue,项目名称:corvusskk,代码行数:101,代码来源:KeyHandlerComposition.cpp


注:本文中的ITfRange::ShiftStart方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。