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

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

Issue 2557103002: Cleanup FWL default values part II. (Closed)
Patch Set: Unused 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
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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 } 291 }
292 292
293 void CFWL_Edit::SetText(const CFX_WideString& wsText) { 293 void CFWL_Edit::SetText(const CFX_WideString& wsText) {
294 m_EdtEngine.SetText(wsText); 294 m_EdtEngine.SetText(wsText);
295 } 295 }
296 296
297 int32_t CFWL_Edit::GetTextLength() const { 297 int32_t CFWL_Edit::GetTextLength() const {
298 return m_EdtEngine.GetTextLength(); 298 return m_EdtEngine.GetTextLength();
299 } 299 }
300 300
301 CFX_WideString CFWL_Edit::GetText(int32_t nStart, int32_t nCount) const { 301 CFX_WideString CFWL_Edit::GetText() const {
302 return m_EdtEngine.GetText(nStart, nCount); 302 return m_EdtEngine.GetText(0, -1);
303 } 303 }
304 304
305 void CFWL_Edit::ClearText() { 305 void CFWL_Edit::ClearText() {
306 m_EdtEngine.ClearText(); 306 m_EdtEngine.ClearText();
307 } 307 }
308 308
309 void CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { 309 void CFWL_Edit::AddSelRange(int32_t nStart) {
310 m_EdtEngine.AddSelRange(nStart, nCount); 310 m_EdtEngine.AddSelRange(nStart, -1);
311 } 311 }
312 312
313 int32_t CFWL_Edit::CountSelRanges() const { 313 int32_t CFWL_Edit::CountSelRanges() const {
314 return m_EdtEngine.CountSelRanges(); 314 return m_EdtEngine.CountSelRanges();
315 } 315 }
316 316
317 int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) const { 317 int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) const {
318 return m_EdtEngine.GetSelRange(nIndex, nStart); 318 return m_EdtEngine.GetSelRange(nIndex, nStart);
319 } 319 }
320 320
(...skipping 14 matching lines...) Expand all
335 m_EdtEngine.SetAliasChar(wAlias); 335 m_EdtEngine.SetAliasChar(wAlias);
336 } 336 }
337 337
338 bool CFWL_Edit::Copy(CFX_WideString& wsCopy) { 338 bool CFWL_Edit::Copy(CFX_WideString& wsCopy) {
339 int32_t nCount = m_EdtEngine.CountSelRanges(); 339 int32_t nCount = m_EdtEngine.CountSelRanges();
340 if (nCount == 0) 340 if (nCount == 0)
341 return false; 341 return false;
342 342
343 wsCopy.clear(); 343 wsCopy.clear();
344 CFX_WideString wsTemp; 344 CFX_WideString wsTemp;
345 int32_t nStart, nLength; 345 int32_t nStart;
346 int32_t nLength;
346 for (int32_t i = 0; i < nCount; i++) { 347 for (int32_t i = 0; i < nCount; i++) {
347 nLength = m_EdtEngine.GetSelRange(i, nStart); 348 nLength = m_EdtEngine.GetSelRange(i, nStart);
Tom Sepez 2016/12/07 17:33:32 nStart used uninitiaized? Or is it an out paramet
dsinclair 2016/12/07 18:28:49 Done. It was being passed as an int32_t&, changed
348 wsTemp = m_EdtEngine.GetText(nStart, nLength); 349 wsTemp = m_EdtEngine.GetText(nStart, nLength);
Tom Sepez 2016/12/07 17:33:32 wsTemp local to this block? Or eliminate
dsinclair 2016/12/07 18:28:49 Done.
349 wsCopy += wsTemp; 350 wsCopy += wsTemp;
350 wsTemp.clear(); 351 wsTemp.clear();
Tom Sepez 2016/12/07 17:33:32 no need to clear on each iteration if local.
dsinclair 2016/12/07 18:28:49 Done.
351 } 352 }
352 return true; 353 return true;
353 } 354 }
354 355
355 bool CFWL_Edit::Cut(CFX_WideString& wsCut) { 356 bool CFWL_Edit::Cut(CFX_WideString& wsCut) {
356 int32_t nCount = m_EdtEngine.CountSelRanges(); 357 int32_t nCount = m_EdtEngine.CountSelRanges();
357 if (nCount == 0) 358 if (nCount == 0)
358 return false; 359 return false;
359 360
360 wsCut.clear(); 361 wsCut.clear();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 411 }
411 412
412 bool CFWL_Edit::CanRedo() { 413 bool CFWL_Edit::CanRedo() {
413 return m_iCurRecord < pdfium::CollectionSize<int32_t>(m_DoRecords) - 1; 414 return m_iCurRecord < pdfium::CollectionSize<int32_t>(m_DoRecords) - 1;
414 } 415 }
415 416
416 void CFWL_Edit::SetOuter(CFWL_Widget* pOuter) { 417 void CFWL_Edit::SetOuter(CFWL_Widget* pOuter) {
417 m_pOuter = pOuter; 418 m_pOuter = pOuter;
418 } 419 }
419 420
420 void CFWL_Edit::On_CaretChanged(CFDE_TxtEdtEngine* pEdit, 421 void CFWL_Edit::On_CaretChanged() {
421 int32_t nPage,
422 bool bVisible) {
423 if (m_rtEngine.IsEmpty()) 422 if (m_rtEngine.IsEmpty())
424 return; 423 return;
425 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) 424 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
426 return; 425 return;
427 426
428 bool bRepaintContent = UpdateOffset(); 427 bool bRepaintContent = UpdateOffset();
429 UpdateCaret(); 428 UpdateCaret();
430 CFX_RectF rtInvalid; 429 CFX_RectF rtInvalid;
431 rtInvalid.Set(0, 0, 0, 0); 430 rtInvalid.Set(0, 0, 0, 0);
432 bool bRepaintScroll = false; 431 bool bRepaintScroll = false;
433 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { 432 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) {
434 CFWL_ScrollBar* pScroll = UpdateScroll(); 433 CFWL_ScrollBar* pScroll = UpdateScroll();
435 if (pScroll) { 434 if (pScroll) {
436 pScroll->GetWidgetRect(rtInvalid, false); 435 pScroll->GetWidgetRect(rtInvalid, false);
437 bRepaintScroll = true; 436 bRepaintScroll = true;
438 } 437 }
439 } 438 }
440 if (bRepaintContent || bRepaintScroll) { 439 if (bRepaintContent || bRepaintScroll) {
441 if (bRepaintContent) 440 if (bRepaintContent)
442 rtInvalid.Union(m_rtEngine); 441 rtInvalid.Union(m_rtEngine);
443 Repaint(&rtInvalid); 442 Repaint(&rtInvalid);
444 } 443 }
445 } 444 }
446 445
447 void CFWL_Edit::On_TextChanged(CFDE_TxtEdtEngine* pEdit, 446 void CFWL_Edit::On_TextChanged(FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) {
Tom Sepez 2016/12/07 17:33:32 nit: pass by const reference?
dsinclair 2016/12/07 18:28:49 Done.
448 FDE_TXTEDT_TEXTCHANGE_INFO& ChangeInfo) {
449 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VAlignMask) 447 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VAlignMask)
450 UpdateVAlignment(); 448 UpdateVAlignment();
451 449
452 CFX_RectF rtTemp; 450 CFX_RectF rtTemp;
453 GetClientRect(rtTemp); 451 GetClientRect(rtTemp);
454 452
455 CFWL_EvtTextChanged event; 453 CFWL_EvtTextChanged event;
456 event.m_pSrcTarget = this; 454 event.m_pSrcTarget = this;
457 event.wsPrevText = ChangeInfo.wsPrevText; 455 event.wsPrevText = ChangeInfo.wsPrevText;
458 DispatchEvent(&event); 456 DispatchEvent(&event);
459 457
460 LayoutScrollBar(); 458 LayoutScrollBar();
461 Repaint(&rtTemp); 459 Repaint(&rtTemp);
462 } 460 }
463 461
464 void CFWL_Edit::On_SelChanged(CFDE_TxtEdtEngine* pEdit) { 462 void CFWL_Edit::On_SelChanged() {
465 CFX_RectF rtTemp; 463 CFX_RectF rtTemp;
466 GetClientRect(rtTemp); 464 GetClientRect(rtTemp);
467 Repaint(&rtTemp); 465 Repaint(&rtTemp);
468 } 466 }
469 467
470 bool CFWL_Edit::On_PageLoad(CFDE_TxtEdtEngine* pEdit, 468 bool CFWL_Edit::On_PageLoad(int32_t nPageIndex) {
471 int32_t nPageIndex,
472 int32_t nPurpose) {
473 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(nPageIndex); 469 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(nPageIndex);
474 if (!pPage) 470 if (!pPage)
475 return false; 471 return false;
476 472
477 pPage->LoadPage(nullptr, nullptr); 473 pPage->LoadPage(nullptr, nullptr);
478 return true; 474 return true;
479 } 475 }
480 476
481 bool CFWL_Edit::On_PageUnload(CFDE_TxtEdtEngine* pEdit, 477 bool CFWL_Edit::On_PageUnload(int32_t nPageIndex) {
482 int32_t nPageIndex,
483 int32_t nPurpose) {
484 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(nPageIndex); 478 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(nPageIndex);
485 if (!pPage) 479 if (!pPage)
486 return false; 480 return false;
487 481
488 pPage->UnloadPage(nullptr); 482 pPage->UnloadPage(nullptr);
489 return true; 483 return true;
490 } 484 }
491 485
492 void CFWL_Edit::On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, 486 void CFWL_Edit::On_AddDoRecord(IFDE_TxtEdtDoRecord* pRecord) {
493 IFDE_TxtEdtDoRecord* pRecord) {
494 AddDoRecord(pRecord); 487 AddDoRecord(pRecord);
495 } 488 }
496 489
497 bool CFWL_Edit::On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText) { 490 bool CFWL_Edit::On_Validate(CFX_WideString& wsText) {
Tom Sepez 2016/12/07 17:33:32 nit: pass by const reference?
dsinclair 2016/12/07 18:28:49 Done.
498 CFWL_Widget* pDst = GetOuter(); 491 CFWL_Widget* pDst = GetOuter();
499 if (!pDst) 492 if (!pDst)
500 pDst = this; 493 pDst = this;
501 494
502 CFWL_EvtValidate event; 495 CFWL_EvtValidate event;
503 event.m_pSrcTarget = this; 496 event.m_pSrcTarget = this;
504 event.wsInsert = wsText; 497 event.wsInsert = wsText;
505 event.bValidate = true; 498 event.bValidate = true;
506 DispatchEvent(&event); 499 DispatchEvent(&event);
507 return event.bValidate; 500 return event.bValidate;
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine); 980 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine);
988 } 981 }
989 982
990 bool CFWL_Edit::IsContentHeightOverflow() { 983 bool CFWL_Edit::IsContentHeightOverflow() {
991 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); 984 IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0);
992 if (!pPage) 985 if (!pPage)
993 return false; 986 return false;
994 return pPage->GetContentsBox().height > m_rtEngine.height + 1.0f; 987 return pPage->GetContentsBox().height > m_rtEngine.height + 1.0f;
995 } 988 }
996 989
997 int32_t CFWL_Edit::AddDoRecord(IFDE_TxtEdtDoRecord* pRecord) { 990 int32_t CFWL_Edit::AddDoRecord(IFDE_TxtEdtDoRecord* pRecord) {
Tom Sepez 2016/12/07 17:33:32 This should be called with the unique_ptr<> itself
dsinclair 2016/12/07 18:28:49 Done.
998 int32_t nCount = pdfium::CollectionSize<int32_t>(m_DoRecords); 991 int32_t nCount = pdfium::CollectionSize<int32_t>(m_DoRecords);
999 if (m_iCurRecord == nCount - 1) { 992 if (m_iCurRecord == nCount - 1) {
1000 if (nCount == m_iMaxRecord) { 993 if (nCount == m_iMaxRecord) {
1001 m_DoRecords.pop_front(); 994 m_DoRecords.pop_front();
1002 m_iCurRecord--; 995 m_iCurRecord--;
1003 } 996 }
1004 } else { 997 } else {
1005 m_DoRecords.erase(m_DoRecords.begin() + m_iCurRecord + 1, 998 m_DoRecords.erase(m_DoRecords.begin() + m_iCurRecord + 1,
1006 m_DoRecords.end()); 999 m_DoRecords.end());
1007 } 1000 }
(...skipping 27 matching lines...) Expand all
1035 &part, CFWL_WidgetCapacity::UIMargin)); 1028 &part, CFWL_WidgetCapacity::UIMargin));
1036 if (pUIMargin) { 1029 if (pUIMargin) {
1037 m_rtEngine.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, 1030 m_rtEngine.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width,
1038 pUIMargin->height); 1031 pUIMargin->height);
1039 } 1032 }
1040 } 1033 }
1041 1034
1042 bool bShowVertScrollbar = IsShowScrollBar(true); 1035 bool bShowVertScrollbar = IsShowScrollBar(true);
1043 bool bShowHorzScrollbar = IsShowScrollBar(false); 1036 bool bShowHorzScrollbar = IsShowScrollBar(false);
1044 if (bShowVertScrollbar) { 1037 if (bShowVertScrollbar) {
1045 InitScrollBar(); 1038 InitVerticalScrollBar();
1046 1039
1047 CFX_RectF rtVertScr; 1040 CFX_RectF rtVertScr;
1048 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { 1041 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
1049 rtVertScr.Set(m_rtClient.right() + kEditMargin, m_rtClient.top, fWidth, 1042 rtVertScr.Set(m_rtClient.right() + kEditMargin, m_rtClient.top, fWidth,
1050 m_rtClient.height); 1043 m_rtClient.height);
1051 } else { 1044 } else {
1052 rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth, 1045 rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth,
1053 m_rtClient.height); 1046 m_rtClient.height);
1054 if (bShowHorzScrollbar) 1047 if (bShowHorzScrollbar)
1055 rtVertScr.height -= fWidth; 1048 rtVertScr.height -= fWidth;
1056 m_rtEngine.width -= fWidth; 1049 m_rtEngine.width -= fWidth;
1057 } 1050 }
1058 1051
1059 m_pVertScrollBar->SetWidgetRect(rtVertScr); 1052 m_pVertScrollBar->SetWidgetRect(rtVertScr);
1060 m_pVertScrollBar->RemoveStates(FWL_WGTSTATE_Invisible); 1053 m_pVertScrollBar->RemoveStates(FWL_WGTSTATE_Invisible);
1061 m_pVertScrollBar->Update(); 1054 m_pVertScrollBar->Update();
1062 } else if (m_pVertScrollBar) { 1055 } else if (m_pVertScrollBar) {
1063 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible); 1056 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible);
1064 } 1057 }
1065 1058
1066 if (bShowHorzScrollbar) { 1059 if (bShowHorzScrollbar) {
1067 InitScrollBar(false); 1060 InitHorizontalScrollBar();
1068 1061
1069 CFX_RectF rtHoriScr; 1062 CFX_RectF rtHoriScr;
1070 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { 1063 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
1071 rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + kEditMargin, 1064 rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + kEditMargin,
1072 m_rtClient.width, fWidth); 1065 m_rtClient.width, fWidth);
1073 } else { 1066 } else {
1074 rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth, 1067 rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth,
1075 m_rtClient.width, fWidth); 1068 m_rtClient.width, fWidth);
1076 if (bShowVertScrollbar) 1069 if (bShowVertScrollbar)
1077 rtHoriScr.width -= fWidth; 1070 rtHoriScr.width -= fWidth;
(...skipping 14 matching lines...) Expand all
1092 } 1085 }
1093 1086
1094 FX_FLOAT* pfWidth = nullptr; 1087 FX_FLOAT* pfWidth = nullptr;
1095 bool bShowVertScrollbar = IsShowScrollBar(true); 1088 bool bShowVertScrollbar = IsShowScrollBar(true);
1096 bool bShowHorzScrollbar = IsShowScrollBar(false); 1089 bool bShowHorzScrollbar = IsShowScrollBar(false);
1097 if (bShowVertScrollbar) { 1090 if (bShowVertScrollbar) {
1098 if (!m_pVertScrollBar) { 1091 if (!m_pVertScrollBar) {
1099 pfWidth = static_cast<FX_FLOAT*>( 1092 pfWidth = static_cast<FX_FLOAT*>(
1100 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 1093 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
1101 FX_FLOAT fWidth = pfWidth ? *pfWidth : 0; 1094 FX_FLOAT fWidth = pfWidth ? *pfWidth : 0;
1102 InitScrollBar(); 1095 InitVerticalScrollBar();
1103 CFX_RectF rtVertScr; 1096 CFX_RectF rtVertScr;
1104 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { 1097 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
1105 rtVertScr.Set(m_rtClient.right() + kEditMargin, m_rtClient.top, fWidth, 1098 rtVertScr.Set(m_rtClient.right() + kEditMargin, m_rtClient.top, fWidth,
1106 m_rtClient.height); 1099 m_rtClient.height);
1107 } else { 1100 } else {
1108 rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth, 1101 rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth,
1109 m_rtClient.height); 1102 m_rtClient.height);
1110 if (bShowHorzScrollbar) 1103 if (bShowHorzScrollbar)
1111 rtVertScr.height -= fWidth; 1104 rtVertScr.height -= fWidth;
1112 } 1105 }
1113 m_pVertScrollBar->SetWidgetRect(rtVertScr); 1106 m_pVertScrollBar->SetWidgetRect(rtVertScr);
1114 m_pVertScrollBar->Update(); 1107 m_pVertScrollBar->Update();
1115 } 1108 }
1116 m_pVertScrollBar->RemoveStates(FWL_WGTSTATE_Invisible); 1109 m_pVertScrollBar->RemoveStates(FWL_WGTSTATE_Invisible);
1117 } else if (m_pVertScrollBar) { 1110 } else if (m_pVertScrollBar) {
1118 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible); 1111 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible);
1119 } 1112 }
1120 1113
1121 if (bShowHorzScrollbar) { 1114 if (bShowHorzScrollbar) {
1122 if (!m_pHorzScrollBar) { 1115 if (!m_pHorzScrollBar) {
1123 if (!pfWidth) { 1116 if (!pfWidth) {
1124 pfWidth = static_cast<FX_FLOAT*>( 1117 pfWidth = static_cast<FX_FLOAT*>(
1125 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 1118 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
1126 } 1119 }
1127 1120
1128 FX_FLOAT fWidth = pfWidth ? *pfWidth : 0; 1121 FX_FLOAT fWidth = pfWidth ? *pfWidth : 0;
1129 InitScrollBar(false); 1122 InitHorizontalScrollBar();
1130 CFX_RectF rtHoriScr; 1123 CFX_RectF rtHoriScr;
1131 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { 1124 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
1132 rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + kEditMargin, 1125 rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + kEditMargin,
1133 m_rtClient.width, fWidth); 1126 m_rtClient.width, fWidth);
1134 } else { 1127 } else {
1135 rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth, 1128 rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth,
1136 m_rtClient.width, fWidth); 1129 m_rtClient.width, fWidth);
1137 if (bShowVertScrollbar) 1130 if (bShowVertScrollbar)
1138 rtHoriScr.width -= (fWidth); 1131 rtHoriScr.width -= (fWidth);
1139 } 1132 }
1140 m_pHorzScrollBar->SetWidgetRect(rtHoriScr); 1133 m_pHorzScrollBar->SetWidgetRect(rtHoriScr);
1141 m_pHorzScrollBar->Update(); 1134 m_pHorzScrollBar->Update();
1142 } 1135 }
1143 m_pHorzScrollBar->RemoveStates(FWL_WGTSTATE_Invisible); 1136 m_pHorzScrollBar->RemoveStates(FWL_WGTSTATE_Invisible);
1144 } else if (m_pHorzScrollBar) { 1137 } else if (m_pHorzScrollBar) {
1145 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible); 1138 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible);
1146 } 1139 }
1147 if (bShowVertScrollbar || bShowHorzScrollbar) 1140 if (bShowVertScrollbar || bShowHorzScrollbar)
1148 UpdateScroll(); 1141 UpdateScroll();
1149 } 1142 }
1150 1143
1151 void CFWL_Edit::DeviceToEngine(CFX_PointF& pt) { 1144 void CFWL_Edit::DeviceToEngine(CFX_PointF& pt) {
1152 pt.x += m_fScrollOffsetX - m_rtEngine.left; 1145 pt.x += m_fScrollOffsetX - m_rtEngine.left;
1153 pt.y += m_fScrollOffsetY - m_rtEngine.top - m_fVAlignOffset; 1146 pt.y += m_fScrollOffsetY - m_rtEngine.top - m_fVAlignOffset;
1154 } 1147 }
1155 1148
1156 void CFWL_Edit::InitScrollBar(bool bVert) { 1149 void CFWL_Edit::InitVerticalScrollBar() {
1157 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) 1150 if (m_pVertScrollBar)
1158 return; 1151 return;
1159 1152
1160 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(); 1153 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>();
1161 prop->m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; 1154 prop->m_dwStyleExes = FWL_STYLEEXT_SCB_Vert;
1162 prop->m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; 1155 prop->m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible;
1163 prop->m_pParent = this; 1156 prop->m_pParent = this;
1164 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider; 1157 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider;
1158 m_pVertScrollBar =
1159 pdfium::MakeUnique<CFWL_ScrollBar>(m_pOwnerApp, std::move(prop), this);
1160 }
1165 1161
1166 CFWL_ScrollBar* sb = new CFWL_ScrollBar(m_pOwnerApp, std::move(prop), this); 1162 void CFWL_Edit::InitHorizontalScrollBar() {
1167 if (bVert) 1163 if (m_pHorzScrollBar)
1168 m_pVertScrollBar.reset(sb); 1164 return;
1169 else 1165
1170 m_pHorzScrollBar.reset(sb); 1166 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>();
1167 prop->m_dwStyleExes = FWL_STYLEEXT_SCB_Horz;
1168 prop->m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible;
1169 prop->m_pParent = this;
1170 prop->m_pThemeProvider = m_pProperties->m_pThemeProvider;
1171 m_pHorzScrollBar =
1172 pdfium::MakeUnique<CFWL_ScrollBar>(m_pOwnerApp, std::move(prop), this);
1171 } 1173 }
1172 1174
1173 void CFWL_Edit::ShowCaret(CFX_RectF* pRect) { 1175 void CFWL_Edit::ShowCaret(CFX_RectF* pRect) {
1174 if (m_pCaret) { 1176 if (m_pCaret) {
1175 m_pCaret->ShowCaret(); 1177 m_pCaret->ShowCaret();
1176 if (!pRect->IsEmpty()) 1178 if (!pRect->IsEmpty())
1177 m_pCaret->SetWidgetRect(*pRect); 1179 m_pCaret->SetWidgetRect(*pRect);
1178 Repaint(&m_rtEngine); 1180 Repaint(&m_rtEngine);
1179 return; 1181 return;
1180 } 1182 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 if (!pDocEnvironment) 1230 if (!pDocEnvironment)
1229 return; 1231 return;
1230 1232
1231 pDocEnvironment->DisplayCaret(pXFAWidget, false, pRect); 1233 pDocEnvironment->DisplayCaret(pXFAWidget, false, pRect);
1232 } 1234 }
1233 1235
1234 bool CFWL_Edit::ValidateNumberChar(FX_WCHAR cNum) { 1236 bool CFWL_Edit::ValidateNumberChar(FX_WCHAR cNum) {
1235 if (!m_bSetRange) 1237 if (!m_bSetRange)
1236 return true; 1238 return true;
1237 1239
1238 CFX_WideString wsText = m_EdtEngine.GetText(0); 1240 CFX_WideString wsText = m_EdtEngine.GetText(0, -1);
1239 if (wsText.IsEmpty()) { 1241 if (wsText.IsEmpty()) {
1240 if (cNum == L'0') 1242 if (cNum == L'0')
1241 return false; 1243 return false;
1242 return true; 1244 return true;
1243 } 1245 }
1244 1246
1245 int32_t caretPos = m_EdtEngine.GetCaretPos(); 1247 int32_t caretPos = m_EdtEngine.GetCaretPos();
1246 if (CountSelRanges() == 0) { 1248 if (CountSelRanges() == 0) {
1247 if (cNum == L'0' && caretPos == 0) 1249 if (cNum == L'0' && caretPos == 0)
1248 return false; 1250 return false;
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 UpdateOffset(pScrollBar, fPos - iCurPos); 1652 UpdateOffset(pScrollBar, fPos - iCurPos);
1651 UpdateCaret(); 1653 UpdateCaret();
1652 1654
1653 CFX_RectF rect; 1655 CFX_RectF rect;
1654 GetWidgetRect(rect, false); 1656 GetWidgetRect(rect, false);
1655 CFX_RectF rtInvalidate; 1657 CFX_RectF rtInvalidate;
1656 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); 1658 rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2);
1657 Repaint(&rtInvalidate); 1659 Repaint(&rtInvalidate);
1658 return true; 1660 return true;
1659 } 1661 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698