| 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 "fpdfsdk/pdfwindow/PWL_ListBox.h" | 7 #include "fpdfsdk/pdfwindow/PWL_ListBox.h" |
| 8 | 8 |
| 9 #include "fpdfsdk/pdfwindow/PWL_Edit.h" | 9 #include "fpdfsdk/pdfwindow/PWL_Edit.h" |
| 10 #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" | 10 #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 IFX_SystemHandler* pSysHandler = GetSystemHandler(); | 196 IFX_SystemHandler* pSysHandler = GetSystemHandler(); |
| 197 IFX_Edit::DrawEdit(pDevice, pUser2Device, m_pList->GetItemEdit(i), | 197 IFX_Edit::DrawEdit(pDevice, pUser2Device, m_pList->GetItemEdit(i), |
| 198 CPWL_Utils::PWLColorToFXColor(GetTextColor()), | 198 CPWL_Utils::PWLColorToFXColor(GetTextColor()), |
| 199 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor()), | 199 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor()), |
| 200 rcList, ptOffset, NULL, pSysHandler, NULL); | 200 rcList, ptOffset, NULL, pSysHandler, NULL); |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 FX_BOOL CPWL_ListBox::OnKeyDown(uint16_t nChar, FX_DWORD nFlag) { | 206 FX_BOOL CPWL_ListBox::OnKeyDown(uint16_t nChar, uint32_t nFlag) { |
| 207 CPWL_Wnd::OnKeyDown(nChar, nFlag); | 207 CPWL_Wnd::OnKeyDown(nChar, nFlag); |
| 208 | 208 |
| 209 if (!m_pList) | 209 if (!m_pList) |
| 210 return FALSE; | 210 return FALSE; |
| 211 | 211 |
| 212 switch (nChar) { | 212 switch (nChar) { |
| 213 default: | 213 default: |
| 214 return FALSE; | 214 return FALSE; |
| 215 case FWL_VKEY_Up: | 215 case FWL_VKEY_Up: |
| 216 case FWL_VKEY_Down: | 216 case FWL_VKEY_Down: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 243 case FWL_VKEY_Delete: | 243 case FWL_VKEY_Delete: |
| 244 break; | 244 break; |
| 245 } | 245 } |
| 246 | 246 |
| 247 FX_BOOL bExit = FALSE; | 247 FX_BOOL bExit = FALSE; |
| 248 OnNotifySelChanged(TRUE, bExit, nFlag); | 248 OnNotifySelChanged(TRUE, bExit, nFlag); |
| 249 | 249 |
| 250 return TRUE; | 250 return TRUE; |
| 251 } | 251 } |
| 252 | 252 |
| 253 FX_BOOL CPWL_ListBox::OnChar(uint16_t nChar, FX_DWORD nFlag) { | 253 FX_BOOL CPWL_ListBox::OnChar(uint16_t nChar, uint32_t nFlag) { |
| 254 CPWL_Wnd::OnChar(nChar, nFlag); | 254 CPWL_Wnd::OnChar(nChar, nFlag); |
| 255 | 255 |
| 256 if (!m_pList) | 256 if (!m_pList) |
| 257 return FALSE; | 257 return FALSE; |
| 258 | 258 |
| 259 if (!m_pList->OnChar(nChar, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag))) | 259 if (!m_pList->OnChar(nChar, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag))) |
| 260 return FALSE; | 260 return FALSE; |
| 261 | 261 |
| 262 FX_BOOL bExit = FALSE; | 262 FX_BOOL bExit = FALSE; |
| 263 OnNotifySelChanged(TRUE, bExit, nFlag); | 263 OnNotifySelChanged(TRUE, bExit, nFlag); |
| 264 | 264 |
| 265 return TRUE; | 265 return TRUE; |
| 266 } | 266 } |
| 267 | 267 |
| 268 FX_BOOL CPWL_ListBox::OnLButtonDown(const CFX_FloatPoint& point, | 268 FX_BOOL CPWL_ListBox::OnLButtonDown(const CFX_FloatPoint& point, |
| 269 FX_DWORD nFlag) { | 269 uint32_t nFlag) { |
| 270 CPWL_Wnd::OnLButtonDown(point, nFlag); | 270 CPWL_Wnd::OnLButtonDown(point, nFlag); |
| 271 | 271 |
| 272 if (ClientHitTest(point)) { | 272 if (ClientHitTest(point)) { |
| 273 m_bMouseDown = TRUE; | 273 m_bMouseDown = TRUE; |
| 274 SetFocus(); | 274 SetFocus(); |
| 275 SetCapture(); | 275 SetCapture(); |
| 276 | 276 |
| 277 if (m_pList) | 277 if (m_pList) |
| 278 m_pList->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 278 m_pList->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 279 } | 279 } |
| 280 | 280 |
| 281 return TRUE; | 281 return TRUE; |
| 282 } | 282 } |
| 283 | 283 |
| 284 FX_BOOL CPWL_ListBox::OnLButtonUp(const CFX_FloatPoint& point, FX_DWORD nFlag) { | 284 FX_BOOL CPWL_ListBox::OnLButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) { |
| 285 CPWL_Wnd::OnLButtonUp(point, nFlag); | 285 CPWL_Wnd::OnLButtonUp(point, nFlag); |
| 286 | 286 |
| 287 if (m_bMouseDown) { | 287 if (m_bMouseDown) { |
| 288 ReleaseCapture(); | 288 ReleaseCapture(); |
| 289 m_bMouseDown = FALSE; | 289 m_bMouseDown = FALSE; |
| 290 } | 290 } |
| 291 | 291 |
| 292 FX_BOOL bExit = FALSE; | 292 FX_BOOL bExit = FALSE; |
| 293 OnNotifySelChanged(FALSE, bExit, nFlag); | 293 OnNotifySelChanged(FALSE, bExit, nFlag); |
| 294 | 294 |
| 295 return TRUE; | 295 return TRUE; |
| 296 } | 296 } |
| 297 | 297 |
| 298 void CPWL_ListBox::SetHoverSel(FX_BOOL bHoverSel) { | 298 void CPWL_ListBox::SetHoverSel(FX_BOOL bHoverSel) { |
| 299 m_bHoverSel = bHoverSel; | 299 m_bHoverSel = bHoverSel; |
| 300 } | 300 } |
| 301 | 301 |
| 302 FX_BOOL CPWL_ListBox::OnMouseMove(const CFX_FloatPoint& point, FX_DWORD nFlag) { | 302 FX_BOOL CPWL_ListBox::OnMouseMove(const CFX_FloatPoint& point, uint32_t nFlag) { |
| 303 CPWL_Wnd::OnMouseMove(point, nFlag); | 303 CPWL_Wnd::OnMouseMove(point, nFlag); |
| 304 | 304 |
| 305 if (m_bHoverSel && !IsCaptureMouse() && ClientHitTest(point)) { | 305 if (m_bHoverSel && !IsCaptureMouse() && ClientHitTest(point)) { |
| 306 if (m_pList) | 306 if (m_pList) |
| 307 m_pList->Select(m_pList->GetItemIndex(point)); | 307 m_pList->Select(m_pList->GetItemIndex(point)); |
| 308 } | 308 } |
| 309 | 309 |
| 310 if (m_bMouseDown) { | 310 if (m_bMouseDown) { |
| 311 if (m_pList) | 311 if (m_pList) |
| 312 m_pList->OnMouseMove(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 312 m_pList->OnMouseMove(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 313 } | 313 } |
| 314 | 314 |
| 315 return TRUE; | 315 return TRUE; |
| 316 } | 316 } |
| 317 | 317 |
| 318 void CPWL_ListBox::OnNotify(CPWL_Wnd* pWnd, | 318 void CPWL_ListBox::OnNotify(CPWL_Wnd* pWnd, |
| 319 FX_DWORD msg, | 319 uint32_t msg, |
| 320 intptr_t wParam, | 320 intptr_t wParam, |
| 321 intptr_t lParam) { | 321 intptr_t lParam) { |
| 322 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); | 322 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); |
| 323 | 323 |
| 324 FX_FLOAT fPos; | 324 FX_FLOAT fPos; |
| 325 | 325 |
| 326 switch (msg) { | 326 switch (msg) { |
| 327 case PNM_SETSCROLLINFO: | 327 case PNM_SETSCROLLINFO: |
| 328 switch (wParam) { | 328 switch (wParam) { |
| 329 case SBT_VSCROLL: | 329 case SBT_VSCROLL: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 360 | 360 |
| 361 void CPWL_ListBox::RePosChildWnd() { | 361 void CPWL_ListBox::RePosChildWnd() { |
| 362 CPWL_Wnd::RePosChildWnd(); | 362 CPWL_Wnd::RePosChildWnd(); |
| 363 | 363 |
| 364 if (m_pList) | 364 if (m_pList) |
| 365 m_pList->SetPlateRect(GetListRect()); | 365 m_pList->SetPlateRect(GetListRect()); |
| 366 } | 366 } |
| 367 | 367 |
| 368 void CPWL_ListBox::OnNotifySelChanged(FX_BOOL bKeyDown, | 368 void CPWL_ListBox::OnNotifySelChanged(FX_BOOL bKeyDown, |
| 369 FX_BOOL& bExit, | 369 FX_BOOL& bExit, |
| 370 FX_DWORD nFlag) { | 370 uint32_t nFlag) { |
| 371 if (!m_pFillerNotify) | 371 if (!m_pFillerNotify) |
| 372 return; | 372 return; |
| 373 | 373 |
| 374 FX_BOOL bRC = TRUE; | 374 FX_BOOL bRC = TRUE; |
| 375 CFX_WideString swChange = GetText(); | 375 CFX_WideString swChange = GetText(); |
| 376 CFX_WideString strChangeEx; | 376 CFX_WideString strChangeEx; |
| 377 int nSelStart = 0; | 377 int nSelStart = 0; |
| 378 int nSelEnd = swChange.GetLength(); | 378 int nSelEnd = swChange.GetLength(); |
| 379 m_pFillerNotify->OnBeforeKeyStroke(GetAttachedData(), swChange, strChangeEx, | 379 m_pFillerNotify->OnBeforeKeyStroke(GetAttachedData(), swChange, strChangeEx, |
| 380 nSelStart, nSelEnd, bKeyDown, bRC, bExit, | 380 nSelStart, nSelEnd, bKeyDown, bRC, bExit, |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 return 0.0f; | 510 return 0.0f; |
| 511 } | 511 } |
| 512 | 512 |
| 513 CFX_FloatRect CPWL_ListBox::GetListRect() const { | 513 CFX_FloatRect CPWL_ListBox::GetListRect() const { |
| 514 return CPWL_Utils::DeflateRect( | 514 return CPWL_Utils::DeflateRect( |
| 515 GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); | 515 GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); |
| 516 } | 516 } |
| 517 | 517 |
| 518 FX_BOOL CPWL_ListBox::OnMouseWheel(short zDelta, | 518 FX_BOOL CPWL_ListBox::OnMouseWheel(short zDelta, |
| 519 const CFX_FloatPoint& point, | 519 const CFX_FloatPoint& point, |
| 520 FX_DWORD nFlag) { | 520 uint32_t nFlag) { |
| 521 if (!m_pList) | 521 if (!m_pList) |
| 522 return FALSE; | 522 return FALSE; |
| 523 | 523 |
| 524 if (zDelta < 0) { | 524 if (zDelta < 0) { |
| 525 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 525 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 526 } else { | 526 } else { |
| 527 m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 527 m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 528 } | 528 } |
| 529 | 529 |
| 530 FX_BOOL bExit = FALSE; | 530 FX_BOOL bExit = FALSE; |
| 531 OnNotifySelChanged(FALSE, bExit, nFlag); | 531 OnNotifySelChanged(FALSE, bExit, nFlag); |
| 532 return TRUE; | 532 return TRUE; |
| 533 } | 533 } |
| OLD | NEW |