OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../../include/fxedit/fxet_stub.h" | 7 #include "../../include/fxedit/fxet_stub.h" |
8 #include "../../include/fxedit/fxet_edit.h" | 8 #include "../../include/fxedit/fxet_edit.h" |
9 | 9 |
10 #define FX_EDIT_UNDO_MAXITEM 10000 | 10 #define FX_EDIT_UNDO_MAXITEM 10000 |
11 | 11 |
12 /* ---------------------------- CFX_Edit_Iterator ---------------------------- *
/ | 12 /* ---------------------------- CFX_Edit_Iterator ---------------------------- |
13 | 13 */ |
14 CFX_Edit_Iterator::CFX_Edit_Iterator(CFX_Edit * pEdit,IPDF_VariableText_Iterator
* pVTIterator) : | 14 |
15 m_pEdit(pEdit), | 15 CFX_Edit_Iterator::CFX_Edit_Iterator(CFX_Edit* pEdit, |
16 m_pVTIterator(pVTIterator) | 16 IPDF_VariableText_Iterator* pVTIterator) |
17 { | 17 : m_pEdit(pEdit), m_pVTIterator(pVTIterator) { |
18 } | 18 } |
19 | 19 |
20 CFX_Edit_Iterator::~CFX_Edit_Iterator() | 20 CFX_Edit_Iterator::~CFX_Edit_Iterator() { |
21 { | 21 } |
22 } | 22 |
23 | 23 FX_BOOL CFX_Edit_Iterator::NextWord() { |
24 FX_BOOL CFX_Edit_Iterator::NextWord() | 24 ASSERT(m_pVTIterator != NULL); |
25 { | 25 |
26 ASSERT(m_pVTIterator != NULL); | 26 return m_pVTIterator->NextWord(); |
27 | 27 } |
28 return m_pVTIterator->NextWord(); | 28 |
29 } | 29 FX_BOOL CFX_Edit_Iterator::NextLine() { |
30 | 30 ASSERT(m_pVTIterator != NULL); |
31 FX_BOOL CFX_Edit_Iterator::NextLine() | 31 |
32 { | 32 return m_pVTIterator->NextLine(); |
33 ASSERT(m_pVTIterator != NULL); | 33 } |
34 | 34 |
35 return m_pVTIterator->NextLine(); | 35 FX_BOOL CFX_Edit_Iterator::NextSection() { |
36 } | 36 ASSERT(m_pVTIterator != NULL); |
37 | 37 |
38 FX_BOOL CFX_Edit_Iterator::NextSection() | 38 return m_pVTIterator->NextSection(); |
39 { | 39 } |
40 ASSERT(m_pVTIterator != NULL); | 40 |
41 | 41 FX_BOOL CFX_Edit_Iterator::PrevWord() { |
42 return m_pVTIterator->NextSection(); | 42 ASSERT(m_pVTIterator != NULL); |
43 } | 43 |
44 | 44 return m_pVTIterator->PrevWord(); |
45 FX_BOOL CFX_Edit_Iterator::PrevWord() | 45 } |
46 { | 46 |
47 ASSERT(m_pVTIterator != NULL); | 47 FX_BOOL CFX_Edit_Iterator::PrevLine() { |
48 | 48 ASSERT(m_pVTIterator != NULL); |
49 return m_pVTIterator->PrevWord(); | 49 |
50 } | 50 return m_pVTIterator->PrevLine(); |
51 | 51 } |
52 FX_BOOL CFX_Edit_Iterator::PrevLine() | 52 |
53 { | 53 FX_BOOL CFX_Edit_Iterator::PrevSection() { |
54 ASSERT(m_pVTIterator != NULL); | 54 ASSERT(m_pVTIterator != NULL); |
55 | 55 |
56 return m_pVTIterator->PrevLine(); | 56 return m_pVTIterator->PrevSection(); |
57 } | 57 } |
58 | 58 |
59 FX_BOOL CFX_Edit_Iterator::PrevSection() | 59 FX_BOOL CFX_Edit_Iterator::GetWord(CPVT_Word& word) const { |
60 { | 60 ASSERT(m_pEdit != NULL); |
61 ASSERT(m_pVTIterator != NULL); | 61 ASSERT(m_pVTIterator != NULL); |
62 | 62 |
63 return m_pVTIterator->PrevSection(); | 63 if (m_pVTIterator->GetWord(word)) { |
64 } | 64 word.ptWord = m_pEdit->VTToEdit(word.ptWord); |
65 | 65 return TRUE; |
66 FX_BOOL CFX_Edit_Iterator::GetWord(CPVT_Word & word) const | 66 } |
67 { | 67 |
68 ASSERT(m_pEdit != NULL); | 68 return FALSE; |
69 ASSERT(m_pVTIterator != NULL); | 69 } |
70 | 70 |
71 if (m_pVTIterator->GetWord(word)) | 71 FX_BOOL CFX_Edit_Iterator::GetLine(CPVT_Line& line) const { |
72 { | 72 ASSERT(m_pEdit != NULL); |
73 word.ptWord = m_pEdit->VTToEdit(word.ptWord); | 73 ASSERT(m_pVTIterator != NULL); |
74 return TRUE; | 74 |
75 } | 75 if (m_pVTIterator->GetLine(line)) { |
76 | 76 line.ptLine = m_pEdit->VTToEdit(line.ptLine); |
77 return FALSE; | 77 return TRUE; |
78 } | 78 } |
79 | 79 |
80 FX_BOOL CFX_Edit_Iterator::GetLine(CPVT_Line & line) const | 80 return FALSE; |
81 { | 81 } |
82 ASSERT(m_pEdit != NULL); | 82 |
83 ASSERT(m_pVTIterator != NULL); | 83 FX_BOOL CFX_Edit_Iterator::GetSection(CPVT_Section& section) const { |
84 | 84 ASSERT(m_pEdit != NULL); |
85 if (m_pVTIterator->GetLine(line)) | 85 ASSERT(m_pVTIterator != NULL); |
86 { | 86 |
87 line.ptLine = m_pEdit->VTToEdit(line.ptLine); | 87 if (m_pVTIterator->GetSection(section)) { |
88 return TRUE; | 88 section.rcSection = m_pEdit->VTToEdit(section.rcSection); |
89 } | 89 return TRUE; |
90 | 90 } |
91 return FALSE; | 91 |
92 } | 92 return FALSE; |
93 | 93 } |
94 FX_BOOL CFX_Edit_Iterator::GetSection(CPVT_Section & section) const | 94 |
95 { | 95 void CFX_Edit_Iterator::SetAt(FX_INT32 nWordIndex) { |
96 ASSERT(m_pEdit != NULL); | 96 ASSERT(m_pVTIterator != NULL); |
97 ASSERT(m_pVTIterator != NULL); | 97 |
98 | 98 m_pVTIterator->SetAt(nWordIndex); |
99 if (m_pVTIterator->GetSection(section)) | 99 } |
100 { | 100 |
101 section.rcSection = m_pEdit->VTToEdit(section.rcSection); | 101 void CFX_Edit_Iterator::SetAt(const CPVT_WordPlace& place) { |
102 return TRUE; | 102 ASSERT(m_pVTIterator != NULL); |
103 } | 103 |
104 | 104 m_pVTIterator->SetAt(place); |
105 return FALSE; | 105 } |
106 } | 106 |
107 | 107 const CPVT_WordPlace& CFX_Edit_Iterator::GetAt() const { |
108 void CFX_Edit_Iterator::SetAt(FX_INT32 nWordIndex) | 108 ASSERT(m_pVTIterator != NULL); |
109 { | 109 |
110 ASSERT(m_pVTIterator != NULL); | 110 return m_pVTIterator->GetAt(); |
111 | 111 } |
112 m_pVTIterator->SetAt(nWordIndex); | 112 |
113 } | 113 IFX_Edit* CFX_Edit_Iterator::GetEdit() const { |
114 | 114 return m_pEdit; |
115 void CFX_Edit_Iterator::SetAt(const CPVT_WordPlace & place) | 115 } |
116 { | 116 |
117 ASSERT(m_pVTIterator != NULL); | 117 /* --------------------------- CFX_Edit_Provider ------------------------------- |
118 | 118 */ |
119 m_pVTIterator->SetAt(place); | 119 |
120 } | 120 CFX_Edit_Provider::CFX_Edit_Provider(IFX_Edit_FontMap* pFontMap) |
121 | 121 : m_pFontMap(pFontMap) { |
122 const CPVT_WordPlace & CFX_Edit_Iterator::GetAt() const | 122 ASSERT(m_pFontMap != NULL); |
123 { | 123 } |
124 ASSERT(m_pVTIterator != NULL); | 124 |
125 | 125 CFX_Edit_Provider::~CFX_Edit_Provider() { |
126 return m_pVTIterator->GetAt(); | 126 } |
127 } | 127 |
128 | 128 IFX_Edit_FontMap* CFX_Edit_Provider::GetFontMap() { |
129 IFX_Edit* CFX_Edit_Iterator::GetEdit() const | 129 return m_pFontMap; |
130 { | 130 } |
131 return m_pEdit; | 131 |
132 } | 132 FX_INT32 CFX_Edit_Provider::GetCharWidth(FX_INT32 nFontIndex, |
133 | 133 FX_WORD word, |
134 /* --------------------------- CFX_Edit_Provider -------------------------------
*/ | 134 FX_INT32 nWordStyle) { |
135 | 135 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) { |
136 CFX_Edit_Provider::CFX_Edit_Provider(IFX_Edit_FontMap * pFontMap) : m_pFontMap(p
FontMap) | 136 FX_DWORD charcode = word; |
137 { | 137 |
138 ASSERT(m_pFontMap != NULL); | 138 if (pPDFFont->IsUnicodeCompatible()) |
139 } | 139 charcode = pPDFFont->CharCodeFromUnicode(word); |
140 | 140 else |
141 CFX_Edit_Provider::~CFX_Edit_Provider() | 141 charcode = m_pFontMap->CharCodeFromUnicode(nFontIndex, word); |
142 { | 142 |
143 } | 143 if (charcode != -1) |
144 | 144 return pPDFFont->GetCharWidthF(charcode); |
145 IFX_Edit_FontMap* CFX_Edit_Provider::GetFontMap() | 145 } |
146 { | 146 |
147 return m_pFontMap; | 147 return 0; |
148 } | 148 } |
149 | 149 |
150 FX_INT32 CFX_Edit_Provider::GetCharWidth(FX_INT32 nFontIndex, FX_WORD word, FX_I
NT32 nWordStyle) | 150 FX_INT32 CFX_Edit_Provider::GetTypeAscent(FX_INT32 nFontIndex) { |
151 { | 151 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) |
152 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) | 152 return pPDFFont->GetTypeAscent(); |
153 { | 153 |
154 FX_DWORD charcode = word; | 154 return 0; |
155 | 155 } |
156 if (pPDFFont->IsUnicodeCompatible()) | 156 |
157 charcode = pPDFFont->CharCodeFromUnicode(word); | 157 FX_INT32 CFX_Edit_Provider::GetTypeDescent(FX_INT32 nFontIndex) { |
158 else | 158 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) |
159 charcode = m_pFontMap->CharCodeFromUnicode(nFontIndex, w
ord); | 159 return pPDFFont->GetTypeDescent(); |
160 | 160 |
161 if (charcode != -1) | 161 return 0; |
162 return pPDFFont->GetCharWidthF(charcode); | 162 } |
163 } | 163 |
164 | 164 FX_INT32 CFX_Edit_Provider::GetWordFontIndex(FX_WORD word, |
165 return 0; | 165 FX_INT32 charset, |
166 } | 166 FX_INT32 nFontIndex) { |
167 | 167 return m_pFontMap->GetWordFontIndex(word, charset, nFontIndex); |
168 FX_INT32 CFX_Edit_Provider::GetTypeAscent(FX_INT32 nFontIndex) | 168 } |
169 { | 169 |
170 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) | 170 FX_INT32 CFX_Edit_Provider::GetDefaultFontIndex() { |
171 return pPDFFont->GetTypeAscent(); | 171 return 0; |
172 | 172 } |
173 return 0; | 173 |
174 } | 174 FX_BOOL CFX_Edit_Provider::IsLatinWord(FX_WORD word) { |
175 | 175 return FX_EDIT_ISLATINWORD(word); |
176 FX_INT32 CFX_Edit_Provider::GetTypeDescent(FX_INT32 nFontIndex) | 176 } |
177 { | 177 |
178 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) | 178 /* --------------------------------- CFX_Edit_Refresh |
179 return pPDFFont->GetTypeDescent(); | 179 * --------------------------------- */ |
180 | 180 |
181 return 0; | 181 CFX_Edit_Refresh::CFX_Edit_Refresh() { |
182 } | 182 } |
183 | 183 |
184 FX_INT32 CFX_Edit_Provider::GetWordFontIndex(FX_WORD word, FX_INT32 charset, FX_
INT32 nFontIndex) | 184 CFX_Edit_Refresh::~CFX_Edit_Refresh() { |
185 { | 185 } |
186 return m_pFontMap->GetWordFontIndex(word,charset,nFontIndex); | 186 |
187 } | 187 void CFX_Edit_Refresh::BeginRefresh() { |
188 | 188 m_RefreshRects.Empty(); |
189 FX_INT32 CFX_Edit_Provider::GetDefaultFontIndex() | 189 m_OldLineRects = m_NewLineRects; |
190 { | 190 } |
191 return 0; | 191 |
192 } | 192 void CFX_Edit_Refresh::Push(const CPVT_WordRange& linerange, |
193 | 193 const CPDF_Rect& rect) { |
194 FX_BOOL CFX_Edit_Provider::IsLatinWord(FX_WORD word) | 194 m_NewLineRects.Add(linerange, rect); |
195 { | 195 } |
196 return FX_EDIT_ISLATINWORD(word); | 196 |
197 } | 197 void CFX_Edit_Refresh::NoAnalyse() { |
198 | 198 { |
199 /* --------------------------------- CFX_Edit_Refresh --------------------------
------- */ | 199 for (FX_INT32 i = 0, sz = m_OldLineRects.GetSize(); i < sz; i++) |
200 | 200 if (CFX_Edit_LineRect* pOldRect = m_OldLineRects.GetAt(i)) |
201 CFX_Edit_Refresh::CFX_Edit_Refresh() | 201 m_RefreshRects.Add(pOldRect->m_rcLine); |
202 { | 202 } |
203 } | 203 |
204 | 204 { |
205 CFX_Edit_Refresh::~CFX_Edit_Refresh() | 205 for (FX_INT32 i = 0, sz = m_NewLineRects.GetSize(); i < sz; i++) |
206 { | 206 if (CFX_Edit_LineRect* pNewRect = m_NewLineRects.GetAt(i)) |
207 } | 207 m_RefreshRects.Add(pNewRect->m_rcLine); |
208 | 208 } |
209 void CFX_Edit_Refresh::BeginRefresh() | 209 } |
210 { | 210 |
211 m_RefreshRects.Empty(); | 211 void CFX_Edit_Refresh::Analyse(FX_INT32 nAlignment) { |
212 m_OldLineRects = m_NewLineRects; | 212 FX_BOOL bLineTopChanged = FALSE; |
213 } | 213 CPDF_Rect rcResult; |
214 | 214 FX_FLOAT fWidthDiff; |
215 void CFX_Edit_Refresh::Push(const CPVT_WordRange & linerange,const CPDF_Rect & r
ect) | 215 |
216 { | 216 FX_INT32 szMax = |
217 m_NewLineRects.Add(linerange,rect); | 217 FX_EDIT_MAX(m_OldLineRects.GetSize(), m_NewLineRects.GetSize()); |
218 } | 218 FX_INT32 i = 0; |
219 | 219 |
220 void CFX_Edit_Refresh::NoAnalyse() | 220 while (i < szMax) { |
221 { | 221 CFX_Edit_LineRect* pOldRect = m_OldLineRects.GetAt(i); |
222 { | 222 CFX_Edit_LineRect* pNewRect = m_NewLineRects.GetAt(i); |
223 for (FX_INT32 i = 0, sz = m_OldLineRects.GetSize(); i < sz; i++) | 223 |
224 if (CFX_Edit_LineRect * pOldRect = m_OldLineRects.GetAt(
i)) | 224 if (pOldRect) { |
225 m_RefreshRects.Add(pOldRect->m_rcLine); | 225 if (pNewRect) { |
226 } | 226 if (bLineTopChanged) { |
227 | 227 rcResult = pOldRect->m_rcLine; |
228 { | 228 rcResult.Union(pNewRect->m_rcLine); |
229 for (FX_INT32 i = 0, sz = m_NewLineRects.GetSize(); i < sz; i++) | 229 m_RefreshRects.Add(rcResult); |
230 if (CFX_Edit_LineRect * pNewRect = m_NewLineRects.GetAt(
i)) | 230 } else { |
231 m_RefreshRects.Add(pNewRect->m_rcLine); | 231 if (*pNewRect != *pOldRect) { |
232 } | 232 if (!pNewRect->IsSameTop(*pOldRect) || |
233 } | 233 !pNewRect->IsSameHeight(*pOldRect)) { |
234 | 234 bLineTopChanged = TRUE; |
235 void CFX_Edit_Refresh::Analyse(FX_INT32 nAlignment) | 235 continue; |
236 { | 236 } |
237 FX_BOOL bLineTopChanged = FALSE; | 237 |
238 CPDF_Rect rcResult; | 238 if (nAlignment == 0) { |
239 FX_FLOAT fWidthDiff; | 239 if (pNewRect->m_wrLine.BeginPos != pOldRect->m_wrLine.BeginPos) { |
240 | 240 rcResult = pOldRect->m_rcLine; |
241 FX_INT32 szMax = FX_EDIT_MAX(m_OldLineRects.GetSize(),m_NewLineRects.Get
Size()); | 241 rcResult.Union(pNewRect->m_rcLine); |
242 FX_INT32 i = 0; | 242 m_RefreshRects.Add(rcResult); |
243 | 243 } else { |
244 while (i < szMax) | 244 if (!pNewRect->IsSameLeft(*pOldRect)) { |
245 { | 245 rcResult = pOldRect->m_rcLine; |
246 CFX_Edit_LineRect * pOldRect = m_OldLineRects.GetAt(i); | 246 rcResult.Union(pNewRect->m_rcLine); |
247 CFX_Edit_LineRect * pNewRect = m_NewLineRects.GetAt(i); | 247 } else { |
248 | 248 fWidthDiff = |
249 if (pOldRect) | 249 pNewRect->m_rcLine.Width() - pOldRect->m_rcLine.Width(); |
250 { | 250 rcResult = pNewRect->m_rcLine; |
251 if (pNewRect) | 251 if (fWidthDiff > 0.0f) |
252 { | 252 rcResult.left = rcResult.right - fWidthDiff; |
253 if (bLineTopChanged) | 253 else { |
254 { | 254 rcResult.left = rcResult.right; |
255 rcResult = pOldRect->m_rcLine; | 255 rcResult.right += (-fWidthDiff); |
256 rcResult.Union(pNewRect->m_rcLine); | 256 } |
257 m_RefreshRects.Add(rcResult); | 257 } |
258 } | 258 m_RefreshRects.Add(rcResult); |
259 else | 259 } |
260 { | 260 } else { |
261 if (*pNewRect != *pOldRect) | 261 rcResult = pOldRect->m_rcLine; |
262 { | 262 rcResult.Union(pNewRect->m_rcLine); |
263 if (!pNewRect->IsSameTop(*pOldRe
ct) || !pNewRect->IsSameHeight(*pOldRect)) | 263 m_RefreshRects.Add(rcResult); |
264 { | 264 } |
265 bLineTopChanged = TRUE; | 265 } else { |
266 continue; | 266 // don't need to do anything |
267 } | 267 } |
268 | 268 } |
269 if (nAlignment == 0) | 269 } else { |
270 { | 270 m_RefreshRects.Add(pOldRect->m_rcLine); |
271 if (pNewRect->m_wrLine.B
eginPos != pOldRect->m_wrLine.BeginPos) | 271 } |
272 { | 272 } else { |
273 rcResult = pOldR
ect->m_rcLine; | 273 if (pNewRect) { |
274 rcResult.Union(p
NewRect->m_rcLine); | 274 m_RefreshRects.Add(pNewRect->m_rcLine); |
275 m_RefreshRects.A
dd(rcResult); | 275 } else { |
276 } | 276 // error |
277 else | 277 } |
278 { | 278 } |
279 if (!pNewRect->I
sSameLeft(*pOldRect)) | 279 i++; |
280 { | 280 } |
281 rcResult
= pOldRect->m_rcLine; | 281 } |
282 rcResult
.Union(pNewRect->m_rcLine);
| 282 |
283 } | 283 void CFX_Edit_Refresh::AddRefresh(const CPDF_Rect& rect) { |
284 else | 284 m_RefreshRects.Add(rect); |
285 { | 285 } |
286 fWidthDi
ff = pNewRect->m_rcLine.Width() - pOldRect->m_rcLine.Width(); | 286 |
287 rcResult
= pNewRect->m_rcLine; | 287 const CFX_Edit_RectArray* CFX_Edit_Refresh::GetRefreshRects() const { |
288 if (fWid
thDiff > 0.0f) | 288 return &m_RefreshRects; |
289
rcResult.left = rcResult.right - fWidthDiff; | 289 } |
290 else | 290 |
291 { | 291 void CFX_Edit_Refresh::EndRefresh() { |
292
rcResult.left = rcResult.right; | 292 m_RefreshRects.Empty(); |
293
rcResult.right += (-fWidthDiff); | 293 } |
294 } | 294 |
295 } | 295 /* ------------------------------------- CFX_Edit_Undo |
296 m_RefreshRects.A
dd(rcResult); | 296 * ------------------------------------- */ |
297 } | 297 |
298 } | 298 CFX_Edit_Undo::CFX_Edit_Undo(FX_INT32 nBufsize) |
299 else | 299 : m_nCurUndoPos(0), |
300 { | 300 m_nBufSize(nBufsize), |
301 rcResult = pOldRect->m_r
cLine; | 301 m_bModified(FALSE), |
302 rcResult.Union(pNewRect-
>m_rcLine); | 302 m_bVirgin(TRUE), |
303 m_RefreshRects.Add(rcRes
ult); | 303 m_bWorking(FALSE) { |
304 } | 304 } |
305 } | 305 |
306 else | 306 CFX_Edit_Undo::~CFX_Edit_Undo() { |
307 { | 307 Reset(); |
308 //don't need to do anything | 308 } |
309 } | 309 |
310 } | 310 FX_BOOL CFX_Edit_Undo::CanUndo() const { |
311 } | 311 return m_nCurUndoPos > 0; |
312 else | 312 } |
313 { | 313 |
314 m_RefreshRects.Add(pOldRect->m_rcLine); | 314 void CFX_Edit_Undo::Undo() { |
315 } | 315 m_bWorking = TRUE; |
316 } | 316 |
317 else | 317 if (m_nCurUndoPos > 0) { |
318 { | 318 IFX_Edit_UndoItem* pItem = m_UndoItemStack.GetAt(m_nCurUndoPos - 1); |
319 if (pNewRect) | 319 ASSERT(pItem != NULL); |
320 { | 320 |
321 m_RefreshRects.Add(pNewRect->m_rcLine); | 321 pItem->Undo(); |
322 } | 322 |
323 else | 323 m_nCurUndoPos--; |
324 { | 324 m_bModified = (m_nCurUndoPos != 0); |
325 //error | 325 } |
326 } | 326 |
327 } | 327 m_bWorking = FALSE; |
328 i++; | 328 } |
329 } | 329 |
330 } | 330 FX_BOOL CFX_Edit_Undo::CanRedo() const { |
331 | 331 return m_nCurUndoPos < m_UndoItemStack.GetSize(); |
332 void CFX_Edit_Refresh::AddRefresh(const CPDF_Rect & rect) | 332 } |
333 { | 333 |
334 m_RefreshRects.Add(rect); | 334 void CFX_Edit_Undo::Redo() { |
335 } | 335 m_bWorking = TRUE; |
336 | 336 |
337 const CFX_Edit_RectArray * CFX_Edit_Refresh::GetRefreshRects() const | 337 FX_INT32 nStackSize = m_UndoItemStack.GetSize(); |
338 { | 338 |
339 return &m_RefreshRects; | 339 if (m_nCurUndoPos < nStackSize) { |
340 } | 340 IFX_Edit_UndoItem* pItem = m_UndoItemStack.GetAt(m_nCurUndoPos); |
341 | 341 ASSERT(pItem != NULL); |
342 void CFX_Edit_Refresh::EndRefresh() | 342 |
343 { | 343 pItem->Redo(); |
344 m_RefreshRects.Empty(); | 344 |
345 } | 345 m_nCurUndoPos++; |
346 | 346 m_bModified = (m_nCurUndoPos != 0); |
347 /* ------------------------------------- CFX_Edit_Undo -------------------------
------------ */ | 347 } |
348 | 348 |
349 CFX_Edit_Undo::CFX_Edit_Undo(FX_INT32 nBufsize) : m_nCurUndoPos(0), | 349 m_bWorking = FALSE; |
350 m_nBufSize(nBufsize), | 350 } |
351 m_bModified(FALSE), | 351 |
352 m_bVirgin(TRUE), | 352 FX_BOOL CFX_Edit_Undo::IsWorking() const { |
353 m_bWorking(FALSE) | 353 return m_bWorking; |
354 { | 354 } |
355 } | 355 |
356 | 356 void CFX_Edit_Undo::AddItem(IFX_Edit_UndoItem* pItem) { |
357 CFX_Edit_Undo::~CFX_Edit_Undo() | 357 ASSERT(!m_bWorking); |
358 { | 358 ASSERT(pItem != NULL); |
359 Reset(); | 359 ASSERT(m_nBufSize > 1); |
360 } | 360 |
361 | 361 if (m_nCurUndoPos < m_UndoItemStack.GetSize()) |
362 FX_BOOL CFX_Edit_Undo::CanUndo() const | 362 RemoveTails(); |
363 { | 363 |
364 return m_nCurUndoPos > 0; | 364 if (m_UndoItemStack.GetSize() >= m_nBufSize) { |
365 } | 365 RemoveHeads(); |
366 | 366 m_bVirgin = FALSE; |
367 void CFX_Edit_Undo::Undo() | 367 } |
368 { | 368 |
369 m_bWorking = TRUE; | 369 m_UndoItemStack.Add(pItem); |
370 | 370 m_nCurUndoPos = m_UndoItemStack.GetSize(); |
371 if (m_nCurUndoPos > 0) | 371 |
372 { | 372 m_bModified = (m_nCurUndoPos != 0); |
373 IFX_Edit_UndoItem * pItem = m_UndoItemStack.GetAt(m_nCurUndoPos-
1); | 373 } |
374 ASSERT(pItem != NULL); | 374 |
375 | 375 FX_BOOL CFX_Edit_Undo::IsModified() const { |
376 pItem->Undo(); | 376 if (m_bVirgin) |
377 | 377 return m_bModified; |
378 m_nCurUndoPos--; | 378 else |
379 m_bModified = (m_nCurUndoPos != 0); | 379 return TRUE; |
380 } | 380 } |
381 | 381 |
382 m_bWorking = FALSE; | 382 IFX_Edit_UndoItem* CFX_Edit_Undo::GetItem(FX_INT32 nIndex) { |
383 } | 383 if (nIndex >= 0 && nIndex < m_UndoItemStack.GetSize()) |
384 | 384 return m_UndoItemStack.GetAt(nIndex); |
385 FX_BOOL CFX_Edit_Undo::CanRedo() const | 385 |
386 { | 386 return NULL; |
387 return m_nCurUndoPos < m_UndoItemStack.GetSize(); | 387 } |
388 } | 388 |
389 | 389 void CFX_Edit_Undo::RemoveHeads() { |
390 void CFX_Edit_Undo::Redo() | 390 ASSERT(m_UndoItemStack.GetSize() > 1); |
391 { | 391 |
392 m_bWorking = TRUE; | 392 IFX_Edit_UndoItem* pItem = m_UndoItemStack.GetAt(0); |
393 | 393 ASSERT(pItem != NULL); |
394 FX_INT32 nStackSize = m_UndoItemStack.GetSize(); | 394 |
395 | 395 pItem->Release(); |
396 if (m_nCurUndoPos < nStackSize) | 396 m_UndoItemStack.RemoveAt(0); |
397 { | 397 } |
398 IFX_Edit_UndoItem * pItem = m_UndoItemStack.GetAt(m_nCurUndoPos)
; | 398 |
399 ASSERT(pItem != NULL); | 399 void CFX_Edit_Undo::RemoveTails() { |
400 | 400 for (FX_INT32 i = m_UndoItemStack.GetSize() - 1; i >= m_nCurUndoPos; i--) { |
401 pItem->Redo(); | 401 IFX_Edit_UndoItem* pItem = m_UndoItemStack.GetAt(i); |
402 | 402 ASSERT(pItem != NULL); |
403 m_nCurUndoPos++; | 403 |
404 m_bModified = (m_nCurUndoPos != 0); | 404 pItem->Release(); |
405 } | 405 m_UndoItemStack.RemoveAt(i); |
406 | 406 } |
407 m_bWorking = FALSE; | 407 } |
408 } | 408 |
409 | 409 void CFX_Edit_Undo::Reset() { |
410 FX_BOOL CFX_Edit_Undo::IsWorking() const | 410 for (FX_INT32 i = 0, sz = m_UndoItemStack.GetSize(); i < sz; i++) { |
411 { | 411 IFX_Edit_UndoItem* pItem = m_UndoItemStack.GetAt(i); |
412 return m_bWorking; | 412 ASSERT(pItem != NULL); |
413 } | 413 |
414 | 414 pItem->Release(); |
415 void CFX_Edit_Undo::AddItem(IFX_Edit_UndoItem* pItem) | 415 } |
416 { | 416 m_nCurUndoPos = 0; |
417 ASSERT(!m_bWorking); | 417 m_UndoItemStack.RemoveAll(); |
418 ASSERT(pItem != NULL); | 418 } |
419 ASSERT(m_nBufSize > 1); | 419 |
420 | 420 /* -------------------------------- CFX_Edit_GroupUndoItem |
421 if (m_nCurUndoPos < m_UndoItemStack.GetSize()) | 421 * -------------------------------- */ |
422 RemoveTails(); | 422 |
423 | 423 CFX_Edit_GroupUndoItem::CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle) |
424 if (m_UndoItemStack.GetSize() >= m_nBufSize) | 424 : m_sTitle(sTitle) { |
425 { | 425 } |
426 RemoveHeads(); | 426 |
427 m_bVirgin = FALSE; | 427 CFX_Edit_GroupUndoItem::~CFX_Edit_GroupUndoItem() { |
428 } | 428 for (int i = 0, sz = m_Items.GetSize(); i < sz; i++) { |
429 | 429 CFX_Edit_UndoItem* pUndoItem = m_Items[i]; |
430 m_UndoItemStack.Add(pItem); | 430 ASSERT(pUndoItem != NULL); |
431 m_nCurUndoPos = m_UndoItemStack.GetSize(); | 431 |
432 | 432 pUndoItem->Release(); |
433 m_bModified = (m_nCurUndoPos != 0); | 433 } |
434 } | 434 |
435 | 435 m_Items.RemoveAll(); |
436 FX_BOOL CFX_Edit_Undo::IsModified() const | 436 } |
437 { | 437 |
438 if (m_bVirgin) | 438 void CFX_Edit_GroupUndoItem::AddUndoItem(CFX_Edit_UndoItem* pUndoItem) { |
439 return m_bModified; | 439 ASSERT(pUndoItem != NULL); |
440 else | 440 |
441 return TRUE; | 441 pUndoItem->SetFirst(FALSE); |
442 } | 442 pUndoItem->SetLast(FALSE); |
443 | 443 |
444 IFX_Edit_UndoItem* CFX_Edit_Undo::GetItem(FX_INT32 nIndex) | 444 m_Items.Add(pUndoItem); |
445 { | 445 |
446 if (nIndex>=0 && nIndex < m_UndoItemStack.GetSize()) | 446 if (m_sTitle.IsEmpty()) |
447 return m_UndoItemStack.GetAt(nIndex); | 447 m_sTitle = pUndoItem->GetUndoTitle(); |
448 | 448 } |
449 return NULL; | 449 |
450 } | 450 void CFX_Edit_GroupUndoItem::UpdateItems() { |
451 | 451 if (m_Items.GetSize() > 0) { |
452 void CFX_Edit_Undo::RemoveHeads() | 452 CFX_Edit_UndoItem* pFirstItem = m_Items[0]; |
453 { | 453 ASSERT(pFirstItem != NULL); |
454 ASSERT(m_UndoItemStack.GetSize() > 1); | 454 pFirstItem->SetFirst(TRUE); |
455 | 455 |
456 IFX_Edit_UndoItem* pItem = m_UndoItemStack.GetAt(0); | 456 CFX_Edit_UndoItem* pLastItem = m_Items[m_Items.GetSize() - 1]; |
457 ASSERT(pItem != NULL); | 457 ASSERT(pLastItem != NULL); |
458 | 458 pLastItem->SetLast(TRUE); |
459 pItem->Release(); | 459 } |
460 m_UndoItemStack.RemoveAt(0); | 460 } |
461 } | 461 |
462 | 462 void CFX_Edit_GroupUndoItem::Undo() { |
463 void CFX_Edit_Undo::RemoveTails() | 463 for (int i = m_Items.GetSize() - 1; i >= 0; i--) { |
464 { | 464 CFX_Edit_UndoItem* pUndoItem = m_Items[i]; |
465 for (FX_INT32 i = m_UndoItemStack.GetSize()-1; i >= m_nCurUndoPos; i--) | 465 ASSERT(pUndoItem != NULL); |
466 { | 466 |
467 IFX_Edit_UndoItem* pItem = m_UndoItemStack.GetAt(i); | 467 pUndoItem->Undo(); |
468 ASSERT(pItem != NULL); | 468 } |
469 | 469 } |
470 pItem->Release(); | 470 |
471 m_UndoItemStack.RemoveAt(i); | 471 void CFX_Edit_GroupUndoItem::Redo() { |
472 } | 472 for (int i = 0, sz = m_Items.GetSize(); i < sz; i++) { |
473 } | 473 CFX_Edit_UndoItem* pUndoItem = m_Items[i]; |
474 | 474 ASSERT(pUndoItem != NULL); |
475 void CFX_Edit_Undo::Reset() | 475 |
476 { | 476 pUndoItem->Redo(); |
477 for (FX_INT32 i=0, sz=m_UndoItemStack.GetSize(); i < sz; i++) | 477 } |
478 { | 478 } |
479 IFX_Edit_UndoItem * pItem = m_UndoItemStack.GetAt(i); | 479 |
480 ASSERT(pItem != NULL); | 480 CFX_WideString CFX_Edit_GroupUndoItem::GetUndoTitle() { |
481 | 481 return m_sTitle; |
482 pItem->Release(); | 482 } |
483 } | 483 |
484 m_nCurUndoPos = 0; | 484 void CFX_Edit_GroupUndoItem::Release() { |
485 m_UndoItemStack.RemoveAll(); | 485 delete this; |
486 } | 486 } |
487 | 487 |
488 /* -------------------------------- CFX_Edit_GroupUndoItem ---------------------
----------- */ | 488 /* ------------------------------------- CFX_Edit_UndoItem derived classes |
489 | 489 * ------------------------------------- */ |
490 CFX_Edit_GroupUndoItem::CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle) : m
_sTitle(sTitle) | 490 |
491 { | 491 CFXEU_InsertWord::CFXEU_InsertWord(CFX_Edit* pEdit, |
492 } | 492 const CPVT_WordPlace& wpOldPlace, |
493 | 493 const CPVT_WordPlace& wpNewPlace, |
494 CFX_Edit_GroupUndoItem::~CFX_Edit_GroupUndoItem() | 494 FX_WORD word, |
495 { | 495 FX_INT32 charset, |
496 for (int i=0,sz=m_Items.GetSize(); i<sz; i++) | 496 const CPVT_WordProps* pWordProps) |
497 { | 497 : m_pEdit(pEdit), |
498 CFX_Edit_UndoItem* pUndoItem = m_Items[i]; | 498 m_wpOld(wpOldPlace), |
499 ASSERT(pUndoItem != NULL); | 499 m_wpNew(wpNewPlace), |
500 | 500 m_Word(word), |
501 pUndoItem->Release(); | 501 m_nCharset(charset), |
502 } | 502 m_WordProps() { |
503 | 503 if (pWordProps) |
504 m_Items.RemoveAll(); | 504 m_WordProps = *pWordProps; |
505 } | 505 } |
506 | 506 |
507 void CFX_Edit_GroupUndoItem::AddUndoItem(CFX_Edit_UndoItem* pUndoItem) | 507 CFXEU_InsertWord::~CFXEU_InsertWord() { |
508 { | 508 } |
509 ASSERT(pUndoItem != NULL); | 509 |
510 | 510 void CFXEU_InsertWord::Redo() { |
511 pUndoItem->SetFirst(FALSE); | 511 if (m_pEdit) { |
512 pUndoItem->SetLast(FALSE); | 512 m_pEdit->SelectNone(); |
513 | 513 m_pEdit->SetCaret(m_wpOld); |
514 m_Items.Add(pUndoItem); | 514 m_pEdit->InsertWord(m_Word, m_nCharset, &m_WordProps, FALSE, TRUE); |
515 | 515 } |
516 if (m_sTitle.IsEmpty()) | 516 } |
517 m_sTitle = pUndoItem->GetUndoTitle(); | 517 |
518 } | 518 void CFXEU_InsertWord::Undo() { |
519 | 519 if (m_pEdit) { |
520 void CFX_Edit_GroupUndoItem::UpdateItems() | 520 m_pEdit->SelectNone(); |
521 { | 521 m_pEdit->SetCaret(m_wpNew); |
522 if (m_Items.GetSize() > 0) | 522 m_pEdit->Backspace(FALSE, TRUE); |
523 { | 523 } |
524 CFX_Edit_UndoItem* pFirstItem = m_Items[0]; | |
525 ASSERT(pFirstItem != NULL); | |
526 pFirstItem->SetFirst(TRUE); | |
527 | |
528 CFX_Edit_UndoItem* pLastItem = m_Items[m_Items.GetSize() - 1]; | |
529 ASSERT(pLastItem != NULL); | |
530 pLastItem->SetLast(TRUE); | |
531 } | |
532 } | |
533 | |
534 void CFX_Edit_GroupUndoItem::Undo() | |
535 { | |
536 for (int i=m_Items.GetSize()-1; i>=0; i--) | |
537 { | |
538 CFX_Edit_UndoItem* pUndoItem = m_Items[i]; | |
539 ASSERT(pUndoItem != NULL); | |
540 | |
541 pUndoItem->Undo(); | |
542 } | |
543 } | |
544 | |
545 void CFX_Edit_GroupUndoItem::Redo() | |
546 { | |
547 for (int i=0,sz=m_Items.GetSize(); i<sz; i++) | |
548 { | |
549 CFX_Edit_UndoItem* pUndoItem = m_Items[i]; | |
550 ASSERT(pUndoItem != NULL); | |
551 | |
552 pUndoItem->Redo(); | |
553 } | |
554 } | |
555 | |
556 CFX_WideString CFX_Edit_GroupUndoItem::GetUndoTitle() | |
557 { | |
558 return m_sTitle; | |
559 } | |
560 | |
561 void CFX_Edit_GroupUndoItem::Release() | |
562 { | |
563 delete this; | |
564 } | |
565 | |
566 /* ------------------------------------- CFX_Edit_UndoItem derived classes -----
-------------------------------- */ | |
567 | |
568 CFXEU_InsertWord::CFXEU_InsertWord(CFX_Edit * pEdit, const CPVT_WordPlace & wpOl
dPlace, const CPVT_WordPlace & wpNewPlace, | |
569 FX_WORD word, F
X_INT32 charset, const CPVT_WordProps * pWordProps) | |
570 : m_pEdit(pEdit), m_wpOld(wpOldPlace), m_wpNew(wpNewPlace), m_Word(word)
, m_nCharset(charset), m_WordProps() | |
571 { | |
572 if (pWordProps) | |
573 m_WordProps = *pWordProps; | |
574 } | |
575 | |
576 CFXEU_InsertWord::~CFXEU_InsertWord() | |
577 { | |
578 } | |
579 | |
580 void CFXEU_InsertWord::Redo() | |
581 { | |
582 if (m_pEdit) | |
583 { | |
584 m_pEdit->SelectNone(); | |
585 m_pEdit->SetCaret(m_wpOld); | |
586 m_pEdit->InsertWord(m_Word,m_nCharset,&m_WordProps,FALSE,TRUE); | |
587 } | |
588 } | |
589 | |
590 void CFXEU_InsertWord::Undo() | |
591 { | |
592 if (m_pEdit) | |
593 { | |
594 m_pEdit->SelectNone(); | |
595 m_pEdit->SetCaret(m_wpNew); | |
596 m_pEdit->Backspace(FALSE,TRUE); | |
597 } | |
598 } | 524 } |
599 | 525 |
600 /* -------------------------------------------------------------------------- */ | 526 /* -------------------------------------------------------------------------- */ |
601 | 527 |
602 CFXEU_InsertReturn::CFXEU_InsertReturn(CFX_Edit * pEdit, const CPVT_WordPlace &
wpOldPlace, const CPVT_WordPlace & wpNewPlace, | 528 CFXEU_InsertReturn::CFXEU_InsertReturn(CFX_Edit* pEdit, |
603 » » » const CPVT_SecProps * pSecProps, const CPVT_WordProps *
pWordProps) : | 529 const CPVT_WordPlace& wpOldPlace, |
604 » » » m_pEdit(pEdit), | 530 const CPVT_WordPlace& wpNewPlace, |
605 » » » m_wpOld(wpOldPlace), | 531 const CPVT_SecProps* pSecProps, |
606 » » » m_wpNew(wpNewPlace), | 532 const CPVT_WordProps* pWordProps) |
607 » » » m_SecProps(), | 533 : m_pEdit(pEdit), |
608 » » » m_WordProps()» » » » » »
» » » | 534 m_wpOld(wpOldPlace), |
609 { | 535 m_wpNew(wpNewPlace), |
610 » if (pSecProps) | 536 m_SecProps(), |
611 » » m_SecProps = *pSecProps; | 537 m_WordProps() { |
612 » if (pWordProps) | 538 if (pSecProps) |
613 » » m_WordProps = *pWordProps; | 539 m_SecProps = *pSecProps; |
614 } | 540 if (pWordProps) |
615 | 541 m_WordProps = *pWordProps; |
616 CFXEU_InsertReturn::~CFXEU_InsertReturn() | 542 } |
617 { | 543 |
618 } | 544 CFXEU_InsertReturn::~CFXEU_InsertReturn() { |
619 | 545 } |
620 void CFXEU_InsertReturn::Redo() | 546 |
621 { | 547 void CFXEU_InsertReturn::Redo() { |
622 » if (m_pEdit) | 548 if (m_pEdit) { |
623 » { | 549 m_pEdit->SelectNone(); |
624 » » m_pEdit->SelectNone(); | 550 m_pEdit->SetCaret(m_wpOld); |
625 » » m_pEdit->SetCaret(m_wpOld); | 551 m_pEdit->InsertReturn(&m_SecProps, &m_WordProps, FALSE, TRUE); |
626 » » m_pEdit->InsertReturn(&m_SecProps,&m_WordProps,FALSE,TRUE); | 552 } |
627 » } | 553 } |
628 } | 554 |
629 | 555 void CFXEU_InsertReturn::Undo() { |
630 void CFXEU_InsertReturn::Undo() | 556 if (m_pEdit) { |
631 { | 557 m_pEdit->SelectNone(); |
632 » if (m_pEdit) | 558 m_pEdit->SetCaret(m_wpNew); |
633 » { | 559 m_pEdit->Backspace(FALSE, TRUE); |
634 » » m_pEdit->SelectNone(); | 560 } |
635 » » m_pEdit->SetCaret(m_wpNew); | |
636 » » m_pEdit->Backspace(FALSE,TRUE); | |
637 » } | |
638 } | 561 } |
639 | 562 |
640 /* -------------------------------------------------------------------------- */ | 563 /* -------------------------------------------------------------------------- */ |
641 //CFXEU_Backspace | 564 // CFXEU_Backspace |
642 | 565 |
643 CFXEU_Backspace::CFXEU_Backspace(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldP
lace, const CPVT_WordPlace & wpNewPlace, | 566 CFXEU_Backspace::CFXEU_Backspace(CFX_Edit* pEdit, |
644 » » » » » » » FX_WORD word, FX_INT3
2 charset, | 567 const CPVT_WordPlace& wpOldPlace, |
645 » » » » » » » const CPVT_SecProps &
SecProps, const CPVT_WordProps & WordProps) : | 568 const CPVT_WordPlace& wpNewPlace, |
646 » » » m_pEdit(pEdit), | 569 FX_WORD word, |
647 » » » m_wpOld(wpOldPlace), | 570 FX_INT32 charset, |
648 » » » m_wpNew(wpNewPlace), | 571 const CPVT_SecProps& SecProps, |
649 » » » m_Word(word), | 572 const CPVT_WordProps& WordProps) |
650 » » » m_nCharset(charset), | 573 : m_pEdit(pEdit), |
651 » » » m_SecProps(SecProps), | 574 m_wpOld(wpOldPlace), |
652 » » » m_WordProps(WordProps)» » » » »
» » » » | 575 m_wpNew(wpNewPlace), |
653 { | 576 m_Word(word), |
654 } | 577 m_nCharset(charset), |
655 | 578 m_SecProps(SecProps), |
656 CFXEU_Backspace::~CFXEU_Backspace() | 579 m_WordProps(WordProps) { |
657 { | 580 } |
658 } | 581 |
659 | 582 CFXEU_Backspace::~CFXEU_Backspace() { |
660 void CFXEU_Backspace::Redo() | 583 } |
661 { | 584 |
662 » if (m_pEdit) | 585 void CFXEU_Backspace::Redo() { |
663 » { | 586 if (m_pEdit) { |
664 » » m_pEdit->SelectNone(); | 587 m_pEdit->SelectNone(); |
665 » » m_pEdit->SetCaret(m_wpOld); | 588 m_pEdit->SetCaret(m_wpOld); |
666 » » m_pEdit->Backspace(FALSE,TRUE); | 589 m_pEdit->Backspace(FALSE, TRUE); |
667 » } | 590 } |
668 } | 591 } |
669 | 592 |
670 void CFXEU_Backspace::Undo() | 593 void CFXEU_Backspace::Undo() { |
671 { | 594 if (m_pEdit) { |
672 » if (m_pEdit) | 595 m_pEdit->SelectNone(); |
673 » { | 596 m_pEdit->SetCaret(m_wpNew); |
674 » » m_pEdit->SelectNone(); | 597 if (m_wpNew.SecCmp(m_wpOld) != 0) { |
675 » » m_pEdit->SetCaret(m_wpNew); | 598 m_pEdit->InsertReturn(&m_SecProps, &m_WordProps, FALSE, TRUE); |
676 » » if (m_wpNew.SecCmp(m_wpOld) != 0) | 599 } else { |
677 » » { | 600 m_pEdit->InsertWord(m_Word, m_nCharset, &m_WordProps, FALSE, TRUE); |
678 » » » m_pEdit->InsertReturn(&m_SecProps,&m_WordProps,FALSE,TRU
E); | 601 } |
679 » » } | 602 } |
680 » » else | |
681 » » { | |
682 » » » m_pEdit->InsertWord(m_Word,m_nCharset,&m_WordProps,FALSE
,TRUE); | |
683 » » } | |
684 » } | |
685 } | 603 } |
686 | 604 |
687 /* -------------------------------------------------------------------------- */ | 605 /* -------------------------------------------------------------------------- */ |
688 //CFXEU_Delete | 606 // CFXEU_Delete |
689 | 607 |
690 CFXEU_Delete::CFXEU_Delete(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace,
const CPVT_WordPlace & wpNewPlace, | 608 CFXEU_Delete::CFXEU_Delete(CFX_Edit* pEdit, |
691 » » » » » » » FX_WORD word, FX_INT3
2 charset, | 609 const CPVT_WordPlace& wpOldPlace, |
692 » » » » » » » const CPVT_SecProps &
SecProps, const CPVT_WordProps & WordProps, FX_BOOL bSecEnd) : | 610 const CPVT_WordPlace& wpNewPlace, |
693 » » » m_pEdit(pEdit), | 611 FX_WORD word, |
694 » » » m_wpOld(wpOldPlace), | 612 FX_INT32 charset, |
695 » » » m_wpNew(wpNewPlace), | 613 const CPVT_SecProps& SecProps, |
696 » » » m_Word(word), | 614 const CPVT_WordProps& WordProps, |
697 » » » m_nCharset(charset), | 615 FX_BOOL bSecEnd) |
698 » » » m_SecProps(SecProps), | 616 : m_pEdit(pEdit), |
699 » » » m_WordProps(WordProps), | 617 m_wpOld(wpOldPlace), |
700 » » » m_bSecEnd(bSecEnd) | 618 m_wpNew(wpNewPlace), |
701 { | 619 m_Word(word), |
702 } | 620 m_nCharset(charset), |
703 | 621 m_SecProps(SecProps), |
704 CFXEU_Delete::~CFXEU_Delete() | 622 m_WordProps(WordProps), |
705 { | 623 m_bSecEnd(bSecEnd) { |
706 } | 624 } |
707 | 625 |
708 void CFXEU_Delete::Redo() | 626 CFXEU_Delete::~CFXEU_Delete() { |
709 { | 627 } |
710 » if (m_pEdit) | 628 |
711 » { | 629 void CFXEU_Delete::Redo() { |
712 » » m_pEdit->SelectNone(); | 630 if (m_pEdit) { |
713 » » m_pEdit->SetCaret(m_wpOld); | 631 m_pEdit->SelectNone(); |
714 » » m_pEdit->Delete(FALSE,TRUE); | 632 m_pEdit->SetCaret(m_wpOld); |
715 » } | 633 m_pEdit->Delete(FALSE, TRUE); |
716 } | 634 } |
717 | 635 } |
718 void CFXEU_Delete::Undo() | 636 |
719 { | 637 void CFXEU_Delete::Undo() { |
720 » if (m_pEdit) | 638 if (m_pEdit) { |
721 » { | 639 m_pEdit->SelectNone(); |
722 » » m_pEdit->SelectNone(); | 640 m_pEdit->SetCaret(m_wpNew); |
723 » » m_pEdit->SetCaret(m_wpNew); | 641 if (m_bSecEnd) { |
724 » » if (m_bSecEnd) | 642 m_pEdit->InsertReturn(&m_SecProps, &m_WordProps, FALSE, TRUE); |
725 » » { | 643 } else { |
726 » » » m_pEdit->InsertReturn(&m_SecProps,&m_WordProps,FALSE,TRU
E); | 644 m_pEdit->InsertWord(m_Word, m_nCharset, &m_WordProps, FALSE, TRUE); |
727 » » } | 645 } |
728 » » else | 646 } |
729 » » { | |
730 » » » m_pEdit->InsertWord(m_Word,m_nCharset,&m_WordProps,FALSE
,TRUE); | |
731 » » } | |
732 » } | |
733 } | 647 } |
734 | 648 |
735 /* -------------------------------------------------------------------------- */ | 649 /* -------------------------------------------------------------------------- */ |
736 //CFXEU_Clear | 650 // CFXEU_Clear |
737 | 651 |
738 CFXEU_Clear::CFXEU_Clear(CFX_Edit * pEdit, const CPVT_WordRange & wrSel, const
CFX_WideString & swText) : | 652 CFXEU_Clear::CFXEU_Clear(CFX_Edit* pEdit, |
739 » » » m_pEdit(pEdit), | 653 const CPVT_WordRange& wrSel, |
740 » » » m_wrSel(wrSel), | 654 const CFX_WideString& swText) |
741 » » » m_swText(swText) | 655 : m_pEdit(pEdit), m_wrSel(wrSel), m_swText(swText) { |
742 { | 656 } |
743 } | 657 |
744 | 658 CFXEU_Clear::~CFXEU_Clear() { |
745 CFXEU_Clear::~CFXEU_Clear() | 659 } |
746 { | 660 |
747 } | 661 void CFXEU_Clear::Redo() { |
748 | 662 if (m_pEdit) { |
749 void CFXEU_Clear::Redo() | 663 m_pEdit->SelectNone(); |
750 { | 664 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); |
751 » if (m_pEdit) | 665 m_pEdit->Clear(FALSE, TRUE); |
752 » { | 666 } |
753 » » m_pEdit->SelectNone(); | 667 } |
754 » » m_pEdit->SetSel(m_wrSel.BeginPos,m_wrSel.EndPos); | 668 |
755 » » m_pEdit->Clear(FALSE,TRUE); | 669 void CFXEU_Clear::Undo() { |
756 » } | 670 if (m_pEdit) { |
757 } | 671 m_pEdit->SelectNone(); |
758 | 672 m_pEdit->SetCaret(m_wrSel.BeginPos); |
759 void CFXEU_Clear::Undo() | 673 m_pEdit->InsertText(m_swText, DEFAULT_CHARSET, NULL, NULL, FALSE, TRUE); |
760 { | 674 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); |
761 » if (m_pEdit) | 675 } |
762 » { | |
763 » » m_pEdit->SelectNone(); | |
764 » » m_pEdit->SetCaret(m_wrSel.BeginPos); | |
765 » » m_pEdit->InsertText(m_swText, DEFAULT_CHARSET, NULL,NULL,FALSE,T
RUE); | |
766 » » m_pEdit->SetSel(m_wrSel.BeginPos,m_wrSel.EndPos); | |
767 » } | |
768 } | 676 } |
769 | 677 |
770 /* -------------------------------------------------------------------------- */ | 678 /* -------------------------------------------------------------------------- */ |
771 //CFXEU_ClearRich | 679 // CFXEU_ClearRich |
772 | 680 |
773 CFXEU_ClearRich::CFXEU_ClearRich(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldP
lace, const CPVT_WordPlace & wpNewPlace, | 681 CFXEU_ClearRich::CFXEU_ClearRich(CFX_Edit* pEdit, |
774 » » » » » » » const CPVT_WordRange
& wrSel, FX_WORD word, FX_INT32 charset, | 682 const CPVT_WordPlace& wpOldPlace, |
775 » » » » » » » const CPVT_SecProps &
SecProps, const CPVT_WordProps & WordProps) : | 683 const CPVT_WordPlace& wpNewPlace, |
776 » » » m_pEdit(pEdit), | 684 const CPVT_WordRange& wrSel, |
777 » » » m_wpOld(wpOldPlace), | 685 FX_WORD word, |
778 » » » m_wpNew(wpNewPlace), | 686 FX_INT32 charset, |
779 » » » m_wrSel(wrSel), | 687 const CPVT_SecProps& SecProps, |
780 » » » m_Word(word), | 688 const CPVT_WordProps& WordProps) |
781 » » » m_nCharset(charset), | 689 : m_pEdit(pEdit), |
782 » » » m_SecProps(SecProps), | 690 m_wpOld(wpOldPlace), |
783 » » » m_WordProps(WordProps)» » » » »
» » » » | 691 m_wpNew(wpNewPlace), |
784 { | 692 m_wrSel(wrSel), |
785 } | 693 m_Word(word), |
786 | 694 m_nCharset(charset), |
787 CFXEU_ClearRich::~CFXEU_ClearRich() | 695 m_SecProps(SecProps), |
788 { | 696 m_WordProps(WordProps) { |
789 } | 697 } |
790 | 698 |
791 void CFXEU_ClearRich::Redo() | 699 CFXEU_ClearRich::~CFXEU_ClearRich() { |
792 { | 700 } |
793 » if (m_pEdit && IsLast()) | 701 |
794 » { | 702 void CFXEU_ClearRich::Redo() { |
795 » » m_pEdit->SelectNone(); | 703 if (m_pEdit && IsLast()) { |
796 » » m_pEdit->SetSel(m_wrSel.BeginPos,m_wrSel.EndPos); | 704 m_pEdit->SelectNone(); |
797 » » m_pEdit->Clear(FALSE,TRUE); | 705 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); |
798 » } | 706 m_pEdit->Clear(FALSE, TRUE); |
799 } | 707 } |
800 | 708 } |
801 void CFXEU_ClearRich::Undo() | 709 |
802 { | 710 void CFXEU_ClearRich::Undo() { |
803 » if (m_pEdit) | 711 if (m_pEdit) { |
804 » { | 712 m_pEdit->SelectNone(); |
805 » » m_pEdit->SelectNone(); | 713 m_pEdit->SetCaret(m_wpOld); |
806 » » m_pEdit->SetCaret(m_wpOld); | 714 if (m_wpNew.SecCmp(m_wpOld) != 0) { |
807 » » if (m_wpNew.SecCmp(m_wpOld) != 0) | 715 m_pEdit->InsertReturn(&m_SecProps, &m_WordProps, FALSE, FALSE); |
808 » » { | 716 } else { |
809 » » » m_pEdit->InsertReturn(&m_SecProps,&m_WordProps,FALSE,FAL
SE); | 717 m_pEdit->InsertWord(m_Word, m_nCharset, &m_WordProps, FALSE, FALSE); |
810 » » } | 718 } |
811 » » else | 719 |
812 » » { | 720 if (IsFirst()) { |
813 » » » m_pEdit->InsertWord(m_Word,m_nCharset,&m_WordProps,FALSE
,FALSE); | 721 m_pEdit->PaintInsertText(m_wrSel.BeginPos, m_wrSel.EndPos); |
814 » » } | 722 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); |
815 | 723 } |
816 » » if (IsFirst()) | 724 } |
817 » » { | |
818 » » » m_pEdit->PaintInsertText(m_wrSel.BeginPos,m_wrSel.EndPos
); | |
819 » » » m_pEdit->SetSel(m_wrSel.BeginPos,m_wrSel.EndPos); | |
820 » » } | |
821 » } | |
822 } | 725 } |
823 /* -------------------------------------------------------------------------- */ | 726 /* -------------------------------------------------------------------------- */ |
824 //CFXEU_InsertText | 727 // CFXEU_InsertText |
825 | 728 |
826 CFXEU_InsertText::CFXEU_InsertText(CFX_Edit * pEdit, const CPVT_WordPlace & wpOl
dPlace, const CPVT_WordPlace & wpNewPlace, | 729 CFXEU_InsertText::CFXEU_InsertText(CFX_Edit* pEdit, |
827 » » » » » » » const CFX_WideString
& swText, FX_INT32 charset, | 730 const CPVT_WordPlace& wpOldPlace, |
828 » » » » » » » const CPVT_SecProps *
pSecProps, const CPVT_WordProps * pWordProps) : | 731 const CPVT_WordPlace& wpNewPlace, |
829 » » » m_pEdit(pEdit), | 732 const CFX_WideString& swText, |
830 » » » m_wpOld(wpOldPlace), | 733 FX_INT32 charset, |
831 » » » m_wpNew(wpNewPlace), | 734 const CPVT_SecProps* pSecProps, |
832 » » » m_swText(swText), | 735 const CPVT_WordProps* pWordProps) |
833 » » » m_nCharset(charset), | 736 : m_pEdit(pEdit), |
834 » » » m_SecProps(), | 737 m_wpOld(wpOldPlace), |
835 » » » m_WordProps()» » » » » »
» » » | 738 m_wpNew(wpNewPlace), |
836 { | 739 m_swText(swText), |
837 » if (pSecProps) | 740 m_nCharset(charset), |
838 » » m_SecProps = *pSecProps; | 741 m_SecProps(), |
839 » if (pWordProps) | 742 m_WordProps() { |
840 » » m_WordProps = *pWordProps; | 743 if (pSecProps) |
841 } | 744 m_SecProps = *pSecProps; |
842 | 745 if (pWordProps) |
843 CFXEU_InsertText::~CFXEU_InsertText() | 746 m_WordProps = *pWordProps; |
844 { | 747 } |
845 } | 748 |
846 | 749 CFXEU_InsertText::~CFXEU_InsertText() { |
847 void CFXEU_InsertText::Redo() | 750 } |
848 { | 751 |
849 » if (m_pEdit && IsLast()) | 752 void CFXEU_InsertText::Redo() { |
850 » { | 753 if (m_pEdit && IsLast()) { |
851 » » m_pEdit->SelectNone(); | 754 m_pEdit->SelectNone(); |
852 » » m_pEdit->SetCaret(m_wpOld); | 755 m_pEdit->SetCaret(m_wpOld); |
853 » » m_pEdit->InsertText(m_swText, m_nCharset,&m_SecProps, &m_WordPro
ps,FALSE,TRUE); | 756 m_pEdit->InsertText( |
854 » } | 757 m_swText, m_nCharset, &m_SecProps, &m_WordProps, FALSE, TRUE); |
855 } | 758 } |
856 | 759 } |
857 void CFXEU_InsertText::Undo() | 760 |
858 { | 761 void CFXEU_InsertText::Undo() { |
859 » if (m_pEdit) | 762 if (m_pEdit) { |
860 » { | 763 m_pEdit->SelectNone(); |
861 » » m_pEdit->SelectNone(); | 764 m_pEdit->SetSel(m_wpOld, m_wpNew); |
862 » » m_pEdit->SetSel(m_wpOld,m_wpNew); | 765 m_pEdit->Clear(FALSE, TRUE); |
863 » » m_pEdit->Clear(FALSE,TRUE); | 766 } |
864 » } | |
865 } | 767 } |
866 | 768 |
867 /* -------------------------------------------------------------------------- */ | 769 /* -------------------------------------------------------------------------- */ |
868 | 770 |
869 CFXEU_SetSecProps::CFXEU_SetSecProps(CFX_Edit * pEdit, const CPVT_WordPlace & pl
ace, EDIT_PROPS_E ep, | 771 CFXEU_SetSecProps::CFXEU_SetSecProps(CFX_Edit* pEdit, |
870 » » const CPVT_SecProps & oldsecprops, const CPVT_WordProps & oldwor
dprops, | 772 const CPVT_WordPlace& place, |
871 » » const CPVT_SecProps & newsecprops, const CPVT_WordProps & newwor
dprops, const CPVT_WordRange & range) | 773 EDIT_PROPS_E ep, |
872 » » : m_pEdit(pEdit), | 774 const CPVT_SecProps& oldsecprops, |
873 » » m_wpPlace(place), | 775 const CPVT_WordProps& oldwordprops, |
874 » » m_wrPlace(range), | 776 const CPVT_SecProps& newsecprops, |
875 » » m_eProps(ep), | 777 const CPVT_WordProps& newwordprops, |
876 » » m_OldSecProps(oldsecprops), | 778 const CPVT_WordRange& range) |
877 » » m_NewSecProps(newsecprops), | 779 : m_pEdit(pEdit), |
878 » » m_OldWordProps(oldwordprops), | 780 m_wpPlace(place), |
879 » » m_NewWordProps(newwordprops) | 781 m_wrPlace(range), |
880 { | 782 m_eProps(ep), |
881 } | 783 m_OldSecProps(oldsecprops), |
882 | 784 m_NewSecProps(newsecprops), |
883 CFXEU_SetSecProps::~CFXEU_SetSecProps() | 785 m_OldWordProps(oldwordprops), |
884 { | 786 m_NewWordProps(newwordprops) { |
885 } | 787 } |
886 | 788 |
887 void CFXEU_SetSecProps::Redo() | 789 CFXEU_SetSecProps::~CFXEU_SetSecProps() { |
888 { | 790 } |
889 » if (m_pEdit) | 791 |
890 » { | 792 void CFXEU_SetSecProps::Redo() { |
891 » » m_pEdit->SetSecProps(m_eProps,m_wpPlace,&m_NewSecProps,&m_NewWor
dProps,m_wrPlace,FALSE); | 793 if (m_pEdit) { |
892 » » if (IsLast()) | 794 m_pEdit->SetSecProps( |
893 » » { | 795 m_eProps, m_wpPlace, &m_NewSecProps, &m_NewWordProps, m_wrPlace, FALSE); |
894 » » » m_pEdit->SelectNone(); | 796 if (IsLast()) { |
895 » » » m_pEdit->PaintSetProps(m_eProps,m_wrPlace); | 797 m_pEdit->SelectNone(); |
896 » » » m_pEdit->SetSel(m_wrPlace.BeginPos,m_wrPlace.EndPos); | 798 m_pEdit->PaintSetProps(m_eProps, m_wrPlace); |
897 » » } | 799 m_pEdit->SetSel(m_wrPlace.BeginPos, m_wrPlace.EndPos); |
898 » } | 800 } |
899 } | 801 } |
900 | 802 } |
901 void CFXEU_SetSecProps::Undo() | 803 |
902 { | 804 void CFXEU_SetSecProps::Undo() { |
903 » if (m_pEdit) | 805 if (m_pEdit) { |
904 » { | 806 m_pEdit->SetSecProps( |
905 » » m_pEdit->SetSecProps(m_eProps,m_wpPlace,&m_OldSecProps,&m_OldWor
dProps,m_wrPlace,FALSE); | 807 m_eProps, m_wpPlace, &m_OldSecProps, &m_OldWordProps, m_wrPlace, FALSE); |
906 » » if (IsFirst()) | 808 if (IsFirst()) { |
907 » » { | 809 m_pEdit->SelectNone(); |
908 » » » m_pEdit->SelectNone(); | 810 m_pEdit->PaintSetProps(m_eProps, m_wrPlace); |
909 » » » m_pEdit->PaintSetProps(m_eProps,m_wrPlace); | 811 m_pEdit->SetSel(m_wrPlace.BeginPos, m_wrPlace.EndPos); |
910 » » » m_pEdit->SetSel(m_wrPlace.BeginPos,m_wrPlace.EndPos); | 812 } |
911 » » } | 813 } |
912 » } | |
913 } | 814 } |
914 | 815 |
915 /* -------------------------------------------------------------------------- */ | 816 /* -------------------------------------------------------------------------- */ |
916 | 817 |
917 CFXEU_SetWordProps::CFXEU_SetWordProps(CFX_Edit * pEdit, const CPVT_WordPlace &
place, EDIT_PROPS_E ep, | 818 CFXEU_SetWordProps::CFXEU_SetWordProps(CFX_Edit* pEdit, |
918 » » const CPVT_WordProps & oldprops, const CPVT_WordProps & newprops
, const CPVT_WordRange & range) | 819 const CPVT_WordPlace& place, |
919 » » : m_pEdit(pEdit), | 820 EDIT_PROPS_E ep, |
920 » » m_wpPlace(place), | 821 const CPVT_WordProps& oldprops, |
921 » » m_wrPlace(range), | 822 const CPVT_WordProps& newprops, |
922 » » m_eProps(ep), | 823 const CPVT_WordRange& range) |
923 » » m_OldWordProps(oldprops), | 824 : m_pEdit(pEdit), |
924 » » m_NewWordProps(newprops) | 825 m_wpPlace(place), |
925 { | 826 m_wrPlace(range), |
926 } | 827 m_eProps(ep), |
927 | 828 m_OldWordProps(oldprops), |
928 CFXEU_SetWordProps::~CFXEU_SetWordProps() | 829 m_NewWordProps(newprops) { |
929 { | 830 } |
930 } | 831 |
931 | 832 CFXEU_SetWordProps::~CFXEU_SetWordProps() { |
932 void CFXEU_SetWordProps::Redo() | 833 } |
933 { | 834 |
934 » if (m_pEdit) | 835 void CFXEU_SetWordProps::Redo() { |
935 » { | 836 if (m_pEdit) { |
936 » » m_pEdit->SetWordProps(m_eProps,m_wpPlace,&m_NewWordProps,m_wrPla
ce,FALSE); | 837 m_pEdit->SetWordProps( |
937 » » if (IsLast()) | 838 m_eProps, m_wpPlace, &m_NewWordProps, m_wrPlace, FALSE); |
938 » » { | 839 if (IsLast()) { |
939 » » » m_pEdit->SelectNone(); | 840 m_pEdit->SelectNone(); |
940 » » » m_pEdit->PaintSetProps(m_eProps,m_wrPlace); | 841 m_pEdit->PaintSetProps(m_eProps, m_wrPlace); |
941 » » » m_pEdit->SetSel(m_wrPlace.BeginPos,m_wrPlace.EndPos); | 842 m_pEdit->SetSel(m_wrPlace.BeginPos, m_wrPlace.EndPos); |
942 » » } | 843 } |
943 » } | 844 } |
944 } | 845 } |
945 | 846 |
946 void CFXEU_SetWordProps::Undo() | 847 void CFXEU_SetWordProps::Undo() { |
947 { | 848 if (m_pEdit) { |
948 » if (m_pEdit) | 849 m_pEdit->SetWordProps( |
949 » { | 850 m_eProps, m_wpPlace, &m_OldWordProps, m_wrPlace, FALSE); |
950 » » m_pEdit->SetWordProps(m_eProps,m_wpPlace,&m_OldWordProps,m_wrPla
ce,FALSE); | 851 if (IsFirst()) { |
951 » » if (IsFirst()) | 852 m_pEdit->SelectNone(); |
952 » » { | 853 m_pEdit->PaintSetProps(m_eProps, m_wrPlace); |
953 » » » m_pEdit->SelectNone(); | 854 m_pEdit->SetSel(m_wrPlace.BeginPos, m_wrPlace.EndPos); |
954 » » » m_pEdit->PaintSetProps(m_eProps,m_wrPlace); | 855 } |
955 » » » m_pEdit->SetSel(m_wrPlace.BeginPos,m_wrPlace.EndPos); | 856 } |
956 » » } | 857 } |
957 » } | 858 |
958 } | 859 /* ------------------------------------- CFX_Edit |
959 | 860 * ------------------------------------- */ |
960 /* ------------------------------------- CFX_Edit ------------------------------
------- */ | 861 |
961 | 862 CFX_Edit::CFX_Edit(IPDF_VariableText* pVT) |
962 CFX_Edit::CFX_Edit(IPDF_VariableText * pVT) : | 863 : m_pVT(pVT), |
963 » m_pVT(pVT), | 864 m_pNotify(NULL), |
964 » m_pNotify(NULL), | 865 m_pOprNotify(NULL), |
965 » m_pOprNotify(NULL), | 866 m_pVTProvide(NULL), |
966 » m_pVTProvide(NULL), | 867 m_wpCaret(-1, -1, -1), |
967 » m_wpCaret(-1,-1,-1), | 868 m_wpOldCaret(-1, -1, -1), |
968 » m_wpOldCaret(-1,-1,-1), | 869 m_SelState(), |
969 » m_SelState(), | 870 m_ptScrollPos(0, 0), |
970 » m_ptScrollPos(0,0), | 871 m_ptRefreshScrollPos(0, 0), |
971 » m_ptRefreshScrollPos(0,0), | 872 m_bEnableScroll(FALSE), |
972 » m_bEnableScroll(FALSE), | 873 m_pIterator(NULL), |
973 » m_pIterator(NULL), | 874 m_ptCaret(0.0f, 0.0f), |
974 » m_ptCaret(0.0f,0.0f), | 875 m_Undo(FX_EDIT_UNDO_MAXITEM), |
975 » m_Undo(FX_EDIT_UNDO_MAXITEM), | 876 m_nAlignment(0), |
976 » m_nAlignment(0), | 877 m_bNotifyFlag(FALSE), |
977 » m_bNotifyFlag(FALSE), | 878 m_bEnableOverflow(FALSE), |
978 » m_bEnableOverflow(FALSE), | 879 m_bEnableRefresh(TRUE), |
979 » m_bEnableRefresh(TRUE), | 880 m_rcOldContent(0.0f, 0.0f, 0.0f, 0.0f), |
980 » m_rcOldContent(0.0f,0.0f,0.0f,0.0f), | 881 m_bEnableUndo(TRUE), |
981 » m_bEnableUndo(TRUE), | 882 m_bNotify(TRUE), |
982 » m_bNotify(TRUE), | 883 m_bOprNotify(FALSE), |
983 » m_bOprNotify(FALSE), | 884 m_pGroupUndoItem(NULL) { |
984 » m_pGroupUndoItem(NULL) | 885 ASSERT(pVT != NULL); |
985 {» | 886 } |
986 » ASSERT(pVT != NULL); | 887 |
987 } | 888 CFX_Edit::~CFX_Edit() { |
988 | 889 if (m_pVTProvide) { |
989 CFX_Edit::~CFX_Edit() | 890 delete m_pVTProvide; |
990 { | 891 m_pVTProvide = NULL; |
991 » if (m_pVTProvide) | 892 } |
992 » { | 893 |
993 » » delete m_pVTProvide; | 894 if (m_pIterator) { |
994 » » m_pVTProvide = NULL; | 895 delete m_pIterator; |
995 » } | 896 m_pIterator = NULL; |
996 | 897 } |
997 » if (m_pIterator) | 898 |
998 » { | 899 ASSERT(m_pGroupUndoItem == NULL); |
999 » » delete m_pIterator; | |
1000 » » m_pIterator = NULL; | |
1001 » } | |
1002 | |
1003 » ASSERT(m_pGroupUndoItem == NULL); | |
1004 } | 900 } |
1005 | 901 |
1006 // public methods | 902 // public methods |
1007 | 903 |
1008 void CFX_Edit::Initialize() | 904 void CFX_Edit::Initialize() { |
1009 { | 905 m_pVT->Initialize(); |
1010 m_pVT->Initialize(); | 906 SetCaret(m_pVT->GetBeginWordPlace()); |
1011 SetCaret(m_pVT->GetBeginWordPlace()); | 907 SetCaretOrigin(); |
1012 SetCaretOrigin(); | 908 } |
1013 } | 909 |
1014 | 910 void CFX_Edit::SetFontMap(IFX_Edit_FontMap* pFontMap) { |
1015 void CFX_Edit::SetFontMap(IFX_Edit_FontMap * pFontMap) | 911 if (m_pVTProvide) |
1016 { | 912 delete m_pVTProvide; |
1017 if (m_pVTProvide) | 913 |
1018 delete m_pVTProvide; | 914 m_pVT->SetProvider(m_pVTProvide = new CFX_Edit_Provider(pFontMap)); |
1019 | 915 } |
1020 m_pVT->SetProvider(m_pVTProvide = new CFX_Edit_Provider(pFontMap)); | 916 |
1021 } | 917 void CFX_Edit::SetVTProvider(IPDF_VariableText_Provider* pProvider) { |
1022 | 918 m_pVT->SetProvider(pProvider); |
1023 void CFX_Edit::SetVTProvider(IPDF_VariableText_Provider* pProvider) | 919 } |
1024 { | 920 |
1025 m_pVT->SetProvider(pProvider); | 921 void CFX_Edit::SetNotify(IFX_Edit_Notify* pNotify) { |
1026 } | 922 m_pNotify = pNotify; |
1027 | 923 } |
1028 void CFX_Edit::SetNotify(IFX_Edit_Notify* pNotify) | 924 |
1029 { | 925 void CFX_Edit::SetOprNotify(IFX_Edit_OprNotify* pOprNotify) { |
1030 m_pNotify = pNotify; | 926 m_pOprNotify = pOprNotify; |
1031 } | 927 } |
1032 | 928 |
1033 void CFX_Edit::SetOprNotify(IFX_Edit_OprNotify* pOprNotify) | 929 IFX_Edit_Iterator* CFX_Edit::GetIterator() { |
1034 { | 930 if (!m_pIterator) |
1035 m_pOprNotify = pOprNotify; | 931 m_pIterator = new CFX_Edit_Iterator(this, m_pVT->GetIterator()); |
1036 } | 932 |
1037 | 933 return m_pIterator; |
1038 IFX_Edit_Iterator * CFX_Edit::GetIterator() | 934 } |
1039 { | 935 |
1040 if (!m_pIterator) | 936 IPDF_VariableText* CFX_Edit::GetVariableText() { |
1041 m_pIterator = new CFX_Edit_Iterator(this,m_pVT->GetIterator()); | 937 return m_pVT; |
1042 | 938 } |
1043 return m_pIterator; | 939 |
1044 } | 940 IFX_Edit_FontMap* CFX_Edit::GetFontMap() { |
1045 | 941 if (m_pVTProvide) |
1046 IPDF_VariableText * CFX_Edit::GetVariableText() | 942 return m_pVTProvide->GetFontMap(); |
1047 { | 943 |
1048 return m_pVT; | 944 return NULL; |
1049 } | 945 } |
1050 | 946 |
1051 IFX_Edit_FontMap* CFX_Edit::GetFontMap() | 947 void CFX_Edit::SetPlateRect(const CPDF_Rect& rect, FX_BOOL bPaint /* = TRUE*/) { |
1052 { | 948 m_pVT->SetPlateRect(rect); |
1053 if (m_pVTProvide) | 949 m_ptScrollPos = CPDF_Point(rect.left, rect.top); |
1054 return m_pVTProvide->GetFontMap(); | 950 if (bPaint) |
1055 | 951 Paint(); |
1056 return NULL; | 952 } |
1057 } | 953 |
1058 | 954 void CFX_Edit::SetAlignmentH(FX_INT32 nFormat /* =0 */, |
1059 void CFX_Edit::SetPlateRect(const CPDF_Rect & rect, FX_BOOL bPaint/* = TRUE*/) | 955 FX_BOOL bPaint /* = TRUE*/) { |
1060 { | 956 m_pVT->SetAlignment(nFormat); |
1061 m_pVT->SetPlateRect(rect); | 957 if (bPaint) |
1062 m_ptScrollPos = CPDF_Point(rect.left,rect.top); | 958 Paint(); |
1063 if (bPaint) Paint(); | 959 } |
1064 } | 960 |
1065 | 961 void CFX_Edit::SetAlignmentV(FX_INT32 nFormat /* =0 */, |
1066 void CFX_Edit::SetAlignmentH(FX_INT32 nFormat/* =0 */, FX_BOOL bPaint/* = TRUE*/
) | 962 FX_BOOL bPaint /* = TRUE*/) { |
1067 { | 963 m_nAlignment = nFormat; |
1068 m_pVT->SetAlignment(nFormat); | 964 if (bPaint) |
1069 if (bPaint) Paint(); | 965 Paint(); |
1070 } | 966 } |
1071 | 967 |
1072 void CFX_Edit::SetAlignmentV(FX_INT32 nFormat/* =0 */, FX_BOOL bPaint/* = TRUE*/
) | 968 void CFX_Edit::SetPasswordChar(FX_WORD wSubWord /* ='*' */, |
1073 { | 969 FX_BOOL bPaint /* = TRUE*/) { |
1074 m_nAlignment = nFormat; | 970 m_pVT->SetPasswordChar(wSubWord); |
1075 if (bPaint) Paint(); | 971 if (bPaint) |
1076 } | 972 Paint(); |
1077 | 973 } |
1078 void CFX_Edit::SetPasswordChar(FX_WORD wSubWord/* ='*' */, FX_BOOL bPaint/* = TR
UE*/) | 974 |
1079 { | 975 void CFX_Edit::SetLimitChar(FX_INT32 nLimitChar /* =0 */, |
1080 m_pVT->SetPasswordChar(wSubWord); | 976 FX_BOOL bPaint /* = TRUE*/) { |
1081 if (bPaint) Paint(); | 977 m_pVT->SetLimitChar(nLimitChar); |
1082 } | 978 if (bPaint) |
1083 | 979 Paint(); |
1084 void CFX_Edit::SetLimitChar(FX_INT32 nLimitChar/* =0 */, FX_BOOL bPaint/* = TRUE
*/) | 980 } |
1085 { | 981 |
1086 m_pVT->SetLimitChar(nLimitChar); | 982 void CFX_Edit::SetCharArray(FX_INT32 nCharArray /* =0 */, |
1087 if (bPaint) Paint(); | 983 FX_BOOL bPaint /* = TRUE*/) { |
1088 } | 984 m_pVT->SetCharArray(nCharArray); |
1089 | 985 if (bPaint) |
1090 void CFX_Edit::SetCharArray(FX_INT32 nCharArray/* =0 */, FX_BOOL bPaint/* = TRUE
*/) | 986 Paint(); |
1091 { | 987 } |
1092 m_pVT->SetCharArray(nCharArray); | 988 |
1093 if (bPaint) Paint(); | 989 void CFX_Edit::SetCharSpace(FX_FLOAT fCharSpace /* =0.0f */, |
1094 } | 990 FX_BOOL bPaint /* = TRUE*/) { |
1095 | 991 m_pVT->SetCharSpace(fCharSpace); |
1096 void CFX_Edit::SetCharSpace(FX_FLOAT fCharSpace/* =0.0f */, FX_BOOL bPaint/* = T
RUE*/) | 992 if (bPaint) |
1097 { | 993 Paint(); |
1098 m_pVT->SetCharSpace(fCharSpace); | 994 } |
1099 if (bPaint) Paint(); | 995 |
1100 } | 996 void CFX_Edit::SetHorzScale(FX_INT32 nHorzScale /* =100 */, |
1101 | 997 FX_BOOL bPaint /* = TRUE*/) { |
1102 void CFX_Edit::SetHorzScale(FX_INT32 nHorzScale/* =100 */, FX_BOOL bPaint/* = TR
UE*/) | 998 m_pVT->SetHorzScale(nHorzScale); |
1103 { | 999 if (bPaint) |
1104 m_pVT->SetHorzScale(nHorzScale); | 1000 Paint(); |
1105 if (bPaint) Paint(); | 1001 } |
1106 } | 1002 |
1107 | 1003 void CFX_Edit::SetMultiLine(FX_BOOL bMultiLine /* =TRUE */, |
1108 void CFX_Edit::SetMultiLine(FX_BOOL bMultiLine/* =TRUE */, FX_BOOL bPaint/* = TR
UE*/) | 1004 FX_BOOL bPaint /* = TRUE*/) { |
1109 { | 1005 m_pVT->SetMultiLine(bMultiLine); |
1110 m_pVT->SetMultiLine(bMultiLine); | 1006 if (bPaint) |
1111 if (bPaint) Paint(); | 1007 Paint(); |
1112 } | 1008 } |
1113 | 1009 |
1114 void CFX_Edit::SetAutoReturn(FX_BOOL bAuto/* =TRUE */, FX_BOOL bPaint/* = TRUE*/
) | 1010 void CFX_Edit::SetAutoReturn(FX_BOOL bAuto /* =TRUE */, |
1115 { | 1011 FX_BOOL bPaint /* = TRUE*/) { |
1116 m_pVT->SetAutoReturn(bAuto); | 1012 m_pVT->SetAutoReturn(bAuto); |
1117 if (bPaint) Paint(); | 1013 if (bPaint) |
1118 } | 1014 Paint(); |
1119 | 1015 } |
1120 void CFX_Edit::SetLineLeading(FX_FLOAT fLineLeading/* =TRUE */, FX_BOOL bPaint/*
= TRUE*/) | 1016 |
1121 { | 1017 void CFX_Edit::SetLineLeading(FX_FLOAT fLineLeading /* =TRUE */, |
1122 m_pVT->SetLineLeading(fLineLeading); | 1018 FX_BOOL bPaint /* = TRUE*/) { |
1123 if (bPaint) Paint(); | 1019 m_pVT->SetLineLeading(fLineLeading); |
1124 } | 1020 if (bPaint) |
1125 | 1021 Paint(); |
1126 void CFX_Edit::SetAutoFontSize(FX_BOOL bAuto/* =TRUE */, FX_BOOL bPaint/* = TRUE
*/) | 1022 } |
1127 { | 1023 |
1128 m_pVT->SetAutoFontSize(bAuto); | 1024 void CFX_Edit::SetAutoFontSize(FX_BOOL bAuto /* =TRUE */, |
1129 if (bPaint) Paint(); | 1025 FX_BOOL bPaint /* = TRUE*/) { |
1130 } | 1026 m_pVT->SetAutoFontSize(bAuto); |
1131 | 1027 if (bPaint) |
1132 void CFX_Edit::SetFontSize(FX_FLOAT fFontSize, FX_BOOL bPaint/* = TRUE*/) | 1028 Paint(); |
1133 { | 1029 } |
1134 m_pVT->SetFontSize(fFontSize); | 1030 |
1135 if (bPaint) Paint(); | 1031 void CFX_Edit::SetFontSize(FX_FLOAT fFontSize, FX_BOOL bPaint /* = TRUE*/) { |
1136 } | 1032 m_pVT->SetFontSize(fFontSize); |
1137 | 1033 if (bPaint) |
1138 void CFX_Edit::SetAutoScroll(FX_BOOL bAuto/* =TRUE */, FX_BOOL bPaint/* = TRUE*/
) | 1034 Paint(); |
1139 { | 1035 } |
1140 m_bEnableScroll = bAuto; | 1036 |
1141 if (bPaint) Paint(); | 1037 void CFX_Edit::SetAutoScroll(FX_BOOL bAuto /* =TRUE */, |
1142 } | 1038 FX_BOOL bPaint /* = TRUE*/) { |
1143 | 1039 m_bEnableScroll = bAuto; |
1144 void CFX_Edit::SetTextOverflow(FX_BOOL bAllowed /*= FALSE*/, FX_BOOL bPaint/* =
TRUE*/) | 1040 if (bPaint) |
1145 { | 1041 Paint(); |
1146 m_bEnableOverflow = bAllowed; | 1042 } |
1147 if (bPaint) Paint(); | 1043 |
1148 } | 1044 void CFX_Edit::SetTextOverflow(FX_BOOL bAllowed /*= FALSE*/, |
1149 | 1045 FX_BOOL bPaint /* = TRUE*/) { |
1150 void CFX_Edit::SetSel(FX_INT32 nStartChar,FX_INT32 nEndChar) | 1046 m_bEnableOverflow = bAllowed; |
1151 { | 1047 if (bPaint) |
1152 if (m_pVT->IsValid()) | 1048 Paint(); |
1153 { | 1049 } |
1154 if (nStartChar == 0 && nEndChar < 0) | 1050 |
1155 { | 1051 void CFX_Edit::SetSel(FX_INT32 nStartChar, FX_INT32 nEndChar) { |
1156 SelectAll(); | 1052 if (m_pVT->IsValid()) { |
1157 } | 1053 if (nStartChar == 0 && nEndChar < 0) { |
1158 else if (nStartChar < 0) | 1054 SelectAll(); |
1159 { | 1055 } else if (nStartChar < 0) { |
1160 this->SelectNone(); | 1056 this->SelectNone(); |
1161 } | 1057 } else { |
1162 else | 1058 if (nStartChar < nEndChar) { |
1163 { | 1059 SetSel(m_pVT->WordIndexToWordPlace(nStartChar), |
1164 if (nStartChar < nEndChar) | 1060 m_pVT->WordIndexToWordPlace(nEndChar)); |
1165 { | 1061 } else { |
1166 SetSel(m_pVT->WordIndexToWordPlace(nStartChar),m
_pVT->WordIndexToWordPlace(nEndChar)); | 1062 SetSel(m_pVT->WordIndexToWordPlace(nEndChar), |
1167 } | 1063 m_pVT->WordIndexToWordPlace(nStartChar)); |
1168 else | 1064 } |
1169 { | 1065 } |
1170 SetSel(m_pVT->WordIndexToWordPlace(nEndChar),m_p
VT->WordIndexToWordPlace(nStartChar)); | 1066 } |
1171 } | 1067 } |
1172 } | 1068 |
1173 } | 1069 void CFX_Edit::SetSel(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) { |
1174 } | 1070 if (m_pVT->IsValid()) { |
1175 | 1071 SelectNone(); |
1176 void CFX_Edit::SetSel(const CPVT_WordPlace & begin,const CPVT_WordPlace & end) | 1072 |
1177 { | 1073 m_SelState.Set(begin, end); |
1178 if (m_pVT->IsValid()) | 1074 |
1179 { | 1075 SetCaret(m_SelState.EndPos); |
1180 SelectNone(); | 1076 |
1181 | 1077 if (m_SelState.IsExist()) { |
1182 m_SelState.Set(begin,end); | 1078 ScrollToCaret(); |
1183 | 1079 CPVT_WordRange wr(m_SelState.BeginPos, m_SelState.EndPos); |
1184 SetCaret(m_SelState.EndPos); | 1080 Refresh(RP_OPTIONAL, &wr); |
1185 | 1081 SetCaretInfo(); |
1186 if (m_SelState.IsExist()) | 1082 } else { |
1187 { | 1083 ScrollToCaret(); |
1188 ScrollToCaret(); | 1084 SetCaretInfo(); |
1189 CPVT_WordRange wr(m_SelState.BeginPos,m_SelState.EndPos)
; | 1085 } |
1190 Refresh(RP_OPTIONAL,&wr); | 1086 } |
1191 SetCaretInfo(); | 1087 } |
1192 } | 1088 |
1193 else | 1089 void CFX_Edit::GetSel(FX_INT32& nStartChar, FX_INT32& nEndChar) const { |
1194 { | 1090 nStartChar = -1; |
1195 ScrollToCaret(); | 1091 nEndChar = -1; |
1196 SetCaretInfo(); | 1092 |
1197 } | 1093 if (m_pVT->IsValid()) { |
1198 } | 1094 if (m_SelState.IsExist()) { |
1199 } | 1095 if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos) < 0) { |
1200 | 1096 nStartChar = m_pVT->WordPlaceToWordIndex(m_SelState.BeginPos); |
1201 void CFX_Edit::GetSel(FX_INT32 & nStartChar, FX_INT32 & nEndChar) const | 1097 nEndChar = m_pVT->WordPlaceToWordIndex(m_SelState.EndPos); |
1202 { | 1098 } else { |
1203 nStartChar = -1; | 1099 nStartChar = m_pVT->WordPlaceToWordIndex(m_SelState.EndPos); |
1204 nEndChar = -1; | 1100 nEndChar = m_pVT->WordPlaceToWordIndex(m_SelState.BeginPos); |
1205 | 1101 } |
1206 if (m_pVT->IsValid()) | 1102 } else { |
1207 { | 1103 nStartChar = m_pVT->WordPlaceToWordIndex(m_wpCaret); |
1208 if (m_SelState.IsExist()) | 1104 nEndChar = m_pVT->WordPlaceToWordIndex(m_wpCaret); |
1209 { | 1105 } |
1210 if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos)<0) | 1106 } |
1211 { | 1107 } |
1212 nStartChar = m_pVT->WordPlaceToWordIndex(m_SelSt
ate.BeginPos); | 1108 |
1213 nEndChar = m_pVT->WordPlaceToWordIndex(m_SelStat
e.EndPos); | 1109 FX_INT32 CFX_Edit::GetCaret() const { |
1214 } | 1110 if (m_pVT->IsValid()) |
1215 else | 1111 return m_pVT->WordPlaceToWordIndex(m_wpCaret); |
1216 { | 1112 |
1217 nStartChar = m_pVT->WordPlaceToWordIndex(m_SelSt
ate.EndPos); | 1113 return -1; |
1218 nEndChar = m_pVT->WordPlaceToWordIndex(m_SelStat
e.BeginPos); | 1114 } |
1219 } | 1115 |
1220 } | 1116 CPVT_WordPlace CFX_Edit::GetCaretWordPlace() const { |
1221 else | 1117 return m_wpCaret; |
1222 { | 1118 } |
1223 nStartChar = m_pVT->WordPlaceToWordIndex(m_wpCaret); | 1119 |
1224 nEndChar = m_pVT->WordPlaceToWordIndex(m_wpCaret); | 1120 CFX_WideString CFX_Edit::GetText() const { |
1225 } | 1121 CFX_WideString swRet; |
1226 } | 1122 |
1227 } | 1123 if (m_pVT->IsValid()) { |
1228 | 1124 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
1229 FX_INT32 CFX_Edit::GetCaret() const | 1125 FX_BOOL bRich = m_pVT->IsRichText(); |
1230 { | 1126 |
1231 if (m_pVT->IsValid()) | 1127 pIterator->SetAt(0); |
1232 return m_pVT->WordPlaceToWordIndex(m_wpCaret); | 1128 |
1233 | 1129 CPVT_Word wordinfo; |
1234 return -1; | 1130 CPVT_WordPlace oldplace = pIterator->GetAt(); |
1235 } | 1131 while (pIterator->NextWord()) { |
1236 | 1132 CPVT_WordPlace place = pIterator->GetAt(); |
1237 CPVT_WordPlace CFX_Edit::GetCaretWordPlace() const | 1133 |
1238 { | 1134 if (pIterator->GetWord(wordinfo)) { |
1239 return m_wpCaret; | 1135 if (bRich) { |
1240 } | 1136 swRet += wordinfo.Word; |
1241 | 1137 } else { |
1242 CFX_WideString CFX_Edit::GetText() const | 1138 swRet += wordinfo.Word; |
1243 { | 1139 } |
1244 CFX_WideString swRet; | 1140 } |
1245 | 1141 |
1246 if (m_pVT->IsValid()) | 1142 if (oldplace.SecCmp(place) != 0) { |
1247 { | 1143 swRet += 0x0D; |
1248 if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator(
)) | 1144 swRet += 0x0A; |
1249 { | 1145 } |
1250 FX_BOOL bRich = m_pVT->IsRichText(); | 1146 |
1251 | 1147 oldplace = place; |
1252 pIterator->SetAt(0); | 1148 } |
1253 | 1149 } |
1254 CPVT_Word wordinfo; | 1150 } |
1255 CPVT_WordPlace oldplace = pIterator->GetAt(); | 1151 |
1256 while (pIterator->NextWord()) | 1152 return swRet; |
1257 { | 1153 } |
1258 CPVT_WordPlace place = pIterator->GetAt(); | 1154 |
1259 | 1155 CFX_WideString CFX_Edit::GetRangeText(const CPVT_WordRange& range) const { |
1260 if (pIterator->GetWord(wordinfo)) | 1156 CFX_WideString swRet; |
1261 { | 1157 |
1262 if (bRich) | 1158 if (m_pVT->IsValid()) { |
1263 { | 1159 FX_BOOL bRich = m_pVT->IsRichText(); |
1264 swRet += wordinfo.Word; | 1160 |
1265 } | 1161 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
1266 else | 1162 CPVT_WordRange wrTemp = range; |
1267 { | 1163 m_pVT->UpdateWordPlace(wrTemp.BeginPos); |
1268 swRet += wordinfo.Word; | 1164 m_pVT->UpdateWordPlace(wrTemp.EndPos); |
1269 } | 1165 pIterator->SetAt(wrTemp.BeginPos); |
1270 } | 1166 |
1271 | 1167 CPVT_Word wordinfo; |
1272 if (oldplace.SecCmp(place) != 0) | 1168 CPVT_WordPlace oldplace = wrTemp.BeginPos; |
1273 { | 1169 while (pIterator->NextWord()) { |
1274 swRet += 0x0D; | 1170 CPVT_WordPlace place = pIterator->GetAt(); |
1275 swRet += 0x0A; | 1171 if (place.WordCmp(wrTemp.EndPos) > 0) |
1276 } | 1172 break; |
1277 | 1173 |
1278 oldplace = place; | 1174 if (pIterator->GetWord(wordinfo)) { |
1279 } | 1175 if (bRich) { |
1280 } | 1176 swRet += wordinfo.Word; |
1281 } | 1177 } else { |
1282 | 1178 swRet += wordinfo.Word; |
1283 return swRet; | 1179 } |
1284 } | 1180 } |
1285 | 1181 |
1286 CFX_WideString CFX_Edit::GetRangeText(const CPVT_WordRange & range) const | 1182 if (oldplace.SecCmp(place) != 0) { |
1287 { | 1183 swRet += 0x0D; |
1288 CFX_WideString swRet; | 1184 swRet += 0x0A; |
1289 | 1185 } |
1290 if (m_pVT->IsValid()) | 1186 |
1291 { | 1187 oldplace = place; |
1292 FX_BOOL bRich = m_pVT->IsRichText(); | 1188 } |
1293 | 1189 } |
1294 if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator(
)) | 1190 } |
1295 { | 1191 |
1296 CPVT_WordRange wrTemp = range; | 1192 return swRet; |
1297 m_pVT->UpdateWordPlace(wrTemp.BeginPos); | 1193 } |
1298 m_pVT->UpdateWordPlace(wrTemp.EndPos); | 1194 |
1299 pIterator->SetAt(wrTemp.BeginPos); | 1195 CFX_WideString CFX_Edit::GetSelText() const { |
1300 | 1196 return GetRangeText(m_SelState.ConvertToWordRange()); |
1301 CPVT_Word wordinfo; | 1197 } |
1302 CPVT_WordPlace oldplace = wrTemp.BeginPos; | 1198 |
1303 while (pIterator->NextWord()) | 1199 FX_INT32 CFX_Edit::GetTotalWords() const { |
1304 { | 1200 return m_pVT->GetTotalWords(); |
1305 CPVT_WordPlace place = pIterator->GetAt(); | 1201 } |
1306 if (place.WordCmp(wrTemp.EndPos) > 0)break; | 1202 |
1307 | 1203 FX_INT32 CFX_Edit::GetTotalLines() const { |
1308 if (pIterator->GetWord(wordinfo)) | 1204 FX_INT32 nLines = 0; |
1309 { | 1205 |
1310 if (bRich) | 1206 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
1311 { | 1207 pIterator->SetAt(0); |
1312 swRet += wordinfo.Word; | 1208 while (pIterator->NextLine()) |
1313 } | 1209 nLines++; |
1314 else | 1210 } |
1315 { | 1211 |
1316 swRet += wordinfo.Word; | 1212 return nLines + 1; |
1317 } | 1213 } |
1318 } | 1214 |
1319 | 1215 CPVT_WordRange CFX_Edit::GetSelectWordRange() const { |
1320 if (oldplace.SecCmp(place) != 0) | 1216 return m_SelState.ConvertToWordRange(); |
1321 { | 1217 } |
1322 swRet += 0x0D; | 1218 |
1323 swRet += 0x0A; | 1219 CPVT_WordRange CFX_Edit::CombineWordRange(const CPVT_WordRange& wr1, |
1324 } | 1220 const CPVT_WordRange& wr2) { |
1325 | 1221 CPVT_WordRange wrRet; |
1326 oldplace = place; | 1222 |
1327 } | 1223 if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0) { |
1328 } | 1224 wrRet.BeginPos = wr1.BeginPos; |
1329 } | 1225 } else { |
1330 | 1226 wrRet.BeginPos = wr2.BeginPos; |
1331 return swRet; | 1227 } |
1332 } | 1228 |
1333 | 1229 if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) { |
1334 CFX_WideString CFX_Edit::GetSelText() const | 1230 wrRet.EndPos = wr2.EndPos; |
1335 { | 1231 } else { |
1336 return GetRangeText(m_SelState.ConvertToWordRange()); | 1232 wrRet.EndPos = wr1.EndPos; |
1337 } | 1233 } |
1338 | 1234 |
1339 FX_INT32 CFX_Edit::GetTotalWords() const | 1235 return wrRet; |
1340 { | 1236 } |
1341 return m_pVT->GetTotalWords(); | 1237 |
1342 } | 1238 FX_BOOL CFX_Edit::IsRichText() const { |
1343 | 1239 return m_pVT->IsRichText(); |
1344 FX_INT32 CFX_Edit::GetTotalLines() const | 1240 } |
1345 { | 1241 |
1346 FX_INT32 nLines = 0; | 1242 void CFX_Edit::SetRichText(FX_BOOL bRichText /* =TRUE */, |
1347 | 1243 FX_BOOL bPaint /* = TRUE*/) { |
1348 if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator()) | 1244 m_pVT->SetRichText(bRichText); |
1349 { | 1245 if (bPaint) |
1350 pIterator->SetAt(0); | 1246 Paint(); |
1351 while (pIterator->NextLine()) | 1247 } |
1352 nLines++; | 1248 |
1353 } | 1249 FX_BOOL CFX_Edit::SetRichFontIndex(FX_INT32 nFontIndex) { |
1354 | 1250 CPVT_WordProps WordProps; |
1355 return nLines+1; | 1251 WordProps.nFontIndex = nFontIndex; |
1356 } | 1252 return SetRichTextProps(EP_FONTINDEX, NULL, &WordProps); |
1357 | 1253 } |
1358 CPVT_WordRange CFX_Edit::GetSelectWordRange() const | 1254 |
1359 { | 1255 FX_BOOL CFX_Edit::SetRichFontSize(FX_FLOAT fFontSize) { |
1360 return m_SelState.ConvertToWordRange(); | 1256 CPVT_WordProps WordProps; |
1361 } | 1257 WordProps.fFontSize = fFontSize; |
1362 | 1258 return SetRichTextProps(EP_FONTSIZE, NULL, &WordProps); |
1363 CPVT_WordRange CFX_Edit::CombineWordRange(const CPVT_WordRange & wr1, const CPVT
_WordRange & wr2) | 1259 } |
1364 { | 1260 |
1365 CPVT_WordRange wrRet; | 1261 FX_BOOL CFX_Edit::SetRichTextColor(FX_COLORREF dwColor) { |
1366 | 1262 CPVT_WordProps WordProps; |
1367 if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0) | 1263 WordProps.dwWordColor = dwColor; |
1368 { | 1264 return SetRichTextProps(EP_WORDCOLOR, NULL, &WordProps); |
1369 wrRet.BeginPos = wr1.BeginPos; | 1265 } |
1370 } | 1266 |
1371 else | 1267 FX_BOOL CFX_Edit::SetRichTextScript(FX_INT32 nScriptType) { |
1372 { | 1268 CPVT_WordProps WordProps; |
1373 wrRet.BeginPos = wr2.BeginPos; | 1269 WordProps.nScriptType = nScriptType; |
1374 } | 1270 return SetRichTextProps(EP_SCRIPTTYPE, NULL, &WordProps); |
1375 | 1271 } |
1376 if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) | 1272 |
1377 { | 1273 FX_BOOL CFX_Edit::SetRichTextBold(FX_BOOL bBold) { |
1378 wrRet.EndPos = wr2.EndPos; | 1274 CPVT_WordProps WordProps; |
1379 } | 1275 if (bBold) |
1380 else | 1276 WordProps.nWordStyle |= PVTWORD_STYLE_BOLD; |
1381 { | 1277 return SetRichTextProps(EP_BOLD, NULL, &WordProps); |
1382 wrRet.EndPos = wr1.EndPos; | 1278 } |
1383 } | 1279 |
1384 | 1280 FX_BOOL CFX_Edit::SetRichTextItalic(FX_BOOL bItalic) { |
1385 return wrRet; | 1281 CPVT_WordProps WordProps; |
1386 } | 1282 if (bItalic) |
1387 | 1283 WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC; |
1388 FX_BOOL CFX_Edit::IsRichText() const | 1284 return SetRichTextProps(EP_ITALIC, NULL, &WordProps); |
1389 { | 1285 } |
1390 return m_pVT->IsRichText(); | 1286 |
1391 } | 1287 FX_BOOL CFX_Edit::SetRichTextUnderline(FX_BOOL bUnderline) { |
1392 | 1288 CPVT_WordProps WordProps; |
1393 void CFX_Edit::SetRichText(FX_BOOL bRichText/* =TRUE */, FX_BOOL bPaint/* = TRUE
*/) | 1289 if (bUnderline) |
1394 { | 1290 WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE; |
1395 m_pVT->SetRichText(bRichText); | 1291 return SetRichTextProps(EP_UNDERLINE, NULL, &WordProps); |
1396 if (bPaint) Paint(); | 1292 } |
1397 } | 1293 |
1398 | 1294 FX_BOOL CFX_Edit::SetRichTextCrossout(FX_BOOL bCrossout) { |
1399 FX_BOOL CFX_Edit::SetRichFontIndex(FX_INT32 nFontIndex) | 1295 CPVT_WordProps WordProps; |
1400 { | 1296 if (bCrossout) |
1401 CPVT_WordProps WordProps; | 1297 WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT; |
1402 WordProps.nFontIndex = nFontIndex; | 1298 return SetRichTextProps(EP_CROSSOUT, NULL, &WordProps); |
1403 return SetRichTextProps(EP_FONTINDEX,NULL,&WordProps); | 1299 } |
1404 } | 1300 |
1405 | 1301 FX_BOOL CFX_Edit::SetRichTextCharSpace(FX_FLOAT fCharSpace) { |
1406 FX_BOOL CFX_Edit::SetRichFontSize(FX_FLOAT fFontSize) | 1302 CPVT_WordProps WordProps; |
1407 { | 1303 WordProps.fCharSpace = fCharSpace; |
1408 CPVT_WordProps WordProps; | 1304 return SetRichTextProps(EP_CHARSPACE, NULL, &WordProps); |
1409 WordProps.fFontSize = fFontSize; | 1305 } |
1410 return SetRichTextProps(EP_FONTSIZE,NULL,&WordProps); | 1306 |
1411 } | 1307 FX_BOOL CFX_Edit::SetRichTextHorzScale(FX_INT32 nHorzScale /*= 100*/) { |
1412 | 1308 CPVT_WordProps WordProps; |
1413 FX_BOOL CFX_Edit::SetRichTextColor(FX_COLORREF dwColor) | 1309 WordProps.nHorzScale = nHorzScale; |
1414 { | 1310 return SetRichTextProps(EP_HORZSCALE, NULL, &WordProps); |
1415 CPVT_WordProps WordProps; | 1311 } |
1416 WordProps.dwWordColor = dwColor; | 1312 |
1417 return SetRichTextProps(EP_WORDCOLOR,NULL,&WordProps); | 1313 FX_BOOL CFX_Edit::SetRichTextLineLeading(FX_FLOAT fLineLeading) { |
1418 } | 1314 CPVT_SecProps SecProps; |
1419 | 1315 SecProps.fLineLeading = fLineLeading; |
1420 FX_BOOL CFX_Edit::SetRichTextScript(FX_INT32 nScriptType) | 1316 return SetRichTextProps(EP_LINELEADING, &SecProps, NULL); |
1421 { | 1317 } |
1422 CPVT_WordProps WordProps; | 1318 |
1423 WordProps.nScriptType = nScriptType; | 1319 FX_BOOL CFX_Edit::SetRichTextLineIndent(FX_FLOAT fLineIndent) { |
1424 return SetRichTextProps(EP_SCRIPTTYPE,NULL,&WordProps); | 1320 CPVT_SecProps SecProps; |
1425 } | 1321 SecProps.fLineIndent = fLineIndent; |
1426 | 1322 return SetRichTextProps(EP_LINEINDENT, &SecProps, NULL); |
1427 FX_BOOL CFX_Edit::SetRichTextBold(FX_BOOL bBold) | 1323 } |
1428 { | 1324 |
1429 CPVT_WordProps WordProps; | 1325 FX_BOOL CFX_Edit::SetRichTextAlignment(FX_INT32 nAlignment) { |
1430 if (bBold) | 1326 CPVT_SecProps SecProps; |
1431 WordProps.nWordStyle |= PVTWORD_STYLE_BOLD; | 1327 SecProps.nAlignment = nAlignment; |
1432 return SetRichTextProps(EP_BOLD,NULL,&WordProps); | 1328 return SetRichTextProps(EP_ALIGNMENT, &SecProps, NULL); |
1433 } | 1329 } |
1434 | 1330 |
1435 FX_BOOL CFX_Edit::SetRichTextItalic(FX_BOOL bItalic) | 1331 FX_BOOL CFX_Edit::SetRichTextProps(EDIT_PROPS_E eProps, |
1436 { | 1332 const CPVT_SecProps* pSecProps, |
1437 CPVT_WordProps WordProps; | 1333 const CPVT_WordProps* pWordProps) { |
1438 if (bItalic) | 1334 FX_BOOL bSet = FALSE; |
1439 WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC; | 1335 FX_BOOL bSet1, bSet2; |
1440 return SetRichTextProps(EP_ITALIC,NULL,&WordProps); | 1336 if (m_pVT->IsValid() && m_pVT->IsRichText()) { |
1441 } | 1337 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
1442 | 1338 CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange(); |
1443 FX_BOOL CFX_Edit::SetRichTextUnderline(FX_BOOL bUnderline) | 1339 |
1444 { | 1340 m_pVT->UpdateWordPlace(wrTemp.BeginPos); |
1445 CPVT_WordProps WordProps; | 1341 m_pVT->UpdateWordPlace(wrTemp.EndPos); |
1446 if (bUnderline) | 1342 pIterator->SetAt(wrTemp.BeginPos); |
1447 WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE; | 1343 |
1448 return SetRichTextProps(EP_UNDERLINE,NULL,&WordProps); | 1344 BeginGroupUndo(L""); |
1449 } | 1345 ; |
1450 | 1346 |
1451 FX_BOOL CFX_Edit::SetRichTextCrossout(FX_BOOL bCrossout) | 1347 bSet = SetSecProps( |
1452 { | 1348 eProps, wrTemp.BeginPos, pSecProps, pWordProps, wrTemp, TRUE); |
1453 CPVT_WordProps WordProps; | 1349 |
1454 if (bCrossout) | 1350 while (pIterator->NextWord()) { |
1455 WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT; | 1351 CPVT_WordPlace place = pIterator->GetAt(); |
1456 return SetRichTextProps(EP_CROSSOUT,NULL,&WordProps); | 1352 if (place.WordCmp(wrTemp.EndPos) > 0) |
1457 } | 1353 break; |
1458 | 1354 bSet1 = SetSecProps(eProps, place, pSecProps, pWordProps, wrTemp, TRUE); |
1459 FX_BOOL CFX_Edit::SetRichTextCharSpace(FX_FLOAT fCharSpace) | 1355 bSet2 = SetWordProps(eProps, place, pWordProps, wrTemp, TRUE); |
1460 { | 1356 |
1461 CPVT_WordProps WordProps; | 1357 if (!bSet) |
1462 WordProps.fCharSpace = fCharSpace; | 1358 bSet = (bSet1 || bSet2); |
1463 return SetRichTextProps(EP_CHARSPACE,NULL,&WordProps); | 1359 } |
1464 } | 1360 |
1465 | 1361 EndGroupUndo(); |
1466 FX_BOOL CFX_Edit::SetRichTextHorzScale(FX_INT32 nHorzScale /*= 100*/) | 1362 |
1467 { | 1363 if (bSet) { |
1468 CPVT_WordProps WordProps; | 1364 PaintSetProps(eProps, wrTemp); |
1469 WordProps.nHorzScale = nHorzScale; | 1365 } |
1470 return SetRichTextProps(EP_HORZSCALE,NULL,&WordProps); | 1366 } |
1471 } | 1367 } |
1472 | 1368 |
1473 FX_BOOL CFX_Edit::SetRichTextLineLeading(FX_FLOAT fLineLeading) | 1369 return bSet; |
1474 { | 1370 } |
1475 CPVT_SecProps SecProps; | 1371 |
1476 SecProps.fLineLeading = fLineLeading; | 1372 void CFX_Edit::PaintSetProps(EDIT_PROPS_E eProps, const CPVT_WordRange& wr) { |
1477 return SetRichTextProps(EP_LINELEADING,&SecProps,NULL); | 1373 switch (eProps) { |
1478 } | 1374 case EP_LINELEADING: |
1479 | 1375 case EP_LINEINDENT: |
1480 FX_BOOL CFX_Edit::SetRichTextLineIndent(FX_FLOAT fLineIndent) | 1376 case EP_ALIGNMENT: |
1481 { | 1377 RearrangePart(wr); |
1482 CPVT_SecProps SecProps; | 1378 ScrollToCaret(); |
1483 SecProps.fLineIndent = fLineIndent; | 1379 Refresh(RP_ANALYSE); |
1484 return SetRichTextProps(EP_LINEINDENT,&SecProps,NULL); | 1380 SetCaretOrigin(); |
1485 } | 1381 SetCaretInfo(); |
1486 | 1382 break; |
1487 FX_BOOL CFX_Edit::SetRichTextAlignment(FX_INT32 nAlignment) | 1383 case EP_WORDCOLOR: |
1488 { | 1384 case EP_UNDERLINE: |
1489 CPVT_SecProps SecProps; | 1385 case EP_CROSSOUT: |
1490 SecProps.nAlignment = nAlignment; | 1386 Refresh(RP_OPTIONAL, &wr); |
1491 return SetRichTextProps(EP_ALIGNMENT,&SecProps,NULL); | 1387 break; |
1492 } | 1388 case EP_FONTINDEX: |
1493 | 1389 case EP_FONTSIZE: |
1494 FX_BOOL CFX_Edit::SetRichTextProps(EDIT_PROPS_E eProps, const CPVT_SecProps * pS
ecProps, const CPVT_WordProps * pWordProps) | 1390 case EP_SCRIPTTYPE: |
1495 { | 1391 case EP_CHARSPACE: |
1496 FX_BOOL bSet = FALSE; | 1392 case EP_HORZSCALE: |
1497 FX_BOOL bSet1,bSet2; | 1393 case EP_BOLD: |
1498 if (m_pVT->IsValid() && m_pVT->IsRichText()) | 1394 case EP_ITALIC: |
1499 { | 1395 RearrangePart(wr); |
1500 if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator(
)) | 1396 ScrollToCaret(); |
1501 { | 1397 |
1502 CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange(); | 1398 CPVT_WordRange wrRefresh(m_pVT->GetSectionBeginPlace(wr.BeginPos), |
1503 | 1399 m_pVT->GetSectionEndPlace(wr.EndPos)); |
1504 m_pVT->UpdateWordPlace(wrTemp.BeginPos); | 1400 Refresh(RP_ANALYSE, &wrRefresh); |
1505 m_pVT->UpdateWordPlace(wrTemp.EndPos); | 1401 |
1506 pIterator->SetAt(wrTemp.BeginPos); | 1402 SetCaretOrigin(); |
1507 | 1403 SetCaretInfo(); |
1508 BeginGroupUndo(L"");; | 1404 break; |
1509 | 1405 } |
1510 bSet = SetSecProps(eProps,wrTemp.BeginPos,pSecProps,pWor
dProps,wrTemp,TRUE); | 1406 } |
1511 | 1407 |
1512 while (pIterator->NextWord()) | 1408 FX_BOOL CFX_Edit::SetSecProps(EDIT_PROPS_E eProps, |
1513 { | 1409 const CPVT_WordPlace& place, |
1514 CPVT_WordPlace place = pIterator->GetAt(); | 1410 const CPVT_SecProps* pSecProps, |
1515 if (place.WordCmp(wrTemp.EndPos) > 0) break; | 1411 const CPVT_WordProps* pWordProps, |
1516 bSet1 = SetSecProps(eProps,place,pSecProps,pWord
Props,wrTemp,TRUE); | 1412 const CPVT_WordRange& wr, |
1517 bSet2 = SetWordProps(eProps,place,pWordProps,wrT
emp,TRUE); | 1413 FX_BOOL bAddUndo) { |
1518 | 1414 if (m_pVT->IsValid() && m_pVT->IsRichText()) { |
1519 if (!bSet) | 1415 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
1520 bSet = (bSet1 || bSet2); | 1416 FX_BOOL bSet = FALSE; |
1521 } | 1417 CPVT_Section secinfo; |
1522 | 1418 CPVT_Section OldSecinfo; |
1523 EndGroupUndo(); | 1419 |
1524 | 1420 CPVT_WordPlace oldplace = pIterator->GetAt(); |
1525 if (bSet) | 1421 |
1526 { | 1422 if (eProps == EP_LINELEADING || eProps == EP_LINEINDENT || |
1527 PaintSetProps(eProps,wrTemp); | 1423 eProps == EP_ALIGNMENT) { |
1528 } | 1424 if (pSecProps) { |
1529 } | 1425 pIterator->SetAt(place); |
1530 } | 1426 if (pIterator->GetSection(secinfo)) { |
1531 | 1427 if (bAddUndo) |
1532 return bSet; | 1428 OldSecinfo = secinfo; |
1533 } | 1429 |
1534 | 1430 switch (eProps) { |
1535 void CFX_Edit::PaintSetProps(EDIT_PROPS_E eProps, const CPVT_WordRange & wr) | 1431 case EP_LINELEADING: |
1536 { | 1432 if (!FX_EDIT_IsFloatEqual(secinfo.SecProps.fLineLeading, |
1537 switch(eProps) | 1433 pSecProps->fLineLeading)) { |
1538 { | 1434 secinfo.SecProps.fLineLeading = pSecProps->fLineLeading; |
1539 case EP_LINELEADING: | 1435 bSet = TRUE; |
1540 case EP_LINEINDENT: | 1436 } |
1541 case EP_ALIGNMENT: | 1437 break; |
1542 RearrangePart(wr); | 1438 case EP_LINEINDENT: |
1543 ScrollToCaret(); | 1439 if (!FX_EDIT_IsFloatEqual(secinfo.SecProps.fLineIndent, |
1544 Refresh(RP_ANALYSE); | 1440 pSecProps->fLineIndent)) { |
1545 SetCaretOrigin(); | 1441 secinfo.SecProps.fLineIndent = pSecProps->fLineIndent; |
1546 SetCaretInfo(); | 1442 bSet = TRUE; |
1547 break; | 1443 } |
1548 case EP_WORDCOLOR: | 1444 break; |
1549 case EP_UNDERLINE: | 1445 case EP_ALIGNMENT: |
1550 case EP_CROSSOUT: | 1446 if (secinfo.SecProps.nAlignment != pSecProps->nAlignment) { |
1551 Refresh(RP_OPTIONAL,&wr); | 1447 secinfo.SecProps.nAlignment = pSecProps->nAlignment; |
1552 break; | 1448 bSet = TRUE; |
1553 case EP_FONTINDEX: | 1449 } |
1554 case EP_FONTSIZE: | 1450 break; |
1555 case EP_SCRIPTTYPE: | 1451 default: |
1556 case EP_CHARSPACE: | 1452 break; |
1557 case EP_HORZSCALE: | 1453 } |
1558 case EP_BOLD: | 1454 } |
1559 case EP_ITALIC: | 1455 } |
1560 RearrangePart(wr); | 1456 } else { |
1561 ScrollToCaret(); | 1457 if (pWordProps && place == m_pVT->GetSectionBeginPlace(place)) { |
1562 | 1458 pIterator->SetAt(place); |
1563 CPVT_WordRange wrRefresh(m_pVT->GetSectionBeginPlace(wr.BeginPos
), | 1459 if (pIterator->GetSection(secinfo)) { |
1564 m_pVT->GetSectionEndPlace(wr.EndPos)); | 1460 if (bAddUndo) |
1565 Refresh(RP_ANALYSE,&wrRefresh); | 1461 OldSecinfo = secinfo; |
1566 | 1462 |
1567 SetCaretOrigin(); | 1463 switch (eProps) { |
1568 SetCaretInfo(); | 1464 case EP_FONTINDEX: |
1569 break; | 1465 if (secinfo.WordProps.nFontIndex != pWordProps->nFontIndex) { |
1570 } | 1466 secinfo.WordProps.nFontIndex = pWordProps->nFontIndex; |
1571 } | 1467 bSet = TRUE; |
1572 | 1468 } |
1573 FX_BOOL CFX_Edit::SetSecProps(EDIT_PROPS_E eProps, const CPVT_WordPlace & place,
| 1469 break; |
1574 const CPVT_SecProps *
pSecProps, const CPVT_WordProps * pWordProps, | 1470 case EP_FONTSIZE: |
1575 const CPVT_WordRange
& wr, FX_BOOL bAddUndo) | 1471 if (!FX_EDIT_IsFloatEqual(secinfo.WordProps.fFontSize, |
1576 { | 1472 pWordProps->fFontSize)) { |
1577 if (m_pVT->IsValid() && m_pVT->IsRichText()) | 1473 secinfo.WordProps.fFontSize = pWordProps->fFontSize; |
1578 { | 1474 bSet = TRUE; |
1579 if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator(
)) | 1475 } |
1580 { | 1476 break; |
1581 FX_BOOL bSet = FALSE; | 1477 case EP_WORDCOLOR: |
1582 CPVT_Section secinfo; | 1478 if (secinfo.WordProps.dwWordColor != pWordProps->dwWordColor) { |
1583 CPVT_Section OldSecinfo; | 1479 secinfo.WordProps.dwWordColor = pWordProps->dwWordColor; |
1584 | 1480 bSet = TRUE; |
1585 CPVT_WordPlace oldplace = pIterator->GetAt(); | 1481 } |
1586 | 1482 break; |
1587 if (eProps == EP_LINELEADING || eProps == EP_LINEINDENT
|| eProps == EP_ALIGNMENT) | 1483 case EP_SCRIPTTYPE: |
1588 { | 1484 if (secinfo.WordProps.nScriptType != pWordProps->nScriptType) { |
1589 if (pSecProps) | 1485 secinfo.WordProps.nScriptType = pWordProps->nScriptType; |
1590 { | 1486 bSet = TRUE; |
1591 pIterator->SetAt(place); | 1487 } |
1592 if (pIterator->GetSection(secinfo)) | 1488 break; |
1593 { | 1489 case EP_CHARSPACE: |
1594 if (bAddUndo) OldSecinfo = secin
fo; | 1490 if (!FX_EDIT_IsFloatEqual(secinfo.WordProps.fCharSpace, |
1595 | 1491 pWordProps->fCharSpace)) { |
1596 switch(eProps) | 1492 secinfo.WordProps.fCharSpace = pWordProps->fCharSpace; |
1597 { | 1493 bSet = TRUE; |
1598 case EP_LINELEADING:
| 1494 } |
1599 if (!FX_EDIT_IsFloatEqua
l(secinfo.SecProps.fLineLeading,pSecProps->fLineLeading)) | 1495 break; |
1600 { | 1496 case EP_HORZSCALE: |
1601 secinfo.SecProps
.fLineLeading = pSecProps->fLineLeading;
| 1497 if (secinfo.WordProps.nHorzScale != pWordProps->nHorzScale) { |
1602 bSet = TRUE; | 1498 secinfo.WordProps.nHorzScale = pWordProps->nHorzScale; |
1603 } | 1499 bSet = TRUE; |
1604 break; | 1500 } |
1605 case EP_LINEINDENT: | 1501 break; |
1606 if (!FX_EDIT_IsFloatEqua
l(secinfo.SecProps.fLineIndent,pSecProps->fLineIndent)) | 1502 case EP_UNDERLINE: |
1607 { | 1503 if (pWordProps->nWordStyle & PVTWORD_STYLE_UNDERLINE) { |
1608 secinfo.SecProps
.fLineIndent = pSecProps->fLineIndent; | 1504 if ((secinfo.WordProps.nWordStyle & |
1609 bSet = TRUE; | 1505 PVTWORD_STYLE_UNDERLINE) == 0) { |
1610 } | 1506 secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE; |
1611 break; | 1507 bSet = TRUE; |
1612 case EP_ALIGNMENT: | 1508 } |
1613 if (secinfo.SecProps.nAl
ignment != pSecProps->nAlignment) | 1509 } else { |
1614 { | 1510 if ((secinfo.WordProps.nWordStyle & |
1615 secinfo.SecProps
.nAlignment = pSecProps->nAlignment; | 1511 PVTWORD_STYLE_UNDERLINE) != 0) { |
1616 bSet = TRUE; | 1512 secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_UNDERLINE; |
1617 } | 1513 bSet = TRUE; |
1618 break; | 1514 } |
1619 default: | 1515 } |
1620 break; | 1516 break; |
1621 } | 1517 case EP_CROSSOUT: |
1622 } | 1518 if (pWordProps->nWordStyle & PVTWORD_STYLE_CROSSOUT) { |
1623 } | 1519 if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) == |
1624 } | 1520 0) { |
1625 else | 1521 secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT; |
1626 { | 1522 bSet = TRUE; |
1627 if (pWordProps && place == m_pVT->GetSectionBegi
nPlace(place)) | 1523 } |
1628 { | 1524 } else { |
1629 pIterator->SetAt(place); | 1525 if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) != |
1630 if (pIterator->GetSection(secinfo)) | 1526 0) { |
1631 { | 1527 secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_CROSSOUT; |
1632 if (bAddUndo) OldSecinfo = secin
fo; | 1528 bSet = TRUE; |
1633 | 1529 } |
1634 switch(eProps) | 1530 } |
1635 { | 1531 break; |
1636 case EP_FONTINDEX:
| 1532 case EP_BOLD: |
1637 if (secinfo.WordProps.nF
ontIndex != pWordProps->nFontIndex) | 1533 if (pWordProps->nWordStyle & PVTWORD_STYLE_BOLD) { |
1638 { | 1534 if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) == |
1639 secinfo.WordProp
s.nFontIndex = pWordProps->nFontIndex; | 1535 0) { |
1640 bSet = TRUE; | 1536 secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_BOLD; |
1641 } | 1537 bSet = TRUE; |
1642 break; | 1538 } |
1643 case EP_FONTSIZE: | 1539 } else { |
1644 if (!FX_EDIT_IsFloatEqua
l(secinfo.WordProps.fFontSize,pWordProps->fFontSize)) | 1540 if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) != |
1645 { | 1541 0) { |
1646 secinfo.WordProp
s.fFontSize = pWordProps->fFontSize; | 1542 secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_BOLD; |
1647 bSet = TRUE; | 1543 bSet = TRUE; |
1648 } | 1544 } |
1649 break; | 1545 } |
1650 case EP_WORDCOLOR: | 1546 break; |
1651 if (secinfo.WordProps.dw
WordColor != pWordProps->dwWordColor) | 1547 case EP_ITALIC: |
1652 { | 1548 if (pWordProps->nWordStyle & PVTWORD_STYLE_ITALIC) { |
1653 secinfo.WordProp
s.dwWordColor = pWordProps->dwWordColor; | 1549 if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) == |
1654 bSet = TRUE; | 1550 0) { |
1655 } | 1551 secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC; |
1656 break; | 1552 bSet = TRUE; |
1657 case EP_SCRIPTTYPE:
| 1553 } |
1658 if (secinfo.WordProps.nS
criptType != pWordProps->nScriptType) | 1554 } else { |
1659 { | 1555 if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) != |
1660 secinfo.WordProp
s.nScriptType = pWordProps->nScriptType; | 1556 0) { |
1661 bSet = TRUE; | 1557 secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_ITALIC; |
1662 } | 1558 bSet = TRUE; |
1663 break; | 1559 } |
1664 case EP_CHARSPACE:
| 1560 } |
1665 if (!FX_EDIT_IsFloatEqua
l(secinfo.WordProps.fCharSpace,pWordProps->fCharSpace)) | 1561 break; |
1666 { | 1562 default: |
1667 secinfo.WordProp
s.fCharSpace = pWordProps->fCharSpace; | 1563 break; |
1668 bSet = TRUE; | 1564 } |
1669 } | 1565 } |
1670 break; | 1566 } |
1671 case EP_HORZSCALE:
| 1567 } |
1672 if (secinfo.WordProps.nH
orzScale != pWordProps->nHorzScale) | 1568 |
1673 { | 1569 if (bSet) { |
1674 secinfo.WordProp
s.nHorzScale = pWordProps->nHorzScale; | 1570 pIterator->SetSection(secinfo); |
1675 bSet = TRUE; | 1571 |
1676 } | 1572 if (bAddUndo && m_bEnableUndo) { |
1677 break; | 1573 AddEditUndoItem(new CFXEU_SetSecProps(this, |
1678 case EP_UNDERLINE: | 1574 place, |
1679 if (pWordProps->nWordSty
le & PVTWORD_STYLE_UNDERLINE) | 1575 eProps, |
1680 { | 1576 OldSecinfo.SecProps, |
1681 if ((secinfo.Wor
dProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) == 0) | 1577 OldSecinfo.WordProps, |
1682 { | 1578 secinfo.SecProps, |
1683 secinfo.
WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE; | 1579 secinfo.WordProps, |
1684 bSet = T
RUE; | 1580 wr)); |
1685 } | 1581 } |
1686 } | 1582 } |
1687 else | 1583 |
1688 { | 1584 pIterator->SetAt(oldplace); |
1689 if ((secinfo.Wor
dProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) != 0) | 1585 |
1690 { | 1586 return bSet; |
1691 secinfo.
WordProps.nWordStyle &= ~PVTWORD_STYLE_UNDERLINE; | 1587 } |
1692 bSet = T
RUE; | 1588 } |
1693 } | 1589 |
1694 } | 1590 return FALSE; |
1695 break; | 1591 } |
1696 case EP_CROSSOUT: | 1592 |
1697 if (pWordProps->nWordSty
le & PVTWORD_STYLE_CROSSOUT) | 1593 FX_BOOL CFX_Edit::SetWordProps(EDIT_PROPS_E eProps, |
1698 { | 1594 const CPVT_WordPlace& place, |
1699 if ((secinfo.Wor
dProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) == 0) | 1595 const CPVT_WordProps* pWordProps, |
1700 { | 1596 const CPVT_WordRange& wr, |
1701 secinfo.
WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT; | 1597 FX_BOOL bAddUndo) { |
1702 bSet = T
RUE; | 1598 if (m_pVT->IsValid() && m_pVT->IsRichText()) { |
1703 } | 1599 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
1704 } | 1600 FX_BOOL bSet = FALSE; |
1705 else | 1601 CPVT_Word wordinfo; |
1706 { | 1602 CPVT_Word OldWordinfo; |
1707 if ((secinfo.Wor
dProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) != 0) | 1603 |
1708 { | 1604 CPVT_WordPlace oldplace = pIterator->GetAt(); |
1709 secinfo.
WordProps.nWordStyle &= ~PVTWORD_STYLE_CROSSOUT; | 1605 |
1710 bSet = T
RUE; | 1606 if (pWordProps) { |
1711 } | 1607 pIterator->SetAt(place); |
1712 } | 1608 if (pIterator->GetWord(wordinfo)) { |
1713 break; | 1609 if (bAddUndo) |
1714 case EP_BOLD: | 1610 OldWordinfo = wordinfo; |
1715 if (pWordProps->nWordSty
le & PVTWORD_STYLE_BOLD) | 1611 |
1716 { | 1612 switch (eProps) { |
1717 if ((secinfo.Wor
dProps.nWordStyle & PVTWORD_STYLE_BOLD) == 0) | 1613 case EP_FONTINDEX: |
1718 { | 1614 if (wordinfo.WordProps.nFontIndex != pWordProps->nFontIndex) { |
1719 secinfo.
WordProps.nWordStyle |= PVTWORD_STYLE_BOLD; | 1615 if (IFX_Edit_FontMap* pFontMap = this->GetFontMap()) { |
1720 bSet = T
RUE; | 1616 wordinfo.WordProps.nFontIndex = pFontMap->GetWordFontIndex( |
1721 } | 1617 wordinfo.Word, wordinfo.nCharset, pWordProps->nFontIndex); |
1722 } | 1618 } |
1723 else | 1619 bSet = TRUE; |
1724 { | 1620 } |
1725 if ((secinfo.Wor
dProps.nWordStyle & PVTWORD_STYLE_BOLD) != 0) | 1621 break; |
1726 { | 1622 case EP_FONTSIZE: |
1727 secinfo.
WordProps.nWordStyle &= ~PVTWORD_STYLE_BOLD; | 1623 if (!FX_EDIT_IsFloatEqual(wordinfo.WordProps.fFontSize, |
1728 bSet = T
RUE; | 1624 pWordProps->fFontSize)) { |
1729 } | 1625 wordinfo.WordProps.fFontSize = pWordProps->fFontSize; |
1730 } | 1626 bSet = TRUE; |
1731 break; | 1627 } |
1732 case EP_ITALIC: | 1628 break; |
1733 if (pWordProps->nWordSty
le & PVTWORD_STYLE_ITALIC) | 1629 case EP_WORDCOLOR: |
1734 { | 1630 if (wordinfo.WordProps.dwWordColor != pWordProps->dwWordColor) { |
1735 if ((secinfo.Wor
dProps.nWordStyle & PVTWORD_STYLE_ITALIC) == 0) | 1631 wordinfo.WordProps.dwWordColor = pWordProps->dwWordColor; |
1736 { | 1632 bSet = TRUE; |
1737 secinfo.
WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC; | 1633 } |
1738 bSet = T
RUE; | 1634 break; |
1739 } | 1635 case EP_SCRIPTTYPE: |
1740 } | 1636 if (wordinfo.WordProps.nScriptType != pWordProps->nScriptType) { |
1741 else | 1637 wordinfo.WordProps.nScriptType = pWordProps->nScriptType; |
1742 { | 1638 bSet = TRUE; |
1743 if ((secinfo.Wor
dProps.nWordStyle & PVTWORD_STYLE_ITALIC) != 0) | 1639 } |
1744 { | 1640 break; |
1745 secinfo.
WordProps.nWordStyle &= ~PVTWORD_STYLE_ITALIC; | 1641 case EP_CHARSPACE: |
1746 bSet = T
RUE; | 1642 if (!FX_EDIT_IsFloatEqual(wordinfo.WordProps.fCharSpace, |
1747 } | 1643 pWordProps->fCharSpace)) { |
1748 } | 1644 wordinfo.WordProps.fCharSpace = pWordProps->fCharSpace; |
1749 break; | 1645 bSet = TRUE; |
1750 default: | 1646 } |
1751 break; | 1647 break; |
1752 } | 1648 case EP_HORZSCALE: |
1753 } | 1649 if (wordinfo.WordProps.nHorzScale != pWordProps->nHorzScale) { |
1754 } | 1650 wordinfo.WordProps.nHorzScale = pWordProps->nHorzScale; |
1755 } | 1651 bSet = TRUE; |
1756 | 1652 } |
1757 if (bSet) | 1653 break; |
1758 { | 1654 case EP_UNDERLINE: |
1759 pIterator->SetSection(secinfo); | 1655 if (pWordProps->nWordStyle & PVTWORD_STYLE_UNDERLINE) { |
1760 | 1656 if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) == |
1761 if (bAddUndo && m_bEnableUndo) | 1657 0) { |
1762 { | 1658 wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE; |
1763 AddEditUndoItem(new CFXEU_SetSecProps | 1659 bSet = TRUE; |
1764 (this,place,eProps,OldSecinfo.Se
cProps,OldSecinfo.WordProps,secinfo.SecProps,secinfo.WordProps,wr)); | 1660 } |
1765 } | 1661 } else { |
1766 } | 1662 if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) != |
1767 | 1663 0) { |
1768 pIterator->SetAt(oldplace); | 1664 wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_UNDERLINE; |
1769 | 1665 bSet = TRUE; |
1770 return bSet; | 1666 } |
1771 } | 1667 } |
1772 } | 1668 break; |
1773 | 1669 case EP_CROSSOUT: |
1774 return FALSE; | 1670 if (pWordProps->nWordStyle & PVTWORD_STYLE_CROSSOUT) { |
1775 } | 1671 if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) == |
1776 | 1672 0) { |
1777 FX_BOOL CFX_Edit::SetWordProps(EDIT_PROPS_E eProps, const CPVT_WordPlace & place
, | 1673 wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT; |
1778 const CPVT_WordP
rops * pWordProps, const CPVT_WordRange & wr, FX_BOOL bAddUndo) | 1674 bSet = TRUE; |
1779 { | 1675 } |
1780 if (m_pVT->IsValid() && m_pVT->IsRichText()) | 1676 } else { |
1781 { | 1677 if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) != |
1782 if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator(
)) | 1678 0) { |
1783 { | 1679 wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_CROSSOUT; |
1784 FX_BOOL bSet = FALSE; | 1680 bSet = TRUE; |
1785 CPVT_Word wordinfo; | 1681 } |
1786 CPVT_Word OldWordinfo; | 1682 } |
1787 | 1683 break; |
1788 CPVT_WordPlace oldplace = pIterator->GetAt(); | 1684 case EP_BOLD: |
1789 | 1685 if (pWordProps->nWordStyle & PVTWORD_STYLE_BOLD) { |
1790 if (pWordProps) | 1686 if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) == 0) { |
1791 { | 1687 wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_BOLD; |
1792 pIterator->SetAt(place); | 1688 bSet = TRUE; |
1793 if (pIterator->GetWord(wordinfo)) | 1689 } |
1794 { | 1690 } else { |
1795 if (bAddUndo) OldWordinfo = wordinfo; | 1691 if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) != 0) { |
1796 | 1692 wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_BOLD; |
1797 switch(eProps) | 1693 bSet = TRUE; |
1798 { | 1694 } |
1799 case EP_FONTINDEX:
| 1695 } |
1800 if (wordinfo.WordProps.nFontInde
x != pWordProps->nFontIndex) | 1696 break; |
1801 { | 1697 case EP_ITALIC: |
1802 if (IFX_Edit_FontMap* pF
ontMap = this->GetFontMap()) | 1698 if (pWordProps->nWordStyle & PVTWORD_STYLE_ITALIC) { |
1803 { | 1699 if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) == |
1804 wordinfo.WordPro
ps.nFontIndex = pFontMap->GetWordFontIndex(wordinfo.Word,wordinfo.nCharset,pWord
Props->nFontIndex); | 1700 0) { |
1805 } | 1701 wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC; |
1806 bSet = TRUE; | 1702 bSet = TRUE; |
1807 } | 1703 } |
1808 break; | 1704 } else { |
1809 case EP_FONTSIZE: | 1705 if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) != |
1810 if (!FX_EDIT_IsFloatEqual(wordin
fo.WordProps.fFontSize,pWordProps->fFontSize)) | 1706 0) { |
1811 { | 1707 wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_ITALIC; |
1812 wordinfo.WordProps.fFont
Size = pWordProps->fFontSize; | 1708 bSet = TRUE; |
1813 bSet = TRUE; | 1709 } |
1814 } | 1710 } |
1815 break; | 1711 break; |
1816 case EP_WORDCOLOR: | 1712 default: |
1817 if (wordinfo.WordProps.dwWordCol
or != pWordProps->dwWordColor) | 1713 break; |
1818 { | 1714 } |
1819 wordinfo.WordProps.dwWor
dColor = pWordProps->dwWordColor; | 1715 } |
1820 bSet = TRUE; | 1716 } |
1821 } | 1717 |
1822 break; | 1718 if (bSet) { |
1823 case EP_SCRIPTTYPE: | 1719 pIterator->SetWord(wordinfo); |
1824 if (wordinfo.WordProps.nScriptTy
pe != pWordProps->nScriptType) | 1720 |
1825 { | 1721 if (bAddUndo && m_bEnableUndo) { |
1826 wordinfo.WordProps.nScri
ptType = pWordProps->nScriptType; | 1722 AddEditUndoItem(new CFXEU_SetWordProps(this, |
1827 bSet = TRUE; | 1723 place, |
1828 } | 1724 eProps, |
1829 break; | 1725 OldWordinfo.WordProps, |
1830 case EP_CHARSPACE: | 1726 wordinfo.WordProps, |
1831 if (!FX_EDIT_IsFloatEqual(wordin
fo.WordProps.fCharSpace,pWordProps->fCharSpace)) | 1727 wr)); |
1832 { | 1728 } |
1833 wordinfo.WordProps.fChar
Space = pWordProps->fCharSpace; | 1729 } |
1834 bSet = TRUE; | 1730 |
1835 } | 1731 pIterator->SetAt(oldplace); |
1836 break; | 1732 return bSet; |
1837 case EP_HORZSCALE: | 1733 } |
1838 if (wordinfo.WordProps.nHorzScal
e != pWordProps->nHorzScale) | 1734 } |
1839 { | 1735 |
1840 wordinfo.WordProps.nHorz
Scale = pWordProps->nHorzScale; | 1736 return FALSE; |
1841 bSet = TRUE; | 1737 } |
1842 } | 1738 |
1843 break; | 1739 void CFX_Edit::SetText(FX_LPCWSTR text, |
1844 case EP_UNDERLINE: | 1740 FX_INT32 charset /*= DEFAULT_CHARSET*/, |
1845 if (pWordProps->nWordStyle & PVT
WORD_STYLE_UNDERLINE) | 1741 const CPVT_SecProps* pSecProps /*= NULL*/, |
1846 { | 1742 const CPVT_WordProps* pWordProps /*= NULL*/) { |
1847 if ((wordinfo.WordProps.
nWordStyle & PVTWORD_STYLE_UNDERLINE) == 0) | 1743 SetText(text, charset, pSecProps, pWordProps, TRUE, TRUE); |
1848 { | 1744 } |
1849 wordinfo.WordPro
ps.nWordStyle |= PVTWORD_STYLE_UNDERLINE; | 1745 |
1850 bSet = TRUE; | 1746 FX_BOOL CFX_Edit::InsertWord(FX_WORD word, |
1851 } | 1747 FX_INT32 charset /*= DEFAULT_CHARSET*/, |
1852 } | 1748 const CPVT_WordProps* pWordProps /*= NULL*/) { |
1853 else | 1749 return InsertWord(word, charset, pWordProps, TRUE, TRUE); |
1854 { | 1750 } |
1855 if ((wordinfo.WordProps.
nWordStyle & PVTWORD_STYLE_UNDERLINE) != 0) | 1751 |
1856 { | 1752 FX_BOOL CFX_Edit::InsertReturn(const CPVT_SecProps* pSecProps /*= NULL*/, |
1857 wordinfo.WordPro
ps.nWordStyle &= ~PVTWORD_STYLE_UNDERLINE; | 1753 const CPVT_WordProps* pWordProps /*= NULL*/) { |
1858 bSet = TRUE; | 1754 return InsertReturn(pSecProps, pWordProps, TRUE, TRUE); |
1859 } | 1755 } |
1860 } | 1756 |
1861 break; | 1757 FX_BOOL CFX_Edit::Backspace() { |
1862 case EP_CROSSOUT: | 1758 return Backspace(TRUE, TRUE); |
1863 if (pWordProps->nWordStyle & PVT
WORD_STYLE_CROSSOUT) | 1759 } |
1864 { | 1760 |
1865 if ((wordinfo.WordProps.
nWordStyle & PVTWORD_STYLE_CROSSOUT) == 0) | 1761 FX_BOOL CFX_Edit::Delete() { |
1866 { | 1762 return Delete(TRUE, TRUE); |
1867 wordinfo.WordPro
ps.nWordStyle |= PVTWORD_STYLE_CROSSOUT; | 1763 } |
1868 bSet = TRUE; | 1764 |
1869 } | 1765 FX_BOOL CFX_Edit::Clear() { |
1870 } | 1766 return Clear(TRUE, TRUE); |
1871 else | 1767 } |
1872 { | 1768 |
1873 if ((wordinfo.WordProps.
nWordStyle & PVTWORD_STYLE_CROSSOUT) != 0) | 1769 FX_BOOL CFX_Edit::InsertText(FX_LPCWSTR text, |
1874 { | 1770 FX_INT32 charset /*= DEFAULT_CHARSET*/, |
1875 wordinfo.WordPro
ps.nWordStyle &= ~PVTWORD_STYLE_CROSSOUT; | 1771 const CPVT_SecProps* pSecProps /*= NULL*/, |
1876 bSet = TRUE; | 1772 const CPVT_WordProps* pWordProps /*= NULL*/) { |
1877 } | 1773 return InsertText(text, charset, pSecProps, pWordProps, TRUE, TRUE); |
1878 } | 1774 } |
1879 break; | 1775 |
1880 case EP_BOLD: | 1776 FX_FLOAT CFX_Edit::GetFontSize() const { |
1881 if (pWordProps->nWordStyle & PVT
WORD_STYLE_BOLD) | 1777 return m_pVT->GetFontSize(); |
1882 { | 1778 } |
1883 if ((wordinfo.WordProps.
nWordStyle & PVTWORD_STYLE_BOLD) == 0) | 1779 |
1884 { | 1780 FX_WORD CFX_Edit::GetPasswordChar() const { |
1885 wordinfo.WordPro
ps.nWordStyle |= PVTWORD_STYLE_BOLD; | 1781 return m_pVT->GetPasswordChar(); |
1886 bSet = TRUE; | 1782 } |
1887 } | 1783 |
1888 } | 1784 FX_INT32 CFX_Edit::GetCharArray() const { |
1889 else | 1785 return m_pVT->GetCharArray(); |
1890 { | 1786 } |
1891 if ((wordinfo.WordProps.
nWordStyle & PVTWORD_STYLE_BOLD) != 0) | 1787 |
1892 { | 1788 CPDF_Rect CFX_Edit::GetPlateRect() const { |
1893 wordinfo.WordPro
ps.nWordStyle &= ~PVTWORD_STYLE_BOLD; | 1789 return m_pVT->GetPlateRect(); |
1894 bSet = TRUE; | 1790 } |
1895 } | 1791 |
1896 } | 1792 CPDF_Rect CFX_Edit::GetContentRect() const { |
1897 break; | 1793 return VTToEdit(m_pVT->GetContentRect()); |
1898 case EP_ITALIC: | 1794 } |
1899 if (pWordProps->nWordStyle & PVT
WORD_STYLE_ITALIC) | 1795 |
1900 { | 1796 FX_INT32 CFX_Edit::GetHorzScale() const { |
1901 if ((wordinfo.WordProps.
nWordStyle & PVTWORD_STYLE_ITALIC) == 0) | 1797 return m_pVT->GetHorzScale(); |
1902 { | 1798 } |
1903 wordinfo.WordPro
ps.nWordStyle |= PVTWORD_STYLE_ITALIC; | 1799 |
1904 bSet = TRUE; | 1800 FX_FLOAT CFX_Edit::GetCharSpace() const { |
1905 } | 1801 return m_pVT->GetCharSpace(); |
1906 } | |
1907 else | |
1908 { | |
1909 if ((wordinfo.WordProps.
nWordStyle & PVTWORD_STYLE_ITALIC) != 0) | |
1910 { | |
1911 wordinfo.WordPro
ps.nWordStyle &= ~PVTWORD_STYLE_ITALIC; | |
1912 bSet = TRUE; | |
1913 } | |
1914 } | |
1915 break; | |
1916 default: | |
1917 break; | |
1918 } | |
1919 } | |
1920 } | |
1921 | |
1922 if (bSet) | |
1923 { | |
1924 pIterator->SetWord(wordinfo); | |
1925 | |
1926 if (bAddUndo && m_bEnableUndo) | |
1927 { | |
1928 AddEditUndoItem(new CFXEU_SetWordProps | |
1929 (this,place,eProps,OldWordinfo.W
ordProps,wordinfo.WordProps,wr)); | |
1930 } | |
1931 } | |
1932 | |
1933 pIterator->SetAt(oldplace); | |
1934 return bSet; | |
1935 } | |
1936 } | |
1937 | |
1938 return FALSE; | |
1939 } | |
1940 | |
1941 void CFX_Edit::SetText(FX_LPCWSTR text,FX_INT32 charset /*= DEFAULT_CHARSET*/, | |
1942 const CPVT_SecProps * pSecProps
/*= NULL*/,const CPVT_WordProps * pWordProps /*= NULL*/) | |
1943 { | |
1944 SetText(text,charset,pSecProps,pWordProps,TRUE,TRUE); | |
1945 } | |
1946 | |
1947 FX_BOOL CFX_Edit::InsertWord(FX_WORD word, FX_INT32 charset /*= DEFAULT_CHARSET*
/, const CPVT_WordProps * pWordProps /*= NULL*/) | |
1948 { | |
1949 return InsertWord(word,charset,pWordProps,TRUE,TRUE); | |
1950 } | |
1951 | |
1952 FX_BOOL CFX_Edit::InsertReturn(const CPVT_SecProps * pSecProps /*= NULL*/,const
CPVT_WordProps * pWordProps /*= NULL*/) | |
1953 { | |
1954 return InsertReturn(pSecProps,pWordProps,TRUE,TRUE); | |
1955 } | |
1956 | |
1957 FX_BOOL CFX_Edit::Backspace() | |
1958 { | |
1959 return Backspace(TRUE,TRUE); | |
1960 } | |
1961 | |
1962 FX_BOOL CFX_Edit::Delete() | |
1963 { | |
1964 return Delete(TRUE,TRUE); | |
1965 } | |
1966 | |
1967 FX_BOOL CFX_Edit::Clear() | |
1968 { | |
1969 return Clear(TRUE,TRUE); | |
1970 } | |
1971 | |
1972 FX_BOOL CFX_Edit::InsertText(FX_LPCWSTR text, FX_INT32 charset /*= DEFAULT_CHARS
ET*/, | |
1973 const CPVT_SecPr
ops * pSecProps /*= NULL*/,const CPVT_WordProps * pWordProps /*= NULL*/) | |
1974 { | |
1975 return InsertText(text,charset,pSecProps,pWordProps,TRUE,TRUE); | |
1976 } | |
1977 | |
1978 FX_FLOAT CFX_Edit::GetFontSize() const | |
1979 { | |
1980 return m_pVT->GetFontSize(); | |
1981 } | |
1982 | |
1983 FX_WORD CFX_Edit::GetPasswordChar() const | |
1984 { | |
1985 return m_pVT->GetPasswordChar(); | |
1986 } | |
1987 | |
1988 FX_INT32 CFX_Edit::GetCharArray() const | |
1989 { | |
1990 return m_pVT->GetCharArray(); | |
1991 } | |
1992 | |
1993 CPDF_Rect CFX_Edit::GetPlateRect() const | |
1994 { | |
1995 return m_pVT->GetPlateRect(); | |
1996 } | |
1997 | |
1998 CPDF_Rect CFX_Edit::GetContentRect() const | |
1999 { | |
2000 return VTToEdit(m_pVT->GetContentRect()); | |
2001 } | |
2002 | |
2003 FX_INT32 CFX_Edit::GetHorzScale() const | |
2004 { | |
2005 return m_pVT->GetHorzScale(); | |
2006 } | |
2007 | |
2008 FX_FLOAT CFX_Edit::GetCharSpace() const | |
2009 { | |
2010 return m_pVT->GetCharSpace(); | |
2011 } | 1802 } |
2012 | 1803 |
2013 // inner methods | 1804 // inner methods |
2014 | 1805 |
2015 CPVT_WordRange CFX_Edit::GetWholeWordRange() const | 1806 CPVT_WordRange CFX_Edit::GetWholeWordRange() const { |
2016 { | 1807 if (m_pVT->IsValid()) |
2017 if (m_pVT->IsValid()) | 1808 return CPVT_WordRange(m_pVT->GetBeginWordPlace(), m_pVT->GetEndWordPlace()); |
2018 return CPVT_WordRange(m_pVT->GetBeginWordPlace(),m_pVT->GetEndWo
rdPlace()); | 1809 |
2019 | 1810 return CPVT_WordRange(); |
2020 return CPVT_WordRange(); | 1811 } |
2021 } | 1812 |
2022 | 1813 CPVT_WordRange CFX_Edit::GetVisibleWordRange() const { |
2023 CPVT_WordRange CFX_Edit::GetVisibleWordRange() const | 1814 if (m_bEnableOverflow) |
2024 { | 1815 return GetWholeWordRange(); |
2025 if (m_bEnableOverflow) return GetWholeWordRange(); | 1816 |
2026 | 1817 if (m_pVT->IsValid()) { |
2027 if (m_pVT->IsValid()) | 1818 CPDF_Rect rcPlate = m_pVT->GetPlateRect(); |
2028 { | 1819 |
2029 CPDF_Rect rcPlate = m_pVT->GetPlateRect(); | 1820 CPVT_WordPlace place1 = |
2030 | 1821 m_pVT->SearchWordPlace(EditToVT(CPDF_Point(rcPlate.left, rcPlate.top))); |
2031 CPVT_WordPlace place1 = m_pVT->SearchWordPlace(EditToVT(CPDF_Poi
nt(rcPlate.left,rcPlate.top))); | 1822 CPVT_WordPlace place2 = m_pVT->SearchWordPlace( |
2032 CPVT_WordPlace place2 = m_pVT->SearchWordPlace(EditToVT(CPDF_Poi
nt(rcPlate.right,rcPlate.bottom))); | 1823 EditToVT(CPDF_Point(rcPlate.right, rcPlate.bottom))); |
2033 | 1824 |
2034 return CPVT_WordRange(place1,place2); | 1825 return CPVT_WordRange(place1, place2); |
2035 } | 1826 } |
2036 | 1827 |
2037 return CPVT_WordRange(); | 1828 return CPVT_WordRange(); |
2038 } | 1829 } |
2039 | 1830 |
2040 CPVT_WordPlace CFX_Edit::SearchWordPlace(const CPDF_Point& point) const | 1831 CPVT_WordPlace CFX_Edit::SearchWordPlace(const CPDF_Point& point) const { |
2041 { | 1832 if (m_pVT->IsValid()) { |
2042 if (m_pVT->IsValid()) | 1833 return m_pVT->SearchWordPlace(EditToVT(point)); |
2043 { | 1834 } |
2044 return m_pVT->SearchWordPlace(EditToVT(point)); | 1835 |
2045 } | 1836 return CPVT_WordPlace(); |
2046 | 1837 } |
2047 return CPVT_WordPlace(); | 1838 |
2048 } | 1839 void CFX_Edit::Paint() { |
2049 | 1840 if (m_pVT->IsValid()) { |
2050 void CFX_Edit::Paint() | 1841 RearrangeAll(); |
2051 { | 1842 ScrollToCaret(); |
2052 if (m_pVT->IsValid()) | 1843 Refresh(RP_NOANALYSE); |
2053 { | 1844 SetCaretOrigin(); |
2054 RearrangeAll(); | 1845 SetCaretInfo(); |
2055 ScrollToCaret(); | 1846 } |
2056 Refresh(RP_NOANALYSE); | 1847 } |
2057 SetCaretOrigin(); | 1848 |
2058 SetCaretInfo(); | 1849 void CFX_Edit::RearrangeAll() { |
2059 } | 1850 if (m_pVT->IsValid()) { |
2060 } | 1851 m_pVT->UpdateWordPlace(m_wpCaret); |
2061 | 1852 m_pVT->RearrangeAll(); |
2062 void CFX_Edit::RearrangeAll() | 1853 m_pVT->UpdateWordPlace(m_wpCaret); |
2063 { | 1854 SetScrollInfo(); |
2064 if (m_pVT->IsValid()) | 1855 SetContentChanged(); |
2065 { | 1856 } |
2066 m_pVT->UpdateWordPlace(m_wpCaret); | 1857 } |
2067 m_pVT->RearrangeAll(); | 1858 |
2068 m_pVT->UpdateWordPlace(m_wpCaret); | 1859 void CFX_Edit::RearrangePart(const CPVT_WordRange& range) { |
2069 SetScrollInfo(); | 1860 if (m_pVT->IsValid()) { |
2070 SetContentChanged(); | 1861 m_pVT->UpdateWordPlace(m_wpCaret); |
2071 } | 1862 m_pVT->RearrangePart(range); |
2072 } | 1863 m_pVT->UpdateWordPlace(m_wpCaret); |
2073 | 1864 SetScrollInfo(); |
2074 void CFX_Edit::RearrangePart(const CPVT_WordRange & range) | 1865 SetContentChanged(); |
2075 { | 1866 } |
2076 if (m_pVT->IsValid()) | 1867 } |
2077 { | 1868 |
2078 m_pVT->UpdateWordPlace(m_wpCaret); | 1869 void CFX_Edit::SetContentChanged() { |
2079 m_pVT->RearrangePart(range); | 1870 if (m_bNotify && m_pNotify) { |
2080 m_pVT->UpdateWordPlace(m_wpCaret); | 1871 CPDF_Rect rcContent = m_pVT->GetContentRect(); |
2081 SetScrollInfo(); | 1872 if (rcContent.Width() != m_rcOldContent.Width() || |
2082 SetContentChanged(); | 1873 rcContent.Height() != m_rcOldContent.Height()) { |
2083 } | 1874 if (!m_bNotifyFlag) { |
2084 } | 1875 m_bNotifyFlag = TRUE; |
2085 | 1876 m_pNotify->IOnContentChange(rcContent); |
2086 void CFX_Edit::SetContentChanged() | 1877 m_bNotifyFlag = FALSE; |
2087 { | 1878 } |
2088 if (m_bNotify && m_pNotify) | 1879 m_rcOldContent = rcContent; |
2089 { | 1880 } |
2090 CPDF_Rect rcContent = m_pVT->GetContentRect(); | 1881 } |
2091 if (rcContent.Width() != m_rcOldContent.Width() || | 1882 } |
2092 rcContent.Height() != m_rcOldContent.Height()) | 1883 |
2093 { | 1884 void CFX_Edit::SelectAll() { |
2094 if (!m_bNotifyFlag) | 1885 if (m_pVT->IsValid()) { |
2095 { | 1886 m_SelState = GetWholeWordRange(); |
2096 m_bNotifyFlag = TRUE; | 1887 SetCaret(m_SelState.EndPos); |
2097 m_pNotify->IOnContentChange(rcContent); | 1888 |
2098 m_bNotifyFlag = FALSE; | 1889 ScrollToCaret(); |
2099 } | 1890 CPVT_WordRange wrVisible = GetVisibleWordRange(); |
2100 m_rcOldContent = rcContent; | 1891 Refresh(RP_OPTIONAL, &wrVisible); |
2101 } | 1892 SetCaretInfo(); |
2102 } | 1893 } |
2103 } | 1894 } |
2104 | 1895 |
2105 void CFX_Edit::SelectAll() | 1896 void CFX_Edit::SelectNone() { |
2106 { | 1897 if (m_pVT->IsValid()) { |
2107 if (m_pVT->IsValid()) | 1898 if (m_SelState.IsExist()) { |
2108 { | 1899 CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange(); |
2109 m_SelState = GetWholeWordRange(); | 1900 m_SelState.Default(); |
2110 SetCaret(m_SelState.EndPos); | 1901 Refresh(RP_OPTIONAL, &wrTemp); |
2111 | 1902 } |
2112 ScrollToCaret(); | 1903 } |
2113 CPVT_WordRange wrVisible = GetVisibleWordRange(); | 1904 } |
2114 Refresh(RP_OPTIONAL,&wrVisible); | 1905 |
2115 SetCaretInfo(); | 1906 FX_BOOL CFX_Edit::IsSelected() const { |
2116 } | 1907 return m_SelState.IsExist(); |
2117 } | 1908 } |
2118 | 1909 |
2119 void CFX_Edit::SelectNone() | 1910 CPDF_Point CFX_Edit::VTToEdit(const CPDF_Point& point) const { |
2120 { | 1911 CPDF_Rect rcContent = m_pVT->GetContentRect(); |
2121 if (m_pVT->IsValid()) | 1912 CPDF_Rect rcPlate = m_pVT->GetPlateRect(); |
2122 { | 1913 |
2123 if (m_SelState.IsExist()) | 1914 FX_FLOAT fPadding = 0.0f; |
2124 { | 1915 |
2125 CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange(); | 1916 switch (m_nAlignment) { |
2126 m_SelState.Default(); | 1917 case 0: |
2127 Refresh(RP_OPTIONAL,&wrTemp); | 1918 fPadding = 0.0f; |
2128 } | 1919 break; |
2129 } | 1920 case 1: |
2130 } | 1921 fPadding = (rcPlate.Height() - rcContent.Height()) * 0.5f; |
2131 | 1922 break; |
2132 FX_BOOL CFX_Edit::IsSelected() const | 1923 case 2: |
2133 { | 1924 fPadding = rcPlate.Height() - rcContent.Height(); |
2134 return m_SelState.IsExist(); | 1925 break; |
2135 } | 1926 } |
2136 | 1927 |
2137 CPDF_Point CFX_Edit::VTToEdit(const CPDF_Point & point) const | 1928 return CPDF_Point(point.x - (m_ptScrollPos.x - rcPlate.left), |
2138 { | 1929 point.y - (m_ptScrollPos.y + fPadding - rcPlate.top)); |
2139 CPDF_Rect rcContent = m_pVT->GetContentRect(); | 1930 } |
2140 CPDF_Rect rcPlate = m_pVT->GetPlateRect(); | 1931 |
2141 | 1932 CPDF_Point CFX_Edit::EditToVT(const CPDF_Point& point) const { |
2142 FX_FLOAT fPadding = 0.0f; | 1933 CPDF_Rect rcContent = m_pVT->GetContentRect(); |
2143 | 1934 CPDF_Rect rcPlate = m_pVT->GetPlateRect(); |
2144 switch (m_nAlignment) | 1935 |
2145 { | 1936 FX_FLOAT fPadding = 0.0f; |
2146 case 0: | 1937 |
2147 fPadding = 0.0f; | 1938 switch (m_nAlignment) { |
2148 break; | 1939 case 0: |
2149 case 1: | 1940 fPadding = 0.0f; |
2150 fPadding = (rcPlate.Height() - rcContent.Height()) * 0.5f; | 1941 break; |
2151 break; | 1942 case 1: |
2152 case 2: | 1943 fPadding = (rcPlate.Height() - rcContent.Height()) * 0.5f; |
2153 fPadding = rcPlate.Height() - rcContent.Height(); | 1944 break; |
2154 break; | 1945 case 2: |
2155 } | 1946 fPadding = rcPlate.Height() - rcContent.Height(); |
2156 | 1947 break; |
2157 return CPDF_Point(point.x - (m_ptScrollPos.x - rcPlate.left), | 1948 } |
2158 point.y - (m_ptScrollPos.y + fPadding - rcPlate.top)); | 1949 |
2159 } | 1950 return CPDF_Point(point.x + (m_ptScrollPos.x - rcPlate.left), |
2160 | 1951 point.y + (m_ptScrollPos.y + fPadding - rcPlate.top)); |
2161 CPDF_Point CFX_Edit::EditToVT(const CPDF_Point & point) const | 1952 } |
2162 { | 1953 |
2163 CPDF_Rect rcContent = m_pVT->GetContentRect(); | 1954 CPDF_Rect CFX_Edit::VTToEdit(const CPDF_Rect& rect) const { |
2164 CPDF_Rect rcPlate = m_pVT->GetPlateRect(); | 1955 CPDF_Point ptLeftBottom = VTToEdit(CPDF_Point(rect.left, rect.bottom)); |
2165 | 1956 CPDF_Point ptRightTop = VTToEdit(CPDF_Point(rect.right, rect.top)); |
2166 FX_FLOAT fPadding = 0.0f; | 1957 |
2167 | 1958 return CPDF_Rect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x, ptRightTop.y); |
2168 switch (m_nAlignment) | 1959 } |
2169 { | 1960 |
2170 case 0: | 1961 CPDF_Rect CFX_Edit::EditToVT(const CPDF_Rect& rect) const { |
2171 fPadding = 0.0f; | 1962 CPDF_Point ptLeftBottom = EditToVT(CPDF_Point(rect.left, rect.bottom)); |
2172 break; | 1963 CPDF_Point ptRightTop = EditToVT(CPDF_Point(rect.right, rect.top)); |
2173 case 1: | 1964 |
2174 fPadding = (rcPlate.Height() - rcContent.Height()) * 0.5f; | 1965 return CPDF_Rect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x, ptRightTop.y); |
2175 break; | 1966 } |
2176 case 2: | 1967 |
2177 fPadding = rcPlate.Height() - rcContent.Height(); | 1968 void CFX_Edit::SetScrollInfo() { |
2178 break; | 1969 if (m_bNotify && m_pNotify) { |
2179 } | 1970 CPDF_Rect rcPlate = m_pVT->GetPlateRect(); |
2180 | 1971 CPDF_Rect rcContent = m_pVT->GetContentRect(); |
2181 return CPDF_Point(point.x + (m_ptScrollPos.x - rcPlate.left), | 1972 |
2182 point.y + (m_ptScrollPos.y + fPadding - rcPlate.top)); | 1973 if (!m_bNotifyFlag) { |
2183 } | 1974 m_bNotifyFlag = TRUE; |
2184 | 1975 m_pNotify->IOnSetScrollInfoX(rcPlate.left, |
2185 CPDF_Rect CFX_Edit::VTToEdit(const CPDF_Rect & rect) const | 1976 rcPlate.right, |
2186 { | 1977 rcContent.left, |
2187 CPDF_Point ptLeftBottom = VTToEdit(CPDF_Point(rect.left,rect.bottom)); | 1978 rcContent.right, |
2188 CPDF_Point ptRightTop = VTToEdit(CPDF_Point(rect.right,rect.top)); | 1979 rcPlate.Width() / 3, |
2189 | 1980 rcPlate.Width()); |
2190 return CPDF_Rect(ptLeftBottom.x,ptLeftBottom.y,ptRightTop.x,ptRightTop.y
); | 1981 |
2191 } | 1982 m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, |
2192 | 1983 rcPlate.top, |
2193 CPDF_Rect CFX_Edit::EditToVT(const CPDF_Rect & rect) const | 1984 rcContent.bottom, |
2194 { | 1985 rcContent.top, |
2195 CPDF_Point ptLeftBottom = EditToVT(CPDF_Point(rect.left,rect.bottom)); | 1986 rcPlate.Height() / 3, |
2196 CPDF_Point ptRightTop = EditToVT(CPDF_Point(rect.right,rect.top)); | 1987 rcPlate.Height()); |
2197 | 1988 m_bNotifyFlag = FALSE; |
2198 return CPDF_Rect(ptLeftBottom.x,ptLeftBottom.y,ptRightTop.x,ptRightTop.y
); | 1989 } |
2199 } | 1990 } |
2200 | 1991 } |
2201 void CFX_Edit::SetScrollInfo() | 1992 |
2202 { | 1993 void CFX_Edit::SetScrollPosX(FX_FLOAT fx) { |
2203 if (m_bNotify && m_pNotify) | 1994 if (!m_bEnableScroll) |
2204 { | 1995 return; |
2205 CPDF_Rect rcPlate = m_pVT->GetPlateRect(); | 1996 |
2206 CPDF_Rect rcContent = m_pVT->GetContentRect(); | 1997 if (m_pVT->IsValid()) { |
2207 | 1998 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.x, fx)) { |
2208 if (!m_bNotifyFlag) | 1999 m_ptScrollPos.x = fx; |
2209 { | 2000 Refresh(RP_NOANALYSE); |
2210 m_bNotifyFlag = TRUE; | 2001 |
2211 m_pNotify->IOnSetScrollInfoX(rcPlate.left, rcPlate.right
, | 2002 if (m_bNotify && m_pNotify) { |
2212 rcContent.left,
rcContent.right, rcPlate.Width() / 3, rcPlate.Width()); | 2003 if (!m_bNotifyFlag) { |
2213 | 2004 m_bNotifyFlag = TRUE; |
2214 m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top
, | 2005 m_pNotify->IOnSetScrollPosX(fx); |
2215 rcContent.bottom, rcContent.top, rcPlate
.Height() / 3, rcPlate.Height()); | 2006 m_bNotifyFlag = FALSE; |
2216 m_bNotifyFlag = FALSE; | 2007 } |
2217 } | 2008 } |
2218 } | 2009 } |
2219 } | 2010 } |
2220 | 2011 } |
2221 void CFX_Edit::SetScrollPosX(FX_FLOAT fx) | 2012 |
2222 { | 2013 void CFX_Edit::SetScrollPosY(FX_FLOAT fy) { |
2223 if (!m_bEnableScroll) return; | 2014 if (!m_bEnableScroll) |
2224 | 2015 return; |
2225 if (m_pVT->IsValid()) | 2016 |
2226 { | 2017 if (m_pVT->IsValid()) { |
2227 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.x,fx)) | 2018 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y, fy)) { |
2228 { | 2019 m_ptScrollPos.y = fy; |
2229 m_ptScrollPos.x = fx; | 2020 Refresh(RP_NOANALYSE); |
2230 Refresh(RP_NOANALYSE); | 2021 |
2231 | 2022 if (m_bNotify && m_pNotify) { |
2232 if (m_bNotify && m_pNotify) | 2023 if (!m_bNotifyFlag) { |
2233 { | 2024 m_bNotifyFlag = TRUE; |
2234 if (!m_bNotifyFlag) | 2025 m_pNotify->IOnSetScrollPosY(fy); |
2235 { | 2026 m_bNotifyFlag = FALSE; |
2236 m_bNotifyFlag = TRUE; | 2027 } |
2237 m_pNotify->IOnSetScrollPosX(fx); | 2028 } |
2238 m_bNotifyFlag = FALSE; | 2029 } |
2239 } | 2030 } |
2240 } | 2031 } |
2241 } | 2032 |
2242 } | 2033 void CFX_Edit::SetScrollPos(const CPDF_Point& point) { |
2243 } | 2034 SetScrollPosX(point.x); |
2244 | 2035 SetScrollPosY(point.y); |
2245 void CFX_Edit::SetScrollPosY(FX_FLOAT fy) | 2036 SetScrollLimit(); |
2246 { | 2037 SetCaretInfo(); |
2247 if (!m_bEnableScroll) return; | 2038 } |
2248 | 2039 |
2249 if (m_pVT->IsValid()) | 2040 CPDF_Point CFX_Edit::GetScrollPos() const { |
2250 { | 2041 return m_ptScrollPos; |
2251 if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y,fy)) | 2042 } |
2252 { | 2043 |
2253 m_ptScrollPos.y = fy; | 2044 void CFX_Edit::SetScrollLimit() { |
2254 Refresh(RP_NOANALYSE); | 2045 if (m_pVT->IsValid()) { |
2255 | 2046 CPDF_Rect rcContent = m_pVT->GetContentRect(); |
2256 if (m_bNotify && m_pNotify) | 2047 CPDF_Rect rcPlate = m_pVT->GetPlateRect(); |
2257 { | 2048 |
2258 if (!m_bNotifyFlag) | 2049 if (rcPlate.Width() > rcContent.Width()) { |
2259 { | 2050 SetScrollPosX(rcPlate.left); |
2260 m_bNotifyFlag = TRUE; | 2051 } else { |
2261 m_pNotify->IOnSetScrollPosY(fy); | 2052 if (FX_EDIT_IsFloatSmaller(m_ptScrollPos.x, rcContent.left)) { |
2262 m_bNotifyFlag = FALSE; | 2053 SetScrollPosX(rcContent.left); |
2263 } | 2054 } else if (FX_EDIT_IsFloatBigger(m_ptScrollPos.x, |
2264 } | 2055 rcContent.right - rcPlate.Width())) { |
2265 } | 2056 SetScrollPosX(rcContent.right - rcPlate.Width()); |
2266 } | 2057 } |
2267 } | 2058 } |
2268 | 2059 |
2269 void CFX_Edit::SetScrollPos(const CPDF_Point & point) | 2060 if (rcPlate.Height() > rcContent.Height()) { |
2270 { | 2061 SetScrollPosY(rcPlate.top); |
2271 SetScrollPosX(point.x); | 2062 } else { |
2272 SetScrollPosY(point.y); | 2063 if (FX_EDIT_IsFloatSmaller(m_ptScrollPos.y, |
2273 SetScrollLimit(); | 2064 rcContent.bottom + rcPlate.Height())) { |
2274 SetCaretInfo(); | 2065 SetScrollPosY(rcContent.bottom + rcPlate.Height()); |
2275 } | 2066 } else if (FX_EDIT_IsFloatBigger(m_ptScrollPos.y, rcContent.top)) { |
2276 | 2067 SetScrollPosY(rcContent.top); |
2277 CPDF_Point CFX_Edit::GetScrollPos() const | 2068 } |
2278 { | 2069 } |
2279 return m_ptScrollPos; | 2070 } |
2280 } | 2071 } |
2281 | 2072 |
2282 void CFX_Edit::SetScrollLimit() | 2073 void CFX_Edit::ScrollToCaret() { |
2283 { | 2074 SetScrollLimit(); |
2284 if (m_pVT->IsValid()) | 2075 |
2285 { | 2076 if (m_pVT->IsValid()) { |
2286 CPDF_Rect rcContent = m_pVT->GetContentRect(); | 2077 CPDF_Point ptHead(0, 0); |
2287 CPDF_Rect rcPlate = m_pVT->GetPlateRect(); | 2078 CPDF_Point ptFoot(0, 0); |
2288 | 2079 |
2289 if (rcPlate.Width() > rcContent.Width()) | 2080 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
2290 { | 2081 pIterator->SetAt(m_wpCaret); |
2291 SetScrollPosX(rcPlate.left); | 2082 |
2292 } | 2083 CPVT_Word word; |
2293 else | 2084 CPVT_Line line; |
2294 { | 2085 if (pIterator->GetWord(word)) { |
2295 if (FX_EDIT_IsFloatSmaller(m_ptScrollPos.x, rcContent.le
ft)) | 2086 ptHead.x = word.ptWord.x + word.fWidth; |
2296 { | 2087 ptHead.y = word.ptWord.y + word.fAscent; |
2297 SetScrollPosX(rcContent.left); | 2088 ptFoot.x = word.ptWord.x + word.fWidth; |
2298 } | 2089 ptFoot.y = word.ptWord.y + word.fDescent; |
2299 else if (FX_EDIT_IsFloatBigger(m_ptScrollPos.x, rcConten
t.right - rcPlate.Width())) | 2090 } else if (pIterator->GetLine(line)) { |
2300 { | 2091 ptHead.x = line.ptLine.x; |
2301 SetScrollPosX(rcContent.right - rcPlate.Width())
; | 2092 ptHead.y = line.ptLine.y + line.fLineAscent; |
2302 } | 2093 ptFoot.x = line.ptLine.x; |
2303 } | 2094 ptFoot.y = line.ptLine.y + line.fLineDescent; |
2304 | 2095 } |
2305 if (rcPlate.Height() > rcContent.Height()) | 2096 } |
2306 { | 2097 |
2307 SetScrollPosY(rcPlate.top); | 2098 CPDF_Point ptHeadEdit = VTToEdit(ptHead); |
2308 } | 2099 CPDF_Point ptFootEdit = VTToEdit(ptFoot); |
2309 else | 2100 |
2310 { | 2101 CPDF_Rect rcPlate = m_pVT->GetPlateRect(); |
2311 if (FX_EDIT_IsFloatSmaller(m_ptScrollPos.y, rcContent.bo
ttom + rcPlate.Height())) | 2102 |
2312 { | 2103 if (!FX_EDIT_IsFloatEqual(rcPlate.left, rcPlate.right)) { |
2313 SetScrollPosY(rcContent.bottom + rcPlate.Height(
)); | 2104 if (FX_EDIT_IsFloatSmaller(ptHeadEdit.x, rcPlate.left) || |
2314 } | 2105 FX_EDIT_IsFloatEqual(ptHeadEdit.x, rcPlate.left)) { |
2315 else if (FX_EDIT_IsFloatBigger(m_ptScrollPos.y, rcConten
t.top)) | 2106 SetScrollPosX(ptHead.x); |
2316 { | 2107 } else if (FX_EDIT_IsFloatBigger(ptHeadEdit.x, rcPlate.right)) { |
2317 SetScrollPosY(rcContent.top); | 2108 SetScrollPosX(ptHead.x - rcPlate.Width()); |
2318 } | 2109 } |
2319 } | 2110 } |
2320 } | 2111 |
2321 } | 2112 if (!FX_EDIT_IsFloatEqual(rcPlate.top, rcPlate.bottom)) { |
2322 | 2113 if (FX_EDIT_IsFloatSmaller(ptFootEdit.y, rcPlate.bottom) || |
2323 void CFX_Edit::ScrollToCaret() | 2114 FX_EDIT_IsFloatEqual(ptFootEdit.y, rcPlate.bottom)) { |
2324 { | 2115 if (FX_EDIT_IsFloatSmaller(ptHeadEdit.y, rcPlate.top)) { |
2325 SetScrollLimit(); | 2116 SetScrollPosY(ptFoot.y + rcPlate.Height()); |
2326 | 2117 } |
2327 if (m_pVT->IsValid()) | 2118 } else if (FX_EDIT_IsFloatBigger(ptHeadEdit.y, rcPlate.top)) { |
2328 { | 2119 if (FX_EDIT_IsFloatBigger(ptFootEdit.y, rcPlate.bottom)) { |
2329 CPDF_Point ptHead(0,0); | 2120 SetScrollPosY(ptHead.y); |
2330 CPDF_Point ptFoot(0,0); | 2121 } |
2331 | 2122 } |
2332 if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator(
)) | 2123 } |
2333 { | 2124 } |
2334 pIterator->SetAt(m_wpCaret); | 2125 } |
2335 | 2126 |
2336 CPVT_Word word; | 2127 void CFX_Edit::Refresh(REFRESH_PLAN_E ePlan, |
2337 CPVT_Line line; | 2128 const CPVT_WordRange* pRange1, |
2338 if (pIterator->GetWord(word)) | 2129 const CPVT_WordRange* pRange2) { |
2339 { | 2130 if (m_bEnableRefresh && m_pVT->IsValid()) { |
2340 ptHead.x = word.ptWord.x + word.fWidth; | 2131 m_Refresh.BeginRefresh(); |
2341 ptHead.y = word.ptWord.y + word.fAscent; | 2132 RefreshPushLineRects(GetVisibleWordRange()); |
2342 ptFoot.x = word.ptWord.x + word.fWidth; | 2133 |
2343 ptFoot.y = word.ptWord.y + word.fDescent; | 2134 // if (!FX_EDIT_IsFloatEqual(m_ptRefreshScrollPos.x,m_ptScrollPos.x
) |
2344 } | 2135 // || |
2345 else if (pIterator->GetLine(line)) | 2136 // !FX_EDIT_IsFloatEqual(m_ptRefreshScrollPos.y,m_ptScrollP
os.y)) |
2346 { | 2137 // { |
2347 ptHead.x = line.ptLine.x; | 2138 m_Refresh.NoAnalyse(); |
2348 ptHead.y = line.ptLine.y + line.fLineAscent; | 2139 m_ptRefreshScrollPos = m_ptScrollPos; |
2349 ptFoot.x = line.ptLine.x; | 2140 // } |
2350 ptFoot.y = line.ptLine.y + line.fLineDescent; | 2141 // else |
2351 } | 2142 // { |
2352 } | 2143 // switch (ePlan) |
2353 | 2144 // { |
2354 CPDF_Point ptHeadEdit = VTToEdit(ptHead); | 2145 // case RP_ANALYSE: |
2355 CPDF_Point ptFootEdit = VTToEdit(ptFoot); | 2146 // m_Refresh.Analyse(m_pVT->GetAlignment()); |
2356 | 2147 // |
2357 CPDF_Rect rcPlate = m_pVT->GetPlateRect(); | 2148 // if (pRange1) RefreshPushRandomRects(*pRange1); |
2358 | 2149 // if (pRange2) RefreshPushRandomRects(*pRange2); |
2359 if (!FX_EDIT_IsFloatEqual(rcPlate.left,rcPlate.right)) | 2150 // break; |
2360 { | 2151 // case RP_NOANALYSE: |
2361 if (FX_EDIT_IsFloatSmaller(ptHeadEdit.x, rcPlate.left) |
| | 2152 // m_Refresh.NoAnalyse(); |
2362 FX_EDIT_IsFloatEqual(ptHeadEdit.x, rcPlate.left)
) | 2153 // break; |
2363 { | 2154 // case RP_OPTIONAL: |
2364 SetScrollPosX(ptHead.x); | 2155 // if (pRange1) RefreshPushRandomRects(*pRange1); |
2365 } | 2156 // if (pRange2) RefreshPushRandomRects(*pRange2); |
2366 else if (FX_EDIT_IsFloatBigger(ptHeadEdit.x, rcPlate.rig
ht)) | 2157 // break; |
2367 { | 2158 // } |
2368 SetScrollPosX(ptHead.x - rcPlate.Width()); | 2159 // } |
2369 } | 2160 |
2370 } | 2161 if (m_bNotify && m_pNotify) { |
2371 | 2162 if (!m_bNotifyFlag) { |
2372 if (!FX_EDIT_IsFloatEqual(rcPlate.top,rcPlate.bottom)) | 2163 m_bNotifyFlag = TRUE; |
2373 { | 2164 if (const CFX_Edit_RectArray* pRects = m_Refresh.GetRefreshRects()) { |
2374 if (FX_EDIT_IsFloatSmaller(ptFootEdit.y, rcPlate.bottom)
|| | 2165 for (FX_INT32 i = 0, sz = pRects->GetSize(); i < sz; i++) |
2375 FX_EDIT_IsFloatEqual(ptFootEdit.y, rcPlate.botto
m)) | 2166 m_pNotify->IOnInvalidateRect(pRects->GetAt(i)); |
2376 { | 2167 } |
2377 if (FX_EDIT_IsFloatSmaller(ptHeadEdit.y, rcPlate
.top)) | 2168 m_bNotifyFlag = FALSE; |
2378 { | 2169 } |
2379 SetScrollPosY(ptFoot.y + rcPlate.Height(
)); | 2170 } |
2380 } | 2171 |
2381 } | 2172 m_Refresh.EndRefresh(); |
2382 else if (FX_EDIT_IsFloatBigger(ptHeadEdit.y, rcPlate.top
)) | 2173 } |
2383 { | 2174 } |
2384 if (FX_EDIT_IsFloatBigger(ptFootEdit.y, rcPlate.
bottom)) | 2175 |
2385 { | 2176 void CFX_Edit::RefreshPushLineRects(const CPVT_WordRange& wr) { |
2386 SetScrollPosY(ptHead.y); | 2177 if (m_pVT->IsValid()) { |
2387 } | 2178 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
2388 } | 2179 CPVT_WordPlace wpBegin = wr.BeginPos; |
2389 } | 2180 m_pVT->UpdateWordPlace(wpBegin); |
2390 } | 2181 CPVT_WordPlace wpEnd = wr.EndPos; |
2391 } | 2182 m_pVT->UpdateWordPlace(wpEnd); |
2392 | 2183 pIterator->SetAt(wpBegin); |
2393 void CFX_Edit::Refresh(REFRESH_PLAN_E ePlan,const CPVT_WordRange * pRange1,const
CPVT_WordRange * pRange2) | 2184 |
2394 { | 2185 CPVT_Line lineinfo; |
2395 if (m_bEnableRefresh && m_pVT->IsValid()) | 2186 do { |
2396 { | 2187 if (!pIterator->GetLine(lineinfo)) |
2397 m_Refresh.BeginRefresh(); | 2188 break; |
2398 RefreshPushLineRects(GetVisibleWordRange()); | 2189 if (lineinfo.lineplace.LineCmp(wpEnd) > 0) |
2399 | 2190 break; |
2400 // if (!FX_EDIT_IsFloatEqual(m_ptRefreshScrollPos.x,m_ptScrollPos.x
) || | 2191 |
2401 // !FX_EDIT_IsFloatEqual(m_ptRefreshScrollPos.y,m_ptScrollP
os.y)) | 2192 CPDF_Rect rcLine(lineinfo.ptLine.x, |
2402 // { | 2193 lineinfo.ptLine.y + lineinfo.fLineDescent, |
2403 m_Refresh.NoAnalyse(); | 2194 lineinfo.ptLine.x + lineinfo.fLineWidth, |
2404 m_ptRefreshScrollPos = m_ptScrollPos; | 2195 lineinfo.ptLine.y + lineinfo.fLineAscent); |
2405 // } | 2196 |
2406 // else | 2197 m_Refresh.Push(CPVT_WordRange(lineinfo.lineplace, lineinfo.lineEnd), |
2407 // { | 2198 VTToEdit(rcLine)); |
2408 // switch (ePlan) | 2199 |
2409 // { | 2200 } while (pIterator->NextLine()); |
2410 // case RP_ANALYSE: | 2201 } |
2411 // m_Refresh.Analyse(m_pVT->GetAlignment()); | 2202 } |
2412 // | 2203 } |
2413 // if (pRange1) RefreshPushRandomRects(*pRange1); | 2204 |
2414 // if (pRange2) RefreshPushRandomRects(*pRange2); | 2205 void CFX_Edit::RefreshPushRandomRects(const CPVT_WordRange& wr) { |
2415 // break; | 2206 if (m_pVT->IsValid()) { |
2416 // case RP_NOANALYSE: | 2207 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
2417 // m_Refresh.NoAnalyse(); | 2208 CPVT_WordRange wrTemp = wr; |
2418 // break; | 2209 |
2419 // case RP_OPTIONAL: | 2210 m_pVT->UpdateWordPlace(wrTemp.BeginPos); |
2420 // if (pRange1) RefreshPushRandomRects(*pRange1); | 2211 m_pVT->UpdateWordPlace(wrTemp.EndPos); |
2421 // if (pRange2) RefreshPushRandomRects(*pRange2); | 2212 pIterator->SetAt(wrTemp.BeginPos); |
2422 // break; | 2213 |
2423 // } | 2214 CPVT_Word wordinfo; |
2424 // } | 2215 CPVT_Line lineinfo; |
2425 | 2216 CPVT_WordPlace place; |
2426 if (m_bNotify && m_pNotify) | 2217 |
2427 { | 2218 while (pIterator->NextWord()) { |
2428 if (!m_bNotifyFlag) | 2219 place = pIterator->GetAt(); |
2429 { | 2220 if (place.WordCmp(wrTemp.EndPos) > 0) |
2430 m_bNotifyFlag = TRUE; | 2221 break; |
2431 if (const CFX_Edit_RectArray * pRects = m_Refres
h.GetRefreshRects()) | 2222 |
2432 { | 2223 pIterator->GetWord(wordinfo); |
2433 for (FX_INT32 i = 0, sz = pRects->GetSiz
e(); i < sz; i++) | 2224 pIterator->GetLine(lineinfo); |
2434 m_pNotify->IOnInvalidateRect(pRe
cts->GetAt(i)); | 2225 |
2435 } | 2226 if (place.LineCmp(wrTemp.BeginPos) == 0 || |
2436 m_bNotifyFlag = FALSE; | 2227 place.LineCmp(wrTemp.EndPos) == 0) { |
2437 } | 2228 CPDF_Rect rcWord(wordinfo.ptWord.x, |
2438 } | 2229 lineinfo.ptLine.y + lineinfo.fLineDescent, |
2439 | 2230 wordinfo.ptWord.x + wordinfo.fWidth, |
2440 m_Refresh.EndRefresh(); | 2231 lineinfo.ptLine.y + lineinfo.fLineAscent); |
2441 } | 2232 |
2442 } | 2233 m_Refresh.AddRefresh(VTToEdit(rcWord)); |
2443 | 2234 } else { |
2444 void CFX_Edit::RefreshPushLineRects(const CPVT_WordRange & wr) | 2235 CPDF_Rect rcLine(lineinfo.ptLine.x, |
2445 { | 2236 lineinfo.ptLine.y + lineinfo.fLineDescent, |
2446 if (m_pVT->IsValid()) | 2237 lineinfo.ptLine.x + lineinfo.fLineWidth, |
2447 { | 2238 lineinfo.ptLine.y + lineinfo.fLineAscent); |
2448 if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator(
)) | 2239 |
2449 { | 2240 m_Refresh.AddRefresh(VTToEdit(rcLine)); |
2450 CPVT_WordPlace wpBegin = wr.BeginPos; | 2241 |
2451 m_pVT->UpdateWordPlace(wpBegin); | 2242 pIterator->NextLine(); |
2452 CPVT_WordPlace wpEnd = wr.EndPos; | 2243 } |
2453 m_pVT->UpdateWordPlace(wpEnd); | 2244 } |
2454 pIterator->SetAt(wpBegin); | 2245 } |
2455 | 2246 } |
2456 CPVT_Line lineinfo; | 2247 } |
2457 do | 2248 |
2458 { | 2249 void CFX_Edit::RefreshWordRange(const CPVT_WordRange& wr) { |
2459 if (!pIterator->GetLine(lineinfo))break; | 2250 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
2460 if (lineinfo.lineplace.LineCmp(wpEnd) > 0)break; | 2251 CPVT_WordRange wrTemp = wr; |
2461 | 2252 |
2462 CPDF_Rect rcLine(lineinfo.ptLine.x, | 2253 m_pVT->UpdateWordPlace(wrTemp.BeginPos); |
2463 lineinfo
.ptLine.y + lineinfo.fLineDescent, | 2254 m_pVT->UpdateWordPlace(wrTemp.EndPos); |
2464 lineinfo
.ptLine.x + lineinfo.fLineWidth, | 2255 pIterator->SetAt(wrTemp.BeginPos); |
2465 lineinfo
.ptLine.y + lineinfo.fLineAscent); | 2256 |
2466 | 2257 CPVT_Word wordinfo; |
2467 m_Refresh.Push(CPVT_WordRange(lineinfo.lineplace
,lineinfo.lineEnd),VTToEdit(rcLine)); | 2258 CPVT_Line lineinfo; |
2468 | 2259 CPVT_WordPlace place; |
2469 }while (pIterator->NextLine()); | 2260 |
2470 } | 2261 while (pIterator->NextWord()) { |
2471 } | 2262 place = pIterator->GetAt(); |
2472 } | 2263 if (place.WordCmp(wrTemp.EndPos) > 0) |
2473 | 2264 break; |
2474 void CFX_Edit::RefreshPushRandomRects(const CPVT_WordRange & wr) | 2265 |
2475 { | 2266 pIterator->GetWord(wordinfo); |
2476 if (m_pVT->IsValid()) | 2267 pIterator->GetLine(lineinfo); |
2477 { | 2268 |
2478 if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator(
)) | 2269 if (place.LineCmp(wrTemp.BeginPos) == 0 || |
2479 { | 2270 place.LineCmp(wrTemp.EndPos) == 0) { |
2480 CPVT_WordRange wrTemp = wr; | 2271 CPDF_Rect rcWord(wordinfo.ptWord.x, |
2481 | 2272 lineinfo.ptLine.y + lineinfo.fLineDescent, |
2482 m_pVT->UpdateWordPlace(wrTemp.BeginPos); | 2273 wordinfo.ptWord.x + wordinfo.fWidth, |
2483 m_pVT->UpdateWordPlace(wrTemp.EndPos); | 2274 lineinfo.ptLine.y + lineinfo.fLineAscent); |
2484 pIterator->SetAt(wrTemp.BeginPos); | 2275 |
2485 | 2276 if (m_bNotify && m_pNotify) { |
2486 CPVT_Word wordinfo; | 2277 if (!m_bNotifyFlag) { |
2487 CPVT_Line lineinfo; | 2278 m_bNotifyFlag = TRUE; |
2488 CPVT_WordPlace place; | 2279 CPDF_Rect rcRefresh = VTToEdit(rcWord); |
2489 | 2280 m_pNotify->IOnInvalidateRect(&rcRefresh); |
2490 while (pIterator->NextWord()) | 2281 m_bNotifyFlag = FALSE; |
2491 { | 2282 } |
2492 place = pIterator->GetAt(); | 2283 } |
2493 if (place.WordCmp(wrTemp.EndPos) > 0) break; | 2284 } else { |
2494 | 2285 CPDF_Rect rcLine(lineinfo.ptLine.x, |
2495 pIterator->GetWord(wordinfo); | 2286 lineinfo.ptLine.y + lineinfo.fLineDescent, |
2496 pIterator->GetLine(lineinfo); | 2287 lineinfo.ptLine.x + lineinfo.fLineWidth, |
2497 | 2288 lineinfo.ptLine.y + lineinfo.fLineAscent); |
2498 if (place.LineCmp(wrTemp.BeginPos) == 0 || place
.LineCmp(wrTemp.EndPos) == 0) | 2289 |
2499 { | 2290 if (m_bNotify && m_pNotify) { |
2500 CPDF_Rect rcWord(wordinfo.ptWord.x, | 2291 if (!m_bNotifyFlag) { |
2501
lineinfo.ptLine.y + lineinfo.fLineDescent, | 2292 m_bNotifyFlag = TRUE; |
2502
wordinfo.ptWord.x + wordinfo.fWidth, | 2293 CPDF_Rect rcRefresh = VTToEdit(rcLine); |
2503
lineinfo.ptLine.y + lineinfo.fLineAscent); | 2294 m_pNotify->IOnInvalidateRect(&rcRefresh); |
2504 | 2295 m_bNotifyFlag = FALSE; |
2505 m_Refresh.AddRefresh(VTToEdit(rcWord)); | 2296 } |
2506 } | 2297 } |
2507 else | 2298 |
2508 { | 2299 pIterator->NextLine(); |
2509 CPDF_Rect rcLine(lineinfo.ptLine.x, | 2300 } |
2510
lineinfo.ptLine.y + lineinfo.fLineDescent, | 2301 } |
2511
lineinfo.ptLine.x + lineinfo.fLineWidth, | 2302 } |
2512
lineinfo.ptLine.y + lineinfo.fLineAscent); | 2303 } |
2513 | 2304 |
2514 m_Refresh.AddRefresh(VTToEdit(rcLine)); | 2305 void CFX_Edit::SetCaret(const CPVT_WordPlace& place) { |
2515 | 2306 m_wpOldCaret = m_wpCaret; |
2516 pIterator->NextLine(); | 2307 m_wpCaret = place; |
2517 } | 2308 } |
2518 } | 2309 |
2519 } | 2310 void CFX_Edit::SetCaretInfo() { |
2520 } | 2311 if (m_bNotify && m_pNotify) { |
2521 } | 2312 if (!m_bNotifyFlag) { |
2522 | 2313 CPDF_Point ptHead(0.0f, 0.0f), ptFoot(0.0f, 0.0f); |
2523 void CFX_Edit::RefreshWordRange(const CPVT_WordRange& wr) | 2314 |
2524 { | 2315 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
2525 if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator()) | 2316 pIterator->SetAt(m_wpCaret); |
2526 { | 2317 CPVT_Word word; |
2527 CPVT_WordRange wrTemp = wr; | 2318 CPVT_Line line; |
2528 | 2319 if (pIterator->GetWord(word)) { |
2529 m_pVT->UpdateWordPlace(wrTemp.BeginPos); | 2320 ptHead.x = word.ptWord.x + word.fWidth; |
2530 m_pVT->UpdateWordPlace(wrTemp.EndPos); | 2321 ptHead.y = word.ptWord.y + word.fAscent; |
2531 pIterator->SetAt(wrTemp.BeginPos); | 2322 ptFoot.x = word.ptWord.x + word.fWidth; |
2532 | 2323 ptFoot.y = word.ptWord.y + word.fDescent; |
2533 CPVT_Word wordinfo; | 2324 } else if (pIterator->GetLine(line)) { |
2534 CPVT_Line lineinfo; | 2325 ptHead.x = line.ptLine.x; |
2535 CPVT_WordPlace place; | 2326 ptHead.y = line.ptLine.y + line.fLineAscent; |
2536 | 2327 ptFoot.x = line.ptLine.x; |
2537 while (pIterator->NextWord()) | 2328 ptFoot.y = line.ptLine.y + line.fLineDescent; |
2538 { | 2329 } |
2539 place = pIterator->GetAt(); | 2330 } |
2540 if (place.WordCmp(wrTemp.EndPos) > 0) break; | 2331 |
2541 | 2332 m_bNotifyFlag = TRUE; |
2542 pIterator->GetWord(wordinfo); | 2333 m_pNotify->IOnSetCaret( |
2543 pIterator->GetLine(lineinfo); | 2334 !m_SelState.IsExist(), VTToEdit(ptHead), VTToEdit(ptFoot), m_wpCaret); |
2544 | 2335 m_bNotifyFlag = FALSE; |
2545 if (place.LineCmp(wrTemp.BeginPos) == 0 || place.LineCmp
(wrTemp.EndPos) == 0) | 2336 } |
2546 { | 2337 } |
2547 CPDF_Rect rcWord(wordinfo.ptWord.x, | 2338 |
2548 lineinfo
.ptLine.y + lineinfo.fLineDescent, | 2339 SetCaretChange(); |
2549 wordinfo
.ptWord.x + wordinfo.fWidth, | 2340 } |
2550 lineinfo
.ptLine.y + lineinfo.fLineAscent); | 2341 |
2551 | 2342 void CFX_Edit::SetCaretChange() { |
2552 if (m_bNotify && m_pNotify) | 2343 if (this->m_wpCaret == this->m_wpOldCaret) |
2553 { | 2344 return; |
2554 if (!m_bNotifyFlag) | 2345 |
2555 { | 2346 if (m_bNotify && m_pVT->IsRichText() && m_pNotify) { |
2556 m_bNotifyFlag = TRUE; | 2347 CPVT_SecProps SecProps; |
2557 CPDF_Rect rcRefresh = VTToEdit(r
cWord); | 2348 CPVT_WordProps WordProps; |
2558 m_pNotify->IOnInvalidateRect(&rc
Refresh); | 2349 |
2559 m_bNotifyFlag = FALSE; | 2350 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
2560 } | 2351 pIterator->SetAt(m_wpCaret); |
2561 } | 2352 CPVT_Word word; |
2562 } | 2353 CPVT_Section section; |
2563 else | 2354 |
2564 { | 2355 if (pIterator->GetSection(section)) { |
2565 CPDF_Rect rcLine(lineinfo.ptLine.x, | 2356 SecProps = section.SecProps; |
2566 lineinfo
.ptLine.y + lineinfo.fLineDescent, | 2357 WordProps = section.WordProps; |
2567 lineinfo
.ptLine.x + lineinfo.fLineWidth, | 2358 } |
2568 lineinfo
.ptLine.y + lineinfo.fLineAscent); | 2359 |
2569 | 2360 if (pIterator->GetWord(word)) { |
2570 if (m_bNotify && m_pNotify) | 2361 WordProps = word.WordProps; |
2571 { | 2362 } |
2572 if (!m_bNotifyFlag) | 2363 } |
2573 { | 2364 |
2574 m_bNotifyFlag = TRUE; | 2365 if (!m_bNotifyFlag) { |
2575 CPDF_Rect rcRefresh = VTToEdit(r
cLine); | 2366 m_bNotifyFlag = TRUE; |
2576 m_pNotify->IOnInvalidateRect(&rc
Refresh); | 2367 m_pNotify->IOnCaretChange(SecProps, WordProps); |
2577 m_bNotifyFlag = FALSE; | 2368 m_bNotifyFlag = FALSE; |
2578 } | 2369 } |
2579 } | 2370 } |
2580 | 2371 } |
2581 pIterator->NextLine(); | 2372 |
2582 } | 2373 void CFX_Edit::SetCaret(FX_INT32 nPos) { |
2583 } | 2374 if (m_pVT->IsValid()) { |
2584 } | 2375 SelectNone(); |
2585 } | 2376 SetCaret(m_pVT->WordIndexToWordPlace(nPos)); |
2586 | 2377 m_SelState.Set(m_wpCaret, m_wpCaret); |
2587 void CFX_Edit::SetCaret(const CPVT_WordPlace & place) | 2378 |
2588 { | 2379 ScrollToCaret(); |
2589 m_wpOldCaret = m_wpCaret; | 2380 SetCaretOrigin(); |
2590 m_wpCaret = place; | 2381 SetCaretInfo(); |
2591 } | 2382 } |
2592 | 2383 } |
2593 void CFX_Edit::SetCaretInfo() | 2384 |
2594 { | 2385 void CFX_Edit::OnMouseDown(const CPDF_Point& point, |
2595 if (m_bNotify && m_pNotify) | 2386 FX_BOOL bShift, |
2596 { | 2387 FX_BOOL bCtrl) { |
2597 if (!m_bNotifyFlag) | 2388 if (m_pVT->IsValid()) { |
2598 { | 2389 SelectNone(); |
2599 CPDF_Point ptHead(0.0f,0.0f),ptFoot(0.0f,0.0f); | 2390 SetCaret(m_pVT->SearchWordPlace(EditToVT(point))); |
2600 | 2391 m_SelState.Set(m_wpCaret, m_wpCaret); |
2601 if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetI
terator()) | 2392 |
2602 { | 2393 ScrollToCaret(); |
2603 pIterator->SetAt(m_wpCaret); | 2394 SetCaretOrigin(); |
2604 CPVT_Word word; | 2395 SetCaretInfo(); |
2605 CPVT_Line line; | 2396 } |
2606 if (pIterator->GetWord(word)) | 2397 } |
2607 { | 2398 |
2608 ptHead.x = word.ptWord.x + word.fWidth; | 2399 void CFX_Edit::OnMouseMove(const CPDF_Point& point, |
2609 ptHead.y = word.ptWord.y + word.fAscent; | 2400 FX_BOOL bShift, |
2610 ptFoot.x = word.ptWord.x + word.fWidth; | 2401 FX_BOOL bCtrl) { |
2611 ptFoot.y = word.ptWord.y + word.fDescent
; | 2402 if (m_pVT->IsValid()) { |
2612 } | 2403 SetCaret(m_pVT->SearchWordPlace(EditToVT(point))); |
2613 else if (pIterator->GetLine(line)) | 2404 |
2614 { | 2405 if (m_wpCaret != m_wpOldCaret) { |
2615 ptHead.x = line.ptLine.x; | 2406 m_SelState.SetEndPos(m_wpCaret); |
2616 ptHead.y = line.ptLine.y + line.fLineAsc
ent; | 2407 |
2617 ptFoot.x = line.ptLine.x; | 2408 ScrollToCaret(); |
2618 ptFoot.y = line.ptLine.y + line.fLineDes
cent; | 2409 CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); |
2619 } | 2410 Refresh(RP_OPTIONAL, &wr); |
2620 } | 2411 SetCaretOrigin(); |
2621 | 2412 SetCaretInfo(); |
2622 m_bNotifyFlag = TRUE; | 2413 } |
2623 m_pNotify->IOnSetCaret(!m_SelState.IsExist(),VTToEdit(pt
Head),VTToEdit(ptFoot), m_wpCaret); | 2414 } |
2624 m_bNotifyFlag = FALSE; | 2415 } |
2625 } | 2416 |
2626 } | 2417 void CFX_Edit::OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl) { |
2627 | 2418 if (m_pVT->IsValid()) { |
2628 SetCaretChange(); | 2419 SetCaret(m_pVT->GetUpWordPlace(m_wpCaret, m_ptCaret)); |
2629 } | 2420 |
2630 | 2421 if (bShift) { |
2631 void CFX_Edit::SetCaretChange() | 2422 if (m_SelState.IsExist()) |
2632 { | 2423 m_SelState.SetEndPos(m_wpCaret); |
2633 if (this->m_wpCaret == this->m_wpOldCaret) return; | 2424 else |
2634 | 2425 m_SelState.Set(m_wpOldCaret, m_wpCaret); |
2635 if (m_bNotify && m_pVT->IsRichText() && m_pNotify) | 2426 |
2636 { | 2427 if (m_wpOldCaret != m_wpCaret) { |
2637 CPVT_SecProps SecProps; | 2428 ScrollToCaret(); |
2638 CPVT_WordProps WordProps; | 2429 CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); |
2639 | 2430 Refresh(RP_OPTIONAL, &wr); |
2640 if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator(
)) | 2431 SetCaretInfo(); |
2641 { | 2432 } |
2642 pIterator->SetAt(m_wpCaret); | 2433 } else { |
2643 CPVT_Word word; | 2434 SelectNone(); |
2644 CPVT_Section section; | 2435 |
2645 | 2436 ScrollToCaret(); |
2646 if (pIterator->GetSection(section)) | 2437 SetCaretInfo(); |
2647 { | 2438 } |
2648 SecProps = section.SecProps; | 2439 } |
2649 WordProps = section.WordProps; | 2440 } |
2650 } | 2441 |
2651 | 2442 void CFX_Edit::OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl) { |
2652 if (pIterator->GetWord(word)) | 2443 if (m_pVT->IsValid()) { |
2653 { | 2444 SetCaret(m_pVT->GetDownWordPlace(m_wpCaret, m_ptCaret)); |
2654 WordProps = word.WordProps;
| 2445 |
2655 } | 2446 if (bShift) { |
2656 } | 2447 if (m_SelState.IsExist()) |
2657 | 2448 m_SelState.SetEndPos(m_wpCaret); |
2658 if (!m_bNotifyFlag) | 2449 else |
2659 { | 2450 m_SelState.Set(m_wpOldCaret, m_wpCaret); |
2660 m_bNotifyFlag = TRUE; | 2451 |
2661 m_pNotify->IOnCaretChange(SecProps,WordProps); | 2452 if (m_wpOldCaret != m_wpCaret) { |
2662 m_bNotifyFlag = FALSE; | 2453 ScrollToCaret(); |
2663 } | 2454 CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); |
2664 } | 2455 Refresh(RP_OPTIONAL, &wr); |
2665 } | 2456 SetCaretInfo(); |
2666 | 2457 } |
2667 void CFX_Edit::SetCaret(FX_INT32 nPos) | 2458 } else { |
2668 { | 2459 SelectNone(); |
2669 if (m_pVT->IsValid()) | 2460 |
2670 { | 2461 ScrollToCaret(); |
2671 SelectNone(); | 2462 SetCaretInfo(); |
2672 SetCaret(m_pVT->WordIndexToWordPlace(nPos)); | 2463 } |
2673 m_SelState.Set(m_wpCaret,m_wpCaret); | 2464 } |
2674 | 2465 } |
2675 ScrollToCaret(); | 2466 |
2676 SetCaretOrigin(); | 2467 void CFX_Edit::OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl) { |
2677 SetCaretInfo(); | 2468 if (m_pVT->IsValid()) { |
2678 } | 2469 if (bShift) { |
2679 } | 2470 if (m_wpCaret == m_pVT->GetLineBeginPlace(m_wpCaret) && |
2680 | 2471 m_wpCaret != m_pVT->GetSectionBeginPlace(m_wpCaret)) |
2681 void CFX_Edit::OnMouseDown(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl
) | 2472 SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret)); |
2682 { | 2473 |
2683 if (m_pVT->IsValid()) | 2474 SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret)); |
2684 { | 2475 |
2685 SelectNone(); | 2476 if (m_SelState.IsExist()) |
2686 SetCaret(m_pVT->SearchWordPlace(EditToVT(point))); | 2477 m_SelState.SetEndPos(m_wpCaret); |
2687 m_SelState.Set(m_wpCaret,m_wpCaret); | 2478 else |
2688 | 2479 m_SelState.Set(m_wpOldCaret, m_wpCaret); |
2689 ScrollToCaret(); | 2480 |
2690 SetCaretOrigin(); | 2481 if (m_wpOldCaret != m_wpCaret) { |
2691 SetCaretInfo(); | 2482 ScrollToCaret(); |
2692 } | 2483 CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); |
2693 } | 2484 Refresh(RP_OPTIONAL, &wr); |
2694 | 2485 SetCaretInfo(); |
2695 void CFX_Edit::OnMouseMove(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl
) | 2486 } |
2696 { | 2487 } else { |
2697 if (m_pVT->IsValid()) | 2488 if (m_SelState.IsExist()) { |
2698 { | 2489 if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos) < 0) |
2699 SetCaret(m_pVT->SearchWordPlace(EditToVT(point))); | 2490 SetCaret(m_SelState.BeginPos); |
2700 | 2491 else |
2701 if (m_wpCaret != m_wpOldCaret) | 2492 SetCaret(m_SelState.EndPos); |
2702 { | 2493 |
2703 m_SelState.SetEndPos(m_wpCaret); | 2494 SelectNone(); |
2704 | 2495 ScrollToCaret(); |
2705 ScrollToCaret(); | 2496 SetCaretInfo(); |
2706 CPVT_WordRange wr(m_wpOldCaret,m_wpCaret); | 2497 } else { |
2707 Refresh(RP_OPTIONAL,&wr); | 2498 if (m_wpCaret == m_pVT->GetLineBeginPlace(m_wpCaret) && |
2708 SetCaretOrigin(); | 2499 m_wpCaret != m_pVT->GetSectionBeginPlace(m_wpCaret)) |
2709 SetCaretInfo(); | 2500 SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret)); |
2710 } | 2501 |
2711 } | 2502 SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret)); |
2712 } | 2503 |
2713 | 2504 ScrollToCaret(); |
2714 void CFX_Edit::OnVK_UP(FX_BOOL bShift,FX_BOOL bCtrl) | 2505 SetCaretOrigin(); |
2715 { | 2506 SetCaretInfo(); |
2716 if (m_pVT->IsValid()) | 2507 } |
2717 { | 2508 } |
2718 SetCaret(m_pVT->GetUpWordPlace(m_wpCaret,m_ptCaret)); | 2509 } |
2719 | 2510 } |
2720 if (bShift) | 2511 |
2721 { | 2512 void CFX_Edit::OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl) { |
2722 if (m_SelState.IsExist()) | 2513 if (m_pVT->IsValid()) { |
2723 m_SelState.SetEndPos(m_wpCaret); | 2514 if (bShift) { |
2724 else | 2515 SetCaret(m_pVT->GetNextWordPlace(m_wpCaret)); |
2725 m_SelState.Set(m_wpOldCaret,m_wpCaret); | 2516 |
2726 | 2517 if (m_wpCaret == m_pVT->GetLineEndPlace(m_wpCaret) && |
2727 if (m_wpOldCaret != m_wpCaret) | 2518 m_wpCaret != m_pVT->GetSectionEndPlace(m_wpCaret)) |
2728 { | 2519 SetCaret(m_pVT->GetNextWordPlace(m_wpCaret)); |
2729 ScrollToCaret(); | 2520 |
2730 CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); | 2521 if (m_SelState.IsExist()) |
2731 Refresh(RP_OPTIONAL, &wr); | 2522 m_SelState.SetEndPos(m_wpCaret); |
2732 SetCaretInfo(); | 2523 else |
2733 } | 2524 m_SelState.Set(m_wpOldCaret, m_wpCaret); |
2734 } | 2525 |
2735 else | 2526 if (m_wpOldCaret != m_wpCaret) { |
2736 { | 2527 ScrollToCaret(); |
2737 SelectNone(); | 2528 CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); |
2738 | 2529 Refresh(RP_OPTIONAL, &wr); |
2739 ScrollToCaret(); | 2530 SetCaretInfo(); |
2740 SetCaretInfo(); | 2531 } |
2741 } | 2532 } else { |
2742 } | 2533 if (m_SelState.IsExist()) { |
2743 } | 2534 if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos) > 0) |
2744 | 2535 SetCaret(m_SelState.BeginPos); |
2745 void CFX_Edit::OnVK_DOWN(FX_BOOL bShift,FX_BOOL bCtrl) | 2536 else |
2746 { | 2537 SetCaret(m_SelState.EndPos); |
2747 if (m_pVT->IsValid()) | 2538 |
2748 { | 2539 SelectNone(); |
2749 SetCaret(m_pVT->GetDownWordPlace(m_wpCaret,m_ptCaret)); | 2540 ScrollToCaret(); |
2750 | 2541 SetCaretInfo(); |
2751 if (bShift) | 2542 } else { |
2752 { | 2543 SetCaret(m_pVT->GetNextWordPlace(m_wpCaret)); |
2753 if (m_SelState.IsExist()) | 2544 |
2754 m_SelState.SetEndPos(m_wpCaret); | 2545 if (m_wpCaret == m_pVT->GetLineEndPlace(m_wpCaret) && |
2755 else | 2546 m_wpCaret != m_pVT->GetSectionEndPlace(m_wpCaret)) |
2756 m_SelState.Set(m_wpOldCaret,m_wpCaret); | 2547 SetCaret(m_pVT->GetNextWordPlace(m_wpCaret)); |
2757 | 2548 |
2758 if (m_wpOldCaret != m_wpCaret) | 2549 ScrollToCaret(); |
2759 { | 2550 SetCaretOrigin(); |
2760 ScrollToCaret(); | 2551 SetCaretInfo(); |
2761 CPVT_WordRange wr(m_wpOldCaret,m_wpCaret); | 2552 } |
2762 Refresh(RP_OPTIONAL, &wr); | 2553 } |
2763 SetCaretInfo(); | 2554 } |
2764 } | 2555 } |
2765 } | 2556 |
2766 else | 2557 void CFX_Edit::OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl) { |
2767 { | 2558 if (m_pVT->IsValid()) { |
2768 SelectNone(); | 2559 if (bShift) { |
2769 | 2560 if (bCtrl) |
2770 ScrollToCaret(); | 2561 SetCaret(m_pVT->GetBeginWordPlace()); |
2771 SetCaretInfo(); | 2562 else |
2772 } | 2563 SetCaret(m_pVT->GetLineBeginPlace(m_wpCaret)); |
2773 } | 2564 |
2774 } | 2565 if (m_SelState.IsExist()) |
2775 | 2566 m_SelState.SetEndPos(m_wpCaret); |
2776 void CFX_Edit::OnVK_LEFT(FX_BOOL bShift,FX_BOOL bCtrl) | 2567 else |
2777 { | 2568 m_SelState.Set(m_wpOldCaret, m_wpCaret); |
2778 if (m_pVT->IsValid()) | 2569 |
2779 { | 2570 ScrollToCaret(); |
2780 if (bShift) | 2571 CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); |
2781 { | 2572 Refresh(RP_OPTIONAL, &wr); |
2782 if (m_wpCaret == m_pVT->GetLineBeginPlace(m_wpCaret) && | 2573 SetCaretInfo(); |
2783 m_wpCaret != m_pVT->GetSectionBeginPlace(m_wpCar
et)) | 2574 } else { |
2784 SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret)); | 2575 if (m_SelState.IsExist()) { |
2785 | 2576 if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos) < 0) |
2786 SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret)); | 2577 SetCaret(m_SelState.BeginPos); |
2787 | 2578 else |
2788 if (m_SelState.IsExist()) | 2579 SetCaret(m_SelState.EndPos); |
2789 m_SelState.SetEndPos(m_wpCaret);
| 2580 |
2790 else | 2581 SelectNone(); |
2791 m_SelState.Set(m_wpOldCaret, m_wpCaret); | 2582 ScrollToCaret(); |
2792 | 2583 SetCaretInfo(); |
2793 if (m_wpOldCaret != m_wpCaret) | 2584 } else { |
2794 { | 2585 if (bCtrl) |
2795 ScrollToCaret(); | 2586 SetCaret(m_pVT->GetBeginWordPlace()); |
2796 CPVT_WordRange wr(m_wpOldCaret,m_wpCaret); | 2587 else |
2797 Refresh(RP_OPTIONAL,&wr); | 2588 SetCaret(m_pVT->GetLineBeginPlace(m_wpCaret)); |
2798 SetCaretInfo(); | 2589 |
2799 } | 2590 ScrollToCaret(); |
2800 } | 2591 SetCaretOrigin(); |
2801 else | 2592 SetCaretInfo(); |
2802 { | 2593 } |
2803 if (m_SelState.IsExist()) | 2594 } |
2804 { | 2595 } |
2805 if (m_SelState.BeginPos.WordCmp(m_SelState.EndPo
s)<0) | 2596 } |
2806 SetCaret(m_SelState.BeginPos); | 2597 |
2807 else | 2598 void CFX_Edit::OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl) { |
2808 SetCaret(m_SelState.EndPos); | 2599 if (m_pVT->IsValid()) { |
2809 | 2600 if (bShift) { |
2810 SelectNone(); | 2601 if (bCtrl) |
2811 ScrollToCaret(); | 2602 SetCaret(m_pVT->GetEndWordPlace()); |
2812 SetCaretInfo(); | 2603 else |
2813 } | 2604 SetCaret(m_pVT->GetLineEndPlace(m_wpCaret)); |
2814 else | 2605 |
2815 { | 2606 if (m_SelState.IsExist()) |
2816 if (m_wpCaret == m_pVT->GetLineBeginPlace(m_wpCa
ret) && | 2607 m_SelState.SetEndPos(m_wpCaret); |
2817 m_wpCaret != m_pVT->GetSectionBeginPlace
(m_wpCaret)) | 2608 else |
2818 SetCaret(m_pVT->GetPrevWordPlace(m_wpCar
et)); | 2609 m_SelState.Set(m_wpOldCaret, m_wpCaret); |
2819 | 2610 |
2820 SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret)); | 2611 ScrollToCaret(); |
2821 | 2612 CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); |
2822 ScrollToCaret(); | 2613 Refresh(RP_OPTIONAL, &wr); |
2823 SetCaretOrigin(); | 2614 SetCaretInfo(); |
2824 SetCaretInfo(); | 2615 } else { |
2825 } | 2616 if (m_SelState.IsExist()) { |
2826 } | 2617 if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos) > 0) |
2827 } | 2618 SetCaret(m_SelState.BeginPos); |
2828 } | 2619 else |
2829 | 2620 SetCaret(m_SelState.EndPos); |
2830 void CFX_Edit::OnVK_RIGHT(FX_BOOL bShift,FX_BOOL bCtrl) | 2621 |
2831 { | 2622 SelectNone(); |
2832 if (m_pVT->IsValid()) | 2623 ScrollToCaret(); |
2833 { | 2624 SetCaretInfo(); |
2834 if (bShift) | 2625 } else { |
2835 { | 2626 if (bCtrl) |
2836 SetCaret(m_pVT->GetNextWordPlace(m_wpCaret)); | 2627 SetCaret(m_pVT->GetEndWordPlace()); |
2837 | 2628 else |
2838 if (m_wpCaret == m_pVT->GetLineEndPlace(m_wpCaret) && | 2629 SetCaret(m_pVT->GetLineEndPlace(m_wpCaret)); |
2839 m_wpCaret != m_pVT->GetSectionEndPlace(m_wpCaret
)) | 2630 |
2840 SetCaret(m_pVT->GetNextWordPlace(m_wpCaret)); | 2631 ScrollToCaret(); |
2841 | 2632 SetCaretOrigin(); |
2842 if (m_SelState.IsExist()) | 2633 SetCaretInfo(); |
2843 m_SelState.SetEndPos(m_wpCaret);
| 2634 } |
2844 else | 2635 } |
2845 m_SelState.Set(m_wpOldCaret,m_wpCaret);
| 2636 } |
2846 | 2637 } |
2847 if (m_wpOldCaret != m_wpCaret) | 2638 |
2848 { | 2639 void CFX_Edit::SetText(FX_LPCWSTR text, |
2849 ScrollToCaret(); | 2640 FX_INT32 charset, |
2850 CPVT_WordRange wr(m_wpOldCaret,m_wpCaret); | 2641 const CPVT_SecProps* pSecProps, |
2851 Refresh(RP_OPTIONAL,&wr); | 2642 const CPVT_WordProps* pWordProps, |
2852 SetCaretInfo(); | 2643 FX_BOOL bAddUndo, |
2853 } | 2644 FX_BOOL bPaint) { |
2854 } | 2645 Empty(); |
2855 else | 2646 DoInsertText(CPVT_WordPlace(0, 0, -1), text, charset, pSecProps, pWordProps); |
2856 { | 2647 if (bPaint) |
2857 if (m_SelState.IsExist()) | 2648 Paint(); |
2858 { | 2649 if (m_bOprNotify && m_pOprNotify) |
2859 if (m_SelState.BeginPos.WordCmp(m_SelState.EndPo
s)>0) | 2650 m_pOprNotify->OnSetText(m_wpCaret, m_wpOldCaret); |
2860 SetCaret(m_SelState.BeginPos); | 2651 // if (bAddUndo) |
2861 else | 2652 } |
2862 SetCaret(m_SelState.EndPos); | 2653 |
2863 | 2654 FX_BOOL CFX_Edit::InsertWord(FX_WORD word, |
2864 SelectNone(); | 2655 FX_INT32 charset, |
2865 ScrollToCaret(); | 2656 const CPVT_WordProps* pWordProps, |
2866 SetCaretInfo(); | 2657 FX_BOOL bAddUndo, |
2867 } | 2658 FX_BOOL bPaint) { |
2868 else | 2659 if (IsTextOverflow()) |
2869 { | 2660 return FALSE; |
2870 SetCaret(m_pVT->GetNextWordPlace(m_wpCaret)); | 2661 |
2871 | 2662 if (m_pVT->IsValid()) { |
2872 if (m_wpCaret == m_pVT->GetLineEndPlace(m_wpCare
t) && | 2663 m_pVT->UpdateWordPlace(m_wpCaret); |
2873 m_wpCaret != m_pVT->GetSectionEndPlace(m
_wpCaret)) | 2664 |
2874 SetCaret(m_pVT->GetNextWordPlace(m_wpCar
et)); | 2665 SetCaret(m_pVT->InsertWord( |
2875 | 2666 m_wpCaret, word, GetCharSetFromUnicode(word, charset), pWordProps)); |
2876 ScrollToCaret(); | 2667 m_SelState.Set(m_wpCaret, m_wpCaret); |
2877 SetCaretOrigin(); | 2668 |
2878 SetCaretInfo(); | 2669 if (m_wpCaret != m_wpOldCaret) { |
2879 } | 2670 if (bAddUndo && m_bEnableUndo) { |
2880 } | 2671 AddEditUndoItem(new CFXEU_InsertWord( |
2881 } | 2672 this, m_wpOldCaret, m_wpCaret, word, charset, pWordProps)); |
2882 } | 2673 } |
2883 | 2674 |
2884 void CFX_Edit::OnVK_HOME(FX_BOOL bShift,FX_BOOL bCtrl) | 2675 if (bPaint) |
2885 { | 2676 PaintInsertText(m_wpOldCaret, m_wpCaret); |
2886 if (m_pVT->IsValid()) | 2677 |
2887 { | 2678 if (m_bOprNotify && m_pOprNotify) |
2888 if (bShift) | 2679 m_pOprNotify->OnInsertWord(m_wpCaret, m_wpOldCaret); |
2889 { | 2680 |
2890 if (bCtrl) | 2681 return TRUE; |
2891 SetCaret(m_pVT->GetBeginWordPlace()); | 2682 } |
2892 else | 2683 } |
2893 SetCaret(m_pVT->GetLineBeginPlace(m_wpCaret)); | 2684 |
2894 | 2685 return FALSE; |
2895 if (m_SelState.IsExist()) | 2686 } |
2896 m_SelState.SetEndPos(m_wpCaret);
| 2687 |
2897 else | 2688 FX_BOOL CFX_Edit::InsertReturn(const CPVT_SecProps* pSecProps, |
2898 m_SelState.Set(m_wpOldCaret,m_wpCaret); | 2689 const CPVT_WordProps* pWordProps, |
2899 | 2690 FX_BOOL bAddUndo, |
2900 ScrollToCaret(); | 2691 FX_BOOL bPaint) { |
2901 CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); | 2692 if (IsTextOverflow()) |
2902 Refresh(RP_OPTIONAL, &wr); | 2693 return FALSE; |
2903 SetCaretInfo(); | 2694 |
2904 } | 2695 if (m_pVT->IsValid()) { |
2905 else | 2696 m_pVT->UpdateWordPlace(m_wpCaret); |
2906 { | 2697 SetCaret(m_pVT->InsertSection(m_wpCaret, pSecProps, pWordProps)); |
2907 if (m_SelState.IsExist()) | 2698 m_SelState.Set(m_wpCaret, m_wpCaret); |
2908 { | 2699 |
2909 if (m_SelState.BeginPos.WordCmp(m_SelState.EndPo
s)<0) | 2700 if (m_wpCaret != m_wpOldCaret) { |
2910 SetCaret(m_SelState.BeginPos); | 2701 if (bAddUndo && m_bEnableUndo) { |
2911 else | 2702 AddEditUndoItem(new CFXEU_InsertReturn( |
2912 SetCaret(m_SelState.EndPos); | 2703 this, m_wpOldCaret, m_wpCaret, pSecProps, pWordProps)); |
2913 | 2704 } |
2914 SelectNone(); | 2705 |
2915 ScrollToCaret(); | 2706 if (bPaint) { |
2916 SetCaretInfo(); | 2707 RearrangePart(CPVT_WordRange(m_wpOldCaret, m_wpCaret)); |
2917 } | 2708 ScrollToCaret(); |
2918 else | 2709 CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRange().EndPos); |
2919 { | 2710 Refresh(RP_ANALYSE, &wr); |
2920 if (bCtrl) | 2711 SetCaretOrigin(); |
2921 SetCaret(m_pVT->GetBeginWordPlace()); | 2712 SetCaretInfo(); |
2922 else | 2713 } |
2923 SetCaret(m_pVT->GetLineBeginPlace(m_wpCa
ret)); | 2714 |
2924 | 2715 if (m_bOprNotify && m_pOprNotify) |
2925 ScrollToCaret(); | 2716 m_pOprNotify->OnInsertReturn(m_wpCaret, m_wpOldCaret); |
2926 SetCaretOrigin(); | 2717 |
2927 SetCaretInfo(); | 2718 return TRUE; |
2928 } | 2719 } |
2929 } | 2720 } |
2930 } | 2721 |
2931 } | 2722 return FALSE; |
2932 | 2723 } |
2933 void CFX_Edit::OnVK_END(FX_BOOL bShift,FX_BOOL bCtrl) | 2724 |
2934 { | 2725 FX_BOOL CFX_Edit::Backspace(FX_BOOL bAddUndo, FX_BOOL bPaint) { |
2935 if (m_pVT->IsValid()) | 2726 if (m_pVT->IsValid()) { |
2936 { | 2727 if (m_wpCaret == m_pVT->GetBeginWordPlace()) |
2937 if (bShift) | 2728 return FALSE; |
2938 { | 2729 |
2939 if (bCtrl) | 2730 CPVT_Section section; |
2940 SetCaret(m_pVT->GetEndWordPlace()); | 2731 CPVT_Word word; |
2941 else | 2732 |
2942 SetCaret(m_pVT->GetLineEndPlace(m_wpCaret)); | 2733 if (bAddUndo) { |
2943 | 2734 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
2944 if (m_SelState.IsExist()) | 2735 pIterator->SetAt(m_wpCaret); |
2945 m_SelState.SetEndPos(m_wpCaret); | 2736 pIterator->GetSection(section); |
2946 else | 2737 pIterator->GetWord(word); |
2947 m_SelState.Set(m_wpOldCaret, m_wpCaret); | 2738 } |
2948 | 2739 } |
2949 ScrollToCaret(); | 2740 |
2950 CPVT_WordRange wr(m_wpOldCaret, m_wpCaret); | 2741 m_pVT->UpdateWordPlace(m_wpCaret); |
2951 Refresh(RP_OPTIONAL, &wr); | 2742 SetCaret(m_pVT->BackSpaceWord(m_wpCaret)); |
2952 SetCaretInfo(); | 2743 m_SelState.Set(m_wpCaret, m_wpCaret); |
2953 } | 2744 |
2954 else | 2745 if (m_wpCaret != m_wpOldCaret) { |
2955 { | 2746 if (bAddUndo && m_bEnableUndo) { |
2956 if (m_SelState.IsExist()) | 2747 if (m_wpCaret.SecCmp(m_wpOldCaret) != 0) |
2957 { | 2748 AddEditUndoItem(new CFXEU_Backspace(this, |
2958 if (m_SelState.BeginPos.WordCmp(m_SelState.EndPo
s)>0) | 2749 m_wpOldCaret, |
2959 SetCaret(m_SelState.BeginPos); | 2750 m_wpCaret, |
2960 else | 2751 word.Word, |
2961 SetCaret(m_SelState.EndPos); | 2752 word.nCharset, |
2962 | 2753 section.SecProps, |
2963 SelectNone(); | 2754 section.WordProps)); |
2964 ScrollToCaret(); | 2755 else |
2965 SetCaretInfo(); | 2756 AddEditUndoItem(new CFXEU_Backspace(this, |
2966 } | 2757 m_wpOldCaret, |
2967 else | 2758 m_wpCaret, |
2968 { | 2759 word.Word, |
2969 if (bCtrl) | 2760 word.nCharset, |
2970 SetCaret(m_pVT->GetEndWordPlace()); | 2761 section.SecProps, |
2971 else | 2762 word.WordProps)); |
2972 SetCaret(m_pVT->GetLineEndPlace(m_wpCare
t)); | 2763 } |
2973 | 2764 |
2974 ScrollToCaret(); | 2765 if (bPaint) { |
2975 SetCaretOrigin(); | 2766 RearrangePart(CPVT_WordRange(m_wpCaret, m_wpOldCaret)); |
2976 SetCaretInfo(); | 2767 ScrollToCaret(); |
2977 } | 2768 |
2978 } | 2769 CPVT_WordRange wr; |
2979 } | 2770 if (m_wpCaret.SecCmp(m_wpOldCaret) != 0) |
2980 } | 2771 wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpCaret), |
2981 | 2772 GetVisibleWordRange().EndPos); |
2982 void CFX_Edit::SetText(FX_LPCWSTR text,FX_INT32 charset, | 2773 else if (m_wpCaret.LineCmp(m_wpOldCaret) != 0) |
2983 const CPVT_SecProps * pSecProps,
const CPVT_WordProps * pWordProps, FX_BOOL bAddUndo, FX_BOOL bPaint) | 2774 wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(m_wpCaret), |
2984 { | 2775 m_pVT->GetSectionEndPlace(m_wpCaret)); |
2985 Empty(); | 2776 else |
2986 DoInsertText(CPVT_WordPlace(0,0,-1), text, charset, pSecProps, pWordProp
s); | 2777 wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpCaret), |
2987 if (bPaint) Paint(); | 2778 m_pVT->GetSectionEndPlace(m_wpCaret)); |
2988 if (m_bOprNotify && m_pOprNotify) | 2779 |
2989 m_pOprNotify->OnSetText(m_wpCaret, m_wpOldCaret); | 2780 Refresh(RP_ANALYSE, &wr); |
2990 //if (bAddUndo) | 2781 |
2991 } | 2782 SetCaretOrigin(); |
2992 | 2783 SetCaretInfo(); |
2993 FX_BOOL CFX_Edit::InsertWord(FX_WORD word, FX_INT32 charset, const CPVT_WordProp
s * pWordProps, FX_BOOL bAddUndo, FX_BOOL bPaint) | 2784 } |
2994 { | 2785 |
2995 if (IsTextOverflow()) return FALSE; | 2786 if (m_bOprNotify && m_pOprNotify) |
2996 | 2787 m_pOprNotify->OnBackSpace(m_wpCaret, m_wpOldCaret); |
2997 if (m_pVT->IsValid()) | 2788 |
2998 { | 2789 return TRUE; |
2999 m_pVT->UpdateWordPlace(m_wpCaret); | 2790 } |
3000 | 2791 } |
3001 SetCaret(m_pVT->InsertWord(m_wpCaret,word,GetCharSetFromUnicode(
word, charset),pWordProps)); | 2792 |
3002 m_SelState.Set(m_wpCaret,m_wpCaret); | 2793 return FALSE; |
3003 | 2794 } |
3004 if (m_wpCaret != m_wpOldCaret) | 2795 |
3005 { | 2796 FX_BOOL CFX_Edit::Delete(FX_BOOL bAddUndo, FX_BOOL bPaint) { |
3006 if (bAddUndo && m_bEnableUndo) | 2797 if (m_pVT->IsValid()) { |
3007 { | 2798 if (m_wpCaret == m_pVT->GetEndWordPlace()) |
3008 AddEditUndoItem(new CFXEU_InsertWord(this,m_wpOl
dCaret,m_wpCaret,word,charset,pWordProps)); | 2799 return FALSE; |
3009 } | 2800 |
3010 | 2801 CPVT_Section section; |
3011 if (bPaint) | 2802 CPVT_Word word; |
3012 PaintInsertText(m_wpOldCaret, m_wpCaret); | 2803 |
3013 | 2804 if (bAddUndo) { |
3014 if (m_bOprNotify && m_pOprNotify) | 2805 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
3015 m_pOprNotify->OnInsertWord(m_wpCaret, m_wpOldCar
et); | 2806 pIterator->SetAt(m_pVT->GetNextWordPlace(m_wpCaret)); |
3016 | 2807 pIterator->GetSection(section); |
3017 return TRUE; | 2808 pIterator->GetWord(word); |
3018 } | 2809 } |
3019 } | 2810 } |
3020 | 2811 |
3021 return FALSE; | 2812 m_pVT->UpdateWordPlace(m_wpCaret); |
3022 } | 2813 FX_BOOL bSecEnd = (m_wpCaret == m_pVT->GetSectionEndPlace(m_wpCaret)); |
3023 | 2814 |
3024 FX_BOOL CFX_Edit::InsertReturn(const CPVT_SecProps * pSecProps,const CPVT_WordPr
ops * pWordProps, | 2815 SetCaret(m_pVT->DeleteWord(m_wpCaret)); |
3025 FX_BOOL bAddUndo, FX_
BOOL bPaint) | 2816 m_SelState.Set(m_wpCaret, m_wpCaret); |
3026 { | 2817 |
3027 if (IsTextOverflow()) return FALSE; | 2818 if (bAddUndo && m_bEnableUndo) { |
3028 | 2819 if (bSecEnd) |
3029 if (m_pVT->IsValid()) | 2820 AddEditUndoItem(new CFXEU_Delete(this, |
3030 { | 2821 m_wpOldCaret, |
3031 m_pVT->UpdateWordPlace(m_wpCaret); | 2822 m_wpCaret, |
3032 SetCaret(m_pVT->InsertSection(m_wpCaret,pSecProps,pWordProps)); | 2823 word.Word, |
3033 m_SelState.Set(m_wpCaret,m_wpCaret); | 2824 word.nCharset, |
3034 | 2825 section.SecProps, |
3035 if (m_wpCaret != m_wpOldCaret) | 2826 section.WordProps, |
3036 { | 2827 bSecEnd)); |
3037 if (bAddUndo && m_bEnableUndo) | 2828 else |
3038 { | 2829 AddEditUndoItem(new CFXEU_Delete(this, |
3039 AddEditUndoItem(new CFXEU_InsertReturn(this,m_wp
OldCaret,m_wpCaret,pSecProps,pWordProps)); | 2830 m_wpOldCaret, |
3040 } | 2831 m_wpCaret, |
3041 | 2832 word.Word, |
3042 if (bPaint) | 2833 word.nCharset, |
3043 { | 2834 section.SecProps, |
3044 RearrangePart(CPVT_WordRange(m_wpOldCaret, m_wpC
aret)); | 2835 word.WordProps, |
3045 ScrollToCaret(); | 2836 bSecEnd)); |
3046 CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRa
nge().EndPos); | 2837 } |
3047 Refresh(RP_ANALYSE, &wr); | 2838 |
3048 SetCaretOrigin(); | 2839 if (bPaint) { |
3049 SetCaretInfo(); | 2840 RearrangePart(CPVT_WordRange(m_wpOldCaret, m_wpCaret)); |
3050 } | 2841 ScrollToCaret(); |
3051 | 2842 |
3052 if (m_bOprNotify && m_pOprNotify) | 2843 CPVT_WordRange wr; |
3053 m_pOprNotify->OnInsertReturn(m_wpCaret, m_wpOldC
aret); | 2844 if (bSecEnd) |
3054 | 2845 wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpOldCaret), |
3055 return TRUE; | 2846 GetVisibleWordRange().EndPos); |
3056 } | 2847 else if (m_wpCaret.LineCmp(m_wpOldCaret) != 0) |
3057 } | 2848 wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(m_wpCaret), |
3058 | 2849 m_pVT->GetSectionEndPlace(m_wpCaret)); |
3059 return FALSE; | 2850 else |
3060 } | 2851 wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpOldCaret), |
3061 | 2852 m_pVT->GetSectionEndPlace(m_wpCaret)); |
3062 FX_BOOL CFX_Edit::Backspace(FX_BOOL bAddUndo, FX_BOOL bPaint) | 2853 |
3063 { | 2854 Refresh(RP_ANALYSE, &wr); |
3064 if (m_pVT->IsValid()) | 2855 |
3065 { | 2856 SetCaretOrigin(); |
3066 if (m_wpCaret == m_pVT->GetBeginWordPlace()) return FALSE; | 2857 SetCaretInfo(); |
3067 | 2858 } |
3068 CPVT_Section section; | 2859 |
3069 CPVT_Word word; | 2860 if (m_bOprNotify && m_pOprNotify) |
3070 | 2861 m_pOprNotify->OnDelete(m_wpCaret, m_wpOldCaret); |
3071 if (bAddUndo) | 2862 |
3072 { | 2863 return TRUE; |
3073 if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetI
terator()) | 2864 } |
3074 { | 2865 |
3075 pIterator->SetAt(m_wpCaret); | 2866 return FALSE; |
3076 pIterator->GetSection(section); | 2867 } |
3077 pIterator->GetWord(word); | 2868 |
3078 } | 2869 FX_BOOL CFX_Edit::Empty() { |
3079 } | 2870 if (m_pVT->IsValid()) { |
3080 | 2871 m_pVT->DeleteWords(GetWholeWordRange()); |
3081 m_pVT->UpdateWordPlace(m_wpCaret); | 2872 SetCaret(m_pVT->GetBeginWordPlace()); |
3082 SetCaret(m_pVT->BackSpaceWord(m_wpCaret)); | 2873 |
3083 m_SelState.Set(m_wpCaret,m_wpCaret); | 2874 return TRUE; |
3084 | 2875 } |
3085 if (m_wpCaret != m_wpOldCaret) | 2876 |
3086 { | 2877 return FALSE; |
3087 if (bAddUndo && m_bEnableUndo) | 2878 } |
3088 { | 2879 |
3089 if (m_wpCaret.SecCmp(m_wpOldCaret) != 0)
| 2880 FX_BOOL CFX_Edit::Clear(FX_BOOL bAddUndo, FX_BOOL bPaint) { |
3090 AddEditUndoItem(new CFXEU_Backspace(this
,m_wpOldCaret,m_wpCaret,word.Word,word.nCharset, | 2881 if (m_pVT->IsValid()) { |
3091 section.SecProps,section.WordPro
ps)); | 2882 if (m_SelState.IsExist()) { |
3092 else | 2883 CPVT_WordRange range = m_SelState.ConvertToWordRange(); |
3093 AddEditUndoItem(new CFXEU_Backspace(this
,m_wpOldCaret,m_wpCaret,word.Word,word.nCharset, | 2884 |
3094 section.SecProps,word.WordProps)
); | 2885 if (bAddUndo && m_bEnableUndo) { |
3095 } | 2886 if (m_pVT->IsRichText()) { |
3096 | 2887 BeginGroupUndo(L""); |
3097 if (bPaint) | 2888 |
3098 { | 2889 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
3099 RearrangePart(CPVT_WordRange(m_wpCaret,m_wpOldCa
ret)); | 2890 pIterator->SetAt(range.EndPos); |
3100 ScrollToCaret(); | 2891 |
3101 | 2892 CPVT_Word wordinfo; |
3102 CPVT_WordRange wr; | 2893 CPVT_Section secinfo; |
3103 if (m_wpCaret.SecCmp(m_wpOldCaret) !=0) | 2894 do { |
3104 wr = CPVT_WordRange(m_pVT->GetPrevWordPl
ace(m_wpCaret),GetVisibleWordRange().EndPos); | 2895 CPVT_WordPlace place = pIterator->GetAt(); |
3105 else if (m_wpCaret.LineCmp(m_wpOldCaret) !=0) | 2896 if (place.WordCmp(range.BeginPos) <= 0) |
3106 wr = CPVT_WordRange(m_pVT->GetLineBeginP
lace(m_wpCaret),m_pVT->GetSectionEndPlace(m_wpCaret)); | 2897 break; |
3107 else | 2898 |
3108 wr = CPVT_WordRange(m_pVT->GetPrevWordPl
ace(m_wpCaret),m_pVT->GetSectionEndPlace(m_wpCaret)); | 2899 CPVT_WordPlace oldplace = m_pVT->GetPrevWordPlace(place); |
3109 | 2900 |
3110 Refresh(RP_ANALYSE, &wr); | 2901 if (oldplace.SecCmp(place) != 0) { |
3111 | 2902 if (pIterator->GetSection(secinfo)) { |
3112 SetCaretOrigin(); | 2903 AddEditUndoItem(new CFXEU_ClearRich(this, |
3113 SetCaretInfo(); | 2904 oldplace, |
3114 } | 2905 place, |
3115 | 2906 range, |
3116 if (m_bOprNotify && m_pOprNotify) | 2907 wordinfo.Word, |
3117 m_pOprNotify->OnBackSpace(m_wpCaret, m_wpOldCare
t); | 2908 wordinfo.nCharset, |
3118 | 2909 secinfo.SecProps, |
3119 return TRUE; | 2910 secinfo.WordProps)); |
3120 } | 2911 } |
3121 } | 2912 } else { |
3122 | 2913 if (pIterator->GetWord(wordinfo)) { |
3123 return FALSE; | 2914 oldplace = m_pVT->AjustLineHeader(oldplace, TRUE); |
3124 } | 2915 place = m_pVT->AjustLineHeader(place, TRUE); |
3125 | 2916 |
3126 FX_BOOL CFX_Edit::Delete(FX_BOOL bAddUndo, FX_BOOL bPaint) | 2917 AddEditUndoItem(new CFXEU_ClearRich(this, |
3127 { | 2918 oldplace, |
3128 if (m_pVT->IsValid()) | 2919 place, |
3129 { | 2920 range, |
3130 if (m_wpCaret == m_pVT->GetEndWordPlace()) return FALSE; | 2921 wordinfo.Word, |
3131 | 2922 wordinfo.nCharset, |
3132 CPVT_Section section; | 2923 secinfo.SecProps, |
3133 CPVT_Word word; | 2924 wordinfo.WordProps)); |
3134 | 2925 } |
3135 if (bAddUndo) | 2926 } |
3136 { | 2927 } while (pIterator->PrevWord()); |
3137 if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetI
terator()) | 2928 } |
3138 { | 2929 EndGroupUndo(); |
3139 pIterator->SetAt(m_pVT->GetNextWordPlace(m_wpCar
et)); | 2930 } else { |
3140 pIterator->GetSection(section); | 2931 AddEditUndoItem(new CFXEU_Clear(this, range, GetSelText())); |
3141 pIterator->GetWord(word); | 2932 } |
3142 } | 2933 } |
3143 } | 2934 |
3144 | 2935 SelectNone(); |
3145 m_pVT->UpdateWordPlace(m_wpCaret); | 2936 SetCaret(m_pVT->DeleteWords(range)); |
3146 FX_BOOL bSecEnd = (m_wpCaret == m_pVT->GetSectionEndPlace(m_wpCa
ret)); | 2937 m_SelState.Set(m_wpCaret, m_wpCaret); |
3147 | 2938 |
3148 SetCaret(m_pVT->DeleteWord(m_wpCaret)); | 2939 if (bPaint) { |
3149 m_SelState.Set(m_wpCaret,m_wpCaret); | 2940 RearrangePart(range); |
3150 | 2941 ScrollToCaret(); |
3151 if (bAddUndo && m_bEnableUndo) | 2942 |
3152 { | 2943 CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRange().EndPos); |
3153 if (bSecEnd) | 2944 Refresh(RP_ANALYSE, &wr); |
3154 AddEditUndoItem(new CFXEU_Delete(this,m_wpOldCar
et,m_wpCaret,word.Word,word.nCharset, | 2945 |
3155 section.SecProps,section.WordProps,bSecE
nd)); | 2946 SetCaretOrigin(); |
3156 else | 2947 SetCaretInfo(); |
3157 AddEditUndoItem(new CFXEU_Delete(this,m_wpOldCar
et,m_wpCaret,word.Word,word.nCharset, | 2948 } |
3158 section.SecProps,word.WordProps,bSecEnd)
); | 2949 |
3159 } | 2950 if (m_bOprNotify && m_pOprNotify) |
3160 | 2951 m_pOprNotify->OnClear(m_wpCaret, m_wpOldCaret); |
3161 if (bPaint) | 2952 |
3162 { | 2953 return TRUE; |
3163 RearrangePart(CPVT_WordRange(m_wpOldCaret,m_wpCaret)); | 2954 } |
3164 ScrollToCaret(); | 2955 } |
3165 | 2956 |
3166 CPVT_WordRange wr; | 2957 return FALSE; |
3167 if (bSecEnd) | 2958 } |
3168 wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wp
OldCaret),GetVisibleWordRange().EndPos); | 2959 |
3169 else if (m_wpCaret.LineCmp(m_wpOldCaret) !=0) | 2960 FX_BOOL CFX_Edit::InsertText(FX_LPCWSTR text, |
3170 wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(m_w
pCaret),m_pVT->GetSectionEndPlace(m_wpCaret)); | 2961 FX_INT32 charset, |
3171 else | 2962 const CPVT_SecProps* pSecProps, |
3172 wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wp
OldCaret),m_pVT->GetSectionEndPlace(m_wpCaret)); | 2963 const CPVT_WordProps* pWordProps, |
3173 | 2964 FX_BOOL bAddUndo, |
3174 Refresh(RP_ANALYSE, &wr); | 2965 FX_BOOL bPaint) { |
3175 | 2966 if (IsTextOverflow()) |
3176 SetCaretOrigin(); | 2967 return FALSE; |
3177 SetCaretInfo(); | 2968 |
3178 } | 2969 m_pVT->UpdateWordPlace(m_wpCaret); |
3179 | 2970 SetCaret(DoInsertText(m_wpCaret, text, charset, pSecProps, pWordProps)); |
3180 if (m_bOprNotify && m_pOprNotify) | 2971 m_SelState.Set(m_wpCaret, m_wpCaret); |
3181 m_pOprNotify->OnDelete(m_wpCaret, m_wpOldCaret); | 2972 |
3182 | 2973 if (m_wpCaret != m_wpOldCaret) { |
3183 return TRUE; | 2974 if (bAddUndo && m_bEnableUndo) { |
3184 } | 2975 AddEditUndoItem(new CFXEU_InsertText( |
3185 | 2976 this, m_wpOldCaret, m_wpCaret, text, charset, pSecProps, pWordProps)); |
3186 return FALSE; | 2977 } |
3187 } | 2978 |
3188 | 2979 if (bPaint) |
3189 FX_BOOL CFX_Edit::Empty() | 2980 PaintInsertText(m_wpOldCaret, m_wpCaret); |
3190 { | 2981 |
3191 if (m_pVT->IsValid()) | 2982 if (m_bOprNotify && m_pOprNotify) |
3192 { | 2983 m_pOprNotify->OnInsertText(m_wpCaret, m_wpOldCaret); |
3193 m_pVT->DeleteWords(GetWholeWordRange()); | 2984 |
3194 SetCaret(m_pVT->GetBeginWordPlace()); | 2985 return TRUE; |
3195 | 2986 } |
3196 return TRUE; | 2987 return FALSE; |
3197 } | 2988 } |
3198 | 2989 |
3199 return FALSE; | 2990 void CFX_Edit::PaintInsertText(const CPVT_WordPlace& wpOld, |
3200 } | 2991 const CPVT_WordPlace& wpNew) { |
3201 | 2992 if (m_pVT->IsValid()) { |
3202 FX_BOOL CFX_Edit::Clear(FX_BOOL bAddUndo, FX_BOOL bPaint) | 2993 RearrangePart(CPVT_WordRange(wpOld, wpNew)); |
3203 { | 2994 ScrollToCaret(); |
3204 if (m_pVT->IsValid()) | 2995 |
3205 { | 2996 CPVT_WordRange wr; |
3206 if (m_SelState.IsExist()) | 2997 if (m_wpCaret.LineCmp(wpOld) != 0) |
3207 { | 2998 wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(wpOld), |
3208 CPVT_WordRange range = m_SelState.ConvertToWordRange(); | 2999 m_pVT->GetSectionEndPlace(wpNew)); |
3209 | 3000 else |
3210 if (bAddUndo && m_bEnableUndo) | 3001 wr = CPVT_WordRange(wpOld, m_pVT->GetSectionEndPlace(wpNew)); |
3211 { | 3002 Refresh(RP_ANALYSE, &wr); |
3212 if (m_pVT->IsRichText()) | 3003 SetCaretOrigin(); |
3213 { | 3004 SetCaretInfo(); |
3214 BeginGroupUndo(L""); | 3005 } |
3215 | 3006 } |
3216 if (IPDF_VariableText_Iterator * pIterat
or = m_pVT->GetIterator()) | 3007 |
3217 { | 3008 FX_BOOL CFX_Edit::Redo() { |
3218 pIterator->SetAt(range.EndPos); | 3009 if (m_bEnableUndo) { |
3219 | 3010 if (m_Undo.CanRedo()) { |
3220 CPVT_Word wordinfo; | 3011 m_Undo.Redo(); |
3221 CPVT_Section secinfo;
| 3012 return TRUE; |
3222 do | 3013 } |
3223 {
| 3014 } |
3224 CPVT_WordPlace place = p
Iterator->GetAt(); | 3015 |
3225 if (place.WordCmp(range.
BeginPos) <= 0)break; | 3016 return FALSE; |
3226 | 3017 } |
3227 CPVT_WordPlace oldplace
= m_pVT->GetPrevWordPlace(place);
| 3018 |
3228 | 3019 FX_BOOL CFX_Edit::Undo() { |
3229 if (oldplace.SecCmp(plac
e) != 0) | 3020 if (m_bEnableUndo) { |
3230 { | 3021 if (m_Undo.CanUndo()) { |
3231 if (pIterator->G
etSection(secinfo)) | 3022 m_Undo.Undo(); |
3232 { | 3023 return TRUE; |
3233 AddEditU
ndoItem(new CFXEU_ClearRich(this,oldplace,place,range,wordinfo.Word, | 3024 } |
3234
wordinfo.nCharset,secinfo.SecProps,secinfo.WordProps)); | 3025 } |
3235 } | 3026 |
3236 } | 3027 return FALSE; |
3237 else | 3028 } |
3238 { | 3029 |
3239 if (pIterator->G
etWord(wordinfo)) | 3030 void CFX_Edit::SetCaretOrigin() { |
3240 {
| 3031 if (m_pVT->IsValid()) { |
3241 oldplace
= m_pVT->AjustLineHeader(oldplace,TRUE); | 3032 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
3242 place =
m_pVT->AjustLineHeader(place,TRUE); | 3033 pIterator->SetAt(m_wpCaret); |
3243 | 3034 CPVT_Word word; |
3244 AddEditU
ndoItem(new CFXEU_ClearRich(this,oldplace,place,range,wordinfo.Word, | 3035 CPVT_Line line; |
3245
wordinfo.nCharset,secinfo.SecProps,wordinfo.WordProps)); | 3036 if (pIterator->GetWord(word)) { |
3246 } | 3037 m_ptCaret.x = word.ptWord.x + word.fWidth; |
3247 } | 3038 m_ptCaret.y = word.ptWord.y; |
3248 }while (pIterator->PrevWord()); | 3039 } else if (pIterator->GetLine(line)) { |
3249 } | 3040 m_ptCaret.x = line.ptLine.x; |
3250 EndGroupUndo(); | 3041 m_ptCaret.y = line.ptLine.y; |
3251 } | 3042 } |
3252 else | 3043 } |
3253 { | 3044 } |
3254 AddEditUndoItem(new CFXEU_Clear(this,ran
ge,GetSelText())); | 3045 } |
3255 } | 3046 |
3256 } | 3047 FX_INT32 CFX_Edit::WordPlaceToWordIndex(const CPVT_WordPlace& place) const { |
3257 | 3048 if (m_pVT->IsValid()) |
3258 SelectNone(); | 3049 return m_pVT->WordPlaceToWordIndex(place); |
3259 SetCaret(m_pVT->DeleteWords(range)); | 3050 |
3260 m_SelState.Set(m_wpCaret,m_wpCaret); | 3051 return -1; |
3261 | 3052 } |
3262 if (bPaint) | 3053 |
3263 { | 3054 CPVT_WordPlace CFX_Edit::WordIndexToWordPlace(FX_INT32 index) const { |
3264 RearrangePart(range); | 3055 if (m_pVT->IsValid()) |
3265 ScrollToCaret(); | 3056 return m_pVT->WordIndexToWordPlace(index); |
3266 | 3057 |
3267 CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRa
nge().EndPos); | 3058 return CPVT_WordPlace(); |
3268 Refresh(RP_ANALYSE, &wr); | 3059 } |
3269 | 3060 |
3270 SetCaretOrigin(); | 3061 FX_BOOL CFX_Edit::IsTextFull() const { |
3271 SetCaretInfo(); | 3062 FX_INT32 nTotalWords = m_pVT->GetTotalWords(); |
3272 } | 3063 FX_INT32 nLimitChar = m_pVT->GetLimitChar(); |
3273 | 3064 FX_INT32 nCharArray = m_pVT->GetCharArray(); |
3274 if (m_bOprNotify && m_pOprNotify) | 3065 |
3275 m_pOprNotify->OnClear(m_wpCaret, m_wpOldCaret); | 3066 return IsTextOverflow() || (nLimitChar > 0 && nTotalWords >= nLimitChar) || |
3276 | 3067 (nCharArray > 0 && nTotalWords >= nCharArray); |
3277 return TRUE; | 3068 } |
3278 } | 3069 |
3279 } | 3070 FX_BOOL CFX_Edit::IsTextOverflow() const { |
3280 | 3071 if (!m_bEnableScroll && !m_bEnableOverflow) { |
3281 return FALSE; | 3072 CPDF_Rect rcPlate = m_pVT->GetPlateRect(); |
3282 } | 3073 CPDF_Rect rcContent = m_pVT->GetContentRect(); |
3283 | 3074 |
3284 FX_BOOL CFX_Edit::InsertText(FX_LPCWSTR text, FX_INT32 charset, | 3075 if (m_pVT->IsMultiLine() && GetTotalLines() > 1) { |
3285 const CPVT_SecProps * pSecProps, const C
PVT_WordProps * pWordProps, FX_BOOL bAddUndo, FX_BOOL bPaint) | 3076 if (FX_EDIT_IsFloatBigger(rcContent.Height(), rcPlate.Height())) |
3286 { | 3077 return TRUE; |
3287 if (IsTextOverflow()) return FALSE; | 3078 } |
3288 | 3079 |
3289 m_pVT->UpdateWordPlace(m_wpCaret); | 3080 if (FX_EDIT_IsFloatBigger(rcContent.Width(), rcPlate.Width())) |
3290 SetCaret(DoInsertText(m_wpCaret, text, charset, pSecProps, pWordProps)); | 3081 return TRUE; |
3291 m_SelState.Set(m_wpCaret,m_wpCaret); | 3082 } |
3292 | 3083 |
3293 if (m_wpCaret != m_wpOldCaret) | 3084 return FALSE; |
3294 { | 3085 } |
3295 if (bAddUndo && m_bEnableUndo) | 3086 |
3296 { | 3087 CPVT_WordPlace CFX_Edit::GetLineBeginPlace(const CPVT_WordPlace& place) const { |
3297 AddEditUndoItem(new CFXEU_InsertText(this,m_wpOldCaret,m
_wpCaret,text,charset,pSecProps,pWordProps)); | 3088 return m_pVT->GetLineBeginPlace(place); |
3298 } | 3089 } |
3299 | 3090 |
3300 if (bPaint) | 3091 CPVT_WordPlace CFX_Edit::GetLineEndPlace(const CPVT_WordPlace& place) const { |
3301 PaintInsertText(m_wpOldCaret, m_wpCaret); | 3092 return m_pVT->GetLineEndPlace(place); |
3302 | 3093 } |
3303 if (m_bOprNotify && m_pOprNotify) | 3094 |
3304 m_pOprNotify->OnInsertText(m_wpCaret, m_wpOldCaret); | 3095 CPVT_WordPlace CFX_Edit::GetSectionBeginPlace( |
3305 | 3096 const CPVT_WordPlace& place) const { |
3306 return TRUE; | 3097 return m_pVT->GetSectionBeginPlace(place); |
3307 } | 3098 } |
3308 return FALSE; | 3099 |
3309 } | 3100 CPVT_WordPlace CFX_Edit::GetSectionEndPlace(const CPVT_WordPlace& place) const { |
3310 | 3101 return m_pVT->GetSectionEndPlace(place); |
3311 void CFX_Edit::PaintInsertText(const CPVT_WordPlace & wpOld, const CPVT_WordPlac
e & wpNew) | 3102 } |
3312 { | 3103 |
3313 if (m_pVT->IsValid()) | 3104 FX_BOOL CFX_Edit::CanUndo() const { |
3314 { | 3105 if (m_bEnableUndo) { |
3315 RearrangePart(CPVT_WordRange(wpOld,wpNew)); | 3106 return m_Undo.CanUndo(); |
3316 ScrollToCaret(); | 3107 } |
3317 | 3108 |
3318 CPVT_WordRange wr; | 3109 return FALSE; |
3319 if (m_wpCaret.LineCmp(wpOld) !=0) | 3110 } |
3320 wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(wpOld),m_pV
T->GetSectionEndPlace(wpNew)); | 3111 |
3321 else | 3112 FX_BOOL CFX_Edit::CanRedo() const { |
3322 wr = CPVT_WordRange(wpOld,m_pVT->GetSectionEndPlace(wpNe
w)); | 3113 if (m_bEnableUndo) { |
3323 Refresh(RP_ANALYSE, &wr); | 3114 return m_Undo.CanRedo(); |
3324 SetCaretOrigin(); | 3115 } |
3325 SetCaretInfo(); | 3116 |
3326 } | 3117 return FALSE; |
3327 } | 3118 } |
3328 | 3119 |
3329 FX_BOOL CFX_Edit::Redo() | 3120 FX_BOOL CFX_Edit::IsModified() const { |
3330 { | 3121 if (m_bEnableUndo) { |
3331 if (m_bEnableUndo) | 3122 return m_Undo.IsModified(); |
3332 { | 3123 } |
3333 if (m_Undo.CanRedo()) | 3124 |
3334 { | 3125 return FALSE; |
3335 m_Undo.Redo(); | 3126 } |
3336 return TRUE; | 3127 |
3337 } | 3128 void CFX_Edit::EnableRefresh(FX_BOOL bRefresh) { |
3338 } | 3129 m_bEnableRefresh = bRefresh; |
3339 | 3130 } |
3340 return FALSE; | 3131 |
3341 } | 3132 void CFX_Edit::EnableUndo(FX_BOOL bUndo) { |
3342 | 3133 this->m_bEnableUndo = bUndo; |
3343 FX_BOOL CFX_Edit::Undo() | 3134 } |
3344 { | 3135 |
3345 if (m_bEnableUndo) | 3136 void CFX_Edit::EnableNotify(FX_BOOL bNotify) { |
3346 { | 3137 this->m_bNotify = bNotify; |
3347 if (m_Undo.CanUndo()) | 3138 } |
3348 { | 3139 |
3349 m_Undo.Undo(); | 3140 void CFX_Edit::EnableOprNotify(FX_BOOL bNotify) { |
3350 return TRUE; | 3141 this->m_bOprNotify = bNotify; |
3351 } | 3142 } |
3352 } | 3143 |
3353 | 3144 FX_FLOAT CFX_Edit::GetLineTop(const CPVT_WordPlace& place) const { |
3354 return FALSE; | 3145 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
3355 } | 3146 CPVT_WordPlace wpOld = pIterator->GetAt(); |
3356 | 3147 |
3357 void CFX_Edit::SetCaretOrigin() | 3148 pIterator->SetAt(place); |
3358 { | 3149 CPVT_Line line; |
3359 if (m_pVT->IsValid()) | 3150 pIterator->GetLine(line); |
3360 { | 3151 |
3361 if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator(
)) | 3152 pIterator->SetAt(wpOld); |
3362 { | 3153 |
3363 pIterator->SetAt(m_wpCaret); | 3154 return line.ptLine.y + line.fLineAscent; |
3364 CPVT_Word word; | 3155 } |
3365 CPVT_Line line; | 3156 |
3366 if (pIterator->GetWord(word)) | 3157 return 0.0f; |
3367 { | 3158 } |
3368 m_ptCaret.x = word.ptWord.x + word.fWidth; | 3159 |
3369 m_ptCaret.y = word.ptWord.y; | 3160 FX_FLOAT CFX_Edit::GetLineBottom(const CPVT_WordPlace& place) const { |
3370 } | 3161 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
3371 else if (pIterator->GetLine(line)) | 3162 CPVT_WordPlace wpOld = pIterator->GetAt(); |
3372 { | 3163 |
3373 m_ptCaret.x = line.ptLine.x; | 3164 pIterator->SetAt(place); |
3374 m_ptCaret.y = line.ptLine.y; | 3165 CPVT_Line line; |
3375 } | 3166 pIterator->GetLine(line); |
3376 } | 3167 |
3377 } | 3168 pIterator->SetAt(wpOld); |
3378 } | 3169 |
3379 | 3170 return line.ptLine.y + line.fLineDescent; |
3380 FX_INT32 CFX_Edit::WordPlaceToWordIndex(const CPVT_WordPlace & place) const | 3171 } |
3381 { | 3172 |
3382 if (m_pVT->IsValid()) | 3173 return 0.0f; |
3383 return m_pVT->WordPlaceToWordIndex(place); | 3174 } |
3384 | 3175 |
3385 return -1; | 3176 CPVT_WordPlace CFX_Edit::DoInsertText(const CPVT_WordPlace& place, |
3386 } | 3177 FX_LPCWSTR text, |
3387 | 3178 FX_INT32 charset, |
3388 CPVT_WordPlace CFX_Edit::WordIndexToWordPlace(FX_INT32 index) const | 3179 const CPVT_SecProps* pSecProps, |
3389 { | 3180 const CPVT_WordProps* pWordProps) { |
3390 if (m_pVT->IsValid()) | 3181 CPVT_WordPlace wp = place; |
3391 return m_pVT->WordIndexToWordPlace(index); | 3182 |
3392 | 3183 if (m_pVT->IsValid()) { |
3393 return CPVT_WordPlace(); | 3184 CFX_WideString sText = text; |
3394 } | 3185 |
3395 | 3186 for (FX_INT32 i = 0, sz = sText.GetLength(); i < sz; i++) { |
3396 FX_BOOL CFX_Edit::IsTextFull() const | 3187 FX_WORD word = sText[i]; |
3397 { | 3188 switch (word) { |
3398 FX_INT32 nTotalWords = m_pVT->GetTotalWords(); | 3189 case 0x0D: |
3399 FX_INT32 nLimitChar = m_pVT->GetLimitChar(); | 3190 wp = m_pVT->InsertSection(wp, pSecProps, pWordProps); |
3400 FX_INT32 nCharArray = m_pVT->GetCharArray(); | 3191 if (sText[i + 1] == 0x0A) |
3401 | 3192 i++; |
3402 return IsTextOverflow() || (nLimitChar>0 && nTotalWords >= nLimitChar) | 3193 break; |
3403 || (nCharArray>0 && nTotalWords >= nCharArray); | 3194 case 0x0A: |
3404 } | 3195 wp = m_pVT->InsertSection(wp, pSecProps, pWordProps); |
3405 | 3196 if (sText[i + 1] == 0x0D) |
3406 FX_BOOL CFX_Edit::IsTextOverflow() const | 3197 i++; |
3407 { | 3198 break; |
3408 if (!m_bEnableScroll && !m_bEnableOverflow) | 3199 case 0x09: |
3409 { | 3200 word = 0x20; |
3410 CPDF_Rect rcPlate = m_pVT->GetPlateRect(); | 3201 default: |
3411 CPDF_Rect rcContent = m_pVT->GetContentRect(); | 3202 wp = m_pVT->InsertWord( |
3412 | 3203 wp, word, GetCharSetFromUnicode(word, charset), pWordProps); |
3413 if (m_pVT->IsMultiLine() && GetTotalLines() > 1) | 3204 break; |
3414 { | 3205 } |
3415 if (FX_EDIT_IsFloatBigger(rcContent.Height(),rcPlate.Hei
ght())) return TRUE; | 3206 } |
3416 } | 3207 } |
3417 | 3208 |
3418 if (FX_EDIT_IsFloatBigger(rcContent.Width(),rcPlate.Width())) re
turn TRUE; | 3209 return wp; |
3419 } | 3210 } |
3420 | 3211 |
3421 return FALSE; | 3212 FX_INT32 CFX_Edit::GetCharSetFromUnicode(FX_WORD word, FX_INT32 nOldCharset) { |
3422 } | 3213 if (IFX_Edit_FontMap* pFontMap = this->GetFontMap()) |
3423 | 3214 return pFontMap->CharSetFromUnicode(word, nOldCharset); |
3424 CPVT_WordPlace CFX_Edit::GetLineBeginPlace(const CPVT_WordPlace & place) const | 3215 else |
3425 { | 3216 return nOldCharset; |
3426 return m_pVT->GetLineBeginPlace(place); | 3217 } |
3427 } | 3218 |
3428 | 3219 void CFX_Edit::BeginGroupUndo(const CFX_WideString& sTitle) { |
3429 CPVT_WordPlace CFX_Edit::GetLineEndPlace(const CPVT_WordPlace & place) const | 3220 ASSERT(m_pGroupUndoItem == NULL); |
3430 { | 3221 |
3431 return m_pVT->GetLineEndPlace(place); | 3222 m_pGroupUndoItem = new CFX_Edit_GroupUndoItem(sTitle); |
3432 } | 3223 } |
3433 | 3224 |
3434 CPVT_WordPlace CFX_Edit::GetSectionBeginPlace(const CPVT_WordPlace & place) cons
t | 3225 void CFX_Edit::EndGroupUndo() { |
3435 { | 3226 ASSERT(m_pGroupUndoItem != NULL); |
3436 return m_pVT->GetSectionBeginPlace(place); | 3227 |
3437 } | 3228 m_pGroupUndoItem->UpdateItems(); |
3438 | 3229 m_Undo.AddItem(m_pGroupUndoItem); |
3439 CPVT_WordPlace CFX_Edit::GetSectionEndPlace(const CPVT_WordPlace & place) const | 3230 if (m_bOprNotify && m_pOprNotify) |
3440 { | 3231 m_pOprNotify->OnAddUndo(m_pGroupUndoItem); |
3441 return m_pVT->GetSectionEndPlace(place); | 3232 m_pGroupUndoItem = NULL; |
3442 } | 3233 } |
3443 | 3234 |
3444 FX_BOOL CFX_Edit::CanUndo() const | 3235 void CFX_Edit::AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem) { |
3445 { | 3236 if (m_pGroupUndoItem) |
3446 if (m_bEnableUndo) | 3237 m_pGroupUndoItem->AddUndoItem(pEditUndoItem); |
3447 { | 3238 else { |
3448 return m_Undo.CanUndo(); | 3239 m_Undo.AddItem(pEditUndoItem); |
3449 } | 3240 if (m_bOprNotify && m_pOprNotify) |
3450 | 3241 m_pOprNotify->OnAddUndo(pEditUndoItem); |
3451 return FALSE; | 3242 } |
3452 } | 3243 } |
3453 | 3244 |
3454 FX_BOOL CFX_Edit::CanRedo() const | 3245 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) { |
3455 { | 3246 m_Undo.AddItem(pUndoItem); |
3456 if (m_bEnableUndo) | 3247 if (m_bOprNotify && m_pOprNotify) |
3457 { | 3248 m_pOprNotify->OnAddUndo(pUndoItem); |
3458 return m_Undo.CanRedo(); | 3249 } |
3459 } | |
3460 | |
3461 return FALSE; | |
3462 } | |
3463 | |
3464 FX_BOOL CFX_Edit::IsModified() const | |
3465 { | |
3466 if (m_bEnableUndo) | |
3467 { | |
3468 return m_Undo.IsModified(); | |
3469 } | |
3470 | |
3471 return FALSE; | |
3472 } | |
3473 | |
3474 void CFX_Edit::EnableRefresh(FX_BOOL bRefresh) | |
3475 { | |
3476 m_bEnableRefresh = bRefresh; | |
3477 } | |
3478 | |
3479 void CFX_Edit::EnableUndo(FX_BOOL bUndo) | |
3480 { | |
3481 this->m_bEnableUndo = bUndo; | |
3482 } | |
3483 | |
3484 void CFX_Edit::EnableNotify(FX_BOOL bNotify) | |
3485 { | |
3486 this->m_bNotify = bNotify; | |
3487 } | |
3488 | |
3489 void CFX_Edit::EnableOprNotify(FX_BOOL bNotify) | |
3490 { | |
3491 this->m_bOprNotify = bNotify; | |
3492 } | |
3493 | |
3494 FX_FLOAT CFX_Edit::GetLineTop(const CPVT_WordPlace& place) const | |
3495 { | |
3496 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) | |
3497 { | |
3498 CPVT_WordPlace wpOld = pIterator->GetAt(); | |
3499 | |
3500 pIterator->SetAt(place); | |
3501 CPVT_Line line; | |
3502 pIterator->GetLine(line); | |
3503 | |
3504 pIterator->SetAt(wpOld); | |
3505 | |
3506 return line.ptLine.y + line.fLineAscent; | |
3507 } | |
3508 | |
3509 return 0.0f; | |
3510 } | |
3511 | |
3512 FX_FLOAT CFX_Edit::GetLineBottom(const CPVT_WordPlace& place) const | |
3513 { | |
3514 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) | |
3515 { | |
3516 CPVT_WordPlace wpOld = pIterator->GetAt(); | |
3517 | |
3518 pIterator->SetAt(place); | |
3519 CPVT_Line line; | |
3520 pIterator->GetLine(line); | |
3521 | |
3522 pIterator->SetAt(wpOld); | |
3523 | |
3524 return line.ptLine.y + line.fLineDescent; | |
3525 } | |
3526 | |
3527 return 0.0f; | |
3528 } | |
3529 | |
3530 CPVT_WordPlace CFX_Edit::DoInsertText(const CPVT_WordPlace& place, FX_LPCWSTR te
xt, FX_INT32 charset, | |
3531 const
CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps) | |
3532 { | |
3533 CPVT_WordPlace wp = place; | |
3534 | |
3535 if (m_pVT->IsValid()) | |
3536 { | |
3537 CFX_WideString sText = text; | |
3538 | |
3539 for (FX_INT32 i = 0, sz = sText.GetLength(); i < sz; i++) | |
3540 { | |
3541 FX_WORD word = sText[i]; | |
3542 switch (word) | |
3543 { | |
3544 case 0x0D: | |
3545 wp = m_pVT->InsertSection(wp,pSecProps,pWordProp
s); | |
3546 if (sText[i+1] == 0x0A) | |
3547 i++; | |
3548 break; | |
3549 case 0x0A: | |
3550 wp = m_pVT->InsertSection(wp,pSecProps,pWordProp
s); | |
3551 if (sText[i+1] == 0x0D) | |
3552 i++; | |
3553 break; | |
3554 case 0x09: | |
3555 word = 0x20; | |
3556 default: | |
3557 wp = m_pVT->InsertWord(wp,word,GetCharSetFromUni
code(word, charset),pWordProps); | |
3558 break; | |
3559 } | |
3560 } | |
3561 } | |
3562 | |
3563 return wp; | |
3564 } | |
3565 | |
3566 FX_INT32 CFX_Edit::GetCharSetFromUnicode(FX_WORD word, FX_INT32 nOldCharset) | |
3567 { | |
3568 if (IFX_Edit_FontMap* pFontMap = this->GetFontMap()) | |
3569 return pFontMap->CharSetFromUnicode(word, nOldCharset); | |
3570 else | |
3571 return nOldCharset; | |
3572 } | |
3573 | |
3574 void CFX_Edit::BeginGroupUndo(const CFX_WideString& sTitle) | |
3575 { | |
3576 ASSERT(m_pGroupUndoItem == NULL); | |
3577 | |
3578 m_pGroupUndoItem = new CFX_Edit_GroupUndoItem(sTitle); | |
3579 } | |
3580 | |
3581 void CFX_Edit::EndGroupUndo() | |
3582 { | |
3583 ASSERT(m_pGroupUndoItem != NULL); | |
3584 | |
3585 m_pGroupUndoItem->UpdateItems(); | |
3586 m_Undo.AddItem(m_pGroupUndoItem); | |
3587 if (m_bOprNotify && m_pOprNotify) | |
3588 m_pOprNotify->OnAddUndo(m_pGroupUndoItem); | |
3589 m_pGroupUndoItem = NULL; | |
3590 } | |
3591 | |
3592 void CFX_Edit::AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem) | |
3593 { | |
3594 if (m_pGroupUndoItem) | |
3595 m_pGroupUndoItem->AddUndoItem(pEditUndoItem); | |
3596 else | |
3597 { | |
3598 m_Undo.AddItem(pEditUndoItem); | |
3599 if (m_bOprNotify && m_pOprNotify) | |
3600 m_pOprNotify->OnAddUndo(pEditUndoItem); | |
3601 } | |
3602 } | |
3603 | |
3604 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) | |
3605 { | |
3606 m_Undo.AddItem(pUndoItem); | |
3607 if (m_bOprNotify && m_pOprNotify) | |
3608 m_pOprNotify->OnAddUndo(pUndoItem); | |
3609 } | |
3610 | |
OLD | NEW |