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.
16 #ifndef __GULALIGN_H__
17 #define __GULALIGN_H__
22 #include <biditext.h> // enum TBidiText::TDirectionality
23 #include <txtfrmat.h> // enum CParaFormat::TAlignment
25 /** Horizontal layout settings for graphic objects.
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
39 /** Vertical layout settings for graphic objects.
45 /** Object is aligned with the top. */
47 /** Object is centred vertically. */
49 /** Object is aligned with the bottom. */
53 /** Alignment settings for the layout of graphic objects.
57 enum TGulAlignmentValue
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
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.
88 enum {EHMask=0x03, EHAbsoluteFlag=0x04, EVMask=0x30};
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);
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;
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;
117 /** Default constructor. */
118 inline TGulAlignment::TGulAlignment()
121 /** Constructor initialising the object with an alignment value.
122 @param aValue The alignment value. */
123 inline TGulAlignment::TGulAlignment(TGulAlignmentValue aValue)
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); }
132 /** Gets the vertical alignment.
133 @return Vertical alignment. */
134 inline TGulVAlignment TGulAlignment::VAlignment() const
135 {return((TGulVAlignment)(iValue&EVMask));}
137 /** Gets the absolute horizontal alignment.
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));}
145 /** Gets the absolute horizontal text alignment.
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()));}
153 #endif // __GULALIGN_H__