extras/calcsoft/src/CalcOutSheet.cpp
branchRCL_3
changeset 20 41b775cdc0c8
parent 19 0f21a5ec0db7
child 21 10c6e6d6e4d9
equal deleted inserted replaced
19:0f21a5ec0db7 20:41b775cdc0c8
     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:  The OutputSheet sub-pane class, CCalcOutputSheet.
       
    15 *                Derived from CCoeControl.
       
    16 *                The CCalcOutputSheet displays histroy data.
       
    17 *                History data is scroll up and down.
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include    <AknUtils.h>
       
    25 #include    <Calcsoft.rsg>
       
    26 #include    <applayout.cdl.h>
       
    27 #include     <AknsDrawUtils.h>
       
    28 #include    <layoutmetadata.cdl.h>
       
    29 #include    "CalcEnv.h"
       
    30 #include    "CalcCont.h"    
       
    31 #include    "CalcOutSheet.h"
       
    32 #include    "CalcDoc.h"
       
    33 #include    "CalcEditline.h"
       
    34 #include    "CalcAppUi.h"
       
    35 #include    "CalcHistory.h"
       
    36 #include    "CalcDrawingConst.laf"
       
    37 #include "fbs.h"
       
    38 #include <AknIconUtils.h>
       
    39 #include <aknlayoutscalable_apps.cdl.h>
       
    40 #include <AknsBasicBackgroundControlContext.h>
       
    41 #include <AknFepInternalCRKeys.h>
       
    42 
       
    43 
       
    44 #include <eiksbfrm.h> 
       
    45 #include <eikscrlb.h>
       
    46 
       
    47 //  LOCAL CONSTANTS AND MACROS  
       
    48 
       
    49 // ================= MEMBER FUNCTIONS =======================
       
    50 
       
    51 // Two-phased constructor.
       
    52 CCalcOutputSheet* CCalcOutputSheet::NewL(
       
    53                     CCalcContainer* aContainer)
       
    54     {
       
    55     CCalcOutputSheet* self = new (ELeave) CCalcOutputSheet();
       
    56     CleanupStack::PushL(self);
       
    57     self->ConstructL(aContainer);
       
    58     CleanupStack::Pop(self); 
       
    59     return self;
       
    60     }
       
    61 
       
    62 // Destructor
       
    63 CCalcOutputSheet::~CCalcOutputSheet()
       
    64     {
       
    65     delete iOpSheetContext;
       
    66     if(iOperatorLayout)
       
    67         {
       
    68         iOperatorLayout->Reset();
       
    69         delete iOperatorLayout;    
       
    70         }
       
    71     if(iOperandLayout)
       
    72         {
       
    73         iOperandLayout->Reset();
       
    74         delete iOperandLayout;    
       
    75         }
       
    76     if(iEqualLineLayout)
       
    77         {
       
    78         iEqualLineLayout->Reset();
       
    79         delete iEqualLineLayout;    
       
    80         }
       
    81     if(iResultsLineLayout)
       
    82         {
       
    83         iResultsLineLayout->Reset();
       
    84         delete iResultsLineLayout;    
       
    85         }
       
    86     if (iCRKey)
       
    87         {
       
    88         delete iCRKey;
       
    89         iCRKey = NULL;
       
    90         }
       
    91         
       
    92     //Delete the scrollbar frame
       
    93     if(iSBFrame)
       
    94         {
       
    95         delete iSBFrame;
       
    96         iSBFrame = NULL;
       
    97         }
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------
       
   101 // CCalcOutputSheet::ScrollToBottomL
       
   102 // Scroll to bottom line.
       
   103 // (other items were commented in a header).
       
   104 // ---------------------------------------------------------
       
   105 //
       
   106 void CCalcOutputSheet::ScrollToBottomL()
       
   107     {
       
   108     iScrollOffset = 0;
       
   109     
       
   110     //If scrollbar is present, update the scrollbar as well
       
   111      if( AknLayoutUtils::PenEnabled()  )
       
   112         {
       
   113           UpdateScrollIndicatorL();
       
   114         }
       
   115     DrawNow();
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------
       
   119 // CCalcOutputSheet::NotifyClearHistory
       
   120 // Called after clearing calculation history.
       
   121 // (other items were commented in a header).
       
   122 // ---------------------------------------------------------
       
   123 //
       
   124 void CCalcOutputSheet::NotifyClearHistoryL()
       
   125     {
       
   126     iScrollOffset = 0;
       
   127     if( AknLayoutUtils::PenEnabled()  )
       
   128     {
       
   129         UpdateScrollIndicatorL();    
       
   130     }
       
   131     DrawNow();
       
   132     }
       
   133         
       
   134 
       
   135 // ---------------------------------------------------------
       
   136 // CCalcOutputSheet::CanUp
       
   137 // Check whether scroll-up can be done or not.
       
   138 // (other items were commented in a header).
       
   139 // ---------------------------------------------------------
       
   140 //
       
   141 TBool CCalcOutputSheet::CanUp() const
       
   142     {
       
   143     // The number of lines of the history which a document has is got.
       
   144     TInt historyLine(iCalcHistory->Count());
       
   145     if ( (iCalcOutputSheetLines + iScrollOffset) < historyLine )
       
   146         {
       
   147         return ETrue;
       
   148         }
       
   149     return EFalse;
       
   150     }
       
   151 
       
   152 // ---------------------------------------------------------
       
   153 // CCalcOutputSheet::CanDown
       
   154 // Check whether scroll-down can be done or not.
       
   155 // (other items were commented in a header).
       
   156 // ---------------------------------------------------------
       
   157 //
       
   158 TBool CCalcOutputSheet::CanDown() const
       
   159     {
       
   160     // The number of lines of the history which a document has is got.
       
   161     return (iScrollOffset != 0);
       
   162     }
       
   163 
       
   164 
       
   165 // ---------------------------------------------------------
       
   166 // CCalcOutputSheet::ScrollUp
       
   167 // history is scrolled up.
       
   168 // (other items were commented in a header).
       
   169 // ---------------------------------------------------------
       
   170 //
       
   171 void CCalcOutputSheet::ScrollUp()
       
   172     {
       
   173    
       
   174     if (CanUp())
       
   175         {
       
   176         iScrollOffset++;
       
   177         DrawNow();
       
   178         }
       
   179     }
       
   180 
       
   181 // ---------------------------------------------------------
       
   182 // CCalcOutputSheet::ScrollDown
       
   183 // history is scrolled down.
       
   184 // (other items were commented in a header).
       
   185 // ---------------------------------------------------------
       
   186 //
       
   187 void CCalcOutputSheet::ScrollDown()
       
   188     {
       
   189 
       
   190     if (CanDown())
       
   191         {
       
   192         iScrollOffset--;
       
   193         DrawNow();
       
   194         }
       
   195     }
       
   196 
       
   197 // C++ default constructor can NOT contain any code, that
       
   198 // might leave.
       
   199 //
       
   200 CCalcOutputSheet::CCalcOutputSheet() 
       
   201     {
       
   202     }
       
   203 
       
   204 // default constructor can leave.
       
   205 void CCalcOutputSheet::ConstructL
       
   206         (CCalcContainer* aContainer) 
       
   207                      
       
   208     {
       
   209     SetContainerWindowL(*aContainer);
       
   210 
       
   211     iCalcContainer = aContainer;
       
   212     
       
   213     iCalcAppEnv = CCalcAppEnv::Static();
       
   214     iCalcPaper = iCalcAppEnv->PaperBitmap();
       
   215     iCalcAppEnv->ScalablePaperBitmaps(iCalcScalablePaper);
       
   216 #ifdef __SCALABLE_ICONS
       
   217     iCalcResultsLine = iCalcAppEnv->ResultsLineBitmap();
       
   218 #endif
       
   219 
       
   220     CCalcAppUi* appui = iCalcAppEnv->AppUi();
       
   221     CCalcDocument* calcDocument = 
       
   222                    STATIC_CAST(CCalcDocument*, appui->Document());
       
   223     iCalcHistory = calcDocument->History(); 
       
   224     TAknLayoutScalableParameterLimits listLimits;
       
   225     listLimits = AknLayoutScalable_Apps::list_calc_item_pane_ParamLimits();
       
   226     iCalcOutputSheetLines   = (listLimits.LastRow()-listLimits.FirstRow()) + 1;
       
   227     iOpSheetContext = CAknsBasicBackgroundControlContext::NewL(KAknsIIDQsnFrCalcPaper , TRect(0,0,0,0), EFalse);
       
   228     iOperatorLayout = new(ELeave)CArrayFixFlat<TAknLayoutText>(iCalcOutputSheetLines);
       
   229     iOperandLayout = new(ELeave)CArrayFixFlat<TAknLayoutText>(iCalcOutputSheetLines);
       
   230     iResultsLineLayout = new(ELeave)CArrayFixFlat<TAknLayoutRect>(iCalcOutputSheetLines-1);
       
   231     iEqualLineLayout = new(ELeave)CArrayFixFlat<TAknLayoutRect>(iCalcOutputSheetLines-1);
       
   232     iUiLanguage = User::Language();
       
   233     }
       
   234 
       
   235 // ---------------------------------------------------------
       
   236 // CCalcOutputSheet::SizeChanged
       
   237 // Set size of control.
       
   238 // (other items were commented in a header).
       
   239 // ---------------------------------------------------------
       
   240 //
       
   241 void CCalcOutputSheet::SizeChanged()
       
   242     {
       
   243     TRAP_IGNORE( SizeChangedOutSheetL() );
       
   244     }
       
   245 
       
   246 // ---------------------------------------------------------
       
   247 // CCalcOutputSheet::SizeChanged
       
   248 // Set size of control.
       
   249 // (other items were commented in a header).
       
   250 // ---------------------------------------------------------
       
   251 //
       
   252 void CCalcOutputSheet::SizeChangedOutSheetL()
       
   253     {
       
   254     TRect parentRect(iCalcContainer->Rect());
       
   255     
       
   256     TAknLayoutScalableParameterLimits listLimits;
       
   257     if(AknLayoutUtils::PenEnabled())
       
   258     {
       
   259         listLimits = AknLayoutScalable_Apps::list_calc_item_pane_ParamLimits(enTouch_enabled);    
       
   260     }
       
   261     else
       
   262     {
       
   263         listLimits = AknLayoutScalable_Apps::list_calc_item_pane_ParamLimits(enTouch_disabled);    
       
   264     }
       
   265     iCalcOutputSheetLines   = (listLimits.LastRow()-listLimits.FirstRow()) + 1;
       
   266     iOperatorLayout->ResizeL(iCalcOutputSheetLines);
       
   267     iOperandLayout->ResizeL(iCalcOutputSheetLines);
       
   268     iResultsLineLayout->ResizeL(iCalcOutputSheetLines-1);
       
   269     iEqualLineLayout->ResizeL(iCalcOutputSheetLines-1);
       
   270     
       
   271     iOperatorLayout->Reset();
       
   272     iOperandLayout->Reset();
       
   273     iResultsLineLayout->Reset();
       
   274     iEqualLineLayout->Reset();
       
   275     
       
   276     TAknLayoutRect rectParent;
       
   277     TAknWindowLineLayout layoutOfParentResultsLine;
       
   278     TAknLayoutRect rectListCalcPane;
       
   279     
       
   280  
       
   281     
       
   282     if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
   283         {
       
   284             TAknWindowLineLayout  calcPaperPane;
       
   285             
       
   286             //For Touch UI Layouts, different configuration
       
   287             if( AknLayoutUtils::PenEnabled() )
       
   288             {
       
   289                 if (Layout_Meta_Data::IsLandscapeOrientation())
       
   290                 {
       
   291                     calcPaperPane = AknLayoutScalable_Apps::calc_paper_pane(enTouch_with_lsc).LayoutLine();
       
   292                 }
       
   293                 else
       
   294                 {
       
   295                     calcPaperPane = AknLayoutScalable_Apps::calc_paper_pane(enTouch_with_prt).LayoutLine();
       
   296                 }
       
   297             }
       
   298             else
       
   299             {
       
   300                 calcPaperPane = AknLayoutScalable_Apps::calc_paper_pane(enTouch_disabled).LayoutLine();
       
   301             }
       
   302             TAknLayoutRect rectcalcPaperPane;    
       
   303             rectcalcPaperPane.LayoutRect(parentRect,calcPaperPane);
       
   304             iSBBrPoint = rectcalcPaperPane.Rect().iBr;
       
   305             TAknWindowLineLayout layoutListCalcPane;
       
   306             if( AknLayoutUtils::PenEnabled() )
       
   307             {
       
   308                 layoutListCalcPane = AknLayoutScalable_Apps::list_calc_pane(enTouch_enabled).LayoutLine();
       
   309             }
       
   310             else
       
   311             {
       
   312                 layoutListCalcPane = AknLayoutScalable_Apps::list_calc_pane(enTouch_disabled).LayoutLine();
       
   313             }
       
   314             
       
   315             rectListCalcPane.LayoutRect(rectcalcPaperPane.Rect(),layoutListCalcPane);
       
   316         }
       
   317     
       
   318     TInt nTimes=(iCalcOutputSheetLines-1);
       
   319     for (TInt cnt(0); cnt < iCalcOutputSheetLines; cnt++)
       
   320         {
       
   321         if (AknLayoutUtils::ScalableLayoutInterfaceAvailable())
       
   322         {
       
   323         if(AknLayoutUtils::PenEnabled())
       
   324         {
       
   325             if (Layout_Meta_Data::IsLandscapeOrientation())
       
   326             {
       
   327                 layoutOfParentResultsLine =  AknLayoutScalable_Apps::list_calc_item_pane(nTimes,enTouch_enabled).LayoutLine();    
       
   328             }
       
   329             else
       
   330             {
       
   331                 layoutOfParentResultsLine =  AknLayoutScalable_Apps::list_calc_item_pane(nTimes,enTouch_enabled).LayoutLine();
       
   332             }
       
   333     
       
   334         }
       
   335         else
       
   336         {
       
   337             layoutOfParentResultsLine =  AknLayoutScalable_Apps::list_calc_item_pane(nTimes,enTouch_disabled).LayoutLine();    
       
   338         }
       
   339         
       
   340         
       
   341         rectParent.LayoutRect(rectListCalcPane.Rect(),layoutOfParentResultsLine) ;
       
   342             
       
   343         TAknLayoutText operatorLayout;
       
   344         TAknLayoutText operendLayout;
       
   345         if(AknLayoutUtils::PenEnabled())
       
   346         {
       
   347             operatorLayout.LayoutText(rectParent.Rect(),AknLayoutScalable_Apps::list_calc_item_pane_t2(enTouch_with_prt).LayoutLine(),iCalcAppEnv->OutSheetOperatorFont()); 
       
   348             iOperatorLayout->AppendL(operatorLayout);
       
   349         
       
   350             operendLayout.LayoutText(rectParent.Rect(),AknLayoutScalable_Apps::list_calc_item_pane_t1(enTouch_with_lsc).LayoutLine(),iCalcAppEnv->OutSheetOperatorFont()); 
       
   351             iOperandLayout->AppendL(operendLayout);
       
   352         }
       
   353         else
       
   354         {
       
   355             operatorLayout.LayoutText(rectParent.Rect(),AknLayoutScalable_Apps::list_calc_item_pane_t2(enTouch_disabled).LayoutLine(),iCalcAppEnv->OutSheetOperatorFont()); 
       
   356             iOperatorLayout->AppendL(operatorLayout);
       
   357         
       
   358             operendLayout.LayoutText(rectParent.Rect(),AknLayoutScalable_Apps::list_calc_item_pane_t1(enTouch_disabled).LayoutLine(),iCalcAppEnv->OutSheetOperatorFont()); 
       
   359             iOperandLayout->AppendL(operendLayout);    
       
   360         }
       
   361         
       
   362       // aCustomFont
       
   363      --nTimes;
       
   364         
       
   365         }
       
   366       
       
   367       else
       
   368       {
       
   369             
       
   370         
       
   371       //Scalable UI.
       
   372 
       
   373           TAknLayoutText operatorLayout;
       
   374         TAknLayoutText operendLayout;
       
   375           operatorLayout.LayoutText(parentRect,AppLayout::Calculator_texts_Line_8(nTimes),iCalcAppEnv->OutSheetOperatorFont()); // aCustomFont
       
   376         iOperatorLayout->AppendL(operatorLayout);        
       
   377 
       
   378         operendLayout.LayoutText(parentRect,AppLayout::Calculator_texts_Line_7(nTimes), NULL);
       
   379         iOperandLayout->AppendL(operendLayout);            
       
   380      --nTimes;
       
   381       }
       
   382     }
       
   383     
       
   384     //Scalable UI.
       
   385     nTimes = iCalcOutputSheetLines - 2;      
       
   386     for (TInt ii(0); ii < (iCalcOutputSheetLines - 1); ii++)
       
   387         {
       
   388 
       
   389 
       
   390         if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
   391             {
       
   392 #ifdef __SCALABLE_ICONS        
       
   393             layoutOfParentResultsLine =  AknLayoutScalable_Apps::list_calc_item_pane(nTimes).LayoutLine();
       
   394 
       
   395             rectParent.LayoutRect(rectListCalcPane.Rect(),layoutOfParentResultsLine) ;
       
   396             TAknWindowLineLayout   layoutOfResultsLine = AknLayoutScalable_Apps::list_calc_item_pane_g1().LayoutLine(); 
       
   397             TAknLayoutRect lineLayout;
       
   398             lineLayout.LayoutRect(rectParent.Rect(),layoutOfResultsLine);
       
   399             iResultsLineLayout->AppendL(lineLayout);
       
   400 #else
       
   401             TAknLayoutRect lineLayout;
       
   402             lineLayout.LayoutRect(parentRect,AppLayout::Calculator_elements_Line_3(nTimes)); 
       
   403             iEqualLineLayout->AppendL(lineLayout);
       
   404 #endif
       
   405             }
       
   406             else
       
   407             {
       
   408             TAknLayoutRect lineLayout;
       
   409             lineLayout.LayoutRect(parentRect,AppLayout::Calculator_elements_Line_3(nTimes)); 
       
   410             iEqualLineLayout->AppendL(lineLayout);
       
   411             }
       
   412             
       
   413         --nTimes;
       
   414         }
       
   415 
       
   416     TAknLayoutRect  paperRect;
       
   417     if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
   418             {
       
   419             TAknLayoutRect rectCalcPaperPane;    
       
   420             TAknLayoutRect rectbgCalcPaperPane;
       
   421             //Different configuration for Touch Layouts
       
   422             if( AknLayoutUtils::PenEnabled() )
       
   423             {
       
   424                     //In landscape mode different configuration is needed
       
   425                  if (Layout_Meta_Data::IsLandscapeOrientation())
       
   426                  {
       
   427                     rectCalcPaperPane.LayoutRect(parentRect,AknLayoutScalable_Apps::calc_paper_pane(enTouch_with_lsc).LayoutLine());  
       
   428                  }
       
   429                  else
       
   430                  {
       
   431                     rectCalcPaperPane.LayoutRect(parentRect,AknLayoutScalable_Apps::calc_paper_pane(enTouch_with_prt).LayoutLine());      
       
   432                  }
       
   433                  rectbgCalcPaperPane.LayoutRect(rectCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane(enTouch_enabled).LayoutLine());
       
   434             }
       
   435             else
       
   436             {
       
   437                 rectCalcPaperPane.LayoutRect(parentRect,AknLayoutScalable_Apps::calc_paper_pane(enTouch_disabled).LayoutLine());    
       
   438                 rectbgCalcPaperPane.LayoutRect(rectCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane().LayoutLine());
       
   439             }
       
   440             
       
   441             iPaperPaneRect  = rectCalcPaperPane;
       
   442             
       
   443             
       
   444             iCalcPaperLayout[0].LayoutRect(rectbgCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane_g1().LayoutLine());
       
   445             iCalcPaperLayout[1].LayoutRect(rectbgCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane_g2().LayoutLine());
       
   446             iCalcPaperLayout[2].LayoutRect(rectbgCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane_g3().LayoutLine());
       
   447             iCalcPaperLayout[3].LayoutRect(rectbgCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane_g4().LayoutLine());
       
   448             iCalcPaperLayout[4].LayoutRect(rectbgCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane_g5().LayoutLine());
       
   449             iCalcPaperLayout[5].LayoutRect(rectbgCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane_g6().LayoutLine());
       
   450             iCalcPaperLayout[6].LayoutRect(rectbgCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane_g7().LayoutLine());
       
   451             iCalcPaperLayout[7].LayoutRect(rectbgCalcPaperPane.Rect(),AknLayoutScalable_Apps::bg_calc_paper_pane_g8().LayoutLine());
       
   452             iCalcPaperLayout[8].LayoutRect(rectbgCalcPaperPane.Rect(),AknLayoutScalable_Apps::calc_bg_paper_pane_g9().LayoutLine());
       
   453             }
       
   454             
       
   455        iOpSheetContext->SetRect(Rect());
       
   456         
       
   457         //Only for touch UI, scrollbars are present
       
   458        if( AknLayoutUtils::PenEnabled()  )
       
   459         {
       
   460           UpdateScrollIndicatorL();
       
   461         }
       
   462         else
       
   463         {
       
   464         if(iSBFrame)
       
   465         {
       
   466             delete(iSBFrame);
       
   467             iSBFrame = NULL;
       
   468         }
       
   469         
       
   470         }
       
   471         
       
   472         }
       
   473 
       
   474 
       
   475 // ---------------------------------------------------------
       
   476 // CCalcOutputSheet::UpdateScrollIndicatorL
       
   477 // Creates and updates the scrollbar
       
   478 // (other items were commented in a header).
       
   479 // ---------------------------------------------------------
       
   480 void CCalcOutputSheet::UpdateScrollIndicatorL()
       
   481     {
       
   482         
       
   483         if( !AknLayoutUtils::PenEnabled()  )
       
   484         {
       
   485             return;
       
   486         }
       
   487         
       
   488         TAknLayoutRect rectCalcScrollPane;    
       
   489 
       
   490         //Get the layout information for the scrollbar
       
   491         if( AknLayoutUtils::PenEnabled() )
       
   492         {
       
   493          if (Layout_Meta_Data::IsLandscapeOrientation())
       
   494          {
       
   495             rectCalcScrollPane.LayoutRect(iPaperPaneRect.Rect(),AknLayoutScalable_Apps::scroll_pane_cp024().LayoutLine());  
       
   496          }
       
   497          else
       
   498          {
       
   499             rectCalcScrollPane.LayoutRect(iPaperPaneRect.Rect(),AknLayoutScalable_Apps::scroll_pane_cp024().LayoutLine());      
       
   500          }
       
   501 
       
   502         }
       
   503                 //Create scrollbar if not created already
       
   504         if ( !iSBFrame )
       
   505         {
       
   506         //Make this class as the observer class as well
       
   507         iSBFrame = new( ELeave ) CEikScrollBarFrame( this,this, ETrue );
       
   508 
       
   509         // Decide which type of scrollbar is to be shown
       
   510         CAknAppUi* appUi = iAvkonAppUi;
       
   511         if (AknLayoutUtils::DefaultScrollBarType(appUi) == CEikScrollBarFrame::EDoubleSpan)
       
   512         {
       
   513             // For EDoubleSpan type scrollbar
       
   514             iSBFrame->CreateDoubleSpanScrollBarsL(ETrue, EFalse); // non-window owning scrollbar            
       
   515             iSBFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EDoubleSpan);
       
   516         }
       
   517         else
       
   518         {
       
   519             // For EArrowHead type scrollbar
       
   520             iSBFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EArrowHead);
       
   521         }  
       
   522         iSBFrame->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOff);
       
   523         }
       
   524 
       
   525         TEikScrollBarModel hSbarModel;
       
   526         TEikScrollBarModel vSbarModel;
       
   527         
       
   528         //By default span is one if only one page is present
       
   529         if(iCalcHistory->Count() < iCalcOutputSheetLines)
       
   530         {
       
   531             vSbarModel.iScrollSpan = 1;    
       
   532             vSbarModel.iThumbPosition = 0;    
       
   533             
       
   534         }
       
   535         else
       
   536         {
       
   537                 //span calculator if no of lines exceeds one page
       
   538             vSbarModel.iScrollSpan = 1 + iCalcHistory->Count() - iCalcOutputSheetLines;  
       
   539         }
       
   540 
       
   541         iPrevThumbPosition = vSbarModel.iThumbPosition = vSbarModel.iScrollSpan - 1;
       
   542         vSbarModel.iThumbSpan = 1;
       
   543 
       
   544         TRect clientRect( iAvkonAppUi->ClientRect() );
       
   545         TRect rec(rectCalcScrollPane.Rect()); 
       
   546         TPoint point = rectCalcScrollPane.Rect().iBr;
       
   547         TInt width = rectCalcScrollPane.Rect().Width();
       
   548         TInt rightPointRectX = iSBBrPoint.iX;
       
   549         TInt pointRectX = point.iX;
       
   550         TInt pointRectY = point.iY;
       
   551         pointRectX = rightPointRectX;
       
   552         TPoint newPoint;
       
   553         newPoint.SetXY( pointRectX, pointRectY );
       
   554         TRect rect;
       
   555         rect.SetRect( rec.iTl, newPoint );
       
   556 
       
   557         TEikScrollBarFrameLayout layout;
       
   558         layout.iTilingMode = TEikScrollBarFrameLayout::EInclusiveRectConstant;
       
   559 
       
   560         if (iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan)
       
   561         {    
       
   562         // For EDoubleSpan type scrollbar
       
   563         if (vSbarModel.iThumbPosition + vSbarModel.iThumbSpan > vSbarModel.iScrollSpan)
       
   564         {
       
   565             // Not let scrollbar values overflow
       
   566             vSbarModel.iThumbPosition = vSbarModel.iScrollSpan - vSbarModel.iThumbSpan;
       
   567         }
       
   568 
       
   569         TAknDoubleSpanScrollBarModel hDsSbarModel(hSbarModel);
       
   570         TAknDoubleSpanScrollBarModel vDsSbarModel(vSbarModel);
       
   571         
       
   572         if (iCalcHistory->Count() <= iCalcOutputSheetLines )
       
   573         {
       
   574         iSBFrame->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,
       
   575                 CEikScrollBarFrame::EOff);
       
   576         }
       
   577         else
       
   578         {
       
   579         iSBFrame->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,
       
   580                 CEikScrollBarFrame::EOn);
       
   581         }
       
   582 
       
   583         iSBFrame->TileL(&hDsSbarModel, &vDsSbarModel, clientRect, rect, layout);               
       
   584         iSBFrame->SetVFocusPosToThumbPos(vDsSbarModel.FocusPosition());
       
   585         }  
       
   586         else
       
   587         {
       
   588         iSBFrame->TileL( &hSbarModel, &vSbarModel, clientRect, rect, layout );
       
   589         iSBFrame->SetVFocusPosToThumbPos( vSbarModel.iThumbPosition );
       
   590         }
       
   591         }
       
   592         
       
   593 
       
   594 // ---------------------------------------------------------
       
   595 // CCalcOutputSheet::Draw
       
   596 // Drawing frame and history.
       
   597 // (other items were commented in a header).
       
   598 // ---------------------------------------------------------
       
   599 //
       
   600 void CCalcOutputSheet::Draw
       
   601         (const TRect& aRect) const
       
   602     {
       
   603     
       
   604     CWindowGc& gc = SystemGc();
       
   605     gc.Clear(aRect);
       
   606     gc.SetClippingRect(aRect);
       
   607     TRect rect(Rect());
       
   608     
       
   609 
       
   610     
       
   611     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   612     
       
   613     AknsDrawUtils::Background( AknsUtils:: SkinInstance(), AknsDrawUtils::ControlContext(this), this, gc, rect );
       
   614         
       
   615            
       
   616     gc.SetBrushStyle(CGraphicsContext::ENullBrush);
       
   617     gc.SetPenStyle(CGraphicsContext::ENullPen);
       
   618     //set the size of the bitmap. SVG-T upgrade.
       
   619     CAknsItemData* idata = NULL;                    
       
   620     if (skin)
       
   621         {
       
   622         idata = skin->GetCachedItemData( KAknsIIDQsnFrCalcPaper);
       
   623         }
       
   624         
       
   625     if ( idata && idata->Type() == EAknsITImageTable )
       
   626         {
       
   627             if ( AknLayoutUtils::PenEnabled() ) 
       
   628             {//when touch input,the paper become bigger,so it needs only one paper 
       
   629                 AknIconUtils::SetSize(iCalcScalablePaper[0]->Bitmap(),iCalcPaperLayout[0].Rect().Size(),EAspectRatioNotPreserved); 
       
   630                 AknIconUtils::SetSize(iCalcScalablePaper[0]->Mask(),iCalcPaperLayout[0].Rect().Size(),EAspectRatioNotPreserved);
       
   631                 iCalcPaperLayout[0].DrawImage(gc, iCalcScalablePaper[0]->Bitmap(),iCalcScalablePaper[0]->Mask());    
       
   632             }
       
   633             else
       
   634             {
       
   635                 for(TInt Cnt=0;Cnt < 9; Cnt++)
       
   636                 {
       
   637                 AknIconUtils::SetSize(iCalcScalablePaper[Cnt]->Bitmap(),iCalcPaperLayout[Cnt].Rect().Size(),EAspectRatioNotPreserved); 
       
   638                 AknIconUtils::SetSize(iCalcScalablePaper[Cnt]->Mask(),iCalcPaperLayout[Cnt].Rect().Size(),EAspectRatioNotPreserved);
       
   639                 iCalcPaperLayout[Cnt].DrawImage(gc, iCalcScalablePaper[Cnt]->Bitmap(),iCalcScalablePaper[Cnt]->Mask());
       
   640                 }
       
   641             }
       
   642           }
       
   643     else
       
   644         {
       
   645             // Make outsheet displayed in Jingmask is the same size as in other themes
       
   646             // when there is a scrollbar on outsheet.
       
   647             if ( AknLayoutUtils::PenEnabled() )
       
   648                 {
       
   649                 AknsDrawUtils::Background( AknsUtils:: SkinInstance(), iOpSheetContext, this, gc, iCalcPaperLayout[0].Rect() );
       
   650                 }
       
   651             else
       
   652                 {
       
   653                 AknsDrawUtils::Background( AknsUtils:: SkinInstance(), iOpSheetContext, this, gc, rect );
       
   654                 }    
       
   655         }
       
   656           
       
   657     
       
   658     for (TInt loop(iCalcOutputSheetLines - 1); loop >= 0; loop--)
       
   659         {
       
   660         const TCalcEditLine& history = (*iCalcHistory)[loop + iScrollOffset];
       
   661         TCalcEditLine::TCalcOperatorType operatorType(
       
   662             history.Operator());
       
   663         
       
   664         if (loop < iCalcOutputSheetLines - 1)
       
   665             {
       
   666             // When an operator is Equal, a line is drawn at an upper end.
       
   667             if (TCalcEditLine::ECalcEqual == operatorType)
       
   668                 {
       
   669                     TRgb ResultsLineolor;
       
   670                     TInt error1 = AknsUtils::GetCachedColor( skin, ResultsLineolor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG29);
       
   671                     if(error1 == KErrNone)
       
   672                     {
       
   673                         AknIconUtils::SetIconColor(iCalcResultsLine->Bitmap(),ResultsLineolor);
       
   674                     }
       
   675                 if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
   676                     {
       
   677 #ifdef __SCALABLE_ICONS
       
   678                     TAknLayoutRect& lineLayout = iResultsLineLayout->At(loop);
       
   679                     AknIconUtils::SetSize(iCalcResultsLine->Bitmap(),lineLayout.Rect().Size(),EAspectRatioNotPreserved);
       
   680                     AknIconUtils::SetSize(iCalcResultsLine->Mask(),lineLayout.Rect().Size(),EAspectRatioNotPreserved);
       
   681                     lineLayout.DrawImage(gc, iCalcResultsLine->Bitmap(),iCalcResultsLine->Mask()); 
       
   682 #else
       
   683                     TAknLayoutRect& equalLineLayout= iEqualLineLayout->At(loop);
       
   684                     TRect rectLine = equalLineLayout.Rect();
       
   685                     equalLineLayout.DrawRect(gc);
       
   686 #endif
       
   687                     }
       
   688                 else 
       
   689                     { 
       
   690                     TAknLayoutRect& equalLineLayout= iEqualLineLayout->At(loop);
       
   691                     TRect rectLine = equalLineLayout.Rect();
       
   692                     equalLineLayout.DrawRect(gc);
       
   693                     }
       
   694                 }
       
   695             }
       
   696             TRgb color;
       
   697             TInt error = AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG29);
       
   698             if(error == KErrNone)
       
   699             {
       
   700                 gc.SetPenColor(color);
       
   701             }
       
   702             
       
   703         //change TBuf<10> to TBuf<KCalcMaxNumberWidth>
       
   704        TBuf<KCalcMaxNumberWidth> keyvalue;
       
   705        
       
   706        keyvalue.Append(history.NumberString());
       
   707        AknTextUtils::LanguageSpecificNumberConversion  (keyvalue);
       
   708         // An operand's drawing
       
   709         TAknLayoutText& operendLayout = iOperandLayout->At(loop);
       
   710 
       
   711                     if ( iUiLanguage == ELangFarsi || iUiLanguage == ELangHindi || 
       
   712                         iUiLanguage == ELangUrdu || iUiLanguage == ELangArabic )
       
   713                         {
       
   714                          if( iUiLanguage == ELangUrdu || iUiLanguage == ELangArabic )
       
   715                  {
       
   716                     TInt len = keyvalue.Length();
       
   717                     TInt pos = KErrNotFound;
       
   718                     TBuf<1> ch;
       
   719                     ch.Append(iCalcAppEnv->MinusIndicator());
       
   720                     if( (pos = keyvalue.Locate(iCalcAppEnv->MinusIndicator())) != KErrNotFound &&
       
   721                          pos == keyvalue.LocateReverse(iCalcAppEnv->MinusIndicator()))
       
   722                     {
       
   723                      keyvalue.Delete( pos, 1 );
       
   724                      keyvalue.Insert( 0, ch );     
       
   725                     }
       
   726                  }
       
   727             operendLayout.DrawText(gc,keyvalue,EFalse,color);
       
   728             }
       
   729         else
       
   730             {
       
   731             operendLayout.DrawText(gc,history.NumberString(),EFalse,color);    
       
   732             }
       
   733         // An operator's drawing
       
   734         TPtrC operatorString(
       
   735             iCalcAppEnv->OutSheetOperator(operatorType));
       
   736         TAknLayoutText& operatorLayout = iOperatorLayout->At(loop);
       
   737         operatorLayout.DrawText(gc, operatorString , EFalse, color);
       
   738         }
       
   739         
       
   740         
       
   741     }
       
   742 
       
   743 // ---------------------------------------------------------
       
   744 // CCalcOutputSheet::HandleScrollEventL
       
   745 // Handles the events from the scrollbar
       
   746 // (other items were commented in a header).
       
   747 // ---------------------------------------------------------
       
   748 //
       
   749 void CCalcOutputSheet::HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType)
       
   750     {
       
   751           //Only on page up/down,scroll up/down and drag events
       
   752     if((aEventType == EEikScrollPageDown) || (aEventType == EEikScrollPageUp) || 
       
   753        (aEventType == EEikScrollThumbDragVert) || (aEventType == EEikScrollUp) ||
       
   754        (aEventType == EEikScrollDown))
       
   755        
       
   756         {
       
   757            //Get the current position from the scroll bar
       
   758            
       
   759            if(iPrevThumbPosition >aScrollBar->ThumbPosition() )
       
   760            {
       
   761                      //Move the scroll bar n times up
       
   762                 while(iPrevThumbPosition != aScrollBar->ThumbPosition())
       
   763                 {
       
   764                     ScrollUp();
       
   765                     iPrevThumbPosition--;
       
   766                 }
       
   767            }
       
   768            else
       
   769            {
       
   770                 //Move the scroll bar n times down
       
   771                 while( iPrevThumbPosition != aScrollBar->ThumbPosition() )
       
   772                 {
       
   773                     ScrollDown();
       
   774                     iPrevThumbPosition++;
       
   775                 }
       
   776            }
       
   777 
       
   778            DrawNow();
       
   779         }
       
   780     }
       
   781     
       
   782 // ---------------------------------------------------------
       
   783 // CCalcOutputSheet::HandleResourceChange
       
   784 // Handles the events that needs to be taken care after resource change
       
   785 // (other items were commented in a header).
       
   786 // ---------------------------------------------------------
       
   787 //
       
   788 void CCalcOutputSheet::HandleResourceChange(TInt aType)
       
   789 {
       
   790     TRAP_IGNORE(HandleResourceChangeOutSheetL(aType) );
       
   791     }
       
   792 
       
   793 // ---------------------------------------------------------
       
   794 // CCalcOutputSheet::HandleResourceChangeOutSheetL
       
   795 // Handles the events that needs to be taken care after resource change
       
   796 // (other items were commented in a header).
       
   797 // ---------------------------------------------------------
       
   798 //
       
   799 void CCalcOutputSheet::HandleResourceChangeOutSheetL(TInt aType)
       
   800 
       
   801 {
       
   802   
       
   803     if ( aType == KEikDynamicLayoutVariantSwitch )
       
   804         {
       
   805         if (AknLayoutUtils::PenEnabled())
       
   806             {
       
   807             ScrollToBottomL();
       
   808             }
       
   809         }
       
   810     if ( aType == KAknsMessageSkinChange )
       
   811         {
       
   812         if (AknLayoutUtils::PenEnabled())
       
   813             {
       
   814             delete (iSBFrame);
       
   815             iSBFrame = NULL;
       
   816 
       
   817             UpdateScrollIndicatorL();
       
   818             }
       
   819         }
       
   820 }
       
   821 //  End of File