summaryrefslogtreecommitdiff
path: root/xfa/fwl/core
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-05-05 10:28:02 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-05 10:28:03 -0700
commitb4d40ffae3f955fab2fac838430c89aca452c45f (patch)
tree046c0a461e9dc0dc295da5839b831e4b53526541 /xfa/fwl/core
parent439bb9e0b2f72cd1ede65b84130fe9ed573f74b0 (diff)
downloadpdfium-b4d40ffae3f955fab2fac838430c89aca452c45f.tar.xz
Remove CLASSHASH defines in favour of an enum class.
This Cl updates all the CLASSHASH defines to use an enum class. A few defines where unabled and were either updated or removed if the number no longer exists in the code base. Review-Url: https://codereview.chromium.org/1946213003
Diffstat (limited to 'xfa/fwl/core')
-rw-r--r--xfa/fwl/core/fwl_formimp.cpp4
-rw-r--r--xfa/fwl/core/fwl_formimp.h44
-rw-r--r--xfa/fwl/core/fwl_noteimp.cpp11
-rw-r--r--xfa/fwl/core/fwl_widgetimp.cpp33
-rw-r--r--xfa/fwl/core/fwl_widgetimp.h3
-rw-r--r--xfa/fwl/core/fwl_widgetmgrimp.cpp51
-rw-r--r--xfa/fwl/core/ifwl_form.h2
-rw-r--r--xfa/fwl/core/ifwl_themeprovider.h2
-rw-r--r--xfa/fwl/core/ifwl_widget.h22
9 files changed, 74 insertions, 98 deletions
diff --git a/xfa/fwl/core/fwl_formimp.cpp b/xfa/fwl/core/fwl_formimp.cpp
index 202a092395..bcaba2c153 100644
--- a/xfa/fwl/core/fwl_formimp.cpp
+++ b/xfa/fwl/core/fwl_formimp.cpp
@@ -104,8 +104,8 @@ FWL_Error CFWL_FormImp::GetClassName(CFX_WideString& wsClass) const {
return FWL_Error::Succeeded;
}
-uint32_t CFWL_FormImp::GetClassID() const {
- return FWL_CLASSHASH_Form;
+FWL_Type CFWL_FormImp::GetClassID() const {
+ return FWL_Type::Form;
}
FX_BOOL CFWL_FormImp::IsInstance(const CFX_WideStringC& wsClass) const {
diff --git a/xfa/fwl/core/fwl_formimp.h b/xfa/fwl/core/fwl_formimp.h
index f1bc51df37..9d2d394d03 100644
--- a/xfa/fwl/core/fwl_formimp.h
+++ b/xfa/fwl/core/fwl_formimp.h
@@ -68,27 +68,29 @@ typedef struct RestoreResizeInfo {
class CFWL_FormImp : public CFWL_WidgetImp {
public:
CFWL_FormImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter);
- virtual ~CFWL_FormImp();
- virtual FWL_Error GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
- virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
- virtual FWL_Error Initialize();
- virtual FWL_Error Finalize();
-
- virtual FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
- virtual FWL_Error GetClientRect(CFX_RectF& rect);
- virtual FWL_Error Update();
- virtual FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy);
- virtual FWL_Error DrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
- virtual FWL_FORMSIZE GetFormSize();
- virtual FWL_Error SetFormSize(FWL_FORMSIZE eFormSize);
- virtual IFWL_Widget* DoModal();
- virtual IFWL_Widget* DoModal(uint32_t& dwCommandID);
- virtual FWL_Error EndDoModal();
- virtual FWL_Error SetBorderRegion(CFX_Path* pPath);
- virtual void DrawBackground(CFX_Graphics* pGraphics,
- IFWL_ThemeProvider* pTheme);
+ ~CFWL_FormImp() override;
+
+ // CFWL_WidgetImp
+ FWL_Error GetClassName(CFX_WideString& wsClass) const override;
+ FWL_Type GetClassID() const override;
+ FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const override;
+ FWL_Error Initialize() override;
+ FWL_Error Finalize() override;
+
+ FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
+ FWL_Error GetClientRect(CFX_RectF& rect) override;
+ FWL_Error Update() override;
+ FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override;
+ FWL_Error DrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = nullptr) override;
+
+ FWL_FORMSIZE GetFormSize();
+ FWL_Error SetFormSize(FWL_FORMSIZE eFormSize);
+ IFWL_Widget* DoModal();
+ IFWL_Widget* DoModal(uint32_t& dwCommandID);
+ FWL_Error EndDoModal();
+ FWL_Error SetBorderRegion(CFX_Path* pPath);
+ void DrawBackground(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme);
CFWL_WidgetImp* GetSubFocus();
void SetSubFocus(CFWL_WidgetImp* pWidget);
diff --git a/xfa/fwl/core/fwl_noteimp.cpp b/xfa/fwl/core/fwl_noteimp.cpp
index 560dc3c535..5cb66efed6 100644
--- a/xfa/fwl/core/fwl_noteimp.cpp
+++ b/xfa/fwl/core/fwl_noteimp.cpp
@@ -426,7 +426,8 @@ FX_BOOL CFWL_NoteDriver::DoDeactivate(CFWL_MsgDeactivate* pMsg,
pMsg->m_pSrcTarget->IsInstance(FX_WSTRC(L"FWL_FORMPROXY"))) {
return FALSE;
}
- if (pMsg->m_pSrcTarget && pMsg->m_pSrcTarget->GetClassID() == 1111984755) {
+ if (pMsg->m_pSrcTarget &&
+ pMsg->m_pSrcTarget->GetClassID() == FWL_Type::ToolTip) {
return FALSE;
}
return TRUE;
@@ -616,10 +617,10 @@ void CFWL_NoteDriver::MouseSecondary(CFWL_MsgMouse* pMsg) {
pTarget->TransformTo(m_pHover, msLeave.m_fx, msLeave.m_fy);
msLeave.m_dwFlags = 0;
msLeave.m_dwCmd = FWL_MouseCommand::Leave;
- DispatchMessage(&msLeave, NULL);
+ DispatchMessage(&msLeave, nullptr);
}
- if (pTarget->GetClassID() == FWL_CLASSHASH_Form) {
- m_pHover = NULL;
+ if (pTarget->GetClassID() == FWL_Type::Form) {
+ m_pHover = nullptr;
return;
}
m_pHover = pTarget;
@@ -629,7 +630,7 @@ void CFWL_NoteDriver::MouseSecondary(CFWL_MsgMouse* pMsg) {
msHover.m_fy = pMsg->m_fy;
msHover.m_dwFlags = 0;
msHover.m_dwCmd = FWL_MouseCommand::Hover;
- DispatchMessage(&msHover, NULL);
+ DispatchMessage(&msHover, nullptr);
}
FX_BOOL CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) {
if (pMessage->GetClassID() == CFWL_MessageType::Post)
diff --git a/xfa/fwl/core/fwl_widgetimp.cpp b/xfa/fwl/core/fwl_widgetimp.cpp
index f45a66cc2d..e72a7f385a 100644
--- a/xfa/fwl/core/fwl_widgetimp.cpp
+++ b/xfa/fwl/core/fwl_widgetimp.cpp
@@ -23,7 +23,6 @@
#include "xfa/fwl/core/ifwl_themeprovider.h"
#include "xfa/fxfa/include/xfa_ffapp.h"
-#define FWL_CLASSHASH_Menu 3957949655
#define FWL_STYLEEXT_MNU_Vert (1L << 0)
IFWL_Widget::~IFWL_Widget() {}
@@ -32,7 +31,7 @@ FWL_Error IFWL_Widget::GetClassName(CFX_WideString& wsClass) const {
return m_pImpl->GetClassName(wsClass);
}
-uint32_t IFWL_Widget::GetClassID() const {
+FWL_Type IFWL_Widget::GetClassID() const {
return m_pImpl->GetClassID();
}
@@ -191,10 +190,6 @@ FWL_Error CFWL_WidgetImp::GetClassName(CFX_WideString& wsClass) const {
return FWL_Error::Succeeded;
}
-uint32_t CFWL_WidgetImp::GetClassID() const {
- return 0;
-}
-
FX_BOOL CFWL_WidgetImp::IsInstance(const CFX_WideStringC& wsClass) const {
return FALSE;
}
@@ -709,30 +704,26 @@ void CFWL_WidgetImp::SetGrab(FX_BOOL bSet) {
static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
pDriver->SetGrab(m_pInterface, bSet);
}
+
FX_BOOL CFWL_WidgetImp::GetPopupPos(FX_FLOAT fMinHeight,
FX_FLOAT fMaxHeight,
const CFX_RectF& rtAnchor,
CFX_RectF& rtPopup) {
- if (GetClassID() == FWL_CLASSHASH_Menu) {
- return GetPopupPosMenu(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
- } else {
- if (GetClassID() == FWL_CLASSHASH_ComboBox) {
- if (m_pWidgetMgr->IsFormDisabled()) {
- return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight,
- fMaxHeight, rtAnchor, rtPopup);
- } else {
- return GetPopupPosComboBox(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
- }
- } else if (GetClassID() == FWL_CLASSHASH_DateTimePicker &&
- m_pWidgetMgr->IsFormDisabled()) {
+ if (GetClassID() == FWL_Type::ComboBox) {
+ if (m_pWidgetMgr->IsFormDisabled()) {
return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight,
fMaxHeight, rtAnchor, rtPopup);
- } else {
- return GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
}
+ return GetPopupPosComboBox(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
}
- return FALSE;
+ if (GetClassID() == FWL_Type::DateTimePicker &&
+ m_pWidgetMgr->IsFormDisabled()) {
+ return m_pWidgetMgr->GetAdapterPopupPos(m_pInterface, fMinHeight,
+ fMaxHeight, rtAnchor, rtPopup);
+ }
+ return GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup);
}
+
FX_BOOL CFWL_WidgetImp::GetPopupPosMenu(FX_FLOAT fMinHeight,
FX_FLOAT fMaxHeight,
const CFX_RectF& rtAnchor,
diff --git a/xfa/fwl/core/fwl_widgetimp.h b/xfa/fwl/core/fwl_widgetimp.h
index 4af2872f41..1b1ccc4b74 100644
--- a/xfa/fwl/core/fwl_widgetimp.h
+++ b/xfa/fwl/core/fwl_widgetimp.h
@@ -23,6 +23,7 @@ class IFWL_App;
class IFWL_DataProvider;
class IFWL_ThemeProvider;
class IFWL_Widget;
+enum class FWL_Type;
class CFWL_WidgetImp {
public:
@@ -31,7 +32,7 @@ class CFWL_WidgetImp {
virtual FWL_Error Initialize();
virtual FWL_Error Finalize();
virtual FWL_Error GetClassName(CFX_WideString& wsClass) const;
- virtual uint32_t GetClassID() const;
+ virtual FWL_Type GetClassID() const = 0;
virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
virtual FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
diff --git a/xfa/fwl/core/fwl_widgetmgrimp.cpp b/xfa/fwl/core/fwl_widgetmgrimp.cpp
index 28500c2cb2..f4ceb78c48 100644
--- a/xfa/fwl/core/fwl_widgetmgrimp.cpp
+++ b/xfa/fwl/core/fwl_widgetmgrimp.cpp
@@ -461,25 +461,13 @@ IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent,
int32_t CFWL_WidgetMgr::CountRadioButtonGroup(IFWL_Widget* pFirst) {
int32_t iRet = 0;
IFWL_Widget* pChild = pFirst;
- while (pChild) {
- if ((pChild->GetStyles() & FWL_WGTSTYLE_Group) &&
- pChild->GetClassID() == 3811304691) {
- iRet++;
- }
+ while (pChild)
pChild = GetWidget(pChild, FWL_WGTRELATION_NextSibling);
- }
return iRet;
}
IFWL_Widget* CFWL_WidgetMgr::GetSiblingRadioButton(IFWL_Widget* pWidget,
FX_BOOL bNext) {
- while ((pWidget = GetWidget(pWidget, bNext ? FWL_WGTRELATION_NextSibling
- : FWL_WGTRELATION_PriorSibling)) !=
- NULL) {
- if (pWidget->GetClassID() == 3811304691) {
- return pWidget;
- }
- }
- return NULL;
+ return nullptr;
}
IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader(
IFWL_Widget* pRadioButton) {
@@ -493,10 +481,6 @@ IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader(
}
}
pNext = GetWidget(pRadioButton, FWL_WGTRELATION_LastSibling);
- if ((pNext->GetStyles() & FWL_WGTSTYLE_Group) &&
- pNext->GetClassID() == 3811304691) {
- return pNext;
- }
while ((pNext = GetSiblingRadioButton(pNext, FALSE)) && pNext &&
pNext != pRadioButton) {
if (pNext->GetStyles() & FWL_WGTSTYLE_Group) {
@@ -504,10 +488,6 @@ IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader(
}
}
pNext = GetWidget(pRadioButton, FWL_WGTRELATION_FirstSibling);
- if (pNext && (pNext->GetStyles() == FWL_WGTSTYLE_Group) &&
- pNext->GetClassID() == 3811304691) {
- return pNext;
- }
return GetSiblingRadioButton(pNext, TRUE);
}
void CFWL_WidgetMgr::GetSameGroupRadioButton(
@@ -519,9 +499,6 @@ void CFWL_WidgetMgr::GetSameGroupRadioButton(
}
int32_t iGroup = CountRadioButtonGroup(pFirst);
if (iGroup < 2) {
- if (pFirst->GetClassID() == 3811304691) {
- group.Add(pFirst);
- }
IFWL_Widget* pNext = pFirst;
while ((pNext = GetSiblingRadioButton(pNext, TRUE)) != NULL) {
group.Add(pNext);
@@ -532,24 +509,19 @@ void CFWL_WidgetMgr::GetSameGroupRadioButton(
do {
group.Add(pNext);
pNext = GetSiblingRadioButton(pNext, TRUE);
- if (!pNext) {
- if (pFirst->GetClassID() == 3811304691) {
- pNext = pFirst;
- } else {
- pNext = GetSiblingRadioButton(pFirst, TRUE);
- }
- }
+ if (!pNext)
+ pNext = GetSiblingRadioButton(pFirst, TRUE);
} while (pNext && ((pNext->GetStyles() & FWL_WGTSTYLE_Group) == 0));
}
IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) {
- if ((pParent->GetClassID() == 3521614244) &&
+ if ((pParent->GetClassID() == FWL_Type::PushButton) &&
(pParent->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) {
return pParent;
}
IFWL_Widget* child =
FWL_GetWidgetMgr()->GetWidget(pParent, FWL_WGTRELATION_FirstChild);
while (child) {
- if ((child->GetClassID() == 3521614244) &&
+ if ((child->GetClassID() == FWL_Type::PushButton) &&
(child->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) {
return child;
}
@@ -831,16 +803,7 @@ FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget,
FWL_GetWidgetMgr()->GetWidget(pWidget, FWL_WGTRELATION_FirstChild);
if (!pChild)
return TRUE;
- if (pChild->GetClassID() == 3150298670) {
- CFX_RectF rtTemp;
- pChild->GetWidgetRect(rtTemp);
- if (rtTemp.width >= rtWidget.width && rtTemp.height >= rtWidget.height) {
- pChild =
- FWL_GetWidgetMgr()->GetWidget(pChild, FWL_WGTRELATION_FirstChild);
- if (!pChild)
- return TRUE;
- }
- }
+
CFX_RectF rtChilds;
rtChilds.Empty();
FX_BOOL bChildIntersectWithDirty = FALSE;
diff --git a/xfa/fwl/core/ifwl_form.h b/xfa/fwl/core/ifwl_form.h
index 22d6ecea12..75bec50d8e 100644
--- a/xfa/fwl/core/ifwl_form.h
+++ b/xfa/fwl/core/ifwl_form.h
@@ -13,9 +13,7 @@
#include "xfa/fwl/core/cfwl_widgetimpproperties.h"
#define FWL_CLASS_Form L"FWL_FORM"
-#define FWL_CLASSHASH_Form 881567292
#define FWL_CLASS_FormProxy L"FWL_FORMPROXY"
-#define FWL_CLASSHASH_FormProxy 881567291
#define FWL_STYLEEXT_FRM_Resize (1L << 0)
#define FWL_STYLEEXT_FRM_NativeBorder (1L << 1)
#define FWL_STYLEEXT_FRM_RoundCorner (2L << 1)
diff --git a/xfa/fwl/core/ifwl_themeprovider.h b/xfa/fwl/core/ifwl_themeprovider.h
index 66e7e0c4fd..274b27958a 100644
--- a/xfa/fwl/core/ifwl_themeprovider.h
+++ b/xfa/fwl/core/ifwl_themeprovider.h
@@ -20,7 +20,7 @@ class IFWL_Widget;
class IFWL_ThemeProvider {
public:
virtual ~IFWL_ThemeProvider() {}
- virtual FX_BOOL IsValidWidget(IFWL_Widget* pWidget) = 0;
+ virtual bool IsValidWidget(IFWL_Widget* pWidget) = 0;
virtual uint32_t GetThemeID(IFWL_Widget* pWidget) = 0;
virtual uint32_t SetThemeID(IFWL_Widget* pWidget,
uint32_t dwThemeID,
diff --git a/xfa/fwl/core/ifwl_widget.h b/xfa/fwl/core/ifwl_widget.h
index 691e4606c5..8bbf8da469 100644
--- a/xfa/fwl/core/ifwl_widget.h
+++ b/xfa/fwl/core/ifwl_widget.h
@@ -26,6 +26,26 @@
// CFWL_... IFWL_... CFWL_...Imp
//
+enum class FWL_Type {
+ Unknown = 0,
+
+ Barcode,
+ Caret,
+ CheckBox,
+ ComboBox,
+ DateTimePicker,
+ Edit,
+ Form,
+ FormProxy,
+ ListBox,
+ MonthCalendar,
+ PictureBox,
+ PushButton,
+ ScrollBar,
+ SpinButton,
+ ToolTip
+};
+
class CFWL_WidgetImp;
class CFX_Graphics;
class IFWL_App;
@@ -79,7 +99,7 @@ class IFWL_Widget {
// These call into equivalent polymorphic methods of m_pImpl. There
// should be no need to override these in subclasses.
FWL_Error GetClassName(CFX_WideString& wsClass) const;
- uint32_t GetClassID() const;
+ FWL_Type GetClassID() const;
FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
FWL_Error Initialize();
FWL_Error Finalize();