Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cfwl_scrollbartp.cpp
Go to the documentation of this file.
1// Copyright 2014 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#include "xfa/fwl/theme/cfwl_scrollbartp.h"
8
9#include "xfa/fgas/graphics/cfgas_gecolor.h"
10#include "xfa/fgas/graphics/cfgas_gegraphics.h"
11#include "xfa/fgas/graphics/cfgas_gepath.h"
12#include "xfa/fwl/cfwl_scrollbar.h"
13#include "xfa/fwl/cfwl_themebackground.h"
14#include "xfa/fwl/cfwl_widget.h"
15#include "xfa/fwl/ifwl_themeprovider.h"
16
17CFWL_ScrollBarTP::CFWL_ScrollBarTP() : m_pThemeData(new SBThemeData) {
18 SetThemeData();
19}
20
21CFWL_ScrollBarTP::~CFWL_ScrollBarTP() = default;
22
23void CFWL_ScrollBarTP::DrawBackground(const CFWL_ThemeBackground& pParams) {
24 CFWL_Widget* pWidget = pParams.GetWidget();
25 CFGAS_GEGraphics* pGraphics = pParams.GetGraphics();
26 bool bVert = !!pWidget->GetStyleExts();
27 switch (pParams.GetPart()) {
29 DrawMaxMinBtn(pGraphics, pParams.m_PartRect,
31 pParams.GetThemeState(), pParams.m_matrix);
32 break;
33 }
35 DrawMaxMinBtn(
36 pGraphics, pParams.m_PartRect,
38 pParams.GetThemeState(), pParams.m_matrix);
39 break;
40 }
42 DrawThumbBtn(pGraphics, pParams.m_PartRect, bVert,
43 pParams.GetThemeState(), pParams.m_matrix);
44 break;
45 }
47 DrawTrack(pGraphics, pParams.m_PartRect, bVert, pParams.GetThemeState(),
48 true, pParams.m_matrix);
49 break;
50 }
52 DrawTrack(pGraphics, pParams.m_PartRect, bVert, pParams.GetThemeState(),
53 false, pParams.m_matrix);
54 break;
55 }
56 default:
57 break;
58 }
59}
60
61void CFWL_ScrollBarTP::DrawThumbBtn(CFGAS_GEGraphics* pGraphics,
62 const CFX_RectF& input_rect,
63 bool bVert,
64 FWLTHEME_STATE eState,
65 const CFX_Matrix& matrix) {
67 return;
68
69 CFX_RectF rect = input_rect;
70 if (bVert)
71 rect.Deflate(1, 0);
72 else
73 rect.Deflate(0, 1);
74
75 if (rect.IsEmpty(0.1f))
76 return;
77
78 FillSolidRect(pGraphics,
79 m_pThemeData->clrBtnBK[static_cast<size_t>(eState) - 1][1],
80 rect, matrix);
81
82 CFGAS_GEGraphics::StateRestorer restorer(pGraphics);
83 CFGAS_GEPath path;
84 path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
85 pGraphics->SetStrokeColor(CFGAS_GEColor(
86 m_pThemeData->clrBtnBorder[static_cast<size_t>(eState) - 1]));
87 pGraphics->StrokePath(path, matrix);
88}
89
90void CFWL_ScrollBarTP::DrawTrack(CFGAS_GEGraphics* pGraphics,
91 const CFX_RectF& rect,
92 bool bVert,
93 FWLTHEME_STATE eState,
94 bool bLowerTrack,
95 const CFX_Matrix& matrix) {
97 return;
98
99 {
100 CFGAS_GEGraphics::StateRestorer restorer(pGraphics);
101 CFGAS_GEPath path;
102 float fRight = rect.right();
103 float fBottom = rect.bottom();
104 if (bVert) {
105 path.AddRectangle(rect.left, rect.top, 1, rect.height);
106 path.AddRectangle(fRight - 1, rect.top, 1, rect.height);
107 } else {
108 path.AddRectangle(rect.left, rect.top, rect.width, 1);
109 path.AddRectangle(rect.left, fBottom - 1, rect.width, 1);
110 }
113 matrix);
114 path.Clear();
115 path.AddRectangle(rect.left + 1, rect.top, rect.width - 2, rect.height);
116 }
117 FillSolidRect(pGraphics, m_pThemeData->clrTrackBKEnd, rect, matrix);
118}
119
120void CFWL_ScrollBarTP::DrawMaxMinBtn(CFGAS_GEGraphics* pGraphics,
121 const CFX_RectF& rect,
122 FWLTHEME_DIRECTION eDict,
123 FWLTHEME_STATE eState,
124 const CFX_Matrix& matrix) {
125 DrawTrack(
126 pGraphics, rect,
128 eState, true, matrix);
129 CFX_RectF rtArrowBtn = rect;
130 rtArrowBtn.Deflate(1, 1, 1, 1);
131 DrawArrowBtn(pGraphics, rtArrowBtn, eDict, eState, matrix);
132}
133
134void CFWL_ScrollBarTP::SetThemeData() {
135 m_pThemeData->clrTrackBKStart = ArgbEncode(0xff, 243, 241, 236);
136 m_pThemeData->clrTrackBKEnd = ArgbEncode(0xff, 254, 254, 251);
137 m_pThemeData->clrBtnBK[0][0] = ArgbEncode(0xff, 197, 213, 252);
138 m_pThemeData->clrBtnBK[0][1] = ArgbEncode(0xff, 182, 205, 251);
139 m_pThemeData->clrBtnBK[1][0] = ArgbEncode(0xff, 216, 232, 255);
140 m_pThemeData->clrBtnBK[1][1] = ArgbEncode(0xff, 204, 225, 255);
141 m_pThemeData->clrBtnBK[2][0] = ArgbEncode(0xff, 167, 190, 245);
142 m_pThemeData->clrBtnBK[2][1] = ArgbEncode(0xff, 146, 179, 249);
143 m_pThemeData->clrBtnBK[3][0] = ArgbEncode(0xff, 164, 180, 139);
144 m_pThemeData->clrBtnBK[3][1] = ArgbEncode(0xff, 141, 157, 115);
145 m_pThemeData->clrBtnBorder[0] = ArgbEncode(0xff, 148, 176, 221);
146 m_pThemeData->clrBtnBorder[1] = ArgbEncode(0xff, 218, 230, 254);
147 m_pThemeData->clrBtnBorder[2] = ArgbEncode(0xff, 124, 159, 211);
148 m_pThemeData->clrBtnBorder[3] = ArgbEncode(0xff, 236, 233, 216);
149}
FWLTHEME_DIRECTION
Definition cfwl_utils.h:17
FWLTHEME_STATE
Definition cfwl_utils.h:15
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 SetFillColor(const CFGAS_GEColor &color)
void StrokePath(const CFGAS_GEPath &path, const CFX_Matrix &matrix)
void AddRectangle(float left, float top, float width, float height)
void DrawBackground(const CFWL_ThemeBackground &pParams) override
~CFWL_ScrollBarTP() override
CFGAS_GEGraphics * GetGraphics() const
CFWL_Widget * GetWidget() const
CFX_RectF m_PartRect
FWLTHEME_STATE GetThemeState() const
CFX_Matrix m_matrix
Part GetPart() const
void DrawArrowBtn(CFGAS_GEGraphics *pGraphics, const CFX_RectF &rect, FWLTHEME_DIRECTION eDict, FWLTHEME_STATE eState, const CFX_Matrix &matrix)
uint32_t GetStyleExts() const
bool IsEmpty(float fEpsilon) const
void Deflate(float off_left, float off_top, float off_right, float off_bottom)
float bottom() const
float right() const
void Deflate(float x, float y)
constexpr FX_ARGB ArgbEncode(uint32_t a, uint32_t r, uint32_t g, uint32_t b)
Definition fx_dib.h:118