summaryrefslogtreecommitdiff
path: root/xfa/fwl/core
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fwl/core')
-rw-r--r--xfa/fwl/core/fwl_formimp.cpp68
-rw-r--r--xfa/fwl/core/fwl_formimp.h2
-rw-r--r--xfa/fwl/core/fwl_widgetdef.h23
-rw-r--r--xfa/fwl/core/fwl_widgetimp.cpp21
-rw-r--r--xfa/fwl/core/fwl_widgetimp.h3
-rw-r--r--xfa/fwl/core/ifwl_widget.h2
-rw-r--r--xfa/fwl/core/include/fwl_widgethit.h35
7 files changed, 77 insertions, 77 deletions
diff --git a/xfa/fwl/core/fwl_formimp.cpp b/xfa/fwl/core/fwl_formimp.cpp
index bbec673ed6..9b91deb140 100644
--- a/xfa/fwl/core/fwl_formimp.cpp
+++ b/xfa/fwl/core/fwl_formimp.cpp
@@ -197,69 +197,57 @@ FWL_ERR CFWL_FormImp::Update() {
Layout();
return FWL_ERR_Succeeded;
}
-uint32_t CFWL_FormImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
- (void)GetAvailableTheme();
- if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) {
- return FWL_WGTHITTEST_CloseBox;
- }
- if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) {
- return FWL_WGTHITTEST_MaxBox;
- }
- if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) {
- return FWL_WGTHITTEST_MinBox;
- }
+FWL_WidgetHit CFWL_FormImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+ GetAvailableTheme();
+ if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy))
+ return FWL_WidgetHit::CloseBox;
+ if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy))
+ return FWL_WidgetHit::MaxBox;
+ if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy))
+ return FWL_WidgetHit::MinBox;
CFX_RectF rtCap;
rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder,
m_rtCaption.width - FWL_SYSBTNSIZE * m_iSysBox - 2 * m_fCYBorder,
m_rtCaption.height - m_fCXBorder);
- if (rtCap.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Titlebar;
- }
+ if (rtCap.Contains(fx, fy))
+ return FWL_WidgetHit::Titlebar;
if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) &&
(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize)) {
FX_FLOAT fWidth = m_rtRelative.width - 2 * (m_fCYBorder + kCornerEnlarge);
FX_FLOAT fHeight = m_rtRelative.height - 2 * (m_fCXBorder + kCornerEnlarge);
CFX_RectF rt;
rt.Set(0, m_fCXBorder + kCornerEnlarge, m_fCYBorder, fHeight);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Left;
- }
+ if (rt.Contains(fx, fy))
+ return FWL_WidgetHit::Left;
rt.Set(m_rtRelative.width - m_fCYBorder, m_fCXBorder + kCornerEnlarge,
m_fCYBorder, fHeight);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Right;
- }
+ if (rt.Contains(fx, fy))
+ return FWL_WidgetHit::Right;
rt.Set(m_fCYBorder + kCornerEnlarge, 0, fWidth, m_fCXBorder);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Top;
- }
+ if (rt.Contains(fx, fy))
+ return FWL_WidgetHit::Top;
rt.Set(m_fCYBorder + kCornerEnlarge, m_rtRelative.height - m_fCXBorder,
fWidth, m_fCXBorder);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Bottom;
- }
+ if (rt.Contains(fx, fy))
+ return FWL_WidgetHit::Bottom;
rt.Set(0, 0, m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_LeftTop;
- }
+ if (rt.Contains(fx, fy))
+ return FWL_WidgetHit::LeftTop;
rt.Set(0, m_rtRelative.height - m_fCXBorder - kCornerEnlarge,
m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_LeftBottom;
- }
+ if (rt.Contains(fx, fy))
+ return FWL_WidgetHit::LeftBottom;
rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge, 0,
m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_RightTop;
- }
+ if (rt.Contains(fx, fy))
+ return FWL_WidgetHit::RightTop;
rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge,
m_rtRelative.height - m_fCXBorder - kCornerEnlarge,
m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge);
- if (rt.Contains(fx, fy)) {
- return FWL_WGTHITTEST_RightBottom;
- }
+ if (rt.Contains(fx, fy))
+ return FWL_WidgetHit::RightBottom;
}
- return FWL_WGTHITTEST_Client;
+ return FWL_WidgetHit::Client;
}
FWL_ERR CFWL_FormImp::DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix) {
@@ -1140,7 +1128,7 @@ void CFWL_FormImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
}
void CFWL_FormImpDelegate::OnLButtonDblClk(CFWL_MsgMouse* pMsg) {
if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) &&
- m_pOwner->HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WGTHITTEST_Titlebar) {
+ m_pOwner->HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WidgetHit::Titlebar) {
if (m_pOwner->m_bMaximized) {
m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore);
} else {
diff --git a/xfa/fwl/core/fwl_formimp.h b/xfa/fwl/core/fwl_formimp.h
index dccdf7f2af..4ee3e0ddae 100644
--- a/xfa/fwl/core/fwl_formimp.h
+++ b/xfa/fwl/core/fwl_formimp.h
@@ -78,7 +78,7 @@ class CFWL_FormImp : public CFWL_WidgetImp {
virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
virtual FWL_ERR GetClientRect(CFX_RectF& rect);
virtual FWL_ERR Update();
- virtual uint32_t HitTest(FX_FLOAT fx, FX_FLOAT fy);
+ virtual FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy);
virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = NULL);
virtual FWL_FORMSIZE GetFormSize();
diff --git a/xfa/fwl/core/fwl_widgetdef.h b/xfa/fwl/core/fwl_widgetdef.h
index 3b858951e5..f0ef5f5d18 100644
--- a/xfa/fwl/core/fwl_widgetdef.h
+++ b/xfa/fwl/core/fwl_widgetdef.h
@@ -50,28 +50,7 @@
#define FWL_WGTSTATE_Focused (1L << 4)
#define FWL_WGTSTATE_Invisible (1L << 5)
#define FWL_WGTSTATE_MAX (6)
-#define FWL_WGTHITTEST_Unknown 0
-#define FWL_WGTHITTEST_Client 1
-#define FWL_WGTHITTEST_Left 2
-#define FWL_WGTHITTEST_Top 3
-#define FWL_WGTHITTEST_Right 4
-#define FWL_WGTHITTEST_Bottom 5
-#define FWL_WGTHITTEST_LeftTop 6
-#define FWL_WGTHITTEST_RightTop 7
-#define FWL_WGTHITTEST_LeftBottom 8
-#define FWL_WGTHITTEST_RightBottom 9
-#define FWL_WGTHITTEST_Icon 10
-#define FWL_WGTHITTEST_Titlebar 11
-#define FWL_WGTHITTEST_MinBox 12
-#define FWL_WGTHITTEST_MaxBox 13
-#define FWL_WGTHITTEST_CloseBox 14
-#define FWL_WGTHITTEST_HScrollBar 15
-#define FWL_WGTHITTEST_VScrollBar 16
-#define FWL_WGTHITTEST_Border 17
-#define FWL_WGTHITTEST_Edge 18
-#define FWL_WGTHITTEST_Edit 19
-#define FWL_WGTHITTEST_HyperLink 20
-#define FWL_WGTHITTEST_MAX 21
+
#define FWL_VKEY_LButton 0x01
#define FWL_VKEY_RButton 0x02
#define FWL_VKEY_MButton 0x04
diff --git a/xfa/fwl/core/fwl_widgetimp.cpp b/xfa/fwl/core/fwl_widgetimp.cpp
index 38516c6557..b9db4f984e 100644
--- a/xfa/fwl/core/fwl_widgetimp.cpp
+++ b/xfa/fwl/core/fwl_widgetimp.cpp
@@ -118,7 +118,7 @@ FWL_ERR IFWL_Widget::LockUpdate() {
FWL_ERR IFWL_Widget::UnlockUpdate() {
return static_cast<CFWL_WidgetImp*>(GetImpl())->UnlockUpdate();
}
-uint32_t IFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+FWL_WidgetHit IFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
return static_cast<CFWL_WidgetImp*>(GetImpl())->HitTest(fx, fy);
}
FWL_ERR IFWL_Widget::TransformTo(IFWL_Widget* pWidget,
@@ -365,27 +365,24 @@ FWL_ERR CFWL_WidgetImp::UnlockUpdate() {
}
return FWL_ERR_Succeeded;
}
-uint32_t CFWL_WidgetImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
+FWL_WidgetHit CFWL_WidgetImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
CFX_RectF rtClient;
GetClientRect(rtClient);
- if (rtClient.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Client;
- }
+ if (rtClient.Contains(fx, fy))
+ return FWL_WidgetHit::Client;
if (HasEdge()) {
CFX_RectF rtEdge;
GetEdgeRect(rtEdge);
- if (rtEdge.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Edge;
- }
+ if (rtEdge.Contains(fx, fy))
+ return FWL_WidgetHit::Edge;
}
if (HasBorder()) {
CFX_RectF rtRelative;
GetRelativeRect(rtRelative);
- if (rtRelative.Contains(fx, fy)) {
- return FWL_WGTHITTEST_Border;
- }
+ if (rtRelative.Contains(fx, fy))
+ return FWL_WidgetHit::Border;
}
- return FWL_WGTHITTEST_Unknown;
+ return FWL_WidgetHit::Unknown;
}
FWL_ERR CFWL_WidgetImp::TransformTo(IFWL_Widget* pWidget,
FX_FLOAT& fx,
diff --git a/xfa/fwl/core/fwl_widgetimp.h b/xfa/fwl/core/fwl_widgetimp.h
index 9381a4203d..3eddfa51c2 100644
--- a/xfa/fwl/core/fwl_widgetimp.h
+++ b/xfa/fwl/core/fwl_widgetimp.h
@@ -12,6 +12,7 @@
#include "xfa/fwl/core/cfwl_event.h"
#include "xfa/fwl/core/cfwl_themepart.h"
#include "xfa/fwl/core/ifwl_widgetdelegate.h"
+#include "xfa/fwl/core/include/fwl_widgethit.h"
#include "xfa/fwl/theme/cfwl_widgettp.h"
class CFWL_AppImp;
@@ -57,7 +58,7 @@ class CFWL_WidgetImp {
virtual FWL_ERR Update();
virtual FWL_ERR LockUpdate();
virtual FWL_ERR UnlockUpdate();
- virtual uint32_t HitTest(FX_FLOAT fx, FX_FLOAT fy);
+ virtual FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy);
virtual FWL_ERR TransformTo(IFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy);
virtual FWL_ERR TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt);
virtual FWL_ERR GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE);
diff --git a/xfa/fwl/core/ifwl_widget.h b/xfa/fwl/core/ifwl_widget.h
index ea57c4e3fa..62f7155c5d 100644
--- a/xfa/fwl/core/ifwl_widget.h
+++ b/xfa/fwl/core/ifwl_widget.h
@@ -61,7 +61,7 @@ class IFWL_Widget {
FWL_ERR Update();
FWL_ERR LockUpdate();
FWL_ERR UnlockUpdate();
- uint32_t HitTest(FX_FLOAT fx, FX_FLOAT fy);
+ FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy);
FWL_ERR TransformTo(IFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy);
FWL_ERR TransformTo(IFWL_Widget* pWidget, CFX_RectF& rt);
FWL_ERR GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE);
diff --git a/xfa/fwl/core/include/fwl_widgethit.h b/xfa/fwl/core/include/fwl_widgethit.h
new file mode 100644
index 0000000000..102024a510
--- /dev/null
+++ b/xfa/fwl/core/include/fwl_widgethit.h
@@ -0,0 +1,35 @@
+// 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_INCLUDE_FWL_WIDGETHIT_H_
+#define XFA_FWL_CORE_INCLUDE_FWL_WIDGETHIT_H_
+
+enum class FWL_WidgetHit {
+ Unknown = 0,
+ Client,
+ Left,
+ Top,
+ Right,
+ Bottom,
+ LeftTop,
+ RightTop,
+ LeftBottom,
+ RightBottom,
+ Titlebar,
+ MinBox,
+ MaxBox,
+ CloseBox,
+ HScrollBar,
+ VScrollBar,
+ Border,
+ Edge,
+ Edit,
+ HyperLink,
+ UpButton,
+ DownButton
+};
+
+#endif // XFA_FWL_CORE_INCLUDE_FWL_WIDGETHIT_H_