deviceencryption/DevEncUi/src/DevEncUiDecrViewContainer.cpp
branchRCL_3
changeset 39 65326cf895ed
child 52 40fb776cbfb3
equal deleted inserted replaced
38:491b3ed49290 39:65326cf895ed
       
     1 /*
       
     2 * Copyright (c) 2005 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:  Implementation of CDevEncUiDecrViewContainer.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 
       
    20 // Class includes
       
    21 #include "DevEncUiDecrViewContainer.h"
       
    22 
       
    23 // System Includes
       
    24 #include <aknlists.h>
       
    25 #include <barsread.h>
       
    26 #include <coemain.h>
       
    27 #include <devencui.rsg>
       
    28 #include <eikenv.h>
       
    29 
       
    30 // User Includes
       
    31 #include "DevEncLog.h"
       
    32 #include "DevEnc.hrh"
       
    33 #include "DevEncUi.pan"
       
    34 #include "DevEncUiAppui.h"
       
    35 #include "DevEncUiDocument.h"
       
    36 #include "DevEncUiDecrView.h"
       
    37 
       
    38 // ================= MEMBER FUNCTIONS =======================
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CDevEncUiDecrViewContainer::NewLC
       
    42 //
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 CDevEncUiDecrViewContainer* CDevEncUiDecrViewContainer::NewLC( const TRect& aRect,
       
    46                                                                CAknView& aOwningView )
       
    47 	{
       
    48     CDevEncUiDecrViewContainer* self =
       
    49         new ( ELeave ) CDevEncUiDecrViewContainer( aOwningView );
       
    50     CleanupStack::PushL( self );
       
    51     self->ConstructL( aRect );
       
    52     return self;
       
    53 	}
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CDevEncUiDecrViewContainer::NewL
       
    57 //
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 CDevEncUiDecrViewContainer* CDevEncUiDecrViewContainer::NewL( const TRect& aRect,
       
    61                                                               CAknView& aOwningView )
       
    62 	{
       
    63     CDevEncUiDecrViewContainer* self = NewLC( aRect, aOwningView );
       
    64     CleanupStack::Pop( self );
       
    65     return self;
       
    66 	}
       
    67 
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CDevEncUiDecrViewContainer::ConstructL
       
    71 //
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 void CDevEncUiDecrViewContainer::ConstructL( const TRect& aRect )
       
    75 	{
       
    76     // Create a window for this application view
       
    77     CreateWindowL();
       
    78 
       
    79     CreateListL();
       
    80 
       
    81     // Set the windows size
       
    82     SetRect( aRect );
       
    83 
       
    84     // Activate the window, which makes it ready to be drawn
       
    85     ActivateL();
       
    86 	}
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // CDevEncUiDecrViewContainer::CreateListL
       
    90 //
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 void CDevEncUiDecrViewContainer::CreateListL()
       
    94     {
       
    95     // First phase construction
       
    96     iListBox = new ( ELeave ) CAknDoubleStyle2ListBox;
       
    97     iListBox->SetContainerWindowL( *this );
       
    98 
       
    99     // Second Phase Construction
       
   100     TResourceReader reader;
       
   101     iEikonEnv->CreateResourceReaderLC( reader, R_DEVENCUI_DECRYPTION_LISTBOX );
       
   102     iListBox->ConstructFromResourceL( reader );
       
   103     CleanupStack::PopAndDestroy(); // reader (Can't pass T-classes as parameter)
       
   104 
       
   105     iListBox->SetListBoxObserver( this );
       
   106     iListBox->CreateScrollBarFrameL( ETrue );
       
   107     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   108         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
   109     }
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CDevEncUiDecrViewContainer::CDevEncUiDecrViewContainer
       
   113 //
       
   114 // -----------------------------------------------------------------------------
       
   115 //
       
   116 CDevEncUiDecrViewContainer::CDevEncUiDecrViewContainer( CAknView& aOwningView )
       
   117  :	iOwningView( aOwningView )
       
   118     {
       
   119     // No implementation required
       
   120 	}
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CDevEncUiDecrViewContainer::CDevEncUiDecrViewContainer
       
   124 //
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 CDevEncUiDecrViewContainer::~CDevEncUiDecrViewContainer()
       
   128 	{
       
   129     delete iListBox;
       
   130 	}
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CDevEncUiDecrViewContainer::HandleListBoxEventL
       
   134 //
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 void CDevEncUiDecrViewContainer::HandleListBoxEventL( CEikListBox* /*aListBox*/,
       
   138                           TListBoxEvent aEventType )
       
   139     {
       
   140     switch ( aEventType )
       
   141         {
       
   142         case EEventItemSingleClicked: // FALLTHROUGH
       
   143         case EEventEnterKeyPressed:
       
   144             {
       
   145             if ( iListBox->CurrentItemIndex() == 0 )
       
   146                 {
       
   147                 iOwningView.HandleCommandL( EDevEncUiCommandDecrypt );
       
   148                 }
       
   149             if ( iListBox->CurrentItemIndex() == 1 )
       
   150                 {
       
   151                 iOwningView.HandleCommandL( EDevEncUiCommandDecryptAndTurnOffEncryption );
       
   152                 }
       
   153             }
       
   154             break;
       
   155         default:
       
   156             break;
       
   157         }
       
   158     }
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // CDevEncUiDecrViewContainer::CountComponentControls
       
   162 // Return number of controls inside this container
       
   163 // -----------------------------------------------------------------------------
       
   164 //
       
   165 TInt CDevEncUiDecrViewContainer::CountComponentControls() const
       
   166     {
       
   167     return 1;
       
   168     }
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // CDevEncUiDecrViewContainer::ComponentControl
       
   172 //
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 CCoeControl* CDevEncUiDecrViewContainer::ComponentControl( TInt aIndex ) const
       
   176     {
       
   177     switch ( aIndex )
       
   178         {
       
   179         case 0:
       
   180             return iListBox;
       
   181         default:
       
   182             return NULL;
       
   183         }
       
   184     }
       
   185 
       
   186 // -----------------------------------------------------------------------------
       
   187 // CDevEncUiDecrViewContainer::Draw
       
   188 //
       
   189 // -----------------------------------------------------------------------------
       
   190 //
       
   191 void CDevEncUiDecrViewContainer::Draw( const TRect& aRect ) const
       
   192     {
       
   193     CWindowGc& gc = SystemGc();
       
   194     gc.Clear( aRect );
       
   195     }
       
   196 
       
   197 // -----------------------------------------------------------------------------
       
   198 // CDevEncUiDecrViewContainer::OfferKeyEventL
       
   199 //
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 TKeyResponse CDevEncUiDecrViewContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   203                                                          TEventCode aType )
       
   204     {
       
   205     if ( !iListBox )
       
   206         {
       
   207         return EKeyWasNotConsumed;
       
   208         }
       
   209     if ( aKeyEvent.iCode == EKeyDevice3 /* OK key */ )
       
   210         {
       
   211         if ( iListBox->CurrentItemIndex() < 0 )
       
   212             {
       
   213             return EKeyWasConsumed;
       
   214             }
       
   215         // User selected a list item. Notify the callback instance.
       
   216         if ( iListBox->CurrentItemIndex() == 0 )
       
   217             {
       
   218             iOwningView.HandleCommandL( EDevEncUiCommandDecrypt );
       
   219             }
       
   220         if ( iListBox->CurrentItemIndex() == 1 )
       
   221             {
       
   222             iOwningView.HandleCommandL( EDevEncUiCommandDecryptAndTurnOffEncryption );
       
   223             }
       
   224         return EKeyWasConsumed;
       
   225         }
       
   226     return iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   227     }
       
   228 
       
   229 // --------------------------------------------------------------------------
       
   230 // CDevEncUiDecrViewContainer::SizeChanged()
       
   231 //
       
   232 // --------------------------------------------------------------------------
       
   233 //
       
   234  void CDevEncUiDecrViewContainer::SizeChanged()
       
   235     {
       
   236     if ( iListBox )
       
   237         {
       
   238         iListBox->SetExtent( TPoint( 0, 0 ), iListBox->MinimumSize() );
       
   239         }
       
   240     }
       
   241 
       
   242 //End Of File
       
   243 
       
   244