00001
00002
00003
00004
00005
00006 #include <barsread.h>
00007 #include <CalendarAPIexample.rsg>
00008 #include "CalendarAPIexampleSearchContainer.h"
00009 #include "CalendarAPIexample.pan"
00010 #include "CalendarAPIexampleAppUi.h"
00011 #include "CalendarAPIexampleSearchView.h"
00012
00013
00014 const TInt KPoint = 5;
00015
00016
00017
00018
00019 CCalendarAPIexampleSearchContainer::CCalendarAPIexampleSearchContainer(CCalendarAPIexampleSearchView& aView)
00020 : iSearchView(aView)
00021 {
00022 }
00023
00024
00025 CCalendarAPIexampleSearchContainer::~CCalendarAPIexampleSearchContainer()
00026 {
00027 }
00028
00029
00030 CCalendarAPIexampleSearchContainer* CCalendarAPIexampleSearchContainer::NewL(const TRect& aRect,
00031 CCalendarAPIexampleSearchView& aView)
00032 {
00033 CCalendarAPIexampleSearchContainer* self = new (ELeave) CCalendarAPIexampleSearchContainer(aView);
00034 CleanupStack::PushL(self);
00035 self->ConstructL(aRect);
00036 CleanupStack::Pop(self);
00037 return self;
00038 }
00039
00040
00041 void CCalendarAPIexampleSearchContainer::ConstructL(const TRect& aRect)
00042 {
00043 CreateWindowL();
00044
00045
00046 InitComponentArrayL();
00047
00048 iSearchListBox = new (ELeave) CAknSingleStyleListBox;
00049 iSearchListBox->SetContainerWindowL(*this);
00050
00051 TResourceReader reader;
00052 CEikonEnv::Static()->CreateResourceReaderLC(reader, R_CALENDARAPIEXAMPLE_SEARCH_LIST);
00053 iSearchListBox->ConstructFromResourceL(reader);
00054 CleanupStack::PopAndDestroy();
00055
00056 iSearchListBox->SetListBoxObserver(this);
00057 iSearchListBox->CreateScrollBarFrameL(ETrue);
00058 iSearchListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
00059 CEikScrollBarFrame::EAuto);
00060
00061 Components().AppendLC(iSearchListBox,1);
00062 CleanupStack::Pop( iSearchListBox );
00063
00064 SetRect(aRect);
00065 ActivateL();
00066 }
00067
00068
00069
00070
00071
00072
00073
00074 void CCalendarAPIexampleSearchContainer::SizeChanged()
00075 {
00076 if (iSearchListBox)
00077 {
00078 iSearchListBox->SetRect(Rect());
00079 }
00080 }
00081
00082 void CCalendarAPIexampleSearchContainer::HandleResourceChange(TInt aType)
00083 {
00084 CCoeControl::HandleResourceChange(aType);
00085 if ( aType==KEikDynamicLayoutVariantSwitch )
00086 {
00087 TRect rect;
00088 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
00089 SetRect(rect);
00090 }
00091 }
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 TKeyResponse CCalendarAPIexampleSearchContainer::OfferKeyEventL(
00103 const TKeyEvent& aKeyEvent,TEventCode aType)
00104 {
00105 if(aType != EEventKey)
00106 {
00107 return EKeyWasNotConsumed;
00108 }
00109 else if(iSearchListBox)
00110 {
00111 return iSearchListBox->OfferKeyEventL( aKeyEvent, aType );
00112 }
00113 else
00114 {
00115 return EKeyWasNotConsumed;
00116 }
00117 }
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 void CCalendarAPIexampleSearchContainer::Draw(const TRect& aRect) const
00128 {
00129
00130 CWindowGc& gc = SystemGc();
00131 gc.SetPenStyle( CGraphicsContext::ENullPen );
00132 gc.SetBrushColor( KRgbWhite );
00133 gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
00134 gc.DrawRect( aRect );
00135
00136 }
00137
00138
00139
00140
00141
00142
00143 TSearchType CCalendarAPIexampleSearchContainer::SearchType() const
00144 {
00145 switch (iSearchListBox->CurrentItemIndex())
00146 {
00147 case 0:
00148 return EWeek;
00149 case 1:
00150 return EMonth;
00151 case 2:
00152 return ESixMonths;
00153 case 3:
00154 return EYear;
00155 default:
00156 Panic(EUnSupportedSearchType);
00157 break;
00158 }
00159 return EWeek;
00160 }
00161
00162
00163
00164
00165
00166
00167
00168 void CCalendarAPIexampleSearchContainer::HandleListBoxEventL(CEikListBox* , TListBoxEvent aEventType)
00169 {
00170 if (aEventType == EEventEnterKeyPressed || aEventType == EEventItemSingleClicked)
00171 {
00172 iSearchView.HandleCommandL(ECalendarAPIexampleCmdSearch);
00173 }
00174 }
00175
00176
00177