summaryrefslogtreecommitdiff
path: root/xfa/src/fwl/core
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/src/fwl/core')
-rw-r--r--xfa/src/fwl/core/fwl_appimp.cpp114
-rw-r--r--xfa/src/fwl/core/fwl_appimp.h38
-rw-r--r--xfa/src/fwl/core/fwl_contentimp.cpp94
-rw-r--r--xfa/src/fwl/core/fwl_contentimp.h35
-rw-r--r--xfa/src/fwl/core/fwl_formimp.cpp1175
-rw-r--r--xfa/src/fwl/core/fwl_formimp.h193
-rw-r--r--xfa/src/fwl/core/fwl_gridimp.cpp1378
-rw-r--r--xfa/src/fwl/core/fwl_gridimp.h197
-rw-r--r--xfa/src/fwl/core/fwl_noteimp.cpp1097
-rw-r--r--xfa/src/fwl/core/fwl_noteimp.h157
-rw-r--r--xfa/src/fwl/core/fwl_panelimp.cpp152
-rw-r--r--xfa/src/fwl/core/fwl_panelimp.h32
-rw-r--r--xfa/src/fwl/core/fwl_sdadapterimp.cpp175
-rw-r--r--xfa/src/fwl/core/fwl_targetimp.cpp44
-rw-r--r--xfa/src/fwl/core/fwl_targetimp.h27
-rw-r--r--xfa/src/fwl/core/fwl_threadimp.cpp38
-rw-r--r--xfa/src/fwl/core/fwl_threadimp.h40
-rw-r--r--xfa/src/fwl/core/fwl_timerimp.cpp36
-rw-r--r--xfa/src/fwl/core/fwl_widgetimp.cpp1101
-rw-r--r--xfa/src/fwl/core/fwl_widgetimp.h162
-rw-r--r--xfa/src/fwl/core/fwl_widgetmgrimp.cpp1075
-rw-r--r--xfa/src/fwl/core/fwl_widgetmgrimp.h170
22 files changed, 0 insertions, 7530 deletions
diff --git a/xfa/src/fwl/core/fwl_appimp.cpp b/xfa/src/fwl/core/fwl_appimp.cpp
deleted file mode 100644
index 43a3d0badf..0000000000
--- a/xfa/src/fwl/core/fwl_appimp.cpp
+++ /dev/null
@@ -1,114 +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/src/fwl/core/fwl_appimp.h"
-
-#include "xfa/include/fwl/adapter/fwl_adapterwidgetmgr.h"
-#include "xfa/include/fwl/core/fwl_app.h"
-#include "xfa/include/fwl/core/fwl_widget.h"
-#include "xfa/src/fwl/core/fwl_noteimp.h"
-#include "xfa/src/fwl/core/fwl_targetimp.h"
-#include "xfa/src/fwl/core/fwl_threadimp.h"
-#include "xfa/src/fwl/core/fwl_widgetmgrimp.h"
-
-IFWL_App* IFWL_App::Create(IFWL_AdapterNative* pAdapter) {
- IFWL_App* pApp = new IFWL_App;
- pApp->SetImpl(new CFWL_AppImp(pApp, pAdapter));
- return pApp;
-}
-FWL_ERR IFWL_App::Initialize() {
- return static_cast<CFWL_AppImp*>(GetImpl())->Initialize();
-}
-FWL_ERR IFWL_App::Finalize() {
- return static_cast<CFWL_AppImp*>(GetImpl())->Finalize();
-}
-IFWL_AdapterNative* IFWL_App::GetAdapterNative() {
- return static_cast<CFWL_AppImp*>(GetImpl())->GetAdapterNative();
-}
-IFWL_WidgetMgr* IFWL_App::GetWidgetMgr() {
- return static_cast<CFWL_AppImp*>(GetImpl())->GetWidgetMgr();
-}
-IFWL_ThemeProvider* IFWL_App::GetThemeProvider() {
- return static_cast<CFWL_AppImp*>(GetImpl())->GetThemeProvider();
-}
-FWL_ERR IFWL_App::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
- return static_cast<CFWL_AppImp*>(GetImpl())->SetThemeProvider(pThemeProvider);
-}
-FWL_ERR IFWL_App::Exit(int32_t iExitCode) {
- return static_cast<CFWL_AppImp*>(GetImpl())->Exit(iExitCode);
-}
-
-CFWL_AppImp::CFWL_AppImp(IFWL_App* pIface, IFWL_AdapterNative* pAdapter)
- : CFWL_NoteThreadImp(pIface),
- m_pAdapterNative(pAdapter),
- m_pThemeProvider(nullptr) {}
-
-CFWL_AppImp::~CFWL_AppImp() {
- CFWL_ToolTipContainer::DeleteInstance();
-}
-
-FWL_ERR CFWL_AppImp::Initialize() {
- if (!m_pWidgetMgr) {
- m_pWidgetMgr.reset(new CFWL_WidgetMgr(m_pAdapterNative));
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_AppImp::Finalize() {
- m_pWidgetMgr.reset();
- return FWL_ERR_Succeeded;
-}
-IFWL_AdapterNative* CFWL_AppImp::GetAdapterNative() const {
- return m_pAdapterNative;
-}
-IFWL_AdapterWidgetMgr* FWL_GetAdapterWidgetMgr() {
- return static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr())
- ->GetAdapterWidgetMgr();
-}
-IFWL_WidgetMgr* CFWL_AppImp::GetWidgetMgr() const {
- return m_pWidgetMgr.get();
-}
-FWL_ERR CFWL_AppImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
- m_pThemeProvider = pThemeProvider;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_AppImp::Exit(int32_t iExitCode) {
- while (m_pNoteDriver->PopNoteLoop()) {
- continue;
- }
- return m_pWidgetMgr->GetAdapterWidgetMgr()->Exit(0);
-}
-IFWL_ThemeProvider* CFWL_AppImp::GetThemeProvider() const {
- return m_pThemeProvider;
-}
-IFWL_AdapterNative* FWL_GetAdapterNative() {
- IFWL_App* pApp = FWL_GetApp();
- if (!pApp)
- return NULL;
- return pApp->GetAdapterNative();
-}
-IFWL_ThemeProvider* FWL_GetThemeProvider() {
- return NULL;
-}
-static IFWL_App* _theApp = NULL;
-IFWL_App* FWL_GetApp() {
- return _theApp;
-}
-void FWL_SetApp(IFWL_App* pApp) {
- _theApp = pApp;
-}
-FWL_ERR FWL_SetFullScreen(IFWL_Widget* pWidget, FX_BOOL bFullScreen) {
- if (!pWidget)
- return FWL_ERR_Succeeded;
- IFWL_NoteThread* pNoteTread = pWidget->GetOwnerThread();
- if (!pNoteTread)
- return FWL_ERR_Succeeded;
- CFWL_NoteDriver* pNoteDriver =
- static_cast<CFWL_NoteDriver*>(pNoteTread->GetNoteDriver());
- if (!pNoteTread)
- return FWL_ERR_Succeeded;
- pNoteDriver->NotifyFullScreenMode(pWidget, bFullScreen);
- return FWL_GetAdapterWidgetMgr()->SetFullScreen(pWidget, bFullScreen);
-}
diff --git a/xfa/src/fwl/core/fwl_appimp.h b/xfa/src/fwl/core/fwl_appimp.h
deleted file mode 100644
index fa4ffecc65..0000000000
--- a/xfa/src/fwl/core/fwl_appimp.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_SRC_FWL_CORE_FWL_APPIMP_H_
-#define XFA_SRC_FWL_CORE_FWL_APPIMP_H_
-
-#include <memory>
-
-#include "xfa/src/fwl/core/fwl_threadimp.h"
-
-class CFWL_WidgetMgr;
-class IFWL_AdapterNative;
-class IFWL_WidgetMgr;
-class IFWL_ThemeProvider;
-class IFWL_App;
-
-class CFWL_AppImp : public CFWL_NoteThreadImp {
- public:
- CFWL_AppImp(IFWL_App* pIface, IFWL_AdapterNative* pAdapter);
- virtual ~CFWL_AppImp();
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual IFWL_AdapterNative* GetAdapterNative() const;
- virtual IFWL_WidgetMgr* GetWidgetMgr() const;
- virtual IFWL_ThemeProvider* GetThemeProvider() const;
- virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
- virtual FWL_ERR Exit(int32_t iExitCode = 0);
-
- protected:
- IFWL_AdapterNative* const m_pAdapterNative;
- std::unique_ptr<CFWL_WidgetMgr> m_pWidgetMgr;
- IFWL_ThemeProvider* m_pThemeProvider;
-};
-
-#endif // XFA_SRC_FWL_CORE_FWL_APPIMP_H_
diff --git a/xfa/src/fwl/core/fwl_contentimp.cpp b/xfa/src/fwl/core/fwl_contentimp.cpp
deleted file mode 100644
index d415e33a26..0000000000
--- a/xfa/src/fwl/core/fwl_contentimp.cpp
+++ /dev/null
@@ -1,94 +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/src/fwl/core/fwl_contentimp.h"
-
-#include "xfa/include/fwl/core/fwl_content.h"
-#include "xfa/src/fwl/core/fwl_noteimp.h"
-#include "xfa/src/fwl/core/fwl_targetimp.h"
-#include "xfa/src/fwl/core/fwl_threadimp.h"
-#include "xfa/src/fwl/core/fwl_widgetimp.h"
-#include "xfa/src/fwl/core/fwl_widgetmgrimp.h"
-
-FWL_ERR IFWL_Content::InsertWidget(IFWL_Widget* pChild, int32_t nIndex) {
- return static_cast<CFWL_ContentImp*>(GetImpl())->InsertWidget(pChild, nIndex);
-}
-FWL_ERR IFWL_Content::RemoveWidget(IFWL_Widget* pWidget) {
- return static_cast<CFWL_ContentImp*>(GetImpl())->RemoveWidget(pWidget);
-}
-FWL_ERR IFWL_Content::RemoveAllWidgets() {
- return static_cast<CFWL_ContentImp*>(GetImpl())->RemoveAllWidgets();
-}
-FWL_ERR IFWL_Content::GetMinSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) {
- return static_cast<CFWL_ContentImp*>(GetImpl())->GetMinSize(fWidth, fHeight);
-}
-FWL_ERR IFWL_Content::SetMinSize(FX_FLOAT fWidth, FX_FLOAT fHeight) {
- return static_cast<CFWL_ContentImp*>(GetImpl())->SetMinSize(fWidth, fHeight);
-}
-FWL_ERR IFWL_Content::GetMaxSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) {
- return static_cast<CFWL_ContentImp*>(GetImpl())->GetMaxSize(fWidth, fHeight);
-}
-FWL_ERR IFWL_Content::SetMaxSize(FX_FLOAT fWidth, FX_FLOAT fHeight) {
- return static_cast<CFWL_ContentImp*>(GetImpl())->SetMaxSize(fWidth, fHeight);
-}
-IFWL_Content::IFWL_Content() {}
-CFWL_ContentImp::CFWL_ContentImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter)
- : CFWL_WidgetImp(properties, pOuter),
- m_fWidthMin(0),
- m_fWidthMax(10000),
- m_fHeightMin(0),
- m_fHeightMax(10000) {}
-CFWL_ContentImp::~CFWL_ContentImp() {}
-FWL_ERR CFWL_ContentImp::InsertWidget(IFWL_Widget* pChild, int32_t nIndex) {
- if (!pChild)
- return FWL_ERR_Indefinite;
- pChild->SetParent(m_pInterface);
- if (nIndex == -1) {
- return FWL_ERR_Succeeded;
- }
- CFWL_WidgetMgr* pMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- if (!pMgr)
- return FWL_ERR_Indefinite;
- pMgr->SetWidgetIndex(pChild, nIndex);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ContentImp::RemoveWidget(IFWL_Widget* pWidget) {
- if (!pWidget)
- return FWL_ERR_Indefinite;
- pWidget->SetParent(NULL);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ContentImp::RemoveAllWidgets() {
- CFWL_WidgetMgr* pMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- if (!pMgr)
- return FWL_ERR_Indefinite;
- while (IFWL_Widget* widget =
- pMgr->GetWidget(m_pInterface, FWL_WGTRELATION_FirstChild)) {
- pMgr->SetParent(NULL, widget);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ContentImp::GetMinSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) {
- fWidth = m_fWidthMin;
- fHeight = m_fHeightMin;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ContentImp::SetMinSize(FX_FLOAT fWidth, FX_FLOAT fHeight) {
- m_fWidthMin = fWidth;
- m_fHeightMin = fHeight;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ContentImp::GetMaxSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) {
- fWidth = m_fWidthMax;
- fHeight = m_fHeightMax;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_ContentImp::SetMaxSize(FX_FLOAT fWidth, FX_FLOAT fHeight) {
- m_fWidthMax = fWidth;
- m_fHeightMax = fHeight;
- return FWL_ERR_Succeeded;
-}
diff --git a/xfa/src/fwl/core/fwl_contentimp.h b/xfa/src/fwl/core/fwl_contentimp.h
deleted file mode 100644
index d2b0277a86..0000000000
--- a/xfa/src/fwl/core/fwl_contentimp.h
+++ /dev/null
@@ -1,35 +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_SRC_FWL_CORE_FWL_CONTENTIMP_H_
-#define XFA_SRC_FWL_CORE_FWL_CONTENTIMP_H_
-
-#include "xfa/src/fwl/core/fwl_widgetimp.h"
-
-class IFWL_Widget;
-
-class CFWL_ContentImp : public CFWL_WidgetImp {
- public:
- CFWL_ContentImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter);
-
- virtual ~CFWL_ContentImp();
- virtual FWL_ERR InsertWidget(IFWL_Widget* pChild, int32_t nIndex = -1);
- virtual FWL_ERR RemoveWidget(IFWL_Widget* pWidget);
- virtual FWL_ERR RemoveAllWidgets();
- FWL_ERR GetMinSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight);
- FWL_ERR SetMinSize(FX_FLOAT fWidth, FX_FLOAT fHeight);
- FWL_ERR GetMaxSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight);
- FWL_ERR SetMaxSize(FX_FLOAT fWidth, FX_FLOAT fHeight);
-
- protected:
- FX_FLOAT m_fWidthMin;
- FX_FLOAT m_fWidthMax;
- FX_FLOAT m_fHeightMin;
- FX_FLOAT m_fHeightMax;
-};
-
-#endif // XFA_SRC_FWL_CORE_FWL_CONTENTIMP_H_
diff --git a/xfa/src/fwl/core/fwl_formimp.cpp b/xfa/src/fwl/core/fwl_formimp.cpp
deleted file mode 100644
index 558ee00f9c..0000000000
--- a/xfa/src/fwl/core/fwl_formimp.cpp
+++ /dev/null
@@ -1,1175 +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/src/fwl/core/fwl_formimp.h"
-
-#include "xfa/include/fwl/adapter/fwl_adapterwidgetmgr.h"
-#include "xfa/include/fwl/core/fwl_app.h"
-#include "xfa/include/fwl/core/fwl_content.h"
-#include "xfa/include/fwl/core/fwl_theme.h"
-#include "xfa/src/fde/tto/fde_textout.h"
-#include "xfa/src/fwl/basewidget/fwl_formproxyimp.h"
-#include "xfa/src/fwl/core/fwl_appimp.h"
-#include "xfa/src/fwl/core/fwl_noteimp.h"
-#include "xfa/src/fwl/core/fwl_panelimp.h"
-#include "xfa/src/fwl/core/fwl_targetimp.h"
-#include "xfa/src/fwl/core/fwl_threadimp.h"
-#include "xfa/src/fwl/core/fwl_widgetimp.h"
-#include "xfa/src/fwl/core/fwl_widgetmgrimp.h"
-
-#define FWL_SYSBTNSIZE 21
-#define FWL_SYSBTNMARGIN 5
-#define FWL_SYSBTNSPAN 2
-#define FWL_CornerEnlarge 10
-
-// static
-IFWL_Form* IFWL_Form::CreateFormProxy(CFWL_WidgetImpProperties& properties,
- CFX_WideString* classname,
- IFWL_Widget* pOuter) {
- IFWL_Form* pForm = new IFWL_Form;
- CFWL_FormProxyImp* pFormProxyImpl = new CFWL_FormProxyImp(properties, pOuter);
- pForm->SetImpl(pFormProxyImpl);
- pFormProxyImpl->SetInterface(pForm);
- return pForm;
-}
-IFWL_Form::IFWL_Form() {}
-FWL_FORMSIZE IFWL_Form::GetFormSize() {
- return static_cast<CFWL_FormImp*>(GetImpl())->GetFormSize();
-}
-FWL_ERR IFWL_Form::SetFormSize(FWL_FORMSIZE eFormSize) {
- return static_cast<CFWL_FormImp*>(GetImpl())->SetFormSize(eFormSize);
-}
-IFWL_Widget* IFWL_Form::DoModal() {
- return static_cast<CFWL_FormImp*>(GetImpl())->DoModal();
-}
-IFWL_Widget* IFWL_Form::DoModal(FX_DWORD& dwCommandID) {
- return static_cast<CFWL_FormImp*>(GetImpl())->DoModal(dwCommandID);
-}
-FWL_ERR IFWL_Form::EndDoModal() {
- return static_cast<CFWL_FormImp*>(GetImpl())->EndDoModal();
-}
-FWL_ERR IFWL_Form::SetBorderRegion(CFX_Path* pPath) {
- return static_cast<CFWL_FormImp*>(GetImpl())->SetBorderRegion(pPath);
-}
-
-CFWL_FormImp::CFWL_FormImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter)
- : CFWL_PanelImp(properties, pOuter),
- m_pCloseBox(NULL),
- m_pMinBox(NULL),
- m_pMaxBox(NULL),
- m_pCaptionBox(NULL),
- m_pNoteLoop(NULL),
- m_pSubFocus(NULL),
- m_fCXBorder(0),
- m_fCYBorder(0),
- m_iCaptureBtn(-1),
- m_iSysBox(0),
- m_eResizeType(FORM_RESIZETYPE_None),
- m_bLButtonDown(FALSE),
- m_bMaximized(FALSE),
- m_bSetMaximize(FALSE),
- m_bCustomizeLayout(FALSE),
- m_eFormSize(FWL_FORMSIZE_Manual),
- m_bDoModalFlag(FALSE),
- m_pBigIcon(NULL),
- m_pSmallIcon(NULL),
- m_bMouseIn(FALSE) {
- m_rtRelative.Reset();
- m_rtCaption.Reset();
- m_rtRestore.Reset();
- m_rtCaptionText.Reset();
- m_rtIcon.Reset();
-}
-CFWL_FormImp::~CFWL_FormImp() {
- RemoveSysButtons();
- delete m_pNoteLoop;
-}
-FWL_ERR CFWL_FormImp::GetClassName(CFX_WideString& wsClass) const {
- wsClass = FWL_CLASS_Form;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_FormImp::GetClassID() const {
- return FWL_CLASSHASH_Form;
-}
-FX_BOOL CFWL_FormImp::IsInstance(const CFX_WideStringC& wsClass) const {
- if (wsClass == CFX_WideStringC(FWL_CLASS_Form)) {
- return TRUE;
- }
- return CFWL_PanelImp::IsInstance(wsClass);
-}
-FWL_ERR CFWL_FormImp::Initialize() {
- if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
- RegisterForm();
- RegisterEventTarget();
- m_pDelegate = new CFWL_FormImpDelegate(this);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_FormImp::Finalize() {
- delete m_pDelegate;
- m_pDelegate = nullptr;
- UnregisterEventTarget();
- UnRegisterForm();
- return CFWL_WidgetImp::Finalize();
-}
-FWL_ERR CFWL_FormImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
- if (bAutoSize) {
- rect.Reset();
- FX_FLOAT fCapHeight = GetCaptionHeight();
- FX_FLOAT fCXBorder = GetBorderSize(TRUE);
- FX_FLOAT fCYBorder = GetBorderSize(FALSE);
- FX_FLOAT fEdge = GetEdgeWidth();
- if (m_pContent) {
- m_pContent->GetWidgetRect(rect, TRUE);
- }
- rect.height += fCapHeight + fCYBorder + fEdge + fEdge;
- rect.width += fCXBorder + fCXBorder + fEdge + fEdge;
- } else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_FormImp::GetClientRect(CFX_RectF& rect) {
- if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) == 0) {
- rect = m_pProperties->m_rtWidget;
- rect.Offset(-rect.left, -rect.top);
- return FWL_ERR_Succeeded;
- }
-#ifdef FWL_UseMacSystemBorder
- rect = m_rtRelative;
- CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- if (!pWidgetMgr)
- return FWL_ERR_Indefinite;
- IFWL_AdapterWidgetMgr* adapterWidgetMgr = pWidgetMgr->GetAdapterWidgetMgr();
- FX_FLOAT l, t, r, b;
- l = t = r = b = 0;
- adapterWidgetMgr->GetSystemBorder(l, t, r, b);
- rect.Deflate(l, t, r, b);
- rect.left = rect.top = 0;
- return FWL_ERR_Succeeded;
-#else
- FX_FLOAT x = 0;
- FX_FLOAT y = 0;
- FX_FLOAT t = 0;
- IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
- if (pTheme) {
- CFWL_ThemePart part;
- part.m_pWidget = m_pInterface;
- x = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CXBorder));
- y = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CYBorder));
- t = *static_cast<FX_FLOAT*>(
- pTheme->GetCapacity(&part, FWL_WGTCAPACITY_FRM_CYCaption));
- }
- rect = m_pProperties->m_rtWidget;
- rect.Offset(-rect.left, -rect.top);
- rect.Deflate(x, t, x, y);
- return FWL_ERR_Succeeded;
-#endif
-}
-FWL_ERR CFWL_FormImp::Update() {
- if (m_iLock > 0) {
- return FWL_ERR_Succeeded;
- }
- if (!m_pProperties->m_pThemeProvider) {
- m_pProperties->m_pThemeProvider = GetAvailableTheme();
- }
-#ifdef FWL_UseMacSystemBorder
-#else
- SetThemeData();
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) {
- UpdateIcon();
- }
-#endif
- UpdateCaption();
- Layout();
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_FormImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
- (void)GetAvailableTheme();
- if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) {
- return FWL_WGTHITTEST_CloseBox;
- }
- if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) {
- return FWL_WGTHITTEST_MaxBox;
- }
- if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) {
- return FWL_WGTHITTEST_MinBox;
- }
- CFX_RectF rtCap;
- rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder,
- m_rtCaption.width - FWL_SYSBTNSIZE * m_iSysBox - 2 * m_fCYBorder,
- m_rtCaption.height - m_fCXBorder);
- if (rtCap.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Titlebar;
- }
- if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) &&
- (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize)) {
- FX_FLOAT fWidth =
- m_rtRelative.width - 2 * (m_fCYBorder + FWL_CornerEnlarge);
- FX_FLOAT fHeight =
- m_rtRelative.height - 2 * (m_fCXBorder + FWL_CornerEnlarge);
- CFX_RectF rt;
- rt.Set(0, m_fCXBorder + FWL_CornerEnlarge, m_fCYBorder, fHeight);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Left;
- }
- rt.Set(m_rtRelative.width - m_fCYBorder, m_fCXBorder + FWL_CornerEnlarge,
- m_fCYBorder, fHeight);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Right;
- }
- rt.Set(m_fCYBorder + FWL_CornerEnlarge, 0, fWidth, m_fCXBorder);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Top;
- }
- rt.Set(m_fCYBorder + FWL_CornerEnlarge, m_rtRelative.height - m_fCXBorder,
- fWidth, m_fCXBorder);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Bottom;
- }
- rt.Set(0, 0, m_fCYBorder + FWL_CornerEnlarge,
- m_fCXBorder + FWL_CornerEnlarge);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_LeftTop;
- }
- rt.Set(0, m_rtRelative.height - m_fCXBorder - FWL_CornerEnlarge,
- m_fCYBorder + FWL_CornerEnlarge, m_fCXBorder + FWL_CornerEnlarge);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_LeftBottom;
- }
- rt.Set(m_rtRelative.width - m_fCYBorder - FWL_CornerEnlarge, 0,
- m_fCYBorder + FWL_CornerEnlarge, m_fCXBorder + FWL_CornerEnlarge);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_RightTop;
- }
- rt.Set(m_rtRelative.width - m_fCYBorder - FWL_CornerEnlarge,
- m_rtRelative.height - m_fCXBorder - FWL_CornerEnlarge,
- m_fCYBorder + FWL_CornerEnlarge, m_fCXBorder + FWL_CornerEnlarge);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_RightBottom;
- }
- }
- return FWL_WGTHITTEST_Client;
-}
-FWL_ERR CFWL_FormImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- if (!pGraphics)
- return FWL_ERR_Indefinite;
- if (!m_pProperties->m_pThemeProvider)
- return FWL_ERR_Indefinite;
- IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
- FX_BOOL bInactive = !IsActive();
- int32_t iState =
- bInactive ? FWL_PARTSTATE_FRM_Inactive : FWL_PARTSTATE_FRM_Normal;
- if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_NoDrawClient) == 0) {
- DrawBackground(pGraphics, pTheme);
- }
-#ifdef FWL_UseMacSystemBorder
- return FWL_ERR_Succeeded;
-#endif
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_dwStates = iState;
- param.m_pGraphics = pGraphics;
- param.m_rtPart = m_rtRelative;
- if (pMatrix) {
- param.m_matrix.Concat(*pMatrix);
- }
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) {
- param.m_iPart = FWL_PART_FRM_Border;
- pTheme->DrawBackground(&param);
- }
- if ((m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_EdgeMask) !=
- FWL_WGTSTYLE_EdgeNone) {
- CFX_RectF rtEdge;
- GetEdgeRect(rtEdge);
- param.m_iPart = FWL_PART_FRM_Edge;
- param.m_rtPart = rtEdge;
- param.m_dwStates = iState;
- pTheme->DrawBackground(&param);
- }
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) {
- param.m_iPart = FWL_PART_FRM_Caption;
- param.m_dwStates = iState;
- param.m_rtPart = m_rtCaption;
- pTheme->DrawBackground(&param);
- DrawCaptionText(pGraphics, pTheme, pMatrix);
- } else if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_NarrowCaption) {
- param.m_iPart = FWL_PART_FRM_NarrowCaption;
- param.m_dwStates = iState;
- param.m_rtPart = m_rtCaption;
- pTheme->DrawBackground(&param);
- DrawCaptionText(pGraphics, pTheme, pMatrix);
- }
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) {
- param.m_iPart = FWL_PART_FRM_Icon;
- if (HasIcon()) {
- DrawIconImage(pGraphics, pTheme, pMatrix);
- }
- }
-#if (_FX_OS_ == _FX_MACOSX_)
- {
- if (m_pCloseBox) {
- param.m_iPart = FWL_PART_FRM_CloseBox;
- param.m_dwStates = m_pCloseBox->GetPartState();
- if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) {
- param.m_dwStates = FWL_PARTSTATE_FRM_Disabled;
- } else if (FWL_PARTSTATE_FRM_Normal == param.m_dwStates && m_bMouseIn) {
- param.m_dwStates = FWL_PARTSTATE_FRM_Hover;
- }
- param.m_rtPart = m_pCloseBox->m_rtBtn;
- pTheme->DrawBackground(&param);
- }
- if (m_pMaxBox) {
- param.m_iPart = FWL_PART_FRM_MaximizeBox;
- param.m_dwStates = m_pMaxBox->GetPartState();
- if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) {
- param.m_dwStates = FWL_PARTSTATE_FRM_Disabled;
- } else if (FWL_PARTSTATE_FRM_Normal == param.m_dwStates && m_bMouseIn) {
- param.m_dwStates = FWL_PARTSTATE_FRM_Hover;
- }
- param.m_rtPart = m_pMaxBox->m_rtBtn;
- param.m_dwData = m_bMaximized;
- pTheme->DrawBackground(&param);
- }
- if (m_pMinBox) {
- param.m_iPart = FWL_PART_FRM_MinimizeBox;
- param.m_dwStates = m_pMinBox->GetPartState();
- if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) {
- param.m_dwStates = FWL_PARTSTATE_FRM_Disabled;
- } else if (FWL_PARTSTATE_FRM_Normal == param.m_dwStates && m_bMouseIn) {
- param.m_dwStates = FWL_PARTSTATE_FRM_Hover;
- }
- param.m_rtPart = m_pMinBox->m_rtBtn;
- pTheme->DrawBackground(&param);
- }
- m_bMouseIn = FALSE;
- }
-#else
- {
- if (m_pCloseBox) {
- param.m_iPart = FWL_PART_FRM_CloseBox;
- param.m_dwStates = m_pCloseBox->GetPartState();
- param.m_rtPart = m_pCloseBox->m_rtBtn;
- pTheme->DrawBackground(&param);
- }
- if (m_pMaxBox) {
- param.m_iPart = FWL_PART_FRM_MaximizeBox;
- param.m_dwStates = m_pMaxBox->GetPartState();
- param.m_rtPart = m_pMaxBox->m_rtBtn;
- param.m_dwData = m_bMaximized;
- pTheme->DrawBackground(&param);
- }
- if (m_pMinBox) {
- param.m_iPart = FWL_PART_FRM_MinimizeBox;
- param.m_dwStates = m_pMinBox->GetPartState();
- param.m_rtPart = m_pMinBox->m_rtBtn;
- pTheme->DrawBackground(&param);
- }
- }
-#endif
- return FWL_ERR_Succeeded;
-}
-FWL_FORMSIZE CFWL_FormImp::GetFormSize() {
- return m_eFormSize;
-}
-FWL_ERR CFWL_FormImp::SetFormSize(FWL_FORMSIZE eFormSize) {
- m_eFormSize = eFormSize;
- return FWL_ERR_Succeeded;
-}
-IFWL_Widget* CFWL_FormImp::DoModal() {
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
- return NULL;
- IFWL_NoteDriver* pDriver = pThread->GetNoteDriver();
- if (!pDriver)
- return NULL;
- m_pNoteLoop = new CFWL_NoteLoop(this);
- pDriver->PushNoteLoop(m_pNoteLoop);
- m_bDoModalFlag = TRUE;
- SetStates(FWL_WGTSTATE_Invisible, FALSE);
- pDriver->Run();
-#if (_FX_OS_ == _FX_MACOSX_)
-#else
- pDriver->PopNoteLoop();
-#endif
- delete m_pNoteLoop;
- m_pNoteLoop = NULL;
- return NULL;
-}
-IFWL_Widget* CFWL_FormImp::DoModal(FX_DWORD& dwCommandID) {
- return DoModal();
-}
-FWL_ERR CFWL_FormImp::EndDoModal() {
- if (!m_pNoteLoop)
- return FWL_ERR_Indefinite;
- m_bDoModalFlag = FALSE;
-#if (_FX_OS_ == _FX_MACOSX_)
- m_pNoteLoop->EndModalLoop();
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
- return FWL_ERR_Indefinite;
- CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
- if (!pDriver)
- return FWL_ERR_Indefinite;
- pDriver->PopNoteLoop();
- SetStates(FWL_WGTSTATE_Invisible, TRUE);
- return FWL_ERR_Succeeded;
-#else
- SetStates(FWL_WGTSTATE_Invisible, TRUE);
- return m_pNoteLoop->EndModalLoop();
-#endif
-}
-FWL_ERR CFWL_FormImp::SetBorderRegion(CFX_Path* pPath) {
- return FWL_ERR_Succeeded;
-}
-void CFWL_FormImp::DrawBackground(CFX_Graphics* pGraphics,
- IFWL_ThemeProvider* pTheme) {
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_FRM_Background;
- param.m_pGraphics = pGraphics;
- param.m_rtPart = m_rtRelative;
- param.m_rtPart.Deflate(m_fCYBorder, m_rtCaption.height, m_fCYBorder,
- m_fCXBorder);
- pTheme->DrawBackground(&param);
-}
-CFWL_WidgetImp* CFWL_FormImp::GetSubFocus() {
- return m_pSubFocus;
-}
-void CFWL_FormImp::SetSubFocus(CFWL_WidgetImp* pWidget) {
- m_pSubFocus = pWidget;
-}
-CFX_MapAccelerators& CFWL_FormImp::GetAccelerator() {
- return m_mapAccelerators;
-}
-void CFWL_FormImp::SetAccelerator(CFX_MapAccelerators* pAccelerators) {
- if (!pAccelerators)
- return;
- m_mapAccelerators.RemoveAll();
- FX_DWORD vrKey, rValue;
- FX_POSITION pos = pAccelerators->GetStartPosition();
- while (pos) {
- pAccelerators->GetNextAssoc(pos, vrKey, rValue);
- m_mapAccelerators.SetAt(vrKey, rValue);
- }
-}
-void CFWL_FormImp::ShowChildWidget(IFWL_Widget* pParent) {
- IFWL_App* pApp = FWL_GetApp();
- if (!pApp)
- return;
- CFWL_WidgetMgr* pWidgetMgr =
- static_cast<CFWL_WidgetMgr*>(pApp->GetWidgetMgr());
- if (!pWidgetMgr)
- return;
- IFWL_Widget* pChild =
- pWidgetMgr->GetWidget(pParent, FWL_WGTRELATION_FirstChild);
- while (pChild) {
- pWidgetMgr->ShowWidget_Native(pChild);
- ShowChildWidget(pChild);
- pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling);
- }
-}
-void CFWL_FormImp::RemoveSysButtons() {
- m_rtCaption.Reset();
- if (m_pCloseBox) {
- delete m_pCloseBox;
- m_pCloseBox = NULL;
- }
- if (m_pMinBox) {
- delete m_pMinBox;
- m_pMinBox = NULL;
- }
- if (m_pMaxBox) {
- delete m_pMaxBox;
- m_pMaxBox = NULL;
- }
- if (m_pCaptionBox) {
- delete m_pCaptionBox;
- m_pCaptionBox = NULL;
- }
-}
-void CFWL_FormImp::CalcContentRect(CFX_RectF& rtContent) {
-#ifdef FWL_UseMacSystemBorder
- rtContent = m_rtRelative;
-#else
- GetEdgeRect(rtContent);
- if (HasEdge()) {
- FX_FLOAT fEdge = GetEdgeWidth();
- rtContent.Deflate(fEdge, fEdge);
- }
-#endif
-}
-CFWL_SysBtn* CFWL_FormImp::GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy) {
- if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) {
- return m_pCloseBox;
- }
- if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) {
- return m_pMaxBox;
- }
- if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) {
- return m_pMinBox;
- }
- if (m_pCaptionBox && m_pCaptionBox->m_rtBtn.Contains(fx, fy)) {
- return m_pCaptionBox;
- }
- return NULL;
-}
-CFWL_SysBtn* CFWL_FormImp::GetSysBtnByState(FX_DWORD dwState) {
- if (m_pCloseBox && (m_pCloseBox->m_dwState & dwState)) {
- return m_pCloseBox;
- }
- if (m_pMaxBox && (m_pMaxBox->m_dwState & dwState)) {
- return m_pMaxBox;
- }
- if (m_pMinBox && (m_pMinBox->m_dwState & dwState)) {
- return m_pMinBox;
- }
- if (m_pCaptionBox && (m_pCaptionBox->m_dwState & dwState)) {
- return m_pCaptionBox;
- }
- return NULL;
-}
-CFWL_SysBtn* CFWL_FormImp::GetSysBtnByIndex(int32_t nIndex) {
- if (nIndex < 0) {
- return NULL;
- }
- CFX_PtrArray arrBtn;
- if (m_pMinBox) {
- arrBtn.Add(m_pMinBox);
- }
- if (m_pMaxBox) {
- arrBtn.Add(m_pMaxBox);
- }
- if (m_pCloseBox) {
- arrBtn.Add(m_pCloseBox);
- }
- return static_cast<CFWL_SysBtn*>(arrBtn[nIndex]);
-}
-int32_t CFWL_FormImp::GetSysBtnIndex(CFWL_SysBtn* pBtn) {
- CFX_PtrArray arrBtn;
- if (m_pMinBox) {
- arrBtn.Add(m_pMinBox);
- }
- if (m_pMaxBox) {
- arrBtn.Add(m_pMaxBox);
- }
- if (m_pCloseBox) {
- arrBtn.Add(m_pCloseBox);
- }
- return arrBtn.Find(pBtn);
-}
-FX_FLOAT CFWL_FormImp::GetCaptionHeight() {
- FX_DWORD dwCapacity = 0;
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) {
- dwCapacity = FWL_WGTCAPACITY_FRM_CYCaption;
- } else if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_NarrowCaption) {
- dwCapacity = FWL_WGTCAPACITY_FRM_CYNarrowCaption;
- }
- if (dwCapacity > 0) {
- FX_FLOAT* pfCapHeight =
- static_cast<FX_FLOAT*>(GetThemeCapacity(dwCapacity));
- return pfCapHeight ? *pfCapHeight : 0;
- }
- return 0;
-}
-void CFWL_FormImp::DrawCaptionText(CFX_Graphics* pGs,
- IFWL_ThemeProvider* pTheme,
- const CFX_Matrix* pMatrix) {
- CFX_WideString wsText;
- IFWL_DataProvider* pData = m_pProperties->m_pDataProvider;
- pData->GetCaption(m_pInterface, wsText);
- if (wsText.IsEmpty()) {
- return;
- }
- CFWL_ThemeText textParam;
- textParam.m_pWidget = m_pInterface;
- textParam.m_iPart = FWL_PART_FRM_Caption;
- textParam.m_dwStates = FWL_PARTSTATE_FRM_Normal;
- textParam.m_pGraphics = pGs;
- if (pMatrix) {
- textParam.m_matrix.Concat(*pMatrix);
- }
- CFX_RectF rtText;
- if (m_bCustomizeLayout) {
- rtText = m_rtCaptionText;
- rtText.top -= 5;
- } else {
- rtText = m_rtCaption;
- FX_FLOAT fpos;
- fpos = HasIcon() ? 29.0f : 13.0f;
- rtText.left += fpos;
- }
- textParam.m_rtPart = rtText;
- textParam.m_wsText = wsText;
- textParam.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine | FDE_TTOSTYLE_Ellipsis;
- textParam.m_iTTOAlign = m_bCustomizeLayout ? FDE_TTOALIGNMENT_Center
- : FDE_TTOALIGNMENT_CenterLeft;
- pTheme->DrawText(&textParam);
-}
-void CFWL_FormImp::DrawIconImage(CFX_Graphics* pGs,
- IFWL_ThemeProvider* pTheme,
- const CFX_Matrix* pMatrix) {
- IFWL_FormDP* pData =
- static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider);
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_FRM_Icon;
- param.m_pGraphics = pGs;
- param.m_pImage = pData->GetIcon(m_pInterface, FALSE);
- param.m_rtPart = m_rtIcon;
- if (pMatrix) {
- param.m_matrix.Concat(*pMatrix);
- }
- pTheme->DrawBackground(&param);
-}
-void CFWL_FormImp::GetEdgeRect(CFX_RectF& rtEdge) {
- rtEdge = m_rtRelative;
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) {
- FX_FLOAT fCX = GetBorderSize();
- FX_FLOAT fCY = GetBorderSize(FALSE);
- rtEdge.Deflate(fCX, m_rtCaption.Height(), fCX, fCY);
- }
-}
-void CFWL_FormImp::SetWorkAreaRect() {
- m_rtRestore = m_pProperties->m_rtWidget;
- CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- if (!pWidgetMgr)
- return;
- m_bSetMaximize = TRUE;
- pWidgetMgr->SetMaximize_Native(m_pInterface);
- Repaint(&m_rtRelative);
-}
-void CFWL_FormImp::SetCursor(FX_FLOAT fx, FX_FLOAT fy) {}
-void CFWL_FormImp::Layout() {
- GetRelativeRect(m_rtRelative);
-#ifndef FWL_UseMacSystemBorder
- ReSetSysBtn();
-#endif
- if (m_pContent) {
- CFX_RectF rtClient;
- GetClientRect(rtClient);
- m_pContent->SetWidgetRect(rtClient);
- m_pContent->Update();
- }
-}
-void CFWL_FormImp::ReSetSysBtn() {
- m_fCXBorder =
- *static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_CXBorder));
- m_fCYBorder =
- *static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_CYBorder));
- RemoveSysButtons();
- IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
- m_bCustomizeLayout = pTheme->IsCustomizedLayout(m_pInterface);
- FX_FLOAT fCapHeight = GetCaptionHeight();
- if (fCapHeight > 0) {
- m_rtCaption = m_rtRelative;
- m_rtCaption.height = fCapHeight;
- }
- m_iSysBox = 0;
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_CloseBox) {
- m_pCloseBox = new CFWL_SysBtn;
- if (m_bCustomizeLayout) {
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_FRM_CloseBox;
- pTheme->GetPartRect(&param, m_pCloseBox->m_rtBtn);
- } else {
- m_pCloseBox->m_rtBtn.Set(
- m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE,
- FWL_SYSBTNMARGIN, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE);
- }
- m_iSysBox++;
- }
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_MaximizeBox) {
- m_pMaxBox = new CFWL_SysBtn;
- if (m_bCustomizeLayout) {
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_FRM_MaximizeBox;
- pTheme->GetPartRect(&param, m_pMaxBox->m_rtBtn);
- } else {
- if (m_pCloseBox) {
- m_pMaxBox->m_rtBtn.Set(
- m_pCloseBox->m_rtBtn.left - FWL_SYSBTNSPAN - FWL_SYSBTNSIZE,
- m_pCloseBox->m_rtBtn.top, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE);
- } else {
- m_pMaxBox->m_rtBtn.Set(
- m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE,
- FWL_SYSBTNMARGIN, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE);
- }
- }
- m_iSysBox++;
- }
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_MinimizeBox) {
- m_pMinBox = new CFWL_SysBtn;
- if (m_bCustomizeLayout) {
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_FRM_MinimizeBox;
- pTheme->GetPartRect(&param, m_pMinBox->m_rtBtn);
- } else {
- if (m_pMaxBox) {
- m_pMinBox->m_rtBtn.Set(
- m_pMaxBox->m_rtBtn.left - FWL_SYSBTNSPAN - FWL_SYSBTNSIZE,
- m_pMaxBox->m_rtBtn.top, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE);
- } else if (m_pCloseBox) {
- m_pMinBox->m_rtBtn.Set(
- m_pCloseBox->m_rtBtn.left - FWL_SYSBTNSPAN - FWL_SYSBTNSIZE,
- m_pCloseBox->m_rtBtn.top, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE);
- } else {
- m_pMinBox->m_rtBtn.Set(
- m_rtRelative.right() - FWL_SYSBTNMARGIN - FWL_SYSBTNSIZE,
- FWL_SYSBTNMARGIN, FWL_SYSBTNSIZE, FWL_SYSBTNSIZE);
- }
- }
- m_iSysBox++;
- }
- IFWL_FormDP* pData =
- static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider);
- if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon &&
- pData->GetIcon(m_pInterface, FALSE)) {
- if (m_bCustomizeLayout) {
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = FWL_PART_FRM_Icon;
- CFX_WideString wsText;
- m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsText);
- param.m_pData = &wsText;
- pTheme->GetPartRect(&param, m_rtIcon);
- } else {
- m_rtIcon.Set(5, (m_rtCaption.height - m_fSmallIconSz) / 2, m_fSmallIconSz,
- m_fSmallIconSz);
- }
- }
- if (m_bCustomizeLayout) {
- CFWL_ThemeText parma;
- parma.m_pWidget = m_pInterface;
- parma.m_iPart = FWL_PART_FRM_HeadText;
- m_pProperties->m_pDataProvider->GetCaption(m_pInterface, parma.m_wsText);
- pTheme->GetPartRect(&parma, m_rtCaptionText);
- }
-}
-void CFWL_FormImp::RegisterForm() {
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
- return;
- CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
- if (!pDriver)
- return;
- pDriver->RegisterForm(this);
-}
-void CFWL_FormImp::UnRegisterForm() {
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
- return;
- CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
- if (!pDriver)
- return;
- pDriver->UnRegisterForm(this);
-}
-FX_BOOL CFWL_FormImp::IsDoModal() {
- return m_bDoModalFlag;
-}
-void CFWL_FormImp::SetThemeData() {
- m_fSmallIconSz =
- *static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_FRM_SmallIcon));
- m_fBigIconSz =
- *static_cast<FX_FLOAT*>(GetThemeCapacity(FWL_WGTCAPACITY_FRM_BigIcon));
-}
-FX_BOOL CFWL_FormImp::HasIcon() {
- IFWL_FormDP* pData =
- static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider);
- return !!pData->GetIcon(m_pInterface, FALSE);
-}
-void CFWL_FormImp::UpdateIcon() {
- CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- if (!pWidgetMgr)
- return;
- IFWL_FormDP* pData =
- static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider);
- CFX_DIBitmap* pBigIcon = pData->GetIcon(m_pInterface, TRUE);
- CFX_DIBitmap* pSmallIcon = pData->GetIcon(m_pInterface, FALSE);
- if (pBigIcon && pBigIcon != m_pBigIcon) {
- m_pBigIcon = pBigIcon;
- pWidgetMgr->SetWidgetIcon_Native(m_pInterface, m_pBigIcon, TRUE);
- }
- if (pSmallIcon && pSmallIcon != m_pSmallIcon) {
- m_pSmallIcon = pSmallIcon;
- pWidgetMgr->SetWidgetIcon_Native(m_pInterface, m_pBigIcon, FALSE);
- }
-}
-void CFWL_FormImp::UpdateCaption() {
- CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- if (!pWidgetMgr)
- return;
- IFWL_FormDP* pData =
- static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider);
- if (!pData)
- return;
- CFX_WideString text;
- pData->GetCaption(m_pInterface, text);
- pWidgetMgr->SetWidgetCaption_Native(m_pInterface, text);
-}
-void CFWL_FormImp::DoWidthLimit(FX_FLOAT& fLeft,
- FX_FLOAT& fWidth,
- FX_FLOAT fCurX,
- FX_FLOAT fSpace,
- FX_FLOAT fLimitMin,
- FX_FLOAT fLimitMax,
- FX_BOOL bLeft) {
- FX_FLOAT fx = fCurX;
- FX_FLOAT fy = 0;
- TransformTo(NULL, fx, fy);
- FX_FLOAT fTemp =
- bLeft ? (fWidth - fx + fLeft + fSpace) : (fx - fLeft + fSpace);
- if (fTemp >= fLimitMin && fTemp <= fLimitMax) {
- fWidth = fTemp;
- fLeft += bLeft ? (fx - fLeft - fSpace) : 0;
- } else {
- if (fTemp < fLimitMin && fWidth > fLimitMin) {
- fLeft += bLeft ? (fWidth - fLimitMin) : 0;
- fWidth = fLimitMin;
- } else if (fTemp > fLimitMax && fWidth < fLimitMax) {
- fLeft -= bLeft ? (fLimitMax - fWidth) : 0;
- fWidth = fLimitMax;
- }
- }
-}
-void CFWL_FormImp::DoHeightLimit(FX_FLOAT& fTop,
- FX_FLOAT& fHeight,
- FX_FLOAT fCurY,
- FX_FLOAT fSpace,
- FX_FLOAT fLimitMin,
- FX_FLOAT fLimitMax,
- FX_BOOL bTop) {
- FX_FLOAT fx = 0;
- FX_FLOAT fy = fCurY;
- TransformTo(NULL, fx, fy);
- FX_FLOAT fTemp = bTop ? (fHeight - fy + fTop + fSpace) : (fy - fTop + fSpace);
- if (fTemp >= fLimitMin && fTemp <= fLimitMax) {
- fHeight = fTemp;
- fTop += bTop ? (fy - fTop - fSpace) : 0;
- } else {
- if (fTemp < fLimitMin && fHeight > fLimitMin) {
- fTop += bTop ? (fHeight - fLimitMin) : 0;
- fHeight = fLimitMin;
- } else if (fTemp > fLimitMax && fHeight < fLimitMax) {
- fTop -= bTop ? (fLimitMax - fHeight) : 0;
- fHeight = fLimitMax;
- }
- }
-}
-CFWL_FormImpDelegate::CFWL_FormImpDelegate(CFWL_FormImp* pOwner)
- : m_pOwner(pOwner) {}
-int32_t CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
-#ifdef FWL_UseMacSystemBorder
- if (!pMessage)
- return 0;
- FX_DWORD dwMsgCode = pMessage->GetClassID();
- switch (dwMsgCode) {
- case FWL_MSGHASH_Activate: {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
- m_pOwner->Repaint(&m_pOwner->m_rtRelative);
- break;
- }
- case FWL_MSGHASH_Deactivate: {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated;
- m_pOwner->Repaint(&m_pOwner->m_rtRelative);
- break;
- }
- }
- return FWL_ERR_Succeeded;
-#else
- if (!pMessage)
- return 0;
- FX_DWORD dwMsgCode = pMessage->GetClassID();
- int32_t iRet = 1;
- switch (dwMsgCode) {
- case FWL_MSGHASH_Activate: {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
- IFWL_NoteThread* pThread = m_pOwner->GetOwnerThread();
- CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
- CFWL_WidgetImp* pSubFocusImp = m_pOwner->GetSubFocus();
- IFWL_Widget* pSubFocus =
- pSubFocusImp ? pSubFocusImp->GetInterface() : NULL;
- if (pSubFocus && pSubFocus != pDriver->GetFocus()) {
- pDriver->SetFocus(pSubFocus);
- }
- m_pOwner->Repaint(&m_pOwner->m_rtRelative);
- break;
- }
- case FWL_MSGHASH_Deactivate: {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated;
- IFWL_NoteThread* pThread = m_pOwner->GetOwnerThread();
- CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
- CFWL_WidgetImp* pSubFocusImp = m_pOwner->GetSubFocus();
- IFWL_Widget* pSubFocus =
- pSubFocusImp ? pSubFocusImp->GetInterface() : NULL;
- if (pSubFocus) {
- if (pSubFocus == pDriver->GetFocus()) {
- pDriver->SetFocus(NULL);
- } else if (pSubFocus->GetStates() & FWL_WGTSTATE_Focused) {
- CFWL_MsgKillFocus ms;
- IFWL_WidgetDelegate* pDelegate = pSubFocus->SetDelegate(NULL);
- if (pDelegate) {
- pDelegate->OnProcessMessage(&ms);
- }
- }
- }
- m_pOwner->Repaint(&m_pOwner->m_rtRelative);
- break;
- }
- case FWL_MSGHASH_Mouse: {
- CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
- switch (pMsg->m_dwCmd) {
- case FWL_MSGMOUSECMD_LButtonDown: {
- OnLButtonDown(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonUp: {
- OnLButtonUp(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_MouseMove: {
- OnMouseMove(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_MouseHover: {
- OnMouseHover(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_MouseLeave: {
- OnMouseLeave(pMsg);
- break;
- }
- case FWL_MSGMOUSECMD_LButtonDblClk: {
- OnLButtonDblClk(pMsg);
- break;
- }
- }
- break;
- }
- case FWL_MSGHASH_Size: {
- CFWL_WidgetMgr* pWidgetMgr =
- static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- if (!pWidgetMgr)
- return 0;
- pWidgetMgr->AddRedrawCounts(m_pOwner->m_pInterface);
- if (!m_pOwner->m_bSetMaximize) {
- break;
- }
- m_pOwner->m_bSetMaximize = FALSE;
- CFWL_MsgSize* pMsg = static_cast<CFWL_MsgSize*>(pMessage);
- CFX_RectF rt;
- pWidgetMgr->GetWidgetRect_Native(m_pOwner->m_pInterface, rt);
- m_pOwner->m_pProperties->m_rtWidget.left = rt.left;
- m_pOwner->m_pProperties->m_rtWidget.top = rt.top;
- m_pOwner->m_pProperties->m_rtWidget.width = (FX_FLOAT)pMsg->m_iWidth;
- m_pOwner->m_pProperties->m_rtWidget.height = (FX_FLOAT)pMsg->m_iHeight;
- m_pOwner->Update();
- break;
- }
- case FWL_MSGHASH_WindowMove: {
- OnWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage));
- break;
- }
- case FWL_MSGHASH_Close: {
- OnClose(static_cast<CFWL_MsgClose*>(pMessage));
- break;
- }
- default: { iRet = 0; }
- }
- return iRet;
-#endif
-}
-FWL_ERR CFWL_FormImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
- if (!pEvent)
- return FWL_ERR_Indefinite;
- if (pEvent->GetClassID() == FWL_EVTHASH_Close &&
- pEvent->m_pSrcTarget == m_pOwner->m_pInterface) {
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_FormImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
-}
-void CFWL_FormImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
- m_pOwner->SetGrab(TRUE);
- m_pOwner->m_bLButtonDown = TRUE;
- m_pOwner->m_eResizeType = FORM_RESIZETYPE_None;
- CFWL_SysBtn* pPressBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy);
- m_pOwner->m_iCaptureBtn = m_pOwner->GetSysBtnIndex(pPressBtn);
- CFX_RectF rtCap;
- rtCap.Set(m_pOwner->m_rtCaption.left + m_pOwner->m_fCYBorder,
- m_pOwner->m_rtCaption.top + m_pOwner->m_fCXBorder,
- m_pOwner->m_rtCaption.width - FWL_SYSBTNSIZE * m_pOwner->m_iSysBox -
- 2 * m_pOwner->m_fCYBorder,
- m_pOwner->m_rtCaption.height - m_pOwner->m_fCXBorder);
- if (pPressBtn) {
- pPressBtn->SetPressed();
- m_pOwner->Repaint(&pPressBtn->m_rtBtn);
- } else if (rtCap.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_eResizeType = FORM_RESIZETYPE_Cap;
- } else if ((m_pOwner->m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) &&
- (m_pOwner->m_pProperties->m_dwStyleExes &
- FWL_STYLEEXT_FRM_Resize) &&
- !m_pOwner->m_bMaximized) {
- m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy);
- }
- m_pOwner->m_InfoStart.m_ptStart = CFX_PointF(pMsg->m_fx, pMsg->m_fy);
- m_pOwner->m_InfoStart.m_szStart =
- CFX_SizeF(m_pOwner->m_pProperties->m_rtWidget.width,
- m_pOwner->m_pProperties->m_rtWidget.height);
-}
-void CFWL_FormImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
- m_pOwner->SetGrab(FALSE);
- m_pOwner->m_bLButtonDown = FALSE;
- CFWL_SysBtn* pPointBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy);
- CFWL_SysBtn* pPressedBtn =
- m_pOwner->GetSysBtnByIndex(m_pOwner->m_iCaptureBtn);
- if (!pPressedBtn || pPointBtn != pPressedBtn) {
- return;
- }
- if (pPressedBtn == m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Pressed)) {
- pPressedBtn->SetNormal();
- }
- if (pPressedBtn == m_pOwner->m_pMaxBox) {
- if (m_pOwner->m_bMaximized) {
- m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore);
- m_pOwner->Update();
- m_pOwner->Repaint();
- } else {
- m_pOwner->SetWorkAreaRect();
- m_pOwner->Update();
- }
- m_pOwner->m_bMaximized = !m_pOwner->m_bMaximized;
- } else if (pPressedBtn == m_pOwner->m_pMinBox) {
- CFWL_WidgetMgr* pWidgetMgr =
- static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- if (!pWidgetMgr)
- return;
- pWidgetMgr->SetMinimize_Native(m_pOwner->m_pInterface);
- } else {
- CFWL_EvtClose eClose;
- eClose.m_pSrcTarget = m_pOwner->m_pInterface;
- m_pOwner->DispatchEvent(&eClose);
- }
-}
-void CFWL_FormImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_bLButtonDown) {
- return;
- }
- if ((m_pOwner->m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) &&
- (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) &&
- !m_pOwner->m_bMaximized) {
- m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy);
- }
- CFX_RectF rtInvalidate;
- rtInvalidate.Reset();
- CFWL_SysBtn* pPointBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy);
- CFWL_SysBtn* pOldHover = m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover);
-#if (_FX_OS_ == _FX_MACOSX_)
- {
- if (pOldHover && pPointBtn != pOldHover) {
- pOldHover->SetNormal();
- }
- if (pPointBtn && pPointBtn != pOldHover) {
- pPointBtn->SetHover();
- }
- if (m_pOwner->m_pCloseBox) {
- rtInvalidate = m_pOwner->m_pCloseBox->m_rtBtn;
- }
- if (m_pOwner->m_pMaxBox) {
- if (rtInvalidate.IsEmpty()) {
- rtInvalidate = m_pOwner->m_pMaxBox->m_rtBtn;
- } else {
- rtInvalidate.Union(m_pOwner->m_pMaxBox->m_rtBtn);
- }
- }
- if (m_pOwner->m_pMinBox) {
- if (rtInvalidate.IsEmpty()) {
- rtInvalidate = m_pOwner->m_pMinBox->m_rtBtn;
- } else {
- rtInvalidate.Union(m_pOwner->m_pMinBox->m_rtBtn);
- }
- }
- if (!rtInvalidate.IsEmpty() &&
- rtInvalidate.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_bMouseIn = TRUE;
- }
- }
-#else
- {
- if (pOldHover && pPointBtn != pOldHover) {
- pOldHover->SetNormal();
- rtInvalidate = pOldHover->m_rtBtn;
- }
- if (pPointBtn && pPointBtn != pOldHover) {
- pPointBtn->SetHover();
- if (rtInvalidate.IsEmpty()) {
- rtInvalidate = pPointBtn->m_rtBtn;
- } else {
- rtInvalidate.Union(pPointBtn->m_rtBtn);
- }
- }
- }
-#endif
- if (!rtInvalidate.IsEmpty()) {
- m_pOwner->Repaint(&rtInvalidate);
- }
-}
-void CFWL_FormImpDelegate::OnMouseHover(CFWL_MsgMouse* pMsg) {
- m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy);
-}
-void CFWL_FormImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
- CFWL_SysBtn* pHover = m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover);
- if (pHover) {
- pHover->SetNormal();
- m_pOwner->Repaint(&pHover->m_rtBtn);
- }
- if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseLeave &&
- !m_pOwner->m_bLButtonDown) {
- m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy);
- }
-}
-void CFWL_FormImpDelegate::OnLButtonDblClk(CFWL_MsgMouse* pMsg) {
- if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) &&
- m_pOwner->HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WGTHITTEST_Titlebar) {
- if (m_pOwner->m_bMaximized) {
- m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore);
- } else {
- m_pOwner->SetWorkAreaRect();
- }
- m_pOwner->Update();
- m_pOwner->m_bMaximized = !m_pOwner->m_bMaximized;
- }
-}
-void CFWL_FormImpDelegate::OnWindowMove(CFWL_MsgWindowMove* pMsg) {
- m_pOwner->m_pProperties->m_rtWidget.left = pMsg->m_fx;
- m_pOwner->m_pProperties->m_rtWidget.top = pMsg->m_fy;
-}
-void CFWL_FormImpDelegate::OnClose(CFWL_MsgClose* pMsg) {
- CFWL_EvtClose eClose;
- eClose.m_pSrcTarget = m_pOwner->m_pInterface;
- m_pOwner->DispatchEvent(&eClose);
-}
-FWL_ERR FWL_Accelerator_SetForm(IFWL_Form* pFrom,
- CFX_MapAccelerators* pMapAccel) {
- CFWL_FormImp* pImp = static_cast<CFWL_FormImp*>(pFrom->GetImpl());
- if (!pImp)
- return FWL_ERR_Indefinite;
- return FWL_ERR_Succeeded;
-}
diff --git a/xfa/src/fwl/core/fwl_formimp.h b/xfa/src/fwl/core/fwl_formimp.h
deleted file mode 100644
index ad31da807c..0000000000
--- a/xfa/src/fwl/core/fwl_formimp.h
+++ /dev/null
@@ -1,193 +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_SRC_FWL_CORE_FWL_FORMIMP_H_
-#define XFA_SRC_FWL_CORE_FWL_FORMIMP_H_
-
-#include "xfa/include/fwl/core/fwl_form.h"
-#include "xfa/src/fwl/core/fwl_panelimp.h"
-#include "xfa/src/fwl/core/fwl_widgetimp.h"
-
-class CFWL_NoteLoop;
-class CFWL_WidgetImpProperties;
-class CFWL_MsgMouse;
-class IFWL_Widget;
-class IFWL_ThemeProvider;
-class CFWL_SysBtn;
-class CFWL_FormImp;
-class CFWL_FormImpDelegate;
-
-#define FWL_SYSBUTTONSTATE_Hover 0x0001
-#define FWL_SYSBUTTONSTATE_Pressed 0x0002
-#define FWL_SYSBUTTONSTATE_Disabled 0x0010
-class CFWL_SysBtn {
- public:
- CFWL_SysBtn() {
- m_rtBtn.Set(0, 0, 0, 0);
- m_dwState = 0;
- }
-
- FX_BOOL IsHover() { return m_dwState & FWL_SYSBUTTONSTATE_Hover; }
- FX_BOOL IsPressed() { return m_dwState & FWL_SYSBUTTONSTATE_Pressed; }
- FX_BOOL IsDisabled() { return m_dwState & FWL_SYSBUTTONSTATE_Disabled; }
- void SetNormal() { m_dwState &= 0xFFF0; }
- void SetPressed() {
- SetNormal();
- m_dwState |= FWL_SYSBUTTONSTATE_Pressed;
- }
- void SetHover() {
- SetNormal();
- m_dwState |= FWL_SYSBUTTONSTATE_Hover;
- }
- void SetDisabled(FX_BOOL bDisabled) {
- bDisabled ? m_dwState |= FWL_SYSBUTTONSTATE_Disabled
- : m_dwState &= ~FWL_SYSBUTTONSTATE_Disabled;
- }
- int32_t GetPartState() {
- return (IsDisabled() ? FWL_PARTSTATE_FRM_Disabled : (m_dwState + 1));
- }
-
- CFX_RectF m_rtBtn;
- FX_DWORD m_dwState;
-};
-enum FORM_RESIZETYPE {
- FORM_RESIZETYPE_None = 0,
- FORM_RESIZETYPE_Cap,
- FORM_RESIZETYPE_Left,
- FORM_RESIZETYPE_Top,
- FORM_RESIZETYPE_Right,
- FORM_RESIZETYPE_Bottom,
- FORM_RESIZETYPE_LeftTop,
- FORM_RESIZETYPE_LeftBottom,
- FORM_RESIZETYPE_RightTop,
- FORM_RESIZETYPE_RightBottom
-};
-typedef struct RestoreResizeInfo {
- CFX_PointF m_ptStart;
- CFX_SizeF m_szStart;
-} RestoreInfo;
-class CFWL_FormImp : public CFWL_PanelImp {
- public:
- CFWL_FormImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter);
- virtual ~CFWL_FormImp();
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
-
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR GetClientRect(CFX_RectF& rect);
- virtual FWL_ERR Update();
- virtual FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy);
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
- virtual FWL_FORMSIZE GetFormSize();
- virtual FWL_ERR SetFormSize(FWL_FORMSIZE eFormSize);
- virtual IFWL_Widget* DoModal();
- virtual IFWL_Widget* DoModal(FX_DWORD& dwCommandID);
- virtual FWL_ERR EndDoModal();
- virtual FWL_ERR SetBorderRegion(CFX_Path* pPath);
- virtual void DrawBackground(CFX_Graphics* pGraphics,
- IFWL_ThemeProvider* pTheme);
- CFWL_WidgetImp* GetSubFocus();
- void SetSubFocus(CFWL_WidgetImp* pWidget);
- CFX_MapAccelerators& GetAccelerator();
- void SetAccelerator(CFX_MapAccelerators* pAccelerators);
-
- protected:
- void ShowChildWidget(IFWL_Widget* pParent);
- void RemoveSysButtons();
- void CalcContentRect(CFX_RectF& rtContent);
- CFWL_SysBtn* GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy);
- CFWL_SysBtn* GetSysBtnByState(FX_DWORD dwState);
- CFWL_SysBtn* GetSysBtnByIndex(int32_t nIndex);
- int32_t GetSysBtnIndex(CFWL_SysBtn* pBtn);
- FX_FLOAT GetCaptionHeight();
- void DrawCaptionText(CFX_Graphics* pGs,
- IFWL_ThemeProvider* pTheme,
- const CFX_Matrix* pMatrix = NULL);
- void DrawIconImage(CFX_Graphics* pGs,
- IFWL_ThemeProvider* pTheme,
- const CFX_Matrix* pMatrix = NULL);
- void GetEdgeRect(CFX_RectF& rtEdge);
- void SetWorkAreaRect();
- void SetCursor(FX_FLOAT fx, FX_FLOAT fy);
- void Layout();
- void ReSetSysBtn();
- void RegisterForm();
- void UnRegisterForm();
- FX_BOOL IsDoModal();
- void SetThemeData();
- FX_BOOL HasIcon();
- void UpdateIcon();
- void UpdateCaption();
- void DoWidthLimit(FX_FLOAT& fLeft,
- FX_FLOAT& fWidth,
- FX_FLOAT fCurX,
- FX_FLOAT fSpace,
- FX_FLOAT fLimitMin,
- FX_FLOAT fLimitMax,
- FX_BOOL bLeft);
- void DoHeightLimit(FX_FLOAT& fTop,
- FX_FLOAT& fHeight,
- FX_FLOAT fCurY,
- FX_FLOAT fSpace,
- FX_FLOAT fLimitMin,
- FX_FLOAT fLimitMax,
- FX_BOOL bTop);
- CFX_MapAccelerators m_mapAccelerators;
- CFX_RectF m_rtRestore;
- CFX_RectF m_rtCaptionText;
- CFX_RectF m_rtRelative;
- CFX_RectF m_rtCaption;
- CFX_RectF m_rtIcon;
- CFWL_SysBtn* m_pCloseBox;
- CFWL_SysBtn* m_pMinBox;
- CFWL_SysBtn* m_pMaxBox;
- CFWL_SysBtn* m_pCaptionBox;
- CFWL_NoteLoop* m_pNoteLoop;
- CFWL_WidgetImp* m_pSubFocus;
- RestoreInfo m_InfoStart;
- FX_FLOAT m_fCXBorder;
- FX_FLOAT m_fCYBorder;
- int32_t m_iCaptureBtn;
- int32_t m_iSysBox;
- int32_t m_eResizeType;
- FX_BOOL m_bLButtonDown;
- FX_BOOL m_bMaximized;
- FX_BOOL m_bSetMaximize;
- FX_BOOL m_bCustomizeLayout;
- FWL_FORMSIZE m_eFormSize;
- FX_BOOL m_bDoModalFlag;
- FX_FLOAT m_fSmallIconSz;
- FX_FLOAT m_fBigIconSz;
- CFX_DIBitmap* m_pBigIcon;
- CFX_DIBitmap* m_pSmallIcon;
- FX_BOOL m_bMouseIn;
- friend class CFWL_FormImpDelegate;
-};
-class CFWL_FormImpDelegate : public CFWL_WidgetImpDelegate {
- public:
- CFWL_FormImpDelegate(CFWL_FormImp* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnProcessEvent(CFWL_Event* pEvent) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
-
- protected:
- void OnLButtonDown(CFWL_MsgMouse* pMsg);
- void OnLButtonUp(CFWL_MsgMouse* pMsg);
- void OnMouseMove(CFWL_MsgMouse* pMsg);
- void OnMouseHover(CFWL_MsgMouse* pMsg);
- void OnMouseLeave(CFWL_MsgMouse* pMsg);
- void OnLButtonDblClk(CFWL_MsgMouse* pMsg);
- void OnWindowMove(CFWL_MsgWindowMove* pMsg);
- void OnClose(CFWL_MsgClose* pMsg);
- CFWL_FormImp* m_pOwner;
-};
-
-#endif // XFA_SRC_FWL_CORE_FWL_FORMIMP_H_
diff --git a/xfa/src/fwl/core/fwl_gridimp.cpp b/xfa/src/fwl/core/fwl_gridimp.cpp
deleted file mode 100644
index 1230fa2655..0000000000
--- a/xfa/src/fwl/core/fwl_gridimp.cpp
+++ /dev/null
@@ -1,1378 +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/src/fwl/core/fwl_gridimp.h"
-
-#include "xfa/src/fwl/core/fwl_contentimp.h"
-#include "xfa/src/fwl/core/fwl_noteimp.h"
-#include "xfa/src/fwl/core/fwl_targetimp.h"
-#include "xfa/src/fwl/core/fwl_threadimp.h"
-#include "xfa/src/fwl/core/fwl_widgetimp.h"
-
-// static
-IFWL_Grid* IFWL_Grid::Create(const CFWL_WidgetImpProperties& properties) {
- IFWL_Grid* pGrid = new IFWL_Grid;
- CFWL_GridImp* pGridImpl = new CFWL_GridImp(properties, nullptr);
- pGrid->SetImpl(pGridImpl);
- pGridImpl->SetInterface(pGrid);
- return pGrid;
-}
-IFWL_Grid::IFWL_Grid() {}
-FWL_HGRIDCOLROW IFWL_Grid::InsertColRow(FX_BOOL bColumn, int32_t nIndex) {
- return static_cast<CFWL_GridImp*>(GetImpl())->InsertColRow(bColumn, nIndex);
-}
-int32_t IFWL_Grid::CountColRows(FX_BOOL bColumn) {
- return static_cast<CFWL_GridImp*>(GetImpl())->CountColRows(bColumn);
-}
-FWL_HGRIDCOLROW IFWL_Grid::GetColRow(FX_BOOL bColumn, int32_t nIndex) {
- return static_cast<CFWL_GridImp*>(GetImpl())->GetColRow(bColumn, nIndex);
-}
-int32_t IFWL_Grid::GetIndex(FWL_HGRIDCOLROW hColRow) {
- return static_cast<CFWL_GridImp*>(GetImpl())->GetIndex(hColRow);
-}
-FX_FLOAT IFWL_Grid::GetSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit) {
- return static_cast<CFWL_GridImp*>(GetImpl())->GetSize(hColRow, eUnit);
-}
-FWL_ERR IFWL_Grid::SetSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit) {
- return static_cast<CFWL_GridImp*>(GetImpl())->SetSize(hColRow, fSize, eUnit);
-}
-FX_FLOAT IFWL_Grid::GetMinSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit) {
- return static_cast<CFWL_GridImp*>(GetImpl())->GetMinSize(hColRow, eUnit);
-}
-FWL_ERR IFWL_Grid::SetMinSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit) {
- return static_cast<CFWL_GridImp*>(GetImpl())
- ->SetMinSize(hColRow, fSize, eUnit);
-}
-FX_FLOAT IFWL_Grid::GetMaxSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit) {
- return static_cast<CFWL_GridImp*>(GetImpl())->GetMaxSize(hColRow, eUnit);
-}
-FWL_ERR IFWL_Grid::SetMaxSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit) {
- return static_cast<CFWL_GridImp*>(GetImpl())
- ->SetMaxSize(hColRow, fSize, eUnit);
-}
-FX_BOOL IFWL_Grid::DeleteColRow(FWL_HGRIDCOLROW hColRow) {
- return static_cast<CFWL_GridImp*>(GetImpl())->DeleteColRow(hColRow);
-}
-FX_BOOL IFWL_Grid::IsColumn(FWL_HGRIDCOLROW hColRow) {
- return static_cast<CFWL_GridImp*>(GetImpl())->IsColumn(hColRow);
-}
-int32_t IFWL_Grid::GetWidgetPos(IFWL_Widget* pWidget, FX_BOOL bColumn) {
- return static_cast<CFWL_GridImp*>(GetImpl())->GetWidgetPos(pWidget, bColumn);
-}
-FWL_ERR IFWL_Grid::SetWidgetPos(IFWL_Widget* pWidget,
- int32_t iPos,
- FX_BOOL bColumn) {
- return static_cast<CFWL_GridImp*>(GetImpl())
- ->SetWidgetPos(pWidget, iPos, bColumn);
-}
-int32_t IFWL_Grid::GetWidgetSpan(IFWL_Widget* pWidget, FX_BOOL bColumn) {
- return static_cast<CFWL_GridImp*>(GetImpl())->GetWidgetSpan(pWidget, bColumn);
-}
-FWL_ERR IFWL_Grid::SetWidgetSpan(IFWL_Widget* pWidget,
- int32_t iSpan,
- FX_BOOL bColumn) {
- return static_cast<CFWL_GridImp*>(GetImpl())
- ->SetWidgetSpan(pWidget, iSpan, bColumn);
-}
-FX_FLOAT IFWL_Grid::GetWidgetSize(IFWL_Widget* pWidget,
- FWL_GRIDSIZE eSize,
- FWL_GRIDUNIT& eUnit) {
- return static_cast<CFWL_GridImp*>(GetImpl())
- ->GetWidgetSize(pWidget, eSize, eUnit);
-}
-FWL_ERR IFWL_Grid::SetWidgetSize(IFWL_Widget* pWidget,
- FWL_GRIDSIZE eSize,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUit) {
- return static_cast<CFWL_GridImp*>(GetImpl())
- ->SetWidgetSize(pWidget, eSize, fSize, eUit);
-}
-FX_BOOL IFWL_Grid::GetWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin,
- FX_FLOAT& fMargin) {
- return static_cast<CFWL_GridImp*>(GetImpl())
- ->GetWidgetMargin(pWidget, eMargin, fMargin);
-}
-FWL_ERR IFWL_Grid::SetWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin,
- FX_FLOAT fMargin) {
- return static_cast<CFWL_GridImp*>(GetImpl())
- ->SetWidgetMargin(pWidget, eMargin, fMargin);
-}
-FWL_ERR IFWL_Grid::RemoveWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin) {
- return static_cast<CFWL_GridImp*>(GetImpl())
- ->RemoveWidgetMargin(pWidget, eMargin);
-}
-FX_FLOAT IFWL_Grid::GetGridSize(FWL_GRIDSIZE eSize, FWL_GRIDUNIT& eUnit) {
- return static_cast<CFWL_GridImp*>(GetImpl())->GetGridSize(eSize, eUnit);
-}
-FWL_ERR IFWL_Grid::SetGridSize(FWL_GRIDSIZE eSize,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUit) {
- return static_cast<CFWL_GridImp*>(GetImpl())->SetGridSize(eSize, fSize, eUit);
-}
-
-CFWL_GridImp::CFWL_GridImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter)
- : CFWL_ContentImp(properties, pOuter) {
- m_Size[FWL_GRIDSIZE_Width].eUnit = FWL_GRIDUNIT_Auto;
- m_Size[FWL_GRIDSIZE_Width].fLength = 0;
- m_Size[FWL_GRIDSIZE_Height].eUnit = FWL_GRIDUNIT_Auto;
- m_Size[FWL_GRIDSIZE_Height].fLength = 0;
- m_Size[FWL_GRIDSIZE_MinWidth].eUnit = FWL_GRIDUNIT_Fixed;
- m_Size[FWL_GRIDSIZE_MinWidth].fLength = 0;
- m_Size[FWL_GRIDSIZE_MaxWidth].eUnit = FWL_GRIDUNIT_Infinity;
- m_Size[FWL_GRIDSIZE_MaxWidth].fLength = 0;
- m_Size[FWL_GRIDSIZE_MinHeight].eUnit = FWL_GRIDUNIT_Fixed;
- m_Size[FWL_GRIDSIZE_MinHeight].fLength = 0;
- m_Size[FWL_GRIDSIZE_MaxHeight].eUnit = FWL_GRIDUNIT_Infinity;
- m_Size[FWL_GRIDSIZE_MaxHeight].fLength = 0;
-}
-CFWL_GridImp::~CFWL_GridImp() {
- int32_t iCount = m_Columns.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- delete static_cast<CFWL_GridColRow*>(m_Columns[i]);
- }
- m_Columns.RemoveAll();
- iCount = m_Rows.GetSize();
- for (int32_t j = 0; j < iCount; j++) {
- delete static_cast<CFWL_GridColRow*>(m_Rows[j]);
- }
- m_Rows.RemoveAll();
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget* pWidget;
- CFWL_GridWidgetInfo* pInfo;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- delete pInfo;
- }
- m_mapWidgetInfo.RemoveAll();
- delete m_pDelegate;
- m_pDelegate = nullptr;
-}
-FWL_ERR CFWL_GridImp::GetClassName(CFX_WideString& wsClass) const {
- wsClass = FWL_CLASS_Grid;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_GridImp::GetClassID() const {
- return FWL_CLASSHASH_Grid;
-}
-FWL_ERR CFWL_GridImp::Initialize() {
- if (CFWL_ContentImp::Initialize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
- m_pDelegate = new CFWL_GridImpDelegate(this);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_GridImp::Finalize() {
- if (CFWL_ContentImp::Finalize() != FWL_ERR_Succeeded)
- return FWL_ERR_Indefinite;
- delete m_pDelegate;
- m_pDelegate = nullptr;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_GridImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
- if (bAutoSize) {
- rect.left = 0;
- rect.top = 0;
- rect.width = ProcessUnCertainColumns();
- rect.height = ProcessUnCertainRows();
- } else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_GridImp::SetWidgetRect(const CFX_RectF& rect) {
- CFWL_WidgetImp::SetWidgetRect(rect);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_GridImp::Update() {
- if (IsLocked()) {
- return FWL_ERR_Indefinite;
- }
- ProcessColumns(m_pProperties->m_rtWidget.width);
- ProcessRows(m_pProperties->m_rtWidget.height);
- SetAllWidgetsRect();
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_GridImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- if (!pGraphics)
- return FWL_ERR_Indefinite;
- if ((m_pProperties->m_dwStyleExes & FWL_GRIDSTYLEEXT_ShowGridLines) == 0) {
- return FWL_ERR_Succeeded;
- }
- pGraphics->SaveGraphState();
- if (pMatrix) {
- pGraphics->ConcatMatrix(pMatrix);
- }
- {
- FX_BOOL bDrawLine = FALSE;
- CFX_Path path;
- path.Create();
- int32_t iColumns = m_Columns.GetSize();
- for (int32_t i = 1; i < iColumns; i++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(m_Columns[i]);
- if (!pColRow) {
- continue;
- }
- bDrawLine = TRUE;
- path.AddLine(pColRow->m_fActualPos, 0, pColRow->m_fActualPos,
- m_pProperties->m_rtWidget.height);
- }
- int32_t iRows = m_Rows.GetSize();
- for (int32_t j = 1; j < iRows; j++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(m_Rows[j]);
- if (!pColRow) {
- continue;
- }
- bDrawLine = TRUE;
- path.AddLine(0, pColRow->m_fActualPos, m_pProperties->m_rtWidget.width,
- pColRow->m_fActualPos);
- }
- if (bDrawLine) {
- CFX_Color cr(0xFFFF0000);
- pGraphics->SetStrokeColor(&cr);
- pGraphics->StrokePath(&path);
- }
- }
- pGraphics->RestoreGraphState();
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_GridImp::InsertWidget(IFWL_Widget* pChild, int32_t nIndex) {
- if (!pChild)
- return FWL_ERR_Indefinite;
- CFWL_ContentImp::InsertWidget(pChild, nIndex);
- if (!m_mapWidgetInfo.GetValueAt(pChild)) {
- CFWL_GridWidgetInfo* pInfo = new CFWL_GridWidgetInfo;
- m_mapWidgetInfo.SetAt(pChild, pInfo);
- m_Widgets.Add(pChild);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_GridImp::RemoveWidget(IFWL_Widget* pWidget) {
- if (!pWidget)
- return FWL_ERR_Indefinite;
- CFWL_ContentImp::RemoveWidget(pWidget);
- if (CFWL_GridWidgetInfo* pInfo = static_cast<CFWL_GridWidgetInfo*>(
- m_mapWidgetInfo.GetValueAt(pWidget))) {
- m_mapWidgetInfo.RemoveKey(pWidget);
- delete pInfo;
- int32_t nIndex = m_Widgets.Find(pWidget);
- m_Widgets.RemoveAt(nIndex, 1);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_HGRIDCOLROW CFWL_GridImp::InsertColRow(FX_BOOL bColumn, int32_t nIndex) {
- if (bColumn) {
- if (nIndex < 0 || nIndex > m_Columns.GetSize()) {
- nIndex = m_Columns.GetSize();
- }
- CFWL_GridColRow* pColumn = new CFWL_GridColRow;
- m_Columns.InsertAt(nIndex, pColumn, 1);
- return (FWL_HGRIDCOLROW)pColumn;
- }
- if (nIndex < 0 || nIndex > m_Rows.GetSize()) {
- nIndex = m_Rows.GetSize();
- }
- CFWL_GridColRow* pRow = new CFWL_GridColRow;
- m_Rows.InsertAt(nIndex, pRow, 1);
- return (FWL_HGRIDCOLROW)pRow;
-}
-int32_t CFWL_GridImp::CountColRows(FX_BOOL bColumn) {
- if (bColumn) {
- return m_Columns.GetSize();
- }
- return m_Rows.GetSize();
-}
-FWL_HGRIDCOLROW CFWL_GridImp::GetColRow(FX_BOOL bColumn, int32_t nIndex) {
- if (bColumn) {
- if (nIndex < 0 || nIndex >= m_Columns.GetSize()) {
- return NULL;
- }
- return (FWL_HGRIDCOLROW)m_Columns[nIndex];
- }
- if (nIndex < 0 || nIndex >= m_Rows.GetSize()) {
- return NULL;
- }
- return (FWL_HGRIDCOLROW)m_Rows[nIndex];
-}
-int32_t CFWL_GridImp::GetIndex(FWL_HGRIDCOLROW hColRow) {
- if (IsColumn(hColRow)) {
- return m_Columns.Find(hColRow);
- }
- return m_Rows.Find(hColRow);
-}
-FX_FLOAT CFWL_GridImp::GetSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit) {
- if (!hColRow)
- return -1;
- CFWL_GridColRow* pColRow = reinterpret_cast<CFWL_GridColRow*>(hColRow);
- eUnit = pColRow->m_Size.eUnit;
- return pColRow->m_Size.fLength;
-}
-FWL_ERR CFWL_GridImp::SetSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit) {
- if (!hColRow)
- return FWL_ERR_Indefinite;
- CFWL_GridColRow* pColRow = reinterpret_cast<CFWL_GridColRow*>(hColRow);
- pColRow->m_Size.eUnit = eUnit;
- pColRow->m_Size.fLength = fSize;
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_GridImp::GetMinSize(FWL_HGRIDCOLROW hColRow,
- FWL_GRIDUNIT& eUnit) {
- if (!hColRow)
- return -1;
- CFWL_GridColRow* pColRow = reinterpret_cast<CFWL_GridColRow*>(hColRow);
- eUnit = pColRow->m_MinSize.eUnit;
- return pColRow->m_MinSize.fLength;
-}
-FWL_ERR CFWL_GridImp::SetMinSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit) {
- if (!hColRow)
- return FWL_ERR_Indefinite;
- CFWL_GridColRow* pColRow = reinterpret_cast<CFWL_GridColRow*>(hColRow);
- pColRow->m_MinSize.eUnit = eUnit;
- pColRow->m_MinSize.fLength = fSize;
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_GridImp::GetMaxSize(FWL_HGRIDCOLROW hColRow,
- FWL_GRIDUNIT& eUnit) {
- if (!hColRow)
- return -1;
- CFWL_GridColRow* pColRow = reinterpret_cast<CFWL_GridColRow*>(hColRow);
- eUnit = pColRow->m_MaxSize.eUnit;
- return pColRow->m_MaxSize.fLength;
-}
-FWL_ERR CFWL_GridImp::SetMaxSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit) {
- if (!hColRow)
- return FWL_ERR_Indefinite;
- CFWL_GridColRow* pColRow = reinterpret_cast<CFWL_GridColRow*>(hColRow);
- pColRow->m_MaxSize.eUnit = eUnit;
- pColRow->m_MaxSize.fLength = fSize;
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_GridImp::DeleteColRow(FWL_HGRIDCOLROW hColRow) {
- int32_t nIndex = m_Columns.Find(hColRow);
- if (nIndex >= 0) {
- m_Columns.RemoveAt(nIndex);
- delete reinterpret_cast<CFWL_GridColRow*>(hColRow);
- return TRUE;
- }
- nIndex = m_Rows.Find(hColRow);
- if (nIndex >= 0) {
- delete reinterpret_cast<CFWL_GridColRow*>(hColRow);
- m_Rows.RemoveAt(nIndex);
- return TRUE;
- }
- return FALSE;
-}
-FX_BOOL CFWL_GridImp::IsColumn(FWL_HGRIDCOLROW hColRow) {
- return m_Columns.Find(hColRow) != -1;
-}
-int32_t CFWL_GridImp::GetWidgetPos(IFWL_Widget* pWidget, FX_BOOL bColumn) {
- CFWL_GridWidgetInfo* pInfo =
- static_cast<CFWL_GridWidgetInfo*>(GetWidgetInfo(pWidget));
- if (pInfo) {
- return bColumn ? pInfo->m_iColumn : pInfo->m_iRow;
- }
- return -1;
-}
-FWL_ERR CFWL_GridImp::SetWidgetPos(IFWL_Widget* pWidget,
- int32_t iPos,
- FX_BOOL bColumn) {
- CFWL_GridWidgetInfo* pInfo =
- static_cast<CFWL_GridWidgetInfo*>(GetWidgetInfo(pWidget));
- if (pInfo) {
- bColumn ? pInfo->m_iColumn = iPos : pInfo->m_iRow = iPos;
- }
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_GridImp::GetWidgetSpan(IFWL_Widget* pWidget, FX_BOOL bColumn) {
- CFWL_GridWidgetInfo* pInfo =
- static_cast<CFWL_GridWidgetInfo*>(GetWidgetInfo(pWidget));
- if (pInfo) {
- return bColumn ? pInfo->m_iColumnSpan : pInfo->m_iRowSpan;
- }
- return 0;
-}
-FWL_ERR CFWL_GridImp::SetWidgetSpan(IFWL_Widget* pWidget,
- int32_t iSpan,
- FX_BOOL bColumn) {
- CFWL_GridWidgetInfo* pInfo =
- static_cast<CFWL_GridWidgetInfo*>(GetWidgetInfo(pWidget));
- if (pInfo) {
- bColumn ? pInfo->m_iColumnSpan = iSpan : pInfo->m_iRowSpan = iSpan;
- }
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_GridImp::GetWidgetSize(IFWL_Widget* pWidget,
- FWL_GRIDSIZE eSize,
- FWL_GRIDUNIT& eUnit) {
- CFWL_GridWidgetInfo* pInfo =
- static_cast<CFWL_GridWidgetInfo*>(GetWidgetInfo(pWidget));
- if (pInfo) {
- eUnit = pInfo->m_Size[eSize].eUnit;
- return pInfo->m_Size[eSize].fLength;
- }
- return 0;
-}
-FWL_ERR CFWL_GridImp::SetWidgetSize(IFWL_Widget* pWidget,
- FWL_GRIDSIZE eSize,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUit) {
- CFWL_GridWidgetInfo* pInfo =
- static_cast<CFWL_GridWidgetInfo*>(GetWidgetInfo(pWidget));
- if (pInfo) {
- pInfo->m_Size[eSize].fLength = fSize;
- pInfo->m_Size[eSize].eUnit = eUit;
- }
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_GridImp::GetWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin,
- FX_FLOAT& fMargin) {
- CFWL_GridWidgetInfo* pInfo =
- static_cast<CFWL_GridWidgetInfo*>(GetWidgetInfo(pWidget));
- if (pInfo) {
- fMargin = pInfo->m_Margin[eMargin];
- return (pInfo->m_dwMarginFlag & (1 << eMargin)) != 0;
- }
- return FALSE;
-}
-FWL_ERR CFWL_GridImp::SetWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin,
- FX_FLOAT fMargin) {
- CFWL_GridWidgetInfo* pInfo =
- static_cast<CFWL_GridWidgetInfo*>(GetWidgetInfo(pWidget));
- if (pInfo) {
- pInfo->m_Margin[eMargin] = fMargin;
- pInfo->m_dwMarginFlag |= (1 << eMargin);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_GridImp::RemoveWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin) {
- CFWL_GridWidgetInfo* pInfo =
- static_cast<CFWL_GridWidgetInfo*>(GetWidgetInfo(pWidget));
- if (pInfo) {
- pInfo->m_dwMarginFlag &= ~(1 << eMargin);
- }
- return FWL_ERR_Succeeded;
-}
-FX_FLOAT CFWL_GridImp::GetGridSize(FWL_GRIDSIZE eSize, FWL_GRIDUNIT& eUnit) {
- eUnit = m_Size[eSize].eUnit;
- return m_Size[eSize].fLength;
-}
-FWL_ERR CFWL_GridImp::SetGridSize(FWL_GRIDSIZE eSize,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUit) {
- m_Size[eSize].fLength = fSize;
- m_Size[eSize].eUnit = eUit;
- return FWL_ERR_Succeeded;
-}
-CFWL_GridWidgetInfo* CFWL_GridImp::GetWidgetInfo(IFWL_Widget* pWidget) {
- return static_cast<CFWL_GridWidgetInfo*>(m_mapWidgetInfo.GetValueAt(pWidget));
-}
-void CFWL_GridImp::ProcFixedColRow(CFWL_GridColRow* pColRow,
- int32_t nIndex,
- FX_FLOAT fColRowSize,
- FX_BOOL bColumn) {
- pColRow->m_fActualSize = fColRowSize;
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- void* key = nullptr;
- void* value = nullptr;
- m_mapWidgetInfo.GetNextAssoc(ps, key, value);
- IFWL_Widget* pWidget = static_cast<IFWL_Widget*>(key);
- CFWL_GridWidgetInfo* pInfo = static_cast<CFWL_GridWidgetInfo*>(value);
- if (bColumn) {
- if (pInfo->m_iColumn == nIndex && pInfo->m_iColumnSpan == 1) {
- CalcWidgetWidth(pWidget, pInfo, pColRow->m_fActualSize);
- }
- } else {
- if (pInfo->m_iRow == nIndex && pInfo->m_iRowSpan == 1) {
- CalcWidgetHeigt(pWidget, pInfo, pColRow->m_fActualSize);
- }
- }
- }
-}
-void CFWL_GridImp::ProcAutoColRow(CFWL_GridColRow* pColRow,
- int32_t nIndex,
- FX_BOOL bColumn) {
- if (!pColRow)
- return;
- FX_FLOAT fMaxSize = 0, fWidgetSize = 0;
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget* pWidget = NULL;
- CFWL_GridWidgetInfo* pInfo = NULL;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- if (!pWidget || !pInfo) {
- continue;
- }
- if (bColumn) {
- if (pInfo->m_iColumn != nIndex || pInfo->m_iColumnSpan != 1) {
- continue;
- }
- fWidgetSize = CalcAutoColumnWidgetWidth(pWidget, pInfo);
- if (fMaxSize < fWidgetSize) {
- fMaxSize = fWidgetSize;
- }
- } else {
- if (pInfo->m_iRow != nIndex || pInfo->m_iRowSpan != 1) {
- continue;
- }
- fWidgetSize = CalcAutoColumnWidgetHeight(pWidget, pInfo);
- if (fMaxSize < fWidgetSize) {
- fMaxSize = fWidgetSize;
- }
- }
- }
- SetColRowActualSize(pColRow, fMaxSize);
-}
-void CFWL_GridImp::ProcScaledColRow(CFWL_GridColRow* pColRow,
- int32_t nIndex,
- FX_FLOAT fColRowSize,
- FX_BOOL bColumn) {
- if (fColRowSize > 0) {
- ProcFixedColRow(pColRow, nIndex, fColRowSize, bColumn);
- }
-}
-void CFWL_GridImp::CalcWidgetWidth(IFWL_Widget* pWidget,
- CFWL_GridWidgetInfo* pInfo,
- FX_FLOAT fColunmWidth) {
- if (pInfo->m_Size[FWL_GRIDSIZE_Width].eUnit == FWL_GRIDUNIT_Fixed) {
- SetWidgetActualWidth(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Width].fLength);
- } else {
- FX_FLOAT fWidth = 0;
- FX_FLOAT fLeftMargin = 0, fRightMargin = 0;
- FX_BOOL bLeftMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Left, fLeftMargin);
- FX_BOOL bRightMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Right, fRightMargin);
- if (bLeftMargin && bRightMargin) {
- fWidth = fColunmWidth - fLeftMargin - fRightMargin;
- } else {
- CFX_RectF rtAuto;
- pWidget->GetWidgetRect(rtAuto, TRUE);
- fWidth = rtAuto.Width();
- }
- SetWidgetActualWidth(pInfo, fWidth);
- }
-}
-void CFWL_GridImp::CalcWidgetHeigt(IFWL_Widget* pWidget,
- CFWL_GridWidgetInfo* pInfo,
- FX_FLOAT fRowHeigt) {
- if (pInfo->m_Size[FWL_GRIDSIZE_Height].eUnit == FWL_GRIDUNIT_Fixed) {
- SetWidgetActualHeight(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Height].fLength);
- } else {
- FX_FLOAT fHeight = 0;
- FX_FLOAT fTopMargin = 0, fBottomMargin = 0;
- FX_BOOL bTopMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Top, fTopMargin);
- FX_BOOL bBottomMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Bottom, fBottomMargin);
- if (bTopMargin && bBottomMargin) {
- fHeight = fRowHeigt - fTopMargin - fBottomMargin;
- } else {
- CFX_RectF rtAuto;
- pWidget->GetWidgetRect(rtAuto, TRUE);
- fHeight = rtAuto.Height();
- }
- SetWidgetActualHeight(pInfo, fHeight);
- }
-}
-FX_FLOAT CFWL_GridImp::CalcAutoColumnWidgetWidth(IFWL_Widget* pWidget,
- CFWL_GridWidgetInfo* pInfo) {
- FX_FLOAT fLeftMargin = 0, fRightMargin = 0;
- FX_BOOL bLeftMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Left, fLeftMargin);
- FX_BOOL bRightMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Right, fRightMargin);
- if (pInfo->m_Size[FWL_GRIDSIZE_Width].eUnit == FWL_GRIDUNIT_Fixed) {
- SetWidgetActualWidth(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Width].fLength);
- } else {
- CFX_RectF rtAuto;
- pWidget->GetWidgetRect(rtAuto, TRUE);
- FX_FLOAT fWidth = rtAuto.width;
- SetWidgetActualWidth(pInfo, fWidth);
- }
- FX_FLOAT fTotal = pInfo->m_fActualWidth;
- if (bLeftMargin) {
- fTotal += fLeftMargin;
- }
- if (bRightMargin) {
- fTotal += fRightMargin;
- }
- return fTotal;
-}
-FX_FLOAT CFWL_GridImp::CalcAutoColumnWidgetHeight(IFWL_Widget* pWidget,
- CFWL_GridWidgetInfo* pInfo) {
- FX_FLOAT fTopMargin = 0, fBottomMargin = 0;
- FX_BOOL bTopMargin = GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Top, fTopMargin);
- FX_BOOL bBottomMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Bottom, fBottomMargin);
- if (pInfo->m_Size[FWL_GRIDSIZE_Height].eUnit == FWL_GRIDUNIT_Fixed) {
- SetWidgetActualHeight(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Height].fLength);
- } else {
- CFX_RectF rtAuto;
- pWidget->GetWidgetRect(rtAuto, TRUE);
- FX_FLOAT fHeight = rtAuto.height;
- SetWidgetActualHeight(pInfo, fHeight);
- }
- FX_FLOAT fTotal = pInfo->m_fActualHeight;
- if (bTopMargin) {
- fTotal += fTopMargin;
- }
- if (bBottomMargin) {
- fTotal += fBottomMargin;
- }
- return fTotal;
-}
-FX_FLOAT CFWL_GridImp::ProcessColumns(FX_FLOAT fWidth) {
- if (fWidth <= 0) {
- return ProcessUnCertainColumns();
- }
- int32_t iColumns = m_Columns.GetSize();
- if (iColumns < 1) {
- return fWidth;
- }
- FX_FLOAT fFixedWidth = 0;
- FX_FLOAT fAutoWidth = 0;
- CFX_PtrArray autoColumns;
- CFX_PtrArray scaledColumns;
- FX_FLOAT fScaledColumnNum = 0;
- for (int32_t i = 0; i < iColumns; i++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(m_Columns[i]);
- if (!pColRow) {
- continue;
- }
- switch (pColRow->m_Size.eUnit) {
- case FWL_GRIDUNIT_Fixed: {
- SetColRowActualSize(pColRow, pColRow->m_Size.fLength);
- fFixedWidth += pColRow->m_fActualSize;
- break;
- }
- case FWL_GRIDUNIT_Auto: {
- ProcAutoColRow(pColRow, i, TRUE);
- autoColumns.Add(pColRow);
- break;
- }
- case FWL_GRIDUNIT_Scaled:
- default: {
- fScaledColumnNum += pColRow->m_Size.fLength;
- scaledColumns.Add(pColRow);
- SetColRowActualSize(pColRow, 0);
- }
- }
- }
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget* pWidget = NULL;
- CFWL_GridWidgetInfo* pInfo = NULL;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- if (!pInfo || pInfo->m_iColumnSpan < 2) {
- continue;
- }
- CFX_PtrArray spanAutoColumns;
- FX_FLOAT fSpanSize = 0;
- int32_t iAutoColRows = 0;
- int32_t iScaledColRows = 0;
- for (int32_t i = 0; i < pInfo->m_iColumnSpan; i++) {
- CFWL_GridColRow* pColumn = reinterpret_cast<CFWL_GridColRow*>(
- GetColRow(TRUE, pInfo->m_iColumn + i));
- if (!pColumn) {
- break;
- }
- fSpanSize += pColumn->m_fActualSize;
- if (pColumn->m_Size.eUnit == FWL_GRIDUNIT_Auto) {
- iAutoColRows++;
- spanAutoColumns.Add(pColumn);
- } else if (pColumn->m_Size.eUnit == FWL_GRIDUNIT_Scaled) {
- iScaledColRows++;
- }
- }
- if (iAutoColRows < 1) {
- continue;
- }
- FX_FLOAT fWidgetWidth = CalcAutoColumnWidgetWidth(pWidget, pInfo);
- if (fWidgetWidth > fSpanSize) {
- if (iScaledColRows > 0) {
- } else {
- SetSpanAutoColRowSize(spanAutoColumns, fWidgetWidth - fSpanSize);
- }
- }
- }
- int32_t iAutoCols = autoColumns.GetSize();
- for (int32_t k = 0; k < iAutoCols; k++) {
- fAutoWidth += static_cast<CFWL_GridColRow*>(autoColumns[k])->m_fActualSize;
- }
- FX_FLOAT fScaledWidth = fWidth - fFixedWidth - fAutoWidth;
- if (fScaledWidth > 0 && fScaledColumnNum > 0) {
- SetScaledColRowsSize(scaledColumns, fScaledWidth, fScaledColumnNum);
- }
- return fWidth;
-}
-FX_FLOAT CFWL_GridImp::ProcessRows(FX_FLOAT fHeight) {
- if (fHeight <= 0) {
- return ProcessUnCertainRows();
- }
- int32_t iRows = m_Rows.GetSize();
- if (iRows < 1) {
- return fHeight;
- }
- FX_FLOAT fFixedHeight = 0;
- FX_FLOAT fAutoHeigt = 0;
- CFX_PtrArray autoRows;
- CFX_PtrArray scaledRows;
- FX_FLOAT fScaledRowNum = 0;
- for (int32_t i = 0; i < iRows; i++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(m_Rows[i]);
- if (!pColRow) {
- continue;
- }
- switch (pColRow->m_Size.eUnit) {
- case FWL_GRIDUNIT_Fixed: {
- SetColRowActualSize(pColRow, pColRow->m_Size.fLength);
- fFixedHeight += pColRow->m_fActualSize;
- break;
- }
- case FWL_GRIDUNIT_Auto: {
- ProcAutoColRow(pColRow, i, FALSE);
- autoRows.Add(pColRow);
- break;
- }
- case FWL_GRIDUNIT_Scaled:
- default: {
- fScaledRowNum += pColRow->m_Size.fLength;
- scaledRows.Add(pColRow);
- SetColRowActualSize(pColRow, 0);
- break;
- }
- }
- }
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget* pWidget = NULL;
- CFWL_GridWidgetInfo* pInfo = NULL;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- if (!pInfo || pInfo->m_iRowSpan < 2) {
- continue;
- }
- CFX_PtrArray spanAutoRows;
- FX_FLOAT fSpanSize = 0;
- int32_t iAutoColRows = 0;
- int32_t iScaledColRows = 0;
- for (int32_t i = 0; i < pInfo->m_iRowSpan; i++) {
- CFWL_GridColRow* pRow = reinterpret_cast<CFWL_GridColRow*>(
- GetColRow(FALSE, pInfo->m_iRow + i));
- if (!pRow) {
- break;
- }
- fSpanSize += pRow->m_fActualSize;
- if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Auto) {
- iAutoColRows++;
- spanAutoRows.Add(pRow);
- } else if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Scaled) {
- iScaledColRows++;
- }
- }
- if (iAutoColRows < 1) {
- continue;
- }
- FX_FLOAT fWidgetHeight = CalcAutoColumnWidgetHeight(pWidget, pInfo);
- if (fWidgetHeight > fSpanSize) {
- if (iScaledColRows > 0) {
- } else {
- SetSpanAutoColRowSize(spanAutoRows, fWidgetHeight - fSpanSize);
- }
- }
- }
- int32_t iAutoRows = autoRows.GetSize();
- for (int32_t k = 0; k < iAutoRows; k++) {
- fAutoHeigt +=
- reinterpret_cast<CFWL_GridColRow*>(autoRows[k])->m_fActualSize;
- }
- FX_FLOAT fScaledHeight = fHeight - fFixedHeight - fAutoHeigt;
- if (fScaledHeight > 0 && fScaledRowNum > 0) {
- SetScaledColRowsSize(scaledRows, fScaledHeight, fScaledRowNum);
- }
- return fHeight;
-}
-FX_FLOAT CFWL_GridImp::ProcessUnCertainColumns() {
- int32_t iColumns = m_Columns.GetSize();
- if (iColumns < 1) {
- CFWL_GridColRow* pColRow = new CFWL_GridColRow;
- pColRow->m_Size.eUnit = FWL_GRIDUNIT_Auto;
- ProcAutoColRow(pColRow, 0, TRUE);
- FX_FLOAT fWidth = pColRow->m_fActualSize;
- delete pColRow;
- return fWidth;
- }
- FX_FLOAT fFixedWidth = 0;
- CFX_PtrArray autoColumns;
- CFX_PtrArray scaledColumns;
- FX_FLOAT fScaledColumnNum = 0;
- FX_FLOAT fScaledMaxPerWidth = 0;
- for (int32_t i = 0; i < iColumns; i++) {
- CFWL_GridColRow* pColRow = reinterpret_cast<CFWL_GridColRow*>(m_Columns[i]);
- if (!pColRow) {
- continue;
- }
- switch (pColRow->m_Size.eUnit) {
- case FWL_GRIDUNIT_Fixed: {
- SetColRowActualSize(pColRow, pColRow->m_Size.fLength);
- fFixedWidth += pColRow->m_fActualSize;
- break;
- }
- case FWL_GRIDUNIT_Auto: {
- ProcAutoColRow(pColRow, i, TRUE);
- autoColumns.Add(pColRow);
- break;
- }
- case FWL_GRIDUNIT_Scaled:
- default: {
- ProcAutoColRow(pColRow, i, TRUE);
- fScaledColumnNum += pColRow->m_Size.fLength;
- scaledColumns.Add(pColRow);
- if (pColRow->m_Size.fLength <= 0) {
- break;
- }
- FX_FLOAT fPerWidth = pColRow->m_fActualSize / pColRow->m_Size.fLength;
- if (fPerWidth > fScaledMaxPerWidth) {
- fScaledMaxPerWidth = fPerWidth;
- }
- }
- }
- }
- iColumns = scaledColumns.GetSize();
- for (int32_t j = 0; j < iColumns; j++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(scaledColumns[j]);
- if (!pColRow) {
- continue;
- }
- SetColRowActualSize(pColRow, fScaledMaxPerWidth * pColRow->m_Size.fLength);
- }
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget* pWidget = NULL;
- CFWL_GridWidgetInfo* pInfo = NULL;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- if (!pInfo || pInfo->m_iColumnSpan < 2) {
- continue;
- }
- CFX_PtrArray spanAutoColumns;
- CFX_PtrArray spanScaledColumns;
- FX_FLOAT fSpanSize = 0;
- FX_FLOAT fScaledSum = 0;
- int32_t iAutoColRows = 0;
- int32_t iScaledColRows = 0;
- for (int32_t i = 0; i < pInfo->m_iColumnSpan; i++) {
- CFWL_GridColRow* pColumn = reinterpret_cast<CFWL_GridColRow*>(
- GetColRow(TRUE, pInfo->m_iColumn + i));
- if (!pColumn) {
- break;
- }
- fSpanSize += pColumn->m_fActualSize;
- if (pColumn->m_Size.eUnit == FWL_GRIDUNIT_Auto) {
- iAutoColRows++;
- spanAutoColumns.Add(pColumn);
- } else if (pColumn->m_Size.eUnit == FWL_GRIDUNIT_Scaled) {
- iScaledColRows++;
- fScaledSum += pColumn->m_Size.fLength;
- spanScaledColumns.Add(pColumn);
- }
- }
- if (iAutoColRows < 1 && iScaledColRows < 1) {
- continue;
- }
- FX_FLOAT fWidgetWidth = CalcAutoColumnWidgetWidth(pWidget, pInfo);
- if (fWidgetWidth > fSpanSize) {
- if (iScaledColRows > 0) {
- if (fScaledSum <= 0) {
- continue;
- }
- SetSpanScaledColRowSize(spanScaledColumns, fWidgetWidth - fSpanSize,
- fScaledSum);
- } else {
- SetSpanAutoColRowSize(spanAutoColumns, fWidgetWidth - fSpanSize);
- }
- }
- }
- FX_FLOAT fAutoWidth = 0;
- int32_t iAutoCols = autoColumns.GetSize();
- for (int32_t m = 0; m < iAutoCols; m++) {
- fAutoWidth += static_cast<CFWL_GridColRow*>(autoColumns[m])->m_fActualSize;
- }
- FX_FLOAT fScaledWidth = 0;
- iColumns = scaledColumns.GetSize();
- for (int32_t n = 0; n < iColumns; n++) {
- fScaledWidth +=
- static_cast<CFWL_GridColRow*>(scaledColumns[n])->m_fActualSize;
- }
- return fFixedWidth + fAutoWidth + fScaledWidth;
-}
-FX_FLOAT CFWL_GridImp::ProcessUnCertainRows() {
- int32_t iRows = m_Rows.GetSize();
- if (iRows < 1) {
- CFWL_GridColRow* pColRow = new CFWL_GridColRow;
- pColRow->m_Size.eUnit = FWL_GRIDUNIT_Auto;
- ProcAutoColRow(pColRow, 0, FALSE);
- FX_FLOAT fWidth = pColRow->m_fActualSize;
- delete pColRow;
- return fWidth;
- }
- FX_FLOAT fFixedHeight = 0;
- CFX_PtrArray autoRows;
- CFX_PtrArray scaledRows;
- FX_FLOAT fScaledRowNum = 0;
- FX_FLOAT fScaledMaxPerHeight = 0;
- for (int32_t i = 0; i < iRows; i++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(m_Rows[i]);
- if (!pColRow) {
- continue;
- }
- switch (pColRow->m_Size.eUnit) {
- case FWL_GRIDUNIT_Fixed: {
- SetColRowActualSize(pColRow, pColRow->m_Size.fLength);
- fFixedHeight += pColRow->m_fActualSize;
- break;
- }
- case FWL_GRIDUNIT_Auto: {
- ProcAutoColRow(pColRow, i, FALSE);
- autoRows.Add(pColRow);
- break;
- }
- case FWL_GRIDUNIT_Scaled:
- default: {
- ProcAutoColRow(pColRow, i, FALSE);
- fScaledRowNum += pColRow->m_Size.fLength;
- scaledRows.Add(pColRow);
- if (pColRow->m_Size.fLength > 0) {
- FX_FLOAT fPerHeight =
- pColRow->m_fActualSize / pColRow->m_Size.fLength;
- if (fPerHeight > fScaledMaxPerHeight) {
- fScaledMaxPerHeight = fPerHeight;
- }
- }
- break;
- }
- }
- }
- iRows = scaledRows.GetSize();
- for (int32_t j = 0; j < iRows; j++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(scaledRows[j]);
- if (!pColRow) {
- continue;
- }
- SetColRowActualSize(pColRow, fScaledMaxPerHeight * pColRow->m_Size.fLength);
- }
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- void* key = nullptr;
- void* value = nullptr;
- m_mapWidgetInfo.GetNextAssoc(ps, key, value);
- IFWL_Widget* pWidget = static_cast<IFWL_Widget*>(key);
- CFWL_GridWidgetInfo* pInfo = static_cast<CFWL_GridWidgetInfo*>(value);
- if (pInfo->m_iRowSpan < 2) {
- continue;
- }
- CFX_PtrArray spanAutoRows;
- CFX_PtrArray spanScaledRows;
- FX_FLOAT fSpanSize = 0;
- FX_FLOAT fScaledSum = 0;
- int32_t iAutoColRows = 0;
- int32_t iScaledColRows = 0;
- for (int32_t i = 0; i < pInfo->m_iRowSpan; i++) {
- CFWL_GridColRow* pRow = reinterpret_cast<CFWL_GridColRow*>(
- GetColRow(FALSE, pInfo->m_iRow + i));
- if (!pRow) {
- break;
- }
- fSpanSize += pRow->m_fActualSize;
- if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Auto) {
- iAutoColRows++;
- spanAutoRows.Add(pRow);
- } else if (pRow->m_Size.eUnit == FWL_GRIDUNIT_Scaled) {
- iScaledColRows++;
- fScaledSum += pRow->m_Size.fLength;
- spanScaledRows.Add(pRow);
- }
- }
- if (iAutoColRows < 1 && iScaledColRows < 1) {
- continue;
- }
- FX_FLOAT fWidgetHeight = CalcAutoColumnWidgetHeight(pWidget, pInfo);
- if (fWidgetHeight > fSpanSize) {
- if (iScaledColRows > 0) {
- if (fScaledSum <= 0) {
- continue;
- }
- SetSpanScaledColRowSize(spanScaledRows, fWidgetHeight - fSpanSize,
- fScaledSum);
- } else {
- SetSpanAutoColRowSize(spanAutoRows, fWidgetHeight - fSpanSize);
- }
- }
- }
- FX_FLOAT fAutoHeigt = 0;
- int32_t iAutoRows = autoRows.GetSize();
- for (int32_t m = 0; m < iAutoRows; m++) {
- fAutoHeigt += static_cast<CFWL_GridColRow*>(autoRows[m])->m_fActualSize;
- }
- FX_FLOAT fScaledHeight = 0;
- iRows = scaledRows.GetSize();
- for (int32_t n = 0; n < iRows; n++) {
- fScaledHeight +=
- static_cast<CFWL_GridColRow*>(scaledRows[n])->m_fActualSize;
- }
- return fFixedHeight + fAutoHeigt + fScaledHeight;
-}
-FX_BOOL CFWL_GridImp::SetColRowActualSize(CFWL_GridColRow* pColRow,
- FX_FLOAT fSize,
- FX_BOOL bSetBeyond) {
- if (pColRow->m_MinSize.eUnit == FWL_GRIDUNIT_Fixed &&
- fSize < pColRow->m_MinSize.fLength) {
- pColRow->m_fActualSize = pColRow->m_MinSize.fLength;
- return FALSE;
- }
- if (pColRow->m_MaxSize.eUnit == FWL_GRIDUNIT_Fixed &&
- fSize > pColRow->m_MaxSize.fLength) {
- pColRow->m_fActualSize = pColRow->m_MaxSize.fLength;
- return FALSE;
- }
- if (bSetBeyond) {
- return TRUE;
- }
- pColRow->m_fActualSize = fSize;
- return TRUE;
-}
-FX_FLOAT CFWL_GridImp::SetWidgetActualWidth(CFWL_GridWidgetInfo* pInfo,
- FX_FLOAT fWidth) {
- if (pInfo->m_Size[FWL_GRIDSIZE_MinWidth].eUnit == FWL_GRIDUNIT_Fixed &&
- fWidth < pInfo->m_Size[FWL_GRIDSIZE_MinWidth].fLength) {
- fWidth = pInfo->m_Size[FWL_GRIDSIZE_MinWidth].fLength;
- }
- if (pInfo->m_Size[FWL_GRIDSIZE_MaxWidth].eUnit == FWL_GRIDUNIT_Fixed &&
- fWidth > pInfo->m_Size[FWL_GRIDSIZE_MaxWidth].fLength) {
- fWidth = pInfo->m_Size[FWL_GRIDSIZE_MaxWidth].fLength;
- }
- pInfo->m_fActualWidth = fWidth;
- return fWidth;
-}
-FX_FLOAT CFWL_GridImp::SetWidgetActualHeight(CFWL_GridWidgetInfo* pInfo,
- FX_FLOAT fHeight) {
- if (pInfo->m_Size[FWL_GRIDSIZE_MinHeight].eUnit == FWL_GRIDUNIT_Fixed &&
- fHeight < pInfo->m_Size[FWL_GRIDSIZE_MinHeight].fLength) {
- fHeight = pInfo->m_Size[FWL_GRIDSIZE_MinHeight].fLength;
- }
- if (pInfo->m_Size[FWL_GRIDSIZE_MaxHeight].eUnit == FWL_GRIDUNIT_Fixed &&
- fHeight > pInfo->m_Size[FWL_GRIDSIZE_MaxHeight].fLength) {
- fHeight = pInfo->m_Size[FWL_GRIDSIZE_MaxHeight].fLength;
- }
- pInfo->m_fActualHeight = fHeight;
- return fHeight;
-}
-void CFWL_GridImp::SetAllWidgetsRect() {
- FX_FLOAT fStartLeft = 0;
- int32_t iColumns = m_Columns.GetSize();
- for (int32_t i = 0; i < iColumns; i++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(m_Columns[i]);
- if (!pColRow) {
- continue;
- }
- pColRow->m_fActualPos = fStartLeft;
- fStartLeft += pColRow->m_fActualSize;
- }
- FX_FLOAT fStartTop = 0;
- int32_t iRows = m_Rows.GetSize();
- for (int32_t j = 0; j < iRows; j++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(m_Rows[j]);
- if (!pColRow) {
- continue;
- }
- pColRow->m_fActualPos = fStartTop;
- fStartTop += pColRow->m_fActualSize;
- }
- FX_POSITION ps = m_mapWidgetInfo.GetStartPosition();
- while (ps) {
- IFWL_Widget* pWidget = NULL;
- CFWL_GridWidgetInfo* pInfo = NULL;
- m_mapWidgetInfo.GetNextAssoc(ps, (void*&)pWidget, (void*&)pInfo);
- if (!pWidget || !pInfo) {
- continue;
- }
- FX_FLOAT fColumnStart = 0;
- CFWL_GridColRow* pColumn =
- reinterpret_cast<CFWL_GridColRow*>(GetColRow(TRUE, pInfo->m_iColumn));
- if (pColumn) {
- fColumnStart = pColumn->m_fActualPos;
- }
- FX_FLOAT fRowStart = 0;
- CFWL_GridColRow* pRow =
- reinterpret_cast<CFWL_GridColRow*>(GetColRow(FALSE, pInfo->m_iRow));
- if (pRow) {
- fRowStart = pRow->m_fActualPos;
- }
- FX_FLOAT fColumnWidth = 0;
- if (iColumns > 0) {
- for (int32_t j = 0; j < pInfo->m_iColumnSpan; j++) {
- CFWL_GridColRow* pCol = reinterpret_cast<CFWL_GridColRow*>(
- GetColRow(TRUE, pInfo->m_iColumn + j));
- if (!pCol) {
- break;
- }
- fColumnWidth += pCol->m_fActualSize;
- }
- } else {
- fColumnWidth = m_pProperties->m_rtWidget.width;
- }
- FX_FLOAT fRowHeight = 0;
- if (iRows > 0) {
- for (int32_t k = 0; k < pInfo->m_iRowSpan; k++) {
- CFWL_GridColRow* pR = reinterpret_cast<CFWL_GridColRow*>(
- GetColRow(FALSE, pInfo->m_iRow + k));
- if (!pR) {
- break;
- }
- fRowHeight += pR->m_fActualSize;
- }
- } else {
- fRowHeight = m_pProperties->m_rtWidget.height;
- }
- FX_FLOAT fLeftMargin = 0, fRightMargin = 0;
- FX_BOOL bLeftMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Left, fLeftMargin);
- FX_BOOL bRightMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Right, fRightMargin);
- FX_FLOAT fTopMargin = 0, fBottomMargin = 0;
- FX_BOOL bTopMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Top, fTopMargin);
- FX_BOOL bBottomMargin =
- GetWidgetMargin(pWidget, FWL_GRIDMARGIN_Bottom, fBottomMargin);
- if (pInfo->m_Size[FWL_GRIDSIZE_Width].eUnit == FWL_GRIDUNIT_Fixed) {
- SetWidgetActualWidth(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Width].fLength);
- } else {
- if (bLeftMargin && bRightMargin) {
- SetWidgetActualWidth(pInfo, fColumnWidth - fLeftMargin - fRightMargin);
- } else {
- CFX_RectF rtAuto;
- pWidget->GetWidgetRect(rtAuto, TRUE);
- SetWidgetActualWidth(pInfo, rtAuto.width);
- }
- }
- if (pInfo->m_Size[FWL_GRIDSIZE_Height].eUnit == FWL_GRIDUNIT_Fixed) {
- SetWidgetActualHeight(pInfo, pInfo->m_Size[FWL_GRIDSIZE_Height].fLength);
- } else {
- if (bTopMargin && bBottomMargin) {
- SetWidgetActualHeight(pInfo, fRowHeight - fTopMargin - fBottomMargin);
- } else {
- CFX_RectF rtAuto;
- pWidget->GetWidgetRect(rtAuto, TRUE);
- SetWidgetActualHeight(pInfo, rtAuto.height);
- }
- }
- if (bLeftMargin && bRightMargin &&
- pInfo->m_Size[FWL_GRIDSIZE_Width].eUnit == FWL_GRIDUNIT_Fixed) {
- fLeftMargin =
- fColumnStart + fLeftMargin +
- (fColumnWidth - fLeftMargin - fRightMargin - pInfo->m_fActualWidth) /
- 2;
- } else if (bLeftMargin) {
- fLeftMargin = fColumnStart + fLeftMargin;
- } else if (bRightMargin) {
- fLeftMargin =
- fColumnStart + fColumnWidth - fRightMargin - pInfo->m_fActualWidth;
- } else {
- fLeftMargin = fColumnStart;
- }
- if (bTopMargin && bBottomMargin &&
- pInfo->m_Size[FWL_GRIDSIZE_Height].eUnit == FWL_GRIDUNIT_Fixed) {
- fTopMargin =
- fRowStart + fTopMargin +
- (fRowHeight - fTopMargin - fBottomMargin - pInfo->m_fActualHeight) /
- 2;
- } else if (bTopMargin) {
- fTopMargin = fRowStart + fTopMargin;
- } else if (bBottomMargin) {
- fTopMargin =
- fRowStart + fRowHeight - fBottomMargin - pInfo->m_fActualHeight;
- } else {
- fTopMargin = fRowStart;
- }
- CFX_RectF rtWidget, rtOld;
- rtWidget.Set(fLeftMargin, fTopMargin, pInfo->m_fActualWidth,
- pInfo->m_fActualHeight);
- pWidget->GetWidgetRect(rtOld);
- if (rtWidget == rtOld) {
- continue;
- }
- pWidget->SetWidgetRect(rtWidget);
- if (rtWidget.width == rtOld.width && rtWidget.height == rtOld.height) {
- continue;
- }
- pWidget->Update();
- }
-}
-FX_BOOL CFWL_GridImp::IsGrid(IFWL_Widget* pWidget) {
- if (!pWidget)
- return FALSE;
- return pWidget->GetClassID() == FWL_CLASSHASH_Grid;
-}
-void CFWL_GridImp::SetSpanAutoColRowSize(const CFX_PtrArray& spanAutos,
- FX_FLOAT fTotalSize) {
- int32_t iAutoColRows = spanAutos.GetSize();
- if (iAutoColRows < 1) {
- return;
- }
- CFX_PtrArray autoNoMinMaxs;
- FX_FLOAT fAutoPer = fTotalSize / iAutoColRows;
- for (int32_t j = 0; j < iAutoColRows; j++) {
- CFWL_GridColRow* pColumn = static_cast<CFWL_GridColRow*>(spanAutos[j]);
- FX_FLOAT fOrgSize = pColumn->m_fActualSize;
- if (SetColRowActualSize(pColumn, pColumn->m_fActualSize + fAutoPer, TRUE)) {
- autoNoMinMaxs.Add(pColumn);
- } else {
- fTotalSize -= pColumn->m_fActualSize - fOrgSize;
- int32_t iNoMinMax = iAutoColRows - (j + 1 - autoNoMinMaxs.GetSize());
- if (iNoMinMax > 0 && fTotalSize > 0) {
- fAutoPer = fTotalSize / iNoMinMax;
- } else {
- break;
- }
- }
- }
- int32_t iNormals = autoNoMinMaxs.GetSize();
- if (fTotalSize > 0) {
- if (iNormals == iAutoColRows) {
- fAutoPer = fTotalSize / iNormals;
- for (int32_t k = 0; k < iNormals; k++) {
- CFWL_GridColRow* pColumn =
- static_cast<CFWL_GridColRow*>(autoNoMinMaxs[k]);
- pColumn->m_fActualSize += fAutoPer;
- }
- } else {
- SetSpanAutoColRowSize(autoNoMinMaxs, fTotalSize);
- }
- } else {
- }
-}
-void CFWL_GridImp::SetSpanScaledColRowSize(const CFX_PtrArray& spanScaleds,
- FX_FLOAT fTotalSize,
- FX_FLOAT fTotalScaledNum) {
- int32_t iScaledColRows = spanScaleds.GetSize();
- if (iScaledColRows < 1) {
- return;
- }
- CFX_PtrArray autoNoMinMaxs;
- FX_FLOAT fPerSize = fTotalSize / fTotalScaledNum;
- for (int32_t i = 0; i < iScaledColRows; i++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(spanScaleds[i]);
- if (SetColRowActualSize(pColRow, pColRow->m_fActualSize +
- fPerSize * pColRow->m_Size.fLength,
- TRUE)) {
- autoNoMinMaxs.Add(pColRow);
- } else {
- fTotalSize -= pColRow->m_fActualSize;
- fTotalScaledNum -= pColRow->m_Size.fLength;
- int32_t iNoMinMax = iScaledColRows - (i + 1 - autoNoMinMaxs.GetSize());
- if (iNoMinMax > 0 && fTotalSize > 0) {
- fPerSize = fTotalSize / fTotalScaledNum;
- } else {
- break;
- }
- }
- }
- int32_t iNormals = autoNoMinMaxs.GetSize();
- if (fTotalSize > 0) {
- if (iNormals == iScaledColRows) {
- fPerSize = fTotalSize / fTotalScaledNum;
- for (int32_t j = 0; j < iNormals; j++) {
- CFWL_GridColRow* pColumn =
- static_cast<CFWL_GridColRow*>(autoNoMinMaxs[j]);
- pColumn->m_fActualSize += fPerSize * pColumn->m_Size.fLength;
- }
- } else {
- SetSpanScaledColRowSize(autoNoMinMaxs, fTotalSize, fTotalScaledNum);
- }
- } else {
- }
-}
-void CFWL_GridImp::SetScaledColRowsSize(const CFX_PtrArray& spanScaleds,
- FX_FLOAT fTotalSize,
- FX_FLOAT fTotalScaledNum) {
- int32_t iScaledColRows = spanScaleds.GetSize();
- if (iScaledColRows < 1) {
- return;
- }
- CFX_PtrArray autoNoMinMaxs;
- FX_FLOAT fPerSize = fTotalSize / fTotalScaledNum;
- for (int32_t i = 0; i < iScaledColRows; i++) {
- CFWL_GridColRow* pColRow = static_cast<CFWL_GridColRow*>(spanScaleds[i]);
- if (!pColRow) {
- continue;
- }
- FX_FLOAT fSize = fPerSize * pColRow->m_Size.fLength;
- FX_FLOAT fOrgSize = pColRow->m_fActualSize;
- if (SetColRowActualSize(pColRow, fSize, TRUE)) {
- autoNoMinMaxs.Add(pColRow);
- } else {
- fTotalSize -= pColRow->m_fActualSize - fOrgSize;
- fTotalScaledNum -= pColRow->m_Size.fLength;
- int32_t iNoMinMax = iScaledColRows - (i + 1 - autoNoMinMaxs.GetSize());
- if (iNoMinMax > 0 && fTotalSize > 0) {
- fPerSize = fTotalSize / fTotalScaledNum;
- } else {
- break;
- }
- }
- }
- int32_t iNormals = autoNoMinMaxs.GetSize();
- if (fTotalSize > 0) {
- if (iNormals == iScaledColRows) {
- fPerSize = fTotalSize / fTotalScaledNum;
- for (int32_t i = 0; i < iNormals; i++) {
- CFWL_GridColRow* pColRow =
- static_cast<CFWL_GridColRow*>(autoNoMinMaxs[i]);
- if (!pColRow) {
- continue;
- }
- FX_FLOAT fSize = fPerSize * pColRow->m_Size.fLength;
- pColRow->m_fActualSize = fSize;
- }
- } else {
- SetScaledColRowsSize(autoNoMinMaxs, fTotalSize, fTotalScaledNum);
- }
- } else {
- }
-}
-CFWL_GridImpDelegate::CFWL_GridImpDelegate(CFWL_GridImp* pOwner)
- : m_pOwner(pOwner) {}
-int32_t CFWL_GridImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
- if (pMessage->GetClassID() != FWL_MSGHASH_Mouse) {
- return 0;
- }
- CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
- if (pMsg->m_dwCmd != FWL_MSGMOUSECMD_LButtonDown) {
- return 0;
- }
- return 1;
-}
-FWL_ERR CFWL_GridImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return m_pOwner->DrawWidget(pGraphics, pMatrix);
-}
diff --git a/xfa/src/fwl/core/fwl_gridimp.h b/xfa/src/fwl/core/fwl_gridimp.h
deleted file mode 100644
index 326b236295..0000000000
--- a/xfa/src/fwl/core/fwl_gridimp.h
+++ /dev/null
@@ -1,197 +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_SRC_FWL_CORE_FWL_GRIDIMP_H_
-#define XFA_SRC_FWL_CORE_FWL_GRIDIMP_H_
-
-#include "xfa/include/fwl/core/fwl_app.h"
-#include "xfa/include/fwl/core/fwl_content.h"
-#include "xfa/include/fwl/core/fwl_grid.h"
-#include "xfa/src/fwl/core/fwl_contentimp.h"
-
-class CFWL_GridLength {
- public:
- CFWL_GridLength() : fLength(0), eUnit(FWL_GRIDUNIT_Fixed) {}
- CFWL_GridLength(FX_FLOAT fValue, FWL_GRIDUNIT e)
- : fLength(fValue), eUnit(e) {}
- FX_FLOAT fLength;
- FWL_GRIDUNIT eUnit;
-};
-
-class CFWL_GridColRow {
- public:
- CFWL_GridColRow()
- : m_Size(1, FWL_GRIDUNIT_Scaled),
- m_MinSize(0, FWL_GRIDUNIT_Fixed),
- m_MaxSize(0, FWL_GRIDUNIT_Infinity),
- m_fActualSize(0),
- m_fActualPos(0) {}
- CFWL_GridLength m_Size;
- CFWL_GridLength m_MinSize;
- CFWL_GridLength m_MaxSize;
- FX_FLOAT m_fActualSize;
- FX_FLOAT m_fActualPos;
-};
-
-class CFWL_GridWidgetInfo {
- public:
- CFWL_GridWidgetInfo()
- : m_iColumn(0),
- m_iColumnSpan(1),
- m_iRow(0),
- m_iRowSpan(1),
- m_dwMarginFlag(0),
- m_fActualWidth(0),
- m_fActualHeight(0) {
- m_Size[FWL_GRIDSIZE_Width].eUnit = FWL_GRIDUNIT_Auto;
- m_Size[FWL_GRIDSIZE_Width].fLength = 0;
- m_Size[FWL_GRIDSIZE_Height].eUnit = FWL_GRIDUNIT_Auto;
- m_Size[FWL_GRIDSIZE_Height].fLength = 0;
- m_Size[FWL_GRIDSIZE_MinWidth].eUnit = FWL_GRIDUNIT_Fixed;
- m_Size[FWL_GRIDSIZE_MinWidth].fLength = 0;
- m_Size[FWL_GRIDSIZE_MaxWidth].eUnit = FWL_GRIDUNIT_Infinity;
- m_Size[FWL_GRIDSIZE_MaxWidth].fLength = 0;
- m_Size[FWL_GRIDSIZE_MinHeight].eUnit = FWL_GRIDUNIT_Fixed;
- m_Size[FWL_GRIDSIZE_MinHeight].fLength = 0;
- m_Size[FWL_GRIDSIZE_MaxHeight].eUnit = FWL_GRIDUNIT_Infinity;
- m_Size[FWL_GRIDSIZE_MaxHeight].fLength = 0;
- m_Margin[0] = m_Margin[1] = m_Margin[2] = m_Margin[3] = 0;
- }
- int32_t m_iColumn;
- int32_t m_iColumnSpan;
- int32_t m_iRow;
- int32_t m_iRowSpan;
- CFWL_GridLength m_Size[6];
- FX_DWORD m_dwMarginFlag;
- FX_FLOAT m_Margin[4];
- FX_FLOAT m_fActualWidth;
- FX_FLOAT m_fActualHeight;
-};
-
-class CFWL_GridImp : public CFWL_ContentImp {
- public:
- CFWL_GridImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter);
- virtual ~CFWL_GridImp();
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR SetWidgetRect(const CFX_RectF& rect);
- virtual FWL_ERR Update();
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
-
- virtual FWL_ERR InsertWidget(IFWL_Widget* pChild, int32_t nIndex = -1);
- virtual FWL_ERR RemoveWidget(IFWL_Widget* pWidget);
- virtual FWL_HGRIDCOLROW InsertColRow(FX_BOOL bColumn, int32_t nIndex = -1);
- virtual int32_t CountColRows(FX_BOOL bColumn);
- virtual FWL_HGRIDCOLROW GetColRow(FX_BOOL bColumn, int32_t nIndex);
- virtual int32_t GetIndex(FWL_HGRIDCOLROW hColRow);
- virtual FX_FLOAT GetSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit);
- virtual FWL_ERR SetSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit);
- FX_FLOAT GetMinSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit);
- FWL_ERR SetMinSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit);
- FX_FLOAT GetMaxSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit);
- FWL_ERR SetMaxSize(FWL_HGRIDCOLROW hColRow,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUnit);
- virtual FX_BOOL DeleteColRow(FWL_HGRIDCOLROW hColRow);
- virtual FX_BOOL IsColumn(FWL_HGRIDCOLROW hColRow);
- virtual int32_t GetWidgetPos(IFWL_Widget* pWidget, FX_BOOL bColumn);
- virtual FWL_ERR SetWidgetPos(IFWL_Widget* pWidget,
- int32_t iPos,
- FX_BOOL bColumn);
- virtual int32_t GetWidgetSpan(IFWL_Widget* pWidget, FX_BOOL bColumn);
- virtual FWL_ERR SetWidgetSpan(IFWL_Widget* pWidget,
- int32_t iSpan,
- FX_BOOL bColumn);
- virtual FX_FLOAT GetWidgetSize(IFWL_Widget* pWidget,
- FWL_GRIDSIZE eSize,
- FWL_GRIDUNIT& eUnit);
- virtual FWL_ERR SetWidgetSize(IFWL_Widget* pWidget,
- FWL_GRIDSIZE eSize,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUit);
- virtual FX_BOOL GetWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin,
- FX_FLOAT& fMargin);
- virtual FWL_ERR SetWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin,
- FX_FLOAT fMargin);
- virtual FWL_ERR RemoveWidgetMargin(IFWL_Widget* pWidget,
- FWL_GRIDMARGIN eMargin);
- virtual FX_FLOAT GetGridSize(FWL_GRIDSIZE eSize, FWL_GRIDUNIT& eUnit);
- virtual FWL_ERR SetGridSize(FWL_GRIDSIZE eSize,
- FX_FLOAT fSize,
- FWL_GRIDUNIT eUit);
-
- protected:
- CFWL_GridWidgetInfo* GetWidgetInfo(IFWL_Widget* pWidget);
- void ProcFixedColRow(CFWL_GridColRow* pColRow,
- int32_t nIndex,
- FX_FLOAT fColRowSize,
- FX_BOOL bColumn);
- void ProcAutoColRow(CFWL_GridColRow* pColRow,
- int32_t nIndex,
- FX_BOOL bColumn);
- void ProcScaledColRow(CFWL_GridColRow* pColRow,
- int32_t nIndex,
- FX_FLOAT fColRowSize,
- FX_BOOL bColumn);
- void CalcWidgetWidth(IFWL_Widget* pWidget,
- CFWL_GridWidgetInfo* pInfo,
- FX_FLOAT fColunmWidth);
- void CalcWidgetHeigt(IFWL_Widget* pWidget,
- CFWL_GridWidgetInfo* pInfo,
- FX_FLOAT fRowHeigt);
- FX_FLOAT CalcAutoColumnWidgetWidth(IFWL_Widget* pWidget,
- CFWL_GridWidgetInfo* pInfo);
- FX_FLOAT CalcAutoColumnWidgetHeight(IFWL_Widget* pWidget,
- CFWL_GridWidgetInfo* pInfo);
- FX_FLOAT ProcessColumns(FX_FLOAT fWidth);
- FX_FLOAT ProcessRows(FX_FLOAT fHeight);
- FX_FLOAT ProcessUnCertainColumns();
- FX_FLOAT ProcessUnCertainRows();
- FX_BOOL SetColRowActualSize(CFWL_GridColRow* pColRow,
- FX_FLOAT fSize,
- FX_BOOL bSetBeyond = FALSE);
- FX_FLOAT SetWidgetActualWidth(CFWL_GridWidgetInfo* pInfo, FX_FLOAT fWidth);
- FX_FLOAT SetWidgetActualHeight(CFWL_GridWidgetInfo* pInfo, FX_FLOAT fHeight);
- void SetAllWidgetsRect();
- FX_BOOL IsGrid(IFWL_Widget* pWidget);
- void SetSpanAutoColRowSize(const CFX_PtrArray& spanAutos,
- FX_FLOAT fTotalSize);
- void SetSpanScaledColRowSize(const CFX_PtrArray& spanScaleds,
- FX_FLOAT fTotalSize,
- FX_FLOAT fTotalScaledNum);
- void SetScaledColRowsSize(const CFX_PtrArray& spanScaleds,
- FX_FLOAT fTotalSize,
- FX_FLOAT fTotalScaledNum);
- CFX_PtrArray m_Rows;
- CFX_PtrArray m_Columns;
- CFX_PtrArray m_Widgets;
- CFX_MapPtrToPtr m_mapWidgetInfo;
- CFWL_GridLength m_Size[6];
- friend class CFWL_GridImpDelegate;
-};
-
-class CFWL_GridImpDelegate : public CFWL_WidgetImpDelegate {
- public:
- CFWL_GridImpDelegate(CFWL_GridImp* pOwner);
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
-
- protected:
- CFWL_GridImp* m_pOwner;
-};
-
-#endif // XFA_SRC_FWL_CORE_FWL_GRIDIMP_H_
diff --git a/xfa/src/fwl/core/fwl_noteimp.cpp b/xfa/src/fwl/core/fwl_noteimp.cpp
deleted file mode 100644
index 3a46446362..0000000000
--- a/xfa/src/fwl/core/fwl_noteimp.cpp
+++ /dev/null
@@ -1,1097 +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/src/fwl/core/fwl_noteimp.h"
-
-#include "core/include/fxcrt/fx_ext.h"
-#include "xfa/include/fwl/adapter/fwl_adapterwidgetmgr.h"
-#include "xfa/include/fwl/basewidget/fwl_tooltipctrl.h"
-#include "xfa/include/fwl/core/fwl_app.h"
-#include "xfa/include/fwl/core/fwl_grid.h"
-#include "xfa/src/fwl/basewidget/fwl_tooltipctrlimp.h"
-#include "xfa/src/fwl/core/fwl_appimp.h"
-#include "xfa/src/fwl/core/fwl_formimp.h"
-#include "xfa/src/fwl/core/fwl_panelimp.h"
-#include "xfa/src/fwl/core/fwl_targetimp.h"
-#include "xfa/src/fwl/core/fwl_threadimp.h"
-#include "xfa/src/fwl/core/fwl_widgetimp.h"
-#include "xfa/src/fwl/core/fwl_widgetmgrimp.h"
-
-CFWL_NoteLoop::CFWL_NoteLoop(CFWL_WidgetImp* pForm)
- : m_pForm(pForm), m_bContinueModal(TRUE) {}
-FX_BOOL CFWL_NoteLoop::PreProcessMessage(CFWL_Message* pMessage) {
- if (!m_pForm) {
- return FALSE;
- }
- return TranslateAccelerator(pMessage);
-}
-FWL_ERR CFWL_NoteLoop::Idle(int32_t count) {
-#if (_FX_OS_ == _FX_WIN32_DESKTOP_)
- if (count <= 0) {
-#endif
- CFWL_EvtIdle ev;
- IFWL_App* pApp = FWL_GetApp();
- if (!pApp)
- return FWL_ERR_Indefinite;
- IFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
- if (!pDriver)
- return FWL_ERR_Indefinite;
- pDriver->SendNote(&ev);
-#if (_FX_OS_ == _FX_WIN32_DESKTOP_)
- }
-#endif
- return FWL_ERR_Indefinite;
-}
-CFWL_WidgetImp* CFWL_NoteLoop::GetForm() {
- return m_pForm;
-}
-FX_BOOL CFWL_NoteLoop::ContinueModal() {
- return m_bContinueModal;
-}
-FWL_ERR CFWL_NoteLoop::EndModalLoop() {
- m_bContinueModal = FALSE;
-#if (_FX_OS_ == _FX_MACOSX_)
- CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- IFWL_AdapterWidgetMgr* adapterWidgetMgr = pWidgetMgr->GetAdapterWidgetMgr();
- adapterWidgetMgr->EndLoop();
-#endif
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_NoteLoop::TranslateAccelerator(CFWL_Message* pMessage) {
- if (pMessage->GetClassID() != FWL_MSGHASH_Key) {
- return FALSE;
- }
- CFWL_MsgKey* pMsgKey = static_cast<CFWL_MsgKey*>(pMessage);
- if (pMsgKey->m_dwCmd != FWL_MSGKEYCMD_KeyDown) {
- return FALSE;
- }
- CFX_MapAccelerators& accel =
- static_cast<CFWL_FormImp*>(m_pForm)->GetAccelerator();
- FX_POSITION pos = accel.GetStartPosition();
- if (!pos) {
- return FALSE;
- }
- FX_DWORD vrKey, rValue;
- while (pos) {
- accel.GetNextAssoc(pos, vrKey, rValue);
- FX_DWORD dwFlags = (vrKey & 0xFF00) >> 8;
- FX_DWORD m_dwKeyCode = vrKey & 0x00FF;
- if (pMsgKey->m_dwFlags == dwFlags && pMsgKey->m_dwKeyCode == m_dwKeyCode) {
- GenerateCommondEvent(rValue);
- return TRUE;
- }
- }
- return FALSE;
-}
-FWL_ERR CFWL_NoteLoop::SetMainForm(CFWL_WidgetImp* pForm) {
- m_pForm = pForm;
- return FWL_ERR_Succeeded;
-}
-void CFWL_NoteLoop::GenerateCommondEvent(FX_DWORD dwCommand) {
- CFWL_EvtMenuCommand ev;
- ev.m_iCommand = dwCommand;
- IFWL_NoteThread* pThread = m_pForm->GetOwnerThread();
- if (!pThread)
- return;
- IFWL_NoteDriver* pDriver = pThread->GetNoteDriver();
- if (!pDriver)
- return;
- pDriver->SendNote(&ev);
-}
-CFWL_NoteDriver::CFWL_NoteDriver()
- : m_sendEventCalled(0),
- m_maxSize(500),
- m_bFullScreen(FALSE),
- m_pHover(nullptr),
- m_pFocus(nullptr),
- m_pGrab(nullptr),
- m_hook(nullptr) {
- m_pNoteLoop = new CFWL_NoteLoop;
- PushNoteLoop(m_pNoteLoop);
-}
-CFWL_NoteDriver::~CFWL_NoteDriver() {
- delete m_pNoteLoop;
- ClearInvalidEventTargets(TRUE);
-}
-FX_BOOL CFWL_NoteDriver::SendNote(CFWL_Note* pNote) {
- if (pNote->IsEvent()) {
- int32_t iCount = m_eventTargets.GetCount();
- if (iCount < 1) {
- return TRUE;
- }
- if (FWL_EVTHASH_Mouse == static_cast<CFWL_Event*>(pNote)->GetClassID()) {
- CFWL_EvtMouse* pMouse = static_cast<CFWL_EvtMouse*>(pNote);
- if (FWL_MSGMOUSECMD_MouseHover == pMouse->m_dwCmd) {
- if (m_pNoteLoop->GetForm() &&
- CFWL_ToolTipContainer::getInstance()->ProcessEnter(
- pMouse, m_pNoteLoop->GetForm()->GetInterface())) {
- }
- } else if (FWL_MSGMOUSECMD_MouseLeave == pMouse->m_dwCmd) {
- if (CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse)) {
- }
- } else if ((FWL_MSGMOUSECMD_LButtonDown <= pMouse->m_dwCmd) &&
- (FWL_MSGMOUSECMD_MButtonDblClk >= pMouse->m_dwCmd)) {
- if (CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse)) {
- }
- }
- }
- m_sendEventCalled++;
- FX_POSITION pos = m_eventTargets.GetStartPosition();
- while (pos) {
- void* key = NULL;
- CFWL_EventTarget* pEventTarget;
- m_eventTargets.GetNextAssoc(pos, key, (void*&)pEventTarget);
- if (pEventTarget && !pEventTarget->IsInvalid()) {
- pEventTarget->ProcessEvent(static_cast<CFWL_Event*>(pNote));
- }
- }
- m_sendEventCalled--;
- } else {
- if (!pNote->m_pDstTarget)
- return FALSE;
- IFWL_WidgetDelegate* pDelegate = pNote->m_pDstTarget->SetDelegate(NULL);
- if (pDelegate) {
- pDelegate->OnProcessMessage(static_cast<CFWL_Message*>(pNote));
- }
- }
- return TRUE;
-}
-extern void FWL_PostMessageToMainRoop(CFWL_Message* pMessage);
-FX_BOOL CFWL_NoteDriver::PostMessage(CFWL_Message* pMessage) {
- FWL_PostMessageToMainRoop(pMessage);
- return TRUE;
-}
-#define FWL_NoteDriver_EventKey 1100
-FWL_ERR CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener,
- IFWL_Widget* pEventSource,
- FX_DWORD dwFilter) {
- FX_DWORD dwkey = (FX_DWORD)(uintptr_t)pListener->GetPrivateData(
- (void*)(uintptr_t)FWL_NoteDriver_EventKey);
- if (dwkey == 0) {
- void* random = FX_Random_MT_Start(0);
- dwkey = rand();
- FX_Random_MT_Close(random);
- pListener->SetPrivateData((void*)(uintptr_t)FWL_NoteDriver_EventKey,
- (void*)(uintptr_t)dwkey, NULL);
- }
- CFWL_EventTarget* value = NULL;
- if (!m_eventTargets.Lookup((void*)(uintptr_t)dwkey, (void*&)value)) {
- value = new CFWL_EventTarget(this, pListener);
- m_eventTargets.SetAt((void*)(uintptr_t)dwkey, value);
- }
- value->SetEventSource(pEventSource, dwFilter);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) {
- FX_DWORD dwkey = (FX_DWORD)(uintptr_t)pListener->GetPrivateData(
- (void*)(uintptr_t)FWL_NoteDriver_EventKey);
- if (dwkey == 0) {
- return FWL_ERR_Indefinite;
- }
- CFWL_EventTarget* value = NULL;
- if (m_eventTargets.Lookup((void*)(uintptr_t)dwkey, (void*&)value)) {
- value->FlagInvalid();
- }
- return FWL_ERR_Succeeded;
-}
-void CFWL_NoteDriver::ClearEventTargets(FX_BOOL bRemoveAll) {
- ClearInvalidEventTargets(bRemoveAll);
-}
-int32_t CFWL_NoteDriver::GetQueueMaxSize() const {
- return m_maxSize;
-}
-FWL_ERR CFWL_NoteDriver::SetQueueMaxSize(const int32_t size) {
- m_maxSize = size;
- return FWL_ERR_Succeeded;
-}
-IFWL_NoteThread* CFWL_NoteDriver::GetOwnerThread() const {
- return FWL_GetApp();
-}
-FWL_ERR CFWL_NoteDriver::PushNoteLoop(IFWL_NoteLoop* pNoteLoop) {
- m_noteLoopQueue.Add(pNoteLoop);
- return FWL_ERR_Succeeded;
-}
-IFWL_NoteLoop* CFWL_NoteDriver::PopNoteLoop() {
- int32_t pos = m_noteLoopQueue.GetSize();
- if (pos <= 0)
- return NULL;
- IFWL_NoteLoop* p =
- static_cast<IFWL_NoteLoop*>(m_noteLoopQueue.GetAt(pos - 1));
- m_noteLoopQueue.RemoveAt(pos - 1);
- return p;
-}
-FX_BOOL CFWL_NoteDriver::SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify) {
- if (m_pFocus == pFocus) {
- return TRUE;
- }
- IFWL_Widget* pPrev = m_pFocus;
- m_pFocus = pFocus;
- if (pPrev) {
- CFWL_MsgKillFocus ms;
- ms.m_pDstTarget = pPrev;
- ms.m_pSrcTarget = pPrev;
- if (bNotify) {
- ms.m_dwExtend = 1;
- }
- IFWL_WidgetDelegate* pDelegate = pPrev->SetDelegate(NULL);
- if (pDelegate) {
- pDelegate->OnProcessMessage(&ms);
- }
- }
- if (pFocus) {
- IFWL_Widget* pWidget =
- FWL_GetWidgetMgr()->GetWidget(pFocus, FWL_WGTRELATION_SystemForm);
- CFWL_FormImp* pForm =
- pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr;
- if (pForm) {
- CFWL_WidgetImp* pNewFocus =
- static_cast<CFWL_WidgetImp*>(pFocus->GetImpl());
- pForm->SetSubFocus(pNewFocus);
- }
- CFWL_MsgSetFocus ms;
- ms.m_pDstTarget = pFocus;
- if (bNotify) {
- ms.m_dwExtend = 1;
- }
- IFWL_WidgetDelegate* pDelegate = pFocus->SetDelegate(NULL);
- if (pDelegate) {
- pDelegate->OnProcessMessage(&ms);
- }
- }
- return TRUE;
-}
-FWL_ERR CFWL_NoteDriver::Run() {
- CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- if (!pWidgetMgr)
- return FWL_ERR_Indefinite;
-#if (_FX_OS_ == _FX_MACOSX_)
- IFWL_AdapterWidgetMgr* adapterWidgetMgr = pWidgetMgr->GetAdapterWidgetMgr();
- CFWL_NoteLoop* pTopLoop = GetTopLoop();
- if (pTopLoop) {
- CFWL_WidgetImp* formImp = pTopLoop->GetForm();
- if (formImp) {
- IFWL_Widget* pForm = formImp->GetInterface();
- adapterWidgetMgr->RunLoop(pForm);
- }
- }
-#elif(_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_)
- FX_BOOL bIdle = TRUE;
- int32_t iIdleCount = 0;
- CFWL_NoteLoop* pTopLoop = NULL;
- for (;;) {
- pTopLoop = GetTopLoop();
- if (!pTopLoop || !pTopLoop->ContinueModal()) {
- break;
- }
- if (UnqueueMessage(pTopLoop)) {
- continue;
- }
- while (bIdle && !(pWidgetMgr->CheckMessage_Native())) {
- if (FWL_ERR_Indefinite == pTopLoop->Idle(iIdleCount++)) {
- bIdle = FALSE;
- }
- }
- do {
- if (FWL_ERR_Indefinite == pWidgetMgr->DispatchMessage_Native()) {
- break;
- }
- if (pWidgetMgr->IsIdleMessage_Native()) {
- bIdle = TRUE;
- iIdleCount = 0;
- }
- } while (pWidgetMgr->CheckMessage_Native());
- }
-#elif(_FX_OS_ == _FX_LINUX_DESKTOP_)
- CFWL_NoteLoop* pTopLoop = NULL;
- for (;;) {
- pTopLoop = GetTopLoop();
- if (!pTopLoop || !pTopLoop->ContinueModal()) {
- break;
- }
- if (UnqueueMessage(pTopLoop)) {
- continue;
- }
- if (pWidgetMgr->CheckMessage_Native()) {
- pWidgetMgr->DispatchMessage_Native();
- }
- }
-#endif
- return FWL_ERR_Succeeded;
-}
-IFWL_Widget* CFWL_NoteDriver::GetFocus() {
- return m_pFocus;
-}
-IFWL_Widget* CFWL_NoteDriver::GetHover() {
- return m_pHover;
-}
-void CFWL_NoteDriver::SetHover(IFWL_Widget* pHover) {
- m_pHover = pHover;
-}
-void CFWL_NoteDriver::SetGrab(IFWL_Widget* pGrab, FX_BOOL bSet) {
- m_pGrab = bSet ? pGrab : NULL;
-}
-void CFWL_NoteDriver::NotifyTargetHide(IFWL_Widget* pNoteTarget) {
- if (m_pFocus == pNoteTarget) {
- m_pFocus = NULL;
- }
- if (m_pHover == pNoteTarget) {
- m_pHover = NULL;
- }
- if (m_pGrab == pNoteTarget) {
- m_pGrab = NULL;
- }
-}
-void CFWL_NoteDriver::NotifyTargetDestroy(IFWL_Widget* pNoteTarget) {
- if (m_pFocus == pNoteTarget) {
- m_pFocus = NULL;
- }
- if (m_pHover == pNoteTarget) {
- m_pHover = NULL;
- }
- if (m_pGrab == pNoteTarget) {
- m_pGrab = NULL;
- }
- UnregisterEventTarget(pNoteTarget);
- int32_t count = m_forms.GetSize();
- for (int32_t nIndex = 0; nIndex < count; nIndex++) {
- CFWL_FormImp* pForm = static_cast<CFWL_FormImp*>(m_forms[nIndex]);
- if (!pForm) {
- continue;
- }
- CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus();
- if (!pSubFocus)
- return;
- if (pSubFocus && pSubFocus->GetInterface() == pNoteTarget) {
- pForm->SetSubFocus(NULL);
- }
- }
-}
-void CFWL_NoteDriver::NotifyFullScreenMode(IFWL_Widget* pNoteTarget,
- FX_BOOL bFullScreen) {
- m_bFullScreen = bFullScreen;
-}
-FWL_ERR CFWL_NoteDriver::RegisterForm(CFWL_WidgetImp* pForm) {
- if (!pForm)
- return FWL_ERR_Indefinite;
- if (m_forms.Find(pForm) >= 0) {
- return FWL_ERR_Indefinite;
- }
- m_forms.Add(pForm);
- if (m_forms.GetSize() == 1) {
- CFWL_NoteLoop* pLoop =
- static_cast<CFWL_NoteLoop*>(m_noteLoopQueue.GetAt(0));
- if (!pLoop)
- return FWL_ERR_Indefinite;
- pLoop->SetMainForm(pForm);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_NoteDriver::UnRegisterForm(CFWL_WidgetImp* pForm) {
- if (!pForm)
- return FWL_ERR_Indefinite;
- int32_t nIndex = m_forms.Find(pForm);
- if (nIndex < 0) {
- return FWL_ERR_Indefinite;
- }
- m_forms.RemoveAt(nIndex);
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_NoteDriver::QueueMessage(CFWL_Message* pMessage) {
- pMessage->Retain();
- m_noteQueue.Add(pMessage);
- return TRUE;
-}
-FX_BOOL CFWL_NoteDriver::UnqueueMessage(CFWL_NoteLoop* pNoteLoop) {
- if (m_noteQueue.GetSize() < 1) {
- return FALSE;
- }
- CFWL_Message* pMessage = static_cast<CFWL_Message*>(m_noteQueue[0]);
- m_noteQueue.RemoveAt(0);
- if (!IsValidMessage(pMessage)) {
- pMessage->Release();
- return TRUE;
- }
- FX_BOOL bHookMessage = FALSE;
- if (m_hook) {
- bHookMessage = (*m_hook)(pMessage, m_hookInfo);
- }
- if (!bHookMessage && !pNoteLoop->PreProcessMessage(pMessage)) {
- ProcessMessage(pMessage);
- }
- pMessage->Release();
- return TRUE;
-}
-CFWL_NoteLoop* CFWL_NoteDriver::GetTopLoop() {
- int32_t size = m_noteLoopQueue.GetSize();
- if (size <= 0)
- return NULL;
- return static_cast<CFWL_NoteLoop*>(m_noteLoopQueue[size - 1]);
-}
-int32_t CFWL_NoteDriver::CountLoop() {
- return m_noteLoopQueue.GetSize();
-}
-void CFWL_NoteDriver::SetHook(FWLMessageHookCallback callback, void* info) {
- m_hook = callback;
- m_hookInfo = info;
-}
-FX_BOOL CFWL_NoteDriver::ProcessMessage(CFWL_Message* pMessage) {
- CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- IFWL_Widget* pMessageForm = pWidgetMgr->IsFormDisabled()
- ? pMessage->m_pDstTarget
- : GetMessageForm(pMessage->m_pDstTarget);
- if (!pMessageForm)
- return FALSE;
- if (DispatchMessage(pMessage, pMessageForm)) {
- if (pMessage->GetClassID() == FWL_MSGHASH_Mouse) {
- MouseSecondary(static_cast<CFWL_MsgMouse*>(pMessage));
- }
- return TRUE;
- }
- return FALSE;
-}
-FX_BOOL CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage,
- IFWL_Widget* pMessageForm) {
- FX_BOOL bRet = FALSE;
- switch (pMessage->GetClassID()) {
- case FWL_MSGHASH_Activate: {
- bRet = DoActivate(static_cast<CFWL_MsgActivate*>(pMessage), pMessageForm);
- break;
- }
- case FWL_MSGHASH_Deactivate: {
- bRet = DoDeactivate(static_cast<CFWL_MsgDeactivate*>(pMessage),
- pMessageForm);
- break;
- }
- case FWL_MSGHASH_SetFocus: {
- bRet = DoSetFocus(static_cast<CFWL_MsgSetFocus*>(pMessage), pMessageForm);
- break;
- }
- case FWL_MSGHASH_KillFocus: {
- bRet =
- DoKillFocus(static_cast<CFWL_MsgKillFocus*>(pMessage), pMessageForm);
- break;
- }
- case FWL_MSGHASH_Key: {
- bRet = DoKey(static_cast<CFWL_MsgKey*>(pMessage), pMessageForm);
- break;
- }
- case FWL_MSGHASH_Mouse: {
- bRet = DoMouse(static_cast<CFWL_MsgMouse*>(pMessage), pMessageForm);
- break;
- }
- case FWL_MSGHASH_MouseWheel: {
- bRet = DoWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage), pMessageForm);
- break;
- }
- case FWL_MSGHASH_Size: {
- bRet = DoSize(static_cast<CFWL_MsgSize*>(pMessage));
- break;
- }
- case FWL_MSGHASH_Cursor: {
- bRet = TRUE;
- break;
- }
- case FWL_MSGHASH_WindowMove: {
- bRet = DoWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage),
- pMessageForm);
- break;
- }
- case FWL_MSGHASH_DropFiles: {
- bRet =
- DoDragFiles(static_cast<CFWL_MsgDropFiles*>(pMessage), pMessageForm);
- break;
- }
- default: {
- bRet = TRUE;
- break;
- }
- }
- if (bRet) {
- IFWL_WidgetDelegate* pDelegate = pMessage->m_pDstTarget->SetDelegate(NULL);
- if (pDelegate) {
- pDelegate->OnProcessMessage(pMessage);
- }
- }
- return bRet;
-}
-FX_BOOL CFWL_NoteDriver::DoActivate(CFWL_MsgActivate* pMsg,
- IFWL_Widget* pMessageForm) {
- if (m_bFullScreen) {
- return FALSE;
- }
- pMsg->m_pDstTarget = pMessageForm;
- return (pMsg->m_pDstTarget)->GetStates() & FWL_WGTSTATE_Deactivated;
-}
-FX_BOOL CFWL_NoteDriver::DoDeactivate(CFWL_MsgDeactivate* pMsg,
- IFWL_Widget* pMessageForm) {
- if (m_bFullScreen) {
- return FALSE;
- }
- int32_t iTrackLoop = m_noteLoopQueue.GetSize();
- if (iTrackLoop <= 0)
- return FALSE;
- if (iTrackLoop == 1) {
- if (pMessageForm->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"))) {
- return FALSE;
- }
- if (pMsg->m_pSrcTarget &&
- pMsg->m_pSrcTarget->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"))) {
- return FALSE;
- }
- if (pMsg->m_pSrcTarget && pMsg->m_pSrcTarget->GetClassID() == 1111984755) {
- return FALSE;
- }
- return TRUE;
- }
- IFWL_Widget* pDst = pMsg->m_pDstTarget;
- if (!pDst)
- return FALSE;
-#if (_FX_OS_ == _FX_MACOSX_)
- if (pDst == pMessageForm && pDst->IsInstance(L"FWL_FORMPROXY")) {
- return TRUE;
- }
-#endif
- return pDst != pMessageForm &&
- !pDst->IsInstance(FX_WSTRC(L"FWL_FORMPROXY")) &&
- !pMessageForm->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"));
-}
-FX_BOOL CFWL_NoteDriver::DoSetFocus(CFWL_MsgSetFocus* pMsg,
- IFWL_Widget* pMessageForm) {
- CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- if (pWidgetMgr->IsFormDisabled()) {
- m_pFocus = pMsg->m_pDstTarget;
- return TRUE;
- } else {
- IFWL_Widget* pWidget = pMsg->m_pDstTarget;
- CFWL_FormImp* pForm =
- pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr;
- if (pForm) {
- CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus();
- if (pSubFocus && ((pSubFocus->GetStates() & FWL_WGTSTATE_Focused) == 0)) {
- pMsg->m_pDstTarget = pSubFocus->GetInterface();
- if (m_pFocus != pMsg->m_pDstTarget) {
- m_pFocus = pMsg->m_pDstTarget;
- return TRUE;
- }
- }
- }
- }
- return FALSE;
-}
-FX_BOOL CFWL_NoteDriver::DoKillFocus(CFWL_MsgKillFocus* pMsg,
- IFWL_Widget* pMessageForm) {
- CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- if (pWidgetMgr->IsFormDisabled()) {
- if (m_pFocus == pMsg->m_pDstTarget) {
- m_pFocus = NULL;
- }
- return TRUE;
- }
- IFWL_Widget* pWidget = pMsg->m_pDstTarget;
- CFWL_FormImp* pForm =
- pWidget ? static_cast<CFWL_FormImp*>(pWidget->GetImpl()) : nullptr;
- if (pForm) {
- CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus();
- if (pSubFocus && (pSubFocus->GetStates() & FWL_WGTSTATE_Focused)) {
- pMsg->m_pDstTarget = pSubFocus->GetInterface();
- if (m_pFocus == pMsg->m_pDstTarget) {
- m_pFocus = NULL;
- return TRUE;
- }
- }
- }
- return FALSE;
-}
-FX_BOOL CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) {
-#if (_FX_OS_ != _FX_MACOSX_)
- if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown &&
- pMsg->m_dwKeyCode == FWL_VKEY_Tab) {
- CFWL_WidgetMgr* pWidgetMgr =
- static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- IFWL_Widget* pForm = GetMessageForm(pMsg->m_pDstTarget);
- IFWL_Widget* pFocus = m_pFocus;
- if (m_pFocus) {
- if (pWidgetMgr->GetWidget(m_pFocus, FWL_WGTRELATION_SystemForm) !=
- pForm) {
- pFocus = NULL;
- }
- }
- FX_BOOL bFind = FALSE;
- IFWL_Widget* pNextTabStop = pWidgetMgr->nextTab(pForm, pFocus, bFind);
- if (!pNextTabStop) {
- bFind = FALSE;
- pNextTabStop = pWidgetMgr->nextTab(pForm, NULL, bFind);
- }
- if (pNextTabStop == pFocus) {
- return TRUE;
- }
- if (pNextTabStop) {
- SetFocus(pNextTabStop);
- }
- return TRUE;
- }
-#endif
- if (!m_pFocus) {
- if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown &&
- pMsg->m_dwKeyCode == FWL_VKEY_Return) {
- CFWL_WidgetMgr* pWidgetMgr =
- static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- IFWL_Widget* defButton = pWidgetMgr->GetDefaultButton(pMessageForm);
- if (defButton) {
- pMsg->m_pDstTarget = defButton;
- return TRUE;
- }
- }
- return FALSE;
- }
- pMsg->m_pDstTarget = m_pFocus;
- return TRUE;
-}
-FX_BOOL CFWL_NoteDriver::DoMouse(CFWL_MsgMouse* pMsg,
- IFWL_Widget* pMessageForm) {
- if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseLeave ||
- pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseHover ||
- pMsg->m_dwCmd == FWL_MSGMOUSECMD_MouseEnter) {
- return pMsg->m_pDstTarget != NULL;
- }
- if (pMsg->m_pDstTarget != pMessageForm) {
- pMsg->m_pDstTarget->TransformTo(pMessageForm, pMsg->m_fx, pMsg->m_fy);
- }
- if (!DoMouseEx(pMsg, pMessageForm)) {
- pMsg->m_pDstTarget = pMessageForm;
- }
- return TRUE;
-}
-FX_BOOL CFWL_NoteDriver::DoWheel(CFWL_MsgMouseWheel* pMsg,
- IFWL_Widget* pMessageForm) {
- CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- if (!pWidgetMgr)
- return FALSE;
- IFWL_Widget* pDst =
- pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy);
- if (!pDst)
- return FALSE;
- while (pDst && pDst->GetClassID() == FWL_CLASSHASH_Grid) {
- pDst = pDst->GetParent();
- }
- pMessageForm->TransformTo(pDst, pMsg->m_fx, pMsg->m_fy);
- pMsg->m_pDstTarget = pDst;
- return TRUE;
-}
-FX_BOOL CFWL_NoteDriver::DoSize(CFWL_MsgSize* pMsg) {
- CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- if (!pWidgetMgr)
- return FALSE;
- pWidgetMgr->NotifySizeChanged(pMsg->m_pDstTarget, (FX_FLOAT)pMsg->m_iWidth,
- (FX_FLOAT)pMsg->m_iHeight);
- return TRUE;
-}
-FX_BOOL CFWL_NoteDriver::DoWindowMove(CFWL_MsgWindowMove* pMsg,
- IFWL_Widget* pMessageForm) {
- return pMsg->m_pDstTarget == pMessageForm;
-}
-FX_BOOL CFWL_NoteDriver::DoDragFiles(CFWL_MsgDropFiles* pMsg,
- IFWL_Widget* pMessageForm) {
- return pMsg->m_pDstTarget == pMessageForm;
-}
-FX_BOOL CFWL_NoteDriver::DoMouseEx(CFWL_MsgMouse* pMsg,
- IFWL_Widget* pMessageForm) {
- CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- if (!pWidgetMgr)
- return FALSE;
- IFWL_Widget* pTarget = NULL;
- if (m_pGrab)
- pTarget = m_pGrab;
- if (!pTarget) {
- pTarget =
- pWidgetMgr->GetWidgetAtPoint(pMessageForm, pMsg->m_fx, pMsg->m_fy);
- while (pTarget && pTarget->GetClassID() == FWL_CLASSHASH_Grid) {
- pTarget = pTarget->GetParent();
- }
- }
- if (pTarget) {
- if (pMessageForm != pTarget) {
- pMessageForm->TransformTo(pTarget, pMsg->m_fx, pMsg->m_fy);
- }
- }
- if (!pTarget)
- return FALSE;
- pMsg->m_pDstTarget = pTarget;
- return TRUE;
-}
-void CFWL_NoteDriver::MouseSecondary(CFWL_MsgMouse* pMsg) {
- IFWL_Widget* pTarget = pMsg->m_pDstTarget;
- if (pTarget == m_pHover) {
- return;
- }
- if (m_pHover) {
- CFWL_MsgMouse msLeave;
- msLeave.m_pDstTarget = m_pHover;
- msLeave.m_fx = pMsg->m_fx;
- msLeave.m_fy = pMsg->m_fy;
- pTarget->TransformTo(m_pHover, msLeave.m_fx, msLeave.m_fy);
- msLeave.m_dwFlags = 0;
- msLeave.m_dwCmd = FWL_MSGMOUSECMD_MouseLeave;
- DispatchMessage(&msLeave, NULL);
- }
- if (pTarget->GetClassID() == FWL_CLASSHASH_Form) {
- m_pHover = NULL;
- return;
- }
- m_pHover = pTarget;
- CFWL_MsgMouse msHover;
- msHover.m_pDstTarget = pTarget;
- msHover.m_fx = pMsg->m_fx;
- msHover.m_fy = pMsg->m_fy;
- msHover.m_dwFlags = 0;
- msHover.m_dwCmd = FWL_MSGMOUSECMD_MouseHover;
- DispatchMessage(&msHover, NULL);
-}
-FX_BOOL CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) {
- if (pMessage->GetClassID() == FWL_MSGHASH_Post) {
- return TRUE;
- }
- int32_t iCount = m_noteLoopQueue.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- CFWL_NoteLoop* pNoteLoop = static_cast<CFWL_NoteLoop*>(m_noteLoopQueue[i]);
- CFWL_WidgetImp* pForm = pNoteLoop->GetForm();
- if (pForm && (pForm->GetInterface() == pMessage->m_pDstTarget)) {
- return TRUE;
- }
- }
- iCount = m_forms.GetSize();
- for (int32_t j = 0; j < iCount; j++) {
- CFWL_FormImp* pForm = static_cast<CFWL_FormImp*>(m_forms[j]);
- if (pForm->GetInterface() == pMessage->m_pDstTarget) {
- return TRUE;
- }
- }
- return FALSE;
-}
-IFWL_Widget* CFWL_NoteDriver::GetMessageForm(IFWL_Widget* pDstTarget) {
- int32_t iTrackLoop = m_noteLoopQueue.GetSize();
- if (iTrackLoop <= 0)
- return NULL;
- IFWL_Widget* pMessageForm = NULL;
- if (iTrackLoop > 1) {
- CFWL_NoteLoop* pNootLoop =
- static_cast<CFWL_NoteLoop*>(m_noteLoopQueue[iTrackLoop - 1]);
- pMessageForm = pNootLoop->GetForm()->GetInterface();
- } else {
- pMessageForm = (m_forms.Find(pDstTarget) < 0) ? NULL : pDstTarget;
- }
- if (!pMessageForm && pDstTarget) {
- CFWL_WidgetMgr* pWidgetMgr =
- static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- if (!pWidgetMgr)
- return NULL;
- pMessageForm =
- pWidgetMgr->GetWidget(pDstTarget, FWL_WGTRELATION_SystemForm);
- }
- return pMessageForm;
-}
-void CFWL_NoteDriver::ClearInvalidEventTargets(FX_BOOL bRemoveAll) {
- FX_POSITION pos = m_eventTargets.GetStartPosition();
- while (pos) {
- void* key = NULL;
- CFWL_EventTarget* pEventTarget = NULL;
- m_eventTargets.GetNextAssoc(pos, key, (void*&)pEventTarget);
- if (pEventTarget && (bRemoveAll || pEventTarget->IsInvalid())) {
- m_eventTargets.RemoveKey(key);
- delete pEventTarget;
- }
- }
-}
-class CFWL_CoreToopTipDP : public IFWL_ToolTipDP {
- public:
- 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();
- CFWL_CoreToopTipDP();
-
- CFX_WideString m_wsCaption;
- int32_t m_nInitDelayTime;
- int32_t m_nAutoPopDelayTime;
- CFX_RectF m_fAnchor;
-};
-CFWL_CoreToopTipDP::CFWL_CoreToopTipDP() {
- m_nInitDelayTime = 500;
- m_nAutoPopDelayTime = 50000;
- m_fAnchor.Set(0.0, 0.0, 0.0, 0.0);
-}
-FWL_ERR CFWL_CoreToopTipDP::GetCaption(IFWL_Widget* pWidget,
- CFX_WideString& wsCaption) {
- wsCaption = m_wsCaption;
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_CoreToopTipDP::GetInitialDelay(IFWL_Widget* pWidget) {
- return m_nInitDelayTime;
-}
-int32_t CFWL_CoreToopTipDP::GetAutoPopDelay(IFWL_Widget* pWidget) {
- return m_nAutoPopDelayTime;
-}
-CFX_DIBitmap* CFWL_CoreToopTipDP::GetToolTipIcon(IFWL_Widget* pWidget) {
- return NULL;
-}
-CFX_SizeF CFWL_CoreToopTipDP::GetToolTipIconSize(IFWL_Widget* pWidget) {
- return CFX_SizeF();
-}
-CFX_RectF CFWL_CoreToopTipDP::GetAnchor() {
- return m_fAnchor;
-}
-CFWL_EventTarget::~CFWL_EventTarget() {
- m_eventSources.RemoveAll();
-}
-int32_t CFWL_EventTarget::SetEventSource(IFWL_Widget* pSource,
- FX_DWORD dwFilter) {
- if (pSource) {
- m_eventSources.SetAt(pSource, dwFilter);
- return m_eventSources.GetCount();
- }
- return 1;
-}
-FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) {
- IFWL_WidgetDelegate* pDelegate = m_pListener->SetDelegate(NULL);
- if (!pDelegate)
- return FALSE;
- if (m_eventSources.GetCount() == 0) {
- pDelegate->OnProcessEvent(pEvent);
- return TRUE;
- }
- FX_POSITION pos = m_eventSources.GetStartPosition();
- while (pos) {
- IFWL_Widget* pSource = NULL;
- FX_DWORD dwFilter = 0;
- m_eventSources.GetNextAssoc(pos, (void*&)pSource, dwFilter);
- if (pSource == pEvent->m_pSrcTarget ||
- pEvent->GetClassID() == FWL_EVTHASH_Idle) {
- if (IsFilterEvent(pEvent, dwFilter)) {
- pDelegate->OnProcessEvent(pEvent);
- return TRUE;
- }
- }
- }
- return FALSE;
-}
-FX_BOOL CFWL_EventTarget::IsFilterEvent(CFWL_Event* pEvent, FX_DWORD dwFilter) {
- if (dwFilter == FWL_EVENT_ALL_MASK) {
- return TRUE;
- }
- FX_BOOL bRet = FALSE;
- switch (pEvent->GetClassID()) {
- case FWL_EVTHASH_Mouse: {
- bRet = dwFilter & FWL_EVENT_MOUSE_MASK;
- break;
- }
- case FWL_EVTHASH_MouseWheel: {
- bRet = dwFilter & FWL_EVENT_MOUSEWHEEL_MASK;
- break;
- }
- case FWL_EVTHASH_Key: {
- bRet = dwFilter & FWL_EVENT_KEY_MASK;
- break;
- }
- case FWL_EVTHASH_SetFocus:
- case FWL_EVTHASH_KillFocus: {
- bRet = dwFilter & FWL_EVENT_FOCUSCHANGED_MASK;
- break;
- }
- case FWL_EVTHASH_Draw: {
- bRet = dwFilter & FWL_EVENT_DRAW_MASK;
- break;
- }
- case FWL_EVTHASH_Close: {
- bRet = dwFilter & FWL_EVENT_CLOSE_MASK;
- break;
- }
- case FWL_EVTHASH_SizeChanged: {
- bRet = dwFilter & FWL_EVENT_SIZECHANGED_MASK;
- break;
- }
- case FWL_EVTHASH_Idle: {
- bRet = dwFilter & FWL_EVENT_IDLE_MASK;
- break;
- }
- default: {
- bRet = dwFilter & FWL_EVENT_CONTROL_MASK;
- break;
- }
- }
- return bRet;
-}
-
-CFWL_ToolTipContainer* CFWL_ToolTipContainer::s_pInstance = NULL;
-
-CFWL_ToolTipContainer::CFWL_ToolTipContainer()
- : pCurTarget(NULL), m_pToolTipImp(NULL) {
- m_ToolTipDp = new CFWL_CoreToopTipDP;
- m_ToolTipDp->m_nInitDelayTime = 0;
- m_ToolTipDp->m_nAutoPopDelayTime = 2000;
-}
-CFWL_ToolTipContainer::~CFWL_ToolTipContainer() {
- if (m_pToolTipImp) {
- IFWL_ToolTip* pToolTip =
- static_cast<IFWL_ToolTip*>(m_pToolTipImp->GetInterface());
- pToolTip->Finalize();
- delete pToolTip;
- }
- delete m_ToolTipDp;
-}
-// static
-CFWL_ToolTipContainer* CFWL_ToolTipContainer::getInstance() {
- if (!s_pInstance) {
- s_pInstance = new CFWL_ToolTipContainer;
- }
- return s_pInstance;
-}
-// static
-void CFWL_ToolTipContainer::DeleteInstance() {
- if (s_pInstance) {
- delete s_pInstance;
- s_pInstance = NULL;
- }
-}
-FX_ERR CFWL_ToolTipContainer::AddToolTipTarget(IFWL_ToolTipTarget* pTarget) {
- if (m_arrWidget.Find((void*)pTarget) < 0) {
- m_arrWidget.Add((void*)pTarget);
- return FWL_ERR_Succeeded;
- }
- return FWL_ERR_Indefinite;
-}
-FX_ERR CFWL_ToolTipContainer::RemoveToolTipTarget(IFWL_ToolTipTarget* pTarget) {
- int index = m_arrWidget.Find((void*)pTarget);
- if (index >= 0) {
- m_arrWidget.RemoveAt(index);
- return FWL_ERR_Succeeded;
- }
- return FWL_ERR_Indefinite;
-}
-FX_BOOL CFWL_ToolTipContainer::HasToolTip(IFWL_Widget* pWedget) {
- int32_t iCount = m_arrWidget.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- IFWL_ToolTipTarget* p = static_cast<IFWL_ToolTipTarget*>(m_arrWidget[i]);
- if (p->GetWidget() == pWedget) {
- pCurTarget = p;
- return TRUE;
- }
- }
- return FALSE;
-}
-FX_BOOL CFWL_ToolTipContainer::ProcessEnter(CFWL_EvtMouse* pEvt,
- IFWL_Widget* pOwner) {
- if (HasToolTip(pEvt->m_pDstTarget)) {
- if (NULL == m_pToolTipImp) {
- CFWL_WidgetImpProperties prop;
- prop.m_pDataProvider = m_ToolTipDp;
- prop.m_pOwner = pOwner;
- CFX_RectF rtTooltip;
- rtTooltip.Set(150, 150, 100, 50);
- prop.m_rtWidget = rtTooltip;
- IFWL_ToolTip* pToolTip = IFWL_ToolTip::Create(prop, nullptr);
- pToolTip->Initialize();
- m_pToolTipImp = static_cast<CFWL_ToolTipImp*>(pToolTip->GetImpl());
- m_pToolTipImp->ModifyStylesEx(FWL_STYLEEXT_TTP_Multiline, 0);
- m_pToolTipImp->SetStates(FWL_WGTSTATE_Invisible, TRUE);
- }
- if (pCurTarget->IsShowed()) {
- CFX_WideString wsCaption;
- pCurTarget->GetCaption(wsCaption);
- if (!wsCaption.IsEmpty()) {
- m_ToolTipDp->m_wsCaption = wsCaption;
- }
- CFX_RectF rt;
- CFX_SizeF sz;
- pCurTarget->GetToolTipSize(sz);
- if (sz.x > 0 && sz.y > 0) {
- rt.width = sz.x;
- rt.height = sz.y;
- } else {
- CFX_RectF r;
- m_pToolTipImp->GetWidgetRect(r, TRUE);
- rt.width = r.width;
- rt.height = r.height;
- }
- CFX_PointF pt(pEvt->m_fx, pEvt->m_fy);
- if (pCurTarget->GetToolTipPos(pt) == FWL_ERR_Succeeded) {
- rt.left = pt.x;
- rt.top = pt.y;
- m_pToolTipImp->ModifyStylesEx(FWL_STYLEEXT_TTP_NoAnchor, 0);
- } else {
- CFX_RectF rtAnchor;
- pCurTarget->GetWidget()->GetClientRect(rtAnchor);
- pCurTarget->GetWidget()->TransformTo(NULL, rtAnchor.left, rtAnchor.top);
- m_pToolTipImp->SetAnchor(rtAnchor);
- m_pToolTipImp->ModifyStylesEx(0, FWL_STYLEEXT_TTP_NoAnchor);
- }
- m_pToolTipImp->SetWidgetRect(rt);
- m_pToolTipImp->Update();
- m_pToolTipImp->Show();
- }
- return TRUE;
- }
- return FALSE;
-}
-FX_BOOL CFWL_ToolTipContainer::ProcessLeave(CFWL_EvtMouse* pEvt) {
- if (HasToolTip(pEvt->m_pDstTarget) && NULL != m_pToolTipImp) {
- m_pToolTipImp->Hide();
- pCurTarget = NULL;
- return TRUE;
- }
- return FALSE;
-}
-IFWL_ToolTipTarget* CFWL_ToolTipContainer::GetCurrentToolTipTarget() {
- return pCurTarget;
-}
-FX_ERR CFWL_ToolTipContainer::SetToolTipInitialDelay(int32_t nDelayTime) {
- m_ToolTipDp->m_nInitDelayTime = nDelayTime;
- return FWL_ERR_Succeeded;
-}
-FX_ERR CFWL_ToolTipContainer::SetToolTipAutoPopDelay(int32_t nDelayTime) {
- m_ToolTipDp->m_nAutoPopDelayTime = nDelayTime;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR FWL_AddToolTipTarget(IFWL_ToolTipTarget* pTarget) {
- return CFWL_ToolTipContainer::getInstance()->AddToolTipTarget(pTarget);
-}
-FWL_ERR FWL_RemoveToolTipTarget(IFWL_ToolTipTarget* pTarget) {
- return CFWL_ToolTipContainer::getInstance()->RemoveToolTipTarget(pTarget);
-}
-FWL_ERR FWL_SetToolTipInitialDelay(int32_t nDelayTime) {
- return CFWL_ToolTipContainer::getInstance()->SetToolTipInitialDelay(
- nDelayTime);
-}
-FWL_ERR FWL_SetToolTipAutoPopDelay(int32_t nDelayTime) {
- return CFWL_ToolTipContainer::getInstance()->SetToolTipAutoPopDelay(
- nDelayTime);
-}
-IFWL_Widget* FWL_GetCurrentThreadModalWidget(IFWL_NoteThread* pNoteThread) {
- if (!pNoteThread)
- return NULL;
- CFWL_NoteDriver* noteDriver =
- static_cast<CFWL_NoteDriver*>(pNoteThread->GetNoteDriver());
- if (!noteDriver)
- return NULL;
- if (noteDriver->CountLoop() == 1) {
- return NULL;
- }
- CFWL_NoteLoop* topLoop = noteDriver->GetTopLoop();
- if (!topLoop)
- return NULL;
- CFWL_WidgetImp* widget = topLoop->GetForm();
- if (!widget)
- return NULL;
- return widget->GetInterface();
-}
-FWL_ERR FWL_SetHook(IFWL_NoteDriver* driver,
- FWLMessageHookCallback callback,
- void* info) {
- CFWL_NoteDriver* noteDriver = static_cast<CFWL_NoteDriver*>(driver);
- noteDriver->SetHook(callback, info);
- return FWL_ERR_Succeeded;
-}
diff --git a/xfa/src/fwl/core/fwl_noteimp.h b/xfa/src/fwl/core/fwl_noteimp.h
deleted file mode 100644
index 72e1a8ef96..0000000000
--- a/xfa/src/fwl/core/fwl_noteimp.h
+++ /dev/null
@@ -1,157 +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_SRC_FWL_CORE_FWL_NOTEIMP_H_
-#define XFA_SRC_FWL_CORE_FWL_NOTEIMP_H_
-
-#include "xfa/include/fwl/core/fwl_note.h"
-
-class CFWL_WidgetImp;
-class CFWL_ToolTipImp;
-class CFWL_CoreToopTipDP;
-class CFWL_NoteDriver;
-class CFWL_EventTarget;
-class CFWL_ToolTipContainer;
-
-class CFWL_NoteLoop : public IFWL_NoteLoop {
- public:
- CFWL_NoteLoop(CFWL_WidgetImp* pForm = NULL);
-
- // IFWL_NoteLoop:
- ~CFWL_NoteLoop() override {}
- FX_BOOL PreProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR Idle(int32_t count) override;
-
- CFWL_WidgetImp* GetForm();
- FX_BOOL ContinueModal();
- FWL_ERR EndModalLoop();
- FX_BOOL TranslateAccelerator(CFWL_Message* pMessage);
- FWL_ERR SetMainForm(CFWL_WidgetImp* pForm);
-
- protected:
- void GenerateCommondEvent(FX_DWORD dwCommand);
-
- CFWL_WidgetImp* m_pForm;
- FX_BOOL m_bContinueModal;
-};
-class CFWL_NoteDriver : public IFWL_NoteDriver {
- public:
- CFWL_NoteDriver();
- ~CFWL_NoteDriver() override;
-
- // IFWL_NoteDriver:
- FX_BOOL SendNote(CFWL_Note* pNote) override;
- FX_BOOL PostMessage(CFWL_Message* pMessage) override;
- FWL_ERR RegisterEventTarget(IFWL_Widget* pListener,
- IFWL_Widget* pEventSource = NULL,
- FX_DWORD dwFilter = FWL_EVENT_ALL_MASK) override;
- FWL_ERR UnregisterEventTarget(IFWL_Widget* pListener) override;
- void ClearEventTargets(FX_BOOL bRemoveAll) override;
- int32_t GetQueueMaxSize() const override;
- FWL_ERR SetQueueMaxSize(const int32_t size) override;
- IFWL_NoteThread* GetOwnerThread() const override;
- FWL_ERR PushNoteLoop(IFWL_NoteLoop* pNoteLoop) override;
- IFWL_NoteLoop* PopNoteLoop() override;
- IFWL_Widget* GetFocus() override;
- FX_BOOL SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify = FALSE) override;
- void SetGrab(IFWL_Widget* pGrab, FX_BOOL bSet) override;
- FWL_ERR Run() override;
-
- IFWL_Widget* GetHover();
- void SetHover(IFWL_Widget* pHover);
- void NotifyTargetHide(IFWL_Widget* pNoteTarget);
- void NotifyTargetDestroy(IFWL_Widget* pNoteTarget);
- void NotifyFullScreenMode(IFWL_Widget* pNoteTarget, FX_BOOL bFullScreen);
- FWL_ERR RegisterForm(CFWL_WidgetImp* pForm);
- FWL_ERR UnRegisterForm(CFWL_WidgetImp* pForm);
- FX_BOOL QueueMessage(CFWL_Message* pMessage);
- FX_BOOL UnqueueMessage(CFWL_NoteLoop* pNoteLoop);
- CFWL_NoteLoop* GetTopLoop();
- int32_t CountLoop();
- void SetHook(FWLMessageHookCallback callback, void* info);
- FX_BOOL ProcessMessage(CFWL_Message* pMessage);
-
- protected:
- FX_BOOL DispatchMessage(CFWL_Message* pMessage, IFWL_Widget* pMessageForm);
- FX_BOOL DoActivate(CFWL_MsgActivate* pMsg, IFWL_Widget* pMessageForm);
- FX_BOOL DoDeactivate(CFWL_MsgDeactivate* pMsg, IFWL_Widget* pMessageForm);
- FX_BOOL DoSetFocus(CFWL_MsgSetFocus* pMsg, IFWL_Widget* pMessageForm);
- FX_BOOL DoKillFocus(CFWL_MsgKillFocus* pMsg, IFWL_Widget* pMessageForm);
- FX_BOOL DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm);
- FX_BOOL DoMouse(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm);
- FX_BOOL DoWheel(CFWL_MsgMouseWheel* pMsg, IFWL_Widget* pMessageForm);
- FX_BOOL DoSize(CFWL_MsgSize* pMsg);
- FX_BOOL DoWindowMove(CFWL_MsgWindowMove* pMsg, IFWL_Widget* pMessageForm);
- FX_BOOL DoDragFiles(CFWL_MsgDropFiles* pMsg, IFWL_Widget* pMessageForm);
- FX_BOOL DoMouseEx(CFWL_MsgMouse* pMsg, IFWL_Widget* pMessageForm);
- void MouseSecondary(CFWL_MsgMouse* pMsg);
- FX_BOOL IsValidMessage(CFWL_Message* pMessage);
- IFWL_Widget* GetMessageForm(IFWL_Widget* pDstTarget);
- void ClearInvalidEventTargets(FX_BOOL bRemoveAll);
- CFX_PtrArray m_forms;
- CFX_PtrArray m_noteQueue;
- CFX_PtrArray m_noteLoopQueue;
- CFX_MapPtrToPtr m_eventTargets;
- int32_t m_sendEventCalled;
- int32_t m_maxSize;
- FX_BOOL m_bFullScreen;
- IFWL_Widget* m_pHover;
- IFWL_Widget* m_pFocus;
- IFWL_Widget* m_pGrab;
- CFWL_NoteLoop* m_pNoteLoop;
- FWLMessageHookCallback m_hook;
- void* m_hookInfo;
-};
-typedef CFX_MapPtrTemplate<void*, FX_DWORD> CFWL_EventSource;
-class CFWL_EventTarget {
- public:
- CFWL_EventTarget(CFWL_NoteDriver* pNoteDriver, IFWL_Widget* pListener)
- : m_pListener(pListener), m_pNoteDriver(pNoteDriver), m_bInvalid(FALSE) {}
- ~CFWL_EventTarget();
- int32_t SetEventSource(IFWL_Widget* pSource,
- FX_DWORD dwFilter = FWL_EVENT_ALL_MASK);
- FX_BOOL ProcessEvent(CFWL_Event* pEvent);
- FX_BOOL IsFilterEvent(CFWL_Event* pEvent, FX_DWORD dwFilter);
- FX_BOOL IsInvalid() { return m_bInvalid; }
- void FlagInvalid() { m_bInvalid = TRUE; }
-
- protected:
- CFWL_EventSource m_eventSources;
- IFWL_Widget* m_pListener;
- CFWL_NoteDriver* m_pNoteDriver;
- FX_BOOL m_bInvalid;
-};
-class CFWL_ToolTipContainer {
- public:
- static CFWL_ToolTipContainer* getInstance();
- static void DeleteInstance();
-
- FX_ERR AddToolTipTarget(IFWL_ToolTipTarget* pTarget);
- FX_ERR RemoveToolTipTarget(IFWL_ToolTipTarget* pTarget);
- IFWL_ToolTipTarget* GetCurrentToolTipTarget();
-
- FX_BOOL HasToolTip(IFWL_Widget* pWidget);
-
- FX_BOOL ProcessEnter(CFWL_EvtMouse* pEvt, IFWL_Widget* pOwner);
- FX_BOOL ProcessLeave(CFWL_EvtMouse* pEvt);
-
- FX_ERR SetToolTipInitialDelay(int32_t iDelayTime);
- FX_ERR SetToolTipAutoPopDelay(int32_t iDelayTime);
-
- protected:
- CFWL_ToolTipContainer();
- virtual ~CFWL_ToolTipContainer();
-
- IFWL_ToolTipTarget* pCurTarget;
- CFWL_ToolTipImp* m_pToolTipImp;
- CFWL_CoreToopTipDP* m_ToolTipDp;
- CFX_PtrArray m_arrWidget;
-
- private:
- static CFWL_ToolTipContainer* s_pInstance;
-};
-
-#endif // XFA_SRC_FWL_CORE_FWL_NOTEIMP_H_
diff --git a/xfa/src/fwl/core/fwl_panelimp.cpp b/xfa/src/fwl/core/fwl_panelimp.cpp
deleted file mode 100644
index 7d6c8ee874..0000000000
--- a/xfa/src/fwl/core/fwl_panelimp.cpp
+++ /dev/null
@@ -1,152 +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/src/fwl/core/fwl_panelimp.h"
-
-#include "xfa/include/fwl/core/fwl_content.h"
-#include "xfa/include/fwl/core/fwl_grid.h"
-#include "xfa/include/fwl/core/fwl_panel.h"
-#include "xfa/src/fwl/core/fwl_noteimp.h"
-#include "xfa/src/fwl/core/fwl_targetimp.h"
-#include "xfa/src/fwl/core/fwl_widgetimp.h"
-#include "xfa/src/fwl/core/fwl_widgetmgrimp.h"
-
-// static
-IFWL_Panel* IFWL_Panel::Create(CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter) {
- IFWL_Panel* pPanel = new IFWL_Panel;
- CFWL_PanelImp* pPanelImpl = new CFWL_PanelImp(properties, pOuter);
- pPanel->SetImpl(pPanelImpl);
- pPanelImpl->SetInterface(pPanel);
- return pPanel;
-}
-IFWL_Panel::IFWL_Panel() {}
-IFWL_Content* IFWL_Panel::GetContent() {
- return static_cast<CFWL_PanelImp*>(GetImpl())->GetContent();
-}
-FWL_ERR IFWL_Panel::SetContent(IFWL_Content* pContent) {
- return static_cast<CFWL_PanelImp*>(GetImpl())->SetContent(pContent);
-}
-
-CFWL_PanelImp::CFWL_PanelImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter)
- : CFWL_WidgetImp(properties, pOuter), m_pContent(nullptr) {}
-CFWL_PanelImp::~CFWL_PanelImp() {}
-FWL_ERR CFWL_PanelImp::GetClassName(CFX_WideString& wsClass) const {
- wsClass = FWL_CLASS_Panel;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_PanelImp::GetClassID() const {
- return FWL_CLASSHASH_Panel;
-}
-FWL_ERR CFWL_PanelImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
- if (bAutoSize) {
- if (m_pContent) {
- m_pContent->GetWidgetRect(rect, TRUE);
- }
- } else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_PanelImp::Update() {
- if (m_pContent) {
- CFX_RectF rtClient;
- GetClientRect(rtClient);
- FWL_GRIDUNIT eWidth = FWL_GRIDUNIT_Fixed, eHeight = FWL_GRIDUNIT_Fixed;
- IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr();
- if (!pWidgetMgr)
- return FWL_ERR_Indefinite;
- IFWL_Widget* pParent =
- pWidgetMgr->GetWidget(GetInterface(), FWL_WGTRELATION_Parent);
- if (pParent && pParent->GetClassID() == FWL_CLASSHASH_Grid) {
- IFWL_Grid* pGrid = static_cast<IFWL_Grid*>(pParent);
- pGrid->GetWidgetSize(GetInterface(), FWL_GRIDSIZE_Width, eWidth);
- pGrid->GetWidgetSize(GetInterface(), FWL_GRIDSIZE_Height, eHeight);
- }
- m_pContent->SetWidgetRect(rtClient);
- m_pContent->Update();
- }
- return FWL_ERR_Succeeded;
-}
-IFWL_Content* CFWL_PanelImp::GetContent() {
- return m_pContent;
-}
-FWL_ERR CFWL_PanelImp::SetContent(IFWL_Content* pContent) {
- if (!pContent)
- return FWL_ERR_Indefinite;
- m_pContent = pContent;
- return pContent->SetParent(m_pInterface);
-}
-class CFWL_CustomPanelImp : public CFWL_WidgetImp {
- public:
- CFWL_CustomPanelImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter);
- virtual ~CFWL_CustomPanelImp();
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual IFWL_Content* GetContent();
- virtual FWL_ERR SetContent(IFWL_Content* pContent);
- FWL_ERR SetProxy(IFWL_Proxy* pProxy);
-
- protected:
- IFWL_Content* m_pContent;
- IFWL_Proxy* m_pProxy;
-};
-CFWL_CustomPanelImp::CFWL_CustomPanelImp(
- const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter)
- : CFWL_WidgetImp(properties, pOuter),
- m_pContent(nullptr),
- m_pProxy(nullptr) {}
-CFWL_CustomPanelImp::~CFWL_CustomPanelImp() {}
-FWL_ERR CFWL_CustomPanelImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
- if (bAutoSize && m_pProxy &&
- (m_pProxy->GetWidgetRect(rect, bAutoSize) == FWL_ERR_Succeeded)) {
- return FWL_ERR_Succeeded;
- }
- return CFWL_WidgetImp::GetWidgetRect(rect, bAutoSize);
-}
-FWL_ERR CFWL_CustomPanelImp::Update() {
- if (m_pProxy) {
- return m_pProxy->Update();
- }
- return CFWL_WidgetImp::Update();
-}
-IFWL_Content* CFWL_CustomPanelImp::GetContent() {
- return m_pContent;
-}
-FWL_ERR CFWL_CustomPanelImp::SetContent(IFWL_Content* pContent) {
- if (!pContent)
- return FWL_ERR_Indefinite;
- m_pContent = pContent;
- return pContent->SetParent(m_pInterface);
-}
-FWL_ERR CFWL_CustomPanelImp::SetProxy(IFWL_Proxy* pProxy) {
- m_pProxy = pProxy;
- return FWL_ERR_Succeeded;
-}
-
-// statuc
-IFWL_CustomPanel* IFWL_CustomPanel::Create(CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter) {
- IFWL_CustomPanel* pCustomPanel = new IFWL_CustomPanel;
- CFWL_CustomPanelImp* pCustomPanelImpl =
- new CFWL_CustomPanelImp(properties, pOuter);
- pCustomPanel->SetImpl(pCustomPanelImpl);
- pCustomPanelImpl->SetInterface(pCustomPanel);
- return pCustomPanel;
-}
-IFWL_CustomPanel::IFWL_CustomPanel() {}
-IFWL_Content* IFWL_CustomPanel::GetContent() {
- return static_cast<CFWL_CustomPanelImp*>(GetImpl())->GetContent();
-}
-FWL_ERR IFWL_CustomPanel::SetContent(IFWL_Content* pContent) {
- return static_cast<CFWL_CustomPanelImp*>(GetImpl())->SetContent(pContent);
-}
-FWL_ERR IFWL_CustomPanel::SetProxy(IFWL_Proxy* pProxy) {
- return static_cast<CFWL_CustomPanelImp*>(GetImpl())->SetProxy(pProxy);
-}
diff --git a/xfa/src/fwl/core/fwl_panelimp.h b/xfa/src/fwl/core/fwl_panelimp.h
deleted file mode 100644
index 1bd7159054..0000000000
--- a/xfa/src/fwl/core/fwl_panelimp.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_SRC_FWL_CORE_FWL_PANELIMP_H_
-#define XFA_SRC_FWL_CORE_FWL_PANELIMP_H_
-
-#include "xfa/src/fwl/core/fwl_widgetimp.h"
-
-class CFWL_WidgetImpProperties;
-class IFWL_Widget;
-class IFWL_Content;
-
-class CFWL_PanelImp : public CFWL_WidgetImp {
- public:
- CFWL_PanelImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter);
- virtual ~CFWL_PanelImp();
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual IFWL_Content* GetContent();
- virtual FWL_ERR SetContent(IFWL_Content* pContent);
-
- protected:
- IFWL_Content* m_pContent;
-};
-
-#endif // XFA_SRC_FWL_CORE_FWL_PANELIMP_H_
diff --git a/xfa/src/fwl/core/fwl_sdadapterimp.cpp b/xfa/src/fwl/core/fwl_sdadapterimp.cpp
deleted file mode 100644
index fedd6b285d..0000000000
--- a/xfa/src/fwl/core/fwl_sdadapterimp.cpp
+++ /dev/null
@@ -1,175 +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/adapter/fwl_sdadapterimp.h"
-
-#include "core/include/fxcrt/fx_system.h"
-#include "xfa/include/fwl/adapter/fwl_adapterthreadmgr.h"
-#include "xfa/include/fwl/adapter/fwl_adapterwidgetmgr.h"
-#include "xfa/include/fwl/core/fwl_app.h"
-#include "xfa/src/fwl/core/fwl_noteimp.h"
-#include "xfa/src/fwl/core/fwl_targetimp.h"
-#include "xfa/src/fwl/core/fwl_threadimp.h"
-#include "xfa/src/fwl/core/fwl_widgetmgrimp.h"
-
-CFWL_SDAdapterWidgetMgr::CFWL_SDAdapterWidgetMgr() {}
-CFWL_SDAdapterWidgetMgr::~CFWL_SDAdapterWidgetMgr() {}
-
-FWL_ERR CFWL_SDAdapterWidgetMgr::CreateWidget(IFWL_Widget* pWidget,
- IFWL_Widget* pParent) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::DestroyWidget(IFWL_Widget* pWidget) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetWidgetRect(IFWL_Widget* pWidget,
- const CFX_RectF& rect) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetWidgetPosition(IFWL_Widget* pWidget,
- FX_FLOAT fx,
- FX_FLOAT fy) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetParentWidget(IFWL_Widget* pWidget,
- IFWL_Widget* pParent) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::ShowWidget(IFWL_Widget* pWidget) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::HideWidget(IFWL_Widget* pWidget) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetNormal(IFWL_Widget* pWidget) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetMaximize(IFWL_Widget* pWidget) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetMinimize(IFWL_Widget* pWidget) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::RunWidget(IFWL_Widget* pWidget) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::RepaintWidget(IFWL_Widget* pWidget,
- const CFX_RectF* pRect) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::Exit(int32_t iExitCode) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::CreateWidgetWithNativeId(IFWL_Widget* pWidget,
- void* vp) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::GetWidgetRect(IFWL_Widget* pWidget,
- CFX_RectF& rect) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetWidgetIcon(IFWL_Widget* pWidget,
- const CFX_DIBitmap* pIcon,
- FX_BOOL bBig) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetWidgetCaption(
- IFWL_Widget* pWidget,
- const CFX_WideStringC& wsCaption) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetBorderRegion(IFWL_Widget* pWidget,
- CFX_Path* pPath) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetTransparent(IFWL_Widget* pWidget,
- FX_DWORD dwAlpha) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetFullScreen(IFWL_Widget* pWidget,
- FX_BOOL bFullScreen) {
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_SDAdapterWidgetMgr::CheckMessage() {
- return TRUE;
-}
-FX_BOOL CFWL_SDAdapterWidgetMgr::IsIdleMessage() {
- return TRUE;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::DispatchMessage() {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::GetWidgetDC(IFWL_Widget* pWidget, void*& pDC) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::ReleaseWidgetDC(IFWL_Widget* pWidget,
- void* pDC,
- CFX_RectF* pClip) {
- return FWL_ERR_Succeeded;
-}
-void* CFWL_SDAdapterWidgetMgr::GetWindow(IFWL_Widget* pWidget) {
- return NULL;
-}
-FX_DWORD CFWL_SDAdapterWidgetMgr::GetKeyState(FX_DWORD dwVirtKey) {
- return 0;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::RunLoop(IFWL_Widget* widget) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::EndLoop() {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::InitMenu(IFWL_Menu* pMenu,
- IFWL_MenuDP* pMenuData) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::UpdateMenu(IFWL_Menu* pMenu,
- const void* hItem,
- int32_t iType) {
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_SDAdapterWidgetMgr::TrackPopupMenu(IFWL_Menu* pMenu,
- IFWL_MenuDP* pMenuData) {
- return 0;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::SetMessageHook(IFWL_AdapterMessageHook* hook) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterWidgetMgr::GetSystemBorder(FX_FLOAT& l,
- FX_FLOAT& t,
- FX_FLOAT& r,
- FX_FLOAT& b) {
- return FWL_ERR_Succeeded;
-}
-FX_BOOL CFWL_SDAdapterWidgetMgr::GetPopupPos(IFWL_Widget* pWidget,
- FX_FLOAT fMinHeight,
- FX_FLOAT fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup) {
- return FWL_ERR_Succeeded;
-}
-CFWL_SDAdapterThreadMgr::CFWL_SDAdapterThreadMgr() {}
-CFWL_SDAdapterThreadMgr::~CFWL_SDAdapterThreadMgr() {}
-FWL_ERR CFWL_SDAdapterThreadMgr::Start(IFWL_Thread* pThread,
- FWL_HTHREAD& hThread,
- FX_BOOL bSuspended) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterThreadMgr::Resume(FWL_HTHREAD hThread) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterThreadMgr::Suspend(FWL_HTHREAD hThread) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterThreadMgr::Kill(FWL_HTHREAD hThread, int32_t iExitCode) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_SDAdapterThreadMgr::Stop(FWL_HTHREAD hThread, int32_t iExitCode) {
- return FWL_ERR_Succeeded;
-}
-IFWL_Thread* CFWL_SDAdapterThreadMgr::GetCurrentThread() {
- return FWL_GetApp();
-}
diff --git a/xfa/src/fwl/core/fwl_targetimp.cpp b/xfa/src/fwl/core/fwl_targetimp.cpp
deleted file mode 100644
index 0c8d5fbce0..0000000000
--- a/xfa/src/fwl/core/fwl_targetimp.cpp
+++ /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
-
-#include "xfa/src/fwl/core/fwl_targetimp.h"
-
-FWL_ERR IFWL_Target::GetClassName(CFX_WideString& wsClass) const {
- return m_pImpl->GetClassName(wsClass);
-}
-FX_DWORD IFWL_Target::GetClassID() const {
- return m_pImpl->GetClassID();
-}
-FX_BOOL IFWL_Target::IsInstance(const CFX_WideStringC& wsClass) const {
- return m_pImpl->IsInstance(wsClass);
-}
-FWL_ERR IFWL_Target::Initialize() {
- return m_pImpl->Initialize();
-}
-FWL_ERR IFWL_Target::Finalize() {
- return m_pImpl->Finalize();
-}
-IFWL_Target::~IFWL_Target() {
- delete m_pImpl;
-}
-CFWL_TargetImp::CFWL_TargetImp() {}
-CFWL_TargetImp::~CFWL_TargetImp() {}
-FWL_ERR CFWL_TargetImp::GetClassName(CFX_WideString& wsClass) const {
- wsClass.Empty();
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_TargetImp::GetClassID() const {
- return 0;
-}
-FX_BOOL CFWL_TargetImp::IsInstance(const CFX_WideStringC& wsClass) const {
- return FALSE;
-}
-FWL_ERR CFWL_TargetImp::Initialize() {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_TargetImp::Finalize() {
- return FWL_ERR_Succeeded;
-}
diff --git a/xfa/src/fwl/core/fwl_targetimp.h b/xfa/src/fwl/core/fwl_targetimp.h
deleted file mode 100644
index e243d39e9b..0000000000
--- a/xfa/src/fwl/core/fwl_targetimp.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_SRC_FWL_CORE_FWL_TARGETIMP_H_
-#define XFA_SRC_FWL_CORE_FWL_TARGETIMP_H_
-
-#include "core/include/fxcrt/fx_basic.h"
-#include "xfa/include/fwl/core/fwl_target.h"
-
-class CFWL_TargetImp {
- public:
- virtual ~CFWL_TargetImp();
-
- virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
- virtual FX_DWORD GetClassID() const;
- virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
-
- protected:
- CFWL_TargetImp();
-};
-
-#endif // XFA_SRC_FWL_CORE_FWL_TARGETIMP_H_
diff --git a/xfa/src/fwl/core/fwl_threadimp.cpp b/xfa/src/fwl/core/fwl_threadimp.cpp
deleted file mode 100644
index 28df34eade..0000000000
--- a/xfa/src/fwl/core/fwl_threadimp.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/src/fwl/core/fwl_threadimp.h"
-
-#include "xfa/src/fwl/core/fwl_appimp.h"
-#include "xfa/src/fwl/core/fwl_noteimp.h"
-#include "xfa/src/fwl/core/fwl_targetimp.h"
-
-void IFWL_Thread::Release() {
- delete m_pImpl;
-}
-FWL_ERR IFWL_Thread::Run(FWL_HTHREAD hThread) {
- return m_pImpl->Run(hThread);
-}
-IFWL_NoteDriver* IFWL_NoteThread::GetNoteDriver() {
- return static_cast<CFWL_NoteThreadImp*>(GetImpl())->GetNoteDriver();
-}
-
-FWL_ERR CFWL_ThreadImp::Run(FWL_HTHREAD hThread) {
- return FWL_ERR_Succeeded;
-}
-CFWL_NoteThreadImp::CFWL_NoteThreadImp(IFWL_NoteThread* pIface)
- : CFWL_ThreadImp(pIface), m_pNoteDriver(new CFWL_NoteDriver) {}
-CFWL_NoteThreadImp::~CFWL_NoteThreadImp() {
- delete m_pNoteDriver;
-}
-FWL_ERR CFWL_NoteThreadImp::Run(FWL_HTHREAD hThread) {
- if (!m_pNoteDriver)
- return FWL_ERR_Indefinite;
- return m_pNoteDriver->Run();
-}
-IFWL_NoteDriver* CFWL_NoteThreadImp::GetNoteDriver() {
- return m_pNoteDriver;
-}
diff --git a/xfa/src/fwl/core/fwl_threadimp.h b/xfa/src/fwl/core/fwl_threadimp.h
deleted file mode 100644
index eaf30e6350..0000000000
--- a/xfa/src/fwl/core/fwl_threadimp.h
+++ /dev/null
@@ -1,40 +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_SRC_FWL_CORE_FWL_THREADIMP_H_
-#define XFA_SRC_FWL_CORE_FWL_THREADIMP_H_
-
-#include "xfa/include/fwl/core/fwl_thread.h" // For FWL_HTHREAD.
-
-class CFWL_NoteDriver;
-class IFWL_NoteDriver;
-
-class CFWL_ThreadImp {
- public:
- virtual ~CFWL_ThreadImp() {}
- IFWL_Thread* GetInterface() const { return m_pIface; }
- virtual FWL_ERR Run(FWL_HTHREAD hThread);
-
- protected:
- CFWL_ThreadImp(IFWL_Thread* pIface) : m_pIface(pIface) {}
-
- private:
- IFWL_Thread* const m_pIface;
-};
-
-class CFWL_NoteThreadImp : public CFWL_ThreadImp {
- public:
- CFWL_NoteThreadImp(IFWL_NoteThread* pIface);
- virtual ~CFWL_NoteThreadImp();
-
- FWL_ERR Run(FWL_HTHREAD hThread) override;
- virtual IFWL_NoteDriver* GetNoteDriver();
-
- protected:
- CFWL_NoteDriver* const m_pNoteDriver;
-};
-
-#endif // XFA_SRC_FWL_CORE_FWL_THREADIMP_H_
diff --git a/xfa/src/fwl/core/fwl_timerimp.cpp b/xfa/src/fwl/core/fwl_timerimp.cpp
deleted file mode 100644
index 503c0f759e..0000000000
--- a/xfa/src/fwl/core/fwl_timerimp.cpp
+++ /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
-
-#include "xfa/include/fwl/adapter/fwl_adapternative.h"
-#include "xfa/include/fwl/adapter/fwl_adaptertimermgr.h"
-#include "xfa/include/fwl/core/fwl_app.h"
-#include "xfa/include/fwl/core/fwl_timer.h"
-#include "xfa/src/fwl/core/fwl_appimp.h"
-#include "xfa/src/fwl/core/fwl_targetimp.h"
-#include "xfa/src/fwl/core/fwl_threadimp.h"
-
-FWL_HTIMER FWL_StartTimer(IFWL_Timer* pTimer,
- FX_DWORD dwElapse,
- FX_BOOL bImmediately) {
- IFWL_AdapterNative* pAdapterNative = FWL_GetAdapterNative();
- if (!pAdapterNative)
- return NULL;
- IFWL_AdapterTimerMgr* pAdapterTimerMgr = pAdapterNative->GetTimerMgr();
- if (!pAdapterTimerMgr)
- return NULL;
- FWL_HTIMER hTimer = NULL;
- pAdapterTimerMgr->Start(pTimer, dwElapse, hTimer, bImmediately);
- return hTimer;
-}
-int32_t FWL_StopTimer(FWL_HTIMER hTimer) {
- IFWL_AdapterNative* pAdapterNative = FWL_GetAdapterNative();
- if (!pAdapterNative)
- return FWL_ERR_Indefinite;
- IFWL_AdapterTimerMgr* pAdapterTimerMgr = pAdapterNative->GetTimerMgr();
- if (!pAdapterTimerMgr)
- return FWL_ERR_Indefinite;
- return pAdapterTimerMgr->Stop(hTimer);
-}
diff --git a/xfa/src/fwl/core/fwl_widgetimp.cpp b/xfa/src/fwl/core/fwl_widgetimp.cpp
deleted file mode 100644
index 32d80d1fb3..0000000000
--- a/xfa/src/fwl/core/fwl_widgetimp.cpp
+++ /dev/null
@@ -1,1101 +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/src/fwl/core/fwl_widgetimp.h"
-
-#include <algorithm>
-
-#include "xfa/include/fwl/adapter/fwl_adapternative.h"
-#include "xfa/include/fwl/adapter/fwl_adapterthreadmgr.h"
-#include "xfa/include/fwl/adapter/fwl_adapterwidgetmgr.h"
-#include "xfa/include/fwl/basewidget/fwl_combobox.h"
-#include "xfa/include/fwl/basewidget/fwl_datetimepicker.h"
-#include "xfa/include/fwl/basewidget/fwl_menu.h"
-#include "xfa/include/fwl/core/fwl_app.h"
-#include "xfa/include/fwl/core/fwl_content.h"
-#include "xfa/include/fwl/core/fwl_form.h"
-#include "xfa/include/fwl/core/fwl_theme.h"
-#include "xfa/src/fde/tto/fde_textout.h"
-#include "xfa/src/fwl/core/fwl_appimp.h"
-#include "xfa/src/fwl/core/fwl_noteimp.h"
-#include "xfa/src/fwl/core/fwl_targetimp.h"
-#include "xfa/src/fwl/core/fwl_threadimp.h"
-#include "xfa/src/fwl/core/fwl_widgetmgrimp.h"
-
-FWL_ERR IFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())
- ->GetWidgetRect(rect, bAutoSize);
-}
-FWL_ERR IFWL_Widget::GetGlobalRect(CFX_RectF& rect) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->GetGlobalRect(rect);
-}
-FWL_ERR IFWL_Widget::SetWidgetRect(const CFX_RectF& rect) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->SetWidgetRect(rect);
-}
-FWL_ERR IFWL_Widget::GetClientRect(CFX_RectF& rect) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->GetClientRect(rect);
-}
-IFWL_Widget* IFWL_Widget::GetParent() {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->GetParent();
-}
-FWL_ERR IFWL_Widget::SetParent(IFWL_Widget* pParent) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->SetParent(pParent);
-}
-IFWL_Widget* IFWL_Widget::GetOwner() {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOwner();
-}
-FWL_ERR IFWL_Widget::SetOwner(IFWL_Widget* pOwner) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->SetOwner(pOwner);
-}
-IFWL_Widget* IFWL_Widget::GetOuter() {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOuter();
-}
-FX_DWORD IFWL_Widget::GetStyles() {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStyles();
-}
-FWL_ERR IFWL_Widget::ModifyStyles(FX_DWORD dwStylesAdded,
- FX_DWORD dwStylesRemoved) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())
- ->ModifyStyles(dwStylesAdded, dwStylesRemoved);
-}
-FX_DWORD IFWL_Widget::GetStylesEx() {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStylesEx();
-}
-FWL_ERR IFWL_Widget::ModifyStylesEx(FX_DWORD dwStylesExAdded,
- FX_DWORD dwStylesExRemoved) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())
- ->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
-}
-FX_DWORD IFWL_Widget::GetStates() {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->GetStates();
-}
-FWL_ERR IFWL_Widget::SetStates(FX_DWORD dwStates, FX_BOOL bSet) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->SetStates(dwStates, bSet);
-}
-FWL_ERR IFWL_Widget::SetPrivateData(void* module_id,
- void* pData,
- PD_CALLBACK_FREEDATA callback) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())
- ->SetPrivateData(module_id, pData, callback);
-}
-void* IFWL_Widget::GetPrivateData(void* module_id) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->GetPrivateData(module_id);
-}
-FWL_ERR IFWL_Widget::Update() {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->Update();
-}
-FWL_ERR IFWL_Widget::LockUpdate() {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->LockUpdate();
-}
-FWL_ERR IFWL_Widget::UnlockUpdate() {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->UnlockUpdate();
-}
-FX_DWORD IFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->HitTest(fx, fy);
-}
-FWL_ERR IFWL_Widget::TransformTo(IFWL_Widget* pWidget,
- FX_FLOAT& fx,
- FX_FLOAT& fy) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->TransformTo(pWidget, fx, fy);
-}
-FWL_ERR IFWL_Widget::TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->TransformTo(pWidget, rt);
-}
-FWL_ERR IFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->GetMatrix(matrix, bGlobal);
-}
-FWL_ERR IFWL_Widget::SetMatrix(const CFX_Matrix& matrix) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->SetMatrix(matrix);
-}
-FWL_ERR IFWL_Widget::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())
- ->DrawWidget(pGraphics, pMatrix);
-}
-IFWL_ThemeProvider* IFWL_Widget::GetThemeProvider() {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->GetThemeProvider();
-}
-FWL_ERR IFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())
- ->SetThemeProvider(pThemeProvider);
-}
-FWL_ERR IFWL_Widget::SetDataProvider(IFWL_DataProvider* pDataProvider) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())
- ->SetDataProvider(pDataProvider);
-}
-IFWL_WidgetDelegate* IFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->SetDelegate(pDelegate);
-}
-IFWL_NoteThread* IFWL_Widget::GetOwnerThread() const {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOwnerThread();
-}
-CFX_SizeF IFWL_Widget::GetOffsetFromParent(IFWL_Widget* pParent) {
- return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOffsetFromParent(pParent);
-}
-FWL_ERR CFWL_WidgetImp::Initialize() {
- IFWL_App* pApp = FWL_GetApp();
- if (!pApp)
- return FWL_ERR_Indefinite;
- IFWL_AdapterNative* pAdapter = pApp->GetAdapterNative();
- if (!pAdapter)
- return FWL_ERR_Indefinite;
- IFWL_AdapterThreadMgr* pAdapterThread = pAdapter->GetThreadMgr();
- if (!pAdapterThread)
- return FWL_ERR_Indefinite;
- SetOwnerThread(static_cast<CFWL_NoteThreadImp*>(
- pAdapterThread->GetCurrentThread()->GetImpl()));
- IFWL_Widget* pParent = m_pProperties->m_pParent;
- m_pWidgetMgr->InsertWidget(pParent, m_pInterface);
- if (!IsChild()) {
- {
- IFWL_Widget* pOwner = m_pProperties->m_pOwner;
- if (pOwner) {
- m_pWidgetMgr->SetOwner(pOwner, m_pInterface);
- }
- }
- m_pWidgetMgr->CreateWidget_Native(m_pInterface);
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetImp::Finalize() {
- NotifyDriver();
- IFWL_Form* pForm = static_cast<IFWL_Form*>(
- FWL_GetWidgetMgr()->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm));
- if (pForm && pForm != m_pInterface) {
- IFWL_Content* pContent = pForm->GetContent();
- if (pContent) {
- pContent->RemoveWidget(m_pInterface);
- }
- }
- if (!IsChild()) {
- m_pWidgetMgr->DestroyWidget_Native(m_pInterface);
- }
- m_pWidgetMgr->RemoveWidget(m_pInterface);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
- if (bAutoSize) {
- if (HasEdge()) {
- FX_FLOAT fEdge = GetEdgeWidth();
- rect.Inflate(fEdge, fEdge);
- }
- if (HasBorder()) {
- FX_FLOAT fBorder = GetBorderSize();
- rect.Inflate(fBorder, fBorder);
- }
- } else {
- rect = m_pProperties->m_rtWidget;
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetImp::GetGlobalRect(CFX_RectF& rect) {
- IFWL_Widget* pForm =
- m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm);
- if (!pForm)
- return FWL_ERR_Indefinite;
- rect.Set(0, 0, m_pProperties->m_rtWidget.width,
- m_pProperties->m_rtWidget.height);
- if (pForm == m_pInterface) {
- return FWL_ERR_Succeeded;
- }
- return TransformTo(pForm, rect);
-}
-FWL_ERR CFWL_WidgetImp::SetWidgetRect(const CFX_RectF& rect) {
- CFX_RectF rtOld = m_pProperties->m_rtWidget;
- m_pProperties->m_rtWidget = rect;
- if (IsChild()) {
- if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f ||
- FXSYS_fabs(rtOld.height - rect.height) > 0.5f) {
- CFWL_EvtSizeChanged ev;
- ev.m_pSrcTarget = m_pInterface;
- ev.m_rtOld = rtOld;
- ev.m_rtNew = rect;
- IFWL_WidgetDelegate* pDelegate = SetDelegate(NULL);
- if (pDelegate) {
- pDelegate->OnProcessEvent(&ev);
- }
- }
- return FWL_ERR_Succeeded;
- }
- m_pWidgetMgr->SetWidgetRect_Native(m_pInterface, rect);
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetImp::GetClientRect(CFX_RectF& rect) {
- GetEdgeRect(rect);
- if (HasEdge()) {
- FX_FLOAT fEdge = GetEdgeWidth();
- rect.Deflate(fEdge, fEdge);
- }
- return FWL_ERR_Succeeded;
-}
-IFWL_Widget* CFWL_WidgetImp::GetParent() {
- return m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_Parent);
-}
-FWL_ERR CFWL_WidgetImp::SetParent(IFWL_Widget* pParent) {
- m_pProperties->m_pParent = pParent;
- m_pWidgetMgr->SetParent(pParent, m_pInterface);
- return FWL_ERR_Succeeded;
-}
-IFWL_Widget* CFWL_WidgetImp::GetOwner() {
- return m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_Owner);
-}
-FWL_ERR CFWL_WidgetImp::SetOwner(IFWL_Widget* pOwner) {
- m_pProperties->m_pOwner = pOwner;
- m_pWidgetMgr->SetOwner(pOwner, m_pInterface);
- return FWL_ERR_Succeeded;
-}
-IFWL_Widget* CFWL_WidgetImp::GetOuter() {
- return m_pOuter;
-}
-FX_DWORD CFWL_WidgetImp::GetStyles() {
- return m_pProperties->m_dwStyles;
-}
-FWL_ERR CFWL_WidgetImp::ModifyStyles(FX_DWORD dwStylesAdded,
- FX_DWORD dwStylesRemoved) {
- m_pProperties->m_dwStyles =
- (m_pProperties->m_dwStyles & ~dwStylesRemoved) | dwStylesAdded;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_WidgetImp::GetStylesEx() {
- return m_pProperties->m_dwStyleExes;
-}
-FWL_ERR CFWL_WidgetImp::ModifyStylesEx(FX_DWORD dwStylesExAdded,
- FX_DWORD dwStylesExRemoved) {
- m_pProperties->m_dwStyleExes =
- (m_pProperties->m_dwStyleExes & ~dwStylesExRemoved) | dwStylesExAdded;
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_WidgetImp::GetStates() {
- return m_pProperties->m_dwStates;
-}
-static void NotifyHideChildWidget(IFWL_WidgetMgr* widgetMgr,
- IFWL_Widget* widget,
- CFWL_NoteDriver* noteDriver) {
- IFWL_Widget* child = widgetMgr->GetWidget(widget, FWL_WGTRELATION_FirstChild);
- while (child) {
- noteDriver->NotifyTargetHide(child);
- NotifyHideChildWidget(widgetMgr, child, noteDriver);
- child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
- }
-}
-FWL_ERR CFWL_WidgetImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet) {
- bSet ? (m_pProperties->m_dwStates |= dwStates)
- : (m_pProperties->m_dwStates &= ~dwStates);
- FWL_ERR ret = FWL_ERR_Succeeded;
- if (dwStates & FWL_WGTSTATE_Invisible) {
- if (bSet) {
- ret = m_pWidgetMgr->HideWidget_Native(m_pInterface);
- CFWL_NoteDriver* noteDriver =
- static_cast<CFWL_NoteDriver*>(GetOwnerThread()->GetNoteDriver());
- IFWL_WidgetMgr* widgetMgr = FWL_GetWidgetMgr();
- noteDriver->NotifyTargetHide(m_pInterface);
- IFWL_Widget* child =
- widgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_FirstChild);
- while (child) {
- noteDriver->NotifyTargetHide(child);
- NotifyHideChildWidget(widgetMgr, child, noteDriver);
- child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
- }
- } else {
- ret = m_pWidgetMgr->ShowWidget_Native(m_pInterface);
- }
- }
- return ret;
-}
-FWL_ERR CFWL_WidgetImp::SetPrivateData(void* module_id,
- void* pData,
- PD_CALLBACK_FREEDATA callback) {
- if (!m_pPrivateData) {
- m_pPrivateData = new CFX_PrivateData;
- }
- m_pPrivateData->SetPrivateData(module_id, pData, callback);
- return FWL_ERR_Succeeded;
-}
-void* CFWL_WidgetImp::GetPrivateData(void* module_id) {
- if (!m_pPrivateData)
- return NULL;
- return m_pPrivateData->GetPrivateData(module_id);
-}
-FWL_ERR CFWL_WidgetImp::Update() {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetImp::LockUpdate() {
- m_iLock++;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetImp::UnlockUpdate() {
- if (IsLocked()) {
- m_iLock--;
- }
- return FWL_ERR_Succeeded;
-}
-FX_DWORD CFWL_WidgetImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
- CFX_RectF rtClient;
- GetClientRect(rtClient);
- if (rtClient.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
- }
- if (HasEdge()) {
- CFX_RectF rtEdge;
- GetEdgeRect(rtEdge);
- if (rtEdge.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Edge;
- }
- }
- if (HasBorder()) {
- CFX_RectF rtRelative;
- GetRelativeRect(rtRelative);
- if (rtRelative.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Border;
- }
- }
- return FWL_WGTHITTEST_Unknown;
-}
-FWL_ERR CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget,
- FX_FLOAT& fx,
- FX_FLOAT& fy) {
- if (m_pWidgetMgr->IsFormDisabled()) {
- CFX_SizeF szOffset;
- if (IsParent(pWidget)) {
- szOffset = GetOffsetFromParent(pWidget);
- } else {
- szOffset = pWidget->GetOffsetFromParent(m_pInterface);
- szOffset.x = -szOffset.x;
- szOffset.y = -szOffset.y;
- }
- fx += szOffset.x;
- fy += szOffset.y;
- return FWL_ERR_Succeeded;
- }
- CFX_RectF r;
- CFX_Matrix m;
- IFWL_Widget* parent = GetParent();
- if (parent) {
- GetWidgetRect(r);
- fx += r.left;
- fy += r.top;
- GetMatrix(m, TRUE);
- m.TransformPoint(fx, fy);
- }
- IFWL_Widget* form1 =
- m_pWidgetMgr->GetWidget(m_pInterface, FWL_WGTRELATION_SystemForm);
- if (!form1)
- return FWL_ERR_Indefinite;
- if (!pWidget) {
- form1->GetWidgetRect(r);
- fx += r.left;
- fy += r.top;
-#ifdef FWL_UseMacSystemBorder
- if (form1->GetStyles() & FWL_WGTSTYLE_Caption) {
- FX_FLOAT l, t, r, b;
- l = t = r = b = 0;
- FWL_GetAdapterWidgetMgr()->GetSystemBorder(l, t, r, b);
- fy += t;
- }
-#endif
- return FWL_ERR_Succeeded;
- }
- IFWL_Widget* form2 =
- m_pWidgetMgr->GetWidget(pWidget, FWL_WGTRELATION_SystemForm);
- if (!form2)
- return FWL_ERR_Indefinite;
- if (form1 != form2) {
- form1->GetWidgetRect(r);
- fx += r.left;
- fy += r.top;
- form2->GetWidgetRect(r);
- fx -= r.left;
- fy -= r.top;
-#ifdef FWL_UseMacSystemBorder
- if ((form1->GetStyles() & FWL_WGTSTYLE_Caption) !=
- (form2->GetStyles() & FWL_WGTSTYLE_Caption)) {
- FX_FLOAT l, t, r, b;
- l = t = r = b = 0;
- FWL_GetAdapterWidgetMgr()->GetSystemBorder(l, t, r, b);
- (form1->GetStyles() & FWL_WGTSTYLE_Caption) ? (fy += t) : (fy -= t);
- }
-#endif
- }
- parent = pWidget->GetParent();
- if (parent) {
- pWidget->GetMatrix(m, TRUE);
- CFX_Matrix m1;
- m1.SetIdentity();
- m1.SetReverse(m);
- m1.TransformPoint(fx, fy);
- pWidget->GetWidgetRect(r);
- fx -= r.left;
- fy -= r.top;
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt) {
- return TransformTo(pWidget, rt.left, rt.top);
-}
-FWL_ERR CFWL_WidgetImp::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) {
- if (!m_pProperties)
- return FWL_ERR_Indefinite;
- if (bGlobal) {
- IFWL_Widget* parent = GetParent();
- CFX_PtrArray parents;
- while (parent) {
- parents.Add(parent);
- parent = parent->GetParent();
- }
- matrix.SetIdentity();
- CFX_Matrix ctmOnParent;
- CFX_RectF rect;
- int32_t count = parents.GetSize();
- for (int32_t i = count - 2; i >= 0; i--) {
- parent = static_cast<IFWL_Widget*>(parents.GetAt(i));
- parent->GetMatrix(ctmOnParent, FALSE);
- parent->GetWidgetRect(rect);
- matrix.Concat(ctmOnParent, TRUE);
- matrix.Translate(rect.left, rect.top, TRUE);
- }
- matrix.Concat(m_pProperties->m_ctmOnParent, TRUE);
- parents.RemoveAll();
- } else {
- matrix = m_pProperties->m_ctmOnParent;
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetImp::SetMatrix(const CFX_Matrix& matrix) {
- if (!m_pProperties)
- return FWL_ERR_Indefinite;
- IFWL_Widget* parent = GetParent();
- if (!parent) {
- return FWL_ERR_Indefinite;
- }
- m_pProperties->m_ctmOnParent = matrix;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetImp::DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- return FWL_ERR_Indefinite;
-}
-IFWL_ThemeProvider* CFWL_WidgetImp::GetThemeProvider() {
- return m_pProperties->m_pThemeProvider;
-}
-FWL_ERR CFWL_WidgetImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
- m_pProperties->m_pThemeProvider = pThemeProvider;
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetImp::SetDataProvider(IFWL_DataProvider* pDataProvider) {
- m_pProperties->m_pDataProvider = pDataProvider;
- return FWL_ERR_Succeeded;
-}
-IFWL_WidgetDelegate* CFWL_WidgetImp::SetDelegate(
- IFWL_WidgetDelegate* pDelegate) {
- if (!m_pCurDelegate) {
- m_pCurDelegate = m_pDelegate;
- }
- if (!pDelegate) {
- return m_pCurDelegate;
- }
- IFWL_WidgetDelegate* pOldDelegate = m_pCurDelegate;
- m_pCurDelegate = pDelegate;
- return pOldDelegate;
-}
-IFWL_NoteThread* CFWL_WidgetImp::GetOwnerThread() const {
- return static_cast<IFWL_NoteThread*>(m_pOwnerThread->GetInterface());
-}
-FWL_ERR CFWL_WidgetImp::SetOwnerThread(CFWL_NoteThreadImp* pOwnerThread) {
- m_pOwnerThread = pOwnerThread;
- return FWL_ERR_Succeeded;
-}
-IFWL_Widget* CFWL_WidgetImp::GetInterface() const {
- return m_pInterface;
-}
-void CFWL_WidgetImp::SetInterface(IFWL_Widget* pInterface) {
- m_pInterface = pInterface;
-}
-CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter)
- : m_pProperties(new CFWL_WidgetImpProperties),
- m_pPrivateData(NULL),
- m_pDelegate(NULL),
- m_pCurDelegate(NULL),
- m_pOuter(pOuter),
- m_pInterface(NULL),
- m_iLock(0) {
- *m_pProperties = properties;
- m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- FXSYS_assert(m_pWidgetMgr != NULL);
-}
-CFWL_WidgetImp::~CFWL_WidgetImp() {
- if (m_pPrivateData) {
- delete m_pPrivateData;
- m_pPrivateData = NULL;
- }
- if (m_pProperties) {
- delete m_pProperties;
- m_pProperties = NULL;
- }
-}
-FX_BOOL CFWL_WidgetImp::IsEnabled() const {
- return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0;
-}
-FX_BOOL CFWL_WidgetImp::IsVisible() const {
- return (m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) == 0;
-}
-FX_BOOL CFWL_WidgetImp::IsActive() const {
- return (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) == 0;
-}
-FX_BOOL CFWL_WidgetImp::IsOverLapper() const {
- return (m_pProperties->m_dwStyles & FWL_WGTSTYLE_WindowTypeMask) ==
- FWL_WGTSTYLE_OverLapper;
-}
-FX_BOOL CFWL_WidgetImp::IsPopup() const {
- return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Popup);
-}
-FX_BOOL CFWL_WidgetImp::IsChild() const {
- return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Child);
-}
-FX_BOOL CFWL_WidgetImp::IsLocked() const {
- return m_iLock > 0;
-}
-FX_BOOL CFWL_WidgetImp::IsOffscreen() const {
- return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Offscreen);
-}
-FX_BOOL CFWL_WidgetImp::HasBorder() const {
- return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border);
-}
-FX_BOOL CFWL_WidgetImp::HasEdge() const {
- return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_EdgeMask);
-}
-void CFWL_WidgetImp::GetEdgeRect(CFX_RectF& rtEdge) {
- rtEdge = m_pProperties->m_rtWidget;
- rtEdge.left = rtEdge.top = 0;
- if (HasBorder()) {
- FX_FLOAT fCX = GetBorderSize();
- FX_FLOAT fCY = GetBorderSize(FALSE);
- rtEdge.Deflate(fCX, fCY);
- }
-}
-FX_FLOAT CFWL_WidgetImp::GetBorderSize(FX_BOOL bCX) {
- FX_FLOAT* pfBorder = static_cast<FX_FLOAT*>(GetThemeCapacity(
- bCX ? FWL_WGTCAPACITY_CXBorder : FWL_WGTCAPACITY_CYBorder));
- if (!pfBorder)
- return 0;
- return *pfBorder;
-}
-FX_FLOAT CFWL_WidgetImp::GetEdgeWidth() {
- FX_DWORD dwCapacity = 0;
- switch (m_pProperties->m_dwStyles & FWL_WGTSTYLE_EdgeMask) {
- case FWL_WGTSTYLE_EdgeFlat: {
- dwCapacity = FWL_WGTCAPACITY_EdgeFlat;
- break;
- }
- case FWL_WGTSTYLE_EdgeRaised: {
- dwCapacity = FWL_WGTCAPACITY_EdgeRaised;
- break;
- }
- case FWL_WGTSTYLE_EdgeSunken: {
- dwCapacity = FWL_WGTCAPACITY_EdgeSunken;
- break;
- }
- }
- if (dwCapacity > 0) {
- FX_FLOAT* fRet = static_cast<FX_FLOAT*>(GetThemeCapacity(dwCapacity));
- return fRet ? *fRet : 0;
- }
- return 0;
-}
-void CFWL_WidgetImp::GetRelativeRect(CFX_RectF& rect) {
- rect = m_pProperties->m_rtWidget;
- rect.left = rect.top = 0;
-}
-void* CFWL_WidgetImp::GetThemeCapacity(FX_DWORD dwCapacity) {
- IFWL_ThemeProvider* pTheme = GetAvailableTheme();
- if (!pTheme)
- return NULL;
- CFWL_ThemePart part;
- part.m_pWidget = m_pInterface;
- return pTheme->GetCapacity(&part, dwCapacity);
-}
-IFWL_ThemeProvider* CFWL_WidgetImp::GetAvailableTheme() {
- if (m_pProperties->m_pThemeProvider) {
- return m_pProperties->m_pThemeProvider;
- }
- IFWL_Widget* pUp = m_pInterface;
- do {
- FWL_WGTRELATION relation = (pUp->GetStyles() & FWL_WGTSTYLE_Popup)
- ? FWL_WGTRELATION_Owner
- : FWL_WGTRELATION_Parent;
- pUp = m_pWidgetMgr->GetWidget(pUp, relation);
- if (pUp) {
- IFWL_ThemeProvider* pRet = pUp->GetThemeProvider();
- if (pRet && pRet->IsValidWidget(m_pInterface)) {
- return pRet;
- }
- }
- } while (pUp);
- return FWL_GetApp()->GetThemeProvider();
-}
-CFWL_WidgetImp* CFWL_WidgetImp::GetRootOuter() {
- IFWL_Widget* pRet = m_pOuter;
- if (!pRet)
- return nullptr;
- while (IFWL_Widget* pOuter = pRet->GetOuter()) {
- pRet = pOuter;
- }
- return static_cast<CFWL_WidgetImp*>(pRet->GetImpl());
-}
-#define FWL_WGT_CalcHeight 2048
-#define FWL_WGT_CalcWidth 2048
-#define FWL_WGT_CalcMultiLineDefWidth 120.0f
-CFX_SizeF CFWL_WidgetImp::CalcTextSize(const CFX_WideString& wsText,
- IFWL_ThemeProvider* pTheme,
- FX_BOOL bMultiLine,
- int32_t iLineWidth) {
- if (!pTheme)
- return CFX_SizeF();
-
- CFWL_ThemeText calPart;
- calPart.m_pWidget = m_pInterface;
- 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);
-}
-void CFWL_WidgetImp::CalcTextRect(const CFX_WideString& wsText,
- IFWL_ThemeProvider* pTheme,
- FX_DWORD dwTTOStyles,
- int32_t iTTOAlign,
- CFX_RectF& rect) {
- CFWL_ThemeText calPart;
- calPart.m_pWidget = m_pInterface;
- calPart.m_wsText = wsText;
- calPart.m_dwTTOStyles = dwTTOStyles;
- calPart.m_iTTOAlign = iTTOAlign;
- pTheme->CalcTextRect(&calPart, rect);
-}
-void CFWL_WidgetImp::SetFocus(FX_BOOL bFocus) {
- if (m_pWidgetMgr->IsFormDisabled())
- return;
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
- return;
- CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
- if (!pDriver)
- return;
- IFWL_Widget* curFocus = pDriver->GetFocus();
- if (bFocus && curFocus != m_pInterface) {
- pDriver->SetFocus(m_pInterface);
- } else if (!bFocus && curFocus == m_pInterface) {
- pDriver->SetFocus(NULL);
- }
-}
-void CFWL_WidgetImp::SetGrab(FX_BOOL bSet) {
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
- return;
- CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
- pDriver->SetGrab(m_pInterface, bSet);
-}
-FX_BOOL CFWL_WidgetImp::GetPopupPos(FX_FLOAT fMinHeight,
- FX_FLOAT fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup) {
- if (GetClassID() == FWL_CLASSHASH_Menu) {
- return GetPopupPosMenu(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
- } else {
- if (GetClassID() == FWL_CLASSHASH_ComboBox) {
- if (m_pWidgetMgr->IsFormDisabled()) {
- return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight,
- fMaxHeight, rtAnchor, rtPopup);
- } else {
- return GetPopupPosComboBox(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
- }
- } else if (GetClassID() == FWL_CLASSHASH_DateTimePicker &&
- m_pWidgetMgr->IsFormDisabled()) {
- return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight,
- fMaxHeight, rtAnchor, rtPopup);
- } else {
- return GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
- }
- }
- return FALSE;
-}
-FX_BOOL CFWL_WidgetImp::GetPopupPosMenu(FX_FLOAT fMinHeight,
- FX_FLOAT fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup) {
- FX_FLOAT fx = 0;
- FX_FLOAT fy = 0;
- FX_FLOAT fScreenWidth = 0;
- FX_FLOAT fScreenHeight = 0;
- GetScreenSize(fScreenWidth, fScreenHeight);
- if (GetStylesEx() & FWL_STYLEEXT_MNU_Vert) {
- FX_BOOL bLeft = m_pProperties->m_rtWidget.left < 0;
- FX_FLOAT fRight = rtAnchor.right() + rtPopup.width;
- TransformTo(NULL, fx, fy);
- if (fRight + fx > fScreenWidth || bLeft) {
- rtPopup.Set(rtAnchor.left - rtPopup.width, rtAnchor.top, rtPopup.width,
- rtPopup.height);
- } else {
- rtPopup.Set(rtAnchor.right(), rtAnchor.top, rtPopup.width,
- rtPopup.height);
- }
- } else {
- FX_FLOAT fBottom = rtAnchor.bottom() + rtPopup.height;
- TransformTo(NULL, fx, fy);
- if (fBottom + fy > fScreenHeight) {
- rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width,
- rtPopup.height);
- } else {
- rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width,
- rtPopup.height);
- }
- }
- rtPopup.Offset(fx, fy);
- return TRUE;
-}
-FX_BOOL CFWL_WidgetImp::GetPopupPosComboBox(FX_FLOAT fMinHeight,
- FX_FLOAT fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup) {
- FX_FLOAT fx = 0;
- FX_FLOAT fy = 0;
- FX_FLOAT fScreenWidth = 0;
- FX_FLOAT fScreenHeight = 0;
- GetScreenSize(fScreenWidth, fScreenHeight);
- FX_FLOAT fPopHeight = rtPopup.height;
- if (rtPopup.height > fMaxHeight) {
- fPopHeight = fMaxHeight;
- } else if (rtPopup.height < fMinHeight) {
- fPopHeight = fMinHeight;
- }
- FX_FLOAT fWidth = std::max(rtAnchor.width, rtPopup.width);
- FX_FLOAT fBottom = rtAnchor.bottom() + fPopHeight;
- TransformTo(NULL, fx, fy);
- if (fBottom + fy > fScreenHeight) {
- rtPopup.Set(rtAnchor.left, rtAnchor.top - fPopHeight, fWidth, fPopHeight);
- } else {
- rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), fWidth, fPopHeight);
- }
- rtPopup.Offset(fx, fy);
- return TRUE;
-}
-FX_BOOL CFWL_WidgetImp::GetPopupPosGeneral(FX_FLOAT fMinHeight,
- FX_FLOAT fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup) {
- FX_FLOAT fx = 0;
- FX_FLOAT fy = 0;
- FX_FLOAT fScreenWidth = 0;
- FX_FLOAT fScreenHeight = 0;
- GetScreenSize(fScreenWidth, fScreenHeight);
- TransformTo(NULL, fx, fy);
- if (rtAnchor.bottom() + fy > fScreenHeight) {
- rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width,
- rtPopup.height);
- } else {
- rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width,
- rtPopup.height);
- }
- rtPopup.Offset(fx, fy);
- return TRUE;
-}
-FX_BOOL CFWL_WidgetImp::GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy) {
- return FALSE;
-}
-void CFWL_WidgetImp::RegisterEventTarget(IFWL_Widget* pEventSource,
- FX_DWORD dwFilter) {
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
- return;
- IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
- if (!pNoteDriver)
- return;
- pNoteDriver->RegisterEventTarget(m_pInterface, pEventSource, dwFilter);
-}
-void CFWL_WidgetImp::UnregisterEventTarget() {
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
- return;
- IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
- if (!pNoteDriver)
- return;
- pNoteDriver->UnregisterEventTarget(m_pInterface);
-}
-void CFWL_WidgetImp::DispatchKeyEvent(CFWL_MsgKey* pNote) {
- if (!pNote)
- return;
- CFWL_EvtKey* pEvent = new CFWL_EvtKey;
- pEvent->m_pSrcTarget = m_pInterface;
- pEvent->m_dwCmd = pNote->m_dwCmd;
- pEvent->m_dwKeyCode = pNote->m_dwKeyCode;
- pEvent->m_dwFlags = pNote->m_dwFlags;
- DispatchEvent(pEvent);
- pEvent->Release();
-}
-void CFWL_WidgetImp::DispatchEvent(CFWL_Event* pEvent) {
- if (m_pOuter) {
- IFWL_WidgetDelegate* pDelegate = m_pOuter->SetDelegate(NULL);
- pDelegate->OnProcessEvent(pEvent);
- return;
- }
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
- return;
- IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
- if (!pNoteDriver)
- return;
- pNoteDriver->SendNote(pEvent);
-}
-void CFWL_WidgetImp::Repaint(const CFX_RectF* pRect) {
- if (pRect) {
- m_pWidgetMgr->RepaintWidget(m_pInterface, pRect);
- return;
- }
- CFX_RectF rect;
- rect = m_pProperties->m_rtWidget;
- rect.left = rect.top = 0;
- m_pWidgetMgr->RepaintWidget(m_pInterface, &rect);
-}
-void CFWL_WidgetImp::DrawBackground(CFX_Graphics* pGraphics,
- int32_t iPartBk,
- IFWL_ThemeProvider* pTheme,
- const CFX_Matrix* pMatrix) {
- CFX_RectF rtRelative;
- GetRelativeRect(rtRelative);
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = iPartBk;
- param.m_pGraphics = pGraphics;
- if (pMatrix) {
- param.m_matrix.Concat(*pMatrix, TRUE);
- }
- param.m_rtPart = rtRelative;
- pTheme->DrawBackground(&param);
-}
-void CFWL_WidgetImp::DrawBorder(CFX_Graphics* pGraphics,
- int32_t iPartBorder,
- IFWL_ThemeProvider* pTheme,
- const CFX_Matrix* pMatrix) {
- CFX_RectF rtRelative;
- GetRelativeRect(rtRelative);
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = iPartBorder;
- param.m_pGraphics = pGraphics;
- if (pMatrix) {
- param.m_matrix.Concat(*pMatrix, TRUE);
- }
- param.m_rtPart = rtRelative;
- pTheme->DrawBackground(&param);
-}
-void CFWL_WidgetImp::DrawEdge(CFX_Graphics* pGraphics,
- int32_t iPartEdge,
- IFWL_ThemeProvider* pTheme,
- const CFX_Matrix* pMatrix) {
- CFX_RectF rtEdge;
- GetEdgeRect(rtEdge);
- CFWL_ThemeBackground param;
- param.m_pWidget = m_pInterface;
- param.m_iPart = iPartEdge;
- param.m_pGraphics = pGraphics;
- if (pMatrix) {
- param.m_matrix.Concat(*pMatrix, TRUE);
- }
- param.m_rtPart = rtEdge;
- pTheme->DrawBackground(&param);
-}
-void CFWL_WidgetImp::NotifyDriver() {
- IFWL_NoteThread* pThread = GetOwnerThread();
- if (!pThread)
- return;
- CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
- if (!pDriver)
- return;
- pDriver->NotifyTargetDestroy(m_pInterface);
-}
-CFX_SizeF CFWL_WidgetImp::GetOffsetFromParent(IFWL_Widget* pParent) {
- if (pParent == GetInterface())
- return CFX_SizeF();
-
- IFWL_WidgetMgr* pWidgetMgr = FWL_GetWidgetMgr();
- if (!pWidgetMgr)
- return CFX_SizeF();
-
- CFX_SizeF szRet(m_pProperties->m_rtWidget.left,
- m_pProperties->m_rtWidget.top);
-
- IFWL_Widget* pDstWidget = GetParent();
- while (pDstWidget && pDstWidget != pParent) {
- CFX_RectF rtDst;
- pDstWidget->GetWidgetRect(rtDst);
- szRet += CFX_SizeF(rtDst.left, rtDst.top);
- pDstWidget = pWidgetMgr->GetWidget(pDstWidget, FWL_WGTRELATION_Parent);
- }
- return szRet;
-}
-FX_BOOL CFWL_WidgetImp::IsParent(IFWL_Widget* pParent) {
- IFWL_Widget* pUpWidget = GetParent();
- while (pUpWidget) {
- if (pUpWidget == pParent)
- return TRUE;
- pUpWidget = pUpWidget->GetParent();
- }
- return FALSE;
-}
-CFWL_WidgetImpDelegate::CFWL_WidgetImpDelegate() {}
-int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
- if (!pMessage->m_pDstTarget)
- return 0;
- CFWL_WidgetImp* pWidget =
- static_cast<CFWL_WidgetImp*>(pMessage->m_pDstTarget->GetImpl());
- FX_DWORD dwMsgCode = pMessage->GetClassID();
- switch (dwMsgCode) {
- case FWL_MSGHASH_Mouse: {
- CFWL_MsgMouse* pMsgMouse = static_cast<CFWL_MsgMouse*>(pMessage);
- CFWL_EvtMouse evt;
- evt.m_pSrcTarget = pWidget->m_pInterface;
- evt.m_pDstTarget = pWidget->m_pInterface;
- evt.m_dwCmd = pMsgMouse->m_dwCmd;
- evt.m_dwFlags = pMsgMouse->m_dwFlags;
- evt.m_fx = pMsgMouse->m_fx;
- evt.m_fy = pMsgMouse->m_fy;
- pWidget->DispatchEvent(&evt);
- break;
- }
- case FWL_MSGHASH_MouseWheel: {
- CFWL_MsgMouseWheel* pMsgMouseWheel =
- static_cast<CFWL_MsgMouseWheel*>(pMessage);
- CFWL_EvtMouseWheel evt;
- evt.m_pSrcTarget = pWidget->m_pInterface;
- evt.m_pDstTarget = pWidget->m_pInterface;
- evt.m_dwFlags = pMsgMouseWheel->m_dwFlags;
- evt.m_fDeltaX = pMsgMouseWheel->m_fDeltaX;
- evt.m_fDeltaY = pMsgMouseWheel->m_fDeltaY;
- evt.m_fx = pMsgMouseWheel->m_fx;
- evt.m_fy = pMsgMouseWheel->m_fy;
- pWidget->DispatchEvent(&evt);
- break;
- }
- case FWL_MSGHASH_Key: {
- CFWL_MsgKey* pMsgKey = static_cast<CFWL_MsgKey*>(pMessage);
- CFWL_EvtKey evt;
- evt.m_pSrcTarget = pWidget->m_pInterface;
- evt.m_pDstTarget = pWidget->m_pInterface;
- evt.m_dwKeyCode = pMsgKey->m_dwKeyCode;
- evt.m_dwFlags = pMsgKey->m_dwFlags;
- evt.m_dwCmd = pMsgKey->m_dwCmd;
- pWidget->DispatchEvent(&evt);
- break;
- }
- case FWL_MSGHASH_SetFocus: {
- CFWL_MsgSetFocus* pMsgSetFocus = static_cast<CFWL_MsgSetFocus*>(pMessage);
- CFWL_EvtSetFocus evt;
- evt.m_pSrcTarget = pMsgSetFocus->m_pDstTarget;
- evt.m_pDstTarget = pMsgSetFocus->m_pDstTarget;
- evt.m_pSetFocus = pWidget->m_pInterface;
- pWidget->DispatchEvent(&evt);
- break;
- }
- case FWL_MSGHASH_KillFocus: {
- CFWL_MsgKillFocus* pMsgKillFocus =
- static_cast<CFWL_MsgKillFocus*>(pMessage);
- CFWL_EvtKillFocus evt;
- evt.m_pSrcTarget = pMsgKillFocus->m_pDstTarget;
- evt.m_pDstTarget = pMsgKillFocus->m_pDstTarget;
- evt.m_pKillFocus = pWidget->m_pInterface;
- pWidget->DispatchEvent(&evt);
- break;
- }
- default: {}
- }
- return 1;
-}
-FWL_ERR CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- CFWL_EvtDraw evt;
- evt.m_pGraphics = pGraphics;
- return FWL_ERR_Succeeded;
-}
-class CFWL_CustomImp : public CFWL_WidgetImp {
- public:
- CFWL_CustomImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter);
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR Update();
- virtual FWL_ERR SetProxy(IFWL_Proxy* pProxy);
-
- protected:
- IFWL_Proxy* m_pProxy;
-};
-CFWL_CustomImp::CFWL_CustomImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter)
- : CFWL_WidgetImp(properties, pOuter), m_pProxy(NULL) {}
-FWL_ERR CFWL_CustomImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
- if (m_pProxy &&
- (m_pProxy->GetWidgetRect(rect, bAutoSize) == FWL_ERR_Succeeded)) {
- return FWL_ERR_Succeeded;
- }
- return CFWL_WidgetImp::GetWidgetRect(rect, bAutoSize);
-}
-FWL_ERR CFWL_CustomImp::Update() {
- if (m_pProxy) {
- return m_pProxy->Update();
- }
- return CFWL_WidgetImp::Update();
-}
-FWL_ERR CFWL_CustomImp::SetProxy(IFWL_Proxy* pProxy) {
- m_pProxy = pProxy;
- return FWL_ERR_Succeeded;
-}
-
-// static
-IFWL_Custom* IFWL_Custom::Create(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter) {
- IFWL_Custom* pCustom = new IFWL_Custom;
- CFWL_CustomImp* pCustomImpl = new CFWL_CustomImp(properties, pOuter);
- pCustom->SetImpl(pCustomImpl);
- pCustomImpl->SetInterface(pCustom);
- return pCustom;
-}
-IFWL_Custom::IFWL_Custom() {}
-FWL_ERR IFWL_Custom::SetProxy(IFWL_Proxy* pProxy) {
- return static_cast<CFWL_CustomImp*>(GetImpl())->SetProxy(pProxy);
-}
-void FWL_SetWidgetRect(IFWL_Widget* widget, const CFX_RectF& rect) {
- static_cast<CFWL_WidgetImp*>(widget->GetImpl())->m_pProperties->m_rtWidget =
- rect;
-}
-void FWL_SetWidgetStates(IFWL_Widget* widget, FX_DWORD dwStates) {
- static_cast<CFWL_WidgetImp*>(widget->GetImpl())->m_pProperties->m_dwStates =
- dwStates;
-}
-void FWL_SetWidgetStyles(IFWL_Widget* widget, FX_DWORD dwStyles) {
- static_cast<CFWL_WidgetImp*>(widget->GetImpl())->m_pProperties->m_dwStyles =
- dwStyles;
-}
-FWL_ERR FWL_EnabelWidget(IFWL_Widget* widget, FX_BOOL bEnable) {
- widget->SetStates(FWL_WGTSTATE_Disabled, !bEnable);
- IFWL_WidgetMgr* widgetMgr = FWL_GetWidgetMgr();
- IFWL_Widget* child = widgetMgr->GetWidget(widget, FWL_WGTRELATION_FirstChild);
- while (child) {
- FWL_EnabelWidget(child, bEnable);
- child = widgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
- }
- return FWL_ERR_Succeeded;
-}
diff --git a/xfa/src/fwl/core/fwl_widgetimp.h b/xfa/src/fwl/core/fwl_widgetimp.h
deleted file mode 100644
index d0dcf3cfc1..0000000000
--- a/xfa/src/fwl/core/fwl_widgetimp.h
+++ /dev/null
@@ -1,162 +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_SRC_FWL_CORE_FWL_WIDGETIMP_H_
-#define XFA_SRC_FWL_CORE_FWL_WIDGETIMP_H_
-
-#include "xfa/include/fwl/core/fwl_widget.h"
-#include "xfa/src/fwl/core/fwl_targetimp.h"
-
-class CFWL_NoteThreadImp;
-class CFWL_WidgetImpProperties;
-class CFWL_WidgetMgr;
-class IFWL_DataProvider;
-class IFWL_ThemeProvider;
-class IFWL_Widget;
-class IFWL_WidgetDelegate;
-
-class CFWL_WidgetImp : public CFWL_TargetImp {
- public:
- virtual FWL_ERR Initialize();
- virtual FWL_ERR Finalize();
-
- virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_ERR GetGlobalRect(CFX_RectF& rect);
- virtual FWL_ERR SetWidgetRect(const CFX_RectF& rect);
- virtual FWL_ERR GetClientRect(CFX_RectF& rect);
- virtual IFWL_Widget* GetParent();
- virtual FWL_ERR SetParent(IFWL_Widget* pParent);
- virtual IFWL_Widget* GetOwner();
- virtual FWL_ERR SetOwner(IFWL_Widget* pOwner);
- virtual IFWL_Widget* GetOuter();
- virtual FX_DWORD GetStyles();
- virtual FWL_ERR ModifyStyles(FX_DWORD dwStylesAdded,
- FX_DWORD dwStylesRemoved);
- virtual FX_DWORD GetStylesEx();
- virtual FWL_ERR ModifyStylesEx(FX_DWORD dwStylesExAdded,
- FX_DWORD dwStylesExRemoved);
- virtual FX_DWORD GetStates();
- virtual FWL_ERR SetStates(FX_DWORD dwStates, FX_BOOL bSet = TRUE);
- virtual FWL_ERR SetPrivateData(void* module_id,
- void* pData,
- PD_CALLBACK_FREEDATA callback);
- virtual void* GetPrivateData(void* module_id);
- virtual FWL_ERR Update();
- virtual FWL_ERR LockUpdate();
- virtual FWL_ERR UnlockUpdate();
- virtual FX_DWORD HitTest(FX_FLOAT fx, FX_FLOAT fy);
- virtual FWL_ERR TransformTo(IFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy);
- virtual FWL_ERR TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt);
- virtual FWL_ERR GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE);
- virtual FWL_ERR SetMatrix(const CFX_Matrix& matrix);
- virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
- virtual IFWL_ThemeProvider* GetThemeProvider();
- virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
- virtual FWL_ERR SetDataProvider(IFWL_DataProvider* pDataProvider);
- virtual IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate);
- virtual IFWL_NoteThread* GetOwnerThread() const;
- FWL_ERR SetOwnerThread(CFWL_NoteThreadImp* pOwnerThread);
- IFWL_Widget* GetInterface() const;
- void SetInterface(IFWL_Widget* pInterface);
- CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent);
-
- protected:
- CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties,
- IFWL_Widget* pOuter);
- virtual ~CFWL_WidgetImp();
- FX_BOOL IsEnabled() const;
- FX_BOOL IsVisible() const;
- FX_BOOL IsActive() const;
- FX_BOOL IsOverLapper() const;
- FX_BOOL IsPopup() const;
- FX_BOOL IsChild() const;
- FX_BOOL IsLocked() const;
- FX_BOOL IsOffscreen() const;
- FX_BOOL HasBorder() const;
- FX_BOOL HasEdge() const;
- void GetEdgeRect(CFX_RectF& rtEdge);
- FX_FLOAT GetBorderSize(FX_BOOL bCX = TRUE);
- FX_FLOAT GetEdgeWidth();
- void GetRelativeRect(CFX_RectF& rect);
- void* GetThemeCapacity(FX_DWORD dwCapacity);
- IFWL_ThemeProvider* GetAvailableTheme();
- CFWL_WidgetImp* GetRootOuter();
- CFX_SizeF CalcTextSize(const CFX_WideString& wsText,
- IFWL_ThemeProvider* pTheme,
- FX_BOOL bMultiLine = FALSE,
- int32_t iLineWidth = -1);
- void CalcTextRect(const CFX_WideString& wsText,
- IFWL_ThemeProvider* pTheme,
- FX_DWORD dwTTOStyles,
- int32_t iTTOAlign,
- CFX_RectF& rect);
- void SetFocus(FX_BOOL bFocus);
- void SetGrab(FX_BOOL bSet);
- FX_BOOL GetPopupPos(FX_FLOAT fMinHeight,
- FX_FLOAT fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup);
- FX_BOOL GetPopupPosMenu(FX_FLOAT fMinHeight,
- FX_FLOAT fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup);
- FX_BOOL GetPopupPosComboBox(FX_FLOAT fMinHeight,
- FX_FLOAT fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup);
- FX_BOOL GetPopupPosGeneral(FX_FLOAT fMinHeight,
- FX_FLOAT fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup);
- FX_BOOL GetScreenSize(FX_FLOAT& fx, FX_FLOAT& fy);
- void RegisterEventTarget(IFWL_Widget* pEventSource = NULL,
- FX_DWORD dwFilter = FWL_EVENT_ALL_MASK);
- void UnregisterEventTarget();
- void DispatchKeyEvent(CFWL_MsgKey* pNote);
- void DispatchEvent(CFWL_Event* pEvent);
- void Repaint(const CFX_RectF* pRect = NULL);
- void DrawBackground(CFX_Graphics* pGraphics,
- int32_t iPartBk,
- IFWL_ThemeProvider* pTheme,
- const CFX_Matrix* pMatrix = NULL);
- void DrawBorder(CFX_Graphics* pGraphics,
- int32_t iPartBorder,
- IFWL_ThemeProvider* pTheme,
- const CFX_Matrix* pMatrix = NULL);
- void DrawEdge(CFX_Graphics* pGraphics,
- int32_t iPartEdge,
- IFWL_ThemeProvider* pTheme,
- const CFX_Matrix* pMatrix = NULL);
- void NotifyDriver();
-
- FX_BOOL IsParent(IFWL_Widget* pParent);
- CFWL_WidgetMgr* m_pWidgetMgr;
- CFWL_NoteThreadImp* m_pOwnerThread;
- CFWL_WidgetImpProperties* m_pProperties;
- CFX_PrivateData* m_pPrivateData;
- IFWL_WidgetDelegate* m_pDelegate;
- IFWL_WidgetDelegate* m_pCurDelegate;
- IFWL_Widget* m_pOuter;
- IFWL_Widget* m_pInterface;
- int32_t m_iLock;
- friend class CFWL_WidgetImpDelegate;
- friend void FWL_SetWidgetRect(IFWL_Widget* widget, const CFX_RectF& rect);
- friend void FWL_SetWidgetStates(IFWL_Widget* widget, FX_DWORD dwStates);
- friend void FWL_SetWidgetStyles(IFWL_Widget* widget, FX_DWORD dwStyles);
-};
-
-class CFWL_WidgetImpDelegate : public IFWL_WidgetDelegate {
- public:
- CFWL_WidgetImpDelegate();
- ~CFWL_WidgetImpDelegate() override {}
- int32_t OnProcessMessage(CFWL_Message* pMessage) override;
- FWL_ERR OnProcessEvent(CFWL_Event* pEvent) override;
- FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL) override;
-};
-
-#endif // XFA_SRC_FWL_CORE_FWL_WIDGETIMP_H_
diff --git a/xfa/src/fwl/core/fwl_widgetmgrimp.cpp b/xfa/src/fwl/core/fwl_widgetmgrimp.cpp
deleted file mode 100644
index aeb655b9ad..0000000000
--- a/xfa/src/fwl/core/fwl_widgetmgrimp.cpp
+++ /dev/null
@@ -1,1075 +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/src/fwl/core/fwl_widgetmgrimp.h"
-
-#include "xfa/include/fwl/adapter/fwl_adapternative.h"
-#include "xfa/include/fwl/adapter/fwl_adapterwidgetmgr.h"
-#include "xfa/include/fwl/core/fwl_app.h"
-#include "xfa/include/fwl/core/fwl_form.h"
-#include "xfa/src/fwl/core/fwl_appimp.h"
-#include "xfa/src/fwl/core/fwl_noteimp.h"
-#include "xfa/src/fwl/core/fwl_targetimp.h"
-#include "xfa/src/fwl/core/fwl_threadimp.h"
-#include "xfa/src/fwl/core/fwl_widgetimp.h"
-
-FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) {
-#if (_FX_OS_ == _FX_MACOSX_)
- return FALSE;
-#else
- return pWidget->GetStyles() & FWL_WGTSTYLE_Offscreen;
-#endif
-}
-IFWL_WidgetMgr* FWL_GetWidgetMgr() {
- IFWL_App* pApp = FWL_GetApp();
- if (!pApp)
- return NULL;
- return pApp->GetWidgetMgr();
-}
-CFWL_WidgetMgr::CFWL_WidgetMgr(IFWL_AdapterNative* pAdapterNative)
- : m_dwCapability(0) {
- m_pDelegate = new CFWL_WidgetMgrDelegate(this);
- m_pAdapter = pAdapterNative->GetWidgetMgr(m_pDelegate);
- FXSYS_assert(m_pAdapter);
- CFWL_WidgetMgrItem* pRoot = new CFWL_WidgetMgrItem;
- m_mapWidgetItem.SetAt(NULL, pRoot);
-#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
- m_rtScreen.Reset();
-#endif
-}
-CFWL_WidgetMgr::~CFWL_WidgetMgr() {
- FX_POSITION ps = m_mapWidgetItem.GetStartPosition();
- while (ps) {
- void* pWidget;
- CFWL_WidgetMgrItem* pItem;
- m_mapWidgetItem.GetNextAssoc(ps, pWidget, (void*&)pItem);
- delete pItem;
- }
- m_mapWidgetItem.RemoveAll();
- if (m_pDelegate) {
- delete m_pDelegate;
- m_pDelegate = NULL;
- }
-}
-int32_t CFWL_WidgetMgr::CountWidgets(IFWL_Widget* pParent) {
- CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent);
- return TravelWidgetMgr(pParentItem, NULL, NULL);
-}
-IFWL_Widget* CFWL_WidgetMgr::GetWidget(int32_t nIndex, IFWL_Widget* pParent) {
- CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent);
- IFWL_Widget* pWidget = NULL;
- TravelWidgetMgr(pParentItem, &nIndex, NULL, &pWidget);
- return pWidget;
-}
-IFWL_Widget* CFWL_WidgetMgr::GetWidget(IFWL_Widget* pWidget,
- FWL_WGTRELATION eRelation) {
- CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
- if (!pItem) {
- return NULL;
- }
- IFWL_Widget* pRet = NULL;
- switch (eRelation) {
- case FWL_WGTRELATION_Parent: {
- pRet = pItem->pParent ? pItem->pParent->pWidget : NULL;
- break;
- }
- case FWL_WGTRELATION_Owner: {
- pRet = pItem->pOwner ? pItem->pOwner->pWidget : NULL;
- break;
- }
- case FWL_WGTRELATION_FirstSibling: {
- pItem = pItem->pPrevious;
- while (pItem && pItem->pPrevious) {
- pItem = pItem->pPrevious;
- }
- pRet = pItem ? pItem->pWidget : NULL;
- break;
- }
- case FWL_WGTRELATION_PriorSibling: {
- pRet = pItem->pPrevious ? pItem->pPrevious->pWidget : NULL;
- break;
- }
- case FWL_WGTRELATION_NextSibling: {
- pRet = pItem->pNext ? pItem->pNext->pWidget : NULL;
- break;
- }
- case FWL_WGTRELATION_LastSibling: {
- pItem = pItem->pNext;
- while (pItem && pItem->pNext) {
- pItem = pItem->pNext;
- }
- pRet = pItem ? pItem->pWidget : NULL;
- break;
- }
- case FWL_WGTRELATION_FirstChild: {
- pRet = pItem->pChild ? pItem->pChild->pWidget : NULL;
- break;
- }
- case FWL_WGTRELATION_LastChild: {
- pItem = pItem->pChild;
- while (pItem && pItem->pNext) {
- pItem = pItem->pNext;
- }
- pRet = pItem ? pItem->pWidget : NULL;
- break;
- }
- case FWL_WGTRELATION_SystemForm: {
- while (pItem) {
- if (IsAbleNative(pItem->pWidget)) {
- pRet = pItem->pWidget;
- break;
- }
- pItem = pItem->pParent;
- }
- break;
- }
- default: {}
- }
- return pRet;
-}
-int32_t CFWL_WidgetMgr::GetWidgetIndex(IFWL_Widget* pWidget) {
- CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
- if (!pItem)
- return -1;
- return TravelWidgetMgr(pItem->pParent, NULL, pItem);
-}
-FX_BOOL CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) {
- CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
- if (!pItem)
- return FALSE;
- if (!pItem->pParent)
- return FALSE;
- CFWL_WidgetMgrItem* pChild = pItem->pParent->pChild;
- int32_t i = 0;
- while (pChild) {
- if (pChild == pItem) {
- if (i == nIndex) {
- return TRUE;
- }
- if (pChild->pPrevious) {
- pChild->pPrevious->pNext = pChild->pNext;
- }
- if (pChild->pNext) {
- pChild->pNext->pPrevious = pChild->pPrevious;
- }
- if (pItem->pParent->pChild == pItem) {
- pItem->pParent->pChild = pItem->pNext;
- }
- pItem->pNext = NULL;
- pItem->pPrevious = NULL;
- break;
- }
- if (!pChild->pNext) {
- break;
- }
- pChild = pChild->pNext;
- ++i;
- }
- pChild = pItem->pParent->pChild;
- if (pChild) {
- if (nIndex < 0) {
- while (pChild->pNext) {
- pChild = pChild->pNext;
- }
- pChild->pNext = pItem;
- pItem->pPrevious = pChild;
- pItem->pNext = NULL;
- return TRUE;
- }
- i = 0;
- while (i < nIndex && pChild->pNext) {
- pChild = pChild->pNext;
- ++i;
- }
- if (!pChild->pNext) {
- pChild->pNext = pItem;
- pItem->pPrevious = pChild;
- pItem->pNext = NULL;
- return TRUE;
- }
- if (pChild->pPrevious) {
- pItem->pPrevious = pChild->pPrevious;
- pChild->pPrevious->pNext = pItem;
- }
- pChild->pPrevious = pItem;
- pItem->pNext = pChild;
- if (pItem->pParent->pChild == pChild) {
- pItem->pParent->pChild = pItem;
- }
- } else {
- pItem->pParent->pChild = pItem;
- pItem->pPrevious = NULL;
- pItem->pNext = NULL;
- }
- return TRUE;
-}
-FWL_ERR CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget,
- const CFX_RectF* pRect) {
- if (!m_pAdapter)
- return FWL_ERR_Indefinite;
- IFWL_Widget* pNative = pWidget;
- CFX_RectF rect(*pRect);
- if (IsFormDisabled()) {
- IFWL_Widget* pOuter = pWidget->GetOuter();
- while (pOuter) {
- CFX_RectF rtTemp;
- pNative->GetWidgetRect(rtTemp);
- rect.left += rtTemp.left;
- rect.top += rtTemp.top;
- pNative = pOuter;
- pOuter = pOuter->GetOuter();
- }
- } else if (!IsAbleNative(pWidget)) {
- pNative = GetWidget(pWidget, FWL_WGTRELATION_SystemForm);
- if (!pNative)
- return FWL_ERR_Indefinite;
- pWidget->TransformTo(pNative, rect.left, rect.top);
- }
- AddRedrawCounts(pNative);
- return m_pAdapter->RepaintWidget(pNative, &rect);
-}
-void CFWL_WidgetMgr::AddWidget(IFWL_Widget* pWidget) {
- CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(NULL);
- CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
- if (!pItem) {
- pItem = new CFWL_WidgetMgrItem;
- pItem->pWidget = pWidget;
- m_mapWidgetItem.SetAt(pWidget, pItem);
- }
- if (pItem->pParent && pItem->pParent != pParentItem) {
- if (pItem->pPrevious) {
- pItem->pPrevious->pNext = pItem->pNext;
- }
- if (pItem->pNext) {
- pItem->pNext->pPrevious = pItem->pPrevious;
- }
- if (pItem->pParent->pChild == pItem) {
- pItem->pParent->pChild = pItem->pNext;
- }
- }
- pItem->pParent = pParentItem;
- SetWidgetIndex(pWidget, -1);
-}
-void CFWL_WidgetMgr::InsertWidget(IFWL_Widget* pParent,
- IFWL_Widget* pChild,
- int32_t nIndex) {
- CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent);
- if (!pParentItem) {
- pParentItem = new CFWL_WidgetMgrItem;
- pParentItem->pWidget = pParent;
- m_mapWidgetItem.SetAt(pParent, pParentItem);
- CFWL_WidgetMgrItem* pRoot = GetWidgetMgrItem(NULL);
- pParentItem->pParent = pRoot;
- SetWidgetIndex(pParent, -1);
- }
- CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pChild);
- if (!pItem) {
- pItem = new CFWL_WidgetMgrItem;
- pItem->pWidget = pChild;
- m_mapWidgetItem.SetAt(pChild, pItem);
- }
- if (pItem->pParent && pItem->pParent != pParentItem) {
- if (pItem->pPrevious) {
- pItem->pPrevious->pNext = pItem->pNext;
- }
- if (pItem->pNext) {
- pItem->pNext->pPrevious = pItem->pPrevious;
- }
- if (pItem->pParent->pChild == pItem) {
- pItem->pParent->pChild = pItem->pNext;
- }
- }
- pItem->pParent = pParentItem;
- SetWidgetIndex(pChild, nIndex);
-}
-void CFWL_WidgetMgr::RemoveWidget(IFWL_Widget* pWidget) {
- CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
- if (!pItem) {
- return;
- }
- if (pItem->pPrevious) {
- pItem->pPrevious->pNext = pItem->pNext;
- }
- if (pItem->pNext) {
- pItem->pNext->pPrevious = pItem->pPrevious;
- }
- if (pItem->pParent && pItem->pParent->pChild == pItem) {
- pItem->pParent->pChild = pItem->pNext;
- }
- CFWL_WidgetMgrItem* pChild = pItem->pChild;
- while (pChild) {
- CFWL_WidgetMgrItem* pNext = pChild->pNext;
- RemoveWidget(pChild->pWidget);
- pChild = pNext;
- }
- m_mapWidgetItem.RemoveKey(pWidget);
- delete pItem;
-}
-void CFWL_WidgetMgr::SetOwner(IFWL_Widget* pOwner, IFWL_Widget* pOwned) {
- CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pOwner);
- if (!pParentItem) {
- pParentItem = new CFWL_WidgetMgrItem;
- pParentItem->pWidget = pOwner;
- m_mapWidgetItem.SetAt(pOwner, pParentItem);
- CFWL_WidgetMgrItem* pRoot = GetWidgetMgrItem(NULL);
- pParentItem->pParent = pRoot;
- SetWidgetIndex(pOwner, -1);
- }
- CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pOwned);
- if (!pItem) {
- pItem = new CFWL_WidgetMgrItem;
- pItem->pWidget = pOwned;
- m_mapWidgetItem.SetAt(pOwned, pItem);
- }
- pItem->pOwner = pParentItem;
-}
-void CFWL_WidgetMgr::SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild) {
- CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent);
- CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pChild);
- if (!pItem)
- return;
- if (pItem->pParent && pItem->pParent != pParentItem) {
- if (pItem->pPrevious) {
- pItem->pPrevious->pNext = pItem->pNext;
- }
- if (pItem->pNext) {
- pItem->pNext->pPrevious = pItem->pPrevious;
- }
- if (pItem->pParent->pChild == pItem) {
- pItem->pParent->pChild = pItem->pNext;
- }
- pItem->pNext = NULL;
- pItem->pPrevious = NULL;
- }
- pItem->pParent = pParentItem;
- SetWidgetIndex(pChild, -1);
- if (!m_pAdapter)
- return;
- m_pAdapter->SetParentWidget(pChild, pParent);
-}
-FX_BOOL CFWL_WidgetMgr::IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent) {
- IFWL_Widget* pTemp = pChild;
- do {
- if (pTemp == pParent) {
- return TRUE;
- }
- pTemp = GetWidget(pTemp, FWL_WGTRELATION_Parent);
- } while (pTemp);
- return FALSE;
-}
-FWL_ERR CFWL_WidgetMgr::CreateWidget_Native(IFWL_Widget* pWidget) {
- if (!IsAbleNative(pWidget)) {
- return FWL_ERR_Succeeded;
- }
- return m_pAdapter->CreateWidget(pWidget, pWidget->GetOwner());
-}
-FWL_ERR CFWL_WidgetMgr::DestroyWidget_Native(IFWL_Widget* pWidget) {
- if (!IsAbleNative(pWidget)) {
- return FWL_ERR_Succeeded;
- }
- return m_pAdapter->DestroyWidget(pWidget);
-}
-FWL_ERR CFWL_WidgetMgr::GetWidgetRect_Native(IFWL_Widget* pWidget,
- CFX_RectF& rect) {
- if (!IsAbleNative(pWidget)) {
- return FWL_ERR_Succeeded;
- }
- return m_pAdapter->GetWidgetRect(pWidget, rect);
-}
-FWL_ERR CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget,
- const CFX_RectF& rect) {
- if (FWL_UseOffscreen(pWidget)) {
- CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
- pItem->iRedrawCounter++;
- if (pItem->pOffscreen) {
- CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice();
- if (pDevice && pDevice->GetBitmap()) {
- CFX_DIBitmap* pBitmap = pDevice->GetBitmap();
- if (pBitmap->GetWidth() - rect.width > 1 ||
- pBitmap->GetHeight() - rect.height > 1) {
- delete pItem->pOffscreen;
- pItem->pOffscreen = NULL;
- }
- }
- }
-#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
- pItem->bOutsideChanged = !m_rtScreen.Contains(rect);
-#endif
- }
- return m_pAdapter->SetWidgetRect(pWidget, rect);
-}
-FWL_ERR CFWL_WidgetMgr::SetWidgetPosition_Native(IFWL_Widget* pWidget,
- FX_FLOAT fx,
- FX_FLOAT fy) {
- return m_pAdapter->SetWidgetPosition(pWidget, fx, fy);
-}
-FWL_ERR CFWL_WidgetMgr::SetWidgetIcon_Native(IFWL_Widget* pWidget,
- const CFX_DIBitmap* pIcon,
- FX_BOOL bBig) {
- return m_pAdapter->SetWidgetIcon(pWidget, pIcon, bBig);
-}
-FWL_ERR CFWL_WidgetMgr::SetWidgetCaption_Native(
- IFWL_Widget* pWidget,
- const CFX_WideStringC& wsCaption) {
- return m_pAdapter->SetWidgetCaption(pWidget, wsCaption);
-}
-FWL_ERR CFWL_WidgetMgr::SetBorderRegion_Native(IFWL_Widget* pWidget,
- CFX_Path* pPath) {
- return m_pAdapter->SetBorderRegion(pWidget, pPath);
-}
-FWL_ERR CFWL_WidgetMgr::ShowWidget_Native(IFWL_Widget* pWidget) {
- return m_pAdapter->ShowWidget(pWidget);
-}
-FWL_ERR CFWL_WidgetMgr::HideWidget_Native(IFWL_Widget* pWidget) {
- return m_pAdapter->HideWidget(pWidget);
-}
-FWL_ERR CFWL_WidgetMgr::SetNormal_Native(IFWL_Widget* pWidget) {
- return m_pAdapter->SetNormal(pWidget);
-}
-FWL_ERR CFWL_WidgetMgr::SetMaximize_Native(IFWL_Widget* pWidget) {
- return m_pAdapter->SetMaximize(pWidget);
-}
-FWL_ERR CFWL_WidgetMgr::SetMinimize_Native(IFWL_Widget* pWidget) {
- return m_pAdapter->SetMinimize(pWidget);
-}
-FX_BOOL CFWL_WidgetMgr::CheckMessage_Native() {
- return m_pAdapter->CheckMessage();
-}
-FWL_ERR CFWL_WidgetMgr::DispatchMessage_Native() {
- return m_pAdapter->DispatchMessage();
-}
-FX_BOOL CFWL_WidgetMgr::IsIdleMessage_Native() {
- return m_pAdapter->IsIdleMessage();
-}
-FWL_ERR CFWL_WidgetMgr::Exit_Native(int32_t iExitCode) {
- return m_pAdapter->Exit(iExitCode);
-}
-FWL_ERR CFWL_WidgetMgr::CreateWidgetWithNativeId_Native(IFWL_Widget* pWidget,
- void* vp) {
- return m_pAdapter->CreateWidgetWithNativeId(pWidget, vp);
-}
-IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent,
- FX_FLOAT x,
- FX_FLOAT y) {
- if (!parent)
- return NULL;
- FX_FLOAT x1;
- FX_FLOAT y1;
- IFWL_Widget* child = GetWidget(parent, FWL_WGTRELATION_LastChild);
- while (child) {
- if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) {
- x1 = x;
- y1 = y;
- CFX_Matrix matrixOnParent;
- child->GetMatrix(matrixOnParent);
- CFX_Matrix m;
- m.SetIdentity();
- m.SetReverse(matrixOnParent);
- m.TransformPoint(x1, y1);
- CFX_RectF bounds;
- child->GetWidgetRect(bounds);
- if (bounds.Contains(x1, y1)) {
- x1 -= bounds.left;
- y1 -= bounds.top;
- return GetWidgetAtPoint(child, x1, y1);
- }
- }
- child = GetWidget(child, FWL_WGTRELATION_PriorSibling);
- }
- return parent;
-}
-void CFWL_WidgetMgr::NotifySizeChanged(IFWL_Widget* pForm,
- FX_FLOAT fx,
- FX_FLOAT fy) {
- if (!FWL_UseOffscreen(pForm)) {
- return;
- }
- CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pForm);
- if (pItem->pOffscreen) {
- delete pItem->pOffscreen;
- pItem->pOffscreen = NULL;
- }
-}
-IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent,
- IFWL_Widget* focus,
- FX_BOOL& bFind) {
- IFWL_Widget* child =
- FWL_GetWidgetMgr()->GetWidget(parent, FWL_WGTRELATION_FirstChild);
- while (child) {
- if (focus == child) {
- bFind = TRUE;
- }
- if ((child->GetStyles() & FWL_WGTSTYLE_TabStop) &&
- (!focus || (focus != child && bFind))) {
- return child;
- }
- IFWL_Widget* bRet = nextTab(child, focus, bFind);
- if (bRet) {
- return bRet;
- }
- child = FWL_GetWidgetMgr()->GetWidget(child, FWL_WGTRELATION_NextSibling);
- }
- return NULL;
-}
-int32_t CFWL_WidgetMgr::CountRadioButtonGroup(IFWL_Widget* pFirst) {
- int32_t iRet = 0;
- IFWL_Widget* pChild = pFirst;
- while (pChild) {
- if ((pChild->GetStyles() & FWL_WGTSTYLE_Group) &&
- pChild->GetClassID() == 3811304691) {
- iRet++;
- }
- pChild = GetWidget(pChild, FWL_WGTRELATION_NextSibling);
- }
- return iRet;
-}
-IFWL_Widget* CFWL_WidgetMgr::GetSiblingRadioButton(IFWL_Widget* pWidget,
- FX_BOOL bNext) {
- while ((pWidget = GetWidget(pWidget, bNext ? FWL_WGTRELATION_NextSibling
- : FWL_WGTRELATION_PriorSibling)) !=
- NULL) {
- if (pWidget->GetClassID() == 3811304691) {
- return pWidget;
- }
- }
- return NULL;
-}
-IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader(
- IFWL_Widget* pRadioButton) {
- if (pRadioButton->GetStyles() & FWL_WGTSTYLE_Group) {
- return pRadioButton;
- }
- IFWL_Widget* pNext = pRadioButton;
- while ((pNext = GetSiblingRadioButton(pNext, FALSE)) != NULL) {
- if (pNext->GetStyles() & FWL_WGTSTYLE_Group) {
- return pNext;
- }
- }
- pNext = GetWidget(pRadioButton, FWL_WGTRELATION_LastSibling);
- if ((pNext->GetStyles() & FWL_WGTSTYLE_Group) &&
- pNext->GetClassID() == 3811304691) {
- return pNext;
- }
- while ((pNext = GetSiblingRadioButton(pNext, FALSE)) && pNext &&
- pNext != pRadioButton) {
- if (pNext->GetStyles() & FWL_WGTSTYLE_Group) {
- return pNext;
- }
- }
- pNext = GetWidget(pRadioButton, FWL_WGTRELATION_FirstSibling);
- if (pNext && (pNext->GetStyles() == FWL_WGTSTYLE_Group) &&
- pNext->GetClassID() == 3811304691) {
- return pNext;
- }
- return GetSiblingRadioButton(pNext, TRUE);
-}
-void CFWL_WidgetMgr::GetSameGroupRadioButton(IFWL_Widget* pRadioButton,
- CFX_PtrArray& group) {
- IFWL_Widget* pFirst = GetWidget(pRadioButton, FWL_WGTRELATION_FirstSibling);
- if (!pFirst) {
- pFirst = pRadioButton;
- }
- int32_t iGroup = CountRadioButtonGroup(pFirst);
- if (iGroup < 2) {
- if (pFirst->GetClassID() == 3811304691) {
- group.Add(pFirst);
- }
- IFWL_Widget* pNext = pFirst;
- while ((pNext = GetSiblingRadioButton(pNext, TRUE)) != NULL) {
- group.Add(pNext);
- }
- return;
- }
- IFWL_Widget* pNext = GetRadioButtonGroupHeader(pRadioButton);
- do {
- group.Add(pNext);
- pNext = GetSiblingRadioButton(pNext, TRUE);
- if (!pNext) {
- if (pFirst->GetClassID() == 3811304691) {
- pNext = pFirst;
- } else {
- pNext = GetSiblingRadioButton(pFirst, TRUE);
- }
- }
- } while (pNext && ((pNext->GetStyles() & FWL_WGTSTYLE_Group) == 0));
-}
-IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) {
- if ((pParent->GetClassID() == 3521614244) &&
- (pParent->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) {
- return pParent;
- }
- IFWL_Widget* child =
- FWL_GetWidgetMgr()->GetWidget(pParent, FWL_WGTRELATION_FirstChild);
- while (child) {
- if ((child->GetClassID() == 3521614244) &&
- (child->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) {
- return child;
- }
- IFWL_Widget* find = GetDefaultButton(child);
- if (find) {
- return find;
- }
- child = FWL_GetWidgetMgr()->GetWidget(child, FWL_WGTRELATION_NextSibling);
- }
- return NULL;
-}
-void CFWL_WidgetMgr::AddRedrawCounts(IFWL_Widget* pWidget) {
- CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
- (pItem->iRedrawCounter)++;
-}
-void CFWL_WidgetMgr::ResetRedrawCounts(IFWL_Widget* pWidget) {
- CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
- pItem->iRedrawCounter = 0;
-}
-CFWL_WidgetMgrItem* CFWL_WidgetMgr::GetWidgetMgrItem(IFWL_Widget* pWidget) {
- return static_cast<CFWL_WidgetMgrItem*>(m_mapWidgetItem.GetValueAt(pWidget));
-}
-int32_t CFWL_WidgetMgr::TravelWidgetMgr(CFWL_WidgetMgrItem* pParent,
- int32_t* pIndex,
- CFWL_WidgetMgrItem* pItem,
- IFWL_Widget** pWidget) {
- if (!pParent) {
- return 0;
- }
- int32_t iCount = 0;
- CFWL_WidgetMgrItem* pChild = pParent->pChild;
- while (pChild) {
- iCount++;
- if (pIndex) {
- if (*pIndex == 0) {
- *pWidget = pChild->pWidget;
- return iCount;
- }
- pIndex--;
- }
- if (pItem && pItem == pChild) {
- return iCount - 1;
- }
- pChild = pChild->pNext;
- }
- if (pIndex) {
- return 0;
- } else if (pItem) {
- return -1;
- }
- return iCount - 1;
-}
-FX_BOOL CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) {
- if (!pWidget)
- return FALSE;
- if (!pWidget->IsInstance(FX_WSTRC(FWL_CLASS_Form))) {
- return FALSE;
- }
- FX_DWORD dwStyles = pWidget->GetStyles();
- return ((dwStyles & FWL_WGTSTYLE_WindowTypeMask) ==
- FWL_WGTSTYLE_OverLapper) ||
- (dwStyles & FWL_WGTSTYLE_Popup);
-}
-FX_BOOL CFWL_WidgetMgr::IsThreadEnabled() {
- return !(m_dwCapability & FWL_WGTMGR_DisableThread);
-}
-FX_BOOL CFWL_WidgetMgr::IsFormDisabled() {
- return m_dwCapability & FWL_WGTMGR_DisableForm;
-}
-FX_BOOL CFWL_WidgetMgr::GetAdapterPopupPos(IFWL_Widget* pWidget,
- FX_FLOAT fMinHeight,
- FX_FLOAT fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup) {
- IFWL_AdapterWidgetMgr* pSDApapter = GetAdapterWidgetMgr();
- return pSDApapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor,
- rtPopup);
-}
-CFWL_WidgetMgrDelegate::CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr)
- : m_pWidgetMgr(pWidgetMgr) {}
-FWL_ERR CFWL_WidgetMgrDelegate::OnSetCapability(FX_DWORD dwCapability) {
- m_pWidgetMgr->m_dwCapability = dwCapability;
- return FWL_ERR_Succeeded;
-}
-int32_t CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) {
- if (!pMessage)
- return 0;
- if (!pMessage->m_pDstTarget)
- return 0;
- IFWL_Widget* pDstWidget = pMessage->m_pDstTarget;
- IFWL_NoteThread* pNoteThread = pDstWidget->GetOwnerThread();
- if (!pNoteThread)
- return 0;
- CFWL_NoteDriver* pNoteDriver =
- static_cast<CFWL_NoteDriver*>(pNoteThread->GetNoteDriver());
- if (!pNoteDriver)
- return 0;
- if (m_pWidgetMgr->IsThreadEnabled()) {
- pMessage = static_cast<CFWL_Message*>(pMessage->Clone());
- }
- if (m_pWidgetMgr->IsFormDisabled()) {
- pNoteDriver->ProcessMessage(pMessage);
- } else {
- pNoteDriver->QueueMessage(pMessage);
- }
-#if (_FX_OS_ == _FX_MACOSX_)
- CFWL_NoteLoop* pTopLoop = pNoteDriver->GetTopLoop();
- if (pTopLoop) {
- pNoteDriver->UnqueueMessage(pTopLoop);
- }
-#endif
- if (m_pWidgetMgr->IsThreadEnabled()) {
- pMessage->Release();
- }
- return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget,
- CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- if (!pWidget)
- return FWL_ERR_Indefinite;
- if (!pGraphics)
- return FWL_ERR_Indefinite;
- CFX_Graphics* pTemp = DrawWidgetBefore(pWidget, pGraphics, pMatrix);
- CFX_RectF clipCopy;
- pWidget->GetWidgetRect(clipCopy);
- clipCopy.left = clipCopy.top = 0;
- if (bUseOffscreenDirect(pWidget)) {
- DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix);
- return FWL_ERR_Succeeded;
- }
- CFX_RectF clipBounds;
-#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) || \
- (_FX_OS_ == _FX_LINUX_DESKTOP_) || (_FX_OS_ == _FX_ANDROID_)
- IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL);
- pDelegate->OnDrawWidget(pTemp, pMatrix);
- pGraphics->GetClipRect(clipBounds);
- clipCopy = clipBounds;
-#elif(_FX_OS_ == _FX_MACOSX_)
- if (m_pWidgetMgr->IsFormDisabled()) {
- IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL);
- pDelegate->OnDrawWidget(pTemp, pMatrix);
- pGraphics->GetClipRect(clipBounds);
- clipCopy = clipBounds;
- } else {
- clipBounds.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d);
- const_cast<CFX_Matrix*>(pMatrix)->SetIdentity(); // FIXME: const cast.
-#ifdef FWL_UseMacSystemBorder
-#else
-#endif
- {
- IFWL_WidgetDelegate* pDelegate = pWidget->SetDelegate(NULL);
- pDelegate->OnDrawWidget(pTemp, pMatrix);
- }
- }
-#endif
- if (!m_pWidgetMgr->IsFormDisabled()) {
- CFX_RectF rtClient;
- pWidget->GetClientRect(rtClient);
- clipBounds.Intersect(rtClient);
- }
- if (!clipBounds.IsEmpty()) {
- DrawChild(pWidget, clipBounds, pTemp, pMatrix);
- }
- DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix);
- m_pWidgetMgr->ResetRedrawCounts(pWidget);
- return FWL_ERR_Succeeded;
-}
-void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent,
- const CFX_RectF& rtClip,
- CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- if (!parent)
- return;
- FX_BOOL bFormDisable = m_pWidgetMgr->IsFormDisabled();
- IFWL_Widget* pNextChild =
- m_pWidgetMgr->GetWidget(parent, FWL_WGTRELATION_FirstChild);
- while (pNextChild) {
- IFWL_Widget* child = pNextChild;
- pNextChild = m_pWidgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
- if (child->GetStates() & FWL_WGTSTATE_Invisible) {
- continue;
- }
- CFX_RectF rtWidget;
- child->GetWidgetRect(rtWidget);
- if (rtWidget.IsEmpty()) {
- continue;
- }
- CFX_Matrix widgetMatrix;
- CFX_RectF clipBounds(rtWidget);
- if (!bFormDisable) {
- child->GetMatrix(widgetMatrix, TRUE);
- }
- if (pMatrix) {
- widgetMatrix.Concat(*pMatrix);
- }
- if (!bFormDisable) {
- widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top);
- clipBounds.Intersect(rtClip);
- if (clipBounds.IsEmpty()) {
- continue;
- }
- pGraphics->SaveGraphState();
- pGraphics->SetClipRect(clipBounds);
- }
- widgetMatrix.Translate(rtWidget.left, rtWidget.top, TRUE);
- IFWL_WidgetDelegate* pDelegate = child->SetDelegate(NULL);
- if (pDelegate) {
- if (m_pWidgetMgr->IsFormDisabled() ||
- IsNeedRepaint(child, &widgetMatrix, rtClip)) {
- pDelegate->OnDrawWidget(pGraphics, &widgetMatrix);
- }
- }
- if (!bFormDisable) {
- pGraphics->RestoreGraphState();
- }
- DrawChild(child, clipBounds, pGraphics,
- bFormDisable ? &widgetMatrix : pMatrix);
- child = m_pWidgetMgr->GetWidget(child, FWL_WGTRELATION_NextSibling);
- }
-}
-CFX_Graphics* CFWL_WidgetMgrDelegate::DrawWidgetBefore(
- IFWL_Widget* pWidget,
- CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- if (!FWL_UseOffscreen(pWidget)) {
- return pGraphics;
- }
- CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget);
- if (!pItem->pOffscreen) {
- pItem->pOffscreen = new CFX_Graphics;
- CFX_RectF rect;
- pWidget->GetWidgetRect(rect);
- pItem->pOffscreen->Create((int32_t)rect.width, (int32_t)rect.height,
- FXDIB_Argb);
- }
- CFX_RectF rect;
- pGraphics->GetClipRect(rect);
- pItem->pOffscreen->SetClipRect(rect);
- return pItem->pOffscreen;
-}
-void CFWL_WidgetMgrDelegate::DrawWidgetAfter(IFWL_Widget* pWidget,
- CFX_Graphics* pGraphics,
- CFX_RectF& rtClip,
- const CFX_Matrix* pMatrix) {
- if (FWL_UseOffscreen(pWidget)) {
- CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget);
- pGraphics->Transfer(pItem->pOffscreen, rtClip.left, rtClip.top, rtClip,
- pMatrix);
-#ifdef _WIN32
- pItem->pOffscreen->ClearClip();
-#endif
- }
- CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget);
- pItem->iRedrawCounter = 0;
-}
-
-#define FWL_NEEDREPAINTHIT_Point 12
-#define FWL_NEEDREPAINTHIT_Piece 3
-struct FWL_NEEDREPAINTHITDATA {
- CFX_PointF hitPoint;
- FX_BOOL bNotNeedRepaint;
- FX_BOOL bNotContainByDirty;
-};
-
-FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget,
- CFX_Matrix* pMatrix,
- const CFX_RectF& rtDirty) {
- CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget);
- if (pItem && pItem->iRedrawCounter > 0) {
- pItem->iRedrawCounter = 0;
- return TRUE;
- }
- CFX_RectF rtWidget;
- pWidget->GetWidgetRect(rtWidget);
- rtWidget.left = rtWidget.top = 0;
- pMatrix->TransformRect(rtWidget);
- if (!rtWidget.IntersectWith(rtDirty)) {
- return FALSE;
- }
- IFWL_Widget* pChild =
- FWL_GetWidgetMgr()->GetWidget(pWidget, FWL_WGTRELATION_FirstChild);
- if (!pChild) {
- return TRUE;
- }
- if (pChild->GetClassID() == 3150298670) {
- CFX_RectF rtTemp;
- pChild->GetWidgetRect(rtTemp);
- if (rtTemp.width >= rtWidget.width && rtTemp.height >= rtWidget.height) {
- pChild =
- FWL_GetWidgetMgr()->GetWidget(pChild, FWL_WGTRELATION_FirstChild);
- if (!pChild) {
- return TRUE;
- }
- }
- }
- CFX_RectF rtChilds;
- rtChilds.Empty();
- FX_BOOL bChildIntersectWithDirty = FALSE;
- FX_BOOL bOrginPtIntersectWidthChild = FALSE;
- FX_BOOL bOrginPtIntersectWidthDirty =
- rtDirty.Contains(rtWidget.left, rtWidget.top);
- static FWL_NEEDREPAINTHITDATA hitPoint[FWL_NEEDREPAINTHIT_Point];
- int32_t iSize = sizeof(FWL_NEEDREPAINTHITDATA);
- FXSYS_memset(hitPoint, 0, iSize);
- FX_FLOAT fxPiece = rtWidget.width / FWL_NEEDREPAINTHIT_Piece;
- FX_FLOAT fyPiece = rtWidget.height / FWL_NEEDREPAINTHIT_Piece;
- hitPoint[2].hitPoint.x = hitPoint[6].hitPoint.x = rtWidget.left;
- hitPoint[0].hitPoint.x = hitPoint[3].hitPoint.x = hitPoint[7].hitPoint.x =
- hitPoint[10].hitPoint.x = fxPiece + rtWidget.left;
- hitPoint[1].hitPoint.x = hitPoint[4].hitPoint.x = hitPoint[8].hitPoint.x =
- hitPoint[11].hitPoint.x = fxPiece * 2 + rtWidget.left;
- hitPoint[5].hitPoint.x = hitPoint[9].hitPoint.x =
- rtWidget.width + rtWidget.left;
- hitPoint[0].hitPoint.y = hitPoint[1].hitPoint.y = rtWidget.top;
- hitPoint[2].hitPoint.y = hitPoint[3].hitPoint.y = hitPoint[4].hitPoint.y =
- hitPoint[5].hitPoint.y = fyPiece + rtWidget.top;
- hitPoint[6].hitPoint.y = hitPoint[7].hitPoint.y = hitPoint[8].hitPoint.y =
- hitPoint[9].hitPoint.y = fyPiece * 2 + rtWidget.top;
- hitPoint[10].hitPoint.y = hitPoint[11].hitPoint.y =
- rtWidget.height + rtWidget.top;
- do {
- CFX_RectF rect;
- pChild->GetWidgetRect(rect);
- CFX_RectF r = rect;
- r.left += rtWidget.left;
- r.top += rtWidget.top;
- if (r.IsEmpty()) {
- continue;
- }
- if (r.Contains(rtDirty)) {
- return FALSE;
- }
- if (!bChildIntersectWithDirty && r.IntersectWith(rtDirty)) {
- bChildIntersectWithDirty = TRUE;
- }
- if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) {
- bOrginPtIntersectWidthChild = rect.Contains(0, 0);
- }
- if (rtChilds.IsEmpty()) {
- rtChilds = rect;
- } else if (!(pChild->GetStates() & FWL_WGTSTATE_Invisible)) {
- rtChilds.Union(rect);
- }
- for (int32_t i = 0; i < FWL_NEEDREPAINTHIT_Point; i++) {
- if (hitPoint[i].bNotContainByDirty || hitPoint[i].bNotNeedRepaint) {
- continue;
- }
- if (!rtDirty.Contains(hitPoint[i].hitPoint)) {
- hitPoint[i].bNotContainByDirty = TRUE;
- continue;
- }
- if (r.Contains(hitPoint[i].hitPoint)) {
- hitPoint[i].bNotNeedRepaint = TRUE;
- }
- }
- } while ((pChild = FWL_GetWidgetMgr()->GetWidget(
- pChild, FWL_WGTRELATION_NextSibling)) != NULL);
- if (!bChildIntersectWithDirty) {
- return TRUE;
- }
- if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) {
- return TRUE;
- }
- if (rtChilds.IsEmpty()) {
- return TRUE;
- }
- int32_t repaintPoint = FWL_NEEDREPAINTHIT_Point;
- for (int32_t i = 0; i < FWL_NEEDREPAINTHIT_Point; i++) {
- if (hitPoint[i].bNotNeedRepaint) {
- repaintPoint--;
- }
- }
- if (repaintPoint > 0) {
- return TRUE;
- }
- pMatrix->TransformRect(rtChilds);
- if (rtChilds.Contains(rtDirty) || rtChilds.Contains(rtWidget)) {
- return FALSE;
- }
- return TRUE;
-}
-FX_BOOL CFWL_WidgetMgrDelegate::bUseOffscreenDirect(IFWL_Widget* pWidget) {
- CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget);
- if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen)) {
- return FALSE;
- }
-#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
- if (pItem->bOutsideChanged) {
- CFX_RectF r;
- pWidget->GetWidgetRect(r);
- CFX_RectF temp(m_pWidgetMgr->m_rtScreen);
- temp.Deflate(50, 50);
- if (!temp.Contains(r)) {
- return FALSE;
- }
- pItem->bOutsideChanged = FALSE;
- }
-#endif
- return pItem->iRedrawCounter == 0;
-}
-static void FWL_WriteBMP(CFX_DIBitmap* pBitmap, const FX_CHAR* filename) {
- FILE* file = fopen(filename, "wb");
- if (file == NULL) {
- return;
- }
- int size = 14 + 40 + pBitmap->GetPitch() * pBitmap->GetHeight();
- unsigned char buffer[40];
- buffer[0] = 'B';
- buffer[1] = 'M';
- buffer[2] = (unsigned char)size;
- buffer[3] = (unsigned char)(size >> 8);
- buffer[4] = (unsigned char)(size >> 16);
- buffer[5] = (unsigned char)(size >> 24);
- buffer[6] = buffer[7] = buffer[8] = buffer[9] = 0;
- buffer[10] = 54;
- buffer[11] = buffer[12] = buffer[13] = 0;
- fwrite(buffer, 14, 1, file);
- memset(buffer, 0, 40);
- buffer[0] = 40;
- buffer[4] = (unsigned char)pBitmap->GetWidth();
- buffer[5] = (unsigned char)(pBitmap->GetWidth() >> 8);
- buffer[6] = (unsigned char)(pBitmap->GetWidth() >> 16);
- buffer[7] = (unsigned char)(pBitmap->GetWidth() >> 24);
- buffer[8] = (unsigned char)(-pBitmap->GetHeight());
- buffer[9] = (unsigned char)((-pBitmap->GetHeight()) >> 8);
- buffer[10] = (unsigned char)((-pBitmap->GetHeight()) >> 16);
- buffer[11] = (unsigned char)((-pBitmap->GetHeight()) >> 24);
- buffer[12] = 1;
- buffer[14] = pBitmap->GetBPP();
- fwrite(buffer, 40, 1, file);
- for (int row = 0; row < pBitmap->GetHeight(); row++) {
- uint8_t* scan_line = pBitmap->GetBuffer() + row * pBitmap->GetPitch();
- fwrite(scan_line, pBitmap->GetPitch(), 1, file);
- }
- fclose(file);
-}
-FWL_ERR FWL_WidgetMgrSnapshot(IFWL_Widget* pWidget,
- const CFX_WideString* saveFile,
- const CFX_Matrix* pMatrix) {
- CFX_RectF r;
- pWidget->GetWidgetRect(r);
- CFX_Graphics gs;
- gs.Create((int32_t)r.width, (int32_t)r.height, FXDIB_Argb);
- CFWL_WidgetMgr* widgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
- CFWL_WidgetMgrDelegate* delegate = widgetMgr->GetDelegate();
- delegate->OnDrawWidget(pWidget, &gs, pMatrix);
- CFX_DIBitmap* dib = gs.GetRenderDevice()->GetBitmap();
- FWL_WriteBMP(dib, saveFile->UTF8Encode());
- return FWL_ERR_Succeeded;
-}
-FX_BOOL FWL_WidgetIsChild(IFWL_Widget* parent, IFWL_Widget* find) {
- if (!find) {
- return FALSE;
- }
- IFWL_Widget* child =
- FWL_GetWidgetMgr()->GetWidget(parent, FWL_WGTRELATION_FirstChild);
- while (child) {
- if (child == find) {
- return TRUE;
- }
- if (FWL_WidgetIsChild(child, find)) {
- return TRUE;
- }
- child = FWL_GetWidgetMgr()->GetWidget(child, FWL_WGTRELATION_NextSibling);
- }
- return FALSE;
-}
diff --git a/xfa/src/fwl/core/fwl_widgetmgrimp.h b/xfa/src/fwl/core/fwl_widgetmgrimp.h
deleted file mode 100644
index f3dfb36017..0000000000
--- a/xfa/src/fwl/core/fwl_widgetmgrimp.h
+++ /dev/null
@@ -1,170 +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_SRC_FWL_CORE_FWL_WIDGETMGRIMP_H_
-#define XFA_SRC_FWL_CORE_FWL_WIDGETMGRIMP_H_
-
-#include "xfa/include/fwl/core/fwl_widgetmgr.h"
-
-class IFWL_Widget;
-class IFWL_AdapterWidgetMgr;
-class CFWL_WidgetMgrDelegate;
-class IFWL_AdapterNative;
-
-class CFWL_WidgetMgrItem {
- public:
- CFWL_WidgetMgrItem()
- : pParent(NULL),
- pOwner(NULL),
- pChild(NULL),
- pPrevious(NULL),
- pNext(NULL),
- pWidget(NULL),
- pOffscreen(NULL),
- iRedrawCounter(0)
-#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
- ,
- bOutsideChanged(FALSE)
-#endif
- {
- }
- ~CFWL_WidgetMgrItem() {
- if (pOffscreen) {
- delete pOffscreen;
- pOffscreen = NULL;
- }
- }
- CFWL_WidgetMgrItem* pParent;
- CFWL_WidgetMgrItem* pOwner;
- CFWL_WidgetMgrItem* pChild;
- CFWL_WidgetMgrItem* pPrevious;
- CFWL_WidgetMgrItem* pNext;
- IFWL_Widget* pWidget;
- CFX_Graphics* pOffscreen;
- int32_t iRedrawCounter;
-#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
- FX_BOOL bOutsideChanged;
-#endif
-};
-
-class CFWL_WidgetMgr : public IFWL_WidgetMgr {
- public:
- CFWL_WidgetMgr(IFWL_AdapterNative* pAdapterNative);
- ~CFWL_WidgetMgr() override;
-
- // IFWL_WidgetMgr:
- int32_t CountWidgets(IFWL_Widget* pParent = NULL) override;
- IFWL_Widget* GetWidget(int32_t nIndex, IFWL_Widget* pParent = NULL) override;
- IFWL_Widget* GetWidget(IFWL_Widget* pWidget,
- FWL_WGTRELATION eRelation) override;
- int32_t GetWidgetIndex(IFWL_Widget* pWidget) override;
- FX_BOOL SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) override;
- FWL_ERR RepaintWidget(IFWL_Widget* pWidget,
- const CFX_RectF* pRect = NULL) override;
- FX_DWORD GetCapability() override { return m_dwCapability; }
-
- void AddWidget(IFWL_Widget* pWidget);
- void InsertWidget(IFWL_Widget* pParent,
- IFWL_Widget* pChild,
- int32_t nIndex = -1);
- void RemoveWidget(IFWL_Widget* pWidget);
- void SetOwner(IFWL_Widget* pOwner, IFWL_Widget* pOwned);
- void SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild);
- FX_BOOL IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent);
- FWL_ERR CreateWidget_Native(IFWL_Widget* pWidget);
- FWL_ERR DestroyWidget_Native(IFWL_Widget* pWidget);
- FWL_ERR GetWidgetRect_Native(IFWL_Widget* pWidget, CFX_RectF& rect);
- FWL_ERR SetWidgetRect_Native(IFWL_Widget* pWidget, const CFX_RectF& rect);
- FWL_ERR SetWidgetPosition_Native(IFWL_Widget* pWidget,
- FX_FLOAT fx,
- FX_FLOAT fy);
- FWL_ERR SetWidgetIcon_Native(IFWL_Widget* pWidget,
- const CFX_DIBitmap* pIcon,
- FX_BOOL bBig);
- FWL_ERR SetWidgetCaption_Native(IFWL_Widget* pWidget,
- const CFX_WideStringC& wsCaption);
- FWL_ERR SetBorderRegion_Native(IFWL_Widget* pWidget, CFX_Path* pPath);
- FWL_ERR ShowWidget_Native(IFWL_Widget* pWidget);
- FWL_ERR HideWidget_Native(IFWL_Widget* pWidget);
- FWL_ERR SetNormal_Native(IFWL_Widget* pWidget);
- FWL_ERR SetMaximize_Native(IFWL_Widget* pWidget);
- FWL_ERR SetMinimize_Native(IFWL_Widget* pWidget);
- FX_BOOL CheckMessage_Native();
- FWL_ERR DispatchMessage_Native();
- FX_BOOL IsIdleMessage_Native();
- FWL_ERR Exit_Native(int32_t iExitCode);
- FWL_ERR CreateWidgetWithNativeId_Native(IFWL_Widget* pWidget, void* vp);
- IFWL_Widget* GetWidgetAtPoint(IFWL_Widget* pParent, FX_FLOAT fx, FX_FLOAT fy);
- void NotifySizeChanged(IFWL_Widget* pForm, FX_FLOAT fx, FX_FLOAT fy);
- IFWL_Widget* nextTab(IFWL_Widget* parent, IFWL_Widget* focus, FX_BOOL& bFind);
- int32_t CountRadioButtonGroup(IFWL_Widget* pFirst);
- IFWL_Widget* GetSiblingRadioButton(IFWL_Widget* pWidget, FX_BOOL bNext);
- IFWL_Widget* GetRadioButtonGroupHeader(IFWL_Widget* pRadioButton);
- void GetSameGroupRadioButton(IFWL_Widget* pRadioButton, CFX_PtrArray& group);
- IFWL_Widget* GetDefaultButton(IFWL_Widget* pParent);
- void AddRedrawCounts(IFWL_Widget* pWidget);
- void ResetRedrawCounts(IFWL_Widget* pWidget);
- IFWL_AdapterWidgetMgr* GetAdapterWidgetMgr() { return m_pAdapter; }
- CFWL_WidgetMgrDelegate* GetDelegate() { return m_pDelegate; }
- CFWL_WidgetMgrItem* GetWidgetMgrItem(IFWL_Widget* pWidget);
- FX_BOOL IsThreadEnabled();
- FX_BOOL IsFormDisabled();
- FX_BOOL GetAdapterPopupPos(IFWL_Widget* pWidget,
- FX_FLOAT fMinHeight,
- FX_FLOAT fMaxHeight,
- const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup);
-
- protected:
- int32_t TravelWidgetMgr(CFWL_WidgetMgrItem* pParent,
- int32_t* pIndex,
- CFWL_WidgetMgrItem* pItem,
- IFWL_Widget** pWidget = NULL);
- FX_BOOL IsAbleNative(IFWL_Widget* pWidget);
- CFX_MapPtrToPtr m_mapWidgetItem;
- IFWL_AdapterWidgetMgr* m_pAdapter;
- CFWL_WidgetMgrDelegate* m_pDelegate;
- friend class CFWL_WidgetMgrDelegate;
- FX_DWORD m_dwCapability;
-#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
- CFX_RectF m_rtScreen;
-#endif
-};
-
-class CFWL_WidgetMgrDelegate : public IFWL_WidgetMgrDelegate {
- public:
- CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr);
- ~CFWL_WidgetMgrDelegate() override {}
-
- // IFWL_WidgetMgrDelegate:
- FWL_ERR OnSetCapability(
- FX_DWORD dwCapability = FWL_WGTMGR_DisableThread) override;
- int32_t OnProcessMessageToForm(CFWL_Message* pMessage) override;
- FWL_ERR OnDrawWidget(IFWL_Widget* pWidget,
- CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) override;
-
- protected:
- void DrawChild(IFWL_Widget* pParent,
- const CFX_RectF& rtClip,
- CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix);
- CFX_Graphics* DrawWidgetBefore(IFWL_Widget* pWidget,
- CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix);
- void DrawWidgetAfter(IFWL_Widget* pWidget,
- CFX_Graphics* pGraphics,
- CFX_RectF& rtClip,
- const CFX_Matrix* pMatrix);
- FX_BOOL IsNeedRepaint(IFWL_Widget* pWidget,
- CFX_Matrix* pMatrix,
- const CFX_RectF& rtDirty);
- FX_BOOL bUseOffscreenDirect(IFWL_Widget* pWidget);
-
- CFWL_WidgetMgr* m_pWidgetMgr;
-};
-
-#endif // XFA_SRC_FWL_CORE_FWL_WIDGETMGRIMP_H_