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 "fpdfsdk/include/fxedit/fxet_edit.h" | 7 #include "fpdfsdk/include/fxedit/fxet_edit.h" |
8 #include "fpdfsdk/include/fxedit/fxet_stub.h" | 8 |
| 9 #include "core/include/fpdfapi/fpdf_resource.h" |
9 | 10 |
10 #define FX_EDIT_UNDO_MAXITEM 10000 | 11 #define FX_EDIT_UNDO_MAXITEM 10000 |
11 | 12 |
12 /* ---------------------------- CFX_Edit_Iterator ---------------------------- | |
13 */ | |
14 | |
15 CFX_Edit_Iterator::CFX_Edit_Iterator(CFX_Edit* pEdit, | 13 CFX_Edit_Iterator::CFX_Edit_Iterator(CFX_Edit* pEdit, |
16 IPDF_VariableText_Iterator* pVTIterator) | 14 IPDF_VariableText_Iterator* pVTIterator) |
17 : m_pEdit(pEdit), m_pVTIterator(pVTIterator) {} | 15 : m_pEdit(pEdit), m_pVTIterator(pVTIterator) {} |
18 | 16 |
19 CFX_Edit_Iterator::~CFX_Edit_Iterator() {} | 17 CFX_Edit_Iterator::~CFX_Edit_Iterator() {} |
20 | 18 |
21 FX_BOOL CFX_Edit_Iterator::NextWord() { | 19 FX_BOOL CFX_Edit_Iterator::NextWord() { |
22 return m_pVTIterator->NextWord(); | 20 return m_pVTIterator->NextWord(); |
23 } | 21 } |
24 | 22 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 79 } |
82 | 80 |
83 const CPVT_WordPlace& CFX_Edit_Iterator::GetAt() const { | 81 const CPVT_WordPlace& CFX_Edit_Iterator::GetAt() const { |
84 return m_pVTIterator->GetAt(); | 82 return m_pVTIterator->GetAt(); |
85 } | 83 } |
86 | 84 |
87 IFX_Edit* CFX_Edit_Iterator::GetEdit() const { | 85 IFX_Edit* CFX_Edit_Iterator::GetEdit() const { |
88 return m_pEdit; | 86 return m_pEdit; |
89 } | 87 } |
90 | 88 |
91 /* --------------------------- CFX_Edit_Provider ------------------------------- | |
92 */ | |
93 | |
94 CFX_Edit_Provider::CFX_Edit_Provider(IFX_Edit_FontMap* pFontMap) | 89 CFX_Edit_Provider::CFX_Edit_Provider(IFX_Edit_FontMap* pFontMap) |
95 : m_pFontMap(pFontMap) { | 90 : m_pFontMap(pFontMap) { |
96 ASSERT(m_pFontMap); | 91 ASSERT(m_pFontMap); |
97 } | 92 } |
98 | 93 |
99 CFX_Edit_Provider::~CFX_Edit_Provider() {} | 94 CFX_Edit_Provider::~CFX_Edit_Provider() {} |
100 | 95 |
101 IFX_Edit_FontMap* CFX_Edit_Provider::GetFontMap() { | 96 IFX_Edit_FontMap* CFX_Edit_Provider::GetFontMap() { |
102 return m_pFontMap; | 97 return m_pFontMap; |
103 } | 98 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 } | 136 } |
142 | 137 |
143 int32_t CFX_Edit_Provider::GetDefaultFontIndex() { | 138 int32_t CFX_Edit_Provider::GetDefaultFontIndex() { |
144 return 0; | 139 return 0; |
145 } | 140 } |
146 | 141 |
147 FX_BOOL CFX_Edit_Provider::IsLatinWord(FX_WORD word) { | 142 FX_BOOL CFX_Edit_Provider::IsLatinWord(FX_WORD word) { |
148 return FX_EDIT_ISLATINWORD(word); | 143 return FX_EDIT_ISLATINWORD(word); |
149 } | 144 } |
150 | 145 |
151 /* --------------------------------- CFX_Edit_Refresh | |
152 * --------------------------------- */ | |
153 | |
154 CFX_Edit_Refresh::CFX_Edit_Refresh() {} | 146 CFX_Edit_Refresh::CFX_Edit_Refresh() {} |
155 | 147 |
156 CFX_Edit_Refresh::~CFX_Edit_Refresh() {} | 148 CFX_Edit_Refresh::~CFX_Edit_Refresh() {} |
157 | 149 |
158 void CFX_Edit_Refresh::BeginRefresh() { | 150 void CFX_Edit_Refresh::BeginRefresh() { |
159 m_RefreshRects.Empty(); | 151 m_RefreshRects.Empty(); |
160 m_OldLineRects = m_NewLineRects; | 152 m_OldLineRects = m_NewLineRects; |
161 } | 153 } |
162 | 154 |
163 void CFX_Edit_Refresh::Push(const CPVT_WordRange& linerange, | 155 void CFX_Edit_Refresh::Push(const CPVT_WordRange& linerange, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 rcResult.Union(pNewRect->m_rcLine); | 204 rcResult.Union(pNewRect->m_rcLine); |
213 m_RefreshRects.Add(rcResult); | 205 m_RefreshRects.Add(rcResult); |
214 } else { | 206 } else { |
215 if (!pNewRect->IsSameLeft(*pOldRect)) { | 207 if (!pNewRect->IsSameLeft(*pOldRect)) { |
216 rcResult = pOldRect->m_rcLine; | 208 rcResult = pOldRect->m_rcLine; |
217 rcResult.Union(pNewRect->m_rcLine); | 209 rcResult.Union(pNewRect->m_rcLine); |
218 } else { | 210 } else { |
219 fWidthDiff = | 211 fWidthDiff = |
220 pNewRect->m_rcLine.Width() - pOldRect->m_rcLine.Width(); | 212 pNewRect->m_rcLine.Width() - pOldRect->m_rcLine.Width(); |
221 rcResult = pNewRect->m_rcLine; | 213 rcResult = pNewRect->m_rcLine; |
222 if (fWidthDiff > 0.0f) | 214 if (fWidthDiff > 0.0f) { |
223 rcResult.left = rcResult.right - fWidthDiff; | 215 rcResult.left = rcResult.right - fWidthDiff; |
224 else { | 216 } else { |
225 rcResult.left = rcResult.right; | 217 rcResult.left = rcResult.right; |
226 rcResult.right += (-fWidthDiff); | 218 rcResult.right += (-fWidthDiff); |
227 } | 219 } |
228 } | 220 } |
229 m_RefreshRects.Add(rcResult); | 221 m_RefreshRects.Add(rcResult); |
230 } | 222 } |
231 } else { | 223 } else { |
232 rcResult = pOldRect->m_rcLine; | 224 rcResult = pOldRect->m_rcLine; |
233 rcResult.Union(pNewRect->m_rcLine); | 225 rcResult.Union(pNewRect->m_rcLine); |
234 m_RefreshRects.Add(rcResult); | 226 m_RefreshRects.Add(rcResult); |
235 } | 227 } |
236 } else { | |
237 // don't need to do anything | |
238 } | 228 } |
239 } | 229 } |
240 } else { | 230 } else { |
241 m_RefreshRects.Add(pOldRect->m_rcLine); | 231 m_RefreshRects.Add(pOldRect->m_rcLine); |
242 } | 232 } |
243 } else { | 233 } else { |
244 if (pNewRect) { | 234 if (pNewRect) { |
245 m_RefreshRects.Add(pNewRect->m_rcLine); | 235 m_RefreshRects.Add(pNewRect->m_rcLine); |
246 } else { | |
247 // error | |
248 } | 236 } |
249 } | 237 } |
250 i++; | 238 i++; |
251 } | 239 } |
252 } | 240 } |
253 | 241 |
254 void CFX_Edit_Refresh::AddRefresh(const CPDF_Rect& rect) { | 242 void CFX_Edit_Refresh::AddRefresh(const CPDF_Rect& rect) { |
255 m_RefreshRects.Add(rect); | 243 m_RefreshRects.Add(rect); |
256 } | 244 } |
257 | 245 |
258 const CFX_Edit_RectArray* CFX_Edit_Refresh::GetRefreshRects() const { | 246 const CFX_Edit_RectArray* CFX_Edit_Refresh::GetRefreshRects() const { |
259 return &m_RefreshRects; | 247 return &m_RefreshRects; |
260 } | 248 } |
261 | 249 |
262 void CFX_Edit_Refresh::EndRefresh() { | 250 void CFX_Edit_Refresh::EndRefresh() { |
263 m_RefreshRects.Empty(); | 251 m_RefreshRects.Empty(); |
264 } | 252 } |
265 | 253 |
266 /* ------------------------------------- CFX_Edit_Undo | |
267 * ------------------------------------- */ | |
268 | |
269 CFX_Edit_Undo::CFX_Edit_Undo(int32_t nBufsize) | 254 CFX_Edit_Undo::CFX_Edit_Undo(int32_t nBufsize) |
270 : m_nCurUndoPos(0), | 255 : m_nCurUndoPos(0), |
271 m_nBufSize(nBufsize), | 256 m_nBufSize(nBufsize), |
272 m_bModified(FALSE), | 257 m_bModified(FALSE), |
273 m_bVirgin(TRUE), | 258 m_bVirgin(TRUE), |
274 m_bWorking(FALSE) {} | 259 m_bWorking(FALSE) {} |
275 | 260 |
276 CFX_Edit_Undo::~CFX_Edit_Undo() { | 261 CFX_Edit_Undo::~CFX_Edit_Undo() { |
277 Reset(); | 262 Reset(); |
278 } | 263 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 } | 349 } |
365 | 350 |
366 void CFX_Edit_Undo::Reset() { | 351 void CFX_Edit_Undo::Reset() { |
367 for (int32_t i = 0, sz = m_UndoItemStack.GetSize(); i < sz; i++) { | 352 for (int32_t i = 0, sz = m_UndoItemStack.GetSize(); i < sz; i++) { |
368 delete m_UndoItemStack.GetAt(i); | 353 delete m_UndoItemStack.GetAt(i); |
369 } | 354 } |
370 m_nCurUndoPos = 0; | 355 m_nCurUndoPos = 0; |
371 m_UndoItemStack.RemoveAll(); | 356 m_UndoItemStack.RemoveAll(); |
372 } | 357 } |
373 | 358 |
374 /* -------------------------------- CFX_Edit_GroupUndoItem | |
375 * -------------------------------- */ | |
376 | |
377 CFX_Edit_GroupUndoItem::CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle) | 359 CFX_Edit_GroupUndoItem::CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle) |
378 : m_sTitle(sTitle) {} | 360 : m_sTitle(sTitle) {} |
379 | 361 |
380 CFX_Edit_GroupUndoItem::~CFX_Edit_GroupUndoItem() { | 362 CFX_Edit_GroupUndoItem::~CFX_Edit_GroupUndoItem() { |
381 for (int i = 0, sz = m_Items.GetSize(); i < sz; i++) { | 363 for (int i = 0, sz = m_Items.GetSize(); i < sz; i++) { |
382 delete m_Items[i]; | 364 delete m_Items[i]; |
383 } | 365 } |
384 | 366 |
385 m_Items.RemoveAll(); | 367 m_Items.RemoveAll(); |
386 } | 368 } |
(...skipping 29 matching lines...) Expand all Loading... |
416 for (int i = 0, sz = m_Items.GetSize(); i < sz; i++) { | 398 for (int i = 0, sz = m_Items.GetSize(); i < sz; i++) { |
417 CFX_Edit_UndoItem* pUndoItem = m_Items[i]; | 399 CFX_Edit_UndoItem* pUndoItem = m_Items[i]; |
418 pUndoItem->Redo(); | 400 pUndoItem->Redo(); |
419 } | 401 } |
420 } | 402 } |
421 | 403 |
422 CFX_WideString CFX_Edit_GroupUndoItem::GetUndoTitle() { | 404 CFX_WideString CFX_Edit_GroupUndoItem::GetUndoTitle() { |
423 return m_sTitle; | 405 return m_sTitle; |
424 } | 406 } |
425 | 407 |
426 /* ------------------------------------- CFX_Edit_UndoItem derived classes | |
427 * ------------------------------------- */ | |
428 | |
429 CFXEU_InsertWord::CFXEU_InsertWord(CFX_Edit* pEdit, | 408 CFXEU_InsertWord::CFXEU_InsertWord(CFX_Edit* pEdit, |
430 const CPVT_WordPlace& wpOldPlace, | 409 const CPVT_WordPlace& wpOldPlace, |
431 const CPVT_WordPlace& wpNewPlace, | 410 const CPVT_WordPlace& wpNewPlace, |
432 FX_WORD word, | 411 FX_WORD word, |
433 int32_t charset, | 412 int32_t charset, |
434 const CPVT_WordProps* pWordProps) | 413 const CPVT_WordProps* pWordProps) |
435 : m_pEdit(pEdit), | 414 : m_pEdit(pEdit), |
436 m_wpOld(wpOldPlace), | 415 m_wpOld(wpOldPlace), |
437 m_wpNew(wpNewPlace), | 416 m_wpNew(wpNewPlace), |
438 m_Word(word), | 417 m_Word(word), |
(...skipping 14 matching lines...) Expand all Loading... |
453 } | 432 } |
454 | 433 |
455 void CFXEU_InsertWord::Undo() { | 434 void CFXEU_InsertWord::Undo() { |
456 if (m_pEdit) { | 435 if (m_pEdit) { |
457 m_pEdit->SelectNone(); | 436 m_pEdit->SelectNone(); |
458 m_pEdit->SetCaret(m_wpNew); | 437 m_pEdit->SetCaret(m_wpNew); |
459 m_pEdit->Backspace(FALSE, TRUE); | 438 m_pEdit->Backspace(FALSE, TRUE); |
460 } | 439 } |
461 } | 440 } |
462 | 441 |
463 /* -------------------------------------------------------------------------- */ | |
464 | |
465 CFXEU_InsertReturn::CFXEU_InsertReturn(CFX_Edit* pEdit, | 442 CFXEU_InsertReturn::CFXEU_InsertReturn(CFX_Edit* pEdit, |
466 const CPVT_WordPlace& wpOldPlace, | 443 const CPVT_WordPlace& wpOldPlace, |
467 const CPVT_WordPlace& wpNewPlace, | 444 const CPVT_WordPlace& wpNewPlace, |
468 const CPVT_SecProps* pSecProps, | 445 const CPVT_SecProps* pSecProps, |
469 const CPVT_WordProps* pWordProps) | 446 const CPVT_WordProps* pWordProps) |
470 : m_pEdit(pEdit), | 447 : m_pEdit(pEdit), |
471 m_wpOld(wpOldPlace), | 448 m_wpOld(wpOldPlace), |
472 m_wpNew(wpNewPlace), | 449 m_wpNew(wpNewPlace), |
473 m_SecProps(), | 450 m_SecProps(), |
474 m_WordProps() { | 451 m_WordProps() { |
(...skipping 14 matching lines...) Expand all Loading... |
489 } | 466 } |
490 | 467 |
491 void CFXEU_InsertReturn::Undo() { | 468 void CFXEU_InsertReturn::Undo() { |
492 if (m_pEdit) { | 469 if (m_pEdit) { |
493 m_pEdit->SelectNone(); | 470 m_pEdit->SelectNone(); |
494 m_pEdit->SetCaret(m_wpNew); | 471 m_pEdit->SetCaret(m_wpNew); |
495 m_pEdit->Backspace(FALSE, TRUE); | 472 m_pEdit->Backspace(FALSE, TRUE); |
496 } | 473 } |
497 } | 474 } |
498 | 475 |
499 /* -------------------------------------------------------------------------- */ | |
500 // CFXEU_Backspace | |
501 | |
502 CFXEU_Backspace::CFXEU_Backspace(CFX_Edit* pEdit, | 476 CFXEU_Backspace::CFXEU_Backspace(CFX_Edit* pEdit, |
503 const CPVT_WordPlace& wpOldPlace, | 477 const CPVT_WordPlace& wpOldPlace, |
504 const CPVT_WordPlace& wpNewPlace, | 478 const CPVT_WordPlace& wpNewPlace, |
505 FX_WORD word, | 479 FX_WORD word, |
506 int32_t charset, | 480 int32_t charset, |
507 const CPVT_SecProps& SecProps, | 481 const CPVT_SecProps& SecProps, |
508 const CPVT_WordProps& WordProps) | 482 const CPVT_WordProps& WordProps) |
509 : m_pEdit(pEdit), | 483 : m_pEdit(pEdit), |
510 m_wpOld(wpOldPlace), | 484 m_wpOld(wpOldPlace), |
511 m_wpNew(wpNewPlace), | 485 m_wpNew(wpNewPlace), |
(...skipping 17 matching lines...) Expand all Loading... |
529 m_pEdit->SelectNone(); | 503 m_pEdit->SelectNone(); |
530 m_pEdit->SetCaret(m_wpNew); | 504 m_pEdit->SetCaret(m_wpNew); |
531 if (m_wpNew.SecCmp(m_wpOld) != 0) { | 505 if (m_wpNew.SecCmp(m_wpOld) != 0) { |
532 m_pEdit->InsertReturn(&m_SecProps, &m_WordProps, FALSE, TRUE); | 506 m_pEdit->InsertReturn(&m_SecProps, &m_WordProps, FALSE, TRUE); |
533 } else { | 507 } else { |
534 m_pEdit->InsertWord(m_Word, m_nCharset, &m_WordProps, FALSE, TRUE); | 508 m_pEdit->InsertWord(m_Word, m_nCharset, &m_WordProps, FALSE, TRUE); |
535 } | 509 } |
536 } | 510 } |
537 } | 511 } |
538 | 512 |
539 /* -------------------------------------------------------------------------- */ | |
540 // CFXEU_Delete | |
541 | |
542 CFXEU_Delete::CFXEU_Delete(CFX_Edit* pEdit, | 513 CFXEU_Delete::CFXEU_Delete(CFX_Edit* pEdit, |
543 const CPVT_WordPlace& wpOldPlace, | 514 const CPVT_WordPlace& wpOldPlace, |
544 const CPVT_WordPlace& wpNewPlace, | 515 const CPVT_WordPlace& wpNewPlace, |
545 FX_WORD word, | 516 FX_WORD word, |
546 int32_t charset, | 517 int32_t charset, |
547 const CPVT_SecProps& SecProps, | 518 const CPVT_SecProps& SecProps, |
548 const CPVT_WordProps& WordProps, | 519 const CPVT_WordProps& WordProps, |
549 FX_BOOL bSecEnd) | 520 FX_BOOL bSecEnd) |
550 : m_pEdit(pEdit), | 521 : m_pEdit(pEdit), |
551 m_wpOld(wpOldPlace), | 522 m_wpOld(wpOldPlace), |
(...skipping 19 matching lines...) Expand all Loading... |
571 m_pEdit->SelectNone(); | 542 m_pEdit->SelectNone(); |
572 m_pEdit->SetCaret(m_wpNew); | 543 m_pEdit->SetCaret(m_wpNew); |
573 if (m_bSecEnd) { | 544 if (m_bSecEnd) { |
574 m_pEdit->InsertReturn(&m_SecProps, &m_WordProps, FALSE, TRUE); | 545 m_pEdit->InsertReturn(&m_SecProps, &m_WordProps, FALSE, TRUE); |
575 } else { | 546 } else { |
576 m_pEdit->InsertWord(m_Word, m_nCharset, &m_WordProps, FALSE, TRUE); | 547 m_pEdit->InsertWord(m_Word, m_nCharset, &m_WordProps, FALSE, TRUE); |
577 } | 548 } |
578 } | 549 } |
579 } | 550 } |
580 | 551 |
581 /* -------------------------------------------------------------------------- */ | |
582 // CFXEU_Clear | |
583 | |
584 CFXEU_Clear::CFXEU_Clear(CFX_Edit* pEdit, | 552 CFXEU_Clear::CFXEU_Clear(CFX_Edit* pEdit, |
585 const CPVT_WordRange& wrSel, | 553 const CPVT_WordRange& wrSel, |
586 const CFX_WideString& swText) | 554 const CFX_WideString& swText) |
587 : m_pEdit(pEdit), m_wrSel(wrSel), m_swText(swText) {} | 555 : m_pEdit(pEdit), m_wrSel(wrSel), m_swText(swText) {} |
588 | 556 |
589 CFXEU_Clear::~CFXEU_Clear() {} | 557 CFXEU_Clear::~CFXEU_Clear() {} |
590 | 558 |
591 void CFXEU_Clear::Redo() { | 559 void CFXEU_Clear::Redo() { |
592 if (m_pEdit) { | 560 if (m_pEdit) { |
593 m_pEdit->SelectNone(); | 561 m_pEdit->SelectNone(); |
594 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); | 562 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); |
595 m_pEdit->Clear(FALSE, TRUE); | 563 m_pEdit->Clear(FALSE, TRUE); |
596 } | 564 } |
597 } | 565 } |
598 | 566 |
599 void CFXEU_Clear::Undo() { | 567 void CFXEU_Clear::Undo() { |
600 if (m_pEdit) { | 568 if (m_pEdit) { |
601 m_pEdit->SelectNone(); | 569 m_pEdit->SelectNone(); |
602 m_pEdit->SetCaret(m_wrSel.BeginPos); | 570 m_pEdit->SetCaret(m_wrSel.BeginPos); |
603 m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, NULL, NULL, FALSE, | 571 m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, NULL, NULL, FALSE, |
604 TRUE); | 572 TRUE); |
605 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); | 573 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); |
606 } | 574 } |
607 } | 575 } |
608 | 576 |
609 /* -------------------------------------------------------------------------- */ | |
610 // CFXEU_ClearRich | |
611 | |
612 CFXEU_ClearRich::CFXEU_ClearRich(CFX_Edit* pEdit, | 577 CFXEU_ClearRich::CFXEU_ClearRich(CFX_Edit* pEdit, |
613 const CPVT_WordPlace& wpOldPlace, | 578 const CPVT_WordPlace& wpOldPlace, |
614 const CPVT_WordPlace& wpNewPlace, | 579 const CPVT_WordPlace& wpNewPlace, |
615 const CPVT_WordRange& wrSel, | 580 const CPVT_WordRange& wrSel, |
616 FX_WORD word, | 581 FX_WORD word, |
617 int32_t charset, | 582 int32_t charset, |
618 const CPVT_SecProps& SecProps, | 583 const CPVT_SecProps& SecProps, |
619 const CPVT_WordProps& WordProps) | 584 const CPVT_WordProps& WordProps) |
620 : m_pEdit(pEdit), | 585 : m_pEdit(pEdit), |
621 m_wpOld(wpOldPlace), | 586 m_wpOld(wpOldPlace), |
(...skipping 23 matching lines...) Expand all Loading... |
645 } else { | 610 } else { |
646 m_pEdit->InsertWord(m_Word, m_nCharset, &m_WordProps, FALSE, FALSE); | 611 m_pEdit->InsertWord(m_Word, m_nCharset, &m_WordProps, FALSE, FALSE); |
647 } | 612 } |
648 | 613 |
649 if (IsFirst()) { | 614 if (IsFirst()) { |
650 m_pEdit->PaintInsertText(m_wrSel.BeginPos, m_wrSel.EndPos); | 615 m_pEdit->PaintInsertText(m_wrSel.BeginPos, m_wrSel.EndPos); |
651 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); | 616 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); |
652 } | 617 } |
653 } | 618 } |
654 } | 619 } |
655 /* -------------------------------------------------------------------------- */ | |
656 // CFXEU_InsertText | |
657 | |
658 CFXEU_InsertText::CFXEU_InsertText(CFX_Edit* pEdit, | 620 CFXEU_InsertText::CFXEU_InsertText(CFX_Edit* pEdit, |
659 const CPVT_WordPlace& wpOldPlace, | 621 const CPVT_WordPlace& wpOldPlace, |
660 const CPVT_WordPlace& wpNewPlace, | 622 const CPVT_WordPlace& wpNewPlace, |
661 const CFX_WideString& swText, | 623 const CFX_WideString& swText, |
662 int32_t charset, | 624 int32_t charset, |
663 const CPVT_SecProps* pSecProps, | 625 const CPVT_SecProps* pSecProps, |
664 const CPVT_WordProps* pWordProps) | 626 const CPVT_WordProps* pWordProps) |
665 : m_pEdit(pEdit), | 627 : m_pEdit(pEdit), |
666 m_wpOld(wpOldPlace), | 628 m_wpOld(wpOldPlace), |
667 m_wpNew(wpNewPlace), | 629 m_wpNew(wpNewPlace), |
(...skipping 19 matching lines...) Expand all Loading... |
687 } | 649 } |
688 | 650 |
689 void CFXEU_InsertText::Undo() { | 651 void CFXEU_InsertText::Undo() { |
690 if (m_pEdit) { | 652 if (m_pEdit) { |
691 m_pEdit->SelectNone(); | 653 m_pEdit->SelectNone(); |
692 m_pEdit->SetSel(m_wpOld, m_wpNew); | 654 m_pEdit->SetSel(m_wpOld, m_wpNew); |
693 m_pEdit->Clear(FALSE, TRUE); | 655 m_pEdit->Clear(FALSE, TRUE); |
694 } | 656 } |
695 } | 657 } |
696 | 658 |
697 /* -------------------------------------------------------------------------- */ | |
698 | |
699 CFXEU_SetSecProps::CFXEU_SetSecProps(CFX_Edit* pEdit, | 659 CFXEU_SetSecProps::CFXEU_SetSecProps(CFX_Edit* pEdit, |
700 const CPVT_WordPlace& place, | 660 const CPVT_WordPlace& place, |
701 EDIT_PROPS_E ep, | 661 EDIT_PROPS_E ep, |
702 const CPVT_SecProps& oldsecprops, | 662 const CPVT_SecProps& oldsecprops, |
703 const CPVT_WordProps& oldwordprops, | 663 const CPVT_WordProps& oldwordprops, |
704 const CPVT_SecProps& newsecprops, | 664 const CPVT_SecProps& newsecprops, |
705 const CPVT_WordProps& newwordprops, | 665 const CPVT_WordProps& newwordprops, |
706 const CPVT_WordRange& range) | 666 const CPVT_WordRange& range) |
707 : m_pEdit(pEdit), | 667 : m_pEdit(pEdit), |
708 m_wpPlace(place), | 668 m_wpPlace(place), |
(...skipping 23 matching lines...) Expand all Loading... |
732 m_pEdit->SetSecProps(m_eProps, m_wpPlace, &m_OldSecProps, &m_OldWordProps, | 692 m_pEdit->SetSecProps(m_eProps, m_wpPlace, &m_OldSecProps, &m_OldWordProps, |
733 m_wrPlace, FALSE); | 693 m_wrPlace, FALSE); |
734 if (IsFirst()) { | 694 if (IsFirst()) { |
735 m_pEdit->SelectNone(); | 695 m_pEdit->SelectNone(); |
736 m_pEdit->PaintSetProps(m_eProps, m_wrPlace); | 696 m_pEdit->PaintSetProps(m_eProps, m_wrPlace); |
737 m_pEdit->SetSel(m_wrPlace.BeginPos, m_wrPlace.EndPos); | 697 m_pEdit->SetSel(m_wrPlace.BeginPos, m_wrPlace.EndPos); |
738 } | 698 } |
739 } | 699 } |
740 } | 700 } |
741 | 701 |
742 /* -------------------------------------------------------------------------- */ | |
743 | |
744 CFXEU_SetWordProps::CFXEU_SetWordProps(CFX_Edit* pEdit, | 702 CFXEU_SetWordProps::CFXEU_SetWordProps(CFX_Edit* pEdit, |
745 const CPVT_WordPlace& place, | 703 const CPVT_WordPlace& place, |
746 EDIT_PROPS_E ep, | 704 EDIT_PROPS_E ep, |
747 const CPVT_WordProps& oldprops, | 705 const CPVT_WordProps& oldprops, |
748 const CPVT_WordProps& newprops, | 706 const CPVT_WordProps& newprops, |
749 const CPVT_WordRange& range) | 707 const CPVT_WordRange& range) |
750 : m_pEdit(pEdit), | 708 : m_pEdit(pEdit), |
751 m_wpPlace(place), | 709 m_wpPlace(place), |
752 m_wrPlace(range), | 710 m_wrPlace(range), |
753 m_eProps(ep), | 711 m_eProps(ep), |
(...skipping 19 matching lines...) Expand all Loading... |
773 m_pEdit->SetWordProps(m_eProps, m_wpPlace, &m_OldWordProps, m_wrPlace, | 731 m_pEdit->SetWordProps(m_eProps, m_wpPlace, &m_OldWordProps, m_wrPlace, |
774 FALSE); | 732 FALSE); |
775 if (IsFirst()) { | 733 if (IsFirst()) { |
776 m_pEdit->SelectNone(); | 734 m_pEdit->SelectNone(); |
777 m_pEdit->PaintSetProps(m_eProps, m_wrPlace); | 735 m_pEdit->PaintSetProps(m_eProps, m_wrPlace); |
778 m_pEdit->SetSel(m_wrPlace.BeginPos, m_wrPlace.EndPos); | 736 m_pEdit->SetSel(m_wrPlace.BeginPos, m_wrPlace.EndPos); |
779 } | 737 } |
780 } | 738 } |
781 } | 739 } |
782 | 740 |
783 /* ------------------------------------- CFX_Edit | |
784 * ------------------------------------- */ | |
785 | |
786 CFX_Edit::CFX_Edit(IPDF_VariableText* pVT) | 741 CFX_Edit::CFX_Edit(IPDF_VariableText* pVT) |
787 : m_pVT(pVT), | 742 : m_pVT(pVT), |
788 m_pNotify(NULL), | 743 m_pNotify(NULL), |
789 m_pOprNotify(NULL), | 744 m_pOprNotify(NULL), |
790 m_pVTProvide(NULL), | 745 m_pVTProvide(NULL), |
791 m_wpCaret(-1, -1, -1), | 746 m_wpCaret(-1, -1, -1), |
792 m_wpOldCaret(-1, -1, -1), | 747 m_wpOldCaret(-1, -1, -1), |
793 m_SelState(), | 748 m_SelState(), |
794 m_ptScrollPos(0, 0), | 749 m_ptScrollPos(0, 0), |
795 m_ptRefreshScrollPos(0, 0), | 750 m_ptRefreshScrollPos(0, 0), |
(...skipping 14 matching lines...) Expand all Loading... |
810 } | 765 } |
811 | 766 |
812 CFX_Edit::~CFX_Edit() { | 767 CFX_Edit::~CFX_Edit() { |
813 delete m_pVTProvide; | 768 delete m_pVTProvide; |
814 m_pVTProvide = NULL; | 769 m_pVTProvide = NULL; |
815 delete m_pIterator; | 770 delete m_pIterator; |
816 m_pIterator = NULL; | 771 m_pIterator = NULL; |
817 ASSERT(!m_pGroupUndoItem); | 772 ASSERT(!m_pGroupUndoItem); |
818 } | 773 } |
819 | 774 |
820 // public methods | |
821 | |
822 void CFX_Edit::Initialize() { | 775 void CFX_Edit::Initialize() { |
823 m_pVT->Initialize(); | 776 m_pVT->Initialize(); |
824 SetCaret(m_pVT->GetBeginWordPlace()); | 777 SetCaret(m_pVT->GetBeginWordPlace()); |
825 SetCaretOrigin(); | 778 SetCaretOrigin(); |
826 } | 779 } |
827 | 780 |
828 void CFX_Edit::SetFontMap(IFX_Edit_FontMap* pFontMap) { | 781 void CFX_Edit::SetFontMap(IFX_Edit_FontMap* pFontMap) { |
829 delete m_pVTProvide; | 782 delete m_pVTProvide; |
830 m_pVT->SetProvider(m_pVTProvide = new CFX_Edit_Provider(pFontMap)); | 783 m_pVT->SetProvider(m_pVTProvide = new CFX_Edit_Provider(pFontMap)); |
831 } | 784 } |
(...skipping 21 matching lines...) Expand all Loading... |
853 return m_pVT; | 806 return m_pVT; |
854 } | 807 } |
855 | 808 |
856 IFX_Edit_FontMap* CFX_Edit::GetFontMap() { | 809 IFX_Edit_FontMap* CFX_Edit::GetFontMap() { |
857 if (m_pVTProvide) | 810 if (m_pVTProvide) |
858 return m_pVTProvide->GetFontMap(); | 811 return m_pVTProvide->GetFontMap(); |
859 | 812 |
860 return NULL; | 813 return NULL; |
861 } | 814 } |
862 | 815 |
863 void CFX_Edit::SetPlateRect(const CPDF_Rect& rect, FX_BOOL bPaint /* = TRUE*/) { | 816 void CFX_Edit::SetPlateRect(const CPDF_Rect& rect, FX_BOOL bPaint) { |
864 m_pVT->SetPlateRect(rect); | 817 m_pVT->SetPlateRect(rect); |
865 m_ptScrollPos = CPDF_Point(rect.left, rect.top); | 818 m_ptScrollPos = CPDF_Point(rect.left, rect.top); |
866 if (bPaint) | 819 if (bPaint) |
867 Paint(); | 820 Paint(); |
868 } | 821 } |
869 | 822 |
870 void CFX_Edit::SetAlignmentH(int32_t nFormat /* =0 */, | 823 void CFX_Edit::SetAlignmentH(int32_t nFormat, FX_BOOL bPaint) { |
871 FX_BOOL bPaint /* = TRUE*/) { | |
872 m_pVT->SetAlignment(nFormat); | 824 m_pVT->SetAlignment(nFormat); |
873 if (bPaint) | 825 if (bPaint) |
874 Paint(); | 826 Paint(); |
875 } | 827 } |
876 | 828 |
877 void CFX_Edit::SetAlignmentV(int32_t nFormat /* =0 */, | 829 void CFX_Edit::SetAlignmentV(int32_t nFormat, FX_BOOL bPaint) { |
878 FX_BOOL bPaint /* = TRUE*/) { | |
879 m_nAlignment = nFormat; | 830 m_nAlignment = nFormat; |
880 if (bPaint) | 831 if (bPaint) |
881 Paint(); | 832 Paint(); |
882 } | 833 } |
883 | 834 |
884 void CFX_Edit::SetPasswordChar(FX_WORD wSubWord /* ='*' */, | 835 void CFX_Edit::SetPasswordChar(FX_WORD wSubWord, FX_BOOL bPaint) { |
885 FX_BOOL bPaint /* = TRUE*/) { | |
886 m_pVT->SetPasswordChar(wSubWord); | 836 m_pVT->SetPasswordChar(wSubWord); |
887 if (bPaint) | 837 if (bPaint) |
888 Paint(); | 838 Paint(); |
889 } | 839 } |
890 | 840 |
891 void CFX_Edit::SetLimitChar(int32_t nLimitChar /* =0 */, | 841 void CFX_Edit::SetLimitChar(int32_t nLimitChar, FX_BOOL bPaint) { |
892 FX_BOOL bPaint /* = TRUE*/) { | |
893 m_pVT->SetLimitChar(nLimitChar); | 842 m_pVT->SetLimitChar(nLimitChar); |
894 if (bPaint) | 843 if (bPaint) |
895 Paint(); | 844 Paint(); |
896 } | 845 } |
897 | 846 |
898 void CFX_Edit::SetCharArray(int32_t nCharArray /* =0 */, | 847 void CFX_Edit::SetCharArray(int32_t nCharArray, FX_BOOL bPaint) { |
899 FX_BOOL bPaint /* = TRUE*/) { | |
900 m_pVT->SetCharArray(nCharArray); | 848 m_pVT->SetCharArray(nCharArray); |
901 if (bPaint) | 849 if (bPaint) |
902 Paint(); | 850 Paint(); |
903 } | 851 } |
904 | 852 |
905 void CFX_Edit::SetCharSpace(FX_FLOAT fCharSpace /* =0.0f */, | 853 void CFX_Edit::SetCharSpace(FX_FLOAT fCharSpace, FX_BOOL bPaint) { |
906 FX_BOOL bPaint /* = TRUE*/) { | |
907 m_pVT->SetCharSpace(fCharSpace); | 854 m_pVT->SetCharSpace(fCharSpace); |
908 if (bPaint) | 855 if (bPaint) |
909 Paint(); | 856 Paint(); |
910 } | 857 } |
911 | 858 |
912 void CFX_Edit::SetHorzScale(int32_t nHorzScale /* =100 */, | 859 void CFX_Edit::SetHorzScale(int32_t nHorzScale, FX_BOOL bPaint) { |
913 FX_BOOL bPaint /* = TRUE*/) { | |
914 m_pVT->SetHorzScale(nHorzScale); | 860 m_pVT->SetHorzScale(nHorzScale); |
915 if (bPaint) | 861 if (bPaint) |
916 Paint(); | 862 Paint(); |
917 } | 863 } |
918 | 864 |
919 void CFX_Edit::SetMultiLine(FX_BOOL bMultiLine /* =TRUE */, | 865 void CFX_Edit::SetMultiLine(FX_BOOL bMultiLine, FX_BOOL bPaint) { |
920 FX_BOOL bPaint /* = TRUE*/) { | |
921 m_pVT->SetMultiLine(bMultiLine); | 866 m_pVT->SetMultiLine(bMultiLine); |
922 if (bPaint) | 867 if (bPaint) |
923 Paint(); | 868 Paint(); |
924 } | 869 } |
925 | 870 |
926 void CFX_Edit::SetAutoReturn(FX_BOOL bAuto /* =TRUE */, | 871 void CFX_Edit::SetAutoReturn(FX_BOOL bAuto, FX_BOOL bPaint) { |
927 FX_BOOL bPaint /* = TRUE*/) { | |
928 m_pVT->SetAutoReturn(bAuto); | 872 m_pVT->SetAutoReturn(bAuto); |
929 if (bPaint) | 873 if (bPaint) |
930 Paint(); | 874 Paint(); |
931 } | 875 } |
932 | 876 |
933 void CFX_Edit::SetLineLeading(FX_FLOAT fLineLeading /* =TRUE */, | 877 void CFX_Edit::SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint) { |
934 FX_BOOL bPaint /* = TRUE*/) { | |
935 m_pVT->SetLineLeading(fLineLeading); | 878 m_pVT->SetLineLeading(fLineLeading); |
936 if (bPaint) | 879 if (bPaint) |
937 Paint(); | 880 Paint(); |
938 } | 881 } |
939 | 882 |
940 void CFX_Edit::SetAutoFontSize(FX_BOOL bAuto /* =TRUE */, | 883 void CFX_Edit::SetAutoFontSize(FX_BOOL bAuto, FX_BOOL bPaint) { |
941 FX_BOOL bPaint /* = TRUE*/) { | |
942 m_pVT->SetAutoFontSize(bAuto); | 884 m_pVT->SetAutoFontSize(bAuto); |
943 if (bPaint) | 885 if (bPaint) |
944 Paint(); | 886 Paint(); |
945 } | 887 } |
946 | 888 |
947 void CFX_Edit::SetFontSize(FX_FLOAT fFontSize, FX_BOOL bPaint /* = TRUE*/) { | 889 void CFX_Edit::SetFontSize(FX_FLOAT fFontSize, FX_BOOL bPaint) { |
948 m_pVT->SetFontSize(fFontSize); | 890 m_pVT->SetFontSize(fFontSize); |
949 if (bPaint) | 891 if (bPaint) |
950 Paint(); | 892 Paint(); |
951 } | 893 } |
952 | 894 |
953 void CFX_Edit::SetAutoScroll(FX_BOOL bAuto /* =TRUE */, | 895 void CFX_Edit::SetAutoScroll(FX_BOOL bAuto, FX_BOOL bPaint) { |
954 FX_BOOL bPaint /* = TRUE*/) { | |
955 m_bEnableScroll = bAuto; | 896 m_bEnableScroll = bAuto; |
956 if (bPaint) | 897 if (bPaint) |
957 Paint(); | 898 Paint(); |
958 } | 899 } |
959 | 900 |
960 void CFX_Edit::SetTextOverflow(FX_BOOL bAllowed /*= FALSE*/, | 901 void CFX_Edit::SetTextOverflow(FX_BOOL bAllowed, FX_BOOL bPaint) { |
961 FX_BOOL bPaint /* = TRUE*/) { | |
962 m_bEnableOverflow = bAllowed; | 902 m_bEnableOverflow = bAllowed; |
963 if (bPaint) | 903 if (bPaint) |
964 Paint(); | 904 Paint(); |
965 } | 905 } |
966 | 906 |
967 void CFX_Edit::SetSel(int32_t nStartChar, int32_t nEndChar) { | 907 void CFX_Edit::SetSel(int32_t nStartChar, int32_t nEndChar) { |
968 if (m_pVT->IsValid()) { | 908 if (m_pVT->IsValid()) { |
969 if (nStartChar == 0 && nEndChar < 0) { | 909 if (nStartChar == 0 && nEndChar < 0) { |
970 SelectAll(); | 910 SelectAll(); |
971 } else if (nStartChar < 0) { | 911 } else if (nStartChar < 0) { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 wrRet.EndPos = wr1.EndPos; | 1088 wrRet.EndPos = wr1.EndPos; |
1149 } | 1089 } |
1150 | 1090 |
1151 return wrRet; | 1091 return wrRet; |
1152 } | 1092 } |
1153 | 1093 |
1154 FX_BOOL CFX_Edit::IsRichText() const { | 1094 FX_BOOL CFX_Edit::IsRichText() const { |
1155 return m_pVT->IsRichText(); | 1095 return m_pVT->IsRichText(); |
1156 } | 1096 } |
1157 | 1097 |
1158 void CFX_Edit::SetRichText(FX_BOOL bRichText /* =TRUE */, | 1098 void CFX_Edit::SetRichText(FX_BOOL bRichText, FX_BOOL bPaint) { |
1159 FX_BOOL bPaint /* = TRUE*/) { | |
1160 m_pVT->SetRichText(bRichText); | 1099 m_pVT->SetRichText(bRichText); |
1161 if (bPaint) | 1100 if (bPaint) |
1162 Paint(); | 1101 Paint(); |
1163 } | 1102 } |
1164 | 1103 |
1165 FX_BOOL CFX_Edit::SetRichFontIndex(int32_t nFontIndex) { | 1104 FX_BOOL CFX_Edit::SetRichFontIndex(int32_t nFontIndex) { |
1166 CPVT_WordProps WordProps; | 1105 CPVT_WordProps WordProps; |
1167 WordProps.nFontIndex = nFontIndex; | 1106 WordProps.nFontIndex = nFontIndex; |
1168 return SetRichTextProps(EP_FONTINDEX, NULL, &WordProps); | 1107 return SetRichTextProps(EP_FONTINDEX, NULL, &WordProps); |
1169 } | 1108 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT; | 1152 WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT; |
1214 return SetRichTextProps(EP_CROSSOUT, NULL, &WordProps); | 1153 return SetRichTextProps(EP_CROSSOUT, NULL, &WordProps); |
1215 } | 1154 } |
1216 | 1155 |
1217 FX_BOOL CFX_Edit::SetRichTextCharSpace(FX_FLOAT fCharSpace) { | 1156 FX_BOOL CFX_Edit::SetRichTextCharSpace(FX_FLOAT fCharSpace) { |
1218 CPVT_WordProps WordProps; | 1157 CPVT_WordProps WordProps; |
1219 WordProps.fCharSpace = fCharSpace; | 1158 WordProps.fCharSpace = fCharSpace; |
1220 return SetRichTextProps(EP_CHARSPACE, NULL, &WordProps); | 1159 return SetRichTextProps(EP_CHARSPACE, NULL, &WordProps); |
1221 } | 1160 } |
1222 | 1161 |
1223 FX_BOOL CFX_Edit::SetRichTextHorzScale(int32_t nHorzScale /*= 100*/) { | 1162 FX_BOOL CFX_Edit::SetRichTextHorzScale(int32_t nHorzScale) { |
1224 CPVT_WordProps WordProps; | 1163 CPVT_WordProps WordProps; |
1225 WordProps.nHorzScale = nHorzScale; | 1164 WordProps.nHorzScale = nHorzScale; |
1226 return SetRichTextProps(EP_HORZSCALE, NULL, &WordProps); | 1165 return SetRichTextProps(EP_HORZSCALE, NULL, &WordProps); |
1227 } | 1166 } |
1228 | 1167 |
1229 FX_BOOL CFX_Edit::SetRichTextLineLeading(FX_FLOAT fLineLeading) { | 1168 FX_BOOL CFX_Edit::SetRichTextLineLeading(FX_FLOAT fLineLeading) { |
1230 CPVT_SecProps SecProps; | 1169 CPVT_SecProps SecProps; |
1231 SecProps.fLineLeading = fLineLeading; | 1170 SecProps.fLineLeading = fLineLeading; |
1232 return SetRichTextProps(EP_LINELEADING, &SecProps, NULL); | 1171 return SetRichTextProps(EP_LINELEADING, &SecProps, NULL); |
1233 } | 1172 } |
(...skipping 17 matching lines...) Expand all Loading... |
1251 FX_BOOL bSet1, bSet2; | 1190 FX_BOOL bSet1, bSet2; |
1252 if (m_pVT->IsValid() && m_pVT->IsRichText()) { | 1191 if (m_pVT->IsValid() && m_pVT->IsRichText()) { |
1253 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { | 1192 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
1254 CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange(); | 1193 CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange(); |
1255 | 1194 |
1256 m_pVT->UpdateWordPlace(wrTemp.BeginPos); | 1195 m_pVT->UpdateWordPlace(wrTemp.BeginPos); |
1257 m_pVT->UpdateWordPlace(wrTemp.EndPos); | 1196 m_pVT->UpdateWordPlace(wrTemp.EndPos); |
1258 pIterator->SetAt(wrTemp.BeginPos); | 1197 pIterator->SetAt(wrTemp.BeginPos); |
1259 | 1198 |
1260 BeginGroupUndo(L""); | 1199 BeginGroupUndo(L""); |
1261 ; | |
1262 | |
1263 bSet = SetSecProps(eProps, wrTemp.BeginPos, pSecProps, pWordProps, wrTemp, | 1200 bSet = SetSecProps(eProps, wrTemp.BeginPos, pSecProps, pWordProps, wrTemp, |
1264 TRUE); | 1201 TRUE); |
1265 | 1202 |
1266 while (pIterator->NextWord()) { | 1203 while (pIterator->NextWord()) { |
1267 CPVT_WordPlace place = pIterator->GetAt(); | 1204 CPVT_WordPlace place = pIterator->GetAt(); |
1268 if (place.WordCmp(wrTemp.EndPos) > 0) | 1205 if (place.WordCmp(wrTemp.EndPos) > 0) |
1269 break; | 1206 break; |
1270 bSet1 = SetSecProps(eProps, place, pSecProps, pWordProps, wrTemp, TRUE); | 1207 bSet1 = SetSecProps(eProps, place, pSecProps, pWordProps, wrTemp, TRUE); |
1271 bSet2 = SetWordProps(eProps, place, pWordProps, wrTemp, TRUE); | 1208 bSet2 = SetWordProps(eProps, place, pWordProps, wrTemp, TRUE); |
1272 | 1209 |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 | 1575 |
1639 pIterator->SetAt(oldplace); | 1576 pIterator->SetAt(oldplace); |
1640 return bSet; | 1577 return bSet; |
1641 } | 1578 } |
1642 } | 1579 } |
1643 | 1580 |
1644 return FALSE; | 1581 return FALSE; |
1645 } | 1582 } |
1646 | 1583 |
1647 void CFX_Edit::SetText(const FX_WCHAR* text, | 1584 void CFX_Edit::SetText(const FX_WCHAR* text, |
1648 int32_t charset /*= DEFAULT_CHARSET*/, | 1585 int32_t charset, |
1649 const CPVT_SecProps* pSecProps /*= NULL*/, | 1586 const CPVT_SecProps* pSecProps, |
1650 const CPVT_WordProps* pWordProps /*= NULL*/) { | 1587 const CPVT_WordProps* pWordProps) { |
1651 SetText(text, charset, pSecProps, pWordProps, TRUE, TRUE); | 1588 SetText(text, charset, pSecProps, pWordProps, TRUE, TRUE); |
1652 } | 1589 } |
1653 | 1590 |
1654 FX_BOOL CFX_Edit::InsertWord(FX_WORD word, | 1591 FX_BOOL CFX_Edit::InsertWord(FX_WORD word, |
1655 int32_t charset /*= DEFAULT_CHARSET*/, | 1592 int32_t charset, |
1656 const CPVT_WordProps* pWordProps /*= NULL*/) { | 1593 const CPVT_WordProps* pWordProps) { |
1657 return InsertWord(word, charset, pWordProps, TRUE, TRUE); | 1594 return InsertWord(word, charset, pWordProps, TRUE, TRUE); |
1658 } | 1595 } |
1659 | 1596 |
1660 FX_BOOL CFX_Edit::InsertReturn(const CPVT_SecProps* pSecProps /*= NULL*/, | 1597 FX_BOOL CFX_Edit::InsertReturn(const CPVT_SecProps* pSecProps, |
1661 const CPVT_WordProps* pWordProps /*= NULL*/) { | 1598 const CPVT_WordProps* pWordProps) { |
1662 return InsertReturn(pSecProps, pWordProps, TRUE, TRUE); | 1599 return InsertReturn(pSecProps, pWordProps, TRUE, TRUE); |
1663 } | 1600 } |
1664 | 1601 |
1665 FX_BOOL CFX_Edit::Backspace() { | 1602 FX_BOOL CFX_Edit::Backspace() { |
1666 return Backspace(TRUE, TRUE); | 1603 return Backspace(TRUE, TRUE); |
1667 } | 1604 } |
1668 | 1605 |
1669 FX_BOOL CFX_Edit::Delete() { | 1606 FX_BOOL CFX_Edit::Delete() { |
1670 return Delete(TRUE, TRUE); | 1607 return Delete(TRUE, TRUE); |
1671 } | 1608 } |
1672 | 1609 |
1673 FX_BOOL CFX_Edit::Clear() { | 1610 FX_BOOL CFX_Edit::Clear() { |
1674 return Clear(TRUE, TRUE); | 1611 return Clear(TRUE, TRUE); |
1675 } | 1612 } |
1676 | 1613 |
1677 FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text, | 1614 FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text, |
1678 int32_t charset /*= DEFAULT_CHARSET*/, | 1615 int32_t charset, |
1679 const CPVT_SecProps* pSecProps /*= NULL*/, | 1616 const CPVT_SecProps* pSecProps, |
1680 const CPVT_WordProps* pWordProps /*= NULL*/) { | 1617 const CPVT_WordProps* pWordProps) { |
1681 return InsertText(text, charset, pSecProps, pWordProps, TRUE, TRUE); | 1618 return InsertText(text, charset, pSecProps, pWordProps, TRUE, TRUE); |
1682 } | 1619 } |
1683 | 1620 |
1684 FX_FLOAT CFX_Edit::GetFontSize() const { | 1621 FX_FLOAT CFX_Edit::GetFontSize() const { |
1685 return m_pVT->GetFontSize(); | 1622 return m_pVT->GetFontSize(); |
1686 } | 1623 } |
1687 | 1624 |
1688 FX_WORD CFX_Edit::GetPasswordChar() const { | 1625 FX_WORD CFX_Edit::GetPasswordChar() const { |
1689 return m_pVT->GetPasswordChar(); | 1626 return m_pVT->GetPasswordChar(); |
1690 } | 1627 } |
(...skipping 11 matching lines...) Expand all Loading... |
1702 } | 1639 } |
1703 | 1640 |
1704 int32_t CFX_Edit::GetHorzScale() const { | 1641 int32_t CFX_Edit::GetHorzScale() const { |
1705 return m_pVT->GetHorzScale(); | 1642 return m_pVT->GetHorzScale(); |
1706 } | 1643 } |
1707 | 1644 |
1708 FX_FLOAT CFX_Edit::GetCharSpace() const { | 1645 FX_FLOAT CFX_Edit::GetCharSpace() const { |
1709 return m_pVT->GetCharSpace(); | 1646 return m_pVT->GetCharSpace(); |
1710 } | 1647 } |
1711 | 1648 |
1712 // inner methods | |
1713 | |
1714 CPVT_WordRange CFX_Edit::GetWholeWordRange() const { | 1649 CPVT_WordRange CFX_Edit::GetWholeWordRange() const { |
1715 if (m_pVT->IsValid()) | 1650 if (m_pVT->IsValid()) |
1716 return CPVT_WordRange(m_pVT->GetBeginWordPlace(), m_pVT->GetEndWordPlace()); | 1651 return CPVT_WordRange(m_pVT->GetBeginWordPlace(), m_pVT->GetEndWordPlace()); |
1717 | 1652 |
1718 return CPVT_WordRange(); | 1653 return CPVT_WordRange(); |
1719 } | 1654 } |
1720 | 1655 |
1721 CPVT_WordRange CFX_Edit::GetVisibleWordRange() const { | 1656 CPVT_WordRange CFX_Edit::GetVisibleWordRange() const { |
1722 if (m_bEnableOverflow) | 1657 if (m_bEnableOverflow) |
1723 return GetWholeWordRange(); | 1658 return GetWholeWordRange(); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2026 } | 1961 } |
2027 } | 1962 } |
2028 | 1963 |
2029 void CFX_Edit::Refresh(REFRESH_PLAN_E ePlan, | 1964 void CFX_Edit::Refresh(REFRESH_PLAN_E ePlan, |
2030 const CPVT_WordRange* pRange1, | 1965 const CPVT_WordRange* pRange1, |
2031 const CPVT_WordRange* pRange2) { | 1966 const CPVT_WordRange* pRange2) { |
2032 if (m_bEnableRefresh && m_pVT->IsValid()) { | 1967 if (m_bEnableRefresh && m_pVT->IsValid()) { |
2033 m_Refresh.BeginRefresh(); | 1968 m_Refresh.BeginRefresh(); |
2034 RefreshPushLineRects(GetVisibleWordRange()); | 1969 RefreshPushLineRects(GetVisibleWordRange()); |
2035 | 1970 |
2036 // if (!FX_EDIT_IsFloatEqual(m_ptRefreshScrollPos.x,m_ptScrollPos.x) || | |
2037 // !FX_EDIT_IsFloatEqual(m_ptRefreshScrollPos.y,m_ptScrollPos.y)) | |
2038 // { | |
2039 m_Refresh.NoAnalyse(); | 1971 m_Refresh.NoAnalyse(); |
2040 m_ptRefreshScrollPos = m_ptScrollPos; | 1972 m_ptRefreshScrollPos = m_ptScrollPos; |
2041 // } | |
2042 // else | |
2043 // { | |
2044 // switch (ePlan) | |
2045 // { | |
2046 // case RP_ANALYSE: | |
2047 // m_Refresh.Analyse(m_pVT->GetAlignment()); | |
2048 // | |
2049 // if (pRange1) RefreshPushRandomRects(*pRange1); | |
2050 // if (pRange2) RefreshPushRandomRects(*pRange2); | |
2051 // break; | |
2052 // case RP_NOANALYSE: | |
2053 // m_Refresh.NoAnalyse(); | |
2054 // break; | |
2055 // case RP_OPTIONAL: | |
2056 // if (pRange1) RefreshPushRandomRects(*pRange1); | |
2057 // if (pRange2) RefreshPushRandomRects(*pRange2); | |
2058 // break; | |
2059 // } | |
2060 // } | |
2061 | 1973 |
2062 if (m_bNotify && m_pNotify) { | 1974 if (m_bNotify && m_pNotify) { |
2063 if (!m_bNotifyFlag) { | 1975 if (!m_bNotifyFlag) { |
2064 m_bNotifyFlag = TRUE; | 1976 m_bNotifyFlag = TRUE; |
2065 if (const CFX_Edit_RectArray* pRects = m_Refresh.GetRefreshRects()) { | 1977 if (const CFX_Edit_RectArray* pRects = m_Refresh.GetRefreshRects()) { |
2066 for (int32_t i = 0, sz = pRects->GetSize(); i < sz; i++) | 1978 for (int32_t i = 0, sz = pRects->GetSize(); i < sz; i++) |
2067 m_pNotify->IOnInvalidateRect(pRects->GetAt(i)); | 1979 m_pNotify->IOnInvalidateRect(pRects->GetAt(i)); |
2068 } | 1980 } |
2069 m_bNotifyFlag = FALSE; | 1981 m_bNotifyFlag = FALSE; |
2070 } | 1982 } |
(...skipping 19 matching lines...) Expand all Loading... |
2090 if (lineinfo.lineplace.LineCmp(wpEnd) > 0) | 2002 if (lineinfo.lineplace.LineCmp(wpEnd) > 0) |
2091 break; | 2003 break; |
2092 | 2004 |
2093 CPDF_Rect rcLine(lineinfo.ptLine.x, | 2005 CPDF_Rect rcLine(lineinfo.ptLine.x, |
2094 lineinfo.ptLine.y + lineinfo.fLineDescent, | 2006 lineinfo.ptLine.y + lineinfo.fLineDescent, |
2095 lineinfo.ptLine.x + lineinfo.fLineWidth, | 2007 lineinfo.ptLine.x + lineinfo.fLineWidth, |
2096 lineinfo.ptLine.y + lineinfo.fLineAscent); | 2008 lineinfo.ptLine.y + lineinfo.fLineAscent); |
2097 | 2009 |
2098 m_Refresh.Push(CPVT_WordRange(lineinfo.lineplace, lineinfo.lineEnd), | 2010 m_Refresh.Push(CPVT_WordRange(lineinfo.lineplace, lineinfo.lineEnd), |
2099 VTToEdit(rcLine)); | 2011 VTToEdit(rcLine)); |
2100 | |
2101 } while (pIterator->NextLine()); | 2012 } while (pIterator->NextLine()); |
2102 } | 2013 } |
2103 } | 2014 } |
2104 } | 2015 } |
2105 | 2016 |
2106 void CFX_Edit::RefreshPushRandomRects(const CPVT_WordRange& wr) { | 2017 void CFX_Edit::RefreshPushRandomRects(const CPVT_WordRange& wr) { |
2107 if (m_pVT->IsValid()) { | 2018 if (m_pVT->IsValid()) { |
2108 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { | 2019 if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) { |
2109 CPVT_WordRange wrTemp = wr; | 2020 CPVT_WordRange wrTemp = wr; |
2110 | 2021 |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2542 const CPVT_SecProps* pSecProps, | 2453 const CPVT_SecProps* pSecProps, |
2543 const CPVT_WordProps* pWordProps, | 2454 const CPVT_WordProps* pWordProps, |
2544 FX_BOOL bAddUndo, | 2455 FX_BOOL bAddUndo, |
2545 FX_BOOL bPaint) { | 2456 FX_BOOL bPaint) { |
2546 Empty(); | 2457 Empty(); |
2547 DoInsertText(CPVT_WordPlace(0, 0, -1), text, charset, pSecProps, pWordProps); | 2458 DoInsertText(CPVT_WordPlace(0, 0, -1), text, charset, pSecProps, pWordProps); |
2548 if (bPaint) | 2459 if (bPaint) |
2549 Paint(); | 2460 Paint(); |
2550 if (m_bOprNotify && m_pOprNotify) | 2461 if (m_bOprNotify && m_pOprNotify) |
2551 m_pOprNotify->OnSetText(m_wpCaret, m_wpOldCaret); | 2462 m_pOprNotify->OnSetText(m_wpCaret, m_wpOldCaret); |
2552 // if (bAddUndo) | |
2553 } | 2463 } |
2554 | 2464 |
2555 FX_BOOL CFX_Edit::InsertWord(FX_WORD word, | 2465 FX_BOOL CFX_Edit::InsertWord(FX_WORD word, |
2556 int32_t charset, | 2466 int32_t charset, |
2557 const CPVT_WordProps* pWordProps, | 2467 const CPVT_WordProps* pWordProps, |
2558 FX_BOOL bAddUndo, | 2468 FX_BOOL bAddUndo, |
2559 FX_BOOL bPaint) { | 2469 FX_BOOL bPaint) { |
2560 if (IsTextOverflow()) | 2470 if (IsTextOverflow()) |
2561 return FALSE; | 2471 return FALSE; |
2562 | 2472 |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3096 | 3006 |
3097 void CFX_Edit::EndGroupUndo() { | 3007 void CFX_Edit::EndGroupUndo() { |
3098 m_pGroupUndoItem->UpdateItems(); | 3008 m_pGroupUndoItem->UpdateItems(); |
3099 m_Undo.AddItem(m_pGroupUndoItem); | 3009 m_Undo.AddItem(m_pGroupUndoItem); |
3100 if (m_bOprNotify && m_pOprNotify) | 3010 if (m_bOprNotify && m_pOprNotify) |
3101 m_pOprNotify->OnAddUndo(m_pGroupUndoItem); | 3011 m_pOprNotify->OnAddUndo(m_pGroupUndoItem); |
3102 m_pGroupUndoItem = NULL; | 3012 m_pGroupUndoItem = NULL; |
3103 } | 3013 } |
3104 | 3014 |
3105 void CFX_Edit::AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem) { | 3015 void CFX_Edit::AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem) { |
3106 if (m_pGroupUndoItem) | 3016 if (m_pGroupUndoItem) { |
3107 m_pGroupUndoItem->AddUndoItem(pEditUndoItem); | 3017 m_pGroupUndoItem->AddUndoItem(pEditUndoItem); |
3108 else { | 3018 } else { |
3109 m_Undo.AddItem(pEditUndoItem); | 3019 m_Undo.AddItem(pEditUndoItem); |
3110 if (m_bOprNotify && m_pOprNotify) | 3020 if (m_bOprNotify && m_pOprNotify) |
3111 m_pOprNotify->OnAddUndo(pEditUndoItem); | 3021 m_pOprNotify->OnAddUndo(pEditUndoItem); |
3112 } | 3022 } |
3113 } | 3023 } |
3114 | 3024 |
3115 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) { | 3025 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) { |
3116 m_Undo.AddItem(pUndoItem); | 3026 m_Undo.AddItem(pUndoItem); |
3117 if (m_bOprNotify && m_pOprNotify) | 3027 if (m_bOprNotify && m_pOprNotify) |
3118 m_pOprNotify->OnAddUndo(pUndoItem); | 3028 m_pOprNotify->OnAddUndo(pUndoItem); |
3119 } | 3029 } |
OLD | NEW |