summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fwl/core/cfwl_widget.cpp8
-rw-r--r--xfa/fwl/core/cfwl_widget.h4
-rw-r--r--xfa/fwl/core/cfwl_widgetmgr.cpp8
-rw-r--r--xfa/fwl/core/fwl_noteimp.cpp8
-rw-r--r--xfa/fwl/core/ifwl_barcode.cpp13
-rw-r--r--xfa/fwl/core/ifwl_barcode.h10
-rw-r--r--xfa/fwl/core/ifwl_caret.cpp18
-rw-r--r--xfa/fwl/core/ifwl_caret.h17
-rw-r--r--xfa/fwl/core/ifwl_checkbox.cpp151
-rw-r--r--xfa/fwl/core/ifwl_checkbox.h23
-rw-r--r--xfa/fwl/core/ifwl_combobox.cpp460
-rw-r--r--xfa/fwl/core/ifwl_combobox.h68
-rw-r--r--xfa/fwl/core/ifwl_comboboxproxy.cpp118
-rw-r--r--xfa/fwl/core/ifwl_comboboxproxy.h41
-rw-r--r--xfa/fwl/core/ifwl_comboedit.cpp17
-rw-r--r--xfa/fwl/core/ifwl_comboedit.h13
-rw-r--r--xfa/fwl/core/ifwl_combolist.cpp121
-rw-r--r--xfa/fwl/core/ifwl_combolist.h15
-rw-r--r--xfa/fwl/core/ifwl_datetimecalendar.cpp188
-rw-r--r--xfa/fwl/core/ifwl_datetimecalendar.h17
-rw-r--r--xfa/fwl/core/ifwl_datetimeedit.cpp31
-rw-r--r--xfa/fwl/core/ifwl_datetimeedit.h11
-rw-r--r--xfa/fwl/core/ifwl_datetimepicker.cpp161
-rw-r--r--xfa/fwl/core/ifwl_datetimepicker.h36
-rw-r--r--xfa/fwl/core/ifwl_edit.cpp351
-rw-r--r--xfa/fwl/core/ifwl_edit.h22
-rw-r--r--xfa/fwl/core/ifwl_form.cpp286
-rw-r--r--xfa/fwl/core/ifwl_form.h16
-rw-r--r--xfa/fwl/core/ifwl_formproxy.cpp8
-rw-r--r--xfa/fwl/core/ifwl_formproxy.h11
-rw-r--r--xfa/fwl/core/ifwl_listbox.cpp233
-rw-r--r--xfa/fwl/core/ifwl_listbox.h17
-rw-r--r--xfa/fwl/core/ifwl_monthcalendar.cpp198
-rw-r--r--xfa/fwl/core/ifwl_monthcalendar.h30
-rw-r--r--xfa/fwl/core/ifwl_picturebox.cpp11
-rw-r--r--xfa/fwl/core/ifwl_picturebox.h15
-rw-r--r--xfa/fwl/core/ifwl_pushbutton.cpp153
-rw-r--r--xfa/fwl/core/ifwl_pushbutton.h20
-rw-r--r--xfa/fwl/core/ifwl_scrollbar.cpp252
-rw-r--r--xfa/fwl/core/ifwl_scrollbar.h18
-rw-r--r--xfa/fwl/core/ifwl_spinbutton.cpp297
-rw-r--r--xfa/fwl/core/ifwl_spinbutton.h21
-rw-r--r--xfa/fwl/core/ifwl_tooltip.cpp21
-rw-r--r--xfa/fwl/core/ifwl_tooltip.h18
-rw-r--r--xfa/fwl/core/ifwl_widget.cpp31
-rw-r--r--xfa/fwl/core/ifwl_widget.h42
-rw-r--r--xfa/fxfa/app/xfa_ffbarcode.cpp4
-rw-r--r--xfa/fxfa/app/xfa_ffcheckbutton.cpp4
-rw-r--r--xfa/fxfa/app/xfa_ffchoicelist.cpp8
-rw-r--r--xfa/fxfa/app/xfa_ffimageedit.cpp4
-rw-r--r--xfa/fxfa/app/xfa_ffpushbutton.cpp4
-rw-r--r--xfa/fxfa/app/xfa_fftextedit.cpp16
52 files changed, 1601 insertions, 2067 deletions
diff --git a/xfa/fwl/core/cfwl_widget.cpp b/xfa/fwl/core/cfwl_widget.cpp
index 999a5a8443..db0d4ebb5e 100644
--- a/xfa/fwl/core/cfwl_widget.cpp
+++ b/xfa/fwl/core/cfwl_widget.cpp
@@ -127,11 +127,11 @@ FWL_Error CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics,
return m_pIface->DrawWidget(pGraphics, pMatrix);
}
-IFWL_WidgetDelegate* CFWL_Widget::GetCurrentDelegate() {
- return m_pIface ? m_pIface->GetCurrentDelegate() : nullptr;
+IFWL_WidgetDelegate* CFWL_Widget::GetDelegate() const {
+ return m_pIface ? m_pIface->GetDelegate() : nullptr;
}
-void CFWL_Widget::SetCurrentDelegate(IFWL_WidgetDelegate* pDelegate) {
+void CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) {
if (m_pIface)
- m_pIface->SetCurrentDelegate(pDelegate);
+ m_pIface->SetDelegate(pDelegate);
}
diff --git a/xfa/fwl/core/cfwl_widget.h b/xfa/fwl/core/cfwl_widget.h
index 28a76661ef..2921145f6a 100644
--- a/xfa/fwl/core/cfwl_widget.h
+++ b/xfa/fwl/core/cfwl_widget.h
@@ -51,8 +51,8 @@ class CFWL_Widget {
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr);
- IFWL_WidgetDelegate* GetCurrentDelegate();
- void SetCurrentDelegate(IFWL_WidgetDelegate*);
+ IFWL_WidgetDelegate* GetDelegate() const;
+ void SetDelegate(IFWL_WidgetDelegate*);
protected:
void Initialize();
diff --git a/xfa/fwl/core/cfwl_widgetmgr.cpp b/xfa/fwl/core/cfwl_widgetmgr.cpp
index 1008defcab..37e31dc501 100644
--- a/xfa/fwl/core/cfwl_widgetmgr.cpp
+++ b/xfa/fwl/core/cfwl_widgetmgr.cpp
@@ -613,18 +613,18 @@ void CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget,
#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ || \
_FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_
- pWidget->GetCurrentDelegate()->OnDrawWidget(pTemp, pMatrix);
+ pWidget->GetDelegate()->OnDrawWidget(pTemp, pMatrix);
pGraphics->GetClipRect(clipBounds);
clipCopy = clipBounds;
#elif _FX_OS_ == _FX_MACOSX_
if (m_pWidgetMgr->IsFormDisabled()) {
- pWidget->GetCurrentDelegate()->OnDrawWidget(pTemp, pMatrix);
+ pWidget->GetDelegate()->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.
- pWidget->GetCurrentDelegate()->OnDrawWidget(pTemp, pMatrix);
+ pWidget->GetDelegate()->OnDrawWidget(pTemp, pMatrix);
}
#endif // _FX_OS_ == _FX_MACOSX_
@@ -678,7 +678,7 @@ void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent,
}
widgetMatrix.Translate(rtWidget.left, rtWidget.top, TRUE);
- if (IFWL_WidgetDelegate* pDelegate = child->GetCurrentDelegate()) {
+ if (IFWL_WidgetDelegate* pDelegate = child->GetDelegate()) {
if (m_pWidgetMgr->IsFormDisabled() ||
IsNeedRepaint(child, &widgetMatrix, rtClip)) {
pDelegate->OnDrawWidget(pGraphics, &widgetMatrix);
diff --git a/xfa/fwl/core/fwl_noteimp.cpp b/xfa/fwl/core/fwl_noteimp.cpp
index 2ca34f9619..2c67f6e34a 100644
--- a/xfa/fwl/core/fwl_noteimp.cpp
+++ b/xfa/fwl/core/fwl_noteimp.cpp
@@ -144,7 +144,7 @@ FX_BOOL CFWL_NoteDriver::SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify) {
if (bNotify) {
ms.m_dwExtend = 1;
}
- if (IFWL_WidgetDelegate* pDelegate = pPrev->GetCurrentDelegate())
+ if (IFWL_WidgetDelegate* pDelegate = pPrev->GetDelegate())
pDelegate->OnProcessMessage(&ms);
}
if (pFocus) {
@@ -160,7 +160,7 @@ FX_BOOL CFWL_NoteDriver::SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify) {
ms.m_dwExtend = 1;
}
- if (IFWL_WidgetDelegate* pDelegate = pFocus->GetCurrentDelegate())
+ if (IFWL_WidgetDelegate* pDelegate = pFocus->GetDelegate())
pDelegate->OnProcessMessage(&ms);
}
return TRUE;
@@ -361,7 +361,7 @@ FX_BOOL CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage,
}
if (bRet) {
if (IFWL_WidgetDelegate* pDelegate =
- pMessage->m_pDstTarget->GetCurrentDelegate()) {
+ pMessage->m_pDstTarget->GetDelegate()) {
pDelegate->OnProcessMessage(pMessage);
}
}
@@ -707,7 +707,7 @@ int32_t CFWL_EventTarget::SetEventSource(IFWL_Widget* pSource,
}
FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) {
- IFWL_WidgetDelegate* pDelegate = m_pListener->GetCurrentDelegate();
+ IFWL_WidgetDelegate* pDelegate = m_pListener->GetDelegate();
if (!pDelegate)
return FALSE;
if (m_eventSources.GetCount() == 0) {
diff --git a/xfa/fwl/core/ifwl_barcode.cpp b/xfa/fwl/core/ifwl_barcode.cpp
index 9a2d91a459..e708e7ed53 100644
--- a/xfa/fwl/core/ifwl_barcode.cpp
+++ b/xfa/fwl/core/ifwl_barcode.cpp
@@ -16,7 +16,6 @@
IFWL_Barcode::IFWL_Barcode(const IFWL_App* app,
const CFWL_WidgetImpProperties& properties)
: IFWL_Edit(app, properties, nullptr), m_dwStatus(0), m_type(BC_UNKNOWN) {
- SetDelegate(pdfium::MakeUnique<CFWL_BarcodeImpDelegate>(this));
}
IFWL_Barcode::~IFWL_Barcode() {}
@@ -175,14 +174,10 @@ FX_BOOL IFWL_Barcode::IsProtectedType() {
return FALSE;
}
-CFWL_BarcodeImpDelegate::CFWL_BarcodeImpDelegate(IFWL_Barcode* pOwner)
- : CFWL_EditImpDelegate(pOwner) {}
-
-void CFWL_BarcodeImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
+void IFWL_Barcode::OnProcessEvent(CFWL_Event* pEvent) {
if (pEvent->GetClassID() == CFWL_EventType::TextChanged) {
- IFWL_Barcode* pOwner = static_cast<IFWL_Barcode*>(m_pOwner);
- pOwner->m_pBarcodeEngine.reset();
- pOwner->m_dwStatus = XFA_BCS_NeedUpdate;
+ m_pBarcodeEngine.reset();
+ m_dwStatus = XFA_BCS_NeedUpdate;
}
- CFWL_EditImpDelegate::OnProcessEvent(pEvent);
+ IFWL_Edit::OnProcessEvent(pEvent);
}
diff --git a/xfa/fwl/core/ifwl_barcode.h b/xfa/fwl/core/ifwl_barcode.h
index f7f28428f5..33cb442e50 100644
--- a/xfa/fwl/core/ifwl_barcode.h
+++ b/xfa/fwl/core/ifwl_barcode.h
@@ -13,7 +13,6 @@
#include "xfa/fwl/core/ifwl_scrollbar.h"
#include "xfa/fxbarcode/BC_Library.h"
-class CFWL_BarcodeImpDelegate;
class CFWL_WidgetImpProperties;
class CFX_Barcode;
class IFWL_Widget;
@@ -68,13 +67,12 @@ class IFWL_Barcode : public IFWL_Edit {
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
FWL_Error SetText(const CFX_WideString& wsText) override;
+ void OnProcessEvent(CFWL_Event* pEvent) override;
void SetType(BC_TYPE type);
FX_BOOL IsProtectedType();
protected:
- friend class CFWL_BarcodeImpDelegate;
-
void GenerateBarcodeImageCache();
void CreateBarcodeEngine();
@@ -83,10 +81,4 @@ class IFWL_Barcode : public IFWL_Edit {
BC_TYPE m_type;
};
-class CFWL_BarcodeImpDelegate : public CFWL_EditImpDelegate {
- public:
- explicit CFWL_BarcodeImpDelegate(IFWL_Barcode* pOwner);
- void OnProcessEvent(CFWL_Event* pEvent) override;
-};
-
#endif // XFA_FWL_CORE_IFWL_BARCODE_H_
diff --git a/xfa/fwl/core/ifwl_caret.cpp b/xfa/fwl/core/ifwl_caret.cpp
index 2dd1866642..94b56e8cf9 100644
--- a/xfa/fwl/core/ifwl_caret.cpp
+++ b/xfa/fwl/core/ifwl_caret.cpp
@@ -22,7 +22,6 @@ IFWL_Caret::IFWL_Caret(const IFWL_App* app,
m_dwElapse(400),
m_bSetColor(FALSE) {
SetStates(FWL_STATE_CAT_HightLight);
- SetDelegate(pdfium::MakeUnique<CFWL_CaretImpDelegate>(this));
}
IFWL_Caret::~IFWL_Caret() {
@@ -99,6 +98,13 @@ void IFWL_Caret::DrawCaretBK(CFX_Graphics* pGraphics,
pTheme->DrawBackground(&param);
}
+void IFWL_Caret::OnProcessMessage(CFWL_Message* pMessage) {}
+
+void IFWL_Caret::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ DrawWidget(pGraphics, pMatrix);
+}
+
IFWL_Caret::Timer::Timer(IFWL_Caret* pCaret) : IFWL_Timer(pCaret) {}
void IFWL_Caret::Timer::Run(IFWL_TimerInfo* pTimerInfo) {
@@ -111,13 +117,3 @@ void IFWL_Caret::Timer::Run(IFWL_TimerInfo* pTimerInfo) {
rt.Set(0, 0, rt.width + 1, rt.height);
pCaret->Repaint(&rt);
}
-
-CFWL_CaretImpDelegate::CFWL_CaretImpDelegate(IFWL_Caret* pOwner)
- : m_pOwner(pOwner) {}
-
-void CFWL_CaretImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {}
-
-void CFWL_CaretImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- m_pOwner->DrawWidget(pGraphics, pMatrix);
-}
diff --git a/xfa/fwl/core/ifwl_caret.h b/xfa/fwl/core/ifwl_caret.h
index 022cadad27..888e8ffbed 100644
--- a/xfa/fwl/core/ifwl_caret.h
+++ b/xfa/fwl/core/ifwl_caret.h
@@ -15,7 +15,6 @@
class CFWL_WidgetImpProperties;
class IFWL_Widget;
-class CFWL_CaretImpDelegate;
#define FWL_STATE_CAT_HightLight 1
@@ -30,6 +29,9 @@ class IFWL_Caret : public IFWL_Widget {
FWL_Type GetClassID() const override;
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) override;
void ShowCaret(FX_BOOL bFlag = TRUE);
FWL_Error GetFrequency(uint32_t& elapse);
@@ -37,8 +39,6 @@ class IFWL_Caret : public IFWL_Widget {
FWL_Error SetColor(CFX_Color crFill);
protected:
- friend class CFWL_CaretImpDelegate;
-
class Timer : public IFWL_Timer {
public:
explicit Timer(IFWL_Caret* pCaret);
@@ -59,15 +59,4 @@ class IFWL_Caret : public IFWL_Widget {
FX_BOOL m_bSetColor;
};
-class CFWL_CaretImpDelegate : public CFWL_WidgetImpDelegate {
- public:
- CFWL_CaretImpDelegate(IFWL_Caret* pOwner);
- void OnProcessMessage(CFWL_Message* pMessage) override;
- void OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) override;
-
- protected:
- IFWL_Caret* m_pOwner;
-};
-
#endif // XFA_FWL_CORE_IFWL_CARET_H_
diff --git a/xfa/fwl/core/ifwl_checkbox.cpp b/xfa/fwl/core/ifwl_checkbox.cpp
index 23edbd7907..b4e6fd4ce1 100644
--- a/xfa/fwl/core/ifwl_checkbox.cpp
+++ b/xfa/fwl/core/ifwl_checkbox.cpp
@@ -35,8 +35,6 @@ IFWL_CheckBox::IFWL_CheckBox(const IFWL_App* app,
m_rtBox.Reset();
m_rtCaption.Reset();
m_rtFocus.Reset();
-
- SetDelegate(pdfium::MakeUnique<CFWL_CheckBoxImpDelegate>(this));
}
IFWL_CheckBox::~IFWL_CheckBox() {}
@@ -392,45 +390,35 @@ void IFWL_CheckBox::NextStates() {
}
}
-CFWL_CheckBoxImpDelegate::CFWL_CheckBoxImpDelegate(IFWL_CheckBox* pOwner)
- : m_pOwner(pOwner) {}
-
-void CFWL_CheckBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+void IFWL_CheckBox::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
return;
switch (pMessage->GetClassID()) {
- case CFWL_MessageType::Activate: {
+ case CFWL_MessageType::Activate:
OnActivate(pMessage);
break;
- }
- case CFWL_MessageType::SetFocus: {
+ case CFWL_MessageType::SetFocus:
OnFocusChanged(pMessage, TRUE);
break;
- }
- case CFWL_MessageType::KillFocus: {
+ case CFWL_MessageType::KillFocus:
OnFocusChanged(pMessage, FALSE);
break;
- }
case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
switch (pMsg->m_dwCmd) {
- case FWL_MouseCommand::LeftButtonDown: {
+ case FWL_MouseCommand::LeftButtonDown:
OnLButtonDown(pMsg);
break;
- }
- case FWL_MouseCommand::LeftButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp:
OnLButtonUp(pMsg);
break;
- }
- case FWL_MouseCommand::Move: {
+ case FWL_MouseCommand::Move:
OnMouseMove(pMsg);
break;
- }
- case FWL_MouseCommand::Leave: {
+ case FWL_MouseCommand::Leave:
OnMouseLeave(pMsg);
break;
- }
default:
break;
}
@@ -442,112 +430,111 @@ void CFWL_CheckBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
OnKeyDown(pKey);
break;
}
- default: { break; }
+ default:
+ break;
}
- CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+ IFWL_Widget::OnProcessMessage(pMessage);
}
-void CFWL_CheckBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- m_pOwner->DrawWidget(pGraphics, pMatrix);
+void IFWL_CheckBox::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ DrawWidget(pGraphics, pMatrix);
}
-void CFWL_CheckBoxImpDelegate::OnActivate(CFWL_Message* pMsg) {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
- m_pOwner->Repaint(&(m_pOwner->m_rtClient));
+void IFWL_CheckBox::OnActivate(CFWL_Message* pMsg) {
+ m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
+ Repaint(&(m_rtClient));
}
-void CFWL_CheckBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
- FX_BOOL bSet) {
- if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- } else {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- }
- m_pOwner->Repaint(&(m_pOwner->m_rtClient));
+void IFWL_CheckBox::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
+ if (bSet)
+ m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+ else
+ m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+
+ Repaint(&(m_rtClient));
}
-void CFWL_CheckBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
+void IFWL_CheckBox::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
return;
- }
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
- m_pOwner->SetFocus(TRUE);
- }
- m_pOwner->m_bBtnDown = TRUE;
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered;
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed;
- m_pOwner->Repaint(&(m_pOwner->m_rtClient));
+ if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
+ SetFocus(TRUE);
+
+ m_bBtnDown = TRUE;
+ m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered;
+ m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed;
+ Repaint(&(m_rtClient));
}
-void CFWL_CheckBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
- if (!m_pOwner->m_bBtnDown) {
+void IFWL_CheckBox::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ if (!m_bBtnDown)
return;
- }
- m_pOwner->m_bBtnDown = FALSE;
- if (!m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
+
+ m_bBtnDown = FALSE;
+ if (!m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy))
return;
- }
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Pressed;
- m_pOwner->NextStates();
+
+ m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
+ m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Pressed;
+ NextStates();
}
-void CFWL_CheckBoxImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
+void IFWL_CheckBox::OnMouseMove(CFWL_MsgMouse* pMsg) {
+ if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
return;
- }
+
FX_BOOL bRepaint = FALSE;
- if (m_pOwner->m_bBtnDown) {
- if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) == 0) {
+ if (m_bBtnDown) {
+ if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if ((m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) == 0) {
bRepaint = TRUE;
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed;
+ m_pProperties->m_dwStates |= FWL_STATE_CKB_Pressed;
}
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered)) {
+ if ((m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered)) {
bRepaint = TRUE;
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered;
+ m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered;
}
} else {
- if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) {
+ if (m_pProperties->m_dwStates & FWL_STATE_CKB_Pressed) {
bRepaint = TRUE;
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Pressed;
+ m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Pressed;
}
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) == 0) {
+ if ((m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) == 0) {
bRepaint = TRUE;
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
+ m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
}
}
} else {
- if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) == 0) {
+ if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if ((m_pProperties->m_dwStates & FWL_STATE_CKB_Hovered) == 0) {
bRepaint = TRUE;
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
+ m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
}
}
}
if (bRepaint) {
- m_pOwner->Repaint(&(m_pOwner->m_rtBox));
+ Repaint(&(m_rtBox));
}
}
-void CFWL_CheckBoxImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_bBtnDown) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
- } else {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered;
- }
- m_pOwner->Repaint(&(m_pOwner->m_rtBox));
+void IFWL_CheckBox::OnMouseLeave(CFWL_MsgMouse* pMsg) {
+ if (m_bBtnDown)
+ m_pProperties->m_dwStates |= FWL_STATE_CKB_Hovered;
+ else
+ m_pProperties->m_dwStates &= ~FWL_STATE_CKB_Hovered;
+
+ Repaint(&(m_rtBox));
}
-void CFWL_CheckBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
+void IFWL_CheckBox::OnKeyDown(CFWL_MsgKey* pMsg) {
if (pMsg->m_dwKeyCode == FWL_VKEY_Tab) {
- m_pOwner->DispatchKeyEvent(pMsg);
+ DispatchKeyEvent(pMsg);
return;
}
if (pMsg->m_dwKeyCode == FWL_VKEY_Return ||
pMsg->m_dwKeyCode == FWL_VKEY_Space) {
- m_pOwner->NextStates();
+ NextStates();
}
}
diff --git a/xfa/fwl/core/ifwl_checkbox.h b/xfa/fwl/core/ifwl_checkbox.h
index 4d112c3723..6222e4be79 100644
--- a/xfa/fwl/core/ifwl_checkbox.h
+++ b/xfa/fwl/core/ifwl_checkbox.h
@@ -43,7 +43,6 @@
#define FWL_STATE_CKB_Neutral (2 << (FWL_WGTSTATE_MAX + 2))
#define FWL_STATE_CKB_CheckMask (3L << (FWL_WGTSTATE_MAX + 2))
-class CFWL_CheckBoxImpDelegate;
class CFWL_MsgMouse;
class CFWL_WidgetImpProperties;
class IFWL_Widget;
@@ -67,12 +66,15 @@ class IFWL_CheckBox : public IFWL_Widget {
FWL_Error Update() override;
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
+
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) override;
+
int32_t GetCheckState();
FWL_Error SetCheckState(int32_t iCheck);
protected:
- friend class CFWL_CheckBoxImpDelegate;
-
void Layout();
uint32_t GetPartStates();
void UpdateTextOutStyles();
@@ -85,26 +87,15 @@ class IFWL_CheckBox : public IFWL_Widget {
uint32_t m_dwTTOStyles;
int32_t m_iTTOAlign;
FX_BOOL m_bBtnDown;
-};
-class CFWL_CheckBoxImpDelegate : public CFWL_WidgetImpDelegate {
- public:
- CFWL_CheckBoxImpDelegate(IFWL_CheckBox* pOwner);
-
- void OnProcessMessage(CFWL_Message* pMessage) override;
- void OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) override;
-
- protected:
+ private:
void OnActivate(CFWL_Message* pMsg);
- void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet);
void OnLButtonDown(CFWL_MsgMouse* pMsg);
void OnLButtonUp(CFWL_MsgMouse* pMsg);
void OnMouseMove(CFWL_MsgMouse* pMsg);
void OnMouseLeave(CFWL_MsgMouse* pMsg);
void OnKeyDown(CFWL_MsgKey* pMsg);
-
- IFWL_CheckBox* m_pOwner;
};
#endif // XFA_FWL_CORE_IFWL_CHECKBOX_H_
diff --git a/xfa/fwl/core/ifwl_combobox.cpp b/xfa/fwl/core/ifwl_combobox.cpp
index 28a5977425..1721aee2a7 100644
--- a/xfa/fwl/core/ifwl_combobox.cpp
+++ b/xfa/fwl/core/ifwl_combobox.cpp
@@ -16,6 +16,7 @@
#include "xfa/fwl/core/cfwl_widgetmgr.h"
#include "xfa/fwl/core/fwl_noteimp.h"
#include "xfa/fwl/core/ifwl_app.h"
+#include "xfa/fwl/core/ifwl_comboboxproxy.h"
#include "xfa/fwl/core/ifwl_comboedit.h"
#include "xfa/fwl/core/ifwl_combolist.h"
#include "xfa/fwl/core/ifwl_formproxy.h"
@@ -24,7 +25,7 @@
IFWL_ComboBox::IFWL_ComboBox(const IFWL_App* app,
const CFWL_WidgetImpProperties& properties)
: IFWL_Widget(app, properties, nullptr),
- m_pForm(nullptr),
+ m_pComboBoxProxy(nullptr),
m_bLButtonDown(FALSE),
m_iCurSel(-1),
m_iBtnState(CFWL_PartState_Normal),
@@ -34,8 +35,6 @@ IFWL_ComboBox::IFWL_ComboBox(const IFWL_App* app,
m_rtBtn.Reset();
m_rtHandler.Reset();
- SetDelegate(pdfium::MakeUnique<CFWL_ComboBoxImpDelegate>(this));
-
if (m_pWidgetMgr->IsFormDisabled()) {
DisForm_InitComboList();
DisForm_InitComboEdit();
@@ -455,17 +454,16 @@ void IFWL_ComboBox::DrawStretchHandler(CFX_Graphics* pGraphics,
}
void IFWL_ComboBox::ShowDropList(FX_BOOL bActivate) {
- if (m_pWidgetMgr->IsFormDisabled()) {
+ if (m_pWidgetMgr->IsFormDisabled())
return DisForm_ShowDropList(bActivate);
- }
+
FX_BOOL bDropList = IsDropListShowed();
- if (bDropList == bActivate) {
+ if (bDropList == bActivate)
return;
- }
- if (!m_pForm) {
+ if (!m_pComboBoxProxy)
InitProxyForm();
- }
- m_pListProxyDelegate->Reset();
+
+ m_pComboBoxProxy->Reset();
if (bActivate) {
m_pListBox->ChangeSelected(m_iCurSel);
ReSetListItemAlignment();
@@ -505,8 +503,8 @@ void IFWL_ComboBox::ShowDropList(FX_BOOL bActivate) {
m_fComboFormHandler);
}
}
- m_pForm->SetWidgetRect(m_rtProxy);
- m_pForm->Update();
+ m_pComboBoxProxy->SetWidgetRect(m_rtProxy);
+ m_pComboBoxProxy->Update();
m_pListBox->SetWidgetRect(m_rtList);
m_pListBox->Update();
CFWL_EvtCmbPreDropDown ev;
@@ -514,10 +512,10 @@ void IFWL_ComboBox::ShowDropList(FX_BOOL bActivate) {
DispatchEvent(&ev);
m_fItemHeight = m_pListBox->m_fItemHeight;
m_pListBox->SetFocus(TRUE);
- m_pForm->DoModal();
+ m_pComboBoxProxy->DoModal();
m_pListBox->SetFocus(FALSE);
} else {
- m_pForm->EndDoModal();
+ m_pComboBoxProxy->EndDoModal();
CFWL_EvtCmbCloseUp ev;
ev.m_pSrcTarget = this;
DispatchEvent(&ev);
@@ -528,7 +526,8 @@ void IFWL_ComboBox::ShowDropList(FX_BOOL bActivate) {
}
FX_BOOL IFWL_ComboBox::IsDropListShowed() {
- return m_pForm && !(m_pForm->GetStates() & FWL_WGTSTATE_Invisible);
+ return m_pComboBoxProxy &&
+ !(m_pComboBoxProxy->GetStates() & FWL_WGTSTATE_Invisible);
}
FX_BOOL IFWL_ComboBox::IsDropDownStyle() const {
@@ -689,7 +688,7 @@ void IFWL_ComboBox::ProcessSelChanged(FX_BOOL bLButtonUp) {
}
void IFWL_ComboBox::InitProxyForm() {
- if (m_pForm)
+ if (m_pComboBoxProxy)
return;
if (!m_pListBox)
return;
@@ -699,10 +698,9 @@ void IFWL_ComboBox::InitProxyForm() {
propForm.m_dwStyles = FWL_WGTSTYLE_Popup;
propForm.m_dwStates = FWL_WGTSTATE_Invisible;
- m_pForm = new IFWL_FormProxy(m_pOwnerApp, propForm, m_pListBox.get());
- m_pListBox->SetParent(m_pForm);
- m_pListProxyDelegate = new CFWL_ComboProxyImpDelegate(m_pForm, this);
- m_pForm->SetCurrentDelegate(m_pListProxyDelegate);
+ m_pComboBoxProxy =
+ new IFWL_ComboBoxProxy(this, m_pOwnerApp, propForm, m_pListBox.get());
+ m_pListBox->SetParent(m_pComboBoxProxy);
}
void IFWL_ComboBox::DisForm_InitComboList() {
@@ -914,11 +912,8 @@ void IFWL_ComboBox::DisForm_Layout() {
}
}
-CFWL_ComboBoxImpDelegate::CFWL_ComboBoxImpDelegate(IFWL_ComboBox* pOwner)
- : m_pOwner(pOwner) {}
-
-void CFWL_ComboBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
- if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
+void IFWL_ComboBox::OnProcessMessage(CFWL_Message* pMessage) {
+ if (m_pWidgetMgr->IsFormDisabled()) {
DisForm_OnProcessMessage(pMessage);
return;
}
@@ -926,226 +921,217 @@ void CFWL_ComboBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
return;
switch (pMessage->GetClassID()) {
- case CFWL_MessageType::SetFocus: {
+ case CFWL_MessageType::SetFocus:
OnFocusChanged(pMessage, TRUE);
break;
- }
- case CFWL_MessageType::KillFocus: {
+ case CFWL_MessageType::KillFocus:
OnFocusChanged(pMessage, FALSE);
break;
- }
case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
switch (pMsg->m_dwCmd) {
- case FWL_MouseCommand::LeftButtonDown: {
+ case FWL_MouseCommand::LeftButtonDown:
OnLButtonDown(pMsg);
break;
- }
- case FWL_MouseCommand::LeftButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp:
OnLButtonUp(pMsg);
break;
- }
- case FWL_MouseCommand::Move: {
+ case FWL_MouseCommand::Move:
OnMouseMove(pMsg);
break;
- }
- case FWL_MouseCommand::Leave: {
+ case FWL_MouseCommand::Leave:
OnMouseLeave(pMsg);
break;
- }
default:
break;
}
break;
}
- case CFWL_MessageType::Key: {
+ case CFWL_MessageType::Key:
OnKey(static_cast<CFWL_MsgKey*>(pMessage));
break;
- }
- default: { break; }
+ default:
+ break;
}
- CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+ IFWL_Widget::OnProcessMessage(pMessage);
}
-void CFWL_ComboBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
+void IFWL_ComboBox::OnProcessEvent(CFWL_Event* pEvent) {
CFWL_EventType dwFlag = pEvent->GetClassID();
if (dwFlag == CFWL_EventType::DrawItem) {
CFWL_EvtLtbDrawItem* pDrawItemEvent =
static_cast<CFWL_EvtLtbDrawItem*>(pEvent);
CFWL_EvtCmbDrawItem pTemp;
- pTemp.m_pSrcTarget = m_pOwner;
+ pTemp.m_pSrcTarget = this;
pTemp.m_pGraphics = pDrawItemEvent->m_pGraphics;
pTemp.m_index = pDrawItemEvent->m_index;
pTemp.m_rtItem = pDrawItemEvent->m_rect;
- m_pOwner->DispatchEvent(&pTemp);
+ DispatchEvent(&pTemp);
} else if (dwFlag == CFWL_EventType::Scroll) {
CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent);
CFWL_EvtScroll pScrollEv;
- pScrollEv.m_pSrcTarget = m_pOwner;
+ pScrollEv.m_pSrcTarget = this;
pScrollEv.m_iScrollCode = pScrollEvent->m_iScrollCode;
pScrollEv.m_fPos = pScrollEvent->m_fPos;
- m_pOwner->DispatchEvent(&pScrollEv);
+ DispatchEvent(&pScrollEv);
} else if (dwFlag == CFWL_EventType::TextChanged) {
CFWL_EvtEdtTextChanged* pTextChangedEvent =
static_cast<CFWL_EvtEdtTextChanged*>(pEvent);
CFWL_EvtCmbEditChanged pTemp;
- pTemp.m_pSrcTarget = m_pOwner;
+ pTemp.m_pSrcTarget = this;
pTemp.wsInsert = pTextChangedEvent->wsInsert;
pTemp.wsDelete = pTextChangedEvent->wsDelete;
pTemp.nChangeType = pTextChangedEvent->nChangeType;
- m_pOwner->DispatchEvent(&pTemp);
+ DispatchEvent(&pTemp);
}
}
-void CFWL_ComboBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- m_pOwner->DrawWidget(pGraphics, pMatrix);
+void IFWL_ComboBox::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ DrawWidget(pGraphics, pMatrix);
}
-void CFWL_ComboBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
- FX_BOOL bSet) {
+void IFWL_ComboBox::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
IFWL_Widget* pDstTarget = pMsg->m_pDstTarget;
IFWL_Widget* pSrcTarget = pMsg->m_pSrcTarget;
- FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
+ FX_BOOL bDropDown = IsDropDownStyle();
if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- if (bDropDown && pSrcTarget != m_pOwner->m_pListBox.get()) {
- if (!m_pOwner->m_pEdit)
+ m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+ if (bDropDown && pSrcTarget != m_pListBox.get()) {
+ if (!m_pEdit)
return;
- m_pOwner->m_pEdit->SetSelected();
+ m_pEdit->SetSelected();
} else {
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ Repaint(&m_rtClient);
}
} else {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- if (bDropDown && pDstTarget != m_pOwner->m_pListBox.get()) {
- if (!m_pOwner->m_pEdit)
+ m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+ if (bDropDown && pDstTarget != m_pListBox.get()) {
+ if (!m_pEdit)
return;
- m_pOwner->m_pEdit->FlagFocus(FALSE);
- m_pOwner->m_pEdit->ClearSelected();
+ m_pEdit->FlagFocus(FALSE);
+ m_pEdit->ClearSelected();
} else {
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ Repaint(&m_rtClient);
}
}
}
-void CFWL_ComboBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
+void IFWL_ComboBox::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
return;
- }
- FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
- CFX_RectF& rtBtn = bDropDown ? m_pOwner->m_rtBtn : m_pOwner->m_rtClient;
+
+ FX_BOOL bDropDown = IsDropDownStyle();
+ CFX_RectF& rtBtn = bDropDown ? m_rtBtn : m_rtClient;
FX_BOOL bClickBtn = rtBtn.Contains(pMsg->m_fx, pMsg->m_fy);
- if (bClickBtn) {
- if (bDropDown && m_pOwner->m_pEdit) {
- m_pOwner->MatchEditText();
- }
- m_pOwner->m_bLButtonDown = TRUE;
- m_pOwner->m_iBtnState = CFWL_PartState_Pressed;
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- m_pOwner->ShowDropList(TRUE);
- m_pOwner->m_iBtnState = CFWL_PartState_Normal;
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- }
+ if (!bClickBtn)
+ return;
+
+ if (bDropDown && m_pEdit)
+ MatchEditText();
+
+ m_bLButtonDown = TRUE;
+ m_iBtnState = CFWL_PartState_Pressed;
+ Repaint(&m_rtClient);
+ ShowDropList(TRUE);
+ m_iBtnState = CFWL_PartState_Normal;
+ Repaint(&m_rtClient);
}
-void CFWL_ComboBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
- m_pOwner->m_bLButtonDown = FALSE;
- if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iBtnState = CFWL_PartState_Hovered;
- } else {
- m_pOwner->m_iBtnState = CFWL_PartState_Normal;
- }
- m_pOwner->Repaint(&m_pOwner->m_rtBtn);
+void IFWL_ComboBox::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ m_bLButtonDown = FALSE;
+ if (m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy))
+ m_iBtnState = CFWL_PartState_Hovered;
+ else
+ m_iBtnState = CFWL_PartState_Normal;
+
+ Repaint(&m_rtBtn);
}
-void CFWL_ComboBoxImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
- int32_t iOldState = m_pOwner->m_iBtnState;
- if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iBtnState = m_pOwner->m_bLButtonDown ? CFWL_PartState_Pressed
- : CFWL_PartState_Hovered;
+void IFWL_ComboBox::OnMouseMove(CFWL_MsgMouse* pMsg) {
+ int32_t iOldState = m_iBtnState;
+ if (m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_iBtnState =
+ m_bLButtonDown ? CFWL_PartState_Pressed : CFWL_PartState_Hovered;
} else {
- m_pOwner->m_iBtnState = CFWL_PartState_Normal;
+ m_iBtnState = CFWL_PartState_Normal;
}
- if ((iOldState != m_pOwner->m_iBtnState) &&
- !((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) ==
+ if ((iOldState != m_iBtnState) &&
+ !((m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) ==
FWL_WGTSTATE_Disabled)) {
- m_pOwner->Repaint(&m_pOwner->m_rtBtn);
+ Repaint(&m_rtBtn);
}
}
-void CFWL_ComboBoxImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
- if (!m_pOwner->IsDropListShowed() &&
- !((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) ==
+void IFWL_ComboBox::OnMouseLeave(CFWL_MsgMouse* pMsg) {
+ if (!IsDropListShowed() &&
+ !((m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) ==
FWL_WGTSTATE_Disabled)) {
- m_pOwner->m_iBtnState = CFWL_PartState_Normal;
- m_pOwner->Repaint(&m_pOwner->m_rtBtn);
+ m_iBtnState = CFWL_PartState_Normal;
+ Repaint(&m_rtBtn);
}
}
-void CFWL_ComboBoxImpDelegate::OnKey(CFWL_MsgKey* pMsg) {
+void IFWL_ComboBox::OnKey(CFWL_MsgKey* pMsg) {
uint32_t dwKeyCode = pMsg->m_dwKeyCode;
if (dwKeyCode == FWL_VKEY_Tab) {
- m_pOwner->DispatchKeyEvent(pMsg);
+ DispatchKeyEvent(pMsg);
return;
}
- if (pMsg->m_pDstTarget == m_pOwner)
+ if (pMsg->m_pDstTarget == this)
DoSubCtrlKey(pMsg);
}
-void CFWL_ComboBoxImpDelegate::DoSubCtrlKey(CFWL_MsgKey* pMsg) {
+void IFWL_ComboBox::DoSubCtrlKey(CFWL_MsgKey* pMsg) {
uint32_t dwKeyCode = pMsg->m_dwKeyCode;
const bool bUp = dwKeyCode == FWL_VKEY_Up;
const bool bDown = dwKeyCode == FWL_VKEY_Down;
if (bUp || bDown) {
- int32_t iCount = m_pOwner->m_pListBox->CountItems();
- if (iCount < 1) {
+ int32_t iCount = m_pListBox->CountItems();
+ if (iCount < 1)
return;
- }
+
FX_BOOL bMatchEqual = FALSE;
- int32_t iCurSel = m_pOwner->m_iCurSel;
- FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
- if (bDropDown && m_pOwner->m_pEdit) {
+ int32_t iCurSel = m_iCurSel;
+ FX_BOOL bDropDown = IsDropDownStyle();
+ if (bDropDown && m_pEdit) {
CFX_WideString wsText;
- m_pOwner->m_pEdit->GetText(wsText);
- iCurSel = m_pOwner->m_pListBox->MatchItem(wsText);
+ m_pEdit->GetText(wsText);
+ iCurSel = m_pListBox->MatchItem(wsText);
if (iCurSel >= 0) {
CFX_WideString wsTemp;
- IFWL_ComboBoxDP* pData = static_cast<IFWL_ComboBoxDP*>(
- m_pOwner->m_pProperties->m_pDataProvider);
- IFWL_ListItem* hItem = pData->GetItem(m_pOwner, iCurSel);
- m_pOwner->m_pListBox->GetItemText(hItem, wsTemp);
+ IFWL_ComboBoxDP* pData =
+ static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
+ IFWL_ListItem* hItem = pData->GetItem(this, iCurSel);
+ m_pListBox->GetItemText(hItem, wsTemp);
bMatchEqual = wsText == wsTemp;
}
}
if (iCurSel < 0) {
iCurSel = 0;
} else if (!bDropDown || bMatchEqual) {
- if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1)) {
+ if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1))
return;
- }
- if (bUp) {
+ if (bUp)
iCurSel--;
- } else {
+ else
iCurSel++;
- }
- }
- m_pOwner->m_iCurSel = iCurSel;
- if (bDropDown && m_pOwner->m_pEdit) {
- m_pOwner->SynchrEditText(m_pOwner->m_iCurSel);
- } else {
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
}
+ m_iCurSel = iCurSel;
+ if (bDropDown && m_pEdit)
+ SynchrEditText(m_iCurSel);
+ else
+ Repaint(&m_rtClient);
return;
}
- FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
+
+ FX_BOOL bDropDown = IsDropDownStyle();
if (bDropDown)
- m_pOwner->m_pEdit->GetCurrentDelegate()->OnProcessMessage(pMsg);
+ m_pEdit->GetDelegate()->OnProcessMessage(pMsg);
}
-void CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage(
- CFWL_Message* pMessage) {
+void IFWL_ComboBox::DisForm_OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
return;
@@ -1165,14 +1151,12 @@ void CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage(
backDefault = FALSE;
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
switch (pMsg->m_dwCmd) {
- case FWL_MouseCommand::LeftButtonDown: {
+ case FWL_MouseCommand::LeftButtonDown:
DisForm_OnLButtonDown(pMsg);
break;
- }
- case FWL_MouseCommand::LeftButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp:
OnLButtonUp(pMsg);
break;
- }
default:
break;
}
@@ -1183,15 +1167,14 @@ void CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage(
CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage);
if (pKey->m_dwCmd == FWL_KeyCommand::KeyUp)
break;
- if (m_pOwner->DisForm_IsDropListShowed() &&
+ if (DisForm_IsDropListShowed() &&
pKey->m_dwCmd == FWL_KeyCommand::KeyDown) {
FX_BOOL bListKey = pKey->m_dwKeyCode == FWL_VKEY_Up ||
pKey->m_dwKeyCode == FWL_VKEY_Down ||
pKey->m_dwKeyCode == FWL_VKEY_Return ||
pKey->m_dwKeyCode == FWL_VKEY_Escape;
if (bListKey) {
- m_pOwner->m_pListBox->GetCurrentDelegate()->OnProcessMessage(
- pMessage);
+ m_pListBox->GetDelegate()->OnProcessMessage(pMessage);
break;
}
}
@@ -1202,199 +1185,80 @@ void CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage(
break;
}
if (backDefault)
- CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+ IFWL_Widget::OnProcessMessage(pMessage);
}
-void CFWL_ComboBoxImpDelegate::DisForm_OnLButtonDown(CFWL_MsgMouse* pMsg) {
- FX_BOOL bDropDown = m_pOwner->DisForm_IsDropListShowed();
- CFX_RectF& rtBtn = bDropDown ? m_pOwner->m_rtBtn : m_pOwner->m_rtClient;
- FX_BOOL bClickBtn = rtBtn.Contains(pMsg->m_fx, pMsg->m_fy);
- if (bClickBtn) {
- if (m_pOwner->DisForm_IsDropListShowed()) {
- m_pOwner->DisForm_ShowDropList(FALSE);
- return;
- }
- {
- if (m_pOwner->m_pEdit) {
- m_pOwner->MatchEditText();
- }
- m_pOwner->DisForm_ShowDropList(TRUE);
- }
+void IFWL_ComboBox::DisForm_OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ FX_BOOL bDropDown = DisForm_IsDropListShowed();
+ CFX_RectF& rtBtn = bDropDown ? m_rtBtn : m_rtClient;
+ if (!rtBtn.Contains(pMsg->m_fx, pMsg->m_fy))
+ return;
+
+ if (DisForm_IsDropListShowed()) {
+ DisForm_ShowDropList(FALSE);
+ return;
}
+ if (m_pEdit)
+ MatchEditText();
+ DisForm_ShowDropList(TRUE);
}
-void CFWL_ComboBoxImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg,
- FX_BOOL bSet) {
+void IFWL_ComboBox::DisForm_OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- if ((m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) == 0) {
+ m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+ if ((m_pEdit->GetStates() & FWL_WGTSTATE_Focused) == 0) {
CFWL_MsgSetFocus msg;
- msg.m_pDstTarget = m_pOwner->m_pEdit.get();
+ msg.m_pDstTarget = m_pEdit.get();
msg.m_pSrcTarget = nullptr;
- m_pOwner->m_pEdit->GetCurrentDelegate()->OnProcessMessage(&msg);
+ m_pEdit->GetDelegate()->OnProcessMessage(&msg);
}
} else {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- m_pOwner->DisForm_ShowDropList(FALSE);
+ m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+ DisForm_ShowDropList(FALSE);
CFWL_MsgKillFocus msg;
msg.m_pDstTarget = nullptr;
- msg.m_pSrcTarget = m_pOwner->m_pEdit.get();
- m_pOwner->m_pEdit->GetCurrentDelegate()->OnProcessMessage(&msg);
+ msg.m_pSrcTarget = m_pEdit.get();
+ m_pEdit->GetDelegate()->OnProcessMessage(&msg);
}
}
-void CFWL_ComboBoxImpDelegate::DisForm_OnKey(CFWL_MsgKey* pMsg) {
+void IFWL_ComboBox::DisForm_OnKey(CFWL_MsgKey* pMsg) {
uint32_t dwKeyCode = pMsg->m_dwKeyCode;
const bool bUp = dwKeyCode == FWL_VKEY_Up;
const bool bDown = dwKeyCode == FWL_VKEY_Down;
if (bUp || bDown) {
- IFWL_ComboList* pComboList = m_pOwner->m_pListBox.get();
+ IFWL_ComboList* pComboList = m_pListBox.get();
int32_t iCount = pComboList->CountItems();
- if (iCount < 1) {
+ if (iCount < 1)
return;
- }
+
FX_BOOL bMatchEqual = FALSE;
- int32_t iCurSel = m_pOwner->m_iCurSel;
- if (m_pOwner->m_pEdit) {
+ int32_t iCurSel = m_iCurSel;
+ if (m_pEdit) {
CFX_WideString wsText;
- m_pOwner->m_pEdit->GetText(wsText);
+ m_pEdit->GetText(wsText);
iCurSel = pComboList->MatchItem(wsText);
if (iCurSel >= 0) {
CFX_WideString wsTemp;
- IFWL_ListItem* item = m_pOwner->m_pListBox->GetSelItem(iCurSel);
- m_pOwner->m_pListBox->GetItemText(item, wsTemp);
+ IFWL_ListItem* item = m_pListBox->GetSelItem(iCurSel);
+ m_pListBox->GetItemText(item, wsTemp);
bMatchEqual = wsText == wsTemp;
}
}
if (iCurSel < 0) {
iCurSel = 0;
} else if (bMatchEqual) {
- if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1)) {
+ if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1))
return;
- }
- if (bUp) {
+ if (bUp)
iCurSel--;
- } else {
+ else
iCurSel++;
- }
}
- m_pOwner->m_iCurSel = iCurSel;
- m_pOwner->SynchrEditText(m_pOwner->m_iCurSel);
+ m_iCurSel = iCurSel;
+ SynchrEditText(m_iCurSel);
return;
}
- if (m_pOwner->m_pEdit)
- m_pOwner->m_pEdit->GetCurrentDelegate()->OnProcessMessage(pMsg);
-}
-
-CFWL_ComboProxyImpDelegate::CFWL_ComboProxyImpDelegate(IFWL_Form* pForm,
- IFWL_ComboBox* pComboBox)
- : m_bLButtonDown(FALSE),
- m_bLButtonUpSelf(FALSE),
- m_fStartPos(0),
- m_pForm(pForm),
- m_pComboBox(pComboBox) {}
-
-void CFWL_ComboProxyImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
- if (!pMessage)
- return;
-
- switch (pMessage->GetClassID()) {
- case CFWL_MessageType::Mouse: {
- CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
- switch (pMsg->m_dwCmd) {
- case FWL_MouseCommand::LeftButtonDown: {
- OnLButtonDown(pMsg);
- break;
- }
- case FWL_MouseCommand::LeftButtonUp: {
- OnLButtonUp(pMsg);
- break;
- }
- case FWL_MouseCommand::Move: {
- OnMouseMove(pMsg);
- break;
- }
- default:
- break;
- }
- break;
- }
- case CFWL_MessageType::Deactivate: {
- OnDeactive(static_cast<CFWL_MsgDeactivate*>(pMessage));
- break;
- }
- case CFWL_MessageType::KillFocus: {
- OnFocusChanged(static_cast<CFWL_MsgKillFocus*>(pMessage), FALSE);
- break;
- }
- case CFWL_MessageType::SetFocus: {
- OnFocusChanged(static_cast<CFWL_MsgKillFocus*>(pMessage), TRUE);
- break;
- }
- default:
- break;
- }
- CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
-}
-
-void CFWL_ComboProxyImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- m_pComboBox->DrawStretchHandler(pGraphics, pMatrix);
-}
-
-void CFWL_ComboProxyImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
- const IFWL_App* pApp = m_pForm->GetOwnerApp();
- if (!pApp)
- return;
-
- CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
- CFX_RectF rtWidget;
- m_pForm->GetWidgetRect(rtWidget);
- rtWidget.left = rtWidget.top = 0;
- if (rtWidget.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_bLButtonDown = TRUE;
- pDriver->SetGrab(m_pForm, TRUE);
- } else {
- m_bLButtonDown = FALSE;
- pDriver->SetGrab(m_pForm, FALSE);
- m_pComboBox->ShowDropList(FALSE);
- }
-}
-
-void CFWL_ComboProxyImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
- m_bLButtonDown = FALSE;
- const IFWL_App* pApp = m_pForm->GetOwnerApp();
- if (!pApp)
- return;
-
- CFWL_NoteDriver* pDriver =
- static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
- pDriver->SetGrab(m_pForm, FALSE);
- if (m_bLButtonUpSelf) {
- CFX_RectF rect;
- m_pForm->GetWidgetRect(rect);
- rect.left = rect.top = 0;
- if (!rect.Contains(pMsg->m_fx, pMsg->m_fy) &&
- m_pComboBox->IsDropListShowed()) {
- m_pComboBox->ShowDropList(FALSE);
- }
- } else {
- m_bLButtonUpSelf = TRUE;
- }
-}
-
-void CFWL_ComboProxyImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {}
-
-void CFWL_ComboProxyImpDelegate::OnDeactive(CFWL_MsgDeactivate* pMsg) {
- m_pComboBox->ShowDropList(FALSE);
-}
-
-void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus* pMsg,
- FX_BOOL bSet) {
- if (!bSet) {
- if (!pMsg->m_pSetFocus) {
- m_pComboBox->ShowDropList(FALSE);
- }
- }
+ if (m_pEdit)
+ m_pEdit->GetDelegate()->OnProcessMessage(pMsg);
}
diff --git a/xfa/fwl/core/ifwl_combobox.h b/xfa/fwl/core/ifwl_combobox.h
index 5fab49986c..cde99d8df1 100644
--- a/xfa/fwl/core/ifwl_combobox.h
+++ b/xfa/fwl/core/ifwl_combobox.h
@@ -11,14 +11,9 @@
#include "xfa/fwl/core/ifwl_listbox.h"
#include "xfa/fxgraphics/cfx_graphics.h"
-class CFWL_ComboBoxImpDelegate;
-class CFWL_ComboEditImpDelegate;
-class CFWL_ComboListImpDelegate;
-class CFWL_ComboProxyImpDelegate;
-class CFWL_ListBoxImpDelegate;
class CFWL_WidgetImpProperties;
-class CFWL_WidgetImpDelegate;
class IFWL_ComboBox;
+class IFWL_ComboBoxProxy;
class IFWL_ComboEdit;
class IFWL_ComboList;
class IFWL_FormProxy;
@@ -99,6 +94,10 @@ class IFWL_ComboBox : public IFWL_Widget {
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessEvent(CFWL_Event* pEvent) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) override;
int32_t GetCurSel();
FWL_Error SetCurSel(int32_t iSel);
@@ -134,18 +133,16 @@ class IFWL_ComboBox : public IFWL_Widget {
FWL_Error EditModifyStylesEx(uint32_t dwStylesExAdded,
uint32_t dwStylesExRemoved);
- protected:
- friend class CFWL_ComboBoxImpDelegate;
- friend class CFWL_ComboEditImpDelegate;
- friend class CFWL_ComboListImpDelegate;
- friend class CFWL_ComboProxyImpDelegate;
- friend class IFWL_ComboEdit;
- friend class IFWL_ComboList;
-
void DrawStretchHandler(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix);
- FX_FLOAT GetListHeight();
- void ShowDropList(FX_BOOL bActivate);
FX_BOOL IsDropListShowed();
+ void ShowDropList(FX_BOOL bActivate);
+
+ IFWL_ComboEdit* GetComboEdit() const { return m_pEdit.get(); }
+ void ProcessSelChanged(FX_BOOL bLButtonUp);
+ int32_t GetCurrentSelection() const { return m_iCurSel; }
+
+ protected:
+ FX_FLOAT GetListHeight();
FX_BOOL IsDropDownStyle() const;
void MatchEditText();
void SynchrEditText(int32_t iListItem);
@@ -153,7 +150,6 @@ class IFWL_ComboBox : public IFWL_Widget {
void ReSetTheme();
void ReSetEditAlignment();
void ReSetListItemAlignment();
- void ProcessSelChanged(FX_BOOL bLButtonUp);
void InitProxyForm();
void DisForm_InitComboList();
void DisForm_InitComboEdit();
@@ -176,7 +172,7 @@ class IFWL_ComboBox : public IFWL_Widget {
CFX_RectF m_rtHandler;
std::unique_ptr<IFWL_ComboEdit> m_pEdit;
std::unique_ptr<IFWL_ComboList> m_pListBox;
- IFWL_FormProxy* m_pForm;
+ IFWL_ComboBoxProxy* m_pComboBoxProxy;
FX_BOOL m_bLButtonDown;
FX_BOOL m_bUpFormHandler;
int32_t m_iCurSel;
@@ -184,18 +180,8 @@ class IFWL_ComboBox : public IFWL_Widget {
FX_FLOAT m_fComboFormHandler;
FX_FLOAT m_fItemHeight;
FX_BOOL m_bNeedShowList;
- CFWL_ComboProxyImpDelegate* m_pListProxyDelegate;
-};
-
-class CFWL_ComboBoxImpDelegate : public CFWL_WidgetImpDelegate {
- public:
- CFWL_ComboBoxImpDelegate(IFWL_ComboBox* pOwner);
- void OnProcessMessage(CFWL_Message* pMessage) override;
- void OnProcessEvent(CFWL_Event* pEvent) override;
- void OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) override;
- protected:
+ private:
void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
void OnLButtonDown(CFWL_MsgMouse* pMsg);
void OnLButtonUp(CFWL_MsgMouse* pMsg);
@@ -208,30 +194,6 @@ class CFWL_ComboBoxImpDelegate : public CFWL_WidgetImpDelegate {
void DisForm_OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
void DisForm_OnKey(CFWL_MsgKey* pMsg);
- IFWL_ComboBox* m_pOwner;
- friend class CFWL_ComboEditImpDelegate;
- friend class CFWL_ComboListImpDelegate;
-};
-
-class CFWL_ComboProxyImpDelegate : public CFWL_WidgetImpDelegate {
- public:
- CFWL_ComboProxyImpDelegate(IFWL_Form* pForm, IFWL_ComboBox* pComboBox);
- void OnProcessMessage(CFWL_Message* pMessage) override;
- void OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) override;
- void Reset() { m_bLButtonUpSelf = FALSE; }
-
- protected:
- void OnLButtonDown(CFWL_MsgMouse* pMsg);
- void OnLButtonUp(CFWL_MsgMouse* pMsg);
- void OnMouseMove(CFWL_MsgMouse* pMsg);
- void OnDeactive(CFWL_MsgDeactivate* pMsg);
- void OnFocusChanged(CFWL_MsgKillFocus* pMsg, FX_BOOL bSet);
- FX_BOOL m_bLButtonDown;
- FX_BOOL m_bLButtonUpSelf;
- FX_FLOAT m_fStartPos;
- IFWL_Form* m_pForm;
- IFWL_ComboBox* m_pComboBox;
};
#endif // XFA_FWL_CORE_IFWL_COMBOBOX_H_
diff --git a/xfa/fwl/core/ifwl_comboboxproxy.cpp b/xfa/fwl/core/ifwl_comboboxproxy.cpp
new file mode 100644
index 0000000000..a0afcd1d72
--- /dev/null
+++ b/xfa/fwl/core/ifwl_comboboxproxy.cpp
@@ -0,0 +1,118 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fwl/core/ifwl_comboboxproxy.h"
+
+#include "xfa/fwl/core/fwl_noteimp.h"
+#include "xfa/fwl/core/ifwl_app.h"
+#include "xfa/fwl/core/ifwl_combobox.h"
+
+IFWL_ComboBoxProxy::IFWL_ComboBoxProxy(
+ IFWL_ComboBox* pComboBox,
+ const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter)
+ : IFWL_FormProxy(app, properties, pOuter),
+ m_bLButtonDown(FALSE),
+ m_bLButtonUpSelf(FALSE),
+ m_pComboBox(pComboBox) {}
+
+IFWL_ComboBoxProxy::~IFWL_ComboBoxProxy() {}
+
+void IFWL_ComboBoxProxy::OnProcessMessage(CFWL_Message* pMessage) {
+ if (!pMessage)
+ return;
+
+ switch (pMessage->GetClassID()) {
+ case CFWL_MessageType::Mouse: {
+ CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
+ switch (pMsg->m_dwCmd) {
+ case FWL_MouseCommand::LeftButtonDown:
+ OnLButtonDown(pMsg);
+ break;
+ case FWL_MouseCommand::LeftButtonUp:
+ OnLButtonUp(pMsg);
+ break;
+ case FWL_MouseCommand::Move:
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+ case CFWL_MessageType::Deactivate:
+ OnDeactive(static_cast<CFWL_MsgDeactivate*>(pMessage));
+ break;
+ case CFWL_MessageType::KillFocus:
+ OnFocusChanged(static_cast<CFWL_MsgKillFocus*>(pMessage), FALSE);
+ break;
+ case CFWL_MessageType::SetFocus:
+ OnFocusChanged(static_cast<CFWL_MsgKillFocus*>(pMessage), TRUE);
+ break;
+ default:
+ break;
+ }
+ IFWL_Widget::OnProcessMessage(pMessage);
+}
+
+void IFWL_ComboBoxProxy::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ m_pComboBox->DrawStretchHandler(pGraphics, pMatrix);
+}
+
+void IFWL_ComboBoxProxy::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ const IFWL_App* pApp = GetOwnerApp();
+ if (!pApp)
+ return;
+
+ CFWL_NoteDriver* pDriver =
+ static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
+ CFX_RectF rtWidget;
+ GetWidgetRect(rtWidget);
+ rtWidget.left = rtWidget.top = 0;
+ if (rtWidget.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_bLButtonDown = TRUE;
+ pDriver->SetGrab(this, TRUE);
+ } else {
+ m_bLButtonDown = FALSE;
+ pDriver->SetGrab(this, FALSE);
+ m_pComboBox->ShowDropList(FALSE);
+ }
+}
+
+void IFWL_ComboBoxProxy::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ m_bLButtonDown = FALSE;
+ const IFWL_App* pApp = GetOwnerApp();
+ if (!pApp)
+ return;
+
+ CFWL_NoteDriver* pDriver =
+ static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
+ pDriver->SetGrab(this, FALSE);
+ if (m_bLButtonUpSelf) {
+ CFX_RectF rect;
+ GetWidgetRect(rect);
+ rect.left = rect.top = 0;
+ if (!rect.Contains(pMsg->m_fx, pMsg->m_fy) &&
+ m_pComboBox->IsDropListShowed()) {
+ m_pComboBox->ShowDropList(FALSE);
+ }
+ } else {
+ m_bLButtonUpSelf = TRUE;
+ }
+}
+
+void IFWL_ComboBoxProxy::OnDeactive(CFWL_MsgDeactivate* pMsg) {
+ m_pComboBox->ShowDropList(FALSE);
+}
+
+void IFWL_ComboBoxProxy::OnFocusChanged(CFWL_MsgKillFocus* pMsg, FX_BOOL bSet) {
+ if (bSet)
+ return;
+
+ if (!pMsg->m_pSetFocus)
+ m_pComboBox->ShowDropList(FALSE);
+}
diff --git a/xfa/fwl/core/ifwl_comboboxproxy.h b/xfa/fwl/core/ifwl_comboboxproxy.h
new file mode 100644
index 0000000000..1cf7a06ccb
--- /dev/null
+++ b/xfa/fwl/core/ifwl_comboboxproxy.h
@@ -0,0 +1,41 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FWL_CORE_IFWL_COMBOBOXPROXY_H_
+#define XFA_FWL_CORE_IFWL_COMBOBOXPROXY_H_
+
+#include "xfa/fwl/core/ifwl_formproxy.h"
+
+class IFWL_ComboBox;
+
+class IFWL_ComboBoxProxy : public IFWL_FormProxy {
+ public:
+ IFWL_ComboBoxProxy(IFWL_ComboBox* pCombobBox,
+ const IFWL_App* app,
+ const CFWL_WidgetImpProperties& properties,
+ IFWL_Widget* pOuter);
+ ~IFWL_ComboBoxProxy() override;
+
+ // IFWL_FormProxy
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) override;
+
+ void Reset() { m_bLButtonUpSelf = FALSE; }
+
+ private:
+ void OnLButtonDown(CFWL_MsgMouse* pMsg);
+ void OnLButtonUp(CFWL_MsgMouse* pMsg);
+ void OnDeactive(CFWL_MsgDeactivate* pMsg);
+ void OnFocusChanged(CFWL_MsgKillFocus* pMsg, FX_BOOL bSet);
+
+ FX_BOOL m_bLButtonDown;
+ FX_BOOL m_bLButtonUpSelf;
+
+ IFWL_ComboBox* m_pComboBox;
+};
+
+#endif // XFA_FWL_CORE_IFWL_COMBOBOXPROXY_H_
diff --git a/xfa/fwl/core/ifwl_comboedit.cpp b/xfa/fwl/core/ifwl_comboedit.cpp
index fc28536d50..ece35417ef 100644
--- a/xfa/fwl/core/ifwl_comboedit.cpp
+++ b/xfa/fwl/core/ifwl_comboedit.cpp
@@ -44,31 +44,28 @@ void IFWL_ComboEdit::SetComboBoxFocus(FX_BOOL bSet) {
m_pOuter->SetFocus(bSet);
}
-CFWL_ComboEditImpDelegate::CFWL_ComboEditImpDelegate(IFWL_ComboEdit* pOwner)
- : CFWL_EditImpDelegate(pOwner), m_pOwner(pOwner) {}
-
-void CFWL_ComboEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+void IFWL_ComboEdit::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
return;
FX_BOOL backDefault = TRUE;
switch (pMessage->GetClassID()) {
case CFWL_MessageType::SetFocus: {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+ m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
backDefault = FALSE;
break;
}
case CFWL_MessageType::KillFocus: {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+ m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
backDefault = FALSE;
break;
}
case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
if ((pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonDown) &&
- ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)) {
- m_pOwner->SetSelected();
- m_pOwner->SetComboBoxFocus(TRUE);
+ ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)) {
+ SetSelected();
+ SetComboBoxFocus(TRUE);
}
break;
}
@@ -76,5 +73,5 @@ void CFWL_ComboEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
break;
}
if (backDefault)
- CFWL_EditImpDelegate::OnProcessMessage(pMessage);
+ IFWL_Edit::OnProcessMessage(pMessage);
}
diff --git a/xfa/fwl/core/ifwl_comboedit.h b/xfa/fwl/core/ifwl_comboedit.h
index f4a529a186..9c321d1cd4 100644
--- a/xfa/fwl/core/ifwl_comboedit.h
+++ b/xfa/fwl/core/ifwl_comboedit.h
@@ -19,6 +19,9 @@ class IFWL_ComboEdit : public IFWL_Edit {
const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
+ // IFWL_Edit.
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+
void ClearSelected();
void SetSelected();
void EndCaret();
@@ -27,16 +30,6 @@ class IFWL_ComboEdit : public IFWL_Edit {
protected:
void SetComboBoxFocus(FX_BOOL bSet);
IFWL_ComboBox* m_pOuter;
- friend class CFWL_ComboEditImpDelegate;
-};
-
-class CFWL_ComboEditImpDelegate : public CFWL_EditImpDelegate {
- public:
- CFWL_ComboEditImpDelegate(IFWL_ComboEdit* pOwner);
- void OnProcessMessage(CFWL_Message* pMessage) override;
-
- protected:
- IFWL_ComboEdit* m_pOwner;
};
#endif // XFA_FWL_CORE_IFWL_COMBOEDIT_H_
diff --git a/xfa/fwl/core/ifwl_combolist.cpp b/xfa/fwl/core/ifwl_combolist.cpp
index 0fdc5ac6d9..5a2ade96de 100644
--- a/xfa/fwl/core/ifwl_combolist.cpp
+++ b/xfa/fwl/core/ifwl_combolist.cpp
@@ -15,7 +15,6 @@ IFWL_ComboList::IFWL_ComboList(const IFWL_App* app,
IFWL_Widget* pOuter)
: IFWL_ListBox(app, properties, pOuter), m_bNotifyOwner(TRUE) {
ASSERT(pOuter);
- SetDelegate(pdfium::MakeUnique<CFWL_ComboListImpDelegate>(this));
}
int32_t IFWL_ComboList::MatchItem(const CFX_WideString& wsMatch) {
@@ -92,10 +91,7 @@ void IFWL_ComboList::SetFocus(FX_BOOL bSet) {
IFWL_Widget::SetFocus(bSet);
}
-CFWL_ComboListImpDelegate::CFWL_ComboListImpDelegate(IFWL_ComboList* pOwner)
- : CFWL_ListBoxImpDelegate(pOwner), m_pOwner(pOwner) {}
-
-void CFWL_ComboListImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+void IFWL_ComboList::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
return;
@@ -106,14 +102,13 @@ void CFWL_ComboListImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
OnDropListFocusChanged(pMessage, dwHashCode == CFWL_MessageType::SetFocus);
} else if (dwHashCode == CFWL_MessageType::Mouse) {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
- if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) {
+ if (IsShowScrollBar(TRUE) && m_pVertScrollBar) {
CFX_RectF rect;
- m_pOwner->m_pVertScrollBar->GetWidgetRect(rect);
+ m_pVertScrollBar->GetWidgetRect(rect);
if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) {
pMsg->m_fx -= rect.left;
pMsg->m_fy -= rect.top;
- m_pOwner->m_pVertScrollBar->GetCurrentDelegate()->OnProcessMessage(
- pMsg);
+ m_pVertScrollBar->GetDelegate()->OnProcessMessage(pMsg);
return;
}
}
@@ -140,87 +135,86 @@ void CFWL_ComboListImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
backDefault = !OnDropListKey(static_cast<CFWL_MsgKey*>(pMessage));
}
if (backDefault)
- CFWL_ListBoxImpDelegate::OnProcessMessage(pMessage);
+ IFWL_ListBox::OnProcessMessage(pMessage);
}
-void CFWL_ComboListImpDelegate::OnDropListFocusChanged(CFWL_Message* pMsg,
- FX_BOOL bSet) {
- if (!bSet) {
- CFWL_MsgKillFocus* pKill = static_cast<CFWL_MsgKillFocus*>(pMsg);
- IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOwner->m_pOuter);
- if (pKill->m_pSetFocus == m_pOwner->m_pOuter ||
- pKill->m_pSetFocus == pOuter->m_pEdit.get()) {
- pOuter->ShowDropList(FALSE);
- }
+void IFWL_ComboList::OnDropListFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
+ if (bSet)
+ return;
+
+ CFWL_MsgKillFocus* pKill = static_cast<CFWL_MsgKillFocus*>(pMsg);
+ IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter);
+ if (pKill->m_pSetFocus == m_pOuter ||
+ pKill->m_pSetFocus == pOuter->GetComboEdit()) {
+ pOuter->ShowDropList(FALSE);
}
}
-int32_t CFWL_ComboListImpDelegate::OnDropListMouseMove(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if (m_pOwner->m_bNotifyOwner) {
- m_pOwner->m_bNotifyOwner = FALSE;
+int32_t IFWL_ComboList::OnDropListMouseMove(CFWL_MsgMouse* pMsg) {
+ if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if (m_bNotifyOwner) {
+ m_bNotifyOwner = FALSE;
}
- if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) {
+ if (IsShowScrollBar(TRUE) && m_pVertScrollBar) {
CFX_RectF rect;
- m_pOwner->m_pVertScrollBar->GetWidgetRect(rect);
+ m_pVertScrollBar->GetWidgetRect(rect);
if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) {
return 1;
}
}
- IFWL_ListItem* hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
+ IFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
if (hItem) {
- if (!m_pOwner->m_pProperties->m_pDataProvider)
+ if (!m_pProperties->m_pDataProvider)
return 0;
- IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(
- m_pOwner->m_pProperties->m_pDataProvider);
- int32_t iSel = pData->GetItemIndex(m_pOwner, hItem);
+ IFWL_ListBoxDP* pData =
+ static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
+ int32_t iSel = pData->GetItemIndex(this, hItem);
CFWL_EvtCmbHoverChanged event;
- event.m_pSrcTarget = m_pOwner->m_pOuter;
+ event.m_pSrcTarget = m_pOuter;
event.m_iCurHover = iSel;
- m_pOwner->DispatchEvent(&event);
- m_pOwner->ChangeSelected(iSel);
+ DispatchEvent(&event);
+ ChangeSelected(iSel);
}
- } else if (m_pOwner->m_bNotifyOwner) {
- m_pOwner->ClientToOuter(pMsg->m_fx, pMsg->m_fy);
- IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOwner->m_pOuter);
+ } else if (m_bNotifyOwner) {
+ ClientToOuter(pMsg->m_fx, pMsg->m_fy);
+ IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter);
pOuter->GetDelegate()->OnProcessMessage(pMsg);
}
return 1;
}
-int32_t CFWL_ComboListImpDelegate::OnDropListLButtonDown(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
+int32_t IFWL_ComboList::OnDropListLButtonDown(CFWL_MsgMouse* pMsg) {
+ if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy))
return 0;
- }
- IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOwner->m_pOuter);
+
+ IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter);
pOuter->ShowDropList(FALSE);
return 1;
}
-int32_t CFWL_ComboListImpDelegate::OnDropListLButtonUp(CFWL_MsgMouse* pMsg) {
- IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOwner->m_pOuter);
- if (m_pOwner->m_bNotifyOwner) {
- m_pOwner->ClientToOuter(pMsg->m_fx, pMsg->m_fy);
+int32_t IFWL_ComboList::OnDropListLButtonUp(CFWL_MsgMouse* pMsg) {
+ IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter);
+ if (m_bNotifyOwner) {
+ ClientToOuter(pMsg->m_fx, pMsg->m_fy);
pOuter->GetDelegate()->OnProcessMessage(pMsg);
} else {
- if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) {
+ if (IsShowScrollBar(TRUE) && m_pVertScrollBar) {
CFX_RectF rect;
- m_pOwner->m_pVertScrollBar->GetWidgetRect(rect);
+ m_pVertScrollBar->GetWidgetRect(rect);
if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) {
return 1;
}
}
pOuter->ShowDropList(FALSE);
- IFWL_ListItem* hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
- if (hItem) {
+ IFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
+ if (hItem)
pOuter->ProcessSelChanged(TRUE);
- }
}
return 1;
}
-int32_t CFWL_ComboListImpDelegate::OnDropListKey(CFWL_MsgKey* pKey) {
- IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOwner->m_pOuter);
+int32_t IFWL_ComboList::OnDropListKey(CFWL_MsgKey* pKey) {
+ IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter);
FX_BOOL bPropagate = FALSE;
if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) {
uint32_t dwKeyCode = pKey->m_dwKeyCode;
@@ -242,34 +236,35 @@ int32_t CFWL_ComboListImpDelegate::OnDropListKey(CFWL_MsgKey* pKey) {
bPropagate = TRUE;
}
if (bPropagate) {
- pKey->m_pDstTarget = m_pOwner->m_pOuter;
+ pKey->m_pDstTarget = m_pOuter;
pOuter->GetDelegate()->OnProcessMessage(pKey);
return 1;
}
return 0;
}
-void CFWL_ComboListImpDelegate::OnDropListKeyDown(CFWL_MsgKey* pKey) {
+void IFWL_ComboList::OnDropListKeyDown(CFWL_MsgKey* pKey) {
uint32_t dwKeyCode = pKey->m_dwKeyCode;
switch (dwKeyCode) {
case FWL_VKEY_Up:
case FWL_VKEY_Down:
case FWL_VKEY_Home:
case FWL_VKEY_End: {
- IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOwner->m_pOuter);
- IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(
- m_pOwner->m_pProperties->m_pDataProvider);
- IFWL_ListItem* hItem = pData->GetItem(m_pOwner, pOuter->m_iCurSel);
- hItem = m_pOwner->GetItem(hItem, dwKeyCode);
+ IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter);
+ IFWL_ListBoxDP* pData =
+ static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
+ IFWL_ListItem* hItem =
+ pData->GetItem(this, pOuter->GetCurrentSelection());
+ hItem = GetItem(hItem, dwKeyCode);
if (!hItem) {
break;
}
- m_pOwner->SetSelection(hItem, hItem, TRUE);
- m_pOwner->ScrollToVisible(hItem);
+ SetSelection(hItem, hItem, TRUE);
+ ScrollToVisible(hItem);
CFX_RectF rtInvalidate;
- rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width,
- m_pOwner->m_pProperties->m_rtWidget.height);
- m_pOwner->Repaint(&rtInvalidate);
+ rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width,
+ m_pProperties->m_rtWidget.height);
+ Repaint(&rtInvalidate);
break;
}
default:
diff --git a/xfa/fwl/core/ifwl_combolist.h b/xfa/fwl/core/ifwl_combolist.h
index 781fbadf73..a4e90f5b93 100644
--- a/xfa/fwl/core/ifwl_combolist.h
+++ b/xfa/fwl/core/ifwl_combolist.h
@@ -17,6 +17,9 @@ class IFWL_ComboList : public IFWL_ListBox {
const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
+ // IFWL_ListBox.
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+
int32_t MatchItem(const CFX_WideString& wsMatch);
void ChangeSelected(int32_t iSel);
int32_t CountItems();
@@ -26,23 +29,15 @@ class IFWL_ComboList : public IFWL_ListBox {
FX_BOOL m_bNotifyOwner;
- friend class CFWL_ComboListImpDelegate;
friend class IFWL_ComboBox;
-};
-
-class CFWL_ComboListImpDelegate : public CFWL_ListBoxImpDelegate {
- public:
- CFWL_ComboListImpDelegate(IFWL_ComboList* pOwner);
- void OnProcessMessage(CFWL_Message* pMessage) override;
- protected:
- void OnDropListFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ private:
+ void OnDropListFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet);
int32_t OnDropListMouseMove(CFWL_MsgMouse* pMsg);
int32_t OnDropListLButtonDown(CFWL_MsgMouse* pMsg);
int32_t OnDropListLButtonUp(CFWL_MsgMouse* pMsg);
int32_t OnDropListKey(CFWL_MsgKey* pKey);
void OnDropListKeyDown(CFWL_MsgKey* pKey);
- IFWL_ComboList* m_pOwner;
};
#endif // XFA_FWL_CORE_IFWL_COMBOLIST_H_
diff --git a/xfa/fwl/core/ifwl_datetimecalendar.cpp b/xfa/fwl/core/ifwl_datetimecalendar.cpp
index a44b558190..f521c56fb7 100644
--- a/xfa/fwl/core/ifwl_datetimecalendar.cpp
+++ b/xfa/fwl/core/ifwl_datetimecalendar.cpp
@@ -15,23 +15,14 @@ IFWL_DateTimeCalendar::IFWL_DateTimeCalendar(
const IFWL_App* app,
const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
- : IFWL_MonthCalendar(app, properties, pOuter) {
- SetDelegate(pdfium::MakeUnique<CFWL_DateTimeCalendarImpDelegate>(this));
-}
-
-CFWL_DateTimeCalendarImpDelegate::CFWL_DateTimeCalendarImpDelegate(
- IFWL_DateTimeCalendar* pOwner)
- : CFWL_MonthCalendarImpDelegate(pOwner), m_pOwner(pOwner) {
- m_bFlag = FALSE;
-}
+ : IFWL_MonthCalendar(app, properties, pOuter), m_bFlag(FALSE) {}
-void CFWL_DateTimeCalendarImpDelegate::OnProcessMessage(
- CFWL_Message* pMessage) {
+void IFWL_DateTimeCalendar::OnProcessMessage(CFWL_Message* pMessage) {
CFWL_MessageType dwCode = pMessage->GetClassID();
if (dwCode == CFWL_MessageType::SetFocus ||
dwCode == CFWL_MessageType::KillFocus) {
- IFWL_Widget* pOuter = m_pOwner->GetOuter();
- pOuter->GetCurrentDelegate()->OnProcessMessage(pMessage);
+ IFWL_Widget* pOuter = GetOuter();
+ pOuter->GetDelegate()->OnProcessMessage(pMessage);
return;
}
if (dwCode == CFWL_MessageType::Mouse) {
@@ -42,72 +33,67 @@ void CFWL_DateTimeCalendarImpDelegate::OnProcessMessage(
OnLButtonUpEx(pMsg);
return;
}
- CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage);
+ IFWL_MonthCalendar::OnProcessMessage(pMessage);
}
-void CFWL_DateTimeCalendarImpDelegate::OnLButtonDownEx(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iLBtnPartStates = CFWL_PartState_Pressed;
- m_pOwner->PrevMonth();
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iRBtnPartStates |= CFWL_PartState_Pressed;
- m_pOwner->NextMonth();
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- } else if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) ==
- 0) {
- m_pOwner->JumpToToday();
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+void IFWL_DateTimeCalendar::OnLButtonDownEx(CFWL_MsgMouse* pMsg) {
+ if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_iLBtnPartStates = CFWL_PartState_Pressed;
+ PrevMonth();
+ Repaint(&m_rtClient);
+ } else if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_iRBtnPartStates |= CFWL_PartState_Pressed;
+ NextMonth();
+ Repaint(&m_rtClient);
+ } else if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) == 0) {
+ JumpToToday();
+ Repaint(&m_rtClient);
}
} else {
- IFWL_DateTimePicker* pIPicker =
- static_cast<IFWL_DateTimePicker*>(m_pOwner->m_pOuter);
- if (pIPicker->IsMonthCalendarShowed()) {
+ IFWL_DateTimePicker* pIPicker = static_cast<IFWL_DateTimePicker*>(m_pOuter);
+ if (pIPicker->IsMonthCalendarShowed())
m_bFlag = 1;
- }
}
}
-void CFWL_DateTimeCalendarImpDelegate::OnLButtonUpEx(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
+void IFWL_DateTimeCalendar::OnLButtonUpEx(CFWL_MsgMouse* pMsg) {
+ if (m_pWidgetMgr->IsFormDisabled())
return DisForm_OnLButtonUpEx(pMsg);
- }
- if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iLBtnPartStates = 0;
- m_pOwner->Repaint(&m_pOwner->m_rtLBtn);
+ if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_iLBtnPartStates = 0;
+ Repaint(&m_rtLBtn);
return;
}
- if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iRBtnPartStates = 0;
- m_pOwner->Repaint(&m_pOwner->m_rtRBtn);
+ if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_iRBtnPartStates = 0;
+ Repaint(&m_rtRBtn);
return;
}
- if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy))
return;
- }
+
int32_t iOldSel = 0;
- if (m_pOwner->m_arrSelDays.GetSize() > 0) {
- iOldSel = m_pOwner->m_arrSelDays[0];
- }
- int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
+ if (m_arrSelDays.GetSize() > 0)
+ iOldSel = m_arrSelDays[0];
+
+ int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
CFX_RectF rt;
- IFWL_DateTimePicker* pIPicker =
- static_cast<IFWL_DateTimePicker*>(m_pOwner->m_pOuter);
- pIPicker->m_pForm->GetWidgetRect(rt);
+ IFWL_DateTimePicker* pIPicker = static_cast<IFWL_DateTimePicker*>(m_pOuter);
+ pIPicker->GetFormProxy()->GetWidgetRect(rt);
rt.Set(0, 0, rt.width, rt.height);
if (iCurSel > 0) {
- FWL_DATEINFO* lpDatesInfo = m_pOwner->m_arrDates.GetAt(iCurSel - 1);
+ FWL_DATEINFO* lpDatesInfo = m_arrDates.GetAt(iCurSel - 1);
CFX_RectF rtInvalidate(lpDatesInfo->rect);
- if (iOldSel > 0 && iOldSel <= m_pOwner->m_arrDates.GetSize()) {
- lpDatesInfo = m_pOwner->m_arrDates.GetAt(iOldSel - 1);
+ if (iOldSel > 0 && iOldSel <= m_arrDates.GetSize()) {
+ lpDatesInfo = m_arrDates.GetAt(iOldSel - 1);
rtInvalidate.Union(lpDatesInfo->rect);
}
- m_pOwner->AddSelDay(iCurSel);
- if (!m_pOwner->m_pOuter)
+ AddSelDay(iCurSel);
+ if (!m_pOuter)
return;
- pIPicker->ProcessSelChanged(m_pOwner->m_iCurYear, m_pOwner->m_iCurMonth,
- iCurSel);
+
+ pIPicker->ProcessSelChanged(m_iCurYear, m_iCurMonth, iCurSel);
pIPicker->ShowMonthCalendar(FALSE);
} else if (m_bFlag && (!rt.Contains(pMsg->m_fx, pMsg->m_fy))) {
pIPicker->ShowMonthCalendar(FALSE);
@@ -115,48 +101,44 @@ void CFWL_DateTimeCalendarImpDelegate::OnLButtonUpEx(CFWL_MsgMouse* pMsg) {
m_bFlag = 0;
}
-void CFWL_DateTimeCalendarImpDelegate::OnMouseMoveEx(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) {
+void IFWL_DateTimeCalendar::OnMouseMoveEx(CFWL_MsgMouse* pMsg) {
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect)
return;
- }
+
FX_BOOL bRepaint = FALSE;
CFX_RectF rtInvalidate;
rtInvalidate.Set(0, 0, 0, 0);
- if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
- int32_t iHover = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
- bRepaint = m_pOwner->m_iHovered != iHover;
+ if (m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ int32_t iHover = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
+ bRepaint = m_iHovered != iHover;
if (bRepaint) {
- if (m_pOwner->m_iHovered > 0) {
- m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
- }
+ if (m_iHovered > 0)
+ GetDayRect(m_iHovered, rtInvalidate);
if (iHover > 0) {
CFX_RectF rtDay;
- m_pOwner->GetDayRect(iHover, rtDay);
- if (rtInvalidate.IsEmpty()) {
+ GetDayRect(iHover, rtDay);
+ if (rtInvalidate.IsEmpty())
rtInvalidate = rtDay;
- } else {
+ else
rtInvalidate.Union(rtDay);
- }
}
}
- m_pOwner->m_iHovered = iHover;
+ m_iHovered = iHover;
CFWL_Event_DtpHoverChanged ev;
ev.hoverday = iHover;
- m_pOwner->DispatchEvent(&ev);
+ DispatchEvent(&ev);
} else {
- bRepaint = m_pOwner->m_iHovered > 0;
- if (bRepaint) {
- m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
- }
- m_pOwner->m_iHovered = -1;
- }
- if (bRepaint && !rtInvalidate.IsEmpty()) {
- m_pOwner->Repaint(&rtInvalidate);
+ bRepaint = m_iHovered > 0;
+ if (bRepaint)
+ GetDayRect(m_iHovered, rtInvalidate);
+
+ m_iHovered = -1;
}
+ if (bRepaint && !rtInvalidate.IsEmpty())
+ Repaint(&rtInvalidate);
}
-void CFWL_DateTimeCalendarImpDelegate::DisForm_OnProcessMessage(
- CFWL_Message* pMessage) {
+void IFWL_DateTimeCalendar::DisForm_OnProcessMessage(CFWL_Message* pMessage) {
if (pMessage->GetClassID() == CFWL_MessageType::Mouse) {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
if (pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonUp) {
@@ -164,41 +146,39 @@ void CFWL_DateTimeCalendarImpDelegate::DisForm_OnProcessMessage(
return;
}
}
- CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage);
+ IFWL_MonthCalendar::OnProcessMessage(pMessage);
}
-void CFWL_DateTimeCalendarImpDelegate::DisForm_OnLButtonUpEx(
- CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iLBtnPartStates = 0;
- m_pOwner->Repaint(&(m_pOwner->m_rtLBtn));
+void IFWL_DateTimeCalendar::DisForm_OnLButtonUpEx(CFWL_MsgMouse* pMsg) {
+ if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_iLBtnPartStates = 0;
+ Repaint(&(m_rtLBtn));
return;
}
- if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iRBtnPartStates = 0;
- m_pOwner->Repaint(&(m_pOwner->m_rtRBtn));
+ if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_iRBtnPartStates = 0;
+ Repaint(&(m_rtRBtn));
return;
}
- if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy))
return;
- }
+
int32_t iOldSel = 0;
- if (m_pOwner->m_arrSelDays.GetSize() > 0) {
- iOldSel = m_pOwner->m_arrSelDays[0];
- }
- int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
+ if (m_arrSelDays.GetSize() > 0)
+ iOldSel = m_arrSelDays[0];
+
+ int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
if (iCurSel > 0) {
- FWL_DATEINFO* lpDatesInfo = m_pOwner->m_arrDates.GetAt(iCurSel - 1);
+ FWL_DATEINFO* lpDatesInfo = m_arrDates.GetAt(iCurSel - 1);
CFX_RectF rtInvalidate(lpDatesInfo->rect);
- if (iOldSel > 0 && iOldSel <= m_pOwner->m_arrDates.GetSize()) {
- lpDatesInfo = m_pOwner->m_arrDates.GetAt(iOldSel - 1);
+ if (iOldSel > 0 && iOldSel <= m_arrDates.GetSize()) {
+ lpDatesInfo = m_arrDates.GetAt(iOldSel - 1);
rtInvalidate.Union(lpDatesInfo->rect);
}
- m_pOwner->AddSelDay(iCurSel);
+ AddSelDay(iCurSel);
IFWL_DateTimePicker* pDateTime =
- static_cast<IFWL_DateTimePicker*>(m_pOwner->m_pOuter);
- pDateTime->ProcessSelChanged(m_pOwner->m_iCurYear, m_pOwner->m_iCurMonth,
- iCurSel);
+ static_cast<IFWL_DateTimePicker*>(m_pOuter);
+ pDateTime->ProcessSelChanged(m_iCurYear, m_iCurMonth, iCurSel);
pDateTime->ShowMonthCalendar(FALSE);
}
}
diff --git a/xfa/fwl/core/ifwl_datetimecalendar.h b/xfa/fwl/core/ifwl_datetimecalendar.h
index 7a3b960fe6..721bc27a73 100644
--- a/xfa/fwl/core/ifwl_datetimecalendar.h
+++ b/xfa/fwl/core/ifwl_datetimecalendar.h
@@ -15,26 +15,17 @@ class IFWL_DateTimeCalendar : public IFWL_MonthCalendar {
const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- protected:
- friend class CFWL_DateTimeCalendarImpDelegate;
-};
-
-class CFWL_DateTimeCalendarImpDelegate : public CFWL_MonthCalendarImpDelegate {
- public:
- CFWL_DateTimeCalendarImpDelegate(IFWL_DateTimeCalendar* pOwner);
+ // IFWL_MonthCalendar
void OnProcessMessage(CFWL_Message* pMessage) override;
+ private:
void OnLButtonDownEx(CFWL_MsgMouse* pMsg);
void OnLButtonUpEx(CFWL_MsgMouse* pMsg);
void OnMouseMoveEx(CFWL_MsgMouse* pMsg);
-
- protected:
- IFWL_DateTimeCalendar* m_pOwner;
- FX_BOOL m_bFlag;
-
- private:
void DisForm_OnProcessMessage(CFWL_Message* pMessage);
void DisForm_OnLButtonUpEx(CFWL_MsgMouse* pMsg);
+
+ FX_BOOL m_bFlag;
};
#endif // XFA_FWL_CORE_IFWL_DATETIMECALENDAR_H_
diff --git a/xfa/fwl/core/ifwl_datetimeedit.cpp b/xfa/fwl/core/ifwl_datetimeedit.cpp
index 1c0baae32d..906ba94e57 100644
--- a/xfa/fwl/core/ifwl_datetimeedit.cpp
+++ b/xfa/fwl/core/ifwl_datetimeedit.cpp
@@ -13,16 +13,10 @@
IFWL_DateTimeEdit::IFWL_DateTimeEdit(const IFWL_App* app,
const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
- : IFWL_Edit(app, properties, pOuter) {
- SetDelegate(pdfium::MakeUnique<CFWL_DateTimeEditImpDelegate>(this));
-}
-
-CFWL_DateTimeEditImpDelegate::CFWL_DateTimeEditImpDelegate(
- IFWL_DateTimeEdit* pOwner)
- : CFWL_EditImpDelegate(pOwner), m_pOwner(pOwner) {}
+ : IFWL_Edit(app, properties, pOuter) {}
-void CFWL_DateTimeEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
- if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
+void IFWL_DateTimeEdit::OnProcessMessage(CFWL_Message* pMessage) {
+ if (m_pWidgetMgr->IsFormDisabled()) {
DisForm_OnProcessMessage(pMessage);
return;
}
@@ -30,24 +24,23 @@ void CFWL_DateTimeEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
CFWL_MessageType dwHashCode = pMessage->GetClassID();
if (dwHashCode == CFWL_MessageType::SetFocus ||
dwHashCode == CFWL_MessageType::KillFocus) {
- IFWL_Widget* pOuter = m_pOwner->GetOuter();
- pOuter->GetCurrentDelegate()->OnProcessMessage(pMessage);
+ IFWL_Widget* pOuter = GetOuter();
+ pOuter->GetDelegate()->OnProcessMessage(pMessage);
}
}
-void CFWL_DateTimeEditImpDelegate::DisForm_OnProcessMessage(
- CFWL_Message* pMessage) {
+void IFWL_DateTimeEdit::DisForm_OnProcessMessage(CFWL_Message* pMessage) {
CFWL_MessageType dwHashCode = pMessage->GetClassID();
- if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
+ if (m_pWidgetMgr->IsFormDisabled()) {
if (dwHashCode == CFWL_MessageType::Mouse) {
CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage);
if (pMouse->m_dwCmd == FWL_MouseCommand::LeftButtonDown ||
pMouse->m_dwCmd == FWL_MouseCommand::RightButtonDown) {
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- }
+ if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
+ m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+
IFWL_DateTimePicker* pDateTime =
- static_cast<IFWL_DateTimePicker*>(m_pOwner->m_pOuter);
+ static_cast<IFWL_DateTimePicker*>(m_pOuter);
if (pDateTime->IsMonthCalendarShowed()) {
CFX_RectF rtInvalidate;
pDateTime->GetWidgetRect(rtInvalidate);
@@ -58,5 +51,5 @@ void CFWL_DateTimeEditImpDelegate::DisForm_OnProcessMessage(
}
}
}
- CFWL_EditImpDelegate::OnProcessMessage(pMessage);
+ IFWL_Edit::OnProcessMessage(pMessage);
}
diff --git a/xfa/fwl/core/ifwl_datetimeedit.h b/xfa/fwl/core/ifwl_datetimeedit.h
index 39dd3718ac..84ff7e7ee7 100644
--- a/xfa/fwl/core/ifwl_datetimeedit.h
+++ b/xfa/fwl/core/ifwl_datetimeedit.h
@@ -19,18 +19,9 @@ class IFWL_DateTimeEdit : public IFWL_Edit {
const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter);
- protected:
- friend class CFWL_DateTimeEditImpDelegate;
-};
-
-class CFWL_DateTimeEditImpDelegate : public CFWL_EditImpDelegate {
- public:
- CFWL_DateTimeEditImpDelegate(IFWL_DateTimeEdit* pOwner);
+ // IFWL_Edit.
void OnProcessMessage(CFWL_Message* pMessage) override;
- protected:
- IFWL_DateTimeEdit* m_pOwner;
-
private:
void DisForm_OnProcessMessage(CFWL_Message* pMessage);
};
diff --git a/xfa/fwl/core/ifwl_datetimepicker.cpp b/xfa/fwl/core/ifwl_datetimepicker.cpp
index 844eb9ebe6..90f85a08a7 100644
--- a/xfa/fwl/core/ifwl_datetimepicker.cpp
+++ b/xfa/fwl/core/ifwl_datetimepicker.cpp
@@ -35,8 +35,6 @@ IFWL_DateTimePicker::IFWL_DateTimePicker(
m_bLBtnDown(FALSE) {
m_rtBtn.Set(0, 0, 0, 0);
- SetDelegate(pdfium::MakeUnique<CFWL_DateTimePickerImpDelegate>(this));
-
m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat;
CFWL_WidgetImpProperties propMonth;
propMonth.m_dwStyles = FWL_WGTSTYLE_Popup | FWL_WGTSTYLE_Border;
@@ -520,7 +518,7 @@ void IFWL_DateTimePicker::DisForm_ShowMonthCalendar(FX_BOOL bActivate) {
CFWL_MsgSetFocus msg;
msg.m_pDstTarget = m_pMonthCal.get();
msg.m_pSrcTarget = m_pEdit.get();
- m_pEdit->GetCurrentDelegate()->OnProcessMessage(&msg);
+ m_pEdit->GetDelegate()->OnProcessMessage(&msg);
}
CFX_RectF rtInvalidate, rtCal;
rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width,
@@ -643,50 +641,40 @@ FWL_Error IFWL_DateTimePicker::DisForm_DrawWidget(CFX_Graphics* pGraphics,
return FWL_Error::Succeeded;
}
-CFWL_DateTimePickerImpDelegate::CFWL_DateTimePickerImpDelegate(
- IFWL_DateTimePicker* pOwner)
- : m_pOwner(pOwner) {}
-
-void CFWL_DateTimePickerImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+void IFWL_DateTimePicker::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
return;
switch (pMessage->GetClassID()) {
- case CFWL_MessageType::SetFocus: {
+ case CFWL_MessageType::SetFocus:
OnFocusChanged(pMessage, TRUE);
break;
- }
- case CFWL_MessageType::KillFocus: {
+ case CFWL_MessageType::KillFocus:
OnFocusChanged(pMessage, FALSE);
break;
- }
case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage);
switch (pMouse->m_dwCmd) {
- case FWL_MouseCommand::LeftButtonDown: {
+ case FWL_MouseCommand::LeftButtonDown:
OnLButtonDown(pMouse);
break;
- }
- case FWL_MouseCommand::LeftButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp:
OnLButtonUp(pMouse);
break;
- }
- case FWL_MouseCommand::Move: {
+ case FWL_MouseCommand::Move:
OnMouseMove(pMouse);
break;
- }
- case FWL_MouseCommand::Leave: {
+ case FWL_MouseCommand::Leave:
OnMouseLeave(pMouse);
break;
- }
default:
break;
}
break;
}
case CFWL_MessageType::Key: {
- if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) {
- m_pOwner->m_pEdit->GetCurrentDelegate()->OnProcessMessage(pMessage);
+ if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) {
+ m_pEdit->GetDelegate()->OnProcessMessage(pMessage);
return;
}
break;
@@ -695,114 +683,105 @@ void CFWL_DateTimePickerImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
break;
}
- CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+ IFWL_Widget::OnProcessMessage(pMessage);
}
-void CFWL_DateTimePickerImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- m_pOwner->DrawWidget(pGraphics, pMatrix);
+void IFWL_DateTimePicker::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ DrawWidget(pGraphics, pMatrix);
}
-void CFWL_DateTimePickerImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
- FX_BOOL bSet) {
+void IFWL_DateTimePicker::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
if (!pMsg)
return;
- if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
+ if (m_pWidgetMgr->IsFormDisabled())
return DisForm_OnFocusChanged(pMsg, bSet);
- }
+
if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused);
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused);
+ Repaint(&m_rtClient);
} else {
- m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
+ Repaint(&m_rtClient);
}
- if (pMsg->m_pSrcTarget == m_pOwner->m_pMonthCal.get() &&
- m_pOwner->IsMonthCalendarShowed()) {
- m_pOwner->ShowMonthCalendar(FALSE);
+ if (pMsg->m_pSrcTarget == m_pMonthCal.get() && IsMonthCalendarShowed()) {
+ ShowMonthCalendar(FALSE);
}
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ Repaint(&m_rtClient);
}
-void CFWL_DateTimePickerImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+void IFWL_DateTimePicker::OnLButtonDown(CFWL_MsgMouse* pMsg) {
if (!pMsg)
return;
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
- m_pOwner->SetFocus(TRUE);
- }
- if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if (m_pOwner->IsMonthCalendarShowed()) {
- m_pOwner->ShowMonthCalendar(FALSE);
+ if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
+ SetFocus(TRUE);
+ if (m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if (IsMonthCalendarShowed()) {
+ ShowMonthCalendar(FALSE);
CFWL_Event_DtpCloseUp ev;
- m_pOwner->DispatchEvent(&ev);
+ DispatchEvent(&ev);
} else {
- if (!(m_pOwner->m_pProperties->m_dwStyleExes &
- FWL_STYLEEXT_DTP_TimeFormat)) {
- m_pOwner->ShowMonthCalendar(TRUE);
+ if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_DTP_TimeFormat)) {
+ ShowMonthCalendar(TRUE);
CFWL_Event_DtpDropDown ev;
- m_pOwner->DispatchEvent(&ev);
- } else {
+ DispatchEvent(&ev);
}
- m_pOwner->m_bLBtnDown = TRUE;
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ m_bLBtnDown = TRUE;
+ Repaint(&m_rtClient);
}
}
}
-void CFWL_DateTimePickerImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+void IFWL_DateTimePicker::OnLButtonUp(CFWL_MsgMouse* pMsg) {
if (!pMsg)
return;
- m_pOwner->m_bLBtnDown = FALSE;
- if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iBtnState = CFWL_PartState_Hovered;
- } else {
- m_pOwner->m_iBtnState = CFWL_PartState_Normal;
- }
- m_pOwner->Repaint(&m_pOwner->m_rtBtn);
+
+ m_bLBtnDown = FALSE;
+ if (m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy))
+ m_iBtnState = CFWL_PartState_Hovered;
+ else
+ m_iBtnState = CFWL_PartState_Normal;
+ Repaint(&m_rtBtn);
}
-void CFWL_DateTimePickerImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- } else {
- m_pOwner->m_iBtnState = CFWL_PartState_Normal;
- }
- m_pOwner->Repaint(&m_pOwner->m_rtBtn);
+void IFWL_DateTimePicker::OnMouseMove(CFWL_MsgMouse* pMsg) {
+ if (!m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy))
+ m_iBtnState = CFWL_PartState_Normal;
+
+ Repaint(&m_rtBtn);
}
-void CFWL_DateTimePickerImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
+void IFWL_DateTimePicker::OnMouseLeave(CFWL_MsgMouse* pMsg) {
if (!pMsg)
return;
- m_pOwner->m_iBtnState = CFWL_PartState_Normal;
- m_pOwner->Repaint(&m_pOwner->m_rtBtn);
+ m_iBtnState = CFWL_PartState_Normal;
+ Repaint(&m_rtBtn);
}
-void CFWL_DateTimePickerImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg,
- FX_BOOL bSet) {
- CFX_RectF rtInvalidate(m_pOwner->m_rtBtn);
+void IFWL_DateTimePicker::DisForm_OnFocusChanged(CFWL_Message* pMsg,
+ FX_BOOL bSet) {
+ CFX_RectF rtInvalidate(m_rtBtn);
if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- if (m_pOwner->m_pEdit &&
- !(m_pOwner->m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly)) {
- m_pOwner->m_rtBtn.Set(m_pOwner->m_pProperties->m_rtWidget.width, 0,
- m_pOwner->m_fBtn,
- m_pOwner->m_pProperties->m_rtWidget.height - 1);
+ m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+ if (m_pEdit && !(m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly)) {
+ m_rtBtn.Set(m_pProperties->m_rtWidget.width, 0, m_fBtn,
+ m_pProperties->m_rtWidget.height - 1);
}
- rtInvalidate = m_pOwner->m_rtBtn;
- pMsg->m_pDstTarget = m_pOwner->m_pEdit.get();
- m_pOwner->m_pEdit->GetCurrentDelegate()->OnProcessMessage(pMsg);
+ rtInvalidate = m_rtBtn;
+ pMsg->m_pDstTarget = m_pEdit.get();
+ m_pEdit->GetDelegate()->OnProcessMessage(pMsg);
} else {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- m_pOwner->m_rtBtn.Set(0, 0, 0, 0);
- if (m_pOwner->DisForm_IsMonthCalendarShowed()) {
- m_pOwner->ShowMonthCalendar(FALSE);
- }
- if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) {
- pMsg->m_pSrcTarget = m_pOwner->m_pEdit.get();
- m_pOwner->m_pEdit->GetCurrentDelegate()->OnProcessMessage(pMsg);
+ m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+ m_rtBtn.Set(0, 0, 0, 0);
+ if (DisForm_IsMonthCalendarShowed())
+ ShowMonthCalendar(FALSE);
+ if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) {
+ pMsg->m_pSrcTarget = m_pEdit.get();
+ m_pEdit->GetDelegate()->OnProcessMessage(pMsg);
}
}
rtInvalidate.Inflate(2, 2);
- m_pOwner->Repaint(&rtInvalidate);
+ Repaint(&rtInvalidate);
}
IFWL_DateTimePicker::CFWL_MonthCalendarImpDP::CFWL_MonthCalendarImpDP() {
diff --git a/xfa/fwl/core/ifwl_datetimepicker.h b/xfa/fwl/core/ifwl_datetimepicker.h
index 5b360d3603..04d2869c54 100644
--- a/xfa/fwl/core/ifwl_datetimepicker.h
+++ b/xfa/fwl/core/ifwl_datetimepicker.h
@@ -74,6 +74,9 @@ class IFWL_DateTimePicker : public IFWL_Widget {
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
FWL_Error SetThemeProvider(IFWL_ThemeProvider* pTP) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) override;
FWL_Error GetCurSel(int32_t& iYear, int32_t& iMonth, int32_t& iDay);
FWL_Error SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay);
@@ -103,12 +106,13 @@ class IFWL_DateTimePicker : public IFWL_Widget {
uint32_t dwStylesExRemoved);
IFWL_DateTimeEdit* GetDataTimeEdit();
- protected:
- friend class CFWL_DateTimeEditImpDelegate;
- friend class IFWL_DateTimeCalendar;
- friend class CFWL_DateTimeCalendarImpDelegate;
- friend class CFWL_DateTimePickerImpDelegate;
+ FX_BOOL IsMonthCalendarShowed();
+ void ShowMonthCalendar(FX_BOOL bActivate);
+ void ProcessSelChanged(int32_t iYear, int32_t iMonth, int32_t iDay);
+ IFWL_FormProxy* GetFormProxy() const { return m_pForm.get(); }
+
+ protected:
class CFWL_MonthCalendarImpDP : public IFWL_MonthCalendarDP {
public:
CFWL_MonthCalendarImpDP();
@@ -134,11 +138,8 @@ class IFWL_DateTimePicker : public IFWL_Widget {
int32_t iMonth,
int32_t iDay,
CFX_WideString& wsText);
- void ShowMonthCalendar(FX_BOOL bActivate);
- FX_BOOL IsMonthCalendarShowed();
void ReSetEditAlignment();
void InitProxyForm();
- void ProcessSelChanged(int32_t iYear, int32_t iMonth, int32_t iDay);
CFX_RectF m_rtBtn;
CFX_RectF m_rtClient;
@@ -166,28 +167,13 @@ class IFWL_DateTimePicker : public IFWL_Widget {
FWL_Error DisForm_GetBBox(CFX_RectF& rect);
FWL_Error DisForm_DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr);
-};
-
-class CFWL_DateTimePickerImpDelegate : public CFWL_WidgetImpDelegate {
- public:
- CFWL_DateTimePickerImpDelegate(IFWL_DateTimePicker* pOwner);
-
- // CFWL_WidgetImpDelegate
- void OnProcessMessage(CFWL_Message* pMessage) override;
- void OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) override;
- protected:
- void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet);
void OnLButtonDown(CFWL_MsgMouse* pMsg);
void OnLButtonUp(CFWL_MsgMouse* pMsg);
void OnMouseMove(CFWL_MsgMouse* pMsg);
void OnMouseLeave(CFWL_MsgMouse* pMsg);
-
- IFWL_DateTimePicker* m_pOwner;
-
- private:
- void DisForm_OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ void DisForm_OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet);
};
#endif // XFA_FWL_CORE_IFWL_DATETIMEPICKER_H_
diff --git a/xfa/fwl/core/ifwl_edit.cpp b/xfa/fwl/core/ifwl_edit.cpp
index 8edc69d578..5222f37c45 100644
--- a/xfa/fwl/core/ifwl_edit.cpp
+++ b/xfa/fwl/core/ifwl_edit.cpp
@@ -76,7 +76,6 @@ IFWL_Edit::IFWL_Edit(const IFWL_App* app,
m_rtEngine.Reset();
m_rtStatic.Reset();
- SetDelegate(pdfium::MakeUnique<CFWL_EditImpDelegate>(this));
InitCaret();
if (!m_pEdtEngine)
InitEngine();
@@ -1586,51 +1585,40 @@ void IFWL_Edit::ProcessInsertError(int32_t iError) {
}
}
-CFWL_EditImpDelegate::CFWL_EditImpDelegate(IFWL_Edit* pOwner)
- : m_pOwner(pOwner) {}
-
-void CFWL_EditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+void IFWL_Edit::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
return;
CFWL_MessageType dwMsgCode = pMessage->GetClassID();
switch (dwMsgCode) {
- case CFWL_MessageType::Activate: {
+ case CFWL_MessageType::Activate:
DoActivate(static_cast<CFWL_MsgActivate*>(pMessage));
break;
- }
- case CFWL_MessageType::Deactivate: {
+ case CFWL_MessageType::Deactivate:
DoDeactivate(static_cast<CFWL_MsgDeactivate*>(pMessage));
break;
- }
case CFWL_MessageType::SetFocus:
- case CFWL_MessageType::KillFocus: {
+ case CFWL_MessageType::KillFocus:
OnFocusChanged(pMessage, dwMsgCode == CFWL_MessageType::SetFocus);
break;
- }
case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
switch (pMsg->m_dwCmd) {
- case FWL_MouseCommand::LeftButtonDown: {
+ case FWL_MouseCommand::LeftButtonDown:
OnLButtonDown(pMsg);
break;
- }
- case FWL_MouseCommand::LeftButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp:
OnLButtonUp(pMsg);
break;
- }
- case FWL_MouseCommand::LeftButtonDblClk: {
+ case FWL_MouseCommand::LeftButtonDblClk:
OnButtonDblClk(pMsg);
break;
- }
- case FWL_MouseCommand::Move: {
+ case FWL_MouseCommand::Move:
OnMouseMove(pMsg);
break;
- }
- case FWL_MouseCommand::RightButtonDown: {
+ case FWL_MouseCommand::RightButtonDown:
DoButtonDown(pMsg);
break;
- }
default:
break;
}
@@ -1644,175 +1632,179 @@ void CFWL_EditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
OnChar(pKey);
break;
}
- default: { break; }
+ default:
+ break;
}
- CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+ IFWL_Widget::OnProcessMessage(pMessage);
}
-void CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
+void IFWL_Edit::OnProcessEvent(CFWL_Event* pEvent) {
if (!pEvent)
return;
if (pEvent->GetClassID() != CFWL_EventType::Scroll)
return;
IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget;
- if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() &&
- m_pOwner->m_pVertScrollBar) ||
- (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() &&
- m_pOwner->m_pHorzScrollBar)) {
+ if ((pSrcTarget == m_pVertScrollBar.get() && m_pVertScrollBar) ||
+ (pSrcTarget == m_pHorzScrollBar.get() && m_pHorzScrollBar)) {
CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent);
OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget),
pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos);
}
}
-void CFWL_EditImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- m_pOwner->DrawWidget(pGraphics, pMatrix);
+void IFWL_Edit::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ DrawWidget(pGraphics, pMatrix);
}
-void CFWL_EditImpDelegate::DoActivate(CFWL_MsgActivate* pMsg) {
- m_pOwner->m_pProperties->m_dwStates |= ~FWL_WGTSTATE_Deactivated;
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+void IFWL_Edit::DoActivate(CFWL_MsgActivate* pMsg) {
+ m_pProperties->m_dwStates |= ~FWL_WGTSTATE_Deactivated;
+ Repaint(&m_rtClient);
}
-void CFWL_EditImpDelegate::DoDeactivate(CFWL_MsgDeactivate* pMsg) {
- m_pOwner->m_pProperties->m_dwStates &= FWL_WGTSTATE_Deactivated;
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+
+void IFWL_Edit::DoDeactivate(CFWL_MsgDeactivate* pMsg) {
+ m_pProperties->m_dwStates &= FWL_WGTSTATE_Deactivated;
+ Repaint(&m_rtClient);
}
-void CFWL_EditImpDelegate::DoButtonDown(CFWL_MsgMouse* pMsg) {
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
- m_pOwner->SetFocus(TRUE);
- }
- if (!m_pOwner->m_pEdtEngine) {
- m_pOwner->UpdateEditEngine();
- }
- IFDE_TxtEdtPage* pPage = m_pOwner->m_pEdtEngine->GetPage(0);
+
+void IFWL_Edit::DoButtonDown(CFWL_MsgMouse* pMsg) {
+ if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
+ SetFocus(TRUE);
+ if (!m_pEdtEngine)
+ UpdateEditEngine();
+
+ IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0);
if (!pPage)
return;
CFX_PointF pt(pMsg->m_fx, pMsg->m_fy);
- m_pOwner->DeviceToEngine(pt);
+ DeviceToEngine(pt);
FX_BOOL bBefore = TRUE;
int32_t nIndex = pPage->GetCharIndex(pt, bBefore);
- if (nIndex < 0) {
+ if (nIndex < 0)
nIndex = 0;
- }
- m_pOwner->m_pEdtEngine->SetCaretPos(nIndex, bBefore);
+
+ m_pEdtEngine->SetCaretPos(nIndex, bBefore);
}
-void CFWL_EditImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
- uint32_t dwStyleEx = m_pOwner->GetStylesEx();
+
+void IFWL_Edit::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
+ uint32_t dwStyleEx = GetStylesEx();
bool bRepaint = !!(dwStyleEx & FWL_STYLEEXT_EDT_InnerCaret);
if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- if (!m_pOwner->m_pEdtEngine) {
- m_pOwner->UpdateEditEngine();
- }
- m_pOwner->UpdateVAlignment();
- m_pOwner->UpdateOffset();
- m_pOwner->UpdateCaret();
- } else if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- m_pOwner->ShowCaret(FALSE);
- if (m_pOwner->m_pEdtEngine &&
- (dwStyleEx & FWL_STYLEEXT_EDT_NoHideSel) == 0) {
- int32_t nSel = m_pOwner->CountSelRanges();
+ m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+ if (!m_pEdtEngine)
+ UpdateEditEngine();
+
+ UpdateVAlignment();
+ UpdateOffset();
+ UpdateCaret();
+ } else if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) {
+ m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+ ShowCaret(FALSE);
+ if (m_pEdtEngine && (dwStyleEx & FWL_STYLEEXT_EDT_NoHideSel) == 0) {
+ int32_t nSel = CountSelRanges();
if (nSel > 0) {
- m_pOwner->ClearSelections();
+ ClearSelections();
bRepaint = TRUE;
}
- m_pOwner->SetCaretPos(0);
- m_pOwner->UpdateOffset();
+ SetCaretPos(0);
+ UpdateOffset();
}
- m_pOwner->ClearRecord();
+ ClearRecord();
}
- m_pOwner->LayoutScrollBar();
+ LayoutScrollBar();
if (bRepaint) {
CFX_RectF rtInvalidate;
- rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width,
- m_pOwner->m_pProperties->m_rtWidget.height);
- m_pOwner->Repaint(&rtInvalidate);
+ rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width,
+ m_pProperties->m_rtWidget.height);
+ Repaint(&rtInvalidate);
}
}
-void CFWL_EditImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
- DoCursor(pMsg);
- if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
+
+void IFWL_Edit::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
return;
- }
- m_pOwner->m_bLButtonDown = TRUE;
- m_pOwner->SetGrab(TRUE);
+
+ m_bLButtonDown = TRUE;
+ SetGrab(TRUE);
DoButtonDown(pMsg);
- int32_t nIndex = m_pOwner->m_pEdtEngine->GetCaretPos();
+ int32_t nIndex = m_pEdtEngine->GetCaretPos();
FX_BOOL bRepaint = FALSE;
- int32_t iCount = m_pOwner->m_pEdtEngine->CountSelRanges();
+ int32_t iCount = m_pEdtEngine->CountSelRanges();
if (iCount > 0) {
- m_pOwner->m_pEdtEngine->ClearSelection();
+ m_pEdtEngine->ClearSelection();
bRepaint = TRUE;
}
+
bool bShift = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Shift);
- if (bShift && m_pOwner->m_nSelStart != nIndex) {
- int32_t iStart = std::min(m_pOwner->m_nSelStart, nIndex);
- int32_t iEnd = std::max(m_pOwner->m_nSelStart, nIndex);
- m_pOwner->m_pEdtEngine->AddSelRange(iStart, iEnd - iStart);
+ if (bShift && m_nSelStart != nIndex) {
+ int32_t iStart = std::min(m_nSelStart, nIndex);
+ int32_t iEnd = std::max(m_nSelStart, nIndex);
+ m_pEdtEngine->AddSelRange(iStart, iEnd - iStart);
bRepaint = TRUE;
} else {
- m_pOwner->m_nSelStart = nIndex;
- }
- if (bRepaint) {
- m_pOwner->Repaint(&m_pOwner->m_rtEngine);
+ m_nSelStart = nIndex;
}
+ if (bRepaint)
+ Repaint(&m_rtEngine);
}
-void CFWL_EditImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
- DoCursor(pMsg);
- m_pOwner->m_bLButtonDown = FALSE;
- m_pOwner->SetGrab(FALSE);
+
+void IFWL_Edit::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ m_bLButtonDown = FALSE;
+ SetGrab(FALSE);
}
-void CFWL_EditImpDelegate::OnButtonDblClk(CFWL_MsgMouse* pMsg) {
- if (!m_pOwner->m_pEdtEngine)
+
+void IFWL_Edit::OnButtonDblClk(CFWL_MsgMouse* pMsg) {
+ if (!m_pEdtEngine)
return;
- DoCursor(pMsg);
- IFDE_TxtEdtPage* pPage = m_pOwner->m_pEdtEngine->GetPage(0);
+
+ IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0);
if (!pPage)
return;
+
CFX_PointF pt(pMsg->m_fx, pMsg->m_fy);
- m_pOwner->DeviceToEngine(pt);
+ DeviceToEngine(pt);
int32_t nCount = 0;
int32_t nIndex = pPage->SelectWord(pt, nCount);
- if (nIndex < 0) {
+ if (nIndex < 0)
return;
- }
- m_pOwner->m_pEdtEngine->AddSelRange(nIndex, nCount);
- m_pOwner->m_pEdtEngine->SetCaretPos(nIndex + nCount - 1, FALSE);
- m_pOwner->Repaint(&m_pOwner->m_rtEngine);
+
+ m_pEdtEngine->AddSelRange(nIndex, nCount);
+ m_pEdtEngine->SetCaretPos(nIndex + nCount - 1, FALSE);
+ Repaint(&m_rtEngine);
}
-void CFWL_EditImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
- if (!m_pOwner->m_pEdtEngine)
+
+void IFWL_Edit::OnMouseMove(CFWL_MsgMouse* pMsg) {
+ if (!m_pEdtEngine)
return;
- DoCursor(pMsg);
- if (m_pOwner->m_nSelStart == -1 || !m_pOwner->m_bLButtonDown) {
+ if (m_nSelStart == -1 || !m_bLButtonDown)
return;
- }
- IFDE_TxtEdtPage* pPage = m_pOwner->m_pEdtEngine->GetPage(0);
+
+ IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0);
if (!pPage)
return;
+
CFX_PointF pt(pMsg->m_fx, pMsg->m_fy);
- m_pOwner->DeviceToEngine(pt);
+ DeviceToEngine(pt);
FX_BOOL bBefore = TRUE;
int32_t nIndex = pPage->GetCharIndex(pt, bBefore);
- m_pOwner->m_pEdtEngine->SetCaretPos(nIndex, bBefore);
- nIndex = m_pOwner->m_pEdtEngine->GetCaretPos();
- m_pOwner->m_pEdtEngine->ClearSelection();
- if (nIndex != m_pOwner->m_nSelStart) {
- int32_t nLen = m_pOwner->m_pEdtEngine->GetTextLength();
- if (m_pOwner->m_nSelStart >= nLen) {
- m_pOwner->m_nSelStart = nLen;
- }
- m_pOwner->m_pEdtEngine->AddSelRange(
- std::min(m_pOwner->m_nSelStart, nIndex),
- FXSYS_abs(nIndex - m_pOwner->m_nSelStart));
+ m_pEdtEngine->SetCaretPos(nIndex, bBefore);
+ nIndex = m_pEdtEngine->GetCaretPos();
+ m_pEdtEngine->ClearSelection();
+ if (nIndex != m_nSelStart) {
+ int32_t nLen = m_pEdtEngine->GetTextLength();
+ if (m_nSelStart >= nLen)
+ m_nSelStart = nLen;
+
+ m_pEdtEngine->AddSelRange(std::min(m_nSelStart, nIndex),
+ FXSYS_abs(nIndex - m_nSelStart));
}
}
-void CFWL_EditImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
- if (!m_pOwner->m_pEdtEngine)
+
+void IFWL_Edit::OnKeyDown(CFWL_MsgKey* pMsg) {
+ if (!m_pEdtEngine)
return;
+
FDE_TXTEDTMOVECARET MoveCaret = MC_MoveNone;
bool bShift = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Shift);
bool bCtrl = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl);
@@ -1835,43 +1827,32 @@ void CFWL_EditImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
break;
}
case FWL_VKEY_Home: {
- if (bCtrl) {
- MoveCaret = MC_Home;
- } else {
- MoveCaret = MC_LineStart;
- }
+ MoveCaret = bCtrl ? MC_Home : MC_LineStart;
break;
}
case FWL_VKEY_End: {
- if (bCtrl) {
- MoveCaret = MC_End;
- } else {
- MoveCaret = MC_LineEnd;
- }
+ MoveCaret = bCtrl ? MC_End : MC_LineEnd;
break;
}
- case FWL_VKEY_Insert: {
+ case FWL_VKEY_Insert:
break;
- }
case FWL_VKEY_Delete: {
- if ((m_pOwner->m_pProperties->m_dwStyleExes &
- FWL_STYLEEXT_EDT_ReadOnly) ||
- (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) ||
+ (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
break;
}
- int32_t nCaret = m_pOwner->m_pEdtEngine->GetCaretPos();
+ int32_t nCaret = m_pEdtEngine->GetCaretPos();
#if (_FX_OS_ == _FX_MACOSX_)
- m_pOwner->m_pEdtEngine->Delete(nCaret, TRUE);
+ m_pEdtEngine->Delete(nCaret, TRUE);
#else
- m_pOwner->m_pEdtEngine->Delete(nCaret);
+ m_pEdtEngine->Delete(nCaret);
#endif
break;
}
- case FWL_VKEY_F2: {
+ case FWL_VKEY_F2:
break;
- }
case FWL_VKEY_Tab: {
- m_pOwner->DispatchKeyEvent(pMsg);
+ DispatchKeyEvent(pMsg);
break;
}
default: {
@@ -1881,67 +1862,63 @@ void CFWL_EditImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) {
#endif
if (dwKeyCode == 0x43 || dwKeyCode == 0x63) {
- m_pOwner->DoClipboard(1);
+ DoClipboard(1);
return;
}
if (dwKeyCode == 0x58 || dwKeyCode == 0x78) {
- m_pOwner->DoClipboard(2);
+ DoClipboard(2);
return;
}
if (dwKeyCode == 0x56 || dwKeyCode == 0x76) {
- m_pOwner->DoClipboard(3);
+ DoClipboard(3);
return;
}
}
}
}
- if (MoveCaret != MC_MoveNone) {
- m_pOwner->m_pEdtEngine->MoveCaretPos(MoveCaret, bShift, bCtrl);
- }
+ if (MoveCaret != MC_MoveNone)
+ m_pEdtEngine->MoveCaretPos(MoveCaret, bShift, bCtrl);
}
-void CFWL_EditImpDelegate::OnChar(CFWL_MsgKey* pMsg) {
- if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) ||
- (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
+
+void IFWL_Edit::OnChar(CFWL_MsgKey* pMsg) {
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) ||
+ (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) {
return;
}
- if (!m_pOwner->m_pEdtEngine)
+ if (!m_pEdtEngine)
return;
+
int32_t iError = 0;
FX_WCHAR c = (FX_WCHAR)pMsg->m_dwKeyCode;
- int32_t nCaret = m_pOwner->m_pEdtEngine->GetCaretPos();
+ int32_t nCaret = m_pEdtEngine->GetCaretPos();
switch (c) {
- case FWL_VKEY_Back: {
- m_pOwner->m_pEdtEngine->Delete(nCaret, TRUE);
+ case FWL_VKEY_Back:
+ m_pEdtEngine->Delete(nCaret, TRUE);
break;
- }
- case 0x0A: {
+ case 0x0A:
break;
- }
- case FWL_VKEY_Escape: {
+ case FWL_VKEY_Escape:
break;
- }
case FWL_VKEY_Tab: {
- iError = m_pOwner->m_pEdtEngine->Insert(nCaret, L"\t", 1);
+ iError = m_pEdtEngine->Insert(nCaret, L"\t", 1);
break;
}
case FWL_VKEY_Return: {
- if (m_pOwner->m_pProperties->m_dwStyleExes &
- FWL_STYLEEXT_EDT_WantReturn) {
- iError = m_pOwner->m_pEdtEngine->Insert(nCaret, L"\n", 1);
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_WantReturn) {
+ iError = m_pEdtEngine->Insert(nCaret, L"\n", 1);
}
break;
}
default: {
- if (!m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
- if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Number) {
+ if (!m_pWidgetMgr->IsFormDisabled()) {
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Number) {
if (((pMsg->m_dwKeyCode < FWL_VKEY_0) &&
(pMsg->m_dwKeyCode != 0x2E && pMsg->m_dwKeyCode != 0x2D)) ||
pMsg->m_dwKeyCode > FWL_VKEY_9) {
break;
}
- if (!m_pOwner->ValidateNumberChar(c)) {
+ if (!ValidateNumberChar(c))
break;
- }
}
}
#if (_FX_OS_ == _FX_MACOSX_)
@@ -1952,17 +1929,17 @@ void CFWL_EditImpDelegate::OnChar(CFWL_MsgKey* pMsg) {
{
break;
}
- iError = m_pOwner->m_pEdtEngine->Insert(nCaret, &c, 1);
+ iError = m_pEdtEngine->Insert(nCaret, &c, 1);
break;
}
}
- if (iError < 0) {
- m_pOwner->ProcessInsertError(iError);
- }
+ if (iError < 0)
+ ProcessInsertError(iError);
}
-FX_BOOL CFWL_EditImpDelegate::OnScroll(IFWL_ScrollBar* pScrollBar,
- uint32_t dwCode,
- FX_FLOAT fPos) {
+
+FX_BOOL IFWL_Edit::OnScroll(IFWL_ScrollBar* pScrollBar,
+ uint32_t dwCode,
+ FX_FLOAT fPos) {
CFX_SizeF fs;
pScrollBar->GetRange(fs.x, fs.y);
FX_FLOAT iCurPos = pScrollBar->GetPos();
@@ -2005,27 +1982,25 @@ FX_BOOL CFWL_EditImpDelegate::OnScroll(IFWL_ScrollBar* pScrollBar,
break;
}
case FWL_SCBCODE_Pos:
- case FWL_SCBCODE_TrackPos: {
+ case FWL_SCBCODE_TrackPos:
break;
- }
- case FWL_SCBCODE_EndScroll: {
+ case FWL_SCBCODE_EndScroll:
return FALSE;
- }
- default: {}
+ default:
+ break;
}
if (iCurPos != fPos) {
pScrollBar->SetPos(fPos);
pScrollBar->SetTrackPos(fPos);
- m_pOwner->UpdateOffset(pScrollBar, fPos - iCurPos);
- if (m_pOwner->m_pEdtEngine) {
- m_pOwner->UpdateCaret();
+ UpdateOffset(pScrollBar, fPos - iCurPos);
+ if (m_pEdtEngine) {
+ UpdateCaret();
}
CFX_RectF rect;
- m_pOwner->GetWidgetRect(rect);
+ GetWidgetRect(rect);
CFX_RectF rtInvalidate;
rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2);
- m_pOwner->Repaint(&rtInvalidate);
+ Repaint(&rtInvalidate);
}
return TRUE;
}
-void CFWL_EditImpDelegate::DoCursor(CFWL_MsgMouse* pMsg) {}
diff --git a/xfa/fwl/core/ifwl_edit.h b/xfa/fwl/core/ifwl_edit.h
index 4c44913b7e..9959e42ba5 100644
--- a/xfa/fwl/core/ifwl_edit.h
+++ b/xfa/fwl/core/ifwl_edit.h
@@ -94,11 +94,9 @@ FWL_EVENT_DEF(CFWL_EvtEdtGetSuggestWords,
class CFWL_WidgetImpProperties;
class IFDE_TxtEdtDoRecord;
class IFWL_Edit;
-class CFWL_EditImpDelegate;
class CFWL_MsgActivate;
class CFWL_MsgDeactivate;
class CFWL_MsgMouse;
-class CFWL_WidgetImpDelegate;
class CFWL_WidgetImpProperties;
class IFWL_Caret;
@@ -121,6 +119,10 @@ class IFWL_Edit : public IFWL_Widget {
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessEvent(CFWL_Event* pEvent) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) override;
virtual FWL_Error SetText(const CFX_WideString& wsText);
virtual int32_t GetTextLength() const;
@@ -184,7 +186,6 @@ class IFWL_Edit : public IFWL_Widget {
protected:
friend class CFWL_TxtEdtEventSink;
- friend class CFWL_EditImpDelegate;
void DrawTextBk(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme,
@@ -250,21 +251,12 @@ class IFWL_Edit : public IFWL_Widget {
std::deque<std::unique_ptr<IFDE_TxtEdtDoRecord>> m_DoRecords;
int32_t m_iCurRecord;
int32_t m_iMaxRecord;
-};
-
-class CFWL_EditImpDelegate : public CFWL_WidgetImpDelegate {
- public:
- CFWL_EditImpDelegate(IFWL_Edit* pOwner);
- void OnProcessMessage(CFWL_Message* pMessage) override;
- void OnProcessEvent(CFWL_Event* pEvent) override;
- void OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) override;
- protected:
+ private:
void DoActivate(CFWL_MsgActivate* pMsg);
void DoDeactivate(CFWL_MsgDeactivate* pMsg);
void DoButtonDown(CFWL_MsgMouse* pMsg);
- void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet);
void OnLButtonDown(CFWL_MsgMouse* pMsg);
void OnLButtonUp(CFWL_MsgMouse* pMsg);
void OnButtonDblClk(CFWL_MsgMouse* pMsg);
@@ -272,8 +264,6 @@ class CFWL_EditImpDelegate : public CFWL_WidgetImpDelegate {
void OnKeyDown(CFWL_MsgKey* pMsg);
void OnChar(CFWL_MsgKey* pMsg);
FX_BOOL OnScroll(IFWL_ScrollBar* pScrollBar, uint32_t dwCode, FX_FLOAT fPos);
- void DoCursor(CFWL_MsgMouse* pMsg);
- IFWL_Edit* m_pOwner;
};
#endif // XFA_FWL_CORE_IFWL_EDIT_H_
diff --git a/xfa/fwl/core/ifwl_form.cpp b/xfa/fwl/core/ifwl_form.cpp
index 125f7c4cab..60213549f7 100644
--- a/xfa/fwl/core/ifwl_form.cpp
+++ b/xfa/fwl/core/ifwl_form.cpp
@@ -68,7 +68,6 @@ IFWL_Form::IFWL_Form(const IFWL_App* app,
RegisterForm();
RegisterEventTarget();
- SetDelegate(pdfium::MakeUnique<CFWL_FormImpDelegate>(this));
}
IFWL_Form::~IFWL_Form() {
@@ -770,23 +769,20 @@ void IFWL_Form::DoHeightLimit(FX_FLOAT& fTop,
}
}
-CFWL_FormImpDelegate::CFWL_FormImpDelegate(IFWL_Form* pOwner)
- : m_pOwner(pOwner) {}
-
#ifdef FWL_UseMacSystemBorder
-void CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+void IFWL_Form::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
return;
switch (pMessage->GetClassID()) {
case CFWL_MessageType::Activate: {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
- m_pOwner->Repaint(&m_pOwner->m_rtRelative);
+ m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
+ Repaint(&m_rtRelative);
break;
}
case CFWL_MessageType::Deactivate: {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated;
- m_pOwner->Repaint(&m_pOwner->m_rtRelative);
+ m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated;
+ Repaint(&m_rtRelative);
break;
}
default:
@@ -794,211 +790,191 @@ void CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
}
}
#else
-void CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+void IFWL_Form::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
return;
switch (pMessage->GetClassID()) {
case CFWL_MessageType::Activate: {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
- const IFWL_App* pApp = m_pOwner->GetOwnerApp();
+ m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
+ const IFWL_App* pApp = GetOwnerApp();
CFWL_NoteDriver* pDriver =
static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
- IFWL_Widget* pSubFocus = m_pOwner->GetSubFocus();
+ IFWL_Widget* pSubFocus = GetSubFocus();
if (pSubFocus && pSubFocus != pDriver->GetFocus())
pDriver->SetFocus(pSubFocus);
- m_pOwner->Repaint(&m_pOwner->m_rtRelative);
+ Repaint(&m_rtRelative);
break;
}
case CFWL_MessageType::Deactivate: {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated;
- const IFWL_App* pApp = m_pOwner->GetOwnerApp();
+ m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated;
+ const IFWL_App* pApp = GetOwnerApp();
CFWL_NoteDriver* pDriver =
static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
- IFWL_Widget* pSubFocus = m_pOwner->GetSubFocus();
+ IFWL_Widget* pSubFocus = GetSubFocus();
if (pSubFocus) {
if (pSubFocus == pDriver->GetFocus()) {
pDriver->SetFocus(nullptr);
} else if (pSubFocus->GetStates() & FWL_WGTSTATE_Focused) {
- if (IFWL_WidgetDelegate* pDelegate =
- pSubFocus->GetCurrentDelegate()) {
+ if (IFWL_WidgetDelegate* pDelegate = pSubFocus->GetDelegate()) {
CFWL_MsgKillFocus ms;
pDelegate->OnProcessMessage(&ms);
}
}
}
- m_pOwner->Repaint(&m_pOwner->m_rtRelative);
+ Repaint(&m_rtRelative);
break;
}
case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
switch (pMsg->m_dwCmd) {
- case FWL_MouseCommand::LeftButtonDown: {
+ case FWL_MouseCommand::LeftButtonDown:
OnLButtonDown(pMsg);
break;
- }
- case FWL_MouseCommand::LeftButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp:
OnLButtonUp(pMsg);
break;
- }
- case FWL_MouseCommand::Move: {
+ case FWL_MouseCommand::Move:
OnMouseMove(pMsg);
break;
- }
- case FWL_MouseCommand::Hover: {
+ case FWL_MouseCommand::Hover:
OnMouseHover(pMsg);
break;
- }
- case FWL_MouseCommand::Leave: {
+ case FWL_MouseCommand::Leave:
OnMouseLeave(pMsg);
break;
- }
- case FWL_MouseCommand::LeftButtonDblClk: {
+ case FWL_MouseCommand::LeftButtonDblClk:
OnLButtonDblClk(pMsg);
break;
- }
default:
break;
}
break;
}
case CFWL_MessageType::Size: {
- CFWL_WidgetMgr* pWidgetMgr = m_pOwner->GetOwnerApp()->GetWidgetMgr();
+ CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr();
if (!pWidgetMgr)
return;
- pWidgetMgr->AddRedrawCounts(m_pOwner);
- if (!m_pOwner->m_bSetMaximize)
+ pWidgetMgr->AddRedrawCounts(this);
+ if (!m_bSetMaximize)
break;
- m_pOwner->m_bSetMaximize = FALSE;
+ m_bSetMaximize = FALSE;
CFWL_MsgSize* pMsg = static_cast<CFWL_MsgSize*>(pMessage);
- m_pOwner->m_pProperties->m_rtWidget.left = 0;
- m_pOwner->m_pProperties->m_rtWidget.top = 0;
- 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();
+ m_pProperties->m_rtWidget.left = 0;
+ m_pProperties->m_rtWidget.top = 0;
+ m_pProperties->m_rtWidget.width = (FX_FLOAT)pMsg->m_iWidth;
+ m_pProperties->m_rtWidget.height = (FX_FLOAT)pMsg->m_iHeight;
+ Update();
break;
}
- case CFWL_MessageType::WindowMove: {
+ case CFWL_MessageType::WindowMove:
OnWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage));
break;
- }
- case CFWL_MessageType::Close: {
+ case CFWL_MessageType::Close:
OnClose(static_cast<CFWL_MsgClose*>(pMessage));
break;
- }
- default: { break; }
+ default:
+ break;
}
}
#endif // FWL_UseMacSystemBorder
-void CFWL_FormImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {}
-
-void CFWL_FormImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- m_pOwner->DrawWidget(pGraphics, pMatrix);
+void IFWL_Form::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ 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);
+void IFWL_Form::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ SetGrab(TRUE);
+ m_bLButtonDown = TRUE;
+ m_eResizeType = FORM_RESIZETYPE_None;
+ CFWL_SysBtn* pPressBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy);
+ m_iCaptureBtn = 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 -
- kSystemButtonSize * m_pOwner->m_iSysBox -
- 2 * m_pOwner->m_fCYBorder,
- m_pOwner->m_rtCaption.height - m_pOwner->m_fCXBorder);
+ rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder,
+ m_rtCaption.width - kSystemButtonSize * m_iSysBox - 2 * m_fCYBorder,
+ m_rtCaption.height - m_fCXBorder);
+
if (pPressBtn) {
pPressBtn->SetPressed();
- m_pOwner->Repaint(&pPressBtn->m_rtBtn);
+ 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_eResizeType = FORM_RESIZETYPE_Cap;
+ } else if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) &&
+ (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) &&
+ !m_bMaximized) {
+ 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);
+ m_InfoStart.m_ptStart = CFX_PointF(pMsg->m_fx, pMsg->m_fy);
+ m_InfoStart.m_szStart = CFX_SizeF(m_pProperties->m_rtWidget.width,
+ 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) {
+
+void IFWL_Form::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ SetGrab(FALSE);
+ m_bLButtonDown = FALSE;
+ CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy);
+ CFWL_SysBtn* pPressedBtn = GetSysBtnByIndex(m_iCaptureBtn);
+ if (!pPressedBtn || pPointBtn != pPressedBtn)
return;
- }
- if (pPressedBtn == m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Pressed)) {
+ if (pPressedBtn == 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();
+ if (pPressedBtn == m_pMaxBox) {
+ if (m_bMaximized) {
+ SetWidgetRect(m_rtRestore);
+ Update();
+ Repaint();
} else {
- m_pOwner->SetWorkAreaRect();
- m_pOwner->Update();
+ SetWorkAreaRect();
+ Update();
}
- m_pOwner->m_bMaximized = !m_pOwner->m_bMaximized;
- } else if (pPressedBtn != m_pOwner->m_pMinBox) {
+ m_bMaximized = !m_bMaximized;
+ } else if (pPressedBtn != m_pMinBox) {
CFWL_EvtClose eClose;
- eClose.m_pSrcTarget = m_pOwner;
- m_pOwner->DispatchEvent(&eClose);
+ eClose.m_pSrcTarget = this;
+ DispatchEvent(&eClose);
}
}
-void CFWL_FormImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_bLButtonDown) {
+
+void IFWL_Form::OnMouseMove(CFWL_MsgMouse* pMsg) {
+ if (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);
+
+ if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) &&
+ (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) &&
+ !m_bMaximized) {
+ 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);
+ CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy);
+ CFWL_SysBtn* pOldHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover);
#if (_FX_OS_ == _FX_MACOSX_)
{
- if (pOldHover && pPointBtn != pOldHover) {
+ if (pOldHover && pPointBtn != pOldHover)
pOldHover->SetNormal();
- }
- if (pPointBtn && pPointBtn != pOldHover) {
+ if (pPointBtn && pPointBtn != pOldHover)
pPointBtn->SetHover();
+ if (m_pCloseBox)
+ rtInvalidate = m_pCloseBox->m_rtBtn;
+ if (m_pMaxBox) {
+ if (rtInvalidate.IsEmpty())
+ rtInvalidate = m_pMaxBox->m_rtBtn;
+ else
+ rtInvalidate.Union(m_pMaxBox->m_rtBtn);
}
- 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 (m_pMinBox) {
+ if (rtInvalidate.IsEmpty())
+ rtInvalidate = m_pMinBox->m_rtBtn;
+ else
+ rtInvalidate.Union(m_pMinBox->m_rtBtn);
}
if (!rtInvalidate.IsEmpty() &&
rtInvalidate.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_bMouseIn = TRUE;
+ m_bMouseIn = TRUE;
}
}
#else
@@ -1009,51 +985,53 @@ void CFWL_FormImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
}
if (pPointBtn && pPointBtn != pOldHover) {
pPointBtn->SetHover();
- if (rtInvalidate.IsEmpty()) {
+ if (rtInvalidate.IsEmpty())
rtInvalidate = pPointBtn->m_rtBtn;
- } else {
+ else
rtInvalidate.Union(pPointBtn->m_rtBtn);
- }
}
}
#endif
- if (!rtInvalidate.IsEmpty()) {
- m_pOwner->Repaint(&rtInvalidate);
- }
+ if (!rtInvalidate.IsEmpty())
+ Repaint(&rtInvalidate);
}
-void CFWL_FormImpDelegate::OnMouseHover(CFWL_MsgMouse* pMsg) {
- m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy);
+
+void IFWL_Form::OnMouseHover(CFWL_MsgMouse* pMsg) {
+ SetCursor(pMsg->m_fx, pMsg->m_fy);
}
-void CFWL_FormImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
- CFWL_SysBtn* pHover = m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover);
+
+void IFWL_Form::OnMouseLeave(CFWL_MsgMouse* pMsg) {
+ CFWL_SysBtn* pHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover);
if (pHover) {
pHover->SetNormal();
- m_pOwner->Repaint(&pHover->m_rtBtn);
- }
- if (pMsg->m_dwCmd == FWL_MouseCommand::Leave && !m_pOwner->m_bLButtonDown) {
- m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy);
+ Repaint(&pHover->m_rtBtn);
}
+ if (pMsg->m_dwCmd == FWL_MouseCommand::Leave && !m_bLButtonDown)
+ 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_WidgetHit::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 IFWL_Form::OnLButtonDblClk(CFWL_MsgMouse* pMsg) {
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) &&
+ HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WidgetHit::Titlebar) {
+ if (m_bMaximized)
+ SetWidgetRect(m_rtRestore);
+ else
+ SetWorkAreaRect();
+
+ Update();
+ m_bMaximized = !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 IFWL_Form::OnWindowMove(CFWL_MsgWindowMove* pMsg) {
+ m_pProperties->m_rtWidget.left = pMsg->m_fx;
+ m_pProperties->m_rtWidget.top = pMsg->m_fy;
}
-void CFWL_FormImpDelegate::OnClose(CFWL_MsgClose* pMsg) {
+
+void IFWL_Form::OnClose(CFWL_MsgClose* pMsg) {
CFWL_EvtClose eClose;
- eClose.m_pSrcTarget = m_pOwner;
- m_pOwner->DispatchEvent(&eClose);
+ eClose.m_pSrcTarget = this;
+ DispatchEvent(&eClose);
}
CFWL_SysBtn::CFWL_SysBtn() {
diff --git a/xfa/fwl/core/ifwl_form.h b/xfa/fwl/core/ifwl_form.h
index c6158c60e1..76634ab513 100644
--- a/xfa/fwl/core/ifwl_form.h
+++ b/xfa/fwl/core/ifwl_form.h
@@ -76,7 +76,6 @@ class CFWL_WidgetImpProperties;
class IFWL_Widget;
class IFWL_ThemeProvider;
class CFWL_SysBtn;
-class CFWL_FormImpDelegate;
class IFWL_FormDP : public IFWL_DataProvider {
public:
@@ -99,6 +98,9 @@ class IFWL_Form : public IFWL_Widget {
FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override;
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) override;
FWL_FORMSIZE GetFormSize();
FWL_Error SetFormSize(FWL_FORMSIZE eFormSize);
@@ -182,17 +184,8 @@ class IFWL_Form : public IFWL_Widget {
CFX_DIBitmap* m_pBigIcon;
CFX_DIBitmap* m_pSmallIcon;
FX_BOOL m_bMouseIn;
-};
-
-class CFWL_FormImpDelegate : public CFWL_WidgetImpDelegate {
- public:
- CFWL_FormImpDelegate(IFWL_Form* pOwner);
- void OnProcessMessage(CFWL_Message* pMessage) override;
- void OnProcessEvent(CFWL_Event* pEvent) override;
- void OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) override;
- protected:
+ private:
void OnLButtonDown(CFWL_MsgMouse* pMsg);
void OnLButtonUp(CFWL_MsgMouse* pMsg);
void OnMouseMove(CFWL_MsgMouse* pMsg);
@@ -201,7 +194,6 @@ class CFWL_FormImpDelegate : public CFWL_WidgetImpDelegate {
void OnLButtonDblClk(CFWL_MsgMouse* pMsg);
void OnWindowMove(CFWL_MsgWindowMove* pMsg);
void OnClose(CFWL_MsgClose* pMsg);
- IFWL_Form* m_pOwner;
};
#endif // XFA_FWL_CORE_IFWL_FORM_H_
diff --git a/xfa/fwl/core/ifwl_formproxy.cpp b/xfa/fwl/core/ifwl_formproxy.cpp
index dee8973bc7..30c25827d5 100644
--- a/xfa/fwl/core/ifwl_formproxy.cpp
+++ b/xfa/fwl/core/ifwl_formproxy.cpp
@@ -13,7 +13,6 @@ IFWL_FormProxy::IFWL_FormProxy(const IFWL_App* app,
const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
: IFWL_Form(app, properties, pOuter) {
- SetDelegate(pdfium::MakeUnique<CFWL_FormProxyImpDelegate>(this));
}
IFWL_FormProxy::~IFWL_FormProxy() {}
@@ -38,9 +37,6 @@ FWL_Error IFWL_FormProxy::DrawWidget(CFX_Graphics* pGraphics,
return FWL_Error::Succeeded;
}
-CFWL_FormProxyImpDelegate::CFWL_FormProxyImpDelegate(IFWL_FormProxy* pOwner)
- : m_pOwner(pOwner) {}
-
-void CFWL_FormProxyImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
- m_pOwner->m_pOuter->GetCurrentDelegate()->OnProcessMessage(pMessage);
+void IFWL_FormProxy::OnProcessMessage(CFWL_Message* pMessage) {
+ m_pOuter->GetDelegate()->OnProcessMessage(pMessage);
}
diff --git a/xfa/fwl/core/ifwl_formproxy.h b/xfa/fwl/core/ifwl_formproxy.h
index c323bdc7b3..d28208b842 100644
--- a/xfa/fwl/core/ifwl_formproxy.h
+++ b/xfa/fwl/core/ifwl_formproxy.h
@@ -10,7 +10,6 @@
#include "xfa/fwl/core/ifwl_form.h"
class CFWL_WidgetImpProperties;
-class CFWL_FormProxyImpDelegate;
class IFWL_FormProxy : public IFWL_Form {
public:
@@ -25,18 +24,10 @@ class IFWL_FormProxy : public IFWL_Form {
FWL_Error Update() override;
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
-
- protected:
- friend class CFWL_FormProxyImpDelegate;
-};
-
-class CFWL_FormProxyImpDelegate : public CFWL_WidgetImpDelegate {
- public:
- CFWL_FormProxyImpDelegate(IFWL_FormProxy* pOwner);
void OnProcessMessage(CFWL_Message* pMessage) override;
protected:
- IFWL_FormProxy* m_pOwner;
+ friend class CFWL_FormProxyImpDelegate;
};
#endif // XFA_FWL_CORE_IFWL_FORMPROXY_H_
diff --git a/xfa/fwl/core/ifwl_listbox.cpp b/xfa/fwl/core/ifwl_listbox.cpp
index b4b6c25136..5d95c749d7 100644
--- a/xfa/fwl/core/ifwl_listbox.cpp
+++ b/xfa/fwl/core/ifwl_listbox.cpp
@@ -34,8 +34,6 @@ IFWL_ListBox::IFWL_ListBox(const IFWL_App* app,
m_rtClient.Reset();
m_rtConent.Reset();
m_rtStatic.Reset();
-
- SetDelegate(pdfium::MakeUnique<CFWL_ListBoxImpDelegate>(this));
}
IFWL_ListBox::~IFWL_ListBox() {}
@@ -913,159 +911,142 @@ void IFWL_ListBox::ProcessSelChanged() {
DispatchEvent(&selEvent);
}
-CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(IFWL_ListBox* pOwner)
- : m_pOwner(pOwner) {}
-
-void CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+void IFWL_ListBox::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
return;
- if (!m_pOwner->IsEnabled())
+ if (!IsEnabled())
return;
CFWL_MessageType dwMsgCode = pMessage->GetClassID();
switch (dwMsgCode) {
- case CFWL_MessageType::SetFocus: {
+ case CFWL_MessageType::SetFocus:
OnFocusChanged(pMessage, TRUE);
break;
- }
- case CFWL_MessageType::KillFocus: {
+ case CFWL_MessageType::KillFocus:
OnFocusChanged(pMessage, FALSE);
break;
- }
case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
switch (pMsg->m_dwCmd) {
- case FWL_MouseCommand::LeftButtonDown: {
+ case FWL_MouseCommand::LeftButtonDown:
OnLButtonDown(pMsg);
break;
- }
- case FWL_MouseCommand::LeftButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp:
OnLButtonUp(pMsg);
break;
- }
default:
break;
}
break;
}
- case CFWL_MessageType::MouseWheel: {
+ case CFWL_MessageType::MouseWheel:
OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage));
break;
- }
case CFWL_MessageType::Key: {
CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage);
if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown)
OnKeyDown(pMsg);
break;
}
- default: { break; }
+ default:
+ break;
}
- CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+ IFWL_Widget::OnProcessMessage(pMessage);
}
-void CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
+void IFWL_ListBox::OnProcessEvent(CFWL_Event* pEvent) {
if (!pEvent)
return;
if (pEvent->GetClassID() != CFWL_EventType::Scroll)
return;
IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget;
- if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() &&
- m_pOwner->m_pVertScrollBar) ||
- (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() &&
- m_pOwner->m_pHorzScrollBar)) {
+ if ((pSrcTarget == m_pVertScrollBar.get() && m_pVertScrollBar) ||
+ (pSrcTarget == m_pHorzScrollBar.get() && m_pHorzScrollBar)) {
CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent);
OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget),
pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos);
}
}
-void CFWL_ListBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- m_pOwner->DrawWidget(pGraphics, pMatrix);
+void IFWL_ListBox::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ DrawWidget(pGraphics, pMatrix);
}
-void CFWL_ListBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
- if (m_pOwner->GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) {
- if (m_pOwner->m_pVertScrollBar) {
- m_pOwner->m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet);
- }
- if (m_pOwner->m_pHorzScrollBar) {
- m_pOwner->m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet);
- }
- }
- if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused);
- } else {
- m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
- }
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+void IFWL_ListBox::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
+ if (GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) {
+ if (m_pVertScrollBar)
+ m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet);
+ if (m_pHorzScrollBar)
+ m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet);
+ }
+ if (bSet)
+ m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused);
+ else
+ m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
+
+ Repaint(&m_rtClient);
}
-void CFWL_ListBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
- m_pOwner->m_bLButtonDown = TRUE;
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
- m_pOwner->SetFocus(TRUE);
- }
- IFWL_ListItem* pItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
- if (!pItem) {
+void IFWL_ListBox::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ m_bLButtonDown = TRUE;
+ if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
+ SetFocus(TRUE);
+
+ IFWL_ListItem* pItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
+ if (!pItem)
return;
- }
- if (m_pOwner->m_pProperties->m_dwStyleExes &
- FWL_STYLEEXT_LTB_MultiSelection) {
+
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) {
if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) {
- FX_BOOL bSelected = m_pOwner->IsItemSelected(pItem);
- m_pOwner->SetSelectionDirect(pItem, !bSelected);
- m_pOwner->m_hAnchor = pItem;
+ FX_BOOL bSelected = IsItemSelected(pItem);
+ SetSelectionDirect(pItem, !bSelected);
+ m_hAnchor = pItem;
} else if (pMsg->m_dwFlags & FWL_KEYFLAG_Shift) {
- if (m_pOwner->m_hAnchor) {
- m_pOwner->SetSelection(m_pOwner->m_hAnchor, pItem, TRUE);
- } else {
- m_pOwner->SetSelectionDirect(pItem, TRUE);
- }
+ if (m_hAnchor)
+ SetSelection(m_hAnchor, pItem, TRUE);
+ else
+ SetSelectionDirect(pItem, TRUE);
} else {
- m_pOwner->SetSelection(pItem, pItem, TRUE);
- m_pOwner->m_hAnchor = pItem;
+ SetSelection(pItem, pItem, TRUE);
+ m_hAnchor = pItem;
}
} else {
- m_pOwner->SetSelection(pItem, pItem, TRUE);
+ SetSelection(pItem, pItem, TRUE);
}
- if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check) {
- IFWL_ListItem* hSelectedItem =
- m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check) {
+ IFWL_ListItem* hSelectedItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
CFX_RectF rtCheck;
- m_pOwner->GetItemCheckRect(hSelectedItem, rtCheck);
- FX_BOOL bChecked = m_pOwner->GetItemChecked(pItem);
+ GetItemCheckRect(hSelectedItem, rtCheck);
+ FX_BOOL bChecked = GetItemChecked(pItem);
if (rtCheck.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if (bChecked) {
- m_pOwner->SetItemChecked(pItem, FALSE);
- } else {
- m_pOwner->SetItemChecked(pItem, TRUE);
- }
- m_pOwner->Update();
+ SetItemChecked(pItem, !bChecked);
+ Update();
}
}
- m_pOwner->SetFocusItem(pItem);
- m_pOwner->ScrollToVisible(pItem);
- m_pOwner->SetGrab(TRUE);
- m_pOwner->ProcessSelChanged();
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ SetFocusItem(pItem);
+ ScrollToVisible(pItem);
+ SetGrab(TRUE);
+ ProcessSelChanged();
+ Repaint(&m_rtClient);
}
-void CFWL_ListBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_bLButtonDown) {
- m_pOwner->m_bLButtonDown = FALSE;
- m_pOwner->SetGrab(FALSE);
- DispatchSelChangedEv();
- }
+void IFWL_ListBox::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ if (!m_bLButtonDown)
+ return;
+
+ m_bLButtonDown = FALSE;
+ SetGrab(FALSE);
+ DispatchSelChangedEv();
}
-void CFWL_ListBoxImpDelegate::OnMouseWheel(CFWL_MsgMouseWheel* pMsg) {
- if (m_pOwner->IsShowScrollBar(TRUE))
- m_pOwner->m_pVertScrollBar->GetCurrentDelegate()->OnProcessMessage(pMsg);
+void IFWL_ListBox::OnMouseWheel(CFWL_MsgMouseWheel* pMsg) {
+ if (IsShowScrollBar(TRUE))
+ m_pVertScrollBar->GetDelegate()->OnProcessMessage(pMsg);
}
-void CFWL_ListBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
+void IFWL_ListBox::OnKeyDown(CFWL_MsgKey* pMsg) {
uint32_t dwKeyCode = pMsg->m_dwKeyCode;
switch (dwKeyCode) {
case FWL_VKEY_Tab:
@@ -1073,13 +1054,13 @@ void CFWL_ListBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
case FWL_VKEY_Down:
case FWL_VKEY_Home:
case FWL_VKEY_End: {
- IFWL_ListItem* pItem = m_pOwner->GetFocusedItem();
- pItem = m_pOwner->GetItem(pItem, dwKeyCode);
+ IFWL_ListItem* pItem = GetFocusedItem();
+ pItem = GetItem(pItem, dwKeyCode);
bool bShift = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Shift);
bool bCtrl = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl);
OnVK(pItem, bShift, bCtrl);
DispatchSelChangedEv();
- m_pOwner->ProcessSelChanged();
+ ProcessSelChanged();
break;
}
default:
@@ -1087,41 +1068,37 @@ void CFWL_ListBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
}
}
-void CFWL_ListBoxImpDelegate::OnVK(IFWL_ListItem* pItem,
- FX_BOOL bShift,
- FX_BOOL bCtrl) {
- if (!pItem) {
+void IFWL_ListBox::OnVK(IFWL_ListItem* pItem, FX_BOOL bShift, FX_BOOL bCtrl) {
+ if (!pItem)
return;
- }
- if (m_pOwner->m_pProperties->m_dwStyleExes &
- FWL_STYLEEXT_LTB_MultiSelection) {
+
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) {
if (bCtrl) {
} else if (bShift) {
- if (m_pOwner->m_hAnchor) {
- m_pOwner->SetSelection(m_pOwner->m_hAnchor, pItem, TRUE);
- } else {
- m_pOwner->SetSelectionDirect(pItem, TRUE);
- }
+ if (m_hAnchor)
+ SetSelection(m_hAnchor, pItem, TRUE);
+ else
+ SetSelectionDirect(pItem, TRUE);
} else {
- m_pOwner->SetSelection(pItem, pItem, TRUE);
- m_pOwner->m_hAnchor = pItem;
+ SetSelection(pItem, pItem, TRUE);
+ m_hAnchor = pItem;
}
} else {
- m_pOwner->SetSelection(pItem, pItem, TRUE);
- }
- m_pOwner->SetFocusItem(pItem);
- m_pOwner->ScrollToVisible(pItem);
- {
- CFX_RectF rtInvalidate;
- rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width,
- m_pOwner->m_pProperties->m_rtWidget.height);
- m_pOwner->Repaint(&rtInvalidate);
+ SetSelection(pItem, pItem, TRUE);
}
+
+ SetFocusItem(pItem);
+ ScrollToVisible(pItem);
+
+ CFX_RectF rtInvalidate;
+ rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width,
+ m_pProperties->m_rtWidget.height);
+ Repaint(&rtInvalidate);
}
-FX_BOOL CFWL_ListBoxImpDelegate::OnScroll(IFWL_ScrollBar* pScrollBar,
- uint32_t dwCode,
- FX_FLOAT fPos) {
+FX_BOOL IFWL_ListBox::OnScroll(IFWL_ScrollBar* pScrollBar,
+ uint32_t dwCode,
+ FX_FLOAT fPos) {
CFX_SizeF fs;
pScrollBar->GetRange(fs.x, fs.y);
FX_FLOAT iCurPos = pScrollBar->GetPos();
@@ -1137,30 +1114,26 @@ FX_BOOL CFWL_ListBoxImpDelegate::OnScroll(IFWL_ScrollBar* pScrollBar,
}
case FWL_SCBCODE_StepBackward: {
fPos -= fStep;
- if (fPos < fs.x + fStep / 2) {
+ if (fPos < fs.x + fStep / 2)
fPos = fs.x;
- }
break;
}
case FWL_SCBCODE_StepForward: {
fPos += fStep;
- if (fPos > fs.y - fStep / 2) {
+ if (fPos > fs.y - fStep / 2)
fPos = fs.y;
- }
break;
}
case FWL_SCBCODE_PageBackward: {
fPos -= pScrollBar->GetPageSize();
- if (fPos < fs.x) {
+ if (fPos < fs.x)
fPos = fs.x;
- }
break;
}
case FWL_SCBCODE_PageForward: {
fPos += pScrollBar->GetPageSize();
- if (fPos > fs.y) {
+ if (fPos > fs.y)
fPos = fs.y;
- }
break;
}
case FWL_SCBCODE_Pos:
@@ -1172,13 +1145,13 @@ FX_BOOL CFWL_ListBoxImpDelegate::OnScroll(IFWL_ScrollBar* pScrollBar,
if (iCurPos != fPos) {
pScrollBar->SetPos(fPos);
pScrollBar->SetTrackPos(fPos);
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ Repaint(&m_rtClient);
}
return TRUE;
}
-void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() {
+void IFWL_ListBox::DispatchSelChangedEv() {
CFWL_EvtLtbSelChanged ev;
- ev.m_pSrcTarget = m_pOwner;
- m_pOwner->DispatchEvent(&ev);
+ ev.m_pSrcTarget = this;
+ DispatchEvent(&ev);
}
diff --git a/xfa/fwl/core/ifwl_listbox.h b/xfa/fwl/core/ifwl_listbox.h
index 25e28cc3a6..5d4f896e94 100644
--- a/xfa/fwl/core/ifwl_listbox.h
+++ b/xfa/fwl/core/ifwl_listbox.h
@@ -32,7 +32,6 @@
#define FWL_ITEMSTATE_LTB_Focused (1L << 1)
#define FWL_ITEMSTATE_LTB_Checked (1L << 2)
-class CFWL_ListBoxImpDelegate;
class CFWL_MsgKillFocus;
class CFWL_MsgMouse;
class CFWL_MsgMouseWheel;
@@ -115,6 +114,10 @@ class IFWL_ListBox : public IFWL_Widget {
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessEvent(CFWL_Event* pEvent) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) override;
int32_t CountSelItems();
IFWL_ListItem* GetSelItem(int32_t nIndexSel);
@@ -180,17 +183,8 @@ class IFWL_ListBox : public IFWL_Widget {
FX_FLOAT m_fScorllBarWidth;
FX_BOOL m_bLButtonDown;
IFWL_ThemeProvider* m_pScrollBarTP;
-};
-
-class CFWL_ListBoxImpDelegate : public CFWL_WidgetImpDelegate {
- public:
- CFWL_ListBoxImpDelegate(IFWL_ListBox* pOwner);
- void OnProcessMessage(CFWL_Message* pMessage) override;
- void OnProcessEvent(CFWL_Event* pEvent) override;
- void OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) override;
- protected:
+ private:
void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
void OnLButtonDown(CFWL_MsgMouse* pMsg);
void OnLButtonUp(CFWL_MsgMouse* pMsg);
@@ -199,7 +193,6 @@ class CFWL_ListBoxImpDelegate : public CFWL_WidgetImpDelegate {
void OnVK(IFWL_ListItem* hItem, FX_BOOL bShift, FX_BOOL bCtrl);
FX_BOOL OnScroll(IFWL_ScrollBar* pScrollBar, uint32_t dwCode, FX_FLOAT fPos);
void DispatchSelChangedEv();
- IFWL_ListBox* m_pOwner;
};
#endif // XFA_FWL_CORE_IFWL_LISTBOX_H_
diff --git a/xfa/fwl/core/ifwl_monthcalendar.cpp b/xfa/fwl/core/ifwl_monthcalendar.cpp
index 8c5b3505b4..4ac0d2b222 100644
--- a/xfa/fwl/core/ifwl_monthcalendar.cpp
+++ b/xfa/fwl/core/ifwl_monthcalendar.cpp
@@ -146,8 +146,6 @@ IFWL_MonthCalendar::IFWL_MonthCalendar(
m_rtClient.Reset();
m_rtWeekNum.Reset();
m_rtWeekNumSep.Reset();
-
- SetDelegate(pdfium::MakeUnique<CFWL_MonthCalendarImpDelegate>(this));
}
IFWL_MonthCalendar::~IFWL_MonthCalendar() {
@@ -1015,185 +1013,165 @@ FX_BOOL IFWL_MonthCalendar::GetDayRect(int32_t iDay, CFX_RectF& rtDay) {
return TRUE;
}
-CFWL_MonthCalendarImpDelegate::CFWL_MonthCalendarImpDelegate(
- IFWL_MonthCalendar* pOwner)
- : m_pOwner(pOwner) {}
-
-void CFWL_MonthCalendarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+void IFWL_MonthCalendar::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
return;
CFWL_MessageType dwMsgCode = pMessage->GetClassID();
switch (dwMsgCode) {
- case CFWL_MessageType::SetFocus: {
+ case CFWL_MessageType::SetFocus:
OnFocusChanged(pMessage, TRUE);
break;
- }
- case CFWL_MessageType::KillFocus: {
+ case CFWL_MessageType::KillFocus:
OnFocusChanged(pMessage, FALSE);
break;
- }
- case CFWL_MessageType::Key: {
+ case CFWL_MessageType::Key:
break;
- }
case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage);
switch (pMouse->m_dwCmd) {
- case FWL_MouseCommand::LeftButtonDown: {
+ case FWL_MouseCommand::LeftButtonDown:
OnLButtonDown(pMouse);
break;
- }
- case FWL_MouseCommand::LeftButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp:
OnLButtonUp(pMouse);
break;
- }
- case FWL_MouseCommand::Move: {
+ case FWL_MouseCommand::Move:
OnMouseMove(pMouse);
break;
- }
- case FWL_MouseCommand::Leave: {
+ case FWL_MouseCommand::Leave:
OnMouseLeave(pMouse);
break;
- }
default:
break;
}
break;
}
- default: { break; }
+ default:
+ break;
}
- CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+ IFWL_Widget::OnProcessMessage(pMessage);
}
-void CFWL_MonthCalendarImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- m_pOwner->DrawWidget(pGraphics, pMatrix);
+void IFWL_MonthCalendar::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ DrawWidget(pGraphics, pMatrix);
}
-void CFWL_MonthCalendarImpDelegate::OnActivate(CFWL_Message* pMsg) {}
+void IFWL_MonthCalendar::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
+ if (bSet)
+ m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+ else
+ m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
-void CFWL_MonthCalendarImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
- FX_BOOL bSet) {
- if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- } else {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- }
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ Repaint(&m_rtClient);
}
-void CFWL_MonthCalendarImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iLBtnPartStates = CFWL_PartState_Pressed;
- m_pOwner->PrevMonth();
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iRBtnPartStates |= CFWL_PartState_Pressed;
- m_pOwner->NextMonth();
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- } else if (m_pOwner->m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) ==
- 0) {
- m_pOwner->JumpToToday();
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+void IFWL_MonthCalendar::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_iLBtnPartStates = CFWL_PartState_Pressed;
+ PrevMonth();
+ Repaint(&m_rtClient);
+ } else if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_iRBtnPartStates |= CFWL_PartState_Pressed;
+ NextMonth();
+ Repaint(&m_rtClient);
+ } else if (m_rtToday.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) == 0) {
+ JumpToToday();
+ Repaint(&m_rtClient);
}
} else {
- if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) {
- } else {
+ if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect)) {
int32_t iOldSel = 0;
- if (m_pOwner->m_arrSelDays.GetSize() > 0) {
- iOldSel = m_pOwner->m_arrSelDays[0];
- } else {
+ if (m_arrSelDays.GetSize() <= 0)
return;
- }
- int32_t iCurSel = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
+ iOldSel = m_arrSelDays[0];
+
+ int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
FX_BOOL bSelChanged = iCurSel > 0 && iCurSel != iOldSel;
if (bSelChanged) {
- FWL_DATEINFO* lpDatesInfo = m_pOwner->m_arrDates.GetAt(iCurSel - 1);
+ FWL_DATEINFO* lpDatesInfo = m_arrDates.GetAt(iCurSel - 1);
CFX_RectF rtInvalidate(lpDatesInfo->rect);
if (iOldSel > 0) {
- lpDatesInfo = m_pOwner->m_arrDates.GetAt(iOldSel - 1);
+ lpDatesInfo = m_arrDates.GetAt(iOldSel - 1);
rtInvalidate.Union(lpDatesInfo->rect);
}
- m_pOwner->AddSelDay(iCurSel);
+ AddSelDay(iCurSel);
CFWL_EvtClick wmClick;
- wmClick.m_pSrcTarget = m_pOwner;
- m_pOwner->DispatchEvent(&wmClick);
+ wmClick.m_pSrcTarget = this;
+ DispatchEvent(&wmClick);
CFWL_EventMcdDateChanged wmDateSelected;
wmDateSelected.m_iStartDay = iCurSel;
wmDateSelected.m_iEndDay = iCurSel;
- wmDateSelected.m_iOldMonth = m_pOwner->m_iCurMonth;
- wmDateSelected.m_iOldYear = m_pOwner->m_iCurYear;
- wmDateSelected.m_pSrcTarget = m_pOwner;
- m_pOwner->DispatchEvent(&wmDateSelected);
- m_pOwner->Repaint(&rtInvalidate);
+ wmDateSelected.m_iOldMonth = m_iCurMonth;
+ wmDateSelected.m_iOldYear = m_iCurYear;
+ wmDateSelected.m_pSrcTarget = this;
+ DispatchEvent(&wmDateSelected);
+ Repaint(&rtInvalidate);
}
}
}
}
-void CFWL_MonthCalendarImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iLBtnPartStates = 0;
- m_pOwner->Repaint(&m_pOwner->m_rtLBtn);
- } else if (m_pOwner->m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_iRBtnPartStates = 0;
- m_pOwner->Repaint(&m_pOwner->m_rtRBtn);
- } else if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
- int32_t iDay = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
- if (iDay != -1) {
- m_pOwner->AddSelDay(iDay);
- }
+void IFWL_MonthCalendar::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ if (m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_iLBtnPartStates = 0;
+ Repaint(&m_rtLBtn);
+ } else if (m_rtRBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_iRBtnPartStates = 0;
+ Repaint(&m_rtRBtn);
+ } else if (m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ int32_t iDay = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
+ if (iDay != -1)
+ AddSelDay(iDay);
}
}
-void CFWL_MonthCalendarImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) {
+void IFWL_MonthCalendar::OnMouseMove(CFWL_MsgMouse* pMsg) {
+ if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect)
return;
- }
+
FX_BOOL bRepaint = FALSE;
CFX_RectF rtInvalidate;
rtInvalidate.Set(0, 0, 0, 0);
- if (m_pOwner->m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
- int32_t iHover = m_pOwner->GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
- bRepaint = m_pOwner->m_iHovered != iHover;
+ if (m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ int32_t iHover = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy);
+ bRepaint = m_iHovered != iHover;
if (bRepaint) {
- if (m_pOwner->m_iHovered > 0) {
- m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
- }
+ if (m_iHovered > 0)
+ GetDayRect(m_iHovered, rtInvalidate);
if (iHover > 0) {
CFX_RectF rtDay;
- m_pOwner->GetDayRect(iHover, rtDay);
- if (rtInvalidate.IsEmpty()) {
+ GetDayRect(iHover, rtDay);
+ if (rtInvalidate.IsEmpty())
rtInvalidate = rtDay;
- } else {
+ else
rtInvalidate.Union(rtDay);
- }
}
}
- m_pOwner->m_iHovered = iHover;
+ m_iHovered = iHover;
} else {
- bRepaint = m_pOwner->m_iHovered > 0;
- if (bRepaint) {
- m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
- }
- m_pOwner->m_iHovered = -1;
- }
- if (bRepaint && !rtInvalidate.IsEmpty()) {
- m_pOwner->Repaint(&rtInvalidate);
+ bRepaint = m_iHovered > 0;
+ if (bRepaint)
+ GetDayRect(m_iHovered, rtInvalidate);
+
+ m_iHovered = -1;
}
+ if (bRepaint && !rtInvalidate.IsEmpty())
+ Repaint(&rtInvalidate);
}
-void CFWL_MonthCalendarImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_iHovered > 0) {
- CFX_RectF rtInvalidate;
- rtInvalidate.Set(0, 0, 0, 0);
- m_pOwner->GetDayRect(m_pOwner->m_iHovered, rtInvalidate);
- m_pOwner->m_iHovered = -1;
- if (!rtInvalidate.IsEmpty()) {
- m_pOwner->Repaint(&rtInvalidate);
- }
- }
+void IFWL_MonthCalendar::OnMouseLeave(CFWL_MsgMouse* pMsg) {
+ if (m_iHovered <= 0)
+ return;
+
+ CFX_RectF rtInvalidate;
+ rtInvalidate.Set(0, 0, 0, 0);
+ GetDayRect(m_iHovered, rtInvalidate);
+ m_iHovered = -1;
+ if (!rtInvalidate.IsEmpty())
+ Repaint(&rtInvalidate);
}
FWL_DATEINFO::FWL_DATEINFO(int32_t day,
diff --git a/xfa/fwl/core/ifwl_monthcalendar.h b/xfa/fwl/core/ifwl_monthcalendar.h
index 6bf8ad4898..dfde3944a1 100644
--- a/xfa/fwl/core/ifwl_monthcalendar.h
+++ b/xfa/fwl/core/ifwl_monthcalendar.h
@@ -34,7 +34,6 @@ FWL_EVENT_DEF(CFWL_EventMcdDateChanged,
int32_t m_iStartDay;
int32_t m_iEndDay;)
-class CFWL_MonthCalendarImpDelegate;
class CFWL_MsgMouse;
class CFWL_WidgetImpProperties;
class IFWL_Widget;
@@ -63,6 +62,10 @@ class IFWL_MonthCalendar : public IFWL_Widget {
FWL_Error Update() override;
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) override;
+
int32_t CountSelect();
FX_BOOL GetSelect(int32_t& iYear,
int32_t& iMonth,
@@ -236,7 +239,13 @@ class IFWL_MonthCalendar : public IFWL_Widget {
FX_FLOAT m_fTodayFlagWid;
FX_FLOAT m_fMCWid;
FX_FLOAT m_fMCHei;
- friend class CFWL_MonthCalendarImpDelegate;
+
+ private:
+ void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet);
+ void OnLButtonDown(CFWL_MsgMouse* pMsg);
+ void OnLButtonUp(CFWL_MsgMouse* pMsg);
+ void OnMouseMove(CFWL_MsgMouse* pMsg);
+ void OnMouseLeave(CFWL_MsgMouse* pMsg);
};
struct FWL_DATEINFO {
@@ -254,21 +263,4 @@ struct FWL_DATEINFO {
CFX_WideString wsDay;
};
-class CFWL_MonthCalendarImpDelegate : public CFWL_WidgetImpDelegate {
- public:
- CFWL_MonthCalendarImpDelegate(IFWL_MonthCalendar* pOwner);
- void OnProcessMessage(CFWL_Message* pMessage) override;
- void OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) override;
-
- protected:
- void OnActivate(CFWL_Message* pMsg);
- void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
- void OnLButtonDown(CFWL_MsgMouse* pMsg);
- void OnLButtonUp(CFWL_MsgMouse* pMsg);
- void OnMouseMove(CFWL_MsgMouse* pMsg);
- void OnMouseLeave(CFWL_MsgMouse* pMsg);
- IFWL_MonthCalendar* m_pOwner;
-};
-
#endif // XFA_FWL_CORE_IFWL_MONTHCALENDAR_H_
diff --git a/xfa/fwl/core/ifwl_picturebox.cpp b/xfa/fwl/core/ifwl_picturebox.cpp
index 50bf2a40ea..6ab792c985 100644
--- a/xfa/fwl/core/ifwl_picturebox.cpp
+++ b/xfa/fwl/core/ifwl_picturebox.cpp
@@ -19,8 +19,6 @@ IFWL_PictureBox::IFWL_PictureBox(const IFWL_App* app,
m_rtClient.Reset();
m_rtImage.Reset();
m_matrix.SetIdentity();
-
- SetDelegate(pdfium::MakeUnique<CFWL_PictureBoxImpDelegate>(this));
}
IFWL_PictureBox::~IFWL_PictureBox() {}
@@ -119,10 +117,7 @@ bool IFWL_PictureBox::VStyle(uint32_t dwStyle) {
return false;
}
-CFWL_PictureBoxImpDelegate::CFWL_PictureBoxImpDelegate(IFWL_PictureBox* pOwner)
- : m_pOwner(pOwner) {}
-
-void CFWL_PictureBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- m_pOwner->DrawWidget(pGraphics, pMatrix);
+void IFWL_PictureBox::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ DrawWidget(pGraphics, pMatrix);
}
diff --git a/xfa/fwl/core/ifwl_picturebox.h b/xfa/fwl/core/ifwl_picturebox.h
index ecbbc449cb..05f094b25c 100644
--- a/xfa/fwl/core/ifwl_picturebox.h
+++ b/xfa/fwl/core/ifwl_picturebox.h
@@ -27,7 +27,6 @@
#define FWL_STYLEEXT_PTB_VAlignMask 3L << 2
#define FWL_STYLEEXT_PTB_StretchAlignMask 7L << 4
-class CFWL_PictureBoxImpDelegate;
class CFWL_WidgetImpProperties;
class CFX_DIBitmap;
class IFWL_Widget;
@@ -54,10 +53,10 @@ class IFWL_PictureBox : public IFWL_Widget {
FWL_Error Update() override;
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) override;
protected:
- friend class CFWL_PictureBoxImpDelegate;
-
void DrawBkground(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix = nullptr);
@@ -71,14 +70,4 @@ class IFWL_PictureBox : public IFWL_Widget {
FX_BOOL m_bButton;
};
-class CFWL_PictureBoxImpDelegate : public CFWL_WidgetImpDelegate {
- public:
- CFWL_PictureBoxImpDelegate(IFWL_PictureBox* pOwner);
- void OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) override;
-
- protected:
- IFWL_PictureBox* m_pOwner;
-};
-
#endif // XFA_FWL_CORE_IFWL_PICTUREBOX_H_
diff --git a/xfa/fwl/core/ifwl_pushbutton.cpp b/xfa/fwl/core/ifwl_pushbutton.cpp
index 597cf65529..8eab8d6eb7 100644
--- a/xfa/fwl/core/ifwl_pushbutton.cpp
+++ b/xfa/fwl/core/ifwl_pushbutton.cpp
@@ -23,8 +23,6 @@ IFWL_PushButton::IFWL_PushButton(const IFWL_App* app,
m_iTTOAlign(FDE_TTOALIGNMENT_Center) {
m_rtClient.Set(0, 0, 0, 0);
m_rtCaption.Set(0, 0, 0, 0);
-
- SetDelegate(pdfium::MakeUnique<CFWL_PushButtonImpDelegate>(this));
}
IFWL_PushButton::~IFWL_PushButton() {}
@@ -381,44 +379,35 @@ void IFWL_PushButton::UpdateTextOutStyles() {
}
}
-CFWL_PushButtonImpDelegate::CFWL_PushButtonImpDelegate(IFWL_PushButton* pOwner)
- : m_pOwner(pOwner) {}
-
-void CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+void IFWL_PushButton::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
return;
- if (!m_pOwner->IsEnabled())
+ if (!IsEnabled())
return;
CFWL_MessageType dwMsgCode = pMessage->GetClassID();
switch (dwMsgCode) {
- case CFWL_MessageType::SetFocus: {
+ case CFWL_MessageType::SetFocus:
OnFocusChanged(pMessage, TRUE);
break;
- }
- case CFWL_MessageType::KillFocus: {
+ case CFWL_MessageType::KillFocus:
OnFocusChanged(pMessage, FALSE);
break;
- }
case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
switch (pMsg->m_dwCmd) {
- case FWL_MouseCommand::LeftButtonDown: {
+ case FWL_MouseCommand::LeftButtonDown:
OnLButtonDown(pMsg);
break;
- }
- case FWL_MouseCommand::LeftButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp:
OnLButtonUp(pMsg);
break;
- }
- case FWL_MouseCommand::Move: {
+ case FWL_MouseCommand::Move:
OnMouseMove(pMsg);
break;
- }
- case FWL_MouseCommand::Leave: {
+ case FWL_MouseCommand::Leave:
OnMouseLeave(pMsg);
break;
- }
default:
break;
}
@@ -430,111 +419,107 @@ void CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
OnKeyDown(pKey);
break;
}
- default: { break; }
+ default:
+ break;
}
- CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+ IFWL_Widget::OnProcessMessage(pMessage);
}
-void CFWL_PushButtonImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {}
-
-void CFWL_PushButtonImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- m_pOwner->DrawWidget(pGraphics, pMatrix);
+void IFWL_PushButton::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ DrawWidget(pGraphics, pMatrix);
}
-void CFWL_PushButtonImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
- FX_BOOL bSet) {
- if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
- } else {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
- }
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+void IFWL_PushButton::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
+ if (bSet)
+ m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
+ else
+ m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
+
+ Repaint(&m_rtClient);
}
-void CFWL_PushButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) {
- m_pOwner->SetFocus(TRUE);
- }
- m_pOwner->m_bBtnDown = TRUE;
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed;
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+void IFWL_PushButton::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)
+ SetFocus(TRUE);
+
+ m_bBtnDown = TRUE;
+ m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
+ m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed;
+ Repaint(&m_rtClient);
}
-void CFWL_PushButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
- m_pOwner->m_bBtnDown = FALSE;
- if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
+void IFWL_PushButton::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ m_bBtnDown = FALSE;
+ if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
+ m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
} else {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
+ m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
+ m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
}
- if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
CFWL_EvtClick wmClick;
- wmClick.m_pSrcTarget = m_pOwner;
- m_pOwner->DispatchEvent(&wmClick);
+ wmClick.m_pSrcTarget = this;
+ DispatchEvent(&wmClick);
}
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ Repaint(&m_rtClient);
}
-void CFWL_PushButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
+void IFWL_PushButton::OnMouseMove(CFWL_MsgMouse* pMsg) {
FX_BOOL bRepaint = FALSE;
- if (m_pOwner->m_bBtnDown) {
- if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) == 0) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed;
+ if (m_bBtnDown) {
+ if (m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if ((m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) == 0) {
+ m_pProperties->m_dwStates |= FWL_STATE_PSB_Pressed;
bRepaint = TRUE;
}
- if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
+ if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) {
+ m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
bRepaint = TRUE;
}
} else {
- if (m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) {
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
+ if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) {
+ m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
bRepaint = TRUE;
}
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
+ if ((m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) {
+ m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
bRepaint = TRUE;
}
}
} else {
- if (!m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if (!m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy))
return;
- }
- if ((m_pOwner->m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) {
- m_pOwner->m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
+ if ((m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) == 0) {
+ m_pProperties->m_dwStates |= FWL_STATE_PSB_Hovered;
bRepaint = TRUE;
}
}
- if (bRepaint) {
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
- }
+ if (bRepaint)
+ Repaint(&m_rtClient);
}
-void CFWL_PushButtonImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
- m_pOwner->m_bBtnDown = FALSE;
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
- m_pOwner->m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+void IFWL_PushButton::OnMouseLeave(CFWL_MsgMouse* pMsg) {
+ m_bBtnDown = FALSE;
+ m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Hovered;
+ m_pProperties->m_dwStates &= ~FWL_STATE_PSB_Pressed;
+ Repaint(&m_rtClient);
}
-void CFWL_PushButtonImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
+void IFWL_PushButton::OnKeyDown(CFWL_MsgKey* pMsg) {
if (pMsg->m_dwKeyCode == FWL_VKEY_Return) {
CFWL_EvtMouse wmMouse;
- wmMouse.m_pSrcTarget = m_pOwner;
+ wmMouse.m_pSrcTarget = this;
wmMouse.m_dwCmd = FWL_MouseCommand::LeftButtonUp;
- m_pOwner->DispatchEvent(&wmMouse);
+ DispatchEvent(&wmMouse);
CFWL_EvtClick wmClick;
- wmClick.m_pSrcTarget = m_pOwner;
- m_pOwner->DispatchEvent(&wmClick);
+ wmClick.m_pSrcTarget = this;
+ DispatchEvent(&wmClick);
return;
}
- if (pMsg->m_dwKeyCode != FWL_VKEY_Tab) {
+ if (pMsg->m_dwKeyCode != FWL_VKEY_Tab)
return;
- }
- m_pOwner->DispatchKeyEvent(pMsg);
+
+ DispatchKeyEvent(pMsg);
}
diff --git a/xfa/fwl/core/ifwl_pushbutton.h b/xfa/fwl/core/ifwl_pushbutton.h
index c009c47dca..18b15ab846 100644
--- a/xfa/fwl/core/ifwl_pushbutton.h
+++ b/xfa/fwl/core/ifwl_pushbutton.h
@@ -28,7 +28,6 @@
#define FWL_STATE_PSB_Default (1 << (FWL_WGTSTATE_MAX + 2))
class CFWL_MsgMouse;
-class CFWL_PushButtonImpDelegate;
class CFWL_WidgetImpProperties;
class CFX_DIBitmap;
class IFWL_Widget;
@@ -51,10 +50,11 @@ class IFWL_PushButton : public IFWL_Widget {
FWL_Error Update() override;
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) override;
protected:
- friend class CFWL_PushButtonImpDelegate;
-
void DrawBkground(CFX_Graphics* pGraphics,
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix);
@@ -69,24 +69,14 @@ class IFWL_PushButton : public IFWL_Widget {
FX_BOOL m_bBtnDown;
uint32_t m_dwTTOStyles;
int32_t m_iTTOAlign;
-};
-class CFWL_PushButtonImpDelegate : public CFWL_WidgetImpDelegate {
- public:
- CFWL_PushButtonImpDelegate(IFWL_PushButton* pOwner);
- void OnProcessMessage(CFWL_Message* pMessage) override;
- void OnProcessEvent(CFWL_Event* pEvent) override;
- void OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) override;
-
- protected:
- void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ private:
+ void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet);
void OnLButtonDown(CFWL_MsgMouse* pMsg);
void OnLButtonUp(CFWL_MsgMouse* pMsg);
void OnMouseMove(CFWL_MsgMouse* pMsg);
void OnMouseLeave(CFWL_MsgMouse* pMsg);
void OnKeyDown(CFWL_MsgKey* pMsg);
- IFWL_PushButton* m_pOwner;
};
#endif // XFA_FWL_CORE_IFWL_PUSHBUTTON_H_
diff --git a/xfa/fwl/core/ifwl_scrollbar.cpp b/xfa/fwl/core/ifwl_scrollbar.cpp
index a66baddc74..24f6b367a5 100644
--- a/xfa/fwl/core/ifwl_scrollbar.cpp
+++ b/xfa/fwl/core/ifwl_scrollbar.cpp
@@ -52,8 +52,6 @@ IFWL_ScrollBar::IFWL_ScrollBar(const IFWL_App* app,
m_rtMaxBtn.Reset();
m_rtMinTrack.Reset();
m_rtMaxTrack.Reset();
-
- SetDelegate(pdfium::MakeUnique<CFWL_ScrollBarImpDelegate>(this));
}
IFWL_ScrollBar::~IFWL_ScrollBar() {}
@@ -569,10 +567,7 @@ FX_BOOL IFWL_ScrollBar::OnScroll(uint32_t dwCode, FX_FLOAT fPos) {
return bRet;
}
-CFWL_ScrollBarImpDelegate::CFWL_ScrollBarImpDelegate(IFWL_ScrollBar* pOwner)
- : m_pOwner(pOwner) {}
-
-void CFWL_ScrollBarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+void IFWL_ScrollBar::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
return;
@@ -580,23 +575,20 @@ void CFWL_ScrollBarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
if (dwMsgCode == CFWL_MessageType::Mouse) {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
switch (pMsg->m_dwCmd) {
- case FWL_MouseCommand::LeftButtonDown: {
+ case FWL_MouseCommand::LeftButtonDown:
OnLButtonDown(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy);
break;
- }
- case FWL_MouseCommand::LeftButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp:
OnLButtonUp(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy);
break;
- }
- case FWL_MouseCommand::Move: {
+ case FWL_MouseCommand::Move:
OnMouseMove(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy);
break;
- }
- case FWL_MouseCommand::Leave: {
+ case FWL_MouseCommand::Leave:
OnMouseLeave();
break;
- }
- default: { break; }
+ default:
+ break;
}
} else if (dwMsgCode == CFWL_MessageType::MouseWheel) {
CFWL_MsgMouseWheel* pMsg = static_cast<CFWL_MsgMouseWheel*>(pMessage);
@@ -605,158 +597,138 @@ void CFWL_ScrollBarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
}
}
-void CFWL_ScrollBarImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- m_pOwner->DrawWidget(pGraphics, pMatrix);
+void IFWL_ScrollBar::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ DrawWidget(pGraphics, pMatrix);
}
-void CFWL_ScrollBarImpDelegate::OnLButtonDown(uint32_t dwFlags,
- FX_FLOAT fx,
- FX_FLOAT fy) {
- if (!m_pOwner->IsEnabled()) {
+void IFWL_ScrollBar::OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
+ if (!IsEnabled())
return;
- }
- m_pOwner->m_bMouseDown = TRUE;
- m_pOwner->SetGrab(TRUE);
- m_pOwner->m_cpTrackPointX = fx;
- m_pOwner->m_cpTrackPointY = fy;
- m_pOwner->m_fLastTrackPos = m_pOwner->m_fTrackPos;
- if (m_pOwner->m_rtMinBtn.Contains(fx, fy)) {
- DoMouseDown(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy);
- } else {
- if (m_pOwner->m_rtThumb.Contains(fx, fy)) {
- DoMouseDown(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx,
- fy);
- } else {
- if (m_pOwner->m_rtMaxBtn.Contains(fx, fy)) {
- DoMouseDown(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx,
- fy);
- } else {
- if (m_pOwner->m_rtMinTrack.Contains(fx, fy)) {
- DoMouseDown(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx,
- fy);
- } else {
- DoMouseDown(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx,
- fy);
- }
- }
- }
- }
- if (!m_pOwner->SendEvent())
- m_pOwner->m_pTimerInfo =
- m_pOwner->m_Timer.StartTimer(FWL_SCROLLBAR_Elapse, true);
-}
-
-void CFWL_ScrollBarImpDelegate::OnLButtonUp(uint32_t dwFlags,
- FX_FLOAT fx,
- FX_FLOAT fy) {
- m_pOwner->m_pTimerInfo->StopTimer();
- m_pOwner->m_bMouseDown = FALSE;
- DoMouseUp(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy);
- DoMouseUp(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy);
- DoMouseUp(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy);
- DoMouseUp(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy);
- DoMouseUp(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy);
- m_pOwner->SetGrab(FALSE);
-}
-
-void CFWL_ScrollBarImpDelegate::OnMouseMove(uint32_t dwFlags,
- FX_FLOAT fx,
- FX_FLOAT fy) {
- DoMouseMove(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy);
- DoMouseMove(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy);
- DoMouseMove(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy);
- DoMouseMove(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy);
- DoMouseMove(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy);
-}
-
-void CFWL_ScrollBarImpDelegate::OnMouseLeave() {
- DoMouseLeave(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState);
- DoMouseLeave(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState);
- DoMouseLeave(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState);
- DoMouseLeave(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState);
- DoMouseLeave(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState);
-}
-
-void CFWL_ScrollBarImpDelegate::OnMouseWheel(FX_FLOAT fx,
- FX_FLOAT fy,
- uint32_t dwFlags,
- FX_FLOAT fDeltaX,
- FX_FLOAT fDeltaY) {
- m_pOwner->m_iMouseWheel = (int32_t)fDeltaX;
- m_pOwner->SendEvent();
- m_pOwner->m_iMouseWheel = 0;
-}
-
-void CFWL_ScrollBarImpDelegate::DoMouseDown(int32_t iItem,
- const CFX_RectF& rtItem,
- int32_t& iState,
- FX_FLOAT fx,
- FX_FLOAT fy) {
- if (!rtItem.Contains(fx, fy)) {
+
+ m_bMouseDown = TRUE;
+ SetGrab(TRUE);
+ m_cpTrackPointX = fx;
+ m_cpTrackPointY = fy;
+ m_fLastTrackPos = m_fTrackPos;
+ if (m_rtMinBtn.Contains(fx, fy))
+ DoMouseDown(0, m_rtMinBtn, m_iMinButtonState, fx, fy);
+ else if (m_rtThumb.Contains(fx, fy))
+ DoMouseDown(1, m_rtThumb, m_iThumbButtonState, fx, fy);
+ else if (m_rtMaxBtn.Contains(fx, fy))
+ DoMouseDown(2, m_rtMaxBtn, m_iMaxButtonState, fx, fy);
+ else if (m_rtMinTrack.Contains(fx, fy))
+ DoMouseDown(3, m_rtMinTrack, m_iMinTrackState, fx, fy);
+ else
+ DoMouseDown(4, m_rtMaxTrack, m_iMaxTrackState, fx, fy);
+
+ if (!SendEvent())
+ m_pTimerInfo = m_Timer.StartTimer(FWL_SCROLLBAR_Elapse, true);
+}
+
+void IFWL_ScrollBar::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
+ m_pTimerInfo->StopTimer();
+ m_bMouseDown = FALSE;
+ DoMouseUp(0, m_rtMinBtn, m_iMinButtonState, fx, fy);
+ DoMouseUp(1, m_rtThumb, m_iThumbButtonState, fx, fy);
+ DoMouseUp(2, m_rtMaxBtn, m_iMaxButtonState, fx, fy);
+ DoMouseUp(3, m_rtMinTrack, m_iMinTrackState, fx, fy);
+ DoMouseUp(4, m_rtMaxTrack, m_iMaxTrackState, fx, fy);
+ SetGrab(FALSE);
+}
+
+void IFWL_ScrollBar::OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) {
+ DoMouseMove(0, m_rtMinBtn, m_iMinButtonState, fx, fy);
+ DoMouseMove(1, m_rtThumb, m_iThumbButtonState, fx, fy);
+ DoMouseMove(2, m_rtMaxBtn, m_iMaxButtonState, fx, fy);
+ DoMouseMove(3, m_rtMinTrack, m_iMinTrackState, fx, fy);
+ DoMouseMove(4, m_rtMaxTrack, m_iMaxTrackState, fx, fy);
+}
+
+void IFWL_ScrollBar::OnMouseLeave() {
+ DoMouseLeave(0, m_rtMinBtn, m_iMinButtonState);
+ DoMouseLeave(1, m_rtThumb, m_iThumbButtonState);
+ DoMouseLeave(2, m_rtMaxBtn, m_iMaxButtonState);
+ DoMouseLeave(3, m_rtMinTrack, m_iMinTrackState);
+ DoMouseLeave(4, m_rtMaxTrack, m_iMaxTrackState);
+}
+
+void IFWL_ScrollBar::OnMouseWheel(FX_FLOAT fx,
+ FX_FLOAT fy,
+ uint32_t dwFlags,
+ FX_FLOAT fDeltaX,
+ FX_FLOAT fDeltaY) {
+ m_iMouseWheel = (int32_t)fDeltaX;
+ SendEvent();
+ m_iMouseWheel = 0;
+}
+
+void IFWL_ScrollBar::DoMouseDown(int32_t iItem,
+ const CFX_RectF& rtItem,
+ int32_t& iState,
+ FX_FLOAT fx,
+ FX_FLOAT fy) {
+ if (!rtItem.Contains(fx, fy))
return;
- }
- if (iState == CFWL_PartState_Pressed) {
+ if (iState == CFWL_PartState_Pressed)
return;
- }
iState = CFWL_PartState_Pressed;
- m_pOwner->Repaint(&rtItem);
+ Repaint(&rtItem);
}
-void CFWL_ScrollBarImpDelegate::DoMouseUp(int32_t iItem,
- const CFX_RectF& rtItem,
- int32_t& iState,
- FX_FLOAT fx,
- FX_FLOAT fy) {
+void IFWL_ScrollBar::DoMouseUp(int32_t iItem,
+ const CFX_RectF& rtItem,
+ int32_t& iState,
+ FX_FLOAT fx,
+ FX_FLOAT fy) {
int32_t iNewState =
rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered : CFWL_PartState_Normal;
- if (iState == iNewState) {
+ if (iState == iNewState)
return;
- }
+
iState = iNewState;
- m_pOwner->Repaint(&rtItem);
- m_pOwner->OnScroll(FWL_SCBCODE_EndScroll, m_pOwner->m_fTrackPos);
+ Repaint(&rtItem);
+ OnScroll(FWL_SCBCODE_EndScroll, m_fTrackPos);
}
-void CFWL_ScrollBarImpDelegate::DoMouseMove(int32_t iItem,
- const CFX_RectF& rtItem,
- int32_t& iState,
- FX_FLOAT fx,
- FX_FLOAT fy) {
- if (!m_pOwner->m_bMouseDown) {
+void IFWL_ScrollBar::DoMouseMove(int32_t iItem,
+ const CFX_RectF& rtItem,
+ int32_t& iState,
+ FX_FLOAT fx,
+ FX_FLOAT fy) {
+ if (!m_bMouseDown) {
int32_t iNewState = rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered
: CFWL_PartState_Normal;
- if (iState == iNewState) {
+ if (iState == iNewState)
return;
- }
+
iState = iNewState;
- m_pOwner->Repaint(&rtItem);
- } else if ((2 == iItem) &&
- (m_pOwner->m_iThumbButtonState == CFWL_PartState_Pressed)) {
- FX_FLOAT fPos = m_pOwner->GetTrackPointPos(fx, fy);
- m_pOwner->m_fTrackPos = fPos;
- m_pOwner->OnScroll(FWL_SCBCODE_TrackPos, fPos);
+ Repaint(&rtItem);
+ } else if ((2 == iItem) && (m_iThumbButtonState == CFWL_PartState_Pressed)) {
+ FX_FLOAT fPos = GetTrackPointPos(fx, fy);
+ m_fTrackPos = fPos;
+ OnScroll(FWL_SCBCODE_TrackPos, fPos);
}
}
-void CFWL_ScrollBarImpDelegate::DoMouseLeave(int32_t iItem,
- const CFX_RectF& rtItem,
- int32_t& iState) {
- if (iState == CFWL_PartState_Normal) {
+void IFWL_ScrollBar::DoMouseLeave(int32_t iItem,
+ const CFX_RectF& rtItem,
+ int32_t& iState) {
+ if (iState == CFWL_PartState_Normal)
return;
- }
+
iState = CFWL_PartState_Normal;
- m_pOwner->Repaint(&rtItem);
+ Repaint(&rtItem);
}
-void CFWL_ScrollBarImpDelegate::DoMouseHover(int32_t iItem,
- const CFX_RectF& rtItem,
- int32_t& iState) {
- if (iState == CFWL_PartState_Hovered) {
+void IFWL_ScrollBar::DoMouseHover(int32_t iItem,
+ const CFX_RectF& rtItem,
+ int32_t& iState) {
+ if (iState == CFWL_PartState_Hovered)
return;
- }
+
iState = CFWL_PartState_Hovered;
- m_pOwner->Repaint(&rtItem);
+ Repaint(&rtItem);
}
IFWL_ScrollBar::Timer::Timer(IFWL_ScrollBar* pToolTip) : IFWL_Timer(pToolTip) {}
diff --git a/xfa/fwl/core/ifwl_scrollbar.h b/xfa/fwl/core/ifwl_scrollbar.h
index 5d7fc97920..1c107638ec 100644
--- a/xfa/fwl/core/ifwl_scrollbar.h
+++ b/xfa/fwl/core/ifwl_scrollbar.h
@@ -14,7 +14,6 @@
#include "xfa/fwl/core/ifwl_timer.h"
#include "xfa/fwl/core/ifwl_widget.h"
-class CFWL_ScrollBarImpDelegate;
class CFWL_WidgetImpProperties;
class IFWL_Widget;
@@ -49,6 +48,9 @@ class IFWL_ScrollBar : public IFWL_Widget {
FWL_Error Update() override;
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) override;
FX_BOOL IsVertical();
FWL_Error GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax);
@@ -65,8 +67,6 @@ class IFWL_ScrollBar : public IFWL_Widget {
FWL_Error SetOuter(IFWL_Widget* pOuter);
protected:
- friend class CFWL_ScrollBarImpDelegate;
-
class Timer : public IFWL_Timer {
public:
explicit Timer(IFWL_ScrollBar* pToolTip);
@@ -131,16 +131,8 @@ class IFWL_ScrollBar : public IFWL_Widget {
bool m_bCustomLayout;
FX_FLOAT m_fMinThumb;
IFWL_ScrollBar::Timer m_Timer;
-};
-
-class CFWL_ScrollBarImpDelegate : public CFWL_WidgetImpDelegate {
- public:
- CFWL_ScrollBarImpDelegate(IFWL_ScrollBar* pOwner);
- void OnProcessMessage(CFWL_Message* pMessage) override;
- void OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) override;
- protected:
+ private:
void OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy);
void OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy);
void OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy);
@@ -167,8 +159,6 @@ class CFWL_ScrollBarImpDelegate : public CFWL_WidgetImpDelegate {
FX_FLOAT fy);
void DoMouseLeave(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState);
void DoMouseHover(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState);
-
- IFWL_ScrollBar* m_pOwner;
};
#endif // XFA_FWL_CORE_IFWL_SCROLLBAR_H_
diff --git a/xfa/fwl/core/ifwl_spinbutton.cpp b/xfa/fwl/core/ifwl_spinbutton.cpp
index 81cff6722b..1ad5f0a969 100644
--- a/xfa/fwl/core/ifwl_spinbutton.cpp
+++ b/xfa/fwl/core/ifwl_spinbutton.cpp
@@ -37,8 +37,6 @@ IFWL_SpinButton::IFWL_SpinButton(const IFWL_App* app,
m_rtUpButton.Reset();
m_rtDnButton.Reset();
m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert;
-
- SetDelegate(pdfium::MakeUnique<CFWL_SpinButtonImpDelegate>(this));
}
IFWL_SpinButton::~IFWL_SpinButton() {}
@@ -98,43 +96,34 @@ FWL_Error IFWL_SpinButton::DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
if (!pGraphics)
return FWL_Error::Indefinite;
+
CFX_RectF rtClip(m_rtClient);
- if (pMatrix) {
+ if (pMatrix)
pMatrix->TransformRect(rtClip);
- }
+
IFWL_ThemeProvider* pTheme = GetAvailableTheme();
- if (HasBorder()) {
+ if (HasBorder())
DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
- }
- if (HasEdge()) {
+ if (HasEdge())
DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
- }
+
DrawUpButton(pGraphics, pTheme, pMatrix);
DrawDownButton(pGraphics, pTheme, pMatrix);
return FWL_Error::Succeeded;
}
FWL_Error IFWL_SpinButton::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) {
- if (bUp) {
- if (bEnable) {
- m_dwUpState = CFWL_PartState_Normal;
- } else {
- m_dwUpState = CFWL_PartState_Disabled;
- }
- } else {
- if (bEnable) {
- m_dwDnState = CFWL_PartState_Normal;
- } else {
- m_dwDnState = CFWL_PartState_Disabled;
- }
- }
+ if (bUp)
+ m_dwUpState = bEnable ? CFWL_PartState_Normal : CFWL_PartState_Disabled;
+ else
+ m_dwDnState = bEnable ? CFWL_PartState_Normal : CFWL_PartState_Disabled;
+
return FWL_Error::Succeeded;
}
FX_BOOL IFWL_SpinButton::IsButtonEnable(FX_BOOL bUp) {
- if (bUp) {
+ if (bUp)
return (m_dwUpState != CFWL_PartState_Disabled);
- }
return (m_dwDnState != CFWL_PartState_Disabled);
}
@@ -146,9 +135,9 @@ void IFWL_SpinButton::DrawUpButton(CFX_Graphics* pGraphics,
params.m_iPart = CFWL_Part::UpButton;
params.m_pGraphics = pGraphics;
params.m_dwStates = m_dwUpState + 1;
- if (pMatrix) {
+ if (pMatrix)
params.m_matrix.Concat(*pMatrix);
- }
+
params.m_rtPart = m_rtUpButton;
pTheme->DrawBackground(&params);
}
@@ -161,17 +150,14 @@ void IFWL_SpinButton::DrawDownButton(CFX_Graphics* pGraphics,
params.m_iPart = CFWL_Part::DownButton;
params.m_pGraphics = pGraphics;
params.m_dwStates = m_dwDnState + 1;
- if (pMatrix) {
+ if (pMatrix)
params.m_matrix.Concat(*pMatrix);
- }
+
params.m_rtPart = m_rtDnButton;
pTheme->DrawBackground(&params);
}
-CFWL_SpinButtonImpDelegate::CFWL_SpinButtonImpDelegate(IFWL_SpinButton* pOwner)
- : m_pOwner(pOwner) {}
-
-void CFWL_SpinButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+void IFWL_SpinButton::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage)
return;
@@ -188,22 +174,18 @@ void CFWL_SpinButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
case CFWL_MessageType::Mouse: {
CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
switch (pMsg->m_dwCmd) {
- case FWL_MouseCommand::LeftButtonDown: {
+ case FWL_MouseCommand::LeftButtonDown:
OnLButtonDown(pMsg);
break;
- }
- case FWL_MouseCommand::LeftButtonUp: {
+ case FWL_MouseCommand::LeftButtonUp:
OnLButtonUp(pMsg);
break;
- }
- case FWL_MouseCommand::Move: {
+ case FWL_MouseCommand::Move:
OnMouseMove(pMsg);
break;
- }
- case FWL_MouseCommand::Leave: {
+ case FWL_MouseCommand::Leave:
OnMouseLeave(pMsg);
break;
- }
default:
break;
}
@@ -215,192 +197,179 @@ void CFWL_SpinButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
OnKeyDown(pKey);
break;
}
- default: { break; }
+ default:
+ break;
}
- CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
+ IFWL_Widget::OnProcessMessage(pMessage);
}
-void CFWL_SpinButtonImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {}
-
-void CFWL_SpinButtonImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- m_pOwner->DrawWidget(pGraphics, pMatrix);
+void IFWL_SpinButton::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ DrawWidget(pGraphics, pMatrix);
}
-void CFWL_SpinButtonImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
- FX_BOOL bSet) {
- if (bSet) {
- m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused);
- } else {
- m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
- }
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+void IFWL_SpinButton::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
+ if (bSet)
+ m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused);
+ else
+ m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
+
+ Repaint(&m_rtClient);
}
-void CFWL_SpinButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
- m_pOwner->m_bLButtonDwn = TRUE;
- m_pOwner->SetGrab(TRUE);
- m_pOwner->SetFocus(TRUE);
- if (!m_pOwner->m_pProperties->m_pDataProvider)
+void IFWL_SpinButton::OnLButtonDown(CFWL_MsgMouse* pMsg) {
+ m_bLButtonDwn = TRUE;
+ SetGrab(TRUE);
+ SetFocus(TRUE);
+ if (!m_pProperties->m_pDataProvider)
return;
- FX_BOOL bUpPress = (m_pOwner->m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy) &&
- m_pOwner->IsButtonEnable(TRUE));
- FX_BOOL bDnPress = (m_pOwner->m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy) &&
- m_pOwner->IsButtonEnable(FALSE));
- if (!bUpPress && !bDnPress) {
+
+ FX_BOOL bUpPress =
+ (m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy) && IsButtonEnable(TRUE));
+ FX_BOOL bDnPress =
+ (m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy) && IsButtonEnable(FALSE));
+ if (!bUpPress && !bDnPress)
return;
- }
if (bUpPress) {
- m_pOwner->m_iButtonIndex = 0;
- m_pOwner->m_dwUpState = CFWL_PartState_Pressed;
+ m_iButtonIndex = 0;
+ m_dwUpState = CFWL_PartState_Pressed;
}
if (bDnPress) {
- m_pOwner->m_iButtonIndex = 1;
- m_pOwner->m_dwDnState = CFWL_PartState_Pressed;
+ m_iButtonIndex = 1;
+ m_dwDnState = CFWL_PartState_Pressed;
}
CFWL_EvtSpbClick wmPosChanged;
- wmPosChanged.m_pSrcTarget = m_pOwner;
+ wmPosChanged.m_pSrcTarget = this;
wmPosChanged.m_bUp = bUpPress;
- m_pOwner->DispatchEvent(&wmPosChanged);
- m_pOwner->Repaint(bUpPress ? &m_pOwner->m_rtUpButton
- : &m_pOwner->m_rtDnButton);
- m_pOwner->m_pTimerInfo = m_pOwner->m_Timer.StartTimer(kElapseTime, true);
+ DispatchEvent(&wmPosChanged);
+ Repaint(bUpPress ? &m_rtUpButton : &m_rtDnButton);
+ m_pTimerInfo = m_Timer.StartTimer(kElapseTime, true);
}
-void CFWL_SpinButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
- if (m_pOwner->m_pProperties->m_dwStates & CFWL_PartState_Disabled) {
+void IFWL_SpinButton::OnLButtonUp(CFWL_MsgMouse* pMsg) {
+ if (m_pProperties->m_dwStates & CFWL_PartState_Disabled)
return;
- }
- m_pOwner->m_bLButtonDwn = FALSE;
- m_pOwner->SetGrab(FALSE);
- m_pOwner->SetFocus(FALSE);
- if (m_pOwner->m_pTimerInfo) {
- m_pOwner->m_pTimerInfo->StopTimer();
- m_pOwner->m_pTimerInfo = nullptr;
+
+ m_bLButtonDwn = FALSE;
+ SetGrab(FALSE);
+ SetFocus(FALSE);
+ if (m_pTimerInfo) {
+ m_pTimerInfo->StopTimer();
+ m_pTimerInfo = nullptr;
}
FX_BOOL bRepaint = FALSE;
CFX_RectF rtInvalidate;
- if (m_pOwner->m_dwUpState == CFWL_PartState_Pressed &&
- m_pOwner->IsButtonEnable(TRUE)) {
- m_pOwner->m_dwUpState = CFWL_PartState_Normal;
+ if (m_dwUpState == CFWL_PartState_Pressed && IsButtonEnable(TRUE)) {
+ m_dwUpState = CFWL_PartState_Normal;
bRepaint = TRUE;
- rtInvalidate = m_pOwner->m_rtUpButton;
- } else if (m_pOwner->m_dwDnState == CFWL_PartState_Pressed &&
- m_pOwner->IsButtonEnable(FALSE)) {
- m_pOwner->m_dwDnState = CFWL_PartState_Normal;
+ rtInvalidate = m_rtUpButton;
+ } else if (m_dwDnState == CFWL_PartState_Pressed && IsButtonEnable(FALSE)) {
+ m_dwDnState = CFWL_PartState_Normal;
bRepaint = TRUE;
- rtInvalidate = m_pOwner->m_rtDnButton;
- }
- if (bRepaint) {
- m_pOwner->Repaint(&rtInvalidate);
+ rtInvalidate = m_rtDnButton;
}
+ if (bRepaint)
+ Repaint(&rtInvalidate);
}
-void CFWL_SpinButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
- if (!m_pOwner->m_pProperties->m_pDataProvider)
+void IFWL_SpinButton::OnMouseMove(CFWL_MsgMouse* pMsg) {
+ if (!m_pProperties->m_pDataProvider)
return;
- if (m_pOwner->m_bLButtonDwn) {
+ if (m_bLButtonDwn)
return;
- }
+
FX_BOOL bRepaint = FALSE;
CFX_RectF rtInvlidate;
rtInvlidate.Reset();
- if (m_pOwner->m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if (m_pOwner->IsButtonEnable(TRUE)) {
- if (m_pOwner->m_dwUpState == CFWL_PartState_Hovered) {
- m_pOwner->m_dwUpState = CFWL_PartState_Hovered;
+ if (m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if (IsButtonEnable(TRUE)) {
+ if (m_dwUpState == CFWL_PartState_Hovered) {
+ m_dwUpState = CFWL_PartState_Hovered;
bRepaint = TRUE;
- rtInvlidate = m_pOwner->m_rtUpButton;
+ rtInvlidate = m_rtUpButton;
}
- if (m_pOwner->m_dwDnState != CFWL_PartState_Normal &&
- m_pOwner->IsButtonEnable(FALSE)) {
- m_pOwner->m_dwDnState = CFWL_PartState_Normal;
- if (bRepaint) {
- rtInvlidate.Union(m_pOwner->m_rtDnButton);
- } else {
- rtInvlidate = m_pOwner->m_rtDnButton;
- }
+ if (m_dwDnState != CFWL_PartState_Normal && IsButtonEnable(FALSE)) {
+ m_dwDnState = CFWL_PartState_Normal;
+ if (bRepaint)
+ rtInvlidate.Union(m_rtDnButton);
+ else
+ rtInvlidate = m_rtDnButton;
+
bRepaint = TRUE;
}
}
- if (!m_pOwner->IsButtonEnable(FALSE)) {
- m_pOwner->EnableButton(FALSE, FALSE);
- }
- } else if (m_pOwner->m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy)) {
- if (m_pOwner->IsButtonEnable(FALSE)) {
- if (m_pOwner->m_dwDnState != CFWL_PartState_Hovered) {
- m_pOwner->m_dwDnState = CFWL_PartState_Hovered;
+ if (!IsButtonEnable(FALSE))
+ EnableButton(FALSE, FALSE);
+
+ } else if (m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy)) {
+ if (IsButtonEnable(FALSE)) {
+ if (m_dwDnState != CFWL_PartState_Hovered) {
+ m_dwDnState = CFWL_PartState_Hovered;
bRepaint = TRUE;
- rtInvlidate = m_pOwner->m_rtDnButton;
+ rtInvlidate = m_rtDnButton;
}
- if (m_pOwner->m_dwUpState != CFWL_PartState_Normal &&
- m_pOwner->IsButtonEnable(TRUE)) {
- m_pOwner->m_dwUpState = CFWL_PartState_Normal;
- if (bRepaint) {
- rtInvlidate.Union(m_pOwner->m_rtUpButton);
- } else {
- rtInvlidate = m_pOwner->m_rtUpButton;
- }
+ if (m_dwUpState != CFWL_PartState_Normal && IsButtonEnable(TRUE)) {
+ m_dwUpState = CFWL_PartState_Normal;
+ if (bRepaint)
+ rtInvlidate.Union(m_rtUpButton);
+ else
+ rtInvlidate = m_rtUpButton;
bRepaint = TRUE;
}
}
- } else if (m_pOwner->m_dwUpState != CFWL_PartState_Normal ||
- m_pOwner->m_dwDnState != CFWL_PartState_Normal) {
- if (m_pOwner->m_dwUpState != CFWL_PartState_Normal) {
- m_pOwner->m_dwUpState = CFWL_PartState_Normal;
+ } else if (m_dwUpState != CFWL_PartState_Normal ||
+ m_dwDnState != CFWL_PartState_Normal) {
+ if (m_dwUpState != CFWL_PartState_Normal) {
+ m_dwUpState = CFWL_PartState_Normal;
bRepaint = TRUE;
- rtInvlidate = m_pOwner->m_rtUpButton;
+ rtInvlidate = m_rtUpButton;
}
- if (m_pOwner->m_dwDnState != CFWL_PartState_Normal) {
- m_pOwner->m_dwDnState = CFWL_PartState_Normal;
- if (bRepaint) {
- rtInvlidate.Union(m_pOwner->m_rtDnButton);
- } else {
- rtInvlidate = m_pOwner->m_rtDnButton;
- }
+ if (m_dwDnState != CFWL_PartState_Normal) {
+ m_dwDnState = CFWL_PartState_Normal;
+ if (bRepaint)
+ rtInvlidate.Union(m_rtDnButton);
+ else
+ rtInvlidate = m_rtDnButton;
+
bRepaint = TRUE;
}
}
- if (bRepaint) {
- m_pOwner->Repaint(&rtInvlidate);
- }
+ if (bRepaint)
+ Repaint(&rtInvlidate);
}
-void CFWL_SpinButtonImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
+void IFWL_SpinButton::OnMouseLeave(CFWL_MsgMouse* pMsg) {
if (!pMsg)
return;
- if (m_pOwner->m_dwUpState != CFWL_PartState_Normal &&
- m_pOwner->IsButtonEnable(TRUE)) {
- m_pOwner->m_dwUpState = CFWL_PartState_Normal;
- }
- if (m_pOwner->m_dwDnState != CFWL_PartState_Normal &&
- m_pOwner->IsButtonEnable(FALSE)) {
- m_pOwner->m_dwDnState = CFWL_PartState_Normal;
- }
- m_pOwner->Repaint(&m_pOwner->m_rtClient);
+ if (m_dwUpState != CFWL_PartState_Normal && IsButtonEnable(TRUE))
+ m_dwUpState = CFWL_PartState_Normal;
+ if (m_dwDnState != CFWL_PartState_Normal && IsButtonEnable(FALSE))
+ m_dwDnState = CFWL_PartState_Normal;
+
+ Repaint(&m_rtClient);
}
-void CFWL_SpinButtonImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) {
- if (!m_pOwner->m_pProperties->m_pDataProvider)
+void IFWL_SpinButton::OnKeyDown(CFWL_MsgKey* pMsg) {
+ if (!m_pProperties->m_pDataProvider)
return;
+
FX_BOOL bUp =
pMsg->m_dwKeyCode == FWL_VKEY_Up || pMsg->m_dwKeyCode == FWL_VKEY_Left;
FX_BOOL bDown =
pMsg->m_dwKeyCode == FWL_VKEY_Down || pMsg->m_dwKeyCode == FWL_VKEY_Right;
- if (!bUp && !bDown) {
+ if (!bUp && !bDown)
return;
- }
- FX_BOOL bUpEnable = m_pOwner->IsButtonEnable(TRUE);
- FX_BOOL bDownEnable = m_pOwner->IsButtonEnable(FALSE);
- if (!bUpEnable && !bDownEnable) {
+
+ FX_BOOL bUpEnable = IsButtonEnable(TRUE);
+ FX_BOOL bDownEnable = IsButtonEnable(FALSE);
+ if (!bUpEnable && !bDownEnable)
return;
- }
+
CFWL_EvtSpbClick wmPosChanged;
- wmPosChanged.m_pSrcTarget = m_pOwner;
+ wmPosChanged.m_pSrcTarget = this;
wmPosChanged.m_bUp = bUpEnable;
- m_pOwner->DispatchEvent(&wmPosChanged);
- m_pOwner->Repaint(bUpEnable ? &m_pOwner->m_rtUpButton
- : &m_pOwner->m_rtDnButton);
+ DispatchEvent(&wmPosChanged);
+ Repaint(bUpEnable ? &m_rtUpButton : &m_rtDnButton);
}
IFWL_SpinButton::Timer::Timer(IFWL_SpinButton* pToolTip)
diff --git a/xfa/fwl/core/ifwl_spinbutton.h b/xfa/fwl/core/ifwl_spinbutton.h
index 5bbd7fb23e..5a6b15628e 100644
--- a/xfa/fwl/core/ifwl_spinbutton.h
+++ b/xfa/fwl/core/ifwl_spinbutton.h
@@ -15,7 +15,6 @@
#define FWL_STYLEEXE_SPB_Vert (1L << 0)
class CFWL_MsgMouse;
-class CFWL_SpinButtonImpDelegate;
class CFWL_WidgetImpProperties;
FWL_EVENT_DEF(CFWL_EvtSpbClick, CFWL_EventType::Click, FX_BOOL m_bUp;)
@@ -33,13 +32,15 @@ class IFWL_SpinButton : public IFWL_Widget {
FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override;
FWL_Error DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = nullptr) override;
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessEvent(CFWL_Event* pEvent) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) override;
FWL_Error EnableButton(FX_BOOL bEnable, FX_BOOL bUp = TRUE);
FX_BOOL IsButtonEnable(FX_BOOL bUp = TRUE);
protected:
- friend class CFWL_SpinButtonImpDelegate;
-
class Timer : public IFWL_Timer {
public:
explicit Timer(IFWL_SpinButton* pToolTip);
@@ -65,24 +66,14 @@ class IFWL_SpinButton : public IFWL_Widget {
FX_BOOL m_bLButtonDwn;
IFWL_TimerInfo* m_pTimerInfo;
IFWL_SpinButton::Timer m_Timer;
-};
-class CFWL_SpinButtonImpDelegate : public CFWL_WidgetImpDelegate {
- public:
- CFWL_SpinButtonImpDelegate(IFWL_SpinButton* pOwner);
- void OnProcessMessage(CFWL_Message* pMessage) override;
- void OnProcessEvent(CFWL_Event* pEvent) override;
- void OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) override;
-
- protected:
- void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ private:
+ void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet);
void OnLButtonDown(CFWL_MsgMouse* pMsg);
void OnLButtonUp(CFWL_MsgMouse* pMsg);
void OnMouseMove(CFWL_MsgMouse* pMsg);
void OnMouseLeave(CFWL_MsgMouse* pMsg);
void OnKeyDown(CFWL_MsgKey* pMsg);
- IFWL_SpinButton* m_pOwner;
};
#endif // XFA_FWL_CORE_IFWL_SPINBUTTON_H_
diff --git a/xfa/fwl/core/ifwl_tooltip.cpp b/xfa/fwl/core/ifwl_tooltip.cpp
index 371709772e..200cf7adab 100644
--- a/xfa/fwl/core/ifwl_tooltip.cpp
+++ b/xfa/fwl/core/ifwl_tooltip.cpp
@@ -32,8 +32,6 @@ IFWL_ToolTip::IFWL_ToolTip(const IFWL_App* app,
m_rtAnchor.Set(0, 0, 0, 0);
m_pProperties->m_dwStyles &= ~FWL_WGTSTYLE_Child;
m_pProperties->m_dwStyles |= FWL_WGTSTYLE_Popup;
-
- SetDelegate(pdfium::MakeUnique<CFWL_ToolTipImpDelegate>(this));
}
IFWL_ToolTip::~IFWL_ToolTip() {}
@@ -228,6 +226,11 @@ void IFWL_ToolTip::RefreshToolTipPos() {
}
}
+void IFWL_ToolTip::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {
+ DrawWidget(pGraphics, pMatrix);
+}
+
IFWL_ToolTip::Timer::Timer(IFWL_ToolTip* pToolTip) : IFWL_Timer(pToolTip) {}
void IFWL_ToolTip::Timer::Run(IFWL_TimerInfo* pTimerInfo) {
@@ -248,17 +251,3 @@ void IFWL_ToolTip::Timer::Run(IFWL_TimerInfo* pTimerInfo) {
pToolTip->m_pTimerInfoHide = nullptr;
}
}
-
-CFWL_ToolTipImpDelegate::CFWL_ToolTipImpDelegate(IFWL_ToolTip* pOwner)
- : m_pOwner(pOwner) {}
-
-void CFWL_ToolTipImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
- CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
-}
-
-void CFWL_ToolTipImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {}
-
-void CFWL_ToolTipImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- m_pOwner->DrawWidget(pGraphics, pMatrix);
-}
diff --git a/xfa/fwl/core/ifwl_tooltip.h b/xfa/fwl/core/ifwl_tooltip.h
index 63708a7f5a..0293759165 100644
--- a/xfa/fwl/core/ifwl_tooltip.h
+++ b/xfa/fwl/core/ifwl_tooltip.h
@@ -47,14 +47,14 @@ class IFWL_ToolTip : public IFWL_Form {
const CFX_Matrix* pMatrix = nullptr) override;
void SetStates(uint32_t dwStates, FX_BOOL bSet) override;
FWL_Error GetClientRect(CFX_RectF& rect) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) override;
void SetAnchor(const CFX_RectF& rtAnchor);
void Show();
void Hide();
protected:
- friend class CFWL_ToolTipImpDelegate;
-
class Timer : public IFWL_Timer {
public:
explicit Timer(IFWL_ToolTip* pToolTip);
@@ -83,24 +83,14 @@ class IFWL_ToolTip : public IFWL_Form {
IFWL_TimerInfo* m_pTimerInfoHide;
IFWL_ToolTip::Timer m_TimerShow;
IFWL_ToolTip::Timer m_TimerHide;
-};
-class CFWL_ToolTipImpDelegate : public CFWL_WidgetImpDelegate {
- public:
- CFWL_ToolTipImpDelegate(IFWL_ToolTip* pOwner);
- void OnProcessMessage(CFWL_Message* pMessage) override;
- void OnProcessEvent(CFWL_Event* pEvent) override;
- void OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) override;
-
- protected:
- void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
+ private:
+ void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet);
void OnLButtonDown(CFWL_MsgMouse* pMsg);
void OnLButtonUp(CFWL_MsgMouse* pMsg);
void OnMouseMove(CFWL_MsgMouse* pMsg);
void OnMouseLeave(CFWL_MsgMouse* pMsg);
void OnKeyDown(CFWL_MsgKey* pMsg);
- IFWL_ToolTip* m_pOwner;
};
#endif // XFA_FWL_CORE_IFWL_TOOLTIP_H_
diff --git a/xfa/fwl/core/ifwl_widget.cpp b/xfa/fwl/core/ifwl_widget.cpp
index 961c02497b..f57d0a11c7 100644
--- a/xfa/fwl/core/ifwl_widget.cpp
+++ b/xfa/fwl/core/ifwl_widget.cpp
@@ -30,12 +30,12 @@ IFWL_Widget::IFWL_Widget(const IFWL_App* app,
: m_pOwnerApp(app),
m_pWidgetMgr(app->GetWidgetMgr()),
m_pProperties(new CFWL_WidgetImpProperties(properties)),
- m_pCurDelegate(nullptr),
m_pOuter(pOuter),
m_pLayoutItem(nullptr),
m_pAssociate(nullptr),
m_iLock(0),
- m_nEventKey(0) {
+ m_nEventKey(0),
+ m_pDelegate(nullptr) {
ASSERT(m_pWidgetMgr);
IFWL_Widget* pParent = m_pProperties->m_pParent;
@@ -97,7 +97,7 @@ FWL_Error IFWL_Widget::SetWidgetRect(const CFX_RectF& rect) {
ev.m_rtOld = rtOld;
ev.m_rtNew = rect;
- if (IFWL_WidgetDelegate* pDelegate = GetCurrentDelegate())
+ if (IFWL_WidgetDelegate* pDelegate = GetDelegate())
pDelegate->OnProcessEvent(&ev);
}
return FWL_Error::Succeeded;
@@ -348,16 +348,6 @@ FWL_Error IFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
return FWL_Error::Succeeded;
}
-IFWL_WidgetDelegate* IFWL_Widget::GetCurrentDelegate() {
- if (!m_pCurDelegate)
- m_pCurDelegate = m_pDelegate.get();
- return m_pCurDelegate;
-}
-
-void IFWL_Widget::SetCurrentDelegate(IFWL_WidgetDelegate* pDelegate) {
- m_pCurDelegate = pDelegate;
-}
-
const IFWL_App* IFWL_Widget::GetOwnerApp() const {
return m_pOwnerApp;
}
@@ -720,7 +710,7 @@ void IFWL_Widget::DispatchKeyEvent(CFWL_MsgKey* pNote) {
void IFWL_Widget::DispatchEvent(CFWL_Event* pEvent) {
if (m_pOuter) {
- m_pOuter->GetCurrentDelegate()->OnProcessEvent(pEvent);
+ m_pOuter->GetDelegate()->OnProcessEvent(pEvent);
return;
}
const IFWL_App* pApp = GetOwnerApp();
@@ -838,9 +828,7 @@ FX_BOOL IFWL_Widget::IsParent(IFWL_Widget* pParent) {
return FALSE;
}
-CFWL_WidgetImpDelegate::CFWL_WidgetImpDelegate() {}
-
-void CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
+void IFWL_Widget::OnProcessMessage(CFWL_Message* pMessage) {
if (!pMessage->m_pDstTarget)
return;
@@ -908,10 +896,7 @@ void CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
}
}
-void CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {}
+void IFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {}
-void CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix) {
- CFWL_EvtDraw evt;
- evt.m_pGraphics = pGraphics;
-}
+void IFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) {}
diff --git a/xfa/fwl/core/ifwl_widget.h b/xfa/fwl/core/ifwl_widget.h
index 264ff67513..0c8cef1adc 100644
--- a/xfa/fwl/core/ifwl_widget.h
+++ b/xfa/fwl/core/ifwl_widget.h
@@ -62,9 +62,9 @@ class IFWL_ThemeProvider;
class IFWL_Widget;
enum class FWL_Type;
-class IFWL_Widget {
+class IFWL_Widget : public IFWL_WidgetDelegate {
public:
- virtual ~IFWL_Widget();
+ ~IFWL_Widget() override;
virtual FWL_Type GetClassID() const = 0;
virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
@@ -112,8 +112,19 @@ class IFWL_Widget {
virtual IFWL_ThemeProvider* GetThemeProvider();
virtual FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
- IFWL_WidgetDelegate* GetCurrentDelegate();
- void SetCurrentDelegate(IFWL_WidgetDelegate* pDelegate);
+ void SetDelegate(IFWL_WidgetDelegate* delegate) { m_pDelegate = delegate; }
+ IFWL_WidgetDelegate* GetDelegate() {
+ return m_pDelegate ? m_pDelegate : this;
+ }
+ const IFWL_WidgetDelegate* GetDelegate() const {
+ return m_pDelegate ? m_pDelegate : this;
+ }
+
+ // IFWL_WidgetDelegate.
+ void OnProcessMessage(CFWL_Message* pMessage) override;
+ void OnProcessEvent(CFWL_Event* pEvent) override;
+ void OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) override;
const IFWL_App* GetOwnerApp() const;
@@ -127,6 +138,9 @@ class IFWL_Widget {
void SetAssociateWidget(CFWL_Widget* pAssociate);
+ void SetFocus(FX_BOOL bFocus);
+ void Repaint(const CFX_RectF* pRect = nullptr);
+
protected:
friend class CFWL_WidgetImpDelegate;
@@ -160,7 +174,6 @@ class IFWL_Widget {
uint32_t 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,
@@ -184,7 +197,6 @@ class IFWL_Widget {
void UnregisterEventTarget();
void DispatchKeyEvent(CFWL_MsgKey* pNote);
void DispatchEvent(CFWL_Event* pEvent);
- void Repaint(const CFX_RectF* pRect = nullptr);
void DrawBackground(CFX_Graphics* pGraphics,
CFWL_Part iPartBk,
IFWL_ThemeProvider* pTheme,
@@ -201,15 +213,9 @@ class IFWL_Widget {
FX_BOOL IsParent(IFWL_Widget* pParent);
- void SetDelegate(std::unique_ptr<IFWL_WidgetDelegate> delegate) {
- m_pDelegate = std::move(delegate);
- }
- IFWL_WidgetDelegate* GetDelegate() const { return m_pDelegate.get(); }
-
const IFWL_App* const m_pOwnerApp;
CFWL_WidgetMgr* const m_pWidgetMgr;
std::unique_ptr<CFWL_WidgetImpProperties> m_pProperties;
- IFWL_WidgetDelegate* m_pCurDelegate; // Not owned.
IFWL_Widget* m_pOuter;
void* m_pLayoutItem;
CFWL_Widget* m_pAssociate;
@@ -217,17 +223,7 @@ class IFWL_Widget {
uint32_t m_nEventKey;
private:
- std::unique_ptr<IFWL_WidgetDelegate> m_pDelegate;
-};
-
-class CFWL_WidgetImpDelegate : public IFWL_WidgetDelegate {
- public:
- CFWL_WidgetImpDelegate();
- ~CFWL_WidgetImpDelegate() override {}
- void OnProcessMessage(CFWL_Message* pMessage) override;
- void OnProcessEvent(CFWL_Event* pEvent) override;
- void OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = nullptr) override;
+ IFWL_WidgetDelegate* m_pDelegate; // Not owned.
};
#endif // XFA_FWL_CORE_IFWL_WIDGET_H_
diff --git a/xfa/fxfa/app/xfa_ffbarcode.cpp b/xfa/fxfa/app/xfa_ffbarcode.cpp
index cd172c5a4d..181b3be80c 100644
--- a/xfa/fxfa/app/xfa_ffbarcode.cpp
+++ b/xfa/fxfa/app/xfa_ffbarcode.cpp
@@ -132,8 +132,8 @@ FX_BOOL CXFA_FFBarcode::LoadWidget() {
CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pWidget, pWidget);
- m_pOldDelegate = m_pNormalWidget->GetCurrentDelegate();
- m_pNormalWidget->SetCurrentDelegate(this);
+ m_pOldDelegate = m_pNormalWidget->GetDelegate();
+ m_pNormalWidget->SetDelegate(this);
m_pNormalWidget->LockUpdate();
CFX_WideString wsText;
diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp
index 9dfb12fa78..9365ccf0a4 100644
--- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp
+++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp
@@ -36,8 +36,8 @@ FX_BOOL CXFA_FFCheckButton::LoadWidget() {
CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pWidget, pWidget);
- m_pOldDelegate = m_pNormalWidget->GetCurrentDelegate();
- m_pNormalWidget->SetCurrentDelegate(this);
+ m_pOldDelegate = m_pNormalWidget->GetDelegate();
+ m_pNormalWidget->SetDelegate(this);
if (m_pDataAcc->IsRadioButton())
pCheckBox->ModifyStylesEx(FWL_STYLEEXT_CKB_RadioButton, 0xFFFFFFFF);
diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp
index 06bbc38eb9..1575889815 100644
--- a/xfa/fxfa/app/xfa_ffchoicelist.cpp
+++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp
@@ -43,8 +43,8 @@ FX_BOOL CXFA_FFListBox::LoadWidget() {
CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pWidget, pWidget);
- m_pOldDelegate = m_pNormalWidget->GetCurrentDelegate();
- m_pNormalWidget->SetCurrentDelegate(this);
+ m_pOldDelegate = m_pNormalWidget->GetDelegate();
+ m_pNormalWidget->SetDelegate(this);
m_pNormalWidget->LockUpdate();
CFX_WideStringArray wsLabelArray;
@@ -242,8 +242,8 @@ FX_BOOL CXFA_FFComboBox::LoadWidget() {
CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pWidget, pWidget);
- m_pOldDelegate = m_pNormalWidget->GetCurrentDelegate();
- m_pNormalWidget->SetCurrentDelegate(this);
+ m_pOldDelegate = m_pNormalWidget->GetDelegate();
+ m_pNormalWidget->SetDelegate(this);
m_pNormalWidget->LockUpdate();
CFX_WideStringArray wsLabelArray;
diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/xfa_ffimageedit.cpp
index 9e29119671..4b77ccf73d 100644
--- a/xfa/fxfa/app/xfa_ffimageedit.cpp
+++ b/xfa/fxfa/app/xfa_ffimageedit.cpp
@@ -32,8 +32,8 @@ FX_BOOL CXFA_FFImageEdit::LoadWidget() {
CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pWidget, pWidget);
- m_pOldDelegate = pPictureBox->GetCurrentDelegate();
- pPictureBox->SetCurrentDelegate(this);
+ m_pOldDelegate = pPictureBox->GetDelegate();
+ pPictureBox->SetDelegate(this);
CXFA_FFField::LoadWidget();
if (m_pDataAcc->GetImageEditImage()) {
diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp
index e648581011..2439eae78f 100644
--- a/xfa/fxfa/app/xfa_ffpushbutton.cpp
+++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp
@@ -55,8 +55,8 @@ FX_BOOL CXFA_FFPushButton::LoadWidget() {
CFWL_PushButton* pPushButton = new CFWL_PushButton(GetFWLApp());
pPushButton->Initialize();
- m_pOldDelegate = pPushButton->GetCurrentDelegate();
- pPushButton->SetCurrentDelegate(this);
+ m_pOldDelegate = pPushButton->GetDelegate();
+ pPushButton->SetDelegate(this);
m_pNormalWidget = pPushButton;
m_pNormalWidget->SetLayoutItem(this);
diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp
index e268f1c4ec..ffbcac1e17 100644
--- a/xfa/fxfa/app/xfa_fftextedit.cpp
+++ b/xfa/fxfa/app/xfa_fftextedit.cpp
@@ -46,8 +46,8 @@ FX_BOOL CXFA_FFTextEdit::LoadWidget() {
CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pWidget, pWidget);
- m_pOldDelegate = m_pNormalWidget->GetCurrentDelegate();
- m_pNormalWidget->SetCurrentDelegate(this);
+ m_pOldDelegate = m_pNormalWidget->GetDelegate();
+ m_pNormalWidget->SetDelegate(this);
m_pNormalWidget->LockUpdate();
UpdateWidgetProperty();
@@ -451,8 +451,8 @@ FX_BOOL CXFA_FFNumericEdit::LoadWidget() {
CFWL_NoteDriver* pNoteDriver = pIWidget->GetOwnerApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pIWidget, pIWidget);
- m_pOldDelegate = m_pNormalWidget->GetCurrentDelegate();
- m_pNormalWidget->SetCurrentDelegate(this);
+ m_pOldDelegate = m_pNormalWidget->GetDelegate();
+ m_pNormalWidget->SetDelegate(this);
m_pNormalWidget->LockUpdate();
CFX_WideString wsText;
@@ -531,8 +531,8 @@ FX_BOOL CXFA_FFPasswordEdit::LoadWidget() {
CFWL_NoteDriver* pNoteDriver = pIWidget->GetOwnerApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pIWidget, pIWidget);
- m_pOldDelegate = m_pNormalWidget->GetCurrentDelegate();
- m_pNormalWidget->SetCurrentDelegate(this);
+ m_pOldDelegate = m_pNormalWidget->GetDelegate();
+ m_pNormalWidget->SetDelegate(this);
m_pNormalWidget->LockUpdate();
CFX_WideString wsText;
@@ -600,8 +600,8 @@ FX_BOOL CXFA_FFDateTimeEdit::LoadWidget() {
CFWL_NoteDriver* pNoteDriver = pIWidget->GetOwnerApp()->GetNoteDriver();
pNoteDriver->RegisterEventTarget(pIWidget, pIWidget);
- m_pOldDelegate = m_pNormalWidget->GetCurrentDelegate();
- m_pNormalWidget->SetCurrentDelegate(this);
+ m_pOldDelegate = m_pNormalWidget->GetDelegate();
+ m_pNormalWidget->SetDelegate(this);
m_pNormalWidget->LockUpdate();
CFX_WideString wsText;