locationlandmarksrefappfors60/Src/LandmarksContainerBase.cpp
branchRCL_3
changeset 18 870918037e16
parent 0 522cd55cc3d7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/locationlandmarksrefappfors60/Src/LandmarksContainerBase.cpp	Wed Sep 01 12:31:27 2010 +0100
@@ -0,0 +1,171 @@
+/*
+* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*       Implements the CLandmarksContainerBase class
+*
+*/
+
+
+
+#include <aknsfld.h>
+#include <aknview.h>
+#include <eiklbx.h>
+
+#include <EPos_Landmarks.h>
+
+#include "LandmarksContainerBase.h"
+#include "LandmarksListbox.h"
+#include "LandmarksListBoxModel.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+CLandmarksContainerBase::CLandmarksContainerBase(
+    CAknView& aView,
+    CLandmarksApplicationEngine& aEngine)
+:   iView(aView), iEngine(aEngine)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void CLandmarksContainerBase::ConstructL(const TRect& aRect)
+    {
+    CreateWindowL();
+
+    CreateListBoxL();
+    CreateFindBoxL();
+
+    SetRect(aRect);
+    ActivateL();
+    }
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+CLandmarksContainerBase::~CLandmarksContainerBase()
+    {
+    delete iListBox;
+    delete iFindBox;
+    delete iOldFilter;
+    }
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+TBool CLandmarksContainerBase::IsItemSelected()
+    {
+    return (iListBox->CurrentItemIndex() >= 0);
+    }
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+TInt CLandmarksContainerBase::CountComponentControls() const
+    {
+    TInt count = 0;
+    if (iListBox)
+        {
+        count++;
+        }
+    if (iFindBox)
+        {
+        count++;
+        }
+
+    return count; // Return the number of controls inside this container.
+    }
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+CCoeControl* CLandmarksContainerBase::ComponentControl(TInt aIndex) const
+    {
+    switch (aIndex)
+        {
+        case 0:
+            return iListBox; // Returns the pointer to listbox object.
+        case 1:
+            return iFindBox; // Returns the pointer to findbox object.
+        default:
+            return NULL; // Exception : Returns NULL.
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void CLandmarksContainerBase::CreateFindBoxL()
+    {
+    // Sets style of findbox.
+    CAknSearchField::TSearchFieldStyle style(CAknSearchField::ESearch);
+
+    // Creates FindBox.
+    CGulIcon* defaultIcon = NULL;
+    iFindBox = CAknSearchField::NewL(
+        *this, style, defaultIcon, KPosLmMaxTextFieldLength);
+
+    // Creates a filter (CAknListBoxFilterItems instance). This filter is not 
+    // used in this app but the CAknSearchField class MUST have a filter 
+    // anyway. The filter is bypassed by the CLandmarksListBoxModel class.
+    iListBox->Model()->CreateFilterL(iListBox, iFindBox);
+
+    // Initialize filter buffer
+    iOldFilter = HBufC::NewL(0);
+    }
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void CLandmarksContainerBase::CreateListBoxL()
+    {
+    // Create a control to display a list of descriptors
+    iListBox = new (ELeave) CLandmarksListBox();
+    iListBox->SetContainerWindowL(*this);
+    iListBox->ConstructL(this, CEikListBox::ELoopScrolling | EAknListBoxMarkableList );
+
+    // Create scrollbars
+    CEikScrollBarFrame* scrollBar = iListBox->CreateScrollBarFrameL(ETrue);
+    scrollBar->SetScrollBarVisibilityL(
+		CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
+    }
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void CLandmarksContainerBase::SizeChanged()
+    {
+	// Set list box size.
+	iListBox->SetRect( Rect() );
+
+    // Set find box size.
+    AknFind::HandleFixedFindSizeChanged( this, iListBox, iFindBox );
+    }
+    
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//
+void CLandmarksContainerBase::HandleResourceChange(TInt aType)
+    {
+    CCoeControl::HandleResourceChange( aType );
+    if ( aType == KEikDynamicLayoutVariantSwitch )
+        {
+        SetRect( iView.ClientRect() );
+        }
+    }
+
+