1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/mw/gulalign.h Wed Mar 31 12:27:01 2010 +0100
1.3 @@ -0,0 +1,153 @@
1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __GULALIGN_H__
1.20 +#define __GULALIGN_H__
1.21 +
1.22 +#include <e32std.h>
1.23 +#include <e32base.h>
1.24 +#include <gdi.h>
1.25 +#include <biditext.h> // enum TBidiText::TDirectionality
1.26 +#include <txtfrmat.h> // enum CParaFormat::TAlignment
1.27 +
1.28 +/** Horizontal layout settings for graphic objects.
1.29 +
1.30 +@publishedAll
1.31 +@released */
1.32 +enum TGulHAlignment
1.33 + {
1.34 + /** Object is left-aligned. */
1.35 + EHLeft=CGraphicsContext::ELeft,
1.36 + /** Object is centred horizontally. */
1.37 + EHCenter=CGraphicsContext::ECenter,
1.38 + /** Object is right-aligned. */
1.39 + EHRight=CGraphicsContext::ERight
1.40 + };
1.41 +
1.42 +/** Vertical layout settings for graphic objects.
1.43 +
1.44 +@publishedAll
1.45 +@released */
1.46 +enum TGulVAlignment
1.47 + {
1.48 + /** Object is aligned with the top. */
1.49 + EVTop=0x00,
1.50 + /** Object is centred vertically. */
1.51 + EVCenter=0x10,
1.52 + /** Object is aligned with the bottom. */
1.53 + EVBottom=0x20
1.54 + };
1.55 +
1.56 +/** Alignment settings for the layout of graphic objects.
1.57 +
1.58 +@publishedAll
1.59 +@released */
1.60 +enum TGulAlignmentValue
1.61 + {
1.62 + /** Object is left and top aligned. */
1.63 + EHLeftVTop=EHLeft|EVTop,
1.64 + /** Object is left aligned and centred vertically. */
1.65 + EHLeftVCenter=EHLeft|EVCenter,
1.66 + /** Object is left aligned and at the bottom. */
1.67 + EHLeftVBottom=EHLeft|EVBottom,
1.68 + /** Object is centre aligned horizontally and at the top. */
1.69 + EHCenterVTop=EHCenter|EVTop,
1.70 + /** Object is centred horizontally and vertically. */
1.71 + EHCenterVCenter=EHCenter|EVCenter,
1.72 + /** Object is centred horizontally and at the bottom. */
1.73 + EHCenterVBottom=EHCenter|EVBottom,
1.74 + /** Object is right and top aligned. */
1.75 + EHRightVTop=EHRight|EVTop,
1.76 + /** Object is right aligned and centred vertically. */
1.77 + EHRightVCenter=EHRight|EVCenter,
1.78 + /** Object is right aligned and at the bottom. */
1.79 + EHRightVBottom=EHRight|EVBottom
1.80 + };
1.81 +
1.82 +
1.83 +/** Provides a convenient way to describe horizontal and vertical layouts of rectangular
1.84 +objects and to enquire how they occupy an area given their alignment.
1.85 +
1.86 +@publishedAll
1.87 +@released */
1.88 +class TGulAlignment
1.89 + {
1.90 +private:
1.91 + enum {EHMask=0x03, EHAbsoluteFlag=0x04, EVMask=0x30};
1.92 +public:
1.93 + inline TGulAlignment();
1.94 + inline TGulAlignment(TGulAlignmentValue aValue);
1.95 + inline TGulAlignment(CGraphicsContext::TTextAlign aHAlign, TGulVAlignment aVAlign = EVTop);
1.96 + IMPORT_C operator TGulAlignmentValue() const;
1.97 + inline TGulVAlignment VAlignment() const;
1.98 + inline TGulHAlignment HAlignment() const;
1.99 + IMPORT_C TGulHAlignment HAlignment(TBidiText::TDirectionality aLanguageDirectionality) const;
1.100 + IMPORT_C TBool HasAbsoluteHAlignment() const;
1.101 + IMPORT_C void SetAbsoluteHAlignment(TBool aAbsoluteHAlignment);
1.102 +
1.103 + // Returns the horizontal text alignment.
1.104 + inline CGraphicsContext::TTextAlign TextAlign() const;
1.105 + IMPORT_C CGraphicsContext::TTextAlign TextAlign(TBidiText::TDirectionality aLanguageDirectionality) const;
1.106 + IMPORT_C CParaFormat::TAlignment ParaAlign() const;
1.107 +
1.108 + IMPORT_C void SetVAlignment(TGulVAlignment aVAlign);
1.109 + IMPORT_C void SetHAlignment(TGulHAlignment aHAlign);
1.110 + IMPORT_C void SetHAlignment(CGraphicsContext::TTextAlign aHAlign);
1.111 + IMPORT_C void SetHAlignment(CParaFormat::TAlignment aHAlign);
1.112 + IMPORT_C TPoint InnerTopLeft(const TRect& aOuter, const TSize& aInnerSize) const;
1.113 + IMPORT_C TPoint InnerTopLeft(const TRect& aOuter, const TSize& aInnerSize, TBidiText::TDirectionality aLanguageDirectionality) const;
1.114 + IMPORT_C TRect InnerRect(const TRect& aOuter, const TSize& aInnerSize) const;
1.115 + IMPORT_C TRect InnerRect(const TRect& aOuter, const TSize& aInnerSize, TBidiText::TDirectionality aLanguageDirectionality) const;
1.116 +private:
1.117 + TInt iValue;
1.118 + };
1.119 +
1.120 +/** Default constructor. */
1.121 +inline TGulAlignment::TGulAlignment()
1.122 + {};
1.123 +
1.124 +/** Constructor initialising the object with an alignment value.
1.125 +@param aValue The alignment value. */
1.126 +inline TGulAlignment::TGulAlignment(TGulAlignmentValue aValue)
1.127 + {iValue=aValue;}
1.128 +
1.129 +/** Constructor initialising the object with an alignment value.
1.130 +@param aHAlign The horizontal alignment value.
1.131 +@param aVAlign The vertical alignment value. */
1.132 +inline TGulAlignment::TGulAlignment(CGraphicsContext::TTextAlign aHAlign, TGulVAlignment aVAlign)
1.133 + { iValue = static_cast<TGulAlignmentValue>(((TGulHAlignment)aHAlign) |aVAlign); }
1.134 +
1.135 +/** Gets the vertical alignment.
1.136 +@return Vertical alignment. */
1.137 +inline TGulVAlignment TGulAlignment::VAlignment() const
1.138 + {return((TGulVAlignment)(iValue&EVMask));}
1.139 +
1.140 +/** Gets the absolute horizontal alignment.
1.141 +
1.142 +Note that this is the alignment in absolute terms. I.e. left and right
1.143 +alignment will not be swapped depending on language directionality.
1.144 +@return Horizontal alignment. */
1.145 +inline TGulHAlignment TGulAlignment::HAlignment() const
1.146 + {return((TGulHAlignment)(iValue&EHMask));}
1.147 +
1.148 +/** Gets the absolute horizontal text alignment.
1.149 +
1.150 +Note that this is the alignment in absolute terms. I.e. left and right
1.151 +alignment will not be swapped depending on language directionality.
1.152 +@return The horizontal text alignment. */
1.153 +inline CGraphicsContext::TTextAlign TGulAlignment::TextAlign() const
1.154 + {return((CGraphicsContext::TTextAlign)(HAlignment()));}
1.155 +
1.156 +#endif // __GULALIGN_H__