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_scroll_bar.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 FPDFSDK_PWL_CPWL_SCROLL_BAR_H_
8#define FPDFSDK_PWL_CPWL_SCROLL_BAR_H_
9
10#include <memory>
11
12#include "core/fxcrt/cfx_timer.h"
13#include "core/fxcrt/unowned_ptr.h"
14#include "fpdfsdk/pwl/cpwl_sbbutton.h"
15#include "fpdfsdk/pwl/cpwl_wnd.h"
16
18 public:
20 : fContentMin(0.0f),
21 fContentMax(0.0f),
22 fPlateWidth(0.0f),
23 fBigStep(0.0f),
24 fSmallStep(0.0f) {}
25
26 bool operator==(const PWL_SCROLL_INFO& that) const {
27 return fContentMin == that.fContentMin && fContentMax == that.fContentMax &&
28 fPlateWidth == that.fPlateWidth && fBigStep == that.fBigStep &&
30 }
31 bool operator!=(const PWL_SCROLL_INFO& that) const {
32 return !(*this == that);
33 }
34
38 float fBigStep;
40};
41
43 public:
44 PWL_FLOATRANGE() = default;
45
46 bool operator==(const PWL_FLOATRANGE& that) const {
47 return fMin == that.fMin && fMax == that.fMax;
48 }
49 bool operator!=(const PWL_FLOATRANGE& that) const { return !(*this == that); }
50
51 void Reset();
52 void Set(float min, float max);
53 bool In(float x) const;
54 float GetWidth() const;
55
56 float fMin = 0.0f;
57 float fMax = 0.0f;
58};
59
61 public:
63
64 bool operator==(const PWL_SCROLL_PRIVATEDATA& that) const {
65 return ScrollRange == that.ScrollRange &&
68 }
69 bool operator!=(const PWL_SCROLL_PRIVATEDATA& that) const {
70 return !(*this == that);
71 }
72
73 void Default();
74 void SetScrollRange(float min, float max);
75 void SetClientWidth(float width);
76 void SetSmallStep(float step);
77 void SetBigStep(float step);
78 bool SetPos(float pos);
79
80 void AddSmall();
81 void SubSmall();
82 void AddBig();
83 void SubBig();
84
88 float fBigStep;
90};
91
92class CPWL_ScrollBar final : public CPWL_Wnd, public CFX_Timer::CallbackIface {
93 public:
94 static constexpr float kWidth = 12.0f;
95 static constexpr uint8_t kTransparency = 150;
96
98 const CreateParams& cp,
99 std::unique_ptr<IPWL_FillerNotify::PerWindowData> pAttachedData);
100 ~CPWL_ScrollBar() override;
101
102 // CPWL_Wnd:
103 void OnDestroy() override;
104 bool RepositionChildWnd() override;
106 const CFX_Matrix& mtUser2Device) override;
107 bool OnLButtonDown(Mask<FWL_EVENTFLAG> nFlag,
108 const CFX_PointF& point) override;
109 bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag, const CFX_PointF& point) override;
110 void SetScrollInfo(const PWL_SCROLL_INFO& info) override;
111 void SetScrollPosition(float pos) override;
112 void NotifyLButtonDown(CPWL_Wnd* child, const CFX_PointF& pos) override;
113 void NotifyLButtonUp(CPWL_Wnd* child, const CFX_PointF& pos) override;
114 void NotifyMouseMove(CPWL_Wnd* child, const CFX_PointF& pos) override;
115 void CreateChildWnd(const CreateParams& cp) override;
116
117 // CFX_Timer::CallbackIface:
118 void OnTimerFired() override;
119
120 float GetScrollBarWidth() const;
121
122 private:
123 void SetScrollRange(float fMin, float fMax, float fClientWidth);
124 void SetScrollPos(float fPos);
125
126 // Returns |true| iff this instance is still allocated.
127 [[nodiscard]] bool MovePosButton(bool bRefresh);
128 void SetScrollStep(float fBigStep, float fSmallStep);
129 void NotifyScrollWindow();
130 CFX_FloatRect GetScrollArea() const;
131
132 void CreateButtons(const CreateParams& cp);
133
134 void OnMinButtonLBDown(const CFX_PointF& point);
135 void OnMinButtonLBUp(const CFX_PointF& point);
136 void OnMinButtonMouseMove(const CFX_PointF& point);
137
138 void OnMaxButtonLBDown(const CFX_PointF& point);
139 void OnMaxButtonLBUp(const CFX_PointF& point);
140 void OnMaxButtonMouseMove(const CFX_PointF& point);
141
142 void OnPosButtonLBDown(const CFX_PointF& point);
143 void OnPosButtonLBUp(const CFX_PointF& point);
144 void OnPosButtonMouseMove(const CFX_PointF& point);
145
146 float TrueToFace(float);
147 float FaceToTrue(float);
148
149 PWL_SCROLL_INFO m_OriginInfo;
150 UnownedPtr<CPWL_SBButton> m_pMinButton;
151 UnownedPtr<CPWL_SBButton> m_pMaxButton;
152 UnownedPtr<CPWL_SBButton> m_pPosButton;
153 std::unique_ptr<CFX_Timer> m_pTimer;
155 bool m_bMouseDown = false;
156 bool m_bMinOrMax = false;
157 float m_nOldPos = 0.0f;
158 float m_fOldPosButton = 0.0f;
159};
160
161#endif // FPDFSDK_PWL_CPWL_SCROLL_BAR_H_
BorderStyle
constexpr CFX_FloatRect(float l, float b, float r, float t)
constexpr CFX_FloatRect()=default
float Width() const
bool IsEmpty() const
void Inflate(float x, float y)
CFX_FloatRect & operator=(const CFX_FloatRect &that)=default
float Height() const
CFX_PointF Transform(const CFX_PointF &point) 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)
const FX_RECT & GetFontBBox() const
Definition cpdf_font.h:113
bool IsStandardFont() const
float fLineAscent
Definition cpvt_line.h:21
float fLineDescent
Definition cpvt_line.h:22
float fAscent
Definition cpvt_word.h:23
float fDescent
Definition cpvt_word.h:24
float fWidth
Definition cpvt_word.h:25
bool GetWord(CPVT_Word &word) const
bool GetLine(CPVT_Line &line) const
bool CanCopy() const
Definition cpwl_edit.cpp:96
static float GetCharArrayAutoFontSize(const CPDF_Font *pFont, const CFX_FloatRect &rcPlate, int32_t nCharArray)
bool IsTextFull() const
void SetScrollInfo(const PWL_SCROLL_INFO &info) override
bool CanRedo() override
void SetFontSize(float fFontSize) override
bool SetCaret(bool bVisible, const CFX_PointF &ptHead, const CFX_PointF &ptFoot)
bool SelectAllText() override
bool OnLButtonUp(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
bool CanUndo() override
bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask< FWL_EVENTFLAG > nFlag) override
CPWL_Edit(const CreateParams &cp, std::unique_ptr< IPWL_FillerNotify::PerWindowData > pAttachedData)
Definition cpwl_edit.cpp:32
void CutText()
bool Undo() override
bool Redo() override
CFX_FloatRect GetFocusRect() const override
bool RepositionChildWnd() override
Definition cpwl_edit.cpp:49
void SetScrollPosition(float pos) override
void SetAlignFormatVerticalCenter()
Definition cpwl_edit.cpp:87
void SetCursor() override
WideString GetText() override
void SetCharSet(FX_Charset nCharSet)
Definition cpwl_edit.h:81
bool CanCut() const
bool OnLButtonDblClk(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
void OnSetFocus() override
void ReplaceAndKeepSelection(const WideString &text) override
void ScrollWindowVertically(float pos) override
void SetCharArray(int32_t nCharArray)
void SetSelection(int32_t nStartChar, int32_t nEndChar)
std::pair< int32_t, int32_t > GetSelection() const
void OnKillFocus() override
void SetScrollPos(const CFX_PointF &point)
void ClearSelection()
void SetText(const WideString &csText)
Definition cpwl_edit.cpp:44
bool OnMouseMove(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
void ReplaceSelection(const WideString &text) override
CFX_FloatRect GetClientRect() const override
Definition cpwl_edit.cpp:78
bool OnMouseWheel(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point, const CFX_Vector &delta) override
void DrawThisAppearance(CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device) override
~CPWL_Edit() override
Definition cpwl_edit.cpp:40
void SetReadyToInput()
bool OnChar(uint16_t nChar, Mask< FWL_EVENTFLAG > nFlag) override
void OnCreated() override
WideString GetSelectedText() override
float GetFontSize() const override
void SetLimitChar(int32_t nLimitChar)
FX_Charset GetCharSet() const
Definition cpwl_edit.h:82
bool OnLButtonDown(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
CFX_PointF GetScrollPos() const
bool OnRButtonUp(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
void CreateChildWnd(const CreateParams &cp) override
void OnDestroy() override
bool CanSelectAll() const
Definition cpwl_edit.cpp:92
static constexpr uint8_t kTransparency
static constexpr float kWidth
bool OnLButtonUp(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
void OnDestroy() override
void NotifyLButtonUp(CPWL_Wnd *child, const CFX_PointF &pos) override
CPWL_ScrollBar(const CreateParams &cp, std::unique_ptr< IPWL_FillerNotify::PerWindowData > pAttachedData)
void SetScrollPosition(float pos) override
float GetScrollBarWidth() const
void CreateChildWnd(const CreateParams &cp) override
bool OnLButtonDown(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point) override
void OnTimerFired() override
void DrawThisAppearance(CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device) override
void NotifyLButtonDown(CPWL_Wnd *child, const CFX_PointF &pos) override
void NotifyMouseMove(CPWL_Wnd *child, const CFX_PointF &pos) override
void SetScrollInfo(const PWL_SCROLL_INFO &info) override
~CPWL_ScrollBar() override
bool RepositionChildWnd() override
CFX_FloatRect rcRectWnd
Definition cpwl_wnd.h:105
BorderStyle nBorderStyle
Definition cpwl_wnd.h:114
virtual void OnSetFocusForEdit(CPWL_Edit *pEdit)=0
CFX_Matrix GetWindowMatrix() const
Definition cpwl_wnd.cpp:739
static bool IsPlatformShortcutKey(Mask< FWL_EVENTFLAG > nFlag)
Definition cpwl_wnd.cpp:143
static bool IsCTRLKeyDown(Mask< FWL_EVENTFLAG > nFlag)
Definition cpwl_wnd.cpp:128
bool ClientHitTest(const CFX_PointF &point) const
Definition cpwl_wnd.cpp:571
void SetCapture()
Definition cpwl_wnd.cpp:518
static bool IsALTKeyDown(Mask< FWL_EVENTFLAG > nFlag)
Definition cpwl_wnd.cpp:133
CFX_Color GetBorderColor() const
Definition cpwl_wnd.cpp:490
BorderStyle GetBorderStyle() const
Definition cpwl_wnd.cpp:478
virtual bool OnChar(uint16_t nChar, Mask< FWL_EVENTFLAG > nFlag)
Definition cpwl_wnd.cpp:309
void RemoveFlag(uint32_t dwFlags)
Definition cpwl_wnd.cpp:466
IPWL_FillerNotify * GetFillerNotify() const
Definition cpwl_wnd.h:245
bool HasFlag(uint32_t dwFlags) const
Definition cpwl_wnd.cpp:462
CFX_FloatRect GetWindowRect() const
Definition cpwl_wnd.cpp:440
void ReleaseCapture()
Definition cpwl_wnd.cpp:524
bool IsFocused() const
Definition cpwl_wnd.cpp:684
IPVT_FontMap * GetFontMap() const
Definition cpwl_wnd.h:274
void SetTransparency(int32_t nTransparency)
Definition cpwl_wnd.cpp:732
virtual bool OnLButtonUp(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point)
virtual bool OnMouseMove(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point)
static bool IsSHIFTKeyDown(Mask< FWL_EVENTFLAG > nFlag)
Definition cpwl_wnd.cpp:123
virtual bool OnRButtonUp(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point)
Definition cpwl_wnd.cpp:357
virtual bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask< FWL_EVENTFLAG > nFlag)
Definition cpwl_wnd.cpp:297
int32_t GetBorderWidth() const
Definition cpwl_wnd.cpp:482
CreateParams * GetCreationParams()
Definition cpwl_wnd.h:238
virtual void SetScrollInfo(const PWL_SCROLL_INFO &info)
Definition cpwl_wnd.cpp:428
virtual bool InvalidateRect(const CFX_FloatRect *pRect)
Definition cpwl_wnd.cpp:278
virtual void SetFocus()
Definition cpwl_wnd.cpp:533
bool IsVisible() const
Definition cpwl_wnd.h:204
virtual bool SetVisible(bool bVisible)
Definition cpwl_wnd.cpp:575
IPWL_FillerNotify::PerWindowData * GetAttachedData() const
Definition cpwl_wnd.h:209
const CPWL_Dash & GetBorderDash() const
Definition cpwl_wnd.cpp:494
int32_t GetInnerBorderWidth() const
Definition cpwl_wnd.cpp:486
virtual void SetScrollPosition(float pos)
Definition cpwl_wnd.cpp:430
virtual void DrawThisAppearance(CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device)
Definition cpwl_wnd.cpp:250
ProviderIface * GetProvider() const
Definition cpwl_wnd.h:239
bool Move(const CFX_FloatRect &rcNew, bool bReset, bool bRefresh)
Definition cpwl_wnd.cpp:211
void SetClipRect(const CFX_FloatRect &rect)
Definition cpwl_wnd.cpp:601
virtual bool OnLButtonDblClk(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point)
CPWL_ScrollBar * GetVScrollBar() const
Definition cpwl_wnd.cpp:498
bool IsValid() const
Definition cpwl_wnd.h:237
virtual bool OnLButtonDown(Mask< FWL_EVENTFLAG > nFlag, const CFX_PointF &point)
bool IsReadOnly() const
Definition cpwl_wnd.cpp:610
virtual RetainPtr< CPDF_Font > GetPDFFont(int32_t nFontIndex)=0
virtual FX_Charset CharSetFromUnicode(uint16_t word, FX_Charset nOldCharset)=0
WideString & operator+=(wchar_t ch)
#define PES_AUTOSCROLL
Definition cpwl_wnd.h:48
#define PES_UNDO
Definition cpwl_wnd.h:50
#define PES_MULTILINE
Definition cpwl_wnd.h:40
#define PES_CHARARRAY
Definition cpwl_wnd.h:47
#define PWS_AUTOTRANSPARENT
Definition cpwl_wnd.h:36
#define PWS_AUTOFONTSIZE
Definition cpwl_wnd.h:35
#define PES_CENTER
Definition cpwl_wnd.h:46
#define PES_TEXTOVERFLOW
Definition cpwl_wnd.h:52
#define PES_MIDDLE
Definition cpwl_wnd.h:44
#define PES_PASSWORD
Definition cpwl_wnd.h:41
#define PWS_NOREFRESHCLIP
Definition cpwl_wnd.h:37
#define PES_RIGHT
Definition cpwl_wnd.h:43
#define PES_AUTORETURN
Definition cpwl_wnd.h:49
@ FWL_VKEY_End
@ FWL_VKEY_Z
@ FWL_VKEY_Right
@ FWL_VKEY_Up
@ FWL_VKEY_Home
@ FWL_VKEY_Down
@ FWL_VKEY_Unknown
@ FWL_VKEY_A
@ FWL_VKEY_Space
@ FWL_VKEY_X
@ FWL_VKEY_Insert
@ FWL_VKEY_C
@ FWL_VKEY_Back
@ FWL_VKEY_V
@ FWL_VKEY_Left
@ FWL_VKEY_Escape
@ FWL_VKEY_Return
@ FWL_VKEY_Delete
FX_Charset
Definition fx_codepage.h:70
constexpr uint8_t kEscape
Definition ascii.h:24
constexpr uint8_t kReturn
Definition ascii.h:20
constexpr uint8_t kControlC
Definition ascii.h:16
constexpr uint8_t kNul
Definition ascii.h:13
constexpr uint8_t kControlZ
Definition ascii.h:23
constexpr uint8_t kBackspace
Definition ascii.h:17
constexpr uint8_t kControlX
Definition ascii.h:22
constexpr uint8_t kNewline
Definition ascii.h:19
constexpr uint8_t kControlV
Definition ascii.h:21
constexpr uint8_t kControlA
Definition ascii.h:14
static constexpr CFX_FillRenderOptions EvenOddOptions()
CPVT_WordRange(const CPVT_WordPlace &begin, const CPVT_WordPlace &end)
CPVT_WordRange()=default
int Height() const
int Width() const
float GetWidth() const
bool In(float x) const
bool operator!=(const PWL_FLOATRANGE &that) const
PWL_FLOATRANGE()=default
void Set(float min, float max)
bool operator==(const PWL_FLOATRANGE &that) const
bool operator!=(const PWL_SCROLL_INFO &that) const
bool operator==(const PWL_SCROLL_INFO &that) const
bool operator!=(const PWL_SCROLL_PRIVATEDATA &that) const
void SetScrollRange(float min, float max)
void SetBigStep(float step)
void SetClientWidth(float width)
PWL_FLOATRANGE ScrollRange
void SetSmallStep(float step)
bool operator==(const PWL_SCROLL_PRIVATEDATA &that) const