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
17namespace pdfium {
18
19CFWL_ScrollBarTP::CFWL_ScrollBarTP()
20 : m_pThemeData(std::make_unique<SBThemeData>()) {
21 SetThemeData();
22}
23
24CFWL_ScrollBarTP::~CFWL_ScrollBarTP() = default;
25
26void CFWL_ScrollBarTP::DrawBackground(const CFWL_ThemeBackground& pParams) {
27 CFWL_Widget* pWidget = pParams.GetWidget();
28 CFGAS_GEGraphics* pGraphics = pParams.GetGraphics();
29 bool bVert = !!pWidget->GetStyleExts();
30 switch (pParams.GetPart()) {
32 DrawMaxMinBtn(pGraphics, pParams.m_PartRect,
34 pParams.GetThemeState(), pParams.m_matrix);
35 break;
36 }
38 DrawMaxMinBtn(
39 pGraphics, pParams.m_PartRect,
41 pParams.GetThemeState(), pParams.m_matrix);
42 break;
43 }
45 DrawThumbBtn(pGraphics, pParams.m_PartRect, bVert,
46 pParams.GetThemeState(), pParams.m_matrix);
47 break;
48 }
50 DrawTrack(pGraphics, pParams.m_PartRect, bVert, pParams.GetThemeState(),
51 true, pParams.m_matrix);
52 break;
53 }
55 DrawTrack(pGraphics, pParams.m_PartRect, bVert, pParams.GetThemeState(),
56 false, pParams.m_matrix);
57 break;
58 }
59 default:
60 break;
61 }
62}
63
64void CFWL_ScrollBarTP::DrawThumbBtn(CFGAS_GEGraphics* pGraphics,
65 const CFX_RectF& input_rect,
66 bool bVert,
67 FWLTHEME_STATE eState,
68 const CFX_Matrix& matrix) {
70 return;
71
72 CFX_RectF rect = input_rect;
73 if (bVert)
74 rect.Deflate(1, 0);
75 else
76 rect.Deflate(0, 1);
77
78 if (rect.IsEmpty(0.1f))
79 return;
80
81 FillSolidRect(pGraphics,
82 m_pThemeData->clrBtnBK[static_cast<size_t>(eState) - 1], rect,
83 matrix);
84
85 CFGAS_GEGraphics::StateRestorer restorer(pGraphics);
86 CFGAS_GEPath path;
87 path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
88 pGraphics->SetStrokeColor(CFGAS_GEColor(
89 m_pThemeData->clrBtnBorder[static_cast<size_t>(eState) - 1]));
90 pGraphics->StrokePath(path, matrix);
91}
92
93void CFWL_ScrollBarTP::DrawTrack(CFGAS_GEGraphics* pGraphics,
94 const CFX_RectF& rect,
95 bool bVert,
96 FWLTHEME_STATE eState,
97 bool bLowerTrack,
98 const CFX_Matrix& matrix) {
100 return;
101
102 {
103 CFGAS_GEGraphics::StateRestorer restorer(pGraphics);
104 CFGAS_GEPath path;
105 float fRight = rect.right();
106 float fBottom = rect.bottom();
107 if (bVert) {
108 path.AddRectangle(rect.left, rect.top, 1, rect.height);
109 path.AddRectangle(fRight - 1, rect.top, 1, rect.height);
110 } else {
111 path.AddRectangle(rect.left, rect.top, rect.width, 1);
112 path.AddRectangle(rect.left, fBottom - 1, rect.width, 1);
113 }
116 matrix);
117 path.Clear();
118 path.AddRectangle(rect.left + 1, rect.top, rect.width - 2, rect.height);
119 }
120 FillSolidRect(pGraphics, m_pThemeData->clrTrackBKEnd, rect, matrix);
121}
122
123void CFWL_ScrollBarTP::DrawMaxMinBtn(CFGAS_GEGraphics* pGraphics,
124 const CFX_RectF& rect,
125 FWLTHEME_DIRECTION eDict,
126 FWLTHEME_STATE eState,
127 const CFX_Matrix& matrix) {
128 DrawTrack(
129 pGraphics, rect,
131 eState, true, matrix);
132 CFX_RectF rtArrowBtn = rect;
133 rtArrowBtn.Deflate(1, 1, 1, 1);
134 DrawArrowBtn(pGraphics, rtArrowBtn, eDict, eState, matrix);
135}
136
137void CFWL_ScrollBarTP::SetThemeData() {
138 m_pThemeData->clrTrackBKStart = ArgbEncode(0xff, 243, 241, 236);
139 m_pThemeData->clrTrackBKEnd = ArgbEncode(0xff, 254, 254, 251);
140 m_pThemeData->clrBtnBK[0] = ArgbEncode(0xff, 182, 205, 251);
141 m_pThemeData->clrBtnBK[1] = ArgbEncode(0xff, 204, 225, 255);
142 m_pThemeData->clrBtnBK[2] = ArgbEncode(0xff, 146, 179, 249);
143 m_pThemeData->clrBtnBK[3] = ArgbEncode(0xff, 141, 157, 115);
144 m_pThemeData->clrBtnBorder[0] = ArgbEncode(0xff, 148, 176, 221);
145 m_pThemeData->clrBtnBorder[1] = ArgbEncode(0xff, 218, 230, 254);
146 m_pThemeData->clrBtnBorder[2] = ArgbEncode(0xff, 124, 159, 211);
147 m_pThemeData->clrBtnBorder[3] = ArgbEncode(0xff, 236, 233, 216);
148}
149
150} // namespace pdfium
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 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)
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)
void DrawBackground(const CFWL_ThemeBackground &pParams) override
CFGAS_GEGraphics * GetGraphics() const
CFWL_Widget * GetWidget() const
FWLTHEME_STATE GetThemeState() const
void DrawArrowBtn(CFGAS_GEGraphics *pGraphics, const CFX_RectF &rect, FWLTHEME_DIRECTION eDict, FWLTHEME_STATE eState, const CFX_Matrix &matrix)
uint32_t GetStyleExts() const
constexpr FX_ARGB ArgbEncode(uint32_t a, uint32_t r, uint32_t g, uint32_t b)
Definition fx_dib.h:188
FWLTHEME_DIRECTION
Definition cfwl_utils.h:19
FWLTHEME_STATE
Definition cfwl_utils.h:17