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

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

Issue 2556873004: Convert GetWidgetRect to return rect. (Closed)
Patch Set: 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_combobox.h" 7 #include "xfa/fwl/core/cfwl_combobox.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 SetStates(m_pProperties->m_dwStates); 66 SetStates(m_pProperties->m_dwStates);
67 } 67 }
68 68
69 CFWL_ComboBox::~CFWL_ComboBox() {} 69 CFWL_ComboBox::~CFWL_ComboBox() {}
70 70
71 FWL_Type CFWL_ComboBox::GetClassID() const { 71 FWL_Type CFWL_ComboBox::GetClassID() const {
72 return FWL_Type::ComboBox; 72 return FWL_Type::ComboBox;
73 } 73 }
74 74
75 void CFWL_ComboBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { 75 CFX_RectF CFWL_ComboBox::GetWidgetRect(bool bAutoSize) {
76 if (!bAutoSize) { 76 if (!bAutoSize)
77 rect = m_pProperties->m_rtWidget; 77 return m_pProperties->m_rtWidget;
78 return;
79 }
80 78
81 rect.Reset(); 79 CFX_RectF rect;
82 if (IsDropDownStyle() && m_pEdit) { 80 if (IsDropDownStyle() && m_pEdit) {
83 m_pEdit->GetWidgetRect(rect, true); 81 rect = m_pEdit->GetWidgetRect(true);
84 } else { 82 } else {
85 rect.width = 100; 83 rect.width = 100;
86 rect.height = 16; 84 rect.height = 16;
87 } 85 }
88 if (!m_pProperties->m_pThemeProvider) 86 if (!m_pProperties->m_pThemeProvider)
89 ResetTheme(); 87 ResetTheme();
90 88
91 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( 89 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>(
92 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 90 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
93 if (!pFWidth) 91 if (!pFWidth)
94 return; 92 return rect;
95 93
96 rect.Inflate(0, 0, *pFWidth, 0); 94 rect.Inflate(0, 0, *pFWidth, 0);
97 InflateWidgetRect(rect); 95 InflateWidgetRect(rect);
96 return rect;
98 } 97 }
99 98
100 void CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { 99 void CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) {
101 m_pListBox->AddString(wsText); 100 m_pListBox->AddString(wsText);
102 } 101 }
103 102
104 bool CFWL_ComboBox::RemoveAt(int32_t iIndex) { 103 bool CFWL_ComboBox::RemoveAt(int32_t iIndex) {
105 return m_pListBox->RemoveAt(iIndex); 104 return m_pListBox->RemoveAt(iIndex);
106 } 105 }
107 106
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 } 312 }
314 313
315 CFX_RectF CFWL_ComboBox::GetBBox() const { 314 CFX_RectF CFWL_ComboBox::GetBBox() const {
316 if (m_pWidgetMgr->IsFormDisabled()) 315 if (m_pWidgetMgr->IsFormDisabled())
317 return DisForm_GetBBox(); 316 return DisForm_GetBBox();
318 317
319 CFX_RectF rect = m_pProperties->m_rtWidget; 318 CFX_RectF rect = m_pProperties->m_rtWidget;
320 if (!m_pListBox || !IsDropListVisible()) 319 if (!m_pListBox || !IsDropListVisible())
321 return rect; 320 return rect;
322 321
323 CFX_RectF rtList; 322 CFX_RectF rtList = m_pListBox->GetWidgetRect(false);
324 m_pListBox->GetWidgetRect(rtList, false);
325 rtList.Offset(rect.left, rect.top); 323 rtList.Offset(rect.left, rect.top);
326 rect.Union(rtList); 324 rect.Union(rtList);
327 return rect; 325 return rect;
328 } 326 }
329 327
330 void CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, 328 void CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded,
331 uint32_t dwStylesExRemoved) { 329 uint32_t dwStylesExRemoved) {
332 if (m_pEdit) 330 if (m_pEdit)
333 m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 331 m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
334 } 332 }
(...skipping 28 matching lines...) Expand all
363 SetFocus(true); 361 SetFocus(true);
364 return; 362 return;
365 } 363 }
366 364
367 m_pListBox->ChangeSelected(m_iCurSel); 365 m_pListBox->ChangeSelected(m_iCurSel);
368 ResetListItemAlignment(); 366 ResetListItemAlignment();
369 367
370 uint32_t dwStyleAdd = m_pProperties->m_dwStyleExes & 368 uint32_t dwStyleAdd = m_pProperties->m_dwStyleExes &
371 (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw); 369 (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw);
372 m_pListBox->ModifyStylesEx(dwStyleAdd, 0); 370 m_pListBox->ModifyStylesEx(dwStyleAdd, 0);
373 m_pListBox->GetWidgetRect(m_rtList, true); 371 m_rtList = m_pListBox->GetWidgetRect(true);
374 372
375 CFX_RectF rtAnchor; 373 CFX_RectF rtAnchor;
376 rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width, 374 rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width,
377 m_pProperties->m_rtWidget.height); 375 m_pProperties->m_rtWidget.height);
378 376
379 m_rtList.width = std::max(m_rtList.width, m_rtClient.width); 377 m_rtList.width = std::max(m_rtList.width, m_rtClient.width);
380 m_rtProxy = m_rtList; 378 m_rtProxy = m_rtList;
381 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag) 379 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListDrag)
382 m_rtProxy.height += m_fComboFormHandler; 380 m_rtProxy.height += m_fComboFormHandler;
383 381
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 } 637 }
640 638
641 if (bActivate) { 639 if (bActivate) {
642 m_pListBox->RemoveStates(FWL_WGTSTATE_Invisible); 640 m_pListBox->RemoveStates(FWL_WGTSTATE_Invisible);
643 CFWL_Event postEvent(CFWL_Event::Type::PostDropDown, this); 641 CFWL_Event postEvent(CFWL_Event::Type::PostDropDown, this);
644 DispatchEvent(&postEvent); 642 DispatchEvent(&postEvent);
645 } else { 643 } else {
646 m_pListBox->SetStates(FWL_WGTSTATE_Invisible); 644 m_pListBox->SetStates(FWL_WGTSTATE_Invisible);
647 } 645 }
648 646
649 CFX_RectF rect; 647 CFX_RectF rect = m_pListBox->GetWidgetRect(false);
650 m_pListBox->GetWidgetRect(rect, false);
651 rect.Inflate(2, 2); 648 rect.Inflate(2, 2);
652 Repaint(&rect); 649 Repaint(&rect);
653 } 650 }
654 651
655 void CFWL_ComboBox::DisForm_ModifyStylesEx(uint32_t dwStylesExAdded, 652 void CFWL_ComboBox::DisForm_ModifyStylesEx(uint32_t dwStylesExAdded,
656 uint32_t dwStylesExRemoved) { 653 uint32_t dwStylesExRemoved) {
657 if (!m_pEdit) 654 if (!m_pEdit)
658 DisForm_InitComboEdit(); 655 DisForm_InitComboEdit();
659 656
660 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown); 657 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown);
(...skipping 20 matching lines...) Expand all
681 678
682 FWL_WidgetHit CFWL_ComboBox::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) { 679 FWL_WidgetHit CFWL_ComboBox::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) {
683 CFX_RectF rect; 680 CFX_RectF rect;
684 rect.Set(0, 0, m_pProperties->m_rtWidget.width - m_rtBtn.width, 681 rect.Set(0, 0, m_pProperties->m_rtWidget.width - m_rtBtn.width,
685 m_pProperties->m_rtWidget.height); 682 m_pProperties->m_rtWidget.height);
686 if (rect.Contains(fx, fy)) 683 if (rect.Contains(fx, fy))
687 return FWL_WidgetHit::Edit; 684 return FWL_WidgetHit::Edit;
688 if (m_rtBtn.Contains(fx, fy)) 685 if (m_rtBtn.Contains(fx, fy))
689 return FWL_WidgetHit::Client; 686 return FWL_WidgetHit::Client;
690 if (DisForm_IsDropListVisible()) { 687 if (DisForm_IsDropListVisible()) {
691 m_pListBox->GetWidgetRect(rect, false); 688 rect = m_pListBox->GetWidgetRect(false);
692 if (rect.Contains(fx, fy)) 689 if (rect.Contains(fx, fy))
693 return FWL_WidgetHit::Client; 690 return FWL_WidgetHit::Client;
694 } 691 }
695 return FWL_WidgetHit::Unknown; 692 return FWL_WidgetHit::Unknown;
696 } 693 }
697 694
698 void CFWL_ComboBox::DisForm_DrawWidget(CFX_Graphics* pGraphics, 695 void CFWL_ComboBox::DisForm_DrawWidget(CFX_Graphics* pGraphics,
699 const CFX_Matrix* pMatrix) { 696 const CFX_Matrix* pMatrix) {
700 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 697 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
701 CFX_Matrix mtOrg; 698 CFX_Matrix mtOrg;
702 mtOrg.Set(1, 0, 0, 1, 0, 0); 699 mtOrg.Set(1, 0, 0, 1, 0, 0);
703 if (pMatrix) 700 if (pMatrix)
704 mtOrg = *pMatrix; 701 mtOrg = *pMatrix;
705 702
706 pGraphics->SaveGraphState(); 703 pGraphics->SaveGraphState();
707 pGraphics->ConcatMatrix(&mtOrg); 704 pGraphics->ConcatMatrix(&mtOrg);
708 if (!m_rtBtn.IsEmpty(0.1f)) { 705 if (!m_rtBtn.IsEmpty(0.1f)) {
709 CFWL_ThemeBackground param; 706 CFWL_ThemeBackground param;
710 param.m_pWidget = this; 707 param.m_pWidget = this;
711 param.m_iPart = CFWL_Part::DropDownButton; 708 param.m_iPart = CFWL_Part::DropDownButton;
712 param.m_dwStates = m_iBtnState; 709 param.m_dwStates = m_iBtnState;
713 param.m_pGraphics = pGraphics; 710 param.m_pGraphics = pGraphics;
714 param.m_rtPart = m_rtBtn; 711 param.m_rtPart = m_rtBtn;
715 pTheme->DrawBackground(&param); 712 pTheme->DrawBackground(&param);
716 } 713 }
717 pGraphics->RestoreGraphState(); 714 pGraphics->RestoreGraphState();
718 715
719 if (m_pEdit) { 716 if (m_pEdit) {
720 CFX_RectF rtEdit; 717 CFX_RectF rtEdit = m_pEdit->GetWidgetRect(false);
721 m_pEdit->GetWidgetRect(rtEdit, false);
722 CFX_Matrix mt; 718 CFX_Matrix mt;
723 mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top); 719 mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top);
724 mt.Concat(mtOrg); 720 mt.Concat(mtOrg);
725 m_pEdit->DrawWidget(pGraphics, &mt); 721 m_pEdit->DrawWidget(pGraphics, &mt);
726 } 722 }
727 if (m_pListBox && DisForm_IsDropListVisible()) { 723 if (m_pListBox && DisForm_IsDropListVisible()) {
728 CFX_RectF rtList; 724 CFX_RectF rtList = m_pListBox->GetWidgetRect(false);
729 m_pListBox->GetWidgetRect(rtList, false);
730 CFX_Matrix mt; 725 CFX_Matrix mt;
731 mt.Set(1, 0, 0, 1, rtList.left, rtList.top); 726 mt.Set(1, 0, 0, 1, rtList.left, rtList.top);
732 mt.Concat(mtOrg); 727 mt.Concat(mtOrg);
733 m_pListBox->DrawWidget(pGraphics, &mt); 728 m_pListBox->DrawWidget(pGraphics, &mt);
734 } 729 }
735 } 730 }
736 731
737 CFX_RectF CFWL_ComboBox::DisForm_GetBBox() const { 732 CFX_RectF CFWL_ComboBox::DisForm_GetBBox() const {
738 CFX_RectF rect = m_pProperties->m_rtWidget; 733 CFX_RectF rect = m_pProperties->m_rtWidget;
739 if (!m_pListBox || !DisForm_IsDropListVisible()) 734 if (!m_pListBox || !DisForm_IsDropListVisible())
740 return rect; 735 return rect;
741 736
742 CFX_RectF rtList; 737 CFX_RectF rtList = m_pListBox->GetWidgetRect(false);
743 m_pListBox->GetWidgetRect(rtList, false);
744 rtList.Offset(rect.left, rect.top); 738 rtList.Offset(rect.left, rect.top);
745 rect.Union(rtList); 739 rect.Union(rtList);
746 return rect; 740 return rect;
747 } 741 }
748 742
749 void CFWL_ComboBox::DisForm_Layout() { 743 void CFWL_ComboBox::DisForm_Layout() {
750 GetClientRect(m_rtClient); 744 GetClientRect(m_rtClient);
751 m_rtContent = m_rtClient; 745 m_rtContent = m_rtClient;
752 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( 746 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>(
753 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 747 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 else 1093 else
1100 iCurSel++; 1094 iCurSel++;
1101 } 1095 }
1102 m_iCurSel = iCurSel; 1096 m_iCurSel = iCurSel;
1103 SyncEditText(m_iCurSel); 1097 SyncEditText(m_iCurSel);
1104 return; 1098 return;
1105 } 1099 }
1106 if (m_pEdit) 1100 if (m_pEdit)
1107 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); 1101 m_pEdit->GetDelegate()->OnProcessMessage(pMsg);
1108 } 1102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698