7#include "xfa/fwl/theme/cfwl_checkboxtp.h"
14#include "core/fxge/cfx_path.h"
15#include "xfa/fde/cfde_textout.h"
16#include "xfa/fgas/graphics/cfgas_gecolor.h"
17#include "xfa/fgas/graphics/cfgas_gegraphics.h"
18#include "xfa/fgas/graphics/cfgas_gepath.h"
19#include "xfa/fwl/cfwl_checkbox.h"
20#include "xfa/fwl/cfwl_themebackground.h"
21#include "xfa/fwl/cfwl_themetext.h"
22#include "xfa/fwl/cfwl_widget.h"
28constexpr int kSignPath = 100;
39CFWL_CheckBoxTP::CFWL_CheckBoxTP() =
default;
43void CFWL_CheckBoxTP::
DrawText(
const CFWL_ThemeText& pParams) {
45 m_pTextOut->SetTextColor(pParams.m_dwStates & CFWL_PartState::kDisabled
55 EnsureCheckPathInitialized(rtSign
.width);
64 pGraphics->FillPath(*m_pCheckPath, CFX_FillRenderOptions::FillType::kWinding,
87 path
.AddLine(rtSign.TopLeft()
, CFX_PointF(fRight, fBottom)
);
89 CFX_PointF(fRight, rtSign
.top)
);
102 const float fWidth = rtSign
.width;
103 const float fHeight = rtSign
.height;
134 float fRadius = (rtSign
.top - fBottom) / (1 + cosf(
FXSYS_PI / 5.0f));
135 CFX_PointF ptCenter((rtSign.left + rtSign.right()) / 2.0f,
136 (rtSign.top + fBottom) / 2.0f);
140 for (
auto& point : points) {
142 ptCenter + CFX_PointF(fRadius * cosf(fAngle), fRadius * sinf(fAngle));
148 for (size_t i = 0; i <
std::size(points); ++i) {
149 next = (next + 2) %
std::size(points);
158void CFWL_CheckBoxTP::EnsureCheckPathInitialized(
float fCheckLen) {
162 m_pCheckPath = std::make_unique<CFGAS_GEPath>();
164 float fWidth = kSignPath;
165 float fHeight = -kSignPath;
166 float fBottom = kSignPath;
167 CFX_PointF pt1(fWidth / 15.0f, fBottom + fHeight * 2 / 5.0f);
168 CFX_PointF pt2(fWidth / 4.5f, fBottom + fHeight / 16.0f);
170 CFX_PointF pt4(fWidth * 14 / 15.0f, fBottom + fHeight * 15 / 16.0f);
171 CFX_PointF pt5(fWidth / 3.6f, fBottom + fHeight / 3.5f);
172 CFX_PointF pt12(fWidth / 7.0f, fBottom + fHeight * 2 / 7.0f);
173 CFX_PointF pt21(fWidth / 5.0f, fBottom + fHeight / 5.0f);
174 CFX_PointF pt23(fWidth / 4.4f, fBottom + fHeight * 0 / 16.0f);
176 CFX_PointF pt34(fWidth * (1 / 7.0f + 7 / 15.0f),
177 fBottom + fHeight * 4 / 5.0f);
178 CFX_PointF pt43(fWidth * (1 / 7.0f + 7 / 15.0f),
179 fBottom + fHeight * 4 / 5.0f);
180 CFX_PointF pt45(fWidth * 7 / 15.0f, fBottom + fHeight * 8 / 7.0f);
181 CFX_PointF pt54(fWidth / 3.4f, fBottom + fHeight / 3.5f);
182 CFX_PointF pt51(fWidth / 3.6f, fBottom + fHeight / 4.0f);
183 CFX_PointF pt15(fWidth / 3.5f, fBottom + fHeight * 3.5f / 5.0f);
184 m_pCheckPath->MoveTo(pt1);
188 m_pCheckPath->BezierTo(pt1 + p1, pt2 + p2, pt2);
190 p1 = ScaleBezierPoint(pt23 - pt2);
191 p2 = ScaleBezierPoint(pt32 - pt3);
192 m_pCheckPath->BezierTo(pt2 + p1, pt3 + p2, pt3);
194 p1 = ScaleBezierPoint(pt34 - pt3);
195 p2 = ScaleBezierPoint(pt43 - pt4);
196 m_pCheckPath->BezierTo(pt3 + p1, pt4 + p2, pt4);
198 p1 = ScaleBezierPoint(pt45 - pt4);
199 p2 = ScaleBezierPoint(pt54 - pt5);
200 m_pCheckPath->BezierTo(pt4 + p1, pt5 + p2, pt5);
202 p1 = ScaleBezierPoint(pt51 - pt5);
203 p2 = ScaleBezierPoint(pt15 - pt1);
204 m_pCheckPath->BezierTo(pt5 + p1, pt1 + p2, pt1);
206 float fScale = fCheckLen / kSignPath;
209 m_pCheckPath->TransformBy(mt);
223void CFWL_CheckBoxTP::DrawCheckSign(
CFWL_Widget* pWidget,
235 DrawSignCheck(pGraphics, rtSign, dwColor, matrix);
238 DrawSignCircle(pGraphics, rtSign, dwColor, matrix);
241 DrawSignCross(pGraphics, rtSign, dwColor, matrix);
244 DrawSignDiamond(pGraphics, rtSign, dwColor, matrix);
247 DrawSignSquare(pGraphics, rtSign, dwColor, matrix);
250 DrawSignStar(pGraphics, rtSign, dwColor, matrix);
#define FWL_STYLEEXT_CKB_SignShapeMask
#define FWL_STYLEEXT_CKB_SignShapeSquare
#define FWL_STYLEEXT_CKB_SignShapeCheck
#define FWL_STYLEEXT_CKB_SignShapeStar
#define FWL_STYLEEXT_CKB_SignShapeCircle
#define FWL_STYLEEXT_CKB_SignShapeDiamond
#define FWL_STYLEEXT_CKB_SignShapeCross
#define FWLTHEME_CAPACITY_TextDisColor
#define FWLTHEME_CAPACITY_TextColor
CFGAS_GEColor(FX_ARGB argb)
StateRestorer(CFGAS_GEGraphics *graphics)
void FillPath(const CFGAS_GEPath &path, CFX_FillRenderOptions::FillType fill_type, const CFX_Matrix &matrix)
void SetLineWidth(float lineWidth)
void SetStrokeColor(const CFGAS_GEColor &color)
void SetFillColor(const CFGAS_GEColor &color)
void StrokePath(const CFGAS_GEPath &path, const CFX_Matrix &matrix)
void AddLine(const CFX_PointF &p1, const CFX_PointF &p2)
void MoveTo(const CFX_PointF &point)
void AddRectangle(float left, float top, float width, float height)
void AddEllipse(const CFX_RectF &rect)
void LineTo(const CFX_PointF &point)
void Scale(float sx, float sy)
void Translate(float x, float y)
void Concat(const CFX_Matrix &right)
CFX_RectF(const CFX_RectF &other)=default
void Deflate(float x, float y)
void DrawBackground(const CFWL_ThemeBackground &pParams) override
~CFWL_CheckBoxTP() override
void DrawText(const CFWL_ThemeText &pParams) override
CFGAS_GEGraphics * GetGraphics() const
CFWL_Widget * GetWidget() const
CFX_PTemplate< float > CFX_PointF