7#include "xfa/fwl/theme/cfwl_checkboxtp.h"
13#include "core/fxge/cfx_path.h"
14#include "xfa/fde/cfde_textout.h"
15#include "xfa/fgas/graphics/cfgas_gecolor.h"
16#include "xfa/fgas/graphics/cfgas_gegraphics.h"
17#include "xfa/fgas/graphics/cfgas_gepath.h"
18#include "xfa/fwl/cfwl_checkbox.h"
19#include "xfa/fwl/cfwl_themebackground.h"
20#include "xfa/fwl/cfwl_themetext.h"
21#include "xfa/fwl/cfwl_widget.h"
25constexpr int kSignPath = 100;
27CFX_PointF ScaleBezierPoint(
const CFX_PointF& point) {
28 CFX_PointF scaled_point(point);
36CFWL_CheckBoxTP::CFWL_CheckBoxTP() =
default;
40void CFWL_CheckBoxTP::
DrawText(
const CFWL_ThemeText& pParams) {
42 m_pTextOut->SetTextColor(pParams.m_dwStates & CFWL_PartState::kDisabled
52 EnsureCheckPathInitialized(rtSign
.width);
61 pGraphics->FillPath(*m_pCheckPath, CFX_FillRenderOptions::FillType::kWinding,
84 path
.AddLine(rtSign.TopLeft()
, CFX_PointF(fRight, fBottom)
);
86 CFX_PointF(fRight, rtSign
.top)
);
99 const float fWidth = rtSign
.width;
100 const float fHeight = rtSign
.height;
131 float fRadius = (rtSign
.top - fBottom) / (1 + cosf(
FXSYS_PI / 5.0f));
132 CFX_PointF ptCenter((rtSign.left + rtSign.right()) / 2.0f,
133 (rtSign.top + fBottom) / 2.0f);
135 CFX_PointF points[5];
137 for (
auto& point : points) {
139 ptCenter + CFX_PointF(fRadius * cosf(fAngle), fRadius * sinf(fAngle));
145 for (size_t i = 0; i <
std::size(points); ++i) {
146 next = (next + 2) %
std::size(points);
155void CFWL_CheckBoxTP::EnsureCheckPathInitialized(
float fCheckLen) {
159 m_pCheckPath = std::make_unique<CFGAS_GEPath>();
161 float fWidth = kSignPath;
162 float fHeight = -kSignPath;
163 float fBottom = kSignPath;
164 CFX_PointF pt1(fWidth / 15.0f, fBottom + fHeight * 2 / 5.0f);
165 CFX_PointF pt2(fWidth / 4.5f, fBottom + fHeight / 16.0f);
166 CFX_PointF pt3(fWidth / 3.0f, fBottom);
167 CFX_PointF pt4(fWidth * 14 / 15.0f, fBottom + fHeight * 15 / 16.0f);
168 CFX_PointF pt5(fWidth / 3.6f, fBottom + fHeight / 3.5f);
169 CFX_PointF pt12(fWidth / 7.0f, fBottom + fHeight * 2 / 7.0f);
170 CFX_PointF pt21(fWidth / 5.0f, fBottom + fHeight / 5.0f);
171 CFX_PointF pt23(fWidth / 4.4f, fBottom + fHeight * 0 / 16.0f);
172 CFX_PointF pt32(fWidth / 4.0f, fBottom);
173 CFX_PointF pt34(fWidth * (1 / 7.0f + 7 / 15.0f),
174 fBottom + fHeight * 4 / 5.0f);
175 CFX_PointF pt43(fWidth * (1 / 7.0f + 7 / 15.0f),
176 fBottom + fHeight * 4 / 5.0f);
177 CFX_PointF pt45(fWidth * 7 / 15.0f, fBottom + fHeight * 8 / 7.0f);
178 CFX_PointF pt54(fWidth / 3.4f, fBottom + fHeight / 3.5f);
179 CFX_PointF pt51(fWidth / 3.6f, fBottom + fHeight / 4.0f);
180 CFX_PointF pt15(fWidth / 3.5f, fBottom + fHeight * 3.5f / 5.0f);
181 m_pCheckPath->MoveTo(pt1);
183 CFX_PointF p1 = ScaleBezierPoint(pt12 - pt1);
184 CFX_PointF p2 = ScaleBezierPoint(pt21 - pt2);
185 m_pCheckPath->BezierTo(pt1 + p1, pt2 + p2, pt2);
187 p1 = ScaleBezierPoint(pt23 - pt2);
188 p2 = ScaleBezierPoint(pt32 - pt3);
189 m_pCheckPath->BezierTo(pt2 + p1, pt3 + p2, pt3);
191 p1 = ScaleBezierPoint(pt34 - pt3);
192 p2 = ScaleBezierPoint(pt43 - pt4);
193 m_pCheckPath->BezierTo(pt3 + p1, pt4 + p2, pt4);
195 p1 = ScaleBezierPoint(pt45 - pt4);
196 p2 = ScaleBezierPoint(pt54 - pt5);
197 m_pCheckPath->BezierTo(pt4 + p1, pt5 + p2, pt5);
199 p1 = ScaleBezierPoint(pt51 - pt5);
200 p2 = ScaleBezierPoint(pt15 - pt1);
201 m_pCheckPath->BezierTo(pt5 + p1, pt1 + p2, pt1);
203 float fScale = fCheckLen / kSignPath;
206 m_pCheckPath->TransformBy(mt);
220void CFWL_CheckBoxTP::DrawCheckSign(
CFWL_Widget* pWidget,
232 DrawSignCheck(pGraphics, rtSign, dwColor, matrix);
235 DrawSignCircle(pGraphics, rtSign, dwColor, matrix);
238 DrawSignCross(pGraphics, rtSign, dwColor, matrix);
241 DrawSignDiamond(pGraphics, rtSign, dwColor, matrix);
244 DrawSignSquare(pGraphics, rtSign, dwColor, matrix);
247 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(const 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 DrawBackground(const CFWL_ThemeBackground &pParams) override
void DrawText(const CFWL_ThemeText &pParams) override
~CFWL_CheckBoxTP() override
CFGAS_GEGraphics * GetGraphics() const
CFWL_Widget * GetWidget() const
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)