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

📄 fepcontrol.cpp

📁 三字经输入法源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	WRITE_LOG_FORMAT2(_L("scan=0x%x modifier=0x%x"), aKeyEvent.iScanCode, aKeyEvent.iModifiers);
	if(keyCode=='#')
		{
		Reset();
		DisplayFep();
		if(iMode&EChinese)
			{
			iMode = ELetter;
			
			delete iEngine;
			iEngine = NULL;
			if(iLetterEngine ==NULL)
				iLetterEngine = CMultiTapEngine::NewL(*this, iInput, *iCand, *iOutput);
			
			iIndicator->SetState(CFepIndicator::EStateAlphabat);
			}
		else if(iMode&ELetter)
			{
			iMode = ENumber;
			
			delete iEngine;
			iEngine = NULL;
			delete iLetterEngine;
			iLetterEngine = NULL;
			
			iIndicator->SetState(CFepIndicator::EStateNumeric);
			}
		else if(iMode&ENumber)
			{
			iMode = EChinese;
			
			delete iLetterEngine;
			iLetterEngine = NULL;
			if(iEngine ==NULL)
				iEngine = CHaneaseEngine::NewL(*this, iInput, *iCand, *iOutput);
			
			iIndicator->SetState(CFepIndicator::EStateChinese);
			}
		response = EKeyWasConsumed;
		}
	else if(keyCode=='*')
		{
		SelectSymbol();
		response = EKeyWasConsumed;
		}
	else if(iMode == EChinese)
		{
		response = ChineseHandle(keyCode);
		}
	else  if(iMode == ELetter)
		{
		response = LetterHandle(keyCode);
		}
	else  if(iMode & ESymbol)
		{
		response = SymbolHandle(keyCode);
		}
	*/
	//return (iFep).OnFinishingHandlingKeyEvent_WithDownUpFilterL(EEventKey, (aKeyEvent), (response));
	FEP_END_KEY_EVENT_HANDLER_L(iFep, aKeyEvent, response);
#endif
	}

void CHaneaseFepControl::DisplayFep()
	{
	//LOG_METHOD(_L("CHaneaseFepControl::DisplayFep"));
	TRect rect(0, 0, 0, 0);
	if(iInput.Length()>0||iCand->Count()>0)
		{
	 	TInt h = iEikonEnv->TitleFont()->HeightInPixels() + 6;	
		
		TInt y = 206 -h;
		TCursorSelection aCursorSelection;
		TPoint aLeftSideOfBaseLine;
		TInt aHeight, aAscent, aDocumentPosition;
		iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(aCursorSelection);
		aDocumentPosition = aCursorSelection.LowerPos();
		iInputCapabilities.FepAwareTextEditor()->GetScreenCoordinatesForFepL(aLeftSideOfBaseLine, aHeight, aAscent, aDocumentPosition);
		if(aLeftSideOfBaseLine.iY + aHeight - aAscent>y)
			y = 206 - aHeight - aAscent - h;
		rect.SetRect(0, y, 174, y +h);
		}

	SetRect(rect);
	Window().Invalidate();
	}

void CHaneaseFepControl::CommitOutput() 
	{
	//LOG_METHOD(_L("CHaneaseFepControl::CommitOutput"));
	if(iCand->Count()>iHighlight)
		{
		//WRITE_LOG_FORMAT2(_L(" pos=%d value=0x%x"), iHighlight, iCand->At(iHighlight));
		iOutput->AppendL(iCand->At(iHighlight));
		//WRITE_LOG_FORMAT2(_L(" n=%d value=0x%x"), iOutput->Count(), iOutput->At(0));
		iFep.SimulateKeyEventsL(iOutput->Array());
		}
	Reset();
	}

void CHaneaseFepControl::DisplaySymbol()
	{
	//LOG_METHOD(_L("CHaneaseFepControl::DisplaySymbol"));
	TRect rect(0, 50, 174, 206);
	SetRect(rect);
	Window().Invalidate();
	}

void CHaneaseFepControl::SelectSymbol()
	{
	//LOG_METHOD(_L("CHaneaseFepControl::SelectSymbol"));
	iMode = (TMode)((TInt)iMode |ESymbol);
	
	if((TInt)iMode&EChinese)
		{
		iCand->AppendL(KChineseSymbol, KChineseSymbolNum);
		}
	else
		{
		iCand->AppendL(KEnglishSymbol, KEnglishSymbolNum);
		}
	
	DisplaySymbol();
	}

void CHaneaseFepControl::Draw(const TRect& /*aRect*/) const
	{
	//LOG_METHOD(_L("CHaneaseFepControl::Draw"));
	
	if(iInput.Length()==0 && iCand->Count()==0 &&(!((TInt)iMode&ESymbol)))
		return;
	
	CWindowGc& gc = SystemGc();
	TRect      drawRect = Rect();
	const CFont*     normalFont, *highlightFont;

	
	gc.Clear();
	gc.DrawRect(drawRect);

	normalFont = iEikonEnv->NormalFont();
	highlightFont = iEikonEnv->TitleFont();
	TInt h = highlightFont->HeightInPixels();
	
	if((TInt)iMode&ESymbol)
		{
		TPoint org(3,  25);		
		TInt i;
		TBuf16<1>cur(1);
		for(i=0; i< iCand->Count(); i++)
			{
			cur[0] = iCand->At(i);			
			if(i==iHighlight)
				{
				TRect rect(org.iX, org.iY-h , org.iX+h, org.iY);
				rect.Grow(2, 2);
				gc.DrawRect(rect);
				gc.UseFont(highlightFont);
				}
			else
				{
				gc.UseFont(normalFont);
				}
			gc.DrawText(cur, org);
			org.iX += 25;
			if(org.iX>174)
				{
				org.iX = 3;
				org.iY += 25;
				}
			}
		}
	else
		{
		TPoint org(3,  h + 3);
		gc.UseFont(normalFont);
		if(iInput.Length()>0)
			gc.DrawText(iInput, org);
		
		TInt i;
		TBuf16<1>cur(1);
		org.iX = 30;
		for(i=0; i< iCand->Count(); i++)
			{
			cur[0] = iCand->At(i);
			if(i==iHighlight)
				{
				TRect rect(org.iX, org.iY-h, org.iX + h, org.iY);
				rect.Grow(2, 2);
				gc.DrawRect(rect);
				gc.UseFont(highlightFont);
				gc.DrawText(cur, org);
				org.iX += highlightFont->CharWidthInPixels(cur[0])+2;
				}
			else
				{
				gc.UseFont(normalFont);
				gc.DrawText(cur, org);
				org.iX += normalFont->CharWidthInPixels(cur[0])+2;
				}
			}
		
		}
	gc.DiscardFont();
	}

void CHaneaseFepControl::SwitchInputModeL(TUint editorMode)
	{
	switch(editorMode)
		{
		case EAknEditorTextInputMode:
		case EAknEditorSecretAlphaInputMode:
		case EAknEditorAllInputModes:
			delete iLetterEngine;
			iLetterEngine = NULL;
			if(iEngine ==NULL)
				iEngine = CHaneaseEngine::NewL(*this, iInput, *iCand, *iOutput);
			iIndicator->SetState(CFepIndicator::EStateChinese);
			iMode = EChinese;
			break;
		case EAknEditorNumericInputMode:
			delete iLetterEngine;
			iLetterEngine = NULL;
			delete iEngine;
			iEngine = NULL;
			iIndicator->SetState(CFepIndicator::EStateNumeric);
			iMode = ENumber;
			break;
		case EAknEditorNullInputMode:
			delete iLetterEngine;
			iLetterEngine = NULL;
			delete iEngine;
			iEngine = NULL;
			iIndicator->SetState(CFepIndicator::EStateNone);
			iMode = ENoInput;
			break;
		}
	}

void CHaneaseFepControl::HandleChangeInFocus()
	{	
	LOG_METHOD(_L("CHaneaseFepControl::HandleChangeInFocus"));		
	iInputCapabilities = STATIC_CAST(const CCoeAppUi*, iCoeEnv->AppUi())->InputCapabilities();
	WRITE_LOG_FORMAT2(_L("iInputCapabilities = 0x%x IsNone=%d"), iInputCapabilities.Capabilities(), iInputCapabilities.IsNone());
	WRITE_LOG_FORMAT2(_L("FepAwareTextEditor()=0x%x CaptionRetrieverForFep=0x%x"), iInputCapabilities.FepAwareTextEditor(), iInputCapabilities.CaptionRetrieverForFep());
	WRITE_LOG_FORMAT(_L(" ObjectProvider=0x%x"), iInputCapabilities.ObjectProvider());

	if (iInputCapabilities.FepAwareTextEditor())
		{
		// Not all text editors are "fep aware". Fep somehow needs help from the editor window 
		// to determine the current editor capabilities.
		CAknEdwinState* editorState = STATIC_CAST(CAknEdwinState*, iInputCapabilities.FepAwareTextEditor()->Extension1()->State(KNullUid));
		TUint editorMode = editorState->CurrentInputMode();
		if (editorMode == EAknEditorNullInputMode)
			editorMode = editorState->DefaultInputMode();

		SwitchInputModeL(editorMode);
		}
	else // no FepAwareTextEditor
		{ // Check for non Edwin derived editors (eg mfne, tel no editor etc)
		if (iInputCapabilities.SupportsWesternNumericIntegerPositive() || iInputCapabilities.SupportsWesternNumericIntegerNegative())
			{
			SwitchInputModeL(EAknEditorNumericInputMode);
			}
		else if (iInputCapabilities.SupportsSecretText())
			{
			SwitchInputModeL(EAknEditorSecretAlphaInputMode);
			}
		else if (iInputCapabilities.SupportsWesternAlphabetic())
			{
			SwitchInputModeL(EAknEditorTextInputMode);
			}
		else 
			{
			SwitchInputModeL(EAknEditorNullInputMode);
			}
		}
	}

/*

void CFepSetupAppUi::HandleCommandL(TInt aCommand)
{
#if defined(_DEBUG)
RDebug::Print(_L("CFepSetupAppUi::HandleCommandL"));
#endif // _DEBUG
switch ( aCommand )
{
case EAknSoftkeyBack:
case EEikCmdExit:
{
Exit();
break;
}
case EFepSetupCmdDefault:
{
iEikonEnv->InfoMsg(_L("Default fep"));
iCoeEnv->InstallFepL(_L("CHINIPFEP.fep"));
iFepSetting->SetIsOn(ETrue);
iFepSetting->StoreChangesAndBroadcastL();

break;
}
case EFepSetupCmdMyfep:
{
iEikonEnv->InfoMsg(_L("Myfep"));
iCoeEnv->InstallFepL(_L("e:\\system\\fep\\myfep.FEP"));
iFepSetting->SetIsOn(ETrue);
iFepSetting->StoreChangesAndBroadcastL();

break;
}

default:
break; 
}
}




*/
// end of file

⌨️ 快捷键说明

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