|
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: flowlayoutmanager implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <alf/alfexceptions.h> |
|
20 #include <alf/alfwidgetcontrol.h> |
|
21 #include <alf/alfflowlayoutmanager.h> |
|
22 #include <osn/ustring.h> |
|
23 #include <osn/osnnew.h> |
|
24 |
|
25 #include "alfflowlayoutpolicyimpl.h" |
|
26 #include "alfflowlayoutpreferencesimpl.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 AlfFlowLayoutManager::AlfFlowLayoutManager() |
|
42 : AlfLayoutManager(EAlfLayoutTypeFlow) |
|
43 { |
|
44 mData.reset(new (EMM) AlfFlowLayoutPolicyImpl(*this)); |
|
45 mPrefImpl.reset(new (EMM) AlfFlowLayoutPreferencesImpl(*this)); |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // virtual destructor |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 OSN_EXPORT AlfFlowLayoutManager::~AlfFlowLayoutManager() |
|
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 AlfFlowLayoutManager::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 //for aControl both the size and position might have changes. |
|
72 //Only the position changes for all the controls after aControl. |
|
73 |
|
74 //set the size and postion for aControl |
|
75 TAlfRealRect rect; |
|
76 if (controlRect(*aControl, rect)) //returns the real rect (of the root visual) |
|
77 { |
|
78 setControlRect(*aControl, rect); |
|
79 } |
|
80 |
|
81 //update the position for controls after aControl in layout. |
|
82 const int childrenCount = count(); |
|
83 bool childControlFound = false; |
|
84 |
|
85 for (int i = 0; i < childrenCount; i++) |
|
86 { |
|
87 CAlfWidgetControl* child = getControl(i); |
|
88 |
|
89 if (childControlFound && controlRect(*child, rect)) |
|
90 { |
|
91 setControlPosition(*child, rect.iTl); |
|
92 } |
|
93 else if (child == aControl) |
|
94 { |
|
95 childControlFound = true; |
|
96 } |
|
97 } |
|
98 |
|
99 // Inform parent layout manager about the changed presentation size |
|
100 owner().updateParentLayout(); |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // From class IAlfInterfaceBase. |
|
105 // Getter for interfaces provided by the element. |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 OSN_EXPORT IAlfInterfaceBase* AlfFlowLayoutManager::makeInterface( |
|
109 const IfId& aType ) |
|
110 { |
|
111 UString param(aType.mImplementationId); |
|
112 IAlfInterfaceBase* ret = 0; |
|
113 |
|
114 ret = mData->makeInterface(aType); |
|
115 if (!ret) |
|
116 { |
|
117 ret = mPrefImpl->makeInterface(aType); |
|
118 } |
|
119 if (!ret) |
|
120 { |
|
121 ret = AlfLayoutManager::makeInterface(aType); |
|
122 } |
|
123 |
|
124 return ret; |
|
125 } |
|
126 |
|
127 } // Alf |
|
128 |