diff options
-rw-r--r-- | BUILD.gn | 2 | ||||
-rw-r--r-- | xfa/fwl/README.md | 1 | ||||
-rw-r--r-- | xfa/fwl/cfwl_combobox.cpp | 22 | ||||
-rw-r--r-- | xfa/fwl/cfwl_combobox.h | 8 | ||||
-rw-r--r-- | xfa/fwl/cfwl_comboboxproxy.cpp | 112 | ||||
-rw-r--r-- | xfa/fwl/cfwl_comboboxproxy.h | 41 |
6 files changed, 1 insertions, 185 deletions
@@ -1890,8 +1890,6 @@ if (pdf_enable_xfa) { "xfa/fwl/cfwl_checkbox.h", "xfa/fwl/cfwl_combobox.cpp", "xfa/fwl/cfwl_combobox.h", - "xfa/fwl/cfwl_comboboxproxy.cpp", - "xfa/fwl/cfwl_comboboxproxy.h", "xfa/fwl/cfwl_comboedit.cpp", "xfa/fwl/cfwl_comboedit.h", "xfa/fwl/cfwl_combolist.cpp", diff --git a/xfa/fwl/README.md b/xfa/fwl/README.md index 9285e89345..9ee5575b42 100644 --- a/xfa/fwl/README.md +++ b/xfa/fwl/README.md @@ -6,7 +6,6 @@ classes are both controllers and renderers for each widget. The hierarchy is: * CFWL_Widget * CFWL_Form * CFWL_FormProxy - * CFWL_ComboBoxProxy * CFWL_Caret * CFWL_CheckBox * CFWL_ComboBox diff --git a/xfa/fwl/cfwl_combobox.cpp b/xfa/fwl/cfwl_combobox.cpp index d53a9e4aea..e4dde352d4 100644 --- a/xfa/fwl/cfwl_combobox.cpp +++ b/xfa/fwl/cfwl_combobox.cpp @@ -32,7 +32,6 @@ CFWL_ComboBox::CFWL_ComboBox(const CFWL_App* app) : CFWL_Widget(app, pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr), - m_pComboBoxProxy(nullptr), m_bLButtonDown(false), m_iCurSel(-1), m_iBtnState(CFWL_PartState_Normal) { @@ -399,24 +398,6 @@ void CFWL_ComboBox::ProcessSelChanged(bool bLButtonUp) { DispatchEvent(&ev); } -void CFWL_ComboBox::InitProxyForm() { - if (m_pComboBoxProxy) - return; - if (!m_pListBox) - return; - - auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(); - prop->m_pOwner = this; - prop->m_dwStyles = FWL_WGTSTYLE_Popup; - prop->m_dwStates = FWL_WGTSTATE_Invisible; - - // TODO(dsinclair): Does this leak? I don't see a delete, but I'm not sure - // if the SetParent call is going to transfer ownership. - m_pComboBoxProxy = new CFWL_ComboBoxProxy(this, m_pOwnerApp.Get(), - std::move(prop), m_pListBox.get()); - m_pListBox->SetParent(m_pComboBoxProxy); -} - void CFWL_ComboBox::InitComboList() { if (m_pListBox) return; @@ -572,8 +553,7 @@ void CFWL_ComboBox::OnMouseMove(CFWL_MessageMouse* pMsg) { } void CFWL_ComboBox::OnMouseLeave(CFWL_MessageMouse* pMsg) { - if (!IsDropListVisible() && - !((m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == + if (!((m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == FWL_WGTSTATE_Disabled)) { m_iBtnState = CFWL_PartState_Normal; RepaintRect(m_rtBtn); diff --git a/xfa/fwl/cfwl_combobox.h b/xfa/fwl/cfwl_combobox.h index 0f05f75650..6c70865550 100644 --- a/xfa/fwl/cfwl_combobox.h +++ b/xfa/fwl/cfwl_combobox.h @@ -9,7 +9,6 @@ #include <memory> -#include "xfa/fwl/cfwl_comboboxproxy.h" #include "xfa/fwl/cfwl_comboedit.h" #include "xfa/fwl/cfwl_combolist.h" #include "xfa/fwl/cfwl_form.h" @@ -18,7 +17,6 @@ class CFWL_WidgetProperties; class CFWL_ComboBox; -class CFWL_ComboBoxProxy; class CFWL_FormProxy; class CFWL_ListBox; class CFWL_Widget; @@ -94,10 +92,6 @@ class CFWL_ComboBox : public CFWL_Widget { void EditModifyStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved); void DrawStretchHandler(CXFA_Graphics* pGraphics, const CFX_Matrix* pMatrix); - bool IsDropListVisible() const { - return m_pComboBoxProxy && - !(m_pComboBoxProxy->GetStates() & FWL_WGTSTATE_Invisible); - } void ShowDropList(bool bActivate); CFWL_ComboEdit* GetComboEdit() const { return m_pEdit.get(); } @@ -115,7 +109,6 @@ class CFWL_ComboBox : public CFWL_Widget { void ResetTheme(); void ResetEditAlignment(); void ResetListItemAlignment(); - void InitProxyForm(); void GetPopupPos(float fMinHeight, float fMaxHeight, const CFX_RectF& rtAnchor, @@ -148,7 +141,6 @@ class CFWL_ComboBox : public CFWL_Widget { CFX_RectF m_rtHandler; std::unique_ptr<CFWL_ComboEdit> m_pEdit; std::unique_ptr<CFWL_ComboList> m_pListBox; - CFWL_ComboBoxProxy* m_pComboBoxProxy; // Can this be a unique_ptr? bool m_bLButtonDown; int32_t m_iCurSel; int32_t m_iBtnState; diff --git a/xfa/fwl/cfwl_comboboxproxy.cpp b/xfa/fwl/cfwl_comboboxproxy.cpp deleted file mode 100644 index d1db1c01a8..0000000000 --- a/xfa/fwl/cfwl_comboboxproxy.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// 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/cfwl_comboboxproxy.h" - -#include <memory> -#include <utility> - -#include "xfa/fwl/cfwl_app.h" -#include "xfa/fwl/cfwl_combobox.h" -#include "xfa/fwl/cfwl_messagekillfocus.h" -#include "xfa/fwl/cfwl_messagemouse.h" -#include "xfa/fwl/cfwl_notedriver.h" - -CFWL_ComboBoxProxy::CFWL_ComboBoxProxy( - CFWL_ComboBox* pComboBox, - const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, - CFWL_Widget* pOuter) - : CFWL_FormProxy(app, std::move(properties), pOuter), - m_bLButtonDown(false), - m_bLButtonUpSelf(false), - m_pComboBox(pComboBox) {} - -CFWL_ComboBoxProxy::~CFWL_ComboBoxProxy() {} - -void CFWL_ComboBoxProxy::OnProcessMessage(CFWL_Message* pMessage) { - if (!pMessage) - return; - - switch (pMessage->GetType()) { - case CFWL_Message::Type::Mouse: { - CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage); - switch (pMsg->m_dwCmd) { - case FWL_MouseCommand::LeftButtonDown: - OnLButtonDown(pMsg); - break; - case FWL_MouseCommand::LeftButtonUp: - OnLButtonUp(pMsg); - break; - default: - break; - } - break; - } - case CFWL_Message::Type::KillFocus: - OnFocusChanged(pMessage, false); - break; - case CFWL_Message::Type::SetFocus: - OnFocusChanged(pMessage, true); - break; - default: - break; - } - CFWL_Widget::OnProcessMessage(pMessage); -} - -void CFWL_ComboBoxProxy::OnDrawWidget(CXFA_Graphics* pGraphics, - const CFX_Matrix& matrix) { - m_pComboBox->DrawStretchHandler(pGraphics, &matrix); -} - -void CFWL_ComboBoxProxy::OnLButtonDown(CFWL_Message* pMessage) { - const CFWL_App* pApp = GetOwnerApp(); - if (!pApp) - return; - - CFWL_NoteDriver* pDriver = - static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); - CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage); - if (CFX_RectF(0, 0, GetWidgetRect().Size()).Contains(pMsg->m_pos)) { - m_bLButtonDown = true; - pDriver->SetGrab(this, true); - } else { - m_bLButtonDown = false; - pDriver->SetGrab(this, false); - m_pComboBox->ShowDropList(false); - } -} - -void CFWL_ComboBoxProxy::OnLButtonUp(CFWL_Message* pMessage) { - m_bLButtonDown = false; - const CFWL_App* pApp = GetOwnerApp(); - if (!pApp) - return; - - CFWL_NoteDriver* pDriver = - static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); - pDriver->SetGrab(this, false); - if (!m_bLButtonUpSelf) { - m_bLButtonUpSelf = true; - return; - } - - CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage); - if (!CFX_RectF(0, 0, GetWidgetRect().Size()).Contains(pMsg->m_pos) && - m_pComboBox->IsDropListVisible()) { - m_pComboBox->ShowDropList(false); - } -} - -void CFWL_ComboBoxProxy::OnFocusChanged(CFWL_Message* pMessage, bool bSet) { - if (bSet) - return; - - CFWL_MessageKillFocus* pMsg = static_cast<CFWL_MessageKillFocus*>(pMessage); - if (!pMsg->m_pSetFocus) - m_pComboBox->ShowDropList(false); -} diff --git a/xfa/fwl/cfwl_comboboxproxy.h b/xfa/fwl/cfwl_comboboxproxy.h deleted file mode 100644 index bb21707851..0000000000 --- a/xfa/fwl/cfwl_comboboxproxy.h +++ /dev/null @@ -1,41 +0,0 @@ -// 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_CFWL_COMBOBOXPROXY_H_ -#define XFA_FWL_CFWL_COMBOBOXPROXY_H_ - -#include <memory> - -#include "xfa/fwl/cfwl_formproxy.h" - -class CFWL_ComboBox; - -class CFWL_ComboBoxProxy : public CFWL_FormProxy { - public: - CFWL_ComboBoxProxy(CFWL_ComboBox* pCombobBox, - const CFWL_App* app, - std::unique_ptr<CFWL_WidgetProperties> properties, - CFWL_Widget* pOuter); - ~CFWL_ComboBoxProxy() override; - - // CFWL_FormProxy - void OnProcessMessage(CFWL_Message* pMessage) override; - void OnDrawWidget(CXFA_Graphics* pGraphics, - const CFX_Matrix& matrix) override; - - void Reset() { m_bLButtonUpSelf = false; } - - private: - void OnLButtonDown(CFWL_Message* pMsg); - void OnLButtonUp(CFWL_Message* pMsg); - void OnFocusChanged(CFWL_Message* pMsg, bool bSet); - - bool m_bLButtonDown; - bool m_bLButtonUpSelf; - CFWL_ComboBox* m_pComboBox; -}; - -#endif // XFA_FWL_CFWL_COMBOBOXPROXY_H_ |