1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 #ifndef __COELAYOUTMANAGER_H__
19 #define __COELAYOUTMANAGER_H__
27 Base class for layout managers.
29 A layout manager can be attached to one, or many (depending on the concrete layout
30 manager), compound controls. The layout manager handles the layout of the components
31 of the attached compound controls, and calculates the attached compound controls'
37 class MCoeLayoutManager
40 IMPORT_C MCoeLayoutManager();
44 /** Determines if it is possible to attach another control to the layout manager.
45 @return <code>ETrue</code> if possible, otherwise <code>EFalse</code>
47 virtual TBool CanAttach() const = 0;
49 /** Attaches <code>aCompoundControl</code> to the layout manager.
50 Is normally not called manually since <code>CCoeControl::SetLayoutManagerL()</code>
52 Once a compound control is attached to a layout manager, the layout manager owns itself.
54 @see CCoeControl::SetLayoutManagerL()
55 @param aCompoundControl The compound control.
57 virtual void AttachL(CCoeControl& aCompoundControl) = 0;
59 /** Detaches <code>aCompoundControl</code> from the layout manager.
60 Is normally not called manually since <code>CCoeControl::SetLayoutManagerL()</code>
61 calls this function when you switch layout managers on a control. It is also called
62 from <code>CCoeControl::~CCoeControl</code>
63 When the last attached compound control detaches, the layout manager deletes itself.
64 @see CCoeControl::SetLayoutManagerL()
65 @param aCompoundControl The compound control.
67 virtual void Detach(CCoeControl& aCompoundControl) = 0;
69 /** Calculates the minimum size of <code>aCompoundControl</code>
70 Is normally not called manually since <code>CCoeControl::MinimumSize()</code>
71 calls this function in the default implementation on controls with layout managers.
73 To calculate the minimum size is almost as time consuming as performing an actual layout
74 and should be used with caution. The minimum size depends on <code>aCompoundControl</code>'s
76 @see CCoeControl::MaximumWidth()
77 @param aCompoundControl The compound control
78 @return The minimum size
80 virtual TSize CalcMinimumSize(const CCoeControl& aCompoundControl) const = 0;
82 /** Performs the layout of the attached controls
83 Is normally not called manually since <code>CCoeControl::SizeChanged()</code>
84 calls this function in the default implementation on controls with layout managers.
86 The layout is generally performed by calling the component controls'
87 <code>SetMaximumWidth()</code>, followed by <code>MinimumSize()</code>, and then the
88 layout manager tries to place the component controls according to their minimum
89 sizes and the settings.
91 @see CCoeControl::SetMaximumWidth()
92 @see CCoeControl::MinimumSize()
94 virtual void PerformLayout() = 0;
96 /** Gets the offset to the first text baseline relative to the top of the control.
98 @param aCompoundControl The control
99 @param aSize The size of the control
101 @see CCoeControl::TextBaselineOffset()
103 virtual TInt CalcTextBaselineOffset(const CCoeControl& aCompoundControl, const TSize& aSize) const = 0;
105 /** Sets the spacing between text baselines.
107 @param aBaselineSpacing The new value for the baseline
108 @see CCoeControl::SetTextBaseLineSpacing()
110 virtual void SetTextBaselineSpacing(TInt aBaselineSpacing) = 0;
112 /** Returns the baseline spacing.
113 @return The baseline value.
115 virtual TInt TextBaselineSpacing() const = 0;
117 /** Handles when a component control is added to an attached compound control
118 Is normally not called manually since <code>CCoeControlArray::InsertLC()</code>
119 calls this function for controls with layout managers.
120 Is used by layout managers to prepare to layout one more component control.
121 @see CCoeControlArray::InsertLC()
122 @param aCompoundControl The compound control.
123 @param aAddedControl The added control
125 virtual void HandleAddedControlL(const CCoeControl& aCompoundControl, const CCoeControl& aAddedControl) = 0;
127 /** Handles when a component control is removed from an attached compound control
128 Is normally not called manually since <code>CCoeControlArray::Remove()</code>
129 calls this function for controls with layout managers.
130 Is used by layout managers to remove all settings and similar that are specific for
131 <code>aRemovedControl</code>.
132 @see CCoeControlArray::Remove()
133 @param aCompoundControl The compound control.
134 @param aRemovedControl The removed control
136 virtual void HandleRemovedControl(const CCoeControl& aCompoundControl, const CCoeControl& aRemovedControl) = 0;
138 /** Handles when a component control is replaced by another component control
139 in an attached compound control
141 Is not called by <code>CCoeControl</code>.
142 Is used by layout managers to move settings and similar that are specified for
143 <code>aOldControl</code> to <code>aNewControl</code>
144 If this function is called, neither <code>HandleAddedControlL</code> nor
145 <code>HandleRemovedControl</code> is allowed to be called.
146 @param aOldControl The old component control
147 @param aNewControl The new component control
148 @return <code>KErrNone</code> if no error. <code>KErrNotFound</code> if the
149 layout manager cannot find <code>aOldControl</code>
151 virtual TInt HandleControlReplaced(const CCoeControl& aOldControl, const CCoeControl& aNewControl) = 0;
155 IMPORT_C virtual void Reserved_MCoeLayoutManager_1();
156 IMPORT_C virtual void Reserved_MCoeLayoutManager_2();
157 IMPORT_C virtual void Reserved_MCoeLayoutManager_3();
158 IMPORT_C virtual void Reserved_MCoeLayoutManager_4();
159 IMPORT_C virtual void Reserved_MCoeLayoutManager_5();
160 IMPORT_C virtual void Reserved_MCoeLayoutManager_6();
161 IMPORT_C virtual void Reserved_MCoeLayoutManager_7();
162 IMPORT_C virtual void Reserved_MCoeLayoutManager_8();
163 IMPORT_C virtual void Reserved_MCoeLayoutManager_9();
164 IMPORT_C virtual void Reserved_MCoeLayoutManager_10();
165 IMPORT_C virtual void Reserved_MCoeLayoutManager_11();
167 TInt iMCoeLayoutManager_Reserved1;
171 #endif // __COELAYOUTMANAGER_H__