summaryrefslogtreecommitdiff
path: root/xfa/fwl/core
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fwl/core')
-rw-r--r--xfa/fwl/core/cfwl_barcode.cpp111
-rw-r--r--xfa/fwl/core/cfwl_barcode.h128
-rw-r--r--xfa/fwl/core/cfwl_checkbox.cpp72
-rw-r--r--xfa/fwl/core/cfwl_checkbox.h46
-rw-r--r--xfa/fwl/core/cfwl_combobox.cpp388
-rw-r--r--xfa/fwl/core/cfwl_combobox.h148
-rw-r--r--xfa/fwl/core/cfwl_datetimepicker.cpp169
-rw-r--r--xfa/fwl/core/cfwl_datetimepicker.h70
-rw-r--r--xfa/fwl/core/cfwl_edit.cpp240
-rw-r--r--xfa/fwl/core/cfwl_edit.h71
-rw-r--r--xfa/fwl/core/cfwl_listbox.cpp355
-rw-r--r--xfa/fwl/core/cfwl_listbox.h123
-rw-r--r--xfa/fwl/core/cfwl_picturebox.cpp156
-rw-r--r--xfa/fwl/core/cfwl_picturebox.h67
-rw-r--r--xfa/fwl/core/cfwl_pushbutton.cpp70
-rw-r--r--xfa/fwl/core/cfwl_pushbutton.h46
-rw-r--r--xfa/fwl/core/cfwl_widget.cpp141
-rw-r--r--xfa/fwl/core/cfwl_widget.h65
-rw-r--r--xfa/fwl/core/cfwl_widgetproperties.cpp39
-rw-r--r--xfa/fwl/core/cfwl_widgetproperties.h37
-rw-r--r--xfa/fwl/core/ifwl_edit.h2
-rw-r--r--xfa/fwl/core/ifwl_picturebox.cpp2
22 files changed, 2544 insertions, 2 deletions
diff --git a/xfa/fwl/core/cfwl_barcode.cpp b/xfa/fwl/core/cfwl_barcode.cpp
new file mode 100644
index 0000000000..67cbc301bd
--- /dev/null
+++ b/xfa/fwl/core/cfwl_barcode.cpp
@@ -0,0 +1,111 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fwl/core/cfwl_barcode.h"
+
+#include <memory>
+
+IFWL_Barcode* CFWL_Barcode::GetWidget() {
+ return static_cast<IFWL_Barcode*>(m_pIface.get());
+}
+
+const IFWL_Barcode* CFWL_Barcode::GetWidget() const {
+ return static_cast<IFWL_Barcode*>(m_pIface.get());
+}
+
+FWL_Error CFWL_Barcode::Initialize(const CFWL_WidgetProperties* pProperties) {
+ if (m_pIface)
+ return FWL_Error::Indefinite;
+ 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;
+ }
+ m_pIface = std::move(pBarcode);
+ CFWL_Widget::Initialize();
+ return FWL_Error::Succeeded;
+}
+
+CFWL_Barcode::CFWL_Barcode() {}
+
+CFWL_Barcode::~CFWL_Barcode() {}
+
+void CFWL_Barcode::SetType(BC_TYPE type) {
+ if (GetWidget())
+ GetWidget()->SetType(type);
+}
+
+FX_BOOL CFWL_Barcode::IsProtectedType() {
+ return GetWidget() ? GetWidget()->IsProtectedType() : FALSE;
+}
+
+CFWL_Barcode::CFWL_BarcodeDP::CFWL_BarcodeDP()
+ : m_dwAttributeMask(FWL_BCDATTRIBUTE_NONE) {}
+
+FWL_Error CFWL_Barcode::CFWL_BarcodeDP::GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
+ return FWL_Error::Succeeded;
+}
+
+BC_CHAR_ENCODING CFWL_Barcode::CFWL_BarcodeDP::GetCharEncoding() {
+ return m_eCharEncoding;
+}
+
+int32_t CFWL_Barcode::CFWL_BarcodeDP::GetModuleHeight() {
+ return m_nModuleHeight;
+}
+
+int32_t CFWL_Barcode::CFWL_BarcodeDP::GetModuleWidth() {
+ return m_nModuleWidth;
+}
+
+int32_t CFWL_Barcode::CFWL_BarcodeDP::GetDataLength() {
+ return m_nDataLength;
+}
+
+int32_t CFWL_Barcode::CFWL_BarcodeDP::GetCalChecksum() {
+ return m_nCalChecksum;
+}
+
+FX_BOOL CFWL_Barcode::CFWL_BarcodeDP::GetPrintChecksum() {
+ return m_bPrintChecksum;
+}
+
+BC_TEXT_LOC CFWL_Barcode::CFWL_BarcodeDP::GetTextLocation() {
+ return m_eTextLocation;
+}
+
+int32_t CFWL_Barcode::CFWL_BarcodeDP::GetWideNarrowRatio() {
+ return m_nWideNarrowRatio;
+}
+
+FX_CHAR CFWL_Barcode::CFWL_BarcodeDP::GetStartChar() {
+ return m_cStartChar;
+}
+
+FX_CHAR CFWL_Barcode::CFWL_BarcodeDP::GetEndChar() {
+ return m_cEndChar;
+}
+
+int32_t CFWL_Barcode::CFWL_BarcodeDP::GetVersion() {
+ return m_nVersion;
+}
+
+int32_t CFWL_Barcode::CFWL_BarcodeDP::GetErrorCorrectionLevel() {
+ return m_nECLevel;
+}
+
+FX_BOOL CFWL_Barcode::CFWL_BarcodeDP::GetTruncated() {
+ return m_bTruncated;
+}
+
+uint32_t CFWL_Barcode::CFWL_BarcodeDP::GetBarcodeAttributeMask() {
+ return m_dwAttributeMask;
+}
diff --git a/xfa/fwl/core/cfwl_barcode.h b/xfa/fwl/core/cfwl_barcode.h
new file mode 100644
index 0000000000..39006676e9
--- /dev/null
+++ b/xfa/fwl/core/cfwl_barcode.h
@@ -0,0 +1,128 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FWL_CORE_CFWL_BARCODE_H_
+#define XFA_FWL_CORE_CFWL_BARCODE_H_
+
+#include "xfa/fwl/core/cfwl_edit.h"
+#include "xfa/fwl/core/fwl_error.h"
+#include "xfa/fwl/core/ifwl_barcode.h"
+
+class CFWL_Widget;
+class CFWL_WidgetProperties;
+
+class CFWL_Barcode : public CFWL_Edit {
+ public:
+ CFWL_Barcode();
+ ~CFWL_Barcode() override;
+
+ IFWL_Barcode* GetWidget() override;
+ const IFWL_Barcode* GetWidget() const override;
+
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+ void SetType(BC_TYPE type);
+ FX_BOOL IsProtectedType();
+
+ void SetCharEncoding(BC_CHAR_ENCODING encoding) {
+ m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_CHARENCODING;
+ m_barcodeData.m_eCharEncoding = encoding;
+ }
+ void SetModuleHeight(int32_t height) {
+ m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_MODULEHEIGHT;
+ m_barcodeData.m_nModuleHeight = height;
+ }
+ void SetModuleWidth(int32_t width) {
+ m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_MODULEWIDTH;
+ m_barcodeData.m_nModuleWidth = width;
+ }
+ void SetDataLength(int32_t dataLength) {
+ m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_DATALENGTH;
+ m_barcodeData.m_nDataLength = dataLength;
+ GetWidget()->SetLimit(dataLength);
+ }
+ void SetCalChecksum(int32_t calChecksum) {
+ m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_CALCHECKSUM;
+ m_barcodeData.m_nCalChecksum = calChecksum;
+ }
+ void SetPrintChecksum(FX_BOOL printChecksum) {
+ m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_PRINTCHECKSUM;
+ m_barcodeData.m_bPrintChecksum = printChecksum;
+ }
+ void SetTextLocation(BC_TEXT_LOC location) {
+ m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_TEXTLOCATION;
+ m_barcodeData.m_eTextLocation = location;
+ }
+ void SetWideNarrowRatio(int32_t ratio) {
+ m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_WIDENARROWRATIO;
+ m_barcodeData.m_nWideNarrowRatio = ratio;
+ }
+ void SetStartChar(FX_CHAR startChar) {
+ m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_STARTCHAR;
+ m_barcodeData.m_cStartChar = startChar;
+ }
+ void SetEndChar(FX_CHAR endChar) {
+ m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_ENDCHAR;
+ m_barcodeData.m_cEndChar = endChar;
+ }
+ void SetVersion(int32_t version) {
+ m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_VERSION;
+ m_barcodeData.m_nVersion = version;
+ }
+ void SetErrorCorrectionLevel(int32_t ecLevel) {
+ m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_ECLEVEL;
+ m_barcodeData.m_nECLevel = ecLevel;
+ }
+ void SetTruncated(FX_BOOL truncated) {
+ m_barcodeData.m_dwAttributeMask |= FWL_BCDATTRIBUTE_TRUNCATED;
+ m_barcodeData.m_bTruncated = truncated;
+ }
+ void ResetBarcodeAttributes() {
+ m_barcodeData.m_dwAttributeMask = FWL_BCDATTRIBUTE_NONE;
+ }
+
+ protected:
+ class CFWL_BarcodeDP : public IFWL_BarcodeDP {
+ public:
+ CFWL_BarcodeDP();
+
+ // IFWL_DataProvider
+ FWL_Error GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) override;
+
+ // IFWL_BarcodeDP
+ BC_CHAR_ENCODING GetCharEncoding() override;
+ int32_t GetModuleHeight() override;
+ int32_t GetModuleWidth() override;
+ int32_t GetDataLength() override;
+ int32_t GetCalChecksum() override;
+ FX_BOOL GetPrintChecksum() override;
+ BC_TEXT_LOC GetTextLocation() override;
+ int32_t GetWideNarrowRatio() override;
+ FX_CHAR GetStartChar() override;
+ FX_CHAR GetEndChar() override;
+ int32_t GetVersion() override;
+ int32_t GetErrorCorrectionLevel() override;
+ FX_BOOL GetTruncated() override;
+ uint32_t GetBarcodeAttributeMask() override;
+
+ BC_CHAR_ENCODING m_eCharEncoding;
+ int32_t m_nModuleHeight, m_nModuleWidth;
+ int32_t m_nDataLength;
+ int32_t m_nCalChecksum;
+ FX_BOOL m_bPrintChecksum;
+ BC_TEXT_LOC m_eTextLocation;
+ int32_t m_nWideNarrowRatio;
+ FX_CHAR m_cStartChar, m_cEndChar;
+ int32_t m_nVersion;
+ int32_t m_nECLevel;
+ FX_BOOL m_bTruncated;
+ uint32_t m_dwAttributeMask;
+ };
+
+ CFWL_BarcodeDP m_barcodeData;
+};
+
+#endif // XFA_FWL_CORE_CFWL_BARCODE_H_
diff --git a/xfa/fwl/core/cfwl_checkbox.cpp b/xfa/fwl/core/cfwl_checkbox.cpp
new file mode 100644
index 0000000000..bc55a690f3
--- /dev/null
+++ b/xfa/fwl/core/cfwl_checkbox.cpp
@@ -0,0 +1,72 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fwl/core/cfwl_checkbox.h"
+
+#include <memory>
+
+#include "xfa/fwl/core/fwl_error.h"
+
+IFWL_CheckBox* CFWL_CheckBox::GetWidget() {
+ return static_cast<IFWL_CheckBox*>(m_pIface.get());
+}
+
+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;
+}
+
+FWL_Error CFWL_CheckBox::SetBoxSize(FX_FLOAT fHeight) {
+ m_checkboxData.m_fBoxHeight = fHeight;
+ return FWL_Error::Succeeded;
+}
+
+int32_t CFWL_CheckBox::GetCheckState() {
+ return GetWidget()->GetCheckState();
+}
+
+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") {}
+
+FWL_Error CFWL_CheckBox::CFWL_CheckBoxDP::GetCaption(
+ IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
+ wsCaption = m_wsCaption;
+ return FWL_Error::Succeeded;
+}
+
+FX_FLOAT CFWL_CheckBox::CFWL_CheckBoxDP::GetBoxSize(IFWL_Widget* pWidget) {
+ return m_fBoxHeight;
+}
diff --git a/xfa/fwl/core/cfwl_checkbox.h b/xfa/fwl/core/cfwl_checkbox.h
new file mode 100644
index 0000000000..9daab33150
--- /dev/null
+++ b/xfa/fwl/core/cfwl_checkbox.h
@@ -0,0 +1,46 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FWL_CORE_CFWL_CHECKBOX_H_
+#define XFA_FWL_CORE_CFWL_CHECKBOX_H_
+
+#include "xfa/fwl/core/cfwl_widget.h"
+#include "xfa/fwl/core/ifwl_checkbox.h"
+
+class CFWL_CheckBox : public CFWL_Widget {
+ public:
+ CFWL_CheckBox();
+ ~CFWL_CheckBox() override;
+
+ IFWL_CheckBox* GetWidget() override;
+ const IFWL_CheckBox* GetWidget() const override;
+
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+ FWL_Error SetCaption(const CFX_WideStringC& wsCaption);
+ FWL_Error SetBoxSize(FX_FLOAT fHeight);
+ int32_t GetCheckState();
+ FWL_Error SetCheckState(int32_t iCheck);
+
+ protected:
+ class CFWL_CheckBoxDP : public IFWL_CheckBoxDP {
+ public:
+ CFWL_CheckBoxDP();
+
+ // IFWL_DataProvider
+ FWL_Error GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) override;
+
+ // IFWL_CheckBoxDP
+ FX_FLOAT GetBoxSize(IFWL_Widget* pWidget) override;
+
+ FX_FLOAT m_fBoxHeight;
+ CFX_WideString m_wsCaption;
+ };
+
+ CFWL_CheckBoxDP m_checkboxData;
+};
+
+#endif // XFA_FWL_CORE_CFWL_CHECKBOX_H_
diff --git a/xfa/fwl/core/cfwl_combobox.cpp b/xfa/fwl/core/cfwl_combobox.cpp
new file mode 100644
index 0000000000..e00f785ade
--- /dev/null
+++ b/xfa/fwl/core/cfwl_combobox.cpp
@@ -0,0 +1,388 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fwl/core/cfwl_combobox.h"
+
+#include <utility>
+
+#include "xfa/fwl/core/fwl_error.h"
+#include "xfa/fwl/core/ifwl_widget.h"
+
+IFWL_ComboBox* CFWL_ComboBox::GetWidget() {
+ return static_cast<IFWL_ComboBox*>(m_pIface.get());
+}
+
+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;
+ pItem->m_dwStyles = 0;
+ m_comboBoxData.m_ItemArray.push_back(std::move(pItem));
+ return m_comboBoxData.m_ItemArray.size() - 1;
+}
+
+int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText,
+ CFX_DIBitmap* pIcon) {
+ std::unique_ptr<CFWL_ComboBoxItem> pItem(new CFWL_ComboBoxItem);
+ pItem->m_wsText = wsText;
+ pItem->m_dwStyles = 0;
+ pItem->m_pDIB = pIcon;
+ m_comboBoxData.m_ItemArray.push_back(std::move(pItem));
+ return m_comboBoxData.m_ItemArray.size() - 1;
+}
+
+bool CFWL_ComboBox::RemoveAt(int32_t iIndex) {
+ if (iIndex < 0 ||
+ static_cast<size_t>(iIndex) >= m_comboBoxData.m_ItemArray.size()) {
+ return false;
+ }
+ m_comboBoxData.m_ItemArray.erase(m_comboBoxData.m_ItemArray.begin() + iIndex);
+ return true;
+}
+
+void CFWL_ComboBox::RemoveAll() {
+ m_comboBoxData.m_ItemArray.clear();
+}
+
+int32_t CFWL_ComboBox::CountItems() {
+ return m_comboBoxData.CountItems(GetWidget());
+}
+
+FWL_Error CFWL_ComboBox::GetTextByIndex(int32_t iIndex,
+ CFX_WideString& wsText) {
+ CFWL_ComboBoxItem* pItem = static_cast<CFWL_ComboBoxItem*>(
+ m_comboBoxData.GetItem(m_pIface.get(), iIndex));
+ if (!pItem)
+ return FWL_Error::Indefinite;
+ wsText = pItem->m_wsText;
+ return FWL_Error::Succeeded;
+}
+
+int32_t CFWL_ComboBox::GetCurSel() {
+ return GetWidget() ? GetWidget()->GetCurSel() : -1;
+}
+
+FWL_Error CFWL_ComboBox::SetCurSel(int32_t iSel) {
+ return GetWidget() ? GetWidget()->SetCurSel(iSel) : FWL_Error::Indefinite;
+}
+
+FWL_Error CFWL_ComboBox::SetEditText(const CFX_WideString& wsText) {
+ return GetWidget() ? GetWidget()->SetEditText(wsText) : FWL_Error::Indefinite;
+}
+
+int32_t CFWL_ComboBox::GetEditTextLength() const {
+ return GetWidget() ? GetWidget()->GetEditTextLength() : 0;
+}
+
+FWL_Error CFWL_ComboBox::GetEditText(CFX_WideString& wsText,
+ int32_t nStart,
+ int32_t nCount) const {
+ return GetWidget() ? GetWidget()->GetEditText(wsText, nStart, nCount)
+ : FWL_Error::Indefinite;
+}
+
+FWL_Error CFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount) {
+ return GetWidget() ? GetWidget()->SetEditSelRange(nStart, nCount)
+ : FWL_Error::Indefinite;
+}
+
+int32_t CFWL_ComboBox::GetEditSelRange(int32_t nIndex, int32_t& nStart) {
+ return GetWidget() ? GetWidget()->GetEditSelRange(nIndex, nStart) : 0;
+}
+
+int32_t CFWL_ComboBox::GetEditLimit() {
+ return GetWidget() ? GetWidget()->GetEditLimit() : 0;
+}
+
+FWL_Error CFWL_ComboBox::SetEditLimit(int32_t nLimit) {
+ return GetWidget() ? GetWidget()->SetEditLimit(nLimit)
+ : FWL_Error::Indefinite;
+}
+
+FWL_Error CFWL_ComboBox::EditDoClipboard(int32_t iCmd) {
+ return GetWidget() ? GetWidget()->EditDoClipboard(iCmd)
+ : FWL_Error::Indefinite;
+}
+
+FX_BOOL CFWL_ComboBox::EditRedo(const IFDE_TxtEdtDoRecord* pRecord) {
+ return GetWidget() ? GetWidget()->EditRedo(pRecord) : FALSE;
+}
+
+FX_BOOL CFWL_ComboBox::EditUndo(const IFDE_TxtEdtDoRecord* pRecord) {
+ return GetWidget() ? GetWidget()->EditUndo(pRecord) : FALSE;
+}
+
+FWL_Error CFWL_ComboBox::SetMaxListHeight(FX_FLOAT fMaxHeight) {
+ m_comboBoxData.m_fMaxListHeight = fMaxHeight;
+ return FWL_Error::Succeeded;
+}
+
+FWL_Error CFWL_ComboBox::SetItemData(int32_t iIndex, void* pData) {
+ CFWL_ComboBoxItem* pItem = static_cast<CFWL_ComboBoxItem*>(
+ m_comboBoxData.GetItem(m_pIface.get(), iIndex));
+ if (!pItem)
+ return FWL_Error::Indefinite;
+ pItem->m_pData = pData;
+ return FWL_Error::Succeeded;
+}
+
+void* CFWL_ComboBox::GetItemData(int32_t iIndex) {
+ CFWL_ComboBoxItem* pItem = static_cast<CFWL_ComboBoxItem*>(
+ m_comboBoxData.GetItem(m_pIface.get(), iIndex));
+ return pItem ? pItem->m_pData : nullptr;
+}
+
+FWL_Error CFWL_ComboBox::SetListTheme(IFWL_ThemeProvider* pTheme) {
+ return GetWidget()->GetListBoxt()->SetThemeProvider(pTheme);
+}
+
+FX_BOOL CFWL_ComboBox::AfterFocusShowDropList() {
+ return GetWidget()->AfterFocusShowDropList();
+}
+
+FWL_Error CFWL_ComboBox::OpenDropDownList(FX_BOOL bActivate) {
+ return GetWidget()->OpenDropDownList(bActivate);
+}
+
+FX_BOOL CFWL_ComboBox::EditCanUndo() {
+ return GetWidget() ? GetWidget()->EditCanUndo() : FALSE;
+}
+
+FX_BOOL CFWL_ComboBox::EditCanRedo() {
+ return GetWidget() ? GetWidget()->EditCanRedo() : FALSE;
+}
+
+FX_BOOL CFWL_ComboBox::EditUndo() {
+ return GetWidget() ? GetWidget()->EditUndo() : FALSE;
+}
+
+FX_BOOL CFWL_ComboBox::EditRedo() {
+ return GetWidget() ? GetWidget()->EditRedo() : FALSE;
+}
+
+FX_BOOL CFWL_ComboBox::EditCanCopy() {
+ return GetWidget() ? GetWidget()->EditCanCopy() : FALSE;
+}
+
+FX_BOOL CFWL_ComboBox::EditCanCut() {
+ return GetWidget() ? GetWidget()->EditCanCut() : FALSE;
+}
+
+FX_BOOL CFWL_ComboBox::EditCanSelectAll() {
+ return GetWidget() ? GetWidget()->EditCanSelectAll() : FALSE;
+}
+
+FX_BOOL CFWL_ComboBox::EditCopy(CFX_WideString& wsCopy) {
+ return GetWidget() ? GetWidget()->EditCopy(wsCopy) : FALSE;
+}
+
+FX_BOOL CFWL_ComboBox::EditCut(CFX_WideString& wsCut) {
+ return GetWidget() ? GetWidget()->EditCut(wsCut) : FALSE;
+}
+
+FX_BOOL CFWL_ComboBox::EditPaste(const CFX_WideString& wsPaste) {
+ return GetWidget() ? GetWidget()->EditPaste(wsPaste) : FALSE;
+}
+
+FX_BOOL CFWL_ComboBox::EditSelectAll() {
+ return GetWidget() ? GetWidget()->EditSelectAll() : FALSE;
+}
+
+FX_BOOL CFWL_ComboBox::EditDelete() {
+ return GetWidget() ? GetWidget()->EditDelete() : FALSE;
+}
+
+FX_BOOL CFWL_ComboBox::EditDeSelect() {
+ return GetWidget() ? GetWidget()->EditDeSelect() : FALSE;
+}
+
+FWL_Error CFWL_ComboBox::GetBBox(CFX_RectF& rect) {
+ return GetWidget() ? GetWidget()->GetBBox(rect) : FWL_Error::Indefinite;
+}
+
+FWL_Error CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved) {
+ return GetWidget()
+ ? GetWidget()->EditModifyStylesEx(dwStylesExAdded,
+ dwStylesExRemoved)
+ : FWL_Error::Indefinite;
+}
+
+CFWL_ComboBox::CFWL_ComboBox() {}
+
+CFWL_ComboBox::~CFWL_ComboBox() {}
+
+CFWL_ComboBox::CFWL_ComboBoxDP::CFWL_ComboBoxDP() {
+ m_fItemHeight = 0;
+ m_fMaxListHeight = 0;
+}
+
+CFWL_ComboBox::CFWL_ComboBoxDP::~CFWL_ComboBoxDP() {}
+
+FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetCaption(
+ IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
+ return FWL_Error::Succeeded;
+}
+
+int32_t CFWL_ComboBox::CFWL_ComboBoxDP::CountItems(const IFWL_Widget* pWidget) {
+ return m_ItemArray.size();
+}
+
+IFWL_ListItem* CFWL_ComboBox::CFWL_ComboBoxDP::GetItem(
+ const IFWL_Widget* pWidget,
+ int32_t nIndex) {
+ if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size())
+ return nullptr;
+
+ return m_ItemArray[nIndex].get();
+}
+
+int32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIndex(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem) {
+ auto it = std::find_if(
+ m_ItemArray.begin(), m_ItemArray.end(),
+ [pItem](const std::unique_ptr<CFWL_ComboBoxItem>& candidate) {
+ return candidate.get() == static_cast<CFWL_ComboBoxItem*>(pItem);
+ });
+ return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1;
+}
+
+FX_BOOL CFWL_ComboBox::CFWL_ComboBoxDP::SetItemIndex(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ int32_t nIndex) {
+ if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size())
+ return FALSE;
+
+ m_ItemArray[nIndex].reset(static_cast<CFWL_ComboBoxItem*>(pItem));
+ return TRUE;
+}
+
+uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemStyles(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem) {
+ if (!pItem)
+ return 0;
+ return static_cast<CFWL_ComboBoxItem*>(pItem)->m_dwStyles;
+}
+
+FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemText(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ CFX_WideString& wsText) {
+ if (!pItem)
+ return FWL_Error::Indefinite;
+ wsText = static_cast<CFWL_ComboBoxItem*>(pItem)->m_wsText;
+ return FWL_Error::Succeeded;
+}
+
+FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemRect(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ CFX_RectF& rtItem) {
+ if (!pItem)
+ return FWL_Error::Indefinite;
+ CFWL_ComboBoxItem* pComboItem = static_cast<CFWL_ComboBoxItem*>(pItem);
+ rtItem.Set(pComboItem->m_rtItem.left, pComboItem->m_rtItem.top,
+ pComboItem->m_rtItem.width, pComboItem->m_rtItem.height);
+ return FWL_Error::Succeeded;
+}
+
+void* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemData(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem) {
+ return pItem ? static_cast<CFWL_ComboBoxItem*>(pItem)->m_pData : nullptr;
+}
+
+FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemStyles(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ uint32_t dwStyle) {
+ if (!pItem)
+ return FWL_Error::Indefinite;
+ static_cast<CFWL_ComboBoxItem*>(pItem)->m_dwStyles = dwStyle;
+ return FWL_Error::Succeeded;
+}
+
+FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemText(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ const FX_WCHAR* pszText) {
+ if (!pItem)
+ return FWL_Error::Indefinite;
+ static_cast<CFWL_ComboBoxItem*>(pItem)->m_wsText = pszText;
+ return FWL_Error::Succeeded;
+}
+
+FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemRect(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ const CFX_RectF& rtItem) {
+ if (!pItem)
+ return FWL_Error::Indefinite;
+ static_cast<CFWL_ComboBoxItem*>(pItem)->m_rtItem = rtItem;
+ return FWL_Error::Succeeded;
+}
+
+FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetItemHeight(IFWL_Widget* pWidget) {
+ return m_fItemHeight;
+}
+
+CFX_DIBitmap* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIcon(
+ IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem) {
+ return pItem ? static_cast<CFWL_ComboBoxItem*>(pItem)->m_pDIB : nullptr;
+}
+
+FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckRect(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ CFX_RectF& rtCheck) {
+ rtCheck = static_cast<CFWL_ComboBoxItem*>(pItem)->m_rtCheckBox;
+ return FWL_Error::Succeeded;
+}
+
+FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckRect(
+ IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ const CFX_RectF& rtCheck) {
+ static_cast<CFWL_ComboBoxItem*>(pItem)->m_rtCheckBox = rtCheck;
+ return FWL_Error::Succeeded;
+}
+
+uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckState(
+ IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem) {
+ return static_cast<CFWL_ComboBoxItem*>(pItem)->m_dwCheckState;
+}
+
+FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckState(
+ IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ uint32_t dwCheckState) {
+ static_cast<CFWL_ComboBoxItem*>(pItem)->m_dwCheckState = dwCheckState;
+ return FWL_Error::Succeeded;
+}
+
+FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetListHeight(IFWL_Widget* pWidget) {
+ return m_fMaxListHeight;
+}
+
+CFWL_ComboBoxItem::CFWL_ComboBoxItem() : m_pDIB(nullptr), m_pData(nullptr) {}
+
+CFWL_ComboBoxItem::~CFWL_ComboBoxItem() {}
diff --git a/xfa/fwl/core/cfwl_combobox.h b/xfa/fwl/core/cfwl_combobox.h
new file mode 100644
index 0000000000..6e4988fe8e
--- /dev/null
+++ b/xfa/fwl/core/cfwl_combobox.h
@@ -0,0 +1,148 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FWL_CORE_CFWL_COMBOBOX_H_
+#define XFA_FWL_CORE_CFWL_COMBOBOX_H_
+
+#include <memory>
+#include <vector>
+
+#include "xfa/fwl/core/cfwl_widget.h"
+#include "xfa/fwl/core/ifwl_combobox.h"
+
+class CFWL_WidgetProperties;
+class IFWL_ComboBoxDP;
+class CFWL_ComboBoxDP;
+class CFWL_ComboBoxItem;
+
+class CFWL_ComboBox : public CFWL_Widget {
+ public:
+ CFWL_ComboBox();
+ ~CFWL_ComboBox() override;
+
+ IFWL_ComboBox* GetWidget() override;
+ const IFWL_ComboBox* GetWidget() const override;
+
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+ 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.
+ void RemoveAll();
+ int32_t CountItems();
+ FWL_Error GetTextByIndex(int32_t iIndex, CFX_WideString& wsText);
+ int32_t GetCurSel();
+ FWL_Error SetCurSel(int32_t iSel);
+ FWL_Error SetEditText(const CFX_WideString& wsText);
+ int32_t GetEditTextLength() const;
+ FWL_Error GetEditText(CFX_WideString& wsText,
+ int32_t nStart = 0,
+ int32_t nCount = -1) const;
+ FWL_Error SetEditSelRange(int32_t nStart, int32_t nCount = -1);
+ int32_t GetEditSelRange(int32_t nIndex, int32_t& nStart);
+ int32_t GetEditLimit();
+ FWL_Error SetEditLimit(int32_t nLimit);
+ FWL_Error EditDoClipboard(int32_t iCmd);
+ FX_BOOL EditRedo(const IFDE_TxtEdtDoRecord* pRecord);
+ FX_BOOL EditUndo(const IFDE_TxtEdtDoRecord* pRecord);
+ FWL_Error SetMaxListHeight(FX_FLOAT fMaxHeight);
+ FWL_Error SetItemData(int32_t iIndex, void* pData);
+ void* GetItemData(int32_t iIndex);
+ FWL_Error SetListTheme(IFWL_ThemeProvider* pTheme);
+ FX_BOOL AfterFocusShowDropList();
+ FWL_Error OpenDropDownList(FX_BOOL bActivate);
+
+ FX_BOOL EditCanUndo();
+ FX_BOOL EditCanRedo();
+ FX_BOOL EditUndo();
+ FX_BOOL EditRedo();
+ FX_BOOL EditCanCopy();
+ FX_BOOL EditCanCut();
+ FX_BOOL EditCanSelectAll();
+ FX_BOOL EditCopy(CFX_WideString& wsCopy);
+ FX_BOOL EditCut(CFX_WideString& wsCut);
+ FX_BOOL EditPaste(const CFX_WideString& wsPaste);
+ FX_BOOL EditSelectAll();
+ FX_BOOL EditDelete();
+ FX_BOOL EditDeSelect();
+ FWL_Error GetBBox(CFX_RectF& rect);
+ FWL_Error EditModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved);
+
+ protected:
+ class CFWL_ComboBoxDP : public IFWL_ComboBoxDP {
+ public:
+ CFWL_ComboBoxDP();
+ ~CFWL_ComboBoxDP() override;
+
+ // IFWL_DataProvider
+ FWL_Error GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) override;
+
+ // IFWL_ListBoxDP
+ int32_t CountItems(const IFWL_Widget* pWidget) override;
+ IFWL_ListItem* GetItem(const IFWL_Widget* pWidget, int32_t nIndex) override;
+ int32_t GetItemIndex(IFWL_Widget* pWidget, IFWL_ListItem* pItem) override;
+ FX_BOOL SetItemIndex(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ int32_t nIndex) override;
+
+ uint32_t GetItemStyles(IFWL_Widget* pWidget, IFWL_ListItem* pItem) override;
+ FWL_Error GetItemText(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ CFX_WideString& wsText) override;
+ FWL_Error GetItemRect(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ CFX_RectF& rtItem) override;
+ void* GetItemData(IFWL_Widget* pWidget, IFWL_ListItem* pItem) override;
+ FWL_Error SetItemStyles(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ uint32_t dwStyle) override;
+ FWL_Error SetItemText(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ const FX_WCHAR* pszText) override;
+ FWL_Error SetItemRect(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ const CFX_RectF& rtItem) override;
+ FX_FLOAT GetItemHeight(IFWL_Widget* pWidget) override;
+ CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem) override;
+ FWL_Error GetItemCheckRect(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ CFX_RectF& rtCheck) override;
+ FWL_Error SetItemCheckRect(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ const CFX_RectF& rtCheck) override;
+ uint32_t GetItemCheckState(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem) override;
+ FWL_Error SetItemCheckState(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ uint32_t dwCheckState) override;
+
+ // IFWL_ComboBoxDP
+ FX_FLOAT GetListHeight(IFWL_Widget* pWidget) override;
+
+ std::vector<std::unique_ptr<CFWL_ComboBoxItem>> m_ItemArray;
+ FX_FLOAT m_fMaxListHeight;
+ FX_FLOAT m_fItemHeight;
+ };
+ CFWL_ComboBoxDP m_comboBoxData;
+};
+
+class CFWL_ComboBoxItem : public IFWL_ListItem {
+ public:
+ CFWL_ComboBoxItem();
+ ~CFWL_ComboBoxItem();
+
+ CFX_RectF m_rtItem;
+ uint32_t m_dwStyles;
+ CFX_WideString m_wsText;
+ CFX_DIBitmap* m_pDIB;
+ uint32_t m_dwCheckState;
+ CFX_RectF m_rtCheckBox;
+ void* m_pData;
+};
+
+#endif // XFA_FWL_CORE_CFWL_COMBOBOX_H_
diff --git a/xfa/fwl/core/cfwl_datetimepicker.cpp b/xfa/fwl/core/cfwl_datetimepicker.cpp
new file mode 100644
index 0000000000..7d5a1535f1
--- /dev/null
+++ b/xfa/fwl/core/cfwl_datetimepicker.cpp
@@ -0,0 +1,169 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fwl/core/cfwl_datetimepicker.h"
+
+#include <memory>
+
+#include "xfa/fwl/core/fwl_error.h"
+#include "xfa/fwl/core/ifwl_datetimepicker.h"
+#include "xfa/fwl/core/ifwl_widget.h"
+
+IFWL_DateTimePicker* CFWL_DateTimePicker::GetWidget() {
+ return static_cast<IFWL_DateTimePicker*>(m_pIface.get());
+}
+
+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) {
+ m_DateTimePickerDP.m_iYear = iYear;
+ m_DateTimePickerDP.m_iMonth = iMonth;
+ m_DateTimePickerDP.m_iDay = iDay;
+ return FWL_Error::Succeeded;
+}
+
+int32_t CFWL_DateTimePicker::CountSelRanges() {
+ return GetWidget()->CountSelRanges();
+}
+
+int32_t CFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) {
+ return GetWidget()->GetSelRange(nIndex, nStart);
+}
+
+FWL_Error CFWL_DateTimePicker::GetEditText(CFX_WideString& wsText) {
+ return GetWidget()->GetEditText(wsText);
+}
+
+FWL_Error CFWL_DateTimePicker::SetEditText(const CFX_WideString& wsText) {
+ return GetWidget()->SetEditText(wsText);
+}
+
+FWL_Error CFWL_DateTimePicker::GetCurSel(int32_t& iYear,
+ int32_t& iMonth,
+ int32_t& iDay) {
+ return GetWidget()->GetCurSel(iYear, iMonth, iDay);
+}
+
+FWL_Error CFWL_DateTimePicker::SetCurSel(int32_t iYear,
+ int32_t iMonth,
+ int32_t iDay) {
+ 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;
+ m_iDay = 1;
+}
+
+FWL_Error CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetCaption(
+ IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
+ wsCaption = m_wsData;
+ return FWL_Error::Succeeded;
+}
+
+FWL_Error CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetToday(
+ IFWL_Widget* pWidget,
+ int32_t& iYear,
+ int32_t& iMonth,
+ int32_t& iDay) {
+ iYear = m_iYear;
+ iMonth = m_iMonth;
+ iDay = m_iDay;
+ return FWL_Error::Succeeded;
+}
+
+FX_BOOL CFWL_DateTimePicker::CanUndo() {
+ return GetWidget()->CanUndo();
+}
+
+FX_BOOL CFWL_DateTimePicker::CanRedo() {
+ return GetWidget()->CanRedo();
+}
+
+FX_BOOL CFWL_DateTimePicker::Undo() {
+ return GetWidget()->Undo();
+}
+
+FX_BOOL CFWL_DateTimePicker::Redo() {
+ return GetWidget()->Redo();
+}
+
+FX_BOOL CFWL_DateTimePicker::CanCopy() {
+ return GetWidget()->CanCopy();
+}
+
+FX_BOOL CFWL_DateTimePicker::CanCut() {
+ return GetWidget()->CanCut();
+}
+
+FX_BOOL CFWL_DateTimePicker::CanSelectAll() {
+ return GetWidget()->CanSelectAll();
+}
+
+FX_BOOL CFWL_DateTimePicker::Copy(CFX_WideString& wsCopy) {
+ return GetWidget()->Copy(wsCopy);
+}
+
+FX_BOOL CFWL_DateTimePicker::Cut(CFX_WideString& wsCut) {
+ return GetWidget()->Copy(wsCut);
+}
+
+FX_BOOL CFWL_DateTimePicker::Paste(const CFX_WideString& wsPaste) {
+ return GetWidget()->Paste(wsPaste);
+}
+
+FX_BOOL CFWL_DateTimePicker::SelectAll() {
+ return GetWidget()->SelectAll();
+}
+
+FX_BOOL CFWL_DateTimePicker::Delete() {
+ return GetWidget()->Delete();
+}
+
+FX_BOOL CFWL_DateTimePicker::DeSelect() {
+ return GetWidget()->DeSelect();
+}
+
+FWL_Error CFWL_DateTimePicker::GetBBox(CFX_RectF& rect) {
+ return GetWidget()->GetBBox(rect);
+}
+
+FWL_Error CFWL_DateTimePicker::SetEditLimit(int32_t nLimit) {
+ return GetWidget()->SetEditLimit(nLimit);
+}
+
+FWL_Error CFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved) {
+ return GetWidget()->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved);
+}
diff --git a/xfa/fwl/core/cfwl_datetimepicker.h b/xfa/fwl/core/cfwl_datetimepicker.h
new file mode 100644
index 0000000000..a3299a92a0
--- /dev/null
+++ b/xfa/fwl/core/cfwl_datetimepicker.h
@@ -0,0 +1,70 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FWL_CORE_CFWL_DATETIMEPICKER_H_
+#define XFA_FWL_CORE_CFWL_DATETIMEPICKER_H_
+
+#include "xfa/fwl/core/cfwl_widget.h"
+#include "xfa/fwl/core/ifwl_datetimepicker.h"
+
+class CFWL_DateTimePicker : public CFWL_Widget {
+ public:
+ CFWL_DateTimePicker();
+ ~CFWL_DateTimePicker() override;
+
+ IFWL_DateTimePicker* GetWidget() override;
+ const IFWL_DateTimePicker* GetWidget() const override;
+
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+ 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);
+ int32_t CountSelRanges();
+ int32_t GetSelRange(int32_t nIndex, int32_t& nStart);
+ FWL_Error GetCurSel(int32_t& iYear, int32_t& iMonth, int32_t& iDay);
+ FWL_Error SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay);
+ FX_BOOL CanUndo();
+ FX_BOOL CanRedo();
+ FX_BOOL Undo();
+ FX_BOOL Redo();
+ FX_BOOL CanCopy();
+ FX_BOOL CanCut();
+ FX_BOOL CanSelectAll();
+ FX_BOOL Copy(CFX_WideString& wsCopy);
+ FX_BOOL Cut(CFX_WideString& wsCut);
+ FX_BOOL Paste(const CFX_WideString& wsPaste);
+ FX_BOOL SelectAll();
+ FX_BOOL Delete();
+ FX_BOOL DeSelect();
+ FWL_Error GetBBox(CFX_RectF& rect);
+ FWL_Error SetEditLimit(int32_t nLimit);
+ FWL_Error ModifyEditStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved);
+
+ protected:
+ class CFWL_DateTimePickerDP : public IFWL_DateTimePickerDP {
+ public:
+ CFWL_DateTimePickerDP();
+
+ // IFWL_DataProvider
+ FWL_Error GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) override;
+
+ // IFWL_DateTimePickerDP
+ FWL_Error GetToday(IFWL_Widget* pWidget,
+ int32_t& iYear,
+ int32_t& iMonth,
+ int32_t& iDay) override;
+ int32_t m_iYear;
+ int32_t m_iMonth;
+ int32_t m_iDay;
+ CFX_WideString m_wsData;
+ };
+
+ CFWL_DateTimePickerDP m_DateTimePickerDP;
+};
+
+#endif // XFA_FWL_CORE_CFWL_DATETIMEPICKER_H_
diff --git a/xfa/fwl/core/cfwl_edit.cpp b/xfa/fwl/core/cfwl_edit.cpp
new file mode 100644
index 0000000000..9e106929bb
--- /dev/null
+++ b/xfa/fwl/core/cfwl_edit.cpp
@@ -0,0 +1,240 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fwl/core/cfwl_edit.h"
+
+#include <memory>
+#include <vector>
+
+IFWL_Edit* CFWL_Edit::GetWidget() {
+ return static_cast<IFWL_Edit*>(m_pIface.get());
+}
+
+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;
+ return GetWidget()->SetText(wsText);
+}
+
+int32_t CFWL_Edit::GetTextLength() const {
+ if (!GetWidget())
+ return 0;
+ return GetWidget()->GetTextLength();
+}
+
+FWL_Error CFWL_Edit::GetText(CFX_WideString& wsText,
+ int32_t nStart,
+ int32_t nCount) const {
+ if (!GetWidget())
+ return FWL_Error::Indefinite;
+ return GetWidget()->GetText(wsText, nStart, nCount);
+}
+
+FWL_Error CFWL_Edit::ClearText() {
+ if (!GetWidget())
+ return FWL_Error::Indefinite;
+ return GetWidget()->ClearText();
+}
+
+int32_t CFWL_Edit::GetCaretPos() const {
+ if (!GetWidget())
+ return -1;
+ return GetWidget()->GetCaretPos();
+}
+
+int32_t CFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) {
+ if (!GetWidget())
+ return -1;
+ return GetWidget()->SetCaretPos(nIndex, bBefore);
+}
+
+int32_t CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) {
+ if (!GetWidget())
+ return -1;
+ GetWidget()->AddSelRange(nStart, nCount);
+ int32_t pos = 0;
+ int32_t sum = GetWidget()->GetTextLength();
+ if (nCount == -1) {
+ pos = sum;
+ } else {
+ pos = nStart + nCount;
+ }
+ return GetWidget()->SetCaretPos(pos);
+}
+
+int32_t CFWL_Edit::CountSelRanges() {
+ if (!GetWidget())
+ return 0;
+ return GetWidget()->CountSelRanges();
+}
+
+int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) {
+ if (!GetWidget())
+ return 0;
+ return GetWidget()->GetSelRange(nIndex, nStart);
+}
+
+FWL_Error CFWL_Edit::ClearSelections() {
+ if (!GetWidget())
+ return FWL_Error::Indefinite;
+ return GetWidget()->ClearSelections();
+}
+
+int32_t CFWL_Edit::GetLimit() {
+ if (!GetWidget())
+ return -1;
+ return GetWidget()->GetLimit();
+}
+
+FWL_Error CFWL_Edit::SetLimit(int32_t nLimit) {
+ if (!GetWidget())
+ return FWL_Error::Indefinite;
+ return GetWidget()->SetLimit(nLimit);
+}
+
+FWL_Error CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) {
+ if (!GetWidget())
+ return FWL_Error::Indefinite;
+ return GetWidget()->SetAliasChar(wAlias);
+}
+
+FWL_Error CFWL_Edit::Insert(int32_t nStart,
+ const FX_WCHAR* lpText,
+ int32_t nLen) {
+ if (!GetWidget())
+ return FWL_Error::Indefinite;
+ return GetWidget()->Insert(nStart, lpText, nLen);
+}
+
+FWL_Error CFWL_Edit::DeleteSelections() {
+ if (!GetWidget())
+ return FWL_Error::Indefinite;
+ return GetWidget()->DeleteSelections();
+}
+
+FWL_Error CFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) {
+ if (!GetWidget())
+ return FWL_Error::Indefinite;
+ return GetWidget()->DeleteRange(nStart, nCount);
+}
+
+FWL_Error CFWL_Edit::Replace(int32_t nStart,
+ int32_t nLen,
+ const CFX_WideStringC& wsReplace) {
+ if (!GetWidget())
+ return FWL_Error::Indefinite;
+ return GetWidget()->Replace(nStart, nLen, wsReplace);
+}
+
+FWL_Error CFWL_Edit::DoClipboard(int32_t iCmd) {
+ if (!GetWidget())
+ return FWL_Error::Indefinite;
+ return GetWidget()->DoClipboard(iCmd);
+}
+
+FX_BOOL CFWL_Edit::Redo(const IFDE_TxtEdtDoRecord* pRecord) {
+ return GetWidget() && GetWidget()->Redo(pRecord);
+}
+
+FX_BOOL CFWL_Edit::Undo(const IFDE_TxtEdtDoRecord* pRecord) {
+ return GetWidget() && GetWidget()->Undo(pRecord);
+}
+
+FWL_Error CFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) {
+ if (!GetWidget())
+ return FWL_Error::Indefinite;
+ return GetWidget()->SetTabWidth(fTabWidth, bEquidistant);
+}
+
+FWL_Error CFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) {
+ if (iMin > iMax) {
+ return FWL_Error::ParameterInvalid;
+ }
+ return GetWidget()->SetNumberRange(iMin, iMax);
+}
+
+FWL_Error CFWL_Edit::SetBackColor(uint32_t dwColor) {
+ if (!GetWidget())
+ return FWL_Error::Indefinite;
+ return GetWidget()->SetBackgroundColor(dwColor);
+}
+
+FWL_Error CFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) {
+ if (!GetWidget())
+ return FWL_Error::Indefinite;
+ return GetWidget()->SetFont(wsFont, fSize);
+}
+
+FX_BOOL CFWL_Edit::CanUndo() {
+ return GetWidget()->CanUndo();
+}
+
+FX_BOOL CFWL_Edit::CanRedo() {
+ return GetWidget()->CanRedo();
+}
+
+FX_BOOL CFWL_Edit::Undo() {
+ return GetWidget()->Undo();
+}
+
+FX_BOOL CFWL_Edit::Redo() {
+ return GetWidget()->Undo();
+}
+
+FX_BOOL CFWL_Edit::Copy(CFX_WideString& wsCopy) {
+ return GetWidget()->Copy(wsCopy);
+}
+
+FX_BOOL CFWL_Edit::Cut(CFX_WideString& wsCut) {
+ return GetWidget()->Cut(wsCut);
+}
+
+FX_BOOL CFWL_Edit::Paste(const CFX_WideString& wsPaste) {
+ return GetWidget()->Paste(wsPaste);
+}
+
+FX_BOOL CFWL_Edit::Delete() {
+ return GetWidget()->Delete();
+}
+
+void CFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) {
+ return GetWidget()->SetScrollOffset(fScrollOffset);
+}
+
+FX_BOOL CFWL_Edit::GetSuggestWords(CFX_PointF pointf,
+ std::vector<CFX_ByteString>& sSuggest) {
+ return GetWidget()->GetSuggestWords(pointf, sSuggest);
+}
+
+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
new file mode 100644
index 0000000000..83343ac751
--- /dev/null
+++ b/xfa/fwl/core/cfwl_edit.h
@@ -0,0 +1,71 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FWL_CORE_CFWL_EDIT_H_
+#define XFA_FWL_CORE_CFWL_EDIT_H_
+
+#include <vector>
+
+#include "xfa/fwl/core/cfwl_widget.h"
+#include "xfa/fwl/core/ifwl_edit.h"
+
+class CFWL_WidgetProperties;
+class IFDE_TxtEdtDoRecord;
+
+class CFWL_Edit : public CFWL_Widget {
+ public:
+ CFWL_Edit();
+ ~CFWL_Edit() override;
+
+ IFWL_Edit* GetWidget() override;
+ const IFWL_Edit* GetWidget() const override;
+
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+ FWL_Error SetText(const CFX_WideString& wsText);
+ int32_t GetTextLength() const;
+ FWL_Error GetText(CFX_WideString& wsText,
+ int32_t nStart = 0,
+ int32_t nCount = -1) const;
+ FWL_Error ClearText();
+ int32_t GetCaretPos() const;
+ int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore = TRUE);
+ int32_t AddSelRange(int32_t nStart, int32_t nCount = -1);
+ int32_t CountSelRanges();
+ int32_t GetSelRange(int32_t nIndex, int32_t& nStart);
+ FWL_Error ClearSelections();
+ int32_t GetLimit();
+ FWL_Error SetLimit(int32_t nLimit);
+ FWL_Error SetAliasChar(FX_WCHAR wAlias);
+ FWL_Error SetFormatString(const CFX_WideString& wsFormat);
+ FWL_Error Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLen);
+ FWL_Error DeleteSelections();
+ FWL_Error DeleteRange(int32_t nStart, int32_t nCount = -1);
+ FWL_Error Replace(int32_t nStart,
+ int32_t nLen,
+ const CFX_WideStringC& wsReplace);
+ FWL_Error DoClipboard(int32_t iCmd);
+ FX_BOOL Redo(const IFDE_TxtEdtDoRecord* pRecord);
+ FX_BOOL Undo(const IFDE_TxtEdtDoRecord* pRecord);
+ FWL_Error SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant);
+ FWL_Error SetNumberRange(int32_t iMin, int32_t iMax);
+ FWL_Error SetBackColor(uint32_t dwColor);
+ FWL_Error SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize);
+ FX_BOOL CanUndo();
+ FX_BOOL CanRedo();
+ FX_BOOL Undo();
+ FX_BOOL Redo();
+ FX_BOOL Copy(CFX_WideString& wsCopy);
+ FX_BOOL Cut(CFX_WideString& wsCut);
+ FX_BOOL Paste(const CFX_WideString& wsPaste);
+ FX_BOOL Delete();
+ void SetScrollOffset(FX_FLOAT fScrollOffset);
+ FX_BOOL GetSuggestWords(CFX_PointF pointf,
+ std::vector<CFX_ByteString>& sSuggest);
+ FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf,
+ const CFX_ByteStringC& bsReplace);
+};
+
+#endif // XFA_FWL_CORE_CFWL_EDIT_H_
diff --git a/xfa/fwl/core/cfwl_listbox.cpp b/xfa/fwl/core/cfwl_listbox.cpp
new file mode 100644
index 0000000000..3884e8c42e
--- /dev/null
+++ b/xfa/fwl/core/cfwl_listbox.cpp
@@ -0,0 +1,355 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fwl/core/cfwl_listbox.h"
+
+#include <memory>
+
+#include "third_party/base/stl_util.h"
+
+IFWL_ListBox* CFWL_ListBox::GetWidget() {
+ return static_cast<IFWL_ListBox*>(m_pIface.get());
+}
+
+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;
+}
+
+IFWL_ListItem* CFWL_ListBox::AddString(const CFX_WideStringC& wsAdd,
+ FX_BOOL bSelect) {
+ std::unique_ptr<CFWL_ListItem> pItem(new CFWL_ListItem);
+ pItem->m_dwStates = 0;
+ pItem->m_wsText = wsAdd;
+ pItem->m_dwStates = bSelect ? FWL_ITEMSTATE_LTB_Selected : 0;
+ m_ListBoxDP.m_ItemArray.push_back(std::move(pItem));
+ return m_ListBoxDP.m_ItemArray.back().get();
+}
+
+FX_BOOL CFWL_ListBox::DeleteString(IFWL_ListItem* pItem) {
+ int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), pItem);
+ if (nIndex < 0 ||
+ static_cast<size_t>(nIndex) >= m_ListBoxDP.m_ItemArray.size()) {
+ return FALSE;
+ }
+ int32_t iCount = m_ListBoxDP.CountItems(m_pIface.get());
+ int32_t iSel = nIndex + 1;
+ if (iSel >= iCount) {
+ iSel = nIndex - 1;
+ if (iSel < 0) {
+ iSel = -1;
+ }
+ }
+ if (iSel >= 0) {
+ CFWL_ListItem* pSel =
+ static_cast<CFWL_ListItem*>(m_ListBoxDP.GetItem(m_pIface.get(), iSel));
+ pSel->m_dwStates |= FWL_ITEMSTATE_LTB_Selected;
+ }
+ m_ListBoxDP.m_ItemArray.erase(m_ListBoxDP.m_ItemArray.begin() + nIndex);
+ return TRUE;
+}
+
+void CFWL_ListBox::DeleteAll() {
+ m_ListBoxDP.m_ItemArray.clear();
+}
+
+int32_t CFWL_ListBox::CountSelItems() {
+ if (!GetWidget())
+ return 0;
+ return GetWidget()->CountSelItems();
+}
+
+IFWL_ListItem* CFWL_ListBox::GetSelItem(int32_t nIndexSel) {
+ if (!GetWidget())
+ return nullptr;
+ return GetWidget()->GetSelItem(nIndexSel);
+}
+
+int32_t CFWL_ListBox::GetSelIndex(int32_t nIndex) {
+ if (!GetWidget())
+ return 0;
+ return GetWidget()->GetSelIndex(nIndex);
+}
+
+FWL_Error CFWL_ListBox::SetSelItem(IFWL_ListItem* pItem, FX_BOOL bSelect) {
+ if (!GetWidget())
+ return FWL_Error::Indefinite;
+ return GetWidget()->SetSelItem(pItem, bSelect);
+}
+
+FWL_Error CFWL_ListBox::GetItemText(IFWL_ListItem* pItem,
+ CFX_WideString& wsText) {
+ if (!GetWidget())
+ return FWL_Error::Indefinite;
+ return GetWidget()->GetItemText(pItem, wsText);
+}
+
+FWL_Error CFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
+ if (!GetWidget())
+ return FWL_Error::Indefinite;
+ return GetWidget()->GetScrollPos(fPos, bVert);
+}
+
+FWL_Error CFWL_ListBox::SetItemHeight(FX_FLOAT fItemHeight) {
+ m_ListBoxDP.m_fItemHeight = fItemHeight;
+ return FWL_Error::Succeeded;
+}
+
+IFWL_ListItem* CFWL_ListBox::GetFocusItem() {
+ for (const auto& pItem : m_ListBoxDP.m_ItemArray) {
+ if (pItem->m_dwStates & FWL_ITEMSTATE_LTB_Focused)
+ return pItem.get();
+ }
+ return nullptr;
+}
+
+FWL_Error CFWL_ListBox::SetFocusItem(IFWL_ListItem* pItem) {
+ int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), pItem);
+ m_ListBoxDP.m_ItemArray[nIndex]->m_dwStates |= FWL_ITEMSTATE_LTB_Focused;
+ return FWL_Error::Succeeded;
+}
+
+int32_t CFWL_ListBox::CountItems() {
+ return pdfium::CollectionSize<int32_t>(m_ListBoxDP.m_ItemArray);
+}
+
+IFWL_ListItem* CFWL_ListBox::GetItem(int32_t nIndex) {
+ if (nIndex < 0 || nIndex >= CountItems())
+ return nullptr;
+
+ return m_ListBoxDP.m_ItemArray[nIndex].get();
+}
+
+FWL_Error CFWL_ListBox::SetItemString(IFWL_ListItem* pItem,
+ const CFX_WideStringC& wsText) {
+ if (!pItem)
+ return FWL_Error::Indefinite;
+ static_cast<CFWL_ListItem*>(pItem)->m_wsText = wsText;
+ return FWL_Error::Succeeded;
+}
+
+FWL_Error CFWL_ListBox::GetItemString(IFWL_ListItem* pItem,
+ CFX_WideString& wsText) {
+ if (!pItem)
+ return FWL_Error::Indefinite;
+ wsText = static_cast<CFWL_ListItem*>(pItem)->m_wsText;
+ return FWL_Error::Succeeded;
+}
+
+FWL_Error CFWL_ListBox::SetItemData(IFWL_ListItem* pItem, void* pData) {
+ if (!pItem)
+ return FWL_Error::Indefinite;
+ static_cast<CFWL_ListItem*>(pItem)->m_pData = pData;
+ return FWL_Error::Succeeded;
+}
+
+void* CFWL_ListBox::GetItemData(IFWL_ListItem* pItem) {
+ return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_pData : nullptr;
+}
+
+IFWL_ListItem* CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) {
+ CFX_RectF rtClient;
+ GetWidget()->GetClientRect(rtClient);
+ fx -= rtClient.left;
+ fy -= rtClient.top;
+ FX_FLOAT fPosX = 0;
+ FX_FLOAT fPosY = 0;
+ GetWidget()->GetScrollPos(fx);
+ GetWidget()->GetScrollPos(fy, FALSE);
+ int32_t nCount = m_ListBoxDP.CountItems(nullptr);
+ for (int32_t i = 0; i < nCount; i++) {
+ IFWL_ListItem* pItem = m_ListBoxDP.GetItem(nullptr, i);
+ if (!pItem) {
+ continue;
+ }
+ CFX_RectF rtItem;
+ m_ListBoxDP.GetItemRect(nullptr, pItem, rtItem);
+ rtItem.Offset(-fPosX, -fPosY);
+ if (rtItem.Contains(fx, fy)) {
+ return pItem;
+ }
+ }
+ return nullptr;
+}
+
+uint32_t CFWL_ListBox::GetItemStates(IFWL_ListItem* pItem) {
+ if (!pItem)
+ return 0;
+ CFWL_ListItem* pListItem = static_cast<CFWL_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() {}
+
+FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
+ wsCaption = m_wsData;
+ return FWL_Error::Succeeded;
+}
+
+int32_t CFWL_ListBox::CFWL_ListBoxDP::CountItems(const IFWL_Widget* pWidget) {
+ return pdfium::CollectionSize<int32_t>(m_ItemArray);
+}
+
+IFWL_ListItem* CFWL_ListBox::CFWL_ListBoxDP::GetItem(const IFWL_Widget* pWidget,
+ int32_t nIndex) {
+ if (nIndex < 0 || nIndex >= CountItems(pWidget))
+ return nullptr;
+
+ return m_ItemArray[nIndex].get();
+}
+
+int32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemIndex(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem) {
+ auto it = std::find_if(
+ m_ItemArray.begin(), m_ItemArray.end(),
+ [pItem](const std::unique_ptr<CFWL_ListItem>& candidate) {
+ return candidate.get() == static_cast<CFWL_ListItem*>(pItem);
+ });
+ return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1;
+}
+
+FX_BOOL CFWL_ListBox::CFWL_ListBoxDP::SetItemIndex(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ int32_t nIndex) {
+ if (nIndex < 0 || nIndex >= CountItems(pWidget))
+ return FALSE;
+ m_ItemArray[nIndex].reset(static_cast<CFWL_ListItem*>(pItem));
+ return TRUE;
+}
+
+uint32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemStyles(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem) {
+ if (!pItem)
+ return 0;
+ return static_cast<CFWL_ListItem*>(pItem)->m_dwStates;
+}
+
+FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetItemText(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ CFX_WideString& wsText) {
+ if (!pItem)
+ return FWL_Error::Indefinite;
+ wsText = static_cast<CFWL_ListItem*>(pItem)->m_wsText;
+ return FWL_Error::Succeeded;
+}
+
+FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetItemRect(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ CFX_RectF& rtItem) {
+ if (!pItem)
+ return FWL_Error::Indefinite;
+ rtItem = static_cast<CFWL_ListItem*>(pItem)->m_rtItem;
+ return FWL_Error::Succeeded;
+}
+
+void* CFWL_ListBox::CFWL_ListBoxDP::GetItemData(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem) {
+ return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_pData : nullptr;
+}
+
+FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemStyles(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ uint32_t dwStyle) {
+ if (!pItem)
+ return FWL_Error::Indefinite;
+ static_cast<CFWL_ListItem*>(pItem)->m_dwStates = dwStyle;
+ return FWL_Error::Succeeded;
+}
+
+FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemText(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ const FX_WCHAR* pszText) {
+ if (!pItem)
+ return FWL_Error::Indefinite;
+ static_cast<CFWL_ListItem*>(pItem)->m_wsText = pszText;
+ return FWL_Error::Succeeded;
+}
+
+FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemRect(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ const CFX_RectF& rtItem) {
+ if (!pItem)
+ return FWL_Error::Indefinite;
+ static_cast<CFWL_ListItem*>(pItem)->m_rtItem = rtItem;
+ return FWL_Error::Succeeded;
+}
+
+FX_FLOAT CFWL_ListBox::CFWL_ListBoxDP::GetItemHeight(IFWL_Widget* pWidget) {
+ return m_fItemHeight;
+}
+
+CFX_DIBitmap* CFWL_ListBox::CFWL_ListBoxDP::GetItemIcon(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem) {
+ return static_cast<CFWL_ListItem*>(pItem)->m_pDIB;
+}
+
+FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckRect(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ CFX_RectF& rtCheck) {
+ rtCheck = static_cast<CFWL_ListItem*>(pItem)->m_rtCheckBox;
+ return FWL_Error::Succeeded;
+}
+
+FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckRect(
+ IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ const CFX_RectF& rtCheck) {
+ static_cast<CFWL_ListItem*>(pItem)->m_rtCheckBox = rtCheck;
+ return FWL_Error::Succeeded;
+}
+
+uint32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckState(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem) {
+ return static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState;
+}
+
+FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckState(
+ IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ uint32_t dwCheckState) {
+ static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState = dwCheckState;
+ return FWL_Error::Succeeded;
+}
+
+CFWL_ListItem::CFWL_ListItem() {
+ m_rtItem.Reset();
+ m_dwStates = 0;
+ m_wsText = L"";
+ m_pDIB = nullptr;
+ m_pData = nullptr;
+ m_dwCheckState = 0;
+ m_rtCheckBox.Reset();
+}
+
+CFWL_ListItem::~CFWL_ListItem() {}
diff --git a/xfa/fwl/core/cfwl_listbox.h b/xfa/fwl/core/cfwl_listbox.h
new file mode 100644
index 0000000000..52caaeaea9
--- /dev/null
+++ b/xfa/fwl/core/cfwl_listbox.h
@@ -0,0 +1,123 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FWL_CORE_CFWL_LISTBOX_H_
+#define XFA_FWL_CORE_CFWL_LISTBOX_H_
+
+#include <memory>
+#include <vector>
+
+#include "xfa/fwl/core/cfwl_widget.h"
+#include "xfa/fwl/core/fwl_error.h"
+#include "xfa/fwl/core/ifwl_listbox.h"
+#include "xfa/fwl/core/ifwl_widget.h"
+
+class CFWL_ListItem;
+
+class CFWL_ListBox : public CFWL_Widget {
+ public:
+ CFWL_ListBox();
+ ~CFWL_ListBox() override;
+
+ IFWL_ListBox* GetWidget() override;
+ const IFWL_ListBox* GetWidget() const override;
+
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+ FWL_Error AddDIBitmap(CFX_DIBitmap* pDIB, IFWL_ListItem* pItem);
+ IFWL_ListItem* AddString(const CFX_WideStringC& wsAdd,
+ FX_BOOL bSelect = FALSE);
+ FX_BOOL DeleteString(IFWL_ListItem* pItem);
+ void DeleteAll();
+ int32_t CountSelItems();
+ IFWL_ListItem* GetSelItem(int32_t nIndexSel);
+ int32_t GetSelIndex(int32_t nIndex);
+ FWL_Error SetSelItem(IFWL_ListItem* pItem, FX_BOOL bSelect = TRUE);
+ FWL_Error GetItemText(IFWL_ListItem* pItem, CFX_WideString& wsText);
+ FWL_Error GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE);
+ FWL_Error SetItemHeight(FX_FLOAT fItemHeight);
+ IFWL_ListItem* GetFocusItem();
+ FWL_Error SetFocusItem(IFWL_ListItem* pItem);
+ int32_t CountItems();
+ IFWL_ListItem* GetItem(int32_t nIndex);
+ FWL_Error SetItemString(IFWL_ListItem* pItem, const CFX_WideStringC& wsText);
+ FWL_Error GetItemString(IFWL_ListItem* pItem, CFX_WideString& wsText);
+ FWL_Error SetItemData(IFWL_ListItem* pItem, void* pData);
+ void* GetItemData(IFWL_ListItem* pItem);
+ IFWL_ListItem* GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy);
+ uint32_t GetItemStates(IFWL_ListItem* pItem);
+
+ protected:
+ class CFWL_ListBoxDP : public IFWL_ListBoxDP {
+ public:
+ CFWL_ListBoxDP();
+ ~CFWL_ListBoxDP() override;
+
+ // IFWL_DataProvider:
+ FWL_Error GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) override;
+
+ // IFWL_ListBoxDP:
+ int32_t CountItems(const IFWL_Widget* pWidget) override;
+ IFWL_ListItem* GetItem(const IFWL_Widget* pWidget, int32_t nIndex) override;
+ int32_t GetItemIndex(IFWL_Widget* pWidget, IFWL_ListItem* pItem) override;
+ FX_BOOL SetItemIndex(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ int32_t nIndex) override;
+ uint32_t GetItemStyles(IFWL_Widget* pWidget, IFWL_ListItem* pItem) override;
+ FWL_Error GetItemText(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ CFX_WideString& wsText) override;
+ FWL_Error GetItemRect(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ CFX_RectF& rtItem) override;
+ void* GetItemData(IFWL_Widget* pWidget, IFWL_ListItem* pItem) override;
+ FWL_Error SetItemStyles(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ uint32_t dwStyle) override;
+ FWL_Error SetItemText(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ const FX_WCHAR* pszText) override;
+ FWL_Error SetItemRect(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ const CFX_RectF& rtItem) override;
+ FX_FLOAT GetItemHeight(IFWL_Widget* pWidget) override;
+ CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem) override;
+ FWL_Error GetItemCheckRect(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ CFX_RectF& rtCheck) override;
+ FWL_Error SetItemCheckRect(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ const CFX_RectF& rtCheck) override;
+ uint32_t GetItemCheckState(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem) override;
+ FWL_Error SetItemCheckState(IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem,
+ uint32_t dwCheckState) override;
+
+ std::vector<std::unique_ptr<CFWL_ListItem>> m_ItemArray;
+ CFX_WideString m_wsData;
+ FX_FLOAT m_fItemHeight;
+ };
+
+ CFWL_ListBoxDP m_ListBoxDP;
+};
+
+class CFWL_ListItem : public IFWL_ListItem {
+ public:
+ CFWL_ListItem();
+ ~CFWL_ListItem();
+
+ CFX_RectF m_rtItem;
+ uint32_t m_dwStates;
+ CFX_WideString m_wsText;
+ CFX_DIBitmap* m_pDIB;
+ void* m_pData;
+ uint32_t m_dwCheckState;
+ CFX_RectF m_rtCheckBox;
+};
+
+#endif // XFA_FWL_CORE_CFWL_LISTBOX_H_
diff --git a/xfa/fwl/core/cfwl_picturebox.cpp b/xfa/fwl/core/cfwl_picturebox.cpp
new file mode 100644
index 0000000000..92058a9818
--- /dev/null
+++ b/xfa/fwl/core/cfwl_picturebox.cpp
@@ -0,0 +1,156 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fwl/core/cfwl_picturebox.h"
+
+#include <memory>
+
+IFWL_PictureBox* CFWL_PictureBox::GetWidget() {
+ return static_cast<IFWL_PictureBox*>(m_pIface.get());
+}
+
+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;
+}
+
+FWL_Error CFWL_PictureBox::SetPicture(CFX_DIBitmap* pBitmap) {
+ m_PictureBoxDP.m_pBitmap = pBitmap;
+ return FWL_Error::Succeeded;
+}
+
+FX_FLOAT CFWL_PictureBox::GetRotation() {
+ return m_PictureBoxDP.m_fRotation;
+}
+
+FWL_Error CFWL_PictureBox::SetRotation(FX_FLOAT fRotation) {
+ m_PictureBoxDP.m_fRotation = fRotation;
+ return FWL_Error::Succeeded;
+}
+
+int32_t CFWL_PictureBox::GetFlipMode() {
+ return m_PictureBoxDP.GetFlipMode(m_pIface.get());
+}
+
+FWL_Error CFWL_PictureBox::SetFlipMode(int32_t iFlipMode) {
+ m_PictureBoxDP.m_iFlipMode = iFlipMode;
+ return FWL_Error::Succeeded;
+}
+
+int32_t CFWL_PictureBox::GetOpacity() {
+ return m_PictureBoxDP.GetOpacity(m_pIface.get());
+}
+
+FWL_Error CFWL_PictureBox::SetOpacity(int32_t iOpacity) {
+ m_PictureBoxDP.m_iOpacity = iOpacity;
+ return FWL_Error::Succeeded;
+}
+
+FWL_Error CFWL_PictureBox::GetScale(FX_FLOAT& fScaleX, FX_FLOAT& fScaleY) {
+ CFX_Matrix matrix;
+ m_PictureBoxDP.GetMatrix(m_pIface.get(), matrix);
+ matrix.Scale(fScaleX, fScaleY);
+ return FWL_Error::Succeeded;
+}
+
+FWL_Error CFWL_PictureBox::SetScale(FX_FLOAT fScaleX, FX_FLOAT fScaleY) {
+ m_PictureBoxDP.m_fScaleX = fScaleX;
+ m_PictureBoxDP.m_fScaleY = fScaleY;
+ return FWL_Error::Succeeded;
+}
+
+FWL_Error CFWL_PictureBox::GetOffset(FX_FLOAT& fx, FX_FLOAT& fy) {
+ CFX_Matrix matrix;
+ m_PictureBoxDP.GetMatrix(m_pIface.get(), matrix);
+ fx = matrix.e;
+ fy = matrix.f;
+ return FWL_Error::Succeeded;
+}
+
+FWL_Error CFWL_PictureBox::SetOffset(FX_FLOAT fx, FX_FLOAT fy) {
+ m_PictureBoxDP.m_fOffSetX = fx;
+ m_PictureBoxDP.m_fOffSetY = 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),
+ m_iFlipMode(0),
+ m_fRotation(0.0f),
+ m_fScaleX(1.0f),
+ m_fScaleY(1.0f),
+ m_fOffSetX(0.0f),
+ m_fOffSetY(0.0f) {}
+
+FWL_Error CFWL_PictureBox::CFWL_PictureBoxDP::GetCaption(
+ IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) {
+ return FWL_Error::Succeeded;
+}
+
+CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetPicture(
+ IFWL_Widget* pWidget) {
+ return m_pBitmap;
+}
+
+CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetErrorPicture(
+ IFWL_Widget* pWidget) {
+ return m_pBitmap;
+}
+
+CFX_DIBitmap* CFWL_PictureBox::CFWL_PictureBoxDP::GetInitialPicture(
+ IFWL_Widget* pWidget) {
+ return m_pBitmap;
+}
+
+int32_t CFWL_PictureBox::CFWL_PictureBoxDP::GetOpacity(IFWL_Widget* pWidget) {
+ return m_iOpacity;
+}
+
+FWL_Error CFWL_PictureBox::CFWL_PictureBoxDP::GetMatrix(IFWL_Widget* pWidget,
+ CFX_Matrix& matrix) {
+ CFX_RectF rect;
+ pWidget->GetClientRect(rect);
+ FX_FLOAT fLen = rect.width / 2;
+ FX_FLOAT fWid = rect.height / 2;
+ matrix.SetIdentity();
+ matrix.Translate(-fLen, -fWid);
+ matrix.Rotate(m_fRotation);
+ matrix.Translate(fLen, fWid);
+ matrix.Scale(m_fScaleX, m_fScaleY);
+ matrix.Translate(m_fOffSetX, m_fOffSetY);
+ return FWL_Error::Succeeded;
+}
+
+int32_t CFWL_PictureBox::CFWL_PictureBoxDP::GetFlipMode(IFWL_Widget* pWidget) {
+ return m_iFlipMode;
+}
diff --git a/xfa/fwl/core/cfwl_picturebox.h b/xfa/fwl/core/cfwl_picturebox.h
new file mode 100644
index 0000000000..584950f045
--- /dev/null
+++ b/xfa/fwl/core/cfwl_picturebox.h
@@ -0,0 +1,67 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FWL_CORE_CFWL_PICTUREBOX_H_
+#define XFA_FWL_CORE_CFWL_PICTUREBOX_H_
+
+#include "xfa/fwl/core/cfwl_widget.h"
+#include "xfa/fwl/core/fwl_error.h"
+#include "xfa/fwl/core/ifwl_picturebox.h"
+
+class CFWL_PictureBox : public CFWL_Widget {
+ public:
+ CFWL_PictureBox();
+ ~CFWL_PictureBox() override;
+
+ IFWL_PictureBox* GetWidget() override;
+ const IFWL_PictureBox* GetWidget() const override;
+
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+ CFX_DIBitmap* GetPicture();
+ FWL_Error SetPicture(CFX_DIBitmap* pBitmap);
+ FX_FLOAT GetRotation();
+ FWL_Error SetRotation(FX_FLOAT fRotation);
+ int32_t GetFlipMode();
+ FWL_Error SetFlipMode(int32_t iFlipMode);
+ int32_t GetOpacity();
+ FWL_Error SetOpacity(int32_t iOpacity);
+ FWL_Error GetScale(FX_FLOAT& fScaleX, FX_FLOAT& fScaleY);
+ FWL_Error SetScale(FX_FLOAT fScaleX, FX_FLOAT fScaleY);
+ FWL_Error GetOffset(FX_FLOAT& fx, FX_FLOAT& fy);
+ FWL_Error SetOffset(FX_FLOAT fx, FX_FLOAT fy);
+
+ protected:
+ class CFWL_PictureBoxDP : public IFWL_PictureBoxDP {
+ public:
+ CFWL_PictureBoxDP();
+
+ // IFWL_DataProvider
+ FWL_Error GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) override;
+
+ // IFWL_PictureBoxDP
+ CFX_DIBitmap* GetPicture(IFWL_Widget* pWidget) override;
+ CFX_DIBitmap* GetErrorPicture(IFWL_Widget* pWidget) override;
+ CFX_DIBitmap* GetInitialPicture(IFWL_Widget* pWidget) override;
+ int32_t GetOpacity(IFWL_Widget* pWidget) override;
+ int32_t GetFlipMode(IFWL_Widget* pWidget) override;
+ FWL_Error GetMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) override;
+
+ CFX_DIBitmap* m_pBitmap;
+ int32_t m_iOpacity;
+ int32_t m_iFlipMode;
+ FX_FLOAT m_fRotation;
+ FX_FLOAT m_fScaleX;
+ FX_FLOAT m_fScaleY;
+ FX_FLOAT m_fOffSetX;
+ FX_FLOAT m_fOffSetY;
+ CFX_WideString m_wsData;
+ };
+
+ CFWL_PictureBoxDP m_PictureBoxDP;
+};
+
+#endif // XFA_FWL_CORE_CFWL_PICTUREBOX_H_
diff --git a/xfa/fwl/core/cfwl_pushbutton.cpp b/xfa/fwl/core/cfwl_pushbutton.cpp
new file mode 100644
index 0000000000..8425f5de24
--- /dev/null
+++ b/xfa/fwl/core/cfwl_pushbutton.cpp
@@ -0,0 +1,70 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fwl/core/cfwl_pushbutton.h"
+
+#include <memory>
+
+IFWL_PushButton* CFWL_PushButton::GetWidget() {
+ return static_cast<IFWL_PushButton*>(m_pIface.get());
+}
+
+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;
+}
+
+FWL_Error CFWL_PushButton::SetCaption(const CFX_WideStringC& wsCaption) {
+ m_buttonData.m_wsCaption = wsCaption;
+ return FWL_Error::Succeeded;
+}
+
+CFX_DIBitmap* CFWL_PushButton::GetPicture() {
+ return m_buttonData.m_pBitmap;
+}
+
+FWL_Error CFWL_PushButton::SetPicture(CFX_DIBitmap* pBitmap) {
+ m_buttonData.m_pBitmap = 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) {
+ wsCaption = m_wsCaption;
+ return FWL_Error::Succeeded;
+}
+
+CFX_DIBitmap* CFWL_PushButton::CFWL_PushButtonDP::GetPicture(
+ IFWL_Widget* pWidget) {
+ return m_pBitmap;
+}
diff --git a/xfa/fwl/core/cfwl_pushbutton.h b/xfa/fwl/core/cfwl_pushbutton.h
new file mode 100644
index 0000000000..8f11660ce9
--- /dev/null
+++ b/xfa/fwl/core/cfwl_pushbutton.h
@@ -0,0 +1,46 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FWL_CORE_CFWL_PUSHBUTTON_H_
+#define XFA_FWL_CORE_CFWL_PUSHBUTTON_H_
+
+#include "xfa/fwl/core/cfwl_widget.h"
+#include "xfa/fwl/core/ifwl_pushbutton.h"
+
+class CFWL_PushButton : public CFWL_Widget {
+ public:
+ CFWL_PushButton();
+ ~CFWL_PushButton() override;
+
+ IFWL_PushButton* GetWidget() override;
+ const IFWL_PushButton* GetWidget() const override;
+
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+ FWL_Error GetCaption(CFX_WideString& wsCaption);
+ FWL_Error SetCaption(const CFX_WideStringC& wsCaption);
+ CFX_DIBitmap* GetPicture();
+ FWL_Error SetPicture(CFX_DIBitmap* pBitmap);
+
+ protected:
+ class CFWL_PushButtonDP : public IFWL_PushButtonDP {
+ public:
+ CFWL_PushButtonDP() : m_pBitmap(nullptr) {}
+
+ // IFWL_DataProvider
+ FWL_Error GetCaption(IFWL_Widget* pWidget,
+ CFX_WideString& wsCaption) override;
+
+ // IFWL_PushButtonDP
+ CFX_DIBitmap* GetPicture(IFWL_Widget* pWidget) override;
+
+ CFX_WideString m_wsCaption;
+ CFX_DIBitmap* m_pBitmap;
+ };
+
+ CFWL_PushButtonDP m_buttonData;
+};
+
+#endif // XFA_FWL_CORE_CFWL_PUSHBUTTON_H_
diff --git a/xfa/fwl/core/cfwl_widget.cpp b/xfa/fwl/core/cfwl_widget.cpp
new file mode 100644
index 0000000000..7f6bd3b07c
--- /dev/null
+++ b/xfa/fwl/core/cfwl_widget.cpp
@@ -0,0 +1,141 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fwl/core/cfwl_widget.h"
+
+#include "xfa/fde/tto/fde_textout.h"
+#include "xfa/fwl/core/cfwl_themetext.h"
+#include "xfa/fwl/core/cfwl_widgetmgr.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
+#include "xfa/fwl/core/ifwl_app.h"
+#include "xfa/fwl/core/ifwl_themeprovider.h"
+
+#define FWL_WGT_CalcHeight 2048
+#define FWL_WGT_CalcWidth 2048
+#define FWL_WGT_CalcMultiLineDefWidth 120.0f
+
+CFWL_Widget::CFWL_Widget()
+ : m_pDelegate(nullptr),
+ m_pWidgetMgr(CFWL_WidgetMgr::GetInstance()),
+ m_pProperties(new CFWL_WidgetProperties) {
+ ASSERT(m_pWidgetMgr);
+}
+
+CFWL_Widget::~CFWL_Widget() {
+ if (m_pIface)
+ m_pIface->Finalize();
+}
+
+IFWL_Widget* CFWL_Widget::GetWidget() {
+ return m_pIface.get();
+}
+
+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;
+ return m_pIface->GetWidgetRect(rect, bAutoSize);
+}
+
+FWL_Error CFWL_Widget::GetGlobalRect(CFX_RectF& rect) {
+ if (!m_pIface)
+ return FWL_Error::Indefinite;
+ return m_pIface->GetGlobalRect(rect);
+}
+
+FWL_Error CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) {
+ if (!m_pIface)
+ return FWL_Error::Indefinite;
+ return m_pIface->SetWidgetRect(rect);
+}
+
+FWL_Error CFWL_Widget::GetClientRect(CFX_RectF& rect) {
+ if (!m_pIface)
+ return FWL_Error::Indefinite;
+ return m_pIface->GetClientRect(rect);
+}
+
+FWL_Error CFWL_Widget::ModifyStyles(uint32_t dwStylesAdded,
+ uint32_t dwStylesRemoved) {
+ if (!m_pIface)
+ return FWL_Error::Indefinite;
+ return m_pIface->ModifyStyles(dwStylesAdded, dwStylesRemoved);
+}
+
+uint32_t CFWL_Widget::GetStylesEx() {
+ if (!m_pIface)
+ return 0;
+ return m_pIface->GetStylesEx();
+}
+
+FWL_Error CFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved) {
+ return m_pIface->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
+}
+
+uint32_t CFWL_Widget::GetStates() {
+ return m_pIface ? m_pIface->GetStates() : 0;
+}
+
+void CFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) {
+ if (m_pIface)
+ m_pIface->SetStates(dwStates, bSet);
+}
+
+void CFWL_Widget::SetLayoutItem(void* pItem) {
+ if (m_pIface)
+ m_pIface->SetLayoutItem(pItem);
+}
+
+void CFWL_Widget::Update() {
+ if (!m_pIface)
+ return;
+ m_pIface->Update();
+}
+
+void CFWL_Widget::LockUpdate() {
+ if (!m_pIface)
+ return;
+ m_pIface->LockUpdate();
+}
+
+void CFWL_Widget::UnlockUpdate() {
+ if (!m_pIface)
+ return;
+ m_pIface->UnlockUpdate();
+}
+
+FWL_WidgetHit CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+ if (!m_pIface)
+ return FWL_WidgetHit::Unknown;
+ return m_pIface->HitTest(fx, fy);
+}
+
+FWL_Error CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ if (!m_pIface)
+ return FWL_Error::Indefinite;
+ return m_pIface->DrawWidget(pGraphics, pMatrix);
+}
+
+IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) {
+ if (!m_pIface)
+ return nullptr;
+
+ m_pDelegate = m_pIface->SetDelegate(pDelegate);
+ return m_pDelegate;
+}
diff --git a/xfa/fwl/core/cfwl_widget.h b/xfa/fwl/core/cfwl_widget.h
new file mode 100644
index 0000000000..cc6967852f
--- /dev/null
+++ b/xfa/fwl/core/cfwl_widget.h
@@ -0,0 +1,65 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FWL_CORE_CFWL_WIDGET_H_
+#define XFA_FWL_CORE_CFWL_WIDGET_H_
+
+#include <memory>
+
+#include "xfa/fwl/core/cfwl_event.h"
+#include "xfa/fwl/core/cfwl_widgetproperties.h"
+#include "xfa/fwl/core/ifwl_widget.h"
+
+class CFWL_Event;
+class CFWL_Message;
+class CFWL_Widget;
+class CFWL_WidgetDelegate;
+class CFWL_WidgetMgr;
+
+class CFWL_Widget {
+ public:
+ CFWL_Widget();
+ virtual ~CFWL_Widget();
+
+ virtual IFWL_Widget* GetWidget();
+ virtual const IFWL_Widget* GetWidget() const;
+
+ FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
+ FWL_Error SetWidgetRect(const CFX_RectF& rect);
+ FWL_Error GetGlobalRect(CFX_RectF& rect);
+ FWL_Error GetClientRect(CFX_RectF& rtClient);
+
+ FWL_Error ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved);
+ uint32_t GetStylesEx();
+ FWL_Error ModifyStylesEx(uint32_t dwStylesExAdded,
+ uint32_t dwStylesExRemoved);
+
+ uint32_t GetStates();
+ void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE);
+
+ void SetLayoutItem(void* pItem);
+
+ void Update();
+ void LockUpdate();
+ void UnlockUpdate();
+
+ FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy);
+
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr);
+
+ IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate);
+
+ protected:
+ FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr);
+
+ std::unique_ptr<IFWL_Widget> m_pIface;
+ IFWL_WidgetDelegate* m_pDelegate;
+ CFWL_WidgetMgr* const m_pWidgetMgr;
+ std::unique_ptr<CFWL_WidgetProperties> m_pProperties;
+};
+
+#endif // XFA_FWL_CORE_CFWL_WIDGET_H_
diff --git a/xfa/fwl/core/cfwl_widgetproperties.cpp b/xfa/fwl/core/cfwl_widgetproperties.cpp
new file mode 100644
index 0000000000..fae1ff605a
--- /dev/null
+++ b/xfa/fwl/core/cfwl_widgetproperties.cpp
@@ -0,0 +1,39 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fwl/core/cfwl_widgetproperties.h"
+
+#include "xfa/fwl/core/cfwl_widget.h"
+
+CFWL_WidgetProperties::CFWL_WidgetProperties()
+ : m_dwStyles(FWL_WGTSTYLE_Child),
+ m_dwStyleExes(0),
+ m_dwStates(0),
+ m_pParent(nullptr),
+ m_pOwner(nullptr) {
+ m_rtWidget.Set(0, 0, 0, 0);
+}
+
+CFWL_WidgetProperties::~CFWL_WidgetProperties() {}
+
+CFWL_WidgetProperties::CFWL_WidgetProperties(
+ const CFWL_WidgetProperties& other) = default;
+
+CFWL_WidgetImpProperties CFWL_WidgetProperties::MakeWidgetImpProperties(
+ IFWL_DataProvider* pDataProvider) const {
+ CFWL_WidgetImpProperties result;
+ result.m_ctmOnParent = m_ctmOnParent;
+ result.m_rtWidget = m_rtWidget;
+ result.m_dwStyles = m_dwStyles;
+ result.m_dwStyleExes = m_dwStyleExes;
+ result.m_dwStates = m_dwStates;
+ if (m_pParent)
+ result.m_pParent = m_pParent->GetWidget();
+ if (m_pOwner)
+ result.m_pOwner = m_pOwner->GetWidget();
+ result.m_pDataProvider = pDataProvider;
+ return result;
+}
diff --git a/xfa/fwl/core/cfwl_widgetproperties.h b/xfa/fwl/core/cfwl_widgetproperties.h
new file mode 100644
index 0000000000..afadfc49f1
--- /dev/null
+++ b/xfa/fwl/core/cfwl_widgetproperties.h
@@ -0,0 +1,37 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FWL_CORE_CFWL_WIDGETPROPERTIES_H_
+#define XFA_FWL_CORE_CFWL_WIDGETPROPERTIES_H_
+
+#include "core/fxcrt/fx_coordinates.h"
+#include "core/fxcrt/fx_string.h"
+#include "core/fxcrt/fx_system.h"
+#include "xfa/fwl/core/cfwl_widgetimpproperties.h"
+
+class CFWL_Widget;
+class IFWL_DataProvider;
+
+class CFWL_WidgetProperties {
+ public:
+ CFWL_WidgetProperties();
+ ~CFWL_WidgetProperties();
+ CFWL_WidgetProperties(const CFWL_WidgetProperties& other);
+
+ CFWL_WidgetImpProperties MakeWidgetImpProperties(
+ IFWL_DataProvider* pDataProvider) const;
+
+ CFX_WideString m_wsWindowclass;
+ CFX_Matrix m_ctmOnParent;
+ CFX_RectF m_rtWidget;
+ uint32_t m_dwStyles;
+ uint32_t m_dwStyleExes;
+ uint32_t m_dwStates;
+ CFWL_Widget* m_pParent;
+ CFWL_Widget* m_pOwner;
+};
+
+#endif // XFA_FWL_CORE_CFWL_WIDGETPROPERTIES_H_
diff --git a/xfa/fwl/core/ifwl_edit.h b/xfa/fwl/core/ifwl_edit.h
index e327a2509f..7c0c451cf9 100644
--- a/xfa/fwl/core/ifwl_edit.h
+++ b/xfa/fwl/core/ifwl_edit.h
@@ -14,9 +14,9 @@
#include "xfa/fde/ifde_txtedtdorecord.h"
#include "xfa/fde/ifde_txtedtengine.h"
#include "xfa/fwl/core/cfwl_event.h"
+#include "xfa/fwl/core/cfwl_widget.h"
#include "xfa/fwl/core/ifwl_dataprovider.h"
#include "xfa/fwl/core/ifwl_scrollbar.h"
-#include "xfa/fwl/lightwidget/cfwl_widget.h"
#include "xfa/fxgraphics/cfx_path.h"
#define FWL_STYLEEXT_EDT_ReadOnly (1L << 0)
diff --git a/xfa/fwl/core/ifwl_picturebox.cpp b/xfa/fwl/core/ifwl_picturebox.cpp
index 301c404767..3539e08b0b 100644
--- a/xfa/fwl/core/ifwl_picturebox.cpp
+++ b/xfa/fwl/core/ifwl_picturebox.cpp
@@ -6,8 +6,8 @@
#include "xfa/fwl/core/ifwl_picturebox.h"
+#include "xfa/fwl/core/cfwl_picturebox.h"
#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/lightwidget/cfwl_picturebox.h"
IFWL_PictureBox::IFWL_PictureBox(const CFWL_WidgetImpProperties& properties)
: IFWL_Widget(properties, nullptr),