uiacceltk/hitchcock/coretoolkit/src/HuiDeckLayout.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006-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:   Implementation for CHuiDeckLayout. Deck layout is a very simple layout
       
    15 *                that overlays all its children to match the layout's own rectangle.
       
    16 *                Think of it as a deck of cards.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 #include "uiacceltk/HuiDeckLayout.h"  // Class definition
       
    23 #include "uiacceltk/HuiControl.h"
       
    24 #include "uiacceltk/HuiPanic.h"
       
    25 
       
    26 
       
    27 EXPORT_C CHuiDeckLayout* CHuiDeckLayout::AddNewL(CHuiControl& aOwnerControl,
       
    28                                                  CHuiLayout* aParentLayout)
       
    29     {
       
    30     CHuiDeckLayout* layout = new (ELeave) CHuiDeckLayout(aOwnerControl);
       
    31     CleanupStack::PushL(layout);
       
    32     layout->ConstructL();    
       
    33     aOwnerControl.AppendL(layout, aParentLayout);
       
    34     CleanupStack::Pop(layout);           
       
    35     return layout;
       
    36     }
       
    37 
       
    38 
       
    39 CHuiDeckLayout::CHuiDeckLayout(MHuiVisualOwner& aOwner)
       
    40         : CHuiLayout(aOwner)
       
    41     {
       
    42     }
       
    43 
       
    44 
       
    45 void CHuiDeckLayout::ConstructL()
       
    46     {    
       
    47     CHuiLayout::ConstructL();
       
    48     }
       
    49 
       
    50     
       
    51 EXPORT_C CHuiDeckLayout::~CHuiDeckLayout()
       
    52     {    
       
    53     }
       
    54 
       
    55 
       
    56 void CHuiDeckLayout::SetSize(const THuiRealSize& aSize, TInt aTransitionTime)
       
    57     {
       
    58     CHuiLayout::SetSize(aSize, aTransitionTime);
       
    59     UpdateChildrenLayout(aTransitionTime);    
       
    60     }
       
    61 
       
    62 TBool CHuiDeckLayout::ChildSize(TInt aOrdinal, TSize& aSize)
       
    63     {
       
    64     TBool result(EFalse);
       
    65     THuiRealRect rect;
       
    66     TInt childRectStatus(THuiLayoutChildRectUpdateNotNeeded);
       
    67     childRectStatus = ChildRect(aOrdinal, rect);
       
    68     if(childRectStatus != THuiLayoutChildRectNotImplemented)
       
    69         {
       
    70         result = (childRectStatus & THuiLayoutChildRectSizeUpdateNeeded);
       
    71         if(result)
       
    72             {
       
    73             THuiRealPoint size(rect.Width(), rect.Height());
       
    74             aSize = LocalPointInPixels(size).AsSize();
       
    75             }
       
    76         }
       
    77     return result;
       
    78     }
       
    79 
       
    80 TBool CHuiDeckLayout::ChildPos(TInt aOrdinal, TPoint& aPos)
       
    81     {
       
    82     TBool result(EFalse);
       
    83     THuiRealRect rect;
       
    84     TInt childRectStatus(THuiLayoutChildRectUpdateNotNeeded);
       
    85     childRectStatus = ChildRect(aOrdinal, rect);
       
    86     if(childRectStatus != THuiLayoutChildRectNotImplemented)
       
    87         {
       
    88         result = (childRectStatus & THuiLayoutChildRectPosUpdateNeeded);
       
    89         if(result)
       
    90             {
       
    91             aPos = LocalPointInPixels(rect.iTl);
       
    92             }
       
    93         }
       
    94     return result;
       
    95     }
       
    96 
       
    97 TInt CHuiDeckLayout::ChildRect(TInt /*aOrdinal*/, THuiRealRect& aPos)
       
    98     {
       
    99     THuiRealSize innerSize = InnerSize();
       
   100     aPos.iTl = InnerTopLeft(); 
       
   101     aPos.iBr = aPos.iTl + THuiRealPoint(innerSize.iWidth, innerSize.iHeight) ; 
       
   102     return THuiLayoutChildRectLayoutUpdateNeeded;
       
   103     }
       
   104