branch | RCL_3 |
changeset 16 | 99b535de1dda |
parent 8 | ebe992a85829 |
child 19 | 0f21a5ec0db7 |
14:a616540b95d9 | 16:99b535de1dda |
---|---|
93 CCalcView::~CCalcView() |
93 CCalcView::~CCalcView() |
94 { |
94 { |
95 delete iContainer; |
95 delete iContainer; |
96 if(iServiceHandler) |
96 if(iServiceHandler) |
97 { |
97 { |
98 delete iServiceHandler; |
98 delete iServiceHandler; |
99 iServiceHandler = NULL; |
99 iServiceHandler = NULL; |
100 } |
100 } |
101 |
101 |
102 } |
102 } |
103 |
103 |
104 // --------------------------------------------------------- |
104 // --------------------------------------------------------- |
105 // CCalcView::State |
105 // CCalcView::State |
106 // Return current state |
106 // Return current state |
107 // (other items were commented in a header). |
107 // (other items were commented in a header). |
151 default: |
151 default: |
152 break; |
152 break; |
153 } |
153 } |
154 break; |
154 break; |
155 } |
155 } |
156 case EOperatorResult: |
156 case EOperatorResult: |
157 { |
157 { |
158 iState = EOperatorOnlyResult; |
158 iState = EOperatorOnlyResult; |
159 break; |
159 break; |
160 } |
160 } |
161 case EOperator: |
161 case EOperator: |
162 { |
162 { |
163 iState = EOperandAndOperator; |
163 iState = EOperandAndOperator; |
164 break; |
164 break; |
165 } |
165 } |
219 resourceId = R_CALC_ERROR_DIVISIONBYZERO; |
219 resourceId = R_CALC_ERROR_DIVISIONBYZERO; |
220 |
220 |
221 // UpdateState( EOperator ); |
221 // UpdateState( EOperator ); |
222 break; |
222 break; |
223 } |
223 } |
224 case KErrNotSupported: |
224 case KErrNotSupported: |
225 { |
225 { |
226 resourceId = R_CALC_ERROR_NEGATIVEVALUESQRT; |
226 resourceId = R_CALC_ERROR_NEGATIVEVALUESQRT; |
227 break; |
227 break; |
228 } |
228 } |
229 default: |
229 default: |
230 { |
230 { |
231 return; |
231 return; |
232 } |
232 } |
233 } |
233 } |
234 |
234 |
235 //Localisation of scalable UI. |
235 //Localisation of scalable UI. |
236 HBufC* message = iCoeEnv->AllocReadResourceLC(resourceId) ; |
236 HBufC* message = iCoeEnv->AllocReadResourceLC(resourceId) ; |
237 CAknErrorNote* note = new (ELeave) CAknErrorNote(); |
237 CAknErrorNote* note = new (ELeave) CAknErrorNote(); |
238 note->ExecuteLD(*message); |
238 note->ExecuteLD(*message); |
239 CleanupStack::PopAndDestroy(message); |
239 CleanupStack::PopAndDestroy(message); |
240 |
240 |
241 } |
241 } |
242 |
242 |
243 |
243 |
244 // ---------------------------------------------------- |
244 // ---------------------------------------------------- |
270 if (iCalcDocument->History()->Count() == 0) |
270 if (iCalcDocument->History()->Count() == 0) |
271 { |
271 { |
272 aMenuPane->DeleteMenuItem(ECalcCmdClearCalcAndHistory); |
272 aMenuPane->DeleteMenuItem(ECalcCmdClearCalcAndHistory); |
273 } |
273 } |
274 if(iLastResultSetected) |
274 if(iLastResultSetected) |
275 { |
275 { |
276 aMenuPane->DeleteMenuItem(ECalcCmdLastResult); |
276 aMenuPane->DeleteMenuItem(ECalcCmdLastResult); |
277 } |
277 } |
278 break; |
278 break; |
279 } |
279 } |
280 case EOperandAndOperator: |
280 case EOperandAndOperator: |
281 case EOperandAndOperatorAndOperand: |
281 case EOperandAndOperatorAndOperand: |
282 if(iLastResultSetected) |
282 if(iLastResultSetected) |
283 { |
283 { |
284 aMenuPane->DeleteMenuItem(ECalcCmdLastResult); |
284 aMenuPane->DeleteMenuItem(ECalcCmdLastResult); |
285 } |
285 } |
286 break; |
286 break; |
287 default: |
287 default: |
288 { |
288 { |
289 break; |
289 break; |
290 } |
290 } |
291 } |
291 } |
371 HandleLastResultL(); |
371 HandleLastResultL(); |
372 break; |
372 break; |
373 } |
373 } |
374 case ECalcCmdPercent: |
374 case ECalcCmdPercent: |
375 { |
375 { |
376 HandleOperatorL(TCalcEditLine::ECalcPercent); |
376 HandleOperatorL(TCalcEditLine::ECalcPercent); |
377 // The result is always is displayed |
377 // The result is always is displayed |
378 // after the percent button is pressed. |
378 // after the percent button is pressed. |
379 // But if there was a error in the calculation |
379 // But if there was a error in the calculation |
380 // this if will enable us to not call the |
380 // this if will enable us to not call the |
381 // HandleResultL and thus making sure that |
381 // HandleResultL and thus making sure that |
382 // the state of the buttons is identical to the |
382 // the state of the buttons is identical to the |
383 // situation before the calculation. |
383 // situation before the calculation. |
384 if (iState == EOperatorOnlyResult) |
384 if (iState == EOperatorOnlyResult) |
385 HandleResultL(); |
385 HandleResultL(); |
386 break; |
386 break; |
387 } |
387 } |
388 case ECalcCmdSqrt: |
388 case ECalcCmdSqrt: |
389 { |
389 { |
390 HandleOperatorL(TCalcEditLine::ECalcSqrt); |
390 // TRequestStatus trs; |
391 // HandleResultL only if sqrt was pressed after single operand. |
391 // RTimer timer; |
392 if (iState == EOperatorOnlyResult) |
392 // timer.CreateLocal(); |
393 HandleResultL(); |
393 // timer.After(trs, 1000*2); |
394 // while ( trs == KRequestPending) { |
|
395 // User::WaitForAnyRequest(); |
|
396 // } |
|
397 // timer.Cancel(); |
|
398 // timer.Close(); |
|
399 HandleOperatorL(TCalcEditLine::ECalcSqrt); |
|
400 // HandleResultL only if sqrt was pressed after single operand. |
|
401 if (iState == EOperatorOnlyResult) |
|
402 HandleResultL(); |
|
403 |
|
394 break; |
404 break; |
395 } |
405 } |
396 case ECalcCmdMemorySave: |
406 case ECalcCmdMemorySave: |
397 { |
407 { |
398 HandleMemorySaveL(); |
408 HandleMemorySaveL(); |
437 HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), AppUi()->AppHelpContextL()); |
447 HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), AppUi()->AppHelpContextL()); |
438 } |
448 } |
439 break; |
449 break; |
440 } |
450 } |
441 case EAknSoftkeySelect: |
451 case EAknSoftkeySelect: |
442 { |
452 { |
443 iContainer->HandleMiddleSoftKey(); |
453 iContainer->HandleMiddleSoftKey(); |
444 break; |
454 break; |
445 } |
455 } |
446 |
456 |
447 //Below cases are possible only for Touch UI Layouts |
457 //Below cases are possible only for Touch UI Layouts |
448 case ECalcCmdOne: |
458 case ECalcCmdOne: |
449 { |
459 { |
450 iContainer->SetOperatorFromTouchL(1); |
460 iContainer->SetOperatorFromTouchL(1); |
451 } |
461 } |
512 break; |
522 break; |
513 |
523 |
514 /****** If none of the cases handle the Aiw Help then it will come to the default case ****/ |
524 /****** If none of the cases handle the Aiw Help then it will come to the default case ****/ |
515 default: |
525 default: |
516 { |
526 { |
517 CArrayFix<TCoeHelpContext>* buf = AppUi()->AppHelpContextL(); |
527 CArrayFix<TCoeHelpContext>* buf = AppUi()->AppHelpContextL(); |
518 TCoeHelpContext& helpContext = buf->At(0); |
528 TCoeHelpContext& helpContext = buf->At(0); |
519 TAiwVariant uidVariant; |
529 TAiwVariant uidVariant; |
520 TAiwVariant contextVariant; |
530 TAiwVariant contextVariant; |
521 uidVariant.Set(helpContext.iMajor); |
531 uidVariant.Set(helpContext.iMajor); |
522 TAiwGenericParam uidParam(EGenericParamHelpItem, uidVariant); contextVariant.Set(helpContext.iContext); |
532 TAiwGenericParam uidParam(EGenericParamHelpItem, uidVariant); contextVariant.Set(helpContext.iContext); |
523 contextVariant.Set(helpContext.iContext); |
533 contextVariant.Set(helpContext.iContext); |
524 TAiwGenericParam contextParam(EGenericParamHelpItem, contextVariant); |
534 TAiwGenericParam contextParam(EGenericParamHelpItem, contextVariant); |
525 CAiwGenericParamList* list = CAiwGenericParamList::NewLC(); |
535 CAiwGenericParamList* list = CAiwGenericParamList::NewLC(); |
526 list->AppendL(uidParam); |
536 list->AppendL(uidParam); |
527 list->AppendL(contextParam); |
537 list->AppendL(contextParam); |
528 iServiceHandler->ExecuteMenuCmdL(aCommand,*list,iServiceHandler->OutParamListL()); |
538 iServiceHandler->ExecuteMenuCmdL(aCommand,*list,iServiceHandler->OutParamListL()); |
529 CleanupStack::PopAndDestroy(list); |
539 CleanupStack::PopAndDestroy(list); |
530 delete buf; |
540 delete buf; |
531 buf= NULL; |
541 buf= NULL; |
532 break; |
542 break; |
533 } |
543 } |
534 } |
544 } |
535 } |
545 } |
536 |
546 |
554 void CCalcView::CreateContainerL() |
564 void CCalcView::CreateContainerL() |
555 { |
565 { |
556 iContainer = CCalcContainer::NewL(this); |
566 iContainer = CCalcContainer::NewL(this); |
557 |
567 |
558 iContainer->SetMopParent(this); |
568 iContainer->SetMopParent(this); |
559 |
569 |
560 TRect mainPaneRect ; |
570 TRect mainPaneRect ; |
561 TRect statusPaneRect; |
571 TRect statusPaneRect; |
562 |
572 |
563 if (Layout_Meta_Data::IsLandscapeOrientation()) |
573 if (Layout_Meta_Data::IsLandscapeOrientation()) |
564 |
574 |
565 { |
575 { |
566 |
576 |
567 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,mainPaneRect); |
577 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,mainPaneRect); |
568 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStatusPane,statusPaneRect); |
578 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStatusPane,statusPaneRect); |
569 mainPaneRect.iTl= statusPaneRect.iTl; |
579 mainPaneRect.iTl= statusPaneRect.iTl; |
570 |
580 |
571 } |
581 } |
572 |
582 |
573 else |
583 else |
574 |
584 |
575 { |
585 { |
576 |
586 |
577 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,mainPaneRect); |
587 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,mainPaneRect); |
578 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStatusPane,statusPaneRect); |
588 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStatusPane,statusPaneRect); |
579 |
589 |
580 mainPaneRect.iTl= statusPaneRect.iTl; |
590 mainPaneRect.iTl= statusPaneRect.iTl; |
581 |
591 |
582 } |
592 } |
583 |
593 |
584 |
594 |
585 iContainer->SetRect(mainPaneRect); |
595 iContainer->SetRect(mainPaneRect); |
586 iEditorSubPane = iContainer->EditorPane(); |
596 iEditorSubPane = iContainer->EditorPane(); |
587 iOutputSheet = iContainer->OutputSheet(); |
597 iOutputSheet = iContainer->OutputSheet(); |
588 } |
598 } |
589 |
599 |
590 |
600 |
598 { |
608 { |
599 if (!HandleEqualSubRoutineL()) |
609 if (!HandleEqualSubRoutineL()) |
600 { |
610 { |
601 iEditorSubPane->DrawNow(); |
611 iEditorSubPane->DrawNow(); |
602 UpdateState(EEqual); |
612 UpdateState(EEqual); |
603 iContainer->SetChangeSignEnableL(); |
613 |
604 iContainer->SetSqrtEnableL(); |
614 iContainer->SetSqrtEnableL(); |
605 iContainer->ShowPercentButton(EFalse); |
615 iContainer->ShowPercentButton(EFalse); |
606 iContainer->SetClearKeyEnable(); |
616 iContainer->SetClearKeyEnable(); |
607 } |
617 } |
608 } |
618 } |
609 |
619 |
642 iEditorSubPane->EditLine().CheckZeroL() ) |
652 iEditorSubPane->EditLine().CheckZeroL() ) |
643 { |
653 { |
644 UpdateState(EAllClear); |
654 UpdateState(EAllClear); |
645 } |
655 } |
646 iContainer->SetChangeSignEnableL(); |
656 iContainer->SetChangeSignEnableL(); |
647 iContainer->SetSqrtEnableL(); |
657 iContainer->SetSqrtEnableL(); |
648 iContainer->SetClearKeyEnable(); |
658 iContainer->SetClearKeyEnable(); |
649 |
659 |
650 //highlighting the sign "%". |
660 //highlighting the sign "%". |
651 if ( iState == EOperandAndOperatorAndOperand ) |
661 if ( iState == EOperandAndOperatorAndOperand ) |
652 { |
662 { |
688 } |
698 } |
689 iCalcDocument->MemorySaveL(iEditorSubPane->EditorNumber()); |
699 iCalcDocument->MemorySaveL(iEditorSubPane->EditorNumber()); |
690 iEditorSubPane->DrawNow(); |
700 iEditorSubPane->DrawNow(); |
691 UpdateState(kindOfInput); |
701 UpdateState(kindOfInput); |
692 iContainer->SetChangeSignEnableL(); |
702 iContainer->SetChangeSignEnableL(); |
693 iContainer->SetSqrtEnableL(); |
703 iContainer->SetSqrtEnableL(); |
694 } |
704 } |
695 |
705 |
696 // --------------------------------------------------------- |
706 // --------------------------------------------------------- |
697 // CCalcView::HandleMemoryRecallL |
707 // CCalcView::HandleMemoryRecallL |
698 // Handle MemoryRecall command |
708 // Handle MemoryRecall command |
799 TCalcEditLine editLine(iEditorSubPane->EditLine()); |
809 TCalcEditLine editLine(iEditorSubPane->EditLine()); |
800 TReal64 editorNumber(iEditorSubPane->EditorNumber()); |
810 TReal64 editorNumber(iEditorSubPane->EditorNumber()); |
801 TReal64 result(editorNumber); |
811 TReal64 result(editorNumber); |
802 |
812 |
803 this->iLastResultSetected = EFalse; |
813 this->iLastResultSetected = EFalse; |
804 // User has pressed % |
814 // User has pressed % |
805 if (aOperator == TCalcEditLine::ECalcPercent) |
815 if (aOperator == TCalcEditLine::ECalcPercent) |
806 { |
816 { |
807 if (iState == EOperandAndOperatorAndOperand) |
817 if (iState == EOperandAndOperatorAndOperand) |
808 { |
818 { |
809 editLine.TrimZeroL(); |
819 editLine.TrimZeroL(); |
810 // Save the previous operator |
820 // Save the previous operator |
811 TCalcEditLine::TCalcOperatorType previousOperator = editLine.Operator(); |
821 TCalcEditLine::TCalcOperatorType previousOperator = editLine.Operator(); |
812 // Set the operator to percent |
822 // Set the operator to percent |
813 editLine.SetOperator(TCalcEditLine::ECalcPercent); |
823 editLine.SetOperator(TCalcEditLine::ECalcPercent); |
814 |
824 |
815 |
825 |
816 // Calculate |
826 // Calculate |
817 TRAPD(errorCode3, |
827 TRAPD(errorCode3, |
818 result = iCalcDocument->CalculateAndModifyHistoryL( |
828 result = iCalcDocument->CalculateAndModifyHistoryL( |
819 editorNumber, editLine, previousOperator)); |
829 editorNumber, editLine, previousOperator)); |
820 |
830 |
821 if (errorCode3) |
831 if (errorCode3) |
822 { |
832 { |
823 ErrorMsgL(errorCode3); |
833 iContainer->SetErrorCode(errorCode3); |
824 return; |
834 return; |
825 } |
835 } |
826 |
836 |
827 iOutputSheet->ScrollToBottomL(); |
837 iOutputSheet->ScrollToBottomL(); |
828 // Show the correct operand in the output sheet |
838 // Show the correct operand in the output sheet |
829 aOperator = previousOperator; |
839 aOperator = previousOperator; |
830 // Set the state to EOperatorResult so that the HandleResult knows what to do |
840 // Set the state to EOperatorResult so that the HandleResult knows what to do |
831 UpdateState(EOperatorResult); |
841 UpdateState(EOperatorResult); |
832 } |
842 } |
833 } |
843 } |
834 |
844 |
835 // User has pressed sqrt |
845 // User has pressed sqrt |
836 else if (aOperator == TCalcEditLine::ECalcSqrt) |
846 else if (aOperator == TCalcEditLine::ECalcSqrt) |
837 { |
847 { |
838 // We are in a middle of calculation chain |
848 // We are in a middle of calculation chain |
839 if (iState == EOperandAndOperatorAndOperand) |
849 if (iState == EOperandAndOperatorAndOperand) |
840 { |
850 { |
841 editLine.TrimZeroL(); |
851 editLine.TrimZeroL(); |
842 // Save the previous operator |
852 // Save the previous operator |
843 TCalcEditLine::TCalcOperatorType previousOperator = editLine.Operator(); |
853 TCalcEditLine::TCalcOperatorType previousOperator = editLine.Operator(); |
844 // Set the operator to sqrt |
854 // Set the operator to sqrt |
845 editLine.SetOperator(TCalcEditLine::ECalcSqrt); |
855 editLine.SetOperator(TCalcEditLine::ECalcSqrt); |
846 |
856 |
847 // First calculate the sqrt |
857 // First calculate the sqrt |
848 TRAPD(errorCode, |
858 TRAPD(errorCode, |
849 result = iCalcDocument->CalculateAndNoHistoryL( |
859 result = iCalcDocument->CalculateAndNoHistoryL( |
850 editorNumber, editLine)); |
860 editorNumber, editLine)); |
851 |
861 |
852 if (errorCode) |
862 if (errorCode) |
853 { |
863 { |
854 ErrorMsgL(errorCode); |
864 iContainer->SetErrorCode(errorCode); |
855 return; |
865 return; |
856 } |
866 } |
857 |
867 |
858 // Set the operator to previous one |
868 // Set the operator to previous one |
859 editLine.SetOperator(previousOperator); |
869 editLine.SetOperator(previousOperator); |
860 // Result goes to the outputsheet |
870 // Result goes to the outputsheet |
861 editLine.SetNumber(result); |
871 editLine.SetNumber(result); |
862 |
872 |
863 // Calculate again |
873 // Calculate again |
864 TRAPD(errorCode2, |
874 TRAPD(errorCode2, |
865 result = iCalcDocument->CalculateAndAddHistoryL( |
875 result = iCalcDocument->CalculateAndAddHistoryL( |
866 result, editLine)); |
876 result, editLine)); |
867 |
877 |
868 if (errorCode2) |
878 if (errorCode2) |
869 { |
879 { |
870 ErrorMsgL(errorCode2); |
880 iContainer->SetErrorCode(errorCode2); |
871 return; |
881 return; |
872 } |
882 } |
873 // Set this so that we will display correct operator in the output sheet |
883 // Set this so that we will display correct operator in the output sheet |
874 aOperator = previousOperator; |
884 aOperator = previousOperator; |
875 iOutputSheet->ScrollToBottomL(); |
885 iOutputSheet->ScrollToBottomL(); |
876 UpdateState(EOperator); |
886 UpdateState(EOperator); |
877 // Dimm the square root and percent |
887 // Dimm the square root and percent |
878 iContainer->ShowSqrtButton(EFalse); |
888 iContainer->ShowSqrtButton(EFalse); |
879 iContainer->ShowPercentButton(EFalse); |
889 iContainer->ShowPercentButton(EFalse); |
880 } |
890 } |
881 // Only operand and sqrt |
891 // Only operand and sqrt |
882 else |
892 else |
883 { |
893 { |
884 editLine.SetOperator(aOperator); |
894 editLine.SetOperator(aOperator); |
885 |
895 |
886 // Trap harness, because the CalculateAndHistoryL leaves in case of negative operand |
896 // Trap harness, because the CalculateAndHistoryL leaves in case of negative operand |
887 TRAPD(errorCode, |
897 TRAPD(errorCode, |
888 result = iCalcDocument->CalculateAndAddHistoryL( |
898 result = iCalcDocument->CalculateAndAddHistoryL( |
889 editorNumber, editLine)); |
899 editorNumber, editLine)); |
890 |
900 |
891 if (errorCode) |
901 if (errorCode) |
892 { |
902 { |
893 ErrorMsgL(errorCode); |
903 iContainer->SetErrorCode(errorCode); |
894 return; |
904 return; |
895 } |
905 } |
896 |
906 |
897 iOutputSheet->ScrollToBottomL(); |
907 iOutputSheet->ScrollToBottomL(); |
898 //Set the state to EOperatorResult so that we know to call HandleResult later |
908 //Set the state to EOperatorResult so that we know to call HandleResult later |
899 UpdateState(EOperatorResult); |
909 UpdateState(EOperatorResult); |
900 } |
910 } |
901 } |
911 } |
902 // Current state is state4 and previous input is MS, |
912 // Current state is state4 and previous input is MS, |
903 // provisional result is get and show this the editor. |
913 // provisional result is get and show this the editor. |
904 // And a line is not added to OutputSheet because a line |
914 // And a line is not added to OutputSheet because a line |
905 // is already added. |
915 // is already added. |
906 |
916 |
907 else if (iState == ESelectResult) |
917 else if (iState == ESelectResult) |
908 { |
918 { |
909 iCalcDocument->AddEmptyLine(); |
919 iCalcDocument->AddEmptyLine(); |
910 editLine.SetOperator(TCalcEditLine::ECalcOperatorNone); |
920 editLine.SetOperator(TCalcEditLine::ECalcOperatorNone); |
911 // Because the state is "User has selected result", |
921 // Because the state is "User has selected result", |
912 // this function does not occur leave. |
922 // this function does not occur leave. |
913 result = iCalcDocument->CalculateAndAddHistoryL( |
923 result = iCalcDocument->CalculateAndAddHistoryL( |
914 editorNumber, editLine); |
924 editorNumber, editLine); |
915 iOutputSheet->ScrollToBottomL(); |
925 iOutputSheet->ScrollToBottomL(); |
916 UpdateState(EOperator); |
926 UpdateState(EOperator); |
917 iContainer->SetSqrtEnableL(); |
927 iContainer->SetSqrtEnableL(); |
918 } |
928 } |
919 |
929 |
920 // If a input is a operator and state is updated, |
930 // If a input is a operator and state is updated, |
921 // calculate and update history. |
931 // calculate and update history. |
922 else if (iState != EOperandAndOperator) |
932 else if (iState != EOperandAndOperator) |
923 { |
933 { |
924 editLine.TrimZeroL(); |
934 editLine.TrimZeroL(); |
925 |
935 |
926 // If the number in the EditLine is not a operand |
936 // If the number in the EditLine is not a operand |
927 // we need to dim square root and percent buttons |
937 // we need to dim square root and percent buttons |
928 if (iState == EOperandAndOperatorAndOperand) |
938 if (iState == EOperandAndOperatorAndOperand) |
929 { |
939 { |
930 iContainer->ShowSqrtButton(EFalse); |
940 iContainer->ShowSqrtButton(EFalse); |
931 iContainer->ShowPercentButton(EFalse); |
941 iContainer->ShowPercentButton(EFalse); |
932 } |
942 } |
933 // Calculate by user's input |
943 // Calculate by user's input |
934 TRAPD(errorCode, |
944 TRAPD(errorCode, |
935 result = iCalcDocument->CalculateAndAddHistoryL( |
945 result = iCalcDocument->CalculateAndAddHistoryL( |
936 editorNumber, editLine)); |
946 editorNumber, editLine)); |
937 |
947 |
938 if (errorCode) |
948 if (errorCode) |
939 { |
949 { |
940 ErrorMsgL(errorCode); |
950 iContainer->SetErrorCode(errorCode); |
941 return; |
951 return; |
942 } |
952 } |
943 iOutputSheet->ScrollToBottomL(); |
953 iOutputSheet->ScrollToBottomL(); |
944 UpdateState(EOperator); |
954 UpdateState(EOperator); |
945 } |
955 } |
946 |
956 |
947 iEditorSubPane->SetEditorNumber(result); |
957 iEditorSubPane->SetEditorNumber(result); |
948 iEditorSubPane->SetOperator(aOperator); |
958 iEditorSubPane->SetOperator(aOperator); |
949 |
959 |
950 if ( aOperator != TCalcEditLine::ECalcSqrt ) |
960 if ( aOperator != TCalcEditLine::ECalcSqrt ) |
951 { |
961 { |
952 iEditorSubPane->DrawNow(); |
962 iEditorSubPane->DrawNow(); |
953 } |
963 } |
954 iContainer->ScrollArrowUpdate(); |
964 iContainer->ScrollArrowUpdate(); |
955 iContainer->SetChangeSignEnableL(); |
965 |
956 iContainer->SetClearKeyEnable(); |
966 iContainer->SetClearKeyEnable(); |
957 if (aOperator == TCalcEditLine::ECalcAdd ||aOperator == TCalcEditLine::ECalcSubtract || |
967 if (aOperator == TCalcEditLine::ECalcAdd ||aOperator == TCalcEditLine::ECalcSubtract || |
958 aOperator == TCalcEditLine::ECalcMultiply ||aOperator == TCalcEditLine::ECalcDivide ) |
968 aOperator == TCalcEditLine::ECalcMultiply ||aOperator == TCalcEditLine::ECalcDivide ) |
959 { |
969 { |
960 iContainer->SetChangeSignDisable(); |
970 iContainer->SetChangeSignDisable(); |
961 } |
971 } |
962 |
972 |
963 } |
973 } |
964 |
974 |
965 |
975 |
966 // --------------------------------------------------------- |
976 // --------------------------------------------------------- |
967 // CCalcView::HandleEqualSubRoutineL |
977 // CCalcView::HandleEqualSubRoutineL |
976 TInt calculationError(KErrNone); |
986 TInt calculationError(KErrNone); |
977 TReal64 result(0); |
987 TReal64 result(0); |
978 |
988 |
979 if (iState == EOperandAndOperator || iState == EOperatorOnlyResult) |
989 if (iState == EOperandAndOperator || iState == EOperatorOnlyResult) |
980 { |
990 { |
981 // User has selected equal or operand and sqrt, or percent |
991 // User has selected equal or operand and sqrt, or percent |
982 result = iCalcDocument->ProvisionalResult(); |
992 result = iCalcDocument->ProvisionalResult(); |
983 } |
993 } |
984 else |
994 else |
985 { |
995 { |
986 editLine.TrimZeroL(); |
996 editLine.TrimZeroL(); |
987 // We are calculating the intermediate result. |
997 // We are calculating the intermediate result. |
988 // So we need to dim the sqrt and percent buttons. |
998 // So we need to dim the sqrt and percent buttons. |
989 iContainer->ShowSqrtButton(EFalse); |
999 iContainer->ShowSqrtButton(EFalse); |
990 iContainer->ShowPercentButton(EFalse); |
1000 iContainer->ShowPercentButton(EFalse); |
991 |
1001 |
992 if (iState == ESelectResult) |
1002 if (iState == ESelectResult) |
993 { |
1003 { |
994 iCalcDocument->AddEmptyLine(); |
1004 iCalcDocument->AddEmptyLine(); |
995 editLine.SetOperator(TCalcEditLine::ECalcOperatorNone); |
1005 editLine.SetOperator(TCalcEditLine::ECalcOperatorNone); |
1001 |
1011 |
1002 // If overflow or division by zero occurs, |
1012 // If overflow or division by zero occurs, |
1003 // error message is displayed. |
1013 // error message is displayed. |
1004 if (calculationError) |
1014 if (calculationError) |
1005 { |
1015 { |
1006 ErrorMsgL(calculationError); |
1016 iContainer->SetErrorCode(calculationError); |
1007 |
|
1008 } |
1017 } |
1009 else |
1018 else |
1010 { |
1019 { |
1011 iCalcDocument->AddEqualLineAndUpdateLastResultL(); |
1020 iCalcDocument->AddEqualLineAndUpdateLastResultL(); |
1012 iEditorSubPane->SetEditorNumber(result); |
1021 iEditorSubPane->SetEditorNumber(result); |
1071 (TInt aResourceId, |
1080 (TInt aResourceId, |
1072 CEikMenuPane* aMenuPane) |
1081 CEikMenuPane* aMenuPane) |
1073 { |
1082 { |
1074 if(iServiceHandler->HandleSubmenuL(*aMenuPane)) |
1083 if(iServiceHandler->HandleSubmenuL(*aMenuPane)) |
1075 { |
1084 { |
1076 return; |
1085 return; |
1077 } |
1086 } |
1078 switch (aResourceId) |
1087 switch (aResourceId) |
1079 { |
1088 { |
1080 case (R_CALC_POPUPMENU): |
1089 case (R_CALC_POPUPMENU): |
1081 { |
1090 { |
1082 |
1091 |
1083 DynInitMainMenuPane(aMenuPane); |
1092 DynInitMainMenuPane(aMenuPane); |
1084 |
1093 |
1085 /***** Get the context of the Help topic from here *****/ |
1094 /***** Get the context of the Help topic from here *****/ |
1086 CArrayFix<TCoeHelpContext>* buf= AppUi()->AppHelpContextL(); |
1095 CArrayFix<TCoeHelpContext>* buf= AppUi()->AppHelpContextL(); |
1087 TInt i= buf->Count(); |
1096 TInt i= buf->Count(); |
1088 if(i!=0) |
1097 if(i!=0) |
1089 { |
1098 { |
1090 /***** Check whether our flag is defined or not *****/ |
1099 /***** Check whether our flag is defined or not *****/ |
1091 #ifdef RD_HELP_AIW_INTEGRATION |
1100 #ifdef RD_HELP_AIW_INTEGRATION |
1092 |
1101 |
1093 /***** Call the AiwProvider's AddItemsL to attach the mnu items********/ |
1102 /***** Call the AiwProvider's AddItemsL to attach the mnu items********/ |
1094 |
1103 |
1095 iServiceHandler->InitializeMenuPaneL(*aMenuPane,aResourceId, |
1104 iServiceHandler->InitializeMenuPaneL(*aMenuPane,aResourceId, |
1096 ECmdLast,iServiceHandler->InParamListL()); |
1105 ECmdLast,iServiceHandler->InParamListL()); |
1097 /**** Set the old embedded help as dimmed one ****/ |
1106 /**** Set the old embedded help as dimmed one ****/ |
1098 aMenuPane->SetItemDimmed(ECalcCmdHelp, ETrue); |
1107 aMenuPane->SetItemDimmed(ECalcCmdHelp, ETrue); |
1099 #else |
1108 #else |
1100 /**** Set the Aiw Help as dimmed one as our feature flag is not defined ****/ |
1109 /**** Set the Aiw Help as dimmed one as our feature flag is not defined ****/ |
1101 aMenuPane->SetItemDimmed(ECmdAiwPlaceHolder,ETrue); |
1110 aMenuPane->SetItemDimmed(ECmdAiwPlaceHolder,ETrue); |
1102 #endif |
1111 #endif |
1103 } |
1112 } |
1104 else |
1113 else |
1105 { |
1114 { |
1106 /**** If the Feature flag is not defined dont show the Aiw Help ****/ |
1115 /**** If the Feature flag is not defined dont show the Aiw Help ****/ |
1107 aMenuPane->SetItemDimmed(ECmdAiwPlaceHolder,ETrue); |
1116 aMenuPane->SetItemDimmed(ECmdAiwPlaceHolder,ETrue); |
1108 } |
1117 } |
1109 |
1118 |
1110 /******* Delete the buffer and make it to NULL *****/ |
1119 /******* Delete the buffer and make it to NULL *****/ |
1111 delete buf; |
1120 delete buf; |
1112 buf = NULL; |
1121 buf = NULL; |
1113 if (!FeatureManager::FeatureSupported( KFeatureIdHelp )) |
1122 if (!FeatureManager::FeatureSupported( KFeatureIdHelp )) |
1114 { |
1123 { |
1115 aMenuPane->DeleteMenuItem(ECalcCmdHelp); |
1124 aMenuPane->DeleteMenuItem(ECalcCmdHelp); |
1116 aMenuPane->DeleteMenuItem(ECmdAiwPlaceHolder); |
1125 aMenuPane->DeleteMenuItem(ECmdAiwPlaceHolder); |
1117 } |
1126 } |
1118 break; |
1127 break; |
1119 } |
1128 } |
1120 |
1129 |
1121 case (R_CALC_MEMORY_MENU): |
1130 case (R_CALC_MEMORY_MENU): |
1122 { |
1131 { |
1133 // CCalcView::HandleForegroundEventL |
1142 // CCalcView::HandleForegroundEventL |
1134 //Refresh and draw display ,paper and function map Icons. |
1143 //Refresh and draw display ,paper and function map Icons. |
1135 // --------------------------------------------------------- |
1144 // --------------------------------------------------------- |
1136 // |
1145 // |
1137 void CCalcView::HandleForegroundEventL(TBool aForeground) |
1146 void CCalcView::HandleForegroundEventL(TBool aForeground) |
1138 { |
1147 { |
1139 if( (aForeground) && (STATIC_CAST(CCalcAppUi*, AppUi())->IsSkinChanged()) ) |
1148 if( (aForeground) && (STATIC_CAST(CCalcAppUi*, AppUi())->IsSkinChanged()) ) |
1140 { |
1149 { |
1141 iEditorSubPane->RefreshDisplaySideLBitmap(); |
1150 iEditorSubPane->RefreshDisplaySideLBitmap(); |
1142 iEditorSubPane->RefreshDisplayCenterBitmap(); |
1151 iEditorSubPane->RefreshDisplayCenterBitmap(); |
1143 iEditorSubPane->RefreshDisplaySideRBitmap(); |
1152 iEditorSubPane->RefreshDisplaySideRBitmap(); |
1144 |
1153 |
1145 iEditorSubPane->DrawNow(); |
1154 iEditorSubPane->DrawNow(); |
1146 |
1155 |
1147 iOutputSheet->RefreshPaperBitmap(); |
1156 iOutputSheet->RefreshPaperBitmap(); |
1148 iOutputSheet->RefreshScalablePaperBitmap(); |
1157 iOutputSheet->RefreshScalablePaperBitmap(); |
1149 #ifdef __SCALABLE_ICONS |
1158 #ifdef __SCALABLE_ICONS |
1150 iOutputSheet->RefreshResultsLineBitmap(); |
1159 iOutputSheet->RefreshResultsLineBitmap(); |
1151 #endif |
1160 #endif |
1152 iOutputSheet->DrawNow(); |
1161 iOutputSheet->DrawNow(); |
1153 |
1162 |
1154 iContainer->FunctionSubPane()->RefreshButtonIcons(); |
1163 iContainer->FunctionSubPane()->RefreshButtonIcons(); |
1155 for(TInt i =0; i< 10; i++) |
1164 for(TInt i =0; i< 10; i++) |
1156 { |
1165 { |
1157 iContainer->FunctionSubPane()->GetButtonBitmapControl(i)->DrawNow(); |
1166 iContainer->FunctionSubPane()->GetButtonBitmapControl(i)->DrawNow(); |
1158 } |
1167 } |
1159 } |
1168 } |
1160 else |
1169 else |
1161 { |
1170 { |
1162 CAknView::HandleForegroundEventL(aForeground); |
1171 CAknView::HandleForegroundEventL(aForeground); |
1163 } |
1172 } |
1164 } |
1173 } |
1165 |
1174 |
1166 |
1175 |
1167 // End of File |
1176 // End of File |