00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 #include "InternetEmailContainer.h"
00033 
00034 #include <eiklabel.h>  
00035 #include <aknutils.h>  
00036 #include <aknlists.h>  
00037 #include <barsread.h>  
00038 #include <avkon.hrh>
00039 
00040 #include "Internetemail.hrh"
00041 #include "InternetEmailEngine.h"
00042 #include <Internetemail.rsg>
00043 
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 void CInternetEmailContainer::ConstructL(const TRect& aRect, CInternetEmailAppUi* aParent )
00053     {
00054     iParent=aParent;
00055     CreateWindowL();
00056 
00057     iListBox = new (ELeave) CAknDoubleStyleListBox;
00058     iListBox->SetContainerWindowL(*this);
00059     iListBox->ConstructL(this, EAknListBoxSelectionList);
00060 
00061     iListBox->Model()->SetItemTextArray(this); 
00062     iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray); 
00063 
00064     iListBox->SetListBoxObserver( this );
00065     iListBox->CreateScrollBarFrameL(ETrue); 
00066     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
00067         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
00068 
00069     iListBox->SetRect( aRect );
00070     iListBox->ActivateL();
00071 
00072     
00073     SetRect(aRect);
00074 
00075     
00076     ActivateL();
00077     }
00078 
00079 
00080 
00081 
00082 
00083 CInternetEmailContainer::~CInternetEmailContainer()
00084     {
00085     delete iListBox;
00086     }
00087 
00088 
00089 
00090 
00091 
00092 
00093 
00094 void CInternetEmailContainer::SizeChanged()
00095     {
00096     iListBox->SetRect( Rect() );
00097     }
00098 
00099 
00100 
00101 
00102 
00103 TInt CInternetEmailContainer::CountComponentControls() const
00104     {
00105     return 1;
00106     }
00107 
00108 
00109 
00110 
00111 
00112 CCoeControl* CInternetEmailContainer::ComponentControl(TInt aIndex) const
00113     {
00114     switch ( aIndex )
00115         {
00116         case 0:
00117             return iListBox;
00118         default:
00119             return NULL;
00120         }
00121     }
00122 
00123 void CInternetEmailContainer::HandleResourceChange(TInt aType)
00124     {
00125     CCoeControl::HandleResourceChange(aType);
00126     if ( aType==KEikDynamicLayoutVariantSwitch )
00127         {
00128         TRect rect;
00129         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
00130         SetRect(rect);
00131         }
00132     }
00133 
00134 
00135 
00136 
00137 
00138 void CInternetEmailContainer::Draw(const TRect& aRect) const
00139     {
00140     CWindowGc& gc = SystemGc();
00141     gc.SetPenStyle(CGraphicsContext::ENullPen);
00142     gc.SetBrushColor(KRgbGray);
00143     gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
00144     gc.DrawRect(aRect);
00145     }
00146 
00147 
00148 
00149 
00150 
00151 
00152 
00153 
00154 TKeyResponse CInternetEmailContainer::OfferKeyEventL(
00155     const TKeyEvent& aKeyEvent, TEventCode aType)
00156     {
00157     if ( aType != EEventKey )
00158         {
00159         return EKeyWasNotConsumed;
00160         }
00161 
00162     switch ( aKeyEvent.iCode )
00163         {
00164         
00165         case EKeyOK:
00166         case EKeyUpArrow:
00167         case EKeyDownArrow:
00168             if ( iListBox )
00169                 {
00170                 return iListBox->OfferKeyEventL( aKeyEvent, aType );
00171                 }
00172             break;
00173 
00174         default:
00175             break;
00176         }
00177 
00178     return EKeyWasNotConsumed;
00179     }
00180 
00181 
00182 
00183 
00184 
00185 
00186 void CInternetEmailContainer::HandleControlEventL(
00187     CCoeControl* ,TCoeEvent )
00188     {
00189     
00190     }
00191 
00192 
00193 
00194 
00195 
00196 
00197 
00198 
00199 void CInternetEmailContainer::HandleListBoxEventL(
00200     CEikListBox* aListBox,TListBoxEvent aEventType)
00201     {
00202     if(aListBox==iListBox &&
00203     ( aEventType==MEikListBoxObserver::EEventEnterKeyPressed ||
00204       aEventType == MEikListBoxObserver::EEventItemClicked || 
00205       aEventType == MEikListBoxObserver::EEventItemDoubleClicked))
00206         {
00207         OpenEmailL(); 
00208         }
00209     }
00210 
00211 
00212 
00213 
00214 
00215 
00216 void CInternetEmailContainer::OpenEmailL()
00217     {
00218     TInt currentItem=iListBox->CurrentItemIndex();
00219     if(currentItem>=0 && currentItem<iParent->Model()->RemoteEmailCount())
00220         {
00221         iParent->Model()->RemoteOpenEmailL(currentItem);
00222         }
00223     }
00224 
00225 
00226 
00227 
00228 
00229 
00230 
00231 void CInternetEmailContainer::EntryToListbox(TInt aIndex) const
00232     {
00233     TPtrC from;
00234     TPtrC subject;
00235 
00236     TRAPD(error,from.Set(iParent->Model()->RemoteEmailSenderL(aIndex)));
00237     if(error == KErrNone)
00238         {
00239         TRAP(error,subject.Set(iParent->Model()->RemoteEmailTextL(aIndex)));
00240         if(error == KErrNone)
00241             {
00242             iText.Format(_L("\t%S\t%S"),&subject,&from);
00243             }
00244         else
00245             {
00246             iText.Zero();
00247             }
00248         }
00249     else
00250         {
00251         iText.Zero();
00252         }
00253     }
00254 
00255 
00256 
00257 
00258 
00259 
00260 TInt CInternetEmailContainer::MdcaCount() const
00261     {
00262     return iParent->Model()->RemoteEmailCount();
00263     }
00264 
00265 
00266 
00267 
00268 
00269 
00270 
00271 TPtrC CInternetEmailContainer::MdcaPoint(TInt aIndex) const
00272     {
00273     EntryToListbox(aIndex);
00274     return iText;
00275     }
00276 
00277 
00278 
00279 
00280 
00281 
00282 
00283 
00284 void CInternetEmailContainer::MailCountChange()
00285     {
00286     iListBox->HandleItemAdditionL();
00287 
00288     
00289     TInt currentItem = iListBox->CurrentItemIndex();
00290     if(currentItem>=0 && currentItem<iParent->Model()->RemoteEmailCount())
00291         {
00292         if( iListBox->ScrollBarFrame() )
00293             {
00294             iListBox->ScrollBarFrame()->MoveVertThumbTo( currentItem );
00295             }
00296         }
00297     }
00298 
00299 
00300