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

📄 auieditor.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    T_AUI_EDITOR_INFO	*data      = (T_AUI_EDITOR_INFO *)win_data->user;

    T_MFW_HND			parent_win	= data->parent;
    USHORT				alphachar;
 	/* Store these in case editor is destroyed on callback */
    USHORT				Identifier	= data->editor_data.Identifier;
    T_AUI_EDIT_CB		Callback	= data->editor_data.Callback;
    UBYTE				destroyEditor = data->editor_data.destroyEditor;

#ifdef TRACE_AUIEditor
    TRACE_FUNCTION ("AUI_edit_ExecCb()");
#endif

    switch (event)
    {
    	/* Initialise */
    
        case E_ED_INIT:
        	TRACE_EVENT("E_ED_INIT");
			win_show(data->win);
			break;

      	/* SPR 1752 Destroy the editor */
      	case E_ED_DESTROY:
			AUI_edit_Destroy(data->win);   
      		break;
      		
      	/* De-initialise editor */
        case E_ED_DEINIT:
         	TRACE_EVENT("E_ED_DEINIT");
	        if (Callback)
    	    	(Callback) (parent_win, Identifier, value);

			if(destroyEditor)
            	AUI_edit_Destroy(data->win);   
            break;

		/* Insert a character */
		
		case E_ED_INSERT:
			alphachar = (USHORT)value;
			/* If value is set, insert character */
			if (alphachar!=NULL)
			{
	            ATB_edit_Char(data->editor, alphachar, TRUE);
#ifdef EASY_TEXT_ENABLED
				if(FFS_flashData.PredTextAvailable && FFS_flashData.PredTextSelected && ATB_edit_Mode(data->editor, ED_MODE_PREDTEXT))
				{
		            if ((alphachar == UNICODE_FULLSTOP) ||(alphachar == UNICODE_EXCLAMATION)
		            	|| (alphachar == UNICODE_QUESTION))
		        	{
		             	ATB_edit_Char(data->editor, UNICODE_SPACE, TRUE);
		        	}
				}
#endif
			}
			else
			/* If parameter is set, insert string */
			if (parameter!=NULL)
			{
				ATB_edit_InsertString(data->editor, (T_ATB_TEXT *)parameter);
			}
			win_show(data->win);
			break;

		/* Update word wrap & redraw editor window */
		
		case E_ED_UPDATE:
			ATB_edit_Refresh(data->editor);
			win_show(data->win);
   			break;

        default:
		break;
    }
    return;
}


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

 $Function:		AUI_edit_WinCb

 $Description:	Editor window event handler.

 $Returns:		None.

 $Arguments:	event	- the event
 				win		- the editor window

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

static int AUI_edit_WinCb(T_MFW_EVENT event, T_MFW_WIN *win_data)
{
    T_AUI_EDITOR_INFO	*data			= (T_AUI_EDITOR_INFO *)win_data->user;
    T_ED_DATA			*editor			= data->editor;
	USHORT				scrollBarSize;
	USHORT				scrollBarPos;
	SHORT				editX			= editor->attr->win_size.px;
	SHORT				editY			= editor->attr->win_size.py;
	SHORT				editWidth		= editor->attr->win_size.sx;
	SHORT				editHeight		= editor->attr->win_size.sy;
	char				lengthIndC[12];

	/* Strings for the header */
	T_ATB_TEXT			string;
	USHORT				stringWidth;
	USHORT				stringHeight;
	T_ATB_TEXT			title;
	USHORT				titleWidth;
	USHORT				titleHeight;

	USHORT				textLen;
	static USHORT		oldTextLen = 0xFFFF;
	USHORT				startPos;
	static USHORT		oldStartPos = 0xFFFF;
	
	T_DS_TEXTFORMAT  	format;
	BOOL				showIcons;				/* Flag that stores whether icons (e.g. alignment icons) should be shown */
	T_ED_LINE			*line;
	USHORT				leftSK;
	USHORT				rightSK;

	/* SPR#1559 - SH - variables added for title scrolling */
	USHORT				textIndex;
	T_ATB_TEXT			newTitle;
	USHORT				lastSpace;
	USHORT				character;
	
#ifdef TRACE_AUIEditor
    TRACE_FUNCTION ("AUI_edit_WinCb()");
#endif

    if (!data)
		return MFW_EVENT_CONSUMED;
  
    switch(event)
    {
        case E_WIN_VISIBLE: 											/* window is visible */
            if (win_data->flags & E_WIN_VISIBLE)
			{
				textLen = data->editor->attr->text.len;
				line = ATB_edit_LineGet(data->editor, data->editor->winStartLine);
				startPos = line->pos;

				if (data->editor->multitap ||
					(textLen==oldTextLen && startPos==oldStartPos && editor->update==ED_UPDATE_TRIVIAL))
				{
					TRACE_EVENT("Only updating editor.");
					ATB_edit_Show(data->editor);
					data->editor->update = ED_UPDATE_DEFAULT;
					return;
				}
				TRACE_EVENT("Updating whole screen.");
				
				oldTextLen = textLen;
				oldStartPos = startPos;

				/* Show the edited text */
				/* SPR#1559 - SH - Don't update editor text if in ED_UPDATE_PARTIAL */
				if (editor->update!=ED_UPDATE_PARTIAL)
				{
					ATB_edit_Show(data->editor);
				}
				
				/* Set the colour for drawing title and scrollbar */

				resources_setTitleColour(COLOUR_EDITOR);

				/* TITLE */

				if (data->editor_data.zone_id & ZONE_TITLE)
				{
					dspl_Clear(0,0, SCREEN_SIZE_X-1, editY-1);
				
					/* Display the title, if it exists */

					string.len = 0;
					string.dcs = ATB_DCS_ASCII;
					title.len = 0;
					title.dcs = ATB_DCS_ASCII;
		
					if (data->hasTitle)
					{
						title.data = data->title.data;
						title.len = data->title.len;
						title.dcs = data->title.dcs;
					}

					/* Uppercase/lowercase indicator */

					if (!ATB_edit_Mode(editor, ED_MODE_READONLY))
					{
						switch(ATB_edit_GetCasePref(editor))
						{
							case ED_CASEPREF_ALPHA_UC:
							case ED_CASEPREF_ALPHANUM_UC:
								string.data = (UBYTE *)ED_IND_UPPER;
								break;

							case ED_CASEPREF_ALPHA_LC:
							case ED_CASEPREF_ALPHANUM_LC:
								string.data = (UBYTE *)ED_IND_LOWER;
								break;
							
							case ED_CASEPREF_ALPHANUM:
								if (ATB_edit_GetCase(editor)==ED_CASE_UPPER)
									string.data = (UBYTE *)ED_IND_UPPER;
								else if (ATB_edit_GetCase(editor)==ED_CASE_LOWER)
									string.data = (UBYTE *)ED_IND_LOWER;
								else if (ATB_edit_GetCase(editor)==ED_CASE_CAPS)
									string.data = (UBYTE *)ED_IND_CAPS;
								else
									string.data = (UBYTE *)ED_IND_NUM;
								break;
								
							case ED_CASEPREF_NUM:
								string.data = (UBYTE *)ED_IND_NUM;
								break;

							default:
								string.data = (UBYTE *)ED_IND_NONE;
								break;
						}

						string.len = ATB_string_Length(&string);
						
#ifdef EASY_TEXT_ENABLED
						/* Display predicted word in header */

						if(ATB_edit_Mode(editor, ED_MODE_PREDTEXT) && FFS_flashData.PredTextSelected)
						{
							if (ATB_edit_CapitaliseWord(data->editor))	/* Word is capitalised */
								string.data = (UBYTE *)ED_IND_CAPS;
							else
								string.data = (UBYTE *)ED_IND_LOWER;
							string.len = ATB_string_Length(&string);
						
							if(data->predText.len!=0)
							{
								title.data = data->predText.data;
								title.len = data->predText.len;
								title.dcs = data->predText.dcs;
		                    }
						}
#endif
						if (ATB_edit_Mode(editor, ED_MODE_ALPHA) && title.len==0)
						{
#ifdef LSCREEN
							sprintf(lengthIndC, "%d/%d", textLen, editor->attr->size);
#else
							sprintf(lengthIndC, "%d", editor->attr->size-textLen);
#endif
								
							title.data = (UBYTE *)lengthIndC;
							title.len = ATB_string_Length(&title);
						}
					}

					/* SPR#1559 - Reorganised this section - order is IMPORTANT */
					/* Draw the string to the right of the editor - the case/format indicator, and icons (if appropriate) */

					stringWidth = 0;
					stringHeight = 0;
					showIcons = FALSE;
					
					if (string.len)
					{
					TRACE_EVENT("Displaying string on right");
						ATB_display_SetFormatAttr(&format, 0, FALSE);	/* Set format to format at cursor */
						stringWidth = ATB_display_StringWidth(&string, &format)+2;
						stringHeight = ATB_display_StringHeight(&string, &format);
						ATB_display_Text(SCREEN_SIZE_X-stringWidth+2,0, &format, &string);
						showIcons = TRUE;				/* If showing case, show icons */
					}

#ifdef EASY_TEXT_ENABLED
					/* Display ezitext icon to the left of the case indicator */

					if(ATB_edit_Mode(editor, ED_MODE_PREDTEXT) && FFS_flashData.PredTextSelected == TRUE)
					{
						if (data->predText.len==0)		// Show icons only if there's no predicted text entry currently
							showIcons = TRUE;
						else
							showIcons = FALSE;
					}
#endif

					/* Show icons to the left of the case indicator */
					
					if (showIcons)
					{
						
#ifdef EASY_TEXT_ENABLED
						/*  Display ezitext icon to the left of the case indicator */
						if(ATB_edit_Mode(editor, ED_MODE_PREDTEXT) && FFS_flashData.PredTextSelected == TRUE)
						{
							stringWidth += 8;
							dspl_BitBlt(SCREEN_SIZE_X-stringWidth+2,
								0,8,8,0,(char*)TextIconeZiTextSmall,0);
						}
#endif

						if (stringHeight<Mmi_layout_line_height())
							stringHeight = Mmi_layout_line_height();
					}
					

					/* Draw the string to the left of the screen - the editor title, or the number of characters
					 * remaining free in the buffer, or the predicted text word. */

					titleWidth = 0;
					titleHeight = 0;
					
					if (title.len)
					{
						ATB_display_SetFormatAttr(&format, 0, FALSE);				/* Clear format */

						titleWidth = ATB_display_StringWidth(&title, &format)+2;
						titleHeight = ATB_display_StringHeight(&title, &format);

						/* SPR#1559 - SH - Check to see if title fits into top line - if it doesn't,
						 * we will need display a section of it. */

						if (titleWidth>(SCREEN_SIZE_X-stringWidth-2))
						{
							TRACE_EVENT("** Titlewidth>available width");

							/* SPR#1597 - SH - Create timer if it doesn't exist */

							if (!data->title_timer)
							{
								data->title_timer = tim_create(data->win, 3000, (T_MFW_CB)AUI_edit_TitleTimerCb);
								data->title_pos = 0;
								data->title_next_pos = 0;
						        tim_start(data->title_timer);
						    }
						    
							titleWidth = 0;
							textIndex = data->title_pos;
							lastSpace = 0;
							
							while (titleWidth<(SCREEN_SIZE_X-stringWidth-2) && textIndex<title.len)
							{
								character = ATB_string_GetChar(&title, textIndex);
								titleWidth+=ATB_display_GetCharWidth(character, &format);
								textIndex++;
								if (character==UNICODE_SPACE)
									lastSpace = textIndex;
							}
								
							TRACE_EVENT_P1("Characters that fit: %d", textIndex);

							/* Calculate next start position */

							if (textIndex==title.len)
								data->title_next_pos = 0;
							else
							{
								/* Word wrap to last space, if there was one */
								
								if (lastSpace>0)
									textIndex = lastSpace;
								data->title_next_pos = textIndex;
							}

							TRACE_EVENT_P1("Next position: %d", data->title_next_pos);
								
							newTitle.len = textIndex-data->title_pos;
							newTitle.data = (UBYTE *)ALLOC_MEMORY((newTitle.len+1)*ATB_string_Size(&title));
							newTitle.dcs = title.dcs;

							for (textIndex=0; textIndex<newTitle.len; textIndex++)
							{
								ATB_string_SetChar(&newTitle, textIndex, ATB_string_GetChar(&title, data->title_pos+textIndex));
							}
							ATB_string_SetChar(&newTitle, newTitle.len, UNICODE_EOLN);
							ATB_display_Text(0,0,&format, &newTitle);

							FREE_MEMORY((UBYTE *)newTitle.data, (newTitle.len+1)*ATB_string_Size(&title));
						}
						else
							ATB_display_Text(0,0,&format, &title);

#ifdef EASY_TEXT_ENABLED
						/* Provides a cursor in the predicted word, so the user can tell which of the characters
						 * entered are being used to select the word. */
						 
						if(ATB_edit_Mode(editor, ED_MODE_PREDTEXT) && FFS_flashData.PredTextSelected && data->predText.len!=0)
						{
							ATB_display_Cursor(&data->predText, data->predTextChar.pos, ED_CURSOR_BLOCK,
								data->predTextChar.lineWidth, 0, data->predTextChar.width, data->predTextChar.height);
	                    }
#endif
					}

					/* SPR#1559 - SH - This section reorganised: block of code here moved
					 * to before title scrolling section */
					
					/* Draw line on top */
					
					if (stringHeight>titleHeight)
						titleHeight = stringHeight;

	/* Non colour display - draw line between title texts*/
#ifndef LSCREEN
					if (titleHeight>0)
					{
						if (stringWidth==0)
							stringWidth = 1;					/* Make sure end of line is on-screen */
						dspl_DrawLine(titleWidth, titleHeight/2, SCREEN_SIZE_X-stringWidth, titleHeight/2); /* Line between title & indicator */
					}
#endif
				}

				/* SCROLLBAR */
				
				if (data->editor_data.zone_id & ZONE_SCROLLBAR)
				{
					dspl_Clear(editX+editWidth, editY, editX+editWidth+ED_SCROLLBAR_WIDTH-1, editY+editHeight-1);
				
					/* Vertical scrollbar - only show if editor is taller than view size */

					if (editor->totalHeight > 0 && editor->viewHeight<editor->totalHeight)
					{
						dspl_DrawLine(editX+editWidth, editY, editX+editWidth, editY+editHeight-1);
						scrollBarSize = editor->viewHeight * editHeight / editor->totalHeight;
						if (scrollBarSize>editHeight)
							scrollBarSize = editHeight;
						scrollBarPos = editor->viewStartPos * editHeight / editor->totalHeight;

						dspl_DrawLine(editX+editWidth+1, editY+scrollBarPos, editX+editWidth+1,
							editY+scrollBarPos+scrollBarSize);
						dspl_DrawLine(editX+editWidth+2, editY+scrollBarPos, editX+editWidth+2,
							editY+scrollBarPos+scrollBarSize);
					}
				}

				/* SOFTKEYS */

				if (data->editor_data.zone_id & ZONE_SOFTKEYS)
				{
#ifdef EASY_TEXT_ENABLED
					/* If a word is being entered, display OK and Delete */

					if (ATB_edit_Mode(data->editor, ED_MODE_PREDTEXT) && data->predText.len!=0 && FFS_flashData.PredTextSelected == TRUE)
					{
						leftSK = TxtSoftOK;
						rightSK = TxtDelete;
					}
					else
#endif

⌨️ 快捷键说明

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