summaryrefslogtreecommitdiff
path: root/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2017-06-29 11:18:49 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-06-29 15:40:59 +0000
commitf1eae2c37cb4bbf7a536cf251706147bbac51880 (patch)
tree8eead543163dddefc63a518d9d44b5ca1ee49875 /fpdfsdk/pdfwindow/cpwl_combo_box.cpp
parenta0b48aa8043be95e5c6b602e0e261fb163282536 (diff)
downloadpdfium-f1eae2c37cb4bbf7a536cf251706147bbac51880.tar.xz
Converted low-hanging cpwl classes in CFX_ByteTextBuf to ostringstream.
Bug: pdfium:731 Change-Id: I3faf5a4ec4b2af6145348e526f39ccbc2055e62e Reviewed-on: https://pdfium-review.googlesource.com/7050 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/pdfwindow/cpwl_combo_box.cpp')
-rw-r--r--fpdfsdk/pdfwindow/cpwl_combo_box.cpp99
1 files changed, 49 insertions, 50 deletions
diff --git a/fpdfsdk/pdfwindow/cpwl_combo_box.cpp b/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
index 2929aac90f..3a6f08c6cd 100644
--- a/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_combo_box.cpp
@@ -7,6 +7,7 @@
#include "fpdfsdk/pdfwindow/cpwl_combo_box.h"
#include <algorithm>
+#include <sstream>
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/cfx_renderdevice.h"
@@ -96,35 +97,33 @@ bool CPWL_CBListBox::OnCharWithExit(uint16_t nChar,
return true;
}
-void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
+void CPWL_CBButton::GetThisAppearanceStream(std::ostringstream* psAppStream) {
+ CPWL_Wnd::GetThisAppearanceStream(psAppStream);
CFX_FloatRect rectWnd = CPWL_Wnd::GetWindowRect();
- if (IsVisible() && !rectWnd.IsEmpty()) {
- CFX_ByteTextBuf sButton;
-
- CFX_PointF ptCenter = GetCenterPoint();
-
- CFX_PointF pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,
- ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CFX_PointF pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,
- ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CFX_PointF pt3(ptCenter.x,
- ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
-
- if (IsFloatBigger(rectWnd.right - rectWnd.left,
- PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) &&
- IsFloatBigger(rectWnd.top - rectWnd.bottom,
- PWL_CBBUTTON_TRIANGLE_HALFLEN)) {
- sButton << "0 g\n";
- sButton << pt1.x << " " << pt1.y << " m\n";
- sButton << pt2.x << " " << pt2.y << " l\n";
- sButton << pt3.x << " " << pt3.y << " l\n";
- sButton << pt1.x << " " << pt1.y << " l f\n";
-
- sAppStream << "q\n" << sButton << "Q\n";
- }
+ if (!IsVisible() || rectWnd.IsEmpty())
+ return;
+
+ CFX_PointF ptCenter = GetCenterPoint();
+
+ CFX_PointF pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,
+ ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+ CFX_PointF pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,
+ ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+ CFX_PointF pt3(ptCenter.x, ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+
+ if (IsFloatBigger(rectWnd.right - rectWnd.left,
+ PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) &&
+ IsFloatBigger(rectWnd.top - rectWnd.bottom,
+ PWL_CBBUTTON_TRIANGLE_HALFLEN)) {
+ *psAppStream << "q\n"
+ << "0 g\n"
+ << pt1.x << " " << pt1.y << " m\n"
+ << pt2.x << " " << pt2.y << " l\n"
+ << pt3.x << " " << pt3.y << " l\n"
+ << pt1.x << " " << pt1.y << " l f\n"
+ << "Q\n";
}
}
@@ -134,30 +133,30 @@ void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_FloatRect rectWnd = CPWL_Wnd::GetWindowRect();
- if (IsVisible() && !rectWnd.IsEmpty()) {
- CFX_PointF ptCenter = GetCenterPoint();
-
- CFX_PointF pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,
- ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CFX_PointF pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,
- ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CFX_PointF pt3(ptCenter.x,
- ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
-
- if (IsFloatBigger(rectWnd.right - rectWnd.left,
- PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) &&
- IsFloatBigger(rectWnd.top - rectWnd.bottom,
- PWL_CBBUTTON_TRIANGLE_HALFLEN)) {
- CFX_PathData path;
- path.AppendPoint(pt1, FXPT_TYPE::MoveTo, false);
- path.AppendPoint(pt2, FXPT_TYPE::LineTo, false);
- path.AppendPoint(pt3, FXPT_TYPE::LineTo, false);
- path.AppendPoint(pt1, FXPT_TYPE::LineTo, false);
-
- pDevice->DrawPath(&path, pUser2Device, nullptr,
- PWL_DEFAULT_BLACKCOLOR.ToFXColor(GetTransparency()), 0,
- FXFILL_ALTERNATE);
- }
+ if (!IsVisible() || rectWnd.IsEmpty())
+ return;
+
+ CFX_PointF ptCenter = GetCenterPoint();
+
+ CFX_PointF pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,
+ ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+ CFX_PointF pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,
+ ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+ CFX_PointF pt3(ptCenter.x, ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+
+ if (IsFloatBigger(rectWnd.right - rectWnd.left,
+ PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) &&
+ IsFloatBigger(rectWnd.top - rectWnd.bottom,
+ PWL_CBBUTTON_TRIANGLE_HALFLEN)) {
+ CFX_PathData path;
+ path.AppendPoint(pt1, FXPT_TYPE::MoveTo, false);
+ path.AppendPoint(pt2, FXPT_TYPE::LineTo, false);
+ path.AppendPoint(pt3, FXPT_TYPE::LineTo, false);
+ path.AppendPoint(pt1, FXPT_TYPE::LineTo, false);
+
+ pDevice->DrawPath(&path, pUser2Device, nullptr,
+ PWL_DEFAULT_BLACKCOLOR.ToFXColor(GetTransparency()), 0,
+ FXFILL_ALTERNATE);
}
}