| 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/ifwl_widget.h" | 7 #include "xfa/fwl/core/ifwl_widget.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/core/cfwl_message.h" | 12 #include "xfa/fwl/core/cfwl_message.h" |
| 13 #include "xfa/fwl/core/cfwl_themebackground.h" | 13 #include "xfa/fwl/core/cfwl_themebackground.h" |
| 14 #include "xfa/fwl/core/cfwl_themepart.h" | 14 #include "xfa/fwl/core/cfwl_themepart.h" |
| 15 #include "xfa/fwl/core/cfwl_themetext.h" | 15 #include "xfa/fwl/core/cfwl_themetext.h" |
| 16 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 16 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
| 17 #include "xfa/fwl/core/fwl_noteimp.h" | 17 #include "xfa/fwl/core/fwl_noteimp.h" |
| 18 #include "xfa/fwl/core/ifwl_app.h" | 18 #include "xfa/fwl/core/ifwl_app.h" |
| 19 #include "xfa/fwl/core/ifwl_combobox.h" | 19 #include "xfa/fwl/core/ifwl_combobox.h" |
| 20 #include "xfa/fwl/core/ifwl_form.h" | 20 #include "xfa/fwl/core/ifwl_form.h" |
| 21 #include "xfa/fwl/core/ifwl_themeprovider.h" | 21 #include "xfa/fwl/core/ifwl_themeprovider.h" |
| 22 #include "xfa/fwl/core/ifwl_widget.h" | 22 #include "xfa/fwl/core/ifwl_widget.h" |
| 23 #include "xfa/fxfa/xfa_ffapp.h" | 23 #include "xfa/fxfa/xfa_ffapp.h" |
| 24 | 24 |
| 25 #define FWL_STYLEEXT_MNU_Vert (1L << 0) | 25 #define FWL_STYLEEXT_MNU_Vert (1L << 0) |
| 26 | 26 |
| 27 IFWL_Widget::IFWL_Widget(const CFWL_WidgetImpProperties& properties, |
| 28 IFWL_Widget* pOuter) |
| 29 : m_pWidgetMgr(CFWL_WidgetMgr::GetInstance()), |
| 30 m_pProperties(new CFWL_WidgetImpProperties(properties)), |
| 31 m_pDelegate(nullptr), |
| 32 m_pCurDelegate(nullptr), |
| 33 m_pOuter(pOuter), |
| 34 m_pLayoutItem(nullptr), |
| 35 m_pAssociate(nullptr), |
| 36 m_iLock(0), |
| 37 m_nEventKey(0) { |
| 38 ASSERT(m_pWidgetMgr); |
| 39 } |
| 40 |
| 41 IFWL_Widget::~IFWL_Widget() {} |
| 42 |
| 27 FWL_Error IFWL_Widget::Initialize() { | 43 FWL_Error IFWL_Widget::Initialize() { |
| 28 IFWL_App* pApp = FWL_GetApp(); | 44 IFWL_App* pApp = FWL_GetApp(); |
| 29 if (!pApp) | 45 if (!pApp) |
| 30 return FWL_Error::Indefinite; | 46 return FWL_Error::Indefinite; |
| 31 | 47 |
| 32 CXFA_FFApp* pAdapter = pApp->GetAdapterNative(); | 48 CXFA_FFApp* pAdapter = pApp->GetAdapterNative(); |
| 33 if (!pAdapter) | 49 if (!pAdapter) |
| 34 return FWL_Error::Indefinite; | 50 return FWL_Error::Indefinite; |
| 35 | 51 |
| 36 SetOwnerApp(FWL_GetApp()); | 52 SetOwnerApp(FWL_GetApp()); |
| 37 | 53 |
| 38 IFWL_Widget* pParent = m_pProperties->m_pParent; | 54 IFWL_Widget* pParent = m_pProperties->m_pParent; |
| 39 m_pWidgetMgr->InsertWidget(pParent, this); | 55 m_pWidgetMgr->InsertWidget(pParent, this); |
| 40 if (!IsChild()) { | 56 if (!IsChild()) { |
| 41 IFWL_Widget* pOwner = m_pProperties->m_pOwner; | 57 IFWL_Widget* pOwner = m_pProperties->m_pOwner; |
| 42 if (pOwner) | 58 if (pOwner) |
| 43 m_pWidgetMgr->SetOwner(pOwner, this); | 59 m_pWidgetMgr->SetOwner(pOwner, this); |
| 44 } | 60 } |
| 45 return FWL_Error::Succeeded; | 61 return FWL_Error::Succeeded; |
| 46 } | 62 } |
| 47 | 63 |
| 48 FWL_Error IFWL_Widget::Finalize() { | 64 void IFWL_Widget::Finalize() { |
| 49 NotifyDriver(); | 65 NotifyDriver(); |
| 50 m_pWidgetMgr->RemoveWidget(this); | 66 m_pWidgetMgr->RemoveWidget(this); |
| 51 return FWL_Error::Succeeded; | |
| 52 } | |
| 53 | |
| 54 FWL_Error IFWL_Widget::GetClassName(CFX_WideString& wsClass) const { | |
| 55 wsClass.clear(); | |
| 56 return FWL_Error::Succeeded; | |
| 57 } | 67 } |
| 58 | 68 |
| 59 FX_BOOL IFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { | 69 FX_BOOL IFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { |
| 60 return FALSE; | 70 return FALSE; |
| 61 } | 71 } |
| 62 | 72 |
| 63 FWL_Error IFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 73 FWL_Error IFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
| 64 if (bAutoSize) { | 74 if (bAutoSize) { |
| 65 if (HasEdge()) { | 75 if (HasEdge()) { |
| 66 FX_FLOAT fEdge = GetEdgeWidth(); | 76 FX_FLOAT fEdge = GetEdgeWidth(); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 } | 392 } |
| 383 | 393 |
| 384 void* IFWL_Widget::GetLayoutItem() const { | 394 void* IFWL_Widget::GetLayoutItem() const { |
| 385 return m_pLayoutItem; | 395 return m_pLayoutItem; |
| 386 } | 396 } |
| 387 | 397 |
| 388 void IFWL_Widget::SetLayoutItem(void* pItem) { | 398 void IFWL_Widget::SetLayoutItem(void* pItem) { |
| 389 m_pLayoutItem = pItem; | 399 m_pLayoutItem = pItem; |
| 390 } | 400 } |
| 391 | 401 |
| 392 CFWL_Widget* IFWL_Widget::GetAssociateWidget() const { | |
| 393 return m_pAssociate; | |
| 394 } | |
| 395 | |
| 396 void IFWL_Widget::SetAssociateWidget(CFWL_Widget* pAssociate) { | 402 void IFWL_Widget::SetAssociateWidget(CFWL_Widget* pAssociate) { |
| 397 m_pAssociate = pAssociate; | 403 m_pAssociate = pAssociate; |
| 398 } | 404 } |
| 399 | |
| 400 IFWL_Widget::IFWL_Widget(const CFWL_WidgetImpProperties& properties, | |
| 401 IFWL_Widget* pOuter) | |
| 402 : m_pWidgetMgr(CFWL_WidgetMgr::GetInstance()), | |
| 403 m_pProperties(new CFWL_WidgetImpProperties(properties)), | |
| 404 m_pDelegate(nullptr), | |
| 405 m_pCurDelegate(nullptr), | |
| 406 m_pOuter(pOuter), | |
| 407 m_pLayoutItem(nullptr), | |
| 408 m_pAssociate(nullptr), | |
| 409 m_iLock(0), | |
| 410 m_nEventKey(0) { | |
| 411 ASSERT(m_pWidgetMgr); | |
| 412 } | |
| 413 | |
| 414 IFWL_Widget::~IFWL_Widget() {} | |
| 415 | |
| 416 FX_BOOL IFWL_Widget::IsEnabled() const { | 405 FX_BOOL IFWL_Widget::IsEnabled() const { |
| 417 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0; | 406 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0; |
| 418 } | 407 } |
| 419 | 408 |
| 420 FX_BOOL IFWL_Widget::IsVisible() const { | 409 FX_BOOL IFWL_Widget::IsVisible() const { |
| 421 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) == 0; | 410 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) == 0; |
| 422 } | 411 } |
| 423 | 412 |
| 424 FX_BOOL IFWL_Widget::IsActive() const { | 413 FX_BOOL IFWL_Widget::IsActive() const { |
| 425 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) == 0; | 414 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) == 0; |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 } | 930 } |
| 942 } | 931 } |
| 943 | 932 |
| 944 void CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {} | 933 void CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {} |
| 945 | 934 |
| 946 void CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 935 void CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
| 947 const CFX_Matrix* pMatrix) { | 936 const CFX_Matrix* pMatrix) { |
| 948 CFWL_EvtDraw evt; | 937 CFWL_EvtDraw evt; |
| 949 evt.m_pGraphics = pGraphics; | 938 evt.m_pGraphics = pGraphics; |
| 950 } | 939 } |
| OLD | NEW |