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