tsrc/CenrepEditor/Src/cenrepeditorview2container.cpp
changeset 15 ccd8e69b5392
parent 2 b31261fd4e04
child 20 e8be2c2e049d
child 22 496ad160a278
equal deleted inserted replaced
2:b31261fd4e04 15:ccd8e69b5392
     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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "cenrepeditorview2container.h"
       
    21 #include "cenrepeditordocument.h"
       
    22 #include "cenrepeditorappui.h"
       
    23 #include  "cenrepeditormodel.h"
       
    24 
       
    25 
       
    26 
       
    27 #include <eiklabel.h>  // for example label control
       
    28 
       
    29 
       
    30 // ================= MEMBER FUNCTIONS =======================
       
    31 
       
    32 // ---------------------------------------------------------
       
    33 // CCenrepEditorView2Container::ConstructL(const TRect& aRect)
       
    34 // EPOC two phased constructor
       
    35 // ---------------------------------------------------------
       
    36 //
       
    37 void CCenrepEditorView2Container::ConstructL(const TRect& aRect,TInt aResourceId, COtherResources*  aOtherResources)
       
    38     {      
       
    39     CreateWindowL(); 
       
    40     iOtherResourceListBox = new(ELeave)COtherResourcesListbox;
       
    41     // and put the data in the list
       
    42     iOtherResourceListBox->SetData(aOtherResources);
       
    43     // setting list is constructed from resources
       
    44     iOtherResourceListBox->ConstructFromResourceL(aResourceId);     
       
    45     SetRect(aRect);
       
    46     iOtherResourceListBox->MakeVisible(ETrue);
       
    47     iOtherResourceListBox->SetRect(aRect);
       
    48     iOtherResourceListBox->LoadSettingsL();
       
    49     iOtherResourceListBox->ActivateL();                
       
    50     ActivateL();
       
    51     }
       
    52 
       
    53 // Destructor
       
    54 CCenrepEditorView2Container::~CCenrepEditorView2Container()
       
    55     {
       
    56     //don't call StoreSettingsL here!, it'll result in copying data
       
    57     //to iOtherResources, which was already deleted
       
    58     //iOtherResourceListBox->StoreSettingsL();
       
    59     delete iOtherResourceListBox;
       
    60 	iOtherResourceListBox = NULL;
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------
       
    64 // CCenrepEditorView2Container::SizeChanged()
       
    65 // Called by framework when the view size is changed
       
    66 // ---------------------------------------------------------
       
    67 //
       
    68 void CCenrepEditorView2Container::SizeChanged()
       
    69     {
       
    70     // TODO: Add here control resize code etc.
       
    71     iOtherResourceListBox->SetRect(Rect());  
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------
       
    75 // CCenrepEditorView2Container::CountComponentControls() const
       
    76 // ---------------------------------------------------------
       
    77 //
       
    78 TInt CCenrepEditorView2Container::CountComponentControls() const
       
    79     {
       
    80     TInt count = 0;    
       
    81     if(iOtherResourceListBox)
       
    82         count++; 
       
    83     return count;
       
    84     }
       
    85 
       
    86 // ---------------------------------------------------------
       
    87 // CCenrepEditorView2Container::ComponentControl(TInt aIndex) const
       
    88 // ---------------------------------------------------------
       
    89 //
       
    90 CCoeControl* CCenrepEditorView2Container::ComponentControl(TInt /*aIndex*/) const
       
    91     {
       
    92     return iOtherResourceListBox;     
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------
       
    96 // CCenrepEditorView2Container::Draw(const TRect& aRect) const
       
    97 // ---------------------------------------------------------
       
    98 //
       
    99 void CCenrepEditorView2Container::Draw(const TRect& aRect) const
       
   100     {
       
   101     CWindowGc& gc = SystemGc();    
       
   102     gc.SetPenStyle( CGraphicsContext::ENullPen );
       
   103     gc.SetBrushColor( KRgbGray );
       
   104     gc.SetBrushStyle( CGraphicsContext::ESolidBrush );    
       
   105     gc.DrawRect( aRect );
       
   106 
       
   107     }
       
   108 
       
   109 
       
   110 TKeyResponse CCenrepEditorView2Container::OfferKeyEventL(
       
   111     const TKeyEvent& aKeyEvent,
       
   112     TEventCode aType )
       
   113     {
       
   114     if(aType != EEventKey) // Is not key event?
       
   115         {
       
   116         return EKeyWasNotConsumed;
       
   117         }       
       
   118     switch (aKeyEvent.iCode)
       
   119         {
       
   120             case EKeyLeftArrow:
       
   121             case EKeyRightArrow:
       
   122                  return EKeyWasNotConsumed;
       
   123             default:
       
   124                  if(iOtherResourceListBox)
       
   125                     {
       
   126                     return iOtherResourceListBox->OfferKeyEventL( aKeyEvent, aType );   
       
   127                     }
       
   128                  else
       
   129                     {
       
   130                     return EKeyWasNotConsumed;
       
   131                     }
       
   132                  
       
   133         }    
       
   134     }    
       
   135 
       
   136 // ---------------------------------------------------------
       
   137 // CCenrepEditorView2Container::StoreSettingsL()
       
   138 // Store the Settings to Variable
       
   139 // ---------------------------------------------------------
       
   140 //
       
   141 void CCenrepEditorView2Container::StoreSettingsL()
       
   142     {    
       
   143     iOtherResourceListBox->StoreSettingsL();
       
   144     }
       
   145 
       
   146 
       
   147 // End of File