From 37b6d1479b1674eb239cea8893eea31274d22ecd Mon Sep 17 00:00:00 2001 From: dsinclair Date: Mon, 21 Nov 2016 17:05:58 -0800 Subject: Split fwl/core class pt II. Split classes in FWL to be single class per file. In the case of data providers which added no new methods, removed and used the IFWL_Widget::DataProvider directly. Review-Url: https://codereview.chromium.org/2520063002 --- BUILD.gn | 11 +- core/fpdfapi/parser/cpdf_document.cpp | 2 +- core/fpdfapi/render/cpdf_renderstatus.cpp | 6 +- core/fpdfdoc/cpdf_dest_unittest.cpp | 2 +- xfa/fwl/core/cfwl_barcode.h | 4 +- xfa/fwl/core/cfwl_checkbox.h | 4 +- xfa/fwl/core/cfwl_datetimepicker.h | 5 +- xfa/fwl/core/cfwl_eventtarget.cpp | 74 ++++ xfa/fwl/core/cfwl_eventtarget.h | 36 ++ xfa/fwl/core/cfwl_notedriver.cpp | 489 ++++++++++++++++++++++++++ xfa/fwl/core/cfwl_notedriver.h | 82 +++++ xfa/fwl/core/cfwl_noteloop.cpp | 9 + xfa/fwl/core/cfwl_noteloop.h | 27 ++ xfa/fwl/core/cfwl_themepart.cpp | 18 + xfa/fwl/core/cfwl_themepart.h | 11 - xfa/fwl/core/cfwl_widget.cpp | 2 +- xfa/fwl/core/cfwl_widgetmgr.cpp | 90 ++--- xfa/fwl/core/cfwl_widgetmgr.h | 52 ++- xfa/fwl/core/cfwl_widgetproperties.cpp | 24 ++ xfa/fwl/core/cfwl_widgetproperties.h | 17 - xfa/fwl/core/fwl_noteimp.cpp | 553 ------------------------------ xfa/fwl/core/fwl_noteimp.h | 116 ------- xfa/fwl/core/ifwl_adaptertimermgr.h | 1 - xfa/fwl/core/ifwl_app.cpp | 2 +- xfa/fwl/core/ifwl_barcode.cpp | 6 +- xfa/fwl/core/ifwl_barcode.h | 36 +- xfa/fwl/core/ifwl_caret.cpp | 2 +- xfa/fwl/core/ifwl_checkbox.cpp | 10 +- xfa/fwl/core/ifwl_checkbox.h | 10 +- xfa/fwl/core/ifwl_combobox.cpp | 2 +- xfa/fwl/core/ifwl_comboboxproxy.cpp | 2 +- xfa/fwl/core/ifwl_datetimepicker.cpp | 12 +- xfa/fwl/core/ifwl_datetimepicker.h | 16 +- xfa/fwl/core/ifwl_form.cpp | 3 +- xfa/fwl/core/ifwl_form.h | 2 - xfa/fwl/core/ifwl_formproxy.cpp | 2 +- xfa/fwl/core/ifwl_monthcalendar.cpp | 2 +- xfa/fwl/core/ifwl_picturebox.cpp | 2 +- xfa/fwl/core/ifwl_pushbutton.cpp | 2 +- xfa/fwl/core/ifwl_scrollbar.cpp | 2 +- xfa/fwl/core/ifwl_spinbutton.cpp | 2 +- xfa/fwl/core/ifwl_tooltip.cpp | 2 +- xfa/fwl/core/ifwl_widget.cpp | 2 +- xfa/fwl/core/ifwl_widgetmgrdelegate.h | 24 ++ xfa/fxfa/app/xfa_ffapp.cpp | 2 +- xfa/fxfa/app/xfa_ffbarcode.cpp | 2 +- xfa/fxfa/app/xfa_ffcheckbutton.cpp | 2 +- xfa/fxfa/app/xfa_ffchoicelist.cpp | 2 +- xfa/fxfa/app/xfa_ffdoc.cpp | 2 +- xfa/fxfa/app/xfa_ffimageedit.cpp | 2 +- xfa/fxfa/app/xfa_ffpushbutton.cpp | 2 +- xfa/fxfa/app/xfa_fftextedit.cpp | 2 +- 52 files changed, 943 insertions(+), 851 deletions(-) create mode 100644 xfa/fwl/core/cfwl_eventtarget.cpp create mode 100644 xfa/fwl/core/cfwl_eventtarget.h create mode 100644 xfa/fwl/core/cfwl_notedriver.cpp create mode 100644 xfa/fwl/core/cfwl_notedriver.h create mode 100644 xfa/fwl/core/cfwl_noteloop.cpp create mode 100644 xfa/fwl/core/cfwl_noteloop.h create mode 100644 xfa/fwl/core/cfwl_themepart.cpp create mode 100644 xfa/fwl/core/cfwl_widgetproperties.cpp delete mode 100644 xfa/fwl/core/fwl_noteimp.cpp delete mode 100644 xfa/fwl/core/fwl_noteimp.h create mode 100644 xfa/fwl/core/ifwl_widgetmgrdelegate.h diff --git a/BUILD.gn b/BUILD.gn index 11174aeb64..3542d457d9 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1190,6 +1190,8 @@ if (pdf_enable_xfa) { "xfa/fwl/core/cfwl_edit.h", "xfa/fwl/core/cfwl_event.cpp", "xfa/fwl/core/cfwl_event.h", + "xfa/fwl/core/cfwl_eventtarget.cpp", + "xfa/fwl/core/cfwl_eventtarget.h", "xfa/fwl/core/cfwl_evtcheckstatechanged.cpp", "xfa/fwl/core/cfwl_evtcheckstatechanged.h", "xfa/fwl/core/cfwl_evtcheckword.cpp", @@ -1242,6 +1244,10 @@ if (pdf_enable_xfa) { "xfa/fwl/core/cfwl_msgmousewheel.h", "xfa/fwl/core/cfwl_msgsetfocus.cpp", "xfa/fwl/core/cfwl_msgsetfocus.h", + "xfa/fwl/core/cfwl_notedriver.cpp", + "xfa/fwl/core/cfwl_notedriver.h", + "xfa/fwl/core/cfwl_noteloop.cpp", + "xfa/fwl/core/cfwl_noteloop.h", "xfa/fwl/core/cfwl_picturebox.cpp", "xfa/fwl/core/cfwl_picturebox.h", "xfa/fwl/core/cfwl_pushbutton.cpp", @@ -1249,18 +1255,18 @@ if (pdf_enable_xfa) { "xfa/fwl/core/cfwl_sysbtn.cpp", "xfa/fwl/core/cfwl_sysbtn.h", "xfa/fwl/core/cfwl_themebackground.h", + "xfa/fwl/core/cfwl_themepart.cpp", "xfa/fwl/core/cfwl_themepart.h", "xfa/fwl/core/cfwl_themetext.h", "xfa/fwl/core/cfwl_widget.cpp", "xfa/fwl/core/cfwl_widget.h", "xfa/fwl/core/cfwl_widgetmgr.cpp", "xfa/fwl/core/cfwl_widgetmgr.h", + "xfa/fwl/core/cfwl_widgetproperties.cpp", "xfa/fwl/core/cfwl_widgetproperties.h", "xfa/fwl/core/cfx_barcode.cpp", "xfa/fwl/core/cfx_barcode.h", "xfa/fwl/core/fwl_error.h", - "xfa/fwl/core/fwl_noteimp.cpp", - "xfa/fwl/core/fwl_noteimp.h", "xfa/fwl/core/fwl_widgetdef.h", "xfa/fwl/core/fwl_widgethit.h", "xfa/fwl/core/ifwl_adaptertimermgr.h", @@ -1312,6 +1318,7 @@ if (pdf_enable_xfa) { "xfa/fwl/core/ifwl_widget.cpp", "xfa/fwl/core/ifwl_widget.h", "xfa/fwl/core/ifwl_widgetdelegate.h", + "xfa/fwl/core/ifwl_widgetmgrdelegate.h", "xfa/fwl/theme/cfwl_arrowdata.cpp", "xfa/fwl/theme/cfwl_arrowdata.h", "xfa/fwl/theme/cfwl_barcodetp.cpp", diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp index 207071c69c..411091ced5 100644 --- a/core/fpdfapi/parser/cpdf_document.cpp +++ b/core/fpdfapi/parser/cpdf_document.cpp @@ -23,8 +23,8 @@ #include "core/fpdfapi/parser/cpdf_number.h" #include "core/fpdfapi/parser/cpdf_parser.h" #include "core/fpdfapi/parser/cpdf_reference.h" -#include "core/fpdfapi/parser/cpdf_string.h" #include "core/fpdfapi/parser/cpdf_stream.h" +#include "core/fpdfapi/parser/cpdf_string.h" #include "core/fpdfapi/render/cpdf_docrenderdata.h" #include "core/fpdfapi/render/render_int.h" #include "core/fxcodec/JBig2_DocumentContext.h" diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 7c389ef37c..d2a17d27fc 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -15,9 +15,9 @@ #include "core/fpdfapi/font/cpdf_type3char.h" #include "core/fpdfapi/font/cpdf_type3font.h" #include "core/fpdfapi/page/cpdf_docpagedata.h" -#include "core/fpdfapi/page/cpdf_graphicstates.h" #include "core/fpdfapi/page/cpdf_form.h" #include "core/fpdfapi/page/cpdf_formobject.h" +#include "core/fpdfapi/page/cpdf_graphicstates.h" #include "core/fpdfapi/page/cpdf_image.h" #include "core/fpdfapi/page/cpdf_imageobject.h" #include "core/fpdfapi/page/cpdf_meshstream.h" @@ -44,10 +44,10 @@ #include "core/fpdfdoc/cpdf_occontext.h" #include "core/fxcodec/fx_codec.h" #include "core/fxcrt/fx_safe_types.h" -#include "core/fxge/cfx_graphstatedata.h" #include "core/fxge/cfx_fxgedevice.h" -#include "core/fxge/cfx_renderdevice.h" +#include "core/fxge/cfx_graphstatedata.h" #include "core/fxge/cfx_pathdata.h" +#include "core/fxge/cfx_renderdevice.h" #include "core/fxge/ifx_renderdevicedriver.h" #include "third_party/base/numerics/safe_math.h" diff --git a/core/fpdfdoc/cpdf_dest_unittest.cpp b/core/fpdfdoc/cpdf_dest_unittest.cpp index bc83ecacfc..7c35371085 100644 --- a/core/fpdfdoc/cpdf_dest_unittest.cpp +++ b/core/fpdfdoc/cpdf_dest_unittest.cpp @@ -3,8 +3,8 @@ // found in the LICENSE file. #include "core/fpdfapi/parser/cpdf_array.h" -#include "core/fpdfapi/parser/cpdf_null.h" #include "core/fpdfapi/parser/cpdf_name.h" +#include "core/fpdfapi/parser/cpdf_null.h" #include "core/fpdfapi/parser/cpdf_number.h" #include "core/fpdfdoc/cpdf_dest.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/xfa/fwl/core/cfwl_barcode.h b/xfa/fwl/core/cfwl_barcode.h index 95b4cd29eb..2a4622f9fb 100644 --- a/xfa/fwl/core/cfwl_barcode.h +++ b/xfa/fwl/core/cfwl_barcode.h @@ -11,7 +11,7 @@ #include "xfa/fwl/core/fwl_error.h" #include "xfa/fwl/core/ifwl_barcode.h" -class CFWL_Barcode : public CFWL_Edit, public IFWL_BarcodeDP { +class CFWL_Barcode : public CFWL_Edit, public IFWL_Barcode::DataProvider { public: explicit CFWL_Barcode(const IFWL_App* pApp); ~CFWL_Barcode() override; @@ -21,7 +21,7 @@ class CFWL_Barcode : public CFWL_Edit, public IFWL_BarcodeDP { // IFWL_Widget::DataProvider void GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption) override; - // IFWL_BarcodeDP + // IFWL_Barcode::DataProvider BC_CHAR_ENCODING GetCharEncoding() const override; int32_t GetModuleHeight() const override; int32_t GetModuleWidth() const override; diff --git a/xfa/fwl/core/cfwl_checkbox.h b/xfa/fwl/core/cfwl_checkbox.h index d395aa058d..4d39a94726 100644 --- a/xfa/fwl/core/cfwl_checkbox.h +++ b/xfa/fwl/core/cfwl_checkbox.h @@ -10,7 +10,7 @@ #include "xfa/fwl/core/cfwl_widget.h" #include "xfa/fwl/core/ifwl_checkbox.h" -class CFWL_CheckBox : public CFWL_Widget, public IFWL_CheckBoxDP { +class CFWL_CheckBox : public CFWL_Widget, public IFWL_CheckBox::DataProvider { public: explicit CFWL_CheckBox(const IFWL_App* pApp); ~CFWL_CheckBox() override; @@ -20,7 +20,7 @@ class CFWL_CheckBox : public CFWL_Widget, public IFWL_CheckBoxDP { // IFWL_Widget::DataProvider void GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption) override; - // IFWL_CheckBoxDP + // IFWL_CheckBox::DataProvider FX_FLOAT GetBoxSize(IFWL_Widget* pWidget) override; void SetBoxSize(FX_FLOAT fHeight); diff --git a/xfa/fwl/core/cfwl_datetimepicker.h b/xfa/fwl/core/cfwl_datetimepicker.h index 8d983c9cdd..68cc421147 100644 --- a/xfa/fwl/core/cfwl_datetimepicker.h +++ b/xfa/fwl/core/cfwl_datetimepicker.h @@ -10,7 +10,8 @@ #include "xfa/fwl/core/cfwl_widget.h" #include "xfa/fwl/core/ifwl_datetimepicker.h" -class CFWL_DateTimePicker : public CFWL_Widget, public IFWL_DateTimePickerDP { +class CFWL_DateTimePicker : public CFWL_Widget, + public IFWL_DateTimePicker::DataProvider { public: explicit CFWL_DateTimePicker(const IFWL_App* pApp); ~CFWL_DateTimePicker() override; @@ -20,7 +21,7 @@ class CFWL_DateTimePicker : public CFWL_Widget, public IFWL_DateTimePickerDP { // IFWL_Widget::DataProvider void GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption) override; - // IFWL_DateTimePickerDP + // IFWL_DateTimePicker::DataProvider void GetToday(IFWL_Widget* pWidget, int32_t& iYear, int32_t& iMonth, diff --git a/xfa/fwl/core/cfwl_eventtarget.cpp b/xfa/fwl/core/cfwl_eventtarget.cpp new file mode 100644 index 0000000000..77fb9d8354 --- /dev/null +++ b/xfa/fwl/core/cfwl_eventtarget.cpp @@ -0,0 +1,74 @@ +// Copyright 2016 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/cfwl_eventtarget.h" + +#include "xfa/fwl/core/ifwl_widget.h" +#include "xfa/fwl/core/ifwl_widgetdelegate.h" + +CFWL_EventTarget::CFWL_EventTarget(IFWL_Widget* pListener) + : m_pListener(pListener), m_bInvalid(false) {} + +CFWL_EventTarget::~CFWL_EventTarget() { + m_eventSources.RemoveAll(); +} + +int32_t CFWL_EventTarget::SetEventSource(IFWL_Widget* pSource, + uint32_t dwFilter) { + if (pSource) { + m_eventSources.SetAt(pSource, dwFilter); + return m_eventSources.GetCount(); + } + return 1; +} + +bool CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) { + IFWL_WidgetDelegate* pDelegate = m_pListener->GetDelegate(); + if (!pDelegate) + return false; + if (m_eventSources.GetCount() == 0) { + pDelegate->OnProcessEvent(pEvent); + return true; + } + + FX_POSITION pos = m_eventSources.GetStartPosition(); + while (pos) { + IFWL_Widget* pSource = nullptr; + uint32_t dwFilter = 0; + m_eventSources.GetNextAssoc(pos, (void*&)pSource, dwFilter); + if (pSource == pEvent->m_pSrcTarget) { + if (IsFilterEvent(pEvent, dwFilter)) { + pDelegate->OnProcessEvent(pEvent); + return true; + } + } + } + return false; +} + +bool CFWL_EventTarget::IsFilterEvent(CFWL_Event* pEvent, + uint32_t dwFilter) const { + if (dwFilter == FWL_EVENT_ALL_MASK) + return true; + + switch (pEvent->GetClassID()) { + case CFWL_EventType::Mouse: + return !!(dwFilter & FWL_EVENT_MOUSE_MASK); + case CFWL_EventType::MouseWheel: + return !!(dwFilter & FWL_EVENT_MOUSEWHEEL_MASK); + case CFWL_EventType::Key: + return !!(dwFilter & FWL_EVENT_KEY_MASK); + case CFWL_EventType::SetFocus: + case CFWL_EventType::KillFocus: + return !!(dwFilter & FWL_EVENT_FOCUSCHANGED_MASK); + case CFWL_EventType::Close: + return !!(dwFilter & FWL_EVENT_CLOSE_MASK); + case CFWL_EventType::SizeChanged: + return !!(dwFilter & FWL_EVENT_SIZECHANGED_MASK); + default: + return !!(dwFilter & FWL_EVENT_CONTROL_MASK); + } +} diff --git a/xfa/fwl/core/cfwl_eventtarget.h b/xfa/fwl/core/cfwl_eventtarget.h new file mode 100644 index 0000000000..b7e43ce5ff --- /dev/null +++ b/xfa/fwl/core/cfwl_eventtarget.h @@ -0,0 +1,36 @@ +// Copyright 2016 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_CFWL_EVENTTARGET_H_ +#define XFA_FWL_CORE_CFWL_EVENTTARGET_H_ + +#include "core/fxcrt/fx_basic.h" +#include "xfa/fwl/core/cfwl_event.h" + +class CFWL_Event; +class IFWL_Widget; + +class CFWL_EventTarget { + public: + explicit CFWL_EventTarget(IFWL_Widget* pListener); + ~CFWL_EventTarget(); + + int32_t SetEventSource(IFWL_Widget* pSource, + uint32_t dwFilter = FWL_EVENT_ALL_MASK); + bool ProcessEvent(CFWL_Event* pEvent); + + bool IsInvalid() const { return m_bInvalid; } + void FlagInvalid() { m_bInvalid = true; } + + private: + bool IsFilterEvent(CFWL_Event* pEvent, uint32_t dwFilter) const; + + CFX_MapPtrTemplate m_eventSources; + IFWL_Widget* m_pListener; + bool m_bInvalid; +}; + +#endif // XFA_FWL_CORE_CFWL_EVENTTARGET_H_ diff --git a/xfa/fwl/core/cfwl_notedriver.cpp b/xfa/fwl/core/cfwl_notedriver.cpp new file mode 100644 index 0000000000..7c53e54847 --- /dev/null +++ b/xfa/fwl/core/cfwl_notedriver.cpp @@ -0,0 +1,489 @@ +// 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/cfwl_notedriver.h" + +#include + +#include "core/fxcrt/fx_ext.h" +#include "third_party/base/ptr_util.h" +#include "third_party/base/stl_util.h" +#include "xfa/fwl/core/cfwl_eventtarget.h" +#include "xfa/fwl/core/cfwl_msgkey.h" +#include "xfa/fwl/core/cfwl_msgkillfocus.h" +#include "xfa/fwl/core/cfwl_msgmouse.h" +#include "xfa/fwl/core/cfwl_msgmousewheel.h" +#include "xfa/fwl/core/cfwl_msgsetfocus.h" +#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" + +CFWL_NoteDriver::CFWL_NoteDriver() + : m_pHover(nullptr), + m_pFocus(nullptr), + m_pGrab(nullptr), + m_pNoteLoop(pdfium::MakeUnique()) { + PushNoteLoop(m_pNoteLoop.get()); +} + +CFWL_NoteDriver::~CFWL_NoteDriver() { + ClearEventTargets(true); +} + +void CFWL_NoteDriver::SendEvent(CFWL_Event* pNote) { + if (m_eventTargets.empty()) + return; + + for (const auto& pair : m_eventTargets) { + CFWL_EventTarget* pEventTarget = pair.second; + if (pEventTarget && !pEventTarget->IsInvalid()) + pEventTarget->ProcessEvent(pNote); + } +} + +void CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener, + IFWL_Widget* pEventSource, + uint32_t dwFilter) { + uint32_t key = pListener->GetEventKey(); + if (key == 0) { + do { + key = rand(); + } while (key == 0 || pdfium::ContainsKey(m_eventTargets, key)); + pListener->SetEventKey(key); + } + if (!m_eventTargets[key]) + m_eventTargets[key] = new CFWL_EventTarget(pListener); + + m_eventTargets[key]->SetEventSource(pEventSource, dwFilter); +} + +void CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) { + uint32_t key = pListener->GetEventKey(); + if (key == 0) + return; + + auto it = m_eventTargets.find(key); + if (it != m_eventTargets.end()) + it->second->FlagInvalid(); +} + +void CFWL_NoteDriver::PushNoteLoop(CFWL_NoteLoop* pNoteLoop) { + m_noteLoopQueue.Add(pNoteLoop); +} + +CFWL_NoteLoop* CFWL_NoteDriver::PopNoteLoop() { + int32_t pos = m_noteLoopQueue.GetSize(); + if (pos <= 0) + return nullptr; + + CFWL_NoteLoop* p = m_noteLoopQueue.GetAt(pos - 1); + m_noteLoopQueue.RemoveAt(pos - 1); + return p; +} + +bool CFWL_NoteDriver::SetFocus(IFWL_Widget* pFocus, bool bNotify) { + if (m_pFocus == pFocus) + return true; + + IFWL_Widget* pPrev = m_pFocus; + m_pFocus = pFocus; + if (pPrev) { + CFWL_MsgKillFocus ms; + ms.m_pDstTarget = pPrev; + ms.m_pSrcTarget = pPrev; + if (bNotify) + ms.m_dwExtend = 1; + + if (IFWL_WidgetDelegate* pDelegate = pPrev->GetDelegate()) + pDelegate->OnProcessMessage(&ms); + } + if (pFocus) { + IFWL_Widget* pWidget = + pFocus->GetOwnerApp()->GetWidgetMgr()->GetSystemFormWidget(pFocus); + IFWL_Form* pForm = static_cast(pWidget); + if (pForm) + pForm->SetSubFocus(pFocus); + + CFWL_MsgSetFocus ms; + ms.m_pDstTarget = pFocus; + if (bNotify) + ms.m_dwExtend = 1; + if (IFWL_WidgetDelegate* pDelegate = pFocus->GetDelegate()) + pDelegate->OnProcessMessage(&ms); + } + return true; +} + +void CFWL_NoteDriver::Run() { +#if (_FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_WIN32_DESKTOP_ || \ + _FX_OS_ == _FX_WIN64_) + for (;;) { + CFWL_NoteLoop* pTopLoop = GetTopLoop(); + if (!pTopLoop || !pTopLoop->ContinueModal()) + break; + UnqueueMessage(pTopLoop); + } +#endif +} + +void CFWL_NoteDriver::NotifyTargetHide(IFWL_Widget* pNoteTarget) { + if (m_pFocus == pNoteTarget) + m_pFocus = nullptr; + if (m_pHover == pNoteTarget) + m_pHover = nullptr; + if (m_pGrab == pNoteTarget) + m_pGrab = nullptr; +} + +void CFWL_NoteDriver::NotifyTargetDestroy(IFWL_Widget* pNoteTarget) { + if (m_pFocus == pNoteTarget) + m_pFocus = nullptr; + if (m_pHover == pNoteTarget) + m_pHover = nullptr; + if (m_pGrab == pNoteTarget) + m_pGrab = nullptr; + + UnregisterEventTarget(pNoteTarget); + + for (int32_t nIndex = 0; nIndex < m_forms.GetSize(); nIndex++) { + IFWL_Form* pForm = static_cast(m_forms[nIndex]); + if (!pForm) + continue; + + IFWL_Widget* pSubFocus = pForm->GetSubFocus(); + if (!pSubFocus) + return; + if (pSubFocus == pNoteTarget) + pForm->SetSubFocus(nullptr); + } +} + +void CFWL_NoteDriver::RegisterForm(IFWL_Widget* pForm) { + if (!pForm || m_forms.Find(pForm) >= 0) + return; + + m_forms.Add(pForm); + if (m_forms.GetSize() != 1) + return; + + CFWL_NoteLoop* pLoop = m_noteLoopQueue.GetAt(0); + if (!pLoop) + return; + + pLoop->SetMainForm(pForm); +} + +void CFWL_NoteDriver::UnRegisterForm(IFWL_Widget* pForm) { + if (!pForm) + return; + + int32_t nIndex = m_forms.Find(pForm); + if (nIndex < 0) + return; + + m_forms.RemoveAt(nIndex); +} + +void CFWL_NoteDriver::QueueMessage(std::unique_ptr pMessage) { + m_noteQueue.push_back(std::move(pMessage)); +} + +void CFWL_NoteDriver::UnqueueMessage(CFWL_NoteLoop* pNoteLoop) { + if (m_noteQueue.empty()) + return; + + std::unique_ptr pMessage = std::move(m_noteQueue[0]); + m_noteQueue.pop_front(); + + if (!IsValidMessage(pMessage.get())) + return; + + ProcessMessage(pMessage.get()); +} + +CFWL_NoteLoop* CFWL_NoteDriver::GetTopLoop() const { + int32_t size = m_noteLoopQueue.GetSize(); + if (size <= 0) + return nullptr; + return m_noteLoopQueue[size - 1]; +} + +void CFWL_NoteDriver::ProcessMessage(CFWL_Message* pMessage) { + CFWL_WidgetMgr* pWidgetMgr = + pMessage->m_pDstTarget->GetOwnerApp()->GetWidgetMgr(); + IFWL_Widget* pMessageForm = pWidgetMgr->IsFormDisabled() + ? pMessage->m_pDstTarget + : GetMessageForm(pMessage->m_pDstTarget); + if (!pMessageForm) + return; + if (!DispatchMessage(pMessage, pMessageForm)) + return; + + if (pMessage->GetClassID() == CFWL_MessageType::Mouse) + MouseSecondary(pMessage); +} + +bool CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage, + IFWL_Widget* pMessageForm) { + switch (pMessage->GetClassID()) { + case CFWL_MessageType::SetFocus: { + if (!DoSetFocus(pMessage, pMessageForm)) + return false; + break; + } + case CFWL_MessageType::KillFocus: { + if (!DoKillFocus(pMessage, pMessageForm)) + return false; + break; + } + case CFWL_MessageType::Key: { + if (!DoKey(pMessage, pMessageForm)) + return false; + break; + } + case CFWL_MessageType::Mouse: { + if (!DoMouse(pMessage, pMessageForm)) + return false; + break; + } + case CFWL_MessageType::MouseWheel: { + if (!DoWheel(pMessage, pMessageForm)) + return false; + break; + } + default: + break; + } + if (IFWL_WidgetDelegate* pDelegate = pMessage->m_pDstTarget->GetDelegate()) + pDelegate->OnProcessMessage(pMessage); + + return true; +} + +bool CFWL_NoteDriver::DoSetFocus(CFWL_Message* pMessage, + IFWL_Widget* pMessageForm) { + CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); + if (pWidgetMgr->IsFormDisabled()) { + m_pFocus = pMessage->m_pDstTarget; + return true; + } + + IFWL_Widget* pWidget = pMessage->m_pDstTarget; + if (!pWidget) + return false; + + IFWL_Form* pForm = static_cast(pWidget); + IFWL_Widget* pSubFocus = pForm->GetSubFocus(); + if (pSubFocus && ((pSubFocus->GetStates() & FWL_WGTSTATE_Focused) == 0)) { + pMessage->m_pDstTarget = pSubFocus; + if (m_pFocus != pMessage->m_pDstTarget) { + m_pFocus = pMessage->m_pDstTarget; + return true; + } + } + return false; +} + +bool CFWL_NoteDriver::DoKillFocus(CFWL_Message* pMessage, + IFWL_Widget* pMessageForm) { + CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); + if (pWidgetMgr->IsFormDisabled()) { + if (m_pFocus == pMessage->m_pDstTarget) + m_pFocus = nullptr; + return true; + } + + IFWL_Form* pForm = static_cast(pMessage->m_pDstTarget); + if (!pForm) + return false; + + IFWL_Widget* pSubFocus = pForm->GetSubFocus(); + if (pSubFocus && (pSubFocus->GetStates() & FWL_WGTSTATE_Focused)) { + pMessage->m_pDstTarget = pSubFocus; + if (m_pFocus == pMessage->m_pDstTarget) { + m_pFocus = nullptr; + return true; + } + } + return false; +} + +bool CFWL_NoteDriver::DoKey(CFWL_Message* pMessage, IFWL_Widget* pMessageForm) { + CFWL_MsgKey* pMsg = static_cast(pMessage); +#if (_FX_OS_ != _FX_MACOSX_) + if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown && + pMsg->m_dwKeyCode == FWL_VKEY_Tab) { + CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); + IFWL_Widget* pForm = GetMessageForm(pMsg->m_pDstTarget); + IFWL_Widget* pFocus = m_pFocus; + if (m_pFocus && pWidgetMgr->GetSystemFormWidget(m_pFocus) != pForm) + pFocus = nullptr; + + bool bFind = false; + IFWL_Widget* pNextTabStop = pWidgetMgr->NextTab(pForm, pFocus, bFind); + if (!pNextTabStop) { + bFind = false; + pNextTabStop = pWidgetMgr->NextTab(pForm, nullptr, bFind); + } + if (pNextTabStop == pFocus) + return true; + if (pNextTabStop) + SetFocus(pNextTabStop); + return true; + } +#endif + + if (!m_pFocus) { + if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown && + pMsg->m_dwKeyCode == FWL_VKEY_Return) { + CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); + IFWL_Widget* defButton = pWidgetMgr->GetDefaultButton(pMessageForm); + if (defButton) { + pMsg->m_pDstTarget = defButton; + return true; + } + } + return false; + } + pMsg->m_pDstTarget = m_pFocus; + return true; +} + +bool CFWL_NoteDriver::DoMouse(CFWL_Message* pMessage, + IFWL_Widget* pMessageForm) { + CFWL_MsgMouse* pMsg = static_cast(pMessage); + if (pMsg->m_dwCmd == FWL_MouseCommand::Leave || + pMsg->m_dwCmd == FWL_MouseCommand::Hover || + pMsg->m_dwCmd == FWL_MouseCommand::Enter) { + return !!pMsg->m_pDstTarget; + } + if (pMsg->m_pDstTarget != pMessageForm) + pMsg->m_pDstTarget->TransformTo(pMessageForm, pMsg->m_fx, pMsg->m_fy); + if (!DoMouseEx(pMsg, pMessageForm)) + pMsg->m_pDstTarget = pMessageForm; + return true; +} + +bool CFWL_NoteDriver::DoWheel(CFWL_Message* pMessage, + IFWL_Widget* pMessageForm) { + CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); + if (!pWidgetMgr) + return false; + + CFWL_MsgMouseWheel* pMsg = static_cast(pMessage); + IFWL_Widget* pDst = + pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy); + if (!pDst) + return false; + + pMessageForm->TransformTo(pDst, pMsg->m_fx, pMsg->m_fy); + pMsg->m_pDstTarget = pDst; + return true; +} + +bool CFWL_NoteDriver::DoMouseEx(CFWL_Message* pMessage, + IFWL_Widget* pMessageForm) { + CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); + if (!pWidgetMgr) + return false; + IFWL_Widget* pTarget = nullptr; + if (m_pGrab) + pTarget = m_pGrab; + + CFWL_MsgMouse* pMsg = static_cast(pMessage); + if (!pTarget) { + pTarget = + pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy); + } + if (pTarget) { + if (pMessageForm != pTarget) + pMessageForm->TransformTo(pTarget, pMsg->m_fx, pMsg->m_fy); + } + if (!pTarget) + return false; + + pMsg->m_pDstTarget = pTarget; + return true; +} + +void CFWL_NoteDriver::MouseSecondary(CFWL_Message* pMessage) { + IFWL_Widget* pTarget = pMessage->m_pDstTarget; + if (pTarget == m_pHover) + return; + + CFWL_MsgMouse* pMsg = static_cast(pMessage); + if (m_pHover) { + CFWL_MsgMouse msLeave; + msLeave.m_pDstTarget = m_pHover; + msLeave.m_fx = pMsg->m_fx; + msLeave.m_fy = pMsg->m_fy; + pTarget->TransformTo(m_pHover, msLeave.m_fx, msLeave.m_fy); + + msLeave.m_dwFlags = 0; + msLeave.m_dwCmd = FWL_MouseCommand::Leave; + DispatchMessage(&msLeave, nullptr); + } + if (pTarget->GetClassID() == FWL_Type::Form) { + m_pHover = nullptr; + return; + } + m_pHover = pTarget; + + CFWL_MsgMouse msHover; + msHover.m_pDstTarget = pTarget; + msHover.m_fx = pMsg->m_fx; + msHover.m_fy = pMsg->m_fy; + msHover.m_dwFlags = 0; + msHover.m_dwCmd = FWL_MouseCommand::Hover; + DispatchMessage(&msHover, nullptr); +} + +bool CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) { + for (int32_t i = 0; i < m_noteLoopQueue.GetSize(); i++) { + CFWL_NoteLoop* pNoteLoop = m_noteLoopQueue[i]; + IFWL_Widget* pForm = pNoteLoop->GetForm(); + if (pForm && (pForm == pMessage->m_pDstTarget)) + return true; + } + + for (int32_t j = 0; j < m_forms.GetSize(); j++) { + IFWL_Form* pForm = static_cast(m_forms[j]); + if (pForm == pMessage->m_pDstTarget) + return true; + } + return false; +} + +IFWL_Widget* CFWL_NoteDriver::GetMessageForm(IFWL_Widget* pDstTarget) { + int32_t iTrackLoop = m_noteLoopQueue.GetSize(); + if (iTrackLoop <= 0) + return nullptr; + + IFWL_Widget* pMessageForm = nullptr; + if (iTrackLoop > 1) + pMessageForm = m_noteLoopQueue[iTrackLoop - 1]->GetForm(); + else if (m_forms.Find(pDstTarget) < 0) + pMessageForm = pDstTarget; + if (!pMessageForm && pDstTarget) { + CFWL_WidgetMgr* pWidgetMgr = pDstTarget->GetOwnerApp()->GetWidgetMgr(); + if (!pWidgetMgr) + return nullptr; + pMessageForm = pWidgetMgr->GetSystemFormWidget(pDstTarget); + } + return pMessageForm; +} + +void CFWL_NoteDriver::ClearEventTargets(bool bRemoveAll) { + auto it = m_eventTargets.begin(); + while (it != m_eventTargets.end()) { + auto old = it++; + if (old->second && (bRemoveAll || old->second->IsInvalid())) { + delete old->second; + m_eventTargets.erase(old); + } + } +} diff --git a/xfa/fwl/core/cfwl_notedriver.h b/xfa/fwl/core/cfwl_notedriver.h new file mode 100644 index 0000000000..a9b2c715db --- /dev/null +++ b/xfa/fwl/core/cfwl_notedriver.h @@ -0,0 +1,82 @@ +// 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_CFWL_NOTEDRIVER_H_ +#define XFA_FWL_CORE_CFWL_NOTEDRIVER_H_ + +#include +#include +#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 { + public: + CFWL_NoteDriver(); + ~CFWL_NoteDriver(); + + void SendEvent(CFWL_Event* pNote); + + void RegisterEventTarget(IFWL_Widget* pListener, + IFWL_Widget* pEventSource = nullptr, + uint32_t dwFilter = FWL_EVENT_ALL_MASK); + void UnregisterEventTarget(IFWL_Widget* pListener); + void ClearEventTargets(bool bRemoveAll); + + CFWL_NoteLoop* GetTopLoop() const; + void PushNoteLoop(CFWL_NoteLoop* pNoteLoop); + CFWL_NoteLoop* PopNoteLoop(); + + IFWL_Widget* GetFocus() const { return m_pFocus; } + bool SetFocus(IFWL_Widget* pFocus, bool bNotify = false); + void SetGrab(IFWL_Widget* pGrab, bool bSet) { + m_pGrab = bSet ? pGrab : nullptr; + } + + void Run(); + + void NotifyTargetHide(IFWL_Widget* pNoteTarget); + void NotifyTargetDestroy(IFWL_Widget* pNoteTarget); + + void RegisterForm(IFWL_Widget* pForm); + void UnRegisterForm(IFWL_Widget* pForm); + + void QueueMessage(std::unique_ptr pMessage); + void UnqueueMessage(CFWL_NoteLoop* pNoteLoop); + void ProcessMessage(CFWL_Message* pMessage); + + private: + bool DispatchMessage(CFWL_Message* pMessage, IFWL_Widget* pMessageForm); + bool DoSetFocus(CFWL_Message* pMsg, IFWL_Widget* pMessageForm); + bool DoKillFocus(CFWL_Message* pMsg, IFWL_Widget* pMessageForm); + bool DoKey(CFWL_Message* pMsg, IFWL_Widget* pMessageForm); + bool DoMouse(CFWL_Message* pMsg, IFWL_Widget* pMessageForm); + bool DoWheel(CFWL_Message* pMsg, IFWL_Widget* pMessageForm); + bool DoMouseEx(CFWL_Message* pMsg, IFWL_Widget* pMessageForm); + void MouseSecondary(CFWL_Message* pMsg); + bool IsValidMessage(CFWL_Message* pMessage); + IFWL_Widget* GetMessageForm(IFWL_Widget* pDstTarget); + + CFX_ArrayTemplate m_forms; + std::deque> m_noteQueue; + CFX_ArrayTemplate m_noteLoopQueue; + std::unordered_map m_eventTargets; + IFWL_Widget* m_pHover; + IFWL_Widget* m_pFocus; + IFWL_Widget* m_pGrab; + std::unique_ptr m_pNoteLoop; +}; + +#endif // XFA_FWL_CORE_CFWL_NOTEDRIVER_H_ diff --git a/xfa/fwl/core/cfwl_noteloop.cpp b/xfa/fwl/core/cfwl_noteloop.cpp new file mode 100644 index 0000000000..4b2b6105ed --- /dev/null +++ b/xfa/fwl/core/cfwl_noteloop.cpp @@ -0,0 +1,9 @@ +// Copyright 2016 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/cfwl_noteloop.h" + +CFWL_NoteLoop::CFWL_NoteLoop() : m_bContinueModal(true) {} diff --git a/xfa/fwl/core/cfwl_noteloop.h b/xfa/fwl/core/cfwl_noteloop.h new file mode 100644 index 0000000000..f07bdc56a4 --- /dev/null +++ b/xfa/fwl/core/cfwl_noteloop.h @@ -0,0 +1,27 @@ +// Copyright 2016 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_CFWL_NOTELOOP_H_ +#define XFA_FWL_CORE_CFWL_NOTELOOP_H_ + +class IFWL_Widget; + +class CFWL_NoteLoop { + public: + CFWL_NoteLoop(); + ~CFWL_NoteLoop() {} + + IFWL_Widget* GetForm() const { return m_pForm; } + bool ContinueModal() const { return m_bContinueModal; } + void EndModalLoop() { m_bContinueModal = false; } + void SetMainForm(IFWL_Widget* pForm) { m_pForm = pForm; } + + private: + IFWL_Widget* m_pForm; + bool m_bContinueModal; +}; + +#endif // XFA_FWL_CORE_CFWL_NOTELOOP_H_ diff --git a/xfa/fwl/core/cfwl_themepart.cpp b/xfa/fwl/core/cfwl_themepart.cpp new file mode 100644 index 0000000000..6b48a1e03e --- /dev/null +++ b/xfa/fwl/core/cfwl_themepart.cpp @@ -0,0 +1,18 @@ +// Copyright 2016 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/cfwl_themepart.h" + +CFWL_ThemePart::CFWL_ThemePart() + : m_pWidget(nullptr), + m_iPart(CFWL_Part::None), + m_dwStates(CFWL_PartState_Normal), + m_bMaximize(false), + m_bStaticBackground(false), + m_pData(nullptr) { + m_rtPart.Reset(); + m_matrix.SetIdentity(); +} diff --git a/xfa/fwl/core/cfwl_themepart.h b/xfa/fwl/core/cfwl_themepart.h index 1b2c706274..93565e91f5 100644 --- a/xfa/fwl/core/cfwl_themepart.h +++ b/xfa/fwl/core/cfwl_themepart.h @@ -93,15 +93,4 @@ class CFWL_ThemePart { void* m_pData; }; -inline CFWL_ThemePart::CFWL_ThemePart() - : m_pWidget(nullptr), - m_iPart(CFWL_Part::None), - m_dwStates(CFWL_PartState_Normal), - m_bMaximize(false), - m_bStaticBackground(false), - m_pData(nullptr) { - m_rtPart.Reset(); - m_matrix.SetIdentity(); -} - #endif // XFA_FWL_CORE_CFWL_THEMEPART_H_ diff --git a/xfa/fwl/core/cfwl_widget.cpp b/xfa/fwl/core/cfwl_widget.cpp index 39d86fa8ba..2e08be7817 100644 --- a/xfa/fwl/core/cfwl_widget.cpp +++ b/xfa/fwl/core/cfwl_widget.cpp @@ -7,9 +7,9 @@ #include "xfa/fwl/core/cfwl_widget.h" #include "xfa/fde/tto/fde_textout.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fwl/core/cfwl_themetext.h" #include "xfa/fwl/core/cfwl_widgetmgr.h" -#include "xfa/fwl/core/fwl_noteimp.h" #include "xfa/fwl/core/ifwl_app.h" #include "xfa/fwl/core/ifwl_themeprovider.h" diff --git a/xfa/fwl/core/cfwl_widgetmgr.cpp b/xfa/fwl/core/cfwl_widgetmgr.cpp index 6623e8f9fb..6c11018893 100644 --- a/xfa/fwl/core/cfwl_widgetmgr.cpp +++ b/xfa/fwl/core/cfwl_widgetmgr.cpp @@ -8,7 +8,8 @@ #include -#include "xfa/fwl/core/fwl_noteimp.h" +#include "third_party/base/ptr_util.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fwl/core/ifwl_app.h" #include "xfa/fwl/core/ifwl_form.h" #include "xfa/fxfa/app/xfa_fwladapter.h" @@ -38,7 +39,7 @@ bool FWL_UseOffscreen(IFWL_Widget* pWidget) { CFWL_WidgetMgr::CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative) : m_dwCapability(0), m_pAdapter(pAdapterNative->GetWidgetMgr(this)) { ASSERT(m_pAdapter); - m_mapWidgetItem[nullptr].reset(new CFWL_WidgetMgrItem); + m_mapWidgetItem[nullptr] = pdfium::MakeUnique(); #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) m_rtScreen.Reset(); #endif @@ -47,17 +48,17 @@ CFWL_WidgetMgr::CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative) CFWL_WidgetMgr::~CFWL_WidgetMgr() {} IFWL_Widget* CFWL_WidgetMgr::GetParentWidget(IFWL_Widget* pWidget) const { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + Item* pItem = GetWidgetMgrItem(pWidget); return pItem && pItem->pParent ? pItem->pParent->pWidget : nullptr; } IFWL_Widget* CFWL_WidgetMgr::GetOwnerWidget(IFWL_Widget* pWidget) const { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + Item* pItem = GetWidgetMgrItem(pWidget); return pItem && pItem->pOwner ? pItem->pOwner->pWidget : nullptr; } IFWL_Widget* CFWL_WidgetMgr::GetFirstSiblingWidget(IFWL_Widget* pWidget) const { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + Item* pItem = GetWidgetMgrItem(pWidget); if (!pItem) return nullptr; @@ -68,22 +69,22 @@ IFWL_Widget* CFWL_WidgetMgr::GetFirstSiblingWidget(IFWL_Widget* pWidget) const { } IFWL_Widget* CFWL_WidgetMgr::GetPriorSiblingWidget(IFWL_Widget* pWidget) const { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + Item* pItem = GetWidgetMgrItem(pWidget); return pItem && pItem->pPrevious ? pItem->pPrevious->pWidget : nullptr; } IFWL_Widget* CFWL_WidgetMgr::GetNextSiblingWidget(IFWL_Widget* pWidget) const { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + Item* pItem = GetWidgetMgrItem(pWidget); return pItem && pItem->pNext ? pItem->pNext->pWidget : nullptr; } IFWL_Widget* CFWL_WidgetMgr::GetFirstChildWidget(IFWL_Widget* pWidget) const { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + Item* pItem = GetWidgetMgrItem(pWidget); return pItem && pItem->pChild ? pItem->pChild->pWidget : nullptr; } IFWL_Widget* CFWL_WidgetMgr::GetLastChildWidget(IFWL_Widget* pWidget) const { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + Item* pItem = GetWidgetMgrItem(pWidget); if (!pItem) return nullptr; @@ -94,7 +95,7 @@ IFWL_Widget* CFWL_WidgetMgr::GetLastChildWidget(IFWL_Widget* pWidget) const { } IFWL_Widget* CFWL_WidgetMgr::GetSystemFormWidget(IFWL_Widget* pWidget) const { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + Item* pItem = GetWidgetMgrItem(pWidget); while (pItem) { if (IsAbleNative(pItem->pWidget)) return pItem->pWidget; @@ -104,13 +105,13 @@ IFWL_Widget* CFWL_WidgetMgr::GetSystemFormWidget(IFWL_Widget* pWidget) const { } void CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + Item* pItem = GetWidgetMgrItem(pWidget); if (!pItem) return; if (!pItem->pParent) return; - CFWL_WidgetMgrItem* pChild = pItem->pParent->pChild; + Item* pChild = pItem->pParent->pChild; int32_t i = 0; while (pChild) { if (pChild == pItem) { @@ -203,18 +204,21 @@ void CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget, void CFWL_WidgetMgr::InsertWidget(IFWL_Widget* pParent, IFWL_Widget* pChild, int32_t nIndex) { - CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); + Item* pParentItem = GetWidgetMgrItem(pParent); if (!pParentItem) { - pParentItem = new CFWL_WidgetMgrItem(pParent); - m_mapWidgetItem[pParent].reset(pParentItem); + auto item = pdfium::MakeUnique(pParent); + pParentItem = item.get(); + m_mapWidgetItem[pParent] = std::move(item); + pParentItem->pParent = GetWidgetMgrItem(nullptr); SetWidgetIndex(pParent, -1); } - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pChild); + Item* pItem = GetWidgetMgrItem(pChild); if (!pItem) { - pItem = new CFWL_WidgetMgrItem(pChild); - m_mapWidgetItem[pChild].reset(pItem); + auto item = pdfium::MakeUnique(pChild); + pItem = item.get(); + m_mapWidgetItem[pChild] = std::move(item); } if (pItem->pParent && pItem->pParent != pParentItem) { if (pItem->pPrevious) @@ -229,7 +233,7 @@ void CFWL_WidgetMgr::InsertWidget(IFWL_Widget* pParent, } void CFWL_WidgetMgr::RemoveWidget(IFWL_Widget* pWidget) { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + Item* pItem = GetWidgetMgrItem(pWidget); if (!pItem) return; if (pItem->pPrevious) @@ -239,9 +243,9 @@ void CFWL_WidgetMgr::RemoveWidget(IFWL_Widget* pWidget) { if (pItem->pParent && pItem->pParent->pChild == pItem) pItem->pParent->pChild = pItem->pNext; - CFWL_WidgetMgrItem* pChild = pItem->pChild; + Item* pChild = pItem->pChild; while (pChild) { - CFWL_WidgetMgrItem* pNext = pChild->pNext; + Item* pNext = pChild->pNext; RemoveWidget(pChild->pWidget); pChild = pNext; } @@ -249,24 +253,27 @@ void CFWL_WidgetMgr::RemoveWidget(IFWL_Widget* pWidget) { } void CFWL_WidgetMgr::SetOwner(IFWL_Widget* pOwner, IFWL_Widget* pOwned) { - CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pOwner); + Item* pParentItem = GetWidgetMgrItem(pOwner); if (!pParentItem) { - pParentItem = new CFWL_WidgetMgrItem(pOwner); - m_mapWidgetItem[pOwner].reset(pParentItem); + auto item = pdfium::MakeUnique(pOwner); + pParentItem = item.get(); + m_mapWidgetItem[pOwner] = std::move(item); + pParentItem->pParent = GetWidgetMgrItem(nullptr); SetWidgetIndex(pOwner, -1); } - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pOwned); + Item* pItem = GetWidgetMgrItem(pOwned); if (!pItem) { - pItem = new CFWL_WidgetMgrItem(pOwned); - m_mapWidgetItem[pOwned].reset(pItem); + auto item = pdfium::MakeUnique(pOwned); + pItem = item.get(); + m_mapWidgetItem[pOwned] = std::move(item); } pItem->pOwner = pParentItem; } void CFWL_WidgetMgr::SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild) { - CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pChild); + Item* pParentItem = GetWidgetMgrItem(pParent); + Item* pItem = GetWidgetMgrItem(pChild); if (!pItem) return; if (pItem->pParent && pItem->pParent != pParentItem) { @@ -289,7 +296,7 @@ void CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, if (!FWL_UseOffscreen(pWidget)) return; - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + Item* pItem = GetWidgetMgrItem(pWidget); pItem->iRedrawCounter++; if (pItem->pOffscreen) { CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice(); @@ -427,12 +434,11 @@ void CFWL_WidgetMgr::ResetRedrawCounts(IFWL_Widget* pWidget) { GetWidgetMgrItem(pWidget)->iRedrawCounter = 0; } -CFWL_WidgetMgrItem* CFWL_WidgetMgr::GetWidgetMgrItem( +CFWL_WidgetMgr::Item* CFWL_WidgetMgr::GetWidgetMgrItem( IFWL_Widget* pWidget) const { auto it = m_mapWidgetItem.find(pWidget); - return it != m_mapWidgetItem.end() - ? static_cast(it->second.get()) - : nullptr; + return it != m_mapWidgetItem.end() ? static_cast(it->second.get()) + : nullptr; } bool CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) const { @@ -591,7 +597,7 @@ CFX_Graphics* CFWL_WidgetMgr::DrawWidgetBefore(IFWL_Widget* pWidget, if (!FWL_UseOffscreen(pWidget)) return pGraphics; - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + Item* pItem = GetWidgetMgrItem(pWidget); if (!pItem->pOffscreen) { pItem->pOffscreen.reset(new CFX_Graphics); CFX_RectF rect; @@ -610,21 +616,21 @@ void CFWL_WidgetMgr::DrawWidgetAfter(IFWL_Widget* pWidget, CFX_RectF& rtClip, const CFX_Matrix* pMatrix) { if (FWL_UseOffscreen(pWidget)) { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + Item* pItem = GetWidgetMgrItem(pWidget); pGraphics->Transfer(pItem->pOffscreen.get(), rtClip.left, rtClip.top, rtClip, pMatrix); #ifdef _WIN32 pItem->pOffscreen->ClearClip(); #endif } - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + Item* pItem = GetWidgetMgrItem(pWidget); pItem->iRedrawCounter = 0; } bool CFWL_WidgetMgr::IsNeedRepaint(IFWL_Widget* pWidget, CFX_Matrix* pMatrix, const CFX_RectF& rtDirty) { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + Item* pItem = GetWidgetMgrItem(pWidget); if (pItem && pItem->iRedrawCounter > 0) { pItem->iRedrawCounter = 0; return true; @@ -722,7 +728,7 @@ bool CFWL_WidgetMgr::IsNeedRepaint(IFWL_Widget* pWidget, } bool CFWL_WidgetMgr::UseOffscreenDirect(IFWL_Widget* pWidget) const { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); + Item* pItem = GetWidgetMgrItem(pWidget); if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen)) return false; @@ -742,9 +748,9 @@ bool CFWL_WidgetMgr::UseOffscreenDirect(IFWL_Widget* pWidget) const { return pItem->iRedrawCounter == 0; } -CFWL_WidgetMgrItem::CFWL_WidgetMgrItem() : CFWL_WidgetMgrItem(nullptr) {} +CFWL_WidgetMgr::Item::Item() : CFWL_WidgetMgr::Item(nullptr) {} -CFWL_WidgetMgrItem::CFWL_WidgetMgrItem(IFWL_Widget* widget) +CFWL_WidgetMgr::Item::Item(IFWL_Widget* widget) : pParent(nullptr), pOwner(nullptr), pChild(nullptr), @@ -759,4 +765,4 @@ CFWL_WidgetMgrItem::CFWL_WidgetMgrItem(IFWL_Widget* widget) { } -CFWL_WidgetMgrItem::~CFWL_WidgetMgrItem() {} +CFWL_WidgetMgr::Item::~Item() {} diff --git a/xfa/fwl/core/cfwl_widgetmgr.h b/xfa/fwl/core/cfwl_widgetmgr.h index cdfa24a91d..0c6a184871 100644 --- a/xfa/fwl/core/cfwl_widgetmgr.h +++ b/xfa/fwl/core/cfwl_widgetmgr.h @@ -12,6 +12,7 @@ #include "core/fxcrt/fx_system.h" #include "xfa/fwl/core/fwl_error.h" +#include "xfa/fwl/core/ifwl_widgetmgrdelegate.h" #include "xfa/fxgraphics/cfx_graphics.h" #define FWL_WGTMGR_DisableForm 0x00000002 @@ -23,34 +24,6 @@ class CFX_Graphics; class CFX_Matrix; class IFWL_Widget; -class CFWL_WidgetMgrItem { - public: - CFWL_WidgetMgrItem(); - explicit CFWL_WidgetMgrItem(IFWL_Widget* widget); - ~CFWL_WidgetMgrItem(); - - CFWL_WidgetMgrItem* pParent; - CFWL_WidgetMgrItem* pOwner; - CFWL_WidgetMgrItem* pChild; - CFWL_WidgetMgrItem* pPrevious; - CFWL_WidgetMgrItem* pNext; - IFWL_Widget* const pWidget; - std::unique_ptr pOffscreen; - int32_t iRedrawCounter; -#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) - bool bOutsideChanged; -#endif -}; - -class IFWL_WidgetMgrDelegate { - public: - virtual void OnSetCapability(uint32_t dwCapability) = 0; - virtual void OnProcessMessageToForm(CFWL_Message* pMessage) = 0; - virtual void OnDrawWidget(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) = 0; -}; - class CFWL_WidgetMgr : public IFWL_WidgetMgrDelegate { public: explicit CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative); @@ -102,10 +75,29 @@ class CFWL_WidgetMgr : public IFWL_WidgetMgrDelegate { CFX_RectF& rtPopup) const; private: + class Item { + public: + Item(); + explicit Item(IFWL_Widget* widget); + ~Item(); + + Item* pParent; + Item* pOwner; + Item* pChild; + Item* pPrevious; + Item* pNext; + IFWL_Widget* const pWidget; + std::unique_ptr pOffscreen; + int32_t iRedrawCounter; +#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) + bool bOutsideChanged; +#endif + }; + IFWL_Widget* GetFirstSiblingWidget(IFWL_Widget* pWidget) const; IFWL_Widget* GetPriorSiblingWidget(IFWL_Widget* pWidget) const; IFWL_Widget* GetLastChildWidget(IFWL_Widget* pWidget) const; - CFWL_WidgetMgrItem* GetWidgetMgrItem(IFWL_Widget* pWidget) const; + Item* GetWidgetMgrItem(IFWL_Widget* pWidget) const; void SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex); @@ -133,7 +125,7 @@ class CFWL_WidgetMgr : public IFWL_WidgetMgrDelegate { bool IsAbleNative(IFWL_Widget* pWidget) const; uint32_t m_dwCapability; - std::map> m_mapWidgetItem; + std::map> m_mapWidgetItem; CXFA_FWLAdapterWidgetMgr* const m_pAdapter; #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) CFX_RectF m_rtScreen; diff --git a/xfa/fwl/core/cfwl_widgetproperties.cpp b/xfa/fwl/core/cfwl_widgetproperties.cpp new file mode 100644 index 0000000000..409b7f5211 --- /dev/null +++ b/xfa/fwl/core/cfwl_widgetproperties.cpp @@ -0,0 +1,24 @@ +// Copyright 2016 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/cfwl_widgetproperties.h" + +CFWL_WidgetProperties::CFWL_WidgetProperties() + : CFWL_WidgetProperties(nullptr) {} + +CFWL_WidgetProperties::CFWL_WidgetProperties( + IFWL_Widget::DataProvider* dataProvider) + : m_dwStyles(FWL_WGTSTYLE_Child), + m_dwStyleExes(0), + m_dwStates(0), + m_pThemeProvider(nullptr), + m_pDataProvider(dataProvider), + m_pParent(nullptr), + m_pOwner(nullptr) { + m_rtWidget.Set(0, 0, 0, 0); +} + +CFWL_WidgetProperties::~CFWL_WidgetProperties() {} diff --git a/xfa/fwl/core/cfwl_widgetproperties.h b/xfa/fwl/core/cfwl_widgetproperties.h index 83e54f1672..5b2a602c6d 100644 --- a/xfa/fwl/core/cfwl_widgetproperties.h +++ b/xfa/fwl/core/cfwl_widgetproperties.h @@ -31,21 +31,4 @@ class CFWL_WidgetProperties { IFWL_Widget* m_pOwner; }; -inline CFWL_WidgetProperties::CFWL_WidgetProperties() - : CFWL_WidgetProperties(nullptr) {} - -inline CFWL_WidgetProperties::CFWL_WidgetProperties( - IFWL_Widget::DataProvider* dataProvider) - : m_dwStyles(FWL_WGTSTYLE_Child), - m_dwStyleExes(0), - m_dwStates(0), - m_pThemeProvider(nullptr), - m_pDataProvider(dataProvider), - m_pParent(nullptr), - m_pOwner(nullptr) { - m_rtWidget.Set(0, 0, 0, 0); -} - -inline CFWL_WidgetProperties::~CFWL_WidgetProperties() {} - #endif // XFA_FWL_CORE_CFWL_WIDGETPROPERTIES_H_ diff --git a/xfa/fwl/core/fwl_noteimp.cpp b/xfa/fwl/core/fwl_noteimp.cpp deleted file mode 100644 index 8b9a7236fe..0000000000 --- a/xfa/fwl/core/fwl_noteimp.cpp +++ /dev/null @@ -1,553 +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/fwl_noteimp.h" - -#include - -#include "core/fxcrt/fx_ext.h" -#include "third_party/base/ptr_util.h" -#include "third_party/base/stl_util.h" -#include "xfa/fwl/core/cfwl_msgkey.h" -#include "xfa/fwl/core/cfwl_msgkillfocus.h" -#include "xfa/fwl/core/cfwl_msgmouse.h" -#include "xfa/fwl/core/cfwl_msgmousewheel.h" -#include "xfa/fwl/core/cfwl_msgsetfocus.h" -#include "xfa/fwl/core/cfwl_widgetmgr.h" -#include "xfa/fwl/core/ifwl_app.h" -#include "xfa/fwl/core/ifwl_tooltip.h" - -CFWL_NoteLoop::CFWL_NoteLoop() : m_bContinueModal(true) {} - -CFWL_NoteDriver::CFWL_NoteDriver() - : m_pHover(nullptr), - m_pFocus(nullptr), - m_pGrab(nullptr), - m_pNoteLoop(pdfium::MakeUnique()) { - PushNoteLoop(m_pNoteLoop.get()); -} - -CFWL_NoteDriver::~CFWL_NoteDriver() { - ClearEventTargets(true); -} - -void CFWL_NoteDriver::SendEvent(CFWL_Event* pNote) { - if (m_eventTargets.empty()) - return; - - for (const auto& pair : m_eventTargets) { - CFWL_EventTarget* pEventTarget = pair.second; - if (pEventTarget && !pEventTarget->IsInvalid()) - pEventTarget->ProcessEvent(pNote); - } -} - -void CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener, - IFWL_Widget* pEventSource, - uint32_t dwFilter) { - uint32_t key = pListener->GetEventKey(); - if (key == 0) { - do { - key = rand(); - } while (key == 0 || pdfium::ContainsKey(m_eventTargets, key)); - pListener->SetEventKey(key); - } - if (!m_eventTargets[key]) - m_eventTargets[key] = new CFWL_EventTarget(pListener); - - m_eventTargets[key]->SetEventSource(pEventSource, dwFilter); -} - -void CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) { - uint32_t key = pListener->GetEventKey(); - if (key == 0) - return; - - auto it = m_eventTargets.find(key); - if (it != m_eventTargets.end()) - it->second->FlagInvalid(); -} - -void CFWL_NoteDriver::PushNoteLoop(CFWL_NoteLoop* pNoteLoop) { - m_noteLoopQueue.Add(pNoteLoop); -} - -CFWL_NoteLoop* CFWL_NoteDriver::PopNoteLoop() { - int32_t pos = m_noteLoopQueue.GetSize(); - if (pos <= 0) - return nullptr; - - CFWL_NoteLoop* p = m_noteLoopQueue.GetAt(pos - 1); - m_noteLoopQueue.RemoveAt(pos - 1); - return p; -} - -bool CFWL_NoteDriver::SetFocus(IFWL_Widget* pFocus, bool bNotify) { - if (m_pFocus == pFocus) - return true; - - IFWL_Widget* pPrev = m_pFocus; - m_pFocus = pFocus; - if (pPrev) { - CFWL_MsgKillFocus ms; - ms.m_pDstTarget = pPrev; - ms.m_pSrcTarget = pPrev; - if (bNotify) - ms.m_dwExtend = 1; - - if (IFWL_WidgetDelegate* pDelegate = pPrev->GetDelegate()) - pDelegate->OnProcessMessage(&ms); - } - if (pFocus) { - IFWL_Widget* pWidget = - pFocus->GetOwnerApp()->GetWidgetMgr()->GetSystemFormWidget(pFocus); - IFWL_Form* pForm = static_cast(pWidget); - if (pForm) - pForm->SetSubFocus(pFocus); - - CFWL_MsgSetFocus ms; - ms.m_pDstTarget = pFocus; - if (bNotify) - ms.m_dwExtend = 1; - if (IFWL_WidgetDelegate* pDelegate = pFocus->GetDelegate()) - pDelegate->OnProcessMessage(&ms); - } - return true; -} - -void CFWL_NoteDriver::Run() { -#if (_FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_WIN32_DESKTOP_ || \ - _FX_OS_ == _FX_WIN64_) - for (;;) { - CFWL_NoteLoop* pTopLoop = GetTopLoop(); - if (!pTopLoop || !pTopLoop->ContinueModal()) - break; - UnqueueMessage(pTopLoop); - } -#endif -} - -void CFWL_NoteDriver::NotifyTargetHide(IFWL_Widget* pNoteTarget) { - if (m_pFocus == pNoteTarget) - m_pFocus = nullptr; - if (m_pHover == pNoteTarget) - m_pHover = nullptr; - if (m_pGrab == pNoteTarget) - m_pGrab = nullptr; -} - -void CFWL_NoteDriver::NotifyTargetDestroy(IFWL_Widget* pNoteTarget) { - if (m_pFocus == pNoteTarget) - m_pFocus = nullptr; - if (m_pHover == pNoteTarget) - m_pHover = nullptr; - if (m_pGrab == pNoteTarget) - m_pGrab = nullptr; - - UnregisterEventTarget(pNoteTarget); - - for (int32_t nIndex = 0; nIndex < m_forms.GetSize(); nIndex++) { - IFWL_Form* pForm = static_cast(m_forms[nIndex]); - if (!pForm) - continue; - - IFWL_Widget* pSubFocus = pForm->GetSubFocus(); - if (!pSubFocus) - return; - if (pSubFocus == pNoteTarget) - pForm->SetSubFocus(nullptr); - } -} - -void CFWL_NoteDriver::RegisterForm(IFWL_Widget* pForm) { - if (!pForm || m_forms.Find(pForm) >= 0) - return; - - m_forms.Add(pForm); - if (m_forms.GetSize() != 1) - return; - - CFWL_NoteLoop* pLoop = m_noteLoopQueue.GetAt(0); - if (!pLoop) - return; - - pLoop->SetMainForm(pForm); -} - -void CFWL_NoteDriver::UnRegisterForm(IFWL_Widget* pForm) { - if (!pForm) - return; - - int32_t nIndex = m_forms.Find(pForm); - if (nIndex < 0) - return; - - m_forms.RemoveAt(nIndex); -} - -void CFWL_NoteDriver::QueueMessage(std::unique_ptr pMessage) { - m_noteQueue.push_back(std::move(pMessage)); -} - -void CFWL_NoteDriver::UnqueueMessage(CFWL_NoteLoop* pNoteLoop) { - if (m_noteQueue.empty()) - return; - - std::unique_ptr pMessage = std::move(m_noteQueue[0]); - m_noteQueue.pop_front(); - - if (!IsValidMessage(pMessage.get())) - return; - - ProcessMessage(pMessage.get()); -} - -CFWL_NoteLoop* CFWL_NoteDriver::GetTopLoop() const { - int32_t size = m_noteLoopQueue.GetSize(); - if (size <= 0) - return nullptr; - return m_noteLoopQueue[size - 1]; -} - -void CFWL_NoteDriver::ProcessMessage(CFWL_Message* pMessage) { - CFWL_WidgetMgr* pWidgetMgr = - pMessage->m_pDstTarget->GetOwnerApp()->GetWidgetMgr(); - IFWL_Widget* pMessageForm = pWidgetMgr->IsFormDisabled() - ? pMessage->m_pDstTarget - : GetMessageForm(pMessage->m_pDstTarget); - if (!pMessageForm) - return; - if (!DispatchMessage(pMessage, pMessageForm)) - return; - - if (pMessage->GetClassID() == CFWL_MessageType::Mouse) - MouseSecondary(pMessage); -} - -bool CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage, - IFWL_Widget* pMessageForm) { - switch (pMessage->GetClassID()) { - case CFWL_MessageType::SetFocus: { - if (!DoSetFocus(pMessage, pMessageForm)) - return false; - break; - } - case CFWL_MessageType::KillFocus: { - if (!DoKillFocus(pMessage, pMessageForm)) - return false; - break; - } - case CFWL_MessageType::Key: { - if (!DoKey(pMessage, pMessageForm)) - return false; - break; - } - case CFWL_MessageType::Mouse: { - if (!DoMouse(pMessage, pMessageForm)) - return false; - break; - } - case CFWL_MessageType::MouseWheel: { - if (!DoWheel(pMessage, pMessageForm)) - return false; - break; - } - default: - break; - } - if (IFWL_WidgetDelegate* pDelegate = pMessage->m_pDstTarget->GetDelegate()) - pDelegate->OnProcessMessage(pMessage); - - return true; -} - -bool CFWL_NoteDriver::DoSetFocus(CFWL_Message* pMessage, - IFWL_Widget* pMessageForm) { - CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); - if (pWidgetMgr->IsFormDisabled()) { - m_pFocus = pMessage->m_pDstTarget; - return true; - } - - IFWL_Widget* pWidget = pMessage->m_pDstTarget; - if (!pWidget) - return false; - - IFWL_Form* pForm = static_cast(pWidget); - IFWL_Widget* pSubFocus = pForm->GetSubFocus(); - if (pSubFocus && ((pSubFocus->GetStates() & FWL_WGTSTATE_Focused) == 0)) { - pMessage->m_pDstTarget = pSubFocus; - if (m_pFocus != pMessage->m_pDstTarget) { - m_pFocus = pMessage->m_pDstTarget; - return true; - } - } - return false; -} - -bool CFWL_NoteDriver::DoKillFocus(CFWL_Message* pMessage, - IFWL_Widget* pMessageForm) { - CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); - if (pWidgetMgr->IsFormDisabled()) { - if (m_pFocus == pMessage->m_pDstTarget) - m_pFocus = nullptr; - return true; - } - - IFWL_Form* pForm = static_cast(pMessage->m_pDstTarget); - if (!pForm) - return false; - - IFWL_Widget* pSubFocus = pForm->GetSubFocus(); - if (pSubFocus && (pSubFocus->GetStates() & FWL_WGTSTATE_Focused)) { - pMessage->m_pDstTarget = pSubFocus; - if (m_pFocus == pMessage->m_pDstTarget) { - m_pFocus = nullptr; - return true; - } - } - return false; -} - -bool CFWL_NoteDriver::DoKey(CFWL_Message* pMessage, IFWL_Widget* pMessageForm) { - CFWL_MsgKey* pMsg = static_cast(pMessage); -#if (_FX_OS_ != _FX_MACOSX_) - if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown && - pMsg->m_dwKeyCode == FWL_VKEY_Tab) { - CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); - IFWL_Widget* pForm = GetMessageForm(pMsg->m_pDstTarget); - IFWL_Widget* pFocus = m_pFocus; - if (m_pFocus && pWidgetMgr->GetSystemFormWidget(m_pFocus) != pForm) - pFocus = nullptr; - - bool bFind = false; - IFWL_Widget* pNextTabStop = pWidgetMgr->NextTab(pForm, pFocus, bFind); - if (!pNextTabStop) { - bFind = false; - pNextTabStop = pWidgetMgr->NextTab(pForm, nullptr, bFind); - } - if (pNextTabStop == pFocus) - return true; - if (pNextTabStop) - SetFocus(pNextTabStop); - return true; - } -#endif - - if (!m_pFocus) { - if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown && - pMsg->m_dwKeyCode == FWL_VKEY_Return) { - CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); - IFWL_Widget* defButton = pWidgetMgr->GetDefaultButton(pMessageForm); - if (defButton) { - pMsg->m_pDstTarget = defButton; - return true; - } - } - return false; - } - pMsg->m_pDstTarget = m_pFocus; - return true; -} - -bool CFWL_NoteDriver::DoMouse(CFWL_Message* pMessage, - IFWL_Widget* pMessageForm) { - CFWL_MsgMouse* pMsg = static_cast(pMessage); - if (pMsg->m_dwCmd == FWL_MouseCommand::Leave || - pMsg->m_dwCmd == FWL_MouseCommand::Hover || - pMsg->m_dwCmd == FWL_MouseCommand::Enter) { - return !!pMsg->m_pDstTarget; - } - if (pMsg->m_pDstTarget != pMessageForm) - pMsg->m_pDstTarget->TransformTo(pMessageForm, pMsg->m_fx, pMsg->m_fy); - if (!DoMouseEx(pMsg, pMessageForm)) - pMsg->m_pDstTarget = pMessageForm; - return true; -} - -bool CFWL_NoteDriver::DoWheel(CFWL_Message* pMessage, - IFWL_Widget* pMessageForm) { - CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); - if (!pWidgetMgr) - return false; - - CFWL_MsgMouseWheel* pMsg = static_cast(pMessage); - IFWL_Widget* pDst = - pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy); - if (!pDst) - return false; - - pMessageForm->TransformTo(pDst, pMsg->m_fx, pMsg->m_fy); - pMsg->m_pDstTarget = pDst; - return true; -} - -bool CFWL_NoteDriver::DoMouseEx(CFWL_Message* pMessage, - IFWL_Widget* pMessageForm) { - CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr(); - if (!pWidgetMgr) - return false; - IFWL_Widget* pTarget = nullptr; - if (m_pGrab) - pTarget = m_pGrab; - - CFWL_MsgMouse* pMsg = static_cast(pMessage); - if (!pTarget) { - pTarget = - pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy); - } - if (pTarget) { - if (pMessageForm != pTarget) - pMessageForm->TransformTo(pTarget, pMsg->m_fx, pMsg->m_fy); - } - if (!pTarget) - return false; - - pMsg->m_pDstTarget = pTarget; - return true; -} - -void CFWL_NoteDriver::MouseSecondary(CFWL_Message* pMessage) { - IFWL_Widget* pTarget = pMessage->m_pDstTarget; - if (pTarget == m_pHover) - return; - - CFWL_MsgMouse* pMsg = static_cast(pMessage); - if (m_pHover) { - CFWL_MsgMouse msLeave; - msLeave.m_pDstTarget = m_pHover; - msLeave.m_fx = pMsg->m_fx; - msLeave.m_fy = pMsg->m_fy; - pTarget->TransformTo(m_pHover, msLeave.m_fx, msLeave.m_fy); - - msLeave.m_dwFlags = 0; - msLeave.m_dwCmd = FWL_MouseCommand::Leave; - DispatchMessage(&msLeave, nullptr); - } - if (pTarget->GetClassID() == FWL_Type::Form) { - m_pHover = nullptr; - return; - } - m_pHover = pTarget; - - CFWL_MsgMouse msHover; - msHover.m_pDstTarget = pTarget; - msHover.m_fx = pMsg->m_fx; - msHover.m_fy = pMsg->m_fy; - msHover.m_dwFlags = 0; - msHover.m_dwCmd = FWL_MouseCommand::Hover; - DispatchMessage(&msHover, nullptr); -} - -bool CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) { - for (int32_t i = 0; i < m_noteLoopQueue.GetSize(); i++) { - CFWL_NoteLoop* pNoteLoop = m_noteLoopQueue[i]; - IFWL_Widget* pForm = pNoteLoop->GetForm(); - if (pForm && (pForm == pMessage->m_pDstTarget)) - return true; - } - - for (int32_t j = 0; j < m_forms.GetSize(); j++) { - IFWL_Form* pForm = static_cast(m_forms[j]); - if (pForm == pMessage->m_pDstTarget) - return true; - } - return false; -} - -IFWL_Widget* CFWL_NoteDriver::GetMessageForm(IFWL_Widget* pDstTarget) { - int32_t iTrackLoop = m_noteLoopQueue.GetSize(); - if (iTrackLoop <= 0) - return nullptr; - - IFWL_Widget* pMessageForm = nullptr; - if (iTrackLoop > 1) - pMessageForm = m_noteLoopQueue[iTrackLoop - 1]->GetForm(); - else if (m_forms.Find(pDstTarget) < 0) - pMessageForm = pDstTarget; - if (!pMessageForm && pDstTarget) { - CFWL_WidgetMgr* pWidgetMgr = pDstTarget->GetOwnerApp()->GetWidgetMgr(); - if (!pWidgetMgr) - return nullptr; - pMessageForm = pWidgetMgr->GetSystemFormWidget(pDstTarget); - } - return pMessageForm; -} - -void CFWL_NoteDriver::ClearEventTargets(bool bRemoveAll) { - auto it = m_eventTargets.begin(); - while (it != m_eventTargets.end()) { - auto old = it++; - if (old->second && (bRemoveAll || old->second->IsInvalid())) { - delete old->second; - m_eventTargets.erase(old); - } - } -} - -CFWL_EventTarget::CFWL_EventTarget(IFWL_Widget* pListener) - : m_pListener(pListener), m_bInvalid(false) {} - -CFWL_EventTarget::~CFWL_EventTarget() { - m_eventSources.RemoveAll(); -} - -int32_t CFWL_EventTarget::SetEventSource(IFWL_Widget* pSource, - uint32_t dwFilter) { - if (pSource) { - m_eventSources.SetAt(pSource, dwFilter); - return m_eventSources.GetCount(); - } - return 1; -} - -bool CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) { - IFWL_WidgetDelegate* pDelegate = m_pListener->GetDelegate(); - if (!pDelegate) - return false; - if (m_eventSources.GetCount() == 0) { - pDelegate->OnProcessEvent(pEvent); - return true; - } - - FX_POSITION pos = m_eventSources.GetStartPosition(); - while (pos) { - IFWL_Widget* pSource = nullptr; - uint32_t dwFilter = 0; - m_eventSources.GetNextAssoc(pos, (void*&)pSource, dwFilter); - if (pSource == pEvent->m_pSrcTarget) { - if (IsFilterEvent(pEvent, dwFilter)) { - pDelegate->OnProcessEvent(pEvent); - return true; - } - } - } - return false; -} - -bool CFWL_EventTarget::IsFilterEvent(CFWL_Event* pEvent, - uint32_t dwFilter) const { - if (dwFilter == FWL_EVENT_ALL_MASK) - return true; - - switch (pEvent->GetClassID()) { - case CFWL_EventType::Mouse: - return !!(dwFilter & FWL_EVENT_MOUSE_MASK); - case CFWL_EventType::MouseWheel: - return !!(dwFilter & FWL_EVENT_MOUSEWHEEL_MASK); - case CFWL_EventType::Key: - return !!(dwFilter & FWL_EVENT_KEY_MASK); - case CFWL_EventType::SetFocus: - case CFWL_EventType::KillFocus: - return !!(dwFilter & FWL_EVENT_FOCUSCHANGED_MASK); - case CFWL_EventType::Close: - return !!(dwFilter & FWL_EVENT_CLOSE_MASK); - case CFWL_EventType::SizeChanged: - return !!(dwFilter & FWL_EVENT_SIZECHANGED_MASK); - default: - return !!(dwFilter & FWL_EVENT_CONTROL_MASK); - } -} diff --git a/xfa/fwl/core/fwl_noteimp.h b/xfa/fwl/core/fwl_noteimp.h deleted file mode 100644 index 5a530ed9af..0000000000 --- a/xfa/fwl/core/fwl_noteimp.h +++ /dev/null @@ -1,116 +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_FWL_NOTEIMP_H_ -#define XFA_FWL_CORE_FWL_NOTEIMP_H_ - -#include -#include -#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_TargetImp; -class IFWL_ToolTip; -class IFWL_Widget; - -class CFWL_NoteLoop { - public: - CFWL_NoteLoop(); - ~CFWL_NoteLoop() {} - - IFWL_Widget* GetForm() const { return m_pForm; } - bool ContinueModal() const { return m_bContinueModal; } - void EndModalLoop() { m_bContinueModal = false; } - void SetMainForm(IFWL_Widget* pForm) { m_pForm = pForm; } - - private: - IFWL_Widget* m_pForm; - bool m_bContinueModal; -}; - -class CFWL_NoteDriver { - public: - CFWL_NoteDriver(); - ~CFWL_NoteDriver(); - - void SendEvent(CFWL_Event* pNote); - - void RegisterEventTarget(IFWL_Widget* pListener, - IFWL_Widget* pEventSource = nullptr, - uint32_t dwFilter = FWL_EVENT_ALL_MASK); - void UnregisterEventTarget(IFWL_Widget* pListener); - void ClearEventTargets(bool bRemoveAll); - - CFWL_NoteLoop* GetTopLoop() const; - void PushNoteLoop(CFWL_NoteLoop* pNoteLoop); - CFWL_NoteLoop* PopNoteLoop(); - - IFWL_Widget* GetFocus() const { return m_pFocus; } - bool SetFocus(IFWL_Widget* pFocus, bool bNotify = false); - void SetGrab(IFWL_Widget* pGrab, bool bSet) { - m_pGrab = bSet ? pGrab : nullptr; - } - - void Run(); - - void NotifyTargetHide(IFWL_Widget* pNoteTarget); - void NotifyTargetDestroy(IFWL_Widget* pNoteTarget); - - void RegisterForm(IFWL_Widget* pForm); - void UnRegisterForm(IFWL_Widget* pForm); - - void QueueMessage(std::unique_ptr pMessage); - void UnqueueMessage(CFWL_NoteLoop* pNoteLoop); - void ProcessMessage(CFWL_Message* pMessage); - - private: - bool DispatchMessage(CFWL_Message* pMessage, IFWL_Widget* pMessageForm); - bool DoSetFocus(CFWL_Message* pMsg, IFWL_Widget* pMessageForm); - bool DoKillFocus(CFWL_Message* pMsg, IFWL_Widget* pMessageForm); - bool DoKey(CFWL_Message* pMsg, IFWL_Widget* pMessageForm); - bool DoMouse(CFWL_Message* pMsg, IFWL_Widget* pMessageForm); - bool DoWheel(CFWL_Message* pMsg, IFWL_Widget* pMessageForm); - bool DoMouseEx(CFWL_Message* pMsg, IFWL_Widget* pMessageForm); - void MouseSecondary(CFWL_Message* pMsg); - bool IsValidMessage(CFWL_Message* pMessage); - IFWL_Widget* GetMessageForm(IFWL_Widget* pDstTarget); - - CFX_ArrayTemplate m_forms; - std::deque> m_noteQueue; - CFX_ArrayTemplate m_noteLoopQueue; - std::unordered_map m_eventTargets; - IFWL_Widget* m_pHover; - IFWL_Widget* m_pFocus; - IFWL_Widget* m_pGrab; - std::unique_ptr m_pNoteLoop; -}; - -class CFWL_EventTarget { - public: - explicit CFWL_EventTarget(IFWL_Widget* pListener); - ~CFWL_EventTarget(); - - int32_t SetEventSource(IFWL_Widget* pSource, - uint32_t dwFilter = FWL_EVENT_ALL_MASK); - bool ProcessEvent(CFWL_Event* pEvent); - - bool IsInvalid() const { return m_bInvalid; } - void FlagInvalid() { m_bInvalid = true; } - - private: - bool IsFilterEvent(CFWL_Event* pEvent, uint32_t dwFilter) const; - - CFX_MapPtrTemplate m_eventSources; - IFWL_Widget* m_pListener; - bool m_bInvalid; -}; - -#endif // XFA_FWL_CORE_FWL_NOTEIMP_H_ diff --git a/xfa/fwl/core/ifwl_adaptertimermgr.h b/xfa/fwl/core/ifwl_adaptertimermgr.h index 156c0cf6f9..ad54f46312 100644 --- a/xfa/fwl/core/ifwl_adaptertimermgr.h +++ b/xfa/fwl/core/ifwl_adaptertimermgr.h @@ -11,7 +11,6 @@ class IFWL_AdapterTimerMgr { public: - virtual ~IFWL_AdapterTimerMgr() {} virtual void Start(IFWL_Timer* pTimer, uint32_t dwElapse, bool bImmediately, diff --git a/xfa/fwl/core/ifwl_app.cpp b/xfa/fwl/core/ifwl_app.cpp index 0a2b53a749..c4a6dc39ca 100644 --- a/xfa/fwl/core/ifwl_app.cpp +++ b/xfa/fwl/core/ifwl_app.cpp @@ -7,8 +7,8 @@ #include "xfa/fwl/core/ifwl_app.h" #include "third_party/base/ptr_util.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fwl/core/cfwl_widgetmgr.h" -#include "xfa/fwl/core/fwl_noteimp.h" #include "xfa/fwl/core/ifwl_widget.h" #include "xfa/fxfa/app/xfa_fwladapter.h" diff --git a/xfa/fwl/core/ifwl_barcode.cpp b/xfa/fwl/core/ifwl_barcode.cpp index 26d60aa4c9..71346b828b 100644 --- a/xfa/fwl/core/ifwl_barcode.cpp +++ b/xfa/fwl/core/ifwl_barcode.cpp @@ -10,9 +10,9 @@ #include "third_party/base/ptr_util.h" #include "xfa/fgas/font/cfgas_gefont.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fwl/core/cfwl_themepart.h" #include "xfa/fwl/core/cfx_barcode.h" -#include "xfa/fwl/core/fwl_noteimp.h" #include "xfa/fwl/core/ifwl_themeprovider.h" IFWL_Barcode::IFWL_Barcode(const IFWL_App* app, @@ -66,8 +66,8 @@ void IFWL_Barcode::GenerateBarcodeImageCache() { m_dwStatus = 0; CreateBarcodeEngine(); - IFWL_BarcodeDP* pData = - static_cast(m_pProperties->m_pDataProvider); + IFWL_Barcode::DataProvider* pData = + static_cast(m_pProperties->m_pDataProvider); if (!pData) return; if (!m_pBarcodeEngine) diff --git a/xfa/fwl/core/ifwl_barcode.h b/xfa/fwl/core/ifwl_barcode.h index 417b1b77cc..5ff99e85c0 100644 --- a/xfa/fwl/core/ifwl_barcode.h +++ b/xfa/fwl/core/ifwl_barcode.h @@ -38,26 +38,26 @@ enum FWL_BCDAttribute { FWL_BCDATTRIBUTE_TRUNCATED = 1 << 12 }; -class IFWL_BarcodeDP : public IFWL_Widget::DataProvider { - public: - virtual BC_CHAR_ENCODING GetCharEncoding() const = 0; - virtual int32_t GetModuleHeight() const = 0; - virtual int32_t GetModuleWidth() const = 0; - virtual int32_t GetDataLength() const = 0; - virtual bool GetCalChecksum() const = 0; - virtual bool GetPrintChecksum() const = 0; - virtual BC_TEXT_LOC GetTextLocation() const = 0; - virtual int32_t GetWideNarrowRatio() const = 0; - virtual FX_CHAR GetStartChar() const = 0; - virtual FX_CHAR GetEndChar() const = 0; - virtual int32_t GetVersion() const = 0; - virtual int32_t GetErrorCorrectionLevel() const = 0; - virtual bool GetTruncated() const = 0; - virtual uint32_t GetBarcodeAttributeMask() const = 0; -}; - class IFWL_Barcode : public IFWL_Edit { public: + class DataProvider : public IFWL_Widget::DataProvider { + public: + virtual BC_CHAR_ENCODING GetCharEncoding() const = 0; + virtual int32_t GetModuleHeight() const = 0; + virtual int32_t GetModuleWidth() const = 0; + virtual int32_t GetDataLength() const = 0; + virtual bool GetCalChecksum() const = 0; + virtual bool GetPrintChecksum() const = 0; + virtual BC_TEXT_LOC GetTextLocation() const = 0; + virtual int32_t GetWideNarrowRatio() const = 0; + virtual FX_CHAR GetStartChar() const = 0; + virtual FX_CHAR GetEndChar() const = 0; + virtual int32_t GetVersion() const = 0; + virtual int32_t GetErrorCorrectionLevel() const = 0; + virtual bool GetTruncated() const = 0; + virtual uint32_t GetBarcodeAttributeMask() const = 0; + }; + IFWL_Barcode(const IFWL_App* app, std::unique_ptr properties); ~IFWL_Barcode() override; diff --git a/xfa/fwl/core/ifwl_caret.cpp b/xfa/fwl/core/ifwl_caret.cpp index b7607e3597..5dcebc1cbb 100644 --- a/xfa/fwl/core/ifwl_caret.cpp +++ b/xfa/fwl/core/ifwl_caret.cpp @@ -9,9 +9,9 @@ #include #include "third_party/base/ptr_util.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fwl/core/cfwl_themebackground.h" #include "xfa/fwl/core/cfwl_widgetproperties.h" -#include "xfa/fwl/core/fwl_noteimp.h" #include "xfa/fwl/core/ifwl_themeprovider.h" #include "xfa/fwl/core/ifwl_timerinfo.h" diff --git a/xfa/fwl/core/ifwl_checkbox.cpp b/xfa/fwl/core/ifwl_checkbox.cpp index 0d18e2cec5..04f367f772 100644 --- a/xfa/fwl/core/ifwl_checkbox.cpp +++ b/xfa/fwl/core/ifwl_checkbox.cpp @@ -15,10 +15,10 @@ #include "xfa/fwl/core/cfwl_evtcheckstatechanged.h" #include "xfa/fwl/core/cfwl_msgkey.h" #include "xfa/fwl/core/cfwl_msgmouse.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fwl/core/cfwl_themebackground.h" #include "xfa/fwl/core/cfwl_themetext.h" #include "xfa/fwl/core/cfwl_widgetmgr.h" -#include "xfa/fwl/core/fwl_noteimp.h" #include "xfa/fwl/core/ifwl_app.h" #include "xfa/fwl/core/ifwl_themeprovider.h" @@ -70,8 +70,8 @@ void IFWL_CheckBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { } rect.Inflate(kCaptionMargin, kCaptionMargin); - IFWL_CheckBoxDP* pData = - static_cast(m_pProperties->m_pDataProvider); + IFWL_CheckBox::DataProvider* pData = + static_cast(m_pProperties->m_pDataProvider); FX_FLOAT fCheckBox = pData->GetBoxSize(this); rect.width += fCheckBox; rect.height = std::max(rect.height, fCheckBox); @@ -172,8 +172,8 @@ void IFWL_CheckBox::Layout() { FX_FLOAT fBoxTop = m_rtClient.top; FX_FLOAT fClientBottom = m_rtClient.bottom(); - IFWL_CheckBoxDP* pData = - static_cast(m_pProperties->m_pDataProvider); + IFWL_CheckBox::DataProvider* pData = + static_cast(m_pProperties->m_pDataProvider); FX_FLOAT fCheckBox = pData->GetBoxSize(this); switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_VLayoutMask) { case FWL_STYLEEXT_CKB_Top: diff --git a/xfa/fwl/core/ifwl_checkbox.h b/xfa/fwl/core/ifwl_checkbox.h index 30d9b637a0..0c9f3cda12 100644 --- a/xfa/fwl/core/ifwl_checkbox.h +++ b/xfa/fwl/core/ifwl_checkbox.h @@ -48,13 +48,13 @@ class CFWL_MsgMouse; class CFWL_WidgetProperties; class IFWL_Widget; -class IFWL_CheckBoxDP : public IFWL_Widget::DataProvider { - public: - virtual FX_FLOAT GetBoxSize(IFWL_Widget* pWidget) = 0; -}; - class IFWL_CheckBox : public IFWL_Widget { public: + class DataProvider : public IFWL_Widget::DataProvider { + public: + virtual FX_FLOAT GetBoxSize(IFWL_Widget* pWidget) = 0; + }; + IFWL_CheckBox(const IFWL_App* app, std::unique_ptr properties); ~IFWL_CheckBox() override; diff --git a/xfa/fwl/core/ifwl_combobox.cpp b/xfa/fwl/core/ifwl_combobox.cpp index b85f4e4959..e632120417 100644 --- a/xfa/fwl/core/ifwl_combobox.cpp +++ b/xfa/fwl/core/ifwl_combobox.cpp @@ -22,11 +22,11 @@ #include "xfa/fwl/core/cfwl_msgkillfocus.h" #include "xfa/fwl/core/cfwl_msgmouse.h" #include "xfa/fwl/core/cfwl_msgsetfocus.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/cfwl_widgetmgr.h" -#include "xfa/fwl/core/fwl_noteimp.h" #include "xfa/fwl/core/ifwl_app.h" #include "xfa/fwl/core/ifwl_formproxy.h" #include "xfa/fwl/core/ifwl_listbox.h" diff --git a/xfa/fwl/core/ifwl_comboboxproxy.cpp b/xfa/fwl/core/ifwl_comboboxproxy.cpp index f454f4c9eb..53586f4062 100644 --- a/xfa/fwl/core/ifwl_comboboxproxy.cpp +++ b/xfa/fwl/core/ifwl_comboboxproxy.cpp @@ -11,7 +11,7 @@ #include "xfa/fwl/core/cfwl_msgkillfocus.h" #include "xfa/fwl/core/cfwl_msgmouse.h" -#include "xfa/fwl/core/fwl_noteimp.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fwl/core/ifwl_app.h" #include "xfa/fwl/core/ifwl_combobox.h" diff --git a/xfa/fwl/core/ifwl_datetimepicker.cpp b/xfa/fwl/core/ifwl_datetimepicker.cpp index dca32c3b42..b0e0114bce 100644 --- a/xfa/fwl/core/ifwl_datetimepicker.cpp +++ b/xfa/fwl/core/ifwl_datetimepicker.cpp @@ -14,9 +14,9 @@ #include "xfa/fwl/core/cfwl_evtselectchanged.h" #include "xfa/fwl/core/cfwl_msgmouse.h" #include "xfa/fwl/core/cfwl_msgsetfocus.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fwl/core/cfwl_themebackground.h" #include "xfa/fwl/core/cfwl_widgetmgr.h" -#include "xfa/fwl/core/fwl_noteimp.h" #include "xfa/fwl/core/ifwl_formproxy.h" #include "xfa/fwl/core/ifwl_spinbutton.h" #include "xfa/fwl/core/ifwl_themeprovider.h" @@ -118,8 +118,9 @@ void IFWL_DateTimePicker::Update() { if (!(m_pMonthCal->GetThemeProvider())) m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider); if (m_pProperties->m_pDataProvider) { - IFWL_DateTimePickerDP* pData = - static_cast(m_pProperties->m_pDataProvider); + IFWL_DateTimePicker::DataProvider* pData = + static_cast( + m_pProperties->m_pDataProvider); pData->GetToday(this, m_iCurYear, m_iCurMonth, m_iCurDay); } @@ -467,8 +468,9 @@ void IFWL_DateTimePicker::DisForm_Update() { if (!m_pMonthCal->GetThemeProvider()) m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider); if (m_pProperties->m_pDataProvider) { - IFWL_DateTimePickerDP* pData = - static_cast(m_pProperties->m_pDataProvider); + IFWL_DateTimePicker::DataProvider* pData = + static_cast( + m_pProperties->m_pDataProvider); pData->GetToday(this, m_iCurYear, m_iCurMonth, m_iCurDay); } diff --git a/xfa/fwl/core/ifwl_datetimepicker.h b/xfa/fwl/core/ifwl_datetimepicker.h index 9d7b83a6c8..21f5f4a28e 100644 --- a/xfa/fwl/core/ifwl_datetimepicker.h +++ b/xfa/fwl/core/ifwl_datetimepicker.h @@ -35,17 +35,17 @@ class IFWL_DateTimeEdit; class IFWL_FormProxy; -class IFWL_DateTimePickerDP : public IFWL_Widget::DataProvider { - public: - virtual void GetToday(IFWL_Widget* pWidget, - int32_t& iYear, - int32_t& iMonth, - int32_t& iDay) = 0; -}; - class IFWL_DateTimePicker : public IFWL_Widget, public IFWL_MonthCalendar::DataProvider { public: + class DataProvider : public IFWL_Widget::DataProvider { + public: + virtual void GetToday(IFWL_Widget* pWidget, + int32_t& iYear, + int32_t& iMonth, + int32_t& iDay) = 0; + }; + explicit IFWL_DateTimePicker( const IFWL_App* app, std::unique_ptr properties); diff --git a/xfa/fwl/core/ifwl_form.cpp b/xfa/fwl/core/ifwl_form.cpp index 115aca04a9..bbc16ebdeb 100644 --- a/xfa/fwl/core/ifwl_form.cpp +++ b/xfa/fwl/core/ifwl_form.cpp @@ -12,12 +12,13 @@ #include "xfa/fde/tto/fde_textout.h" #include "xfa/fwl/core/cfwl_evtclose.h" #include "xfa/fwl/core/cfwl_msgmouse.h" +#include "xfa/fwl/core/cfwl_notedriver.h" +#include "xfa/fwl/core/cfwl_noteloop.h" #include "xfa/fwl/core/cfwl_sysbtn.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/cfwl_widgetmgr.h" -#include "xfa/fwl/core/fwl_noteimp.h" #include "xfa/fwl/core/ifwl_app.h" #include "xfa/fwl/core/ifwl_formproxy.h" #include "xfa/fwl/core/ifwl_themeprovider.h" diff --git a/xfa/fwl/core/ifwl_form.h b/xfa/fwl/core/ifwl_form.h index 3b7fe4f698..8970a5c81a 100644 --- a/xfa/fwl/core/ifwl_form.h +++ b/xfa/fwl/core/ifwl_form.h @@ -33,8 +33,6 @@ class IFWL_Widget; class IFWL_ThemeProvider; class CFWL_SysBtn; -class IFWL_FormDP : public IFWL_Widget::DataProvider {}; - class IFWL_Form : public IFWL_Widget { public: IFWL_Form(const IFWL_App* app, diff --git a/xfa/fwl/core/ifwl_formproxy.cpp b/xfa/fwl/core/ifwl_formproxy.cpp index 0e85d986ed..253ed7fb94 100644 --- a/xfa/fwl/core/ifwl_formproxy.cpp +++ b/xfa/fwl/core/ifwl_formproxy.cpp @@ -10,7 +10,7 @@ #include #include "third_party/base/ptr_util.h" -#include "xfa/fwl/core/fwl_noteimp.h" +#include "xfa/fwl/core/cfwl_notedriver.h" IFWL_FormProxy::IFWL_FormProxy( const IFWL_App* app, diff --git a/xfa/fwl/core/ifwl_monthcalendar.cpp b/xfa/fwl/core/ifwl_monthcalendar.cpp index 3d7dbf549f..10ce33a719 100644 --- a/xfa/fwl/core/ifwl_monthcalendar.cpp +++ b/xfa/fwl/core/ifwl_monthcalendar.cpp @@ -13,9 +13,9 @@ #include "third_party/base/ptr_util.h" #include "xfa/fde/tto/fde_textout.h" #include "xfa/fwl/core/cfwl_msgmouse.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fwl/core/cfwl_themebackground.h" #include "xfa/fwl/core/cfwl_themetext.h" -#include "xfa/fwl/core/fwl_noteimp.h" #include "xfa/fwl/core/ifwl_datetimepicker.h" #include "xfa/fwl/core/ifwl_formproxy.h" #include "xfa/fwl/core/ifwl_themeprovider.h" diff --git a/xfa/fwl/core/ifwl_picturebox.cpp b/xfa/fwl/core/ifwl_picturebox.cpp index f1bec5134a..9cb3604076 100644 --- a/xfa/fwl/core/ifwl_picturebox.cpp +++ b/xfa/fwl/core/ifwl_picturebox.cpp @@ -10,8 +10,8 @@ #include #include "third_party/base/ptr_util.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fwl/core/cfwl_picturebox.h" -#include "xfa/fwl/core/fwl_noteimp.h" IFWL_PictureBox::IFWL_PictureBox( const IFWL_App* app, diff --git a/xfa/fwl/core/ifwl_pushbutton.cpp b/xfa/fwl/core/ifwl_pushbutton.cpp index b1894931d5..8ee0485b11 100644 --- a/xfa/fwl/core/ifwl_pushbutton.cpp +++ b/xfa/fwl/core/ifwl_pushbutton.cpp @@ -15,9 +15,9 @@ #include "xfa/fwl/core/cfwl_evtmouse.h" #include "xfa/fwl/core/cfwl_msgkey.h" #include "xfa/fwl/core/cfwl_msgmouse.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fwl/core/cfwl_themebackground.h" #include "xfa/fwl/core/cfwl_themetext.h" -#include "xfa/fwl/core/fwl_noteimp.h" #include "xfa/fwl/core/ifwl_themeprovider.h" IFWL_PushButton::IFWL_PushButton( diff --git a/xfa/fwl/core/ifwl_scrollbar.cpp b/xfa/fwl/core/ifwl_scrollbar.cpp index 0de791fa2d..b4d6b5076a 100644 --- a/xfa/fwl/core/ifwl_scrollbar.cpp +++ b/xfa/fwl/core/ifwl_scrollbar.cpp @@ -13,9 +13,9 @@ #include "third_party/base/ptr_util.h" #include "xfa/fwl/core/cfwl_msgmouse.h" #include "xfa/fwl/core/cfwl_msgmousewheel.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/fwl_noteimp.h" #include "xfa/fwl/core/ifwl_themeprovider.h" #include "xfa/fwl/core/ifwl_timerinfo.h" diff --git a/xfa/fwl/core/ifwl_spinbutton.cpp b/xfa/fwl/core/ifwl_spinbutton.cpp index fa063d6da5..b77c259de9 100644 --- a/xfa/fwl/core/ifwl_spinbutton.cpp +++ b/xfa/fwl/core/ifwl_spinbutton.cpp @@ -13,9 +13,9 @@ #include "xfa/fwl/core/cfwl_evtclick.h" #include "xfa/fwl/core/cfwl_msgkey.h" #include "xfa/fwl/core/cfwl_msgmouse.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fwl/core/cfwl_themebackground.h" #include "xfa/fwl/core/cfwl_widgetproperties.h" -#include "xfa/fwl/core/fwl_noteimp.h" #include "xfa/fwl/core/ifwl_themeprovider.h" #include "xfa/fwl/core/ifwl_timerinfo.h" diff --git a/xfa/fwl/core/ifwl_tooltip.cpp b/xfa/fwl/core/ifwl_tooltip.cpp index a9a07c636a..770527de02 100644 --- a/xfa/fwl/core/ifwl_tooltip.cpp +++ b/xfa/fwl/core/ifwl_tooltip.cpp @@ -11,10 +11,10 @@ #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/fwl_noteimp.h" #include "xfa/fwl/core/ifwl_themeprovider.h" #include "xfa/fwl/core/ifwl_timerinfo.h" #include "xfa/fwl/theme/cfwl_widgettp.h" diff --git a/xfa/fwl/core/ifwl_widget.cpp b/xfa/fwl/core/ifwl_widget.cpp index e9ee2a8715..ca574b2356 100644 --- a/xfa/fwl/core/ifwl_widget.cpp +++ b/xfa/fwl/core/ifwl_widget.cpp @@ -21,11 +21,11 @@ #include "xfa/fwl/core/cfwl_msgmouse.h" #include "xfa/fwl/core/cfwl_msgmousewheel.h" #include "xfa/fwl/core/cfwl_msgsetfocus.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/cfwl_widgetmgr.h" -#include "xfa/fwl/core/fwl_noteimp.h" #include "xfa/fwl/core/ifwl_app.h" #include "xfa/fwl/core/ifwl_combobox.h" #include "xfa/fwl/core/ifwl_form.h" diff --git a/xfa/fwl/core/ifwl_widgetmgrdelegate.h b/xfa/fwl/core/ifwl_widgetmgrdelegate.h new file mode 100644 index 0000000000..c832692314 --- /dev/null +++ b/xfa/fwl/core/ifwl_widgetmgrdelegate.h @@ -0,0 +1,24 @@ +// Copyright 2016 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_WIDGETMGRDELEGATE_H_ +#define XFA_FWL_CORE_IFWL_WIDGETMGRDELEGATE_H_ + +class CFWL_Message; +class CFX_Graphics; +class CFX_Matrix; +class IFWL_Widget; + +class IFWL_WidgetMgrDelegate { + public: + virtual void OnSetCapability(uint32_t dwCapability) = 0; + virtual void OnProcessMessageToForm(CFWL_Message* pMessage) = 0; + virtual void OnDrawWidget(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) = 0; +}; + +#endif // XFA_FWL_CORE_IFWL_WIDGETMGRDELEGATE_H_ diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/app/xfa_ffapp.cpp index 3f013487f2..285194f608 100644 --- a/xfa/fxfa/app/xfa_ffapp.cpp +++ b/xfa/fxfa/app/xfa_ffapp.cpp @@ -12,8 +12,8 @@ #include #include "xfa/fgas/font/cfgas_fontmgr.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fwl/core/cfwl_widgetmgr.h" -#include "xfa/fwl/core/fwl_noteimp.h" #include "xfa/fxfa/app/xfa_fwladapter.h" #include "xfa/fxfa/app/xfa_fwltheme.h" #include "xfa/fxfa/xfa_ffdoc.h" diff --git a/xfa/fxfa/app/xfa_ffbarcode.cpp b/xfa/fxfa/app/xfa_ffbarcode.cpp index a971e959ca..bfa8097248 100644 --- a/xfa/fxfa/app/xfa_ffbarcode.cpp +++ b/xfa/fxfa/app/xfa_ffbarcode.cpp @@ -8,7 +8,7 @@ #include "core/fxcrt/fx_ext.h" #include "xfa/fwl/core/cfwl_barcode.h" -#include "xfa/fwl/core/fwl_noteimp.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fwl/core/ifwl_app.h" #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/app/xfa_fftextedit.h" diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp index 39bfe50e2f..a99b7b1cb4 100644 --- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp +++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp @@ -8,8 +8,8 @@ #include "xfa/fwl/core/cfwl_checkbox.h" #include "xfa/fwl/core/cfwl_msgmouse.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fwl/core/cfwl_widgetmgr.h" -#include "xfa/fwl/core/fwl_noteimp.h" #include "xfa/fxfa/app/xfa_ffexclgroup.h" #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/xfa_ffapp.h" diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp index c9287b5eca..63ed7c46d3 100644 --- a/xfa/fxfa/app/xfa_ffchoicelist.cpp +++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp @@ -9,7 +9,7 @@ #include "xfa/fwl/core/cfwl_combobox.h" #include "xfa/fwl/core/cfwl_evtselectchanged.h" #include "xfa/fwl/core/cfwl_listbox.h" -#include "xfa/fwl/core/fwl_noteimp.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fwl/core/ifwl_app.h" #include "xfa/fwl/core/ifwl_combobox.h" #include "xfa/fwl/core/ifwl_edit.h" diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp index 3d1ead5069..1b5665bb08 100644 --- a/xfa/fxfa/app/xfa_ffdoc.cpp +++ b/xfa/fxfa/app/xfa_ffdoc.cpp @@ -17,7 +17,7 @@ #include "core/fxcrt/fx_ext.h" #include "core/fxcrt/fx_memory.h" #include "xfa/fde/xml/fde_xml_imp.h" -#include "xfa/fwl/core/fwl_noteimp.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fxfa/app/xfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_dataexporter.h" #include "xfa/fxfa/parser/cxfa_dataimporter.h" diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/xfa_ffimageedit.cpp index 1cbb9bc5c7..b88ccb624c 100644 --- a/xfa/fxfa/app/xfa_ffimageedit.cpp +++ b/xfa/fxfa/app/xfa_ffimageedit.cpp @@ -7,8 +7,8 @@ #include "xfa/fxfa/app/xfa_ffimageedit.h" #include "xfa/fwl/core/cfwl_msgmouse.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fwl/core/cfwl_picturebox.h" -#include "xfa/fwl/core/fwl_noteimp.h" #include "xfa/fwl/core/ifwl_app.h" #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/xfa_ffdoc.h" diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp index 12fabb5a1e..ba0bdcf85a 100644 --- a/xfa/fxfa/app/xfa_ffpushbutton.cpp +++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp @@ -6,9 +6,9 @@ #include "xfa/fxfa/app/xfa_ffpushbutton.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fwl/core/cfwl_pushbutton.h" #include "xfa/fwl/core/cfwl_widgetmgr.h" -#include "xfa/fwl/core/fwl_noteimp.h" #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/app/xfa_ffwidgetacc.h" #include "xfa/fxfa/app/xfa_textlayout.h" diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp index 6a2c611539..d13e946374 100644 --- a/xfa/fxfa/app/xfa_fftextedit.cpp +++ b/xfa/fxfa/app/xfa_fftextedit.cpp @@ -17,7 +17,7 @@ #include "xfa/fwl/core/cfwl_msgkillfocus.h" #include "xfa/fwl/core/cfwl_msgmouse.h" #include "xfa/fwl/core/cfwl_msgsetfocus.h" -#include "xfa/fwl/core/fwl_noteimp.h" +#include "xfa/fwl/core/cfwl_notedriver.h" #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/app/xfa_fwladapter.h" #include "xfa/fxfa/app/xfa_textlayout.h" -- cgit v1.2.3