os/textandloc/textrendering/textformatting/group/CustomWrapping.rtf
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f1\fswiss\fcharset0\fprq2{\*\panose 020b0604020202020204}Arial;}
sl@0
     2
{\f2\fmodern\fcharset0\fprq1{\*\panose 02070309020205020404}Courier New;}{\f82\froman\fcharset238\fprq2 Times New Roman CE;}{\f83\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f85\froman\fcharset161\fprq2 Times New Roman Greek;}
sl@0
     3
{\f86\froman\fcharset162\fprq2 Times New Roman Tur;}{\f87\froman\fcharset186\fprq2 Times New Roman Baltic;}{\f88\fswiss\fcharset238\fprq2 Arial CE;}{\f89\fswiss\fcharset204\fprq2 Arial Cyr;}{\f91\fswiss\fcharset161\fprq2 Arial Greek;}
sl@0
     4
{\f92\fswiss\fcharset162\fprq2 Arial Tur;}{\f93\fswiss\fcharset186\fprq2 Arial Baltic;}{\f94\fmodern\fcharset238\fprq1 Courier New CE;}{\f95\fmodern\fcharset204\fprq1 Courier New Cyr;}{\f97\fmodern\fcharset161\fprq1 Courier New Greek;}
sl@0
     5
{\f98\fmodern\fcharset162\fprq1 Courier New Tur;}{\f99\fmodern\fcharset186\fprq1 Courier New Baltic;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;
sl@0
     6
\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{
sl@0
     7
\widctlpar\adjustright \fs20\cgrid \snext0 Normal;}{\s2\sb240\sa60\keepn\widctlpar\adjustright \b\i\f1\cgrid \sbasedon0 \snext0 heading 2;}{\*\cs10 \additive Default Paragraph Font;}}{\*\listtable{\list\listtemplateid134807567\listsimple{\listlevel
sl@0
     8
\levelnfc0\leveljc0\levelfollow0\levelstartat1\levelspace0\levelindent0{\leveltext\'02\'00.;}{\levelnumbers\'01;}\fi-360\li360\jclisttab\tx360 }{\listname ;}\listid275217526}}{\*\listoverridetable{\listoverride\listid275217526\listoverridecount0\ls1}}
sl@0
     9
{\info{\title Introduction}{\author Arunsakh Sachamuneewongse}{\operator Arunsakh Sachamuneewongse}{\creatim\yr2001\mo3\dy28\hr11\min50}{\revtim\yr2001\mo3\dy29\hr16\min33}{\version3}{\edmins146}{\nofpages3}{\nofwords928}{\nofchars5292}
sl@0
    10
{\*\company Symbian}{\nofcharsws0}{\vern113}}\paperw11906\paperh16838 \widowctrl\ftnbj\aenddoc\hyphcaps0\formshade\viewkind1\viewscale100\pgbrdrhead\pgbrdrfoot \fet0\sectd \linex0\endnhere\sectdefaultcl {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang
sl@0
    11
{\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang{\pntxtb (}
sl@0
    12
{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl9
sl@0
    13
\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}\pard\plain \widctlpar\adjustright \fs20\cgrid {Author:\tab  Arunsakh Sachamuneewongse\line Date: \tab 29}{\super th}{ March 2001
sl@0
    14
\par {\pntext\pard\plain\s2 \b\i\f1\lang1033\cgrid \hich\af1\dbch\af0\loch\f1 1.\tab}}\pard\plain \s2\fi-360\li360\sb240\sa60\keepn\widctlpar\jclisttab\tx360{\*\pn \pnlvlbody\ilvl0\ls1\pnrnot0\pndec\pnstart1\pnindent360\pnhang{\pntxta .}}
sl@0
    15
\ls1\outlinelevel1\adjustright \b\i\f1\cgrid {Introduction
sl@0
    16
\par }\pard\plain \widctlpar{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\adjustright \fs20\cgrid {
sl@0
    17
\par One of the functional requirements in 6.2, as requested by the Pearl and the Crystal DFRDs, was auto-
sl@0
    18
hyphenation. Since the Pearl and Crystal devices screens are smaller, they wanted to avoid a jagged white space on the right hand side of a text editable screen introduced when the lines are broken. The following was what was happening:
sl@0
    19
\par 
sl@0
    20
\par 
sl@0
    21
\par }\trowd \trgaph108\trleft1350\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrh\brdrs\brdrw10 \trbrdrv\brdrs\brdrw10 \clvertalt\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr
sl@0
    22
\brdrs\brdrw10 \cltxlrtb \cellx5130\pard \widctlpar\intbl{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\adjustright {An example of how
sl@0
    23
 in text boxes, the extremely long words at the end of a line are wrapped to the next line leaving an uneven jagged white space on the right hand side of the screen which is undesirable.\cell }\pard \widctlpar\intbl{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0
sl@0
    24
\pndec }\adjustright {\row }\pard \widctlpar{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\adjustright {
sl@0
    25
\par 
sl@0
    26
\par After a little consideration, it was decided that a fully fledge a
sl@0
    27
uto-hyphenation was out of the scope of the project for 6.2. An alternative solution was suggested, Custom Wrapping or Custom line breaking, which would allow a line to be broken in any way required to eliminate the jagged white spaces.  
sl@0
    28
\par 
sl@0
    29
\par 
sl@0
    30
\par {\pntext\pard\plain\s2 \b\i\f1\lang1033\cgrid \hich\af1\dbch\af0\loch\f1 2.\tab}}\pard\plain \s2\fi-360\li360\sb240\sa60\keepn\widctlpar\jclisttab\tx360{\*\pn \pnlvlbody\ilvl0\ls1\pnrnot0\pndec\pnstart1\pnindent360\pnhang{\pntxta .}}
sl@0
    31
\ls1\outlinelevel1\adjustright \b\i\f1\cgrid {Custom Wrapping
sl@0
    32
\par }\pard\plain \widctlpar\adjustright \fs20\cgrid {
sl@0
    33
\par The class }{\f2\cf2 MTmCustom}{ in FORM defines the four virtual functions involving line breaking. These four functions are: 
sl@0
    34
\par 
sl@0
    35
\par }{\cf2 TUint LineBreakClass(TUint aCode,TUint& aRangeStart,TUint& aRangeEnd) const;
sl@0
    36
\par TBool LineBreakPossible(TUint aPrevClass,TUint aNextClass,TBool aHaveSpaces) const;
sl@0
    37
\par TBool GetLineBreakInContext(const TDesC& aText,TInt aMinBreakPos,TInt aMaxBreakPos,
sl@0
    38
\par \tab \tab \tab \tab \tab TBool aForwards,TInt& aBreakPos) const;
sl@0
    39
\par TBool IsHangingCharacter(TUint aChar) const;
sl@0
    40
\par }{
sl@0
    41
\par The function LineBreakClass returns the assigned line breaking class value for the character aCode. It also returns the range of characters that share the same line breaking class, starting from aRangeStart till aRangeEnd. 
sl@0
    42
\par 
sl@0
    43
\par LineBreakPossible returns TRUE if a line break is possible between characters of the two specified classes. If aHaveSpaces is TRUE, one or more characters in ESpLineBreakClass was found between the characters in the two specified classes.
sl@0
    44
\par 
sl@0
    45
\par GetLineBreakInCo
sl@0
    46
ntext returns the first (if aForwards is TRUE) or last (if aForwards is FALSE) linebreak in aText, this must be in the range aMinBreakPos...aMaxBreakPos, which is a run of characters in the class ESaLineBreakClass, usually employed for Thai, Lao and Khmer
sl@0
    47
sl@0
    48
\par letters, because these scripts don't use word spaces and need dictionary-based line breaking.
sl@0
    49
\par The break position is returned in aBreakPos, which must be > 0 and < aText.Length() - 1.
sl@0
    50
\par Return TRUE if a break is found, FALSE otherwise.
sl@0
    51
\par 
sl@0
    52
\par IsHangingCharacter return TRUE if this character, aChar, can overhang the measured right end of the line.
sl@0
    53
\par 
sl@0
    54
\par To change the line breaking behaviour one/all of these functions need to be overridden. It was decided to provide a new Interface class to override these line-breaking functions. So a new interface was added in FORM. This is the class MFormCustomWrap.
sl@0
    55
sl@0
    56
\par 
sl@0
    57
\par 
sl@0
    58
\par 
sl@0
    59
\par 
sl@0
    60
\par 
sl@0
    61
\par }{\cf2 class MFormCustomWrap
sl@0
    62
\par \tab \{
sl@0
    63
\par public:
sl@0
    64
\par \tab IMPORT_C virtual TUint LineBreakClass(TUint aCode,TUint& aRangeStart,TUint& aRangeEnd) const;
sl@0
    65
\par \tab IMPORT_C virtual TBool LineBreakPossible(TUint aPrevClass,TUint aNextClass,TBool aHaveSpaces) const;
sl@0
    66
\par \tab IMPORT_C virtual TBool GetLineBreakInContext(const TDesC& aText,TInt aMinBreakPos,TInt aMaxBreakPos,TBool aForwards,TInt& aBreakPos) const;
sl@0
    67
\par \tab IMPORT_C virtual TBool IsHangingCharacter(TUint aChar) const;
sl@0
    68
\par private:
sl@0
    69
\par \tab IMPORT_C virtual void MFormCustomWrap_Reserved_1();
sl@0
    70
\par \tab IMPORT_C virtual void MFormCustomWrap_Reserved_2();\tab 
sl@0
    71
\par \tab \};
sl@0
    72
\par }{
sl@0
    73
\par Besides adding the new interface, a few more changes were made in FORM to allow custom wrapping to take place. The following were the changes made in FORM. 
sl@0
    74
\par 
sl@0
    75
\par 
sl@0
    76
\par A new member was added in class }{\f2\cf2 TLayDocTextSource}{, which is internal to Symbian. This class  is derived from the class }{\f2\cf2 MTmSource}{, which is derived from }{\f2\cf2 MTmCustom}{ where the line breaking functions are defined. 
sl@0
    77
\par 
sl@0
    78
\par }{\cf2 const MFormCustomWrap* iCustomWrap;\tab      // if non-null, points to custom wrapping routines
sl@0
    79
\par }{
sl@0
    80
\par Also added in the class TLayDocTextSource were 4 function overrides 
sl@0
    81
\par 
sl@0
    82
\par }{\cf2 TUint LineBreakClass(TUint aCode,TUint& aRangeStart,TUint& aRangeEnd) const;
sl@0
    83
\par TBool LineBreakPossible(TUint aPrevClass,TUint aNextClass,TBool aHaveSpaces) const;
sl@0
    84
\par TBool GetLineBreakInContext(const TDesC& aText,TInt aMinBreakPos,TInt aMaxBreakPos,
sl@0
    85
\par \tab \tab \tab \tab \tab TBool aForwards,TInt& aBreakPos) const;
sl@0
    86
\par TBool IsHangingCharacter(TUint aChar) const;}{
sl@0
    87
\par 
sl@0
    88
\par If iCustomWrap is set then the override implementations are called, else the base implementation of these functions are called, which is the implementation in MTmCustom. 
sl@0
    89
\par 
sl@0
    90
\par 2 new functions were added in class CTextLayout: 
sl@0
    91
\par 
sl@0
    92
\par }{\cf2 IMPORT_C void SetCustomWrap(const MFormCustomWrap* aCustomWrap);
sl@0
    93
\par IMPORT_C const MFormCustomWrap* CustomWrap() const;
sl@0
    94
\par }{
sl@0
    95
\par The class CTextLayout is the lowest-level text formatting class provided by FORM. It has as its member a pointer to TLayDocTextSource, iSource. 
sl@0
    96
\par 
sl@0
    97
\par }{\cf2 SetCustomWrap(const MFormCustomWrap* aCustomWrap)}{ sets 
sl@0
    98
\par iSource.iCustomWrap = aCustomWrap and  }{\cf2 CustomWrap()}{ returns iSource.iCustomWrap. 
sl@0
    99
\par 
sl@0
   100
\par 
sl@0
   101
\par In order to use the custom wrapping interface, a class has to implement the custom wrapping interface MFormCustomWrap. That class then needs to be set as the custom wrapper by passing a pointer to that class in the function SetCustomWrap in CTextLayout.  
sl@0
   102
sl@0
   103
\par 
sl@0
   104
\par \line 
sl@0
   105
\par 
sl@0
   106
\par 
sl@0
   107
\par 
sl@0
   108
\par 
sl@0
   109
\par The following are the changes made in UIKLAF and UIKON to allow the text editable window \endash  Edwin \endash  to eliminate the jagged white space on the right hand side of the screen by implementing the custom wrapping interface. 
sl@0
   110
\par 
sl@0
   111
\par A new class implementing the MFormCustomWrap interface was added in the UIKLAFGT component. 
sl@0
   112
\par 
sl@0
   113
\par }{\cf2 // Lafmain.h
sl@0
   114
\par class CLafEdwinCustomWrapBase : public CBase, public MFormCustomWrap
sl@0
   115
\par \tab \{
sl@0
   116
\par \'85
sl@0
   117
\par \'85
sl@0
   118
\par \tab IMPORT_C TBool LineBreakPossible(TUint aPrevClass,TUint aNextClass,TBool aHaveSpaces) const;
sl@0
   119
\par \'85
sl@0
   120
\par \'85
sl@0
   121
\par \tab \};
sl@0
   122
\par }{
sl@0
   123
\par 
sl@0
   124
\par CLafEdwinCustomWrapBase implements MFormCustomWrap and overrides the interfaces virtual functions. Her
sl@0
   125
e I have shown one of the functions that have been overridden. LineBreakPossible returns TRUE if it is possible to break line between the two classes. The overridden implementation returns TRUE all the time, thus allowing a line break anywhere. 
sl@0
   126
\par 
sl@0
   127
\par In UIKON, in the class CEikEdwin the following changes were made.
sl@0
   128
\par 
sl@0
   129
\par A New flag was added to the enum TFlags: - }{\cf2 ENoCustomWrap\tab  \tab =0x02000000
sl@0
   130
\par 
sl@0
   131
\par }{CEikEdwin has a pointer to CTextLayout \endash  iLayout.  So what was needed now was to add a new member data to CEikEdwin, a pointer
sl@0
   132
 to CLafEdwinCustomWrapBase and call CTextLayouts SetCustomWrap function passing the pointer to CLafEdwinCustomWrapBase.  When creating a CEikEdwin, the flag ENoCustomWrap can be used to establish whether the Edwin is allowed custom wrapping or not.  
sl@0
   133
sl@0
   134
\par }}