| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fwl/core/fwl_widgetimp.h" | 7 #include "xfa/fwl/core/fwl_widgetimp.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "xfa/fde/tto/fde_textout.h" | 11 #include "xfa/fde/tto/fde_textout.h" |
| 12 #include "xfa/fwl/basewidget/ifwl_combobox.h" | 12 #include "xfa/fwl/basewidget/ifwl_combobox.h" |
| 13 #include "xfa/fwl/basewidget/ifwl_datetimepicker.h" | 13 #include "xfa/fwl/basewidget/ifwl_datetimepicker.h" |
| 14 #include "xfa/fwl/core/cfwl_message.h" | 14 #include "xfa/fwl/core/cfwl_message.h" |
| 15 #include "xfa/fwl/core/cfwl_themebackground.h" | 15 #include "xfa/fwl/core/cfwl_themebackground.h" |
| 16 #include "xfa/fwl/core/cfwl_themepart.h" | 16 #include "xfa/fwl/core/cfwl_themepart.h" |
| 17 #include "xfa/fwl/core/cfwl_themetext.h" | 17 #include "xfa/fwl/core/cfwl_themetext.h" |
| 18 #include "xfa/fwl/core/fwl_appimp.h" | 18 #include "xfa/fwl/core/fwl_appimp.h" |
| 19 #include "xfa/fwl/core/fwl_noteimp.h" | 19 #include "xfa/fwl/core/fwl_noteimp.h" |
| 20 #include "xfa/fwl/core/fwl_widgetmgrimp.h" | 20 #include "xfa/fwl/core/fwl_widgetmgrimp.h" |
| 21 #include "xfa/fwl/core/ifwl_adapternative.h" | 21 #include "xfa/fwl/core/ifwl_adapternative.h" |
| 22 #include "xfa/fwl/core/ifwl_adapterthreadmgr.h" | 22 #include "xfa/fwl/core/ifwl_adapterthreadmgr.h" |
| 23 #include "xfa/fwl/core/ifwl_adapterwidgetmgr.h" | 23 #include "xfa/fwl/core/ifwl_adapterwidgetmgr.h" |
| 24 #include "xfa/fwl/core/ifwl_app.h" | 24 #include "xfa/fwl/core/ifwl_app.h" |
| 25 #include "xfa/fwl/core/ifwl_form.h" | 25 #include "xfa/fwl/core/ifwl_form.h" |
| 26 #include "xfa/fwl/core/ifwl_themeprovider.h" | 26 #include "xfa/fwl/core/ifwl_themeprovider.h" |
| 27 | 27 |
| 28 #define FWL_CLASSHASH_Menu 3957949655 | |
| 29 #define FWL_STYLEEXT_MNU_Vert (1L << 0) | 28 #define FWL_STYLEEXT_MNU_Vert (1L << 0) |
| 30 | 29 |
| 31 IFWL_Widget::~IFWL_Widget() {} | 30 IFWL_Widget::~IFWL_Widget() {} |
| 32 | 31 |
| 33 FWL_ERR IFWL_Widget::GetClassName(CFX_WideString& wsClass) const { | 32 FWL_ERR IFWL_Widget::GetClassName(CFX_WideString& wsClass) const { |
| 34 return m_pImpl->GetClassName(wsClass); | 33 return m_pImpl->GetClassName(wsClass); |
| 35 } | 34 } |
| 36 | 35 |
| 37 uint32_t IFWL_Widget::GetClassID() const { | 36 FWL_Type IFWL_Widget::GetClassID() const { |
| 38 return m_pImpl->GetClassID(); | 37 return m_pImpl->GetClassID(); |
| 39 } | 38 } |
| 40 | 39 |
| 41 FX_BOOL IFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { | 40 FX_BOOL IFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { |
| 42 return m_pImpl->IsInstance(wsClass); | 41 return m_pImpl->IsInstance(wsClass); |
| 43 } | 42 } |
| 44 | 43 |
| 45 FWL_ERR IFWL_Widget::Initialize() { | 44 FWL_ERR IFWL_Widget::Initialize() { |
| 46 return m_pImpl->Initialize(); | 45 return m_pImpl->Initialize(); |
| 47 } | 46 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 193 |
| 195 m_pWidgetMgr->RemoveWidget(m_pInterface); | 194 m_pWidgetMgr->RemoveWidget(m_pInterface); |
| 196 return FWL_ERR_Succeeded; | 195 return FWL_ERR_Succeeded; |
| 197 } | 196 } |
| 198 | 197 |
| 199 FWL_ERR CFWL_WidgetImp::GetClassName(CFX_WideString& wsClass) const { | 198 FWL_ERR CFWL_WidgetImp::GetClassName(CFX_WideString& wsClass) const { |
| 200 wsClass.clear(); | 199 wsClass.clear(); |
| 201 return FWL_ERR_Succeeded; | 200 return FWL_ERR_Succeeded; |
| 202 } | 201 } |
| 203 | 202 |
| 204 uint32_t CFWL_WidgetImp::GetClassID() const { | |
| 205 return 0; | |
| 206 } | |
| 207 | |
| 208 FX_BOOL CFWL_WidgetImp::IsInstance(const CFX_WideStringC& wsClass) const { | 203 FX_BOOL CFWL_WidgetImp::IsInstance(const CFX_WideStringC& wsClass) const { |
| 209 return FALSE; | 204 return FALSE; |
| 210 } | 205 } |
| 211 | 206 |
| 212 FWL_ERR CFWL_WidgetImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 207 FWL_ERR CFWL_WidgetImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
| 213 if (bAutoSize) { | 208 if (bAutoSize) { |
| 214 if (HasEdge()) { | 209 if (HasEdge()) { |
| 215 FX_FLOAT fEdge = GetEdgeWidth(); | 210 FX_FLOAT fEdge = GetEdgeWidth(); |
| 216 rect.Inflate(fEdge, fEdge); | 211 rect.Inflate(fEdge, fEdge); |
| 217 } | 212 } |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 } | 728 } |
| 734 } | 729 } |
| 735 void CFWL_WidgetImp::SetGrab(FX_BOOL bSet) { | 730 void CFWL_WidgetImp::SetGrab(FX_BOOL bSet) { |
| 736 IFWL_App* pApp = GetOwnerApp(); | 731 IFWL_App* pApp = GetOwnerApp(); |
| 737 if (!pApp) | 732 if (!pApp) |
| 738 return; | 733 return; |
| 739 CFWL_NoteDriver* pDriver = | 734 CFWL_NoteDriver* pDriver = |
| 740 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 735 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
| 741 pDriver->SetGrab(m_pInterface, bSet); | 736 pDriver->SetGrab(m_pInterface, bSet); |
| 742 } | 737 } |
| 738 |
| 743 FX_BOOL CFWL_WidgetImp::GetPopupPos(FX_FLOAT fMinHeight, | 739 FX_BOOL CFWL_WidgetImp::GetPopupPos(FX_FLOAT fMinHeight, |
| 744 FX_FLOAT fMaxHeight, | 740 FX_FLOAT fMaxHeight, |
| 745 const CFX_RectF& rtAnchor, | 741 const CFX_RectF& rtAnchor, |
| 746 CFX_RectF& rtPopup) { | 742 CFX_RectF& rtPopup) { |
| 747 if (GetClassID() == FWL_CLASSHASH_Menu) { | 743 if (GetClassID() == FWL_Type::ComboBox) { |
| 748 return GetPopupPosMenu(fMinHeight, fMaxHeight, rtAnchor, rtPopup); | 744 if (m_pWidgetMgr->IsFormDisabled()) { |
| 749 } else { | |
| 750 if (GetClassID() == FWL_CLASSHASH_ComboBox) { | |
| 751 if (m_pWidgetMgr->IsFormDisabled()) { | |
| 752 return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight, | |
| 753 fMaxHeight, rtAnchor, rtPopup); | |
| 754 } else { | |
| 755 return GetPopupPosComboBox(fMinHeight, fMaxHeight, rtAnchor, rtPopup); | |
| 756 } | |
| 757 } else if (GetClassID() == FWL_CLASSHASH_DateTimePicker && | |
| 758 m_pWidgetMgr->IsFormDisabled()) { | |
| 759 return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight, | 745 return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight, |
| 760 fMaxHeight, rtAnchor, rtPopup); | 746 fMaxHeight, rtAnchor, rtPopup); |
| 761 } else { | |
| 762 return GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup); | |
| 763 } | 747 } |
| 748 return GetPopupPosComboBox(fMinHeight, fMaxHeight, rtAnchor, rtPopup); |
| 764 } | 749 } |
| 765 return FALSE; | 750 if (GetClassID() == FWL_Type::DateTimePicker && |
| 751 m_pWidgetMgr->IsFormDisabled()) { |
| 752 return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight, |
| 753 fMaxHeight, rtAnchor, rtPopup); |
| 754 } |
| 755 return GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup); |
| 766 } | 756 } |
| 757 |
| 767 FX_BOOL CFWL_WidgetImp::GetPopupPosMenu(FX_FLOAT fMinHeight, | 758 FX_BOOL CFWL_WidgetImp::GetPopupPosMenu(FX_FLOAT fMinHeight, |
| 768 FX_FLOAT fMaxHeight, | 759 FX_FLOAT fMaxHeight, |
| 769 const CFX_RectF& rtAnchor, | 760 const CFX_RectF& rtAnchor, |
| 770 CFX_RectF& rtPopup) { | 761 CFX_RectF& rtPopup) { |
| 771 FX_FLOAT fx = 0; | 762 FX_FLOAT fx = 0; |
| 772 FX_FLOAT fy = 0; | 763 FX_FLOAT fy = 0; |
| 773 FX_FLOAT fScreenWidth = 0; | 764 FX_FLOAT fScreenWidth = 0; |
| 774 FX_FLOAT fScreenHeight = 0; | 765 FX_FLOAT fScreenHeight = 0; |
| 775 GetScreenSize(fScreenWidth, fScreenHeight); | 766 GetScreenSize(fScreenWidth, fScreenHeight); |
| 776 if (GetStylesEx() & FWL_STYLEEXT_MNU_Vert) { | 767 if (GetStylesEx() & FWL_STYLEEXT_MNU_Vert) { |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 FWL_ERR CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { | 1061 FWL_ERR CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { |
| 1071 return FWL_ERR_Succeeded; | 1062 return FWL_ERR_Succeeded; |
| 1072 } | 1063 } |
| 1073 | 1064 |
| 1074 FWL_ERR CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 1065 FWL_ERR CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
| 1075 const CFX_Matrix* pMatrix) { | 1066 const CFX_Matrix* pMatrix) { |
| 1076 CFWL_EvtDraw evt; | 1067 CFWL_EvtDraw evt; |
| 1077 evt.m_pGraphics = pGraphics; | 1068 evt.m_pGraphics = pGraphics; |
| 1078 return FWL_ERR_Succeeded; | 1069 return FWL_ERR_Succeeded; |
| 1079 } | 1070 } |
| OLD | NEW |