diff options
author | dsinclair <dsinclair@chromium.org> | 2016-04-21 13:12:06 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-21 13:12:06 -0700 |
commit | 5d9da0c1255a75dd9b7b2005f8b7d6ae4948feaf (patch) | |
tree | df40bedc2582cab695e7bf4b2056bfddd4969908 | |
parent | 0f6425fff33e4096b4e1fbfb954edae1349c0145 (diff) | |
download | pdfium-5d9da0c1255a75dd9b7b2005f8b7d6ae4948feaf.tar.xz |
Remove CFWL_Note.
This CL removes the CFWL_Note class. The two subclasses, CFWL_Event and
CFWL_Message are distinct types and should not be related by the subclass. The
code has been updated to pass the correct types as needed.
The various FWL_EVTHASH and FWL_MSGHASH defines have all been removed and turned
into an FWL_EventType and FWL_MessageType enum classes.
BUG=pdfium:474
Review URL: https://codereview.chromium.org/1901183002
32 files changed, 623 insertions, 540 deletions
@@ -42,9 +42,7 @@ config("pdfium_config") { } if (is_win) { - cflags += [ - "/wd4267", - ] + cflags += [ "/wd4267" ] } if (is_clang || is_posix) { @@ -1023,7 +1021,6 @@ if (pdf_enable_xfa) { "xfa/fwl/basewidget/ifwl_tooltip.h", "xfa/fwl/core/cfwl_event.h", "xfa/fwl/core/cfwl_message.h", - "xfa/fwl/core/cfwl_note.h", "xfa/fwl/core/cfwl_themebackground.h", "xfa/fwl/core/cfwl_themepart.h", "xfa/fwl/core/cfwl_themetext.h", @@ -173,7 +173,6 @@ "xfa/fwl/basewidget/ifwl_spinbutton.h", "xfa/fwl/basewidget/ifwl_tooltip.h", "xfa/fwl/core/cfwl_event.h", - "xfa/fwl/core/cfwl_note.h", "xfa/fwl/core/cfwl_message.h", "xfa/fwl/core/cfwl_themebackground.h", "xfa/fwl/core/cfwl_themepart.h", diff --git a/xfa/fwl/basewidget/fwl_barcodeimp.cpp b/xfa/fwl/basewidget/fwl_barcodeimp.cpp index 8238d6af04..cc0bd62257 100644 --- a/xfa/fwl/basewidget/fwl_barcodeimp.cpp +++ b/xfa/fwl/basewidget/fwl_barcodeimp.cpp @@ -217,11 +217,12 @@ FX_BOOL CFWL_BarcodeImp::IsProtectedType() { } return FALSE; } + CFWL_BarcodeImpDelegate::CFWL_BarcodeImpDelegate(CFWL_BarcodeImp* pOwner) : CFWL_EditImpDelegate(pOwner) {} + FWL_ERR CFWL_BarcodeImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { - uint32_t dwFlag = pEvent->GetClassID(); - if (dwFlag == FWL_EVTHASH_EDT_TextChanged) { + if (pEvent->GetClassID() == CFWL_EventType::TextChanged) { CFWL_BarcodeImp* pOwner = static_cast<CFWL_BarcodeImp*>(m_pOwner); pOwner->ReleaseBarcodeEngine(); pOwner->m_dwStatus = XFA_BCS_NeedUpdate; diff --git a/xfa/fwl/basewidget/fwl_checkboximp.cpp b/xfa/fwl/basewidget/fwl_checkboximp.cpp index 9ed2f0b8ed..e511b8e444 100644 --- a/xfa/fwl/basewidget/fwl_checkboximp.cpp +++ b/xfa/fwl/basewidget/fwl_checkboximp.cpp @@ -409,22 +409,26 @@ void CFWL_CheckBoxImp::NextStates() { } CFWL_CheckBoxImpDelegate::CFWL_CheckBoxImpDelegate(CFWL_CheckBoxImp* pOwner) : m_pOwner(pOwner) {} + int32_t CFWL_CheckBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { if (!pMessage) return 0; - uint32_t dwMsgCode = pMessage->GetClassID(); + int32_t iRet = 1; - switch (dwMsgCode) { - case FWL_MSGHASH_Activate: { + switch (pMessage->GetClassID()) { + case CFWL_MessageType::Activate: { OnActivate(pMessage); break; } - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { - OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); + case CFWL_MessageType::SetFocus: { + OnFocusChanged(pMessage, TRUE); break; } - case FWL_MSGHASH_Mouse: { + case CFWL_MessageType::KillFocus: { + OnFocusChanged(pMessage, FALSE); + break; + } + case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); uint32_t dwCmd = pMsg->m_dwCmd; switch (dwCmd) { @@ -444,19 +448,23 @@ int32_t CFWL_CheckBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { OnMouseLeave(pMsg); break; } - default: {} + default: + break; } break; } - case FWL_MSGHASH_Key: { + case CFWL_MessageType::Key: { CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); - if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) { + if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) OnKeyDown(pKey); - } break; } - default: { iRet = 0; } + default: { + iRet = 0; + break; + } } + CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); return iRet; } diff --git a/xfa/fwl/basewidget/fwl_comboboximp.cpp b/xfa/fwl/basewidget/fwl_comboboximp.cpp index b093b6c171..d7fe209e16 100644 --- a/xfa/fwl/basewidget/fwl_comboboximp.cpp +++ b/xfa/fwl/basewidget/fwl_comboboximp.cpp @@ -141,23 +141,24 @@ CFWL_ComboEditImp::CFWL_ComboEditImp(const CFWL_WidgetImpProperties& properties, CFWL_ComboEditImpDelegate::CFWL_ComboEditImpDelegate(CFWL_ComboEditImp* pOwner) : CFWL_EditImpDelegate(pOwner), m_pOwner(pOwner) {} + int32_t CFWL_ComboEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { if (!pMessage) return 0; - uint32_t dwMsgCode = pMessage->GetClassID(); + FX_BOOL backDefault = TRUE; - switch (dwMsgCode) { - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { - if (dwMsgCode == FWL_MSGHASH_SetFocus) { - m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; - } else { - m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; - } + switch (pMessage->GetClassID()) { + case CFWL_MessageType::SetFocus: { + m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; + backDefault = FALSE; + break; + } + case CFWL_MessageType::KillFocus: { + m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; backDefault = FALSE; break; } - case FWL_MSGHASH_Mouse: { + case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); if ((pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown) && ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)) { @@ -166,13 +167,14 @@ int32_t CFWL_ComboEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { } break; } - default: {} + default: + break; } - if (!backDefault) { + if (!backDefault) return 1; - } return CFWL_EditImpDelegate::OnProcessMessage(pMessage); } + void CFWL_ComboEditImp::ClearSelected() { ClearSelections(); Repaint(&m_rtClient); @@ -281,17 +283,20 @@ void CFWL_ComboListImp::ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy) { void CFWL_ComboListImp::SetFocus(FX_BOOL bSet) { CFWL_WidgetImp::SetFocus(bSet); } + CFWL_ComboListImpDelegate::CFWL_ComboListImpDelegate(CFWL_ComboListImp* pOwner) : CFWL_ListBoxImpDelegate(pOwner), m_pOwner(pOwner) {} + int32_t CFWL_ComboListImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { if (!pMessage) return 0; - uint32_t dwHashCode = pMessage->GetClassID(); + + CFWL_MessageType dwHashCode = pMessage->GetClassID(); FX_BOOL backDefault = TRUE; - if (dwHashCode == FWL_MSGHASH_SetFocus || - dwHashCode == FWL_MSGHASH_KillFocus) { - OnDropListFocusChanged(pMessage, dwHashCode == FWL_MSGHASH_SetFocus); - } else if (dwHashCode == FWL_MSGHASH_Mouse) { + if (dwHashCode == CFWL_MessageType::SetFocus || + dwHashCode == CFWL_MessageType::KillFocus) { + 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) { CFX_RectF rect; @@ -323,14 +328,14 @@ int32_t CFWL_ComboListImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { } default: {} } - } else if (dwHashCode == FWL_MSGHASH_Key) { + } else if (dwHashCode == CFWL_MessageType::Key) { backDefault = !OnDropListKey(static_cast<CFWL_MsgKey*>(pMessage)); } - if (!backDefault) { + if (!backDefault) return 1; - } return CFWL_ListBoxImpDelegate::OnProcessMessage(pMessage); } + void CFWL_ComboListImpDelegate::OnDropListFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { if (!bSet) { @@ -1356,26 +1361,30 @@ void CFWL_ComboBoxImp::DisForm_Layout() { m_pEdit->Update(); } } + CFWL_ComboBoxImpDelegate::CFWL_ComboBoxImpDelegate(CFWL_ComboBoxImp* pOwner) : m_pOwner(pOwner) {} + int32_t CFWL_ComboBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { - if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { + if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) return DisForm_OnProcessMessage(pMessage); - } + if (!pMessage) return 0; - uint32_t dwMsgCode = pMessage->GetClassID(); + FX_BOOL iRet = 1; - switch (dwMsgCode) { - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { - OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); + switch (pMessage->GetClassID()) { + case CFWL_MessageType::SetFocus: { + OnFocusChanged(pMessage, TRUE); + break; + } + case CFWL_MessageType::KillFocus: { + OnFocusChanged(pMessage, FALSE); break; } - case FWL_MSGHASH_Mouse: { + case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - uint32_t dwCmd = pMsg->m_dwCmd; - switch (dwCmd) { + switch (pMsg->m_dwCmd) { case FWL_MSGMOUSECMD_LButtonDown: { OnLButtonDown(pMsg); break; @@ -1392,22 +1401,28 @@ int32_t CFWL_ComboBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { OnMouseLeave(pMsg); break; } - default: {} + default: + break; } break; } - case FWL_MSGHASH_Key: { + case CFWL_MessageType::Key: { OnKey(static_cast<CFWL_MsgKey*>(pMessage)); break; } - default: { iRet = 0; } + default: { + iRet = 0; + break; + } } + CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); return iRet; } + FWL_ERR CFWL_ComboBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { - uint32_t dwFlag = pEvent->GetClassID(); - if (dwFlag == FWL_EVTHASH_LTB_DrawItem) { + CFWL_EventType dwFlag = pEvent->GetClassID(); + if (dwFlag == CFWL_EventType::DrawItem) { CFWL_EvtLtbDrawItem* pDrawItemEvent = static_cast<CFWL_EvtLtbDrawItem*>(pEvent); CFWL_EvtCmbDrawItem pTemp; @@ -1416,14 +1431,14 @@ FWL_ERR CFWL_ComboBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { pTemp.m_index = pDrawItemEvent->m_index; pTemp.m_rtItem = pDrawItemEvent->m_rect; m_pOwner->DispatchEvent(&pTemp); - } else if (dwFlag == FWL_EVTHASH_Scroll) { + } else if (dwFlag == CFWL_EventType::Scroll) { CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); CFWL_EvtScroll pScrollEv; pScrollEv.m_pSrcTarget = m_pOwner->m_pInterface; pScrollEv.m_iScrollCode = pScrollEvent->m_iScrollCode; pScrollEv.m_fPos = pScrollEvent->m_fPos; m_pOwner->DispatchEvent(&pScrollEv); - } else if (dwFlag == FWL_EVTHASH_EDT_TextChanged) { + } else if (dwFlag == CFWL_EventType::TextChanged) { CFWL_EvtEdtTextChanged* pTextChangedEvent = static_cast<CFWL_EvtEdtTextChanged*>(pEvent); CFWL_EvtCmbEditChanged pTemp; @@ -1435,6 +1450,7 @@ FWL_ERR CFWL_ComboBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { } return FWL_ERR_Succeeded; } + FWL_ERR CFWL_ComboBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { return m_pOwner->DrawWidget(pGraphics, pMatrix); @@ -1586,20 +1602,23 @@ int32_t CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage( CFWL_Message* pMessage) { if (!pMessage) return 0; - uint32_t dwMsgCode = pMessage->GetClassID(); + FX_BOOL backDefault = TRUE; - switch (dwMsgCode) { - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { + switch (pMessage->GetClassID()) { + case CFWL_MessageType::SetFocus: { backDefault = FALSE; - DisForm_OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); + DisForm_OnFocusChanged(pMessage, TRUE); break; } - case FWL_MSGHASH_Mouse: { + case CFWL_MessageType::KillFocus: { + backDefault = FALSE; + DisForm_OnFocusChanged(pMessage, FALSE); + break; + } + case CFWL_MessageType::Mouse: { backDefault = FALSE; CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - uint32_t dwCmd = pMsg->m_dwCmd; - switch (dwCmd) { + switch (pMsg->m_dwCmd) { case FWL_MSGMOUSECMD_LButtonDown: { DisForm_OnLButtonDown(pMsg); break; @@ -1608,22 +1627,22 @@ int32_t CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage( OnLButtonUp(pMsg); break; } - default: {} + default: + break; } break; } - case FWL_MSGHASH_Key: { + case CFWL_MessageType::Key: { backDefault = FALSE; CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); - if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyUp) { + if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyUp) break; - } if (m_pOwner->DisForm_IsDropListShowed() && pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) { - uint32_t dwKeyCode = pKey->m_dwKeyCode; - FX_BOOL bListKey = - dwKeyCode == FWL_VKEY_Up || dwKeyCode == FWL_VKEY_Down || - dwKeyCode == FWL_VKEY_Return || dwKeyCode == FWL_VKEY_Escape; + 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) { IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pListBox->SetDelegate(NULL); @@ -1634,13 +1653,14 @@ int32_t CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage( DisForm_OnKey(pKey); break; } - default: {} + default: + break; } - if (!backDefault) { + if (!backDefault) return 1; - } return CFWL_WidgetImpDelegate::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; @@ -1724,6 +1744,7 @@ void CFWL_ComboBoxImpDelegate::DisForm_OnKey(CFWL_MsgKey* pMsg) { pDelegate->OnProcessMessage(pMsg); } } + CFWL_ComboProxyImpDelegate::CFWL_ComboProxyImpDelegate( IFWL_Form* pForm, CFWL_ComboBoxImp* pComboBox) @@ -1732,38 +1753,50 @@ CFWL_ComboProxyImpDelegate::CFWL_ComboProxyImpDelegate( m_fStartPos(0), m_pForm(pForm), m_pComboBox(pComboBox) {} + int32_t CFWL_ComboProxyImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { if (!pMessage) return 0; - uint32_t dwMsgCode = pMessage->GetClassID(); - if (dwMsgCode == FWL_MSGHASH_Mouse) { - CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - uint32_t dwCmd = pMsg->m_dwCmd; - switch (dwCmd) { - case FWL_MSGMOUSECMD_LButtonDown: { - OnLButtonDown(pMsg); - break; - } - case FWL_MSGMOUSECMD_LButtonUp: { - OnLButtonUp(pMsg); - break; - } - case FWL_MSGMOUSECMD_MouseMove: { - OnMouseMove(pMsg); - break; + + switch (pMessage->GetClassID()) { + case CFWL_MessageType::Mouse: { + CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); + switch (pMsg->m_dwCmd) { + case FWL_MSGMOUSECMD_LButtonDown: { + OnLButtonDown(pMsg); + break; + } + case FWL_MSGMOUSECMD_LButtonUp: { + OnLButtonUp(pMsg); + break; + } + case FWL_MSGMOUSECMD_MouseMove: { + OnMouseMove(pMsg); + break; + } + default: + break; } - default: {} + break; } - } - if (dwMsgCode == FWL_MSGHASH_Deactivate) { - OnDeactive(static_cast<CFWL_MsgDeactivate*>(pMessage)); - } - if (dwMsgCode == FWL_MSGHASH_KillFocus || dwMsgCode == FWL_MSGHASH_SetFocus) { - OnFocusChanged(static_cast<CFWL_MsgKillFocus*>(pMessage), - dwMsgCode == FWL_MSGHASH_SetFocus); + 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; } return CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); } + FWL_ERR CFWL_ComboProxyImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { m_pComboBox->DrawStretchHandler(pGraphics, pMatrix); diff --git a/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp b/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp index 21616992b1..c70ad691a4 100644 --- a/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp +++ b/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp @@ -165,27 +165,30 @@ FWL_ERR CFWL_DateTimeEdit::Finalize() { m_pDelegate = nullptr; return CFWL_EditImp::Finalize(); } + CFWL_DateTimeEditImpDelegate::CFWL_DateTimeEditImpDelegate( CFWL_DateTimeEdit* pOwner) : CFWL_EditImpDelegate(pOwner), m_pOwner(pOwner) {} + int32_t CFWL_DateTimeEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { - if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { + if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) return DisForm_OnProcessMessage(pMessage); - } - uint32_t dwHashCode = pMessage->GetClassID(); - if (dwHashCode == FWL_MSGHASH_SetFocus || - dwHashCode == FWL_MSGHASH_KillFocus) { + + CFWL_MessageType dwHashCode = pMessage->GetClassID(); + if (dwHashCode == CFWL_MessageType::SetFocus || + dwHashCode == CFWL_MessageType::KillFocus) { IFWL_Widget* pOuter = m_pOwner->GetOuter(); IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(NULL); pDelegate->OnProcessMessage(pMessage); } return 1; } + int32_t CFWL_DateTimeEditImpDelegate::DisForm_OnProcessMessage( CFWL_Message* pMessage) { - uint32_t dwHashCode = pMessage->GetClassID(); + CFWL_MessageType dwHashCode = pMessage->GetClassID(); if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { - if (dwHashCode == FWL_MSGHASH_Mouse) { + if (dwHashCode == CFWL_MessageType::Mouse) { CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); if (pMouse->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown || pMouse->m_dwCmd == FWL_MSGMOUSECMD_RButtonDown) { @@ -202,12 +205,13 @@ int32_t CFWL_DateTimeEditImpDelegate::DisForm_OnProcessMessage( pDateTime->Repaint(&rtInvalidate); } } - } else if (dwHashCode == FWL_MSGHASH_Key) { + } else if (dwHashCode == CFWL_MessageType::Key) { return CFWL_EditImpDelegate::OnProcessMessage(pMessage); } } return CFWL_EditImpDelegate::OnProcessMessage(pMessage); } + CFWL_DateTimeCalendar::CFWL_DateTimeCalendar( const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter) @@ -224,19 +228,22 @@ FWL_ERR CFWL_DateTimeCalendar::Finalize() { m_pDelegate = nullptr; return CFWL_MonthCalendarImp::Finalize(); } + CFWL_DateTimeCalendarImpDelegate::CFWL_DateTimeCalendarImpDelegate( CFWL_DateTimeCalendar* pOwner) : CFWL_MonthCalendarImpDelegate(pOwner), m_pOwner(pOwner) { m_bFlag = FALSE; } + int32_t CFWL_DateTimeCalendarImpDelegate::OnProcessMessage( CFWL_Message* pMessage) { - uint32_t dwCode = pMessage->GetClassID(); - if (dwCode == FWL_MSGHASH_SetFocus || dwCode == FWL_MSGHASH_KillFocus) { + CFWL_MessageType dwCode = pMessage->GetClassID(); + if (dwCode == CFWL_MessageType::SetFocus || + dwCode == CFWL_MessageType::KillFocus) { IFWL_Widget* pOuter = m_pOwner->GetOuter(); IFWL_WidgetDelegate* pDelegate = pOuter->SetDelegate(NULL); return pDelegate->OnProcessMessage(pMessage); - } else if (dwCode == FWL_MSGHASH_Mouse) { + } else if (dwCode == CFWL_MessageType::Mouse) { CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonDown) { OnLButtonDownEx(pMsg); @@ -248,6 +255,7 @@ int32_t CFWL_DateTimeCalendarImpDelegate::OnProcessMessage( } return CFWL_MonthCalendarImpDelegate::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; @@ -364,9 +372,10 @@ void CFWL_DateTimeCalendarImpDelegate::OnMouseMoveEx(CFWL_MsgMouse* pMsg) { m_pOwner->Repaint(&rtInvalidate); } } + int32_t CFWL_DateTimeCalendarImpDelegate::DisForm_OnProcessMessage( CFWL_Message* pMessage) { - if (pMessage->GetClassID() == FWL_MSGHASH_Mouse) { + if (pMessage->GetClassID() == CFWL_MessageType::Mouse) { CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); if (pMsg->m_dwCmd == FWL_MSGMOUSECMD_LButtonUp) { DisForm_OnLButtonUpEx(pMsg); @@ -375,6 +384,7 @@ int32_t CFWL_DateTimeCalendarImpDelegate::DisForm_OnProcessMessage( } return CFWL_MonthCalendarImpDelegate::OnProcessMessage(pMessage); } + void CFWL_DateTimeCalendarImpDelegate::DisForm_OnLButtonUpEx( CFWL_MsgMouse* pMsg) { if (m_pOwner->m_rtLBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { @@ -1010,24 +1020,28 @@ FWL_ERR CFWL_DateTimePickerImp::DisForm_DrawWidget(CFX_Graphics* pGraphics, } return FWL_ERR_Succeeded; } + CFWL_DateTimePickerImpDelegate::CFWL_DateTimePickerImpDelegate( CFWL_DateTimePickerImp* pOwner) : m_pOwner(pOwner) {} + int32_t CFWL_DateTimePickerImpDelegate::OnProcessMessage( CFWL_Message* pMessage) { if (!pMessage) return 0; - uint32_t dwMsgCode = pMessage->GetClassID(); - switch (dwMsgCode) { - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { - OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); + + switch (pMessage->GetClassID()) { + case CFWL_MessageType::SetFocus: { + OnFocusChanged(pMessage, TRUE); + break; + } + case CFWL_MessageType::KillFocus: { + OnFocusChanged(pMessage, FALSE); break; } - case FWL_MSGHASH_Mouse: { + case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); - uint32_t dwCmd = pMouse->m_dwCmd; - switch (dwCmd) { + switch (pMouse->m_dwCmd) { case FWL_MSGMOUSECMD_LButtonDown: { OnLButtonDown(pMouse); break; @@ -1044,20 +1058,25 @@ int32_t CFWL_DateTimePickerImpDelegate::OnProcessMessage( OnMouseLeave(pMouse); break; } - default: {} + default: + break; + } + break; + } + case CFWL_MessageType::Key: { + if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { + IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); + return pDelegate->OnProcessMessage(pMessage); } break; } default: break; } - if (dwMsgCode == FWL_MSGHASH_Key && - m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { - IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); - return pDelegate->OnProcessMessage(pMessage); - } + return CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); } + FWL_ERR CFWL_DateTimePickerImpDelegate::OnDrawWidget( CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp index 54e8abcb8b..74db0c96af 100644 --- a/xfa/fwl/basewidget/fwl_editimp.cpp +++ b/xfa/fwl/basewidget/fwl_editimp.cpp @@ -1729,28 +1729,31 @@ void CFWL_EditImp::ProcessInsertError(int32_t iError) { default: {} } } + CFWL_EditImpDelegate::CFWL_EditImpDelegate(CFWL_EditImp* pOwner) : m_pOwner(pOwner) {} + int32_t CFWL_EditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { if (!pMessage) return 0; - uint32_t dwMsgCode = pMessage->GetClassID(); + + CFWL_MessageType dwMsgCode = pMessage->GetClassID(); int32_t iRet = 1; switch (dwMsgCode) { - case FWL_MSGHASH_Activate: { + case CFWL_MessageType::Activate: { DoActivate(static_cast<CFWL_MsgActivate*>(pMessage)); break; } - case FWL_MSGHASH_Deactivate: { + case CFWL_MessageType::Deactivate: { DoDeactivate(static_cast<CFWL_MsgDeactivate*>(pMessage)); break; } - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { - OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); + case CFWL_MessageType::SetFocus: + case CFWL_MessageType::KillFocus: { + OnFocusChanged(pMessage, dwMsgCode == CFWL_MessageType::SetFocus); break; } - case FWL_MSGHASH_Mouse: { + case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); uint32_t dwCmd = pMsg->m_dwCmd; switch (dwCmd) { @@ -1774,32 +1777,35 @@ int32_t CFWL_EditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { DoButtonDown(pMsg); break; } - default: {} + default: + break; } break; } - case FWL_MSGHASH_Key: { + case CFWL_MessageType::Key: { CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); uint32_t dwCmd = pKey->m_dwCmd; - if (dwCmd == FWL_MSGKEYCMD_KeyDown) { + if (dwCmd == FWL_MSGKEYCMD_KeyDown) OnKeyDown(pKey); - } else if (dwCmd == FWL_MSGKEYCMD_Char) { + else if (dwCmd == FWL_MSGKEYCMD_Char) OnChar(pKey); - } break; } - default: { iRet = 0; } + default: { + iRet = 0; + break; + } } CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); return iRet; } + FWL_ERR CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { if (!pEvent) return FWL_ERR_Indefinite; - uint32_t dwHashCode = pEvent->GetClassID(); - if (dwHashCode != FWL_EVTHASH_Scroll) { + if (pEvent->GetClassID() != CFWL_EventType::Scroll) return FWL_ERR_Succeeded; - } + IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && m_pOwner->m_pVertScrollBar) || @@ -1811,6 +1817,7 @@ FWL_ERR CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { } return FWL_ERR_Succeeded; } + FWL_ERR CFWL_EditImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { return m_pOwner->DrawWidget(pGraphics, pMatrix); diff --git a/xfa/fwl/basewidget/fwl_listboximp.cpp b/xfa/fwl/basewidget/fwl_listboximp.cpp index 2adeb97496..49d5d41d87 100644 --- a/xfa/fwl/basewidget/fwl_listboximp.cpp +++ b/xfa/fwl/basewidget/fwl_listboximp.cpp @@ -982,26 +982,30 @@ void CFWL_ListBoxImp::ProcessSelChanged() { } DispatchEvent(&selEvent); } + CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner) : m_pOwner(pOwner) {} + int32_t CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { if (!pMessage) return 0; - if (!m_pOwner->IsEnabled()) { + if (!m_pOwner->IsEnabled()) return 1; - } - uint32_t dwMsgCode = pMessage->GetClassID(); + + CFWL_MessageType dwMsgCode = pMessage->GetClassID(); int32_t iRet = 1; switch (dwMsgCode) { - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { - OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); + case CFWL_MessageType::SetFocus: { + OnFocusChanged(pMessage, TRUE); break; } - case FWL_MSGHASH_Mouse: { + case CFWL_MessageType::KillFocus: { + OnFocusChanged(pMessage, FALSE); + break; + } + case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - uint32_t dwCmd = pMsg->m_dwCmd; - switch (dwCmd) { + switch (pMsg->m_dwCmd) { case FWL_MSGMOUSECMD_LButtonDown: { OnLButtonDown(pMsg); break; @@ -1010,31 +1014,36 @@ int32_t CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { OnLButtonUp(pMsg); break; } - default: {} + default: + break; } break; } - case FWL_MSGHASH_MouseWheel: { + case CFWL_MessageType::MouseWheel: { OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage)); break; } - case FWL_MSGHASH_Key: { + case CFWL_MessageType::Key: { CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage); if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown) OnKeyDown(pMsg); break; } - default: { iRet = 0; } + default: { + iRet = 0; + break; + } } CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); return iRet; } + FWL_ERR CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { if (!pEvent) return FWL_ERR_Indefinite; - if (pEvent->GetClassID() != FWL_EVTHASH_Scroll) { + if (pEvent->GetClassID() != CFWL_EventType::Scroll) return FWL_ERR_Succeeded; - } + IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && m_pOwner->m_pVertScrollBar) || @@ -1046,6 +1055,7 @@ FWL_ERR CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { } return FWL_ERR_Succeeded; } + FWL_ERR CFWL_ListBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { return m_pOwner->DrawWidget(pGraphics, pMatrix); diff --git a/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp b/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp index 1965e400b7..0c6539b51d 100644 --- a/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp +++ b/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp @@ -1013,28 +1013,33 @@ FX_BOOL CFWL_MonthCalendarImp::GetDayRect(int32_t iDay, CFX_RectF& rtDay) { rtDay = pDateInfo->rect; return TRUE; } + CFWL_MonthCalendarImpDelegate::CFWL_MonthCalendarImpDelegate( CFWL_MonthCalendarImp* pOwner) : m_pOwner(pOwner) {} + int32_t CFWL_MonthCalendarImpDelegate::OnProcessMessage( CFWL_Message* pMessage) { if (!pMessage) return 0; - uint32_t dwMsgCode = pMessage->GetClassID(); + + CFWL_MessageType dwMsgCode = pMessage->GetClassID(); int32_t iRet = 1; switch (dwMsgCode) { - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { - OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); + case CFWL_MessageType::SetFocus: { + OnFocusChanged(pMessage, TRUE); break; } - case FWL_MSGHASH_Key: { + case CFWL_MessageType::KillFocus: { + OnFocusChanged(pMessage, FALSE); break; } - case FWL_MSGHASH_Mouse: { + case CFWL_MessageType::Key: { + break; + } + case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMouse = static_cast<CFWL_MsgMouse*>(pMessage); - uint32_t dwCmd = pMouse->m_dwCmd; - switch (dwCmd) { + switch (pMouse->m_dwCmd) { case FWL_MSGMOUSECMD_LButtonDown: { OnLButtonDown(pMouse); break; @@ -1051,7 +1056,8 @@ int32_t CFWL_MonthCalendarImpDelegate::OnProcessMessage( OnMouseLeave(pMouse); break; } - default: { break; } + default: + break; } break; } @@ -1063,6 +1069,7 @@ int32_t CFWL_MonthCalendarImpDelegate::OnProcessMessage( CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); return iRet; } + FWL_ERR CFWL_MonthCalendarImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { return m_pOwner->DrawWidget(pGraphics, pMatrix); diff --git a/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp b/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp index 92f0ca11d2..167d8f3c1f 100644 --- a/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp +++ b/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp @@ -398,27 +398,31 @@ void CFWL_PushButtonImp::UpdateTextOutStyles() { m_dwTTOStyles |= FDE_TTOSTYLE_RTL; } } + CFWL_PushButtonImpDelegate::CFWL_PushButtonImpDelegate( CFWL_PushButtonImp* pOwner) : m_pOwner(pOwner) {} + int32_t CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { if (!pMessage) return 0; - if (!m_pOwner->IsEnabled()) { + if (!m_pOwner->IsEnabled()) return 1; - } + int32_t iRet = 1; - uint32_t dwMsgCode = pMessage->GetClassID(); + CFWL_MessageType dwMsgCode = pMessage->GetClassID(); switch (dwMsgCode) { - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { - OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); + case CFWL_MessageType::SetFocus: { + OnFocusChanged(pMessage, TRUE); break; } - case FWL_MSGHASH_Mouse: { + case CFWL_MessageType::KillFocus: { + OnFocusChanged(pMessage, FALSE); + break; + } + case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - uint32_t dwCmd = pMsg->m_dwCmd; - switch (dwCmd) { + switch (pMsg->m_dwCmd) { case FWL_MSGMOUSECMD_LButtonDown: { OnLButtonDown(pMsg); break; @@ -435,15 +439,15 @@ int32_t CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { OnMouseLeave(pMsg); break; } - default: {} + default: + break; } break; } - case FWL_MSGHASH_Key: { + case CFWL_MessageType::Key: { CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); - if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) { + if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) OnKeyDown(pKey); - } break; } default: { @@ -454,6 +458,7 @@ int32_t CFWL_PushButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); return iRet; } + FWL_ERR CFWL_PushButtonImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { return FWL_ERR_Succeeded; } diff --git a/xfa/fwl/basewidget/fwl_scrollbarimp.cpp b/xfa/fwl/basewidget/fwl_scrollbarimp.cpp index 8812076f6b..fed93fbc07 100644 --- a/xfa/fwl/basewidget/fwl_scrollbarimp.cpp +++ b/xfa/fwl/basewidget/fwl_scrollbarimp.cpp @@ -625,14 +625,17 @@ FX_BOOL CFWL_ScrollBarImp::OnScroll(uint32_t dwCode, FX_FLOAT fPos) { DispatchEvent(&ev); return bRet; } + CFWL_ScrollBarImpDelegate::CFWL_ScrollBarImpDelegate(CFWL_ScrollBarImp* pOwner) : m_pOwner(pOwner) {} + int32_t CFWL_ScrollBarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { if (!pMessage) return 0; + int32_t iRet = 1; - uint32_t dwMsgCode = pMessage->GetClassID(); - if (dwMsgCode == FWL_MSGHASH_Mouse) { + CFWL_MessageType dwMsgCode = pMessage->GetClassID(); + if (dwMsgCode == CFWL_MessageType::Mouse) { CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); uint32_t dwCmd = pMsg->m_dwCmd; switch (dwCmd) { @@ -652,9 +655,12 @@ int32_t CFWL_ScrollBarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { OnMouseLeave(); break; } - default: { iRet = 0; } + default: { + iRet = 0; + break; + } } - } else if (dwMsgCode == FWL_MSGHASH_MouseWheel) { + } else if (dwMsgCode == CFWL_MessageType::MouseWheel) { CFWL_MsgMouseWheel* pMsg = static_cast<CFWL_MsgMouseWheel*>(pMessage); OnMouseWheel(pMsg->m_fx, pMsg->m_fy, pMsg->m_dwFlags, pMsg->m_fDeltaX, pMsg->m_fDeltaY); @@ -663,6 +669,7 @@ int32_t CFWL_ScrollBarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { } return iRet; } + FWL_ERR CFWL_ScrollBarImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { return m_pOwner->DrawWidget(pGraphics, pMatrix); diff --git a/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp b/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp index e52529d3c6..6d60d81e81 100644 --- a/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp +++ b/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp @@ -201,24 +201,29 @@ void CFWL_SpinButtonImp::DrawDownButton(CFX_Graphics* pGraphics, params.m_rtPart = m_rtDnButton; pTheme->DrawBackground(¶ms); } + CFWL_SpinButtonImpDelegate::CFWL_SpinButtonImpDelegate( CFWL_SpinButtonImp* pOwner) : m_pOwner(pOwner) {} + int32_t CFWL_SpinButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { if (!pMessage) return 0; + int32_t iRet = 1; - uint32_t dwMsgCode = pMessage->GetClassID(); + CFWL_MessageType dwMsgCode = pMessage->GetClassID(); switch (dwMsgCode) { - case FWL_MSGHASH_SetFocus: - case FWL_MSGHASH_KillFocus: { - OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); + case CFWL_MessageType::SetFocus: { + OnFocusChanged(pMessage, TRUE); + break; + } + case CFWL_MessageType::KillFocus: { + OnFocusChanged(pMessage, FALSE); break; } - case FWL_MSGHASH_Mouse: { + case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); - uint32_t dwCmd = pMsg->m_dwCmd; - switch (dwCmd) { + switch (pMsg->m_dwCmd) { case FWL_MSGMOUSECMD_LButtonDown: { OnLButtonDown(pMsg); break; @@ -235,15 +240,15 @@ int32_t CFWL_SpinButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { OnMouseLeave(pMsg); break; } - default: {} + default: + break; } break; } - case FWL_MSGHASH_Key: { + case CFWL_MessageType::Key: { CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); - if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) { + if (pKey->m_dwCmd == FWL_MSGKEYCMD_KeyDown) OnKeyDown(pKey); - } break; } default: { @@ -254,6 +259,7 @@ int32_t CFWL_SpinButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); return iRet; } + FWL_ERR CFWL_SpinButtonImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { return FWL_ERR_Succeeded; } diff --git a/xfa/fwl/basewidget/ifwl_checkbox.h b/xfa/fwl/basewidget/ifwl_checkbox.h index f4cfe5f956..0f4b42c2c8 100644 --- a/xfa/fwl/basewidget/ifwl_checkbox.h +++ b/xfa/fwl/basewidget/ifwl_checkbox.h @@ -45,11 +45,8 @@ #define FWL_STATE_CKB_Neutral (2 << (FWL_WGTSTATE_MAX + 2)) #define FWL_STATE_CKB_CheckMask (3L << (FWL_WGTSTATE_MAX + 2)) -// TODO(dsinclair): Event hash is hash of string, cleanup. pdfium:474 -#define FWL_EVTHASH_CKB_CheckStateChanged 2503252963 - BEGIN_FWL_EVENT_DEF(CFWL_EvtCkbCheckStateChanged, - FWL_EVTHASH_CKB_CheckStateChanged) + CFWL_EventType::CheckStateChanged) END_FWL_EVENT_DEF class IFWL_CheckBoxDP : public IFWL_DataProvider { diff --git a/xfa/fwl/basewidget/ifwl_combobox.h b/xfa/fwl/basewidget/ifwl_combobox.h index 826404f9aa..b76724811b 100644 --- a/xfa/fwl/basewidget/ifwl_combobox.h +++ b/xfa/fwl/basewidget/ifwl_combobox.h @@ -38,40 +38,32 @@ class IFWL_ComboBox; #define FWL_STYLEEXT_CMB_ListItemIconText (1L << 12) #define FWL_STYLEEXT_CMB_ListItemAlignMask (3L << 12) #define FWL_STYLEEXT_CMB_ReadOnly (1L << 13) -// TODO(dsinclair): Event hash is hash of string, cleanup. pdfium:474 -#define FWL_EVTHASH_CMB_PreDropDown 1357646798 -#define FWL_EVTHASH_CMB_PostDropDown 3677010285 -#define FWL_EVTHASH_CMB_CloseUp 2871271190 -#define FWL_EVTHASH_CMB_EditChanged 1527034762 -#define FWL_EVTHASH_CMB_SelChanged 2923227784 -#define FWL_EVTHASH_CMB_HoverChanged 944325448 -#define FWL_EVTHASH_CMB_DrawItem 917354551 - -BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbPreDropDown, FWL_EVTHASH_CMB_PreDropDown) + +BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbPreDropDown, CFWL_EventType::PreDropDown) END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbPostDropDown, FWL_EVTHASH_CMB_PostDropDown) +BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbPostDropDown, CFWL_EventType::PostDropDown) END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbCloseUp, FWL_EVTHASH_CMB_CloseUp) +BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbCloseUp, CFWL_EventType::CloseUp) END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbEditChanged, FWL_EVTHASH_CMB_EditChanged) +BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbEditChanged, CFWL_EventType::EditChanged) int32_t nChangeType; CFX_WideString wsInsert; CFX_WideString wsDelete; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbSelChanged, FWL_EVTHASH_CMB_SelChanged) +BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbSelChanged, CFWL_EventType::SelectChanged) CFX_Int32Array iArraySels; FX_BOOL bLButtonUp; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbHoverChanged, FWL_EVTHASH_CMB_HoverChanged) +BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbHoverChanged, CFWL_EventType::HoverChanged) int32_t m_iCurHover; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbDrawItem, FWL_EVTHASH_CMB_DrawItem) +BEGIN_FWL_EVENT_DEF(CFWL_EvtCmbDrawItem, CFWL_EventType::DrawItem) CFX_Graphics* m_pGraphics; CFX_Matrix m_matrix; int32_t m_index; diff --git a/xfa/fwl/basewidget/ifwl_datetimepicker.h b/xfa/fwl/basewidget/ifwl_datetimepicker.h index 07bc8715c3..3d1188eead 100644 --- a/xfa/fwl/basewidget/ifwl_datetimepicker.h +++ b/xfa/fwl/basewidget/ifwl_datetimepicker.h @@ -30,28 +30,22 @@ #define FWL_STYLEEXT_DTP_EditHAlignMask (3L << 4) #define FWL_STYLEEXT_DTP_EditVAlignMask (3L << 6) #define FWL_STYLEEXT_DTP_EditHAlignModeMask (3L << 8) -// TODO(dsinclair): Event hash is hash of string, cleanup. pdfium:474 -#define FWL_EVTHASH_DTP_DropDown 264728733 -#define FWL_EVTHASH_DTP_CloseUp 4280973803 -#define FWL_EVTHASH_DTP_EditChanged 4009610944 -#define FWL_EVTHASH_DTP_HoverChanged 686674750 -#define FWL_EVTHASH_DTP_SelectChanged 1589616858 -BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpDropDown, FWL_EVTHASH_DTP_DropDown) +BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpDropDown, CFWL_EventType::DropDown) END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpCloseUp, FWL_EVTHASH_DTP_CloseUp) +BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpCloseUp, CFWL_EventType::CloseUp) END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpEditChanged, FWL_EVTHASH_DTP_EditChanged) +BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpEditChanged, CFWL_EventType::EditChanged) CFX_WideString m_wsText; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpHoverChanged, FWL_EVTHASH_DTP_HoverChanged) +BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpHoverChanged, CFWL_EventType::HoverChanged) int32_t hoverday; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpSelectChanged, FWL_EVTHASH_DTP_SelectChanged) +BEGIN_FWL_EVENT_DEF(CFWL_Event_DtpSelectChanged, CFWL_EventType::SelectChanged) int32_t iYear; int32_t iMonth; int32_t iDay; diff --git a/xfa/fwl/basewidget/ifwl_edit.h b/xfa/fwl/basewidget/ifwl_edit.h index caa2b530b8..eb8c77b8a6 100644 --- a/xfa/fwl/basewidget/ifwl_edit.h +++ b/xfa/fwl/basewidget/ifwl_edit.h @@ -9,6 +9,7 @@ #include <vector> +#include "xfa/fwl/core/cfwl_event.h" #include "xfa/fwl/core/ifwl_dataprovider.h" #include "xfa/fwl/lightwidget/cfwl_widget.h" @@ -49,13 +50,6 @@ #define FWL_STYLEEXT_EDT_LastLineHeight (1L << 27) #define FWL_PARTDATA_EDT_Background 0 #define FWL_PARTDATA_EDT_StaticBackground 1 -// TODO(dsinclair): Event hash is hash of string, cleanup. pdfium:474 -#define FWL_EVTHASH_EDT_TextChanged 1064022132 -#define FWL_EVTHASH_EDT_PreSelfAdaption 1001979178 -#define FWL_EVTHASH_EDT_Validate 3373308608 -#define FWL_EVTHASH_EDT_CheckWord 2897181520 -#define FWL_EVTHASH_EDT_GetSuggestWords 315782791 -#define FWL_EVTHASH_EDT_TextFull 2158580174 typedef struct FWL_HEDTFIND_ { void* pData; } * FWL_HEDTFIND; @@ -65,34 +59,35 @@ enum FWL_EDT_TEXTCHANGED { FWL_EDT_TEXTCHANGED_Replace, }; -BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtTextChanged, FWL_EVTHASH_EDT_TextChanged) +BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtTextChanged, CFWL_EventType::TextChanged) int32_t nChangeType; CFX_WideString wsInsert; CFX_WideString wsDelete; CFX_WideString wsPrevText; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtTextFull, FWL_EVTHASH_EDT_TextFull) +BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtTextFull, CFWL_EventType::TextFull) END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtPreSelfAdaption, FWL_EVTHASH_EDT_PreSelfAdaption) +BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtPreSelfAdaption, CFWL_EventType::PreSelfAdaption) FX_BOOL bHSelfAdaption; FX_BOOL bVSelfAdaption; CFX_RectF rtAfterChange; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtValidate, FWL_EVTHASH_EDT_Validate) +BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtValidate, CFWL_EventType::Validate) IFWL_Widget* pDstWidget; CFX_WideString wsInsert; FX_BOOL bValidate; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtCheckWord, FWL_EVTHASH_EDT_CheckWord) +BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtCheckWord, CFWL_EventType::CheckWord) CFX_ByteString bsWord; FX_BOOL bCheckWord; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtGetSuggestWords, FWL_EVTHASH_EDT_GetSuggestWords) +BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtGetSuggestWords, + CFWL_EventType::GetSuggestedWords) FX_BOOL bSuggestWords; CFX_ByteString bsWord; std::vector<CFX_ByteString> bsArraySuggestWords; diff --git a/xfa/fwl/basewidget/ifwl_listbox.h b/xfa/fwl/basewidget/ifwl_listbox.h index af4335aa03..87d11a3c56 100644 --- a/xfa/fwl/basewidget/ifwl_listbox.h +++ b/xfa/fwl/basewidget/ifwl_listbox.h @@ -30,9 +30,6 @@ #define FWL_ITEMSTATE_LTB_Selected (1L << 0) #define FWL_ITEMSTATE_LTB_Focused (1L << 1) #define FWL_ITEMSTATE_LTB_Checked (1L << 2) -// TODO(dsinclair): Event hash is hash of string, cleanup. pdfium:474 -#define FWL_EVTHASH_LTB_SelChanged 1701781688 -#define FWL_EVTHASH_LTB_DrawItem 1050853991 typedef struct FWL_HLISTITEM_ { void* pData; } * FWL_HLISTITEM; @@ -44,11 +41,11 @@ struct FWL_ListBoxItemData { int32_t iIndex; }; -BEGIN_FWL_EVENT_DEF(CFWL_EvtLtbSelChanged, FWL_EVTHASH_LTB_SelChanged) +BEGIN_FWL_EVENT_DEF(CFWL_EvtLtbSelChanged, CFWL_EventType::SelectChanged) CFX_Int32Array iarraySels; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtLtbDrawItem, FWL_EVTHASH_LTB_DrawItem) +BEGIN_FWL_EVENT_DEF(CFWL_EvtLtbDrawItem, CFWL_EventType::DrawItem) CFX_Graphics* m_pGraphics; CFX_Matrix m_matrix; int32_t m_index; diff --git a/xfa/fwl/basewidget/ifwl_monthcalendar.h b/xfa/fwl/basewidget/ifwl_monthcalendar.h index ad3ce1d62e..38e06f265b 100644 --- a/xfa/fwl/basewidget/ifwl_monthcalendar.h +++ b/xfa/fwl/basewidget/ifwl_monthcalendar.h @@ -22,16 +22,13 @@ #define FWL_ITEMSTATE_MCD_Flag (1L << 0) #define FWL_ITEMSTATE_MCD_Selected (1L << 1) #define FWL_ITEMSTATE_MCD_Focused (1L << 2) -#define FWL_NOTEHASH_MCD_DATASELECTED 1085596932 -// TODO(dsinclair): Event hash is hash of string, cleanup. pdfium:474 -#define FWL_EVTHASH_MCD_DateChanged 54212227 -BEGIN_FWL_EVENT_DEF(CFWL_Event_McdDateSelected, FWL_NOTEHASH_MCD_DATASELECTED) +BEGIN_FWL_EVENT_DEF(CFWL_Event_McdDateSelected, CFWL_EventType::DataSelected) int32_t m_iStartDay; int32_t m_iEndDay; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EventMcdDateChanged, FWL_EVTHASH_MCD_DateChanged) +BEGIN_FWL_EVENT_DEF(CFWL_EventMcdDateChanged, CFWL_EventType::DateChanged) int32_t m_iOldYear; int32_t m_iOldMonth; int32_t m_iStartDay; diff --git a/xfa/fwl/basewidget/ifwl_spinbutton.h b/xfa/fwl/basewidget/ifwl_spinbutton.h index 9a8ff59520..b98e2255ff 100644 --- a/xfa/fwl/basewidget/ifwl_spinbutton.h +++ b/xfa/fwl/basewidget/ifwl_spinbutton.h @@ -14,10 +14,8 @@ #define FWL_STYLEEXE_SPB_Vert (1L << 0) #define FWL_WGTHITTEST_SPB_UpButton (FWL_WGTHITTEST_MAX + 1) #define FWL_WGTHITTEST_SPB_DownButton (FWL_WGTHITTEST_MAX + 2) -// TODO(dsinclair): Event hash is hash of string, cleanup. pdfium:474 -#define FWL_EVTHASH_SPB_Click 2927651187 -BEGIN_FWL_EVENT_DEF(CFWL_EvtSpbClick, FWL_EVTHASH_SPB_Click) +BEGIN_FWL_EVENT_DEF(CFWL_EvtSpbClick, CFWL_EventType::Click) FX_BOOL m_bUp; END_FWL_EVENT_DEF diff --git a/xfa/fwl/core/cfwl_event.h b/xfa/fwl/core/cfwl_event.h index b2f88802f9..d53fcb36dc 100644 --- a/xfa/fwl/core/cfwl_event.h +++ b/xfa/fwl/core/cfwl_event.h @@ -10,23 +10,42 @@ #include "core/fxcrt/include/fx_coordinates.h" #include "core/fxcrt/include/fx_string.h" #include "core/fxcrt/include/fx_system.h" -#include "xfa/fwl/core/cfwl_note.h" #include "xfa/fwl/core/fwl_error.h" -// TODO(dsinclair): Event hash is hash of string, cleanup. pdfium:474 -#define FWL_EVTHASH_Mouse 1765258002 -#define FWL_EVTHASH_MouseWheel 3907114407 -#define FWL_EVTHASH_Key 2408354450 -#define FWL_EVTHASH_SetFocus 3909721269 -#define FWL_EVTHASH_KillFocus 1779363253 -#define FWL_EVTHASH_Draw 2430713303 -#define FWL_EVTHASH_Click 4026328783 -#define FWL_EVTHASH_Scroll 2965158968 -#define FWL_EVTHASH_Close 4036693599 -#define FWL_EVTHASH_ContextMenu 2717307715 -#define FWL_EVTHASH_MenuCommand 497763741 -#define FWL_EVTHASH_SizeChanged 3083958510 -#define FWL_EVTHASH_Idle 839546759 +enum class CFWL_EventType { + None = 0, + + CheckStateChanged, + CheckWord, + Click, + Close, + CloseUp, + ContextMenu, + DataSelected, + DateChanged, + Draw, + DrawItem, + DropDown, + EditChanged, + GetSuggestedWords, + HoverChanged, + Idle, + Key, + KillFocus, + MenuCommand, + Mouse, + MouseWheel, + PostDropDown, + PreDropDown, + PreSelfAdaption, + Scroll, + SelectChanged, + SetFocus, + SizeChanged, + TextChanged, + TextFull, + Validate +}; typedef enum { FWL_EVENT_MOUSE_MASK = 1 << 0, @@ -44,13 +63,33 @@ typedef enum { class CFX_Graphics; class IFWL_Widget; -class CFWL_Event : public CFWL_Note { +class CFWL_Event { public: - CFWL_Event() : CFWL_Note(TRUE) {} + CFWL_Event() + : m_pSrcTarget(nullptr), m_pDstTarget(nullptr), m_dwRefCount(1) {} virtual ~CFWL_Event() {} + + virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const { + return FWL_ERR_Succeeded; + } + virtual CFWL_EventType GetClassID() const { return CFWL_EventType::None; } + + uint32_t Release() { + m_dwRefCount--; + uint32_t dwRefCount = m_dwRefCount; + if (!m_dwRefCount) + delete this; + return dwRefCount; + } + + IFWL_Widget* m_pSrcTarget; + IFWL_Widget* m_pDstTarget; + + private: + uint32_t m_dwRefCount; }; -#define BEGIN_FWL_EVENT_DEF(classname, eventhashcode) \ +#define BEGIN_FWL_EVENT_DEF(classname, eventType) \ class classname : public CFWL_Event { \ public: \ classname() : CFWL_Event() {} \ @@ -58,20 +97,20 @@ class CFWL_Event : public CFWL_Note { wsClass = L## #classname; \ return FWL_ERR_Succeeded; \ } \ - virtual uint32_t GetClassID() const { return eventhashcode; } + virtual CFWL_EventType GetClassID() const { return eventType; } #define END_FWL_EVENT_DEF \ } \ ; // NOLINT -BEGIN_FWL_EVENT_DEF(CFWL_EvtMouse, FWL_EVTHASH_Mouse) +BEGIN_FWL_EVENT_DEF(CFWL_EvtMouse, CFWL_EventType::Mouse) FX_FLOAT m_fx; FX_FLOAT m_fy; uint32_t m_dwFlags; uint32_t m_dwCmd; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtMouseWheel, FWL_EVTHASH_MouseWheel) +BEGIN_FWL_EVENT_DEF(CFWL_EvtMouseWheel, CFWL_EventType::MouseWheel) FX_FLOAT m_fx; FX_FLOAT m_fy; FX_FLOAT m_fDeltaX; @@ -79,55 +118,55 @@ FX_FLOAT m_fDeltaY; uint32_t m_dwFlags; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtKey, FWL_EVTHASH_Key) +BEGIN_FWL_EVENT_DEF(CFWL_EvtKey, CFWL_EventType::Key) uint32_t m_dwKeyCode; uint32_t m_dwFlags; uint32_t m_dwCmd; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtSetFocus, FWL_EVTHASH_SetFocus) +BEGIN_FWL_EVENT_DEF(CFWL_EvtSetFocus, CFWL_EventType::SetFocus) IFWL_Widget* m_pSetFocus; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtKillFocus, FWL_EVTHASH_KillFocus) +BEGIN_FWL_EVENT_DEF(CFWL_EvtKillFocus, CFWL_EventType::KillFocus) IFWL_Widget* m_pKillFocus; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtDraw, FWL_EVTHASH_Draw) +BEGIN_FWL_EVENT_DEF(CFWL_EvtDraw, CFWL_EventType::Draw) CFX_Graphics* m_pGraphics; IFWL_Widget* m_pWidget; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtClick, FWL_EVTHASH_Click) +BEGIN_FWL_EVENT_DEF(CFWL_EvtClick, CFWL_EventType::Click) END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtScroll, FWL_EVTHASH_Scroll) +BEGIN_FWL_EVENT_DEF(CFWL_EvtScroll, CFWL_EventType::Scroll) uint32_t m_iScrollCode; FX_FLOAT m_fPos; FX_BOOL* m_pRet; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtClose, FWL_EVTHASH_Close) +BEGIN_FWL_EVENT_DEF(CFWL_EvtClose, CFWL_EventType::Close) END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtContextMenu, FWL_EVTHASH_ContextMenu) +BEGIN_FWL_EVENT_DEF(CFWL_EvtContextMenu, CFWL_EventType::ContextMenu) FX_FLOAT m_fPosX; FX_FLOAT m_fPosY; IFWL_Widget* m_pOwner; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtMenuCommand, FWL_EVTHASH_MenuCommand) +BEGIN_FWL_EVENT_DEF(CFWL_EvtMenuCommand, CFWL_EventType::MenuCommand) int32_t m_iCommand; void* m_pData; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtSizeChanged, FWL_EVTHASH_SizeChanged) +BEGIN_FWL_EVENT_DEF(CFWL_EvtSizeChanged, CFWL_EventType::SizeChanged) IFWL_Widget* m_pWidget; CFX_RectF m_rtOld; CFX_RectF m_rtNew; END_FWL_EVENT_DEF -BEGIN_FWL_EVENT_DEF(CFWL_EvtIdle, FWL_EVTHASH_Idle) +BEGIN_FWL_EVENT_DEF(CFWL_EvtIdle, CFWL_EventType::Idle) END_FWL_EVENT_DEF #endif // XFA_FWL_CORE_CFWL_EVENT_H_ diff --git a/xfa/fwl/core/cfwl_message.h b/xfa/fwl/core/cfwl_message.h index 7bd6af1977..e751824bc9 100644 --- a/xfa/fwl/core/cfwl_message.h +++ b/xfa/fwl/core/cfwl_message.h @@ -9,24 +9,27 @@ #include "core/fxcrt/include/fx_string.h" #include "core/fxcrt/include/fx_system.h" -#include "xfa/fwl/core/cfwl_note.h" #include "xfa/fwl/core/fwl_error.h" -#define FWL_MSGHASH_Activate 2410369469 -#define FWL_MSGHASH_Deactivate 1184214790 -#define FWL_MSGHASH_SetFocus 4174512504 -#define FWL_MSGHASH_KillFocus 1557903832 -#define FWL_MSGHASH_Mouse 706128309 -#define FWL_MSGHASH_MouseWheel 893703466 -#define FWL_MSGHASH_Key 3751372405 -#define FWL_MSGHASH_Cursor 3182626218 -#define FWL_MSGHASH_Size 160077735 -#define FWL_MSGHASH_WindowMove 1032269377 -#define FWL_MSGHASH_DropFiles 2004165236 -#define FWL_MSGHASH_TaskClicked 3128231086 -#define FWL_MSGHASH_Close 2977563906 -#define FWL_MSGHASH_Post 1969633074 -#define FWL_MSGHASH_WindowWillMove 2229175763 +enum class CFWL_MessageType { + None = 0, + + Activate, + Close, + Cursor, + Deactivate, + DropFiles, + Key, + KillFocus, + Mouse, + MouseWheel, + Post, + SetFocus, + Size, + TaskClicked, + WindowMove, + WindowWillMove +}; #define FWL_MSG_Activate L"FWL_MESSAGE_Activate" #define FWL_MSG_Deactivate L"FWL_MESSAGE_Deactivate" @@ -63,41 +66,71 @@ class IFWL_Widget; -class CFWL_Message : public CFWL_Note { +class CFWL_Message { public: - CFWL_Message() : CFWL_Note(FALSE) {} + CFWL_Message() + : m_pSrcTarget(nullptr), + m_pDstTarget(nullptr), + m_dwExtend(0), + m_dwRefCount(1) {} virtual ~CFWL_Message() {} + + virtual CFWL_Message* Clone() { return nullptr; } + virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const { + return FWL_ERR_Succeeded; + } + virtual CFWL_MessageType GetClassID() const { return CFWL_MessageType::None; } + + uint32_t Release() { + m_dwRefCount--; + uint32_t dwRefCount = m_dwRefCount; + if (!m_dwRefCount) + delete this; + return dwRefCount; + } + + CFWL_Message* Retain() { + m_dwRefCount++; + return this; + } + + IFWL_Widget* m_pSrcTarget; + IFWL_Widget* m_pDstTarget; + uint32_t m_dwExtend; + + private: + uint32_t m_dwRefCount; }; -#define BEGIN_FWL_MESSAGE_DEF(classname, msghashcode) \ - class classname : public CFWL_Message { \ - public: \ - classname() : CFWL_Message() {} \ - virtual CFWL_Note* Clone() { return new classname(*this); } \ - virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const { \ - wsClass = L## #classname; \ - return FWL_ERR_Succeeded; \ - } \ - virtual uint32_t GetClassID() const { return msghashcode; } +#define BEGIN_FWL_MESSAGE_DEF(classname, msgType) \ + class classname : public CFWL_Message { \ + public: \ + classname() : CFWL_Message() {} \ + CFWL_Message* Clone() override { return new classname(*this); } \ + FWL_ERR GetClassName(CFX_WideString& wsClass) const override { \ + wsClass = L## #classname; \ + return FWL_ERR_Succeeded; \ + } \ + CFWL_MessageType GetClassID() const override { return msgType; } #define END_FWL_MESSAGE_DEF \ } \ ; // NOLINT -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgActivate, FWL_MSGHASH_Activate) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgActivate, CFWL_MessageType::Activate) END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDeactivate, FWL_MSGHASH_Deactivate) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDeactivate, CFWL_MessageType::Deactivate) END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouse, FWL_MSGHASH_Mouse) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouse, CFWL_MessageType::Mouse) FX_FLOAT m_fx; FX_FLOAT m_fy; uint32_t m_dwFlags; uint32_t m_dwCmd; END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouseWheel, FWL_MSGHASH_MouseWheel) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgMouseWheel, CFWL_MessageType::MouseWheel) FX_FLOAT m_fx; FX_FLOAT m_fy; FX_FLOAT m_fDeltaX; @@ -105,34 +138,34 @@ FX_FLOAT m_fDeltaY; uint32_t m_dwFlags; END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSetFocus, FWL_MSGHASH_SetFocus) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSetFocus, CFWL_MessageType::SetFocus) IFWL_Widget* m_pKillFocus; END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKillFocus, FWL_MSGHASH_KillFocus) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKillFocus, CFWL_MessageType::KillFocus) IFWL_Widget* m_pSetFocus; END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKey, FWL_MSGHASH_Key) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgKey, CFWL_MessageType::Key) uint32_t m_dwKeyCode; uint32_t m_dwFlags; uint32_t m_dwCmd; END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgCursor, FWL_MSGHASH_Cursor) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgCursor, CFWL_MessageType::Cursor) END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSize, FWL_MSGHASH_Size) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgSize, CFWL_MessageType::Size) int32_t m_iWidth; int32_t m_iHeight; END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowMove, FWL_MSGHASH_WindowMove) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowMove, CFWL_MessageType::WindowMove) FX_FLOAT m_fx; FX_FLOAT m_fy; END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDropFiles, FWL_MSGHASH_DropFiles) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgDropFiles, CFWL_MessageType::DropFiles) CFWL_MsgDropFiles(const CFWL_MsgDropFiles& copy) { m_pDstTarget = copy.m_pDstTarget; m_pSrcTarget = copy.m_pSrcTarget; @@ -145,15 +178,15 @@ FX_FLOAT m_fy; CFX_WideStringArray m_files; END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgTaskClicked, FWL_MSGHASH_TaskClicked) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgTaskClicked, CFWL_MessageType::TaskClicked) FX_FLOAT m_fx; FX_FLOAT m_fy; END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgClose, FWL_MSGHASH_Close) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgClose, CFWL_MessageType::Close) END_FWL_MESSAGE_DEF -BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowWillMove, FWL_MSGHASH_WindowWillMove) +BEGIN_FWL_MESSAGE_DEF(CFWL_MsgWindowWillMove, CFWL_MessageType::WindowWillMove) END_FWL_MESSAGE_DEF #endif // XFA_FWL_CORE_CFWL_MESSAGE_H_ diff --git a/xfa/fwl/core/cfwl_note.h b/xfa/fwl/core/cfwl_note.h deleted file mode 100644 index d173dc6f76..0000000000 --- a/xfa/fwl/core/cfwl_note.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2016 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FWL_CORE_CFWL_NOTE_H_ -#define XFA_FWL_CORE_CFWL_NOTE_H_ - -#include "core/fxcrt/include/fx_string.h" -#include "core/fxcrt/include/fx_system.h" -#include "xfa/fwl/core/fwl_error.h" - -class IFWL_Widget; - -// Separate hierarchy not related to IFWL_* hierarchy. These should not -// get cast to IFWL_* types. -class CFWL_Note { - public: - virtual uint32_t Release() { - m_dwRefCount--; - uint32_t dwRefCount = m_dwRefCount; - if (!m_dwRefCount) - delete this; - return dwRefCount; - } - - virtual CFWL_Note* Retain() { - m_dwRefCount++; - return this; - } - - virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const { - wsClass = L"CFWL_Note"; - return FWL_ERR_Succeeded; - } - - virtual uint32_t GetClassID() const { return 0; } - - virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const { - return TRUE; - } - - virtual CFWL_Note* Clone() { return NULL; } - FX_BOOL IsEvent() const { return m_bIsEvent; } - - IFWL_Widget* m_pSrcTarget; - IFWL_Widget* m_pDstTarget; - uint32_t m_dwExtend; - - protected: - CFWL_Note(FX_BOOL bIsEvent) - : m_pSrcTarget(NULL), - m_pDstTarget(NULL), - m_dwExtend(0), - m_dwRefCount(1), - m_bIsEvent(bIsEvent) {} - - virtual ~CFWL_Note() {} - virtual FX_BOOL Initialize() { return TRUE; } - virtual int32_t Finalize() { return 0; } - - uint32_t m_dwRefCount; - FX_BOOL m_bIsEvent; -}; - -#endif // XFA_FWL_CORE_CFWL_NOTE_H_ diff --git a/xfa/fwl/core/fwl_formimp.cpp b/xfa/fwl/core/fwl_formimp.cpp index 338c55fee1..ad3c173590 100644 --- a/xfa/fwl/core/fwl_formimp.cpp +++ b/xfa/fwl/core/fwl_formimp.cpp @@ -856,20 +856,25 @@ void CFWL_FormImp::DoHeightLimit(FX_FLOAT& fTop, } } } + CFWL_FormImpDelegate::CFWL_FormImpDelegate(CFWL_FormImp* pOwner) : m_pOwner(pOwner) {} + int32_t CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { -#ifdef FWL_UseMacSystemBorder if (!pMessage) return 0; - uint32_t dwMsgCode = pMessage->GetClassID(); + + CFWL_MessageType dwMsgCode = pMessage->GetClassID(); + +#ifdef FWL_UseMacSystemBorder + switch (dwMsgCode) { - case FWL_MSGHASH_Activate: { + case CFWL_MessageType::Activate: { m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated; m_pOwner->Repaint(&m_pOwner->m_rtRelative); break; } - case FWL_MSGHASH_Deactivate: { + case CFWL_MessageType::Deactivate: { m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated; m_pOwner->Repaint(&m_pOwner->m_rtRelative); break; @@ -877,48 +882,44 @@ int32_t CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { } return FWL_ERR_Succeeded; #else - if (!pMessage) - return 0; - uint32_t dwMsgCode = pMessage->GetClassID(); int32_t iRet = 1; switch (dwMsgCode) { - case FWL_MSGHASH_Activate: { + case CFWL_MessageType::Activate: { m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated; IFWL_Thread* pThread = m_pOwner->GetOwnerThread(); CFWL_NoteDriver* pDriver = static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); CFWL_WidgetImp* pSubFocusImp = m_pOwner->GetSubFocus(); IFWL_Widget* pSubFocus = - pSubFocusImp ? pSubFocusImp->GetInterface() : NULL; - if (pSubFocus && pSubFocus != pDriver->GetFocus()) { + pSubFocusImp ? pSubFocusImp->GetInterface() : nullptr; + if (pSubFocus && pSubFocus != pDriver->GetFocus()) pDriver->SetFocus(pSubFocus); - } + m_pOwner->Repaint(&m_pOwner->m_rtRelative); break; } - case FWL_MSGHASH_Deactivate: { + case CFWL_MessageType::Deactivate: { m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated; IFWL_Thread* pThread = m_pOwner->GetOwnerThread(); CFWL_NoteDriver* pDriver = static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver()); CFWL_WidgetImp* pSubFocusImp = m_pOwner->GetSubFocus(); IFWL_Widget* pSubFocus = - pSubFocusImp ? pSubFocusImp->GetInterface() : NULL; + pSubFocusImp ? pSubFocusImp->GetInterface() : nullptr; if (pSubFocus) { if (pSubFocus == pDriver->GetFocus()) { - pDriver->SetFocus(NULL); + pDriver->SetFocus(nullptr); } else if (pSubFocus->GetStates() & FWL_WGTSTATE_Focused) { CFWL_MsgKillFocus ms; - IFWL_WidgetDelegate* pDelegate = pSubFocus->SetDelegate(NULL); - if (pDelegate) { + IFWL_WidgetDelegate* pDelegate = pSubFocus->SetDelegate(nullptr); + if (pDelegate) pDelegate->OnProcessMessage(&ms); - } } } m_pOwner->Repaint(&m_pOwner->m_rtRelative); break; } - case FWL_MSGHASH_Mouse: { + case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); switch (pMsg->m_dwCmd) { case FWL_MSGMOUSECMD_LButtonDown: { @@ -948,15 +949,16 @@ int32_t CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { } break; } - case FWL_MSGHASH_Size: { + case CFWL_MessageType::Size: { CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); if (!pWidgetMgr) return 0; + pWidgetMgr->AddRedrawCounts(m_pOwner->m_pInterface); - if (!m_pOwner->m_bSetMaximize) { + if (!m_pOwner->m_bSetMaximize) break; - } + m_pOwner->m_bSetMaximize = FALSE; CFWL_MsgSize* pMsg = static_cast<CFWL_MsgSize*>(pMessage); CFX_RectF rt; @@ -968,27 +970,29 @@ int32_t CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { m_pOwner->Update(); break; } - case FWL_MSGHASH_WindowMove: { + case CFWL_MessageType::WindowMove: { OnWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage)); break; } - case FWL_MSGHASH_Close: { + case CFWL_MessageType::Close: { OnClose(static_cast<CFWL_MsgClose*>(pMessage)); break; } - default: { iRet = 0; } + default: { + iRet = 0; + break; + } } return iRet; -#endif +#endif // FWL_UseMacSystemBorder } + FWL_ERR CFWL_FormImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { if (!pEvent) return FWL_ERR_Indefinite; - if (pEvent->GetClassID() == FWL_EVTHASH_Close && - pEvent->m_pSrcTarget == m_pOwner->m_pInterface) { - } return FWL_ERR_Succeeded; } + FWL_ERR CFWL_FormImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { return m_pOwner->DrawWidget(pGraphics, pMatrix); diff --git a/xfa/fwl/core/fwl_noteimp.cpp b/xfa/fwl/core/fwl_noteimp.cpp index a01eea9138..b2e7440761 100644 --- a/xfa/fwl/core/fwl_noteimp.cpp +++ b/xfa/fwl/core/fwl_noteimp.cpp @@ -34,7 +34,7 @@ FWL_ERR CFWL_NoteLoop::Idle(int32_t count) { IFWL_NoteDriver* pDriver = pApp->GetNoteDriver(); if (!pDriver) return FWL_ERR_Indefinite; - pDriver->SendNote(&ev); + pDriver->SendEvent(&ev); #if (_FX_OS_ == _FX_WIN32_DESKTOP_) } #endif @@ -69,7 +69,7 @@ void CFWL_NoteLoop::GenerateCommondEvent(uint32_t dwCommand) { IFWL_NoteDriver* pDriver = pThread->GetNoteDriver(); if (!pDriver) return; - pDriver->SendNote(&ev); + pDriver->SendEvent(&ev); } CFWL_NoteDriver::CFWL_NoteDriver() : m_sendEventCalled(0), @@ -83,47 +83,37 @@ CFWL_NoteDriver::~CFWL_NoteDriver() { delete m_pNoteLoop; ClearInvalidEventTargets(TRUE); } -FX_BOOL CFWL_NoteDriver::SendNote(CFWL_Note* pNote) { - if (pNote->IsEvent()) { - int32_t iCount = m_eventTargets.GetCount(); - if (iCount < 1) { - return TRUE; - } - if (FWL_EVTHASH_Mouse == static_cast<CFWL_Event*>(pNote)->GetClassID()) { - CFWL_EvtMouse* pMouse = static_cast<CFWL_EvtMouse*>(pNote); - if (FWL_MSGMOUSECMD_MouseHover == pMouse->m_dwCmd) { - if (m_pNoteLoop->GetForm() && - CFWL_ToolTipContainer::getInstance()->ProcessEnter( - pMouse, m_pNoteLoop->GetForm()->GetInterface())) { - } - } else if (FWL_MSGMOUSECMD_MouseLeave == pMouse->m_dwCmd) { - if (CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse)) { - } - } else if ((FWL_MSGMOUSECMD_LButtonDown <= pMouse->m_dwCmd) && - (FWL_MSGMOUSECMD_MButtonDblClk >= pMouse->m_dwCmd)) { - if (CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse)) { - } - } - } - m_sendEventCalled++; - FX_POSITION pos = m_eventTargets.GetStartPosition(); - while (pos) { - void* key = NULL; - CFWL_EventTarget* pEventTarget; - m_eventTargets.GetNextAssoc(pos, key, (void*&)pEventTarget); - if (pEventTarget && !pEventTarget->IsInvalid()) { - pEventTarget->ProcessEvent(static_cast<CFWL_Event*>(pNote)); + +FX_BOOL CFWL_NoteDriver::SendEvent(CFWL_Event* pNote) { + int32_t iCount = m_eventTargets.GetCount(); + if (iCount < 1) + return TRUE; + if (CFWL_EventType::Mouse == pNote->GetClassID()) { + CFWL_EvtMouse* pMouse = static_cast<CFWL_EvtMouse*>(pNote); + if (FWL_MSGMOUSECMD_MouseHover == pMouse->m_dwCmd) { + if (m_pNoteLoop->GetForm() && + CFWL_ToolTipContainer::getInstance()->ProcessEnter( + pMouse, m_pNoteLoop->GetForm()->GetInterface())) { } - } - m_sendEventCalled--; - } else { - if (!pNote->m_pDstTarget) - return FALSE; - IFWL_WidgetDelegate* pDelegate = pNote->m_pDstTarget->SetDelegate(NULL); - if (pDelegate) { - pDelegate->OnProcessMessage(static_cast<CFWL_Message*>(pNote)); + } else if (FWL_MSGMOUSECMD_MouseLeave == pMouse->m_dwCmd) { + CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse); + } else if ((FWL_MSGMOUSECMD_LButtonDown <= pMouse->m_dwCmd) && + (FWL_MSGMOUSECMD_MButtonDblClk >= pMouse->m_dwCmd)) { + CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse); } } + m_sendEventCalled++; + FX_POSITION pos = m_eventTargets.GetStartPosition(); + while (pos) { + void* key = nullptr; + void* value = nullptr; + m_eventTargets.GetNextAssoc(pos, key, value); + + CFWL_EventTarget* pEventTarget = static_cast<CFWL_EventTarget*>(value); + if (pEventTarget && !pEventTarget->IsInvalid()) + pEventTarget->ProcessEvent(pNote); + } + m_sendEventCalled--; return TRUE; } @@ -390,61 +380,61 @@ FX_BOOL CFWL_NoteDriver::ProcessMessage(CFWL_Message* pMessage) { if (!pMessageForm) return FALSE; if (DispatchMessage(pMessage, pMessageForm)) { - if (pMessage->GetClassID() == FWL_MSGHASH_Mouse) { + if (pMessage->GetClassID() == CFWL_MessageType::Mouse) MouseSecondary(static_cast<CFWL_MsgMouse*>(pMessage)); - } return TRUE; } return FALSE; } + FX_BOOL CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage, IFWL_Widget* pMessageForm) { FX_BOOL bRet = FALSE; switch (pMessage->GetClassID()) { - case FWL_MSGHASH_Activate: { + case CFWL_MessageType::Activate: { bRet = DoActivate(static_cast<CFWL_MsgActivate*>(pMessage), pMessageForm); break; } - case FWL_MSGHASH_Deactivate: { + case CFWL_MessageType::Deactivate: { bRet = DoDeactivate(static_cast<CFWL_MsgDeactivate*>(pMessage), pMessageForm); break; } - case FWL_MSGHASH_SetFocus: { + case CFWL_MessageType::SetFocus: { bRet = DoSetFocus(static_cast<CFWL_MsgSetFocus*>(pMessage), pMessageForm); break; } - case FWL_MSGHASH_KillFocus: { + case CFWL_MessageType::KillFocus: { bRet = DoKillFocus(static_cast<CFWL_MsgKillFocus*>(pMessage), pMessageForm); break; } - case FWL_MSGHASH_Key: { + case CFWL_MessageType::Key: { bRet = DoKey(static_cast<CFWL_MsgKey*>(pMessage), pMessageForm); break; } - case FWL_MSGHASH_Mouse: { + case CFWL_MessageType::Mouse: { bRet = DoMouse(static_cast<CFWL_MsgMouse*>(pMessage), pMessageForm); break; } - case FWL_MSGHASH_MouseWheel: { + case CFWL_MessageType::MouseWheel: { bRet = DoWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage), pMessageForm); break; } - case FWL_MSGHASH_Size: { + case CFWL_MessageType::Size: { bRet = DoSize(static_cast<CFWL_MsgSize*>(pMessage)); break; } - case FWL_MSGHASH_Cursor: { + case CFWL_MessageType::Cursor: { bRet = TRUE; break; } - case FWL_MSGHASH_WindowMove: { + case CFWL_MessageType::WindowMove: { bRet = DoWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage), pMessageForm); break; } - case FWL_MSGHASH_DropFiles: { + case CFWL_MessageType::DropFiles: { bRet = DoDragFiles(static_cast<CFWL_MsgDropFiles*>(pMessage), pMessageForm); break; @@ -456,12 +446,12 @@ FX_BOOL CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage, } if (bRet) { IFWL_WidgetDelegate* pDelegate = pMessage->m_pDstTarget->SetDelegate(NULL); - if (pDelegate) { + if (pDelegate) pDelegate->OnProcessMessage(pMessage); - } } return bRet; } + FX_BOOL CFWL_NoteDriver::DoActivate(CFWL_MsgActivate* pMsg, IFWL_Widget* pMessageForm) { pMsg->m_pDstTarget = pMessageForm; @@ -686,26 +676,25 @@ void CFWL_NoteDriver::MouseSecondary(CFWL_MsgMouse* pMsg) { DispatchMessage(&msHover, NULL); } FX_BOOL CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) { - if (pMessage->GetClassID() == FWL_MSGHASH_Post) { + if (pMessage->GetClassID() == CFWL_MessageType::Post) return TRUE; - } + int32_t iCount = m_noteLoopQueue.GetSize(); for (int32_t i = 0; i < iCount; i++) { CFWL_NoteLoop* pNoteLoop = static_cast<CFWL_NoteLoop*>(m_noteLoopQueue[i]); CFWL_WidgetImp* pForm = pNoteLoop->GetForm(); - if (pForm && (pForm->GetInterface() == pMessage->m_pDstTarget)) { + if (pForm && (pForm->GetInterface() == pMessage->m_pDstTarget)) return TRUE; - } } iCount = m_forms.GetSize(); for (int32_t j = 0; j < iCount; j++) { CFWL_FormImp* pForm = static_cast<CFWL_FormImp*>(m_forms[j]); - if (pForm->GetInterface() == pMessage->m_pDstTarget) { + if (pForm->GetInterface() == pMessage->m_pDstTarget) return TRUE; - } } return FALSE; } + IFWL_Widget* CFWL_NoteDriver::GetMessageForm(IFWL_Widget* pDstTarget) { int32_t iTrackLoop = m_noteLoopQueue.GetSize(); if (iTrackLoop <= 0) @@ -791,6 +780,7 @@ int32_t CFWL_EventTarget::SetEventSource(IFWL_Widget* pSource, } return 1; } + FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) { IFWL_WidgetDelegate* pDelegate = m_pListener->SetDelegate(NULL); if (!pDelegate) @@ -805,7 +795,7 @@ FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) { uint32_t dwFilter = 0; m_eventSources.GetNextAssoc(pos, (void*&)pSource, dwFilter); if (pSource == pEvent->m_pSrcTarget || - pEvent->GetClassID() == FWL_EVTHASH_Idle) { + pEvent->GetClassID() == CFWL_EventType::Idle) { if (IsFilterEvent(pEvent, dwFilter)) { pDelegate->OnProcessEvent(pEvent); return TRUE; @@ -814,42 +804,43 @@ FX_BOOL CFWL_EventTarget::ProcessEvent(CFWL_Event* pEvent) { } return FALSE; } + FX_BOOL CFWL_EventTarget::IsFilterEvent(CFWL_Event* pEvent, uint32_t dwFilter) { - if (dwFilter == FWL_EVENT_ALL_MASK) { + if (dwFilter == FWL_EVENT_ALL_MASK) return TRUE; - } + FX_BOOL bRet = FALSE; switch (pEvent->GetClassID()) { - case FWL_EVTHASH_Mouse: { + case CFWL_EventType::Mouse: { bRet = dwFilter & FWL_EVENT_MOUSE_MASK; break; } - case FWL_EVTHASH_MouseWheel: { + case CFWL_EventType::MouseWheel: { bRet = dwFilter & FWL_EVENT_MOUSEWHEEL_MASK; break; } - case FWL_EVTHASH_Key: { + case CFWL_EventType::Key: { bRet = dwFilter & FWL_EVENT_KEY_MASK; break; } - case FWL_EVTHASH_SetFocus: - case FWL_EVTHASH_KillFocus: { + case CFWL_EventType::SetFocus: + case CFWL_EventType::KillFocus: { bRet = dwFilter & FWL_EVENT_FOCUSCHANGED_MASK; break; } - case FWL_EVTHASH_Draw: { + case CFWL_EventType::Draw: { bRet = dwFilter & FWL_EVENT_DRAW_MASK; break; } - case FWL_EVTHASH_Close: { + case CFWL_EventType::Close: { bRet = dwFilter & FWL_EVENT_CLOSE_MASK; break; } - case FWL_EVTHASH_SizeChanged: { + case CFWL_EventType::SizeChanged: { bRet = dwFilter & FWL_EVENT_SIZECHANGED_MASK; break; } - case FWL_EVTHASH_Idle: { + case CFWL_EventType::Idle: { bRet = dwFilter & FWL_EVENT_IDLE_MASK; break; } diff --git a/xfa/fwl/core/fwl_noteimp.h b/xfa/fwl/core/fwl_noteimp.h index 0a0c8424e8..334c70535b 100644 --- a/xfa/fwl/core/fwl_noteimp.h +++ b/xfa/fwl/core/fwl_noteimp.h @@ -52,9 +52,9 @@ class CFWL_NoteDriver : public IFWL_NoteDriver { ~CFWL_NoteDriver() override; // IFWL_NoteDriver: - FX_BOOL SendNote(CFWL_Note* pNote) override; + FX_BOOL SendEvent(CFWL_Event* pNote) override; FWL_ERR RegisterEventTarget(IFWL_Widget* pListener, - IFWL_Widget* pEventSource = NULL, + IFWL_Widget* pEventSource = nullptr, uint32_t dwFilter = FWL_EVENT_ALL_MASK) override; FWL_ERR UnregisterEventTarget(IFWL_Widget* pListener) override; void ClearEventTargets(FX_BOOL bRemoveAll) override; diff --git a/xfa/fwl/core/fwl_widgetimp.cpp b/xfa/fwl/core/fwl_widgetimp.cpp index b11530eab5..f6be8cac5e 100644 --- a/xfa/fwl/core/fwl_widgetimp.cpp +++ b/xfa/fwl/core/fwl_widgetimp.cpp @@ -853,7 +853,7 @@ void CFWL_WidgetImp::DispatchEvent(CFWL_Event* pEvent) { IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); if (!pNoteDriver) return; - pNoteDriver->SendNote(pEvent); + pNoteDriver->SendEvent(pEvent); } void CFWL_WidgetImp::Repaint(const CFX_RectF* pRect) { if (pRect) { @@ -952,15 +952,18 @@ FX_BOOL CFWL_WidgetImp::IsParent(IFWL_Widget* pParent) { } return FALSE; } + CFWL_WidgetImpDelegate::CFWL_WidgetImpDelegate() {} + int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { if (!pMessage->m_pDstTarget) return 0; + CFWL_WidgetImp* pWidget = static_cast<CFWL_WidgetImp*>(pMessage->m_pDstTarget->GetImpl()); - uint32_t dwMsgCode = pMessage->GetClassID(); + CFWL_MessageType dwMsgCode = pMessage->GetClassID(); switch (dwMsgCode) { - case FWL_MSGHASH_Mouse: { + case CFWL_MessageType::Mouse: { CFWL_MsgMouse* pMsgMouse = static_cast<CFWL_MsgMouse*>(pMessage); CFWL_EvtMouse evt; evt.m_pSrcTarget = pWidget->m_pInterface; @@ -972,7 +975,7 @@ int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { pWidget->DispatchEvent(&evt); break; } - case FWL_MSGHASH_MouseWheel: { + case CFWL_MessageType::MouseWheel: { CFWL_MsgMouseWheel* pMsgMouseWheel = static_cast<CFWL_MsgMouseWheel*>(pMessage); CFWL_EvtMouseWheel evt; @@ -986,7 +989,7 @@ int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { pWidget->DispatchEvent(&evt); break; } - case FWL_MSGHASH_Key: { + case CFWL_MessageType::Key: { CFWL_MsgKey* pMsgKey = static_cast<CFWL_MsgKey*>(pMessage); CFWL_EvtKey evt; evt.m_pSrcTarget = pWidget->m_pInterface; @@ -997,7 +1000,7 @@ int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { pWidget->DispatchEvent(&evt); break; } - case FWL_MSGHASH_SetFocus: { + case CFWL_MessageType::SetFocus: { CFWL_MsgSetFocus* pMsgSetFocus = static_cast<CFWL_MsgSetFocus*>(pMessage); CFWL_EvtSetFocus evt; evt.m_pSrcTarget = pMsgSetFocus->m_pDstTarget; @@ -1006,7 +1009,7 @@ int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { pWidget->DispatchEvent(&evt); break; } - case FWL_MSGHASH_KillFocus: { + case CFWL_MessageType::KillFocus: { CFWL_MsgKillFocus* pMsgKillFocus = static_cast<CFWL_MsgKillFocus*>(pMessage); CFWL_EvtKillFocus evt; @@ -1016,13 +1019,16 @@ int32_t CFWL_WidgetImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { pWidget->DispatchEvent(&evt); break; } - default: {} + default: + break; } return 1; } + FWL_ERR CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { return FWL_ERR_Succeeded; } + FWL_ERR CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { CFWL_EvtDraw evt; diff --git a/xfa/fwl/core/ifwl_notedriver.h b/xfa/fwl/core/ifwl_notedriver.h index 783bebcd10..4bf265593c 100644 --- a/xfa/fwl/core/ifwl_notedriver.h +++ b/xfa/fwl/core/ifwl_notedriver.h @@ -29,7 +29,8 @@ class IFWL_NoteDriver { public: virtual ~IFWL_NoteDriver() {} - virtual FX_BOOL SendNote(CFWL_Note* pNote) = 0; + virtual FX_BOOL SendEvent(CFWL_Event* pNote) = 0; + virtual FWL_ERR RegisterEventTarget( IFWL_Widget* pListener, IFWL_Widget* pEventSource = NULL, diff --git a/xfa/fwl/lightwidget/cfwl_widget.cpp b/xfa/fwl/lightwidget/cfwl_widget.cpp index 071940fe36..31c54d8efa 100644 --- a/xfa/fwl/lightwidget/cfwl_widget.cpp +++ b/xfa/fwl/lightwidget/cfwl_widget.cpp @@ -298,7 +298,7 @@ void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver(); if (!pNoteDriver) return; - pNoteDriver->SendNote(pEvent); + pNoteDriver->SendEvent(pEvent); } #define FWL_WGT_CalcHeight 2048 diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp index 85f445fedc..4527afef7d 100644 --- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp +++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp @@ -298,11 +298,11 @@ FX_BOOL CXFA_FFCheckButton::UpdateFWLData() { int32_t CXFA_FFCheckButton::OnProcessMessage(CFWL_Message* pMessage) { return m_pOldDelegate->OnProcessMessage(pMessage); } + FWL_ERR CXFA_FFCheckButton::OnProcessEvent(CFWL_Event* pEvent) { CXFA_FFField::OnProcessEvent(pEvent); - uint32_t dwEventID = pEvent->GetClassID(); - switch (dwEventID) { - case FWL_EVTHASH_CKB_CheckStateChanged: { + switch (pEvent->GetClassID()) { + case CFWL_EventType::CheckStateChanged: { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_Change; m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); @@ -327,10 +327,12 @@ FWL_ERR CXFA_FFCheckButton::OnProcessEvent(CFWL_Event* pEvent) { m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam); break; } - default: {} + default: + break; } return m_pOldDelegate->OnProcessEvent(pEvent); } + FWL_ERR CXFA_FFCheckButton::OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp index a13c36d973..cfd78c2035 100644 --- a/xfa/fxfa/app/xfa_ffchoicelist.cpp +++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp @@ -185,14 +185,14 @@ int32_t CXFA_FFListBox::OnProcessMessage(CFWL_Message* pMessage) { } FWL_ERR CXFA_FFListBox::OnProcessEvent(CFWL_Event* pEvent) { CXFA_FFField::OnProcessEvent(pEvent); - uint32_t dwEventID = pEvent->GetClassID(); - switch (dwEventID) { - case FWL_EVTHASH_LTB_SelChanged: { + switch (pEvent->GetClassID()) { + case CFWL_EventType::SelectChanged: { CFX_Int32Array arrSels; OnSelectChanged(m_pNormalWidget->GetWidget(), arrSels); break; } - default: {} + default: + break; } return m_pOldDelegate->OnProcessEvent(pEvent); } @@ -498,33 +498,35 @@ void CXFA_FFComboBox::OnPostOpen(IFWL_Widget* pWidget) { int32_t CXFA_FFComboBox::OnProcessMessage(CFWL_Message* pMessage) { return m_pOldDelegate->OnProcessMessage(pMessage); } + FWL_ERR CXFA_FFComboBox::OnProcessEvent(CFWL_Event* pEvent) { CXFA_FFField::OnProcessEvent(pEvent); - uint32_t dwEventID = pEvent->GetClassID(); - switch (dwEventID) { - case FWL_EVTHASH_CMB_SelChanged: { + switch (pEvent->GetClassID()) { + case CFWL_EventType::SelectChanged: { CFWL_EvtCmbSelChanged* postEvent = (CFWL_EvtCmbSelChanged*)pEvent; OnSelectChanged(m_pNormalWidget->GetWidget(), postEvent->iArraySels, postEvent->bLButtonUp); break; } - case FWL_EVTHASH_CMB_EditChanged: { + case CFWL_EventType::EditChanged: { CFX_WideString wsChanged; OnTextChanged(m_pNormalWidget->GetWidget(), wsChanged); break; } - case FWL_EVTHASH_CMB_PreDropDown: { + case CFWL_EventType::PreDropDown: { OnPreOpen(m_pNormalWidget->GetWidget()); break; } - case FWL_EVTHASH_CMB_PostDropDown: { + case CFWL_EventType::PostDropDown: { OnPostOpen(m_pNormalWidget->GetWidget()); break; } - default: {} + default: + break; } return m_pOldDelegate->OnProcessEvent(pEvent); } + FWL_ERR CXFA_FFComboBox::OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp index 745f44d7e3..872dc8f3ce 100644 --- a/xfa/fxfa/app/xfa_fffield.cpp +++ b/xfa/fxfa/app/xfa_fffield.cpp @@ -794,10 +794,10 @@ void CXFA_FFField::TranslateFWLMessage(CFWL_Message* pMessage) { int32_t CXFA_FFField::OnProcessMessage(CFWL_Message* pMessage) { return FWL_ERR_Succeeded; } + FWL_ERR CXFA_FFField::OnProcessEvent(CFWL_Event* pEvent) { - uint32_t dwEventID = pEvent->GetClassID(); - switch (dwEventID) { - case FWL_EVTHASH_Mouse: { + switch (pEvent->GetClassID()) { + case CFWL_EventType::Mouse: { CFWL_EvtMouse* event = (CFWL_EvtMouse*)pEvent; if (event->m_dwCmd == FWL_MSGMOUSECMD_MouseEnter) { CXFA_EventParam eParam; @@ -822,17 +822,19 @@ FWL_ERR CXFA_FFField::OnProcessEvent(CFWL_Event* pEvent) { } break; } - case FWL_EVTHASH_Click: { + case CFWL_EventType::Click: { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_Click; eParam.m_pTarget = m_pDataAcc; m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Click, &eParam); break; } - default: {} + default: + break; } return FWL_ERR_Succeeded; } + FWL_ERR CXFA_FFField::OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { return FWL_ERR_Succeeded; diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp index 5b543db14d..baa1d8aca6 100644 --- a/xfa/fxfa/app/xfa_fftextedit.cpp +++ b/xfa/fxfa/app/xfa_fftextedit.cpp @@ -403,36 +403,38 @@ FX_BOOL CXFA_FFTextEdit::GetSuggestWords( int32_t CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) { return m_pOldDelegate->OnProcessMessage(pMessage); } + FWL_ERR CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { CXFA_FFField::OnProcessEvent(pEvent); - uint32_t dwEventID = pEvent->GetClassID(); - switch (dwEventID) { - case FWL_EVTHASH_EDT_TextChanged: { + switch (pEvent->GetClassID()) { + case CFWL_EventType::TextChanged: { CFWL_EvtEdtTextChanged* event = (CFWL_EvtEdtTextChanged*)pEvent; CFX_WideString wsChange; OnTextChanged(m_pNormalWidget->GetWidget(), wsChange, event->wsPrevText); break; } - case FWL_EVTHASH_EDT_TextFull: { + case CFWL_EventType::TextFull: { OnTextFull(m_pNormalWidget->GetWidget()); break; } - case FWL_EVTHASH_EDT_CheckWord: { + case CFWL_EventType::CheckWord: { CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged"); CFWL_EvtEdtCheckWord* event = (CFWL_EvtEdtCheckWord*)pEvent; event->bCheckWord = CheckWord(event->bsWord.AsStringC()); break; } - case FWL_EVTHASH_EDT_GetSuggestWords: { + case CFWL_EventType::GetSuggestedWords: { CFWL_EvtEdtGetSuggestWords* event = (CFWL_EvtEdtGetSuggestWords*)pEvent; event->bSuggestWords = GetSuggestWords(event->bsWord.AsStringC(), event->bsArraySuggestWords); break; } - default: {} + default: + break; } return m_pOldDelegate->OnProcessEvent(pEvent); } + FWL_ERR CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); @@ -483,17 +485,17 @@ void CXFA_FFNumericEdit::UpdateWidgetProperty() { } m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); } + FWL_ERR CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) { - uint32_t dwEventID = pEvent->GetClassID(); - if (dwEventID == FWL_EVTHASH_EDT_Validate) { + if (pEvent->GetClassID() == CFWL_EventType::Validate) { CFWL_EvtEdtValidate* event = (CFWL_EvtEdtValidate*)pEvent; CFX_WideString wsChange = event->wsInsert; event->bValidate = OnValidate(m_pNormalWidget->GetWidget(), wsChange); return event->bValidate; - } else { - return CXFA_FFTextEdit::OnProcessEvent(pEvent); } + return CXFA_FFTextEdit::OnProcessEvent(pEvent); } + FX_BOOL CXFA_FFNumericEdit::OnValidate(IFWL_Widget* pWidget, CFX_WideString& wsText) { CFX_WideString wsPattern; @@ -785,14 +787,13 @@ void CXFA_FFDateTimeEdit::OnSelectChanged(IFWL_Widget* pWidget, m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); } + FWL_ERR CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { - uint32_t dwEventID = pEvent->GetClassID(); - if (dwEventID == FWL_EVTHASH_DTP_SelectChanged) { + if (pEvent->GetClassID() == CFWL_EventType::SelectChanged) { CFWL_Event_DtpSelectChanged* event = (CFWL_Event_DtpSelectChanged*)pEvent; OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth, event->iDay); return TRUE; - } else { - return CXFA_FFTextEdit::OnProcessEvent(pEvent); } + return CXFA_FFTextEdit::OnProcessEvent(pEvent); } |