Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: xfa/fwl/core/cfwl_edit.cpp

Issue 2557103002: Cleanup FWL default values part II. (Closed)
Patch Set: Rebase to master Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fwl/core/cfwl_edit.h ('k') | xfa/fwl/core/cfwl_form.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "xfa/fwl/core/cfwl_edit.h" 7 #include "xfa/fwl/core/cfwl_edit.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 rect.height += kEditMargin; 106 rect.height += kEditMargin;
107 } 107 }
108 } 108 }
109 return; 109 return;
110 } 110 }
111 111
112 rect.Set(0, 0, 0, 0); 112 rect.Set(0, 0, 0, 0);
113 113
114 int32_t iTextLen = m_EdtEngine.GetTextLength(); 114 int32_t iTextLen = m_EdtEngine.GetTextLength();
115 if (iTextLen > 0) { 115 if (iTextLen > 0) {
116 CFX_WideString wsText = m_EdtEngine.GetText(0); 116 CFX_WideString wsText = m_EdtEngine.GetText(0, -1);
117 CFX_SizeF sz = CalcTextSize( 117 CFX_SizeF sz = CalcTextSize(
118 wsText, m_pProperties->m_pThemeProvider, 118 wsText, m_pProperties->m_pThemeProvider,
119 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine)); 119 !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine));
120 rect.Set(0, 0, sz.x, sz.y); 120 rect.Set(0, 0, sz.x, sz.y);
121 } 121 }
122 CFWL_Widget::GetWidgetRect(rect, true); 122 CFWL_Widget::GetWidgetRect(rect, true);
123 } 123 }
124 124
125 void CFWL_Edit::SetStates(uint32_t dwStates) { 125 void CFWL_Edit::SetStates(uint32_t dwStates) {
126 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) || 126 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) ||
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 } 290 }
291 291
292 void CFWL_Edit::SetText(const CFX_WideString& wsText) { 292 void CFWL_Edit::SetText(const CFX_WideString& wsText) {
293 m_EdtEngine.SetText(wsText); 293 m_EdtEngine.SetText(wsText);
294 } 294 }
295 295
296 int32_t CFWL_Edit::GetTextLength() const { 296 int32_t CFWL_Edit::GetTextLength() const {
297 return m_EdtEngine.GetTextLength(); 297 return m_EdtEngine.GetTextLength();
298 } 298 }
299 299
300 CFX_WideString CFWL_Edit::GetText(int32_t nStart, int32_t nCount) const { 300 CFX_WideString CFWL_Edit::GetText() const {
301 return m_EdtEngine.GetText(nStart, nCount); 301 return m_EdtEngine.GetText(0, -1);
302 } 302 }
303 303
304 void CFWL_Edit::ClearText() { 304 void CFWL_Edit::ClearText() {
305 m_EdtEngine.ClearText(); 305 m_EdtEngine.ClearText();
306 } 306 }
307 307
308 void CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { 308 void CFWL_Edit::AddSelRange(int32_t nStart) {
309 m_EdtEngine.AddSelRange(nStart, nCount); 309 m_EdtEngine.AddSelRange(nStart, -1);
310 } 310 }
311 311
312 int32_t CFWL_Edit::CountSelRanges() const { 312 int32_t CFWL_Edit::CountSelRanges() const {
313 return m_EdtEngine.CountSelRanges(); 313 return m_EdtEngine.CountSelRanges();
314 } 314 }
315 315
316 int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) const { 316 int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t* nStart) const {
317 return m_EdtEngine.GetSelRange(nIndex, nStart); 317 return m_EdtEngine.GetSelRange(nIndex, nStart);
318 } 318 }
319 319
320 void CFWL_Edit::ClearSelections() { 320 void CFWL_Edit::ClearSelections() {
321 m_EdtEngine.ClearSelection(); 321 m_EdtEngine.ClearSelection();
322 } 322 }
323 323
324 int32_t CFWL_Edit::GetLimit() const { 324 int32_t CFWL_Edit::GetLimit() const {
325 return m_nLimit; 325 return m_nLimit;
326 } 326 }
327 327
328 void CFWL_Edit::SetLimit(int32_t nLimit) { 328 void CFWL_Edit::SetLimit(int32_t nLimit) {
329 m_nLimit = nLimit; 329 m_nLimit = nLimit;
330 m_EdtEngine.SetLimit(nLimit); 330 m_EdtEngine.SetLimit(nLimit);
331 } 331 }
332 332
333 void CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { 333 void CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) {
334 m_EdtEngine.SetAliasChar(wAlias); 334 m_EdtEngine.SetAliasChar(wAlias);
335 } 335 }
336 336
337 bool CFWL_Edit::Copy(CFX_WideString& wsCopy) { 337 bool CFWL_Edit::Copy(CFX_WideString& wsCopy) {
338 int32_t nCount = m_EdtEngine.CountSelRanges(); 338 int32_t nCount = m_EdtEngine.CountSelRanges();
339 if (nCount == 0) 339 if (nCount == 0)
340 return false; 340 return false;
341 341
342 wsCopy.clear(); 342 wsCopy.clear();
343 CFX_WideString wsTemp; 343 int32_t nStart;
344 int32_t nStart, nLength; 344 int32_t nLength;
345 for (int32_t i = 0; i < nCount; i++) { 345 for (int32_t i = 0; i < nCount; i++) {
346 nLength = m_EdtEngine.GetSelRange(i, nStart); 346 nLength = m_EdtEngine.GetSelRange(i, &nStart);
347 wsTemp = m_EdtEngine.GetText(nStart, nLength); 347 wsCopy += m_EdtEngine.GetText(nStart, nLength);
348 wsCopy += wsTemp;
349 wsTemp.clear();
350 } 348 }
351 return true; 349 return true;
352 } 350 }
353 351
354 bool CFWL_Edit::Cut(CFX_WideString& wsCut) { 352 bool CFWL_Edit::Cut(CFX_WideString& wsCut) {
355 int32_t nCount = m_EdtEngine.CountSelRanges(); 353 int32_t nCount = m_EdtEngine.CountSelRanges();
356 if (nCount == 0) 354 if (nCount == 0)
357 return false; 355 return false;
358 356
359 wsCut.clear(); 357 wsCut.clear();
360 CFX_WideString wsTemp; 358 CFX_WideString wsTemp;
361 int32_t nStart, nLength; 359 int32_t nStart, nLength;
362 for (int32_t i = 0; i < nCount; i++) { 360 for (int32_t i = 0; i < nCount; i++) {
363 nLength = m_EdtEngine.GetSelRange(i, nStart); 361 nLength = m_EdtEngine.GetSelRange(i, &nStart);
364 wsTemp = m_EdtEngine.GetText(nStart, nLength); 362 wsTemp = m_EdtEngine.GetText(nStart, nLength);
365 wsCut += wsTemp; 363 wsCut += wsTemp;
366 wsTemp.clear(); 364 wsTemp.clear();
367 } 365 }
368 m_EdtEngine.Delete(0); 366 m_EdtEngine.Delete(0);
369 return true; 367 return true;
370 } 368 }
371 369
372 bool CFWL_Edit::Paste(const CFX_WideString& wsPaste) { 370 bool CFWL_Edit::Paste(const CFX_WideString& wsPaste) {
373 int32_t nCaret = m_EdtEngine.GetCaretPos(); 371 int32_t nCaret = m_EdtEngine.GetCaretPos();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 } 407 }
410 408
411 bool CFWL_Edit::CanRedo() { 409 bool CFWL_Edit::CanRedo() {
412 return m_iCurRecord < pdfium::CollectionSize<int32_t>(m_DoRecords) - 1; 410 return m_iCurRecord < pdfium::CollectionSize<int32_t>(m_DoRecords) - 1;
413 } 411 }
414 412
415 void CFWL_Edit::SetOuter(CFWL_Widget* pOuter) { 413 void CFWL_Edit::SetOuter(CFWL_Widget* pOuter) {
416 m_pOuter = pOuter; 414 m_pOuter = pOuter;
417 } 415 }
418 416
419 void CFWL_Edit::On_CaretChanged(CFDE_TxtEdtEngine* pEdit, 417 void CFWL_Edit::OnCaretChanged() {
420 int32_t nPage,
421 bool bVisible) {
422 if (m_rtEngine.IsEmpty()) 418 if (m_rtEngine.IsEmpty())
423 return; 419 return;
424 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) 420 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
425 return; 421 return;
426 422
427 bool bRepaintContent = UpdateOffset(); 423 bool bRepaintContent = UpdateOffset();
428 UpdateCaret(); 424 UpdateCaret();
429 CFX_RectF rtInvalid; 425 CFX_RectF rtInvalid;
430 rtInvalid.Set(0, 0, 0, 0); 426 rtInvalid.Set(0, 0, 0, 0);
431 bool bRepaintScroll = false; 427 bool bRepaintScroll = false;
432 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { 428 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) {
433 CFWL_ScrollBar* pScroll = UpdateScroll(); 429 CFWL_ScrollBar* pScroll = UpdateScroll();
434 if (pScroll) { 430 if (pScroll) {
435 pScroll->GetWidgetRect(rtInvalid, false); 431 pScroll->GetWidgetRect(rtInvalid, false);
436 bRepaintScroll = true; 432 bRepaintScroll = true;
437 } 433 }
438 } 434 }
439 if (bRepaintContent || bRepaintScroll) { 435 if (bRepaintContent || bRepaintScroll) {
440 if (bRepaintContent) 436 if (bRepaintContent)
441 rtInvalid.Union(m_rtEngine); 437 rtInvalid.Union(m_rtEngine);
442 Repaint(&rtInvalid); 438 Repaint(&rtInvalid);
443 } 439 }
444 } 440 }
445 441
446 void CFWL_Edit::On_TextChanged(CFDE_TxtEdtEngine* pEdit, 442 void CFWL_Edit::OnTextChanged(const FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) {
447 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) {
448 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VAlignMask) 443 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VAlignMask)
449 UpdateVAlignment(); 444 UpdateVAlignment();
450 445
451 CFX_RectF rtTemp; 446 CFX_RectF rtTemp;
452 GetClientRect(rtTemp); 447 GetClientRect(rtTemp);
453 448
454 CFWL_EvtTextChanged event(this); 449 CFWL_EvtTextChanged event(this);
455 event.wsPrevText = ChangeInfo.wsPrevText; 450 event.wsPrevText = ChangeInfo.wsPrevText;
456 DispatchEvent(&event); 451 DispatchEvent(&event);
457 452
458 LayoutScrollBar(); 453 LayoutScrollBar();
459 Repaint(&rtTemp); 454 Repaint(&rtTemp);
460 } 455 }
461 456
462 void CFWL_Edit::On_SelChanged(CFDE_TxtEdtEngine* pEdit) { 457 void CFWL_Edit::OnSelChanged() {
463 CFX_RectF rtTemp; 458 CFX_RectF rtTemp;
464 GetClientRect(rtTemp); 459 GetClientRect(rtTemp);
465 Repaint(&rtTemp); 460 Repaint(&rtTemp);
466 } 461 }
467 462
468 bool CFWL_Edit::On_PageLoad(CFDE_TxtEdtEngine* pEdit, 463 bool CFWL_Edit::OnPageLoad(int32_t nPageIndex) {
469 int32_t nPageIndex,
470 int32_t nPurpose) {
471 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(nPageIndex); 464 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(nPageIndex);
472 if (!pPage) 465 if (!pPage)
473 return false; 466 return false;
474 467
475 pPage->LoadPage(nullptr, nullptr); 468 pPage->LoadPage(nullptr, nullptr);
476 return true; 469 return true;
477 } 470 }
478 471
479 bool CFWL_Edit::On_PageUnload(CFDE_TxtEdtEngine* pEdit, 472 bool CFWL_Edit::OnPageUnload(int32_t nPageIndex) {
480 int32_t nPageIndex,
481 int32_t nPurpose) {
482 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(nPageIndex); 473 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(nPageIndex);
483 if (!pPage) 474 if (!pPage)
484 return false; 475 return false;
485 476
486 pPage->UnloadPage(nullptr); 477 pPage->UnloadPage(nullptr);
487 return true; 478 return true;
488 } 479 }
489 480
490 void CFWL_Edit::On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, 481 void CFWL_Edit::OnAddDoRecord(std::unique_ptr<IFDE_TxtEdtDoRecord> pRecord) {
491 IFDE_TxtEdtDoRecord* pRecord) { 482 AddDoRecord(std::move(pRecord));
492 AddDoRecord(pRecord);
493 } 483 }
494 484
495 bool CFWL_Edit::On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText) { 485 bool CFWL_Edit::OnValidate(const CFX_WideString& wsText) {
496 CFWL_Widget* pDst = GetOuter(); 486 CFWL_Widget* pDst = GetOuter();
497 if (!pDst) 487 if (!pDst)
498 pDst = this; 488 pDst = this;
499 489
500 CFWL_EvtValidate event(this); 490 CFWL_EvtValidate event(this);
501 event.wsInsert = wsText; 491 event.wsInsert = wsText;
502 event.bValidate = true; 492 event.bValidate = true;
503 DispatchEvent(&event); 493 DispatchEvent(&event);
504 return event.bValidate; 494 return event.bValidate;
505 } 495 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 int32_t nSelCount = m_EdtEngine.CountSelRanges(); 566 int32_t nSelCount = m_EdtEngine.CountSelRanges();
577 if (bShowSel && nSelCount > 0) { 567 if (bShowSel && nSelCount > 0) {
578 int32_t nPageCharStart = pPage->GetCharStart(); 568 int32_t nPageCharStart = pPage->GetCharStart();
579 int32_t nPageCharCount = pPage->GetCharCount(); 569 int32_t nPageCharCount = pPage->GetCharCount();
580 int32_t nPageCharEnd = nPageCharStart + nPageCharCount - 1; 570 int32_t nPageCharEnd = nPageCharStart + nPageCharCount - 1;
581 int32_t nCharCount; 571 int32_t nCharCount;
582 int32_t nCharStart; 572 int32_t nCharStart;
583 CFX_RectFArray rectArr; 573 CFX_RectFArray rectArr;
584 int32_t i = 0; 574 int32_t i = 0;
585 for (i = 0; i < nSelCount; i++) { 575 for (i = 0; i < nSelCount; i++) {
586 nCharCount = m_EdtEngine.GetSelRange(i, nCharStart); 576 nCharCount = m_EdtEngine.GetSelRange(i, &nCharStart);
587 int32_t nCharEnd = nCharStart + nCharCount - 1; 577 int32_t nCharEnd = nCharStart + nCharCount - 1;
588 if (nCharEnd < nPageCharStart || nCharStart > nPageCharEnd) 578 if (nCharEnd < nPageCharStart || nCharStart > nPageCharEnd)
589 continue; 579 continue;
590 580
591 int32_t nBgn = std::max(nCharStart, nPageCharStart); 581 int32_t nBgn = std::max(nCharStart, nPageCharStart);
592 int32_t nEnd = std::min(nCharEnd, nPageCharEnd); 582 int32_t nEnd = std::min(nCharEnd, nPageCharEnd);
593 pPage->CalcRangeRectArray(nBgn - nPageCharStart, nEnd - nBgn + 1, 583 pPage->CalcRangeRectArray(nBgn - nPageCharStart, nEnd - nBgn + 1,
594 rectArr); 584 rectArr);
595 } 585 }
596 586
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine); 974 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine);
985 } 975 }
986 976
987 bool CFWL_Edit::IsContentHeightOverflow() { 977 bool CFWL_Edit::IsContentHeightOverflow() {
988 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); 978 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0);
989 if (!pPage) 979 if (!pPage)
990 return false; 980 return false;
991 return pPage->GetContentsBox().height > m_rtEngine.height + 1.0f; 981 return pPage->GetContentsBox().height > m_rtEngine.height + 1.0f;
992 } 982 }
993 983
994 int32_t CFWL_Edit::AddDoRecord(IFDE_TxtEdtDoRecord* pRecord) { 984 int32_t CFWL_Edit::AddDoRecord(std::unique_ptr<IFDE_TxtEdtDoRecord> pRecord) {
995 int32_t nCount = pdfium::CollectionSize<int32_t>(m_DoRecords); 985 int32_t nCount = pdfium::CollectionSize<int32_t>(m_DoRecords);
996 if (m_iCurRecord == nCount - 1) { 986 if (m_iCurRecord == nCount - 1) {
997 if (nCount == m_iMaxRecord) { 987 if (nCount == m_iMaxRecord) {
998 m_DoRecords.pop_front(); 988 m_DoRecords.pop_front();
999 m_iCurRecord--; 989 m_iCurRecord--;
1000 } 990 }
1001 } else { 991 } else {
1002 m_DoRecords.erase(m_DoRecords.begin() + m_iCurRecord + 1, 992 m_DoRecords.erase(m_DoRecords.begin() + m_iCurRecord + 1,
1003 m_DoRecords.end()); 993 m_DoRecords.end());
1004 } 994 }
1005 995
1006 m_DoRecords.push_back(std::unique_ptr<IFDE_TxtEdtDoRecord>(pRecord)); 996 m_DoRecords.push_back(std::move(pRecord));
1007 m_iCurRecord = pdfium::CollectionSize<int32_t>(m_DoRecords) - 1; 997 m_iCurRecord = pdfium::CollectionSize<int32_t>(m_DoRecords) - 1;
1008 return m_iCurRecord; 998 return m_iCurRecord;
1009 } 999 }
1010 1000
1011 void CFWL_Edit::Layout() { 1001 void CFWL_Edit::Layout() {
1012 GetClientRect(m_rtClient); 1002 GetClientRect(m_rtClient);
1013 m_rtEngine = m_rtClient; 1003 m_rtEngine = m_rtClient;
1014 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>( 1004 FX_FLOAT* pfWidth = static_cast<FX_FLOAT*>(
1015 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 1005 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
1016 if (!pfWidth) 1006 if (!pfWidth)
(...skipping 15 matching lines...) Expand all
1032 &part, CFWL_WidgetCapacity::UIMargin)); 1022 &part, CFWL_WidgetCapacity::UIMargin));
1033 if (pUIMargin) { 1023 if (pUIMargin) {
1034 m_rtEngine.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, 1024 m_rtEngine.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width,
1035 pUIMargin->height); 1025 pUIMargin->height);
1036 } 1026 }
1037 } 1027 }
1038 1028
1039 bool bShowVertScrollbar = IsShowScrollBar(true); 1029 bool bShowVertScrollbar = IsShowScrollBar(true);
1040 bool bShowHorzScrollbar = IsShowScrollBar(false); 1030 bool bShowHorzScrollbar = IsShowScrollBar(false);
1041 if (bShowVertScrollbar) { 1031 if (bShowVertScrollbar) {
1042 InitScrollBar(); 1032 InitVerticalScrollBar();
1043 1033
1044 CFX_RectF rtVertScr; 1034 CFX_RectF rtVertScr;
1045 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { 1035 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
1046 rtVertScr.Set(m_rtClient.right() + kEditMargin, m_rtClient.top, fWidth, 1036 rtVertScr.Set(m_rtClient.right() + kEditMargin, m_rtClient.top, fWidth,
1047 m_rtClient.height); 1037 m_rtClient.height);
1048 } else { 1038 } else {
1049 rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth, 1039 rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth,
1050 m_rtClient.height); 1040 m_rtClient.height);
1051 if (bShowHorzScrollbar) 1041 if (bShowHorzScrollbar)
1052 rtVertScr.height -= fWidth; 1042 rtVertScr.height -= fWidth;
1053 m_rtEngine.width -= fWidth; 1043 m_rtEngine.width -= fWidth;
1054 } 1044 }
1055 1045
1056 m_pVertScrollBar->SetWidgetRect(rtVertScr); 1046 m_pVertScrollBar->SetWidgetRect(rtVertScr);
1057 m_pVertScrollBar->RemoveStates(FWL_WGTSTATE_Invisible); 1047 m_pVertScrollBar->RemoveStates(FWL_WGTSTATE_Invisible);
1058 m_pVertScrollBar->Update(); 1048 m_pVertScrollBar->Update();
1059 } else if (m_pVertScrollBar) { 1049 } else if (m_pVertScrollBar) {
1060 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible); 1050 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible);
1061 } 1051 }
1062 1052
1063 if (bShowHorzScrollbar) { 1053 if (bShowHorzScrollbar) {
1064 InitScrollBar(false); 1054 InitHorizontalScrollBar();
1065 1055
1066 CFX_RectF rtHoriScr; 1056 CFX_RectF rtHoriScr;
1067 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { 1057 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
1068 rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + kEditMargin, 1058 rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + kEditMargin,
1069 m_rtClient.width, fWidth); 1059 m_rtClient.width, fWidth);
1070 } else { 1060 } else {
1071 rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth, 1061 rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth,
1072 m_rtClient.width, fWidth); 1062 m_rtClient.width, fWidth);
1073 if (bShowVertScrollbar) 1063 if (bShowVertScrollbar)
1074 rtHoriScr.width -= fWidth; 1064 rtHoriScr.width -= fWidth;
(...skipping 14 matching lines...) Expand all
1089 } 1079 }
1090 1080
1091 FX_FLOAT* pfWidth = nullptr; 1081 FX_FLOAT* pfWidth = nullptr;
1092 bool bShowVertScrollbar = IsShowScrollBar(true); 1082 bool bShowVertScrollbar = IsShowScrollBar(true);
1093 bool bShowHorzScrollbar = IsShowScrollBar(false); 1083 bool bShowHorzScrollbar = IsShowScrollBar(false);
1094 if (bShowVertScrollbar) { 1084 if (bShowVertScrollbar) {
1095 if (!m_pVertScrollBar) { 1085 if (!m_pVertScrollBar) {
1096 pfWidth = static_cast<FX_FLOAT*>( 1086 pfWidth = static_cast<FX_FLOAT*>(
1097 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 1087 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
1098 FX_FLOAT fWidth = pfWidth ? *pfWidth : 0; 1088 FX_FLOAT fWidth = pfWidth ? *pfWidth : 0;
1099 InitScrollBar(); 1089 InitVerticalScrollBar();
1100 CFX_RectF rtVertScr; 1090 CFX_RectF rtVertScr;
1101 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { 1091 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
1102 rtVertScr.Set(m_rtClient.right() + kEditMargin, m_rtClient.top, fWidth, 1092 rtVertScr.Set(m_rtClient.right() + kEditMargin, m_rtClient.top, fWidth,
1103 m_rtClient.height); 1093 m_rtClient.height);
1104 } else { 1094 } else {
1105 rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth, 1095 rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth,
1106 m_rtClient.height); 1096 m_rtClient.height);
1107 if (bShowHorzScrollbar) 1097 if (bShowHorzScrollbar)
1108 rtVertScr.height -= fWidth; 1098 rtVertScr.height -= fWidth;
1109 } 1099 }
1110 m_pVertScrollBar->SetWidgetRect(rtVertScr); 1100 m_pVertScrollBar->SetWidgetRect(rtVertScr);
1111 m_pVertScrollBar->Update(); 1101 m_pVertScrollBar->Update();
1112 } 1102 }
1113 m_pVertScrollBar->RemoveStates(FWL_WGTSTATE_Invisible); 1103 m_pVertScrollBar->RemoveStates(FWL_WGTSTATE_Invisible);
1114 } else if (m_pVertScrollBar) { 1104 } else if (m_pVertScrollBar) {
1115 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible); 1105 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible);
1116 } 1106 }
1117 1107
1118 if (bShowHorzScrollbar) { 1108 if (bShowHorzScrollbar) {
1119 if (!m_pHorzScrollBar) { 1109 if (!m_pHorzScrollBar) {
1120 if (!pfWidth) { 1110 if (!pfWidth) {
1121 pfWidth = static_cast<FX_FLOAT*>( 1111 pfWidth = static_cast<FX_FLOAT*>(
1122 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 1112 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
1123 } 1113 }
1124 1114
1125 FX_FLOAT fWidth = pfWidth ? *pfWidth : 0; 1115 FX_FLOAT fWidth = pfWidth ? *pfWidth : 0;
1126 InitScrollBar(false); 1116 InitHorizontalScrollBar();
1127 CFX_RectF rtHoriScr; 1117 CFX_RectF rtHoriScr;
1128 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { 1118 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
1129 rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + kEditMargin, 1119 rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + kEditMargin,
1130 m_rtClient.width, fWidth); 1120 m_rtClient.width, fWidth);
1131 } else { 1121 } else {
1132 rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth, 1122 rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth,
1133 m_rtClient.width, fWidth); 1123 m_rtClient.width, fWidth);
1134 if (bShowVertScrollbar) 1124 if (bShowVertScrollbar)
1135 rtHoriScr.width -= (fWidth); 1125 rtHoriScr.width -= (fWidth);
1136 } 1126 }
1137 m_pHorzScrollBar->SetWidgetRect(rtHoriScr); 1127 m_pHorzScrollBar->SetWidgetRect(rtHoriScr);
1138 m_pHorzScrollBar->Update(); 1128 m_pHorzScrollBar->Update();
1139 } 1129 }
1140 m_pHorzScrollBar->RemoveStates(FWL_WGTSTATE_Invisible); 1130 m_pHorzScrollBar->RemoveStates(FWL_WGTSTATE_Invisible);
1141 } else if (m_pHorzScrollBar) { 1131 } else if (m_pHorzScrollBar) {
1142 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible); 1132 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible);
1143 } 1133 }
1144 if (bShowVertScrollbar || bShowHorzScrollbar) 1134 if (bShowVertScrollbar || bShowHorzScrollbar)
1145 UpdateScroll(); 1135 UpdateScroll();
1146 } 1136 }
1147 1137
1148 void CFWL_Edit::DeviceToEngine(CFX_PointF& pt) { 1138 void CFWL_Edit::DeviceToEngine(CFX_PointF& pt) {
1149 pt.x += m_fScrollOffsetX - m_rtEngine.left; 1139 pt.x += m_fScrollOffsetX - m_rtEngine.left;
1150 pt.y += m_fScrollOffsetY - m_rtEngine.top - m_fVAlignOffset; 1140 pt.y += m_fScrollOffsetY - m_rtEngine.top - m_fVAlignOffset;
1151 } 1141 }
1152 1142
1153 void CFWL_Edit::InitScrollBar(bool bVert) { 1143 void CFWL_Edit::InitVerticalScrollBar() {
1154 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) 1144 if (m_pVertScrollBar)
1155 return; 1145 return;
1156 1146
1157 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(); 1147 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>();
1158 prop->m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; 1148 prop->m_dwStyleExes = FWL_STYLEEXT_SCB_Vert;
1159 prop->m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; 1149 prop->m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible;
1160 prop->m_pParent = this; 1150 prop->m_pParent = this;
1161 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider; 1151 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider;
1152 m_pVertScrollBar =
1153 pdfium::MakeUnique<CFWL_ScrollBar>(m_pOwnerApp, std::move(prop), this);
1154 }
1162 1155
1163 CFWL_ScrollBar* sb = new CFWL_ScrollBar(m_pOwnerApp, std::move(prop), this); 1156 void CFWL_Edit::InitHorizontalScrollBar() {
1164 if (bVert) 1157 if (m_pHorzScrollBar)
1165 m_pVertScrollBar.reset(sb); 1158 return;
1166 else 1159
1167 m_pHorzScrollBar.reset(sb); 1160 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>();
1161 prop->m_dwStyleExes = FWL_STYLEEXT_SCB_Horz;
1162 prop->m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible;
1163 prop->m_pParent = this;
1164 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider;
1165 m_pHorzScrollBar =
1166 pdfium::MakeUnique<CFWL_ScrollBar>(m_pOwnerApp, std::move(prop), this);
1168 } 1167 }
1169 1168
1170 void CFWL_Edit::ShowCaret(CFX_RectF* pRect) { 1169 void CFWL_Edit::ShowCaret(CFX_RectF* pRect) {
1171 if (m_pCaret) { 1170 if (m_pCaret) {
1172 m_pCaret->ShowCaret(); 1171 m_pCaret->ShowCaret();
1173 if (!pRect->IsEmpty()) 1172 if (!pRect->IsEmpty())
1174 m_pCaret->SetWidgetRect(*pRect); 1173 m_pCaret->SetWidgetRect(*pRect);
1175 Repaint(&m_rtEngine); 1174 Repaint(&m_rtEngine);
1176 return; 1175 return;
1177 } 1176 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 if (!pDocEnvironment) 1224 if (!pDocEnvironment)
1226 return; 1225 return;
1227 1226
1228 pDocEnvironment->DisplayCaret(pXFAWidget, false, pRect); 1227 pDocEnvironment->DisplayCaret(pXFAWidget, false, pRect);
1229 } 1228 }
1230 1229
1231 bool CFWL_Edit::ValidateNumberChar(FX_WCHAR cNum) { 1230 bool CFWL_Edit::ValidateNumberChar(FX_WCHAR cNum) {
1232 if (!m_bSetRange) 1231 if (!m_bSetRange)
1233 return true; 1232 return true;
1234 1233
1235 CFX_WideString wsText = m_EdtEngine.GetText(0); 1234 CFX_WideString wsText = m_EdtEngine.GetText(0, -1);
1236 if (wsText.IsEmpty()) { 1235 if (wsText.IsEmpty()) {
1237 if (cNum == L'0') 1236 if (cNum == L'0')
1238 return false; 1237 return false;
1239 return true; 1238 return true;
1240 } 1239 }
1241 1240
1242 int32_t caretPos = m_EdtEngine.GetCaretPos(); 1241 int32_t caretPos = m_EdtEngine.GetCaretPos();
1243 if (CountSelRanges() == 0) { 1242 if (CountSelRanges() == 0) {
1244 if (cNum == L'0' && caretPos == 0) 1243 if (cNum == L'0' && caretPos == 0)
1245 return false; 1244 return false;
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 UpdateOffset(pScrollBar, fPos - iCurPos); 1646 UpdateOffset(pScrollBar, fPos - iCurPos);
1648 UpdateCaret(); 1647 UpdateCaret();
1649 1648
1650 CFX_RectF rect; 1649 CFX_RectF rect;
1651 GetWidgetRect(rect, false); 1650 GetWidgetRect(rect, false);
1652 CFX_RectF rtInvalidate; 1651 CFX_RectF rtInvalidate;
1653 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); 1652 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2);
1654 Repaint(&rtInvalidate); 1653 Repaint(&rtInvalidate);
1655 return true; 1654 return true;
1656 } 1655 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/cfwl_edit.h ('k') | xfa/fwl/core/cfwl_form.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698