#include <nodetxtl.h>
Public Member Functions | |
FormatState (MILLIPOINT AvailableWidth, BOOL SetPositions, VisibleTextNode *pFirstNode, MILLIPOINT Indent, MILLIPOINT _CharPosOffset, MILLIPOINT _ExtraOnChars, MILLIPOINT _ExtraOnSpaces) | |
void | AdvanceBy (MILLIPOINT Advance, BOOL IsADecimalPoint) |
Account for a char with width CharWidth to be fitted into the current line. See also: TextLine::FindBreakChar for a description of the formatting algorithm used. | |
BOOL | FinishTabSection (VisibleTextNode *pLastFormattedNode, BOOL IsLastTabSection) |
This routine is called when a tab or the end of the line is encountered, so the text after the previous tab (or the start of the line) can be finally formatted. The Width/Advance of the Tab is always set and if SetCharPositions is TRUE, then all the character positions are set. | |
BOOL | IsAvailable (MILLIPOINT CharWidth, BOOL IsATab, BOOL IsADecimalPoint) |
Test whether a char with width CharWidth can be fitted into the current line. | |
Public Attributes | |
const BOOL | SetCharPositions |
const MILLIPOINT | FitWidth |
VisibleTextNode *const | pFirstVTN |
const MILLIPOINT | CharPosOffset |
const MILLIPOINT | ExtraOnChars |
const MILLIPOINT | ExtraOnSpaces |
MILLIPOINT | Width |
TxtTabType | ActiveTabType |
MILLIPOINT | ActiveTabPos |
VisibleTextNode * | pLastTabVTN |
MILLIPOINT | AnchorPos |
MILLIPOINT | RemainingSpace |
WCHAR | DecimalPointChar |
BOOL | DecimalPointFound |
Definition at line 198 of file nodetxtl.h.
|
Definition at line 231 of file nodetxtl.h. 00233 : 00234 SetCharPositions(SetPositions), 00235 FitWidth(AvailableWidth), pFirstVTN(pFirstNode), 00236 CharPosOffset(_CharPosOffset), 00237 ExtraOnChars(_ExtraOnChars), ExtraOnSpaces(_ExtraOnSpaces), 00238 Width(Indent), ActiveTabType(LeftTab), ActiveTabPos(0), 00239 pLastTabVTN(NULL), AnchorPos(Indent) {}; void AdvanceBy(MILLIPOINT Advance, BOOL IsADecimalPoint);
|
|
Account for a char with width CharWidth to be fitted into the current line. See also: TextLine::FindBreakChar for a description of the formatting algorithm used.
Definition at line 1133 of file nodetxtl.cpp. 01134 { 01135 // Note: This routine may only update Width and RemainingSpace, otherwise 01136 // the backtracking in IsAvailable() does not work as expected. 01137 if (ActiveTabType == CentreTab && RemainingSpace > 0) 01138 { 01139 MILLIPOINT SpaceToLeftUsed = 0; 01140 // half the width is distributed into RemainingSpace, if it is big enough 01141 if (RemainingSpace >= CharWidth / 2) 01142 { 01143 // half the width fully fits into RemainingSpace 01144 SpaceToLeftUsed = CharWidth / 2; 01145 } 01146 else 01147 { 01148 // does not fit, so use up all of RemainingSpace 01149 SpaceToLeftUsed = RemainingSpace; 01150 } 01151 // distribute some of the character to the left 01152 RemainingSpace -= SpaceToLeftUsed; 01153 // and the remainder to the right 01154 Width += CharWidth - SpaceToLeftUsed; 01155 } 01156 else if ((ActiveTabType == RightTab || (ActiveTabType == DecimalTab && !DecimalPointFound 01157 && !IsADecimalPoint)) 01158 && RemainingSpace > 0) 01159 { 01160 if (RemainingSpace >= CharWidth) RemainingSpace -= CharWidth; 01161 else 01162 { 01163 Width += CharWidth - RemainingSpace; 01164 RemainingSpace = 0; 01165 } 01166 } 01167 else 01168 { 01169 // We end up here if: 01170 // - the last tab was left tab, or 01171 // - the last tab was a decimal tab and we have already found the decimal point, or 01172 // - the last tab was a decimal tab and this is a decimal point character (NB. - the 01173 // decimal point is always formatted to the right of the tab position), or, finally, 01174 // - this is any kind of tab and we have no more remaining space to the left of it 01175 // In all these cases, we simply format the character to the right of the current position, 01176 // which is the easiest thing to do anyway 01177 Width += CharWidth; 01178 } 01179 }
|
|
This routine is called when a tab or the end of the line is encountered, so the text after the previous tab (or the start of the line) can be finally formatted. The Width/Advance of the Tab is always set and if SetCharPositions is TRUE, then all the character positions are set.
Definition at line 1086 of file nodetxtl.cpp. 01087 { 01088 // first, set the Tab character's width - this is only necessary for non-Left tabs 01089 // (for left tabs we have already set it when encountering the tab) 01090 if (ActiveTabType != LeftTab) 01091 { 01092 // pLastTabVTN can only be undefined for ActiveTabType == LeftTab 01093 ((HorizontalTab*)pLastTabVTN)->SetCharWidth(RemainingSpace); 01094 ((HorizontalTab*)pLastTabVTN)->SetCharAdvance(RemainingSpace); 01095 } 01096 if (!SetCharPositions) return TRUE; 01097 01098 // full formatting desired 01099 VisibleTextNode* pVTN = pLastTabVTN ? pLastTabVTN : pFirstVTN; 01100 MILLIPOINT Pos = AnchorPos; 01101 do 01102 { 01103 ERROR2IF(pVTN == NULL, FALSE, "FinishTabSection - unexpected end of line"); 01104 if (Pos + CharPosOffset != pVTN->GetPosInLine()) 01105 { 01106 pVTN->SetPosInLine(Pos + CharPosOffset); 01107 pVTN->FlagNodeAndDescendantsAffectedAndParentsHaveDescendantAffected(); 01108 } 01109 Pos += pVTN->GetCharAdvance(); 01110 01111 if (IsLastTabSection && IS_A(pVTN,TextChar)) 01112 Pos += ExtraOnChars; 01113 if (IsLastTabSection && pVTN->IsASpace()) 01114 Pos += ExtraOnSpaces; 01115 if (pVTN == pLastFormattedNode) break; 01116 pVTN = pVTN->FindNextVTNInLine(); 01117 } while(1); 01118 return TRUE; 01119 }
|
|
Test whether a char with width CharWidth can be fitted into the current line.
Definition at line 1193 of file nodetxtl.cpp. 01194 { 01195 // If the full CharWidth still fits, then we can return TRUE straight away 01196 // without having to look at the active tab type 01197 if (Width + CharWidth < FitWidth) return TRUE; 01198 // If the above did not succeed there is no hope in the standard case (last 01199 // tab was left tab or the beginning of the line) - the same is true for a 01200 // tab character because it will start a new tab section, so none of its width 01201 // can go to the left of the current formatting position 01202 if (ActiveTabType == LeftTab || IsATab) return FALSE; 01203 01204 // For other tab types, things are a bit more complicated because half or 01205 // all of the character can go to the left of the tab stop. Rather than 01206 // duplicating all the AdvanceBy code, we simply advance and backtrack. 01207 MILLIPOINT OldWidth = Width; 01208 MILLIPOINT OldRemainingSpace = RemainingSpace; 01209 AdvanceBy(CharWidth, IsADecimalPoint); 01210 MILLIPOINT NewWidth = Width; 01211 Width = OldWidth; 01212 RemainingSpace = OldRemainingSpace; 01213 return NewWidth < FitWidth; 01214 }
|
|
Definition at line 213 of file nodetxtl.h. |
|
Definition at line 212 of file nodetxtl.h. |
|
Definition at line 219 of file nodetxtl.h. |
|
Definition at line 204 of file nodetxtl.h. |
|
Definition at line 227 of file nodetxtl.h. |
|
Definition at line 228 of file nodetxtl.h. |
|
Definition at line 205 of file nodetxtl.h. |
|
Definition at line 206 of file nodetxtl.h. |
|
Definition at line 202 of file nodetxtl.h. |
|
Definition at line 203 of file nodetxtl.h. |
|
Definition at line 214 of file nodetxtl.h. |
|
Definition at line 224 of file nodetxtl.h. |
|
Definition at line 201 of file nodetxtl.h. |
|
Definition at line 207 of file nodetxtl.h. |