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
17CFWL_ListBoxTP::CFWL_ListBoxTP() = default;
18
19CFWL_ListBoxTP::~CFWL_ListBoxTP() = default;
20
21void CFWL_ListBoxTP::DrawBackground(const CFWL_ThemeBackground& pParams) {
22 switch (pParams.GetPart()) {
24 DrawBorder(pParams.GetGraphics(), pParams.m_PartRect, pParams.m_matrix);
25 break;
26 }
28 FillSolidRect(pParams.GetGraphics(), ArgbEncode(255, 255, 255, 255),
29 pParams.m_PartRect, pParams.m_matrix);
30 if (pParams.m_pRtData) {
32 *pParams.m_pRtData, pParams.m_matrix);
33 }
34 break;
35 }
37 DrawListBoxItem(pParams.GetGraphics(), pParams.m_dwStates,
38 pParams.m_PartRect, pParams.m_pRtData, pParams.m_matrix);
39 break;
40 }
42 uint32_t color = 0xFF000000;
43 if (pParams.m_dwStates == CFWL_PartState::kChecked) {
44 color = 0xFFFF0000;
45 } else if (pParams.m_dwStates == CFWL_PartState::kNormal) {
46 color = 0xFF0000FF;
47 }
48 FillSolidRect(pParams.GetGraphics(), color, pParams.m_PartRect,
49 pParams.m_matrix);
50 break;
51 }
52 default:
53 break;
54 }
55}
56
57void CFWL_ListBoxTP::DrawListBoxItem(CFGAS_GEGraphics* pGraphics,
58 Mask<CFWL_PartState> dwStates,
59 const CFX_RectF& rtItem,
60 const CFX_RectF* pData,
61 const CFX_Matrix& matrix) {
62 if (dwStates & CFWL_PartState::kSelected) {
63 CFGAS_GEGraphics::StateRestorer restorer(pGraphics);
65 CFGAS_GEPath path;
66#if BUILDFLAG(IS_APPLE)
67 path.AddRectangle(rtItem.left, rtItem.top, rtItem.width - 1,
68 rtItem.height - 1);
69#else
70 path.AddRectangle(rtItem.left, rtItem.top, rtItem.width, rtItem.height);
71#endif
73 matrix);
74 }
75 if ((dwStates & CFWL_PartState::kFocused) && pData)
76 DrawFocus(pGraphics, *pData, matrix);
77}
CFWL_PartState
#define FWLTHEME_COLOR_BKSelected
Definition cfwl_utils.h:21
#define FWLTHEME_COLOR_Background
Definition cfwl_utils.h:20
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 AddRectangle(float left, float top, float width, float height)
~CFWL_ListBoxTP() override
void DrawBackground(const CFWL_ThemeBackground &pParams) override
CFGAS_GEGraphics * GetGraphics() const
CFX_RectF m_PartRect
CFX_Matrix m_matrix
Part GetPart() const
void DrawBorder(CFGAS_GEGraphics *pGraphics, const CFX_RectF &rect, const CFX_Matrix &matrix)
void DrawFocus(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:118