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/ifwl_form.h" | 7 #include "xfa/fwl/core/ifwl_form.h" |
8 | 8 |
9 #include "third_party/base/ptr_util.h" | 9 #include "third_party/base/ptr_util.h" |
10 #include "xfa/fde/tto/fde_textout.h" | 10 #include "xfa/fde/tto/fde_textout.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 m_pSmallIcon(nullptr), | 61 m_pSmallIcon(nullptr), |
62 m_bMouseIn(FALSE) { | 62 m_bMouseIn(FALSE) { |
63 m_rtRelative.Reset(); | 63 m_rtRelative.Reset(); |
64 m_rtCaption.Reset(); | 64 m_rtCaption.Reset(); |
65 m_rtRestore.Reset(); | 65 m_rtRestore.Reset(); |
66 m_rtCaptionText.Reset(); | 66 m_rtCaptionText.Reset(); |
67 m_rtIcon.Reset(); | 67 m_rtIcon.Reset(); |
68 | 68 |
69 RegisterForm(); | 69 RegisterForm(); |
70 RegisterEventTarget(); | 70 RegisterEventTarget(); |
71 SetDelegate(pdfium::MakeUnique<CFWL_FormImpDelegate>(this)); | |
72 } | 71 } |
73 | 72 |
74 IFWL_Form::~IFWL_Form() { | 73 IFWL_Form::~IFWL_Form() { |
75 UnregisterEventTarget(); | 74 UnregisterEventTarget(); |
76 UnRegisterForm(); | 75 UnRegisterForm(); |
77 RemoveSysButtons(); | 76 RemoveSysButtons(); |
78 } | 77 } |
79 | 78 |
80 FWL_Type IFWL_Form::GetClassID() const { | 79 FWL_Type IFWL_Form::GetClassID() const { |
81 return FWL_Type::Form; | 80 return FWL_Type::Form; |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 if (fTemp < fLimitMin && fHeight > fLimitMin) { | 762 if (fTemp < fLimitMin && fHeight > fLimitMin) { |
764 fTop += bTop ? (fHeight - fLimitMin) : 0; | 763 fTop += bTop ? (fHeight - fLimitMin) : 0; |
765 fHeight = fLimitMin; | 764 fHeight = fLimitMin; |
766 } else if (fTemp > fLimitMax && fHeight < fLimitMax) { | 765 } else if (fTemp > fLimitMax && fHeight < fLimitMax) { |
767 fTop -= bTop ? (fLimitMax - fHeight) : 0; | 766 fTop -= bTop ? (fLimitMax - fHeight) : 0; |
768 fHeight = fLimitMax; | 767 fHeight = fLimitMax; |
769 } | 768 } |
770 } | 769 } |
771 } | 770 } |
772 | 771 |
773 CFWL_FormImpDelegate::CFWL_FormImpDelegate(IFWL_Form* pOwner) | |
774 : m_pOwner(pOwner) {} | |
775 | |
776 #ifdef FWL_UseMacSystemBorder | 772 #ifdef FWL_UseMacSystemBorder |
777 void CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | 773 void IFWL_Form::OnProcessMessage(CFWL_Message* pMessage) { |
778 if (!pMessage) | 774 if (!pMessage) |
779 return; | 775 return; |
780 | 776 |
781 switch (pMessage->GetClassID()) { | 777 switch (pMessage->GetClassID()) { |
782 case CFWL_MessageType::Activate: { | 778 case CFWL_MessageType::Activate: { |
783 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated; | 779 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated; |
784 m_pOwner->Repaint(&m_pOwner->m_rtRelative); | 780 Repaint(&m_rtRelative); |
785 break; | 781 break; |
786 } | 782 } |
787 case CFWL_MessageType::Deactivate: { | 783 case CFWL_MessageType::Deactivate: { |
788 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated; | 784 m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated; |
789 m_pOwner->Repaint(&m_pOwner->m_rtRelative); | 785 Repaint(&m_rtRelative); |
790 break; | 786 break; |
791 } | 787 } |
792 default: | 788 default: |
793 break; | 789 break; |
794 } | 790 } |
795 } | 791 } |
796 #else | 792 #else |
797 void CFWL_FormImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | 793 void IFWL_Form::OnProcessMessage(CFWL_Message* pMessage) { |
798 if (!pMessage) | 794 if (!pMessage) |
799 return; | 795 return; |
800 | 796 |
801 switch (pMessage->GetClassID()) { | 797 switch (pMessage->GetClassID()) { |
802 case CFWL_MessageType::Activate: { | 798 case CFWL_MessageType::Activate: { |
803 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated; | 799 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated; |
804 const IFWL_App* pApp = m_pOwner->GetOwnerApp(); | 800 const IFWL_App* pApp = GetOwnerApp(); |
805 CFWL_NoteDriver* pDriver = | 801 CFWL_NoteDriver* pDriver = |
806 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 802 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
807 IFWL_Widget* pSubFocus = m_pOwner->GetSubFocus(); | 803 IFWL_Widget* pSubFocus = GetSubFocus(); |
808 if (pSubFocus && pSubFocus != pDriver->GetFocus()) | 804 if (pSubFocus && pSubFocus != pDriver->GetFocus()) |
809 pDriver->SetFocus(pSubFocus); | 805 pDriver->SetFocus(pSubFocus); |
810 | 806 |
811 m_pOwner->Repaint(&m_pOwner->m_rtRelative); | 807 Repaint(&m_rtRelative); |
812 break; | 808 break; |
813 } | 809 } |
814 case CFWL_MessageType::Deactivate: { | 810 case CFWL_MessageType::Deactivate: { |
815 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated; | 811 m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated; |
816 const IFWL_App* pApp = m_pOwner->GetOwnerApp(); | 812 const IFWL_App* pApp = GetOwnerApp(); |
817 CFWL_NoteDriver* pDriver = | 813 CFWL_NoteDriver* pDriver = |
818 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 814 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
819 IFWL_Widget* pSubFocus = m_pOwner->GetSubFocus(); | 815 IFWL_Widget* pSubFocus = GetSubFocus(); |
820 if (pSubFocus) { | 816 if (pSubFocus) { |
821 if (pSubFocus == pDriver->GetFocus()) { | 817 if (pSubFocus == pDriver->GetFocus()) { |
822 pDriver->SetFocus(nullptr); | 818 pDriver->SetFocus(nullptr); |
823 } else if (pSubFocus->GetStates() & FWL_WGTSTATE_Focused) { | 819 } else if (pSubFocus->GetStates() & FWL_WGTSTATE_Focused) { |
824 if (IFWL_WidgetDelegate* pDelegate = | 820 if (IFWL_WidgetDelegate* pDelegate = pSubFocus->GetDelegate()) { |
825 pSubFocus->GetCurrentDelegate()) { | |
826 CFWL_MsgKillFocus ms; | 821 CFWL_MsgKillFocus ms; |
827 pDelegate->OnProcessMessage(&ms); | 822 pDelegate->OnProcessMessage(&ms); |
828 } | 823 } |
829 } | 824 } |
830 } | 825 } |
831 m_pOwner->Repaint(&m_pOwner->m_rtRelative); | 826 Repaint(&m_rtRelative); |
832 break; | 827 break; |
833 } | 828 } |
834 case CFWL_MessageType::Mouse: { | 829 case CFWL_MessageType::Mouse: { |
835 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 830 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
836 switch (pMsg->m_dwCmd) { | 831 switch (pMsg->m_dwCmd) { |
837 case FWL_MouseCommand::LeftButtonDown: { | 832 case FWL_MouseCommand::LeftButtonDown: |
838 OnLButtonDown(pMsg); | 833 OnLButtonDown(pMsg); |
839 break; | 834 break; |
840 } | 835 case FWL_MouseCommand::LeftButtonUp: |
841 case FWL_MouseCommand::LeftButtonUp: { | |
842 OnLButtonUp(pMsg); | 836 OnLButtonUp(pMsg); |
843 break; | 837 break; |
844 } | 838 case FWL_MouseCommand::Move: |
845 case FWL_MouseCommand::Move: { | |
846 OnMouseMove(pMsg); | 839 OnMouseMove(pMsg); |
847 break; | 840 break; |
848 } | 841 case FWL_MouseCommand::Hover: |
849 case FWL_MouseCommand::Hover: { | |
850 OnMouseHover(pMsg); | 842 OnMouseHover(pMsg); |
851 break; | 843 break; |
852 } | 844 case FWL_MouseCommand::Leave: |
853 case FWL_MouseCommand::Leave: { | |
854 OnMouseLeave(pMsg); | 845 OnMouseLeave(pMsg); |
855 break; | 846 break; |
856 } | 847 case FWL_MouseCommand::LeftButtonDblClk: |
857 case FWL_MouseCommand::LeftButtonDblClk: { | |
858 OnLButtonDblClk(pMsg); | 848 OnLButtonDblClk(pMsg); |
859 break; | 849 break; |
860 } | |
861 default: | 850 default: |
862 break; | 851 break; |
863 } | 852 } |
864 break; | 853 break; |
865 } | 854 } |
866 case CFWL_MessageType::Size: { | 855 case CFWL_MessageType::Size: { |
867 CFWL_WidgetMgr* pWidgetMgr = m_pOwner->GetOwnerApp()->GetWidgetMgr(); | 856 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); |
868 if (!pWidgetMgr) | 857 if (!pWidgetMgr) |
869 return; | 858 return; |
870 | 859 |
871 pWidgetMgr->AddRedrawCounts(m_pOwner); | 860 pWidgetMgr->AddRedrawCounts(this); |
872 if (!m_pOwner->m_bSetMaximize) | 861 if (!m_bSetMaximize) |
873 break; | 862 break; |
874 | 863 |
875 m_pOwner->m_bSetMaximize = FALSE; | 864 m_bSetMaximize = FALSE; |
876 CFWL_MsgSize* pMsg = static_cast<CFWL_MsgSize*>(pMessage); | 865 CFWL_MsgSize* pMsg = static_cast<CFWL_MsgSize*>(pMessage); |
877 m_pOwner->m_pProperties->m_rtWidget.left = 0; | 866 m_pProperties->m_rtWidget.left = 0; |
878 m_pOwner->m_pProperties->m_rtWidget.top = 0; | 867 m_pProperties->m_rtWidget.top = 0; |
879 m_pOwner->m_pProperties->m_rtWidget.width = (FX_FLOAT)pMsg->m_iWidth; | 868 m_pProperties->m_rtWidget.width = (FX_FLOAT)pMsg->m_iWidth; |
880 m_pOwner->m_pProperties->m_rtWidget.height = (FX_FLOAT)pMsg->m_iHeight; | 869 m_pProperties->m_rtWidget.height = (FX_FLOAT)pMsg->m_iHeight; |
881 m_pOwner->Update(); | 870 Update(); |
882 break; | 871 break; |
883 } | 872 } |
884 case CFWL_MessageType::WindowMove: { | 873 case CFWL_MessageType::WindowMove: |
885 OnWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage)); | 874 OnWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage)); |
886 break; | 875 break; |
887 } | 876 case CFWL_MessageType::Close: |
888 case CFWL_MessageType::Close: { | |
889 OnClose(static_cast<CFWL_MsgClose*>(pMessage)); | 877 OnClose(static_cast<CFWL_MsgClose*>(pMessage)); |
890 break; | 878 break; |
891 } | 879 default: |
892 default: { break; } | 880 break; |
893 } | 881 } |
894 } | 882 } |
895 #endif // FWL_UseMacSystemBorder | 883 #endif // FWL_UseMacSystemBorder |
896 | 884 |
897 void CFWL_FormImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {} | 885 void IFWL_Form::OnDrawWidget(CFX_Graphics* pGraphics, |
898 | 886 const CFX_Matrix* pMatrix) { |
899 void CFWL_FormImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 887 DrawWidget(pGraphics, pMatrix); |
900 const CFX_Matrix* pMatrix) { | |
901 m_pOwner->DrawWidget(pGraphics, pMatrix); | |
902 } | 888 } |
903 | 889 |
904 void CFWL_FormImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { | 890 void IFWL_Form::OnLButtonDown(CFWL_MsgMouse* pMsg) { |
905 m_pOwner->SetGrab(TRUE); | 891 SetGrab(TRUE); |
906 m_pOwner->m_bLButtonDown = TRUE; | 892 m_bLButtonDown = TRUE; |
907 m_pOwner->m_eResizeType = FORM_RESIZETYPE_None; | 893 m_eResizeType = FORM_RESIZETYPE_None; |
908 CFWL_SysBtn* pPressBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); | 894 CFWL_SysBtn* pPressBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); |
909 m_pOwner->m_iCaptureBtn = m_pOwner->GetSysBtnIndex(pPressBtn); | 895 m_iCaptureBtn = GetSysBtnIndex(pPressBtn); |
910 CFX_RectF rtCap; | 896 CFX_RectF rtCap; |
911 rtCap.Set(m_pOwner->m_rtCaption.left + m_pOwner->m_fCYBorder, | 897 rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder, |
912 m_pOwner->m_rtCaption.top + m_pOwner->m_fCXBorder, | 898 m_rtCaption.width - kSystemButtonSize * m_iSysBox - 2 * m_fCYBorder, |
913 m_pOwner->m_rtCaption.width - | 899 m_rtCaption.height - m_fCXBorder); |
914 kSystemButtonSize * m_pOwner->m_iSysBox - | 900 |
915 2 * m_pOwner->m_fCYBorder, | |
916 m_pOwner->m_rtCaption.height - m_pOwner->m_fCXBorder); | |
917 if (pPressBtn) { | 901 if (pPressBtn) { |
918 pPressBtn->SetPressed(); | 902 pPressBtn->SetPressed(); |
919 m_pOwner->Repaint(&pPressBtn->m_rtBtn); | 903 Repaint(&pPressBtn->m_rtBtn); |
920 } else if (rtCap.Contains(pMsg->m_fx, pMsg->m_fy)) { | 904 } else if (rtCap.Contains(pMsg->m_fx, pMsg->m_fy)) { |
921 m_pOwner->m_eResizeType = FORM_RESIZETYPE_Cap; | 905 m_eResizeType = FORM_RESIZETYPE_Cap; |
922 } else if ((m_pOwner->m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && | 906 } else if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && |
923 (m_pOwner->m_pProperties->m_dwStyleExes & | 907 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && |
924 FWL_STYLEEXT_FRM_Resize) && | 908 !m_bMaximized) { |
925 !m_pOwner->m_bMaximized) { | 909 SetCursor(pMsg->m_fx, pMsg->m_fy); |
926 m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy); | |
927 } | 910 } |
928 m_pOwner->m_InfoStart.m_ptStart = CFX_PointF(pMsg->m_fx, pMsg->m_fy); | 911 m_InfoStart.m_ptStart = CFX_PointF(pMsg->m_fx, pMsg->m_fy); |
929 m_pOwner->m_InfoStart.m_szStart = | 912 m_InfoStart.m_szStart = CFX_SizeF(m_pProperties->m_rtWidget.width, |
930 CFX_SizeF(m_pOwner->m_pProperties->m_rtWidget.width, | 913 m_pProperties->m_rtWidget.height); |
931 m_pOwner->m_pProperties->m_rtWidget.height); | |
932 } | 914 } |
933 void CFWL_FormImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { | 915 |
934 m_pOwner->SetGrab(FALSE); | 916 void IFWL_Form::OnLButtonUp(CFWL_MsgMouse* pMsg) { |
935 m_pOwner->m_bLButtonDown = FALSE; | 917 SetGrab(FALSE); |
936 CFWL_SysBtn* pPointBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); | 918 m_bLButtonDown = FALSE; |
937 CFWL_SysBtn* pPressedBtn = | 919 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); |
938 m_pOwner->GetSysBtnByIndex(m_pOwner->m_iCaptureBtn); | 920 CFWL_SysBtn* pPressedBtn = GetSysBtnByIndex(m_iCaptureBtn); |
939 if (!pPressedBtn || pPointBtn != pPressedBtn) { | 921 if (!pPressedBtn || pPointBtn != pPressedBtn) |
940 return; | 922 return; |
941 } | 923 if (pPressedBtn == GetSysBtnByState(FWL_SYSBUTTONSTATE_Pressed)) |
942 if (pPressedBtn == m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Pressed)) { | |
943 pPressedBtn->SetNormal(); | 924 pPressedBtn->SetNormal(); |
944 } | 925 if (pPressedBtn == m_pMaxBox) { |
945 if (pPressedBtn == m_pOwner->m_pMaxBox) { | 926 if (m_bMaximized) { |
946 if (m_pOwner->m_bMaximized) { | 927 SetWidgetRect(m_rtRestore); |
947 m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore); | 928 Update(); |
948 m_pOwner->Update(); | 929 Repaint(); |
949 m_pOwner->Repaint(); | |
950 } else { | 930 } else { |
951 m_pOwner->SetWorkAreaRect(); | 931 SetWorkAreaRect(); |
952 m_pOwner->Update(); | 932 Update(); |
953 } | 933 } |
954 m_pOwner->m_bMaximized = !m_pOwner->m_bMaximized; | 934 m_bMaximized = !m_bMaximized; |
955 } else if (pPressedBtn != m_pOwner->m_pMinBox) { | 935 } else if (pPressedBtn != m_pMinBox) { |
956 CFWL_EvtClose eClose; | 936 CFWL_EvtClose eClose; |
957 eClose.m_pSrcTarget = m_pOwner; | 937 eClose.m_pSrcTarget = this; |
958 m_pOwner->DispatchEvent(&eClose); | 938 DispatchEvent(&eClose); |
959 } | 939 } |
960 } | 940 } |
961 void CFWL_FormImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { | 941 |
962 if (m_pOwner->m_bLButtonDown) { | 942 void IFWL_Form::OnMouseMove(CFWL_MsgMouse* pMsg) { |
| 943 if (m_bLButtonDown) |
963 return; | 944 return; |
964 } | 945 |
965 if ((m_pOwner->m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && | 946 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && |
966 (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && | 947 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && |
967 !m_pOwner->m_bMaximized) { | 948 !m_bMaximized) { |
968 m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy); | 949 SetCursor(pMsg->m_fx, pMsg->m_fy); |
969 } | 950 } |
970 CFX_RectF rtInvalidate; | 951 CFX_RectF rtInvalidate; |
971 rtInvalidate.Reset(); | 952 rtInvalidate.Reset(); |
972 CFWL_SysBtn* pPointBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); | 953 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); |
973 CFWL_SysBtn* pOldHover = m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); | 954 CFWL_SysBtn* pOldHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); |
974 #if (_FX_OS_ == _FX_MACOSX_) | 955 #if (_FX_OS_ == _FX_MACOSX_) |
975 { | 956 { |
976 if (pOldHover && pPointBtn != pOldHover) { | 957 if (pOldHover && pPointBtn != pOldHover) |
977 pOldHover->SetNormal(); | 958 pOldHover->SetNormal(); |
| 959 if (pPointBtn && pPointBtn != pOldHover) |
| 960 pPointBtn->SetHover(); |
| 961 if (m_pCloseBox) |
| 962 rtInvalidate = m_pCloseBox->m_rtBtn; |
| 963 if (m_pMaxBox) { |
| 964 if (rtInvalidate.IsEmpty()) |
| 965 rtInvalidate = m_pMaxBox->m_rtBtn; |
| 966 else |
| 967 rtInvalidate.Union(m_pMaxBox->m_rtBtn); |
978 } | 968 } |
979 if (pPointBtn && pPointBtn != pOldHover) { | 969 if (m_pMinBox) { |
980 pPointBtn->SetHover(); | 970 if (rtInvalidate.IsEmpty()) |
981 } | 971 rtInvalidate = m_pMinBox->m_rtBtn; |
982 if (m_pOwner->m_pCloseBox) { | 972 else |
983 rtInvalidate = m_pOwner->m_pCloseBox->m_rtBtn; | 973 rtInvalidate.Union(m_pMinBox->m_rtBtn); |
984 } | |
985 if (m_pOwner->m_pMaxBox) { | |
986 if (rtInvalidate.IsEmpty()) { | |
987 rtInvalidate = m_pOwner->m_pMaxBox->m_rtBtn; | |
988 } else { | |
989 rtInvalidate.Union(m_pOwner->m_pMaxBox->m_rtBtn); | |
990 } | |
991 } | |
992 if (m_pOwner->m_pMinBox) { | |
993 if (rtInvalidate.IsEmpty()) { | |
994 rtInvalidate = m_pOwner->m_pMinBox->m_rtBtn; | |
995 } else { | |
996 rtInvalidate.Union(m_pOwner->m_pMinBox->m_rtBtn); | |
997 } | |
998 } | 974 } |
999 if (!rtInvalidate.IsEmpty() && | 975 if (!rtInvalidate.IsEmpty() && |
1000 rtInvalidate.Contains(pMsg->m_fx, pMsg->m_fy)) { | 976 rtInvalidate.Contains(pMsg->m_fx, pMsg->m_fy)) { |
1001 m_pOwner->m_bMouseIn = TRUE; | 977 m_bMouseIn = TRUE; |
1002 } | 978 } |
1003 } | 979 } |
1004 #else | 980 #else |
1005 { | 981 { |
1006 if (pOldHover && pPointBtn != pOldHover) { | 982 if (pOldHover && pPointBtn != pOldHover) { |
1007 pOldHover->SetNormal(); | 983 pOldHover->SetNormal(); |
1008 rtInvalidate = pOldHover->m_rtBtn; | 984 rtInvalidate = pOldHover->m_rtBtn; |
1009 } | 985 } |
1010 if (pPointBtn && pPointBtn != pOldHover) { | 986 if (pPointBtn && pPointBtn != pOldHover) { |
1011 pPointBtn->SetHover(); | 987 pPointBtn->SetHover(); |
1012 if (rtInvalidate.IsEmpty()) { | 988 if (rtInvalidate.IsEmpty()) |
1013 rtInvalidate = pPointBtn->m_rtBtn; | 989 rtInvalidate = pPointBtn->m_rtBtn; |
1014 } else { | 990 else |
1015 rtInvalidate.Union(pPointBtn->m_rtBtn); | 991 rtInvalidate.Union(pPointBtn->m_rtBtn); |
1016 } | |
1017 } | 992 } |
1018 } | 993 } |
1019 #endif | 994 #endif |
1020 if (!rtInvalidate.IsEmpty()) { | 995 if (!rtInvalidate.IsEmpty()) |
1021 m_pOwner->Repaint(&rtInvalidate); | 996 Repaint(&rtInvalidate); |
| 997 } |
| 998 |
| 999 void IFWL_Form::OnMouseHover(CFWL_MsgMouse* pMsg) { |
| 1000 SetCursor(pMsg->m_fx, pMsg->m_fy); |
| 1001 } |
| 1002 |
| 1003 void IFWL_Form::OnMouseLeave(CFWL_MsgMouse* pMsg) { |
| 1004 CFWL_SysBtn* pHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); |
| 1005 if (pHover) { |
| 1006 pHover->SetNormal(); |
| 1007 Repaint(&pHover->m_rtBtn); |
| 1008 } |
| 1009 if (pMsg->m_dwCmd == FWL_MouseCommand::Leave && !m_bLButtonDown) |
| 1010 SetCursor(pMsg->m_fx, pMsg->m_fy); |
| 1011 } |
| 1012 |
| 1013 void IFWL_Form::OnLButtonDblClk(CFWL_MsgMouse* pMsg) { |
| 1014 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && |
| 1015 HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WidgetHit::Titlebar) { |
| 1016 if (m_bMaximized) |
| 1017 SetWidgetRect(m_rtRestore); |
| 1018 else |
| 1019 SetWorkAreaRect(); |
| 1020 |
| 1021 Update(); |
| 1022 m_bMaximized = !m_bMaximized; |
1022 } | 1023 } |
1023 } | 1024 } |
1024 void CFWL_FormImpDelegate::OnMouseHover(CFWL_MsgMouse* pMsg) { | 1025 |
1025 m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy); | 1026 void IFWL_Form::OnWindowMove(CFWL_MsgWindowMove* pMsg) { |
| 1027 m_pProperties->m_rtWidget.left = pMsg->m_fx; |
| 1028 m_pProperties->m_rtWidget.top = pMsg->m_fy; |
1026 } | 1029 } |
1027 void CFWL_FormImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { | 1030 |
1028 CFWL_SysBtn* pHover = m_pOwner->GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); | 1031 void IFWL_Form::OnClose(CFWL_MsgClose* pMsg) { |
1029 if (pHover) { | |
1030 pHover->SetNormal(); | |
1031 m_pOwner->Repaint(&pHover->m_rtBtn); | |
1032 } | |
1033 if (pMsg->m_dwCmd == FWL_MouseCommand::Leave && !m_pOwner->m_bLButtonDown) { | |
1034 m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy); | |
1035 } | |
1036 } | |
1037 void CFWL_FormImpDelegate::OnLButtonDblClk(CFWL_MsgMouse* pMsg) { | |
1038 if ((m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && | |
1039 m_pOwner->HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WidgetHit::Titlebar) { | |
1040 if (m_pOwner->m_bMaximized) { | |
1041 m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore); | |
1042 } else { | |
1043 m_pOwner->SetWorkAreaRect(); | |
1044 } | |
1045 m_pOwner->Update(); | |
1046 m_pOwner->m_bMaximized = !m_pOwner->m_bMaximized; | |
1047 } | |
1048 } | |
1049 void CFWL_FormImpDelegate::OnWindowMove(CFWL_MsgWindowMove* pMsg) { | |
1050 m_pOwner->m_pProperties->m_rtWidget.left = pMsg->m_fx; | |
1051 m_pOwner->m_pProperties->m_rtWidget.top = pMsg->m_fy; | |
1052 } | |
1053 void CFWL_FormImpDelegate::OnClose(CFWL_MsgClose* pMsg) { | |
1054 CFWL_EvtClose eClose; | 1032 CFWL_EvtClose eClose; |
1055 eClose.m_pSrcTarget = m_pOwner; | 1033 eClose.m_pSrcTarget = this; |
1056 m_pOwner->DispatchEvent(&eClose); | 1034 DispatchEvent(&eClose); |
1057 } | 1035 } |
1058 | 1036 |
1059 CFWL_SysBtn::CFWL_SysBtn() { | 1037 CFWL_SysBtn::CFWL_SysBtn() { |
1060 m_rtBtn.Set(0, 0, 0, 0); | 1038 m_rtBtn.Set(0, 0, 0, 0); |
1061 m_dwState = 0; | 1039 m_dwState = 0; |
1062 } | 1040 } |
1063 | 1041 |
1064 bool CFWL_SysBtn::IsDisabled() const { | 1042 bool CFWL_SysBtn::IsDisabled() const { |
1065 return !!(m_dwState & FWL_SYSBUTTONSTATE_Disabled); | 1043 return !!(m_dwState & FWL_SYSBUTTONSTATE_Disabled); |
1066 } | 1044 } |
(...skipping 19 matching lines...) Expand all Loading... |
1086 | 1064 |
1087 uint32_t CFWL_SysBtn::GetPartState() const { | 1065 uint32_t CFWL_SysBtn::GetPartState() const { |
1088 if (IsDisabled()) | 1066 if (IsDisabled()) |
1089 return CFWL_PartState_Disabled; | 1067 return CFWL_PartState_Disabled; |
1090 if (m_dwState & FWL_SYSBUTTONSTATE_Pressed) | 1068 if (m_dwState & FWL_SYSBUTTONSTATE_Pressed) |
1091 return CFWL_PartState_Pressed; | 1069 return CFWL_PartState_Pressed; |
1092 if (m_dwState & FWL_SYSBUTTONSTATE_Hover) | 1070 if (m_dwState & FWL_SYSBUTTONSTATE_Hover) |
1093 return CFWL_PartState_Hovered; | 1071 return CFWL_PartState_Hovered; |
1094 return CFWL_PartState_Normal; | 1072 return CFWL_PartState_Normal; |
1095 } | 1073 } |
OLD | NEW |