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

📄 auicalceditor.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 2 页
字号:
#endif
				else
				{
					data->title.dcs = ATB_DCS_ASCII;
				}
				
				data->title.len = ATB_string_Length(&data->title);
			}
	
        	/* Check to see if number already has decimal point */

			data->hasDecimalPoint = FALSE;
			
			for (textIndex = 0; textIndex<data->editor->attr->text.len; textIndex++)
			{
				if (ATB_string_GetChar(&data->editor->attr->text, textIndex)==UNICODE_FULLSTOP)
				{
					data->hasDecimalPoint = TRUE;
				}
			}

			/* Show the window */
			win_show(data->win);
			break;

		case E_CALC_UPDATE:
        	TRACE_EVENT("E_CALC_UPDATE");
			win_show(data->win);
			break;

		case E_CALC_DEINIT:
			TRACE_EVENT("E_CALC_DEINIT");

			if (Callback)
    	    	(Callback) (parent_win, Identifier, value);
    	    	
			if (destroyEditor)
				AUI_calc_Destroy(data->win);
				
			break;

   	}

    return;
}

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

 $Function:		AUI_calc_WinCb

 $Description:	Calc editor window event handler.

 $Returns:		None.

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

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

static int AUI_calc_WinCb(T_MFW_EVENT event, T_MFW_WIN *win_data)
{
    T_AUI_CALC_DATA		*data			= (T_AUI_CALC_DATA *)win_data->user;
    T_ED_DATA			*editor			= data->editor;
    T_ATB_WIN_SIZE		*win_size		= &data->editor->attr->win_size;
    T_DS_TEXTFORMAT		format;
    USHORT				titleLen;

	TRACE_EVENT("AUI_calc_WinCb");
	
	if (!data)
		return MFW_EVENT_CONSUMED;
  
    switch(event)
    {
        case E_WIN_VISIBLE: 											/* window is visible */
            if (win_data->flags & E_WIN_VISIBLE)
			{
				if (editor->update==ED_UPDATE_TRIVIAL)
				{
					TRACE_EVENT("Only updating editor.");
					ATB_edit_Show(data->editor);
				}
				else
				{
					TRACE_EVENT("Updating whole screen.");

					ATB_edit_Show(data->editor);

					/* Set the colour for drawing title */

					resources_setTitleColour(COLOUR_EDITOR);

					/* TITLE */
				
					dspl_Clear(0,0, SCREEN_SIZE_X-1, win_size->py-1);
					
					if (data->haveTitle)
					{
						ATB_display_SetFormatAttr(&format, 0, FALSE);
						ATB_display_Text(0,0,&format, &data->title);
					}

					/* RESULT */

					if (data->haveResult)
					{
						resources_setHLColour(COLOUR_EDITOR);
						ATB_display_SetFormatAttr(&format, 0, FALSE);
						dspl_Clear( win_size->px, win_size->py+win_size->sy,  win_size->px+win_size->sx,
							win_size->py+win_size->sy+ATB_display_StringHeight(&data->result, &format));
						
						ATB_display_Text(win_size->px+win_size->sx-ATB_display_StringWidth(&data->result, &format),
							win_size->py+win_size->sy,&format, &data->result);
					}

					/* Display Soft Keys */
					
					if (data->editor_data.editor_attr.text.len < data->editor_data.min_enter)
					{
						/* entered less than the required number of chars: Alternate Softkey appears */
						displaySoftKeys(data->editor_data.AltLeftSoftKey,data->editor_data.RightSoftKey);
					}
					else
					{
						/* entered sufficient number of chars: Normal Softkey appears */
						displaySoftKeys(data->editor_data.LeftSoftKey, data->editor_data.RightSoftKey);
					}
				}
			}
            break;
    }

	data->editor->update = ED_UPDATE_DEFAULT;

	return;
}


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

 $Function:		AUI_calc_KbdCb

 $Description:	Calc editor keyboard event handler

 $Returns:		None.

 $Arguments:	event		- The keyboard event
 				keyboard 	- The keypress info

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

static int AUI_calc_KbdCb(T_MFW_EVENT event, T_MFW_KBD *keyboard)
{
	T_MFW_HND			win			= mfw_parent (mfw_header());
	T_MFW_WIN			*win_data	= ((T_MFW_HDR *)win)->data;
	T_AUI_CALC_DATA		*data		= (T_AUI_CALC_DATA *)win_data->user;
	ED_RES				result;
  	
	TRACE_FUNCTION("AUI_calc_KbdCb()");

   /* Suppress unwanted long keypresses */

	data->doNextLongPress = TRUE;         		/* next Key_long event is correct */
	data->editor->update = ED_UPDATE_DEFAULT;	/* Default behaviour is just to update text */

	switch (keyboard->code)
	{
#ifdef COLOURDISPLAY
		case KCD_MNUSELECT:
			if (data->editor_data.Callback)
    	    	(data->editor_data.Callback) (data->parent, data->editor_data.Identifier, INFO_KCD_SELECT);
			break;

#endif /* COLOURDISPLAY */

		case KCD_STAR:
			if (data->editor_data.Callback)
    	    	(data->editor_data.Callback) (data->parent, data->editor_data.Identifier, INFO_KCD_STAR);
			break;

		case KCD_HASH:
			/* Insert decimal point, if the number doesn't have one already */
			if (!data->hasDecimalPoint)
			{
				data->hasDecimalPoint = TRUE;
				AUI_entry_EditChar(data->entry_data, UNICODE_FULLSTOP, FALSE);
				win_show(data->win);
			}
			break;
			
		case KCD_LEFT:
			if (data->editor_data.editor_attr.text.len < data->editor_data.min_enter)
			{
				/* Entered less than the required number of chars */
				if (data->editor_data.AltLeftSoftKey!=TxtNull)
				{
					/* an alternate softkey is defined: execute it */
					SEND_EVENT (win, E_CALC_DEINIT, INFO_KCD_ALTERNATELEFT, NULL);
				}
			}
			else if (data->editor_data.LeftSoftKey!=TxtNull)
			{
				/* Left Softkey is enabled (and entered sufficient number of chars): execute it */
				SEND_EVENT (win, E_CALC_DEINIT, INFO_KCD_LEFT, NULL);
			}
			break;

		case KCD_HUP:
			SEND_EVENT(data->win, E_CALC_DEINIT, INFO_KCD_HUP, 0);
			break;              

		case KCD_RIGHT:
			/* If we're deleting the decimal point... */
			if (ATB_edit_GetCursorChar(data->editor, -1)==UNICODE_FULLSTOP)
			{
				data->hasDecimalPoint = FALSE;
			}

			/* If we've just got a zero, delete it so we can exit with next call to ATB_edit_DeleteLeft() */
			
			if (ATB_edit_GetCursorChar(data->editor, -1)==ATB_char_Unicode('0'))
			{
				ATB_edit_DeleteLeft(data->editor);
			}

			/* Perform normal delete */
			result = ATB_edit_DeleteLeft(data->editor);

			/* If buffer is now empty, insert '0' */
			if (data->editor->attr->text.len==0 && result!=ED_DONE)
			{
				AUI_entry_EditChar(data->entry_data, ATB_char_Unicode('0'), FALSE);
			}

			/* If we've deleted on an empty buffer, exit editor */
			if (result==ED_DONE)
			{
				SEND_EVENT(data->win, E_CALC_DEINIT, INFO_KCD_RIGHT, 0);
			}
			else
			{
				win_show(data->win);
			}
			break;

		/* 0 - 9 */
		
		case KCD_0:
		case KCD_1:
		case KCD_2:
		case KCD_3:
		case KCD_4:
		case KCD_5:
		case KCD_6:
		case KCD_7:
		case KCD_8:
		case KCD_9:
			/* Remove leading zero */
			if (data->editor->attr->text.len==1 && ATB_edit_GetCursorChar(data->editor, -1)==ATB_char_Unicode('0'))
			{
				ATB_edit_DeleteLeft(data->editor);
			}

			/* Insert the digit */
			AUI_entry_EventKey(data->entry_data, event, keyboard);
			win_show(data->win);
			break;
	}
	
	return MFW_EVENT_CONSUMED;
}


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

 $Function:		AUI_calc_KbdLongCb

 $Description:	Calc editor long keypress event handler

 $Returns:		None.

 $Arguments:	event		- The keyboard event
 				keyboard 	- The keypress info

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

static int AUI_calc_KbdLongCb(T_MFW_EVENT event, T_MFW_KBD *keyboard)
{
	T_MFW_HND			win			= mfw_parent (mfw_header());
	T_MFW_WIN			*win_data	= ((T_MFW_HDR *)win)->data;
	T_AUI_CALC_DATA		*data		= (T_AUI_CALC_DATA *)win_data->user;
	ED_RES				result;
	
    /* Suppress unwanted long keypresses */

	 if ( data->doNextLongPress )
		data->doNextLongPress = FALSE;       			/* mark Key_long event as consumed but do current long press */
	else
		return MFW_EVENT_CONSUMED;      		/* don't do current long press */

	switch (keyboard->code)
	{        
		case KCD_RIGHT:
			/* Long press of RSK deletes buffer */
			result = ATB_edit_ClearAll(data->editor);

			/* If buffer is now empty, insert '0' */
			if (data->editor->attr->text.len==0 && result!=ED_DONE)
			{
				AUI_entry_EditChar(data->entry_data, ATB_char_Unicode('0'), FALSE);
			}
			
			/* If we've deleted on an empty buffer, exit editor */
			if (result==ED_DONE)
			{
				SEND_EVENT(data->win, E_CALC_DEINIT, INFO_KCD_RIGHT, 0);
			}
			else
			{
				win_show(data->win);
			}
			break;
	}

	return MFW_EVENT_CONSUMED;
}

⌨️ 快捷键说明

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