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

📄 mmimain.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 4 页
字号:
    
	*formatIndex = -1;															// Find first non-fixed character,
	edtChar(myHandle,ecTop);													// starting from the top.
	editCharFindNext(NULL);

	while (edit->cp <strlen(tb))
	{
		editCharFindNext(' ');														// Overwrite everything with spaces
	}
	edtChar(myHandle,ecTop);
	*formatIndex = -1;
	editCharFindNext(NULL);															// Return to the first non-fixed character
	
	return;
}


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

 $Function:  editCharFindNext 

 $Description:	SH - For formatted input, adds a character to the input buffer then finds
 				the next non-fixed character space for the cursor to occupy

 $Returns:		

 $Arguments:	character - the character (or code) to print
 
*******************************************************************************/
/*MC SPR 1242 merged in b-sample version of this function */
void editCharFindNext(char character)
{
	char	*format = formatHandle;												// SH - temporary format template
	char	formatchar;
	MfwEdt	*edit = ((MfwHdr *) myHandle)->data;
	char	test_string[40];
	UBYTE	inField = 0;								// =1 if entering field, =2 if in field 

	TRACE_EVENT("editCharFindNext");

	// Check for delimited field
	
	if (*formatIndex>0)
	{
		formatchar = format[*formatIndex-1];
		if ((formatchar>'0' && formatchar<='9') || formatchar=='*')
			inField = 2;
	}
	
	formatchar = format[*formatIndex];
	if ((formatchar>'0' && formatchar<='9') || formatchar=='*')
		inField = 1;
	
	// Check for cursor right at end of string - don't allow
	
	if (character == ecRight && edit->cp >= strlen(edit->attr->text) && *formatIndex>-1 && inField==0)
	{
		TRACE_EVENT("End of string.");
		return;
	}
	
	if (character!=NULL)														// First add the required character
	{
		edtChar(myHandle, character);											// to the buffer
	}

	// Check for start of fixed input field

	if (inField==1)
	{
		TRACE_EVENT("Entering field.");
		(*formatIndex)++;														// Get us into the field...
		*fieldIndex = 0;														// ...and reset the field index
		formatchar = *(format+*formatIndex);
		if (formatchar=='M')
			upCase = TRUE;
		if (formatchar=='m')
			upCase = FALSE;
		inField = 2;
	}
	
	// Check whether we're in a fixed input field, e.g. "4N" or "8X"

	if (inField==2)															// So we don't look back beyond start of string
	{
		TRACE_EVENT("Move on in field.");
		(*fieldIndex)++;													// Increment the position in the field
		if (*fieldIndex==(int)(formatchar-'0'))								// If we've entered the number of characters specified (note- will never happen for the '*' !)
		{
			TRACE_EVENT("Exiting field.");
			(*formatIndex)++;												// point to NULL at end of string (no more input)
		}
		return;
	}

	// If not, just look at next format character as usual
	
	(*formatIndex)++;															// Point to next character
	
	while (*formatIndex<strlen(format) && *(format+*formatIndex) == '\\')		// Fixed characters encountered
	{
		edtChar(myHandle,ecRight);												// Skip over them
		(*formatIndex)+=2;
	}

	if (*formatIndex>(strlen(format)))											// Don't look beyond end of string
		*formatIndex = strlen(format);
	sprintf(stringTrace, "formatIndex, fieldIndex: %d, %d", *formatIndex, *fieldIndex);
	TRACE_EVENT(stringTrace);
	return;
}

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

 $Function:  editFindPrev 

 $Description:	SH - For formatted input, finds the previous non-fixed character and
 				moves the cursor there if possible

 $Returns:		0 if the cursor position is not changed (nowhere to go)
 				1 if the previous character has been found
 				2 if the cursor was over the first non-fixed character

 $Arguments:	
 
*******************************************************************************/
/*MC SPR 1242 merged in b-sample version of this function */
int editFindPrev()
{
	char	*format		= formatHandle;											// SH - temporary format template
	int		editIndex;
	char	formatchar;
	MfwEdt	*edit = ((MfwHdr *) myHandle)->data;

	TRACE_EVENT("editFindPrev");
	
	if (edit->cp == 0)															// If cursor is at start of string, return 2
	{
		TRACE_EVENT("Exit - start of string found");
		sprintf(stringTrace, "formatIndex, fieldIndex: %d, %d", *formatIndex, *fieldIndex);
		TRACE_EVENT(stringTrace);
		return 2;
	}
	// First check whether we're in a fixed input field, e.g. "4N" or "8X"
			
	if (*formatIndex>0)															// So we don't look back beyond start of string
	{
		formatchar = *(format+*formatIndex-1);
		if ((formatchar>'0' && formatchar<='9') || formatchar=='*')				// If it's a number between 1 and 9, or a *
		{
			TRACE_EVENT("In delimited field.");
			edtChar(myHandle,ecLeft);
			if (edit->cp < edit->attr->size-1)									// (Don't decrement if at last char in string)
				(*fieldIndex)--;												// Decrement the position in the field
			
			if (*fieldIndex==0)													// If we've reached the beginning of the field
			{
				TRACE_EVENT("Getting out of field.");
				(*formatIndex)--;												// Get out of the field
			}

			sprintf(stringTrace, "formatIndex, fieldIndex: %d, %d", *formatIndex, *fieldIndex);
			TRACE_EVENT(stringTrace);
			
			if (edit->cp==(strlen(edit->attr->text)-1))		// Special case if last character - tell editor to shorten the string
			{
				TRACE_EVENT("Shorten string");
				return 3;
			}
			
			return 1;															// then we're done
		}
	}

	// If not (or if we've just come out of one) just look at next format character as usual

	editIndex	= *formatIndex-1;												// Make copy of format position, starting off to left
	 	
	while (editIndex>0)
	{
		if (*(format+editIndex-1)=='\\')										// If there's a fixed char
			editIndex -=2;														// Look back a further 2 characters
		else																	// If there's a non-fixed character
			break;																// then exit loop
   	}

	if (editIndex==-1)															// Go back from 1st character in editor
	{
		TRACE_EVENT("Exit - skipped over fixed character");
		sprintf(stringTrace, "formatIndex, fieldIndex: %d, %d", *formatIndex, *fieldIndex);
		TRACE_EVENT(stringTrace);
		return 2;
	}
	
	formatchar = format[editIndex-1];											
	if ((formatchar>'0' && formatchar<='9') || formatchar=='*')
		(*fieldIndex)--;
		
	if (editIndex>-1)															// Provided there is somewhere to go....
		{
		while(*formatIndex>editIndex)
		{
			if (edtChar(myHandle,ecLeft)==MfwResOk)								// move cursor there
				(*formatIndex)--;
			if (format[*formatIndex]=='\\')
				(*formatIndex)--;
		}
		TRACE_EVENT("Found new position.");
		sprintf(stringTrace, "formatIndex, fieldIndex: %d, %d", *formatIndex, *fieldIndex);
		TRACE_EVENT(stringTrace);
		return 1;																// Found new position
	}
	TRACE_EVENT("Position unchanged.");
	sprintf(stringTrace, "formatIndex, fieldIndex: %d, %d", *formatIndex, *fieldIndex);
	TRACE_EVENT(stringTrace);
	return 0;																	// Position unchanged
}


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

 $Function:  editActivate  

 $Description:	 Activates the edit component

 $Returns:		none.

 $Arguments:	
 
*******************************************************************************/
void editActivate (MfwHnd e, int AlphaMode)
{
  TRACE_FUNCTION("editActivate");

    myHandle = e;
    /*NM p028*/
    if (!editTim)
        editTim = timCreate(0,1000,(MfwCb) editEventTim);
    editAlphaMode = ((AlphaMode != 0) && (AlphaMode != 4) && (AlphaMode != 5));
    editCalcMode  = (AlphaMode == 4);
    editFormatMode = (AlphaMode == 6);
    editHiddenMode = FALSE;
    editAlphaLevel = KEY_PAD_MAX-1;
    editAlphaKey = KCD_MAX;
}


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

 $Function:  editHiddenActivate

 $Description:	 SH - Activates the edit component for hidden alphanumeric entry

 $Returns:    none.

 $Arguments:

*******************************************************************************/
void editHiddenActivate (char *buffer)
{
  TRACE_FUNCTION("editHiddenActivate");
    tmpBuf = buffer;
    editHiddenMode = 1;
  return;
}

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

 $Function:  editDeactivate

 $Description:	 deactivates the edit component

 $Returns:    none.

 $Arguments:

*******************************************************************************/
void editDeactivate (void)
{
    //myHandle = 0; //SPR#1014 - DS - Commented out.

    if (editTim){
    timStop(editTim);
    timDelete(editTim);
  }
    editTim = 0;
}
/*******************************************************************************

 $Function:  activeEditor

 $Description:	 deactivates the edit component

 $Returns:    none.

 $Arguments:

*******************************************************************************/
MfwHnd activeEditor (void)
{
  return myHandle;
}

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

 $Function:	setformatpointers

 $Description:	SH - Sets static variables formatHandle and formatIndex, so thet editEventKey
				can access the format string
 
 $Returns:		

 $Arguments:	Pointer to format string, pointer to format index
				
*******************************************************************************/


void setFormatPointers (char *format, int *index, int *index2)
{

  TRACE_FUNCTION("setFormatPointers");
  formatHandle = format;
  formatIndex = index;
  fieldIndex = index2;
  return;
}

#endif /* NEW_EDITOR */

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

 $Function:  MmiModuleSet

 $Description:	 Set the status

 $Returns:    none.

 $Arguments:

*******************************************************************************/
void MmiModuleSet (int module)
{
  switch(module)
  {
  case ModuleIdle:
  MmiModule = MmiModule & ModuleBattLow;
  MmiModule = MmiModule | ModuleIdle;
  break;
  case ModuleInCall:
  MmiModuleDel(ModuleIdle);
  MmiModule=MmiModule | ModuleInCall;
  break;
  case ModuleCall:
    MmiModuleDel(ModuleIdle);
  MmiModule=MmiModule | ModuleCall;
  break;
  case ModuleMenu:
    MmiModuleDel(ModuleIdle);
  MmiModule=MmiModule | ModuleMenu;
  break;
  case ModulePhon:
    MmiModuleDel(ModuleIdle);
  MmiModule=MmiModule | ModulePhon;
  break;
  case ModuleSms:
  MmiModuleDel(ModuleIdle);
  MmiModule=MmiModule | ModuleSms;
  break;
  case ModuleBattLow:
  MmiModule=MmiModule | ModuleBattLow;
  break;
  case ModuleSAT:
    MmiModuleDel(ModuleIdle);
  MmiModule=MmiModule | ModuleSAT;
  break;
  case ModuleAlarm:
    MmiModuleDel(ModuleIdle);
  MmiModule=MmiModule | ModuleAlarm;
  break;
  case ModuleFax:
    MmiModule=MmiModule | ModuleFax;
  break;
  case ModuleDialling:
    MmiModuleDel(ModuleIdle);
  MmiModule=MmiModule | ModuleDialling;
  break;
  default:
  break;
  }

  return;

}

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

 $Function:  MmiModuleDel

 $Description:	Delete the status

 $Returns:    none.

 $Arguments:

*******************************************************************************/
void MmiModuleDel (int module)
{
  switch(module)
  {
  case ModuleIdle:

  MmiModule = MmiModule & (~ModuleIdle);
  break;
  case ModuleInCall:
    MmiModule=MmiModule & (~ModuleInCall);
  break;
  case ModuleCall:
    MmiModule=MmiModule & (~ModuleCall);
  break;
  case ModuleMenu:
    MmiModule=MmiModule & (~ModuleMenu);
  break;
  case ModulePhon:
    MmiModule=MmiModule & (~ModulePhon);
  break;
  case ModuleSms:
    MmiModule=MmiModule & (~ModuleSms);
  break;
 case ModuleBattLow:
    MmiModule=MmiModule & (~ModuleBattLow);
  break;
  case ModuleSAT:
    MmiModule=MmiModule & (~ModuleSAT);
  break;
  case ModuleAlarm:
    MmiModule=MmiModule & (~ModuleAlarm);
  break;
  case ModuleFax:
    MmiModule=MmiModule & (~ModuleFax);
  break;
  case ModuleDialling:
  MmiModule=MmiModule & (~ModuleDialling);
  default:
  break;
  }

  return;

}

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

 $Function:	showGoodBye

 $Description:	 shows a goodbye Message when swiching off the mobile

 $Returns:    none

 $Arguments:

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


static void showGoodBye (T_MFW_HND win)
{
    T_DISPLAY_DATA   display_info;

  TRACE_FUNCTION("showGoodBye ()");
	dlg_zeroDisplayData(&display_info);
	dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)goodbye_cb, FOREVER, 0 );

      /*
       * Call Icon
       */

  mmi_dialogs_insert_animation (info_dialog (win, &display_info), 400 ,(MfwIcnAttr*)&goodbye_Attr,animGoodbye);


}

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

 $Function:	goodbye_cb

 $Description:

 $Returns:

 $Arguments:

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


static void goodbye_cb (void)
{
  TRACE_FUNCTION("goodbye_cb ()");
  nm_deregistration();	      /* start deregistration procedure   */
}

⌨️ 快捷键说明

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