📄 eqtapsmartenglish.cpp
字号:
tmpRect.SetHeight(16);
gc.SetBrushColor(CANDBRUSHCOLOR);
gc.DrawRect(tmpRect);
//画分割线
gc.SetPenStyle(CGraphicsContext::ESolidPen);
gc.SetPenColor(LINECOLOR);
gc.DrawLine(TPoint(0,0),TPoint(rect.Width(),0));
/*
gc.DrawLine(TPoint(0,15),TPoint(rect.Width(),15));
gc.DrawLine(TPoint(0,29),TPoint(rect.Width(),29));
*/
//画三角
DrawUpDownArrow();
//写字符
if (m_bSelectMode==TRUE) //选择模式
{
DrawCandWithNumber();
}
else
{
DrawCand();
}
}
TBool CeQTapSmartEnglish::CurrentChange()
{
int pnCharBegin, pnCharEnd, pnDigiBegin, pnDigiEnd;
NEXTAP_GetActiveWordInfo(m_pSentenceEnglish, m_pDictionaryEnglish, &pnCharBegin, &pnCharEnd, &pnDigiBegin, &pnDigiEnd);
if(pnDigiBegin==0)
{
m_bCurrentWordIsNull=CURRENT_WORD_NOT_NULL;
return FALSE;
}
else
{
m_bCurrentWordIsNull=CURRENT_WORD_NULL;
return TRUE;
}
}
void CeQTapSmartEnglish::DrawArrow(int Style) const
{
CWindowGc& aGc = SystemGc();
TRect rect = Rect();
TInt temp = rect.Width()-3;
// TPoint upTriangle[3] = {TPoint(temp-8,36),TPoint(temp,36),TPoint(temp-4,32)};
// TPoint downTriangle[3] = {TPoint(temp-8,38),TPoint(temp,38),TPoint(temp-4,42)};
TPoint upTriangle[3] = {TPoint(temp-8,7),TPoint(temp,7),TPoint(temp-4,3)};
TPoint downTriangle[3] = {TPoint(temp-8,9),TPoint(temp,9),TPoint(temp-4,13)};
switch (Style)
{
case DOWN_DISABLE:
aGc.SetBrushColor(ARROWCOLOR);
aGc.SetPenColor(ARROWCOLOR);
aGc.DrawPolygon(downTriangle,3);
break;
case DOWN_ENABLE:
aGc.SetBrushColor(TEXTCOLOR);
aGc.SetPenColor(TEXTCOLOR);
aGc.DrawPolygon(downTriangle,3);
break;
case UP_DISABLE:
aGc.SetBrushColor(ARROWCOLOR);
aGc.SetPenColor(ARROWCOLOR);
aGc.DrawPolygon(upTriangle,3);
break;
case UP_ENABLE:
aGc.SetBrushColor(TEXTCOLOR);
aGc.SetPenColor(TEXTCOLOR);
aGc.DrawPolygon(upTriangle,3);
break;
}
}
void CeQTapSmartEnglish::DrawUpDownArrow() const
{
if(UpisActive() ==TRUE)
{
DrawArrow(UP_ENABLE);
}
else
{
DrawArrow(UP_DISABLE);
}
if(DownisActive() ==TRUE)
{
DrawArrow(DOWN_ENABLE);
}
else
{
DrawArrow(DOWN_DISABLE);
}
}
TBool CeQTapSmartEnglish::UpisActive(void) const
{
#ifdef ENGLISH_UNIFIED
if (m_pSentenceEnglish==NULL)
{
return EFalse;
}
if(m_pSentenceEnglish->nUnifiedCandTotal==0)
{
return EFalse;
}
if(m_pSentenceEnglish->nUnifiedCandBegin==0)
{
return EFalse;
}
else
{
return ETrue;
}
#else
if (m_pSentenceEnglish==NULL)
{
return EFalse;
}
if(m_pSentenceEnglish->nCandTotal==0)
{
return EFalse;
}
if(m_pSentenceEnglish->nCandBegin==0)
{
return EFalse;
}
else
{
return ETrue;
}
#endif
}
TBool CeQTapSmartEnglish::DownisActive(void) const
{
#ifdef ENGLISH_UNIFIED
if(m_pSentenceEnglish->nUnifiedCandTotal==0)
{
return EFalse;
}
if(m_pSentenceEnglish->nUnifiedCandBegin+m_pSentenceEnglish->nUnifiedCandNum ==m_pSentenceEnglish->nUnifiedCandTotal)
{
return EFalse;
}
else
{
return ETrue;
}
#else
if(m_pSentenceEnglish->nCandTotal==0)
{
return EFalse;
}
if(m_pSentenceEnglish->nCandBegin+m_pSentenceEnglish->nCandNum ==m_pSentenceEnglish->nCandTotal)
{
return EFalse;
}
else
{
return ETrue;
}
#endif
}
void CeQTapSmartEnglish::DrawCandWithNumber() const
{
CWindowGc& gc = SystemGc();
TInt len,i;
TBuf<16> wordTemp;
char *Number[]={
"7",
"8",
"9",
"*",
"0",
"#"
};
const CFont* fontUsed = iEikonEnv->SymbolFont();
gc.UseFont(fontUsed);
len=0;
#ifdef ENGLISH_UNIFIED
for( i=0; i < m_pSentenceEnglish->nUnifiedCandNum; i++)
{
wordTemp.Zero();
wordTemp.Append(Number[i][0]);
//wordTemp.Append(32);
gc.SetPenColor(CANDCOLOR);
// gc.DrawText(wordTemp,TPoint(len,43));
gc.DrawText(wordTemp,TPoint(len,14));
len = len + fontUsed->TextWidthInPixels(wordTemp);
gc.SetPenColor(TEXTCOLOR);
wordTemp.Zero();
wordTemp.Format(_L("%s "),m_pSentenceEnglish->pszUnifiedCand[i]);
// gc.DrawText(wordTemp,TPoint(len,43));
gc.DrawText(wordTemp,TPoint(len,14));
len = len + fontUsed->TextWidthInPixels(wordTemp);
}
#else
for( i=0; i < m_pSentenceEnglish->nCandNum; i++)
{
wordTemp.Zero();
wordTemp.Append(Number[i][0]);
//wordTemp.Append(32);
gc.SetPenColor(CANDCOLOR);
// gc.DrawText(wordTemp,TPoint(len,43));
gc.DrawText(wordTemp,TPoint(len,14));
len = len + fontUsed->TextWidthInPixels(wordTemp);
gc.SetPenColor(TEXTCOLOR);
wordTemp.Zero();
wordTemp.Format(_L("%s "),m_pSentenceEnglish->pszCand[i]);
// gc.DrawText(wordTemp,TPoint(len,43));
gc.DrawText(wordTemp,TPoint(len,14));
len = len + fontUsed->TextWidthInPixels(wordTemp);
}
#endif
gc.DiscardFont();
}
void CeQTapSmartEnglish::DrawCand() const
{
CWindowGc& gc = SystemGc();
TInt len,i;
TBuf<16> wordTemp;
if(m_bCurrentWordIsNull==CURRENT_WORD_NULL && m_bKeyMode == ENoMove)
{
return ;
}
if(m_pSentenceEnglish->szDigi[0]==0)
{
return;
}
const CFont* fontUsed = iEikonEnv->SymbolFont();
gc.UseFont(fontUsed);
len=0;
#ifdef ENGLISH_UNIFIED
for( i=0; i < m_pSentenceEnglish->nUnifiedCandNum; i++)
{
wordTemp.Zero();
wordTemp.Append('8');
len = len + fontUsed->TextWidthInPixels(wordTemp);
gc.SetPenColor(TEXTCOLOR);
wordTemp.Zero();
wordTemp.Format(_L("%s "),m_pSentenceEnglish->pszUnifiedCand[i]);
// gc.DrawText(wordTemp,TPoint(len,43));
gc.DrawText(wordTemp,TPoint(len,14));
len = len + fontUsed->TextWidthInPixels(wordTemp);
}
#else
for( i=0; i < m_pSentenceEnglish->nCandNum; i++)
{
wordTemp.Zero();
wordTemp.Append('8');
len = len + fontUsed->TextWidthInPixels(wordTemp);
gc.SetPenColor(TEXTCOLOR);
wordTemp.Zero();
wordTemp.Format(_L("%s "),m_pSentenceEnglish->pszCand[i]);
// gc.DrawText(wordTemp,TPoint(len,43));
gc.DrawText(wordTemp,TPoint(len,14));
len = len + fontUsed->TextWidthInPixels(wordTemp);
}
#endif
gc.DiscardFont();
}
TKeyResponse CeQTapSmartEnglish::OnKeyMoveUp(const TKeyEvent& aKeyEvent)
{
if(m_pSentenceEnglish->szDigi [0]==0)
{
return EKeyWasNotConsumed;
}
#ifdef ENGLISH_UNIFIED
NEXTAP_MoveCandPredictEN(m_pSentenceEnglish, m_pDictionaryEnglish,PATTREE_MOVESTATE_LEFT, PATTREE_UNIFIED_CAND);
#else
NEXTAP_MoveCandPredictEN(m_pSentenceEnglish, m_pDictionaryEnglish,PATTREE_MOVESTATE_LEFT, PATTREE_CAND);
#endif
m_peQTapCtrl->FreshSEWindow();
return EKeyWasConsumed;
}
TKeyResponse CeQTapSmartEnglish::OnKeyMoveDown(const TKeyEvent& aKeyEvent)
{
if(m_pSentenceEnglish->szDigi [0]==0)
{
return EKeyWasNotConsumed;
}
#ifdef ENGLISH_UNIFIED
NEXTAP_MoveCandPredictEN(m_pSentenceEnglish, m_pDictionaryEnglish,PATTREE_MOVESTATE_RIGHT, PATTREE_UNIFIED_CAND);
#else
NEXTAP_MoveCandPredictEN(m_pSentenceEnglish, m_pDictionaryEnglish,PATTREE_MOVESTATE_RIGHT, PATTREE_CAND);
#endif
m_peQTapCtrl->FreshSEWindow();
return EKeyWasConsumed;
}
void CeQTapSmartEnglish::OnLostFocus()
{
if(m_pSentenceEnglish==NULL)
{
return;
}
if(m_pSentenceEnglish->szDigi[0]!=0)
{
m_pSentenceEnglish->szDigi[0]=0;
NEXTAP_ResetSentenceEN(m_pSentenceEnglish, m_pDictionaryEnglish, PATTREE_EN_LOWERCASE,MAXCAND*2,MAXCAND*2);
ResetValue();
m_peQTapCtrl->CommitInlineEdit(TRUE);
}
}
TKeyResponse CeQTapSmartEnglish::DoFunctionKeys(TInt keycode)
{
TKeyResponse response = EKeyWasNotConsumed;
switch(keycode)
{
case EKeyCBA1:
NEXTAP_AddDigi2SentenceEN(m_pSentenceEnglish, m_pDictionaryEnglish, '\'');
response = EKeyWasConsumed;
m_peQTapCtrl->FreshSEWindow ();
break;
case EKeyCBA2:
break;
case EKeyMenu:
break;
default:
break;
}
return response;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -