| 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(CFX_FloatRect* pRect) { | 63 void CPWL_List_Notify::IOnInvalidateRect(CPDF_Rect* 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 CFX_FloatRect rcPlate = m_pList->GetPlateRect(); | 112 CPDF_Rect 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 CFX_FloatRect rcItem = m_pList->GetItemRect(i); | 114 CPDF_Rect 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 CFX_FloatPoint ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f); | 119 CPDF_Point 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 CFX_FloatRect rcClient = GetClientRect(); | 143 CPDF_Rect 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 CFX_FloatRect rcPlate = m_pList->GetPlateRect(); | 161 CPDF_Rect rcPlate = m_pList->GetPlateRect(); |
| 162 CFX_FloatRect rcList = GetListRect(); | 162 CPDF_Rect rcList = GetListRect(); |
| 163 CFX_FloatRect rcClient = GetClientRect(); | 163 CPDF_Rect 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 CFX_FloatRect rcItem = m_pList->GetItemRect(i); | 166 CPDF_Rect 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 CFX_FloatPoint ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f); | 170 CPDF_Point 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 CFX_FloatRect rcContent = pEdit->GetContentRect(); | 172 CPDF_Rect 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 CFX_FloatPoint& point, | 268 FX_BOOL CPWL_ListBox::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) { |
| 269 FX_DWORD nFlag) { | |
| 270 CPWL_Wnd::OnLButtonDown(point, nFlag); | 269 CPWL_Wnd::OnLButtonDown(point, nFlag); |
| 271 | 270 |
| 272 if (ClientHitTest(point)) { | 271 if (ClientHitTest(point)) { |
| 273 m_bMouseDown = TRUE; | 272 m_bMouseDown = TRUE; |
| 274 SetFocus(); | 273 SetFocus(); |
| 275 SetCapture(); | 274 SetCapture(); |
| 276 | 275 |
| 277 if (m_pList) | 276 if (m_pList) |
| 278 m_pList->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 277 m_pList->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 279 } | 278 } |
| 280 | 279 |
| 281 return TRUE; | 280 return TRUE; |
| 282 } | 281 } |
| 283 | 282 |
| 284 FX_BOOL CPWL_ListBox::OnLButtonUp(const CFX_FloatPoint& point, FX_DWORD nFlag) { | 283 FX_BOOL CPWL_ListBox::OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag) { |
| 285 CPWL_Wnd::OnLButtonUp(point, nFlag); | 284 CPWL_Wnd::OnLButtonUp(point, nFlag); |
| 286 | 285 |
| 287 if (m_bMouseDown) { | 286 if (m_bMouseDown) { |
| 288 ReleaseCapture(); | 287 ReleaseCapture(); |
| 289 m_bMouseDown = FALSE; | 288 m_bMouseDown = FALSE; |
| 290 } | 289 } |
| 291 | 290 |
| 292 FX_BOOL bExit = FALSE; | 291 FX_BOOL bExit = FALSE; |
| 293 OnNotifySelChanged(FALSE, bExit, nFlag); | 292 OnNotifySelChanged(FALSE, bExit, nFlag); |
| 294 | 293 |
| 295 return TRUE; | 294 return TRUE; |
| 296 } | 295 } |
| 297 | 296 |
| 298 void CPWL_ListBox::SetHoverSel(FX_BOOL bHoverSel) { | 297 void CPWL_ListBox::SetHoverSel(FX_BOOL bHoverSel) { |
| 299 m_bHoverSel = bHoverSel; | 298 m_bHoverSel = bHoverSel; |
| 300 } | 299 } |
| 301 | 300 |
| 302 FX_BOOL CPWL_ListBox::OnMouseMove(const CFX_FloatPoint& point, FX_DWORD nFlag) { | 301 FX_BOOL CPWL_ListBox::OnMouseMove(const CPDF_Point& point, FX_DWORD nFlag) { |
| 303 CPWL_Wnd::OnMouseMove(point, nFlag); | 302 CPWL_Wnd::OnMouseMove(point, nFlag); |
| 304 | 303 |
| 305 if (m_bHoverSel && !IsCaptureMouse() && ClientHitTest(point)) { | 304 if (m_bHoverSel && !IsCaptureMouse() && ClientHitTest(point)) { |
| 306 if (m_pList) | 305 if (m_pList) |
| 307 m_pList->Select(m_pList->GetItemIndex(point)); | 306 m_pList->Select(m_pList->GetItemIndex(point)); |
| 308 } | 307 } |
| 309 | 308 |
| 310 if (m_bMouseDown) { | 309 if (m_bMouseDown) { |
| 311 if (m_pList) | 310 if (m_pList) |
| 312 m_pList->OnMouseMove(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 311 m_pList->OnMouseMove(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 340 pChild->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam); | 339 pChild->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam); |
| 341 } | 340 } |
| 342 break; | 341 break; |
| 343 } | 342 } |
| 344 break; | 343 break; |
| 345 case PNM_SCROLLWINDOW: | 344 case PNM_SCROLLWINDOW: |
| 346 fPos = *(FX_FLOAT*)lParam; | 345 fPos = *(FX_FLOAT*)lParam; |
| 347 switch (wParam) { | 346 switch (wParam) { |
| 348 case SBT_VSCROLL: | 347 case SBT_VSCROLL: |
| 349 if (m_pList) | 348 if (m_pList) |
| 350 m_pList->SetScrollPos(CFX_FloatPoint(0, fPos)); | 349 m_pList->SetScrollPos(CPDF_Point(0, fPos)); |
| 351 break; | 350 break; |
| 352 } | 351 } |
| 353 break; | 352 break; |
| 354 } | 353 } |
| 355 } | 354 } |
| 356 | 355 |
| 357 void CPWL_ListBox::KillFocus() { | 356 void CPWL_ListBox::KillFocus() { |
| 358 CPWL_Wnd::KillFocus(); | 357 CPWL_Wnd::KillFocus(); |
| 359 } | 358 } |
| 360 | 359 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 374 FX_BOOL bRC = TRUE; | 373 FX_BOOL bRC = TRUE; |
| 375 CFX_WideString swChange = GetText(); | 374 CFX_WideString swChange = GetText(); |
| 376 CFX_WideString strChangeEx; | 375 CFX_WideString strChangeEx; |
| 377 int nSelStart = 0; | 376 int nSelStart = 0; |
| 378 int nSelEnd = swChange.GetLength(); | 377 int nSelEnd = swChange.GetLength(); |
| 379 m_pFillerNotify->OnBeforeKeyStroke(GetAttachedData(), swChange, strChangeEx, | 378 m_pFillerNotify->OnBeforeKeyStroke(GetAttachedData(), swChange, strChangeEx, |
| 380 nSelStart, nSelEnd, bKeyDown, bRC, bExit, | 379 nSelStart, nSelEnd, bKeyDown, bRC, bExit, |
| 381 nFlag); | 380 nFlag); |
| 382 } | 381 } |
| 383 | 382 |
| 384 CFX_FloatRect CPWL_ListBox::GetFocusRect() const { | 383 CPDF_Rect CPWL_ListBox::GetFocusRect() const { |
| 385 if (m_pList && m_pList->IsMultipleSel()) { | 384 if (m_pList && m_pList->IsMultipleSel()) { |
| 386 CFX_FloatRect rcCaret = m_pList->GetItemRect(m_pList->GetCaret()); | 385 CPDF_Rect rcCaret = m_pList->GetItemRect(m_pList->GetCaret()); |
| 387 rcCaret.Intersect(GetClientRect()); | 386 rcCaret.Intersect(GetClientRect()); |
| 388 return rcCaret; | 387 return rcCaret; |
| 389 } | 388 } |
| 390 | 389 |
| 391 return CPWL_Wnd::GetFocusRect(); | 390 return CPWL_Wnd::GetFocusRect(); |
| 392 } | 391 } |
| 393 | 392 |
| 394 void CPWL_ListBox::AddString(const FX_WCHAR* string) { | 393 void CPWL_ListBox::AddString(const FX_WCHAR* string) { |
| 395 if (m_pList) { | 394 if (m_pList) { |
| 396 m_pList->AddString(string); | 395 m_pList->AddString(string); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 return 0; | 488 return 0; |
| 490 } | 489 } |
| 491 | 490 |
| 492 int32_t CPWL_ListBox::FindNext(int32_t nIndex, FX_WCHAR nChar) const { | 491 int32_t CPWL_ListBox::FindNext(int32_t nIndex, FX_WCHAR nChar) const { |
| 493 if (m_pList) | 492 if (m_pList) |
| 494 return m_pList->FindNext(nIndex, nChar); | 493 return m_pList->FindNext(nIndex, nChar); |
| 495 | 494 |
| 496 return nIndex; | 495 return nIndex; |
| 497 } | 496 } |
| 498 | 497 |
| 499 CFX_FloatRect CPWL_ListBox::GetContentRect() const { | 498 CPDF_Rect CPWL_ListBox::GetContentRect() const { |
| 500 if (m_pList) | 499 if (m_pList) |
| 501 return m_pList->GetContentRect(); | 500 return m_pList->GetContentRect(); |
| 502 | 501 |
| 503 return CFX_FloatRect(); | 502 return CPDF_Rect(); |
| 504 } | 503 } |
| 505 | 504 |
| 506 FX_FLOAT CPWL_ListBox::GetFirstHeight() const { | 505 FX_FLOAT CPWL_ListBox::GetFirstHeight() const { |
| 507 if (m_pList) | 506 if (m_pList) |
| 508 return m_pList->GetFirstHeight(); | 507 return m_pList->GetFirstHeight(); |
| 509 | 508 |
| 510 return 0.0f; | 509 return 0.0f; |
| 511 } | 510 } |
| 512 | 511 |
| 513 CFX_FloatRect CPWL_ListBox::GetListRect() const { | 512 CPDF_Rect CPWL_ListBox::GetListRect() const { |
| 514 return CPWL_Utils::DeflateRect( | 513 return CPWL_Utils::DeflateRect( |
| 515 GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); | 514 GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); |
| 516 } | 515 } |
| 517 | 516 |
| 518 FX_BOOL CPWL_ListBox::OnMouseWheel(short zDelta, | 517 FX_BOOL CPWL_ListBox::OnMouseWheel(short zDelta, |
| 519 const CFX_FloatPoint& point, | 518 const CPDF_Point& point, |
| 520 FX_DWORD nFlag) { | 519 FX_DWORD nFlag) { |
| 521 if (!m_pList) | 520 if (!m_pList) |
| 522 return FALSE; | 521 return FALSE; |
| 523 | 522 |
| 524 if (zDelta < 0) { | 523 if (zDelta < 0) { |
| 525 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 524 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 526 } else { | 525 } else { |
| 527 m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); | 526 m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 528 } | 527 } |
| 529 | 528 |
| 530 FX_BOOL bExit = FALSE; | 529 FX_BOOL bExit = FALSE; |
| 531 OnNotifySelChanged(FALSE, bExit, nFlag); | 530 OnNotifySelChanged(FALSE, bExit, nFlag); |
| 532 return TRUE; | 531 return TRUE; |
| 533 } | 532 } |
| OLD | NEW |