From c635c93c974db1c55032c36e81e98f3d214a249f Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 3 Jan 2017 15:46:55 -0500 Subject: Remove the ::GetCapacity methods. The GetCapacity methods return a void* because they return different types of internal class memory based on what the calling parameter was. This is confusing and makes it difficult to tell when then enum values can be removed. This CL removes GetCapacity and adds methods as needed to get the real values. Change-Id: I64c2edc858220624880e27f4ed49c2dae080f462 Reviewed-on: https://pdfium-review.googlesource.com/2137 Commit-Queue: dsinclair Reviewed-by: Tom Sepez --- xfa/fwl/cfwl_barcode.cpp | 35 +++---- xfa/fwl/cfwl_combobox.cpp | 34 +++---- xfa/fwl/cfwl_combobox.h | 2 - xfa/fwl/cfwl_datetimepicker.cpp | 15 ++- xfa/fwl/cfwl_edit.cpp | 89 +++++++----------- xfa/fwl/cfwl_form.cpp | 7 +- xfa/fwl/cfwl_listbox.cpp | 28 +++--- xfa/fwl/cfwl_monthcalendar.cpp | 61 +----------- xfa/fwl/cfwl_monthcalendar.h | 26 ------ xfa/fwl/cfwl_pushbutton.cpp | 3 - xfa/fwl/cfwl_scrollbar.cpp | 16 ++-- xfa/fwl/cfwl_scrollbar.h | 1 - xfa/fwl/cfwl_widget.cpp | 19 +--- xfa/fwl/cfwl_widget.h | 1 - xfa/fwl/ifwl_themeprovider.h | 11 ++- xfa/fwl/theme/cfwl_comboboxtp.cpp | 15 --- xfa/fwl/theme/cfwl_comboboxtp.h | 2 - xfa/fwl/theme/cfwl_monthcalendartp.cpp | 164 --------------------------------- xfa/fwl/theme/cfwl_monthcalendartp.h | 2 - xfa/fwl/theme/cfwl_pushbuttontp.cpp | 9 -- xfa/fwl/theme/cfwl_pushbuttontp.h | 2 - xfa/fwl/theme/cfwl_scrollbartp.cpp | 9 -- xfa/fwl/theme/cfwl_scrollbartp.h | 2 - xfa/fwl/theme/cfwl_widgettp.cpp | 70 -------------- xfa/fwl/theme/cfwl_widgettp.h | 60 +----------- xfa/fxfa/app/xfa_ffcheckbutton.cpp | 3 +- xfa/fxfa/app/xfa_fffield.cpp | 9 +- xfa/fxfa/app/xfa_ffimageedit.cpp | 3 +- xfa/fxfa/app/xfa_ffwidgetacc.cpp | 9 +- xfa/fxfa/app/xfa_fwltheme.cpp | 154 +++++++++++++++---------------- xfa/fxfa/app/xfa_fwltheme.h | 17 ++-- xfa/fxfa/parser/cxfa_widgetdata.cpp | 27 +++--- xfa/fxfa/parser/cxfa_widgetdata.h | 5 +- 33 files changed, 216 insertions(+), 694 deletions(-) diff --git a/xfa/fwl/cfwl_barcode.cpp b/xfa/fwl/cfwl_barcode.cpp index 83ab74a608..8b05927223 100644 --- a/xfa/fwl/cfwl_barcode.cpp +++ b/xfa/fwl/cfwl_barcode.cpp @@ -165,27 +165,20 @@ void CFWL_Barcode::GenerateBarcodeImageCache() { if (!m_pBarcodeEngine) return; - CFX_WideString wsText = GetText(); - - CFWL_ThemePart part; - part.m_pWidget = this; - IFWL_ThemeProvider* pTheme = GetAvailableTheme(); - CFGAS_GEFont* pFont = static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Font)); - CFX_Font* pCXFont = pFont ? pFont->GetDevFont() : nullptr; - if (pCXFont) - m_pBarcodeEngine->SetFont(pCXFont); - - FX_FLOAT* pFontSize = static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::FontSize)); - if (pFontSize) - m_pBarcodeEngine->SetFontSize(*pFontSize); - - FX_ARGB* pFontColor = static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TextColor)); - if (pFontColor) - m_pBarcodeEngine->SetFontColor(*pFontColor); + if (pTheme) { + CFWL_ThemePart part; + part.m_pWidget = this; + + if (CFGAS_GEFont* pFont = pTheme->GetFont(&part)) { + if (CFX_Font* pCXFont = pFont->GetDevFont()) + m_pBarcodeEngine->SetFont(pCXFont); + } + m_pBarcodeEngine->SetFontSize(pTheme->GetFontSize(&part)); + m_pBarcodeEngine->SetFontColor(pTheme->GetTextColor(&part)); + } else { + m_pBarcodeEngine->SetFontSize(FWLTHEME_CAPACITY_FontSize); + } m_pBarcodeEngine->SetHeight(int32_t(GetRTClient().height)); m_pBarcodeEngine->SetWidth(int32_t(GetRTClient().width)); @@ -217,7 +210,7 @@ void CFWL_Barcode::GenerateBarcodeImageCache() { m_pBarcodeEngine->SetTruncated(m_bTruncated); int32_t errorCode = 0; - m_dwStatus = m_pBarcodeEngine->Encode(wsText.AsStringC(), true, errorCode) + m_dwStatus = m_pBarcodeEngine->Encode(GetText().AsStringC(), true, errorCode) ? XFA_BCS_EncodeSuccess : 0; } diff --git a/xfa/fwl/cfwl_combobox.cpp b/xfa/fwl/cfwl_combobox.cpp index c07e0cf246..03d2921e65 100644 --- a/xfa/fwl/cfwl_combobox.cpp +++ b/xfa/fwl/cfwl_combobox.cpp @@ -35,8 +35,7 @@ CFWL_ComboBox::CFWL_ComboBox(const CFWL_App* app) m_pComboBoxProxy(nullptr), m_bLButtonDown(false), m_iCurSel(-1), - m_iBtnState(CFWL_PartState_Normal), - m_fComboFormHandler(0) { + m_iBtnState(CFWL_PartState_Normal) { m_rtClient.Reset(); m_rtBtn.Reset(); m_rtHandler.Reset(); @@ -117,11 +116,6 @@ void CFWL_ComboBox::Update() { m_pProperties->m_pThemeProvider = GetAvailableTheme(); Layout(); - CFWL_ThemePart part; - part.m_pWidget = this; - m_fComboFormHandler = - *static_cast(m_pProperties->m_pThemeProvider->GetCapacity( - &part, CFWL_WidgetCapacity::ComboFormHandler)); } FWL_WidgetHit CFWL_ComboBox::HitTest(FX_FLOAT fx, FX_FLOAT fy) { @@ -349,7 +343,6 @@ void CFWL_ComboBox::ShowDropList(bool bActivate) { CFWL_Event ev(CFWL_Event::Type::PreDropDown, this); DispatchEvent(&ev); - m_fItemHeight = m_pListBox->GetItemHeight(); m_pListBox->SetFocus(true); m_pComboBoxProxy->DoModal(); m_pListBox->SetFocus(false); @@ -380,12 +373,11 @@ void CFWL_ComboBox::Layout() { return DisForm_Layout(); m_rtClient = GetClientRect(); - FX_FLOAT* pFWidth = static_cast( - GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); - if (!pFWidth) + IFWL_ThemeProvider* theme = GetAvailableTheme(); + if (!theme) return; - FX_FLOAT fBtn = *pFWidth; + FX_FLOAT fBtn = theme->GetScrollBarWidth(); m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn, m_rtClient.height); if (!IsDropDownStyle() || !m_pEdit) @@ -680,24 +672,22 @@ CFX_RectF CFWL_ComboBox::DisForm_GetBBox() const { void CFWL_ComboBox::DisForm_Layout() { m_rtClient = GetClientRect(); m_rtContent = m_rtClient; - FX_FLOAT* pFWidth = static_cast( - GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); - if (!pFWidth) + IFWL_ThemeProvider* theme = GetAvailableTheme(); + if (!theme) return; FX_FLOAT borderWidth = 1; - FX_FLOAT fBtn = *pFWidth; + FX_FLOAT fBtn = theme->GetScrollBarWidth(); if (!(GetStylesEx() & FWL_STYLEEXT_CMB_ReadOnly)) { m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top + borderWidth, fBtn - borderWidth, m_rtClient.height - 2 * borderWidth); } - CFX_RectF* pUIMargin = - static_cast(GetThemeCapacity(CFWL_WidgetCapacity::UIMargin)); - if (pUIMargin) { - m_rtContent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, - pUIMargin->height); - } + CFWL_ThemePart part; + part.m_pWidget = this; + CFX_RectF pUIMargin = theme->GetUIMargin(&part); + m_rtContent.Deflate(pUIMargin.left, pUIMargin.top, pUIMargin.width, + pUIMargin.height); if (!IsDropDownStyle() || !m_pEdit) return; diff --git a/xfa/fwl/cfwl_combobox.h b/xfa/fwl/cfwl_combobox.h index c1c4ed42e0..d8db10dd2c 100644 --- a/xfa/fwl/cfwl_combobox.h +++ b/xfa/fwl/cfwl_combobox.h @@ -156,8 +156,6 @@ class CFWL_ComboBox : public CFWL_Widget { bool m_bLButtonDown; int32_t m_iCurSel; int32_t m_iBtnState; - FX_FLOAT m_fComboFormHandler; - FX_FLOAT m_fItemHeight; }; #endif // XFA_FWL_CFWL_COMBOBOX_H_ diff --git a/xfa/fwl/cfwl_datetimepicker.cpp b/xfa/fwl/cfwl_datetimepicker.cpp index 658cb036dc..861692f8e2 100644 --- a/xfa/fwl/cfwl_datetimepicker.cpp +++ b/xfa/fwl/cfwl_datetimepicker.cpp @@ -79,12 +79,12 @@ void CFWL_DateTimePicker::Update() { m_pEdit->SetThemeProvider(m_pProperties->m_pThemeProvider); m_rtClient = GetClientRect(); - FX_FLOAT* pFWidth = static_cast( - GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); - if (!pFWidth) + + IFWL_ThemeProvider* theme = GetAvailableTheme(); + if (!theme) return; - FX_FLOAT fBtn = *pFWidth; + FX_FLOAT fBtn = theme->GetScrollBarWidth(); m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn - 1, m_rtClient.height - 1); @@ -426,12 +426,11 @@ void CFWL_DateTimePicker::DisForm_Update() { if (!m_pMonthCal->GetThemeProvider()) m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider); - FX_FLOAT* pWidth = static_cast( - GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); - if (!pWidth) + IFWL_ThemeProvider* theme = GetAvailableTheme(); + if (!theme) return; - m_fBtn = *pWidth; + m_fBtn = theme->GetScrollBarWidth(); CFX_RectF rtMonthCal = m_pMonthCal->GetAutosizedWidgetRect(); CFX_RectF rtPopUp; rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index b0d9e8d222..79b0b2d366 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -92,16 +92,14 @@ FWL_Type CFWL_Edit::GetClassID() const { CFX_RectF CFWL_Edit::GetWidgetRect() { CFX_RectF rect = m_pProperties->m_rtWidget; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { + IFWL_ThemeProvider* theme = GetAvailableTheme(); + float scrollbarWidth = theme ? theme->GetScrollBarWidth() : 0.0f; if (IsShowScrollBar(true)) { - FX_FLOAT* pfWidth = static_cast( - GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); - rect.width += *pfWidth; + rect.width += scrollbarWidth; rect.width += kEditMargin; } if (IsShowScrollBar(false)) { - FX_FLOAT* pfWidth = static_cast( - GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); - rect.height += *pfWidth; + rect.height += scrollbarWidth; rect.height += kEditMargin; } } @@ -679,26 +677,18 @@ void CFWL_Edit::UpdateEditParams() { params.dwMode |= FDE_TEXTEDITMODE_ReadOnly; } - FX_FLOAT* pFontSize = - static_cast(GetThemeCapacity(CFWL_WidgetCapacity::FontSize)); - if (!pFontSize) - return; + IFWL_ThemeProvider* theme = GetAvailableTheme(); + CFWL_ThemePart part; + part.m_pWidget = this; + m_fFontSize = theme ? theme->GetFontSize(&part) : FWLTHEME_CAPACITY_FontSize; - m_fFontSize = *pFontSize; - uint32_t* pFontColor = - static_cast(GetThemeCapacity(CFWL_WidgetCapacity::TextColor)); - if (!pFontColor) + if (!theme) return; - params.dwFontColor = *pFontColor; - FX_FLOAT* pLineHeight = - static_cast(GetThemeCapacity(CFWL_WidgetCapacity::LineHeight)); - if (!pLineHeight) - return; + params.dwFontColor = theme->GetTextColor(&part); + params.fLineSpace = theme->GetLineHeight(&part); - params.fLineSpace = *pLineHeight; - CFGAS_GEFont* pFont = - static_cast(GetThemeCapacity(CFWL_WidgetCapacity::Font)); + CFGAS_GEFont* pFont = theme->GetFont(&part); if (!pFont) return; @@ -790,11 +780,14 @@ void CFWL_Edit::UpdateVAlignment() { FX_FLOAT fOffsetY = 0.0f; FX_FLOAT fSpaceAbove = 0.0f; FX_FLOAT fSpaceBelow = 0.0f; - CFX_SizeF* pSpace = static_cast( - GetThemeCapacity(CFWL_WidgetCapacity::SpaceAboveBelow)); - if (pSpace) { - fSpaceAbove = pSpace->x; - fSpaceBelow = pSpace->y; + IFWL_ThemeProvider* theme = GetAvailableTheme(); + if (theme) { + CFWL_ThemePart part; + part.m_pWidget = this; + + CFX_SizeF pSpace = theme->GetSpaceAboveBelow(&part); + fSpaceAbove = pSpace.x; + fSpaceBelow = pSpace.y; } if (fSpaceAbove < 0.1f) fSpaceAbove = 0; @@ -952,29 +945,22 @@ int32_t CFWL_Edit::AddDoRecord(std::unique_ptr pRecord) { void CFWL_Edit::Layout() { m_rtClient = GetClientRect(); m_rtEngine = m_rtClient; - FX_FLOAT* pfWidth = static_cast( - GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); - if (!pfWidth) + IFWL_ThemeProvider* theme = GetAvailableTheme(); + if (!theme) return; - FX_FLOAT fWidth = *pfWidth; + FX_FLOAT fWidth = theme->GetScrollBarWidth(); + CFWL_ThemePart part; if (!m_pOuter) { - CFX_RectF* pUIMargin = static_cast( - GetThemeCapacity(CFWL_WidgetCapacity::UIMargin)); - if (pUIMargin) { - m_rtEngine.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, - pUIMargin->height); - } + part.m_pWidget = this; + CFX_RectF pUIMargin = theme->GetUIMargin(&part); + m_rtEngine.Deflate(pUIMargin.left, pUIMargin.top, pUIMargin.width, + pUIMargin.height); } else if (m_pOuter->GetClassID() == FWL_Type::DateTimePicker) { - CFWL_ThemePart part; part.m_pWidget = m_pOuter; - CFX_RectF* pUIMargin = - static_cast(m_pOuter->GetThemeProvider()->GetCapacity( - &part, CFWL_WidgetCapacity::UIMargin)); - if (pUIMargin) { - m_rtEngine.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, - pUIMargin->height); - } + CFX_RectF pUIMargin = theme->GetUIMargin(&part); + m_rtEngine.Deflate(pUIMargin.left, pUIMargin.top, pUIMargin.width, + pUIMargin.height); } bool bShowVertScrollbar = IsShowScrollBar(true); @@ -1029,14 +1015,13 @@ void CFWL_Edit::LayoutScrollBar() { return; } - FX_FLOAT* pfWidth = nullptr; bool bShowVertScrollbar = IsShowScrollBar(true); bool bShowHorzScrollbar = IsShowScrollBar(false); + + IFWL_ThemeProvider* theme = GetAvailableTheme(); + FX_FLOAT fWidth = theme ? theme->GetScrollBarWidth() : 0; if (bShowVertScrollbar) { if (!m_pVertScrollBar) { - pfWidth = static_cast( - GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); - FX_FLOAT fWidth = pfWidth ? *pfWidth : 0; InitVerticalScrollBar(); CFX_RectF rtVertScr; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { @@ -1058,12 +1043,6 @@ void CFWL_Edit::LayoutScrollBar() { if (bShowHorzScrollbar) { if (!m_pHorzScrollBar) { - if (!pfWidth) { - pfWidth = static_cast( - GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); - } - - FX_FLOAT fWidth = pfWidth ? *pfWidth : 0; InitHorizontalScrollBar(); CFX_RectF rtHoriScr; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { diff --git a/xfa/fwl/cfwl_form.cpp b/xfa/fwl/cfwl_form.cpp index a40f74e00c..d0d6ef211c 100644 --- a/xfa/fwl/cfwl_form.cpp +++ b/xfa/fwl/cfwl_form.cpp @@ -181,10 +181,9 @@ void CFWL_Form::Layout() { m_rtRelative = GetRelativeRect(); #ifndef FWL_UseMacSystemBorder - m_fCXBorder = - *static_cast(GetThemeCapacity(CFWL_WidgetCapacity::CXBorder)); - m_fCYBorder = - *static_cast(GetThemeCapacity(CFWL_WidgetCapacity::CYBorder)); + IFWL_ThemeProvider* theme = GetAvailableTheme(); + m_fCXBorder = theme ? theme->GetCXBorderSize() : 0.0f; + m_fCYBorder = theme ? theme->GetCYBorderSize() : 0.0f; #endif } diff --git a/xfa/fwl/cfwl_listbox.cpp b/xfa/fwl/cfwl_listbox.cpp index d79e48991e..a7a568cd14 100644 --- a/xfa/fwl/cfwl_listbox.cpp +++ b/xfa/fwl/cfwl_listbox.cpp @@ -477,12 +477,12 @@ CFX_SizeF CFWL_ListBox::CalcSize(bool bAutoSize) { CFX_RectF rtUIMargin; rtUIMargin.Set(0, 0, 0, 0); if (!m_pOuter) { - CFX_RectF* pUIMargin = static_cast( - GetThemeCapacity(CFWL_WidgetCapacity::UIMargin)); - if (pUIMargin) { - m_rtConent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, - pUIMargin->height); - } + CFWL_ThemePart part; + part.m_pWidget = this; + IFWL_ThemeProvider* theme = GetAvailableTheme(); + CFX_RectF pUIMargin = theme ? theme->GetUIMargin(&part) : CFX_RectF(); + m_rtConent.Deflate(pUIMargin.left, pUIMargin.top, pUIMargin.width, + pUIMargin.height); } FX_FLOAT fWidth = GetMaxTextWidth(); @@ -612,19 +612,15 @@ FX_FLOAT CFWL_ListBox::GetMaxTextWidth() { } FX_FLOAT CFWL_ListBox::GetScrollWidth() { - FX_FLOAT* pfWidth = static_cast( - GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); - if (!pfWidth) - return 0; - return *pfWidth; + IFWL_ThemeProvider* theme = GetAvailableTheme(); + return theme ? theme->GetScrollBarWidth() : 0.0f; } FX_FLOAT CFWL_ListBox::CalcItemHeight() { - FX_FLOAT* pfFont = - static_cast(GetThemeCapacity(CFWL_WidgetCapacity::FontSize)); - if (!pfFont) - return 20; - return *pfFont + 2 * kItemTextMargin; + IFWL_ThemeProvider* theme = GetAvailableTheme(); + CFWL_ThemePart part; + part.m_pWidget = this; + return (theme ? theme->GetFontSize(&part) : 20.0f) + 2 * kItemTextMargin; } void CFWL_ListBox::InitVerticalScrollBar() { diff --git a/xfa/fwl/cfwl_monthcalendar.cpp b/xfa/fwl/cfwl_monthcalendar.cpp index c779665820..b79dc3ec6c 100644 --- a/xfa/fwl/cfwl_monthcalendar.cpp +++ b/xfa/fwl/cfwl_monthcalendar.cpp @@ -541,63 +541,6 @@ void CFWL_MonthCalendar::CalDateItem() { void CFWL_MonthCalendar::GetCapValue() { if (!m_pProperties->m_pThemeProvider) m_pProperties->m_pThemeProvider = GetAvailableTheme(); - - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - CFWL_ThemePart part; - part.m_pWidget = this; - m_fHeadWid = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderWidth)); - m_fHeadHei = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderHeight)); - m_fHeadBtnWid = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderBtnWidth)); - m_fHeadBtnHei = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderBtnHeight)); - m_fHeadBtnHMargin = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderBtnHMargin)); - m_fHeadBtnVMargin = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderBtnVMargin)); - m_fHeadTextWid = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderTextWidth)); - m_fHeadTextHei = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderTextHeight)); - m_fHeadTextHMargin = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderTextHMargin)); - m_fHeadTextVMargin = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HeaderTextVMargin)); - m_fHSepWid = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HSepWidth)); - m_fHSepHei = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::HSepHeight)); - m_fWeekNumWid = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::WeekNumWidth)); - m_fSepDOffset = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::SepDOffset)); - m_fSepX = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::SepX)); - m_fSepY = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::SepY)); - m_fWeekNumHeigh = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::WeekNumHeight)); - m_fWeekWid = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::WeekWidth)); - m_fWeekHei = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::WeekHeight)); - m_fDateCellWid = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::DatesCellWidth)); - m_fDateCellHei = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::DatesCellHeight)); - m_fTodayWid = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TodayWidth)); - m_fTodayHei = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TodayHeight)); - m_fTodayFlagWid = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TodayFlagWidth)); - m_fMCWid = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Width)); - - m_fMCHei = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Height)); } void CFWL_MonthCalendar::InitDate() { @@ -826,7 +769,7 @@ void CFWL_MonthCalendar::OnLButtonDown(CFWL_MessageMouse* pMsg) { } else { CFWL_DateTimePicker* pIPicker = static_cast(m_pOuter); if (pIPicker->IsMonthCalendarVisible()) - m_bFlag = 1; + m_bFlag = true; } } @@ -871,7 +814,7 @@ void CFWL_MonthCalendar::OnLButtonUp(CFWL_MessageMouse* pMsg) { } else if (m_bFlag && (!rt.Contains(pMsg->m_fx, pMsg->m_fy))) { pIPicker->ShowMonthCalendar(false); } - m_bFlag = 0; + m_bFlag = false; } void CFWL_MonthCalendar::DisForm_OnLButtonUp(CFWL_MessageMouse* pMsg) { diff --git a/xfa/fwl/cfwl_monthcalendar.h b/xfa/fwl/cfwl_monthcalendar.h index 979f53b136..6c1d0d9246 100644 --- a/xfa/fwl/cfwl_monthcalendar.h +++ b/xfa/fwl/cfwl_monthcalendar.h @@ -181,32 +181,6 @@ class CFWL_MonthCalendar : public CFWL_Widget { CFX_SizeF m_szToday; CFX_ArrayTemplate m_arrSelDays; CFX_RectF m_rtClient; - FX_FLOAT m_fHeadWid; - FX_FLOAT m_fHeadHei; - FX_FLOAT m_fHeadBtnWid; - FX_FLOAT m_fHeadBtnHei; - FX_FLOAT m_fHeadBtnHMargin; - FX_FLOAT m_fHeadBtnVMargin; - FX_FLOAT m_fHeadTextWid; - FX_FLOAT m_fHeadTextHei; - FX_FLOAT m_fHeadTextHMargin; - FX_FLOAT m_fHeadTextVMargin; - FX_FLOAT m_fHSepWid; - FX_FLOAT m_fHSepHei; - FX_FLOAT m_fWeekNumWid; - FX_FLOAT m_fSepDOffset; - FX_FLOAT m_fSepX; - FX_FLOAT m_fSepY; - FX_FLOAT m_fWeekNumHeigh; - FX_FLOAT m_fWeekWid; - FX_FLOAT m_fWeekHei; - FX_FLOAT m_fDateCellWid; - FX_FLOAT m_fDateCellHei; - FX_FLOAT m_fTodayWid; - FX_FLOAT m_fTodayHei; - FX_FLOAT m_fTodayFlagWid; - FX_FLOAT m_fMCWid; - FX_FLOAT m_fMCHei; bool m_bFlag; }; diff --git a/xfa/fwl/cfwl_pushbutton.cpp b/xfa/fwl/cfwl_pushbutton.cpp index 05f8d256c8..3f0be45d10 100644 --- a/xfa/fwl/cfwl_pushbutton.cpp +++ b/xfa/fwl/cfwl_pushbutton.cpp @@ -52,9 +52,6 @@ void CFWL_PushButton::Update() { UpdateTextOutStyles(); m_rtClient = GetClientRect(); m_rtCaption = m_rtClient; - FX_FLOAT* fcaption = - static_cast(GetThemeCapacity(CFWL_WidgetCapacity::Margin)); - m_rtCaption.Inflate(-*fcaption, -*fcaption); } void CFWL_PushButton::DrawWidget(CFX_Graphics* pGraphics, diff --git a/xfa/fwl/cfwl_scrollbar.cpp b/xfa/fwl/cfwl_scrollbar.cpp index 016afd6d36..d4dd8885e3 100644 --- a/xfa/fwl/cfwl_scrollbar.cpp +++ b/xfa/fwl/cfwl_scrollbar.cpp @@ -20,7 +20,12 @@ #include "xfa/fwl/ifwl_themeprovider.h" #define FWL_SCROLLBAR_Elapse 500 -#define FWL_SCROLLBAR_MinThumb 5 + +namespace { + +const float kMinThumbSize = 5.0f; + +} // namespace CFWL_ScrollBar::CFWL_ScrollBar( const CFWL_App* app, @@ -46,7 +51,6 @@ CFWL_ScrollBar::CFWL_ScrollBar( m_bMouseDown(false), m_fButtonLen(0), m_bMinSize(false), - m_fMinThumb(FWL_SCROLLBAR_MinThumb), m_Timer(this) { m_rtClient.Reset(); m_rtThumb.Reset(); @@ -150,12 +154,8 @@ void CFWL_ScrollBar::DrawThumb(CFX_Graphics* pGraphics, } void CFWL_ScrollBar::Layout() { - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - CFWL_ThemePart part; - part.m_pWidget = this; - m_fMinThumb = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Size)); m_rtClient = GetClientRect(); + CalcButtonLen(); m_rtMinBtn = CalcMinButtonRect(); m_rtMaxBtn = CalcMaxButtonRect(); @@ -226,7 +226,7 @@ CFX_RectF CFWL_ScrollBar::CalcThumbButtonRect(const CFX_RectF& rtThumb) { fLength = 0.0f; FX_FLOAT fThumbSize = fLength * fLength / (fRange + fLength); - fThumbSize = std::max(fThumbSize, m_fMinThumb); + fThumbSize = std::max(fThumbSize, kMinThumbSize); FX_FLOAT fDiff = std::max(fLength - fThumbSize, 0.0f); FX_FLOAT fTrackPos = diff --git a/xfa/fwl/cfwl_scrollbar.h b/xfa/fwl/cfwl_scrollbar.h index 40beb7a3b9..62ce523646 100644 --- a/xfa/fwl/cfwl_scrollbar.h +++ b/xfa/fwl/cfwl_scrollbar.h @@ -141,7 +141,6 @@ class CFWL_ScrollBar : public CFWL_Widget { CFX_RectF m_rtMaxBtn; CFX_RectF m_rtMinTrack; CFX_RectF m_rtMaxTrack; - FX_FLOAT m_fMinThumb; CFWL_ScrollBar::Timer m_Timer; }; diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp index 7da12fcfba..301ad5fc9d 100644 --- a/xfa/fwl/cfwl_widget.cpp +++ b/xfa/fwl/cfwl_widget.cpp @@ -292,11 +292,10 @@ CFX_RectF CFWL_Widget::GetEdgeRect() { } FX_FLOAT CFWL_Widget::GetBorderSize(bool bCX) { - FX_FLOAT* pfBorder = static_cast(GetThemeCapacity( - bCX ? CFWL_WidgetCapacity::CXBorder : CFWL_WidgetCapacity::CYBorder)); - if (!pfBorder) - return 0; - return *pfBorder; + IFWL_ThemeProvider* theme = GetAvailableTheme(); + if (!theme) + return 0.0f; + return bCX ? theme->GetCXBorderSize() : theme->GetCYBorderSize(); } CFX_RectF CFWL_Widget::GetRelativeRect() { @@ -306,16 +305,6 @@ CFX_RectF CFWL_Widget::GetRelativeRect() { return rect; } -void* CFWL_Widget::GetThemeCapacity(CFWL_WidgetCapacity dwCapacity) { - IFWL_ThemeProvider* pTheme = GetAvailableTheme(); - if (!pTheme) - return nullptr; - - CFWL_ThemePart part; - part.m_pWidget = this; - return pTheme->GetCapacity(&part, dwCapacity); -} - IFWL_ThemeProvider* CFWL_Widget::GetAvailableTheme() { if (m_pProperties->m_pThemeProvider) return m_pProperties->m_pThemeProvider; diff --git a/xfa/fwl/cfwl_widget.h b/xfa/fwl/cfwl_widget.h index 759ab1f3e6..74fa314bfd 100644 --- a/xfa/fwl/cfwl_widget.h +++ b/xfa/fwl/cfwl_widget.h @@ -124,7 +124,6 @@ class CFWL_Widget : public IFWL_WidgetDelegate { CFX_RectF GetEdgeRect(); FX_FLOAT GetBorderSize(bool bCX); CFX_RectF GetRelativeRect(); - void* GetThemeCapacity(CFWL_WidgetCapacity dwCapacity); IFWL_ThemeProvider* GetAvailableTheme(); CFX_SizeF CalcTextSize(const CFX_WideString& wsText, IFWL_ThemeProvider* pTheme, diff --git a/xfa/fwl/ifwl_themeprovider.h b/xfa/fwl/ifwl_themeprovider.h index 69932e7fc9..c0460fe901 100644 --- a/xfa/fwl/ifwl_themeprovider.h +++ b/xfa/fwl/ifwl_themeprovider.h @@ -21,9 +21,16 @@ class IFWL_ThemeProvider { virtual void DrawBackground(CFWL_ThemeBackground* pParams) = 0; virtual void DrawText(CFWL_ThemeText* pParams) = 0; - virtual void* GetCapacity(CFWL_ThemePart* pThemePart, - CFWL_WidgetCapacity dwCapacity) = 0; virtual void CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) = 0; + virtual float GetCXBorderSize() const = 0; + virtual float GetCYBorderSize() const = 0; + virtual CFX_RectF GetUIMargin(CFWL_ThemePart* pThemePart) const = 0; + virtual float GetFontSize(CFWL_ThemePart* pThemePart) const = 0; + virtual CFGAS_GEFont* GetFont(CFWL_ThemePart* pThemePart) const = 0; + virtual float GetLineHeight(CFWL_ThemePart* pThemePart) const = 0; + virtual float GetScrollBarWidth() const = 0; + virtual FX_COLORREF GetTextColor(CFWL_ThemePart* pThemePart) const = 0; + virtual CFX_SizeF GetSpaceAboveBelow(CFWL_ThemePart* pThemePart) const = 0; }; #endif // XFA_FWL_IFWL_THEMEPROVIDER_H_ diff --git a/xfa/fwl/theme/cfwl_comboboxtp.cpp b/xfa/fwl/theme/cfwl_comboboxtp.cpp index 10409a8eeb..8f961c9884 100644 --- a/xfa/fwl/theme/cfwl_comboboxtp.cpp +++ b/xfa/fwl/theme/cfwl_comboboxtp.cpp @@ -13,12 +13,6 @@ #include "xfa/fxgraphics/cfx_color.h" #include "xfa/fxgraphics/cfx_path.h" -namespace { - -const float kComboFormHandler = 8.0f; - -} // namespace - CFWL_ComboBoxTP::CFWL_ComboBoxTP() {} CFWL_ComboBoxTP::~CFWL_ComboBoxTP() {} @@ -84,15 +78,6 @@ void CFWL_ComboBoxTP::DrawStrethHandler(CFWL_ThemeBackground* pParams, pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix); } -void* CFWL_ComboBoxTP::GetCapacity(CFWL_ThemePart* pThemePart, - CFWL_WidgetCapacity dwCapacity) { - if (dwCapacity == CFWL_WidgetCapacity::ComboFormHandler) { - m_fValue = kComboFormHandler; - return &m_fValue; - } - return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); -} - void CFWL_ComboBoxTP::DrawDropDownButton(CFWL_ThemeBackground* pParams, uint32_t dwStates, CFX_Matrix* pMatrix) { diff --git a/xfa/fwl/theme/cfwl_comboboxtp.h b/xfa/fwl/theme/cfwl_comboboxtp.h index 6abca29d60..e25328101d 100644 --- a/xfa/fwl/theme/cfwl_comboboxtp.h +++ b/xfa/fwl/theme/cfwl_comboboxtp.h @@ -17,8 +17,6 @@ class CFWL_ComboBoxTP : public CFWL_WidgetTP { // CFWL_WidgetTP bool IsValidWidget(CFWL_Widget* pWidget) override; void DrawBackground(CFWL_ThemeBackground* pParams) override; - void* GetCapacity(CFWL_ThemePart* pThemePart, - CFWL_WidgetCapacity dwCapacity) override; protected: void DrawDropDownButton(CFWL_ThemeBackground* pParams, diff --git a/xfa/fwl/theme/cfwl_monthcalendartp.cpp b/xfa/fwl/theme/cfwl_monthcalendartp.cpp index a76d959cca..7e9ea0a72f 100644 --- a/xfa/fwl/theme/cfwl_monthcalendartp.cpp +++ b/xfa/fwl/theme/cfwl_monthcalendartp.cpp @@ -15,40 +15,6 @@ #include "xfa/fxgraphics/cfx_color.h" #include "xfa/fxgraphics/cfx_path.h" -namespace { - -const int kWidth = 200; -const int kHeight = 160; - -const int kHeaderWidth = 200; -const int kHeaderHeight = 30; - -const int kButtonWidth = 18; -const int kButtonHeight = 16; -const int kButtonHorizontalMargin = 5; -const int kButtonVerticalMargin = (kHeaderHeight - kButtonHeight) / 2; - -const int kHeaderTextWidth = 100; -const int kHeaderTextHeight = 20; -const int kHeaderTextHorizontalMargin = (kHeaderWidth - kHeaderTextWidth) / 2; -const int kHeaderTextVerticalMargin = (kHeaderHeight - kHeaderTextHeight) / 2; - -const int kDatesCellWidth = (kHeaderWidth / 7); -const int kDatesCellHeight = 16; -const int kWeekWidth = kDatesCellWidth * 7; -const int kWeekNumWidth = 26; -const int kWeekNumHeight = (6 * kDatesCellHeight); - -const int kHorizontalSeparatorWidth = kWeekWidth - 10; -const int kHorizontalSeparatorHeight = 1; -const int kVerticalSeparatorWidth = 1; -const int kVerticalSeparatorHeight = kWeekNumHeight; -const int kSeparatorDOffset = -4; -const int kSeparatorX = 3; -const int kSeparatorY = kHeaderHeight + kDatesCellHeight + kSeparatorDOffset; - -} // namespace - CFWL_MonthCalendarTP::CFWL_MonthCalendarTP() : m_pThemeData(new MCThemeData) { SetThemeData(); } @@ -130,136 +96,6 @@ void CFWL_MonthCalendarTP::DrawText(CFWL_ThemeText* pParams) { CFWL_WidgetTP::DrawText(pParams); } -void* CFWL_MonthCalendarTP::GetCapacity(CFWL_ThemePart* pThemePart, - CFWL_WidgetCapacity dwCapacity) { - bool bDefPro = false; - bool bDwordVal = false; - switch (dwCapacity) { - case CFWL_WidgetCapacity::HeaderWidth: { - m_fValue = kHeaderWidth; - break; - } - case CFWL_WidgetCapacity::HeaderHeight: { - m_fValue = kHeaderHeight; - break; - } - case CFWL_WidgetCapacity::HeaderBtnWidth: { - m_fValue = kButtonWidth; - break; - } - case CFWL_WidgetCapacity::HeaderBtnHeight: { - m_fValue = kButtonHeight; - break; - } - case CFWL_WidgetCapacity::HeaderBtnHMargin: { - bDwordVal = true; - m_dwValue = kButtonHorizontalMargin; - break; - } - case CFWL_WidgetCapacity::HeaderBtnVMargin: { - m_fValue = kButtonVerticalMargin; - break; - } - case CFWL_WidgetCapacity::HeaderTextWidth: { - m_fValue = kHeaderTextWidth; - break; - } - case CFWL_WidgetCapacity::HeaderTextHeight: { - m_fValue = kHeaderTextHeight; - break; - } - case CFWL_WidgetCapacity::HeaderTextHMargin: { - m_fValue = kHeaderTextHorizontalMargin; - break; - } - case CFWL_WidgetCapacity::HeaderTextVMargin: { - m_fValue = kHeaderTextVerticalMargin; - break; - } - case CFWL_WidgetCapacity::HSepWidth: { - m_fValue = kHorizontalSeparatorWidth; - break; - } - case CFWL_WidgetCapacity::HSepHeight: { - m_fValue = kHorizontalSeparatorHeight; - break; - } - case CFWL_WidgetCapacity::VSepWidth: { - m_fValue = kVerticalSeparatorWidth; - break; - } - case CFWL_WidgetCapacity::VSepHeight: { - m_fValue = kVerticalSeparatorHeight; - break; - } - case CFWL_WidgetCapacity::WeekNumWidth: { - m_fValue = kWeekNumWidth; - break; - } - case CFWL_WidgetCapacity::WeekNumHeight: { - m_fValue = kWeekNumHeight; - break; - } - case CFWL_WidgetCapacity::WeekWidth: { - m_fValue = kWeekWidth; - break; - } - case CFWL_WidgetCapacity::WeekHeight: { - m_fValue = kDatesCellHeight; - break; - } - case CFWL_WidgetCapacity::SepDOffset: { - m_fValue = kSeparatorDOffset; - break; - } - case CFWL_WidgetCapacity::SepX: { - m_fValue = kSeparatorX; - break; - } - case CFWL_WidgetCapacity::SepY: { - m_fValue = kSeparatorY; - break; - } - case CFWL_WidgetCapacity::DatesCellWidth: { - m_fValue = kDatesCellWidth; - break; - } - case CFWL_WidgetCapacity::DatesCellHeight: { - m_fValue = kDatesCellHeight; - break; - } - case CFWL_WidgetCapacity::TodayWidth: { - m_fValue = kHeaderWidth; - break; - } - case CFWL_WidgetCapacity::TodayHeight: { - m_fValue = kDatesCellHeight; - break; - } - case CFWL_WidgetCapacity::TodayFlagWidth: { - m_fValue = kDatesCellWidth; - break; - } - case CFWL_WidgetCapacity::Width: { - m_fValue = kWidth; - break; - } - case CFWL_WidgetCapacity::Height: { - m_fValue = kHeight; - break; - } - default: - bDefPro = true; - break; - } - if (!bDefPro) { - if (bDwordVal) - return &m_dwValue; - return &m_fValue; - } - return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); -} - void CFWL_MonthCalendarTP::Initialize() { InitTTO(); CFWL_WidgetTP::Initialize(); diff --git a/xfa/fwl/theme/cfwl_monthcalendartp.h b/xfa/fwl/theme/cfwl_monthcalendartp.h index a0b1322858..a5ef6313d4 100644 --- a/xfa/fwl/theme/cfwl_monthcalendartp.h +++ b/xfa/fwl/theme/cfwl_monthcalendartp.h @@ -22,8 +22,6 @@ class CFWL_MonthCalendarTP : public CFWL_WidgetTP { bool IsValidWidget(CFWL_Widget* pWidget) override; void DrawBackground(CFWL_ThemeBackground* pParams) override; void DrawText(CFWL_ThemeText* pParams) override; - void* GetCapacity(CFWL_ThemePart* pThemePart, - CFWL_WidgetCapacity dwCapacity) override; protected: struct MCThemeData { diff --git a/xfa/fwl/theme/cfwl_pushbuttontp.cpp b/xfa/fwl/theme/cfwl_pushbuttontp.cpp index 5515ffb578..bf3baedd50 100644 --- a/xfa/fwl/theme/cfwl_pushbuttontp.cpp +++ b/xfa/fwl/theme/cfwl_pushbuttontp.cpp @@ -83,15 +83,6 @@ void CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) { } } -void* CFWL_PushButtonTP::GetCapacity(CFWL_ThemePart* pThemePart, - CFWL_WidgetCapacity dwCapacity) { - if (dwCapacity == CFWL_WidgetCapacity::Margin) { - m_fValue = 0; - return &m_fValue; - } - return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); -} - void CFWL_PushButtonTP::Initialize() { InitTTO(); CFWL_WidgetTP::Initialize(); diff --git a/xfa/fwl/theme/cfwl_pushbuttontp.h b/xfa/fwl/theme/cfwl_pushbuttontp.h index b0efe036ec..64a0088086 100644 --- a/xfa/fwl/theme/cfwl_pushbuttontp.h +++ b/xfa/fwl/theme/cfwl_pushbuttontp.h @@ -21,8 +21,6 @@ class CFWL_PushButtonTP : public CFWL_WidgetTP { void Finalize() override; bool IsValidWidget(CFWL_Widget* pWidget) override; void DrawBackground(CFWL_ThemeBackground* pParams) override; - void* GetCapacity(CFWL_ThemePart* pThemePart, - CFWL_WidgetCapacity dwCapacity) override; protected: struct PBThemeData { diff --git a/xfa/fwl/theme/cfwl_scrollbartp.cpp b/xfa/fwl/theme/cfwl_scrollbartp.cpp index 0129f353ad..7f5d357c43 100644 --- a/xfa/fwl/theme/cfwl_scrollbartp.cpp +++ b/xfa/fwl/theme/cfwl_scrollbartp.cpp @@ -29,15 +29,6 @@ bool CFWL_ScrollBarTP::IsValidWidget(CFWL_Widget* pWidget) { return pWidget && pWidget->GetClassID() == FWL_Type::ScrollBar; } -void* CFWL_ScrollBarTP::GetCapacity(CFWL_ThemePart* pThemePart, - CFWL_WidgetCapacity dwCapacity) { - if (dwCapacity == CFWL_WidgetCapacity::Size) { - m_fValue = 5; - return &m_fValue; - } - return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); -} - void CFWL_ScrollBarTP::DrawBackground(CFWL_ThemeBackground* pParams) { if (!pParams) return; diff --git a/xfa/fwl/theme/cfwl_scrollbartp.h b/xfa/fwl/theme/cfwl_scrollbartp.h index 10138d6cf7..fe625fb8f4 100644 --- a/xfa/fwl/theme/cfwl_scrollbartp.h +++ b/xfa/fwl/theme/cfwl_scrollbartp.h @@ -19,8 +19,6 @@ class CFWL_ScrollBarTP : public CFWL_WidgetTP { // CFWL_WidgetTP bool IsValidWidget(CFWL_Widget* pWidget) override; void DrawBackground(CFWL_ThemeBackground* pParams) override; - void* GetCapacity(CFWL_ThemePart* pThemePart, - CFWL_WidgetCapacity dwCapacity) override; protected: struct SBThemeData { diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp index 3867257e0c..2d61a4100d 100644 --- a/xfa/fwl/theme/cfwl_widgettp.cpp +++ b/xfa/fwl/theme/cfwl_widgettp.cpp @@ -24,20 +24,6 @@ #include "xfa/fxgraphics/cfx_path.h" #include "xfa/fxgraphics/cfx_shading.h" -namespace { - -const float kEdgeFlat = 2.0f; -const float kEdgeRaised = 2.0f; -const float kEdgeSunken = 2.0f; -const float kLineHeight = 12.0f; -const float kScrollBarWidth = 17.0f; -const float kCXBorder = 1.0f; -const float kCYBorder = 1.0f; - -#define FWLTHEME_CAPACITY_TextSelColor (ArgbEncode(255, 153, 193, 218)) - -} // namespace - bool CFWL_WidgetTP::IsValidWidget(CFWL_Widget* pWidget) { return false; } @@ -62,62 +48,6 @@ void CFWL_WidgetTP::DrawText(CFWL_ThemeText* pParams) { m_pTextOut->DrawLogicText(pParams->m_wsText.c_str(), iLen, pParams->m_rtPart); } -void* CFWL_WidgetTP::GetCapacity(CFWL_ThemePart* pThemePart, - CFWL_WidgetCapacity dwCapacity) { - switch (dwCapacity) { - case CFWL_WidgetCapacity::CXBorder: { - m_fValue = kCXBorder; - break; - } - case CFWL_WidgetCapacity::CYBorder: { - m_fValue = kCYBorder; - break; - } - case CFWL_WidgetCapacity::EdgeFlat: { - m_fValue = kEdgeFlat; - break; - } - case CFWL_WidgetCapacity::EdgeRaised: { - m_fValue = kEdgeRaised; - break; - } - case CFWL_WidgetCapacity::EdgeSunken: { - m_fValue = kEdgeSunken; - break; - } - case CFWL_WidgetCapacity::FontSize: { - m_fValue = FWLTHEME_CAPACITY_FontSize; - break; - } - case CFWL_WidgetCapacity::TextColor: { - m_dwValue = FWLTHEME_CAPACITY_TextColor; - return &m_dwValue; - } - case CFWL_WidgetCapacity::ScrollBarWidth: { - m_fValue = kScrollBarWidth; - break; - } - case CFWL_WidgetCapacity::Font: { - return m_pFDEFont; - } - case CFWL_WidgetCapacity::TextSelColor: { - m_dwValue = FWLTHEME_CAPACITY_TextSelColor; - return &m_dwValue; - } - case CFWL_WidgetCapacity::LineHeight: { - m_fValue = kLineHeight; - break; - } - case CFWL_WidgetCapacity::UIMargin: { - m_rtMargin.Set(0, 0, 0, 0); - return &m_rtMargin; - } - default: - return nullptr; - } - return &m_fValue; -} - void CFWL_WidgetTP::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { if (!pParams || !m_pTextOut) return; diff --git a/xfa/fwl/theme/cfwl_widgettp.h b/xfa/fwl/theme/cfwl_widgettp.h index 11135121c0..50dd478cfd 100644 --- a/xfa/fwl/theme/cfwl_widgettp.h +++ b/xfa/fwl/theme/cfwl_widgettp.h @@ -16,59 +16,6 @@ #include "xfa/fwl/theme/cfwl_utils.h" #include "xfa/fxgraphics/cfx_graphics.h" -enum class CFWL_WidgetCapacity { - None = 0, - - BigIcon, - ComboFormHandler, - CXBorder, - CYBorder, - CYCaption, - CYNarrowCaption, - DatesCellHeight, - DatesCellWidth, - EdgeFlat, - EdgeRaised, - EdgeSunken, - Font, - FontSize, - HeaderBtnHeight, - HeaderBtnHMargin, - HeaderBtnVMargin, - HeaderBtnWidth, - HeaderHeight, - HeaderTextHeight, - HeaderTextHMargin, - HeaderTextVMargin, - HeaderTextWidth, - HeaderWidth, - Height, - HSepHeight, - HSepWidth, - LineHeight, - Margin, - ScrollBarWidth, - SepDOffset, - SepX, - SepY, - Size, - SmallIcon, - SpaceAboveBelow, - TextColor, - TextSelColor, - TodayFlagWidth, - TodayHeight, - TodayWidth, - UIMargin, - VSepHeight, - VSepWidth, - WeekHeight, - WeekNumHeight, - WeekNumWidth, - WeekWidth, - Width -}; - class CFDE_TextOut; class CFGAS_GEFont; class CFWL_ThemeBackground; @@ -92,10 +39,10 @@ class CFWL_WidgetTP { virtual void DrawBackground(CFWL_ThemeBackground* pParams); virtual void DrawText(CFWL_ThemeText* pParams); - virtual void* GetCapacity(CFWL_ThemePart* pThemePart, - CFWL_WidgetCapacity dwCapacity); virtual void CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect); + CFGAS_GEFont* GetFont() const { return m_pFDEFont; } + void SetFont(CFWL_Widget* pWidget, const FX_WCHAR* strFont, FX_FLOAT fFontSize, @@ -186,9 +133,6 @@ class CFWL_WidgetTP { uint32_t m_dwRefCount; std::unique_ptr m_pTextOut; CFGAS_GEFont* m_pFDEFont; - FX_FLOAT m_fValue; - uint32_t m_dwValue; - CFX_RectF m_rtMargin; }; void FWLTHEME_Release(); diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp index 30ea09ff4d..e8a422ebd6 100644 --- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp +++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp @@ -192,8 +192,7 @@ void CXFA_FFCheckButton::CapLeftRightPlacement(CXFA_Margin mgCap) { } } void CXFA_FFCheckButton::AddUIMargin(int32_t iCapPlacement) { - CFX_RectF rtUIMargin; - m_pDataAcc->GetUIMargin(rtUIMargin); + CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin(); m_rtUI.top -= rtUIMargin.top / 2 - rtUIMargin.height / 2; FX_FLOAT fLeftAddRight = rtUIMargin.left + rtUIMargin.width; FX_FLOAT fTopAddBottom = rtUIMargin.top + rtUIMargin.height; diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp index 2e15696ab7..0bd6160944 100644 --- a/xfa/fxfa/app/xfa_fffield.cpp +++ b/xfa/fxfa/app/xfa_fffield.cpp @@ -135,8 +135,7 @@ void CXFA_FFField::SetEditScrollOffset() { FX_FLOAT fScrollOffset = 0; CXFA_FFField* pPrev = static_cast(GetPrev()); if (pPrev) { - CFX_RectF rtMargin; - m_pDataAcc->GetUIMargin(rtMargin); + CFX_RectF rtMargin = m_pDataAcc->GetUIMargin(); fScrollOffset = -rtMargin.top; } while (pPrev) { @@ -265,8 +264,7 @@ void CXFA_FFField::CapPlacement() { void CXFA_FFField::CapTopBottomPlacement(CXFA_Caption caption, const CFX_RectF& rtWidget, int32_t iCapPlacement) { - CFX_RectF rtUIMargin; - m_pDataAcc->GetUIMargin(rtUIMargin); + CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin(); m_rtCaption.left += rtUIMargin.left; if (CXFA_Margin mgCap = caption.GetMargin()) { XFA_RectWidthoutMargin(m_rtCaption, mgCap); @@ -292,8 +290,7 @@ void CXFA_FFField::CapTopBottomPlacement(CXFA_Caption caption, void CXFA_FFField::CapLeftRightPlacement(CXFA_Caption caption, const CFX_RectF& rtWidget, int32_t iCapPlacement) { - CFX_RectF rtUIMargin; - m_pDataAcc->GetUIMargin(rtUIMargin); + CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin(); m_rtCaption.top += rtUIMargin.top; m_rtCaption.height -= rtUIMargin.top; if (CXFA_Margin mgCap = caption.GetMargin()) { diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/xfa_ffimageedit.cpp index 04ad313a27..3b063d6e98 100644 --- a/xfa/fxfa/app/xfa_ffimageedit.cpp +++ b/xfa/fxfa/app/xfa_ffimageedit.cpp @@ -107,8 +107,7 @@ void CXFA_FFImageEdit::SetFWLRect() { if (!m_pNormalWidget) { return; } - CFX_RectF rtUIMargin; - m_pDataAcc->GetUIMargin(rtUIMargin); + CFX_RectF rtUIMargin = m_pDataAcc->GetUIMargin(); CFX_RectF rtImage(m_rtUI); rtImage.Deflate(rtUIMargin.left, rtUIMargin.top, rtUIMargin.width, rtUIMargin.height); diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp index 3ff159aa41..13145e6448 100644 --- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp +++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp @@ -768,8 +768,7 @@ void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) { bool CXFA_WidgetAcc::CalculateFieldAutoSize(CFX_SizeF& size) { CFX_SizeF szCap; CalcCaptionSize(szCap); - CFX_RectF rtUIMargin; - GetUIMargin(rtUIMargin); + CFX_RectF rtUIMargin = GetUIMargin(); size.x += rtUIMargin.left + rtUIMargin.width; size.y += rtUIMargin.top + rtUIMargin.height; if (szCap.x > 0 && szCap.y > 0) { @@ -883,8 +882,7 @@ bool CXFA_WidgetAcc::CalculateTextEditAutoSize(CFX_SizeF& size) { break; } } - CFX_RectF rtUIMargin; - GetUIMargin(rtUIMargin); + CFX_RectF rtUIMargin = GetUIMargin(); size.x -= rtUIMargin.left + rtUIMargin.width; CXFA_Margin mgWidget = GetMargin(); if (mgWidget) { @@ -1168,8 +1166,7 @@ bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, FX_FLOAT& fCalcHeight) { mgWidget.GetTopInset(fTopInset); mgWidget.GetBottomInset(fBottomInset); } - CFX_RectF rtUIMargin; - GetUIMargin(rtUIMargin); + CFX_RectF rtUIMargin = GetUIMargin(); fTopInset += rtUIMargin.top; fBottomInset += rtUIMargin.width; } diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp index c08e51f807..d12678e51b 100644 --- a/xfa/fxfa/app/xfa_fwltheme.cpp +++ b/xfa/fxfa/app/xfa_fwltheme.cpp @@ -32,6 +32,8 @@ const FX_WCHAR* const g_FWLTheme_CalFonts[] = { L"Arial", L"Courier New", L"DejaVu Sans", }; +const float kLineHeight = 12.0f; + } // namespace CXFA_FFWidget* XFA_ThemeGetOuterWidget(CFWL_Widget* pWidget) { @@ -54,8 +56,6 @@ CXFA_FWLTheme::CXFA_FWLTheme(CXFA_FFApp* pApp) m_pCaretTP(new CFWL_CaretTP), m_pBarcodeTP(new CFWL_BarcodeTP), m_pTextOut(new CFDE_TextOut), - m_fCapacity(0.0f), - m_dwCapacity(0), m_pCalendarFont(nullptr), m_pApp(pApp) { m_Rect.Reset(); @@ -151,84 +151,80 @@ void CXFA_FWLTheme::DrawText(CFWL_ThemeText* pParams) { pParams->m_wsText.GetLength(), pParams->m_rtPart); } -void* CXFA_FWLTheme::GetCapacity(CFWL_ThemePart* pThemePart, - CFWL_WidgetCapacity dwCapacity) { - switch (dwCapacity) { - case CFWL_WidgetCapacity::Font: { - if (CXFA_FFWidget* pWidget = - XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) { - return pWidget->GetDataAcc()->GetFDEFont(); - } - break; - } - case CFWL_WidgetCapacity::FontSize: { - if (CXFA_FFWidget* pWidget = - XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) { - m_fCapacity = pWidget->GetDataAcc()->GetFontSize(); - return &m_fCapacity; - } - break; - } - case CFWL_WidgetCapacity::TextColor: { - if (CXFA_FFWidget* pWidget = - XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) { - m_dwCapacity = pWidget->GetDataAcc()->GetTextColor(); - return &m_dwCapacity; - } - break; - } - case CFWL_WidgetCapacity::LineHeight: { - if (CXFA_FFWidget* pWidget = - XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) { - m_fCapacity = pWidget->GetDataAcc()->GetLineHeight(); - return &m_fCapacity; - } - break; - } - case CFWL_WidgetCapacity::ScrollBarWidth: { - m_fCapacity = 9; - return &m_fCapacity; - } - case CFWL_WidgetCapacity::UIMargin: { - CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget); - if (pWidget) { - CXFA_LayoutItem* pItem = pWidget; - CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); - pWidgetAcc->GetUIMargin(m_Rect); - if (CXFA_Para para = pWidgetAcc->GetPara()) { - m_Rect.left += para.GetMarginLeft(); - if (pWidgetAcc->IsMultiLine()) { - m_Rect.width += para.GetMarginRight(); - } - } - if (!pItem->GetPrev()) { - if (pItem->GetNext()) { - m_Rect.height = 0; - } - } else if (!pItem->GetNext()) { - m_Rect.top = 0; - } else { - m_Rect.top = 0; - m_Rect.height = 0; - } - } - return &m_Rect; - } - case CFWL_WidgetCapacity::SpaceAboveBelow: { - CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget); - if (pWidget) { - CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); - if (CXFA_Para para = pWidgetAcc->GetPara()) { - m_SizeAboveBelow.x = para.GetSpaceAbove(); - m_SizeAboveBelow.y = para.GetSpaceBelow(); - } - } - return &m_SizeAboveBelow; +CFX_RectF CXFA_FWLTheme::GetUIMargin(CFWL_ThemePart* pThemePart) const { + CFX_RectF rect; + rect.Reset(); + + CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget); + if (!pWidget) + return rect; + + CXFA_LayoutItem* pItem = pWidget; + CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); + rect = pWidgetAcc->GetUIMargin(); + if (CXFA_Para para = pWidgetAcc->GetPara()) { + rect.left += para.GetMarginLeft(); + if (pWidgetAcc->IsMultiLine()) + rect.width += para.GetMarginRight(); + } + if (!pItem->GetPrev()) { + if (pItem->GetNext()) + rect.height = 0; + } else if (!pItem->GetNext()) { + rect.top = 0; + } else { + rect.top = 0; + rect.height = 0; + } + return rect; +} + +float CXFA_FWLTheme::GetCXBorderSize() const { + return 1.0f; +} + +float CXFA_FWLTheme::GetCYBorderSize() const { + return 1.0f; +} + +float CXFA_FWLTheme::GetFontSize(CFWL_ThemePart* pThemePart) const { + if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) + return pWidget->GetDataAcc()->GetFontSize(); + return FWLTHEME_CAPACITY_FontSize; +} + +CFGAS_GEFont* CXFA_FWLTheme::GetFont(CFWL_ThemePart* pThemePart) const { + if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) + return pWidget->GetDataAcc()->GetFDEFont(); + return GetTheme(pThemePart->m_pWidget)->GetFont(); +} + +float CXFA_FWLTheme::GetLineHeight(CFWL_ThemePart* pThemePart) const { + if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) + return pWidget->GetDataAcc()->GetLineHeight(); + return kLineHeight; +} + +float CXFA_FWLTheme::GetScrollBarWidth() const { + return 9.0f; +} + +FX_COLORREF CXFA_FWLTheme::GetTextColor(CFWL_ThemePart* pThemePart) const { + if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) + return pWidget->GetDataAcc()->GetTextColor(); + return FWLTHEME_CAPACITY_TextColor; +} + +CFX_SizeF CXFA_FWLTheme::GetSpaceAboveBelow(CFWL_ThemePart* pThemePart) const { + CFX_SizeF sizeAboveBelow; + if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) { + CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); + if (CXFA_Para para = pWidgetAcc->GetPara()) { + sizeAboveBelow.x = para.GetSpaceAbove(); + sizeAboveBelow.y = para.GetSpaceBelow(); } - default: - break; } - return GetTheme(pThemePart->m_pWidget)->GetCapacity(pThemePart, dwCapacity); + return sizeAboveBelow; } void CXFA_FWLTheme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { @@ -263,7 +259,7 @@ void CXFA_FWLTheme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { pParams->m_wsText.GetLength(), rect); } -CFWL_WidgetTP* CXFA_FWLTheme::GetTheme(CFWL_Widget* pWidget) { +CFWL_WidgetTP* CXFA_FWLTheme::GetTheme(CFWL_Widget* pWidget) const { switch (pWidget->GetClassID()) { case FWL_Type::CheckBox: return m_pCheckBoxTP.get(); diff --git a/xfa/fxfa/app/xfa_fwltheme.h b/xfa/fxfa/app/xfa_fwltheme.h index 98fd74c315..f8b804893a 100644 --- a/xfa/fxfa/app/xfa_fwltheme.h +++ b/xfa/fxfa/app/xfa_fwltheme.h @@ -32,12 +32,20 @@ class CXFA_FWLTheme final : public IFWL_ThemeProvider { // IFWL_ThemeProvider: void DrawBackground(CFWL_ThemeBackground* pParams) override; void DrawText(CFWL_ThemeText* pParams) override; - void* GetCapacity(CFWL_ThemePart* pThemePart, - CFWL_WidgetCapacity dwCapacity) override; void CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) override; + float GetCXBorderSize() const override; + float GetCYBorderSize() const override; + CFX_RectF GetUIMargin(CFWL_ThemePart* pThemePart) const override; + float GetFontSize(CFWL_ThemePart* pThemePart) const override; + CFGAS_GEFont* GetFont(CFWL_ThemePart* pThemePart) const override; + float GetLineHeight(CFWL_ThemePart* pThemePart) const override; + float GetScrollBarWidth() const override; + FX_COLORREF GetTextColor(CFWL_ThemePart* pThemePart) const override; + CFX_SizeF GetSpaceAboveBelow(CFWL_ThemePart* pThemePart) const override; private: - CFWL_WidgetTP* GetTheme(CFWL_Widget* pWidget); + CFWL_WidgetTP* GetTheme(CFWL_Widget* pWidget) const; + std::unique_ptr m_pCheckBoxTP; std::unique_ptr m_pListBoxTP; std::unique_ptr m_pPictureBoxTP; @@ -50,13 +58,10 @@ class CXFA_FWLTheme final : public IFWL_ThemeProvider { std::unique_ptr m_pCaretTP; std::unique_ptr m_pBarcodeTP; std::unique_ptr m_pTextOut; - FX_FLOAT m_fCapacity; - uint32_t m_dwCapacity; CFGAS_GEFont* m_pCalendarFont; CFX_WideString m_wsResource; CXFA_FFApp* const m_pApp; CFX_RectF m_Rect; - CFX_SizeF m_SizeAboveBelow; }; CXFA_FFWidget* XFA_ThemeGetOuterWidget(CFWL_Widget* pWidget); diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index 48a26aafad..80c50b781e 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -399,29 +399,27 @@ bool CXFA_WidgetData::GetMaxHeight(FX_FLOAT& fMaxHeight) { return TryMeasure(XFA_ATTRIBUTE_MaxH, fMaxHeight); } -CXFA_Border CXFA_WidgetData::GetUIBorder(bool bModified) { +CXFA_Border CXFA_WidgetData::GetUIBorder() { CXFA_Node* pUIChild = GetUIChild(); - return CXFA_Border( - pUIChild ? pUIChild->GetProperty(0, XFA_Element::Border, bModified) - : nullptr); + return CXFA_Border(pUIChild + ? pUIChild->GetProperty(0, XFA_Element::Border, false) + : nullptr); } -CXFA_Margin CXFA_WidgetData::GetUIMargin(bool bModified) { +CFX_RectF CXFA_WidgetData::GetUIMargin() { + CFX_RectF rtUIMargin; + rtUIMargin.Reset(); + CXFA_Node* pUIChild = GetUIChild(); - return CXFA_Margin( - pUIChild ? pUIChild->GetProperty(0, XFA_Element::Margin, bModified) + CXFA_Margin mgUI = CXFA_Margin( + pUIChild ? pUIChild->GetProperty(0, XFA_Element::Margin, false) : nullptr); -} - -void CXFA_WidgetData::GetUIMargin(CFX_RectF& rtUIMargin) { - rtUIMargin.Reset(); - CXFA_Margin mgUI = GetUIMargin(); if (!mgUI) - return; + return rtUIMargin; CXFA_Border border = GetUIBorder(); if (border && border.GetPresence() != XFA_ATTRIBUTEENUM_Visible) - return; + return rtUIMargin; FX_FLOAT fLeftInset, fTopInset, fRightInset, fBottomInset; bool bLeft = mgUI.GetLeftInset(fLeftInset); @@ -446,6 +444,7 @@ void CXFA_WidgetData::GetUIMargin(CFX_RectF& rtUIMargin) { } } rtUIMargin.Set(fLeftInset, fTopInset, fRightInset, fBottomInset); + return rtUIMargin; } int32_t CXFA_WidgetData::GetButtonHighlight() { diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h index 0079996735..7986fa9d82 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.h +++ b/xfa/fxfa/parser/cxfa_widgetdata.h @@ -69,9 +69,8 @@ class CXFA_WidgetData : public CXFA_Data { bool GetMinHeight(FX_FLOAT& fMinHeight); bool GetMaxWidth(FX_FLOAT& fMaxWidth); bool GetMaxHeight(FX_FLOAT& fMaxHeight); - CXFA_Border GetUIBorder(bool bModified = false); - CXFA_Margin GetUIMargin(bool bModified = false); - void GetUIMargin(CFX_RectF& rtUIMargin); + CXFA_Border GetUIBorder(); + CFX_RectF GetUIMargin(); int32_t GetButtonHighlight(); bool GetButtonRollover(CFX_WideString& wsRollover, bool& bRichText); bool GetButtonDown(CFX_WideString& wsDown, bool& bRichText); -- cgit v1.2.3