Chromium Code Reviews| 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 #define FWL_SYSBTNSIZE 21 | 23 #define FWL_SYSBTNSIZE 21 |
| 25 #define FWL_SYSBTNMARGIN 5 | 24 #define FWL_SYSBTNMARGIN 5 |
| 26 #define FWL_SYSBTNSPAN 2 | 25 #define FWL_SYSBTNSPAN 2 |
| 27 | 26 |
| 28 namespace { | 27 namespace { |
| 29 | 28 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) == 0) { | 143 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) == 0) { |
| 145 rect = m_pProperties->m_rtWidget; | 144 rect = m_pProperties->m_rtWidget; |
| 146 rect.Offset(-rect.left, -rect.top); | 145 rect.Offset(-rect.left, -rect.top); |
| 147 return FWL_ERR_Succeeded; | 146 return FWL_ERR_Succeeded; |
| 148 } | 147 } |
| 149 #ifdef FWL_UseMacSystemBorder | 148 #ifdef FWL_UseMacSystemBorder |
| 150 rect = m_rtRelative; | 149 rect = m_rtRelative; |
| 151 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); | 150 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); |
| 152 if (!pWidgetMgr) | 151 if (!pWidgetMgr) |
| 153 return FWL_ERR_Indefinite; | 152 return FWL_ERR_Indefinite; |
| 154 IFWL_AdapterWidgetMgr* adapterWidgetMgr = pWidgetMgr->GetAdapterWidgetMgr(); | 153 CXFA_FWLAdapterWidgetMgr* adapterWidgetMgr = |
| 154 pWidgetMgr->GetAdapterWidgetMgr(); | |
| 155 FX_FLOAT l, t, r, b; | 155 FX_FLOAT l, t, r, b; |
| 156 l = t = r = b = 0; | 156 l = t = r = b = 0; |
| 157 adapterWidgetMgr->GetSystemBorder(l, t, r, b); | 157 adapterWidgetMgr->GetSystemBorder(l, t, r, b); |
| 158 rect.Deflate(l, t, r, b); | 158 rect.Deflate(l, t, r, b); |
| 159 rect.left = rect.top = 0; | 159 rect.left = rect.top = 0; |
| 160 return FWL_ERR_Succeeded; | 160 return FWL_ERR_Succeeded; |
| 161 #else | 161 #else |
| 162 FX_FLOAT x = 0; | 162 FX_FLOAT x = 0; |
| 163 FX_FLOAT y = 0; | 163 FX_FLOAT y = 0; |
| 164 FX_FLOAT t = 0; | 164 FX_FLOAT t = 0; |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 IFWL_App* pApp = FWL_GetApp(); | 459 IFWL_App* pApp = FWL_GetApp(); |
| 460 if (!pApp) | 460 if (!pApp) |
| 461 return; | 461 return; |
| 462 CFWL_WidgetMgr* pWidgetMgr = | 462 CFWL_WidgetMgr* pWidgetMgr = |
| 463 static_cast<CFWL_WidgetMgr*>(pApp->GetWidgetMgr()); | 463 static_cast<CFWL_WidgetMgr*>(pApp->GetWidgetMgr()); |
| 464 if (!pWidgetMgr) | 464 if (!pWidgetMgr) |
| 465 return; | 465 return; |
| 466 IFWL_Widget* pChild = | 466 IFWL_Widget* pChild = |
| 467 pWidgetMgr->GetWidget(pParent, FWL_WGTRELATION_FirstChild); | 467 pWidgetMgr->GetWidget(pParent, FWL_WGTRELATION_FirstChild); |
| 468 while (pChild) { | 468 while (pChild) { |
| 469 pWidgetMgr->ShowWidget_Native(pChild); | |
| 470 ShowChildWidget(pChild); | 469 ShowChildWidget(pChild); |
| 471 pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling); | 470 pChild = pWidgetMgr->GetWidget(pChild, FWL_WGTRELATION_NextSibling); |
| 472 } | 471 } |
| 473 } | 472 } |
| 474 void CFWL_FormImp::RemoveSysButtons() { | 473 void CFWL_FormImp::RemoveSysButtons() { |
| 475 m_rtCaption.Reset(); | 474 m_rtCaption.Reset(); |
| 476 if (m_pCloseBox) { | 475 if (m_pCloseBox) { |
| 477 delete m_pCloseBox; | 476 delete m_pCloseBox; |
| 478 m_pCloseBox = NULL; | 477 m_pCloseBox = NULL; |
| 479 } | 478 } |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 632 FX_FLOAT fCY = GetBorderSize(FALSE); | 631 FX_FLOAT fCY = GetBorderSize(FALSE); |
| 633 rtEdge.Deflate(fCX, m_rtCaption.Height(), fCX, fCY); | 632 rtEdge.Deflate(fCX, m_rtCaption.Height(), fCX, fCY); |
| 634 } | 633 } |
| 635 } | 634 } |
| 636 void CFWL_FormImp::SetWorkAreaRect() { | 635 void CFWL_FormImp::SetWorkAreaRect() { |
| 637 m_rtRestore = m_pProperties->m_rtWidget; | 636 m_rtRestore = m_pProperties->m_rtWidget; |
| 638 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); | 637 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); |
| 639 if (!pWidgetMgr) | 638 if (!pWidgetMgr) |
| 640 return; | 639 return; |
| 641 m_bSetMaximize = TRUE; | 640 m_bSetMaximize = TRUE; |
| 642 pWidgetMgr->SetMaximize_Native(m_pInterface); | |
| 643 Repaint(&m_rtRelative); | 641 Repaint(&m_rtRelative); |
| 644 } | 642 } |
| 645 void CFWL_FormImp::SetCursor(FX_FLOAT fx, FX_FLOAT fy) {} | 643 void CFWL_FormImp::SetCursor(FX_FLOAT fx, FX_FLOAT fy) {} |
| 646 void CFWL_FormImp::Layout() { | 644 void CFWL_FormImp::Layout() { |
| 647 GetRelativeRect(m_rtRelative); | 645 GetRelativeRect(m_rtRelative); |
| 648 #ifndef FWL_UseMacSystemBorder | 646 #ifndef FWL_UseMacSystemBorder |
| 649 ReSetSysBtn(); | 647 ReSetSysBtn(); |
| 650 #endif | 648 #endif |
| 651 } | 649 } |
| 652 void CFWL_FormImp::ReSetSysBtn() { | 650 void CFWL_FormImp::ReSetSysBtn() { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 785 return !!pData->GetIcon(m_pInterface, FALSE); | 783 return !!pData->GetIcon(m_pInterface, FALSE); |
| 786 } | 784 } |
| 787 void CFWL_FormImp::UpdateIcon() { | 785 void CFWL_FormImp::UpdateIcon() { |
| 788 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); | 786 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); |
| 789 if (!pWidgetMgr) | 787 if (!pWidgetMgr) |
| 790 return; | 788 return; |
| 791 IFWL_FormDP* pData = | 789 IFWL_FormDP* pData = |
| 792 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); | 790 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); |
| 793 CFX_DIBitmap* pBigIcon = pData->GetIcon(m_pInterface, TRUE); | 791 CFX_DIBitmap* pBigIcon = pData->GetIcon(m_pInterface, TRUE); |
| 794 CFX_DIBitmap* pSmallIcon = pData->GetIcon(m_pInterface, FALSE); | 792 CFX_DIBitmap* pSmallIcon = pData->GetIcon(m_pInterface, FALSE); |
| 795 if (pBigIcon && pBigIcon != m_pBigIcon) { | 793 if (pBigIcon && pBigIcon != m_pBigIcon) |
|
Tom Sepez
2016/04/28 16:42:11
The second part of the && seems redundant, do we c
dsinclair
2016/04/28 17:53:45
I guess it was guarding the _Native calls. Removed
| |
| 796 m_pBigIcon = pBigIcon; | 794 m_pBigIcon = pBigIcon; |
| 797 pWidgetMgr->SetWidgetIcon_Native(m_pInterface, m_pBigIcon, TRUE); | 795 if (pSmallIcon && pSmallIcon != m_pSmallIcon) |
| 798 } | |
| 799 if (pSmallIcon && pSmallIcon != m_pSmallIcon) { | |
| 800 m_pSmallIcon = pSmallIcon; | 796 m_pSmallIcon = pSmallIcon; |
| 801 pWidgetMgr->SetWidgetIcon_Native(m_pInterface, m_pBigIcon, FALSE); | |
| 802 } | |
| 803 } | 797 } |
| 804 void CFWL_FormImp::UpdateCaption() { | 798 void CFWL_FormImp::UpdateCaption() { |
| 805 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); | 799 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); |
| 806 if (!pWidgetMgr) | 800 if (!pWidgetMgr) |
| 807 return; | 801 return; |
| 808 IFWL_FormDP* pData = | 802 IFWL_FormDP* pData = |
| 809 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); | 803 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); |
| 810 if (!pData) | 804 if (!pData) |
| 811 return; | 805 return; |
| 812 CFX_WideString text; | 806 CFX_WideString text; |
| 813 pData->GetCaption(m_pInterface, text); | 807 pData->GetCaption(m_pInterface, text); |
| 814 pWidgetMgr->SetWidgetCaption_Native(m_pInterface, text.AsStringC()); | |
| 815 } | 808 } |
| 816 void CFWL_FormImp::DoWidthLimit(FX_FLOAT& fLeft, | 809 void CFWL_FormImp::DoWidthLimit(FX_FLOAT& fLeft, |
| 817 FX_FLOAT& fWidth, | 810 FX_FLOAT& fWidth, |
| 818 FX_FLOAT fCurX, | 811 FX_FLOAT fCurX, |
| 819 FX_FLOAT fSpace, | 812 FX_FLOAT fSpace, |
| 820 FX_FLOAT fLimitMin, | 813 FX_FLOAT fLimitMin, |
| 821 FX_FLOAT fLimitMax, | 814 FX_FLOAT fLimitMax, |
| 822 FX_BOOL bLeft) { | 815 FX_BOOL bLeft) { |
| 823 FX_FLOAT fx = fCurX; | 816 FX_FLOAT fx = fCurX; |
| 824 FX_FLOAT fy = 0; | 817 FX_FLOAT fy = 0; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 963 if (!pWidgetMgr) | 956 if (!pWidgetMgr) |
| 964 return 0; | 957 return 0; |
| 965 | 958 |
| 966 pWidgetMgr->AddRedrawCounts(m_pOwner->m_pInterface); | 959 pWidgetMgr->AddRedrawCounts(m_pOwner->m_pInterface); |
| 967 if (!m_pOwner->m_bSetMaximize) | 960 if (!m_pOwner->m_bSetMaximize) |
| 968 break; | 961 break; |
| 969 | 962 |
| 970 m_pOwner->m_bSetMaximize = FALSE; | 963 m_pOwner->m_bSetMaximize = FALSE; |
| 971 CFWL_MsgSize* pMsg = static_cast<CFWL_MsgSize*>(pMessage); | 964 CFWL_MsgSize* pMsg = static_cast<CFWL_MsgSize*>(pMessage); |
| 972 CFX_RectF rt; | 965 CFX_RectF rt; |
| 973 pWidgetMgr->GetWidgetRect_Native(m_pOwner->m_pInterface, rt); | |
| 974 m_pOwner->m_pProperties->m_rtWidget.left = rt.left; | 966 m_pOwner->m_pProperties->m_rtWidget.left = rt.left; |
| 975 m_pOwner->m_pProperties->m_rtWidget.top = rt.top; | 967 m_pOwner->m_pProperties->m_rtWidget.top = rt.top; |
| 976 m_pOwner->m_pProperties->m_rtWidget.width = (FX_FLOAT)pMsg->m_iWidth; | 968 m_pOwner->m_pProperties->m_rtWidget.width = (FX_FLOAT)pMsg->m_iWidth; |
| 977 m_pOwner->m_pProperties->m_rtWidget.height = (FX_FLOAT)pMsg->m_iHeight; | 969 m_pOwner->m_pProperties->m_rtWidget.height = (FX_FLOAT)pMsg->m_iHeight; |
| 978 m_pOwner->Update(); | 970 m_pOwner->Update(); |
| 979 break; | 971 break; |
| 980 } | 972 } |
| 981 case CFWL_MessageType::WindowMove: { | 973 case CFWL_MessageType::WindowMove: { |
| 982 OnWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage)); | 974 OnWindowMove(static_cast<CFWL_MsgWindowMove*>(pMessage)); |
| 983 break; | 975 break; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1048 if (pPressedBtn == m_pOwner->m_pMaxBox) { | 1040 if (pPressedBtn == m_pOwner->m_pMaxBox) { |
| 1049 if (m_pOwner->m_bMaximized) { | 1041 if (m_pOwner->m_bMaximized) { |
| 1050 m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore); | 1042 m_pOwner->SetWidgetRect(m_pOwner->m_rtRestore); |
| 1051 m_pOwner->Update(); | 1043 m_pOwner->Update(); |
| 1052 m_pOwner->Repaint(); | 1044 m_pOwner->Repaint(); |
| 1053 } else { | 1045 } else { |
| 1054 m_pOwner->SetWorkAreaRect(); | 1046 m_pOwner->SetWorkAreaRect(); |
| 1055 m_pOwner->Update(); | 1047 m_pOwner->Update(); |
| 1056 } | 1048 } |
| 1057 m_pOwner->m_bMaximized = !m_pOwner->m_bMaximized; | 1049 m_pOwner->m_bMaximized = !m_pOwner->m_bMaximized; |
| 1058 } else if (pPressedBtn == m_pOwner->m_pMinBox) { | 1050 } else if (pPressedBtn != m_pOwner->m_pMinBox) { |
| 1059 CFWL_WidgetMgr* pWidgetMgr = | |
| 1060 static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); | |
| 1061 if (!pWidgetMgr) | |
| 1062 return; | |
| 1063 pWidgetMgr->SetMinimize_Native(m_pOwner->m_pInterface); | |
| 1064 } else { | |
| 1065 CFWL_EvtClose eClose; | 1051 CFWL_EvtClose eClose; |
| 1066 eClose.m_pSrcTarget = m_pOwner->m_pInterface; | 1052 eClose.m_pSrcTarget = m_pOwner->m_pInterface; |
| 1067 m_pOwner->DispatchEvent(&eClose); | 1053 m_pOwner->DispatchEvent(&eClose); |
| 1068 } | 1054 } |
| 1069 } | 1055 } |
| 1070 void CFWL_FormImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { | 1056 void CFWL_FormImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { |
| 1071 if (m_pOwner->m_bLButtonDown) { | 1057 if (m_pOwner->m_bLButtonDown) { |
| 1072 return; | 1058 return; |
| 1073 } | 1059 } |
| 1074 if ((m_pOwner->m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && | 1060 if ((m_pOwner->m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1158 } | 1144 } |
| 1159 void CFWL_FormImpDelegate::OnWindowMove(CFWL_MsgWindowMove* pMsg) { | 1145 void CFWL_FormImpDelegate::OnWindowMove(CFWL_MsgWindowMove* pMsg) { |
| 1160 m_pOwner->m_pProperties->m_rtWidget.left = pMsg->m_fx; | 1146 m_pOwner->m_pProperties->m_rtWidget.left = pMsg->m_fx; |
| 1161 m_pOwner->m_pProperties->m_rtWidget.top = pMsg->m_fy; | 1147 m_pOwner->m_pProperties->m_rtWidget.top = pMsg->m_fy; |
| 1162 } | 1148 } |
| 1163 void CFWL_FormImpDelegate::OnClose(CFWL_MsgClose* pMsg) { | 1149 void CFWL_FormImpDelegate::OnClose(CFWL_MsgClose* pMsg) { |
| 1164 CFWL_EvtClose eClose; | 1150 CFWL_EvtClose eClose; |
| 1165 eClose.m_pSrcTarget = m_pOwner->m_pInterface; | 1151 eClose.m_pSrcTarget = m_pOwner->m_pInterface; |
| 1166 m_pOwner->DispatchEvent(&eClose); | 1152 m_pOwner->DispatchEvent(&eClose); |
| 1167 } | 1153 } |
| OLD | NEW |