From 7f432a1c87014d6673ee69ff0ffa3724f237acf4 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Tue, 29 Mar 2016 12:38:01 -0700 Subject: Move xfa/include/fwl/{theme,lightwidget} to xfa/fwl This CL moves and splits the remaining FWL files out of xfa/include and into their proper locations. Review URL: https://codereview.chromium.org/1834323003 --- xfa/fwl/basewidget/fwl_pictureboximp.cpp | 2 +- xfa/fwl/basewidget/ifwl_edit.h | 2 +- xfa/fwl/core/ifwl_widgetdelegate.h | 2 +- xfa/fwl/lightwidget/app.cpp | 33 - xfa/fwl/lightwidget/barcode.cpp | 45 -- xfa/fwl/lightwidget/caret.cpp | 48 -- xfa/fwl/lightwidget/cfwl_app.cpp | 35 + xfa/fwl/lightwidget/cfwl_app.h | 31 + xfa/fwl/lightwidget/cfwl_barcode.cpp | 50 ++ xfa/fwl/lightwidget/cfwl_barcode.h | 120 ++++ xfa/fwl/lightwidget/cfwl_caret.cpp | 55 ++ xfa/fwl/lightwidget/cfwl_caret.h | 28 + xfa/fwl/lightwidget/cfwl_checkbox.cpp | 67 ++ xfa/fwl/lightwidget/cfwl_checkbox.h | 38 ++ xfa/fwl/lightwidget/cfwl_combobox.cpp | 432 +++++++++++++ xfa/fwl/lightwidget/cfwl_combobox.h | 143 ++++ xfa/fwl/lightwidget/cfwl_datetimepicker.cpp | 171 +++++ xfa/fwl/lightwidget/cfwl_datetimepicker.h | 61 ++ xfa/fwl/lightwidget/cfwl_edit.cpp | 250 +++++++ xfa/fwl/lightwidget/cfwl_edit.h | 67 ++ xfa/fwl/lightwidget/cfwl_listbox.cpp | 347 ++++++++++ xfa/fwl/lightwidget/cfwl_listbox.h | 127 ++++ xfa/fwl/lightwidget/cfwl_picturebox.cpp | 141 ++++ xfa/fwl/lightwidget/cfwl_picturebox.h | 64 ++ xfa/fwl/lightwidget/cfwl_pushbutton.cpp | 65 ++ xfa/fwl/lightwidget/cfwl_pushbutton.h | 36 ++ xfa/fwl/lightwidget/cfwl_scrollbar.cpp | 108 ++++ xfa/fwl/lightwidget/cfwl_scrollbar.h | 32 + xfa/fwl/lightwidget/cfwl_theme.cpp | 138 ++++ xfa/fwl/lightwidget/cfwl_theme.h | 59 ++ xfa/fwl/lightwidget/cfwl_tooltip.cpp | 134 ++++ xfa/fwl/lightwidget/cfwl_tooltip.h | 53 ++ xfa/fwl/lightwidget/cfwl_widget.cpp | 331 ++++++++++ xfa/fwl/lightwidget/cfwl_widget.h | 76 +++ xfa/fwl/lightwidget/cfwl_widgetdelegate.cpp | 27 + xfa/fwl/lightwidget/cfwl_widgetdelegate.h | 29 + xfa/fwl/lightwidget/cfwl_widgetproperties.cpp | 25 + xfa/fwl/lightwidget/cfwl_widgetproperties.h | 42 ++ xfa/fwl/lightwidget/checkbox.cpp | 57 -- xfa/fwl/lightwidget/combobox.cpp | 370 ----------- xfa/fwl/lightwidget/datetimepicker.cpp | 143 ---- xfa/fwl/lightwidget/edit.cpp | 211 ------ xfa/fwl/lightwidget/listbox.cpp | 302 --------- xfa/fwl/lightwidget/picturebox.cpp | 119 ---- xfa/fwl/lightwidget/pushbutton.cpp | 56 -- xfa/fwl/lightwidget/scrollbar.cpp | 93 --- xfa/fwl/lightwidget/theme.cpp | 138 ---- xfa/fwl/lightwidget/tooltipctrl.cpp | 111 ---- xfa/fwl/lightwidget/widget.cpp | 319 --------- xfa/fwl/theme/barcodetp.cpp | 42 -- xfa/fwl/theme/carettp.cpp | 52 -- xfa/fwl/theme/cfwl_barcodetp.cpp | 44 ++ xfa/fwl/theme/cfwl_barcodetp.h | 21 + xfa/fwl/theme/cfwl_carettp.cpp | 52 ++ xfa/fwl/theme/cfwl_carettp.h | 27 + xfa/fwl/theme/cfwl_checkboxtp.cpp | 536 +++++++++++++++ xfa/fwl/theme/cfwl_checkboxtp.h | 84 +++ xfa/fwl/theme/cfwl_comboboxtp.cpp | 160 +++++ xfa/fwl/theme/cfwl_comboboxtp.h | 29 + xfa/fwl/theme/cfwl_datetimepickedtp.cpp | 141 ++++ xfa/fwl/theme/cfwl_datetimepickertp.h | 27 + xfa/fwl/theme/cfwl_edittp.cpp | 92 +++ xfa/fwl/theme/cfwl_edittp.h | 22 + xfa/fwl/theme/cfwl_formtp.cpp | 899 ++++++++++++++++++++++++++ xfa/fwl/theme/cfwl_formtp.h | 111 ++++ xfa/fwl/theme/cfwl_listboxtp.cpp | 104 +++ xfa/fwl/theme/cfwl_listboxtp.h | 29 + xfa/fwl/theme/cfwl_monthcalendartp.cpp | 587 +++++++++++++++++ xfa/fwl/theme/cfwl_monthcalendartp.h | 51 ++ xfa/fwl/theme/cfwl_pictureboxtp.cpp | 38 ++ xfa/fwl/theme/cfwl_pictureboxtp.h | 20 + xfa/fwl/theme/cfwl_pushbuttontp.cpp | 161 +++++ xfa/fwl/theme/cfwl_pushbuttontp.h | 46 ++ xfa/fwl/theme/cfwl_scrollbartp.cpp | 381 +++++++++++ xfa/fwl/theme/cfwl_scrollbartp.h | 60 ++ xfa/fwl/theme/cfwl_utils.h | 75 +++ xfa/fwl/theme/cfwl_widgettp.cpp | 846 ++++++++++++++++++++++++ xfa/fwl/theme/cfwl_widgettp.h | 220 +++++++ xfa/fwl/theme/checkboxtp.cpp | 536 --------------- xfa/fwl/theme/comboboxtp.cpp | 160 ----- xfa/fwl/theme/datetimepickertp.cpp | 139 ---- xfa/fwl/theme/edittp.cpp | 92 --- xfa/fwl/theme/formtp.cpp | 899 -------------------------- xfa/fwl/theme/listboxtp.cpp | 104 --- xfa/fwl/theme/monthcalendartp.cpp | 587 ----------------- xfa/fwl/theme/pictureboxtp.cpp | 38 -- xfa/fwl/theme/pushbuttontp.cpp | 161 ----- xfa/fwl/theme/scrollbartp.cpp | 381 ----------- xfa/fwl/theme/widgettp.cpp | 846 ------------------------ xfa/fxfa/app/xfa_ffbarcode.cpp | 2 +- xfa/fxfa/app/xfa_ffcheckbutton.cpp | 2 +- xfa/fxfa/app/xfa_ffchoicelist.cpp | 4 +- xfa/fxfa/app/xfa_fffield.cpp | 4 +- xfa/fxfa/app/xfa_fffield.h | 2 +- xfa/fxfa/app/xfa_ffimageedit.cpp | 2 +- xfa/fxfa/app/xfa_ffpushbutton.cpp | 2 +- xfa/fxfa/app/xfa_fftextedit.cpp | 4 +- xfa/fxfa/app/xfa_fwltheme.h | 24 +- xfa/include/fwl/lightwidget/app.h | 31 - xfa/include/fwl/lightwidget/barcode.h | 120 ---- xfa/include/fwl/lightwidget/caret.h | 28 - xfa/include/fwl/lightwidget/checkbox.h | 38 -- xfa/include/fwl/lightwidget/combobox.h | 144 ----- xfa/include/fwl/lightwidget/datetimepicker.h | 61 -- xfa/include/fwl/lightwidget/edit.h | 67 -- xfa/include/fwl/lightwidget/listbox.h | 127 ---- xfa/include/fwl/lightwidget/picturebox.h | 64 -- xfa/include/fwl/lightwidget/pushbutton.h | 36 -- xfa/include/fwl/lightwidget/scrollbar.h | 32 - xfa/include/fwl/lightwidget/theme.h | 59 -- xfa/include/fwl/lightwidget/tooltipctrl.h | 53 -- xfa/include/fwl/lightwidget/widget.h | 110 ---- xfa/include/fwl/theme/barcodetp.h | 21 - xfa/include/fwl/theme/carettp.h | 27 - xfa/include/fwl/theme/checkboxtp.h | 84 --- xfa/include/fwl/theme/comboboxtp.h | 29 - xfa/include/fwl/theme/datetimepickertp.h | 27 - xfa/include/fwl/theme/edittp.h | 22 - xfa/include/fwl/theme/formtp.h | 111 ---- xfa/include/fwl/theme/listboxtp.h | 29 - xfa/include/fwl/theme/monthcalendartp.h | 51 -- xfa/include/fwl/theme/pictureboxtp.h | 20 - xfa/include/fwl/theme/pushbuttontp.h | 44 -- xfa/include/fwl/theme/scrollbartp.h | 57 -- xfa/include/fwl/theme/utils.h | 75 --- xfa/include/fwl/theme/widgettp.h | 220 ------- 126 files changed, 8271 insertions(+), 7895 deletions(-) delete mode 100644 xfa/fwl/lightwidget/app.cpp delete mode 100644 xfa/fwl/lightwidget/barcode.cpp delete mode 100644 xfa/fwl/lightwidget/caret.cpp create mode 100644 xfa/fwl/lightwidget/cfwl_app.cpp create mode 100644 xfa/fwl/lightwidget/cfwl_app.h create mode 100644 xfa/fwl/lightwidget/cfwl_barcode.cpp create mode 100644 xfa/fwl/lightwidget/cfwl_barcode.h create mode 100644 xfa/fwl/lightwidget/cfwl_caret.cpp create mode 100644 xfa/fwl/lightwidget/cfwl_caret.h create mode 100644 xfa/fwl/lightwidget/cfwl_checkbox.cpp create mode 100644 xfa/fwl/lightwidget/cfwl_checkbox.h create mode 100644 xfa/fwl/lightwidget/cfwl_combobox.cpp create mode 100644 xfa/fwl/lightwidget/cfwl_combobox.h create mode 100644 xfa/fwl/lightwidget/cfwl_datetimepicker.cpp create mode 100644 xfa/fwl/lightwidget/cfwl_datetimepicker.h create mode 100644 xfa/fwl/lightwidget/cfwl_edit.cpp create mode 100644 xfa/fwl/lightwidget/cfwl_edit.h create mode 100644 xfa/fwl/lightwidget/cfwl_listbox.cpp create mode 100644 xfa/fwl/lightwidget/cfwl_listbox.h create mode 100644 xfa/fwl/lightwidget/cfwl_picturebox.cpp create mode 100644 xfa/fwl/lightwidget/cfwl_picturebox.h create mode 100644 xfa/fwl/lightwidget/cfwl_pushbutton.cpp create mode 100644 xfa/fwl/lightwidget/cfwl_pushbutton.h create mode 100644 xfa/fwl/lightwidget/cfwl_scrollbar.cpp create mode 100644 xfa/fwl/lightwidget/cfwl_scrollbar.h create mode 100644 xfa/fwl/lightwidget/cfwl_theme.cpp create mode 100644 xfa/fwl/lightwidget/cfwl_theme.h create mode 100644 xfa/fwl/lightwidget/cfwl_tooltip.cpp create mode 100644 xfa/fwl/lightwidget/cfwl_tooltip.h create mode 100644 xfa/fwl/lightwidget/cfwl_widget.cpp create mode 100644 xfa/fwl/lightwidget/cfwl_widget.h create mode 100644 xfa/fwl/lightwidget/cfwl_widgetdelegate.cpp create mode 100644 xfa/fwl/lightwidget/cfwl_widgetdelegate.h create mode 100644 xfa/fwl/lightwidget/cfwl_widgetproperties.cpp create mode 100644 xfa/fwl/lightwidget/cfwl_widgetproperties.h delete mode 100644 xfa/fwl/lightwidget/checkbox.cpp delete mode 100644 xfa/fwl/lightwidget/combobox.cpp delete mode 100644 xfa/fwl/lightwidget/datetimepicker.cpp delete mode 100644 xfa/fwl/lightwidget/edit.cpp delete mode 100644 xfa/fwl/lightwidget/listbox.cpp delete mode 100644 xfa/fwl/lightwidget/picturebox.cpp delete mode 100644 xfa/fwl/lightwidget/pushbutton.cpp delete mode 100644 xfa/fwl/lightwidget/scrollbar.cpp delete mode 100644 xfa/fwl/lightwidget/theme.cpp delete mode 100644 xfa/fwl/lightwidget/tooltipctrl.cpp delete mode 100644 xfa/fwl/lightwidget/widget.cpp delete mode 100644 xfa/fwl/theme/barcodetp.cpp delete mode 100644 xfa/fwl/theme/carettp.cpp create mode 100644 xfa/fwl/theme/cfwl_barcodetp.cpp create mode 100644 xfa/fwl/theme/cfwl_barcodetp.h create mode 100644 xfa/fwl/theme/cfwl_carettp.cpp create mode 100644 xfa/fwl/theme/cfwl_carettp.h create mode 100644 xfa/fwl/theme/cfwl_checkboxtp.cpp create mode 100644 xfa/fwl/theme/cfwl_checkboxtp.h create mode 100644 xfa/fwl/theme/cfwl_comboboxtp.cpp create mode 100644 xfa/fwl/theme/cfwl_comboboxtp.h create mode 100644 xfa/fwl/theme/cfwl_datetimepickedtp.cpp create mode 100644 xfa/fwl/theme/cfwl_datetimepickertp.h create mode 100644 xfa/fwl/theme/cfwl_edittp.cpp create mode 100644 xfa/fwl/theme/cfwl_edittp.h create mode 100644 xfa/fwl/theme/cfwl_formtp.cpp create mode 100644 xfa/fwl/theme/cfwl_formtp.h create mode 100644 xfa/fwl/theme/cfwl_listboxtp.cpp create mode 100644 xfa/fwl/theme/cfwl_listboxtp.h create mode 100644 xfa/fwl/theme/cfwl_monthcalendartp.cpp create mode 100644 xfa/fwl/theme/cfwl_monthcalendartp.h create mode 100644 xfa/fwl/theme/cfwl_pictureboxtp.cpp create mode 100644 xfa/fwl/theme/cfwl_pictureboxtp.h create mode 100644 xfa/fwl/theme/cfwl_pushbuttontp.cpp create mode 100644 xfa/fwl/theme/cfwl_pushbuttontp.h create mode 100644 xfa/fwl/theme/cfwl_scrollbartp.cpp create mode 100644 xfa/fwl/theme/cfwl_scrollbartp.h create mode 100644 xfa/fwl/theme/cfwl_utils.h create mode 100644 xfa/fwl/theme/cfwl_widgettp.cpp create mode 100644 xfa/fwl/theme/cfwl_widgettp.h delete mode 100644 xfa/fwl/theme/checkboxtp.cpp delete mode 100644 xfa/fwl/theme/comboboxtp.cpp delete mode 100644 xfa/fwl/theme/datetimepickertp.cpp delete mode 100644 xfa/fwl/theme/edittp.cpp delete mode 100644 xfa/fwl/theme/formtp.cpp delete mode 100644 xfa/fwl/theme/listboxtp.cpp delete mode 100644 xfa/fwl/theme/monthcalendartp.cpp delete mode 100644 xfa/fwl/theme/pictureboxtp.cpp delete mode 100644 xfa/fwl/theme/pushbuttontp.cpp delete mode 100644 xfa/fwl/theme/scrollbartp.cpp delete mode 100644 xfa/fwl/theme/widgettp.cpp delete mode 100644 xfa/include/fwl/lightwidget/app.h delete mode 100644 xfa/include/fwl/lightwidget/barcode.h delete mode 100644 xfa/include/fwl/lightwidget/caret.h delete mode 100644 xfa/include/fwl/lightwidget/checkbox.h delete mode 100644 xfa/include/fwl/lightwidget/combobox.h delete mode 100644 xfa/include/fwl/lightwidget/datetimepicker.h delete mode 100644 xfa/include/fwl/lightwidget/edit.h delete mode 100644 xfa/include/fwl/lightwidget/listbox.h delete mode 100644 xfa/include/fwl/lightwidget/picturebox.h delete mode 100644 xfa/include/fwl/lightwidget/pushbutton.h delete mode 100644 xfa/include/fwl/lightwidget/scrollbar.h delete mode 100644 xfa/include/fwl/lightwidget/theme.h delete mode 100644 xfa/include/fwl/lightwidget/tooltipctrl.h delete mode 100644 xfa/include/fwl/lightwidget/widget.h delete mode 100644 xfa/include/fwl/theme/barcodetp.h delete mode 100644 xfa/include/fwl/theme/carettp.h delete mode 100644 xfa/include/fwl/theme/checkboxtp.h delete mode 100644 xfa/include/fwl/theme/comboboxtp.h delete mode 100644 xfa/include/fwl/theme/datetimepickertp.h delete mode 100644 xfa/include/fwl/theme/edittp.h delete mode 100644 xfa/include/fwl/theme/formtp.h delete mode 100644 xfa/include/fwl/theme/listboxtp.h delete mode 100644 xfa/include/fwl/theme/monthcalendartp.h delete mode 100644 xfa/include/fwl/theme/pictureboxtp.h delete mode 100644 xfa/include/fwl/theme/pushbuttontp.h delete mode 100644 xfa/include/fwl/theme/scrollbartp.h delete mode 100644 xfa/include/fwl/theme/utils.h delete mode 100644 xfa/include/fwl/theme/widgettp.h (limited to 'xfa') diff --git a/xfa/fwl/basewidget/fwl_pictureboximp.cpp b/xfa/fwl/basewidget/fwl_pictureboximp.cpp index f1b72b8ee4..2787423d6e 100644 --- a/xfa/fwl/basewidget/fwl_pictureboximp.cpp +++ b/xfa/fwl/basewidget/fwl_pictureboximp.cpp @@ -9,7 +9,7 @@ #include "xfa/fwl/core/fwl_noteimp.h" #include "xfa/fwl/core/fwl_targetimp.h" #include "xfa/fwl/core/fwl_widgetimp.h" -#include "xfa/include/fwl/lightwidget/picturebox.h" +#include "xfa/fwl/lightwidget/cfwl_picturebox.h" // static IFWL_PictureBox* IFWL_PictureBox::Create( diff --git a/xfa/fwl/basewidget/ifwl_edit.h b/xfa/fwl/basewidget/ifwl_edit.h index f77714122d..b27f8b4898 100644 --- a/xfa/fwl/basewidget/ifwl_edit.h +++ b/xfa/fwl/basewidget/ifwl_edit.h @@ -9,8 +9,8 @@ #include -#include "xfa/include/fwl/lightwidget/widget.h" #include "xfa/fwl/core/ifwl_dataprovider.h" +#include "xfa/fwl/lightwidget/cfwl_widget.h" #define FWL_CLASS_Edit L"FWL_EDIT" #define FWL_CLASSHASH_Edit 2893987822 diff --git a/xfa/fwl/core/ifwl_widgetdelegate.h b/xfa/fwl/core/ifwl_widgetdelegate.h index eeca68e8bc..7fb56d3ba1 100644 --- a/xfa/fwl/core/ifwl_widgetdelegate.h +++ b/xfa/fwl/core/ifwl_widgetdelegate.h @@ -20,7 +20,7 @@ class IFWL_WidgetDelegate { virtual int32_t OnProcessMessage(CFWL_Message* pMessage) = 0; virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent) = 0; virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = NULL) = 0; + const CFX_Matrix* pMatrix = nullptr) = 0; }; #endif // XFA_FWL_CORE_IFWL_WIDGETDELEGATE_H_ diff --git a/xfa/fwl/lightwidget/app.cpp b/xfa/fwl/lightwidget/app.cpp deleted file mode 100644 index 1d5b7d6f8f..0000000000 --- a/xfa/fwl/lightwidget/app.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// 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/include/fwl/lightwidget/app.h" - -#include "core/fxcrt/include/fx_coordinates.h" -#include "xfa/fwl/core/fwl_error.h" -#include "xfa/fwl/core/ifwl_app.h" -#include "xfa/include/fwl/lightwidget/theme.h" - -CFWL_App::CFWL_App() : m_pIface(IFWL_App::Create(nullptr)), m_pTheme(nullptr) {} -CFWL_App::~CFWL_App() { - if (m_pTheme) { - m_pTheme->Finalize(); - delete m_pTheme; - m_pTheme = NULL; - } - m_pIface->Release(); -} -FWL_ERR CFWL_App::Initialize() { - m_pTheme = new CFWL_Theme; - m_pTheme->Initialize(); - m_pIface->SetThemeProvider(m_pTheme); - return m_pIface->Initialize(); -} -FWL_ERR CFWL_App::Exit(int32_t iExitCode) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->Exit(iExitCode); -} diff --git a/xfa/fwl/lightwidget/barcode.cpp b/xfa/fwl/lightwidget/barcode.cpp deleted file mode 100644 index 4f05837352..0000000000 --- a/xfa/fwl/lightwidget/barcode.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// 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/include/fwl/lightwidget/barcode.h" - -#include - -CFWL_Barcode* CFWL_Barcode::Create() { - return new CFWL_Barcode; -} -FWL_ERR CFWL_Barcode::Initialize(const CFWL_WidgetProperties* pProperties) { - if (m_pIface) - return FWL_ERR_Indefinite; - if (pProperties) { - *m_pProperties = *pProperties; - } - std::unique_ptr pBarcode(IFWL_Barcode::Create( - m_pProperties->MakeWidgetImpProperties(&m_barcodeData))); - FWL_ERR ret = pBarcode->Initialize(); - if (ret != FWL_ERR_Succeeded) { - return ret; - } - m_pIface = pBarcode.release(); - CFWL_Widget::Initialize(); - return FWL_ERR_Succeeded; -} -CFWL_Barcode::CFWL_Barcode() {} -CFWL_Barcode::~CFWL_Barcode() {} -void CFWL_Barcode::SetType(BC_TYPE type) { - if (!m_pIface) - return; - static_cast(m_pIface)->SetType(type); -} -FX_BOOL CFWL_Barcode::IsProtectedType() { - if (!m_pIface) - return 0; - return static_cast(m_pIface)->IsProtectedType(); -} -FWL_ERR CFWL_Barcode::CFWL_BarcodeDP::GetCaption(IFWL_Widget* pWidget, - CFX_WideString& wsCaption) { - return FWL_ERR_Succeeded; -} diff --git a/xfa/fwl/lightwidget/caret.cpp b/xfa/fwl/lightwidget/caret.cpp deleted file mode 100644 index 9c2b90b22a..0000000000 --- a/xfa/fwl/lightwidget/caret.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// 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/include/fwl/lightwidget/caret.h" - -#include - -#include "xfa/fwl/basewidget/ifwl_caret.h" -#include "xfa/fwl/core/fwl_targetimp.h" -#include "xfa/fxgraphics/cfx_color.h" -#include "xfa/include/fwl/lightwidget/edit.h" - -CFWL_Caret* CFWL_Caret::Create() { - return new CFWL_Caret; -} -FWL_ERR CFWL_Caret::Initialize(const CFWL_WidgetProperties* pProperties) { - if (m_pIface) - return FWL_ERR_Indefinite; - if (pProperties) { - *m_pProperties = *pProperties; - } - std::unique_ptr pCaret(IFWL_Caret::Create( - m_pProperties->MakeWidgetImpProperties(nullptr), nullptr)); - FWL_ERR ret = pCaret->Initialize(); - if (ret != FWL_ERR_Succeeded) { - return ret; - } - m_pIface = pCaret.release(); - CFWL_Widget::Initialize(); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_Caret::ShowCaret(FX_BOOL bFlag) { - return static_cast(m_pIface)->ShowCaret(bFlag); -} -FWL_ERR CFWL_Caret::GetFrequency(uint32_t& elapse) { - return static_cast(m_pIface)->GetFrequency(elapse); -} -FWL_ERR CFWL_Caret::SetFrequency(uint32_t elapse) { - return static_cast(m_pIface)->SetFrequency(elapse); -} -FWL_ERR CFWL_Caret::SetColor(CFX_Color crFill) { - return static_cast(m_pIface)->SetColor(crFill); -} -CFWL_Caret::CFWL_Caret() {} -CFWL_Caret::~CFWL_Caret() {} diff --git a/xfa/fwl/lightwidget/cfwl_app.cpp b/xfa/fwl/lightwidget/cfwl_app.cpp new file mode 100644 index 0000000000..c09e5c0a26 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_app.cpp @@ -0,0 +1,35 @@ +// 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/lightwidget/cfwl_app.h" + +#include "core/fxcrt/include/fx_coordinates.h" +#include "xfa/fwl/core/fwl_error.h" +#include "xfa/fwl/core/ifwl_app.h" +#include "xfa/fwl/lightwidget/cfwl_theme.h" + +CFWL_App::CFWL_App() : m_pIface(IFWL_App::Create(nullptr)), m_pTheme(nullptr) {} + +CFWL_App::~CFWL_App() { + if (m_pTheme) { + m_pTheme->Finalize(); + delete m_pTheme; + } + m_pIface->Release(); +} + +FWL_ERR CFWL_App::Initialize() { + m_pTheme = new CFWL_Theme; + m_pTheme->Initialize(); + m_pIface->SetThemeProvider(m_pTheme); + return m_pIface->Initialize(); +} + +FWL_ERR CFWL_App::Exit(int32_t iExitCode) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->Exit(iExitCode); +} diff --git a/xfa/fwl/lightwidget/cfwl_app.h b/xfa/fwl/lightwidget/cfwl_app.h new file mode 100644 index 0000000000..24cbd5abb4 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_app.h @@ -0,0 +1,31 @@ +// 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_LIGHTWIDGET_CFWL_APP_H_ +#define XFA_FWL_LIGHTWIDGET_CFWL_APP_H_ + +#include "xfa/fwl/core/fwl_error.h" + +class CFWL_Theme; +class IFWL_App; + +class CFWL_App { + public: + CFWL_App(); + virtual ~CFWL_App(); + + FWL_ERR Initialize(); + FWL_ERR Exit(int32_t iExitCode); + + CFWL_Theme* GetTheme() const { return m_pTheme; } + IFWL_App* GetInterface() const { return m_pIface; } + + private: + IFWL_App* m_pIface; + CFWL_Theme* m_pTheme; +}; + +#endif // XFA_FWL_LIGHTWIDGET_CFWL_APP_H_ diff --git a/xfa/fwl/lightwidget/cfwl_barcode.cpp b/xfa/fwl/lightwidget/cfwl_barcode.cpp new file mode 100644 index 0000000000..4ac358ce54 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_barcode.cpp @@ -0,0 +1,50 @@ +// 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/lightwidget/cfwl_barcode.h" + +#include + +CFWL_Barcode* CFWL_Barcode::Create() { + return new CFWL_Barcode; +} + +FWL_ERR CFWL_Barcode::Initialize(const CFWL_WidgetProperties* pProperties) { + if (m_pIface) + return FWL_ERR_Indefinite; + if (pProperties) { + *m_pProperties = *pProperties; + } + std::unique_ptr pBarcode(IFWL_Barcode::Create( + m_pProperties->MakeWidgetImpProperties(&m_barcodeData))); + FWL_ERR ret = pBarcode->Initialize(); + if (ret != FWL_ERR_Succeeded) { + return ret; + } + m_pIface = pBarcode.release(); + CFWL_Widget::Initialize(); + return FWL_ERR_Succeeded; +} + +CFWL_Barcode::CFWL_Barcode() {} + +CFWL_Barcode::~CFWL_Barcode() {} + +void CFWL_Barcode::SetType(BC_TYPE type) { + if (!m_pIface) + return; + static_cast(m_pIface)->SetType(type); +} + +FX_BOOL CFWL_Barcode::IsProtectedType() { + if (!m_pIface) + return 0; + return static_cast(m_pIface)->IsProtectedType(); +} +FWL_ERR CFWL_Barcode::CFWL_BarcodeDP::GetCaption(IFWL_Widget* pWidget, + CFX_WideString& wsCaption) { + return FWL_ERR_Succeeded; +} diff --git a/xfa/fwl/lightwidget/cfwl_barcode.h b/xfa/fwl/lightwidget/cfwl_barcode.h new file mode 100644 index 0000000000..e1e7e658d5 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_barcode.h @@ -0,0 +1,120 @@ +// 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_LIGHTWIDGET_CFWL_BARCODE_H_ +#define XFA_FWL_LIGHTWIDGET_CFWL_BARCODE_H_ + +#include "xfa/fwl/basewidget/ifwl_barcode.h" +#include "xfa/fwl/core/fwl_error.h" +#include "xfa/fwl/lightwidget/cfwl_edit.h" + +class CFWL_Widget; +class CFWL_WidgetProperties; + +class CFWL_Barcode : public CFWL_Edit { + public: + static CFWL_Barcode* Create(); + FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); + 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; + static_cast(m_pIface)->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 = 0; } + + protected: + CFWL_Barcode(); + virtual ~CFWL_Barcode(); + + class CFWL_BarcodeDP : public IFWL_BarcodeDP { + public: + virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption); + BC_CHAR_ENCODING m_eCharEncoding; + virtual BC_CHAR_ENCODING GetCharEncoding() { return m_eCharEncoding; } + int32_t m_nModuleHeight, m_nModuleWidth; + virtual int32_t GetModuleHeight() { return m_nModuleHeight; } + virtual int32_t GetModuleWidth() { return m_nModuleWidth; } + int32_t m_nDataLength; + virtual int32_t GetDataLength() { return m_nDataLength; } + int32_t m_nCalChecksum; + virtual int32_t GetCalChecksum() { return m_nCalChecksum; } + FX_BOOL m_bPrintChecksum; + virtual FX_BOOL GetPrintChecksum() { return m_bPrintChecksum; } + + BC_TEXT_LOC m_eTextLocation; + virtual BC_TEXT_LOC GetTextLocation() { return m_eTextLocation; } + int32_t m_nWideNarrowRatio; + virtual int32_t GetWideNarrowRatio() { return m_nWideNarrowRatio; } + FX_CHAR m_cStartChar, m_cEndChar; + virtual FX_CHAR GetStartChar() { return m_cStartChar; } + virtual FX_CHAR GetEndChar() { return m_cEndChar; } + int32_t m_nVersion; + virtual int32_t GetVersion() { return m_nVersion; } + int32_t m_nECLevel; + virtual int32_t GetErrorCorrectionLevel() { return m_nECLevel; } + FX_BOOL m_bTruncated; + virtual FX_BOOL GetTruncated() { return m_bTruncated; } + uint32_t m_dwAttributeMask; + virtual uint32_t GetBarcodeAttributeMask() { return m_dwAttributeMask; } + + public: + CFWL_BarcodeDP() : m_dwAttributeMask(0) {} + }; + CFWL_BarcodeDP m_barcodeData; +}; + +#endif // XFA_FWL_LIGHTWIDGET_CFWL_BARCODE_H_ diff --git a/xfa/fwl/lightwidget/cfwl_caret.cpp b/xfa/fwl/lightwidget/cfwl_caret.cpp new file mode 100644 index 0000000000..7fea4f9e77 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_caret.cpp @@ -0,0 +1,55 @@ +// 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/lightwidget/cfwl_caret.h" + +#include + +#include "xfa/fwl/basewidget/ifwl_caret.h" +#include "xfa/fwl/core/fwl_targetimp.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fwl/lightwidget/cfwl_edit.h" + +CFWL_Caret* CFWL_Caret::Create() { + return new CFWL_Caret; +} + +FWL_ERR CFWL_Caret::Initialize(const CFWL_WidgetProperties* pProperties) { + if (m_pIface) + return FWL_ERR_Indefinite; + if (pProperties) { + *m_pProperties = *pProperties; + } + std::unique_ptr pCaret(IFWL_Caret::Create( + m_pProperties->MakeWidgetImpProperties(nullptr), nullptr)); + FWL_ERR ret = pCaret->Initialize(); + if (ret != FWL_ERR_Succeeded) { + return ret; + } + m_pIface = pCaret.release(); + CFWL_Widget::Initialize(); + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_Caret::ShowCaret(FX_BOOL bFlag) { + return static_cast(m_pIface)->ShowCaret(bFlag); +} + +FWL_ERR CFWL_Caret::GetFrequency(uint32_t& elapse) { + return static_cast(m_pIface)->GetFrequency(elapse); +} + +FWL_ERR CFWL_Caret::SetFrequency(uint32_t elapse) { + return static_cast(m_pIface)->SetFrequency(elapse); +} + +FWL_ERR CFWL_Caret::SetColor(CFX_Color crFill) { + return static_cast(m_pIface)->SetColor(crFill); +} + +CFWL_Caret::CFWL_Caret() {} + +CFWL_Caret::~CFWL_Caret() {} diff --git a/xfa/fwl/lightwidget/cfwl_caret.h b/xfa/fwl/lightwidget/cfwl_caret.h new file mode 100644 index 0000000000..c806f2eb73 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_caret.h @@ -0,0 +1,28 @@ +// 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_LIGHTWIDGET_CFWL_CARET_H_ +#define XFA_FWL_LIGHTWIDGET_CFWL_CARET_H_ + +#include "xfa/fwl/core/fwl_error.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fwl/lightwidget/cfwl_widget.h" + +class CFWL_Caret : public CFWL_Widget { + public: + static CFWL_Caret* Create(); + FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); + FWL_ERR ShowCaret(FX_BOOL bFlag = TRUE); + FWL_ERR GetFrequency(uint32_t& elapse); + FWL_ERR SetFrequency(uint32_t elapse); + FWL_ERR SetColor(CFX_Color crFill); + + protected: + CFWL_Caret(); + virtual ~CFWL_Caret(); +}; + +#endif // XFA_FWL_LIGHTWIDGET_CFWL_CARET_H_ diff --git a/xfa/fwl/lightwidget/cfwl_checkbox.cpp b/xfa/fwl/lightwidget/cfwl_checkbox.cpp new file mode 100644 index 0000000000..b5e2a87d67 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_checkbox.cpp @@ -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 + +#include "xfa/fwl/lightwidget/cfwl_checkbox.h" + +#include + +#include "xfa/fwl/core/fwl_error.h" + +CFWL_CheckBox* CFWL_CheckBox::Create() { + return new CFWL_CheckBox; +} + +FWL_ERR CFWL_CheckBox::Initialize(const CFWL_WidgetProperties* pProperties) { + if (m_pIface) + return FWL_ERR_Indefinite; + if (pProperties) { + *m_pProperties = *pProperties; + } + std::unique_ptr pCheckBox(IFWL_CheckBox::Create( + m_pProperties->MakeWidgetImpProperties(&m_checkboxData), nullptr)); + FWL_ERR ret = pCheckBox->Initialize(); + if (ret != FWL_ERR_Succeeded) { + return ret; + } + m_pIface = pCheckBox.release(); + CFWL_Widget::Initialize(); + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_CheckBox::SetCaption(const CFX_WideStringC& wsCaption) { + m_checkboxData.m_wsCaption = wsCaption; + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_CheckBox::SetBoxSize(FX_FLOAT fHeight) { + m_checkboxData.m_fBoxHeight = fHeight; + return FWL_ERR_Succeeded; +} + +int32_t CFWL_CheckBox::GetCheckState() { + return static_cast(m_pIface)->GetCheckState(); +} + +FWL_ERR CFWL_CheckBox::SetCheckState(int32_t iCheck) { + return static_cast(m_pIface)->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_ERR CFWL_CheckBox::CFWL_CheckBoxDP::GetCaption(IFWL_Widget* pWidget, + CFX_WideString& wsCaption) { + wsCaption = m_wsCaption; + return FWL_ERR_Succeeded; +} + +FX_FLOAT CFWL_CheckBox::CFWL_CheckBoxDP::GetBoxSize(IFWL_Widget* pWidget) { + return m_fBoxHeight; +} diff --git a/xfa/fwl/lightwidget/cfwl_checkbox.h b/xfa/fwl/lightwidget/cfwl_checkbox.h new file mode 100644 index 0000000000..7b7e4004bd --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_checkbox.h @@ -0,0 +1,38 @@ +// 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_LIGHTWIDGET_CFWL_CHECKBOX_H_ +#define XFA_FWL_LIGHTWIDGET_CFWL_CHECKBOX_H_ + +#include "xfa/fwl/basewidget/ifwl_checkbox.h" +#include "xfa/fwl/lightwidget/cfwl_widget.h" + +class CFWL_CheckBox : public CFWL_Widget { + public: + static CFWL_CheckBox* Create(); + + FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); + FWL_ERR GetCaption(CFX_WideString& wsCaption); + FWL_ERR SetCaption(const CFX_WideStringC& wsCaption); + FWL_ERR SetBoxSize(FX_FLOAT fHeight); + int32_t GetCheckState(); + FWL_ERR SetCheckState(int32_t iCheck); + CFWL_CheckBox(); + virtual ~CFWL_CheckBox(); + + protected: + class CFWL_CheckBoxDP : public IFWL_CheckBoxDP { + public: + CFWL_CheckBoxDP(); + virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption); + virtual FX_FLOAT GetBoxSize(IFWL_Widget* pWidget); + FX_FLOAT m_fBoxHeight; + CFX_WideString m_wsCaption; + }; + CFWL_CheckBoxDP m_checkboxData; +}; + +#endif // XFA_FWL_LIGHTWIDGET_CFWL_CHECKBOX_H_ diff --git a/xfa/fwl/lightwidget/cfwl_combobox.cpp b/xfa/fwl/lightwidget/cfwl_combobox.cpp new file mode 100644 index 0000000000..bdcc36fa30 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_combobox.cpp @@ -0,0 +1,432 @@ +// 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/lightwidget/cfwl_combobox.h" + +#include + +#include "xfa/fwl/core/fwl_error.h" +#include "xfa/fwl/core/ifwl_widget.h" + +CFWL_ComboBox* CFWL_ComboBox::Create() { + return new CFWL_ComboBox; +} + +FWL_ERR CFWL_ComboBox::Initialize(const CFWL_WidgetProperties* pProperties) { + if (m_pIface) + return FWL_ERR_Indefinite; + if (pProperties) { + *m_pProperties = *pProperties; + } + std::unique_ptr pComboBox(IFWL_ComboBox::Create( + m_pProperties->MakeWidgetImpProperties(&m_comboBoxData))); + FWL_ERR ret = pComboBox->Initialize(); + if (ret != FWL_ERR_Succeeded) { + return ret; + } + m_pIface = pComboBox.release(); + CFWL_Widget::Initialize(); + return FWL_ERR_Succeeded; +} + +int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { + std::unique_ptr 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 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(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_ERR CFWL_ComboBox::GetTextByIndex(int32_t iIndex, CFX_WideString& wsText) { + CFWL_ComboBoxItem* pItem = reinterpret_cast( + m_comboBoxData.GetItem(m_pIface, iIndex)); + if (!pItem) + return FWL_ERR_Indefinite; + wsText = pItem->m_wsText; + return FWL_ERR_Succeeded; +} + +int32_t CFWL_ComboBox::GetCurSel() { + if (!m_pIface) + return -1; + return static_cast(m_pIface)->GetCurSel(); +} + +FWL_ERR CFWL_ComboBox::SetCurSel(int32_t iSel) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->SetCurSel(iSel); +} + +FWL_ERR CFWL_ComboBox::SetEditText(const CFX_WideStringC& wsText) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->SetEditText(wsText); +} + +int32_t CFWL_ComboBox::GetEditTextLength() const { + if (!m_pIface) + return 0; + return static_cast(m_pIface)->GetEditTextLength(); +} + +FWL_ERR CFWL_ComboBox::GetEditText(CFX_WideString& wsText, + int32_t nStart, + int32_t nCount) const { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface) + ->GetEditText(wsText, nStart, nCount); +} + +FWL_ERR CFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->SetEditSelRange(nStart, nCount); +} + +int32_t CFWL_ComboBox::GetEditSelRange(int32_t nIndex, int32_t& nStart) { + if (!m_pIface) + return 0; + return static_cast(m_pIface)->GetEditSelRange(nIndex, nStart); +} + +int32_t CFWL_ComboBox::GetEditLimit() { + if (!m_pIface) + return 0; + return static_cast(m_pIface)->GetEditLimit(); +} + +FWL_ERR CFWL_ComboBox::SetEditLimit(int32_t nLimit) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->SetEditLimit(nLimit); +} + +FWL_ERR CFWL_ComboBox::EditDoClipboard(int32_t iCmd) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->EditDoClipboard(iCmd); +} + +FX_BOOL CFWL_ComboBox::EditRedo(const CFX_ByteStringC& bsRecord) { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->EditRedo(bsRecord); +} + +FX_BOOL CFWL_ComboBox::EditUndo(const CFX_ByteStringC& bsRecord) { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->EditUndo(bsRecord); +} + +FWL_ERR CFWL_ComboBox::SetMaxListHeight(FX_FLOAT fMaxHeight) { + m_comboBoxData.m_fMaxListHeight = fMaxHeight; + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_ComboBox::SetItemData(int32_t iIndex, void* pData) { + CFWL_ComboBoxItem* pItem = reinterpret_cast( + m_comboBoxData.GetItem(m_pIface, iIndex)); + if (!pItem) + return FWL_ERR_Indefinite; + pItem->m_pData = pData; + return FWL_ERR_Succeeded; +} + +void* CFWL_ComboBox::GetItemData(int32_t iIndex) { + CFWL_ComboBoxItem* pItem = reinterpret_cast( + m_comboBoxData.GetItem(m_pIface, iIndex)); + if (!pItem) + return NULL; + return pItem->m_pData; +} + +FWL_ERR CFWL_ComboBox::SetListTheme(IFWL_ThemeProvider* pTheme) { + return static_cast(m_pIface)->GetListBoxt()->SetThemeProvider( + pTheme); +} + +FX_BOOL CFWL_ComboBox::AfterFocusShowDropList() { + return static_cast(m_pIface)->AfterFocusShowDropList(); +} + +FWL_ERR CFWL_ComboBox::OpenDropDownList(FX_BOOL bActivate) { + return static_cast(m_pIface)->OpenDropDownList(bActivate); +} + +FX_BOOL CFWL_ComboBox::EditCanUndo() { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->EditCanUndo(); +} + +FX_BOOL CFWL_ComboBox::EditCanRedo() { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->EditCanRedo(); +} + +FX_BOOL CFWL_ComboBox::EditUndo() { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->EditUndo(); +} + +FX_BOOL CFWL_ComboBox::EditRedo() { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->EditRedo(); +} + +FX_BOOL CFWL_ComboBox::EditCanCopy() { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->EditCanCopy(); +} + +FX_BOOL CFWL_ComboBox::EditCanCut() { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->EditCanCut(); +} + +FX_BOOL CFWL_ComboBox::EditCanSelectAll() { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->EditCanSelectAll(); +} + +FX_BOOL CFWL_ComboBox::EditCopy(CFX_WideString& wsCopy) { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->EditCopy(wsCopy); +} + +FX_BOOL CFWL_ComboBox::EditCut(CFX_WideString& wsCut) { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->EditCut(wsCut); +} + +FX_BOOL CFWL_ComboBox::EditPaste(const CFX_WideString& wsPaste) { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->EditPaste(wsPaste); +} + +FX_BOOL CFWL_ComboBox::EditSelectAll() { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->EditSelectAll(); +} + +FX_BOOL CFWL_ComboBox::EditDelete() { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->EditDelete(); +} + +FX_BOOL CFWL_ComboBox::EditDeSelect() { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->EditDeSelect(); +} + +FWL_ERR CFWL_ComboBox::GetBBox(CFX_RectF& rect) { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->GetBBox(rect); +} + +FWL_ERR CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, + uint32_t dwStylesExRemoved) { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface) + ->EditModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); +} + +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() {} + +int32_t CFWL_ComboBox::CFWL_ComboBoxDP::CountItems(IFWL_Widget* pWidget) { + return m_ItemArray.size(); +} + +FWL_HLISTITEM CFWL_ComboBox::CFWL_ComboBoxDP::GetItem(IFWL_Widget* pWidget, + int32_t nIndex) { + if (nIndex < 0 || static_cast(nIndex) >= m_ItemArray.size()) + return nullptr; + + return reinterpret_cast(m_ItemArray[nIndex].get()); +} + +int32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIndex(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem) { + auto it = std::find_if( + m_ItemArray.begin(), m_ItemArray.end(), + [hItem](const std::unique_ptr& candidate) { + return candidate.get() == reinterpret_cast(hItem); + }); + return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1; +} + +FX_BOOL CFWL_ComboBox::CFWL_ComboBoxDP::SetItemIndex(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + int32_t nIndex) { + if (nIndex < 0 || static_cast(nIndex) >= m_ItemArray.size()) + return FALSE; + + m_ItemArray[nIndex].reset(reinterpret_cast(hItem)); + return TRUE; +} + +uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemStyles(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem) { + if (!hItem) + return 0; + return reinterpret_cast(hItem)->m_dwStyles; +} + +FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::GetItemText(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + CFX_WideString& wsText) { + if (!hItem) + return FWL_ERR_Indefinite; + wsText = reinterpret_cast(hItem)->m_wsText; + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::GetItemRect(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + CFX_RectF& rtItem) { + if (!hItem) + return FWL_ERR_Indefinite; + CFWL_ComboBoxItem* pItem = reinterpret_cast(hItem); + rtItem.Set(pItem->m_rtItem.left, pItem->m_rtItem.top, pItem->m_rtItem.width, + pItem->m_rtItem.height); + return FWL_ERR_Succeeded; +} + +void* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemData(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem) { + if (!hItem) + return NULL; + CFWL_ComboBoxItem* pItem = reinterpret_cast(hItem); + return pItem->m_pData; +} + +FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemStyles(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + uint32_t dwStyle) { + if (!hItem) + return FWL_ERR_Indefinite; + reinterpret_cast(hItem)->m_dwStyles = dwStyle; + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemText(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + const FX_WCHAR* pszText) { + if (!hItem) + return FWL_ERR_Indefinite; + reinterpret_cast(hItem)->m_wsText = pszText; + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemRect(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + const CFX_RectF& rtItem) { + if (!hItem) + return FWL_ERR_Indefinite; + reinterpret_cast(hItem)->m_rtItem = rtItem; + return FWL_ERR_Succeeded; +} + +FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetItemHeight(IFWL_Widget* pWidget) { + return m_fItemHeight; +} + +CFX_DIBitmap* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIcon(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem) { + if (!hItem) + return NULL; + return reinterpret_cast(hItem)->m_pDIB; +} + +FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckRect(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + CFX_RectF& rtCheck) { + CFWL_ComboBoxItem* pItem = reinterpret_cast(hItem); + rtCheck = pItem->m_rtCheckBox; + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckRect( + IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + const CFX_RectF& rtCheck) { + CFWL_ComboBoxItem* pItem = reinterpret_cast(hItem); + pItem->m_rtCheckBox = rtCheck; + return FWL_ERR_Succeeded; +} + +uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckState( + IFWL_Widget* pWidget, + FWL_HLISTITEM hItem) { + CFWL_ComboBoxItem* pItem = reinterpret_cast(hItem); + return pItem->m_dwCheckState; +} + +FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckState( + IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + uint32_t dwCheckState) { + CFWL_ComboBoxItem* pItem = reinterpret_cast(hItem); + pItem->m_dwCheckState = dwCheckState; + return FWL_ERR_Succeeded; +} + +FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetListHeight(IFWL_Widget* pWidget) { + return m_fMaxListHeight; +} diff --git a/xfa/fwl/lightwidget/cfwl_combobox.h b/xfa/fwl/lightwidget/cfwl_combobox.h new file mode 100644 index 0000000000..59b542c453 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_combobox.h @@ -0,0 +1,143 @@ +// 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_LIGHTWIDGET_CFWL_COMBOBOX_H_ +#define XFA_FWL_LIGHTWIDGET_CFWL_COMBOBOX_H_ + +#include +#include + +#include "xfa/fwl/basewidget/ifwl_combobox.h" +#include "xfa/fwl/lightwidget/cfwl_widget.h" + +class CFWL_WidgetProperties; +class IFWL_ComboBoxDP; +class CFWL_ComboBoxDP; +class CFWL_ComboBoxItem; + +class CFWL_ComboBox : public CFWL_Widget { + public: + static CFWL_ComboBox* Create(); + FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); + 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_ERR GetTextByIndex(int32_t iIndex, CFX_WideString& wsText); + int32_t GetCurSel(); + FWL_ERR SetCurSel(int32_t iSel); + FWL_ERR SetEditText(const CFX_WideStringC& wsText); + int32_t GetEditTextLength() const; + FWL_ERR GetEditText(CFX_WideString& wsText, + int32_t nStart = 0, + int32_t nCount = -1) const; + FWL_ERR SetEditSelRange(int32_t nStart, int32_t nCount = -1); + int32_t GetEditSelRange(int32_t nIndex, int32_t& nStart); + int32_t GetEditLimit(); + FWL_ERR SetEditLimit(int32_t nLimit); + FWL_ERR EditDoClipboard(int32_t iCmd); + FX_BOOL EditRedo(const CFX_ByteStringC& bsRecord); + FX_BOOL EditUndo(const CFX_ByteStringC& bsRecord); + FWL_ERR SetMaxListHeight(FX_FLOAT fMaxHeight); + FWL_ERR SetItemData(int32_t iIndex, void* pData); + void* GetItemData(int32_t iIndex); + FWL_ERR SetListTheme(IFWL_ThemeProvider* pTheme); + FX_BOOL AfterFocusShowDropList(); + FWL_ERR 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_ERR GetBBox(CFX_RectF& rect); + FWL_ERR EditModifyStylesEx(uint32_t dwStylesExAdded, + uint32_t dwStylesExRemoved); + CFWL_ComboBox(); + virtual ~CFWL_ComboBox(); + + protected: + class CFWL_ComboBoxDP : public IFWL_ComboBoxDP { + public: + CFWL_ComboBoxDP(); + ~CFWL_ComboBoxDP(); + virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, + CFX_WideString& wsCaption) { + return FWL_ERR_Succeeded; + } + + virtual int32_t CountItems(IFWL_Widget* pWidget); + virtual FWL_HLISTITEM GetItem(IFWL_Widget* pWidget, int32_t nIndex); + virtual int32_t GetItemIndex(IFWL_Widget* pWidget, FWL_HLISTITEM hItem); + virtual FX_BOOL SetItemIndex(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + int32_t nIndex); + + virtual uint32_t GetItemStyles(IFWL_Widget* pWidget, FWL_HLISTITEM hItem); + virtual FWL_ERR GetItemText(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + CFX_WideString& wsText); + virtual FWL_ERR GetItemRect(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + CFX_RectF& rtItem); + virtual void* GetItemData(IFWL_Widget* pWidget, FWL_HLISTITEM hItem); + virtual FWL_ERR SetItemStyles(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + uint32_t dwStyle); + virtual FWL_ERR SetItemText(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + const FX_WCHAR* pszText); + virtual FWL_ERR SetItemRect(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + const CFX_RectF& rtItem); + virtual FX_FLOAT GetItemHeight(IFWL_Widget* pWidget); + virtual CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem); + virtual FWL_ERR GetItemCheckRect(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + CFX_RectF& rtCheck); + virtual FWL_ERR SetItemCheckRect(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + const CFX_RectF& rtCheck); + virtual uint32_t GetItemCheckState(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem); + virtual FWL_ERR SetItemCheckState(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + uint32_t dwCheckState); + virtual FX_FLOAT GetListHeight(IFWL_Widget* pWidget); + + std::vector> m_ItemArray; + FX_FLOAT m_fMaxListHeight; + FX_FLOAT m_fItemHeight; + }; + CFWL_ComboBoxDP m_comboBoxData; +}; + +class CFWL_ComboBoxItem { + public: + CFWL_ComboBoxItem() { + m_pDIB = NULL; + m_pData = NULL; + } + 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_LIGHTWIDGET_CFWL_COMBOBOX_H_ diff --git a/xfa/fwl/lightwidget/cfwl_datetimepicker.cpp b/xfa/fwl/lightwidget/cfwl_datetimepicker.cpp new file mode 100644 index 0000000000..e470616ed8 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_datetimepicker.cpp @@ -0,0 +1,171 @@ +// 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/lightwidget/cfwl_datetimepicker.h" + +#include + +#include "xfa/fwl/basewidget/ifwl_datetimepicker.h" +#include "xfa/fwl/core/fwl_error.h" +#include "xfa/fwl/core/ifwl_widget.h" + +CFWL_DateTimePicker* CFWL_DateTimePicker::Create() { + return new CFWL_DateTimePicker; +} + +FWL_ERR CFWL_DateTimePicker::Initialize( + const CFWL_WidgetProperties* pProperties) { + if (m_pIface) + return FWL_ERR_Indefinite; + if (pProperties) { + *m_pProperties = *pProperties; + } + std::unique_ptr pDateTimePicker( + IFWL_DateTimePicker::Create( + m_pProperties->MakeWidgetImpProperties(&m_DateTimePickerDP), + nullptr)); + FWL_ERR ret = pDateTimePicker->Initialize(); + if (ret != FWL_ERR_Succeeded) { + return ret; + } + m_pIface = pDateTimePicker.release(); + CFWL_Widget::Initialize(); + return FWL_ERR_Succeeded; +} + +FWL_ERR 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_ERR_Succeeded; +} + +int32_t CFWL_DateTimePicker::CountSelRanges() { + return static_cast(m_pIface)->CountSelRanges(); +} + +int32_t CFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) { + return static_cast(m_pIface) + ->GetSelRange(nIndex, nStart); +} + +FWL_ERR CFWL_DateTimePicker::GetEditText(CFX_WideString& wsText) { + return static_cast(m_pIface)->GetEditText(wsText); +} + +FWL_ERR CFWL_DateTimePicker::SetEditText(const CFX_WideStringC& wsText) { + return static_cast(m_pIface)->SetEditText(wsText); +} + +FWL_ERR CFWL_DateTimePicker::GetCurSel(int32_t& iYear, + int32_t& iMonth, + int32_t& iDay) { + return static_cast(m_pIface) + ->GetCurSel(iYear, iMonth, iDay); +} + +FWL_ERR CFWL_DateTimePicker::SetCurSel(int32_t iYear, + int32_t iMonth, + int32_t iDay) { + return static_cast(m_pIface) + ->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_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetCaption( + IFWL_Widget* pWidget, + CFX_WideString& wsCaption) { + wsCaption = m_wsData; + return FWL_ERR_Succeeded; +} + +FWL_ERR 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_ERR_Succeeded; +} + +FX_BOOL CFWL_DateTimePicker::CanUndo() { + return static_cast(m_pIface)->CanUndo(); +} + +FX_BOOL CFWL_DateTimePicker::CanRedo() { + return static_cast(m_pIface)->CanRedo(); +} + +FX_BOOL CFWL_DateTimePicker::Undo() { + return static_cast(m_pIface)->Undo(); +} + +FX_BOOL CFWL_DateTimePicker::Redo() { + return static_cast(m_pIface)->Redo(); +} + +FX_BOOL CFWL_DateTimePicker::CanCopy() { + return static_cast(m_pIface)->CanCopy(); +} + +FX_BOOL CFWL_DateTimePicker::CanCut() { + return static_cast(m_pIface)->CanCut(); +} + +FX_BOOL CFWL_DateTimePicker::CanSelectAll() { + return static_cast(m_pIface)->CanSelectAll(); +} + +FX_BOOL CFWL_DateTimePicker::Copy(CFX_WideString& wsCopy) { + return static_cast(m_pIface)->Copy(wsCopy); +} + +FX_BOOL CFWL_DateTimePicker::Cut(CFX_WideString& wsCut) { + return static_cast(m_pIface)->Copy(wsCut); +} + +FX_BOOL CFWL_DateTimePicker::Paste(const CFX_WideString& wsPaste) { + return static_cast(m_pIface)->Paste(wsPaste); +} + +FX_BOOL CFWL_DateTimePicker::SelectAll() { + return static_cast(m_pIface)->SelectAll(); +} + +FX_BOOL CFWL_DateTimePicker::Delete() { + return static_cast(m_pIface)->Delete(); +} + +FX_BOOL CFWL_DateTimePicker::DeSelect() { + return static_cast(m_pIface)->DeSelect(); +} + +FWL_ERR CFWL_DateTimePicker::GetBBox(CFX_RectF& rect) { + return static_cast(m_pIface)->GetBBox(rect); +} + +FWL_ERR CFWL_DateTimePicker::SetEditLimit(int32_t nLimit) { + return static_cast(m_pIface)->SetEditLimit(nLimit); +} + +FWL_ERR CFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded, + uint32_t dwStylesExRemoved) { + return static_cast(m_pIface) + ->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved); +} diff --git a/xfa/fwl/lightwidget/cfwl_datetimepicker.h b/xfa/fwl/lightwidget/cfwl_datetimepicker.h new file mode 100644 index 0000000000..a96ac532c1 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_datetimepicker.h @@ -0,0 +1,61 @@ +// 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_LIGHTWIDGET_CFWL_DATETIMEPICKER_H_ +#define XFA_FWL_LIGHTWIDGET_CFWL_DATETIMEPICKER_H_ + +#include "xfa/fwl/basewidget/ifwl_datetimepicker.h" +#include "xfa/fwl/lightwidget/cfwl_widget.h" + +class CFWL_DateTimePicker : public CFWL_Widget { + public: + static CFWL_DateTimePicker* Create(); + FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); + FWL_ERR SetToday(int32_t iYear, int32_t iMonth, int32_t iDay); + FWL_ERR GetEditText(CFX_WideString& wsText); + FWL_ERR SetEditText(const CFX_WideStringC& wsText); + int32_t CountSelRanges(); + int32_t GetSelRange(int32_t nIndex, int32_t& nStart); + FWL_ERR GetCurSel(int32_t& iYear, int32_t& iMonth, int32_t& iDay); + FWL_ERR 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_ERR GetBBox(CFX_RectF& rect); + FWL_ERR SetEditLimit(int32_t nLimit); + FWL_ERR ModifyEditStylesEx(uint32_t dwStylesExAdded, + uint32_t dwStylesExRemoved); + + protected: + CFWL_DateTimePicker(); + virtual ~CFWL_DateTimePicker(); + class CFWL_DateTimePickerDP : public IFWL_DateTimePickerDP { + public: + CFWL_DateTimePickerDP(); + virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption); + virtual FWL_ERR GetToday(IFWL_Widget* pWidget, + int32_t& iYear, + int32_t& iMonth, + int32_t& iDay); + int32_t m_iYear; + int32_t m_iMonth; + int32_t m_iDay; + CFX_WideString m_wsData; + }; + CFWL_DateTimePickerDP m_DateTimePickerDP; +}; + +#endif // XFA_FWL_LIGHTWIDGET_CFWL_DATETIMEPICKER_H_ diff --git a/xfa/fwl/lightwidget/cfwl_edit.cpp b/xfa/fwl/lightwidget/cfwl_edit.cpp new file mode 100644 index 0000000000..ba0ff58f6d --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_edit.cpp @@ -0,0 +1,250 @@ +// 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/lightwidget/cfwl_edit.h" + +#include +#include + +#include "xfa/fwl/basewidget/ifwl_edit.h" + +CFWL_Edit* CFWL_Edit::Create() { + return new CFWL_Edit; +} + +FWL_ERR CFWL_Edit::Initialize(const CFWL_WidgetProperties* pProperties) { + if (m_pIface) + return FWL_ERR_Indefinite; + if (pProperties) { + *m_pProperties = *pProperties; + } + std::unique_ptr pEdit(IFWL_Edit::Create( + m_pProperties->MakeWidgetImpProperties(nullptr), nullptr)); + FWL_ERR ret = pEdit->Initialize(); + if (ret != FWL_ERR_Succeeded) { + return ret; + } + m_pIface = pEdit.release(); + CFWL_Widget::Initialize(); + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_Edit::SetText(const CFX_WideString& wsText) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->SetText(wsText); +} + +int32_t CFWL_Edit::GetTextLength() const { + if (!m_pIface) + return 0; + return static_cast(m_pIface)->GetTextLength(); +} + +FWL_ERR CFWL_Edit::GetText(CFX_WideString& wsText, + int32_t nStart, + int32_t nCount) const { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->GetText(wsText, nStart, nCount); +} + +FWL_ERR CFWL_Edit::ClearText() { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->ClearText(); +} + +int32_t CFWL_Edit::GetCaretPos() const { + if (!m_pIface) + return -1; + return static_cast(m_pIface)->GetCaretPos(); +} + +int32_t CFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { + if (!m_pIface) + return -1; + return static_cast(m_pIface)->SetCaretPos(nIndex, bBefore); +} + +FWL_ERR CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { + if (!m_pIface) + return FWL_ERR_Indefinite; + static_cast(m_pIface)->AddSelRange(nStart, nCount); + int32_t pos = 0; + int32_t sum = static_cast(m_pIface)->GetTextLength(); + if (nCount == -1) { + pos = sum; + } else { + pos = nStart + nCount; + } + return static_cast(m_pIface)->SetCaretPos(pos); +} + +int32_t CFWL_Edit::CountSelRanges() { + if (!m_pIface) + return 0; + return static_cast(m_pIface)->CountSelRanges(); +} + +int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) { + if (!m_pIface) + return 0; + return static_cast(m_pIface)->GetSelRange(nIndex, nStart); +} + +FWL_ERR CFWL_Edit::ClearSelections() { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->ClearSelections(); +} + +int32_t CFWL_Edit::GetLimit() { + if (!m_pIface) + return -1; + return static_cast(m_pIface)->GetLimit(); +} + +FWL_ERR CFWL_Edit::SetLimit(int32_t nLimit) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->SetLimit(nLimit); +} + +FWL_ERR CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->SetAliasChar(wAlias); +} + +FWL_ERR CFWL_Edit::Insert(int32_t nStart, + const FX_WCHAR* lpText, + int32_t nLen) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->Insert(nStart, lpText, nLen); +} + +FWL_ERR CFWL_Edit::DeleteSelections() { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->DeleteSelections(); +} + +FWL_ERR CFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->DeleteRange(nStart, nCount); +} + +FWL_ERR CFWL_Edit::ReplaceSelections(const CFX_WideStringC& wsReplace) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->ReplaceSelections(wsReplace); +} + +FWL_ERR CFWL_Edit::Replace(int32_t nStart, + int32_t nLen, + const CFX_WideStringC& wsReplace) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->Replace(nStart, nLen, wsReplace); +} + +FWL_ERR CFWL_Edit::DoClipboard(int32_t iCmd) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->DoClipboard(iCmd); +} + +FX_BOOL CFWL_Edit::Redo(const CFX_ByteStringC& bsRecord) { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->Redo(bsRecord); +} + +FX_BOOL CFWL_Edit::Undo(const CFX_ByteStringC& bsRecord) { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->Undo(bsRecord); +} + +FWL_ERR CFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface) + ->SetTabWidth(fTabWidth, bEquidistant); +} + +FWL_ERR CFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { + if (iMin > iMax) { + return FWL_ERR_Parameter_Invalid; + } + return static_cast(m_pIface)->SetNumberRange(iMin, iMax); +} + +FWL_ERR CFWL_Edit::SetBackColor(uint32_t dwColor) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->SetBackColor(dwColor); +} + +FWL_ERR CFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->SetFont(wsFont, fSize); +} + +FX_BOOL CFWL_Edit::CanUndo() { + return static_cast(m_pIface)->CanUndo(); +} + +FX_BOOL CFWL_Edit::CanRedo() { + return static_cast(m_pIface)->CanRedo(); +} + +FX_BOOL CFWL_Edit::Undo() { + return static_cast(m_pIface)->Undo(); +} + +FX_BOOL CFWL_Edit::Redo() { + return static_cast(m_pIface)->Undo(); +} + +FX_BOOL CFWL_Edit::Copy(CFX_WideString& wsCopy) { + return static_cast(m_pIface)->Copy(wsCopy); +} + +FX_BOOL CFWL_Edit::Cut(CFX_WideString& wsCut) { + return static_cast(m_pIface)->Cut(wsCut); +} + +FX_BOOL CFWL_Edit::Paste(const CFX_WideString& wsPaste) { + return static_cast(m_pIface)->Paste(wsPaste); +} + +FX_BOOL CFWL_Edit::Delete() { + return static_cast(m_pIface)->Delete(); +} + +void CFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { + return static_cast(m_pIface)->SetScrollOffset(fScrollOffset); +} + +FX_BOOL CFWL_Edit::GetSuggestWords(CFX_PointF pointf, + std::vector& sSuggest) { + return static_cast(m_pIface)->GetSuggestWords(pointf, sSuggest); +} + +FX_BOOL CFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf, + const CFX_ByteStringC& bsReplace) { + return static_cast(m_pIface) + ->ReplaceSpellCheckWord(pointf, bsReplace); +} + +CFWL_Edit::CFWL_Edit() {} + +CFWL_Edit::~CFWL_Edit() {} diff --git a/xfa/fwl/lightwidget/cfwl_edit.h b/xfa/fwl/lightwidget/cfwl_edit.h new file mode 100644 index 0000000000..153c756044 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_edit.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_LIGHTWIDGET_CFWL_EDIT_H_ +#define XFA_FWL_LIGHTWIDGET_CFWL_EDIT_H_ + +#include + +#include "xfa/fwl/lightwidget/cfwl_widget.h" + +class CFWL_WidgetProperties; + +class CFWL_Edit : public CFWL_Widget { + public: + static CFWL_Edit* Create(); + FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); + FWL_ERR SetText(const CFX_WideString& wsText); + int32_t GetTextLength() const; + FWL_ERR GetText(CFX_WideString& wsText, + int32_t nStart = 0, + int32_t nCount = -1) const; + FWL_ERR ClearText(); + int32_t GetCaretPos() const; + int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore = TRUE); + FWL_ERR AddSelRange(int32_t nStart, int32_t nCount = -1); + int32_t CountSelRanges(); + int32_t GetSelRange(int32_t nIndex, int32_t& nStart); + FWL_ERR ClearSelections(); + int32_t GetLimit(); + FWL_ERR SetLimit(int32_t nLimit); + FWL_ERR SetAliasChar(FX_WCHAR wAlias); + FWL_ERR SetFormatString(const CFX_WideString& wsFormat); + FWL_ERR Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLen); + FWL_ERR DeleteSelections(); + FWL_ERR DeleteRange(int32_t nStart, int32_t nCount = -1); + FWL_ERR ReplaceSelections(const CFX_WideStringC& wsReplace); + FWL_ERR Replace(int32_t nStart, + int32_t nLen, + const CFX_WideStringC& wsReplace); + FWL_ERR DoClipboard(int32_t iCmd); + FX_BOOL Redo(const CFX_ByteStringC& bsRecord); + FX_BOOL Undo(const CFX_ByteStringC& bsRecord); + FWL_ERR SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant); + FWL_ERR SetNumberRange(int32_t iMin, int32_t iMax); + FWL_ERR SetBackColor(uint32_t dwColor); + FWL_ERR 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& sSuggest); + FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, + const CFX_ByteStringC& bsReplace); + CFWL_Edit(); + virtual ~CFWL_Edit(); +}; + +#endif // XFA_FWL_LIGHTWIDGET_CFWL_EDIT_H_ diff --git a/xfa/fwl/lightwidget/cfwl_listbox.cpp b/xfa/fwl/lightwidget/cfwl_listbox.cpp new file mode 100644 index 0000000000..2102d2d3ee --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_listbox.cpp @@ -0,0 +1,347 @@ +// 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/lightwidget/cfwl_listbox.h" + +#include + +#include "third_party/base/stl_util.h" + +CFWL_ListBox* CFWL_ListBox::Create() { + return new CFWL_ListBox; +} + +FWL_ERR CFWL_ListBox::Initialize(const CFWL_WidgetProperties* pProperties) { + if (m_pIface) + return FWL_ERR_Indefinite; + if (pProperties) { + *m_pProperties = *pProperties; + } + std::unique_ptr pListBox(IFWL_ListBox::Create( + m_pProperties->MakeWidgetImpProperties(&m_ListBoxDP), nullptr)); + FWL_ERR ret = pListBox->Initialize(); + if (ret != FWL_ERR_Succeeded) { + return ret; + } + m_pIface = pListBox.release(); + CFWL_Widget::Initialize(); + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_ListBox::AddDIBitmap(CFX_DIBitmap* pDIB, FWL_HLISTITEM hItem) { + reinterpret_cast(hItem)->m_pDIB = pDIB; + return FWL_ERR_Succeeded; +} + +FWL_HLISTITEM CFWL_ListBox::AddString(const CFX_WideStringC& wsAdd, + FX_BOOL bSelect) { + std::unique_ptr 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 (FWL_HLISTITEM)m_ListBoxDP.m_ItemArray.back().get(); +} + +FX_BOOL CFWL_ListBox::DeleteString(FWL_HLISTITEM hItem) { + int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), hItem); + if (nIndex < 0 || + static_cast(nIndex) >= m_ListBoxDP.m_ItemArray.size()) { + return FALSE; + } + int32_t iCount = m_ListBoxDP.CountItems(m_pIface); + int32_t iSel = nIndex + 1; + if (iSel >= iCount) { + iSel = nIndex - 1; + if (iSel < 0) { + iSel = -1; + } + } + if (iSel >= 0) { + CFWL_ListItem* pSel = + reinterpret_cast(m_ListBoxDP.GetItem(m_pIface, 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 (!m_pIface) + return 0; + return static_cast(m_pIface)->CountSelItems(); +} + +FWL_HLISTITEM CFWL_ListBox::GetSelItem(int32_t nIndexSel) { + if (!m_pIface) + return NULL; + return static_cast(m_pIface)->GetSelItem(nIndexSel); +} + +int32_t CFWL_ListBox::GetSelIndex(int32_t nIndex) { + if (!m_pIface) + return 0; + return static_cast(m_pIface)->GetSelIndex(nIndex); +} + +FWL_ERR CFWL_ListBox::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->SetSelItem(hItem, bSelect); +} + +FWL_ERR CFWL_ListBox::GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->GetItemText(hItem, wsText); +} + +FWL_ERR CFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->GetScrollPos(fPos, bVert); +} + +FWL_ERR CFWL_ListBox::SetItemHeight(FX_FLOAT fItemHeight) { + m_ListBoxDP.m_fItemHeight = fItemHeight; + return FWL_ERR_Succeeded; +} + +FWL_HLISTITEM CFWL_ListBox::GetFocusItem() { + for (const auto& hItem : m_ListBoxDP.m_ItemArray) { + if (hItem->m_dwStates & FWL_ITEMSTATE_LTB_Focused) + return (FWL_HLISTITEM)hItem.get(); + } + return nullptr; +} + +FWL_ERR CFWL_ListBox::SetFocusItem(FWL_HLISTITEM hItem) { + int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), hItem); + m_ListBoxDP.m_ItemArray[nIndex]->m_dwStates |= FWL_ITEMSTATE_LTB_Focused; + return FWL_ERR_Succeeded; +} + +FWL_ERR* CFWL_ListBox::Sort(IFWL_ListBoxCompare* pCom) { + return static_cast(m_pIface)->Sort(pCom); +} + +int32_t CFWL_ListBox::CountItems() { + return pdfium::CollectionSize(m_ListBoxDP.m_ItemArray); +} + +FWL_HLISTITEM CFWL_ListBox::GetItem(int32_t nIndex) { + if (nIndex < 0 || nIndex >= CountItems()) + return nullptr; + + return (FWL_HLISTITEM)m_ListBoxDP.m_ItemArray[nIndex].get(); +} + +FWL_ERR CFWL_ListBox::SetItemString(FWL_HLISTITEM hItem, + const CFX_WideStringC& wsText) { + if (!hItem) + return FWL_ERR_Indefinite; + reinterpret_cast(hItem)->m_wsText = wsText; + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_ListBox::GetItemString(FWL_HLISTITEM hItem, + CFX_WideString& wsText) { + if (!hItem) + return FWL_ERR_Indefinite; + wsText = reinterpret_cast(hItem)->m_wsText; + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_ListBox::SetItemData(FWL_HLISTITEM hItem, void* pData) { + if (!hItem) + return FWL_ERR_Indefinite; + reinterpret_cast(hItem)->m_pData = pData; + return FWL_ERR_Succeeded; +} + +void* CFWL_ListBox::GetItemData(FWL_HLISTITEM hItem) { + if (!hItem) + return NULL; + return reinterpret_cast(hItem)->m_pData; +} + +FWL_HLISTITEM CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { + CFX_RectF rtClient; + m_pIface->GetClientRect(rtClient); + fx -= rtClient.left; + fy -= rtClient.top; + FX_FLOAT fPosX = 0; + FX_FLOAT fPosY = 0; + static_cast(m_pIface)->GetScrollPos(fx); + static_cast(m_pIface)->GetScrollPos(fy, FALSE); + int32_t nCount = m_ListBoxDP.CountItems(NULL); + for (int32_t i = 0; i < nCount; i++) { + FWL_HLISTITEM hItem = m_ListBoxDP.GetItem(NULL, i); + if (!hItem) { + continue; + } + CFX_RectF rtItem; + m_ListBoxDP.GetItemRect(NULL, hItem, rtItem); + rtItem.Offset(-fPosX, -fPosY); + if (rtItem.Contains(fx, fy)) { + return hItem; + } + } + return NULL; +} + +uint32_t CFWL_ListBox::GetItemStates(FWL_HLISTITEM hItem) { + if (!hItem) + return 0; + CFWL_ListItem* pItem = reinterpret_cast(hItem); + return pItem->m_dwStates | pItem->m_dwCheckState; +} + +CFWL_ListBox::CFWL_ListBox() {} + +CFWL_ListBox::~CFWL_ListBox() {} + +CFWL_ListBox::CFWL_ListBoxDP::CFWL_ListBoxDP() {} + +CFWL_ListBox::CFWL_ListBoxDP::~CFWL_ListBoxDP() {} + +FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetCaption(IFWL_Widget* pWidget, + CFX_WideString& wsCaption) { + wsCaption = m_wsData; + return FWL_ERR_Succeeded; +} + +int32_t CFWL_ListBox::CFWL_ListBoxDP::CountItems(IFWL_Widget* pWidget) { + return pdfium::CollectionSize(m_ItemArray); +} + +FWL_HLISTITEM CFWL_ListBox::CFWL_ListBoxDP::GetItem(IFWL_Widget* pWidget, + int32_t nIndex) { + if (nIndex < 0 || nIndex >= CountItems(pWidget)) + return nullptr; + + return (FWL_HLISTITEM)m_ItemArray[nIndex].get(); +} + +int32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemIndex(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem) { + auto it = std::find_if( + m_ItemArray.begin(), m_ItemArray.end(), + [hItem](const std::unique_ptr& candidate) { + return candidate.get() == reinterpret_cast(hItem); + }); + return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1; +} + +FX_BOOL CFWL_ListBox::CFWL_ListBoxDP::SetItemIndex(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + int32_t nIndex) { + if (nIndex < 0 || nIndex >= CountItems(pWidget)) + return FALSE; + m_ItemArray[nIndex].reset(reinterpret_cast(hItem)); + return TRUE; +} + +uint32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemStyles(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem) { + if (!hItem) + return -1; + return reinterpret_cast(hItem)->m_dwStates; +} + +FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemText(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + CFX_WideString& wsText) { + if (!hItem) + return FWL_ERR_Indefinite; + wsText = reinterpret_cast(hItem)->m_wsText; + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemRect(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + CFX_RectF& rtItem) { + if (!hItem) + return FWL_ERR_Indefinite; + CFWL_ListItem* pItem = reinterpret_cast(hItem); + rtItem = pItem->m_rtItem; + return FWL_ERR_Succeeded; +} + +void* CFWL_ListBox::CFWL_ListBoxDP::GetItemData(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem) { + if (!hItem) + return NULL; + CFWL_ListItem* pItem = reinterpret_cast(hItem); + return pItem->m_pData; +} + +FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemStyles(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + uint32_t dwStyle) { + if (!hItem) + return FWL_ERR_Indefinite; + reinterpret_cast(hItem)->m_dwStates = dwStyle; + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemText(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + const FX_WCHAR* pszText) { + if (!hItem) + return FWL_ERR_Indefinite; + reinterpret_cast(hItem)->m_wsText = pszText; + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemRect(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + const CFX_RectF& rtItem) { + if (!hItem) + return FWL_ERR_Indefinite; + reinterpret_cast(hItem)->m_rtItem = rtItem; + return FWL_ERR_Succeeded; +} + +FX_FLOAT CFWL_ListBox::CFWL_ListBoxDP::GetItemHeight(IFWL_Widget* pWidget) { + return m_fItemHeight; +} + +CFX_DIBitmap* CFWL_ListBox::CFWL_ListBoxDP::GetItemIcon(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem) { + return reinterpret_cast(hItem)->m_pDIB; +} + +FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckRect(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + CFX_RectF& rtCheck) { + rtCheck = reinterpret_cast(hItem)->m_rtCheckBox; + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckRect( + IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + const CFX_RectF& rtCheck) { + reinterpret_cast(hItem)->m_rtCheckBox = rtCheck; + return FWL_ERR_Succeeded; +} + +uint32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckState(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem) { + return reinterpret_cast(hItem)->m_dwCheckState; +} + +FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckState(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + uint32_t dwCheckState) { + reinterpret_cast(hItem)->m_dwCheckState = dwCheckState; + return FWL_ERR_Succeeded; +} diff --git a/xfa/fwl/lightwidget/cfwl_listbox.h b/xfa/fwl/lightwidget/cfwl_listbox.h new file mode 100644 index 0000000000..28fb42af69 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_listbox.h @@ -0,0 +1,127 @@ +// 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_LIGHTWIDGET_CFWL_LISTBOX_H_ +#define XFA_FWL_LIGHTWIDGET_CFWL_LISTBOX_H_ + +#include +#include + +#include "xfa/fwl/basewidget/ifwl_listbox.h" +#include "xfa/fwl/core/fwl_error.h" +#include "xfa/fwl/core/ifwl_widget.h" +#include "xfa/fwl/lightwidget/cfwl_widget.h" + +class CFWL_ListItem; + +class CFWL_ListBox : public CFWL_Widget { + public: + static CFWL_ListBox* Create(); + FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); + FWL_ERR AddDIBitmap(CFX_DIBitmap* pDIB, FWL_HLISTITEM hItem); + FWL_HLISTITEM AddString(const CFX_WideStringC& wsAdd, + FX_BOOL bSelect = FALSE); + FX_BOOL DeleteString(FWL_HLISTITEM hItem); + void DeleteAll(); + int32_t CountSelItems(); + FWL_HLISTITEM GetSelItem(int32_t nIndexSel); + int32_t GetSelIndex(int32_t nIndex); + FWL_ERR SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect = TRUE); + FWL_ERR GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText); + FWL_ERR GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE); + FWL_ERR SetItemHeight(FX_FLOAT fItemHeight); + FWL_HLISTITEM GetFocusItem(); + FWL_ERR SetFocusItem(FWL_HLISTITEM hItem); + FWL_ERR* Sort(IFWL_ListBoxCompare* pCom); + int32_t CountItems(); + FWL_HLISTITEM GetItem(int32_t nIndex); + FWL_ERR SetItemString(FWL_HLISTITEM hItem, const CFX_WideStringC& wsText); + FWL_ERR GetItemString(FWL_HLISTITEM hItem, CFX_WideString& wsText); + FWL_ERR SetItemData(FWL_HLISTITEM hItem, void* pData); + void* GetItemData(FWL_HLISTITEM hItem); + FWL_HLISTITEM GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy); + uint32_t GetItemStates(FWL_HLISTITEM hItem); + CFWL_ListBox(); + virtual ~CFWL_ListBox(); + + protected: + class CFWL_ListBoxDP : public IFWL_ListBoxDP { + public: + CFWL_ListBoxDP(); + ~CFWL_ListBoxDP(); + + // IFWL_DataProvider: + FWL_ERR GetCaption(IFWL_Widget* pWidget, + CFX_WideString& wsCaption) override; + + // IFWL_ListBoxDP: + int32_t CountItems(IFWL_Widget* pWidget) override; + FWL_HLISTITEM GetItem(IFWL_Widget* pWidget, int32_t nIndex) override; + int32_t GetItemIndex(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) override; + FX_BOOL SetItemIndex(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + int32_t nIndex) override; + uint32_t GetItemStyles(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) override; + FWL_ERR GetItemText(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + CFX_WideString& wsText) override; + FWL_ERR GetItemRect(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + CFX_RectF& rtItem) override; + void* GetItemData(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) override; + FWL_ERR SetItemStyles(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + uint32_t dwStyle) override; + FWL_ERR SetItemText(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + const FX_WCHAR* pszText) override; + FWL_ERR SetItemRect(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + const CFX_RectF& rtItem) override; + FX_FLOAT GetItemHeight(IFWL_Widget* pWidget) override; + CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem) override; + FWL_ERR GetItemCheckRect(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + CFX_RectF& rtCheck) override; + FWL_ERR SetItemCheckRect(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + const CFX_RectF& rtCheck) override; + uint32_t GetItemCheckState(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem) override; + FWL_ERR SetItemCheckState(IFWL_Widget* pWidget, + FWL_HLISTITEM hItem, + uint32_t dwCheckState) override; + + std::vector> m_ItemArray; + CFX_WideString m_wsData; + FX_FLOAT m_fItemHeight; + }; + + CFWL_ListBoxDP m_ListBoxDP; +}; + +class CFWL_ListItem { + public: + CFWL_ListItem() { + m_rtItem.Reset(); + m_dwStates = 0; + m_wsText = L""; + m_pDIB = NULL; + m_pData = NULL; + m_dwCheckState = 0; + m_rtCheckBox.Reset(); + } + 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_LIGHTWIDGET_CFWL_LISTBOX_H_ diff --git a/xfa/fwl/lightwidget/cfwl_picturebox.cpp b/xfa/fwl/lightwidget/cfwl_picturebox.cpp new file mode 100644 index 0000000000..b0bd3c9931 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_picturebox.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/lightwidget/cfwl_picturebox.h" + +#include + +CFWL_PictureBox* CFWL_PictureBox::Create() { + return new CFWL_PictureBox; +} + +FWL_ERR CFWL_PictureBox::Initialize(const CFWL_WidgetProperties* pProperties) { + if (m_pIface) + return FWL_ERR_Indefinite; + if (pProperties) { + *m_pProperties = *pProperties; + } + std::unique_ptr pPictureBox(IFWL_PictureBox::Create( + m_pProperties->MakeWidgetImpProperties(&m_PictureBoxDP), nullptr)); + FWL_ERR ret = pPictureBox->Initialize(); + if (ret != FWL_ERR_Succeeded) { + return ret; + } + m_pIface = pPictureBox.release(); + CFWL_Widget::Initialize(); + return FWL_ERR_Succeeded; +} + +CFX_DIBitmap* CFWL_PictureBox::GetPicture() { + return m_PictureBoxDP.m_pBitmap; +} + +FWL_ERR CFWL_PictureBox::SetPicture(CFX_DIBitmap* pBitmap) { + m_PictureBoxDP.m_pBitmap = pBitmap; + return FWL_ERR_Succeeded; +} + +FX_FLOAT CFWL_PictureBox::GetRotation() { + return m_PictureBoxDP.m_fRotation; +} + +FWL_ERR CFWL_PictureBox::SetRotation(FX_FLOAT fRotation) { + m_PictureBoxDP.m_fRotation = fRotation; + return FWL_ERR_Succeeded; +} + +int32_t CFWL_PictureBox::GetFlipMode() { + return m_PictureBoxDP.GetFlipMode(m_pIface); +} + +FWL_ERR CFWL_PictureBox::SetFlipMode(int32_t iFlipMode) { + m_PictureBoxDP.m_iFlipMode = iFlipMode; + return FWL_ERR_Succeeded; +} + +int32_t CFWL_PictureBox::GetOpacity() { + return m_PictureBoxDP.GetOpacity(m_pIface); +} + +FWL_ERR CFWL_PictureBox::SetOpacity(int32_t iOpacity) { + m_PictureBoxDP.m_iOpacity = iOpacity; + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_PictureBox::GetScale(FX_FLOAT& fScaleX, FX_FLOAT& fScaleY) { + CFX_Matrix matrix; + m_PictureBoxDP.GetMatrix(m_pIface, matrix); + matrix.Scale(fScaleX, fScaleY); + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_PictureBox::SetScale(FX_FLOAT fScaleX, FX_FLOAT fScaleY) { + m_PictureBoxDP.m_fScaleX = fScaleX; + m_PictureBoxDP.m_fScaleY = fScaleY; + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_PictureBox::GetOffset(FX_FLOAT& fx, FX_FLOAT& fy) { + CFX_Matrix matrix; + m_PictureBoxDP.GetMatrix(m_pIface, matrix); + fx = matrix.e; + fy = matrix.f; + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_PictureBox::SetOffset(FX_FLOAT fx, FX_FLOAT fy) { + m_PictureBoxDP.m_fOffSetX = fx; + m_PictureBoxDP.m_fOffSetY = fy; + return FWL_ERR_Succeeded; +} + +CFWL_PictureBox::CFWL_PictureBox() {} + +CFWL_PictureBox::~CFWL_PictureBox() {} + +FWL_ERR CFWL_PictureBox::CFWL_PictureBoxDP::GetCaption( + IFWL_Widget* pWidget, + CFX_WideString& wsCaption) { + return FWL_ERR_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_ERR 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_ERR_Succeeded; +} + +int32_t CFWL_PictureBox::CFWL_PictureBoxDP::GetFlipMode(IFWL_Widget* pWidget) { + return m_iFlipMode; +} diff --git a/xfa/fwl/lightwidget/cfwl_picturebox.h b/xfa/fwl/lightwidget/cfwl_picturebox.h new file mode 100644 index 0000000000..8fa985acd8 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_picturebox.h @@ -0,0 +1,64 @@ +// 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_LIGHTWIDGET_CFWL_PICTUREBOX_H_ +#define XFA_FWL_LIGHTWIDGET_CFWL_PICTUREBOX_H_ + +#include "xfa/fwl/basewidget/ifwl_picturebox.h" +#include "xfa/fwl/core/fwl_error.h" +#include "xfa/fwl/lightwidget/cfwl_widget.h" + +class CFWL_PictureBox : public CFWL_Widget { + public: + static CFWL_PictureBox* Create(); + FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); + CFX_DIBitmap* GetPicture(); + FWL_ERR SetPicture(CFX_DIBitmap* pBitmap); + FX_FLOAT GetRotation(); + FWL_ERR SetRotation(FX_FLOAT fRotation); + int32_t GetFlipMode(); + FWL_ERR SetFlipMode(int32_t iFlipMode); + int32_t GetOpacity(); + FWL_ERR SetOpacity(int32_t iOpacity); + FWL_ERR GetScale(FX_FLOAT& fScaleX, FX_FLOAT& fScaleY); + FWL_ERR SetScale(FX_FLOAT fScaleX, FX_FLOAT fScaleY); + FWL_ERR GetOffset(FX_FLOAT& fx, FX_FLOAT& fy); + FWL_ERR SetOffset(FX_FLOAT fx, FX_FLOAT fy); + CFWL_PictureBox(); + virtual ~CFWL_PictureBox(); + + protected: + class CFWL_PictureBoxDP : public IFWL_PictureBoxDP { + public: + CFWL_PictureBoxDP() { + m_fRotation = 0.0f; + m_fScaleX = 1.0f; + m_fScaleY = 1.0f; + m_fOffSetX = 0.0f; + m_fOffSetY = 0.0f; + m_pBitmap = NULL; + } + virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption); + virtual CFX_DIBitmap* GetPicture(IFWL_Widget* pWidget); + virtual CFX_DIBitmap* GetErrorPicture(IFWL_Widget* pWidget); + virtual CFX_DIBitmap* GetInitialPicture(IFWL_Widget* pWidget); + virtual int32_t GetOpacity(IFWL_Widget* pWidget); + virtual int32_t GetFlipMode(IFWL_Widget* pWidget); + virtual FWL_ERR GetMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix); + 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_LIGHTWIDGET_CFWL_PICTUREBOX_H_ diff --git a/xfa/fwl/lightwidget/cfwl_pushbutton.cpp b/xfa/fwl/lightwidget/cfwl_pushbutton.cpp new file mode 100644 index 0000000000..52747bdebe --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_pushbutton.cpp @@ -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 + +#include "xfa/fwl/lightwidget/cfwl_pushbutton.h" + +#include + +CFWL_PushButton* CFWL_PushButton::Create() { + return new CFWL_PushButton; +} + +FWL_ERR CFWL_PushButton::Initialize(const CFWL_WidgetProperties* pProperties) { + if (m_pIface) + return FWL_ERR_Indefinite; + if (pProperties) { + *m_pProperties = *pProperties; + } + std::unique_ptr pPushButton(IFWL_PushButton::Create( + m_pProperties->MakeWidgetImpProperties(&m_buttonData), nullptr)); + FWL_ERR ret = pPushButton->Initialize(); + if (ret != FWL_ERR_Succeeded) { + return ret; + } + m_pIface = pPushButton.release(); + CFWL_Widget::Initialize(); + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_PushButton::GetCaption(CFX_WideString& wsCaption) { + wsCaption = m_buttonData.m_wsCaption; + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_PushButton::SetCaption(const CFX_WideStringC& wsCaption) { + m_buttonData.m_wsCaption = wsCaption; + return FWL_ERR_Succeeded; +} + +CFX_DIBitmap* CFWL_PushButton::GetPicture() { + return m_buttonData.m_pBitmap; +} + +FWL_ERR CFWL_PushButton::SetPicture(CFX_DIBitmap* pBitmap) { + m_buttonData.m_pBitmap = pBitmap; + return FWL_ERR_Succeeded; +} + +CFWL_PushButton::CFWL_PushButton() {} + +CFWL_PushButton::~CFWL_PushButton() {} + +FWL_ERR CFWL_PushButton::CFWL_PushButtonDP::GetCaption( + IFWL_Widget* pWidget, + CFX_WideString& wsCaption) { + wsCaption = m_wsCaption; + return FWL_ERR_Succeeded; +} + +CFX_DIBitmap* CFWL_PushButton::CFWL_PushButtonDP::GetPicture( + IFWL_Widget* pWidget) { + return m_pBitmap; +} diff --git a/xfa/fwl/lightwidget/cfwl_pushbutton.h b/xfa/fwl/lightwidget/cfwl_pushbutton.h new file mode 100644 index 0000000000..99b067d2cf --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_pushbutton.h @@ -0,0 +1,36 @@ +// 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_LIGHTWIDGET_CFWL_PUSHBUTTON_H_ +#define XFA_FWL_LIGHTWIDGET_CFWL_PUSHBUTTON_H_ + +#include "xfa/fwl/basewidget/ifwl_pushbutton.h" +#include "xfa/fwl/lightwidget/cfwl_widget.h" + +class CFWL_PushButton : public CFWL_Widget { + public: + static CFWL_PushButton* Create(); + FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); + FWL_ERR GetCaption(CFX_WideString& wsCaption); + FWL_ERR SetCaption(const CFX_WideStringC& wsCaption); + CFX_DIBitmap* GetPicture(); + FWL_ERR SetPicture(CFX_DIBitmap* pBitmap); + CFWL_PushButton(); + virtual ~CFWL_PushButton(); + + protected: + class CFWL_PushButtonDP : public IFWL_PushButtonDP { + public: + CFWL_PushButtonDP() : m_pBitmap(NULL) {} + FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption); + virtual CFX_DIBitmap* GetPicture(IFWL_Widget* pWidget); + CFX_WideString m_wsCaption; + CFX_DIBitmap* m_pBitmap; + }; + CFWL_PushButtonDP m_buttonData; +}; + +#endif // XFA_FWL_LIGHTWIDGET_CFWL_PUSHBUTTON_H_ diff --git a/xfa/fwl/lightwidget/cfwl_scrollbar.cpp b/xfa/fwl/lightwidget/cfwl_scrollbar.cpp new file mode 100644 index 0000000000..0c02314733 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_scrollbar.cpp @@ -0,0 +1,108 @@ +// 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/lightwidget/cfwl_scrollbar.h" + +#include + +#include "xfa/fwl/basewidget/ifwl_scrollbar.h" + +CFWL_ScrollBar* CFWL_ScrollBar::Create() { + return new CFWL_ScrollBar; +} + +CFWL_ScrollBar::CFWL_ScrollBar() {} + +CFWL_ScrollBar::~CFWL_ScrollBar() {} + +FWL_ERR CFWL_ScrollBar::Initialize(const CFWL_WidgetProperties* pProperties) { + if (m_pIface) + return FWL_ERR_Indefinite; + if (pProperties) { + *m_pProperties = *pProperties; + } + std::unique_ptr pScrollBar(IFWL_ScrollBar::Create( + m_pProperties->MakeWidgetImpProperties(nullptr), nullptr)); + FWL_ERR ret = pScrollBar->Initialize(); + if (ret != FWL_ERR_Succeeded) { + return ret; + } + m_pIface = pScrollBar.release(); + CFWL_Widget::Initialize(); + return FWL_ERR_Succeeded; +} + +FX_BOOL CFWL_ScrollBar::IsVertical() { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->IsVertical(); +} + +FWL_ERR CFWL_ScrollBar::GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->GetRange(fMin, fMax); +} + +FWL_ERR CFWL_ScrollBar::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->SetRange(fMin, fMax); +} + +FX_FLOAT CFWL_ScrollBar::GetPageSize() { + if (!m_pIface) + return 0; + return static_cast(m_pIface)->GetPageSize(); +} + +FWL_ERR CFWL_ScrollBar::SetPageSize(FX_FLOAT fPageSize) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->SetPageSize(fPageSize); +} + +FX_FLOAT CFWL_ScrollBar::GetStepSize() { + if (!m_pIface) + return 0; + return static_cast(m_pIface)->GetStepSize(); +} + +FWL_ERR CFWL_ScrollBar::SetStepSize(FX_FLOAT fStepSize) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->SetStepSize(fStepSize); +} + +FX_FLOAT CFWL_ScrollBar::GetPos() { + if (!m_pIface) + return -1; + return static_cast(m_pIface)->GetPos(); +} + +FWL_ERR CFWL_ScrollBar::SetPos(FX_FLOAT fPos) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->SetPos(fPos); +} + +FX_FLOAT CFWL_ScrollBar::GetTrackPos() { + if (!m_pIface) + return -1; + return static_cast(m_pIface)->GetTrackPos(); +} + +FWL_ERR CFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return static_cast(m_pIface)->SetTrackPos(fTrackPos); +} + +FX_BOOL CFWL_ScrollBar::DoScroll(uint32_t dwCode, FX_FLOAT fPos) { + if (!m_pIface) + return FALSE; + return static_cast(m_pIface)->DoScroll(dwCode, fPos); +} diff --git a/xfa/fwl/lightwidget/cfwl_scrollbar.h b/xfa/fwl/lightwidget/cfwl_scrollbar.h new file mode 100644 index 0000000000..89c0fe44e4 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_scrollbar.h @@ -0,0 +1,32 @@ +// 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_LIGHTWIDGET_CFWL_SCROLLBAR_H_ +#define XFA_FWL_LIGHTWIDGET_CFWL_SCROLLBAR_H_ + +#include "xfa/fwl/lightwidget/cfwl_widget.h" + +class CFWL_ScrollBar : public CFWL_Widget { + public: + static CFWL_ScrollBar* Create(); + FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); + FX_BOOL IsVertical(); + FWL_ERR GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax); + FWL_ERR SetRange(FX_FLOAT fMin, FX_FLOAT fMax); + FX_FLOAT GetPageSize(); + FWL_ERR SetPageSize(FX_FLOAT fPageSize); + FX_FLOAT GetStepSize(); + FWL_ERR SetStepSize(FX_FLOAT fStepSize); + FX_FLOAT GetPos(); + FWL_ERR SetPos(FX_FLOAT fPos); + FX_FLOAT GetTrackPos(); + FWL_ERR SetTrackPos(FX_FLOAT fTrackPos); + FX_BOOL DoScroll(uint32_t dwCode, FX_FLOAT fPos = 0.0f); + CFWL_ScrollBar(); + virtual ~CFWL_ScrollBar(); +}; + +#endif // XFA_FWL_LIGHTWIDGET_CFWL_SCROLLBAR_H_ diff --git a/xfa/fwl/lightwidget/cfwl_theme.cpp b/xfa/fwl/lightwidget/cfwl_theme.cpp new file mode 100644 index 0000000000..fdb0a89997 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_theme.cpp @@ -0,0 +1,138 @@ +// 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/lightwidget/cfwl_theme.h" + +#include + +#include "xfa/fwl/core/cfwl_themebackground.h" +#include "xfa/fwl/core/cfwl_themepart.h" +#include "xfa/fwl/core/cfwl_themetext.h" +#include "xfa/fwl/theme/cfwl_barcodetp.h" +#include "xfa/fwl/theme/cfwl_carettp.h" +#include "xfa/fwl/theme/cfwl_checkboxtp.h" +#include "xfa/fwl/theme/cfwl_comboboxtp.h" +#include "xfa/fwl/theme/cfwl_datetimepickertp.h" +#include "xfa/fwl/theme/cfwl_edittp.h" +#include "xfa/fwl/theme/cfwl_formtp.h" +#include "xfa/fwl/theme/cfwl_listboxtp.h" +#include "xfa/fwl/theme/cfwl_monthcalendartp.h" +#include "xfa/fwl/theme/cfwl_pictureboxtp.h" +#include "xfa/fwl/theme/cfwl_pushbuttontp.h" +#include "xfa/fwl/theme/cfwl_scrollbartp.h" + +CFWL_Theme::CFWL_Theme() { + m_ThemesArray.push_back(std::unique_ptr(new CFWL_FormTP)); + m_ThemesArray.push_back( + std::unique_ptr(new CFWL_PushButtonTP)); + m_ThemesArray.push_back(std::unique_ptr(new CFWL_CheckBoxTP)); + m_ThemesArray.push_back(std::unique_ptr(new CFWL_ListBoxTP)); + m_ThemesArray.push_back( + std::unique_ptr(new CFWL_PictureBoxTP)); + m_ThemesArray.push_back(std::unique_ptr(new CFWL_ScrollBarTP)); + m_ThemesArray.push_back(std::unique_ptr(new CFWL_EditTP)); + m_ThemesArray.push_back(std::unique_ptr(new CFWL_ComboBoxTP)); + m_ThemesArray.push_back(std::unique_ptr(new CFWL_BarcodeTP)); + m_ThemesArray.push_back( + std::unique_ptr(new CFWL_DateTimePickerTP)); + m_ThemesArray.push_back( + std::unique_ptr(new CFWL_MonthCalendarTP)); + m_ThemesArray.push_back(std::unique_ptr(new CFWL_CaretTP)); +} + +CFWL_Theme::~CFWL_Theme() {} + +FX_BOOL CFWL_Theme::IsValidWidget(IFWL_Widget* pWidget) { + return !!GetTheme(pWidget); +} + +uint32_t CFWL_Theme::GetThemeID(IFWL_Widget* pWidget) { + return GetTheme(pWidget)->GetThemeID(pWidget); +} + +uint32_t CFWL_Theme::SetThemeID(IFWL_Widget* pWidget, + uint32_t dwThemeID, + FX_BOOL bChildren) { + uint32_t dwID; + for (const auto& pTheme : m_ThemesArray) { + dwID = pTheme->GetThemeID(pWidget); + pTheme->SetThemeID(pWidget, dwThemeID, FALSE); + } + return dwID; +} + +FWL_ERR CFWL_Theme::GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) { + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_Theme::SetThemeMatrix(IFWL_Widget* pWidget, + const CFX_Matrix& matrix) { + return FWL_ERR_Succeeded; +} + +FX_BOOL CFWL_Theme::DrawBackground(CFWL_ThemeBackground* pParams) { + return GetTheme(pParams->m_pWidget)->DrawBackground(pParams); +} + +FX_BOOL CFWL_Theme::DrawText(CFWL_ThemeText* pParams) { + return GetTheme(pParams->m_pWidget)->DrawText(pParams); +} + +void* CFWL_Theme::GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity) { + return GetTheme(pThemePart->m_pWidget)->GetCapacity(pThemePart, dwCapacity); +} + +FX_BOOL CFWL_Theme::IsCustomizedLayout(IFWL_Widget* pWidget) { + return GetTheme(pWidget)->IsCustomizedLayout(pWidget); +} + +FWL_ERR CFWL_Theme::GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart) { + return GetTheme(pThemePart->m_pWidget)->GetPartRect(pThemePart, rtPart); +} + +FX_BOOL CFWL_Theme::IsInPart(CFWL_ThemePart* pThemePart, + FX_FLOAT fx, + FX_FLOAT fy) { + return GetTheme(pThemePart->m_pWidget)->IsInPart(pThemePart, fx, fy); +} + +FX_BOOL CFWL_Theme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { + return GetTheme(pParams->m_pWidget)->CalcTextRect(pParams, rect); +} + +FWL_ERR CFWL_Theme::Initialize() { + for (const auto& pTheme : m_ThemesArray) + pTheme->Initialize(); + + FWLTHEME_Init(); + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_Theme::Finalize() { + for (const auto& pTheme : m_ThemesArray) + pTheme->Finalize(); + + FWLTHEME_Release(); + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_Theme::SetFont(IFWL_Widget* pWidget, + const FX_WCHAR* strFont, + FX_FLOAT fFontSize, + FX_ARGB rgbFont) { + for (const auto& pTheme : m_ThemesArray) + pTheme->SetFont(pWidget, strFont, fFontSize, rgbFont); + + return FWL_ERR_Succeeded; +} + +CFWL_WidgetTP* CFWL_Theme::GetTheme(IFWL_Widget* pWidget) { + for (const auto& pTheme : m_ThemesArray) { + if (pTheme->IsValidWidget(pWidget)) + return pTheme.get(); + } + return nullptr; +} diff --git a/xfa/fwl/lightwidget/cfwl_theme.h b/xfa/fwl/lightwidget/cfwl_theme.h new file mode 100644 index 0000000000..fa62e092fb --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_theme.h @@ -0,0 +1,59 @@ +// 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_LIGHTWIDGET_CFWL_THEME_H_ +#define XFA_FWL_LIGHTWIDGET_CFWL_THEME_H_ + +#include +#include + +#include "core/fxcrt/include/fx_coordinates.h" +#include "core/fxcrt/include/fx_system.h" +#include "core/include/fxge/fx_dib.h" +#include "xfa/fwl/core/ifwl_themeprovider.h" + +class CFWL_WidgetTP; +class IFWL_Widget; +class CFWL_ThemePart; +class CFWL_ThemeText; + +class CFWL_Theme : public IFWL_ThemeProvider { + public: + CFWL_Theme(); + ~CFWL_Theme() override; + + // IFWL_ThemeProvider: + FX_BOOL IsValidWidget(IFWL_Widget* pWidget) override; + uint32_t GetThemeID(IFWL_Widget* pWidget) override; + uint32_t SetThemeID(IFWL_Widget* pWidget, + uint32_t dwThemeID, + FX_BOOL bChildren = TRUE) override; + FWL_ERR GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) override; + FWL_ERR SetThemeMatrix(IFWL_Widget* pWidget, + const CFX_Matrix& matrix) override; + FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams) override; + FX_BOOL DrawText(CFWL_ThemeText* pParams) override; + void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity) override; + FX_BOOL IsCustomizedLayout(IFWL_Widget* pWidget) override; + FWL_ERR GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart) override; + FX_BOOL IsInPart(CFWL_ThemePart* pThemePart, + FX_FLOAT fx, + FX_FLOAT fy) override; + FX_BOOL CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) override; + + FWL_ERR Initialize(); + FWL_ERR Finalize(); + FWL_ERR SetFont(IFWL_Widget* pWidget, + const FX_WCHAR* strFont, + FX_FLOAT fFontSize, + FX_ARGB rgbFont); + CFWL_WidgetTP* GetTheme(IFWL_Widget* pWidget); + + protected: + std::vector> m_ThemesArray; +}; + +#endif // XFA_FWL_LIGHTWIDGET_CFWL_THEME_H_ diff --git a/xfa/fwl/lightwidget/cfwl_tooltip.cpp b/xfa/fwl/lightwidget/cfwl_tooltip.cpp new file mode 100644 index 0000000000..abdf48997c --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_tooltip.cpp @@ -0,0 +1,134 @@ +// 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/lightwidget/cfwl_tooltip.h" + +#include + +#include "xfa/fwl/core/fwl_formimp.h" +#include "xfa/fwl/core/fwl_noteimp.h" +#include "xfa/fwl/core/fwl_panelimp.h" +#include "xfa/fwl/core/fwl_targetimp.h" +#include "xfa/fwl/core/fwl_threadimp.h" +#include "xfa/fwl/core/fwl_widgetimp.h" + +CFWL_ToolTip* CFWL_ToolTip::Create() { + return new CFWL_ToolTip; +} + +FWL_ERR CFWL_ToolTip::Initialize(const CFWL_WidgetProperties* pProperties) { + if (m_pIface) + return FWL_ERR_Indefinite; + if (pProperties) { + *m_pProperties = *pProperties; + } + std::unique_ptr pToolTip(IFWL_ToolTip::Create( + m_pProperties->MakeWidgetImpProperties(&m_tooltipData), nullptr)); + FWL_ERR ret = pToolTip->Initialize(); + if (ret != FWL_ERR_Succeeded) { + return ret; + } + m_pIface = pToolTip.release(); + CFWL_Widget::Initialize(); + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_ToolTip::GetCaption(CFX_WideString& wsCaption) { + wsCaption = m_tooltipData.m_wsCaption; + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_ToolTip::SetCaption(const CFX_WideStringC& wsCaption) { + m_tooltipData.m_wsCaption = wsCaption; + return FWL_ERR_Succeeded; +} + +int32_t CFWL_ToolTip::GetInitialDelay() { + return m_tooltipData.m_nInitDelayTime; +} + +int32_t CFWL_ToolTip::SetInitialDelay(int32_t nDelayTime) { + m_tooltipData.m_nInitDelayTime = nDelayTime; + return FWL_ERR_Succeeded; +} + +int32_t CFWL_ToolTip::GetAutoPopDelay() { + return m_tooltipData.m_nAutoPopDelayTime; +} + +int32_t CFWL_ToolTip::SetAutoPopDelay(int32_t nDelayTime) { + m_tooltipData.m_nAutoPopDelayTime = nDelayTime; + return FWL_ERR_Succeeded; +} + +CFX_DIBitmap* CFWL_ToolTip::GetToolTipIcon() { + return m_tooltipData.m_pBitmap; +} + +FWL_ERR CFWL_ToolTip::SetToolTipIcon(CFX_DIBitmap* pBitmap) { + m_tooltipData.m_pBitmap = pBitmap; + return FWL_ERR_Succeeded; +} + +CFX_SizeF CFWL_ToolTip::GetToolTipIconSize() { + return m_tooltipData.m_fIconSize; +} + +FWL_ERR CFWL_ToolTip::SetToolTipIconSize(CFX_SizeF fSize) { + m_tooltipData.m_fIconSize = fSize; + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_ToolTip::SetAnchor(const CFX_RectF& rtAnchor) { + return static_cast(m_pIface)->SetAnchor(rtAnchor); +} + +FWL_ERR CFWL_ToolTip::Show() { + return static_cast(m_pIface)->Show(); +} + +FWL_ERR CFWL_ToolTip::Hide() { + return static_cast(m_pIface)->Hide(); +} + +CFWL_ToolTip::CFWL_ToolTip() {} + +CFWL_ToolTip::~CFWL_ToolTip() {} + +CFWL_ToolTip::CFWL_ToolTipDP::CFWL_ToolTipDP() : m_pBitmap(NULL) { + m_wsCaption = L""; + m_nInitDelayTime = 500; + m_nAutoPopDelayTime = 50000; + m_fAnchor.Set(0.0, 0.0, 0.0, 0.0); +} + +FWL_ERR CFWL_ToolTip::CFWL_ToolTipDP::GetCaption(IFWL_Widget* pWidget, + CFX_WideString& wsCaption) { + wsCaption = m_wsCaption; + return FWL_ERR_Succeeded; +} + +int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetInitialDelay(IFWL_Widget* pWidget) { + return m_nInitDelayTime; +} + +int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetAutoPopDelay(IFWL_Widget* pWidget) { + return m_nAutoPopDelayTime; +} + +CFX_DIBitmap* CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIcon( + IFWL_Widget* pWidget) { + return m_pBitmap; +} + +CFX_SizeF CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIconSize( + IFWL_Widget* pWidget) { + return m_fIconSize; +} + +CFX_RectF CFWL_ToolTip::CFWL_ToolTipDP::GetAnchor() { + return m_fAnchor; +} diff --git a/xfa/fwl/lightwidget/cfwl_tooltip.h b/xfa/fwl/lightwidget/cfwl_tooltip.h new file mode 100644 index 0000000000..817362a41c --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_tooltip.h @@ -0,0 +1,53 @@ +// 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_LIGHTWIDGET_CFWL_TOOLTIP_H_ +#define XFA_FWL_LIGHTWIDGET_CFWL_TOOLTIP_H_ + +#include "xfa/fwl/basewidget/ifwl_tooltip.h" +#include "xfa/fwl/lightwidget/cfwl_widget.h" + +class CFWL_ToolTip : public CFWL_Widget { + public: + static CFWL_ToolTip* Create(); + FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); + FWL_ERR GetCaption(CFX_WideString& wsCaption); + FWL_ERR SetCaption(const CFX_WideStringC& wsCaption); + int32_t GetInitialDelay(); + int32_t SetInitialDelay(int32_t nDelayTime); + int32_t GetAutoPopDelay(); + int32_t SetAutoPopDelay(int32_t nDelayTime); + CFX_DIBitmap* GetToolTipIcon(); + FWL_ERR SetToolTipIcon(CFX_DIBitmap* pBitmap); + CFX_SizeF GetToolTipIconSize(); + FWL_ERR SetToolTipIconSize(CFX_SizeF fSize); + FWL_ERR SetAnchor(const CFX_RectF& rtAnchor); + FWL_ERR Show(); + FWL_ERR Hide(); + CFWL_ToolTip(); + virtual ~CFWL_ToolTip(); + + protected: + class CFWL_ToolTipDP : public IFWL_ToolTipDP { + public: + CFWL_ToolTipDP(); + FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption); + int32_t GetInitialDelay(IFWL_Widget* pWidget); + int32_t GetAutoPopDelay(IFWL_Widget* pWidget); + CFX_DIBitmap* GetToolTipIcon(IFWL_Widget* pWidget); + CFX_SizeF GetToolTipIconSize(IFWL_Widget* pWidget); + CFX_RectF GetAnchor(); + CFX_WideString m_wsCaption; + int32_t m_nInitDelayTime; + int32_t m_nAutoPopDelayTime; + CFX_DIBitmap* m_pBitmap; + CFX_SizeF m_fIconSize; + CFX_RectF m_fAnchor; + }; + CFWL_ToolTipDP m_tooltipData; +}; + +#endif // XFA_FWL_LIGHTWIDGET_CFWL_TOOLTIP_H_ diff --git a/xfa/fwl/lightwidget/cfwl_widget.cpp b/xfa/fwl/lightwidget/cfwl_widget.cpp new file mode 100644 index 0000000000..1f4512e381 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_widget.cpp @@ -0,0 +1,331 @@ +// 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/lightwidget/cfwl_widget.h" + +#include "xfa/fde/tto/fde_textout.h" +#include "xfa/fwl/core/cfwl_themetext.h" +#include "xfa/fwl/core/fwl_noteimp.h" +#include "xfa/fwl/core/fwl_noteimp.h" +#include "xfa/fwl/core/fwl_targetimp.h" +#include "xfa/fwl/core/fwl_widgetimp.h" +#include "xfa/fwl/core/fwl_widgetmgrimp.h" +#include "xfa/fwl/core/ifwl_notethread.h" +#include "xfa/fwl/core/ifwl_themeprovider.h" + +IFWL_Widget* CFWL_Widget::GetWidget() { + return m_pIface; +} + +FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->GetClassName(wsClass); +} + +uint32_t CFWL_Widget::GetClassID() const { + if (!m_pIface) + return 0; + return m_pIface->GetClassID(); +} + +FX_BOOL CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { + if (!m_pIface) + return FALSE; + return m_pIface->IsInstance(wsClass); +} + +static void* gs_pFWLWidget = (void*)FXBSTR_ID('l', 'i', 'g', 't'); + +FWL_ERR CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->SetPrivateData(gs_pFWLWidget, this, NULL); +} + +FWL_ERR CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->GetWidgetRect(rect, bAutoSize); +} + +FWL_ERR CFWL_Widget::GetGlobalRect(CFX_RectF& rect) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->GetGlobalRect(rect); +} + +FWL_ERR CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->SetWidgetRect(rect); +} + +FWL_ERR CFWL_Widget::GetClientRect(CFX_RectF& rect) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->GetClientRect(rect); +} + +CFWL_Widget* CFWL_Widget::GetParent() { + if (!m_pIface) + return NULL; + IFWL_Widget* parent = m_pIface->GetParent(); + if (parent) { + return static_cast(parent->GetPrivateData(gs_pFWLWidget)); + } + return NULL; +} + +FWL_ERR CFWL_Widget::SetParent(CFWL_Widget* pParent) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->SetParent(pParent ? pParent->GetWidget() : NULL); +} + +CFWL_Widget* CFWL_Widget::GetOwner() { + if (!m_pIface) + return NULL; + return NULL; +} + +FWL_ERR CFWL_Widget::SetOwner(CFWL_Widget* pOwner) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return FWL_ERR_Succeeded; +} + +uint32_t CFWL_Widget::GetStyles() { + if (!m_pIface) + return 0; + return m_pIface->GetStyles(); +} + +FWL_ERR CFWL_Widget::ModifyStyles(uint32_t dwStylesAdded, + uint32_t dwStylesRemoved) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->ModifyStyles(dwStylesAdded, dwStylesRemoved); +} +uint32_t CFWL_Widget::GetStylesEx() { + if (!m_pIface) + return 0; + return m_pIface->GetStylesEx(); +} + +FWL_ERR CFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded, + uint32_t dwStylesExRemoved) { + return m_pIface->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); +} + +uint32_t CFWL_Widget::GetStates() { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->GetStates(); +} + +FWL_ERR CFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->SetStates(dwStates, bSet); +} + +FWL_ERR CFWL_Widget::SetPrivateData(void* module_id, + void* pData, + PD_CALLBACK_FREEDATA callback) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->SetPrivateData(module_id, pData, callback); +} + +void* CFWL_Widget::GetPrivateData(void* module_id) { + if (!m_pIface) + return NULL; + return m_pIface->GetPrivateData(module_id); +} + +FWL_ERR CFWL_Widget::Update() { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->Update(); +} + +FWL_ERR CFWL_Widget::LockUpdate() { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->LockUpdate(); +} + +FWL_ERR CFWL_Widget::UnlockUpdate() { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->UnlockUpdate(); +} + +uint32_t CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { + if (!m_pIface) + return 0; + return m_pIface->HitTest(fx, fy); +} + +FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget, + FX_FLOAT& fx, + FX_FLOAT& fy) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : NULL, fx, fy); +} + +FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : NULL, rt); +} + +FWL_ERR CFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->GetMatrix(matrix, bGlobal); +} + +FWL_ERR CFWL_Widget::SetMatrix(const CFX_Matrix& matrix) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->SetMatrix(matrix); +} + +FWL_ERR CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + if (!m_pIface) + return FWL_ERR_Indefinite; + return m_pIface->DrawWidget(pGraphics, pMatrix); +} + +IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { + if (!m_pIface) + return NULL; + m_pDelegate = m_pIface->SetDelegate(pDelegate); + return m_pDelegate; +} + +CFWL_Widget::CFWL_Widget() + : m_pIface(NULL), m_pDelegate(NULL), m_pProperties(NULL) { + m_pProperties = new CFWL_WidgetProperties; + m_pWidgetMgr = static_cast(FWL_GetWidgetMgr()); + FXSYS_assert(m_pWidgetMgr != NULL); +} + +CFWL_Widget::~CFWL_Widget() { + delete m_pProperties; + if (m_pIface) { + m_pIface->Finalize(); + delete m_pIface; + } +} + +FWL_ERR CFWL_Widget::Repaint(const CFX_RectF* pRect) { + if (!m_pIface) + return FWL_ERR_Indefinite; + CFX_RectF rect; + if (pRect) { + rect = *pRect; + } else { + m_pIface->GetWidgetRect(rect); + rect.left = rect.top = 0; + } + return m_pWidgetMgr->RepaintWidget(m_pIface, &rect); +} + +FWL_ERR CFWL_Widget::SetFocus(FX_BOOL bFocus) { + if (!m_pIface) + return FWL_ERR_Indefinite; + IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); + if (!pThread) + return FWL_ERR_Indefinite; + IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); + if (!pDriver) + return FWL_ERR_Indefinite; + if (bFocus) { + pDriver->SetFocus(m_pIface); + } else { + if (pDriver->GetFocus() == m_pIface) { + pDriver->SetFocus(NULL); + } + } + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_Widget::SetGrab(FX_BOOL bSet) { + if (!m_pIface) + return FWL_ERR_Indefinite; + IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); + if (!pThread) + return FWL_ERR_Indefinite; + IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); + if (!pDriver) + return FWL_ERR_Indefinite; + pDriver->SetGrab(m_pIface, bSet); + return FWL_ERR_Succeeded; +} + +void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource, + uint32_t dwFilter) { + if (!m_pIface) + return; + IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); + if (!pThread) + return; + IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); + if (!pNoteDriver) + return; + IFWL_Widget* pEventSourceImp = + !pEventSource ? NULL : pEventSource->GetWidget(); + pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter); +} + +void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { + if (!m_pIface) + return; + if (m_pIface->GetOuter()) { + return; + } + IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); + if (!pThread) + return; + IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); + if (!pNoteDriver) + return; + pNoteDriver->SendNote(pEvent); +} + +#define FWL_WGT_CalcHeight 2048 +#define FWL_WGT_CalcWidth 2048 +#define FWL_WGT_CalcMultiLineDefWidth 120.0f + +CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText, + FX_BOOL bMultiLine, + int32_t iLineWidth) { + if (!m_pIface) + return CFX_SizeF(); + IFWL_ThemeProvider* pTheme = m_pIface->GetThemeProvider(); + if (!pTheme) + return CFX_SizeF(); + + CFWL_ThemeText calPart; + calPart.m_pWidget = m_pIface; + calPart.m_wsText = wsText; + calPart.m_dwTTOStyles = + bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine; + calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; + CFX_RectF rect; + FX_FLOAT fWidth = bMultiLine + ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth + : FWL_WGT_CalcMultiLineDefWidth) + : FWL_WGT_CalcWidth; + rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); + pTheme->CalcTextRect(&calPart, rect); + return CFX_SizeF(rect.width, rect.height); +} diff --git a/xfa/fwl/lightwidget/cfwl_widget.h b/xfa/fwl/lightwidget/cfwl_widget.h new file mode 100644 index 0000000000..f1b6715811 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_widget.h @@ -0,0 +1,76 @@ +// 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_LIGHTWIDGET_CFWL_WIDGET_H_ +#define XFA_FWL_LIGHTWIDGET_CFWL_WIDGET_H_ + +#include "xfa/fwl/core/cfwl_event.h" +#include "xfa/fwl/lightwidget/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: + virtual ~CFWL_Widget(); + IFWL_Widget* GetWidget(); + FWL_ERR GetClassName(CFX_WideString& wsClass) const; + uint32_t GetClassID() const; + virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const; + + FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE); + FWL_ERR GetGlobalRect(CFX_RectF& rect); + FWL_ERR SetWidgetRect(const CFX_RectF& rect); + FWL_ERR GetClientRect(CFX_RectF& rtClient); + CFWL_Widget* GetParent(); + FWL_ERR SetParent(CFWL_Widget* pParent); + CFWL_Widget* GetOwner(); + FWL_ERR SetOwner(CFWL_Widget* pOwner); + uint32_t GetStyles(); + FWL_ERR ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved); + uint32_t GetStylesEx(); + FWL_ERR ModifyStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved); + uint32_t GetStates(); + FWL_ERR SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE); + FWL_ERR SetPrivateData(void* module_id, + void* pData, + PD_CALLBACK_FREEDATA callback); + void* GetPrivateData(void* module_id); + FWL_ERR Update(); + FWL_ERR LockUpdate(); + FWL_ERR UnlockUpdate(); + uint32_t HitTest(FX_FLOAT fx, FX_FLOAT fy); + FWL_ERR TransformTo(CFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy); + FWL_ERR TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt); + FWL_ERR GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE); + FWL_ERR SetMatrix(const CFX_Matrix& matrix); + FWL_ERR DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix = NULL); + IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate); + FWL_ERR Repaint(const CFX_RectF* pRect = NULL); + FWL_ERR SetFocus(FX_BOOL bFocus); + FWL_ERR SetGrab(FX_BOOL bSet); + CFWL_Widget(); + + void RegisterEventTarget(CFWL_Widget* pEventSource = NULL, + uint32_t dwFilter = FWL_EVENT_ALL_MASK); + void DispatchEvent(CFWL_Event* pEvent); + CFX_SizeF CalcTextSize(const CFX_WideString& wsText, + FX_BOOL bMultiLine = FALSE, + int32_t iLineWidth = -1); + IFWL_Widget* m_pIface; + IFWL_WidgetDelegate* m_pDelegate; + CFWL_WidgetMgr* m_pWidgetMgr; + CFWL_WidgetProperties* m_pProperties; + + protected: + FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); +}; + +#endif // XFA_FWL_LIGHTWIDGET_CFWL_WIDGET_H_ diff --git a/xfa/fwl/lightwidget/cfwl_widgetdelegate.cpp b/xfa/fwl/lightwidget/cfwl_widgetdelegate.cpp new file mode 100644 index 0000000000..1596aba48a --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_widgetdelegate.cpp @@ -0,0 +1,27 @@ +// 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/lightwidget/cfwl_widgetdelegate.h" + +#include "xfa/fwl/core/cfwl_event.h" +#include "xfa/fwl/core/cfwl_message.h" + +CFWL_WidgetDelegate::CFWL_WidgetDelegate() {} + +CFWL_WidgetDelegate::~CFWL_WidgetDelegate() {} + +int32_t CFWL_WidgetDelegate::OnProcessMessage(CFWL_Message* pMessage) { + return 1; +} + +FWL_ERR CFWL_WidgetDelegate::OnProcessEvent(CFWL_Event* pEvent) { + return FWL_ERR_Succeeded; +} + +FWL_ERR CFWL_WidgetDelegate::OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { + return FWL_ERR_Succeeded; +} diff --git a/xfa/fwl/lightwidget/cfwl_widgetdelegate.h b/xfa/fwl/lightwidget/cfwl_widgetdelegate.h new file mode 100644 index 0000000000..42f6f9329f --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_widgetdelegate.h @@ -0,0 +1,29 @@ +// 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_LIGHTWIDGET_CFWL_WIDGETDELEGATE_H_ +#define XFA_FWL_LIGHTWIDGET_CFWL_WIDGETDELEGATE_H_ + +#include "xfa/fwl/core/fwl_error.h" +#include "xfa/fwl/core/ifwl_widgetdelegate.h" + +class CFWL_Event; +class CFWL_Message; +class CFX_Graphics; +class CFX_Matrix; + +class CFWL_WidgetDelegate : public IFWL_WidgetDelegate { + public: + CFWL_WidgetDelegate(); + virtual ~CFWL_WidgetDelegate(); + + int32_t OnProcessMessage(CFWL_Message* pMessage) override; + FWL_ERR OnProcessEvent(CFWL_Event* pEvent) override; + FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix = nullptr) override; +}; + +#endif // XFA_FWL_LIGHTWIDGET_CFWL_WIDGETDELEGATE_H_ diff --git a/xfa/fwl/lightwidget/cfwl_widgetproperties.cpp b/xfa/fwl/lightwidget/cfwl_widgetproperties.cpp new file mode 100644 index 0000000000..9afa1b6959 --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_widgetproperties.cpp @@ -0,0 +1,25 @@ +// 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/lightwidget/cfwl_widgetproperties.h" + +#include "xfa/fwl/lightwidget/cfwl_widget.h" + +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/lightwidget/cfwl_widgetproperties.h b/xfa/fwl/lightwidget/cfwl_widgetproperties.h new file mode 100644 index 0000000000..2a3e3ffefb --- /dev/null +++ b/xfa/fwl/lightwidget/cfwl_widgetproperties.h @@ -0,0 +1,42 @@ +// 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_LIGHTWIDGET_CFWL_WIDGETPROPERTIES_H_ +#define XFA_FWL_LIGHTWIDGET_CFWL_WIDGETPROPERTIES_H_ + +#include "core/fxcrt/include/fx_coordinates.h" +#include "core/fxcrt/include/fx_string.h" +#include "core/fxcrt/include/fx_system.h" +#include "xfa/fwl/core/cfwl_widgetimpproperties.h" + +class CFWL_Widget; +class IFWL_DataProvider; + +class CFWL_WidgetProperties { + public: + 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_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_LIGHTWIDGET_CFWL_WIDGETPROPERTIES_H_ diff --git a/xfa/fwl/lightwidget/checkbox.cpp b/xfa/fwl/lightwidget/checkbox.cpp deleted file mode 100644 index 1d921993d6..0000000000 --- a/xfa/fwl/lightwidget/checkbox.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// 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/include/fwl/lightwidget/checkbox.h" - -#include - -#include "xfa/fwl/core/fwl_error.h" - -CFWL_CheckBox* CFWL_CheckBox::Create() { - return new CFWL_CheckBox; -} -FWL_ERR CFWL_CheckBox::Initialize(const CFWL_WidgetProperties* pProperties) { - if (m_pIface) - return FWL_ERR_Indefinite; - if (pProperties) { - *m_pProperties = *pProperties; - } - std::unique_ptr pCheckBox(IFWL_CheckBox::Create( - m_pProperties->MakeWidgetImpProperties(&m_checkboxData), nullptr)); - FWL_ERR ret = pCheckBox->Initialize(); - if (ret != FWL_ERR_Succeeded) { - return ret; - } - m_pIface = pCheckBox.release(); - CFWL_Widget::Initialize(); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_CheckBox::SetCaption(const CFX_WideStringC& wsCaption) { - m_checkboxData.m_wsCaption = wsCaption; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_CheckBox::SetBoxSize(FX_FLOAT fHeight) { - m_checkboxData.m_fBoxHeight = fHeight; - return FWL_ERR_Succeeded; -} -int32_t CFWL_CheckBox::GetCheckState() { - return static_cast(m_pIface)->GetCheckState(); -} -FWL_ERR CFWL_CheckBox::SetCheckState(int32_t iCheck) { - return static_cast(m_pIface)->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_ERR CFWL_CheckBox::CFWL_CheckBoxDP::GetCaption(IFWL_Widget* pWidget, - CFX_WideString& wsCaption) { - wsCaption = m_wsCaption; - return FWL_ERR_Succeeded; -} -FX_FLOAT CFWL_CheckBox::CFWL_CheckBoxDP::GetBoxSize(IFWL_Widget* pWidget) { - return m_fBoxHeight; -} diff --git a/xfa/fwl/lightwidget/combobox.cpp b/xfa/fwl/lightwidget/combobox.cpp deleted file mode 100644 index 65b1081832..0000000000 --- a/xfa/fwl/lightwidget/combobox.cpp +++ /dev/null @@ -1,370 +0,0 @@ -// 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/include/fwl/lightwidget/combobox.h" - -#include - -#include "xfa/fwl/core/fwl_error.h" -#include "xfa/fwl/core/ifwl_widget.h" - -CFWL_ComboBox* CFWL_ComboBox::Create() { - return new CFWL_ComboBox; -} -FWL_ERR CFWL_ComboBox::Initialize(const CFWL_WidgetProperties* pProperties) { - if (m_pIface) - return FWL_ERR_Indefinite; - if (pProperties) { - *m_pProperties = *pProperties; - } - std::unique_ptr pComboBox(IFWL_ComboBox::Create( - m_pProperties->MakeWidgetImpProperties(&m_comboBoxData))); - FWL_ERR ret = pComboBox->Initialize(); - if (ret != FWL_ERR_Succeeded) { - return ret; - } - m_pIface = pComboBox.release(); - CFWL_Widget::Initialize(); - return FWL_ERR_Succeeded; -} -int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { - std::unique_ptr 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 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(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_ERR CFWL_ComboBox::GetTextByIndex(int32_t iIndex, CFX_WideString& wsText) { - CFWL_ComboBoxItem* pItem = reinterpret_cast( - m_comboBoxData.GetItem(m_pIface, iIndex)); - if (!pItem) - return FWL_ERR_Indefinite; - wsText = pItem->m_wsText; - return FWL_ERR_Succeeded; -} -int32_t CFWL_ComboBox::GetCurSel() { - if (!m_pIface) - return -1; - return static_cast(m_pIface)->GetCurSel(); -} -FWL_ERR CFWL_ComboBox::SetCurSel(int32_t iSel) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->SetCurSel(iSel); -} -FWL_ERR CFWL_ComboBox::SetEditText(const CFX_WideStringC& wsText) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->SetEditText(wsText); -} -int32_t CFWL_ComboBox::GetEditTextLength() const { - if (!m_pIface) - return 0; - return static_cast(m_pIface)->GetEditTextLength(); -} -FWL_ERR CFWL_ComboBox::GetEditText(CFX_WideString& wsText, - int32_t nStart, - int32_t nCount) const { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface) - ->GetEditText(wsText, nStart, nCount); -} -FWL_ERR CFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->SetEditSelRange(nStart, nCount); -} -int32_t CFWL_ComboBox::GetEditSelRange(int32_t nIndex, int32_t& nStart) { - if (!m_pIface) - return 0; - return static_cast(m_pIface)->GetEditSelRange(nIndex, nStart); -} -int32_t CFWL_ComboBox::GetEditLimit() { - if (!m_pIface) - return 0; - return static_cast(m_pIface)->GetEditLimit(); -} -FWL_ERR CFWL_ComboBox::SetEditLimit(int32_t nLimit) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->SetEditLimit(nLimit); -} -FWL_ERR CFWL_ComboBox::EditDoClipboard(int32_t iCmd) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->EditDoClipboard(iCmd); -} -FX_BOOL CFWL_ComboBox::EditRedo(const CFX_ByteStringC& bsRecord) { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->EditRedo(bsRecord); -} -FX_BOOL CFWL_ComboBox::EditUndo(const CFX_ByteStringC& bsRecord) { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->EditUndo(bsRecord); -} -FWL_ERR CFWL_ComboBox::SetMaxListHeight(FX_FLOAT fMaxHeight) { - m_comboBoxData.m_fMaxListHeight = fMaxHeight; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ComboBox::SetItemData(int32_t iIndex, void* pData) { - CFWL_ComboBoxItem* pItem = reinterpret_cast( - m_comboBoxData.GetItem(m_pIface, iIndex)); - if (!pItem) - return FWL_ERR_Indefinite; - pItem->m_pData = pData; - return FWL_ERR_Succeeded; -} -void* CFWL_ComboBox::GetItemData(int32_t iIndex) { - CFWL_ComboBoxItem* pItem = reinterpret_cast( - m_comboBoxData.GetItem(m_pIface, iIndex)); - if (!pItem) - return NULL; - return pItem->m_pData; -} -FWL_ERR CFWL_ComboBox::SetListTheme(IFWL_ThemeProvider* pTheme) { - return static_cast(m_pIface)->GetListBoxt()->SetThemeProvider( - pTheme); -} -FX_BOOL CFWL_ComboBox::AfterFocusShowDropList() { - return static_cast(m_pIface)->AfterFocusShowDropList(); -} -FWL_ERR CFWL_ComboBox::OpenDropDownList(FX_BOOL bActivate) { - return static_cast(m_pIface)->OpenDropDownList(bActivate); -} -FX_BOOL CFWL_ComboBox::EditCanUndo() { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->EditCanUndo(); -} -FX_BOOL CFWL_ComboBox::EditCanRedo() { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->EditCanRedo(); -} -FX_BOOL CFWL_ComboBox::EditUndo() { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->EditUndo(); -} -FX_BOOL CFWL_ComboBox::EditRedo() { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->EditRedo(); -} -FX_BOOL CFWL_ComboBox::EditCanCopy() { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->EditCanCopy(); -} -FX_BOOL CFWL_ComboBox::EditCanCut() { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->EditCanCut(); -} -FX_BOOL CFWL_ComboBox::EditCanSelectAll() { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->EditCanSelectAll(); -} -FX_BOOL CFWL_ComboBox::EditCopy(CFX_WideString& wsCopy) { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->EditCopy(wsCopy); -} -FX_BOOL CFWL_ComboBox::EditCut(CFX_WideString& wsCut) { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->EditCut(wsCut); -} -FX_BOOL CFWL_ComboBox::EditPaste(const CFX_WideString& wsPaste) { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->EditPaste(wsPaste); -} -FX_BOOL CFWL_ComboBox::EditSelectAll() { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->EditSelectAll(); -} -FX_BOOL CFWL_ComboBox::EditDelete() { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->EditDelete(); -} -FX_BOOL CFWL_ComboBox::EditDeSelect() { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->EditDeSelect(); -} -FWL_ERR CFWL_ComboBox::GetBBox(CFX_RectF& rect) { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->GetBBox(rect); -} -FWL_ERR CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, - uint32_t dwStylesExRemoved) { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface) - ->EditModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); -} -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() {} -int32_t CFWL_ComboBox::CFWL_ComboBoxDP::CountItems(IFWL_Widget* pWidget) { - return m_ItemArray.size(); -} -FWL_HLISTITEM CFWL_ComboBox::CFWL_ComboBoxDP::GetItem(IFWL_Widget* pWidget, - int32_t nIndex) { - if (nIndex < 0 || static_cast(nIndex) >= m_ItemArray.size()) - return nullptr; - - return reinterpret_cast(m_ItemArray[nIndex].get()); -} -int32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIndex(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem) { - auto it = std::find_if( - m_ItemArray.begin(), m_ItemArray.end(), - [hItem](const std::unique_ptr& candidate) { - return candidate.get() == reinterpret_cast(hItem); - }); - return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1; -} -FX_BOOL CFWL_ComboBox::CFWL_ComboBoxDP::SetItemIndex(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - int32_t nIndex) { - if (nIndex < 0 || static_cast(nIndex) >= m_ItemArray.size()) - return FALSE; - - m_ItemArray[nIndex].reset(reinterpret_cast(hItem)); - return TRUE; -} -uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemStyles(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem) { - if (!hItem) - return 0; - return reinterpret_cast(hItem)->m_dwStyles; -} -FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::GetItemText(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - CFX_WideString& wsText) { - if (!hItem) - return FWL_ERR_Indefinite; - wsText = reinterpret_cast(hItem)->m_wsText; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::GetItemRect(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - CFX_RectF& rtItem) { - if (!hItem) - return FWL_ERR_Indefinite; - CFWL_ComboBoxItem* pItem = reinterpret_cast(hItem); - rtItem.Set(pItem->m_rtItem.left, pItem->m_rtItem.top, pItem->m_rtItem.width, - pItem->m_rtItem.height); - return FWL_ERR_Succeeded; -} -void* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemData(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem) { - if (!hItem) - return NULL; - CFWL_ComboBoxItem* pItem = reinterpret_cast(hItem); - return pItem->m_pData; -} -FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemStyles(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - uint32_t dwStyle) { - if (!hItem) - return FWL_ERR_Indefinite; - reinterpret_cast(hItem)->m_dwStyles = dwStyle; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemText(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - const FX_WCHAR* pszText) { - if (!hItem) - return FWL_ERR_Indefinite; - reinterpret_cast(hItem)->m_wsText = pszText; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemRect(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - const CFX_RectF& rtItem) { - if (!hItem) - return FWL_ERR_Indefinite; - reinterpret_cast(hItem)->m_rtItem = rtItem; - return FWL_ERR_Succeeded; -} -FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetItemHeight(IFWL_Widget* pWidget) { - return m_fItemHeight; -} -CFX_DIBitmap* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIcon(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem) { - if (!hItem) - return NULL; - return reinterpret_cast(hItem)->m_pDIB; -} -FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckRect(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - CFX_RectF& rtCheck) { - CFWL_ComboBoxItem* pItem = reinterpret_cast(hItem); - rtCheck = pItem->m_rtCheckBox; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckRect( - IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - const CFX_RectF& rtCheck) { - CFWL_ComboBoxItem* pItem = reinterpret_cast(hItem); - pItem->m_rtCheckBox = rtCheck; - return FWL_ERR_Succeeded; -} -uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckState( - IFWL_Widget* pWidget, - FWL_HLISTITEM hItem) { - CFWL_ComboBoxItem* pItem = reinterpret_cast(hItem); - return pItem->m_dwCheckState; -} -FWL_ERR CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckState( - IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - uint32_t dwCheckState) { - CFWL_ComboBoxItem* pItem = reinterpret_cast(hItem); - pItem->m_dwCheckState = dwCheckState; - return FWL_ERR_Succeeded; -} -FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetListHeight(IFWL_Widget* pWidget) { - return m_fMaxListHeight; -} diff --git a/xfa/fwl/lightwidget/datetimepicker.cpp b/xfa/fwl/lightwidget/datetimepicker.cpp deleted file mode 100644 index a3ace90c2d..0000000000 --- a/xfa/fwl/lightwidget/datetimepicker.cpp +++ /dev/null @@ -1,143 +0,0 @@ -// 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/include/fwl/lightwidget/datetimepicker.h" - -#include - -#include "xfa/fwl/basewidget/ifwl_datetimepicker.h" -#include "xfa/fwl/core/fwl_error.h" -#include "xfa/fwl/core/ifwl_widget.h" - -CFWL_DateTimePicker* CFWL_DateTimePicker::Create() { - return new CFWL_DateTimePicker; -} -FWL_ERR CFWL_DateTimePicker::Initialize( - const CFWL_WidgetProperties* pProperties) { - if (m_pIface) - return FWL_ERR_Indefinite; - if (pProperties) { - *m_pProperties = *pProperties; - } - std::unique_ptr pDateTimePicker( - IFWL_DateTimePicker::Create( - m_pProperties->MakeWidgetImpProperties(&m_DateTimePickerDP), - nullptr)); - FWL_ERR ret = pDateTimePicker->Initialize(); - if (ret != FWL_ERR_Succeeded) { - return ret; - } - m_pIface = pDateTimePicker.release(); - CFWL_Widget::Initialize(); - return FWL_ERR_Succeeded; -} - -FWL_ERR 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_ERR_Succeeded; -} -int32_t CFWL_DateTimePicker::CountSelRanges() { - return static_cast(m_pIface)->CountSelRanges(); -} -int32_t CFWL_DateTimePicker::GetSelRange(int32_t nIndex, int32_t& nStart) { - return static_cast(m_pIface) - ->GetSelRange(nIndex, nStart); -} -FWL_ERR CFWL_DateTimePicker::GetEditText(CFX_WideString& wsText) { - return static_cast(m_pIface)->GetEditText(wsText); -} -FWL_ERR CFWL_DateTimePicker::SetEditText(const CFX_WideStringC& wsText) { - return static_cast(m_pIface)->SetEditText(wsText); -} -FWL_ERR CFWL_DateTimePicker::GetCurSel(int32_t& iYear, - int32_t& iMonth, - int32_t& iDay) { - return static_cast(m_pIface) - ->GetCurSel(iYear, iMonth, iDay); -} -FWL_ERR CFWL_DateTimePicker::SetCurSel(int32_t iYear, - int32_t iMonth, - int32_t iDay) { - return static_cast(m_pIface) - ->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_ERR CFWL_DateTimePicker::CFWL_DateTimePickerDP::GetCaption( - IFWL_Widget* pWidget, - CFX_WideString& wsCaption) { - wsCaption = m_wsData; - return FWL_ERR_Succeeded; -} -FWL_ERR 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_ERR_Succeeded; -} -FX_BOOL CFWL_DateTimePicker::CanUndo() { - return static_cast(m_pIface)->CanUndo(); -} -FX_BOOL CFWL_DateTimePicker::CanRedo() { - return static_cast(m_pIface)->CanRedo(); -} -FX_BOOL CFWL_DateTimePicker::Undo() { - return static_cast(m_pIface)->Undo(); -} -FX_BOOL CFWL_DateTimePicker::Redo() { - return static_cast(m_pIface)->Redo(); -} -FX_BOOL CFWL_DateTimePicker::CanCopy() { - return static_cast(m_pIface)->CanCopy(); -} -FX_BOOL CFWL_DateTimePicker::CanCut() { - return static_cast(m_pIface)->CanCut(); -} -FX_BOOL CFWL_DateTimePicker::CanSelectAll() { - return static_cast(m_pIface)->CanSelectAll(); -} -FX_BOOL CFWL_DateTimePicker::Copy(CFX_WideString& wsCopy) { - return static_cast(m_pIface)->Copy(wsCopy); -} -FX_BOOL CFWL_DateTimePicker::Cut(CFX_WideString& wsCut) { - return static_cast(m_pIface)->Copy(wsCut); -} -FX_BOOL CFWL_DateTimePicker::Paste(const CFX_WideString& wsPaste) { - return static_cast(m_pIface)->Paste(wsPaste); -} -FX_BOOL CFWL_DateTimePicker::SelectAll() { - return static_cast(m_pIface)->SelectAll(); -} -FX_BOOL CFWL_DateTimePicker::Delete() { - return static_cast(m_pIface)->Delete(); -} -FX_BOOL CFWL_DateTimePicker::DeSelect() { - return static_cast(m_pIface)->DeSelect(); -} -FWL_ERR CFWL_DateTimePicker::GetBBox(CFX_RectF& rect) { - return static_cast(m_pIface)->GetBBox(rect); -} -FWL_ERR CFWL_DateTimePicker::SetEditLimit(int32_t nLimit) { - return static_cast(m_pIface)->SetEditLimit(nLimit); -} -FWL_ERR CFWL_DateTimePicker::ModifyEditStylesEx(uint32_t dwStylesExAdded, - uint32_t dwStylesExRemoved) { - return static_cast(m_pIface) - ->ModifyEditStylesEx(dwStylesExAdded, dwStylesExRemoved); -} diff --git a/xfa/fwl/lightwidget/edit.cpp b/xfa/fwl/lightwidget/edit.cpp deleted file mode 100644 index efceb4e39f..0000000000 --- a/xfa/fwl/lightwidget/edit.cpp +++ /dev/null @@ -1,211 +0,0 @@ -// 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/include/fwl/lightwidget/edit.h" - -#include -#include - -#include "xfa/fwl/basewidget/ifwl_edit.h" - -CFWL_Edit* CFWL_Edit::Create() { - return new CFWL_Edit; -} -FWL_ERR CFWL_Edit::Initialize(const CFWL_WidgetProperties* pProperties) { - if (m_pIface) - return FWL_ERR_Indefinite; - if (pProperties) { - *m_pProperties = *pProperties; - } - std::unique_ptr pEdit(IFWL_Edit::Create( - m_pProperties->MakeWidgetImpProperties(nullptr), nullptr)); - FWL_ERR ret = pEdit->Initialize(); - if (ret != FWL_ERR_Succeeded) { - return ret; - } - m_pIface = pEdit.release(); - CFWL_Widget::Initialize(); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_Edit::SetText(const CFX_WideString& wsText) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->SetText(wsText); -} -int32_t CFWL_Edit::GetTextLength() const { - if (!m_pIface) - return 0; - return static_cast(m_pIface)->GetTextLength(); -} -FWL_ERR CFWL_Edit::GetText(CFX_WideString& wsText, - int32_t nStart, - int32_t nCount) const { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->GetText(wsText, nStart, nCount); -} -FWL_ERR CFWL_Edit::ClearText() { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->ClearText(); -} -int32_t CFWL_Edit::GetCaretPos() const { - if (!m_pIface) - return -1; - return static_cast(m_pIface)->GetCaretPos(); -} -int32_t CFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { - if (!m_pIface) - return -1; - return static_cast(m_pIface)->SetCaretPos(nIndex, bBefore); -} -FWL_ERR CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { - if (!m_pIface) - return FWL_ERR_Indefinite; - static_cast(m_pIface)->AddSelRange(nStart, nCount); - int32_t pos = 0; - int32_t sum = static_cast(m_pIface)->GetTextLength(); - if (nCount == -1) { - pos = sum; - } else { - pos = nStart + nCount; - } - return static_cast(m_pIface)->SetCaretPos(pos); -} -int32_t CFWL_Edit::CountSelRanges() { - if (!m_pIface) - return 0; - return static_cast(m_pIface)->CountSelRanges(); -} -int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) { - if (!m_pIface) - return 0; - return static_cast(m_pIface)->GetSelRange(nIndex, nStart); -} -FWL_ERR CFWL_Edit::ClearSelections() { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->ClearSelections(); -} -int32_t CFWL_Edit::GetLimit() { - if (!m_pIface) - return -1; - return static_cast(m_pIface)->GetLimit(); -} -FWL_ERR CFWL_Edit::SetLimit(int32_t nLimit) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->SetLimit(nLimit); -} -FWL_ERR CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->SetAliasChar(wAlias); -} -FWL_ERR CFWL_Edit::Insert(int32_t nStart, - const FX_WCHAR* lpText, - int32_t nLen) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->Insert(nStart, lpText, nLen); -} -FWL_ERR CFWL_Edit::DeleteSelections() { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->DeleteSelections(); -} -FWL_ERR CFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->DeleteRange(nStart, nCount); -} -FWL_ERR CFWL_Edit::ReplaceSelections(const CFX_WideStringC& wsReplace) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->ReplaceSelections(wsReplace); -} -FWL_ERR CFWL_Edit::Replace(int32_t nStart, - int32_t nLen, - const CFX_WideStringC& wsReplace) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->Replace(nStart, nLen, wsReplace); -} -FWL_ERR CFWL_Edit::DoClipboard(int32_t iCmd) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->DoClipboard(iCmd); -} -FX_BOOL CFWL_Edit::Redo(const CFX_ByteStringC& bsRecord) { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->Redo(bsRecord); -} -FX_BOOL CFWL_Edit::Undo(const CFX_ByteStringC& bsRecord) { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->Undo(bsRecord); -} -FWL_ERR CFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface) - ->SetTabWidth(fTabWidth, bEquidistant); -} -FWL_ERR CFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { - if (iMin > iMax) { - return FWL_ERR_Parameter_Invalid; - } - return static_cast(m_pIface)->SetNumberRange(iMin, iMax); -} -FWL_ERR CFWL_Edit::SetBackColor(uint32_t dwColor) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->SetBackColor(dwColor); -} -FWL_ERR CFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->SetFont(wsFont, fSize); -} -FX_BOOL CFWL_Edit::CanUndo() { - return static_cast(m_pIface)->CanUndo(); -} -FX_BOOL CFWL_Edit::CanRedo() { - return static_cast(m_pIface)->CanRedo(); -} -FX_BOOL CFWL_Edit::Undo() { - return static_cast(m_pIface)->Undo(); -} -FX_BOOL CFWL_Edit::Redo() { - return static_cast(m_pIface)->Undo(); -} -FX_BOOL CFWL_Edit::Copy(CFX_WideString& wsCopy) { - return static_cast(m_pIface)->Copy(wsCopy); -} -FX_BOOL CFWL_Edit::Cut(CFX_WideString& wsCut) { - return static_cast(m_pIface)->Cut(wsCut); -} -FX_BOOL CFWL_Edit::Paste(const CFX_WideString& wsPaste) { - return static_cast(m_pIface)->Paste(wsPaste); -} -FX_BOOL CFWL_Edit::Delete() { - return static_cast(m_pIface)->Delete(); -} -void CFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { - return static_cast(m_pIface)->SetScrollOffset(fScrollOffset); -} -FX_BOOL CFWL_Edit::GetSuggestWords(CFX_PointF pointf, - std::vector& sSuggest) { - return static_cast(m_pIface)->GetSuggestWords(pointf, sSuggest); -} -FX_BOOL CFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf, - const CFX_ByteStringC& bsReplace) { - return static_cast(m_pIface) - ->ReplaceSpellCheckWord(pointf, bsReplace); -} -CFWL_Edit::CFWL_Edit() {} -CFWL_Edit::~CFWL_Edit() {} diff --git a/xfa/fwl/lightwidget/listbox.cpp b/xfa/fwl/lightwidget/listbox.cpp deleted file mode 100644 index 7913727775..0000000000 --- a/xfa/fwl/lightwidget/listbox.cpp +++ /dev/null @@ -1,302 +0,0 @@ -// 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/include/fwl/lightwidget/listbox.h" - -#include - -#include "third_party/base/stl_util.h" - -CFWL_ListBox* CFWL_ListBox::Create() { - return new CFWL_ListBox; -} -FWL_ERR CFWL_ListBox::Initialize(const CFWL_WidgetProperties* pProperties) { - if (m_pIface) - return FWL_ERR_Indefinite; - if (pProperties) { - *m_pProperties = *pProperties; - } - std::unique_ptr pListBox(IFWL_ListBox::Create( - m_pProperties->MakeWidgetImpProperties(&m_ListBoxDP), nullptr)); - FWL_ERR ret = pListBox->Initialize(); - if (ret != FWL_ERR_Succeeded) { - return ret; - } - m_pIface = pListBox.release(); - CFWL_Widget::Initialize(); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ListBox::AddDIBitmap(CFX_DIBitmap* pDIB, FWL_HLISTITEM hItem) { - reinterpret_cast(hItem)->m_pDIB = pDIB; - return FWL_ERR_Succeeded; -} -FWL_HLISTITEM CFWL_ListBox::AddString(const CFX_WideStringC& wsAdd, - FX_BOOL bSelect) { - std::unique_ptr 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 (FWL_HLISTITEM)m_ListBoxDP.m_ItemArray.back().get(); -} -FX_BOOL CFWL_ListBox::DeleteString(FWL_HLISTITEM hItem) { - int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), hItem); - if (nIndex < 0 || - static_cast(nIndex) >= m_ListBoxDP.m_ItemArray.size()) { - return FALSE; - } - int32_t iCount = m_ListBoxDP.CountItems(m_pIface); - int32_t iSel = nIndex + 1; - if (iSel >= iCount) { - iSel = nIndex - 1; - if (iSel < 0) { - iSel = -1; - } - } - if (iSel >= 0) { - CFWL_ListItem* pSel = - reinterpret_cast(m_ListBoxDP.GetItem(m_pIface, 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 (!m_pIface) - return 0; - return static_cast(m_pIface)->CountSelItems(); -} -FWL_HLISTITEM CFWL_ListBox::GetSelItem(int32_t nIndexSel) { - if (!m_pIface) - return NULL; - return static_cast(m_pIface)->GetSelItem(nIndexSel); -} -int32_t CFWL_ListBox::GetSelIndex(int32_t nIndex) { - if (!m_pIface) - return 0; - return static_cast(m_pIface)->GetSelIndex(nIndex); -} -FWL_ERR CFWL_ListBox::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->SetSelItem(hItem, bSelect); -} -FWL_ERR CFWL_ListBox::GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->GetItemText(hItem, wsText); -} -FWL_ERR CFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->GetScrollPos(fPos, bVert); -} -FWL_ERR CFWL_ListBox::SetItemHeight(FX_FLOAT fItemHeight) { - m_ListBoxDP.m_fItemHeight = fItemHeight; - return FWL_ERR_Succeeded; -} -FWL_HLISTITEM CFWL_ListBox::GetFocusItem() { - for (const auto& hItem : m_ListBoxDP.m_ItemArray) { - if (hItem->m_dwStates & FWL_ITEMSTATE_LTB_Focused) - return (FWL_HLISTITEM)hItem.get(); - } - return nullptr; -} -FWL_ERR CFWL_ListBox::SetFocusItem(FWL_HLISTITEM hItem) { - int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), hItem); - m_ListBoxDP.m_ItemArray[nIndex]->m_dwStates |= FWL_ITEMSTATE_LTB_Focused; - return FWL_ERR_Succeeded; -} -FWL_ERR* CFWL_ListBox::Sort(IFWL_ListBoxCompare* pCom) { - return static_cast(m_pIface)->Sort(pCom); -} -int32_t CFWL_ListBox::CountItems() { - return pdfium::CollectionSize(m_ListBoxDP.m_ItemArray); -} -FWL_HLISTITEM CFWL_ListBox::GetItem(int32_t nIndex) { - if (nIndex < 0 || nIndex >= CountItems()) - return nullptr; - - return (FWL_HLISTITEM)m_ListBoxDP.m_ItemArray[nIndex].get(); -} -FWL_ERR CFWL_ListBox::SetItemString(FWL_HLISTITEM hItem, - const CFX_WideStringC& wsText) { - if (!hItem) - return FWL_ERR_Indefinite; - reinterpret_cast(hItem)->m_wsText = wsText; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ListBox::GetItemString(FWL_HLISTITEM hItem, - CFX_WideString& wsText) { - if (!hItem) - return FWL_ERR_Indefinite; - wsText = reinterpret_cast(hItem)->m_wsText; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ListBox::SetItemData(FWL_HLISTITEM hItem, void* pData) { - if (!hItem) - return FWL_ERR_Indefinite; - reinterpret_cast(hItem)->m_pData = pData; - return FWL_ERR_Succeeded; -} -void* CFWL_ListBox::GetItemData(FWL_HLISTITEM hItem) { - if (!hItem) - return NULL; - return reinterpret_cast(hItem)->m_pData; -} -FWL_HLISTITEM CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { - CFX_RectF rtClient; - m_pIface->GetClientRect(rtClient); - fx -= rtClient.left; - fy -= rtClient.top; - FX_FLOAT fPosX = 0; - FX_FLOAT fPosY = 0; - static_cast(m_pIface)->GetScrollPos(fx); - static_cast(m_pIface)->GetScrollPos(fy, FALSE); - int32_t nCount = m_ListBoxDP.CountItems(NULL); - for (int32_t i = 0; i < nCount; i++) { - FWL_HLISTITEM hItem = m_ListBoxDP.GetItem(NULL, i); - if (!hItem) { - continue; - } - CFX_RectF rtItem; - m_ListBoxDP.GetItemRect(NULL, hItem, rtItem); - rtItem.Offset(-fPosX, -fPosY); - if (rtItem.Contains(fx, fy)) { - return hItem; - } - } - return NULL; -} -uint32_t CFWL_ListBox::GetItemStates(FWL_HLISTITEM hItem) { - if (!hItem) - return 0; - CFWL_ListItem* pItem = reinterpret_cast(hItem); - return pItem->m_dwStates | pItem->m_dwCheckState; -} -CFWL_ListBox::CFWL_ListBox() {} -CFWL_ListBox::~CFWL_ListBox() {} -CFWL_ListBox::CFWL_ListBoxDP::CFWL_ListBoxDP() {} -CFWL_ListBox::CFWL_ListBoxDP::~CFWL_ListBoxDP() {} -FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetCaption(IFWL_Widget* pWidget, - CFX_WideString& wsCaption) { - wsCaption = m_wsData; - return FWL_ERR_Succeeded; -} -int32_t CFWL_ListBox::CFWL_ListBoxDP::CountItems(IFWL_Widget* pWidget) { - return pdfium::CollectionSize(m_ItemArray); -} -FWL_HLISTITEM CFWL_ListBox::CFWL_ListBoxDP::GetItem(IFWL_Widget* pWidget, - int32_t nIndex) { - if (nIndex < 0 || nIndex >= CountItems(pWidget)) - return nullptr; - - return (FWL_HLISTITEM)m_ItemArray[nIndex].get(); -} -int32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemIndex(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem) { - auto it = std::find_if( - m_ItemArray.begin(), m_ItemArray.end(), - [hItem](const std::unique_ptr& candidate) { - return candidate.get() == reinterpret_cast(hItem); - }); - return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1; -} -FX_BOOL CFWL_ListBox::CFWL_ListBoxDP::SetItemIndex(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - int32_t nIndex) { - if (nIndex < 0 || nIndex >= CountItems(pWidget)) - return FALSE; - m_ItemArray[nIndex].reset(reinterpret_cast(hItem)); - return TRUE; -} -uint32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemStyles(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem) { - if (!hItem) - return -1; - return reinterpret_cast(hItem)->m_dwStates; -} -FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemText(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - CFX_WideString& wsText) { - if (!hItem) - return FWL_ERR_Indefinite; - wsText = reinterpret_cast(hItem)->m_wsText; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemRect(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - CFX_RectF& rtItem) { - if (!hItem) - return FWL_ERR_Indefinite; - CFWL_ListItem* pItem = reinterpret_cast(hItem); - rtItem = pItem->m_rtItem; - return FWL_ERR_Succeeded; -} -void* CFWL_ListBox::CFWL_ListBoxDP::GetItemData(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem) { - if (!hItem) - return NULL; - CFWL_ListItem* pItem = reinterpret_cast(hItem); - return pItem->m_pData; -} -FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemStyles(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - uint32_t dwStyle) { - if (!hItem) - return FWL_ERR_Indefinite; - reinterpret_cast(hItem)->m_dwStates = dwStyle; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemText(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - const FX_WCHAR* pszText) { - if (!hItem) - return FWL_ERR_Indefinite; - reinterpret_cast(hItem)->m_wsText = pszText; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemRect(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - const CFX_RectF& rtItem) { - if (!hItem) - return FWL_ERR_Indefinite; - reinterpret_cast(hItem)->m_rtItem = rtItem; - return FWL_ERR_Succeeded; -} -FX_FLOAT CFWL_ListBox::CFWL_ListBoxDP::GetItemHeight(IFWL_Widget* pWidget) { - return m_fItemHeight; -} -CFX_DIBitmap* CFWL_ListBox::CFWL_ListBoxDP::GetItemIcon(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem) { - return reinterpret_cast(hItem)->m_pDIB; -} -FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckRect(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - CFX_RectF& rtCheck) { - rtCheck = reinterpret_cast(hItem)->m_rtCheckBox; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckRect( - IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - const CFX_RectF& rtCheck) { - reinterpret_cast(hItem)->m_rtCheckBox = rtCheck; - return FWL_ERR_Succeeded; -} -uint32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckState(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem) { - return reinterpret_cast(hItem)->m_dwCheckState; -} -FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckState(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - uint32_t dwCheckState) { - reinterpret_cast(hItem)->m_dwCheckState = dwCheckState; - return FWL_ERR_Succeeded; -} diff --git a/xfa/fwl/lightwidget/picturebox.cpp b/xfa/fwl/lightwidget/picturebox.cpp deleted file mode 100644 index e35741c3ac..0000000000 --- a/xfa/fwl/lightwidget/picturebox.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// 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/include/fwl/lightwidget/picturebox.h" - -#include - -CFWL_PictureBox* CFWL_PictureBox::Create() { - return new CFWL_PictureBox; -} -FWL_ERR CFWL_PictureBox::Initialize(const CFWL_WidgetProperties* pProperties) { - if (m_pIface) - return FWL_ERR_Indefinite; - if (pProperties) { - *m_pProperties = *pProperties; - } - std::unique_ptr pPictureBox(IFWL_PictureBox::Create( - m_pProperties->MakeWidgetImpProperties(&m_PictureBoxDP), nullptr)); - FWL_ERR ret = pPictureBox->Initialize(); - if (ret != FWL_ERR_Succeeded) { - return ret; - } - m_pIface = pPictureBox.release(); - CFWL_Widget::Initialize(); - return FWL_ERR_Succeeded; -} -CFX_DIBitmap* CFWL_PictureBox::GetPicture() { - return m_PictureBoxDP.m_pBitmap; -} -FWL_ERR CFWL_PictureBox::SetPicture(CFX_DIBitmap* pBitmap) { - m_PictureBoxDP.m_pBitmap = pBitmap; - return FWL_ERR_Succeeded; -} -FX_FLOAT CFWL_PictureBox::GetRotation() { - return m_PictureBoxDP.m_fRotation; -} -FWL_ERR CFWL_PictureBox::SetRotation(FX_FLOAT fRotation) { - m_PictureBoxDP.m_fRotation = fRotation; - return FWL_ERR_Succeeded; -} -int32_t CFWL_PictureBox::GetFlipMode() { - return m_PictureBoxDP.GetFlipMode(m_pIface); -} -FWL_ERR CFWL_PictureBox::SetFlipMode(int32_t iFlipMode) { - m_PictureBoxDP.m_iFlipMode = iFlipMode; - return FWL_ERR_Succeeded; -} -int32_t CFWL_PictureBox::GetOpacity() { - return m_PictureBoxDP.GetOpacity(m_pIface); -} -FWL_ERR CFWL_PictureBox::SetOpacity(int32_t iOpacity) { - m_PictureBoxDP.m_iOpacity = iOpacity; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_PictureBox::GetScale(FX_FLOAT& fScaleX, FX_FLOAT& fScaleY) { - CFX_Matrix matrix; - m_PictureBoxDP.GetMatrix(m_pIface, matrix); - matrix.Scale(fScaleX, fScaleY); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_PictureBox::SetScale(FX_FLOAT fScaleX, FX_FLOAT fScaleY) { - m_PictureBoxDP.m_fScaleX = fScaleX; - m_PictureBoxDP.m_fScaleY = fScaleY; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_PictureBox::GetOffset(FX_FLOAT& fx, FX_FLOAT& fy) { - CFX_Matrix matrix; - m_PictureBoxDP.GetMatrix(m_pIface, matrix); - fx = matrix.e; - fy = matrix.f; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_PictureBox::SetOffset(FX_FLOAT fx, FX_FLOAT fy) { - m_PictureBoxDP.m_fOffSetX = fx; - m_PictureBoxDP.m_fOffSetY = fy; - return FWL_ERR_Succeeded; -} -CFWL_PictureBox::CFWL_PictureBox() {} -CFWL_PictureBox::~CFWL_PictureBox() {} -FWL_ERR CFWL_PictureBox::CFWL_PictureBoxDP::GetCaption( - IFWL_Widget* pWidget, - CFX_WideString& wsCaption) { - return FWL_ERR_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_ERR 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_ERR_Succeeded; -} -int32_t CFWL_PictureBox::CFWL_PictureBoxDP::GetFlipMode(IFWL_Widget* pWidget) { - return m_iFlipMode; -} diff --git a/xfa/fwl/lightwidget/pushbutton.cpp b/xfa/fwl/lightwidget/pushbutton.cpp deleted file mode 100644 index c9fb74e5f5..0000000000 --- a/xfa/fwl/lightwidget/pushbutton.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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/include/fwl/lightwidget/pushbutton.h" - -#include - -CFWL_PushButton* CFWL_PushButton::Create() { - return new CFWL_PushButton; -} -FWL_ERR CFWL_PushButton::Initialize(const CFWL_WidgetProperties* pProperties) { - if (m_pIface) - return FWL_ERR_Indefinite; - if (pProperties) { - *m_pProperties = *pProperties; - } - std::unique_ptr pPushButton(IFWL_PushButton::Create( - m_pProperties->MakeWidgetImpProperties(&m_buttonData), nullptr)); - FWL_ERR ret = pPushButton->Initialize(); - if (ret != FWL_ERR_Succeeded) { - return ret; - } - m_pIface = pPushButton.release(); - CFWL_Widget::Initialize(); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_PushButton::GetCaption(CFX_WideString& wsCaption) { - wsCaption = m_buttonData.m_wsCaption; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_PushButton::SetCaption(const CFX_WideStringC& wsCaption) { - m_buttonData.m_wsCaption = wsCaption; - return FWL_ERR_Succeeded; -} -CFX_DIBitmap* CFWL_PushButton::GetPicture() { - return m_buttonData.m_pBitmap; -} -FWL_ERR CFWL_PushButton::SetPicture(CFX_DIBitmap* pBitmap) { - m_buttonData.m_pBitmap = pBitmap; - return FWL_ERR_Succeeded; -} -CFWL_PushButton::CFWL_PushButton() {} -CFWL_PushButton::~CFWL_PushButton() {} -FWL_ERR CFWL_PushButton::CFWL_PushButtonDP::GetCaption( - IFWL_Widget* pWidget, - CFX_WideString& wsCaption) { - wsCaption = m_wsCaption; - return FWL_ERR_Succeeded; -} -CFX_DIBitmap* CFWL_PushButton::CFWL_PushButtonDP::GetPicture( - IFWL_Widget* pWidget) { - return m_pBitmap; -} diff --git a/xfa/fwl/lightwidget/scrollbar.cpp b/xfa/fwl/lightwidget/scrollbar.cpp deleted file mode 100644 index 62f2ffd1e5..0000000000 --- a/xfa/fwl/lightwidget/scrollbar.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// 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/include/fwl/lightwidget/scrollbar.h" - -#include - -#include "xfa/fwl/basewidget/ifwl_scrollbar.h" - -CFWL_ScrollBar* CFWL_ScrollBar::Create() { - return new CFWL_ScrollBar; -} -FWL_ERR CFWL_ScrollBar::Initialize(const CFWL_WidgetProperties* pProperties) { - if (m_pIface) - return FWL_ERR_Indefinite; - if (pProperties) { - *m_pProperties = *pProperties; - } - std::unique_ptr pScrollBar(IFWL_ScrollBar::Create( - m_pProperties->MakeWidgetImpProperties(nullptr), nullptr)); - FWL_ERR ret = pScrollBar->Initialize(); - if (ret != FWL_ERR_Succeeded) { - return ret; - } - m_pIface = pScrollBar.release(); - CFWL_Widget::Initialize(); - return FWL_ERR_Succeeded; -} -FX_BOOL CFWL_ScrollBar::IsVertical() { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->IsVertical(); -} -FWL_ERR CFWL_ScrollBar::GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->GetRange(fMin, fMax); -} -FWL_ERR CFWL_ScrollBar::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->SetRange(fMin, fMax); -} -FX_FLOAT CFWL_ScrollBar::GetPageSize() { - if (!m_pIface) - return 0; - return static_cast(m_pIface)->GetPageSize(); -} -FWL_ERR CFWL_ScrollBar::SetPageSize(FX_FLOAT fPageSize) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->SetPageSize(fPageSize); -} -FX_FLOAT CFWL_ScrollBar::GetStepSize() { - if (!m_pIface) - return 0; - return static_cast(m_pIface)->GetStepSize(); -} -FWL_ERR CFWL_ScrollBar::SetStepSize(FX_FLOAT fStepSize) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->SetStepSize(fStepSize); -} -FX_FLOAT CFWL_ScrollBar::GetPos() { - if (!m_pIface) - return -1; - return static_cast(m_pIface)->GetPos(); -} -FWL_ERR CFWL_ScrollBar::SetPos(FX_FLOAT fPos) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->SetPos(fPos); -} -FX_FLOAT CFWL_ScrollBar::GetTrackPos() { - if (!m_pIface) - return -1; - return static_cast(m_pIface)->GetTrackPos(); -} -FWL_ERR CFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return static_cast(m_pIface)->SetTrackPos(fTrackPos); -} -FX_BOOL CFWL_ScrollBar::DoScroll(uint32_t dwCode, FX_FLOAT fPos) { - if (!m_pIface) - return FALSE; - return static_cast(m_pIface)->DoScroll(dwCode, fPos); -} -CFWL_ScrollBar::CFWL_ScrollBar() {} -CFWL_ScrollBar::~CFWL_ScrollBar() {} diff --git a/xfa/fwl/lightwidget/theme.cpp b/xfa/fwl/lightwidget/theme.cpp deleted file mode 100644 index 59729c1b2d..0000000000 --- a/xfa/fwl/lightwidget/theme.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// 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/include/fwl/lightwidget/theme.h" - -#include - -#include "xfa/fwl/core/cfwl_themebackground.h" -#include "xfa/fwl/core/cfwl_themepart.h" -#include "xfa/fwl/core/cfwl_themetext.h" -#include "xfa/include/fwl/theme/barcodetp.h" -#include "xfa/include/fwl/theme/carettp.h" -#include "xfa/include/fwl/theme/checkboxtp.h" -#include "xfa/include/fwl/theme/comboboxtp.h" -#include "xfa/include/fwl/theme/datetimepickertp.h" -#include "xfa/include/fwl/theme/edittp.h" -#include "xfa/include/fwl/theme/formtp.h" -#include "xfa/include/fwl/theme/listboxtp.h" -#include "xfa/include/fwl/theme/monthcalendartp.h" -#include "xfa/include/fwl/theme/pictureboxtp.h" -#include "xfa/include/fwl/theme/pushbuttontp.h" -#include "xfa/include/fwl/theme/scrollbartp.h" - -CFWL_Theme::CFWL_Theme() { - m_ThemesArray.push_back(std::unique_ptr(new CFWL_FormTP)); - m_ThemesArray.push_back( - std::unique_ptr(new CFWL_PushButtonTP)); - m_ThemesArray.push_back(std::unique_ptr(new CFWL_CheckBoxTP)); - m_ThemesArray.push_back(std::unique_ptr(new CFWL_ListBoxTP)); - m_ThemesArray.push_back( - std::unique_ptr(new CFWL_PictureBoxTP)); - m_ThemesArray.push_back(std::unique_ptr(new CFWL_ScrollBarTP)); - m_ThemesArray.push_back(std::unique_ptr(new CFWL_EditTP)); - m_ThemesArray.push_back(std::unique_ptr(new CFWL_ComboBoxTP)); - m_ThemesArray.push_back(std::unique_ptr(new CFWL_BarcodeTP)); - m_ThemesArray.push_back( - std::unique_ptr(new CFWL_DateTimePickerTP)); - m_ThemesArray.push_back( - std::unique_ptr(new CFWL_MonthCalendarTP)); - m_ThemesArray.push_back(std::unique_ptr(new CFWL_CaretTP)); -} - -CFWL_Theme::~CFWL_Theme() {} - -FX_BOOL CFWL_Theme::IsValidWidget(IFWL_Widget* pWidget) { - return !!GetTheme(pWidget); -} - -uint32_t CFWL_Theme::GetThemeID(IFWL_Widget* pWidget) { - return GetTheme(pWidget)->GetThemeID(pWidget); -} - -uint32_t CFWL_Theme::SetThemeID(IFWL_Widget* pWidget, - uint32_t dwThemeID, - FX_BOOL bChildren) { - uint32_t dwID; - for (const auto& pTheme : m_ThemesArray) { - dwID = pTheme->GetThemeID(pWidget); - pTheme->SetThemeID(pWidget, dwThemeID, FALSE); - } - return dwID; -} - -FWL_ERR CFWL_Theme::GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) { - return FWL_ERR_Succeeded; -} - -FWL_ERR CFWL_Theme::SetThemeMatrix(IFWL_Widget* pWidget, - const CFX_Matrix& matrix) { - return FWL_ERR_Succeeded; -} - -FX_BOOL CFWL_Theme::DrawBackground(CFWL_ThemeBackground* pParams) { - return GetTheme(pParams->m_pWidget)->DrawBackground(pParams); -} - -FX_BOOL CFWL_Theme::DrawText(CFWL_ThemeText* pParams) { - return GetTheme(pParams->m_pWidget)->DrawText(pParams); -} - -void* CFWL_Theme::GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity) { - return GetTheme(pThemePart->m_pWidget)->GetCapacity(pThemePart, dwCapacity); -} - -FX_BOOL CFWL_Theme::IsCustomizedLayout(IFWL_Widget* pWidget) { - return GetTheme(pWidget)->IsCustomizedLayout(pWidget); -} - -FWL_ERR CFWL_Theme::GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart) { - return GetTheme(pThemePart->m_pWidget)->GetPartRect(pThemePart, rtPart); -} - -FX_BOOL CFWL_Theme::IsInPart(CFWL_ThemePart* pThemePart, - FX_FLOAT fx, - FX_FLOAT fy) { - return GetTheme(pThemePart->m_pWidget)->IsInPart(pThemePart, fx, fy); -} - -FX_BOOL CFWL_Theme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { - return GetTheme(pParams->m_pWidget)->CalcTextRect(pParams, rect); -} - -FWL_ERR CFWL_Theme::Initialize() { - for (const auto& pTheme : m_ThemesArray) - pTheme->Initialize(); - - FWLTHEME_Init(); - return FWL_ERR_Succeeded; -} - -FWL_ERR CFWL_Theme::Finalize() { - for (const auto& pTheme : m_ThemesArray) - pTheme->Finalize(); - - FWLTHEME_Release(); - return FWL_ERR_Succeeded; -} - -FWL_ERR CFWL_Theme::SetFont(IFWL_Widget* pWidget, - const FX_WCHAR* strFont, - FX_FLOAT fFontSize, - FX_ARGB rgbFont) { - for (const auto& pTheme : m_ThemesArray) - pTheme->SetFont(pWidget, strFont, fFontSize, rgbFont); - - return FWL_ERR_Succeeded; -} - -CFWL_WidgetTP* CFWL_Theme::GetTheme(IFWL_Widget* pWidget) { - for (const auto& pTheme : m_ThemesArray) { - if (pTheme->IsValidWidget(pWidget)) - return pTheme.get(); - } - return nullptr; -} diff --git a/xfa/fwl/lightwidget/tooltipctrl.cpp b/xfa/fwl/lightwidget/tooltipctrl.cpp deleted file mode 100644 index 323eed0282..0000000000 --- a/xfa/fwl/lightwidget/tooltipctrl.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// 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/include/fwl/lightwidget/tooltipctrl.h" - -#include - -#include "xfa/fwl/core/fwl_formimp.h" -#include "xfa/fwl/core/fwl_noteimp.h" -#include "xfa/fwl/core/fwl_panelimp.h" -#include "xfa/fwl/core/fwl_targetimp.h" -#include "xfa/fwl/core/fwl_threadimp.h" -#include "xfa/fwl/core/fwl_widgetimp.h" - -CFWL_ToolTip* CFWL_ToolTip::Create() { - return new CFWL_ToolTip; -} -FWL_ERR CFWL_ToolTip::Initialize(const CFWL_WidgetProperties* pProperties) { - if (m_pIface) - return FWL_ERR_Indefinite; - if (pProperties) { - *m_pProperties = *pProperties; - } - std::unique_ptr pToolTip(IFWL_ToolTip::Create( - m_pProperties->MakeWidgetImpProperties(&m_tooltipData), nullptr)); - FWL_ERR ret = pToolTip->Initialize(); - if (ret != FWL_ERR_Succeeded) { - return ret; - } - m_pIface = pToolTip.release(); - CFWL_Widget::Initialize(); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ToolTip::GetCaption(CFX_WideString& wsCaption) { - wsCaption = m_tooltipData.m_wsCaption; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ToolTip::SetCaption(const CFX_WideStringC& wsCaption) { - m_tooltipData.m_wsCaption = wsCaption; - return FWL_ERR_Succeeded; -} -int32_t CFWL_ToolTip::GetInitialDelay() { - return m_tooltipData.m_nInitDelayTime; -} -int32_t CFWL_ToolTip::SetInitialDelay(int32_t nDelayTime) { - m_tooltipData.m_nInitDelayTime = nDelayTime; - return FWL_ERR_Succeeded; -} -int32_t CFWL_ToolTip::GetAutoPopDelay() { - return m_tooltipData.m_nAutoPopDelayTime; -} -int32_t CFWL_ToolTip::SetAutoPopDelay(int32_t nDelayTime) { - m_tooltipData.m_nAutoPopDelayTime = nDelayTime; - return FWL_ERR_Succeeded; -} -CFX_DIBitmap* CFWL_ToolTip::GetToolTipIcon() { - return m_tooltipData.m_pBitmap; -} -FWL_ERR CFWL_ToolTip::SetToolTipIcon(CFX_DIBitmap* pBitmap) { - m_tooltipData.m_pBitmap = pBitmap; - return FWL_ERR_Succeeded; -} -CFX_SizeF CFWL_ToolTip::GetToolTipIconSize() { - return m_tooltipData.m_fIconSize; -} -FWL_ERR CFWL_ToolTip::SetToolTipIconSize(CFX_SizeF fSize) { - m_tooltipData.m_fIconSize = fSize; - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_ToolTip::SetAnchor(const CFX_RectF& rtAnchor) { - return static_cast(m_pIface)->SetAnchor(rtAnchor); -} -FWL_ERR CFWL_ToolTip::Show() { - return static_cast(m_pIface)->Show(); -} -FWL_ERR CFWL_ToolTip::Hide() { - return static_cast(m_pIface)->Hide(); -} -CFWL_ToolTip::CFWL_ToolTip() {} -CFWL_ToolTip::~CFWL_ToolTip() {} -CFWL_ToolTip::CFWL_ToolTipDP::CFWL_ToolTipDP() : m_pBitmap(NULL) { - m_wsCaption = L""; - m_nInitDelayTime = 500; - m_nAutoPopDelayTime = 50000; - m_fAnchor.Set(0.0, 0.0, 0.0, 0.0); -} -FWL_ERR CFWL_ToolTip::CFWL_ToolTipDP::GetCaption(IFWL_Widget* pWidget, - CFX_WideString& wsCaption) { - wsCaption = m_wsCaption; - return FWL_ERR_Succeeded; -} -int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetInitialDelay(IFWL_Widget* pWidget) { - return m_nInitDelayTime; -} -int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetAutoPopDelay(IFWL_Widget* pWidget) { - return m_nAutoPopDelayTime; -} -CFX_DIBitmap* CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIcon( - IFWL_Widget* pWidget) { - return m_pBitmap; -} -CFX_SizeF CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIconSize( - IFWL_Widget* pWidget) { - return m_fIconSize; -} -CFX_RectF CFWL_ToolTip::CFWL_ToolTipDP::GetAnchor() { - return m_fAnchor; -} diff --git a/xfa/fwl/lightwidget/widget.cpp b/xfa/fwl/lightwidget/widget.cpp deleted file mode 100644 index 294604a01b..0000000000 --- a/xfa/fwl/lightwidget/widget.cpp +++ /dev/null @@ -1,319 +0,0 @@ -// 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/include/fwl/lightwidget/widget.h" - -#include "xfa/fde/tto/fde_textout.h" -#include "xfa/fwl/core/cfwl_themetext.h" -#include "xfa/fwl/core/fwl_noteimp.h" -#include "xfa/fwl/core/fwl_noteimp.h" -#include "xfa/fwl/core/fwl_targetimp.h" -#include "xfa/fwl/core/fwl_widgetimp.h" -#include "xfa/fwl/core/fwl_widgetmgrimp.h" -#include "xfa/fwl/core/ifwl_notethread.h" -#include "xfa/fwl/core/ifwl_themeprovider.h" - -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; -} -IFWL_Widget* CFWL_Widget::GetWidget() { - return m_pIface; -} -FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->GetClassName(wsClass); -} -uint32_t CFWL_Widget::GetClassID() const { - if (!m_pIface) - return 0; - return m_pIface->GetClassID(); -} -FX_BOOL CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { - if (!m_pIface) - return FALSE; - return m_pIface->IsInstance(wsClass); -} -static void* gs_pFWLWidget = (void*)FXBSTR_ID('l', 'i', 'g', 't'); -FWL_ERR CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->SetPrivateData(gs_pFWLWidget, this, NULL); -} -FWL_ERR CFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->GetWidgetRect(rect, bAutoSize); -} -FWL_ERR CFWL_Widget::GetGlobalRect(CFX_RectF& rect) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->GetGlobalRect(rect); -} -FWL_ERR CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->SetWidgetRect(rect); -} -FWL_ERR CFWL_Widget::GetClientRect(CFX_RectF& rect) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->GetClientRect(rect); -} -CFWL_Widget* CFWL_Widget::GetParent() { - if (!m_pIface) - return NULL; - IFWL_Widget* parent = m_pIface->GetParent(); - if (parent) { - return static_cast(parent->GetPrivateData(gs_pFWLWidget)); - } - return NULL; -} -FWL_ERR CFWL_Widget::SetParent(CFWL_Widget* pParent) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->SetParent(pParent ? pParent->GetWidget() : NULL); -} -CFWL_Widget* CFWL_Widget::GetOwner() { - if (!m_pIface) - return NULL; - return NULL; -} -FWL_ERR CFWL_Widget::SetOwner(CFWL_Widget* pOwner) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return FWL_ERR_Succeeded; -} -uint32_t CFWL_Widget::GetStyles() { - if (!m_pIface) - return 0; - return m_pIface->GetStyles(); -} -FWL_ERR CFWL_Widget::ModifyStyles(uint32_t dwStylesAdded, - uint32_t dwStylesRemoved) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->ModifyStyles(dwStylesAdded, dwStylesRemoved); -} -uint32_t CFWL_Widget::GetStylesEx() { - if (!m_pIface) - return 0; - return m_pIface->GetStylesEx(); -} -FWL_ERR CFWL_Widget::ModifyStylesEx(uint32_t dwStylesExAdded, - uint32_t dwStylesExRemoved) { - return m_pIface->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); -} -uint32_t CFWL_Widget::GetStates() { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->GetStates(); -} -FWL_ERR CFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->SetStates(dwStates, bSet); -} -FWL_ERR CFWL_Widget::SetPrivateData(void* module_id, - void* pData, - PD_CALLBACK_FREEDATA callback) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->SetPrivateData(module_id, pData, callback); -} -void* CFWL_Widget::GetPrivateData(void* module_id) { - if (!m_pIface) - return NULL; - return m_pIface->GetPrivateData(module_id); -} -FWL_ERR CFWL_Widget::Update() { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->Update(); -} -FWL_ERR CFWL_Widget::LockUpdate() { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->LockUpdate(); -} -FWL_ERR CFWL_Widget::UnlockUpdate() { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->UnlockUpdate(); -} -uint32_t CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { - if (!m_pIface) - return 0; - return m_pIface->HitTest(fx, fy); -} -FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget, - FX_FLOAT& fx, - FX_FLOAT& fy) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : NULL, fx, fy); -} -FWL_ERR CFWL_Widget::TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : NULL, rt); -} -FWL_ERR CFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->GetMatrix(matrix, bGlobal); -} -FWL_ERR CFWL_Widget::SetMatrix(const CFX_Matrix& matrix) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->SetMatrix(matrix); -} -FWL_ERR CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - if (!m_pIface) - return FWL_ERR_Indefinite; - return m_pIface->DrawWidget(pGraphics, pMatrix); -} -IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { - if (!m_pIface) - return NULL; - m_pDelegate = m_pIface->SetDelegate(pDelegate); - return m_pDelegate; -} -CFWL_Widget::CFWL_Widget() - : m_pIface(NULL), m_pDelegate(NULL), m_pProperties(NULL) { - m_pProperties = new CFWL_WidgetProperties; - m_pWidgetMgr = static_cast(FWL_GetWidgetMgr()); - FXSYS_assert(m_pWidgetMgr != NULL); -} -CFWL_Widget::~CFWL_Widget() { - delete m_pProperties; - if (m_pIface) { - m_pIface->Finalize(); - delete m_pIface; - } -} -FWL_ERR CFWL_Widget::Repaint(const CFX_RectF* pRect) { - if (!m_pIface) - return FWL_ERR_Indefinite; - CFX_RectF rect; - if (pRect) { - rect = *pRect; - } else { - m_pIface->GetWidgetRect(rect); - rect.left = rect.top = 0; - } - return m_pWidgetMgr->RepaintWidget(m_pIface, &rect); -} -FWL_ERR CFWL_Widget::SetFocus(FX_BOOL bFocus) { - if (!m_pIface) - return FWL_ERR_Indefinite; - IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); - if (!pThread) - return FWL_ERR_Indefinite; - IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); - if (!pDriver) - return FWL_ERR_Indefinite; - if (bFocus) { - pDriver->SetFocus(m_pIface); - } else { - if (pDriver->GetFocus() == m_pIface) { - pDriver->SetFocus(NULL); - } - } - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_Widget::SetGrab(FX_BOOL bSet) { - if (!m_pIface) - return FWL_ERR_Indefinite; - IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); - if (!pThread) - return FWL_ERR_Indefinite; - IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); - if (!pDriver) - return FWL_ERR_Indefinite; - pDriver->SetGrab(m_pIface, bSet); - return FWL_ERR_Succeeded; -} -void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource, - uint32_t dwFilter) { - if (!m_pIface) - return; - IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); - if (!pThread) - return; - IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); - if (!pNoteDriver) - return; - IFWL_Widget* pEventSourceImp = - !pEventSource ? NULL : pEventSource->GetWidget(); - pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter); -} -void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { - if (!m_pIface) - return; - if (m_pIface->GetOuter()) { - return; - } - IFWL_NoteThread* pThread = m_pIface->GetOwnerThread(); - if (!pThread) - return; - IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); - if (!pNoteDriver) - return; - pNoteDriver->SendNote(pEvent); -} -#define FWL_WGT_CalcHeight 2048 -#define FWL_WGT_CalcWidth 2048 -#define FWL_WGT_CalcMultiLineDefWidth 120.0f -CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText, - FX_BOOL bMultiLine, - int32_t iLineWidth) { - if (!m_pIface) - return CFX_SizeF(); - IFWL_ThemeProvider* pTheme = m_pIface->GetThemeProvider(); - if (!pTheme) - return CFX_SizeF(); - - CFWL_ThemeText calPart; - calPart.m_pWidget = m_pIface; - calPart.m_wsText = wsText; - calPart.m_dwTTOStyles = - bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine; - calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; - CFX_RectF rect; - FX_FLOAT fWidth = bMultiLine - ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth - : FWL_WGT_CalcMultiLineDefWidth) - : FWL_WGT_CalcWidth; - rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); - pTheme->CalcTextRect(&calPart, rect); - return CFX_SizeF(rect.width, rect.height); -} -CFWL_WidgetDelegate::CFWL_WidgetDelegate() {} -CFWL_WidgetDelegate::~CFWL_WidgetDelegate() {} -int32_t CFWL_WidgetDelegate::OnProcessMessage(CFWL_Message* pMessage) { - return 1; -} -FWL_ERR CFWL_WidgetDelegate::OnProcessEvent(CFWL_Event* pEvent) { - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_WidgetDelegate::OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { - return FWL_ERR_Succeeded; -} diff --git a/xfa/fwl/theme/barcodetp.cpp b/xfa/fwl/theme/barcodetp.cpp deleted file mode 100644 index da10d7a344..0000000000 --- a/xfa/fwl/theme/barcodetp.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// 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/include/fwl/theme/barcodetp.h" - -#include "xfa/fwl/basewidget/ifwl_barcode.h" -#include "xfa/fwl/core/cfwl_themebackground.h" -#include "xfa/fwl/core/ifwl_widget.h" - -CFWL_BarcodeTP::CFWL_BarcodeTP() {} -CFWL_BarcodeTP::~CFWL_BarcodeTP() {} - -FX_BOOL CFWL_BarcodeTP::IsValidWidget(IFWL_Widget* pWidget) { - if (!pWidget) - return FALSE; - return pWidget->GetClassID() == FWL_CLASSHASH_Barcode; -} -FX_BOOL CFWL_BarcodeTP::DrawBackground(CFWL_ThemeBackground* pParams) { - if (!pParams) - return FALSE; - switch (pParams->m_iPart) { - case FWL_PART_BCD_Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_BCD_Edge: { - DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), - &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_BCD_Background: { - FillBackground(pParams->m_pGraphics, &pParams->m_rtPart, - &pParams->m_matrix); - break; - } - default: {} - } - return TRUE; -} diff --git a/xfa/fwl/theme/carettp.cpp b/xfa/fwl/theme/carettp.cpp deleted file mode 100644 index a5782f30b6..0000000000 --- a/xfa/fwl/theme/carettp.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// 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/include/fwl/theme/carettp.h" - -#include "xfa/fwl/basewidget/ifwl_caret.h" -#include "xfa/fwl/core/cfwl_themebackground.h" -#include "xfa/fwl/core/ifwl_widget.h" -#include "xfa/fxgraphics/cfx_color.h" -#include "xfa/fxgraphics/cfx_path.h" - -CFWL_CaretTP::CFWL_CaretTP() {} -CFWL_CaretTP::~CFWL_CaretTP() {} - -FX_BOOL CFWL_CaretTP::IsValidWidget(IFWL_Widget* pWidget) { - if (!pWidget) - return FALSE; - return pWidget->GetClassID() == FWL_CLASSHASH_Caret; -} -FX_BOOL CFWL_CaretTP::DrawBackground(CFWL_ThemeBackground* pParams) { - if (!pParams) - return FALSE; - switch (pParams->m_iPart) { - case FWL_PART_CAT_Background: { - if (!(pParams->m_dwStates & FWL_PARTSTATE_CAT_HightLight)) { - return TRUE; - } - DrawCaretBK(pParams->m_pGraphics, pParams->m_dwStates, - &(pParams->m_rtPart), (CFX_Color*)pParams->m_pData, - &(pParams->m_matrix)); - break; - } - } - return TRUE; -} -void CFWL_CaretTP::DrawCaretBK(CFX_Graphics* pGraphics, - uint32_t dwStates, - const CFX_RectF* pRect, - CFX_Color* crFill, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - CFX_Color crFilltemp; - crFill ? crFilltemp = *crFill : crFilltemp = ArgbEncode(255, 0, 0, 0); - CFX_RectF rect = *pRect; - path.AddRectangle(rect.left, rect.top, rect.width, rect.height); - pGraphics->SetFillColor(&crFilltemp); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); -} diff --git a/xfa/fwl/theme/cfwl_barcodetp.cpp b/xfa/fwl/theme/cfwl_barcodetp.cpp new file mode 100644 index 0000000000..0edc29b775 --- /dev/null +++ b/xfa/fwl/theme/cfwl_barcodetp.cpp @@ -0,0 +1,44 @@ +// 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/theme/cfwl_barcodetp.h" + +#include "xfa/fwl/basewidget/ifwl_barcode.h" +#include "xfa/fwl/core/cfwl_themebackground.h" +#include "xfa/fwl/core/ifwl_widget.h" + +CFWL_BarcodeTP::CFWL_BarcodeTP() {} + +CFWL_BarcodeTP::~CFWL_BarcodeTP() {} + +FX_BOOL CFWL_BarcodeTP::IsValidWidget(IFWL_Widget* pWidget) { + if (!pWidget) + return FALSE; + return pWidget->GetClassID() == FWL_CLASSHASH_Barcode; +} + +FX_BOOL CFWL_BarcodeTP::DrawBackground(CFWL_ThemeBackground* pParams) { + if (!pParams) + return FALSE; + switch (pParams->m_iPart) { + case FWL_PART_BCD_Border: { + DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_BCD_Edge: { + DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), + &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_BCD_Background: { + FillBackground(pParams->m_pGraphics, &pParams->m_rtPart, + &pParams->m_matrix); + break; + } + default: {} + } + return TRUE; +} diff --git a/xfa/fwl/theme/cfwl_barcodetp.h b/xfa/fwl/theme/cfwl_barcodetp.h new file mode 100644 index 0000000000..0a03f49805 --- /dev/null +++ b/xfa/fwl/theme/cfwl_barcodetp.h @@ -0,0 +1,21 @@ +// 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_THEME_CFWL_BARCODETP_H_ +#define XFA_FWL_THEME_CFWL_BARCODETP_H_ + +#include "xfa/fwl/theme/cfwl_utils.h" +#include "xfa/fwl/theme/cfwl_widgettp.h" + +class CFWL_BarcodeTP : public CFWL_WidgetTP { + public: + CFWL_BarcodeTP(); + virtual ~CFWL_BarcodeTP(); + virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); + virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); +}; + +#endif // XFA_FWL_THEME_CFWL_BARCODETP_H_ diff --git a/xfa/fwl/theme/cfwl_carettp.cpp b/xfa/fwl/theme/cfwl_carettp.cpp new file mode 100644 index 0000000000..0ebc519642 --- /dev/null +++ b/xfa/fwl/theme/cfwl_carettp.cpp @@ -0,0 +1,52 @@ +// 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/theme/cfwl_carettp.h" + +#include "xfa/fwl/basewidget/ifwl_caret.h" +#include "xfa/fwl/core/cfwl_themebackground.h" +#include "xfa/fwl/core/ifwl_widget.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" + +CFWL_CaretTP::CFWL_CaretTP() {} +CFWL_CaretTP::~CFWL_CaretTP() {} + +FX_BOOL CFWL_CaretTP::IsValidWidget(IFWL_Widget* pWidget) { + if (!pWidget) + return FALSE; + return pWidget->GetClassID() == FWL_CLASSHASH_Caret; +} +FX_BOOL CFWL_CaretTP::DrawBackground(CFWL_ThemeBackground* pParams) { + if (!pParams) + return FALSE; + switch (pParams->m_iPart) { + case FWL_PART_CAT_Background: { + if (!(pParams->m_dwStates & FWL_PARTSTATE_CAT_HightLight)) { + return TRUE; + } + DrawCaretBK(pParams->m_pGraphics, pParams->m_dwStates, + &(pParams->m_rtPart), (CFX_Color*)pParams->m_pData, + &(pParams->m_matrix)); + break; + } + } + return TRUE; +} +void CFWL_CaretTP::DrawCaretBK(CFX_Graphics* pGraphics, + uint32_t dwStates, + const CFX_RectF* pRect, + CFX_Color* crFill, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + CFX_Color crFilltemp; + crFill ? crFilltemp = *crFill : crFilltemp = ArgbEncode(255, 0, 0, 0); + CFX_RectF rect = *pRect; + path.AddRectangle(rect.left, rect.top, rect.width, rect.height); + pGraphics->SetFillColor(&crFilltemp); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); +} diff --git a/xfa/fwl/theme/cfwl_carettp.h b/xfa/fwl/theme/cfwl_carettp.h new file mode 100644 index 0000000000..8c56d38aa9 --- /dev/null +++ b/xfa/fwl/theme/cfwl_carettp.h @@ -0,0 +1,27 @@ +// 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_THEME_CFWL_CARETTP_H_ +#define XFA_FWL_THEME_CFWL_CARETTP_H_ + +#include "xfa/fwl/theme/cfwl_widgettp.h" + +class CFWL_CaretTP : public CFWL_WidgetTP { + public: + CFWL_CaretTP(); + virtual ~CFWL_CaretTP(); + virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); + virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); + + protected: + void DrawCaretBK(CFX_Graphics* pGraphics, + uint32_t dwStates, + const CFX_RectF* pRect, + CFX_Color* crFill, + CFX_Matrix* pMatrix = NULL); +}; + +#endif // XFA_FWL_THEME_CFWL_CARETTP_H_ diff --git a/xfa/fwl/theme/cfwl_checkboxtp.cpp b/xfa/fwl/theme/cfwl_checkboxtp.cpp new file mode 100644 index 0000000000..94f69a4389 --- /dev/null +++ b/xfa/fwl/theme/cfwl_checkboxtp.cpp @@ -0,0 +1,536 @@ +// 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/theme/cfwl_checkboxtp.h" + +#include "xfa/fde/tto/fde_textout.h" +#include "xfa/fwl/basewidget/ifwl_checkbox.h" +#include "xfa/fwl/core/cfwl_themebackground.h" +#include "xfa/fwl/core/cfwl_themetext.h" +#include "xfa/fwl/core/ifwl_widget.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" + +#define CHECKBOX_SIZE_SIGNMARGIN 3 +#define CHECKBOX_SIZE_SIGNBORDER 2 +#define CHECKBOX_SIZE_SIGNPATH 100 +#define CHECKBOX_COLOR_BOXLT1 (ArgbEncode(255, 172, 168, 153)) +#define CHECKBOX_COLOR_BOXLT2 (ArgbEncode(255, 113, 111, 100)) +#define CHECKBOX_COLOR_BOXRB1 (ArgbEncode(255, 241, 239, 226)) +#define CHECKBOX_COLOR_BOXRB2 (ArgbEncode(255, 255, 255, 255)) +#define CHECKBOX_FXGE_CoordinatesAdjust + +CFWL_CheckBoxTP::CFWL_CheckBoxTP() : m_pCheckPath(NULL) { + m_pThemeData = new CKBThemeData; + SetThemeData(0); +} +CFWL_CheckBoxTP::~CFWL_CheckBoxTP() { + if (m_pThemeData) { + delete m_pThemeData; + m_pThemeData = NULL; + } + if (m_pCheckPath) { + m_pCheckPath->Clear(); + delete m_pCheckPath; + m_pCheckPath = NULL; + } +} +FX_BOOL CFWL_CheckBoxTP::IsValidWidget(IFWL_Widget* pWidget) { + return pWidget && pWidget->GetClassID() == FWL_CLASSHASH_CheckBox; +} +uint32_t CFWL_CheckBoxTP::SetThemeID(IFWL_Widget* pWidget, + uint32_t dwThemeID, + FX_BOOL bChildren) { + if (m_pThemeData) { + SetThemeData(FWL_GetThemeColor(dwThemeID)); + } + return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren); +} +FX_BOOL CFWL_CheckBoxTP::DrawText(CFWL_ThemeText* pParams) { + if (!m_pTextOut) + return FALSE; + m_pTextOut->SetTextColor((pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask1) == + FWL_PARTSTATE_CKB_Disabled + ? FWLTHEME_CAPACITY_TextDisColor + : FWLTHEME_CAPACITY_TextColor); + return CFWL_WidgetTP::DrawText(pParams); +} +FX_BOOL CFWL_CheckBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { + if (!pParams) + return FALSE; + switch (pParams->m_iPart) { + case FWL_PART_CKB_Border: { + DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_CKB_Edge: { + DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), + &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_CKB_Background: { + FillBackground(pParams->m_pGraphics, &pParams->m_rtPart, + &pParams->m_matrix); + if (pParams->m_dwStates & FWL_PARTSTATE_CKB_Focused) { + pParams->m_rtPart = *(CFX_RectF*)pParams->m_pData; + DrawFocus(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + } + break; + } + case FWL_PART_CKB_CheckBox: { + DrawBoxBk(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart, + pParams->m_dwStates, &pParams->m_matrix); + if (((pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask2) == + FWL_PARTSTATE_CKB_Checked) | + ((pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask2) == + FWL_PARTSTATE_CKB_Neutral)) { + DrawSign(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart, + pParams->m_dwStates, &pParams->m_matrix); + } + FX_BOOL bDisable = (pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask1) == + FWL_PARTSTATE_CKB_Disabled; + DrawSignBorder(pParams->m_pWidget, pParams->m_pGraphics, + &pParams->m_rtPart, bDisable, &pParams->m_matrix); + break; + } + default: { return FALSE; } + } + return TRUE; +} +FWL_ERR CFWL_CheckBoxTP::Initialize() { + InitTTO(); + return CFWL_WidgetTP::Initialize(); +} +FWL_ERR CFWL_CheckBoxTP::Finalize() { + FinalizeTTO(); + return CFWL_WidgetTP::Finalize(); +} +void CFWL_CheckBoxTP::DrawBoxBk(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + uint32_t dwStates, + CFX_Matrix* pMatrix) { + dwStates &= 0x03; + int32_t fillMode = FXFILL_WINDING; + uint32_t dwStyleEx = pWidget->GetStylesEx(); + dwStyleEx &= FWL_STYLEEXT_CKB_ShapeMask; + CFX_Path path; + path.Create(); + FX_FLOAT fRight = pRect->right(); + FX_FLOAT fBottom = pRect->bottom(); + FX_BOOL bClipSign = + (dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Hovered; + if ((dwStyleEx == FWL_STYLEEXT_CKB_ShapeSolidSquare) || + (dwStyleEx == FWL_STYLEEXT_CKB_ShapeSunkenSquare)) { + path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); + if (bClipSign) { + fillMode = FXFILL_ALTERNATE; + path.AddRectangle(pRect->left + CHECKBOX_SIZE_SIGNMARGIN, + pRect->top + CHECKBOX_SIZE_SIGNMARGIN, + pRect->width - CHECKBOX_SIZE_SIGNMARGIN * 2, + pRect->height - CHECKBOX_SIZE_SIGNMARGIN * 2); + } + } else { +#ifdef CHECKBOX_FXGE_CoordinatesAdjust + CFX_RectF rect(*pRect); + rect.Deflate(0, 0, 1, 1); + path.AddEllipse(rect); +#else + path.AddEllipse(*pRect); +#endif + if (bClipSign) { + fillMode = FXFILL_ALTERNATE; +#ifdef CHECKBOX_FXGE_CoordinatesAdjust + CFX_RectF rtClip(rect); +#else + CFX_RectF rtClip(*pRect); +#endif + rtClip.Deflate(CHECKBOX_SIZE_SIGNMARGIN - 1, + CHECKBOX_SIZE_SIGNMARGIN - 1); + path.AddEllipse(rtClip); + } + } + int32_t iTheme = 1; + if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Hovered) { + iTheme = 2; + } else if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == + FWL_PARTSTATE_CKB_Pressed) { + iTheme = 3; + } else if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == + FWL_PARTSTATE_CKB_Disabled) { + iTheme = 4; + } + if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Checked) { + iTheme += 4; + } else if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == + FWL_PARTSTATE_CKB_Neutral) { + iTheme += 8; + } + DrawAxialShading(pGraphics, pRect->left - 1, pRect->top - 1, fRight, fBottom, + m_pThemeData->clrBoxBk[iTheme][0], + m_pThemeData->clrBoxBk[iTheme][1], &path, fillMode, pMatrix); +} +void CFWL_CheckBoxTP::DrawSign(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_RectF* pRtBox, + uint32_t dwStates, + CFX_Matrix* pMatrix) { + CFX_RectF rtSign(*pRtBox); + rtSign.Deflate(CHECKBOX_SIZE_SIGNMARGIN, CHECKBOX_SIZE_SIGNMARGIN); + uint32_t dwColor = m_pThemeData->clrSignCheck; + FX_BOOL bCheck = TRUE; + if (((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Disabled) && + ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Checked)) { + dwColor = m_pThemeData->clrSignBorderDisable; + } else if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == + FWL_PARTSTATE_CKB_Neutral) { + switch (dwStates & FWL_PARTSTATE_CKB_Mask1) { + case FWL_PARTSTATE_CKB_Normal: { + bCheck = FALSE; + dwColor = m_pThemeData->clrSignNeutralNormal; + break; + } + case FWL_PARTSTATE_CKB_Hovered: { + bCheck = FALSE; + dwColor = m_pThemeData->clrSignNeutralHover; + break; + } + case FWL_PARTSTATE_CKB_Pressed: { + bCheck = FALSE, dwColor = m_pThemeData->clrSignNeutralPressed; + break; + } + case FWL_PARTSTATE_CKB_Disabled: { + bCheck = FALSE, dwColor = m_pThemeData->clrSignBorderDisable; + break; + } + } + } + if (bCheck) { + uint32_t dwStyle = pWidget->GetStylesEx(); + switch (dwStyle & FWL_STYLEEXT_CKB_SignShapeMask) { + case FWL_STYLEEXT_CKB_SignShapeCheck: { + DrawSignCheck(pGraphics, &rtSign, dwColor, pMatrix); + break; + } + case FWL_STYLEEXT_CKB_SignShapeCircle: { + rtSign.Deflate(1, 1); + DrawSignCircle(pGraphics, &rtSign, dwColor, pMatrix); + break; + } + case FWL_STYLEEXT_CKB_SignShapeCross: { + DrawSignCross(pGraphics, &rtSign, dwColor, pMatrix); + break; + } + case FWL_STYLEEXT_CKB_SignShapeDiamond: { + DrawSignDiamond(pGraphics, &rtSign, dwColor, pMatrix); + break; + } + case FWL_STYLEEXT_CKB_SignShapeSquare: { + DrawSignSquare(pGraphics, &rtSign, dwColor, pMatrix); + break; + } + case FWL_STYLEEXT_CKB_SignShapeStar: { + DrawSignStar(pGraphics, &rtSign, dwColor, pMatrix); + break; + } + } + } else { + FillSoildRect(pGraphics, ArgbEncode(255, 33, 161, 33), &rtSign, pMatrix); + } +} +void CFWL_CheckBoxTP::DrawSignNeutral(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + CFX_Matrix* pMatrix) { + ((CFX_RectF*)pRtSign)->Inflate(-3, -3); + FillSoildRect(pGraphics, m_pThemeData->clrSignNeutral, pRtSign, pMatrix); +} +void CFWL_CheckBoxTP::DrawSignCheck(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + FX_ARGB argbFill, + CFX_Matrix* pMatrix) { + if (!m_pCheckPath) { + initCheckPath(pRtSign->width); + } + CFX_Matrix mt; + mt.SetIdentity(); + mt.Translate(pRtSign->left, pRtSign->top); + mt.Concat(*pMatrix); + CFX_Color crFill(argbFill); + pGraphics->SaveGraphState(); + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(m_pCheckPath, FXFILL_WINDING, &mt); + pGraphics->RestoreGraphState(); +} +void CFWL_CheckBoxTP::DrawSignCircle(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + FX_ARGB argbFill, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + path.AddEllipse(*pRtSign); + CFX_Color crFill(argbFill); + pGraphics->SaveGraphState(); + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_CheckBoxTP::DrawSignCross(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + FX_ARGB argbFill, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + FX_FLOAT fRight = pRtSign->right(); + FX_FLOAT fBottom = pRtSign->bottom(); + path.AddLine(pRtSign->left, pRtSign->top, fRight, fBottom); + path.AddLine(pRtSign->left, fBottom, fRight, pRtSign->top); + CFX_Color crFill(argbFill); + pGraphics->SaveGraphState(); + pGraphics->SetStrokeColor(&crFill); + pGraphics->SetLineWidth(1.0f); + pGraphics->StrokePath(&path, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_CheckBoxTP::DrawSignDiamond(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + FX_ARGB argbFill, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + FX_FLOAT fWidth = pRtSign->width; + FX_FLOAT fHeight = pRtSign->height; + FX_FLOAT fBottom = pRtSign->bottom(); + path.MoveTo(pRtSign->left + fWidth / 2, pRtSign->top); + path.LineTo(pRtSign->left, pRtSign->top + fHeight / 2); + path.LineTo(pRtSign->left + fWidth / 2, fBottom); + path.LineTo(pRtSign->right(), pRtSign->top + fHeight / 2); + path.LineTo(pRtSign->left + fWidth / 2, pRtSign->top); + CFX_Color crFill(argbFill); + pGraphics->SaveGraphState(); + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_CheckBoxTP::DrawSignSquare(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + FX_ARGB argbFill, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + path.AddRectangle(pRtSign->left, pRtSign->top, pRtSign->width, + pRtSign->height); + CFX_Color crFill(argbFill); + pGraphics->SaveGraphState(); + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_CheckBoxTP::DrawSignStar(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + FX_ARGB argbFill, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + FX_FLOAT fBottom = pRtSign->bottom(); + FX_FLOAT fRadius = + (pRtSign->top - fBottom) / (1 + (FX_FLOAT)cos(FX_PI / 5.0f)); + CFX_PointF ptCenter((pRtSign->left + pRtSign->right()) / 2.0f, + (pRtSign->top + fBottom) / 2.0f); + FX_FLOAT px[5], py[5]; + FX_FLOAT fAngel = FX_PI / 10.0f; + for (int32_t i = 0; i < 5; i++) { + px[i] = ptCenter.x + fRadius * (FX_FLOAT)cos(fAngel); + py[i] = ptCenter.y + fRadius * (FX_FLOAT)sin(fAngel); + fAngel += FX_PI * 2 / 5.0f; + } + path.MoveTo(px[0], py[0]); + int32_t nNext = 0; + for (int32_t j = 0; j < 5; j++) { + nNext += 2; + if (nNext >= 5) { + nNext -= 5; + } + path.LineTo(px[nNext], py[nNext]); + } + CFX_Color crFill(argbFill); + pGraphics->SaveGraphState(); + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_CheckBoxTP::DrawSignBorder(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_RectF* pRtBox, + FX_BOOL bDisable, + CFX_Matrix* pMatrix) { + switch (pWidget->GetStylesEx() & FWL_STYLEEXT_CKB_ShapeMask) { + case FWL_STYLEEXT_CKB_ShapeSolidSquare: { + DrawAnnulusRect(pGraphics, bDisable ? m_pThemeData->clrSignBorderDisable + : m_pThemeData->clrSignBorderNormal, + pRtBox, 1, pMatrix); + break; + } + case FWL_STYLEEXT_CKB_ShapeSunkenSquare: { + Draw3DRect(pGraphics, FWLTHEME_EDGE_Sunken, CHECKBOX_SIZE_SIGNBORDER, + pRtBox, CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2, + CHECKBOX_COLOR_BOXRB1, CHECKBOX_COLOR_BOXRB2, pMatrix); + break; + } + case FWL_STYLEEXT_CKB_ShapeSolidCircle: { + DrawAnnulusCircle(pGraphics, bDisable ? m_pThemeData->clrSignBorderDisable + : m_pThemeData->clrSignBorderNormal, + pRtBox, 1, pMatrix); + break; + } + case FWL_STYLEEXT_CKB_ShapeSunkenCircle: { + Draw3DCircle(pGraphics, FWLTHEME_EDGE_Sunken, CHECKBOX_SIZE_SIGNBORDER, + pRtBox, CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2, + CHECKBOX_COLOR_BOXRB1, CHECKBOX_COLOR_BOXRB2, pMatrix); + break; + } + } +} +void CFWL_CheckBoxTP::SetThemeData(uint32_t dwID) { + uint32_t* pData = (uint32_t*)&m_pThemeData->clrBoxBk; + if (dwID) { + *pData++ = 0, *pData++ = 0, *pData++ = ArgbEncode(255, 220, 220, 215), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 240, 207), + *pData++ = ArgbEncode(255, 248, 179, 48), + *pData++ = ArgbEncode(255, 176, 176, 167), + *pData++ = ArgbEncode(255, 241, 239, 239), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 220, 220, 215), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 240, 207), + *pData++ = ArgbEncode(255, 248, 179, 48), + *pData++ = ArgbEncode(255, 176, 176, 167), + *pData++ = ArgbEncode(255, 241, 239, 239), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 220, 220, 215), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 240, 207), + *pData++ = ArgbEncode(255, 248, 179, 48), + *pData++ = ArgbEncode(255, 176, 176, 167), + *pData++ = ArgbEncode(255, 241, 239, 239), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 255, 255); + m_pThemeData->clrSignBorderNormal = ArgbEncode(255, 154, 167, 114); + m_pThemeData->clrSignBorderDisable = ArgbEncode(255, 202, 200, 187); + m_pThemeData->clrSignCheck = ArgbEncode(255, 164, 180, 138); + m_pThemeData->clrSignNeutral = ArgbEncode(2255, 28, 134, 26); + m_pThemeData->clrSignNeutralNormal = ArgbEncode(255, 114, 192, 113); + m_pThemeData->clrSignNeutralHover = ArgbEncode(255, 33, 161, 33); + m_pThemeData->clrSignNeutralPressed = ArgbEncode(255, 28, 134, 26); + } else { + *pData++ = 0, *pData++ = 0, *pData++ = ArgbEncode(255, 220, 220, 215), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 240, 207), + *pData++ = ArgbEncode(255, 248, 179, 48), + *pData++ = ArgbEncode(255, 176, 176, 167), + *pData++ = ArgbEncode(255, 241, 239, 239), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 220, 220, 215), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 240, 207), + *pData++ = ArgbEncode(255, 248, 179, 48), + *pData++ = ArgbEncode(255, 176, 176, 167), + *pData++ = ArgbEncode(255, 241, 239, 239), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 220, 220, 215), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 240, 207), + *pData++ = ArgbEncode(255, 248, 179, 48), + *pData++ = ArgbEncode(255, 176, 176, 167), + *pData++ = ArgbEncode(255, 241, 239, 239), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 255, 255); + m_pThemeData->clrSignBorderNormal = ArgbEncode(255, 28, 81, 128); + m_pThemeData->clrSignBorderDisable = ArgbEncode(255, 202, 200, 187); + m_pThemeData->clrSignCheck = ArgbEncode(255, 28, 81, 128); + m_pThemeData->clrSignNeutral = ArgbEncode(255, 28, 134, 26); + m_pThemeData->clrSignNeutralNormal = ArgbEncode(255, 114, 192, 113); + m_pThemeData->clrSignNeutralHover = ArgbEncode(255, 33, 161, 33); + m_pThemeData->clrSignNeutralPressed = ArgbEncode(255, 28, 134, 26); + } +} +void CFWL_CheckBoxTP::initCheckPath(FX_FLOAT fCheckLen) { + if (!m_pCheckPath) { + m_pCheckPath = new CFX_Path; + m_pCheckPath->Create(); + FX_FLOAT fWidth = CHECKBOX_SIZE_SIGNPATH; + FX_FLOAT fHeight = -CHECKBOX_SIZE_SIGNPATH; + FX_FLOAT fBottom = CHECKBOX_SIZE_SIGNPATH; + CFX_PointF pt1(fWidth / 15.0f, fBottom + fHeight * 2 / 5.0f); + CFX_PointF pt2(fWidth / 4.5f, fBottom + fHeight / 16.0f); + CFX_PointF pt3(fWidth / 3.0f, fBottom); + CFX_PointF pt4(fWidth * 14 / 15.0f, fBottom + fHeight * 15 / 16.0f); + CFX_PointF pt5(fWidth / 3.6f, fBottom + fHeight / 3.5f); + CFX_PointF pt12(fWidth / 7.0f, fBottom + fHeight * 2 / 7.0f); + CFX_PointF pt21(fWidth / 5.0f, fBottom + fHeight / 5.0f); + CFX_PointF pt23(fWidth / 4.4f, fBottom + fHeight * 0 / 16.0f); + CFX_PointF pt32(fWidth / 4.0f, fBottom); + CFX_PointF pt34(fWidth * (1 / 7.0f + 7 / 15.0f), + fBottom + fHeight * 4 / 5.0f); + CFX_PointF pt43(fWidth * (1 / 7.0f + 7 / 15.0f), + fBottom + fHeight * 4 / 5.0f); + CFX_PointF pt45(fWidth * 7 / 15.0f, fBottom + fHeight * 8 / 7.0f); + CFX_PointF pt54(fWidth / 3.4f, fBottom + fHeight / 3.5f); + CFX_PointF pt51(fWidth / 3.6f, fBottom + fHeight / 4.0f); + CFX_PointF pt15(fWidth / 3.5f, fBottom + fHeight * 3.5f / 5.0f); + m_pCheckPath->MoveTo(pt1.x, pt1.y); + FX_FLOAT px1 = pt12.x - pt1.x; + FX_FLOAT py1 = pt12.y - pt1.y; + FX_FLOAT px2 = pt21.x - pt2.x; + FX_FLOAT py2 = pt21.y - pt2.y; + m_pCheckPath->BezierTo(pt1.x + px1 * FWLTHEME_BEZIER, + pt1.y + py1 * FWLTHEME_BEZIER, + pt2.x + px2 * FWLTHEME_BEZIER, + pt2.y + py2 * FWLTHEME_BEZIER, pt2.x, pt2.y); + px1 = pt23.x - pt2.x; + py1 = pt23.y - pt2.y; + px2 = pt32.x - pt3.x; + py2 = pt32.y - pt3.y; + m_pCheckPath->BezierTo(pt2.x + px1 * FWLTHEME_BEZIER, + pt2.y + py1 * FWLTHEME_BEZIER, + pt3.x + px2 * FWLTHEME_BEZIER, + pt3.y + py2 * FWLTHEME_BEZIER, pt3.x, pt3.y); + px1 = pt34.x - pt3.x; + py1 = pt34.y - pt3.y; + px2 = pt43.x - pt4.x; + py2 = pt43.y - pt4.y; + m_pCheckPath->BezierTo(pt3.x + px1 * FWLTHEME_BEZIER, + pt3.y + py1 * FWLTHEME_BEZIER, + pt4.x + px2 * FWLTHEME_BEZIER, + pt4.y + py2 * FWLTHEME_BEZIER, pt4.x, pt4.y); + px1 = pt45.x - pt4.x; + py1 = pt45.y - pt4.y; + px2 = pt54.x - pt5.x; + py2 = pt54.y - pt5.y; + m_pCheckPath->BezierTo(pt4.x + px1 * FWLTHEME_BEZIER, + pt4.y + py1 * FWLTHEME_BEZIER, + pt5.x + px2 * FWLTHEME_BEZIER, + pt5.y + py2 * FWLTHEME_BEZIER, pt5.x, pt5.y); + px1 = pt51.x - pt5.x; + py1 = pt51.y - pt5.y; + px2 = pt15.x - pt1.x; + py2 = pt15.y - pt1.y; + m_pCheckPath->BezierTo(pt5.x + px1 * FWLTHEME_BEZIER, + pt5.y + py1 * FWLTHEME_BEZIER, + pt1.x + px2 * FWLTHEME_BEZIER, + pt1.y + py2 * FWLTHEME_BEZIER, pt1.x, pt1.y); + FX_FLOAT fScale = fCheckLen / CHECKBOX_SIZE_SIGNPATH; + CFX_Matrix mt; + mt.Set(1, 0, 0, 1, 0, 0); + mt.Scale(fScale, fScale); + CFX_PathData* pData = m_pCheckPath->GetPathData(); + pData->Transform(&mt); + } +} diff --git a/xfa/fwl/theme/cfwl_checkboxtp.h b/xfa/fwl/theme/cfwl_checkboxtp.h new file mode 100644 index 0000000000..bb2f14dec3 --- /dev/null +++ b/xfa/fwl/theme/cfwl_checkboxtp.h @@ -0,0 +1,84 @@ +// 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_THEME_CFWL_CHECKBOXTP_H_ +#define XFA_FWL_THEME_CFWL_CHECKBOXTP_H_ + +#include "xfa/fwl/theme/cfwl_utils.h" +#include "xfa/fwl/theme/cfwl_widgettp.h" + +class CFWL_CheckBoxTP : public CFWL_WidgetTP { + public: + CFWL_CheckBoxTP(); + virtual ~CFWL_CheckBoxTP(); + virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); + virtual uint32_t SetThemeID(IFWL_Widget* pWidget, + uint32_t dwThemeID, + FX_BOOL bChildren = TRUE); + virtual FX_BOOL DrawText(CFWL_ThemeText* pParams); + virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); + virtual FWL_ERR Initialize(); + virtual FWL_ERR Finalize(); + + protected: + void DrawBoxBk(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + uint32_t dwStates, + CFX_Matrix* pMatrix = NULL); + void DrawSign(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_RectF* pRtBox, + uint32_t dwStates, + CFX_Matrix* pMatrix = NULL); + void DrawSignNeutral(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + CFX_Matrix* pMatrix = NULL); + void DrawSignCheck(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + FX_ARGB argbFill, + CFX_Matrix* pMatrix = NULL); + void DrawSignCircle(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + FX_ARGB argbFill, + CFX_Matrix* pMatrix = NULL); + void DrawSignCross(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + FX_ARGB argbFill, + CFX_Matrix* pMatrix = NULL); + void DrawSignDiamond(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + FX_ARGB argbFill, + CFX_Matrix* pMatrix = NULL); + void DrawSignSquare(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + FX_ARGB argbFill, + CFX_Matrix* pMatrix = NULL); + void DrawSignStar(CFX_Graphics* pGraphics, + const CFX_RectF* pRtSign, + FX_ARGB argbFill, + CFX_Matrix* pMatrix = NULL); + void DrawSignBorder(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_RectF* pRtBox, + FX_BOOL bDisable = FALSE, + CFX_Matrix* pMatrix = NULL); + void SetThemeData(uint32_t dwID); + void initCheckPath(FX_FLOAT fCheckLen); + struct CKBThemeData { + FX_ARGB clrBoxBk[13][2]; + FX_ARGB clrSignBorderNormal; + FX_ARGB clrSignBorderDisable; + FX_ARGB clrSignCheck; + FX_ARGB clrSignNeutral; + FX_ARGB clrSignNeutralNormal; + FX_ARGB clrSignNeutralHover; + FX_ARGB clrSignNeutralPressed; + } * m_pThemeData; + CFX_Path* m_pCheckPath; +}; + +#endif // XFA_FWL_THEME_CFWL_CHECKBOXTP_H_ diff --git a/xfa/fwl/theme/cfwl_comboboxtp.cpp b/xfa/fwl/theme/cfwl_comboboxtp.cpp new file mode 100644 index 0000000000..2c5a1c4ff4 --- /dev/null +++ b/xfa/fwl/theme/cfwl_comboboxtp.cpp @@ -0,0 +1,160 @@ +// 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/theme/cfwl_comboboxtp.h" + +#include "xfa/fwl/basewidget/ifwl_combobox.h" +#include "xfa/fwl/core/cfwl_themebackground.h" +#include "xfa/fwl/core/ifwl_themeprovider.h" +#include "xfa/fwl/core/ifwl_widget.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" + +#define FWLTHEME_CAPACITY_ComboFormHandler 8.0f + +CFWL_ComboBoxTP::CFWL_ComboBoxTP() { + m_dwThemeID = 0; +} +CFWL_ComboBoxTP::~CFWL_ComboBoxTP() {} +FX_BOOL CFWL_ComboBoxTP::IsValidWidget(IFWL_Widget* pWidget) { + if (!pWidget) + return FALSE; + return pWidget->GetClassID() == FWL_CLASSHASH_ComboBox; +} +FX_BOOL CFWL_ComboBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { + if (!pParams) + return FALSE; + switch (pParams->m_iPart) { + case FWL_PART_CMB_Border: { + DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_CMB_Edge: { + DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), + &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_CMB_Background: { + CFX_Path path; + path.Create(); + CFX_RectF& rect = pParams->m_rtPart; + path.AddRectangle(rect.left, rect.top, rect.width, rect.height); + CFX_Color cr; + switch (pParams->m_dwStates) { + case FWL_PARTSTATE_CMB_Selected: + cr = FWLTHEME_COLOR_BKSelected; + break; + case FWL_PARTSTATE_CMB_Disabled: + cr = FWLTHEME_COLOR_EDGERB1; + break; + default: + cr = 0xFFFFFFFF; + } + pParams->m_pGraphics->SaveGraphState(); + pParams->m_pGraphics->SetFillColor(&cr); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix); + pParams->m_pGraphics->RestoreGraphState(); + break; + } + case FWL_PART_CMB_DropDownButton: { + DrawDropDownButton(pParams, pParams->m_dwStates, &pParams->m_matrix); + break; + } + case FWL_PART_CMB_StretcgHandler: { + DrawStrethHandler(pParams, 0, &pParams->m_matrix); + break; + } + default: { return FALSE; } + } + return TRUE; +} +void CFWL_ComboBoxTP::DrawStrethHandler(CFWL_ThemeBackground* pParams, + uint32_t dwStates, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + path.AddRectangle(pParams->m_rtPart.left, pParams->m_rtPart.top, + pParams->m_rtPart.width - 1, pParams->m_rtPart.height); + CFX_Color cr(ArgbEncode(0xff, 0xff, 0, 0)); + pParams->m_pGraphics->SetFillColor(&cr); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix); +} +void* CFWL_ComboBoxTP::GetCapacity(CFWL_ThemePart* pThemePart, + uint32_t dwCapacity) { + if (dwCapacity == FWL_WGTCAPACITY_CMB_ComboFormHandler) { + m_fValue = FWLTHEME_CAPACITY_ComboFormHandler; + return &m_fValue; + } + return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); +} +#ifdef THEME_XPSimilar +void CFWL_ComboBoxTP::DrawDropDownButton(CFWL_ThemeBackground* pParams, + uint32_t dwStates, + CFX_Matrix* pMatrix) { + FWLTHEME_STATE eState = FWLTHEME_STATE_Normal; + switch (dwStates) { + case FWL_PARTSTATE_CMB_Normal: { + eState = FWLTHEME_STATE_Normal; + break; + } + case FWL_PARTSTATE_CMB_Hovered: { + eState = FWLTHEME_STATE_Hover; + break; + } + case FWL_PARTSTATE_CMB_Pressed: { + eState = FWLTHEME_STATE_Pressed; + break; + } + case FWL_PARTSTATE_CMB_Disabled: { + eState = FWLTHEME_STATE_Disabale; + break; + } + default: {} + } + DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, + FWLTHEME_DIRECTION_Down, eState, &pParams->m_matrix); +} +#else +void CFWL_ComboBoxTP::DrawDropDownButton(CFWL_ThemeBackground* pParams, + uint32_t dwStates, + CFX_Matrix* pMatrix) { + FX_BOOL bPressed = ((pParams->m_dwStates & FWL_CMBPARTSTATE_Pressed) == + FWL_CMBPARTSTATE_Pressed); + FX_FLOAT fWidth = bPressed ? 1.0f : 2.0f; + FWLTHEME_EDGE eType = bPressed ? FWLTHEME_EDGE_Flat : FWLTHEME_EDGE_Raised; + Draw3DRect(pParams->m_pGraphics, eType, fWidth, &pParams->m_rtPart, + FWLTHEME_COLOR_EDGELT1, FWLTHEME_COLOR_EDGELT2, + FWLTHEME_COLOR_EDGERB1, FWLTHEME_COLOR_EDGERB2, pMatrix); + CFX_Path path; + path.Create(); + path.AddRectangle(pParams->m_rtPart.left + fWidth, + pParams->m_rtPart.top + fWidth, + pParams->m_rtPart.width - 2 * fWidth, + pParams->m_rtPart.height - 2 * fWidth); + pParams->m_pGraphics->SaveGraphState(); + CFX_Color crFill(FWLTHEME_COLOR_Background); + pParams->m_pGraphics->SetFillColor(&crFill); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix); + pParams->m_pGraphics->RestoreGraphState(); + FX_ARGB argbFill = ArgbEncode(255, 77, 97, 133); + switch (pParams->m_dwStates & 0x03) { + case FWL_CMBPARTSTATE_Normal: { + } + case FWL_CMBPARTSTATE_Hovered: { + } + case FWL_CMBPARTSTATE_Pressed: { + argbFill = 0xFF000000; + break; + } + case FWL_CMBPARTSTATE_Disabled: { + argbFill = 0xFFF0F0F0; + break; + } + } + DrawArrow(pParams->m_pGraphics, &pParams->m_rtPart, FWLTHEME_DIRECTION_Down, + argbFill, bPressed, &pParams->m_matrix); +} +#endif diff --git a/xfa/fwl/theme/cfwl_comboboxtp.h b/xfa/fwl/theme/cfwl_comboboxtp.h new file mode 100644 index 0000000000..fd65fa5fab --- /dev/null +++ b/xfa/fwl/theme/cfwl_comboboxtp.h @@ -0,0 +1,29 @@ +// 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_THEME_CFWL_COMBOBOXTP_H_ +#define XFA_FWL_THEME_CFWL_COMBOBOXTP_H_ + +#include "xfa/fwl/theme/cfwl_widgettp.h" + +class CFWL_ComboBoxTP : public CFWL_WidgetTP { + public: + CFWL_ComboBoxTP(); + virtual ~CFWL_ComboBoxTP(); + virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); + virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); + virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity); + + protected: + void DrawDropDownButton(CFWL_ThemeBackground* pParams, + uint32_t dwStates, + CFX_Matrix* pMatrix); + void DrawStrethHandler(CFWL_ThemeBackground* pParams, + uint32_t dwStates, + CFX_Matrix* pMatrix); +}; + +#endif // XFA_FWL_THEME_CFWL_COMBOBOXTP_H_ diff --git a/xfa/fwl/theme/cfwl_datetimepickedtp.cpp b/xfa/fwl/theme/cfwl_datetimepickedtp.cpp new file mode 100644 index 0000000000..4e1d39a15a --- /dev/null +++ b/xfa/fwl/theme/cfwl_datetimepickedtp.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/theme/cfwl_datetimepickertp.h" + +#include "xfa/fwl/basewidget/ifwl_datetimepicker.h" +#include "xfa/fwl/core/cfwl_themebackground.h" + +CFWL_DateTimePickerTP::CFWL_DateTimePickerTP() { + m_pThemeData = new DTPThemeData; + initThemeData(); +} +CFWL_DateTimePickerTP::~CFWL_DateTimePickerTP() { + delete m_pThemeData; +} +FX_BOOL CFWL_DateTimePickerTP::IsValidWidget(IFWL_Widget* pWidget) { + if (!pWidget) + return FALSE; + return pWidget->GetClassID() == FWL_CLASSHASH_DateTimePicker; +} +FX_BOOL CFWL_DateTimePickerTP::DrawBackground(CFWL_ThemeBackground* pParams) { + if (!pParams) + return FALSE; + switch (pParams->m_iPart) { + case FWL_PART_DTP_Border: { + DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_DTP_Edge: { + DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), + &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_DTP_DropDownButton: { + DrawDropDownButton(pParams, &pParams->m_matrix); + break; + } + default: {} + } + return TRUE; +} +#ifdef THEME_XPSimilar +void CFWL_DateTimePickerTP::DrawDropDownButton(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + uint32_t dwStates = pParams->m_dwStates; + dwStates &= 0x03; + FWLTHEME_STATE eState = FWLTHEME_STATE_Normal; + switch (eState & dwStates) { + case FWL_PARTSTATE_DTP_Normal: { + eState = FWLTHEME_STATE_Normal; + break; + } + case FWL_PARTSTATE_DTP_Hovered: { + eState = FWLTHEME_STATE_Hover; + break; + } + case FWL_PARTSTATE_DTP_Pressed: { + eState = FWLTHEME_STATE_Pressed; + break; + } + case FWL_PARTSTATE_DTP_Disabled: { + eState = FWLTHEME_STATE_Disabale; + break; + } + default: {} + } + DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, + FWLTHEME_DIRECTION_Down, eState, pMatrix); +} +#else +void CFWL_DateTimePickerTP::DrawDropDownButton(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + FX_BOOL bPressed = ((pParams->m_dwStates & FWL_PARTSTATE_DTP_Pressed) == + FWL_PARTSTATE_DTP_Pressed); + FX_FLOAT fWidth = bPressed ? 1.0f : 2.0f; + FWLTHEME_EDGE eType = bPressed ? FWLTHEME_EDGE_Flat : FWLTHEME_EDGE_Raised; + Draw3DRect(pParams->m_pGraphics, eType, fWidth, &pParams->m_rtPart, + FWLTHEME_COLOR_EDGELT1, FWLTHEME_COLOR_EDGELT2, + FWLTHEME_COLOR_EDGERB1, FWLTHEME_COLOR_EDGERB2, pMatrix); + CFX_Path path; + path.Create(); + path.AddRectangle(pParams->m_rtPart.left + fWidth, + pParams->m_rtPart.top + fWidth, + pParams->m_rtPart.width - 2 * fWidth, + pParams->m_rtPart.height - 2 * fWidth); + pParams->m_pGraphics->SaveGraphState(); + CFX_Color crFill(FWLTHEME_COLOR_Background); + pParams->m_pGraphics->SetFillColor(&crFill); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pParams->m_pGraphics->RestoreGraphState(); + FX_ARGB argbFill = ArgbEncode(255, 77, 97, 133); + switch (pParams->m_dwStates & 0x03) { + case FWL_PARTSTATE_DTP_Normal: { + } + case FWL_PARTSTATE_DTP_Hovered: { + } + case FWL_PARTSTATE_DTP_Pressed: { + argbFill = 0xFF000000; + break; + } + case FWL_PARTSTATE_DTP_Disabled: { + argbFill = 0xFFF0F0F0; + break; + } + } + DrawArrow(pParams->m_pGraphics, &pParams->m_rtPart, FWLTHEME_DIRECTION_Down, + argbFill, bPressed, pMatrix); +} +#endif +void CFWL_DateTimePickerTP::initThemeData() { + uint32_t* pData = (uint32_t*)&m_pThemeData->BoxBkColor; + *pData++ = 0; + *pData++ = 0; + *pData++ = ArgbEncode(255, 220, 220, 215), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 240, 207), + *pData++ = ArgbEncode(255, 248, 179, 48), + *pData++ = ArgbEncode(255, 176, 176, 167), + *pData++ = ArgbEncode(255, 241, 239, 239), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 220, 220, 215), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 240, 207), + *pData++ = ArgbEncode(255, 248, 179, 48), + *pData++ = ArgbEncode(255, 176, 176, 167), + *pData++ = ArgbEncode(255, 241, 239, 239), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 220, 220, 215), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 240, 207), + *pData++ = ArgbEncode(255, 248, 179, 48), + *pData++ = ArgbEncode(255, 176, 176, 167), + *pData++ = ArgbEncode(255, 241, 239, 239), + *pData++ = ArgbEncode(255, 255, 255, 255), + *pData++ = ArgbEncode(255, 255, 255, 255); +} diff --git a/xfa/fwl/theme/cfwl_datetimepickertp.h b/xfa/fwl/theme/cfwl_datetimepickertp.h new file mode 100644 index 0000000000..199551ea1f --- /dev/null +++ b/xfa/fwl/theme/cfwl_datetimepickertp.h @@ -0,0 +1,27 @@ +// 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_THEME_CFWL_DATETIMEPICKERTP_H_ +#define XFA_FWL_THEME_CFWL_DATETIMEPICKERTP_H_ + +#include "xfa/fwl/theme/cfwl_widgettp.h" + +class CFWL_DateTimePickerTP : public CFWL_WidgetTP { + public: + CFWL_DateTimePickerTP(); + virtual ~CFWL_DateTimePickerTP(); + virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); + virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); + + protected: + void DrawDropDownButton(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); + void initThemeData(); + struct DTPThemeData { + FX_ARGB BoxBkColor[13][2]; + } * m_pThemeData; +}; + +#endif // XFA_FWL_THEME_CFWL_DATETIMEPICKERTP_H_ diff --git a/xfa/fwl/theme/cfwl_edittp.cpp b/xfa/fwl/theme/cfwl_edittp.cpp new file mode 100644 index 0000000000..92f32dcaa9 --- /dev/null +++ b/xfa/fwl/theme/cfwl_edittp.cpp @@ -0,0 +1,92 @@ +// 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/theme/cfwl_edittp.h" + +#include "xfa/fwl/basewidget/ifwl_edit.h" +#include "xfa/fwl/core/cfwl_themebackground.h" +#include "xfa/fwl/core/ifwl_widget.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" + +CFWL_EditTP::CFWL_EditTP() {} +CFWL_EditTP::~CFWL_EditTP() {} + +FX_BOOL CFWL_EditTP::IsValidWidget(IFWL_Widget* pWidget) { + if (!pWidget) + return FALSE; + return pWidget->GetClassID() == FWL_CLASSHASH_Edit; +} +FX_BOOL CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) { + switch (pParams->m_iPart) { + case FWL_PART_EDT_Border: { + DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_EDT_Edge: { + DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), + &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_EDT_Background: { + if (pParams->m_pPath) { + CFX_Graphics* pGraphics = pParams->m_pGraphics; + pGraphics->SaveGraphState(); + CFX_Color crSelected(FWL_GetThemeColor(m_dwThemeID) == 0 + ? FWLTHEME_COLOR_BKSelected + : FWLTHEME_COLOR_Green_BKSelected); + pGraphics->SetFillColor(&crSelected); + pGraphics->FillPath(pParams->m_pPath, FXFILL_WINDING, + &pParams->m_matrix); + pGraphics->RestoreGraphState(); + } else { + FX_BOOL bStatic = + pParams->m_dwData == FWL_PARTDATA_EDT_StaticBackground; + CFX_Path path; + path.Create(); + path.AddRectangle(pParams->m_rtPart.left, pParams->m_rtPart.top, + pParams->m_rtPart.width, pParams->m_rtPart.height); + CFX_Color cr(FWLTHEME_COLOR_Background); + if (!bStatic) { + if ((pParams->m_dwStates & FWL_PARTSTATE_EDT_Disable) == + FWL_PARTSTATE_EDT_Disable) { + cr.Set(FWLTHEME_COLOR_EDGERB1); + } else if ((pParams->m_dwStates & FWL_PARTSTATE_EDT_ReadOnly) == + FWL_PARTSTATE_EDT_ReadOnly) { + cr.Set(ArgbEncode(255, 236, 233, 216)); + } else { + cr.Set(0xFFFFFFFF); + } + } + pParams->m_pGraphics->SaveGraphState(); + pParams->m_pGraphics->SetFillColor(&cr); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, + &pParams->m_matrix); + pParams->m_pGraphics->RestoreGraphState(); + } + break; + } + case FWL_PART_EDT_CombTextLine: { + FX_ARGB cr = 0xFF000000; + FX_FLOAT fWidth = 1.0f; + CFX_Color crLine(cr); + pParams->m_pGraphics->SetStrokeColor(&crLine); + pParams->m_pGraphics->SetLineWidth(fWidth); + pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix); + break; + } + default: { break; } + } + return TRUE; +} +FWL_ERR CFWL_EditTP::Initialize() { + InitTTO(); + return CFWL_WidgetTP::Initialize(); +} +FWL_ERR CFWL_EditTP::Finalize() { + FinalizeTTO(); + return CFWL_WidgetTP::Finalize(); +} diff --git a/xfa/fwl/theme/cfwl_edittp.h b/xfa/fwl/theme/cfwl_edittp.h new file mode 100644 index 0000000000..73c99dafb7 --- /dev/null +++ b/xfa/fwl/theme/cfwl_edittp.h @@ -0,0 +1,22 @@ +// 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_THEME_CFWL_EDITTP_H_ +#define XFA_FWL_THEME_CFWL_EDITTP_H_ + +#include "xfa/fwl/theme/cfwl_widgettp.h" + +class CFWL_EditTP : public CFWL_WidgetTP { + public: + CFWL_EditTP(); + virtual ~CFWL_EditTP(); + virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); + virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); + virtual FWL_ERR Initialize(); + virtual FWL_ERR Finalize(); +}; + +#endif // XFA_FWL_THEME_CFWL_EDITTP_H_ diff --git a/xfa/fwl/theme/cfwl_formtp.cpp b/xfa/fwl/theme/cfwl_formtp.cpp new file mode 100644 index 0000000000..e7cc1221d0 --- /dev/null +++ b/xfa/fwl/theme/cfwl_formtp.cpp @@ -0,0 +1,899 @@ +// 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/theme/cfwl_formtp.h" + +#include "xfa/fde/tto/fde_textout.h" +#include "xfa/fwl/core/cfwl_themebackground.h" +#include "xfa/fwl/core/cfwl_themepart.h" +#include "xfa/fwl/core/cfwl_themetext.h" +#include "xfa/fwl/core/ifwl_form.h" +#include "xfa/fwl/core/ifwl_themeprovider.h" +#include "xfa/fwl/core/ifwl_widget.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" + +#define FWLTHEME_CAPACITY_CXFormBorder 3 +#define FWLTHEME_CAPACITY_CYFormBorder 3 +#define FWLTHEME_CAPACITY_CYNarrowCaption 18 +#define FWLTHEME_CAPACITY_CYCaption 29 +#define FWLTHEME_CAPACITY_BigIconSize 32 +#define FWLTHEME_CAPACITY_SmallIconSize 16 +#define FWLTHEME_CAPACITY_FormTextColor 0xFFFFFFFF +#define FWLTHEME_FORMBTN_Margin 5 +#define FWLTHEME_FORMBTN_Span 2 +#define FWLTHEME_FORMBTN_Size 21 + +CFWL_FormTP::CFWL_FormTP() : m_pActiveBitmap(NULL), m_pDeactivebitmap(NULL) { + m_pThemeData = new SBThemeData; + SetThemeData(0); + m_rtDisLBorder.Reset(); + m_rtDisRBorder.Reset(); + m_rtDisBBorder.Reset(); + m_rtDisCaption.Reset(); +} +CFWL_FormTP::~CFWL_FormTP() { + if (m_pThemeData) { + delete m_pThemeData; + m_pThemeData = NULL; + } +} +FWL_ERR CFWL_FormTP::Initialize() { + InitTTO(); + InitCaption(TRUE); + InitCaption(FALSE); + return CFWL_WidgetTP::Initialize(); +} +FWL_ERR CFWL_FormTP::Finalize() { + FinalizeTTO(); + if (m_pActiveBitmap) { + delete m_pActiveBitmap; + m_pActiveBitmap = NULL; + } + if (m_pDeactivebitmap) { + delete m_pDeactivebitmap; + m_pDeactivebitmap = NULL; + } + return CFWL_WidgetTP::Finalize(); +} +FX_BOOL CFWL_FormTP::IsValidWidget(IFWL_Widget* pWidget) { + if (!pWidget) + return FALSE; + uint32_t dwHash = pWidget->GetClassID(); + return dwHash == FWL_CLASSHASH_Form; +} +uint32_t CFWL_FormTP::SetThemeID(IFWL_Widget* pWidget, + uint32_t dwThemeID, + FX_BOOL bChildren) { + if (m_pThemeData) { + SetThemeData(FWL_GetThemeColor(dwThemeID)); + } + InitCaption(TRUE); + InitCaption(FALSE); + return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren); +} +FX_BOOL CFWL_FormTP::DrawBackground(CFWL_ThemeBackground* pParams) { + if (!pParams) + return FALSE; + int32_t iActive = 0; + if (pParams->m_dwStates & FWL_PARTSTATE_FRM_Inactive) { + iActive = 1; + } + FWLTHEME_STATE eState = FWLTHEME_STATE_Normal; + switch (pParams->m_dwStates & 0x03) { + case FWL_PARTSTATE_FRM_Hover: { + eState = FWLTHEME_STATE_Hover; + break; + } + case FWL_PARTSTATE_FRM_Pressed: { + eState = FWLTHEME_STATE_Pressed; + break; + } + case FWL_PARTSTATE_FRM_Disabled: { + eState = FWLTHEME_STATE_Disabale; + break; + } + default: {} + } + switch (pParams->m_iPart) { + case FWL_PART_FRM_Border: { + DrawFormBorder(pParams->m_pGraphics, &pParams->m_rtPart, eState, + &pParams->m_matrix, iActive); + break; + } + case FWL_PART_FRM_Edge: { + DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), + &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_FRM_Background: { + FillBackground(pParams->m_pGraphics, &pParams->m_rtPart, + &pParams->m_matrix); + break; + } + case FWL_PART_FRM_Caption: { + DrawCaption(pParams->m_pGraphics, &pParams->m_rtPart, eState, + &pParams->m_matrix, iActive); + break; + } + case FWL_PART_FRM_NarrowCaption: { + DrawNarrowCaption(pParams->m_pGraphics, &pParams->m_rtPart, eState, + &pParams->m_matrix, iActive); + break; + } + case FWL_PART_FRM_CloseBox: { + DrawCloseBox(pParams->m_pGraphics, &pParams->m_rtPart, eState, + &pParams->m_matrix, iActive); + break; + } + case FWL_PART_FRM_MinimizeBox: { + DrawMinimizeBox(pParams->m_pGraphics, &pParams->m_rtPart, eState, + &pParams->m_matrix, iActive); + break; + } + case FWL_PART_FRM_MaximizeBox: { + DrawMaximizeBox(pParams->m_pGraphics, &pParams->m_rtPart, eState, + pParams->m_dwData, &pParams->m_matrix, iActive); + break; + } + case FWL_PART_FRM_Icon: { + DrawIconImage(pParams->m_pGraphics, pParams->m_pImage, &pParams->m_rtPart, + eState, &pParams->m_matrix, iActive); + break; + } + default: {} + } + return TRUE; +} +FX_BOOL CFWL_FormTP::DrawText(CFWL_ThemeText* pParams) { + if (!m_pTextOut) + return FALSE; + if (pParams->m_iPart == FWL_PART_FRM_Caption) { + m_pTextOut->SetTextColor(0xFFFFFFFF); + } else { + m_pTextOut->SetTextColor(0xFF000000); + } + return CFWL_WidgetTP::DrawText(pParams); +} +void* CFWL_FormTP::GetCapacity(CFWL_ThemePart* pThemePart, + uint32_t dwCapacity) { + FX_BOOL bDefPro = FALSE; + FX_BOOL bDwordVal = FALSE; + switch (dwCapacity) { + case FWL_WGTCAPACITY_CXBorder: { + m_fValue = FWLTHEME_CAPACITY_CXFormBorder; + break; + } + case FWL_WGTCAPACITY_CYBorder: { + m_fValue = FWLTHEME_CAPACITY_CYFormBorder; + break; + } + case FWL_WGTCAPACITY_FRM_CYCaption: { + m_fValue = FWLTHEME_CAPACITY_CYCaption; + break; + } + case FWL_WGTCAPACITY_FRM_CYNarrowCaption: { + m_fValue = FWLTHEME_CAPACITY_CYCaption; + break; + } + case FWL_WGTCAPACITY_TextColor: { + bDwordVal = TRUE; + m_dwValue = FWLTHEME_CAPACITY_FormTextColor; + break; + } + case FWL_WGTCAPACITY_FRM_BigIcon: { + m_fValue = FWLTHEME_CAPACITY_BigIconSize; + break; + } + case FWL_WGTCAPACITY_FRM_SmallIcon: { + m_fValue = FWLTHEME_CAPACITY_SmallIconSize; + break; + } + default: { bDefPro = TRUE; } + } + if (!bDefPro) { + if (bDwordVal) { + return &m_dwValue; + } + return &m_fValue; + } + return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); +} +FWL_ERR CFWL_FormTP::GetPartRect(CFWL_ThemePart* pThemePart, + CFX_RectF& rtPart) { + switch (pThemePart->m_iPart) { + case FWL_PART_FRM_CloseBox: { + CalCloseBox(pThemePart->m_pWidget, rtPart); + break; + } + case FWL_PART_FRM_MaximizeBox: { + CalMaxBox(pThemePart->m_pWidget, rtPart); + break; + } + case FWL_PART_FRM_MinimizeBox: { + CalMinBox(pThemePart->m_pWidget, rtPart); + break; + } + case FWL_PART_FRM_HeadText: { + CalCaption(pThemePart->m_pWidget, rtPart); + break; + } + case FWL_PART_FRM_Icon: { + CalIcon(pThemePart->m_pWidget, rtPart); + break; + } + default: {} + } + return FWL_ERR_Succeeded; +} +void CFWL_FormTP::CalCloseBox(IFWL_Widget* pWidget, CFX_RectF& rect) { + uint32_t dwStyles = pWidget->GetStyles(); + CFX_RectF rtWidget; + pWidget->GetWidgetRect(rtWidget); + rtWidget.Offset(-rtWidget.left, -rtWidget.top); + if (dwStyles & FWL_WGTSTYLE_CloseBox) { + rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Span, + rtWidget.top + FWLTHEME_FORMBTN_Margin, FWLTHEME_FORMBTN_Size, + FWLTHEME_FORMBTN_Size); + } else { + rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Span, + rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0); + } +} +void CFWL_FormTP::CalMaxBox(IFWL_Widget* pWidget, CFX_RectF& rect) { + uint32_t dwStyles = pWidget->GetStyles(); + CFX_RectF rtWidget; + pWidget->GetWidgetRect(rtWidget); + rtWidget.Offset(-rtWidget.left, -rtWidget.top); + if (dwStyles & FWL_WGTSTYLE_MaximizeBox) { + rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Size + + FWLTHEME_FORMBTN_Span * 2, + rtWidget.top + FWLTHEME_FORMBTN_Margin, FWLTHEME_FORMBTN_Size, + FWLTHEME_FORMBTN_Size); + } else { + rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Size + + FWLTHEME_FORMBTN_Span * 2, + rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0); + } +} +void CFWL_FormTP::CalMinBox(IFWL_Widget* pWidget, CFX_RectF& rect) { + uint32_t dwStyles = pWidget->GetStyles(); + CFX_RectF rtWidget; + pWidget->GetWidgetRect(rtWidget); + rtWidget.Offset(-rtWidget.left, -rtWidget.top); + if (dwStyles & FWL_WGTSTYLE_MinimizeBox) { + rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + + FWLTHEME_FORMBTN_Size * 2 + FWLTHEME_FORMBTN_Span * 3, + rtWidget.top + FWLTHEME_FORMBTN_Margin, FWLTHEME_FORMBTN_Size, + FWLTHEME_FORMBTN_Size); + } else { + rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + + FWLTHEME_FORMBTN_Size * 2 + FWLTHEME_FORMBTN_Span * 3, + rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0); + } +} +void CFWL_FormTP::CalCaption(IFWL_Widget* pWidget, CFX_RectF& rect) { + CFX_RectF rtWidget; + pWidget->GetWidgetRect(rtWidget); + rtWidget.Offset(-rtWidget.left, -rtWidget.top); + rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin, + rtWidget.top + FWLTHEME_FORMBTN_Margin - 2, + rtWidget.width - FWLTHEME_FORMBTN_Margin * 2, + FWLTHEME_FORMBTN_Size + 2 * FWLTHEME_FORMBTN_Margin + 4); +} +void CFWL_FormTP::CalIcon(IFWL_Widget* pWidget, CFX_RectF& rect) {} +void CFWL_FormTP::DrawFormBorder(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive) { + CFX_RectF rt; + rt.Set(pRect->left, pRect->top, 1, pRect->height); + FX_FLOAT fBottom, fRight; + fBottom = pRect->bottom(); + fRight = pRect->right(); + CFX_Path path; + path.Create(); + CFX_Color clrLine; + path.Clear(); + path.MoveTo(pRect->left, pRect->top); + path.LineTo(pRect->left, fBottom - 1); + path.LineTo(fRight - 1, fBottom - 1); + path.LineTo(fRight - 1, pRect->top); + clrLine = m_pThemeData->clrFormBorder[iActive][2]; + pGraphics->SetStrokeColor(&clrLine); + pGraphics->StrokePath(&path, pMatrix); + path.Clear(); + path.MoveTo(pRect->left + 1, pRect->top); + path.LineTo(pRect->left + 1, fBottom - 2); + path.LineTo(fRight - 2, fBottom - 2); + path.LineTo(fRight - 2, pRect->top); + clrLine = m_pThemeData->clrFormBorder[iActive][1]; + pGraphics->SetStrokeColor(&clrLine); + pGraphics->StrokePath(&path, pMatrix); + path.Clear(); + path.MoveTo(pRect->left + 2, pRect->top); + path.LineTo(pRect->left + 2, fBottom - 3); + path.LineTo(fRight - 3, fBottom - 3); + path.LineTo(fRight - 3, pRect->top); + clrLine = m_pThemeData->clrFormBorder[iActive][0]; + pGraphics->SetStrokeColor(&clrLine); + pGraphics->StrokePath(&path, pMatrix); + path.Clear(); + path.MoveTo(pRect->left + 3, pRect->top); + path.LineTo(pRect->left + 3, fBottom - 4); + path.LineTo(fRight - 4, fBottom - 4); + path.LineTo(fRight - 4, pRect->top); + clrLine = m_pThemeData->clrFormBorder[iActive][4]; + pGraphics->SetStrokeColor(&clrLine); + pGraphics->StrokePath(&path, pMatrix); + m_rtDisLBorder.Set(pRect->left, pRect->top + 29, 4, pRect->height - 29); + m_rtDisRBorder.Set(pRect->right() - 4, pRect->top + 29, 4, + pRect->height - 29); + m_rtDisBBorder.Set(pRect->left, pRect->bottom() - 4, pRect->width, 4); + m_rtDisCaption.Set(pRect->left, pRect->top, pRect->width, 29); +} +void CFWL_FormTP::DrawCaption(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive) { + CFX_RectF rt; + FX_FLOAT fBottom, fRight; + fBottom = pRect->bottom(); + fRight = pRect->right(); + rt.Set(pRect->left, pRect->top, pRect->width, 1); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][0], &rt, + pMatrix); + rt.Offset(0, 1); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][1], &rt, + pMatrix); + rt.Offset(0, 1); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][2], &rt, + pMatrix); + rt.Set(pRect->left, pRect->bottom() - 1, pRect->width, 1); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeBottom[iActive][2], &rt, + pMatrix); + rt.Offset(0, -1); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeBottom[iActive][1], &rt, + pMatrix); + rt.Set(pRect->left, pRect->top, 1, pRect->height); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][2], &rt, + pMatrix); + rt.Set(pRect->left + 1, pRect->top + 1, 1, fBottom - 1); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][1], &rt, + pMatrix); + rt.Set(pRect->left + 2, pRect->top + 2, 1, fBottom - 2); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][0], &rt, + pMatrix); + rt.Set(fRight - 1, pRect->top, pRect->width, pRect->height); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][2], &rt, + pMatrix); + rt.Set(fRight - 2, pRect->top + 1, 1, fBottom - 1); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][1], &rt, + pMatrix); + rt.Set(fRight - 3, pRect->top + 2, 1, fBottom - 2); + FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][0], &rt, + pMatrix); + CFX_RectF rect(*pRect); + rect.Set(rect.left + 3, rect.top + 3, rect.width - 6, rect.height - 5); + if (iActive == 0) { + pGraphics->StretchImage(m_pActiveBitmap, rect, pMatrix); + } else { + pGraphics->StretchImage(m_pDeactivebitmap, rect, pMatrix); + } +} +void CFWL_FormTP::DrawNarrowCaption(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive) {} +void CFWL_FormTP::DrawCloseBox(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive) { + FX_FLOAT fRight = pRect->right(); + FX_FLOAT fBottom = pRect->bottom(); + FX_FLOAT fWidth = pRect->width; + FX_FLOAT fHeight = pRect->height; + pGraphics->SaveGraphState(); + CFX_RectF rt(*pRect); + pGraphics->SetLineWidth(1.0f); + CFX_Path path; + path.Create(); + path.AddRectangle(rt.left + 1, rt.top, fWidth - 2, 1); + path.AddRectangle(rt.left, rt.top + 1, 1, fHeight - 2); + path.AddRectangle(fRight - 1, rt.top + 1, 1, fHeight - 2); + path.AddRectangle(rt.left + 1, fBottom - 1, fWidth - 2, 1); + CFX_Color crFill; + crFill = m_pThemeData->clrBtnEdgeOut[iActive]; + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + path.Clear(); + path.AddRectangle(rt.left + 1, rt.top + 1, 1, 1); + path.AddRectangle(fRight - 2, rt.top + 1, 1, 1); + path.AddRectangle(rt.left + 1, fBottom - 2, 1, 1); + path.AddRectangle(fRight - 2, fBottom - 2, 1, 1); + crFill = m_pThemeData->clrBtnCornerLight[iActive][eState - 1]; + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + path.Clear(); + path.AddRectangle(rt.left + 2, rt.top + 1, fWidth - 4, 1); + path.AddRectangle(rt.left + 1, rt.top + 2, 1, fHeight - 4); + crFill = m_pThemeData->clrCloseBtEdgeLight[iActive][eState - 1]; + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + path.Clear(); + path.AddRectangle(fRight - 2, rt.top + 2, 1, fHeight - 4); + path.AddRectangle(rt.left + 2, fBottom - 2, fWidth - 4, 1); + crFill = m_pThemeData->clrCloseBtEdgeDark[iActive][eState - 1]; + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + path.Clear(); + path.AddRectangle(pRect->left + 2, pRect->top + 2, fWidth - 4, fHeight - 4); + DrawAxialShading(pGraphics, pRect->left + 2, pRect->top + 2, fRight - 2, + fBottom - 2, + m_pThemeData->clrCloseBtBKStart[iActive][eState - 1], + m_pThemeData->clrCloseBtBKEnd[iActive][eState - 1], &path, + FXFILL_WINDING, pMatrix); + CFX_RectF rtX(*pRect); + rtX.Inflate(-5, -5); + path.Clear(); + FX_FLOAT frtXRight = rtX.right(); + FX_FLOAT frtXBottom = rtX.bottom(); + path.AddLine(rtX.left, rtX.top + 1, frtXRight - 1, frtXBottom); + path.AddLine(rtX.left, rtX.top, frtXRight, frtXBottom); + path.AddLine(rtX.left + 1, rtX.top, frtXRight, frtXBottom - 1); + path.AddLine(rtX.left, frtXBottom - 1, frtXRight - 1, rtX.top); + path.AddLine(rtX.left, frtXBottom, frtXRight, rtX.top); + path.AddLine(rtX.left + 1, frtXBottom, frtXRight, rtX.top + 1); + CFX_Color clrLine(0xffffffff); + pGraphics->SetLineWidth(1.0f); + pGraphics->SetStrokeColor(&clrLine); + pGraphics->StrokePath(&path, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_FormTP::DrawMinMaxBoxCommon(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive) { + pGraphics->SaveGraphState(); + FX_FLOAT fRight = pRect->right(); + FX_FLOAT fBottom = pRect->bottom(); + FX_FLOAT fWidth = pRect->width; + FX_FLOAT fHeight = pRect->height; + CFX_RectF rt(*pRect); + pGraphics->SetLineWidth(1.0f); + CFX_Path path; + path.Create(); + path.AddRectangle(rt.left + 1, rt.top, fWidth - 2, 1); + path.AddRectangle(rt.left, rt.top + 1, 1, fHeight - 2); + path.AddRectangle(fRight - 1, rt.top + 1, 1, fHeight - 2); + path.AddRectangle(rt.left + 1, fBottom - 1, fWidth - 2, 1); + CFX_Color crFill; + crFill = m_pThemeData->clrBtnEdgeOut[iActive]; + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + path.Clear(); + path.AddRectangle(rt.left + 1, rt.top + 1, 1, 1); + path.AddRectangle(fRight - 2, rt.top + 1, 1, 1); + path.AddRectangle(rt.left + 1, fBottom - 2, 1, 1); + path.AddRectangle(fRight - 2, fBottom - 2, 1, 1); + crFill = m_pThemeData->clrBtnCornerLight[iActive][eState - 1]; + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + path.Clear(); + path.AddRectangle(rt.left + 2, rt.top + 1, fWidth - 4, 1); + path.AddRectangle(rt.left + 1, rt.top + 2, 1, fHeight - 4); + crFill = m_pThemeData->clrNormalBtEdgeLight[iActive][eState - 1]; + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + path.Clear(); + path.AddRectangle(fRight - 2, rt.top + 2, 1, fHeight - 4); + path.AddRectangle(rt.left + 2, fBottom - 2, fWidth - 4, 1); + crFill = m_pThemeData->clrNormalBtEdgeDark[iActive][eState - 1]; + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pGraphics->RestoreGraphState(); + path.Clear(); + path.AddRectangle(pRect->left + 2, pRect->top + 2, fWidth - 4, fHeight - 4); + DrawAxialShading(pGraphics, pRect->left + 2, pRect->top + 2, fRight - 2, + fBottom - 2, + m_pThemeData->clrNormalBtBKStart[iActive][eState - 1], + m_pThemeData->clrNormalBtBKEnd[iActive][eState - 1], &path, + FXFILL_WINDING, pMatrix); +} +void CFWL_FormTP::DrawMinimizeBox(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive) { + DrawMinMaxBoxCommon(pGraphics, pRect, eState, pMatrix); + CFX_RectF rtMin; + rtMin.Set(pRect->left + 5, pRect->top + 13, pRect->width - 14, + pRect->height - 18); + FillSoildRect(pGraphics, 0xFFFFFFFF, &rtMin, pMatrix); +} +void CFWL_FormTP::DrawMaximizeBox(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + FX_BOOL bMax, + CFX_Matrix* pMatrix, + int32_t iActive) { + DrawMinMaxBoxCommon(pGraphics, pRect, eState, pMatrix); + FX_FLOAT fWidth = pRect->width; + FX_FLOAT fHeight = pRect->height; + if (bMax) { + CFX_Path path; + path.Create(); + path.AddLine(pRect->left + 7, pRect->top + 6, pRect->left + 14, + pRect->top + 6); + path.AddLine(pRect->left + 4, pRect->top + 9, pRect->left + 11, + pRect->top + 9); + pGraphics->SaveGraphState(); + pGraphics->SetLineWidth(2); + CFX_Color crStroke(0xFFFFFFFF); + pGraphics->SetStrokeColor(&crStroke); + pGraphics->StrokePath(&path, pMatrix); + pGraphics->SetLineWidth(1); + path.Clear(); + path.AddLine(pRect->left + 4, pRect->top + 10, pRect->left + 4, + pRect->top + 14); + path.AddLine(pRect->left + 10, pRect->top + 10, pRect->left + 10, + pRect->top + 14); + path.AddLine(pRect->left + 13, pRect->top + 7, pRect->left + 13, + pRect->top + 11); + path.AddLine(pRect->left + 4, pRect->top + 14, pRect->left + 10, + pRect->top + 14); + path.AddLine(pRect->left + 12, pRect->top + 11, pRect->left + 12, + pRect->top + 11); + pGraphics->StrokePath(&path, pMatrix); + pGraphics->RestoreGraphState(); + } else { + CFX_RectF rtMax(*pRect); + rtMax.Inflate(-5, -5); + CFX_Path path; + path.Create(); + path.AddRectangle(pRect->left + 5, pRect->top + 5, fWidth - 10, + fHeight - 10); + path.AddRectangle(pRect->left + 6, pRect->top + 8, fWidth - 12, + fHeight - 14); + pGraphics->SaveGraphState(); + CFX_Color crFill(0xFFFFFFFF); + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix); + pGraphics->RestoreGraphState(); + } +} +void CFWL_FormTP::DrawIconImage(CFX_Graphics* pGraphics, + CFX_DIBitmap* pDIBitmap, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive) { + pGraphics->StretchImage(pDIBitmap, *pRect, pMatrix); +} +void CFWL_FormTP::SetThemeData(uint32_t dwID) { + m_pThemeData->clrTransWhite = ArgbEncode(0x65, 255, 255, 255); + m_pThemeData->clrCloseBtBKStart[0][0] = ArgbEncode(0xff, 240, 166, 148); + m_pThemeData->clrCloseBtBKEnd[0][0] = ArgbEncode(0xff, 228, 61, 5); + m_pThemeData->clrCloseBtBKStart[0][1] = ArgbEncode(0xff, 255, 184, 176); + m_pThemeData->clrCloseBtBKEnd[0][1] = ArgbEncode(0xff, 252, 107, 71); + m_pThemeData->clrCloseBtBKStart[0][2] = ArgbEncode(0xff, 141, 44, 20); + m_pThemeData->clrCloseBtBKEnd[0][2] = ArgbEncode(0xff, 202, 72, 33); + m_pThemeData->clrCloseBtEdgeLight[0][0] = ArgbEncode(0xff, 255, 122, 107); + m_pThemeData->clrCloseBtEdgeDark[0][0] = ArgbEncode(0xff, 218, 77, 54); + m_pThemeData->clrCloseBtEdgeLight[0][1] = ArgbEncode(0xff, 255, 93, 74); + m_pThemeData->clrCloseBtEdgeDark[0][1] = ArgbEncode(0xff, 218, 74, 51); + m_pThemeData->clrCloseBtEdgeLight[0][2] = ArgbEncode(0xff, 191, 61, 28); + m_pThemeData->clrCloseBtEdgeDark[0][2] = ArgbEncode(0xff, 93, 30, 13); + if (dwID) { + m_pThemeData->clrHeadBK[0][0] = ArgbEncode(0xff, 194, 205, 149); + m_pThemeData->clrHeadBK[0][1] = ArgbEncode(0xff, 170, 184, 131); + m_pThemeData->clrHeadBK[0][2] = ArgbEncode(0xff, 168, 182, 128); + m_pThemeData->clrHeadBK[0][3] = ArgbEncode(0xff, 194, 205, 149); + m_pThemeData->clrHeadEdgeLeft[0][0] = ArgbEncode(0xff, 117, 141, 94); + m_pThemeData->clrHeadEdgeLeft[0][1] = ArgbEncode(0xff, 139, 161, 105); + m_pThemeData->clrHeadEdgeLeft[0][2] = ArgbEncode(0xff, 171, 189, 133); + m_pThemeData->clrHeadEdgeRight[0][0] = ArgbEncode(0xff, 155, 175, 125); + m_pThemeData->clrHeadEdgeRight[0][1] = ArgbEncode(0xff, 128, 146, 103); + m_pThemeData->clrHeadEdgeRight[0][2] = ArgbEncode(0xff, 94, 118, 79); + m_pThemeData->clrHeadEdgeTop[0][0] = ArgbEncode(0xff, 139, 161, 105); + m_pThemeData->clrHeadEdgeTop[0][1] = ArgbEncode(0xff, 234, 245, 201); + m_pThemeData->clrHeadEdgeTop[0][2] = ArgbEncode(0xff, 194, 205, 149); + m_pThemeData->clrHeadEdgeBottom[0][0] = ArgbEncode(0xff, 175, 189, 133); + m_pThemeData->clrHeadEdgeBottom[0][1] = ArgbEncode(0xff, 153, 168, 121); + m_pThemeData->clrHeadEdgeBottom[0][2] = ArgbEncode(0xff, 150, 168, 103); + m_pThemeData->clrNormalBtBKStart[0][0] = ArgbEncode(0xff, 182, 195, 162); + m_pThemeData->clrNormalBtBKEnd[0][0] = ArgbEncode(0xff, 128, 144, 84); + m_pThemeData->clrNormalBtBKStart[0][1] = ArgbEncode(0xff, 234, 241, 208); + m_pThemeData->clrNormalBtBKEnd[0][1] = ArgbEncode(0xff, 169, 186, 112); + m_pThemeData->clrNormalBtBKStart[0][2] = ArgbEncode(0xff, 199, 199, 190); + m_pThemeData->clrNormalBtBKEnd[0][2] = ArgbEncode(0xff, 133, 148, 88); + m_pThemeData->clrNormalBtEdgeLight[0][0] = ArgbEncode(0xff, 163, 176, 137); + m_pThemeData->clrNormalBtEdgeDark[0][0] = ArgbEncode(0xff, 118, 135, 83); + m_pThemeData->clrNormalBtEdgeLight[0][1] = ArgbEncode(0xff, 154, 174, 105); + m_pThemeData->clrNormalBtEdgeDark[0][1] = ArgbEncode(0xff, 154, 174, 105); + m_pThemeData->clrNormalBtEdgeLight[0][2] = ArgbEncode(0xff, 172, 193, 123); + m_pThemeData->clrNormalBtEdgeDark[0][2] = ArgbEncode(0xff, 154, 174, 105); + m_pThemeData->clrBtnCornerLight[0][0] = ArgbEncode(0xff, 220, 220, 220); + m_pThemeData->clrBtnCornerLight[0][1] = ArgbEncode(0xff, 255, 255, 255); + m_pThemeData->clrBtnCornerLight[0][2] = ArgbEncode(0xff, 225, 225, 225); + m_pThemeData->clrBtnEdgeOut[0] = ArgbEncode(0xff, 255, 255, 255); + m_pThemeData->clrFormBorder[0][0] = ArgbEncode(0xff, 117, 141, 94); + m_pThemeData->clrFormBorder[0][1] = ArgbEncode(0xff, 139, 161, 105); + m_pThemeData->clrFormBorder[0][2] = ArgbEncode(0xff, 171, 189, 133); + m_pThemeData->clrFormBorder[0][3] = ArgbEncode(0xff, 164, 178, 127); + m_pThemeData->clrFormBorder[0][4] = ArgbEncode(0xff, 255, 255, 255); + m_pThemeData->clrFormBorderLight[0] = ArgbEncode(0xff, 171, 189, 133); + } else { + m_pThemeData->clrHeadBK[0][0] = ArgbEncode(0xff, 3, 114, 255); + m_pThemeData->clrHeadBK[0][1] = ArgbEncode(0xff, 0, 85, 226); + m_pThemeData->clrHeadBK[0][2] = ArgbEncode(0xff, 0, 85, 226); + m_pThemeData->clrHeadBK[0][3] = ArgbEncode(0xff, 3, 114, 255); + m_pThemeData->clrHeadEdgeLeft[0][2] = ArgbEncode(0xff, 0, 32, 200); + m_pThemeData->clrHeadEdgeLeft[0][1] = ArgbEncode(0xff, 0, 61, 220); + m_pThemeData->clrHeadEdgeLeft[0][0] = ArgbEncode(0xff, 0, 54, 210); + m_pThemeData->clrHeadEdgeRight[0][0] = ArgbEncode(0xff, 0, 56, 234); + m_pThemeData->clrHeadEdgeRight[0][1] = ArgbEncode(0xff, 0, 50, 193); + m_pThemeData->clrHeadEdgeRight[0][2] = ArgbEncode(0xff, 0, 19, 139); + m_pThemeData->clrHeadEdgeTop[0][0] = ArgbEncode(0xff, 0, 88, 238); + m_pThemeData->clrHeadEdgeTop[0][1] = ArgbEncode(0xff, 63, 151, 255); + m_pThemeData->clrHeadEdgeTop[0][2] = ArgbEncode(0xff, 3, 114, 255); + m_pThemeData->clrHeadEdgeBottom[0][0] = ArgbEncode(0xff, 0, 96, 252); + m_pThemeData->clrHeadEdgeBottom[0][1] = ArgbEncode(0xff, 63, 151, 255); + m_pThemeData->clrHeadEdgeBottom[0][2] = ArgbEncode(0xff, 0, 67, 207); + m_pThemeData->clrNormalBtBKStart[0][2] = ArgbEncode(0xff, 0, 49, 112); + m_pThemeData->clrNormalBtBKEnd[0][2] = ArgbEncode(0xff, 0, 87, 188); + m_pThemeData->clrNormalBtBKStart[0][0] = ArgbEncode(0xff, 154, 183, 250); + m_pThemeData->clrNormalBtBKEnd[0][0] = ArgbEncode(0xff, 17, 110, 248); + m_pThemeData->clrNormalBtBKStart[0][1] = ArgbEncode(0xff, 164, 194, 255); + m_pThemeData->clrNormalBtBKEnd[0][1] = ArgbEncode(0xff, 29, 158, 255); + m_pThemeData->clrNormalBtEdgeLight[0][0] = ArgbEncode(0xff, 68, 120, 245); + m_pThemeData->clrNormalBtEdgeDark[0][0] = ArgbEncode(0xff, 24, 72, 187); + m_pThemeData->clrNormalBtEdgeLight[0][1] = ArgbEncode(0xff, 72, 122, 245); + m_pThemeData->clrNormalBtEdgeDark[0][1] = ArgbEncode(0xff, 35, 87, 195); + m_pThemeData->clrNormalBtEdgeLight[0][2] = ArgbEncode(0xff, 60, 114, 244); + m_pThemeData->clrNormalBtEdgeDark[0][2] = ArgbEncode(0xff, 21, 70, 185); + m_pThemeData->clrBtnCornerLight[0][0] = ArgbEncode(0xff, 220, 220, 220); + m_pThemeData->clrBtnCornerLight[0][1] = ArgbEncode(0xff, 255, 255, 255); + m_pThemeData->clrBtnCornerLight[0][2] = ArgbEncode(0xff, 225, 225, 225); + m_pThemeData->clrBtnEdgeOut[0] = ArgbEncode(0xff, 255, 255, 255); + m_pThemeData->clrFormBorder[0][0] = ArgbEncode(0xff, 0, 72, 241); + m_pThemeData->clrFormBorder[0][1] = ArgbEncode(0xff, 0, 61, 220); + m_pThemeData->clrFormBorder[0][2] = ArgbEncode(0xff, 0, 30, 160); + m_pThemeData->clrFormBorder[0][3] = ArgbEncode(0xff, 0, 19, 140); + m_pThemeData->clrFormBorder[0][4] = ArgbEncode(0xff, 255, 255, 255); + m_pThemeData->clrFormBorderLight[0] = ArgbEncode(0xff, 22, 106, 239); + } + m_pThemeData->clrCloseBtBKStart[1][0] = m_pThemeData->clrCloseBtBKStart[0][0]; + m_pThemeData->clrCloseBtBKEnd[1][0] = m_pThemeData->clrCloseBtBKEnd[0][0]; + m_pThemeData->clrCloseBtBKStart[1][1] = m_pThemeData->clrCloseBtBKStart[0][1]; + m_pThemeData->clrCloseBtBKEnd[1][1] = m_pThemeData->clrCloseBtBKEnd[0][1]; + m_pThemeData->clrCloseBtBKStart[1][2] = m_pThemeData->clrCloseBtBKStart[0][2]; + m_pThemeData->clrCloseBtBKEnd[1][2] = m_pThemeData->clrCloseBtBKEnd[0][2]; + m_pThemeData->clrCloseBtEdgeLight[1][0] = + m_pThemeData->clrCloseBtEdgeLight[0][0]; + m_pThemeData->clrCloseBtEdgeDark[1][0] = + m_pThemeData->clrCloseBtEdgeDark[0][0]; + m_pThemeData->clrCloseBtEdgeLight[1][1] = + m_pThemeData->clrCloseBtEdgeLight[0][1]; + m_pThemeData->clrCloseBtEdgeDark[1][1] = + m_pThemeData->clrCloseBtEdgeDark[0][1]; + m_pThemeData->clrCloseBtEdgeLight[1][2] = + m_pThemeData->clrCloseBtEdgeLight[0][2]; + m_pThemeData->clrCloseBtEdgeDark[1][2] = + m_pThemeData->clrCloseBtEdgeDark[0][2]; + m_pThemeData->clrHeadBK[1][0] = m_pThemeData->clrHeadBK[0][0]; + m_pThemeData->clrHeadBK[1][1] = m_pThemeData->clrHeadBK[0][1]; + m_pThemeData->clrHeadBK[1][2] = m_pThemeData->clrHeadBK[0][2]; + m_pThemeData->clrHeadBK[1][3] = m_pThemeData->clrHeadBK[0][3]; + m_pThemeData->clrHeadEdgeLeft[1][2] = m_pThemeData->clrHeadEdgeLeft[0][2]; + m_pThemeData->clrHeadEdgeLeft[1][1] = m_pThemeData->clrHeadEdgeLeft[0][1]; + m_pThemeData->clrHeadEdgeLeft[1][0] = m_pThemeData->clrHeadEdgeLeft[0][0]; + m_pThemeData->clrHeadEdgeRight[1][0] = m_pThemeData->clrHeadEdgeRight[0][0]; + m_pThemeData->clrHeadEdgeRight[1][1] = m_pThemeData->clrHeadEdgeRight[0][1]; + m_pThemeData->clrHeadEdgeRight[1][2] = m_pThemeData->clrHeadEdgeRight[0][2]; + m_pThemeData->clrHeadEdgeTop[1][0] = m_pThemeData->clrHeadEdgeTop[0][0]; + m_pThemeData->clrHeadEdgeTop[1][1] = m_pThemeData->clrHeadEdgeTop[0][1]; + m_pThemeData->clrHeadEdgeTop[1][2] = m_pThemeData->clrHeadEdgeTop[0][2]; + m_pThemeData->clrHeadEdgeBottom[1][0] = m_pThemeData->clrHeadEdgeBottom[0][0]; + m_pThemeData->clrHeadEdgeBottom[1][1] = m_pThemeData->clrHeadEdgeBottom[0][1]; + m_pThemeData->clrHeadEdgeBottom[1][2] = m_pThemeData->clrHeadEdgeBottom[0][2]; + m_pThemeData->clrNormalBtBKStart[1][2] = + m_pThemeData->clrNormalBtBKStart[0][2]; + m_pThemeData->clrNormalBtBKEnd[1][2] = m_pThemeData->clrNormalBtBKEnd[0][2]; + m_pThemeData->clrNormalBtBKStart[1][0] = + m_pThemeData->clrNormalBtBKStart[0][0]; + m_pThemeData->clrNormalBtBKEnd[1][0] = m_pThemeData->clrNormalBtBKEnd[1][0]; + m_pThemeData->clrNormalBtBKStart[1][1] = + m_pThemeData->clrNormalBtBKStart[0][1]; + m_pThemeData->clrNormalBtBKEnd[1][1] = m_pThemeData->clrNormalBtBKEnd[0][1]; + m_pThemeData->clrNormalBtEdgeLight[1][0] = + m_pThemeData->clrNormalBtEdgeLight[0][0]; + m_pThemeData->clrNormalBtEdgeDark[1][0] = + m_pThemeData->clrNormalBtEdgeDark[0][0]; + m_pThemeData->clrNormalBtEdgeLight[1][1] = + m_pThemeData->clrNormalBtEdgeLight[0][1]; + m_pThemeData->clrNormalBtEdgeDark[1][1] = + m_pThemeData->clrNormalBtEdgeDark[0][1]; + m_pThemeData->clrNormalBtEdgeLight[1][2] = + m_pThemeData->clrNormalBtEdgeLight[0][2]; + m_pThemeData->clrNormalBtEdgeDark[1][2] = + m_pThemeData->clrNormalBtEdgeDark[0][2]; + m_pThemeData->clrBtnCornerLight[1][0] = m_pThemeData->clrBtnCornerLight[0][0]; + m_pThemeData->clrBtnCornerLight[1][1] = m_pThemeData->clrBtnCornerLight[0][1]; + m_pThemeData->clrBtnCornerLight[1][2] = m_pThemeData->clrBtnCornerLight[0][2]; + m_pThemeData->clrBtnEdgeOut[1] = m_pThemeData->clrBtnEdgeOut[0]; + m_pThemeData->clrFormBorder[1][0] = m_pThemeData->clrFormBorder[0][0]; + m_pThemeData->clrFormBorder[1][1] = m_pThemeData->clrFormBorder[0][1]; + m_pThemeData->clrFormBorder[1][2] = m_pThemeData->clrFormBorder[0][2]; + m_pThemeData->clrFormBorder[1][3] = m_pThemeData->clrFormBorder[0][3]; + m_pThemeData->clrFormBorder[1][4] = m_pThemeData->clrFormBorder[0][4]; + m_pThemeData->clrFormBorderLight[1] = m_pThemeData->clrFormBorderLight[0]; + DeactiveForm(); +} +void CFWL_FormTP::DeactiveForm() { + TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][3]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeLeft[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeLeft[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeLeft[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeRight[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeRight[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeRight[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeTop[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeTop[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeTop[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeBottom[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeBottom[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrHeadEdgeBottom[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtBKStart[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtBKStart[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtBKStart[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtBKEnd[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtBKEnd[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtBKEnd[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtEdgeLight[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtEdgeLight[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtEdgeLight[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtEdgeDark[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtEdgeDark[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrNormalBtEdgeDark[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrBtnCornerLight[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrBtnCornerLight[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrBtnCornerLight[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrBtnEdgeOut[1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrFormBorder[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrFormBorder[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrFormBorder[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrFormBorder[1][3]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrFormBorder[1][4]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrFormBorderLight[1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtBKStart[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtBKStart[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtBKStart[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtBKEnd[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtBKEnd[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtBKEnd[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtEdgeLight[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtEdgeLight[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtEdgeLight[1][2]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtEdgeDark[1][0]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtEdgeDark[1][1]); + TransModeColor(m_pThemeData->clrTransWhite, + m_pThemeData->clrCloseBtEdgeDark[1][2]); +} +void CFWL_FormTP::TransModeColor(FX_ARGB clrFore, FX_ARGB& clrBack) { + int32_t iAlfaF, iRF, iGF, iBF; + int32_t iAlfaB, iRB, iGB, iBB; + ArgbDecode(clrFore, iAlfaF, iRF, iGF, iBF); + ArgbDecode(clrBack, iAlfaB, iRB, iGB, iBB); + clrBack = ArgbEncode(0xff, iRB + (iRF - iRB) * iAlfaF / 255, + iGB + (iGF - iGB) * iAlfaF / 255, + iBB + (iBF - iBB) * iAlfaF / 255); +} +void CFWL_FormTP::InitCaption(FX_BOOL bActive) { + if (bActive) { + CFX_FxgeDevice dev; + CFX_Graphics gs; + CFX_Path path; + path.Create(); + if (m_pActiveBitmap) { + delete m_pActiveBitmap; + m_pActiveBitmap = NULL; + } + m_pActiveBitmap = new CFX_DIBitmap; + m_pActiveBitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb); + dev.Attach(m_pActiveBitmap); + gs.Create(&dev); + path.AddRectangle(0, 0, 1, 5); + DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[0][0], + m_pThemeData->clrHeadBK[0][1], &path); + path.Clear(); + path.AddRectangle(0, 5, 1, 15); + DrawAxialShading(&gs, 0, 5, 0, 20, m_pThemeData->clrHeadBK[0][1], + m_pThemeData->clrHeadBK[0][2], &path); + path.Clear(); + path.AddRectangle(0, 20, 1, FWLTHEME_CAPACITY_CYCaption - 19); + DrawAxialShading(&gs, 0, 20, 0, FWLTHEME_CAPACITY_CYCaption, + m_pThemeData->clrHeadBK[0][2], + m_pThemeData->clrHeadBK[0][3], &path); + } else { + CFX_FxgeDevice dev; + CFX_Graphics gs; + CFX_Path path; + path.Create(); + if (m_pDeactivebitmap) { + delete m_pDeactivebitmap; + m_pDeactivebitmap = NULL; + } + m_pDeactivebitmap = new CFX_DIBitmap; + m_pDeactivebitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb); + dev.Attach(m_pDeactivebitmap); + gs.Create(&dev); + path.AddRectangle(0, 0, 1, 5); + DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[1][0], + m_pThemeData->clrHeadBK[1][1], &path); + path.Clear(); + path.AddRectangle(0, 5, 1, 15); + DrawAxialShading(&gs, 0, 5, 0, 20, m_pThemeData->clrHeadBK[1][1], + m_pThemeData->clrHeadBK[1][2], &path); + path.Clear(); + path.AddRectangle(0, 20, 1, FWLTHEME_CAPACITY_CYCaption - 19); + DrawAxialShading(&gs, 0, 20, 0, FWLTHEME_CAPACITY_CYCaption, + m_pThemeData->clrHeadBK[1][2], + m_pThemeData->clrHeadBK[1][3], &path); + } +} diff --git a/xfa/fwl/theme/cfwl_formtp.h b/xfa/fwl/theme/cfwl_formtp.h new file mode 100644 index 0000000000..838f19858a --- /dev/null +++ b/xfa/fwl/theme/cfwl_formtp.h @@ -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 + +#ifndef XFA_FWL_THEME_CFWL_FORMTP_H_ +#define XFA_FWL_THEME_CFWL_FORMTP_H_ + +#include "xfa/fwl/theme/cfwl_utils.h" +#include "xfa/fwl/theme/cfwl_widgettp.h" + +class CFWL_FormTP : public CFWL_WidgetTP { + public: + CFWL_FormTP(); + virtual ~CFWL_FormTP(); + + virtual FWL_ERR Initialize(); + virtual FWL_ERR Finalize(); + virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); + virtual uint32_t SetThemeID(IFWL_Widget* pWidget, + uint32_t dwThemeID, + FX_BOOL bChildren = TRUE); + virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); + virtual FX_BOOL DrawText(CFWL_ThemeText* pParams); + virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity); + virtual FWL_ERR GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart); + + protected: + void CalCloseBox(IFWL_Widget* pWidget, CFX_RectF& rect); + void CalMaxBox(IFWL_Widget* pWidget, CFX_RectF& rect); + void CalMinBox(IFWL_Widget* pWidget, CFX_RectF& rect); + void CalCaption(IFWL_Widget* pWidget, CFX_RectF& rect); + void CalIcon(IFWL_Widget* pWidget, CFX_RectF& rect); + + void DrawFormBorder(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive = 0); + void DrawCaption(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive = 0); + void DrawNarrowCaption(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive = 0); + void DrawCloseBox(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive = 0); + void DrawMinMaxBoxCommon(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive = 0); + void DrawMinimizeBox(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive = 0); + void DrawMaximizeBox(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + FX_BOOL bMax, + CFX_Matrix* pMatrix, + int32_t iActive = 0); + void DrawIconImage(CFX_Graphics* pGraphics, + CFX_DIBitmap* pDIBitmap, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix, + int32_t iActive = 0); + void SetThemeData(uint32_t dwID); + void TransModeColor(FX_ARGB clrFore, FX_ARGB& clrBack); + void DeactiveForm(); + void InitCaption(FX_BOOL bActive); + CFX_DIBitmap* m_pActiveBitmap; + CFX_DIBitmap* m_pDeactivebitmap; + CFX_RectF m_rtDisCaption; + CFX_RectF m_rtDisLBorder; + CFX_RectF m_rtDisRBorder; + CFX_RectF m_rtDisBBorder; + struct SBThemeData { + FX_ARGB clrHeadBK[2][4]; + FX_ARGB clrHeadEdgeLeft[2][3]; + FX_ARGB clrHeadEdgeRight[2][3]; + FX_ARGB clrHeadEdgeTop[2][3]; + FX_ARGB clrHeadEdgeBottom[2][3]; + FX_ARGB clrCloseBtBKStart[2][3]; + FX_ARGB clrCloseBtBKEnd[2][3]; + FX_ARGB clrCloseBtEdgeLight[2][3]; + FX_ARGB clrCloseBtEdgeDark[2][3]; + FX_ARGB clrNormalBtBKStart[2][3]; + FX_ARGB clrNormalBtBKEnd[2][3]; + FX_ARGB clrNormalBtEdgeLight[2][3]; + FX_ARGB clrNormalBtEdgeDark[2][3]; + FX_ARGB clrBtnEdgeOut[2]; + FX_ARGB clrBtnCornerLight[2][3]; + FX_ARGB clrHeadText[2]; + FX_ARGB clrFormBorder[2][5]; + FX_ARGB clrFormBorderLight[2]; + FX_ARGB clrTransWhite; + } * m_pThemeData; +}; + +#endif // XFA_FWL_THEME_CFWL_FORMTP_H_ diff --git a/xfa/fwl/theme/cfwl_listboxtp.cpp b/xfa/fwl/theme/cfwl_listboxtp.cpp new file mode 100644 index 0000000000..210949aa41 --- /dev/null +++ b/xfa/fwl/theme/cfwl_listboxtp.cpp @@ -0,0 +1,104 @@ +// 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/theme/cfwl_listboxtp.h" + +#include "xfa/fwl/basewidget/ifwl_listbox.h" +#include "xfa/fwl/core/cfwl_themebackground.h" +#include "xfa/fwl/core/ifwl_widget.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" + +CFWL_ListBoxTP::CFWL_ListBoxTP() {} +CFWL_ListBoxTP::~CFWL_ListBoxTP() {} + +FX_BOOL CFWL_ListBoxTP::IsValidWidget(IFWL_Widget* pWidget) { + if (!pWidget) + return FALSE; + return pWidget->GetClassID() == FWL_CLASSHASH_ListBox; +} +FX_BOOL CFWL_ListBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { + if (!pParams) + return FALSE; + switch (pParams->m_iPart) { + case FWL_PART_LTB_Border: { + DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_LTB_Edge: { + DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), + &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_LTB_Background: { + FillSoildRect(pParams->m_pGraphics, ArgbEncode(255, 255, 255, 255), + &pParams->m_rtPart, &pParams->m_matrix); + if (pParams->m_pData) { + FillSoildRect(pParams->m_pGraphics, FWLTHEME_COLOR_Background, + (CFX_RectF*)pParams->m_pData, &pParams->m_matrix); + } + break; + } + case FWL_PART_LTB_ListItem: { + DrawListBoxItem(pParams->m_pGraphics, pParams->m_dwStates, + &pParams->m_rtPart, pParams->m_pData, &pParams->m_matrix); + break; + } + case FWL_PART_LTB_Icon: { + pParams->m_pGraphics->StretchImage(pParams->m_pImage, pParams->m_rtPart, + &pParams->m_matrix); + break; + } + case FWL_PART_LTB_Check: { + uint32_t color = 0xFF000000; + if (pParams->m_dwStates == FWL_PARTSTATE_LTB_Checked) { + color = 0xFFFF0000; + } else if (pParams->m_dwStates == FWL_PARTSTATE_LTB_UnChecked) { + color = 0xFF0000FF; + } + FillSoildRect(pParams->m_pGraphics, color, &pParams->m_rtPart, + &pParams->m_matrix); + } + default: {} + } + return TRUE; +} +FWL_ERR CFWL_ListBoxTP::Initialize() { + InitTTO(); + return CFWL_WidgetTP::Initialize(); +} +FWL_ERR CFWL_ListBoxTP::Finalize() { + FinalizeTTO(); + return CFWL_WidgetTP::Finalize(); +} +void CFWL_ListBoxTP::DrawListBoxItem(CFX_Graphics* pGraphics, + uint32_t dwStates, + const CFX_RectF* prtItem, + void* pData, + CFX_Matrix* pMatrix) { + if (dwStates & FWL_PARTSTATE_LTB_Selected) { + pGraphics->SaveGraphState(); + CFX_Color crFill(FWL_GetThemeColor(m_dwThemeID) == 0 + ? FWLTHEME_COLOR_BKSelected + : FWLTHEME_COLOR_Green_BKSelected); + pGraphics->SetFillColor(&crFill); + CFX_RectF rt(*prtItem); + CFX_Path path; + path.Create(); +#if (_FX_OS_ == _FX_MACOSX_) + path.AddRectangle(rt.left, rt.top, rt.width - 1, rt.height - 1); +#else + path.AddRectangle(rt.left, rt.top, rt.width, rt.height); +#endif + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pGraphics->RestoreGraphState(); + } + if (dwStates & FWL_PARTSTATE_LTB_Focused) { + if (pData) { + DrawFocus(pGraphics, (CFX_RectF*)pData, pMatrix); + } + } +} diff --git a/xfa/fwl/theme/cfwl_listboxtp.h b/xfa/fwl/theme/cfwl_listboxtp.h new file mode 100644 index 0000000000..d4bd7eff94 --- /dev/null +++ b/xfa/fwl/theme/cfwl_listboxtp.h @@ -0,0 +1,29 @@ +// 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_THEME_CFWL_LISTBOXTP_H_ +#define XFA_FWL_THEME_CFWL_LISTBOXTP_H_ + +#include "xfa/fwl/theme/cfwl_widgettp.h" + +class CFWL_ListBoxTP : public CFWL_WidgetTP { + public: + CFWL_ListBoxTP(); + virtual ~CFWL_ListBoxTP(); + virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); + virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); + virtual FWL_ERR Initialize(); + virtual FWL_ERR Finalize(); + + protected: + void DrawListBoxItem(CFX_Graphics* pGraphics, + uint32_t dwStates, + const CFX_RectF* prtItem, + void* pData = NULL, + CFX_Matrix* pMatrix = NULL); +}; + +#endif // XFA_FWL_THEME_CFWL_LISTBOXTP_H_ diff --git a/xfa/fwl/theme/cfwl_monthcalendartp.cpp b/xfa/fwl/theme/cfwl_monthcalendartp.cpp new file mode 100644 index 0000000000..2d53080b37 --- /dev/null +++ b/xfa/fwl/theme/cfwl_monthcalendartp.cpp @@ -0,0 +1,587 @@ +// 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/theme/cfwl_monthcalendartp.h" + +#include "xfa/fde/tto/fde_textout.h" +#include "xfa/fwl/basewidget/ifwl_monthcalendar.h" +#include "xfa/fwl/core/cfwl_themebackground.h" +#include "xfa/fwl/core/cfwl_themetext.h" +#include "xfa/fwl/core/ifwl_themeprovider.h" +#include "xfa/fwl/core/ifwl_widget.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" + +#define FWL_THEMECAPACITY_MC_HEADER_WIDTH 200 +#define FWL_THEMECAPACITY_MC_HEADER_HEIGHT 30 +#define FWL_THEMECAPACITY_MC_HEADER_BTN_WIDTH 18 +#define FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT 16 +#define FWL_THEMECAPACITY_MC_HEADER_BTN_HMARGIN 5 +#define FWL_THEMECAPACITY_MC_HEADER_BTN_VMARGIN \ + (FWL_THEMECAPACITY_MC_HEADER_HEIGHT - \ + FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT) / \ + 2 +#define FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT 100 +#define FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT 20 +#define FWL_THEMECAPACITY_MC_HEADER_TEXT_HMARGIN \ + (FWL_THEMECAPACITY_MC_HEADER_WIDTH - \ + FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT) / \ + 2 +#define FWL_THEMECAPACITY_MC_HEADER_TEXT_VMARGIN \ + (FWL_THEMECAPACITY_MC_HEADER_HEIGHT - \ + FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT) / \ + 2 +#define FWL_THEMECAPACITY_MC_HSEP_WIDTH (FWL_THEMECAPACITY_MC_WEEK_WIDTH - 10) +#define FWL_THEMECAPACITY_MC_HSEP_HEIGHT 1 +#define FWL_THEMECAPACITY_MC_VSEP_WIDTH 1 +#define FWL_THEMECAPACITY_MC_VSEP_HEIGHT FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT +#define FWL_THEMECAPACITY_MC_WEEKNUM_WIDTH 26 +#define FWL_THEMECAPACITY_MC_SEP_DOFFSET -4 +#define FWL_THEMECAPACITY_MC_SEP_X 3 +#define FWL_THEMECAPACITY_MC_SEP_Y \ + (FWL_THEMECAPACITY_MC_HEADER_HEIGHT + FWL_THEMECAPACITY_MC_WEEK_HEIGHT + \ + FWL_THEMECAPACITY_MC_SEP_DOFFSET) +#define FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT \ + (6 * FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT) +#define FWL_THEMECAPACITY_MC_WEEK_WIDTH \ + (FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH * 7) +#define FWL_THEMECAPACITY_MC_WEEK_HEIGHT FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT +#define FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH \ + (FWL_THEMECAPACITY_MC_HEADER_WIDTH / 7) +#define FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT 16 +#define FWL_THEMECAPACITY_MC_TODAY_WIDHT FWL_THEMECAPACITY_MC_HEADER_WIDTH +#define FWL_THEMECAPACITY_MC_TODAY_HEIGHT FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT +#define FWL_THEMECAPACITY_MC_TODAY_FLAG_WIDHT \ + FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH +#define FWL_MC_WIDTH 200 +#define FWL_MC_HEIGHT 160 + +CFWL_MonthCalendarTP::CFWL_MonthCalendarTP() { + m_pThemeData = new MCThemeData; + SetThemeData(0); +} +CFWL_MonthCalendarTP::~CFWL_MonthCalendarTP() { + delete m_pThemeData; +} +FX_BOOL CFWL_MonthCalendarTP::IsValidWidget(IFWL_Widget* pWidget) { + if (!pWidget) + return FALSE; + return pWidget->GetClassID() == FWL_CLASSHASH_MonthCalendar; +} +uint32_t CFWL_MonthCalendarTP::SetThemeID(IFWL_Widget* pWidget, + uint32_t dwThemeID, + FX_BOOL bChildren) { + if (m_pThemeData) { + SetThemeData(FWL_GetThemeColor(dwThemeID)); + } + return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren); +} +FX_BOOL CFWL_MonthCalendarTP::DrawBackground(CFWL_ThemeBackground* pParams) { + if (!pParams) + return FALSE; + switch (pParams->m_iPart) { + case FWL_PART_MCD_Border: { + DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_MCD_Edge: { + DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), + &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_MCD_Background: { + DrawTotalBK(pParams, &pParams->m_matrix); + break; + } + case FWL_PART_MCD_Header: { + DrawHeadBk(pParams, &pParams->m_matrix); + break; + } + case FWL_PART_MCD_LBtn: { +#ifdef THEME_XPSimilar + FWLTHEME_STATE eState = GetState(pParams->m_dwStates); + DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, + FWLTHEME_DIRECTION_Left, eState, &pParams->m_matrix); +#else + DrawLButton(pParams, &pParams->m_matrix); +#endif + break; + } + case FWL_PART_MCD_RBtn: { +#ifdef THEME_XPSimilar + FWLTHEME_STATE eState = GetState(pParams->m_dwStates); + DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, + FWLTHEME_DIRECTION_Right, eState, &pParams->m_matrix); +#else + DrawRButton(pParams, &pParams->m_matrix); +#endif + break; + } + case FWL_PART_MCD_HSeparator: { + DrawHSeperator(pParams, &pParams->m_matrix); + break; + } + case FWL_PART_MCD_DatesIn: { + DrawDatesInBK(pParams, &pParams->m_matrix); + break; + } + case FWL_PART_MCD_TodayCircle: { + DrawTodayCircle(pParams, &pParams->m_matrix); + break; + } + case FWL_PART_MCD_DateInCircle: { + DrawDatesInCircle(pParams, &pParams->m_matrix); + break; + } + case FWL_PART_MCD_WeekNumSep: { + DrawWeekNumSep(pParams, &pParams->m_matrix); + break; + } + default: {} + } + return TRUE; +} +FX_BOOL CFWL_MonthCalendarTP::DrawText(CFWL_ThemeText* pParams) { + if (!m_pTextOut) + return FALSE; + if ((pParams->m_iPart == FWL_PART_MCD_DatesIn) && + !(pParams->m_dwStates & FWL_ITEMSTATE_MCD_Flag) && + (pParams->m_dwStates & + (FWL_PARTSTATE_MCD_Hovered | FWL_PARTSTATE_MCD_Selected))) { + m_pTextOut->SetTextColor(0xFFFFFFFF); + } else if (pParams->m_iPart == FWL_PART_MCD_Caption) { + m_pTextOut->SetTextColor(m_pThemeData->clrCaption); + } else { + m_pTextOut->SetTextColor(0xFF000000); + } + return CFWL_WidgetTP::DrawText(pParams); +} +void* CFWL_MonthCalendarTP::GetCapacity(CFWL_ThemePart* pThemePart, + uint32_t dwCapacity) { + FX_BOOL bDefPro = FALSE; + FX_BOOL bDwordVal = FALSE; + switch (dwCapacity) { + case FWL_WGTCAPACITY_MC_HEADER_WIDTH: { + m_fValue = FWL_THEMECAPACITY_MC_HEADER_WIDTH; + break; + } + case FWL_WGTCAPACITY_MC_HEADER_Height: { + m_fValue = FWL_THEMECAPACITY_MC_HEADER_HEIGHT; + break; + } + case FWL_WGTCAPACITY_MC_HEADER_BTN_WIDTH: { + m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_WIDTH; + break; + } + case FWL_WGTCAPACITY_MC_HEADER_BTN_HEIGHT: { + m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT; + break; + } + case FWL_WGTCAPACITY_MC_HEADER_BTN_HMARGIN: { + bDwordVal = TRUE; + m_dwValue = FWL_THEMECAPACITY_MC_HEADER_BTN_HMARGIN; + break; + } + case FWL_WGTCAPACITY_MC_HEADER_BTN_VMARGIN: { + m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_VMARGIN; + break; + } + case FWL_WGTCAPACITY_MC_HEADER_TEXTWIDHT: { + m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT; + break; + } + case FWL_WGTCAPACITY_MC_HEADER_TEXTHEIGHT: { + m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT; + break; + } + case FWL_WGTCAPACITY_MC_HEADER_TEXT_HMARGIN: { + m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXT_HMARGIN; + break; + } + case FWL_WGTCAPACITY_MC_HEADER_TEXT_VMARGIN: { + m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXT_VMARGIN; + break; + } + case FWL_WGTCAPACITY_MC_HSEP_WIDTH: { + m_fValue = FWL_THEMECAPACITY_MC_HSEP_WIDTH; + break; + } + case FWL_WGTCAPACITY_MC_HSEP_HEIGHT: { + m_fValue = FWL_THEMECAPACITY_MC_HSEP_HEIGHT; + break; + } + case FWL_WGTCAPACITY_MC_VSEP_WIDTH: { + m_fValue = FWL_THEMECAPACITY_MC_VSEP_WIDTH; + break; + } + case FWL_WGTCAPACITY_MC_VSEP_HEIGHT: { + m_fValue = FWL_THEMECAPACITY_MC_VSEP_HEIGHT; + break; + } + case FWL_WGTCAPACITY_MC_WEEKNUM_WIDTH: { + m_fValue = FWL_THEMECAPACITY_MC_WEEKNUM_WIDTH; + break; + } + case FWL_WGTCAPACITY_MC_WEEKNUM_HEIGHT: { + m_fValue = FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT; + break; + } + case FWL_WGTCAPACITY_MC_WEEK_WIDTH: { + m_fValue = FWL_THEMECAPACITY_MC_WEEK_WIDTH; + break; + } + case FWL_WGTCAPACITY_MC_WEEK_HEIGHT: { + m_fValue = FWL_THEMECAPACITY_MC_WEEK_HEIGHT; + break; + } + case FWL_WGTCAPACITY_MC_SEP_DOFFSET: { + m_fValue = FWL_THEMECAPACITY_MC_SEP_DOFFSET; + break; + } + case FWL_WGTCAPACITY_MC_SEP_X: { + m_fValue = FWL_THEMECAPACITY_MC_SEP_X; + break; + } + case FWL_WGTCAPACITY_MC_SEP_Y: { + m_fValue = FWL_THEMECAPACITY_MC_SEP_Y; + break; + } + case FWL_WGTCAPACITY_MC_DATES_CELL_WIDTH: { + m_fValue = FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH; + break; + } + case FWL_WGTCAPACITY_MC_DATES_CELL_HEIGHT: { + m_fValue = FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT; + break; + } + case FWL_WGTCAPACITY_MC_TODAY_WIDHT: { + m_fValue = FWL_THEMECAPACITY_MC_TODAY_WIDHT; + break; + } + case FWL_WGTCAPACITY_MC_TODAY_HEIGHT: { + m_fValue = FWL_THEMECAPACITY_MC_TODAY_HEIGHT; + break; + } + case FWL_WGTCAPACITY_MC_TODAY_FLAG_WIDHT: { + m_fValue = FWL_THEMECAPACITY_MC_TODAY_FLAG_WIDHT; + break; + } + case FWL_WGTCAPACITY_MC_WIDTH: { + m_fValue = FWL_MC_WIDTH; + break; + } + case FWL_WGTCAPACITY_MC_HEIGHT: { + m_fValue = FWL_MC_HEIGHT; + break; + } + case FWL_MCCAPACITY_Sun: { + wsResource = L"Sun"; + return &wsResource; + } + case FWL_MCCAPACITY_Mon: { + wsResource = L"Mon"; + return &wsResource; + } + case FWL_MCCAPACITY_Tue: { + wsResource = L"Tue"; + return &wsResource; + } + case FWL_MCCAPACITY_Wed: { + wsResource = L"Wed"; + return &wsResource; + } + case FWL_MCCAPACITY_Thu: { + wsResource = L"Thu"; + return &wsResource; + } + case FWL_MCCAPACITY_Fri: { + wsResource = L"Fri"; + return &wsResource; + } + case FWL_MCCAPACITY_Sat: { + wsResource = L"Sat"; + return &wsResource; + } + case FWL_MCCAPACITY_January: { + wsResource = L"January"; + return &wsResource; + } + case FWL_MCCAPACITY_February: { + wsResource = L"February"; + return &wsResource; + } + case FWL_MCCAPACITY_March: { + wsResource = L"March"; + return &wsResource; + } + case FWL_MCCAPACITY_April: { + wsResource = L"April"; + return &wsResource; + } + case FWL_MCCAPACITY_May: { + wsResource = L"May"; + return &wsResource; + } + case FWL_MCCAPACITY_June: { + wsResource = L"June"; + return &wsResource; + } + case FWL_MCCAPACITY_July: { + wsResource = L"July"; + return &wsResource; + } + case FWL_MCCAPACITY_August: { + wsResource = L"August"; + return &wsResource; + } + case FWL_MCCAPACITY_September: { + wsResource = L"September"; + return &wsResource; + } + case FWL_MCCAPACITY_October: { + wsResource = L"October"; + return &wsResource; + } + case FWL_MCCAPACITY_November: { + wsResource = L"November"; + return &wsResource; + } + case FWL_MCCAPACITY_December: { + wsResource = L"December"; + return &wsResource; + } + case FWL_MCCAPACITY_Today: { + wsResource = L"Today"; + return &wsResource; + } + default: { bDefPro = TRUE; } + } + if (!bDefPro) { + if (bDwordVal) { + return &m_dwValue; + } + return &m_fValue; + } + return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); +} +FWL_ERR CFWL_MonthCalendarTP::Initialize() { + InitTTO(); + return CFWL_WidgetTP::Initialize(); +} +FWL_ERR CFWL_MonthCalendarTP::Finalize() { + FinalizeTTO(); + return CFWL_WidgetTP::Finalize(); +} +FX_BOOL CFWL_MonthCalendarTP::DrawTotalBK(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + CFX_RectF rtTotal(pParams->m_rtPart); + path.AddRectangle(rtTotal.left, rtTotal.top, rtTotal.width, rtTotal.height); + pParams->m_pGraphics->SaveGraphState(); + CFX_Color clrBK(m_pThemeData->clrBK); + pParams->m_pGraphics->SetFillColor(&clrBK); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pParams->m_pGraphics->RestoreGraphState(); + return TRUE; +} +FX_BOOL CFWL_MonthCalendarTP::DrawHeadBk(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + CFX_RectF rtHead = pParams->m_rtPart; + path.AddRectangle(rtHead.left, rtHead.top, rtHead.width, rtHead.height); + pParams->m_pGraphics->SaveGraphState(); + CFX_Color clrHeadBK(m_pThemeData->clrBK); + pParams->m_pGraphics->SetFillColor(&clrHeadBK); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pParams->m_pGraphics->RestoreGraphState(); + return TRUE; +} +FX_BOOL CFWL_MonthCalendarTP::DrawLButton(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + CFX_RectF rtLBtn; + rtLBtn = pParams->m_rtPart; + path.AddRectangle(rtLBtn.left, rtLBtn.top, rtLBtn.width, rtLBtn.height); + pParams->m_pGraphics->SaveGraphState(); + CFX_Color clrLBtnEdge(ArgbEncode(0xff, 205, 219, 243)); + pParams->m_pGraphics->SetStrokeColor(&clrLBtnEdge); + pParams->m_pGraphics->StrokePath(&path, pMatrix); + if ((pParams->m_dwStates & FWL_PARTSTATE_MCD_Pressed) == + FWL_PARTSTATE_MCD_Pressed) { + CFX_Color clrLBtnFill(ArgbEncode(0xff, 174, 198, 242)); + pParams->m_pGraphics->SetFillColor(&clrLBtnFill); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + } else { + CFX_Color clrLBtnFill(ArgbEncode(0xff, 227, 235, 249)); + pParams->m_pGraphics->SetFillColor(&clrLBtnFill); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + } + path.Clear(); + path.MoveTo(rtLBtn.left + rtLBtn.Width() / 3 * 2, + rtLBtn.top + rtLBtn.height / 4); + path.LineTo(rtLBtn.left + rtLBtn.Width() / 3, rtLBtn.top + rtLBtn.height / 2); + path.LineTo(rtLBtn.left + rtLBtn.Width() / 3 * 2, + rtLBtn.bottom() - rtLBtn.height / 4); + CFX_Color clrFlag(ArgbEncode(0xff, 50, 104, 205)); + pParams->m_pGraphics->SetStrokeColor(&clrFlag); + pParams->m_pGraphics->StrokePath(&path, pMatrix); + pParams->m_pGraphics->RestoreGraphState(); + return TRUE; +} +FX_BOOL CFWL_MonthCalendarTP::DrawRButton(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + CFX_RectF rtRBtn; + rtRBtn = pParams->m_rtPart; + path.AddRectangle(rtRBtn.left, rtRBtn.top, rtRBtn.width, rtRBtn.height); + pParams->m_pGraphics->SaveGraphState(); + CFX_Color clrRBtnEdge(ArgbEncode(0xff, 205, 219, 243)); + pParams->m_pGraphics->SetStrokeColor(&clrRBtnEdge); + pParams->m_pGraphics->StrokePath(&path, pMatrix); + if ((pParams->m_dwStates & FWL_PARTSTATE_MCD_Pressed) == + FWL_PARTSTATE_MCD_Pressed) { + CFX_Color clrRBtnFill(ArgbEncode(0xff, 174, 198, 242)); + pParams->m_pGraphics->SetFillColor(&clrRBtnFill); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + } else { + CFX_Color clrRBtnFill(ArgbEncode(0xff, 227, 235, 249)); + pParams->m_pGraphics->SetFillColor(&clrRBtnFill); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + } + path.Clear(); + path.MoveTo(rtRBtn.left + rtRBtn.Width() / 3, rtRBtn.top + rtRBtn.height / 4); + path.LineTo(rtRBtn.left + rtRBtn.Width() / 3 * 2, + rtRBtn.top + rtRBtn.height / 2); + path.LineTo(rtRBtn.left + rtRBtn.Width() / 3, + rtRBtn.bottom() - rtRBtn.height / 4); + CFX_Color clrFlag(ArgbEncode(0xff, 50, 104, 205)); + pParams->m_pGraphics->SetStrokeColor(&clrFlag); + pParams->m_pGraphics->StrokePath(&path, pMatrix); + pParams->m_pGraphics->RestoreGraphState(); + return TRUE; +} +FX_BOOL CFWL_MonthCalendarTP::DrawHSeperator(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + CFX_RectF rtHSep; + rtHSep = pParams->m_rtPart; + path.MoveTo(rtHSep.left, rtHSep.top + rtHSep.height / 2); + path.LineTo(rtHSep.right(), rtHSep.top + rtHSep.height / 2); + pParams->m_pGraphics->SaveGraphState(); + CFX_Color clrHSep(m_pThemeData->clrSeperator); + pParams->m_pGraphics->SetStrokeColor(&clrHSep); + pParams->m_pGraphics->StrokePath(&path, pMatrix); + pParams->m_pGraphics->RestoreGraphState(); + return TRUE; +} +FX_BOOL CFWL_MonthCalendarTP::DrawWeekNumSep(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + CFX_RectF rtWeekSep; + rtWeekSep = pParams->m_rtPart; + path.MoveTo(rtWeekSep.left, rtWeekSep.top); + path.LineTo(rtWeekSep.left, rtWeekSep.bottom()); + pParams->m_pGraphics->SaveGraphState(); + CFX_Color clrHSep(m_pThemeData->clrSeperator); + pParams->m_pGraphics->SetStrokeColor(&clrHSep); + pParams->m_pGraphics->StrokePath(&path, pMatrix); + pParams->m_pGraphics->RestoreGraphState(); + return TRUE; +} +FX_BOOL CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + pParams->m_pGraphics->SaveGraphState(); + if (pParams->m_dwStates & FWL_PARTSTATE_MCD_Selected) { + CFX_Path path; + path.Create(); + CFX_RectF rtSelDay; + rtSelDay = pParams->m_rtPart; + path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, + rtSelDay.height); + CFX_Color clrSelDayBK; + clrSelDayBK = m_pThemeData->clrDatesSelectedBK; + pParams->m_pGraphics->SetFillColor(&clrSelDayBK); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + } else if (pParams->m_dwStates & FWL_PARTSTATE_MCD_Hovered) { + CFX_Path path; + path.Create(); + CFX_RectF rtSelDay; + rtSelDay = pParams->m_rtPart; + path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, + rtSelDay.height); + CFX_Color clrSelDayBK; + clrSelDayBK = m_pThemeData->clrDatesHoverBK; + pParams->m_pGraphics->SetFillColor(&clrSelDayBK); + pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + } + pParams->m_pGraphics->RestoreGraphState(); + return FALSE; +} +FX_BOOL CFWL_MonthCalendarTP::DrawDatesInCircle(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + CFX_RectF rtSelDay; + rtSelDay = pParams->m_rtPart; + path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, + rtSelDay.height); + pParams->m_pGraphics->SaveGraphState(); + CFX_Color clrSelDayBK; + clrSelDayBK = m_pThemeData->clrDatesCircle; + pParams->m_pGraphics->SetStrokeColor(&clrSelDayBK); + pParams->m_pGraphics->StrokePath(&path, pMatrix); + pParams->m_pGraphics->RestoreGraphState(); + return TRUE; +} +FX_BOOL CFWL_MonthCalendarTP::DrawTodayCircle(CFWL_ThemeBackground* pParams, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + CFX_RectF rtTodayCircle; + rtTodayCircle = pParams->m_rtPart; + path.AddRectangle(rtTodayCircle.left, rtTodayCircle.top, rtTodayCircle.width, + rtTodayCircle.height); + pParams->m_pGraphics->SaveGraphState(); + CFX_Color clrTodayCircle; + clrTodayCircle = m_pThemeData->clrDatesCircle; + pParams->m_pGraphics->SetStrokeColor(&clrTodayCircle); + pParams->m_pGraphics->StrokePath(&path, pMatrix); + pParams->m_pGraphics->RestoreGraphState(); + return TRUE; +} +FWLTHEME_STATE CFWL_MonthCalendarTP::GetState(uint32_t dwFWLStates) { + if (dwFWLStates & FWL_PARTSTATE_MCD_Hovered) { + return FWLTHEME_STATE_Hover; + } else if (dwFWLStates & FWL_PARTSTATE_MCD_Pressed) { + return FWLTHEME_STATE_Pressed; + } + return FWLTHEME_STATE_Normal; +} +void CFWL_MonthCalendarTP::SetThemeData(uint32_t dwThemeID) { + if (dwThemeID == 0) { + m_pThemeData->clrCaption = ArgbEncode(0xff, 0, 153, 255); + m_pThemeData->clrSeperator = ArgbEncode(0xff, 141, 161, 239); + m_pThemeData->clrDatesHoverBK = ArgbEncode(0xff, 193, 211, 251); + m_pThemeData->clrDatesSelectedBK = ArgbEncode(0xff, 173, 188, 239); + m_pThemeData->clrDatesCircle = ArgbEncode(0xff, 103, 144, 209); + m_pThemeData->clrToday = ArgbEncode(0xff, 0, 0, 0); + m_pThemeData->clrBK = ArgbEncode(0xff, 255, 255, 255); + } else { + m_pThemeData->clrCaption = ArgbEncode(0xff, 128, 128, 0); + m_pThemeData->clrSeperator = ArgbEncode(0xff, 128, 128, 64); + m_pThemeData->clrDatesHoverBK = ArgbEncode(0xff, 217, 220, 191); + m_pThemeData->clrDatesSelectedBK = ArgbEncode(0xff, 204, 208, 183); + m_pThemeData->clrDatesCircle = ArgbEncode(0xff, 128, 128, 0); + m_pThemeData->clrToday = ArgbEncode(0xff, 0, 0, 0); + m_pThemeData->clrBK = ArgbEncode(0xff, 255, 255, 255); + } +} diff --git a/xfa/fwl/theme/cfwl_monthcalendartp.h b/xfa/fwl/theme/cfwl_monthcalendartp.h new file mode 100644 index 0000000000..3624ee1bfd --- /dev/null +++ b/xfa/fwl/theme/cfwl_monthcalendartp.h @@ -0,0 +1,51 @@ +// 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_THEME_CFWL_MONTHCALENDARTP_H_ +#define XFA_FWL_THEME_CFWL_MONTHCALENDARTP_H_ + +#include "xfa/fwl/theme/cfwl_widgettp.h" + +class CFWL_MonthCalendarTP : public CFWL_WidgetTP { + public: + CFWL_MonthCalendarTP(); + virtual ~CFWL_MonthCalendarTP(); + virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); + virtual uint32_t SetThemeID(IFWL_Widget* pWidget, + uint32_t dwThemeID, + FX_BOOL bChildren = TRUE); + virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); + virtual FX_BOOL DrawText(CFWL_ThemeText* pParams); + virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity); + virtual FWL_ERR Initialize(); + virtual FWL_ERR Finalize(); + + protected: + FX_BOOL DrawTotalBK(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); + FX_BOOL DrawHeadBk(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); + FX_BOOL DrawLButton(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); + FX_BOOL DrawRButton(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); + FX_BOOL DrawDatesInBK(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); + FX_BOOL DrawDatesInCircle(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); + FX_BOOL DrawTodayCircle(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); + FX_BOOL DrawHSeperator(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); + FX_BOOL DrawWeekNumSep(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); + FWLTHEME_STATE GetState(uint32_t dwFWLStates); + void SetThemeData(uint32_t dwThemeID); + class MCThemeData { + public: + FX_ARGB clrCaption; + FX_ARGB clrSeperator; + FX_ARGB clrDatesHoverBK; + FX_ARGB clrDatesSelectedBK; + FX_ARGB clrDatesCircle; + FX_ARGB clrToday; + FX_ARGB clrBK; + } * m_pThemeData; + CFX_WideString wsResource; +}; + +#endif // XFA_FWL_THEME_CFWL_MONTHCALENDARTP_H_ diff --git a/xfa/fwl/theme/cfwl_pictureboxtp.cpp b/xfa/fwl/theme/cfwl_pictureboxtp.cpp new file mode 100644 index 0000000000..ee83a7eb3f --- /dev/null +++ b/xfa/fwl/theme/cfwl_pictureboxtp.cpp @@ -0,0 +1,38 @@ +// 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/theme/cfwl_pictureboxtp.h" + +#include "xfa/fwl/basewidget/ifwl_picturebox.h" +#include "xfa/fwl/core/cfwl_themebackground.h" +#include "xfa/fwl/core/ifwl_widget.h" + +CFWL_PictureBoxTP::CFWL_PictureBoxTP() {} + +CFWL_PictureBoxTP::~CFWL_PictureBoxTP() {} + +FX_BOOL CFWL_PictureBoxTP::IsValidWidget(IFWL_Widget* pWidget) { + if (!pWidget) + return FALSE; + return pWidget->GetClassID() == FWL_CLASSHASH_PictureBox; +} +FX_BOOL CFWL_PictureBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { + if (!pParams) + return FALSE; + switch (pParams->m_iPart) { + case FWL_PART_PTB_Border: { + DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_PTB_Edge: { + DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), + &pParams->m_rtPart, &pParams->m_matrix); + break; + } + default: {} + } + return TRUE; +} diff --git a/xfa/fwl/theme/cfwl_pictureboxtp.h b/xfa/fwl/theme/cfwl_pictureboxtp.h new file mode 100644 index 0000000000..0216971a94 --- /dev/null +++ b/xfa/fwl/theme/cfwl_pictureboxtp.h @@ -0,0 +1,20 @@ +// 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_THEME_CFWL_PICTUREBOXTP_H_ +#define XFA_FWL_THEME_CFWL_PICTUREBOXTP_H_ + +#include "xfa/fwl/theme/cfwl_widgettp.h" + +class CFWL_PictureBoxTP : public CFWL_WidgetTP { + public: + CFWL_PictureBoxTP(); + virtual ~CFWL_PictureBoxTP(); + virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); + virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); +}; + +#endif // XFA_FWL_THEME_CFWL_PICTUREBOXTP_H_ diff --git a/xfa/fwl/theme/cfwl_pushbuttontp.cpp b/xfa/fwl/theme/cfwl_pushbuttontp.cpp new file mode 100644 index 0000000000..5889f30927 --- /dev/null +++ b/xfa/fwl/theme/cfwl_pushbuttontp.cpp @@ -0,0 +1,161 @@ +// 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/theme/cfwl_pushbuttontp.h" + +#include "xfa/fwl/basewidget/ifwl_pushbutton.h" +#include "xfa/fwl/core/cfwl_themebackground.h" +#include "xfa/fwl/core/ifwl_themeprovider.h" +#include "xfa/fwl/core/ifwl_widget.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" + +#define PUSHBUTTON_SIZE_Corner 2 + +CFWL_PushButtonTP::CFWL_PushButtonTP() { + m_pThemeData = new PBThemeData; + SetThemeData(0); +} +CFWL_PushButtonTP::~CFWL_PushButtonTP() { + if (m_pThemeData) { + delete m_pThemeData; + } +} +FX_BOOL CFWL_PushButtonTP::IsValidWidget(IFWL_Widget* pWidget) { + return pWidget->GetClassID() == FWL_CLASSHASH_PushButton; +} +uint32_t CFWL_PushButtonTP::SetThemeID(IFWL_Widget* pWidget, + uint32_t dwThemeID, + FX_BOOL bChildren) { + SetThemeData(FWL_GetThemeColor(dwThemeID)); + return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren); +} +FX_BOOL CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) { + switch (pParams->m_iPart) { + case FWL_PART_PSB_Border: { + DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_PSB_Edge: { + DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), + &pParams->m_rtPart, &pParams->m_matrix); + break; + } + case FWL_PART_PSB_Background: { + CFX_RectF& rect = pParams->m_rtPart; + FX_FLOAT fRight = rect.right(); + FX_FLOAT fBottom = rect.bottom(); + CFX_Path strokePath; + strokePath.Create(); + strokePath.MoveTo(rect.left + PUSHBUTTON_SIZE_Corner, rect.top); + strokePath.LineTo(fRight - PUSHBUTTON_SIZE_Corner, rect.top); + strokePath.LineTo(fRight, rect.top + PUSHBUTTON_SIZE_Corner); + strokePath.LineTo(fRight, fBottom - PUSHBUTTON_SIZE_Corner); + strokePath.LineTo(fRight - PUSHBUTTON_SIZE_Corner, fBottom); + strokePath.LineTo(rect.left + PUSHBUTTON_SIZE_Corner, fBottom); + strokePath.LineTo(rect.left, fBottom - PUSHBUTTON_SIZE_Corner); + strokePath.LineTo(rect.left, rect.top + PUSHBUTTON_SIZE_Corner); + strokePath.LineTo(rect.left + PUSHBUTTON_SIZE_Corner, rect.top); + CFX_Path fillPath; + fillPath.Create(); + fillPath.AddSubpath(&strokePath); + CFX_Graphics* pGraphics = pParams->m_pGraphics; + pGraphics->SaveGraphState(); + CFX_RectF rtInner(rect); + rtInner.Deflate(PUSHBUTTON_SIZE_Corner + 1, PUSHBUTTON_SIZE_Corner + 1, + PUSHBUTTON_SIZE_Corner, PUSHBUTTON_SIZE_Corner); + fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width, + rtInner.height); + int32_t iColor = GetColorID(pParams->m_dwStates); + DrawAxialShading(pGraphics, rect.left + PUSHBUTTON_SIZE_Corner, rect.top, + rect.left + PUSHBUTTON_SIZE_Corner, rect.bottom(), + m_pThemeData->clrStart[iColor], + m_pThemeData->clrEnd[iColor], &fillPath, + FXFILL_ALTERNATE, &pParams->m_matrix); + CFX_Color crStroke(m_pThemeData->clrBorder[iColor]); + pGraphics->SetStrokeColor(&crStroke); + pGraphics->StrokePath(&strokePath, &pParams->m_matrix); + fillPath.Clear(); + fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width, + rtInner.height); + CFX_Color crFill(m_pThemeData->clrFill[iColor]); + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&fillPath, FXFILL_WINDING, &pParams->m_matrix); + if (pParams->m_dwStates & FWL_PARTSTATE_PSB_Focused) { + rtInner.Inflate(1, 1, 0, 0); + DrawFocus(pGraphics, &rtInner, &pParams->m_matrix); + } + pGraphics->RestoreGraphState(); + break; + } + default: {} + } + return TRUE; +} +void* CFWL_PushButtonTP::GetCapacity(CFWL_ThemePart* pThemePart, + uint32_t dwCapacity) { + if (dwCapacity == FWL_WGTCAPACITY_PSB_Margin) { + m_fValue = 0; + return &m_fValue; + } + return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); +} +FWL_ERR CFWL_PushButtonTP::Initialize() { + InitTTO(); + return CFWL_WidgetTP::Initialize(); +} +FWL_ERR CFWL_PushButtonTP::Finalize() { + FinalizeTTO(); + return CFWL_WidgetTP::Finalize(); +} +void CFWL_PushButtonTP::SetThemeData(uint32_t dwID) { + if (dwID) { + m_pThemeData->clrBorder[0] = ArgbEncode(255, 55, 98, 6); + m_pThemeData->clrBorder[1] = ArgbEncode(255, 55, 98, 6); + m_pThemeData->clrBorder[2] = ArgbEncode(255, 55, 98, 6); + m_pThemeData->clrBorder[3] = ArgbEncode(255, 55, 98, 6); + m_pThemeData->clrBorder[4] = ArgbEncode(255, 172, 168, 153); + m_pThemeData->clrStart[0] = ArgbEncode(255, 255, 255, 246); + m_pThemeData->clrStart[1] = ArgbEncode(255, 223, 205, 180); + m_pThemeData->clrStart[2] = ArgbEncode(255, 252, 197, 149); + m_pThemeData->clrStart[3] = ArgbEncode(255, 194, 209, 143); + m_pThemeData->clrStart[4] = ArgbEncode(255, 216, 216, 216); + m_pThemeData->clrEnd[0] = ArgbEncode(255, 227, 209, 184); + m_pThemeData->clrEnd[1] = ArgbEncode(255, 248, 244, 228); + m_pThemeData->clrEnd[2] = ArgbEncode(255, 207, 114, 37); + m_pThemeData->clrEnd[3] = ArgbEncode(255, 144, 193, 84); + m_pThemeData->clrEnd[4] = ArgbEncode(255, 172, 168, 153); + m_pThemeData->clrFill[0] = ArgbEncode(255, 255, 255, 255); + m_pThemeData->clrFill[1] = ArgbEncode(255, 226, 225, 218); + m_pThemeData->clrFill[2] = ArgbEncode(255, 255, 255, 255); + m_pThemeData->clrFill[3] = ArgbEncode(255, 255, 255, 255); + m_pThemeData->clrFill[4] = ArgbEncode(255, 245, 244, 234); + } else { + m_pThemeData->clrBorder[0] = ArgbEncode(255, 0, 60, 116); + m_pThemeData->clrBorder[1] = ArgbEncode(255, 0, 60, 116); + m_pThemeData->clrBorder[2] = ArgbEncode(255, 0, 60, 116); + m_pThemeData->clrBorder[3] = ArgbEncode(255, 0, 60, 116); + m_pThemeData->clrBorder[4] = ArgbEncode(255, 201, 199, 186); + m_pThemeData->clrStart[0] = ArgbEncode(255, 255, 255, 255); + m_pThemeData->clrStart[1] = ArgbEncode(255, 209, 204, 193); + m_pThemeData->clrStart[2] = ArgbEncode(255, 255, 240, 207); + m_pThemeData->clrStart[3] = ArgbEncode(255, 206, 231, 255); + m_pThemeData->clrStart[4] = ArgbEncode(255, 245, 244, 234); + m_pThemeData->clrEnd[0] = ArgbEncode(255, 214, 208, 197); + m_pThemeData->clrEnd[1] = ArgbEncode(255, 242, 241, 238); + m_pThemeData->clrEnd[2] = ArgbEncode(255, 229, 151, 0); + m_pThemeData->clrEnd[3] = ArgbEncode(255, 105, 130, 238); + m_pThemeData->clrEnd[4] = ArgbEncode(255, 245, 244, 234); + m_pThemeData->clrFill[0] = ArgbEncode(255, 255, 255, 255); + m_pThemeData->clrFill[1] = ArgbEncode(255, 226, 225, 218); + m_pThemeData->clrFill[2] = ArgbEncode(255, 255, 255, 255); + m_pThemeData->clrFill[3] = ArgbEncode(255, 255, 255, 255); + m_pThemeData->clrFill[4] = ArgbEncode(255, 245, 244, 234); + } +} +int32_t CFWL_PushButtonTP::GetColorID(uint32_t dwStates) { + return dwStates &= FWL_PARTSTATE_PSB_Mask; +} diff --git a/xfa/fwl/theme/cfwl_pushbuttontp.h b/xfa/fwl/theme/cfwl_pushbuttontp.h new file mode 100644 index 0000000000..b72ac86126 --- /dev/null +++ b/xfa/fwl/theme/cfwl_pushbuttontp.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_THEME_CFWL_PUSHBUTTONTP_H_ +#define XFA_FWL_THEME_CFWL_PUSHBUTTONTP_H_ + +#include "xfa/fwl/theme/cfwl_widgettp.h" + +class CFWL_PushButtonTP : public CFWL_WidgetTP { + public: + CFWL_PushButtonTP(); + virtual ~CFWL_PushButtonTP(); + virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); + virtual uint32_t SetThemeID(IFWL_Widget* pWidget, + uint32_t dwThemeID, + FX_BOOL bChildren = TRUE); + virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); + virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity); + virtual FWL_ERR Initialize(); + virtual FWL_ERR Finalize(); + + protected: + struct PBThemeData { + FX_ARGB clrBorder[5]; + FX_ARGB clrStart[5]; + FX_ARGB clrEnd[5]; + FX_ARGB clrFill[5]; + }; + + void SetThemeData(uint32_t dwID); + void SetTopLineColor(uint32_t* pData); + void SetLeftLineColor(uint32_t* pData); + void SetRightLineColor(uint32_t* pData); + void SetBottomLineColor(uint32_t* pData); + void SetBackgroudColor(uint32_t* pData); + void SetCaptionColor(uint32_t* pData); + void SetCornerColor(uint32_t* pData); + int32_t GetColorID(uint32_t dwStates); + + struct PBThemeData* m_pThemeData; +}; + +#endif // XFA_FWL_THEME_CFWL_PUSHBUTTONTP_H_ diff --git a/xfa/fwl/theme/cfwl_scrollbartp.cpp b/xfa/fwl/theme/cfwl_scrollbartp.cpp new file mode 100644 index 0000000000..c6a14f8e94 --- /dev/null +++ b/xfa/fwl/theme/cfwl_scrollbartp.cpp @@ -0,0 +1,381 @@ +// 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/theme/cfwl_scrollbartp.h" + +#include "xfa/fwl/basewidget/ifwl_scrollbar.h" +#include "xfa/fwl/core/cfwl_themebackground.h" +#include "xfa/fwl/core/ifwl_themeprovider.h" +#include "xfa/fwl/core/ifwl_widget.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" + +#define FWL_SCROLL_PawLen 12.5f + +CFWL_ScrollBarTP::CFWL_ScrollBarTP() { + m_pThemeData = new SBThemeData; + SetThemeData(0); +} +CFWL_ScrollBarTP::~CFWL_ScrollBarTP() { + if (m_pThemeData) { + delete m_pThemeData; + m_pThemeData = NULL; + } +} +FX_BOOL CFWL_ScrollBarTP::IsValidWidget(IFWL_Widget* pWidget) { + if (!pWidget) + return FALSE; + return pWidget->GetClassID() == FWL_CLASSHASH_ScrollBar; +} +void* CFWL_ScrollBarTP::GetCapacity(CFWL_ThemePart* pThemePart, + uint32_t dwCapacity) { + if (dwCapacity == FWL_CAPACITY_SCB_Size) { + m_fValue = 5; + return &m_fValue; + } + return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); +} +uint32_t CFWL_ScrollBarTP::SetThemeID(IFWL_Widget* pWidget, + uint32_t dwThemeID, + FX_BOOL bChildren) { + if (m_pThemeData) { + SetThemeData(FWL_GetThemeColor(dwThemeID)); + } + return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren); +} +FX_BOOL CFWL_ScrollBarTP::DrawBackground(CFWL_ThemeBackground* pParams) { + if (!pParams) + return FALSE; + IFWL_Widget* pWidget = pParams->m_pWidget; + FWLTHEME_STATE eState = FWLTHEME_STATE_Normal; + switch (pParams->m_dwStates & 0x03) { + case FWL_PARTSTATE_SCB_Hovered: { + eState = FWLTHEME_STATE_Hover; + break; + } + case FWL_PARTSTATE_SCB_Pressed: { + eState = FWLTHEME_STATE_Pressed; + break; + } + case FWL_PARTSTATE_SCB_Disabled: { + eState = FWLTHEME_STATE_Disabale; + break; + } + } + CFX_Graphics* pGraphics = pParams->m_pGraphics; + CFX_RectF* pRect = &pParams->m_rtPart; + FX_BOOL bVert = pWidget->GetStylesEx(); + switch (pParams->m_iPart) { + case FWL_PART_SCB_ForeArrow: { + DrawMaxMinBtn(pGraphics, pRect, + bVert ? FWLTHEME_DIRECTION_Up : FWLTHEME_DIRECTION_Left, + eState, &pParams->m_matrix); + break; + } + case FWL_PART_SCB_BackArrow: { + DrawMaxMinBtn(pGraphics, pRect, + bVert ? FWLTHEME_DIRECTION_Down : FWLTHEME_DIRECTION_Right, + eState, &pParams->m_matrix); + break; + } + case FWL_PART_SCB_Thumb: { + DrawThumbBtn(pGraphics, pRect, bVert, eState, TRUE, &pParams->m_matrix); + break; + } + case FWL_PART_SCB_LowerTrack: { + DrawTrack(pGraphics, pRect, bVert, eState, TRUE, &pParams->m_matrix); + break; + } + case FWL_PART_SCB_UpperTrack: { + DrawTrack(pGraphics, pRect, bVert, eState, FALSE, &pParams->m_matrix); + break; + } + default: {} + } + return TRUE; +} +#ifdef THEME_XPSimilar +void CFWL_ScrollBarTP::DrawThumbBtn(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FX_BOOL bVert, + FWLTHEME_STATE eState, + FX_BOOL bPawButton, + CFX_Matrix* pMatrix) { + if (eState < FWLTHEME_STATE_Normal || eState > FWLTHEME_STATE_Disabale) { + return; + } + CFX_Path path; + path.Create(); + CFX_RectF rect(*pRect); + if (bVert) { + rect.Deflate(1, 0); + if (rect.IsEmpty(0.1f)) { + return; + } + path.AddRectangle(rect.left, rect.top, rect.width, rect.height); + DrawAxialShading(pGraphics, rect.left, rect.top, rect.right(), rect.top, + m_pThemeData->clrBtnBK[eState - 1][0], + m_pThemeData->clrBtnBK[eState - 1][1], &path, + FXFILL_WINDING, pMatrix); + CFX_Color rcStroke; + rcStroke.Set(m_pThemeData->clrBtnBorder[eState - 1]); + pGraphics->SaveGraphState(); + pGraphics->SetStrokeColor(&rcStroke); + pGraphics->StrokePath(&path, pMatrix); + pGraphics->RestoreGraphState(); + } else { + rect.Deflate(0, 1); + if (rect.IsEmpty(0.1f)) { + return; + } + path.AddRectangle(rect.left, rect.top, rect.width, rect.height); + DrawAxialShading(pGraphics, rect.left, rect.top, rect.left, rect.bottom(), + m_pThemeData->clrBtnBK[eState - 1][0], + m_pThemeData->clrBtnBK[eState - 1][1], &path, + FXFILL_WINDING, pMatrix); + CFX_Color rcStroke; + rcStroke.Set(m_pThemeData->clrBtnBorder[eState - 1]); + pGraphics->SaveGraphState(); + pGraphics->SetStrokeColor(&rcStroke); + pGraphics->StrokePath(&path, pMatrix); + pGraphics->RestoreGraphState(); + } +} +void CFWL_ScrollBarTP::DrawPaw(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FX_BOOL bVert, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + if (bVert) { + FX_FLOAT fPawLen = FWL_SCROLL_PawLen; + if (pRect->width / 2 <= fPawLen) { + fPawLen = (pRect->width - 6) / 2; + } + FX_FLOAT fX = pRect->left + pRect->width / 4; + FX_FLOAT fY = pRect->top + pRect->height / 2; + path.MoveTo(fX, fY - 4); + path.LineTo(fX + fPawLen, fY - 4); + path.MoveTo(fX, fY - 2); + path.LineTo(fX + fPawLen, fY - 2); + path.MoveTo(fX, fY); + path.LineTo(fX + fPawLen, fY); + path.MoveTo(fX, fY + 2); + path.LineTo(fX + fPawLen, fY + 2); + CFX_Color clrLight(m_pThemeData->clrPawColorLight[eState - 1]); + pGraphics->SetLineWidth(1); + pGraphics->SetStrokeColor(&clrLight); + pGraphics->StrokePath(&path); + fX++; + path.Clear(); + path.MoveTo(fX, fY - 3); + path.LineTo(fX + fPawLen, fY - 3); + path.MoveTo(fX, fY - 1); + path.LineTo(fX + fPawLen, fY - 1); + path.MoveTo(fX, fY + 1); + path.LineTo(fX + fPawLen, fY + 1); + path.MoveTo(fX, fY + 3); + path.LineTo(fX + fPawLen, fY + 3); + CFX_Color clrDark(m_pThemeData->clrPawColorDark[eState - 1]); + pGraphics->SetLineWidth(1); + pGraphics->SetStrokeColor(&clrDark); + pGraphics->StrokePath(&path, pMatrix); + } else { + FX_FLOAT fPawLen = FWL_SCROLL_PawLen; + if (pRect->height / 2 <= fPawLen) { + fPawLen = (pRect->height - 6) / 2; + } + FX_FLOAT fX = pRect->left + pRect->width / 2; + FX_FLOAT fY = pRect->top + pRect->height / 4; + path.MoveTo(fX - 4, fY); + path.LineTo(fX - 4, fY + fPawLen); + path.MoveTo(fX - 2, fY); + path.LineTo(fX - 2, fY + fPawLen); + path.MoveTo(fX, fY); + path.LineTo(fX, fY + fPawLen); + path.MoveTo(fX + 2, fY); + path.LineTo(fX + 2, fY + fPawLen); + CFX_Color clrLight(m_pThemeData->clrPawColorLight[eState - 1]); + pGraphics->SetLineWidth(1); + pGraphics->SetStrokeColor(&clrLight); + pGraphics->StrokePath(&path, pMatrix); + fY++; + path.Clear(); + path.MoveTo(fX - 3, fY); + path.LineTo(fX - 3, fY + fPawLen); + path.MoveTo(fX - 1, fY); + path.LineTo(fX - 1, fY + fPawLen); + path.MoveTo(fX + 1, fY); + path.LineTo(fX + 1, fY + fPawLen); + path.MoveTo(fX + 3, fY); + path.LineTo(fX + 3, fY + fPawLen); + CFX_Color clrDark(m_pThemeData->clrPawColorDark[eState - 1]); + pGraphics->SetLineWidth(1); + pGraphics->SetStrokeColor(&clrDark); + pGraphics->StrokePath(&path, pMatrix); + } +} +void CFWL_ScrollBarTP::DrawTrack(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FX_BOOL bVert, + FWLTHEME_STATE eState, + FX_BOOL bLowerTrack, + CFX_Matrix* pMatrix) { + if (eState < FWLTHEME_STATE_Normal || eState > FWLTHEME_STATE_Disabale) { + return; + } + pGraphics->SaveGraphState(); + CFX_Color colorLine(ArgbEncode(255, 238, 237, 229)); + CFX_Path path; + path.Create(); + FX_FLOAT fRight = pRect->right(); + FX_FLOAT fBottom = pRect->bottom(); + if (bVert) { + path.AddRectangle(pRect->left, pRect->top, 1, pRect->height); + path.AddRectangle(fRight - 1, pRect->top, 1, pRect->height); + } else { + path.AddRectangle(pRect->left, pRect->top, pRect->width, 1); + path.AddRectangle(pRect->left, fBottom - 1, pRect->width, 1); + } + pGraphics->SetFillColor(&colorLine); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + path.Clear(); + path.AddRectangle(pRect->left + 1, pRect->top, pRect->width - 2, + pRect->height); + FX_FLOAT x1 = bVert ? pRect->left + 1 : pRect->left; + FX_FLOAT y1 = bVert ? pRect->top : pRect->top + 1; + FX_FLOAT x2 = bVert ? fRight - 1 : pRect->left; + FX_FLOAT y2 = bVert ? pRect->top : fBottom - 1; + pGraphics->RestoreGraphState(); + DrawAxialShading(pGraphics, x1, y1, x2, y2, m_pThemeData->clrTrackBKStart, + m_pThemeData->clrTrackBKEnd, &path, FXFILL_WINDING, pMatrix); +} +void CFWL_ScrollBarTP::DrawMaxMinBtn(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_DIRECTION eDict, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix) { + DrawTrack(pGraphics, pRect, + eDict == FWLTHEME_DIRECTION_Up || eDict == FWLTHEME_DIRECTION_Down, + eState, TRUE, pMatrix); + CFX_RectF rtArrowBtn(*pRect); + rtArrowBtn.Deflate(1, 1, 1, 1); + DrawArrowBtn(pGraphics, &rtArrowBtn, eDict, eState, pMatrix); +} +#else +void CFWL_ScrollBarTP::DrawThumbBtn(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FX_BOOL bVert, + FWLTHEME_STATE eState, + FX_BOOL bPawButton, + CFX_Matrix* pMatrix) { + if (pRect->IsEmpty()) { + return; + } + CFX_RectF rtThumb(*pRect); + FX_FLOAT fWidth = 2; + Draw3DRect(pGraphics, FWLTHEME_EDGE_Raised, fWidth, pRect, + FWLTHEME_COLOR_EDGELT1, FWLTHEME_COLOR_EDGELT2, + FWLTHEME_COLOR_EDGERB1, FWLTHEME_COLOR_EDGERB2, pMatrix); + CFX_Path path; + path.Create(); + path.AddRectangle(pRect->left + fWidth, pRect->top + fWidth, + pRect->width - 2 * fWidth, pRect->height - 2 * fWidth); + pGraphics->SaveGraphState(); + CFX_Color crFill(FWLTHEME_COLOR_Background); + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_ScrollBarTP::DrawTrack(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FX_BOOL bVert, + FWLTHEME_STATE eState, + FX_BOOL bLowerTrack, + CFX_Matrix* pMatrix) { + if (pRect->IsEmpty()) { + return; + } + CFX_Path path; + path.Create(); + path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); + pGraphics->SaveGraphState(); + CFX_Color clrFill(0xFFF0F0F0); + pGraphics->SetFillColor(&clrFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_ScrollBarTP::DrawMaxMinBtn(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_DIRECTION eDict, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix) { + CFX_RectF rtThumb(*pRect); + FX_FLOAT fWidth = eState == FWLTHEME_STATE_Pressed ? 1.0f : 2.0f; + FWLTHEME_EDGE eType = eState == FWLTHEME_STATE_Pressed ? FWLTHEME_EDGE_Flat + : FWLTHEME_EDGE_Raised; + Draw3DRect(pGraphics, eType, fWidth, pRect, FWLTHEME_COLOR_EDGELT1, + FWLTHEME_COLOR_EDGELT2, FWLTHEME_COLOR_EDGERB1, + FWLTHEME_COLOR_EDGERB2, pMatrix); + CFX_Path path; + path.Create(); + path.AddRectangle(pRect->left + fWidth, pRect->top + fWidth, + pRect->width - 2 * fWidth, pRect->height - 2 * fWidth); + pGraphics->SaveGraphState(); + CFX_Color crFill(FWLTHEME_COLOR_Background); + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pGraphics->RestoreGraphState(); + DrawArrow(pGraphics, pRect, eDict, + eState == FWLTHEME_STATE_Disabale ? 0xFFA0A0A0 : 0xFF000000, + eState == FWLTHEME_STATE_Pressed, pMatrix); +} +#endif +void CFWL_ScrollBarTP::SetThemeData(uint32_t dwID) { + m_pThemeData->clrPawColorLight[3] = ArgbEncode(0xff, 208, 223, 172); + m_pThemeData->clrPawColorDark[3] = ArgbEncode(0xff, 140, 157, 115); + m_pThemeData->clrBtnBK[3][0] = ArgbEncode(0xff, 164, 180, 139); + m_pThemeData->clrBtnBK[3][1] = ArgbEncode(0xff, 141, 157, 115); + m_pThemeData->clrBtnBorder[3] = ArgbEncode(0xff, 236, 233, 216); + if (dwID) { + m_pThemeData->clrPawColorLight[0] = ArgbEncode(0xff, 208, 223, 172); + m_pThemeData->clrPawColorDark[0] = ArgbEncode(0xff, 140, 157, 115); + m_pThemeData->clrBtnBK[0][0] = ArgbEncode(0xff, 162, 179, 141); + m_pThemeData->clrBtnBK[0][1] = ArgbEncode(0xff, 149, 167, 117); + m_pThemeData->clrBtnBorder[0] = ArgbEncode(0xff, 142, 153, 125); + m_pThemeData->clrPawColorLight[1] = ArgbEncode(0xff, 235, 245, 212); + m_pThemeData->clrPawColorDark[1] = ArgbEncode(0xff, 182, 198, 142); + m_pThemeData->clrBtnBK[1][0] = ArgbEncode(0xff, 200, 213, 170); + m_pThemeData->clrBtnBK[1][1] = ArgbEncode(0xff, 195, 208, 150); + m_pThemeData->clrBtnBorder[1] = ArgbEncode(0xff, 189, 203, 150); + m_pThemeData->clrPawColorLight[2] = ArgbEncode(0xff, 208, 223, 172); + m_pThemeData->clrPawColorDark[2] = ArgbEncode(0xff, 140, 157, 115); + m_pThemeData->clrBtnBK[2][0] = ArgbEncode(0xff, 164, 180, 139); + m_pThemeData->clrBtnBK[2][1] = ArgbEncode(0xff, 141, 157, 115); + m_pThemeData->clrBtnBorder[2] = ArgbEncode(0xff, 128, 146, 102); + m_pThemeData->clrTrackBKStart = ArgbEncode(0xff, 243, 241, 236); + m_pThemeData->clrTrackBKEnd = ArgbEncode(0xff, 254, 254, 251); + } else { + m_pThemeData->clrPawColorLight[0] = ArgbEncode(0xff, 238, 244, 254); + m_pThemeData->clrPawColorDark[0] = ArgbEncode(0xff, 140, 176, 248); + m_pThemeData->clrBtnBK[0][0] = ArgbEncode(0xff, 197, 213, 252); + m_pThemeData->clrBtnBK[0][1] = ArgbEncode(0xff, 182, 205, 251); + m_pThemeData->clrBtnBorder[0] = ArgbEncode(0xff, 148, 176, 221); + m_pThemeData->clrPawColorLight[1] = ArgbEncode(0xff, 252, 253, 255); + m_pThemeData->clrPawColorDark[1] = ArgbEncode(0xff, 156, 197, 255); + m_pThemeData->clrBtnBK[1][0] = ArgbEncode(0xff, 216, 232, 255); + m_pThemeData->clrBtnBK[1][1] = ArgbEncode(0xff, 204, 225, 255); + m_pThemeData->clrBtnBorder[1] = ArgbEncode(0xff, 218, 230, 254); + m_pThemeData->clrPawColorLight[2] = ArgbEncode(0xff, 207, 221, 253); + m_pThemeData->clrPawColorDark[2] = ArgbEncode(0xff, 131, 158, 216); + m_pThemeData->clrBtnBK[2][0] = ArgbEncode(0xff, 167, 190, 245); + m_pThemeData->clrBtnBK[2][1] = ArgbEncode(0xff, 146, 179, 249); + m_pThemeData->clrBtnBorder[2] = ArgbEncode(0xff, 124, 159, 211); + m_pThemeData->clrTrackBKStart = ArgbEncode(0xff, 243, 241, 236); + m_pThemeData->clrTrackBKEnd = ArgbEncode(0xff, 254, 254, 251); + } +} diff --git a/xfa/fwl/theme/cfwl_scrollbartp.h b/xfa/fwl/theme/cfwl_scrollbartp.h new file mode 100644 index 0000000000..0530393043 --- /dev/null +++ b/xfa/fwl/theme/cfwl_scrollbartp.h @@ -0,0 +1,60 @@ +// 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_THEME_CFWL_SCROLLBARTP_H_ +#define XFA_FWL_THEME_CFWL_SCROLLBARTP_H_ + +#include "xfa/fwl/theme/cfwl_widgettp.h" + +class CFWL_ScrollBarTP : public CFWL_WidgetTP { + public: + CFWL_ScrollBarTP(); + virtual ~CFWL_ScrollBarTP(); + virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); + virtual uint32_t SetThemeID(IFWL_Widget* pWidget, + uint32_t dwThemeID, + FX_BOOL bChildren = TRUE); + virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); + virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity); + + protected: + struct SBThemeData { + FX_ARGB clrPawColorLight[4]; + FX_ARGB clrPawColorDark[4]; + FX_ARGB clrBtnBK[4][2]; + FX_ARGB clrBtnBorder[4]; + FX_ARGB clrTrackBKStart; + FX_ARGB clrTrackBKEnd; + }; + + void DrawThumbBtn(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FX_BOOL bVert, + FWLTHEME_STATE eState, + FX_BOOL bPawButton = TRUE, + CFX_Matrix* pMatrix = NULL); + void DrawTrack(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FX_BOOL bVert, + FWLTHEME_STATE eState, + FX_BOOL bLowerTrack, + CFX_Matrix* pMatrix = NULL); + void DrawMaxMinBtn(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_DIRECTION eDict, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix = NULL); + void DrawPaw(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FX_BOOL bVert, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix = NULL); + void SetThemeData(uint32_t dwID); + + struct SBThemeData* m_pThemeData; +}; + +#endif // XFA_FWL_THEME_CFWL_SCROLLBARTP_H_ diff --git a/xfa/fwl/theme/cfwl_utils.h b/xfa/fwl/theme/cfwl_utils.h new file mode 100644 index 0000000000..d530b7631b --- /dev/null +++ b/xfa/fwl/theme/cfwl_utils.h @@ -0,0 +1,75 @@ +// 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_THEME_CFWL_UTILS_H_ +#define XFA_FWL_THEME_CFWL_UTILS_H_ + +#include "core/fxcrt/include/fx_system.h" + +#define THEME_XPSimilar +enum FWLTHEME_EDGE { + FWLTHEME_EDGE_Flat = 0, + FWLTHEME_EDGE_Raised, + FWLTHEME_EDGE_Sunken +}; +enum FWLTHEME_STATE { + FWLTHEME_STATE_Normal = 1, + FWLTHEME_STATE_Hover, + FWLTHEME_STATE_Pressed, + FWLTHEME_STATE_Disabale +}; +enum FWLTHEME_DIRECTION { + FWLTHEME_DIRECTION_Up = 0, + FWLTHEME_DIRECTION_Down, + FWLTHEME_DIRECTION_Left, + FWLTHEME_DIRECTION_Right +}; +struct FWLCOLOR { + union { + uint32_t color; + struct { + uint8_t b; + uint8_t g; + uint8_t r; + uint8_t a; + }; + }; + + FWLCOLOR() : color(0) {} + FWLCOLOR(uint32_t c) : color(c) {} + FWLCOLOR(const FWLCOLOR& c) : color(c.color) {} + + bool operator==(const FWLCOLOR& frColor) { return color == frColor.color; } + operator uint32_t() { return color; } +}; +#define FWLTHEME_BEZIER FX_BEZIER +#define FWLTHEME_PI FX_PI +#define FWLTHEME_PI_2_1 (FX_PI / 2.0f) +#define FWLTHEME_PI_2_3 (3.0f * FX_PI / 2.0f) +#define FWLTHEME_COLOR_EDGELT1 (ArgbEncode(255, 172, 168, 153)) +#define FWLTHEME_COLOR_EDGELT2 (ArgbEncode(255, 113, 111, 100)) +#define FWLTHEME_COLOR_EDGERB1 (ArgbEncode(255, 241, 239, 226)) +#define FWLTHEME_COLOR_EDGERB2 (ArgbEncode(255, 255, 255, 255)) +#define FWLTHEME_COLOR_Background (ArgbEncode(255, 236, 233, 216)) +#define FWLTHEME_COLOR_BKSelected (ArgbEncode(255, 153, 193, 218)) +#define FWLTHEME_COLOR_Green_BKSelected (ArgbEncode(255, 147, 160, 112)) +#ifdef THEME_XPSimilar +#define FWLTHEME_CAPACITY_EdgeFlat 2.0f +#else +#define FWLTHEME_CAPACITY_EdgeFlat 0.0f +#endif +#define FWLTHEME_CAPACITY_EdgeRaised 2.0f +#define FWLTHEME_CAPACITY_EdgeSunken 2.0f +#define FWLTHEME_CAPACITY_FontSize 12.0f +#define FWLTHEME_CAPACITY_LineHeight 12.0f +#define FWLTHEME_CAPACITY_TextColor (ArgbEncode(255, 0, 0, 0)) +#define FWLTHEME_CAPACITY_TextSelColor (ArgbEncode(255, 153, 193, 218)) +#define FWLTHEME_CAPACITY_TextDisColor (ArgbEncode(255, 172, 168, 153)) +#define FWLTHEME_CAPACITY_ScrollBarWidth 17.0f +#define FWLTHEME_CAPACITY_CXBorder 1.0f +#define FWLTHEME_CAPACITY_CYBorder 1.0f + +#endif // XFA_FWL_THEME_CFWL_UTILS_H_ diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp new file mode 100644 index 0000000000..7aaaf40454 --- /dev/null +++ b/xfa/fwl/theme/cfwl_widgettp.cpp @@ -0,0 +1,846 @@ +// 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/theme/cfwl_widgettp.h" + +#include + +#include "xfa/fde/tto/fde_textout.h" +#include "xfa/fwl/core/cfwl_themebackground.h" +#include "xfa/fwl/core/cfwl_themepart.h" +#include "xfa/fwl/core/cfwl_themetext.h" +#include "xfa/fwl/core/ifwl_themeprovider.h" +#include "xfa/fwl/core/ifwl_widgetmgr.h" +#include "xfa/fxgraphics/cfx_color.h" +#include "xfa/fxgraphics/cfx_path.h" +#include "xfa/fxgraphics/cfx_shading.h" + +static void FWL_SetChildThemeID(IFWL_Widget* pParent, uint32_t dwThemeID) { + IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr(); + IFWL_Widget* pChild = + pWidgetMgr->GetWidget(pParent, FWL_WGTRELATION_FirstChild); + while (pChild) { + IFWL_ThemeProvider* pTheme = pChild->GetThemeProvider(); + if (pTheme) { + pTheme->SetThemeID(pChild, dwThemeID, FALSE); + } + FWL_SetChildThemeID(pChild, dwThemeID); + pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling); + } +} +FX_BOOL CFWL_WidgetTP::IsValidWidget(IFWL_Widget* pWidget) { + return FALSE; +} +uint32_t CFWL_WidgetTP::GetThemeID(IFWL_Widget* pWidget) { + return m_dwThemeID; +} +uint32_t CFWL_WidgetTP::SetThemeID(IFWL_Widget* pWidget, + uint32_t dwThemeID, + FX_BOOL bChildren) { + uint32_t dwOld = m_dwThemeID; + m_dwThemeID = dwThemeID; + if (CFWL_ArrowData::IsInstance()) { + CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(dwThemeID)); + } + if (bChildren) { + FWL_SetChildThemeID(pWidget, dwThemeID); + } + return dwOld; +} +FWL_ERR CFWL_WidgetTP::GetThemeMatrix(IFWL_Widget* pWidget, + CFX_Matrix& matrix) { + matrix.Set(_ctm.a, _ctm.b, _ctm.c, _ctm.d, _ctm.e, _ctm.f); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_WidgetTP::SetThemeMatrix(IFWL_Widget* pWidget, + const CFX_Matrix& matrix) { + _ctm.Set(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f); + return FWL_ERR_Succeeded; +} +FX_BOOL CFWL_WidgetTP::DrawBackground(CFWL_ThemeBackground* pParams) { + return TRUE; +} +FX_BOOL CFWL_WidgetTP::DrawText(CFWL_ThemeText* pParams) { + if (!m_pTextOut) { + InitTTO(); + } + int32_t iLen = pParams->m_wsText.GetLength(); + if (iLen <= 0) + return FALSE; + CFX_Graphics* pGraphics = pParams->m_pGraphics; + m_pTextOut->SetRenderDevice(pGraphics->GetRenderDevice()); + m_pTextOut->SetStyles(pParams->m_dwTTOStyles); + m_pTextOut->SetAlignment(pParams->m_iTTOAlign); + CFX_Matrix* pMatrix = &pParams->m_matrix; + pMatrix->Concat(*pGraphics->GetMatrix()); + m_pTextOut->SetMatrix(*pMatrix); + m_pTextOut->DrawLogicText(pParams->m_wsText, iLen, pParams->m_rtPart); + return TRUE; +} +void* CFWL_WidgetTP::GetCapacity(CFWL_ThemePart* pThemePart, + uint32_t dwCapacity) { + switch (dwCapacity) { + case FWL_WGTCAPACITY_CXBorder: { + m_fValue = FWLTHEME_CAPACITY_CXBorder; + break; + } + case FWL_WGTCAPACITY_CYBorder: { + m_fValue = FWLTHEME_CAPACITY_CYBorder; + break; + } + case FWL_WGTCAPACITY_EdgeFlat: { + m_fValue = FWLTHEME_CAPACITY_EdgeFlat; + break; + } + case FWL_WGTCAPACITY_EdgeRaised: { + m_fValue = FWLTHEME_CAPACITY_EdgeRaised; + break; + } + case FWL_WGTCAPACITY_EdgeSunken: { + m_fValue = FWLTHEME_CAPACITY_EdgeSunken; + break; + } + case FWL_WGTCAPACITY_FontSize: { + m_fValue = FWLTHEME_CAPACITY_FontSize; + break; + } + case FWL_WGTCAPACITY_TextColor: { + m_dwValue = FWLTHEME_CAPACITY_TextColor; + return &m_dwValue; + } + case FWL_WGTCAPACITY_ScrollBarWidth: { + m_fValue = FWLTHEME_CAPACITY_ScrollBarWidth; + break; + } + case FWL_WGTCAPACITY_Font: { + return m_pFDEFont; + } + case FWL_WGTCAPACITY_TextSelColor: { + m_dwValue = (m_dwThemeID == 0) ? FWLTHEME_CAPACITY_TextSelColor + : FWLTHEME_COLOR_Green_BKSelected; + return &m_dwValue; + } + case FWL_WGTCAPACITY_LineHeight: { + m_fValue = FWLTHEME_CAPACITY_LineHeight; + break; + } + case FWL_WGTCAPACITY_UIMargin: { + m_rtMargin.Set(0, 0, 0, 0); + return &m_rtMargin; + } + default: { return NULL; } + } + return &m_fValue; +} +FX_BOOL CFWL_WidgetTP::IsCustomizedLayout(IFWL_Widget* pWidget) { + return FWL_GetThemeLayout(m_dwThemeID); +} +FWL_ERR CFWL_WidgetTP::GetPartRect(CFWL_ThemePart* pThemePart, + CFX_RectF& rect) { + return FWL_ERR_Succeeded; +} +FX_BOOL CFWL_WidgetTP::IsInPart(CFWL_ThemePart* pThemePart, + FX_FLOAT fx, + FX_FLOAT fy) { + return TRUE; +} +FX_BOOL CFWL_WidgetTP::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { + if (!pParams) + return FALSE; + if (!m_pTextOut) + return FALSE; + m_pTextOut->SetAlignment(pParams->m_iTTOAlign); + m_pTextOut->SetStyles(pParams->m_dwTTOStyles | FDE_TTOSTYLE_ArabicContext); + m_pTextOut->CalcLogicSize(pParams->m_wsText, pParams->m_wsText.GetLength(), + rect); + return TRUE; +} +FWL_ERR CFWL_WidgetTP::Initialize() { + m_dwThemeID = 0; + _ctm.SetIdentity(); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_WidgetTP::Finalize() { + if (!m_pTextOut) { + FinalizeTTO(); + } + return FWL_ERR_Succeeded; +} +CFWL_WidgetTP::~CFWL_WidgetTP() {} +FWL_ERR CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, + const FX_WCHAR* strFont, + FX_FLOAT fFontSize, + FX_ARGB rgbFont) { + if (!m_pTextOut) { + return FWL_ERR_Succeeded; + } + m_pFDEFont = CFWL_FontManager::GetInstance()->FindFont(strFont, 0, 0); + m_pTextOut->SetFont(m_pFDEFont); + m_pTextOut->SetFontSize(fFontSize); + m_pTextOut->SetTextColor(rgbFont); + return FWL_ERR_Succeeded; +} +FWL_ERR CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, + IFX_Font* pFont, + FX_FLOAT fFontSize, + FX_ARGB rgbFont) { + if (!m_pTextOut) { + return FWL_ERR_Succeeded; + } + m_pTextOut->SetFont(pFont); + m_pTextOut->SetFontSize(fFontSize); + m_pTextOut->SetTextColor(rgbFont); + return FWL_ERR_Succeeded; +} +IFX_Font* CFWL_WidgetTP::GetFont(IFWL_Widget* pWidget) { + return m_pFDEFont; +} +CFWL_WidgetTP::CFWL_WidgetTP() + : m_dwRefCount(1), m_pTextOut(NULL), m_pFDEFont(NULL), m_dwThemeID(0) {} +FX_ERR CFWL_WidgetTP::InitTTO() { + if (m_pTextOut) { + return FWL_ERR_Succeeded; + } + m_pFDEFont = + CFWL_FontManager::GetInstance()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0); + m_pTextOut = IFDE_TextOut::Create(); + m_pTextOut->SetFont(m_pFDEFont); + m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); + m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); + m_pTextOut->SetEllipsisString(L"..."); + return FWL_ERR_Succeeded; +} +FX_ERR CFWL_WidgetTP::FinalizeTTO() { + if (m_pTextOut) { + m_pTextOut->Release(); + m_pTextOut = NULL; + } + return FWL_ERR_Succeeded; +} +#ifdef THEME_XPSimilar +void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, + uint32_t dwStyles, + const CFX_RectF* pRect, + CFX_Matrix* pMatrix) { + if (!pGraphics) + return; + if (!pRect) + return; + pGraphics->SaveGraphState(); + CFX_Color crStroke(FWL_GetThemeColor(m_dwThemeID) == 0 + ? ArgbEncode(255, 127, 157, 185) + : FWLTHEME_COLOR_Green_BKSelected); + pGraphics->SetStrokeColor(&crStroke); + CFX_Path path; + path.Create(); + path.AddRectangle(pRect->left, pRect->top, pRect->width - 1, + pRect->height - 1); + pGraphics->StrokePath(&path, pMatrix); + path.Clear(); + crStroke = ArgbEncode(255, 255, 255, 255); + pGraphics->SetStrokeColor(&crStroke); + path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 3, + pRect->height - 3); + pGraphics->StrokePath(&path, pMatrix); + pGraphics->RestoreGraphState(); +} +#else +void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, + uint32_t dwStyles, + const CFX_RectF* pRect, + CFX_Matrix* pMatrix) { + if (!pGraphics) + return; + if (!pRect) + return; + FWLTHEME_EDGE eType; + FX_FLOAT fWidth; + switch (dwStyles & FWL_WGTSTYLE_EdgeMask) { + case FWL_WGTSTYLE_EdgeRaised: { + eType = FWLTHEME_EDGE_Raised, fWidth = FWLTHEME_CAPACITY_EdgeRaised; + break; + } + case FWL_WGTSTYLE_EdgeSunken: { + eType = FWLTHEME_EDGE_Sunken, fWidth = FWLTHEME_CAPACITY_EdgeSunken; + break; + } + case FWL_WGTSTYLE_EdgeFlat: + default: { return; } + } + Draw3DRect(pGraphics, eType, fWidth, pRect, FWLTHEME_COLOR_EDGELT1, + FWLTHEME_COLOR_EDGELT2, FWLTHEME_COLOR_EDGERB1, + FWLTHEME_COLOR_EDGERB2, pMatrix); +} +#endif +void CFWL_WidgetTP::Draw3DRect(CFX_Graphics* pGraphics, + FWLTHEME_EDGE eType, + FX_FLOAT fWidth, + const CFX_RectF* pRect, + FX_ARGB cr1, + FX_ARGB cr2, + FX_ARGB cr3, + FX_ARGB cr4, + CFX_Matrix* pMatrix) { + if (!pGraphics) + return; + if (!pRect) + return; + pGraphics->SaveGraphState(); + if (eType == FWLTHEME_EDGE_Flat) { + CFX_Path path; + path.Create(); + path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); + path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2, + pRect->height - 2); + CFX_Color cr(ArgbEncode(255, 100, 100, 100)); + pGraphics->SetFillColor(&cr); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + path.Clear(); + path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2, + pRect->height - 2); + path.AddRectangle(pRect->left + 2, pRect->top + 2, pRect->width - 4, + pRect->height - 4); + cr.Set(0xFFFFFFFF); + pGraphics->SetFillColor(&cr); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + } else { + FX_FLOAT fLeft = pRect->left; + FX_FLOAT fRight = pRect->right(); + FX_FLOAT fTop = pRect->top; + FX_FLOAT fBottom = pRect->bottom(); + FX_FLOAT fHalfWidth = fWidth / 2.0f; + CFX_Color crLT(eType == FWLTHEME_EDGE_Raised ? cr4 : cr1); + pGraphics->SetFillColor(&crLT); + CFX_Path pathLT; + pathLT.Create(); + pathLT.MoveTo(fLeft, fBottom - fHalfWidth); + pathLT.LineTo(fLeft, fTop); + pathLT.LineTo(fRight - fHalfWidth, fTop); + pathLT.LineTo(fRight - fHalfWidth, fTop + fHalfWidth); + pathLT.LineTo(fLeft + fHalfWidth, fTop + fHalfWidth); + pathLT.LineTo(fLeft + fHalfWidth, fBottom - fHalfWidth); + pathLT.LineTo(fLeft, fBottom - fHalfWidth); + pGraphics->FillPath(&pathLT, FXFILL_WINDING, pMatrix); + crLT = CFX_Color(eType == FWLTHEME_EDGE_Raised ? cr3 : cr2); + pGraphics->SetFillColor(&crLT); + pathLT.Clear(); + pathLT.MoveTo(fLeft + fHalfWidth, fBottom - fWidth); + pathLT.LineTo(fLeft + fHalfWidth, fTop + fHalfWidth); + pathLT.LineTo(fRight - fWidth, fTop + fHalfWidth); + pathLT.LineTo(fRight - fWidth, fTop + fWidth); + pathLT.LineTo(fLeft + fWidth, fTop + fWidth); + pathLT.LineTo(fLeft + fWidth, fBottom - fWidth); + pathLT.LineTo(fLeft + fHalfWidth, fBottom - fWidth); + pGraphics->FillPath(&pathLT, FXFILL_WINDING, pMatrix); + CFX_Color crRB(eType == FWLTHEME_EDGE_Raised ? cr1 : cr3); + pGraphics->SetFillColor(&crRB); + CFX_Path pathRB; + pathRB.Create(); + pathRB.MoveTo(fRight - fHalfWidth, fTop + fHalfWidth); + pathRB.LineTo(fRight - fHalfWidth, fBottom - fHalfWidth); + pathRB.LineTo(fLeft + fHalfWidth, fBottom - fHalfWidth); + pathRB.LineTo(fLeft + fHalfWidth, fBottom - fWidth); + pathRB.LineTo(fRight - fWidth, fBottom - fWidth); + pathRB.LineTo(fRight - fWidth, fTop + fHalfWidth); + pathRB.LineTo(fRight - fHalfWidth, fTop + fHalfWidth); + pGraphics->FillPath(&pathRB, FXFILL_WINDING, pMatrix); + crRB = CFX_Color(eType == FWLTHEME_EDGE_Raised ? cr2 : cr4); + pGraphics->SetFillColor(&crRB); + pathRB.Clear(); + pathRB.MoveTo(fRight, fTop); + pathRB.LineTo(fRight, fBottom); + pathRB.LineTo(fLeft, fBottom); + pathRB.LineTo(fLeft, fBottom - fHalfWidth); + pathRB.LineTo(fRight - fHalfWidth, fBottom - fHalfWidth); + pathRB.LineTo(fRight - fHalfWidth, fTop); + pathRB.LineTo(fRight, fTop); + pGraphics->FillPath(&pathRB, FXFILL_WINDING, pMatrix); + } + pGraphics->RestoreGraphState(); +} +void CFWL_WidgetTP::Draw3DCircle(CFX_Graphics* pGraphics, + FWLTHEME_EDGE eType, + FX_FLOAT fWidth, + const CFX_RectF* pRect, + FX_ARGB cr1, + FX_ARGB cr2, + FX_ARGB cr3, + FX_ARGB cr4, + CFX_Matrix* pMatrix) { + if (!pGraphics) + return; + if (!pRect) + return; + pGraphics->SaveGraphState(); + CFX_Path path; + path.Create(); + path.AddArc(pRect->left, pRect->top, pRect->width, pRect->height, + FWLTHEME_PI * 3 / 4, FWLTHEME_PI); + CFX_Color crFill1(eType == FWLTHEME_EDGE_Raised ? cr4 : cr1); + pGraphics->SetStrokeColor(&crFill1); + pGraphics->StrokePath(&path, pMatrix); + CFX_RectF rtInner(*pRect); + rtInner.Deflate(pRect->width / 4, pRect->height / 4); + path.Clear(); + path.AddArc(rtInner.left, rtInner.top, rtInner.width, rtInner.height, + FWLTHEME_PI * 3 / 4, FWLTHEME_PI); + CFX_Color crFill2(eType == FWLTHEME_EDGE_Raised ? cr3 : cr2); + pGraphics->SetStrokeColor(&crFill2); + pGraphics->StrokePath(&path, pMatrix); + path.Clear(); + path.AddArc(pRect->left, pRect->top, pRect->width, pRect->height, + FWLTHEME_PI * 7 / 4, FWLTHEME_PI); + CFX_Color crFill3(eType == FWLTHEME_EDGE_Raised ? cr1 : cr3); + pGraphics->SetStrokeColor(&crFill3); + pGraphics->StrokePath(&path, pMatrix); + path.AddArc(rtInner.left, rtInner.top, rtInner.width, rtInner.height, + FWLTHEME_PI * 7 / 4, FWLTHEME_PI); + CFX_Color crFill4(eType == FWLTHEME_EDGE_Raised ? cr2 : cr4); + pGraphics->SetStrokeColor(&crFill4); + pGraphics->StrokePath(&path, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_WidgetTP::DrawBorder(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + CFX_Matrix* pMatrix) { + if (!pGraphics) + return; + if (!pRect) + return; + CFX_Path path; + path.Create(); + path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); + path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2, + pRect->height - 2); + pGraphics->SaveGraphState(); + CFX_Color crFill(ArgbEncode(255, 0, 0, 0)); + pGraphics->SetFillColor(&crFill); + pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_WidgetTP::FillBackground(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + CFX_Matrix* pMatrix) { + FillSoildRect(pGraphics, FWLTHEME_COLOR_Background, pRect, pMatrix); +} +void CFWL_WidgetTP::FillSoildRect(CFX_Graphics* pGraphics, + FX_ARGB fillColor, + const CFX_RectF* pRect, + CFX_Matrix* pMatrix) { + if (!pGraphics) + return; + if (!pRect) + return; + pGraphics->SaveGraphState(); + CFX_Color crFill(fillColor); + pGraphics->SetFillColor(&crFill); + CFX_Path path; + path.Create(); + path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_WidgetTP::DrawAxialShading(CFX_Graphics* pGraphics, + FX_FLOAT fx1, + FX_FLOAT fy1, + FX_FLOAT fx2, + FX_FLOAT fy2, + FX_ARGB beginColor, + FX_ARGB endColor, + CFX_Path* path, + int32_t fillMode, + CFX_Matrix* pMatrix) { + if (!pGraphics || !path) + return; + + CFX_PointF begPoint(fx1, fy1); + CFX_PointF endPoint(fx2, fy2); + CFX_Shading shading(begPoint, endPoint, FALSE, FALSE, beginColor, endColor); + pGraphics->SaveGraphState(); + CFX_Color color1(&shading); + pGraphics->SetFillColor(&color1); + pGraphics->FillPath(path, fillMode, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_WidgetTP::DrawAnnulusRect(CFX_Graphics* pGraphics, + FX_ARGB fillColor, + const CFX_RectF* pRect, + FX_FLOAT fRingWidth, + CFX_Matrix* pMatrix) { + if (!pGraphics) + return; + if (!pRect) + return; + pGraphics->SaveGraphState(); + CFX_Color cr(fillColor); + pGraphics->SetFillColor(&cr); + CFX_Path path; + path.Create(); + CFX_RectF rtInner(*pRect); + rtInner.Deflate(fRingWidth, fRingWidth); + path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); + path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); + pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_WidgetTP::DrawAnnulusCircle(CFX_Graphics* pGraphics, + FX_ARGB fillColor, + const CFX_RectF* pRect, + FX_FLOAT fWidth, + CFX_Matrix* pMatrix) { + if (!pGraphics) + return; + if (!pRect) + return; + if (fWidth > pRect->width / 2) { + return; + } + pGraphics->SaveGraphState(); + CFX_Color cr(fillColor); + pGraphics->SetFillColor(&cr); + CFX_Path path; + path.Create(); + path.AddEllipse(*pRect); + CFX_RectF rtIn(*pRect); + rtIn.Inflate(-fWidth, -fWidth); + path.AddEllipse(rtIn); + pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_WidgetTP::DrawFocus(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + CFX_Matrix* pMatrix) { + if (!pGraphics) + return; + if (!pRect) + return; + pGraphics->SaveGraphState(); + CFX_Color cr(0xFF000000); + pGraphics->SetStrokeColor(&cr); + FX_FLOAT DashPattern[2] = {1, 1}; + pGraphics->SetLineDash(0.0f, DashPattern, 2); + CFX_Path path; + path.Create(); + path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); + pGraphics->StrokePath(&path, pMatrix); + pGraphics->RestoreGraphState(); +} +#define FWLTHEME_ARROW_Denominator 3 +void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_DIRECTION eDict, + FX_ARGB argbFill, + FX_BOOL bPressed, + CFX_Matrix* pMatrix) { + CFX_RectF rtArrow(*pRect); + CFX_Path path; + path.Create(); + FX_FLOAT fBtn = + std::min(pRect->width, pRect->height) / FWLTHEME_ARROW_Denominator; + rtArrow.left = pRect->left + (pRect->width - fBtn) / 2; + rtArrow.top = pRect->top + (pRect->height - fBtn) / 2; + rtArrow.width = fBtn; + rtArrow.height = fBtn; + if (bPressed) { + rtArrow.Offset(1, 1); + } + switch (eDict) { + case FWLTHEME_DIRECTION_Up: { + path.MoveTo(rtArrow.left, rtArrow.bottom()); + path.LineTo(rtArrow.right(), rtArrow.bottom()); + path.LineTo(rtArrow.left + fBtn / 2, rtArrow.top); + path.LineTo(rtArrow.left, rtArrow.bottom()); + break; + } + case FWLTHEME_DIRECTION_Left: { + path.MoveTo(rtArrow.right(), rtArrow.top); + path.LineTo(rtArrow.right(), rtArrow.bottom()); + path.LineTo(rtArrow.left, rtArrow.top + fBtn / 2); + path.LineTo(rtArrow.right(), rtArrow.top); + break; + } + case FWLTHEME_DIRECTION_Right: { + path.MoveTo(rtArrow.left, rtArrow.top); + path.LineTo(rtArrow.left, rtArrow.bottom()); + path.LineTo(rtArrow.right(), rtArrow.top + fBtn / 2); + path.LineTo(rtArrow.left, rtArrow.top); + break; + } + case FWLTHEME_DIRECTION_Down: + default: { + path.MoveTo(rtArrow.left, rtArrow.top); + path.LineTo(rtArrow.right(), rtArrow.top); + path.LineTo(rtArrow.left + fBtn / 2, rtArrow.bottom()); + path.LineTo(rtArrow.left, rtArrow.top); + } + } + pGraphics->SaveGraphState(); + CFX_Color cr(argbFill); + pGraphics->SetFillColor(&cr); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); + pGraphics->RestoreGraphState(); +} +void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_DIRECTION eDict, + FX_ARGB argSign, + CFX_Matrix* pMatrix) { + FX_BOOL bVert = + (eDict == FWLTHEME_DIRECTION_Up || eDict == FWLTHEME_DIRECTION_Down); + FX_FLOAT fLeft = + (FX_FLOAT)(((pRect->width - (bVert ? 9 : 6)) / 2 + pRect->left) + 0.5); + FX_FLOAT fTop = + (FX_FLOAT)(((pRect->height - (bVert ? 6 : 9)) / 2 + pRect->top) + 0.5); + CFX_Path path; + path.Create(); + switch (eDict) { + case FWLTHEME_DIRECTION_Down: { + path.MoveTo(fLeft, fTop + 1); + path.LineTo(fLeft + 4, fTop + 5); + path.LineTo(fLeft + 8, fTop + 1); + path.LineTo(fLeft + 7, fTop); + path.LineTo(fLeft + 4, fTop + 3); + path.LineTo(fLeft + 1, fTop); + break; + } + case FWLTHEME_DIRECTION_Up: { + path.MoveTo(fLeft, fTop + 4); + path.LineTo(fLeft + 4, fTop); + path.LineTo(fLeft + 8, fTop + 4); + path.LineTo(fLeft + 7, fTop + 5); + path.LineTo(fLeft + 4, fTop + 2); + path.LineTo(fLeft + 1, fTop + 5); + break; + } + case FWLTHEME_DIRECTION_Right: { + path.MoveTo(fLeft + 1, fTop); + path.LineTo(fLeft + 5, fTop + 4); + path.LineTo(fLeft + 1, fTop + 8); + path.LineTo(fLeft, fTop + 7); + path.LineTo(fLeft + 3, fTop + 4); + path.LineTo(fLeft, fTop + 1); + break; + } + case FWLTHEME_DIRECTION_Left: { + path.MoveTo(fLeft, fTop + 4); + path.LineTo(fLeft + 4, fTop); + path.LineTo(fLeft + 5, fTop + 1); + path.LineTo(fLeft + 2, fTop + 4); + path.LineTo(fLeft + 5, fTop + 7); + path.LineTo(fLeft + 4, fTop + 8); + break; + } + } + CFX_Color cr(argSign); + pGraphics->SetFillColor(&cr); + pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); +} +void CFWL_WidgetTP::DrawBtn(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix) { + CFX_Path path; + path.Create(); + if (!CFWL_ArrowData::IsInstance()) { + CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(m_dwThemeID)); + } + CFWL_ArrowData::CColorData* pColorData = + CFWL_ArrowData::GetInstance()->m_pColorData; + FX_FLOAT fRight = pRect->right(); + FX_FLOAT fBottom = pRect->bottom(); + path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); + DrawAxialShading(pGraphics, pRect->left, pRect->top, fRight, fBottom, + pColorData->clrStart[eState - 1], + pColorData->clrEnd[eState - 1], &path, FXFILL_WINDING, + pMatrix); + CFX_Color rcStroke; + rcStroke.Set(pColorData->clrBorder[eState - 1]); + pGraphics->SetStrokeColor(&rcStroke); + pGraphics->StrokePath(&path, pMatrix); +} +void CFWL_WidgetTP::DrawArrowBtn(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_DIRECTION eDict, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix) { + DrawBtn(pGraphics, pRect, eState, pMatrix); + if (!CFWL_ArrowData::IsInstance()) { + CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(m_dwThemeID)); + } + CFWL_ArrowData::CColorData* pColorData = + CFWL_ArrowData::GetInstance()->m_pColorData; + DrawArrow(pGraphics, pRect, eDict, pColorData->clrSign[eState - 1], pMatrix); +} +FWLCOLOR CFWL_WidgetTP::BlendColor(FWLCOLOR srcColor, + FWLCOLOR renderColor, + uint8_t scale) { + FWLCOLOR dstColor; + uint8_t n = 255 - scale; + dstColor.a = (uint8_t)( + ((uint16_t)srcColor.a * n + (uint16_t)renderColor.a * scale) >> 8); + dstColor.r = (uint8_t)( + ((uint16_t)srcColor.r * n + (uint16_t)renderColor.r * scale) >> 8); + dstColor.g = (uint8_t)( + ((uint16_t)srcColor.g * n + (uint16_t)renderColor.g * scale) >> 8); + dstColor.b = (uint8_t)( + ((uint16_t)srcColor.b * n + (uint16_t)renderColor.b * scale) >> 8); + return dstColor; +} +CFWL_ArrowData::CFWL_ArrowData() : m_pColorData(NULL) { + SetColorData(0); +} +CFWL_FontData::CFWL_FontData() + : m_dwStyles(0), + m_dwCodePage(0), + m_pFont(0), + m_pFontMgr(NULL) +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + , + m_pFontSource(NULL) +#endif +{ +} +CFWL_FontData::~CFWL_FontData() { + if (m_pFont) { + m_pFont->Release(); + } + if (m_pFontMgr) { + m_pFontMgr->Release(); + } +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + if (m_pFontSource != NULL) { + m_pFontSource->Release(); + } +#endif +} +FX_BOOL CFWL_FontData::Equal(const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage) { + return m_wsFamily == wsFontFamily && m_dwStyles == dwFontStyles && + m_dwCodePage == wCodePage; +} +FX_BOOL CFWL_FontData::LoadFont(const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t dwCodePage) { + m_wsFamily = wsFontFamily; + m_dwStyles = dwFontStyles; + m_dwCodePage = dwCodePage; + if (!m_pFontMgr) { +#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ + m_pFontMgr = IFX_FontMgr::Create(FX_GetDefFontEnumerator()); +#else + m_pFontSource = FX_CreateDefaultFontSourceEnum(); + m_pFontMgr = IFX_FontMgr::Create(m_pFontSource); +#endif + } + m_pFont = IFX_Font::LoadFont(wsFontFamily.GetPtr(), dwFontStyles, dwCodePage, + m_pFontMgr); + return m_pFont != NULL; +} + +CFWL_FontManager* CFWL_FontManager::s_FontManager = nullptr; +CFWL_FontManager* CFWL_FontManager::GetInstance() { + if (!s_FontManager) + s_FontManager = new CFWL_FontManager; + return s_FontManager; +} +void CFWL_FontManager::DestroyInstance() { + delete s_FontManager; + s_FontManager = nullptr; +} +CFWL_FontManager::CFWL_FontManager() {} +CFWL_FontManager::~CFWL_FontManager() {} +IFX_Font* CFWL_FontManager::FindFont(const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage) { + for (const auto& pData : m_FontsArray) { + if (pData->Equal(wsFontFamily, dwFontStyles, wCodePage)) + return pData->GetFont(); + } + std::unique_ptr pFontData(new CFWL_FontData); + if (!pFontData->LoadFont(wsFontFamily, dwFontStyles, wCodePage)) + return nullptr; + m_FontsArray.push_back(std::move(pFontData)); + return m_FontsArray.back()->GetFont(); +} +FX_BOOL FWLTHEME_Init() { + return TRUE; +} +void FWLTHEME_Release() { + CFWL_ArrowData::DestroyInstance(); + CFWL_FontManager::DestroyInstance(); +} +uint32_t FWL_GetThemeLayout(uint32_t dwThemeID) { + return 0xffff0000 & dwThemeID; +} +uint32_t FWL_GetThemeColor(uint32_t dwThemeID) { + return 0x0000ffff & dwThemeID; +} +uint32_t FWL_MakeThemeID(uint32_t dwLayout, uint32_t dwColor) { + return (dwLayout << 16) | (0x0000FFFF & dwColor); +} +CFWL_ArrowData* CFWL_ArrowData::m_pInstance = NULL; +CFWL_ArrowData* CFWL_ArrowData::GetInstance() { + if (!m_pInstance) { + m_pInstance = new CFWL_ArrowData; + } + return m_pInstance; +} +FX_BOOL CFWL_ArrowData::IsInstance() { + return (m_pInstance != NULL); +} +void CFWL_ArrowData::DestroyInstance() { + if (m_pInstance) { + delete m_pInstance; + m_pInstance = NULL; + } +} +CFWL_ArrowData::~CFWL_ArrowData() { + if (m_pColorData) { + delete m_pColorData; + m_pColorData = NULL; + } +} +void CFWL_ArrowData::SetColorData(uint32_t dwID) { + if (!m_pColorData) { + m_pColorData = new CColorData; + } + if (dwID) { + m_pColorData->clrBorder[0] = ArgbEncode(255, 142, 153, 125); + m_pColorData->clrBorder[1] = ArgbEncode(255, 157, 171, 119); + m_pColorData->clrBorder[2] = ArgbEncode(255, 118, 131, 97); + m_pColorData->clrBorder[3] = ArgbEncode(255, 172, 168, 153); + m_pColorData->clrStart[0] = ArgbEncode(255, 203, 215, 186); + m_pColorData->clrStart[1] = ArgbEncode(255, 218, 232, 185); + m_pColorData->clrStart[2] = ArgbEncode(255, 203, 215, 186); + m_pColorData->clrStart[3] = ArgbEncode(255, 254, 254, 251); + m_pColorData->clrEnd[0] = ArgbEncode(255, 149, 167, 117); + m_pColorData->clrEnd[1] = ArgbEncode(255, 198, 211, 155); + m_pColorData->clrEnd[2] = ArgbEncode(255, 149, 167, 117); + m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236); + m_pColorData->clrSign[0] = ArgbEncode(255, 255, 255, 255); + m_pColorData->clrSign[1] = ArgbEncode(255, 255, 255, 255); + m_pColorData->clrSign[2] = ArgbEncode(255, 255, 255, 255); + m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128); + } else { + m_pColorData->clrBorder[0] = ArgbEncode(255, 202, 216, 249); + m_pColorData->clrBorder[1] = ArgbEncode(255, 171, 190, 233); + m_pColorData->clrBorder[2] = ArgbEncode(255, 135, 147, 219); + m_pColorData->clrBorder[3] = ArgbEncode(255, 172, 168, 153); + m_pColorData->clrStart[0] = ArgbEncode(255, 225, 234, 254); + m_pColorData->clrStart[1] = ArgbEncode(255, 253, 255, 255); + m_pColorData->clrStart[2] = ArgbEncode(255, 110, 142, 241); + m_pColorData->clrStart[3] = ArgbEncode(255, 254, 254, 251); + m_pColorData->clrEnd[0] = ArgbEncode(255, 175, 204, 251); + m_pColorData->clrEnd[1] = ArgbEncode(255, 185, 218, 251); + m_pColorData->clrEnd[2] = ArgbEncode(255, 210, 222, 235); + m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236); + m_pColorData->clrSign[0] = ArgbEncode(255, 77, 97, 133); + m_pColorData->clrSign[1] = ArgbEncode(255, 77, 97, 133); + m_pColorData->clrSign[2] = ArgbEncode(255, 77, 97, 133); + m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128); + } +} diff --git a/xfa/fwl/theme/cfwl_widgettp.h b/xfa/fwl/theme/cfwl_widgettp.h new file mode 100644 index 0000000000..03d575a1d9 --- /dev/null +++ b/xfa/fwl/theme/cfwl_widgettp.h @@ -0,0 +1,220 @@ +// 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_THEME_CFWL_WIDGETTP_H_ +#define XFA_FWL_THEME_CFWL_WIDGETTP_H_ + +#include +#include + +#include "core/fxcrt/include/fx_coordinates.h" +#include "core/fxcrt/include/fx_system.h" +#include "xfa/fwl/core/fwl_error.h" +#include "xfa/fxgraphics/include/cfx_graphics.h" +#include "xfa/fwl/theme/cfwl_utils.h" + +class IFWL_Widget; +class IFDE_TextOut; +class IFX_Font; +class IFX_FontMgr; +class CFWL_ArrowData; +class CFWL_ThemeBackground; +class CFWL_ThemePart; +class CFWL_ThemeText; + +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ +class IFX_FontSourceEnum; +#endif + +class CFWL_WidgetTP { + public: + virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); + virtual uint32_t GetThemeID(IFWL_Widget* pWidget); + virtual uint32_t SetThemeID(IFWL_Widget* pWidget, + uint32_t dwThemeID, + FX_BOOL bChildren = TRUE); + virtual FWL_ERR GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix); + virtual FWL_ERR SetThemeMatrix(IFWL_Widget* pWidget, + const CFX_Matrix& matrix); + virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); + virtual FX_BOOL DrawText(CFWL_ThemeText* pParams); + virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity); + virtual FX_BOOL IsCustomizedLayout(IFWL_Widget* pWidget); + virtual FWL_ERR GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart); + virtual FX_BOOL IsInPart(CFWL_ThemePart* pThemePart, + FX_FLOAT fx, + FX_FLOAT fy); + virtual FX_BOOL CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect); + virtual FWL_ERR Initialize(); + virtual FWL_ERR Finalize(); + virtual ~CFWL_WidgetTP(); + FWL_ERR SetFont(IFWL_Widget* pWidget, + const FX_WCHAR* strFont, + FX_FLOAT fFontSize, + FX_ARGB rgbFont); + FWL_ERR SetFont(IFWL_Widget* pWidget, + IFX_Font* pFont, + FX_FLOAT fFontSize, + FX_ARGB rgbFont); + IFX_Font* GetFont(IFWL_Widget* pWidget); + + protected: + CFWL_WidgetTP(); + FX_ERR InitTTO(); + FX_ERR FinalizeTTO(); + void DrawEdge(CFX_Graphics* pGraphics, + uint32_t dwStyles, + const CFX_RectF* pRect, + CFX_Matrix* pMatrix = NULL); + void Draw3DRect(CFX_Graphics* pGraphics, + FWLTHEME_EDGE eType, + FX_FLOAT fWidth, + const CFX_RectF* pRect, + FX_ARGB cr1, + FX_ARGB cr2, + FX_ARGB cr3, + FX_ARGB cr4, + CFX_Matrix* pMatrix = NULL); + void Draw3DCircle(CFX_Graphics* pGraphics, + FWLTHEME_EDGE eType, + FX_FLOAT fWidth, + const CFX_RectF* pRect, + FX_ARGB cr1, + FX_ARGB cr2, + FX_ARGB cr3, + FX_ARGB cr4, + CFX_Matrix* pMatrix = NULL); + void DrawBorder(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + CFX_Matrix* pMatrix = NULL); + void FillBackground(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + CFX_Matrix* pMatrix = NULL); + void FillSoildRect(CFX_Graphics* pGraphics, + FX_ARGB fillColor, + const CFX_RectF* pRect, + CFX_Matrix* pMatrix = NULL); + void DrawAxialShading(CFX_Graphics* pGraphics, + FX_FLOAT fx1, + FX_FLOAT fy1, + FX_FLOAT fx2, + FX_FLOAT fy2, + FX_ARGB beginColor, + FX_ARGB endColor, + CFX_Path* path, + int32_t fillMode = FXFILL_WINDING, + CFX_Matrix* pMatrix = NULL); + void DrawAnnulusRect(CFX_Graphics* pGraphics, + FX_ARGB fillColor, + const CFX_RectF* pRect, + FX_FLOAT fRingWidth = 1, + CFX_Matrix* pMatrix = NULL); + void DrawAnnulusCircle(CFX_Graphics* pGraphics, + FX_ARGB fillColor, + const CFX_RectF* pRect, + FX_FLOAT fWidth = 1, + CFX_Matrix* pMatrix = NULL); + void DrawFocus(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + CFX_Matrix* pMatrix = NULL); + void DrawArrow(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_DIRECTION eDict, + FX_ARGB argbFill, + FX_BOOL bPressed, + CFX_Matrix* pMatrix = NULL); + void DrawArrow(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_DIRECTION eDict, + FX_ARGB argSign, + CFX_Matrix* pMatrix = NULL); + void DrawBtn(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix = NULL); + void DrawArrowBtn(CFX_Graphics* pGraphics, + const CFX_RectF* pRect, + FWLTHEME_DIRECTION eDict, + FWLTHEME_STATE eState, + CFX_Matrix* pMatrix = NULL); + FWLCOLOR BlendColor(FWLCOLOR srcColor, FWLCOLOR renderColor, uint8_t scale); + uint32_t m_dwRefCount; + IFDE_TextOut* m_pTextOut; + IFX_Font* m_pFDEFont; + FX_FLOAT m_fValue; + uint32_t m_dwValue; + CFX_RectF m_rtMargin; + uint32_t m_dwThemeID; + CFX_Matrix _ctm; +}; +FX_BOOL FWLTHEME_Init(); +void FWLTHEME_Release(); +uint32_t FWL_GetThemeLayout(uint32_t dwThemeID); +uint32_t FWL_GetThemeColor(uint32_t dwThemeID); +uint32_t FWL_MakeThemeID(uint32_t dwLayout, uint32_t dwColor); + +class CFWL_ArrowData { + public: + static CFWL_ArrowData* GetInstance(); + static FX_BOOL IsInstance(); + static void DestroyInstance(); + virtual ~CFWL_ArrowData(); + void SetColorData(uint32_t dwID); + + class CColorData { + public: + FX_ARGB clrBorder[4]; + FX_ARGB clrStart[4]; + FX_ARGB clrEnd[4]; + FX_ARGB clrSign[4]; + } * m_pColorData; + + protected: + CFWL_ArrowData(); + static CFWL_ArrowData* m_pInstance; +}; + +class CFWL_FontData { + public: + CFWL_FontData(); + virtual ~CFWL_FontData(); + FX_BOOL Equal(const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage); + FX_BOOL LoadFont(const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t wCodePage); + IFX_Font* GetFont() const { return m_pFont; } + + protected: + CFX_WideString m_wsFamily; + uint32_t m_dwStyles; + uint32_t m_dwCodePage; + IFX_Font* m_pFont; + IFX_FontMgr* m_pFontMgr; +#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ + IFX_FontSourceEnum* m_pFontSource; +#endif +}; + +class CFWL_FontManager { + public: + static CFWL_FontManager* GetInstance(); + static void DestroyInstance(); + + IFX_Font* FindFont(const CFX_WideStringC& wsFontFamily, + uint32_t dwFontStyles, + uint16_t dwCodePage); + + protected: + CFWL_FontManager(); + virtual ~CFWL_FontManager(); + + static CFWL_FontManager* s_FontManager; + std::vector> m_FontsArray; +}; + +#endif // XFA_FWL_THEME_CFWL_WIDGETTP_H_ diff --git a/xfa/fwl/theme/checkboxtp.cpp b/xfa/fwl/theme/checkboxtp.cpp deleted file mode 100644 index ee485fb7ac..0000000000 --- a/xfa/fwl/theme/checkboxtp.cpp +++ /dev/null @@ -1,536 +0,0 @@ -// 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/include/fwl/theme/checkboxtp.h" - -#include "xfa/fde/tto/fde_textout.h" -#include "xfa/fwl/basewidget/ifwl_checkbox.h" -#include "xfa/fwl/core/cfwl_themebackground.h" -#include "xfa/fwl/core/cfwl_themetext.h" -#include "xfa/fwl/core/ifwl_widget.h" -#include "xfa/fxgraphics/cfx_color.h" -#include "xfa/fxgraphics/cfx_path.h" - -#define CHECKBOX_SIZE_SIGNMARGIN 3 -#define CHECKBOX_SIZE_SIGNBORDER 2 -#define CHECKBOX_SIZE_SIGNPATH 100 -#define CHECKBOX_COLOR_BOXLT1 (ArgbEncode(255, 172, 168, 153)) -#define CHECKBOX_COLOR_BOXLT2 (ArgbEncode(255, 113, 111, 100)) -#define CHECKBOX_COLOR_BOXRB1 (ArgbEncode(255, 241, 239, 226)) -#define CHECKBOX_COLOR_BOXRB2 (ArgbEncode(255, 255, 255, 255)) -#define CHECKBOX_FXGE_CoordinatesAdjust - -CFWL_CheckBoxTP::CFWL_CheckBoxTP() : m_pCheckPath(NULL) { - m_pThemeData = new CKBThemeData; - SetThemeData(0); -} -CFWL_CheckBoxTP::~CFWL_CheckBoxTP() { - if (m_pThemeData) { - delete m_pThemeData; - m_pThemeData = NULL; - } - if (m_pCheckPath) { - m_pCheckPath->Clear(); - delete m_pCheckPath; - m_pCheckPath = NULL; - } -} -FX_BOOL CFWL_CheckBoxTP::IsValidWidget(IFWL_Widget* pWidget) { - return pWidget && pWidget->GetClassID() == FWL_CLASSHASH_CheckBox; -} -uint32_t CFWL_CheckBoxTP::SetThemeID(IFWL_Widget* pWidget, - uint32_t dwThemeID, - FX_BOOL bChildren) { - if (m_pThemeData) { - SetThemeData(FWL_GetThemeColor(dwThemeID)); - } - return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren); -} -FX_BOOL CFWL_CheckBoxTP::DrawText(CFWL_ThemeText* pParams) { - if (!m_pTextOut) - return FALSE; - m_pTextOut->SetTextColor((pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask1) == - FWL_PARTSTATE_CKB_Disabled - ? FWLTHEME_CAPACITY_TextDisColor - : FWLTHEME_CAPACITY_TextColor); - return CFWL_WidgetTP::DrawText(pParams); -} -FX_BOOL CFWL_CheckBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { - if (!pParams) - return FALSE; - switch (pParams->m_iPart) { - case FWL_PART_CKB_Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_CKB_Edge: { - DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), - &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_CKB_Background: { - FillBackground(pParams->m_pGraphics, &pParams->m_rtPart, - &pParams->m_matrix); - if (pParams->m_dwStates & FWL_PARTSTATE_CKB_Focused) { - pParams->m_rtPart = *(CFX_RectF*)pParams->m_pData; - DrawFocus(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); - } - break; - } - case FWL_PART_CKB_CheckBox: { - DrawBoxBk(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart, - pParams->m_dwStates, &pParams->m_matrix); - if (((pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask2) == - FWL_PARTSTATE_CKB_Checked) | - ((pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask2) == - FWL_PARTSTATE_CKB_Neutral)) { - DrawSign(pParams->m_pWidget, pParams->m_pGraphics, &pParams->m_rtPart, - pParams->m_dwStates, &pParams->m_matrix); - } - FX_BOOL bDisable = (pParams->m_dwStates & FWL_PARTSTATE_CKB_Mask1) == - FWL_PARTSTATE_CKB_Disabled; - DrawSignBorder(pParams->m_pWidget, pParams->m_pGraphics, - &pParams->m_rtPart, bDisable, &pParams->m_matrix); - break; - } - default: { return FALSE; } - } - return TRUE; -} -FWL_ERR CFWL_CheckBoxTP::Initialize() { - InitTTO(); - return CFWL_WidgetTP::Initialize(); -} -FWL_ERR CFWL_CheckBoxTP::Finalize() { - FinalizeTTO(); - return CFWL_WidgetTP::Finalize(); -} -void CFWL_CheckBoxTP::DrawBoxBk(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - uint32_t dwStates, - CFX_Matrix* pMatrix) { - dwStates &= 0x03; - int32_t fillMode = FXFILL_WINDING; - uint32_t dwStyleEx = pWidget->GetStylesEx(); - dwStyleEx &= FWL_STYLEEXT_CKB_ShapeMask; - CFX_Path path; - path.Create(); - FX_FLOAT fRight = pRect->right(); - FX_FLOAT fBottom = pRect->bottom(); - FX_BOOL bClipSign = - (dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Hovered; - if ((dwStyleEx == FWL_STYLEEXT_CKB_ShapeSolidSquare) || - (dwStyleEx == FWL_STYLEEXT_CKB_ShapeSunkenSquare)) { - path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); - if (bClipSign) { - fillMode = FXFILL_ALTERNATE; - path.AddRectangle(pRect->left + CHECKBOX_SIZE_SIGNMARGIN, - pRect->top + CHECKBOX_SIZE_SIGNMARGIN, - pRect->width - CHECKBOX_SIZE_SIGNMARGIN * 2, - pRect->height - CHECKBOX_SIZE_SIGNMARGIN * 2); - } - } else { -#ifdef CHECKBOX_FXGE_CoordinatesAdjust - CFX_RectF rect(*pRect); - rect.Deflate(0, 0, 1, 1); - path.AddEllipse(rect); -#else - path.AddEllipse(*pRect); -#endif - if (bClipSign) { - fillMode = FXFILL_ALTERNATE; -#ifdef CHECKBOX_FXGE_CoordinatesAdjust - CFX_RectF rtClip(rect); -#else - CFX_RectF rtClip(*pRect); -#endif - rtClip.Deflate(CHECKBOX_SIZE_SIGNMARGIN - 1, - CHECKBOX_SIZE_SIGNMARGIN - 1); - path.AddEllipse(rtClip); - } - } - int32_t iTheme = 1; - if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Hovered) { - iTheme = 2; - } else if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == - FWL_PARTSTATE_CKB_Pressed) { - iTheme = 3; - } else if ((dwStates & FWL_PARTSTATE_CKB_Mask1) == - FWL_PARTSTATE_CKB_Disabled) { - iTheme = 4; - } - if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Checked) { - iTheme += 4; - } else if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == - FWL_PARTSTATE_CKB_Neutral) { - iTheme += 8; - } - DrawAxialShading(pGraphics, pRect->left - 1, pRect->top - 1, fRight, fBottom, - m_pThemeData->clrBoxBk[iTheme][0], - m_pThemeData->clrBoxBk[iTheme][1], &path, fillMode, pMatrix); -} -void CFWL_CheckBoxTP::DrawSign(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_RectF* pRtBox, - uint32_t dwStates, - CFX_Matrix* pMatrix) { - CFX_RectF rtSign(*pRtBox); - rtSign.Deflate(CHECKBOX_SIZE_SIGNMARGIN, CHECKBOX_SIZE_SIGNMARGIN); - uint32_t dwColor = m_pThemeData->clrSignCheck; - FX_BOOL bCheck = TRUE; - if (((dwStates & FWL_PARTSTATE_CKB_Mask1) == FWL_PARTSTATE_CKB_Disabled) && - ((dwStates & FWL_PARTSTATE_CKB_Mask2) == FWL_PARTSTATE_CKB_Checked)) { - dwColor = m_pThemeData->clrSignBorderDisable; - } else if ((dwStates & FWL_PARTSTATE_CKB_Mask2) == - FWL_PARTSTATE_CKB_Neutral) { - switch (dwStates & FWL_PARTSTATE_CKB_Mask1) { - case FWL_PARTSTATE_CKB_Normal: { - bCheck = FALSE; - dwColor = m_pThemeData->clrSignNeutralNormal; - break; - } - case FWL_PARTSTATE_CKB_Hovered: { - bCheck = FALSE; - dwColor = m_pThemeData->clrSignNeutralHover; - break; - } - case FWL_PARTSTATE_CKB_Pressed: { - bCheck = FALSE, dwColor = m_pThemeData->clrSignNeutralPressed; - break; - } - case FWL_PARTSTATE_CKB_Disabled: { - bCheck = FALSE, dwColor = m_pThemeData->clrSignBorderDisable; - break; - } - } - } - if (bCheck) { - uint32_t dwStyle = pWidget->GetStylesEx(); - switch (dwStyle & FWL_STYLEEXT_CKB_SignShapeMask) { - case FWL_STYLEEXT_CKB_SignShapeCheck: { - DrawSignCheck(pGraphics, &rtSign, dwColor, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_SignShapeCircle: { - rtSign.Deflate(1, 1); - DrawSignCircle(pGraphics, &rtSign, dwColor, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_SignShapeCross: { - DrawSignCross(pGraphics, &rtSign, dwColor, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_SignShapeDiamond: { - DrawSignDiamond(pGraphics, &rtSign, dwColor, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_SignShapeSquare: { - DrawSignSquare(pGraphics, &rtSign, dwColor, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_SignShapeStar: { - DrawSignStar(pGraphics, &rtSign, dwColor, pMatrix); - break; - } - } - } else { - FillSoildRect(pGraphics, ArgbEncode(255, 33, 161, 33), &rtSign, pMatrix); - } -} -void CFWL_CheckBoxTP::DrawSignNeutral(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - CFX_Matrix* pMatrix) { - ((CFX_RectF*)pRtSign)->Inflate(-3, -3); - FillSoildRect(pGraphics, m_pThemeData->clrSignNeutral, pRtSign, pMatrix); -} -void CFWL_CheckBoxTP::DrawSignCheck(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - FX_ARGB argbFill, - CFX_Matrix* pMatrix) { - if (!m_pCheckPath) { - initCheckPath(pRtSign->width); - } - CFX_Matrix mt; - mt.SetIdentity(); - mt.Translate(pRtSign->left, pRtSign->top); - mt.Concat(*pMatrix); - CFX_Color crFill(argbFill); - pGraphics->SaveGraphState(); - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(m_pCheckPath, FXFILL_WINDING, &mt); - pGraphics->RestoreGraphState(); -} -void CFWL_CheckBoxTP::DrawSignCircle(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - FX_ARGB argbFill, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - path.AddEllipse(*pRtSign); - CFX_Color crFill(argbFill); - pGraphics->SaveGraphState(); - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_CheckBoxTP::DrawSignCross(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - FX_ARGB argbFill, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - FX_FLOAT fRight = pRtSign->right(); - FX_FLOAT fBottom = pRtSign->bottom(); - path.AddLine(pRtSign->left, pRtSign->top, fRight, fBottom); - path.AddLine(pRtSign->left, fBottom, fRight, pRtSign->top); - CFX_Color crFill(argbFill); - pGraphics->SaveGraphState(); - pGraphics->SetStrokeColor(&crFill); - pGraphics->SetLineWidth(1.0f); - pGraphics->StrokePath(&path, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_CheckBoxTP::DrawSignDiamond(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - FX_ARGB argbFill, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - FX_FLOAT fWidth = pRtSign->width; - FX_FLOAT fHeight = pRtSign->height; - FX_FLOAT fBottom = pRtSign->bottom(); - path.MoveTo(pRtSign->left + fWidth / 2, pRtSign->top); - path.LineTo(pRtSign->left, pRtSign->top + fHeight / 2); - path.LineTo(pRtSign->left + fWidth / 2, fBottom); - path.LineTo(pRtSign->right(), pRtSign->top + fHeight / 2); - path.LineTo(pRtSign->left + fWidth / 2, pRtSign->top); - CFX_Color crFill(argbFill); - pGraphics->SaveGraphState(); - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_CheckBoxTP::DrawSignSquare(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - FX_ARGB argbFill, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - path.AddRectangle(pRtSign->left, pRtSign->top, pRtSign->width, - pRtSign->height); - CFX_Color crFill(argbFill); - pGraphics->SaveGraphState(); - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_CheckBoxTP::DrawSignStar(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - FX_ARGB argbFill, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - FX_FLOAT fBottom = pRtSign->bottom(); - FX_FLOAT fRadius = - (pRtSign->top - fBottom) / (1 + (FX_FLOAT)cos(FX_PI / 5.0f)); - CFX_PointF ptCenter((pRtSign->left + pRtSign->right()) / 2.0f, - (pRtSign->top + fBottom) / 2.0f); - FX_FLOAT px[5], py[5]; - FX_FLOAT fAngel = FX_PI / 10.0f; - for (int32_t i = 0; i < 5; i++) { - px[i] = ptCenter.x + fRadius * (FX_FLOAT)cos(fAngel); - py[i] = ptCenter.y + fRadius * (FX_FLOAT)sin(fAngel); - fAngel += FX_PI * 2 / 5.0f; - } - path.MoveTo(px[0], py[0]); - int32_t nNext = 0; - for (int32_t j = 0; j < 5; j++) { - nNext += 2; - if (nNext >= 5) { - nNext -= 5; - } - path.LineTo(px[nNext], py[nNext]); - } - CFX_Color crFill(argbFill); - pGraphics->SaveGraphState(); - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_CheckBoxTP::DrawSignBorder(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_RectF* pRtBox, - FX_BOOL bDisable, - CFX_Matrix* pMatrix) { - switch (pWidget->GetStylesEx() & FWL_STYLEEXT_CKB_ShapeMask) { - case FWL_STYLEEXT_CKB_ShapeSolidSquare: { - DrawAnnulusRect(pGraphics, bDisable ? m_pThemeData->clrSignBorderDisable - : m_pThemeData->clrSignBorderNormal, - pRtBox, 1, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_ShapeSunkenSquare: { - Draw3DRect(pGraphics, FWLTHEME_EDGE_Sunken, CHECKBOX_SIZE_SIGNBORDER, - pRtBox, CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2, - CHECKBOX_COLOR_BOXRB1, CHECKBOX_COLOR_BOXRB2, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_ShapeSolidCircle: { - DrawAnnulusCircle(pGraphics, bDisable ? m_pThemeData->clrSignBorderDisable - : m_pThemeData->clrSignBorderNormal, - pRtBox, 1, pMatrix); - break; - } - case FWL_STYLEEXT_CKB_ShapeSunkenCircle: { - Draw3DCircle(pGraphics, FWLTHEME_EDGE_Sunken, CHECKBOX_SIZE_SIGNBORDER, - pRtBox, CHECKBOX_COLOR_BOXLT1, CHECKBOX_COLOR_BOXLT2, - CHECKBOX_COLOR_BOXRB1, CHECKBOX_COLOR_BOXRB2, pMatrix); - break; - } - } -} -void CFWL_CheckBoxTP::SetThemeData(uint32_t dwID) { - uint32_t* pData = (uint32_t*)&m_pThemeData->clrBoxBk; - if (dwID) { - *pData++ = 0, *pData++ = 0, *pData++ = ArgbEncode(255, 220, 220, 215), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 240, 207), - *pData++ = ArgbEncode(255, 248, 179, 48), - *pData++ = ArgbEncode(255, 176, 176, 167), - *pData++ = ArgbEncode(255, 241, 239, 239), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 220, 220, 215), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 240, 207), - *pData++ = ArgbEncode(255, 248, 179, 48), - *pData++ = ArgbEncode(255, 176, 176, 167), - *pData++ = ArgbEncode(255, 241, 239, 239), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 220, 220, 215), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 240, 207), - *pData++ = ArgbEncode(255, 248, 179, 48), - *pData++ = ArgbEncode(255, 176, 176, 167), - *pData++ = ArgbEncode(255, 241, 239, 239), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 255, 255); - m_pThemeData->clrSignBorderNormal = ArgbEncode(255, 154, 167, 114); - m_pThemeData->clrSignBorderDisable = ArgbEncode(255, 202, 200, 187); - m_pThemeData->clrSignCheck = ArgbEncode(255, 164, 180, 138); - m_pThemeData->clrSignNeutral = ArgbEncode(2255, 28, 134, 26); - m_pThemeData->clrSignNeutralNormal = ArgbEncode(255, 114, 192, 113); - m_pThemeData->clrSignNeutralHover = ArgbEncode(255, 33, 161, 33); - m_pThemeData->clrSignNeutralPressed = ArgbEncode(255, 28, 134, 26); - } else { - *pData++ = 0, *pData++ = 0, *pData++ = ArgbEncode(255, 220, 220, 215), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 240, 207), - *pData++ = ArgbEncode(255, 248, 179, 48), - *pData++ = ArgbEncode(255, 176, 176, 167), - *pData++ = ArgbEncode(255, 241, 239, 239), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 220, 220, 215), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 240, 207), - *pData++ = ArgbEncode(255, 248, 179, 48), - *pData++ = ArgbEncode(255, 176, 176, 167), - *pData++ = ArgbEncode(255, 241, 239, 239), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 220, 220, 215), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 240, 207), - *pData++ = ArgbEncode(255, 248, 179, 48), - *pData++ = ArgbEncode(255, 176, 176, 167), - *pData++ = ArgbEncode(255, 241, 239, 239), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 255, 255); - m_pThemeData->clrSignBorderNormal = ArgbEncode(255, 28, 81, 128); - m_pThemeData->clrSignBorderDisable = ArgbEncode(255, 202, 200, 187); - m_pThemeData->clrSignCheck = ArgbEncode(255, 28, 81, 128); - m_pThemeData->clrSignNeutral = ArgbEncode(255, 28, 134, 26); - m_pThemeData->clrSignNeutralNormal = ArgbEncode(255, 114, 192, 113); - m_pThemeData->clrSignNeutralHover = ArgbEncode(255, 33, 161, 33); - m_pThemeData->clrSignNeutralPressed = ArgbEncode(255, 28, 134, 26); - } -} -void CFWL_CheckBoxTP::initCheckPath(FX_FLOAT fCheckLen) { - if (!m_pCheckPath) { - m_pCheckPath = new CFX_Path; - m_pCheckPath->Create(); - FX_FLOAT fWidth = CHECKBOX_SIZE_SIGNPATH; - FX_FLOAT fHeight = -CHECKBOX_SIZE_SIGNPATH; - FX_FLOAT fBottom = CHECKBOX_SIZE_SIGNPATH; - CFX_PointF pt1(fWidth / 15.0f, fBottom + fHeight * 2 / 5.0f); - CFX_PointF pt2(fWidth / 4.5f, fBottom + fHeight / 16.0f); - CFX_PointF pt3(fWidth / 3.0f, fBottom); - CFX_PointF pt4(fWidth * 14 / 15.0f, fBottom + fHeight * 15 / 16.0f); - CFX_PointF pt5(fWidth / 3.6f, fBottom + fHeight / 3.5f); - CFX_PointF pt12(fWidth / 7.0f, fBottom + fHeight * 2 / 7.0f); - CFX_PointF pt21(fWidth / 5.0f, fBottom + fHeight / 5.0f); - CFX_PointF pt23(fWidth / 4.4f, fBottom + fHeight * 0 / 16.0f); - CFX_PointF pt32(fWidth / 4.0f, fBottom); - CFX_PointF pt34(fWidth * (1 / 7.0f + 7 / 15.0f), - fBottom + fHeight * 4 / 5.0f); - CFX_PointF pt43(fWidth * (1 / 7.0f + 7 / 15.0f), - fBottom + fHeight * 4 / 5.0f); - CFX_PointF pt45(fWidth * 7 / 15.0f, fBottom + fHeight * 8 / 7.0f); - CFX_PointF pt54(fWidth / 3.4f, fBottom + fHeight / 3.5f); - CFX_PointF pt51(fWidth / 3.6f, fBottom + fHeight / 4.0f); - CFX_PointF pt15(fWidth / 3.5f, fBottom + fHeight * 3.5f / 5.0f); - m_pCheckPath->MoveTo(pt1.x, pt1.y); - FX_FLOAT px1 = pt12.x - pt1.x; - FX_FLOAT py1 = pt12.y - pt1.y; - FX_FLOAT px2 = pt21.x - pt2.x; - FX_FLOAT py2 = pt21.y - pt2.y; - m_pCheckPath->BezierTo(pt1.x + px1 * FWLTHEME_BEZIER, - pt1.y + py1 * FWLTHEME_BEZIER, - pt2.x + px2 * FWLTHEME_BEZIER, - pt2.y + py2 * FWLTHEME_BEZIER, pt2.x, pt2.y); - px1 = pt23.x - pt2.x; - py1 = pt23.y - pt2.y; - px2 = pt32.x - pt3.x; - py2 = pt32.y - pt3.y; - m_pCheckPath->BezierTo(pt2.x + px1 * FWLTHEME_BEZIER, - pt2.y + py1 * FWLTHEME_BEZIER, - pt3.x + px2 * FWLTHEME_BEZIER, - pt3.y + py2 * FWLTHEME_BEZIER, pt3.x, pt3.y); - px1 = pt34.x - pt3.x; - py1 = pt34.y - pt3.y; - px2 = pt43.x - pt4.x; - py2 = pt43.y - pt4.y; - m_pCheckPath->BezierTo(pt3.x + px1 * FWLTHEME_BEZIER, - pt3.y + py1 * FWLTHEME_BEZIER, - pt4.x + px2 * FWLTHEME_BEZIER, - pt4.y + py2 * FWLTHEME_BEZIER, pt4.x, pt4.y); - px1 = pt45.x - pt4.x; - py1 = pt45.y - pt4.y; - px2 = pt54.x - pt5.x; - py2 = pt54.y - pt5.y; - m_pCheckPath->BezierTo(pt4.x + px1 * FWLTHEME_BEZIER, - pt4.y + py1 * FWLTHEME_BEZIER, - pt5.x + px2 * FWLTHEME_BEZIER, - pt5.y + py2 * FWLTHEME_BEZIER, pt5.x, pt5.y); - px1 = pt51.x - pt5.x; - py1 = pt51.y - pt5.y; - px2 = pt15.x - pt1.x; - py2 = pt15.y - pt1.y; - m_pCheckPath->BezierTo(pt5.x + px1 * FWLTHEME_BEZIER, - pt5.y + py1 * FWLTHEME_BEZIER, - pt1.x + px2 * FWLTHEME_BEZIER, - pt1.y + py2 * FWLTHEME_BEZIER, pt1.x, pt1.y); - FX_FLOAT fScale = fCheckLen / CHECKBOX_SIZE_SIGNPATH; - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, 0, 0); - mt.Scale(fScale, fScale); - CFX_PathData* pData = m_pCheckPath->GetPathData(); - pData->Transform(&mt); - } -} diff --git a/xfa/fwl/theme/comboboxtp.cpp b/xfa/fwl/theme/comboboxtp.cpp deleted file mode 100644 index 578793b002..0000000000 --- a/xfa/fwl/theme/comboboxtp.cpp +++ /dev/null @@ -1,160 +0,0 @@ -// 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/include/fwl/theme/comboboxtp.h" - -#include "xfa/fwl/basewidget/ifwl_combobox.h" -#include "xfa/fwl/core/cfwl_themebackground.h" -#include "xfa/fwl/core/ifwl_themeprovider.h" -#include "xfa/fwl/core/ifwl_widget.h" -#include "xfa/fxgraphics/cfx_color.h" -#include "xfa/fxgraphics/cfx_path.h" - -#define FWLTHEME_CAPACITY_ComboFormHandler 8.0f - -CFWL_ComboBoxTP::CFWL_ComboBoxTP() { - m_dwThemeID = 0; -} -CFWL_ComboBoxTP::~CFWL_ComboBoxTP() {} -FX_BOOL CFWL_ComboBoxTP::IsValidWidget(IFWL_Widget* pWidget) { - if (!pWidget) - return FALSE; - return pWidget->GetClassID() == FWL_CLASSHASH_ComboBox; -} -FX_BOOL CFWL_ComboBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { - if (!pParams) - return FALSE; - switch (pParams->m_iPart) { - case FWL_PART_CMB_Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_CMB_Edge: { - DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), - &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_CMB_Background: { - CFX_Path path; - path.Create(); - CFX_RectF& rect = pParams->m_rtPart; - path.AddRectangle(rect.left, rect.top, rect.width, rect.height); - CFX_Color cr; - switch (pParams->m_dwStates) { - case FWL_PARTSTATE_CMB_Selected: - cr = FWLTHEME_COLOR_BKSelected; - break; - case FWL_PARTSTATE_CMB_Disabled: - cr = FWLTHEME_COLOR_EDGERB1; - break; - default: - cr = 0xFFFFFFFF; - } - pParams->m_pGraphics->SaveGraphState(); - pParams->m_pGraphics->SetFillColor(&cr); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix); - pParams->m_pGraphics->RestoreGraphState(); - break; - } - case FWL_PART_CMB_DropDownButton: { - DrawDropDownButton(pParams, pParams->m_dwStates, &pParams->m_matrix); - break; - } - case FWL_PART_CMB_StretcgHandler: { - DrawStrethHandler(pParams, 0, &pParams->m_matrix); - break; - } - default: { return FALSE; } - } - return TRUE; -} -void CFWL_ComboBoxTP::DrawStrethHandler(CFWL_ThemeBackground* pParams, - uint32_t dwStates, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - path.AddRectangle(pParams->m_rtPart.left, pParams->m_rtPart.top, - pParams->m_rtPart.width - 1, pParams->m_rtPart.height); - CFX_Color cr(ArgbEncode(0xff, 0xff, 0, 0)); - pParams->m_pGraphics->SetFillColor(&cr); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix); -} -void* CFWL_ComboBoxTP::GetCapacity(CFWL_ThemePart* pThemePart, - uint32_t dwCapacity) { - if (dwCapacity == FWL_WGTCAPACITY_CMB_ComboFormHandler) { - m_fValue = FWLTHEME_CAPACITY_ComboFormHandler; - return &m_fValue; - } - return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); -} -#ifdef THEME_XPSimilar -void CFWL_ComboBoxTP::DrawDropDownButton(CFWL_ThemeBackground* pParams, - uint32_t dwStates, - CFX_Matrix* pMatrix) { - FWLTHEME_STATE eState = FWLTHEME_STATE_Normal; - switch (dwStates) { - case FWL_PARTSTATE_CMB_Normal: { - eState = FWLTHEME_STATE_Normal; - break; - } - case FWL_PARTSTATE_CMB_Hovered: { - eState = FWLTHEME_STATE_Hover; - break; - } - case FWL_PARTSTATE_CMB_Pressed: { - eState = FWLTHEME_STATE_Pressed; - break; - } - case FWL_PARTSTATE_CMB_Disabled: { - eState = FWLTHEME_STATE_Disabale; - break; - } - default: {} - } - DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, - FWLTHEME_DIRECTION_Down, eState, &pParams->m_matrix); -} -#else -void CFWL_ComboBoxTP::DrawDropDownButton(CFWL_ThemeBackground* pParams, - uint32_t dwStates, - CFX_Matrix* pMatrix) { - FX_BOOL bPressed = ((pParams->m_dwStates & FWL_CMBPARTSTATE_Pressed) == - FWL_CMBPARTSTATE_Pressed); - FX_FLOAT fWidth = bPressed ? 1.0f : 2.0f; - FWLTHEME_EDGE eType = bPressed ? FWLTHEME_EDGE_Flat : FWLTHEME_EDGE_Raised; - Draw3DRect(pParams->m_pGraphics, eType, fWidth, &pParams->m_rtPart, - FWLTHEME_COLOR_EDGELT1, FWLTHEME_COLOR_EDGELT2, - FWLTHEME_COLOR_EDGERB1, FWLTHEME_COLOR_EDGERB2, pMatrix); - CFX_Path path; - path.Create(); - path.AddRectangle(pParams->m_rtPart.left + fWidth, - pParams->m_rtPart.top + fWidth, - pParams->m_rtPart.width - 2 * fWidth, - pParams->m_rtPart.height - 2 * fWidth); - pParams->m_pGraphics->SaveGraphState(); - CFX_Color crFill(FWLTHEME_COLOR_Background); - pParams->m_pGraphics->SetFillColor(&crFill); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix); - pParams->m_pGraphics->RestoreGraphState(); - FX_ARGB argbFill = ArgbEncode(255, 77, 97, 133); - switch (pParams->m_dwStates & 0x03) { - case FWL_CMBPARTSTATE_Normal: { - } - case FWL_CMBPARTSTATE_Hovered: { - } - case FWL_CMBPARTSTATE_Pressed: { - argbFill = 0xFF000000; - break; - } - case FWL_CMBPARTSTATE_Disabled: { - argbFill = 0xFFF0F0F0; - break; - } - } - DrawArrow(pParams->m_pGraphics, &pParams->m_rtPart, FWLTHEME_DIRECTION_Down, - argbFill, bPressed, &pParams->m_matrix); -} -#endif diff --git a/xfa/fwl/theme/datetimepickertp.cpp b/xfa/fwl/theme/datetimepickertp.cpp deleted file mode 100644 index 63fbc13110..0000000000 --- a/xfa/fwl/theme/datetimepickertp.cpp +++ /dev/null @@ -1,139 +0,0 @@ -// 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/include/fwl/theme/datetimepickertp.h" - -#include "xfa/fwl/basewidget/ifwl_datetimepicker.h" -#include "xfa/fwl/core/cfwl_themebackground.h" - -CFWL_DateTimePickerTP::CFWL_DateTimePickerTP() { - m_pThemeData = new DTPThemeData; - initThemeData(); -} -CFWL_DateTimePickerTP::~CFWL_DateTimePickerTP() { - delete m_pThemeData; -} -FX_BOOL CFWL_DateTimePickerTP::IsValidWidget(IFWL_Widget* pWidget) { - if (!pWidget) - return FALSE; - return pWidget->GetClassID() == FWL_CLASSHASH_DateTimePicker; -} -FX_BOOL CFWL_DateTimePickerTP::DrawBackground(CFWL_ThemeBackground* pParams) { - if (!pParams) - return FALSE; - switch (pParams->m_iPart) { - case FWL_PART_DTP_Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_DTP_Edge: { - DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), - &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_DTP_DropDownButton: { - DrawDropDownButton(pParams, &pParams->m_matrix); - break; - } - default: {} - } - return TRUE; -} -#ifdef THEME_XPSimilar -void CFWL_DateTimePickerTP::DrawDropDownButton(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - uint32_t dwStates = pParams->m_dwStates; - dwStates &= 0x03; - FWLTHEME_STATE eState = FWLTHEME_STATE_Normal; - switch (eState & dwStates) { - case FWL_PARTSTATE_DTP_Normal: { - eState = FWLTHEME_STATE_Normal; - break; - } - case FWL_PARTSTATE_DTP_Hovered: { - eState = FWLTHEME_STATE_Hover; - break; - } - case FWL_PARTSTATE_DTP_Pressed: { - eState = FWLTHEME_STATE_Pressed; - break; - } - case FWL_PARTSTATE_DTP_Disabled: { - eState = FWLTHEME_STATE_Disabale; - break; - } - default: {} - } - DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, - FWLTHEME_DIRECTION_Down, eState, pMatrix); -} -#else -void CFWL_DateTimePickerTP::DrawDropDownButton(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - FX_BOOL bPressed = ((pParams->m_dwStates & FWL_PARTSTATE_DTP_Pressed) == - FWL_PARTSTATE_DTP_Pressed); - FX_FLOAT fWidth = bPressed ? 1.0f : 2.0f; - FWLTHEME_EDGE eType = bPressed ? FWLTHEME_EDGE_Flat : FWLTHEME_EDGE_Raised; - Draw3DRect(pParams->m_pGraphics, eType, fWidth, &pParams->m_rtPart, - FWLTHEME_COLOR_EDGELT1, FWLTHEME_COLOR_EDGELT2, - FWLTHEME_COLOR_EDGERB1, FWLTHEME_COLOR_EDGERB2, pMatrix); - CFX_Path path; - path.Create(); - path.AddRectangle(pParams->m_rtPart.left + fWidth, - pParams->m_rtPart.top + fWidth, - pParams->m_rtPart.width - 2 * fWidth, - pParams->m_rtPart.height - 2 * fWidth); - pParams->m_pGraphics->SaveGraphState(); - CFX_Color crFill(FWLTHEME_COLOR_Background); - pParams->m_pGraphics->SetFillColor(&crFill); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pParams->m_pGraphics->RestoreGraphState(); - FX_ARGB argbFill = ArgbEncode(255, 77, 97, 133); - switch (pParams->m_dwStates & 0x03) { - case FWL_PARTSTATE_DTP_Normal: { - } - case FWL_PARTSTATE_DTP_Hovered: { - } - case FWL_PARTSTATE_DTP_Pressed: { - argbFill = 0xFF000000; - break; - } - case FWL_PARTSTATE_DTP_Disabled: { - argbFill = 0xFFF0F0F0; - break; - } - } - DrawArrow(pParams->m_pGraphics, &pParams->m_rtPart, FWLTHEME_DIRECTION_Down, - argbFill, bPressed, pMatrix); -} -#endif -void CFWL_DateTimePickerTP::initThemeData() { - uint32_t* pData = (uint32_t*)&m_pThemeData->BoxBkColor; - *pData++ = 0, *pData++ = 0, *pData++ = ArgbEncode(255, 220, 220, 215), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 240, 207), - *pData++ = ArgbEncode(255, 248, 179, 48), - *pData++ = ArgbEncode(255, 176, 176, 167), - *pData++ = ArgbEncode(255, 241, 239, 239), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 220, 220, 215), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 240, 207), - *pData++ = ArgbEncode(255, 248, 179, 48), - *pData++ = ArgbEncode(255, 176, 176, 167), - *pData++ = ArgbEncode(255, 241, 239, 239), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 220, 220, 215), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 240, 207), - *pData++ = ArgbEncode(255, 248, 179, 48), - *pData++ = ArgbEncode(255, 176, 176, 167), - *pData++ = ArgbEncode(255, 241, 239, 239), - *pData++ = ArgbEncode(255, 255, 255, 255), - *pData++ = ArgbEncode(255, 255, 255, 255); -} diff --git a/xfa/fwl/theme/edittp.cpp b/xfa/fwl/theme/edittp.cpp deleted file mode 100644 index a99b2146d1..0000000000 --- a/xfa/fwl/theme/edittp.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// 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/include/fwl/theme/edittp.h" - -#include "xfa/fwl/basewidget/ifwl_edit.h" -#include "xfa/fwl/core/cfwl_themebackground.h" -#include "xfa/fwl/core/ifwl_widget.h" -#include "xfa/fxgraphics/cfx_color.h" -#include "xfa/fxgraphics/cfx_path.h" - -CFWL_EditTP::CFWL_EditTP() {} -CFWL_EditTP::~CFWL_EditTP() {} - -FX_BOOL CFWL_EditTP::IsValidWidget(IFWL_Widget* pWidget) { - if (!pWidget) - return FALSE; - return pWidget->GetClassID() == FWL_CLASSHASH_Edit; -} -FX_BOOL CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) { - switch (pParams->m_iPart) { - case FWL_PART_EDT_Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_EDT_Edge: { - DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), - &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_EDT_Background: { - if (pParams->m_pPath) { - CFX_Graphics* pGraphics = pParams->m_pGraphics; - pGraphics->SaveGraphState(); - CFX_Color crSelected(FWL_GetThemeColor(m_dwThemeID) == 0 - ? FWLTHEME_COLOR_BKSelected - : FWLTHEME_COLOR_Green_BKSelected); - pGraphics->SetFillColor(&crSelected); - pGraphics->FillPath(pParams->m_pPath, FXFILL_WINDING, - &pParams->m_matrix); - pGraphics->RestoreGraphState(); - } else { - FX_BOOL bStatic = - pParams->m_dwData == FWL_PARTDATA_EDT_StaticBackground; - CFX_Path path; - path.Create(); - path.AddRectangle(pParams->m_rtPart.left, pParams->m_rtPart.top, - pParams->m_rtPart.width, pParams->m_rtPart.height); - CFX_Color cr(FWLTHEME_COLOR_Background); - if (!bStatic) { - if ((pParams->m_dwStates & FWL_PARTSTATE_EDT_Disable) == - FWL_PARTSTATE_EDT_Disable) { - cr.Set(FWLTHEME_COLOR_EDGERB1); - } else if ((pParams->m_dwStates & FWL_PARTSTATE_EDT_ReadOnly) == - FWL_PARTSTATE_EDT_ReadOnly) { - cr.Set(ArgbEncode(255, 236, 233, 216)); - } else { - cr.Set(0xFFFFFFFF); - } - } - pParams->m_pGraphics->SaveGraphState(); - pParams->m_pGraphics->SetFillColor(&cr); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, - &pParams->m_matrix); - pParams->m_pGraphics->RestoreGraphState(); - } - break; - } - case FWL_PART_EDT_CombTextLine: { - FX_ARGB cr = 0xFF000000; - FX_FLOAT fWidth = 1.0f; - CFX_Color crLine(cr); - pParams->m_pGraphics->SetStrokeColor(&crLine); - pParams->m_pGraphics->SetLineWidth(fWidth); - pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix); - break; - } - default: { break; } - } - return TRUE; -} -FWL_ERR CFWL_EditTP::Initialize() { - InitTTO(); - return CFWL_WidgetTP::Initialize(); -} -FWL_ERR CFWL_EditTP::Finalize() { - FinalizeTTO(); - return CFWL_WidgetTP::Finalize(); -} diff --git a/xfa/fwl/theme/formtp.cpp b/xfa/fwl/theme/formtp.cpp deleted file mode 100644 index 28a8805dee..0000000000 --- a/xfa/fwl/theme/formtp.cpp +++ /dev/null @@ -1,899 +0,0 @@ -// 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/include/fwl/theme/formtp.h" - -#include "xfa/fde/tto/fde_textout.h" -#include "xfa/fwl/core/cfwl_themebackground.h" -#include "xfa/fwl/core/cfwl_themepart.h" -#include "xfa/fwl/core/cfwl_themetext.h" -#include "xfa/fwl/core/ifwl_form.h" -#include "xfa/fwl/core/ifwl_themeprovider.h" -#include "xfa/fwl/core/ifwl_widget.h" -#include "xfa/fxgraphics/cfx_color.h" -#include "xfa/fxgraphics/cfx_path.h" - -#define FWLTHEME_CAPACITY_CXFormBorder 3 -#define FWLTHEME_CAPACITY_CYFormBorder 3 -#define FWLTHEME_CAPACITY_CYNarrowCaption 18 -#define FWLTHEME_CAPACITY_CYCaption 29 -#define FWLTHEME_CAPACITY_BigIconSize 32 -#define FWLTHEME_CAPACITY_SmallIconSize 16 -#define FWLTHEME_CAPACITY_FormTextColor 0xFFFFFFFF -#define FWLTHEME_FORMBTN_Margin 5 -#define FWLTHEME_FORMBTN_Span 2 -#define FWLTHEME_FORMBTN_Size 21 - -CFWL_FormTP::CFWL_FormTP() : m_pActiveBitmap(NULL), m_pDeactivebitmap(NULL) { - m_pThemeData = new SBThemeData; - SetThemeData(0); - m_rtDisLBorder.Reset(); - m_rtDisRBorder.Reset(); - m_rtDisBBorder.Reset(); - m_rtDisCaption.Reset(); -} -CFWL_FormTP::~CFWL_FormTP() { - if (m_pThemeData) { - delete m_pThemeData; - m_pThemeData = NULL; - } -} -FWL_ERR CFWL_FormTP::Initialize() { - InitTTO(); - InitCaption(TRUE); - InitCaption(FALSE); - return CFWL_WidgetTP::Initialize(); -} -FWL_ERR CFWL_FormTP::Finalize() { - FinalizeTTO(); - if (m_pActiveBitmap) { - delete m_pActiveBitmap; - m_pActiveBitmap = NULL; - } - if (m_pDeactivebitmap) { - delete m_pDeactivebitmap; - m_pDeactivebitmap = NULL; - } - return CFWL_WidgetTP::Finalize(); -} -FX_BOOL CFWL_FormTP::IsValidWidget(IFWL_Widget* pWidget) { - if (!pWidget) - return FALSE; - uint32_t dwHash = pWidget->GetClassID(); - return dwHash == FWL_CLASSHASH_Form; -} -uint32_t CFWL_FormTP::SetThemeID(IFWL_Widget* pWidget, - uint32_t dwThemeID, - FX_BOOL bChildren) { - if (m_pThemeData) { - SetThemeData(FWL_GetThemeColor(dwThemeID)); - } - InitCaption(TRUE); - InitCaption(FALSE); - return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren); -} -FX_BOOL CFWL_FormTP::DrawBackground(CFWL_ThemeBackground* pParams) { - if (!pParams) - return FALSE; - int32_t iActive = 0; - if (pParams->m_dwStates & FWL_PARTSTATE_FRM_Inactive) { - iActive = 1; - } - FWLTHEME_STATE eState = FWLTHEME_STATE_Normal; - switch (pParams->m_dwStates & 0x03) { - case FWL_PARTSTATE_FRM_Hover: { - eState = FWLTHEME_STATE_Hover; - break; - } - case FWL_PARTSTATE_FRM_Pressed: { - eState = FWLTHEME_STATE_Pressed; - break; - } - case FWL_PARTSTATE_FRM_Disabled: { - eState = FWLTHEME_STATE_Disabale; - break; - } - default: {} - } - switch (pParams->m_iPart) { - case FWL_PART_FRM_Border: { - DrawFormBorder(pParams->m_pGraphics, &pParams->m_rtPart, eState, - &pParams->m_matrix, iActive); - break; - } - case FWL_PART_FRM_Edge: { - DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), - &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_FRM_Background: { - FillBackground(pParams->m_pGraphics, &pParams->m_rtPart, - &pParams->m_matrix); - break; - } - case FWL_PART_FRM_Caption: { - DrawCaption(pParams->m_pGraphics, &pParams->m_rtPart, eState, - &pParams->m_matrix, iActive); - break; - } - case FWL_PART_FRM_NarrowCaption: { - DrawNarrowCaption(pParams->m_pGraphics, &pParams->m_rtPart, eState, - &pParams->m_matrix, iActive); - break; - } - case FWL_PART_FRM_CloseBox: { - DrawCloseBox(pParams->m_pGraphics, &pParams->m_rtPart, eState, - &pParams->m_matrix, iActive); - break; - } - case FWL_PART_FRM_MinimizeBox: { - DrawMinimizeBox(pParams->m_pGraphics, &pParams->m_rtPart, eState, - &pParams->m_matrix, iActive); - break; - } - case FWL_PART_FRM_MaximizeBox: { - DrawMaximizeBox(pParams->m_pGraphics, &pParams->m_rtPart, eState, - pParams->m_dwData, &pParams->m_matrix, iActive); - break; - } - case FWL_PART_FRM_Icon: { - DrawIconImage(pParams->m_pGraphics, pParams->m_pImage, &pParams->m_rtPart, - eState, &pParams->m_matrix, iActive); - break; - } - default: {} - } - return TRUE; -} -FX_BOOL CFWL_FormTP::DrawText(CFWL_ThemeText* pParams) { - if (!m_pTextOut) - return FALSE; - if (pParams->m_iPart == FWL_PART_FRM_Caption) { - m_pTextOut->SetTextColor(0xFFFFFFFF); - } else { - m_pTextOut->SetTextColor(0xFF000000); - } - return CFWL_WidgetTP::DrawText(pParams); -} -void* CFWL_FormTP::GetCapacity(CFWL_ThemePart* pThemePart, - uint32_t dwCapacity) { - FX_BOOL bDefPro = FALSE; - FX_BOOL bDwordVal = FALSE; - switch (dwCapacity) { - case FWL_WGTCAPACITY_CXBorder: { - m_fValue = FWLTHEME_CAPACITY_CXFormBorder; - break; - } - case FWL_WGTCAPACITY_CYBorder: { - m_fValue = FWLTHEME_CAPACITY_CYFormBorder; - break; - } - case FWL_WGTCAPACITY_FRM_CYCaption: { - m_fValue = FWLTHEME_CAPACITY_CYCaption; - break; - } - case FWL_WGTCAPACITY_FRM_CYNarrowCaption: { - m_fValue = FWLTHEME_CAPACITY_CYCaption; - break; - } - case FWL_WGTCAPACITY_TextColor: { - bDwordVal = TRUE; - m_dwValue = FWLTHEME_CAPACITY_FormTextColor; - break; - } - case FWL_WGTCAPACITY_FRM_BigIcon: { - m_fValue = FWLTHEME_CAPACITY_BigIconSize; - break; - } - case FWL_WGTCAPACITY_FRM_SmallIcon: { - m_fValue = FWLTHEME_CAPACITY_SmallIconSize; - break; - } - default: { bDefPro = TRUE; } - } - if (!bDefPro) { - if (bDwordVal) { - return &m_dwValue; - } - return &m_fValue; - } - return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); -} -FWL_ERR CFWL_FormTP::GetPartRect(CFWL_ThemePart* pThemePart, - CFX_RectF& rtPart) { - switch (pThemePart->m_iPart) { - case FWL_PART_FRM_CloseBox: { - CalCloseBox(pThemePart->m_pWidget, rtPart); - break; - } - case FWL_PART_FRM_MaximizeBox: { - CalMaxBox(pThemePart->m_pWidget, rtPart); - break; - } - case FWL_PART_FRM_MinimizeBox: { - CalMinBox(pThemePart->m_pWidget, rtPart); - break; - } - case FWL_PART_FRM_HeadText: { - CalCaption(pThemePart->m_pWidget, rtPart); - break; - } - case FWL_PART_FRM_Icon: { - CalIcon(pThemePart->m_pWidget, rtPart); - break; - } - default: {} - } - return FWL_ERR_Succeeded; -} -void CFWL_FormTP::CalCloseBox(IFWL_Widget* pWidget, CFX_RectF& rect) { - uint32_t dwStyles = pWidget->GetStyles(); - CFX_RectF rtWidget; - pWidget->GetWidgetRect(rtWidget); - rtWidget.Offset(-rtWidget.left, -rtWidget.top); - if (dwStyles & FWL_WGTSTYLE_CloseBox) { - rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Span, - rtWidget.top + FWLTHEME_FORMBTN_Margin, FWLTHEME_FORMBTN_Size, - FWLTHEME_FORMBTN_Size); - } else { - rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Span, - rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0); - } -} -void CFWL_FormTP::CalMaxBox(IFWL_Widget* pWidget, CFX_RectF& rect) { - uint32_t dwStyles = pWidget->GetStyles(); - CFX_RectF rtWidget; - pWidget->GetWidgetRect(rtWidget); - rtWidget.Offset(-rtWidget.left, -rtWidget.top); - if (dwStyles & FWL_WGTSTYLE_MaximizeBox) { - rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Size + - FWLTHEME_FORMBTN_Span * 2, - rtWidget.top + FWLTHEME_FORMBTN_Margin, FWLTHEME_FORMBTN_Size, - FWLTHEME_FORMBTN_Size); - } else { - rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Size + - FWLTHEME_FORMBTN_Span * 2, - rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0); - } -} -void CFWL_FormTP::CalMinBox(IFWL_Widget* pWidget, CFX_RectF& rect) { - uint32_t dwStyles = pWidget->GetStyles(); - CFX_RectF rtWidget; - pWidget->GetWidgetRect(rtWidget); - rtWidget.Offset(-rtWidget.left, -rtWidget.top); - if (dwStyles & FWL_WGTSTYLE_MinimizeBox) { - rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + - FWLTHEME_FORMBTN_Size * 2 + FWLTHEME_FORMBTN_Span * 3, - rtWidget.top + FWLTHEME_FORMBTN_Margin, FWLTHEME_FORMBTN_Size, - FWLTHEME_FORMBTN_Size); - } else { - rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + - FWLTHEME_FORMBTN_Size * 2 + FWLTHEME_FORMBTN_Span * 3, - rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0); - } -} -void CFWL_FormTP::CalCaption(IFWL_Widget* pWidget, CFX_RectF& rect) { - CFX_RectF rtWidget; - pWidget->GetWidgetRect(rtWidget); - rtWidget.Offset(-rtWidget.left, -rtWidget.top); - rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin, - rtWidget.top + FWLTHEME_FORMBTN_Margin - 2, - rtWidget.width - FWLTHEME_FORMBTN_Margin * 2, - FWLTHEME_FORMBTN_Size + 2 * FWLTHEME_FORMBTN_Margin + 4); -} -void CFWL_FormTP::CalIcon(IFWL_Widget* pWidget, CFX_RectF& rect) {} -void CFWL_FormTP::DrawFormBorder(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive) { - CFX_RectF rt; - rt.Set(pRect->left, pRect->top, 1, pRect->height); - FX_FLOAT fBottom, fRight; - fBottom = pRect->bottom(); - fRight = pRect->right(); - CFX_Path path; - path.Create(); - CFX_Color clrLine; - path.Clear(); - path.MoveTo(pRect->left, pRect->top); - path.LineTo(pRect->left, fBottom - 1); - path.LineTo(fRight - 1, fBottom - 1); - path.LineTo(fRight - 1, pRect->top); - clrLine = m_pThemeData->clrFormBorder[iActive][2]; - pGraphics->SetStrokeColor(&clrLine); - pGraphics->StrokePath(&path, pMatrix); - path.Clear(); - path.MoveTo(pRect->left + 1, pRect->top); - path.LineTo(pRect->left + 1, fBottom - 2); - path.LineTo(fRight - 2, fBottom - 2); - path.LineTo(fRight - 2, pRect->top); - clrLine = m_pThemeData->clrFormBorder[iActive][1]; - pGraphics->SetStrokeColor(&clrLine); - pGraphics->StrokePath(&path, pMatrix); - path.Clear(); - path.MoveTo(pRect->left + 2, pRect->top); - path.LineTo(pRect->left + 2, fBottom - 3); - path.LineTo(fRight - 3, fBottom - 3); - path.LineTo(fRight - 3, pRect->top); - clrLine = m_pThemeData->clrFormBorder[iActive][0]; - pGraphics->SetStrokeColor(&clrLine); - pGraphics->StrokePath(&path, pMatrix); - path.Clear(); - path.MoveTo(pRect->left + 3, pRect->top); - path.LineTo(pRect->left + 3, fBottom - 4); - path.LineTo(fRight - 4, fBottom - 4); - path.LineTo(fRight - 4, pRect->top); - clrLine = m_pThemeData->clrFormBorder[iActive][4]; - pGraphics->SetStrokeColor(&clrLine); - pGraphics->StrokePath(&path, pMatrix); - m_rtDisLBorder.Set(pRect->left, pRect->top + 29, 4, pRect->height - 29); - m_rtDisRBorder.Set(pRect->right() - 4, pRect->top + 29, 4, - pRect->height - 29); - m_rtDisBBorder.Set(pRect->left, pRect->bottom() - 4, pRect->width, 4); - m_rtDisCaption.Set(pRect->left, pRect->top, pRect->width, 29); -} -void CFWL_FormTP::DrawCaption(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive) { - CFX_RectF rt; - FX_FLOAT fBottom, fRight; - fBottom = pRect->bottom(); - fRight = pRect->right(); - rt.Set(pRect->left, pRect->top, pRect->width, 1); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][0], &rt, - pMatrix); - rt.Offset(0, 1); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][1], &rt, - pMatrix); - rt.Offset(0, 1); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][2], &rt, - pMatrix); - rt.Set(pRect->left, pRect->bottom() - 1, pRect->width, 1); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeBottom[iActive][2], &rt, - pMatrix); - rt.Offset(0, -1); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeBottom[iActive][1], &rt, - pMatrix); - rt.Set(pRect->left, pRect->top, 1, pRect->height); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][2], &rt, - pMatrix); - rt.Set(pRect->left + 1, pRect->top + 1, 1, fBottom - 1); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][1], &rt, - pMatrix); - rt.Set(pRect->left + 2, pRect->top + 2, 1, fBottom - 2); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][0], &rt, - pMatrix); - rt.Set(fRight - 1, pRect->top, pRect->width, pRect->height); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][2], &rt, - pMatrix); - rt.Set(fRight - 2, pRect->top + 1, 1, fBottom - 1); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][1], &rt, - pMatrix); - rt.Set(fRight - 3, pRect->top + 2, 1, fBottom - 2); - FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][0], &rt, - pMatrix); - CFX_RectF rect(*pRect); - rect.Set(rect.left + 3, rect.top + 3, rect.width - 6, rect.height - 5); - if (iActive == 0) { - pGraphics->StretchImage(m_pActiveBitmap, rect, pMatrix); - } else { - pGraphics->StretchImage(m_pDeactivebitmap, rect, pMatrix); - } -} -void CFWL_FormTP::DrawNarrowCaption(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive) {} -void CFWL_FormTP::DrawCloseBox(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive) { - FX_FLOAT fRight = pRect->right(); - FX_FLOAT fBottom = pRect->bottom(); - FX_FLOAT fWidth = pRect->width; - FX_FLOAT fHeight = pRect->height; - pGraphics->SaveGraphState(); - CFX_RectF rt(*pRect); - pGraphics->SetLineWidth(1.0f); - CFX_Path path; - path.Create(); - path.AddRectangle(rt.left + 1, rt.top, fWidth - 2, 1); - path.AddRectangle(rt.left, rt.top + 1, 1, fHeight - 2); - path.AddRectangle(fRight - 1, rt.top + 1, 1, fHeight - 2); - path.AddRectangle(rt.left + 1, fBottom - 1, fWidth - 2, 1); - CFX_Color crFill; - crFill = m_pThemeData->clrBtnEdgeOut[iActive]; - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - path.Clear(); - path.AddRectangle(rt.left + 1, rt.top + 1, 1, 1); - path.AddRectangle(fRight - 2, rt.top + 1, 1, 1); - path.AddRectangle(rt.left + 1, fBottom - 2, 1, 1); - path.AddRectangle(fRight - 2, fBottom - 2, 1, 1); - crFill = m_pThemeData->clrBtnCornerLight[iActive][eState - 1]; - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - path.Clear(); - path.AddRectangle(rt.left + 2, rt.top + 1, fWidth - 4, 1); - path.AddRectangle(rt.left + 1, rt.top + 2, 1, fHeight - 4); - crFill = m_pThemeData->clrCloseBtEdgeLight[iActive][eState - 1]; - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - path.Clear(); - path.AddRectangle(fRight - 2, rt.top + 2, 1, fHeight - 4); - path.AddRectangle(rt.left + 2, fBottom - 2, fWidth - 4, 1); - crFill = m_pThemeData->clrCloseBtEdgeDark[iActive][eState - 1]; - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - path.Clear(); - path.AddRectangle(pRect->left + 2, pRect->top + 2, fWidth - 4, fHeight - 4); - DrawAxialShading(pGraphics, pRect->left + 2, pRect->top + 2, fRight - 2, - fBottom - 2, - m_pThemeData->clrCloseBtBKStart[iActive][eState - 1], - m_pThemeData->clrCloseBtBKEnd[iActive][eState - 1], &path, - FXFILL_WINDING, pMatrix); - CFX_RectF rtX(*pRect); - rtX.Inflate(-5, -5); - path.Clear(); - FX_FLOAT frtXRight = rtX.right(); - FX_FLOAT frtXBottom = rtX.bottom(); - path.AddLine(rtX.left, rtX.top + 1, frtXRight - 1, frtXBottom); - path.AddLine(rtX.left, rtX.top, frtXRight, frtXBottom); - path.AddLine(rtX.left + 1, rtX.top, frtXRight, frtXBottom - 1); - path.AddLine(rtX.left, frtXBottom - 1, frtXRight - 1, rtX.top); - path.AddLine(rtX.left, frtXBottom, frtXRight, rtX.top); - path.AddLine(rtX.left + 1, frtXBottom, frtXRight, rtX.top + 1); - CFX_Color clrLine(0xffffffff); - pGraphics->SetLineWidth(1.0f); - pGraphics->SetStrokeColor(&clrLine); - pGraphics->StrokePath(&path, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_FormTP::DrawMinMaxBoxCommon(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive) { - pGraphics->SaveGraphState(); - FX_FLOAT fRight = pRect->right(); - FX_FLOAT fBottom = pRect->bottom(); - FX_FLOAT fWidth = pRect->width; - FX_FLOAT fHeight = pRect->height; - CFX_RectF rt(*pRect); - pGraphics->SetLineWidth(1.0f); - CFX_Path path; - path.Create(); - path.AddRectangle(rt.left + 1, rt.top, fWidth - 2, 1); - path.AddRectangle(rt.left, rt.top + 1, 1, fHeight - 2); - path.AddRectangle(fRight - 1, rt.top + 1, 1, fHeight - 2); - path.AddRectangle(rt.left + 1, fBottom - 1, fWidth - 2, 1); - CFX_Color crFill; - crFill = m_pThemeData->clrBtnEdgeOut[iActive]; - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - path.Clear(); - path.AddRectangle(rt.left + 1, rt.top + 1, 1, 1); - path.AddRectangle(fRight - 2, rt.top + 1, 1, 1); - path.AddRectangle(rt.left + 1, fBottom - 2, 1, 1); - path.AddRectangle(fRight - 2, fBottom - 2, 1, 1); - crFill = m_pThemeData->clrBtnCornerLight[iActive][eState - 1]; - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - path.Clear(); - path.AddRectangle(rt.left + 2, rt.top + 1, fWidth - 4, 1); - path.AddRectangle(rt.left + 1, rt.top + 2, 1, fHeight - 4); - crFill = m_pThemeData->clrNormalBtEdgeLight[iActive][eState - 1]; - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - path.Clear(); - path.AddRectangle(fRight - 2, rt.top + 2, 1, fHeight - 4); - path.AddRectangle(rt.left + 2, fBottom - 2, fWidth - 4, 1); - crFill = m_pThemeData->clrNormalBtEdgeDark[iActive][eState - 1]; - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pGraphics->RestoreGraphState(); - path.Clear(); - path.AddRectangle(pRect->left + 2, pRect->top + 2, fWidth - 4, fHeight - 4); - DrawAxialShading(pGraphics, pRect->left + 2, pRect->top + 2, fRight - 2, - fBottom - 2, - m_pThemeData->clrNormalBtBKStart[iActive][eState - 1], - m_pThemeData->clrNormalBtBKEnd[iActive][eState - 1], &path, - FXFILL_WINDING, pMatrix); -} -void CFWL_FormTP::DrawMinimizeBox(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive) { - DrawMinMaxBoxCommon(pGraphics, pRect, eState, pMatrix); - CFX_RectF rtMin; - rtMin.Set(pRect->left + 5, pRect->top + 13, pRect->width - 14, - pRect->height - 18); - FillSoildRect(pGraphics, 0xFFFFFFFF, &rtMin, pMatrix); -} -void CFWL_FormTP::DrawMaximizeBox(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - FX_BOOL bMax, - CFX_Matrix* pMatrix, - int32_t iActive) { - DrawMinMaxBoxCommon(pGraphics, pRect, eState, pMatrix); - FX_FLOAT fWidth = pRect->width; - FX_FLOAT fHeight = pRect->height; - if (bMax) { - CFX_Path path; - path.Create(); - path.AddLine(pRect->left + 7, pRect->top + 6, pRect->left + 14, - pRect->top + 6); - path.AddLine(pRect->left + 4, pRect->top + 9, pRect->left + 11, - pRect->top + 9); - pGraphics->SaveGraphState(); - pGraphics->SetLineWidth(2); - CFX_Color crStroke(0xFFFFFFFF); - pGraphics->SetStrokeColor(&crStroke); - pGraphics->StrokePath(&path, pMatrix); - pGraphics->SetLineWidth(1); - path.Clear(); - path.AddLine(pRect->left + 4, pRect->top + 10, pRect->left + 4, - pRect->top + 14); - path.AddLine(pRect->left + 10, pRect->top + 10, pRect->left + 10, - pRect->top + 14); - path.AddLine(pRect->left + 13, pRect->top + 7, pRect->left + 13, - pRect->top + 11); - path.AddLine(pRect->left + 4, pRect->top + 14, pRect->left + 10, - pRect->top + 14); - path.AddLine(pRect->left + 12, pRect->top + 11, pRect->left + 12, - pRect->top + 11); - pGraphics->StrokePath(&path, pMatrix); - pGraphics->RestoreGraphState(); - } else { - CFX_RectF rtMax(*pRect); - rtMax.Inflate(-5, -5); - CFX_Path path; - path.Create(); - path.AddRectangle(pRect->left + 5, pRect->top + 5, fWidth - 10, - fHeight - 10); - path.AddRectangle(pRect->left + 6, pRect->top + 8, fWidth - 12, - fHeight - 14); - pGraphics->SaveGraphState(); - CFX_Color crFill(0xFFFFFFFF); - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix); - pGraphics->RestoreGraphState(); - } -} -void CFWL_FormTP::DrawIconImage(CFX_Graphics* pGraphics, - CFX_DIBitmap* pDIBitmap, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive) { - pGraphics->StretchImage(pDIBitmap, *pRect, pMatrix); -} -void CFWL_FormTP::SetThemeData(uint32_t dwID) { - m_pThemeData->clrTransWhite = ArgbEncode(0x65, 255, 255, 255); - m_pThemeData->clrCloseBtBKStart[0][0] = ArgbEncode(0xff, 240, 166, 148); - m_pThemeData->clrCloseBtBKEnd[0][0] = ArgbEncode(0xff, 228, 61, 5); - m_pThemeData->clrCloseBtBKStart[0][1] = ArgbEncode(0xff, 255, 184, 176); - m_pThemeData->clrCloseBtBKEnd[0][1] = ArgbEncode(0xff, 252, 107, 71); - m_pThemeData->clrCloseBtBKStart[0][2] = ArgbEncode(0xff, 141, 44, 20); - m_pThemeData->clrCloseBtBKEnd[0][2] = ArgbEncode(0xff, 202, 72, 33); - m_pThemeData->clrCloseBtEdgeLight[0][0] = ArgbEncode(0xff, 255, 122, 107); - m_pThemeData->clrCloseBtEdgeDark[0][0] = ArgbEncode(0xff, 218, 77, 54); - m_pThemeData->clrCloseBtEdgeLight[0][1] = ArgbEncode(0xff, 255, 93, 74); - m_pThemeData->clrCloseBtEdgeDark[0][1] = ArgbEncode(0xff, 218, 74, 51); - m_pThemeData->clrCloseBtEdgeLight[0][2] = ArgbEncode(0xff, 191, 61, 28); - m_pThemeData->clrCloseBtEdgeDark[0][2] = ArgbEncode(0xff, 93, 30, 13); - if (dwID) { - m_pThemeData->clrHeadBK[0][0] = ArgbEncode(0xff, 194, 205, 149); - m_pThemeData->clrHeadBK[0][1] = ArgbEncode(0xff, 170, 184, 131); - m_pThemeData->clrHeadBK[0][2] = ArgbEncode(0xff, 168, 182, 128); - m_pThemeData->clrHeadBK[0][3] = ArgbEncode(0xff, 194, 205, 149); - m_pThemeData->clrHeadEdgeLeft[0][0] = ArgbEncode(0xff, 117, 141, 94); - m_pThemeData->clrHeadEdgeLeft[0][1] = ArgbEncode(0xff, 139, 161, 105); - m_pThemeData->clrHeadEdgeLeft[0][2] = ArgbEncode(0xff, 171, 189, 133); - m_pThemeData->clrHeadEdgeRight[0][0] = ArgbEncode(0xff, 155, 175, 125); - m_pThemeData->clrHeadEdgeRight[0][1] = ArgbEncode(0xff, 128, 146, 103); - m_pThemeData->clrHeadEdgeRight[0][2] = ArgbEncode(0xff, 94, 118, 79); - m_pThemeData->clrHeadEdgeTop[0][0] = ArgbEncode(0xff, 139, 161, 105); - m_pThemeData->clrHeadEdgeTop[0][1] = ArgbEncode(0xff, 234, 245, 201); - m_pThemeData->clrHeadEdgeTop[0][2] = ArgbEncode(0xff, 194, 205, 149); - m_pThemeData->clrHeadEdgeBottom[0][0] = ArgbEncode(0xff, 175, 189, 133); - m_pThemeData->clrHeadEdgeBottom[0][1] = ArgbEncode(0xff, 153, 168, 121); - m_pThemeData->clrHeadEdgeBottom[0][2] = ArgbEncode(0xff, 150, 168, 103); - m_pThemeData->clrNormalBtBKStart[0][0] = ArgbEncode(0xff, 182, 195, 162); - m_pThemeData->clrNormalBtBKEnd[0][0] = ArgbEncode(0xff, 128, 144, 84); - m_pThemeData->clrNormalBtBKStart[0][1] = ArgbEncode(0xff, 234, 241, 208); - m_pThemeData->clrNormalBtBKEnd[0][1] = ArgbEncode(0xff, 169, 186, 112); - m_pThemeData->clrNormalBtBKStart[0][2] = ArgbEncode(0xff, 199, 199, 190); - m_pThemeData->clrNormalBtBKEnd[0][2] = ArgbEncode(0xff, 133, 148, 88); - m_pThemeData->clrNormalBtEdgeLight[0][0] = ArgbEncode(0xff, 163, 176, 137); - m_pThemeData->clrNormalBtEdgeDark[0][0] = ArgbEncode(0xff, 118, 135, 83); - m_pThemeData->clrNormalBtEdgeLight[0][1] = ArgbEncode(0xff, 154, 174, 105); - m_pThemeData->clrNormalBtEdgeDark[0][1] = ArgbEncode(0xff, 154, 174, 105); - m_pThemeData->clrNormalBtEdgeLight[0][2] = ArgbEncode(0xff, 172, 193, 123); - m_pThemeData->clrNormalBtEdgeDark[0][2] = ArgbEncode(0xff, 154, 174, 105); - m_pThemeData->clrBtnCornerLight[0][0] = ArgbEncode(0xff, 220, 220, 220); - m_pThemeData->clrBtnCornerLight[0][1] = ArgbEncode(0xff, 255, 255, 255); - m_pThemeData->clrBtnCornerLight[0][2] = ArgbEncode(0xff, 225, 225, 225); - m_pThemeData->clrBtnEdgeOut[0] = ArgbEncode(0xff, 255, 255, 255); - m_pThemeData->clrFormBorder[0][0] = ArgbEncode(0xff, 117, 141, 94); - m_pThemeData->clrFormBorder[0][1] = ArgbEncode(0xff, 139, 161, 105); - m_pThemeData->clrFormBorder[0][2] = ArgbEncode(0xff, 171, 189, 133); - m_pThemeData->clrFormBorder[0][3] = ArgbEncode(0xff, 164, 178, 127); - m_pThemeData->clrFormBorder[0][4] = ArgbEncode(0xff, 255, 255, 255); - m_pThemeData->clrFormBorderLight[0] = ArgbEncode(0xff, 171, 189, 133); - } else { - m_pThemeData->clrHeadBK[0][0] = ArgbEncode(0xff, 3, 114, 255); - m_pThemeData->clrHeadBK[0][1] = ArgbEncode(0xff, 0, 85, 226); - m_pThemeData->clrHeadBK[0][2] = ArgbEncode(0xff, 0, 85, 226); - m_pThemeData->clrHeadBK[0][3] = ArgbEncode(0xff, 3, 114, 255); - m_pThemeData->clrHeadEdgeLeft[0][2] = ArgbEncode(0xff, 0, 32, 200); - m_pThemeData->clrHeadEdgeLeft[0][1] = ArgbEncode(0xff, 0, 61, 220); - m_pThemeData->clrHeadEdgeLeft[0][0] = ArgbEncode(0xff, 0, 54, 210); - m_pThemeData->clrHeadEdgeRight[0][0] = ArgbEncode(0xff, 0, 56, 234); - m_pThemeData->clrHeadEdgeRight[0][1] = ArgbEncode(0xff, 0, 50, 193); - m_pThemeData->clrHeadEdgeRight[0][2] = ArgbEncode(0xff, 0, 19, 139); - m_pThemeData->clrHeadEdgeTop[0][0] = ArgbEncode(0xff, 0, 88, 238); - m_pThemeData->clrHeadEdgeTop[0][1] = ArgbEncode(0xff, 63, 151, 255); - m_pThemeData->clrHeadEdgeTop[0][2] = ArgbEncode(0xff, 3, 114, 255); - m_pThemeData->clrHeadEdgeBottom[0][0] = ArgbEncode(0xff, 0, 96, 252); - m_pThemeData->clrHeadEdgeBottom[0][1] = ArgbEncode(0xff, 63, 151, 255); - m_pThemeData->clrHeadEdgeBottom[0][2] = ArgbEncode(0xff, 0, 67, 207); - m_pThemeData->clrNormalBtBKStart[0][2] = ArgbEncode(0xff, 0, 49, 112); - m_pThemeData->clrNormalBtBKEnd[0][2] = ArgbEncode(0xff, 0, 87, 188); - m_pThemeData->clrNormalBtBKStart[0][0] = ArgbEncode(0xff, 154, 183, 250); - m_pThemeData->clrNormalBtBKEnd[0][0] = ArgbEncode(0xff, 17, 110, 248); - m_pThemeData->clrNormalBtBKStart[0][1] = ArgbEncode(0xff, 164, 194, 255); - m_pThemeData->clrNormalBtBKEnd[0][1] = ArgbEncode(0xff, 29, 158, 255); - m_pThemeData->clrNormalBtEdgeLight[0][0] = ArgbEncode(0xff, 68, 120, 245); - m_pThemeData->clrNormalBtEdgeDark[0][0] = ArgbEncode(0xff, 24, 72, 187); - m_pThemeData->clrNormalBtEdgeLight[0][1] = ArgbEncode(0xff, 72, 122, 245); - m_pThemeData->clrNormalBtEdgeDark[0][1] = ArgbEncode(0xff, 35, 87, 195); - m_pThemeData->clrNormalBtEdgeLight[0][2] = ArgbEncode(0xff, 60, 114, 244); - m_pThemeData->clrNormalBtEdgeDark[0][2] = ArgbEncode(0xff, 21, 70, 185); - m_pThemeData->clrBtnCornerLight[0][0] = ArgbEncode(0xff, 220, 220, 220); - m_pThemeData->clrBtnCornerLight[0][1] = ArgbEncode(0xff, 255, 255, 255); - m_pThemeData->clrBtnCornerLight[0][2] = ArgbEncode(0xff, 225, 225, 225); - m_pThemeData->clrBtnEdgeOut[0] = ArgbEncode(0xff, 255, 255, 255); - m_pThemeData->clrFormBorder[0][0] = ArgbEncode(0xff, 0, 72, 241); - m_pThemeData->clrFormBorder[0][1] = ArgbEncode(0xff, 0, 61, 220); - m_pThemeData->clrFormBorder[0][2] = ArgbEncode(0xff, 0, 30, 160); - m_pThemeData->clrFormBorder[0][3] = ArgbEncode(0xff, 0, 19, 140); - m_pThemeData->clrFormBorder[0][4] = ArgbEncode(0xff, 255, 255, 255); - m_pThemeData->clrFormBorderLight[0] = ArgbEncode(0xff, 22, 106, 239); - } - m_pThemeData->clrCloseBtBKStart[1][0] = m_pThemeData->clrCloseBtBKStart[0][0]; - m_pThemeData->clrCloseBtBKEnd[1][0] = m_pThemeData->clrCloseBtBKEnd[0][0]; - m_pThemeData->clrCloseBtBKStart[1][1] = m_pThemeData->clrCloseBtBKStart[0][1]; - m_pThemeData->clrCloseBtBKEnd[1][1] = m_pThemeData->clrCloseBtBKEnd[0][1]; - m_pThemeData->clrCloseBtBKStart[1][2] = m_pThemeData->clrCloseBtBKStart[0][2]; - m_pThemeData->clrCloseBtBKEnd[1][2] = m_pThemeData->clrCloseBtBKEnd[0][2]; - m_pThemeData->clrCloseBtEdgeLight[1][0] = - m_pThemeData->clrCloseBtEdgeLight[0][0]; - m_pThemeData->clrCloseBtEdgeDark[1][0] = - m_pThemeData->clrCloseBtEdgeDark[0][0]; - m_pThemeData->clrCloseBtEdgeLight[1][1] = - m_pThemeData->clrCloseBtEdgeLight[0][1]; - m_pThemeData->clrCloseBtEdgeDark[1][1] = - m_pThemeData->clrCloseBtEdgeDark[0][1]; - m_pThemeData->clrCloseBtEdgeLight[1][2] = - m_pThemeData->clrCloseBtEdgeLight[0][2]; - m_pThemeData->clrCloseBtEdgeDark[1][2] = - m_pThemeData->clrCloseBtEdgeDark[0][2]; - m_pThemeData->clrHeadBK[1][0] = m_pThemeData->clrHeadBK[0][0]; - m_pThemeData->clrHeadBK[1][1] = m_pThemeData->clrHeadBK[0][1]; - m_pThemeData->clrHeadBK[1][2] = m_pThemeData->clrHeadBK[0][2]; - m_pThemeData->clrHeadBK[1][3] = m_pThemeData->clrHeadBK[0][3]; - m_pThemeData->clrHeadEdgeLeft[1][2] = m_pThemeData->clrHeadEdgeLeft[0][2]; - m_pThemeData->clrHeadEdgeLeft[1][1] = m_pThemeData->clrHeadEdgeLeft[0][1]; - m_pThemeData->clrHeadEdgeLeft[1][0] = m_pThemeData->clrHeadEdgeLeft[0][0]; - m_pThemeData->clrHeadEdgeRight[1][0] = m_pThemeData->clrHeadEdgeRight[0][0]; - m_pThemeData->clrHeadEdgeRight[1][1] = m_pThemeData->clrHeadEdgeRight[0][1]; - m_pThemeData->clrHeadEdgeRight[1][2] = m_pThemeData->clrHeadEdgeRight[0][2]; - m_pThemeData->clrHeadEdgeTop[1][0] = m_pThemeData->clrHeadEdgeTop[0][0]; - m_pThemeData->clrHeadEdgeTop[1][1] = m_pThemeData->clrHeadEdgeTop[0][1]; - m_pThemeData->clrHeadEdgeTop[1][2] = m_pThemeData->clrHeadEdgeTop[0][2]; - m_pThemeData->clrHeadEdgeBottom[1][0] = m_pThemeData->clrHeadEdgeBottom[0][0]; - m_pThemeData->clrHeadEdgeBottom[1][1] = m_pThemeData->clrHeadEdgeBottom[0][1]; - m_pThemeData->clrHeadEdgeBottom[1][2] = m_pThemeData->clrHeadEdgeBottom[0][2]; - m_pThemeData->clrNormalBtBKStart[1][2] = - m_pThemeData->clrNormalBtBKStart[0][2]; - m_pThemeData->clrNormalBtBKEnd[1][2] = m_pThemeData->clrNormalBtBKEnd[0][2]; - m_pThemeData->clrNormalBtBKStart[1][0] = - m_pThemeData->clrNormalBtBKStart[0][0]; - m_pThemeData->clrNormalBtBKEnd[1][0] = m_pThemeData->clrNormalBtBKEnd[1][0]; - m_pThemeData->clrNormalBtBKStart[1][1] = - m_pThemeData->clrNormalBtBKStart[0][1]; - m_pThemeData->clrNormalBtBKEnd[1][1] = m_pThemeData->clrNormalBtBKEnd[0][1]; - m_pThemeData->clrNormalBtEdgeLight[1][0] = - m_pThemeData->clrNormalBtEdgeLight[0][0]; - m_pThemeData->clrNormalBtEdgeDark[1][0] = - m_pThemeData->clrNormalBtEdgeDark[0][0]; - m_pThemeData->clrNormalBtEdgeLight[1][1] = - m_pThemeData->clrNormalBtEdgeLight[0][1]; - m_pThemeData->clrNormalBtEdgeDark[1][1] = - m_pThemeData->clrNormalBtEdgeDark[0][1]; - m_pThemeData->clrNormalBtEdgeLight[1][2] = - m_pThemeData->clrNormalBtEdgeLight[0][2]; - m_pThemeData->clrNormalBtEdgeDark[1][2] = - m_pThemeData->clrNormalBtEdgeDark[0][2]; - m_pThemeData->clrBtnCornerLight[1][0] = m_pThemeData->clrBtnCornerLight[0][0]; - m_pThemeData->clrBtnCornerLight[1][1] = m_pThemeData->clrBtnCornerLight[0][1]; - m_pThemeData->clrBtnCornerLight[1][2] = m_pThemeData->clrBtnCornerLight[0][2]; - m_pThemeData->clrBtnEdgeOut[1] = m_pThemeData->clrBtnEdgeOut[0]; - m_pThemeData->clrFormBorder[1][0] = m_pThemeData->clrFormBorder[0][0]; - m_pThemeData->clrFormBorder[1][1] = m_pThemeData->clrFormBorder[0][1]; - m_pThemeData->clrFormBorder[1][2] = m_pThemeData->clrFormBorder[0][2]; - m_pThemeData->clrFormBorder[1][3] = m_pThemeData->clrFormBorder[0][3]; - m_pThemeData->clrFormBorder[1][4] = m_pThemeData->clrFormBorder[0][4]; - m_pThemeData->clrFormBorderLight[1] = m_pThemeData->clrFormBorderLight[0]; - DeactiveForm(); -} -void CFWL_FormTP::DeactiveForm() { - TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][3]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeLeft[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeLeft[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeLeft[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeRight[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeRight[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeRight[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeTop[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeTop[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeTop[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeBottom[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeBottom[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrHeadEdgeBottom[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtBKStart[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtBKStart[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtBKStart[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtBKEnd[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtBKEnd[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtBKEnd[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtEdgeLight[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtEdgeLight[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtEdgeLight[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtEdgeDark[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtEdgeDark[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrNormalBtEdgeDark[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrBtnCornerLight[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrBtnCornerLight[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrBtnCornerLight[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrBtnEdgeOut[1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrFormBorder[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrFormBorder[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrFormBorder[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrFormBorder[1][3]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrFormBorder[1][4]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrFormBorderLight[1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtBKStart[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtBKStart[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtBKStart[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtBKEnd[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtBKEnd[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtBKEnd[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtEdgeLight[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtEdgeLight[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtEdgeLight[1][2]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtEdgeDark[1][0]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtEdgeDark[1][1]); - TransModeColor(m_pThemeData->clrTransWhite, - m_pThemeData->clrCloseBtEdgeDark[1][2]); -} -void CFWL_FormTP::TransModeColor(FX_ARGB clrFore, FX_ARGB& clrBack) { - int32_t iAlfaF, iRF, iGF, iBF; - int32_t iAlfaB, iRB, iGB, iBB; - ArgbDecode(clrFore, iAlfaF, iRF, iGF, iBF); - ArgbDecode(clrBack, iAlfaB, iRB, iGB, iBB); - clrBack = ArgbEncode(0xff, iRB + (iRF - iRB) * iAlfaF / 255, - iGB + (iGF - iGB) * iAlfaF / 255, - iBB + (iBF - iBB) * iAlfaF / 255); -} -void CFWL_FormTP::InitCaption(FX_BOOL bActive) { - if (bActive) { - CFX_FxgeDevice dev; - CFX_Graphics gs; - CFX_Path path; - path.Create(); - if (m_pActiveBitmap) { - delete m_pActiveBitmap; - m_pActiveBitmap = NULL; - } - m_pActiveBitmap = new CFX_DIBitmap; - m_pActiveBitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb); - dev.Attach(m_pActiveBitmap); - gs.Create(&dev); - path.AddRectangle(0, 0, 1, 5); - DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[0][0], - m_pThemeData->clrHeadBK[0][1], &path); - path.Clear(); - path.AddRectangle(0, 5, 1, 15); - DrawAxialShading(&gs, 0, 5, 0, 20, m_pThemeData->clrHeadBK[0][1], - m_pThemeData->clrHeadBK[0][2], &path); - path.Clear(); - path.AddRectangle(0, 20, 1, FWLTHEME_CAPACITY_CYCaption - 19); - DrawAxialShading(&gs, 0, 20, 0, FWLTHEME_CAPACITY_CYCaption, - m_pThemeData->clrHeadBK[0][2], - m_pThemeData->clrHeadBK[0][3], &path); - } else { - CFX_FxgeDevice dev; - CFX_Graphics gs; - CFX_Path path; - path.Create(); - if (m_pDeactivebitmap) { - delete m_pDeactivebitmap; - m_pDeactivebitmap = NULL; - } - m_pDeactivebitmap = new CFX_DIBitmap; - m_pDeactivebitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb); - dev.Attach(m_pDeactivebitmap); - gs.Create(&dev); - path.AddRectangle(0, 0, 1, 5); - DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[1][0], - m_pThemeData->clrHeadBK[1][1], &path); - path.Clear(); - path.AddRectangle(0, 5, 1, 15); - DrawAxialShading(&gs, 0, 5, 0, 20, m_pThemeData->clrHeadBK[1][1], - m_pThemeData->clrHeadBK[1][2], &path); - path.Clear(); - path.AddRectangle(0, 20, 1, FWLTHEME_CAPACITY_CYCaption - 19); - DrawAxialShading(&gs, 0, 20, 0, FWLTHEME_CAPACITY_CYCaption, - m_pThemeData->clrHeadBK[1][2], - m_pThemeData->clrHeadBK[1][3], &path); - } -} diff --git a/xfa/fwl/theme/listboxtp.cpp b/xfa/fwl/theme/listboxtp.cpp deleted file mode 100644 index 5c38166afa..0000000000 --- a/xfa/fwl/theme/listboxtp.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// 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/include/fwl/theme/listboxtp.h" - -#include "xfa/fwl/basewidget/ifwl_listbox.h" -#include "xfa/fwl/core/cfwl_themebackground.h" -#include "xfa/fwl/core/ifwl_widget.h" -#include "xfa/fxgraphics/cfx_color.h" -#include "xfa/fxgraphics/cfx_path.h" - -CFWL_ListBoxTP::CFWL_ListBoxTP() {} -CFWL_ListBoxTP::~CFWL_ListBoxTP() {} - -FX_BOOL CFWL_ListBoxTP::IsValidWidget(IFWL_Widget* pWidget) { - if (!pWidget) - return FALSE; - return pWidget->GetClassID() == FWL_CLASSHASH_ListBox; -} -FX_BOOL CFWL_ListBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { - if (!pParams) - return FALSE; - switch (pParams->m_iPart) { - case FWL_PART_LTB_Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_LTB_Edge: { - DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), - &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_LTB_Background: { - FillSoildRect(pParams->m_pGraphics, ArgbEncode(255, 255, 255, 255), - &pParams->m_rtPart, &pParams->m_matrix); - if (pParams->m_pData) { - FillSoildRect(pParams->m_pGraphics, FWLTHEME_COLOR_Background, - (CFX_RectF*)pParams->m_pData, &pParams->m_matrix); - } - break; - } - case FWL_PART_LTB_ListItem: { - DrawListBoxItem(pParams->m_pGraphics, pParams->m_dwStates, - &pParams->m_rtPart, pParams->m_pData, &pParams->m_matrix); - break; - } - case FWL_PART_LTB_Icon: { - pParams->m_pGraphics->StretchImage(pParams->m_pImage, pParams->m_rtPart, - &pParams->m_matrix); - break; - } - case FWL_PART_LTB_Check: { - uint32_t color = 0xFF000000; - if (pParams->m_dwStates == FWL_PARTSTATE_LTB_Checked) { - color = 0xFFFF0000; - } else if (pParams->m_dwStates == FWL_PARTSTATE_LTB_UnChecked) { - color = 0xFF0000FF; - } - FillSoildRect(pParams->m_pGraphics, color, &pParams->m_rtPart, - &pParams->m_matrix); - } - default: {} - } - return TRUE; -} -FWL_ERR CFWL_ListBoxTP::Initialize() { - InitTTO(); - return CFWL_WidgetTP::Initialize(); -} -FWL_ERR CFWL_ListBoxTP::Finalize() { - FinalizeTTO(); - return CFWL_WidgetTP::Finalize(); -} -void CFWL_ListBoxTP::DrawListBoxItem(CFX_Graphics* pGraphics, - uint32_t dwStates, - const CFX_RectF* prtItem, - void* pData, - CFX_Matrix* pMatrix) { - if (dwStates & FWL_PARTSTATE_LTB_Selected) { - pGraphics->SaveGraphState(); - CFX_Color crFill(FWL_GetThemeColor(m_dwThemeID) == 0 - ? FWLTHEME_COLOR_BKSelected - : FWLTHEME_COLOR_Green_BKSelected); - pGraphics->SetFillColor(&crFill); - CFX_RectF rt(*prtItem); - CFX_Path path; - path.Create(); -#if (_FX_OS_ == _FX_MACOSX_) - path.AddRectangle(rt.left, rt.top, rt.width - 1, rt.height - 1); -#else - path.AddRectangle(rt.left, rt.top, rt.width, rt.height); -#endif - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pGraphics->RestoreGraphState(); - } - if (dwStates & FWL_PARTSTATE_LTB_Focused) { - if (pData) { - DrawFocus(pGraphics, (CFX_RectF*)pData, pMatrix); - } - } -} diff --git a/xfa/fwl/theme/monthcalendartp.cpp b/xfa/fwl/theme/monthcalendartp.cpp deleted file mode 100644 index 2ae154860a..0000000000 --- a/xfa/fwl/theme/monthcalendartp.cpp +++ /dev/null @@ -1,587 +0,0 @@ -// 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/include/fwl/theme/monthcalendartp.h" - -#include "xfa/fde/tto/fde_textout.h" -#include "xfa/fwl/basewidget/ifwl_monthcalendar.h" -#include "xfa/fwl/core/cfwl_themebackground.h" -#include "xfa/fwl/core/cfwl_themetext.h" -#include "xfa/fwl/core/ifwl_themeprovider.h" -#include "xfa/fwl/core/ifwl_widget.h" -#include "xfa/fxgraphics/cfx_color.h" -#include "xfa/fxgraphics/cfx_path.h" - -#define FWL_THEMECAPACITY_MC_HEADER_WIDTH 200 -#define FWL_THEMECAPACITY_MC_HEADER_HEIGHT 30 -#define FWL_THEMECAPACITY_MC_HEADER_BTN_WIDTH 18 -#define FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT 16 -#define FWL_THEMECAPACITY_MC_HEADER_BTN_HMARGIN 5 -#define FWL_THEMECAPACITY_MC_HEADER_BTN_VMARGIN \ - (FWL_THEMECAPACITY_MC_HEADER_HEIGHT - \ - FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT) / \ - 2 -#define FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT 100 -#define FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT 20 -#define FWL_THEMECAPACITY_MC_HEADER_TEXT_HMARGIN \ - (FWL_THEMECAPACITY_MC_HEADER_WIDTH - \ - FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT) / \ - 2 -#define FWL_THEMECAPACITY_MC_HEADER_TEXT_VMARGIN \ - (FWL_THEMECAPACITY_MC_HEADER_HEIGHT - \ - FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT) / \ - 2 -#define FWL_THEMECAPACITY_MC_HSEP_WIDTH (FWL_THEMECAPACITY_MC_WEEK_WIDTH - 10) -#define FWL_THEMECAPACITY_MC_HSEP_HEIGHT 1 -#define FWL_THEMECAPACITY_MC_VSEP_WIDTH 1 -#define FWL_THEMECAPACITY_MC_VSEP_HEIGHT FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT -#define FWL_THEMECAPACITY_MC_WEEKNUM_WIDTH 26 -#define FWL_THEMECAPACITY_MC_SEP_DOFFSET -4 -#define FWL_THEMECAPACITY_MC_SEP_X 3 -#define FWL_THEMECAPACITY_MC_SEP_Y \ - (FWL_THEMECAPACITY_MC_HEADER_HEIGHT + FWL_THEMECAPACITY_MC_WEEK_HEIGHT + \ - FWL_THEMECAPACITY_MC_SEP_DOFFSET) -#define FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT \ - (6 * FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT) -#define FWL_THEMECAPACITY_MC_WEEK_WIDTH \ - (FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH * 7) -#define FWL_THEMECAPACITY_MC_WEEK_HEIGHT FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT -#define FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH \ - (FWL_THEMECAPACITY_MC_HEADER_WIDTH / 7) -#define FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT 16 -#define FWL_THEMECAPACITY_MC_TODAY_WIDHT FWL_THEMECAPACITY_MC_HEADER_WIDTH -#define FWL_THEMECAPACITY_MC_TODAY_HEIGHT FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT -#define FWL_THEMECAPACITY_MC_TODAY_FLAG_WIDHT \ - FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH -#define FWL_MC_WIDTH 200 -#define FWL_MC_HEIGHT 160 - -CFWL_MonthCalendarTP::CFWL_MonthCalendarTP() { - m_pThemeData = new MCThemeData; - SetThemeData(0); -} -CFWL_MonthCalendarTP::~CFWL_MonthCalendarTP() { - delete m_pThemeData; -} -FX_BOOL CFWL_MonthCalendarTP::IsValidWidget(IFWL_Widget* pWidget) { - if (!pWidget) - return FALSE; - return pWidget->GetClassID() == FWL_CLASSHASH_MonthCalendar; -} -uint32_t CFWL_MonthCalendarTP::SetThemeID(IFWL_Widget* pWidget, - uint32_t dwThemeID, - FX_BOOL bChildren) { - if (m_pThemeData) { - SetThemeData(FWL_GetThemeColor(dwThemeID)); - } - return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren); -} -FX_BOOL CFWL_MonthCalendarTP::DrawBackground(CFWL_ThemeBackground* pParams) { - if (!pParams) - return FALSE; - switch (pParams->m_iPart) { - case FWL_PART_MCD_Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_MCD_Edge: { - DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), - &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_MCD_Background: { - DrawTotalBK(pParams, &pParams->m_matrix); - break; - } - case FWL_PART_MCD_Header: { - DrawHeadBk(pParams, &pParams->m_matrix); - break; - } - case FWL_PART_MCD_LBtn: { -#ifdef THEME_XPSimilar - FWLTHEME_STATE eState = GetState(pParams->m_dwStates); - DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, - FWLTHEME_DIRECTION_Left, eState, &pParams->m_matrix); -#else - DrawLButton(pParams, &pParams->m_matrix); -#endif - break; - } - case FWL_PART_MCD_RBtn: { -#ifdef THEME_XPSimilar - FWLTHEME_STATE eState = GetState(pParams->m_dwStates); - DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, - FWLTHEME_DIRECTION_Right, eState, &pParams->m_matrix); -#else - DrawRButton(pParams, &pParams->m_matrix); -#endif - break; - } - case FWL_PART_MCD_HSeparator: { - DrawHSeperator(pParams, &pParams->m_matrix); - break; - } - case FWL_PART_MCD_DatesIn: { - DrawDatesInBK(pParams, &pParams->m_matrix); - break; - } - case FWL_PART_MCD_TodayCircle: { - DrawTodayCircle(pParams, &pParams->m_matrix); - break; - } - case FWL_PART_MCD_DateInCircle: { - DrawDatesInCircle(pParams, &pParams->m_matrix); - break; - } - case FWL_PART_MCD_WeekNumSep: { - DrawWeekNumSep(pParams, &pParams->m_matrix); - break; - } - default: {} - } - return TRUE; -} -FX_BOOL CFWL_MonthCalendarTP::DrawText(CFWL_ThemeText* pParams) { - if (!m_pTextOut) - return FALSE; - if ((pParams->m_iPart == FWL_PART_MCD_DatesIn) && - !(pParams->m_dwStates & FWL_ITEMSTATE_MCD_Flag) && - (pParams->m_dwStates & - (FWL_PARTSTATE_MCD_Hovered | FWL_PARTSTATE_MCD_Selected))) { - m_pTextOut->SetTextColor(0xFFFFFFFF); - } else if (pParams->m_iPart == FWL_PART_MCD_Caption) { - m_pTextOut->SetTextColor(m_pThemeData->clrCaption); - } else { - m_pTextOut->SetTextColor(0xFF000000); - } - return CFWL_WidgetTP::DrawText(pParams); -} -void* CFWL_MonthCalendarTP::GetCapacity(CFWL_ThemePart* pThemePart, - uint32_t dwCapacity) { - FX_BOOL bDefPro = FALSE; - FX_BOOL bDwordVal = FALSE; - switch (dwCapacity) { - case FWL_WGTCAPACITY_MC_HEADER_WIDTH: { - m_fValue = FWL_THEMECAPACITY_MC_HEADER_WIDTH; - break; - } - case FWL_WGTCAPACITY_MC_HEADER_Height: { - m_fValue = FWL_THEMECAPACITY_MC_HEADER_HEIGHT; - break; - } - case FWL_WGTCAPACITY_MC_HEADER_BTN_WIDTH: { - m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_WIDTH; - break; - } - case FWL_WGTCAPACITY_MC_HEADER_BTN_HEIGHT: { - m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_HEIGHT; - break; - } - case FWL_WGTCAPACITY_MC_HEADER_BTN_HMARGIN: { - bDwordVal = TRUE; - m_dwValue = FWL_THEMECAPACITY_MC_HEADER_BTN_HMARGIN; - break; - } - case FWL_WGTCAPACITY_MC_HEADER_BTN_VMARGIN: { - m_fValue = FWL_THEMECAPACITY_MC_HEADER_BTN_VMARGIN; - break; - } - case FWL_WGTCAPACITY_MC_HEADER_TEXTWIDHT: { - m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXTWIDHT; - break; - } - case FWL_WGTCAPACITY_MC_HEADER_TEXTHEIGHT: { - m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXTHEIGHT; - break; - } - case FWL_WGTCAPACITY_MC_HEADER_TEXT_HMARGIN: { - m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXT_HMARGIN; - break; - } - case FWL_WGTCAPACITY_MC_HEADER_TEXT_VMARGIN: { - m_fValue = FWL_THEMECAPACITY_MC_HEADER_TEXT_VMARGIN; - break; - } - case FWL_WGTCAPACITY_MC_HSEP_WIDTH: { - m_fValue = FWL_THEMECAPACITY_MC_HSEP_WIDTH; - break; - } - case FWL_WGTCAPACITY_MC_HSEP_HEIGHT: { - m_fValue = FWL_THEMECAPACITY_MC_HSEP_HEIGHT; - break; - } - case FWL_WGTCAPACITY_MC_VSEP_WIDTH: { - m_fValue = FWL_THEMECAPACITY_MC_VSEP_WIDTH; - break; - } - case FWL_WGTCAPACITY_MC_VSEP_HEIGHT: { - m_fValue = FWL_THEMECAPACITY_MC_VSEP_HEIGHT; - break; - } - case FWL_WGTCAPACITY_MC_WEEKNUM_WIDTH: { - m_fValue = FWL_THEMECAPACITY_MC_WEEKNUM_WIDTH; - break; - } - case FWL_WGTCAPACITY_MC_WEEKNUM_HEIGHT: { - m_fValue = FWL_THEMECAPACITY_MC_WEEKNUM_HEIGHT; - break; - } - case FWL_WGTCAPACITY_MC_WEEK_WIDTH: { - m_fValue = FWL_THEMECAPACITY_MC_WEEK_WIDTH; - break; - } - case FWL_WGTCAPACITY_MC_WEEK_HEIGHT: { - m_fValue = FWL_THEMECAPACITY_MC_WEEK_HEIGHT; - break; - } - case FWL_WGTCAPACITY_MC_SEP_DOFFSET: { - m_fValue = FWL_THEMECAPACITY_MC_SEP_DOFFSET; - break; - } - case FWL_WGTCAPACITY_MC_SEP_X: { - m_fValue = FWL_THEMECAPACITY_MC_SEP_X; - break; - } - case FWL_WGTCAPACITY_MC_SEP_Y: { - m_fValue = FWL_THEMECAPACITY_MC_SEP_Y; - break; - } - case FWL_WGTCAPACITY_MC_DATES_CELL_WIDTH: { - m_fValue = FWL_THEMECAPACITY_MC_DATES_CELL_WIDTH; - break; - } - case FWL_WGTCAPACITY_MC_DATES_CELL_HEIGHT: { - m_fValue = FWL_THEMECAPACITY_MC_DATES_CELL_HEIGHT; - break; - } - case FWL_WGTCAPACITY_MC_TODAY_WIDHT: { - m_fValue = FWL_THEMECAPACITY_MC_TODAY_WIDHT; - break; - } - case FWL_WGTCAPACITY_MC_TODAY_HEIGHT: { - m_fValue = FWL_THEMECAPACITY_MC_TODAY_HEIGHT; - break; - } - case FWL_WGTCAPACITY_MC_TODAY_FLAG_WIDHT: { - m_fValue = FWL_THEMECAPACITY_MC_TODAY_FLAG_WIDHT; - break; - } - case FWL_WGTCAPACITY_MC_WIDTH: { - m_fValue = FWL_MC_WIDTH; - break; - } - case FWL_WGTCAPACITY_MC_HEIGHT: { - m_fValue = FWL_MC_HEIGHT; - break; - } - case FWL_MCCAPACITY_Sun: { - wsResource = L"Sun"; - return &wsResource; - } - case FWL_MCCAPACITY_Mon: { - wsResource = L"Mon"; - return &wsResource; - } - case FWL_MCCAPACITY_Tue: { - wsResource = L"Tue"; - return &wsResource; - } - case FWL_MCCAPACITY_Wed: { - wsResource = L"Wed"; - return &wsResource; - } - case FWL_MCCAPACITY_Thu: { - wsResource = L"Thu"; - return &wsResource; - } - case FWL_MCCAPACITY_Fri: { - wsResource = L"Fri"; - return &wsResource; - } - case FWL_MCCAPACITY_Sat: { - wsResource = L"Sat"; - return &wsResource; - } - case FWL_MCCAPACITY_January: { - wsResource = L"January"; - return &wsResource; - } - case FWL_MCCAPACITY_February: { - wsResource = L"February"; - return &wsResource; - } - case FWL_MCCAPACITY_March: { - wsResource = L"March"; - return &wsResource; - } - case FWL_MCCAPACITY_April: { - wsResource = L"April"; - return &wsResource; - } - case FWL_MCCAPACITY_May: { - wsResource = L"May"; - return &wsResource; - } - case FWL_MCCAPACITY_June: { - wsResource = L"June"; - return &wsResource; - } - case FWL_MCCAPACITY_July: { - wsResource = L"July"; - return &wsResource; - } - case FWL_MCCAPACITY_August: { - wsResource = L"August"; - return &wsResource; - } - case FWL_MCCAPACITY_September: { - wsResource = L"September"; - return &wsResource; - } - case FWL_MCCAPACITY_October: { - wsResource = L"October"; - return &wsResource; - } - case FWL_MCCAPACITY_November: { - wsResource = L"November"; - return &wsResource; - } - case FWL_MCCAPACITY_December: { - wsResource = L"December"; - return &wsResource; - } - case FWL_MCCAPACITY_Today: { - wsResource = L"Today"; - return &wsResource; - } - default: { bDefPro = TRUE; } - } - if (!bDefPro) { - if (bDwordVal) { - return &m_dwValue; - } - return &m_fValue; - } - return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); -} -FWL_ERR CFWL_MonthCalendarTP::Initialize() { - InitTTO(); - return CFWL_WidgetTP::Initialize(); -} -FWL_ERR CFWL_MonthCalendarTP::Finalize() { - FinalizeTTO(); - return CFWL_WidgetTP::Finalize(); -} -FX_BOOL CFWL_MonthCalendarTP::DrawTotalBK(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - CFX_RectF rtTotal(pParams->m_rtPart); - path.AddRectangle(rtTotal.left, rtTotal.top, rtTotal.width, rtTotal.height); - pParams->m_pGraphics->SaveGraphState(); - CFX_Color clrBK(m_pThemeData->clrBK); - pParams->m_pGraphics->SetFillColor(&clrBK); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pParams->m_pGraphics->RestoreGraphState(); - return TRUE; -} -FX_BOOL CFWL_MonthCalendarTP::DrawHeadBk(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - CFX_RectF rtHead = pParams->m_rtPart; - path.AddRectangle(rtHead.left, rtHead.top, rtHead.width, rtHead.height); - pParams->m_pGraphics->SaveGraphState(); - CFX_Color clrHeadBK(m_pThemeData->clrBK); - pParams->m_pGraphics->SetFillColor(&clrHeadBK); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pParams->m_pGraphics->RestoreGraphState(); - return TRUE; -} -FX_BOOL CFWL_MonthCalendarTP::DrawLButton(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - CFX_RectF rtLBtn; - rtLBtn = pParams->m_rtPart; - path.AddRectangle(rtLBtn.left, rtLBtn.top, rtLBtn.width, rtLBtn.height); - pParams->m_pGraphics->SaveGraphState(); - CFX_Color clrLBtnEdge(ArgbEncode(0xff, 205, 219, 243)); - pParams->m_pGraphics->SetStrokeColor(&clrLBtnEdge); - pParams->m_pGraphics->StrokePath(&path, pMatrix); - if ((pParams->m_dwStates & FWL_PARTSTATE_MCD_Pressed) == - FWL_PARTSTATE_MCD_Pressed) { - CFX_Color clrLBtnFill(ArgbEncode(0xff, 174, 198, 242)); - pParams->m_pGraphics->SetFillColor(&clrLBtnFill); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - } else { - CFX_Color clrLBtnFill(ArgbEncode(0xff, 227, 235, 249)); - pParams->m_pGraphics->SetFillColor(&clrLBtnFill); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - } - path.Clear(); - path.MoveTo(rtLBtn.left + rtLBtn.Width() / 3 * 2, - rtLBtn.top + rtLBtn.height / 4); - path.LineTo(rtLBtn.left + rtLBtn.Width() / 3, rtLBtn.top + rtLBtn.height / 2); - path.LineTo(rtLBtn.left + rtLBtn.Width() / 3 * 2, - rtLBtn.bottom() - rtLBtn.height / 4); - CFX_Color clrFlag(ArgbEncode(0xff, 50, 104, 205)); - pParams->m_pGraphics->SetStrokeColor(&clrFlag); - pParams->m_pGraphics->StrokePath(&path, pMatrix); - pParams->m_pGraphics->RestoreGraphState(); - return TRUE; -} -FX_BOOL CFWL_MonthCalendarTP::DrawRButton(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - CFX_RectF rtRBtn; - rtRBtn = pParams->m_rtPart; - path.AddRectangle(rtRBtn.left, rtRBtn.top, rtRBtn.width, rtRBtn.height); - pParams->m_pGraphics->SaveGraphState(); - CFX_Color clrRBtnEdge(ArgbEncode(0xff, 205, 219, 243)); - pParams->m_pGraphics->SetStrokeColor(&clrRBtnEdge); - pParams->m_pGraphics->StrokePath(&path, pMatrix); - if ((pParams->m_dwStates & FWL_PARTSTATE_MCD_Pressed) == - FWL_PARTSTATE_MCD_Pressed) { - CFX_Color clrRBtnFill(ArgbEncode(0xff, 174, 198, 242)); - pParams->m_pGraphics->SetFillColor(&clrRBtnFill); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - } else { - CFX_Color clrRBtnFill(ArgbEncode(0xff, 227, 235, 249)); - pParams->m_pGraphics->SetFillColor(&clrRBtnFill); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - } - path.Clear(); - path.MoveTo(rtRBtn.left + rtRBtn.Width() / 3, rtRBtn.top + rtRBtn.height / 4); - path.LineTo(rtRBtn.left + rtRBtn.Width() / 3 * 2, - rtRBtn.top + rtRBtn.height / 2); - path.LineTo(rtRBtn.left + rtRBtn.Width() / 3, - rtRBtn.bottom() - rtRBtn.height / 4); - CFX_Color clrFlag(ArgbEncode(0xff, 50, 104, 205)); - pParams->m_pGraphics->SetStrokeColor(&clrFlag); - pParams->m_pGraphics->StrokePath(&path, pMatrix); - pParams->m_pGraphics->RestoreGraphState(); - return TRUE; -} -FX_BOOL CFWL_MonthCalendarTP::DrawHSeperator(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - CFX_RectF rtHSep; - rtHSep = pParams->m_rtPart; - path.MoveTo(rtHSep.left, rtHSep.top + rtHSep.height / 2); - path.LineTo(rtHSep.right(), rtHSep.top + rtHSep.height / 2); - pParams->m_pGraphics->SaveGraphState(); - CFX_Color clrHSep(m_pThemeData->clrSeperator); - pParams->m_pGraphics->SetStrokeColor(&clrHSep); - pParams->m_pGraphics->StrokePath(&path, pMatrix); - pParams->m_pGraphics->RestoreGraphState(); - return TRUE; -} -FX_BOOL CFWL_MonthCalendarTP::DrawWeekNumSep(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - CFX_RectF rtWeekSep; - rtWeekSep = pParams->m_rtPart; - path.MoveTo(rtWeekSep.left, rtWeekSep.top); - path.LineTo(rtWeekSep.left, rtWeekSep.bottom()); - pParams->m_pGraphics->SaveGraphState(); - CFX_Color clrHSep(m_pThemeData->clrSeperator); - pParams->m_pGraphics->SetStrokeColor(&clrHSep); - pParams->m_pGraphics->StrokePath(&path, pMatrix); - pParams->m_pGraphics->RestoreGraphState(); - return TRUE; -} -FX_BOOL CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - pParams->m_pGraphics->SaveGraphState(); - if (pParams->m_dwStates & FWL_PARTSTATE_MCD_Selected) { - CFX_Path path; - path.Create(); - CFX_RectF rtSelDay; - rtSelDay = pParams->m_rtPart; - path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, - rtSelDay.height); - CFX_Color clrSelDayBK; - clrSelDayBK = m_pThemeData->clrDatesSelectedBK; - pParams->m_pGraphics->SetFillColor(&clrSelDayBK); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - } else if (pParams->m_dwStates & FWL_PARTSTATE_MCD_Hovered) { - CFX_Path path; - path.Create(); - CFX_RectF rtSelDay; - rtSelDay = pParams->m_rtPart; - path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, - rtSelDay.height); - CFX_Color clrSelDayBK; - clrSelDayBK = m_pThemeData->clrDatesHoverBK; - pParams->m_pGraphics->SetFillColor(&clrSelDayBK); - pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - } - pParams->m_pGraphics->RestoreGraphState(); - return FALSE; -} -FX_BOOL CFWL_MonthCalendarTP::DrawDatesInCircle(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - CFX_RectF rtSelDay; - rtSelDay = pParams->m_rtPart; - path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, - rtSelDay.height); - pParams->m_pGraphics->SaveGraphState(); - CFX_Color clrSelDayBK; - clrSelDayBK = m_pThemeData->clrDatesCircle; - pParams->m_pGraphics->SetStrokeColor(&clrSelDayBK); - pParams->m_pGraphics->StrokePath(&path, pMatrix); - pParams->m_pGraphics->RestoreGraphState(); - return TRUE; -} -FX_BOOL CFWL_MonthCalendarTP::DrawTodayCircle(CFWL_ThemeBackground* pParams, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - CFX_RectF rtTodayCircle; - rtTodayCircle = pParams->m_rtPart; - path.AddRectangle(rtTodayCircle.left, rtTodayCircle.top, rtTodayCircle.width, - rtTodayCircle.height); - pParams->m_pGraphics->SaveGraphState(); - CFX_Color clrTodayCircle; - clrTodayCircle = m_pThemeData->clrDatesCircle; - pParams->m_pGraphics->SetStrokeColor(&clrTodayCircle); - pParams->m_pGraphics->StrokePath(&path, pMatrix); - pParams->m_pGraphics->RestoreGraphState(); - return TRUE; -} -FWLTHEME_STATE CFWL_MonthCalendarTP::GetState(uint32_t dwFWLStates) { - if (dwFWLStates & FWL_PARTSTATE_MCD_Hovered) { - return FWLTHEME_STATE_Hover; - } else if (dwFWLStates & FWL_PARTSTATE_MCD_Pressed) { - return FWLTHEME_STATE_Pressed; - } - return FWLTHEME_STATE_Normal; -} -void CFWL_MonthCalendarTP::SetThemeData(uint32_t dwThemeID) { - if (dwThemeID == 0) { - m_pThemeData->clrCaption = ArgbEncode(0xff, 0, 153, 255); - m_pThemeData->clrSeperator = ArgbEncode(0xff, 141, 161, 239); - m_pThemeData->clrDatesHoverBK = ArgbEncode(0xff, 193, 211, 251); - m_pThemeData->clrDatesSelectedBK = ArgbEncode(0xff, 173, 188, 239); - m_pThemeData->clrDatesCircle = ArgbEncode(0xff, 103, 144, 209); - m_pThemeData->clrToday = ArgbEncode(0xff, 0, 0, 0); - m_pThemeData->clrBK = ArgbEncode(0xff, 255, 255, 255); - } else { - m_pThemeData->clrCaption = ArgbEncode(0xff, 128, 128, 0); - m_pThemeData->clrSeperator = ArgbEncode(0xff, 128, 128, 64); - m_pThemeData->clrDatesHoverBK = ArgbEncode(0xff, 217, 220, 191); - m_pThemeData->clrDatesSelectedBK = ArgbEncode(0xff, 204, 208, 183); - m_pThemeData->clrDatesCircle = ArgbEncode(0xff, 128, 128, 0); - m_pThemeData->clrToday = ArgbEncode(0xff, 0, 0, 0); - m_pThemeData->clrBK = ArgbEncode(0xff, 255, 255, 255); - } -} diff --git a/xfa/fwl/theme/pictureboxtp.cpp b/xfa/fwl/theme/pictureboxtp.cpp deleted file mode 100644 index ab5cd02246..0000000000 --- a/xfa/fwl/theme/pictureboxtp.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// 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/include/fwl/theme/pictureboxtp.h" - -#include "xfa/fwl/basewidget/ifwl_picturebox.h" -#include "xfa/fwl/core/cfwl_themebackground.h" -#include "xfa/fwl/core/ifwl_widget.h" - -CFWL_PictureBoxTP::CFWL_PictureBoxTP() {} - -CFWL_PictureBoxTP::~CFWL_PictureBoxTP() {} - -FX_BOOL CFWL_PictureBoxTP::IsValidWidget(IFWL_Widget* pWidget) { - if (!pWidget) - return FALSE; - return pWidget->GetClassID() == FWL_CLASSHASH_PictureBox; -} -FX_BOOL CFWL_PictureBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { - if (!pParams) - return FALSE; - switch (pParams->m_iPart) { - case FWL_PART_PTB_Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_PTB_Edge: { - DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), - &pParams->m_rtPart, &pParams->m_matrix); - break; - } - default: {} - } - return TRUE; -} diff --git a/xfa/fwl/theme/pushbuttontp.cpp b/xfa/fwl/theme/pushbuttontp.cpp deleted file mode 100644 index 00ff3e9737..0000000000 --- a/xfa/fwl/theme/pushbuttontp.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// 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/include/fwl/theme/pushbuttontp.h" - -#include "xfa/fwl/basewidget/ifwl_pushbutton.h" -#include "xfa/fwl/core/cfwl_themebackground.h" -#include "xfa/fwl/core/ifwl_themeprovider.h" -#include "xfa/fwl/core/ifwl_widget.h" -#include "xfa/fxgraphics/cfx_color.h" -#include "xfa/fxgraphics/cfx_path.h" - -#define PUSHBUTTON_SIZE_Corner 2 - -CFWL_PushButtonTP::CFWL_PushButtonTP() { - m_pThemeData = new PBThemeData; - SetThemeData(0); -} -CFWL_PushButtonTP::~CFWL_PushButtonTP() { - if (m_pThemeData) { - delete m_pThemeData; - } -} -FX_BOOL CFWL_PushButtonTP::IsValidWidget(IFWL_Widget* pWidget) { - return pWidget->GetClassID() == FWL_CLASSHASH_PushButton; -} -uint32_t CFWL_PushButtonTP::SetThemeID(IFWL_Widget* pWidget, - uint32_t dwThemeID, - FX_BOOL bChildren) { - SetThemeData(FWL_GetThemeColor(dwThemeID)); - return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren); -} -FX_BOOL CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) { - switch (pParams->m_iPart) { - case FWL_PART_PSB_Border: { - DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_PSB_Edge: { - DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), - &pParams->m_rtPart, &pParams->m_matrix); - break; - } - case FWL_PART_PSB_Background: { - CFX_RectF& rect = pParams->m_rtPart; - FX_FLOAT fRight = rect.right(); - FX_FLOAT fBottom = rect.bottom(); - CFX_Path strokePath; - strokePath.Create(); - strokePath.MoveTo(rect.left + PUSHBUTTON_SIZE_Corner, rect.top); - strokePath.LineTo(fRight - PUSHBUTTON_SIZE_Corner, rect.top); - strokePath.LineTo(fRight, rect.top + PUSHBUTTON_SIZE_Corner); - strokePath.LineTo(fRight, fBottom - PUSHBUTTON_SIZE_Corner); - strokePath.LineTo(fRight - PUSHBUTTON_SIZE_Corner, fBottom); - strokePath.LineTo(rect.left + PUSHBUTTON_SIZE_Corner, fBottom); - strokePath.LineTo(rect.left, fBottom - PUSHBUTTON_SIZE_Corner); - strokePath.LineTo(rect.left, rect.top + PUSHBUTTON_SIZE_Corner); - strokePath.LineTo(rect.left + PUSHBUTTON_SIZE_Corner, rect.top); - CFX_Path fillPath; - fillPath.Create(); - fillPath.AddSubpath(&strokePath); - CFX_Graphics* pGraphics = pParams->m_pGraphics; - pGraphics->SaveGraphState(); - CFX_RectF rtInner(rect); - rtInner.Deflate(PUSHBUTTON_SIZE_Corner + 1, PUSHBUTTON_SIZE_Corner + 1, - PUSHBUTTON_SIZE_Corner, PUSHBUTTON_SIZE_Corner); - fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width, - rtInner.height); - int32_t iColor = GetColorID(pParams->m_dwStates); - DrawAxialShading(pGraphics, rect.left + PUSHBUTTON_SIZE_Corner, rect.top, - rect.left + PUSHBUTTON_SIZE_Corner, rect.bottom(), - m_pThemeData->clrStart[iColor], - m_pThemeData->clrEnd[iColor], &fillPath, - FXFILL_ALTERNATE, &pParams->m_matrix); - CFX_Color crStroke(m_pThemeData->clrBorder[iColor]); - pGraphics->SetStrokeColor(&crStroke); - pGraphics->StrokePath(&strokePath, &pParams->m_matrix); - fillPath.Clear(); - fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width, - rtInner.height); - CFX_Color crFill(m_pThemeData->clrFill[iColor]); - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&fillPath, FXFILL_WINDING, &pParams->m_matrix); - if (pParams->m_dwStates & FWL_PARTSTATE_PSB_Focused) { - rtInner.Inflate(1, 1, 0, 0); - DrawFocus(pGraphics, &rtInner, &pParams->m_matrix); - } - pGraphics->RestoreGraphState(); - break; - } - default: {} - } - return TRUE; -} -void* CFWL_PushButtonTP::GetCapacity(CFWL_ThemePart* pThemePart, - uint32_t dwCapacity) { - if (dwCapacity == FWL_WGTCAPACITY_PSB_Margin) { - m_fValue = 0; - return &m_fValue; - } - return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); -} -FWL_ERR CFWL_PushButtonTP::Initialize() { - InitTTO(); - return CFWL_WidgetTP::Initialize(); -} -FWL_ERR CFWL_PushButtonTP::Finalize() { - FinalizeTTO(); - return CFWL_WidgetTP::Finalize(); -} -void CFWL_PushButtonTP::SetThemeData(uint32_t dwID) { - if (dwID) { - m_pThemeData->clrBorder[0] = ArgbEncode(255, 55, 98, 6); - m_pThemeData->clrBorder[1] = ArgbEncode(255, 55, 98, 6); - m_pThemeData->clrBorder[2] = ArgbEncode(255, 55, 98, 6); - m_pThemeData->clrBorder[3] = ArgbEncode(255, 55, 98, 6); - m_pThemeData->clrBorder[4] = ArgbEncode(255, 172, 168, 153); - m_pThemeData->clrStart[0] = ArgbEncode(255, 255, 255, 246); - m_pThemeData->clrStart[1] = ArgbEncode(255, 223, 205, 180); - m_pThemeData->clrStart[2] = ArgbEncode(255, 252, 197, 149); - m_pThemeData->clrStart[3] = ArgbEncode(255, 194, 209, 143); - m_pThemeData->clrStart[4] = ArgbEncode(255, 216, 216, 216); - m_pThemeData->clrEnd[0] = ArgbEncode(255, 227, 209, 184); - m_pThemeData->clrEnd[1] = ArgbEncode(255, 248, 244, 228); - m_pThemeData->clrEnd[2] = ArgbEncode(255, 207, 114, 37); - m_pThemeData->clrEnd[3] = ArgbEncode(255, 144, 193, 84); - m_pThemeData->clrEnd[4] = ArgbEncode(255, 172, 168, 153); - m_pThemeData->clrFill[0] = ArgbEncode(255, 255, 255, 255); - m_pThemeData->clrFill[1] = ArgbEncode(255, 226, 225, 218); - m_pThemeData->clrFill[2] = ArgbEncode(255, 255, 255, 255); - m_pThemeData->clrFill[3] = ArgbEncode(255, 255, 255, 255); - m_pThemeData->clrFill[4] = ArgbEncode(255, 245, 244, 234); - } else { - m_pThemeData->clrBorder[0] = ArgbEncode(255, 0, 60, 116); - m_pThemeData->clrBorder[1] = ArgbEncode(255, 0, 60, 116); - m_pThemeData->clrBorder[2] = ArgbEncode(255, 0, 60, 116); - m_pThemeData->clrBorder[3] = ArgbEncode(255, 0, 60, 116); - m_pThemeData->clrBorder[4] = ArgbEncode(255, 201, 199, 186); - m_pThemeData->clrStart[0] = ArgbEncode(255, 255, 255, 255); - m_pThemeData->clrStart[1] = ArgbEncode(255, 209, 204, 193); - m_pThemeData->clrStart[2] = ArgbEncode(255, 255, 240, 207); - m_pThemeData->clrStart[3] = ArgbEncode(255, 206, 231, 255); - m_pThemeData->clrStart[4] = ArgbEncode(255, 245, 244, 234); - m_pThemeData->clrEnd[0] = ArgbEncode(255, 214, 208, 197); - m_pThemeData->clrEnd[1] = ArgbEncode(255, 242, 241, 238); - m_pThemeData->clrEnd[2] = ArgbEncode(255, 229, 151, 0); - m_pThemeData->clrEnd[3] = ArgbEncode(255, 105, 130, 238); - m_pThemeData->clrEnd[4] = ArgbEncode(255, 245, 244, 234); - m_pThemeData->clrFill[0] = ArgbEncode(255, 255, 255, 255); - m_pThemeData->clrFill[1] = ArgbEncode(255, 226, 225, 218); - m_pThemeData->clrFill[2] = ArgbEncode(255, 255, 255, 255); - m_pThemeData->clrFill[3] = ArgbEncode(255, 255, 255, 255); - m_pThemeData->clrFill[4] = ArgbEncode(255, 245, 244, 234); - } -} -int32_t CFWL_PushButtonTP::GetColorID(uint32_t dwStates) { - return dwStates &= FWL_PARTSTATE_PSB_Mask; -} diff --git a/xfa/fwl/theme/scrollbartp.cpp b/xfa/fwl/theme/scrollbartp.cpp deleted file mode 100644 index 2df08d68be..0000000000 --- a/xfa/fwl/theme/scrollbartp.cpp +++ /dev/null @@ -1,381 +0,0 @@ -// 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/include/fwl/theme/scrollbartp.h" - -#include "xfa/fwl/basewidget/ifwl_scrollbar.h" -#include "xfa/fwl/core/cfwl_themebackground.h" -#include "xfa/fwl/core/ifwl_themeprovider.h" -#include "xfa/fwl/core/ifwl_widget.h" -#include "xfa/fxgraphics/cfx_color.h" -#include "xfa/fxgraphics/cfx_path.h" - -#define FWL_SCROLL_PawLen 12.5f - -CFWL_ScrollBarTP::CFWL_ScrollBarTP() { - m_pThemeData = new SBThemeData; - SetThemeData(0); -} -CFWL_ScrollBarTP::~CFWL_ScrollBarTP() { - if (m_pThemeData) { - delete m_pThemeData; - m_pThemeData = NULL; - } -} -FX_BOOL CFWL_ScrollBarTP::IsValidWidget(IFWL_Widget* pWidget) { - if (!pWidget) - return FALSE; - return pWidget->GetClassID() == FWL_CLASSHASH_ScrollBar; -} -void* CFWL_ScrollBarTP::GetCapacity(CFWL_ThemePart* pThemePart, - uint32_t dwCapacity) { - if (dwCapacity == FWL_CAPACITY_SCB_Size) { - m_fValue = 5; - return &m_fValue; - } - return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); -} -uint32_t CFWL_ScrollBarTP::SetThemeID(IFWL_Widget* pWidget, - uint32_t dwThemeID, - FX_BOOL bChildren) { - if (m_pThemeData) { - SetThemeData(FWL_GetThemeColor(dwThemeID)); - } - return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren); -} -FX_BOOL CFWL_ScrollBarTP::DrawBackground(CFWL_ThemeBackground* pParams) { - if (!pParams) - return FALSE; - IFWL_Widget* pWidget = pParams->m_pWidget; - FWLTHEME_STATE eState = FWLTHEME_STATE_Normal; - switch (pParams->m_dwStates & 0x03) { - case FWL_PARTSTATE_SCB_Hovered: { - eState = FWLTHEME_STATE_Hover; - break; - } - case FWL_PARTSTATE_SCB_Pressed: { - eState = FWLTHEME_STATE_Pressed; - break; - } - case FWL_PARTSTATE_SCB_Disabled: { - eState = FWLTHEME_STATE_Disabale; - break; - } - } - CFX_Graphics* pGraphics = pParams->m_pGraphics; - CFX_RectF* pRect = &pParams->m_rtPart; - FX_BOOL bVert = pWidget->GetStylesEx(); - switch (pParams->m_iPart) { - case FWL_PART_SCB_ForeArrow: { - DrawMaxMinBtn(pGraphics, pRect, - bVert ? FWLTHEME_DIRECTION_Up : FWLTHEME_DIRECTION_Left, - eState, &pParams->m_matrix); - break; - } - case FWL_PART_SCB_BackArrow: { - DrawMaxMinBtn(pGraphics, pRect, - bVert ? FWLTHEME_DIRECTION_Down : FWLTHEME_DIRECTION_Right, - eState, &pParams->m_matrix); - break; - } - case FWL_PART_SCB_Thumb: { - DrawThumbBtn(pGraphics, pRect, bVert, eState, TRUE, &pParams->m_matrix); - break; - } - case FWL_PART_SCB_LowerTrack: { - DrawTrack(pGraphics, pRect, bVert, eState, TRUE, &pParams->m_matrix); - break; - } - case FWL_PART_SCB_UpperTrack: { - DrawTrack(pGraphics, pRect, bVert, eState, FALSE, &pParams->m_matrix); - break; - } - default: {} - } - return TRUE; -} -#ifdef THEME_XPSimilar -void CFWL_ScrollBarTP::DrawThumbBtn(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FX_BOOL bVert, - FWLTHEME_STATE eState, - FX_BOOL bPawButton, - CFX_Matrix* pMatrix) { - if (eState < FWLTHEME_STATE_Normal || eState > FWLTHEME_STATE_Disabale) { - return; - } - CFX_Path path; - path.Create(); - CFX_RectF rect(*pRect); - if (bVert) { - rect.Deflate(1, 0); - if (rect.IsEmpty(0.1f)) { - return; - } - path.AddRectangle(rect.left, rect.top, rect.width, rect.height); - DrawAxialShading(pGraphics, rect.left, rect.top, rect.right(), rect.top, - m_pThemeData->clrBtnBK[eState - 1][0], - m_pThemeData->clrBtnBK[eState - 1][1], &path, - FXFILL_WINDING, pMatrix); - CFX_Color rcStroke; - rcStroke.Set(m_pThemeData->clrBtnBorder[eState - 1]); - pGraphics->SaveGraphState(); - pGraphics->SetStrokeColor(&rcStroke); - pGraphics->StrokePath(&path, pMatrix); - pGraphics->RestoreGraphState(); - } else { - rect.Deflate(0, 1); - if (rect.IsEmpty(0.1f)) { - return; - } - path.AddRectangle(rect.left, rect.top, rect.width, rect.height); - DrawAxialShading(pGraphics, rect.left, rect.top, rect.left, rect.bottom(), - m_pThemeData->clrBtnBK[eState - 1][0], - m_pThemeData->clrBtnBK[eState - 1][1], &path, - FXFILL_WINDING, pMatrix); - CFX_Color rcStroke; - rcStroke.Set(m_pThemeData->clrBtnBorder[eState - 1]); - pGraphics->SaveGraphState(); - pGraphics->SetStrokeColor(&rcStroke); - pGraphics->StrokePath(&path, pMatrix); - pGraphics->RestoreGraphState(); - } -} -void CFWL_ScrollBarTP::DrawPaw(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FX_BOOL bVert, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - if (bVert) { - FX_FLOAT fPawLen = FWL_SCROLL_PawLen; - if (pRect->width / 2 <= fPawLen) { - fPawLen = (pRect->width - 6) / 2; - } - FX_FLOAT fX = pRect->left + pRect->width / 4; - FX_FLOAT fY = pRect->top + pRect->height / 2; - path.MoveTo(fX, fY - 4); - path.LineTo(fX + fPawLen, fY - 4); - path.MoveTo(fX, fY - 2); - path.LineTo(fX + fPawLen, fY - 2); - path.MoveTo(fX, fY); - path.LineTo(fX + fPawLen, fY); - path.MoveTo(fX, fY + 2); - path.LineTo(fX + fPawLen, fY + 2); - CFX_Color clrLight(m_pThemeData->clrPawColorLight[eState - 1]); - pGraphics->SetLineWidth(1); - pGraphics->SetStrokeColor(&clrLight); - pGraphics->StrokePath(&path); - fX++; - path.Clear(); - path.MoveTo(fX, fY - 3); - path.LineTo(fX + fPawLen, fY - 3); - path.MoveTo(fX, fY - 1); - path.LineTo(fX + fPawLen, fY - 1); - path.MoveTo(fX, fY + 1); - path.LineTo(fX + fPawLen, fY + 1); - path.MoveTo(fX, fY + 3); - path.LineTo(fX + fPawLen, fY + 3); - CFX_Color clrDark(m_pThemeData->clrPawColorDark[eState - 1]); - pGraphics->SetLineWidth(1); - pGraphics->SetStrokeColor(&clrDark); - pGraphics->StrokePath(&path, pMatrix); - } else { - FX_FLOAT fPawLen = FWL_SCROLL_PawLen; - if (pRect->height / 2 <= fPawLen) { - fPawLen = (pRect->height - 6) / 2; - } - FX_FLOAT fX = pRect->left + pRect->width / 2; - FX_FLOAT fY = pRect->top + pRect->height / 4; - path.MoveTo(fX - 4, fY); - path.LineTo(fX - 4, fY + fPawLen); - path.MoveTo(fX - 2, fY); - path.LineTo(fX - 2, fY + fPawLen); - path.MoveTo(fX, fY); - path.LineTo(fX, fY + fPawLen); - path.MoveTo(fX + 2, fY); - path.LineTo(fX + 2, fY + fPawLen); - CFX_Color clrLight(m_pThemeData->clrPawColorLight[eState - 1]); - pGraphics->SetLineWidth(1); - pGraphics->SetStrokeColor(&clrLight); - pGraphics->StrokePath(&path, pMatrix); - fY++; - path.Clear(); - path.MoveTo(fX - 3, fY); - path.LineTo(fX - 3, fY + fPawLen); - path.MoveTo(fX - 1, fY); - path.LineTo(fX - 1, fY + fPawLen); - path.MoveTo(fX + 1, fY); - path.LineTo(fX + 1, fY + fPawLen); - path.MoveTo(fX + 3, fY); - path.LineTo(fX + 3, fY + fPawLen); - CFX_Color clrDark(m_pThemeData->clrPawColorDark[eState - 1]); - pGraphics->SetLineWidth(1); - pGraphics->SetStrokeColor(&clrDark); - pGraphics->StrokePath(&path, pMatrix); - } -} -void CFWL_ScrollBarTP::DrawTrack(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FX_BOOL bVert, - FWLTHEME_STATE eState, - FX_BOOL bLowerTrack, - CFX_Matrix* pMatrix) { - if (eState < FWLTHEME_STATE_Normal || eState > FWLTHEME_STATE_Disabale) { - return; - } - pGraphics->SaveGraphState(); - CFX_Color colorLine(ArgbEncode(255, 238, 237, 229)); - CFX_Path path; - path.Create(); - FX_FLOAT fRight = pRect->right(); - FX_FLOAT fBottom = pRect->bottom(); - if (bVert) { - path.AddRectangle(pRect->left, pRect->top, 1, pRect->height); - path.AddRectangle(fRight - 1, pRect->top, 1, pRect->height); - } else { - path.AddRectangle(pRect->left, pRect->top, pRect->width, 1); - path.AddRectangle(pRect->left, fBottom - 1, pRect->width, 1); - } - pGraphics->SetFillColor(&colorLine); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - path.Clear(); - path.AddRectangle(pRect->left + 1, pRect->top, pRect->width - 2, - pRect->height); - FX_FLOAT x1 = bVert ? pRect->left + 1 : pRect->left; - FX_FLOAT y1 = bVert ? pRect->top : pRect->top + 1; - FX_FLOAT x2 = bVert ? fRight - 1 : pRect->left; - FX_FLOAT y2 = bVert ? pRect->top : fBottom - 1; - pGraphics->RestoreGraphState(); - DrawAxialShading(pGraphics, x1, y1, x2, y2, m_pThemeData->clrTrackBKStart, - m_pThemeData->clrTrackBKEnd, &path, FXFILL_WINDING, pMatrix); -} -void CFWL_ScrollBarTP::DrawMaxMinBtn(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_DIRECTION eDict, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix) { - DrawTrack(pGraphics, pRect, - eDict == FWLTHEME_DIRECTION_Up || eDict == FWLTHEME_DIRECTION_Down, - eState, TRUE, pMatrix); - CFX_RectF rtArrowBtn(*pRect); - rtArrowBtn.Deflate(1, 1, 1, 1); - DrawArrowBtn(pGraphics, &rtArrowBtn, eDict, eState, pMatrix); -} -#else -void CFWL_ScrollBarTP::DrawThumbBtn(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FX_BOOL bVert, - FWLTHEME_STATE eState, - FX_BOOL bPawButton, - CFX_Matrix* pMatrix) { - if (pRect->IsEmpty()) { - return; - } - CFX_RectF rtThumb(*pRect); - FX_FLOAT fWidth = 2; - Draw3DRect(pGraphics, FWLTHEME_EDGE_Raised, fWidth, pRect, - FWLTHEME_COLOR_EDGELT1, FWLTHEME_COLOR_EDGELT2, - FWLTHEME_COLOR_EDGERB1, FWLTHEME_COLOR_EDGERB2, pMatrix); - CFX_Path path; - path.Create(); - path.AddRectangle(pRect->left + fWidth, pRect->top + fWidth, - pRect->width - 2 * fWidth, pRect->height - 2 * fWidth); - pGraphics->SaveGraphState(); - CFX_Color crFill(FWLTHEME_COLOR_Background); - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_ScrollBarTP::DrawTrack(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FX_BOOL bVert, - FWLTHEME_STATE eState, - FX_BOOL bLowerTrack, - CFX_Matrix* pMatrix) { - if (pRect->IsEmpty()) { - return; - } - CFX_Path path; - path.Create(); - path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); - pGraphics->SaveGraphState(); - CFX_Color clrFill(0xFFF0F0F0); - pGraphics->SetFillColor(&clrFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_ScrollBarTP::DrawMaxMinBtn(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_DIRECTION eDict, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix) { - CFX_RectF rtThumb(*pRect); - FX_FLOAT fWidth = eState == FWLTHEME_STATE_Pressed ? 1.0f : 2.0f; - FWLTHEME_EDGE eType = eState == FWLTHEME_STATE_Pressed ? FWLTHEME_EDGE_Flat - : FWLTHEME_EDGE_Raised; - Draw3DRect(pGraphics, eType, fWidth, pRect, FWLTHEME_COLOR_EDGELT1, - FWLTHEME_COLOR_EDGELT2, FWLTHEME_COLOR_EDGERB1, - FWLTHEME_COLOR_EDGERB2, pMatrix); - CFX_Path path; - path.Create(); - path.AddRectangle(pRect->left + fWidth, pRect->top + fWidth, - pRect->width - 2 * fWidth, pRect->height - 2 * fWidth); - pGraphics->SaveGraphState(); - CFX_Color crFill(FWLTHEME_COLOR_Background); - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pGraphics->RestoreGraphState(); - DrawArrow(pGraphics, pRect, eDict, - eState == FWLTHEME_STATE_Disabale ? 0xFFA0A0A0 : 0xFF000000, - eState == FWLTHEME_STATE_Pressed, pMatrix); -} -#endif -void CFWL_ScrollBarTP::SetThemeData(uint32_t dwID) { - m_pThemeData->clrPawColorLight[3] = ArgbEncode(0xff, 208, 223, 172); - m_pThemeData->clrPawColorDark[3] = ArgbEncode(0xff, 140, 157, 115); - m_pThemeData->clrBtnBK[3][0] = ArgbEncode(0xff, 164, 180, 139); - m_pThemeData->clrBtnBK[3][1] = ArgbEncode(0xff, 141, 157, 115); - m_pThemeData->clrBtnBorder[3] = ArgbEncode(0xff, 236, 233, 216); - if (dwID) { - m_pThemeData->clrPawColorLight[0] = ArgbEncode(0xff, 208, 223, 172); - m_pThemeData->clrPawColorDark[0] = ArgbEncode(0xff, 140, 157, 115); - m_pThemeData->clrBtnBK[0][0] = ArgbEncode(0xff, 162, 179, 141); - m_pThemeData->clrBtnBK[0][1] = ArgbEncode(0xff, 149, 167, 117); - m_pThemeData->clrBtnBorder[0] = ArgbEncode(0xff, 142, 153, 125); - m_pThemeData->clrPawColorLight[1] = ArgbEncode(0xff, 235, 245, 212); - m_pThemeData->clrPawColorDark[1] = ArgbEncode(0xff, 182, 198, 142); - m_pThemeData->clrBtnBK[1][0] = ArgbEncode(0xff, 200, 213, 170); - m_pThemeData->clrBtnBK[1][1] = ArgbEncode(0xff, 195, 208, 150); - m_pThemeData->clrBtnBorder[1] = ArgbEncode(0xff, 189, 203, 150); - m_pThemeData->clrPawColorLight[2] = ArgbEncode(0xff, 208, 223, 172); - m_pThemeData->clrPawColorDark[2] = ArgbEncode(0xff, 140, 157, 115); - m_pThemeData->clrBtnBK[2][0] = ArgbEncode(0xff, 164, 180, 139); - m_pThemeData->clrBtnBK[2][1] = ArgbEncode(0xff, 141, 157, 115); - m_pThemeData->clrBtnBorder[2] = ArgbEncode(0xff, 128, 146, 102); - m_pThemeData->clrTrackBKStart = ArgbEncode(0xff, 243, 241, 236); - m_pThemeData->clrTrackBKEnd = ArgbEncode(0xff, 254, 254, 251); - } else { - m_pThemeData->clrPawColorLight[0] = ArgbEncode(0xff, 238, 244, 254); - m_pThemeData->clrPawColorDark[0] = ArgbEncode(0xff, 140, 176, 248); - m_pThemeData->clrBtnBK[0][0] = ArgbEncode(0xff, 197, 213, 252); - m_pThemeData->clrBtnBK[0][1] = ArgbEncode(0xff, 182, 205, 251); - m_pThemeData->clrBtnBorder[0] = ArgbEncode(0xff, 148, 176, 221); - m_pThemeData->clrPawColorLight[1] = ArgbEncode(0xff, 252, 253, 255); - m_pThemeData->clrPawColorDark[1] = ArgbEncode(0xff, 156, 197, 255); - m_pThemeData->clrBtnBK[1][0] = ArgbEncode(0xff, 216, 232, 255); - m_pThemeData->clrBtnBK[1][1] = ArgbEncode(0xff, 204, 225, 255); - m_pThemeData->clrBtnBorder[1] = ArgbEncode(0xff, 218, 230, 254); - m_pThemeData->clrPawColorLight[2] = ArgbEncode(0xff, 207, 221, 253); - m_pThemeData->clrPawColorDark[2] = ArgbEncode(0xff, 131, 158, 216); - m_pThemeData->clrBtnBK[2][0] = ArgbEncode(0xff, 167, 190, 245); - m_pThemeData->clrBtnBK[2][1] = ArgbEncode(0xff, 146, 179, 249); - m_pThemeData->clrBtnBorder[2] = ArgbEncode(0xff, 124, 159, 211); - m_pThemeData->clrTrackBKStart = ArgbEncode(0xff, 243, 241, 236); - m_pThemeData->clrTrackBKEnd = ArgbEncode(0xff, 254, 254, 251); - } -} diff --git a/xfa/fwl/theme/widgettp.cpp b/xfa/fwl/theme/widgettp.cpp deleted file mode 100644 index c87c70c1c2..0000000000 --- a/xfa/fwl/theme/widgettp.cpp +++ /dev/null @@ -1,846 +0,0 @@ -// 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/include/fwl/theme/widgettp.h" - -#include - -#include "xfa/fde/tto/fde_textout.h" -#include "xfa/fwl/core/cfwl_themebackground.h" -#include "xfa/fwl/core/cfwl_themepart.h" -#include "xfa/fwl/core/cfwl_themetext.h" -#include "xfa/fwl/core/ifwl_themeprovider.h" -#include "xfa/fwl/core/ifwl_widgetmgr.h" -#include "xfa/fxgraphics/cfx_color.h" -#include "xfa/fxgraphics/cfx_path.h" -#include "xfa/fxgraphics/cfx_shading.h" - -static void FWL_SetChildThemeID(IFWL_Widget* pParent, uint32_t dwThemeID) { - IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr(); - IFWL_Widget* pChild = - pWidgetMgr->GetWidget(pParent, FWL_WGTRELATION_FirstChild); - while (pChild) { - IFWL_ThemeProvider* pTheme = pChild->GetThemeProvider(); - if (pTheme) { - pTheme->SetThemeID(pChild, dwThemeID, FALSE); - } - FWL_SetChildThemeID(pChild, dwThemeID); - pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling); - } -} -FX_BOOL CFWL_WidgetTP::IsValidWidget(IFWL_Widget* pWidget) { - return FALSE; -} -uint32_t CFWL_WidgetTP::GetThemeID(IFWL_Widget* pWidget) { - return m_dwThemeID; -} -uint32_t CFWL_WidgetTP::SetThemeID(IFWL_Widget* pWidget, - uint32_t dwThemeID, - FX_BOOL bChildren) { - uint32_t dwOld = m_dwThemeID; - m_dwThemeID = dwThemeID; - if (CFWL_ArrowData::IsInstance()) { - CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(dwThemeID)); - } - if (bChildren) { - FWL_SetChildThemeID(pWidget, dwThemeID); - } - return dwOld; -} -FWL_ERR CFWL_WidgetTP::GetThemeMatrix(IFWL_Widget* pWidget, - CFX_Matrix& matrix) { - matrix.Set(_ctm.a, _ctm.b, _ctm.c, _ctm.d, _ctm.e, _ctm.f); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_WidgetTP::SetThemeMatrix(IFWL_Widget* pWidget, - const CFX_Matrix& matrix) { - _ctm.Set(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f); - return FWL_ERR_Succeeded; -} -FX_BOOL CFWL_WidgetTP::DrawBackground(CFWL_ThemeBackground* pParams) { - return TRUE; -} -FX_BOOL CFWL_WidgetTP::DrawText(CFWL_ThemeText* pParams) { - if (!m_pTextOut) { - InitTTO(); - } - int32_t iLen = pParams->m_wsText.GetLength(); - if (iLen <= 0) - return FALSE; - CFX_Graphics* pGraphics = pParams->m_pGraphics; - m_pTextOut->SetRenderDevice(pGraphics->GetRenderDevice()); - m_pTextOut->SetStyles(pParams->m_dwTTOStyles); - m_pTextOut->SetAlignment(pParams->m_iTTOAlign); - CFX_Matrix* pMatrix = &pParams->m_matrix; - pMatrix->Concat(*pGraphics->GetMatrix()); - m_pTextOut->SetMatrix(*pMatrix); - m_pTextOut->DrawLogicText(pParams->m_wsText, iLen, pParams->m_rtPart); - return TRUE; -} -void* CFWL_WidgetTP::GetCapacity(CFWL_ThemePart* pThemePart, - uint32_t dwCapacity) { - switch (dwCapacity) { - case FWL_WGTCAPACITY_CXBorder: { - m_fValue = FWLTHEME_CAPACITY_CXBorder; - break; - } - case FWL_WGTCAPACITY_CYBorder: { - m_fValue = FWLTHEME_CAPACITY_CYBorder; - break; - } - case FWL_WGTCAPACITY_EdgeFlat: { - m_fValue = FWLTHEME_CAPACITY_EdgeFlat; - break; - } - case FWL_WGTCAPACITY_EdgeRaised: { - m_fValue = FWLTHEME_CAPACITY_EdgeRaised; - break; - } - case FWL_WGTCAPACITY_EdgeSunken: { - m_fValue = FWLTHEME_CAPACITY_EdgeSunken; - break; - } - case FWL_WGTCAPACITY_FontSize: { - m_fValue = FWLTHEME_CAPACITY_FontSize; - break; - } - case FWL_WGTCAPACITY_TextColor: { - m_dwValue = FWLTHEME_CAPACITY_TextColor; - return &m_dwValue; - } - case FWL_WGTCAPACITY_ScrollBarWidth: { - m_fValue = FWLTHEME_CAPACITY_ScrollBarWidth; - break; - } - case FWL_WGTCAPACITY_Font: { - return m_pFDEFont; - } - case FWL_WGTCAPACITY_TextSelColor: { - m_dwValue = (m_dwThemeID == 0) ? FWLTHEME_CAPACITY_TextSelColor - : FWLTHEME_COLOR_Green_BKSelected; - return &m_dwValue; - } - case FWL_WGTCAPACITY_LineHeight: { - m_fValue = FWLTHEME_CAPACITY_LineHeight; - break; - } - case FWL_WGTCAPACITY_UIMargin: { - m_rtMargin.Set(0, 0, 0, 0); - return &m_rtMargin; - } - default: { return NULL; } - } - return &m_fValue; -} -FX_BOOL CFWL_WidgetTP::IsCustomizedLayout(IFWL_Widget* pWidget) { - return FWL_GetThemeLayout(m_dwThemeID); -} -FWL_ERR CFWL_WidgetTP::GetPartRect(CFWL_ThemePart* pThemePart, - CFX_RectF& rect) { - return FWL_ERR_Succeeded; -} -FX_BOOL CFWL_WidgetTP::IsInPart(CFWL_ThemePart* pThemePart, - FX_FLOAT fx, - FX_FLOAT fy) { - return TRUE; -} -FX_BOOL CFWL_WidgetTP::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { - if (!pParams) - return FALSE; - if (!m_pTextOut) - return FALSE; - m_pTextOut->SetAlignment(pParams->m_iTTOAlign); - m_pTextOut->SetStyles(pParams->m_dwTTOStyles | FDE_TTOSTYLE_ArabicContext); - m_pTextOut->CalcLogicSize(pParams->m_wsText, pParams->m_wsText.GetLength(), - rect); - return TRUE; -} -FWL_ERR CFWL_WidgetTP::Initialize() { - m_dwThemeID = 0; - _ctm.SetIdentity(); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_WidgetTP::Finalize() { - if (!m_pTextOut) { - FinalizeTTO(); - } - return FWL_ERR_Succeeded; -} -CFWL_WidgetTP::~CFWL_WidgetTP() {} -FWL_ERR CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, - const FX_WCHAR* strFont, - FX_FLOAT fFontSize, - FX_ARGB rgbFont) { - if (!m_pTextOut) { - return FWL_ERR_Succeeded; - } - m_pFDEFont = CFWL_FontManager::GetInstance()->FindFont(strFont, 0, 0); - m_pTextOut->SetFont(m_pFDEFont); - m_pTextOut->SetFontSize(fFontSize); - m_pTextOut->SetTextColor(rgbFont); - return FWL_ERR_Succeeded; -} -FWL_ERR CFWL_WidgetTP::SetFont(IFWL_Widget* pWidget, - IFX_Font* pFont, - FX_FLOAT fFontSize, - FX_ARGB rgbFont) { - if (!m_pTextOut) { - return FWL_ERR_Succeeded; - } - m_pTextOut->SetFont(pFont); - m_pTextOut->SetFontSize(fFontSize); - m_pTextOut->SetTextColor(rgbFont); - return FWL_ERR_Succeeded; -} -IFX_Font* CFWL_WidgetTP::GetFont(IFWL_Widget* pWidget) { - return m_pFDEFont; -} -CFWL_WidgetTP::CFWL_WidgetTP() - : m_dwRefCount(1), m_pTextOut(NULL), m_pFDEFont(NULL), m_dwThemeID(0) {} -FX_ERR CFWL_WidgetTP::InitTTO() { - if (m_pTextOut) { - return FWL_ERR_Succeeded; - } - m_pFDEFont = - CFWL_FontManager::GetInstance()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0); - m_pTextOut = IFDE_TextOut::Create(); - m_pTextOut->SetFont(m_pFDEFont); - m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); - m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); - m_pTextOut->SetEllipsisString(L"..."); - return FWL_ERR_Succeeded; -} -FX_ERR CFWL_WidgetTP::FinalizeTTO() { - if (m_pTextOut) { - m_pTextOut->Release(); - m_pTextOut = NULL; - } - return FWL_ERR_Succeeded; -} -#ifdef THEME_XPSimilar -void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, - uint32_t dwStyles, - const CFX_RectF* pRect, - CFX_Matrix* pMatrix) { - if (!pGraphics) - return; - if (!pRect) - return; - pGraphics->SaveGraphState(); - CFX_Color crStroke(FWL_GetThemeColor(m_dwThemeID) == 0 - ? ArgbEncode(255, 127, 157, 185) - : FWLTHEME_COLOR_Green_BKSelected); - pGraphics->SetStrokeColor(&crStroke); - CFX_Path path; - path.Create(); - path.AddRectangle(pRect->left, pRect->top, pRect->width - 1, - pRect->height - 1); - pGraphics->StrokePath(&path, pMatrix); - path.Clear(); - crStroke = ArgbEncode(255, 255, 255, 255); - pGraphics->SetStrokeColor(&crStroke); - path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 3, - pRect->height - 3); - pGraphics->StrokePath(&path, pMatrix); - pGraphics->RestoreGraphState(); -} -#else -void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, - uint32_t dwStyles, - const CFX_RectF* pRect, - CFX_Matrix* pMatrix) { - if (!pGraphics) - return; - if (!pRect) - return; - FWLTHEME_EDGE eType; - FX_FLOAT fWidth; - switch (dwStyles & FWL_WGTSTYLE_EdgeMask) { - case FWL_WGTSTYLE_EdgeRaised: { - eType = FWLTHEME_EDGE_Raised, fWidth = FWLTHEME_CAPACITY_EdgeRaised; - break; - } - case FWL_WGTSTYLE_EdgeSunken: { - eType = FWLTHEME_EDGE_Sunken, fWidth = FWLTHEME_CAPACITY_EdgeSunken; - break; - } - case FWL_WGTSTYLE_EdgeFlat: - default: { return; } - } - Draw3DRect(pGraphics, eType, fWidth, pRect, FWLTHEME_COLOR_EDGELT1, - FWLTHEME_COLOR_EDGELT2, FWLTHEME_COLOR_EDGERB1, - FWLTHEME_COLOR_EDGERB2, pMatrix); -} -#endif -void CFWL_WidgetTP::Draw3DRect(CFX_Graphics* pGraphics, - FWLTHEME_EDGE eType, - FX_FLOAT fWidth, - const CFX_RectF* pRect, - FX_ARGB cr1, - FX_ARGB cr2, - FX_ARGB cr3, - FX_ARGB cr4, - CFX_Matrix* pMatrix) { - if (!pGraphics) - return; - if (!pRect) - return; - pGraphics->SaveGraphState(); - if (eType == FWLTHEME_EDGE_Flat) { - CFX_Path path; - path.Create(); - path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); - path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2, - pRect->height - 2); - CFX_Color cr(ArgbEncode(255, 100, 100, 100)); - pGraphics->SetFillColor(&cr); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - path.Clear(); - path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2, - pRect->height - 2); - path.AddRectangle(pRect->left + 2, pRect->top + 2, pRect->width - 4, - pRect->height - 4); - cr.Set(0xFFFFFFFF); - pGraphics->SetFillColor(&cr); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - } else { - FX_FLOAT fLeft = pRect->left; - FX_FLOAT fRight = pRect->right(); - FX_FLOAT fTop = pRect->top; - FX_FLOAT fBottom = pRect->bottom(); - FX_FLOAT fHalfWidth = fWidth / 2.0f; - CFX_Color crLT(eType == FWLTHEME_EDGE_Raised ? cr4 : cr1); - pGraphics->SetFillColor(&crLT); - CFX_Path pathLT; - pathLT.Create(); - pathLT.MoveTo(fLeft, fBottom - fHalfWidth); - pathLT.LineTo(fLeft, fTop); - pathLT.LineTo(fRight - fHalfWidth, fTop); - pathLT.LineTo(fRight - fHalfWidth, fTop + fHalfWidth); - pathLT.LineTo(fLeft + fHalfWidth, fTop + fHalfWidth); - pathLT.LineTo(fLeft + fHalfWidth, fBottom - fHalfWidth); - pathLT.LineTo(fLeft, fBottom - fHalfWidth); - pGraphics->FillPath(&pathLT, FXFILL_WINDING, pMatrix); - crLT = CFX_Color(eType == FWLTHEME_EDGE_Raised ? cr3 : cr2); - pGraphics->SetFillColor(&crLT); - pathLT.Clear(); - pathLT.MoveTo(fLeft + fHalfWidth, fBottom - fWidth); - pathLT.LineTo(fLeft + fHalfWidth, fTop + fHalfWidth); - pathLT.LineTo(fRight - fWidth, fTop + fHalfWidth); - pathLT.LineTo(fRight - fWidth, fTop + fWidth); - pathLT.LineTo(fLeft + fWidth, fTop + fWidth); - pathLT.LineTo(fLeft + fWidth, fBottom - fWidth); - pathLT.LineTo(fLeft + fHalfWidth, fBottom - fWidth); - pGraphics->FillPath(&pathLT, FXFILL_WINDING, pMatrix); - CFX_Color crRB(eType == FWLTHEME_EDGE_Raised ? cr1 : cr3); - pGraphics->SetFillColor(&crRB); - CFX_Path pathRB; - pathRB.Create(); - pathRB.MoveTo(fRight - fHalfWidth, fTop + fHalfWidth); - pathRB.LineTo(fRight - fHalfWidth, fBottom - fHalfWidth); - pathRB.LineTo(fLeft + fHalfWidth, fBottom - fHalfWidth); - pathRB.LineTo(fLeft + fHalfWidth, fBottom - fWidth); - pathRB.LineTo(fRight - fWidth, fBottom - fWidth); - pathRB.LineTo(fRight - fWidth, fTop + fHalfWidth); - pathRB.LineTo(fRight - fHalfWidth, fTop + fHalfWidth); - pGraphics->FillPath(&pathRB, FXFILL_WINDING, pMatrix); - crRB = CFX_Color(eType == FWLTHEME_EDGE_Raised ? cr2 : cr4); - pGraphics->SetFillColor(&crRB); - pathRB.Clear(); - pathRB.MoveTo(fRight, fTop); - pathRB.LineTo(fRight, fBottom); - pathRB.LineTo(fLeft, fBottom); - pathRB.LineTo(fLeft, fBottom - fHalfWidth); - pathRB.LineTo(fRight - fHalfWidth, fBottom - fHalfWidth); - pathRB.LineTo(fRight - fHalfWidth, fTop); - pathRB.LineTo(fRight, fTop); - pGraphics->FillPath(&pathRB, FXFILL_WINDING, pMatrix); - } - pGraphics->RestoreGraphState(); -} -void CFWL_WidgetTP::Draw3DCircle(CFX_Graphics* pGraphics, - FWLTHEME_EDGE eType, - FX_FLOAT fWidth, - const CFX_RectF* pRect, - FX_ARGB cr1, - FX_ARGB cr2, - FX_ARGB cr3, - FX_ARGB cr4, - CFX_Matrix* pMatrix) { - if (!pGraphics) - return; - if (!pRect) - return; - pGraphics->SaveGraphState(); - CFX_Path path; - path.Create(); - path.AddArc(pRect->left, pRect->top, pRect->width, pRect->height, - FWLTHEME_PI * 3 / 4, FWLTHEME_PI); - CFX_Color crFill1(eType == FWLTHEME_EDGE_Raised ? cr4 : cr1); - pGraphics->SetStrokeColor(&crFill1); - pGraphics->StrokePath(&path, pMatrix); - CFX_RectF rtInner(*pRect); - rtInner.Deflate(pRect->width / 4, pRect->height / 4); - path.Clear(); - path.AddArc(rtInner.left, rtInner.top, rtInner.width, rtInner.height, - FWLTHEME_PI * 3 / 4, FWLTHEME_PI); - CFX_Color crFill2(eType == FWLTHEME_EDGE_Raised ? cr3 : cr2); - pGraphics->SetStrokeColor(&crFill2); - pGraphics->StrokePath(&path, pMatrix); - path.Clear(); - path.AddArc(pRect->left, pRect->top, pRect->width, pRect->height, - FWLTHEME_PI * 7 / 4, FWLTHEME_PI); - CFX_Color crFill3(eType == FWLTHEME_EDGE_Raised ? cr1 : cr3); - pGraphics->SetStrokeColor(&crFill3); - pGraphics->StrokePath(&path, pMatrix); - path.AddArc(rtInner.left, rtInner.top, rtInner.width, rtInner.height, - FWLTHEME_PI * 7 / 4, FWLTHEME_PI); - CFX_Color crFill4(eType == FWLTHEME_EDGE_Raised ? cr2 : cr4); - pGraphics->SetStrokeColor(&crFill4); - pGraphics->StrokePath(&path, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_WidgetTP::DrawBorder(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - CFX_Matrix* pMatrix) { - if (!pGraphics) - return; - if (!pRect) - return; - CFX_Path path; - path.Create(); - path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); - path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2, - pRect->height - 2); - pGraphics->SaveGraphState(); - CFX_Color crFill(ArgbEncode(255, 0, 0, 0)); - pGraphics->SetFillColor(&crFill); - pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_WidgetTP::FillBackground(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - CFX_Matrix* pMatrix) { - FillSoildRect(pGraphics, FWLTHEME_COLOR_Background, pRect, pMatrix); -} -void CFWL_WidgetTP::FillSoildRect(CFX_Graphics* pGraphics, - FX_ARGB fillColor, - const CFX_RectF* pRect, - CFX_Matrix* pMatrix) { - if (!pGraphics) - return; - if (!pRect) - return; - pGraphics->SaveGraphState(); - CFX_Color crFill(fillColor); - pGraphics->SetFillColor(&crFill); - CFX_Path path; - path.Create(); - path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_WidgetTP::DrawAxialShading(CFX_Graphics* pGraphics, - FX_FLOAT fx1, - FX_FLOAT fy1, - FX_FLOAT fx2, - FX_FLOAT fy2, - FX_ARGB beginColor, - FX_ARGB endColor, - CFX_Path* path, - int32_t fillMode, - CFX_Matrix* pMatrix) { - if (!pGraphics || !path) - return; - - CFX_PointF begPoint(fx1, fy1); - CFX_PointF endPoint(fx2, fy2); - CFX_Shading shading(begPoint, endPoint, FALSE, FALSE, beginColor, endColor); - pGraphics->SaveGraphState(); - CFX_Color color1(&shading); - pGraphics->SetFillColor(&color1); - pGraphics->FillPath(path, fillMode, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_WidgetTP::DrawAnnulusRect(CFX_Graphics* pGraphics, - FX_ARGB fillColor, - const CFX_RectF* pRect, - FX_FLOAT fRingWidth, - CFX_Matrix* pMatrix) { - if (!pGraphics) - return; - if (!pRect) - return; - pGraphics->SaveGraphState(); - CFX_Color cr(fillColor); - pGraphics->SetFillColor(&cr); - CFX_Path path; - path.Create(); - CFX_RectF rtInner(*pRect); - rtInner.Deflate(fRingWidth, fRingWidth); - path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); - path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); - pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_WidgetTP::DrawAnnulusCircle(CFX_Graphics* pGraphics, - FX_ARGB fillColor, - const CFX_RectF* pRect, - FX_FLOAT fWidth, - CFX_Matrix* pMatrix) { - if (!pGraphics) - return; - if (!pRect) - return; - if (fWidth > pRect->width / 2) { - return; - } - pGraphics->SaveGraphState(); - CFX_Color cr(fillColor); - pGraphics->SetFillColor(&cr); - CFX_Path path; - path.Create(); - path.AddEllipse(*pRect); - CFX_RectF rtIn(*pRect); - rtIn.Inflate(-fWidth, -fWidth); - path.AddEllipse(rtIn); - pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_WidgetTP::DrawFocus(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - CFX_Matrix* pMatrix) { - if (!pGraphics) - return; - if (!pRect) - return; - pGraphics->SaveGraphState(); - CFX_Color cr(0xFF000000); - pGraphics->SetStrokeColor(&cr); - FX_FLOAT DashPattern[2] = {1, 1}; - pGraphics->SetLineDash(0.0f, DashPattern, 2); - CFX_Path path; - path.Create(); - path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); - pGraphics->StrokePath(&path, pMatrix); - pGraphics->RestoreGraphState(); -} -#define FWLTHEME_ARROW_Denominator 3 -void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_DIRECTION eDict, - FX_ARGB argbFill, - FX_BOOL bPressed, - CFX_Matrix* pMatrix) { - CFX_RectF rtArrow(*pRect); - CFX_Path path; - path.Create(); - FX_FLOAT fBtn = - std::min(pRect->width, pRect->height) / FWLTHEME_ARROW_Denominator; - rtArrow.left = pRect->left + (pRect->width - fBtn) / 2; - rtArrow.top = pRect->top + (pRect->height - fBtn) / 2; - rtArrow.width = fBtn; - rtArrow.height = fBtn; - if (bPressed) { - rtArrow.Offset(1, 1); - } - switch (eDict) { - case FWLTHEME_DIRECTION_Up: { - path.MoveTo(rtArrow.left, rtArrow.bottom()); - path.LineTo(rtArrow.right(), rtArrow.bottom()); - path.LineTo(rtArrow.left + fBtn / 2, rtArrow.top); - path.LineTo(rtArrow.left, rtArrow.bottom()); - break; - } - case FWLTHEME_DIRECTION_Left: { - path.MoveTo(rtArrow.right(), rtArrow.top); - path.LineTo(rtArrow.right(), rtArrow.bottom()); - path.LineTo(rtArrow.left, rtArrow.top + fBtn / 2); - path.LineTo(rtArrow.right(), rtArrow.top); - break; - } - case FWLTHEME_DIRECTION_Right: { - path.MoveTo(rtArrow.left, rtArrow.top); - path.LineTo(rtArrow.left, rtArrow.bottom()); - path.LineTo(rtArrow.right(), rtArrow.top + fBtn / 2); - path.LineTo(rtArrow.left, rtArrow.top); - break; - } - case FWLTHEME_DIRECTION_Down: - default: { - path.MoveTo(rtArrow.left, rtArrow.top); - path.LineTo(rtArrow.right(), rtArrow.top); - path.LineTo(rtArrow.left + fBtn / 2, rtArrow.bottom()); - path.LineTo(rtArrow.left, rtArrow.top); - } - } - pGraphics->SaveGraphState(); - CFX_Color cr(argbFill); - pGraphics->SetFillColor(&cr); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); - pGraphics->RestoreGraphState(); -} -void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_DIRECTION eDict, - FX_ARGB argSign, - CFX_Matrix* pMatrix) { - FX_BOOL bVert = - (eDict == FWLTHEME_DIRECTION_Up || eDict == FWLTHEME_DIRECTION_Down); - FX_FLOAT fLeft = - (FX_FLOAT)(((pRect->width - (bVert ? 9 : 6)) / 2 + pRect->left) + 0.5); - FX_FLOAT fTop = - (FX_FLOAT)(((pRect->height - (bVert ? 6 : 9)) / 2 + pRect->top) + 0.5); - CFX_Path path; - path.Create(); - switch (eDict) { - case FWLTHEME_DIRECTION_Down: { - path.MoveTo(fLeft, fTop + 1); - path.LineTo(fLeft + 4, fTop + 5); - path.LineTo(fLeft + 8, fTop + 1); - path.LineTo(fLeft + 7, fTop); - path.LineTo(fLeft + 4, fTop + 3); - path.LineTo(fLeft + 1, fTop); - break; - } - case FWLTHEME_DIRECTION_Up: { - path.MoveTo(fLeft, fTop + 4); - path.LineTo(fLeft + 4, fTop); - path.LineTo(fLeft + 8, fTop + 4); - path.LineTo(fLeft + 7, fTop + 5); - path.LineTo(fLeft + 4, fTop + 2); - path.LineTo(fLeft + 1, fTop + 5); - break; - } - case FWLTHEME_DIRECTION_Right: { - path.MoveTo(fLeft + 1, fTop); - path.LineTo(fLeft + 5, fTop + 4); - path.LineTo(fLeft + 1, fTop + 8); - path.LineTo(fLeft, fTop + 7); - path.LineTo(fLeft + 3, fTop + 4); - path.LineTo(fLeft, fTop + 1); - break; - } - case FWLTHEME_DIRECTION_Left: { - path.MoveTo(fLeft, fTop + 4); - path.LineTo(fLeft + 4, fTop); - path.LineTo(fLeft + 5, fTop + 1); - path.LineTo(fLeft + 2, fTop + 4); - path.LineTo(fLeft + 5, fTop + 7); - path.LineTo(fLeft + 4, fTop + 8); - break; - } - } - CFX_Color cr(argSign); - pGraphics->SetFillColor(&cr); - pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); -} -void CFWL_WidgetTP::DrawBtn(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix) { - CFX_Path path; - path.Create(); - if (!CFWL_ArrowData::IsInstance()) { - CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(m_dwThemeID)); - } - CFWL_ArrowData::CColorData* pColorData = - CFWL_ArrowData::GetInstance()->m_pColorData; - FX_FLOAT fRight = pRect->right(); - FX_FLOAT fBottom = pRect->bottom(); - path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); - DrawAxialShading(pGraphics, pRect->left, pRect->top, fRight, fBottom, - pColorData->clrStart[eState - 1], - pColorData->clrEnd[eState - 1], &path, FXFILL_WINDING, - pMatrix); - CFX_Color rcStroke; - rcStroke.Set(pColorData->clrBorder[eState - 1]); - pGraphics->SetStrokeColor(&rcStroke); - pGraphics->StrokePath(&path, pMatrix); -} -void CFWL_WidgetTP::DrawArrowBtn(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_DIRECTION eDict, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix) { - DrawBtn(pGraphics, pRect, eState, pMatrix); - if (!CFWL_ArrowData::IsInstance()) { - CFWL_ArrowData::GetInstance()->SetColorData(FWL_GetThemeColor(m_dwThemeID)); - } - CFWL_ArrowData::CColorData* pColorData = - CFWL_ArrowData::GetInstance()->m_pColorData; - DrawArrow(pGraphics, pRect, eDict, pColorData->clrSign[eState - 1], pMatrix); -} -FWLCOLOR CFWL_WidgetTP::BlendColor(FWLCOLOR srcColor, - FWLCOLOR renderColor, - uint8_t scale) { - FWLCOLOR dstColor; - uint8_t n = 255 - scale; - dstColor.a = (uint8_t)( - ((uint16_t)srcColor.a * n + (uint16_t)renderColor.a * scale) >> 8); - dstColor.r = (uint8_t)( - ((uint16_t)srcColor.r * n + (uint16_t)renderColor.r * scale) >> 8); - dstColor.g = (uint8_t)( - ((uint16_t)srcColor.g * n + (uint16_t)renderColor.g * scale) >> 8); - dstColor.b = (uint8_t)( - ((uint16_t)srcColor.b * n + (uint16_t)renderColor.b * scale) >> 8); - return dstColor; -} -CFWL_ArrowData::CFWL_ArrowData() : m_pColorData(NULL) { - SetColorData(0); -} -CFWL_FontData::CFWL_FontData() - : m_dwStyles(0), - m_dwCodePage(0), - m_pFont(0), - m_pFontMgr(NULL) -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - , - m_pFontSource(NULL) -#endif -{ -} -CFWL_FontData::~CFWL_FontData() { - if (m_pFont) { - m_pFont->Release(); - } - if (m_pFontMgr) { - m_pFontMgr->Release(); - } -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - if (m_pFontSource != NULL) { - m_pFontSource->Release(); - } -#endif -} -FX_BOOL CFWL_FontData::Equal(const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage) { - return m_wsFamily == wsFontFamily && m_dwStyles == dwFontStyles && - m_dwCodePage == wCodePage; -} -FX_BOOL CFWL_FontData::LoadFont(const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t dwCodePage) { - m_wsFamily = wsFontFamily; - m_dwStyles = dwFontStyles; - m_dwCodePage = dwCodePage; - if (!m_pFontMgr) { -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - m_pFontMgr = IFX_FontMgr::Create(FX_GetDefFontEnumerator()); -#else - m_pFontSource = FX_CreateDefaultFontSourceEnum(); - m_pFontMgr = IFX_FontMgr::Create(m_pFontSource); -#endif - } - m_pFont = IFX_Font::LoadFont(wsFontFamily.GetPtr(), dwFontStyles, dwCodePage, - m_pFontMgr); - return m_pFont != NULL; -} - -CFWL_FontManager* CFWL_FontManager::s_FontManager = nullptr; -CFWL_FontManager* CFWL_FontManager::GetInstance() { - if (!s_FontManager) - s_FontManager = new CFWL_FontManager; - return s_FontManager; -} -void CFWL_FontManager::DestroyInstance() { - delete s_FontManager; - s_FontManager = nullptr; -} -CFWL_FontManager::CFWL_FontManager() {} -CFWL_FontManager::~CFWL_FontManager() {} -IFX_Font* CFWL_FontManager::FindFont(const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage) { - for (const auto& pData : m_FontsArray) { - if (pData->Equal(wsFontFamily, dwFontStyles, wCodePage)) - return pData->GetFont(); - } - std::unique_ptr pFontData(new CFWL_FontData); - if (!pFontData->LoadFont(wsFontFamily, dwFontStyles, wCodePage)) - return nullptr; - m_FontsArray.push_back(std::move(pFontData)); - return m_FontsArray.back()->GetFont(); -} -FX_BOOL FWLTHEME_Init() { - return TRUE; -} -void FWLTHEME_Release() { - CFWL_ArrowData::DestroyInstance(); - CFWL_FontManager::DestroyInstance(); -} -uint32_t FWL_GetThemeLayout(uint32_t dwThemeID) { - return 0xffff0000 & dwThemeID; -} -uint32_t FWL_GetThemeColor(uint32_t dwThemeID) { - return 0x0000ffff & dwThemeID; -} -uint32_t FWL_MakeThemeID(uint32_t dwLayout, uint32_t dwColor) { - return (dwLayout << 16) | (0x0000FFFF & dwColor); -} -CFWL_ArrowData* CFWL_ArrowData::m_pInstance = NULL; -CFWL_ArrowData* CFWL_ArrowData::GetInstance() { - if (!m_pInstance) { - m_pInstance = new CFWL_ArrowData; - } - return m_pInstance; -} -FX_BOOL CFWL_ArrowData::IsInstance() { - return (m_pInstance != NULL); -} -void CFWL_ArrowData::DestroyInstance() { - if (m_pInstance) { - delete m_pInstance; - m_pInstance = NULL; - } -} -CFWL_ArrowData::~CFWL_ArrowData() { - if (m_pColorData) { - delete m_pColorData; - m_pColorData = NULL; - } -} -void CFWL_ArrowData::SetColorData(uint32_t dwID) { - if (!m_pColorData) { - m_pColorData = new CColorData; - } - if (dwID) { - m_pColorData->clrBorder[0] = ArgbEncode(255, 142, 153, 125); - m_pColorData->clrBorder[1] = ArgbEncode(255, 157, 171, 119); - m_pColorData->clrBorder[2] = ArgbEncode(255, 118, 131, 97); - m_pColorData->clrBorder[3] = ArgbEncode(255, 172, 168, 153); - m_pColorData->clrStart[0] = ArgbEncode(255, 203, 215, 186); - m_pColorData->clrStart[1] = ArgbEncode(255, 218, 232, 185); - m_pColorData->clrStart[2] = ArgbEncode(255, 203, 215, 186); - m_pColorData->clrStart[3] = ArgbEncode(255, 254, 254, 251); - m_pColorData->clrEnd[0] = ArgbEncode(255, 149, 167, 117); - m_pColorData->clrEnd[1] = ArgbEncode(255, 198, 211, 155); - m_pColorData->clrEnd[2] = ArgbEncode(255, 149, 167, 117); - m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236); - m_pColorData->clrSign[0] = ArgbEncode(255, 255, 255, 255); - m_pColorData->clrSign[1] = ArgbEncode(255, 255, 255, 255); - m_pColorData->clrSign[2] = ArgbEncode(255, 255, 255, 255); - m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128); - } else { - m_pColorData->clrBorder[0] = ArgbEncode(255, 202, 216, 249); - m_pColorData->clrBorder[1] = ArgbEncode(255, 171, 190, 233); - m_pColorData->clrBorder[2] = ArgbEncode(255, 135, 147, 219); - m_pColorData->clrBorder[3] = ArgbEncode(255, 172, 168, 153); - m_pColorData->clrStart[0] = ArgbEncode(255, 225, 234, 254); - m_pColorData->clrStart[1] = ArgbEncode(255, 253, 255, 255); - m_pColorData->clrStart[2] = ArgbEncode(255, 110, 142, 241); - m_pColorData->clrStart[3] = ArgbEncode(255, 254, 254, 251); - m_pColorData->clrEnd[0] = ArgbEncode(255, 175, 204, 251); - m_pColorData->clrEnd[1] = ArgbEncode(255, 185, 218, 251); - m_pColorData->clrEnd[2] = ArgbEncode(255, 210, 222, 235); - m_pColorData->clrEnd[3] = ArgbEncode(255, 243, 241, 236); - m_pColorData->clrSign[0] = ArgbEncode(255, 77, 97, 133); - m_pColorData->clrSign[1] = ArgbEncode(255, 77, 97, 133); - m_pColorData->clrSign[2] = ArgbEncode(255, 77, 97, 133); - m_pColorData->clrSign[3] = ArgbEncode(255, 128, 128, 128); - } -} diff --git a/xfa/fxfa/app/xfa_ffbarcode.cpp b/xfa/fxfa/app/xfa_ffbarcode.cpp index 22ab7f7cd3..daa94912fc 100644 --- a/xfa/fxfa/app/xfa_ffbarcode.cpp +++ b/xfa/fxfa/app/xfa_ffbarcode.cpp @@ -9,12 +9,12 @@ #include "core/fxcrt/include/fx_ext.h" #include "xfa/fwl/core/ifwl_app.h" #include "xfa/fwl/core/ifwl_notedriver.h" +#include "xfa/fwl/lightwidget/cfwl_barcode.h" #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/app/xfa_ffpageview.h" #include "xfa/fxfa/app/xfa_fftextedit.h" #include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxfa/app/xfa_fwladapter.h" -#include "xfa/include/fwl/lightwidget/barcode.h" namespace { diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp index c1b3099ff4..fdf7d7829d 100644 --- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp +++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp @@ -9,6 +9,7 @@ #include "xfa/fwl/core/cfwl_message.h" #include "xfa/fwl/core/ifwl_notedriver.h" #include "xfa/fwl/core/ifwl_widgetmgrdelegate.h" +#include "xfa/fwl/lightwidget/cfwl_checkbox.h" #include "xfa/fxfa/app/xfa_ffapp.h" #include "xfa/fxfa/app/xfa_ffdoc.h" #include "xfa/fxfa/app/xfa_ffdocview.h" @@ -16,7 +17,6 @@ #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/app/xfa_ffpageview.h" #include "xfa/fxfa/app/xfa_ffwidget.h" -#include "xfa/include/fwl/lightwidget/checkbox.h" CXFA_FFCheckButton::CXFA_FFCheckButton(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp index 1410ad4fa5..9017f68597 100644 --- a/xfa/fxfa/app/xfa_ffchoicelist.cpp +++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp @@ -9,14 +9,14 @@ #include "xfa/fwl/basewidget/ifwl_edit.h" #include "xfa/fwl/core/ifwl_app.h" #include "xfa/fwl/core/ifwl_notedriver.h" +#include "xfa/fwl/lightwidget/cfwl_combobox.h" +#include "xfa/fwl/lightwidget/cfwl_listbox.h" #include "xfa/fxfa/app/xfa_ffdoc.h" #include "xfa/fxfa/app/xfa_ffdocview.h" #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/app/xfa_ffpageview.h" #include "xfa/fxfa/app/xfa_ffwidget.h" #include "xfa/fxfa/app/xfa_fwladapter.h" -#include "xfa/include/fwl/lightwidget/combobox.h" -#include "xfa/include/fwl/lightwidget/listbox.h" CXFA_FFListBox::CXFA_FFListBox(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp index ed81953897..7aac2add61 100644 --- a/xfa/fxfa/app/xfa_fffield.cpp +++ b/xfa/fxfa/app/xfa_fffield.cpp @@ -9,6 +9,8 @@ #include "xfa/fwl/basewidget/ifwl_edit.h" #include "xfa/fwl/core/cfwl_message.h" #include "xfa/fwl/core/ifwl_widgetmgrdelegate.h" +#include "xfa/fwl/lightwidget/cfwl_edit.h" +#include "xfa/fwl/lightwidget/cfwl_picturebox.h" #include "xfa/fxfa/app/xfa_ffapp.h" #include "xfa/fxfa/app/xfa_ffdoc.h" #include "xfa/fxfa/app/xfa_ffdocview.h" @@ -18,8 +20,6 @@ #include "xfa/fxfa/app/xfa_textlayout.h" #include "xfa/fxgraphics/cfx_color.h" #include "xfa/fxgraphics/cfx_path.h" -#include "xfa/include/fwl/lightwidget/edit.h" -#include "xfa/include/fwl/lightwidget/picturebox.h" CXFA_FFField::CXFA_FFField(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) : CXFA_FFWidget(pPageView, pDataAcc), m_pNormalWidget(NULL) { diff --git a/xfa/fxfa/app/xfa_fffield.h b/xfa/fxfa/app/xfa_fffield.h index a6174157d3..64bdfa3470 100644 --- a/xfa/fxfa/app/xfa_fffield.h +++ b/xfa/fxfa/app/xfa_fffield.h @@ -9,9 +9,9 @@ #include "xfa/fwl/core/fwl_sdadapterimp.h" #include "xfa/fwl/core/ifwl_widgetdelegate.h" +#include "xfa/fwl/lightwidget/cfwl_widget.h" #include "xfa/fxfa/app/xfa_ffpageview.h" #include "xfa/fxfa/app/xfa_ffwidget.h" -#include "xfa/include/fwl/lightwidget/widget.h" #define XFA_MINUI_HEIGHT 4.32f #define XFA_DEFAULTUI_HEIGHT 2.0f diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/xfa_ffimageedit.cpp index a90e25c919..c0b371afcf 100644 --- a/xfa/fxfa/app/xfa_ffimageedit.cpp +++ b/xfa/fxfa/app/xfa_ffimageedit.cpp @@ -9,12 +9,12 @@ #include "xfa/fwl/core/cfwl_message.h" #include "xfa/fwl/core/ifwl_app.h" #include "xfa/fwl/core/ifwl_notedriver.h" +#include "xfa/fwl/lightwidget/cfwl_picturebox.h" #include "xfa/fxfa/app/xfa_ffdoc.h" #include "xfa/fxfa/app/xfa_ffdocview.h" #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/app/xfa_ffpageview.h" #include "xfa/fxfa/app/xfa_ffwidget.h" -#include "xfa/include/fwl/lightwidget/picturebox.h" CXFA_FFImageEdit::CXFA_FFImageEdit(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp index 0d70143ac3..89d0bfdb82 100644 --- a/xfa/fxfa/app/xfa_ffpushbutton.cpp +++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp @@ -8,6 +8,7 @@ #include "xfa/fwl/core/ifwl_notedriver.h" #include "xfa/fwl/core/ifwl_widgetmgrdelegate.h" +#include "xfa/fwl/lightwidget/cfwl_pushbutton.h" #include "xfa/fxfa/app/xfa_ffapp.h" #include "xfa/fxfa/app/xfa_fffield.h" #include "xfa/fxfa/app/xfa_ffpageview.h" @@ -16,7 +17,6 @@ #include "xfa/fxfa/app/xfa_textlayout.h" #include "xfa/fxgraphics/cfx_color.h" #include "xfa/fxgraphics/cfx_path.h" -#include "xfa/include/fwl/lightwidget/pushbutton.h" CXFA_FFPushButton::CXFA_FFPushButton(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp index 01f23ab61f..d6d292b96f 100644 --- a/xfa/fxfa/app/xfa_fftextedit.cpp +++ b/xfa/fxfa/app/xfa_fftextedit.cpp @@ -12,6 +12,8 @@ #include "xfa/fwl/basewidget/ifwl_edit.h" #include "xfa/fwl/core/cfwl_message.h" #include "xfa/fwl/core/ifwl_notedriver.h" +#include "xfa/fwl/lightwidget/cfwl_datetimepicker.h" +#include "xfa/fwl/lightwidget/cfwl_edit.h" #include "xfa/fxfa/app/xfa_ffapp.h" #include "xfa/fxfa/app/xfa_ffdoc.h" #include "xfa/fxfa/app/xfa_ffdocview.h" @@ -21,8 +23,6 @@ #include "xfa/fxfa/app/xfa_fwladapter.h" #include "xfa/fxfa/app/xfa_textlayout.h" #include "xfa/fxfa/parser/xfa_localevalue.h" -#include "xfa/include/fwl/lightwidget/datetimepicker.h" -#include "xfa/include/fwl/lightwidget/edit.h" CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc) diff --git a/xfa/fxfa/app/xfa_fwltheme.h b/xfa/fxfa/app/xfa_fwltheme.h index 0266b8c24d..33ceb477cf 100644 --- a/xfa/fxfa/app/xfa_fwltheme.h +++ b/xfa/fxfa/app/xfa_fwltheme.h @@ -9,19 +9,19 @@ #include "xfa/fwl/core/ifwl_target.h" #include "xfa/fwl/core/ifwl_themeprovider.h" +#include "xfa/fwl/theme/cfwl_barcodetp.h" +#include "xfa/fwl/theme/cfwl_carettp.h" +#include "xfa/fwl/theme/cfwl_checkboxtp.h" +#include "xfa/fwl/theme/cfwl_comboboxtp.h" +#include "xfa/fwl/theme/cfwl_datetimepickertp.h" +#include "xfa/fwl/theme/cfwl_edittp.h" +#include "xfa/fwl/theme/cfwl_listboxtp.h" +#include "xfa/fwl/theme/cfwl_monthcalendartp.h" +#include "xfa/fwl/theme/cfwl_pictureboxtp.h" +#include "xfa/fwl/theme/cfwl_pushbuttontp.h" +#include "xfa/fwl/theme/cfwl_scrollbartp.h" +#include "xfa/fwl/theme/cfwl_widgettp.h" #include "xfa/fxfa/app/xfa_ffapp.h" -#include "xfa/include/fwl/theme/barcodetp.h" -#include "xfa/include/fwl/theme/carettp.h" -#include "xfa/include/fwl/theme/checkboxtp.h" -#include "xfa/include/fwl/theme/comboboxtp.h" -#include "xfa/include/fwl/theme/datetimepickertp.h" -#include "xfa/include/fwl/theme/edittp.h" -#include "xfa/include/fwl/theme/listboxtp.h" -#include "xfa/include/fwl/theme/monthcalendartp.h" -#include "xfa/include/fwl/theme/pictureboxtp.h" -#include "xfa/include/fwl/theme/pushbuttontp.h" -#include "xfa/include/fwl/theme/scrollbartp.h" -#include "xfa/include/fwl/theme/widgettp.h" class CXFA_FWLTheme : public IFWL_ThemeProvider { public: diff --git a/xfa/include/fwl/lightwidget/app.h b/xfa/include/fwl/lightwidget/app.h deleted file mode 100644 index dee8d04de3..0000000000 --- a/xfa/include/fwl/lightwidget/app.h +++ /dev/null @@ -1,31 +0,0 @@ -// 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_INCLUDE_FWL_LIGHTWIDGET_APP_H_ -#define XFA_INCLUDE_FWL_LIGHTWIDGET_APP_H_ - -#include "xfa/fwl/core/fwl_error.h" - -class CFWL_Theme; -class IFWL_App; - -class CFWL_App { - public: - CFWL_App(); - virtual ~CFWL_App(); - - FWL_ERR Initialize(); - FWL_ERR Exit(int32_t iExitCode); - - CFWL_Theme* GetTheme() const { return m_pTheme; } - IFWL_App* GetInterface() const { return m_pIface; } - - private: - IFWL_App* m_pIface; - CFWL_Theme* m_pTheme; -}; - -#endif // XFA_INCLUDE_FWL_LIGHTWIDGET_APP_H_ diff --git a/xfa/include/fwl/lightwidget/barcode.h b/xfa/include/fwl/lightwidget/barcode.h deleted file mode 100644 index 2aa05a2a3c..0000000000 --- a/xfa/include/fwl/lightwidget/barcode.h +++ /dev/null @@ -1,120 +0,0 @@ -// 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_INCLUDE_FWL_LIGHTWIDGET_BARCODE_H_ -#define XFA_INCLUDE_FWL_LIGHTWIDGET_BARCODE_H_ - -#include "xfa/fwl/basewidget/ifwl_barcode.h" -#include "xfa/fwl/core/fwl_error.h" -#include "xfa/include/fwl/lightwidget/edit.h" - -class CFWL_Widget; -class CFWL_WidgetProperties; - -class CFWL_Barcode : public CFWL_Edit { - public: - static CFWL_Barcode* Create(); - FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); - void SetType(BC_TYPE type); - FX_BOOL IsProtectedType(); - - public: - 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; - static_cast(m_pIface)->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 = 0; } - - protected: - CFWL_Barcode(); - virtual ~CFWL_Barcode(); - class CFWL_BarcodeDP : public IFWL_BarcodeDP { - public: - virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption); - BC_CHAR_ENCODING m_eCharEncoding; - virtual BC_CHAR_ENCODING GetCharEncoding() { return m_eCharEncoding; } - int32_t m_nModuleHeight, m_nModuleWidth; - virtual int32_t GetModuleHeight() { return m_nModuleHeight; } - virtual int32_t GetModuleWidth() { return m_nModuleWidth; } - int32_t m_nDataLength; - virtual int32_t GetDataLength() { return m_nDataLength; } - int32_t m_nCalChecksum; - virtual int32_t GetCalChecksum() { return m_nCalChecksum; } - FX_BOOL m_bPrintChecksum; - virtual FX_BOOL GetPrintChecksum() { return m_bPrintChecksum; } - - BC_TEXT_LOC m_eTextLocation; - virtual BC_TEXT_LOC GetTextLocation() { return m_eTextLocation; } - int32_t m_nWideNarrowRatio; - virtual int32_t GetWideNarrowRatio() { return m_nWideNarrowRatio; } - FX_CHAR m_cStartChar, m_cEndChar; - virtual FX_CHAR GetStartChar() { return m_cStartChar; } - virtual FX_CHAR GetEndChar() { return m_cEndChar; } - int32_t m_nVersion; - virtual int32_t GetVersion() { return m_nVersion; } - int32_t m_nECLevel; - virtual int32_t GetErrorCorrectionLevel() { return m_nECLevel; } - FX_BOOL m_bTruncated; - virtual FX_BOOL GetTruncated() { return m_bTruncated; } - uint32_t m_dwAttributeMask; - virtual uint32_t GetBarcodeAttributeMask() { return m_dwAttributeMask; } - - public: - CFWL_BarcodeDP() : m_dwAttributeMask(0) {} - }; - CFWL_BarcodeDP m_barcodeData; -}; - -#endif // XFA_INCLUDE_FWL_LIGHTWIDGET_BARCODE_H_ diff --git a/xfa/include/fwl/lightwidget/caret.h b/xfa/include/fwl/lightwidget/caret.h deleted file mode 100644 index 0d8817d296..0000000000 --- a/xfa/include/fwl/lightwidget/caret.h +++ /dev/null @@ -1,28 +0,0 @@ -// 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_INCLUDE_FWL_LIGHTWIDGET_CARET_H_ -#define XFA_INCLUDE_FWL_LIGHTWIDGET_CARET_H_ - -#include "xfa/fwl/core/fwl_error.h" -#include "xfa/fxgraphics/cfx_color.h" -#include "xfa/include/fwl/lightwidget/widget.h" - -class CFWL_Caret : public CFWL_Widget { - public: - static CFWL_Caret* Create(); - FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); - FWL_ERR ShowCaret(FX_BOOL bFlag = TRUE); - FWL_ERR GetFrequency(uint32_t& elapse); - FWL_ERR SetFrequency(uint32_t elapse); - FWL_ERR SetColor(CFX_Color crFill); - - protected: - CFWL_Caret(); - virtual ~CFWL_Caret(); -}; - -#endif // XFA_INCLUDE_FWL_LIGHTWIDGET_CARET_H_ diff --git a/xfa/include/fwl/lightwidget/checkbox.h b/xfa/include/fwl/lightwidget/checkbox.h deleted file mode 100644 index a691c9664c..0000000000 --- a/xfa/include/fwl/lightwidget/checkbox.h +++ /dev/null @@ -1,38 +0,0 @@ -// 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_INCLUDE_FWL_LIGHTWIDGET_CHECKBOX_H_ -#define XFA_INCLUDE_FWL_LIGHTWIDGET_CHECKBOX_H_ - -#include "xfa/fwl/basewidget/ifwl_checkbox.h" -#include "xfa/include/fwl/lightwidget/widget.h" - -class CFWL_CheckBox : public CFWL_Widget { - public: - static CFWL_CheckBox* Create(); - - FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); - FWL_ERR GetCaption(CFX_WideString& wsCaption); - FWL_ERR SetCaption(const CFX_WideStringC& wsCaption); - FWL_ERR SetBoxSize(FX_FLOAT fHeight); - int32_t GetCheckState(); - FWL_ERR SetCheckState(int32_t iCheck); - CFWL_CheckBox(); - virtual ~CFWL_CheckBox(); - - protected: - class CFWL_CheckBoxDP : public IFWL_CheckBoxDP { - public: - CFWL_CheckBoxDP(); - virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption); - virtual FX_FLOAT GetBoxSize(IFWL_Widget* pWidget); - FX_FLOAT m_fBoxHeight; - CFX_WideString m_wsCaption; - }; - CFWL_CheckBoxDP m_checkboxData; -}; - -#endif // XFA_INCLUDE_FWL_LIGHTWIDGET_CHECKBOX_H_ diff --git a/xfa/include/fwl/lightwidget/combobox.h b/xfa/include/fwl/lightwidget/combobox.h deleted file mode 100644 index c89ddb2b2a..0000000000 --- a/xfa/include/fwl/lightwidget/combobox.h +++ /dev/null @@ -1,144 +0,0 @@ -// 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_INCLUDE_FWL_LIGHTWIDGET_COMBOBOX_H_ -#define XFA_INCLUDE_FWL_LIGHTWIDGET_COMBOBOX_H_ - -#include -#include - -#include "xfa/fwl/basewidget/ifwl_combobox.h" -#include "xfa/include/fwl/lightwidget/widget.h" - -class CFWL_WidgetProperties; -class IFWL_ComboBoxDP; -class CFWL_ComboBoxDP; -class CFWL_ComboBoxItem; - -class CFWL_ComboBox : public CFWL_Widget { - public: - static CFWL_ComboBox* Create(); - FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); - 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_ERR GetTextByIndex(int32_t iIndex, CFX_WideString& wsText); - int32_t GetCurSel(); - FWL_ERR SetCurSel(int32_t iSel); - FWL_ERR SetEditText(const CFX_WideStringC& wsText); - int32_t GetEditTextLength() const; - FWL_ERR GetEditText(CFX_WideString& wsText, - int32_t nStart = 0, - int32_t nCount = -1) const; - FWL_ERR SetEditSelRange(int32_t nStart, int32_t nCount = -1); - int32_t GetEditSelRange(int32_t nIndex, int32_t& nStart); - int32_t GetEditLimit(); - FWL_ERR SetEditLimit(int32_t nLimit); - FWL_ERR EditDoClipboard(int32_t iCmd); - FX_BOOL EditRedo(const CFX_ByteStringC& bsRecord); - FX_BOOL EditUndo(const CFX_ByteStringC& bsRecord); - FWL_ERR SetMaxListHeight(FX_FLOAT fMaxHeight); - FWL_ERR SetItemData(int32_t iIndex, void* pData); - void* GetItemData(int32_t iIndex); - FWL_ERR SetListTheme(IFWL_ThemeProvider* pTheme); - FX_BOOL AfterFocusShowDropList(); - FWL_ERR OpenDropDownList(FX_BOOL bActivate); - - public: - 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_ERR GetBBox(CFX_RectF& rect); - FWL_ERR EditModifyStylesEx(uint32_t dwStylesExAdded, - uint32_t dwStylesExRemoved); - CFWL_ComboBox(); - virtual ~CFWL_ComboBox(); - - protected: - class CFWL_ComboBoxDP : public IFWL_ComboBoxDP { - public: - CFWL_ComboBoxDP(); - ~CFWL_ComboBoxDP(); - virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, - CFX_WideString& wsCaption) { - return FWL_ERR_Succeeded; - } - - virtual int32_t CountItems(IFWL_Widget* pWidget); - virtual FWL_HLISTITEM GetItem(IFWL_Widget* pWidget, int32_t nIndex); - virtual int32_t GetItemIndex(IFWL_Widget* pWidget, FWL_HLISTITEM hItem); - virtual FX_BOOL SetItemIndex(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - int32_t nIndex); - - virtual uint32_t GetItemStyles(IFWL_Widget* pWidget, FWL_HLISTITEM hItem); - virtual FWL_ERR GetItemText(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - CFX_WideString& wsText); - virtual FWL_ERR GetItemRect(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - CFX_RectF& rtItem); - virtual void* GetItemData(IFWL_Widget* pWidget, FWL_HLISTITEM hItem); - virtual FWL_ERR SetItemStyles(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - uint32_t dwStyle); - virtual FWL_ERR SetItemText(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - const FX_WCHAR* pszText); - virtual FWL_ERR SetItemRect(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - const CFX_RectF& rtItem); - virtual FX_FLOAT GetItemHeight(IFWL_Widget* pWidget); - virtual CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem); - virtual FWL_ERR GetItemCheckRect(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - CFX_RectF& rtCheck); - virtual FWL_ERR SetItemCheckRect(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - const CFX_RectF& rtCheck); - virtual uint32_t GetItemCheckState(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem); - virtual FWL_ERR SetItemCheckState(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - uint32_t dwCheckState); - virtual FX_FLOAT GetListHeight(IFWL_Widget* pWidget); - - std::vector> m_ItemArray; - FX_FLOAT m_fMaxListHeight; - FX_FLOAT m_fItemHeight; - }; - CFWL_ComboBoxDP m_comboBoxData; -}; - -class CFWL_ComboBoxItem { - public: - CFWL_ComboBoxItem() { - m_pDIB = NULL; - m_pData = NULL; - } - 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_INCLUDE_FWL_LIGHTWIDGET_COMBOBOX_H_ diff --git a/xfa/include/fwl/lightwidget/datetimepicker.h b/xfa/include/fwl/lightwidget/datetimepicker.h deleted file mode 100644 index 17ab11ceb2..0000000000 --- a/xfa/include/fwl/lightwidget/datetimepicker.h +++ /dev/null @@ -1,61 +0,0 @@ -// 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_INCLUDE_FWL_LIGHTWIDGET_DATETIMEPICKER_H_ -#define XFA_INCLUDE_FWL_LIGHTWIDGET_DATETIMEPICKER_H_ - -#include "xfa/fwl/basewidget/ifwl_datetimepicker.h" -#include "xfa/include/fwl/lightwidget/widget.h" - -class CFWL_DateTimePicker : public CFWL_Widget { - public: - static CFWL_DateTimePicker* Create(); - FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); - FWL_ERR SetToday(int32_t iYear, int32_t iMonth, int32_t iDay); - FWL_ERR GetEditText(CFX_WideString& wsText); - FWL_ERR SetEditText(const CFX_WideStringC& wsText); - int32_t CountSelRanges(); - int32_t GetSelRange(int32_t nIndex, int32_t& nStart); - FWL_ERR GetCurSel(int32_t& iYear, int32_t& iMonth, int32_t& iDay); - FWL_ERR 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_ERR GetBBox(CFX_RectF& rect); - FWL_ERR SetEditLimit(int32_t nLimit); - FWL_ERR ModifyEditStylesEx(uint32_t dwStylesExAdded, - uint32_t dwStylesExRemoved); - - protected: - CFWL_DateTimePicker(); - virtual ~CFWL_DateTimePicker(); - class CFWL_DateTimePickerDP : public IFWL_DateTimePickerDP { - public: - CFWL_DateTimePickerDP(); - virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption); - virtual FWL_ERR GetToday(IFWL_Widget* pWidget, - int32_t& iYear, - int32_t& iMonth, - int32_t& iDay); - int32_t m_iYear; - int32_t m_iMonth; - int32_t m_iDay; - CFX_WideString m_wsData; - }; - CFWL_DateTimePickerDP m_DateTimePickerDP; -}; - -#endif // XFA_INCLUDE_FWL_LIGHTWIDGET_DATETIMEPICKER_H_ diff --git a/xfa/include/fwl/lightwidget/edit.h b/xfa/include/fwl/lightwidget/edit.h deleted file mode 100644 index a142f483d1..0000000000 --- a/xfa/include/fwl/lightwidget/edit.h +++ /dev/null @@ -1,67 +0,0 @@ -// 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_INCLUDE_FWL_LIGHTWIDGET_EDIT_H_ -#define XFA_INCLUDE_FWL_LIGHTWIDGET_EDIT_H_ - -#include - -#include "xfa/include/fwl/lightwidget/widget.h" - -class CFWL_WidgetProperties; - -class CFWL_Edit : public CFWL_Widget { - public: - static CFWL_Edit* Create(); - FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); - FWL_ERR SetText(const CFX_WideString& wsText); - int32_t GetTextLength() const; - FWL_ERR GetText(CFX_WideString& wsText, - int32_t nStart = 0, - int32_t nCount = -1) const; - FWL_ERR ClearText(); - int32_t GetCaretPos() const; - int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore = TRUE); - FWL_ERR AddSelRange(int32_t nStart, int32_t nCount = -1); - int32_t CountSelRanges(); - int32_t GetSelRange(int32_t nIndex, int32_t& nStart); - FWL_ERR ClearSelections(); - int32_t GetLimit(); - FWL_ERR SetLimit(int32_t nLimit); - FWL_ERR SetAliasChar(FX_WCHAR wAlias); - FWL_ERR SetFormatString(const CFX_WideString& wsFormat); - FWL_ERR Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLen); - FWL_ERR DeleteSelections(); - FWL_ERR DeleteRange(int32_t nStart, int32_t nCount = -1); - FWL_ERR ReplaceSelections(const CFX_WideStringC& wsReplace); - FWL_ERR Replace(int32_t nStart, - int32_t nLen, - const CFX_WideStringC& wsReplace); - FWL_ERR DoClipboard(int32_t iCmd); - FX_BOOL Redo(const CFX_ByteStringC& bsRecord); - FX_BOOL Undo(const CFX_ByteStringC& bsRecord); - FWL_ERR SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant); - FWL_ERR SetNumberRange(int32_t iMin, int32_t iMax); - FWL_ERR SetBackColor(uint32_t dwColor); - FWL_ERR 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& sSuggest); - FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, - const CFX_ByteStringC& bsReplace); - CFWL_Edit(); - virtual ~CFWL_Edit(); -}; - -#endif // XFA_INCLUDE_FWL_LIGHTWIDGET_EDIT_H_ diff --git a/xfa/include/fwl/lightwidget/listbox.h b/xfa/include/fwl/lightwidget/listbox.h deleted file mode 100644 index 6e35de738b..0000000000 --- a/xfa/include/fwl/lightwidget/listbox.h +++ /dev/null @@ -1,127 +0,0 @@ -// 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_INCLUDE_FWL_LIGHTWIDGET_LISTBOX_H_ -#define XFA_INCLUDE_FWL_LIGHTWIDGET_LISTBOX_H_ - -#include -#include - -#include "xfa/fwl/basewidget/ifwl_listbox.h" -#include "xfa/fwl/core/fwl_error.h" -#include "xfa/fwl/core/ifwl_widget.h" -#include "xfa/include/fwl/lightwidget/widget.h" - -class CFWL_ListItem; - -class CFWL_ListBox : public CFWL_Widget { - public: - static CFWL_ListBox* Create(); - FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); - FWL_ERR AddDIBitmap(CFX_DIBitmap* pDIB, FWL_HLISTITEM hItem); - FWL_HLISTITEM AddString(const CFX_WideStringC& wsAdd, - FX_BOOL bSelect = FALSE); - FX_BOOL DeleteString(FWL_HLISTITEM hItem); - void DeleteAll(); - int32_t CountSelItems(); - FWL_HLISTITEM GetSelItem(int32_t nIndexSel); - int32_t GetSelIndex(int32_t nIndex); - FWL_ERR SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect = TRUE); - FWL_ERR GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText); - FWL_ERR GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE); - FWL_ERR SetItemHeight(FX_FLOAT fItemHeight); - FWL_HLISTITEM GetFocusItem(); - FWL_ERR SetFocusItem(FWL_HLISTITEM hItem); - FWL_ERR* Sort(IFWL_ListBoxCompare* pCom); - int32_t CountItems(); - FWL_HLISTITEM GetItem(int32_t nIndex); - FWL_ERR SetItemString(FWL_HLISTITEM hItem, const CFX_WideStringC& wsText); - FWL_ERR GetItemString(FWL_HLISTITEM hItem, CFX_WideString& wsText); - FWL_ERR SetItemData(FWL_HLISTITEM hItem, void* pData); - void* GetItemData(FWL_HLISTITEM hItem); - FWL_HLISTITEM GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy); - uint32_t GetItemStates(FWL_HLISTITEM hItem); - CFWL_ListBox(); - virtual ~CFWL_ListBox(); - - protected: - class CFWL_ListBoxDP : public IFWL_ListBoxDP { - public: - CFWL_ListBoxDP(); - ~CFWL_ListBoxDP(); - - // IFWL_DataProvider: - FWL_ERR GetCaption(IFWL_Widget* pWidget, - CFX_WideString& wsCaption) override; - - // IFWL_ListBoxDP: - int32_t CountItems(IFWL_Widget* pWidget) override; - FWL_HLISTITEM GetItem(IFWL_Widget* pWidget, int32_t nIndex) override; - int32_t GetItemIndex(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) override; - FX_BOOL SetItemIndex(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - int32_t nIndex) override; - uint32_t GetItemStyles(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) override; - FWL_ERR GetItemText(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - CFX_WideString& wsText) override; - FWL_ERR GetItemRect(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - CFX_RectF& rtItem) override; - void* GetItemData(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) override; - FWL_ERR SetItemStyles(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - uint32_t dwStyle) override; - FWL_ERR SetItemText(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - const FX_WCHAR* pszText) override; - FWL_ERR SetItemRect(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - const CFX_RectF& rtItem) override; - FX_FLOAT GetItemHeight(IFWL_Widget* pWidget) override; - CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem) override; - FWL_ERR GetItemCheckRect(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - CFX_RectF& rtCheck) override; - FWL_ERR SetItemCheckRect(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - const CFX_RectF& rtCheck) override; - uint32_t GetItemCheckState(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem) override; - FWL_ERR SetItemCheckState(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, - uint32_t dwCheckState) override; - - std::vector> m_ItemArray; - CFX_WideString m_wsData; - FX_FLOAT m_fItemHeight; - }; - - CFWL_ListBoxDP m_ListBoxDP; -}; - -class CFWL_ListItem { - public: - CFWL_ListItem() { - m_rtItem.Reset(); - m_dwStates = 0; - m_wsText = L""; - m_pDIB = NULL; - m_pData = NULL; - m_dwCheckState = 0; - m_rtCheckBox.Reset(); - } - 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_INCLUDE_FWL_LIGHTWIDGET_LISTBOX_H_ diff --git a/xfa/include/fwl/lightwidget/picturebox.h b/xfa/include/fwl/lightwidget/picturebox.h deleted file mode 100644 index b5c8ae5192..0000000000 --- a/xfa/include/fwl/lightwidget/picturebox.h +++ /dev/null @@ -1,64 +0,0 @@ -// 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_INCLUDE_FWL_LIGHTWIDGET_PICTUREBOX_H_ -#define XFA_INCLUDE_FWL_LIGHTWIDGET_PICTUREBOX_H_ - -#include "xfa/fwl/basewidget/ifwl_picturebox.h" -#include "xfa/fwl/core/fwl_error.h" -#include "xfa/include/fwl/lightwidget/widget.h" - -class CFWL_PictureBox : public CFWL_Widget { - public: - static CFWL_PictureBox* Create(); - FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); - CFX_DIBitmap* GetPicture(); - FWL_ERR SetPicture(CFX_DIBitmap* pBitmap); - FX_FLOAT GetRotation(); - FWL_ERR SetRotation(FX_FLOAT fRotation); - int32_t GetFlipMode(); - FWL_ERR SetFlipMode(int32_t iFlipMode); - int32_t GetOpacity(); - FWL_ERR SetOpacity(int32_t iOpacity); - FWL_ERR GetScale(FX_FLOAT& fScaleX, FX_FLOAT& fScaleY); - FWL_ERR SetScale(FX_FLOAT fScaleX, FX_FLOAT fScaleY); - FWL_ERR GetOffset(FX_FLOAT& fx, FX_FLOAT& fy); - FWL_ERR SetOffset(FX_FLOAT fx, FX_FLOAT fy); - CFWL_PictureBox(); - virtual ~CFWL_PictureBox(); - - protected: - class CFWL_PictureBoxDP : public IFWL_PictureBoxDP { - public: - CFWL_PictureBoxDP() { - m_fRotation = 0.0f; - m_fScaleX = 1.0f; - m_fScaleY = 1.0f; - m_fOffSetX = 0.0f; - m_fOffSetY = 0.0f; - m_pBitmap = NULL; - } - virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption); - virtual CFX_DIBitmap* GetPicture(IFWL_Widget* pWidget); - virtual CFX_DIBitmap* GetErrorPicture(IFWL_Widget* pWidget); - virtual CFX_DIBitmap* GetInitialPicture(IFWL_Widget* pWidget); - virtual int32_t GetOpacity(IFWL_Widget* pWidget); - virtual int32_t GetFlipMode(IFWL_Widget* pWidget); - virtual FWL_ERR GetMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix); - 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_INCLUDE_FWL_LIGHTWIDGET_PICTUREBOX_H_ diff --git a/xfa/include/fwl/lightwidget/pushbutton.h b/xfa/include/fwl/lightwidget/pushbutton.h deleted file mode 100644 index abd76f50a5..0000000000 --- a/xfa/include/fwl/lightwidget/pushbutton.h +++ /dev/null @@ -1,36 +0,0 @@ -// 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_INCLUDE_FWL_LIGHTWIDGET_PUSHBUTTON_H_ -#define XFA_INCLUDE_FWL_LIGHTWIDGET_PUSHBUTTON_H_ - -#include "xfa/fwl/basewidget/ifwl_pushbutton.h" -#include "xfa/include/fwl/lightwidget/widget.h" - -class CFWL_PushButton : public CFWL_Widget { - public: - static CFWL_PushButton* Create(); - FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); - FWL_ERR GetCaption(CFX_WideString& wsCaption); - FWL_ERR SetCaption(const CFX_WideStringC& wsCaption); - CFX_DIBitmap* GetPicture(); - FWL_ERR SetPicture(CFX_DIBitmap* pBitmap); - CFWL_PushButton(); - virtual ~CFWL_PushButton(); - - protected: - class CFWL_PushButtonDP : public IFWL_PushButtonDP { - public: - CFWL_PushButtonDP() : m_pBitmap(NULL) {} - FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption); - virtual CFX_DIBitmap* GetPicture(IFWL_Widget* pWidget); - CFX_WideString m_wsCaption; - CFX_DIBitmap* m_pBitmap; - }; - CFWL_PushButtonDP m_buttonData; -}; - -#endif // XFA_INCLUDE_FWL_LIGHTWIDGET_PUSHBUTTON_H_ diff --git a/xfa/include/fwl/lightwidget/scrollbar.h b/xfa/include/fwl/lightwidget/scrollbar.h deleted file mode 100644 index 3d35ee651f..0000000000 --- a/xfa/include/fwl/lightwidget/scrollbar.h +++ /dev/null @@ -1,32 +0,0 @@ -// 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_INCLUDE_FWL_LIGHTWIDGET_SCROLLBAR_H_ -#define XFA_INCLUDE_FWL_LIGHTWIDGET_SCROLLBAR_H_ - -#include "xfa/include/fwl/lightwidget/widget.h" - -class CFWL_ScrollBar : public CFWL_Widget { - public: - static CFWL_ScrollBar* Create(); - FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); - FX_BOOL IsVertical(); - FWL_ERR GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax); - FWL_ERR SetRange(FX_FLOAT fMin, FX_FLOAT fMax); - FX_FLOAT GetPageSize(); - FWL_ERR SetPageSize(FX_FLOAT fPageSize); - FX_FLOAT GetStepSize(); - FWL_ERR SetStepSize(FX_FLOAT fStepSize); - FX_FLOAT GetPos(); - FWL_ERR SetPos(FX_FLOAT fPos); - FX_FLOAT GetTrackPos(); - FWL_ERR SetTrackPos(FX_FLOAT fTrackPos); - FX_BOOL DoScroll(uint32_t dwCode, FX_FLOAT fPos = 0.0f); - CFWL_ScrollBar(); - virtual ~CFWL_ScrollBar(); -}; - -#endif // XFA_INCLUDE_FWL_LIGHTWIDGET_SCROLLBAR_H_ diff --git a/xfa/include/fwl/lightwidget/theme.h b/xfa/include/fwl/lightwidget/theme.h deleted file mode 100644 index 9e91236ce8..0000000000 --- a/xfa/include/fwl/lightwidget/theme.h +++ /dev/null @@ -1,59 +0,0 @@ -// 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_INCLUDE_FWL_LIGHTWIDGET_THEME_H_ -#define XFA_INCLUDE_FWL_LIGHTWIDGET_THEME_H_ - -#include -#include - -#include "core/fxcrt/include/fx_coordinates.h" -#include "core/fxcrt/include/fx_system.h" -#include "core/include/fxge/fx_dib.h" -#include "xfa/fwl/core/ifwl_themeprovider.h" - -class CFWL_WidgetTP; -class IFWL_Widget; -class CFWL_ThemePart; -class CFWL_ThemeText; - -class CFWL_Theme : public IFWL_ThemeProvider { - public: - CFWL_Theme(); - ~CFWL_Theme() override; - - // IFWL_ThemeProvider: - FX_BOOL IsValidWidget(IFWL_Widget* pWidget) override; - uint32_t GetThemeID(IFWL_Widget* pWidget) override; - uint32_t SetThemeID(IFWL_Widget* pWidget, - uint32_t dwThemeID, - FX_BOOL bChildren = TRUE) override; - FWL_ERR GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix) override; - FWL_ERR SetThemeMatrix(IFWL_Widget* pWidget, - const CFX_Matrix& matrix) override; - FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams) override; - FX_BOOL DrawText(CFWL_ThemeText* pParams) override; - void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity) override; - FX_BOOL IsCustomizedLayout(IFWL_Widget* pWidget) override; - FWL_ERR GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart) override; - FX_BOOL IsInPart(CFWL_ThemePart* pThemePart, - FX_FLOAT fx, - FX_FLOAT fy) override; - FX_BOOL CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) override; - - FWL_ERR Initialize(); - FWL_ERR Finalize(); - FWL_ERR SetFont(IFWL_Widget* pWidget, - const FX_WCHAR* strFont, - FX_FLOAT fFontSize, - FX_ARGB rgbFont); - CFWL_WidgetTP* GetTheme(IFWL_Widget* pWidget); - - protected: - std::vector> m_ThemesArray; -}; - -#endif // XFA_INCLUDE_FWL_LIGHTWIDGET_THEME_H_ diff --git a/xfa/include/fwl/lightwidget/tooltipctrl.h b/xfa/include/fwl/lightwidget/tooltipctrl.h deleted file mode 100644 index 6a487f27e7..0000000000 --- a/xfa/include/fwl/lightwidget/tooltipctrl.h +++ /dev/null @@ -1,53 +0,0 @@ -// 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_INCLUDE_FWL_LIGHTWIDGET_TOOLTIPCTRL_H_ -#define XFA_INCLUDE_FWL_LIGHTWIDGET_TOOLTIPCTRL_H_ - -#include "xfa/fwl/basewidget/ifwl_tooltip.h" -#include "xfa/include/fwl/lightwidget/widget.h" - -class CFWL_ToolTip : public CFWL_Widget { - public: - static CFWL_ToolTip* Create(); - FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); - FWL_ERR GetCaption(CFX_WideString& wsCaption); - FWL_ERR SetCaption(const CFX_WideStringC& wsCaption); - int32_t GetInitialDelay(); - int32_t SetInitialDelay(int32_t nDelayTime); - int32_t GetAutoPopDelay(); - int32_t SetAutoPopDelay(int32_t nDelayTime); - CFX_DIBitmap* GetToolTipIcon(); - FWL_ERR SetToolTipIcon(CFX_DIBitmap* pBitmap); - CFX_SizeF GetToolTipIconSize(); - FWL_ERR SetToolTipIconSize(CFX_SizeF fSize); - FWL_ERR SetAnchor(const CFX_RectF& rtAnchor); - FWL_ERR Show(); - FWL_ERR Hide(); - CFWL_ToolTip(); - virtual ~CFWL_ToolTip(); - - protected: - class CFWL_ToolTipDP : public IFWL_ToolTipDP { - public: - CFWL_ToolTipDP(); - FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption); - int32_t GetInitialDelay(IFWL_Widget* pWidget); - int32_t GetAutoPopDelay(IFWL_Widget* pWidget); - CFX_DIBitmap* GetToolTipIcon(IFWL_Widget* pWidget); - CFX_SizeF GetToolTipIconSize(IFWL_Widget* pWidget); - CFX_RectF GetAnchor(); - CFX_WideString m_wsCaption; - int32_t m_nInitDelayTime; - int32_t m_nAutoPopDelayTime; - CFX_DIBitmap* m_pBitmap; - CFX_SizeF m_fIconSize; - CFX_RectF m_fAnchor; - }; - CFWL_ToolTipDP m_tooltipData; -}; - -#endif // XFA_INCLUDE_FWL_LIGHTWIDGET_TOOLTIPCTRL_H_ diff --git a/xfa/include/fwl/lightwidget/widget.h b/xfa/include/fwl/lightwidget/widget.h deleted file mode 100644 index 38fe777fd2..0000000000 --- a/xfa/include/fwl/lightwidget/widget.h +++ /dev/null @@ -1,110 +0,0 @@ -// 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_INCLUDE_FWL_LIGHTWIDGET_WIDGET_H_ -#define XFA_INCLUDE_FWL_LIGHTWIDGET_WIDGET_H_ - -#include "xfa/fwl/core/cfwl_event.h" -#include "xfa/fwl/core/cfwl_widgetimpproperties.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_WidgetProperties { - public: - CFWL_WidgetProperties() { - m_ctmOnParent.SetIdentity(); - m_rtWidget.Set(0, 0, 0, 0); - m_dwStyles = FWL_WGTSTYLE_Child; - m_dwStyleExes = 0; - m_dwStates = 0; - m_pParent = NULL; - m_pOwner = NULL; - } - 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; -}; - -class CFWL_Widget { - public: - virtual ~CFWL_Widget(); - IFWL_Widget* GetWidget(); - FWL_ERR GetClassName(CFX_WideString& wsClass) const; - uint32_t GetClassID() const; - virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const; - - protected: - FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); - - public: - FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE); - FWL_ERR GetGlobalRect(CFX_RectF& rect); - FWL_ERR SetWidgetRect(const CFX_RectF& rect); - FWL_ERR GetClientRect(CFX_RectF& rtClient); - CFWL_Widget* GetParent(); - FWL_ERR SetParent(CFWL_Widget* pParent); - CFWL_Widget* GetOwner(); - FWL_ERR SetOwner(CFWL_Widget* pOwner); - uint32_t GetStyles(); - FWL_ERR ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved); - uint32_t GetStylesEx(); - FWL_ERR ModifyStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved); - uint32_t GetStates(); - FWL_ERR SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE); - FWL_ERR SetPrivateData(void* module_id, - void* pData, - PD_CALLBACK_FREEDATA callback); - void* GetPrivateData(void* module_id); - FWL_ERR Update(); - FWL_ERR LockUpdate(); - FWL_ERR UnlockUpdate(); - uint32_t HitTest(FX_FLOAT fx, FX_FLOAT fy); - FWL_ERR TransformTo(CFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy); - FWL_ERR TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt); - FWL_ERR GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE); - FWL_ERR SetMatrix(const CFX_Matrix& matrix); - FWL_ERR DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix = NULL); - IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate); - FWL_ERR Repaint(const CFX_RectF* pRect = NULL); - FWL_ERR SetFocus(FX_BOOL bFocus); - FWL_ERR SetGrab(FX_BOOL bSet); - CFWL_Widget(); - - void RegisterEventTarget(CFWL_Widget* pEventSource = NULL, - uint32_t dwFilter = FWL_EVENT_ALL_MASK); - void DispatchEvent(CFWL_Event* pEvent); - CFX_SizeF CalcTextSize(const CFX_WideString& wsText, - FX_BOOL bMultiLine = FALSE, - int32_t iLineWidth = -1); - IFWL_Widget* m_pIface; - IFWL_WidgetDelegate* m_pDelegate; - CFWL_WidgetMgr* m_pWidgetMgr; - CFWL_WidgetProperties* m_pProperties; -}; -class CFWL_WidgetDelegate { - public: - CFWL_WidgetDelegate(); - virtual ~CFWL_WidgetDelegate(); - virtual int32_t OnProcessMessage(CFWL_Message* pMessage); - virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent); - virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix = NULL); -}; - -#endif // XFA_INCLUDE_FWL_LIGHTWIDGET_WIDGET_H_ diff --git a/xfa/include/fwl/theme/barcodetp.h b/xfa/include/fwl/theme/barcodetp.h deleted file mode 100644 index 89c9a679f3..0000000000 --- a/xfa/include/fwl/theme/barcodetp.h +++ /dev/null @@ -1,21 +0,0 @@ -// 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_INCLUDE_FWL_THEME_BARCODETP_H_ -#define XFA_INCLUDE_FWL_THEME_BARCODETP_H_ - -#include "xfa/include/fwl/theme/utils.h" -#include "xfa/include/fwl/theme/widgettp.h" - -class CFWL_BarcodeTP : public CFWL_WidgetTP { - public: - CFWL_BarcodeTP(); - virtual ~CFWL_BarcodeTP(); - virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); - virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); -}; - -#endif // XFA_INCLUDE_FWL_THEME_BARCODETP_H_ diff --git a/xfa/include/fwl/theme/carettp.h b/xfa/include/fwl/theme/carettp.h deleted file mode 100644 index bd432dc401..0000000000 --- a/xfa/include/fwl/theme/carettp.h +++ /dev/null @@ -1,27 +0,0 @@ -// 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_INCLUDE_FWL_THEME_CARETTP_H_ -#define XFA_INCLUDE_FWL_THEME_CARETTP_H_ - -#include "xfa/include/fwl/theme/widgettp.h" - -class CFWL_CaretTP : public CFWL_WidgetTP { - public: - CFWL_CaretTP(); - virtual ~CFWL_CaretTP(); - virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); - virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); - - protected: - void DrawCaretBK(CFX_Graphics* pGraphics, - uint32_t dwStates, - const CFX_RectF* pRect, - CFX_Color* crFill, - CFX_Matrix* pMatrix = NULL); -}; - -#endif // XFA_INCLUDE_FWL_THEME_CARETTP_H_ diff --git a/xfa/include/fwl/theme/checkboxtp.h b/xfa/include/fwl/theme/checkboxtp.h deleted file mode 100644 index fc666d74b5..0000000000 --- a/xfa/include/fwl/theme/checkboxtp.h +++ /dev/null @@ -1,84 +0,0 @@ -// 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_INCLUDE_FWL_THEME_CHECKBOXTP_H_ -#define XFA_INCLUDE_FWL_THEME_CHECKBOXTP_H_ - -#include "xfa/include/fwl/theme/utils.h" -#include "xfa/include/fwl/theme/widgettp.h" - -class CFWL_CheckBoxTP : public CFWL_WidgetTP { - public: - CFWL_CheckBoxTP(); - virtual ~CFWL_CheckBoxTP(); - virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); - virtual uint32_t SetThemeID(IFWL_Widget* pWidget, - uint32_t dwThemeID, - FX_BOOL bChildren = TRUE); - virtual FX_BOOL DrawText(CFWL_ThemeText* pParams); - virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); - virtual FWL_ERR Initialize(); - virtual FWL_ERR Finalize(); - - protected: - void DrawBoxBk(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - uint32_t dwStates, - CFX_Matrix* pMatrix = NULL); - void DrawSign(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_RectF* pRtBox, - uint32_t dwStates, - CFX_Matrix* pMatrix = NULL); - void DrawSignNeutral(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - CFX_Matrix* pMatrix = NULL); - void DrawSignCheck(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - FX_ARGB argbFill, - CFX_Matrix* pMatrix = NULL); - void DrawSignCircle(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - FX_ARGB argbFill, - CFX_Matrix* pMatrix = NULL); - void DrawSignCross(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - FX_ARGB argbFill, - CFX_Matrix* pMatrix = NULL); - void DrawSignDiamond(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - FX_ARGB argbFill, - CFX_Matrix* pMatrix = NULL); - void DrawSignSquare(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - FX_ARGB argbFill, - CFX_Matrix* pMatrix = NULL); - void DrawSignStar(CFX_Graphics* pGraphics, - const CFX_RectF* pRtSign, - FX_ARGB argbFill, - CFX_Matrix* pMatrix = NULL); - void DrawSignBorder(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_RectF* pRtBox, - FX_BOOL bDisable = FALSE, - CFX_Matrix* pMatrix = NULL); - void SetThemeData(uint32_t dwID); - void initCheckPath(FX_FLOAT fCheckLen); - struct CKBThemeData { - FX_ARGB clrBoxBk[13][2]; - FX_ARGB clrSignBorderNormal; - FX_ARGB clrSignBorderDisable; - FX_ARGB clrSignCheck; - FX_ARGB clrSignNeutral; - FX_ARGB clrSignNeutralNormal; - FX_ARGB clrSignNeutralHover; - FX_ARGB clrSignNeutralPressed; - } * m_pThemeData; - CFX_Path* m_pCheckPath; -}; - -#endif // XFA_INCLUDE_FWL_THEME_CHECKBOXTP_H_ diff --git a/xfa/include/fwl/theme/comboboxtp.h b/xfa/include/fwl/theme/comboboxtp.h deleted file mode 100644 index 74d49b45e7..0000000000 --- a/xfa/include/fwl/theme/comboboxtp.h +++ /dev/null @@ -1,29 +0,0 @@ -// 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_INCLUDE_FWL_THEME_COMBOBOXTP_H_ -#define XFA_INCLUDE_FWL_THEME_COMBOBOXTP_H_ - -#include "xfa/include/fwl/theme/widgettp.h" - -class CFWL_ComboBoxTP : public CFWL_WidgetTP { - public: - CFWL_ComboBoxTP(); - virtual ~CFWL_ComboBoxTP(); - virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); - virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); - virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity); - - protected: - void DrawDropDownButton(CFWL_ThemeBackground* pParams, - uint32_t dwStates, - CFX_Matrix* pMatrix); - void DrawStrethHandler(CFWL_ThemeBackground* pParams, - uint32_t dwStates, - CFX_Matrix* pMatrix); -}; - -#endif // XFA_INCLUDE_FWL_THEME_COMBOBOXTP_H_ diff --git a/xfa/include/fwl/theme/datetimepickertp.h b/xfa/include/fwl/theme/datetimepickertp.h deleted file mode 100644 index de2f8304f0..0000000000 --- a/xfa/include/fwl/theme/datetimepickertp.h +++ /dev/null @@ -1,27 +0,0 @@ -// 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_INCLUDE_FWL_THEME_DATETIMEPICKERTP_H_ -#define XFA_INCLUDE_FWL_THEME_DATETIMEPICKERTP_H_ - -#include "xfa/include/fwl/theme/widgettp.h" - -class CFWL_DateTimePickerTP : public CFWL_WidgetTP { - public: - CFWL_DateTimePickerTP(); - virtual ~CFWL_DateTimePickerTP(); - virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); - virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); - - protected: - void DrawDropDownButton(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); - void initThemeData(); - struct DTPThemeData { - FX_ARGB BoxBkColor[13][2]; - } * m_pThemeData; -}; - -#endif // XFA_INCLUDE_FWL_THEME_DATETIMEPICKERTP_H_ diff --git a/xfa/include/fwl/theme/edittp.h b/xfa/include/fwl/theme/edittp.h deleted file mode 100644 index d03fbe60eb..0000000000 --- a/xfa/include/fwl/theme/edittp.h +++ /dev/null @@ -1,22 +0,0 @@ -// 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_INCLUDE_FWL_THEME_EDITTP_H_ -#define XFA_INCLUDE_FWL_THEME_EDITTP_H_ - -#include "xfa/include/fwl/theme/widgettp.h" - -class CFWL_EditTP : public CFWL_WidgetTP { - public: - CFWL_EditTP(); - virtual ~CFWL_EditTP(); - virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); - virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); - virtual FWL_ERR Initialize(); - virtual FWL_ERR Finalize(); -}; - -#endif // XFA_INCLUDE_FWL_THEME_EDITTP_H_ diff --git a/xfa/include/fwl/theme/formtp.h b/xfa/include/fwl/theme/formtp.h deleted file mode 100644 index 90ec67387e..0000000000 --- a/xfa/include/fwl/theme/formtp.h +++ /dev/null @@ -1,111 +0,0 @@ -// 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_INCLUDE_FWL_THEME_FORMTP_H_ -#define XFA_INCLUDE_FWL_THEME_FORMTP_H_ - -#include "xfa/include/fwl/theme/utils.h" -#include "xfa/include/fwl/theme/widgettp.h" - -class CFWL_FormTP : public CFWL_WidgetTP { - public: - CFWL_FormTP(); - virtual ~CFWL_FormTP(); - - virtual FWL_ERR Initialize(); - virtual FWL_ERR Finalize(); - virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); - virtual uint32_t SetThemeID(IFWL_Widget* pWidget, - uint32_t dwThemeID, - FX_BOOL bChildren = TRUE); - virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); - virtual FX_BOOL DrawText(CFWL_ThemeText* pParams); - virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity); - virtual FWL_ERR GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart); - - protected: - void CalCloseBox(IFWL_Widget* pWidget, CFX_RectF& rect); - void CalMaxBox(IFWL_Widget* pWidget, CFX_RectF& rect); - void CalMinBox(IFWL_Widget* pWidget, CFX_RectF& rect); - void CalCaption(IFWL_Widget* pWidget, CFX_RectF& rect); - void CalIcon(IFWL_Widget* pWidget, CFX_RectF& rect); - - void DrawFormBorder(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive = 0); - void DrawCaption(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive = 0); - void DrawNarrowCaption(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive = 0); - void DrawCloseBox(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive = 0); - void DrawMinMaxBoxCommon(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive = 0); - void DrawMinimizeBox(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive = 0); - void DrawMaximizeBox(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - FX_BOOL bMax, - CFX_Matrix* pMatrix, - int32_t iActive = 0); - void DrawIconImage(CFX_Graphics* pGraphics, - CFX_DIBitmap* pDIBitmap, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix, - int32_t iActive = 0); - void SetThemeData(uint32_t dwID); - void TransModeColor(FX_ARGB clrFore, FX_ARGB& clrBack); - void DeactiveForm(); - void InitCaption(FX_BOOL bActive); - CFX_DIBitmap* m_pActiveBitmap; - CFX_DIBitmap* m_pDeactivebitmap; - CFX_RectF m_rtDisCaption; - CFX_RectF m_rtDisLBorder; - CFX_RectF m_rtDisRBorder; - CFX_RectF m_rtDisBBorder; - struct SBThemeData { - FX_ARGB clrHeadBK[2][4]; - FX_ARGB clrHeadEdgeLeft[2][3]; - FX_ARGB clrHeadEdgeRight[2][3]; - FX_ARGB clrHeadEdgeTop[2][3]; - FX_ARGB clrHeadEdgeBottom[2][3]; - FX_ARGB clrCloseBtBKStart[2][3]; - FX_ARGB clrCloseBtBKEnd[2][3]; - FX_ARGB clrCloseBtEdgeLight[2][3]; - FX_ARGB clrCloseBtEdgeDark[2][3]; - FX_ARGB clrNormalBtBKStart[2][3]; - FX_ARGB clrNormalBtBKEnd[2][3]; - FX_ARGB clrNormalBtEdgeLight[2][3]; - FX_ARGB clrNormalBtEdgeDark[2][3]; - FX_ARGB clrBtnEdgeOut[2]; - FX_ARGB clrBtnCornerLight[2][3]; - FX_ARGB clrHeadText[2]; - FX_ARGB clrFormBorder[2][5]; - FX_ARGB clrFormBorderLight[2]; - FX_ARGB clrTransWhite; - } * m_pThemeData; -}; - -#endif // XFA_INCLUDE_FWL_THEME_FORMTP_H_ diff --git a/xfa/include/fwl/theme/listboxtp.h b/xfa/include/fwl/theme/listboxtp.h deleted file mode 100644 index 8f5720c9fb..0000000000 --- a/xfa/include/fwl/theme/listboxtp.h +++ /dev/null @@ -1,29 +0,0 @@ -// 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_INCLUDE_FWL_THEME_LISTBOXTP_H_ -#define XFA_INCLUDE_FWL_THEME_LISTBOXTP_H_ - -#include "xfa/include/fwl/theme/widgettp.h" - -class CFWL_ListBoxTP : public CFWL_WidgetTP { - public: - CFWL_ListBoxTP(); - virtual ~CFWL_ListBoxTP(); - virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); - virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); - virtual FWL_ERR Initialize(); - virtual FWL_ERR Finalize(); - - protected: - void DrawListBoxItem(CFX_Graphics* pGraphics, - uint32_t dwStates, - const CFX_RectF* prtItem, - void* pData = NULL, - CFX_Matrix* pMatrix = NULL); -}; - -#endif // XFA_INCLUDE_FWL_THEME_LISTBOXTP_H_ diff --git a/xfa/include/fwl/theme/monthcalendartp.h b/xfa/include/fwl/theme/monthcalendartp.h deleted file mode 100644 index 8321965a8b..0000000000 --- a/xfa/include/fwl/theme/monthcalendartp.h +++ /dev/null @@ -1,51 +0,0 @@ -// 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_INCLUDE_FWL_THEME_MONTHCALENDARTP_H_ -#define XFA_INCLUDE_FWL_THEME_MONTHCALENDARTP_H_ - -#include "xfa/include/fwl/theme/widgettp.h" - -class CFWL_MonthCalendarTP : public CFWL_WidgetTP { - public: - CFWL_MonthCalendarTP(); - virtual ~CFWL_MonthCalendarTP(); - virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); - virtual uint32_t SetThemeID(IFWL_Widget* pWidget, - uint32_t dwThemeID, - FX_BOOL bChildren = TRUE); - virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); - virtual FX_BOOL DrawText(CFWL_ThemeText* pParams); - virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity); - virtual FWL_ERR Initialize(); - virtual FWL_ERR Finalize(); - - protected: - FX_BOOL DrawTotalBK(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); - FX_BOOL DrawHeadBk(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); - FX_BOOL DrawLButton(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); - FX_BOOL DrawRButton(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); - FX_BOOL DrawDatesInBK(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); - FX_BOOL DrawDatesInCircle(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); - FX_BOOL DrawTodayCircle(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); - FX_BOOL DrawHSeperator(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); - FX_BOOL DrawWeekNumSep(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix); - FWLTHEME_STATE GetState(uint32_t dwFWLStates); - void SetThemeData(uint32_t dwThemeID); - class MCThemeData { - public: - FX_ARGB clrCaption; - FX_ARGB clrSeperator; - FX_ARGB clrDatesHoverBK; - FX_ARGB clrDatesSelectedBK; - FX_ARGB clrDatesCircle; - FX_ARGB clrToday; - FX_ARGB clrBK; - } * m_pThemeData; - CFX_WideString wsResource; -}; - -#endif // XFA_INCLUDE_FWL_THEME_MONTHCALENDARTP_H_ diff --git a/xfa/include/fwl/theme/pictureboxtp.h b/xfa/include/fwl/theme/pictureboxtp.h deleted file mode 100644 index 8879890649..0000000000 --- a/xfa/include/fwl/theme/pictureboxtp.h +++ /dev/null @@ -1,20 +0,0 @@ -// 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_INCLUDE_FWL_THEME_PICTUREBOXTP_H_ -#define XFA_INCLUDE_FWL_THEME_PICTUREBOXTP_H_ - -#include "xfa/include/fwl/theme/widgettp.h" - -class CFWL_PictureBoxTP : public CFWL_WidgetTP { - public: - CFWL_PictureBoxTP(); - virtual ~CFWL_PictureBoxTP(); - virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); - virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); -}; - -#endif // XFA_INCLUDE_FWL_THEME_PICTUREBOXTP_H_ diff --git a/xfa/include/fwl/theme/pushbuttontp.h b/xfa/include/fwl/theme/pushbuttontp.h deleted file mode 100644 index b951de0bed..0000000000 --- a/xfa/include/fwl/theme/pushbuttontp.h +++ /dev/null @@ -1,44 +0,0 @@ -// 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_INCLUDE_FWL_THEME_PUSHBUTTONTP_H_ -#define XFA_INCLUDE_FWL_THEME_PUSHBUTTONTP_H_ - -#include "xfa/include/fwl/theme/widgettp.h" - -class CFWL_PushButtonTP : public CFWL_WidgetTP { - public: - CFWL_PushButtonTP(); - virtual ~CFWL_PushButtonTP(); - virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); - virtual uint32_t SetThemeID(IFWL_Widget* pWidget, - uint32_t dwThemeID, - FX_BOOL bChildren = TRUE); - virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); - virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity); - virtual FWL_ERR Initialize(); - virtual FWL_ERR Finalize(); - - protected: - void SetThemeData(uint32_t dwID); - void SetTopLineColor(uint32_t* pData); - void SetLeftLineColor(uint32_t* pData); - void SetRightLineColor(uint32_t* pData); - void SetBottomLineColor(uint32_t* pData); - void SetBackgroudColor(uint32_t* pData); - void SetCaptionColor(uint32_t* pData); - void SetCornerColor(uint32_t* pData); - int32_t GetColorID(uint32_t dwStates); - - struct PBThemeData { - FX_ARGB clrBorder[5]; - FX_ARGB clrStart[5]; - FX_ARGB clrEnd[5]; - FX_ARGB clrFill[5]; - } * m_pThemeData; -}; - -#endif // XFA_INCLUDE_FWL_THEME_PUSHBUTTONTP_H_ diff --git a/xfa/include/fwl/theme/scrollbartp.h b/xfa/include/fwl/theme/scrollbartp.h deleted file mode 100644 index 5b7145c155..0000000000 --- a/xfa/include/fwl/theme/scrollbartp.h +++ /dev/null @@ -1,57 +0,0 @@ -// 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_INCLUDE_FWL_THEME_SCROLLBARTP_H_ -#define XFA_INCLUDE_FWL_THEME_SCROLLBARTP_H_ - -#include "xfa/include/fwl/theme/widgettp.h" - -class CFWL_ScrollBarTP : public CFWL_WidgetTP { - public: - CFWL_ScrollBarTP(); - virtual ~CFWL_ScrollBarTP(); - virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); - virtual uint32_t SetThemeID(IFWL_Widget* pWidget, - uint32_t dwThemeID, - FX_BOOL bChildren = TRUE); - virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); - virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity); - - protected: - void DrawThumbBtn(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FX_BOOL bVert, - FWLTHEME_STATE eState, - FX_BOOL bPawButton = TRUE, - CFX_Matrix* pMatrix = NULL); - void DrawTrack(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FX_BOOL bVert, - FWLTHEME_STATE eState, - FX_BOOL bLowerTrack, - CFX_Matrix* pMatrix = NULL); - void DrawMaxMinBtn(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_DIRECTION eDict, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix = NULL); - void DrawPaw(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FX_BOOL bVert, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix = NULL); - void SetThemeData(uint32_t dwID); - struct SBThemeData { - FX_ARGB clrPawColorLight[4]; - FX_ARGB clrPawColorDark[4]; - FX_ARGB clrBtnBK[4][2]; - FX_ARGB clrBtnBorder[4]; - FX_ARGB clrTrackBKStart; - FX_ARGB clrTrackBKEnd; - } * m_pThemeData; -}; - -#endif // XFA_INCLUDE_FWL_THEME_SCROLLBARTP_H_ diff --git a/xfa/include/fwl/theme/utils.h b/xfa/include/fwl/theme/utils.h deleted file mode 100644 index 0a37d3274b..0000000000 --- a/xfa/include/fwl/theme/utils.h +++ /dev/null @@ -1,75 +0,0 @@ -// 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_INCLUDE_FWL_THEME_UTILS_H_ -#define XFA_INCLUDE_FWL_THEME_UTILS_H_ - -#include "core/fxcrt/include/fx_system.h" - -#define THEME_XPSimilar -enum FWLTHEME_EDGE { - FWLTHEME_EDGE_Flat = 0, - FWLTHEME_EDGE_Raised, - FWLTHEME_EDGE_Sunken -}; -enum FWLTHEME_STATE { - FWLTHEME_STATE_Normal = 1, - FWLTHEME_STATE_Hover, - FWLTHEME_STATE_Pressed, - FWLTHEME_STATE_Disabale -}; -enum FWLTHEME_DIRECTION { - FWLTHEME_DIRECTION_Up = 0, - FWLTHEME_DIRECTION_Down, - FWLTHEME_DIRECTION_Left, - FWLTHEME_DIRECTION_Right -}; -struct FWLCOLOR { - union { - uint32_t color; - struct { - uint8_t b; - uint8_t g; - uint8_t r; - uint8_t a; - }; - }; - - FWLCOLOR() : color(0) {} - FWLCOLOR(uint32_t c) : color(c) {} - FWLCOLOR(const FWLCOLOR& c) : color(c.color) {} - - bool operator==(const FWLCOLOR& frColor) { return color == frColor.color; } - operator uint32_t() { return color; } -}; -#define FWLTHEME_BEZIER FX_BEZIER -#define FWLTHEME_PI FX_PI -#define FWLTHEME_PI_2_1 (FX_PI / 2.0f) -#define FWLTHEME_PI_2_3 (3.0f * FX_PI / 2.0f) -#define FWLTHEME_COLOR_EDGELT1 (ArgbEncode(255, 172, 168, 153)) -#define FWLTHEME_COLOR_EDGELT2 (ArgbEncode(255, 113, 111, 100)) -#define FWLTHEME_COLOR_EDGERB1 (ArgbEncode(255, 241, 239, 226)) -#define FWLTHEME_COLOR_EDGERB2 (ArgbEncode(255, 255, 255, 255)) -#define FWLTHEME_COLOR_Background (ArgbEncode(255, 236, 233, 216)) -#define FWLTHEME_COLOR_BKSelected (ArgbEncode(255, 153, 193, 218)) -#define FWLTHEME_COLOR_Green_BKSelected (ArgbEncode(255, 147, 160, 112)) -#ifdef THEME_XPSimilar -#define FWLTHEME_CAPACITY_EdgeFlat 2.0f -#else -#define FWLTHEME_CAPACITY_EdgeFlat 0.0f -#endif -#define FWLTHEME_CAPACITY_EdgeRaised 2.0f -#define FWLTHEME_CAPACITY_EdgeSunken 2.0f -#define FWLTHEME_CAPACITY_FontSize 12.0f -#define FWLTHEME_CAPACITY_LineHeight 12.0f -#define FWLTHEME_CAPACITY_TextColor (ArgbEncode(255, 0, 0, 0)) -#define FWLTHEME_CAPACITY_TextSelColor (ArgbEncode(255, 153, 193, 218)) -#define FWLTHEME_CAPACITY_TextDisColor (ArgbEncode(255, 172, 168, 153)) -#define FWLTHEME_CAPACITY_ScrollBarWidth 17.0f -#define FWLTHEME_CAPACITY_CXBorder 1.0f -#define FWLTHEME_CAPACITY_CYBorder 1.0f - -#endif // XFA_INCLUDE_FWL_THEME_UTILS_H_ diff --git a/xfa/include/fwl/theme/widgettp.h b/xfa/include/fwl/theme/widgettp.h deleted file mode 100644 index 344f4d3034..0000000000 --- a/xfa/include/fwl/theme/widgettp.h +++ /dev/null @@ -1,220 +0,0 @@ -// 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_INCLUDE_FWL_THEME_WIDGETTP_H_ -#define XFA_INCLUDE_FWL_THEME_WIDGETTP_H_ - -#include -#include - -#include "core/fxcrt/include/fx_coordinates.h" -#include "core/fxcrt/include/fx_system.h" -#include "xfa/fwl/core/fwl_error.h" -#include "xfa/fxgraphics/include/cfx_graphics.h" -#include "xfa/include/fwl/theme/utils.h" - -class IFWL_Widget; -class IFDE_TextOut; -class IFX_Font; -class IFX_FontMgr; -class CFWL_ArrowData; -class CFWL_ThemeBackground; -class CFWL_ThemePart; -class CFWL_ThemeText; - -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ -class IFX_FontSourceEnum; -#endif - -class CFWL_WidgetTP { - public: - virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget); - virtual uint32_t GetThemeID(IFWL_Widget* pWidget); - virtual uint32_t SetThemeID(IFWL_Widget* pWidget, - uint32_t dwThemeID, - FX_BOOL bChildren = TRUE); - virtual FWL_ERR GetThemeMatrix(IFWL_Widget* pWidget, CFX_Matrix& matrix); - virtual FWL_ERR SetThemeMatrix(IFWL_Widget* pWidget, - const CFX_Matrix& matrix); - virtual FX_BOOL DrawBackground(CFWL_ThemeBackground* pParams); - virtual FX_BOOL DrawText(CFWL_ThemeText* pParams); - virtual void* GetCapacity(CFWL_ThemePart* pThemePart, uint32_t dwCapacity); - virtual FX_BOOL IsCustomizedLayout(IFWL_Widget* pWidget); - virtual FWL_ERR GetPartRect(CFWL_ThemePart* pThemePart, CFX_RectF& rtPart); - virtual FX_BOOL IsInPart(CFWL_ThemePart* pThemePart, - FX_FLOAT fx, - FX_FLOAT fy); - virtual FX_BOOL CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect); - virtual FWL_ERR Initialize(); - virtual FWL_ERR Finalize(); - virtual ~CFWL_WidgetTP(); - FWL_ERR SetFont(IFWL_Widget* pWidget, - const FX_WCHAR* strFont, - FX_FLOAT fFontSize, - FX_ARGB rgbFont); - FWL_ERR SetFont(IFWL_Widget* pWidget, - IFX_Font* pFont, - FX_FLOAT fFontSize, - FX_ARGB rgbFont); - IFX_Font* GetFont(IFWL_Widget* pWidget); - - protected: - CFWL_WidgetTP(); - FX_ERR InitTTO(); - FX_ERR FinalizeTTO(); - void DrawEdge(CFX_Graphics* pGraphics, - uint32_t dwStyles, - const CFX_RectF* pRect, - CFX_Matrix* pMatrix = NULL); - void Draw3DRect(CFX_Graphics* pGraphics, - FWLTHEME_EDGE eType, - FX_FLOAT fWidth, - const CFX_RectF* pRect, - FX_ARGB cr1, - FX_ARGB cr2, - FX_ARGB cr3, - FX_ARGB cr4, - CFX_Matrix* pMatrix = NULL); - void Draw3DCircle(CFX_Graphics* pGraphics, - FWLTHEME_EDGE eType, - FX_FLOAT fWidth, - const CFX_RectF* pRect, - FX_ARGB cr1, - FX_ARGB cr2, - FX_ARGB cr3, - FX_ARGB cr4, - CFX_Matrix* pMatrix = NULL); - void DrawBorder(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - CFX_Matrix* pMatrix = NULL); - void FillBackground(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - CFX_Matrix* pMatrix = NULL); - void FillSoildRect(CFX_Graphics* pGraphics, - FX_ARGB fillColor, - const CFX_RectF* pRect, - CFX_Matrix* pMatrix = NULL); - void DrawAxialShading(CFX_Graphics* pGraphics, - FX_FLOAT fx1, - FX_FLOAT fy1, - FX_FLOAT fx2, - FX_FLOAT fy2, - FX_ARGB beginColor, - FX_ARGB endColor, - CFX_Path* path, - int32_t fillMode = FXFILL_WINDING, - CFX_Matrix* pMatrix = NULL); - void DrawAnnulusRect(CFX_Graphics* pGraphics, - FX_ARGB fillColor, - const CFX_RectF* pRect, - FX_FLOAT fRingWidth = 1, - CFX_Matrix* pMatrix = NULL); - void DrawAnnulusCircle(CFX_Graphics* pGraphics, - FX_ARGB fillColor, - const CFX_RectF* pRect, - FX_FLOAT fWidth = 1, - CFX_Matrix* pMatrix = NULL); - void DrawFocus(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - CFX_Matrix* pMatrix = NULL); - void DrawArrow(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_DIRECTION eDict, - FX_ARGB argbFill, - FX_BOOL bPressed, - CFX_Matrix* pMatrix = NULL); - void DrawArrow(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_DIRECTION eDict, - FX_ARGB argSign, - CFX_Matrix* pMatrix = NULL); - void DrawBtn(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix = NULL); - void DrawArrowBtn(CFX_Graphics* pGraphics, - const CFX_RectF* pRect, - FWLTHEME_DIRECTION eDict, - FWLTHEME_STATE eState, - CFX_Matrix* pMatrix = NULL); - FWLCOLOR BlendColor(FWLCOLOR srcColor, FWLCOLOR renderColor, uint8_t scale); - uint32_t m_dwRefCount; - IFDE_TextOut* m_pTextOut; - IFX_Font* m_pFDEFont; - FX_FLOAT m_fValue; - uint32_t m_dwValue; - CFX_RectF m_rtMargin; - uint32_t m_dwThemeID; - CFX_Matrix _ctm; -}; -FX_BOOL FWLTHEME_Init(); -void FWLTHEME_Release(); -uint32_t FWL_GetThemeLayout(uint32_t dwThemeID); -uint32_t FWL_GetThemeColor(uint32_t dwThemeID); -uint32_t FWL_MakeThemeID(uint32_t dwLayout, uint32_t dwColor); - -class CFWL_ArrowData { - public: - static CFWL_ArrowData* GetInstance(); - static FX_BOOL IsInstance(); - static void DestroyInstance(); - virtual ~CFWL_ArrowData(); - void SetColorData(uint32_t dwID); - - class CColorData { - public: - FX_ARGB clrBorder[4]; - FX_ARGB clrStart[4]; - FX_ARGB clrEnd[4]; - FX_ARGB clrSign[4]; - } * m_pColorData; - - protected: - CFWL_ArrowData(); - static CFWL_ArrowData* m_pInstance; -}; - -class CFWL_FontData { - public: - CFWL_FontData(); - virtual ~CFWL_FontData(); - FX_BOOL Equal(const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage); - FX_BOOL LoadFont(const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t wCodePage); - IFX_Font* GetFont() const { return m_pFont; } - - protected: - CFX_WideString m_wsFamily; - uint32_t m_dwStyles; - uint32_t m_dwCodePage; - IFX_Font* m_pFont; - IFX_FontMgr* m_pFontMgr; -#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ - IFX_FontSourceEnum* m_pFontSource; -#endif -}; - -class CFWL_FontManager { - public: - static CFWL_FontManager* GetInstance(); - static void DestroyInstance(); - - IFX_Font* FindFont(const CFX_WideStringC& wsFontFamily, - uint32_t dwFontStyles, - uint16_t dwCodePage); - - protected: - CFWL_FontManager(); - virtual ~CFWL_FontManager(); - - static CFWL_FontManager* s_FontManager; - std::vector> m_FontsArray; -}; - -#endif // XFA_INCLUDE_FWL_THEME_WIDGETTP_H_ -- cgit v1.2.3