1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#ifndef FPDFSDK_PDFWINDOW_PWL_SCROLLBAR_H_
#define FPDFSDK_PDFWINDOW_PWL_SCROLLBAR_H_
#include "fpdfsdk/pdfwindow/PWL_Wnd.h"
class CPWL_SBButton;
class CPWL_ScrollBar;
struct PWL_SCROLL_INFO {
public:
PWL_SCROLL_INFO()
: fContentMin(0.0f),
fContentMax(0.0f),
fPlateWidth(0.0f),
fBigStep(0.0f),
fSmallStep(0.0f) {}
FX_FLOAT fContentMin;
FX_FLOAT fContentMax;
FX_FLOAT fPlateWidth;
FX_FLOAT fBigStep;
FX_FLOAT fSmallStep;
};
enum PWL_SCROLLBAR_TYPE { SBT_HSCROLL, SBT_VSCROLL };
enum PWL_SBBUTTON_TYPE { PSBT_MIN, PSBT_MAX, PSBT_POS };
class CPWL_SBButton : public CPWL_Wnd {
public:
CPWL_SBButton(PWL_SCROLLBAR_TYPE eScrollBarType,
PWL_SBBUTTON_TYPE eButtonType);
~CPWL_SBButton() override;
// CPWL_Wnd
CFX_ByteString GetClassName() const override;
void OnCreate(PWL_CREATEPARAM& cp) override;
void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) override;
void DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device) override;
FX_BOOL OnLButtonDown(const CFX_FloatPoint& point, FX_DWORD nFlag) override;
FX_BOOL OnLButtonUp(const CFX_FloatPoint& point, FX_DWORD nFlag) override;
FX_BOOL OnMouseMove(const CFX_FloatPoint& point, FX_DWORD nFlag) override;
protected:
PWL_SCROLLBAR_TYPE m_eScrollBarType;
PWL_SBBUTTON_TYPE m_eSBButtonType;
FX_BOOL m_bMouseDown;
};
struct PWL_FLOATRANGE {
public:
PWL_FLOATRANGE();
PWL_FLOATRANGE(FX_FLOAT min, FX_FLOAT max);
void Default();
void Set(FX_FLOAT min, FX_FLOAT max);
FX_BOOL In(FX_FLOAT x) const;
FX_FLOAT GetWidth() const;
FX_FLOAT fMin, fMax;
};
struct PWL_SCROLL_PRIVATEDATA {
public:
PWL_SCROLL_PRIVATEDATA();
void Default();
void SetScrollRange(FX_FLOAT min, FX_FLOAT max);
void SetClientWidth(FX_FLOAT width);
void SetSmallStep(FX_FLOAT step);
void SetBigStep(FX_FLOAT step);
FX_BOOL SetPos(FX_FLOAT pos);
void AddSmall();
void SubSmall();
void AddBig();
void SubBig();
PWL_FLOATRANGE ScrollRange;
FX_FLOAT fClientWidth;
FX_FLOAT fScrollPos;
FX_FLOAT fBigStep;
FX_FLOAT fSmallStep;
};
class CPWL_ScrollBar : public CPWL_Wnd {
public:
CPWL_ScrollBar(PWL_SCROLLBAR_TYPE sbType = SBT_HSCROLL);
~CPWL_ScrollBar() override;
// CPWL_Wnd
CFX_ByteString GetClassName() const override;
void OnCreate(PWL_CREATEPARAM& cp) override;
void RePosChildWnd() override;
void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) override;
void DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device) override;
FX_BOOL OnLButtonDown(const CFX_FloatPoint& point, FX_DWORD nFlag) override;
FX_BOOL OnLButtonUp(const CFX_FloatPoint& point, FX_DWORD nFlag) override;
void OnNotify(CPWL_Wnd* pWnd,
FX_DWORD msg,
intptr_t wParam = 0,
intptr_t lParam = 0) override;
void CreateChildWnd(const PWL_CREATEPARAM& cp) override;
void TimerProc() override;
FX_FLOAT GetScrollBarWidth() const;
PWL_SCROLLBAR_TYPE GetScrollBarType() const { return m_sbType; }
void SetNotifyForever(FX_BOOL bForever) { m_bNotifyForever = bForever; }
protected:
void SetScrollRange(FX_FLOAT fMin, FX_FLOAT fMax, FX_FLOAT fClientWidth);
void SetScrollPos(FX_FLOAT fPos);
void MovePosButton(FX_BOOL bRefresh);
void SetScrollStep(FX_FLOAT fBigStep, FX_FLOAT fSmallStep);
void NotifyScrollWindow();
CFX_FloatRect GetScrollArea() const;
private:
void CreateButtons(const PWL_CREATEPARAM& cp);
void OnMinButtonLBDown(const CFX_FloatPoint& point);
void OnMinButtonLBUp(const CFX_FloatPoint& point);
void OnMinButtonMouseMove(const CFX_FloatPoint& point);
void OnMaxButtonLBDown(const CFX_FloatPoint& point);
void OnMaxButtonLBUp(const CFX_FloatPoint& point);
void OnMaxButtonMouseMove(const CFX_FloatPoint& point);
void OnPosButtonLBDown(const CFX_FloatPoint& point);
void OnPosButtonLBUp(const CFX_FloatPoint& point);
void OnPosButtonMouseMove(const CFX_FloatPoint& point);
FX_FLOAT TrueToFace(FX_FLOAT);
FX_FLOAT FaceToTrue(FX_FLOAT);
PWL_SCROLLBAR_TYPE m_sbType;
PWL_SCROLL_INFO m_OriginInfo;
CPWL_SBButton* m_pMinButton;
CPWL_SBButton* m_pMaxButton;
CPWL_SBButton* m_pPosButton;
PWL_SCROLL_PRIVATEDATA m_sData;
FX_BOOL m_bMouseDown;
FX_BOOL m_bMinOrMax;
FX_BOOL m_bNotifyForever;
FX_FLOAT m_nOldPos;
FX_FLOAT m_fOldPosButton;
};
#endif // FPDFSDK_PDFWINDOW_PWL_SCROLLBAR_H_
|