summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-02-26 14:24:28 -0800
committerTom Sepez <tsepez@chromium.org>2016-02-26 14:24:28 -0800
commit281a9eadff15b167e2ee3032e21b83190ad49125 (patch)
treef02f7d0842f59d8e69bda011b3e62547ffb1acde /fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
parent566b974287ce0e81a963138152b8898f22480f52 (diff)
downloadpdfium-281a9eadff15b167e2ee3032e21b83190ad49125.tar.xz
Re-land "Replace CPDF_Rect and CPDF_Point with CFX types."
TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1737593006 .
Diffstat (limited to 'fpdfsdk/src/pdfwindow/PWL_Wnd.cpp')
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Wnd.cpp90
1 files changed, 47 insertions, 43 deletions
diff --git a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
index d0aaa78ea4..28bd0e04ed 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
@@ -273,9 +273,11 @@ void CPWL_Wnd::Destroy() {
m_pVScrollBar = NULL;
}
-void CPWL_Wnd::Move(const CPDF_Rect& rcNew, FX_BOOL bReset, FX_BOOL bRefresh) {
+void CPWL_Wnd::Move(const CFX_FloatRect& rcNew,
+ FX_BOOL bReset,
+ FX_BOOL bRefresh) {
if (IsValid()) {
- CPDF_Rect rcOld = GetWindowRect();
+ CFX_FloatRect rcOld = GetWindowRect();
m_rcWindow = rcNew;
m_rcWindow.Normalize();
@@ -294,9 +296,9 @@ void CPWL_Wnd::Move(const CPDF_Rect& rcNew, FX_BOOL bReset, FX_BOOL bRefresh) {
}
}
-void CPWL_Wnd::InvalidateRectMove(const CPDF_Rect& rcOld,
- const CPDF_Rect& rcNew) {
- CPDF_Rect rcUnion = rcOld;
+void CPWL_Wnd::InvalidateRectMove(const CFX_FloatRect& rcOld,
+ const CFX_FloatRect& rcNew) {
+ CFX_FloatRect rcUnion = rcOld;
rcUnion.Union(rcNew);
InvalidateRect(&rcUnion);
@@ -311,7 +313,7 @@ void CPWL_Wnd::GetAppearanceStream(CFX_ByteTextBuf& sAppStream) {
// if don't set,Get default apperance stream
void CPWL_Wnd::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
- CPDF_Rect rectWnd = GetWindowRect();
+ CFX_FloatRect rectWnd = GetWindowRect();
if (!rectWnd.IsEmpty()) {
CFX_ByteTextBuf sThis;
@@ -348,10 +350,10 @@ void CPWL_Wnd::DrawAppearance(CFX_RenderDevice* pDevice,
void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device) {
- CPDF_Rect rectWnd = GetWindowRect();
+ CFX_FloatRect rectWnd = GetWindowRect();
if (!rectWnd.IsEmpty()) {
if (HasFlag(PWS_BACKGROUND)) {
- CPDF_Rect rcClient = CPWL_Utils::DeflateRect(
+ CFX_FloatRect rcClient = CPWL_Utils::DeflateRect(
rectWnd, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth()));
CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient,
GetBackgroundColor(), GetTransparency());
@@ -381,12 +383,12 @@ void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice,
}
}
-void CPWL_Wnd::InvalidateRect(CPDF_Rect* pRect) {
+void CPWL_Wnd::InvalidateRect(CFX_FloatRect* pRect) {
if (IsValid()) {
- CPDF_Rect rcRefresh = pRect ? *pRect : GetWindowRect();
+ CFX_FloatRect rcRefresh = pRect ? *pRect : GetWindowRect();
if (!HasFlag(PWS_NOREFRESHCLIP)) {
- CPDF_Rect rcClip = GetClipRect();
+ CFX_FloatRect rcClip = GetClipRect();
if (!rcClip.IsEmpty()) {
rcRefresh.Intersect(rcClip);
}
@@ -423,7 +425,7 @@ void CPWL_Wnd::InvalidateRect(CPDF_Rect* pRect) {
}
#define PWL_IMPLEMENT_MOUSE_METHOD(mouse_method_name) \
- FX_BOOL CPWL_Wnd::mouse_method_name(const CPDF_Point& point, \
+ FX_BOOL CPWL_Wnd::mouse_method_name(const CFX_FloatPoint& point, \
FX_DWORD nFlag) { \
if (IsValid() && IsVisible() && IsEnabled()) { \
if (IsWndCaptureMouse(this)) { \
@@ -467,7 +469,7 @@ PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonUp)
PWL_IMPLEMENT_MOUSE_METHOD(OnMouseMove)
FX_BOOL CPWL_Wnd::OnMouseWheel(short zDelta,
- const CPDF_Point& point,
+ const CFX_FloatPoint& point,
FX_DWORD nFlag) {
if (IsValid() && IsVisible() && IsEnabled()) {
SetCursor();
@@ -528,25 +530,25 @@ CPWL_Wnd* CPWL_Wnd::GetParentWindow() const {
return m_sPrivateParam.pParentWnd;
}
-CPDF_Rect CPWL_Wnd::GetWindowRect() const {
+CFX_FloatRect CPWL_Wnd::GetWindowRect() const {
return m_rcWindow;
}
-CPDF_Rect CPWL_Wnd::GetClientRect() const {
- CPDF_Rect rcWindow = GetWindowRect();
- CPDF_Rect rcClient = CPWL_Utils::DeflateRect(
+CFX_FloatRect CPWL_Wnd::GetClientRect() const {
+ CFX_FloatRect rcWindow = GetWindowRect();
+ CFX_FloatRect rcClient = CPWL_Utils::DeflateRect(
rcWindow, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth()));
if (CPWL_ScrollBar* pVSB = GetVScrollBar())
rcClient.right -= pVSB->GetScrollBarWidth();
rcClient.Normalize();
- return rcWindow.Contains(rcClient) ? rcClient : CPDF_Rect();
+ return rcWindow.Contains(rcClient) ? rcClient : CFX_FloatRect();
}
-CPDF_Point CPWL_Wnd::GetCenterPoint() const {
- CPDF_Rect rcClient = GetClientRect();
- return CPDF_Point((rcClient.left + rcClient.right) * 0.5f,
- (rcClient.top + rcClient.bottom) * 0.5f);
+CFX_FloatPoint CPWL_Wnd::GetCenterPoint() const {
+ CFX_FloatRect rcClient = GetClientRect();
+ return CFX_FloatPoint((rcClient.left + rcClient.right) * 0.5f,
+ (rcClient.top + rcClient.bottom) * 0.5f);
}
FX_BOOL CPWL_Wnd::HasFlag(FX_DWORD dwFlags) const {
@@ -682,11 +684,11 @@ void CPWL_Wnd::OnSetFocus() {}
void CPWL_Wnd::OnKillFocus() {}
-FX_BOOL CPWL_Wnd::WndHitTest(const CPDF_Point& point) const {
+FX_BOOL CPWL_Wnd::WndHitTest(const CFX_FloatPoint& point) const {
return IsValid() && IsVisible() && GetWindowRect().Contains(point.x, point.y);
}
-FX_BOOL CPWL_Wnd::ClientHitTest(const CPDF_Point& point) const {
+FX_BOOL CPWL_Wnd::ClientHitTest(const CFX_FloatPoint& point) const {
return IsValid() && IsVisible() && GetClientRect().Contains(point.x, point.y);
}
@@ -713,12 +715,12 @@ void CPWL_Wnd::SetVisible(FX_BOOL bVisible) {
}
}
-void CPWL_Wnd::SetClipRect(const CPDF_Rect& rect) {
+void CPWL_Wnd::SetClipRect(const CFX_FloatRect& rect) {
m_rcClip = rect;
m_rcClip.Normalize();
}
-const CPDF_Rect& CPWL_Wnd::GetClipRect() const {
+const CFX_FloatRect& CPWL_Wnd::GetClipRect() const {
return m_rcClip;
}
@@ -727,14 +729,14 @@ FX_BOOL CPWL_Wnd::IsReadOnly() const {
}
void CPWL_Wnd::RePosChildWnd() {
- CPDF_Rect rcContent = CPWL_Utils::DeflateRect(
+ CFX_FloatRect rcContent = CPWL_Utils::DeflateRect(
GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth()));
CPWL_ScrollBar* pVSB = GetVScrollBar();
- CPDF_Rect rcVScroll =
- CPDF_Rect(rcContent.right - PWL_SCROLLBAR_WIDTH, rcContent.bottom,
- rcContent.right - 1.0f, rcContent.top);
+ CFX_FloatRect rcVScroll =
+ CFX_FloatRect(rcContent.right - PWL_SCROLLBAR_WIDTH, rcContent.bottom,
+ rcContent.right - 1.0f, rcContent.top);
if (pVSB)
pVSB->Move(rcVScroll, TRUE, FALSE);
@@ -791,7 +793,7 @@ FX_BOOL CPWL_Wnd::IsFocused() const {
return FALSE;
}
-CPDF_Rect CPWL_Wnd::GetFocusRect() const {
+CFX_FloatRect CPWL_Wnd::GetFocusRect() const {
return CPWL_Utils::InflateRect(GetWindowRect(), 1);
}
@@ -886,16 +888,18 @@ CFX_Matrix CPWL_Wnd::GetWindowMatrix() const {
return mt;
}
-void CPWL_Wnd::PWLtoWnd(const CPDF_Point& point, int32_t& x, int32_t& y) const {
+void CPWL_Wnd::PWLtoWnd(const CFX_FloatPoint& point,
+ int32_t& x,
+ int32_t& y) const {
CFX_Matrix mt = GetWindowMatrix();
- CPDF_Point pt = point;
+ CFX_FloatPoint pt = point;
mt.Transform(pt.x, pt.y);
x = (int32_t)(pt.x + 0.5);
y = (int32_t)(pt.y + 0.5);
}
-FX_RECT CPWL_Wnd::PWLtoWnd(const CPDF_Rect& rect) const {
- CPDF_Rect rcTemp = rect;
+FX_RECT CPWL_Wnd::PWLtoWnd(const CFX_FloatRect& rect) const {
+ CFX_FloatRect rcTemp = rect;
CFX_Matrix mt = GetWindowMatrix();
mt.TransformRect(rcTemp);
return FX_RECT((int32_t)(rcTemp.left + 0.5), (int32_t)(rcTemp.bottom + 0.5),
@@ -906,44 +910,44 @@ FX_HWND CPWL_Wnd::GetAttachedHWnd() const {
return m_sPrivateParam.hAttachedWnd;
}
-CPDF_Point CPWL_Wnd::ChildToParent(const CPDF_Point& point) const {
+CFX_FloatPoint CPWL_Wnd::ChildToParent(const CFX_FloatPoint& point) const {
CFX_Matrix mt = GetChildMatrix();
if (mt.IsIdentity())
return point;
- CPDF_Point pt = point;
+ CFX_FloatPoint pt = point;
mt.Transform(pt.x, pt.y);
return pt;
}
-CPDF_Rect CPWL_Wnd::ChildToParent(const CPDF_Rect& rect) const {
+CFX_FloatRect CPWL_Wnd::ChildToParent(const CFX_FloatRect& rect) const {
CFX_Matrix mt = GetChildMatrix();
if (mt.IsIdentity())
return rect;
- CPDF_Rect rc = rect;
+ CFX_FloatRect rc = rect;
mt.TransformRect(rc);
return rc;
}
-CPDF_Point CPWL_Wnd::ParentToChild(const CPDF_Point& point) const {
+CFX_FloatPoint CPWL_Wnd::ParentToChild(const CFX_FloatPoint& point) const {
CFX_Matrix mt = GetChildMatrix();
if (mt.IsIdentity())
return point;
mt.SetReverse(mt);
- CPDF_Point pt = point;
+ CFX_FloatPoint pt = point;
mt.Transform(pt.x, pt.y);
return pt;
}
-CPDF_Rect CPWL_Wnd::ParentToChild(const CPDF_Rect& rect) const {
+CFX_FloatRect CPWL_Wnd::ParentToChild(const CFX_FloatRect& rect) const {
CFX_Matrix mt = GetChildMatrix();
if (mt.IsIdentity())
return rect;
mt.SetReverse(mt);
- CPDF_Rect rc = rect;
+ CFX_FloatRect rc = rect;
mt.TransformRect(rc);
return rc;
}