lafagnosticuifoundation/cone/inc/CoeLayoutMan.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // CoeLayoutManager.H
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __COELAYOUTMANAGER_H__
       
    19 #define __COELAYOUTMANAGER_H__
       
    20 
       
    21 #include <e32base.h>
       
    22 
       
    23 class CCoeControl;
       
    24 
       
    25 
       
    26 /**
       
    27 Base class for layout managers.
       
    28 
       
    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' 
       
    32 minimum size. 
       
    33 
       
    34 @publishedAll
       
    35 @released
       
    36 */
       
    37 class MCoeLayoutManager
       
    38 	{
       
    39 protected:
       
    40 	IMPORT_C MCoeLayoutManager();
       
    41 	
       
    42 public:
       
    43 
       
    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>
       
    46 	*/
       
    47 	virtual TBool CanAttach() const = 0;
       
    48 
       
    49 	/** Attaches <code>aCompoundControl</code> to the layout manager.
       
    50 	Is normally not called manually since <code>CCoeControl::SetLayoutManagerL()</code>
       
    51 	calls this function.
       
    52 	Once a compound control is attached to a layout manager, the layout manager owns itself.
       
    53 	@see Detach()
       
    54 	@see CCoeControl::SetLayoutManagerL()
       
    55 	@param aCompoundControl The compound control.
       
    56 	*/
       
    57 	virtual void AttachL(CCoeControl& aCompoundControl) = 0;
       
    58 
       
    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.
       
    66 	*/
       
    67 	virtual void Detach(CCoeControl& aCompoundControl) = 0;
       
    68 
       
    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.
       
    72 
       
    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
       
    75 	maximum width.
       
    76 	@see CCoeControl::MaximumWidth()
       
    77 	@param aCompoundControl The compound control
       
    78 	@return The minimum size
       
    79 	*/
       
    80 	virtual TSize CalcMinimumSize(const CCoeControl& aCompoundControl) const = 0;
       
    81 
       
    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.
       
    85 
       
    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.
       
    90 
       
    91 	@see CCoeControl::SetMaximumWidth()
       
    92 	@see CCoeControl::MinimumSize()
       
    93 	*/
       
    94 	virtual void PerformLayout() = 0;
       
    95 
       
    96 	/** Gets the offset to the first text baseline relative to the top of the control.
       
    97 	
       
    98 	@param aCompoundControl The control
       
    99 	@param aSize The size of the control
       
   100 	@return The baseline
       
   101 	@see CCoeControl::TextBaselineOffset()
       
   102 	*/
       
   103 	virtual TInt CalcTextBaselineOffset(const CCoeControl& aCompoundControl, const TSize& aSize) const = 0;
       
   104 
       
   105 	/** Sets the spacing between text baselines.
       
   106 
       
   107 	@param aBaselineSpacing The new value for the baseline
       
   108 	@see CCoeControl::SetTextBaseLineSpacing()
       
   109 	*/
       
   110 	virtual void SetTextBaselineSpacing(TInt aBaselineSpacing) = 0;
       
   111 	
       
   112 	/** Returns the baseline spacing.
       
   113 	@return The baseline value.
       
   114 	*/
       
   115 	virtual TInt TextBaselineSpacing() const = 0;
       
   116 
       
   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
       
   124 	*/
       
   125 	virtual void HandleAddedControlL(const CCoeControl& aCompoundControl, const CCoeControl& aAddedControl) = 0;
       
   126 	
       
   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
       
   135 	*/
       
   136 	virtual void HandleRemovedControl(const CCoeControl& aCompoundControl, const CCoeControl& aRemovedControl) = 0;
       
   137 
       
   138 	/** Handles when a component control is replaced by another component control
       
   139 	in an attached compound control
       
   140 	
       
   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>
       
   150 	*/
       
   151 	virtual TInt HandleControlReplaced(const CCoeControl& aOldControl, const CCoeControl& aNewControl) = 0;
       
   152 
       
   153 	
       
   154 private:
       
   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();
       
   166 private:
       
   167 	TInt iMCoeLayoutManager_Reserved1;
       
   168 	};
       
   169 
       
   170 
       
   171 #endif	// __COELAYOUTMANAGER_H__