📄 fepcontrol.cpp
字号:
#include <eikappui.h>
#include <eikenv.h> //CEikEnv
#include <bautils.h> // for BaflUtils
#include <aknedsts.h> // for CAknEdwinState
#include "fepexample.h"
#include "fepcontrol.h"
#include "multitapengine.h"
#include "fepindicator.h"
//_LIT(KT9FepResourceFileName, "z:\\system\\fep\\t9fep.rsc");
/////////////////////////////////////////////////////////////////////////////////
//
//Class CeQTapControl
//
/////////////////////////////////////////////////////////////////////////////////
/**
* Two phase construction
*/
CeQTapControl* CeQTapControl::NewL(CExampleFep& aFep)
{
CeQTapControl* self=new(ELeave) CeQTapControl(aFep);
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(); //self
return self;
}
CeQTapControl::CeQTapControl(CExampleFep& aFep)
:iFep(aFep),
iInputCapabilities(TCoeInputCapabilities::ENone),
iInputMode(EAknEditorNullInputMode),
iInsideInlineEditingTransaction(EFalse),
m_pEQTAPNumberic(NULL),
m_pEQTAPMultitap(NULL),
m_CurrentIMIndex(0),
m_pEQTAPInterpunction(NULL),
m_pEQTAPSmartEnglish(NULL),
m_bWindowVisible(FALSE),
m_pEQTAPSmartChinese(NULL),
m_pDictionaryChinese(NULL),
m_pSentenceChinese(NULL),
m_pEQTAPStroke(NULL)
{
}
void CeQTapControl::ConstructL()
{
// Set up fep key catching control - front window, null size, non-focusing
CreateWindowL();
SetNonFocusing();
RWindow& window = Window();
window.SetOrdinalPosition(0, ECoeWinPriorityFep);
TPoint fepControlPos(0, 162);
SetExtent(fepControlPos, TSize(176,45));
window.SetExtent(fepControlPos, TSize(176,45));
window.SetNonFading(ETrue);
// Create status pane indicator
iIndicator = CFepIndicator::NewL();
m_pEQTAPNumberic = CeQTapNumeric::NewL(this);
if(m_pEQTAPNumberic==NULL)
{
/*do something here??*/
}
m_pEQTAPMultitap = CeQTapMultitap::NewL (this);
if(m_pEQTAPMultitap==NULL)
{
/*do something here*/
}
m_pEQTAPInterpunction = CeQTapInterpunction::NewL(this);
if(m_pEQTAPInterpunction ==NULL)
{
/*DO SOMETHING HERE*/
}
m_pEQTAPSmartEnglish = CeQTapSmartEnglish::NewL(this);
if(m_pEQTAPSmartEnglish==NULL)
{
/* Do something here */
}
m_pEQTAPSmartChinese = CeQTapSmartChinese::NewL(this);
if(m_pEQTAPSmartChinese==NULL)
{
/* DO SOMETHING HERE */
}
m_pEQTAPStroke = CeQTapStroke::NewL(this);
if(m_pEQTAPStroke==NULL)
{
/*DO SOMETHING HERE*/
}
// The reason why we need to set up the T9 resource is that, Series 60 platform integrates the
// T9 engine into the system, and some on-board applications expect this resource to be
// present, if not, those applications will not work. The T9 resource is loaded when the T9 FEP
// start up.
//
// As a workaround solution, we load the T9 resource in our own FEP.
//TFileName resourceName(KT9FepResourceFileName);
//BaflUtils::NearestLanguageFile(iEikonEnv->FsSession(), resourceName);
//iResId = iEikonEnv->AddResourceFileL(resourceName);
SetFocusing(EFalse);
ActivateL();
Window().SetVisible(EFalse);//窗口不可见
DrawNow();
((CCoeAppUi*)iEikonEnv->AppUi())->AddToStackL(this,
ECoeStackPriorityFep, ECoeStackFlagSharable|ECoeStackFlagRefusesFocus);
}
CeQTapControl::~CeQTapControl()
{
if (iIndicator)
{
delete iIndicator;
iIndicator = NULL;
}
if(m_pEQTAPNumberic!=NULL)
{
delete m_pEQTAPNumberic;
m_pEQTAPNumberic = NULL;
}
if(m_pEQTAPMultitap!=NULL)
{
delete m_pEQTAPMultitap;
m_pEQTAPMultitap = NULL;
}
if(m_pEQTAPSmartEnglish!=NULL)
{
delete m_pEQTAPSmartEnglish;
m_pEQTAPSmartEnglish = NULL;
}
if(m_pEQTAPSmartChinese!=NULL)
{
delete m_pEQTAPSmartChinese;
m_pEQTAPSmartChinese = NULL;
}
if(m_pEQTAPStroke!=NULL)
{
delete m_pEQTAPStroke;
m_pEQTAPStroke= NULL;
}
iEikonEnv->DeleteResourceFile(iResId);
((CCoeAppUi*)iEikonEnv->AppUi())->RemoveFromStack(this);
}
// Please consult SDK for more information on Inline Editing transaction
void CeQTapControl::StartInlineEditL(MCoeFepAwareTextEditor& aFepAwareTextEditor, const TDesC& aInitialInlineText, TInt aPositionOfInsertionPointInInlineText, TBool aCursorVisibility)
{
aFepAwareTextEditor.StartFepInlineEditL(aInitialInlineText, aPositionOfInsertionPointInInlineText,
aCursorVisibility, NULL, *this, *this);
iInsideInlineEditingTransaction = ETrue;
}
// Please consult SDK for more information on Inline Editing transaction
void CeQTapControl::UpdateInlineEditL(const TDesC& aNewInlineText, TInt aPositionOfInsertionPointInInlineText)
{
iInputCapabilities.FepAwareTextEditor()->UpdateFepInlineTextL(aNewInlineText, aPositionOfInsertionPointInInlineText);
}
// Please consult SDK for more information on Inline Editing transaction
void CeQTapControl::CancelInlineEdit(MCoeFepAwareTextEditor& aFepAwareTextEditor)
{
aFepAwareTextEditor.CancelFepInlineEdit();
iInsideInlineEditingTransaction = EFalse;
ClearBuffer();
}
// Please consult SDK for more information on Inline Editing transaction
void CeQTapControl::CommitInlineEditL(MCoeFepAwareTextEditor& aFepAwareTextEditor, TBool aCursorVisibility)
{
aFepAwareTextEditor.SetInlineEditingCursorVisibilityL(aCursorVisibility);
iInsideInlineEditingTransaction = EFalse;
aFepAwareTextEditor.CommitFepInlineEditL(*iCoeEnv);
aFepAwareTextEditor.GetCursorSelectionForFep(iUncommittedText);
ClearBuffer();
}
void CeQTapControl::GetFormatOfFepInlineText(TCharFormat& /*aFormat*/, TInt& /*aNumberOfCharactersWithSameFormat*/, TInt /*aPositionOfCharacter*/) const
{
// No implementation
}
void CeQTapControl::HandlePointerEventInInlineTextL(TPointerEvent::TType /*aType*/, TUint /*aModifiers*/, TInt /*aPositionInInlineText*/)
{
// not supported in series 60 platform 1.x
}
TKeyResponse CeQTapControl::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aEventCode)
{
TKeyResponse response = EKeyWasNotConsumed;
TInt keyCode = aKeyEvent.iCode;
TBool longKeyPress=(aEventCode==EEventKey && aKeyEvent.iRepeats>=1 );//hejj
TInt nRespon=0;
if(aEventCode ==EEventKeyUp)
{
if(aKeyEvent.iScanCode==KEYCHANGEIM)
{
return OfferKeyEventInSwichModeL();
}
}
if (aEventCode != EEventKey)
{
return EKeyWasNotConsumed;
}
if (((keyCode == EKeyCBA1) || (keyCode == EKeyCBA2)) || (keyCode == EKeyMenu))
{
if(m_bWindowVisible==FALSE)
{
return EKeyWasNotConsumed;
}
else
{
return DoFunctionKeys(keyCode);
}
}
if (iFep.IsTurnedOnByL(aKeyEvent) || iFep.IsTurnedOffByL(aKeyEvent))
{
return EKeyWasConsumed;
}
if (!iFep.IsOn())
return EKeyWasNotConsumed;
if(m_pEQTAPInterpunction->GetIpState()== TRUE)//hejja
{
return m_pEQTAPInterpunction->CompleteInterpunction (keyCode);
}
response = EKeyWasNotConsumed;
if((keyCode == '*'))//&&(longKeyPress==TRUE))
{
if(longKeyPress==TRUE)
{
response = m_pEQTAPInterpunction->ChangeIMtoInterpunction();
return response;
}
}
switch (iInputMode)
{
case EAknEditorBiHUa:
nRespon = m_pEQTAPStroke->OnKeyEventProc((int)&aKeyEvent, aEventCode);
if(nRespon<0)
{
}
else
{
response =(TKeyResponse)nRespon;
}
break;
case EAKnEditorSmartChinese:
nRespon = m_pEQTAPSmartChinese->OnKeyEventProc((int)&aKeyEvent, aEventCode);
if(nRespon<0)
{
}
else
{
response =(TKeyResponse)nRespon;
}
break;
case EAknEditorSmartEnglish:
nRespon = m_pEQTAPSmartEnglish->OnKeyEventProc((int)&aKeyEvent, aEventCode);
if(nRespon<0)
{
}
else
{
response =(TKeyResponse)nRespon;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -