summaryrefslogtreecommitdiff
path: root/xfa/fwl/core
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-10-31 07:29:34 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-31 07:29:34 -0700
commit20855384b8149a631c3c1d229551523c12eb767b (patch)
treee3cef278e322742bea6c4b48f40ed580754ebd80 /xfa/fwl/core
parent747dcf775c5cb661e96a639f73322cc489d8590f (diff)
downloadpdfium-20855384b8149a631c3c1d229551523c12eb767b.tar.xz
Remove FWL globals.
This CL removes the FWL_GetApp, FWL_SetApp and FWL_GetWidgetAdapter methods. In the process it changes the various Initialize methods to return void. Review-Url: https://codereview.chromium.org/2436103002
Diffstat (limited to 'xfa/fwl/core')
-rw-r--r--xfa/fwl/core/cfwl_barcode.cpp39
-rw-r--r--xfa/fwl/core/cfwl_barcode.h5
-rw-r--r--xfa/fwl/core/cfwl_checkbox.cpp39
-rw-r--r--xfa/fwl/core/cfwl_checkbox.h5
-rw-r--r--xfa/fwl/core/cfwl_combobox.cpp39
-rw-r--r--xfa/fwl/core/cfwl_combobox.h5
-rw-r--r--xfa/fwl/core/cfwl_datetimepicker.cpp41
-rw-r--r--xfa/fwl/core/cfwl_datetimepicker.h5
-rw-r--r--xfa/fwl/core/cfwl_edit.cpp39
-rw-r--r--xfa/fwl/core/cfwl_edit.h5
-rw-r--r--xfa/fwl/core/cfwl_listbox.cpp39
-rw-r--r--xfa/fwl/core/cfwl_listbox.h5
-rw-r--r--xfa/fwl/core/cfwl_picturebox.cpp40
-rw-r--r--xfa/fwl/core/cfwl_picturebox.h5
-rw-r--r--xfa/fwl/core/cfwl_pushbutton.cpp40
-rw-r--r--xfa/fwl/core/cfwl_pushbutton.h5
-rw-r--r--xfa/fwl/core/cfwl_themetext.h1
-rw-r--r--xfa/fwl/core/cfwl_widget.cpp19
-rw-r--r--xfa/fwl/core/cfwl_widget.h5
-rw-r--r--xfa/fwl/core/cfwl_widgetmgr.cpp19
-rw-r--r--xfa/fwl/core/cfwl_widgetmgr.h5
-rw-r--r--xfa/fwl/core/fwl_noteimp.cpp36
-rw-r--r--xfa/fwl/core/fwl_noteimp.h1
-rw-r--r--xfa/fwl/core/ifwl_app.cpp32
-rw-r--r--xfa/fwl/core/ifwl_app.h10
-rw-r--r--xfa/fwl/core/ifwl_barcode.cpp15
-rw-r--r--xfa/fwl/core/ifwl_barcode.h7
-rw-r--r--xfa/fwl/core/ifwl_caret.cpp28
-rw-r--r--xfa/fwl/core/ifwl_caret.h20
-rw-r--r--xfa/fwl/core/ifwl_checkbox.cpp23
-rw-r--r--xfa/fwl/core/ifwl_checkbox.h7
-rw-r--r--xfa/fwl/core/ifwl_combobox.cpp62
-rw-r--r--xfa/fwl/core/ifwl_combobox.h8
-rw-r--r--xfa/fwl/core/ifwl_comboedit.cpp5
-rw-r--r--xfa/fwl/core/ifwl_comboedit.h3
-rw-r--r--xfa/fwl/core/ifwl_combolist.cpp13
-rw-r--r--xfa/fwl/core/ifwl_combolist.h5
-rw-r--r--xfa/fwl/core/ifwl_dataprovider.h1
-rw-r--r--xfa/fwl/core/ifwl_datetimecalendar.cpp11
-rw-r--r--xfa/fwl/core/ifwl_datetimecalendar.h5
-rw-r--r--xfa/fwl/core/ifwl_datetimeedit.cpp14
-rw-r--r--xfa/fwl/core/ifwl_datetimeedit.h5
-rw-r--r--xfa/fwl/core/ifwl_datetimepicker.cpp30
-rw-r--r--xfa/fwl/core/ifwl_datetimepicker.h7
-rw-r--r--xfa/fwl/core/ifwl_edit.cpp24
-rw-r--r--xfa/fwl/core/ifwl_edit.h8
-rw-r--r--xfa/fwl/core/ifwl_form.cpp54
-rw-r--r--xfa/fwl/core/ifwl_form.h9
-rw-r--r--xfa/fwl/core/ifwl_formproxy.cpp29
-rw-r--r--xfa/fwl/core/ifwl_formproxy.h7
-rw-r--r--xfa/fwl/core/ifwl_listbox.cpp22
-rw-r--r--xfa/fwl/core/ifwl_listbox.h8
-rw-r--r--xfa/fwl/core/ifwl_monthcalendar.cpp18
-rw-r--r--xfa/fwl/core/ifwl_monthcalendar.h7
-rw-r--r--xfa/fwl/core/ifwl_picturebox.cpp20
-rw-r--r--xfa/fwl/core/ifwl_picturebox.h7
-rw-r--r--xfa/fwl/core/ifwl_pushbutton.cpp20
-rw-r--r--xfa/fwl/core/ifwl_pushbutton.h7
-rw-r--r--xfa/fwl/core/ifwl_scrollbar.cpp46
-rw-r--r--xfa/fwl/core/ifwl_scrollbar.h26
-rw-r--r--xfa/fwl/core/ifwl_spinbutton.cpp50
-rw-r--r--xfa/fwl/core/ifwl_spinbutton.h22
-rw-r--r--xfa/fwl/core/ifwl_themeprovider.h1
-rw-r--r--xfa/fwl/core/ifwl_timer.cpp17
-rw-r--r--xfa/fwl/core/ifwl_timer.h14
-rw-r--r--xfa/fwl/core/ifwl_tooltip.cpp53
-rw-r--r--xfa/fwl/core/ifwl_tooltip.h23
-rw-r--r--xfa/fwl/core/ifwl_widget.cpp42
-rw-r--r--xfa/fwl/core/ifwl_widget.h12
-rw-r--r--xfa/fwl/core/ifwl_widgetdelegate.h1
70 files changed, 632 insertions, 668 deletions
diff --git a/xfa/fwl/core/cfwl_barcode.cpp b/xfa/fwl/core/cfwl_barcode.cpp
index 5a3f9dd545..c17185990e 100644
--- a/xfa/fwl/core/cfwl_barcode.cpp
+++ b/xfa/fwl/core/cfwl_barcode.cpp
@@ -8,34 +8,31 @@
#include <memory>
-IFWL_Barcode* CFWL_Barcode::GetWidget() {
- return static_cast<IFWL_Barcode*>(m_pIface.get());
-}
+CFWL_Barcode::CFWL_Barcode(const IFWL_App* app) : CFWL_Edit(app) {}
-const IFWL_Barcode* CFWL_Barcode::GetWidget() const {
- return static_cast<IFWL_Barcode*>(m_pIface.get());
-}
+CFWL_Barcode::~CFWL_Barcode() {}
-FWL_Error CFWL_Barcode::Initialize(const CFWL_WidgetProperties* pProperties) {
- if (m_pIface)
- return FWL_Error::Indefinite;
- if (pProperties) {
+void CFWL_Barcode::Initialize(const CFWL_WidgetProperties* pProperties) {
+ ASSERT(!m_pIface);
+
+ if (pProperties)
*m_pProperties = *pProperties;
- }
- std::unique_ptr<IFWL_Barcode> pBarcode(
- new IFWL_Barcode(m_pProperties->MakeWidgetImpProperties(&m_barcodeData)));
- FWL_Error ret = pBarcode->Initialize();
- if (ret != FWL_Error::Succeeded) {
- return ret;
- }
+
+ std::unique_ptr<IFWL_Barcode> pBarcode(new IFWL_Barcode(
+ m_pApp, m_pProperties->MakeWidgetImpProperties(&m_barcodeData)));
+ pBarcode->Initialize();
+
m_pIface = std::move(pBarcode);
- CFWL_Widget::Initialize();
- return FWL_Error::Succeeded;
+ CFWL_Widget::Initialize(pProperties);
}
-CFWL_Barcode::CFWL_Barcode() {}
+IFWL_Barcode* CFWL_Barcode::GetWidget() {
+ return static_cast<IFWL_Barcode*>(m_pIface.get());
+}
-CFWL_Barcode::~CFWL_Barcode() {}
+const IFWL_Barcode* CFWL_Barcode::GetWidget() const {
+ return static_cast<IFWL_Barcode*>(m_pIface.get());
+}
void CFWL_Barcode::SetType(BC_TYPE type) {
if (GetWidget())
diff --git a/xfa/fwl/core/cfwl_barcode.h b/xfa/fwl/core/cfwl_barcode.h
index aa6f8fccf4..c2bf38ad40 100644
--- a/xfa/fwl/core/cfwl_barcode.h
+++ b/xfa/fwl/core/cfwl_barcode.h
@@ -16,13 +16,14 @@ class CFWL_WidgetProperties;
class CFWL_Barcode : public CFWL_Edit {
public:
- CFWL_Barcode();
+ CFWL_Barcode(const IFWL_App*);
~CFWL_Barcode() override;
IFWL_Barcode* GetWidget() override;
const IFWL_Barcode* GetWidget() const override;
- FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+ void Initialize(const CFWL_WidgetProperties* pProperties);
+
void SetType(BC_TYPE type);
FX_BOOL IsProtectedType();
diff --git a/xfa/fwl/core/cfwl_checkbox.cpp b/xfa/fwl/core/cfwl_checkbox.cpp
index bc55a690f3..8ae3e970e3 100644
--- a/xfa/fwl/core/cfwl_checkbox.cpp
+++ b/xfa/fwl/core/cfwl_checkbox.cpp
@@ -10,6 +10,24 @@
#include "xfa/fwl/core/fwl_error.h"
+CFWL_CheckBox::CFWL_CheckBox(const IFWL_App* app) : CFWL_Widget(app) {}
+
+CFWL_CheckBox::~CFWL_CheckBox() {}
+
+void CFWL_CheckBox::Initialize(const CFWL_WidgetProperties* pProperties) {
+ ASSERT(!m_pIface);
+
+ if (pProperties)
+ *m_pProperties = *pProperties;
+
+ std::unique_ptr<IFWL_CheckBox> pCheckBox(new IFWL_CheckBox(
+ m_pApp, m_pProperties->MakeWidgetImpProperties(&m_checkboxData)));
+ pCheckBox->Initialize();
+
+ m_pIface = std::move(pCheckBox);
+ CFWL_Widget::Initialize(pProperties);
+}
+
IFWL_CheckBox* CFWL_CheckBox::GetWidget() {
return static_cast<IFWL_CheckBox*>(m_pIface.get());
}
@@ -18,23 +36,6 @@ const IFWL_CheckBox* CFWL_CheckBox::GetWidget() const {
return static_cast<IFWL_CheckBox*>(m_pIface.get());
}
-FWL_Error CFWL_CheckBox::Initialize(const CFWL_WidgetProperties* pProperties) {
- if (m_pIface)
- return FWL_Error::Indefinite;
- if (pProperties) {
- *m_pProperties = *pProperties;
- }
- std::unique_ptr<IFWL_CheckBox> pCheckBox(new IFWL_CheckBox(
- m_pProperties->MakeWidgetImpProperties(&m_checkboxData)));
- FWL_Error ret = pCheckBox->Initialize();
- if (ret != FWL_Error::Succeeded) {
- return ret;
- }
- m_pIface = std::move(pCheckBox);
- CFWL_Widget::Initialize();
- return FWL_Error::Succeeded;
-}
-
FWL_Error CFWL_CheckBox::SetCaption(const CFX_WideStringC& wsCaption) {
m_checkboxData.m_wsCaption = wsCaption;
return FWL_Error::Succeeded;
@@ -53,10 +54,6 @@ FWL_Error CFWL_CheckBox::SetCheckState(int32_t iCheck) {
return GetWidget()->SetCheckState(iCheck);
}
-CFWL_CheckBox::CFWL_CheckBox() {}
-
-CFWL_CheckBox::~CFWL_CheckBox() {}
-
CFWL_CheckBox::CFWL_CheckBoxDP::CFWL_CheckBoxDP()
: m_fBoxHeight(16.0f), m_wsCaption(L"Check box") {}
diff --git a/xfa/fwl/core/cfwl_checkbox.h b/xfa/fwl/core/cfwl_checkbox.h
index 9daab33150..e17e6b5ef7 100644
--- a/xfa/fwl/core/cfwl_checkbox.h
+++ b/xfa/fwl/core/cfwl_checkbox.h
@@ -12,13 +12,14 @@
class CFWL_CheckBox : public CFWL_Widget {
public:
- CFWL_CheckBox();
+ CFWL_CheckBox(const IFWL_App*);
~CFWL_CheckBox() override;
IFWL_CheckBox* GetWidget() override;
const IFWL_CheckBox* GetWidget() const override;
- FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+ void Initialize(const CFWL_WidgetProperties* pProperties);
+
FWL_Error SetCaption(const CFX_WideStringC& wsCaption);
FWL_Error SetBoxSize(FX_FLOAT fHeight);
int32_t GetCheckState();
diff --git a/xfa/fwl/core/cfwl_combobox.cpp b/xfa/fwl/core/cfwl_combobox.cpp
index e00f785ade..825df9c538 100644
--- a/xfa/fwl/core/cfwl_combobox.cpp
+++ b/xfa/fwl/core/cfwl_combobox.cpp
@@ -11,6 +11,24 @@
#include "xfa/fwl/core/fwl_error.h"
#include "xfa/fwl/core/ifwl_widget.h"
+CFWL_ComboBox::CFWL_ComboBox(const IFWL_App* app) : CFWL_Widget(app) {}
+
+CFWL_ComboBox::~CFWL_ComboBox() {}
+
+void CFWL_ComboBox::Initialize(const CFWL_WidgetProperties* pProperties) {
+ ASSERT(!m_pIface);
+
+ if (pProperties)
+ *m_pProperties = *pProperties;
+
+ std::unique_ptr<IFWL_ComboBox> pComboBox(new IFWL_ComboBox(
+ m_pApp, m_pProperties->MakeWidgetImpProperties(&m_comboBoxData)));
+ pComboBox->Initialize();
+
+ m_pIface = std::move(pComboBox);
+ CFWL_Widget::Initialize(pProperties);
+}
+
IFWL_ComboBox* CFWL_ComboBox::GetWidget() {
return static_cast<IFWL_ComboBox*>(m_pIface.get());
}
@@ -19,23 +37,6 @@ const IFWL_ComboBox* CFWL_ComboBox::GetWidget() const {
return static_cast<IFWL_ComboBox*>(m_pIface.get());
}
-FWL_Error CFWL_ComboBox::Initialize(const CFWL_WidgetProperties* pProperties) {
- if (m_pIface)
- return FWL_Error::Indefinite;
- if (pProperties) {
- *m_pProperties = *pProperties;
- }
- std::unique_ptr<IFWL_ComboBox> pComboBox(new IFWL_ComboBox(
- m_pProperties->MakeWidgetImpProperties(&m_comboBoxData)));
- FWL_Error ret = pComboBox->Initialize();
- if (ret != FWL_Error::Succeeded) {
- return ret;
- }
- m_pIface = std::move(pComboBox);
- CFWL_Widget::Initialize();
- return FWL_Error::Succeeded;
-}
-
int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) {
std::unique_ptr<CFWL_ComboBoxItem> pItem(new CFWL_ComboBoxItem);
pItem->m_wsText = wsText;
@@ -231,10 +232,6 @@ FWL_Error CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded,
: FWL_Error::Indefinite;
}
-CFWL_ComboBox::CFWL_ComboBox() {}
-
-CFWL_ComboBox::~CFWL_ComboBox() {}
-
CFWL_ComboBox::CFWL_ComboBoxDP::CFWL_ComboBoxDP() {
m_fItemHeight = 0;
m_fMaxListHeight = 0;
diff --git a/xfa/fwl/core/cfwl_combobox.h b/xfa/fwl/core/cfwl_combobox.h
index 6e4988fe8e..bb19e55653 100644
--- a/xfa/fwl/core/cfwl_combobox.h
+++ b/xfa/fwl/core/cfwl_combobox.h
@@ -20,13 +20,14 @@ class CFWL_ComboBoxItem;
class CFWL_ComboBox : public CFWL_Widget {
public:
- CFWL_ComboBox();
+ CFWL_ComboBox(const IFWL_App*);
~CFWL_ComboBox() override;
IFWL_ComboBox* GetWidget() override;
const IFWL_ComboBox* GetWidget() const override;
- FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+ void Initialize(const CFWL_WidgetProperties* pProperties);
+
int32_t AddString(const CFX_WideStringC& wsText);
int32_t AddString(const CFX_WideStringC& wsText, CFX_DIBitmap* pIcon);
bool RemoveAt(int32_t iIndex); // Returns false iff |iIndex| out of range.
diff --git a/xfa/fwl/core/cfwl_datetimepicker.cpp b/xfa/fwl/core/cfwl_datetimepicker.cpp
index 7d5a1535f1..ebfcee62ba 100644
--- a/xfa/fwl/core/cfwl_datetimepicker.cpp
+++ b/xfa/fwl/core/cfwl_datetimepicker.cpp
@@ -12,6 +12,25 @@
#include "xfa/fwl/core/ifwl_datetimepicker.h"
#include "xfa/fwl/core/ifwl_widget.h"
+CFWL_DateTimePicker::CFWL_DateTimePicker(const IFWL_App* app)
+ : CFWL_Widget(app) {}
+
+CFWL_DateTimePicker::~CFWL_DateTimePicker() {}
+
+void CFWL_DateTimePicker::Initialize(const CFWL_WidgetProperties* pProperties) {
+ ASSERT(!m_pIface);
+
+ if (pProperties)
+ *m_pProperties = *pProperties;
+
+ std::unique_ptr<IFWL_DateTimePicker> pDateTimePicker(new IFWL_DateTimePicker(
+ m_pApp, m_pProperties->MakeWidgetImpProperties(&m_DateTimePickerDP)));
+ pDateTimePicker->Initialize();
+
+ m_pIface = std::move(pDateTimePicker);
+ CFWL_Widget::Initialize(pProperties);
+}
+
IFWL_DateTimePicker* CFWL_DateTimePicker::GetWidget() {
return static_cast<IFWL_DateTimePicker*>(m_pIface.get());
}
@@ -20,24 +39,6 @@ const IFWL_DateTimePicker* CFWL_DateTimePicker::GetWidget() const {
return static_cast<IFWL_DateTimePicker*>(m_pIface.get());
}
-FWL_Error CFWL_DateTimePicker::Initialize(
- const CFWL_WidgetProperties* pProperties) {
- if (m_pIface)
- return FWL_Error::Indefinite;
- if (pProperties) {
- *m_pProperties = *pProperties;
- }
- std::unique_ptr<IFWL_DateTimePicker> pDateTimePicker(new IFWL_DateTimePicker(
- m_pProperties->MakeWidgetImpProperties(&m_DateTimePickerDP)));
- FWL_Error ret = pDateTimePicker->Initialize();
- if (ret != FWL_Error::Succeeded) {
- return ret;
- }
- m_pIface = std::move(pDateTimePicker);
- CFWL_Widget::Initialize();
- return FWL_Error::Succeeded;
-}
-
FWL_Error CFWL_DateTimePicker::SetToday(int32_t iYear,
int32_t iMonth,
int32_t iDay) {
@@ -75,10 +76,6 @@ FWL_Error CFWL_DateTimePicker::SetCurSel(int32_t iYear,
return GetWidget()->SetCurSel(iYear, iMonth, iDay);
}
-CFWL_DateTimePicker::CFWL_DateTimePicker() {}
-
-CFWL_DateTimePicker::~CFWL_DateTimePicker() {}
-
CFWL_DateTimePicker::CFWL_DateTimePickerDP::CFWL_DateTimePickerDP() {
m_iYear = 2011;
m_iMonth = 1;
diff --git a/xfa/fwl/core/cfwl_datetimepicker.h b/xfa/fwl/core/cfwl_datetimepicker.h
index a3299a92a0..2de57add80 100644
--- a/xfa/fwl/core/cfwl_datetimepicker.h
+++ b/xfa/fwl/core/cfwl_datetimepicker.h
@@ -12,13 +12,14 @@
class CFWL_DateTimePicker : public CFWL_Widget {
public:
- CFWL_DateTimePicker();
+ CFWL_DateTimePicker(const IFWL_App*);
~CFWL_DateTimePicker() override;
IFWL_DateTimePicker* GetWidget() override;
const IFWL_DateTimePicker* GetWidget() const override;
- FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+ void Initialize(const CFWL_WidgetProperties* pProperties);
+
FWL_Error SetToday(int32_t iYear, int32_t iMonth, int32_t iDay);
FWL_Error GetEditText(CFX_WideString& wsText);
FWL_Error SetEditText(const CFX_WideString& wsText);
diff --git a/xfa/fwl/core/cfwl_edit.cpp b/xfa/fwl/core/cfwl_edit.cpp
index 9e106929bb..d0936a65b7 100644
--- a/xfa/fwl/core/cfwl_edit.cpp
+++ b/xfa/fwl/core/cfwl_edit.cpp
@@ -9,6 +9,24 @@
#include <memory>
#include <vector>
+CFWL_Edit::CFWL_Edit(const IFWL_App* app) : CFWL_Widget(app) {}
+
+CFWL_Edit::~CFWL_Edit() {}
+
+void CFWL_Edit::Initialize(const CFWL_WidgetProperties* pProperties) {
+ ASSERT(!m_pIface);
+
+ if (pProperties)
+ *m_pProperties = *pProperties;
+
+ std::unique_ptr<IFWL_Edit> pEdit(new IFWL_Edit(
+ m_pApp, m_pProperties->MakeWidgetImpProperties(nullptr), nullptr));
+ pEdit->Initialize();
+
+ m_pIface = std::move(pEdit);
+ CFWL_Widget::Initialize(pProperties);
+}
+
IFWL_Edit* CFWL_Edit::GetWidget() {
return static_cast<IFWL_Edit*>(m_pIface.get());
}
@@ -17,23 +35,6 @@ const IFWL_Edit* CFWL_Edit::GetWidget() const {
return static_cast<IFWL_Edit*>(m_pIface.get());
}
-FWL_Error CFWL_Edit::Initialize(const CFWL_WidgetProperties* pProperties) {
- if (m_pIface)
- return FWL_Error::Indefinite;
- if (pProperties) {
- *m_pProperties = *pProperties;
- }
- std::unique_ptr<IFWL_Edit> pEdit(
- new IFWL_Edit(m_pProperties->MakeWidgetImpProperties(nullptr), nullptr));
- FWL_Error ret = pEdit->Initialize();
- if (ret != FWL_Error::Succeeded) {
- return ret;
- }
- m_pIface = std::move(pEdit);
- CFWL_Widget::Initialize();
- return FWL_Error::Succeeded;
-}
-
FWL_Error CFWL_Edit::SetText(const CFX_WideString& wsText) {
if (!GetWidget())
return FWL_Error::Indefinite;
@@ -234,7 +235,3 @@ FX_BOOL CFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf,
const CFX_ByteStringC& bsReplace) {
return GetWidget()->ReplaceSpellCheckWord(pointf, bsReplace);
}
-
-CFWL_Edit::CFWL_Edit() {}
-
-CFWL_Edit::~CFWL_Edit() {}
diff --git a/xfa/fwl/core/cfwl_edit.h b/xfa/fwl/core/cfwl_edit.h
index 83343ac751..ceeb95f325 100644
--- a/xfa/fwl/core/cfwl_edit.h
+++ b/xfa/fwl/core/cfwl_edit.h
@@ -17,13 +17,14 @@ class IFDE_TxtEdtDoRecord;
class CFWL_Edit : public CFWL_Widget {
public:
- CFWL_Edit();
+ CFWL_Edit(const IFWL_App*);
~CFWL_Edit() override;
IFWL_Edit* GetWidget() override;
const IFWL_Edit* GetWidget() const override;
- FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+ void Initialize(const CFWL_WidgetProperties* pProperties);
+
FWL_Error SetText(const CFX_WideString& wsText);
int32_t GetTextLength() const;
FWL_Error GetText(CFX_WideString& wsText,
diff --git a/xfa/fwl/core/cfwl_listbox.cpp b/xfa/fwl/core/cfwl_listbox.cpp
index 3884e8c42e..f8a5e199c2 100644
--- a/xfa/fwl/core/cfwl_listbox.cpp
+++ b/xfa/fwl/core/cfwl_listbox.cpp
@@ -10,6 +10,24 @@
#include "third_party/base/stl_util.h"
+CFWL_ListBox::CFWL_ListBox(const IFWL_App* app) : CFWL_Widget(app) {}
+
+CFWL_ListBox::~CFWL_ListBox() {}
+
+void CFWL_ListBox::Initialize(const CFWL_WidgetProperties* pProperties) {
+ ASSERT(!m_pIface);
+
+ if (pProperties)
+ *m_pProperties = *pProperties;
+
+ std::unique_ptr<IFWL_ListBox> pListBox(new IFWL_ListBox(
+ m_pApp, m_pProperties->MakeWidgetImpProperties(&m_ListBoxDP), nullptr));
+ pListBox->Initialize();
+
+ m_pIface = std::move(pListBox);
+ CFWL_Widget::Initialize(pProperties);
+}
+
IFWL_ListBox* CFWL_ListBox::GetWidget() {
return static_cast<IFWL_ListBox*>(m_pIface.get());
}
@@ -18,23 +36,6 @@ const IFWL_ListBox* CFWL_ListBox::GetWidget() const {
return static_cast<IFWL_ListBox*>(m_pIface.get());
}
-FWL_Error CFWL_ListBox::Initialize(const CFWL_WidgetProperties* pProperties) {
- if (m_pIface)
- return FWL_Error::Indefinite;
- if (pProperties) {
- *m_pProperties = *pProperties;
- }
- std::unique_ptr<IFWL_ListBox> pListBox(new IFWL_ListBox(
- m_pProperties->MakeWidgetImpProperties(&m_ListBoxDP), nullptr));
- FWL_Error ret = pListBox->Initialize();
- if (ret != FWL_Error::Succeeded) {
- return ret;
- }
- m_pIface = std::move(pListBox);
- CFWL_Widget::Initialize();
- return FWL_Error::Succeeded;
-}
-
FWL_Error CFWL_ListBox::AddDIBitmap(CFX_DIBitmap* pDIB, IFWL_ListItem* pItem) {
static_cast<CFWL_ListItem*>(pItem)->m_pDIB = pDIB;
return FWL_Error::Succeeded;
@@ -203,10 +204,6 @@ uint32_t CFWL_ListBox::GetItemStates(IFWL_ListItem* pItem) {
return pListItem->m_dwStates | pListItem->m_dwCheckState;
}
-CFWL_ListBox::CFWL_ListBox() {}
-
-CFWL_ListBox::~CFWL_ListBox() {}
-
CFWL_ListBox::CFWL_ListBoxDP::CFWL_ListBoxDP() {}
CFWL_ListBox::CFWL_ListBoxDP::~CFWL_ListBoxDP() {}
diff --git a/xfa/fwl/core/cfwl_listbox.h b/xfa/fwl/core/cfwl_listbox.h
index 52caaeaea9..872ac722db 100644
--- a/xfa/fwl/core/cfwl_listbox.h
+++ b/xfa/fwl/core/cfwl_listbox.h
@@ -19,13 +19,14 @@ class CFWL_ListItem;
class CFWL_ListBox : public CFWL_Widget {
public:
- CFWL_ListBox();
+ CFWL_ListBox(const IFWL_App*);
~CFWL_ListBox() override;
IFWL_ListBox* GetWidget() override;
const IFWL_ListBox* GetWidget() const override;
- FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+ void Initialize(const CFWL_WidgetProperties* pProperties);
+
FWL_Error AddDIBitmap(CFX_DIBitmap* pDIB, IFWL_ListItem* pItem);
IFWL_ListItem* AddString(const CFX_WideStringC& wsAdd,
FX_BOOL bSelect = FALSE);
diff --git a/xfa/fwl/core/cfwl_picturebox.cpp b/xfa/fwl/core/cfwl_picturebox.cpp
index 92058a9818..8210db2562 100644
--- a/xfa/fwl/core/cfwl_picturebox.cpp
+++ b/xfa/fwl/core/cfwl_picturebox.cpp
@@ -8,6 +8,24 @@
#include <memory>
+CFWL_PictureBox::CFWL_PictureBox(const IFWL_App* app) : CFWL_Widget(app) {}
+
+CFWL_PictureBox::~CFWL_PictureBox() {}
+
+void CFWL_PictureBox::Initialize(const CFWL_WidgetProperties* pProperties) {
+ ASSERT(!m_pIface);
+
+ if (pProperties)
+ *m_pProperties = *pProperties;
+
+ std::unique_ptr<IFWL_PictureBox> pPictureBox(new IFWL_PictureBox(
+ m_pApp, m_pProperties->MakeWidgetImpProperties(&m_PictureBoxDP)));
+ pPictureBox->Initialize();
+
+ m_pIface = std::move(pPictureBox);
+ CFWL_Widget::Initialize(pProperties);
+}
+
IFWL_PictureBox* CFWL_PictureBox::GetWidget() {
return static_cast<IFWL_PictureBox*>(m_pIface.get());
}
@@ -16,24 +34,6 @@ const IFWL_PictureBox* CFWL_PictureBox::GetWidget() const {
return static_cast<IFWL_PictureBox*>(m_pIface.get());
}
-FWL_Error CFWL_PictureBox::Initialize(
- const CFWL_WidgetProperties* pProperties) {
- if (m_pIface)
- return FWL_Error::Indefinite;
- if (pProperties) {
- *m_pProperties = *pProperties;
- }
- std::unique_ptr<IFWL_PictureBox> pPictureBox(new IFWL_PictureBox(
- m_pProperties->MakeWidgetImpProperties(&m_PictureBoxDP)));
- FWL_Error ret = pPictureBox->Initialize();
- if (ret != FWL_Error::Succeeded) {
- return ret;
- }
- m_pIface = std::move(pPictureBox);
- CFWL_Widget::Initialize();
- return FWL_Error::Succeeded;
-}
-
CFX_DIBitmap* CFWL_PictureBox::GetPicture() {
return m_PictureBoxDP.m_pBitmap;
}
@@ -97,10 +97,6 @@ FWL_Error CFWL_PictureBox::SetOffset(FX_FLOAT fx, FX_FLOAT fy) {
return FWL_Error::Succeeded;
}
-CFWL_PictureBox::CFWL_PictureBox() {}
-
-CFWL_PictureBox::~CFWL_PictureBox() {}
-
CFWL_PictureBox::CFWL_PictureBoxDP::CFWL_PictureBoxDP()
: m_pBitmap(nullptr),
m_iOpacity(0),
diff --git a/xfa/fwl/core/cfwl_picturebox.h b/xfa/fwl/core/cfwl_picturebox.h
index 584950f045..2338009cc1 100644
--- a/xfa/fwl/core/cfwl_picturebox.h
+++ b/xfa/fwl/core/cfwl_picturebox.h
@@ -13,13 +13,14 @@
class CFWL_PictureBox : public CFWL_Widget {
public:
- CFWL_PictureBox();
+ CFWL_PictureBox(const IFWL_App*);
~CFWL_PictureBox() override;
IFWL_PictureBox* GetWidget() override;
const IFWL_PictureBox* GetWidget() const override;
- FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+ void Initialize(const CFWL_WidgetProperties* pProperties);
+
CFX_DIBitmap* GetPicture();
FWL_Error SetPicture(CFX_DIBitmap* pBitmap);
FX_FLOAT GetRotation();
diff --git a/xfa/fwl/core/cfwl_pushbutton.cpp b/xfa/fwl/core/cfwl_pushbutton.cpp
index 8425f5de24..0930f93aa0 100644
--- a/xfa/fwl/core/cfwl_pushbutton.cpp
+++ b/xfa/fwl/core/cfwl_pushbutton.cpp
@@ -8,6 +8,24 @@
#include <memory>
+CFWL_PushButton::CFWL_PushButton(const IFWL_App* app) : CFWL_Widget(app) {}
+
+CFWL_PushButton::~CFWL_PushButton() {}
+
+void CFWL_PushButton::Initialize(const CFWL_WidgetProperties* pProperties) {
+ ASSERT(!m_pIface);
+
+ if (pProperties)
+ *m_pProperties = *pProperties;
+
+ std::unique_ptr<IFWL_PushButton> pPushButton(new IFWL_PushButton(
+ m_pApp, m_pProperties->MakeWidgetImpProperties(&m_buttonData)));
+ pPushButton->Initialize();
+
+ m_pIface = std::move(pPushButton);
+ CFWL_Widget::Initialize(pProperties);
+}
+
IFWL_PushButton* CFWL_PushButton::GetWidget() {
return static_cast<IFWL_PushButton*>(m_pIface.get());
}
@@ -16,24 +34,6 @@ const IFWL_PushButton* CFWL_PushButton::GetWidget() const {
return static_cast<IFWL_PushButton*>(m_pIface.get());
}
-FWL_Error CFWL_PushButton::Initialize(
- const CFWL_WidgetProperties* pProperties) {
- if (m_pIface)
- return FWL_Error::Indefinite;
- if (pProperties) {
- *m_pProperties = *pProperties;
- }
- std::unique_ptr<IFWL_PushButton> pPushButton(new IFWL_PushButton(
- m_pProperties->MakeWidgetImpProperties(&m_buttonData)));
- FWL_Error ret = pPushButton->Initialize();
- if (ret != FWL_Error::Succeeded) {
- return ret;
- }
- m_pIface = std::move(pPushButton);
- CFWL_Widget::Initialize();
- return FWL_Error::Succeeded;
-}
-
FWL_Error CFWL_PushButton::GetCaption(CFX_WideString& wsCaption) {
wsCaption = m_buttonData.m_wsCaption;
return FWL_Error::Succeeded;
@@ -53,10 +53,6 @@ FWL_Error CFWL_PushButton::SetPicture(CFX_DIBitmap* pBitmap) {
return FWL_Error::Succeeded;
}
-CFWL_PushButton::CFWL_PushButton() {}
-
-CFWL_PushButton::~CFWL_PushButton() {}
-
FWL_Error CFWL_PushButton::CFWL_PushButtonDP::GetCaption(
IFWL_Widget* pWidget,
CFX_WideString& wsCaption) {
diff --git a/xfa/fwl/core/cfwl_pushbutton.h b/xfa/fwl/core/cfwl_pushbutton.h
index 8f11660ce9..44106d3c2c 100644
--- a/xfa/fwl/core/cfwl_pushbutton.h
+++ b/xfa/fwl/core/cfwl_pushbutton.h
@@ -12,13 +12,14 @@
class CFWL_PushButton : public CFWL_Widget {
public:
- CFWL_PushButton();
+ CFWL_PushButton(const IFWL_App*);
~CFWL_PushButton() override;
IFWL_PushButton* GetWidget() override;
const IFWL_PushButton* GetWidget() const override;
- FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+ void Initialize(const CFWL_WidgetProperties* pProperties);
+
FWL_Error GetCaption(CFX_WideString& wsCaption);
FWL_Error SetCaption(const CFX_WideStringC& wsCaption);
CFX_DIBitmap* GetPicture();
diff --git a/xfa/fwl/core/cfwl_themetext.h b/xfa/fwl/core/cfwl_themetext.h
index b570ca814d..9662414069 100644
--- a/xfa/fwl/core/cfwl_themetext.h
+++ b/xfa/fwl/core/cfwl_themetext.h
@@ -14,6 +14,7 @@
class CFWL_ThemeText : public CFWL_ThemePart {
public:
CFWL_ThemeText() : m_pGraphics(nullptr) {}
+
CFX_WideString m_wsText;
uint32_t m_dwTTOStyles;
int32_t m_iTTOAlign;
diff --git a/xfa/fwl/core/cfwl_widget.cpp b/xfa/fwl/core/cfwl_widget.cpp
index 7f6bd3b07c..d7903ea8a8 100644
--- a/xfa/fwl/core/cfwl_widget.cpp
+++ b/xfa/fwl/core/cfwl_widget.cpp
@@ -18,9 +18,10 @@
#define FWL_WGT_CalcWidth 2048
#define FWL_WGT_CalcMultiLineDefWidth 120.0f
-CFWL_Widget::CFWL_Widget()
- : m_pDelegate(nullptr),
- m_pWidgetMgr(CFWL_WidgetMgr::GetInstance()),
+CFWL_Widget::CFWL_Widget(const IFWL_App* app)
+ : m_pApp(app),
+ m_pDelegate(nullptr),
+ m_pWidgetMgr(app->GetWidgetMgr()),
m_pProperties(new CFWL_WidgetProperties) {
ASSERT(m_pWidgetMgr);
}
@@ -30,6 +31,11 @@ CFWL_Widget::~CFWL_Widget() {
m_pIface->Finalize();
}
+void CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) {
+ ASSERT(m_pIface);
+ m_pIface->SetAssociateWidget(this);
+}
+
IFWL_Widget* CFWL_Widget::GetWidget() {
return m_pIface.get();
}
@@ -38,13 +44,6 @@ const IFWL_Widget* CFWL_Widget::GetWidget() const {
return m_pIface.get();
}
-FWL_Error CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) {
- if (!m_pIface)
- return FWL_Error::Indefinite;
- m_pIface->SetAssociateWidget(this);
- return FWL_Error::Succeeded;
-}
-
FWL_Error CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (!m_pIface)
return FWL_Error::Indefinite;
diff --git a/xfa/fwl/core/cfwl_widget.h b/xfa/fwl/core/cfwl_widget.h
index cc6967852f..b96c1ffaec 100644
--- a/xfa/fwl/core/cfwl_widget.h
+++ b/xfa/fwl/core/cfwl_widget.h
@@ -21,7 +21,7 @@ class CFWL_WidgetMgr;
class CFWL_Widget {
public:
- CFWL_Widget();
+ CFWL_Widget(const IFWL_App*);
virtual ~CFWL_Widget();
virtual IFWL_Widget* GetWidget();
@@ -54,8 +54,9 @@ class CFWL_Widget {
IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate);
protected:
- FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+ void Initialize(const CFWL_WidgetProperties* pProperties);
+ const IFWL_App* m_pApp;
std::unique_ptr<IFWL_Widget> m_pIface;
IFWL_WidgetDelegate* m_pDelegate;
CFWL_WidgetMgr* const m_pWidgetMgr;
diff --git a/xfa/fwl/core/cfwl_widgetmgr.cpp b/xfa/fwl/core/cfwl_widgetmgr.cpp
index 79d03b701b..bcbc394884 100644
--- a/xfa/fwl/core/cfwl_widgetmgr.cpp
+++ b/xfa/fwl/core/cfwl_widgetmgr.cpp
@@ -34,12 +34,6 @@ FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) {
#endif
}
-// static
-CFWL_WidgetMgr* CFWL_WidgetMgr::GetInstance() {
- IFWL_App* pApp = FWL_GetApp();
- return pApp ? pApp->GetWidgetMgr() : nullptr;
-}
-
CFWL_WidgetMgr::CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative)
: m_dwCapability(0),
m_pDelegate(new CFWL_WidgetMgrDelegate(this)),
@@ -392,7 +386,7 @@ void CFWL_WidgetMgr::NotifySizeChanged(IFWL_Widget* pForm,
IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent,
IFWL_Widget* focus,
FX_BOOL& bFind) {
- CFWL_WidgetMgr* pMgr = CFWL_WidgetMgr::GetInstance();
+ CFWL_WidgetMgr* pMgr = parent->GetOwnerApp()->GetWidgetMgr();
IFWL_Widget* child = pMgr->GetFirstChildWidget(parent);
while (child) {
if (focus == child)
@@ -470,7 +464,7 @@ IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) {
return pParent;
}
IFWL_Widget* child =
- CFWL_WidgetMgr::GetInstance()->GetFirstChildWidget(pParent);
+ pParent->GetOwnerApp()->GetWidgetMgr()->GetFirstChildWidget(pParent);
while (child) {
if ((child->GetClassID() == FWL_Type::PushButton) &&
(child->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) {
@@ -480,7 +474,7 @@ IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) {
if (find) {
return find;
}
- child = CFWL_WidgetMgr::GetInstance()->GetNextSiblingWidget(child);
+ child = child->GetOwnerApp()->GetWidgetMgr()->GetNextSiblingWidget(child);
}
return nullptr;
}
@@ -573,7 +567,7 @@ void CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) {
return;
IFWL_Widget* pDstWidget = pMessage->m_pDstTarget;
- IFWL_App* pApp = pDstWidget->GetOwnerApp();
+ const IFWL_App* pApp = pDstWidget->GetOwnerApp();
if (!pApp)
return;
@@ -755,7 +749,7 @@ FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget,
return FALSE;
IFWL_Widget* pChild =
- CFWL_WidgetMgr::GetInstance()->GetFirstChildWidget(pWidget);
+ pWidget->GetOwnerApp()->GetWidgetMgr()->GetFirstChildWidget(pWidget);
if (!pChild)
return TRUE;
@@ -813,7 +807,8 @@ FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget,
if (r.Contains(hitPoint[i].hitPoint))
hitPoint[i].bNotNeedRepaint = true;
}
- pChild = CFWL_WidgetMgr::GetInstance()->GetNextSiblingWidget(pChild);
+ pChild =
+ pChild->GetOwnerApp()->GetWidgetMgr()->GetNextSiblingWidget(pChild);
} while (pChild);
if (!bChildIntersectWithDirty)
diff --git a/xfa/fwl/core/cfwl_widgetmgr.h b/xfa/fwl/core/cfwl_widgetmgr.h
index e0188bd600..3c443cbfca 100644
--- a/xfa/fwl/core/cfwl_widgetmgr.h
+++ b/xfa/fwl/core/cfwl_widgetmgr.h
@@ -46,8 +46,6 @@ class CFWL_WidgetMgrItem {
class CFWL_WidgetMgr {
public:
- static CFWL_WidgetMgr* GetInstance();
-
explicit CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative);
~CFWL_WidgetMgr();
@@ -97,6 +95,8 @@ class CFWL_WidgetMgr {
CFX_RectF& rtPopup);
protected:
+ friend class CFWL_WidgetMgrDelegate;
+
int32_t TravelWidgetMgr(CFWL_WidgetMgrItem* pParent,
int32_t* pIndex,
CFWL_WidgetMgrItem* pItem,
@@ -110,7 +110,6 @@ class CFWL_WidgetMgr {
#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
CFX_RectF m_rtScreen;
#endif
- friend class CFWL_WidgetMgrDelegate;
};
class CFWL_WidgetMgrDelegate {
diff --git a/xfa/fwl/core/fwl_noteimp.cpp b/xfa/fwl/core/fwl_noteimp.cpp
index b6e02843e2..318fd9f6fc 100644
--- a/xfa/fwl/core/fwl_noteimp.cpp
+++ b/xfa/fwl/core/fwl_noteimp.cpp
@@ -21,12 +21,14 @@ FWL_Error CFWL_NoteLoop::Idle(int32_t count) {
if (count <= 0) {
#endif
CFWL_EvtIdle ev;
- IFWL_App* pApp = FWL_GetApp();
+ const IFWL_App* pApp = m_pForm->GetOwnerApp();
if (!pApp)
return FWL_Error::Indefinite;
+
CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
if (!pDriver)
return FWL_Error::Indefinite;
+
pDriver->SendEvent(&ev);
#if (_FX_OS_ == _FX_WIN32_DESKTOP_)
}
@@ -51,7 +53,7 @@ FWL_Error CFWL_NoteLoop::SetMainForm(IFWL_Widget* pForm) {
void CFWL_NoteLoop::GenerateCommondEvent(uint32_t dwCommand) {
CFWL_EvtMenuCommand ev;
ev.m_iCommand = dwCommand;
- IFWL_App* pApp = m_pForm->GetOwnerApp();
+ const IFWL_App* pApp = m_pForm->GetOwnerApp();
if (!pApp)
return;
@@ -115,9 +117,7 @@ FWL_Error CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) {
void CFWL_NoteDriver::ClearEventTargets(FX_BOOL bRemoveAll) {
ClearInvalidEventTargets(bRemoveAll);
}
-IFWL_App* CFWL_NoteDriver::GetOwnerApp() const {
- return FWL_GetApp();
-}
+
FWL_Error CFWL_NoteDriver::PushNoteLoop(CFWL_NoteLoop* pNoteLoop) {
m_noteLoopQueue.Add(pNoteLoop);
return FWL_Error::Succeeded;
@@ -151,7 +151,7 @@ FX_BOOL CFWL_NoteDriver::SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify) {
}
if (pFocus) {
IFWL_Widget* pWidget =
- CFWL_WidgetMgr::GetInstance()->GetSystemFormWidget(pFocus);
+ pFocus->GetOwnerApp()->GetWidgetMgr()->GetSystemFormWidget(pFocus);
IFWL_Form* pForm = static_cast<IFWL_Form*>(pWidget);
if (pForm)
pForm->SetSubFocus(pFocus);
@@ -169,10 +169,6 @@ FX_BOOL CFWL_NoteDriver::SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify) {
return TRUE;
}
FWL_Error CFWL_NoteDriver::Run() {
- CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
- if (!pWidgetMgr)
- return FWL_Error::Indefinite;
-
#if (_FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_WIN32_DESKTOP_ || \
_FX_OS_ == _FX_WIN64_)
CFWL_NoteLoop* pTopLoop = nullptr;
@@ -294,7 +290,8 @@ int32_t CFWL_NoteDriver::CountLoop() {
}
FX_BOOL CFWL_NoteDriver::ProcessMessage(CFWL_Message* pMessage) {
- CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
+ CFWL_WidgetMgr* pWidgetMgr =
+ pMessage->m_pDstTarget->GetOwnerApp()->GetWidgetMgr();
IFWL_Widget* pMessageForm = pWidgetMgr->IsFormDisabled()
? pMessage->m_pDstTarget
: GetMessageForm(pMessage->m_pDstTarget);
@@ -413,7 +410,7 @@ FX_BOOL CFWL_NoteDriver::DoDeactivate(CFWL_MsgDeactivate* pMsg,
}
FX_BOOL CFWL_NoteDriver::DoSetFocus(CFWL_MsgSetFocus* pMsg,
IFWL_Widget* pMessageForm) {
- CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
+ CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr();
if (pWidgetMgr->IsFormDisabled()) {
m_pFocus = pMsg->m_pDstTarget;
return TRUE;
@@ -434,7 +431,7 @@ FX_BOOL CFWL_NoteDriver::DoSetFocus(CFWL_MsgSetFocus* pMsg,
}
FX_BOOL CFWL_NoteDriver::DoKillFocus(CFWL_MsgKillFocus* pMsg,
IFWL_Widget* pMessageForm) {
- CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
+ CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr();
if (pWidgetMgr->IsFormDisabled()) {
if (m_pFocus == pMsg->m_pDstTarget) {
m_pFocus = nullptr;
@@ -458,7 +455,7 @@ FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) {
#if (_FX_OS_ != _FX_MACOSX_)
if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown &&
pMsg->m_dwKeyCode == FWL_VKEY_Tab) {
- CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
+ CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr();
IFWL_Widget* pForm = GetMessageForm(pMsg->m_pDstTarget);
IFWL_Widget* pFocus = m_pFocus;
if (m_pFocus) {
@@ -483,7 +480,7 @@ FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) {
if (!m_pFocus) {
if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown &&
pMsg->m_dwKeyCode == FWL_VKEY_Return) {
- CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
+ CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr();
IFWL_Widget* defButton = pWidgetMgr->GetDefaultButton(pMessageForm);
if (defButton) {
pMsg->m_pDstTarget = defButton;
@@ -512,7 +509,7 @@ FX_BOOL CFWL_NoteDriver::DoMouse(CFWL_MsgMouse* pMsg,
}
FX_BOOL CFWL_NoteDriver::DoWheel(CFWL_MsgMouseWheel* pMsg,
IFWL_Widget* pMessageForm) {
- CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
+ CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr();
if (!pWidgetMgr)
return FALSE;
@@ -526,7 +523,8 @@ FX_BOOL CFWL_NoteDriver::DoWheel(CFWL_MsgMouseWheel* pMsg,
return TRUE;
}
FX_BOOL CFWL_NoteDriver::DoSize(CFWL_MsgSize* pMsg) {
- CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
+ CFWL_WidgetMgr* pWidgetMgr =
+ pMsg->m_pDstTarget->GetOwnerApp()->GetWidgetMgr();
if (!pWidgetMgr)
return FALSE;
pWidgetMgr->NotifySizeChanged(pMsg->m_pDstTarget, (FX_FLOAT)pMsg->m_iWidth,
@@ -543,7 +541,7 @@ FX_BOOL CFWL_NoteDriver::DoDragFiles(CFWL_MsgDropFiles* pMsg,
}
FX_BOOL CFWL_NoteDriver::DoMouseEx(CFWL_MsgMouse* pMsg,
IFWL_Widget* pMessageForm) {
- CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
+ CFWL_WidgetMgr* pWidgetMgr = pMessageForm->GetOwnerApp()->GetWidgetMgr();
if (!pWidgetMgr)
return FALSE;
IFWL_Widget* pTarget = nullptr;
@@ -624,7 +622,7 @@ IFWL_Widget* CFWL_NoteDriver::GetMessageForm(IFWL_Widget* pDstTarget) {
pMessageForm = pDstTarget;
}
if (!pMessageForm && pDstTarget) {
- CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
+ CFWL_WidgetMgr* pWidgetMgr = pDstTarget->GetOwnerApp()->GetWidgetMgr();
if (!pWidgetMgr)
return nullptr;
pMessageForm = pWidgetMgr->GetSystemFormWidget(pDstTarget);
diff --git a/xfa/fwl/core/fwl_noteimp.h b/xfa/fwl/core/fwl_noteimp.h
index 6e587166c0..85b44c7ed5 100644
--- a/xfa/fwl/core/fwl_noteimp.h
+++ b/xfa/fwl/core/fwl_noteimp.h
@@ -61,7 +61,6 @@ class CFWL_NoteDriver {
uint32_t dwFilter = FWL_EVENT_ALL_MASK);
FWL_Error UnregisterEventTarget(IFWL_Widget* pListener);
void ClearEventTargets(FX_BOOL bRemoveAll);
- IFWL_App* GetOwnerApp() const;
FWL_Error PushNoteLoop(CFWL_NoteLoop* pNoteLoop);
CFWL_NoteLoop* PopNoteLoop();
IFWL_Widget* GetFocus();
diff --git a/xfa/fwl/core/ifwl_app.cpp b/xfa/fwl/core/ifwl_app.cpp
index a47a76e4c0..2612088c79 100644
--- a/xfa/fwl/core/ifwl_app.cpp
+++ b/xfa/fwl/core/ifwl_app.cpp
@@ -12,39 +12,13 @@
#include "xfa/fwl/core/ifwl_widget.h"
#include "xfa/fxfa/app/xfa_fwladapter.h"
-CXFA_FWLAdapterWidgetMgr* FWL_GetAdapterWidgetMgr() {
- return CFWL_WidgetMgr::GetInstance()->GetAdapterWidgetMgr();
-}
-
-CXFA_FFApp* FWL_GetAdapterNative() {
- IFWL_App* pApp = FWL_GetApp();
- if (!pApp)
- return nullptr;
- return pApp->GetAdapterNative();
-}
-
-static IFWL_App* g_theApp = nullptr;
-IFWL_App* FWL_GetApp() {
- return g_theApp;
-}
-
-void FWL_SetApp(IFWL_App* pApp) {
- g_theApp = pApp;
-}
-
IFWL_App::IFWL_App(CXFA_FFApp* pAdapter)
: m_pAdapterNative(pAdapter),
m_pWidgetMgr(pdfium::MakeUnique<CFWL_WidgetMgr>(pAdapter)),
- m_pNoteDriver(pdfium::MakeUnique<CFWL_NoteDriver>()) {}
+ m_pNoteDriver(pdfium::MakeUnique<CFWL_NoteDriver>()) {
+ ASSERT(m_pAdapterNative);
+}
IFWL_App::~IFWL_App() {
CFWL_ToolTipContainer::DeleteInstance();
}
-
-CXFA_FFApp* IFWL_App::GetAdapterNative() {
- return m_pAdapterNative;
-}
-
-CFWL_WidgetMgr* IFWL_App::GetWidgetMgr() {
- return m_pWidgetMgr.get();
-}
diff --git a/xfa/fwl/core/ifwl_app.h b/xfa/fwl/core/ifwl_app.h
index 35cbbe2ff9..307cb0770f 100644
--- a/xfa/fwl/core/ifwl_app.h
+++ b/xfa/fwl/core/ifwl_app.h
@@ -32,8 +32,8 @@ class IFWL_App {
explicit IFWL_App(CXFA_FFApp* pAdapter);
~IFWL_App();
- CXFA_FFApp* GetAdapterNative();
- CFWL_WidgetMgr* GetWidgetMgr();
+ CXFA_FFApp* GetAdapterNative() const { return m_pAdapterNative; }
+ CFWL_WidgetMgr* GetWidgetMgr() const { return m_pWidgetMgr.get(); }
CFWL_NoteDriver* GetNoteDriver() const { return m_pNoteDriver.get(); }
private:
@@ -42,10 +42,4 @@ class IFWL_App {
std::unique_ptr<CFWL_NoteDriver> m_pNoteDriver;
};
-IFWL_App* FWL_GetApp();
-void FWL_SetApp(IFWL_App* pApp);
-
-CXFA_FFApp* FWL_GetAdapterNative();
-CXFA_FWLAdapterWidgetMgr* FWL_GetAdapterWidgetMgr();
-
#endif // XFA_FWL_CORE_IFWL_APP_H_
diff --git a/xfa/fwl/core/ifwl_barcode.cpp b/xfa/fwl/core/ifwl_barcode.cpp
index a4b210f115..779b44ab3e 100644
--- a/xfa/fwl/core/ifwl_barcode.cpp
+++ b/xfa/fwl/core/ifwl_barcode.cpp
@@ -12,8 +12,9 @@
#include "xfa/fwl/core/fwl_noteimp.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
-IFWL_Barcode::IFWL_Barcode(const CFWL_WidgetImpProperties& properties)
- : IFWL_Edit(properties, nullptr), m_dwStatus(0), m_type(BC_UNKNOWN) {}
+IFWL_Barcode::IFWL_Barcode(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties)
+ : IFWL_Edit(app, properties, nullptr), m_dwStatus(0), m_type(BC_UNKNOWN) {}
IFWL_Barcode::~IFWL_Barcode() {}
@@ -21,13 +22,11 @@ FWL_Type IFWL_Barcode::GetClassID() const {
return FWL_Type::Barcode;
}
-FWL_Error IFWL_Barcode::Initialize() {
- if (!m_pDelegate) {
+void IFWL_Barcode::Initialize() {
+ if (!m_pDelegate)
m_pDelegate = new CFWL_BarcodeImpDelegate(this);
- }
- if (IFWL_Edit::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
- return FWL_Error::Succeeded;
+
+ IFWL_Edit::Initialize();
}
void IFWL_Barcode::Finalize() {
diff --git a/xfa/fwl/core/ifwl_barcode.h b/xfa/fwl/core/ifwl_barcode.h
index 5bc800d9a1..7ca6dbeb6f 100644
--- a/xfa/fwl/core/ifwl_barcode.h
+++ b/xfa/fwl/core/ifwl_barcode.h
@@ -58,13 +58,14 @@ class IFWL_BarcodeDP : public IFWL_EditDP {
class IFWL_Barcode : public IFWL_Edit {
public:
- explicit IFWL_Barcode(const CFWL_WidgetImpProperties& properties);
+ explicit IFWL_Barcode(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties);
~IFWL_Barcode() override;
// IFWL_Widget
- FWL_Type GetClassID() const override;
- FWL_Error Initialize() override;
+ void Initialize() override;
void Finalize() override;
+ FWL_Type GetClassID() const override;
FWL_Error Update() override;
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
diff --git a/xfa/fwl/core/ifwl_caret.cpp b/xfa/fwl/core/ifwl_caret.cpp
index 52269049e2..b6f799633b 100644
--- a/xfa/fwl/core/ifwl_caret.cpp
+++ b/xfa/fwl/core/ifwl_caret.cpp
@@ -12,10 +12,11 @@
#include "xfa/fwl/core/ifwl_caret.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
-IFWL_Caret::IFWL_Caret(const CFWL_WidgetImpProperties& properties,
+IFWL_Caret::IFWL_Caret(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
- : IFWL_Widget(properties, pOuter),
- m_pTimer(new CFWL_CaretTimer(this)),
+ : IFWL_Widget(app, properties, pOuter),
+ m_pTimer(new IFWL_Caret::Timer(this)),
m_pTimerInfo(nullptr),
m_dwElapse(400),
m_bSetColor(FALSE) {
@@ -28,12 +29,9 @@ FWL_Type IFWL_Caret::GetClassID() const {
return FWL_Type::Caret;
}
-FWL_Error IFWL_Caret::Initialize() {
- if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
-
+void IFWL_Caret::Initialize() {
+ IFWL_Widget::Initialize();
m_pDelegate = new CFWL_CaretImpDelegate(this);
- return FWL_Error::Succeeded;
}
void IFWL_Caret::Finalize() {
@@ -109,17 +107,17 @@ void IFWL_Caret::DrawCaretBK(CFX_Graphics* pGraphics,
pTheme->DrawBackground(&param);
}
-IFWL_Caret::CFWL_CaretTimer::CFWL_CaretTimer(IFWL_Caret* pCaret)
- : m_pCaret(pCaret) {}
+IFWL_Caret::Timer::Timer(IFWL_Caret* pCaret) : IFWL_Timer(pCaret) {}
-void IFWL_Caret::CFWL_CaretTimer::Run(IFWL_TimerInfo* pTimerInfo) {
- bool toggle = !(m_pCaret->GetStates() & FWL_STATE_CAT_HightLight);
- m_pCaret->SetStates(FWL_STATE_CAT_HightLight, toggle);
+void IFWL_Caret::Timer::Run(IFWL_TimerInfo* pTimerInfo) {
+ IFWL_Caret* pCaret = static_cast<IFWL_Caret*>(m_pWidget);
+ bool toggle = !(pCaret->GetStates() & FWL_STATE_CAT_HightLight);
+ pCaret->SetStates(FWL_STATE_CAT_HightLight, toggle);
CFX_RectF rt;
- m_pCaret->GetWidgetRect(rt);
+ pCaret->GetWidgetRect(rt);
rt.Set(0, 0, rt.width + 1, rt.height);
- m_pCaret->Repaint(&rt);
+ pCaret->Repaint(&rt);
}
CFWL_CaretImpDelegate::CFWL_CaretImpDelegate(IFWL_Caret* pOwner)
diff --git a/xfa/fwl/core/ifwl_caret.h b/xfa/fwl/core/ifwl_caret.h
index c5b6997b45..351c8461a9 100644
--- a/xfa/fwl/core/ifwl_caret.h
+++ b/xfa/fwl/core/ifwl_caret.h
@@ -21,13 +21,15 @@ class CFWL_CaretImpDelegate;
class IFWL_Caret : public IFWL_Widget {
public:
- IFWL_Caret(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter);
+ IFWL_Caret(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter);
~IFWL_Caret() override;
// IFWL_Widget
- FWL_Type GetClassID() const override;
- FWL_Error Initialize() override;
+ void Initialize() override;
void Finalize() override;
+ FWL_Type GetClassID() const override;
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
@@ -38,21 +40,21 @@ class IFWL_Caret : public IFWL_Widget {
protected:
friend class CFWL_CaretImpDelegate;
- friend class CFWL_CaretTimer;
- class CFWL_CaretTimer : public IFWL_Timer {
+ class Timer : public IFWL_Timer {
public:
- explicit CFWL_CaretTimer(IFWL_Caret* pCaret);
- ~CFWL_CaretTimer() override {}
+ explicit Timer(IFWL_Caret* pCaret);
+ ~Timer() override {}
+
void Run(IFWL_TimerInfo* hTimer) override;
- IFWL_Caret* const m_pCaret;
};
+ friend class IFWL_Caret::Timer;
void DrawCaretBK(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix);
- std::unique_ptr<CFWL_CaretTimer> m_pTimer;
+ std::unique_ptr<IFWL_Caret::Timer> m_pTimer;
IFWL_TimerInfo* m_pTimerInfo; // not owned.
uint32_t m_dwElapse;
CFX_Color m_crFill;
diff --git a/xfa/fwl/core/ifwl_checkbox.cpp b/xfa/fwl/core/ifwl_checkbox.cpp
index 2dd8c2d5db..8af413e602 100644
--- a/xfa/fwl/core/ifwl_checkbox.cpp
+++ b/xfa/fwl/core/ifwl_checkbox.cpp
@@ -13,6 +13,7 @@
#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/ifwl_app.h"
#include "xfa/fwl/core/fwl_noteimp.h"
#include "xfa/fwl/core/ifwl_checkbox.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
@@ -23,8 +24,9 @@ const int kCaptionMargin = 5;
} // namespace
-IFWL_CheckBox::IFWL_CheckBox(const CFWL_WidgetImpProperties& properties)
- : IFWL_Widget(properties, nullptr),
+IFWL_CheckBox::IFWL_CheckBox(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties)
+ : IFWL_Widget(app, properties, nullptr),
m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
m_iTTOAlign(FDE_TTOALIGNMENT_Center),
m_bBtnDown(FALSE) {
@@ -36,16 +38,9 @@ IFWL_CheckBox::IFWL_CheckBox(const CFWL_WidgetImpProperties& properties)
IFWL_CheckBox::~IFWL_CheckBox() {}
-FWL_Type IFWL_CheckBox::GetClassID() const {
- return FWL_Type::CheckBox;
-}
-
-FWL_Error IFWL_CheckBox::Initialize() {
- if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
-
+void IFWL_CheckBox::Initialize() {
+ IFWL_Widget::Initialize();
m_pDelegate = new CFWL_CheckBoxImpDelegate(this);
- return FWL_Error::Succeeded;
}
void IFWL_CheckBox::Finalize() {
@@ -54,6 +49,10 @@ void IFWL_CheckBox::Finalize() {
IFWL_Widget::Finalize();
}
+FWL_Type IFWL_CheckBox::GetClassID() const {
+ return FWL_Type::CheckBox;
+}
+
FWL_Error IFWL_CheckBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Set(0, 0, 0, 0);
@@ -353,7 +352,7 @@ void IFWL_CheckBox::NextStates() {
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CKB_RadioButton) {
if ((m_pProperties->m_dwStates & FWL_STATE_CKB_CheckMask) ==
FWL_STATE_CKB_Unchecked) {
- CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
+ CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr();
if (!pWidgetMgr->IsFormDisabled()) {
CFX_ArrayTemplate<IFWL_Widget*> radioarr;
pWidgetMgr->GetSameGroupRadioButton(this, radioarr);
diff --git a/xfa/fwl/core/ifwl_checkbox.h b/xfa/fwl/core/ifwl_checkbox.h
index cdf1e91ca3..b290f04839 100644
--- a/xfa/fwl/core/ifwl_checkbox.h
+++ b/xfa/fwl/core/ifwl_checkbox.h
@@ -57,13 +57,14 @@ class IFWL_CheckBoxDP : public IFWL_DataProvider {
class IFWL_CheckBox : public IFWL_Widget {
public:
- explicit IFWL_CheckBox(const CFWL_WidgetImpProperties& properties);
+ explicit IFWL_CheckBox(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties);
~IFWL_CheckBox() override;
// IFWL_Widget
- FWL_Type GetClassID() const override;
- FWL_Error Initialize() override;
+ void Initialize() override;
void Finalize() override;
+ FWL_Type GetClassID() const override;
FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
FWL_Error Update() override;
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
diff --git a/xfa/fwl/core/ifwl_combobox.cpp b/xfa/fwl/core/ifwl_combobox.cpp
index edc430a0f2..dcd2cf850e 100644
--- a/xfa/fwl/core/ifwl_combobox.cpp
+++ b/xfa/fwl/core/ifwl_combobox.cpp
@@ -20,8 +20,9 @@
#include "xfa/fwl/core/ifwl_formproxy.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
-IFWL_ComboBox::IFWL_ComboBox(const CFWL_WidgetImpProperties& properties)
- : IFWL_Widget(properties, nullptr),
+IFWL_ComboBox::IFWL_ComboBox(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties)
+ : IFWL_Widget(app, properties, nullptr),
m_pForm(nullptr),
m_bLButtonDown(FALSE),
m_iCurSel(-1),
@@ -35,18 +36,16 @@ IFWL_ComboBox::IFWL_ComboBox(const CFWL_WidgetImpProperties& properties)
IFWL_ComboBox::~IFWL_ComboBox() {}
-FWL_Type IFWL_ComboBox::GetClassID() const {
- return FWL_Type::ComboBox;
-}
-
-FWL_Error IFWL_ComboBox::Initialize() {
- if (m_pWidgetMgr->IsFormDisabled())
- return DisForm_Initialize();
+void IFWL_ComboBox::Initialize() {
+ IFWL_Widget::Initialize();
+ m_pDelegate = new CFWL_ComboBoxImpDelegate(this);
- if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
+ if (m_pWidgetMgr->IsFormDisabled()) {
+ DisForm_InitComboList();
+ DisForm_InitComboEdit();
+ return;
+ }
- m_pDelegate = new CFWL_ComboBoxImpDelegate(this);
CFWL_WidgetImpProperties prop;
prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
prop.m_dwStyles |= FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll;
@@ -54,11 +53,11 @@ FWL_Error IFWL_ComboBox::Initialize() {
prop.m_dwStyleExes |= FWL_STYLEEXT_LTB_Icon;
prop.m_pDataProvider = m_pProperties->m_pDataProvider;
- m_pListBox.reset(new IFWL_ComboList(prop, this));
+ m_pListBox.reset(new IFWL_ComboList(m_pOwnerApp, prop, this));
m_pListBox->Initialize();
if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) && !m_pEdit) {
CFWL_WidgetImpProperties prop2;
- m_pEdit.reset(new IFWL_ComboEdit(prop2, this));
+ m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, prop2, this));
m_pEdit->Initialize();
m_pEdit->SetOuter(this);
}
@@ -66,7 +65,6 @@ FWL_Error IFWL_ComboBox::Initialize() {
m_pEdit->SetParent(this);
SetStates(m_pProperties->m_dwStates);
- return FWL_Error::Succeeded;
}
void IFWL_ComboBox::Finalize() {
@@ -79,6 +77,10 @@ void IFWL_ComboBox::Finalize() {
IFWL_Widget::Finalize();
}
+FWL_Type IFWL_ComboBox::GetClassID() const {
+ return FWL_Type::ComboBox;
+}
+
FWL_Error IFWL_ComboBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Reset();
@@ -113,7 +115,7 @@ FWL_Error IFWL_ComboBox::ModifyStylesEx(uint32_t dwStylesExAdded,
bool bRemoveDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown);
if (bAddDropDown && !m_pEdit) {
CFWL_WidgetImpProperties prop;
- m_pEdit.reset(new IFWL_ComboEdit(prop, nullptr));
+ m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, prop, nullptr));
m_pEdit->Initialize();
m_pEdit->SetOuter(this);
m_pEdit->SetParent(this);
@@ -712,23 +714,13 @@ void IFWL_ComboBox::InitProxyForm() {
propForm.m_dwStyles = FWL_WGTSTYLE_Popup;
propForm.m_dwStates = FWL_WGTSTATE_Invisible;
- m_pForm = new IFWL_FormProxy(propForm, m_pListBox.get());
+ m_pForm = new IFWL_FormProxy(m_pOwnerApp, propForm, m_pListBox.get());
m_pForm->Initialize();
m_pListBox->SetParent(m_pForm);
m_pListProxyDelegate = new CFWL_ComboProxyImpDelegate(m_pForm, this);
m_pForm->SetDelegate(m_pListProxyDelegate);
}
-FWL_Error IFWL_ComboBox::DisForm_Initialize() {
- if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
-
- m_pDelegate = new CFWL_ComboBoxImpDelegate(this);
- DisForm_InitComboList();
- DisForm_InitComboEdit();
- return FWL_Error::Succeeded;
-}
-
void IFWL_ComboBox::DisForm_InitComboList() {
if (m_pListBox)
return;
@@ -739,18 +731,18 @@ void IFWL_ComboBox::DisForm_InitComboList() {
prop.m_dwStates = FWL_WGTSTATE_Invisible;
prop.m_pDataProvider = m_pProperties->m_pDataProvider;
prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
- m_pListBox.reset(new IFWL_ComboList(prop, this));
+ m_pListBox.reset(new IFWL_ComboList(m_pOwnerApp, prop, this));
m_pListBox->Initialize();
}
void IFWL_ComboBox::DisForm_InitComboEdit() {
- if (m_pEdit) {
+ if (m_pEdit)
return;
- }
+
CFWL_WidgetImpProperties prop;
prop.m_pParent = this;
prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
- m_pEdit.reset(new IFWL_ComboEdit(prop, this));
+ m_pEdit.reset(new IFWL_ComboEdit(m_pOwnerApp, prop, this));
m_pEdit->Initialize();
m_pEdit->SetOuter(this);
}
@@ -807,9 +799,9 @@ FX_BOOL IFWL_ComboBox::DisForm_IsDropListShowed() {
FWL_Error IFWL_ComboBox::DisForm_ModifyStylesEx(uint32_t dwStylesExAdded,
uint32_t dwStylesExRemoved) {
- if (!m_pEdit) {
+ if (!m_pEdit)
DisForm_InitComboEdit();
- }
+
bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown);
bool bDelDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown);
dwStylesExRemoved &= ~FWL_STYLEEXT_CMB_DropDown;
@@ -1376,7 +1368,7 @@ void CFWL_ComboProxyImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
}
void CFWL_ComboProxyImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
- IFWL_App* pApp = m_pForm->GetOwnerApp();
+ const IFWL_App* pApp = m_pForm->GetOwnerApp();
if (!pApp)
return;
@@ -1397,7 +1389,7 @@ void CFWL_ComboProxyImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
void CFWL_ComboProxyImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
m_bLButtonDown = FALSE;
- IFWL_App* pApp = m_pForm->GetOwnerApp();
+ const IFWL_App* pApp = m_pForm->GetOwnerApp();
if (!pApp)
return;
diff --git a/xfa/fwl/core/ifwl_combobox.h b/xfa/fwl/core/ifwl_combobox.h
index 15db0490ee..268a4b516b 100644
--- a/xfa/fwl/core/ifwl_combobox.h
+++ b/xfa/fwl/core/ifwl_combobox.h
@@ -84,13 +84,14 @@ class IFWL_ComboBoxDP : public IFWL_ListBoxDP {
class IFWL_ComboBox : public IFWL_Widget {
public:
- explicit IFWL_ComboBox(const CFWL_WidgetImpProperties& properties);
+ explicit IFWL_ComboBox(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties);
~IFWL_ComboBox() override;
// IFWL_Widget
- FWL_Type GetClassID() const override;
- FWL_Error Initialize() override;
+ void Initialize() override;
void Finalize() override;
+ FWL_Type GetClassID() const override;
FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
FWL_Error ModifyStylesEx(uint32_t dwStylesExAdded,
uint32_t dwStylesExRemoved) override;
@@ -156,7 +157,6 @@ class IFWL_ComboBox : public IFWL_Widget {
void ReSetListItemAlignment();
void ProcessSelChanged(FX_BOOL bLButtonUp);
void InitProxyForm();
- FWL_Error DisForm_Initialize();
void DisForm_InitComboList();
void DisForm_InitComboEdit();
void DisForm_ShowDropList(FX_BOOL bActivate);
diff --git a/xfa/fwl/core/ifwl_comboedit.cpp b/xfa/fwl/core/ifwl_comboedit.cpp
index 62b2d5a1de..fc28536d50 100644
--- a/xfa/fwl/core/ifwl_comboedit.cpp
+++ b/xfa/fwl/core/ifwl_comboedit.cpp
@@ -9,9 +9,10 @@
#include "xfa/fde/cfde_txtedtengine.h"
#include "xfa/fwl/core/ifwl_combobox.h"
-IFWL_ComboEdit::IFWL_ComboEdit(const CFWL_WidgetImpProperties& properties,
+IFWL_ComboEdit::IFWL_ComboEdit(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
- : IFWL_Edit(properties, pOuter) {
+ : IFWL_Edit(app, properties, pOuter) {
m_pOuter = static_cast<IFWL_ComboBox*>(pOuter);
}
diff --git a/xfa/fwl/core/ifwl_comboedit.h b/xfa/fwl/core/ifwl_comboedit.h
index fceba2f528..f4a529a186 100644
--- a/xfa/fwl/core/ifwl_comboedit.h
+++ b/xfa/fwl/core/ifwl_comboedit.h
@@ -15,7 +15,8 @@ class IFWL_ComboBox;
class IFWL_ComboEdit : public IFWL_Edit {
public:
- IFWL_ComboEdit(const CFWL_WidgetImpProperties& properties,
+ IFWL_ComboEdit(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
void ClearSelected();
diff --git a/xfa/fwl/core/ifwl_combolist.cpp b/xfa/fwl/core/ifwl_combolist.cpp
index d34a55bcc2..6538bff20d 100644
--- a/xfa/fwl/core/ifwl_combolist.cpp
+++ b/xfa/fwl/core/ifwl_combolist.cpp
@@ -9,18 +9,19 @@
#include "xfa/fwl/core/ifwl_combobox.h"
#include "xfa/fwl/core/ifwl_comboedit.h"
-IFWL_ComboList::IFWL_ComboList(const CFWL_WidgetImpProperties& properties,
+IFWL_ComboList::IFWL_ComboList(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
- : IFWL_ListBox(properties, pOuter), m_bNotifyOwner(TRUE) {
+ : IFWL_ListBox(app, properties, pOuter), m_bNotifyOwner(TRUE) {
ASSERT(pOuter);
}
-FWL_Error IFWL_ComboList::Initialize() {
- if (IFWL_ListBox::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
+void IFWL_ComboList::Initialize() {
+ IFWL_ListBox::Initialize();
+
+ // Delete the delegate that was created by IFWL_ListBox::Initialize ...
delete m_pDelegate;
m_pDelegate = new CFWL_ComboListImpDelegate(this);
- return FWL_Error::Succeeded;
}
void IFWL_ComboList::Finalize() {
diff --git a/xfa/fwl/core/ifwl_combolist.h b/xfa/fwl/core/ifwl_combolist.h
index d88a5956c2..eaa03e36d4 100644
--- a/xfa/fwl/core/ifwl_combolist.h
+++ b/xfa/fwl/core/ifwl_combolist.h
@@ -13,11 +13,12 @@
class IFWL_ComboList : public IFWL_ListBox {
public:
- IFWL_ComboList(const CFWL_WidgetImpProperties& properties,
+ IFWL_ComboList(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
// IFWL_Widget
- FWL_Error Initialize() override;
+ void Initialize() override;
void Finalize() override;
int32_t MatchItem(const CFX_WideString& wsMatch);
diff --git a/xfa/fwl/core/ifwl_dataprovider.h b/xfa/fwl/core/ifwl_dataprovider.h
index 9a3634c40e..53c6ec4055 100644
--- a/xfa/fwl/core/ifwl_dataprovider.h
+++ b/xfa/fwl/core/ifwl_dataprovider.h
@@ -15,6 +15,7 @@ class IFWL_Widget;
class IFWL_DataProvider {
public:
virtual ~IFWL_DataProvider() {}
+
virtual FWL_Error GetCaption(IFWL_Widget* pWidget,
CFX_WideString& wsCaption) = 0;
};
diff --git a/xfa/fwl/core/ifwl_datetimecalendar.cpp b/xfa/fwl/core/ifwl_datetimecalendar.cpp
index 0e095b9424..e85bdfb606 100644
--- a/xfa/fwl/core/ifwl_datetimecalendar.cpp
+++ b/xfa/fwl/core/ifwl_datetimecalendar.cpp
@@ -11,16 +11,17 @@
#include "xfa/fwl/core/ifwl_formproxy.h"
IFWL_DateTimeCalendar::IFWL_DateTimeCalendar(
+ const IFWL_App* app,
const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
- : IFWL_MonthCalendar(properties, pOuter) {}
+ : IFWL_MonthCalendar(app, properties, pOuter) {}
-FWL_Error IFWL_DateTimeCalendar::Initialize() {
- if (IFWL_MonthCalendar::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
+void IFWL_DateTimeCalendar::Initialize() {
+ IFWL_MonthCalendar::Initialize();
+
+ // Delete delegated set by IFWL_MonthCalendar::Initialize.
delete m_pDelegate;
m_pDelegate = new CFWL_DateTimeCalendarImpDelegate(this);
- return FWL_Error::Succeeded;
}
void IFWL_DateTimeCalendar::Finalize() {
diff --git a/xfa/fwl/core/ifwl_datetimecalendar.h b/xfa/fwl/core/ifwl_datetimecalendar.h
index c106e7f86d..3d856fd578 100644
--- a/xfa/fwl/core/ifwl_datetimecalendar.h
+++ b/xfa/fwl/core/ifwl_datetimecalendar.h
@@ -11,11 +11,12 @@
class IFWL_DateTimeCalendar : public IFWL_MonthCalendar {
public:
- IFWL_DateTimeCalendar(const CFWL_WidgetImpProperties& properties,
+ IFWL_DateTimeCalendar(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
// IFWL_MonthCalendar
- FWL_Error Initialize() override;
+ void Initialize() override;
void Finalize() override;
protected:
diff --git a/xfa/fwl/core/ifwl_datetimeedit.cpp b/xfa/fwl/core/ifwl_datetimeedit.cpp
index 0097691c42..9d0a08bed6 100644
--- a/xfa/fwl/core/ifwl_datetimeedit.cpp
+++ b/xfa/fwl/core/ifwl_datetimeedit.cpp
@@ -9,15 +9,17 @@
#include "xfa/fwl/core/cfwl_widgetmgr.h"
#include "xfa/fwl/core/ifwl_datetimepicker.h"
-IFWL_DateTimeEdit::IFWL_DateTimeEdit(const CFWL_WidgetImpProperties& properties,
+IFWL_DateTimeEdit::IFWL_DateTimeEdit(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
- : IFWL_Edit(properties, pOuter) {}
+ : IFWL_Edit(app, properties, pOuter) {}
-FWL_Error IFWL_DateTimeEdit::Initialize() {
+void IFWL_DateTimeEdit::Initialize() {
+ IFWL_Edit::Initialize();
+
+ // Delete delegate set by IFWL_Edit::Initialize.
+ delete m_pDelegate;
m_pDelegate = new CFWL_DateTimeEditImpDelegate(this);
- if (IFWL_Edit::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
- return FWL_Error::Succeeded;
}
void IFWL_DateTimeEdit::Finalize() {
diff --git a/xfa/fwl/core/ifwl_datetimeedit.h b/xfa/fwl/core/ifwl_datetimeedit.h
index 2429e98a4c..cbb118329a 100644
--- a/xfa/fwl/core/ifwl_datetimeedit.h
+++ b/xfa/fwl/core/ifwl_datetimeedit.h
@@ -15,11 +15,12 @@
class IFWL_DateTimeEdit : public IFWL_Edit {
public:
- IFWL_DateTimeEdit(const CFWL_WidgetImpProperties& properties,
+ IFWL_DateTimeEdit(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
// IFWL_Edit
- FWL_Error Initialize() override;
+ void Initialize() override;
void Finalize() override;
protected:
diff --git a/xfa/fwl/core/ifwl_datetimepicker.cpp b/xfa/fwl/core/ifwl_datetimepicker.cpp
index ef13d71cf1..9292a5acfa 100644
--- a/xfa/fwl/core/ifwl_datetimepicker.cpp
+++ b/xfa/fwl/core/ifwl_datetimepicker.cpp
@@ -24,8 +24,9 @@ const int kDateTimePickerHeight = 20;
} // namespace
IFWL_DateTimePicker::IFWL_DateTimePicker(
+ const IFWL_App* app,
const CFWL_WidgetImpProperties& properties)
- : IFWL_Widget(properties, nullptr),
+ : IFWL_Widget(app, properties, nullptr),
m_iBtnState(1),
m_iYear(-1),
m_iMonth(-1),
@@ -36,15 +37,11 @@ IFWL_DateTimePicker::IFWL_DateTimePicker(
IFWL_DateTimePicker::~IFWL_DateTimePicker() {}
-FWL_Type IFWL_DateTimePicker::GetClassID() const {
- return FWL_Type::DateTimePicker;
-}
-
-FWL_Error IFWL_DateTimePicker::Initialize() {
- if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
+void IFWL_DateTimePicker::Initialize() {
+ IFWL_Widget::Initialize();
m_pDelegate = new CFWL_DateTimePickerImpDelegate(this);
+
m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat;
CFWL_WidgetImpProperties propMonth;
propMonth.m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border;
@@ -53,7 +50,7 @@ FWL_Error IFWL_DateTimePicker::Initialize() {
propMonth.m_pParent = this;
propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider;
- m_pMonthCal.reset(new IFWL_DateTimeCalendar(propMonth, this));
+ m_pMonthCal.reset(new IFWL_DateTimeCalendar(m_pOwnerApp, propMonth, this));
m_pMonthCal->Initialize();
CFX_RectF rtMonthCal;
m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
@@ -63,11 +60,10 @@ FWL_Error IFWL_DateTimePicker::Initialize() {
propEdit.m_pParent = this;
propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider;
- m_pEdit.reset(new IFWL_DateTimeEdit(propEdit, this));
+ m_pEdit.reset(new IFWL_DateTimeEdit(m_pOwnerApp, propEdit, this));
m_pEdit->Initialize();
RegisterEventTarget(m_pMonthCal.get());
RegisterEventTarget(m_pEdit.get());
- return FWL_Error::Succeeded;
}
void IFWL_DateTimePicker::Finalize() {
@@ -84,6 +80,10 @@ void IFWL_DateTimePicker::Finalize() {
IFWL_Widget::Finalize();
}
+FWL_Type IFWL_DateTimePicker::GetClassID() const {
+ return FWL_Type::DateTimePicker;
+}
+
FWL_Error IFWL_DateTimePicker::GetWidgetRect(CFX_RectF& rect,
FX_BOOL bAutoSize) {
if (m_pWidgetMgr->IsFormDisabled()) {
@@ -328,7 +328,7 @@ void IFWL_DateTimePicker::DrawDropDownButton(CFX_Graphics* pGraphics,
prop.m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert;
prop.m_pParent = this;
prop.m_rtWidget = m_rtBtn;
- IFWL_SpinButton* pSpin = new IFWL_SpinButton(prop);
+ IFWL_SpinButton* pSpin = new IFWL_SpinButton(m_pOwnerApp, prop);
pSpin->Initialize();
} else {
CFWL_ThemeBackground param;
@@ -463,7 +463,7 @@ void IFWL_DateTimePicker::InitProxyForm() {
propForm.m_dwStates = FWL_WGTSTATE_Invisible;
propForm.m_pOwner = this;
- m_pForm.reset(new IFWL_FormProxy(propForm, m_pMonthCal.get()));
+ m_pForm.reset(new IFWL_FormProxy(m_pOwnerApp, propForm, m_pMonthCal.get()));
m_pForm->Initialize();
m_pMonthCal->SetParent(m_pForm.get());
}
@@ -493,7 +493,7 @@ void IFWL_DateTimePicker::DisForm_InitDateTimeCalendar() {
propMonth.m_pDataProvider = &m_MonthCalendarDP;
propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider;
- m_pMonthCal.reset(new IFWL_DateTimeCalendar(propMonth, this));
+ m_pMonthCal.reset(new IFWL_DateTimeCalendar(m_pOwnerApp, propMonth, this));
m_pMonthCal->Initialize();
CFX_RectF rtMonthCal;
m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE);
@@ -509,7 +509,7 @@ void IFWL_DateTimePicker::DisForm_InitDateTimeEdit() {
propEdit.m_pParent = this;
propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider;
- m_pEdit.reset(new IFWL_DateTimeEdit(propEdit, this));
+ m_pEdit.reset(new IFWL_DateTimeEdit(m_pOwnerApp, propEdit, this));
m_pEdit->Initialize();
}
diff --git a/xfa/fwl/core/ifwl_datetimepicker.h b/xfa/fwl/core/ifwl_datetimepicker.h
index 4113e9b83e..476eb09b3c 100644
--- a/xfa/fwl/core/ifwl_datetimepicker.h
+++ b/xfa/fwl/core/ifwl_datetimepicker.h
@@ -62,13 +62,14 @@ class IFWL_DateTimePickerDP : public IFWL_DataProvider {
class IFWL_DateTimePicker : public IFWL_Widget {
public:
- explicit IFWL_DateTimePicker(const CFWL_WidgetImpProperties& properties);
+ explicit IFWL_DateTimePicker(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties);
~IFWL_DateTimePicker() override;
// IFWL_Widget
- FWL_Type GetClassID() const override;
- FWL_Error Initialize() override;
+ void Initialize() override;
void Finalize() override;
+ FWL_Type GetClassID() const override;
FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
FWL_Error Update() override;
FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override;
diff --git a/xfa/fwl/core/ifwl_edit.cpp b/xfa/fwl/core/ifwl_edit.cpp
index e911aa0c8b..b826bd2f02 100644
--- a/xfa/fwl/core/ifwl_edit.cpp
+++ b/xfa/fwl/core/ifwl_edit.cpp
@@ -51,9 +51,10 @@ void AddSquigglyPath(CFX_Path* pPathData,
} // namespace
-IFWL_Edit::IFWL_Edit(const CFWL_WidgetImpProperties& properties,
+IFWL_Edit::IFWL_Edit(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
- : IFWL_Widget(properties, pOuter),
+ : IFWL_Widget(app, properties, pOuter),
m_fVAlignOffset(0.0f),
m_fScrollOffsetX(0.0f),
m_fScrollOffsetY(0.0f),
@@ -79,21 +80,14 @@ IFWL_Edit::~IFWL_Edit() {
ClearRecord();
}
-FWL_Type IFWL_Edit::GetClassID() const {
- return FWL_Type::Edit;
-}
-
-FWL_Error IFWL_Edit::Initialize() {
- if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
+void IFWL_Edit::Initialize() {
+ IFWL_Widget::Initialize();
if (!m_pDelegate)
m_pDelegate = new CFWL_EditImpDelegate(this);
InitCaret();
if (!m_pEdtEngine)
InitEngine();
-
- return FWL_Error::Succeeded;
}
void IFWL_Edit::Finalize() {
@@ -109,6 +103,10 @@ void IFWL_Edit::Finalize() {
IFWL_Widget::Finalize();
}
+FWL_Type IFWL_Edit::GetClassID() const {
+ return FWL_Type::Edit;
+}
+
FWL_Error IFWL_Edit::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Set(0, 0, 0, 0);
@@ -1474,7 +1472,7 @@ void IFWL_Edit::InitScrollBar(FX_BOOL bVert) {
prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible;
prop.m_pParent = this;
prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
- IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar(prop, this);
+ IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar(m_pOwnerApp, prop, this);
pScrollBar->Initialize();
(bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar);
}
@@ -1572,7 +1570,7 @@ void IFWL_Edit::InitCaret() {
if (!m_pCaret) {
if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) {
CFWL_WidgetImpProperties prop;
- m_pCaret.reset(new IFWL_Caret(prop, this));
+ m_pCaret.reset(new IFWL_Caret(m_pOwnerApp, prop, this));
m_pCaret->Initialize();
m_pCaret->SetParent(this);
m_pCaret->SetStates(m_pProperties->m_dwStates);
diff --git a/xfa/fwl/core/ifwl_edit.h b/xfa/fwl/core/ifwl_edit.h
index 7c0c451cf9..a03431b6ee 100644
--- a/xfa/fwl/core/ifwl_edit.h
+++ b/xfa/fwl/core/ifwl_edit.h
@@ -106,13 +106,15 @@ class IFWL_EditDP : public IFWL_DataProvider {};
class IFWL_Edit : public IFWL_Widget {
public:
- IFWL_Edit(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter);
+ IFWL_Edit(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter);
~IFWL_Edit() override;
// IFWL_Widget:
- FWL_Type GetClassID() const override;
- FWL_Error Initialize() override;
+ void Initialize() override;
void Finalize() override;
+ FWL_Type GetClassID() const override;
FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
FWL_Error SetWidgetRect(const CFX_RectF& rect) override;
FWL_Error Update() override;
diff --git a/xfa/fwl/core/ifwl_form.cpp b/xfa/fwl/core/ifwl_form.cpp
index 5aaa566ff4..e46328b634 100644
--- a/xfa/fwl/core/ifwl_form.cpp
+++ b/xfa/fwl/core/ifwl_form.cpp
@@ -36,9 +36,10 @@ RestoreInfo::RestoreInfo() {}
RestoreInfo::~RestoreInfo() {}
-IFWL_Form::IFWL_Form(const CFWL_WidgetImpProperties& properties,
+IFWL_Form::IFWL_Form(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
- : IFWL_Widget(properties, pOuter),
+ : IFWL_Widget(app, properties, pOuter),
m_pCloseBox(nullptr),
m_pMinBox(nullptr),
m_pMaxBox(nullptr),
@@ -69,23 +70,12 @@ IFWL_Form::~IFWL_Form() {
RemoveSysButtons();
}
-FWL_Type IFWL_Form::GetClassID() const {
- return FWL_Type::Form;
-}
+void IFWL_Form::Initialize() {
+ IFWL_Widget::Initialize();
-FX_BOOL IFWL_Form::IsInstance(const CFX_WideStringC& wsClass) const {
- if (wsClass == CFX_WideStringC(FWL_CLASS_Form))
- return TRUE;
- return IFWL_Widget::IsInstance(wsClass);
-}
-
-FWL_Error IFWL_Form::Initialize() {
- if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
RegisterForm();
RegisterEventTarget();
m_pDelegate = new CFWL_FormImpDelegate(this);
- return FWL_Error::Succeeded;
}
void IFWL_Form::Finalize() {
@@ -96,6 +86,16 @@ void IFWL_Form::Finalize() {
IFWL_Widget::Finalize();
}
+FWL_Type IFWL_Form::GetClassID() const {
+ return FWL_Type::Form;
+}
+
+FX_BOOL IFWL_Form::IsInstance(const CFX_WideStringC& wsClass) const {
+ if (wsClass == CFX_WideStringC(FWL_CLASS_Form))
+ return TRUE;
+ return IFWL_Widget::IsInstance(wsClass);
+}
+
FWL_Error IFWL_Form::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Reset();
@@ -118,7 +118,7 @@ FWL_Error IFWL_Form::GetClientRect(CFX_RectF& rect) {
}
#ifdef FWL_UseMacSystemBorder
rect = m_rtRelative;
- CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
+ CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr();
if (!pWidgetMgr)
return FWL_Error::Indefinite;
@@ -345,7 +345,7 @@ FWL_Error IFWL_Form::SetFormSize(FWL_FORMSIZE eFormSize) {
}
IFWL_Widget* IFWL_Form::DoModal() {
- IFWL_App* pApp = GetOwnerApp();
+ const IFWL_App* pApp = GetOwnerApp();
if (!pApp)
return nullptr;
@@ -376,7 +376,7 @@ FWL_Error IFWL_Form::EndDoModal() {
m_bDoModalFlag = FALSE;
#if (_FX_OS_ == _FX_MACOSX_)
m_pNoteLoop->EndModalLoop();
- IFWL_App* pApp = GetOwnerApp();
+ const IFWL_App* pApp = GetOwnerApp();
if (!pApp)
return FWL_Error::Indefinite;
@@ -416,7 +416,7 @@ void IFWL_Form::SetSubFocus(IFWL_Widget* pWidget) {
}
void IFWL_Form::ShowChildWidget(IFWL_Widget* pParent) {
- IFWL_App* pApp = FWL_GetApp();
+ const IFWL_App* pApp = pParent->GetOwnerApp();
if (!pApp)
return;
@@ -588,7 +588,7 @@ void IFWL_Form::GetEdgeRect(CFX_RectF& rtEdge) {
}
void IFWL_Form::SetWorkAreaRect() {
m_rtRestore = m_pProperties->m_rtWidget;
- CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
+ CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr();
if (!pWidgetMgr)
return;
m_bSetMaximize = TRUE;
@@ -669,7 +669,7 @@ void IFWL_Form::ReSetSysBtn() {
}
}
void IFWL_Form::RegisterForm() {
- IFWL_App* pApp = GetOwnerApp();
+ const IFWL_App* pApp = GetOwnerApp();
if (!pApp)
return;
@@ -681,7 +681,7 @@ void IFWL_Form::RegisterForm() {
pDriver->RegisterForm(this);
}
void IFWL_Form::UnRegisterForm() {
- IFWL_App* pApp = GetOwnerApp();
+ const IFWL_App* pApp = GetOwnerApp();
if (!pApp)
return;
@@ -707,7 +707,7 @@ FX_BOOL IFWL_Form::HasIcon() {
return !!pData->GetIcon(this, FALSE);
}
void IFWL_Form::UpdateIcon() {
- CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
+ CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr();
if (!pWidgetMgr)
return;
IFWL_FormDP* pData =
@@ -720,7 +720,7 @@ void IFWL_Form::UpdateIcon() {
m_pSmallIcon = pSmallIcon;
}
void IFWL_Form::UpdateCaption() {
- CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
+ CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr();
if (!pWidgetMgr)
return;
IFWL_DataProvider* pData = m_pProperties->m_pDataProvider;
@@ -810,7 +810,7 @@ void CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
switch (pMessage->GetClassID()) {
case CFWL_MessageType::Activate: {
m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
- IFWL_App* pApp = m_pOwner->GetOwnerApp();
+ const IFWL_App* pApp = m_pOwner->GetOwnerApp();
CFWL_NoteDriver* pDriver =
static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
IFWL_Widget* pSubFocus = m_pOwner->GetSubFocus();
@@ -822,7 +822,7 @@ void CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
}
case CFWL_MessageType::Deactivate: {
m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated;
- IFWL_App* pApp = m_pOwner->GetOwnerApp();
+ const IFWL_App* pApp = m_pOwner->GetOwnerApp();
CFWL_NoteDriver* pDriver =
static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
IFWL_Widget* pSubFocus = m_pOwner->GetSubFocus();
@@ -872,7 +872,7 @@ void CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
break;
}
case CFWL_MessageType::Size: {
- CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
+ CFWL_WidgetMgr* pWidgetMgr = m_pOwner->GetOwnerApp()->GetWidgetMgr();
if (!pWidgetMgr)
return;
diff --git a/xfa/fwl/core/ifwl_form.h b/xfa/fwl/core/ifwl_form.h
index ee1f360629..4203177d11 100644
--- a/xfa/fwl/core/ifwl_form.h
+++ b/xfa/fwl/core/ifwl_form.h
@@ -85,15 +85,16 @@ class IFWL_FormDP : public IFWL_DataProvider {
class IFWL_Form : public IFWL_Widget {
public:
- IFWL_Form(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter);
+ IFWL_Form(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter);
~IFWL_Form() override;
// IFWL_Widget
+ void Initialize() override;
+ void Finalize() override;
FWL_Type GetClassID() const override;
FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const override;
- FWL_Error Initialize() override;
- void Finalize() override;
-
FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
FWL_Error GetClientRect(CFX_RectF& rect) override;
FWL_Error Update() override;
diff --git a/xfa/fwl/core/ifwl_formproxy.cpp b/xfa/fwl/core/ifwl_formproxy.cpp
index 9a00bf3e8f..16cd90813d 100644
--- a/xfa/fwl/core/ifwl_formproxy.cpp
+++ b/xfa/fwl/core/ifwl_formproxy.cpp
@@ -8,12 +8,24 @@
#include "xfa/fwl/core/fwl_noteimp.h"
-IFWL_FormProxy::IFWL_FormProxy(const CFWL_WidgetImpProperties& properties,
+IFWL_FormProxy::IFWL_FormProxy(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
- : IFWL_Form(properties, pOuter) {}
+ : IFWL_Form(app, properties, pOuter) {}
IFWL_FormProxy::~IFWL_FormProxy() {}
+void IFWL_FormProxy::Initialize() {
+ IFWL_Widget::Initialize();
+ m_pDelegate = new CFWL_FormProxyImpDelegate(this);
+}
+
+void IFWL_FormProxy::Finalize() {
+ delete m_pDelegate;
+ m_pDelegate = nullptr;
+ IFWL_Widget::Finalize();
+}
+
FWL_Type IFWL_FormProxy::GetClassID() const {
return FWL_Type::FormProxy;
}
@@ -25,19 +37,6 @@ FX_BOOL IFWL_FormProxy::IsInstance(const CFX_WideStringC& wsClass) const {
return IFWL_Form::IsInstance(wsClass);
}
-FWL_Error IFWL_FormProxy::Initialize() {
- if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
- m_pDelegate = new CFWL_FormProxyImpDelegate(this);
- return FWL_Error::Succeeded;
-}
-
-void IFWL_FormProxy::Finalize() {
- delete m_pDelegate;
- m_pDelegate = nullptr;
- IFWL_Widget::Finalize();
-}
-
FWL_Error IFWL_FormProxy::Update() {
return FWL_Error::Succeeded;
}
diff --git a/xfa/fwl/core/ifwl_formproxy.h b/xfa/fwl/core/ifwl_formproxy.h
index 3bc614c4d4..15288ce62f 100644
--- a/xfa/fwl/core/ifwl_formproxy.h
+++ b/xfa/fwl/core/ifwl_formproxy.h
@@ -14,15 +14,16 @@ class CFWL_FormProxyImpDelegate;
class IFWL_FormProxy : public IFWL_Form {
public:
- IFWL_FormProxy(const CFWL_WidgetImpProperties& properties,
+ IFWL_FormProxy(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
~IFWL_FormProxy() override;
// IFWL_Widget
+ void Initialize() override;
+ void Finalize() override;
FWL_Type GetClassID() const override;
FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const override;
- FWL_Error Initialize() override;
- void Finalize() override;
FWL_Error Update() override;
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
diff --git a/xfa/fwl/core/ifwl_listbox.cpp b/xfa/fwl/core/ifwl_listbox.cpp
index bb6d86d384..05cc64bb90 100644
--- a/xfa/fwl/core/ifwl_listbox.cpp
+++ b/xfa/fwl/core/ifwl_listbox.cpp
@@ -20,9 +20,10 @@ const int kItemTextMargin = 2;
} // namespace
-IFWL_ListBox::IFWL_ListBox(const CFWL_WidgetImpProperties& properties,
+IFWL_ListBox::IFWL_ListBox(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
- : IFWL_Widget(properties, pOuter),
+ : IFWL_Widget(app, properties, pOuter),
m_dwTTOStyles(0),
m_iTTOAligns(0),
m_hAnchor(nullptr),
@@ -36,16 +37,9 @@ IFWL_ListBox::IFWL_ListBox(const CFWL_WidgetImpProperties& properties,
IFWL_ListBox::~IFWL_ListBox() {}
-FWL_Type IFWL_ListBox::GetClassID() const {
- return FWL_Type::ListBox;
-}
-
-FWL_Error IFWL_ListBox::Initialize() {
- if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
-
+void IFWL_ListBox::Initialize() {
+ IFWL_Widget::Initialize();
m_pDelegate = new CFWL_ListBoxImpDelegate(this);
- return FWL_Error::Succeeded;
}
void IFWL_ListBox::Finalize() {
@@ -59,6 +53,10 @@ void IFWL_ListBox::Finalize() {
IFWL_Widget::Finalize();
}
+FWL_Type IFWL_ListBox::GetClassID() const {
+ return FWL_Type::ListBox;
+}
+
FWL_Error IFWL_ListBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Set(0, 0, 0, 0);
@@ -898,7 +896,7 @@ void IFWL_ListBox::InitScrollBar(FX_BOOL bVert) {
prop.m_dwStates = FWL_WGTSTATE_Invisible;
prop.m_pParent = this;
prop.m_pThemeProvider = m_pScrollBarTP;
- IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar(prop, this);
+ IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar(m_pOwnerApp, prop, this);
pScrollBar->Initialize();
(bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar);
}
diff --git a/xfa/fwl/core/ifwl_listbox.h b/xfa/fwl/core/ifwl_listbox.h
index 036aee2d62..a5efceb5b0 100644
--- a/xfa/fwl/core/ifwl_listbox.h
+++ b/xfa/fwl/core/ifwl_listbox.h
@@ -102,13 +102,15 @@ class IFWL_ListBoxCompare {
class IFWL_ListBox : public IFWL_Widget {
public:
- IFWL_ListBox(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter);
+ IFWL_ListBox(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter);
~IFWL_ListBox() override;
// IFWL_Widget
- FWL_Type GetClassID() const override;
- FWL_Error Initialize() override;
+ void Initialize() override;
void Finalize() override;
+ FWL_Type GetClassID() const override;
FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
FWL_Error Update() override;
FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override;
diff --git a/xfa/fwl/core/ifwl_monthcalendar.cpp b/xfa/fwl/core/ifwl_monthcalendar.cpp
index 69e7588245..43e90a23a5 100644
--- a/xfa/fwl/core/ifwl_monthcalendar.cpp
+++ b/xfa/fwl/core/ifwl_monthcalendar.cpp
@@ -118,9 +118,10 @@ CFX_WideString* GetCapacityForMonth(IFWL_ThemeProvider* pTheme,
} // namespace
IFWL_MonthCalendar::IFWL_MonthCalendar(
+ const IFWL_App* app,
const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
- : IFWL_Widget(properties, pOuter),
+ : IFWL_Widget(app, properties, pOuter),
m_bInit(FALSE),
m_pDateTime(new CFX_DateTime),
m_iCurYear(2011),
@@ -151,16 +152,9 @@ IFWL_MonthCalendar::~IFWL_MonthCalendar() {
m_arrSelDays.RemoveAll();
}
-FWL_Type IFWL_MonthCalendar::GetClassID() const {
- return FWL_Type::MonthCalendar;
-}
-
-FWL_Error IFWL_MonthCalendar::Initialize() {
- if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
-
+void IFWL_MonthCalendar::Initialize() {
+ IFWL_Widget::Initialize();
m_pDelegate = new CFWL_MonthCalendarImpDelegate(this);
- return FWL_Error::Succeeded;
}
void IFWL_MonthCalendar::Finalize() {
@@ -169,6 +163,10 @@ void IFWL_MonthCalendar::Finalize() {
IFWL_Widget::Finalize();
}
+FWL_Type IFWL_MonthCalendar::GetClassID() const {
+ return FWL_Type::MonthCalendar;
+}
+
FWL_Error IFWL_MonthCalendar::GetWidgetRect(CFX_RectF& rect,
FX_BOOL bAutoSize) {
if (bAutoSize) {
diff --git a/xfa/fwl/core/ifwl_monthcalendar.h b/xfa/fwl/core/ifwl_monthcalendar.h
index b9376b82c3..793eaa8eea 100644
--- a/xfa/fwl/core/ifwl_monthcalendar.h
+++ b/xfa/fwl/core/ifwl_monthcalendar.h
@@ -52,14 +52,15 @@ class IFWL_MonthCalendarDP : public IFWL_DataProvider {
class IFWL_MonthCalendar : public IFWL_Widget {
public:
- IFWL_MonthCalendar(const CFWL_WidgetImpProperties& properties,
+ IFWL_MonthCalendar(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
~IFWL_MonthCalendar() override;
// FWL_WidgetImp
- FWL_Type GetClassID() const override;
- FWL_Error Initialize() override;
+ void Initialize() override;
void Finalize() override;
+ FWL_Type GetClassID() const override;
FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
FWL_Error Update() override;
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
diff --git a/xfa/fwl/core/ifwl_picturebox.cpp b/xfa/fwl/core/ifwl_picturebox.cpp
index 9e0e0b8623..20ab54a37c 100644
--- a/xfa/fwl/core/ifwl_picturebox.cpp
+++ b/xfa/fwl/core/ifwl_picturebox.cpp
@@ -9,8 +9,9 @@
#include "xfa/fwl/core/cfwl_picturebox.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-IFWL_PictureBox::IFWL_PictureBox(const CFWL_WidgetImpProperties& properties)
- : IFWL_Widget(properties, nullptr),
+IFWL_PictureBox::IFWL_PictureBox(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties)
+ : IFWL_Widget(app, properties, nullptr),
m_bTop(FALSE),
m_bVCenter(FALSE),
m_bButton(FALSE) {
@@ -21,16 +22,9 @@ IFWL_PictureBox::IFWL_PictureBox(const CFWL_WidgetImpProperties& properties)
IFWL_PictureBox::~IFWL_PictureBox() {}
-FWL_Type IFWL_PictureBox::GetClassID() const {
- return FWL_Type::PictureBox;
-}
-
-FWL_Error IFWL_PictureBox::Initialize() {
- if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
-
+void IFWL_PictureBox::Initialize() {
+ IFWL_Widget::Initialize();
m_pDelegate = new CFWL_PictureBoxImpDelegate(this);
- return FWL_Error::Succeeded;
}
void IFWL_PictureBox::Finalize() {
@@ -39,6 +33,10 @@ void IFWL_PictureBox::Finalize() {
IFWL_Widget::Finalize();
}
+FWL_Type IFWL_PictureBox::GetClassID() const {
+ return FWL_Type::PictureBox;
+}
+
FWL_Error IFWL_PictureBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Set(0, 0, 0, 0);
diff --git a/xfa/fwl/core/ifwl_picturebox.h b/xfa/fwl/core/ifwl_picturebox.h
index 434b3cff29..24c6e7edfd 100644
--- a/xfa/fwl/core/ifwl_picturebox.h
+++ b/xfa/fwl/core/ifwl_picturebox.h
@@ -44,13 +44,14 @@ class IFWL_PictureBoxDP : public IFWL_DataProvider {
class IFWL_PictureBox : public IFWL_Widget {
public:
- explicit IFWL_PictureBox(const CFWL_WidgetImpProperties& properties);
+ explicit IFWL_PictureBox(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties);
~IFWL_PictureBox() override;
// IFWL_Widget
- FWL_Type GetClassID() const override;
- FWL_Error Initialize() override;
+ void Initialize() override;
void Finalize() override;
+ FWL_Type GetClassID() const override;
FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
FWL_Error Update() override;
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
diff --git a/xfa/fwl/core/ifwl_pushbutton.cpp b/xfa/fwl/core/ifwl_pushbutton.cpp
index 6040ae1117..b9d11d9e5a 100644
--- a/xfa/fwl/core/ifwl_pushbutton.cpp
+++ b/xfa/fwl/core/ifwl_pushbutton.cpp
@@ -14,8 +14,9 @@
#include "xfa/fwl/core/ifwl_pushbutton.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
-IFWL_PushButton::IFWL_PushButton(const CFWL_WidgetImpProperties& properties)
- : IFWL_Widget(properties, nullptr),
+IFWL_PushButton::IFWL_PushButton(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties)
+ : IFWL_Widget(app, properties, nullptr),
m_bBtnDown(FALSE),
m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
m_iTTOAlign(FDE_TTOALIGNMENT_Center) {
@@ -25,16 +26,9 @@ IFWL_PushButton::IFWL_PushButton(const CFWL_WidgetImpProperties& properties)
IFWL_PushButton::~IFWL_PushButton() {}
-FWL_Type IFWL_PushButton::GetClassID() const {
- return FWL_Type::PushButton;
-}
-
-FWL_Error IFWL_PushButton::Initialize() {
- if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
-
+void IFWL_PushButton::Initialize() {
+ IFWL_Widget::Initialize();
m_pDelegate = new CFWL_PushButtonImpDelegate(this);
- return FWL_Error::Succeeded;
}
void IFWL_PushButton::Finalize() {
@@ -43,6 +37,10 @@ void IFWL_PushButton::Finalize() {
IFWL_Widget::Finalize();
}
+FWL_Type IFWL_PushButton::GetClassID() const {
+ return FWL_Type::PushButton;
+}
+
FWL_Error IFWL_PushButton::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Set(0, 0, 0, 0);
diff --git a/xfa/fwl/core/ifwl_pushbutton.h b/xfa/fwl/core/ifwl_pushbutton.h
index 8906aa898f..6a4d28ddba 100644
--- a/xfa/fwl/core/ifwl_pushbutton.h
+++ b/xfa/fwl/core/ifwl_pushbutton.h
@@ -40,13 +40,14 @@ class IFWL_PushButtonDP : public IFWL_DataProvider {
class IFWL_PushButton : public IFWL_Widget {
public:
- IFWL_PushButton(const CFWL_WidgetImpProperties& properties);
+ IFWL_PushButton(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties);
~IFWL_PushButton() override;
// IFWL_Widget
- FWL_Type GetClassID() const override;
- FWL_Error Initialize() override;
+ void Initialize() override;
void Finalize() override;
+ FWL_Type GetClassID() const override;
FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE) override;
FWL_Error Update() override;
diff --git a/xfa/fwl/core/ifwl_scrollbar.cpp b/xfa/fwl/core/ifwl_scrollbar.cpp
index a8e277324f..27a131f45d 100644
--- a/xfa/fwl/core/ifwl_scrollbar.cpp
+++ b/xfa/fwl/core/ifwl_scrollbar.cpp
@@ -16,9 +16,10 @@
#define FWL_SCROLLBAR_Elapse 500
#define FWL_SCROLLBAR_MinThumb 5
-IFWL_ScrollBar::IFWL_ScrollBar(const CFWL_WidgetImpProperties& properties,
+IFWL_ScrollBar::IFWL_ScrollBar(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
- : IFWL_Widget(properties, pOuter),
+ : IFWL_Widget(app, properties, pOuter),
m_pTimerInfo(nullptr),
m_fRangeMin(0),
m_fRangeMax(-1),
@@ -42,7 +43,8 @@ IFWL_ScrollBar::IFWL_ScrollBar(const CFWL_WidgetImpProperties& properties,
m_fButtonLen(0),
m_bMinSize(FALSE),
m_bCustomLayout(false),
- m_fMinThumb(FWL_SCROLLBAR_MinThumb) {
+ m_fMinThumb(FWL_SCROLLBAR_MinThumb),
+ m_Timer(this) {
m_rtClient.Reset();
m_rtThumb.Reset();
m_rtMinBtn.Reset();
@@ -53,16 +55,9 @@ IFWL_ScrollBar::IFWL_ScrollBar(const CFWL_WidgetImpProperties& properties,
IFWL_ScrollBar::~IFWL_ScrollBar() {}
-FWL_Type IFWL_ScrollBar::GetClassID() const {
- return FWL_Type::ScrollBar;
-}
-
-FWL_Error IFWL_ScrollBar::Initialize() {
- if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
-
+void IFWL_ScrollBar::Initialize() {
+ IFWL_Widget::Initialize();
m_pDelegate = new CFWL_ScrollBarImpDelegate(this);
- return FWL_Error::Succeeded;
}
void IFWL_ScrollBar::Finalize() {
@@ -71,6 +66,10 @@ void IFWL_ScrollBar::Finalize() {
IFWL_Widget::Finalize();
}
+FWL_Type IFWL_ScrollBar::GetClassID() const {
+ return FWL_Type::ScrollBar;
+}
+
FWL_Error IFWL_ScrollBar::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Set(0, 0, 0, 0);
@@ -196,14 +195,6 @@ FX_BOOL IFWL_ScrollBar::DoScroll(uint32_t dwCode, FX_FLOAT fPos) {
return OnScroll(dwCode, fPos);
}
-void IFWL_ScrollBar::Run(IFWL_TimerInfo* pTimerInfo) {
- if (m_pTimerInfo)
- m_pTimerInfo->StopTimer();
-
- if (!SendEvent())
- m_pTimerInfo = StartTimer(0, true);
-}
-
FWL_Error IFWL_ScrollBar::SetOuter(IFWL_Widget* pOuter) {
m_pOuter = pOuter;
return FWL_Error::Succeeded;
@@ -660,7 +651,8 @@ void CFWL_ScrollBarImpDelegate::OnLButtonDown(uint32_t dwFlags,
}
}
if (!m_pOwner->SendEvent())
- m_pOwner->m_pTimerInfo = m_pOwner->StartTimer(FWL_SCROLLBAR_Elapse, true);
+ m_pOwner->m_pTimerInfo =
+ m_pOwner->m_Timer.StartTimer(FWL_SCROLLBAR_Elapse, true);
}
void CFWL_ScrollBarImpDelegate::OnLButtonUp(uint32_t dwFlags,
@@ -774,3 +766,15 @@ void CFWL_ScrollBarImpDelegate::DoMouseHover(int32_t iItem,
iState = CFWL_PartState_Hovered;
m_pOwner->Repaint(&rtItem);
}
+
+IFWL_ScrollBar::Timer::Timer(IFWL_ScrollBar* pToolTip) : IFWL_Timer(pToolTip) {}
+
+void IFWL_ScrollBar::Timer::Run(IFWL_TimerInfo* pTimerInfo) {
+ IFWL_ScrollBar* pButton = static_cast<IFWL_ScrollBar*>(m_pWidget);
+
+ if (pButton->m_pTimerInfo)
+ pButton->m_pTimerInfo->StopTimer();
+
+ if (!pButton->SendEvent())
+ pButton->m_pTimerInfo = StartTimer(0, true);
+}
diff --git a/xfa/fwl/core/ifwl_scrollbar.h b/xfa/fwl/core/ifwl_scrollbar.h
index 95fe7739fe..346649c11d 100644
--- a/xfa/fwl/core/ifwl_scrollbar.h
+++ b/xfa/fwl/core/ifwl_scrollbar.h
@@ -36,24 +36,22 @@ enum FWL_SCBCODE {
class IFWL_ScrollBarDP : public IFWL_DataProvider {};
-class IFWL_ScrollBar : public IFWL_Widget, public IFWL_Timer {
+class IFWL_ScrollBar : public IFWL_Widget {
public:
- IFWL_ScrollBar(const CFWL_WidgetImpProperties& properties,
+ IFWL_ScrollBar(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
~IFWL_ScrollBar() override;
// IFWL_Widget
- FWL_Type GetClassID() const override;
- FWL_Error Initialize() override;
+ void Initialize() override;
void Finalize() override;
+ FWL_Type GetClassID() const override;
FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
FWL_Error Update() override;
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
- // IFWL_Timer
- void Run(IFWL_TimerInfo* pTimerInfo) override;
-
FX_BOOL IsVertical();
FWL_Error GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax);
FWL_Error SetRange(FX_FLOAT fMin, FX_FLOAT fMax);
@@ -71,6 +69,16 @@ class IFWL_ScrollBar : public IFWL_Widget, public IFWL_Timer {
protected:
friend class CFWL_ScrollBarImpDelegate;
+ class Timer : public IFWL_Timer {
+ public:
+ explicit Timer(IFWL_ScrollBar* pToolTip);
+ ~Timer() override {}
+
+ void Run(IFWL_TimerInfo* pTimerInfo) override;
+ };
+ friend class IFWL_ScrollBar::Timer;
+
+ IFWL_ScrollBar();
void DrawTrack(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme,
FX_BOOL bLower = TRUE,
@@ -124,9 +132,7 @@ class IFWL_ScrollBar : public IFWL_Widget, public IFWL_Timer {
CFX_RectF m_rtMaxTrack;
bool m_bCustomLayout;
FX_FLOAT m_fMinThumb;
-
- protected:
- IFWL_ScrollBar();
+ IFWL_ScrollBar::Timer m_Timer;
};
class CFWL_ScrollBarImpDelegate : public CFWL_WidgetImpDelegate {
diff --git a/xfa/fwl/core/ifwl_spinbutton.cpp b/xfa/fwl/core/ifwl_spinbutton.cpp
index d94a240e59..992ea7358c 100644
--- a/xfa/fwl/core/ifwl_spinbutton.cpp
+++ b/xfa/fwl/core/ifwl_spinbutton.cpp
@@ -23,13 +23,15 @@ const int kElapseTime = 200;
} // namespace
-IFWL_SpinButton::IFWL_SpinButton(const CFWL_WidgetImpProperties& properties)
- : IFWL_Widget(properties, nullptr),
+IFWL_SpinButton::IFWL_SpinButton(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties)
+ : IFWL_Widget(app, properties, nullptr),
m_dwUpState(CFWL_PartState_Normal),
m_dwDnState(CFWL_PartState_Normal),
m_iButtonIndex(0),
m_bLButtonDwn(FALSE),
- m_pTimerInfo(nullptr) {
+ m_pTimerInfo(nullptr),
+ m_Timer(this) {
m_rtClient.Reset();
m_rtUpButton.Reset();
m_rtDnButton.Reset();
@@ -38,16 +40,9 @@ IFWL_SpinButton::IFWL_SpinButton(const CFWL_WidgetImpProperties& properties)
IFWL_SpinButton::~IFWL_SpinButton() {}
-FWL_Type IFWL_SpinButton::GetClassID() const {
- return FWL_Type::SpinButton;
-}
-
-FWL_Error IFWL_SpinButton::Initialize() {
- if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
-
+void IFWL_SpinButton::Initialize() {
+ IFWL_Widget::Initialize();
m_pDelegate = new CFWL_SpinButtonImpDelegate(this);
- return FWL_Error::Succeeded;
}
void IFWL_SpinButton::Finalize() {
@@ -56,6 +51,10 @@ void IFWL_SpinButton::Finalize() {
IFWL_Widget::Finalize();
}
+FWL_Type IFWL_SpinButton::GetClassID() const {
+ return FWL_Type::SpinButton;
+}
+
FWL_Error IFWL_SpinButton::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Set(0, 0, kMinWidth, kMinHeight);
@@ -123,16 +122,6 @@ FWL_Error IFWL_SpinButton::DrawWidget(CFX_Graphics* pGraphics,
return FWL_Error::Succeeded;
}
-void IFWL_SpinButton::Run(IFWL_TimerInfo* pTimerInfo) {
- if (!m_pTimerInfo)
- return;
-
- CFWL_EvtSpbClick wmPosChanged;
- wmPosChanged.m_pSrcTarget = this;
- wmPosChanged.m_bUp = m_iButtonIndex == 0;
- DispatchEvent(&wmPosChanged);
-}
-
FWL_Error IFWL_SpinButton::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) {
if (bUp) {
if (bEnable) {
@@ -283,7 +272,7 @@ void CFWL_SpinButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
m_pOwner->DispatchEvent(&wmPosChanged);
m_pOwner->Repaint(bUpPress ? &m_pOwner->m_rtUpButton
: &m_pOwner->m_rtDnButton);
- m_pOwner->m_pTimerInfo = m_pOwner->StartTimer(kElapseTime, true);
+ m_pOwner->m_pTimerInfo = m_pOwner->m_Timer.StartTimer(kElapseTime, true);
}
void CFWL_SpinButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
@@ -421,3 +410,18 @@ void CFWL_SpinButtonImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
m_pOwner->Repaint(bUpEnable ? &m_pOwner->m_rtUpButton
: &m_pOwner->m_rtDnButton);
}
+
+IFWL_SpinButton::Timer::Timer(IFWL_SpinButton* pToolTip)
+ : IFWL_Timer(pToolTip) {}
+
+void IFWL_SpinButton::Timer::Run(IFWL_TimerInfo* pTimerInfo) {
+ IFWL_SpinButton* pButton = static_cast<IFWL_SpinButton*>(m_pWidget);
+
+ if (!pButton->m_pTimerInfo)
+ return;
+
+ CFWL_EvtSpbClick wmPosChanged;
+ wmPosChanged.m_pSrcTarget = pButton;
+ wmPosChanged.m_bUp = pButton->m_iButtonIndex == 0;
+ pButton->DispatchEvent(&wmPosChanged);
+}
diff --git a/xfa/fwl/core/ifwl_spinbutton.h b/xfa/fwl/core/ifwl_spinbutton.h
index e5e6211917..ad03098dc6 100644
--- a/xfa/fwl/core/ifwl_spinbutton.h
+++ b/xfa/fwl/core/ifwl_spinbutton.h
@@ -20,30 +20,37 @@ class CFWL_WidgetImpProperties;
FWL_EVENT_DEF(CFWL_EvtSpbClick, CFWL_EventType::Click, FX_BOOL m_bUp;)
-class IFWL_SpinButton : public IFWL_Widget, public IFWL_Timer {
+class IFWL_SpinButton : public IFWL_Widget {
public:
- explicit IFWL_SpinButton(const CFWL_WidgetImpProperties& properties);
+ explicit IFWL_SpinButton(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties);
~IFWL_SpinButton() override;
// IFWL_Widget
- FWL_Type GetClassID() const override;
- FWL_Error Initialize() override;
+ void Initialize() override;
void Finalize() override;
+ FWL_Type GetClassID() const override;
FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
FWL_Error Update() override;
FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override;
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
- // IFWL_Timer
- void Run(IFWL_TimerInfo* pTimerInfo) override;
-
FWL_Error EnableButton(FX_BOOL bEnable, FX_BOOL bUp = TRUE);
FX_BOOL IsButtonEnable(FX_BOOL bUp = TRUE);
protected:
friend class CFWL_SpinButtonImpDelegate;
+ class Timer : public IFWL_Timer {
+ public:
+ explicit Timer(IFWL_SpinButton* pToolTip);
+ ~Timer() override {}
+
+ void Run(IFWL_TimerInfo* pTimerInfo) override;
+ };
+ friend class IFWL_SpinButton::Timer;
+
void DrawUpButton(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix);
@@ -59,6 +66,7 @@ class IFWL_SpinButton : public IFWL_Widget, public IFWL_Timer {
int32_t m_iButtonIndex;
FX_BOOL m_bLButtonDwn;
IFWL_TimerInfo* m_pTimerInfo;
+ IFWL_SpinButton::Timer m_Timer;
};
class CFWL_SpinButtonImpDelegate : public CFWL_WidgetImpDelegate {
diff --git a/xfa/fwl/core/ifwl_themeprovider.h b/xfa/fwl/core/ifwl_themeprovider.h
index d64b6f038d..166d8a72ca 100644
--- a/xfa/fwl/core/ifwl_themeprovider.h
+++ b/xfa/fwl/core/ifwl_themeprovider.h
@@ -20,6 +20,7 @@ class IFWL_Widget;
class IFWL_ThemeProvider {
public:
virtual ~IFWL_ThemeProvider() {}
+
virtual void DrawBackground(CFWL_ThemeBackground* pParams) = 0;
virtual void DrawText(CFWL_ThemeText* pParams) = 0;
virtual void* GetCapacity(CFWL_ThemePart* pThemePart,
diff --git a/xfa/fwl/core/ifwl_timer.cpp b/xfa/fwl/core/ifwl_timer.cpp
index 941113e7ca..3f81eec476 100644
--- a/xfa/fwl/core/ifwl_timer.cpp
+++ b/xfa/fwl/core/ifwl_timer.cpp
@@ -7,10 +7,15 @@
#include "xfa/fwl/core/ifwl_adaptertimermgr.h"
#include "xfa/fwl/core/ifwl_app.h"
#include "xfa/fwl/core/ifwl_timer.h"
+#include "xfa/fwl/core/ifwl_widget.h"
#include "xfa/fxfa/xfa_ffapp.h"
IFWL_TimerInfo* IFWL_Timer::StartTimer(uint32_t dwElapse, bool bImmediately) {
- CXFA_FFApp* pAdapterNative = FWL_GetAdapterNative();
+ const IFWL_App* pApp = m_pWidget->GetOwnerApp();
+ if (!pApp)
+ return nullptr;
+
+ CXFA_FFApp* pAdapterNative = pApp->GetAdapterNative();
if (!pAdapterNative)
return nullptr;
@@ -24,13 +29,5 @@ IFWL_TimerInfo* IFWL_Timer::StartTimer(uint32_t dwElapse, bool bImmediately) {
}
FWL_Error IFWL_TimerInfo::StopTimer() {
- CXFA_FFApp* pAdapterNative = FWL_GetAdapterNative();
- if (!pAdapterNative)
- return FWL_Error::Indefinite;
-
- IFWL_AdapterTimerMgr* pAdapterTimerMgr = pAdapterNative->GetTimerMgr();
- if (!pAdapterTimerMgr)
- return FWL_Error::Indefinite;
-
- return pAdapterTimerMgr->Stop(this);
+ return m_pMgr->Stop(this);
}
diff --git a/xfa/fwl/core/ifwl_timer.h b/xfa/fwl/core/ifwl_timer.h
index 9c1c56dd73..7562085060 100644
--- a/xfa/fwl/core/ifwl_timer.h
+++ b/xfa/fwl/core/ifwl_timer.h
@@ -10,19 +10,33 @@
#include "core/fxcrt/fx_system.h"
#include "xfa/fwl/core/fwl_error.h"
+class IFWL_AdapterTimerMgr;
class IFWL_TimerInfo;
+class IFWL_Widget;
class IFWL_Timer {
public:
+ explicit IFWL_Timer(IFWL_Widget* parent) : m_pWidget(parent) {}
virtual ~IFWL_Timer() {}
+
virtual void Run(IFWL_TimerInfo* hTimer) = 0;
IFWL_TimerInfo* StartTimer(uint32_t dwElapse, bool bImmediately);
+
+ protected:
+ IFWL_Widget* m_pWidget; // Not owned.
};
class IFWL_TimerInfo {
public:
+ explicit IFWL_TimerInfo(IFWL_AdapterTimerMgr* mgr) : m_pMgr(mgr) {
+ ASSERT(mgr);
+ }
virtual ~IFWL_TimerInfo() {}
+
FWL_Error StopTimer();
+
+ protected:
+ IFWL_AdapterTimerMgr* m_pMgr; // Not owned.
};
#endif // XFA_FWL_CORE_IFWL_TIMER_H_
diff --git a/xfa/fwl/core/ifwl_tooltip.cpp b/xfa/fwl/core/ifwl_tooltip.cpp
index a9b9085010..815670ed75 100644
--- a/xfa/fwl/core/ifwl_tooltip.cpp
+++ b/xfa/fwl/core/ifwl_tooltip.cpp
@@ -15,35 +15,31 @@
#include "xfa/fwl/core/ifwl_tooltip.h"
#include "xfa/fwl/theme/cfwl_widgettp.h"
-IFWL_ToolTip::IFWL_ToolTip(const CFWL_WidgetImpProperties& properties,
+IFWL_ToolTip::IFWL_ToolTip(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
- : IFWL_Form(properties, pOuter),
+ : IFWL_Form(app, properties, pOuter),
m_bBtnDown(FALSE),
m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
m_iTTOAlign(FDE_TTOALIGNMENT_Center),
m_pTimerInfoShow(nullptr),
- m_pTimerInfoHide(nullptr) {
+ m_pTimerInfoHide(nullptr),
+ m_TimerShow(this),
+ m_TimerHide(this) {
m_rtClient.Set(0, 0, 0, 0);
m_rtCaption.Set(0, 0, 0, 0);
m_rtAnchor.Set(0, 0, 0, 0);
- m_TimerShow.m_pToolTip = this;
- m_TimerHide.m_pToolTip = this;
}
IFWL_ToolTip::~IFWL_ToolTip() {}
-FWL_Type IFWL_ToolTip::GetClassID() const {
- return FWL_Type::ToolTip;
-}
+void IFWL_ToolTip::Initialize() {
+ IFWL_Widget::Initialize();
-FWL_Error IFWL_ToolTip::Initialize() {
m_pProperties->m_dwStyles |= FWL_WGTSTYLE_Popup;
m_pProperties->m_dwStyles &= ~FWL_WGTSTYLE_Child;
- if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
- return FWL_Error::Indefinite;
m_pDelegate = new CFWL_ToolTipImpDelegate(this);
- return FWL_Error::Succeeded;
}
void IFWL_ToolTip::Finalize() {
@@ -52,6 +48,10 @@ void IFWL_ToolTip::Finalize() {
IFWL_Widget::Finalize();
}
+FWL_Type IFWL_ToolTip::GetClassID() const {
+ return FWL_Type::ToolTip;
+}
+
FWL_Error IFWL_ToolTip::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
if (bAutoSize) {
rect.Set(0, 0, 0, 0);
@@ -238,25 +238,24 @@ void IFWL_ToolTip::RefreshToolTipPos() {
}
}
-IFWL_ToolTip::CFWL_ToolTipTimer::CFWL_ToolTipTimer(IFWL_ToolTip* pToolTip)
- : m_pToolTip(pToolTip) {}
+IFWL_ToolTip::Timer::Timer(IFWL_ToolTip* pToolTip) : IFWL_Timer(pToolTip) {}
+
+void IFWL_ToolTip::Timer::Run(IFWL_TimerInfo* pTimerInfo) {
+ IFWL_ToolTip* pToolTip = static_cast<IFWL_ToolTip*>(m_pWidget);
-void IFWL_ToolTip::CFWL_ToolTipTimer::Run(IFWL_TimerInfo* pTimerInfo) {
- if (m_pToolTip->m_pTimerInfoShow == pTimerInfo &&
- m_pToolTip->m_pTimerInfoShow) {
- if (m_pToolTip->GetStates() & FWL_WGTSTATE_Invisible) {
- m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, FALSE);
- m_pToolTip->RefreshToolTipPos();
- m_pToolTip->m_pTimerInfoShow->StopTimer();
- m_pToolTip->m_pTimerInfoShow = nullptr;
+ if (pToolTip->m_pTimerInfoShow == pTimerInfo && pToolTip->m_pTimerInfoShow) {
+ if (pToolTip->GetStates() & FWL_WGTSTATE_Invisible) {
+ pToolTip->SetStates(FWL_WGTSTATE_Invisible, FALSE);
+ pToolTip->RefreshToolTipPos();
+ pToolTip->m_pTimerInfoShow->StopTimer();
+ pToolTip->m_pTimerInfoShow = nullptr;
return;
}
}
- if (m_pToolTip->m_pTimerInfoHide == pTimerInfo &&
- m_pToolTip->m_pTimerInfoHide) {
- m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, TRUE);
- m_pToolTip->m_pTimerInfoHide->StopTimer();
- m_pToolTip->m_pTimerInfoHide = nullptr;
+ if (pToolTip->m_pTimerInfoHide == pTimerInfo && pToolTip->m_pTimerInfoHide) {
+ pToolTip->SetStates(FWL_WGTSTATE_Invisible, TRUE);
+ pToolTip->m_pTimerInfoHide->StopTimer();
+ pToolTip->m_pTimerInfoHide = nullptr;
}
}
diff --git a/xfa/fwl/core/ifwl_tooltip.h b/xfa/fwl/core/ifwl_tooltip.h
index 4aed7d8f7f..fcf1637714 100644
--- a/xfa/fwl/core/ifwl_tooltip.h
+++ b/xfa/fwl/core/ifwl_tooltip.h
@@ -34,13 +34,15 @@ class IFWL_ToolTipDP : public IFWL_DataProvider {
class IFWL_ToolTip : public IFWL_Form {
public:
- IFWL_ToolTip(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter);
+ IFWL_ToolTip(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter);
~IFWL_ToolTip() override;
// IFWL_Widget
- FWL_Type GetClassID() const override;
- FWL_Error Initialize() override;
+ void Initialize() override;
void Finalize() override;
+ FWL_Type GetClassID() const override;
FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
FWL_Error Update() override;
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
@@ -54,18 +56,15 @@ class IFWL_ToolTip : public IFWL_Form {
protected:
friend class CFWL_ToolTipImpDelegate;
- friend class CFWL_ToolTipTimer;
- class CFWL_ToolTipTimer : public IFWL_Timer {
+ class Timer : public IFWL_Timer {
public:
- CFWL_ToolTipTimer() {}
- explicit CFWL_ToolTipTimer(IFWL_ToolTip* pToolTip);
- ~CFWL_ToolTipTimer() override {}
+ explicit Timer(IFWL_ToolTip* pToolTip);
+ ~Timer() override {}
void Run(IFWL_TimerInfo* pTimerInfo) override;
-
- IFWL_ToolTip* m_pToolTip;
};
+ friend class IFWL_ToolTip::Timer;
void DrawBkground(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme,
@@ -84,8 +83,8 @@ class IFWL_ToolTip : public IFWL_Form {
CFX_RectF m_rtAnchor;
IFWL_TimerInfo* m_pTimerInfoShow;
IFWL_TimerInfo* m_pTimerInfoHide;
- CFWL_ToolTipTimer m_TimerShow;
- CFWL_ToolTipTimer m_TimerHide;
+ IFWL_ToolTip::Timer m_TimerShow;
+ IFWL_ToolTip::Timer m_TimerHide;
};
class CFWL_ToolTipImpDelegate : public CFWL_WidgetImpDelegate {
diff --git a/xfa/fwl/core/ifwl_widget.cpp b/xfa/fwl/core/ifwl_widget.cpp
index 5ec738f8cc..eb8b1281e9 100644
--- a/xfa/fwl/core/ifwl_widget.cpp
+++ b/xfa/fwl/core/ifwl_widget.cpp
@@ -24,9 +24,11 @@
#define FWL_STYLEEXT_MNU_Vert (1L << 0)
-IFWL_Widget::IFWL_Widget(const CFWL_WidgetImpProperties& properties,
+IFWL_Widget::IFWL_Widget(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
- : m_pWidgetMgr(CFWL_WidgetMgr::GetInstance()),
+ : m_pOwnerApp(app),
+ m_pWidgetMgr(app->GetWidgetMgr()),
m_pProperties(new CFWL_WidgetImpProperties(properties)),
m_pDelegate(nullptr),
m_pCurDelegate(nullptr),
@@ -40,17 +42,7 @@ IFWL_Widget::IFWL_Widget(const CFWL_WidgetImpProperties& properties,
IFWL_Widget::~IFWL_Widget() {}
-FWL_Error IFWL_Widget::Initialize() {
- IFWL_App* pApp = FWL_GetApp();
- if (!pApp)
- return FWL_Error::Indefinite;
-
- CXFA_FFApp* pAdapter = pApp->GetAdapterNative();
- if (!pAdapter)
- return FWL_Error::Indefinite;
-
- SetOwnerApp(FWL_GetApp());
-
+void IFWL_Widget::Initialize() {
IFWL_Widget* pParent = m_pProperties->m_pParent;
m_pWidgetMgr->InsertWidget(pParent, this);
if (!IsChild()) {
@@ -58,7 +50,6 @@ FWL_Error IFWL_Widget::Initialize() {
if (pOwner)
m_pWidgetMgr->SetOwner(pOwner, this);
}
- return FWL_Error::Succeeded;
}
void IFWL_Widget::Finalize() {
@@ -198,7 +189,7 @@ void IFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) {
CFWL_NoteDriver* noteDriver =
static_cast<CFWL_NoteDriver*>(GetOwnerApp()->GetNoteDriver());
- CFWL_WidgetMgr* widgetMgr = CFWL_WidgetMgr::GetInstance();
+ CFWL_WidgetMgr* widgetMgr = GetOwnerApp()->GetWidgetMgr();
noteDriver->NotifyTargetHide(this);
IFWL_Widget* child = widgetMgr->GetFirstChildWidget(this);
while (child) {
@@ -374,15 +365,10 @@ IFWL_WidgetDelegate* IFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) {
return pOldDelegate;
}
-IFWL_App* IFWL_Widget::GetOwnerApp() const {
+const IFWL_App* IFWL_Widget::GetOwnerApp() const {
return m_pOwnerApp;
}
-FWL_Error IFWL_Widget::SetOwnerApp(IFWL_App* pOwnerApp) {
- m_pOwnerApp = pOwnerApp;
- return FWL_Error::Succeeded;
-}
-
uint32_t IFWL_Widget::GetEventKey() const {
return m_nEventKey;
}
@@ -570,7 +556,7 @@ void IFWL_Widget::SetFocus(FX_BOOL bFocus) {
if (m_pWidgetMgr->IsFormDisabled())
return;
- IFWL_App* pApp = GetOwnerApp();
+ const IFWL_App* pApp = GetOwnerApp();
if (!pApp)
return;
@@ -588,7 +574,7 @@ void IFWL_Widget::SetFocus(FX_BOOL bFocus) {
}
void IFWL_Widget::SetGrab(FX_BOOL bSet) {
- IFWL_App* pApp = GetOwnerApp();
+ const IFWL_App* pApp = GetOwnerApp();
if (!pApp)
return;
CFWL_NoteDriver* pDriver =
@@ -704,7 +690,7 @@ FX_BOOL IFWL_Widget::GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy) {
void IFWL_Widget::RegisterEventTarget(IFWL_Widget* pEventSource,
uint32_t dwFilter) {
- IFWL_App* pApp = GetOwnerApp();
+ const IFWL_App* pApp = GetOwnerApp();
if (!pApp)
return;
@@ -716,7 +702,7 @@ void IFWL_Widget::RegisterEventTarget(IFWL_Widget* pEventSource,
}
void IFWL_Widget::UnregisterEventTarget() {
- IFWL_App* pApp = GetOwnerApp();
+ const IFWL_App* pApp = GetOwnerApp();
if (!pApp)
return;
@@ -745,7 +731,7 @@ void IFWL_Widget::DispatchEvent(CFWL_Event* pEvent) {
pDelegate->OnProcessEvent(pEvent);
return;
}
- IFWL_App* pApp = GetOwnerApp();
+ const IFWL_App* pApp = GetOwnerApp();
if (!pApp)
return;
CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver();
@@ -817,7 +803,7 @@ void IFWL_Widget::DrawEdge(CFX_Graphics* pGraphics,
}
void IFWL_Widget::NotifyDriver() {
- IFWL_App* pApp = GetOwnerApp();
+ const IFWL_App* pApp = GetOwnerApp();
if (!pApp)
return;
@@ -833,7 +819,7 @@ CFX_SizeF IFWL_Widget::GetOffsetFromParent(IFWL_Widget* pParent) {
if (pParent == this)
return CFX_SizeF();
- CFWL_WidgetMgr* pWidgetMgr = CFWL_WidgetMgr::GetInstance();
+ CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr();
if (!pWidgetMgr)
return CFX_SizeF();
diff --git a/xfa/fwl/core/ifwl_widget.h b/xfa/fwl/core/ifwl_widget.h
index 6cb241d363..38a8d337f6 100644
--- a/xfa/fwl/core/ifwl_widget.h
+++ b/xfa/fwl/core/ifwl_widget.h
@@ -66,7 +66,7 @@ class IFWL_Widget {
public:
virtual ~IFWL_Widget();
- virtual FWL_Error Initialize();
+ virtual void Initialize();
virtual void Finalize();
virtual FWL_Type GetClassID() const = 0;
virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
@@ -114,9 +114,9 @@ class IFWL_Widget {
virtual IFWL_ThemeProvider* GetThemeProvider();
virtual FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
virtual IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate);
- virtual IFWL_App* GetOwnerApp() const;
- FWL_Error SetOwnerApp(IFWL_App* pOwnerApp);
+ const IFWL_App* GetOwnerApp() const;
+
CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent);
uint32_t GetEventKey() const;
@@ -130,7 +130,9 @@ class IFWL_Widget {
protected:
friend class CFWL_WidgetImpDelegate;
- IFWL_Widget(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter);
+ IFWL_Widget(const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter);
FX_BOOL IsEnabled() const;
FX_BOOL IsVisible() const;
@@ -199,8 +201,8 @@ class IFWL_Widget {
FX_BOOL IsParent(IFWL_Widget* pParent);
+ const IFWL_App* const m_pOwnerApp;
CFWL_WidgetMgr* const m_pWidgetMgr;
- IFWL_App* m_pOwnerApp;
std::unique_ptr<CFWL_WidgetImpProperties> m_pProperties;
IFWL_WidgetDelegate* m_pDelegate;
IFWL_WidgetDelegate* m_pCurDelegate;
diff --git a/xfa/fwl/core/ifwl_widgetdelegate.h b/xfa/fwl/core/ifwl_widgetdelegate.h
index 820fb6b1c4..b013375da8 100644
--- a/xfa/fwl/core/ifwl_widgetdelegate.h
+++ b/xfa/fwl/core/ifwl_widgetdelegate.h
@@ -19,6 +19,7 @@ class CFX_Matrix;
class IFWL_WidgetDelegate {
public:
virtual ~IFWL_WidgetDelegate() {}
+
virtual void OnProcessMessage(CFWL_Message* pMessage) = 0;
virtual void OnProcessEvent(CFWL_Event* pEvent) = 0;
virtual void OnDrawWidget(CFX_Graphics* pGraphics,