summaryrefslogtreecommitdiff
path: root/fpdfsdk/pdfwindow
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/pdfwindow')
-rw-r--r--fpdfsdk/pdfwindow/cpwl_edit.cpp9
-rw-r--r--fpdfsdk/pdfwindow/cpwl_list_box.cpp9
-rw-r--r--fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp27
-rw-r--r--fpdfsdk/pdfwindow/cpwl_special_button.cpp9
-rw-r--r--fpdfsdk/pdfwindow/cpwl_utils.cpp15
-rw-r--r--fpdfsdk/pdfwindow/cpwl_wnd.cpp19
6 files changed, 24 insertions, 64 deletions
diff --git a/fpdfsdk/pdfwindow/cpwl_edit.cpp b/fpdfsdk/pdfwindow/cpwl_edit.cpp
index 92b3f6498e..7d75bc693d 100644
--- a/fpdfsdk/pdfwindow/cpwl_edit.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_edit.cpp
@@ -103,13 +103,8 @@ void CPWL_Edit::RePosChildWnd() {
}
CFX_FloatRect CPWL_Edit::GetClientRect() const {
- CFX_FloatRect rcClient = GetWindowRect();
- if (!rcClient.IsEmpty()) {
- float width = static_cast<float>(GetBorderWidth() + GetInnerBorderWidth());
- rcClient.Deflate(width, width);
- rcClient.Normalize();
- }
-
+ float width = static_cast<float>(GetBorderWidth() + GetInnerBorderWidth());
+ CFX_FloatRect rcClient = GetWindowRect().GetDeflated(width, width);
if (CPWL_ScrollBar* pVSB = GetVScrollBar()) {
if (pVSB->IsVisible()) {
rcClient.right -= PWL_SCROLLBAR_WIDTH;
diff --git a/fpdfsdk/pdfwindow/cpwl_list_box.cpp b/fpdfsdk/pdfwindow/cpwl_list_box.cpp
index 4b4df33e39..96df02c642 100644
--- a/fpdfsdk/pdfwindow/cpwl_list_box.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_list_box.cpp
@@ -405,13 +405,8 @@ float CPWL_ListBox::GetFirstHeight() const {
}
CFX_FloatRect CPWL_ListBox::GetListRect() const {
- CFX_FloatRect rect = GetWindowRect();
- if (!rect.IsEmpty()) {
- float width = static_cast<float>(GetBorderWidth() + GetInnerBorderWidth());
- rect.Deflate(width, width);
- rect.Normalize();
- }
- return rect;
+ float width = static_cast<float>(GetBorderWidth() + GetInnerBorderWidth());
+ return GetWindowRect().GetDeflated(width, width);
}
bool CPWL_ListBox::OnMouseWheel(short zDelta,
diff --git a/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp b/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp
index 491d0b3876..dc153fda37 100644
--- a/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp
@@ -242,31 +242,23 @@ void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
}
// draw border
- CFX_FloatRect rcDraw = rectWnd;
- CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw,
+ CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rectWnd,
ArgbEncode(nTransparency, 100, 100, 100), 0.0f);
// draw inner border
- rcDraw = rectWnd;
- if (!rcDraw.IsEmpty()) {
- rcDraw.Deflate(0.5f, 0.5f);
- rcDraw.Normalize();
- }
- CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw,
+ CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device,
+ rectWnd.GetDeflated(0.5f, 0.5f),
ArgbEncode(nTransparency, 255, 255, 255), 1.0f);
if (m_eSBButtonType != PSBT_POS) {
// draw background
- rcDraw = rectWnd;
- if (!rcDraw.IsEmpty()) {
- rcDraw.Deflate(1.0f, 1.0f);
- rcDraw.Normalize();
- }
if (IsEnabled()) {
- CPWL_Utils::DrawShadow(pDevice, pUser2Device, true, false, rcDraw,
- nTransparency, 80, 220);
+ CPWL_Utils::DrawShadow(pDevice, pUser2Device, true, false,
+ rectWnd.GetDeflated(1.0f, 1.0f), nTransparency, 80,
+ 220);
} else {
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcDraw,
+ CPWL_Utils::DrawFillRect(pDevice, pUser2Device,
+ rectWnd.GetDeflated(1.0f, 1.0f),
ArgbEncode(255, 255, 255, 255));
}
@@ -326,7 +318,8 @@ void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
ptBottom.x += 1.0f;
}
} else {
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcDraw,
+ CPWL_Utils::DrawFillRect(pDevice, pUser2Device,
+ rectWnd.GetDeflated(0.5f, 0.5f),
ArgbEncode(255, 255, 255, 255));
}
diff --git a/fpdfsdk/pdfwindow/cpwl_special_button.cpp b/fpdfsdk/pdfwindow/cpwl_special_button.cpp
index 743565f0dc..da91da3ecb 100644
--- a/fpdfsdk/pdfwindow/cpwl_special_button.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_special_button.cpp
@@ -18,13 +18,8 @@ CFX_ByteString CPWL_PushButton::GetClassName() const {
}
CFX_FloatRect CPWL_PushButton::GetFocusRect() const {
- CFX_FloatRect rect = GetWindowRect();
- if (!rect.IsEmpty()) {
- rect.Deflate(static_cast<float>(GetBorderWidth()),
- static_cast<float>(GetBorderWidth()));
- rect.Normalize();
- }
- return rect;
+ return GetWindowRect().GetDeflated(static_cast<float>(GetBorderWidth()),
+ static_cast<float>(GetBorderWidth()));
}
CPWL_CheckBox::CPWL_CheckBox() : m_bChecked(false) {}
diff --git a/fpdfsdk/pdfwindow/cpwl_utils.cpp b/fpdfsdk/pdfwindow/cpwl_utils.cpp
index c576044a69..af69174276 100644
--- a/fpdfsdk/pdfwindow/cpwl_utils.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_utils.cpp
@@ -611,19 +611,10 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(
sAppStream << "q\n";
float fHalfWidth = fWidth / 2.0f;
+ CFX_FloatRect rect_by_2 = rect.GetDeflated(fHalfWidth, fHalfWidth);
- CFX_FloatRect rect_by_2 = rect;
- CFX_FloatRect rect_by_75 = rect;
- if (!rect.IsEmpty()) {
- float div = fWidth / 2.0f;
- rect_by_2.Deflate(div, div);
- rect_by_2.Normalize();
-
- div = fHalfWidth * 0.75f;
- rect_by_75.Deflate(div, div);
- rect_by_75.Normalize();
- }
-
+ float div = fHalfWidth * 0.75f;
+ CFX_FloatRect rect_by_75 = rect.GetDeflated(div, div);
switch (nStyle) {
default:
case BorderStyle::SOLID:
diff --git a/fpdfsdk/pdfwindow/cpwl_wnd.cpp b/fpdfsdk/pdfwindow/cpwl_wnd.cpp
index 5aae2dfa92..863b9aab9a 100644
--- a/fpdfsdk/pdfwindow/cpwl_wnd.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_wnd.cpp
@@ -292,14 +292,9 @@ void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice,
return;
if (HasFlag(PWS_BACKGROUND)) {
- CFX_FloatRect rcClient = rectWnd;
- if (!rcClient.IsEmpty()) {
- float width =
- static_cast<float>(GetBorderWidth() + GetInnerBorderWidth());
- rcClient.Deflate(width, width);
- rcClient.Normalize();
- }
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient,
+ float width = static_cast<float>(GetBorderWidth() + GetInnerBorderWidth());
+ CPWL_Utils::DrawFillRect(pDevice, pUser2Device,
+ rectWnd.GetDeflated(width, width),
GetBackgroundColor(), GetTransparency());
}
@@ -468,13 +463,9 @@ CFX_FloatRect CPWL_Wnd::GetWindowRect() const {
CFX_FloatRect CPWL_Wnd::GetClientRect() const {
CFX_FloatRect rcWindow = GetWindowRect();
- CFX_FloatRect rcClient = rcWindow;
- if (!rcClient.IsEmpty()) {
- float width = static_cast<float>(GetBorderWidth() + GetInnerBorderWidth());
- rcClient.Deflate(width, width);
- rcClient.Normalize();
- }
+ float width = static_cast<float>(GetBorderWidth() + GetInnerBorderWidth());
+ CFX_FloatRect rcClient = rcWindow.GetDeflated(width, width);
if (CPWL_ScrollBar* pVSB = GetVScrollBar())
rcClient.right -= pVSB->GetScrollBarWidth();