locationlandmarksrefappfors60/Src/LandmarksContainerBase.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *       Implements the CLandmarksContainerBase class
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #include <aknsfld.h>
       
    22 #include <aknview.h>
       
    23 #include <eiklbx.h>
       
    24 
       
    25 #include <EPos_Landmarks.h>
       
    26 
       
    27 #include "LandmarksContainerBase.h"
       
    28 #include "LandmarksListbox.h"
       
    29 #include "LandmarksListBoxModel.h"
       
    30 
       
    31 // ============================ MEMBER FUNCTIONS ===============================
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CLandmarksContainerBase::CLandmarksContainerBase(
       
    37     CAknView& aView,
       
    38     CLandmarksApplicationEngine& aEngine)
       
    39 :   iView(aView), iEngine(aEngine)
       
    40     {
       
    41     }
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 void CLandmarksContainerBase::ConstructL(const TRect& aRect)
       
    47     {
       
    48     CreateWindowL();
       
    49 
       
    50     CreateListBoxL();
       
    51     CreateFindBoxL();
       
    52 
       
    53     SetRect(aRect);
       
    54     ActivateL();
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 CLandmarksContainerBase::~CLandmarksContainerBase()
       
    61     {
       
    62     delete iListBox;
       
    63     delete iFindBox;
       
    64     delete iOldFilter;
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 TBool CLandmarksContainerBase::IsItemSelected()
       
    71     {
       
    72     return (iListBox->CurrentItemIndex() >= 0);
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 TInt CLandmarksContainerBase::CountComponentControls() const
       
    79     {
       
    80     TInt count = 0;
       
    81     if (iListBox)
       
    82         {
       
    83         count++;
       
    84         }
       
    85     if (iFindBox)
       
    86         {
       
    87         count++;
       
    88         }
       
    89 
       
    90     return count; // Return the number of controls inside this container.
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 CCoeControl* CLandmarksContainerBase::ComponentControl(TInt aIndex) const
       
    97     {
       
    98     switch (aIndex)
       
    99         {
       
   100         case 0:
       
   101             return iListBox; // Returns the pointer to listbox object.
       
   102         case 1:
       
   103             return iFindBox; // Returns the pointer to findbox object.
       
   104         default:
       
   105             return NULL; // Exception : Returns NULL.
       
   106         }
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 void CLandmarksContainerBase::CreateFindBoxL()
       
   113     {
       
   114     // Sets style of findbox.
       
   115     CAknSearchField::TSearchFieldStyle style(CAknSearchField::ESearch);
       
   116 
       
   117     // Creates FindBox.
       
   118     CGulIcon* defaultIcon = NULL;
       
   119     iFindBox = CAknSearchField::NewL(
       
   120         *this, style, defaultIcon, KPosLmMaxTextFieldLength);
       
   121 
       
   122     // Creates a filter (CAknListBoxFilterItems instance). This filter is not 
       
   123     // used in this app but the CAknSearchField class MUST have a filter 
       
   124     // anyway. The filter is bypassed by the CLandmarksListBoxModel class.
       
   125     iListBox->Model()->CreateFilterL(iListBox, iFindBox);
       
   126 
       
   127     // Initialize filter buffer
       
   128     iOldFilter = HBufC::NewL(0);
       
   129     }
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 void CLandmarksContainerBase::CreateListBoxL()
       
   135     {
       
   136     // Create a control to display a list of descriptors
       
   137     iListBox = new (ELeave) CLandmarksListBox();
       
   138     iListBox->SetContainerWindowL(*this);
       
   139     iListBox->ConstructL(this, CEikListBox::ELoopScrolling | EAknListBoxMarkableList );
       
   140 
       
   141     // Create scrollbars
       
   142     CEikScrollBarFrame* scrollBar = iListBox->CreateScrollBarFrameL(ETrue);
       
   143     scrollBar->SetScrollBarVisibilityL(
       
   144 		CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
       
   145     }
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 void CLandmarksContainerBase::SizeChanged()
       
   151     {
       
   152 	// Set list box size.
       
   153 	iListBox->SetRect( Rect() );
       
   154 
       
   155     // Set find box size.
       
   156     AknFind::HandleFixedFindSizeChanged( this, iListBox, iFindBox );
       
   157     }
       
   158     
       
   159 // -----------------------------------------------------------------------------
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 void CLandmarksContainerBase::HandleResourceChange(TInt aType)
       
   163     {
       
   164     CCoeControl::HandleResourceChange( aType );
       
   165     if ( aType == KEikDynamicLayoutVariantSwitch )
       
   166         {
       
   167         SetRect( iView.ClientRect() );
       
   168         }
       
   169     }
       
   170 
       
   171