williamr@2: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@2: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #ifndef __GULALIGN_H__ williamr@2: #define __GULALIGN_H__ williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include // enum TBidiText::TDirectionality williamr@2: #include // enum CParaFormat::TAlignment williamr@2: williamr@2: /** Horizontal layout settings for graphic objects. williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@2: enum TGulHAlignment williamr@2: { williamr@2: /** Object is left-aligned. */ williamr@2: EHLeft=CGraphicsContext::ELeft, williamr@2: /** Object is centred horizontally. */ williamr@2: EHCenter=CGraphicsContext::ECenter, williamr@2: /** Object is right-aligned. */ williamr@2: EHRight=CGraphicsContext::ERight williamr@2: }; williamr@2: williamr@2: /** Vertical layout settings for graphic objects. williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@2: enum TGulVAlignment williamr@2: { williamr@2: /** Object is aligned with the top. */ williamr@2: EVTop=0x00, williamr@2: /** Object is centred vertically. */ williamr@2: EVCenter=0x10, williamr@2: /** Object is aligned with the bottom. */ williamr@2: EVBottom=0x20 williamr@2: }; williamr@2: williamr@2: /** Alignment settings for the layout of graphic objects. williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@2: enum TGulAlignmentValue williamr@2: { williamr@2: /** Object is left and top aligned. */ williamr@2: EHLeftVTop=EHLeft|EVTop, williamr@2: /** Object is left aligned and centred vertically. */ williamr@2: EHLeftVCenter=EHLeft|EVCenter, williamr@2: /** Object is left aligned and at the bottom. */ williamr@2: EHLeftVBottom=EHLeft|EVBottom, williamr@2: /** Object is centre aligned horizontally and at the top. */ williamr@2: EHCenterVTop=EHCenter|EVTop, williamr@2: /** Object is centred horizontally and vertically. */ williamr@2: EHCenterVCenter=EHCenter|EVCenter, williamr@2: /** Object is centred horizontally and at the bottom. */ williamr@2: EHCenterVBottom=EHCenter|EVBottom, williamr@2: /** Object is right and top aligned. */ williamr@2: EHRightVTop=EHRight|EVTop, williamr@2: /** Object is right aligned and centred vertically. */ williamr@2: EHRightVCenter=EHRight|EVCenter, williamr@2: /** Object is right aligned and at the bottom. */ williamr@2: EHRightVBottom=EHRight|EVBottom williamr@2: }; williamr@2: williamr@2: williamr@2: /** Provides a convenient way to describe horizontal and vertical layouts of rectangular williamr@2: objects and to enquire how they occupy an area given their alignment. williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@2: class TGulAlignment williamr@2: { williamr@2: private: williamr@2: enum {EHMask=0x03, EHAbsoluteFlag=0x04, EVMask=0x30}; williamr@2: public: williamr@2: inline TGulAlignment(); williamr@2: inline TGulAlignment(TGulAlignmentValue aValue); williamr@2: inline TGulAlignment(CGraphicsContext::TTextAlign aHAlign, TGulVAlignment aVAlign = EVTop); williamr@2: IMPORT_C operator TGulAlignmentValue() const; williamr@2: inline TGulVAlignment VAlignment() const; williamr@2: inline TGulHAlignment HAlignment() const; williamr@2: IMPORT_C TGulHAlignment HAlignment(TBidiText::TDirectionality aLanguageDirectionality) const; williamr@2: IMPORT_C TBool HasAbsoluteHAlignment() const; williamr@2: IMPORT_C void SetAbsoluteHAlignment(TBool aAbsoluteHAlignment); williamr@2: williamr@2: // Returns the horizontal text alignment. williamr@2: inline CGraphicsContext::TTextAlign TextAlign() const; williamr@2: IMPORT_C CGraphicsContext::TTextAlign TextAlign(TBidiText::TDirectionality aLanguageDirectionality) const; williamr@2: IMPORT_C CParaFormat::TAlignment ParaAlign() const; williamr@2: williamr@2: IMPORT_C void SetVAlignment(TGulVAlignment aVAlign); williamr@2: IMPORT_C void SetHAlignment(TGulHAlignment aHAlign); williamr@2: IMPORT_C void SetHAlignment(CGraphicsContext::TTextAlign aHAlign); williamr@2: IMPORT_C void SetHAlignment(CParaFormat::TAlignment aHAlign); williamr@2: IMPORT_C TPoint InnerTopLeft(const TRect& aOuter, const TSize& aInnerSize) const; williamr@2: IMPORT_C TPoint InnerTopLeft(const TRect& aOuter, const TSize& aInnerSize, TBidiText::TDirectionality aLanguageDirectionality) const; williamr@2: IMPORT_C TRect InnerRect(const TRect& aOuter, const TSize& aInnerSize) const; williamr@2: IMPORT_C TRect InnerRect(const TRect& aOuter, const TSize& aInnerSize, TBidiText::TDirectionality aLanguageDirectionality) const; williamr@2: private: williamr@2: TInt iValue; williamr@2: }; williamr@2: williamr@2: /** Default constructor. */ williamr@2: inline TGulAlignment::TGulAlignment() williamr@2: {}; williamr@2: williamr@2: /** Constructor initialising the object with an alignment value. williamr@2: @param aValue The alignment value. */ williamr@2: inline TGulAlignment::TGulAlignment(TGulAlignmentValue aValue) williamr@2: {iValue=aValue;} williamr@2: williamr@2: /** Constructor initialising the object with an alignment value. williamr@2: @param aHAlign The horizontal alignment value. williamr@2: @param aVAlign The vertical alignment value. */ williamr@2: inline TGulAlignment::TGulAlignment(CGraphicsContext::TTextAlign aHAlign, TGulVAlignment aVAlign) williamr@2: { iValue = static_cast(((TGulHAlignment)aHAlign) |aVAlign); } williamr@2: williamr@2: /** Gets the vertical alignment. williamr@2: @return Vertical alignment. */ williamr@2: inline TGulVAlignment TGulAlignment::VAlignment() const williamr@2: {return((TGulVAlignment)(iValue&EVMask));} williamr@2: williamr@2: /** Gets the absolute horizontal alignment. williamr@2: williamr@2: Note that this is the alignment in absolute terms. I.e. left and right williamr@2: alignment will not be swapped depending on language directionality. williamr@2: @return Horizontal alignment. */ williamr@2: inline TGulHAlignment TGulAlignment::HAlignment() const williamr@2: {return((TGulHAlignment)(iValue&EHMask));} williamr@2: williamr@2: /** Gets the absolute horizontal text alignment. williamr@2: williamr@2: Note that this is the alignment in absolute terms. I.e. left and right williamr@2: alignment will not be swapped depending on language directionality. williamr@2: @return The horizontal text alignment. */ williamr@2: inline CGraphicsContext::TTextAlign TGulAlignment::TextAlign() const williamr@2: {return((CGraphicsContext::TTextAlign)(HAlignment()));} williamr@2: williamr@2: #endif // __GULALIGN_H__