videditor/VideoEditorUiComponents/src/ExtProgressDialog.cpp
changeset 0 951a5db380a0
equal deleted inserted replaced
-1:000000000000 0:951a5db380a0
       
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "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 * Ixonos Plc
       
    14 *
       
    15 * Description: 
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /*
       
    21 *   File:       ExtProgressDialog.cpp
       
    22 *   Created:    14-10-2005
       
    23 *   Author:     
       
    24 *               
       
    25 */
       
    26 
       
    27 #include "ExtProgressDialog.h"
       
    28 #include "ExtProgressContainer.h"
       
    29 #include "ExtProgressAnimationControl.h"
       
    30 
       
    31 #include <avkon.hrh>
       
    32 #include <aknborders.h> 
       
    33 #include <AknUtils.h> 
       
    34 #include <eikapp.h>
       
    35 #include <eikprogi.h>
       
    36 #include <eiklabel.h>
       
    37 #include <data_caging_path_literals.hrh>
       
    38 
       
    39 // CONSTANTS
       
    40 _LIT(KResourceFile, "VideoEditorUiComponents.rsc");
       
    41 
       
    42 
       
    43 //=============================================================================
       
    44 EXPORT_C CExtProgressDialog::CExtProgressDialog(CExtProgressDialog** aSelfPtr)
       
    45 : iSelfPtr(aSelfPtr), 
       
    46   iResLoader(*CEikonEnv::Static()) 
       
    47 {
       
    48 }
       
    49 
       
    50 //=============================================================================
       
    51 EXPORT_C CExtProgressDialog::~CExtProgressDialog()
       
    52 {
       
    53     
       
    54     delete iContainer;
       
    55     iResLoader.Close();   
       
    56     
       
    57     // Nullify self pointer
       
    58     *iSelfPtr = NULL;        
       
    59 }
       
    60 
       
    61 //=============================================================================
       
    62 EXPORT_C void CExtProgressDialog::PrepareLC(TInt aResourceId)
       
    63 {
       
    64 	TFileName resourceFile;
       
    65     Dll::FileName(resourceFile);
       
    66     TParse p;
       
    67     p.Set(KResourceFile, &KDC_RESOURCE_FILES_DIR, &resourceFile);
       
    68     resourceFile = p.FullName();
       
    69 	iResLoader.OpenL( resourceFile );
       
    70 
       
    71 	CEikDialog::PrepareLC(aResourceId);
       
    72 
       
    73 	TRect rect;
       
    74 	iContainer = CExtProgressContainer::NewL(rect, this);
       
    75 
       
    76 	iContainer->SetControlContext(this);
       
    77 	iContainer->SetObserver(this);
       
    78 
       
    79 }
       
    80 
       
    81 //============================================================================= 
       
    82 void CExtProgressDialog::SetSizeAndPosition( const TSize& /*aSize*/ )
       
    83 {
       
    84     TRect rect;
       
    85     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
       
    86 
       
    87     TSize size = iContainer->Rect().Size();
       
    88     SetSize(size);
       
    89     SetPosition(TPoint(0, rect.iBr.iY - size.iHeight));
       
    90 }
       
    91 
       
    92 //=============================================================================
       
    93 TBool CExtProgressDialog::OkToExitL( TInt aButtonId )
       
    94 {
       
    95     if (iCallback)
       
    96     {
       
    97         iCallback->DialogDismissedL(aButtonId);
       
    98     }
       
    99     
       
   100     return ETrue;
       
   101 }
       
   102 
       
   103 //=============================================================================    
       
   104 void CExtProgressDialog::PreLayoutDynInitL() 
       
   105 { 
       
   106 
       
   107 }
       
   108     
       
   109 //=============================================================================    
       
   110 TKeyResponse CExtProgressDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
   111 {
       
   112     TKeyResponse res = EKeyWasConsumed;
       
   113             
       
   114     if (aType == EEventKey)
       
   115     {
       
   116         switch (aKeyEvent.iCode)
       
   117         {
       
   118             case 0x31:
       
   119             {
       
   120                 iContainer->GetProgressInfoL()->IncrementAndDraw(1);
       
   121                 
       
   122                 break;
       
   123             }
       
   124             case 0x32:
       
   125             {
       
   126                 DrawNow();
       
   127                 
       
   128                 break;
       
   129             }
       
   130             case 0x33:
       
   131             {
       
   132                 iContainer->GetAnimationControlL()->StartAnimationL();
       
   133                 
       
   134                 break;
       
   135             }
       
   136             case 0x34:
       
   137             {
       
   138                 iContainer->DrawNow();
       
   139                 
       
   140                 break;
       
   141             }
       
   142            case 0x37:
       
   143             {
       
   144                 iContainer->Test();
       
   145                 
       
   146                 break;
       
   147             }             
       
   148            default:
       
   149             {
       
   150                 res = CEikDialog::OfferKeyEventL(aKeyEvent, aType);
       
   151             }
       
   152         }
       
   153     }
       
   154     return res;
       
   155 }
       
   156 
       
   157 //=============================================================================    
       
   158 EXPORT_C void CExtProgressDialog::SetCallback(MExtProgressDialogCallback* aCallback)
       
   159 {
       
   160     iCallback = aCallback;
       
   161 }
       
   162 
       
   163 //============================================================================= 
       
   164 EXPORT_C CEikProgressInfo* CExtProgressDialog::GetProgressInfoL()
       
   165 {
       
   166     return iContainer->GetProgressInfoL();
       
   167 }
       
   168  
       
   169 //============================================================================= 
       
   170 EXPORT_C void CExtProgressDialog::StartAnimationL()
       
   171 {
       
   172     return iContainer->GetAnimationControlL()->StartAnimationL();
       
   173    
       
   174 }
       
   175 
       
   176 //============================================================================= 
       
   177 EXPORT_C void CExtProgressDialog::SetTextL(const TDesC &aText)
       
   178 {
       
   179     iContainer->SetTextL(aText);
       
   180 }
       
   181 //============================================================================= 
       
   182 
       
   183 EXPORT_C void CExtProgressDialog::SetAnimationResourceIdL(const TInt &aResourceId)
       
   184 {
       
   185     iContainer->GetAnimationControlL()->SetAnimationResourceId(aResourceId);
       
   186 }
       
   187 //============================================================================= 
       
   188 
       
   189 void CExtProgressDialog::HandleControlEventL(
       
   190     CCoeControl* /*aControl*/,TCoeEvent aEventType)
       
   191 {
       
   192     if (aEventType == MCoeControlObserver::EEventStateChanged )
       
   193     {
       
   194         DrawNow();    
       
   195     }
       
   196 }
       
   197 
       
   198 //============================================================================= 
       
   199 TInt CExtProgressDialog::CountComponentControls() const
       
   200 {
       
   201     return 1;
       
   202 }
       
   203 
       
   204 //============================================================================= 
       
   205 CCoeControl* CExtProgressDialog::ComponentControl(TInt aIndex) const
       
   206 {
       
   207     CCoeControl* ret = NULL;
       
   208     switch (aIndex)
       
   209     {
       
   210         case 0:
       
   211         {
       
   212             ret = iContainer;
       
   213             break;
       
   214         }
       
   215         default:
       
   216         {
       
   217             break;
       
   218         }
       
   219         
       
   220     }
       
   221     
       
   222     return ret;
       
   223 }
       
   224 
       
   225 // End of File