email/imum/Utils/Src/IMSWizardControl.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     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: 
       
    15 *       Control class for mailbox wizard help screen
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #include <eikbctrl.h>
       
    23 #include <eikrted.h>
       
    24 #include <AknsUtils.h>
       
    25 #include <AknsBasicBackgroundControlContext.h>
       
    26 #include <AknDef.h>
       
    27 #include <aknappui.h>
       
    28 #include <aknlayoutscalable_apps.cdl.h>
       
    29 #include <AknUtils.h>
       
    30 #include <AknsControlContext.h>
       
    31 #include <AknsDrawUtils.h>
       
    32 #include <StringLoader.h>
       
    33 
       
    34 #include <ImumUtils.rsg>
       
    35 
       
    36 #include "IMSWizardControl.h"
       
    37 
       
    38 
       
    39 // MEMBER FUNCTIONS
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // Constructor
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 
       
    46 CIMSWizardControl::CIMSWizardControl()
       
    47 {
       
    48 }
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // Destructor
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 CIMSWizardControl::~CIMSWizardControl()
       
    55 {
       
    56     delete iEditor;
       
    57     iEditor = NULL;
       
    58 }
       
    59 
       
    60 
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // CIMSWizardControl::ConstructFromResourceL()
       
    64 // From CoeControl
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 void CIMSWizardControl::ConstructFromResourceL( TResourceReader& aReader )
       
    68 {
       
    69     iEditor = new ( ELeave ) CEikRichTextEditor;
       
    70     iEditor->SetContainerWindowL( *this );
       
    71 
       
    72     iEditor->ConstructFromResourceL( aReader );
       
    73     
       
    74     // get help screen text
       
    75     
       
    76     HBufC* helpText = StringLoader::LoadLC( R_IMUM_WIZARD_HELP_SCREEN );
       
    77     
       
    78     iEditor->SetTextL( helpText );
       
    79     CleanupStack::PopAndDestroy( helpText ); 
       
    80 
       
    81 }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // CIMSWizardControl::SizeChanged()
       
    85 // From CCoeControl
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 void CIMSWizardControl::SizeChanged()
       
    89 {
       
    90     TRect clientrect = Rect();
       
    91     
       
    92     // create akn layout rectancular
       
    93     TAknLayoutRect r;
       
    94     // first create whole messaging main pane
       
    95     r.LayoutRect( clientrect, AknLayoutScalable_Apps::main_messa_pane( ) );
       
    96     // listscroll pane for text rows
       
    97     r.LayoutRect( r.Rect(), AknLayoutScalable_Apps::listscroll_mce_pane( ) );
       
    98     // one text line pane
       
    99     r.LayoutRect( r.Rect(), AknLayoutScalable_Apps::mce_text_pane( 0 ) );
       
   100 
       
   101     // count of text rows
       
   102     TInt count = 
       
   103         AknLayoutScalable_Apps::list_single_mce_message_pane_ParamLimits(
       
   104             ).LastRow();
       
   105     // array contains all text rows in help screen
       
   106     RArray<TAknTextComponentLayout> array;
       
   107     
       
   108     
       
   109     for( int i = 0; i < count; i++ )
       
   110         {
       
   111         // pane area for one text row
       
   112         TAknWindowComponentLayout windowComponentWiz =  
       
   113             AknLayoutScalable_Apps::list_single_mce_message_pane(i);
       
   114         // smaller pane for text itself
       
   115         TAknTextComponentLayout textComponentWiz =  
       
   116             AknLayoutScalable_Apps::list_single_mce_message_pane_t1();
       
   117     
       
   118         // composition of two latter componets
       
   119         TAknTextComponentLayout textCompCompositionWiz = 
       
   120             TAknWindowComponentLayout::ComposeText(
       
   121                 windowComponentWiz, textComponentWiz );
       
   122  
       
   123         TRAPD(error, array.AppendL( textCompCompositionWiz ) );
       
   124         // if error in append function, then just exit the loop      
       
   125         if ( error != KErrNone )
       
   126             {
       
   127             break;
       
   128             }
       
   129         }
       
   130     
       
   131     TAknMultiLineTextLayout multilineLayout 
       
   132         = TAknTextComponentLayout::Multiline( array );         
       
   133 
       
   134     AknLayoutUtils::LayoutEdwin( 
       
   135         iEditor, 
       
   136         r.Rect(), 
       
   137         multilineLayout,
       
   138         EAknsCIQsnTextColorsCG6 );
       
   139         
       
   140     array.Close();
       
   141 }
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // CIMSWizardControl::Draw()
       
   145 // From CCoeControl.
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 void CIMSWizardControl::Draw( const TRect& aRect ) const
       
   149 {
       
   150     // draw function for background
       
   151     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   152     MAknsControlContext* cc = iBgContext;
       
   153     CWindowGc& gc = SystemGc();
       
   154     // if we couldn't get background from layouts, then just set some 
       
   155     // defaults
       
   156     if ( !AknsDrawUtils::Background( skin, cc, this, gc, aRect ) )
       
   157         {
       
   158         gc.SetPenStyle( CGraphicsContext::ENullPen );
       
   159         gc.SetBrushColor( AKN_LAF_COLOR( 0 ) );
       
   160         gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   161         gc.DrawRect( Rect() );
       
   162         } 
       
   163 }
       
   164 
       
   165 // ---------------------------------------------------------------------------
       
   166 // CIMSWizardControl::CountComponentControls()
       
   167 // From CCoeControl
       
   168 // ---------------------------------------------------------------------------
       
   169 //
       
   170 TInt CIMSWizardControl::CountComponentControls() const
       
   171 {
       
   172     if ( iEditor )
       
   173         {
       
   174         return 1;
       
   175         }
       
   176     return 0;   
       
   177 }
       
   178 
       
   179 // ---------------------------------------------------------------------------
       
   180 // CIMSWizardControl::CountComponentControls()
       
   181 // From CCoeControl
       
   182 // ---------------------------------------------------------------------------
       
   183 //
       
   184 CCoeControl* CIMSWizardControl::ComponentControl( TInt aIndex ) const
       
   185 {
       
   186     if ( aIndex == 0 )
       
   187         {
       
   188         return iEditor;   
       
   189         }
       
   190     return NULL;
       
   191 }
       
   192 
       
   193 // ---------------------------------------------------------------------------
       
   194 // CIMSWizardControl::HandleResourceChange()
       
   195 // From CCoeControl
       
   196 // ---------------------------------------------------------------------------
       
   197 //
       
   198 void CIMSWizardControl::HandleResourceChange( TInt aType )
       
   199 {
       
   200 CCoeControl::HandleResourceChange( aType );
       
   201     if ( aType == KAknsMessageSkinChange ||
       
   202         aType == KEikDynamicLayoutVariantSwitch )
       
   203         {
       
   204         SizeChanged();
       
   205         }  
       
   206 }
       
   207 
       
   208 void CIMSWizardControl::SetBackgroundContext( MAknsControlContext* aContext )
       
   209 {
       
   210     iBgContext = aContext;
       
   211     TRAP_IGNORE( iEditor->SetSkinBackgroundControlContextL( iBgContext ) );
       
   212 }