examples/ForumNokia/CalendarExample/src/CAlendarAPIexampleEntryContainer.cpp

00001 /*
00002  * Copyright © 2008 Nokia Corporation.
00003  */
00004 
00005 // INCLUDE FILES
00006 #include <CalendarAPIexample.rsg> 
00007 #include "CalendarAPIexampleEntryContainer.h"
00008 #include "CalendarAPIexample.hrh"
00009 #include "CalendarAPIexampleEntryItemList.h"
00010 #include "CalendarAPIexampleDocument.h"
00011 
00012 
00013 // ================= MEMBER FUNCTIONS =======================
00014 
00015 // constructor
00016 CCalendarAPIexampleEntryContainer::CCalendarAPIexampleEntryContainer()
00017     {
00018     }
00019 
00020 // destructor
00021 CCalendarAPIexampleEntryContainer::~CCalendarAPIexampleEntryContainer()
00022     {
00023     delete iItemList;
00024     iItemList=NULL;
00025     }
00026 
00027 // Two-phased constructor.  
00028 CCalendarAPIexampleEntryContainer* CCalendarAPIexampleEntryContainer::NewL(
00029                             const TRect& aRect, 
00030                             const TDesC& aName,
00031                             const TDateTime& aDate,
00032                             const TBool& aAlarm,
00033                             const TDateTime& aAlarmTime,
00034                             const TInt& aSync)
00035     {
00036     CCalendarAPIexampleEntryContainer* self = 
00037         new (ELeave) CCalendarAPIexampleEntryContainer();
00038     CleanupStack::PushL(self);
00039     self->ConstructL(aRect, aName, aDate,aAlarm, aAlarmTime, aSync);
00040     CleanupStack::Pop(self);
00041     return self;
00042     }
00043 
00044 // Symbian OS default constructor can leave.    
00045 void CCalendarAPIexampleEntryContainer::ConstructL(
00046                             const TRect& aRect,
00047                             const TDesC& aName,
00048                             const TDateTime& aDate,
00049                             const TBool& aAlarm,
00050                             const TDateTime& aAlarmTime,
00051                             const TInt& aSync)
00052     {
00053     CreateWindowL();    
00054 
00055     iItemList = new (ELeave) CCalendarAPIexampleEntryItemList();
00056     iItemList->SetContainerWindowL(*this); 
00057 
00058     SetValues(aName, aDate,aAlarm, aAlarmTime, aSync);
00059     //This results in a call to CreateSettingItemL
00060     //So the data should be there already   
00061     iItemList->ConstructFromResourceL(R_ENTRY_SETTINGS_LIST); 
00062     
00063     SetRect(aRect);
00064     ActivateL();    
00065     }
00066 
00067 void CCalendarAPIexampleEntryContainer::SizeChanged()
00068     {
00069     iItemList->SetRect(Rect());
00070     iItemList->ListBox()->SetRect(Rect());
00071     }
00072 
00073 void CCalendarAPIexampleEntryContainer::HandleResourceChange(TInt aType)
00074     {
00075     CCoeControl::HandleResourceChange(aType);
00076     if ( aType==KEikDynamicLayoutVariantSwitch )
00077         {
00078         TRect rect;
00079         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
00080         SetRect(rect);
00081         }
00082     }
00083 
00084 
00085 // ----------------------------------------------------
00086 // CCalendarAPIexampleEntryContainer::CountComponentControls()
00087 // Gets the number of controls contained in a compound 
00088 // control. 
00089 // ----------------------------------------------------
00090 //          
00091 TInt CCalendarAPIexampleEntryContainer::CountComponentControls() const
00092     {
00093     TInt count = 0;
00094     if (iItemList)
00095         count++;
00096     return count;
00097     }
00098     
00099 // ----------------------------------------------------
00100 // CCalendarAPIexampleEntryContainer::ComponentControl()
00101 // Gets the specified component of a compound control.
00102 // ----------------------------------------------------
00103 //  
00104 CCoeControl* CCalendarAPIexampleEntryContainer::ComponentControl(
00105                                                                 TInt /*aIndex*/
00106                                                                 ) const
00107     {
00108     return iItemList;
00109     }
00110     
00111 // ----------------------------------------------------
00112 // CCalendarAPIexampleEntryContainer::OfferKeyEventL()
00113 // When a key event occurs, the control framework calls 
00114 // this function for each control on the control stack, 
00115 // until one of them can process the key event 
00116 // (and returns EKeyWasConsumed).
00117 // ----------------------------------------------------
00118 //  
00119 TKeyResponse CCalendarAPIexampleEntryContainer::OfferKeyEventL( 
00120                                                 const TKeyEvent& aKeyEvent, 
00121                                                 TEventCode aType )
00122     {
00123     if(aType != EEventKey)
00124         {
00125         return EKeyWasNotConsumed;
00126         }    
00127     else if(iItemList)
00128         {
00129         return iItemList->OfferKeyEventL( aKeyEvent, aType );
00130         }
00131     else
00132         {
00133         return EKeyWasNotConsumed;
00134         }
00135     
00136     }
00137     
00138 // ----------------------------------------------------
00139 // CCalendarAPIexampleEntryContainer::SaveL()
00140 // Calls the itemlist to save its values to containers
00141 // member entry object
00142 // ----------------------------------------------------
00143 //  
00144 TBool CCalendarAPIexampleEntryContainer::SaveL()
00145     {   
00146     return iItemList->SaveL();
00147     }
00148     
00149 void CCalendarAPIexampleEntryContainer::GetValues(
00150                                 TDes& aName, TTime& aDate,
00151                                 TBool& aAlarm, TTime& aAlarmTime, 
00152                                 TInt& aSync)
00153     {
00154     iItemList->GetValues(aName,aDate,aAlarm,aAlarmTime,aSync);
00155     }
00156 
00157 void CCalendarAPIexampleEntryContainer::SetValues(
00158                             const TDesC& aName,
00159                             const TDateTime& aDate,
00160                             const TBool& aAlarm,
00161                             const TDateTime& aAlarmTime,
00162                             const TInt& aSync)                               
00163     {
00164     iItemList->SetValues(aName,aDate,aAlarm,aAlarmTime,aSync);
00165     }    
00166 
00167 // End of File

Generated by  doxygen 1.6.2