summaryrefslogtreecommitdiff
path: root/xfa/fwl
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-11-10 11:01:16 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-10 11:01:16 -0800
commit3e577c2660c89646b56753839c1ec59c3ad187f4 (patch)
tree9b35b8cedcc885230ec521473ef2a3c9b5aaa6c6 /xfa/fwl
parentf3480661a20c259581e7c100b0d5d06950a9559b (diff)
downloadpdfium-3e577c2660c89646b56753839c1ec59c3ad187f4.tar.xz
Convert FWL_SCBCODE to an enum class
This Cl changes the enum into an enum class and updates calling code to pass the enum instead of a uint32_t Review-Url: https://codereview.chromium.org/2482253004
Diffstat (limited to 'xfa/fwl')
-rw-r--r--xfa/fwl/core/cfwl_event.h15
-rw-r--r--xfa/fwl/core/ifwl_edit.cpp23
-rw-r--r--xfa/fwl/core/ifwl_edit.h2
-rw-r--r--xfa/fwl/core/ifwl_listbox.cpp21
-rw-r--r--xfa/fwl/core/ifwl_listbox.h2
-rw-r--r--xfa/fwl/core/ifwl_scrollbar.cpp36
-rw-r--r--xfa/fwl/core/ifwl_scrollbar.h17
7 files changed, 52 insertions, 64 deletions
diff --git a/xfa/fwl/core/cfwl_event.h b/xfa/fwl/core/cfwl_event.h
index f43ebb7cc9..ba8a4d683f 100644
--- a/xfa/fwl/core/cfwl_event.h
+++ b/xfa/fwl/core/cfwl_event.h
@@ -13,6 +13,19 @@
#include "xfa/fwl/core/cfwl_message.h"
#include "xfa/fwl/core/fwl_error.h"
+enum class FWL_SCBCODE {
+ None = 1,
+ Min,
+ Max,
+ PageBackward,
+ PageForward,
+ StepBackward,
+ StepForward,
+ Pos,
+ TrackPos,
+ EndScroll,
+};
+
enum class CFWL_EventType {
None = 0,
@@ -137,7 +150,7 @@ FWL_EVENT_DEF(CFWL_EvtDraw, CFWL_EventType::Draw, CFX_Graphics* m_pGraphics;
FWL_EVENT_DEF(CFWL_EvtClick, CFWL_EventType::Click)
-FWL_EVENT_DEF(CFWL_EvtScroll, CFWL_EventType::Scroll, uint32_t m_iScrollCode;
+FWL_EVENT_DEF(CFWL_EvtScroll, CFWL_EventType::Scroll, FWL_SCBCODE m_iScrollCode;
FX_FLOAT m_fPos;
bool* m_pRet;)
diff --git a/xfa/fwl/core/ifwl_edit.cpp b/xfa/fwl/core/ifwl_edit.cpp
index 79896ea636..1679a5b16d 100644
--- a/xfa/fwl/core/ifwl_edit.cpp
+++ b/xfa/fwl/core/ifwl_edit.cpp
@@ -1928,56 +1928,55 @@ void IFWL_Edit::OnChar(CFWL_MsgKey* pMsg) {
}
bool IFWL_Edit::OnScroll(IFWL_ScrollBar* pScrollBar,
- uint32_t dwCode,
+ FWL_SCBCODE dwCode,
FX_FLOAT fPos) {
CFX_SizeF fs;
pScrollBar->GetRange(&fs.x, &fs.y);
FX_FLOAT iCurPos = pScrollBar->GetPos();
FX_FLOAT fStep = pScrollBar->GetStepSize();
switch (dwCode) {
- case FWL_SCBCODE_Min: {
+ case FWL_SCBCODE::Min: {
fPos = fs.x;
break;
}
- case FWL_SCBCODE_Max: {
+ case FWL_SCBCODE::Max: {
fPos = fs.y;
break;
}
- case FWL_SCBCODE_StepBackward: {
+ case FWL_SCBCODE::StepBackward: {
fPos -= fStep;
if (fPos < fs.x + fStep / 2) {
fPos = fs.x;
}
break;
}
- case FWL_SCBCODE_StepForward: {
+ case FWL_SCBCODE::StepForward: {
fPos += fStep;
if (fPos > fs.y - fStep / 2) {
fPos = fs.y;
}
break;
}
- case FWL_SCBCODE_PageBackward: {
+ case FWL_SCBCODE::PageBackward: {
fPos -= pScrollBar->GetPageSize();
if (fPos < fs.x) {
fPos = fs.x;
}
break;
}
- case FWL_SCBCODE_PageForward: {
+ case FWL_SCBCODE::PageForward: {
fPos += pScrollBar->GetPageSize();
if (fPos > fs.y) {
fPos = fs.y;
}
break;
}
- case FWL_SCBCODE_Pos:
- case FWL_SCBCODE_TrackPos:
+ case FWL_SCBCODE::Pos:
+ case FWL_SCBCODE::TrackPos:
+ case FWL_SCBCODE::None:
break;
- case FWL_SCBCODE_EndScroll:
+ case FWL_SCBCODE::EndScroll:
return false;
- default:
- break;
}
if (iCurPos != fPos) {
pScrollBar->SetPos(fPos);
diff --git a/xfa/fwl/core/ifwl_edit.h b/xfa/fwl/core/ifwl_edit.h
index 9dc8d01fbc..d436a4f550 100644
--- a/xfa/fwl/core/ifwl_edit.h
+++ b/xfa/fwl/core/ifwl_edit.h
@@ -261,7 +261,7 @@ class IFWL_Edit : public IFWL_Widget {
void OnMouseMove(CFWL_MsgMouse* pMsg);
void OnKeyDown(CFWL_MsgKey* pMsg);
void OnChar(CFWL_MsgKey* pMsg);
- bool OnScroll(IFWL_ScrollBar* pScrollBar, uint32_t dwCode, FX_FLOAT fPos);
+ bool OnScroll(IFWL_ScrollBar* pScrollBar, FWL_SCBCODE dwCode, FX_FLOAT fPos);
};
#endif // XFA_FWL_CORE_IFWL_EDIT_H_
diff --git a/xfa/fwl/core/ifwl_listbox.cpp b/xfa/fwl/core/ifwl_listbox.cpp
index d52e8b1c8c..9a713c09cd 100644
--- a/xfa/fwl/core/ifwl_listbox.cpp
+++ b/xfa/fwl/core/ifwl_listbox.cpp
@@ -1089,49 +1089,50 @@ void IFWL_ListBox::OnVK(CFWL_ListItem* pItem, bool bShift, bool bCtrl) {
}
bool IFWL_ListBox::OnScroll(IFWL_ScrollBar* pScrollBar,
- uint32_t dwCode,
+ FWL_SCBCODE dwCode,
FX_FLOAT fPos) {
CFX_SizeF fs;
pScrollBar->GetRange(&fs.x, &fs.y);
FX_FLOAT iCurPos = pScrollBar->GetPos();
FX_FLOAT fStep = pScrollBar->GetStepSize();
switch (dwCode) {
- case FWL_SCBCODE_Min: {
+ case FWL_SCBCODE::Min: {
fPos = fs.x;
break;
}
- case FWL_SCBCODE_Max: {
+ case FWL_SCBCODE::Max: {
fPos = fs.y;
break;
}
- case FWL_SCBCODE_StepBackward: {
+ case FWL_SCBCODE::StepBackward: {
fPos -= fStep;
if (fPos < fs.x + fStep / 2)
fPos = fs.x;
break;
}
- case FWL_SCBCODE_StepForward: {
+ case FWL_SCBCODE::StepForward: {
fPos += fStep;
if (fPos > fs.y - fStep / 2)
fPos = fs.y;
break;
}
- case FWL_SCBCODE_PageBackward: {
+ case FWL_SCBCODE::PageBackward: {
fPos -= pScrollBar->GetPageSize();
if (fPos < fs.x)
fPos = fs.x;
break;
}
- case FWL_SCBCODE_PageForward: {
+ case FWL_SCBCODE::PageForward: {
fPos += pScrollBar->GetPageSize();
if (fPos > fs.y)
fPos = fs.y;
break;
}
- case FWL_SCBCODE_Pos:
- case FWL_SCBCODE_TrackPos:
+ case FWL_SCBCODE::Pos:
+ case FWL_SCBCODE::TrackPos:
+ case FWL_SCBCODE::None:
break;
- case FWL_SCBCODE_EndScroll:
+ case FWL_SCBCODE::EndScroll:
return false;
}
if (iCurPos != fPos) {
diff --git a/xfa/fwl/core/ifwl_listbox.h b/xfa/fwl/core/ifwl_listbox.h
index fed3337a99..195b710ec2 100644
--- a/xfa/fwl/core/ifwl_listbox.h
+++ b/xfa/fwl/core/ifwl_listbox.h
@@ -188,7 +188,7 @@ class IFWL_ListBox : public IFWL_Widget {
void OnMouseWheel(CFWL_MsgMouseWheel* pMsg);
void OnKeyDown(CFWL_MsgKey* pMsg);
void OnVK(CFWL_ListItem* hItem, bool bShift, bool bCtrl);
- bool OnScroll(IFWL_ScrollBar* pScrollBar, uint32_t dwCode, FX_FLOAT fPos);
+ bool OnScroll(IFWL_ScrollBar* pScrollBar, FWL_SCBCODE dwCode, FX_FLOAT fPos);
void DispatchSelChangedEv();
};
diff --git a/xfa/fwl/core/ifwl_scrollbar.cpp b/xfa/fwl/core/ifwl_scrollbar.cpp
index 3dc38efa69..c651abecb1 100644
--- a/xfa/fwl/core/ifwl_scrollbar.cpp
+++ b/xfa/fwl/core/ifwl_scrollbar.cpp
@@ -113,21 +113,9 @@ void IFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) {
CalcMaxTrackRect(m_rtMaxTrack);
}
-bool IFWL_ScrollBar::DoScroll(uint32_t dwCode, FX_FLOAT fPos) {
- switch (dwCode) {
- case FWL_SCBCODE_Min:
- case FWL_SCBCODE_Max:
- case FWL_SCBCODE_PageBackward:
- case FWL_SCBCODE_PageForward:
- case FWL_SCBCODE_StepBackward:
- case FWL_SCBCODE_StepForward:
- case FWL_SCBCODE_Pos:
- case FWL_SCBCODE_TrackPos:
- case FWL_SCBCODE_EndScroll:
- break;
- default:
- return false;
- }
+bool IFWL_ScrollBar::DoScroll(FWL_SCBCODE dwCode, FX_FLOAT fPos) {
+ if (dwCode == FWL_SCBCODE::None)
+ return false;
return OnScroll(dwCode, fPos);
}
@@ -474,30 +462,30 @@ void IFWL_ScrollBar::GetTrackRect(CFX_RectF& rect, bool bLower) {
bool IFWL_ScrollBar::SendEvent() {
if (m_iMinButtonState == CFWL_PartState_Pressed) {
- DoScroll(FWL_SCBCODE_StepBackward, m_fTrackPos);
+ DoScroll(FWL_SCBCODE::StepBackward, m_fTrackPos);
return false;
}
if (m_iMaxButtonState == CFWL_PartState_Pressed) {
- DoScroll(FWL_SCBCODE_StepForward, m_fTrackPos);
+ DoScroll(FWL_SCBCODE::StepForward, m_fTrackPos);
return false;
}
if (m_iMinTrackState == CFWL_PartState_Pressed) {
- DoScroll(FWL_SCBCODE_PageBackward, m_fTrackPos);
+ DoScroll(FWL_SCBCODE::PageBackward, m_fTrackPos);
return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY);
}
if (m_iMaxTrackState == CFWL_PartState_Pressed) {
- DoScroll(FWL_SCBCODE_PageForward, m_fTrackPos);
+ DoScroll(FWL_SCBCODE::PageForward, m_fTrackPos);
return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY);
}
if (m_iMouseWheel) {
- uint16_t dwCode =
- m_iMouseWheel < 0 ? FWL_SCBCODE_StepForward : FWL_SCBCODE_StepBackward;
+ FWL_SCBCODE dwCode = m_iMouseWheel < 0 ? FWL_SCBCODE::StepForward
+ : FWL_SCBCODE::StepBackward;
DoScroll(dwCode, m_fTrackPos);
}
return true;
}
-bool IFWL_ScrollBar::OnScroll(uint32_t dwCode, FX_FLOAT fPos) {
+bool IFWL_ScrollBar::OnScroll(FWL_SCBCODE dwCode, FX_FLOAT fPos) {
bool bRet = true;
CFWL_EvtScroll ev;
ev.m_iScrollCode = dwCode;
@@ -629,7 +617,7 @@ void IFWL_ScrollBar::DoMouseUp(int32_t iItem,
iState = iNewState;
Repaint(&rtItem);
- OnScroll(FWL_SCBCODE_EndScroll, m_fTrackPos);
+ OnScroll(FWL_SCBCODE::EndScroll, m_fTrackPos);
}
void IFWL_ScrollBar::DoMouseMove(int32_t iItem,
@@ -648,7 +636,7 @@ void IFWL_ScrollBar::DoMouseMove(int32_t iItem,
} else if ((2 == iItem) && (m_iThumbButtonState == CFWL_PartState_Pressed)) {
FX_FLOAT fPos = GetTrackPointPos(fx, fy);
m_fTrackPos = fPos;
- OnScroll(FWL_SCBCODE_TrackPos, fPos);
+ OnScroll(FWL_SCBCODE::TrackPos, fPos);
}
}
diff --git a/xfa/fwl/core/ifwl_scrollbar.h b/xfa/fwl/core/ifwl_scrollbar.h
index 78164fd50a..c2d74b2c3b 100644
--- a/xfa/fwl/core/ifwl_scrollbar.h
+++ b/xfa/fwl/core/ifwl_scrollbar.h
@@ -18,19 +18,6 @@ class IFWL_Widget;
#define FWL_STYLEEXT_SCB_Horz (0L << 0)
#define FWL_STYLEEXT_SCB_Vert (1L << 0)
-enum FWL_SCBCODE {
- FWL_SCBCODE_None = 1,
- FWL_SCBCODE_Min,
- FWL_SCBCODE_Max,
- FWL_SCBCODE_PageBackward,
- FWL_SCBCODE_PageForward,
- FWL_SCBCODE_StepBackward,
- FWL_SCBCODE_StepForward,
- FWL_SCBCODE_Pos,
- FWL_SCBCODE_TrackPos,
- FWL_SCBCODE_EndScroll,
-};
-
class IFWL_ScrollBarDP : public IFWL_DataProvider {};
class IFWL_ScrollBar : public IFWL_Widget {
@@ -102,7 +89,7 @@ class IFWL_ScrollBar : public IFWL_Widget {
FX_FLOAT GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy);
void GetTrackRect(CFX_RectF& rect, bool bLower = true);
bool SendEvent();
- bool OnScroll(uint32_t dwCode, FX_FLOAT fPos);
+ bool OnScroll(FWL_SCBCODE dwCode, FX_FLOAT fPos);
void OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy);
void OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy);
void OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy);
@@ -112,7 +99,7 @@ class IFWL_ScrollBar : public IFWL_Widget {
uint32_t dwFlags,
FX_FLOAT fDeltaX,
FX_FLOAT fDeltaY);
- bool DoScroll(uint32_t dwCode, FX_FLOAT fPos = 0.0f);
+ bool DoScroll(FWL_SCBCODE dwCode, FX_FLOAT fPos = 0.0f);
void DoMouseDown(int32_t iItem,
const CFX_RectF& rtItem,
int32_t& iState,