uifw/EikStd/dlgsrc/EIKCAPC.CPP
branchRCL_3
changeset 19 aecbbf00d063
parent 17 a1caeb42b3a3
child 20 d48ab3b357f1
equal deleted inserted replaced
18:fcdfafb36fe7 19:aecbbf00d063
     1 /*
     1 /*
     2 * Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    78 #include <avkon.mbg>
    78 #include <avkon.mbg>
    79 // For MAknMfneCommandObserver
    79 // For MAknMfneCommandObserver
    80 #include <aknmfnecommandobserver.h>
    80 #include <aknmfnecommandobserver.h>
    81 #endif //if defined( RD_SCALABLE_UI_V2)
    81 #endif //if defined( RD_SCALABLE_UI_V2)
    82 
    82 
    83 #include "akntrace.h"
    83 
    84 
    84 
    85 GLREF_C void Panic(TEikDialogPanic aPanic);
    85 GLREF_C void Panic(TEikDialogPanic aPanic);
    86 
    86 
    87 const TInt KViewHighlightColor = 244 ;
    87 const TInt KViewHighlightColor = 244 ;
       
    88 // const TInt KViewHighlightShadowColor = 222 ; 
       
    89 // const TInt KNormalBackgroundColor = 0 ;
       
    90 
       
    91 
       
    92 // Do not reference these directly... Use MaximumNumberOfControlLinesOnVisiblePage() 
       
    93 // const TInt KMaxControlLinesOnPageSingleLineFormat =6;
       
    94 // const TInt KMaxControlLinesOnPageDoubleLineFormat =5;
    88 
    95 
    89 enum
    96 enum
    90     {// must carry on from TSpaceSharingFlags
    97     {// must carry on from TSpaceSharingFlags
    91     EUsesEars       =0x10,
    98     EUsesEars       =0x10,
    92     ELeftEarDown    =0x20,
    99     ELeftEarDown    =0x20,
   102     EOfferAllHotKeys=0x8000,
   109     EOfferAllHotKeys=0x8000,
   103     ETrailerAfterEar=0x10000,
   110     ETrailerAfterEar=0x10000,
   104     ENoBorder       = 0x20000
   111     ENoBorder       = 0x20000
   105     };
   112     };
   106 
   113 
       
   114 const TInt KDynamicEarMask=(ELeftEarDown|ERightEarDown|ELeftEarGrab|ERightEarGrab);
       
   115 
       
   116 const TInt KCapCDefaultHorzEdgeSpacing=0;
       
   117 const TInt KCapCDefaultVertEdgeSpacing=0; 
   107 const TInt KCapCCenterSpacing=0;
   118 const TInt KCapCCenterSpacing=0;
   108 const TInt KControlTrailerSpacing=0;
   119 const TInt KControlTrailerSpacing=0;
       
   120 // const TInt KCapCEarHeightTopHalf=0;
       
   121 // const TInt KCapCEarHeightBottomHalf=0;
       
   122 // const TInt KCapCEarHeight=KCapCEarHeightTopHalf+KCapCEarHeightBottomHalf;
   109 const TInt KCapCEarWidth=0;
   123 const TInt KCapCEarWidth=0;
   110 const TInt KCapCEarSpacing=0;
   124 const TInt KCapCEarSpacing=0;
   111 const TInt KCapCVertCaptionOffset=0;
   125 const TInt KCapCVertCaptionOffset=0;
   112 const TInt KCapCExtraAscent=KCapCVertCaptionOffset+0;
   126 const TInt KCapCExtraAscent=KCapCVertCaptionOffset+0;
   113 const TInt KTrailCVertCaptionOffset=0;
   127 const TInt KTrailCVertCaptionOffset=0;
   114 const TInt KCapCSeparatorAfterSpace=0;
   128 const TInt KCapCSeparatorAfterSpace=0;
       
   129 
       
   130 const TInt KCapCInitialEarRepeat=600000;    // 6 tenths of a second
       
   131 const TInt KCapCEarRepeat=100000; // one tenth of a second
   115 
   132 
   116 /*
   133 /*
   117  *  The following set of static functions return value which have been hard coded from the Series 60 Skins LAF v2.0
   134  *  The following set of static functions return value which have been hard coded from the Series 60 Skins LAF v2.0
   118  *  If a layout DLL becomes available the hard-coded values may be replaced with equivalent Macros.
   135  *  If a layout DLL becomes available the hard-coded values may be replaced with equivalent Macros.
   119  *  NOTE THAT THERE ARE COPIES OF SOME OF THESE FUNCTIONS IN EIKDPAGE.CPP
   136  *  NOTE THAT THERE ARE COPIES OF SOME OF THESE FUNCTIONS IN EIKDPAGE.CPP
   264 /**
   281 /**
   265 * 
   282 * 
   266 * Extension class for additional data members.
   283 * Extension class for additional data members.
   267 *
   284 *
   268 */
   285 */
   269 NONSHARABLE_CLASS( CEikCapCExtension ) : public CBase,
   286 NONSHARABLE_CLASS( CEikCapCExtension ): public MEikFormAnimObserver
   270                                          public MEikFormAnimObserver
       
   271     {
   287     {
   272     friend class CEikCaptionedControl ;
   288     friend class CEikCaptionedControl ;
   273 
   289 
   274 private:
   290 private:
   275     CEikCapCExtension();
   291     CEikCapCExtension();
   331     MTouchFeedback* iFeedback;
   347     MTouchFeedback* iFeedback;
   332 
   348 
   333 public: // needs to be public because idle callback uses these members.
   349 public: // needs to be public because idle callback uses these members.
   334 	CIdle *iIdle;
   350 	CIdle *iIdle;
   335 	CIdleCallbackData *iIdleData;
   351 	CIdleCallbackData *iIdleData;
   336 
   352     /** iPartiallyVisible is used as a protection from changing subcontrol positions of 
       
   353       * partially-visible controls in PositionFormComponents(). This is needed only for
       
   354       * dynamic screen size change.
       
   355       */
       
   356     TBool iPartiallyVisible;
       
   357     
   337     /**
   358     /**
   338      * Boolean used to check if application is single touch compatible.
   359      * Boolean used to check if application is single touch compatible.
   339      */
   360      */
   340     TBool iUsesSingleClick;
   361     TBool iUsesSingleClick;
   341 
   362 
   356     iSelf( NULL ), 
   377     iSelf( NULL ), 
   357     iEditModeHighlightControlContext ( NULL ) ,
   378     iEditModeHighlightControlContext ( NULL ) ,
   358     iViewModeHighlightControlContext ( NULL ) ,
   379     iViewModeHighlightControlContext ( NULL ) ,
   359     iEditModeHighlightControlContextPressed( NULL ),
   380     iEditModeHighlightControlContextPressed( NULL ),
   360     iViewModeHighlightControlContextPressed( NULL ),
   381     iViewModeHighlightControlContextPressed( NULL ),
   361     iPreviousRect( 0, 0, 0, 0 ),
   382     iPreviousRect( TPoint(0, 0), TSize(0, 0) ) ,
   362     iPreviousState( EFalse ) ,
   383     iPreviousState( EFalse ) ,
   363     iPressDownEffect( EFalse ),
   384     iPressDownEffect( EFalse ),
   364     iXOffsetForDataPaneInEditMode( ELayoutEmpty ) ,
   385     iXOffsetForDataPaneInEditMode( ELayoutEmpty ) ,
   365     iYOffsetForDataPaneInEditMode( ELayoutEmpty ) ,
   386     iYOffsetForDataPaneInEditMode( ELayoutEmpty ) ,
   366     iDrawNoWhiteBackground( EFalse ),
   387     iDrawNoWhiteBackground( EFalse ),
   367     iAnimation( NULL )
   388     iAnimation( NULL )
   368 	, iIndicator(NULL),
   389 	, iIndicator(NULL),
   369 	iIndicator2(NULL),
   390 	iIndicator2(NULL),
   370 	iObserver(NULL),
   391 	iObserver(NULL),
   371 	iSimulatedDownEvent( EFalse ),
       
   372     iFeedback( MTouchFeedback::Instance() ),
   392     iFeedback( MTouchFeedback::Instance() ),
   373 	iIdle(NULL),
   393 	iIdle(NULL),
   374 	iIdleData(NULL)
   394 	iIdleData(NULL),
   375     {
   395     iPartiallyVisible( EFalse )
   376     _AKNTRACE_FUNC_ENTER;
   396     {
   377     if ( iAvkonAppUi )
   397     if ( iAvkonAppUi )
   378         {
   398         {
   379         iUsesSingleClick = iAvkonAppUi->IsSingleClickCompatible();
   399         iUsesSingleClick = iAvkonAppUi->IsSingleClickCompatible();
   380         }
   400         }
   381     _AKNTRACE_FUNC_EXIT;
   401     };
   382     }
       
   383 
   402 
   384 CEikCapCExtension::~CEikCapCExtension()
   403 CEikCapCExtension::~CEikCapCExtension()
   385     {
   404     {
   386     _AKNTRACE_FUNC_ENTER;
       
   387     // Remember to unacquire animation
   405     // Remember to unacquire animation
   388     if( iAnimation && iSelf )
   406     if( iAnimation && iSelf )
   389         {
   407         {
   390         if( iSelf->iDialogPage )
   408         if( iSelf->iDialogPage )
   391             iSelf->iDialogPage->AcquireAnim( EFalse, this );
   409             iSelf->iDialogPage->AcquireAnim( EFalse, this );
   392         }
   410         }
   393     _AKNTRACE_FUNC_EXIT;
       
   394     }
   411     }
   395 
   412 
   396 TBool CEikCapCExtension::IsHighlightAnimated() const
   413 TBool CEikCapCExtension::IsHighlightAnimated() const
   397     {
   414     {
   398     if( iAnimation )
   415     if( iAnimation )
   405     return EFalse;
   422     return EFalse;
   406     }
   423     }
   407 
   424 
   408 void CEikCapCExtension::SkinChanged()
   425 void CEikCapCExtension::SkinChanged()
   409     {
   426     {
   410     _AKNTRACE_FUNC_ENTER;
       
   411     iAnimation = NULL;
   427     iAnimation = NULL;
   412     if( iSelf->iDialogPage )
   428     if( iSelf->iDialogPage )
   413         iAnimation = iSelf->iDialogPage->AcquireAnim( ETrue, this );
   429         iAnimation = iSelf->iDialogPage->AcquireAnim( ETrue, this );
   414 
   430 
   415     if( iAnimation )
   431     if( iAnimation )
   416         {
   432         {
   417         iAnimation->SetHighlightSize( iSelf->Rect().Size() );
   433         iAnimation->SetHighlightSize( iSelf->Rect().Size() );
   418         }
   434         }
   419     _AKNTRACE_FUNC_EXIT;
       
   420     }
   435     }
   421 
   436 
   422 void CEikCapCExtension::HandleLayoutSwitch( const TSize& aSize )
   437 void CEikCapCExtension::HandleLayoutSwitch( const TSize& aSize )
   423     {
   438     {
   424     _AKNTRACE_FUNC_ENTER;
       
   425     if( iAnimation )
   439     if( iAnimation )
   426         {
   440         {
   427         if( iAnimation->Size() == aSize )
   441         if( iAnimation->Size() == aSize )
   428             {
   442             {
   429             // No need to resize, just change the background used
   443             // No need to resize, just change the background used
   433         else
   447         else
   434             {
   448             {
   435             iAnimation->SetHighlightSize( aSize );
   449             iAnimation->SetHighlightSize( aSize );
   436             }
   450             }
   437         }
   451         }
   438     _AKNTRACE_FUNC_EXIT;
       
   439     }
   452     }
   440 
   453 
   441 void CEikCapCExtension::AnimFrameReady()
   454 void CEikCapCExtension::AnimFrameReady()
   442     {
   455     {
   443     if( iSelf )
   456     if( iSelf )
   453     // drawing, we only grab a piece from the list background bitmap.
   466     // drawing, we only grab a piece from the list background bitmap.
   454     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   467     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   455     MAknsControlContext* cc = AknsDrawUtils::ControlContext( iSelf->iDialogPage );
   468     MAknsControlContext* cc = AknsDrawUtils::ControlContext( iSelf->iDialogPage );
   456 
   469 
   457     return AknsDrawUtils::DrawBackground( skin, cc, iSelf->iDialogPage, aGc, TPoint(0,0),
   470     return AknsDrawUtils::DrawBackground( skin, cc, iSelf->iDialogPage, aGc, TPoint(0,0),
   458                                           iSelf->Rect(), KAknsDrawParamRGBOnly );
   471                                           iSelf->ViewRect(), KAknsDrawParamRGBOnly );
   459     }
   472     }
   460 
   473 
   461 
   474 
   462 void CEikCapCExtension::SimulatePointerEventToControlL(
   475 void CEikCapCExtension::SimulatePointerEventToControlL(
   463         const TPointerEvent& aPointerEvent )
   476         const TPointerEvent& aPointerEvent )
   465     // Extend form item touch area to whole item area
   478     // Extend form item touch area to whole item area
   466     if ( iSelf->iIsEditable
   479     if ( iSelf->iIsEditable
   467          && ( aPointerEvent.iType == TPointerEvent::EButton1Down 
   480          && ( aPointerEvent.iType == TPointerEvent::EButton1Down 
   468             || aPointerEvent.iType == TPointerEvent::EButton1Up ) )
   481             || aPointerEvent.iType == TPointerEvent::EButton1Up ) )
   469         {
   482         {
       
   483 
   470         // Check control type
   484         // Check control type
   471         TBool edwinControl( LaunchInputType() );
   485         TBool edwinControl( LaunchInputType() );
   472         TBool simulate = EFalse;
   486         TBool simulate = EFalse;
   473 
   487         if ( aPointerEvent.iType == TPointerEvent::EButton1Down
   474         if ( iSelf->Rect().Contains( aPointerEvent.iPosition ) )
   488                 && iSelf->Rect().Contains( aPointerEvent.iPosition )
   475             {
   489                 && !iSelf->iControl->Rect().Contains(
   476             if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
   490                         aPointerEvent.iPosition ) )
   477                  !iSelf->iControl->Rect().Contains( aPointerEvent.iPosition ) )
   491             {
   478                 {
   492             iSimulatedDownEvent = ETrue;
   479                 iSimulatedDownEvent = ETrue;
   493             if ( !edwinControl )
       
   494                 {
   480                 simulate = ETrue;
   495                 simulate = ETrue;
   481                 }
   496                 }
   482             else if ( aPointerEvent.iType == TPointerEvent::EButton1Up &&
   497             }
   483                       iSimulatedDownEvent )
   498         else if ( aPointerEvent.iType == TPointerEvent::EButton1Up
   484                 {
   499                 && iSimulatedDownEvent )
   485                 simulate = ETrue;
   500             {
   486                 }
   501             simulate = ETrue;
   487             }
   502             }
   488 
   503 
   489         // Simulate pointer event to control
   504         // Simulate pointer event to control
   490         if ( simulate && !edwinControl )
   505         if ( simulate && !edwinControl )
   491             {
   506             {
   494                 iSelf->iControl->Rect().iTl + TPoint( 1, 1 );
   509                 iSelf->iControl->Rect().iTl + TPoint( 1, 1 );
   495             iSelf->iControl->HandlePointerEventL( controlEvent );
   510             iSelf->iControl->HandlePointerEventL( controlEvent );
   496             }
   511             }
   497 
   512 
   498         // With edwin do action directly (due to cursor problems)
   513         // With edwin do action directly (due to cursor problems)
   499         else if ( edwinControl &&
   514         else if ( edwinControl && simulate
   500                   simulate &&
   515                 && aPointerEvent.iType == TPointerEvent::EButton1Up )
   501                   ( aPointerEvent.iType == TPointerEvent::EButton1Up ||
   516             {
   502                     aPointerEvent.iType == TPointerEvent::EButton1Down ) )
   517             CAknExtendedInputCapabilities* input( NULL );
   503             {
   518             iSelf->iControl->InputCapabilities().ObjectProvider(
   504             // Basic list feedback is given instead of sensitive edit
   519                     )->MopGetObjectNoChaining( input );
   505             // feedback when tapping editor fields in forms.
   520             if ( input )
   506             if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
   521                 {
   507                 {
   522                 iFeedback->InstantFeedback(
   508                 iFeedback->InstantFeedback( iSelf->iControl,
   523                         iSelf->iControl, ETouchFeedbackEditor,
   509                                             ETouchFeedbackList );
   524                         ETouchFeedbackVibra, aPointerEvent );
   510                 }
   525                 input->ReportEventL(
   511             else
       
   512                 {
       
   513                 iFeedback->InstantFeedback( iSelf->iControl,
       
   514                                             ETouchFeedbackList,
       
   515                                             ETouchFeedbackVibra,
       
   516                                             aPointerEvent );
       
   517                 
       
   518                 CAknExtendedInputCapabilities* input( NULL );
       
   519                 iSelf->iControl->InputCapabilities().ObjectProvider(
       
   520                         )->MopGetObjectNoChaining( input );
       
   521                 
       
   522                 if ( input )
       
   523                     {
       
   524                     input->ReportEventL(
       
   525                         CAknExtendedInputCapabilities::\
   526                         CAknExtendedInputCapabilities::\
   526                             MAknEventObserver::EActivatePenInputRequest,
   527                         MAknEventObserver::EActivatePenInputRequest,
   527                         NULL );
   528                         NULL );
   528                     }
   529                 }
   529                 }
   530             }
   530             }
       
   531 
       
   532         if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   531         if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   533             {
   532             {
   534             iSimulatedDownEvent = EFalse;
   533             iSimulatedDownEvent = EFalse;
   535             }
   534             }
   536         }
   535         }
   588 * This draws the form highlight line
   587 * This draws the form highlight line
   589 *
   588 *
   590 */
   589 */
   591 void CEikCaptionedControlFormHighlightLine::Draw(const TRect& /*aRect*/) const
   590 void CEikCaptionedControlFormHighlightLine::Draw(const TRect& /*aRect*/) const
   592     {
   591     {
   593     _AKNTRACE_FUNC_ENTER;
       
   594     CWindowGc& gc=SystemGc();
   592     CWindowGc& gc=SystemGc();
   595     TBool drawn = EFalse;
   593     TBool drawn = EFalse;
   596 
   594 
   597     if ( IsVisible() && DrawingSkins() )
   595     if ( IsVisible() && DrawingSkins() )
   598         {
   596         {
   658                 gc.SetPenColor( line3Rect.Color() ) ; // black line;
   656                 gc.SetPenColor( line3Rect.Color() ) ; // black line;
   659                 gc.DrawRect(rectToDraw);
   657                 gc.DrawRect(rectToDraw);
   660                 }
   658                 }
   661             }
   659             }
   662         }
   660         }
   663     _AKNTRACE_FUNC_EXIT;
       
   664     };
   661     };
   665 
   662 
   666 
   663 
   667 TInt CEikCaptionedControlFormHighlightLine::HeightOfHighlight(TTopOrBottom aTopOrBottom) const
   664 TInt CEikCaptionedControlFormHighlightLine::HeightOfHighlight(TTopOrBottom aTopOrBottom) const
   668     {
   665     {
   699       }
   696       }
   700 
   697 
   701 
   698 
   702 TBool CEikCaptionedControlFormHighlightLine::DrawingSkins() const
   699 TBool CEikCaptionedControlFormHighlightLine::DrawingSkins() const
   703     {
   700     {
   704     _AKNTRACE_FUNC_ENTER;
       
   705     TBool drawingSkins = EFalse;
   701     TBool drawingSkins = EFalse;
   706     if ( AknsUtils::AvkonSkinEnabled() )
   702     if ( AknsUtils::AvkonSkinEnabled() )
   707         {
   703         {
   708         MAknsSkinInstance* skin = AknsUtils::SkinInstance() ;
   704         MAknsSkinInstance* skin = AknsUtils::SkinInstance() ;
   709         MAknsControlContext* cc = AknsDrawUtils::ControlContext( &iCapCtl ) ;
   705         MAknsControlContext* cc = AknsDrawUtils::ControlContext( &iCapCtl ) ;
   710         CWindowGc& gc = SystemGc();
   706         CWindowGc& gc = SystemGc();
   711         drawingSkins = AknsDrawUtils::Background( skin, cc, this, gc, Rect(), KAknsDrawParamPrepareOnly ); 
   707         drawingSkins = AknsDrawUtils::Background( skin, cc, this, gc, Rect(), KAknsDrawParamPrepareOnly ); 
   712         }
   708         }
   713     _AKNTRACE_FUNC_EXIT;
       
   714     return drawingSkins;
   709     return drawingSkins;
   715     }
   710     }
   716 
   711 
   717 EXPORT_C CEikCaptionedControl::CEikCaptionedControl()
   712 EXPORT_C CEikCaptionedControl::CEikCaptionedControl() : iHasAppendedEditIndicator(EFalse)
   718     {
   713     {
   719     _AKNTRACE_FUNC_ENTER;
       
   720     iNumberOfLines = 1 ;  // default starting value
   714     iNumberOfLines = 1 ;  // default starting value
   721     AKNTASHOOK_ADD( this, "CEikCaptionedControl" );
   715     AKNTASHOOK_ADD( this, "CEikCaptionedControl" );
   722     _AKNTRACE_FUNC_EXIT;
       
   723     }
   716     }
   724 
   717 
   725 EXPORT_C CEikCaptionedControl::~CEikCaptionedControl()
   718 EXPORT_C CEikCaptionedControl::~CEikCaptionedControl()
   726     {
   719     {
   727     _AKNTRACE_FUNC_ENTER;
       
   728     AKNTASHOOK_REMOVE();
   720     AKNTASHOOK_REMOVE();
   729     AknsUtils::DeregisterControlPosition(this);
   721     AknsUtils::DeregisterControlPosition(this);
   730     AknsUtils::DeregisterControlPosition(iBitmap);
   722     AknsUtils::DeregisterControlPosition(iBitmap);
   731     AknsUtils::DeregisterControlPosition(iCaption);
   723     AknsUtils::DeregisterControlPosition(iCaption);
   732     AknsUtils::DeregisterControlPosition(iControl);
   724     AknsUtils::DeregisterControlPosition(iControl);
   740         iControl->SetFocus( EFalse);
   732         iControl->SetFocus( EFalse);
   741     delete iControl;
   733     delete iControl;
   742     delete iCaptionText;
   734     delete iCaptionText;
   743     delete iCaption;
   735     delete iCaption;
   744     delete iTrailer;
   736     delete iTrailer;
       
   737     delete iToolTipText ;
   745     delete iBitmap ;
   738     delete iBitmap ;
   746     delete iHighlightControl ;
   739     delete iHighlightControl ;
   747     if ( iExtension )
   740     if ( iExtension )
   748         {
   741         {
   749 		delete iExtension->iIdle;
   742 		delete iExtension->iIdle;
   754         delete iExtension->iViewModeHighlightControlContextPressed;
   747         delete iExtension->iViewModeHighlightControlContextPressed;
   755 	    delete iExtension->iIndicator;
   748 	    delete iExtension->iIndicator;
   756   		delete iExtension->iIndicator2;
   749   		delete iExtension->iIndicator2;
   757         }
   750         }
   758     delete iExtension ; 
   751     delete iExtension ; 
   759     _AKNTRACE_FUNC_EXIT;
       
   760     }
   752     }
   761 
   753 
   762 EXPORT_C void CEikCaptionedControl::SetPointerEventObserver(MPointerEventObserver *aObserver)
   754 EXPORT_C void CEikCaptionedControl::SetPointerEventObserver(MPointerEventObserver *aObserver)
   763 	{
   755 	{
   764 	if (iExtension)	
   756 	if (iExtension)	
   798     return KErrNone;
   790     return KErrNone;
   799     }
   791     }
   800 
   792 
   801 EXPORT_C TSize CEikCaptionedControl::MinimumSize()
   793 EXPORT_C TSize CEikCaptionedControl::MinimumSize()
   802     {
   794     {
   803     _AKNTRACE_FUNC_ENTER;
       
   804 // NTBD Add an extra line for those with the label on a separate 
   795 // NTBD Add an extra line for those with the label on a separate 
   805     if ( iIsFormControl )
   796     if ( iIsFormControl )
   806         {
   797         {
   807         if (iControl->IsDimmed())
   798         if (iControl->IsDimmed())
   808             {
   799             {
   809             iSize = TSize( 0, 0) ; 
   800             iSize = TSize( 0, 0) ; 
   810             _AKNTRACE_FUNC_EXIT;
       
   811             return iSize;
   801             return iSize;
   812             }
   802             }
   813         // We can get the minimum size from the resource - and the size of the editor (EditorControlSize() in lines)
   803         // We can get the minimum size from the resource - and the size of the editor (EditorControlSize() in lines)
   814         CalculateNumberOfLinesForControl( ENotSupplied );
   804         CalculateNumberOfLinesForControl( ENotSupplied );
   815 
   805 
   880             iNumberOfLines = 0;
   870             iNumberOfLines = 0;
   881             }
   871             }
   882         // ------------------------
   872         // ------------------------
   883 
   873 
   884         iSize = layout.Size();
   874         iSize = layout.Size();
   885         _AKNTRACE_FUNC_EXIT;
       
   886         return ( iSize ) ;
   875         return ( iSize ) ;
   887         }
   876         }
   888     else
   877     else
   889         {   
   878         {   
   890         TSize size=iControl->MinimumSize();
   879         TSize size=iControl->MinimumSize();
   948         if (iCapCFlags&EUsesEars)
   937         if (iCapCFlags&EUsesEars)
   949             {
   938             {
   950             size.iWidth+=KCapCEarWidth+KCapCEarSpacing;
   939             size.iWidth+=KCapCEarWidth+KCapCEarSpacing;
   951             iCaptionWidth+=KCapCEarWidth+KCapCEarSpacing;
   940             iCaptionWidth+=KCapCEarWidth+KCapCEarSpacing;
   952             }
   941             }
   953         size.iWidth+=iCaptionWidth;
   942         size.iHeight+=2*iVertEdgeSpacing;
       
   943         size.iWidth+=iCaptionWidth+2*iHorzEdgeSpacing;
   954         if (iCapCFlags&ESeparatorAfter)
   944         if (iCapCFlags&ESeparatorAfter)
   955             size.iHeight+=KCapCSeparatorAfterSpace;
   945             size.iHeight+=KCapCSeparatorAfterSpace;
   956 
   946         iMinSize=size;
   957         _AKNTRACE_FUNC_EXIT;
   947 
       
   948         if ( iDoNotDisplay )
       
   949             // This flag is set if the control is not to be shown - so set it's height to zero
       
   950             iMinSize.iHeight = 0 ;
   958        return(size);
   951        return(size);
   959         }
   952         }
   960     }
   953     }
   961 /**
   954 /**
   962 * This routine should always called when any state affecting layout changed, including
   955 * This routine should always called when any state affecting layout changed, including
   964 * 
   957 * 
   965 * This is also called from Cone as a matter of course when SetRect is called on the object.
   958 * This is also called from Cone as a matter of course when SetRect is called on the object.
   966 */
   959 */
   967 EXPORT_C void CEikCaptionedControl::SizeChanged()
   960 EXPORT_C void CEikCaptionedControl::SizeChanged()
   968     {
   961     {
   969     _AKNTRACE_FUNC_ENTER;
       
   970     // Resize the animation
   962     // Resize the animation
   971     if( iIsFormControl && iExtension->iAnimation )
   963     if( iIsFormControl && iExtension->iAnimation )
   972         {
   964         {
   973         iExtension->iAnimation->SetHighlightSize( Rect().Size() );
   965         iExtension->iAnimation->SetHighlightSize( Rect().Size() );
   974         }
   966         }
  1131         else if ( mfne )
  1123         else if ( mfne )
  1132             {
  1124             {
  1133             mfne->SetSuppressBackgroundDrawing( EFalse );
  1125             mfne->SetSuppressBackgroundDrawing( EFalse );
  1134             }
  1126             }
  1135         }
  1127         }
  1136     _AKNTRACE_FUNC_EXIT;
       
  1137     }
  1128     }
  1138 
  1129 
  1139 
  1130 
  1140 void CEikCaptionedControl::StretchComponents()
  1131 void CEikCaptionedControl::StretchComponents()
  1141     {
  1132     {
  1142     if (iCapCFlags&EIfTooSmallDontStrech)
  1133     if (iCapCFlags&EIfTooSmallDontStrech)
  1143     	return;
  1134     	return;
  1144     
  1135     
  1145     TRect rect(Rect());
  1136     TRect rect=Rect();
       
  1137     rect.Shrink(iHorzEdgeSpacing,iVertEdgeSpacing);
  1146     if (iCapCFlags&ESeparatorAfter)
  1138     if (iCapCFlags&ESeparatorAfter)
  1147         rect.iBr.iY-=KCapCSeparatorAfterSpace;
  1139         rect.iBr.iY-=KCapCSeparatorAfterSpace;
  1148 
  1140 
  1149     const CFont* editorFont = AknLayoutUtils::FontFromId( iEditorFontId ) ;
  1141     const CFont* editorFont = AknLayoutUtils::FontFromId( iEditorFontId ) ;
  1150 
  1142 
  1151     TInt normalEditorHeight = editorFont->HeightInPixels() + editorFont->DescentInPixels();
  1143     TInt normalEditorHeight = editorFont->HeightInPixels() + editorFont->DescentInPixels() + ( 2 * iVertEdgeSpacing ) ;
  1152     if ( normalEditorHeight > rect.Height() )
  1144     if ( normalEditorHeight > rect.Height() )
  1153         normalEditorHeight = rect.Height() ;
  1145         normalEditorHeight = rect.Height() ;
  1154 
  1146 
  1155     // Insert Bitmap before caption 
  1147     // Insert Bitmap before caption 
  1156     // Note, if position of caption & bitmap is to be configurable this routine will have to be re structured
  1148     // Note, if position of caption & bitmap is to be configurable this routine will have to be re structured
  1157     if ( iBitmap )
  1149     if ( iBitmap )
  1158         {       
  1150         {       
  1159         TPoint bitmapTl( rect.iTl );
  1151         TPoint bitmapTl = rect.iTl ;
  1160         TSize bitmapSize( iBitmap->MinimumSize() );
  1152         TSize bitmapSize = iBitmap->MinimumSize() ;
  1161         if ( bitmapSize.iHeight > normalEditorHeight )
  1153         if ( bitmapSize.iHeight > normalEditorHeight )
  1162             {
  1154             {
  1163             // reduce the size of the bitmap whilst retaining proportion. (will clip the bitmap methinks)
  1155             // reduce the size of the bitmap whilst retaining proportion. (will clip the bitmap methinks)
  1164             TReal ratio = normalEditorHeight/bitmapSize.iHeight ;
  1156             TReal ratio = normalEditorHeight/bitmapSize.iHeight ;
  1165             bitmapSize = TSize( TInt(bitmapSize.iWidth * ratio) , TInt(bitmapSize.iHeight * ratio) ) ;
  1157             bitmapSize = TSize( TInt(bitmapSize.iWidth * ratio) , TInt(bitmapSize.iHeight * ratio) ) ;
  1183         iCaption->SetExtent(capPos,capSize);
  1175         iCaption->SetExtent(capPos,capSize);
  1184         if (iCapCFlags&EExtraAscent)
  1176         if (iCapCFlags&EExtraAscent)
  1185             rect.iTl.iY+=KCapCExtraAscent;
  1177             rect.iTl.iY+=KCapCExtraAscent;
  1186         }
  1178         }
  1187     rect.iTl.iX+=iCaptionWidth;
  1179     rect.iTl.iX+=iCaptionWidth;
       
  1180 
       
  1181     if ((iCapCFlags&EUsesEars) && !(iCapCFlags&ETrailerAfterEar))
       
  1182         rect.iBr.iX-=(KCapCEarWidth+KCapCEarSpacing);
  1188 
  1183 
  1189     if (iTrailer)
  1184     if (iTrailer)
  1190         {
  1185         {
  1191         TSize trailSize=iTrailer->MinimumSize();
  1186         TSize trailSize=iTrailer->MinimumSize();
  1192         TInt trailPosX=rect.iBr.iX-trailSize.iWidth;
  1187         TInt trailPosX=rect.iBr.iX-trailSize.iWidth;
  1194         if(trailSize.iHeight+trailPosY>Rect().iBr.iY)
  1189         if(trailSize.iHeight+trailPosY>Rect().iBr.iY)
  1195             trailSize.iHeight=Rect().iBr.iY-trailPosY;
  1190             trailSize.iHeight=Rect().iBr.iY-trailPosY;
  1196         iTrailer->SetExtent(TPoint(trailPosX,trailPosY),trailSize);
  1191         iTrailer->SetExtent(TPoint(trailPosX,trailPosY),trailSize);
  1197         rect.iBr.iX=trailPosX-KControlTrailerSpacing;
  1192         rect.iBr.iX=trailPosX-KControlTrailerSpacing;
  1198         }
  1193         }
       
  1194     if ((iCapCFlags&EUsesEars) && (iCapCFlags&ETrailerAfterEar))
       
  1195         rect.iBr.iX-=(KCapCEarWidth+KCapCEarSpacing);
  1199 
  1196 
  1200     if(iCapCFlags&EIfTooBigCtlStaysMinHeight && rect.Height()>iControl->MinimumSize().iHeight)
  1197     if(iCapCFlags&EIfTooBigCtlStaysMinHeight && rect.Height()>iControl->MinimumSize().iHeight)
  1201         rect.iBr.iY=rect.iTl.iY+iControl->MinimumSize().iHeight;
  1198         rect.iBr.iY=rect.iTl.iY+iControl->MinimumSize().iHeight;
  1202     if(iCapCFlags&EIfTooBigCtlStaysMinWidth && rect.Width()>iControl->MinimumSize().iWidth)
  1199     if(iCapCFlags&EIfTooBigCtlStaysMinWidth && rect.Width()>iControl->MinimumSize().iWidth)
  1203         rect.iBr.iX=rect.iTl.iX+iControl->MinimumSize().iWidth;
  1200         rect.iBr.iX=rect.iTl.iX+iControl->MinimumSize().iWidth;
  1204     iControl->SetRect(rect);
  1201     iControl->SetRect(rect);
  1205     
  1202     
  1206     }
  1203     }
  1207 
  1204 
  1208 
  1205 
       
  1206 TInt CEikCaptionedControl::WidthForEars(TInt aWidthRemaining) const
       
  1207     {
       
  1208     TInt earWidth=0;
       
  1209     if(iCapCFlags&EUsesEars)
       
  1210         {
       
  1211         const TInt earAndMarginWidth=KCapCEarWidth+KCapCEarSpacing;
       
  1212         if(iTrailer || iCaption)
       
  1213             {
       
  1214             if(aWidthRemaining>(2+(iTrailer?1:0)+(iCaption?1:0))*earAndMarginWidth)
       
  1215                 earWidth=earAndMarginWidth;
       
  1216             else if(aWidthRemaining>(2+(iTrailer?1:0)+(iCaption?1:0))*KCapCEarWidth)
       
  1217                 earWidth=KCapCEarWidth;
       
  1218             }
       
  1219         else
       
  1220             earWidth=Min(aWidthRemaining/2,earAndMarginWidth);
       
  1221         }
       
  1222     return earWidth;
       
  1223     }
       
  1224 
       
  1225 
  1209 void CEikCaptionedControl::SquashComponents()
  1226 void CEikCaptionedControl::SquashComponents()
  1210     {
  1227     {
  1211     TRect rect=Rect();
  1228     TRect rect=Rect();
  1212     // Shrink for Separator
  1229     // Shrink for Separator
  1213     if (iCapCFlags&ESeparatorAfter)
  1230     if (iCapCFlags&ESeparatorAfter)
  1214         rect.iBr.iY-=KCapCSeparatorAfterSpace;
  1231         rect.iBr.iY-=KCapCSeparatorAfterSpace;
  1215 
  1232 
  1216     // Space required before the left of the control rect
  1233     // Space required before the left of the control rect
  1217     TInt desiredLeft=0;
  1234     TInt desiredLeft=iHorzEdgeSpacing;
  1218     if(iCaption)
  1235     if(iCaption)
  1219         desiredLeft+=iCaption->MinimumSize().iWidth+KCapCCenterSpacing;
  1236         desiredLeft+=iCaption->MinimumSize().iWidth+KCapCCenterSpacing;
  1220     if ( iBitmap )
  1237     if ( iBitmap )
  1221         desiredLeft += iBitmap->MinimumSize().iWidth ; // + additional separation?
  1238         desiredLeft += iBitmap->MinimumSize().iWidth ; // + additional separation?
  1222 
  1239 
  1223     // Space required after the right of the control rect
  1240     // Space required after the right of the control rect
  1224     TInt desiredRight=0;
  1241     TInt desiredRight=iHorzEdgeSpacing;
  1225     if(iTrailer)
  1242     if(iTrailer)
  1226         desiredRight+=iTrailer->MinimumSize().iWidth+KControlTrailerSpacing;
  1243         desiredRight+=iTrailer->MinimumSize().iWidth+KControlTrailerSpacing;
  1227     
  1244     
  1228     // Decide on space for the control rect.
  1245     // Decide on space for the control rect.
  1229     TInt controlWidth=0;
  1246     TInt controlWidth=0;
  1239         else
  1256         else
  1240             controlWidth=Max(0,widthRemaining-(desiredLeft+desiredRight+2*(KCapCEarWidth+KCapCEarSpacing)));
  1257             controlWidth=Max(0,widthRemaining-(desiredLeft+desiredRight+2*(KCapCEarWidth+KCapCEarSpacing)));
  1241         widthRemaining-=controlWidth;
  1258         widthRemaining-=controlWidth;
  1242         }
  1259         }
  1243     
  1260     
       
  1261     // Decide if there is space for ears with margins, ears only, or no ears.
       
  1262     TInt earWidth=WidthForEars(widthRemaining);
       
  1263     widthRemaining-=2*earWidth;
       
  1264     
  1244     // Space assigned for before the left of the control rect
  1265     // Space assigned for before the left of the control rect
  1245     TInt actualLeft=0;
  1266     TInt actualLeft=0;
  1246     actualLeft=ScaledSubLength(widthRemaining,desiredLeft,desiredLeft+desiredRight);
  1267     actualLeft=ScaledSubLength(widthRemaining,desiredLeft,desiredLeft+desiredRight);
  1247     // Space assigned for after the right of the control rect
  1268     // Space assigned for after the right of the control rect
  1248     TInt actualRight=widthRemaining-actualLeft;
  1269     TInt actualRight=widthRemaining-actualLeft;
  1273         captionRect.iTl.iX+=actualLeft-actualCaption;
  1294         captionRect.iTl.iX+=actualLeft-actualCaption;
  1274         captionRect.iBr.iX=captionRect.iTl.iX+actualCaption;
  1295         captionRect.iBr.iX=captionRect.iTl.iX+actualCaption;
  1275         if (iCapCFlags&EExtraAscent)
  1296         if (iCapCFlags&EExtraAscent)
  1276             rect.iTl.iY+=KCapCExtraAscent;
  1297             rect.iTl.iY+=KCapCExtraAscent;
  1277         
  1298         
  1278         if(actualLeft>2*(KCapCCenterSpacing))
  1299         if(actualLeft>2*(KCapCCenterSpacing+iHorzEdgeSpacing))
  1279                 {
  1300                 {
       
  1301                 captionRect.iTl.iX+=iHorzEdgeSpacing;
  1280                 captionRect.iBr.iX-=KCapCCenterSpacing;
  1302                 captionRect.iBr.iX-=KCapCCenterSpacing;
  1281                 }
  1303                 }
  1282         const TSize capMin=iCaption->MinimumSize();
  1304         const TSize capMin=iCaption->MinimumSize();
  1283         iCaption->SetExtent(captionRect.iTl,TSize(Min(captionRect.Width(),capMin.iWidth)
  1305         iCaption->SetExtent(captionRect.iTl,TSize(Min(captionRect.Width(),capMin.iWidth)
  1284             ,Min(captionRect.Height(),iCaption->MinimumSize().iHeight)));
  1306             ,Min(captionRect.Height(),iCaption->MinimumSize().iHeight)));
  1287     // Decide if there is room in actualRight for trailer only, or trailer with margins.
  1309     // Decide if there is room in actualRight for trailer only, or trailer with margins.
  1288     if(iTrailer)
  1310     if(iTrailer)
  1289         {
  1311         {
  1290         TInt leftAdjust=0;
  1312         TInt leftAdjust=0;
  1291         TInt rightAdjust=0;
  1313         TInt rightAdjust=0;
  1292         TRect trailerRect(rect);
  1314         TRect trailerRect=rect;
  1293         trailerRect.iTl.iX+=actualLeft+controlWidth;
  1315         trailerRect.iTl.iX+=actualLeft+controlWidth+(iCapCFlags&EUsesEars ? earWidth : 0);
  1294         trailerRect.iTl.iY+=KTrailCVertCaptionOffset;
  1316         trailerRect.iTl.iY+=KTrailCVertCaptionOffset;
  1295 
  1317 
  1296         if(actualRight>2*(KControlTrailerSpacing))
  1318         if(actualRight>2*(iHorzEdgeSpacing+KControlTrailerSpacing))
  1297             {
  1319             {
  1298             leftAdjust=KControlTrailerSpacing;
  1320             if(iCapCFlags&ETrailerAfterEar)
  1299             }
  1321                 {
  1300 
  1322                 leftAdjust=KControlTrailerSpacing+earWidth;
       
  1323                 rightAdjust=iHorzEdgeSpacing;
       
  1324                 }
       
  1325             else
       
  1326                 {
       
  1327                 rightAdjust=earWidth+iHorzEdgeSpacing;
       
  1328                 leftAdjust=KControlTrailerSpacing;
       
  1329                 }
       
  1330             }
       
  1331         else
       
  1332             {
       
  1333             if(iCapCFlags&ETrailerAfterEar)
       
  1334                 leftAdjust=earWidth;
       
  1335             else
       
  1336                 rightAdjust=earWidth;
       
  1337             }
  1301         trailerRect.iTl.iX+=leftAdjust;
  1338         trailerRect.iTl.iX+=leftAdjust;
  1302         trailerRect.iBr.iX-=rightAdjust;
  1339         trailerRect.iBr.iX-=rightAdjust;
  1303         iTrailer->SetExtent(trailerRect.iTl,TSize(trailerRect.Width(),
  1340         iTrailer->SetExtent(trailerRect.iTl,TSize(trailerRect.Width(),
  1304             Min(trailerRect.Height(),iTrailer->MinimumSize().iHeight)));
  1341             Min(trailerRect.Height(),iTrailer->MinimumSize().iHeight)));
  1305         }
  1342         }
  1306     // Position and set the controls space
  1343     // Position and set the controls space
  1307     TRect controlRect=rect;
  1344     TRect controlRect=rect;
  1308     controlRect.iTl.iX+=actualLeft;
  1345     controlRect.iTl.iX+=actualLeft+earWidth;
  1309     controlRect.iBr.iX-=actualRight;
  1346     controlRect.iBr.iX-=(actualRight+earWidth);
  1310     if(iCapCFlags&EIfTooBigCtlStaysMinHeight && controlRect.Height()>iControl->MinimumSize().iHeight)
  1347     if(iCapCFlags&EIfTooBigCtlStaysMinHeight && controlRect.Height()>iControl->MinimumSize().iHeight)
  1311         controlRect.iBr.iY=controlRect.iTl.iY+iControl->MinimumSize().iHeight;
  1348         controlRect.iBr.iY=controlRect.iTl.iY+iControl->MinimumSize().iHeight;
  1312     iControl->SetRect(controlRect);
  1349     iControl->SetRect(controlRect);
  1313     }
  1350     
       
  1351     }
       
  1352 
  1314 
  1353 
  1315 
  1354 
  1316 /**
  1355 /**
  1317  * Sets the flags, aFlags, (see TSpaceSharingFlags), which determine
  1356  * Sets the flags, aFlags, (see TSpaceSharingFlags), which determine
  1318  * the way space is distributed if the captioned control is given too
  1357  * the way space is distributed if the captioned control is given too
  1325     }
  1364     }
  1326 
  1365 
  1327 
  1366 
  1328 static TInt IdleCallback(TAny *aAny)
  1367 static TInt IdleCallback(TAny *aAny)
  1329 {
  1368 {
  1330 	_AKNTRACE_FUNC_ENTER;
       
  1331 	CIdleCallbackData *data = (CIdleCallbackData*)aAny;
  1369 	CIdleCallbackData *data = (CIdleCallbackData*)aAny;
  1332 	CEikCapCExtension *ext = data->iExt;
  1370 	CEikCapCExtension *ext = data->iExt;
  1333 	CEikCaptionedControl *ctrl = data->iCtrl;
  1371 	CEikCaptionedControl *ctrl = data->iCtrl;
  1334 
  1372 
  1335 	CEikEdwin *edwin = (CEikEdwin*)ctrl->iControl;
  1373 	CEikEdwin *edwin = (CEikEdwin*)ctrl->iControl;
  1338 	TRAP_IGNORE ( edwin->SetCursorPosL( (textLength>=0 ? textLength : 0), EFalse) );
  1376 	TRAP_IGNORE ( edwin->SetCursorPosL( (textLength>=0 ? textLength : 0), EFalse) );
  1339 	delete ext->iIdle;
  1377 	delete ext->iIdle;
  1340 	ext->iIdle = NULL;
  1378 	ext->iIdle = NULL;
  1341 	delete data;
  1379 	delete data;
  1342 	ext->iIdleData = NULL;
  1380 	ext->iIdleData = NULL;
  1343 	_AKNTRACE_FUNC_EXIT;
       
  1344 	return EFalse;	
  1381 	return EFalse;	
  1345 }
  1382 }
  1346 
  1383 
  1347 void CEikCaptionedControl::ScrollBackEditorL()
  1384 void CEikCaptionedControl::ScrollBackEditor()
  1348     {
  1385 {
  1349     _AKNTRACE_FUNC_ENTER;
  1386         //
  1350     //
  1387 		// For long single-line edwin, scroll horizontally to show beginning of the edwin
  1351     // For long single-line edwin, scroll horizontally to show beginning
  1388 		// when focus changes away from the edwin.
  1352     // of the edwin when focus changes away from the edwin.
  1389 		// 
  1353     // 
  1390       	if ( iIsEditable && ControlIsAnEdwin(iControlType) )
  1354     if ( iIsEditable && ControlIsAnEdwin( iControlType ) )
  1391 			{
  1355         {
  1392 			delete iExtension->iIdle;
  1356         delete iExtension->iIdle;
  1393 			delete iExtension->iIdleData;
  1357         iExtension->iIdle = NULL;
  1394 			iExtension->iIdleData = new (ELeave) CIdleCallbackData;
  1358         delete iExtension->iIdleData;
  1395 			iExtension->iIdleData->iCtrl = this;
  1359         iExtension->iIdleData = NULL;
  1396 			iExtension->iIdleData->iExt = iExtension;
  1360         iExtension->iIdleData = new (ELeave) CIdleCallbackData;
  1397 			iExtension->iIdle = CIdle::NewL(0);
  1361         iExtension->iIdleData->iCtrl = this;
  1398 			iExtension->iIdle->Start(TCallBack(&IdleCallback, iExtension->iIdleData));
  1362         iExtension->iIdleData->iExt = iExtension;
  1399 			}	
  1363         iExtension->iIdle = CIdle::NewL( 0 );
  1400 }
  1364         iExtension->iIdle->Start(
       
  1365             TCallBack( &IdleCallback, iExtension->iIdleData ) );
       
  1366         }
       
  1367     _AKNTRACE_FUNC_EXIT;
       
  1368     }
       
  1369 
  1401 
  1370 EXPORT_C void CEikCaptionedControl::FocusChanged(TDrawNow aDrawNow)
  1402 EXPORT_C void CEikCaptionedControl::FocusChanged(TDrawNow aDrawNow)
  1371     {    
  1403     {    
  1372     _AKNTRACE_FUNC_ENTER;
       
  1373     // Only form controls need to adapt animation to focus changes.
  1404     // Only form controls need to adapt animation to focus changes.
  1374     if( iExtension->iAnimation && iIsFormControl )
  1405     if( iExtension->iAnimation && iIsFormControl )
  1375         {
  1406         {
  1376         // Pause animation when losing focus (other states ignored)
  1407         // Pause animation when losing focus (other states ignored)
  1377         if( !IsFocused() )
  1408         if( !IsFocused() )
  1378             {
  1409             {
  1379             iExtension->iAnimation->Pause();
  1410             iExtension->iAnimation->Pause();
  1380             }
  1411             }
  1381         else if( iIsCurrentLine && !iIsEditable ) // Current and in view mode
  1412         else if( iIsCurrentLine && !iIsEditable ) // Current and in view mode
  1382             {
  1413             {
  1383             CAknAppUi* aui = static_cast<CAknAppUi*>(iEikonEnv->AppUi());
  1414             CAknAppUi* aui = static_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi());
  1384             if( aui->IsForeground() )
  1415             if( aui->IsForeground() )
  1385                 {
  1416                 {
  1386                 iExtension->iAnimation->Play();
  1417                 iExtension->iAnimation->Play();
  1387                 }
  1418                 }
  1388             }
  1419             }
  1444             if (!focused)
  1475             if (!focused)
  1445                 emphasis=(iCapCFlags&ECurrent? CEikLabel::EPartialEmphasis: CEikLabel::ENoEmphasis);
  1476                 emphasis=(iCapCFlags&ECurrent? CEikLabel::EPartialEmphasis: CEikLabel::ENoEmphasis);
  1446             iCaption->SetEmphasis(emphasis);
  1477             iCaption->SetEmphasis(emphasis);
  1447             }
  1478             }
  1448         }
  1479         }
  1449 
  1480     
  1450     _AKNTRACE_FUNC_EXIT;
  1481 
  1451     }
  1482     if (aDrawNow && iCapCFlags&EUsesEars && IsReadyToDraw())
  1452 
  1483         DrawEarsNow(EBothEars);
       
  1484     }
       
  1485 
       
  1486 
       
  1487 
       
  1488 void CEikCaptionedControl::DrawEarsNow(TWhichEars aEar) const
       
  1489     {
       
  1490     ActivateGc();
       
  1491     DrawEars(aEar);
       
  1492     DeactivateGc();
       
  1493     }
       
  1494 
       
  1495 void CEikCaptionedControl::DrawEars(TWhichEars aEar) const
       
  1496     {
       
  1497     if (aEar&ELeftEar)
       
  1498         DrawSingleEar(ELeftEar,iCapCFlags&ELeftEarDown);
       
  1499     if (aEar&ERightEar)
       
  1500         DrawSingleEar(ERightEar,iCapCFlags&ERightEarDown);
       
  1501     }
       
  1502 
       
  1503 void CEikCaptionedControl::DrawSingleEar(TWhichEars /*aEar*/,TBool /*aPressed*/) const
       
  1504     {
       
  1505     // not needed in S60
       
  1506     }
       
  1507 
       
  1508 TRect CEikCaptionedControl::EarRect(TWhichEars /*aEar*/) const
       
  1509     {
       
  1510     return(TRect(0,0,0,0)); // not needed in S60
       
  1511     }
  1453 
  1512 
  1454 EXPORT_C TInt CEikCaptionedControl::CountComponentControls() const
  1513 EXPORT_C TInt CEikCaptionedControl::CountComponentControls() const
  1455     {
  1514     {
  1456     CCoeControl* controls[] = 
  1515     CCoeControl* controls[] = 
  1457     {
  1516     {
  1496     }
  1555     }
  1497 
  1556 
  1498 
  1557 
  1499 EXPORT_C void CEikCaptionedControl::Draw(const TRect& aRect) const
  1558 EXPORT_C void CEikCaptionedControl::Draw(const TRect& aRect) const
  1500     {   
  1559     {   
  1501     _AKNTRACE_FUNC_ENTER;
       
  1502     if (iIsFormControl )
  1560     if (iIsFormControl )
  1503         DrawAsForm( aRect );
  1561         DrawAsForm( aRect );
  1504     else
  1562     else
  1505         DrawAsEikonDialog( aRect );
  1563         DrawAsEikonDialog( aRect );
  1506     _AKNTRACE_FUNC_EXIT;
       
  1507     }
  1564     }
  1508 
  1565 
  1509 void CEikCaptionedControl::DrawAsForm( const TRect& aRect ) const
  1566 void CEikCaptionedControl::DrawAsForm( const TRect& aRect ) const
  1510     {
  1567     {
  1511     _AKNTRACE_FUNC_ENTER;
  1568 
  1512     CWindowGc& gc=SystemGc();
  1569     CWindowGc& gc=SystemGc();
  1513 
  1570 
  1514     gc.SetPenStyle(CGraphicsContext::ENullPen);
  1571     gc.SetPenStyle(CGraphicsContext::ENullPen);
       
  1572     if ( iRefresh )
       
  1573         {
       
  1574         gc.SetBrushStyle( CGraphicsContext::ESolidBrush ) ;
       
  1575         gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ) ;
       
  1576         }
  1515 
  1577 
  1516     if ( iCaption )
  1578     if ( iCaption )
  1517         {
  1579         {
  1518 // Draw ':' for edit indicator.  ( Skin independant )
  1580 // Draw ':' for edit indicator.  ( Skin independant )
  1519         if ( iIsEditable && iIsCurrentLine )
  1581         if ( iIsEditable && iIsCurrentLine )
  1545         DrawAsFormInEditMode( aRect );
  1607         DrawAsFormInEditMode( aRect );
  1546     else if (!iIsEditable && iIsCurrentLine )
  1608     else if (!iIsEditable && iIsCurrentLine )
  1547         DrawAsFormInViewMode( aRect );
  1609         DrawAsFormInViewMode( aRect );
  1548     else
  1610     else
  1549         DrawAsFormUnFocusedLine( aRect );
  1611         DrawAsFormUnFocusedLine( aRect );
  1550     _AKNTRACE_FUNC_EXIT;
       
  1551     }
  1612     }
  1552 
  1613 
  1553 void CEikCaptionedControl::DrawAsFormInEditMode( const TRect& /*aRect*/ ) const
  1614 void CEikCaptionedControl::DrawAsFormInEditMode( const TRect& /*aRect*/ ) const
  1554     {
  1615     {
  1555     _AKNTRACE_FUNC_ENTER;
       
  1556     CWindowGc& gc=SystemGc();
  1616     CWindowGc& gc=SystemGc();
  1557 
  1617 
  1558     gc.SetPenStyle(CGraphicsContext::ENullPen);
  1618     gc.SetPenStyle(CGraphicsContext::ENullPen);
       
  1619 
       
  1620     if ( iRefresh )
       
  1621         {
       
  1622         gc.SetBrushStyle( CGraphicsContext::ESolidBrush ) ;
       
  1623         gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ) ;
       
  1624         }
  1559 
  1625 
  1560     if (iDialogPage&& iHighlightControl)
  1626     if (iDialogPage&& iHighlightControl)
  1561         {
  1627         {
  1562         TInt height(Rect().Height());
  1628         TInt height(Rect().Height());
  1563         TBool top = iDialogPage->VisibleSizeOnPage(height,iControl);
  1629         TBool top = iDialogPage->VisibleSizeOnPage(height,iControl);
  1616         );
  1682         );
  1617     gc.SetPenStyle(CGraphicsContext::ESolidPen);
  1683     gc.SetPenStyle(CGraphicsContext::ESolidPen);
  1618     gc.SetBrushStyle( CGraphicsContext::ENullBrush ) ;
  1684     gc.SetBrushStyle( CGraphicsContext::ENullBrush ) ;
  1619     gc.SetPenColor( line2Rect.Color() ) ;   
  1685     gc.SetPenColor( line2Rect.Color() ) ;   
  1620     gc.DrawRect(line2Rect.Rect());
  1686     gc.DrawRect(line2Rect.Rect());
  1621     _AKNTRACE_FUNC_EXIT;
       
  1622     }
  1687     }
  1623 
  1688 
  1624 
  1689 
  1625 void CEikCaptionedControl::DrawAsFormInViewMode( const TRect& /*aRect*/ ) const
  1690 void CEikCaptionedControl::DrawAsFormInViewMode( const TRect& /*aRect*/ ) const
  1626     {
  1691     {
  1627     _AKNTRACE_FUNC_ENTER;
       
  1628     CWindowGc& gc=SystemGc();
  1692     CWindowGc& gc=SystemGc();
  1629 
  1693 
  1630     gc.SetPenStyle(CGraphicsContext::ENullPen);
  1694     gc.SetPenStyle(CGraphicsContext::ENullPen);
  1631 
  1695 
       
  1696     if ( iRefresh )
       
  1697         {
       
  1698         gc.SetBrushStyle( CGraphicsContext::ESolidBrush ) ;
       
  1699         gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ) ;
       
  1700         }
       
  1701 
  1632     // This gives the correct Rect for using the Layout functions
  1702     // This gives the correct Rect for using the Layout functions
  1633     TRect viewRect( Rect() ); 
  1703     TRect viewRect=ViewRect(); 
  1634 
  1704 
  1635     TAknLayoutRect line1Rect;
  1705     TAknLayoutRect line1Rect;
  1636     line1Rect.LayoutRect( viewRect, AKN_LAYOUT_WINDOW_List_pane_highlight_graphics__various__Line_1 (viewRect) );
  1706     line1Rect.LayoutRect( viewRect, AKN_LAYOUT_WINDOW_List_pane_highlight_graphics__various__Line_1 (viewRect) );
  1637 
  1707 
  1638     /* This is in view mode, and is the current line
  1708     /* This is in view mode, and is the current line
  1677             TPoint(iVerticalLineXPosition,Rect().iTl.iY+2));
  1747             TPoint(iVerticalLineXPosition,Rect().iTl.iY+2));
  1678         }
  1748         }
  1679 
  1749 
  1680     gc.DrawLine(TPoint(iVerticalLineXPosition,Rect().iBr.iY-1),
  1750     gc.DrawLine(TPoint(iVerticalLineXPosition,Rect().iBr.iY-1),
  1681         TPoint(iVerticalLineXPosition,Rect().iBr.iY+1));
  1751         TPoint(iVerticalLineXPosition,Rect().iBr.iY+1));
  1682     _AKNTRACE_FUNC_EXIT;
       
  1683     }
  1752     }
  1684     
  1753     
  1685 void CEikCaptionedControl::DrawAsFormUnFocusedLine( const TRect& /*aRect*/ ) const
  1754 void CEikCaptionedControl::DrawAsFormUnFocusedLine( const TRect& /*aRect*/ ) const
  1686     {
  1755     {
  1687     _AKNTRACE_FUNC_ENTER;
       
  1688     CWindowGc& gc=SystemGc();
  1756     CWindowGc& gc=SystemGc();
       
  1757 
       
  1758     gc.SetPenStyle(CGraphicsContext::ENullPen);
       
  1759 
       
  1760     if ( iRefresh )
       
  1761         {
       
  1762         gc.SetBrushStyle( CGraphicsContext::ESolidBrush ) ;
       
  1763         gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ) ;
       
  1764         }
  1689 
  1765 
  1690     gc.SetPenStyle(CGraphicsContext::ENullPen);
  1766     gc.SetPenStyle(CGraphicsContext::ENullPen);
  1691     gc.SetBrushStyle( CGraphicsContext::ESolidBrush ) ;
  1767     gc.SetBrushStyle( CGraphicsContext::ESolidBrush ) ;
  1692     gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ) ;  
  1768     gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ) ;  
  1693 
  1769 
  1702     gc.SetPenStyle(CGraphicsContext::ESolidPen);
  1778     gc.SetPenStyle(CGraphicsContext::ESolidPen);
  1703     gc.SetPenColor(iEikonEnv->ControlColor(EColorDialogText,*this));
  1779     gc.SetPenColor(iEikonEnv->ControlColor(EColorDialogText,*this));
  1704     gc.SetBrushStyle( CGraphicsContext::ENullBrush ) ;
  1780     gc.SetBrushStyle( CGraphicsContext::ENullBrush ) ;
  1705     gc.DrawLine(TPoint(iVerticalLineXPosition,Rect().iTl.iY),
  1781     gc.DrawLine(TPoint(iVerticalLineXPosition,Rect().iTl.iY),
  1706         TPoint(iVerticalLineXPosition,Rect().iBr.iY+1));
  1782         TPoint(iVerticalLineXPosition,Rect().iBr.iY+1));
       
  1783     // CEikCaptionedControl* visibleBelow=0; (NOT USED)
  1707 
  1784 
  1708     if (iDialogPage) 
  1785     if (iDialogPage) 
  1709         {
  1786         {
  1710         // visibleBelow=iDialogPage->FindNextControlOnPageWithHeight(EFalse,this); 
  1787         // visibleBelow=iDialogPage->FindNextControlOnPageWithHeight(EFalse,this); 
  1711 
  1788 
  1712         //draw separator line unless This control is at or off the top of the page.
  1789         //draw separator line unless This control is at or off the top of the page.
  1713         TBool atTopOfPage = (iDialogPage && iDialogPage->IsAtOrOffTopOfPage(iControl) );
  1790         TBool atTopOfPage = (iDialogPage && iDialogPage->IsAtOrOffTopOfPage(iControl) );
  1714         if (HasSeparator() && !atTopOfPage)
  1791         if (HasSeparator() && !atTopOfPage)
  1715             DrawFormSeparator( gc );
  1792             DrawFormSeparator( gc );
  1716         }
  1793         }
  1717     _AKNTRACE_FUNC_EXIT;
       
  1718     } 
  1794     } 
  1719 
  1795 
  1720 
  1796 
  1721 // ---------------------------------------------------------------------------
  1797 // ---------------------------------------------------------------------------
  1722 // CEikCaptionedControl::TextColorIndex
  1798 // CEikCaptionedControl::TextColorIndex
  1723 // ---------------------------------------------------------------------------
  1799 // ---------------------------------------------------------------------------
  1724 //
  1800 //
  1725 TAknsQsnTextColorsIndex CEikCaptionedControl::TextColorIndex() const
  1801 TAknsQsnTextColorsIndex CEikCaptionedControl::TextColorIndex() const
  1726     {
  1802     {
  1727     TAknsQsnTextColorsIndex colorIndex = EAknsCIQsnTextColorsCG6;
  1803     TAknsQsnTextColorsIndex colorIndex = EAknsCIQsnTextColorsCG8;
  1728 
  1804 
  1729     // Note control doesn't use highlight text color
  1805     // Note control doesn't use highlight text color
  1730     if ( iControlType != EAknCtNote )
  1806     if ( iControlType != EAknCtNote )
  1731         {
  1807         {
  1732         if ( iIsCurrentLine && iDialogPage->HighlightVisible() )
  1808         if ( iIsCurrentLine && iDialogPage->HighlightVisible() )
  1733             {
  1809             {
  1734             colorIndex = EAknsCIQsnTextColorsCG8;
  1810             colorIndex = EAknsCIQsnTextColorsCG10;
  1735             }
  1811             }
  1736         }
  1812         }
  1737     
  1813     
  1738     return colorIndex;
  1814     return colorIndex;
  1739     }
  1815     }
  1740 
  1816 
  1741 
  1817 
  1742 void CEikCaptionedControl::DrawAsEikonDialog( const TRect& /*aRect*/ ) const
  1818 void CEikCaptionedControl::DrawAsEikonDialog( const TRect& aRect ) const
  1743     {
  1819     {
  1744     _AKNTRACE_FUNC_ENTER;
       
  1745     CWindowGc& gc=SystemGc();
  1820     CWindowGc& gc=SystemGc();
  1746     gc.SetPenStyle(CGraphicsContext::ENullPen);
  1821     gc.SetPenStyle(CGraphicsContext::ENullPen);
  1747 
  1822 
  1748     if (iHighlightControl)
  1823     if (iHighlightControl)
  1749         STATIC_CAST(CEikCaptionedControlFormHighlightLine*,iHighlightControl)->SetTopOrBottom(CEikCaptionedControlFormHighlightLine::EUnset);
  1824         STATIC_CAST(CEikCaptionedControlFormHighlightLine*,iHighlightControl)->SetTopOrBottom(CEikCaptionedControlFormHighlightLine::EUnset);
       
  1825 
       
  1826     if ( iRefresh )
       
  1827         {
       
  1828         gc.SetBrushStyle( CGraphicsContext::ESolidBrush ) ;
       
  1829         gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ) ;
       
  1830         }
       
  1831 
       
  1832 
       
  1833     TRect redrawRect=Rect();
       
  1834     redrawRect.Intersection(aRect);
  1750 
  1835 
  1751     /*
  1836     /*
  1752     *
  1837     *
  1753     * FIX TSW JTON-6HGAND - see also eikdpage.cpp
  1838     * FIX TSW JTON-6HGAND - see also eikdpage.cpp
  1754     *
  1839     *
  1756     *    gc.DrawRect(redrawRect);
  1841     *    gc.DrawRect(redrawRect);
  1757     *
  1842     *
  1758     * Most likely other places using gc.Clear() ( or gc.DrawRect() as 'clear'
  1843     * Most likely other places using gc.Clear() ( or gc.DrawRect() as 'clear'
  1759     * should be fixed also.
  1844     * should be fixed also.
  1760     */
  1845     */
       
  1846     
  1761     if (iCapCFlags&ESeparatorAfter)
  1847     if (iCapCFlags&ESeparatorAfter)
  1762         {
  1848         {
  1763         TRect rect(Rect());
  1849         TRect rect(Rect());
  1764         TPoint separatorStartPt(rect.iTl.iX,rect.iBr.iY-1);
  1850         TPoint separatorStartPt(rect.iTl.iX+iHorzEdgeSpacing/2,rect.iBr.iY-1);
  1765         TPoint separatorEndPt(separatorStartPt.iX, separatorStartPt.iY);
  1851         TPoint separatorEndPt(separatorStartPt.iX+(iFullWidth-iHorzEdgeSpacing), separatorStartPt.iY);
  1766         gc.SetPenStyle(CGraphicsContext::ESolidPen);
  1852         gc.SetPenStyle(CGraphicsContext::ESolidPen);
  1767         gc.SetPenColor(iEikonEnv->ControlColor(EColorWindowText, *this));
  1853         gc.SetPenColor(iEikonEnv->ControlColor(EColorWindowText, *this));
  1768         gc.DrawLine(separatorStartPt, separatorEndPt);
  1854         gc.DrawLine(separatorStartPt, separatorEndPt);
  1769         }
  1855         };
  1770 
  1856 
  1771     _AKNTRACE_FUNC_EXIT;
  1857     if (iCapCFlags&EUsesEars)
       
  1858         DrawEars(EBothEars); 
  1772     }
  1859     }
  1773 
  1860 
  1774 /*
  1861 /*
  1775 * Method to return T/F whether this CEikCaptionedControl has a separator.
  1862 * Method to return T/F whether this CEikCaptionedControl has a separator.
  1776 */
  1863 */
  1780     }
  1867     }
  1781 
  1868 
  1782 
  1869 
  1783 EXPORT_C TKeyResponse CEikCaptionedControl::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
  1870 EXPORT_C TKeyResponse CEikCaptionedControl::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
  1784     {
  1871     {
  1785     _AKNTRACE_FUNC_ENTER;
       
  1786     if ( !iIsFormControl) 
  1872     if ( !iIsFormControl) 
  1787         return iControl->OfferKeyEventL(aKeyEvent,aType);
  1873         return iControl->OfferKeyEventL(aKeyEvent,aType);
  1788     else if ( iIsFormControl && iIsEditable )
  1874     else if ( iIsFormControl && iIsEditable )
  1789         {
  1875         {
  1790         TKeyResponse retVal ;
  1876         TKeyResponse retVal ;
  1791         retVal = iControl->OfferKeyEventL( aKeyEvent, aType ) ;
  1877         retVal = iControl->OfferKeyEventL( aKeyEvent, aType ) ;
  1792         _AKNTRACE_FUNC_EXIT;
       
  1793         return retVal ;
  1878         return retVal ;
  1794         }
  1879         }
  1795     else
  1880     else
  1796         _AKNTRACE_FUNC_EXIT;
       
  1797         return EKeyWasNotConsumed ;
  1881         return EKeyWasNotConsumed ;
  1798     }
  1882     }
  1799 
  1883 
  1800 EXPORT_C TCoeInputCapabilities CEikCaptionedControl::InputCapabilities() const
  1884 EXPORT_C TCoeInputCapabilities CEikCaptionedControl::InputCapabilities() const
  1801     {
  1885     {
  1802     return TCoeInputCapabilities(TCoeInputCapabilities::ENone, NULL, CONST_CAST(CEikCaptionedControl*, this));
  1886     return TCoeInputCapabilities(TCoeInputCapabilities::ENone, NULL, CONST_CAST(CEikCaptionedControl*, this));
  1803     }
  1887     }
  1804 
  1888 
  1805 EXPORT_C void CEikCaptionedControl::SetDimmed(TBool aDimmed)
  1889 EXPORT_C void CEikCaptionedControl::SetDimmed(TBool aDimmed)
  1806     {
  1890     {
  1807     _AKNTRACE_FUNC_ENTER;
       
  1808     CCoeControl::SetDimmed(aDimmed);
  1891     CCoeControl::SetDimmed(aDimmed);
  1809     if (iControl && iControl->IsVisible())
  1892     if (iControl && iControl->IsVisible())
  1810         {
  1893         {
  1811         iControl->SetDimmed(aDimmed);
  1894         iControl->SetDimmed(aDimmed);
  1812         }
  1895         }
  1816         }
  1899         }
  1817     if (iTrailer)
  1900     if (iTrailer)
  1818         {
  1901         {
  1819         iTrailer->SetDimmed(aDimmed);
  1902         iTrailer->SetDimmed(aDimmed);
  1820         }
  1903         }
  1821     _AKNTRACE_FUNC_EXIT;
       
  1822     }
  1904     }
  1823 
  1905 
  1824 EXPORT_C void* CEikCaptionedControl::ExtensionInterface( TUid /*aInterface*/ )
  1906 EXPORT_C void* CEikCaptionedControl::ExtensionInterface( TUid /*aInterface*/ )
  1825     {
  1907     {
  1826     return NULL;
  1908     return NULL;
  1827     }   
  1909     }   
  1828 
  1910 
  1829 EXPORT_C void CEikCaptionedControl::HandlePointerEventL(const TPointerEvent& aPointerEvent)
  1911 EXPORT_C void CEikCaptionedControl::HandlePointerEventL(const TPointerEvent& aPointerEvent)
  1830     {
  1912     {
  1831     _AKNTRACE_FUNC_ENTER;
  1913     if (!IsNonFocusing())
  1832     TBool edwinControl( ControlIsAnEdwin( iControlType ) );
  1914         {
  1833     
  1915         TWhichEars ear=ENoEar;
  1834      if ( iIsFormControl )
  1916         if (aPointerEvent.iType!=TPointerEvent::EButton1Down)
  1835         {
  1917             {
  1836         if ( !PressedDownState() &&
  1918             if (iCapCFlags&ELeftEarGrab)
  1837              aPointerEvent.iType == TPointerEvent::EButton1Down )
  1919                 ear=ELeftEar;
       
  1920             else if (iCapCFlags&ERightEarGrab)
       
  1921                 ear=ERightEar;
       
  1922             if (ear)
       
  1923                 {
       
  1924                 TInt oldDrawFlags=iCapCFlags&(ELeftEarDown|ERightEarDown);
       
  1925                 if (aPointerEvent.iType==TPointerEvent::EButton1Up)
       
  1926                     iCapCFlags&=(~KDynamicEarMask);
       
  1927                 else
       
  1928                     {
       
  1929                     iCapCFlags&=(~(ELeftEarDown|ERightEarDown));
       
  1930                     if (EarRect(ear).Contains(aPointerEvent.iPosition))
       
  1931                         {
       
  1932                         FireEarL(ear, KCapCEarRepeat);
       
  1933                         return;
       
  1934                         }
       
  1935                     }
       
  1936                 if (oldDrawFlags!=(iCapCFlags&(ELeftEarDown|ERightEarDown)))
       
  1937                     DrawEarsNow(ear);
       
  1938                 return;
       
  1939                 }
       
  1940             }
       
  1941         else if (iCapCFlags&EUsesEars)
       
  1942             {
       
  1943             iCapCFlags&=(~KDynamicEarMask);
       
  1944             if (EarRect(ELeftEar).Contains(aPointerEvent.iPosition))
       
  1945                 ear=ELeftEar;
       
  1946             else if (EarRect(ERightEar).Contains(aPointerEvent.iPosition))
       
  1947                 ear=ERightEar;
       
  1948             if (ear)
       
  1949                 {
       
  1950                 FireEarL(ear, KCapCInitialEarRepeat);
       
  1951                 return;
       
  1952                 }
       
  1953             }
       
  1954         }
       
  1955      if (iIsFormControl)
       
  1956         {
       
  1957         if ( PressedDownState()&&
       
  1958             aPointerEvent.iType == TPointerEvent::EButton1Down )
  1838             {
  1959             {
  1839             SetPressedDownState( ETrue );
  1960             SetPressedDownState( ETrue );
  1840             DrawDeferred();
  1961             DrawDeferred();    
  1841             }
  1962             }
  1842         else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
  1963         else if(aPointerEvent.iType == TPointerEvent::EButton1Up)
  1843             {
  1964             {
  1844             _AKNTRACE( "TPointerEvent::EButton1Up" );
       
  1845             SetPressedDownState( EFalse );
  1965             SetPressedDownState( EFalse );
  1846             DrawDeferred();
  1966             DrawDeferred();
  1847             }
  1967             }       
  1848         
       
  1849         if ( ( aPointerEvent.iType == TPointerEvent::EButton1Down || 
       
  1850                aPointerEvent.iType == TPointerEvent::EButton1Up ) &&
       
  1851              iIsEditable &&
       
  1852              edwinControl &&
       
  1853              iExtension &&
       
  1854              iExtension->iFeedback &&
       
  1855              iControl->Rect().Contains( aPointerEvent.iPosition ) )
       
  1856             {
       
  1857             CEikEdwin* edwin = static_cast<CEikEdwin*>( iControl );
       
  1858             if ( edwin &&
       
  1859                  ( edwin->UserFlags() & CEikEdwin::EDisplayOnly ||
       
  1860                    edwin->IsReadOnly() ) )
       
  1861                 {
       
  1862                 // For edwins in view only mode we must produce the feedback
       
  1863                 // here, as the edwin itself doesn't.
       
  1864                 if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
  1865                     {
       
  1866                     iExtension->iFeedback->InstantFeedback( iControl,
       
  1867                                                             ETouchFeedbackList );
       
  1868                     }
       
  1869                 else
       
  1870                     {
       
  1871                     iExtension->iFeedback->InstantFeedback( iControl,
       
  1872                                                             ETouchFeedbackList,
       
  1873                                                             ETouchFeedbackVibra,
       
  1874                                                             aPointerEvent );
       
  1875                     }
       
  1876                 }
       
  1877             }
       
  1878         }
  1968         }
  1879     
  1969     
  1880     if ( !iIsEditable && ( edwinControl || ControlIsAMfne( iControlType ) )
  1970     if ( !iIsEditable && (ControlIsAnEdwin(iControlType) || ControlIsAMfne(iControlType))
  1881        &&( iDialogPage && CEikDialogPage::EDouble == iDialogPage->FormLayout() ))
  1971        &&( iDialogPage && CEikDialogPage::EDouble == iDialogPage->FormLayout() ))
  1882         {
  1972         {
  1883         _AKNTRACE_FUNC_EXIT;
       
  1884 		return;
  1973 		return;
  1885         }
  1974         }
  1886 
  1975 
  1887     CCoeControl::HandlePointerEventL(aPointerEvent);    
  1976     CCoeControl::HandlePointerEventL(aPointerEvent);    
  1888      
  1977      
  1889     if ( iExtension && iIsFormControl )
  1978     if ( iExtension )
  1890         {
  1979         {
  1891         iExtension->SimulatePointerEventToControlL( aPointerEvent );
  1980         iExtension->SimulatePointerEventToControlL( aPointerEvent );
  1892         }
  1981         }
  1893     }
  1982     }
  1894 
  1983 
       
  1984 void CEikCaptionedControl::FireEarL(TWhichEars aEar, TInt aEarRepeat)
       
  1985     {
       
  1986     Window().RequestPointerRepeatEvent(aEarRepeat, EarRect(aEar));
       
  1987     TKeyEvent key;
       
  1988     key.iModifiers=0;
       
  1989     if (aEar==ELeftEar)
       
  1990         {
       
  1991         key.iCode=EKeyLeftArrow;
       
  1992         iCapCFlags|=ELeftEarDown|ELeftEarGrab;
       
  1993         }
       
  1994     else
       
  1995         {
       
  1996         key.iCode=EKeyRightArrow;
       
  1997         iCapCFlags|=ERightEarDown|ERightEarGrab;
       
  1998         }
       
  1999     DrawEarsNow(aEar);
       
  2000     iControl->OfferKeyEventL(key,EEventKey);
       
  2001     }
  1895 
  2002 
  1896 EXPORT_C void CEikCaptionedControl::SetCaptionL(const TDesC& aText)
  2003 EXPORT_C void CEikCaptionedControl::SetCaptionL(const TDesC& aText)
  1897     {
  2004     {
  1898     _AKNTRACE_FUNC_ENTER;
       
  1899     _AKNTRACE("aText = %s", &aText);    
       
  1900     ConstructExtensionL() ; // One of several places where this is made
  2005     ConstructExtensionL() ; // One of several places where this is made
  1901     if (!iCaption)
  2006     if (!iCaption)
  1902         {
  2007         {
  1903 //      Retain a zero sized caption for formatting forms
  2008 //      Retain a zero sized caption for formatting forms
  1904         iCaption=new(ELeave) CEikCapCLabel;
  2009         iCaption=new(ELeave) CEikCapCLabel;
  1907         delete iCaptionText; // get rid of old iCaptionText
  2012         delete iCaptionText; // get rid of old iCaptionText
  1908         iCaptionText=0;
  2013         iCaptionText=0;
  1909         iCaptionText = aText.AllocL();
  2014         iCaptionText = aText.AllocL();
  1910         }
  2015         }
  1911         
  2016         
  1912     if (!iCaption->DrawableWindow())    
  2017     if (iCaption->DrawableWindow() == NULL)    
  1913         {
  2018         {
  1914         iCaption->SetContainerWindowL(*this);
  2019         iCaption->SetContainerWindowL(*this);
  1915         iCaption->CopyControlContextFrom(this);
  2020         iCaption->CopyControlContextFrom(this);
  1916         }
  2021         }
  1917 /*
  2022 /*
  1921 */
  2026 */
  1922     if (iIsFormControl)
  2027     if (iIsFormControl)
  1923         DoFormCaptionSettingsL(aText);
  2028         DoFormCaptionSettingsL(aText);
  1924     else
  2029     else
  1925         iCaption->SetTextL(aText);
  2030         iCaption->SetTextL(aText);
  1926     _AKNTRACE_FUNC_EXIT;
       
  1927     }
  2031     }
  1928 
  2032 
  1929 EXPORT_C void CEikCaptionedControl::SetDrawNoWhiteBackground(TBool aEnabled)
  2033 EXPORT_C void CEikCaptionedControl::SetDrawNoWhiteBackground(TBool aEnabled)
  1930     {
  2034     {
  1931     iExtension->iDrawNoWhiteBackground = aEnabled;
  2035     iExtension->iDrawNoWhiteBackground = aEnabled;
  1932     }
  2036     }
  1933 
  2037 
  1934 EXPORT_C void CEikCaptionedControl::SetTrailerL(const TDesC& aText)
  2038 EXPORT_C void CEikCaptionedControl::SetTrailerL(const TDesC& aText)
  1935     {
  2039     {
  1936     _AKNTRACE_FUNC_ENTER;
       
  1937     if (!aText.Length())
  2040     if (!aText.Length())
  1938         return;
  2041         return;
  1939     if (!iTrailer)
  2042     if (!iTrailer)
  1940         {
  2043         {
  1941         iTrailer=new(ELeave) CEikLabel;
  2044         iTrailer=new(ELeave) CEikLabel;
  1944         iTrailer->CopyControlContextFrom(this);
  2047         iTrailer->CopyControlContextFrom(this);
  1945         iTrailer->SetAllMarginsTo(1);
  2048         iTrailer->SetAllMarginsTo(1);
  1946         iTrailer->SetNonFocusing();
  2049         iTrailer->SetNonFocusing();
  1947         }
  2050         }
  1948     iTrailer->SetTextL(aText);
  2051     iTrailer->SetTextL(aText);
  1949     _AKNTRACE( "SetTextL = %s" , &aText); 
       
  1950     _AKNTRACE_FUNC_EXIT;
       
  1951     }
  2052     }
  1952 
  2053 
  1953 EXPORT_C void CEikCaptionedControl::SetCurrent(TBool aSelected)
  2054 EXPORT_C void CEikCaptionedControl::SetCurrent(TBool aSelected)
  1954     {
  2055     {
  1955     SetCurrent( aSelected, ETrue );
  2056     SetCurrent( aSelected, ETrue );
  1956     }
  2057     }
  1957 
  2058 
  1958 EXPORT_C void CEikCaptionedControl::ConstructFromResourceL(TResourceReader& aReader)
  2059 EXPORT_C void CEikCaptionedControl::ConstructFromResourceL(TResourceReader& aReader)
  1959     {
  2060     {
  1960     _AKNTRACE_FUNC_ENTER;
       
  1961     TPtrC capTextTPtrC = aReader.ReadTPtrC();
  2061     TPtrC capTextTPtrC = aReader.ReadTPtrC();
  1962     iCaptionText = capTextTPtrC.AllocL();
  2062     iCaptionText = capTextTPtrC.AllocL();
  1963     SetCaptionL(capTextTPtrC);
  2063     SetCaptionL(capTextTPtrC);
  1964     iId=aReader.ReadInt16();
  2064     iId=aReader.ReadInt16();
  1965     TInt itemFlags=aReader.ReadInt32();
  2065     TInt itemFlags=aReader.ReadInt32();
  2022 
  2122 
  2023     // Process ToolTip
  2123     // Process ToolTip
  2024     TPtrC16 toolTip = aReader.ReadTPtrC() ;
  2124     TPtrC16 toolTip = aReader.ReadTPtrC() ;
  2025     SetToolTipTextL( toolTip ) ; 
  2125     SetToolTipTextL( toolTip ) ; 
  2026     
  2126     
       
  2127     // Set the border spacing to the default value
       
  2128     SetVertEdgeSpacing( KCapCDefaultVertEdgeSpacing ) ;
       
  2129     SetHorzEdgeSpacing( KCapCDefaultHorzEdgeSpacing ) ;
       
  2130 
  2027     //Added to create new form box closer for edwins in forms.
  2131     //Added to create new form box closer for edwins in forms.
  2028     if (!iHighlightControl)
  2132     if (!iHighlightControl)
  2029         {
  2133         {
  2030         iHighlightControl = new(ELeave) CEikCaptionedControlFormHighlightLine( *this ) ;
  2134         iHighlightControl = new(ELeave) CEikCaptionedControlFormHighlightLine( *this ) ;
  2031         STATIC_CAST(CEikCaptionedControlFormHighlightLine*,iHighlightControl)->ConstructL() ;
  2135         STATIC_CAST(CEikCaptionedControlFormHighlightLine*,iHighlightControl)->ConstructL() ;
  2032         }
  2136         }
  2033     ConstructExtensionL() ;
  2137     ConstructExtensionL() ;
  2034     _AKNTRACE_FUNC_EXIT;
       
  2035     }
  2138     }
  2036 
  2139 
  2037 
  2140 
  2038 EXPORT_C void CEikCaptionedControl::SetBitmapFromFileL( const TDesC& aFilename,TInt aMainId,TInt aMaskId /*=-1*/ ) 
  2141 EXPORT_C void CEikCaptionedControl::SetBitmapFromFileL( const TDesC& aFilename,TInt aMainId,TInt aMaskId /*=-1*/ ) 
  2039     {
  2142     {
  2072         }
  2175         }
  2073     }
  2176     }
  2074 
  2177 
  2075 EXPORT_C void CEikCaptionedControl::ResetMinimumSizes()
  2178 EXPORT_C void CEikCaptionedControl::ResetMinimumSizes()
  2076     {
  2179     {
  2077 	_AKNTRACE_FUNC_ENTER;
  2180     iMinSize.iWidth=0;
  2078     iCaptionWidth=0;
  2181     iCaptionWidth=0;
  2079     _AKNTRACE_FUNC_EXIT;
  2182     iFullWidth=0;
  2080     }
  2183     }
  2081 
  2184 
  2082 EXPORT_C TBool CEikCaptionedControl::IsLatent() const
  2185 EXPORT_C TBool CEikCaptionedControl::IsLatent() const
  2083     {
  2186     {
  2084     return(iCapCFlags&ELatent);
  2187     return(iCapCFlags&ELatent);
  2159  *
  2262  *
  2160  * @since ER5U 
  2263  * @since ER5U 
  2161  */
  2264  */
  2162 EXPORT_C void CEikCaptionedControl::GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const
  2265 EXPORT_C void CEikCaptionedControl::GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const
  2163     {
  2266     {
  2164     _AKNTRACE_FUNC_ENTER;
       
  2165     CCoeControl::GetColorUseListL(aColorUseList);
  2267     CCoeControl::GetColorUseListL(aColorUseList);
  2166 
  2268 
  2167     TCoeColorUse colorUse;
  2269     TCoeColorUse colorUse;
  2168     colorUse.SetLogicalColor(EColorWindowText);
  2270     colorUse.SetLogicalColor(EColorWindowText);
  2169     colorUse.SetUse(TCoeColorUse::EFore|TCoeColorUse::EActive|TCoeColorUse::ESurrounds|TCoeColorUse::ENormal|TCoeColorUse::ENeutral);
  2271     colorUse.SetUse(TCoeColorUse::EFore|TCoeColorUse::EActive|TCoeColorUse::ESurrounds|TCoeColorUse::ENormal|TCoeColorUse::ENeutral);
  2170     aColorUseList.AppendL(colorUse);
  2272     aColorUseList.AppendL(colorUse);
  2171 
  2273 
  2172     const TInt count=CountComponentControls();
  2274     const TInt count=CountComponentControls();
  2173     for(TInt ii=0;ii<count;ii++)
  2275     for(TInt ii=0;ii<count;ii++)
  2174         ComponentControl(ii)->GetColorUseListL(aColorUseList);  
  2276         ComponentControl(ii)->GetColorUseListL(aColorUseList);  
  2175     _AKNTRACE_FUNC_EXIT;
       
  2176     }
  2277     }
  2177 
  2278 
  2178 /**
  2279 /**
  2179  * Handles a change to the control's resources of type aType
  2280  * Handles a change to the control's resources of type aType
  2180  * which are shared across the environment, e.g. colors or fonts.
  2281  * which are shared across the environment, e.g. colors or fonts.
  2181  *
  2282  *
  2182  * @since ER5U 
  2283  * @since ER5U 
  2183  */
  2284  */
  2184 EXPORT_C void CEikCaptionedControl::HandleResourceChange(TInt aType)
  2285 EXPORT_C void CEikCaptionedControl::HandleResourceChange(TInt aType)
  2185     {
  2286     {
  2186     _AKNTRACE_FUNC_ENTER;
       
  2187     _AKNTRACE( "[%s][%s][%d].", "CEikCaptionedControl", __FUNCTION__, aType );
       
  2188     CCoeControl::HandleResourceChange(aType);
  2287     CCoeControl::HandleResourceChange(aType);
  2189 
  2288 
  2190     // Animation is skin dependent, whenever skin changes animation changes
  2289     // Animation is skin dependent, whenever skin changes animation changes
  2191     // too.
  2290     // too.
  2192     if( KAknsMessageSkinChange == aType )
  2291     if( KAknsMessageSkinChange == aType )
  2206             {
  2305             {
  2207             iExtension->HandleLayoutSwitch( Rect().Size() );
  2306             iExtension->HandleLayoutSwitch( Rect().Size() );
  2208             }
  2307             }
  2209         DrawDeferred();
  2308         DrawDeferred();
  2210         }
  2309         }
  2211     _AKNTRACE_FUNC_EXIT;
       
  2212    }
  2310    }
  2213 
  2311 
  2214 
  2312 
  2215 /* Deactivated as requested in AISA-595AEZ
  2313 /* Deactivated as requested in AISA-595AEZ
  2216 */
  2314 */
  2219     {
  2317     {
  2220     }
  2318     }
  2221 
  2319 
  2222 EXPORT_C const TDesC* CEikCaptionedControl::ToolTipText() const 
  2320 EXPORT_C const TDesC* CEikCaptionedControl::ToolTipText() const 
  2223     {
  2321     {
  2224     return NULL ;
  2322     if ( iToolTipText )
       
  2323         return  iToolTipText ;
       
  2324     else
       
  2325         return NULL ;
  2225     }
  2326     }
  2226 
  2327 
  2227 /**
  2328 /**
  2228  * Writes the internal state of the control and its components to aStream.
  2329  * Writes the internal state of the control and its components to aStream.
  2229  * Does nothing in release mode.
  2330  * Does nothing in release mode.
  2279 EXPORT_C void CEikCaptionedControl::MCoeCaptionRetrieverForFep_Reserved_2()
  2380 EXPORT_C void CEikCaptionedControl::MCoeCaptionRetrieverForFep_Reserved_2()
  2280     {}
  2381     {}
  2281 
  2382 
  2282 EXPORT_C void CEikCaptionedControl::SetEditableL( TBool aEditable, TBool /*aShowEmptyFields*/ )
  2383 EXPORT_C void CEikCaptionedControl::SetEditableL( TBool aEditable, TBool /*aShowEmptyFields*/ )
  2283     {
  2384     {
  2284     _AKNTRACE_FUNC_ENTER;
       
  2285     _AKNTRACE( "CEikCaptionedControl::SetEditableL() aEditable: [%d]", aEditable );
       
  2286     // Construct extension object if needed
  2385     // Construct extension object if needed
  2287     ConstructExtensionL() ;
  2386     ConstructExtensionL() ;
  2288 
  2387 
  2289     // Animation is not run when editing
  2388     // Animation is not run when editing
  2290     if( iIsFormControl && iExtension->iAnimation && aEditable )
  2389     if( iIsFormControl && iExtension->iAnimation && aEditable )
  2355         ResetMinimumSizes() ;
  2454         ResetMinimumSizes() ;
  2356         LayoutSkinControlContexts();
  2455         LayoutSkinControlContexts();
  2357 		if (IsReadyToDraw())
  2456 		if (IsReadyToDraw())
  2358 			SizeChanged(); // needed because layout lines change when editable flag is switched.
  2457 			SizeChanged(); // needed because layout lines change when editable flag is switched.
  2359         }
  2458         }
  2360     _AKNTRACE_FUNC_EXIT;
  2459     }
       
  2460 
       
  2461 void CEikCaptionedControl::SetVertEdgeSpacing( TInt aVertEdgeSpacing ) 
       
  2462     {
       
  2463     iVertEdgeSpacing = aVertEdgeSpacing ;
       
  2464     }
       
  2465 
       
  2466 void CEikCaptionedControl::SetHorzEdgeSpacing( TInt aHorzEdgeSpacing ) 
       
  2467     {
       
  2468     iHorzEdgeSpacing = aHorzEdgeSpacing ;
  2361     }
  2469     }
  2362 
  2470 
  2363 /**
  2471 /**
  2364  * Avkon component positioning for Forms
  2472  * Avkon component positioning for Forms
  2365  */
  2473  */
  2366 
  2474 
  2367 void CEikCaptionedControl::PositionFormComponents()
  2475 void CEikCaptionedControl::PositionFormComponents()
  2368     {
  2476     {
  2369     _AKNTRACE_FUNC_ENTER;
  2477     if( iExtension->iPartiallyVisible )
       
  2478         return;
       
  2479     TBool isFocused = iIsCurrentLine;
       
  2480     TBool isSingleLineLayout = ( FormLayout() == CEikDialogPage::ESingle);
  2370     MinimumSize() ;
  2481     MinimumSize() ;
  2371 
  2482     TBool hasBitmaps = ShowBitmap();
  2372     // if control has no height, return now (no point laying out)
  2483     
       
  2484 /* 
       
  2485 if control has no height, return now (no point laying out)
       
  2486 */
  2373     if (!Rect().Height())  
  2487     if (!Rect().Height())  
  2374         return;
  2488         return;
  2375 
  2489 
  2376     TBool isFocused = iIsCurrentLine;
       
  2377     TBool isSingleLineLayout = ( FormLayout() == CEikDialogPage::ESingle);
       
  2378     TBool hasBitmaps = ShowBitmap();
       
  2379     TAknWindowLineLayout verticalLine = AKN_LAYOUT_WINDOW_List_pane_elements__single_heading__Line_1 ; 
  2490     TAknWindowLineLayout verticalLine = AKN_LAYOUT_WINDOW_List_pane_elements__single_heading__Line_1 ; 
  2380 
  2491 
  2381     // If double line layout update verticalLine
  2492     // If double line layout update verticalLine
  2382     if ( !isSingleLineLayout )
  2493     if ( !isSingleLineLayout )
  2383         {
  2494         {
  2402                 {
  2513                 {
  2403                 verticalLine = AKN_LAYOUT_WINDOW_List_pane_lines__A_column__Line_1(0);
  2514                 verticalLine = AKN_LAYOUT_WINDOW_List_pane_lines__A_column__Line_1(0);
  2404                 }
  2515                 }
  2405             }    
  2516             }    
  2406         }
  2517         }
  2407 
  2518         TRect parentRect = Rect();
  2408     TAknLayoutRect layoutRect;
  2519         TAknLayoutRect layoutRect;
  2409     layoutRect.LayoutRect( Rect(), verticalLine );
  2520         layoutRect.LayoutRect( parentRect, verticalLine );
  2410     TRect rectVerticalLine( layoutRect.Rect() );
  2521         TRect rectVerticalLine( layoutRect.Rect() );
       
  2522 
  2411 
  2523 
  2412     // set vertical line position.  
  2524     // set vertical line position.  
  2413     if ( AknLayoutUtils::LayoutMirrored() )
  2525     if ( AknLayoutUtils::LayoutMirrored() )
  2414         {
  2526         {
  2415         iVerticalLineXPosition = Rect().Width() - rectVerticalLine.iBr.iX;
  2527         iVerticalLineXPosition = Rect().Width() - rectVerticalLine.iBr.iX;
  2436 Each control type checks to see if it a user-defined control type is of that type, using the
  2548 Each control type checks to see if it a user-defined control type is of that type, using the
  2437 ConvertCustomControlTypeToBaseControlType mechanism so if the code gets here, the control is 
  2549 ConvertCustomControlTypeToBaseControlType mechanism so if the code gets here, the control is 
  2438 "none of the above".
  2550 "none of the above".
  2439 */
  2551 */
  2440         Panic(EEikFormPanicUnknownControlType);
  2552         Panic(EEikFormPanicUnknownControlType);
  2441         }
  2553         };
       
  2554 
       
  2555     //TRect layoutRectOfDataPane =(iIsEditable)? EditRect() : ViewRect();
  2442 
  2556 
  2443    //view and edit data pane rect should be the same
  2557    //view and edit data pane rect should be the same
  2444     TRect layoutRectOfDataPane( Rect() );    
  2558     TRect layoutRectOfDataPane = ViewRect();    
  2445 
  2559 
  2446     if ( hasBitmaps )
  2560     if ( hasBitmaps )
  2447         {
  2561         {
  2448         if (iBitmap)
  2562         if (iBitmap)
  2449             FormLayoutControlBitmap
  2563             FormLayoutControlBitmap
  2582         default:
  2696         default:
  2583             Panic(EEikFormPanicLayoutErrorUnknownControlType);  
  2697             Panic(EEikFormPanicLayoutErrorUnknownControlType);  
  2584         }
  2698         }
  2585         
  2699         
  2586     TRAP_IGNORE( SetElementTextColorsL(TRgb()));
  2700     TRAP_IGNORE( SetElementTextColorsL(TRgb()));
  2587     _AKNTRACE_FUNC_EXIT;
       
  2588     }
  2701     }
  2589 
  2702 
  2590 TBool CEikCaptionedControl::ShowBitmap() const
  2703 TBool CEikCaptionedControl::ShowBitmap() const
  2591     {
  2704     {
  2592     return (iFlags & EEikFormShowBitmaps);
  2705     return (iFlags & EEikFormShowBitmaps);
  2612         else
  2725         else
  2613             {
  2726             {
  2614             AknLayoutUtils::LayoutLabel( iCaption, aRect, R_AVKON_FORM_LABEL_NO_ICON ) ;
  2727             AknLayoutUtils::LayoutLabel( iCaption, aRect, R_AVKON_FORM_LABEL_NO_ICON ) ;
  2615             }
  2728             }
  2616         }
  2729         }
       
  2730     }
       
  2731 
       
  2732 TSize CEikCaptionedControl::EditorControlSize() const 
       
  2733     {
       
  2734     return iEditorControlSize ;
  2617     }
  2735     }
  2618 
  2736 
  2619 TInt CEikCaptionedControl::NumberOfLines() const
  2737 TInt CEikCaptionedControl::NumberOfLines() const
  2620 	{
  2738 	{
  2621 	return iNumberOfLines;
  2739 	return iNumberOfLines;
  2622 	}
  2740 	}
  2623 
  2741 
       
  2742 TInt CEikCaptionedControl::NumberOfLinesForScrollBar() const
       
  2743 	{
       
  2744 	if ( FormLayout() == CEikDialogPage::ESingle ) return NumberOfLines();
       
  2745 	return NumberOfLines()+1;
       
  2746 	}
       
  2747 
  2624 /**
  2748 /**
  2625  * Recalculates the number of required lines for a control.
  2749  * Recalculates the number of required lines for a control.
  2626  */
  2750  */
  2627 void CEikCaptionedControl::CalculateNumberOfLinesForControl( TInt aLines )
  2751 void CEikCaptionedControl::CalculateNumberOfLinesForControl( TInt aLines )
  2628     {
  2752     {
  2629 	_AKNTRACE_FUNC_ENTER;
       
  2630     // NB if new control types are added, ones which should be invisible in view mode
  2753     // NB if new control types are added, ones which should be invisible in view mode
  2631     // should be also added to IsDisplayable().
  2754     // should be also added to IsDisplayable().
  2632     if ( aLines == ENotSupplied )
  2755     if ( aLines == ENotSupplied )
  2633         {
  2756         {
  2634         // Function has to be aware of edit/view state.  
  2757         // Function has to be aware of edit/view state.  
  2680             else
  2803             else
  2681                 aLines=1;
  2804                 aLines=1;
  2682             }
  2805             }
  2683         }
  2806         }
  2684     iNumberOfLines = aLines ;
  2807     iNumberOfLines = aLines ;
  2685     _AKNTRACE( "iNumberOfLines: [%d]", iNumberOfLines );
       
  2686     _AKNTRACE_FUNC_EXIT;
       
  2687     }
  2808     }
  2688 
  2809 
  2689 EXPORT_C void CEikCaptionedControl::SetFormFlags( TInt aFlags ) 
  2810 EXPORT_C void CEikCaptionedControl::SetFormFlags( TInt aFlags ) 
  2690     {
  2811     {
  2691     iFlags = aFlags ;
  2812     iFlags = aFlags ;
  2720     
  2841     
  2721     if(ControlIsAnEdwin(iControlType))
  2842     if(ControlIsAnEdwin(iControlType))
  2722         {
  2843         {
  2723         AknLayoutUtils::OverrideControlColorL(*this, EColorControlText, textColor );
  2844         AknLayoutUtils::OverrideControlColorL(*this, EColorControlText, textColor );
  2724         }
  2845         }
  2725     }
  2846     
  2726 
  2847     }
       
  2848 
       
  2849 /**
       
  2850  * Retrieves the Series 60 European LAF layout values from avkon.rh
       
  2851  *
       
  2852  */
       
  2853 void CEikCaptionedControl::GetAknLayoutValuesL()
       
  2854     {
       
  2855     TAknWindowLineLayout l = AknLayoutScalable_Avkon::form_field_data_pane(0).LayoutLine();
       
  2856     TRect parentRect = iAvkonAppUi->ClientRect();
       
  2857     TAknLayoutRect layoutRect;
       
  2858     layoutRect.LayoutRect( parentRect, l );
       
  2859     TRect rectDataPane( layoutRect.Rect() );
       
  2860 
       
  2861     iAknFormControlWidth = rectDataPane.Width();
       
  2862     iAknFormControlHeight = rectDataPane.Height();
       
  2863    }
       
  2864 
       
  2865     
  2727 
  2866 
  2728 TBool   CEikCaptionedControl::IsDisplayable() const
  2867 TBool   CEikCaptionedControl::IsDisplayable() const
  2729     {
  2868     {
  2730 /*
  2869 /*
  2731 Added to provide whether the control should be displayed without calls to minimumsize.
  2870 Added to provide whether the control should be displayed without calls to minimumsize.
  2788         case EEikCtNumberEditor:
  2927         case EEikCtNumberEditor:
  2789         case EAknCtLocationEditor:
  2928         case EAknCtLocationEditor:
  2790         case EAknCtUnitEditor:
  2929         case EAknCtUnitEditor:
  2791             return ETrue;
  2930             return ETrue;
  2792         }
  2931         }
  2793     if (iDialogPage)
  2932     TInt typeOfControlToLayout=iDialogPage->PageContainer()->PageSelector()->Dialg()->ConvertCustomControlTypeToBaseControlType(iControlType);
  2794         {
  2933     if (typeOfControlToLayout==MEikDialogPageObserver::EMfneDerived)
  2795 	    TInt typeOfControlToLayout=iDialogPage->PageContainer()->PageSelector()->Dialg()->ConvertCustomControlTypeToBaseControlType(iControlType);
  2934         return ETrue;
  2796         if (typeOfControlToLayout==MEikDialogPageObserver::EMfneDerived)
       
  2797             return ETrue;
       
  2798         }
       
  2799     return EFalse;
  2935     return EFalse;
  2800     }
  2936     }
  2801 
  2937 
  2802 TBool CEikCaptionedControl::ControlIsAPopfield(TInt aControlType) const 
  2938 TBool CEikCaptionedControl::ControlIsAPopfield(TInt aControlType) const 
  2803     {
  2939     {
  2826         {
  2962         {
  2827         case EEikCtSecretEd:
  2963         case EEikCtSecretEd:
  2828         case EAknCtNumericSecretEditor:
  2964         case EAknCtNumericSecretEditor:
  2829             return ETrue;
  2965             return ETrue;
  2830         }
  2966         }
  2831     if (iDialogPage)
  2967     TInt typeOfControlToLayout=iDialogPage->PageContainer()->PageSelector()->Dialg()->ConvertCustomControlTypeToBaseControlType(iControlType);
  2832         {
  2968     if (typeOfControlToLayout==MEikDialogPageObserver::ESecretEditorDerived)
  2833         TInt typeOfControlToLayout=iDialogPage->PageContainer()->PageSelector()->Dialg()->ConvertCustomControlTypeToBaseControlType(iControlType);
  2969         return ETrue;
  2834         if (typeOfControlToLayout==MEikDialogPageObserver::ESecretEditorDerived)
       
  2835             return ETrue;
       
  2836         }
       
  2837     return EFalse;
  2970     return EFalse;
  2838     }
  2971     }
  2839 
  2972 
  2840 TBool CEikCaptionedControl::ControlIsASlider(TInt aControlType) const 
  2973 TBool CEikCaptionedControl::ControlIsASlider(TInt aControlType) const 
  2841     {
  2974     {
  2844     switch (aControlType)
  2977     switch (aControlType)
  2845         {
  2978         {
  2846         case EAknCtSlider :
  2979         case EAknCtSlider :
  2847             return ETrue;
  2980             return ETrue;
  2848         }
  2981         }
  2849     if (iDialogPage)
  2982     TInt typeOfControlToLayout=iDialogPage->PageContainer()->PageSelector()->Dialg()->ConvertCustomControlTypeToBaseControlType(iControlType);
  2850         {
  2983     if (typeOfControlToLayout==MEikDialogPageObserver::ESliderDerived)
  2851         TInt typeOfControlToLayout=iDialogPage->PageContainer()->PageSelector()->Dialg()->ConvertCustomControlTypeToBaseControlType(iControlType);
  2984         return ETrue;
  2852         if (typeOfControlToLayout==MEikDialogPageObserver::ESliderDerived)
       
  2853             return ETrue;
       
  2854         }
       
  2855     return EFalse;
  2985     return EFalse;
  2856     }
  2986     }
  2857 
  2987 
  2858 //------------------------------------------------------------------------
  2988 //------------------------------------------------------------------------
  2859 // CEikCaptionedControl::ControlIsAColourSelGrid
  2989 // CEikCaptionedControl::ControlIsAColourSelGrid
  2868         case EAknCtColourSelectionDialogGrid :   // Deprecated
  2998         case EAknCtColourSelectionDialogGrid :   // Deprecated
  2869         case EAknCtColourSelectionGridDialog :
  2999         case EAknCtColourSelectionGridDialog :
  2870         case EAknCtColourSelectionDialogNoneField:
  3000         case EAknCtColourSelectionDialogNoneField:
  2871             return ETrue;
  3001             return ETrue;
  2872         }
  3002         }
  2873     if (iDialogPage)
  3003     TInt typeOfControlToLayout=iDialogPage->PageContainer()->PageSelector()->Dialg()->ConvertCustomControlTypeToBaseControlType(iControlType);
  2874         {
  3004     if (typeOfControlToLayout==MEikDialogPageObserver::EColourSelectionGridDerived)
  2875         TInt typeOfControlToLayout=iDialogPage->PageContainer()->PageSelector()->Dialg()->ConvertCustomControlTypeToBaseControlType(iControlType);
  3005         return ETrue;
  2876         if (typeOfControlToLayout==MEikDialogPageObserver::EColourSelectionGridDerived)
       
  2877             return ETrue;
       
  2878         }
       
  2879     return EFalse;
  3006     return EFalse;
  2880     }  
  3007     }  
  2881  
  3008  
  2882 void CEikCaptionedControl::DoFormCaptionSettingsL(const TDesC& aText)
  3009 void CEikCaptionedControl::DoFormCaptionSettingsL(const TDesC& aText)
  2883     {
  3010     {
  2890 
  3017 
  2891 
  3018 
  2892 EXPORT_C const TPtrC CEikCaptionedControl::GetFullCaptionText() const
  3019 EXPORT_C const TPtrC CEikCaptionedControl::GetFullCaptionText() const
  2893     {
  3020     {
  2894     return *iCaptionText;
  3021     return *iCaptionText;
  2895     }
  3022     };
  2896 
  3023 
  2897 void CEikCaptionedControl::RegisterPageWithCaptionControl(CEikDialogPage* aPage)
  3024 void CEikCaptionedControl::RegisterPageWithCaptionControl(CEikDialogPage* aPage)
  2898     {
  3025     {
  2899     iDialogPage=aPage;
  3026     iDialogPage=aPage;
  2900     }
  3027     };
  2901 
  3028 
  2902 TInt CEikCaptionedControl::MaximumNumberOfControlLinesOnVisiblePage() const
  3029 TInt CEikCaptionedControl::MaximumNumberOfControlLinesOnVisiblePage() const
  2903     {
  3030     {
  2904 	_AKNTRACE_FUNC_ENTER;
       
  2905 	TInt maxItems = 0;
  3031 	TInt maxItems = 0;
  2906 	TAknLayoutScalableParameterLimits paneLimits;
  3032 	TAknLayoutScalableParameterLimits paneLimits;
  2907 	if (IsPopupField(this))
  3033 	if (IsPopupField(this))
  2908     	{
  3034     	{
  2909         if (iDialogPage&& CEikDialogPage::EDouble == iDialogPage->FormLayout())
  3035         if (iDialogPage&& CEikDialogPage::EDouble == iDialogPage->FormLayout())
  2942         TInt defineHeight = static_cast<CEikEdwin*>( iControl )->MaximumHeightInLines();
  3068         TInt defineHeight = static_cast<CEikEdwin*>( iControl )->MaximumHeightInLines();
  2943         if ( defineHeight && defineHeight < maxItems )
  3069         if ( defineHeight && defineHeight < maxItems )
  2944             return defineHeight;
  3070             return defineHeight;
  2945         }
  3071         }
  2946 	//maxItems -= 1; // TODO: this is a temporary workaround for layout data being incorrect, it has too many options available
  3072 	//maxItems -= 1; // TODO: this is a temporary workaround for layout data being incorrect, it has too many options available
  2947     _AKNTRACE( "maxItems: [%d]", maxItems );
       
  2948     _AKNTRACE_FUNC_EXIT;
       
  2949     return maxItems;
  3073     return maxItems;
  2950     }
  3074     };
  2951 
  3075 
       
  3076 
       
  3077 TRect CEikCaptionedControl::ViewRect() const
       
  3078 
       
  3079     {
       
  3080 /* 
       
  3081 The Rect that the view mode is expecting is:
       
  3082 176 across 
       
  3083 21 high
       
  3084 set from 0,0
       
  3085 
       
  3086 We are
       
  3087 174 across
       
  3088 23 high
       
  3089 set from (1,1) relative to viewwin.
       
  3090 
       
  3091 To convert we must:
       
  3092 * Shrink(-1,1) to make Y cord and size equal, and X coord equal.
       
  3093 * add 1 to the BR X coord. to make X size equal.
       
  3094 */
       
  3095     TRect viewRectConversion(EditRect());
       
  3096     viewRectConversion.Shrink(0,1);
       
  3097     return viewRectConversion;
       
  3098     }
       
  3099 
       
  3100 TRect CEikCaptionedControl::EditRect() const
       
  3101     {
       
  3102     //The Rect provided by Rect() is fine  
       
  3103     return Rect();
       
  3104     } 
  2952 
  3105 
  2953 void CEikCaptionedControl::FormLayoutControlBitmap(CEikImage* aBitmap, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines)
  3106 void CEikCaptionedControl::FormLayoutControlBitmap(CEikImage* aBitmap, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines)
  2954     {   
  3107     {   
  2955     if (!aNumberOfLines)
  3108     if (!aNumberOfLines)
  2956         return;
  3109         return;
  3096         AknLayoutUtils::LayoutEdwin( aEdwin, layoutRect, textLayout,
  3249         AknLayoutUtils::LayoutEdwin( aEdwin, layoutRect, textLayout,
  3097                                      colorIndex, 0, ETrue );
  3250                                      colorIndex, 0, ETrue );
  3098     	SetScrollRect(aEdwin, layoutRect, textLayout, aNumberOfLines);
  3251     	SetScrollRect(aEdwin, layoutRect, textLayout, aNumberOfLines);
  3099 	    }
  3252 	    }
  3100 
  3253 
  3101 	aEdwin->SetSuppressBackgroundDrawing(!aIsEditable);
  3254 	TBool isviewmode = !aIsEditable;
       
  3255 	aEdwin->SetSuppressBackgroundDrawing(isviewmode);
  3102     }
  3256     }
  3103 
  3257 
  3104 
  3258 
  3105 // Labels
  3259 // Labels
  3106 void CEikCaptionedControl::FormLayoutControlLabel(
  3260 void CEikCaptionedControl::FormLayoutControlLabel(
  3119     TAknTextLineLayout textLayout( AKN_LAYOUT_TEXT_Form_data_field_texts_Line_1(bitmap,0) );
  3273     TAknTextLineLayout textLayout( AKN_LAYOUT_TEXT_Form_data_field_texts_Line_1(bitmap,0) );
  3120     
  3274     
  3121     // Layout the label for the single line format
  3275     // Layout the label for the single line format
  3122     if (aSingleLayout) 
  3276     if (aSingleLayout) 
  3123         {
  3277         {
  3124         if (!aIsEditable)
  3278         if (aIsEditable)
       
  3279             {
       
  3280             // Do nothing; this is the default used
       
  3281             }
       
  3282         else
  3125             {
  3283             {
  3126             // This layout is dy
  3284             // This layout is dy
  3127             if (aBitmapPresent)
  3285             if (aBitmapPresent)
  3128                 {
  3286                 {
  3129                 TAknTextLineLayout anotherTextLayout(AKN_LAYOUT_TEXT_List_pane_texts__single_graphic_heading__Line_1(0) );
  3287                 TAknTextLineLayout anotherTextLayout(AKN_LAYOUT_TEXT_List_pane_texts__single_graphic_heading__Line_1(0) );
  3262 void CEikCaptionedControl::FormLayoutControlPopfield(
  3420 void CEikCaptionedControl::FormLayoutControlPopfield(
  3263         CAknPopupField* aPopfield, const TRect& aParent, TBool aIsEditable,
  3421         CAknPopupField* aPopfield, const TRect& aParent, TBool aIsEditable,
  3264         TBool aSingleLayout, TInt aNumberOfLines, TBool aBitmapPresent,
  3422         TBool aSingleLayout, TInt aNumberOfLines, TBool aBitmapPresent,
  3265         TBool /*aIsFocused*/)
  3423         TBool /*aIsFocused*/)
  3266     {
  3424     {
  3267     TRect layoutRect( aParent );
  3425     TRect layoutRect = aParent;
  3268     TAknWindowLineLayout layoutData(AKN_LAYOUT_WINDOW_list_form_pane(aNumberOfLines-1));
  3426     TAknWindowLineLayout layoutData(AKN_LAYOUT_WINDOW_list_form_pane(aNumberOfLines-1));
  3269 	TAknTextLineLayout labelLayout(AknLayout::Form_data_field_texts_Line_2(0));
  3427 	TAknTextLineLayout labelLayout(AknLayout::Form_data_field_texts_Line_2(0));
  3270     if (!aNumberOfLines)
  3428     if (!aNumberOfLines)
  3271         return;
  3429         return;
  3272     
  3430     
  3285     TBool isText = EFalse;
  3443     TBool isText = EFalse;
  3286 	if (aPopfield->SelectionMode() == CAknPopupField::EAknPopupFieldLabelMode)
  3444 	if (aPopfield->SelectionMode() == CAknPopupField::EAknPopupFieldLabelMode)
  3287 		{
  3445 		{
  3288 		isText = ETrue;
  3446 		isText = ETrue;
  3289 		}
  3447 		}
  3290 	
  3448  
  3291     if (aSingleLayout)
  3449     if (aSingleLayout)
  3292         {
  3450         {
  3293         layoutData=AKN_LAYOUT_WINDOW_list_form_pane(aNumberOfLines-1);
  3451         if (aIsEditable)
       
  3452             {
       
  3453             layoutData=AKN_LAYOUT_WINDOW_list_form_pane(aNumberOfLines-1);
       
  3454             }
       
  3455         else
       
  3456             {
       
  3457 /* 
       
  3458 popupfields not specified in lists.  
       
  3459 Have to convert aParent to form equivalent and use that layout.
       
  3460 */
       
  3461             ConvertViewRectToEditRect(layoutRect);
       
  3462             layoutData=AKN_LAYOUT_WINDOW_list_form_pane(aNumberOfLines-1);
       
  3463             }
  3294         }
  3464         }
  3295     else  // double layout
  3465     else  // double layout
  3296         {
  3466         {
  3297         TInt newpar = ( aBitmapPresent ? 1 : 0 ) ;
  3467         TInt newpar = ( aBitmapPresent ? 1 : 0 ) ;
  3298         layoutData=AKN_LAYOUT_WINDOW_list_form_wide_pane(newpar, aNumberOfLines-1);
  3468         if (!aBitmapPresent)
  3299 
  3469             {
  3300         if ( aBitmapPresent && !aIsEditable )
  3470             if (aIsEditable)
  3301             {
  3471                 {
  3302             //move bitmap's width for display second line text
  3472                 layoutData=AKN_LAYOUT_WINDOW_list_form_wide_pane(newpar, aNumberOfLines-1);
  3303             TAknWindowLineLayout l = AknLayout::List_pane_elements__single_graphic_heading__Line_1();
  3473                 }
  3304             TAknLayoutRect bmpRect;
  3474             else
  3305             TRect tempRect;
  3475                 {
  3306             bmpRect.LayoutRect( tempRect, l );
  3476                 // have to convert Rect before doing this.
  3307             layoutRect.iTl.iX += bmpRect.Rect().Width();
  3477                 ConvertViewRectToEditRect(layoutRect);
  3308             }
  3478                 layoutData=AKN_LAYOUT_WINDOW_list_form_wide_pane(newpar, aNumberOfLines-1);
  3309         }
  3479                 }
       
  3480             }
       
  3481         else //AKN_LAYOUT_WINDOW_list_form_graphic_wide_pane
       
  3482             {
       
  3483             if (aIsEditable)
       
  3484                 {
       
  3485                 layoutData=AKN_LAYOUT_WINDOW_list_form_wide_pane(newpar, aNumberOfLines-1);
       
  3486                 }
       
  3487             else
       
  3488                 {
       
  3489                 // have to convert Rect before doing this.
       
  3490                 ConvertViewRectToEditRect(layoutRect);
       
  3491                 layoutData=AKN_LAYOUT_WINDOW_list_form_wide_pane(newpar, aNumberOfLines-1);
       
  3492 				//move bitmap's width for display second line text
       
  3493 		        TAknWindowLineLayout l = AknLayout::List_pane_elements__single_graphic_heading__Line_1();
       
  3494 		        TAknLayoutRect bmpRect;
       
  3495 		        TRect tempRect;
       
  3496 		        bmpRect.LayoutRect( tempRect, l );
       
  3497 				layoutRect.iTl.iX += bmpRect.Rect().Width();
       
  3498                 }
       
  3499             }
       
  3500         };
  3310 	aPopfield->SetFormFieldRect(layoutRect);
  3501 	aPopfield->SetFormFieldRect(layoutRect);
  3311 	if (isText)
  3502 	if (isText)
  3312 		{ // popup field will be same size as text element
  3503 		{ // popup field will be same size as text element
  3313 		TAknLayoutText r;
  3504 		TAknLayoutText r;
  3314 		r.LayoutText(layoutRect, labelLayout);
  3505 		r.LayoutText(layoutRect, labelLayout);
  3315 		TRect resultRect( r.TextRect() );
  3506 		TRect resultRect = r.TextRect();
  3316 		aPopfield->SetRect(resultRect);
  3507 		aPopfield->SetRect(resultRect);
  3317 		}
  3508 		}
  3318 	else
  3509 	else
  3319 		{ // popup field will be same size as list_pane
  3510 		{ // popup field will be same size as list_pane
  3320 	    AknLayoutUtils::LayoutControl
  3511 	    AknLayoutUtils::LayoutControl
  3335         if (error == KErrNone )
  3526         if (error == KErrNone )
  3336             {
  3527             {
  3337             TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( *aPopfield, EColorLabelText, textColor ) ); 
  3528             TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( *aPopfield, EColorLabelText, textColor ) ); 
  3338             }          
  3529             }          
  3339         }
  3530         }
       
  3531         
  3340     }
  3532     }
  3341 
  3533 
  3342 // Password editor
  3534 // Password editor
  3343 void CEikCaptionedControl::FormLayoutControlSecretEditor(
  3535 void CEikCaptionedControl::FormLayoutControlSecretEditor(
  3344         CEikSecretEditor* aSecretEd, const TRect& aParent, TBool aIsEditable,
  3536         CEikSecretEditor* aSecretEd, const TRect& aParent, TBool aIsEditable,
  3406 // Slider control
  3598 // Slider control
  3407 void CEikCaptionedControl::FormLayoutControlSlider(CAknSlider* aSlider, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines, TBool /*aBitmapPresent*/)
  3599 void CEikCaptionedControl::FormLayoutControlSlider(CAknSlider* aSlider, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines, TBool /*aBitmapPresent*/)
  3408     {   
  3600     {   
  3409     if (!aNumberOfLines)
  3601     if (!aNumberOfLines)
  3410         return;
  3602         return;
  3411     
  3603     if (aSingleLayout)
  3412     TRect parentRect( aParent );
  3604         {
  3413     
  3605         if (aIsEditable)
  3414     if ( !aSingleLayout )
  3606             {
       
  3607             aSlider->SetRect(aParent);
       
  3608             }
       
  3609         else
       
  3610             {
       
  3611 /* 
       
  3612 sliders not specified in lists.  
       
  3613 Have to convert aParent to form equivalent and use that layout.
       
  3614 */
       
  3615             TRect conversionRect(aParent);
       
  3616             ConvertViewRectToEditRect(conversionRect);
       
  3617             aSlider->SetRect(conversionRect);
       
  3618             }
       
  3619         }
       
  3620     else 
  3415         {
  3621         {
  3416         // Not currently specified, so making temporary alterations here.
  3622         // Not currently specified, so making temporary alterations here.
  3417         TInt baselineSkip = AKN_LAYOUT_MULTILINE_TEXT_Form_data_field_texts_Line_2(1).BaselineSkip();
  3623         TInt baselineSkip= AKN_LAYOUT_MULTILINE_TEXT_Form_data_field_texts_Line_2(1).BaselineSkip();
  3418 
  3624         TRect newParentRect(aParent);
  3419         // Only move the rect will cover a part or next dialogline, so decrease height of rect form iTl.
  3625         //Only move the rect will cover a part or next dialogline, so decrease height of rect form iTl.
  3420         if( !aIsEditable )
  3626         if( !aIsEditable )
  3421 	        {
  3627 	        {
  3422             parentRect.iTl.iX += baselineSkip;          	
  3628 	        newParentRect.iTl.iX += baselineSkip;          	
  3423 	        }
  3629 	        }
  3424         
  3630         newParentRect.iTl.iY += baselineSkip;
  3425         parentRect.iTl.iY += baselineSkip;
  3631             
  3426         }
  3632         if (aIsEditable)
  3427     
  3633             {
  3428     aSlider->SetRect( parentRect );
  3634             aSlider->SetRect(newParentRect);
  3429     }
  3635             }
  3430 
  3636         else 
       
  3637             {
       
  3638             TRect conversionRect(newParentRect);
       
  3639             ConvertViewRectToEditRect(conversionRect);
       
  3640             aSlider->SetRect(conversionRect);
       
  3641             }
       
  3642         }   
       
  3643 
       
  3644         // Exteded skin support for sliders coded in slider file: \s60\AvKon\src\Aknslider.cpp
       
  3645     }
       
  3646 
       
  3647 void CEikCaptionedControl::ConvertViewRectToEditRect(TRect& aRect)
       
  3648     {
       
  3649     aRect.Grow(-1,1);
       
  3650     aRect.iBr.iX--;
       
  3651     }
       
  3652 
       
  3653 void CEikCaptionedControl::ConvertEditRectToViewRect(TRect& aRect)
       
  3654     {
       
  3655     aRect.Shrink(-1,1);
       
  3656     aRect.iBr.iX++;
       
  3657     }
  3431 
  3658 
  3432 // Standard access method for the form layout from within captioned control
  3659 // Standard access method for the form layout from within captioned control
  3433 CEikDialogPage::TFormLayoutSelection CEikCaptionedControl::FormLayout() const
  3660 CEikDialogPage::TFormLayoutSelection CEikCaptionedControl::FormLayout() const
  3434     {
  3661     {
  3435     // There is no undefined style, but initialize to single...
  3662     // There is no undefined style, but initialize to single...
  3436     CEikDialogPage::TFormLayoutSelection ret = CEikDialogPage::ESingle;
  3663     CEikDialogPage::TFormLayoutSelection ret = CEikDialogPage::ESingle;
  3437     if ( iDialogPage )
  3664     if ( iDialogPage )
  3438         {
       
  3439         ret = iDialogPage->FormLayout();
  3665         ret = iDialogPage->FormLayout();
  3440         }
  3666     
  3441     else if (iFlags & EEikFormUseDoubleSpacedFormat) // similar to CEikDialogPage::ConstructFormFromResourceL()
  3667     if (!iDialogPage)
  3442         {
  3668         {
  3443         ret = CEikDialogPage::EDouble;
  3669         if (iFlags & EEikFormUseDoubleSpacedFormat) // similar to CEikDialogPage::ConstructFormFromResourceL()
       
  3670             ret = CEikDialogPage::EDouble;
  3444         }
  3671         }
  3445     return ret;
  3672     return ret;
  3446     }
  3673     }
  3447 
  3674 
  3448 void CEikCaptionedControl::DrawFormSeparator( CWindowGc& gc ) const
  3675 void CEikCaptionedControl::DrawFormSeparator( CWindowGc& gc ) const
  3450     TAknLayoutRect sepLineRect;
  3677     TAknLayoutRect sepLineRect;
  3451     if ( FormLayout() == CEikDialogPage::ESingle )
  3678     if ( FormLayout() == CEikDialogPage::ESingle )
  3452         {
  3679         {
  3453         sepLineRect.LayoutRect
  3680         sepLineRect.LayoutRect
  3454             (
  3681             (
  3455             Rect(), 
  3682             ViewRect(), 
  3456             AKN_LAYOUT_WINDOW_List_pane_elements__single_heading__Line_2
  3683             AKN_LAYOUT_WINDOW_List_pane_elements__single_heading__Line_2
  3457             );
  3684             );
  3458         sepLineRect.DrawRect(gc);
  3685         sepLineRect.DrawRect(gc);
  3459         }
  3686 
       
  3687         }
       
  3688 //  else
       
  3689 //      {
       
  3690 // Currently no LAF specification for separator in double mode
       
  3691 //      sepLineRect.LayoutRect
       
  3692 //          (
       
  3693 //          ViewRect(), 
       
  3694 //          AKN_LAYOUT_WINDOW_List_pane_elements__double_graphic__Line_??
       
  3695 //          );
       
  3696 //      sepLineRect.DrawRect(gc);
       
  3697 //
       
  3698 //      }
  3460     }
  3699     }
  3461 
  3700 
  3462 void CEikCaptionedControl::DrawClosingLine() const
  3701 void CEikCaptionedControl::DrawClosingLine() const
  3463     {
  3702     {
  3464     if (iHighlightControl)
  3703     if (iHighlightControl)
  3540         iExtension->iEditModeHighlightControlContextPressed->SetParentContext(
  3779         iExtension->iEditModeHighlightControlContextPressed->SetParentContext(
  3541             GetDialogControlContext( iDialogPage ) );
  3780             GetDialogControlContext( iDialogPage ) );
  3542         }
  3781         }
  3543     else
  3782     else
  3544         {
  3783         {
       
  3784         outerRect = ViewRect() ;
       
  3785         innerRect = outerRect ;
  3545         innerRect.iTl = ViewFrameTopLeftRect( outerRect ).iBr ;
  3786         innerRect.iTl = ViewFrameTopLeftRect( outerRect ).iBr ;
  3546         innerRect.iBr = ViewFrameBottomRightRect( outerRect ).iTl ;
  3787         innerRect.iBr = ViewFrameBottomRightRect( outerRect ).iTl ;
  3547         iExtension->iViewModeHighlightControlContext->SetFrameRects( outerRect, innerRect );
  3788         iExtension->iViewModeHighlightControlContext->SetFrameRects( outerRect, innerRect );
  3548         iExtension->iViewModeHighlightControlContext->SetParentContext(
  3789         iExtension->iViewModeHighlightControlContext->SetParentContext(
  3549             GetDialogControlContext( iDialogPage ) );
  3790             GetDialogControlContext( iDialogPage ) );
  3568     }
  3809     }
  3569     
  3810     
  3570 void CEikCaptionedControl::DrawAsSkinnedForm( CWindowGc& aGc, const TRect& /*aRect*/ ) const
  3811 void CEikCaptionedControl::DrawAsSkinnedForm( CWindowGc& aGc, const TRect& /*aRect*/ ) const
  3571     {
  3812     {
  3572     MAknsSkinInstance* skin = AknsUtils::SkinInstance() ;
  3813     MAknsSkinInstance* skin = AknsUtils::SkinInstance() ;
  3573     TRgb textColor( KRgbBlack );
       
  3574     GetColor( EColorLabelText, textColor );
       
  3575 
  3814 
  3576     if ( !iIsCurrentLine )
  3815     if ( !iIsCurrentLine )
  3577         {
  3816         {
  3578         AknListUtils::DrawSeparator( aGc, Rect(), textColor, skin );
       
  3579         aGc.SetBrushStyle( CGraphicsContext::ENullBrush ) ; 
  3817         aGc.SetBrushStyle( CGraphicsContext::ENullBrush ) ; 
  3580         }
  3818         }
  3581     else // Highlight Skinning.  Requires Frame
  3819     else // Highlight Skinning.  Requires Frame
  3582         {
  3820         {
  3583         TRect outerRect( Rect() );
       
  3584         TRect innerRect( outerRect );
       
  3585         
       
  3586         if ( iIsEditable )
  3821         if ( iIsEditable )
  3587             {
  3822             {
  3588             innerRect.iTl = EditFrameTopLeftRect( outerRect ).iBr ;
  3823             TRect innerRect( EditRect() ) ;
  3589             innerRect.iBr = EditFrameBottomRightRect( outerRect ).iTl ;
  3824             innerRect.iTl = EditFrameTopLeftRect( Rect() ).iBr ;
       
  3825             innerRect.iBr = EditFrameBottomRightRect( Rect() ).iTl ;
  3590 
  3826 
  3591             MAknsControlContext* parentCc = GetDialogControlContext( iDialogPage ) ; 
  3827             MAknsControlContext* parentCc = GetDialogControlContext( iDialogPage ) ; 
  3592             AknsDrawUtils::Background( skin, parentCc, this, aGc, outerRect ) ;
  3828             AknsDrawUtils::Background( skin, parentCc, this, aGc, Rect() ) ;
  3593 
  3829 
  3594             AknListUtils::DrawSeparator( aGc, outerRect, textColor, skin );
  3830             // Set the rectangle(s) for the Frame context
       
  3831             iExtension->iEditModeHighlightControlContext->SetFrameRects( EditRect(), innerRect ) ;
       
  3832             iExtension->iEditModeHighlightControlContextPressed->SetFrameRects( EditRect(), innerRect ) ;
  3595             
  3833             
  3596             // Set the rectangle(s) for the Frame context
  3834             AknsDrawUtils::DrawFrame( skin, aGc, EditRect(), innerRect,
  3597             iExtension->iEditModeHighlightControlContext->SetFrameRects( outerRect, innerRect ) ;
       
  3598             iExtension->iEditModeHighlightControlContextPressed->SetFrameRects( outerRect, innerRect ) ;
       
  3599             
       
  3600             AknsDrawUtils::DrawFrame( skin, aGc, outerRect, innerRect,
       
  3601                                       PressedDownState() ?
  3835                                       PressedDownState() ?
  3602                                       KAknsIIDQsnFrListPressed : KAknsIIDQsnFrInput, KAknsIIDDefault );
  3836                                       KAknsIIDQsnFrListPressed : KAknsIIDQsnFrInput, KAknsIIDDefault );
  3603             }
  3837             }
  3604         else // View Mode highlight
  3838         else // View Mode highlight
  3605             {
  3839             {
  3606             TBool drawOk = EFalse;
  3840             TBool drawOk = EFalse;
  3607             innerRect.iTl = ViewFrameTopLeftRect( outerRect ).iBr;
  3841             if( iExtension->IsHighlightAnimated() ) // Draw animated highlight
  3608             innerRect.iBr = ViewFrameBottomRightRect( outerRect ).iTl ;
  3842                 {
  3609     
  3843                 CAknsEffectAnim* anim = iExtension->iAnimation->Animation();
  3610             // The bit around the outside must use the parent's control context
  3844 
  3611             MAknsControlContext* parentCc = GetDialogControlContext( iDialogPage );
  3845                 // TODO: Background is drawn first to prevent white stripes
  3612             AknsDrawUtils::Background( skin, parentCc, this, aGc, outerRect ) ;
  3846                 // appearing above and below the highlight. Wasting resources
  3613     
  3847                 // here, you could create animation that is a tad bigger and
  3614             AknListUtils::DrawSeparator( aGc, outerRect, textColor, skin );
  3848                 // remove background drawing from here.
  3615 
  3849                 TRect viewRect = ViewRect() ;
  3616             // Draw the animation itself
  3850                 TRect innerRect( viewRect ) ;
  3617             if ( iExtension->IsHighlightAnimated() 
  3851                 innerRect.iTl = ViewFrameTopLeftRect( viewRect ).iBr ;
  3618                     && iExtension->iAnimation->Animation() )
  3852                 innerRect.iTl.iX-- ; innerRect.iTl.iY-- ;  // not sure why this adjustment is required here and not above.
  3619                 {
  3853                 innerRect.iBr = ViewFrameBottomRightRect( viewRect ).iTl ;
  3620                 drawOk = iExtension->iAnimation->Animation()->Render( aGc, 
  3854 
  3621                         outerRect );
  3855                 // The bit around the outside must use the parent's control context
  3622                 }
  3856                 MAknsControlContext* parentCc = GetDialogControlContext( iDialogPage ) ;
  3623     
  3857                 AknsDrawUtils::BackgroundBetweenRects( skin, parentCc, this, aGc, Rect() , innerRect ) ;
  3624             if ( !drawOk )
  3858 
  3625                 {
  3859                 // Draw the animation itself
       
  3860                 if( anim )
       
  3861                     {
       
  3862                     drawOk = anim->Render( aGc, ViewRect() );
       
  3863                     }
       
  3864                 }
       
  3865 
       
  3866             if( !drawOk )
       
  3867                 {
       
  3868                 // Code for skinning Highlight ( Using AVKON LAF highlight in place of
       
  3869                 // Skins LAF to establish highlight outer rect )
       
  3870                 TRect viewRect = ViewRect() ;
       
  3871                 TRect innerRect( viewRect ) ;
       
  3872                 innerRect.iTl = ViewFrameTopLeftRect( viewRect ).iBr ;
       
  3873                 innerRect.iTl.iX-- ; innerRect.iTl.iY-- ;  // not sure why this adjustment is required here and not above.
       
  3874                 innerRect.iBr = ViewFrameBottomRightRect( viewRect ).iTl ;
       
  3875 
       
  3876                 // The bit around the outside must use the parent's control context
       
  3877                 MAknsControlContext* parentCc = GetDialogControlContext( iDialogPage ) ;
       
  3878                 AknsDrawUtils::BackgroundBetweenRects( skin, parentCc, this, aGc, Rect() , innerRect ) ;
       
  3879 
  3626                 // Set the rectangle(s) for the Frame context
  3880                 // Set the rectangle(s) for the Frame context
  3627                 iExtension->iViewModeHighlightControlContext->SetFrameRects( 
  3881                 iExtension->iViewModeHighlightControlContext->SetFrameRects( viewRect, innerRect ) ;
  3628                         outerRect, innerRect ) ;
  3882                 iExtension->iViewModeHighlightControlContextPressed->SetFrameRects( viewRect, innerRect ) ;
  3629                 iExtension->iViewModeHighlightControlContextPressed->
       
  3630                     SetFrameRects( outerRect, innerRect ) ;
       
  3631                 
  3883                 
  3632                 AknsDrawUtils::DrawFrame( skin, aGc, outerRect, innerRect,
  3884                 AknsDrawUtils::DrawFrame( skin, aGc, viewRect, innerRect,
  3633                         PressedDownState() ? KAknsIIDQsnFrListPressed : 
  3885                                           PressedDownState() ?
  3634                         KAknsIIDQsnFrList, KAknsIIDDefault );
  3886                                           KAknsIIDQsnFrListPressed : KAknsIIDQsnFrList, KAknsIIDDefault );
  3635                 }
  3887                 }
  3636             }
  3888             }
  3637         }
  3889         }
  3638 
  3890 
  3639     // Enable/disable the control line as required.  (Hide first, show if necessary)
  3891     // Enable/disable the control line as required.  (Hide first, show if necessary)
  3767         TRect rectElements( layoutRect.Rect() );
  4019         TRect rectElements( layoutRect.Rect() );
  3768 
  4020 
  3769         User::LeaveIfError(AknIconUtils::SetSize(aBitmap, 
  4021         User::LeaveIfError(AknIconUtils::SetSize(aBitmap, 
  3770                               rectElements.Size() ));
  4022                               rectElements.Size() ));
  3771         }
  4023         }
  3772     }
  4024 /*        
       
  4025     
       
  4026     if (iIsFormControl)
       
  4027         {
       
  4028         if (iIsEditable)
       
  4029             {
       
  4030             if (iBitmap && iBitmap->Bitmap())
       
  4031                 {
       
  4032                 AknIconUtils::SetSize(CONST_CAST(CFbsBitmap*, iBitmap->Bitmap()), 
       
  4033                                         TSize(AKN_LAYOUT_WINDOW_Form_data_field_elements_Line_4.iW, 
       
  4034                                         AKN_LAYOUT_WINDOW_Form_data_field_elements_Line_4.iH));
       
  4035                 }
       
  4036             }
       
  4037         else
       
  4038             {
       
  4039             if (iBitmap && iBitmap->Bitmap())
       
  4040                 {
       
  4041                 AknIconUtils::SetSize(CONST_CAST(CFbsBitmap*, iBitmap->Bitmap()), 
       
  4042                                         TSize(AKN_LAYOUT_WINDOW_List_pane_elements__single_graphic_heading__Line_1.iW, 
       
  4043                                         AKN_LAYOUT_WINDOW_List_pane_elements__single_graphic_heading__Line_1.iH));
       
  4044                 }
       
  4045             }
       
  4046         }
       
  4047     else
       
  4048         {
       
  4049         if (iBitmap && iBitmap->Bitmap())
       
  4050             {
       
  4051             AknIconUtils::SetSize(CONST_CAST(CFbsBitmap*, iBitmap->Bitmap()), 
       
  4052                         TSize(AKN_LAYOUT_WINDOW_List_pane_elements__single_graphic_heading__Line_1.iW, 
       
  4053                         AKN_LAYOUT_WINDOW_List_pane_elements__single_graphic_heading__Line_1.iH));
       
  4054             }
       
  4055         }                       */
       
  4056     }
       
  4057     
  3773 
  4058 
  3774 
  4059 
  3775 // -----------------------------------------------------------------------------
  4060 // -----------------------------------------------------------------------------
  3776 // CEikCaptionedControl::HandleControlEventL
  4061 // CEikCaptionedControl::HandleControlEventL
  3777 // Implementation of MCoeControlObserver observer interface for observing touch button 
  4062 // Implementation of MCoeControlObserver observer interface for observing touch button 
  3861     else
  4146     else
  3862         SetFocus(aSelected,EDrawNow); 
  4147         SetFocus(aSelected,EDrawNow); 
  3863     }
  4148     }
  3864 
  4149 
  3865 
  4150 
       
  4151 void CEikCaptionedControl::SetPartiallyVisible( TBool aPVisible )
       
  4152     {
       
  4153     iExtension->iPartiallyVisible = aPVisible;
       
  4154     }
       
  4155     
  3866 /*  
  4156 /*  
  3867  * Special Label Class which appends colon to label text
  4157  * Special Label Class which appends colon to label text
  3868  */
  4158  */
  3869 
  4159 
  3870 CEikCapCLabel::CEikCapCLabel() : iIsColonEnabled( EFalse ) 
  4160 CEikCapCLabel::CEikCapCLabel() : iIsColonEnabled( EFalse )