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 "xfa/fwl/core/fwl_widgetimp.h" | 7 #include "xfa/fwl/core/fwl_widgetimp.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 FWL_Error CFWL_WidgetImp::SetWidgetRect(const CFX_RectF& rect) { | 238 FWL_Error CFWL_WidgetImp::SetWidgetRect(const CFX_RectF& rect) { |
239 CFX_RectF rtOld = m_pProperties->m_rtWidget; | 239 CFX_RectF rtOld = m_pProperties->m_rtWidget; |
240 m_pProperties->m_rtWidget = rect; | 240 m_pProperties->m_rtWidget = rect; |
241 if (IsChild()) { | 241 if (IsChild()) { |
242 if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f || | 242 if (FXSYS_fabs(rtOld.width - rect.width) > 0.5f || |
243 FXSYS_fabs(rtOld.height - rect.height) > 0.5f) { | 243 FXSYS_fabs(rtOld.height - rect.height) > 0.5f) { |
244 CFWL_EvtSizeChanged ev; | 244 CFWL_EvtSizeChanged ev; |
245 ev.m_pSrcTarget = m_pInterface; | 245 ev.m_pSrcTarget = m_pInterface; |
246 ev.m_rtOld = rtOld; | 246 ev.m_rtOld = rtOld; |
247 ev.m_rtNew = rect; | 247 ev.m_rtNew = rect; |
248 IFWL_WidgetDelegate* pDelegate = SetDelegate(NULL); | 248 IFWL_WidgetDelegate* pDelegate = SetDelegate(nullptr); |
249 if (pDelegate) { | 249 if (pDelegate) { |
250 pDelegate->OnProcessEvent(&ev); | 250 pDelegate->OnProcessEvent(&ev); |
251 } | 251 } |
252 } | 252 } |
253 return FWL_Error::Succeeded; | 253 return FWL_Error::Succeeded; |
254 } | 254 } |
255 m_pWidgetMgr->SetWidgetRect_Native(m_pInterface, rect); | 255 m_pWidgetMgr->SetWidgetRect_Native(m_pInterface, rect); |
256 return FWL_Error::Succeeded; | 256 return FWL_Error::Succeeded; |
257 } | 257 } |
258 FWL_Error CFWL_WidgetImp::GetClientRect(CFX_RectF& rect) { | 258 FWL_Error CFWL_WidgetImp::GetClientRect(CFX_RectF& rect) { |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 } | 618 } |
619 return 0; | 619 return 0; |
620 } | 620 } |
621 void CFWL_WidgetImp::GetRelativeRect(CFX_RectF& rect) { | 621 void CFWL_WidgetImp::GetRelativeRect(CFX_RectF& rect) { |
622 rect = m_pProperties->m_rtWidget; | 622 rect = m_pProperties->m_rtWidget; |
623 rect.left = rect.top = 0; | 623 rect.left = rect.top = 0; |
624 } | 624 } |
625 void* CFWL_WidgetImp::GetThemeCapacity(CFWL_WidgetCapacity dwCapacity) { | 625 void* CFWL_WidgetImp::GetThemeCapacity(CFWL_WidgetCapacity dwCapacity) { |
626 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); | 626 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); |
627 if (!pTheme) | 627 if (!pTheme) |
628 return NULL; | 628 return nullptr; |
629 CFWL_ThemePart part; | 629 CFWL_ThemePart part; |
630 part.m_pWidget = m_pInterface; | 630 part.m_pWidget = m_pInterface; |
631 return pTheme->GetCapacity(&part, dwCapacity); | 631 return pTheme->GetCapacity(&part, dwCapacity); |
632 } | 632 } |
633 IFWL_ThemeProvider* CFWL_WidgetImp::GetAvailableTheme() { | 633 IFWL_ThemeProvider* CFWL_WidgetImp::GetAvailableTheme() { |
634 if (m_pProperties->m_pThemeProvider) { | 634 if (m_pProperties->m_pThemeProvider) { |
635 return m_pProperties->m_pThemeProvider; | 635 return m_pProperties->m_pThemeProvider; |
636 } | 636 } |
637 IFWL_Widget* pUp = m_pInterface; | 637 IFWL_Widget* pUp = m_pInterface; |
638 do { | 638 do { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 | 703 |
704 CFWL_NoteDriver* pDriver = | 704 CFWL_NoteDriver* pDriver = |
705 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 705 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
706 if (!pDriver) | 706 if (!pDriver) |
707 return; | 707 return; |
708 | 708 |
709 IFWL_Widget* curFocus = pDriver->GetFocus(); | 709 IFWL_Widget* curFocus = pDriver->GetFocus(); |
710 if (bFocus && curFocus != m_pInterface) { | 710 if (bFocus && curFocus != m_pInterface) { |
711 pDriver->SetFocus(m_pInterface); | 711 pDriver->SetFocus(m_pInterface); |
712 } else if (!bFocus && curFocus == m_pInterface) { | 712 } else if (!bFocus && curFocus == m_pInterface) { |
713 pDriver->SetFocus(NULL); | 713 pDriver->SetFocus(nullptr); |
714 } | 714 } |
715 } | 715 } |
716 void CFWL_WidgetImp::SetGrab(FX_BOOL bSet) { | 716 void CFWL_WidgetImp::SetGrab(FX_BOOL bSet) { |
717 IFWL_App* pApp = GetOwnerApp(); | 717 IFWL_App* pApp = GetOwnerApp(); |
718 if (!pApp) | 718 if (!pApp) |
719 return; | 719 return; |
720 CFWL_NoteDriver* pDriver = | 720 CFWL_NoteDriver* pDriver = |
721 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 721 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
722 pDriver->SetGrab(m_pInterface, bSet); | 722 pDriver->SetGrab(m_pInterface, bSet); |
723 } | 723 } |
(...skipping 22 matching lines...) Expand all Loading... |
746 const CFX_RectF& rtAnchor, | 746 const CFX_RectF& rtAnchor, |
747 CFX_RectF& rtPopup) { | 747 CFX_RectF& rtPopup) { |
748 FX_FLOAT fx = 0; | 748 FX_FLOAT fx = 0; |
749 FX_FLOAT fy = 0; | 749 FX_FLOAT fy = 0; |
750 FX_FLOAT fScreenWidth = 0; | 750 FX_FLOAT fScreenWidth = 0; |
751 FX_FLOAT fScreenHeight = 0; | 751 FX_FLOAT fScreenHeight = 0; |
752 GetScreenSize(fScreenWidth, fScreenHeight); | 752 GetScreenSize(fScreenWidth, fScreenHeight); |
753 if (GetStylesEx() & FWL_STYLEEXT_MNU_Vert) { | 753 if (GetStylesEx() & FWL_STYLEEXT_MNU_Vert) { |
754 FX_BOOL bLeft = m_pProperties->m_rtWidget.left < 0; | 754 FX_BOOL bLeft = m_pProperties->m_rtWidget.left < 0; |
755 FX_FLOAT fRight = rtAnchor.right() + rtPopup.width; | 755 FX_FLOAT fRight = rtAnchor.right() + rtPopup.width; |
756 TransformTo(NULL, fx, fy); | 756 TransformTo(nullptr, fx, fy); |
757 if (fRight + fx > fScreenWidth || bLeft) { | 757 if (fRight + fx > fScreenWidth || bLeft) { |
758 rtPopup.Set(rtAnchor.left - rtPopup.width, rtAnchor.top, rtPopup.width, | 758 rtPopup.Set(rtAnchor.left - rtPopup.width, rtAnchor.top, rtPopup.width, |
759 rtPopup.height); | 759 rtPopup.height); |
760 } else { | 760 } else { |
761 rtPopup.Set(rtAnchor.right(), rtAnchor.top, rtPopup.width, | 761 rtPopup.Set(rtAnchor.right(), rtAnchor.top, rtPopup.width, |
762 rtPopup.height); | 762 rtPopup.height); |
763 } | 763 } |
764 } else { | 764 } else { |
765 FX_FLOAT fBottom = rtAnchor.bottom() + rtPopup.height; | 765 FX_FLOAT fBottom = rtAnchor.bottom() + rtPopup.height; |
766 TransformTo(NULL, fx, fy); | 766 TransformTo(nullptr, fx, fy); |
767 if (fBottom + fy > fScreenHeight) { | 767 if (fBottom + fy > fScreenHeight) { |
768 rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width, | 768 rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width, |
769 rtPopup.height); | 769 rtPopup.height); |
770 } else { | 770 } else { |
771 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, | 771 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, |
772 rtPopup.height); | 772 rtPopup.height); |
773 } | 773 } |
774 } | 774 } |
775 rtPopup.Offset(fx, fy); | 775 rtPopup.Offset(fx, fy); |
776 return TRUE; | 776 return TRUE; |
777 } | 777 } |
778 FX_BOOL CFWL_WidgetImp::GetPopupPosComboBox(FX_FLOAT fMinHeight, | 778 FX_BOOL CFWL_WidgetImp::GetPopupPosComboBox(FX_FLOAT fMinHeight, |
779 FX_FLOAT fMaxHeight, | 779 FX_FLOAT fMaxHeight, |
780 const CFX_RectF& rtAnchor, | 780 const CFX_RectF& rtAnchor, |
781 CFX_RectF& rtPopup) { | 781 CFX_RectF& rtPopup) { |
782 FX_FLOAT fx = 0; | 782 FX_FLOAT fx = 0; |
783 FX_FLOAT fy = 0; | 783 FX_FLOAT fy = 0; |
784 FX_FLOAT fScreenWidth = 0; | 784 FX_FLOAT fScreenWidth = 0; |
785 FX_FLOAT fScreenHeight = 0; | 785 FX_FLOAT fScreenHeight = 0; |
786 GetScreenSize(fScreenWidth, fScreenHeight); | 786 GetScreenSize(fScreenWidth, fScreenHeight); |
787 FX_FLOAT fPopHeight = rtPopup.height; | 787 FX_FLOAT fPopHeight = rtPopup.height; |
788 if (rtPopup.height > fMaxHeight) { | 788 if (rtPopup.height > fMaxHeight) { |
789 fPopHeight = fMaxHeight; | 789 fPopHeight = fMaxHeight; |
790 } else if (rtPopup.height < fMinHeight) { | 790 } else if (rtPopup.height < fMinHeight) { |
791 fPopHeight = fMinHeight; | 791 fPopHeight = fMinHeight; |
792 } | 792 } |
793 FX_FLOAT fWidth = std::max(rtAnchor.width, rtPopup.width); | 793 FX_FLOAT fWidth = std::max(rtAnchor.width, rtPopup.width); |
794 FX_FLOAT fBottom = rtAnchor.bottom() + fPopHeight; | 794 FX_FLOAT fBottom = rtAnchor.bottom() + fPopHeight; |
795 TransformTo(NULL, fx, fy); | 795 TransformTo(nullptr, fx, fy); |
796 if (fBottom + fy > fScreenHeight) { | 796 if (fBottom + fy > fScreenHeight) { |
797 rtPopup.Set(rtAnchor.left, rtAnchor.top - fPopHeight, fWidth, fPopHeight); | 797 rtPopup.Set(rtAnchor.left, rtAnchor.top - fPopHeight, fWidth, fPopHeight); |
798 } else { | 798 } else { |
799 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), fWidth, fPopHeight); | 799 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), fWidth, fPopHeight); |
800 } | 800 } |
801 rtPopup.Offset(fx, fy); | 801 rtPopup.Offset(fx, fy); |
802 return TRUE; | 802 return TRUE; |
803 } | 803 } |
804 FX_BOOL CFWL_WidgetImp::GetPopupPosGeneral(FX_FLOAT fMinHeight, | 804 FX_BOOL CFWL_WidgetImp::GetPopupPosGeneral(FX_FLOAT fMinHeight, |
805 FX_FLOAT fMaxHeight, | 805 FX_FLOAT fMaxHeight, |
806 const CFX_RectF& rtAnchor, | 806 const CFX_RectF& rtAnchor, |
807 CFX_RectF& rtPopup) { | 807 CFX_RectF& rtPopup) { |
808 FX_FLOAT fx = 0; | 808 FX_FLOAT fx = 0; |
809 FX_FLOAT fy = 0; | 809 FX_FLOAT fy = 0; |
810 FX_FLOAT fScreenWidth = 0; | 810 FX_FLOAT fScreenWidth = 0; |
811 FX_FLOAT fScreenHeight = 0; | 811 FX_FLOAT fScreenHeight = 0; |
812 GetScreenSize(fScreenWidth, fScreenHeight); | 812 GetScreenSize(fScreenWidth, fScreenHeight); |
813 TransformTo(NULL, fx, fy); | 813 TransformTo(nullptr, fx, fy); |
814 if (rtAnchor.bottom() + fy > fScreenHeight) { | 814 if (rtAnchor.bottom() + fy > fScreenHeight) { |
815 rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width, | 815 rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width, |
816 rtPopup.height); | 816 rtPopup.height); |
817 } else { | 817 } else { |
818 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, | 818 rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, |
819 rtPopup.height); | 819 rtPopup.height); |
820 } | 820 } |
821 rtPopup.Offset(fx, fy); | 821 rtPopup.Offset(fx, fy); |
822 return TRUE; | 822 return TRUE; |
823 } | 823 } |
(...skipping 29 matching lines...) Expand all Loading... |
853 CFWL_EvtKey* pEvent = new CFWL_EvtKey; | 853 CFWL_EvtKey* pEvent = new CFWL_EvtKey; |
854 pEvent->m_pSrcTarget = m_pInterface; | 854 pEvent->m_pSrcTarget = m_pInterface; |
855 pEvent->m_dwCmd = pNote->m_dwCmd; | 855 pEvent->m_dwCmd = pNote->m_dwCmd; |
856 pEvent->m_dwKeyCode = pNote->m_dwKeyCode; | 856 pEvent->m_dwKeyCode = pNote->m_dwKeyCode; |
857 pEvent->m_dwFlags = pNote->m_dwFlags; | 857 pEvent->m_dwFlags = pNote->m_dwFlags; |
858 DispatchEvent(pEvent); | 858 DispatchEvent(pEvent); |
859 pEvent->Release(); | 859 pEvent->Release(); |
860 } | 860 } |
861 void CFWL_WidgetImp::DispatchEvent(CFWL_Event* pEvent) { | 861 void CFWL_WidgetImp::DispatchEvent(CFWL_Event* pEvent) { |
862 if (m_pOuter) { | 862 if (m_pOuter) { |
863 IFWL_WidgetDelegate* pDelegate = m_pOuter->SetDelegate(NULL); | 863 IFWL_WidgetDelegate* pDelegate = m_pOuter->SetDelegate(nullptr); |
864 pDelegate->OnProcessEvent(pEvent); | 864 pDelegate->OnProcessEvent(pEvent); |
865 return; | 865 return; |
866 } | 866 } |
867 IFWL_App* pApp = GetOwnerApp(); | 867 IFWL_App* pApp = GetOwnerApp(); |
868 if (!pApp) | 868 if (!pApp) |
869 return; | 869 return; |
870 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); | 870 CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); |
871 if (!pNoteDriver) | 871 if (!pNoteDriver) |
872 return; | 872 return; |
873 pNoteDriver->SendEvent(pEvent); | 873 pNoteDriver->SendEvent(pEvent); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 } | 1043 } |
1044 } | 1044 } |
1045 | 1045 |
1046 void CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {} | 1046 void CFWL_WidgetImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {} |
1047 | 1047 |
1048 void CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 1048 void CFWL_WidgetImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
1049 const CFX_Matrix* pMatrix) { | 1049 const CFX_Matrix* pMatrix) { |
1050 CFWL_EvtDraw evt; | 1050 CFWL_EvtDraw evt; |
1051 evt.m_pGraphics = pGraphics; | 1051 evt.m_pGraphics = pGraphics; |
1052 } | 1052 } |
OLD | NEW |