email/imum/Utils/Src/IMSWTextEditorPage.cpp
branchRCL_3
changeset 60 7fdbb852d323
parent 0 72b543305e3a
equal deleted inserted replaced
57:ebe688cedc25 60:7fdbb852d323
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  IMSWTextEditorPage.cpp
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <aknnavide.h>                      // CAknNavigationDecorator
       
    22 #include <aknEditStateIndicator.h>
       
    23 #include <AknIndicatorContainer.h>
       
    24 #include <e32base.h>
       
    25 
       
    26 #include "IMSSettingsWizard.h"
       
    27 #include "IMSWTextEditorPage.h"
       
    28 #include "ImumUtilsLogging.h"
       
    29 
       
    30 // EXTERNAL DATA STRUCTURES
       
    31 // EXTERNAL FUNCTION PROTOTYPES
       
    32 // CONSTANTS
       
    33 const TText KIMASCharAt = '@';
       
    34 
       
    35 // MACROS
       
    36 // LOCAL CONSTANTS AND MACROS
       
    37 // MODULE DATA STRUCTURES
       
    38 // LOCAL FUNCTION PROTOTYPES
       
    39 // FORWARD DECLARATIONS
       
    40 
       
    41 // ============================ MEMBER FUNCTIONS ===============================
       
    42 
       
    43 // ----------------------------------------------------------------------------
       
    44 // CIMSSettingsWizardEditTextPage::CIMSSettingsWizardEditTextPage()
       
    45 // ----------------------------------------------------------------------------
       
    46 CIMSSettingsWizardEditTextPage::CIMSSettingsWizardEditTextPage(
       
    47     CIMSSettingsWizard& aWizard,
       
    48     TInt aResourceId,
       
    49     TDes& aText,
       
    50     TDesC& aPageText,
       
    51     TInt aTextSettingPageFlags )
       
    52     :
       
    53     CAknTextSettingPage( aResourceId, aText, aTextSettingPageFlags ),
       
    54     iWizard( aWizard ),
       
    55     iText( aText ),
       
    56     iPageText( aPageText )
       
    57     {
       
    58     IMUM_CONTEXT( CIMSSettingsWizardEditTextPage::CIMSSettingsWizardEditTextPage, 0, KLogUi );
       
    59 
       
    60     }
       
    61 
       
    62 // ----------------------------------------------------------------------------
       
    63 // CIMSSettingsWizardEditTextPage::ConstructL()
       
    64 // ----------------------------------------------------------------------------
       
    65 //
       
    66 void CIMSSettingsWizardEditTextPage::ConstructL()
       
    67     {
       
    68     IMUM_CONTEXT( CIMSSettingsWizardEditTextPage::ConstructL, 0, KLogUi );
       
    69 
       
    70     CAknTextSettingPage::ConstructL();
       
    71     }
       
    72 
       
    73 // ----------------------------------------------------------------------------
       
    74 // CIMSSettingsWizardEditTextPage::PostDisplayCheckL()
       
    75 // ----------------------------------------------------------------------------
       
    76 //
       
    77 TBool CIMSSettingsWizardEditTextPage::PostDisplayCheckL()
       
    78     {
       
    79     IMUM_CONTEXT( CIMSSettingsWizardEditTextPage::PostDisplayCheckL, 0, KLogUi );
       
    80 
       
    81     // Set the text to navipane
       
    82     UpdateIndicatorL();
       
    83 
       
    84     // Handle text selections
       
    85     UpdateTextEditorL();
       
    86 
       
    87     // Reset popup
       
    88     iWizard.PostponePopup();
       
    89 
       
    90     return ETrue;
       
    91     }
       
    92 
       
    93 // ----------------------------------------------------------------------------
       
    94 // CIMSSettingsWizardEditTextPage::~CIMSSettingsWizardEditTextPage()
       
    95 // ----------------------------------------------------------------------------
       
    96 //
       
    97 CIMSSettingsWizardEditTextPage::~CIMSSettingsWizardEditTextPage()
       
    98     {
       
    99     IMUM_CONTEXT( CIMSSettingsWizardEditTextPage::~CIMSSettingsWizardEditTextPage, 0, KLogUi );
       
   100 
       
   101     MAknEditingStateIndicator* ptr = iAvkonEnv->EditingStateIndicator();
       
   102 
       
   103     if ( ptr )
       
   104         {
       
   105         CAknIndicatorContainer* iIndicatorContainer =
       
   106             ptr->IndicatorContainer();
       
   107 
       
   108         // Make sure the pointer to indicator exist
       
   109         if ( iIndicatorContainer )
       
   110             {
       
   111             iIndicatorContainer->SetIndicatorState(
       
   112                 TUid::Uid( EAknNaviPaneEditorIndicatorMessageLength ),
       
   113                 EAknIndicatorStateOff );
       
   114             }
       
   115         }
       
   116     }
       
   117 
       
   118 // ----------------------------------------------------------------------------
       
   119 // CIMSSettingsWizardEditTextPage::NewL()
       
   120 // ----------------------------------------------------------------------------
       
   121 //
       
   122 CIMSSettingsWizardEditTextPage* CIMSSettingsWizardEditTextPage::NewL(
       
   123     CIMSSettingsWizard& aWizard,
       
   124     TInt aResourceId,
       
   125     TDes& aText,
       
   126     TDesC& aPageText,
       
   127     TInt aTextSettingPageFlags )
       
   128     {
       
   129     IMUM_STATIC_CONTEXT( CIMSSettingsWizardEditTextPage::NewL, 0, utils, KLogUi );
       
   130 
       
   131     CIMSSettingsWizardEditTextPage* self = NewLC(
       
   132         aWizard, aResourceId, aText, aPageText, aTextSettingPageFlags );
       
   133     CleanupStack::Pop( self );
       
   134 
       
   135     return self;
       
   136     }
       
   137 
       
   138 // ----------------------------------------------------------------------------
       
   139 // CIMSSettingsWizardEditTextPage::NewLC()
       
   140 // ----------------------------------------------------------------------------
       
   141 //
       
   142 CIMSSettingsWizardEditTextPage* CIMSSettingsWizardEditTextPage::NewLC(
       
   143     CIMSSettingsWizard& aWizard,
       
   144     TInt aResourceId,
       
   145     TDes& aText,
       
   146     TDesC& aPageText,
       
   147     TInt aTextSettingPageFlags )
       
   148     {
       
   149     IMUM_STATIC_CONTEXT( CIMSSettingsWizardEditTextPage::NewLC, 0, utils, KLogUi );
       
   150 
       
   151     CIMSSettingsWizardEditTextPage* self =
       
   152         new ( ELeave ) CIMSSettingsWizardEditTextPage(
       
   153             aWizard, aResourceId, aText, aPageText, aTextSettingPageFlags );
       
   154     CleanupStack::PushL( self );
       
   155     self->ConstructL();
       
   156 
       
   157     return self;
       
   158     }
       
   159 
       
   160 // ----------------------------------------------------------------------------
       
   161 // CIMSSettingsWizardEditTextPage::ProcessCommandL()
       
   162 // ----------------------------------------------------------------------------
       
   163 //
       
   164 void CIMSSettingsWizardEditTextPage::ProcessCommandL( TInt aCommandId )
       
   165     {
       
   166     IMUM_CONTEXT( CIMSSettingsWizardEditTextPage::ProcessCommandL, 0, KLogUi );
       
   167 
       
   168     // Reset info popup
       
   169     iWizard.PostponePopup();
       
   170 
       
   171     switch( aCommandId )
       
   172         {
       
   173         case EAknSoftkeyCancel: // falltrough
       
   174         case EAknCmdExit:
       
   175             // Exit setting page (dialog)
       
   176             AttemptExitL( EFalse );
       
   177             // falltrough
       
   178         case EAknSoftkeyBack: // falltrough
       
   179         case EAknSoftkeyDone:
       
   180             // Move to prev/next wizard page or exit app
       
   181             iWizard.ProcessCommandL( aCommandId );
       
   182             break;
       
   183         default:
       
   184             // Process edit commands (eg. number/alpha mode, spec. char table)
       
   185             CAknTextSettingPage::ProcessCommandL( aCommandId );
       
   186             break;
       
   187         }
       
   188     }
       
   189 
       
   190 // ----------------------------------------------------------------------------
       
   191 // CIMSSettingsWizardEditTextPage::KeyPressedNextL()
       
   192 // ----------------------------------------------------------------------------
       
   193 //
       
   194 void CIMSSettingsWizardEditTextPage::KeyPressedNextL()
       
   195     {
       
   196     IMUM_CONTEXT( CIMSSettingsWizardEditTextPage::KeyPressedNextL, 0, KLogUi );
       
   197 
       
   198     AttemptExitL( ETrue );
       
   199     }
       
   200 
       
   201 // ----------------------------------------------------------------------------
       
   202 // CIMSSettingsWizardEditTextPage::KeyPressedBackL()
       
   203 // ----------------------------------------------------------------------------
       
   204 //
       
   205 void CIMSSettingsWizardEditTextPage::KeyPressedBackL()
       
   206     {
       
   207     IMUM_CONTEXT( CIMSSettingsWizardEditTextPage::KeyPressedBackL, 0, KLogUi );
       
   208 
       
   209     AttemptExitL( EFalse );
       
   210     }
       
   211 
       
   212 // ----------------------------------------------------------------------------
       
   213 // CIMSSettingsWizardEditTextPage::KeyPressedSelectL()
       
   214 // ----------------------------------------------------------------------------
       
   215 //
       
   216 void CIMSSettingsWizardEditTextPage::KeyPressedSelectL()
       
   217     {
       
   218     IMUM_CONTEXT( CIMSSettingsWizardEditTextPage::KeyPressedSelectL, 0, KLogUi );
       
   219 
       
   220     }
       
   221 
       
   222 // ----------------------------------------------------------------------------
       
   223 // CIMSSettingsWizardEditTextPage::UpdateIndicatorL()
       
   224 // ----------------------------------------------------------------------------
       
   225 //
       
   226 void CIMSSettingsWizardEditTextPage::UpdateIndicatorL()
       
   227     {
       
   228     IMUM_CONTEXT( CIMSSettingsWizardEditTextPage::UpdateIndicatorL, 0, KLogUi );
       
   229 
       
   230     MAknEditingStateIndicator* ptr = iAvkonEnv->EditingStateIndicator();
       
   231 
       
   232     if ( ptr )
       
   233         {
       
   234         CAknIndicatorContainer* iIndicatorContainer =
       
   235             ptr->IndicatorContainer();
       
   236 
       
   237         // Make sure the pointer to indicator exist
       
   238         if ( iIndicatorContainer )
       
   239             {
       
   240             iIndicatorContainer->SetIndicatorState(
       
   241                 TUid::Uid( EAknNaviPaneEditorIndicatorMessageLength ),
       
   242                 EAknIndicatorStateOn );
       
   243             iIndicatorContainer->SetIndicatorValueL(
       
   244                 TUid::Uid( EAknNaviPaneEditorIndicatorMessageLength ),
       
   245                 iPageText );
       
   246             }
       
   247         }
       
   248     }
       
   249 
       
   250 // ----------------------------------------------------------------------------
       
   251 // CIMSSettingsWizardEditTextPage::UpdateTextEditorL()
       
   252 // ----------------------------------------------------------------------------
       
   253 //
       
   254 void CIMSSettingsWizardEditTextPage::UpdateTextEditorL()
       
   255     {
       
   256     IMUM_CONTEXT( CIMSSettingsWizardEditTextPage::UpdateTextEditorL, 0, KLogUi );
       
   257 
       
   258     // Check if the text contains '@' in the first char
       
   259     if ( iText.Size() && iText[0] == KIMASCharAt )
       
   260         {
       
   261         // Remove selection and move the cursor at the beginning
       
   262         CEikEdwin* edwin = TextControl();
       
   263         edwin->ClearSelectionL();
       
   264         edwin->SetCursorPosL( 0, EFalse );
       
   265         edwin = NULL;
       
   266         }
       
   267     }
       
   268 
       
   269 // -----------------------------------------------------------------------------
       
   270 // CIMSSettingsWizardEditTextPage::OfferKeyEventL()
       
   271 // This is needed to postpone popup time
       
   272 // when user is writing. Popup should apper
       
   273 // only when user has been "idle" for some time.
       
   274 // -----------------------------------------------------------------------------
       
   275 //
       
   276 TKeyResponse CIMSSettingsWizardEditTextPage::OfferKeyEventL(
       
   277     const TKeyEvent& aKeyEvent,
       
   278     TEventCode aType )
       
   279     {
       
   280     IMUM_CONTEXT( CIMSSettingsWizardEditTextPage::OfferKeyEventL, 0, KLogUi );
       
   281 
       
   282     if ( aType == EEventKeyDown )
       
   283         {
       
   284         iWizard.PostponePopup();
       
   285         }
       
   286     return CAknTextSettingPage::OfferKeyEventL( aKeyEvent, aType );
       
   287     }
       
   288 
       
   289 #ifdef RD_SCALABLE_UI_V2
       
   290 // -----------------------------------------------------------------------------
       
   291 // CIMSSettingsWizardEditTextPage::HandlePointerEventL()
       
   292 // This is needed to postpone popup time
       
   293 // when user is tapping with stylus. Popup should apper
       
   294 // only when user has been "idle" for some time.
       
   295 // -----------------------------------------------------------------------------
       
   296 //
       
   297 void CIMSSettingsWizardEditTextPage::HandlePointerEventL(
       
   298     const TPointerEvent& aPointerEvent)
       
   299     {
       
   300     IMUM_CONTEXT( CIMSSettingsWizardEditTextPage::HandlePointerEventL, 0, KLogUi );
       
   301     IMUM_IN();
       
   302 
       
   303     if( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
   304         {
       
   305         iWizard.PostponePopup();
       
   306         }
       
   307 
       
   308     CAknTextSettingPage::HandlePointerEventL( aPointerEvent );
       
   309     IMUM_OUT();
       
   310     }
       
   311 
       
   312 // -----------------------------------------------------------------------------
       
   313 // CIMSSettingsWizardEditTextPage::HandleControlEventL()
       
   314 // This is needed to postpone popup time
       
   315 // when user is writing with stylus. Popup should apper
       
   316 // only when user has been "idle" for some time.
       
   317 // -----------------------------------------------------------------------------
       
   318 //
       
   319 void CIMSSettingsWizardEditTextPage::HandleControlEventL(
       
   320     CCoeControl* aControl, TCoeEvent aEventType )
       
   321     {
       
   322     IMUM_CONTEXT( CIMSSettingsWizardEditTextPage::HandleControlEventL, 0, KLogUi );
       
   323     IMUM_IN();
       
   324 
       
   325     if( aEventType == EEventStateChanged )
       
   326         {
       
   327         iWizard.PostponePopup();
       
   328         }
       
   329 
       
   330     CAknTextSettingPage::HandleControlEventL( aControl, aEventType );
       
   331     IMUM_OUT();
       
   332     }
       
   333 
       
   334 #endif  //RD_SCALABLE_UI_V2
       
   335 
       
   336 //  End of File