FreeCalypso > hg > fc-tourmaline
comparison src/ui/bmi/AUICalcEditor.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 | 70ea7526b59e |
comparison
equal
deleted
inserted
replaced
91:c3d28a37caad | 92:c0052fe355d3 |
---|---|
28 | 28 |
29 $History: AUICalcEditor.c | 29 $History: AUICalcEditor.c |
30 | 30 |
31 xrashmic 20 Oct, 2005 MMI-SPR-33845 | 31 xrashmic 20 Oct, 2005 MMI-SPR-33845 |
32 To display BACK softkey when no more character are left in the calculator editor | 32 To display BACK softkey when no more character are left in the calculator editor |
33 | 33 |
34 14/11/02 Original Condat(UK) BMI version. | 34 14/11/02 Original Condat(UK) BMI version. |
35 $End | 35 $End |
36 | 36 |
37 *******************************************************************************/ | 37 *******************************************************************************/ |
38 | 38 |
165 /******************************************************************************* | 165 /******************************************************************************* |
166 | 166 |
167 $Function: AUI_calc_Create | 167 $Function: AUI_calc_Create |
168 | 168 |
169 $Description: Create the Calc editor. | 169 $Description: Create the Calc editor. |
170 | 170 |
171 $Returns: Pointer to the editor's window. | 171 $Returns: Pointer to the editor's window. |
172 | 172 |
173 $Arguments: parent - The parent window. | 173 $Arguments: parent - The parent window. |
174 | 174 |
175 *******************************************************************************/ | 175 *******************************************************************************/ |
189 { | 189 { |
190 return NULL; | 190 return NULL; |
191 } | 191 } |
192 | 192 |
193 /* Connect the dialog data to the MFW-window */ | 193 /* Connect the dialog data to the MFW-window */ |
194 | 194 |
195 data->mmi_control.dialog = (T_DIALOG_FUNC)AUI_calc_ExecCb; /* Setup the destination for events */ | 195 data->mmi_control.dialog = (T_DIALOG_FUNC)AUI_calc_ExecCb; /* Setup the destination for events */ |
196 data->mmi_control.data = data; | 196 data->mmi_control.data = data; |
197 data->parent = parent; | 197 data->parent = parent; |
198 win_data = ((T_MFW_HDR *)data->win)->data; | 198 win_data = ((T_MFW_HDR *)data->win)->data; |
199 win_data->user = (void *)data; | 199 win_data->user = (void *)data; |
200 | 200 |
201 data->kbd = kbd_create(data->win, KEY_ALL,(T_MFW_CB)AUI_calc_KbdCb); | 201 data->kbd = kbd_create(data->win, KEY_ALL,(T_MFW_CB)AUI_calc_KbdCb); |
202 data->kbd_long = kbd_create(data->win, KEY_ALL|KEY_LONG,(T_MFW_CB)AUI_calc_KbdLongCb); | 202 data->kbd_long = kbd_create(data->win, KEY_ALL|KEY_LONG,(T_MFW_CB)AUI_calc_KbdLongCb); |
203 data->editor = ATB_edit_Create(&data->editor_data.editor_attr,0); | 203 data->editor = ATB_edit_Create(&data->editor_data.editor_attr,0); |
204 | 204 |
205 data->editor_data = *editor_data; | 205 data->editor_data = *editor_data; |
206 data->entry_data = AUI_entry_Create(data->win, data->editor, E_CALC_UPDATE); | 206 data->entry_data = AUI_entry_Create(data->win, data->editor, E_CALC_UPDATE); |
207 | 207 |
208 SEND_EVENT(data->win, E_CALC_INIT, 0, 0); | 208 SEND_EVENT(data->win, E_CALC_INIT, 0, 0); |
209 | 209 |
210 /* Return window handle */ | 210 /* Return window handle */ |
211 | 211 |
212 return data->win; | 212 return data->win; |
213 } | 213 } |
214 | 214 |
231 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; | 231 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; |
232 | 232 |
233 if (data) | 233 if (data) |
234 { | 234 { |
235 AUI_entry_Destroy(data->entry_data); | 235 AUI_entry_Destroy(data->entry_data); |
236 | 236 |
237 win_delete (data->win); | 237 win_delete (data->win); |
238 | 238 |
239 /* Free memory allocated to store result */ | 239 /* Free memory allocated to store result */ |
240 | 240 |
241 if (data->haveResult) | 241 if (data->haveResult) |
242 { | 242 { |
243 FREE_MEMORY(data->result.data, data->result.len*sizeof(char)); | 243 FREE_MEMORY(data->result.data, data->result.len*sizeof(char)); |
244 } | 244 } |
245 | 245 |
246 /* Free editor memory */ | 246 /* Free editor memory */ |
247 | 247 |
248 ATB_edit_Destroy(data->editor); | 248 ATB_edit_Destroy(data->editor); |
249 FREE_MEMORY ((void *)data, sizeof (T_AUI_CALC_DATA)); | 249 FREE_MEMORY ((void *)data, sizeof (T_AUI_CALC_DATA)); |
250 } | 250 } |
251 | 251 |
252 return; | 252 return; |
253 } | 253 } |
254 | 254 |
255 | 255 |
256 /******************************************************************************* | 256 /******************************************************************************* |
257 | 257 |
258 $Function: AUI_calc_ExecCb | 258 $Function: AUI_calc_ExecCb |
259 | 259 |
260 $Description: Dialog function for Calc editor. | 260 $Description: Dialog function for Calc editor. |
261 | 261 |
262 $Returns: None. | 262 $Returns: None. |
263 | 263 |
264 $Arguments: None. | 264 $Arguments: None. |
265 | 265 |
266 *******************************************************************************/ | 266 *******************************************************************************/ |
267 | 267 |
268 static void AUI_calc_ExecCb(T_MFW_HND win, USHORT event, SHORT value, void *parameter) | 268 static void AUI_calc_ExecCb(T_MFW_HND win, USHORT event, SHORT value, void *parameter) |
269 { | 269 { |
270 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; | 270 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; |
274 T_ATB_TEXT text; | 274 T_ATB_TEXT text; |
275 /* Store these in case editor is destroyed on callback */ | 275 /* Store these in case editor is destroyed on callback */ |
276 USHORT Identifier = data->editor_data.Identifier; | 276 USHORT Identifier = data->editor_data.Identifier; |
277 T_AUI_EDIT_CB Callback = data->editor_data.Callback; | 277 T_AUI_EDIT_CB Callback = data->editor_data.Callback; |
278 UBYTE destroyEditor = data->editor_data.destroyEditor; | 278 UBYTE destroyEditor = data->editor_data.destroyEditor; |
279 | 279 |
280 TRACE_FUNCTION ("AUI_calc_ExecCb()"); | 280 TRACE_FUNCTION ("AUI_calc_ExecCb()"); |
281 | 281 |
282 switch (event) | 282 switch (event) |
283 { | 283 { |
284 /* Initialise */ | 284 /* Initialise */ |
285 | 285 |
286 case E_CALC_INIT: | 286 case E_CALC_INIT: |
287 TRACE_EVENT("E_CALC_INIT"); | 287 TRACE_EVENT("E_CALC_INIT"); |
288 ATB_edit_Init(data->editor); | 288 ATB_edit_Init(data->editor); |
289 | 289 |
290 data->haveTitle = FALSE; | 290 data->haveTitle = FALSE; |
314 data->haveTitle = TRUE; | 314 data->haveTitle = TRUE; |
315 data->title.data = (UBYTE *)MmiRsrcGetText(data->editor_data.TitleId); | 315 data->title.data = (UBYTE *)MmiRsrcGetText(data->editor_data.TitleId); |
316 } | 316 } |
317 | 317 |
318 /* If title exists, get its dcs and length */ | 318 /* If title exists, get its dcs and length */ |
319 | 319 |
320 if (data->haveTitle) | 320 if (data->haveTitle) |
321 { | 321 { |
322 if (data->title.data[0]==0x80) | 322 if (data->title.data[0]==0x80) |
323 { | 323 { |
324 data->title.data += 2; /* Skip over two unicode indicator bytes */ | 324 data->title.data += 2; /* Skip over two unicode indicator bytes */ |
332 #endif | 332 #endif |
333 else | 333 else |
334 { | 334 { |
335 data->title.dcs = ATB_DCS_ASCII; | 335 data->title.dcs = ATB_DCS_ASCII; |
336 } | 336 } |
337 | 337 |
338 data->title.len = ATB_string_Length(&data->title); | 338 data->title.len = ATB_string_Length(&data->title); |
339 } | 339 } |
340 | 340 |
341 /* Check to see if number already has decimal point */ | 341 /* Check to see if number already has decimal point */ |
342 | 342 |
343 data->hasDecimalPoint = FALSE; | 343 data->hasDecimalPoint = FALSE; |
344 | 344 |
345 for (textIndex = 0; textIndex<data->editor->attr->text.len; textIndex++) | 345 for (textIndex = 0; textIndex<data->editor->attr->text.len; textIndex++) |
346 { | 346 { |
347 if (ATB_string_GetChar(&data->editor->attr->text, textIndex)==UNICODE_FULLSTOP) | 347 if (ATB_string_GetChar(&data->editor->attr->text, textIndex)==UNICODE_FULLSTOP) |
348 { | 348 { |
349 data->hasDecimalPoint = TRUE; | 349 data->hasDecimalPoint = TRUE; |
362 case E_CALC_DEINIT: | 362 case E_CALC_DEINIT: |
363 TRACE_EVENT("E_CALC_DEINIT"); | 363 TRACE_EVENT("E_CALC_DEINIT"); |
364 | 364 |
365 if (Callback) | 365 if (Callback) |
366 (Callback) (parent_win, Identifier, value); | 366 (Callback) (parent_win, Identifier, value); |
367 | 367 |
368 if (destroyEditor) | 368 if (destroyEditor) |
369 AUI_calc_Destroy(data->win); | 369 AUI_calc_Destroy(data->win); |
370 | 370 |
371 break; | 371 break; |
372 | 372 |
373 } | 373 } |
374 | 374 |
375 return; | 375 return; |
395 T_ATB_WIN_SIZE *win_size = &data->editor->attr->win_size; | 395 T_ATB_WIN_SIZE *win_size = &data->editor->attr->win_size; |
396 T_DS_TEXTFORMAT format; | 396 T_DS_TEXTFORMAT format; |
397 // USHORT titleLen; // RAVI | 397 // USHORT titleLen; // RAVI |
398 | 398 |
399 TRACE_EVENT("AUI_calc_WinCb"); | 399 TRACE_EVENT("AUI_calc_WinCb"); |
400 | 400 |
401 if (!data) | 401 if (!data) |
402 return MFW_EVENT_CONSUMED; | 402 return MFW_EVENT_CONSUMED; |
403 | 403 |
404 switch(event) | 404 switch(event) |
405 { | 405 { |
406 case E_WIN_VISIBLE: /* window is visible */ | 406 case E_WIN_VISIBLE: /* window is visible */ |
407 if (win_data->flags & E_WIN_VISIBLE) | 407 if (win_data->flags & E_WIN_VISIBLE) |
408 { | 408 { |
420 /* Set the colour for drawing title */ | 420 /* Set the colour for drawing title */ |
421 | 421 |
422 resources_setTitleColour(COLOUR_EDITOR); | 422 resources_setTitleColour(COLOUR_EDITOR); |
423 | 423 |
424 /* TITLE */ | 424 /* TITLE */ |
425 | 425 |
426 dspl_Clear(0,0, SCREEN_SIZE_X-1, win_size->py-1); | 426 dspl_Clear(0,0, SCREEN_SIZE_X-1, win_size->py-1); |
427 | 427 |
428 if (data->haveTitle) | 428 if (data->haveTitle) |
429 { | 429 { |
430 ATB_display_SetFormatAttr(&format, 0, FALSE); | 430 ATB_display_SetFormatAttr(&format, 0, FALSE); |
431 ATB_display_Text(0,0,&format, &data->title); | 431 ATB_display_Text(0,0,&format, &data->title); |
432 } | 432 } |
437 { | 437 { |
438 resources_setHLColour(COLOUR_EDITOR); | 438 resources_setHLColour(COLOUR_EDITOR); |
439 ATB_display_SetFormatAttr(&format, 0, FALSE); | 439 ATB_display_SetFormatAttr(&format, 0, FALSE); |
440 dspl_Clear( win_size->px, win_size->py+win_size->sy, win_size->px+win_size->sx, | 440 dspl_Clear( win_size->px, win_size->py+win_size->sy, win_size->px+win_size->sx, |
441 win_size->py+win_size->sy+ATB_display_StringHeight(&data->result, &format)); | 441 win_size->py+win_size->sy+ATB_display_StringHeight(&data->result, &format)); |
442 | 442 |
443 ATB_display_Text(win_size->px+win_size->sx-ATB_display_StringWidth(&data->result, &format), | 443 ATB_display_Text(win_size->px+win_size->sx-ATB_display_StringWidth(&data->result, &format), |
444 win_size->py+win_size->sy,&format, &data->result); | 444 win_size->py+win_size->sy,&format, &data->result); |
445 } | 445 } |
446 | 446 |
447 /* Display Soft Keys */ | 447 /* Display Soft Keys */ |
448 //xrashmic 20 Oct, 2005 MMI-SPR-33845 | 448 //xrashmic 20 Oct, 2005 MMI-SPR-33845 |
449 //Need to display the alternate right softkey when the editor is does not contain any character other than 0. | 449 //Need to display the alternate right softkey when the editor is does not contain any character other than 0. |
450 if (data->editor_data.editor_attr.text.len == data->editor_data.min_enter && (data->editor_data.editor_attr.text.data[0] == '0')) | 450 if (data->editor_data.editor_attr.text.len == data->editor_data.min_enter && (data->editor_data.editor_attr.text.data[0] == '0')) |
451 { | 451 { |
452 /* entered less than the required number of chars: Alternate Softkey appears */ | 452 /* entered less than the required number of chars: Alternate Softkey appears */ |
453 displaySoftKeys(data->editor_data.LeftSoftKey,data->editor_data.AltRightSoftKey); | 453 displaySoftKeys(data->editor_data.LeftSoftKey,data->editor_data.AltRightSoftKey); |
462 break; | 462 break; |
463 } | 463 } |
464 | 464 |
465 data->editor->update = ED_UPDATE_DEFAULT; | 465 data->editor->update = ED_UPDATE_DEFAULT; |
466 | 466 |
467 return MFW_EVENT_CONSUMED; | 467 return MFW_EVENT_CONSUMED; |
468 } | 468 } |
469 | 469 |
470 | 470 |
471 /******************************************************************************* | 471 /******************************************************************************* |
472 | 472 |
485 { | 485 { |
486 T_MFW_HND win = mfw_parent (mfw_header()); | 486 T_MFW_HND win = mfw_parent (mfw_header()); |
487 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; | 487 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; |
488 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; | 488 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; |
489 ED_RES result; | 489 ED_RES result; |
490 | 490 |
491 TRACE_FUNCTION("AUI_calc_KbdCb()"); | 491 TRACE_FUNCTION("AUI_calc_KbdCb()"); |
492 | 492 |
493 /* Suppress unwanted long keypresses */ | 493 /* Suppress unwanted long keypresses */ |
494 | 494 |
495 data->doNextLongPress = TRUE; /* next Key_long event is correct */ | 495 data->doNextLongPress = TRUE; /* next Key_long event is correct */ |
517 data->hasDecimalPoint = TRUE; | 517 data->hasDecimalPoint = TRUE; |
518 AUI_entry_EditChar(data->entry_data, UNICODE_FULLSTOP, FALSE); | 518 AUI_entry_EditChar(data->entry_data, UNICODE_FULLSTOP, FALSE); |
519 win_show(data->win); | 519 win_show(data->win); |
520 } | 520 } |
521 break; | 521 break; |
522 | 522 |
523 case KCD_LEFT: | 523 case KCD_LEFT: |
524 if (data->editor_data.editor_attr.text.len < data->editor_data.min_enter) | 524 if (data->editor_data.editor_attr.text.len < data->editor_data.min_enter) |
525 { | 525 { |
526 /* Entered less than the required number of chars */ | 526 /* Entered less than the required number of chars */ |
527 if (data->editor_data.AltLeftSoftKey!=TxtNull) | 527 if (data->editor_data.AltLeftSoftKey!=TxtNull) |
537 } | 537 } |
538 break; | 538 break; |
539 | 539 |
540 case KCD_HUP: | 540 case KCD_HUP: |
541 SEND_EVENT(data->win, E_CALC_DEINIT, INFO_KCD_HUP, 0); | 541 SEND_EVENT(data->win, E_CALC_DEINIT, INFO_KCD_HUP, 0); |
542 break; | 542 break; |
543 | 543 |
544 case KCD_RIGHT: | 544 case KCD_RIGHT: |
545 /* If we're deleting the decimal point... */ | 545 /* If we're deleting the decimal point... */ |
546 if (ATB_edit_GetCursorChar(data->editor, -1)==UNICODE_FULLSTOP) | 546 if (ATB_edit_GetCursorChar(data->editor, -1)==UNICODE_FULLSTOP) |
547 { | 547 { |
548 data->hasDecimalPoint = FALSE; | 548 data->hasDecimalPoint = FALSE; |
549 } | 549 } |
550 | 550 |
551 /* If we've just got a zero, delete it so we can exit with next call to ATB_edit_DeleteLeft() */ | 551 /* If we've just got a zero, delete it so we can exit with next call to ATB_edit_DeleteLeft() */ |
552 | 552 |
553 if (ATB_edit_GetCursorChar(data->editor, -1)==ATB_char_Unicode('0')) | 553 if (ATB_edit_GetCursorChar(data->editor, -1)==ATB_char_Unicode('0')) |
554 { | 554 { |
555 ATB_edit_DeleteLeft(data->editor, FALSE); /* SPR#2342 - SH */ | 555 ATB_edit_DeleteLeft(data->editor, FALSE); /* SPR#2342 - SH */ |
556 } | 556 } |
557 | 557 |
574 win_show(data->win); | 574 win_show(data->win); |
575 } | 575 } |
576 break; | 576 break; |
577 | 577 |
578 /* 0 - 9 */ | 578 /* 0 - 9 */ |
579 | 579 |
580 case KCD_0: | 580 case KCD_0: |
581 case KCD_1: | 581 case KCD_1: |
582 case KCD_2: | 582 case KCD_2: |
583 case KCD_3: | 583 case KCD_3: |
584 case KCD_4: | 584 case KCD_4: |
596 /* Insert the digit */ | 596 /* Insert the digit */ |
597 AUI_entry_EventKey(data->entry_data, event, keyboard); | 597 AUI_entry_EventKey(data->entry_data, event, keyboard); |
598 win_show(data->win); | 598 win_show(data->win); |
599 break; | 599 break; |
600 } | 600 } |
601 | 601 |
602 return MFW_EVENT_CONSUMED; | 602 return MFW_EVENT_CONSUMED; |
603 } | 603 } |
604 | 604 |
605 | 605 |
606 /******************************************************************************* | 606 /******************************************************************************* |
620 { | 620 { |
621 T_MFW_HND win = mfw_parent (mfw_header()); | 621 T_MFW_HND win = mfw_parent (mfw_header()); |
622 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; | 622 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data; |
623 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; | 623 T_AUI_CALC_DATA *data = (T_AUI_CALC_DATA *)win_data->user; |
624 ED_RES result; | 624 ED_RES result; |
625 | 625 |
626 /* Suppress unwanted long keypresses */ | 626 /* Suppress unwanted long keypresses */ |
627 | 627 |
628 if ( data->doNextLongPress ) | 628 if ( data->doNextLongPress ) |
629 data->doNextLongPress = FALSE; /* mark Key_long event as consumed but do current long press */ | 629 data->doNextLongPress = FALSE; /* mark Key_long event as consumed but do current long press */ |
630 else | 630 else |
631 return MFW_EVENT_CONSUMED; /* don't do current long press */ | 631 return MFW_EVENT_CONSUMED; /* don't do current long press */ |
632 | 632 |
633 switch (keyboard->code) | 633 switch (keyboard->code) |
634 { | 634 { |
635 case KCD_RIGHT: | 635 case KCD_RIGHT: |
636 /* Long press of RSK deletes buffer */ | 636 /* Long press of RSK deletes buffer */ |
637 result = ATB_edit_ClearAll(data->editor); | 637 result = ATB_edit_ClearAll(data->editor); |
638 | 638 |
639 /* If buffer is now empty, insert '0' */ | 639 /* If buffer is now empty, insert '0' */ |
640 if (data->editor->attr->text.len==0 && result!=ED_DONE) | 640 if (data->editor->attr->text.len==0 && result!=ED_DONE) |
641 { | 641 { |
642 AUI_entry_EditChar(data->entry_data, ATB_char_Unicode('0'), FALSE); | 642 AUI_entry_EditChar(data->entry_data, ATB_char_Unicode('0'), FALSE); |
643 } | 643 } |
644 | 644 |
645 /* If we've deleted on an empty buffer, exit editor */ | 645 /* If we've deleted on an empty buffer, exit editor */ |
646 if (result==ED_DONE) | 646 if (result==ED_DONE) |
647 { | 647 { |
648 SEND_EVENT(data->win, E_CALC_DEINIT, INFO_KCD_RIGHT, 0); | 648 SEND_EVENT(data->win, E_CALC_DEINIT, INFO_KCD_RIGHT, 0); |
649 } | 649 } |