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

📄 mfw_edt.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:

MfwRes edtSetText (MfwHnd e,  char * s)
{
    MfwEdt *edt;

    if( !e )
        return MfwResIllHnd;            /* element does not exist   */

    edt = ((MfwHdr *) e)->data;         /* get edit control block   */
    edt->attr->text = s;

    return MfwResOk;
}

/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_EDT            |
| STATE   : code                        ROUTINE : edtUpdate          |
+--------------------------------------------------------------------+

  PURPOSE : draw editor
GW 06/09/01 - Call chinese update if first char is 0x80,0x81 or 0x82.
GW 06/09/01 - Added extra parameters to displ_setCursorPos for the size of cursor.
*/

//Return non-zero result if chr is in the string str.
int chrInString(char chr,char* str)
{
    int i;
    i=0;
    while( str[i] != 0x00 )
    {
        if( str[i]== chr )
            return(i+1);
        else
            i++;
    }
    //Not found -
    return(0);
}

//GW 18/09/01 Use 'isAWordChar' procedure instead of 'chrInString' 
void findWordBounds(MfwEdt *e, int *opStChr, int *opEndChr)
{
    int found;
    int stChr,endChr;
    //Find char before start of the word.
    stChr = e->cp-1;
    found = FALSE;
    while( (stChr >0) && (!found) )
    {
        if( isAWordChar(e->attr->text[stChr])==0 )
            found = TRUE;
        else
            stChr--;
    }
    //find char after end of the word.
    endChr = e->cp;
    found = FALSE;
    while( (e->attr->text[endChr]!=0x00 ) && (!found) )
    {
        if( isAWordChar(e->attr->text[endChr])==0 )
            found = TRUE;
        else
            endChr++;
    }
    *opStChr  = stChr;
    *opEndChr = endChr;
}

//GW 18/09/01 Commented out debug code. 
MfwRes edtUpdate (MfwEdt *e,int all)
{
    UBYTE temp;

    char *tp,*tShow;
    S16 px, py;                         /* top left corner of edit  */
    S16 ls;                             /* width of edit window     */
    S16 ly;                             /* bottom of edit window    */
    U8 oldFont = -1;                    /* store previous font      */
    U8 uMode;
    char* endChar;

    unsigned char *tb;
    //char spareNum[4];    //zgz,2002.06.28  temp buffer for spare number  display
    //char *title; //zgz, 2002.7.2

    //Data used to add word highlight 
    char saveChr[2];
    char text_more[17]="";//the buffer for show the text of the cursor line
    char *tMore=&text_more[0];
    char startHtext[2] = {0x01,0x00};
    char endHtext[2]   = {0x02,0x00};
    char Trace_data[10]="";
    //char *show_text;
    int stChr,endChr;
    int textlen;//the text len from the cursor

    U16* tmp;
    UINT32 oldColor,oldFontColor;
    TRACE_EVENT("edtupdate");
    if( !e )
        return MfwResIllHnd;

    if( !e->attr->text )
        return MfwResErr;               /* no text to display       */

    tb = (unsigned char*)e->attr->text;

    if( (tb[0] == 0x80) || (tb[0] == 0x81) || (tb[0] == 0x82) )
    {
        return( edtUpdateUnicode (e,all ) );
    }
    /* 2003/10/13 sunsj mark for remove mmihz.c & mmihzapi.c */
    //if ( editForChineseInput )
    //    return(edtshowforchineseinput(e) );

    temp = dspl_get_char_type();        
    dspl_set_char_type(DSPL_TYPE_ASCII);


    if( !(e->flags & MfwEdtVisible) )
        display = 0;                    /* invisible editor         */
    else display=1;

    if( display )
        uMode = dspl_Enable(0);

    //    textStart = e->attr->text;          /* start of edit text       */
    tp = e->attr->text + e->curOffs;    /* start of display buffer  */
    tShow=e->attr->text+e->cp;
    px = e->attr->win.px;               /* left of edit window      */
    py = e->attr->win.py;               /* top of edit window       */
    ls = e->attr->win.sx;               /* width of edit window     */
    ly = (S16) (py+e->attr->win.sy);    /* bottom of edit window    */
    if( e->attr->font != (U8) -1 )
        oldFont = dspl_SelectFontbyID(e->attr->font); /* setup font */
    /* 2004/02/11 sunsj modify font height for cursor display */
    fontHeight = dspl_GetFontHeight()+1;  /* get height of curr font  */
    curMode = e->attr->mode;            /* setup edi mode           */

    if( display )
    {

        TRACE_EVENT("now we will clear and display");
        if( all )
        {
            oldColor=dspl_GetBkgColor();
            if( e->attr->fgColor<1 )
                e->attr->fgColor=0xffffff;
            dspl_SetBkgColor(e->attr->fgColor);
            if( (e->attr->titleMode==1) )//|| (e->attr->titleMode == TITLE_TOP)
                //dspl_Clear(1, e->attr->win.py, 119, (U16)(ly));       		    
                dspl_Clear(0,e->attr->win.py,SCREEN_WIDTH,ly);
            else dspl_Clear(e->attr->win.px,e->attr->win.py,(U16)(ls+e->attr->win.px),(U16)(ly));
            edtOutTextLines(e->attr->win.px,e->attr->win.py,ls,ly,NULL,(unsigned char*)tp); // show it 
            dspl_SetCursor(0,(U8)(curMode&edtCurMask));
            dspl_SetBkgColor(oldColor);
            //dspl_SetFrgColor(oldFontColor);
        }
        else
        {
            oldColor=dspl_GetBkgColor();
            //oldFontColor=dspl_GetFrgColor();
            if( e->attr->fgColor<1 )
                e->attr->fgColor=0xffffff;
            dspl_SetBkgColor(e->attr->fgColor);
            //dspl_SetFrgColor(0x000000);
            /* 2003/12/29 sunsj modify for different font hight */
            dspl_Clear(curCX,curCY,(U16)(e->attr->win.px+ls),(U16)(curCY+fontHeight));
            if( e->cp_last_y != curCY )
            {
                /* 2004/04/06 sunsj modify */
                //dspl_Clear((U16)(e->attr->win.px+e->cp_last_x),(U16)e->cp_last_y,(U16)SCREEN_WIDTH,(U16)(e->cp_last_y+fontHeight));
                e->cp_last_y = curCY;
            }
            dspl_Clear(e->attr->win.px,curCY+fontHeight,(U16)(ls+e->attr->win.px),(U16)(ly));       
            textlen=curCX;
            while( *tShow!='\0' )
            {
                /* 2003/10/28 sunsj because *tShow is a char.When *tShow is a negative so it will become a big num when
                  we conver it into unsigned number */
                USHORT temp_char;
                /* 2003/10/28 sunsj modify for auto width char display */
                //textlen+=8;
                temp_char = *tShow & 0x00FF;
                textlen += get_CharWidth((USHORT)temp_char);

                if( textlen>(ls+px) )
                    break;
                if( (*tShow==0x0a)||(*tShow==0x0d) )
                {
                    tShow++;
                    break;
                }

                *tMore=*tShow;
                tMore++;
                tShow++;                    
            }
            *tMore='\0';
            tMore++;
            *tMore='\0';
            dspl_TextOut(curCX,curCY,0,text_more);
            /* 2003/12/29 sunsj modify for different font hight */
            if( (*tShow!='\0')&&(ly-curCY-fontHeight>=fontHeight) )
            {
                edtOutTextLines(e->attr->win.px,curCY+fontHeight,(U16)ls,(U16)ly,NULL,(unsigned char *)tShow);
            }
            redrawcursor(preCX,preCY,preCSize,curCX,curCY,curCSize,0,e->attr->fgColor);
            /*
            if(strlen(tShow)>(120-curCX)/8)
                {
            strncpy(text_more,tShow,(120-curCX)/8);
            text_more[(120-curCX)/8]='\0';
            text_more[(120-curCX)/8+1]='\0';
            dspl_TextOut(curCX,curCY,0,text_more);
            edtOutTextLines(e->attr->win.px,curCY+16,(U16)ls,(U16)ly,NULL,(unsigned char *)(tShow+(120-curCX)/8));
            
            redrawcursor(preCX,preCY,preCSize,curCX,curCY,curCSize,0,e->attr->fgColor);
                }
            else
                {
                    strcpy(text_more,tShow);
                    TRACE_EVENT("the text of this line");
                    TRACE_EVENT(text_more);
                    dspl_TextOut(curCX,curCY,0,text_more);
                    redrawcursor(preCX,preCY,preCSize,curCX,curCY,curCSize,0,e->attr->fgColor);
                }
            */      
            dspl_SetBkgColor(oldColor);
            //dspl_SetFrgColor(oldFontColor);
        }
    }


    //Add a space to the end of the line
    endChar = &tp[strlen(tp)];


    if( display )
    {
        //zgz, 2002.06.28  display my title
        inputIndicate_update(e);
    }

    if( display && (curMode & edtCurMask) )
    {
        //dspl_SetCursorPos(curCX,curCY,curCSize,(S16)fontHeight); /* display cursor           */
        if( all )
            dspl_SetCursorPos(curCX,curCY+1,curCSize,(S16)fontHeight); // sbh 19/02/02, position cursor correctly
    }
    if( oldFont != (U8) -1 )
        dspl_SelectFontbyID(oldFont);   /* restore previous font    */


    if( display )
        dspl_Enable(uMode);
    dspl_set_char_type(temp);

    //	e->attr->curChar    = e->attr->text[e->cp];
    return MfwResOk;
}




//GW 18/09/01 - Corrected linefeed definition and added carriage return definition.
#define UNICODE_SPACE			0x2000
#define UNICODE_LINEFEED		0x0A00
#define UNICODE_CR				0x0D00
#define UNICODE_EOLN			0x0000
#define UNICODE_NONASCII		0x00FF
//#define UNICODE_EXTENDEDASCII	0x8000			// sbh - extended ascii interferes with normal ascii processing
#define UNICODE_STARTHIGHLIGHT	0x0100 
#define UNICODE_ENDHIGHLIGHT	0x0200


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_EDT            |
| STATE   : code                        ROUTINE : edtChar            |
+--------------------------------------------------------------------+

  PURPOSE : handle editing char
//GW 06/09/01 - Call chinese procedure if first char is 0x80,0x81 or 0x82 or display type is not ascii.

*/
char getCursorChar(MfwHnd e, int offset )
{
    MfwEdt *edit; 
    int chPos;

    if( !e )
        return(0xFF);

    if( ((MfwHdr *)e)->type != MfwTypEdt )

⌨️ 快捷键说明

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