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_listboxtp.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_listboxtp.h"
8
9#include "build/build_config.h"
10#include "xfa/fgas/graphics/cfgas_gecolor.h"
11#include "xfa/fgas/graphics/cfgas_gegraphics.h"
12#include "xfa/fgas/graphics/cfgas_gepath.h"
13#include "xfa/fwl/cfwl_listbox.h"
14#include "xfa/fwl/cfwl_themebackground.h"
15#include "xfa/fwl/cfwl_widget.h"
16
17namespace pdfium {
18
19CFWL_ListBoxTP::CFWL_ListBoxTP() = default;
20
21CFWL_ListBoxTP::~CFWL_ListBoxTP() = default;
22
23void CFWL_ListBoxTP::DrawBackground(const CFWL_ThemeBackground& pParams) {
24 switch (pParams.GetPart()) {
26 DrawBorder(pParams.GetGraphics(), pParams.m_PartRect, pParams.m_matrix);
27 break;
28 }
30 FillSolidRect(pParams.GetGraphics(), ArgbEncode(255, 255, 255, 255),
31 pParams.m_PartRect, pParams.m_matrix);
32 if (pParams.m_pRtData) {
34 *pParams.m_pRtData, pParams.m_matrix);
35 }
36 break;
37 }
39 DrawListBoxItem(pParams.GetGraphics(), pParams.m_dwStates,
40 pParams.m_PartRect, pParams.m_pRtData, pParams.m_matrix);
41 break;
42 }
44 uint32_t color = 0xFF000000;
45 if (pParams.m_dwStates == CFWL_PartState::kChecked) {
46 color = 0xFFFF0000;
47 } else if (pParams.m_dwStates == CFWL_PartState::kNormal) {
48 color = 0xFF0000FF;
49 }
50 FillSolidRect(pParams.GetGraphics(), color, pParams.m_PartRect,
51 pParams.m_matrix);
52 break;
53 }
54 default:
55 break;
56 }
57}
58
59void CFWL_ListBoxTP::DrawListBoxItem(CFGAS_GEGraphics* pGraphics,
60 Mask<CFWL_PartState> dwStates,
61 const CFX_RectF& rtItem,
62 const CFX_RectF* pData,
63 const CFX_Matrix& matrix) {
64 if (dwStates & CFWL_PartState::kSelected) {
65 CFGAS_GEGraphics::StateRestorer restorer(pGraphics);
67 CFGAS_GEPath path;
68#if BUILDFLAG(IS_APPLE)
69 path.AddRectangle(rtItem.left, rtItem.top, rtItem.width - 1,
70 rtItem.height - 1);
71#else
72 path.AddRectangle(rtItem.left, rtItem.top, rtItem.width, rtItem.height);
73#endif
75 matrix);
76 }
77 if ((dwStates & CFWL_PartState::kFocused) && pData)
78 DrawFocus(pGraphics, *pData, matrix);
79}
80
81} // namespace pdfium
#define FWLTHEME_COLOR_BKSelected
Definition cfwl_utils.h:23
#define FWLTHEME_COLOR_Background
Definition cfwl_utils.h:22
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 AddRectangle(float left, float top, float width, float height)
void DrawBackground(const CFWL_ThemeBackground &pParams) override
~CFWL_ListBoxTP() override
CFGAS_GEGraphics * GetGraphics() const
void DrawFocus(CFGAS_GEGraphics *pGraphics, const CFX_RectF &rect, const CFX_Matrix &matrix)
void DrawBorder(CFGAS_GEGraphics *pGraphics, const CFX_RectF &rect, const CFX_Matrix &matrix)
void FillSolidRect(CFGAS_GEGraphics *pGraphics, FX_ARGB fillColor, const CFX_RectF &rect, const CFX_Matrix &matrix)
constexpr FX_ARGB ArgbEncode(uint32_t a, uint32_t r, uint32_t g, uint32_t b)
Definition fx_dib.h:188