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 <map> | 7 #include <map> |
8 | 8 |
9 #include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h" | 9 #include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h" |
10 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" | 10 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } | 295 } |
296 | 296 |
297 void CPWL_Wnd::InvalidateRectMove(const CPDF_Rect& rcOld, | 297 void CPWL_Wnd::InvalidateRectMove(const CPDF_Rect& rcOld, |
298 const CPDF_Rect& rcNew) { | 298 const CPDF_Rect& rcNew) { |
299 CPDF_Rect rcUnion = rcOld; | 299 CPDF_Rect rcUnion = rcOld; |
300 rcUnion.Union(rcNew); | 300 rcUnion.Union(rcNew); |
301 | 301 |
302 InvalidateRect(&rcUnion); | 302 InvalidateRect(&rcUnion); |
303 } | 303 } |
304 | 304 |
305 void CPWL_Wnd::GetAppearanceStream(CFX_ByteString& sAppStream) { | |
306 if (IsValid()) { | |
307 CFX_ByteTextBuf sTextBuf; | |
308 GetAppearanceStream(sTextBuf); | |
309 sAppStream += sTextBuf.GetByteString(); | |
310 } | |
311 } | |
312 | |
313 void CPWL_Wnd::GetAppearanceStream(CFX_ByteTextBuf& sAppStream) { | 305 void CPWL_Wnd::GetAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
314 if (IsValid() && IsVisible()) { | 306 if (IsValid() && IsVisible()) { |
315 GetThisAppearanceStream(sAppStream); | 307 GetThisAppearanceStream(sAppStream); |
316 GetChildAppearanceStream(sAppStream); | 308 GetChildAppearanceStream(sAppStream); |
317 } | 309 } |
318 } | 310 } |
319 | 311 |
320 // if don't set,Get default apperance stream | 312 // if don't set,Get default apperance stream |
321 void CPWL_Wnd::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { | 313 void CPWL_Wnd::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
322 CPDF_Rect rectWnd = GetWindowRect(); | 314 CPDF_Rect rectWnd = GetWindowRect(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 CPDF_Rect rectWnd = GetWindowRect(); | 351 CPDF_Rect rectWnd = GetWindowRect(); |
360 if (!rectWnd.IsEmpty()) { | 352 if (!rectWnd.IsEmpty()) { |
361 if (HasFlag(PWS_BACKGROUND)) { | 353 if (HasFlag(PWS_BACKGROUND)) { |
362 CPDF_Rect rcClient = CPWL_Utils::DeflateRect( | 354 CPDF_Rect rcClient = CPWL_Utils::DeflateRect( |
363 rectWnd, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); | 355 rectWnd, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); |
364 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient, | 356 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient, |
365 GetBackgroundColor(), GetTransparency()); | 357 GetBackgroundColor(), GetTransparency()); |
366 } | 358 } |
367 | 359 |
368 if (HasFlag(PWS_BORDER)) | 360 if (HasFlag(PWS_BORDER)) |
369 CPWL_Utils::DrawBorder( | 361 CPWL_Utils::DrawBorder(pDevice, pUser2Device, rectWnd, |
370 pDevice, pUser2Device, rectWnd, (FX_FLOAT)GetBorderWidth(), | 362 (FX_FLOAT)GetBorderWidth(), GetBorderColor(), |
371 GetBorderColor(), GetBorderLeftTopColor(GetBorderStyle()), | 363 GetBorderLeftTopColor(GetBorderStyle()), |
372 GetBorderRightBottomColor(GetBorderStyle()), GetBorderStyle(), | 364 GetBorderRightBottomColor(GetBorderStyle()), |
373 GetBorderDash(), GetTransparency()); | 365 GetBorderStyle(), GetTransparency()); |
374 } | 366 } |
375 } | 367 } |
376 | 368 |
377 void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice, | 369 void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice, |
378 CFX_Matrix* pUser2Device) { | 370 CFX_Matrix* pUser2Device) { |
379 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { | 371 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
380 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { | 372 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
381 CFX_Matrix mt = pChild->GetChildMatrix(); | 373 CFX_Matrix mt = pChild->GetChildMatrix(); |
382 if (mt.IsIdentity()) { | 374 if (mt.IsIdentity()) { |
383 pChild->DrawAppearance(pDevice, pUser2Device); | 375 pChild->DrawAppearance(pDevice, pUser2Device); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 break; | 513 break; |
522 default: | 514 default: |
523 break; | 515 break; |
524 } | 516 } |
525 } | 517 } |
526 | 518 |
527 FX_BOOL CPWL_Wnd::IsValid() const { | 519 FX_BOOL CPWL_Wnd::IsValid() const { |
528 return m_bCreated; | 520 return m_bCreated; |
529 } | 521 } |
530 | 522 |
531 PWL_CREATEPARAM CPWL_Wnd::GetCreationParam() const { | 523 const PWL_CREATEPARAM& CPWL_Wnd::GetCreationParam() const { |
532 return m_sPrivateParam; | 524 return m_sPrivateParam; |
533 } | 525 } |
534 | 526 |
535 CPWL_Wnd* CPWL_Wnd::GetParentWindow() const { | 527 CPWL_Wnd* CPWL_Wnd::GetParentWindow() const { |
536 return m_sPrivateParam.pParentWnd; | 528 return m_sPrivateParam.pParentWnd; |
537 } | 529 } |
538 | 530 |
539 CPDF_Rect CPWL_Wnd::GetOriginWindowRect() const { | |
540 return m_sPrivateParam.rcRectWnd; | |
541 } | |
542 | |
543 CPDF_Rect CPWL_Wnd::GetWindowRect() const { | 531 CPDF_Rect CPWL_Wnd::GetWindowRect() const { |
544 return m_rcWindow; | 532 return m_rcWindow; |
545 } | 533 } |
546 | 534 |
547 CPDF_Rect CPWL_Wnd::GetClientRect() const { | 535 CPDF_Rect CPWL_Wnd::GetClientRect() const { |
548 CPDF_Rect rcWindow = GetWindowRect(); | 536 CPDF_Rect rcWindow = GetWindowRect(); |
549 CPDF_Rect rcClient = CPWL_Utils::DeflateRect( | 537 CPDF_Rect rcClient = CPWL_Utils::DeflateRect( |
550 rcWindow, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); | 538 rcWindow, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); |
551 if (CPWL_ScrollBar* pVSB = GetVScrollBar()) | 539 if (CPWL_ScrollBar* pVSB = GetVScrollBar()) |
552 rcClient.right -= pVSB->GetScrollBarWidth(); | 540 rcClient.right -= pVSB->GetScrollBarWidth(); |
553 | 541 |
554 rcClient.Normalize(); | 542 rcClient.Normalize(); |
555 return rcWindow.Contains(rcClient) ? rcClient : CPDF_Rect(); | 543 return rcWindow.Contains(rcClient) ? rcClient : CPDF_Rect(); |
556 } | 544 } |
557 | 545 |
558 CPDF_Point CPWL_Wnd::GetCenterPoint() const { | 546 CPDF_Point CPWL_Wnd::GetCenterPoint() const { |
559 CPDF_Rect rcClient = GetClientRect(); | 547 CPDF_Rect rcClient = GetClientRect(); |
560 return CPDF_Point((rcClient.left + rcClient.right) * 0.5f, | 548 return CPDF_Point((rcClient.left + rcClient.right) * 0.5f, |
561 (rcClient.top + rcClient.bottom) * 0.5f); | 549 (rcClient.top + rcClient.bottom) * 0.5f); |
562 } | 550 } |
563 | 551 |
564 CPDF_Rect CPWL_Wnd::GetClientCenterSquare() const { | |
565 return CPWL_Utils::GetCenterSquare(GetClientRect()); | |
566 } | |
567 | |
568 CPDF_Rect CPWL_Wnd::GetWindowCenterSquare() const { | |
569 return CPWL_Utils::GetCenterSquare( | |
570 CPWL_Utils::DeflateRect(GetWindowRect(), 0.1f)); | |
571 } | |
572 | |
573 FX_BOOL CPWL_Wnd::HasFlag(FX_DWORD dwFlags) const { | 552 FX_BOOL CPWL_Wnd::HasFlag(FX_DWORD dwFlags) const { |
574 return (m_sPrivateParam.dwFlags & dwFlags) != 0; | 553 return (m_sPrivateParam.dwFlags & dwFlags) != 0; |
575 } | 554 } |
576 | 555 |
577 void CPWL_Wnd::RemoveFlag(FX_DWORD dwFlags) { | 556 void CPWL_Wnd::RemoveFlag(FX_DWORD dwFlags) { |
578 m_sPrivateParam.dwFlags &= ~dwFlags; | 557 m_sPrivateParam.dwFlags &= ~dwFlags; |
579 } | 558 } |
580 | 559 |
581 void CPWL_Wnd::AddFlag(FX_DWORD dwFlags) { | 560 void CPWL_Wnd::AddFlag(FX_DWORD dwFlags) { |
582 m_sPrivateParam.dwFlags |= dwFlags; | 561 m_sPrivateParam.dwFlags |= dwFlags; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 if (HasFlag(PWS_BORDER)) | 598 if (HasFlag(PWS_BORDER)) |
620 return m_sPrivateParam.dwBorderWidth; | 599 return m_sPrivateParam.dwBorderWidth; |
621 | 600 |
622 return 0; | 601 return 0; |
623 } | 602 } |
624 | 603 |
625 int32_t CPWL_Wnd::GetInnerBorderWidth() const { | 604 int32_t CPWL_Wnd::GetInnerBorderWidth() const { |
626 return 0; | 605 return 0; |
627 } | 606 } |
628 | 607 |
629 void CPWL_Wnd::SetBorderWidth(int32_t nBorderWidth) { | |
630 if (HasFlag(PWS_BORDER)) | |
631 m_sPrivateParam.dwBorderWidth = nBorderWidth; | |
632 } | |
633 | |
634 CPWL_Color CPWL_Wnd::GetBorderColor() const { | 608 CPWL_Color CPWL_Wnd::GetBorderColor() const { |
635 if (HasFlag(PWS_BORDER)) | 609 if (HasFlag(PWS_BORDER)) |
636 return m_sPrivateParam.sBorderColor; | 610 return m_sPrivateParam.sBorderColor; |
637 | 611 |
638 return CPWL_Color(); | 612 return CPWL_Color(); |
639 } | 613 } |
640 | 614 |
641 void CPWL_Wnd::SetBorderColor(const CPWL_Color& color) { | 615 const CPWL_Dash& CPWL_Wnd::GetBorderDash() const { |
642 if (HasFlag(PWS_BORDER)) | |
643 m_sPrivateParam.sBorderColor = color; | |
644 } | |
645 | |
646 CPWL_Dash CPWL_Wnd::GetBorderDash() const { | |
647 return m_sPrivateParam.sDash; | 616 return m_sPrivateParam.sDash; |
648 } | 617 } |
649 | 618 |
650 void* CPWL_Wnd::GetAttachedData() const { | 619 void* CPWL_Wnd::GetAttachedData() const { |
651 return m_sPrivateParam.pAttachedData; | 620 return m_sPrivateParam.pAttachedData; |
652 } | 621 } |
653 | 622 |
654 void CPWL_Wnd::SetBorderDash(const CPWL_Dash& sDash) { | |
655 if (HasFlag(PWS_BORDER)) | |
656 m_sPrivateParam.sDash = sDash; | |
657 } | |
658 | |
659 CPWL_ScrollBar* CPWL_Wnd::GetVScrollBar() const { | 623 CPWL_ScrollBar* CPWL_Wnd::GetVScrollBar() const { |
660 if (HasFlag(PWS_VSCROLL)) | 624 if (HasFlag(PWS_VSCROLL)) |
661 return m_pVScrollBar; | 625 return m_pVScrollBar; |
662 | 626 |
663 return NULL; | 627 return NULL; |
664 } | 628 } |
665 | 629 |
666 void CPWL_Wnd::CreateScrollBar(const PWL_CREATEPARAM& cp) { | 630 void CPWL_Wnd::CreateScrollBar(const PWL_CREATEPARAM& cp) { |
667 CreateVScrollBar(cp); | 631 CreateVScrollBar(cp); |
668 } | 632 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 InvalidateRect(); | 711 InvalidateRect(); |
748 } | 712 } |
749 } | 713 } |
750 } | 714 } |
751 | 715 |
752 void CPWL_Wnd::SetClipRect(const CPDF_Rect& rect) { | 716 void CPWL_Wnd::SetClipRect(const CPDF_Rect& rect) { |
753 m_rcClip = rect; | 717 m_rcClip = rect; |
754 m_rcClip.Normalize(); | 718 m_rcClip.Normalize(); |
755 } | 719 } |
756 | 720 |
757 CPDF_Rect CPWL_Wnd::GetClipRect() const { | 721 const CPDF_Rect& CPWL_Wnd::GetClipRect() const { |
758 return m_rcClip; | 722 return m_rcClip; |
759 } | 723 } |
760 | 724 |
761 FX_BOOL CPWL_Wnd::IsReadOnly() const { | 725 FX_BOOL CPWL_Wnd::IsReadOnly() const { |
762 return HasFlag(PWS_READONLY); | 726 return HasFlag(PWS_READONLY); |
763 } | 727 } |
764 | 728 |
765 void CPWL_Wnd::RePosChildWnd() { | 729 void CPWL_Wnd::RePosChildWnd() { |
766 CPDF_Rect rcContent = CPWL_Utils::DeflateRect( | 730 CPDF_Rect rcContent = CPWL_Utils::DeflateRect( |
767 GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); | 731 GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 return FALSE; | 1028 return FALSE; |
1065 } | 1029 } |
1066 | 1030 |
1067 FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const { | 1031 FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const { |
1068 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) { | 1032 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) { |
1069 return pSystemHandler->IsINSERTKeyDown(nFlag); | 1033 return pSystemHandler->IsINSERTKeyDown(nFlag); |
1070 } | 1034 } |
1071 | 1035 |
1072 return FALSE; | 1036 return FALSE; |
1073 } | 1037 } |
OLD | NEW |