landmarksui/app/src/CLmkLbWithFilterContainer.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2002-2010 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:   This file contains methods for implementing container with
       
    15 *				 find/searchbox
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include <aknlists.h>
       
    22 #include <aknsfld.h>
       
    23 #include <AknsBasicBackgroundControlContext.h>
       
    24 #include "CLmkDocument.h"
       
    25 #include "landmarks.hrh"
       
    26 #include "CLmkAppUi.h"
       
    27 #include "CLmkAppSelectorImplBase.h"
       
    28 #include "CLmkLbWithFilterContainer.h"
       
    29 #include <lmkerrors.h>
       
    30 #include "Debug.h"
       
    31 
       
    32 // CONSTANTS
       
    33 namespace {
       
    34 #if defined(_DEBUG)
       
    35 _LIT( KPanicText, "CLmkLbWithFilterContainer" );
       
    36 
       
    37 void Panic( TPanicCode aReason )
       
    38     {
       
    39     User::Panic( KPanicText, aReason );
       
    40     }
       
    41 #endif
       
    42 }  // namespace
       
    43 // ================= MEMBER FUNCTIONS =======================
       
    44 
       
    45 // ----------------------------------------------------------------------------
       
    46 // CLmkLbWithFilterContainer::CLmkBaseContainer
       
    47 // ----------------------------------------------------------------------------
       
    48 //
       
    49 CLmkLbWithFilterContainer::CLmkLbWithFilterContainer(
       
    50     MLmkKeyProcessor& aKeyProcessor,
       
    51     const TDesC& aHelpContext )
       
    52     :CLmkBaseContainer( aKeyProcessor, aHelpContext )
       
    53     {
       
    54     }
       
    55 
       
    56 // ----------------------------------------------------------------------------
       
    57 // CLmkLbWithFilterContainer::ConstructL
       
    58 // Symbian 2nd phase constructor can leave.
       
    59 // ----------------------------------------------------------------------------
       
    60 //
       
    61 void CLmkLbWithFilterContainer::ConstructL( const TRect& aRect )
       
    62     {
       
    63     CLmkBaseContainer::BaseConstructL();
       
    64     CreateWindowL();
       
    65 
       
    66     // Get the skin instance
       
    67 	iSkinInstance = AknsUtils::SkinInstance();
       
    68 
       
    69 	// Create background control context for skinning the background
       
    70 	iBackgroundSkinContext = CAknsBasicBackgroundControlContext::NewL(
       
    71 			KAknsIIDQsnBgAreaMain, aRect, ETrue );
       
    72 
       
    73     iIsNeedToReDraw = ETrue;
       
    74 
       
    75     CLmkAppUi* lmkAppUi = static_cast<CLmkAppUi*>( ViewAppUi() );
       
    76     CPosLandmarkDatabase& db = lmkAppUi->Document().LmDbL();
       
    77     CLmkSender& sender = lmkAppUi->LmkSender();
       
    78     SetupSelectorAndListL( db, sender );
       
    79 
       
    80     SetupTitlePaneL();
       
    81     SetupNaviPaneL();
       
    82     SetupFindBoxL();
       
    83 
       
    84     // enable scroll arrows
       
    85     CEikScrollBarFrame* sBFrame = iListBox->CreateScrollBarFrameL( ETrue );
       
    86     sBFrame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOn,
       
    87                                       CEikScrollBarFrame::EAuto );
       
    88 
       
    89     SetRect( aRect );
       
    90     ActivateL();
       
    91     }
       
    92 
       
    93 // ----------------------------------------------------------------------------
       
    94 // CLmkLbWithFilterContainer::~CLmkLbWithFilterContainer
       
    95 // ----------------------------------------------------------------------------
       
    96 //
       
    97 CLmkLbWithFilterContainer::~CLmkLbWithFilterContainer()
       
    98     {
       
    99     delete iNaviDeco;
       
   100     delete iFindBox;
       
   101     delete iBackgroundSkinContext;
       
   102     }
       
   103 // ----------------------------------------------------------------------------
       
   104 // CLmkLbWithFilterContainer::ListBox()
       
   105 // ----------------------------------------------------------------------------
       
   106 //
       
   107 CEikTextListBox& CLmkLbWithFilterContainer::ListBox()
       
   108     {
       
   109     __ASSERT_DEBUG( iListBox, Panic( KLmkPanicNullMember ) );
       
   110     return *iListBox;
       
   111     }
       
   112 
       
   113 // ----------------------------------------------------------------------------
       
   114 // CLmkLbWithFilterContainer::OfferKeyEventL
       
   115 // ----------------------------------------------------------------------------
       
   116 //
       
   117 TKeyResponse CLmkLbWithFilterContainer::OfferKeyEventL(
       
   118                                      const TKeyEvent& aKeyEvent,
       
   119                                      TEventCode aType )
       
   120     {
       
   121     DEBUG( CLmkLbWithFilterContainer::OfferKeyEventL start );
       
   122     TKeyResponse result( EKeyWasNotConsumed );
       
   123     if ( ( aType == EEventKey || aType == EEventKeyUp) )
       
   124         {
       
   125         if(( iFindBox->TextLength() > 0 ||
       
   126              aKeyEvent.iCode != EKeyBackspace ) && iFindBox->IsVisible())
       
   127             {
       
   128 			result = iFindBox->OfferKeyEventL(aKeyEvent, aType);
       
   129             }
       
   130         else if( aKeyEvent.iCode == EKeyBackspace )
       
   131             {
       
   132 			CLmkAppSelectorImplBase& selector = SelectorImpl();
       
   133 			TInt markedCount( selector.ListMarkedItemCountL() );
       
   134 			
       
   135 			DEBUG1( CLmkLbWithFilterContainer::OfferKeyEventL markedCount = %d,markedCount);
       
   136 			CEikMenuBar* menuBar = MenuBar();
       
   137 			if( menuBar )
       
   138 			    {
       
   139                 if( MenuBar()->ItemSpecificCommandsEnabled())
       
   140                     {
       
   141                     return EKeyWasConsumed;
       
   142                     }			
       
   143 			    }
       
   144 			if(  markedCount <= 0)
       
   145 			    {
       
   146                 return EKeyWasConsumed;
       
   147 			    }
       
   148 			selector.ProcessCommandL( ELmkCmdDeleteLm );
       
   149             return EKeyWasConsumed;
       
   150             }
       
   151         }
       
   152     if ( result == EKeyWasNotConsumed )
       
   153         {
       
   154 	    result = CLmkBaseContainer::OfferKeyEventL( aKeyEvent, aType );
       
   155 	    if(  aKeyEvent.iScanCode == EStdKeyHash )
       
   156 	        {
       
   157 	        UpdateMskContainerL();
       
   158 	        }
       
   159         }
       
   160     DEBUG1( CLmkLbWithFilterContainer::OfferKeyEventL End result=%d,result );
       
   161     return result;
       
   162     }
       
   163 
       
   164 // ----------------------------------------------------------------------------
       
   165 // CLmkLbWithFilterContainer::SizeChanged()
       
   166 // Called by framework when the view size is changed
       
   167 // ----------------------------------------------------------------------------
       
   168 //
       
   169 void CLmkLbWithFilterContainer::SizeChanged()
       
   170     {
       
   171     __ASSERT_DEBUG( iListBox, Panic( KLmkPanicNullMember ) );
       
   172 	const TRect rect(Rect());
       
   173 
       
   174     AknFind::HandleFixedFindSizeChanged(
       
   175         this,
       
   176         static_cast<CAknColumnListBox*>( iListBox ),
       
   177         iFindBox );
       
   178 
       
   179 	if (iListBox && iFindBox && iFindBox->IsVisible())
       
   180 		{
       
   181 		AknLayoutUtils::LayoutControl(iListBox, rect,
       
   182 		AKN_LAYOUT_WINDOW_list_gen_pane(1));
       
   183 		AknLayoutUtils::LayoutControl(iFindBox, rect,
       
   184 		AKN_LAYOUT_WINDOW_find_pane);
       
   185 		if (iFindBox->IsVisible() && iListBox->IsVisible())
       
   186 			{
       
   187 			// The correct line position to use is 2, which corresponds
       
   188 			// EABColumn in Avkon (not a public enumeration,
       
   189 			// hence hard-coding used here)
       
   190 			const TInt KSeparatorLinePos = 2;
       
   191 			iFindBox->SetLinePos(KSeparatorLinePos);
       
   192 			}
       
   193 		}
       
   194 	else if (iListBox)
       
   195 		{
       
   196 		AknLayoutUtils::LayoutControl(iListBox, rect,
       
   197 		AKN_LAYOUT_WINDOW_list_gen_pane(0));
       
   198 		}
       
   199 	if (iListBox)
       
   200 		{
       
   201 		STATIC_CAST(CAknFilteredTextListBoxModel*,iListBox->Model())->Filter()->SetParentControl(this);
       
   202 		}
       
   203 	SelectorImpl().HandleScreenSizeChange();
       
   204     }
       
   205 
       
   206 // ----------------------------------------------------------------------------
       
   207 // CLmkLbWithFilterContainer::CountComponentControls
       
   208 // ----------------------------------------------------------------------------
       
   209 //
       
   210 TInt CLmkLbWithFilterContainer::CountComponentControls() const
       
   211     {
       
   212     return 2; // return nbr of controls inside this container
       
   213     }
       
   214 
       
   215 // ----------------------------------------------------------------------------
       
   216 // CLmkLbWithFilterContainer::ComponentControl
       
   217 // ----------------------------------------------------------------------------
       
   218 //
       
   219 CCoeControl* CLmkLbWithFilterContainer::ComponentControl( TInt aIndex ) const
       
   220     {
       
   221     switch ( aIndex )
       
   222         {
       
   223         case 0:
       
   224             {
       
   225             return iListBox;
       
   226             }
       
   227         case 1:
       
   228             {
       
   229             return iFindBox;
       
   230             }
       
   231         default:
       
   232             {
       
   233             return NULL;
       
   234             }
       
   235         }
       
   236     }
       
   237 
       
   238 // ----------------------------------------------------------------------------
       
   239 // CLmkLbWithFilterContainer::SetupFindBoxL
       
   240 // ----------------------------------------------------------------------------
       
   241 //
       
   242 void CLmkLbWithFilterContainer::SetupFindBoxL()
       
   243 	{
       
   244 	iFindBox = SelectorImpl().CreateFindBoxL(*this);
       
   245 	}
       
   246 
       
   247 
       
   248 // ---------------------------------------------------------
       
   249 // CLmkLbWithFilterContainer::Draw(const TRect& aRect) const
       
   250 // ---------------------------------------------------------
       
   251 //
       
   252 void CLmkLbWithFilterContainer::Draw(const TRect& /*aRect*/) const
       
   253     {
       
   254     if(iIsNeedToReDraw)
       
   255         {
       
   256         CWindowGc& gc = SystemGc();
       
   257 
       
   258         AknsDrawUtils::Background( iSkinInstance,
       
   259             iBackgroundSkinContext, this, gc, Rect() );
       
   260 
       
   261         iIsNeedToReDraw = EFalse;
       
   262         }
       
   263     }
       
   264 
       
   265 #ifdef RD_SCALABLE_UI_V2
       
   266 // ---------------------------------------------------------
       
   267 // CLmkLbWithFilterContainer::SetListBoxObserver
       
   268 // ---------------------------------------------------------
       
   269 //
       
   270 void CLmkLbWithFilterContainer::SetListBoxObserver(MEikListBoxObserver* aObserver)
       
   271 	{
       
   272 	__ASSERT_DEBUG( aObserver, Panic( KLmkPanicNullMember ) );
       
   273 	iListBox->SetListBoxObserver(aObserver);
       
   274 	}
       
   275 #endif//RD_SCALABLE_UI_V2
       
   276 
       
   277 // ----------------------------------------------------------------------------
       
   278 // CLmkLbWithFilterContainer::UpdateMskContainerForFilterL()
       
   279 // ----------------------------------------------------------------------------
       
   280 //
       
   281 void CLmkLbWithFilterContainer::UpdateMskContainerForFilterL()
       
   282 	{
       
   283 	iSearchInitiated = ETrue;
       
   284 	UpdateMskContainerL();
       
   285 	iSearchInitiated = EFalse;
       
   286 	}
       
   287 // End of File