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
cpwl_cbbutton.cpp
Go to the documentation of this file.
1// Copyright 2020 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 "fpdfsdk/pwl/cpwl_cbbutton.h"
8
9#include <utility>
10
11#include "core/fxge/cfx_fillrenderoptions.h"
12#include "core/fxge/cfx_path.h"
13#include "core/fxge/cfx_renderdevice.h"
14
15CPWL_CBButton::CPWL_CBButton(
16 const CreateParams& cp,
17 std::unique_ptr<IPWL_FillerNotify::PerWindowData> pAttachedData)
18 : CPWL_Wnd(cp, std::move(pAttachedData)) {}
19
20CPWL_CBButton::~CPWL_CBButton() = default;
21
22void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
23 const CFX_Matrix& mtUser2Device) {
24 CPWL_Wnd::DrawThisAppearance(pDevice, mtUser2Device);
25
26 if (!IsVisible())
27 return;
28
30 if (window.IsEmpty())
31 return;
32
33 constexpr float kComboBoxTriangleLength = 6.0f;
34 constexpr float kComboBoxTriangleHalfLength = kComboBoxTriangleLength / 2;
35 constexpr float kComboBoxTriangleQuarterLength = kComboBoxTriangleLength / 4;
36 if (!FXSYS_IsFloatBigger(window.right - window.left,
37 kComboBoxTriangleLength) ||
38 !FXSYS_IsFloatBigger(window.top - window.bottom,
39 kComboBoxTriangleHalfLength)) {
40 return;
41 }
42
43 CFX_PointF ptCenter = GetCenterPoint();
44 CFX_PointF pt1(ptCenter.x - kComboBoxTriangleHalfLength,
45 ptCenter.y + kComboBoxTriangleQuarterLength);
46 CFX_PointF pt2(ptCenter.x + kComboBoxTriangleHalfLength,
47 ptCenter.y + kComboBoxTriangleQuarterLength);
48 CFX_PointF pt3(ptCenter.x, ptCenter.y - kComboBoxTriangleQuarterLength);
49
50 CFX_Path path;
55
56 pDevice->DrawPath(path, &mtUser2Device, nullptr,
59}
60
61bool CPWL_CBButton::OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag,
62 const CFX_PointF& point) {
64
65 SetCapture();
66 CPWL_Wnd* pParent = GetParentWindow();
67 if (pParent)
68 pParent->NotifyLButtonDown(this, point);
69
70 return true;
71}
72
73bool CPWL_CBButton::OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag,
74 const CFX_PointF& point) {
75 CPWL_Wnd::OnLButtonUp(nFlag, point);
76
78 return true;
79}
bool IsEmpty() const
void AppendPoint(const CFX_PointF &point, Point::Type type)
Definition cfx_path.cpp:289
bool DrawPath(const CFX_Path &path, const CFX_Matrix *pObject2Device, const CFX_GraphStateData *pGraphState, uint32_t fill_color, uint32_t stroke_color, const CFX_FillRenderOptions &fill_options)
void DrawThisAppearance(CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device) override
bool OnLButtonDown(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
CPWL_CBButton(const CreateParams &cp, std::unique_ptr< IPWL_FillerNotify::PerWindowData > pAttachedData)
bool OnLButtonUp(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
~CPWL_CBButton() override
void SetCapture()
Definition cpwl_wnd.cpp:518
CFX_FloatRect GetWindowRect() const
Definition cpwl_wnd.cpp:440
void ReleaseCapture()
Definition cpwl_wnd.cpp:524
CPWL_Wnd * GetParentWindow() const
Definition cpwl_wnd.h:249
virtual void NotifyLButtonDown(CPWL_Wnd *child, const CFX_PointF &pos)
Definition cpwl_wnd.cpp:434
virtual bool OnLButtonUp(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point)
bool IsVisible() const
Definition cpwl_wnd.h:204
int32_t GetTransparency()
Definition cpwl_wnd.cpp:728
virtual void DrawThisAppearance(CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device)
Definition cpwl_wnd.cpp:250
static const CFX_Color kDefaultBlackColor
Definition cpwl_wnd.h:79
virtual bool OnLButtonDown(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point)
#define FXSYS_IsFloatBigger(fa, fb)
Definition fx_system.h:36
FX_COLORREF ToFXColor(int32_t nTransparency) const
static constexpr CFX_FillRenderOptions EvenOddOptions()