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: implementation for flowlayoutpolicy |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <assert.h> |
|
20 #include <alf/alfflowlayout.h> |
|
21 #include <alf/alfflowlayoutmanager.h> |
|
22 #include <osn/ustring.h> |
|
23 #include <osn/osnnew.h> |
|
24 |
|
25 #include "alfflowlayoutpolicyimpl.h" |
|
26 |
|
27 using osncore::UString; |
|
28 |
|
29 using namespace Alf; |
|
30 |
|
31 namespace Alf |
|
32 { |
|
33 |
|
34 typedef enum IAlfFlowLayoutPolicy::flowDirection flowDirection; |
|
35 |
|
36 // ======== MEMBER FUNCTIONS ======== |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // flowlayoutpolicyimpl constructor |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 AlfFlowLayoutPolicyImpl::AlfFlowLayoutPolicyImpl( |
|
43 AlfFlowLayoutManager& aFlowLayoutManager) : |
|
44 mFlowLayoutManager(aFlowLayoutManager), mDirection(EFlowVertical) |
|
45 { |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // creates the layout used by the layoutmanager. |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 AlfFlowLayoutPolicyImpl::~AlfFlowLayoutPolicyImpl() |
|
53 { |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // Sets the direction of the flow. |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 void AlfFlowLayoutPolicyImpl::setFlowDirection(enum flowDirection aDirection) |
|
61 { |
|
62 mDirection = aDirection; |
|
63 |
|
64 CAlfFlowLayout::TFlowDirection flowdir(CAlfFlowLayout::EFlowHorizontal); |
|
65 if (aDirection == EFlowVertical) |
|
66 { |
|
67 flowdir = CAlfFlowLayout::EFlowVertical; |
|
68 } |
|
69 |
|
70 layout().SetFlowDirection(flowdir); |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // returns the flow direction |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 flowDirection AlfFlowLayoutPolicyImpl::flowDirection() const |
|
78 { |
|
79 return mDirection; |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // Sets the mode of the flow. The mode flags determine how the flow layout |
|
84 // behaves. |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void AlfFlowLayoutPolicyImpl::setMode(int aMode) |
|
88 { |
|
89 layout().SetMode(aMode); |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // Returns the mode flags of the flow. |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 int AlfFlowLayoutPolicyImpl::mode() const |
|
97 { |
|
98 return layout().Mode(); |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // From class IAlfInterfaceBase. |
|
103 // Getter for interfaces provided by the element. |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 IAlfInterfaceBase* AlfFlowLayoutPolicyImpl::makeInterface(const IfId& aType) |
|
107 { |
|
108 UString param(aType.mImplementationId); |
|
109 IAlfInterfaceBase* ret = 0; |
|
110 if (param == IAlfFlowLayoutPolicy::type().mImplementationId) |
|
111 { |
|
112 ret = static_cast<IAlfFlowLayoutPolicy*>(this); |
|
113 } |
|
114 |
|
115 return ret; |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // returns the flow layout used by the layoutmanager |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 CAlfFlowLayout& AlfFlowLayoutPolicyImpl::layout() const |
|
123 { |
|
124 return dynamic_cast<CAlfFlowLayout&>(mFlowLayoutManager.getLayout()); |
|
125 } |
|
126 |
|
127 } // Alf |
|