diff options
-rw-r--r-- | xfa/fwl/basewidget/fwl_editimp.cpp | 2 | ||||
-rw-r--r-- | xfa/fwl/core/fwl_widgetimp.cpp | 39 | ||||
-rw-r--r-- | xfa/fwl/core/fwl_widgetimp.h | 3 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_widget.h | 2 | ||||
-rw-r--r-- | xfa/fwl/lightwidget/cfwl_widget.cpp | 13 | ||||
-rw-r--r-- | xfa/fwl/lightwidget/cfwl_widget.h | 3 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffbarcode.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffcheckbutton.cpp | 7 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffchoicelist.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffimageedit.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffpushbutton.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_fftextedit.cpp | 8 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_fwladapter.cpp | 10 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_fwltheme.cpp | 11 |
14 files changed, 67 insertions, 41 deletions
diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp index 15cdf031f1..6d0197eeb4 100644 --- a/xfa/fwl/basewidget/fwl_editimp.cpp +++ b/xfa/fwl/basewidget/fwl_editimp.cpp @@ -1637,7 +1637,7 @@ FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget, FX_BOOL bVisible, const CFX_RectF* pRtAnchor) { CXFA_FFWidget* pXFAWidget = - static_cast<CXFA_FFWidget*>(pWidget->GetPrivateData(pWidget)); + static_cast<CXFA_FFWidget*>(pWidget->GetLayoutItem()); if (!pXFAWidget) return FALSE; diff --git a/xfa/fwl/core/fwl_widgetimp.cpp b/xfa/fwl/core/fwl_widgetimp.cpp index c6070b28e7..38e3a1ff28 100644 --- a/xfa/fwl/core/fwl_widgetimp.cpp +++ b/xfa/fwl/core/fwl_widgetimp.cpp @@ -103,6 +103,14 @@ void IFWL_Widget::SetEventKey(uint32_t key) { GetImpl()->SetEventKey(key); } +void* IFWL_Widget::GetLayoutItem() const { + return GetImpl()->GetLayoutItem(); +} + +void IFWL_Widget::SetLayoutItem(void* pItem) { + GetImpl()->SetLayoutItem(pItem); +} + FWL_Error IFWL_Widget::SetPrivateData(void* module_id, void* pData, PD_CALLBACK_FREEDATA callback) { @@ -517,30 +525,35 @@ void CFWL_WidgetImp::SetEventKey(uint32_t key) { m_nEventKey = key; } +void* CFWL_WidgetImp::GetLayoutItem() const { + return m_pLayoutItem; +} + +void CFWL_WidgetImp::SetLayoutItem(void* pItem) { + m_pLayoutItem = pItem; +} + CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter) : m_pProperties(new CFWL_WidgetImpProperties), - m_pPrivateData(NULL), - m_pDelegate(NULL), - m_pCurDelegate(NULL), + m_pPrivateData(nullptr), + m_pDelegate(nullptr), + m_pCurDelegate(nullptr), m_pOuter(pOuter), - m_pInterface(NULL), + m_pInterface(nullptr), + m_pLayoutItem(nullptr), m_iLock(0), m_nEventKey(0) { *m_pProperties = properties; m_pWidgetMgr = CFWL_WidgetMgr::GetInstance(); - ASSERT(m_pWidgetMgr != NULL); + ASSERT(m_pWidgetMgr); } + CFWL_WidgetImp::~CFWL_WidgetImp() { - if (m_pPrivateData) { - delete m_pPrivateData; - m_pPrivateData = NULL; - } - if (m_pProperties) { - delete m_pProperties; - m_pProperties = NULL; - } + delete m_pPrivateData; + delete m_pProperties; } + FX_BOOL CFWL_WidgetImp::IsEnabled() const { return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0; } diff --git a/xfa/fwl/core/fwl_widgetimp.h b/xfa/fwl/core/fwl_widgetimp.h index 3fdef9786c..8a887126e3 100644 --- a/xfa/fwl/core/fwl_widgetimp.h +++ b/xfa/fwl/core/fwl_widgetimp.h @@ -80,6 +80,8 @@ class CFWL_WidgetImp { CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent); uint32_t GetEventKey() const; void SetEventKey(uint32_t key); + void* GetLayoutItem() const; + void SetLayoutItem(void* pItem); protected: friend class CFWL_WidgetImpDelegate; @@ -162,6 +164,7 @@ class CFWL_WidgetImp { IFWL_WidgetDelegate* m_pCurDelegate; IFWL_Widget* m_pOuter; IFWL_Widget* m_pInterface; + void* m_pLayoutItem; int32_t m_iLock; uint32_t m_nEventKey; }; diff --git a/xfa/fwl/core/ifwl_widget.h b/xfa/fwl/core/ifwl_widget.h index 1c469b276c..e9da806291 100644 --- a/xfa/fwl/core/ifwl_widget.h +++ b/xfa/fwl/core/ifwl_widget.h @@ -77,6 +77,8 @@ class IFWL_Widget { void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE); uint32_t GetEventKey() const; void SetEventKey(uint32_t key); + void* GetLayoutItem() const; + void SetLayoutItem(void* pItem); FWL_Error SetPrivateData(void* module_id, void* pData, PD_CALLBACK_FREEDATA callback); diff --git a/xfa/fwl/lightwidget/cfwl_widget.cpp b/xfa/fwl/lightwidget/cfwl_widget.cpp index 0258c27489..239796d03a 100644 --- a/xfa/fwl/lightwidget/cfwl_widget.cpp +++ b/xfa/fwl/lightwidget/cfwl_widget.cpp @@ -124,9 +124,7 @@ FWL_Error CFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded, } uint32_t CFWL_Widget::GetStates() { - if (!m_pIface) - return 0; - return m_pIface->GetStates(); + return m_pIface ? m_pIface->GetStates() : 0; } void CFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) { @@ -134,6 +132,15 @@ void CFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) { m_pIface->SetStates(dwStates, bSet); } +void* CFWL_Widget::GetLayoutItem() const { + return m_pIface ? m_pIface->GetLayoutItem() : nullptr; +} + +void CFWL_Widget::SetLayoutItem(void* pItem) { + if (m_pIface) + m_pIface->SetLayoutItem(pItem); +} + FWL_Error CFWL_Widget::SetPrivateData(void* module_id, void* pData, PD_CALLBACK_FREEDATA callback) { diff --git a/xfa/fwl/lightwidget/cfwl_widget.h b/xfa/fwl/lightwidget/cfwl_widget.h index 1c29b1f58e..ea17627063 100644 --- a/xfa/fwl/lightwidget/cfwl_widget.h +++ b/xfa/fwl/lightwidget/cfwl_widget.h @@ -41,6 +41,9 @@ class CFWL_Widget { uint32_t dwStylesExRemoved); uint32_t GetStates(); void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE); + void* GetLayoutItem() const; + void SetLayoutItem(void* pItem); + FWL_Error SetPrivateData(void* module_id, void* pData, PD_CALLBACK_FREEDATA callback); diff --git a/xfa/fxfa/app/xfa_ffbarcode.cpp b/xfa/fxfa/app/xfa_ffbarcode.cpp index a659e13c55..508356ccf2 100644 --- a/xfa/fxfa/app/xfa_ffbarcode.cpp +++ b/xfa/fxfa/app/xfa_ffbarcode.cpp @@ -126,8 +126,8 @@ FX_BOOL CXFA_FFBarcode::LoadWidget() { pFWLBarcode->Initialize(); } m_pNormalWidget = pFWLBarcode; + m_pNormalWidget->SetLayoutItem(this); IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pWidget, this, NULL); CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); pNoteDriver->RegisterEventTarget(pWidget, pWidget); m_pOldDelegate = m_pNormalWidget->SetDelegate(this); diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp index 65b4247934..80a4e92bda 100644 --- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp +++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp @@ -28,20 +28,17 @@ FX_BOOL CXFA_FFCheckButton::LoadWidget() { CFWL_CheckBox* pCheckBox = CFWL_CheckBox::Create(); pCheckBox->Initialize(); m_pNormalWidget = pCheckBox; + m_pNormalWidget->SetLayoutItem(this); IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pWidget, this, NULL); CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); pNoteDriver->RegisterEventTarget(pWidget, pWidget); m_pOldDelegate = m_pNormalWidget->SetDelegate(this); if (m_pDataAcc->IsRadioButton()) { pCheckBox->ModifyStylesEx(FWL_STYLEEXT_CKB_RadioButton, 0xFFFFFFFF); } - m_pNormalWidget = (CFWL_Widget*)pCheckBox; - m_pNormalWidget->SetPrivateData(m_pNormalWidget->GetWidget(), this, NULL); m_pNormalWidget->LockUpdate(); UpdateWidgetProperty(); - XFA_CHECKSTATE eState = m_pDataAcc->GetCheckState(); - SetFWLCheckState(eState); + SetFWLCheckState(m_pDataAcc->GetCheckState()); m_pNormalWidget->UnlockUpdate(); return CXFA_FFField::LoadWidget(); } diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp index 4676bc9374..3f8ea29a49 100644 --- a/xfa/fxfa/app/xfa_ffchoicelist.cpp +++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp @@ -34,8 +34,8 @@ FX_BOOL CXFA_FFListBox::LoadWidget() { pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll | FWL_WGTSTYLE_NoBackground, 0xFFFFFFFF); m_pNormalWidget = (CFWL_Widget*)pListBox; + m_pNormalWidget->SetLayoutItem(this); IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pWidget, this, NULL); CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); pNoteDriver->RegisterEventTarget(pWidget, pWidget); m_pOldDelegate = m_pNormalWidget->SetDelegate(this); @@ -232,8 +232,8 @@ FX_BOOL CXFA_FFComboBox::LoadWidget() { CFWL_ComboBox* pComboBox = CFWL_ComboBox::Create(); pComboBox->Initialize(); m_pNormalWidget = (CFWL_Widget*)pComboBox; + m_pNormalWidget->SetLayoutItem(this); IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pWidget, this, NULL); CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); pNoteDriver->RegisterEventTarget(pWidget, pWidget); m_pOldDelegate = m_pNormalWidget->SetDelegate(this); diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/xfa_ffimageedit.cpp index 2250eef2e4..bda281f744 100644 --- a/xfa/fxfa/app/xfa_ffimageedit.cpp +++ b/xfa/fxfa/app/xfa_ffimageedit.cpp @@ -28,8 +28,8 @@ FX_BOOL CXFA_FFImageEdit::LoadWidget() { pPictureBox->Initialize(); } m_pNormalWidget = (CFWL_Widget*)pPictureBox; + m_pNormalWidget->SetLayoutItem(this); IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pWidget, this, NULL); CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); pNoteDriver->RegisterEventTarget(pWidget, pWidget); m_pOldDelegate = pPictureBox->SetDelegate(this); diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp index c210814a42..6c161b064b 100644 --- a/xfa/fxfa/app/xfa_ffpushbutton.cpp +++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp @@ -59,8 +59,8 @@ FX_BOOL CXFA_FFPushButton::LoadWidget() { } m_pOldDelegate = pPushButton->SetDelegate(this); m_pNormalWidget = (CFWL_Widget*)pPushButton; + m_pNormalWidget->SetLayoutItem(this); IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pWidget, this, NULL); CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); pNoteDriver->RegisterEventTarget(pWidget, pWidget); m_pNormalWidget->LockUpdate(); diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp index 89c9d356bd..ad1a508a16 100644 --- a/xfa/fxfa/app/xfa_fftextedit.cpp +++ b/xfa/fxfa/app/xfa_fftextedit.cpp @@ -38,8 +38,8 @@ FX_BOOL CXFA_FFTextEdit::LoadWidget() { CFWL_Edit* pFWLEdit = CFWL_Edit::Create(); pFWLEdit->Initialize(); m_pNormalWidget = pFWLEdit; + m_pNormalWidget->SetLayoutItem(this); IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pWidget, this, NULL); CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); pNoteDriver->RegisterEventTarget(pWidget, pWidget); m_pOldDelegate = m_pNormalWidget->SetDelegate(this); @@ -450,7 +450,7 @@ FX_BOOL CXFA_FFNumericEdit::LoadWidget() { pWidget->Initialize(); m_pNormalWidget = (CFWL_Widget*)pWidget; IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pIWidget, this, NULL); + m_pNormalWidget->SetLayoutItem(this); CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); m_pOldDelegate = m_pNormalWidget->SetDelegate(this); @@ -523,8 +523,8 @@ FX_BOOL CXFA_FFPasswordEdit::LoadWidget() { CFWL_Edit* pWidget = CFWL_Edit::Create(); pWidget->Initialize(); m_pNormalWidget = (CFWL_Widget*)pWidget; + m_pNormalWidget->SetLayoutItem(this); IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pIWidget, this, NULL); CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); m_pOldDelegate = m_pNormalWidget->SetDelegate(this); @@ -589,8 +589,8 @@ FX_BOOL CXFA_FFDateTimeEdit::LoadWidget() { CFWL_DateTimePicker* pWidget = CFWL_DateTimePicker::Create(); pWidget->Initialize(); m_pNormalWidget = (CFWL_Widget*)pWidget; + m_pNormalWidget->SetLayoutItem(this); IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); - m_pNormalWidget->SetPrivateData(pIWidget, this, NULL); CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); m_pOldDelegate = m_pNormalWidget->SetDelegate(this); diff --git a/xfa/fxfa/app/xfa_fwladapter.cpp b/xfa/fxfa/app/xfa_fwladapter.cpp index 4a0828b5ef..ea63d84dfb 100644 --- a/xfa/fxfa/app/xfa_fwladapter.cpp +++ b/xfa/fxfa/app/xfa_fwladapter.cpp @@ -18,11 +18,12 @@ FWL_Error CXFA_FWLAdapterWidgetMgr::RepaintWidget(IFWL_Widget* pWidget, if (!pWidget) return FWL_Error::Indefinite; - CXFA_FFField* pField = (CXFA_FFField*)pWidget->GetPrivateData(pWidget); - if (!pField) + CXFA_FFWidget* pFFWidget = + static_cast<CXFA_FFWidget*>(pWidget->GetLayoutItem()); + if (!pFFWidget) return FWL_Error::Indefinite; - pField->AddInvalidateRect(nullptr); + pFFWidget->AddInvalidateRect(nullptr); return FWL_Error::Succeeded; } @@ -31,7 +32,8 @@ FX_BOOL CXFA_FWLAdapterWidgetMgr::GetPopupPos(IFWL_Widget* pWidget, FX_FLOAT fMaxHeight, const CFX_RectF& rtAnchor, CFX_RectF& rtPopup) { - CXFA_FFWidget* pFFWidget = (CXFA_FFWidget*)(pWidget->GetPrivateData(pWidget)); + CXFA_FFWidget* pFFWidget = + static_cast<CXFA_FFWidget*>(pWidget->GetLayoutItem()); CFX_Matrix mt; pFFWidget->GetRotateMatrix(mt); CFX_RectF rtRotateAnchor(rtAnchor); diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp index df09fb504a..14649f1b80 100644 --- a/xfa/fxfa/app/xfa_fwltheme.cpp +++ b/xfa/fxfa/app/xfa_fwltheme.cpp @@ -35,14 +35,13 @@ const FX_WCHAR* const g_FWLTheme_CalFonts[] = { CXFA_FFWidget* XFA_ThemeGetOuterWidget(IFWL_Widget* pWidget) { IFWL_Widget* pOuter = pWidget; - while (pOuter->GetOuter()) { + while (pOuter && pOuter->GetOuter()) pOuter = pOuter->GetOuter(); - } - if (pOuter) { - return (CXFA_FFWidget*)pOuter->GetPrivateData(pOuter); - } - return NULL; + + return pOuter ? static_cast<CXFA_FFWidget*>(pOuter->GetLayoutItem()) + : nullptr; } + CXFA_FWLTheme::CXFA_FWLTheme(CXFA_FFApp* pApp) : m_pApp(pApp) { m_dwCapacity = 0; m_fCapacity = 0; |