| 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/include/pdfwindow/PWL_ListBox.h" | 7 #include "fpdfsdk/include/pdfwindow/PWL_ListBox.h" |
| 8 | 8 |
| 9 #include "fpdfsdk/include/pdfwindow/PWL_Edit.h" | 9 #include "fpdfsdk/include/pdfwindow/PWL_Edit.h" |
| 10 #include "fpdfsdk/include/pdfwindow/PWL_EditCtrl.h" | 10 #include "fpdfsdk/include/pdfwindow/PWL_EditCtrl.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 m_pList->RePosChildWnd(); | 53 m_pList->RePosChildWnd(); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 void CPWL_List_Notify::IOnSetScrollPosY(FX_FLOAT fy) { | 59 void CPWL_List_Notify::IOnSetScrollPosY(FX_FLOAT fy) { |
| 60 m_pList->OnNotify(m_pList, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&fy); | 60 m_pList->OnNotify(m_pList, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&fy); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void CPWL_List_Notify::IOnInvalidateRect(CPDF_Rect* pRect) { | 63 void CPWL_List_Notify::IOnInvalidateRect(CFX_FloatRect* pRect) { |
| 64 m_pList->InvalidateRect(pRect); | 64 m_pList->InvalidateRect(pRect); |
| 65 } | 65 } |
| 66 | 66 |
| 67 CPWL_ListBox::CPWL_ListBox() | 67 CPWL_ListBox::CPWL_ListBox() |
| 68 : m_pList(NULL), | 68 : m_pList(NULL), |
| 69 m_pListNotify(NULL), | 69 m_pListNotify(NULL), |
| 70 m_bMouseDown(FALSE), | 70 m_bMouseDown(FALSE), |
| 71 m_bHoverSel(FALSE), | 71 m_bHoverSel(FALSE), |
| 72 m_pFillerNotify(NULL) { | 72 m_pFillerNotify(NULL) { |
| 73 m_pList = IFX_List::NewList(); | 73 m_pList = IFX_List::NewList(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 102 delete m_pListNotify; | 102 delete m_pListNotify; |
| 103 m_pListNotify = NULL; | 103 m_pListNotify = NULL; |
| 104 } | 104 } |
| 105 | 105 |
| 106 void CPWL_ListBox::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { | 106 void CPWL_ListBox::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
| 107 CPWL_Wnd::GetThisAppearanceStream(sAppStream); | 107 CPWL_Wnd::GetThisAppearanceStream(sAppStream); |
| 108 | 108 |
| 109 CFX_ByteTextBuf sListItems; | 109 CFX_ByteTextBuf sListItems; |
| 110 | 110 |
| 111 if (m_pList) { | 111 if (m_pList) { |
| 112 CPDF_Rect rcPlate = m_pList->GetPlateRect(); | 112 CFX_FloatRect rcPlate = m_pList->GetPlateRect(); |
| 113 for (int32_t i = 0, sz = m_pList->GetCount(); i < sz; i++) { | 113 for (int32_t i = 0, sz = m_pList->GetCount(); i < sz; i++) { |
| 114 CPDF_Rect rcItem = m_pList->GetItemRect(i); | 114 CFX_FloatRect rcItem = m_pList->GetItemRect(i); |
| 115 | 115 |
| 116 if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.bottom) | 116 if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.bottom) |
| 117 continue; | 117 continue; |
| 118 | 118 |
| 119 CPDF_Point ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f); | 119 CFX_FloatPoint ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f); |
| 120 if (m_pList->IsItemSelected(i)) { | 120 if (m_pList->IsItemSelected(i)) { |
| 121 sListItems << CPWL_Utils::GetRectFillAppStream( | 121 sListItems << CPWL_Utils::GetRectFillAppStream( |
| 122 rcItem, PWL_DEFAULT_SELBACKCOLOR); | 122 rcItem, PWL_DEFAULT_SELBACKCOLOR); |
| 123 CFX_ByteString sItem = | 123 CFX_ByteString sItem = |
| 124 CPWL_Utils::GetEditAppStream(m_pList->GetItemEdit(i), ptOffset); | 124 CPWL_Utils::GetEditAppStream(m_pList->GetItemEdit(i), ptOffset); |
| 125 if (sItem.GetLength() > 0) { | 125 if (sItem.GetLength() > 0) { |
| 126 sListItems << "BT\n" | 126 sListItems << "BT\n" |
| 127 << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELTEXTCOLOR) | 127 << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELTEXTCOLOR) |
| 128 << sItem << "ET\n"; | 128 << sItem << "ET\n"; |
| 129 } | 129 } |
| 130 } else { | 130 } else { |
| 131 CFX_ByteString sItem = | 131 CFX_ByteString sItem = |
| 132 CPWL_Utils::GetEditAppStream(m_pList->GetItemEdit(i), ptOffset); | 132 CPWL_Utils::GetEditAppStream(m_pList->GetItemEdit(i), ptOffset); |
| 133 if (sItem.GetLength() > 0) { | 133 if (sItem.GetLength() > 0) { |
| 134 sListItems << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) | 134 sListItems << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) |
| 135 << sItem << "ET\n"; | 135 << sItem << "ET\n"; |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 | 140 |
| 141 if (sListItems.GetLength() > 0) { | 141 if (sListItems.GetLength() > 0) { |
| 142 CFX_ByteTextBuf sClip; | 142 CFX_ByteTextBuf sClip; |
| 143 CPDF_Rect rcClient = GetClientRect(); | 143 CFX_FloatRect rcClient = GetClientRect(); |
| 144 | 144 |
| 145 sClip << "q\n"; | 145 sClip << "q\n"; |
| 146 sClip << rcClient.left << " " << rcClient.bottom << " " | 146 sClip << rcClient.left << " " << rcClient.bottom << " " |
| 147 << rcClient.right - rcClient.left << " " | 147 << rcClient.right - rcClient.left << " " |
| 148 << rcClient.top - rcClient.bottom << " re W n\n"; | 148 << rcClient.top - rcClient.bottom << " re W n\n"; |
| 149 | 149 |
| 150 sClip << sListItems << "Q\n"; | 150 sClip << sListItems << "Q\n"; |
| 151 | 151 |
| 152 sAppStream << "/Tx BMC\n" << sClip << "EMC\n"; | 152 sAppStream << "/Tx BMC\n" << sClip << "EMC\n"; |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 | 155 |
| 156 void CPWL_ListBox::DrawThisAppearance(CFX_RenderDevice* pDevice, | 156 void CPWL_ListBox::DrawThisAppearance(CFX_RenderDevice* pDevice, |
| 157 CFX_Matrix* pUser2Device) { | 157 CFX_Matrix* pUser2Device) { |
| 158 CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); | 158 CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); |
| 159 | 159 |
| 160 if (m_pList) { | 160 if (m_pList) { |
| 161 CPDF_Rect rcPlate = m_pList->GetPlateRect(); | 161 CFX_FloatRect rcPlate = m_pList->GetPlateRect(); |
| 162 CPDF_Rect rcList = GetListRect(); | 162 CFX_FloatRect rcList = GetListRect(); |
| 163 CPDF_Rect rcClient = GetClientRect(); | 163 CFX_FloatRect rcClient = GetClientRect(); |
| 164 | 164 |
| 165 for (int32_t i = 0, sz = m_pList->GetCount(); i < sz; i++) { | 165 for (int32_t i = 0, sz = m_pList->GetCount(); i < sz; i++) { |
| 166 CPDF_Rect rcItem = m_pList->GetItemRect(i); | 166 CFX_FloatRect rcItem = m_pList->GetItemRect(i); |
| 167 if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.bottom) | 167 if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.bottom) |
| 168 continue; | 168 continue; |
| 169 | 169 |
| 170 CPDF_Point ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f); | 170 CFX_FloatPoint ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f); |
| 171 if (IFX_Edit* pEdit = m_pList->GetItemEdit(i)) { | 171 if (IFX_Edit* pEdit = m_pList->GetItemEdit(i)) { |
| 172 CPDF_Rect rcContent = pEdit->GetContentRect(); | 172 CFX_FloatRect rcContent = pEdit->GetContentRect(); |
| 173 if (rcContent.Width() > rcClient.Width()) | 173 if (rcContent.Width() > rcClient.Width()) |
| 174 rcItem.Intersect(rcList); | 174 rcItem.Intersect(rcList); |
| 175 else | 175 else |
| 176 rcItem.Intersect(rcClient); | 176 rcItem.Intersect(rcClient); |
| 177 } | 177 } |
| 178 | 178 |
| 179 if (m_pList->IsItemSelected(i)) { | 179 if (m_pList->IsItemSelected(i)) { |
| 180 IFX_SystemHandler* pSysHandler = GetSystemHandler(); | 180 IFX_SystemHandler* pSysHandler = GetSystemHandler(); |
| 181 if (pSysHandler && pSysHandler->IsSelectionImplemented()) { | 181 if (pSysHandler && pSysHandler->IsSelectionImplemented()) { |
| 182 IFX_Edit::DrawEdit( | 182 IFX_Edit::DrawEdit( |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 CPDF_Point& point, FX_DWORD nFlag) { | 268 FX_BOOL CPWL_ListBox::OnLButtonDown(const CFX_FloatPoint& point, |
| 269 FX_DWORD nFlag) { |
| 269 CPWL_Wnd::OnLButtonDown(point, nFlag); | 270 CPWL_Wnd::OnLButtonDown(point, nFlag); |
| 270 | 271 |
| 271 if (ClientHitTest(point)) { | 272 if (ClientHitTest(point)) { |
| 272 m_bMouseDown = TRUE; | 273 m_bMouseDown = TRUE; |
| 273 SetFocus(); | 274 SetFocus(); |
| 274 SetCapture(); | 275 SetCapture(); |
| 275 | 276 |
| 276 if (m_pList) | 277 if (m_pList) |
| 277 m_pList->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 278 m_pList->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 278 } | 279 } |
| 279 | 280 |
| 280 return TRUE; | 281 return TRUE; |
| 281 } | 282 } |
| 282 | 283 |
| 283 FX_BOOL CPWL_ListBox::OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag) { | 284 FX_BOOL CPWL_ListBox::OnLButtonUp(const CFX_FloatPoint& point, FX_DWORD nFlag) { |
| 284 CPWL_Wnd::OnLButtonUp(point, nFlag); | 285 CPWL_Wnd::OnLButtonUp(point, nFlag); |
| 285 | 286 |
| 286 if (m_bMouseDown) { | 287 if (m_bMouseDown) { |
| 287 ReleaseCapture(); | 288 ReleaseCapture(); |
| 288 m_bMouseDown = FALSE; | 289 m_bMouseDown = FALSE; |
| 289 } | 290 } |
| 290 | 291 |
| 291 FX_BOOL bExit = FALSE; | 292 FX_BOOL bExit = FALSE; |
| 292 OnNotifySelChanged(FALSE, bExit, nFlag); | 293 OnNotifySelChanged(FALSE, bExit, nFlag); |
| 293 | 294 |
| 294 return TRUE; | 295 return TRUE; |
| 295 } | 296 } |
| 296 | 297 |
| 297 void CPWL_ListBox::SetHoverSel(FX_BOOL bHoverSel) { | 298 void CPWL_ListBox::SetHoverSel(FX_BOOL bHoverSel) { |
| 298 m_bHoverSel = bHoverSel; | 299 m_bHoverSel = bHoverSel; |
| 299 } | 300 } |
| 300 | 301 |
| 301 FX_BOOL CPWL_ListBox::OnMouseMove(const CPDF_Point& point, FX_DWORD nFlag) { | 302 FX_BOOL CPWL_ListBox::OnMouseMove(const CFX_FloatPoint& point, FX_DWORD nFlag) { |
| 302 CPWL_Wnd::OnMouseMove(point, nFlag); | 303 CPWL_Wnd::OnMouseMove(point, nFlag); |
| 303 | 304 |
| 304 if (m_bHoverSel && !IsCaptureMouse() && ClientHitTest(point)) { | 305 if (m_bHoverSel && !IsCaptureMouse() && ClientHitTest(point)) { |
| 305 if (m_pList) | 306 if (m_pList) |
| 306 m_pList->Select(m_pList->GetItemIndex(point)); | 307 m_pList->Select(m_pList->GetItemIndex(point)); |
| 307 } | 308 } |
| 308 | 309 |
| 309 if (m_bMouseDown) { | 310 if (m_bMouseDown) { |
| 310 if (m_pList) | 311 if (m_pList) |
| 311 m_pList->OnMouseMove(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 312 m_pList->OnMouseMove(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 339 pChild->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam); | 340 pChild->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam); |
| 340 } | 341 } |
| 341 break; | 342 break; |
| 342 } | 343 } |
| 343 break; | 344 break; |
| 344 case PNM_SCROLLWINDOW: | 345 case PNM_SCROLLWINDOW: |
| 345 fPos = *(FX_FLOAT*)lParam; | 346 fPos = *(FX_FLOAT*)lParam; |
| 346 switch (wParam) { | 347 switch (wParam) { |
| 347 case SBT_VSCROLL: | 348 case SBT_VSCROLL: |
| 348 if (m_pList) | 349 if (m_pList) |
| 349 m_pList->SetScrollPos(CPDF_Point(0, fPos)); | 350 m_pList->SetScrollPos(CFX_FloatPoint(0, fPos)); |
| 350 break; | 351 break; |
| 351 } | 352 } |
| 352 break; | 353 break; |
| 353 } | 354 } |
| 354 } | 355 } |
| 355 | 356 |
| 356 void CPWL_ListBox::KillFocus() { | 357 void CPWL_ListBox::KillFocus() { |
| 357 CPWL_Wnd::KillFocus(); | 358 CPWL_Wnd::KillFocus(); |
| 358 } | 359 } |
| 359 | 360 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 373 FX_BOOL bRC = TRUE; | 374 FX_BOOL bRC = TRUE; |
| 374 CFX_WideString swChange = GetText(); | 375 CFX_WideString swChange = GetText(); |
| 375 CFX_WideString strChangeEx; | 376 CFX_WideString strChangeEx; |
| 376 int nSelStart = 0; | 377 int nSelStart = 0; |
| 377 int nSelEnd = swChange.GetLength(); | 378 int nSelEnd = swChange.GetLength(); |
| 378 m_pFillerNotify->OnBeforeKeyStroke(GetAttachedData(), swChange, strChangeEx, | 379 m_pFillerNotify->OnBeforeKeyStroke(GetAttachedData(), swChange, strChangeEx, |
| 379 nSelStart, nSelEnd, bKeyDown, bRC, bExit, | 380 nSelStart, nSelEnd, bKeyDown, bRC, bExit, |
| 380 nFlag); | 381 nFlag); |
| 381 } | 382 } |
| 382 | 383 |
| 383 CPDF_Rect CPWL_ListBox::GetFocusRect() const { | 384 CFX_FloatRect CPWL_ListBox::GetFocusRect() const { |
| 384 if (m_pList && m_pList->IsMultipleSel()) { | 385 if (m_pList && m_pList->IsMultipleSel()) { |
| 385 CPDF_Rect rcCaret = m_pList->GetItemRect(m_pList->GetCaret()); | 386 CFX_FloatRect rcCaret = m_pList->GetItemRect(m_pList->GetCaret()); |
| 386 rcCaret.Intersect(GetClientRect()); | 387 rcCaret.Intersect(GetClientRect()); |
| 387 return rcCaret; | 388 return rcCaret; |
| 388 } | 389 } |
| 389 | 390 |
| 390 return CPWL_Wnd::GetFocusRect(); | 391 return CPWL_Wnd::GetFocusRect(); |
| 391 } | 392 } |
| 392 | 393 |
| 393 void CPWL_ListBox::AddString(const FX_WCHAR* string) { | 394 void CPWL_ListBox::AddString(const FX_WCHAR* string) { |
| 394 if (m_pList) { | 395 if (m_pList) { |
| 395 m_pList->AddString(string); | 396 m_pList->AddString(string); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 return 0; | 489 return 0; |
| 489 } | 490 } |
| 490 | 491 |
| 491 int32_t CPWL_ListBox::FindNext(int32_t nIndex, FX_WCHAR nChar) const { | 492 int32_t CPWL_ListBox::FindNext(int32_t nIndex, FX_WCHAR nChar) const { |
| 492 if (m_pList) | 493 if (m_pList) |
| 493 return m_pList->FindNext(nIndex, nChar); | 494 return m_pList->FindNext(nIndex, nChar); |
| 494 | 495 |
| 495 return nIndex; | 496 return nIndex; |
| 496 } | 497 } |
| 497 | 498 |
| 498 CPDF_Rect CPWL_ListBox::GetContentRect() const { | 499 CFX_FloatRect CPWL_ListBox::GetContentRect() const { |
| 499 if (m_pList) | 500 if (m_pList) |
| 500 return m_pList->GetContentRect(); | 501 return m_pList->GetContentRect(); |
| 501 | 502 |
| 502 return CPDF_Rect(); | 503 return CFX_FloatRect(); |
| 503 } | 504 } |
| 504 | 505 |
| 505 FX_FLOAT CPWL_ListBox::GetFirstHeight() const { | 506 FX_FLOAT CPWL_ListBox::GetFirstHeight() const { |
| 506 if (m_pList) | 507 if (m_pList) |
| 507 return m_pList->GetFirstHeight(); | 508 return m_pList->GetFirstHeight(); |
| 508 | 509 |
| 509 return 0.0f; | 510 return 0.0f; |
| 510 } | 511 } |
| 511 | 512 |
| 512 CPDF_Rect CPWL_ListBox::GetListRect() const { | 513 CFX_FloatRect CPWL_ListBox::GetListRect() const { |
| 513 return CPWL_Utils::DeflateRect( | 514 return CPWL_Utils::DeflateRect( |
| 514 GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); | 515 GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); |
| 515 } | 516 } |
| 516 | 517 |
| 517 FX_BOOL CPWL_ListBox::OnMouseWheel(short zDelta, | 518 FX_BOOL CPWL_ListBox::OnMouseWheel(short zDelta, |
| 518 const CPDF_Point& point, | 519 const CFX_FloatPoint& point, |
| 519 FX_DWORD nFlag) { | 520 FX_DWORD nFlag) { |
| 520 if (!m_pList) | 521 if (!m_pList) |
| 521 return FALSE; | 522 return FALSE; |
| 522 | 523 |
| 523 if (zDelta < 0) { | 524 if (zDelta < 0) { |
| 524 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 525 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 525 } else { | 526 } else { |
| 526 m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 527 m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 527 } | 528 } |
| 528 | 529 |
| 529 FX_BOOL bExit = FALSE; | 530 FX_BOOL bExit = FALSE; |
| 530 OnNotifySelChanged(FALSE, bExit, nFlag); | 531 OnNotifySelChanged(FALSE, bExit, nFlag); |
| 531 return TRUE; | 532 return TRUE; |
| 532 } | 533 } |
| OLD | NEW |