os/graphics/graphicsdeviceinterface/gdi/inc/LineBreak.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#ifndef LINEBREAK_H_
sl@0
    17
#define LINEBREAK_H_
sl@0
    18
sl@0
    19
#include <e32def.h>
sl@0
    20
class MContingentLineBreaker;
sl@0
    21
class MContingentLineBreakerL;
sl@0
    22
class TDesC16;
sl@0
    23
class TUid;
sl@0
    24
sl@0
    25
sl@0
    26
/**
sl@0
    27
 This enumeration holds the possible panic codes that may be raised
sl@0
    28
 by the LineBreak API on detecting an unrecoverable error.
sl@0
    29
@publishedAll
sl@0
    30
@released
sl@0
    31
*/
sl@0
    32
enum TLineBreakPanic
sl@0
    33
	{
sl@0
    34
	/** Not used */
sl@0
    35
	ELineBreakPanic_Unknown				= 0,
sl@0
    36
	/** Internal error, error found in data table */
sl@0
    37
	ELineBreakPanic_BadTable			= 1,
sl@0
    38
	/** One or more of the input parameters to the interface were invalid */
sl@0
    39
	ELineBreakPanic_InvalidInputParam	= 2,
sl@0
    40
	/** Raised when an output parameter breaks an API condition */
sl@0
    41
	ELineBreakPanic_InvalidOutputParam	= 3,
sl@0
    42
	};
sl@0
    43
sl@0
    44
sl@0
    45
sl@0
    46
class MLineBreaker
sl@0
    47
/**
sl@0
    48
Customizes the Unicode line-breaking algorithm. 
sl@0
    49
@publishedAll
sl@0
    50
@released
sl@0
    51
*/
sl@0
    52
	{
sl@0
    53
public:
sl@0
    54
	/** The Unicode line breaking classes; see Unicode Technical Report 14.
sl@0
    55
	Not a named enumerated type, so that overriding classes may add new
sl@0
    56
	line breaking classes freely.
sl@0
    57
	The description of each constant gives the name of the line-breaking
sl@0
    58
	class, an example and a brief, imprecise description of the default
sl@0
    59
	behaviour of characters of that class.	 */
sl@0
    60
	enum
sl@0
    61
		{
sl@0
    62
		/** Opening Punctuation (e.g. '['). Breaking after prohibited. */
sl@0
    63
		EOpLineBreakClass,
sl@0
    64
		/** Closing Punctuation (e.g. ']'). Breaking before prohibited. */
sl@0
    65
		EClLineBreakClass,
sl@0
    66
		/** Ambiguous Quotes (e.g. '"'). Breaking before and after prohibited. */
sl@0
    67
		EQuLineBreakClass,
sl@0
    68
		/** Glue (e.g. Non-breaking space). Breaking before and after prohibited
sl@0
    69
		unless spaces are present. */
sl@0
    70
		EGlLineBreakClass,
sl@0
    71
		/** Non-Starter (e.g. small Japanese kana). Breaking before prohibited
sl@0
    72
		if no spaces present. */
sl@0
    73
		ENsLineBreakClass,
sl@0
    74
		/** Exclamation or Interrogation (e.g. '?'). Like closing punctuation
sl@0
    75
		except before Postfix or Non-starter. */
sl@0
    76
		EExLineBreakClass,
sl@0
    77
		/** Symbol (e.g. '/'. Like Alphabetic, but allows breaking before
sl@0
    78
		Alphabetic. */
sl@0
    79
		ESyLineBreakClass,
sl@0
    80
		/** Numeric Infix Separator (e.g. ','). Forbids breaking after any and before
sl@0
    81
		Numeric. */
sl@0
    82
		EIsLineBreakClass,
sl@0
    83
		/** Numeric Prefix (e.g. '$'). Forbids breaking before Numeric. */
sl@0
    84
		EPrLineBreakClass,
sl@0
    85
		/** Numeric Postfix (e.g. '%'). Forbids breaking after Numeric. */
sl@0
    86
		EPoLineBreakClass,
sl@0
    87
		/** Numeric (e.g. '1'). */
sl@0
    88
		ENuLineBreakClass,
sl@0
    89
		/** Alphabetic (e.g. 'a'). */
sl@0
    90
		EAlLineBreakClass,
sl@0
    91
		/** Ideographic (e.g. Japanese Kanji). Generally break before or after */
sl@0
    92
		EIdLineBreakClass,
sl@0
    93
		/** Inseparable (e.g. ellipsis). Forbid breaks between Inseparables. */
sl@0
    94
		EInLineBreakClass,
sl@0
    95
		/** Hyphen (e.g. '-'). Allows a break after except before Numeric. */
sl@0
    96
		EHyLineBreakClass,
sl@0
    97
		/** Break After. Generally allow a break after. Breaking between Break
sl@0
    98
		Afters not separated by spaces is prohibited. */
sl@0
    99
		EBaLineBreakClass,
sl@0
   100
		/** Break Before. Generally allow a break before. Breaking between Break
sl@0
   101
		Befores not separated by spaces is prohibited. */
sl@0
   102
		EBbLineBreakClass,
sl@0
   103
		/** Break Before and After. Generally allow a break before or after.
sl@0
   104
		Breaking between Break Before and Afters is prohibited, even if spaces
sl@0
   105
		are present. */
sl@0
   106
		EB2LineBreakClass,
sl@0
   107
		/** Zero-Width Space. Allow a break. */
sl@0
   108
		EZwLineBreakClass,
sl@0
   109
		/** Combining Mark. Takes on the class of its base class. */
sl@0
   110
		ECmLineBreakClass,
sl@0
   111
		/** Mandatory Break. */
sl@0
   112
		EBkLineBreakClass,
sl@0
   113
		/** Carriage Return. Break after unless part of a CRLF pair. */
sl@0
   114
		ECrLineBreakClass,
sl@0
   115
		/** Line Feed. Break after. */
sl@0
   116
		ELfLineBreakClass,
sl@0
   117
		/** Surrogate. Half of a surrogate pair. */
sl@0
   118
		ESgLineBreakClass,
sl@0
   119
		/** Contingent Break (e.g. embedded pictures). Uses external
sl@0
   120
		information */
sl@0
   121
		ECbLineBreakClass,
sl@0
   122
sl@0
   123
		/** Space. Intervening characters of class Space are indicated by
sl@0
   124
		aHaveSpaces in LineBreakPossible. */
sl@0
   125
		ESpLineBreakClass, 
sl@0
   126
sl@0
   127
		/** Complex Context (e.g. Thai). Runs of Complex Context are passed to
sl@0
   128
		GetLineBreakInContext. */
sl@0
   129
		ESaLineBreakClass,
sl@0
   130
sl@0
   131
		/** Ambiguous. Characters of ambiguous East Asian width are treated
sl@0
   132
		as Alphabetic, unless they are resolved as being "Wide", in which case
sl@0
   133
		they are treated as Ideographic. */
sl@0
   134
		EAiLineBreakClass,
sl@0
   135
sl@0
   136
		/** The Xx class is used when the class is unknown; e.g.; outside the provided context. */
sl@0
   137
		EXxLineBreakClass,
sl@0
   138
sl@0
   139
		/** The number of Unicode line break classes. */
sl@0
   140
		ELineBreakClasses
sl@0
   141
		};
sl@0
   142
sl@0
   143
	IMPORT_C virtual TUint LineBreakClass(TUint aCode,
sl@0
   144
		TUint& aRangeStart, TUint& aRangeEnd) const;
sl@0
   145
	IMPORT_C virtual TBool LineBreakPossible(TUint aPrevClass, TUint aNextClass,
sl@0
   146
		TBool aHaveSpaces) const;
sl@0
   147
	IMPORT_C virtual TBool GetLineBreakInContext(const TDesC16& aText,
sl@0
   148
		TInt aMinBreakPos, TInt aMaxBreakPos, TBool aForwards,
sl@0
   149
		TInt& aBreakPos) const;
sl@0
   150
	IMPORT_C virtual TBool IsHangingCharacter(TUint aChar) const;
sl@0
   151
	IMPORT_C TBool GetLineBreak(const TDesC16& aText,
sl@0
   152
		TInt aMinBreakPos, TInt aMaxBreakPos, TBool aForwards,
sl@0
   153
		MContingentLineBreaker* aCbDelegate,
sl@0
   154
		TInt& aBreakPos, TInt& aBreakPosAfterSpaces) const;
sl@0
   155
	IMPORT_C TBool GetLineBreakL(const TDesC16& aText,
sl@0
   156
		TInt aMinBreakPos, TInt aMaxBreakPos, TBool aForwards,
sl@0
   157
		MContingentLineBreakerL* aCbDelegate,
sl@0
   158
		TInt& aBreakPos, TInt& aBreakPosAfterSpaces) const;
sl@0
   159
	IMPORT_C virtual void* ExtendedInterface(TUid& aUid) const;
sl@0
   160
	};
sl@0
   161
sl@0
   162
sl@0
   163
class MContingentLineBreaker
sl@0
   164
/**
sl@0
   165
Used to determine the line breaks around pictures and other characters with 
sl@0
   166
the CB (contingent line break) class in situations where this operation cannot 
sl@0
   167
leave. 
sl@0
   168
@publishedAll
sl@0
   169
@released
sl@0
   170
*/
sl@0
   171
	{
sl@0
   172
public:
sl@0
   173
	/** Determines if a break is legal before the picture at aTextPosition. 
sl@0
   174
	
sl@0
   175
	@param aTextPosition The position of a character of line breaking class ECbLineBreakClass 
sl@0
   176
	in the text as supplied to MLineBreaker::GetLineBreak(), which may refer to 
sl@0
   177
	a picture.
sl@0
   178
	@param aPrecedingClass The class of the character preceding aTextPosition.
sl@0
   179
	@param aHasSpaces ETrue if spaces separate the preceding class from this.
sl@0
   180
	@return ETrue if a line break is legal here. */
sl@0
   181
	virtual TBool IsLegalBreakBefore(TInt aTextPosition, TInt aPrecedingClass,
sl@0
   182
		TBool aHasSpaces) = 0;
sl@0
   183
	/** Determines if a break is legal after the picture at aTextPosition. 
sl@0
   184
	
sl@0
   185
	@param aTextPosition The position of a character of line breaking class ECbLineBreakClass 
sl@0
   186
	in the text as supplied to MLineBreaker::GetLineBreak, which may refer to 
sl@0
   187
	a picture.
sl@0
   188
	@param aFollowingClass The class of the character immediately following aTextPosition.
sl@0
   189
	@param aHasSpaces ETrue if spaces separate the following class from this.
sl@0
   190
	@return ETrue if a line break is legal here. */
sl@0
   191
	virtual TBool IsLegalBreakAfter(TInt aTextPosition, TInt aFollowingClass,
sl@0
   192
		TBool aHasSpaces) = 0;
sl@0
   193
	};
sl@0
   194
sl@0
   195
sl@0
   196
sl@0
   197
class MContingentLineBreakerL
sl@0
   198
/**
sl@0
   199
Used to determine the line breaks around pictures and other characters with 
sl@0
   200
the CB (contingent line break) class in situations where this operation may 
sl@0
   201
leave. 
sl@0
   202
@publishedAll
sl@0
   203
@released
sl@0
   204
*/
sl@0
   205
	{
sl@0
   206
public:
sl@0
   207
	/** Determines if a break is legal before the picture at aTextPosition. 
sl@0
   208
	
sl@0
   209
	@param aTextPosition The position of a character of line breaking class ECbLineBreakClass 
sl@0
   210
	in the text as supplied to MLineBreaker::GetLineBreak(), which may refer to 
sl@0
   211
	a picture.
sl@0
   212
	@param aPrecedingClass The class of the character preceding aTextPosition.
sl@0
   213
	@param aHasSpaces ETrue if spaces separate the preceding class from this.
sl@0
   214
	@return ETrue if a line break is legal here. */
sl@0
   215
	virtual TBool IsLegalBreakBeforeL(TInt aTextPosition, TInt aPrecedingClass,
sl@0
   216
		TBool aHasSpaces) = 0;
sl@0
   217
	/** Determines if a break is legal after the picture at aTextPosition. 
sl@0
   218
	
sl@0
   219
	@param aTextPosition The position of a character of line breaking class ECbLineBreakClass 
sl@0
   220
	in the text as supplied to MLineBreaker::GetLineBreak(), which may refer to 
sl@0
   221
	a picture.
sl@0
   222
	@param aFollowingClass The class of the character immediately following aTextPosition.
sl@0
   223
	@param aHasSpaces ETrue if spaces separate the preceding class from this.
sl@0
   224
	@return ETrue if a line break is legal here. */
sl@0
   225
	virtual TBool IsLegalBreakAfterL(TInt aTextPosition, TInt aFollowingClass,
sl@0
   226
		TBool aHasSpaces) = 0;
sl@0
   227
	};
sl@0
   228
sl@0
   229
#endif