lafagnosticuifoundation/uigraphicsutils/gulinc/GULALIGN.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 //
       
    15 
       
    16 #ifndef __GULALIGN_H__
       
    17 #define __GULALIGN_H__
       
    18 
       
    19 #include <e32std.h>
       
    20 #include <e32base.h>
       
    21 #include <gdi.h>
       
    22 #include <biditext.h>	// enum TBidiText::TDirectionality
       
    23 #include <txtfrmat.h>	// enum CParaFormat::TAlignment
       
    24 
       
    25 /** Horizontal layout settings for graphic objects. 
       
    26 
       
    27 @publishedAll
       
    28 @released */
       
    29 enum TGulHAlignment
       
    30 	{
       
    31 	/** Object is left-aligned. */
       
    32 	EHLeft=CGraphicsContext::ELeft,
       
    33 	/** Object is centred horizontally. */
       
    34 	EHCenter=CGraphicsContext::ECenter,
       
    35 	/** Object is right-aligned. */
       
    36 	EHRight=CGraphicsContext::ERight
       
    37 	};
       
    38 
       
    39 /** Vertical layout settings for graphic objects. 
       
    40 
       
    41 @publishedAll
       
    42 @released */
       
    43 enum TGulVAlignment
       
    44 	{
       
    45 	/** Object is aligned with the top. */
       
    46 	EVTop=0x00,
       
    47 	/** Object is centred vertically. */
       
    48 	EVCenter=0x10,
       
    49 	/** Object is aligned with the bottom. */
       
    50 	EVBottom=0x20
       
    51 	};
       
    52 
       
    53 /** Alignment settings for the layout of graphic objects. 
       
    54 
       
    55 @publishedAll
       
    56 @released */
       
    57 enum TGulAlignmentValue
       
    58 	{
       
    59 	/** Object is left and top aligned. */
       
    60 	EHLeftVTop=EHLeft|EVTop,
       
    61 	/** Object is left aligned and centred vertically. */
       
    62 	EHLeftVCenter=EHLeft|EVCenter,
       
    63 	/** Object is left aligned and at the bottom. */
       
    64 	EHLeftVBottom=EHLeft|EVBottom,
       
    65 	/** Object is centre aligned horizontally and at the top. */
       
    66 	EHCenterVTop=EHCenter|EVTop,
       
    67 	/** Object is centred horizontally and vertically. */
       
    68 	EHCenterVCenter=EHCenter|EVCenter,
       
    69 	/** Object is centred horizontally and at the bottom. */
       
    70 	EHCenterVBottom=EHCenter|EVBottom,
       
    71 	/** Object is right and top aligned. */
       
    72 	EHRightVTop=EHRight|EVTop,
       
    73 	/** Object is right aligned and centred vertically. */
       
    74 	EHRightVCenter=EHRight|EVCenter,
       
    75 	/** Object is right aligned and at the bottom. */
       
    76 	EHRightVBottom=EHRight|EVBottom
       
    77 	};
       
    78 
       
    79 
       
    80 /** Provides a convenient way to describe horizontal and vertical layouts of rectangular 
       
    81 objects and to enquire how they occupy an area given their alignment. 
       
    82 
       
    83 @publishedAll 
       
    84 @released */
       
    85 class TGulAlignment
       
    86 	{
       
    87 private:
       
    88 	enum {EHMask=0x03, EHAbsoluteFlag=0x04, EVMask=0x30};
       
    89 public:
       
    90 	inline TGulAlignment();
       
    91 	inline TGulAlignment(TGulAlignmentValue aValue);
       
    92 	inline TGulAlignment(CGraphicsContext::TTextAlign aHAlign, TGulVAlignment aVAlign = EVTop);
       
    93 	IMPORT_C operator TGulAlignmentValue() const;
       
    94 	inline TGulVAlignment VAlignment() const;
       
    95 	inline TGulHAlignment HAlignment() const;
       
    96 	IMPORT_C TGulHAlignment HAlignment(TBidiText::TDirectionality aLanguageDirectionality) const;	
       
    97 	IMPORT_C TBool HasAbsoluteHAlignment() const;
       
    98 	IMPORT_C void SetAbsoluteHAlignment(TBool aAbsoluteHAlignment);
       
    99 	
       
   100 	// Returns the horizontal text alignment. 
       
   101 	inline CGraphicsContext::TTextAlign TextAlign() const;
       
   102 	IMPORT_C CGraphicsContext::TTextAlign TextAlign(TBidiText::TDirectionality aLanguageDirectionality) const;
       
   103 	IMPORT_C CParaFormat::TAlignment ParaAlign() const;
       
   104 
       
   105 	IMPORT_C void SetVAlignment(TGulVAlignment aVAlign);
       
   106 	IMPORT_C void SetHAlignment(TGulHAlignment aHAlign);
       
   107 	IMPORT_C void SetHAlignment(CGraphicsContext::TTextAlign aHAlign);
       
   108 	IMPORT_C void SetHAlignment(CParaFormat::TAlignment aHAlign);
       
   109 	IMPORT_C TPoint InnerTopLeft(const TRect& aOuter, const TSize& aInnerSize) const;
       
   110 	IMPORT_C TPoint InnerTopLeft(const TRect& aOuter, const TSize& aInnerSize, TBidiText::TDirectionality aLanguageDirectionality) const;
       
   111 	IMPORT_C TRect InnerRect(const TRect& aOuter, const TSize& aInnerSize) const;
       
   112 	IMPORT_C TRect InnerRect(const TRect& aOuter, const TSize& aInnerSize, TBidiText::TDirectionality aLanguageDirectionality) const;
       
   113 private:
       
   114 	TInt iValue;
       
   115 	};
       
   116 
       
   117 /** Default constructor. */
       
   118 inline TGulAlignment::TGulAlignment()
       
   119 	{};
       
   120 
       
   121 /** Constructor initialising the object with an alignment value.
       
   122 @param aValue The alignment value. */
       
   123 inline TGulAlignment::TGulAlignment(TGulAlignmentValue aValue)
       
   124 	{iValue=aValue;}
       
   125 	
       
   126 /** Constructor initialising the object with an alignment value.
       
   127 @param aHAlign The horizontal alignment value. 
       
   128 @param aVAlign The vertical alignment value. */
       
   129 inline TGulAlignment::TGulAlignment(CGraphicsContext::TTextAlign aHAlign, TGulVAlignment aVAlign)
       
   130 	{ iValue = static_cast<TGulAlignmentValue>(((TGulHAlignment)aHAlign) |aVAlign); }
       
   131 		
       
   132 /** Gets the vertical alignment. 
       
   133 @return Vertical alignment. */
       
   134 inline TGulVAlignment TGulAlignment::VAlignment() const
       
   135 	{return((TGulVAlignment)(iValue&EVMask));}
       
   136 
       
   137 /** Gets the absolute horizontal alignment. 
       
   138 
       
   139 Note that this is the alignment in absolute terms. I.e. left and right 
       
   140 alignment will not be swapped depending on language directionality.
       
   141 @return Horizontal alignment. */
       
   142 inline TGulHAlignment TGulAlignment::HAlignment() const
       
   143 	{return((TGulHAlignment)(iValue&EHMask));}
       
   144 
       
   145 /** Gets the absolute horizontal text alignment.
       
   146 
       
   147 Note that this is the alignment in absolute terms. I.e. left and right 
       
   148 alignment will not be swapped depending on language directionality.
       
   149 @return The horizontal text alignment. */
       
   150 inline CGraphicsContext::TTextAlign TGulAlignment::TextAlign() const
       
   151 	{return((CGraphicsContext::TTextAlign)(HAlignment()));}
       
   152 
       
   153 #endif	// __GULALIGN_H__