• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_comboboxtp.h"
8 
9 #include "xfa/fgas/graphics/cfgas_gecolor.h"
10 #include "xfa/fgas/graphics/cfgas_gepath.h"
11 #include "xfa/fwl/cfwl_combobox.h"
12 #include "xfa/fwl/cfwl_themebackground.h"
13 #include "xfa/fwl/cfwl_widget.h"
14 #include "xfa/fwl/ifwl_themeprovider.h"
15 
16 namespace pdfium {
17 
18 CFWL_ComboBoxTP::CFWL_ComboBoxTP() = default;
19 
20 CFWL_ComboBoxTP::~CFWL_ComboBoxTP() = default;
21 
DrawBackground(const CFWL_ThemeBackground & pParams)22 void CFWL_ComboBoxTP::DrawBackground(const CFWL_ThemeBackground& pParams) {
23   switch (pParams.GetPart()) {
24     case CFWL_ThemePart::Part::kBorder: {
25       DrawBorder(pParams.GetGraphics(), pParams.m_PartRect, pParams.m_matrix);
26       break;
27     }
28     case CFWL_ThemePart::Part::kBackground: {
29       CFGAS_GEPath path;
30       const CFX_RectF& rect = pParams.m_PartRect;
31       path.AddRectangle(rect.left, rect.top, rect.width, rect.height);
32       FX_ARGB argb_color;
33       if (pParams.m_dwStates & CFWL_PartState::kSelected)
34         argb_color = FWLTHEME_COLOR_BKSelected;
35       else if (pParams.m_dwStates & CFWL_PartState::kDisabled)
36         argb_color = FWLTHEME_COLOR_EDGERB1;
37       else
38         argb_color = 0xFFFFFFFF;
39 
40       CFGAS_GEGraphics::StateRestorer restorer(pParams.GetGraphics());
41       pParams.GetGraphics()->SetFillColor(CFGAS_GEColor(argb_color));
42       pParams.GetGraphics()->FillPath(
43           path, CFX_FillRenderOptions::FillType::kWinding, pParams.m_matrix);
44       break;
45     }
46     case CFWL_ThemePart::Part::kDropDownButton: {
47       DrawArrowBtn(pParams.GetGraphics(), pParams.m_PartRect,
48                    FWLTHEME_DIRECTION::kDown, pParams.GetThemeState(),
49                    pParams.m_matrix);
50       break;
51     }
52     default:
53       break;
54   }
55 }
56 
57 }  // namespace pdfium
58