summaryrefslogtreecommitdiff
path: root/fpdfsdk/pdfwindow
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/pdfwindow')
-rw-r--r--fpdfsdk/pdfwindow/cpwl_list_box.cpp5
-rw-r--r--fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp57
-rw-r--r--fpdfsdk/pdfwindow/cpwl_utils.cpp240
-rw-r--r--fpdfsdk/pdfwindow/cpwl_utils.h43
-rw-r--r--fpdfsdk/pdfwindow/cpwl_wnd.cpp16
5 files changed, 35 insertions, 326 deletions
diff --git a/fpdfsdk/pdfwindow/cpwl_list_box.cpp b/fpdfsdk/pdfwindow/cpwl_list_box.cpp
index 96df02c642..f9fdef0663 100644
--- a/fpdfsdk/pdfwindow/cpwl_list_box.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_list_box.cpp
@@ -8,6 +8,7 @@
#include <sstream>
+#include "core/fxge/cfx_renderdevice.h"
#include "fpdfsdk/fxedit/fxet_edit.h"
#include "fpdfsdk/fxedit/fxet_list.h"
#include "fpdfsdk/pdfwindow/cpwl_edit.h"
@@ -171,8 +172,8 @@ void CPWL_ListBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
nullptr, pSysHandler, m_pFormFiller.Get());
pSysHandler->OutputSelectedRect(m_pFormFiller.Get(), rcItem);
} else {
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcItem,
- ArgbEncode(255, 0, 51, 113));
+ pDevice->DrawFillRect(pUser2Device, rcItem,
+ ArgbEncode(255, 0, 51, 113));
CFX_Edit::DrawEdit(pDevice, pUser2Device, m_pList->GetItemEdit(i),
ArgbEncode(255, 255, 255, 255), rcList, ptOffset,
nullptr, pSysHandler, m_pFormFiller.Get());
diff --git a/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp b/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp
index dc153fda37..ca637600f7 100644
--- a/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_scroll_bar.cpp
@@ -242,24 +242,20 @@ void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
}
// draw border
- CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rectWnd,
- ArgbEncode(nTransparency, 100, 100, 100), 0.0f);
-
- // draw inner border
- CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device,
- rectWnd.GetDeflated(0.5f, 0.5f),
- ArgbEncode(nTransparency, 255, 255, 255), 1.0f);
+ pDevice->DrawStrokeRect(pUser2Device, rectWnd,
+ ArgbEncode(nTransparency, 100, 100, 100), 0.0f);
+ pDevice->DrawStrokeRect(pUser2Device, rectWnd.GetDeflated(0.5f, 0.5f),
+ ArgbEncode(nTransparency, 255, 255, 255), 1.0f);
if (m_eSBButtonType != PSBT_POS) {
// draw background
if (IsEnabled()) {
- CPWL_Utils::DrawShadow(pDevice, pUser2Device, true, false,
- rectWnd.GetDeflated(1.0f, 1.0f), nTransparency, 80,
- 220);
+ pDevice->DrawShadow(pUser2Device, true, false,
+ rectWnd.GetDeflated(1.0f, 1.0f), nTransparency, 80,
+ 220);
} else {
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device,
- rectWnd.GetDeflated(1.0f, 1.0f),
- ArgbEncode(255, 255, 255, 255));
+ pDevice->DrawFillRect(pUser2Device, rectWnd.GetDeflated(1.0f, 1.0f),
+ ArgbEncode(255, 255, 255, 255));
}
// draw arrow
@@ -284,10 +280,10 @@ void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
pts.push_back(CFX_PointF(fX + 4.5f, fY + 3.0f));
pts.push_back(CFX_PointF(fX + 2.5f, fY + 5.0f));
}
- CPWL_Utils::DrawFillArea(pDevice, pUser2Device, pts.data(), 7,
- IsEnabled()
- ? ArgbEncode(nTransparency, 255, 255, 255)
- : PWL_DEFAULT_HEAVYGRAYCOLOR.ToFXColor(255));
+ pDevice->DrawFillArea(pUser2Device, pts.data(), 7,
+ IsEnabled()
+ ? ArgbEncode(nTransparency, 255, 255, 255)
+ : PWL_DEFAULT_HEAVYGRAYCOLOR.ToFXColor(255));
}
return;
}
@@ -310,17 +306,15 @@ void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
ArgbEncode(nTransparency, 150, 150, 150),
ArgbEncode(nTransparency, 180, 180, 180),
ArgbEncode(nTransparency, 210, 210, 210)};
- for (auto* it = std::begin(refs); it < std::end(refs); ++it) {
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom, *it,
- 1.0f);
+ for (FX_COLORREF ref : refs) {
+ pDevice->DrawStrokeLine(pUser2Device, ptTop, ptBottom, ref, 1.0f);
ptTop.x += 1.0f;
ptBottom.x += 1.0f;
}
} else {
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device,
- rectWnd.GetDeflated(0.5f, 0.5f),
- ArgbEncode(255, 255, 255, 255));
+ pDevice->DrawFillRect(pUser2Device, rectWnd.GetDeflated(0.5f, 0.5f),
+ ArgbEncode(255, 255, 255, 255));
}
// draw friction
@@ -340,8 +334,7 @@ void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
ptCenter.y - nFrictionHeight / 2.0f + 0.5f);
for (size_t i = 0; i < 3; ++i) {
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight, crStroke,
- 1.0f);
+ pDevice->DrawStrokeLine(pUser2Device, ptLeft, ptRight, crStroke, 1.0f);
ptLeft.y += 2.0f;
ptRight.y += 2.0f;
}
@@ -487,18 +480,16 @@ void CPWL_ScrollBar::DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_FloatRect rectWnd = GetWindowRect();
if (IsVisible() && !rectWnd.IsEmpty()) {
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rectWnd,
- GetBackgroundColor(), GetTransparency());
+ pDevice->DrawFillRect(pUser2Device, rectWnd, GetBackgroundColor(),
+ GetTransparency());
- CPWL_Utils::DrawStrokeLine(
- pDevice, pUser2Device,
- CFX_PointF(rectWnd.left + 2.0f, rectWnd.top - 2.0f),
+ pDevice->DrawStrokeLine(
+ pUser2Device, CFX_PointF(rectWnd.left + 2.0f, rectWnd.top - 2.0f),
CFX_PointF(rectWnd.left + 2.0f, rectWnd.bottom + 2.0f),
ArgbEncode(GetTransparency(), 100, 100, 100), 1.0f);
- CPWL_Utils::DrawStrokeLine(
- pDevice, pUser2Device,
- CFX_PointF(rectWnd.right - 2.0f, rectWnd.top - 2.0f),
+ pDevice->DrawStrokeLine(
+ pUser2Device, CFX_PointF(rectWnd.right - 2.0f, rectWnd.top - 2.0f),
CFX_PointF(rectWnd.right - 2.0f, rectWnd.bottom + 2.0f),
ArgbEncode(GetTransparency(), 100, 100, 100), 1.0f);
}
diff --git a/fpdfsdk/pdfwindow/cpwl_utils.cpp b/fpdfsdk/pdfwindow/cpwl_utils.cpp
index af69174276..b21047b623 100644
--- a/fpdfsdk/pdfwindow/cpwl_utils.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_utils.cpp
@@ -11,12 +11,8 @@
#include <sstream>
#include "core/fpdfdoc/cpvt_word.h"
-#include "core/fxge/cfx_graphstatedata.h"
-#include "core/fxge/cfx_pathdata.h"
-#include "core/fxge/cfx_renderdevice.h"
#include "fpdfsdk/fxedit/fxet_edit.h"
#include "fpdfsdk/pdfwindow/cpwl_icon.h"
-#include "fpdfsdk/pdfwindow/cpwl_wnd.h"
CFX_ByteString CPWL_Utils::GetAP_Check(const CFX_FloatRect& crBBox) {
const float fWidth = crBBox.right - crBBox.left;
@@ -842,239 +838,3 @@ CFX_ByteString CPWL_Utils::GetDropButtonAppStream(const CFX_FloatRect& rcBBox) {
return CFX_ByteString(sAppStream);
}
-
-void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- const CFX_FloatRect& rect,
- const FX_COLORREF& color) {
- CFX_PathData path;
- CFX_FloatRect rcTemp(rect);
- path.AppendRect(rcTemp.left, rcTemp.bottom, rcTemp.right, rcTemp.top);
- pDevice->DrawPath(&path, pUser2Device, nullptr, color, 0, FXFILL_WINDING);
-}
-
-void CPWL_Utils::DrawFillArea(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- const CFX_PointF* pPts,
- int32_t nCount,
- const FX_COLORREF& color) {
- CFX_PathData path;
- path.AppendPoint(pPts[0], FXPT_TYPE::MoveTo, false);
- for (int32_t i = 1; i < nCount; i++)
- path.AppendPoint(pPts[i], FXPT_TYPE::LineTo, false);
-
- pDevice->DrawPath(&path, pUser2Device, nullptr, color, 0, FXFILL_ALTERNATE);
-}
-
-void CPWL_Utils::DrawStrokeRect(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- const CFX_FloatRect& rect,
- const FX_COLORREF& color,
- float fWidth) {
- CFX_PathData path;
- CFX_FloatRect rcTemp(rect);
- path.AppendRect(rcTemp.left, rcTemp.bottom, rcTemp.right, rcTemp.top);
-
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = fWidth;
-
- pDevice->DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE);
-}
-
-void CPWL_Utils::DrawStrokeLine(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- const CFX_PointF& ptMoveTo,
- const CFX_PointF& ptLineTo,
- const FX_COLORREF& color,
- float fWidth) {
- CFX_PathData path;
- path.AppendPoint(ptMoveTo, FXPT_TYPE::MoveTo, false);
- path.AppendPoint(ptLineTo, FXPT_TYPE::LineTo, false);
-
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = fWidth;
-
- pDevice->DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE);
-}
-
-void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- const CFX_FloatRect& rect,
- const CFX_Color& color,
- int32_t nTransparency) {
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rect,
- color.ToFXColor(nTransparency));
-}
-
-void CPWL_Utils::DrawShadow(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- bool bVertical,
- bool bHorizontal,
- CFX_FloatRect rect,
- int32_t nTransparency,
- int32_t nStartGray,
- int32_t nEndGray) {
- float fStepGray = 1.0f;
-
- if (bVertical) {
- fStepGray = (nEndGray - nStartGray) / rect.Height();
-
- for (float fy = rect.bottom + 0.5f; fy <= rect.top - 0.5f; fy += 1.0f) {
- int32_t nGray = nStartGray + (int32_t)(fStepGray * (fy - rect.bottom));
- CPWL_Utils::DrawStrokeLine(
- pDevice, pUser2Device, CFX_PointF(rect.left, fy),
- CFX_PointF(rect.right, fy),
- ArgbEncode(nTransparency, nGray, nGray, nGray), 1.5f);
- }
- }
-
- if (bHorizontal) {
- fStepGray = (nEndGray - nStartGray) / rect.Width();
-
- for (float fx = rect.left + 0.5f; fx <= rect.right - 0.5f; fx += 1.0f) {
- int32_t nGray = nStartGray + (int32_t)(fStepGray * (fx - rect.left));
- CPWL_Utils::DrawStrokeLine(
- pDevice, pUser2Device, CFX_PointF(fx, rect.bottom),
- CFX_PointF(fx, rect.top),
- ArgbEncode(nTransparency, nGray, nGray, nGray), 1.5f);
- }
- }
-}
-
-void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- const CFX_FloatRect& rect,
- float fWidth,
- const CFX_Color& color,
- const CFX_Color& crLeftTop,
- const CFX_Color& crRightBottom,
- BorderStyle nStyle,
- int32_t nTransparency) {
- float fLeft = rect.left;
- float fRight = rect.right;
- float fTop = rect.top;
- float fBottom = rect.bottom;
-
- if (fWidth > 0.0f) {
- float fHalfWidth = fWidth / 2.0f;
-
- switch (nStyle) {
- default:
- case BorderStyle::SOLID: {
- CFX_PathData path;
- path.AppendRect(fLeft, fBottom, fRight, fTop);
- path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth,
- fTop - fWidth);
- pDevice->DrawPath(&path, pUser2Device, nullptr,
- color.ToFXColor(nTransparency), 0, FXFILL_ALTERNATE);
- break;
- }
- case BorderStyle::DASH: {
- CFX_PathData path;
- path.AppendPoint(
- CFX_PointF(fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f),
- FXPT_TYPE::MoveTo, false);
- path.AppendPoint(
- CFX_PointF(fLeft + fWidth / 2.0f, fTop - fWidth / 2.0f),
- FXPT_TYPE::LineTo, false);
- path.AppendPoint(
- CFX_PointF(fRight - fWidth / 2.0f, fTop - fWidth / 2.0f),
- FXPT_TYPE::LineTo, false);
- path.AppendPoint(
- CFX_PointF(fRight - fWidth / 2.0f, fBottom + fWidth / 2.0f),
- FXPT_TYPE::LineTo, false);
- path.AppendPoint(
- CFX_PointF(fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f),
- FXPT_TYPE::LineTo, false);
-
- CFX_GraphStateData gsd;
- gsd.SetDashCount(2);
- gsd.m_DashArray[0] = 3.0f;
- gsd.m_DashArray[1] = 3.0f;
- gsd.m_DashPhase = 0;
-
- gsd.m_LineWidth = fWidth;
- pDevice->DrawPath(&path, pUser2Device, &gsd, 0,
- color.ToFXColor(nTransparency), FXFILL_WINDING);
- break;
- }
- case BorderStyle::BEVELED:
- case BorderStyle::INSET: {
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = fHalfWidth;
-
- CFX_PathData pathLT;
-
- pathLT.AppendPoint(CFX_PointF(fLeft + fHalfWidth, fBottom + fHalfWidth),
- FXPT_TYPE::MoveTo, false);
- pathLT.AppendPoint(CFX_PointF(fLeft + fHalfWidth, fTop - fHalfWidth),
- FXPT_TYPE::LineTo, false);
- pathLT.AppendPoint(CFX_PointF(fRight - fHalfWidth, fTop - fHalfWidth),
- FXPT_TYPE::LineTo, false);
- pathLT.AppendPoint(
- CFX_PointF(fRight - fHalfWidth * 2, fTop - fHalfWidth * 2),
- FXPT_TYPE::LineTo, false);
- pathLT.AppendPoint(
- CFX_PointF(fLeft + fHalfWidth * 2, fTop - fHalfWidth * 2),
- FXPT_TYPE::LineTo, false);
- pathLT.AppendPoint(
- CFX_PointF(fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2),
- FXPT_TYPE::LineTo, false);
- pathLT.AppendPoint(CFX_PointF(fLeft + fHalfWidth, fBottom + fHalfWidth),
- FXPT_TYPE::LineTo, false);
-
- pDevice->DrawPath(&pathLT, pUser2Device, &gsd,
- crLeftTop.ToFXColor(nTransparency), 0,
- FXFILL_ALTERNATE);
-
- CFX_PathData pathRB;
- pathRB.AppendPoint(CFX_PointF(fRight - fHalfWidth, fTop - fHalfWidth),
- FXPT_TYPE::MoveTo, false);
- pathRB.AppendPoint(
- CFX_PointF(fRight - fHalfWidth, fBottom + fHalfWidth),
- FXPT_TYPE::LineTo, false);
- pathRB.AppendPoint(CFX_PointF(fLeft + fHalfWidth, fBottom + fHalfWidth),
- FXPT_TYPE::LineTo, false);
- pathRB.AppendPoint(
- CFX_PointF(fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2),
- FXPT_TYPE::LineTo, false);
- pathRB.AppendPoint(
- CFX_PointF(fRight - fHalfWidth * 2, fBottom + fHalfWidth * 2),
- FXPT_TYPE::LineTo, false);
- pathRB.AppendPoint(
- CFX_PointF(fRight - fHalfWidth * 2, fTop - fHalfWidth * 2),
- FXPT_TYPE::LineTo, false);
- pathRB.AppendPoint(CFX_PointF(fRight - fHalfWidth, fTop - fHalfWidth),
- FXPT_TYPE::LineTo, false);
-
- pDevice->DrawPath(&pathRB, pUser2Device, &gsd,
- crRightBottom.ToFXColor(nTransparency), 0,
- FXFILL_ALTERNATE);
-
- CFX_PathData path;
-
- path.AppendRect(fLeft, fBottom, fRight, fTop);
- path.AppendRect(fLeft + fHalfWidth, fBottom + fHalfWidth,
- fRight - fHalfWidth, fTop - fHalfWidth);
-
- pDevice->DrawPath(&path, pUser2Device, &gsd,
- color.ToFXColor(nTransparency), 0, FXFILL_ALTERNATE);
- break;
- }
- case BorderStyle::UNDERLINE: {
- CFX_PathData path;
- path.AppendPoint(CFX_PointF(fLeft, fBottom + fWidth / 2),
- FXPT_TYPE::MoveTo, false);
- path.AppendPoint(CFX_PointF(fRight, fBottom + fWidth / 2),
- FXPT_TYPE::LineTo, false);
-
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = fWidth;
-
- pDevice->DrawPath(&path, pUser2Device, &gsd, 0,
- color.ToFXColor(nTransparency), FXFILL_ALTERNATE);
- break;
- }
- }
- }
-}
diff --git a/fpdfsdk/pdfwindow/cpwl_utils.h b/fpdfsdk/pdfwindow/cpwl_utils.h
index 70680c71d9..67876edbc3 100644
--- a/fpdfsdk/pdfwindow/cpwl_utils.h
+++ b/fpdfsdk/pdfwindow/cpwl_utils.h
@@ -77,49 +77,6 @@ class CPWL_Utils {
const CPVT_WordRange* pRange = nullptr);
static CFX_ByteString GetDropButtonAppStream(const CFX_FloatRect& rcBBox);
- static void DrawFillRect(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- const CFX_FloatRect& rect,
- const CFX_Color& color,
- int32_t nTransparency);
- static void DrawFillRect(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- const CFX_FloatRect& rect,
- const FX_COLORREF& color);
- static void DrawStrokeRect(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- const CFX_FloatRect& rect,
- const FX_COLORREF& color,
- float fWidth);
- static void DrawStrokeLine(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- const CFX_PointF& ptMoveTo,
- const CFX_PointF& ptLineTo,
- const FX_COLORREF& color,
- float fWidth);
- static void DrawBorder(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- const CFX_FloatRect& rect,
- float fWidth,
- const CFX_Color& color,
- const CFX_Color& crLeftTop,
- const CFX_Color& crRightBottom,
- BorderStyle nStyle,
- int32_t nTransparency);
- static void DrawFillArea(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- const CFX_PointF* pPts,
- int32_t nCount,
- const FX_COLORREF& color);
- static void DrawShadow(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- bool bVertical,
- bool bHorizontal,
- CFX_FloatRect rect,
- int32_t nTransparency,
- int32_t nStartGray,
- int32_t nEndGray);
-
private:
static CFX_ByteString GetAppStream_Check(const CFX_FloatRect& rcBBox,
const CFX_Color& crText);
diff --git a/fpdfsdk/pdfwindow/cpwl_wnd.cpp b/fpdfsdk/pdfwindow/cpwl_wnd.cpp
index 863b9aab9a..d3ff2a5743 100644
--- a/fpdfsdk/pdfwindow/cpwl_wnd.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_wnd.cpp
@@ -10,6 +10,7 @@
#include <sstream>
#include <vector>
+#include "core/fxge/cfx_renderdevice.h"
#include "fpdfsdk/pdfwindow/cpwl_scroll_bar.h"
#include "fpdfsdk/pdfwindow/cpwl_utils.h"
#include "third_party/base/ptr_util.h"
@@ -293,17 +294,16 @@ void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice,
if (HasFlag(PWS_BACKGROUND)) {
float width = static_cast<float>(GetBorderWidth() + GetInnerBorderWidth());
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device,
- rectWnd.GetDeflated(width, width),
- GetBackgroundColor(), GetTransparency());
+ pDevice->DrawFillRect(pUser2Device, rectWnd.GetDeflated(width, width),
+ GetBackgroundColor(), GetTransparency());
}
if (HasFlag(PWS_BORDER)) {
- CPWL_Utils::DrawBorder(pDevice, pUser2Device, rectWnd,
- (float)GetBorderWidth(), GetBorderColor(),
- GetBorderLeftTopColor(GetBorderStyle()),
- GetBorderRightBottomColor(GetBorderStyle()),
- GetBorderStyle(), GetTransparency());
+ pDevice->DrawBorder(pUser2Device, rectWnd,
+ static_cast<float>(GetBorderWidth()), GetBorderColor(),
+ GetBorderLeftTopColor(GetBorderStyle()),
+ GetBorderRightBottomColor(GetBorderStyle()),
+ GetBorderStyle(), GetTransparency());
}
}