From da911bc12558667555266425d0b7e83296e8cc7d Mon Sep 17 00:00:00 2001 From: dsinclair Date: Wed, 7 Dec 2016 18:47:00 -0800 Subject: Convert GetWidgetRect to return rect. Current GetWidgetRect accepts the rect as an out-param. This CL converts the code to return the rect instead. Review-Url: https://codereview.chromium.org/2556873004 --- xfa/fwl/core/cfwl_caret.cpp | 6 ++-- xfa/fwl/core/cfwl_checkbox.cpp | 26 +------------- xfa/fwl/core/cfwl_checkbox.h | 1 - xfa/fwl/core/cfwl_combobox.cpp | 44 ++++------------------- xfa/fwl/core/cfwl_combobox.h | 1 - xfa/fwl/core/cfwl_comboboxproxy.cpp | 6 ++-- xfa/fwl/core/cfwl_combolist.cpp | 9 ++--- xfa/fwl/core/cfwl_datetimeedit.cpp | 3 +- xfa/fwl/core/cfwl_datetimepicker.cpp | 61 ++++++++----------------------- xfa/fwl/core/cfwl_datetimepicker.h | 2 -- xfa/fwl/core/cfwl_edit.cpp | 69 +++++++++++++++--------------------- xfa/fwl/core/cfwl_edit.h | 3 +- xfa/fwl/core/cfwl_form.cpp | 14 -------- xfa/fwl/core/cfwl_form.h | 1 - xfa/fwl/core/cfwl_listbox.cpp | 21 ++--------- xfa/fwl/core/cfwl_listbox.h | 1 - xfa/fwl/core/cfwl_monthcalendar.cpp | 12 +++---- xfa/fwl/core/cfwl_monthcalendar.h | 2 +- xfa/fwl/core/cfwl_picturebox.cpp | 10 ------ xfa/fwl/core/cfwl_picturebox.h | 1 - xfa/fwl/core/cfwl_pushbutton.cpp | 16 --------- xfa/fwl/core/cfwl_pushbutton.h | 1 - xfa/fwl/core/cfwl_scrollbar.cpp | 19 ---------- xfa/fwl/core/cfwl_scrollbar.h | 1 - xfa/fwl/core/cfwl_spinbutton.cpp | 13 ------- xfa/fwl/core/cfwl_spinbutton.h | 1 - xfa/fwl/core/cfwl_widget.cpp | 28 +++++++-------- xfa/fwl/core/cfwl_widget.h | 3 +- xfa/fwl/core/cfwl_widgetmgr.cpp | 24 +++++-------- xfa/fxfa/app/xfa_ffbarcode.cpp | 3 +- xfa/fxfa/app/xfa_fffield.cpp | 26 ++++++-------- xfa/fxfa/app/xfa_ffimageedit.cpp | 3 +- xfa/fxfa/app/xfa_ffpushbutton.cpp | 7 ++-- 33 files changed, 108 insertions(+), 330 deletions(-) diff --git a/xfa/fwl/core/cfwl_caret.cpp b/xfa/fwl/core/cfwl_caret.cpp index 0457347b66..f9e26a7e9f 100644 --- a/xfa/fwl/core/cfwl_caret.cpp +++ b/xfa/fwl/core/cfwl_caret.cpp @@ -76,8 +76,7 @@ void CFWL_Caret::DrawCaretBK(CFX_Graphics* pGraphics, if (!(m_pProperties->m_dwStates & FWL_STATE_CAT_HightLight)) return; - CFX_RectF rect; - GetWidgetRect(rect, false); + CFX_RectF rect = GetWidgetRect(); rect.Set(0, 0, rect.width, rect.height); CFWL_ThemeBackground param; @@ -107,8 +106,7 @@ void CFWL_Caret::Timer::Run(CFWL_TimerInfo* pTimerInfo) { else pCaret->RemoveStates(FWL_STATE_CAT_HightLight); - CFX_RectF rt; - pCaret->GetWidgetRect(rt, false); + CFX_RectF rt = pCaret->GetWidgetRect(); rt.Set(0, 0, rt.width + 1, rt.height); pCaret->Repaint(&rt); } diff --git a/xfa/fwl/core/cfwl_checkbox.cpp b/xfa/fwl/core/cfwl_checkbox.cpp index 4183551f68..8d99d7acf5 100644 --- a/xfa/fwl/core/cfwl_checkbox.cpp +++ b/xfa/fwl/core/cfwl_checkbox.cpp @@ -50,29 +50,6 @@ void CFWL_CheckBox::SetBoxSize(FX_FLOAT fHeight) { m_fBoxHeight = fHeight; } -void CFWL_CheckBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (!bAutoSize) { - rect = m_pProperties->m_rtWidget; - return; - } - - rect.Set(0, 0, 0, 0); - if (!m_pProperties->m_pThemeProvider) - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - if (!m_pProperties->m_pThemeProvider) - return; - - CFX_SizeF sz = CalcTextSize( - L"Check box", m_pProperties->m_pThemeProvider, - !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine)); - rect.Set(0, 0, sz.x, sz.y); - rect.Inflate(kCaptionMargin, kCaptionMargin); - - rect.width += m_fBoxHeight; - rect.height = std::max(rect.height, m_fBoxHeight); - InflateWidgetRect(rect); -} - void CFWL_CheckBox::Update() { if (IsLocked()) return; @@ -308,8 +285,7 @@ void CFWL_CheckBox::NextStates() { if (pCheckBox != this && pCheckBox->GetStates() & FWL_STATE_CKB_Checked) { pCheckBox->SetCheckState(0); - CFX_RectF rt; - pCheckBox->GetWidgetRect(rt, false); + CFX_RectF rt = pCheckBox->GetWidgetRect(); rt.left = rt.top = 0; m_pWidgetMgr->RepaintWidget(pCheckBox, &rt); break; diff --git a/xfa/fwl/core/cfwl_checkbox.h b/xfa/fwl/core/cfwl_checkbox.h index ace09e57c9..f699aa0059 100644 --- a/xfa/fwl/core/cfwl_checkbox.h +++ b/xfa/fwl/core/cfwl_checkbox.h @@ -55,7 +55,6 @@ class CFWL_CheckBox : public CFWL_Widget { // CFWL_Widget FWL_Type GetClassID() const override; - void GetWidgetRect(CFX_RectF& rect, bool bAutoSize) override; void Update() override; void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; diff --git a/xfa/fwl/core/cfwl_combobox.cpp b/xfa/fwl/core/cfwl_combobox.cpp index 3c0337ed57..bfc3f32f46 100644 --- a/xfa/fwl/core/cfwl_combobox.cpp +++ b/xfa/fwl/core/cfwl_combobox.cpp @@ -72,31 +72,6 @@ FWL_Type CFWL_ComboBox::GetClassID() const { return FWL_Type::ComboBox; } -void CFWL_ComboBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (!bAutoSize) { - rect = m_pProperties->m_rtWidget; - return; - } - - rect.Reset(); - if (IsDropDownStyle() && m_pEdit) { - m_pEdit->GetWidgetRect(rect, true); - } else { - rect.width = 100; - rect.height = 16; - } - if (!m_pProperties->m_pThemeProvider) - ResetTheme(); - - FX_FLOAT* pFWidth = static_cast( - GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); - if (!pFWidth) - return; - - rect.Inflate(0, 0, *pFWidth, 0); - InflateWidgetRect(rect); -} - void CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { m_pListBox->AddString(wsText); } @@ -320,8 +295,7 @@ CFX_RectF CFWL_ComboBox::GetBBox() const { if (!m_pListBox || !IsDropListVisible()) return rect; - CFX_RectF rtList; - m_pListBox->GetWidgetRect(rtList, false); + CFX_RectF rtList = m_pListBox->GetWidgetRect(); rtList.Offset(rect.left, rect.top); rect.Union(rtList); return rect; @@ -370,7 +344,7 @@ void CFWL_ComboBox::ShowDropList(bool bActivate) { uint32_t dwStyleAdd = m_pProperties->m_dwStyleExes & (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw); m_pListBox->ModifyStylesEx(dwStyleAdd, 0); - m_pListBox->GetWidgetRect(m_rtList, true); + m_rtList = m_pListBox->GetAutosizedWidgetRect(); CFX_RectF rtAnchor; rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width, @@ -646,8 +620,7 @@ void CFWL_ComboBox::DisForm_ShowDropList(bool bActivate) { m_pListBox->SetStates(FWL_WGTSTATE_Invisible); } - CFX_RectF rect; - m_pListBox->GetWidgetRect(rect, false); + CFX_RectF rect = m_pListBox->GetWidgetRect(); rect.Inflate(2, 2); Repaint(&rect); } @@ -688,7 +661,7 @@ FWL_WidgetHit CFWL_ComboBox::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) { if (m_rtBtn.Contains(fx, fy)) return FWL_WidgetHit::Client; if (DisForm_IsDropListVisible()) { - m_pListBox->GetWidgetRect(rect, false); + rect = m_pListBox->GetWidgetRect(); if (rect.Contains(fx, fy)) return FWL_WidgetHit::Client; } @@ -717,16 +690,14 @@ void CFWL_ComboBox::DisForm_DrawWidget(CFX_Graphics* pGraphics, pGraphics->RestoreGraphState(); if (m_pEdit) { - CFX_RectF rtEdit; - m_pEdit->GetWidgetRect(rtEdit, false); + CFX_RectF rtEdit = m_pEdit->GetWidgetRect(); CFX_Matrix mt; mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top); mt.Concat(mtOrg); m_pEdit->DrawWidget(pGraphics, &mt); } if (m_pListBox && DisForm_IsDropListVisible()) { - CFX_RectF rtList; - m_pListBox->GetWidgetRect(rtList, false); + CFX_RectF rtList = m_pListBox->GetWidgetRect(); CFX_Matrix mt; mt.Set(1, 0, 0, 1, rtList.left, rtList.top); mt.Concat(mtOrg); @@ -739,8 +710,7 @@ CFX_RectF CFWL_ComboBox::DisForm_GetBBox() const { if (!m_pListBox || !DisForm_IsDropListVisible()) return rect; - CFX_RectF rtList; - m_pListBox->GetWidgetRect(rtList, false); + CFX_RectF rtList = m_pListBox->GetWidgetRect(); rtList.Offset(rect.left, rect.top); rect.Union(rtList); return rect; diff --git a/xfa/fwl/core/cfwl_combobox.h b/xfa/fwl/core/cfwl_combobox.h index b10a571b2c..26c54b5377 100644 --- a/xfa/fwl/core/cfwl_combobox.h +++ b/xfa/fwl/core/cfwl_combobox.h @@ -54,7 +54,6 @@ class CFWL_ComboBox : public CFWL_Widget { // CFWL_Widget FWL_Type GetClassID() const override; - void GetWidgetRect(CFX_RectF& rect, bool bAutoSize) override; void ModifyStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved) override; void SetStates(uint32_t dwStates) override; diff --git a/xfa/fwl/core/cfwl_comboboxproxy.cpp b/xfa/fwl/core/cfwl_comboboxproxy.cpp index be45f2b729..b7c56378cf 100644 --- a/xfa/fwl/core/cfwl_comboboxproxy.cpp +++ b/xfa/fwl/core/cfwl_comboboxproxy.cpp @@ -70,8 +70,7 @@ void CFWL_ComboBoxProxy::OnLButtonDown(CFWL_Message* pMessage) { CFWL_NoteDriver* pDriver = static_cast(pApp->GetNoteDriver()); - CFX_RectF rtWidget; - GetWidgetRect(rtWidget, false); + CFX_RectF rtWidget = GetWidgetRect(); rtWidget.left = rtWidget.top = 0; CFWL_MsgMouse* pMsg = static_cast(pMessage); @@ -100,8 +99,7 @@ void CFWL_ComboBoxProxy::OnLButtonUp(CFWL_Message* pMessage) { } CFWL_MsgMouse* pMsg = static_cast(pMessage); - CFX_RectF rect; - GetWidgetRect(rect, false); + CFX_RectF rect = GetWidgetRect(); rect.left = rect.top = 0; if (!rect.Contains(pMsg->m_fx, pMsg->m_fy) && m_pComboBox->IsDropListVisible()) { diff --git a/xfa/fwl/core/cfwl_combolist.cpp b/xfa/fwl/core/cfwl_combolist.cpp index 7532da26d7..ff7bd2722c 100644 --- a/xfa/fwl/core/cfwl_combolist.cpp +++ b/xfa/fwl/core/cfwl_combolist.cpp @@ -86,8 +86,7 @@ void CFWL_ComboList::OnProcessMessage(CFWL_Message* pMessage) { CFWL_MsgMouse* pMsg = static_cast(pMessage); CFWL_ScrollBar* vertSB = GetVertScrollBar(); if (IsShowScrollBar(true) && vertSB) { - CFX_RectF rect; - vertSB->GetWidgetRect(rect, false); + CFX_RectF rect = vertSB->GetWidgetRect(); if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) { pMsg->m_fx -= rect.left; pMsg->m_fy -= rect.top; @@ -140,8 +139,7 @@ void CFWL_ComboList::OnDropListMouseMove(CFWL_MsgMouse* pMsg) { CFWL_ScrollBar* vertSB = GetVertScrollBar(); if (IsShowScrollBar(true) && vertSB) { - CFX_RectF rect; - vertSB->GetWidgetRect(rect, false); + CFX_RectF rect = vertSB->GetWidgetRect(); if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) return; } @@ -176,8 +174,7 @@ void CFWL_ComboList::OnDropListLButtonUp(CFWL_MsgMouse* pMsg) { CFWL_ScrollBar* vertSB = GetVertScrollBar(); if (IsShowScrollBar(true) && vertSB) { - CFX_RectF rect; - vertSB->GetWidgetRect(rect, false); + CFX_RectF rect = vertSB->GetWidgetRect(); if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) return; } diff --git a/xfa/fwl/core/cfwl_datetimeedit.cpp b/xfa/fwl/core/cfwl_datetimeedit.cpp index fc3edcf52b..37d79b6024 100644 --- a/xfa/fwl/core/cfwl_datetimeedit.cpp +++ b/xfa/fwl/core/cfwl_datetimeedit.cpp @@ -50,8 +50,7 @@ void CFWL_DateTimeEdit::DisForm_OnProcessMessage(CFWL_Message* pMessage) { CFWL_DateTimePicker* pDateTime = static_cast(m_pOuter); if (pDateTime->IsMonthCalendarVisible()) { - CFX_RectF rtInvalidate; - pDateTime->GetWidgetRect(rtInvalidate, false); + CFX_RectF rtInvalidate = pDateTime->GetWidgetRect(); pDateTime->ShowMonthCalendar(false); rtInvalidate.Offset(-rtInvalidate.left, -rtInvalidate.top); pDateTime->Repaint(&rtInvalidate); diff --git a/xfa/fwl/core/cfwl_datetimepicker.cpp b/xfa/fwl/core/cfwl_datetimepicker.cpp index 651b1b38c8..63f8955a0e 100644 --- a/xfa/fwl/core/cfwl_datetimepicker.cpp +++ b/xfa/fwl/core/cfwl_datetimepicker.cpp @@ -23,7 +23,6 @@ namespace { -const int kDateTimePickerWidth = 100; const int kDateTimePickerHeight = 20; } // namespace @@ -46,8 +45,7 @@ CFWL_DateTimePicker::CFWL_DateTimePicker(const CFWL_App* app) m_pMonthCal.reset( new CFWL_MonthCalendar(m_pOwnerApp, std::move(monthProp), this)); - CFX_RectF rtMonthCal; - m_pMonthCal->GetWidgetRect(rtMonthCal, true); + CFX_RectF rtMonthCal = m_pMonthCal->GetAutosizedWidgetRect(); rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); m_pMonthCal->SetWidgetRect(rtMonthCal); @@ -68,20 +66,6 @@ FWL_Type CFWL_DateTimePicker::GetClassID() const { return FWL_Type::DateTimePicker; } -void CFWL_DateTimePicker::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (m_pWidgetMgr->IsFormDisabled()) { - DisForm_GetWidgetRect(rect, bAutoSize); - return; - } - if (!bAutoSize) { - rect = m_pProperties->m_rtWidget; - return; - } - - rect.Set(0, 0, kDateTimePickerWidth, kDateTimePickerHeight); - InflateWidgetRect(rect); -} - void CFWL_DateTimePicker::Update() { if (m_pWidgetMgr->IsFormDisabled()) { DisForm_Update(); @@ -112,8 +96,7 @@ void CFWL_DateTimePicker::Update() { if (!(m_pMonthCal->GetThemeProvider())) m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider); - CFX_RectF rtMonthCal; - m_pMonthCal->GetWidgetRect(rtMonthCal, true); + CFX_RectF rtMonthCal = m_pMonthCal->GetAutosizedWidgetRect(); CFX_RectF rtPopUp; rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, rtMonthCal.width, rtMonthCal.height); @@ -128,8 +111,7 @@ FWL_WidgetHit CFWL_DateTimePicker::HitTest(FX_FLOAT fx, FX_FLOAT fy) { if (m_rtClient.Contains(fx, fy)) return FWL_WidgetHit::Client; if (IsMonthCalendarVisible()) { - CFX_RectF rect; - m_pMonthCal->GetWidgetRect(rect, false); + CFX_RectF rect = m_pMonthCal->GetWidgetRect(); if (rect.Contains(fx, fy)) return FWL_WidgetHit::Client; } @@ -208,8 +190,7 @@ void CFWL_DateTimePicker::GetBBox(CFX_RectF& rect) const { rect = m_pProperties->m_rtWidget; if (IsMonthCalendarVisible()) { - CFX_RectF rtMonth; - m_pMonthCal->GetWidgetRect(rtMonth, false); + CFX_RectF rtMonth = m_pMonthCal->GetWidgetRect(); rtMonth.Offset(m_pProperties->m_rtWidget.left, m_pProperties->m_rtWidget.top); rect.Union(rtMonth); @@ -266,8 +247,7 @@ void CFWL_DateTimePicker::ShowMonthCalendar(bool bActivate) { return; } - CFX_RectF rtMonth; - m_pMonthCal->GetWidgetRect(rtMonth, false); + CFX_RectF rtMonth = m_pMonthCal->GetWidgetRect(); CFX_RectF rtAnchor; rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width, @@ -383,8 +363,7 @@ void CFWL_DateTimePicker::DisForm_ShowMonthCalendar(bool bActivate) { return; if (bActivate) { - CFX_RectF rtMonthCal; - m_pMonthCal->GetWidgetRect(rtMonthCal, true); + CFX_RectF rtMonthCal = m_pMonthCal->GetAutosizedWidgetRect(); FX_FLOAT fPopupMin = rtMonthCal.height; FX_FLOAT fPopupMax = rtMonthCal.height; CFX_RectF rtAnchor(m_pProperties->m_rtWidget); @@ -407,10 +386,11 @@ void CFWL_DateTimePicker::DisForm_ShowMonthCalendar(bool bActivate) { m_pEdit->GetDelegate()->OnProcessMessage(&msg); } - CFX_RectF rtInvalidate, rtCal; + CFX_RectF rtInvalidate; rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, m_pProperties->m_rtWidget.height); - m_pMonthCal->GetWidgetRect(rtCal, false); + + CFX_RectF rtCal = m_pMonthCal->GetWidgetRect(); rtInvalidate.Union(rtCal); rtInvalidate.Inflate(2, 2); Repaint(&rtInvalidate); @@ -428,8 +408,7 @@ FWL_WidgetHit CFWL_DateTimePicker::DisForm_HitTest(FX_FLOAT fx, if (rect.Contains(fx, fy)) return FWL_WidgetHit::Client; if (IsMonthCalendarVisible()) { - m_pMonthCal->GetWidgetRect(rect, false); - if (rect.Contains(fx, fy)) + if (m_pMonthCal->GetWidgetRect().Contains(fx, fy)) return FWL_WidgetHit::Client; } return FWL_WidgetHit::Unknown; @@ -462,9 +441,7 @@ void CFWL_DateTimePicker::DisForm_Update() { return; m_fBtn = *pWidth; - CFX_RectF rtMonthCal; - m_pMonthCal->GetWidgetRect(rtMonthCal, true); - + CFX_RectF rtMonthCal = m_pMonthCal->GetAutosizedWidgetRect(); CFX_RectF rtPopUp; rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, rtMonthCal.width, rtMonthCal.height); @@ -472,13 +449,6 @@ void CFWL_DateTimePicker::DisForm_Update() { m_pMonthCal->Update(); } -void CFWL_DateTimePicker::DisForm_GetWidgetRect(CFX_RectF& rect, - bool bAutoSize) { - rect = m_pProperties->m_rtWidget; - if (DisForm_IsNeedShowButton()) - rect.width += m_fBtn; -} - void CFWL_DateTimePicker::DisForm_GetBBox(CFX_RectF& rect) const { rect = m_pProperties->m_rtWidget; if (DisForm_IsNeedShowButton()) @@ -486,8 +456,7 @@ void CFWL_DateTimePicker::DisForm_GetBBox(CFX_RectF& rect) const { if (!IsMonthCalendarVisible()) return; - CFX_RectF rtMonth; - m_pMonthCal->GetWidgetRect(rtMonth, false); + CFX_RectF rtMonth = m_pMonthCal->GetWidgetRect(); rtMonth.Offset(m_pProperties->m_rtWidget.left, m_pProperties->m_rtWidget.top); rect.Union(rtMonth); } @@ -497,8 +466,7 @@ void CFWL_DateTimePicker::DisForm_DrawWidget(CFX_Graphics* pGraphics, if (!pGraphics) return; if (m_pEdit) { - CFX_RectF rtEdit; - m_pEdit->GetWidgetRect(rtEdit, false); + CFX_RectF rtEdit = m_pEdit->GetWidgetRect(); CFX_Matrix mt; mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top); @@ -509,8 +477,7 @@ void CFWL_DateTimePicker::DisForm_DrawWidget(CFX_Graphics* pGraphics, if (!IsMonthCalendarVisible()) return; - CFX_RectF rtMonth; - m_pMonthCal->GetWidgetRect(rtMonth, false); + CFX_RectF rtMonth = m_pMonthCal->GetWidgetRect(); CFX_Matrix mt; mt.Set(1, 0, 0, 1, rtMonth.left, rtMonth.top); if (pMatrix) diff --git a/xfa/fwl/core/cfwl_datetimepicker.h b/xfa/fwl/core/cfwl_datetimepicker.h index d6d47ebb2f..e88cdc2f96 100644 --- a/xfa/fwl/core/cfwl_datetimepicker.h +++ b/xfa/fwl/core/cfwl_datetimepicker.h @@ -42,7 +42,6 @@ class CFWL_DateTimePicker : public CFWL_Widget { // CFWL_Widget FWL_Type GetClassID() const override; - void GetWidgetRect(CFX_RectF& rect, bool bAutoSize) override; void Update() override; FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; @@ -93,7 +92,6 @@ class CFWL_DateTimePicker : public CFWL_Widget { FWL_WidgetHit DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) const; bool DisForm_IsNeedShowButton() const; void DisForm_Update(); - void DisForm_GetWidgetRect(CFX_RectF& rect, bool bAutoSize); void DisForm_GetBBox(CFX_RectF& rect) const; void DisForm_DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix); void DisForm_OnFocusChanged(CFWL_Message* pMsg, bool bSet); diff --git a/xfa/fwl/core/cfwl_edit.cpp b/xfa/fwl/core/cfwl_edit.cpp index 28ab71bac0..c6c0ce29ba 100644 --- a/xfa/fwl/core/cfwl_edit.cpp +++ b/xfa/fwl/core/cfwl_edit.cpp @@ -89,37 +89,35 @@ FWL_Type CFWL_Edit::GetClassID() const { return FWL_Type::Edit; } -void CFWL_Edit::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (!bAutoSize) { - rect = m_pProperties->m_rtWidget; - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { - if (IsShowScrollBar(true)) { - FX_FLOAT* pfWidth = static_cast( - GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); - rect.width += *pfWidth; - rect.width += kEditMargin; - } - if (IsShowScrollBar(false)) { - FX_FLOAT* pfWidth = static_cast( - GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); - rect.height += *pfWidth; - rect.height += kEditMargin; - } +CFX_RectF CFWL_Edit::GetWidgetRect() { + CFX_RectF rect = m_pProperties->m_rtWidget; + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { + if (IsShowScrollBar(true)) { + FX_FLOAT* pfWidth = static_cast( + GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); + rect.width += *pfWidth; + rect.width += kEditMargin; + } + if (IsShowScrollBar(false)) { + FX_FLOAT* pfWidth = static_cast( + GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); + rect.height += *pfWidth; + rect.height += kEditMargin; } - return; } + return rect; +} - rect.Set(0, 0, 0, 0); - - int32_t iTextLen = m_EdtEngine.GetTextLength(); - if (iTextLen > 0) { - CFX_WideString wsText = m_EdtEngine.GetText(0, -1); +CFX_RectF CFWL_Edit::GetAutosizedWidgetRect() { + CFX_RectF rect; + if (m_EdtEngine.GetTextLength() > 0) { CFX_SizeF sz = CalcTextSize( - wsText, m_pProperties->m_pThemeProvider, + m_EdtEngine.GetText(0, -1), m_pProperties->m_pThemeProvider, !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine)); rect.Set(0, 0, sz.x, sz.y); } InflateWidgetRect(rect); + return rect; } void CFWL_Edit::SetStates(uint32_t dwStates) { @@ -149,15 +147,11 @@ void CFWL_Edit::Update() { FWL_WidgetHit CFWL_Edit::HitTest(FX_FLOAT fx, FX_FLOAT fy) { if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { if (IsShowScrollBar(true)) { - CFX_RectF rect; - m_pVertScrollBar->GetWidgetRect(rect, false); - if (rect.Contains(fx, fy)) + if (m_pVertScrollBar->GetWidgetRect().Contains(fx, fy)) return FWL_WidgetHit::VScrollBar; } if (IsShowScrollBar(false)) { - CFX_RectF rect; - m_pHorzScrollBar->GetWidgetRect(rect, false); - if (rect.Contains(fx, fy)) + if (m_pHorzScrollBar->GetWidgetRect().Contains(fx, fy)) return FWL_WidgetHit::HScrollBar; } } @@ -428,7 +422,7 @@ void CFWL_Edit::OnCaretChanged() { if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { CFWL_ScrollBar* pScroll = UpdateScroll(); if (pScroll) { - pScroll->GetWidgetRect(rtInvalid, false); + rtInvalid = pScroll->GetWidgetRect(); bRepaintScroll = true; } } @@ -519,8 +513,7 @@ void CFWL_Edit::DrawTextBk(CFX_Graphics* pGraphics, if (!IsShowScrollBar(true) || !IsShowScrollBar(false)) return; - CFX_RectF rtScroll; - m_pHorzScrollBar->GetWidgetRect(rtScroll, false); + CFX_RectF rtScroll = m_pHorzScrollBar->GetWidgetRect(); CFX_RectF rtStatic; rtStatic.Set(m_rtClient.right() - rtScroll.height, @@ -903,8 +896,7 @@ CFWL_ScrollBar* CFWL_Edit::UpdateScroll() { const CFX_RectF& rtFDE = pPage->GetContentsBox(); CFWL_ScrollBar* pRepaint = nullptr; if (bShowHorz) { - CFX_RectF rtScroll; - m_pHorzScrollBar->GetWidgetRect(rtScroll, false); + CFX_RectF rtScroll = m_pHorzScrollBar->GetWidgetRect(); if (rtScroll.width < rtFDE.width) { m_pHorzScrollBar->LockUpdate(); FX_FLOAT fRange = rtFDE.width - rtScroll.width; @@ -930,8 +922,7 @@ CFWL_ScrollBar* CFWL_Edit::UpdateScroll() { } if (bShowVert) { - CFX_RectF rtScroll; - m_pVertScrollBar->GetWidgetRect(rtScroll, false); + CFX_RectF rtScroll = m_pVertScrollBar->GetWidgetRect(); if (rtScroll.height < rtFDE.height) { m_pVertScrollBar->LockUpdate(); FX_FLOAT fStep = m_EdtEngine.GetEditParams()->fLineSpace; @@ -1180,8 +1171,7 @@ void CFWL_Edit::ShowCaret(CFX_RectF* pRect) { while (pOuter->GetOuter()) { pOuter = pOuter->GetOuter(); - CFX_RectF rtOuter; - pOuter->GetWidgetRect(rtOuter, false); + CFX_RectF rtOuter = pOuter->GetWidgetRect(); pRect->Offset(rtOuter.left, rtOuter.top); } @@ -1646,8 +1636,7 @@ bool CFWL_Edit::OnScroll(CFWL_ScrollBar* pScrollBar, UpdateOffset(pScrollBar, fPos - iCurPos); UpdateCaret(); - CFX_RectF rect; - GetWidgetRect(rect, false); + CFX_RectF rect = GetWidgetRect(); CFX_RectF rtInvalidate; rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); Repaint(&rtInvalidate); diff --git a/xfa/fwl/core/cfwl_edit.h b/xfa/fwl/core/cfwl_edit.h index 8143c7d5ed..d31f148cd0 100644 --- a/xfa/fwl/core/cfwl_edit.h +++ b/xfa/fwl/core/cfwl_edit.h @@ -65,7 +65,8 @@ class CFWL_Edit : public CFWL_Widget { // CFWL_Widget: FWL_Type GetClassID() const override; - void GetWidgetRect(CFX_RectF& rect, bool bAutoSize) override; + CFX_RectF GetAutosizedWidgetRect() override; + CFX_RectF GetWidgetRect() override; void Update() override; FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; void SetStates(uint32_t dwStates) override; diff --git a/xfa/fwl/core/cfwl_form.cpp b/xfa/fwl/core/cfwl_form.cpp index 60f0de3862..5b494fe1e2 100644 --- a/xfa/fwl/core/cfwl_form.cpp +++ b/xfa/fwl/core/cfwl_form.cpp @@ -80,20 +80,6 @@ bool CFWL_Form::IsInstance(const CFX_WideStringC& wsClass) const { return CFWL_Widget::IsInstance(wsClass); } -void CFWL_Form::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (!bAutoSize) { - rect = m_pProperties->m_rtWidget; - return; - } - - rect.Reset(); - FX_FLOAT fCXBorder = GetBorderSize(true); - FX_FLOAT fCYBorder = GetBorderSize(false); - FX_FLOAT fEdge = GetEdgeWidth(); - rect.height += fCYBorder + fEdge + fEdge; - rect.width += fCXBorder + fCXBorder + fEdge + fEdge; -} - void CFWL_Form::GetClientRect(CFX_RectF& rect) { rect = m_pProperties->m_rtWidget; rect.Offset(-rect.left, -rect.top); diff --git a/xfa/fwl/core/cfwl_form.h b/xfa/fwl/core/cfwl_form.h index fc7c47be3b..847256a57c 100644 --- a/xfa/fwl/core/cfwl_form.h +++ b/xfa/fwl/core/cfwl_form.h @@ -43,7 +43,6 @@ class CFWL_Form : public CFWL_Widget { // CFWL_Widget FWL_Type GetClassID() const override; bool IsInstance(const CFX_WideStringC& wsClass) const override; - void GetWidgetRect(CFX_RectF& rect, bool bAutoSize) override; void GetClientRect(CFX_RectF& rect) override; void Update() override; FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; diff --git a/xfa/fwl/core/cfwl_listbox.cpp b/xfa/fwl/core/cfwl_listbox.cpp index 5dd37d15d7..45898b1ed7 100644 --- a/xfa/fwl/core/cfwl_listbox.cpp +++ b/xfa/fwl/core/cfwl_listbox.cpp @@ -49,21 +49,6 @@ FWL_Type CFWL_ListBox::GetClassID() const { return FWL_Type::ListBox; } -void CFWL_ListBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (!bAutoSize) { - rect = m_pProperties->m_rtWidget; - return; - } - - rect.Set(0, 0, 0, 0); - if (!m_pProperties->m_pThemeProvider) - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - - CFX_SizeF fs = CalcSize(true); - rect.Set(0, 0, fs.x, fs.y); - InflateWidgetRect(rect); -} - void CFWL_ListBox::Update() { if (IsLocked()) return; @@ -95,14 +80,12 @@ void CFWL_ListBox::Update() { FWL_WidgetHit CFWL_ListBox::HitTest(FX_FLOAT fx, FX_FLOAT fy) { if (IsShowScrollBar(false)) { - CFX_RectF rect; - m_pHorzScrollBar->GetWidgetRect(rect, false); + CFX_RectF rect = m_pHorzScrollBar->GetWidgetRect(); if (rect.Contains(fx, fy)) return FWL_WidgetHit::HScrollBar; } if (IsShowScrollBar(true)) { - CFX_RectF rect; - m_pVertScrollBar->GetWidgetRect(rect, false); + CFX_RectF rect = m_pVertScrollBar->GetWidgetRect(); if (rect.Contains(fx, fy)) return FWL_WidgetHit::VScrollBar; } diff --git a/xfa/fwl/core/cfwl_listbox.h b/xfa/fwl/core/cfwl_listbox.h index 0cfe1f0367..905a040326 100644 --- a/xfa/fwl/core/cfwl_listbox.h +++ b/xfa/fwl/core/cfwl_listbox.h @@ -47,7 +47,6 @@ class CFWL_ListBox : public CFWL_Widget { // CFWL_Widget FWL_Type GetClassID() const override; - void GetWidgetRect(CFX_RectF& rect, bool bAutoSize) override; void Update() override; FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; diff --git a/xfa/fwl/core/cfwl_monthcalendar.cpp b/xfa/fwl/core/cfwl_monthcalendar.cpp index c182338460..8a284aae52 100644 --- a/xfa/fwl/core/cfwl_monthcalendar.cpp +++ b/xfa/fwl/core/cfwl_monthcalendar.cpp @@ -160,15 +160,12 @@ FWL_Type CFWL_MonthCalendar::GetClassID() const { return FWL_Type::MonthCalendar; } -void CFWL_MonthCalendar::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (!bAutoSize) { - rect = m_pProperties->m_rtWidget; - return; - } - +CFX_RectF CFWL_MonthCalendar::GetAutosizedWidgetRect() { CFX_SizeF fs = CalcSize(); + CFX_RectF rect; rect.Set(0, 0, fs.x, fs.y); InflateWidgetRect(rect); + return rect; } void CFWL_MonthCalendar::Update() { @@ -976,9 +973,8 @@ void CFWL_MonthCalendar::OnLButtonUp(CFWL_MsgMouse* pMsg) { iOldSel = m_arrSelDays[0]; int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); - CFX_RectF rt; CFWL_DateTimePicker* pIPicker = static_cast(m_pOuter); - pIPicker->GetFormProxy()->GetWidgetRect(rt, false); + CFX_RectF rt = pIPicker->GetFormProxy()->GetWidgetRect(); rt.Set(0, 0, rt.width, rt.height); if (iCurSel > 0) { DATEINFO* lpDatesInfo = m_arrDates.GetAt(iCurSel - 1); diff --git a/xfa/fwl/core/cfwl_monthcalendar.h b/xfa/fwl/core/cfwl_monthcalendar.h index 15912e59c3..7586a586f6 100644 --- a/xfa/fwl/core/cfwl_monthcalendar.h +++ b/xfa/fwl/core/cfwl_monthcalendar.h @@ -35,7 +35,7 @@ class CFWL_MonthCalendar : public CFWL_Widget { // FWL_WidgetImp FWL_Type GetClassID() const override; - void GetWidgetRect(CFX_RectF& rect, bool bAutoSize) override; + CFX_RectF GetAutosizedWidgetRect() override; void Update() override; void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; void OnProcessMessage(CFWL_Message* pMessage) override; diff --git a/xfa/fwl/core/cfwl_picturebox.cpp b/xfa/fwl/core/cfwl_picturebox.cpp index 3c95033aa0..96a52c9638 100644 --- a/xfa/fwl/core/cfwl_picturebox.cpp +++ b/xfa/fwl/core/cfwl_picturebox.cpp @@ -23,16 +23,6 @@ FWL_Type CFWL_PictureBox::GetClassID() const { return FWL_Type::PictureBox; } -void CFWL_PictureBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (!bAutoSize) { - rect = m_pProperties->m_rtWidget; - return; - } - - rect.Set(0, 0, 0, 0); - InflateWidgetRect(rect); -} - void CFWL_PictureBox::Update() { if (IsLocked()) return; diff --git a/xfa/fwl/core/cfwl_picturebox.h b/xfa/fwl/core/cfwl_picturebox.h index 37127048de..f4ece5bb2d 100644 --- a/xfa/fwl/core/cfwl_picturebox.h +++ b/xfa/fwl/core/cfwl_picturebox.h @@ -37,7 +37,6 @@ class CFWL_PictureBox : public CFWL_Widget { // CFWL_Widget FWL_Type GetClassID() const override; - void GetWidgetRect(CFX_RectF& rect, bool bAutoSize) override; void Update() override; void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; void OnDrawWidget(CFX_Graphics* pGraphics, diff --git a/xfa/fwl/core/cfwl_pushbutton.cpp b/xfa/fwl/core/cfwl_pushbutton.cpp index a2f9b5f1cf..d3bf7e6552 100644 --- a/xfa/fwl/core/cfwl_pushbutton.cpp +++ b/xfa/fwl/core/cfwl_pushbutton.cpp @@ -35,22 +35,6 @@ FWL_Type CFWL_PushButton::GetClassID() const { return FWL_Type::PushButton; } -void CFWL_PushButton::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (!bAutoSize) { - rect = m_pProperties->m_rtWidget; - return; - } - - rect.Set(0, 0, 0, 0); - if (!m_pProperties->m_pThemeProvider) - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - - FX_FLOAT* fcaption = - static_cast(GetThemeCapacity(CFWL_WidgetCapacity::Margin)); - rect.Inflate(*fcaption, *fcaption); - InflateWidgetRect(rect); -} - void CFWL_PushButton::SetStates(uint32_t dwStates) { if (dwStates & FWL_WGTSTATE_Disabled) { m_pProperties->m_dwStates = FWL_WGTSTATE_Disabled; diff --git a/xfa/fwl/core/cfwl_pushbutton.h b/xfa/fwl/core/cfwl_pushbutton.h index 68f2278258..e5bd295a8c 100644 --- a/xfa/fwl/core/cfwl_pushbutton.h +++ b/xfa/fwl/core/cfwl_pushbutton.h @@ -39,7 +39,6 @@ class CFWL_PushButton : public CFWL_Widget { // CFWL_Widget FWL_Type GetClassID() const override; - void GetWidgetRect(CFX_RectF& rect, bool bAutoSize) override; void SetStates(uint32_t dwStates) override; void Update() override; void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; diff --git a/xfa/fwl/core/cfwl_scrollbar.cpp b/xfa/fwl/core/cfwl_scrollbar.cpp index 8b3ce51195..6c2ad99601 100644 --- a/xfa/fwl/core/cfwl_scrollbar.cpp +++ b/xfa/fwl/core/cfwl_scrollbar.cpp @@ -62,25 +62,6 @@ FWL_Type CFWL_ScrollBar::GetClassID() const { return FWL_Type::ScrollBar; } -void CFWL_ScrollBar::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (!bAutoSize) { - rect = m_pProperties->m_rtWidget; - return; - } - - rect.Set(0, 0, 0, 0); - FX_FLOAT* pfMinWidth = static_cast( - GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); - if (!pfMinWidth) - return; - if (IsVertical()) - rect.Set(0, 0, (*pfMinWidth), (*pfMinWidth) * 3); - else - rect.Set(0, 0, (*pfMinWidth) * 3, (*pfMinWidth)); - - InflateWidgetRect(rect); -} - void CFWL_ScrollBar::Update() { if (IsLocked()) return; diff --git a/xfa/fwl/core/cfwl_scrollbar.h b/xfa/fwl/core/cfwl_scrollbar.h index fb44af6908..f1eb35b327 100644 --- a/xfa/fwl/core/cfwl_scrollbar.h +++ b/xfa/fwl/core/cfwl_scrollbar.h @@ -29,7 +29,6 @@ class CFWL_ScrollBar : public CFWL_Widget { // CFWL_Widget FWL_Type GetClassID() const override; - void GetWidgetRect(CFX_RectF& rect, bool bAutoSize) override; void Update() override; void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; void OnProcessMessage(CFWL_Message* pMessage) override; diff --git a/xfa/fwl/core/cfwl_spinbutton.cpp b/xfa/fwl/core/cfwl_spinbutton.cpp index 03ec5afdf8..68844f9900 100644 --- a/xfa/fwl/core/cfwl_spinbutton.cpp +++ b/xfa/fwl/core/cfwl_spinbutton.cpp @@ -20,9 +20,6 @@ #include "xfa/fwl/core/ifwl_themeprovider.h" namespace { - -const int kMinWidth = 18; -const int kMinHeight = 32; const int kElapseTime = 200; } // namespace @@ -49,16 +46,6 @@ FWL_Type CFWL_SpinButton::GetClassID() const { return FWL_Type::SpinButton; } -void CFWL_SpinButton::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (!bAutoSize) { - rect = m_pProperties->m_rtWidget; - return; - } - - rect.Set(0, 0, kMinWidth, kMinHeight); - InflateWidgetRect(rect); -} - void CFWL_SpinButton::Update() { if (IsLocked()) return; diff --git a/xfa/fwl/core/cfwl_spinbutton.h b/xfa/fwl/core/cfwl_spinbutton.h index fd2f02e998..dc480071ec 100644 --- a/xfa/fwl/core/cfwl_spinbutton.h +++ b/xfa/fwl/core/cfwl_spinbutton.h @@ -26,7 +26,6 @@ class CFWL_SpinButton : public CFWL_Widget { // CFWL_Widget FWL_Type GetClassID() const override; - void GetWidgetRect(CFX_RectF& rect, bool bAutoSize) override; void Update() override; FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; diff --git a/xfa/fwl/core/cfwl_widget.cpp b/xfa/fwl/core/cfwl_widget.cpp index 80ff57ce13..225721be43 100644 --- a/xfa/fwl/core/cfwl_widget.cpp +++ b/xfa/fwl/core/cfwl_widget.cpp @@ -65,12 +65,12 @@ bool CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { return false; } -void CFWL_Widget::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (!bAutoSize) { - rect = m_pProperties->m_rtWidget; - return; - } - InflateWidgetRect(rect); +CFX_RectF CFWL_Widget::GetAutosizedWidgetRect() { + return CFX_RectF(); +} + +CFX_RectF CFWL_Widget::GetWidgetRect() { + return m_pProperties->m_rtWidget; } void CFWL_Widget::InflateWidgetRect(CFX_RectF& rect) { @@ -201,7 +201,7 @@ void CFWL_Widget::TransformTo(CFWL_Widget* pWidget, CFX_Matrix m; CFWL_Widget* parent = GetParent(); if (parent) { - GetWidgetRect(r, false); + r = GetWidgetRect(); fx += r.left; fy += r.top; GetMatrix(m, true); @@ -210,8 +210,9 @@ void CFWL_Widget::TransformTo(CFWL_Widget* pWidget, CFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(this); if (!form1) return; + if (!pWidget) { - form1->GetWidgetRect(r, false); + r = form1->GetWidgetRect(); fx += r.left; fy += r.top; return; @@ -220,10 +221,10 @@ void CFWL_Widget::TransformTo(CFWL_Widget* pWidget, if (!form2) return; if (form1 != form2) { - form1->GetWidgetRect(r, false); + r = form1->GetWidgetRect(); fx += r.left; fy += r.top; - form2->GetWidgetRect(r, false); + r = form2->GetWidgetRect(); fx -= r.left; fy -= r.top; } @@ -234,7 +235,7 @@ void CFWL_Widget::TransformTo(CFWL_Widget* pWidget, m1.SetIdentity(); m1.SetReverse(m); m1.TransformPoint(fx, fy); - pWidget->GetWidgetRect(r, false); + r = pWidget->GetWidgetRect(); fx -= r.left; fy -= r.top; } @@ -261,7 +262,7 @@ void CFWL_Widget::GetMatrix(CFX_Matrix& matrix, bool bGlobal) { for (int32_t i = count - 2; i >= 0; i--) { parent = parents.GetAt(i); parent->GetMatrix(ctmOnParent, false); - parent->GetWidgetRect(rect, false); + rect = parent->GetWidgetRect(); matrix.Concat(ctmOnParent, true); matrix.Translate(rect.left, rect.top, true); } @@ -686,8 +687,7 @@ CFX_SizeF CFWL_Widget::GetOffsetFromParent(CFWL_Widget* pParent) { CFWL_Widget* pDstWidget = GetParent(); while (pDstWidget && pDstWidget != pParent) { - CFX_RectF rtDst; - pDstWidget->GetWidgetRect(rtDst, false); + CFX_RectF rtDst = pDstWidget->GetWidgetRect(); szRet += CFX_SizeF(rtDst.left, rtDst.top); pDstWidget = pWidgetMgr->GetParentWidget(pDstWidget); } diff --git a/xfa/fwl/core/cfwl_widget.h b/xfa/fwl/core/cfwl_widget.h index 3272e9d011..15acbf53c0 100644 --- a/xfa/fwl/core/cfwl_widget.h +++ b/xfa/fwl/core/cfwl_widget.h @@ -51,7 +51,8 @@ class CFWL_Widget : public IFWL_WidgetDelegate { virtual FWL_Type GetClassID() const = 0; virtual bool IsInstance(const CFX_WideStringC& wsClass) const; - virtual void GetWidgetRect(CFX_RectF& rect, bool bAutoSize); + virtual CFX_RectF GetAutosizedWidgetRect(); + virtual CFX_RectF GetWidgetRect(); virtual void GetClientRect(CFX_RectF& rect); virtual void ModifyStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved); diff --git a/xfa/fwl/core/cfwl_widgetmgr.cpp b/xfa/fwl/core/cfwl_widgetmgr.cpp index 1649ee76b9..5bcef7b7df 100644 --- a/xfa/fwl/core/cfwl_widgetmgr.cpp +++ b/xfa/fwl/core/cfwl_widgetmgr.cpp @@ -157,8 +157,7 @@ void CFWL_WidgetMgr::RepaintWidget(CFWL_Widget* pWidget, if (IsFormDisabled()) { CFWL_Widget* pOuter = pWidget->GetOuter(); while (pOuter) { - CFX_RectF rtTemp; - pNative->GetWidgetRect(rtTemp, false); + CFX_RectF rtTemp = pNative->GetWidgetRect(); rect.left += rtTemp.left; rect.top += rtTemp.top; pNative = pOuter; @@ -304,8 +303,7 @@ CFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(CFWL_Widget* parent, m.SetIdentity(); m.SetReverse(matrixOnParent); m.TransformPoint(x1, y1); - CFX_RectF bounds; - child->GetWidgetRect(bounds, false); + CFX_RectF bounds = child->GetWidgetRect(); if (bounds.Contains(x1, y1)) { x1 -= bounds.left; y1 -= bounds.top; @@ -473,8 +471,7 @@ void CFWL_WidgetMgr::OnDrawWidget(CFWL_Widget* pWidget, return; CFX_Graphics* pTemp = DrawWidgetBefore(pWidget, pGraphics, pMatrix); - CFX_RectF clipCopy; - pWidget->GetWidgetRect(clipCopy, false); + CFX_RectF clipCopy = pWidget->GetWidgetRect(); clipCopy.left = clipCopy.top = 0; if (UseOffscreenDirect(pWidget)) { @@ -527,8 +524,7 @@ void CFWL_WidgetMgr::DrawChild(CFWL_Widget* parent, if (child->GetStates() & FWL_WGTSTATE_Invisible) continue; - CFX_RectF rtWidget; - child->GetWidgetRect(rtWidget, false); + CFX_RectF rtWidget = child->GetWidgetRect(); if (rtWidget.IsEmpty()) continue; @@ -572,8 +568,7 @@ CFX_Graphics* CFWL_WidgetMgr::DrawWidgetBefore(CFWL_Widget* pWidget, Item* pItem = GetWidgetMgrItem(pWidget); if (!pItem->pOffscreen) { pItem->pOffscreen.reset(new CFX_Graphics); - CFX_RectF rect; - pWidget->GetWidgetRect(rect, false); + CFX_RectF rect = pWidget->GetWidgetRect(); pItem->pOffscreen->Create((int32_t)rect.width, (int32_t)rect.height, FXDIB_Argb); } @@ -608,8 +603,7 @@ bool CFWL_WidgetMgr::IsNeedRepaint(CFWL_Widget* pWidget, return true; } - CFX_RectF rtWidget; - pWidget->GetWidgetRect(rtWidget, false); + CFX_RectF rtWidget = pWidget->GetWidgetRect(); rtWidget.left = rtWidget.top = 0; pMatrix->TransformRect(rtWidget); if (!rtWidget.IntersectWith(rtDirty)) @@ -645,8 +639,7 @@ bool CFWL_WidgetMgr::IsNeedRepaint(CFWL_Widget* pWidget, hitPoint[10].hitPoint.y = hitPoint[11].hitPoint.y = rtWidget.height + rtWidget.top; do { - CFX_RectF rect; - pChild->GetWidgetRect(rect, false); + CFX_RectF rect = pChild->GetWidgetRect(); CFX_RectF r = rect; r.left += rtWidget.left; r.top += rtWidget.top; @@ -706,8 +699,7 @@ bool CFWL_WidgetMgr::UseOffscreenDirect(CFWL_Widget* pWidget) const { #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) if (pItem->bOutsideChanged) { - CFX_RectF r; - pWidget->GetWidgetRect(r, false); + CFX_RectF r = pWidget->GetWidgetRect(); CFX_RectF temp(m_rtScreen); temp.Deflate(50, 50); if (!temp.Contains(r)) diff --git a/xfa/fxfa/app/xfa_ffbarcode.cpp b/xfa/fxfa/app/xfa_ffbarcode.cpp index 8c42bcf774..6f83173b71 100644 --- a/xfa/fxfa/app/xfa_ffbarcode.cpp +++ b/xfa/fxfa/app/xfa_ffbarcode.cpp @@ -157,8 +157,7 @@ void CXFA_FFBarcode::RenderWidget(CFX_Graphics* pGS, CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); RenderCaption(pGS, &mtRotate); - CFX_RectF rtWidget; - m_pNormalWidget->GetWidgetRect(rtWidget, false); + CFX_RectF rtWidget = m_pNormalWidget->GetWidgetRect(); CFX_Matrix mt; mt.Set(1, 0, 0, 1, rtWidget.left, rtWidget.top); mt.Concat(mtRotate); diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp index 136a99cb6c..9b5504708f 100644 --- a/xfa/fxfa/app/xfa_fffield.cpp +++ b/xfa/fxfa/app/xfa_fffield.cpp @@ -69,8 +69,8 @@ void CXFA_FFField::RenderWidget(CFX_Graphics* pGS, DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); RenderCaption(pGS, &mtRotate); DrawHighlight(pGS, &mtRotate, dwStatus, false); - CFX_RectF rtWidget; - m_pNormalWidget->GetWidgetRect(rtWidget, false); + + CFX_RectF rtWidget = m_pNormalWidget->GetWidgetRect(); CFX_Matrix mt; mt.Set(1, 0, 0, 1, rtWidget.left, rtWidget.top); mt.Concat(mtRotate); @@ -363,15 +363,16 @@ bool CXFA_FFField::OnMouseExit() { TranslateFWLMessage(&ms); return true; } + void CXFA_FFField::FWLToClient(FX_FLOAT& fx, FX_FLOAT& fy) { - if (!m_pNormalWidget) { + if (!m_pNormalWidget) return; - } - CFX_RectF rtWidget; - m_pNormalWidget->GetWidgetRect(rtWidget, false); + + CFX_RectF rtWidget = m_pNormalWidget->GetWidgetRect(); fx -= rtWidget.left; fy -= rtWidget.top; } + bool CXFA_FFField::OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { if (!m_pNormalWidget) { return false; @@ -585,20 +586,15 @@ FWL_WidgetHit CXFA_FFField::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { return FWL_WidgetHit::Titlebar; return FWL_WidgetHit::Border; } + bool CXFA_FFField::OnSetCursor(FX_FLOAT fx, FX_FLOAT fy) { return true; } + bool CXFA_FFField::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { - if (!m_pNormalWidget) { - return false; - } - CFX_RectF rtWidget; - m_pNormalWidget->GetWidgetRect(rtWidget, false); - if (rtWidget.Contains(fx, fy)) { - return true; - } - return false; + return m_pNormalWidget && m_pNormalWidget->GetWidgetRect().Contains(fx, fy); } + void CXFA_FFField::LayoutCaption() { CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); if (!pCapTextLayout) diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/xfa_ffimageedit.cpp index e9156bace3..8ee6510b2d 100644 --- a/xfa/fxfa/app/xfa_ffimageedit.cpp +++ b/xfa/fxfa/app/xfa_ffimageedit.cpp @@ -61,8 +61,7 @@ void CXFA_FFImageEdit::RenderWidget(CFX_Graphics* pGS, DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); RenderCaption(pGS, &mtRotate); if (CFX_DIBitmap* pDIBitmap = m_pDataAcc->GetImageEditImage()) { - CFX_RectF rtImage; - m_pNormalWidget->GetWidgetRect(rtImage, false); + CFX_RectF rtImage = m_pNormalWidget->GetWidgetRect(); int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; if (CXFA_Para para = m_pDataAcc->GetPara()) { diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp index a26714aac3..a2b11e89ae 100644 --- a/xfa/fxfa/app/xfa_ffpushbutton.cpp +++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp @@ -214,8 +214,7 @@ void CXFA_FFPushButton::OnDrawWidget(CFX_Graphics* pGraphics, if (m_pNormalWidget->GetStylesEx() & XFA_FWL_PSBSTYLEEXT_HiliteInverted) { if ((m_pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) && (m_pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) { - CFX_RectF rtFill; - m_pNormalWidget->GetWidgetRect(rtFill, false); + CFX_RectF rtFill = m_pNormalWidget->GetWidgetRect(); rtFill.left = rtFill.top = 0; FX_FLOAT fLineWith = GetLineWidth(); rtFill.Deflate(fLineWith, fLineWith); @@ -236,8 +235,8 @@ void CXFA_FFPushButton::OnDrawWidget(CFX_Graphics* pGraphics, pGraphics->SetLineWidth(fLineWidth); CFX_Path path; path.Create(); - CFX_RectF rect; - m_pNormalWidget->GetWidgetRect(rect, false); + + CFX_RectF rect = m_pNormalWidget->GetWidgetRect(); path.AddRectangle(0, 0, rect.width, rect.height); pGraphics->StrokePath(&path, (CFX_Matrix*)pMatrix); } -- cgit v1.2.3