|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : LandmarksContainerBase.cpp 00004 * Part of : Landmark Reference Application 00005 * Interface : - 00006 * Description : Implements the CLandmarksContainerBase class 00007 * Version : 1.0 00008 * 00009 * Copyright (c) 2004-2006 Nokia Corporation. 00010 * This material, including documentation and any related 00011 * computer programs, is protected by copyright controlled by 00012 * Nokia Corporation. 00013 * ============================================================================== 00014 */ 00015 00016 // INCLUDE FILES 00017 #include <aknsfld.h> 00018 #include <aknview.h> 00019 #include <eiklbx.h> 00020 00021 #include <EPos_Landmarks.h> 00022 00023 #include "LandmarksContainerBase.h" 00024 #include "LandmarksListBox.h" 00025 #include "LandmarksListBoxModel.h" 00026 00027 // ============================ MEMBER FUNCTIONS =============================== 00028 00029 // ----------------------------------------------------------------------------- 00030 // CLandmarksCategoriesView::CLandmarksCategoriesView 00031 // C++ constructor can NOT contain any code, that 00032 // might leave. 00033 // ----------------------------------------------------------------------------- 00034 // 00035 CLandmarksContainerBase::CLandmarksContainerBase( 00036 CAknView& aView, 00037 CLandmarksApplicationEngine& aEngine) 00038 : iView(aView), iEngine(aEngine) 00039 { 00040 } 00041 00042 // ----------------------------------------------------------------------------- 00043 // CLandmarksCategoriesView::ConstructL 00044 // Symbian 2nd phase constructor can leave. 00045 // ----------------------------------------------------------------------------- 00046 // 00047 void CLandmarksContainerBase::ConstructL(const TRect& aRect) 00048 { 00049 CreateWindowL(); 00050 00051 CreateListBoxL(); 00052 CreateFindBoxL(); 00053 00054 SetRect(aRect); 00055 ActivateL(); 00056 } 00057 00058 // Destructor 00059 CLandmarksContainerBase::~CLandmarksContainerBase() 00060 { 00061 delete iListBox; 00062 delete iFindBox; 00063 delete iOldFilter; 00064 } 00065 00066 // ----------------------------------------------------------------------------- 00067 // CLandmarksContainerBase::IsItemSelected 00068 // 00069 // (other items were commented in a header). 00070 // ----------------------------------------------------------------------------- 00071 // 00072 TBool CLandmarksContainerBase::IsItemSelected() 00073 { 00074 return (iListBox->CurrentItemIndex() >= 0); 00075 } 00076 00077 // ----------------------------------------------------------------------------- 00078 // CLandmarksContainerBase::CountComponentControls 00079 // 00080 // (other items were commented in a header). 00081 // ----------------------------------------------------------------------------- 00082 // 00083 TInt CLandmarksContainerBase::CountComponentControls() const 00084 { 00085 TInt count = 0; 00086 if (iListBox) 00087 { 00088 count++; 00089 } 00090 if (iFindBox) 00091 { 00092 count++; 00093 } 00094 00095 return count; // Return the number of controls inside this container. 00096 } 00097 00098 // ----------------------------------------------------------------------------- 00099 // CLandmarksContainerBase::ComponentControl 00100 // 00101 // (other items were commented in a header). 00102 // ----------------------------------------------------------------------------- 00103 // 00104 CCoeControl* CLandmarksContainerBase::ComponentControl(TInt aIndex) const 00105 { 00106 switch (aIndex) 00107 { 00108 case 0: 00109 return iListBox; // Returns the pointer to listbox object. 00110 case 1: 00111 return iFindBox; // Returns the pointer to findbox object. 00112 default: 00113 return NULL; // Exception : Returns NULL. 00114 } 00115 } 00116 00117 // ----------------------------------------------------------------------------- 00118 // CLandmarksContainerBase::CreateFindBoxL 00119 // 00120 // (other items were commented in a header). 00121 // ----------------------------------------------------------------------------- 00122 // 00123 void CLandmarksContainerBase::CreateFindBoxL() 00124 { 00125 // Sets style of findbox. 00126 CAknSearchField::TSearchFieldStyle style(CAknSearchField::ESearch); 00127 00128 // Creates FindBox. 00129 CGulIcon* defaultIcon = NULL; 00130 iFindBox = CAknSearchField::NewL( 00131 *this, style, defaultIcon, KPosLmMaxTextFieldLength); 00132 00133 // Creates a filter (CAknListBoxFilterItems instance). This filter is not 00134 // used in this app but the CAknSearchField class MUST have a filter 00135 // anyway. The filter is bypassed by the CLandmarksListBoxModel class. 00136 iListBox->Model()->CreateFilterL(iListBox, iFindBox); 00137 00138 // Initialize filter buffer 00139 iOldFilter = HBufC::NewL(0); 00140 } 00141 00142 // ----------------------------------------------------------------------------- 00143 // CLandmarksContainerBase::CreateListBoxL 00144 // 00145 // (other items were commented in a header). 00146 // ----------------------------------------------------------------------------- 00147 // 00148 void CLandmarksContainerBase::CreateListBoxL() 00149 { 00150 // Create a control to display a list of descriptors 00151 iListBox = new (ELeave) CLandmarksListBox(); 00152 iListBox->SetContainerWindowL(*this); 00153 iListBox->ConstructL(this, CEikListBox::ELoopScrolling); 00154 00155 // Create scrollbars 00156 CEikScrollBarFrame* scrollBar = iListBox->CreateScrollBarFrameL(ETrue); 00157 scrollBar->SetScrollBarVisibilityL( 00158 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); 00159 } 00160 00161 // ----------------------------------------------------------------------------- 00162 // CLandmarksContainerBase::SizeChanged 00163 // 00164 // (other items were commented in a header). 00165 // ----------------------------------------------------------------------------- 00166 // 00167 void CLandmarksContainerBase::SizeChanged() 00168 { 00169 // Set list box size. 00170 //iListBox->SetRect(Rect()); 00171 iListBox->SizeChanged(); 00172 00173 // Set find box size. 00174 AknFind::HandleFixedFindSizeChanged(this, iListBox, iFindBox); 00175 } 00176 00177 // ----------------------------------------------------------------------------- 00178 // CLandmarksContainerBase::HandleResourceChange 00179 // 00180 // (other items were commented in a header). 00181 // ----------------------------------------------------------------------------- 00182 // 00183 void CLandmarksContainerBase::HandleResourceChange(TInt aType) 00184 { 00185 CCoeControl::HandleResourceChange(aType); 00186 if ( aType == KEikDynamicLayoutVariantSwitch ) 00187 { 00188 SetRect(iView.ClientRect()); 00189 } 00190 } 00191 00192 // End of File 00193
|
© Nokia 2006 |