| 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_formimp.h" | 7 #include "xfa/fwl/core/fwl_formimp.h" |
| 8 | 8 |
| 9 #include "xfa/fde/tto/fde_textout.h" | 9 #include "xfa/fde/tto/fde_textout.h" |
| 10 #include "xfa/fwl/basewidget/fwl_formproxyimp.h" | 10 #include "xfa/fwl/basewidget/fwl_formproxyimp.h" |
| 11 #include "xfa/fwl/core/cfwl_message.h" | 11 #include "xfa/fwl/core/cfwl_message.h" |
| 12 #include "xfa/fwl/core/cfwl_themebackground.h" | 12 #include "xfa/fwl/core/cfwl_themebackground.h" |
| 13 #include "xfa/fwl/core/cfwl_themepart.h" | 13 #include "xfa/fwl/core/cfwl_themepart.h" |
| 14 #include "xfa/fwl/core/cfwl_themetext.h" | 14 #include "xfa/fwl/core/cfwl_themetext.h" |
| 15 #include "xfa/fwl/core/fwl_appimp.h" | 15 #include "xfa/fwl/core/fwl_appimp.h" |
| 16 #include "xfa/fwl/core/fwl_noteimp.h" | 16 #include "xfa/fwl/core/fwl_noteimp.h" |
| 17 #include "xfa/fwl/core/fwl_widgetimp.h" | 17 #include "xfa/fwl/core/fwl_widgetimp.h" |
| 18 #include "xfa/fwl/core/fwl_widgetmgrimp.h" | 18 #include "xfa/fwl/core/fwl_widgetmgrimp.h" |
| 19 #include "xfa/fwl/core/ifwl_adapterwidgetmgr.h" | |
| 20 #include "xfa/fwl/core/ifwl_app.h" | 19 #include "xfa/fwl/core/ifwl_app.h" |
| 21 #include "xfa/fwl/core/ifwl_themeprovider.h" | 20 #include "xfa/fwl/core/ifwl_themeprovider.h" |
| 22 #include "xfa/fwl/theme/cfwl_widgettp.h" | 21 #include "xfa/fwl/theme/cfwl_widgettp.h" |
| 23 | 22 |
| 24 namespace { | 23 namespace { |
| 25 | 24 |
| 26 const int kSystemButtonSize = 21; | 25 const int kSystemButtonSize = 21; |
| 27 const int kSystemButtonMargin = 5; | 26 const int kSystemButtonMargin = 5; |
| 28 const int kSystemButtonSpan = 2; | 27 const int kSystemButtonSpan = 2; |
| 29 | 28 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) == 0) { | 147 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) == 0) { |
| 149 rect = m_pProperties->m_rtWidget; | 148 rect = m_pProperties->m_rtWidget; |
| 150 rect.Offset(-rect.left, -rect.top); | 149 rect.Offset(-rect.left, -rect.top); |
| 151 return FWL_ERR_Succeeded; | 150 return FWL_ERR_Succeeded; |
| 152 } | 151 } |
| 153 #ifdef FWL_UseMacSystemBorder | 152 #ifdef FWL_UseMacSystemBorder |
| 154 rect = m_rtRelative; | 153 rect = m_rtRelative; |
| 155 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); | 154 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); |
| 156 if (!pWidgetMgr) | 155 if (!pWidgetMgr) |
| 157 return FWL_ERR_Indefinite; | 156 return FWL_ERR_Indefinite; |
| 158 IFWL_AdapterWidgetMgr* adapterWidgetMgr = pWidgetMgr->GetAdapterWidgetMgr(); | 157 |
| 159 FX_FLOAT l, t, r, b; | 158 rect.left = 0; |
| 160 l = t = r = b = 0; | 159 rect.top = 0; |
| 161 adapterWidgetMgr->GetSystemBorder(l, t, r, b); | |
| 162 rect.Deflate(l, t, r, b); | |
| 163 rect.left = rect.top = 0; | |
| 164 return FWL_ERR_Succeeded; | 160 return FWL_ERR_Succeeded; |
| 165 #else | 161 #else |
| 166 FX_FLOAT x = 0; | 162 FX_FLOAT x = 0; |
| 167 FX_FLOAT y = 0; | 163 FX_FLOAT y = 0; |
| 168 FX_FLOAT t = 0; | 164 FX_FLOAT t = 0; |
| 169 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 165 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
| 170 if (pTheme) { | 166 if (pTheme) { |
| 171 CFWL_ThemePart part; | 167 CFWL_ThemePart part; |
| 172 part.m_pWidget = m_pInterface; | 168 part.m_pWidget = m_pInterface; |
| 173 x = *static_cast<FX_FLOAT*>( | 169 x = *static_cast<FX_FLOAT*>( |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 IFWL_App* pApp = FWL_GetApp(); | 447 IFWL_App* pApp = FWL_GetApp(); |
| 452 if (!pApp) | 448 if (!pApp) |
| 453 return; | 449 return; |
| 454 CFWL_WidgetMgr* pWidgetMgr = | 450 CFWL_WidgetMgr* pWidgetMgr = |
| 455 static_cast<CFWL_WidgetMgr*>(pApp->GetWidgetMgr()); | 451 static_cast<CFWL_WidgetMgr*>(pApp->GetWidgetMgr()); |
| 456 if (!pWidgetMgr) | 452 if (!pWidgetMgr) |
| 457 return; | 453 return; |
| 458 IFWL_Widget* pChild = | 454 IFWL_Widget* pChild = |
| 459 pWidgetMgr->GetWidget(pParent, FWL_WGTRELATION_FirstChild); | 455 pWidgetMgr->GetWidget(pParent, FWL_WGTRELATION_FirstChild); |
| 460 while (pChild) { | 456 while (pChild) { |
| 461 pWidgetMgr->ShowWidget_Native(pChild); | |
| 462 ShowChildWidget(pChild); | 457 ShowChildWidget(pChild); |
| 463 pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling); | 458 pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling); |
| 464 } | 459 } |
| 465 } | 460 } |
| 466 | 461 |
| 467 void CFWL_FormImp::RemoveSysButtons() { | 462 void CFWL_FormImp::RemoveSysButtons() { |
| 468 m_rtCaption.Reset(); | 463 m_rtCaption.Reset(); |
| 469 delete m_pCloseBox; | 464 delete m_pCloseBox; |
| 470 m_pCloseBox = nullptr; | 465 m_pCloseBox = nullptr; |
| 471 delete m_pMinBox; | 466 delete m_pMinBox; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 FX_FLOAT fCY = GetBorderSize(FALSE); | 613 FX_FLOAT fCY = GetBorderSize(FALSE); |
| 619 rtEdge.Deflate(fCX, m_rtCaption.Height(), fCX, fCY); | 614 rtEdge.Deflate(fCX, m_rtCaption.Height(), fCX, fCY); |
| 620 } | 615 } |
| 621 } | 616 } |
| 622 void CFWL_FormImp::SetWorkAreaRect() { | 617 void CFWL_FormImp::SetWorkAreaRect() { |
| 623 m_rtRestore = m_pProperties->m_rtWidget; | 618 m_rtRestore = m_pProperties->m_rtWidget; |
| 624 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); | 619 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); |
| 625 if (!pWidgetMgr) | 620 if (!pWidgetMgr) |
| 626 return; | 621 return; |
| 627 m_bSetMaximize = TRUE; | 622 m_bSetMaximize = TRUE; |
| 628 pWidgetMgr->SetMaximize_Native(m_pInterface); | |
| 629 Repaint(&m_rtRelative); | 623 Repaint(&m_rtRelative); |
| 630 } | 624 } |
| 631 void CFWL_FormImp::SetCursor(FX_FLOAT fx, FX_FLOAT fy) {} | 625 void CFWL_FormImp::SetCursor(FX_FLOAT fx, FX_FLOAT fy) {} |
| 632 void CFWL_FormImp::Layout() { | 626 void CFWL_FormImp::Layout() { |
| 633 GetRelativeRect(m_rtRelative); | 627 GetRelativeRect(m_rtRelative); |
| 634 #ifndef FWL_UseMacSystemBorder | 628 #ifndef FWL_UseMacSystemBorder |
| 635 ReSetSysBtn(); | 629 ReSetSysBtn(); |
| 636 #endif | 630 #endif |
| 637 } | 631 } |
| 638 void CFWL_FormImp::ReSetSysBtn() { | 632 void CFWL_FormImp::ReSetSysBtn() { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 return !!pData->GetIcon(m_pInterface, FALSE); | 765 return !!pData->GetIcon(m_pInterface, FALSE); |
| 772 } | 766 } |
| 773 void CFWL_FormImp::UpdateIcon() { | 767 void CFWL_FormImp::UpdateIcon() { |
| 774 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); | 768 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); |
| 775 if (!pWidgetMgr) | 769 if (!pWidgetMgr) |
| 776 return; | 770 return; |
| 777 IFWL_FormDP* pData = | 771 IFWL_FormDP* pData = |
| 778 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); | 772 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); |
| 779 CFX_DIBitmap* pBigIcon = pData->GetIcon(m_pInterface, TRUE); | 773 CFX_DIBitmap* pBigIcon = pData->GetIcon(m_pInterface, TRUE); |
| 780 CFX_DIBitmap* pSmallIcon = pData->GetIcon(m_pInterface, FALSE); | 774 CFX_DIBitmap* pSmallIcon = pData->GetIcon(m_pInterface, FALSE); |
| 781 if (pBigIcon && pBigIcon != m_pBigIcon) { | 775 if (pBigIcon) |
| 782 m_pBigIcon = pBigIcon; | 776 m_pBigIcon = pBigIcon; |
| 783 pWidgetMgr->SetWidgetIcon_Native(m_pInterface, m_pBigIcon, TRUE); | 777 if (pSmallIcon) |
| 784 } | |
| 785 if (pSmallIcon && pSmallIcon != m_pSmallIcon) { | |
| 786 m_pSmallIcon = pSmallIcon; | 778 m_pSmallIcon = pSmallIcon; |
| 787 pWidgetMgr->SetWidgetIcon_Native(m_pInterface, m_pBigIcon, FALSE); | |
| 788 } | |
| 789 } | 779 } |
| 790 void CFWL_FormImp::UpdateCaption() { | 780 void CFWL_FormImp::UpdateCaption() { |
| 791 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); | 781 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); |
| 792 if (!pWidgetMgr) | 782 if (!pWidgetMgr) |
| 793 return; | 783 return; |
| 794 IFWL_FormDP* pData = | 784 IFWL_FormDP* pData = |
| 795 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); | 785 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); |
| 796 if (!pData) | 786 if (!pData) |
| 797 return; | 787 return; |
| 798 CFX_WideString text; | 788 CFX_WideString text; |
| 799 pData->GetCaption(m_pInterface, text); | 789 pData->GetCaption(m_pInterface, text); |
| 800 pWidgetMgr->SetWidgetCaption_Native(m_pInterface, text.AsStringC()); | |
| 801 } | 790 } |
| 802 void CFWL_FormImp::DoWidthLimit(FX_FLOAT& fLeft, | 791 void CFWL_FormImp::DoWidthLimit(FX_FLOAT& fLeft, |
| 803 FX_FLOAT& fWidth, | 792 FX_FLOAT& fWidth, |
| 804 FX_FLOAT fCurX, | 793 FX_FLOAT fCurX, |
| 805 FX_FLOAT fSpace, | 794 FX_FLOAT fSpace, |
| 806 FX_FLOAT fLimitMin, | 795 FX_FLOAT fLimitMin, |
| 807 FX_FLOAT fLimitMax, | 796 FX_FLOAT fLimitMax, |
| 808 FX_BOOL bLeft) { | 797 FX_BOOL bLeft) { |
| 809 FX_FLOAT fx = fCurX; | 798 FX_FLOAT fx = fCurX; |
| 810 FX_FLOAT fy = 0; | 799 FX_FLOAT fy = 0; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); | 939 static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); |
| 951 if (!pWidgetMgr) | 940 if (!pWidgetMgr) |
| 952 return 0; | 941 return 0; |
| 953 | 942 |
| 954 pWidgetMgr->AddRedrawCounts(m_pOwner->m_pInterface); | 943 pWidgetMgr->AddRedrawCounts(m_pOwner->m_pInterface); |
| 955 if (!m_pOwner->m_bSetMaximize) | 944 if (!m_pOwner->m_bSetMaximize) |
| 956 break; | 945 break; |
| 957 | 946 |
| 958 m_pOwner->m_bSetMaximize = FALSE; | 947 m_pOwner->m_bSetMaximize = FALSE; |
| 959 CFWL_MsgSize* pMsg = static_cast<CFWL_MsgSize*>(pMessage); | 948 CFWL_MsgSize* pMsg = static_cast<CFWL_MsgSize*>(pMessage); |
| 960 CFX_RectF rt; | 949 m_pOwner->m_pProperties->m_rtWidget.left = 0; |
| 961 pWidgetMgr->GetWidgetRect_Native(m_pOwner->m_pInterface, rt); | 950 m_pOwner->m_pProperties->m_rtWidget.top = 0; |
| 962 m_pOwner->m_pProperties->m_rtWidget.left = rt.left; | |
| 963 m_pOwner->m_pProperties->m_rtWidget.top = rt.top; | |
| 964 m_pOwner->m_pProperties->m_rtWidget.width = (FX_FLOAT)pMsg->m_iWidth; | 951 m_pOwner->m_pProperties->m_rtWidget.width = (FX_FLOAT)pMsg->m_iWidth; |
| 965 m_pOwner->m_pProperties->m_rtWidget.height = (FX_FLOAT)pMsg->m_iHeight; | 952 m_pOwner->m_pProperties->m_rtWidget.height = (FX_FLOAT)pMsg->m_iHeight; |
| 966 m_pOwner->Update(); | 953 m_pOwner->Update(); |
| 967 break; | 954 break; |
| 968 } | 955 } |
| 969 case CFWL_MessageType::WindowMove: { | 956 case CFWL_MessageType::WindowMove: { |
| 970 OnWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage)); | 957 OnWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage)); |
| 971 break; | 958 break; |
| 972 } | 959 } |
| 973 case CFWL_MessageType::Close: { | 960 case CFWL_MessageType::Close: { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 if (pPressedBtn == m_pOwner->m_pMaxBox) { | 1024 if (pPressedBtn == m_pOwner->m_pMaxBox) { |
| 1038 if (m_pOwner->m_bMaximized) { | 1025 if (m_pOwner->m_bMaximized) { |
| 1039 m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore); | 1026 m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore); |
| 1040 m_pOwner->Update(); | 1027 m_pOwner->Update(); |
| 1041 m_pOwner->Repaint(); | 1028 m_pOwner->Repaint(); |
| 1042 } else { | 1029 } else { |
| 1043 m_pOwner->SetWorkAreaRect(); | 1030 m_pOwner->SetWorkAreaRect(); |
| 1044 m_pOwner->Update(); | 1031 m_pOwner->Update(); |
| 1045 } | 1032 } |
| 1046 m_pOwner->m_bMaximized = !m_pOwner->m_bMaximized; | 1033 m_pOwner->m_bMaximized = !m_pOwner->m_bMaximized; |
| 1047 } else if (pPressedBtn == m_pOwner->m_pMinBox) { | 1034 } else if (pPressedBtn != m_pOwner->m_pMinBox) { |
| 1048 CFWL_WidgetMgr* pWidgetMgr = | |
| 1049 static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); | |
| 1050 if (!pWidgetMgr) | |
| 1051 return; | |
| 1052 pWidgetMgr->SetMinimize_Native(m_pOwner->m_pInterface); | |
| 1053 } else { | |
| 1054 CFWL_EvtClose eClose; | 1035 CFWL_EvtClose eClose; |
| 1055 eClose.m_pSrcTarget = m_pOwner->m_pInterface; | 1036 eClose.m_pSrcTarget = m_pOwner->m_pInterface; |
| 1056 m_pOwner->DispatchEvent(&eClose); | 1037 m_pOwner->DispatchEvent(&eClose); |
| 1057 } | 1038 } |
| 1058 } | 1039 } |
| 1059 void CFWL_FormImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { | 1040 void CFWL_FormImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { |
| 1060 if (m_pOwner->m_bLButtonDown) { | 1041 if (m_pOwner->m_bLButtonDown) { |
| 1061 return; | 1042 return; |
| 1062 } | 1043 } |
| 1063 if ((m_pOwner->m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && | 1044 if ((m_pOwner->m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 } | 1127 } |
| 1147 void CFWL_FormImpDelegate::OnWindowMove(CFWL_MsgWindowMove* pMsg) { | 1128 void CFWL_FormImpDelegate::OnWindowMove(CFWL_MsgWindowMove* pMsg) { |
| 1148 m_pOwner->m_pProperties->m_rtWidget.left = pMsg->m_fx; | 1129 m_pOwner->m_pProperties->m_rtWidget.left = pMsg->m_fx; |
| 1149 m_pOwner->m_pProperties->m_rtWidget.top = pMsg->m_fy; | 1130 m_pOwner->m_pProperties->m_rtWidget.top = pMsg->m_fy; |
| 1150 } | 1131 } |
| 1151 void CFWL_FormImpDelegate::OnClose(CFWL_MsgClose* pMsg) { | 1132 void CFWL_FormImpDelegate::OnClose(CFWL_MsgClose* pMsg) { |
| 1152 CFWL_EvtClose eClose; | 1133 CFWL_EvtClose eClose; |
| 1153 eClose.m_pSrcTarget = m_pOwner->m_pInterface; | 1134 eClose.m_pSrcTarget = m_pOwner->m_pInterface; |
| 1154 m_pOwner->DispatchEvent(&eClose); | 1135 m_pOwner->DispatchEvent(&eClose); |
| 1155 } | 1136 } |
| OLD | NEW |