comparison src/ui/bmi/mmiCalculatorMain.c @ 144:f1f29e85f92b

mmiCalculatorMain.c: bogotab fixes
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 16 Nov 2020 05:19:56 +0000
parents c0052fe355d3
children
comparison
equal deleted inserted replaced
143:fbe284e160c1 144:f1f29e85f92b
1 /******************************************************************************* 1 /*******************************************************************************
2 2
3 CONDAT (UK) 3 CONDAT (UK)
4 4
5 ******************************************************************************** 5 ********************************************************************************
6 6
7 This software product is the property of Condat (UK) Ltd and may not be 7 This software product is the property of Condat (UK) Ltd and may not be
8 disclosed to any third party without the express permission of the owner. 8 disclosed to any third party without the express permission of the owner.
9 9
10 ******************************************************************************** 10 ********************************************************************************
11 11
12 $Project name: Basic MMI 12 $Project name: Basic MMI
13 $Project code: BMI (6349) 13 $Project code: BMI (6349)
14 $Module: Calculator 14 $Module: Calculator
15 $File: MmiCalculatorMain.c 15 $File: MmiCalculatorMain.c
16 $Revision: 1.0 16 $Revision: 1.0
17 17
18 $Author: Condat(UK) 18 $Author: Condat(UK)
19 $Date: 25/10/00 19 $Date: 25/10/00
20 20
21 ******************************************************************************** 21 ********************************************************************************
22 22
23 Description 23 Description
24 24
26 26
27 27
28 ******************************************************************************** 28 ********************************************************************************
29 $History: MmiCalculatorMain.c 29 $History: MmiCalculatorMain.c
30 30
31 25/10/00 Original Condat(UK) BMI version. 31 25/10/00 Original Condat(UK) BMI version.
32 32
33 xrashmic 20 Oct, 2005 MMI-SPR-33845 33 xrashmic 20 Oct, 2005 MMI-SPR-33845
34 To display BACK softkey when no more character are left in the calulator editor 34 To display BACK softkey when no more character are left in the calulator editor
35 35
36 Oct 20, 2004 REF: CRR 25755 xnkulkar 36 Oct 20, 2004 REF: CRR 25755 xnkulkar
37 Description: calculator -divide by zero operation is allowed. 37 Description: calculator -divide by zero operation is allowed.
38 Fix: Display "Not Allowed" message when user tries to divide a number by 0 and do not perform the 38 Fix: Display "Not Allowed" message when user tries to divide a number by 0 and do not perform the
39 division. Also, show the editor again so that user can enter a number other than 0. 39 division. Also, show the editor again so that user can enter a number other than 0.
40 40
41 $End 41 $End
42 42
43 *******************************************************************************/ 43 *******************************************************************************/
44 #define MAX_CALC_TOTAL 999999999 44 #define MAX_CALC_TOTAL 999999999
164 Public Functions 164 Public Functions
165 165
166 *******************************************************************************/ 166 *******************************************************************************/
167 /******************************************************************************* 167 /*******************************************************************************
168 168
169 $Function: calculator 169 $Function: calculator
170 170
171 $Description: Starts the calculator function on user selection 171 $Description: Starts the calculator function on user selection
172 172
173 $Returns: MFW_EVENT_CONSUMED if event handled, otherwise 173 $Returns: MFW_EVENT_CONSUMED if event handled, otherwise
174 MFW_EVENT_PASSED 174 MFW_EVENT_PASSED
175 175
176 $Arguments: menu, menu item 176 $Arguments: menu, menu item
177 177
178 *******************************************************************************/ 178 *******************************************************************************/
179 int calculator(MfwMnu* m, MfwMnuItem* i) 179 int calculator(MfwMnu* m, MfwMnuItem* i)
180 { 180 {
181 T_MFW_HND parent = mfwParent( mfw_header()); 181 T_MFW_HND parent = mfwParent( mfw_header());
182 TRACE_FUNCTION("calculator()"); 182 TRACE_FUNCTION("calculator()");
183 calc_start(parent); 183 calc_start(parent);
184 return MFW_EVENT_CONSUMED; 184 return MFW_EVENT_CONSUMED;
185 } 185 }
186 186
187 /******************************************************************************* 187 /*******************************************************************************
188 188
189 $Function: calcPlus 189 $Function: calcPlus
190 190
191 $Description: Handles the selction of the "Plus" option in the calculator menu 191 $Description: Handles the selction of the "Plus" option in the calculator menu
192 192
193 $Returns: MFW_EVENT_CONSUMED if event handled, otherwise 193 $Returns: MFW_EVENT_CONSUMED if event handled, otherwise
194 MFW_EVENT_PASSED 194 MFW_EVENT_PASSED
195 195
196 $Arguments: menu, menu item 196 $Arguments: menu, menu item
197 197
198 *******************************************************************************/ 198 *******************************************************************************/
199 int calcPlus(MfwMnu* m, MfwMnuItem* i) 199 int calcPlus(MfwMnu* m, MfwMnuItem* i)
200 { 200 {
201 T_MFW_WIN* win_data; 201 T_MFW_WIN* win_data;
202 tCalcData* data; 202 tCalcData* data;
203 203
204 TRACE_FUNCTION("calcPlus()"); 204 TRACE_FUNCTION("calcPlus()");
205 //if new window successfully created 205 //if new window successfully created
206 if (calculator_win NEQ NULL) 206 if (calculator_win NEQ NULL)
207 { win_data = ( (T_MFW_HDR *) calculator_win )->data; 207 { win_data = ( (T_MFW_HDR *) calculator_win )->data;
208 data = (tCalcData*)win_data->user; 208 data = (tCalcData*)win_data->user;
209 data->operation = PLUS;//set the arithmetic operation 209 data->operation = PLUS;//set the arithmetic operation
210 SEND_EVENT (calculator_win, CALC_ENTER_OPERAND, 0, 0); 210 SEND_EVENT (calculator_win, CALC_ENTER_OPERAND, 0, 0);
211 } 211 }
212 return MFW_EVENT_CONSUMED; 212 return MFW_EVENT_CONSUMED;
213 } 213 }
214 214
215 /******************************************************************************* 215 /*******************************************************************************
216 216
217 $Function: calcMinus 217 $Function: calcMinus
218 218
219 $Description: Handles the selection of the "Minus" option in the calculator menu 219 $Description: Handles the selection of the "Minus" option in the calculator menu
220 220
221 $Returns: MFW_EVENT_CONSUMED if event handled, otherwise 221 $Returns: MFW_EVENT_CONSUMED if event handled, otherwise
222 MFW_EVENT_PASSED 222 MFW_EVENT_PASSED
223 223
224 $Arguments: menu, menu item 224 $Arguments: menu, menu item
225 225
226 *******************************************************************************/ 226 *******************************************************************************/
227 int calcMinus(MfwMnu* m, MfwMnuItem* i) 227 int calcMinus(MfwMnu* m, MfwMnuItem* i)
228 { 228 {
229 T_MFW_WIN* win_data; 229 T_MFW_WIN* win_data;
230 tCalcData* data; 230 tCalcData* data;
231 231
232 //if new window successfully created 232 //if new window successfully created
233 TRACE_FUNCTION("calcMinus()"); 233 TRACE_FUNCTION("calcMinus()");
234 if (calculator_win NEQ NULL) 234 if (calculator_win NEQ NULL)
235 { win_data = ( (T_MFW_HDR *) calculator_win )->data; 235 { win_data = ( (T_MFW_HDR *) calculator_win )->data;
236 data = (tCalcData*)win_data->user; 236 data = (tCalcData*)win_data->user;
237 data->operation = MINUS;//set the arithmetic operation 237 data->operation = MINUS;//set the arithmetic operation
238 SEND_EVENT (calculator_win, CALC_ENTER_OPERAND, 0, 0); 238 SEND_EVENT (calculator_win, CALC_ENTER_OPERAND, 0, 0);
239 } 239 }
240 return MFW_EVENT_CONSUMED; 240 return MFW_EVENT_CONSUMED;
241 } 241 }
242 242
243 /******************************************************************************* 243 /*******************************************************************************
244 244
245 $Function: calcDivide 245 $Function: calcDivide
246 246
247 $Description: Handles the selection of the "Divide" option in the calculator menu 247 $Description: Handles the selection of the "Divide" option in the calculator menu
248 248
249 $Returns: MFW_EVENT_CONSUMED if event handled, otherwise 249 $Returns: MFW_EVENT_CONSUMED if event handled, otherwise
250 MFW_EVENT_PASSED 250 MFW_EVENT_PASSED
251 251
252 $Arguments: menu, menu item 252 $Arguments: menu, menu item
253 253
254 *******************************************************************************/ 254 *******************************************************************************/
255 int calcDivide(MfwMnu* m, MfwMnuItem* i) 255 int calcDivide(MfwMnu* m, MfwMnuItem* i)
256 { 256 {
257 T_MFW_WIN* win_data; 257 T_MFW_WIN* win_data;
258 tCalcData* data; 258 tCalcData* data;
259 259
260 TRACE_FUNCTION("calcDivide()"); 260 TRACE_FUNCTION("calcDivide()");
261 //if new window successfully created 261 //if new window successfully created
262 if (calculator_win NEQ NULL) 262 if (calculator_win NEQ NULL)
263 { win_data = ( (T_MFW_HDR *) calculator_win )->data; 263 { win_data = ( (T_MFW_HDR *) calculator_win )->data;
264 data = (tCalcData*)win_data->user; 264 data = (tCalcData*)win_data->user;
265 data->operation = DIVIDE;//set the arithmetic operation 265 data->operation = DIVIDE;//set the arithmetic operation
266 SEND_EVENT (calculator_win, CALC_ENTER_OPERAND, 0, 0); 266 SEND_EVENT (calculator_win, CALC_ENTER_OPERAND, 0, 0);
267 } 267 }
268 return MFW_EVENT_CONSUMED; 268 return MFW_EVENT_CONSUMED;
269 } 269 }
270 /******************************************************************************* 270 /*******************************************************************************
271 271
272 $Function: calcMultiply 272 $Function: calcMultiply
273 273
274 $Description: Handles the selection of the "Multiply" option in the calculator menu 274 $Description: Handles the selection of the "Multiply" option in the calculator menu
275 275
276 $Returns: MFW_EVENT_CONSUMED if event handled, otherwise 276 $Returns: MFW_EVENT_CONSUMED if event handled, otherwise
277 MFW_EVENT_PASSED 277 MFW_EVENT_PASSED
278 278
279 $Arguments: menu, menu item 279 $Arguments: menu, menu item
280 280
281 *******************************************************************************/ 281 *******************************************************************************/
282 int calcMultiply(MfwMnu* m, MfwMnuItem* i) 282 int calcMultiply(MfwMnu* m, MfwMnuItem* i)
283 { 283 {
284 T_MFW_WIN* win_data; 284 T_MFW_WIN* win_data;
285 tCalcData* data; 285 tCalcData* data;
286 286
287 TRACE_FUNCTION("calcMultiply()"); 287 TRACE_FUNCTION("calcMultiply()");
288 //if new window successfully created 288 //if new window successfully created
289 if (calculator_win NEQ NULL) 289 if (calculator_win NEQ NULL)
290 { win_data = ( (T_MFW_HDR *) calculator_win )->data; 290 { win_data = ( (T_MFW_HDR *) calculator_win )->data;
291 data = (tCalcData*)win_data->user; 291 data = (tCalcData*)win_data->user;
292 data->operation = MULTIPLY;//set the arithmetic operation 292 data->operation = MULTIPLY;//set the arithmetic operation
293 SEND_EVENT (calculator_win, CALC_ENTER_OPERAND, 0, 0); 293 SEND_EVENT (calculator_win, CALC_ENTER_OPERAND, 0, 0);
294 } 294 }
295 return MFW_EVENT_CONSUMED; 295 return MFW_EVENT_CONSUMED;
296 } 296 }
297 297
298 // Oct 20, 2004 REF: CRR 25755 xnkulkar 298 // Oct 20, 2004 REF: CRR 25755 xnkulkar
299 /******************************************************************************* 299 /*******************************************************************************
300 300
301 $Function: info_screen_cb 301 $Function: info_screen_cb
302 302
303 $Description: Callback function for info screen 303 $Description: Callback function for info screen
304 304
305 $Returns: nothing 305 $Returns: nothing
306 306
307 $Arguments: Parent Window handle, identifier and reason 307 $Arguments: Parent Window handle, identifier and reason
308 308
309 *******************************************************************************/ 309 *******************************************************************************/
310 310
311 static void info_screen_cb(T_MFW_HND parent_win, UBYTE identifier, UBYTE reason) 311 static void info_screen_cb(T_MFW_HND parent_win, UBYTE identifier, UBYTE reason)
312 { 312 {
313 // Send CALC_ENTER_OPERAND event tp prompt the user to enter the operand again 313 // Send CALC_ENTER_OPERAND event tp prompt the user to enter the operand again
314 SEND_EVENT (calculator_win, CALC_ENTER_OPERAND, 0, 0); 314 SEND_EVENT (calculator_win, CALC_ENTER_OPERAND, 0, 0);
315 } 315 }
316 316
317 /******************************************************************************* 317 /*******************************************************************************
318 318
319 $Function: calcEquals 319 $Function: calcEquals
320 320
321 $Description: Handles the selection of the "Equals" option in the calculator menu 321 $Description: Handles the selection of the "Equals" option in the calculator menu
322 322
323 $Returns: MFW_EVENT_CONSUMED if event handled, otherwise 323 $Returns: MFW_EVENT_CONSUMED if event handled, otherwise
324 MFW_EVENT_PASSED 324 MFW_EVENT_PASSED
325 325
326 $Arguments: menu, menu item 326 $Arguments: menu, menu item
327 327
328 *******************************************************************************/ 328 *******************************************************************************/
329 int calcEquals(MfwMnu* m, MfwMnuItem* i) 329 int calcEquals(MfwMnu* m, MfwMnuItem* i)
330 { 330 {
331 TRACE_FUNCTION("calcEquals()"); 331 TRACE_FUNCTION("calcEquals()");
332 332
333 // Oct 20, 2004 REF: CRR 25755 xnkulkar 333 // Oct 20, 2004 REF: CRR 25755 xnkulkar
334 // if 'divide by zero' operation is attempted 334 // if 'divide by zero' operation is attempted
335 if(divideByZero == TRUE) 335 if(divideByZero == TRUE)
336 { 336 {
337 divideByZero = FALSE; // disable the flag 337 divideByZero = FALSE; // disable the flag
338 info_screen(0, TxtNotAllowed, TxtNull,(T_VOID_FUNC) info_screen_cb); // display "Not Allowed" message 338 info_screen(0, TxtNotAllowed, TxtNull,(T_VOID_FUNC) info_screen_cb); // display "Not Allowed" message
339 return MFW_EVENT_CONSUMED; // consume the event 339 return MFW_EVENT_CONSUMED; // consume the event
340 } 340 }
341 341
342 if (calculator_win NEQ NULL) 342 if (calculator_win NEQ NULL)
343 { 343 {
344 SEND_EVENT (calculator_win, CALC_DISPLAY_RESULT, 0, 0); 344 SEND_EVENT (calculator_win, CALC_DISPLAY_RESULT, 0, 0);
345 } 345 }
346 346
347 return MFW_EVENT_CONSUMED; 347 return MFW_EVENT_CONSUMED;
348 } 348 }
349 349
350 /******************************************************************************* 350 /*******************************************************************************
351 351
352 Private Functions 352 Private Functions
353 353
354 *******************************************************************************/ 354 *******************************************************************************/
355 /******************************************************************************* 355 /*******************************************************************************
356 356
357 $Function: calcGetRunningTotal 357 $Function: calcGetRunningTotal
358 358
359 $Description: If the calculator's running total value ever needs to be accessed by 359 $Description: If the calculator's running total value ever needs to be accessed by
360 code in another file, then this function ought to be made public to prevent 360 code in another file, then this function ought to be made public to prevent
361 to allow safe access; 361 to allow safe access;
362 362
363 $Returns: Calculator's running total (double) 363 $Returns: Calculator's running total (double)
364 364
365 $Arguments: none 365 $Arguments: none
366 366
367 *******************************************************************************/ 367 *******************************************************************************/
368 double calcGetRunningTotal(void) 368 double calcGetRunningTotal(void)
369 { 369 {
370 TRACE_FUNCTION("calcGetRunningTotal()"); 370 TRACE_FUNCTION("calcGetRunningTotal()");
371 return running_total; 371 return running_total;
372 } 372 }
373 373
374 /******************************************************************************* 374 /*******************************************************************************
375 375
376 $Function: operatorSymbol 376 $Function: operatorSymbol
377 377
378 $Description: returns character corresponding to arithmetic operation 378 $Description: returns character corresponding to arithmetic operation
379 379
380 $Returns: Operator character 380 $Returns: Operator character
381 381
382 $Arguments: Operator enum 382 $Arguments: Operator enum
383 383
384 *******************************************************************************/ 384 *******************************************************************************/
385 char operatorSymbol(UBYTE operator) 385 char operatorSymbol(UBYTE operator)
386 { 386 {
387 TRACE_FUNCTION("operatorSymbol()"); 387 TRACE_FUNCTION("operatorSymbol()");
388 switch (operator) 388 switch (operator)
389 { 389 {
390 case (PLUS): return '+'; // break; // RAVI 390 case (PLUS): return '+'; // break; // RAVI
391 case (MINUS): return '-'; // break; // RAVI 391 case (MINUS): return '-'; // break; // RAVI
392 case (MULTIPLY): return '*'; // break; // RAVI 392 case (MULTIPLY): return '*'; // break; // RAVI
393 case (DIVIDE): return '/'; // break; // RAVI 393 case (DIVIDE): return '/'; // break; // RAVI
394 default: return '\0'; // break; // RAVI 394 default: return '\0'; // break; // RAVI
395 } 395 }
396 396 }
397 } 397
398 398
399 399 /*******************************************************************************
400 /******************************************************************************* 400
401 401 $Function: calc_start
402 $Function: calc_start 402
403 403 $Description: Creates the calculator window and calls for it to be initialised
404 $Description: Creates the calculator window and calls for it to be initialised 404
405 405 $Returns: Window
406 $Returns: Window 406
407 407 $Arguments: Parent Window
408 $Arguments: Parent Window
409 408
410 *******************************************************************************/ 409 *******************************************************************************/
411 410
412 T_MFW_HND calc_start(T_MFW_HND parent_window) 411 T_MFW_HND calc_start(T_MFW_HND parent_window)
413 { 412 {
414 T_MFW_HND win = calc_create(parent_window); 413 T_MFW_HND win = calc_create(parent_window);
415 TRACE_FUNCTION("calc_start()"); 414 TRACE_FUNCTION("calc_start()");
416 if (win NEQ NULL) 415 if (win NEQ NULL)
416 {
417 SEND_EVENT (win, CALC_INIT, 0, 0);
418 }
419
420 return win;
421 }
422
423 /*******************************************************************************
424
425 $Function: calc_create
426
427 $Description: Creates the calculator window and connect the dialog data to it
428
429 $Returns: Window
430
431 $Arguments: Parent Window
432
433 *******************************************************************************/
434 static T_MFW_HND calc_create(MfwHnd parent_window)
435 {
436 tCalcData * data = (tCalcData *)ALLOC_MEMORY (sizeof (tCalcData ));
437 T_MFW_WIN * win;
438
439 TRACE_FUNCTION("calc_create()");
440 if (data EQ NULL)
441 {
442 return NULL;
443 }
444
445 // Create window handler
446 data->win = win_create (parent_window, 0, E_WIN_VISIBLE, NULL);
447 if (data->win EQ NULL)
448 {
449 return NULL;
450 }
451 // connect the dialog data to the MFW-window
452 data->mmi_control.dialog = (T_DIALOG_FUNC)calc_DialogCB;
453 data->mmi_control.data = data;
454 win = ((T_MFW_HDR *)data->win)->data;
455 win->user = (void *)data;
456 data->parent_win = parent_window;
457 calculator_win = data->win;
458 return data->win;
459 }
460
461 /*******************************************************************************
462
463 $Function: calc_DialogCB
464
465 $Description: Callback function for the calculator window
466
467 $Returns: nothing
468
469 $Arguments: Window, event, identifier (not used), parameter (not used)
470
471 *******************************************************************************/
472 static void calc_DialogCB(T_MFW_HND win, USHORT e, SHORT identifier, void *parameter)
473 {
474 T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
475 tCalcData* data = (tCalcData *) win_data->user;
476 char display_buffer[28] = "";
477 #ifdef NEW_EDITOR
478 // T_AUI_EDITOR_DATA editor_data; /* SPR#1428 - SH - New Editor data */ // RAVI
479 #else
480 // T_EDITOR_DATA editor_data; // RAVI
481 #endif
482 char* running_total_out;
483 // char debug_buffer[50]; // RAVI
484 TRACE_FUNCTION("calc_DialogCB()");
485
486 switch( e )
487 { //when window first created
488 case CALC_INIT:
489 { //set running total to 0 and display in editor
490 TRACE_EVENT("CALC-INIT-JGG");
491 running_total = 0;
492 data->menu_options_win = NULL;
493
494 /* SPR#1428 - SH - New editor: calc starts with 0 */
495 #ifdef NEW_EDITOR
496 sprintf(data->buffer, "%s", "0"); /* SH - calc starts off with '0'*/
497 #else
498 sprintf(data->buffer, "%s", ""); /* SH - calc starts off with nothing*/
499 #endif
500
501 calcSetEditor(win);//set editor with default attribute values
502 /* SPR#1428 - SH - New Editor changes: use calc editor */
503 #ifdef NEW_EDITOR
504 AUI_edit_SetEvents(&data->editor_data, 0, TRUE, FOREVER, (T_AUI_EDIT_CB)calcGetNumberCB);
505 data->editor_win = AUI_calc_Start(win, &data->editor_data);
506 #else /* NEW_EDITOR */
507 data->editor_data.Callback = (T_EDIT_CB)calcGetNumberCB;
508 data->editor_win = editor_start(win, &(data->editor_data)); /* start the editor */
509 #endif /* NEW_EDITOR */
510 winShow(data->win);
511 }
512 break;
513
514 //when an arithmetic operator has been selected from the calc menu
515 case CALC_ENTER_OPERAND:
417 { 516 {
418 SEND_EVENT (win, CALC_INIT, 0, 0); 517 TRACE_EVENT("CALC_ENTER_OPERAND");
419 } 518 /* This memory alloc seems to fix a problem where running_total_out
420 519 * would become an empty string after sevaral running calculations */
421 return win; 520 running_total_out = (char*)ALLOC_MEMORY(22*sizeof(char)); /* SH - change malloc to ALLOC_MEMORY */
422 } 521
423 522 running_total_out[0] = '\0';
424 /******************************************************************************* 523
425 524 /* Display the first operand and the operator symbol
426 $Function: calc_create 525 * above the operand to be entered */
427 526 if ( (long)calcGetRunningTotal() == calcGetRunningTotal())
428 $Description: Creates the calculator window and connect the dialog data to it 527 sprintf((char*)running_total_out, "%d", (long)calcGetRunningTotal());
429 528 else
430 $Returns: Window 529 sprintf((char*)running_total_out, "%f", calcGetRunningTotal());
431 530
432 $Arguments: Parent Window 531 if (running_total_out[8] == '.')
433 532 running_total_out[8] = '\0';
434 *******************************************************************************/ 533 else
435 static T_MFW_HND calc_create(MfwHnd parent_window) 534 running_total_out[9] = '\0';
436 { 535
437 tCalcData * data = (tCalcData *)ALLOC_MEMORY (sizeof (tCalcData )); 536 sprintf((char*)display_buffer,"%s %c", running_total_out, operatorSymbol(data->operation));
438 T_MFW_WIN * win; 537 FREE_MEMORY((void*)running_total_out, 22*sizeof(char)); /* SH - change free to FREE_MEMORY */
439 538
440 TRACE_FUNCTION("calc_create()"); 539 /* SPR#1428 - SH - Calc now starts off with '0' */
441 if (data EQ NULL)
442 {
443 return NULL;
444 }
445
446 // Create window handler
447 data->win = win_create (parent_window, 0, E_WIN_VISIBLE, NULL);
448 if (data->win EQ NULL)
449 {
450
451 return NULL;
452 }
453 // connect the dialog data to the MFW-window
454 data->mmi_control.dialog = (T_DIALOG_FUNC)calc_DialogCB;
455 data->mmi_control.data = data;
456 win = ((T_MFW_HDR *)data->win)->data;
457 win->user = (void *)data;
458 data->parent_win = parent_window;
459 calculator_win = data->win;
460 return data->win;
461 }
462
463 /*******************************************************************************
464
465 $Function: calc_DialogCB
466
467 $Description: Callback function for the calculator window
468
469 $Returns: nothing
470
471 $Arguments: Window, event, identifier (not used), parameter (not used)
472
473 *******************************************************************************/
474 static void calc_DialogCB(T_MFW_HND win, USHORT e, SHORT identifier, void *parameter)
475 {
476 T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
477 tCalcData* data = (tCalcData *) win_data->user;
478 char display_buffer[28] = "";
479 #ifdef NEW_EDITOR 540 #ifdef NEW_EDITOR
480 // T_AUI_EDITOR_DATA editor_data; /* SPR#1428 - SH - New Editor data */ // RAVI 541 sprintf(data->buffer, "%s", "0"); /* SH - calc starts off with '0'*/
481 #else 542 #else
482 // T_EDITOR_DATA editor_data; // RAVI 543 sprintf(data->buffer, "%s", ""); /* SH - calc starts off with nothing*/
483 #endif 544 #endif
484 char* running_total_out; 545
485 // char debug_buffer[50]; // RAVI 546 calcSetEditor(win);
486 TRACE_FUNCTION("calc_DialogCB()"); 547
487 548 /* SPR#1428 - SH - New Editor changes */
488 switch( e ) 549 #ifdef NEW_EDITOR
489 { //when window first created 550 AUI_edit_SetEvents(&data->editor_data, 0, TRUE, FOREVER, (T_AUI_EDIT_CB)calcGetOperandCB);
490 case CALC_INIT: 551 AUI_edit_SetTextStr(&data->editor_data, TxtSoftOptions, TxtDelete, TxtCalculator, (UBYTE *)display_buffer);
491 { //set running total to 0 and display in editor 552 AUI_edit_SetAltTextStr(&data->editor_data, 1, TxtSoftOptions, TRUE, TxtSoftBack);//x0035544 17-11-2005
492 TRACE_EVENT("CALC-INIT-JGG"); 553 data->input_number_win = AUI_calc_Start(win, &data->editor_data);
493 running_total = 0;
494 data->menu_options_win = NULL;
495
496 /* SPR#1428 - SH - New editor: calc starts with 0 */
497 #ifdef NEW_EDITOR
498 sprintf(data->buffer, "%s", "0"); /* SH - calc starts off with '0'*/
499 #else
500 sprintf(data->buffer, "%s", ""); /* SH - calc starts off with nothing*/
501 #endif
502
503 calcSetEditor(win);//set editor with default attribute values
504 /* SPR#1428 - SH - New Editor changes: use calc editor */
505 #ifdef NEW_EDITOR
506 AUI_edit_SetEvents(&data->editor_data, 0, TRUE, FOREVER, (T_AUI_EDIT_CB)calcGetNumberCB);
507 data->editor_win = AUI_calc_Start(win, &data->editor_data);
508 #else /* NEW_EDITOR */ 554 #else /* NEW_EDITOR */
509 data->editor_data.Callback = (T_EDIT_CB)calcGetNumberCB; 555 data->editor_data.TextString = display_buffer;
510 data->editor_win = editor_start(win, &(data->editor_data)); /* start the editor */ 556 data->editor_data.editor_attr.win.px = 0;
557 data->editor_data.editor_attr.win.py = Mmi_layout_line(3); //30
558 data->editor_data.editor_attr.win.sx = SCREEN_SIZE_X;
559 data->editor_data.editor_attr.win.sy = numberLineHeight()+2;
560
561 data->editor_data.Callback = (T_EDIT_CB)calcGetOperandCB;
562 data->input_number_win = editor_start(win, &(data->editor_data)); /* start the editor */
511 #endif /* NEW_EDITOR */ 563 #endif /* NEW_EDITOR */
512 winShow(data->win); 564
513 } 565 winShow(data->win);
514 break; 566
515 567 /* Marcus: Issue 1039: 05/09/2002: Start */
516 //when an arithmetic operator has been selected from the calc menu 568 if (data->menu_options_win != NULL)
517 case CALC_ENTER_OPERAND: 569 {
518 { 570 bookMenuDestroy( data->menu_options_win );
519 TRACE_EVENT("CALC_ENTER_OPERAND"); 571 data->menu_options_win = NULL;
520 /* This memory alloc seems to fix a problem where running_total_out 572 }
521 * would become an empty string after sevaral running calculations */ 573 /* Marcus: Issue 1039: 05/09/2002: End */
522 running_total_out = (char*)ALLOC_MEMORY(22*sizeof(char)); /* SH - change malloc to ALLOC_MEMORY */ 574 }
523 575 break;
524 running_total_out[0] = '\0'; 576
525 577 //when "Equals" selected from calc menu
526 /* Display the first operand and the operator symbol 578 case CALC_DISPLAY_RESULT:
527 * above the operand to be entered */ 579 {
528 if ( (long)calcGetRunningTotal() == calcGetRunningTotal()) 580 //if running total out of display range, set it to 0
529 sprintf((char*)running_total_out, "%d", (long)calcGetRunningTotal()); 581 if ((calcGetRunningTotal() > MAX_CALC_TOTAL) || (calcGetRunningTotal() < MIN_CALC_TOTAL))
530 else 582 running_total =0;
531 sprintf((char*)running_total_out, "%f", calcGetRunningTotal()); 583 //Convert running total double to string
532 584 //if integer total, don't display any decimal places
533 if (running_total_out[8] == '.') 585 if ( (long)calcGetRunningTotal() == calcGetRunningTotal())
534 running_total_out[8] = '\0'; 586 sprintf(data->buffer, "%d", (long) calcGetRunningTotal());
535 else 587 else //if a floating-point total, display as many decimal places as will fit
536 running_total_out[9] = '\0'; 588 sprintf(data->buffer, "%f", (double) calcGetRunningTotal());
537 589 //if last number in display is a decimal point
538 sprintf((char*)display_buffer,"%s %c", running_total_out, operatorSymbol(data->operation)); 590 if (data->buffer[8] == '.')
539 FREE_MEMORY((void*)running_total_out, 22*sizeof(char)); /* SH - change free to FREE_MEMORY */ 591 data->buffer[8] = '\0';//remove it
540 592 data->buffer[9] = '\0'; //ensure string is properly terminated
541 /* SPR#1428 - SH - Calc now starts off with '0' */ 593 //ensure string is no longer than 9 chars
542 #ifdef NEW_EDITOR 594
543 sprintf(data->buffer, "%s", "0"); /* SH - calc starts off with '0'*/ 595 calcSetEditor(win);
544 #else 596
545 sprintf(data->buffer, "%s", ""); /* SH - calc starts off with nothing*/ 597 /* SPR#1428 - SH - New Editor changes */
546 #endif
547
548 calcSetEditor(win);
549
550 /* SPR#1428 - SH - New Editor changes */
551 #ifdef NEW_EDITOR 598 #ifdef NEW_EDITOR
552 AUI_edit_SetEvents(&data->editor_data, 0, TRUE, FOREVER, (T_AUI_EDIT_CB)calcGetOperandCB); 599 AUI_edit_SetEvents(&data->editor_data, 0, TRUE, FOREVER, (T_AUI_EDIT_CB)calcGetNumberCB);
553 AUI_edit_SetTextStr(&data->editor_data, TxtSoftOptions, TxtDelete, TxtCalculator, (UBYTE *)display_buffer); 600 AUI_calc_Start(win, &data->editor_data);
554 AUI_edit_SetAltTextStr(&data->editor_data, 1, TxtSoftOptions, TRUE, TxtSoftBack);//x0035544 17-11-2005 601 #else /* NEW_EDITOR */
555 data->input_number_win = AUI_calc_Start(win, &data->editor_data); 602 data->editor_data.Callback = (T_EDIT_CB)calcGetNumberCB;
556 #else /* NEW_EDITOR */ 603 editor_start(win, &(data->editor_data)); /* start the editor */
557 data->editor_data.TextString = display_buffer;
558 data->editor_data.editor_attr.win.px = 0;
559 data->editor_data.editor_attr.win.py = Mmi_layout_line(3); //30
560 data->editor_data.editor_attr.win.sx = SCREEN_SIZE_X;
561 data->editor_data.editor_attr.win.sy = numberLineHeight()+2;
562
563 data->editor_data.Callback = (T_EDIT_CB)calcGetOperandCB;
564 data->input_number_win = editor_start(win, &(data->editor_data)); /* start the editor */
565 #endif /* NEW_EDITOR */ 604 #endif /* NEW_EDITOR */
566 605
567 winShow(data->win);
568
569 /* Marcus: Issue 1039: 05/09/2002: Start */ 606 /* Marcus: Issue 1039: 05/09/2002: Start */
570 if (data->menu_options_win != NULL) 607 if (data->menu_options_win != NULL)
571 { 608 {
572 bookMenuDestroy( data->menu_options_win ); 609 bookMenuDestroy( data->menu_options_win );
573 data->menu_options_win = NULL; 610 data->menu_options_win = NULL;
574 } 611 }
575 /* Marcus: Issue 1039: 05/09/2002: End */ 612 /* Marcus: Issue 1039: 05/09/2002: End */
576 } 613
577 break; 614 winShow(data->win);
578 615 }
579 //when "Equals" selected from calc menu 616 break;
580 case CALC_DISPLAY_RESULT: 617 default:
581 { 618 {
582 //if running total out of display range, set it to 0 619 TRACE_EVENT("calc_DialogCB(): Unknown Event");
583 if ((calcGetRunningTotal() > MAX_CALC_TOTAL) || (calcGetRunningTotal() < MIN_CALC_TOTAL)) 620 }
584 running_total =0; 621 break;
585 //Convert running total double to string 622
586 //if integer total, don't display any decimal places 623 }
587 if ( (long)calcGetRunningTotal() == calcGetRunningTotal()) 624 }
588 sprintf(data->buffer, "%d", (long) calcGetRunningTotal()); 625
589 else //if a floating-point total, display as many decimal places as will fit 626 /*******************************************************************************
590 sprintf(data->buffer, "%f", (double) calcGetRunningTotal()); 627
591 //if last number in display is a decimal point 628 $Function: calcGetNumberCB
592 if (data->buffer[8] == '.') 629
593 data->buffer[8] = '\0';//remove it 630 $Description: Callback function for the editor window
594 data->buffer[9] = '\0'; //ensure string is properly terminated 631
595 //ensure string is no longer than 9 chars 632 $Returns: nothing
596 633
597 calcSetEditor(win); 634 $Arguments: Window, identifier (not used), reason (not used)
598
599 /* SPR#1428 - SH - New Editor changes */
600 #ifdef NEW_EDITOR
601 AUI_edit_SetEvents(&data->editor_data, 0, TRUE, FOREVER, (T_AUI_EDIT_CB)calcGetNumberCB);
602 AUI_calc_Start(win, &data->editor_data);
603 #else /* NEW_EDITOR */
604 data->editor_data.Callback = (T_EDIT_CB)calcGetNumberCB;
605 editor_start(win, &(data->editor_data)); /* start the editor */
606 #endif /* NEW_EDITOR */
607
608 /* Marcus: Issue 1039: 05/09/2002: Start */
609 if (data->menu_options_win != NULL)
610 {
611 bookMenuDestroy( data->menu_options_win );
612 data->menu_options_win = NULL;
613 }
614 /* Marcus: Issue 1039: 05/09/2002: End */
615
616 winShow(data->win);
617 }
618 break;
619 default:
620 {
621 TRACE_EVENT("calc_DialogCB(): Unknown Event");
622 }
623 break;
624
625 }
626
627
628 }
629
630 /*******************************************************************************
631
632 $Function: calcGetNumberCB
633
634 $Description: Callback function for the editor window
635
636 $Returns: nothing
637
638 $Arguments: Window, identifier (not used), reason (not used)
639 635
640 *******************************************************************************/ 636 *******************************************************************************/
641 static void calcGetNumberCB( T_MFW_HND win, USHORT Identifier, SHORT reason) 637 static void calcGetNumberCB( T_MFW_HND win, USHORT Identifier, SHORT reason)
642 { 638 {
643 T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data; 639 T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
644 tCalcData *data = (tCalcData *) win_data->user; 640 tCalcData *data = (tCalcData *) win_data->user;
645 float after_decimal = 0; 641 float after_decimal = 0;
646 int digits_after_point = 0; 642 int digits_after_point = 0;
647 int i; 643 int i;
648 char* end; 644 char* end;
649 // char debug[40]; // RAVI 645 // char debug[40]; // RAVI
650 646
651 647
652 TRACE_FUNCTION("calcGetNumberCB()"); 648 TRACE_FUNCTION("calcGetNumberCB()");
653 649
654 switch (reason ) 650 switch (reason )
655 { 651 {
656 case INFO_KCD_LEFT: 652 case INFO_KCD_LEFT:
657 { TRACE_EVENT("Left button pressed in calculator"); 653 { TRACE_EVENT("Left button pressed in calculator");
658 //get the number entered before the decimal point 654 //get the number entered before the decimal point
659 running_total = strtol(data->buffer, &end, 10); 655 running_total = strtol(data->buffer, &end, 10);
660 if (strlen(end) != 0) 656 if (strlen(end) != 0)
661 { //if decimal point entered 657 { //if decimal point entered
662 if ((end[0] == '.') && isdigit(end[1]))//get number after decimal point 658 if ((end[0] == '.') && isdigit(end[1]))//get number after decimal point
663 { 659 {
664 end++; 660 end++;
665 digits_after_point = strlen(end); 661 digits_after_point = strlen(end);
666 after_decimal = strtol(end, &end, 10); 662 after_decimal = strtol(end, &end, 10);
667 } 663 }
668 664
669 //convert number after decimal point to it's actual fractional value 665 //convert number after decimal point to it's actual fractional value
670 for (i=0; i < digits_after_point; i++) 666 for (i=0; i < digits_after_point; i++)
671 after_decimal = after_decimal/10; 667 after_decimal = after_decimal/10;
672 //add whole number and fraction together 668 //add whole number and fraction together
673 running_total = running_total + after_decimal; 669 running_total = running_total + after_decimal;
674 } 670 }
675 if (data->menu_options_win != NULL) 671 if (data->menu_options_win != NULL)
676 bookMenuDestroy( data->menu_options_win ); 672 bookMenuDestroy( data->menu_options_win );
677 //start the calculator option menu and kill this window 673 //start the calculator option menu and kill this window
678 data->menu_options_win = bookMenuStart( data->win, calcOptionMenuAttributes(),0); 674 data->menu_options_win = bookMenuStart( data->win, calcOptionMenuAttributes(),0);
679 SEND_EVENT(data->menu_options_win, ADD_CALLBACK, NULL, (void *)calc_menu_cb); 675 SEND_EVENT(data->menu_options_win, ADD_CALLBACK, NULL, (void *)calc_menu_cb);
680 676
681 } 677 }
682 break; 678 break;
683 679
684 case INFO_KCD_HUP: 680 case INFO_KCD_HUP:
685 case INFO_KCD_RIGHT: 681 case INFO_KCD_RIGHT:
686 { 682 {
687 TRACE_EVENT("Right button pressed in calculator"); 683 TRACE_EVENT("Right button pressed in calculator");
688 calc_destroy(win); 684 calc_destroy(win);
689 } 685 }
690 break; 686 break;
691 687
692 default: 688 default:
693 { 689 {
694 /* otherwise no action to be performed 690 /* otherwise no action to be performed
695 */ 691 */
696 /*calc_destroy(win); */ /*SH - do not destroy calc for other key */ 692 /*calc_destroy(win); */ /*SH - do not destroy calc for other key */
697 break; 693 break;
698 } 694 }
699 } 695 }
700 } 696 }
701 697
702 698
703 /******************************************************************************* 699 /*******************************************************************************
704 700
705 $Function: calcGetOperandCB 701 $Function: calcGetOperandCB
706 702
707 $Description: Callback function for the editor window, when second number in operation 703 $Description: Callback function for the editor window, when second number in operation
708 is entered. 704 is entered.
709 705
710 $Returns: nothing 706 $Returns: nothing
711 707
712 $Arguments: Window, identifier (not used), reason (not used) 708 $Arguments: Window, identifier (not used), reason (not used)
713 709
714 *******************************************************************************/ 710 *******************************************************************************/
715 711
716 static void calcGetOperandCB( T_MFW_HND win, USHORT Identifier, SHORT reason) 712 static void calcGetOperandCB( T_MFW_HND win, USHORT Identifier, SHORT reason)
717 { 713 {
718 T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data; 714 T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
719 tCalcData *data = (tCalcData *) win_data->user; 715 tCalcData *data = (tCalcData *) win_data->user;
720 // char* buffer; // RAVI 716 // char* buffer; // RAVI
721 float operand = 0; 717 float operand = 0;
722 float after_decimal = 0; 718 float after_decimal = 0;
723 int digits_after_point = 0; 719 int digits_after_point = 0;
724 int i; 720 int i;
725 char* end; 721 char* end;
726 char debug[40]; 722 char debug[40];
727 723
728 TRACE_FUNCTION("calcGetOperandCB()"); 724 TRACE_FUNCTION("calcGetOperandCB()");
729 TRACE_EVENT_P2("ID, reason: %d, %d", Identifier, reason); 725 TRACE_EVENT_P2("ID, reason: %d, %d", Identifier, reason);
730 726
731 switch (reason ) 727 switch (reason )
732 { 728 {
733 case INFO_KCD_LEFT: 729 case INFO_KCD_LEFT:
734 /* SPR#1428 - SH - New Editor: Can use '*' or centre button as 'equals', to show result */ 730 /* SPR#1428 - SH - New Editor: Can use '*' or centre button as 'equals', to show result */
735 #ifdef NEW_EDITOR 731 #ifdef NEW_EDITOR
736 #ifdef COLOURDISPLAY 732 #ifdef COLOURDISPLAY
737 case INFO_KCD_SELECT: 733 case INFO_KCD_SELECT:
738 #endif /* COLOURDISPLAY */ 734 #endif /* COLOURDISPLAY */
739 case INFO_KCD_STAR: 735 case INFO_KCD_STAR:
740 #endif /* NEW_EDITOR */ 736 #endif /* NEW_EDITOR */
741 { //Get whole number before decimal point 737 { //Get whole number before decimal point
742 operand = strtol(data->buffer, &end, 10); 738 operand = strtol(data->buffer, &end, 10);
743 739
744 //if buffer not pointing at an empty string now 740 //if buffer not pointing at an empty string now
745 if (strlen(end) != 0) 741 if (strlen(end) != 0)
746 { //if decimal point entered 742 { //if decimal point entered
747 if ((end[0] == '.') && isdigit(end[1]))//get number after decimal point 743 if ((end[0] == '.') && isdigit(end[1]))//get number after decimal point
748 { 744 {
749 end++; 745 end++;
750 digits_after_point = strlen(end); 746 digits_after_point = strlen(end);
751 after_decimal = strtol(end, &end, 10); 747 after_decimal = strtol(end, &end, 10);
752 sprintf(debug,"Digits after decimal: %f.", after_decimal); 748 sprintf(debug,"Digits after decimal: %f.", after_decimal);
753 } 749 }
754 //convert number after decimal point to an appropriate fraction 750 //convert number after decimal point to an appropriate fraction
755 for (i=0; i < digits_after_point; i++) 751 for (i=0; i < digits_after_point; i++)
756 after_decimal = after_decimal/10; 752 after_decimal = after_decimal/10;
757 //add whole and fraction together 753 //add whole and fraction together
758 operand = operand + after_decimal; 754 operand = operand + after_decimal;
759 } 755 }
760 756
761 //perform the arithmetic function requested 757 //perform the arithmetic function requested
762 switch (data->operation) 758 switch (data->operation)
763 { 759 {
764 case PLUS: running_total = running_total + operand; break; 760 case PLUS: running_total = running_total + operand; break;
765 case MINUS: running_total = running_total - operand;break; 761 case MINUS: running_total = running_total - operand;break;
766 case MULTIPLY: running_total = running_total * operand;break; 762 case MULTIPLY: running_total = running_total * operand;break;
767 case DIVIDE: 763 case DIVIDE:
768 // Oct 20, 2004 REF: CRR 25755 xnkulkar 764 // Oct 20, 2004 REF: CRR 25755 xnkulkar
769 // if the attempted division is by zero 765 // if the attempted division is by zero
770 if(operand == 0) 766 if(operand == 0)
771 { 767 {
772 divideByZero = TRUE; // enable the flag 768 divideByZero = TRUE; // enable the flag
773 } 769 }
774 else // else perform the division operation 770 else // else perform the division operation
775 { 771 {
776 running_total = running_total / operand; 772 running_total = running_total / operand;
777 } 773 }
778 break; 774 break;
779 default: TRACE_EVENT("Unknown calc operation"); break; 775 default: TRACE_EVENT("Unknown calc operation"); break;
780 } 776 }
781 777
782 /* SPR#1428 - SH - New Editor: Can use '*' as 'equals', to show result */ 778 /* SPR#1428 - SH - New Editor: Can use '*' as 'equals', to show result */
783 #ifdef NEW_EDITOR 779 #ifdef NEW_EDITOR
784 #ifdef COLOURDISPLAY 780 #ifdef COLOURDISPLAY
785 if (reason==INFO_KCD_STAR || reason==INFO_KCD_SELECT) 781 if (reason==INFO_KCD_STAR || reason==INFO_KCD_SELECT)
786 #else /* COLOURDISPLAY */ 782 #else /* COLOURDISPLAY */
787 if (reason==INFO_KCD_STAR) 783 if (reason==INFO_KCD_STAR)
788 #endif /* COLOURDISPLAY */ 784 #endif /* COLOURDISPLAY */
789 { 785 {
790 TRACE_EVENT("Star key - show result"); 786 TRACE_EVENT("Star key - show result");
791 /* Star didn't destroy window automatically, do it here */ 787 /* Star didn't destroy window automatically, do it here */
792 if (data->menu_options_win != NULL) 788 if (data->menu_options_win != NULL)
793 { 789 {
794 bookMenuDestroy( data->menu_options_win ); 790 bookMenuDestroy( data->menu_options_win );
795 data->menu_options_win = NULL; 791 data->menu_options_win = NULL;
796 } 792 }
797 if (data->input_number_win) 793 if (data->input_number_win)
798 { 794 {
799 AUI_calc_Destroy(data->input_number_win); 795 AUI_calc_Destroy(data->input_number_win);
800 data->input_number_win = NULL; 796 data->input_number_win = NULL;
801 } 797 }
802 SEND_EVENT(data->win, CALC_DISPLAY_RESULT, 0, 0); 798 SEND_EVENT(data->win, CALC_DISPLAY_RESULT, 0, 0);
803 } 799 }
804 else 800 else
805 #endif /* NEW_EDITOR */ 801 #endif /* NEW_EDITOR */
806 { 802 {
807 //Show option menu 803 //Show option menu
808 if (data->menu_options_win != NULL) 804 if (data->menu_options_win != NULL)
809 bookMenuDestroy( data->menu_options_win ); 805 bookMenuDestroy( data->menu_options_win );
810 data->menu_options_win = bookMenuStart( data->win, calcOptionMenuAttributes(),0); 806 data->menu_options_win = bookMenuStart( data->win, calcOptionMenuAttributes(),0);
811 } 807 }
812 } 808 }
813 break; 809 break;
814 810
815 case INFO_KCD_HUP: 811 case INFO_KCD_HUP:
816 case INFO_KCD_RIGHT: 812 case INFO_KCD_RIGHT:
817 { 813 {
818 TRACE_EVENT("Right button pressed in calculator"); 814 TRACE_EVENT("Right button pressed in calculator");
819 815
820 calc_destroy(win); 816 calc_destroy(win);
821 } 817 }
822 break; 818 break;
823 819
824 default: 820 default:
825 { 821 {
826 /* otherwise no action to be performed 822 /* otherwise no action to be performed
827 */ 823 */
828 break; 824 break;
829 } 825 }
830 } 826 }
831 } 827 }
832 828
833 829
834 static void calc_menu_cb(T_MFW_HND parent_win, UBYTE identifier, UBYTE reason) 830 static void calc_menu_cb(T_MFW_HND parent_win, UBYTE identifier, UBYTE reason)
835 { 831 {
836 T_MFW_WIN *win_data = ( (T_MFW_HDR *) parent_win )->data; 832 T_MFW_WIN *win_data = ( (T_MFW_HDR *) parent_win )->data;
837 tCalcData* data = (tCalcData *) win_data->user; 833 tCalcData* data = (tCalcData *) win_data->user;
838 834
839 TRACE_FUNCTION("calc_menu_cb()"); 835 TRACE_FUNCTION("calc_menu_cb()");
840 //set menu window to NULL to prevent any dealloc problems 836 //set menu window to NULL to prevent any dealloc problems
841 data->menu_options_win = NULL; 837 data->menu_options_win = NULL;
842 calc_destroy(parent_win); 838 calc_destroy(parent_win);
843 839 }
844 840
845 } 841 /*******************************************************************************
846 842
847 /******************************************************************************* 843 $Function: calcSetEditor
848 844
849 $Function: calcSetEditor 845 $Description: Sets the editor attributes to defaults for the calculator module
850 846
851 $Description: Sets the editor attributes to defaults for the calculator module 847 $Returns: nothing
852 848
853 $Returns: nothing 849 $Arguments: Window
854
855 $Arguments: Window
856 850
857 *******************************************************************************/ 851 *******************************************************************************/
858 void calcSetEditor(T_MFW_HND win) 852 void calcSetEditor(T_MFW_HND win)
859 { 853 {
860 T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data; 854 T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
861 tCalcData* data = (tCalcData *) win_data->user; 855 tCalcData* data = (tCalcData *) win_data->user;
862 856
863 TRACE_FUNCTION("calcSetEditor()"); 857 TRACE_FUNCTION("calcSetEditor()");
864 858
865 /* SPR#1428 - SH - New Editor changes */ 859 /* SPR#1428 - SH - New Editor changes */
866 #ifdef NEW_EDITOR 860 #ifdef NEW_EDITOR
867 { 861 {
868 AUI_edit_SetDefault(&data->editor_data); 862 AUI_edit_SetDefault(&data->editor_data);
869 AUI_edit_SetDisplay(&data->editor_data, ZONE_FULL_SK_TITLE, COLOUR_EDITOR, EDITOR_FONT); 863 AUI_edit_SetDisplay(&data->editor_data, ZONE_FULL_SK_TITLE, COLOUR_EDITOR, EDITOR_FONT);
870 AUI_edit_SetBuffer(&data->editor_data, ATB_DCS_ASCII, (UBYTE *)data->buffer, 10); 864 AUI_edit_SetBuffer(&data->editor_data, ATB_DCS_ASCII, (UBYTE *)data->buffer, 10);
871 AUI_edit_SetMode(&data->editor_data, 0, ED_CURSOR_NONE); 865 AUI_edit_SetMode(&data->editor_data, 0, ED_CURSOR_NONE);
872 AUI_edit_SetEvents(&data->editor_data, 0, TRUE, FOREVER, NULL); 866 AUI_edit_SetEvents(&data->editor_data, 0, TRUE, FOREVER, NULL);
873 AUI_edit_SetTextStr(&data->editor_data, TxtSoftOptions, TxtDelete, TxtCalculator, NULL); 867 AUI_edit_SetTextStr(&data->editor_data, TxtSoftOptions, TxtDelete, TxtCalculator, NULL);
874 //xrashmic 20 Oct, 2005 MMI-SPR-33845 868 //xrashmic 20 Oct, 2005 MMI-SPR-33845
875 //Editor always starts with min one character "0" and 869 //Editor always starts with min one character "0" and
876 //alterRight softkey is set to "BACK" here. 870 //alterRight softkey is set to "BACK" here.
877 data->editor_data.min_enter=1; 871 data->editor_data.min_enter=1;
878 data->editor_data.AltRightSoftKey=TxtSoftBack ; 872 data->editor_data.AltRightSoftKey=TxtSoftBack ;
879 AUI_edit_SetFormatAttr(&data->editor_data, DS_ALIGN_RIGHT); 873 AUI_edit_SetFormatAttr(&data->editor_data, DS_ALIGN_RIGHT);
880 } 874 }
881 #else /* NEW_EDITOR */ 875 #else /* NEW_EDITOR */
882 editor_attr_init(&((data->editor_data).editor_attr), 0, edtCurBar1, 0, data->buffer, 10, COLOUR_EDITOR); 876 editor_attr_init(&((data->editor_data).editor_attr), 0, edtCurBar1, 0, data->buffer, 10, COLOUR_EDITOR);
883 editor_data_init( &data->editor_data, NULL, TxtSoftOptions, TxtDelete, NULL, 1, CALC_MODE, FOREVER); 877 editor_data_init( &data->editor_data, NULL, TxtSoftOptions, TxtDelete, NULL, 1, CALC_MODE, FOREVER);
884 data->editor_data.hide = FALSE; 878 data->editor_data.hide = FALSE;
885 data->editor_data.Identifier = 0xFFFF ; 879 data->editor_data.Identifier = 0xFFFF ;
886 data->editor_data.destroyEditor = TRUE; 880 data->editor_data.destroyEditor = TRUE;
887 #endif /* NEW_EDITOR */ 881 #endif /* NEW_EDITOR */
888 882
889 return; 883 return;
890 } 884 }
891 885
892 /******************************************************************************* 886 /*******************************************************************************
893 887
894 $Function: calc_destroy 888 $Function: calc_destroy
895 889
896 $Description: Destroys the calculator editor window and frees up memory 890 $Description: Destroys the calculator editor window and frees up memory
897 891
898 $Returns: nothing 892 $Returns: nothing
899 893
900 $Arguments: Window 894 $Arguments: Window
901 895
902 *******************************************************************************/ 896 *******************************************************************************/
903 void calc_destroy(MfwHnd own_window) 897 void calc_destroy(MfwHnd own_window)
904 { 898 {
905 T_MFW_WIN * win_data; 899 T_MFW_WIN * win_data;
906 tCalcData * data = NULL; 900 tCalcData * data = NULL;
907 901
908 TRACE_EVENT ("calc_destroy()"); 902 TRACE_EVENT ("calc_destroy()");
909 if (own_window) 903 if (own_window)
910 { 904 {
911 905
912 win_data = ((T_MFW_HDR *)own_window)->data; 906 win_data = ((T_MFW_HDR *)own_window)->data;
913 if (win_data != NULL) //PATCH TB 907 if (win_data != NULL) //PATCH TB
914 data = (tCalcData *)win_data->user; 908 data = (tCalcData *)win_data->user;
915 909
916 if (data) 910 if (data)
917 { 911 {
918 912
919 win_delete (data->win); 913 win_delete (data->win);
920 /* Marcus: Issue 1039: 05/09/2002: Start */ 914 /* Marcus: Issue 1039: 05/09/2002: Start */
921 if (data->menu_options_win != NULL) 915 if (data->menu_options_win != NULL)
922 { 916 {
923 bookMenuDestroy( data->menu_options_win ); 917 bookMenuDestroy( data->menu_options_win );
924 data->menu_options_win = NULL; 918 data->menu_options_win = NULL;
925 } 919 }
926 /* Marcus: Issue 1039: 05/09/2002: End */ 920 /* Marcus: Issue 1039: 05/09/2002: End */
927 // Free Memory 921 // Free Memory
928 FREE_MEMORY ((void *)data, sizeof (tCalcData)); 922 FREE_MEMORY ((void *)data, sizeof (tCalcData));
929 923
930 } 924 }
931 else 925 else
932 { 926 {
933 TRACE_EVENT ("calc_destroy() called twice"); 927 TRACE_EVENT ("calc_destroy() called twice");
934 } 928 }
935 } 929 }
936 } 930 }
937
938
939
940