os/graphics/graphicsdeviceinterface/gdi/inc/LineBreak.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsdeviceinterface/gdi/inc/LineBreak.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,229 @@
     1.4 +// Copyright (c) 2002-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 "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.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 LINEBREAK_H_
    1.20 +#define LINEBREAK_H_
    1.21 +
    1.22 +#include <e32def.h>
    1.23 +class MContingentLineBreaker;
    1.24 +class MContingentLineBreakerL;
    1.25 +class TDesC16;
    1.26 +class TUid;
    1.27 +
    1.28 +
    1.29 +/**
    1.30 + This enumeration holds the possible panic codes that may be raised
    1.31 + by the LineBreak API on detecting an unrecoverable error.
    1.32 +@publishedAll
    1.33 +@released
    1.34 +*/
    1.35 +enum TLineBreakPanic
    1.36 +	{
    1.37 +	/** Not used */
    1.38 +	ELineBreakPanic_Unknown				= 0,
    1.39 +	/** Internal error, error found in data table */
    1.40 +	ELineBreakPanic_BadTable			= 1,
    1.41 +	/** One or more of the input parameters to the interface were invalid */
    1.42 +	ELineBreakPanic_InvalidInputParam	= 2,
    1.43 +	/** Raised when an output parameter breaks an API condition */
    1.44 +	ELineBreakPanic_InvalidOutputParam	= 3,
    1.45 +	};
    1.46 +
    1.47 +
    1.48 +
    1.49 +class MLineBreaker
    1.50 +/**
    1.51 +Customizes the Unicode line-breaking algorithm. 
    1.52 +@publishedAll
    1.53 +@released
    1.54 +*/
    1.55 +	{
    1.56 +public:
    1.57 +	/** The Unicode line breaking classes; see Unicode Technical Report 14.
    1.58 +	Not a named enumerated type, so that overriding classes may add new
    1.59 +	line breaking classes freely.
    1.60 +	The description of each constant gives the name of the line-breaking
    1.61 +	class, an example and a brief, imprecise description of the default
    1.62 +	behaviour of characters of that class.	 */
    1.63 +	enum
    1.64 +		{
    1.65 +		/** Opening Punctuation (e.g. '['). Breaking after prohibited. */
    1.66 +		EOpLineBreakClass,
    1.67 +		/** Closing Punctuation (e.g. ']'). Breaking before prohibited. */
    1.68 +		EClLineBreakClass,
    1.69 +		/** Ambiguous Quotes (e.g. '"'). Breaking before and after prohibited. */
    1.70 +		EQuLineBreakClass,
    1.71 +		/** Glue (e.g. Non-breaking space). Breaking before and after prohibited
    1.72 +		unless spaces are present. */
    1.73 +		EGlLineBreakClass,
    1.74 +		/** Non-Starter (e.g. small Japanese kana). Breaking before prohibited
    1.75 +		if no spaces present. */
    1.76 +		ENsLineBreakClass,
    1.77 +		/** Exclamation or Interrogation (e.g. '?'). Like closing punctuation
    1.78 +		except before Postfix or Non-starter. */
    1.79 +		EExLineBreakClass,
    1.80 +		/** Symbol (e.g. '/'. Like Alphabetic, but allows breaking before
    1.81 +		Alphabetic. */
    1.82 +		ESyLineBreakClass,
    1.83 +		/** Numeric Infix Separator (e.g. ','). Forbids breaking after any and before
    1.84 +		Numeric. */
    1.85 +		EIsLineBreakClass,
    1.86 +		/** Numeric Prefix (e.g. '$'). Forbids breaking before Numeric. */
    1.87 +		EPrLineBreakClass,
    1.88 +		/** Numeric Postfix (e.g. '%'). Forbids breaking after Numeric. */
    1.89 +		EPoLineBreakClass,
    1.90 +		/** Numeric (e.g. '1'). */
    1.91 +		ENuLineBreakClass,
    1.92 +		/** Alphabetic (e.g. 'a'). */
    1.93 +		EAlLineBreakClass,
    1.94 +		/** Ideographic (e.g. Japanese Kanji). Generally break before or after */
    1.95 +		EIdLineBreakClass,
    1.96 +		/** Inseparable (e.g. ellipsis). Forbid breaks between Inseparables. */
    1.97 +		EInLineBreakClass,
    1.98 +		/** Hyphen (e.g. '-'). Allows a break after except before Numeric. */
    1.99 +		EHyLineBreakClass,
   1.100 +		/** Break After. Generally allow a break after. Breaking between Break
   1.101 +		Afters not separated by spaces is prohibited. */
   1.102 +		EBaLineBreakClass,
   1.103 +		/** Break Before. Generally allow a break before. Breaking between Break
   1.104 +		Befores not separated by spaces is prohibited. */
   1.105 +		EBbLineBreakClass,
   1.106 +		/** Break Before and After. Generally allow a break before or after.
   1.107 +		Breaking between Break Before and Afters is prohibited, even if spaces
   1.108 +		are present. */
   1.109 +		EB2LineBreakClass,
   1.110 +		/** Zero-Width Space. Allow a break. */
   1.111 +		EZwLineBreakClass,
   1.112 +		/** Combining Mark. Takes on the class of its base class. */
   1.113 +		ECmLineBreakClass,
   1.114 +		/** Mandatory Break. */
   1.115 +		EBkLineBreakClass,
   1.116 +		/** Carriage Return. Break after unless part of a CRLF pair. */
   1.117 +		ECrLineBreakClass,
   1.118 +		/** Line Feed. Break after. */
   1.119 +		ELfLineBreakClass,
   1.120 +		/** Surrogate. Half of a surrogate pair. */
   1.121 +		ESgLineBreakClass,
   1.122 +		/** Contingent Break (e.g. embedded pictures). Uses external
   1.123 +		information */
   1.124 +		ECbLineBreakClass,
   1.125 +
   1.126 +		/** Space. Intervening characters of class Space are indicated by
   1.127 +		aHaveSpaces in LineBreakPossible. */
   1.128 +		ESpLineBreakClass, 
   1.129 +
   1.130 +		/** Complex Context (e.g. Thai). Runs of Complex Context are passed to
   1.131 +		GetLineBreakInContext. */
   1.132 +		ESaLineBreakClass,
   1.133 +
   1.134 +		/** Ambiguous. Characters of ambiguous East Asian width are treated
   1.135 +		as Alphabetic, unless they are resolved as being "Wide", in which case
   1.136 +		they are treated as Ideographic. */
   1.137 +		EAiLineBreakClass,
   1.138 +
   1.139 +		/** The Xx class is used when the class is unknown; e.g.; outside the provided context. */
   1.140 +		EXxLineBreakClass,
   1.141 +
   1.142 +		/** The number of Unicode line break classes. */
   1.143 +		ELineBreakClasses
   1.144 +		};
   1.145 +
   1.146 +	IMPORT_C virtual TUint LineBreakClass(TUint aCode,
   1.147 +		TUint& aRangeStart, TUint& aRangeEnd) const;
   1.148 +	IMPORT_C virtual TBool LineBreakPossible(TUint aPrevClass, TUint aNextClass,
   1.149 +		TBool aHaveSpaces) const;
   1.150 +	IMPORT_C virtual TBool GetLineBreakInContext(const TDesC16& aText,
   1.151 +		TInt aMinBreakPos, TInt aMaxBreakPos, TBool aForwards,
   1.152 +		TInt& aBreakPos) const;
   1.153 +	IMPORT_C virtual TBool IsHangingCharacter(TUint aChar) const;
   1.154 +	IMPORT_C TBool GetLineBreak(const TDesC16& aText,
   1.155 +		TInt aMinBreakPos, TInt aMaxBreakPos, TBool aForwards,
   1.156 +		MContingentLineBreaker* aCbDelegate,
   1.157 +		TInt& aBreakPos, TInt& aBreakPosAfterSpaces) const;
   1.158 +	IMPORT_C TBool GetLineBreakL(const TDesC16& aText,
   1.159 +		TInt aMinBreakPos, TInt aMaxBreakPos, TBool aForwards,
   1.160 +		MContingentLineBreakerL* aCbDelegate,
   1.161 +		TInt& aBreakPos, TInt& aBreakPosAfterSpaces) const;
   1.162 +	IMPORT_C virtual void* ExtendedInterface(TUid& aUid) const;
   1.163 +	};
   1.164 +
   1.165 +
   1.166 +class MContingentLineBreaker
   1.167 +/**
   1.168 +Used to determine the line breaks around pictures and other characters with 
   1.169 +the CB (contingent line break) class in situations where this operation cannot 
   1.170 +leave. 
   1.171 +@publishedAll
   1.172 +@released
   1.173 +*/
   1.174 +	{
   1.175 +public:
   1.176 +	/** Determines if a break is legal before the picture at aTextPosition. 
   1.177 +	
   1.178 +	@param aTextPosition The position of a character of line breaking class ECbLineBreakClass 
   1.179 +	in the text as supplied to MLineBreaker::GetLineBreak(), which may refer to 
   1.180 +	a picture.
   1.181 +	@param aPrecedingClass The class of the character preceding aTextPosition.
   1.182 +	@param aHasSpaces ETrue if spaces separate the preceding class from this.
   1.183 +	@return ETrue if a line break is legal here. */
   1.184 +	virtual TBool IsLegalBreakBefore(TInt aTextPosition, TInt aPrecedingClass,
   1.185 +		TBool aHasSpaces) = 0;
   1.186 +	/** Determines if a break is legal after the picture at aTextPosition. 
   1.187 +	
   1.188 +	@param aTextPosition The position of a character of line breaking class ECbLineBreakClass 
   1.189 +	in the text as supplied to MLineBreaker::GetLineBreak, which may refer to 
   1.190 +	a picture.
   1.191 +	@param aFollowingClass The class of the character immediately following aTextPosition.
   1.192 +	@param aHasSpaces ETrue if spaces separate the following class from this.
   1.193 +	@return ETrue if a line break is legal here. */
   1.194 +	virtual TBool IsLegalBreakAfter(TInt aTextPosition, TInt aFollowingClass,
   1.195 +		TBool aHasSpaces) = 0;
   1.196 +	};
   1.197 +
   1.198 +
   1.199 +
   1.200 +class MContingentLineBreakerL
   1.201 +/**
   1.202 +Used to determine the line breaks around pictures and other characters with 
   1.203 +the CB (contingent line break) class in situations where this operation may 
   1.204 +leave. 
   1.205 +@publishedAll
   1.206 +@released
   1.207 +*/
   1.208 +	{
   1.209 +public:
   1.210 +	/** Determines if a break is legal before the picture at aTextPosition. 
   1.211 +	
   1.212 +	@param aTextPosition The position of a character of line breaking class ECbLineBreakClass 
   1.213 +	in the text as supplied to MLineBreaker::GetLineBreak(), which may refer to 
   1.214 +	a picture.
   1.215 +	@param aPrecedingClass The class of the character preceding aTextPosition.
   1.216 +	@param aHasSpaces ETrue if spaces separate the preceding class from this.
   1.217 +	@return ETrue if a line break is legal here. */
   1.218 +	virtual TBool IsLegalBreakBeforeL(TInt aTextPosition, TInt aPrecedingClass,
   1.219 +		TBool aHasSpaces) = 0;
   1.220 +	/** Determines if a break is legal after the picture at aTextPosition. 
   1.221 +	
   1.222 +	@param aTextPosition The position of a character of line breaking class ECbLineBreakClass 
   1.223 +	in the text as supplied to MLineBreaker::GetLineBreak(), which may refer to 
   1.224 +	a picture.
   1.225 +	@param aFollowingClass The class of the character immediately following aTextPosition.
   1.226 +	@param aHasSpaces ETrue if spaces separate the preceding class from this.
   1.227 +	@return ETrue if a line break is legal here. */
   1.228 +	virtual TBool IsLegalBreakAfterL(TInt aTextPosition, TInt aFollowingClass,
   1.229 +		TBool aHasSpaces) = 0;
   1.230 +	};
   1.231 +
   1.232 +#endif