extras/calcsoft/src/CalcEdit.cpp
changeset 0 3ee3dfdd8d69
child 12 ddecbce3dc1f
equal deleted inserted replaced
-1:000000000000 0:3ee3dfdd8d69
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0""
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Source file of "editor sub-pane", CCalcEditorSubPane class 
       
    15 *                which derived from CCoeControl class. 
       
    16 *                Role of this class is to draw editor.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <AknUtils.h>
       
    23 #include <Calcsoft.rsg>
       
    24 #include <avkon.hrh>
       
    25 #include <aknsoundsystem.h>
       
    26 #include    <applayout.cdl.h>
       
    27 #include <AknIconUtils.h>
       
    28 #include    <AknsDrawUtils.h>
       
    29 #include  <aknlayoutscalable_avkon.cdl.h>  
       
    30 #include <AknLayoutScalable_Avkon.cdl.common.h>
       
    31 #include <AknLayout2ScalableDef.h>
       
    32 #include <AvkonInternalCRKeys.h>
       
    33 #include    <aknlayoutscalable_apps.cdl.h>
       
    34 
       
    35 #include "CalcAppUi.h"
       
    36 #include "CalcCont.h"
       
    37 #include "CalcDoc.h"
       
    38 #include "CalcEdit.h"
       
    39 #include "CalcEnv.h"
       
    40 #include "CalcDrawingConst.laf" // for drawing information.
       
    41 #include "fbs.h"
       
    42 #include <PtiKeyMappings.h>
       
    43 
       
    44 #include <PtiDefs.h>
       
    45 #include <PtiEngine.h>
       
    46 #include <AknFepInternalCRKeys.h>
       
    47 #include <layoutmetadata.cdl.h>
       
    48 
       
    49 //  LOCAL CONSTANTS AND MACROS  
       
    50 
       
    51 // If const TChar is used, complie error occurs in THUMB build.
       
    52 // To avoid this, #define is used.
       
    53 #define KCalcHashBtn '#' 
       
    54 #define KZero 0.0 
       
    55 
       
    56 // ================= MEMBER FUNCTIONS =======================
       
    57 
       
    58 // Two-phased constructor.
       
    59 CCalcEditorSubPane* CCalcEditorSubPane::NewL(
       
    60                     CCalcContainer* aContainer)
       
    61     {
       
    62     CCalcEditorSubPane* self = new (ELeave) CCalcEditorSubPane();
       
    63     CleanupStack::PushL(self);
       
    64     self->ConstructL(aContainer);
       
    65     CleanupStack::Pop(self); 
       
    66     return self;
       
    67     }
       
    68 
       
    69 
       
    70 
       
    71 
       
    72 // Destructor
       
    73 CCalcEditorSubPane::~CCalcEditorSubPane()
       
    74     {
       
    75     iQwertyModeStatusProperty.Close();
       
    76     delete iEngine;
       
    77     delete iCRKey;
       
    78     }
       
    79 
       
    80 
       
    81 // ---------------------------------------------------------
       
    82 // CCalcEditorSubPane::EditLine
       
    83 // Return reference of editor line which has been edited by user.
       
    84 // (other items were commented in a header).
       
    85 // ---------------------------------------------------------
       
    86 //
       
    87 const TCalcEditLine& CCalcEditorSubPane::EditLine() const
       
    88     {
       
    89     return iEditLine;
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------
       
    93 // CCalcEditorSubPane::SetEditorNumber
       
    94 // Set TReal64 type editor number.
       
    95 // (other items were commented in a header). 
       
    96 // ---------------------------------------------------------
       
    97 //
       
    98 void CCalcEditorSubPane::SetOperator(
       
    99      TCalcEditLine::TCalcOperatorType aType)
       
   100     {
       
   101     iEditLine.SetOperator(aType);
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------
       
   105 // CCalcEditorSubPane::SetEditorNumber
       
   106 // Set TReal64 type editor number.
       
   107 // (other items were commented in a header). 
       
   108 // ---------------------------------------------------------
       
   109 //
       
   110 void CCalcEditorSubPane::SetEditorNumber(TReal64 aNewNumber)
       
   111     {
       
   112     iEditorNumber = aNewNumber;
       
   113     iEditLine.SetNumber(aNewNumber);
       
   114     }
       
   115         
       
   116 // ---------------------------------------------------------
       
   117 // CCalcEditorSubPane::EditorNumber
       
   118 // Return TReal64 type editor number
       
   119 // (other items were commented in a header). 
       
   120 // ---------------------------------------------------------
       
   121 //
       
   122 TReal64 CCalcEditorSubPane::EditorNumber() const
       
   123     {
       
   124     return iEditorNumber;
       
   125     }
       
   126 
       
   127 // ---------------------------------------------------------
       
   128 // CCalcEditorSubPane::ResetL
       
   129 // Clear editor.
       
   130 // (other items were commented in a header).
       
   131 // ---------------------------------------------------------
       
   132 //
       
   133 void CCalcEditorSubPane::ResetL()
       
   134     {
       
   135     iEditLine.AllClear();  
       
   136     iEditLine.ClearL();
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------
       
   140 // CCalcEditorSubPane::ClearOperand
       
   141 // Clear operand
       
   142 // (other items were commented in a header).
       
   143 // ---------------------------------------------------------
       
   144 //
       
   145 void CCalcEditorSubPane::ClearOperand()
       
   146     {
       
   147     iEditLine.ClearOperand();  
       
   148     }
       
   149 
       
   150 
       
   151 // ---------------------------------------------------------
       
   152 // CCalcEditorSubPane::ClearLastInput
       
   153 // Clear last input.
       
   154 // (other items were commented in a header).
       
   155 // ---------------------------------------------------------
       
   156 //
       
   157 void CCalcEditorSubPane::ClearLastInputL()
       
   158     {
       
   159     const TPtrC number(iEditLine.NumberString());
       
   160     
       
   161     if (number.Length() == 1 && 
       
   162         iCalcContainer->View()->State() == CCalcView::EOperandOnly)
       
   163         {
       
   164         iCalcContainer->InputClearL();
       
   165         }
       
   166     else
       
   167         {
       
   168         if (iEditLine.CheckZeroL())
       
   169             {
       
   170             iCalcContainer->InputClearL();
       
   171             }
       
   172         else
       
   173             {
       
   174             ClearL();
       
   175             if (iEditLine.CheckZeroL() && 
       
   176                 iCalcContainer->View()->State() == CCalcView::EOperandOnly)
       
   177                 {
       
   178                 iCalcContainer->InputClearL();
       
   179                 }
       
   180             }
       
   181         }
       
   182     }
       
   183 
       
   184 // ---------------------------------------------------------
       
   185 // CCalcEditorSubPane::OfferShortPressClearKeyEventL
       
   186 // Handle short-press-clear-key and CBA-clear-key event.
       
   187 // (other items were commented in a header).
       
   188 // ---------------------------------------------------------
       
   189 //
       
   190 void CCalcEditorSubPane::OfferShortPressClearKeyEventL()
       
   191     {
       
   192     CCalcView* view = iCalcContainer->View();
       
   193     CCalcView::TStateNo state(view->State());
       
   194     CCalcView::TKindOfInput latestInput(view->LatestInput());
       
   195 
       
   196     switch (latestInput)
       
   197         {
       
   198         case (CCalcView::EMemoryRecall):
       
   199         case (CCalcView::EOperator):
       
   200             {
       
   201             if (state == CCalcView::EOperandOnly ||
       
   202                 iEditLine.CheckZeroL())
       
   203                 {
       
   204                 iCalcContainer->InputClearL();
       
   205                 }
       
   206             else 
       
   207                 {
       
   208                 ClearOperand();
       
   209                 }
       
   210             break;
       
   211             }
       
   212         case (CCalcView::EMemorySave):
       
   213             {
       
   214             if (state != CCalcView::EOperandAndOperator ||
       
   215                 iEditLine.CheckZeroL())
       
   216                 {
       
   217                 iCalcContainer->InputClearL();
       
   218                 }
       
   219             else
       
   220                 {
       
   221                 ClearOperand();
       
   222                 }
       
   223             break;
       
   224             }
       
   225         case (CCalcView::EEqual):
       
   226             {
       
   227             iCalcContainer->InputClearL();
       
   228             break;
       
   229             }
       
   230         default:
       
   231             {
       
   232             ClearLastInputL();
       
   233             break;
       
   234             }
       
   235         }
       
   236     }
       
   237 
       
   238 // ---------------------------------------------------------
       
   239 // CCalcEditorSubPane::DoChangeSign
       
   240 // Changing sign.
       
   241 // This is not called when editor number is 0. 
       
   242 // (other items were commented in a header).
       
   243 // ---------------------------------------------------------
       
   244 //
       
   245 void CCalcEditorSubPane::DoChangeSignL(
       
   246      CCalcView::TStateNo aState)
       
   247     {
       
   248     // If current state is other than State1, "+/-" command is ignored.
       
   249     if (aState != CCalcView::EInitialMode)
       
   250         {
       
   251         if (aState == CCalcView::ESelectResult)
       
   252             {
       
   253             // "=" is disappeared from editor.
       
   254             iEditLine.SetOperator(TCalcEditLine::ECalcOperatorNone);  
       
   255             }
       
   256         
       
   257         iEditLine.ChangeSignL();
       
   258         iEditorNumber = iEditorNumber * (-1);
       
   259         DrawNow();
       
   260         }
       
   261     }
       
   262 
       
   263 // ---------------------------------------------------------
       
   264 // CCalcEditorSubPane::DoMemoryRecallOrLastResult
       
   265 // Update editor number to memory or last result.
       
   266 // (other items were commented in a header).
       
   267 // ---------------------------------------------------------
       
   268 //
       
   269 void CCalcEditorSubPane::DoMemoryRecallOrLastResult(
       
   270                     TReal64 aMemoryOrLastResult, 
       
   271                     CCalcView::TStateNo aState)
       
   272     {
       
   273     if (aState == CCalcView::ESelectResult)
       
   274         {
       
   275         // "=" is disappeared from editor.
       
   276         iEditLine.SetOperator(TCalcEditLine::ECalcOperatorNone);
       
   277         }
       
   278     
       
   279     iEditLine.SetNumber(aMemoryOrLastResult);
       
   280     iEditorNumber = aMemoryOrLastResult;
       
   281     DrawNow();
       
   282     }
       
   283 
       
   284 
       
   285 // ---------------------------------------------------------
       
   286 // CCalcEditorSubPane::NotifyChangeDecimal
       
   287 // Call when decimal separator is changed.
       
   288 // (other items were commented in a header).
       
   289 // ---------------------------------------------------------
       
   290 //
       
   291 void CCalcEditorSubPane::NotifyChangeDecimal(TChar aOld, TChar aNew)
       
   292     {
       
   293     iEditLine.ChangeDecimal(aOld, aNew);
       
   294     DrawNow();
       
   295     }
       
   296     
       
   297 // ---------------------------------------------------------
       
   298 // CCalcEditorSubPane::IsQwertyKeypadActive
       
   299 // Called to check qwerty keypad is active or not
       
   300 // (other items were commented in a header).
       
   301 // ---------------------------------------------------------
       
   302 //
       
   303 
       
   304 TInt CCalcEditorSubPane::IsQwertyKeypadActive()
       
   305 	{
       
   306  	TInt value = 0;
       
   307     iQwertyModeStatusProperty.Get(value);
       
   308     return value;
       
   309 	}
       
   310 
       
   311 
       
   312 // ---------------------------------------------------------
       
   313 // CCalcEditorSubPane::OfferKeyEventL
       
   314 // This function is called by CCalcContainer::OfferKeyEventL()
       
   315 // when inputted key is number or "#". 
       
   316 // (other items were commented in a header).
       
   317 // ---------------------------------------------------------
       
   318 //
       
   319 TKeyResponse CCalcEditorSubPane::OfferKeyEventL
       
   320                 ( const TKeyEvent& aKeyEvent,  
       
   321                   TEventCode aType )           
       
   322     {
       
   323 	
       
   324     if (aType != EEventKey)
       
   325         {
       
   326         return EKeyWasNotConsumed;
       
   327         }
       
   328 	TPtiKey keyQwertyValue = (TPtiKey)aKeyEvent.iScanCode;
       
   329     TChar decimal(iCalcAppEnv->DecimalSeparator());
       
   330 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   331     TChar keyCode( aKeyEvent.iCode );
       
   332 #else 
       
   333     TChar keyCode(aKeyEvent.iScanCode);
       
   334 #endif
       
   335     TChar decimalkey(aKeyEvent.iCode);
       
   336     
       
   337     if( iDecimalCounter < KCalcMaxNumberWidth  )
       
   338     {
       
   339     	iAllowedDecimal.Append(decimal);
       
   340     	iDecimalCounter++;	
       
   341     }
       
   342     
       
   343 		if(IsQwertyKeypadActive())
       
   344 		{
       
   345  
       
   346 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   347             if( MapDecimal(aKeyEvent) || MapDecimal(aKeyEvent) ||aKeyEvent.iCode == KCalcHashBtn )
       
   348                 {
       
   349                 keyCode = decimal;
       
   350                 }		    	
       
   351 #else
       
   352 		    if(MapDecimal(keyQwertyValue,EPtiCaseUpper) || MapDecimal(keyQwertyValue,EPtiCaseLower) ||aKeyEvent.iCode == KCalcHashBtn )
       
   353 		      {
       
   354 		      keyCode = decimal;
       
   355 		      }
       
   356 #endif
       
   357                   //}
       
   358 		}
       
   359 	else
       
   360 		{
       
   361 		if (aKeyEvent.iCode == KCalcHashBtn)
       
   362 	        {
       
   363 	        keyCode = decimal;
       
   364 	        }	
       
   365 		}
       
   366     
       
   367     TKeyResponse response(EKeyWasNotConsumed);
       
   368     CCalcView* view = iCalcContainer->View();
       
   369     
       
   370     if (keyCode.IsDigit() || keyCode == decimal)
       
   371         {
       
   372         DrawDeferred();
       
   373         iCalcContainer->ProcessPreinputL();
       
   374         view->iLastResultSetected = EFalse;
       
   375         // Append input to editor space if editor space is not full.
       
   376         TRAPD(errorCode, iEditLine.AppendL(keyCode));
       
   377 
       
   378         //  If editor space is full, error message is shown.
       
   379         if (errorCode)  
       
   380             {
       
   381             CAknKeySoundSystem* soundSystem = 
       
   382                 iCalcAppEnv->AppUi()->KeySounds();
       
   383             if (soundSystem)
       
   384                 {
       
   385                 soundSystem->PlaySound(EAvkonSIDInformationTone);
       
   386                 }
       
   387             }
       
   388         else
       
   389             {
       
   390             if (iEditLine.CheckZeroL() && 
       
   391                 iEditLine.Operator() == TCalcEditLine::ECalcOperatorNone)
       
   392                 {
       
   393                 view->UpdateState(CCalcView::EAllClear);
       
   394                 }
       
   395             else
       
   396                 {
       
   397                 view->UpdateState(CCalcView::EOperand);
       
   398                 }
       
   399             iEditorNumber = iEditLine.NumberL();
       
   400             }
       
   401 		
       
   402 		// Enable ChangeSign and Square root buttons
       
   403 		// if there is no 0 in the editor.
       
   404 		iCalcContainer->SetChangeSignEnableL();
       
   405 		iCalcContainer->SetSqrtEnableL();
       
   406         iCalcContainer->SetClearKeyEnable();
       
   407         
       
   408 		// Enable the Percent button if the calculator
       
   409 		// is in correct state and there is no 0 in the editor.
       
   410 		if ( iCalcContainer->GetState() == CCalcView::EOperandAndOperator || 
       
   411 			 iCalcContainer->GetState() == CCalcView::EOperandAndOperatorAndOperand )
       
   412 			if (keyCode.IsDigit())
       
   413 				iCalcContainer->SetPercentEnableL();
       
   414 		
       
   415 			response = EKeyWasConsumed;
       
   416         }
       
   417     else if (decimalkey == EKeyBackspace)   
       
   418         {view->iLastResultSetected = EFalse;
       
   419         DrawDeferred();
       
   420         //  If Clear-Key is pressed long, number editor and operand
       
   421         // is clear and the state is set initial one.
       
   422         if (aKeyEvent.iRepeats)  
       
   423             {
       
   424             iCalcContainer->InputClearL();
       
   425             }
       
   426         // If Clear-key is pressed short, the latest input is deleted.
       
   427         else   
       
   428             {
       
   429             OfferShortPressClearKeyEventL();
       
   430             }
       
   431         iEditorNumber = iEditLine.NumberL();
       
   432         iCalcContainer->SetChangeSignEnableL();
       
   433 		iCalcContainer->SetSqrtEnableL();
       
   434         iCalcContainer->SetClearKeyEnable();
       
   435         		
       
   436         if ( iCalcContainer->GetState() == CCalcView::EOperandAndOperator || 
       
   437         	 iCalcContainer->GetState() == CCalcView::EOperandAndOperatorAndOperand ||
       
   438         	 iEditorNumber == KZero )
       
   439             iCalcContainer->SetPercentEnableL();
       
   440         response = EKeyWasConsumed;
       
   441         }
       
   442         	
       
   443     return response;
       
   444     }
       
   445 
       
   446 // C++ default constructor can NOT contain any code, that
       
   447 // might leave.
       
   448 //
       
   449 CCalcEditorSubPane::CCalcEditorSubPane()
       
   450     {
       
   451   
       
   452     }
       
   453 
       
   454 // Second-phase constructor
       
   455 void CCalcEditorSubPane::ConstructL
       
   456         (CCalcContainer* aContainer) 
       
   457     {
       
   458     // The state is set initial one.
       
   459     // Number editor is set "0".
       
   460     iEditLine.ClearL();
       
   461     iEditorNumber = 0.0;
       
   462 
       
   463     SetContainerWindowL(*aContainer);
       
   464     
       
   465     iCalcContainer = aContainer;  
       
   466     // Load calc_display bitmap 
       
   467     iCalcAppEnv = CCalcAppEnv::Static();
       
   468     iCalcSideLDisplay = iCalcAppEnv->DisplaySideLBitmap();
       
   469     iCalcCenterDisplay = iCalcAppEnv->DisplayCenterBitmap();
       
   470     iCalcSideRDisplay = iCalcAppEnv->DisplaySideRBitmap();
       
   471     iIsQwertyActive = 0;
       
   472     User::LeaveIfError(iQwertyModeStatusProperty.Attach(KCRUidAvkon, KAknQwertyInputModeActive));
       
   473   
       
   474     // Try to get the English key mappings. If those are not available, use the 
       
   475     // mappings of the current input language. The order is this because all mappings
       
   476     // do not necessarily contain all characters neeeded by the Calculator.
       
   477     iLanguage = ELangEnglish;
       
   478     iEngine = CPtiEngine::NewL(ETrue);
       
   479     iCoreLanguage = static_cast<CPtiCoreLanguage*>(iEngine->GetLanguage( iLanguage ));
       
   480 
       
   481     if( !iCoreLanguage )
       
   482         {
       
   483         iCRKey = CRepository::NewL(KCRUidAknFep);
       
   484         TInt ret = iCRKey->Get(KAknFepInputTxtLang,iLanguage);
       
   485         if( ret!= KErrNone )
       
   486             {
       
   487             //Exit application if server is busy( Error Raised )
       
   488             iAvkonViewAppUi->Exit();
       
   489             }
       
   490             iCoreLanguage = static_cast<CPtiCoreLanguage*>(iEngine->GetLanguage(iLanguage));
       
   491         }
       
   492     
       
   493     RProperty::Get( KCRUidAvkon, KAknKeyBoardLayout, iKeyboardType );
       
   494 
       
   495     if( iCoreLanguage )
       
   496         {
       
   497 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   498         if ( iKeyboardType == EPtiKeyboardHalfQwerty)
       
   499            {
       
   500            iHalfQwertyKeyMappings = static_cast<CPtiHalfQwertyKeyMappings*>(iCoreLanguage->GetHalfQwertyKeymappings());
       
   501            }
       
   502        else
       
   503 #endif
       
   504           {
       
   505           iQwertyKeyMappings = static_cast<CPtiQwertyKeyMappings*>(iCoreLanguage->GetQwertyKeymappings());
       
   506           }
       
   507         }
       
   508     
       
   509 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   510         
       
   511     if ( iKeyboardType == EPtiKeyboardHalfQwerty )
       
   512         { 
       
   513         iEngine->ActivateLanguageL( iLanguage, EPtiEngineHalfQwerty );
       
   514         }
       
   515     else if ( IsQwertyKeypadActive())
       
   516         { 
       
   517         iEngine->ActivateLanguageL( iLanguage, EPtiEngineQwerty );
       
   518         } 
       
   519        
       
   520   //      RProperty::Get( KCRUidAvkon, KAknKeyBoardLayout, iKeyboardType );
       
   521         iEngine->SetKeyboardType( TPtiKeyboardType (iKeyboardType ));
       
   522         
       
   523 #endif
       
   524         
       
   525     // UI language is used to determine the used number format.
       
   526     iUiLanguage = User::Language();
       
   527     iDecimalCounter = 0;
       
   528     }
       
   529     
       
   530 // ---------------------------------------------------------
       
   531 // CCalcEditorSubPane::IsQwertyActive
       
   532 // (other items were commented in a header).
       
   533 // ---------------------------------------------------------
       
   534 //
       
   535 void CCalcEditorSubPane::IsQwertyActive()
       
   536     {
       
   537     iIsQwertyActive = 1;
       
   538     }
       
   539     
       
   540 // ---------------------------------------------------------
       
   541 // CCalcEditorSubPane::IsQwertyNotActive
       
   542 // (other items were commented in a header).
       
   543 // ---------------------------------------------------------
       
   544 //
       
   545 void CCalcEditorSubPane::IsQwertyNotActive()
       
   546     {
       
   547     iIsQwertyActive = 0;
       
   548     } 
       
   549 
       
   550 // ---------------------------------------------------------
       
   551 // CCalcEditorSubPane::ClearL
       
   552 // Clear 1 charactor from editor.
       
   553 // (other items were commented in a header).
       
   554 // ---------------------------------------------------------
       
   555 //
       
   556 void CCalcEditorSubPane::ClearL()
       
   557     {
       
   558     iEditLine.ClearL();
       
   559     }
       
   560 
       
   561 // ---------------------------------------------------------
       
   562 // CCalcEditorSubPane::SizeChanged
       
   563 // Size of control is set. 
       
   564 // (other items were commented in a header).
       
   565 // ---------------------------------------------------------
       
   566 //
       
   567 void CCalcEditorSubPane::SizeChanged()
       
   568     {
       
   569     TRect parentRect(iCalcContainer->Rect());
       
   570     TRect EditorPaneRect(iCalcContainer->EditorPane()->Rect());
       
   571     
       
   572 
       
   573 	if (!(AknLayoutUtils::ScalableLayoutInterfaceAvailable()))
       
   574 		{
       
   575 		iLayoutText[ECalcEditorOperandShadow].LayoutText(
       
   576 			parentRect,AppLayout::Calculator_texts_Line_1(),iCalcAppEnv->NumberShadowFont());
       
   577 		}
       
   578 
       
   579 
       
   580                     
       
   581      	if (AknLayoutUtils::ScalableLayoutInterfaceAvailable())
       
   582 			{
       
   583                         if( iUiLanguage == ELangFarsi || iUiLanguage == ELangUrdu || iUiLanguage == ELangArabic
       
   584                             || iUiLanguage == ELangHindi )
       
   585 				{
       
   586 				TAknTextLineLayout layout1; 
       
   587 			    if( AknLayoutUtils::PenEnabled() )
       
   588     	        {
       
   589     	            layout1	= AknLayoutScalable_Apps:: calc_display_pane_t1(enTouch_enabled).LayoutLine();
       
   590     	        }
       
   591     	        else
       
   592     	        {
       
   593     	            layout1	= AknLayoutScalable_Apps:: calc_display_pane_t1(enTouch_disabled).LayoutLine();    
       
   594     	        }     
       
   595 				// Do this only in A&H etc. variants...
       
   596 				layout1.iFont &= 0xFFFFFFF0; // clear first 4 bits (font category)
       
   597 				layout1.iFont |= 0x00000001; // set first 4 bits to primary font category value (=1)					
       
   598 
       
   599                 // When the pen enable and the current screen is transverse,
       
   600                 // Enlarge the size of parent rect.
       
   601                 if ( AknLayoutUtils::PenEnabled() && Layout_Meta_Data::IsLandscapeOrientation() )
       
   602                     {
       
   603                     TRect enlargeEditorPaneRect;
       
   604                     enlargeEditorPaneRect = EditorPaneRect;
       
   605                     // Enlarging the parent rect, so that the editor could display a long number absolutely.
       
   606                     enlargeEditorPaneRect.iBr.iX += EEnlargeFive;
       
   607                     enlargeEditorPaneRect.iTl.iX -= EEnlargeTwenty;
       
   608                     iLayoutText[ECalcEditorOperand].LayoutText( enlargeEditorPaneRect,
       
   609 					                                 layout1, iCalcAppEnv->NumberFont() );
       
   610                     }
       
   611                 else
       
   612                     {
       
   613 				iLayoutText[ECalcEditorOperand].LayoutText(EditorPaneRect,
       
   614 						layout1,iCalcAppEnv->NumberFont());
       
   615                     }
       
   616 				}
       
   617 			else
       
   618 				{
       
   619 				 if( AknLayoutUtils::PenEnabled() )
       
   620 				 {
       
   621                     // If the current screen is transverse,enlarge the size of parent rect.
       
   622                     if ( Layout_Meta_Data::IsLandscapeOrientation() )
       
   623                         {
       
   624                         TRect enlargeEditorPaneRect;
       
   625                         enlargeEditorPaneRect = EditorPaneRect;
       
   626                         // Enlarging the parent rect, so that the editor could display a long number absolutely.
       
   627                         enlargeEditorPaneRect.iBr.iX += EEnlargeFive;
       
   628                         enlargeEditorPaneRect.iTl.iX -= EEnlargeTwenty;
       
   629                         iLayoutText[ECalcEditorOperand].LayoutText( enlargeEditorPaneRect,
       
   630                              AknLayoutScalable_Apps::calc_display_pane_t1( enTouch_enabled ).LayoutLine(), iCalcAppEnv->NumberFont() );
       
   631                         }
       
   632                     else
       
   633                         {
       
   634 				    iLayoutText[ECalcEditorOperand].LayoutText(EditorPaneRect,
       
   635 					AknLayoutScalable_Apps::calc_display_pane_t1(enTouch_enabled).LayoutLine(),iCalcAppEnv->NumberFont());    
       
   636                         }   
       
   637 				 }
       
   638 				 else
       
   639 				 {
       
   640 				    iLayoutText[ECalcEditorOperand].LayoutText(EditorPaneRect,
       
   641 					AknLayoutScalable_Apps::calc_display_pane_t1(enTouch_disabled).LayoutLine(),iCalcAppEnv->NumberFont());    
       
   642 				 }
       
   643 				}
       
   644 			}
       
   645 		else
       
   646 			{
       
   647        		// Set layout for number
       
   648     		iLayoutText[ECalcEditorOperand].LayoutText(
       
   649             	parentRect,AppLayout::Calculator_texts_Line_2(),iCalcAppEnv->NumberFont());  
       
   650        		}
       
   651 
       
   652 
       
   653 	if (!(AknLayoutUtils::ScalableLayoutInterfaceAvailable()))
       
   654 		{
       
   655 		iLayoutText[ECalcEditorOperatorShadow].LayoutText(
       
   656 			parentRect,AppLayout::Calculator_texts_Line_3(),iCalcAppEnv->OperatorShadowFont());   
       
   657 		}
       
   658 
       
   659 
       
   660      if (AknLayoutUtils::ScalableLayoutInterfaceAvailable())
       
   661 		{
       
   662     	    if( AknLayoutUtils::PenEnabled() )
       
   663     	    {
       
   664     	        iLayoutText[ECalcEditorOperator].LayoutText(EditorPaneRect,
       
   665     			AknLayoutScalable_Apps::calc_display_pane_t2(enTouch_enabled).LayoutLine(),iCalcAppEnv->OperatorFont());
       
   666     	    }
       
   667     	    else
       
   668     	    {
       
   669     	        iLayoutText[ECalcEditorOperator].LayoutText(EditorPaneRect,
       
   670     			AknLayoutScalable_Apps::calc_display_pane_t2(enTouch_disabled).LayoutLine(),iCalcAppEnv->OperatorFont());
       
   671     	    }
       
   672 		}
       
   673 	
       
   674 	else
       
   675        	{
       
   676        		// Set layout for operator
       
   677     	iLayoutText[ECalcEditorOperator].LayoutText(
       
   678                 parentRect,AppLayout::Calculator_texts_Line_4(),iCalcAppEnv->OperatorFont());   
       
   679        	} 
       
   680                         
       
   681     if (AknLayoutUtils::ScalableLayoutInterfaceAvailable())
       
   682 		{
       
   683 		    if( AknLayoutUtils::PenEnabled() )
       
   684 		    {
       
   685 		        iLayoutText[ECalcEditorMemory].LayoutText(EditorPaneRect,
       
   686 				AknLayoutScalable_Apps::calc_display_pane_t3(enTouch_enabled).LayoutLine(),NULL);    
       
   687 		    }
       
   688 		    else
       
   689 		    {
       
   690 		        iLayoutText[ECalcEditorMemory].LayoutText(EditorPaneRect,
       
   691 				AknLayoutScalable_Apps::calc_display_pane_t3(enTouch_disabled).LayoutLine(),NULL);
       
   692 		    }
       
   693 		}
       
   694 	else
       
   695 		{
       
   696 		//	Set layout for memory indicator shadow
       
   697 		iLayoutText[ECalcEditorMemoryShadow].LayoutText(
       
   698 			parentRect,AppLayout::Calculator_texts_Line_5(),NULL);
       
   699 		// Set layout for memory indicator
       
   700 		iLayoutText[ECalcEditorMemory].LayoutText(
       
   701 			parentRect,AppLayout::Calculator_texts_Line_6(),NULL); 
       
   702 		}
       
   703 	
       
   704 	if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
   705 		{               
       
   706 		TAknWindowLineLayout layoutOfDisplay;
       
   707 		if( AknLayoutUtils::PenEnabled() )
       
   708 		{
       
   709 		    layoutOfDisplay =  AknLayoutScalable_Apps:: bg_calc_display_pane(enTouch_enabled).LayoutLine();    
       
   710 		}
       
   711 		else
       
   712 		{
       
   713 		    layoutOfDisplay =  AknLayoutScalable_Apps:: bg_calc_display_pane(enTouch_enabled).LayoutLine();    
       
   714 		}
       
   715 		
       
   716 		TAknWindowLineLayout layoutOfSideLDisplay = AknLayoutScalable_Apps:: bg_calc_display_pane_g1().LayoutLine();              
       
   717 		TAknWindowLineLayout layoutOfCenterDisplay = AknLayoutScalable_Apps:: bg_calc_display_pane_g2().LayoutLine();             
       
   718 		TAknWindowLineLayout layoutOfSideRDisplay  = AknLayoutScalable_Apps:: bg_calc_display_pane_g3().LayoutLine();
       
   719 		TAknLayoutRect rectParent;
       
   720 		rectParent.LayoutRect(iCalcContainer->EditorPane()->Rect(),layoutOfDisplay) ;
       
   721 		iSideLDisplayLayout.LayoutRect(rectParent.Rect(),layoutOfSideLDisplay);
       
   722 		iCenterDisplayLayout.LayoutRect(rectParent.Rect(),layoutOfCenterDisplay);          
       
   723 		iSideRDisplayLayout.LayoutRect(rectParent.Rect(),layoutOfSideRDisplay);  
       
   724 		}
       
   725     }
       
   726 
       
   727 
       
   728 // ---------------------------------------------------------
       
   729 // CCalcEditorSubPane::Draw
       
   730 // Drawing editor
       
   731 // (other items were commented in a header).
       
   732 // ---------------------------------------------------------
       
   733 //
       
   734 void CCalcEditorSubPane::Draw
       
   735               (const TRect& aRect) const   
       
   736     {
       
   737     // Get a graphics context
       
   738      CWindowGc& gc = SystemGc();
       
   739     gc.Clear(aRect);
       
   740     gc.SetClippingRect(aRect);
       
   741     // Draw calc_display outline
       
   742     TRect rect(Rect()); 
       
   743     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   744 	AknsDrawUtils::Background( skin, AknsDrawUtils::ControlContext(this), this, gc, rect );
       
   745                                    
       
   746     AknIconUtils::SetSize(iCalcSideLDisplay->Bitmap(),iSideLDisplayLayout.Rect().Size(),EAspectRatioNotPreserved);
       
   747 	AknIconUtils::SetSize(iCalcSideLDisplay->Mask(), iSideLDisplayLayout.Rect().Size(),EAspectRatioNotPreserved);  
       
   748 	
       
   749 	AknIconUtils::SetSize(iCalcCenterDisplay->Bitmap(),iCenterDisplayLayout.Rect().Size(),EAspectRatioNotPreserved);
       
   750 	AknIconUtils::SetSize(iCalcCenterDisplay->Mask(), iCenterDisplayLayout.Rect().Size(),EAspectRatioNotPreserved);        
       
   751                     
       
   752     AknIconUtils::SetSize(iCalcSideRDisplay->Bitmap(),iSideRDisplayLayout.Rect().Size(),EAspectRatioNotPreserved);
       
   753 	AknIconUtils::SetSize(iCalcSideRDisplay->Mask(), iSideRDisplayLayout.Rect().Size(),EAspectRatioNotPreserved);     
       
   754 
       
   755 	iSideLDisplayLayout.DrawImage(gc, iCalcSideLDisplay->Bitmap(),iCalcSideLDisplay->Mask());
       
   756 	iCenterDisplayLayout.DrawImage(gc,iCalcCenterDisplay->Bitmap(),iCalcCenterDisplay->Mask());
       
   757 	iSideRDisplayLayout.DrawImage(gc, iCalcSideRDisplay->Bitmap(),iCalcSideRDisplay->Mask());
       
   758 	
       
   759 	TRgb shadowcolor ;
       
   760 	AknsUtils::GetCachedColor( skin,shadowcolor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG31);
       
   761 	
       
   762 	TRgb color;
       
   763     AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG30);
       
   764     TBuf<256> keyvalue ;
       
   765 
       
   766     if (iUiLanguage == ELangFarsi || iUiLanguage == ELangArabic 
       
   767             || iUiLanguage == ELangHindi || iUiLanguage == ELangUrdu)
       
   768 	    {
       
   769 	    TPtrC number(iEditLine.NumberString());
       
   770 	    keyvalue.Append(number);
       
   771 	    AknTextUtils::LanguageSpecificNumberConversion  (keyvalue);
       
   772 	    }
       
   773 
       
   774 	if (!(AknLayoutUtils::ScalableLayoutInterfaceAvailable()))
       
   775 		{
       
   776                     if ( iUiLanguage == ELangArabic || iUiLanguage == ELangUrdu )
       
   777 		    {
       
   778 		        TInt len = keyvalue.Length();
       
   779 			    TInt pos = KErrNotFound;
       
   780 			    TBuf<1> ch;
       
   781 			    ch.Append(iCalcAppEnv->MinusIndicator());
       
   782 			    if( (pos = keyvalue.Locate(iCalcAppEnv->MinusIndicator())) != KErrNotFound &&
       
   783 			         pos == keyvalue.LocateReverse(iCalcAppEnv->MinusIndicator()))
       
   784 			    {
       
   785 			     keyvalue.Delete( pos, 1 );
       
   786 			     keyvalue.Insert( 0, ch );	 
       
   787 			    }
       
   788 			iLayoutText[ECalcEditorOperandShadow].DrawText(gc, keyvalue,EFalse,shadowcolor);
       
   789 			}
       
   790                     else if( iUiLanguage == ELangHindi || iUiLanguage == ELangFarsi )
       
   791 			{
       
   792 			 iLayoutText[ECalcEditorOperandShadow].DrawText(gc, keyvalue,EFalse,shadowcolor);	
       
   793 			}
       
   794 		else 
       
   795 			{
       
   796 			iLayoutText[ECalcEditorOperandShadow].DrawText(gc, iEditLine.NumberString(),EFalse,shadowcolor);	
       
   797 			}
       
   798 		}
       
   799 
       
   800     if ( iUiLanguage == ELangArabic || iUiLanguage == ELangUrdu )
       
   801 	    {
       
   802 	        TInt len = keyvalue.Length();
       
   803 		    TInt pos = KErrNotFound;
       
   804 		    TBuf<1> ch;
       
   805 		    ch.Append(iCalcAppEnv->MinusIndicator());
       
   806 		    if( (pos = keyvalue.Locate(iCalcAppEnv->MinusIndicator())) != KErrNotFound &&
       
   807 		         pos == keyvalue.LocateReverse(iCalcAppEnv->MinusIndicator()))
       
   808 		    {
       
   809 		     keyvalue.Delete( pos, 1 );
       
   810 		     keyvalue.Insert( 0, ch );	 
       
   811 		    }
       
   812 	    iLayoutText[ECalcEditorOperand].DrawText(gc, keyvalue,EFalse,color);
       
   813 		}
       
   814     else if( iUiLanguage == ELangHindi || iUiLanguage == ELangFarsi )
       
   815 		{
       
   816 	    iLayoutText[ECalcEditorOperand].DrawText(gc, keyvalue,EFalse,color);
       
   817 		}
       
   818     else
       
   819 	    {
       
   820 		iLayoutText[ECalcEditorOperand].DrawText(gc, iEditLine.NumberString(),EFalse,color);
       
   821 		}
       
   822 
       
   823 	TCalcEditLine::TCalcOperatorType operatorType(
       
   824 		iEditLine.Operator());
       
   825 	TPtrC operatorString(
       
   826 		iCalcAppEnv->EditorOperator(operatorType));
       
   827 
       
   828 	if (!(AknLayoutUtils::ScalableLayoutInterfaceAvailable()))
       
   829 		{
       
   830 		iLayoutText[ECalcEditorOperatorShadow].DrawText(gc,operatorString,EFalse,shadowcolor);
       
   831 		}
       
   832 
       
   833    	iLayoutText[ECalcEditorOperator].DrawText(gc, operatorString,EFalse,color);
       
   834     CCalcDocument* calcDocument = 
       
   835         STATIC_CAST(CCalcDocument*, iCalcAppEnv->AppUi()->Document());
       
   836     if (calcDocument->HasMemory())
       
   837         {
       
   838         TPtrC mIndicatorShadow(
       
   839             iCalcAppEnv->MemoryIndicatorShadow());
       
   840         TPtrC mIndicator(iCalcAppEnv->MemoryIndicator());
       
   841 
       
   842 
       
   843 	if (!(AknLayoutUtils::ScalableLayoutInterfaceAvailable()))
       
   844 		{
       
   845 		iLayoutText[ECalcEditorMemoryShadow].DrawText(gc, mIndicatorShadow);
       
   846 		}
       
   847 
       
   848 
       
   849         iLayoutText[ECalcEditorMemory].DrawText(gc, mIndicator);
       
   850         }
       
   851     }
       
   852     
       
   853 // ---------------------------------------------------------
       
   854 // CCalcEditorSubPane::MapNumericChar
       
   855 // Redraw percent button, either normal or dimmed.
       
   856 // (other items were commented in a header).
       
   857 // ---------------------------------------------------------
       
   858 //		
       
   859 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   860 TBool CCalcEditorSubPane::MapDecimal( TKeyEvent aKeyEvent )
       
   861     {
       
   862     const TInt KMaxNumCharsPerCase = 50;
       
   863     TBuf<KMaxNumCharsPerCase> keys;
       
   864 
       
   865     TPtiKey aKey = ( TPtiKey )aKeyEvent.iScanCode;
       
   866     if( !keys.Length() )
       
   867             {
       
   868             keys.Append( aKeyEvent.iCode );
       
   869             }
       
   870 
       
   871     if ( keys.Length() > 0 )
       
   872         {
       
   873         TUint16 firstChar = keys[0];
       
   874         switch ( firstChar )		
       
   875             {
       
   876             case KPtiPinyinMarker:
       
   877             case KPtiStrokeMarker:
       
   878             case KPtiZhuyinMarker:
       
   879             case KPtiCangjieMarker:
       
   880             case KPtiGetAllMarker:
       
   881             if ( keys.Length() > 1 )
       
   882                 {
       
   883                 firstChar = keys[1];
       
   884                 }
       
   885             default:
       
   886                 break;
       
   887             }
       
   888         TInt loc = iAllowedDecimal.Locate( firstChar );
       
   889 
       
   890                 if ( ( loc != KErrNotFound ) )/*|| (HandleSpeciallyForChineseNubers(aKey, aCase)))*/
       
   891             {
       
   892             return ETrue;
       
   893             }
       
   894         }
       
   895     return EFalse;
       
   896     }
       
   897 
       
   898 #else
       
   899 TBool CCalcEditorSubPane::MapDecimal( TPtiKey aKey, TPtiTextCase aCase )	
       
   900     {
       
   901     const TInt KMaxNumCharsPerCase = 50;
       
   902     TBuf<KMaxNumCharsPerCase> keys;
       
   903 
       
   904     iQwertyKeyMappings->GetDataForKey( aKey, keys, aCase );
       
   905 
       
   906     if ( keys.Length() > 0 )
       
   907         {
       
   908         TUint16 firstChar = keys[0];
       
   909         switch ( firstChar )
       
   910             {
       
   911             case KPtiPinyinMarker:
       
   912             case KPtiStrokeMarker:
       
   913             case KPtiZhuyinMarker:
       
   914             case KPtiCangjieMarker:
       
   915             case KPtiGetAllMarker:
       
   916                 if ( keys.Length() > 1 )
       
   917                     {
       
   918                     firstChar = keys[1];
       
   919                     }
       
   920             default:
       
   921                 break;
       
   922             }
       
   923         TInt loc = iAllowedDecimal.Locate( firstChar );
       
   924 
       
   925                 if ( ( loc != KErrNotFound ) )/*|| (HandleSpeciallyForChineseNubers(aKey, aCase)))*/
       
   926             {
       
   927             return ETrue;
       
   928             }
       
   929         }
       
   930     return EFalse;
       
   931     }
       
   932 #endif
       
   933 	
       
   934 // ---------------------------------------------------------
       
   935 // CCalcEditorSubPane::EditPaneRect
       
   936 // This function gives the editor pane layout.
       
   937 // (other items were commented in a header).
       
   938 // ---------------------------------------------------------
       
   939 //
       
   940 
       
   941 TRect CCalcEditorSubPane::EditPaneRect()
       
   942    {
       
   943    TRect parentRect(Rect()); 
       
   944    return 	parentRect;
       
   945    }
       
   946    
       
   947 // ---------------------------------------------------------
       
   948 // CCalcEditorSubPane::HandlePointerEventL
       
   949 // Handled when there is a pen input in EditorPane.
       
   950 // (other items were commented in a header).
       
   951 // ---------------------------------------------------------
       
   952 //   
       
   953 void CCalcEditorSubPane::HandlePointerEventL
       
   954             ( const TPointerEvent& aPointerEvent )           
       
   955     {
       
   956     TRect memoryLayoutRect = iLayoutText[ECalcEditorMemory].TextRect();
       
   957     CCalcDocument* calcDocument = 
       
   958         STATIC_CAST( CCalcDocument*, iCalcAppEnv->AppUi()->Document() );
       
   959     if( ( memoryLayoutRect.Contains( aPointerEvent.iPosition ) ) && ( calcDocument->HasMemory() ) )
       
   960         {
       
   961         // When we set the memory value to the editor, 
       
   962         // We should change the menu item "Lase Result"'s flag to "EFalse".
       
   963         iCalcContainer->View()->iLastResultSetected = EFalse;
       
   964         iCalcContainer->View()->HandleMemoryRecallL();
       
   965         }
       
   966 
       
   967     }
       
   968 
       
   969 // End of file  CALCEDIT_CPP