widgetmodel/alfwidgetmodel/src/alfgridlayoutmanager.cpp
changeset 17 3eca7e70b1b8
parent 3 4526337fb576
equal deleted inserted replaced
3:4526337fb576 17:3eca7e70b1b8
     1 /*
       
     2 * Copyright (c) 2007 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:  gridlayoutmanager with focus handling in 1D (next/previous)
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <alf/alfgridlayoutmanager.h>
       
    20 #include <alf/alfexceptions.h>
       
    21 #include <alf/alfwidgetcontrol.h>
       
    22 #include <osn/ustring.h>
       
    23 #include <osn/osnnew.h>
       
    24 
       
    25 #include "alfgridlayoutmanagerimpl.h"
       
    26 #include "alfgridlayoutpolicyimpl.h"
       
    27 
       
    28 using osncore::UString;
       
    29 
       
    30 using namespace Alf;
       
    31 
       
    32 namespace Alf
       
    33     {
       
    34 
       
    35 // ======== MEMBER FUNCTIONS ========
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // layout manager constructor
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 OSN_EXPORT AlfGridLayoutManager::AlfGridLayoutManager() 
       
    42     : AlfLayoutManager(EAlfLayoutTypeGrid)
       
    43     {
       
    44     mData.reset(new (EMM) AlfGridLayoutManagerImpl(*this));
       
    45     mDataPolicy.reset(new (EMM) AlfGridLayoutPolicyImpl(*this));
       
    46     }
       
    47         
       
    48 // ---------------------------------------------------------------------------
       
    49 // virtual destructor
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 OSN_EXPORT AlfGridLayoutManager::~AlfGridLayoutManager()
       
    53     {
       
    54     }
       
    55     
       
    56 // ---------------------------------------------------------------------------
       
    57 // from AlfLayoutManager
       
    58 // notifies the layout manager, that the child control's layout
       
    59 // must be updated.
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 OSN_EXPORT void AlfGridLayoutManager::updateChildLayout(
       
    63     CAlfWidgetControl* aControl)
       
    64     {
       
    65     CAlfLayout& layout = getLayout();
       
    66     doUpdateChildLayout(aControl);
       
    67     layout.UpdateChildrenLayout();
       
    68 
       
    69     //doUpdateChildLayout changes the visual size and position.
       
    70     //need to notify the widget that size and position has changed.
       
    71     
       
    72     //set the size and postion for aControl
       
    73     TAlfRealRect rect;
       
    74     if (controlRect(*aControl, rect)) //returns the real rect (of the root visual)
       
    75         {
       
    76         setControlRect(*aControl, rect);
       
    77         }
       
    78 
       
    79     // Inform parent layout manager about the changed presentation size
       
    80     owner().updateParentLayout();
       
    81     }
       
    82         
       
    83 // ---------------------------------------------------------------------------
       
    84 // from IAlfLayoutManager
       
    85 // notifies the layout manager, that the control's has been
       
    86 // removed from the layout.
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 OSN_EXPORT void AlfGridLayoutManager::childRemoved(CAlfWidgetControl* aControl)
       
    90     {
       
    91     //when control is removed from layout, no change to other widget rects,
       
    92     // just call the base class
       
    93     AlfLayoutManager::childRemoved(aControl);
       
    94     }
       
    95     
       
    96 // ---------------------------------------------------------------------------
       
    97 // from AlfLayoutManager
       
    98 // notifies the layout manager, that the child control's layout
       
    99 // must be updated.
       
   100 // ---------------------------------------------------------------------------
       
   101 //    
       
   102 OSN_EXPORT void AlfGridLayoutManager::doUpdateChildLayout(
       
   103     CAlfWidgetControl* /*aControl*/)
       
   104     {
       
   105     //gridlayout changes the position and size, nothing to do here.
       
   106     }
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 // From class IAlfInterfaceBase.
       
   110 // Getter for interfaces provided by the element.
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 OSN_EXPORT IAlfInterfaceBase* AlfGridLayoutManager::makeInterface( 
       
   114     const IfId& aType )
       
   115     {
       
   116     UString param(aType.mImplementationId);
       
   117     if (param == IAlfLayoutManager::type().mImplementationId)
       
   118         {
       
   119         return this;
       
   120         }      
       
   121 
       
   122     // Let the implementation class try the interface creation
       
   123     IAlfInterfaceBase* pInterface = mData->makeInterface(aType);
       
   124     if(!pInterface)
       
   125         pInterface = mDataPolicy->makeInterface(aType);
       
   126     return pInterface;
       
   127     }
       
   128  } // Alf