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

📄 mmieditor.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	}
	else if (zone_id == 0)
		zone_id = ZONE_FULLSOFTKEYS;

	if (zone_id & ZONE_ICONS)
		attr->win.py = attr->win.py + Mmi_layout_IconHeight();

	if (zone_id & ZONE_SOFTKEYS)
		attr->win.sy = attr->win.sy - Mmi_layout_softkeyHeight();

	if (zone_id & ZONE_TITLE)
		attr->win.py = attr->win.py + Mmi_layout_TitleHeight();
	
	if (zone_id & ZONE_CASE_ABC)
		attr->win.sy = attr->win.sy - Mmi_layout_line_height();

	attr->win.sy = attr->win.sy - attr->win.py;

	if ((zone_id & ZONE_FULLSCREEN) == ZONE_FULLSCREEN)
		return;
	
	//Else window is not entire screen
	switch (zone_id & ZONE_FULL_HEIGHT)
	{
	case ZONE_FULL_HEIGHT:	
		break;
	case ZONE_TOPHALF_HEIGHT:
		attr->win.sy = attr->win.sy/2;		
		break;
	case ZONE_MIDDLE_HEIGHT:			
		attr->win.sy = attr->win.sy/2;		
		attr->win.py = attr->win.py+attr->win.sy/2;		
		break;
	case ZONE_BOTTOMHALF_HEIGHT:		
		attr->win.sy = attr->win.sy/2;		
		attr->win.py = attr->win.py+attr->win.sy;		
		break;
	default:
		//No action
		break;
	}
	switch (zone_id & ZONE_FULL_WIDTH)
	{
	case ZONE_FULL_WIDTH:	
		break;
	case ZONE_LEFTHALF_WIDTH:		
		attr->win.sx = attr->win.sx/2;		
		break;
	case ZONE_MIDDLE_WIDTH	:		
		attr->win.sx = attr->win.sx/2;		
		attr->win.px = attr->win.px+attr->win.sx/2;		
		break;
	case ZONE_RIGHTHALF_WIDTH:		
		attr->win.sx = attr->win.sx/2;		
		attr->win.px = attr->win.px+attr->win.sx;		
		break;
	default:
		//No action
		break;
	}
}

void getTitlePosition(MfwEdtAttr* attr, int zone_id )
{
	if (zone_id & 0xFFFF0000)
	{
		//title is on top line/LHS
		
	}
}
#define EDITOR_FONT             0
#define EDITOR_CONTROLS         0
/*******************************************************************************

 $Function:     editor_attr_init

 $Description:  initialize parameters in the edit buffer

 $Returns:    None.

 $Arguments:  None.

*******************************************************************************/
void editor_attr_init(MfwEdtAttr* attr, int zone_id, U8 mode, U8 *controls, char *text, U16 size, int colour )
{
	calculateWindow(attr, zone_id);
	getTitlePosition(attr, zone_id);
	attr->edtCol = colour;
  	attr->font = EDITOR_FONT;
  	attr->mode = mode;
  	attr->controls = controls;
  	attr->text = text;
  	attr->size = size;
  	AllowPredText = FALSE;
}
#ifdef EASY_TEXT_ENABLED
/*******************************************************************************

 $Function:     editor_attr_init_pred

 $Description:  initialize parameters in the predictive text editor buffer

 $Returns:    None.

 $Arguments:  None.

*******************************************************************************/
void editor_attr_init_pred(MfwEdtAttr* attr, int zone_id, U8 mode, U8 *controls, char *text, U16 size, int colour)
{
	calculateWindow(attr, zone_id);
	attr->edtCol = colour;
  	attr->font = EDITOR_FONT;
  	attr->mode = mode;
  	attr->controls = controls;
  	attr->text = text;
  	attr->size = size;
  	AllowPredText = TRUE;
}

//returns true if next word after cursor ought to be capitalised
UBYTE capitalise_word(T_MFW_HND editor_handle)
{ char LastChar;
  char CharBefore;

  LastChar = getCursorChar(editor_handle, -1);
  CharBefore = getCursorChar(editor_handle, -2);

  if (LastChar == '.' || LastChar == '!' || LastChar == '?' || LastChar == 0)
    return TRUE;
  if (LastChar == ' ')
    if(CharBefore == '.' || CharBefore == '!' || CharBefore == '?' )
      return TRUE;
  return FALSE;
}


#endif


/*******************************************************************************

 $Function:     editor_start

 $Description:  Common editor.

 $Returns:    None.

 $Arguments:  None.

*******************************************************************************/
T_MFW_HND editor_start (T_MFW_HND parent, T_EDITOR_DATA * editor_data)
{
    T_MFW_HND win;

    TRACE_FUNCTION ("editor_start()");

    win = editor_create (parent);

    if (win NEQ NULL)
        {
            SEND_EVENT (win, E_EDITOR_INIT, 0, editor_data);
        }
    return win;
}

/*******************************************************************************

 $Function:     editor_create

 $Description:  Creation of an editor.

 $Returns:    None.

 $Arguments:  None.

*******************************************************************************/
static T_MFW_HND editor_create (T_MFW_HND  parent)
{
    T_EDITOR_INFO *  data = (T_EDITOR_INFO *)ALLOC_MEMORY (sizeof (T_EDITOR_INFO));
    T_MFW_WIN     *  win;

    TRACE_FUNCTION ("editor_create()");

    /*
     * Create window handler
     */

    data->edt_win = win_create (parent, 0, E_WIN_VISIBLE, (T_MFW_CB)editor_win_cb);

    if (data->edt_win EQ NULL)
    {
        return NULL;
    }

    /*
     * connect the dialog data to the MFW-window
     */


    data->mmi_control.dialog = (T_DIALOG_FUNC)editor_exec_cb;
    data->mmi_control.data   = data;
    data->parent             = parent;
    win                      = ((T_MFW_HDR *)data->edt_win)->data;
    win->user                = (void *)data;


    /*
     * return window handle
     */

    return data->edt_win;
}
/*******************************************************************************

 $Function:     editor_destroy

 $Description:  Destroy the editor.

 $Returns:    None.

 $Arguments:  None.

*******************************************************************************/
void editor_destroy (T_MFW_HND window)
{
    T_MFW_WIN     * win  = ((T_MFW_HDR *)window)->data;
    T_EDITOR_INFO * data = (T_EDITOR_INFO *)win->user;

    TRACE_FUNCTION ("editor_destroy()");

	if (window == NULL)
	{
		TRACE_EVENT ("Error : Called with NULL Pointer");
		return;
	}

    if (data)
        {
			AllowPredText = FALSE; //prevent any problems with new editors
            /* end KGT */

            /*
             * Delete WIN Handler
             */
            editDeactivate();
            win_delete (data->edt_win);
            /*
             * Free Memory
             */
            FREE_MEMORY ((void *)data, sizeof (T_EDITOR_INFO));
        }
    else
        {
            TRACE_FUNCTION ("editor_destroy() called twice");
            return ;
        }
}

/*******************************************************************************

 $Function:     editor_exec_cb

 $Description:  Dialog function for editor.

 $Returns:    None.

 $Arguments:  None.

*******************************************************************************/
static void editor_exec_cb (T_MFW_HND win, USHORT event, SHORT value, T_EDITOR_DATA * editor_data)
{
    T_MFW_WIN      * win_data  = ((T_MFW_HDR *)win)->data;
    T_EDITOR_INFO  * data      = (T_EDITOR_INFO *)win_data->user;

    T_MFW_HND       parent_win = data->parent;
    USHORT          Identifier = data->editor_data.Identifier;
    T_EDIT_CB       Callback   = data->editor_data.Callback;

	 T_EDITOR_DATA editor_label;
  
    TRACE_EVENT ("editor_exec_cb()");
	

    switch (event)
        {
        case E_EDITOR_INIT:
            /*
             * Store data
             */
            data->editor_data = *editor_data;
            if (data->editor_data.TextString NEQ NULL)
                {
                    memcpy (data->LabelText, data->editor_data.TextString, sizeof(data->LabelText));
                }
            /* Note that we do not copy the edited buffer here */
      data->editor_data.editor_attr.predText[0] = '\0';
            /*
             * Create the handler
             */
            data->edt_kbd      = kbd_create (data->edt_win, KEY_ALL,         (T_MFW_CB)editor_kbd_cb);
            data->edt_kbd_long = kbd_create (data->edt_win, KEY_ALL|KEY_LONG,(T_MFW_CB)editor_kbd_cb);
            data->edt_edt      = edtCreate  (data->edt_win, &data->editor_data.editor_attr,MfwEdtVisible,0);

            /*
             * Set the mode for the editor
             */
      data->destroyEditor = editor_data->destroyEditor;
            editActivate(data->edt_edt,data->editor_data.mode);

      // SH - format mode with *M or *m is just alpha mode with case preference

      if (data->editor_data.mode == FORMAT_MODE)
        {
        if (strcmp(data->editor_data.FormatString, "*M")==0)
          {
           upCase = TRUE;
          UPPER_CASE = FALSE;
          }
        if (strcmp(data->editor_data.FormatString, "*m")==0)
          {
          upCase = FALSE;
          UPPER_CASE = TRUE;
          }
        }

      // SH - end of format mode modification

            switch (data->editor_data.mode)
                {
                case READ_ONLY_MODE:
                    data->editor_data.hide  = FALSE;           /* don't allow hide for other modes than DIGITS_MODE.  */
                    data->edt_mode          = E_NORMAL_MODE;   /* if editor is not called in T9 mode, set the normal  */
       				data->editor_data.editor_attr.mode = 0;	// sbh - read only mode has no cursor
                win_show(data->edt_win);
                edtChar(data->edt_edt,ecTop);              /* in read-only mode set cursor to begin               */
                    break;                                     /* editor mode                                         */

                case ALPHA_MODE:

#ifdef EASY_TEXT_ENABLED
                  FFS_flashData.PredTextAvailable = TRUE;
                  Initialize_Dict(Mmi_getCurrentLanguage()/*MC, SPR 1319*/, 0);
          ResetDictSearch();
#endif

                  if ( data->editor_data.hide )              /* if hide is set, show '*' instead of numbers.        */
                    {
                        editor_hideInit(data);                 /* initialize editor for hide                          */
                        editHiddenActivate(data->tmpBuf);   /* initialise multi-tap for hide */
                        data->editor_data.editor_attr.mode |= edtModOverWr; // Must be overwrite mode
                    }
                    data->edt_mode          = E_NORMAL_MODE;   /* if editor is not called in T9 mode, set the normal  */
                win_show(data->edt_win);
                edtChar(data->edt_edt,ecBottom);              /* in read-only mode set cursor to begin               */

⌨️ 快捷键说明

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