epoc32/include/mw/gulalign.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@4
     4
// under the terms of "Eclipse Public License v1.0"
williamr@2
     5
// which accompanies this distribution, and is available
williamr@4
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
//
williamr@2
    15
williamr@2
    16
#ifndef __GULALIGN_H__
williamr@2
    17
#define __GULALIGN_H__
williamr@2
    18
williamr@2
    19
#include <e32std.h>
williamr@2
    20
#include <e32base.h>
williamr@2
    21
#include <gdi.h>
williamr@2
    22
#include <biditext.h>	// enum TBidiText::TDirectionality
williamr@2
    23
#include <txtfrmat.h>	// enum CParaFormat::TAlignment
williamr@2
    24
williamr@2
    25
/** Horizontal layout settings for graphic objects. 
williamr@2
    26
williamr@2
    27
@publishedAll
williamr@2
    28
@released */
williamr@2
    29
enum TGulHAlignment
williamr@2
    30
	{
williamr@2
    31
	/** Object is left-aligned. */
williamr@2
    32
	EHLeft=CGraphicsContext::ELeft,
williamr@2
    33
	/** Object is centred horizontally. */
williamr@2
    34
	EHCenter=CGraphicsContext::ECenter,
williamr@2
    35
	/** Object is right-aligned. */
williamr@2
    36
	EHRight=CGraphicsContext::ERight
williamr@2
    37
	};
williamr@2
    38
williamr@2
    39
/** Vertical layout settings for graphic objects. 
williamr@2
    40
williamr@2
    41
@publishedAll
williamr@2
    42
@released */
williamr@2
    43
enum TGulVAlignment
williamr@2
    44
	{
williamr@2
    45
	/** Object is aligned with the top. */
williamr@2
    46
	EVTop=0x00,
williamr@2
    47
	/** Object is centred vertically. */
williamr@2
    48
	EVCenter=0x10,
williamr@2
    49
	/** Object is aligned with the bottom. */
williamr@2
    50
	EVBottom=0x20
williamr@2
    51
	};
williamr@2
    52
williamr@2
    53
/** Alignment settings for the layout of graphic objects. 
williamr@2
    54
williamr@2
    55
@publishedAll
williamr@2
    56
@released */
williamr@2
    57
enum TGulAlignmentValue
williamr@2
    58
	{
williamr@2
    59
	/** Object is left and top aligned. */
williamr@2
    60
	EHLeftVTop=EHLeft|EVTop,
williamr@2
    61
	/** Object is left aligned and centred vertically. */
williamr@2
    62
	EHLeftVCenter=EHLeft|EVCenter,
williamr@2
    63
	/** Object is left aligned and at the bottom. */
williamr@2
    64
	EHLeftVBottom=EHLeft|EVBottom,
williamr@2
    65
	/** Object is centre aligned horizontally and at the top. */
williamr@2
    66
	EHCenterVTop=EHCenter|EVTop,
williamr@2
    67
	/** Object is centred horizontally and vertically. */
williamr@2
    68
	EHCenterVCenter=EHCenter|EVCenter,
williamr@2
    69
	/** Object is centred horizontally and at the bottom. */
williamr@2
    70
	EHCenterVBottom=EHCenter|EVBottom,
williamr@2
    71
	/** Object is right and top aligned. */
williamr@2
    72
	EHRightVTop=EHRight|EVTop,
williamr@2
    73
	/** Object is right aligned and centred vertically. */
williamr@2
    74
	EHRightVCenter=EHRight|EVCenter,
williamr@2
    75
	/** Object is right aligned and at the bottom. */
williamr@2
    76
	EHRightVBottom=EHRight|EVBottom
williamr@2
    77
	};
williamr@2
    78
williamr@2
    79
williamr@2
    80
/** Provides a convenient way to describe horizontal and vertical layouts of rectangular 
williamr@2
    81
objects and to enquire how they occupy an area given their alignment. 
williamr@2
    82
williamr@2
    83
@publishedAll 
williamr@2
    84
@released */
williamr@2
    85
class TGulAlignment
williamr@2
    86
	{
williamr@2
    87
private:
williamr@2
    88
	enum {EHMask=0x03, EHAbsoluteFlag=0x04, EVMask=0x30};
williamr@2
    89
public:
williamr@2
    90
	inline TGulAlignment();
williamr@2
    91
	inline TGulAlignment(TGulAlignmentValue aValue);
williamr@2
    92
	inline TGulAlignment(CGraphicsContext::TTextAlign aHAlign, TGulVAlignment aVAlign = EVTop);
williamr@2
    93
	IMPORT_C operator TGulAlignmentValue() const;
williamr@2
    94
	inline TGulVAlignment VAlignment() const;
williamr@2
    95
	inline TGulHAlignment HAlignment() const;
williamr@2
    96
	IMPORT_C TGulHAlignment HAlignment(TBidiText::TDirectionality aLanguageDirectionality) const;	
williamr@2
    97
	IMPORT_C TBool HasAbsoluteHAlignment() const;
williamr@2
    98
	IMPORT_C void SetAbsoluteHAlignment(TBool aAbsoluteHAlignment);
williamr@2
    99
	
williamr@2
   100
	// Returns the horizontal text alignment. 
williamr@2
   101
	inline CGraphicsContext::TTextAlign TextAlign() const;
williamr@2
   102
	IMPORT_C CGraphicsContext::TTextAlign TextAlign(TBidiText::TDirectionality aLanguageDirectionality) const;
williamr@2
   103
	IMPORT_C CParaFormat::TAlignment ParaAlign() const;
williamr@2
   104
williamr@2
   105
	IMPORT_C void SetVAlignment(TGulVAlignment aVAlign);
williamr@2
   106
	IMPORT_C void SetHAlignment(TGulHAlignment aHAlign);
williamr@2
   107
	IMPORT_C void SetHAlignment(CGraphicsContext::TTextAlign aHAlign);
williamr@2
   108
	IMPORT_C void SetHAlignment(CParaFormat::TAlignment aHAlign);
williamr@2
   109
	IMPORT_C TPoint InnerTopLeft(const TRect& aOuter, const TSize& aInnerSize) const;
williamr@2
   110
	IMPORT_C TPoint InnerTopLeft(const TRect& aOuter, const TSize& aInnerSize, TBidiText::TDirectionality aLanguageDirectionality) const;
williamr@2
   111
	IMPORT_C TRect InnerRect(const TRect& aOuter, const TSize& aInnerSize) const;
williamr@2
   112
	IMPORT_C TRect InnerRect(const TRect& aOuter, const TSize& aInnerSize, TBidiText::TDirectionality aLanguageDirectionality) const;
williamr@2
   113
private:
williamr@2
   114
	TInt iValue;
williamr@2
   115
	};
williamr@2
   116
williamr@2
   117
/** Default constructor. */
williamr@2
   118
inline TGulAlignment::TGulAlignment()
williamr@2
   119
	{};
williamr@2
   120
williamr@2
   121
/** Constructor initialising the object with an alignment value.
williamr@2
   122
@param aValue The alignment value. */
williamr@2
   123
inline TGulAlignment::TGulAlignment(TGulAlignmentValue aValue)
williamr@2
   124
	{iValue=aValue;}
williamr@2
   125
	
williamr@2
   126
/** Constructor initialising the object with an alignment value.
williamr@2
   127
@param aHAlign The horizontal alignment value. 
williamr@2
   128
@param aVAlign The vertical alignment value. */
williamr@2
   129
inline TGulAlignment::TGulAlignment(CGraphicsContext::TTextAlign aHAlign, TGulVAlignment aVAlign)
williamr@2
   130
	{ iValue = static_cast<TGulAlignmentValue>(((TGulHAlignment)aHAlign) |aVAlign); }
williamr@2
   131
		
williamr@2
   132
/** Gets the vertical alignment. 
williamr@2
   133
@return Vertical alignment. */
williamr@2
   134
inline TGulVAlignment TGulAlignment::VAlignment() const
williamr@2
   135
	{return((TGulVAlignment)(iValue&EVMask));}
williamr@2
   136
williamr@2
   137
/** Gets the absolute horizontal alignment. 
williamr@2
   138
williamr@2
   139
Note that this is the alignment in absolute terms. I.e. left and right 
williamr@2
   140
alignment will not be swapped depending on language directionality.
williamr@2
   141
@return Horizontal alignment. */
williamr@2
   142
inline TGulHAlignment TGulAlignment::HAlignment() const
williamr@2
   143
	{return((TGulHAlignment)(iValue&EHMask));}
williamr@2
   144
williamr@2
   145
/** Gets the absolute horizontal text alignment.
williamr@2
   146
williamr@2
   147
Note that this is the alignment in absolute terms. I.e. left and right 
williamr@2
   148
alignment will not be swapped depending on language directionality.
williamr@2
   149
@return The horizontal text alignment. */
williamr@2
   150
inline CGraphicsContext::TTextAlign TGulAlignment::TextAlign() const
williamr@2
   151
	{return((CGraphicsContext::TTextAlign)(HAlignment()));}
williamr@2
   152
williamr@2
   153
#endif	// __GULALIGN_H__