examples/ForumNokia/CalendarExample/src/CAlendarAPIexampleEntryContainer.cpp

00001 /*
00002  * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003  *    
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are met:
00006  *    
00007  *  * Redistributions of source code must retain the above copyright notice, this
00008  *    list of conditions and the following disclaimer.
00009  *  * Redistributions in binary form must reproduce the above copyright notice,
00010  *    this list of conditions and the following disclaimer in the documentation
00011  *    and/or other materials provided with the distribution.
00012  *  * Neither the name of Nokia Corporation nor the names of its contributors
00013  *    may be used to endorse or promote products derived from this software
00014  *    without specific prior written permission.
00015  *    
00016  *    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017  *    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018  *    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019  *    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020  *    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021  *    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022  *    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023  *    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024  *    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025  *    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026  *    
00027  *    Description:  
00028  */
00029 
00030 // INCLUDE FILES
00031 #include <CalendarAPIexample.rsg> 
00032 #include "CalendarAPIexampleEntryContainer.h"
00033 #include "CalendarAPIexample.hrh"
00034 #include "CalendarAPIexampleEntryItemList.h"
00035 #include "CalendarAPIexampleDocument.h"
00036 
00037 
00038 // ================= MEMBER FUNCTIONS =======================
00039 
00040 // constructor
00041 CCalendarAPIexampleEntryContainer::CCalendarAPIexampleEntryContainer()
00042     {
00043     }
00044 
00045 // destructor
00046 CCalendarAPIexampleEntryContainer::~CCalendarAPIexampleEntryContainer()
00047     {
00048     delete iItemList;
00049     iItemList=NULL;
00050     }
00051 
00052 // Two-phased constructor.  
00053 CCalendarAPIexampleEntryContainer* CCalendarAPIexampleEntryContainer::NewL(
00054                             const TRect& aRect, 
00055                             const TDesC& aName,
00056                             const TDateTime& aDate,
00057                             const TBool& aAlarm,
00058                             const TDateTime& aAlarmTime,
00059                             const TInt& aSync)
00060     {
00061     CCalendarAPIexampleEntryContainer* self = 
00062         new (ELeave) CCalendarAPIexampleEntryContainer();
00063     CleanupStack::PushL(self);
00064     self->ConstructL(aRect, aName, aDate,aAlarm, aAlarmTime, aSync);
00065     CleanupStack::Pop(self);
00066     return self;
00067     }
00068 
00069 // Symbian OS default constructor can leave.    
00070 void CCalendarAPIexampleEntryContainer::ConstructL(
00071                             const TRect& aRect,
00072                             const TDesC& aName,
00073                             const TDateTime& aDate,
00074                             const TBool& aAlarm,
00075                             const TDateTime& aAlarmTime,
00076                             const TInt& aSync)
00077     {
00078     CreateWindowL();    
00079 
00080     iItemList = new (ELeave) CCalendarAPIexampleEntryItemList();
00081     iItemList->SetContainerWindowL(*this); 
00082 
00083     SetValues(aName, aDate,aAlarm, aAlarmTime, aSync);
00084     //This results in a call to CreateSettingItemL
00085     //So the data should be there already   
00086     iItemList->ConstructFromResourceL(R_ENTRY_SETTINGS_LIST); 
00087     
00088     SetRect(aRect);
00089     ActivateL();    
00090     }
00091 
00092 void CCalendarAPIexampleEntryContainer::SizeChanged()
00093     {
00094     iItemList->SetRect(Rect());
00095     iItemList->ListBox()->SetRect(Rect());
00096     }
00097 
00098 void CCalendarAPIexampleEntryContainer::HandleResourceChange(TInt aType)
00099     {
00100     CCoeControl::HandleResourceChange(aType);
00101     if ( aType==KEikDynamicLayoutVariantSwitch )
00102         {
00103         TRect rect;
00104         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
00105         SetRect(rect);
00106         }
00107     }
00108 
00109 
00110 // ----------------------------------------------------
00111 // CCalendarAPIexampleEntryContainer::CountComponentControls()
00112 // Gets the number of controls contained in a compound 
00113 // control. 
00114 // ----------------------------------------------------
00115 //          
00116 TInt CCalendarAPIexampleEntryContainer::CountComponentControls() const
00117     {
00118     TInt count = 0;
00119     if (iItemList)
00120         count++;
00121     return count;
00122     }
00123     
00124 // ----------------------------------------------------
00125 // CCalendarAPIexampleEntryContainer::ComponentControl()
00126 // Gets the specified component of a compound control.
00127 // ----------------------------------------------------
00128 //  
00129 CCoeControl* CCalendarAPIexampleEntryContainer::ComponentControl(
00130                                                                 TInt /*aIndex*/
00131                                                                 ) const
00132     {
00133     return iItemList;
00134     }
00135     
00136 // ----------------------------------------------------
00137 // CCalendarAPIexampleEntryContainer::OfferKeyEventL()
00138 // When a key event occurs, the control framework calls 
00139 // this function for each control on the control stack, 
00140 // until one of them can process the key event 
00141 // (and returns EKeyWasConsumed).
00142 // ----------------------------------------------------
00143 //  
00144 TKeyResponse CCalendarAPIexampleEntryContainer::OfferKeyEventL( 
00145                                                 const TKeyEvent& aKeyEvent, 
00146                                                 TEventCode aType )
00147     {
00148     if(aType != EEventKey)
00149         {
00150         return EKeyWasNotConsumed;
00151         }    
00152     else if(iItemList)
00153         {
00154         return iItemList->OfferKeyEventL( aKeyEvent, aType );
00155         }
00156     else
00157         {
00158         return EKeyWasNotConsumed;
00159         }
00160     
00161     }
00162     
00163 // ----------------------------------------------------
00164 // CCalendarAPIexampleEntryContainer::SaveL()
00165 // Calls the itemlist to save its values to containers
00166 // member entry object
00167 // ----------------------------------------------------
00168 //  
00169 TBool CCalendarAPIexampleEntryContainer::SaveL()
00170     {   
00171     return iItemList->SaveL();
00172     }
00173     
00174 void CCalendarAPIexampleEntryContainer::GetValues(
00175                                 TDes& aName, TTime& aDate,
00176                                 TBool& aAlarm, TTime& aAlarmTime, 
00177                                 TInt& aSync)
00178     {
00179     iItemList->GetValues(aName,aDate,aAlarm,aAlarmTime,aSync);
00180     }
00181 
00182 void CCalendarAPIexampleEntryContainer::SetValues(
00183                             const TDesC& aName,
00184                             const TDateTime& aDate,
00185                             const TBool& aAlarm,
00186                             const TDateTime& aAlarmTime,
00187                             const TInt& aSync)                               
00188     {
00189     iItemList->SetValues(aName,aDate,aAlarm,aAlarmTime,aSync);
00190     }    
00191 
00192 // End of File

Generated by  doxygen 1.6.2