From 4572c8a20beee5cbab2eb1a90cb6cadcc5fa512c Mon Sep 17 00:00:00 2001 From: dsinclair Date: Mon, 21 Nov 2016 18:11:16 -0800 Subject: Remove the GetCaption dataprovider method This method mostly returns L"". In the one case where it returns something different the value is substituted into the callsite. The IFWL_Tooltip class was using the caption, but it is not currently being used. Removed as well. Review-Url: https://codereview.chromium.org/2522663002 --- xfa/fwl/core/cfwl_barcode.cpp | 3 - xfa/fwl/core/cfwl_barcode.h | 3 - xfa/fwl/core/cfwl_checkbox.cpp | 5 - xfa/fwl/core/cfwl_checkbox.h | 3 - xfa/fwl/core/cfwl_combobox.cpp | 3 - xfa/fwl/core/cfwl_combobox.h | 3 - xfa/fwl/core/cfwl_datetimepicker.cpp | 5 - xfa/fwl/core/cfwl_datetimepicker.h | 3 - xfa/fwl/core/cfwl_listbox.cpp | 4 - xfa/fwl/core/cfwl_listbox.h | 3 - xfa/fwl/core/cfwl_notedriver.cpp | 2 +- xfa/fwl/core/cfwl_notedriver.h | 2 - xfa/fwl/core/cfwl_picturebox.cpp | 2 - xfa/fwl/core/cfwl_picturebox.h | 3 - xfa/fwl/core/cfwl_pushbutton.cpp | 4 - xfa/fwl/core/cfwl_pushbutton.h | 3 - xfa/fwl/core/ifwl_checkbox.cpp | 28 +---- xfa/fwl/core/ifwl_datetimepicker.cpp | 3 - xfa/fwl/core/ifwl_datetimepicker.h | 3 - xfa/fwl/core/ifwl_pushbutton.cpp | 56 ---------- xfa/fwl/core/ifwl_pushbutton.h | 3 - xfa/fwl/core/ifwl_tooltip.cpp | 206 ----------------------------------- xfa/fwl/core/ifwl_tooltip.h | 72 ------------ xfa/fwl/core/ifwl_widget.h | 6 +- 24 files changed, 8 insertions(+), 420 deletions(-) delete mode 100644 xfa/fwl/core/ifwl_tooltip.cpp delete mode 100644 xfa/fwl/core/ifwl_tooltip.h (limited to 'xfa/fwl') diff --git a/xfa/fwl/core/cfwl_barcode.cpp b/xfa/fwl/core/cfwl_barcode.cpp index ef3ae4036d..00bf82957a 100644 --- a/xfa/fwl/core/cfwl_barcode.cpp +++ b/xfa/fwl/core/cfwl_barcode.cpp @@ -102,9 +102,6 @@ bool CFWL_Barcode::IsProtectedType() { return GetWidget() ? ToBarcode(GetWidget())->IsProtectedType() : false; } -void CFWL_Barcode::GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption) { -} - BC_CHAR_ENCODING CFWL_Barcode::GetCharEncoding() const { return m_eCharEncoding; } diff --git a/xfa/fwl/core/cfwl_barcode.h b/xfa/fwl/core/cfwl_barcode.h index 2a4622f9fb..0f52a048b1 100644 --- a/xfa/fwl/core/cfwl_barcode.h +++ b/xfa/fwl/core/cfwl_barcode.h @@ -18,9 +18,6 @@ class CFWL_Barcode : public CFWL_Edit, public IFWL_Barcode::DataProvider { void Initialize(); - // IFWL_Widget::DataProvider - void GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption) override; - // IFWL_Barcode::DataProvider BC_CHAR_ENCODING GetCharEncoding() const override; int32_t GetModuleHeight() const override; diff --git a/xfa/fwl/core/cfwl_checkbox.cpp b/xfa/fwl/core/cfwl_checkbox.cpp index 97f963b327..8117dfe631 100644 --- a/xfa/fwl/core/cfwl_checkbox.cpp +++ b/xfa/fwl/core/cfwl_checkbox.cpp @@ -29,11 +29,6 @@ void CFWL_CheckBox::SetBoxSize(FX_FLOAT fHeight) { m_fBoxHeight = fHeight; } -void CFWL_CheckBox::GetCaption(IFWL_Widget* pWidget, - CFX_WideString& wsCaption) { - wsCaption = L"Check box"; -} - FX_FLOAT CFWL_CheckBox::GetBoxSize(IFWL_Widget* pWidget) { return m_fBoxHeight; } diff --git a/xfa/fwl/core/cfwl_checkbox.h b/xfa/fwl/core/cfwl_checkbox.h index 4d39a94726..099fe31d28 100644 --- a/xfa/fwl/core/cfwl_checkbox.h +++ b/xfa/fwl/core/cfwl_checkbox.h @@ -17,9 +17,6 @@ class CFWL_CheckBox : public CFWL_Widget, public IFWL_CheckBox::DataProvider { void Initialize(); - // IFWL_Widget::DataProvider - void GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption) override; - // IFWL_CheckBox::DataProvider FX_FLOAT GetBoxSize(IFWL_Widget* pWidget) override; diff --git a/xfa/fwl/core/cfwl_combobox.cpp b/xfa/fwl/core/cfwl_combobox.cpp index f38140821b..c1e8a3df67 100644 --- a/xfa/fwl/core/cfwl_combobox.cpp +++ b/xfa/fwl/core/cfwl_combobox.cpp @@ -156,9 +156,6 @@ void CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, } } -void CFWL_ComboBox::GetCaption(IFWL_Widget* pWidget, - CFX_WideString& wsCaption) {} - int32_t CFWL_ComboBox::CountItems(const IFWL_Widget* pWidget) const { return m_ItemArray.size(); } diff --git a/xfa/fwl/core/cfwl_combobox.h b/xfa/fwl/core/cfwl_combobox.h index 67d723718d..45d571f987 100644 --- a/xfa/fwl/core/cfwl_combobox.h +++ b/xfa/fwl/core/cfwl_combobox.h @@ -20,9 +20,6 @@ class CFWL_ComboBox : public CFWL_Widget, public IFWL_ComboBox::DataProvider { void Initialize(); - // IFWL_Widget::DataProvider - void GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption) override; - // IFWL_ListBox::DataProvider int32_t CountItems(const IFWL_Widget* pWidget) const override; CFWL_ListItem* GetItem(const IFWL_Widget* pWidget, diff --git a/xfa/fwl/core/cfwl_datetimepicker.cpp b/xfa/fwl/core/cfwl_datetimepicker.cpp index 809392d949..abb85468cf 100644 --- a/xfa/fwl/core/cfwl_datetimepicker.cpp +++ b/xfa/fwl/core/cfwl_datetimepicker.cpp @@ -57,11 +57,6 @@ void CFWL_DateTimePicker::SetCurSel(int32_t iYear, ToDateTimePicker(GetWidget())->SetCurSel(iYear, iMonth, iDay); } -void CFWL_DateTimePicker::GetCaption(IFWL_Widget* pWidget, - CFX_WideString& wsCaption) { - wsCaption = L""; -} - void CFWL_DateTimePicker::GetToday(IFWL_Widget* pWidget, int32_t& iYear, int32_t& iMonth, diff --git a/xfa/fwl/core/cfwl_datetimepicker.h b/xfa/fwl/core/cfwl_datetimepicker.h index 68cc421147..8cdc7c10ce 100644 --- a/xfa/fwl/core/cfwl_datetimepicker.h +++ b/xfa/fwl/core/cfwl_datetimepicker.h @@ -18,9 +18,6 @@ class CFWL_DateTimePicker : public CFWL_Widget, void Initialize(); - // IFWL_Widget::DataProvider - void GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption) override; - // IFWL_DateTimePicker::DataProvider void GetToday(IFWL_Widget* pWidget, int32_t& iYear, diff --git a/xfa/fwl/core/cfwl_listbox.cpp b/xfa/fwl/core/cfwl_listbox.cpp index faedf5bef7..4c933bf24e 100644 --- a/xfa/fwl/core/cfwl_listbox.cpp +++ b/xfa/fwl/core/cfwl_listbox.cpp @@ -99,10 +99,6 @@ uint32_t CFWL_ListBox::GetItemStates(CFWL_ListItem* pItem) { return pItem->m_dwStates | pItem->m_dwCheckState; } -void CFWL_ListBox::GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption) { - wsCaption = L""; -} - int32_t CFWL_ListBox::CountItems(const IFWL_Widget* pWidget) const { return pdfium::CollectionSize(m_ItemArray); } diff --git a/xfa/fwl/core/cfwl_listbox.h b/xfa/fwl/core/cfwl_listbox.h index 44b580ced2..ec033825bb 100644 --- a/xfa/fwl/core/cfwl_listbox.h +++ b/xfa/fwl/core/cfwl_listbox.h @@ -22,9 +22,6 @@ class CFWL_ListBox : public CFWL_Widget, public IFWL_ListBox::DataProvider { void Initialize(); - // IFWL_Widget::DataProvider: - void GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption) override; - // IFWL_ListBox::DataProvider: int32_t CountItems(const IFWL_Widget* pWidget) const override; CFWL_ListItem* GetItem(const IFWL_Widget* pWidget, diff --git a/xfa/fwl/core/cfwl_notedriver.cpp b/xfa/fwl/core/cfwl_notedriver.cpp index 2041c619e7..051619bee2 100644 --- a/xfa/fwl/core/cfwl_notedriver.cpp +++ b/xfa/fwl/core/cfwl_notedriver.cpp @@ -20,7 +20,7 @@ #include "xfa/fwl/core/cfwl_noteloop.h" #include "xfa/fwl/core/cfwl_widgetmgr.h" #include "xfa/fwl/core/ifwl_app.h" -#include "xfa/fwl/core/ifwl_tooltip.h" +#include "xfa/fwl/core/ifwl_form.h" CFWL_NoteDriver::CFWL_NoteDriver() : m_pHover(nullptr), diff --git a/xfa/fwl/core/cfwl_notedriver.h b/xfa/fwl/core/cfwl_notedriver.h index 9e5fa99f6a..ee9b384e7a 100644 --- a/xfa/fwl/core/cfwl_notedriver.h +++ b/xfa/fwl/core/cfwl_notedriver.h @@ -12,14 +12,12 @@ #include #include "xfa/fwl/core/cfwl_event.h" -#include "xfa/fwl/core/ifwl_tooltip.h" #include "xfa/fwl/core/ifwl_widget.h" #include "xfa/fxgraphics/cfx_graphics.h" class CFWL_EventTarget; class CFWL_NoteLoop; class CFWL_TargetImp; -class IFWL_ToolTip; class IFWL_Widget; class CFWL_NoteDriver { diff --git a/xfa/fwl/core/cfwl_picturebox.cpp b/xfa/fwl/core/cfwl_picturebox.cpp index 4b8bf70d07..3298307a59 100644 --- a/xfa/fwl/core/cfwl_picturebox.cpp +++ b/xfa/fwl/core/cfwl_picturebox.cpp @@ -23,5 +23,3 @@ void CFWL_PictureBox::Initialize() { CFWL_Widget::Initialize(); } -void CFWL_PictureBox::GetCaption(IFWL_Widget* pWidget, - CFX_WideString& wsCaption) {} diff --git a/xfa/fwl/core/cfwl_picturebox.h b/xfa/fwl/core/cfwl_picturebox.h index d1be78bda4..ce61a34519 100644 --- a/xfa/fwl/core/cfwl_picturebox.h +++ b/xfa/fwl/core/cfwl_picturebox.h @@ -17,9 +17,6 @@ class CFWL_PictureBox : public CFWL_Widget, public IFWL_Widget::DataProvider { ~CFWL_PictureBox() override; void Initialize(); - - // IFWL_Widget::DataProvider - void GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption) override; }; #endif // XFA_FWL_CORE_CFWL_PICTUREBOX_H_ diff --git a/xfa/fwl/core/cfwl_pushbutton.cpp b/xfa/fwl/core/cfwl_pushbutton.cpp index 90c8ab4941..3d98498ea8 100644 --- a/xfa/fwl/core/cfwl_pushbutton.cpp +++ b/xfa/fwl/core/cfwl_pushbutton.cpp @@ -23,7 +23,3 @@ void CFWL_PushButton::Initialize() { CFWL_Widget::Initialize(); } -void CFWL_PushButton::GetCaption(IFWL_Widget* pWidget, - CFX_WideString& wsCaption) { - wsCaption = L""; -} diff --git a/xfa/fwl/core/cfwl_pushbutton.h b/xfa/fwl/core/cfwl_pushbutton.h index b35ed65474..2d7fa9f075 100644 --- a/xfa/fwl/core/cfwl_pushbutton.h +++ b/xfa/fwl/core/cfwl_pushbutton.h @@ -17,9 +17,6 @@ class CFWL_PushButton : public CFWL_Widget, public IFWL_Widget::DataProvider { ~CFWL_PushButton() override; void Initialize(); - - // IFWL_Widget::DataProvider - void GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption) override; }; #endif // XFA_FWL_CORE_CFWL_PUSHBUTTON_H_ diff --git a/xfa/fwl/core/ifwl_checkbox.cpp b/xfa/fwl/core/ifwl_checkbox.cpp index 04f367f772..4af7cc78fa 100644 --- a/xfa/fwl/core/ifwl_checkbox.cpp +++ b/xfa/fwl/core/ifwl_checkbox.cpp @@ -60,14 +60,10 @@ void IFWL_CheckBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { if (!m_pProperties->m_pDataProvider) return; - CFX_WideString wsCaption; - m_pProperties->m_pDataProvider->GetCaption(this, wsCaption); - if (wsCaption.GetLength() > 0) { - CFX_SizeF sz = CalcTextSize( - wsCaption, m_pProperties->m_pThemeProvider, - !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine)); - rect.Set(0, 0, sz.x, sz.y); - } + 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); IFWL_CheckBox::DataProvider* pData = @@ -124,11 +120,6 @@ void IFWL_CheckBox::DrawWidget(CFX_Graphics* pGraphics, if (!m_pProperties->m_pDataProvider) return; - CFX_WideString wsCaption; - m_pProperties->m_pDataProvider->GetCaption(this, wsCaption); - if (wsCaption.GetLength() <= 0) - return; - CFWL_ThemeText textParam; textParam.m_pWidget = this; textParam.m_iPart = CFWL_Part::Caption; @@ -137,7 +128,7 @@ void IFWL_CheckBox::DrawWidget(CFX_Graphics* pGraphics, if (pMatrix) textParam.m_matrix.Concat(*pMatrix); textParam.m_rtPart = m_rtCaption; - textParam.m_wsText = wsCaption; + textParam.m_wsText = L"Check box"; textParam.m_dwTTOStyles = m_dwTTOStyles; textParam.m_iTTOAlign = m_iTTOAlign; pTheme->DrawText(&textParam); @@ -211,14 +202,7 @@ void IFWL_CheckBox::Layout() { rtFocus.Set(m_rtCaption.left, m_rtCaption.top, m_rtCaption.width, m_rtCaption.height); - CFX_WideString wsCaption; - m_pProperties->m_pDataProvider->GetCaption(this, wsCaption); - if (wsCaption.IsEmpty()) { - m_rtFocus.Set(0, 0, 0, 0); - return; - } - - CalcTextRect(wsCaption, m_pProperties->m_pThemeProvider, m_dwTTOStyles, + CalcTextRect(L"Check box", m_pProperties->m_pThemeProvider, m_dwTTOStyles, m_iTTOAlign, rtFocus); if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_MultiLine) == 0) { FX_FLOAT fWidth = std::max(m_rtCaption.width, rtFocus.width); diff --git a/xfa/fwl/core/ifwl_datetimepicker.cpp b/xfa/fwl/core/ifwl_datetimepicker.cpp index b0e0114bce..85acbc4d7d 100644 --- a/xfa/fwl/core/ifwl_datetimepicker.cpp +++ b/xfa/fwl/core/ifwl_datetimepicker.cpp @@ -675,9 +675,6 @@ void IFWL_DateTimePicker::DisForm_OnFocusChanged(CFWL_Message* pMsg, Repaint(&rtInvalidate); } -void IFWL_DateTimePicker::GetCaption(IFWL_Widget* pWidget, - CFX_WideString& wsCaption) {} - int32_t IFWL_DateTimePicker::GetCurDay(IFWL_Widget* pWidget) { return m_iCurDay; } diff --git a/xfa/fwl/core/ifwl_datetimepicker.h b/xfa/fwl/core/ifwl_datetimepicker.h index 21f5f4a28e..67c1c33d7b 100644 --- a/xfa/fwl/core/ifwl_datetimepicker.h +++ b/xfa/fwl/core/ifwl_datetimepicker.h @@ -63,9 +63,6 @@ class IFWL_DateTimePicker : public IFWL_Widget, void OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; - // IFWL_Widget::DataProvider - void GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption) override; - // IFWL_MonthCalendar::DataProvider int32_t GetCurDay(IFWL_Widget* pWidget) override; int32_t GetCurMonth(IFWL_Widget* pWidget) override; diff --git a/xfa/fwl/core/ifwl_pushbutton.cpp b/xfa/fwl/core/ifwl_pushbutton.cpp index 8ee0485b11..9589de1c3c 100644 --- a/xfa/fwl/core/ifwl_pushbutton.cpp +++ b/xfa/fwl/core/ifwl_pushbutton.cpp @@ -47,16 +47,6 @@ void IFWL_PushButton::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { if (!m_pProperties->m_pThemeProvider) m_pProperties->m_pThemeProvider = GetAvailableTheme(); - CFX_WideString wsCaption; - if (m_pProperties->m_pDataProvider) - m_pProperties->m_pDataProvider->GetCaption(this, wsCaption); - - int32_t iLen = wsCaption.GetLength(); - if (iLen > 0) { - CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider); - rect.Set(0, 0, sz.x, sz.y); - } - FX_FLOAT* fcaption = static_cast(GetThemeCapacity(CFWL_WidgetCapacity::Margin)); rect.Inflate(*fcaption, *fcaption); @@ -92,7 +82,6 @@ void IFWL_PushButton::DrawWidget(CFX_Graphics* pGraphics, if (!m_pProperties->m_pThemeProvider) return; - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; if (HasBorder()) { DrawBorder(pGraphics, CFWL_Part::Border, m_pProperties->m_pThemeProvider, pMatrix); @@ -102,26 +91,6 @@ void IFWL_PushButton::DrawWidget(CFX_Graphics* pGraphics, pMatrix); } DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); - CFX_Matrix matrix; - matrix.Concat(*pMatrix); - - CFX_WideString wsCaption; - if (m_pProperties->m_pDataProvider) - m_pProperties->m_pDataProvider->GetCaption(this, wsCaption); - - CFX_RectF rtText; - rtText.Set(0, 0, 0, 0); - if (!wsCaption.IsEmpty()) - CalcTextRect(wsCaption, pTheme, 0, m_iTTOAlign, rtText); - - switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_PSB_ModeMask) { - case FWL_STYLEEXT_PSB_TextOnly: - DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix); - break; - case FWL_STYLEEXT_PSB_IconOnly: - case FWL_STYLEEXT_PSB_TextIcon: - break; - } } void IFWL_PushButton::DrawBkground(CFX_Graphics* pGraphics, @@ -140,31 +109,6 @@ void IFWL_PushButton::DrawBkground(CFX_Graphics* pGraphics, pTheme->DrawBackground(¶m); } -void IFWL_PushButton::DrawText(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - if (!m_pProperties->m_pDataProvider) - return; - - CFX_WideString wsCaption; - m_pProperties->m_pDataProvider->GetCaption(this, wsCaption); - if (wsCaption.IsEmpty()) - return; - - CFWL_ThemeText param; - param.m_pWidget = this; - param.m_iPart = CFWL_Part::Caption; - param.m_dwStates = GetPartStates(); - param.m_pGraphics = pGraphics; - if (pMatrix) - param.m_matrix.Concat(*pMatrix); - param.m_rtPart = m_rtCaption; - param.m_wsText = wsCaption; - param.m_dwTTOStyles = m_dwTTOStyles; - param.m_iTTOAlign = m_iTTOAlign; - pTheme->DrawText(¶m); -} - uint32_t IFWL_PushButton::GetPartStates() { uint32_t dwStates = CFWL_PartState_Normal; if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) diff --git a/xfa/fwl/core/ifwl_pushbutton.h b/xfa/fwl/core/ifwl_pushbutton.h index a3fa8da1a8..c2c337df55 100644 --- a/xfa/fwl/core/ifwl_pushbutton.h +++ b/xfa/fwl/core/ifwl_pushbutton.h @@ -53,9 +53,6 @@ class IFWL_PushButton : public IFWL_Widget { void DrawBkground(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix); - void DrawText(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); uint32_t GetPartStates(); void UpdateTextOutStyles(); void OnFocusChanged(CFWL_Message* pMsg, bool bSet); diff --git a/xfa/fwl/core/ifwl_tooltip.cpp b/xfa/fwl/core/ifwl_tooltip.cpp deleted file mode 100644 index 770527de02..0000000000 --- a/xfa/fwl/core/ifwl_tooltip.cpp +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fwl/core/ifwl_tooltip.h" - -#include -#include - -#include "third_party/base/ptr_util.h" -#include "xfa/fde/tto/fde_textout.h" -#include "xfa/fwl/core/cfwl_notedriver.h" -#include "xfa/fwl/core/cfwl_themebackground.h" -#include "xfa/fwl/core/cfwl_themepart.h" -#include "xfa/fwl/core/cfwl_themetext.h" -#include "xfa/fwl/core/ifwl_themeprovider.h" -#include "xfa/fwl/core/ifwl_timerinfo.h" -#include "xfa/fwl/theme/cfwl_widgettp.h" - -IFWL_ToolTip::IFWL_ToolTip(const IFWL_App* app, - std::unique_ptr properties, - IFWL_Widget* pOuter) - : IFWL_Form(app, std::move(properties), pOuter), - m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), - m_iTTOAlign(FDE_TTOALIGNMENT_Center), - m_pTimerInfoShow(nullptr), - m_pTimerInfoHide(nullptr), - m_TimerShow(this), - m_TimerHide(this) { - m_rtClient.Set(0, 0, 0, 0); - m_rtCaption.Set(0, 0, 0, 0); - m_rtAnchor.Set(0, 0, 0, 0); - m_pProperties->m_dwStyles &= ~FWL_WGTSTYLE_Child; - m_pProperties->m_dwStyles |= FWL_WGTSTYLE_Popup; -} - -IFWL_ToolTip::~IFWL_ToolTip() {} - -FWL_Type IFWL_ToolTip::GetClassID() const { - return FWL_Type::ToolTip; -} - -void IFWL_ToolTip::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_WideString wsCaption; - if (m_pProperties->m_pDataProvider) - m_pProperties->m_pDataProvider->GetCaption(this, wsCaption); - - int32_t iLen = wsCaption.GetLength(); - if (iLen > 0) { - CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider); - rect.Set(0, 0, sz.x, sz.y); - rect.width += 25; - rect.height += 16; - } - IFWL_Widget::GetWidgetRect(rect, true); -} - -void IFWL_ToolTip::Update() { - if (IsLocked()) - return; - if (!m_pProperties->m_pThemeProvider) - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - - UpdateTextOutStyles(); - GetClientRect(m_rtClient); - m_rtCaption = m_rtClient; -} - -void IFWL_ToolTip::GetClientRect(CFX_RectF& rect) { - FX_FLOAT x = 0; - FX_FLOAT y = 0; - FX_FLOAT t = 0; - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - if (pTheme) { - CFWL_ThemePart part; - part.m_pWidget = this; - x = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CXBorder)); - y = *static_cast( - pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CYBorder)); - } - rect = m_pProperties->m_rtWidget; - rect.Offset(-rect.left, -rect.top); - rect.Deflate(x, t, x, y); -} - -void IFWL_ToolTip::DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - if (!pGraphics || !m_pProperties->m_pThemeProvider) - return; - - IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - DrawBkground(pGraphics, pTheme, pMatrix); - DrawText(pGraphics, pTheme, pMatrix); -} - -void IFWL_ToolTip::DrawBkground(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - CFWL_ThemeBackground param; - param.m_pWidget = this; - param.m_iPart = CFWL_Part::Background; - param.m_dwStates = m_pProperties->m_dwStates; - param.m_pGraphics = pGraphics; - if (pMatrix) - param.m_matrix.Concat(*pMatrix); - param.m_rtPart = m_rtClient; - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) - param.m_pData = &m_rtCaption; - pTheme->DrawBackground(¶m); -} - -void IFWL_ToolTip::DrawText(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - if (!m_pProperties->m_pDataProvider) - return; - - CFX_WideString wsCaption; - m_pProperties->m_pDataProvider->GetCaption(this, wsCaption); - if (wsCaption.IsEmpty()) - return; - - CFWL_ThemeText param; - param.m_pWidget = this; - param.m_iPart = CFWL_Part::Caption; - param.m_dwStates = m_pProperties->m_dwStates; - param.m_pGraphics = pGraphics; - if (pMatrix) - param.m_matrix.Concat(*pMatrix); - param.m_rtPart = m_rtCaption; - param.m_wsText = wsCaption; - param.m_dwTTOStyles = m_dwTTOStyles; - param.m_iTTOAlign = m_iTTOAlign; - pTheme->DrawText(¶m); -} - -void IFWL_ToolTip::UpdateTextOutStyles() { - m_iTTOAlign = FDE_TTOALIGNMENT_Center; - m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; - if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) - m_dwTTOStyles |= FDE_TTOSTYLE_RTL; - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_Multiline) - m_dwTTOStyles &= ~FDE_TTOSTYLE_SingleLine; -} - -void IFWL_ToolTip::RefreshToolTipPos() { - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_NoAnchor) == 0) { - CFX_RectF rtPopup; - CFX_RectF rtWidget(m_pProperties->m_rtWidget); - CFX_RectF rtAnchor(m_rtAnchor); - rtPopup.Set(0, 0, 0, 0); - FX_FLOAT fx = rtAnchor.Center().x + 20; - FX_FLOAT fy = rtAnchor.Center().y + 20; - rtPopup.Set(fx, fy, rtWidget.Width(), rtWidget.Height()); - - if (rtPopup.bottom() > 0.0f) - rtPopup.Offset(0, 0.0f - rtPopup.bottom()); - if (rtPopup.right() > 0.0f) - rtPopup.Offset(0.0f - rtPopup.right(), 0); - if (rtPopup.left < 0) - rtPopup.Offset(0 - rtPopup.left, 0); - if (rtPopup.top < 0) - rtPopup.Offset(0, 0 - rtPopup.top); - - SetWidgetRect(rtPopup); - Update(); - } -} - -void IFWL_ToolTip::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - DrawWidget(pGraphics, pMatrix); -} - -IFWL_ToolTip::Timer::Timer(IFWL_ToolTip* pToolTip) : IFWL_Timer(pToolTip) {} - -void IFWL_ToolTip::Timer::Run(IFWL_TimerInfo* pTimerInfo) { - IFWL_ToolTip* pToolTip = static_cast(m_pWidget); - - if (pToolTip->m_pTimerInfoShow == pTimerInfo && pToolTip->m_pTimerInfoShow) { - if (pToolTip->GetStates() & FWL_WGTSTATE_Invisible) { - pToolTip->SetStates(FWL_WGTSTATE_Invisible, false); - pToolTip->RefreshToolTipPos(); - pToolTip->m_pTimerInfoShow->StopTimer(); - pToolTip->m_pTimerInfoShow = nullptr; - return; - } - } - if (pToolTip->m_pTimerInfoHide == pTimerInfo && pToolTip->m_pTimerInfoHide) { - pToolTip->SetStates(FWL_WGTSTATE_Invisible, true); - pToolTip->m_pTimerInfoHide->StopTimer(); - pToolTip->m_pTimerInfoHide = nullptr; - } -} diff --git a/xfa/fwl/core/ifwl_tooltip.h b/xfa/fwl/core/ifwl_tooltip.h deleted file mode 100644 index 71a913010a..0000000000 --- a/xfa/fwl/core/ifwl_tooltip.h +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FWL_CORE_IFWL_TOOLTIP_H_ -#define XFA_FWL_CORE_IFWL_TOOLTIP_H_ - -#include - -#include "xfa/fwl/core/ifwl_form.h" -#include "xfa/fwl/core/ifwl_timer.h" - -class CFWL_WidgetProperties; -class IFWL_Widget; - -#define FWL_STYLEEXT_TTP_Rectangle (0L << 3) -#define FWL_STYLEEXT_TTP_RoundCorner (1L << 3) -#define FWL_STYLEEXT_TTP_Balloon (1L << 4) -#define FWL_STYLEEXT_TTP_Multiline (1L << 5) -#define FWL_STYLEEXT_TTP_NoAnchor (1L << 6) - -class IFWL_ToolTip : public IFWL_Form { - public: - IFWL_ToolTip(const IFWL_App* app, - std::unique_ptr properties, - IFWL_Widget* pOuter); - ~IFWL_ToolTip() override; - - // IFWL_Widget - FWL_Type GetClassID() const override; - void GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false) override; - void Update() override; - void DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = nullptr) override; - void SetStates(uint32_t dwStates, bool bSet) override; - void GetClientRect(CFX_RectF& rect) override; - void OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) override; - - private: - class Timer : public IFWL_Timer { - public: - explicit Timer(IFWL_ToolTip* pToolTip); - ~Timer() override {} - - void Run(IFWL_TimerInfo* pTimerInfo) override; - }; - friend class IFWL_ToolTip::Timer; - - void DrawBkground(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void DrawText(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); - void UpdateTextOutStyles(); - void RefreshToolTipPos(); - - CFX_RectF m_rtClient; - CFX_RectF m_rtCaption; - uint32_t m_dwTTOStyles; - int32_t m_iTTOAlign; - CFX_RectF m_rtAnchor; - IFWL_TimerInfo* m_pTimerInfoShow; - IFWL_TimerInfo* m_pTimerInfoHide; - IFWL_ToolTip::Timer m_TimerShow; - IFWL_ToolTip::Timer m_TimerHide; -}; - -#endif // XFA_FWL_CORE_IFWL_TOOLTIP_H_ diff --git a/xfa/fwl/core/ifwl_widget.h b/xfa/fwl/core/ifwl_widget.h index 414678fb60..a7ae8ce590 100644 --- a/xfa/fwl/core/ifwl_widget.h +++ b/xfa/fwl/core/ifwl_widget.h @@ -64,11 +64,7 @@ enum class FWL_Type; class IFWL_Widget : public IFWL_WidgetDelegate { public: - class DataProvider { - public: - virtual void GetCaption(IFWL_Widget* pWidget, - CFX_WideString& wsCaption) = 0; - }; + class DataProvider {}; ~IFWL_Widget() override; -- cgit v1.2.3