diff src/ui/bmi/mmiCalculatorMain.c @ 92:c0052fe355d3

src/ui/bmi/*.[ch]: rm trailing white space
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 08 Nov 2020 06:39:16 +0000
parents 67bfe9f274f6
children f1f29e85f92b
line wrap: on
line diff
--- a/src/ui/bmi/mmiCalculatorMain.c	Sun Nov 08 05:12:05 2020 +0000
+++ b/src/ui/bmi/mmiCalculatorMain.c	Sun Nov 08 06:39:16 2020 +0000
@@ -2,42 +2,42 @@
 
 					CONDAT (UK)
 
-********************************************************************************                                                                              
+********************************************************************************
 
  This software product is the property of Condat (UK) Ltd and may not be
- disclosed to any third party without the express permission of the owner.                                 
-                                                                              
+ disclosed to any third party without the express permission of the owner.
+
 ********************************************************************************
 
- $Project name:	Basic MMI                                                      
- $Project code:	BMI (6349)                                                           
+ $Project name:	Basic MMI
+ $Project code:	BMI (6349)
  $Module:		Calculator
  $File:		    MmiCalculatorMain.c
- $Revision:		1.0                                                       
-                                                                              
- $Author:		Condat(UK)                                                         
- $Date:		    25/10/00                                                      
-                                                                               
+ $Revision:		1.0
+
+ $Author:		Condat(UK)
+ $Date:		    25/10/00
+
 ********************************************************************************
-                                                                              
+
  Description
 
     This provides the main calculator functionality
 
-  
+
 ********************************************************************************
  $History: MmiCalculatorMain.c
 
-	25/10/00			Original Condat(UK) BMI version.	
+	25/10/00			Original Condat(UK) BMI version.
 
 	xrashmic 20 Oct, 2005 MMI-SPR-33845
 	To display BACK softkey when no more character are left in the calulator editor
 
 	Oct 20, 2004    REF: CRR 25755 xnkulkar
 	Description: calculator -divide by zero operation is allowed.
-	Fix:	Display "Not Allowed" message when user tries to divide a number by 0 and do not perform the 
+	Fix:	Display "Not Allowed" message when user tries to divide a number by 0 and do not perform the
 			     division. Also, show the editor again so that user can enter a number other than 0.
-	   
+
  $End
 
 *******************************************************************************/
@@ -45,9 +45,9 @@
 #define MIN_CALC_TOTAL -99999999
 
 /******************************************************************************
-                                                                              
+
                                 Include Files
-                                                                              
+
 *******************************************************************************/
 #define ENTITY_MFW
 
@@ -131,9 +131,9 @@
 
 
 /*******************************************************************************
-                                                                              
+
                                 Function Prototypes
-                                                                              
+
 *******************************************************************************/
 static T_MFW_HND calc_create(MfwHnd parent_window);
 void calc_destroy(MfwHnd own_window);
@@ -145,10 +145,10 @@
 char operatorSymbol(UBYTE operator);
 static void calc_menu_cb(T_MFW_HND parent_win, UBYTE identifier, UBYTE reason);
 /*******************************************************************************
-                                                                              
-                                Static Global Variable(s) 
-                                                                              
-*******************************************************************************/	
+
+                                Static Global Variable(s)
+
+*******************************************************************************/
 
 static double running_total;
 
@@ -157,24 +157,24 @@
 
 // Oct 20, 2004    REF: CRR 25755 xnkulkar
 // Added this flag to detect 'divide by zero' operation
-BOOL divideByZero = FALSE; 
+BOOL divideByZero = FALSE;
 
 /*******************************************************************************
-                                                                              
+
                                 Public Functions
-                                                                              
+
 *******************************************************************************/
 /*******************************************************************************
 
  $Function:    	calculator
 
  $Description:	Starts the calculator function on user selection
- 
+
  $Returns:		MFW_EVENT_CONSUMED if event handled, otherwise
 				MFW_EVENT_PASSED
 
  $Arguments:	menu, menu item
- 
+
 *******************************************************************************/
 int calculator(MfwMnu* m, MfwMnuItem* i)
 {
@@ -189,12 +189,12 @@
  $Function:    	calcPlus
 
  $Description:	Handles the selction of the "Plus" option in the calculator menu
- 
+
  $Returns:		MFW_EVENT_CONSUMED if event handled, otherwise
 				MFW_EVENT_PASSED
 
  $Arguments:	menu, menu item
- 
+
 *******************************************************************************/
 int calcPlus(MfwMnu* m, MfwMnuItem* i)
 {
@@ -208,7 +208,7 @@
         	data = (tCalcData*)win_data->user;
         	data->operation = PLUS;//set the arithmetic operation
            	SEND_EVENT (calculator_win, CALC_ENTER_OPERAND, 0, 0);
-        } 
+        }
     return MFW_EVENT_CONSUMED;
 }
 
@@ -217,12 +217,12 @@
  $Function:    	calcMinus
 
  $Description:	Handles the selection of the "Minus" option in the calculator menu
- 
+
  $Returns:		MFW_EVENT_CONSUMED if event handled, otherwise
 				MFW_EVENT_PASSED
 
  $Arguments:	menu, menu item
- 
+
 *******************************************************************************/
 int calcMinus(MfwMnu* m, MfwMnuItem* i)
 {
@@ -236,7 +236,7 @@
         	data = (tCalcData*)win_data->user;
         	data->operation = MINUS;//set the arithmetic operation
            	SEND_EVENT (calculator_win, CALC_ENTER_OPERAND, 0, 0);
-        } 
+        }
     return MFW_EVENT_CONSUMED;
 }
 
@@ -245,12 +245,12 @@
  $Function:    	calcDivide
 
  $Description:	Handles the selection of the "Divide" option in the calculator menu
- 
+
  $Returns:		MFW_EVENT_CONSUMED if event handled, otherwise
 				MFW_EVENT_PASSED
 
  $Arguments:	menu, menu item
- 
+
 *******************************************************************************/
 int calcDivide(MfwMnu* m, MfwMnuItem* i)
 {
@@ -264,7 +264,7 @@
         	data = (tCalcData*)win_data->user;
         	data->operation = DIVIDE;//set the arithmetic operation
            	SEND_EVENT (calculator_win, CALC_ENTER_OPERAND, 0, 0);
-        } 
+        }
     return MFW_EVENT_CONSUMED;
 }
 /*******************************************************************************
@@ -272,12 +272,12 @@
  $Function:    	calcMultiply
 
  $Description:	Handles the selection of the "Multiply" option in the calculator menu
- 
+
  $Returns:		MFW_EVENT_CONSUMED if event handled, otherwise
 				MFW_EVENT_PASSED
 
  $Arguments:	menu, menu item
- 
+
 *******************************************************************************/
 int calcMultiply(MfwMnu* m, MfwMnuItem* i)
 {
@@ -291,7 +291,7 @@
         	data = (tCalcData*)win_data->user;
         	data->operation = MULTIPLY;//set the arithmetic operation
            	SEND_EVENT (calculator_win, CALC_ENTER_OPERAND, 0, 0);
-        } 
+        }
     return MFW_EVENT_CONSUMED;
 }
 
@@ -301,11 +301,11 @@
  $Function:    	info_screen_cb
 
  $Description:	Callback function for info screen
- 
+
  $Returns:	nothing
 
  $Arguments:	Parent Window handle, identifier and reason
- 
+
 *******************************************************************************/
 
 static void info_screen_cb(T_MFW_HND parent_win, UBYTE identifier, UBYTE reason)
@@ -319,19 +319,19 @@
  $Function:    	calcEquals
 
  $Description:	Handles the selection of the "Equals" option in the calculator menu
- 
+
  $Returns:		MFW_EVENT_CONSUMED if event handled, otherwise
 				MFW_EVENT_PASSED
 
  $Arguments:	menu, menu item
- 
+
 *******************************************************************************/
 int calcEquals(MfwMnu* m, MfwMnuItem* i)
 {
     TRACE_FUNCTION("calcEquals()");
 
 	// Oct 20, 2004    REF: CRR 25755 xnkulkar
-	// if 'divide by zero' operation is attempted 
+	// if 'divide by zero' operation is attempted
 	if(divideByZero == TRUE)
 	{
      		divideByZero = FALSE;	// disable the flag
@@ -340,30 +340,30 @@
        }
 
        if (calculator_win NEQ NULL)
-       {	
+       {
        	SEND_EVENT (calculator_win, CALC_DISPLAY_RESULT, 0, 0);
-       } 
+       }
 
        return MFW_EVENT_CONSUMED;
 }
 
 /*******************************************************************************
-                                                                              
+
                                 Private Functions
-                                                                              
-*******************************************************************************/	
+
+*******************************************************************************/
 /*******************************************************************************
 
  $Function:    	calcGetRunningTotal
 
- $Description:	If the calculator's running total value ever needs to be accessed by 
- 				code in another file, then this function ought to be made public to prevent 
+ $Description:	If the calculator's running total value ever needs to be accessed by
+ 				code in another file, then this function ought to be made public to prevent
  				to allow safe access;
- 
+
  $Returns:		Calculator's running total (double)
 
  $Arguments:	none
- 
+
 *******************************************************************************/
 double calcGetRunningTotal(void)
 {
@@ -375,12 +375,12 @@
 
  $Function:    	operatorSymbol
 
- $Description:	returns character corresponding to arithmetic operation 
- 
+ $Description:	returns character corresponding to arithmetic operation
+
  $Returns:		Operator character
 
  $Arguments:	Operator enum
- 
+
 *******************************************************************************/
 char operatorSymbol(UBYTE operator)
 {
@@ -393,7 +393,7 @@
 		case (DIVIDE):	return '/'; // break;  // RAVI
 		default: 		return '\0'; // break;  // RAVI
 	}
-		
+
 }
 
 
@@ -401,12 +401,12 @@
 
  $Function:    	calc_start
 
- $Description:	Creates the calculator window and calls for it to be initialised 
- 
+ $Description:	Creates the calculator window and calls for it to be initialised
+
  $Returns:		Window
 
  $Arguments:	Parent Window
- 
+
 *******************************************************************************/
 
 T_MFW_HND calc_start(T_MFW_HND parent_window)
@@ -416,7 +416,7 @@
     if (win NEQ NULL)
         {
            	SEND_EVENT (win, CALC_INIT, 0, 0);
-        } 
+        }
 
    return win;
 }
@@ -426,12 +426,12 @@
  $Function:    	calc_create
 
  $Description:	Creates the calculator window and connect the dialog data to it
- 
+
  $Returns:		Window
 
  $Arguments:	Parent Window
- 
-*******************************************************************************/	
+
+*******************************************************************************/
 static T_MFW_HND calc_create(MfwHnd parent_window)
 {
 	tCalcData     * data = (tCalcData *)ALLOC_MEMORY (sizeof (tCalcData ));
@@ -447,7 +447,7 @@
 	data->win = win_create (parent_window, 0, E_WIN_VISIBLE, NULL);
 	if (data->win EQ NULL)
 	{
-		
+
 		return NULL;
 	}
 	// connect the dialog data to the MFW-window
@@ -465,14 +465,14 @@
  $Function:    	calc_DialogCB
 
  $Description:	Callback function for the calculator window
- 
+
  $Returns:		nothing
 
  $Arguments:	Window, event, identifier (not used), parameter (not used)
- 
+
 *******************************************************************************/
 static void calc_DialogCB(T_MFW_HND win, USHORT e,  SHORT identifier, void *parameter)
-{ 	
+{
 	T_MFW_WIN       	*win_data   = ( (T_MFW_HDR *) win )->data;
 	tCalcData* data = (tCalcData *) win_data->user;
 	char display_buffer[28] = "";
@@ -481,7 +481,7 @@
 #else
 //	T_EDITOR_DATA		editor_data;   // RAVI
 #endif
-	char* running_total_out; 
+	char* running_total_out;
 //	char debug_buffer[50];  // RAVI
  	TRACE_FUNCTION("calc_DialogCB()");
 
@@ -507,7 +507,7 @@
 			data->editor_win = AUI_calc_Start(win, &data->editor_data);
 #else /* NEW_EDITOR */
 			data->editor_data.Callback     		= (T_EDIT_CB)calcGetNumberCB;
-			data->editor_win = editor_start(win, &(data->editor_data));  /* start the editor */ 
+			data->editor_win = editor_start(win, &(data->editor_data));  /* start the editor */
 #endif /* NEW_EDITOR */
 			winShow(data->win);
     	}
@@ -515,14 +515,14 @@
 
     	//when an arithmetic operator has been selected from the calc menu
     	case CALC_ENTER_OPERAND:
-    	{ 	
+    	{
 			TRACE_EVENT("CALC_ENTER_OPERAND");
     		/* This memory alloc seems to fix a problem where running_total_out
     		 * would become an empty string after sevaral running calculations */
     		running_total_out = (char*)ALLOC_MEMORY(22*sizeof(char));	/* SH - change malloc to ALLOC_MEMORY */
-    		
+
 			running_total_out[0] = '\0';
-			
+
 			/* Display the first operand and the operator symbol
 			 * above the operand to be entered */
 			if ( (long)calcGetRunningTotal() == calcGetRunningTotal())
@@ -534,7 +534,7 @@
 				running_total_out[8] = '\0';
 			else
 				running_total_out[9] = '\0';
-				
+
     		sprintf((char*)display_buffer,"%s %c", running_total_out, operatorSymbol(data->operation));
     		FREE_MEMORY((void*)running_total_out, 22*sizeof(char));		/* SH - change free to FREE_MEMORY */
 
@@ -559,9 +559,9 @@
 			data->editor_data.editor_attr.win.py = Mmi_layout_line(3); //30
 			data->editor_data.editor_attr.win.sx = SCREEN_SIZE_X;
 			data->editor_data.editor_attr.win.sy = numberLineHeight()+2;
-	
+
 			data->editor_data.Callback     		= (T_EDIT_CB)calcGetOperandCB;
-			data->input_number_win = editor_start(win, &(data->editor_data));  /* start the editor */ 
+			data->input_number_win = editor_start(win, &(data->editor_data));  /* start the editor */
 #endif /* NEW_EDITOR */
 
 			winShow(data->win);
@@ -573,12 +573,12 @@
 				data->menu_options_win = NULL;
 			}
             /* Marcus: Issue 1039: 05/09/2002: End */
-    	}    	
+    	}
     	break;
-    	
+
     	//when "Equals" selected from calc menu
     	case CALC_DISPLAY_RESULT:
-    	{	
+    	{
     		//if running total out of display range, set it to 0
     		if ((calcGetRunningTotal() > MAX_CALC_TOTAL) || (calcGetRunningTotal() < MIN_CALC_TOTAL))
     			running_total =0;
@@ -589,11 +589,11 @@
     		else //if a floating-point total, display as many decimal places as will fit
     			sprintf(data->buffer, "%f", (double) calcGetRunningTotal());
 			//if last number in display is a decimal point
-			if (data->buffer[8] == '.') 
+			if (data->buffer[8] == '.')
 				data->buffer[8] = '\0';//remove it
     		data->buffer[9] = '\0'; //ensure string is properly terminated
     		//ensure string is no longer than 9 chars
-    		
+
     		calcSetEditor(win);
 
 			/* SPR#1428 - SH - New Editor changes */
@@ -602,7 +602,7 @@
  			AUI_calc_Start(win, &data->editor_data);
  #else /* NEW_EDITOR */
 			data->editor_data.Callback     		= (T_EDIT_CB)calcGetNumberCB;
-			editor_start(win, &(data->editor_data));  /* start the editor */ 
+			editor_start(win, &(data->editor_data));  /* start the editor */
 #endif /* NEW_EDITOR */
 
             /* Marcus: Issue 1039: 05/09/2002: Start */
@@ -623,8 +623,8 @@
     	break;
 
     }
-    	
-   
+
+
 }
 
 /*******************************************************************************
@@ -632,23 +632,23 @@
  $Function:    	calcGetNumberCB
 
  $Description:	Callback function for the editor window
- 
+
  $Returns:		nothing
 
  $Arguments:	Window,  identifier (not used), reason (not used)
- 
+
 *******************************************************************************/
 static void calcGetNumberCB( T_MFW_HND win, USHORT Identifier, SHORT reason)
 {
     T_MFW_WIN       *win_data   = ( (T_MFW_HDR *) win )->data;
-    tCalcData   *data       = (tCalcData *) win_data->user;   
+    tCalcData   *data       = (tCalcData *) win_data->user;
     float after_decimal = 0;
     int digits_after_point = 0;
     int i;
 	char* end;
 //    char debug[40];  // RAVI
 
-    
+
     TRACE_FUNCTION("calcGetNumberCB()");
 
 	switch (reason )
@@ -660,7 +660,7 @@
         	if (strlen(end) != 0)
 			{	//if decimal point entered
 				if ((end[0] == '.') && isdigit(end[1]))//get number after decimal point
-				{	
+				{
 					end++;
 					digits_after_point = strlen(end);
 					after_decimal = strtol(end, &end, 10);
@@ -677,10 +677,10 @@
 			//start the calculator option menu and kill this window
 			data->menu_options_win = bookMenuStart( data->win, calcOptionMenuAttributes(),0);
 			 SEND_EVENT(data->menu_options_win, ADD_CALLBACK, NULL, (void *)calc_menu_cb);
-			 
+
         }
 		break;
-		
+
 		case INFO_KCD_HUP:
         case INFO_KCD_RIGHT:
         {
@@ -706,11 +706,11 @@
 
  $Description:	Callback function for the editor window, when second number in operation
  				is entered.
- 
+
  $Returns:		nothing
 
  $Arguments:	Window,  identifier (not used), reason (not used)
- 
+
 *******************************************************************************/
 
 static void calcGetOperandCB( T_MFW_HND win, USHORT Identifier, SHORT reason)
@@ -724,7 +724,7 @@
     int i;
     char* end;
     char debug[40];
-    
+
     TRACE_FUNCTION("calcGetOperandCB()");
     TRACE_EVENT_P2("ID, reason: %d, %d", Identifier, reason);
 
@@ -745,7 +745,7 @@
 			if (strlen(end) != 0)
 			{	//if decimal point entered
 				if ((end[0] == '.') && isdigit(end[1]))//get number after decimal point
-				{	
+				{
 					end++;
 					digits_after_point = strlen(end);
 					after_decimal = strtol(end, &end, 10);
@@ -763,12 +763,12 @@
         	{
         		case PLUS: running_total = running_total + operand; break;
         		case MINUS: running_total = running_total - operand;break;
-        		case MULTIPLY: running_total = running_total * operand;break; 
-        		case DIVIDE: 
+        		case MULTIPLY: running_total = running_total * operand;break;
+        		case DIVIDE:
 				// Oct 20, 2004    REF: CRR 25755 xnkulkar
 				// if the attempted division is by zero
 				if(operand == 0)
-				{    		
+				{
 					divideByZero = TRUE; // enable the flag
 				}
 				else // else perform the division operation
@@ -778,7 +778,7 @@
 				break;
 				default: TRACE_EVENT("Unknown calc operation"); break;
         	}
-				
+
 		/* SPR#1428 - SH - New Editor: Can use '*' as 'equals', to show result */
 #ifdef NEW_EDITOR
 #ifdef COLOURDISPLAY
@@ -811,12 +811,12 @@
 			}
         }
 		break;
-		
+
 		case INFO_KCD_HUP:
         case INFO_KCD_RIGHT:
         {
             TRACE_EVENT("Right button pressed in calculator");
-            
+
 			calc_destroy(win);
         }
 		break;
@@ -849,11 +849,11 @@
  $Function:    	calcSetEditor
 
  $Description:	Sets the editor attributes to defaults for the calculator module
- 
+
  $Returns:		nothing
 
  $Arguments:	Window
- 
+
 *******************************************************************************/
 void calcSetEditor(T_MFW_HND win)
 {
@@ -861,7 +861,7 @@
 	tCalcData* data = (tCalcData *) win_data->user;
 
 	TRACE_FUNCTION("calcSetEditor()");
-	
+
 	/* SPR#1428 - SH - New Editor changes */
 #ifdef NEW_EDITOR
 	{
@@ -871,8 +871,8 @@
 		AUI_edit_SetMode(&data->editor_data, 0, ED_CURSOR_NONE);
 		AUI_edit_SetEvents(&data->editor_data, 0, TRUE, FOREVER, NULL);
 		AUI_edit_SetTextStr(&data->editor_data, TxtSoftOptions, TxtDelete, TxtCalculator, NULL);
-		//xrashmic 20 Oct, 2005 MMI-SPR-33845 
-		//Editor always starts with min one character "0" and 
+		//xrashmic 20 Oct, 2005 MMI-SPR-33845
+		//Editor always starts with min one character "0" and
 		//alterRight softkey is set to "BACK" here.
 		data->editor_data.min_enter=1;
 		data->editor_data.AltRightSoftKey=TxtSoftBack ;
@@ -882,7 +882,7 @@
 	editor_attr_init(&((data->editor_data).editor_attr), 0, edtCurBar1, 0, data->buffer, 10, COLOUR_EDITOR);
 	editor_data_init( &data->editor_data, NULL, TxtSoftOptions, TxtDelete, NULL, 1, CALC_MODE, FOREVER);
 			data->editor_data.hide				= FALSE;
-			data->editor_data.Identifier		= 0xFFFF ; 
+			data->editor_data.Identifier		= 0xFFFF ;
 			data->editor_data.destroyEditor		= TRUE;
 #endif /* NEW_EDITOR */
 
@@ -894,20 +894,20 @@
  $Function:    	calc_destroy
 
  $Description:	Destroys the calculator editor window and frees up memory
- 
+
  $Returns:		nothing
 
  $Arguments:	Window
- 
+
 *******************************************************************************/
 void calc_destroy(MfwHnd own_window)
 {
   T_MFW_WIN * win_data;
-  tCalcData   * data = NULL; 
+  tCalcData   * data = NULL;
 
   TRACE_EVENT ("calc_destroy()");
   if (own_window)
-	{  	
+	{
 
 	win_data = ((T_MFW_HDR *)own_window)->data;
 		if (win_data != NULL) //PATCH TB
@@ -915,7 +915,7 @@
 
 	  if (data)
 		{
-			
+
 			win_delete (data->win);
             /* Marcus: Issue 1039: 05/09/2002: Start */
 			if (data->menu_options_win != NULL)
@@ -926,7 +926,7 @@
             /* Marcus: Issue 1039: 05/09/2002: End */
 		  // Free Memory
 			FREE_MEMORY ((void *)data, sizeof (tCalcData));
-	
+
 		}
 	  else
 		{