John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
dan sinclair | 89e904b | 2016-03-23 19:29:15 -0400 | [diff] [blame] | 7 | #include "fpdfsdk/pdfwindow/PWL_ScrollBar.h" |
Dan Sinclair | aa403d3 | 2016-03-15 14:57:22 -0400 | [diff] [blame] | 8 | |
| 9 | #include "core/include/fxge/fx_ge.h" |
dan sinclair | 89e904b | 2016-03-23 19:29:15 -0400 | [diff] [blame] | 10 | #include "fpdfsdk/pdfwindow/PWL_Utils.h" |
| 11 | #include "fpdfsdk/pdfwindow/PWL_Wnd.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 12 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 13 | #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) |
| 14 | #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) |
| 15 | #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) |
| 16 | #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 17 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 18 | PWL_FLOATRANGE::PWL_FLOATRANGE() { |
| 19 | Default(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 20 | } |
| 21 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 22 | PWL_FLOATRANGE::PWL_FLOATRANGE(FX_FLOAT min, FX_FLOAT max) { |
| 23 | Set(min, max); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 24 | } |
| 25 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 26 | void PWL_FLOATRANGE::Default() { |
| 27 | fMin = 0; |
| 28 | fMax = 0; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 29 | } |
| 30 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 31 | void PWL_FLOATRANGE::Set(FX_FLOAT min, FX_FLOAT max) { |
| 32 | if (min > max) { |
| 33 | fMin = max; |
| 34 | fMax = min; |
| 35 | } else { |
| 36 | fMin = min; |
| 37 | fMax = max; |
| 38 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 39 | } |
| 40 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 41 | FX_BOOL PWL_FLOATRANGE::In(FX_FLOAT x) const { |
| 42 | return (IsFloatBigger(x, fMin) || IsFloatEqual(x, fMin)) && |
| 43 | (IsFloatSmaller(x, fMax) || IsFloatEqual(x, fMax)); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 44 | } |
| 45 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 46 | FX_FLOAT PWL_FLOATRANGE::GetWidth() const { |
| 47 | return fMax - fMin; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 48 | } |
| 49 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 50 | PWL_SCROLL_PRIVATEDATA::PWL_SCROLL_PRIVATEDATA() { |
| 51 | Default(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 52 | } |
| 53 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 54 | void PWL_SCROLL_PRIVATEDATA::Default() { |
| 55 | ScrollRange.Default(); |
| 56 | fScrollPos = ScrollRange.fMin; |
| 57 | fClientWidth = 0; |
| 58 | fBigStep = 10; |
| 59 | fSmallStep = 1; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 62 | void PWL_SCROLL_PRIVATEDATA::SetScrollRange(FX_FLOAT min, FX_FLOAT max) { |
| 63 | ScrollRange.Set(min, max); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 64 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 65 | if (IsFloatSmaller(fScrollPos, ScrollRange.fMin)) |
| 66 | fScrollPos = ScrollRange.fMin; |
| 67 | if (IsFloatBigger(fScrollPos, ScrollRange.fMax)) |
| 68 | fScrollPos = ScrollRange.fMax; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 69 | } |
| 70 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 71 | void PWL_SCROLL_PRIVATEDATA::SetClientWidth(FX_FLOAT width) { |
| 72 | fClientWidth = width; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 73 | } |
| 74 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 75 | void PWL_SCROLL_PRIVATEDATA::SetSmallStep(FX_FLOAT step) { |
| 76 | fSmallStep = step; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 77 | } |
| 78 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 79 | void PWL_SCROLL_PRIVATEDATA::SetBigStep(FX_FLOAT step) { |
| 80 | fBigStep = step; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 83 | FX_BOOL PWL_SCROLL_PRIVATEDATA::SetPos(FX_FLOAT pos) { |
| 84 | if (ScrollRange.In(pos)) { |
| 85 | fScrollPos = pos; |
| 86 | return TRUE; |
| 87 | } |
| 88 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 89 | } |
| 90 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 91 | void PWL_SCROLL_PRIVATEDATA::AddSmall() { |
| 92 | if (!SetPos(fScrollPos + fSmallStep)) |
| 93 | SetPos(ScrollRange.fMax); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 94 | } |
| 95 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 96 | void PWL_SCROLL_PRIVATEDATA::SubSmall() { |
| 97 | if (!SetPos(fScrollPos - fSmallStep)) |
| 98 | SetPos(ScrollRange.fMin); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 99 | } |
| 100 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 101 | void PWL_SCROLL_PRIVATEDATA::AddBig() { |
| 102 | if (!SetPos(fScrollPos + fBigStep)) |
| 103 | SetPos(ScrollRange.fMax); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 104 | } |
| 105 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 106 | void PWL_SCROLL_PRIVATEDATA::SubBig() { |
| 107 | if (!SetPos(fScrollPos - fBigStep)) |
| 108 | SetPos(ScrollRange.fMin); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 109 | } |
| 110 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 111 | CPWL_SBButton::CPWL_SBButton(PWL_SCROLLBAR_TYPE eScrollBarType, |
| 112 | PWL_SBBUTTON_TYPE eButtonType) { |
| 113 | m_eScrollBarType = eScrollBarType; |
| 114 | m_eSBButtonType = eButtonType; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 115 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 116 | m_bMouseDown = FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 117 | } |
| 118 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 119 | CPWL_SBButton::~CPWL_SBButton() {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 120 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 121 | CFX_ByteString CPWL_SBButton::GetClassName() const { |
| 122 | return "CPWL_SBButton"; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 123 | } |
| 124 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 125 | void CPWL_SBButton::OnCreate(PWL_CREATEPARAM& cp) { |
| 126 | cp.eCursorType = FXCT_ARROW; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 127 | } |
| 128 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 129 | void CPWL_SBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
| 130 | CPWL_Wnd::GetThisAppearanceStream(sAppStream); |
| 131 | |
| 132 | if (!IsVisible()) |
| 133 | return; |
| 134 | |
| 135 | CFX_ByteTextBuf sButton; |
| 136 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 137 | CFX_FloatRect rectWnd = GetWindowRect(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 138 | |
| 139 | if (rectWnd.IsEmpty()) |
| 140 | return; |
| 141 | |
| 142 | sAppStream << "q\n"; |
| 143 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 144 | CFX_FloatPoint ptCenter = GetCenterPoint(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 145 | |
| 146 | switch (m_eScrollBarType) { |
| 147 | case SBT_HSCROLL: |
| 148 | switch (m_eSBButtonType) { |
| 149 | case PSBT_MIN: { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 150 | CFX_FloatPoint pt1(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f, |
| 151 | ptCenter.y); |
| 152 | CFX_FloatPoint pt2(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f, |
| 153 | ptCenter.y + PWL_TRIANGLE_HALFLEN); |
| 154 | CFX_FloatPoint pt3(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f, |
| 155 | ptCenter.y - PWL_TRIANGLE_HALFLEN); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 156 | |
| 157 | if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 && |
| 158 | rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) { |
| 159 | sButton << "0 g\n"; |
| 160 | sButton << pt1.x << " " << pt1.y << " m\n"; |
| 161 | sButton << pt2.x << " " << pt2.y << " l\n"; |
| 162 | sButton << pt3.x << " " << pt3.y << " l\n"; |
| 163 | sButton << pt1.x << " " << pt1.y << " l f\n"; |
| 164 | |
| 165 | sAppStream << sButton; |
| 166 | } |
| 167 | } break; |
| 168 | case PSBT_MAX: { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 169 | CFX_FloatPoint pt1(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f, |
| 170 | ptCenter.y); |
| 171 | CFX_FloatPoint pt2(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f, |
| 172 | ptCenter.y + PWL_TRIANGLE_HALFLEN); |
| 173 | CFX_FloatPoint pt3(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f, |
| 174 | ptCenter.y - PWL_TRIANGLE_HALFLEN); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 175 | |
| 176 | if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 && |
| 177 | rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) { |
| 178 | sButton << "0 g\n"; |
| 179 | sButton << pt1.x << " " << pt1.y << " m\n"; |
| 180 | sButton << pt2.x << " " << pt2.y << " l\n"; |
| 181 | sButton << pt3.x << " " << pt3.y << " l\n"; |
| 182 | sButton << pt1.x << " " << pt1.y << " l f\n"; |
| 183 | |
| 184 | sAppStream << sButton; |
| 185 | } |
| 186 | } break; |
| 187 | default: |
| 188 | break; |
| 189 | } |
| 190 | break; |
| 191 | case SBT_VSCROLL: |
| 192 | switch (m_eSBButtonType) { |
| 193 | case PSBT_MIN: { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 194 | CFX_FloatPoint pt1(ptCenter.x - PWL_TRIANGLE_HALFLEN, |
| 195 | ptCenter.y - PWL_TRIANGLE_HALFLEN * 0.5f); |
| 196 | CFX_FloatPoint pt2(ptCenter.x + PWL_TRIANGLE_HALFLEN, |
| 197 | ptCenter.y - PWL_TRIANGLE_HALFLEN * 0.5f); |
| 198 | CFX_FloatPoint pt3(ptCenter.x, |
| 199 | ptCenter.y + PWL_TRIANGLE_HALFLEN * 0.5f); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 200 | |
| 201 | if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 && |
| 202 | rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) { |
| 203 | sButton << "0 g\n"; |
| 204 | sButton << pt1.x << " " << pt1.y << " m\n"; |
| 205 | sButton << pt2.x << " " << pt2.y << " l\n"; |
| 206 | sButton << pt3.x << " " << pt3.y << " l\n"; |
| 207 | sButton << pt1.x << " " << pt1.y << " l f\n"; |
| 208 | |
| 209 | sAppStream << sButton; |
| 210 | } |
| 211 | } break; |
| 212 | case PSBT_MAX: { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 213 | CFX_FloatPoint pt1(ptCenter.x - PWL_TRIANGLE_HALFLEN, |
| 214 | ptCenter.y + PWL_TRIANGLE_HALFLEN * 0.5f); |
| 215 | CFX_FloatPoint pt2(ptCenter.x + PWL_TRIANGLE_HALFLEN, |
| 216 | ptCenter.y + PWL_TRIANGLE_HALFLEN * 0.5f); |
| 217 | CFX_FloatPoint pt3(ptCenter.x, |
| 218 | ptCenter.y - PWL_TRIANGLE_HALFLEN * 0.5f); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 219 | |
| 220 | if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 && |
| 221 | rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) { |
| 222 | sButton << "0 g\n"; |
| 223 | sButton << pt1.x << " " << pt1.y << " m\n"; |
| 224 | sButton << pt2.x << " " << pt2.y << " l\n"; |
| 225 | sButton << pt3.x << " " << pt3.y << " l\n"; |
| 226 | sButton << pt1.x << " " << pt1.y << " l f\n"; |
| 227 | |
| 228 | sAppStream << sButton; |
| 229 | } |
| 230 | } break; |
| 231 | default: |
| 232 | break; |
| 233 | } |
| 234 | break; |
| 235 | default: |
| 236 | break; |
| 237 | } |
| 238 | |
| 239 | sAppStream << "Q\n"; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 240 | } |
| 241 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 242 | void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 243 | CFX_Matrix* pUser2Device) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 244 | if (!IsVisible()) |
| 245 | return; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 246 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 247 | CFX_FloatRect rectWnd = GetWindowRect(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 248 | if (rectWnd.IsEmpty()) |
| 249 | return; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 250 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 251 | CFX_FloatPoint ptCenter = GetCenterPoint(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 252 | int32_t nTransparancy = GetTransparency(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 253 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 254 | switch (m_eScrollBarType) { |
| 255 | case SBT_HSCROLL: |
| 256 | CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); |
| 257 | switch (m_eSBButtonType) { |
| 258 | case PSBT_MIN: { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 259 | CFX_FloatPoint pt1(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f, |
| 260 | ptCenter.y); |
| 261 | CFX_FloatPoint pt2(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f, |
| 262 | ptCenter.y + PWL_TRIANGLE_HALFLEN); |
| 263 | CFX_FloatPoint pt3(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f, |
| 264 | ptCenter.y - PWL_TRIANGLE_HALFLEN); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 265 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 266 | if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 && |
| 267 | rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) { |
| 268 | CFX_PathData path; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 269 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 270 | path.SetPointCount(4); |
| 271 | path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO); |
| 272 | path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO); |
| 273 | path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO); |
| 274 | path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 275 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 276 | pDevice->DrawPath(&path, pUser2Device, NULL, |
| 277 | CPWL_Utils::PWLColorToFXColor( |
| 278 | PWL_DEFAULT_BLACKCOLOR, nTransparancy), |
| 279 | 0, FXFILL_ALTERNATE); |
| 280 | } |
| 281 | } break; |
| 282 | case PSBT_MAX: { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 283 | CFX_FloatPoint pt1(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f, |
| 284 | ptCenter.y); |
| 285 | CFX_FloatPoint pt2(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f, |
| 286 | ptCenter.y + PWL_TRIANGLE_HALFLEN); |
| 287 | CFX_FloatPoint pt3(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f, |
| 288 | ptCenter.y - PWL_TRIANGLE_HALFLEN); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 289 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 290 | if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 && |
| 291 | rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) { |
| 292 | CFX_PathData path; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 293 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 294 | path.SetPointCount(4); |
| 295 | path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO); |
| 296 | path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO); |
| 297 | path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO); |
| 298 | path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 299 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 300 | pDevice->DrawPath(&path, pUser2Device, NULL, |
| 301 | CPWL_Utils::PWLColorToFXColor( |
| 302 | PWL_DEFAULT_BLACKCOLOR, nTransparancy), |
| 303 | 0, FXFILL_ALTERNATE); |
| 304 | } |
| 305 | } break; |
| 306 | default: |
| 307 | break; |
| 308 | } |
| 309 | break; |
| 310 | case SBT_VSCROLL: |
| 311 | switch (m_eSBButtonType) { |
| 312 | case PSBT_MIN: { |
| 313 | // draw border |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 314 | CFX_FloatRect rcDraw = rectWnd; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 315 | CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw, |
| 316 | ArgbEncode(nTransparancy, 100, 100, 100), |
| 317 | 0.0f); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 318 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 319 | // draw inner border |
| 320 | rcDraw = CPWL_Utils::DeflateRect(rectWnd, 0.5f); |
| 321 | CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw, |
| 322 | ArgbEncode(nTransparancy, 255, 255, 255), |
| 323 | 1.0f); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 324 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 325 | // draw background |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 326 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 327 | rcDraw = CPWL_Utils::DeflateRect(rectWnd, 1.0f); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 328 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 329 | if (IsEnabled()) |
| 330 | CPWL_Utils::DrawShadow(pDevice, pUser2Device, TRUE, FALSE, rcDraw, |
| 331 | nTransparancy, 80, 220); |
| 332 | else |
| 333 | CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcDraw, |
| 334 | ArgbEncode(255, 255, 255, 255)); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 335 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 336 | // draw arrow |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 337 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 338 | if (rectWnd.top - rectWnd.bottom > 6.0f) { |
| 339 | FX_FLOAT fX = rectWnd.left + 1.5f; |
| 340 | FX_FLOAT fY = rectWnd.bottom; |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 341 | CFX_FloatPoint pts[7] = {CFX_FloatPoint(fX + 2.5f, fY + 4.0f), |
| 342 | CFX_FloatPoint(fX + 2.5f, fY + 3.0f), |
| 343 | CFX_FloatPoint(fX + 4.5f, fY + 5.0f), |
| 344 | CFX_FloatPoint(fX + 6.5f, fY + 3.0f), |
| 345 | CFX_FloatPoint(fX + 6.5f, fY + 4.0f), |
| 346 | CFX_FloatPoint(fX + 4.5f, fY + 6.0f), |
| 347 | CFX_FloatPoint(fX + 2.5f, fY + 4.0f)}; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 348 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 349 | if (IsEnabled()) |
| 350 | CPWL_Utils::DrawFillArea( |
| 351 | pDevice, pUser2Device, pts, 7, |
| 352 | ArgbEncode(nTransparancy, 255, 255, 255)); |
| 353 | else |
| 354 | CPWL_Utils::DrawFillArea(pDevice, pUser2Device, pts, 7, |
| 355 | CPWL_Utils::PWLColorToFXColor( |
| 356 | PWL_DEFAULT_HEAVYGRAYCOLOR, 255)); |
| 357 | } |
| 358 | } break; |
| 359 | case PSBT_MAX: { |
| 360 | // draw border |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 361 | CFX_FloatRect rcDraw = rectWnd; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 362 | CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw, |
| 363 | ArgbEncode(nTransparancy, 100, 100, 100), |
| 364 | 0.0f); |
| 365 | |
| 366 | // draw inner border |
| 367 | rcDraw = CPWL_Utils::DeflateRect(rectWnd, 0.5f); |
| 368 | CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw, |
| 369 | ArgbEncode(nTransparancy, 255, 255, 255), |
| 370 | 1.0f); |
| 371 | |
| 372 | // draw background |
| 373 | rcDraw = CPWL_Utils::DeflateRect(rectWnd, 1.0f); |
| 374 | if (IsEnabled()) |
| 375 | CPWL_Utils::DrawShadow(pDevice, pUser2Device, TRUE, FALSE, rcDraw, |
| 376 | nTransparancy, 80, 220); |
| 377 | else |
| 378 | CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcDraw, |
| 379 | ArgbEncode(255, 255, 255, 255)); |
| 380 | |
| 381 | // draw arrow |
| 382 | |
| 383 | if (rectWnd.top - rectWnd.bottom > 6.0f) { |
| 384 | FX_FLOAT fX = rectWnd.left + 1.5f; |
| 385 | FX_FLOAT fY = rectWnd.bottom; |
| 386 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 387 | CFX_FloatPoint pts[7] = {CFX_FloatPoint(fX + 2.5f, fY + 5.0f), |
| 388 | CFX_FloatPoint(fX + 2.5f, fY + 6.0f), |
| 389 | CFX_FloatPoint(fX + 4.5f, fY + 4.0f), |
| 390 | CFX_FloatPoint(fX + 6.5f, fY + 6.0f), |
| 391 | CFX_FloatPoint(fX + 6.5f, fY + 5.0f), |
| 392 | CFX_FloatPoint(fX + 4.5f, fY + 3.0f), |
| 393 | CFX_FloatPoint(fX + 2.5f, fY + 5.0f)}; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 394 | |
| 395 | if (IsEnabled()) |
| 396 | CPWL_Utils::DrawFillArea( |
| 397 | pDevice, pUser2Device, pts, 7, |
| 398 | ArgbEncode(nTransparancy, 255, 255, 255)); |
| 399 | else |
| 400 | CPWL_Utils::DrawFillArea(pDevice, pUser2Device, pts, 7, |
| 401 | CPWL_Utils::PWLColorToFXColor( |
| 402 | PWL_DEFAULT_HEAVYGRAYCOLOR, 255)); |
| 403 | } |
| 404 | } break; |
| 405 | case PSBT_POS: { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 406 | // draw border |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 407 | CFX_FloatRect rcDraw = rectWnd; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 408 | CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw, |
| 409 | ArgbEncode(nTransparancy, 100, 100, 100), |
| 410 | 0.0f); |
| 411 | |
| 412 | // draw inner border |
| 413 | rcDraw = CPWL_Utils::DeflateRect(rectWnd, 0.5f); |
| 414 | CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw, |
| 415 | ArgbEncode(nTransparancy, 255, 255, 255), |
| 416 | 1.0f); |
| 417 | |
| 418 | if (IsEnabled()) { |
| 419 | // draw shadow effect |
| 420 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 421 | CFX_FloatPoint ptTop = |
| 422 | CFX_FloatPoint(rectWnd.left, rectWnd.top - 1.0f); |
| 423 | CFX_FloatPoint ptBottom = |
| 424 | CFX_FloatPoint(rectWnd.left, rectWnd.bottom + 1.0f); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 425 | |
| 426 | ptTop.x += 1.5f; |
| 427 | ptBottom.x += 1.5f; |
| 428 | |
| 429 | CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom, |
| 430 | ArgbEncode(nTransparancy, 210, 210, 210), |
| 431 | 1.0f); |
| 432 | |
| 433 | ptTop.x += 1.0f; |
| 434 | ptBottom.x += 1.0f; |
| 435 | |
| 436 | CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom, |
| 437 | ArgbEncode(nTransparancy, 220, 220, 220), |
| 438 | 1.0f); |
| 439 | |
| 440 | ptTop.x += 1.0f; |
| 441 | ptBottom.x += 1.0f; |
| 442 | |
| 443 | CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom, |
| 444 | ArgbEncode(nTransparancy, 240, 240, 240), |
| 445 | 1.0f); |
| 446 | |
| 447 | ptTop.x += 1.0f; |
| 448 | ptBottom.x += 1.0f; |
| 449 | |
| 450 | CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom, |
| 451 | ArgbEncode(nTransparancy, 240, 240, 240), |
| 452 | 1.0f); |
| 453 | |
| 454 | ptTop.x += 1.0f; |
| 455 | ptBottom.x += 1.0f; |
| 456 | |
| 457 | CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom, |
| 458 | ArgbEncode(nTransparancy, 210, 210, 210), |
| 459 | 1.0f); |
| 460 | |
| 461 | ptTop.x += 1.0f; |
| 462 | ptBottom.x += 1.0f; |
| 463 | |
| 464 | CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom, |
| 465 | ArgbEncode(nTransparancy, 180, 180, 180), |
| 466 | 1.0f); |
| 467 | |
| 468 | ptTop.x += 1.0f; |
| 469 | ptBottom.x += 1.0f; |
| 470 | |
| 471 | CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom, |
| 472 | ArgbEncode(nTransparancy, 150, 150, 150), |
| 473 | 1.0f); |
| 474 | |
| 475 | ptTop.x += 1.0f; |
| 476 | ptBottom.x += 1.0f; |
| 477 | |
| 478 | CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom, |
| 479 | ArgbEncode(nTransparancy, 150, 150, 150), |
| 480 | 1.0f); |
| 481 | |
| 482 | ptTop.x += 1.0f; |
| 483 | ptBottom.x += 1.0f; |
| 484 | |
| 485 | CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom, |
| 486 | ArgbEncode(nTransparancy, 180, 180, 180), |
| 487 | 1.0f); |
| 488 | |
| 489 | ptTop.x += 1.0f; |
| 490 | ptBottom.x += 1.0f; |
| 491 | |
| 492 | CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom, |
| 493 | ArgbEncode(nTransparancy, 210, 210, 210), |
| 494 | 1.0f); |
| 495 | } else { |
| 496 | CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcDraw, |
| 497 | ArgbEncode(255, 255, 255, 255)); |
| 498 | } |
| 499 | |
| 500 | // draw friction |
| 501 | |
| 502 | if (rectWnd.Height() > 8.0f) { |
| 503 | FX_COLORREF crStroke = ArgbEncode(nTransparancy, 120, 120, 120); |
| 504 | if (!IsEnabled()) |
| 505 | crStroke = CPWL_Utils::PWLColorToFXColor( |
| 506 | PWL_DEFAULT_HEAVYGRAYCOLOR, 255); |
| 507 | |
| 508 | FX_FLOAT nFrictionWidth = 5.0f; |
| 509 | FX_FLOAT nFrictionHeight = 5.5f; |
| 510 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 511 | CFX_FloatPoint ptLeft = |
| 512 | CFX_FloatPoint(ptCenter.x - nFrictionWidth / 2.0f, |
| 513 | ptCenter.y - nFrictionHeight / 2.0f + 0.5f); |
| 514 | CFX_FloatPoint ptRight = |
| 515 | CFX_FloatPoint(ptCenter.x + nFrictionWidth / 2.0f, |
| 516 | ptCenter.y - nFrictionHeight / 2.0f + 0.5f); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 517 | |
| 518 | CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight, |
| 519 | crStroke, 1.0f); |
| 520 | |
| 521 | ptLeft.y += 2.0f; |
| 522 | ptRight.y += 2.0f; |
| 523 | |
| 524 | CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight, |
| 525 | crStroke, 1.0f); |
| 526 | |
| 527 | ptLeft.y += 2.0f; |
| 528 | ptRight.y += 2.0f; |
| 529 | |
| 530 | CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight, |
| 531 | crStroke, 1.0f); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 532 | } |
| 533 | } break; |
| 534 | default: |
| 535 | break; |
| 536 | } |
| 537 | break; |
| 538 | default: |
| 539 | break; |
| 540 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 541 | } |
| 542 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 543 | FX_BOOL CPWL_SBButton::OnLButtonDown(const CFX_FloatPoint& point, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 544 | uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 545 | CPWL_Wnd::OnLButtonDown(point, nFlag); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 546 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 547 | if (CPWL_Wnd* pParent = GetParentWindow()) |
| 548 | pParent->OnNotify(this, PNM_LBUTTONDOWN, 0, (intptr_t)&point); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 549 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 550 | m_bMouseDown = TRUE; |
| 551 | SetCapture(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 552 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 553 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 554 | } |
| 555 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 556 | FX_BOOL CPWL_SBButton::OnLButtonUp(const CFX_FloatPoint& point, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 557 | uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 558 | CPWL_Wnd::OnLButtonUp(point, nFlag); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 559 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 560 | if (CPWL_Wnd* pParent = GetParentWindow()) |
| 561 | pParent->OnNotify(this, PNM_LBUTTONUP, 0, (intptr_t)&point); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 562 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 563 | m_bMouseDown = FALSE; |
| 564 | ReleaseCapture(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 565 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 566 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 567 | } |
| 568 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 569 | FX_BOOL CPWL_SBButton::OnMouseMove(const CFX_FloatPoint& point, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 570 | uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 571 | CPWL_Wnd::OnMouseMove(point, nFlag); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 572 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 573 | if (CPWL_Wnd* pParent = GetParentWindow()) { |
| 574 | pParent->OnNotify(this, PNM_MOUSEMOVE, 0, (intptr_t)&point); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 575 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 576 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 577 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 578 | } |
| 579 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 580 | CPWL_ScrollBar::CPWL_ScrollBar(PWL_SCROLLBAR_TYPE sbType) |
| 581 | : m_sbType(sbType), |
| 582 | m_pMinButton(NULL), |
| 583 | m_pMaxButton(NULL), |
| 584 | m_pPosButton(NULL), |
| 585 | m_bMouseDown(FALSE), |
| 586 | m_bMinOrMax(FALSE), |
| 587 | m_bNotifyForever(TRUE) {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 588 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 589 | CPWL_ScrollBar::~CPWL_ScrollBar() {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 590 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 591 | CFX_ByteString CPWL_ScrollBar::GetClassName() const { |
| 592 | return "CPWL_ScrollBar"; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 593 | } |
| 594 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 595 | void CPWL_ScrollBar::OnCreate(PWL_CREATEPARAM& cp) { |
| 596 | cp.eCursorType = FXCT_ARROW; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 597 | } |
| 598 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 599 | void CPWL_ScrollBar::RePosChildWnd() { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 600 | CFX_FloatRect rcClient = GetClientRect(); |
| 601 | CFX_FloatRect rcMinButton, rcMaxButton; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 602 | FX_FLOAT fBWidth = 0; |
| 603 | |
| 604 | switch (m_sbType) { |
| 605 | case SBT_HSCROLL: |
| 606 | if (rcClient.right - rcClient.left > |
| 607 | PWL_SCROLLBAR_BUTTON_WIDTH * 2 + PWL_SCROLLBAR_POSBUTTON_MINWIDTH + |
| 608 | 2) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 609 | rcMinButton = CFX_FloatRect(rcClient.left, rcClient.bottom, |
| 610 | rcClient.left + PWL_SCROLLBAR_BUTTON_WIDTH, |
| 611 | rcClient.top); |
| 612 | rcMaxButton = |
| 613 | CFX_FloatRect(rcClient.right - PWL_SCROLLBAR_BUTTON_WIDTH, |
| 614 | rcClient.bottom, rcClient.right, rcClient.top); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 615 | } else { |
| 616 | fBWidth = (rcClient.right - rcClient.left - |
| 617 | PWL_SCROLLBAR_POSBUTTON_MINWIDTH - 2) / |
| 618 | 2; |
| 619 | |
| 620 | if (fBWidth > 0) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 621 | rcMinButton = CFX_FloatRect(rcClient.left, rcClient.bottom, |
| 622 | rcClient.left + fBWidth, rcClient.top); |
| 623 | rcMaxButton = CFX_FloatRect(rcClient.right - fBWidth, rcClient.bottom, |
| 624 | rcClient.right, rcClient.top); |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 625 | } else { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 626 | SetVisible(FALSE); |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 627 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 628 | } |
| 629 | break; |
| 630 | case SBT_VSCROLL: |
| 631 | if (IsFloatBigger(rcClient.top - rcClient.bottom, |
| 632 | PWL_SCROLLBAR_BUTTON_WIDTH * 2 + |
| 633 | PWL_SCROLLBAR_POSBUTTON_MINWIDTH + 2)) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 634 | rcMinButton = CFX_FloatRect(rcClient.left, |
| 635 | rcClient.top - PWL_SCROLLBAR_BUTTON_WIDTH, |
| 636 | rcClient.right, rcClient.top); |
| 637 | rcMaxButton = |
| 638 | CFX_FloatRect(rcClient.left, rcClient.bottom, rcClient.right, |
| 639 | rcClient.bottom + PWL_SCROLLBAR_BUTTON_WIDTH); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 640 | } else { |
| 641 | fBWidth = (rcClient.top - rcClient.bottom - |
| 642 | PWL_SCROLLBAR_POSBUTTON_MINWIDTH - 2) / |
| 643 | 2; |
| 644 | |
| 645 | if (IsFloatBigger(fBWidth, 0)) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 646 | rcMinButton = CFX_FloatRect(rcClient.left, rcClient.top - fBWidth, |
| 647 | rcClient.right, rcClient.top); |
| 648 | rcMaxButton = |
| 649 | CFX_FloatRect(rcClient.left, rcClient.bottom, rcClient.right, |
| 650 | rcClient.bottom + fBWidth); |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 651 | } else { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 652 | SetVisible(FALSE); |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 653 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 654 | } |
| 655 | break; |
| 656 | } |
| 657 | |
| 658 | if (m_pMinButton) |
| 659 | m_pMinButton->Move(rcMinButton, TRUE, FALSE); |
| 660 | if (m_pMaxButton) |
| 661 | m_pMaxButton->Move(rcMaxButton, TRUE, FALSE); |
| 662 | MovePosButton(FALSE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 663 | } |
| 664 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 665 | void CPWL_ScrollBar::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 666 | CFX_FloatRect rectWnd = GetWindowRect(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 667 | |
| 668 | if (IsVisible() && !rectWnd.IsEmpty()) { |
| 669 | CFX_ByteTextBuf sButton; |
| 670 | |
| 671 | sButton << "q\n"; |
| 672 | sButton << "0 w\n" |
| 673 | << CPWL_Utils::GetColorAppStream(GetBackgroundColor(), TRUE); |
| 674 | sButton << rectWnd.left << " " << rectWnd.bottom << " " |
| 675 | << rectWnd.right - rectWnd.left << " " |
| 676 | << rectWnd.top - rectWnd.bottom << " re b Q\n"; |
| 677 | |
| 678 | sAppStream << sButton; |
| 679 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 680 | } |
| 681 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 682 | void CPWL_ScrollBar::DrawThisAppearance(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 683 | CFX_Matrix* pUser2Device) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 684 | CFX_FloatRect rectWnd = GetWindowRect(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 685 | |
| 686 | if (IsVisible() && !rectWnd.IsEmpty()) { |
| 687 | CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rectWnd, |
| 688 | GetBackgroundColor(), GetTransparency()); |
| 689 | |
| 690 | CPWL_Utils::DrawStrokeLine( |
| 691 | pDevice, pUser2Device, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 692 | CFX_FloatPoint(rectWnd.left + 2.0f, rectWnd.top - 2.0f), |
| 693 | CFX_FloatPoint(rectWnd.left + 2.0f, rectWnd.bottom + 2.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 694 | ArgbEncode(GetTransparency(), 100, 100, 100), 1.0f); |
| 695 | |
| 696 | CPWL_Utils::DrawStrokeLine( |
| 697 | pDevice, pUser2Device, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 698 | CFX_FloatPoint(rectWnd.right - 2.0f, rectWnd.top - 2.0f), |
| 699 | CFX_FloatPoint(rectWnd.right - 2.0f, rectWnd.bottom + 2.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 700 | ArgbEncode(GetTransparency(), 100, 100, 100), 1.0f); |
| 701 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 702 | } |
| 703 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 704 | FX_BOOL CPWL_ScrollBar::OnLButtonDown(const CFX_FloatPoint& point, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 705 | uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 706 | CPWL_Wnd::OnLButtonDown(point, nFlag); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 707 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 708 | if (HasFlag(PWS_AUTOTRANSPARENT)) { |
| 709 | if (GetTransparency() != 255) { |
| 710 | SetTransparency(255); |
| 711 | InvalidateRect(); |
| 712 | } |
| 713 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 714 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 715 | CFX_FloatRect rcMinArea, rcMaxArea; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 716 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 717 | if (m_pPosButton && m_pPosButton->IsVisible()) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 718 | CFX_FloatRect rcClient = GetClientRect(); |
| 719 | CFX_FloatRect rcPosButton = m_pPosButton->GetWindowRect(); |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 720 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 721 | switch (m_sbType) { |
| 722 | case SBT_HSCROLL: |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 723 | rcMinArea = |
| 724 | CFX_FloatRect(rcClient.left + PWL_SCROLLBAR_BUTTON_WIDTH, |
| 725 | rcClient.bottom, rcPosButton.left, rcClient.top); |
| 726 | rcMaxArea = CFX_FloatRect(rcPosButton.right, rcClient.bottom, |
| 727 | rcClient.right - PWL_SCROLLBAR_BUTTON_WIDTH, |
| 728 | rcClient.top); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 729 | |
| 730 | break; |
| 731 | case SBT_VSCROLL: |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 732 | rcMinArea = |
| 733 | CFX_FloatRect(rcClient.left, rcPosButton.top, rcClient.right, |
| 734 | rcClient.top - PWL_SCROLLBAR_BUTTON_WIDTH); |
| 735 | rcMaxArea = CFX_FloatRect(rcClient.left, |
| 736 | rcClient.bottom + PWL_SCROLLBAR_BUTTON_WIDTH, |
| 737 | rcClient.right, rcPosButton.bottom); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 738 | break; |
| 739 | } |
| 740 | |
| 741 | rcMinArea.Normalize(); |
| 742 | rcMaxArea.Normalize(); |
| 743 | |
| 744 | if (rcMinArea.Contains(point.x, point.y)) { |
| 745 | m_sData.SubBig(); |
| 746 | MovePosButton(TRUE); |
| 747 | NotifyScrollWindow(); |
| 748 | } |
| 749 | |
| 750 | if (rcMaxArea.Contains(point.x, point.y)) { |
| 751 | m_sData.AddBig(); |
| 752 | MovePosButton(TRUE); |
| 753 | NotifyScrollWindow(); |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 758 | } |
| 759 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 760 | FX_BOOL CPWL_ScrollBar::OnLButtonUp(const CFX_FloatPoint& point, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 761 | uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 762 | CPWL_Wnd::OnLButtonUp(point, nFlag); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 763 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 764 | if (HasFlag(PWS_AUTOTRANSPARENT)) { |
| 765 | if (GetTransparency() != PWL_SCROLLBAR_TRANSPARANCY) { |
| 766 | SetTransparency(PWL_SCROLLBAR_TRANSPARANCY); |
| 767 | InvalidateRect(); |
| 768 | } |
| 769 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 770 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 771 | EndTimer(); |
| 772 | m_bMouseDown = FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 773 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 774 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 775 | } |
| 776 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 777 | void CPWL_ScrollBar::OnNotify(CPWL_Wnd* pWnd, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 778 | uint32_t msg, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 779 | intptr_t wParam, |
| 780 | intptr_t lParam) { |
| 781 | CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 782 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 783 | switch (msg) { |
| 784 | case PNM_LBUTTONDOWN: |
| 785 | if (pWnd == m_pMinButton) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 786 | OnMinButtonLBDown(*(CFX_FloatPoint*)lParam); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 787 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 788 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 789 | if (pWnd == m_pMaxButton) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 790 | OnMaxButtonLBDown(*(CFX_FloatPoint*)lParam); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 791 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 792 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 793 | if (pWnd == m_pPosButton) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 794 | OnPosButtonLBDown(*(CFX_FloatPoint*)lParam); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 795 | } |
| 796 | break; |
| 797 | case PNM_LBUTTONUP: |
| 798 | if (pWnd == m_pMinButton) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 799 | OnMinButtonLBUp(*(CFX_FloatPoint*)lParam); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 800 | } |
| 801 | |
| 802 | if (pWnd == m_pMaxButton) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 803 | OnMaxButtonLBUp(*(CFX_FloatPoint*)lParam); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | if (pWnd == m_pPosButton) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 807 | OnPosButtonLBUp(*(CFX_FloatPoint*)lParam); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 808 | } |
| 809 | break; |
| 810 | case PNM_MOUSEMOVE: |
| 811 | if (pWnd == m_pMinButton) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 812 | OnMinButtonMouseMove(*(CFX_FloatPoint*)lParam); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 813 | } |
| 814 | |
| 815 | if (pWnd == m_pMaxButton) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 816 | OnMaxButtonMouseMove(*(CFX_FloatPoint*)lParam); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 817 | } |
| 818 | |
| 819 | if (pWnd == m_pPosButton) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 820 | OnPosButtonMouseMove(*(CFX_FloatPoint*)lParam); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 821 | } |
| 822 | break; |
| 823 | case PNM_SETSCROLLINFO: { |
| 824 | if (PWL_SCROLL_INFO* pInfo = (PWL_SCROLL_INFO*)lParam) { |
| 825 | if (FXSYS_memcmp(&m_OriginInfo, pInfo, sizeof(PWL_SCROLL_INFO)) != 0) { |
| 826 | m_OriginInfo = *pInfo; |
| 827 | FX_FLOAT fMax = |
| 828 | pInfo->fContentMax - pInfo->fContentMin - pInfo->fPlateWidth; |
| 829 | fMax = fMax > 0.0f ? fMax : 0.0f; |
| 830 | SetScrollRange(0, fMax, pInfo->fPlateWidth); |
| 831 | SetScrollStep(pInfo->fBigStep, pInfo->fSmallStep); |
| 832 | } |
| 833 | } |
| 834 | } break; |
| 835 | case PNM_SETSCROLLPOS: { |
| 836 | FX_FLOAT fPos = *(FX_FLOAT*)lParam; |
| 837 | switch (m_sbType) { |
| 838 | case SBT_HSCROLL: |
| 839 | fPos = fPos - m_OriginInfo.fContentMin; |
| 840 | break; |
| 841 | case SBT_VSCROLL: |
| 842 | fPos = m_OriginInfo.fContentMax - fPos; |
| 843 | break; |
| 844 | } |
| 845 | SetScrollPos(fPos); |
| 846 | } break; |
| 847 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 848 | } |
| 849 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 850 | void CPWL_ScrollBar::CreateButtons(const PWL_CREATEPARAM& cp) { |
| 851 | PWL_CREATEPARAM scp = cp; |
| 852 | scp.pParentWnd = this; |
| 853 | scp.dwBorderWidth = 2; |
| 854 | scp.nBorderStyle = PBS_BEVELED; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 855 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 856 | scp.dwFlags = |
| 857 | PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PWS_NOREFRESHCLIP; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 858 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 859 | if (!m_pMinButton) { |
| 860 | m_pMinButton = new CPWL_SBButton(m_sbType, PSBT_MIN); |
| 861 | m_pMinButton->Create(scp); |
| 862 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 863 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 864 | if (!m_pMaxButton) { |
| 865 | m_pMaxButton = new CPWL_SBButton(m_sbType, PSBT_MAX); |
| 866 | m_pMaxButton->Create(scp); |
| 867 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 868 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 869 | if (!m_pPosButton) { |
| 870 | m_pPosButton = new CPWL_SBButton(m_sbType, PSBT_POS); |
| 871 | m_pPosButton->SetVisible(FALSE); |
| 872 | m_pPosButton->Create(scp); |
| 873 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 874 | } |
| 875 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 876 | FX_FLOAT CPWL_ScrollBar::GetScrollBarWidth() const { |
| 877 | if (!IsVisible()) |
| 878 | return 0; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 879 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 880 | return PWL_SCROLLBAR_WIDTH; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 881 | } |
| 882 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 883 | void CPWL_ScrollBar::SetScrollRange(FX_FLOAT fMin, |
| 884 | FX_FLOAT fMax, |
| 885 | FX_FLOAT fClientWidth) { |
| 886 | if (m_pPosButton) { |
| 887 | m_sData.SetScrollRange(fMin, fMax); |
| 888 | m_sData.SetClientWidth(fClientWidth); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 889 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 890 | if (IsFloatSmaller(m_sData.ScrollRange.GetWidth(), 0.0f)) { |
| 891 | m_pPosButton->SetVisible(FALSE); |
| 892 | } else { |
| 893 | m_pPosButton->SetVisible(TRUE); |
| 894 | MovePosButton(TRUE); |
| 895 | } |
| 896 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 897 | } |
| 898 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 899 | void CPWL_ScrollBar::SetScrollPos(FX_FLOAT fPos) { |
| 900 | FX_FLOAT fOldPos = m_sData.fScrollPos; |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 901 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 902 | m_sData.SetPos(fPos); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 903 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 904 | if (!IsFloatEqual(m_sData.fScrollPos, fOldPos)) |
| 905 | MovePosButton(TRUE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 906 | } |
| 907 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 908 | void CPWL_ScrollBar::SetScrollStep(FX_FLOAT fBigStep, FX_FLOAT fSmallStep) { |
| 909 | m_sData.SetBigStep(fBigStep); |
| 910 | m_sData.SetSmallStep(fSmallStep); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 911 | } |
| 912 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 913 | void CPWL_ScrollBar::MovePosButton(FX_BOOL bRefresh) { |
Lei Zhang | 96660d6 | 2015-12-14 18:27:25 -0800 | [diff] [blame] | 914 | ASSERT(m_pMinButton); |
| 915 | ASSERT(m_pMaxButton); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 916 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 917 | if (m_pPosButton->IsVisible()) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 918 | CFX_FloatRect rcClient; |
| 919 | CFX_FloatRect rcPosArea, rcPosButton; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 920 | |
| 921 | rcClient = GetClientRect(); |
| 922 | rcPosArea = GetScrollArea(); |
| 923 | |
| 924 | FX_FLOAT fLeft, fRight, fTop, fBottom; |
| 925 | |
| 926 | switch (m_sbType) { |
| 927 | case SBT_HSCROLL: |
| 928 | fLeft = TrueToFace(m_sData.fScrollPos); |
| 929 | fRight = TrueToFace(m_sData.fScrollPos + m_sData.fClientWidth); |
| 930 | |
| 931 | if (fRight - fLeft < PWL_SCROLLBAR_POSBUTTON_MINWIDTH) |
| 932 | fRight = fLeft + PWL_SCROLLBAR_POSBUTTON_MINWIDTH; |
| 933 | |
| 934 | if (fRight > rcPosArea.right) { |
| 935 | fRight = rcPosArea.right; |
| 936 | fLeft = fRight - PWL_SCROLLBAR_POSBUTTON_MINWIDTH; |
| 937 | } |
| 938 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 939 | rcPosButton = |
| 940 | CFX_FloatRect(fLeft, rcPosArea.bottom, fRight, rcPosArea.top); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 941 | |
| 942 | break; |
| 943 | case SBT_VSCROLL: |
| 944 | fBottom = TrueToFace(m_sData.fScrollPos + m_sData.fClientWidth); |
| 945 | fTop = TrueToFace(m_sData.fScrollPos); |
| 946 | |
| 947 | if (IsFloatSmaller(fTop - fBottom, PWL_SCROLLBAR_POSBUTTON_MINWIDTH)) |
| 948 | fBottom = fTop - PWL_SCROLLBAR_POSBUTTON_MINWIDTH; |
| 949 | |
| 950 | if (IsFloatSmaller(fBottom, rcPosArea.bottom)) { |
| 951 | fBottom = rcPosArea.bottom; |
| 952 | fTop = fBottom + PWL_SCROLLBAR_POSBUTTON_MINWIDTH; |
| 953 | } |
| 954 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 955 | rcPosButton = |
| 956 | CFX_FloatRect(rcPosArea.left, fBottom, rcPosArea.right, fTop); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 957 | |
| 958 | break; |
| 959 | } |
| 960 | |
| 961 | m_pPosButton->Move(rcPosButton, TRUE, bRefresh); |
| 962 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 963 | } |
| 964 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 965 | void CPWL_ScrollBar::OnMinButtonLBDown(const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 966 | m_sData.SubSmall(); |
| 967 | MovePosButton(TRUE); |
| 968 | NotifyScrollWindow(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 969 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 970 | m_bMinOrMax = TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 971 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 972 | EndTimer(); |
| 973 | BeginTimer(100); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 974 | } |
| 975 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 976 | void CPWL_ScrollBar::OnMinButtonLBUp(const CFX_FloatPoint& point) {} |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 977 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 978 | void CPWL_ScrollBar::OnMinButtonMouseMove(const CFX_FloatPoint& point) {} |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 979 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 980 | void CPWL_ScrollBar::OnMaxButtonLBDown(const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 981 | m_sData.AddSmall(); |
| 982 | MovePosButton(TRUE); |
| 983 | NotifyScrollWindow(); |
| 984 | |
| 985 | m_bMinOrMax = FALSE; |
| 986 | |
| 987 | EndTimer(); |
| 988 | BeginTimer(100); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 989 | } |
| 990 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 991 | void CPWL_ScrollBar::OnMaxButtonLBUp(const CFX_FloatPoint& point) {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 992 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 993 | void CPWL_ScrollBar::OnMaxButtonMouseMove(const CFX_FloatPoint& point) {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 994 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 995 | void CPWL_ScrollBar::OnPosButtonLBDown(const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 996 | m_bMouseDown = TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 997 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 998 | if (m_pPosButton) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 999 | CFX_FloatRect rcPosButton = m_pPosButton->GetWindowRect(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1000 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1001 | switch (m_sbType) { |
| 1002 | case SBT_HSCROLL: |
| 1003 | m_nOldPos = point.x; |
| 1004 | m_fOldPosButton = rcPosButton.left; |
| 1005 | break; |
| 1006 | case SBT_VSCROLL: |
| 1007 | m_nOldPos = point.y; |
| 1008 | m_fOldPosButton = rcPosButton.top; |
| 1009 | break; |
| 1010 | } |
| 1011 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1012 | } |
| 1013 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1014 | void CPWL_ScrollBar::OnPosButtonLBUp(const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1015 | if (m_bMouseDown) { |
| 1016 | if (!m_bNotifyForever) |
| 1017 | NotifyScrollWindow(); |
| 1018 | } |
| 1019 | m_bMouseDown = FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1020 | } |
| 1021 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1022 | void CPWL_ScrollBar::OnPosButtonMouseMove(const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1023 | FX_FLOAT fOldScrollPos = m_sData.fScrollPos; |
| 1024 | |
| 1025 | FX_FLOAT fNewPos = 0; |
| 1026 | |
| 1027 | switch (m_sbType) { |
| 1028 | case SBT_HSCROLL: |
| 1029 | if (FXSYS_fabs(point.x - m_nOldPos) < 1) |
| 1030 | return; |
| 1031 | fNewPos = FaceToTrue(m_fOldPosButton + point.x - m_nOldPos); |
| 1032 | break; |
| 1033 | case SBT_VSCROLL: |
| 1034 | if (FXSYS_fabs(point.y - m_nOldPos) < 1) |
| 1035 | return; |
| 1036 | fNewPos = FaceToTrue(m_fOldPosButton + point.y - m_nOldPos); |
| 1037 | break; |
| 1038 | } |
| 1039 | |
| 1040 | if (m_bMouseDown) { |
| 1041 | switch (m_sbType) { |
| 1042 | case SBT_HSCROLL: |
| 1043 | |
| 1044 | if (IsFloatSmaller(fNewPos, m_sData.ScrollRange.fMin)) { |
| 1045 | fNewPos = m_sData.ScrollRange.fMin; |
| 1046 | } |
| 1047 | |
| 1048 | if (IsFloatBigger(fNewPos, m_sData.ScrollRange.fMax)) { |
| 1049 | fNewPos = m_sData.ScrollRange.fMax; |
| 1050 | } |
| 1051 | |
| 1052 | m_sData.SetPos(fNewPos); |
| 1053 | |
| 1054 | break; |
| 1055 | case SBT_VSCROLL: |
| 1056 | |
| 1057 | if (IsFloatSmaller(fNewPos, m_sData.ScrollRange.fMin)) { |
| 1058 | fNewPos = m_sData.ScrollRange.fMin; |
| 1059 | } |
| 1060 | |
| 1061 | if (IsFloatBigger(fNewPos, m_sData.ScrollRange.fMax)) { |
| 1062 | fNewPos = m_sData.ScrollRange.fMax; |
| 1063 | } |
| 1064 | |
| 1065 | m_sData.SetPos(fNewPos); |
| 1066 | |
| 1067 | break; |
| 1068 | } |
| 1069 | |
| 1070 | if (!IsFloatEqual(fOldScrollPos, m_sData.fScrollPos)) { |
| 1071 | MovePosButton(TRUE); |
| 1072 | |
| 1073 | if (m_bNotifyForever) |
| 1074 | NotifyScrollWindow(); |
| 1075 | } |
| 1076 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1077 | } |
| 1078 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1079 | void CPWL_ScrollBar::NotifyScrollWindow() { |
| 1080 | if (CPWL_Wnd* pParent = GetParentWindow()) { |
| 1081 | FX_FLOAT fPos; |
| 1082 | switch (m_sbType) { |
| 1083 | case SBT_HSCROLL: |
| 1084 | fPos = m_OriginInfo.fContentMin + m_sData.fScrollPos; |
| 1085 | break; |
| 1086 | case SBT_VSCROLL: |
| 1087 | fPos = m_OriginInfo.fContentMax - m_sData.fScrollPos; |
| 1088 | break; |
| 1089 | } |
| 1090 | pParent->OnNotify(this, PNM_SCROLLWINDOW, (intptr_t)m_sbType, |
| 1091 | (intptr_t)&fPos); |
| 1092 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1093 | } |
| 1094 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1095 | CFX_FloatRect CPWL_ScrollBar::GetScrollArea() const { |
| 1096 | CFX_FloatRect rcClient = GetClientRect(); |
| 1097 | CFX_FloatRect rcArea; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1098 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1099 | if (!m_pMinButton || !m_pMaxButton) |
| 1100 | return rcClient; |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 1101 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1102 | CFX_FloatRect rcMin = m_pMinButton->GetWindowRect(); |
| 1103 | CFX_FloatRect rcMax = m_pMaxButton->GetWindowRect(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1104 | |
| 1105 | FX_FLOAT fMinWidth = rcMin.right - rcMin.left; |
| 1106 | FX_FLOAT fMinHeight = rcMin.top - rcMin.bottom; |
| 1107 | FX_FLOAT fMaxWidth = rcMax.right - rcMax.left; |
| 1108 | FX_FLOAT fMaxHeight = rcMax.top - rcMax.bottom; |
| 1109 | |
| 1110 | switch (m_sbType) { |
| 1111 | case SBT_HSCROLL: |
| 1112 | if (rcClient.right - rcClient.left > fMinWidth + fMaxWidth + 2) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1113 | rcArea = CFX_FloatRect(rcClient.left + fMinWidth + 1, rcClient.bottom, |
| 1114 | rcClient.right - fMaxWidth - 1, rcClient.top); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1115 | } else { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1116 | rcArea = CFX_FloatRect(rcClient.left + fMinWidth + 1, rcClient.bottom, |
| 1117 | rcClient.left + fMinWidth + 1, rcClient.top); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1118 | } |
| 1119 | break; |
| 1120 | case SBT_VSCROLL: |
| 1121 | if (rcClient.top - rcClient.bottom > fMinHeight + fMaxHeight + 2) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1122 | rcArea = CFX_FloatRect(rcClient.left, rcClient.bottom + fMinHeight + 1, |
| 1123 | rcClient.right, rcClient.top - fMaxHeight - 1); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1124 | } else { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1125 | rcArea = |
| 1126 | CFX_FloatRect(rcClient.left, rcClient.bottom + fMinHeight + 1, |
| 1127 | rcClient.right, rcClient.bottom + fMinHeight + 1); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1128 | } |
| 1129 | break; |
| 1130 | } |
| 1131 | |
| 1132 | rcArea.Normalize(); |
| 1133 | |
| 1134 | return rcArea; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1135 | } |
| 1136 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1137 | FX_FLOAT CPWL_ScrollBar::TrueToFace(FX_FLOAT fTrue) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1138 | CFX_FloatRect rcPosArea; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1139 | rcPosArea = GetScrollArea(); |
| 1140 | |
| 1141 | FX_FLOAT fFactWidth = m_sData.ScrollRange.GetWidth() + m_sData.fClientWidth; |
| 1142 | fFactWidth = fFactWidth == 0 ? 1 : fFactWidth; |
| 1143 | |
| 1144 | FX_FLOAT fFace = 0; |
| 1145 | |
| 1146 | switch (m_sbType) { |
| 1147 | case SBT_HSCROLL: |
| 1148 | fFace = rcPosArea.left + |
| 1149 | fTrue * (rcPosArea.right - rcPosArea.left) / fFactWidth; |
| 1150 | break; |
| 1151 | case SBT_VSCROLL: |
| 1152 | fFace = rcPosArea.top - |
| 1153 | fTrue * (rcPosArea.top - rcPosArea.bottom) / fFactWidth; |
| 1154 | break; |
| 1155 | } |
| 1156 | |
| 1157 | return fFace; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1158 | } |
| 1159 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1160 | FX_FLOAT CPWL_ScrollBar::FaceToTrue(FX_FLOAT fFace) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1161 | CFX_FloatRect rcPosArea; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1162 | rcPosArea = GetScrollArea(); |
| 1163 | |
| 1164 | FX_FLOAT fFactWidth = m_sData.ScrollRange.GetWidth() + m_sData.fClientWidth; |
| 1165 | fFactWidth = fFactWidth == 0 ? 1 : fFactWidth; |
| 1166 | |
| 1167 | FX_FLOAT fTrue = 0; |
| 1168 | |
| 1169 | switch (m_sbType) { |
| 1170 | case SBT_HSCROLL: |
| 1171 | fTrue = (fFace - rcPosArea.left) * fFactWidth / |
| 1172 | (rcPosArea.right - rcPosArea.left); |
| 1173 | break; |
| 1174 | case SBT_VSCROLL: |
| 1175 | fTrue = (rcPosArea.top - fFace) * fFactWidth / |
| 1176 | (rcPosArea.top - rcPosArea.bottom); |
| 1177 | break; |
| 1178 | } |
| 1179 | |
| 1180 | return fTrue; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1181 | } |
| 1182 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1183 | void CPWL_ScrollBar::CreateChildWnd(const PWL_CREATEPARAM& cp) { |
| 1184 | CreateButtons(cp); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1185 | } |
| 1186 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1187 | void CPWL_ScrollBar::TimerProc() { |
| 1188 | PWL_SCROLL_PRIVATEDATA sTemp = m_sData; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1189 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1190 | if (m_bMinOrMax) |
| 1191 | m_sData.SubSmall(); |
| 1192 | else |
| 1193 | m_sData.AddSmall(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1194 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1195 | if (FXSYS_memcmp(&m_sData, &sTemp, sizeof(PWL_SCROLL_PRIVATEDATA)) != 0) { |
| 1196 | MovePosButton(TRUE); |
| 1197 | NotifyScrollWindow(); |
| 1198 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1199 | } |