uifw/AvKon/src/AknTextSettingPage.cpp
branchRCL_3
changeset 56 d48ab3b357f1
parent 55 aecbbf00d063
equal deleted inserted replaced
55:aecbbf00d063 56:d48ab3b357f1
    32 #include <AknsControlContext.h>
    32 #include <AknsControlContext.h>
    33 #include <AknsFrameBackgroundControlContext.h>
    33 #include <AknsFrameBackgroundControlContext.h>
    34 #include <eikedwob.h>
    34 #include <eikedwob.h>
    35 
    35 
    36 #include <AknTasHook.h>
    36 #include <AknTasHook.h>
    37 
    37 #include <AknFepInternalPSKeys.h>
       
    38 #include <e32property.h>
       
    39 #include <AknDef.h>
       
    40 
       
    41 
       
    42 /*
       
    43  * this class is a fixing for bug ESLM-8395MP 
       
    44  * Settingpage will keep watch the RProperty(set by Fep) to hide it self 
       
    45  */
       
    46 NONSHARABLE_CLASS( CAknFepSettingDialogStatusWatcher ) : public CActive
       
    47     {
       
    48 public:
       
    49     static CAknFepSettingDialogStatusWatcher* NewL( CAknTextSettingPage* aControl )
       
    50         {
       
    51         CAknFepSettingDialogStatusWatcher* watcher = new (ELeave) CAknFepSettingDialogStatusWatcher( aControl );
       
    52         CleanupStack::PushL( watcher );
       
    53         watcher->ConstructL();
       
    54         CleanupStack::Pop(watcher);
       
    55         return watcher;
       
    56         }
       
    57 
       
    58     CAknFepSettingDialogStatusWatcher( CAknTextSettingPage* aControl )
       
    59         : CActive( EPriorityNormal )
       
    60         , iControl( aControl ) 
       
    61         , iAttachSucceed( EFalse )
       
    62         {
       
    63         CActiveScheduler::Add( this );
       
    64         }
       
    65 
       
    66     ~CAknFepSettingDialogStatusWatcher()
       
    67         {
       
    68         StopWatching();
       
    69         iFepSettingDialogStatusProperty.Close();
       
    70         }
       
    71 
       
    72     void StartWatching()
       
    73         {
       
    74         if ( !IsActive() && iAttachSucceed )
       
    75             {
       
    76             iFepSettingDialogStatusProperty.Subscribe( iStatus );
       
    77             SetActive();
       
    78             }
       
    79         }
       
    80 
       
    81     void StopWatching()
       
    82         {
       
    83         Cancel();
       
    84         }
       
    85 
       
    86 private:
       
    87 
       
    88     void ConstructL()
       
    89         {
       
    90         TInt ret = iFepSettingDialogStatusProperty.Attach( KPSUidAknFep
       
    91                                                          , KAknFepSettingDialogState
       
    92                                                          , EOwnerThread );
       
    93         iAttachSucceed = ( ret == KErrNone );
       
    94         }
       
    95 
       
    96     void HandleAknFepSettingDialogStatusChangeNotification()
       
    97         {
       
    98         TInt isOpen = 0;
       
    99         iFepSettingDialogStatusProperty.Get( isOpen );
       
   100         if ( !iControl )
       
   101             {
       
   102             return;
       
   103             }
       
   104 
       
   105         if ( isOpen )
       
   106             {
       
   107             iControl->MakeVisible( EFalse );
       
   108             }
       
   109         else
       
   110             {
       
   111             iControl->MakeVisible( ETrue );
       
   112             }
       
   113         }
       
   114 
       
   115 private: // from CActive
       
   116 
       
   117     void RunL()
       
   118         {
       
   119         if ( iStatus.Int() == KErrNone )
       
   120             {
       
   121             HandleAknFepSettingDialogStatusChangeNotification();
       
   122             StartWatching();
       
   123             }
       
   124         }
       
   125 
       
   126     void DoCancel()
       
   127         {
       
   128         iFepSettingDialogStatusProperty.Cancel();
       
   129         }
       
   130 
       
   131 private:
       
   132     //
       
   133     // not owned
       
   134     //
       
   135     CAknTextSettingPage* iControl;
       
   136 
       
   137     RProperty  iFepSettingDialogStatusProperty;
       
   138 
       
   139     //
       
   140     // If RProperty attach succeed 
       
   141     //
       
   142     TBool iAttachSucceed ;
       
   143     };
       
   144 
       
   145 
       
   146 // ============================================================================
       
   147 //  text settingpage private extented class 
       
   148 //
       
   149 // ============================================================================
       
   150 //
    38 class CAknTextSettingPageExtension : public CBase
   151 class CAknTextSettingPageExtension : public CBase
    39 								   , public MEikEdwinObserver
   152 								   , public MEikEdwinObserver
    40     {
   153     {
    41 public:
   154 public:
    42     static CAknTextSettingPageExtension* NewL(CAknTextSettingPage* aExtensionOwner )
   155     static CAknTextSettingPageExtension* NewL(CAknTextSettingPage* aExtensionOwner )
    49         }
   162         }
    50         
   163         
    51     ~CAknTextSettingPageExtension()
   164     ~CAknTextSettingPageExtension()
    52         {
   165         {
    53         iExtensionOwner = 0;
   166         iExtensionOwner = 0;
       
   167 		
       
   168 		if( iAknFepSettingDialogStatusWatcher )
       
   169 		    {
       
   170 		    iAknFepSettingDialogStatusWatcher->StopWatching();
       
   171             }			
       
   172 		delete iAknFepSettingDialogStatusWatcher;
    54         }
   173         }
    55         
   174         
    56     TInt PreviousCba()
   175     TInt PreviousCba()
    57         {
   176         {
    58         return iPreviousCba;
   177         return iPreviousCba;
    59         };
   178         };
       
   179 		
    60     void SetPreviousCba(TInt aCbaId)
   180     void SetPreviousCba(TInt aCbaId)
    61         {
   181         {
    62         iPreviousCba = aCbaId;
   182         iPreviousCba = aCbaId;
    63         }
   183         }
       
   184 		
    64 	TBool PopupState()
   185 	TBool PopupState()
    65 	 	{
   186 	 	{
    66 		return iPopupState;
   187 		return iPopupState;
    67 		}
   188 		}
    68 
   189 
    80 		}
   201 		}
    81     
   202     
    82 private:
   203 private:
    83     void ConstructL()
   204     void ConstructL()
    84         {
   205         {
       
   206 		iAknFepSettingDialogStatusWatcher = CAknFepSettingDialogStatusWatcher::NewL( iExtensionOwner );
       
   207 		iAknFepSettingDialogStatusWatcher->StartWatching();
    85         }
   208         }
    86         
   209         
    87     CAknTextSettingPageExtension(CAknTextSettingPage*  aExtensionOwner )
   210     CAknTextSettingPageExtension(CAknTextSettingPage*  aExtensionOwner )
    88         : iPreviousCba( 0 ), iExtensionOwner( aExtensionOwner )
   211         : iPreviousCba( 0 )
       
   212         , iExtensionOwner( aExtensionOwner )
    89         , iPopupState( EFalse )
   213         , iPopupState( EFalse )
    90         {
   214         {
    91         }
   215         }
    92         
   216         
    93 private:
   217 private:
    94     TInt iPreviousCba;
   218     TInt iPreviousCba;
    95     CAknTextSettingPage* iExtensionOwner;
   219     CAknTextSettingPage* iExtensionOwner;
    96     TBool iPopupState;  // when open the popup set popup state flag  to 1
   220     TBool iPopupState;  // when open the popup set popup state flag  to 1
       
   221 
       
   222 	//
       
   223 	// active object keep watching Fep's property (Owned)
       
   224 	//
       
   225 	CAknFepSettingDialogStatusWatcher* iAknFepSettingDialogStatusWatcher;
    97     };
   226     };
    98 
   227 
    99 /**
   228 /**
   100  * Exported in case others want to derive from this class
   229  * Exported in case others want to derive from this class
   101  *
   230  *
   225 	{
   354 	{
   226 	BaseConstructL();
   355 	BaseConstructL();
   227 	iBackupText = iText.AllocL();
   356 	iBackupText = iText.AllocL();
   228 	CEikEdwin* editor = TextControl();
   357 	CEikEdwin* editor = TextControl();
   229 
   358 
       
   359 	editor->EnableKineticScrollingL( ETrue );
   230 	// Inhibit predictive text entry unless allowed by API
   360 	// Inhibit predictive text entry unless allowed by API
   231 	if ( !(iTextSettingPageFlags & EPredictiveTextEntryPermitted) )
   361 	if ( !(iTextSettingPageFlags & EPredictiveTextEntryPermitted) )
   232 		editor->SetAknEditorFlags( EAknEditorFlagNoT9 | editor->AknEdwinFlags() );
   362 		editor->SetAknEditorFlags( EAknEditorFlagNoT9 | editor->AknEdwinFlags() );
   233 	
   363 	
   234 	if(!IsEditable())
   364 	if(!IsEditable())
   267 	UpdateCbaL();
   397 	UpdateCbaL();
   268 
   398 
   269 	// Construct an appropriate control context for the contained editor areas.
   399 	// Construct an appropriate control context for the contained editor areas.
   270 	// Context produced is owned by CAknSettingPage. 
   400 	// Context produced is owned by CAknSettingPage. 
   271     SetEditedItemFrameIID( KAknsIIDQsnFrInput, KAknsIIDQsnFrInputCenter );
   401     SetEditedItemFrameIID( KAknsIIDQsnFrInput, KAknsIIDQsnFrInputCenter );
   272 	TextControl()->ScrollBarFrame()->VerticalScrollBar()->SetMopParent(this);
   402     
       
   403     // ScrollBarFrame always exists in this phase
       
   404     CEikScrollBar* sb = editor->ScrollBarFrame()->VerticalScrollBar();
       
   405     if ( sb )
       
   406         {
       
   407         sb->SetMopParent( this );
       
   408         sb->MakeVisible( ETrue );
       
   409         }
   273 	}
   410 	}
   274 
   411 
   275 /**
   412 /**
   276  * Acts upon changes in the hosted control's state. 
   413  * Acts upon changes in the hosted control's state. 
   277  *
   414  *
   421     TAknTextComponentLayout layout;
   558     TAknTextComponentLayout layout;
   422     RArray<TAknTextComponentLayout> array;
   559     RArray<TAknTextComponentLayout> array;
   423     
   560     
   424     for ( TInt i = textLimits.FirstRow(); i <= textLimits.LastRow(); ++i )
   561     for ( TInt i = textLimits.FirstRow(); i <= textLimits.LastRow(); ++i )
   425         {
   562         {
   426         array.Append(
   563 		TInt err = array.Append( AknLayoutScalable_Avkon::set_text_pane_t1_copy1( 0, 0, i ) );
   427             AknLayoutScalable_Avkon::set_text_pane_t1_copy1( 0, 0, i ) );
   564         if ( err != KErrNone)
       
   565         	{
       
   566 			array.Close();
       
   567 			return;
       
   568         	}
   428         }
   569         }
   429     
   570     
   430     AknLayoutUtils::LayoutEdwin( TextControl(),
   571     AknLayoutUtils::LayoutEdwin( TextControl(),
   431                                  edwinRect,
   572                                  edwinRect,
   432                                  layout.Multiline( array ),
   573                                  layout.Multiline( array ),