1e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// Copyright 2014 PDFium Authors. All rights reserved. 2e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// Use of this source code is governed by a BSD-style license that can be 3e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// found in the LICENSE file. 4ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 5e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 7d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann#ifndef FPDFSDK_PWL_CPWL_SCROLL_BAR_H_ 8d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann#define FPDFSDK_PWL_CPWL_SCROLL_BAR_H_ 9e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 10d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann#include "core/fxcrt/unowned_ptr.h" 11d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann#include "fpdfsdk/pwl/cpwl_wnd.h" 12e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 13e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganovclass CPWL_SBButton; 14e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganovclass CPWL_ScrollBar; 15e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 16ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmannstruct PWL_SCROLL_INFO { 17ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann public: 18ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann PWL_SCROLL_INFO() 19ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann : fContentMin(0.0f), 20ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann fContentMax(0.0f), 21ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann fPlateWidth(0.0f), 22ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann fBigStep(0.0f), 23ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann fSmallStep(0.0f) {} 244d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann 254d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann bool operator==(const PWL_SCROLL_INFO& that) const { 264d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann return fContentMin == that.fContentMin && fContentMax == that.fContentMax && 274d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann fPlateWidth == that.fPlateWidth && fBigStep == that.fBigStep && 284d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann fSmallStep == that.fSmallStep; 294d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann } 304d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann bool operator!=(const PWL_SCROLL_INFO& that) const { 314d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann return !(*this == that); 324d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann } 334d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann 34d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann float fContentMin; 35d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann float fContentMax; 36d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann float fPlateWidth; 37d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann float fBigStep; 38d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann float fSmallStep; 39e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov}; 40e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 41ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmannenum PWL_SCROLLBAR_TYPE { SBT_HSCROLL, SBT_VSCROLL }; 42e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 43ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmannenum PWL_SBBUTTON_TYPE { PSBT_MIN, PSBT_MAX, PSBT_POS }; 44ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 45ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmannclass CPWL_SBButton : public CPWL_Wnd { 46ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann public: 47ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CPWL_SBButton(PWL_SCROLLBAR_TYPE eScrollBarType, 48ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann PWL_SBBUTTON_TYPE eButtonType); 49ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann ~CPWL_SBButton() override; 50e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 51ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann // CPWL_Wnd 52d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann ByteString GetClassName() const override; 53d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void OnCreate(CreateParams* pParamsToAdjust) override; 54ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann void DrawThisAppearance(CFX_RenderDevice* pDevice, 55d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann const CFX_Matrix& mtUser2Device) override; 5633357cad1fd1321a2b38d2963e2585f27ce980a2Philip P. Moltmann bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) override; 5733357cad1fd1321a2b38d2963e2585f27ce980a2Philip P. Moltmann bool OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) override; 5833357cad1fd1321a2b38d2963e2585f27ce980a2Philip P. Moltmann bool OnMouseMove(const CFX_PointF& point, uint32_t nFlag) override; 59ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 60ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann protected: 61ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann PWL_SCROLLBAR_TYPE m_eScrollBarType; 62ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann PWL_SBBUTTON_TYPE m_eSBButtonType; 63ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 644d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann bool m_bMouseDown; 65e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov}; 66e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 67ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmannstruct PWL_FLOATRANGE { 68ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann public: 69ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann PWL_FLOATRANGE(); 70d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann PWL_FLOATRANGE(float min, float max); 714d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann 724d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann bool operator==(const PWL_FLOATRANGE& that) const { 734d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann return fMin == that.fMin && fMax == that.fMax; 744d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann } 754d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann bool operator!=(const PWL_FLOATRANGE& that) const { return !(*this == that); } 764d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann 77ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann void Default(); 78d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void Set(float min, float max); 79d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann bool In(float x) const; 80d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann float GetWidth() const; 81ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 82d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann float fMin; 83d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann float fMax; 84e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov}; 85e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 86ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmannstruct PWL_SCROLL_PRIVATEDATA { 87ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann public: 88ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann PWL_SCROLL_PRIVATEDATA(); 89ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 904d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann bool operator==(const PWL_SCROLL_PRIVATEDATA& that) const { 914d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann return ScrollRange == that.ScrollRange && 924d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann fClientWidth == that.fClientWidth && fScrollPos == that.fScrollPos && 934d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann fBigStep == that.fBigStep && fSmallStep == that.fSmallStep; 944d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann } 954d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann bool operator!=(const PWL_SCROLL_PRIVATEDATA& that) const { 964d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann return !(*this == that); 974d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann } 984d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann 99ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann void Default(); 100d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void SetScrollRange(float min, float max); 101d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void SetClientWidth(float width); 102d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void SetSmallStep(float step); 103d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void SetBigStep(float step); 104d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann bool SetPos(float pos); 105ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 106ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann void AddSmall(); 107ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann void SubSmall(); 108ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann void AddBig(); 109ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann void SubBig(); 110ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 111ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann PWL_FLOATRANGE ScrollRange; 112d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann float fClientWidth; 113d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann float fScrollPos; 114d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann float fBigStep; 115d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann float fSmallStep; 116e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov}; 117e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 118ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmannclass CPWL_ScrollBar : public CPWL_Wnd { 119ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann public: 1204d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann explicit CPWL_ScrollBar(PWL_SCROLLBAR_TYPE sbType = SBT_HSCROLL); 121ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann ~CPWL_ScrollBar() override; 122ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 123d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann // CPWL_Wnd: 124d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann ByteString GetClassName() const override; 125d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void OnCreate(CreateParams* pParamsToAdjust) override; 126d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void OnDestroy() override; 127d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann bool RePosChildWnd() override; 128ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann void DrawThisAppearance(CFX_RenderDevice* pDevice, 129d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann const CFX_Matrix& mtUser2Device) override; 13033357cad1fd1321a2b38d2963e2585f27ce980a2Philip P. Moltmann bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) override; 13133357cad1fd1321a2b38d2963e2585f27ce980a2Philip P. Moltmann bool OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) override; 132d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void SetScrollInfo(const PWL_SCROLL_INFO& info) override; 133d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void SetScrollPosition(float pos) override; 134d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void NotifyLButtonDown(CPWL_Wnd* child, const CFX_PointF& pos) override; 135d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void NotifyLButtonUp(CPWL_Wnd* child, const CFX_PointF& pos) override; 136d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void NotifyMouseMove(CPWL_Wnd* child, const CFX_PointF& pos) override; 137d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void CreateChildWnd(const CreateParams& cp) override; 138ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann void TimerProc() override; 139ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 140d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann float GetScrollBarWidth() const; 141ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann PWL_SCROLLBAR_TYPE GetScrollBarType() const { return m_sbType; } 142ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 1434d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann void SetNotifyForever(bool bForever) { m_bNotifyForever = bForever; } 144ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 145ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann protected: 146d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void SetScrollRange(float fMin, float fMax, float fClientWidth); 147d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void SetScrollPos(float fPos); 148d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann 149d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann // Returns |true| iff this instance is still allocated. 150d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann bool MovePosButton(bool bRefresh); 151d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void SetScrollStep(float fBigStep, float fSmallStep); 152ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann void NotifyScrollWindow(); 1534d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann CFX_FloatRect GetScrollArea() const; 154ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 155ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann private: 156d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann void CreateButtons(const CreateParams& cp); 157ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 15833357cad1fd1321a2b38d2963e2585f27ce980a2Philip P. Moltmann void OnMinButtonLBDown(const CFX_PointF& point); 15933357cad1fd1321a2b38d2963e2585f27ce980a2Philip P. Moltmann void OnMinButtonLBUp(const CFX_PointF& point); 16033357cad1fd1321a2b38d2963e2585f27ce980a2Philip P. Moltmann void OnMinButtonMouseMove(const CFX_PointF& point); 161ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 16233357cad1fd1321a2b38d2963e2585f27ce980a2Philip P. Moltmann void OnMaxButtonLBDown(const CFX_PointF& point); 16333357cad1fd1321a2b38d2963e2585f27ce980a2Philip P. Moltmann void OnMaxButtonLBUp(const CFX_PointF& point); 16433357cad1fd1321a2b38d2963e2585f27ce980a2Philip P. Moltmann void OnMaxButtonMouseMove(const CFX_PointF& point); 165ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 16633357cad1fd1321a2b38d2963e2585f27ce980a2Philip P. Moltmann void OnPosButtonLBDown(const CFX_PointF& point); 16733357cad1fd1321a2b38d2963e2585f27ce980a2Philip P. Moltmann void OnPosButtonLBUp(const CFX_PointF& point); 16833357cad1fd1321a2b38d2963e2585f27ce980a2Philip P. Moltmann void OnPosButtonMouseMove(const CFX_PointF& point); 169ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 170d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann float TrueToFace(float); 171d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann float FaceToTrue(float); 172ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 173ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann PWL_SCROLLBAR_TYPE m_sbType; 174ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann PWL_SCROLL_INFO m_OriginInfo; 175d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann UnownedPtr<CPWL_SBButton> m_pMinButton; 176d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann UnownedPtr<CPWL_SBButton> m_pMaxButton; 177d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann UnownedPtr<CPWL_SBButton> m_pPosButton; 178ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann PWL_SCROLL_PRIVATEDATA m_sData; 1794d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann bool m_bMouseDown; 1804d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann bool m_bMinOrMax; 1814d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann bool m_bNotifyForever; 182d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann float m_nOldPos; 183d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann float m_fOldPosButton; 184e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov}; 185e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 186d904c1ec7e8d1d86ed56f0dd252435d12cd345aePhilip P. Moltmann#endif // FPDFSDK_PWL_CPWL_SCROLL_BAR_H_ 187