| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef FPDFSDK_PDFWINDOW_PWL_SCROLLBAR_H_ | 7 #ifndef FPDFSDK_PDFWINDOW_PWL_SCROLLBAR_H_ |
| 8 #define FPDFSDK_PDFWINDOW_PWL_SCROLLBAR_H_ | 8 #define FPDFSDK_PDFWINDOW_PWL_SCROLLBAR_H_ |
| 9 | 9 |
| 10 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" | 10 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 CPWL_SBButton(PWL_SCROLLBAR_TYPE eScrollBarType, | 46 CPWL_SBButton(PWL_SCROLLBAR_TYPE eScrollBarType, |
| 47 PWL_SBBUTTON_TYPE eButtonType); | 47 PWL_SBBUTTON_TYPE eButtonType); |
| 48 ~CPWL_SBButton() override; | 48 ~CPWL_SBButton() override; |
| 49 | 49 |
| 50 // CPWL_Wnd | 50 // CPWL_Wnd |
| 51 CFX_ByteString GetClassName() const override; | 51 CFX_ByteString GetClassName() const override; |
| 52 void OnCreate(PWL_CREATEPARAM& cp) override; | 52 void OnCreate(PWL_CREATEPARAM& cp) override; |
| 53 void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) override; | 53 void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) override; |
| 54 void DrawThisAppearance(CFX_RenderDevice* pDevice, | 54 void DrawThisAppearance(CFX_RenderDevice* pDevice, |
| 55 CFX_Matrix* pUser2Device) override; | 55 CFX_Matrix* pUser2Device) override; |
| 56 FX_BOOL OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) override; | 56 bool OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) override; |
| 57 FX_BOOL OnLButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) override; | 57 bool OnLButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) override; |
| 58 FX_BOOL OnMouseMove(const CFX_FloatPoint& point, uint32_t nFlag) override; | 58 bool OnMouseMove(const CFX_FloatPoint& point, uint32_t nFlag) override; |
| 59 | 59 |
| 60 protected: | 60 protected: |
| 61 PWL_SCROLLBAR_TYPE m_eScrollBarType; | 61 PWL_SCROLLBAR_TYPE m_eScrollBarType; |
| 62 PWL_SBBUTTON_TYPE m_eSBButtonType; | 62 PWL_SBBUTTON_TYPE m_eSBButtonType; |
| 63 | 63 |
| 64 FX_BOOL m_bMouseDown; | 64 bool m_bMouseDown; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 struct PWL_FLOATRANGE { | 67 struct PWL_FLOATRANGE { |
| 68 public: | 68 public: |
| 69 PWL_FLOATRANGE(); | 69 PWL_FLOATRANGE(); |
| 70 PWL_FLOATRANGE(FX_FLOAT min, FX_FLOAT max); | 70 PWL_FLOATRANGE(FX_FLOAT min, FX_FLOAT max); |
| 71 | 71 |
| 72 bool operator==(const PWL_FLOATRANGE& that) const { | 72 bool operator==(const PWL_FLOATRANGE& that) const { |
| 73 return fMin == that.fMin && fMax == that.fMax; | 73 return fMin == that.fMin && fMax == that.fMax; |
| 74 } | 74 } |
| 75 bool operator!=(const PWL_FLOATRANGE& that) const { return !(*this == that); } | 75 bool operator!=(const PWL_FLOATRANGE& that) const { return !(*this == that); } |
| 76 | 76 |
| 77 void Default(); | 77 void Default(); |
| 78 void Set(FX_FLOAT min, FX_FLOAT max); | 78 void Set(FX_FLOAT min, FX_FLOAT max); |
| 79 FX_BOOL In(FX_FLOAT x) const; | 79 bool In(FX_FLOAT x) const; |
| 80 FX_FLOAT GetWidth() const; | 80 FX_FLOAT GetWidth() const; |
| 81 | 81 |
| 82 FX_FLOAT fMin; | 82 FX_FLOAT fMin; |
| 83 FX_FLOAT fMax; | 83 FX_FLOAT fMax; |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 struct PWL_SCROLL_PRIVATEDATA { | 86 struct PWL_SCROLL_PRIVATEDATA { |
| 87 public: | 87 public: |
| 88 PWL_SCROLL_PRIVATEDATA(); | 88 PWL_SCROLL_PRIVATEDATA(); |
| 89 | 89 |
| 90 bool operator==(const PWL_SCROLL_PRIVATEDATA& that) const { | 90 bool operator==(const PWL_SCROLL_PRIVATEDATA& that) const { |
| 91 return ScrollRange == that.ScrollRange && | 91 return ScrollRange == that.ScrollRange && |
| 92 fClientWidth == that.fClientWidth && fScrollPos == that.fScrollPos && | 92 fClientWidth == that.fClientWidth && fScrollPos == that.fScrollPos && |
| 93 fBigStep == that.fBigStep && fSmallStep == that.fSmallStep; | 93 fBigStep == that.fBigStep && fSmallStep == that.fSmallStep; |
| 94 } | 94 } |
| 95 bool operator!=(const PWL_SCROLL_PRIVATEDATA& that) const { | 95 bool operator!=(const PWL_SCROLL_PRIVATEDATA& that) const { |
| 96 return !(*this == that); | 96 return !(*this == that); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void Default(); | 99 void Default(); |
| 100 void SetScrollRange(FX_FLOAT min, FX_FLOAT max); | 100 void SetScrollRange(FX_FLOAT min, FX_FLOAT max); |
| 101 void SetClientWidth(FX_FLOAT width); | 101 void SetClientWidth(FX_FLOAT width); |
| 102 void SetSmallStep(FX_FLOAT step); | 102 void SetSmallStep(FX_FLOAT step); |
| 103 void SetBigStep(FX_FLOAT step); | 103 void SetBigStep(FX_FLOAT step); |
| 104 FX_BOOL SetPos(FX_FLOAT pos); | 104 bool SetPos(FX_FLOAT pos); |
| 105 | 105 |
| 106 void AddSmall(); | 106 void AddSmall(); |
| 107 void SubSmall(); | 107 void SubSmall(); |
| 108 void AddBig(); | 108 void AddBig(); |
| 109 void SubBig(); | 109 void SubBig(); |
| 110 | 110 |
| 111 PWL_FLOATRANGE ScrollRange; | 111 PWL_FLOATRANGE ScrollRange; |
| 112 FX_FLOAT fClientWidth; | 112 FX_FLOAT fClientWidth; |
| 113 FX_FLOAT fScrollPos; | 113 FX_FLOAT fScrollPos; |
| 114 FX_FLOAT fBigStep; | 114 FX_FLOAT fBigStep; |
| 115 FX_FLOAT fSmallStep; | 115 FX_FLOAT fSmallStep; |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 class CPWL_ScrollBar : public CPWL_Wnd { | 118 class CPWL_ScrollBar : public CPWL_Wnd { |
| 119 public: | 119 public: |
| 120 CPWL_ScrollBar(PWL_SCROLLBAR_TYPE sbType = SBT_HSCROLL); | 120 CPWL_ScrollBar(PWL_SCROLLBAR_TYPE sbType = SBT_HSCROLL); |
| 121 ~CPWL_ScrollBar() override; | 121 ~CPWL_ScrollBar() override; |
| 122 | 122 |
| 123 // CPWL_Wnd | 123 // CPWL_Wnd |
| 124 CFX_ByteString GetClassName() const override; | 124 CFX_ByteString GetClassName() const override; |
| 125 void OnCreate(PWL_CREATEPARAM& cp) override; | 125 void OnCreate(PWL_CREATEPARAM& cp) override; |
| 126 void RePosChildWnd() override; | 126 void RePosChildWnd() override; |
| 127 void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) override; | 127 void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) override; |
| 128 void DrawThisAppearance(CFX_RenderDevice* pDevice, | 128 void DrawThisAppearance(CFX_RenderDevice* pDevice, |
| 129 CFX_Matrix* pUser2Device) override; | 129 CFX_Matrix* pUser2Device) override; |
| 130 FX_BOOL OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) override; | 130 bool OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) override; |
| 131 FX_BOOL OnLButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) override; | 131 bool OnLButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) override; |
| 132 void OnNotify(CPWL_Wnd* pWnd, | 132 void OnNotify(CPWL_Wnd* pWnd, |
| 133 uint32_t msg, | 133 uint32_t msg, |
| 134 intptr_t wParam = 0, | 134 intptr_t wParam = 0, |
| 135 intptr_t lParam = 0) override; | 135 intptr_t lParam = 0) override; |
| 136 void CreateChildWnd(const PWL_CREATEPARAM& cp) override; | 136 void CreateChildWnd(const PWL_CREATEPARAM& cp) override; |
| 137 void TimerProc() override; | 137 void TimerProc() override; |
| 138 | 138 |
| 139 FX_FLOAT GetScrollBarWidth() const; | 139 FX_FLOAT GetScrollBarWidth() const; |
| 140 PWL_SCROLLBAR_TYPE GetScrollBarType() const { return m_sbType; } | 140 PWL_SCROLLBAR_TYPE GetScrollBarType() const { return m_sbType; } |
| 141 | 141 |
| 142 void SetNotifyForever(FX_BOOL bForever) { m_bNotifyForever = bForever; } | 142 void SetNotifyForever(bool bForever) { m_bNotifyForever = bForever; } |
| 143 | 143 |
| 144 protected: | 144 protected: |
| 145 void SetScrollRange(FX_FLOAT fMin, FX_FLOAT fMax, FX_FLOAT fClientWidth); | 145 void SetScrollRange(FX_FLOAT fMin, FX_FLOAT fMax, FX_FLOAT fClientWidth); |
| 146 void SetScrollPos(FX_FLOAT fPos); | 146 void SetScrollPos(FX_FLOAT fPos); |
| 147 void MovePosButton(FX_BOOL bRefresh); | 147 void MovePosButton(bool bRefresh); |
| 148 void SetScrollStep(FX_FLOAT fBigStep, FX_FLOAT fSmallStep); | 148 void SetScrollStep(FX_FLOAT fBigStep, FX_FLOAT fSmallStep); |
| 149 void NotifyScrollWindow(); | 149 void NotifyScrollWindow(); |
| 150 CFX_FloatRect GetScrollArea() const; | 150 CFX_FloatRect GetScrollArea() const; |
| 151 | 151 |
| 152 private: | 152 private: |
| 153 void CreateButtons(const PWL_CREATEPARAM& cp); | 153 void CreateButtons(const PWL_CREATEPARAM& cp); |
| 154 | 154 |
| 155 void OnMinButtonLBDown(const CFX_FloatPoint& point); | 155 void OnMinButtonLBDown(const CFX_FloatPoint& point); |
| 156 void OnMinButtonLBUp(const CFX_FloatPoint& point); | 156 void OnMinButtonLBUp(const CFX_FloatPoint& point); |
| 157 void OnMinButtonMouseMove(const CFX_FloatPoint& point); | 157 void OnMinButtonMouseMove(const CFX_FloatPoint& point); |
| 158 | 158 |
| 159 void OnMaxButtonLBDown(const CFX_FloatPoint& point); | 159 void OnMaxButtonLBDown(const CFX_FloatPoint& point); |
| 160 void OnMaxButtonLBUp(const CFX_FloatPoint& point); | 160 void OnMaxButtonLBUp(const CFX_FloatPoint& point); |
| 161 void OnMaxButtonMouseMove(const CFX_FloatPoint& point); | 161 void OnMaxButtonMouseMove(const CFX_FloatPoint& point); |
| 162 | 162 |
| 163 void OnPosButtonLBDown(const CFX_FloatPoint& point); | 163 void OnPosButtonLBDown(const CFX_FloatPoint& point); |
| 164 void OnPosButtonLBUp(const CFX_FloatPoint& point); | 164 void OnPosButtonLBUp(const CFX_FloatPoint& point); |
| 165 void OnPosButtonMouseMove(const CFX_FloatPoint& point); | 165 void OnPosButtonMouseMove(const CFX_FloatPoint& point); |
| 166 | 166 |
| 167 FX_FLOAT TrueToFace(FX_FLOAT); | 167 FX_FLOAT TrueToFace(FX_FLOAT); |
| 168 FX_FLOAT FaceToTrue(FX_FLOAT); | 168 FX_FLOAT FaceToTrue(FX_FLOAT); |
| 169 | 169 |
| 170 PWL_SCROLLBAR_TYPE m_sbType; | 170 PWL_SCROLLBAR_TYPE m_sbType; |
| 171 PWL_SCROLL_INFO m_OriginInfo; | 171 PWL_SCROLL_INFO m_OriginInfo; |
| 172 CPWL_SBButton* m_pMinButton; | 172 CPWL_SBButton* m_pMinButton; |
| 173 CPWL_SBButton* m_pMaxButton; | 173 CPWL_SBButton* m_pMaxButton; |
| 174 CPWL_SBButton* m_pPosButton; | 174 CPWL_SBButton* m_pPosButton; |
| 175 PWL_SCROLL_PRIVATEDATA m_sData; | 175 PWL_SCROLL_PRIVATEDATA m_sData; |
| 176 FX_BOOL m_bMouseDown; | 176 bool m_bMouseDown; |
| 177 FX_BOOL m_bMinOrMax; | 177 bool m_bMinOrMax; |
| 178 FX_BOOL m_bNotifyForever; | 178 bool m_bNotifyForever; |
| 179 FX_FLOAT m_nOldPos; | 179 FX_FLOAT m_nOldPos; |
| 180 FX_FLOAT m_fOldPosButton; | 180 FX_FLOAT m_fOldPosButton; |
| 181 }; | 181 }; |
| 182 | 182 |
| 183 #endif // FPDFSDK_PDFWINDOW_PWL_SCROLLBAR_H_ | 183 #endif // FPDFSDK_PDFWINDOW_PWL_SCROLLBAR_H_ |
| OLD | NEW |