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

📄 eqtapinterpunction.cpp

📁 Symbian平台 数字键盘手机输入法源码
💻 CPP
字号:
// eQTapInterpunction.cpp: implementation of the CeQTapInterpunction class.
//
//////////////////////////////////////////////////////////////////////

#include "eQTapInterpunction.h"
#include "FepControl.h"

#if 1
const TUint8 biaoDian[IP_TEXT_NUMBER][6] =
{
	{0x0C,0xFF,0x00,0x00,0x00,0x00},			//,       
	{0x02,0x30,0x00,0x00,0x00,0x00},          //。       
	{0x3F,0x00,0x00,0x00,0x00,0x00},          //?       
	{0x2D,0x00,0x00,0x00,0x00,0x00},          //-       
	{0x3B,0x00,0x00,0x00,0x00,0x00},          //;       
	{0x40,0x00,0x00,0x00,0x00,0x00},          //@       
	{0x21,0x00,0x00,0x00,0x00,0x00},          //!       
	{0x25,0x00,0x00,0x00,0x00,0x00},          //%       
	{0x4C,0x00,0x00,0x00,0x00,0x00},          //,       
	{0x2E,0x00,0x00,0x00,0x00,0x00},          //.       
	{0x1F,0xFF,0x00,0x00,0x00,0x00},          //?       
	{0x0E,0x30,0x00,0x00,0x00,0x00},          //『       
	{0x0F,0x30,0x00,0x00,0x00,0x00},          //』       
	{0x0A,0x30,0x00,0x00,0x00,0x00},          //《       
	{0x0B,0x30,0x00,0x00,0x00,0x00},          //》       
	{0x01,0xFF,0x00,0x00,0x00,0x00},          //!       
	{0x1D,0xFF,0x00,0x00,0x00,0x00},          //=       
	{0x0B,0xFF,0x00,0x00,0x00,0x00},          //+       
	{0x0D,0xFF,0x00,0x00,0x00,0x00},          //-       
	{0x28,0x00,0x00,0x00,0x00,0x00},          //(       
	{0x29,0x00,0x00,0x00,0x00,0x00},          //)       
	{0x2A,0x00,0x00,0x00,0x00,0x00},          //*       
	{0x5E,0x00,0x00,0x00,0x00,0x00},          //^       
	{0x3A,0x00,0x00,0x00,0x00,0x00},          //:       
	{0x29,0x00,0x00,0x00,0x00,0x00},          //)       
	{0x26,0x20,0x00,0x00,0x00,0x00},          //…       
	{0xD7,0x00,0x00,0x00,0x00,0x00},          //×       
	{0x01,0x30,0x00,0x00,0x00,0x00},          //、       
	{0xE5,0xFF,0x00,0x00,0x00,0x00},          //¥       
	{0x03,0xFF,0x00,0x00,0x00,0x00},          //#       
	{0xCE,0x25,0x00,0x00,0x00,0x00},          //◎       
	{0x5E,0xFF,0x00,0x00,0x00,0x00},          //~       
	{0x7C,0x00,0x00,0x00,0x00,0x00},          //|       
	{0x7B,0x00,0x00,0x00,0x00,0x00},          //{       
	{0x7D,0x00,0x00,0x00,0x00,0x00},          //}       
	{0x1C,0x20,0x00,0x00,0x00,0x00},          //“       
	{0x1D,0x20,0x00,0x00,0x00,0x00},          //”       
	{0x1B,0xFF,0x00,0x00,0x00,0x00},          //;       
	{0x18,0x20,0x00,0x00,0x00,0x00},          //‘       
	{0x19,0x20,0x00,0x00,0x00,0x00},          //’       
	{0x5C,0x00,0x5C,0x00,0x00,0x00},          //\\       
	{0x3A,0x00,0x29,0x00,0x00,0x00},          //:)       
	{0x3A,0x00,0x28,0x00,0x00,0x00},          //:(       
	{0x3A,0x00,0x4F,0x00,0x00,0x00},          //:O       
	{0x3A,0x00,0x44,0x00,0x00,0x00},          //:D       
	{0x3B,0x00,0x29,0x00,0x00,0x00},          //;)       
	{0x3B,0x00,0x50,0x00,0x00,0x00},          //;P       
	{0x24,0x00,0x00,0x00,0x00,0x00},          //$       
};

#else //#if 0


	const TUint8 douHao[4]        = {0x0C, 0xFF, 0, 0};   //逗号,
	const TUint8 juHao[4]         = {0x02, 0x30, 0, 0};   //句号。
	const TUint8 wenHao[4]        = {0x1F, 0xFF, 0, 0};   //问号?
	const TUint8 tanHao[4]        = {0x01, 0xFF, 0, 0};   //叹号!
	const TUint8 maoHao[4]        = {0x1A, 0xFF, 0, 0};   //冒号:
	const TUint8 fenHao[4]        = {0x1B, 0xFF, 0, 0};   //分号;
	const TUint8 xingHao[4]       = {0x2A, 0x00, 0, 0};   //星号*
	const TUint8 baifenHao[4]     = {0x25, 0x00, 0, 0};   //百分号%
	const TUint8 huobiHao[4]      = {0x04, 0xFF, 0, 0};   //货币号$
	const TUint8 zuoshumingHao[4] = {0x0A, 0x30, 0, 0};   //左书名号《
	const TUint8 youshumingHao[4] = {0x0B, 0x30, 0, 0};   //右书名号》
	const TUint8 zuokuoHao[4]     = {0x08, 0xFF, 0, 0};   //左括号(
	const TUint8 youkuoHao[4]     = {0x09, 0xFF, 0, 0};   //右括号)
	const TUint8 xiaoyuHao[4]     = {0x08, 0x30, 0, 0};   //小于号〈
	const TUint8 dayuHao[4]       = {0x09, 0x30, 0, 0};   //大于号〉
	const TUint8 andHao[4]        = {0x40, 0x00, 0, 0};   //and号@
	const TUint8 zuoyinHao[4]     = {0x1C, 0x20, 0, 0};   //左引号"
	const TUint8 youyinHao[4]     = {0x1D, 0x20, 0, 0};   //右引号"

	const TUint8 *biaoDian[] = 
	{
			douHao , juHao, wenHao, tanHao, maoHao, 
			fenHao, xingHao, baifenHao,
			huobiHao, zuoshumingHao, youshumingHao, 
			zuokuoHao, youkuoHao, xiaoyuHao,
			dayuHao, andHao, zuoyinHao, youyinHao 
	};
#endif // #if 0

CeQTapInterpunction* CeQTapInterpunction::NewL(CeQTapControl* aControl)
{

	CeQTapInterpunction* self = new(ELeave)CeQTapInterpunction(aControl);
	CleanupStack::PushL(self);
	self->ConstructL();
	CleanupStack::Pop();	// self
	return self;
}
CeQTapInterpunction::CeQTapInterpunction()
:	m_iInterpunctionList(0),
	m_iCurrentPos(0)
{
	m_WholeSentence.Zero ();
}
CeQTapInterpunction::CeQTapInterpunction(CeQTapControl* aControl)
:	m_iInterpunctionList(0),
	m_iCurrentPos(0)
{
	m_peQTapCtrl = aControl;
	m_bIsIMActive = FALSE;
	m_WholeSentence.Zero ();
}
CeQTapInterpunction::~CeQTapInterpunction()
{

}

void CeQTapInterpunction::DrawBDText (CWindowGc& gc, TBuf<16>& Text, TInt nWordIndex, const CFont* pfont) const
{
	TInt x=0;
	TInt y=0;
	TInt xpos =0;
	TInt ypos =0;

	xpos = pfont->TextWidthInPixels(Text);
	ypos = pfont->HeightInPixels();

	x = (nWordIndex %IP_TEXT_VERT_NUMBER)*IP_LINE_WIDTH;
	y = (nWordIndex /IP_TEXT_VERT_NUMBER)*IP_LINE_HEIGHT+IP_LINE_HEIGHT;

	x = x + ((IP_LINE_WIDTH - xpos)>>1);
	y = y - ((IP_LINE_HEIGHT- ypos)>>1);
	gc.DrawText (Text, TPoint(x, y));
}

void CeQTapInterpunction::ConstructL ()
{
}

void CeQTapInterpunction::DrawBD() const    
{
	CWindowGc& gc = SystemGc();
	TRect  rect  = Rect();
	TBuf<16> wordTemp;
//	TInt pos;
	TInt i=0;
	
	gc.Clear();

	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
	gc.SetPenStyle(CGraphicsContext::ENullPen);

	
	//因为是标点所以只用画一行即可
	gc.SetBrushColor(CANDBRUSHCOLOR);
	gc.DrawRect(rect);
	//画分割线
	gc.SetPenStyle(CGraphicsContext::ESolidPen);
	gc.SetPenColor(LINECOLOR);
//	gc.DrawLine(TPoint(0,rect.iTl .iY),TPoint(rect.Width(),rect.iTl .iY)));
	for(i=0;i<IP_LINE_HORZ_NUMBER;i++)
	{
		gc.DrawLine(TPoint(0,i*IP_LINE_HEIGHT),TPoint(rect.Width(),i*IP_LINE_HEIGHT));
	}
	gc.DrawLine(TPoint(0,i*IP_LINE_HEIGHT-1),TPoint(rect.Width(),i*IP_LINE_HEIGHT-1));
	for(i=0;i<IP_LINE_VERT_NUMBER;i++)
	{
		gc.DrawLine (TPoint(i*IP_LINE_WIDTH, 0), TPoint(i*IP_LINE_WIDTH, rect.Height ()));
	}
	gc.DrawLine (TPoint(i*IP_LINE_WIDTH+1, 0), TPoint(i*IP_LINE_WIDTH+1, rect.Height ()));
	//获取字符
	gc.SetPenColor(TEXTCOLOR);
	const CFont* fontUsed = iEikonEnv->TitleFont();
	gc.UseFont(fontUsed);
	wordTemp.Zero();

	for(i=0;i<IP_TEXT_NUMBER;i++)
	{
		wordTemp.Format(_L("%s"), biaoDian[i]);
		DrawBDText(gc, wordTemp, i, fontUsed);
	}

	gc.SetBrushStyle(CGraphicsContext::ENullBrush);
	gc.SetPenStyle(CGraphicsContext::ESolidPen);
	gc.SetPenColor(SELECTLINECOLOR);
	gc.SetPenSize(TSize(3, 3));
	gc.DrawRect (TRect((m_iCurrentPos %IP_TEXT_VERT_NUMBER)*IP_LINE_WIDTH, (m_iCurrentPos /IP_TEXT_VERT_NUMBER)*IP_LINE_HEIGHT,
		((m_iCurrentPos %IP_TEXT_VERT_NUMBER) +1)*IP_LINE_WIDTH, ((m_iCurrentPos /IP_TEXT_VERT_NUMBER)+1)*IP_LINE_HEIGHT));
	/*			
	pos=0;
	for( i=0; i < 6; i++)
	{
		wordTemp.Zero();
		wordTemp.Format(_L("%d"),i+1);
		gc.SetPenColor(CANDCOLOR);
		gc.DrawText(wordTemp,TPoint(pos,16));
		pos = pos + fontUsed->TextWidthInPixels(wordTemp);
						
		wordTemp.Zero();
		gc.SetPenColor(TEXTCOLOR);
		wordTemp.Format(_L("%s"),biaoDian[i+6*m_iInterpunctionList]);
		gc.DrawText(wordTemp,TPoint(pos,16));
		pos = pos + fontUsed->TextWidthInPixels(wordTemp);
	}
	*/

	gc.DiscardFont();

}
/******************************************************************************
Name			:	CompleteInterpunction

Purpose			:	update the content and send it to the target, then change to the normal mode

Parameters		:	keycode			key data

Return values	:	if the key is 1-6, send the right interpunction to the target, and return the
					EKeyWasConsumed. If the key is not 1-6, it returns EKeyWasConsumed, and if it 
					returns EKeyWasNotConsumed, the digital will be send to the target, not the 
					interpunction.

Modify Records	:	
*******************************************************************************/
TKeyResponse CeQTapInterpunction::CompleteInterpunction(TUint keyCode)
{
	TKeyResponse response = EKeyWasNotConsumed;
	TInt	nLine =0;

	switch (keyCode)
	{
		case EKeyOK:
		if (!m_peQTapCtrl->IsInlineEditTrans())
			{ 
			// Previous transaction is not inline editor editing, so start it.
				m_peQTapCtrl->StartInlineEdit(KNullDesC, 0, ETrue);
			}
			UpdateBDContent(EFalse);
			m_peQTapCtrl->UpdateInlineEditL(m_WholeSentence,m_WholeSentence.Length());
			m_peQTapCtrl->CommitInlineEdit(ETrue);	
		case '#':
			/*change it into normal IM*/
			m_bIsIMActive=FALSE;
			/*refresh the window*/
			m_peQTapCtrl->FreshFepWindow();
			response = EKeyWasConsumed;
			break;
		case EKeyLeftArrow:
			nLine = m_iCurrentPos/IP_TEXT_VERT_NUMBER;
			m_iCurrentPos--;
			if(m_iCurrentPos<nLine*IP_TEXT_VERT_NUMBER)
			{
				m_iCurrentPos = (nLine+1)*IP_TEXT_VERT_NUMBER-1;
			}
			m_peQTapCtrl->FreshIPWindow ();
			response = EKeyWasConsumed;
			break;
		case EKeyRightArrow:
			nLine = m_iCurrentPos/IP_TEXT_VERT_NUMBER;
			m_iCurrentPos++;
			if(m_iCurrentPos>=(nLine+1)*IP_TEXT_VERT_NUMBER)
			{
				m_iCurrentPos = nLine*IP_TEXT_VERT_NUMBER;
			}
			m_peQTapCtrl->FreshIPWindow ();
			response = EKeyWasConsumed;
			break;
		case EKeyUpArrow:
			nLine = m_iCurrentPos%IP_TEXT_VERT_NUMBER;
			m_iCurrentPos-=IP_TEXT_VERT_NUMBER;
			if(m_iCurrentPos<0)
			{
				m_iCurrentPos = IP_TEXT_NUMBER-IP_TEXT_VERT_NUMBER+nLine;
			}
			m_peQTapCtrl->FreshIPWindow ();
			response = EKeyWasConsumed;
			break;			
		case EKeyDownArrow:
			nLine = m_iCurrentPos%IP_TEXT_VERT_NUMBER;
			m_iCurrentPos+=IP_TEXT_VERT_NUMBER;
			if(m_iCurrentPos>=IP_TEXT_NUMBER)
			{
				m_iCurrentPos = nLine;
			}
			m_peQTapCtrl->FreshIPWindow ();
			response = EKeyWasConsumed;
			break;
		default:
			response = EKeyWasConsumed;

	}
	return response;

}
/******************************************************************************
Name			:	ChangeIMtoInterpunction

Purpose			:	change the im to interpunction interface.

Parameters		:	NULL

Return values	:	EKeyWasConsumed, becuase the change always success.

Modify Records	:	
*******************************************************************************/

TKeyResponse CeQTapInterpunction::ChangeIMtoInterpunction()
{
	
	//必须要保证不是标点的时候才切换
	if(m_bIsIMActive==FALSE)
	{
		/*we should put all the input text to target first */
//		m_peQTapCtrl->OfferKeyEventInOKModeL(EKeyOK);

		/*update the mode to Interpunction*/
		m_iInterpunctionList=0;
		m_bIsIMActive=TRUE;      //改成标点输入
		m_iCurrentPos = 0;
		UpdateBDContent(ETrue);//keyCode

		/*refresh the window*/
		ActiveIPWindow(ETrue);
		m_peQTapCtrl->FreshIPWindow ();
	}
	return EKeyWasConsumed;

}
void CeQTapInterpunction::ActiveIPWindow(TBool aActive)
{
	TPoint fepControlPos;
	
	TInt	nWidth =IP_WINDOW_WIDTH;
	TInt	nHeight = IP_WINDOW_HEIGHT;
	
	RWindow& window = m_peQTapCtrl->GetRWindow() ;

	fepControlPos.iX=IP_WINDOW_X;
	fepControlPos.iY=IP_WINDOW_Y;//162+OUTAREAWIDTH*2-8;
	SetExtent(fepControlPos, TSize(nWidth,nHeight-fepControlPos.iY));
	window.SetExtent(fepControlPos, TSize(nWidth,nHeight-fepControlPos.iY));

	if (aActive == TRUE)	
	{
		window.SetVisible(ETrue);
	}
	else
	{
		window.SetVisible(EFalse);
	}

}

/******************************************************************************
Name			:	UpdateBDContent

Purpose			:	Update the content of the text to display

Parameters		:	aClean		Clear the content or not.

Return values	:	NULL

Modify Records	:	
*******************************************************************************/
void CeQTapInterpunction::UpdateBDContent(TBool aClean)//const TKeyEvent& aKeyEvent
{
	//汉字标点定义,18个标点符号
	
	/*process the BiaoDian mode, iCurWordPos means the input digital, here only 1-6 is avaliable*/
		/*make sure the digital is validate*/

	m_WholeSentence.Zero ();
	/*
	if (m_iCurrentPos > 0 && m_iCurrentPos< 7)
	{
		m_WholeSentence.Format(_L("%s"),biaoDian[m_iCurrentPos-1+6*m_iInterpunctionList]);
	}
	*/
	if(m_iCurrentPos >=0 && m_iCurrentPos<IP_TEXT_NUMBER)
	{
		m_WholeSentence.Format(_L("%s"),biaoDian[m_iCurrentPos]);
	}
	/*if need to clear all the input data*/
	/*
	if (aClean==TRUE) 
	{
		m_peQTapCtrl->GetiWord ().Zero();
	}
	*/
}

⌨️ 快捷键说明

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