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_scrollbar.h
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#ifndef XFA_FWL_CFWL_SCROLLBAR_H_
8#define XFA_FWL_CFWL_SCROLLBAR_H_
9
10#include <stdint.h>
11
12#include <memory>
13
14#include "core/fxcrt/cfx_timer.h"
15#include "third_party/base/check.h"
16#include "xfa/fwl/cfwl_eventscroll.h"
17#include "xfa/fwl/cfwl_themepart.h"
18#include "xfa/fwl/cfwl_widget.h"
19
20#define FWL_STYLEEXT_SCB_Horz (0L << 0)
21#define FWL_STYLEEXT_SCB_Vert (1L << 0)
22
23class CFWL_ScrollBar final : public CFWL_Widget,
24 public CFX_Timer::CallbackIface {
25 public:
27 ~CFWL_ScrollBar() override;
28
29 // CFWL_Widget:
30 FWL_Type GetClassID() const override;
31 void Update() override;
32 void DrawWidget(CFGAS_GEGraphics* pGraphics,
33 const CFX_Matrix& matrix) override;
34 void OnProcessMessage(CFWL_Message* pMessage) override;
35 void OnDrawWidget(CFGAS_GEGraphics* pGraphics,
36 const CFX_Matrix& matrix) override;
37
38 // CFX_Timer::CallbackIface:
39 void OnTimerFired() override;
40
41 void GetRange(float* fMin, float* fMax) const {
42 *fMin = m_fRangeMin;
43 *fMax = m_fRangeMax;
44 }
45 void SetRange(float fMin, float fMax) {
46 m_fRangeMin = fMin;
47 m_fRangeMax = fMax;
48 }
49 float GetPageSize() const { return m_fPageSize; }
50 void SetPageSize(float fPageSize) { m_fPageSize = fPageSize; }
51 float GetStepSize() const { return m_fStepSize; }
52 void SetStepSize(float fStepSize) { m_fStepSize = fStepSize; }
53 float GetPos() const { return m_fPos; }
54 void SetPos(float fPos) { m_fPos = fPos; }
55 void SetTrackPos(float fTrackPos);
56
57 private:
58 CFWL_ScrollBar(CFWL_App* app,
59 const Properties& properties,
60 CFWL_Widget* pOuter);
61
62 bool IsVertical() const { return !!(GetStyleExts() & FWL_STYLEEXT_SCB_Vert); }
63 void DrawUpperTrack(CFGAS_GEGraphics* pGraphics, const CFX_Matrix& mtMatrix);
64 void DrawLowerTrack(CFGAS_GEGraphics* pGraphics, const CFX_Matrix& mtMatrix);
65 void DrawMaxArrowBtn(CFGAS_GEGraphics* pGraphics, const CFX_Matrix& mtMatrix);
66 void DrawMinArrowBtn(CFGAS_GEGraphics* pGraphics, const CFX_Matrix& mtMatrix);
67 void DrawThumb(CFGAS_GEGraphics* pGraphics, const CFX_Matrix& mtMatrix);
68 void Layout();
69 void CalcButtonLen();
70 CFX_RectF CalcMinButtonRect();
71 CFX_RectF CalcMaxButtonRect();
72 CFX_RectF CalcThumbButtonRect(const CFX_RectF& rtThumbRect);
73 CFX_RectF CalcMinTrackRect(const CFX_RectF& rtMinRect);
74 CFX_RectF CalcMaxTrackRect(const CFX_RectF& rtMaxRect);
75 float GetTrackPointPos(const CFX_PointF& point);
76
77 bool SendEvent();
78 bool OnScroll(CFWL_EventScroll::Code dwCode, float fPos);
79 void OnLButtonDown(const CFX_PointF& point);
80 void OnLButtonUp(const CFX_PointF& point);
81 void OnMouseMove(const CFX_PointF& point);
82 void OnMouseLeave();
83 void OnMouseWheel(const CFX_Vector& delta);
84 bool DoScroll(CFWL_EventScroll::Code dwCode, float fPos);
85 void DoMouseDown(int32_t iItem,
86 const CFX_RectF& rtItem,
87 CFWL_PartState* pState,
88 const CFX_PointF& point);
89 void DoMouseUp(int32_t iItem,
90 const CFX_RectF& rtItem,
91 CFWL_PartState* pState,
92 const CFX_PointF& point);
93 void DoMouseMove(int32_t iItem,
94 const CFX_RectF& rtItem,
95 CFWL_PartState* pState,
96 const CFX_PointF& point);
97 void DoMouseLeave(int32_t iItem,
98 const CFX_RectF& rtItem,
99 CFWL_PartState* pState);
100 void DoMouseHover(int32_t iItem,
101 const CFX_RectF& rtItem,
102 CFWL_PartState* pState);
103
104 float m_fRangeMin = 0.0f;
105 float m_fRangeMax = -1.0f;
106 float m_fPageSize = 0.0f;
107 float m_fStepSize = 0.0f;
108 float m_fPos = 0.0f;
109 float m_fTrackPos = 0.0f;
110 CFWL_PartState m_iMinButtonState = CFWL_PartState::kNormal;
111 CFWL_PartState m_iMaxButtonState = CFWL_PartState::kNormal;
112 CFWL_PartState m_iThumbButtonState = CFWL_PartState::kNormal;
113 CFWL_PartState m_iMinTrackState = CFWL_PartState::kNormal;
114 CFWL_PartState m_iMaxTrackState = CFWL_PartState::kNormal;
115 float m_fLastTrackPos = 0.0f;
116 CFX_PointF m_cpTrackPoint;
117 int32_t m_iMouseWheel = 0;
118 float m_fButtonLen = 0.0f;
119 bool m_bMouseDown = false;
120 bool m_bMinSize = false;
121 CFX_RectF m_ClientRect;
122 CFX_RectF m_ThumbRect;
123 CFX_RectF m_MinBtnRect;
124 CFX_RectF m_MaxBtnRect;
125 CFX_RectF m_MinTrackRect;
126 CFX_RectF m_MaxTrackRect;
127 std::unique_ptr<CFX_Timer> m_pTimer;
128};
129
130#endif // XFA_FWL_CFWL_SCROLLBAR_H_
BC_TEXT_LOC
Definition BC_Library.h:12
BC_TYPE
Definition BC_Library.h:25
BC_CHAR_ENCODING
Definition BC_Library.h:20
#define FWL_STYLEEXT_SCB_Vert
CFWL_PartState
FWL_Type
Definition cfwl_widget.h:46
#define FWL_STATE_WGT_Focused
Definition cfwl_widget.h:42
void SetDataLength(int32_t dataLength)
FWL_Type GetClassID() const override
void SetType(BC_TYPE type)
void SetCalChecksum(bool calChecksum)
void SetWideNarrowRatio(int8_t ratio)
~CFWL_Barcode() override
void OnProcessEvent(CFWL_Event *pEvent) override
void Update() override
void DrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
void SetPrintChecksum(bool printChecksum)
void SetTextLocation(BC_TEXT_LOC location)
void SetStartChar(char startChar)
void SetText(const WideString &wsText) override
void SetEndChar(char endChar)
void SetModuleHeight(int32_t height)
void SetErrorCorrectionLevel(int32_t ecLevel)
void SetTextSkipNotify(const WideString &wsText) override
void SetModuleWidth(int32_t width)
bool IsProtectedType() const
void SetCharEncoding(BC_CHAR_ENCODING encoding)
bool CanUndo()
CFX_RectF GetAutosizedWidgetRect() override
Definition cfwl_edit.cpp:89
void OnTextChanged() override
CFX_RectF GetWidgetRect() override
Definition cfwl_edit.cpp:77
virtual void SetText(const WideString &wsText)
void SetLimit(int32_t nLimit)
const CFX_RectF & GetRTClient() const
Definition cfwl_edit.h:105
void OnProcessMessage(CFWL_Message *pMessage) override
bool Redo()
void ClearSelection()
void OnCaretChanged() override
void DrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
size_t GetTextLength() const
CFDE_TextEditEngine * GetTxtEdtEngine()
Definition cfwl_edit.h:106
void Trace(cppgc::Visitor *visitor) const override
Definition cfwl_edit.cpp:67
void SetScrollOffset(float fScrollOffset) override
CFWL_Edit(CFWL_App *app, const Properties &properties, CFWL_Widget *pOuter)
Definition cfwl_edit.cpp:50
void Update() override
~CFWL_Edit() override
int32_t GetLimit() const
FWL_WidgetHit HitTest(const CFX_PointF &point) override
bool OnValidate(const WideString &wsText) override
void SetAliasChar(wchar_t wAlias)
bool Undo()
bool Paste(const WideString &wsPaste)
void OnTextWillChange(CFDE_TextEditEngine::TextChange *change) override
absl::optional< WideString > Cut()
WideString GetText() const
FWL_Type GetClassID() const override
Definition cfwl_edit.cpp:73
void PreFinalize() override
Definition cfwl_edit.cpp:60
bool CanRedo()
void SelectAll()
void ShowCaret(CFX_RectF *pRect)
void OnProcessEvent(CFWL_Event *pEvent) override
absl::optional< WideString > Copy()
void ClearText()
void OnDrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
void SetStates(uint32_t dwStates) override
void HideCaret(CFX_RectF *pRect)
bool HasSelection() const
void OnSelChanged() override
void NotifyTextFull() override
std::pair< size_t, size_t > GetSelection() const
virtual void SetTextSkipNotify(const WideString &wsText)
CFWL_Widget * GetDstTarget() const
Definition cfwl_event.h:41
Type GetType() const
Definition cfwl_event.h:39
CFWL_Event(Type type)
CFWL_Event(Type type, CFWL_Widget *pSrcTarget)
CFWL_Widget * GetSrcTarget() const
Definition cfwl_event.h:40
CFWL_Event(Type type, CFWL_Widget *pSrcTarget, CFWL_Widget *pDstTarget)
virtual ~CFWL_Event()
void OnDrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
float GetPos() const
void SetStepSize(float fStepSize)
float GetStepSize() const
void OnTimerFired() override
void GetRange(float *fMin, float *fMax) const
void OnProcessMessage(CFWL_Message *pMessage) override
void Update() override
FWL_Type GetClassID() const override
~CFWL_ScrollBar() override
void SetPos(float fPos)
void DrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
float GetPageSize() const
void SetPageSize(float fPageSize)
void SetRange(float fMin, float fMax)
void SetTrackPos(float fTrackPos)
uint32_t GetStyleExts() const
Properties m_Properties
IFWL_ThemeProvider * GetThemeProvider() const
bool IsLocked() const
void Concat(const CFX_Matrix &right)
FWL_WidgetHit
#define CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED
Definition heap.h:32