uifw/EikStd/dlgsrc/EIKDPAGE.CPP
branchRCL_3
changeset 20 d48ab3b357f1
parent 19 aecbbf00d063
child 21 978afdc0236f
equal deleted inserted replaced
19:aecbbf00d063 20:d48ab3b357f1
    54 #include "aknformphysics.h"
    54 #include "aknformphysics.h"
    55 #include "aknrecordinggc.h"
    55 #include "aknrecordinggc.h"
    56 #include <aknphysics.h>
    56 #include <aknphysics.h>
    57 #include <aknappui.h>
    57 #include <aknappui.h>
    58 #include <AknPriv.hrh>
    58 #include <AknPriv.hrh>
    59 
    59 #include "akntrace.h"
    60 //
    60 //
    61 // Global constants.
    61 // Global constants.
    62 //
    62 //
    63 
    63 
    64 const TInt KSpaceFromTitle=0 ; 
    64 const TInt KSpaceFromTitle=0 ; 
    92 NONSHARABLE_CLASS(CDialogPageExtension) : public CBase
    92 NONSHARABLE_CLASS(CDialogPageExtension) : public CBase
    93     {
    93     {
    94 public:
    94 public:
    95     enum TFlags
    95     enum TFlags
    96         {
    96         {
    97         ELineHandlerCalled
    97         ELineHandlerCalled,
       
    98         EDragEventsAllowed  // turned on when dragging is allowed
    98         };
    99         };
    99     static CDialogPageExtension* NewL();
   100     static CDialogPageExtension* NewL();
   100     ~CDialogPageExtension();
   101     ~CDialogPageExtension();
   101 
   102 
   102     void Feedback( CEikDialogPage* aControl, TTouchLogicalFeedback aFeedback ) const;
   103     void Feedback( const CEikDialogPage& aControl,
       
   104                    TTouchLogicalFeedback aFeedback ) const;
       
   105 
   103     /**
   106     /**
   104      * Produces vibra-only feedback. Event filtering by pointer event is used..
   107      * Produces vibra-only feedback.
       
   108      * Event filtering by pointer event is used.
   105      */
   109      */
   106     void SilentFeedback( CEikDialogPage* aDPage, 
   110     void SilentFeedback( const CEikDialogPage& aDPage, 
   107                          TTouchLogicalFeedback aFeedback, 
   111                          TTouchLogicalFeedback aFeedback, 
   108                          const TPointerEvent& aPointerEvent ) const;
   112                          const TPointerEvent& aPointerEvent ) const;
   109     
   113 
   110     void HandleFormFeedback( CEikDialogPage* aControl, const TPointerEvent& aPointerEvent, TInt aTouchedLineIndex, TInt aCurrentLine );
   114     /**
       
   115      * Produces feedback in cases where the captioned control itself
       
   116      * doesn't do it.
       
   117      */
       
   118     void HandleFormFeedback( const CEikDialogPage& aDPage,
       
   119                              const TPointerEvent& aPointerEvent,
       
   120                              TInt aTouchedLineIndex,
       
   121                              TInt aCurrentLine );
   111 
   122 
   112 protected:  
   123 protected:  
   113     void ConstructL();
   124     void ConstructL();
   114     
   125     
   115 private:
   126 private:
   119 public: 
   130 public: 
   120     TInt iPopFieldEvents;    
   131     TInt iPopFieldEvents;    
   121     TBool iExternalScrollbar;
   132     TBool iExternalScrollbar;
   122     TBool iIsDoubleQuery;
   133     TBool iIsDoubleQuery;
   123     TBool iFocusedClicked;
   134     TBool iFocusedClicked;
   124     TInt iPreviousThumbPosition;
       
   125     TBool iPreviousThumbDirection;
   135     TBool iPreviousThumbDirection;
   126     MTouchFeedback* iFeedback;
   136     MTouchFeedback* iFeedback;
   127     TBitFlags iFlags;
   137     TBitFlags iFlags;
   128     /**
   138     /**
   129     * @c iDestroyedPtr is used for the object destruction check.
   139     * @c iDestroyedPtr is used for the object destruction check.
   139     TBool iHandlingScrollEvent;
   149     TBool iHandlingScrollEvent;
   140     CPeriodic* iHighlightTimer;
   150     CPeriodic* iHighlightTimer;
   141     TInt iLastTouchedLine;
   151     TInt iLastTouchedLine;
   142     TPoint iSynchronizedPosition;
   152     TPoint iSynchronizedPosition;
   143     TBool iScrolling;
   153     TBool iScrolling;
   144     TBool iScrolled;
       
   145     TBool iInitialLayoutDone;
   154     TBool iInitialLayoutDone;
       
   155     TBool iSetInitialFocusDone;
   146     TBool iHandlingResourceChange;
   156     TBool iHandlingResourceChange;
   147     TInt iCapturingItem;
   157     TInt iCapturingItem;
   148     // record the center point Y value of current view when touch down an item
   158     // record the center point Y value of current view when touch down an item
   149     TInt iOldCenterY;
   159     TInt iOldCenterY;
   150     // top item in current view, -1 if item's Y is negative
   160     // top item in current view, -1 if item's Y is negative
   157      * Boolean used to check if application is single touch compatible.
   167      * Boolean used to check if application is single touch compatible.
   158      */
   168      */
   159     TBool iUsesSingleClick;
   169     TBool iUsesSingleClick;
   160     // It is used to distinguish if the focus item has changed.
   170     // It is used to distinguish if the focus item has changed.
   161     TBool iFocusItemChanged;
   171     TBool iFocusItemChanged;
       
   172     // Boolean to check if form was scrolling on button down
       
   173     TBool iWasScrolling;
   162     };
   174     };
   163 
   175 
   164 CDialogPageExtension::CDialogPageExtension()
   176 CDialogPageExtension::CDialogPageExtension()
   165     {
   177     {
   166     }
   178     }
   198     iHighlightTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   210     iHighlightTimer = CPeriodic::NewL( CActive::EPriorityStandard );
   199     iCapturingItem = KErrNotFound;
   211     iCapturingItem = KErrNotFound;
   200     }
   212     }
   201 
   213 
   202 void CDialogPageExtension::HandleFormFeedback(
   214 void CDialogPageExtension::HandleFormFeedback(
   203     CEikDialogPage* aDPage,
   215     const CEikDialogPage& aDPage,
   204     const TPointerEvent& aPointerEvent,
   216     const TPointerEvent& aPointerEvent,
   205     TInt aTouchedLineIndex,
   217     TInt aTouchedLineIndex,
   206     TInt aCurrentLine )
   218     TInt aCurrentLine )
   207     {
   219     {
   208     // note, that iFormControl is checked in Feedback()
   220     CEikCaptionedControl* firstLine( aDPage.LineOnPageOrNull( 0 ) );
   209     if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
   221     
   210         aCurrentLine != aTouchedLineIndex && aDPage->LineOnPageOrNull( 0 ) ) 
   222     if( aDPage.IsEditable() )
   211         {
   223         {
   212         // feedback for edit/view mode form, when non-focused line is clicked
   224         // note, that iFormControl is checked in Feedback()
   213         // feedback for focused item is responsibility of the item
   225         if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
   214         // no feedback with focus change when single click is enabled
   226              aCurrentLine != aTouchedLineIndex &&
   215         if ( !iUsesSingleClick )
   227              firstLine ) 
   216             {
   228             {
   217             Feedback( aDPage, ETouchFeedbackSensitiveItem );
   229             // feedback for edit mode form, when non-focused line is clicked
   218             }
   230             // feedback for focused item is responsibility of the item
   219         iFocusItemChanged = ETrue;
   231             // no feedback with focus change when single click is enabled
   220         }
   232             if ( !iUsesSingleClick )
   221 
   233                 {
   222     else if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
   234                 Feedback( aDPage, ETouchFeedbackSensitiveList );
   223         aTouchedLineIndex == aCurrentLine && aDPage->LineOnPageOrNull( 0 ) )
   235                 }
   224         {
   236             iFocusItemChanged = ETrue;
   225         // Feedback for view mode form, when focused item is
   237             }
   226         // clicked. Basically same case as for msk simulation later on
   238         else if ( firstLine )
   227         // the function, but on pointer
   239             {
   228         // down. iExtension->iFocusedClicked is not valid here, since
   240             if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
   229         // it can't be known in this phase whether user drags pointer
   241                  aTouchedLineIndex == aCurrentLine )
   230         // away.
   242                 {
   231         Feedback( aDPage, ETouchFeedbackBasicItem );
   243                 // Feedback for edit mode form, when focused item is
   232         iFocusItemChanged = EFalse;
   244                 // clicked. Basically same case as for msk simulation later on
   233         }
   245                 // the function, but on pointer
   234 
   246                 // down. iExtension->iFocusedClicked is not valid here, since
   235     else if ( aPointerEvent.iType == TPointerEvent::EButton1Up &&
   247                 // it can't be known in this phase whether user drags pointer
   236             aDPage->LineOnPageOrNull( 0 ) )
   248                 // away.
   237         {// when focus changed, it should not send feedback on up event.
   249                 Feedback( aDPage, ETouchFeedbackList );
   238         //when up event comes, aTouchedLineIndex always equal to aCurrentLine
   250                 iFocusItemChanged = EFalse;
   239         if ( !iFocusItemChanged )
   251                 }
   240             {
   252             else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   241             SilentFeedback( aDPage, ETouchFeedbackBasicItem, aPointerEvent );
   253                 {
   242             }
   254                 // When focus changed, it should not send feedback on up event.
   243         }
   255                 // When up event comes, aTouchedLineIndex always equal to
   244     }
   256                 // aCurrentLine.
   245 
   257                 if ( !iFocusItemChanged )
   246 void CDialogPageExtension::Feedback( CEikDialogPage* aDPage, 
   258                     {
       
   259                     SilentFeedback( aDPage, ETouchFeedbackList, aPointerEvent );
       
   260                     }
       
   261                 }
       
   262             }
       
   263         }
       
   264     }
       
   265 
       
   266 
       
   267 void CDialogPageExtension::Feedback( const CEikDialogPage& aDPage, 
   247                                      TTouchLogicalFeedback aFeedback ) const
   268                                      TTouchLogicalFeedback aFeedback ) const
   248     {
   269     {
   249     if ( aDPage
   270     if ( iFeedback &&
   250         && aDPage->IsForm()
   271          aDPage.IsForm() &&
   251         && iFeedback
   272          !aDPage.IsDimmed() &&
   252         && !aDPage->IsDimmed()
   273          aDPage.IsVisible() )
   253         && aDPage->IsVisible() )
       
   254         {
   274         {
   255         iFeedback->InstantFeedback( aFeedback );
   275         iFeedback->InstantFeedback( aFeedback );
   256         }
   276         }
   257     }
   277     }
   258 
   278 
   259 void CDialogPageExtension::SilentFeedback( CEikDialogPage* aDPage, 
   279 
   260                                            TTouchLogicalFeedback aFeedback, 
   280 void CDialogPageExtension::SilentFeedback(
   261                                            const TPointerEvent& aPointerEvent ) const
   281     const CEikDialogPage& aDPage,
   262     {
   282     TTouchLogicalFeedback aFeedback,
   263     if ( aDPage
   283     const TPointerEvent& aPointerEvent ) const
   264         && aDPage->IsForm()
   284     {
   265         && iFeedback
   285     if ( iFeedback &&
   266         && !aDPage->IsDimmed()
   286          aDPage.IsForm() &&
   267         && aDPage->IsVisible() )
   287          !aDPage.IsDimmed() &&
   268         {
   288          aDPage.IsVisible() )
   269         iFeedback->InstantFeedback( aDPage, aFeedback, ETouchFeedbackVibra, aPointerEvent );
   289         {
   270         }
   290         iFeedback->InstantFeedback( &aDPage,
   271     }
   291                                     aFeedback,
       
   292                                     ETouchFeedbackVibra,
       
   293                                     aPointerEvent );
       
   294         }
       
   295     }
       
   296 
   272 
   297 
   273 class CAknPaneScroll : public CBase
   298 class CAknPaneScroll : public CBase
   274 {
   299 {
   275 public:
   300 public:
   276     enum TScrollChangeType
   301     enum TScrollChangeType
   330 // CEikDialogPage.
   355 // CEikDialogPage.
   331 //
   356 //
   332 
   357 
   333 CEikDialogPage::~CEikDialogPage()
   358 CEikDialogPage::~CEikDialogPage()
   334     {
   359     {
       
   360 	_AKNTRACE_FUNC_ENTER;
   335     AKNTASHOOK_REMOVE();
   361     AKNTASHOOK_REMOVE();
   336     // Page observer needs to be nulled or an already deleted instance is
   362     // Page observer needs to be nulled or an already deleted instance is
   337     // called when pointer up event is handled. This is valid only for dialogs
   363     // called when pointer up event is handled. This is valid only for dialogs
   338     // that have embedded virtual inputs.
   364     // that have embedded virtual inputs.
   339     iPageObserver = NULL;
   365     iPageObserver = NULL;
   340     delete iPhysics;
   366     delete iPhysics;
   341     delete iLines;
   367     delete iLines;
   342     delete iScroll;    
   368     delete iScroll;    
   343     delete iExtension;
   369     delete iExtension;
       
   370     _AKNTRACE_FUNC_EXIT;
   344     }
   371     }
   345 
   372 
   346 CEikDialogPage* CEikDialogPage::NewL(TInt aPageId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,const CEikDialogPageContainer& aParent,MEikDialogPageObserver* aPageObserver)
   373 CEikDialogPage* CEikDialogPage::NewL(TInt aPageId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,const CEikDialogPageContainer& aParent,MEikDialogPageObserver* aPageObserver)
   347     {
   374     {
       
   375 	_AKNTRACE_FUNC_ENTER;
   348     CEikDialogPage* self=CEikDialogPage::NewLC(aPageId,aViewWin,aSBFrame,aParent,aPageObserver);
   376     CEikDialogPage* self=CEikDialogPage::NewLC(aPageId,aViewWin,aSBFrame,aParent,aPageObserver);
   349     CleanupStack::Pop();
   377     CleanupStack::Pop();
       
   378     _AKNTRACE_FUNC_EXIT;
   350     return self;
   379     return self;
   351     }
   380     }
   352 
   381 
   353 void CEikDialogPage::CommonConstructCodeBetweenNewL(CEikDialogPage& aDialogPage, const CEikDialogPageContainer& aParent)
   382 void CEikDialogPage::CommonConstructCodeBetweenNewL(CEikDialogPage& aDialogPage, const CEikDialogPageContainer& aParent)
   354     {
   383     {
   362     aDialogPage.CopyControlContextFrom(&aParent);
   391     aDialogPage.CopyControlContextFrom(&aParent);
   363     };
   392     };
   364 
   393 
   365 CEikDialogPage* CEikDialogPage::NewLC(TInt aPageId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,const CEikDialogPageContainer& aParent,MEikDialogPageObserver* aPageObserver)
   394 CEikDialogPage* CEikDialogPage::NewLC(TInt aPageId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,const CEikDialogPageContainer& aParent,MEikDialogPageObserver* aPageObserver)
   366     {
   395     {
       
   396 	_AKNTRACE_FUNC_ENTER;
   367     CEikDialogPage* self=new(ELeave) CEikDialogPage(aPageId,aViewWin,aSBFrame,aPageObserver);
   397     CEikDialogPage* self=new(ELeave) CEikDialogPage(aPageId,aViewWin,aSBFrame,aPageObserver);
   368     CleanupStack::PushL(self);
   398     CleanupStack::PushL(self);
   369     CommonConstructCodeBetweenNewL(*self,aParent); 
   399     CommonConstructCodeBetweenNewL(*self,aParent); 
   370     AKNTASHOOK_ADDL( self, "CEikDialogPage" );
   400     AKNTASHOOK_ADDL( self, "CEikDialogPage" );
       
   401     _AKNTRACE_FUNC_EXIT;
   371     return self;
   402     return self;
   372     }
   403     }
   373 
   404 
   374 CEikDialogPage* CEikDialogPage::NewL(TInt aPageId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,const CEikDialogPageContainer& aParent,MEikDialogPageObserver* aPageObserver,TResourceReader& aReader)
   405 CEikDialogPage* CEikDialogPage::NewL(TInt aPageId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,const CEikDialogPageContainer& aParent,MEikDialogPageObserver* aPageObserver,TResourceReader& aReader)
   375     {
   406     {
       
   407 	_AKNTRACE_FUNC_ENTER;
   376     CEikDialogPage* self=CEikDialogPage::NewLC(aPageId,aViewWin,aSBFrame,aParent,aPageObserver,aReader);
   408     CEikDialogPage* self=CEikDialogPage::NewLC(aPageId,aViewWin,aSBFrame,aParent,aPageObserver,aReader);
   377     CleanupStack::Pop();
   409     CleanupStack::Pop();
       
   410     _AKNTRACE_FUNC_EXIT;
   378     return self;
   411     return self;
   379     }
   412     }
   380 
   413 
   381 CEikDialogPage* CEikDialogPage::NewLC(TInt aPageId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,const CEikDialogPageContainer& aParent,MEikDialogPageObserver* aPageObserver,TResourceReader& aReader)
   414 CEikDialogPage* CEikDialogPage::NewLC(TInt aPageId,RWindow& aViewWin,CEikScrollBarFrame& aSBFrame,const CEikDialogPageContainer& aParent,MEikDialogPageObserver* aPageObserver,TResourceReader& aReader)
   382     {
   415     {
       
   416 	_AKNTRACE_FUNC_ENTER;
   383     CEikDialogPage* self=new(ELeave) CEikDialogPage(aPageId,aViewWin,aSBFrame,aPageObserver);
   417     CEikDialogPage* self=new(ELeave) CEikDialogPage(aPageId,aViewWin,aSBFrame,aPageObserver);
   384     CleanupStack::PushL(self);
   418     CleanupStack::PushL(self);
   385     CommonConstructCodeBetweenNewL(*self,aParent);
   419     CommonConstructCodeBetweenNewL(*self,aParent);
   386     self->ConstructFromResourceL(aReader);
   420     self->ConstructFromResourceL(aReader);
   387     AKNTASHOOK_ADDL( self, "CEikDialogPage" );
   421     AKNTASHOOK_ADDL( self, "CEikDialogPage" );
       
   422     _AKNTRACE_FUNC_EXIT;
   388     return self;
   423     return self;
   389     }
   424     }
   390 
   425 
   391 CEikDialogPage::CEikDialogPage(TInt aPageId,RWindow& /*aViewWin*/,
   426 CEikDialogPage::CEikDialogPage(TInt aPageId,RWindow& /*aViewWin*/,
   392     CEikScrollBarFrame& /*aSBFrame*/,MEikDialogPageObserver* aPageObserver)
   427     CEikScrollBarFrame& /*aSBFrame*/,MEikDialogPageObserver* aPageObserver)
   393     : iPageObserver(aPageObserver),
   428     : iPageObserver(aPageObserver),
   394         iPageId(aPageId),iCurrentLine(-1)
   429         iPageId(aPageId),iCurrentLine(-1)
   395     {
   430     {
       
   431 	_AKNTRACE_FUNC_ENTER;
   396     SetBlank();
   432     SetBlank();
   397     SetComponentsToInheritVisibility();
   433     SetComponentsToInheritVisibility();
       
   434     _AKNTRACE_FUNC_EXIT;
   398     }
   435     }
   399 
   436 
   400 void CEikDialogPage::ConstructL()
   437 void CEikDialogPage::ConstructL()
   401     {
   438     {
       
   439 	_AKNTRACE_FUNC_ENTER;
   402     iLines=new(ELeave)CEikCapCArray(KLineArrayGranularity);
   440     iLines=new(ELeave)CEikCapCArray(KLineArrayGranularity);
   403     SetContainerWindowL( *iPageContainer );
   441     SetContainerWindowL( *iPageContainer );
   404     Window().SetPointerGrab(ETrue); 
   442     Window().SetPointerGrab(ETrue); 
   405     Window().SetShadowDisabled(ETrue);
   443     Window().SetShadowDisabled(ETrue);
   406     Window().SetBackgroundColor(iEikonEnv->ControlColor(EColorDialogBackground,*this));
   444     Window().SetBackgroundColor(iEikonEnv->ControlColor(EColorDialogBackground,*this));
   407     iScroll = new(ELeave)CAknPaneScroll(this);
   445     iScroll = new(ELeave)CAknPaneScroll(this);
   408     iScroll->SetLines(iLines);
   446     iScroll->SetLines(iLines);
   409     iExtension = CDialogPageExtension::NewL();
   447     iExtension = CDialogPageExtension::NewL();
       
   448     _AKNTRACE_FUNC_EXIT;
   410     }
   449     }
   411 
   450 
   412 void CEikDialogPage::ConstructFromResourceL(TResourceReader& aReader, TBool aFormControl )
   451 void CEikDialogPage::ConstructFromResourceL(TResourceReader& aReader, TBool aFormControl )
   413     {
   452     {
       
   453 	_AKNTRACE_FUNC_ENTER;
   414     iFormControl = aFormControl ;
   454     iFormControl = aFormControl ;
   415 
   455 
   416     if ( IsForm() )
   456     if ( IsForm() )
   417         {
   457         {
   418         if ( iAvkonAppUi )
   458         if ( iAvkonAppUi )
   433             return;
   473             return;
   434         TResourceReader indirectReader;
   474         TResourceReader indirectReader;
   435         iCoeEnv->CreateResourceReaderLC(indirectReader,indirectRid);
   475         iCoeEnv->CreateResourceReaderLC(indirectReader,indirectRid);
   436         ConstructFromResourceL(indirectReader);
   476         ConstructFromResourceL(indirectReader);
   437         CleanupStack::PopAndDestroy();
   477         CleanupStack::PopAndDestroy();
       
   478         _AKNTRACE_FUNC_EXIT;
   438         return;
   479         return;
   439         }
   480         }
   440 
   481 
   441     // This section modified to handle FORM structure (which contains DIALOG_LINE structs )
   482     // This section modified to handle FORM structure (which contains DIALOG_LINE structs )
   442     // There might be lines on the page already
   483     // There might be lines on the page already
   452         iLines->AppendL(thisLine);
   493         iLines->AppendL(thisLine);
   453         CleanupStack::Pop(); // thisLine
   494         CleanupStack::Pop(); // thisLine
   454         thisLine->iIsFormControl = aFormControl ;
   495         thisLine->iIsFormControl = aFormControl ;
   455         if ( aFormControl )
   496         if ( aFormControl )
   456             {
   497             {
   457             thisLine->GetAknLayoutValuesL() ;   // should cause the control to have size.
       
   458             if ( iFormFlags )
   498             if ( iFormFlags )
   459             thisLine->SetFormFlags( iFormFlags ) ;
   499             thisLine->SetFormFlags( iFormFlags ) ;
   460             }       
   500             }       
   461 // allow the caption to know the one above itself
   501 // allow the caption to know the one above itself
   462         AfterAddingNewLinesL(iLines->LineIndexFromId(thisLine->iId));
   502         AfterAddingNewLinesL(iLines->LineIndexFromId(thisLine->iId));
   466     if (!iScroll)
   506     if (!iScroll)
   467         {
   507         {
   468         iScroll = new(ELeave)CAknPaneScroll(this);
   508         iScroll = new(ELeave)CAknPaneScroll(this);
   469         }
   509         }
   470     iScroll->SetLines(iLines);
   510     iScroll->SetLines(iLines);
       
   511     _AKNTRACE_FUNC_EXIT;
   471     }
   512     }
   472 
   513 
   473 void CEikDialogPage::ConstructFormFromResourceL( TResourceReader& aReader ) 
   514 void CEikDialogPage::ConstructFormFromResourceL( TResourceReader& aReader ) 
   474     {
   515     {
       
   516 	_AKNTRACE_FUNC_ENTER;
   475     iFormFlags = TInt16(aReader.ReadInt16()) ;
   517     iFormFlags = TInt16(aReader.ReadInt16()) ;
   476     iFormLayout = (iFormFlags&EEikFormUseDoubleSpacedFormat) ? EDouble : ESingle;
   518     iFormLayout = (iFormFlags&EEikFormUseDoubleSpacedFormat) ? EDouble : ESingle;
   477     ConstructFromResourceL( aReader, ETrue ) ;
   519     ConstructFromResourceL( aReader, ETrue ) ;
       
   520     _AKNTRACE_FUNC_EXIT;
   478     }
   521     }
   479 
   522 
   480 CCoeControl* CEikDialogPage::CreateLineByTypeL(const TDesC& aCaption,TInt aLineId,TInt aControlType,TAny* aReturnValue)
   523 CCoeControl* CEikDialogPage::CreateLineByTypeL(const TDesC& aCaption,TInt aLineId,TInt aControlType,TAny* aReturnValue)
   481     {
   524     {
       
   525 	_AKNTRACE_FUNC_ENTER;
   482     ShowFocus( EFalse, EFalse ) ;  // Turn the focus off the current line.  
   526     ShowFocus( EFalse, EFalse ) ;  // Turn the focus off the current line.  
   483     CEikCaptionedControl* line=new(ELeave) CEikCaptionedControl;
   527     CEikCaptionedControl* line=new(ELeave) CEikCaptionedControl;
   484     CleanupStack::PushL(line);
   528     CleanupStack::PushL(line);
   485     line->SetComponentsToInheritVisibility();
   529     line->SetComponentsToInheritVisibility();
   486     // Try to insert line above the currently selected line.  If no line is currently selected then append (TimW 22/5/00)
   530     // Try to insert line above the currently selected line.  If no line is currently selected then append (TimW 22/5/00)
   512 
   556 
   513     ChangeFocusTo( targetLine );
   557     ChangeFocusTo( targetLine );
   514 
   558 
   515     // physics engine needs to be updated when lines are added after the initial layout
   559     // physics engine needs to be updated when lines are added after the initial layout
   516     UpdatePhysics();
   560     UpdatePhysics();
   517 
   561     _AKNTRACE_FUNC_EXIT;
   518     return line->iControl;
   562     return line->iControl;
   519     }
   563     }
   520 
   564 
   521 CEikCaptionedControl* CEikDialogPage::ConstructLineL(TInt aResourceId)
   565 CEikCaptionedControl* CEikDialogPage::ConstructLineL(TInt aResourceId)
   522     {
   566     {
       
   567 	_AKNTRACE_FUNC_ENTER;
   523     TResourceReader resourceReader;
   568     TResourceReader resourceReader;
   524     iCoeEnv->CreateResourceReaderLC(resourceReader,aResourceId);
   569     iCoeEnv->CreateResourceReaderLC(resourceReader,aResourceId);
   525     CEikCaptionedControl* line=ConstructLineL(resourceReader);
   570     CEikCaptionedControl* line=ConstructLineL(resourceReader);
   526     CleanupStack::PopAndDestroy(); // resourceReader
   571     CleanupStack::PopAndDestroy(); // resourceReader
       
   572     _AKNTRACE_FUNC_EXIT;
   527     return line;
   573     return line;
   528     }
   574     }
   529 
   575 
   530 CEikCaptionedControl* CEikDialogPage::ConstructLineL(TResourceReader& aReader)
   576 CEikCaptionedControl* CEikDialogPage::ConstructLineL(TResourceReader& aReader)
   531     {
   577     {
       
   578 	_AKNTRACE_FUNC_ENTER;
   532     CEikCaptionedControl* line=new(ELeave) CEikCaptionedControl;
   579     CEikCaptionedControl* line=new(ELeave) CEikCaptionedControl;
   533     CleanupStack::PushL(line);
   580     CleanupStack::PushL(line);
   534     line->iIsFormControl=iFormControl; 
   581     line->iIsFormControl=iFormControl; 
   535     line->SetComponentsToInheritVisibility();
   582     line->SetComponentsToInheritVisibility();
   536     TInt controlType=aReader.ReadInt16();
   583     TInt controlType=aReader.ReadInt16();
   548     ConstructByTypeL(controlType,line,this);
   595     ConstructByTypeL(controlType,line,this);
   549     line->ConstructFromResourceL(*reader);
   596     line->ConstructFromResourceL(*reader);
   550     if (indirectRid)
   597     if (indirectRid)
   551         CleanupStack::PopAndDestroy();
   598         CleanupStack::PopAndDestroy();
   552     CleanupStack::Pop(); // line
   599     CleanupStack::Pop(); // line
       
   600     _AKNTRACE_FUNC_EXIT;
   553     return line;
   601     return line;
   554     }
   602     }
   555 
   603 
   556 void CEikDialogPage::ConstructByTypeL(TInt aType,CEikCaptionedControl* aLine,CCoeControl* aContainer)
   604 void CEikDialogPage::ConstructByTypeL(TInt aType,CEikCaptionedControl* aLine,CCoeControl* aContainer)
   557     {
   605     {
       
   606 	_AKNTRACE_FUNC_ENTER;
   558     SEikControlInfo controlInfo=EikControlFactory::CreateByTypeL(aType);
   607     SEikControlInfo controlInfo=EikControlFactory::CreateByTypeL(aType);
   559     if (!controlInfo.iControl)
   608     if (!controlInfo.iControl)
   560         controlInfo=CreateCustomControlL(aType);
   609         controlInfo=CreateCustomControlL(aType);
   561     aLine->iIsFormControl=iFormControl; 
   610     aLine->iIsFormControl=iFormControl; 
   562     aLine->iControl=controlInfo.iControl;
   611     aLine->iControl=controlInfo.iControl;
   586         {
   635         {
   587         HBufC* tmp=iCoeEnv->AllocReadResourceLC(controlInfo.iTrailerTextId);
   636         HBufC* tmp=iCoeEnv->AllocReadResourceLC(controlInfo.iTrailerTextId);
   588         aLine->SetTrailerL(tmp->Des());
   637         aLine->SetTrailerL(tmp->Des());
   589         CleanupStack::PopAndDestroy(); // tmp
   638         CleanupStack::PopAndDestroy(); // tmp
   590         }
   639         }
       
   640     _AKNTRACE_FUNC_EXIT;
   591     }
   641     }
   592 
   642 
   593 SEikControlInfo CEikDialogPage::CreateCustomControlL(TInt aControlType)
   643 SEikControlInfo CEikDialogPage::CreateCustomControlL(TInt aControlType)
   594     {
   644     {
   595     ASSERT(iPageObserver);
   645     ASSERT(iPageObserver);
   596     return iPageObserver->CreateCustomControlL(aControlType);
   646     return iPageObserver->CreateCustomControlL(aControlType);
   597     }
   647     }
   598 
   648 
   599 void CEikDialogPage::SetActiveL()
   649 void CEikDialogPage::SetActiveL()
   600     {
   650     {
       
   651 	_AKNTRACE_FUNC_ENTER;
   601     ActivateL();
   652     ActivateL();
   602     MakeVisible(ETrue);        
   653     MakeVisible(ETrue);        
   603     
   654     
   604     if(AknLayoutUtils::PenEnabled())
   655     if(AknLayoutUtils::PenEnabled())
   605     {
   656     {
   631         AknsUtils::RegisterControlPosition(capCtrl->iCaption);
   682         AknsUtils::RegisterControlPosition(capCtrl->iCaption);
   632         AknsUtils::RegisterControlPosition(capCtrl->iControl);
   683         AknsUtils::RegisterControlPosition(capCtrl->iControl);
   633         AknsUtils::RegisterControlPosition(capCtrl->iTrailer);
   684         AknsUtils::RegisterControlPosition(capCtrl->iTrailer);
   634         AknsUtils::RegisterControlPosition(capCtrl->iBitmap);
   685         AknsUtils::RegisterControlPosition(capCtrl->iBitmap);
   635 
   686 
   636     if ( capCtrl->iIsFormControl && iCurrentLine != i)
   687         if ( capCtrl->iIsFormControl && iCurrentLine != i)
   637         {
   688             {
   638 
   689             if (capCtrl->ControlIsAnEdwin(capCtrl->iControlType))
   639         if (capCtrl->ControlIsAnEdwin(capCtrl->iControlType))
   690                 {
   640             {
   691                 CEikEdwin *edwin = (CEikEdwin*)capCtrl->iControl;
   641             CEikEdwin *edwin = (CEikEdwin*)capCtrl->iControl;
   692                 TRAP_IGNORE( edwin->TextView()->SetDocPosL( 0 ) );
   642             TRAP_IGNORE(edwin->TextView()->SetDocPosL(0)
   693                 }
   643                 );
   694             }
   644             }
   695         }
   645        }
   696     
   646 
   697     _AKNTRACE_FUNC_EXIT;
   647         }
       
   648     }
   698     }
   649 
   699 
   650 void CEikDialogPage::SetActiveAndFocusL()
   700 void CEikDialogPage::SetActiveAndFocusL()
   651     {
   701     {
       
   702 	_AKNTRACE_FUNC_ENTER;
   652     SetActiveL();
   703     SetActiveL();
   653     SetEditableL(iIsEditable, ETrue);
   704     SetEditableL(iIsEditable, ETrue);
   654     //When active a page, need to show the focus in that page.
   705     //When active a page, need to show the focus in that page.
   655     ShowFocus( ETrue, EFalse ) ;
   706     ShowFocus( ETrue, EFalse ) ;
   656     // Display the focus on the current line 
   707     // Display the focus on the current line 
   659         SetInitialFocus() ;
   710         SetInitialFocus() ;
   660         }
   711         }
   661     
   712     
   662     ExposeLine( iCurrentLine, EFalse );
   713     ExposeLine( iCurrentLine, EFalse );
   663     UpdateScrollBarL();
   714     UpdateScrollBarL();
       
   715     _AKNTRACE_FUNC_EXIT;
   664     }
   716     }
   665 
   717 
   666 void CEikDialogPage::SetInactiveL()
   718 void CEikDialogPage::SetInactiveL()
   667     {
   719     {
       
   720 	_AKNTRACE_FUNC_ENTER;
   668     MakeEdwinScrollbarsVisibleL(EFalse);
   721     MakeEdwinScrollbarsVisibleL(EFalse);
   669     MakeVisible(EFalse);
   722     MakeVisible(EFalse);
       
   723     _AKNTRACE_FUNC_EXIT;
   670     }
   724     }
   671 
   725 
   672 void CEikDialogPage::MakeEdwinScrollbarsVisibleL(TBool aVisible)
   726 void CEikDialogPage::MakeEdwinScrollbarsVisibleL(TBool aVisible)
   673     {
   727     {
       
   728 	_AKNTRACE_FUNC_ENTER;
   674     const TInt numLines=iLines->Count();
   729     const TInt numLines=iLines->Count();
   675     for (TInt ii=0;ii<numLines;ii++)
   730     for (TInt ii=0;ii<numLines;ii++)
   676         {
   731         {
   677         CEikCaptionedControl* thisLine=(*iLines)[ii];
   732         CEikCaptionedControl* thisLine=(*iLines)[ii];
   678         const TInt controlType(thisLine->iControlType);
   733         const TInt controlType(thisLine->iControlType);
   688                 for (TInt jj=0;jj<count;jj++)
   743                 for (TInt jj=0;jj<count;jj++)
   689                     frame->ComponentControl(jj)->MakeVisible(aVisible);
   744                     frame->ComponentControl(jj)->MakeVisible(aVisible);
   690                 }
   745                 }
   691             }
   746             }
   692         }
   747         }
       
   748     _AKNTRACE_FUNC_EXIT;
   693     }
   749     }
   694 
   750 
   695 TInt CEikDialogPage::PageId() const
   751 TInt CEikDialogPage::PageId() const
   696     {
   752     {
   697     return iPageId;
   753     return iPageId;
   706     return KErrNotFound;
   762     return KErrNotFound;
   707     }
   763     }
   708 
   764 
   709 TBool CEikDialogPage::SetInitialFocus()
   765 TBool CEikDialogPage::SetInitialFocus()
   710     {
   766     {
       
   767 	_AKNTRACE_FUNC_ENTER;
   711     TBool focusSet=EFalse;
   768     TBool focusSet=EFalse;
   712 
   769 
   713     const TInt numLines=iLines->Count();
   770     const TInt numLines=iLines->Count();
   714     for (TInt ii=0;ii<numLines;ii++)
   771     for (TInt ii=0;ii<numLines;ii++)
   715         {
   772         {
   716         CEikCaptionedControl* line=(*iLines)[ii];
   773         CEikCaptionedControl* line=(*iLines)[ii];
   717         if (line->IsNonFocusing() || line->IsDimmed() || !(line->IsVisible()))
   774         if (line->IsNonFocusing() || line->IsDimmed() || !(line->IsVisible()))
   718             continue;
   775             continue;
   719         ChangeFocusTo(ii);
   776         ChangeFocusTo(ii);
   720         focusSet=ETrue;
   777         focusSet=ETrue;
   721         
       
   722         if ( IsForm() )
       
   723             {
       
   724             // move line with initial focus to the screen
       
   725     		iLines->MoveLineToScreen( ii, iPhysics->ViewTopY(), ETrue );
       
   726             }
       
   727         break;
   778         break;
   728         }
   779         }
   729 
   780     iExtension->iSetInitialFocusDone = ETrue;
       
   781     _AKNTRACE( "return focusSet;: [%d]", focusSet );
       
   782     _AKNTRACE_FUNC_EXIT;
   730     return focusSet;
   783     return focusSet;
   731     }
   784     }
   732 
   785 
   733 TKeyResponse CEikDialogPage::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
   786 TKeyResponse CEikDialogPage::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
   734     {
   787     {
       
   788 	_AKNTRACE_FUNC_ENTER;
   735     TKeyResponse response=EKeyWasNotConsumed;
   789     TKeyResponse response=EKeyWasNotConsumed;
   736 
   790 
   737     if (!(PageContainer()->PageSelector()->Dialg()->DialogFlags() & EEikDialogFlagDontEatUpDownEvents))
   791     if (!(PageContainer()->PageSelector()->Dialg()->DialogFlags() & EEikDialogFlagDontEatUpDownEvents))
   738         {
   792         {
   739         if (aType != EEventKey)
   793         if (aType != EEventKey)
   740         return response;
   794         	{
       
   795             _AKNTRACE_FUNC_EXIT;	
       
   796             return response;        
       
   797         	}
   741         }
   798         }
   742 
   799 
   743     const TInt numLines=iLines->Count();
   800     const TInt numLines=iLines->Count();
   744     if ((iCurrentLine>-1)&&(iCurrentLine<numLines))
   801     if ((iCurrentLine>-1)&&(iCurrentLine<numLines))
   745         {
   802         {
   759             || aKeyEvent.iCode==EKeyTab
   816             || aKeyEvent.iCode==EKeyTab
   760             || aKeyEvent.iCode==EKeyNext
   817             || aKeyEvent.iCode==EKeyNext
   761             || aKeyEvent.iCode==EKeyPrevious
   818             || aKeyEvent.iCode==EKeyPrevious
   762             ))
   819             ))
   763         response=OfferUpDownKeyEventL(aKeyEvent,aType,ENonCyclic);
   820         response=OfferUpDownKeyEventL(aKeyEvent,aType,ENonCyclic);
       
   821     _AKNTRACE_FUNC_EXIT;
   764     return response;
   822     return response;
   765     }
   823     }
   766 
   824 
   767 TKeyResponse CEikDialogPage::OfferUpDownKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType,TFocusNavigationMode aFocusNavigationMode)
   825 TKeyResponse CEikDialogPage::OfferUpDownKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType,TFocusNavigationMode aFocusNavigationMode)
   768     {
   826     {
       
   827 	_AKNTRACE_FUNC_ENTER;
   769     TKeyResponse response=EKeyWasNotConsumed;
   828     TKeyResponse response=EKeyWasNotConsumed;
   770     if (aType==EEventKey)
   829     if (aType==EEventKey)
   771         {
   830         {
   772         const TInt numLines=iLines->Count();
   831         const TInt numLines=iLines->Count();
   773         if ((iCurrentLine>-1)&&(iCurrentLine<numLines))
   832         if ((iCurrentLine>-1)&&(iCurrentLine<numLines))
   800             iExtension->iFocusedClicked = ETrue;
   859             iExtension->iFocusedClicked = ETrue;
   801             
   860             
   802             switch (aFocusNavigationMode)
   861             switch (aFocusNavigationMode)
   803                 {
   862                 {
   804                 case ECyclic:
   863                 case ECyclic:
   805                     iExtension->iScrolled = ETrue;                    
       
   806                     response=HandleCyclicFocusNavigationKeyL(aKeyEvent);
   864                     response=HandleCyclicFocusNavigationKeyL(aKeyEvent);
   807                     break;
   865                     break;
   808                     
   866                     
   809                 case ENonCyclic:
   867                 case ENonCyclic:
   810                     iExtension->iScrolled = ETrue;                    
       
   811                     response=HandleNonCyclicFocusNavigationKeyL(aKeyEvent);
   868                     response=HandleNonCyclicFocusNavigationKeyL(aKeyEvent);
   812                     break;
   869                     break;
   813                     
   870                     
   814                 default:
   871                 default:
   815                     break;
   872                     break;
   820             }
   877             }
   821         }
   878         }
   822 
   879 
   823     if (response==EKeyWasConsumed)
   880     if (response==EKeyWasConsumed)
   824         UpdateScrollBarThumb();
   881         UpdateScrollBarThumb();
   825 
   882     _AKNTRACE_FUNC_EXIT;
   826     return response;
   883     return response;
   827     }
   884     }
   828 
   885 
   829 TKeyResponse CEikDialogPage::HandleNonCyclicFocusNavigationKeyL(const TKeyEvent& aKeyEvent)
   886 TKeyResponse CEikDialogPage::HandleNonCyclicFocusNavigationKeyL(const TKeyEvent& aKeyEvent)
   830     {
   887     {
   929     return ownsLine;
   986     return ownsLine;
   930     }
   987     }
   931 
   988 
   932 void CEikDialogPage::SetDimmed(TBool aDimmed)
   989 void CEikDialogPage::SetDimmed(TBool aDimmed)
   933     {
   990     {
       
   991 	_AKNTRACE_FUNC_ENTER;
   934     CCoeControl::SetDimmed(aDimmed);
   992     CCoeControl::SetDimmed(aDimmed);
   935 
   993 
   936     const TInt numLines=iLines->Count();
   994     const TInt numLines=iLines->Count();
   937     for (TInt ii=0;ii<numLines;ii++)
   995     for (TInt ii=0;ii<numLines;ii++)
   938         {
   996         {
   939         CEikCaptionedControl* thisLine=(*iLines)[ii];
   997         CEikCaptionedControl* thisLine=(*iLines)[ii];
   940         thisLine->iControl->SetDimmed(aDimmed);
   998         thisLine->iControl->SetDimmed(aDimmed);
   941         thisLine->CheckDimmedDisplayState();
   999         thisLine->CheckDimmedDisplayState();
   942         }
  1000         }
       
  1001     _AKNTRACE_FUNC_EXIT;
   943     }
  1002     }
   944 
  1003 
   945 TBool CEikDialogPage::RotateFocusByL(TInt aDelta)
  1004 TBool CEikDialogPage::RotateFocusByL(TInt aDelta)
   946     {
  1005     {
       
  1006 	_AKNTRACE_FUNC_ENTER;
   947     TInt numLines=iLines->Count();
  1007     TInt numLines=iLines->Count();
   948     if (numLines == 0)
  1008     if (numLines == 0)
       
  1009         {
       
  1010         _AKNTRACE_FUNC_EXIT;
   949         return(EFalse);
  1011         return(EFalse);
       
  1012         }
   950     
  1013     
   951     // If form is in view mode and highlight is hidden then the first
  1014     // If form is in view mode and highlight is hidden then the first
   952     // navigation key press just displays the highlight.
  1015     // navigation key press just displays the highlight.
   953     if ( IsForm() && !IsEditable() && !HighlightVisible() )
  1016     if ( IsForm() && !IsEditable() && !HighlightVisible() )
   954         {
  1017         {
   968                 {
  1031                 {
   969                 iExtension->iLastTouchedLine = lineIndex;
  1032                 iExtension->iLastTouchedLine = lineIndex;
   970                 HandleHighlightTimer();
  1033                 HandleHighlightTimer();
   971                 }
  1034                 }
   972             }
  1035             }
   973         
  1036         _AKNTRACE_FUNC_EXIT;
   974         return ETrue;
  1037         return ETrue;
   975         }
  1038         }
   976     
  1039     
   977     TInt max=numLines-1;
  1040     TInt max=numLines-1;
   978     TInt currentLine=iCurrentLine;
  1041     TInt currentLine=iCurrentLine;
   997             continue;
  1060             continue;
   998 
  1061 
   999         ChangeFocusToAndExposeL(currentLine);
  1062         ChangeFocusToAndExposeL(currentLine);
  1000         LineChangedL((*iLines)[currentLine]->iId);
  1063         LineChangedL((*iLines)[currentLine]->iId);
  1001         iExtension->iFocusedClicked = ETrue;
  1064         iExtension->iFocusedClicked = ETrue;
       
  1065         _AKNTRACE_FUNC_EXIT;
  1002         return(ETrue);
  1066         return(ETrue);
  1003         }
  1067         }
  1004         
  1068     _AKNTRACE_FUNC_EXIT;    
  1005     return EFalse;
  1069     return EFalse;
  1006     }
  1070     }
  1007 
  1071 
  1008 void CEikDialogPage::ChangeFocusToAndExposeL( TInt aLine, TBool /*aShowWholeControl*/ )
  1072 void CEikDialogPage::ChangeFocusToAndExposeL( TInt aLine, TBool /*aShowWholeControl*/ )
  1009     {
  1073     {
       
  1074 	_AKNTRACE_FUNC_ENTER;
       
  1075 	_AKNTRACE( "CEikDialogPage::ChangeFocusToAndExposeL() aLine: [%d]", aLine );
  1010     if ( aLine < 0 || aLine == iCurrentLine )
  1076     if ( aLine < 0 || aLine == iCurrentLine )
       
  1077         {
       
  1078         _AKNTRACE_FUNC_EXIT;
  1011         return;
  1079         return;
       
  1080         }
  1012     
  1081     
  1013     TInt oldLine = iCurrentLine;
  1082     TInt oldLine = iCurrentLine;
  1014     
  1083     
  1015     if( aLine != iCurrentLine )
  1084     if( aLine != iCurrentLine )
  1016         (*iLines)[iCurrentLine]->ScrollBackEditor();
  1085         (*iLines)[iCurrentLine]->ScrollBackEditorL();
  1017     
  1086     
  1018     ChangeFocusTo( aLine );
  1087     ChangeFocusTo( aLine );
  1019     ExposeLine( iCurrentLine, EFalse );
  1088     ExposeLine( iCurrentLine, EFalse );
  1020 
  1089 
  1021     if ( oldLine != iCurrentLine )
  1090     if ( oldLine != iCurrentLine )
  1029             ShowFocus(ETrue, EFalse);
  1098             ShowFocus(ETrue, EFalse);
  1030             }
  1099             }
  1031         
  1100         
  1032         DrawDeferred();
  1101         DrawDeferred();
  1033         }
  1102         }
       
  1103     _AKNTRACE_FUNC_EXIT;
  1034     }
  1104     }
  1035 
  1105 
  1036 TInt CEikDialogPage::TopFocusableLine() const
  1106 TInt CEikDialogPage::TopFocusableLine() const
  1037     {
  1107     {
  1038     const TInt numLines=iLines->Count();
  1108     const TInt numLines=iLines->Count();
  1057     return KErrNotFound;
  1127     return KErrNotFound;
  1058     }
  1128     }
  1059 
  1129 
  1060 TBool CEikDialogPage::LineIsFocusable(TInt aLine) const
  1130 TBool CEikDialogPage::LineIsFocusable(TInt aLine) const
  1061     {
  1131     {
       
  1132 	_AKNTRACE_FUNC_ENTER;
  1062     TBool focusable(ETrue);
  1133     TBool focusable(ETrue);
  1063     CEikCaptionedControl* line=(*iLines)[aLine];
  1134     CEikCaptionedControl* line=(*iLines)[aLine];
  1064 
  1135 
  1065     if (line->IsNonFocusing() || line->IsDimmed() || !(line->IsVisible()))
  1136     if (line->IsNonFocusing() || line->IsDimmed() || !(line->IsVisible()))
  1066         focusable=EFalse;
  1137         focusable=EFalse;
  1067 
  1138     _AKNTRACE( "focusable: [%d]", focusable );
       
  1139     _AKNTRACE_FUNC_EXIT;
  1068     return focusable;
  1140     return focusable;
  1069     }
  1141     }
  1070 
  1142 
  1071 void CEikDialogPage::SetDensePacking(TBool aDensePacking)
  1143 void CEikDialogPage::SetDensePacking(TBool aDensePacking)
  1072     {
  1144     {
  1073     iLines->SetDensePacking(aDensePacking);
  1145     iLines->SetDensePacking(aDensePacking);
  1074     }
  1146     }
  1075 
  1147 
  1076 void CEikDialogPage::InsertLineL(TInt aPosition,TInt aResourceId)
  1148 void CEikDialogPage::InsertLineL(TInt aPosition,TInt aResourceId)
  1077     {
  1149     {
       
  1150 	_AKNTRACE_FUNC_ENTER;
       
  1151 	_AKNTRACE( "aPosition: [%d]", aPosition );
  1078     // alteration is bloated but should not provide any side-effects.
  1152     // alteration is bloated but should not provide any side-effects.
  1079     if (!iFormControl)
  1153     if (!iFormControl)
  1080         {
  1154         {
  1081         CEikCaptionedControl* line=ConstructLineL(aResourceId);
  1155         CEikCaptionedControl* line=ConstructLineL(aResourceId);
  1082         CleanupStack::PushL(line);
  1156         CleanupStack::PushL(line);
  1096 iCurrentLine should be increased as it is relative to the lines in that page
  1170 iCurrentLine should be increased as it is relative to the lines in that page
  1097 and we have just added a new line before it in the page.
  1171 and we have just added a new line before it in the page.
  1098 */
  1172 */
  1099     if (iCurrentLine>=aPosition) 
  1173     if (iCurrentLine>=aPosition) 
  1100         iCurrentLine++;
  1174         iCurrentLine++;
       
  1175     _AKNTRACE_FUNC_EXIT;
  1101     }
  1176     }
  1102 
  1177 
  1103 void CEikDialogPage::DeleteLine(TInt aLineId, TBool aRedraw)
  1178 void CEikDialogPage::DeleteLine(TInt aLineId, TBool aRedraw)
  1104     {
  1179     {
       
  1180 	_AKNTRACE_FUNC_ENTER;
  1105     TInt index( LineIndex( aLineId ) ) ;
  1181     TInt index( LineIndex( aLineId ) ) ;
       
  1182 	_AKNTRACE( "Delete line index: [%d]", index );
  1106     if ( index == iCurrentLine ) // we're deleting the current line
  1183     if ( index == iCurrentLine ) // we're deleting the current line
  1107         {
  1184         {
  1108 // If this is the last line then move the focus to the line above.  (becomes -1 if last line)
  1185 // If this is the last line then move the focus to the line above.  (becomes -1 if last line)
  1109         if( iCurrentLine == iLines->Count() - 1 )
  1186         if( iCurrentLine == iLines->Count() - 1 )
  1110             iCurrentLine-- ;
  1187             iCurrentLine-- ;
  1143         if (iCurrentLine!=-1)
  1220         if (iCurrentLine!=-1)
  1144             {
  1221             {
  1145             TInt targetLine = iCurrentLine ;
  1222             TInt targetLine = iCurrentLine ;
  1146             iCurrentLine = -1 ;
  1223             iCurrentLine = -1 ;
  1147             ChangeFocusTo( targetLine ) ;
  1224             ChangeFocusTo( targetLine ) ;
  1148             ExposeLine( targetLine, EFalse ) ;
  1225             ExposeLine( targetLine, ETrue ) ;
  1149             ShowFocus( ETrue, EFalse ) ;
  1226             ShowFocus( ETrue, EFalse ) ;
  1150             }
  1227             }
  1151 
  1228 
  1152         DrawNow();
  1229         DrawNow();
  1153         TRAP_IGNORE(UpdateScrollBarL()); // if OOM, scrollbar will not be updated - No great loss.
  1230         TRAP_IGNORE(UpdateScrollBarL()); // if OOM, scrollbar will not be updated - No great loss.
  1154         }
  1231         }
       
  1232     _AKNTRACE_FUNC_EXIT;
  1155     }
  1233     }
  1156 
  1234 
  1157 void CEikDialogPage::AdjustAllIds(TInt aControlIdDelta)
  1235 void CEikDialogPage::AdjustAllIds(TInt aControlIdDelta)
  1158     {
  1236     {
  1159     iLines->AdjustAllIds(aControlIdDelta);
  1237     iLines->AdjustAllIds(aControlIdDelta);
  1160     }
  1238     }
  1161 
  1239 
  1162 TInt CEikDialogPage::FocusLineL(TInt aLineId)
  1240 TInt CEikDialogPage::FocusLineL(TInt aLineId)
  1163     {
  1241     {
       
  1242     _AKNTRACE_FUNC_ENTER;
  1164     TInt lineIndex=LineIndex(aLineId);
  1243     TInt lineIndex=LineIndex(aLineId);
  1165 
  1244     _AKNTRACE( "Delete line index: [%d]", lineIndex );
  1166     if (lineIndex==KErrNotFound)
  1245     if (lineIndex==KErrNotFound)
  1167         return KErrNotFound;
  1246         return KErrNotFound;
  1168 
  1247 
  1169     PrepareForFocusTransitionL();
  1248     PrepareForFocusTransitionL();
  1170 // Show whole line, not scroll into line.
  1249 // Show whole line, not scroll into line.
  1171     ChangeFocusToAndExposeL(lineIndex, ETrue); 
  1250     ChangeFocusToAndExposeL(lineIndex, ETrue); 
  1172     LineChangedL(aLineId);
  1251     LineChangedL(aLineId);
       
  1252     _AKNTRACE_FUNC_EXIT;
  1173     return KErrNone;
  1253     return KErrNone;
  1174     }
  1254     }
  1175 
  1255 
  1176 TInt CEikDialogPage::FocusedLineId() const
  1256 TInt CEikDialogPage::FocusedLineId() const
  1177     {
  1257     {
  1246         }
  1326         }
  1247 
  1327 
  1248     return KErrNotFound;
  1328     return KErrNotFound;
  1249     }
  1329     }
  1250 
  1330 
  1251 TInt CEikDialogPage::YPosToLine2(TInt aYPos) const
       
  1252     {
       
  1253     return iLines->YPosToLine( Rect(), iScroll->Top(), iScroll->Middle(), iScroll->Bottom(), aYPos );
       
  1254     }
       
  1255 
       
  1256 TInt CEikDialogPage::LineToYPos(TInt& aLine) const
       
  1257 //
       
  1258 // Calcs YPos of line relative to the ViewWin and adjusts aLine if its out of bounds
       
  1259     {
       
  1260     ASSERT(iLines);
       
  1261     const TInt numLines=iLines->Count();
       
  1262     ASSERT(numLines>0);
       
  1263     if (aLine<0)
       
  1264         aLine=0;
       
  1265     else if (aLine>=numLines)
       
  1266         aLine=numLines-1;
       
  1267     return (*iLines)[aLine]->Position().iY; // TPREMOVAL +iDataWinPos.iY;
       
  1268     }
       
  1269 
  1331 
  1270 void CEikDialogPage::ExposeLine(TInt aLine, TBool aForceResize, TBool aShowWholeLine) 
  1332 void CEikDialogPage::ExposeLine(TInt aLine, TBool aForceResize, TBool aShowWholeLine) 
  1271 //
  1333 //
  1272 /* Exposes the given line so that its fully visible in the ViewWin
  1334 /* Exposes the given line so that its fully visible in the ViewWin
  1273 */  {
  1335 */  {
       
  1336 	_AKNTRACE_FUNC_ENTER;
  1274     if ( iSize.iHeight == 0 || aLine == -1 )
  1337     if ( iSize.iHeight == 0 || aLine == -1 )
  1275         {
  1338         {
       
  1339         _AKNTRACE_FUNC_EXIT;
  1276         return;
  1340         return;
  1277         }
  1341         }
  1278 
  1342 
  1279     CAknPaneScroll::TScrollChangeType change = iScroll->ExposeLine( aLine, aShowWholeLine );
  1343     CAknPaneScroll::TScrollChangeType change = iScroll->ExposeLine( aLine, aShowWholeLine );
  1280     
  1344     
  1281     if ( change == CAknPaneScroll::ENoChange && !aForceResize )
  1345     if ( change == CAknPaneScroll::ENoChange && !aForceResize )
  1282         {
  1346         {
       
  1347         _AKNTRACE_FUNC_EXIT;
  1283         return;
  1348         return;
  1284         }
  1349         }
  1285 
  1350 
  1286     CEikCaptionedControl* capCtrl = (*iLines)[aLine];
  1351     CEikCaptionedControl* capCtrl = (*iLines)[aLine];
  1287     capCtrl->MinimumSize();
  1352     capCtrl->MinimumSize();
  1317             topYPosOfControlWhichMustBeViewable = iLastExposedLineViewWinYPosition;
  1382             topYPosOfControlWhichMustBeViewable = iLastExposedLineViewWinYPosition;
  1318             bottomYPosOfControlWhichMustBeViewable = topYPosOfControlWhichMustBeViewable + controlHeight;
  1383             bottomYPosOfControlWhichMustBeViewable = topYPosOfControlWhichMustBeViewable + controlHeight;
  1319             }
  1384             }
  1320         }
  1385         }
  1321 
  1386 
       
  1387     // If control height is greater then screen. Make sure that edwin's cursor is visible
       
  1388     if (controlType == EEikCtEdwin && controlHeight > Rect().Height())
       
  1389         {
       
  1390         CEikEdwin* edwin = dynamic_cast<CEikEdwin*>(capCtrl->iControl); 
       
  1391         if (edwin)
       
  1392             {
       
  1393             TInt pos = edwin->CursorPos();
       
  1394             TRect linerect;
       
  1395             TRAP_IGNORE( linerect = edwin->TextLayout()->GetLineRectL(pos, pos) );
       
  1396             
       
  1397             TPoint capctrlpos = capCtrl->Position();
       
  1398             TPoint edwinpos = edwin->Position();
       
  1399             if (edwinpos.iY - capctrlpos.iY + (linerect.iTl.iY + linerect.iBr.iY)/2 > Rect().Height()/2) // cursor not fully visible
       
  1400                 {
       
  1401                 TInt offset = edwinpos.iY - capctrlpos.iY + (linerect.iTl.iY + linerect.iBr.iY)/2 - Rect().Height()/2;
       
  1402                 if (topYPosOfControlWhichMustBeViewable + offset + Rect().Height() <= bottomYPosOfControlWhichMustBeViewable)
       
  1403                     {
       
  1404                     topYPosOfControlWhichMustBeViewable += offset;
       
  1405                     bottomYPosOfControlWhichMustBeViewable = topYPosOfControlWhichMustBeViewable + Rect().Height();
       
  1406                     }
       
  1407                 else
       
  1408                     {
       
  1409                     topYPosOfControlWhichMustBeViewable = bottomYPosOfControlWhichMustBeViewable - Rect().Height();
       
  1410                     }
       
  1411                 }
       
  1412             else
       
  1413                 {
       
  1414                 bottomYPosOfControlWhichMustBeViewable = topYPosOfControlWhichMustBeViewable + Rect().Height();
       
  1415                 }
       
  1416             }
       
  1417         }
       
  1418  
  1322     SetDataPosition( topYPosOfControlWhichMustBeViewable, bottomYPosOfControlWhichMustBeViewable, aForceResize ); 
  1419     SetDataPosition( topYPosOfControlWhichMustBeViewable, bottomYPosOfControlWhichMustBeViewable, aForceResize ); 
  1323   
  1420   
  1324     if ( aLine != iLastExposedLine )
  1421     if ( aLine != iLastExposedLine )
  1325         {
  1422         {
  1326         iLastExposedLine = aLine;
  1423         iLastExposedLine = aLine;
  1327         iLastExposedLineViewWinYPosition = topYPosOfControlWhichMustBeViewable + idealDataWindowPosition;
  1424         iLastExposedLineViewWinYPosition = topYPosOfControlWhichMustBeViewable + idealDataWindowPosition;
  1328         }
  1425         }
       
  1426     _AKNTRACE_FUNC_EXIT;
  1329     }
  1427     }
  1330 
  1428 
  1331 void CEikDialogPage::SetDataPosition( TInt aTopY, TInt aBottomY, TBool aForceResize )
  1429 void CEikDialogPage::SetDataPosition( TInt aTopY, TInt aBottomY, TBool aForceResize )
  1332     {
  1430     {
       
  1431 	_AKNTRACE_FUNC_ENTER;
       
  1432 	_AKNTRACE( "[%s][%s] aTopY: [%d]", "CEikDialogPage", __FUNCTION__, aTopY );
  1333     // update rect only if the currently focused control doesn't fit
  1433     // update rect only if the currently focused control doesn't fit
  1334     if ( iFormControl )
  1434     if ( iFormControl )
  1335         {
  1435         {
  1336         TInt topY = iPhysics->ViewTopY();
  1436         TInt topY = iPhysics->ViewTopY();
  1337         TInt maxBottomY = topY + iSize.iHeight;
  1437         TInt maxBottomY = topY + iSize.iHeight;
  1373 
  1473 
  1374             iPhysics->SetViewCenter( viewCenter );
  1474             iPhysics->SetViewCenter( viewCenter );
  1375             iLines->MoveLineToScreen( iCurrentLine, iPhysics->ViewTopY(), ETrue );
  1475             iLines->MoveLineToScreen( iCurrentLine, iPhysics->ViewTopY(), ETrue );
  1376             }
  1476             }
  1377         }
  1477         }
       
  1478     _AKNTRACE_FUNC_EXIT;
  1378     }
  1479     }
  1379                     
  1480                     
  1380 /*
  1481 /*
  1381 class CDummy: public CCoeControl
  1482 class CDummy: public CCoeControl
  1382     {
  1483     {
  1414     return (*iLines)[aLineIndex]->Size().iHeight;
  1515     return (*iLines)[aLineIndex]->Size().iHeight;
  1415     }
  1516     }
  1416 
  1517 
  1417 void CEikDialogPage::SizeChanged()
  1518 void CEikDialogPage::SizeChanged()
  1418     {
  1519     {
       
  1520 	_AKNTRACE_FUNC_ENTER;
       
  1521 	if ( IsForm() )
       
  1522 	    {
       
  1523         iExtension->iInitialLayoutDone = EFalse;
       
  1524 	
       
  1525         iScroll->SetOutsideRect( Rect() );
       
  1526         
       
  1527         // force each line to resize
       
  1528         TInt count = iLines->Count();
       
  1529         
       
  1530         for ( TInt i = 0; i < count; ++i )
       
  1531             {
       
  1532             (*iLines)[i]->HandleResourceChange( KEikDynamicLayoutVariantSwitch );
       
  1533             }
       
  1534 
       
  1535         iLines->SetRect( Rect(), iScroll->Top(), iScroll->Middle(), iScroll->Bottom() );
       
  1536         iExtension->iInitialLayoutDone = ETrue;
       
  1537         UpdatePhysics();
       
  1538 
       
  1539         if ( iExtension->iScrolling
       
  1540                 || iExtension->iFlags.IsSet( 
       
  1541                         CDialogPageExtension::EDragEventsAllowed ) )
       
  1542             {
       
  1543             iPhysics->Stop();
       
  1544             Synchronize();
       
  1545             }
       
  1546 
       
  1547         if ( count > 0 && iCurrentLine != KErrNotFound )
       
  1548             {
       
  1549             if ( iLastExposedLine != -1 )
       
  1550                 {
       
  1551                 iLastExposedLineViewWinYPosition = 
       
  1552                         iLines->LineIndexToYPosition( iLastExposedLine, 0 );
       
  1553                 }
       
  1554 
       
  1555             ExposeLine( iCurrentLine, ETrue );
       
  1556             
       
  1557             if ( Size() != TSize::EUninitialized )
       
  1558                 {
       
  1559                 (*iLines)[iCurrentLine]->DrawDeferred();
       
  1560                 }
       
  1561             }
       
  1562         
       
  1563         TRAP_IGNORE( UpdateScrollBarL() ); // ignore any errors.
       
  1564         AknsUtils::RegisterControlPosition( this ); 
       
  1565 
       
  1566         _AKNTRACE_FUNC_EXIT;
       
  1567         return;
       
  1568 	    }
       
  1569 	
  1419     // update form area's size to scroll control
  1570     // update form area's size to scroll control
  1420     iScroll->SetOutsideRect( Rect() );
  1571     iScroll->SetOutsideRect( Rect() );
  1421     iLines->SetRect( Rect(), iScroll->Top(), iScroll->Middle(), iScroll->Bottom() );
  1572     iLines->SetRect( Rect(), iScroll->Top(), iScroll->Middle(), iScroll->Bottom() );
  1422 
  1573 
  1423     if ( (iLines->Count() > 0 ) && ( iCurrentLine >= 0 ) )
  1574     if ( (iLines->Count() > 0 ) && ( iCurrentLine >= 0 ) )
  1426         }
  1577         }
  1427 
  1578 
  1428     TRAP_IGNORE( UpdateScrollBarL() ); // ignore any errors.
  1579     TRAP_IGNORE( UpdateScrollBarL() ); // ignore any errors.
  1429     AknsUtils::RegisterControlPosition( this ); 
  1580     AknsUtils::RegisterControlPosition( this ); 
  1430 
  1581 
  1431     UpdatePhysics();
       
  1432     iExtension->iInitialLayoutDone = ETrue;
  1582     iExtension->iInitialLayoutDone = ETrue;
       
  1583     _AKNTRACE_FUNC_EXIT;
  1433     }
  1584     }
  1434 
  1585 
  1435 TSize CEikDialogPage::MinimumSize()
  1586 TSize CEikDialogPage::MinimumSize()
  1436     {
  1587     {
       
  1588 	_AKNTRACE( "[%s][%s] MinimumSize: w = %d, h = %d.",
       
  1589 	                "CEikDialogPage", __FUNCTION__, iLines->MinimumSize().iWidth, 0 );
  1437     return TSize( iLines->MinimumSize().iWidth, 0 );   // Can be zero height
  1590     return TSize( iLines->MinimumSize().iWidth, 0 );   // Can be zero height
  1438     }
  1591     }
  1439 
  1592 
  1440 void CEikDialogPage::PrepareForFocusLossL()
  1593 void CEikDialogPage::PrepareForFocusLossL()
  1441     {
  1594     {
  1486  * From MEikEdwinObserver. Look for navigation and editor text update events, as scrolling
  1639  * From MEikEdwinObserver. Look for navigation and editor text update events, as scrolling
  1487  might be required to keep cursor visible.
  1640  might be required to keep cursor visible.
  1488  */
  1641  */
  1489 void CEikDialogPage::HandleEdwinEventL(CEikEdwin* aEdwin,TEdwinEvent aEventType)
  1642 void CEikDialogPage::HandleEdwinEventL(CEikEdwin* aEdwin,TEdwinEvent aEventType)
  1490     {
  1643     {
       
  1644 	_AKNTRACE_FUNC_ENTER;
  1491     if ( IsForm() && ( aEventType == EEventTextUpdate
  1645     if ( IsForm() && ( aEventType == EEventTextUpdate
  1492             || aEventType == EEventTextUpdateAPI ) )
  1646             || aEventType == EEventTextUpdateAPI ) )
  1493         {
  1647         {
  1494         CEikCaptionedControl* line = NULL;
  1648         CEikCaptionedControl* line = NULL;
  1495         TInt controlType = -1;
  1649         TInt controlType = -1;
  1505                     {
  1659                     {
  1506                     RecordLineL( i );
  1660                     RecordLineL( i );
  1507                     
  1661                     
  1508                     if ( i != iCurrentLine )
  1662                     if ( i != iCurrentLine )
  1509                         {
  1663                         {
  1510                         DrawNow();
  1664                         DrawDeferred();
  1511                         }
  1665                         }
  1512                         
  1666                         
  1513                     break;
  1667                     break;
  1514                     }
  1668                     }
  1515                 }
  1669                 }
  1516             }
  1670             }
  1517         }
  1671         }
  1518     
  1672     
  1519     if( iCurrentLine == iLastExposedLine || iCurrentLine == -1 )
  1673     if( iCurrentLine == iLastExposedLine || iCurrentLine == -1 )
       
  1674         {
       
  1675         _AKNTRACE_FUNC_EXIT;
  1520         return;
  1676         return;
       
  1677         }
  1521     if( aEventType == EEventNavigation || aEventType == EEventTextUpdate )
  1678     if( aEventType == EEventNavigation || aEventType == EEventTextUpdate )
  1522         {
  1679         {
  1523         ExposeLine( iCurrentLine, EFalse );
  1680         ExposeLine( iCurrentLine, EFalse );
  1524             
  1681             
  1525         UpdateScrollBarL();
  1682         UpdateScrollBarL();
  1526         }
  1683         }
       
  1684     _AKNTRACE_FUNC_EXIT;
  1527     }
  1685     }
  1528 
  1686 
  1529 /**
  1687 /**
  1530  * Handle events caused by popup field controls, and resize if necessary
  1688  * Handle events caused by popup field controls, and resize if necessary
  1531  */
  1689  */
  1532 void CEikDialogPage::HandlePopupFieldEventL(CAknPopupField* aPopupField, TAknPopupFieldEvent aEventType, TInt /*aHint*/)
  1690 void CEikDialogPage::HandlePopupFieldEventL(CAknPopupField* aPopupField, TAknPopupFieldEvent aEventType, TInt /*aHint*/)
  1533     {
  1691     {
       
  1692 	_AKNTRACE_FUNC_ENTER;
  1534     switch (aEventType)
  1693     switch (aEventType)
  1535         {
  1694         {
  1536     case EAknPopupFieldEventValueChange:
  1695     case EAknPopupFieldEventValueChange:
  1537         {
  1696         {
       
  1697         _AKNTRACE( "[%s][%s][%d] EAknPopupFieldEventValueChange", 
       
  1698         		   "CEikDialogPage", __FUNCTION__, __LINE__ );
  1538         CEikCaptionedControl* line = NULL;
  1699         CEikCaptionedControl* line = NULL;
  1539         for ( TInt i = 0; i < iLines->Count(); ++i )
  1700         for ( TInt i = 0; i < iLines->Count(); ++i )
  1540             {
  1701             {
  1541             line = (*iLines)[i];
  1702             line = (*iLines)[i];
  1542             if ( line->iControl == aPopupField )
  1703             if ( line->iControl == aPopupField )
  1543                 {
  1704                 {
  1544                 if ( IsForm() )
  1705                 if ( IsForm() )
  1545                     {
  1706                     {
  1546                     RecordLineL( i );
  1707                     RecordLineL( i );
  1547                     }
  1708                     }
  1548                 DrawNow();
  1709                 DrawDeferred();
  1549                 break;
  1710                 break;
  1550                 }
  1711                 }
  1551             }
  1712             }
  1552         break;  
  1713         break;  
  1553         }
  1714         }
  1554     case EAknPopupFieldEventModeChange:
  1715     case EAknPopupFieldEventModeChange:
  1555         {
  1716         {
       
  1717         _AKNTRACE( "[%s][%s][%d] EAknPopupFieldEventModeChange", 
       
  1718         		   "CEikDialogPage", __FUNCTION__, __LINE__ );
  1556         TInt index = iCurrentLine;
  1719         TInt index = iCurrentLine;
  1557         
  1720         
  1558         if(iIsEditable && (iExtension->iPopFieldEvents != 0))
  1721         if(iIsEditable && (iExtension->iPopFieldEvents != 0))
  1559             {           
  1722             {           
  1560             iExtension->iPopFieldEvents = 0;
  1723             iExtension->iPopFieldEvents = 0;
  1562             }
  1725             }
  1563         else
  1726         else
  1564             {
  1727             {
  1565             iExtension->iPopFieldEvents = 1;
  1728             iExtension->iPopFieldEvents = 1;
  1566             }     
  1729             }     
  1567                 
  1730   
  1568         ReconsiderPageSize();
  1731         (*iLines)[iCurrentLine]->SetRect( (*iLines)[iCurrentLine]->Rect() );
  1569         ExposeLine( index, ETrue );
  1732         ExposeLine( index, ETrue );
  1570         DrawNow();
  1733         DrawNow();
  1571 
  1734 
  1572         UpdateScrollBarL();
  1735         UpdateScrollBarL();
  1573         PrepareToDrawVerticalLine();
  1736         PrepareToDrawVerticalLine();
  1574         break;
  1737         break;
  1575         }
  1738         }
  1576     default:
  1739     default:
  1577         break;
  1740         break;
  1578         }
  1741         }
       
  1742     _AKNTRACE_FUNC_EXIT;
  1579     }
  1743     }
  1580 
  1744 
  1581 void CEikDialogPage::PrepareToDrawVerticalLine() const
  1745 void CEikDialogPage::PrepareToDrawVerticalLine() const
  1582     { // to avoid flushes, we resize skin frame bitmaps before actual draw.
  1746     { // to avoid flushes, we resize skin frame bitmaps before actual draw.
  1583       // NOTE, this should be possiblie to call from SizeChanged() or OfferKeyEventL() method :-) (the GC?)
  1747       // NOTE, this should be possiblie to call from SizeChanged() or OfferKeyEventL() method :-) (the GC?)
  1599                                              rectNotToDrawOuter,
  1763                                              rectNotToDrawOuter,
  1600                                              rectNotToDrawInner,
  1764                                              rectNotToDrawInner,
  1601                                              KAknsIIDQsnFrInput,
  1765                                              KAknsIIDQsnFrInput,
  1602                                              KAknsIIDDefault ) ;
  1766                                              KAknsIIDDefault ) ;
  1603                 }
  1767                 }
  1604 
       
  1605             }       
  1768             }       
  1606         
  1769         }
  1607         }
  1770     }
  1608     
  1771 
  1609     }
       
  1610 
       
  1611 void CEikDialogPage::DrawVerticalLine() const
       
  1612     {       
       
  1613     }
       
  1614 
  1772 
  1615 void CEikDialogPage::HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType)
  1773 void CEikDialogPage::HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType)
  1616     {
  1774     {
       
  1775 	_AKNTRACE_FUNC_ENTER;
  1617     switch (aEventType)
  1776     switch (aEventType)
  1618         {
  1777         {
  1619     case EEventPrepareFocusTransition:
  1778     case EEventPrepareFocusTransition:
  1620         PrepareForFocusTransitionL();
  1779         PrepareForFocusTransitionL();
  1621         break;
  1780         break;
  1663     case EEventRequestCancel:
  1822     case EEventRequestCancel:
  1664     case EEventInteractionRefused:
  1823     case EEventInteractionRefused:
  1665     default:
  1824     default:
  1666         break;
  1825         break;
  1667         }
  1826         }
       
  1827     _AKNTRACE_FUNC_EXIT;
  1668     }
  1828     }
  1669 
  1829 
  1670 void CEikDialogPage::PassOnEventL(CCoeControl* aControl,MCoeControlObserver::TCoeEvent aEvent)
  1830 void CEikDialogPage::PassOnEventL(CCoeControl* aControl,MCoeControlObserver::TCoeEvent aEvent)
  1671     {
  1831     {
  1672     MCoeControlObserver* observer=Observer();
  1832     MCoeControlObserver* observer=Observer();
  1683     const TInt maxHeight=iSize.iHeight-(KSpaceFromTitle+KSpaceFromBottom);
  1843     const TInt maxHeight=iSize.iHeight-(KSpaceFromTitle+KSpaceFromBottom);
  1684     TInt height = aDesirableEdwinSize.iHeight;
  1844     TInt height = aDesirableEdwinSize.iHeight;
  1685     if (height > maxHeight)
  1845     if (height > maxHeight)
  1686         height = maxHeight;
  1846         height = maxHeight;
  1687 
  1847 
  1688     TSize size = aEdwin->Size();
  1848     TSize size( aEdwin->Size() );
  1689     TInt maximumEdwinHeight = aEdwin->MaximumHeight();
  1849     TInt maximumEdwinHeight = aEdwin->MaximumHeight();
  1690 // ensure maxheight as dynamic construction may be done whilst form is of zero height.
  1850 // ensure maxheight as dynamic construction may be done whilst form is of zero height.
  1691     if ((maximumEdwinHeight > maxHeight) && maxHeight) 
  1851     if ((maximumEdwinHeight > maxHeight) && maxHeight) 
  1692         aEdwin->SetMaximumHeight(maxHeight);    // Can't be bigger than form itself
  1852         aEdwin->SetMaximumHeight(maxHeight);    // Can't be bigger than form itself
  1693     else if ((maximumEdwinHeight == 0) && (size.iHeight == height))
  1853     else if ((maximumEdwinHeight == 0) && (size.iHeight == height))
  1696     if ( (maximumEdwinHeight > 0) && (height > maximumEdwinHeight))
  1856     if ( (maximumEdwinHeight > 0) && (height > maximumEdwinHeight))
  1697         height=maximumEdwinHeight;  // Can't be bigger than edwin itself
  1857         height=maximumEdwinHeight;  // Can't be bigger than edwin itself
  1698     size.iHeight = height;
  1858     size.iHeight = height;
  1699 
  1859 
  1700     // Must force a size change on current captioned contrl even if control doesn't change size (so that edwin is resized by aknutils)
  1860     // Must force a size change on current captioned contrl even if control doesn't change size (so that edwin is resized by aknutils)
  1701     aEdwin->SetSize(size);  
  1861     aEdwin->SetSize(size);
  1702     ReconsiderPageSize();
  1862     
  1703     ExposeLine(iCurrentLine, ETrue);
  1863     if ( IsForm() )
       
  1864         {
       
  1865         (*iLines)[iCurrentLine]->SetRect( (*iLines)[iCurrentLine]->Rect() );
       
  1866         ExposeLine( iCurrentLine, ETrue );
       
  1867         }
       
  1868     else
       
  1869         {
       
  1870         ReconsiderPageSize();
       
  1871         ExposeLine(iCurrentLine, ETrue);
       
  1872         }
       
  1873 
  1704     PrepareToDrawVerticalLine(); // do flushes here.
  1874     PrepareToDrawVerticalLine(); // do flushes here.
  1705 
  1875 
  1706 /* improved redraw code
  1876 /* improved redraw code
  1707 Due to some unpleasantness about dialogs, forms and requirements, to get caption controls
  1877 Due to some unpleasantness about dialogs, forms and requirements, to get caption controls
  1708 to draw properly requires a call to draw now.  A system initiated draw does not work correctly
  1878 to draw properly requires a call to draw now.  A system initiated draw does not work correctly
  1728         }
  1898         }
  1729     return ETrue;
  1899     return ETrue;
  1730     }
  1900     }
  1731 
  1901 
  1732 
  1902 
  1733 static TInt CountNumberOfLines_Edwin(CEikEdwin *aEdwin, TRect aRect, TInt numOfLines)
       
  1734     {
       
  1735     TInt edwinLines = numOfLines;
       
  1736     TInt count = 0;
       
  1737     for(TInt i=0;i<edwinLines;i++)
       
  1738         {
       
  1739         TInt scrolledLines = aEdwin->TextLayout()->FirstLineInBand();
       
  1740         TInt docPos = aEdwin->TextLayout()->FirstCharOnLine(scrolledLines + i+1);
       
  1741         TPoint point;
       
  1742         aEdwin->TextLayout()->PosInBand(docPos, point);
       
  1743         TInt yPos = point.iY;
       
  1744         TRect lineRect;
       
  1745         aEdwin->TextLayout()->GetLineRect(yPos, lineRect);
       
  1746         lineRect.iTl += aEdwin->Position();
       
  1747         lineRect.iBr += aEdwin->Position();
       
  1748         if (aRect.Contains(lineRect.iTl) && aRect.Contains(lineRect.iBr))
       
  1749             count++;
       
  1750         }   
       
  1751     return count;
       
  1752     }
       
  1753 static TInt CountNumberOfLines_Ctrl(CCoeControl *aControl, TRect aRect)
       
  1754     {
       
  1755     TRect rect = TRect(aControl->Position(), aControl->Size());
       
  1756     TInt count = 0;
       
  1757     if (aRect.Contains(rect.iTl) && aRect.Contains(rect.iBr))
       
  1758         count ++;
       
  1759     return count;
       
  1760     }
       
  1761 
       
  1762 static TInt CountNumberOfVisibleLines(CEikCaptionedControl *aControl, TRect aClipRect)
       
  1763     {
       
  1764     TInt count = 0;
       
  1765     if (aControl->ControlIsAnEdwin(aControl->iControlType))
       
  1766         count += CountNumberOfLines_Edwin((CEikEdwin*)aControl->iControl, aClipRect, aControl->NumberOfLines());
       
  1767     else
       
  1768         count += CountNumberOfLines_Ctrl(aControl->iControl, aClipRect);
       
  1769     count += CountNumberOfLines_Ctrl(aControl->iCaption, aClipRect);
       
  1770     return count;
       
  1771     }
       
  1772 
       
  1773 static TInt NumberOfTextLinesVisible(CEikCapCArray *aLines, TInt aItem, TRect aClipRect)
       
  1774     {
       
  1775     if (aItem < 0) return 0;
       
  1776     CEikCaptionedControl *control = (*aLines)[aItem];
       
  1777     return CountNumberOfVisibleLines(control, aClipRect);   
       
  1778     }
       
  1779 
       
  1780 
       
  1781 void CEikDialogPage::HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType)
  1903 void CEikDialogPage::HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType)
  1782     {
  1904     {
       
  1905 	_AKNTRACE_FUNC_ENTER;
  1783     iExtension->iHandlingScrollEvent = ETrue;
  1906     iExtension->iHandlingScrollEvent = ETrue;
  1784 
  1907 
  1785     switch (aEventType)
  1908     switch (aEventType)
  1786         {
  1909         {
  1787         case EEikScrollPageUp:
  1910         case EEikScrollPageUp:
  1788         case EEikScrollPageDown:
  1911         case EEikScrollPageDown:
  1789         case EEikScrollThumbDragVert:
  1912         case EEikScrollThumbDragVert:
  1790             iExtension->iScrolled = ETrue;
       
  1791             iExtension->iScrolling = ETrue;
  1913             iExtension->iScrolling = ETrue;
  1792             iLines->MoveLineToScreen( iCurrentLine, 0, EFalse );
  1914             iLines->MoveLineToScreen( iCurrentLine, 0, EFalse );
  1793             break;
  1915             break;
  1794 
  1916 
  1795         default:
  1917         default:
  1811         default:
  1933         default:
  1812             break;
  1934             break;
  1813         }
  1935         }
  1814     
  1936     
  1815     iExtension->iHandlingScrollEvent = EFalse;
  1937     iExtension->iHandlingScrollEvent = EFalse;
       
  1938     _AKNTRACE_FUNC_EXIT;
  1816     }
  1939     }
  1817 
  1940 
  1818 TBool CEikDialogPage::LineHandlerCalled() const
  1941 TBool CEikDialogPage::LineHandlerCalled() const
  1819     {
  1942     {
  1820     return iExtension->iFlags.IsSet( CDialogPageExtension::ELineHandlerCalled );
  1943     return iExtension->iFlags.IsSet( CDialogPageExtension::ELineHandlerCalled );
  1827     return mainPaneRect;
  1950     return mainPaneRect;
  1828     }
  1951     }
  1829 
  1952 
  1830 void CEikDialogPage::UpdateScrollBarL()
  1953 void CEikDialogPage::UpdateScrollBarL()
  1831     {
  1954     {
       
  1955 	_AKNTRACE_FUNC_ENTER;
  1832     // Only forms in S60 need dialog's scrollbar.
  1956     // Only forms in S60 need dialog's scrollbar.
  1833     if ( !iFormControl || !iPageContainer->ScrollBar() || iSize.iHeight == 0 || iSize.iWidth == 0 || iExtension->iHandlingScrollEvent )
  1957     if ( !iFormControl || !iPageContainer->ScrollBar() || iSize.iHeight == 0 || iSize.iWidth == 0 || iExtension->iHandlingScrollEvent )
  1834         {
  1958         {
       
  1959         _AKNTRACE_FUNC_EXIT;
  1835         return;
  1960         return;
  1836         }
  1961         }
  1837 
  1962 
  1838     CAknScrollBar* scrollBar = STATIC_CAST(CAknScrollBar*, iPageContainer->ScrollBar()->VerticalScrollBar());
  1963     CAknScrollBar* scrollBar = STATIC_CAST(CAknScrollBar*, iPageContainer->ScrollBar()->VerticalScrollBar());
  1839 
  1964 
  1840     if (scrollBar)
  1965     if (scrollBar)
  1841         {
  1966         {
  1842         TInt top = iScroll->Top();
       
  1843         TInt middle = iScroll->Middle();
       
  1844         TInt bottom = iScroll->Bottom();
       
  1845         TRect parent( Rect() );
       
  1846         TBool topmostPartial = top == -1;
       
  1847         iLines->CalcItemIndexes(top, middle, bottom, parent.Size());
       
  1848         TInt extraLines = topmostPartial ? NumberOfTextLinesVisible(iLines, top-1, parent) : 0;
       
  1849         iExtension->iPreviousThumbPosition = iLines->NumberOfTextLinesBeforeLine( top - extraLines );
       
  1850 
       
  1851         // Using form layout, since this is used by AknForm only
  1967         // Using form layout, since this is used by AknForm only
  1852         TAknWindowComponentLayout layout = TAknWindowComponentLayout::Compose( 
  1968         TAknWindowComponentLayout layout = TAknWindowComponentLayout::Compose( 
  1853             AknLayoutScalable_Avkon::listscroll_form_pane(),  
  1969             AknLayoutScalable_Avkon::listscroll_form_pane(),  
  1854             AknLayoutScalable_Avkon::scroll_pane_cp8());
  1970             AknLayoutScalable_Avkon::scroll_pane_cp8());
  1855             
  1971             
  1856         TRect scrollBarParent( MainPane().Size()/*mainPaneRect.Size()*/ );
  1972 		//Using Rect() instead of main pane rect for supporting partial input mode.
  1857     
  1973         //TRect scrollBarParent( MainPane().Size() );   
  1858         AknLayoutUtils::LayoutVerticalScrollBar(iPageContainer->ScrollBar(), scrollBarParent, layout.LayoutLine());
  1974         AknLayoutUtils::LayoutVerticalScrollBar(iPageContainer->ScrollBar(), Rect(), layout.LayoutLine());
       
  1975         
  1859         if(!ScbState() &&  iCurrentLine!=-1 && iCurrentLine < iLines->Count() )
  1976         if(!ScbState() &&  iCurrentLine!=-1 && iCurrentLine < iLines->Count() )
  1860         	{
  1977         	{
  1861     		CEikCaptionedControl *ctrl = (*iLines)[iCurrentLine];
  1978     		CEikCaptionedControl *ctrl = (*iLines)[iCurrentLine];
  1862         	if(ctrl->ControlIsAPopfield(ctrl->iControlType))
  1979         	if(ctrl->ControlIsAPopfield(ctrl->iControlType))
  1863 				{
  1980 				{
  1864 	            CAknPopupField::EAknPopupFieldSelectionMode mode = ((CAknPopupField*)ctrl->iControl)->SelectionMode();
  1981 	            CAknPopupField::EAknPopupFieldSelectionMode mode = ((CAknPopupField*)ctrl->iControl)->SelectionMode();
  1865 	            if (mode == CAknPopupField::EAknPopupFieldSelectionListMode)
  1982 	            if (mode == CAknPopupField::EAknPopupFieldSelectionListMode)
  1866 	                {
  1983 	                {
       
  1984 	                _AKNTRACE_FUNC_EXIT;
  1867 	                return;
  1985 	                return;
  1868 	                }
  1986 	                }
  1869 				}        		
  1987 				}        		
  1870         	UpdateScrollBarThumb();
  1988         	UpdateScrollBarThumb();
  1871         	}
  1989         	}
  1872         }
  1990         }
       
  1991     _AKNTRACE_FUNC_EXIT;
  1873     }
  1992     }
  1874     
  1993     
  1875 
  1994 
  1876 void CEikDialogPage::UpdateScrollBarThumb()
  1995 void CEikDialogPage::UpdateScrollBarThumb()
  1877     {
  1996     {
       
  1997 	_AKNTRACE_FUNC_ENTER;
  1878     if ( !iFormControl || !iPageContainer->ScrollBar() || ScbState() )
  1998     if ( !iFormControl || !iPageContainer->ScrollBar() || ScbState() )
  1879         {
  1999         {
       
  2000         _AKNTRACE_FUNC_EXIT;
  1880         return;
  2001         return;
  1881         }
  2002         }
  1882 
  2003 
  1883     CAknScrollBar* scrollBar = STATIC_CAST(CAknScrollBar*, iPageContainer->ScrollBar()->VerticalScrollBar());
  2004     CAknScrollBar* scrollBar = STATIC_CAST(CAknScrollBar*, iPageContainer->ScrollBar()->VerticalScrollBar());
  1884     
  2005     
  1890         // TODO: replace iLines->MinimumSize with world size, presumably saved in CAknFormPhysics
  2011         // TODO: replace iLines->MinimumSize with world size, presumably saved in CAknFormPhysics
  1891         vertModel.iScrollSpan = iLines->MinimumSize().iHeight;
  2012         vertModel.iScrollSpan = iLines->MinimumSize().iHeight;
  1892         vertModel.iThumbSpan = iSize.iHeight - iSize.iHeight % 2;
  2013         vertModel.iThumbSpan = iSize.iHeight - iSize.iHeight % 2;
  1893         vertModel.iThumbPosition = Max( iPhysics->ViewTopY(), 0 );
  2014         vertModel.iThumbPosition = Max( iPhysics->ViewTopY(), 0 );
  1894 
  2015 
  1895         iExtension->iPreviousThumbPosition = vertModel.iThumbPosition;
       
  1896         TRAP_IGNORE(scrollBar->SetModelL(&vertModel)); // won't leave now, but can't guarantee forever        
  2016         TRAP_IGNORE(scrollBar->SetModelL(&vertModel)); // won't leave now, but can't guarantee forever        
  1897         iPageContainer->ScrollBar()->Tile(&vertModel);
  2017         iPageContainer->ScrollBar()->Tile(&vertModel);
  1898         iPageContainer->ScrollBar()->SetVFocusPosToThumbPos(vertModel.iThumbPosition);
  2018         iPageContainer->ScrollBar()->SetVFocusPosToThumbPos(vertModel.iThumbPosition);
  1899         }
  2019         }
       
  2020     _AKNTRACE_FUNC_EXIT;
  1900     }
  2021     }
  1901 
  2022 
  1902 CCoeControl* CEikDialogPage::ComponentControl(TInt aIndex) const
  2023 CCoeControl* CEikDialogPage::ComponentControl(TInt aIndex) const
  1903     {
  2024     {
  1904     if ( IsForm() && !iExtension->iHandlingResourceChange)
  2025     if ( IsForm() && !iExtension->iHandlingResourceChange)
  1961     PrepareToDrawVerticalLine();
  2082     PrepareToDrawVerticalLine();
  1962     }
  2083     }
  1963 
  2084 
  1964 void CEikDialogPage::ShowFocus(TBool aFocus, TBool aRedraw)
  2085 void CEikDialogPage::ShowFocus(TBool aFocus, TBool aRedraw)
  1965     {
  2086     {
       
  2087 	_AKNTRACE_FUNC_ENTER;
  1966     if (iCurrentLine>=0)
  2088     if (iCurrentLine>=0)
  1967         {
  2089         {
  1968         if ( iExtension && iExtension->iUsesSingleClick && aFocus )
  2090         if ( iExtension && iExtension->iUsesSingleClick && aFocus )
  1969             {
  2091             {
  1970             aFocus = HighlightVisible();
  2092             aFocus = HighlightVisible();
  1975         if (aRedraw)
  2097         if (aRedraw)
  1976             (*iLines)[iCurrentLine]->DrawNow();
  2098             (*iLines)[iCurrentLine]->DrawNow();
  1977         else 
  2099         else 
  1978             (*iLines)[iCurrentLine]->DrawDeferred(); 
  2100             (*iLines)[iCurrentLine]->DrawDeferred(); 
  1979         }
  2101         }
       
  2102     _AKNTRACE_FUNC_EXIT;
  1980     }
  2103     }
  1981 
  2104 
  1982 void CEikDialogPage::ChangeFocusTo(TInt aLineIndex)
  2105 void CEikDialogPage::ChangeFocusTo(TInt aLineIndex)
  1983     {
  2106     {
       
  2107 	_AKNTRACE_FUNC_ENTER;
       
  2108 	_AKNTRACE( "CEikDialogPage::ChangeFocusTo() aLineIndex: [%d]", aLineIndex );
  1984     TInt oldLine = iCurrentLine;
  2109     TInt oldLine = iCurrentLine;
  1985     
  2110     
  1986     if (aLineIndex==iCurrentLine)
  2111     if (aLineIndex==iCurrentLine)
  1987         return;
  2112         return;
       
  2113     // If current line has settingslist open, close it
       
  2114     CEikCaptionedControl* currentLine = CurrentLine();
       
  2115     if ( currentLine && 
       
  2116          currentLine->ControlIsAPopfield( currentLine->ControlType() ) )
       
  2117         {
       
  2118         CAknPopupField *field = ( CAknPopupField* )currentLine->iControl;
       
  2119         if ( field && field->SelectionMode() 
       
  2120             == CAknPopupField::EAknPopupFieldSelectionListMode )
       
  2121             {
       
  2122             TRAP_IGNORE( field->CloseSelectionListL() );
       
  2123             }
       
  2124         }
       
  2125     // If new line is edwin, move cursor to the end of the string.
       
  2126     CEikCaptionedControl* theNewLine =  (*iLines)[aLineIndex];
       
  2127     if ( iExtension->iSetInitialFocusDone 
       
  2128     		&& IsForm()
       
  2129     		&& theNewLine->ControlIsAnEdwin( theNewLine->iControlType ) 
       
  2130     		&& theNewLine->iIsEditable )
       
  2131     	{
       
  2132         CEikEdwin* edwinPtr = STATIC_CAST( CEikEdwin*, theNewLine->iControl );
       
  2133         if( edwinPtr->Text() )
       
  2134         	{
       
  2135             TRAP_IGNORE( edwinPtr->SetCursorPosL( edwinPtr->TextLength(), EFalse ) );       
       
  2136         	}
       
  2137     	}
       
  2138 
  1988     ShowFocus( EFalse, EFalse );
  2139     ShowFocus( EFalse, EFalse );
  1989     iCurrentLine=aLineIndex;
  2140     iCurrentLine=aLineIndex;
  1990     ShowFocus(ETrue, EFalse );
  2141     ShowFocus(ETrue, EFalse );
  1991 
  2142 
  1992     if ( ( oldLine != iCurrentLine && IsForm() ) && 
  2143     if ( ( oldLine != iCurrentLine && IsForm() ) && 
  1993             iExtension->iInitialLayoutDone )
  2144             iExtension->iInitialLayoutDone )
  1994         {
  2145         {
       
  2146         // Set temporarily for EFalse to prevent one extra physics update
       
  2147         // because of two calls to iLines->MoveLineToScreen
       
  2148         iExtension->iInitialLayoutDone = EFalse;
       
  2149     
  1995         if ( oldLine != -1 )
  2150         if ( oldLine != -1 )
  1996             {
  2151             {
  1997             iLines->MoveLineToScreen( oldLine, 0, EFalse );
  2152             iLines->MoveLineToScreen( oldLine, 0, EFalse );
  1998             RecordLineL( oldLine );
  2153             TRAP_IGNORE( RecordLineL( oldLine ) );
  1999             }
  2154             }
  2000 
  2155         
  2001 		RecordLineL( iCurrentLine );
  2156         // set back to correct value
       
  2157         iExtension->iInitialLayoutDone = ETrue;
       
  2158 
       
  2159 		TRAP_IGNORE( RecordLineL( iCurrentLine ) );
  2002 		iLines->MoveLineToScreen( iCurrentLine, iPhysics->ViewTopY(), ETrue );
  2160 		iLines->MoveLineToScreen( iCurrentLine, iPhysics->ViewTopY(), ETrue );
  2003 		}
  2161 		}
       
  2162     _AKNTRACE_FUNC_EXIT;
  2004     }
  2163     }
  2005 
  2164 
  2006 TInt CEikDialogPage::FindLineIndex(const CCoeControl* aControl) const
  2165 TInt CEikDialogPage::FindLineIndex(const CCoeControl* aControl) const
  2007     {
  2166     {
  2008     return(iLines->FindLineIndex(aControl));
  2167     return(iLines->FindLineIndex(aControl));
  2024  * Handles a change to the control's resources of type aType
  2183  * Handles a change to the control's resources of type aType
  2025  * which are shared across the environment, e.g. colors or fonts.
  2184  * which are shared across the environment, e.g. colors or fonts.
  2026  */
  2185  */
  2027 void CEikDialogPage::HandleResourceChange(TInt aType)
  2186 void CEikDialogPage::HandleResourceChange(TInt aType)
  2028     {
  2187     {
  2029     if ( aType==KEikDynamicLayoutVariantSwitch )
  2188 	_AKNTRACE_FUNC_ENTER;
       
  2189     if ( aType==KEikDynamicLayoutVariantSwitch && !IsForm() )
  2030         {
  2190         {
  2031         const TInt numLines=iLines->Count();
  2191         const TInt numLines=iLines->Count();
  2032         for ( TInt i=0; i < numLines; i++ )
  2192         for ( TInt i=0; i < numLines; i++ )
  2033             {
  2193             {
  2034             CEikCaptionedControl* thisLine=(*iLines)[i];
  2194             CEikCaptionedControl* thisLine=(*iLines)[i];
  2104 
  2264 
  2105             default:
  2265             default:
  2106                 break;
  2266                 break;
  2107             }
  2267             }
  2108         }
  2268         }
       
  2269     _AKNTRACE_FUNC_EXIT;
  2109     }
  2270     }
  2110 
  2271 
  2111 CCoeControl* CEikDialogPage::Control(TInt aLineId) const
  2272 CCoeControl* CEikDialogPage::Control(TInt aLineId) const
  2112     {
  2273     {
  2113     return(Line(aLineId)->iControl);
  2274     return(Line(aLineId)->iControl);
  2147     return NULL;
  2308     return NULL;
  2148     }
  2309     }
  2149 
  2310 
  2150 void CEikDialogPage::FocusChanged(TDrawNow /*aDrawNow*/)
  2311 void CEikDialogPage::FocusChanged(TDrawNow /*aDrawNow*/)
  2151     {
  2312     {
       
  2313 	_AKNTRACE_FUNC_ENTER;
  2152     if (iCurrentLine>=0 && !IsFocused())
  2314     if (iCurrentLine>=0 && !IsFocused())
  2153         {
  2315         {
  2154         CEikCaptionedControl* currentLine=(*iLines)[iCurrentLine];
  2316         CEikCaptionedControl* currentLine=(*iLines)[iCurrentLine];
  2155         currentLine->SetCurrent(EFalse);
  2317         currentLine->SetCurrent(EFalse);
  2156         }
  2318         }
       
  2319     _AKNTRACE_FUNC_EXIT;
  2157     }
  2320     }
  2158 
  2321 
  2159 void CEikDialogPage::ResetLineMinimumSizes()
  2322 void CEikDialogPage::ResetLineMinimumSizes()
  2160     {
  2323     {
  2161     iLines->ResetMinimumSizes();
  2324     iLines->ResetMinimumSizes();
  2168 someone accepts the hotkey, to only offering the hot key to the current line and then, only if 
  2331 someone accepts the hotkey, to only offering the hot key to the current line and then, only if 
  2169 it accepts hotkeys.
  2332 it accepts hotkeys.
  2170 
  2333 
  2171   Added Enter key as a special case... 
  2334   Added Enter key as a special case... 
  2172 */
  2335 */
       
  2336        
  2173     if ( (iCurrentLine!=-1) && (iCurrentLine < iLines->Count()) )
  2337     if ( (iCurrentLine!=-1) && (iCurrentLine < iLines->Count()) )
       
  2338         {
  2174         if ( (*iLines)[iCurrentLine]->OfferHotKeys() ||
  2339         if ( (*iLines)[iCurrentLine]->OfferHotKeys() ||
  2175             (*iLines)[iCurrentLine]->TakesEnterKey() && (aKeyEvent.iCode==EKeyEnter)
  2340             (*iLines)[iCurrentLine]->TakesEnterKey() && (aKeyEvent.iCode==EKeyEnter)
  2176             )
  2341             ) 
       
  2342             {
       
  2343             CEikCaptionedControl* currentLine = ( *iLines )[iCurrentLine];
       
  2344             const TInt controlType( currentLine->iControlType );
       
  2345             
       
  2346             if ( currentLine->ControlIsAnEdwin( controlType ) )
       
  2347                 {
       
  2348                 CEikEdwin* edwin = ( CEikEdwin* )currentLine->iControl;
       
  2349                 TBool readOnly = edwin->IsReadOnly();
       
  2350     
       
  2351                 // The control is an editor which is read-only, 
       
  2352                 // such as an on/off control
       
  2353                 if ( readOnly )
       
  2354                     {
       
  2355                     iPageObserver->HandleDialogPageEventL( 
       
  2356                             MEikDialogPageObserver::EDialogPageTapped );
       
  2357                     return EKeyWasConsumed;                                
       
  2358                     }
       
  2359                 }
       
  2360 
  2177             if (!IsForm()|| iIsEditable)
  2361             if (!IsForm()|| iIsEditable)
       
  2362                 {
  2178                 return (*iLines)[iCurrentLine]->iControl->OfferKeyEventL(aKeyEvent,aType);
  2363                 return (*iLines)[iCurrentLine]->iControl->OfferKeyEventL(aKeyEvent,aType);
       
  2364                 }
       
  2365             }
       
  2366         }
  2179     return EKeyWasNotConsumed;
  2367     return EKeyWasNotConsumed;
  2180     }
  2368     }
  2181 
  2369 
  2182 TBool CEikDialogPage::TakesEnterKey()
  2370 TBool CEikDialogPage::TakesEnterKey()
  2183     {
  2371     {
  2187     }
  2375     }
  2188 
  2376 
  2189 void CEikDialogPage::SetEditableL( TBool aEditable, TBool /*aActivePage*/ ) 
  2377 void CEikDialogPage::SetEditableL( TBool aEditable, TBool /*aActivePage*/ ) 
  2190     {
  2378     {
  2191     // Tell each of the controls on the page (which are part of a form) of their editable state.  
  2379     // Tell each of the controls on the page (which are part of a form) of their editable state.  
  2192 
  2380     _AKNTRACE_FUNC_ENTER;
       
  2381     _AKNTRACE( "CEikDialogPage::SetEditableL() aEditable: [%d]", aEditable );
  2193     iIsEditable = aEditable;
  2382     iIsEditable = aEditable;
  2194 
  2383 
       
  2384     TBool initialLayoutDone = iExtension->iInitialLayoutDone;
       
  2385     iExtension->iInitialLayoutDone = EFalse;
       
  2386     
  2195     HighlightVisible( aEditable );
  2387     HighlightVisible( aEditable );
  2196     
  2388     
  2197     if ( iExtension->iUsesSingleClick )
  2389     if ( iExtension->iUsesSingleClick && iExtension->iSetInitialFocusDone )
  2198         {
  2390         {
  2199         ShowFocus( EFalse );
  2391         ShowFocus( EFalse, EFalse );
  2200         }
  2392         }
  2201     
  2393     
  2202     const TInt numLines=iLines->Count() ;
  2394     const TInt numLines=iLines->Count() ;
  2203 /* if a form, no currently selected line, in edit mode,  and there is a line 
  2395 /* if a form, no currently selected line, in edit mode,  and there is a line 
  2204 available (we know this as iLines->Count()>0), then select the first line.
  2396 available (we know this as iLines->Count()>0), then select the first line.
  2266 
  2458 
  2267     if ((iLines->Count()>0) && (iCurrentLine >= 0))
  2459     if ((iLines->Count()>0) && (iCurrentLine >= 0))
  2268         {
  2460         {
  2269         ExposeLine(iCurrentLine,ETrue); 
  2461         ExposeLine(iCurrentLine,ETrue); 
  2270         }
  2462         }
       
  2463     
       
  2464     iExtension->iInitialLayoutDone = initialLayoutDone;
       
  2465     
       
  2466     if ( IsForm() )
       
  2467         {
       
  2468         UpdatePhysics();
       
  2469         }
       
  2470     
       
  2471   _AKNTRACE_FUNC_EXIT;
  2271   }
  2472   }
  2272 
  2473 
  2273 TBool CEikDialogPage::AnythingToDisplay() const
  2474 TBool CEikDialogPage::AnythingToDisplay() const
  2274     {
  2475     {
  2275     // assume Form control... shouldnt be called otherwise (Panic?)
  2476     // assume Form control... shouldnt be called otherwise (Panic?)
  2293     CleanupStack::PopAndDestroy(); // finished with current val of dataBuffer 
  2494     CleanupStack::PopAndDestroy(); // finished with current val of dataBuffer 
  2294     }
  2495     }
  2295 
  2496 
  2296 void CEikDialogPage::Draw(const TRect& /*aRect*/) const
  2497 void CEikDialogPage::Draw(const TRect& /*aRect*/) const
  2297     {
  2498     {
       
  2499 	_AKNTRACE_FUNC_ENTER;
  2298     if ( iFormControl )
  2500     if ( iFormControl )
  2299         {
  2501         {
  2300         // added this to see if anything on the page is visible.
  2502         // added this to see if anything on the page is visible.
  2301         // if not, this is used to display the No data found screen.
  2503         // if not, this is used to display the No data found screen.
  2302         TBool anythingToShow= AnythingToDisplay();
  2504         TBool anythingToShow= AnythingToDisplay();
  2306         if (!anythingToShow)
  2508         if (!anythingToShow)
  2307             {
  2509             {
  2308             // Have to call non const leaving function...  Ignore the TRAP as result is cosmetic only.
  2510             // Have to call non const leaving function...  Ignore the TRAP as result is cosmetic only.
  2309             TRAP_IGNORE( const_cast<CEikDialogPage*>(this)->DrawEmptyListL( windowGcRef ) ) ;
  2511             TRAP_IGNORE( const_cast<CEikDialogPage*>(this)->DrawEmptyListL( windowGcRef ) ) ;
  2310             }
  2512             }
  2311         else
       
  2312             DrawVerticalLine();
       
  2313         
       
  2314         
  2513         
  2315         if ( IsForm() )
  2514         if ( IsForm() )
  2316             {
  2515             {
  2317             TInt delta = iPhysics->ViewCenter().iY;
  2516             TInt delta = iPhysics->ViewCenter().iY;
  2318             delta -= iPhysics->ViewCenterDistance();
  2517             delta -= iPhysics->ViewCenterDistance();
  2336                 }
  2535                 }
  2337             
  2536             
  2338             iExtension->iRecordingGc->FlushBuffer( targetRect, lineToSkip );
  2537             iExtension->iRecordingGc->FlushBuffer( targetRect, lineToSkip );
  2339             }
  2538             }
  2340         }
  2539         }
       
  2540     _AKNTRACE_FUNC_EXIT;
  2341     }
  2541     }
  2342 
  2542 
  2343 void CEikDialogPage::AfterAddingNewLinesL(TInt aNewLineAdded)
  2543 void CEikDialogPage::AfterAddingNewLinesL(TInt aNewLineAdded)
  2344     {
  2544     {
  2345 /**
  2545 /**
  2352 *   #1 register the the dialog page with the caption control.
  2552 *   #1 register the the dialog page with the caption control.
  2353 *   #2 register the control on this line (e.g. an edwin) with the one above it 
  2553 *   #2 register the control on this line (e.g. an edwin) with the one above it 
  2354 *   #3 call Register component on the line, to set up listeners, etc.
  2554 *   #3 call Register component on the line, to set up listeners, etc.
  2355 *   #4 Set the editable value to whatever the dialog page's editable value is.
  2555 *   #4 Set the editable value to whatever the dialog page's editable value is.
  2356 */
  2556 */
       
  2557 	_AKNTRACE_FUNC_ENTER;
       
  2558 	_AKNTRACE( "aNewLineAdded: [%d]", aNewLineAdded );
  2357     __ASSERT_DEBUG(iLines && (aNewLineAdded<=iLines->Count()), Panic(EEikDialogPanicErrorDuringAddingLine));
  2559     __ASSERT_DEBUG(iLines && (aNewLineAdded<=iLines->Count()), Panic(EEikDialogPanicErrorDuringAddingLine));
  2358     if (aNewLineAdded== -1)
  2560     if (aNewLineAdded== -1)
       
  2561         {
       
  2562         _AKNTRACE_FUNC_EXIT;
  2359         return; // line has not been added yet.
  2563         return; // line has not been added yet.
       
  2564         }
  2360     CEikCaptionedControl* lineAdded = iLines->At(aNewLineAdded);
  2565     CEikCaptionedControl* lineAdded = iLines->At(aNewLineAdded);
  2361 // if aNewLineAdded is zero, then there is no line above, else set value.
  2566 // if aNewLineAdded is zero, then there is no line above, else set value.
  2362     CEikCaptionedControl* lineVisuallyAboveAndNumericallyBelow = 
  2567     CEikCaptionedControl* lineVisuallyAboveAndNumericallyBelow = 
  2363                         (!aNewLineAdded)? 0:iLines->At(aNewLineAdded-1);
  2568                         (!aNewLineAdded)? 0:iLines->At(aNewLineAdded-1);
  2364     // #1
  2569     // #1
  2399 
  2604 
  2400     ExposeLine( aNewLineAdded, EFalse );
  2605     ExposeLine( aNewLineAdded, EFalse );
  2401 
  2606 
  2402     if ( IsForm() && iSize.iHeight != 0 && aNewLineAdded != -1 )
  2607     if ( IsForm() && iSize.iHeight != 0 && aNewLineAdded != -1 )
  2403         iLines->MoveLineToScreen( aNewLineAdded, iPhysics->ViewTopY(), EFalse );
  2608         iLines->MoveLineToScreen( aNewLineAdded, iPhysics->ViewTopY(), EFalse );
       
  2609     _AKNTRACE_FUNC_EXIT;
  2404     }
  2610     }
  2405 
  2611 
  2406 TInt CEikDialogPage::GetFormFlags() const
  2612 TInt CEikDialogPage::GetFormFlags() const
  2407     {return iFormFlags;};
  2613     {return iFormFlags;};
  2408 
  2614 
  2461         {
  2667         {
  2462         // Tell the line that it is on a form - activate it to enable it draw its highlight box
  2668         // Tell the line that it is on a form - activate it to enable it draw its highlight box
  2463         aLine->iIsFormControl = iFormControl ;
  2669         aLine->iIsFormControl = iFormControl ;
  2464         if ( iFormFlags )
  2670         if ( iFormFlags )
  2465             aLine->SetFormFlags( iFormFlags ) ;
  2671             aLine->SetFormFlags( iFormFlags ) ;
  2466 
       
  2467         aLine->GetAknLayoutValuesL() ;  // should cause the control to have size.
       
  2468         }
  2672         }
  2469     };
  2673     };
  2470 
  2674 
  2471 
  2675 
  2472 void CEikDialogPage::SetPageContainer(const CEikDialogPageContainer* aPageContainer)
  2676 void CEikDialogPage::SetPageContainer(const CEikDialogPageContainer* aPageContainer)
  2576     CEikCaptionedControl* capCtrl =(*iLines)[lineIndex];
  2780     CEikCaptionedControl* capCtrl =(*iLines)[lineIndex];
  2577     aHeightOfControlVisibleOnPage=capCtrl->Rect().Height();
  2781     aHeightOfControlVisibleOnPage=capCtrl->Rect().Height();
  2578     return EFalse;
  2782     return EFalse;
  2579     }
  2783     }
  2580 
  2784 
  2581 TSize CEikDialogPage::RealDataSize() const
       
  2582     {
       
  2583     if (iLines)
       
  2584         if (iLines->Count()>0)
       
  2585             return TRect((*iLines)[0]->Rect().iTl,(*iLines)[iLines->Count()-1]->Rect().iBr).Size();
       
  2586     return iSize;
       
  2587     }
       
  2588 
       
  2589 TInt CEikDialogPage::NumberOfLines() const
  2785 TInt CEikDialogPage::NumberOfLines() const
  2590     {
  2786     {
  2591     if (iLines)
  2787     if (iLines)
  2592         return iLines->Count();
  2788         return iLines->Count();
  2593     return 0;
  2789     return 0;
  2609 // CEikDialogPage::HandleFormPointerEventL
  2805 // CEikDialogPage::HandleFormPointerEventL
  2610 // ---------------------------------------------------------------------------
  2806 // ---------------------------------------------------------------------------
  2611 //
  2807 //
  2612 void CEikDialogPage::HandleFormPointerEventL( const TPointerEvent& aPointerEvent )
  2808 void CEikDialogPage::HandleFormPointerEventL( const TPointerEvent& aPointerEvent )
  2613     {
  2809     {
       
  2810 	_AKNTRACE_FUNC_ENTER;
  2614     if ( LineHandlerCalled() )
  2811     if ( LineHandlerCalled() )
  2615         {
  2812         {
       
  2813         _AKNTRACE_FUNC_EXIT;
  2616         return;
  2814         return;
  2617         }
  2815         }
  2618     
  2816     
  2619     TInt touchedLine = iLines->YPositionToLineIndex( aPointerEvent.iPosition.iY + iPhysics->ViewTopY() );
  2817     TInt touchedLine = iLines->YPositionToLineIndex( aPointerEvent.iPosition.iY + iPhysics->ViewTopY() );
  2620     TBool callDefaultImplementation = ETrue;
  2818     TBool callDefaultImplementation = ETrue;
  2622     // Tapping form's empty area takes no action of any kind. Also bounce
  2820     // Tapping form's empty area takes no action of any kind. Also bounce
  2623     // effect can't be stopped.
  2821     // effect can't be stopped.
  2624     if ( ( aPointerEvent.iType == TPointerEvent::EButton1Down && touchedLine == KErrNotFound ) || !iPhysics->CanBeStopped() )
  2822     if ( ( aPointerEvent.iType == TPointerEvent::EButton1Down && touchedLine == KErrNotFound ) || !iPhysics->CanBeStopped() )
  2625         {
  2823         {
  2626         IgnoreEventsUntilNextPointerUp();
  2824         IgnoreEventsUntilNextPointerUp();
       
  2825         _AKNTRACE_FUNC_EXIT;
  2627         return;
  2826         return;
  2628         }
  2827         }
  2629 
  2828 
  2630     CEikCaptionedControl* newLine = NULL;
  2829     CEikCaptionedControl* newLine = NULL;
  2631     TInt controlType = KErrNotFound;
  2830     TInt controlType = KErrNotFound;
  2663             }
  2862             }
  2664         }
  2863         }
  2665         
  2864         
  2666     if ( aPointerEvent.iType == TPointerEvent::EButton1Down && touchedLine != KErrNotFound )
  2865     if ( aPointerEvent.iType == TPointerEvent::EButton1Down && touchedLine != KErrNotFound )
  2667         {
  2866         {
       
  2867         _AKNTRACE( "TPointerEvent::EButton1Down" );
  2668         iExtension->iOldCenterY = iPhysics->ViewCenter().iY;
  2868         iExtension->iOldCenterY = iPhysics->ViewCenter().iY;
  2669         TInt bottom = iExtension->iOldCenterY + iSize.iHeight - iSize.iHeight / 2;
  2869         TInt bottom = iExtension->iOldCenterY + iSize.iHeight - iSize.iHeight / 2;
  2670         if ( bottom < 0 )
  2870         if ( bottom < 0 )
  2671             {
  2871             {
  2672             iExtension->iBottomItem = -1;
  2872             iExtension->iBottomItem = -1;
  2691                 {
  2891                 {
  2692                 iExtension->iTopItem = iLines->Count();
  2892                 iExtension->iTopItem = iLines->Count();
  2693                 }
  2893                 }
  2694             }
  2894             }
  2695         iExtension->iScrolling = EFalse;
  2895         iExtension->iScrolling = EFalse;
  2696         iExtension->HandleFormFeedback( this, aPointerEvent, touchedLine, iCurrentLine );
  2896         iExtension->HandleFormFeedback( *this,
       
  2897                                         aPointerEvent,
       
  2898                                         touchedLine,
       
  2899                                         iCurrentLine );
  2697         
  2900         
  2698         TBool wasScrolling = ( iPhysics->OngoingPhysicsAction() != 
  2901         iExtension->iWasScrolling = ( iPhysics->OngoingPhysicsAction() != 
  2699             CAknPhysics::EAknPhysicsActionNone );
  2902         CAknPhysics::EAknPhysicsActionNone );
  2700         iPhysics->Stop();
  2903         if(iExtension->iWasScrolling)
       
  2904             {
       
  2905             iPhysics->Stop();
       
  2906             iExtension->Feedback( *this, ETouchFeedbackList );
       
  2907             }
  2701         iExtension->iLastTouchedLine = touchedLine;
  2908         iExtension->iLastTouchedLine = touchedLine;
  2702         iExtension->iDragStartPosition = aPointerEvent.iPosition;
  2909         iExtension->iDragStartPosition = aPointerEvent.iPosition;
  2703         iExtension->iLastPointerPos = aPointerEvent.iPosition;
  2910         iExtension->iLastPointerPos = aPointerEvent.iPosition;
  2704         iExtension->iStartTime.HomeTime();
  2911         iExtension->iStartTime.HomeTime();
  2705 
  2912 
  2707             {
  2914             {
  2708             iExtension->iFocusedClicked = EFalse;
  2915             iExtension->iFocusedClicked = EFalse;
  2709 
  2916 
  2710             if ( iExtension->iUsesSingleClick )
  2917             if ( iExtension->iUsesSingleClick )
  2711                 {
  2918                 {
  2712                 if ( !wasScrolling )
  2919                 if ( !iExtension->iWasScrolling )
  2713                     {
  2920                     {
  2714                     HighlightVisible( ETrue );
  2921                     if ( iFormFlags & EEikFormDisableHighlightInViewMode )
  2715                     HighlightTimerCallBack( this );
  2922                         {
       
  2923                         HighlightVisible( EFalse );
       
  2924                         }                
       
  2925                     else
       
  2926                         {
       
  2927                         HighlightVisible( ETrue );
       
  2928                         HighlightTimerCallBack( this );
       
  2929                         }
  2716                     }
  2930                     }
  2717                 }
  2931                 }
  2718             else
  2932             else
  2719                 {
  2933                 {
  2720                 iExtension->iHighlightTimer->Cancel();
  2934                 iExtension->iHighlightTimer->Cancel();
  2737                     HighlightVisible( ETrue );
  2951                     HighlightVisible( ETrue );
  2738                     ShowFocus( ETrue, ETrue );
  2952                     ShowFocus( ETrue, ETrue );
  2739                     }
  2953                     }
  2740                 }
  2954                 }
  2741             }
  2955             }
       
  2956         
       
  2957         iExtension->iFlags.Set( CDialogPageExtension::EDragEventsAllowed );
  2742         }
  2958         }
  2743 
  2959 
  2744     if ( aPointerEvent.iType == TPointerEvent::EDrag )
  2960     if ( aPointerEvent.iType == TPointerEvent::EDrag )
  2745         {
  2961         {
       
  2962         _AKNTRACE( "TPointerEvent::EDrag" );
  2746         TPoint drag( iExtension->iDragStartPosition - aPointerEvent.iPosition );
  2963         TPoint drag( iExtension->iDragStartPosition - aPointerEvent.iPosition );
  2747         
  2964         
  2748         if ( Abs( drag.iY ) > iPhysics->DragThreshold() )
  2965         if ( Abs( drag.iY ) > iPhysics->DragThreshold()
       
  2966                 && iExtension->iFlags.IsSet( 
       
  2967                         CDialogPageExtension::EDragEventsAllowed ) )
  2749             {
  2968             {
  2750             iExtension->iHighlightTimer->Cancel();
  2969             iExtension->iHighlightTimer->Cancel();
  2751 
  2970 
  2752             if ( !iExtension->iScrolling && !textSelected )
  2971             if ( !iExtension->iScrolling && !textSelected )
  2753                 {
  2972                 {
  2763                         ShowFocus( EFalse, ETrue );
  2982                         ShowFocus( EFalse, ETrue );
  2764                         }
  2983                         }
  2765                     }
  2984                     }
  2766 
  2985 
  2767                 iExtension->iScrolling = ETrue;
  2986                 iExtension->iScrolling = ETrue;
  2768                 iExtension->iScrolled = ETrue;
       
  2769                 iExtension->iLastPointerPos = aPointerEvent.iPosition;
  2987                 iExtension->iLastPointerPos = aPointerEvent.iPosition;
  2770                 RemovePressedDownHighlight();
  2988                 RemovePressedDownHighlight();
  2771                 iLines->MoveLineToScreen( iCurrentLine, 0, EFalse );
  2989                 iLines->MoveLineToScreen( iCurrentLine, 0, EFalse );
  2772                 callDefaultImplementation = EFalse;
  2990                 callDefaultImplementation = EFalse;
  2773                 }
  2991                 }
  2788             }
  3006             }
  2789         }                                
  3007         }                                
  2790     
  3008     
  2791     if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
  3009     if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
  2792         {
  3010         {
  2793         iExtension->HandleFormFeedback( this, aPointerEvent, touchedLine, iCurrentLine );
  3011         _AKNTRACE( "TPointerEvent::EButton1Up" );
       
  3012         iExtension->HandleFormFeedback( *this,
       
  3013                                         aPointerEvent,
       
  3014                                         touchedLine,
       
  3015                                         iCurrentLine );
  2794         if ( !IsEditable() && iExtension->iUsesSingleClick && 
  3016         if ( !IsEditable() && iExtension->iUsesSingleClick && 
  2795              HighlightVisible() )
  3017              HighlightVisible() )
  2796             {
  3018             {
  2797             HighlightVisible( EFalse );
  3019             HighlightVisible( EFalse );
  2798             
  3020             
  2806 
  3028 
  2807         TPoint drag( iExtension->iDragStartPosition - aPointerEvent.iPosition );
  3029         TPoint drag( iExtension->iDragStartPosition - aPointerEvent.iPosition );
  2808         
  3030         
  2809         if ( !textSelected )
  3031         if ( !textSelected )
  2810             {
  3032             {
  2811             if ( !iPhysics->StartFlick( drag, iExtension->iStartTime ) )
  3033             if ( !iExtension->iFlags.IsSet( CDialogPageExtension::EDragEventsAllowed ) 
       
  3034                     || !iPhysics->StartFlick( drag, iExtension->iStartTime ) )
  2812                 {
  3035                 {
  2813                 iExtension->iScrolling = EFalse;
  3036                 iExtension->iScrolling = EFalse;
  2814                 
  3037                 
  2815                 if ( iPageObserver && GrabbingComponent() )
  3038                 if ( iPageObserver && GrabbingComponent() 
       
  3039                     && !iExtension->iWasScrolling 
       
  3040                     && touchedLine == iCurrentLine )
  2816                     {
  3041                     {
  2817                     iPageObserver->HandleDialogPageEventL( MEikDialogPageObserver::EDialogPageTapped );
  3042                     iPageObserver->HandleDialogPageEventL( MEikDialogPageObserver::EDialogPageTapped );
  2818                     }
  3043                     }
  2819                 }
  3044                 }
  2820             else 
  3045             else 
  2823                 
  3048                 
  2824                 if ( !iExtension->iScrolling )
  3049                 if ( !iExtension->iScrolling )
  2825                     {
  3050                     {
  2826                     // feedback is given every time when new item 
  3051                     // feedback is given every time when new item 
  2827                     // appears to the screen -> follows the visual feedback
  3052                     // appears to the screen -> follows the visual feedback
  2828                     iExtension->SilentFeedback( this, ETouchFeedbackSensitiveItem, aPointerEvent );
  3053                     iExtension->SilentFeedback( *this,
       
  3054                                                 ETouchFeedbackSensitiveList,
       
  3055                                                 aPointerEvent );
       
  3056 
  2829                     // It might happen that there are no drag events between down and
  3057                     // It might happen that there are no drag events between down and
  2830                     // up if the distance is short enough.
  3058                     // up if the distance is short enough.
  2831                     iExtension->iHighlightTimer->Cancel();
  3059                     iExtension->iHighlightTimer->Cancel();
  2832                     iExtension->iScrolling = ETrue;
  3060                     iExtension->iScrolling = ETrue;
  2833                     iExtension->iScrolled = ETrue;
       
  2834                     iLines->MoveLineToScreen( iCurrentLine, 0, EFalse );
  3061                     iLines->MoveLineToScreen( iCurrentLine, 0, EFalse );
  2835                     RemovePressedDownHighlight();
  3062                     RemovePressedDownHighlight();
  2836                     }
  3063                     }
  2837                 }
  3064                 }
  2838             }
  3065             }
       
  3066         
       
  3067         iExtension->iFlags.Clear( CDialogPageExtension::EDragEventsAllowed );
  2839         }
  3068         }
  2840 
  3069 
  2841     // forward pointer event to line's observer
  3070     // forward pointer event to line's observer
  2842     if ( touchedLine == iCurrentLine && newLine && 
  3071     if ( touchedLine == iCurrentLine && newLine && 
  2843             ( iExtension->iFocusedClicked || 
  3072             ( iExtension->iFocusedClicked || 
  2861         aPointerEvent.iType == TPointerEvent::EButton1Up &&
  3090         aPointerEvent.iType == TPointerEvent::EButton1Up &&
  2862         touchedLine == iCurrentLine &&
  3091         touchedLine == iCurrentLine &&
  2863         ( iExtension->iFocusedClicked || iExtension->iUsesSingleClick ) &&
  3092         ( iExtension->iFocusedClicked || iExtension->iUsesSingleClick ) &&
  2864         !iExtension->iScrolling )
  3093         !iExtension->iScrolling )
  2865         {
  3094         {
  2866         mskPress = ETrue;
  3095 		mskPress = ETrue;
  2867         callDefaultImplementation = EFalse;
  3096         callDefaultImplementation = EFalse;
  2868         }
  3097         }
  2869     
       
  2870     if ( callDefaultImplementation && ( iExtension->iFocusedClicked || 
  3098     if ( callDefaultImplementation && ( iExtension->iFocusedClicked || 
  2871             iExtension->iUsesSingleClick ) && newLine )
  3099             iExtension->iUsesSingleClick ) && newLine && 
       
  3100             !iExtension->iWasScrolling )
  2872         {
  3101         {
  2873         if ( newLine->ControlIsAPopfield( controlType ) )
  3102         if ( newLine->ControlIsAPopfield( controlType ) )
  2874             {
  3103             {
  2875             if(aPointerEvent.iType == TPointerEvent::EButton1Down)
  3104             if(aPointerEvent.iType == TPointerEvent::EButton1Down)
  2876                 {
  3105                 {
  2890          
  3119          
  2891     if ( mskPress )
  3120     if ( mskPress )
  2892         {
  3121         {
  2893         TKeyEvent key;
  3122         TKeyEvent key;
  2894         key.iCode=EKeyOK;
  3123         key.iCode=EKeyOK;
  2895         key.iModifiers=0;
  3124         key.iModifiers=EModifierSpecial;
  2896         key.iRepeats = 0;
  3125         key.iRepeats = 0;
  2897         CEikonEnv::Static()->SimulateKeyEventL( key, EEventKey );
  3126         iEikonEnv->SimulateKeyEventL( key, EEventKey );
  2898         }
  3127         }
       
  3128     _AKNTRACE_FUNC_EXIT;
  2899     }
  3129     }
  2900 
  3130 
  2901 
  3131 
  2902 // ---------------------------------------------------------------------------
  3132 // ---------------------------------------------------------------------------
  2903 // CEikDialogPage::UpdatePhysics
  3133 // CEikDialogPage::UpdatePhysics
  2904 // ---------------------------------------------------------------------------
  3134 // ---------------------------------------------------------------------------
  2905 //
  3135 //
  2906 void CEikDialogPage::UpdatePhysics()
  3136 void CEikDialogPage::UpdatePhysics()
  2907     {
  3137     {
       
  3138 	_AKNTRACE_FUNC_ENTER;
  2908     if ( IsForm() )
  3139     if ( IsForm() )
  2909         {
  3140         {
  2910         TPoint viewCenter( iSize.iWidth / 2, 0 );
  3141         TPoint viewCenter( iSize.iWidth / 2, 0 );
  2911         
  3142         
  2912         if ( iLines->Count() > 0 )
  3143         if ( iLines->Count() > 0 )
  2913             {
  3144             {
  2914             viewCenter.iY = Abs( (*iLines)[0]->Rect().iTl.iY - iPosition.iY );
  3145             viewCenter.iY = Abs( (*iLines)[0]->Rect().iTl.iY - iPosition.iY );
  2915             }
  3146             }
  2916             
  3147             
  2917         viewCenter.iY += iPhysics->ViewCenterDistance();
  3148         TInt viewCenterDistance = iPhysics->ViewCenterDistance();
       
  3149         viewCenter.iY += viewCenterDistance;
  2918         
  3150         
  2919         if ( iExtension->iInitialLayoutDone )
  3151         if ( iExtension->iInitialLayoutDone )
  2920             {
  3152             {
  2921             TInt oldScreenHeight = iPhysics->ViewSize().iHeight;
  3153             TInt oldScreenHeight = iPhysics->ViewSize().iHeight;
  2922             TInt delta = ( iPhysics->ViewCenterDistance() ) - 
  3154             TInt delta = ( viewCenterDistance ) - ( oldScreenHeight / 2 );
  2923                 ( oldScreenHeight / 2 );
       
  2924 
  3155 
  2925             viewCenter = iPhysics->ViewCenter();
  3156             viewCenter = iPhysics->ViewCenter();
  2926             viewCenter.iY += delta;
  3157             viewCenter.iY += delta;
  2927             }
  3158             }
  2928 
  3159 
  2929         TSize worldSize( iLines->MinimumSize() );
  3160         TSize worldSize( iLines->MinimumSize() );
  2930         worldSize.iHeight = Max( worldSize.iHeight, iSize.iHeight );
  3161         worldSize.iHeight = Max( worldSize.iHeight, iSize.iHeight );
  2931 
  3162 
       
  3163         // align to borders if those are crossed
       
  3164         if ( viewCenter.iY < viewCenterDistance )
       
  3165             {
       
  3166             viewCenter.iY = viewCenterDistance;
       
  3167             }
       
  3168         else if ( viewCenter.iY > ( worldSize.iHeight - viewCenterDistance ) )
       
  3169             {
       
  3170             viewCenter.iY = worldSize.iHeight - viewCenterDistance;
       
  3171             }
       
  3172         
  2932         TRAP_IGNORE( iPhysics->InitPhysicsL( worldSize, iSize, viewCenter ) );
  3173         TRAP_IGNORE( iPhysics->InitPhysicsL( worldSize, iSize, viewCenter ) );
  2933         TRAP_IGNORE( UpdateScrollBarL() );
  3174         TRAP_IGNORE( UpdateScrollBarL() );
  2934         }
  3175         }
       
  3176     _AKNTRACE_FUNC_EXIT;
  2935     }
  3177     }
  2936 
  3178 
  2937 
  3179 
  2938 // ---------------------------------------------------------------------------
  3180 // ---------------------------------------------------------------------------
  2939 // CEikDialogPage::HighlightTimerCallBack
  3181 // CEikDialogPage::HighlightTimerCallBack
  2962         {
  3204         {
  2963         (*iLines)[touchedLine]->ActivateL();
  3205         (*iLines)[touchedLine]->ActivateL();
  2964         
  3206         
  2965         if ( LineIsFocusable( touchedLine ) )
  3207         if ( LineIsFocusable( touchedLine ) )
  2966             {
  3208             {
  2967             TRAP_IGNORE( PrepareForFocusTransitionL() );
  3209             TRAP_IGNORE( PrepareForFocusTransitionL();
  2968             ChangeFocusToAndExposeL( touchedLine );
  3210                          ChangeFocusToAndExposeL( touchedLine );
  2969             LineChangedL( (*iLines)[touchedLine]->iId );
  3211                          LineChangedL( (*iLines)[touchedLine]->iId );
       
  3212                        );
  2970             }
  3213             }
  2971         }
  3214         }
  2972     }
  3215     }
  2973 
  3216 
  2974 
  3217 
  2991 // ---------------------------------------------------------------------------
  3234 // ---------------------------------------------------------------------------
  2992 // CEikDialogPage::ScrollCacheByPixels
  3235 // CEikDialogPage::ScrollCacheByPixels
  2993 // ---------------------------------------------------------------------------
  3236 // ---------------------------------------------------------------------------
  2994 //
  3237 //
  2995 void CEikDialogPage::ScrollCacheByPixels( 
  3238 void CEikDialogPage::ScrollCacheByPixels( 
  2996 		TInt /*aDelta*/, const TDesC& /*aDebugMsg*/, TBool aDrawNow )
  3239 		TInt /*aDelta*/, TBool aDrawNow )
  2997     {
  3240     {
  2998     if ( iLines->Count() <= 0 )
  3241     if ( iLines->Count() <= 0 )
  2999         return;
  3242         return;
  3000     TInt bottomItem, upperItem;
  3243     TInt bottomItem, upperItem;
  3001     TInt bottom = iPhysics->ViewCenter().iY + iSize.iHeight - iSize.iHeight / 2;
  3244     TInt bottom = iPhysics->ViewCenter().iY + iSize.iHeight - iSize.iHeight / 2;
  3026         }
  3269         }
  3027     if ( upperItem == -1 || bottomItem == iLines->Count() )
  3270     if ( upperItem == -1 || bottomItem == iLines->Count() )
  3028         {
  3271         {
  3029         if ( upperItem != iExtension->iTopItem || bottomItem != iExtension->iBottomItem )
  3272         if ( upperItem != iExtension->iTopItem || bottomItem != iExtension->iBottomItem )
  3030             {
  3273             {
  3031             iExtension->SilentFeedback( this, ETouchFeedbackSensitiveItem, TPointerEvent() );
  3274             switch(iPhysics->OngoingPhysicsAction())
       
  3275                 {
       
  3276                 case CAknPhysics::EAknPhysicsActionBouncing:
       
  3277                 case CAknPhysics::EAknPhysicsActionDragging:
       
  3278                 case CAknPhysics::EAknPhysicsActionFlicking:
       
  3279                     iExtension->SilentFeedback( *this,
       
  3280                             ETouchFeedbackSensitiveList, TPointerEvent() );
       
  3281                     break;
       
  3282                 default:
       
  3283                     break;
       
  3284                 }
  3032             }
  3285             }
  3033         }
  3286         }
  3034     else if ( upperItem >= 0 || bottomItem < iLines->Count() )
  3287     else if ( upperItem >= 0 || bottomItem < iLines->Count() )
  3035         {
  3288         {
  3036         if ( upperItem < iExtension->iTopItem || bottomItem > iExtension->iBottomItem )
  3289         if ( upperItem < iExtension->iTopItem || bottomItem > iExtension->iBottomItem )
  3037             {
  3290             {
  3038             iExtension->SilentFeedback( this, ETouchFeedbackSensitiveItem, TPointerEvent() );
  3291             switch(iPhysics->OngoingPhysicsAction())
       
  3292                 {
       
  3293                 case CAknPhysics::EAknPhysicsActionBouncing:
       
  3294                 case CAknPhysics::EAknPhysicsActionDragging:
       
  3295                 case CAknPhysics::EAknPhysicsActionFlicking:
       
  3296                     iExtension->SilentFeedback( *this,
       
  3297                             ETouchFeedbackSensitiveList, TPointerEvent() );
       
  3298                     break;
       
  3299                 default:
       
  3300                     break;
       
  3301                 }
  3039             }
  3302             }
  3040         }
  3303         }
  3041     iExtension->iBottomItem = bottomItem;
  3304     iExtension->iBottomItem = bottomItem;
  3042     iExtension->iTopItem = upperItem;
  3305     iExtension->iTopItem = upperItem;
  3043     if ( aDrawNow )
  3306     if ( aDrawNow )
  3052 // CEikDialogPage::UpdateLineInCache
  3315 // CEikDialogPage::UpdateLineInCache
  3053 // ---------------------------------------------------------------------------
  3316 // ---------------------------------------------------------------------------
  3054 //
  3317 //
  3055 void CEikDialogPage::UpdateLineInCache( CEikCaptionedControl* aLine )
  3318 void CEikDialogPage::UpdateLineInCache( CEikCaptionedControl* aLine )
  3056     {
  3319     {
       
  3320 	_AKNTRACE_FUNC_ENTER;
       
  3321 	
       
  3322 	if ( !IsActivated() )
       
  3323 	    {
       
  3324         _AKNTRACE_FUNC_EXIT;
       
  3325         return;
       
  3326 	    }
       
  3327 
  3057     TInt lineIndex = iLines->FindLineIndex( aLine );
  3328     TInt lineIndex = iLines->FindLineIndex( aLine );
  3058     
  3329     
  3059     if ( lineIndex != KErrNotFound )
  3330     if ( lineIndex != KErrNotFound )
  3060         {
  3331         {
  3061         if ( aLine->Position() != TPoint( 1000, 0 ) )
  3332         if ( aLine->Position() != TPoint( 1000, 0 ) )
  3078 
  3349 
  3079     if ( iExtension->iInitialLayoutDone )
  3350     if ( iExtension->iInitialLayoutDone )
  3080         {
  3351         {
  3081         UpdatePhysics();
  3352         UpdatePhysics();
  3082         }
  3353         }
       
  3354     _AKNTRACE_FUNC_EXIT;
  3083     }
  3355     }
  3084 
  3356 
  3085 
  3357 
  3086 // ---------------------------------------------------------------------------
  3358 // ---------------------------------------------------------------------------
  3087 // CEikDialogPage::Synchronize
  3359 // CEikDialogPage::Synchronize
  3088 // ---------------------------------------------------------------------------
  3360 // ---------------------------------------------------------------------------
  3089 //
  3361 //
  3090 void CEikDialogPage::Synchronize()
  3362 void CEikDialogPage::Synchronize()
  3091     {
  3363     {
  3092     iExtension->iScrolling = EFalse;
  3364     iExtension->iScrolling = EFalse;
       
  3365     iExtension->iFlags.Clear( CDialogPageExtension::EDragEventsAllowed );
  3093     iLines->MoveLineToScreen( iCurrentLine, iPhysics->ViewTopY(), ETrue );
  3366     iLines->MoveLineToScreen( iCurrentLine, iPhysics->ViewTopY(), ETrue );
  3094     }
  3367     }
  3095 
  3368 
  3096 
  3369 
  3097 // ---------------------------------------------------------------------------
  3370 // ---------------------------------------------------------------------------
  3125 // CEikDialogPage::RecordLinesL
  3398 // CEikDialogPage::RecordLinesL
  3126 // ---------------------------------------------------------------------------
  3399 // ---------------------------------------------------------------------------
  3127 //
  3400 //
  3128 void CEikDialogPage::RecordLinesL()
  3401 void CEikDialogPage::RecordLinesL()
  3129     {
  3402     {
       
  3403 	_AKNTRACE_FUNC_ENTER;
  3130     Parent()->Parent()->Parent()->SetCustomGc( iExtension->iRecordingGc );
  3404     Parent()->Parent()->Parent()->SetCustomGc( iExtension->iRecordingGc );
  3131     
  3405     
  3132     iExtension->iRecordingGc->PurgeBuffer();
  3406     iExtension->iRecordingGc->PurgeBuffer();
  3133 
  3407 
  3134     CEikCaptionedControl* line = NULL;
  3408     CEikCaptionedControl* line = NULL;
  3140         line->DrawForeground( line->Rect() );
  3414         line->DrawForeground( line->Rect() );
  3141         DrawControl( line );
  3415         DrawControl( line );
  3142         }
  3416         }
  3143 
  3417 
  3144     Parent()->Parent()->Parent()->SetCustomGc( NULL );
  3418     Parent()->Parent()->Parent()->SetCustomGc( NULL );
       
  3419     _AKNTRACE_FUNC_EXIT;
  3145     }
  3420     }
  3146 
  3421 
  3147 
  3422 
  3148 // ---------------------------------------------------------------------------
  3423 // ---------------------------------------------------------------------------
  3149 // CEikDialogPage::RecordLineL
  3424 // CEikDialogPage::RecordLineL
  3150 // ---------------------------------------------------------------------------
  3425 // ---------------------------------------------------------------------------
  3151 //
  3426 //
  3152 void CEikDialogPage::RecordLineL( TInt aLine )
  3427 void CEikDialogPage::RecordLineL( TInt aLine )
  3153     {
  3428     {
       
  3429 	_AKNTRACE_FUNC_ENTER;
       
  3430 	_AKNTRACE( "CEikDialogPage::RecordLineL() aLine: [%d]", aLine );
  3154     Parent()->Parent()->Parent()->SetCustomGc( iExtension->iRecordingGc );
  3431     Parent()->Parent()->Parent()->SetCustomGc( iExtension->iRecordingGc );
  3155     
  3432     
  3156     CEikCaptionedControl* line = (*iLines)[aLine];
  3433     CEikCaptionedControl* line = (*iLines)[aLine];
  3157     
  3434     
  3158     if ( line )
  3435     if ( line )
  3161         line->DrawForeground( (line->Rect() ) );
  3438         line->DrawForeground( (line->Rect() ) );
  3162         DrawControl( line );
  3439         DrawControl( line );
  3163         }
  3440         }
  3164     
  3441     
  3165     Parent()->Parent()->Parent()->SetCustomGc( NULL );
  3442     Parent()->Parent()->Parent()->SetCustomGc( NULL );
  3166     }
  3443     _AKNTRACE_FUNC_EXIT;
  3167 
       
  3168 
       
  3169 // ---------------------------------------------------------------------------
       
  3170 // CEikDialogPage::ScrollByPixels
       
  3171 // ---------------------------------------------------------------------------
       
  3172 //
       
  3173 void CEikDialogPage::ScrollByPixels( TInt aDelta )
       
  3174     {
       
  3175     if ( aDelta != 0 )
       
  3176         {
       
  3177         iLines->ScrollByPixels( aDelta );
       
  3178         TRAP_IGNORE( UpdateScrollBarL() );
       
  3179         DrawNow();
       
  3180         TRAP_IGNORE( RecordLinesL() );
       
  3181         }
       
  3182     }
  3444     }
  3183 
  3445 
  3184 
  3446 
  3185 // ---------------------------------------------------------------------------
  3447 // ---------------------------------------------------------------------------
  3186 // CEikDialogPage::RemovePressedDownHighlight
  3448 // CEikDialogPage::RemovePressedDownHighlight
  3195         if ( currentLine && currentLine->PressedDownState() )
  3457         if ( currentLine && currentLine->PressedDownState() )
  3196             {
  3458             {
  3197             currentLine->SetPressedDownState( EFalse );
  3459             currentLine->SetPressedDownState( EFalse );
  3198             if ( IsForm() )
  3460             if ( IsForm() )
  3199                 {
  3461                 {
  3200                 RecordLineL( iCurrentLine );
  3462                 TRAP_IGNORE( RecordLineL( iCurrentLine ) );
  3201                 }
  3463                 }
  3202             }
  3464             }
  3203         }
  3465         }
  3204     }
  3466     }
  3205 
  3467 
  3280         }
  3542         }
  3281     
  3543     
  3282     CCoeControl* grabbingComponent = GrabbingComponent(); 
  3544     CCoeControl* grabbingComponent = GrabbingComponent(); 
  3283     TBool callDefaultImplementation = ETrue;
  3545     TBool callDefaultImplementation = ETrue;
  3284     TBool focusItem = EFalse;
  3546     TBool focusItem = EFalse;
  3285     // YPosToLine is scaled to iDataWinPos, so add it to pointer Y position
  3547     TInt touchedLineIndex = iLines->YPositionToLineIndex( aPointerEvent.iPosition.iY );
  3286     TInt yPosition = aPointerEvent.iPosition.iY; // + iDataWinPos.iY;
  3548 
  3287     TInt touchedLineIndex = YPosToLine2( yPosition );
       
  3288     // If the stylus is down and the touched line is already the current one,
  3549     // If the stylus is down and the touched line is already the current one,
  3289     // mark this fact in iExtension->iFocusedClicked to be used later when the stylus is up.
  3550     // mark this fact in iExtension->iFocusedClicked to be used later when the stylus is up.
  3290     
       
  3291     if ( touchedLineIndex != KErrNotFound && 
  3551     if ( touchedLineIndex != KErrNotFound && 
  3292          iExtension->iCapturingItem != KErrNotFound &&
  3552          iExtension->iCapturingItem != KErrNotFound &&
  3293          touchedLineIndex != iExtension->iCapturingItem )
  3553          touchedLineIndex != iExtension->iCapturingItem )
  3294         {
  3554         {
  3295         iExtension->iCapturingItem = KErrNotFound;
  3555         iExtension->iCapturingItem = KErrNotFound;
  3469     if ( PageContainer()->PageSelector()->Dialg()->Extension()->iPublicFlags.IsSet( CEikDialogExtension::EUseVirtualInput ) )
  3729     if ( PageContainer()->PageSelector()->Dialg()->Extension()->iPublicFlags.IsSet( CEikDialogExtension::EUseVirtualInput ) )
  3470         {
  3730         {
  3471         clear = ETrue;
  3731         clear = ETrue;
  3472         }
  3732         }
  3473         
  3733         
  3474     if ( focusItem || iExtension->iFocusedClicked)
  3734     if ( focusItem || iExtension->iFocusedClicked )
  3475         {
  3735         {
  3476         iExtension->HandleFormFeedback( this, aPointerEvent, touchedLineIndex, iCurrentLine );
  3736         iExtension->HandleFormFeedback( *this,
       
  3737                                         aPointerEvent,
       
  3738                                         touchedLineIndex,
       
  3739                                         iCurrentLine );
  3477         }
  3740         }
  3478                 
  3741                 
  3479     if ( focusItem )
  3742     if ( focusItem )
  3480         {
  3743         {
  3481         PrepareForFocusTransitionL();
  3744         PrepareForFocusTransitionL();
  3482         
  3745         
  3483         (*iLines)[iCurrentLine]->ScrollBackEditor();
  3746         (*iLines)[iCurrentLine]->ScrollBackEditorL();
  3484         ShowFocus( EFalse, EFalse );
  3747         ShowFocus( EFalse, EFalse );
  3485         iCurrentLine = touchedLineIndex;
  3748         iCurrentLine = touchedLineIndex;
  3486         ShowFocus( ETrue, EFalse );        
  3749         ShowFocus( ETrue, EFalse );        
  3487         ExposeLine( iCurrentLine, EFalse );
  3750         ExposeLine( iCurrentLine, EFalse );
  3488         LineChangedL((*iLines)[touchedLineIndex]->iId);
  3751         LineChangedL((*iLines)[touchedLineIndex]->iId);
  3497         {
  3760         {
  3498         TKeyEvent key;
  3761         TKeyEvent key;
  3499         key.iCode=EKeyOK;
  3762         key.iCode=EKeyOK;
  3500         key.iModifiers=0;
  3763         key.iModifiers=0;
  3501         key.iRepeats = 0;
  3764         key.iRepeats = 0;
  3502         CEikonEnv::Static()->SimulateKeyEventL(key, EEventKey);
  3765         iEikonEnv->SimulateKeyEventL(key, EEventKey);
  3503         // SimulateKeyEventL has to be last, because it can
  3766         // SimulateKeyEventL has to be last, because it can
  3504         // possibly delete the dialog.. Must not do anything
  3767         // possibly delete the dialog.. Must not do anything
  3505         // to the dialog after the call.
  3768         // to the dialog after the call.
  3506         }
  3769         }
  3507 
  3770 
  3642     ASSERT(EFalse); // aPageIndex not found.
  3905     ASSERT(EFalse); // aPageIndex not found.
  3643     }
  3906     }
  3644 
  3907 
  3645 TInt CEikDialogPageContainer::ActivateFirstPageL()
  3908 TInt CEikDialogPageContainer::ActivateFirstPageL()
  3646     {
  3909     {
       
  3910 	_AKNTRACE_FUNC_ENTER;
  3647     // Activate first page that isn't dimmed.
  3911     // Activate first page that isn't dimmed.
  3648     // SetToolTips() ;
  3912     // SetToolTips() ;
  3649     const TInt numPages=iPageArray->Count();
  3913     const TInt numPages=iPageArray->Count();
  3650     for (TInt ii=0;ii<numPages;ii++)
  3914     for (TInt ii=0;ii<numPages;ii++)
  3651         {
  3915         {
  3658             if(iActivePage!=ii)
  3922             if(iActivePage!=ii)
  3659                 {
  3923                 {
  3660                 thisPage->ReportPageChangedL();
  3924                 thisPage->ReportPageChangedL();
  3661                 iActivePage=ii;
  3925                 iActivePage=ii;
  3662                 }
  3926                 }
       
  3927             _AKNTRACE_FUNC_EXIT;
  3663             return thisPage->PageId();
  3928             return thisPage->PageId();
  3664             }
  3929             }
  3665         }
  3930         }
  3666 
  3931 
  3667     // All dimmed, so activate first.
  3932     // All dimmed, so activate first.
  3672     if(iActivePage!=0)
  3937     if(iActivePage!=0)
  3673         {
  3938         {
  3674         firstPage->ReportPageChangedL();
  3939         firstPage->ReportPageChangedL();
  3675         iActivePage=0;
  3940         iActivePage=0;
  3676         }
  3941         }
       
  3942     _AKNTRACE_FUNC_EXIT;
  3677     return firstPage->PageId();
  3943     return firstPage->PageId();
  3678     }
  3944     }
  3679 
  3945 
  3680 TInt CEikDialogPageContainer::PageId(TInt aIndex) const
  3946 TInt CEikDialogPageContainer::PageId(TInt aIndex) const
  3681  
  3947  
  4010     return preferredSize;
  4276     return preferredSize;
  4011     }
  4277     }
  4012 
  4278 
  4013 void CEikDialogPageContainer::ActivateL()
  4279 void CEikDialogPageContainer::ActivateL()
  4014     {
  4280     {
       
  4281 	_AKNTRACE_FUNC_ENTER;
  4015     // Pass the activate event to child controls always.
  4282     // Pass the activate event to child controls always.
  4016     CCoeControl::ActivateL();
  4283     CCoeControl::ActivateL();
  4017     //
  4284     //
  4018     // Have to do this here instead of CEikCaptionedControl::ActivateL, because CaptionedControl has no
  4285     // Have to do this here instead of CEikCaptionedControl::ActivateL, because CaptionedControl has no
  4019     // activateL overridden.
  4286     // activateL overridden.
  4037                            );
  4304                            );
  4038                      }
  4305                      }
  4039                  }
  4306                  }
  4040              }
  4307              }
  4041          }  
  4308          }  
       
  4309     _AKNTRACE_FUNC_EXIT;
  4042     }
  4310     }
  4043 
  4311 
  4044 void CEikDialogPageContainer::FocusChanged(TDrawNow aDrawNow)
  4312 void CEikDialogPageContainer::FocusChanged(TDrawNow aDrawNow)
  4045     {
  4313     {
  4046     (*iPageArray)[iActivePage]->SetFocus(IsFocused(),aDrawNow);
  4314     (*iPageArray)[iActivePage]->SetFocus(IsFocused(),aDrawNow);
  4147             }
  4415             }
  4148         }
  4416         }
  4149 
  4417 
  4150     CCoeControl::HandleResourceChange(aType);
  4418     CCoeControl::HandleResourceChange(aType);
  4151 
  4419 
  4152     if(aType==KEikDynamicLayoutVariantSwitch)
  4420     // if this is a form then its size has been set already by 
       
  4421     // CEikDialog::HandleResourceChange
       
  4422     if ( aType == KEikDynamicLayoutVariantSwitch && !iForm )
  4153         {
  4423         {
  4154         SizeChanged();
  4424         SizeChanged();
  4155         }
  4425         }
  4156 
  4426 
  4157     TInt numPages = iPageArray->Count();
  4427     TInt numPages = iPageArray->Count();
  4170 void CEikDialogPageContainer::SetPageSelector(const CEikDialogPageSelector* aPageSelector)
  4440 void CEikDialogPageContainer::SetPageSelector(const CEikDialogPageSelector* aPageSelector)
  4171     {
  4441     {
  4172     iPageSelector = aPageSelector;
  4442     iPageSelector = aPageSelector;
  4173     }
  4443     }
  4174 
  4444 
  4175 void CEikDialogPageContainer::SetPageFormSized()
  4445 void CEikDialogPageContainer::SetPageFormSized(const TRect& aRect)
  4176     {
  4446     {
  4177     iForm = ETrue;
  4447     iForm = ETrue;
  4178 
  4448 
  4179     //
  4449     //
  4180     // Form layout
  4450     // Form layout
  4181     //
  4451     //    
  4182     
  4452     
  4183     /** Dialog page container and page have the same size */
  4453     SetRect(aRect);
  4184     TRect mainPaneRect;
       
  4185     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
       
  4186     mainPaneRect = TRect( mainPaneRect.Size() );    // Moving to point (0, 0)
       
  4187     TAknLayoutRect formPaneLt;
       
  4188     formPaneLt.LayoutRect( mainPaneRect, AknLayoutScalable_Avkon::listscroll_form_pane().LayoutLine() );
       
  4189     formPaneLt.LayoutRect( formPaneLt.Rect(), AknLayoutScalable_Avkon::list_form_gen_pane().LayoutLine() );
       
  4190     
       
  4191     //
       
  4192     // End of form layout
       
  4193     //
       
  4194 
       
  4195     if ( formPaneLt.Rect() != Rect() )
       
  4196         {
       
  4197         // TODO: use static method to do variation between traditional scrolling and panning when available
       
  4198         //SetRect( formPaneLt.Rect() );
       
  4199         SetRect( mainPaneRect );
       
  4200         }
       
  4201 
  4454 
  4202     /** Only forms have line highlight animations. Animation creation is delayed
  4455     /** Only forms have line highlight animations. Animation creation is delayed
  4203       * here.
  4456       * here.
  4204       */
  4457       */
  4205     if ( !iAnimation )
  4458     if ( !iAnimation )