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

📄 editbase.c

📁 深圳市微逻辑电子有限公司 巨果&#8226 Kingmos&reg 系统核心
💻 C
📖 第 1 页 / 共 5 页
字号:
			}
//			RETAILMSG(1,( "*lpCurChar  = %d \r\n",*lpCurChar));
//			if (*lpCurChar<0)
			if (*lpCurChar<0 || *lpCurChar>0x7F)
			{ // the current character is Chinese
				nCurCharWidth=ChineseCharWidth;
//			    RETAILMSG(1,( "nCurCharWidth 000 = %d \r\n",nCurCharWidth));
				nCurCharLen=2;
			}
      else
      { // the currrent character is English and Symbol
        nCurCharWidth=lpCharWidthBuffer[*lpCurChar];
//		RETAILMSG(1,( "nCurCharWidth 111 = %d \r\n",nCurCharWidth));
        nCurCharLen=1;
      }
			if (lpEditItem->lpInvertStart!=lpEditItem->lpInvertEnd)
			{  // is exist invert area
				if (lpCurChar==lpEditItem->lpInvertStart)
				{  // this is to invert start ,enter the invert area
					// display this line start position
					x=nCurShowPos-lpEditItem->nDisplayx;
					y=(nCurLine-lpEditItem->nDisplayLine)*nTextHeight+lpEditItem->iStartPos;

					// display this line
					if (y>=0&&y<nWindowHeight)
					{
//						RETAILMSG(1,("TextOut3 (%d,%d) %s -- %d\r\n",x,y,lpLineAddress,nShowLen));						
						TextOut(hdc,x,y,lpLineAddress,nShowLen);
					}

					// set Next Display Area : Invert Area
					nCurShowPos=nCurCharPos;
					lpLineAddress=lpCurChar;
					nShowLen=0;

					// Set Invert area color
					SetPDAEditColor(hWnd,hdc,INVERTCOLOR);
				}
				if (lpCurChar==lpEditItem->lpInvertEnd)
				{  // this is to invert end , out the invert area

					// display Invert area text
					x=nCurShowPos-lpEditItem->nDisplayx;
					y=(nCurLine-lpEditItem->nDisplayLine)*nTextHeight+lpEditItem->iStartPos;
					// display this line
					if (y>=0&&y<nWindowHeight)
					{
//						RETAILMSG(1,("TextOut4 (%d,%d) %s -- %d\r\n",x,y,lpLineAddress,nShowLen));						
						TextOut(hdc,x,y,lpLineAddress,nShowLen);
					}

					// set Next Display Area : Invert Area
					lpLineAddress=lpCurChar;
					nShowLen=0;
					nCurShowPos=nCurCharPos;

					// restore normal area color
					if (!(lpEditItem->dwStyle&WS_DISABLED))
					{
// !!! modified End by jami chen in 2004.7.12
//						SetPDAEditColor(hWnd,hdc,NORMALCOLOR);
						if (lpEditItem->dwStyle&ES_READONLY)
						{ // 是只读
							SetPDAEditColor(hWnd,hdc,READONLYCOLOR);
						}
						else
						{  // 一般文本
							SetPDAEditColor(hWnd,hdc,NORMALCOLOR);
						}
// !!! modified End by jami chen in 2004.7.12
					}
				}
			}
      if (dwStyle&ES_FORMAT)
      {
          if ((lpCurChar==lpEditItem->lpPDAEditBuffer)&&(dwFlag==PE_SHOWCLIENT||dwFlag==PE_SHOWALL))
          { // will display the format title text , must display the edit text
					  x=nCurShowPos-lpEditItem->nDisplayx;
					  y=(nCurLine-lpEditItem->nDisplayLine)*nTextHeight+lpEditItem->iStartPos;
					  // display this line
						if (y>=0&&y<nWindowHeight)
						{
//						  RETAILMSG(1,("TextOut6 (%d,%d) %s -- %d\r\n",x,y,lpLineAddress,nShowLen));						
						  TextOut(hdc,x,y,lpLineAddress,nShowLen);
						}
						// display the format title
            ShowFormatText(hWnd,hdc,lpEditItem,
                                  FmtAnalysis.lpTitle,
                                  FmtAnalysis.cTitleLen,
                                  &nCurCharPos,
                                  &nCurLine);
            // set Next Display Area : format item edit text
            nCurShowPos=nCurCharPos;
					  lpLineAddress=lpCurChar;
					  nShowLen=0;
          }
          if (*lpCurChar==FMTSEPARATE)
          {// will display the next item text
						// display this item text first
					  x=nCurShowPos-lpEditItem->nDisplayx;
					  y=(nCurLine-lpEditItem->nDisplayLine)*nTextHeight+lpEditItem->iStartPos;
					  // display this line
						if (y>=0&&y<nWindowHeight)
						{
//						  RETAILMSG(1,("TextOut7 (%d,%d) %s -- %d\r\n",x,y,lpLineAddress,nShowLen));						
						  TextOut(hdc,x,y,lpLineAddress,nShowLen);
						}

						// display this item tile text
            ShowFormatText(hWnd,hdc,lpEditItem,
                                  (FmtAnalysis.arrayFmtItem[nFMTItem]).lpTileText,
                                  (FmtAnalysis.arrayFmtItem[nFMTItem]).cTileTextLen,
                                  &nCurCharPos,
                                  &nCurLine);

            nCurShowPos=nCurCharPos;
				    lpCurChar++;

            // set Next Display Area :  next item text
					  lpLineAddress=lpCurChar;
					  nShowLen=0;
				    nAddLen++;
            nFMTItem++;
						if (nFMTItem>=FORMATITEMMAXNUM)
							nFMTItem=FORMATITEMMAXNUM-1;
            continue;
          }
      }
			if (dwStyle&ES_MULTILINE)
			{ // the edit control is multiple line
				if (*lpCurChar==0x0d&&*(lpCurChar+1)==0x0a)
				{  // this code is enter code , must display this line and to next line
					// display this line start position
					x=nCurShowPos-lpEditItem->nDisplayx;
					y=(nCurLine-lpEditItem->nDisplayLine)*nTextHeight+lpEditItem->iStartPos;
					if ((y>=rcClientRect.bottom)&&dwFlag!=PE_SHOWALL)
						break;

					// display this line
					if (y>=0&&y<nWindowHeight)
					{
//						RETAILMSG(1,("TextOut8 (%d,%d) %s -- %d\r\n",x,y,lpLineAddress,nShowLen));						
						TextOut(hdc,x,y,lpLineAddress,nShowLen);
					}

//          ClearLine(hWnd,hdc,lpEditItem,nCurCharPos-lpEditItem->nDisplayx,nCurLine);
          ClearLine(hWnd,hdc,lpEditItem,(int)(nCurCharPos-lpEditItem->nDisplayx),y);
					// display the separate line
          if (dwStyle&ES_LINESEPARATE)
            DrawLineSeparate(hWnd,hdc,lpEditItem,(int)(nCurLine-lpEditItem->nDisplayLine));

					// to next char
					lpCurChar+=2;
					nAddLen+=2;
					lpLineAddress=lpCurChar;

					// to next line
					nShowLen=0;
					nCurLine++;
					nCurShowPos=GetxStartOfLine(hWnd,lpEditItem,lpCurChar);
					nCurCharPos=nCurShowPos;
					// to next circle
					continue;
				}
				if (dwStyle&ES_AUTONEWLINE)
				{
					if (nCurCharPos+nCurCharWidth>nWindowWidth)
					{
						// display this line start position
						x=nCurShowPos-lpEditItem->nDisplayx;
						y=(nCurLine-lpEditItem->nDisplayLine)*nTextHeight+lpEditItem->iStartPos;

						// display this line
						if (y>=0&&y<nWindowHeight)
						{
//							RETAILMSG(1,("TextOut9 (%d,%d) %s -- %d\r\n",x,y,lpLineAddress,nShowLen));						
							TextOut(hdc,x,y,lpLineAddress,nShowLen);
						}

//            ClearLine(hWnd,hdc,lpEditItem,nCurCharPos,nCurLine);
              ClearLine(hWnd,hdc,lpEditItem,(int)(nCurCharPos-lpEditItem->nDisplayx),y);

						if (dwStyle&ES_LINESEPARATE)
							DrawLineSeparate(hWnd,hdc,lpEditItem,(int)(nCurLine-lpEditItem->nDisplayLine));
						// to next char
						lpLineAddress=lpCurChar;
						// to next line
						nShowLen=0;
						nCurLine++;
						nCurShowPos=GetxStartOfLine(hWnd,lpEditItem,lpCurChar);
						nCurCharPos=nCurShowPos;
					}
				}
			}
			else
			{ 
// !!! Add By Jami chen in 2003.10.23
				// is single line
// !!! modified By Jami chen in 2004.05.11
//  错误原因:nCurShowPos -- 开始显示字符的位置
//			  nCurCharPos -- 没有加入当前字符(前一个字符)的位置,即当前字符开始显示的位置
//            在这里只需要判断当前字符是否已经在屏幕外就可以了,而当前字符的屏幕位置是nCurCharPos-lpEditItem->nDisplayx
//			  而不是nCurShowPos-lpEditItem->nDisplayx + nCurCharPos。
//			  另如果使用nCurCharPos-lpEditItem->nDisplayx + nCurCharWidth,则最后一个字符(半个字符)不能显示,而且必须调用
//			  ClearTextEnd来清除行尾的字符痕迹,不加nCurCharWidth就不必调用,因为已经全部清除了

//				if ((nCurShowPos-lpEditItem->nDisplayx + nCurCharPos) > nWindowWidth)
//				if ((nCurCharPos-lpEditItem->nDisplayx + nCurCharWidth) > nWindowWidth)
				if ((nCurCharPos-lpEditItem->nDisplayx) > nWindowWidth)
// !!! modified end
				{
					x=nCurShowPos-lpEditItem->nDisplayx;
					y=(nCurLine-lpEditItem->nDisplayLine)*nTextHeight+lpEditItem->iStartPos;
					if (y>=0&&y<nWindowHeight)
					{
	//					RETAILMSG(1,("TextOut1 (%d,%d) %s -- %d\r\n",x,y,lpLineAddress,nShowLen));						
						TextOut(hdc,x,y,lpLineAddress,nShowLen);
					}
					if (dwStyle&ES_LINESEPARATE)
						DrawLineSeparate(hWnd,hdc,lpEditItem,(short)(nCurLine-lpEditItem->nDisplayLine));
					// exit circle
					break;
				}
			}
// !!! Add End By Jami chen in 2003.10.23

			// to next char
	        nCurCharPos+=nCurCharWidth;
//			RETAILMSG(1,("nCurCharPos = %d ,nCurCharWidth = %d\r\n",nCurCharPos,nCurCharWidth));
 	       lpCurChar+=nCurCharLen;
			nShowLen+=nCurCharLen;
			nAddLen+=nCurCharLen;

		}
/*
        if( y + nTextHeight < rcClientRect.bottom )
        {
            rcClientRect.top = y+nTextHeight;
            FillRect( hdc, &rcClientRect, GetStockObject( WHITE_BRUSH ) );
        }
*/
		// show caret
		ShowPDACaret(hWnd);
// !!! add By Jami chen for have a call back style
		if (lpEditItem->dwStyle&ES_CALLBACK)
		{
			ShowCallBackFlag(hWnd,hdc,lpEditItem);
		}
// !!! add End
		return;
}
/**************************************************
声明: void ClearInvert(HWND hWnd,LPEDITITEM lpEditItem, BOOL bFlag)
参数:
	IN hWnd -- 窗口句柄
	IN lpEdititem -- 编辑条目结构指针
	IN bFlag -- 重绘标志
返回值:无
功能描述:清除选择区域。
引用: 
************************************************/
 void ClearInvert(HWND hWnd,LPEDITITEM lpEditItem, BOOL bFlag)
{
    LPTSTR lpShowAddress;
//	LPEDITITEM lpEditItem;
	int nShowPos,nShowLine;
	int sizeLen;
	HDC hdc;
	DWORD dwStyle;

		 // get struct EDITITEM data
//	   lpEditItem=(LPEDITITEM)GetWindowLong(hWnd,0);
//     if (lpEditItem==NULL) return;
	   if (bFlag==TRUE)
	   {	// Initial redraw data
			// get window style
//			dwStyle=GetWindowLong(hWnd,GWL_STYLE);
      dwStyle=lpEditItem->dwStyle;
			// get redraw start address
			lpShowAddress=lpEditItem->lpInvertStart;
			// get redraw text length
			sizeLen=lpEditItem->lpInvertEnd-lpEditItem->lpInvertStart;
			// get redraw start cordinate position
			GetCoordinate(hWnd,lpEditItem,lpShowAddress,&nShowPos,&nShowLine,dwStyle&ES_MULTILINE);
	   }
		 // clear the invert area
	   lpEditItem->lpInvertInitial=NULL;
	   lpEditItem->lpInvertStart=NULL;
	   lpEditItem->lpInvertEnd=NULL;
	   lpEditItem->lpOldInvertStart=NULL;
	   lpEditItem->lpOldInvertEnd=NULL;
 	   if (bFlag==TRUE&&sizeLen!=0)
	   {// redraw the change text
		    // get hdc
	      hdc=GetDC(hWnd);
			  // redraw the change text
			  DrawPDAEditSpecialText(hWnd,hdc,lpEditItem,lpShowAddress,
			                          nShowPos,nShowLine,sizeLen,PE_SHOWSPECIALLEN);
			  //release hdc
			  ReleaseDC(hWnd,hdc);
	   }
}
/*********************************************************************/
// get coordinate position of the appoiont address

// input :  hWnd --- handle of the window
//		    	lpPosition  --- the appoint address 
//			    lpxPos ---- will return the x-coordinate
//          lpnLine ---- will return the line
//			    bIsMultiLine --- is or not multiple line 
/*********************************************************************/
/**************************************************
声明: void GetCoordinate(HWND hWnd,LPEDITITEM lpEditItem,LPTSTR lpPosition,int * lpxPos,int * lpnLine,BOOL bIsMultiLine)
参数:
	IN hWnd -- 窗口句柄
	IN lpEdititem -- 编辑条目结构指针
	IN lpPosition -- 指定地址
	OUT lpxPos -- 存放指定地址的X坐标
	OUT lpnLine -- 存放指定地址的行索引
	IN bIsMultiLine -- 是否是多行编辑区 
返回值:无
功能描述:得到指定地址的坐标值
引用: 
************************************************/
 void GetCoordinate(HWND hWnd,LPEDITITEM lpEditItem,LPTSTR lpPosition,int * lpxPos,int * lpnLine,BOOL bIsMultiLine)
{
//	LPEDITITEM lpEditItem;
  int lpCharWidthBuffer[128];
  int ChineseCharWidth;
  int nAddWidth=0;
  int nCurCharWidth,nCurLine,nWindowWidth;
//  LPSTR lpCurChar;
  char *lpCurChar;
  DWORD dwStyle;
  FORMATANALYSIS FmtAnalysis;
  int nFMTItem=0;
  SIZE Size;

		// get struct EDITITEM data
//		lpEditItem=(LPEDITITEM)GetWindowLong(hWnd,0);
//    if (lpEditItem==NULL)
//    {
//				if (lpxPos)
//					*lpxPos=0;
//				if (lpnLine)
//					*lpnLine=0;
//        return;
//    }
    // Get Window Width
     nWindowWidth=GetWindowWidth(hWnd,lpEditItem);
		// get Char Width for ASCII Code
    GetPDACharWidth(hWnd,lpCharWidthBuffer,&ChineseCharWidth);
		// Get Edit Control Style
//		dwStyle=GetWindowLong(hWnd,GWL_STYLE);
    dwStyle=lpEditItem->dwStyle;

		// Get Start Address
		lpCurChar=lpEditItem->lpPDAControlBuffer;
		nCurLine=0;

		nAddWidth=GetxStartOfLine(hWnd,lpEditItem,lpCurChar);

    if (dwStyle&ES_FORMAT)
    {  //this  edit is format edit
      FormatEdit(hWnd,lpEditItem,&FmtAnalysis);
      nFMTItem=0;
      Size=GetSize(hWnd,FmtAnalysis.lpTitle,FmtAnalysis.cTitleLen);
      nCurCharWidth=(int)Size.cx;
			nAddWidth+=nCurCharWidth;
    }
		while(TRUE)
		{
//			if (lpCurChar==lpPosition)
			if (lpCurChar >= lpPosition)
			{// is to the appoint address
				// exist circle
				break;
			}
			// The buffer is end?
			if (*lpCurChar==0x00)
			{
				break;
			}
			// Get Current Character Width
//			if ((*lpCurChar)<0)
			if (*lpCurChar<0 || *lpCurChar>0x7F)
			{  // current Character is a chinese
				nCurCharWidth=ChineseCharWidth;
			}

⌨️ 快捷键说明

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