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: layoutpreferences implementation class for flowlayoutmanager |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef ALFFLOWLAYOUTPREFERENCESIMPL_H |
|
20 #define ALFFLOWLAYOUTPREFERENCESIMPL_H |
|
21 |
|
22 #include <osn/osndefines.h> |
|
23 #include <alf/ialflayoutpreferences.h> |
|
24 |
|
25 using namespace Alf; |
|
26 |
|
27 namespace Alf |
|
28 { |
|
29 class AlfFlowLayoutManager; |
|
30 |
|
31 /** |
|
32 * layout preferences implementation for flowlayoutmanager. |
|
33 * |
|
34 * @lib alfwidgetmodel.lib |
|
35 * @since S60 ?S60_version |
|
36 */ |
|
37 class AlfFlowLayoutPreferencesImpl : public IAlfLayoutPreferences |
|
38 { |
|
39 public: |
|
40 AlfFlowLayoutPreferencesImpl(AlfFlowLayoutManager& aFlowLayoutManager); |
|
41 public: |
|
42 // from base class IAlfLayoutPreferences |
|
43 |
|
44 /** |
|
45 * Returns the minimum size of the layout by combining the minimum sizes of the |
|
46 * layed out visuals. |
|
47 * |
|
48 * @param aMinSize The minimum size that the object would like to be laid out to |
|
49 * @return false iff none of the layed out UI elements do not care about minimum size |
|
50 */ |
|
51 virtual bool getMinimumSize( TAlfXYMetric& aMinSize ) const; |
|
52 |
|
53 /** |
|
54 * Returns the maximum size of the layout by combining the maximum sizes of the |
|
55 * layed out visuals. |
|
56 * |
|
57 * @param aMaxSize The maximum size that the object would like to be laid out to |
|
58 * @return false iff none of the layed out UI elements do not care about maximum size |
|
59 */ |
|
60 virtual bool getMaximumSize( TAlfXYMetric& aMaxSize ) const; |
|
61 |
|
62 /** |
|
63 * Returns the size combined by all preferred sizes of child UI elements in this layout |
|
64 * when they are being layed out according to the layout manager rules. |
|
65 * |
|
66 * @param aPreferredSize Filled with the referred area occupied by child elements when |
|
67 * layed out by layouting rules in this layout manager. |
|
68 * @return False if none of the child components report their preferred size. True |
|
69 * otherwise. |
|
70 */ |
|
71 virtual bool getPreferredSize(TAlfXYMetric& aPreferredSize) const; |
|
72 |
|
73 /** |
|
74 * Set the preferred size into a presentation object. |
|
75 * |
|
76 * This is not supported on the layout manager. Users should set preferred sizes of the |
|
77 * contained UI elements. |
|
78 */ |
|
79 virtual void setPreferredSize( const TAlfXYMetric& aPreferredSize ); |
|
80 // from base class IAlfInterfaceBase |
|
81 |
|
82 /** |
|
83 * Interface getter. |
|
84 * @see IAlfInterfaceBase::makeInterface |
|
85 * |
|
86 * @since S60 ?S60_version |
|
87 * @param aType The type id of the queried interface. |
|
88 * @return The queried interface, or NULL if the interface is not |
|
89 * supported or available. |
|
90 */ |
|
91 virtual IAlfInterfaceBase* makeInterface( const IfId& aType ); |
|
92 protected: |
|
93 |
|
94 /** size type to calculate @see calculateChildSizes */ |
|
95 enum sizeType |
|
96 { |
|
97 ESizePreferred, |
|
98 ESizeMin, |
|
99 ESizeMax |
|
100 }; |
|
101 |
|
102 /** |
|
103 * calculate the min-, preferred-, or max- sizes from the children. |
|
104 * |
|
105 * @param aSize on return, contains the calculated size. |
|
106 * @param aFlowDirection direction of flow. |
|
107 * @param aSizeType specifies, whether the min-, preferred- or max-size of the |
|
108 * IAlfLayoutPreferences is used for calculation. |
|
109 */ |
|
110 bool calculateChildSizes(TAlfXYMetric& aSize, |
|
111 enum IAlfFlowLayoutPolicy::flowDirection aFlowDirection, |
|
112 enum sizeType aSizeType) const; |
|
113 |
|
114 /** |
|
115 * fetches the size from the IAlfLayoutPreferences-interface of the aControl. |
|
116 * |
|
117 * @param aControl control, which preferences-interface to query. |
|
118 * @param aSize on return, contains the size. |
|
119 * @param aSizeType specifies, whether the min-, preferred- or max-size of the |
|
120 * IAlfLayoutPreferences is returned. |
|
121 */ |
|
122 bool getSize(CAlfWidgetControl* aControl, |
|
123 TAlfXYMetric& aSize, |
|
124 enum sizeType aSizeType) const; |
|
125 |
|
126 /** |
|
127 * @return the flow layout policy-instance of the layoutmanager. |
|
128 * |
|
129 */ |
|
130 const IAlfFlowLayoutPolicy& flowLayoutPolicy() const; |
|
131 |
|
132 /** |
|
133 * converts size in metrics to size in pixels. Implementation missing. |
|
134 * |
|
135 * @param aSize size to convert |
|
136 * @return size in pixels. |
|
137 */ |
|
138 static TAlfRealSize sizeInPixels(const TAlfXYMetric& aSize); |
|
139 |
|
140 private: |
|
141 AlfFlowLayoutManager &mFlowLayoutManager; |
|
142 TAlfXYMetric mPreferredSize; |
|
143 }; |
|
144 |
|
145 } // namespace Alf |
|
146 |
|
147 #endif // ALFFLOWLAYOUTPREFERENCESIMPL_H |
|