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/src/foxitlib.h" | 7 #include "xfa/src/foxitlib.h" |
8 #include "xfa/src/fwl/src/core/include/fwl_targetimp.h" | 8 #include "xfa/src/fwl/src/core/include/fwl_targetimp.h" |
9 #include "xfa/src/fwl/src/core/include/fwl_threadimp.h" | 9 #include "xfa/src/fwl/src/core/include/fwl_threadimp.h" |
10 #include "xfa/src/fwl/src/core/include/fwl_noteimp.h" | 10 #include "xfa/src/fwl/src/core/include/fwl_noteimp.h" |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 void CFWL_FormImp::SetWorkAreaRect() { | 641 void CFWL_FormImp::SetWorkAreaRect() { |
642 m_rtRestore = m_pProperties->m_rtWidget; | 642 m_rtRestore = m_pProperties->m_rtWidget; |
643 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); | 643 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); |
644 if (!pWidgetMgr) | 644 if (!pWidgetMgr) |
645 return; | 645 return; |
646 m_bSetMaximize = TRUE; | 646 m_bSetMaximize = TRUE; |
647 pWidgetMgr->SetMaximize_Native(m_pInterface); | 647 pWidgetMgr->SetMaximize_Native(m_pInterface); |
648 Repaint(&m_rtRelative); | 648 Repaint(&m_rtRelative); |
649 } | 649 } |
650 void CFWL_FormImp::SetCursor(FX_FLOAT fx, FX_FLOAT fy) { | 650 void CFWL_FormImp::SetCursor(FX_FLOAT fx, FX_FLOAT fy) { |
651 IFWL_AdapterNative* pNative = FWL_GetAdapterNative(); | |
652 IFWL_AdapterCursorMgr* pCursorMgr = pNative->GetCursorMgr(); | |
653 if (!pCursorMgr) | |
654 return; | |
655 FX_DWORD dwHitTest = HitTest(fx, fy); | |
656 switch (dwHitTest) { | |
657 case FWL_WGTHITTEST_Right: { | |
658 FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeWE); | |
659 pCursorMgr->SetCursor(hCursor); | |
660 pCursorMgr->ShowCursor(TRUE); | |
661 m_eResizeType = FORM_RESIZETYPE_Right; | |
662 break; | |
663 } | |
664 case FWL_WGTHITTEST_Bottom: { | |
665 FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNS); | |
666 pCursorMgr->SetCursor(hCursor); | |
667 pCursorMgr->ShowCursor(TRUE); | |
668 m_eResizeType = FORM_RESIZETYPE_Bottom; | |
669 break; | |
670 } | |
671 case FWL_WGTHITTEST_Left: { | |
672 FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeWE); | |
673 pCursorMgr->SetCursor(hCursor); | |
674 pCursorMgr->ShowCursor(TRUE); | |
675 m_eResizeType = FORM_RESIZETYPE_Left; | |
676 break; | |
677 } | |
678 case FWL_WGTHITTEST_Top: { | |
679 FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNS); | |
680 pCursorMgr->SetCursor(hCursor); | |
681 pCursorMgr->ShowCursor(TRUE); | |
682 m_eResizeType = FORM_RESIZETYPE_Top; | |
683 break; | |
684 } | |
685 case FWL_WGTHITTEST_LeftTop: { | |
686 FWL_HCURSOR hCursor = | |
687 pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNWSE); | |
688 pCursorMgr->SetCursor(hCursor); | |
689 pCursorMgr->ShowCursor(TRUE); | |
690 m_eResizeType = FORM_RESIZETYPE_LeftTop; | |
691 break; | |
692 } | |
693 case FWL_WGTHITTEST_LeftBottom: { | |
694 FWL_HCURSOR hCursor = | |
695 pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNESW); | |
696 pCursorMgr->SetCursor(hCursor); | |
697 pCursorMgr->ShowCursor(TRUE); | |
698 m_eResizeType = FORM_RESIZETYPE_LeftBottom; | |
699 break; | |
700 } | |
701 case FWL_WGTHITTEST_RightTop: { | |
702 FWL_HCURSOR hCursor = | |
703 pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNESW); | |
704 pCursorMgr->SetCursor(hCursor); | |
705 pCursorMgr->ShowCursor(TRUE); | |
706 m_eResizeType = FORM_RESIZETYPE_RightTop; | |
707 break; | |
708 } | |
709 case FWL_WGTHITTEST_RightBottom: { | |
710 FWL_HCURSOR hCursor = | |
711 pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNWSE); | |
712 pCursorMgr->SetCursor(hCursor); | |
713 pCursorMgr->ShowCursor(TRUE); | |
714 m_eResizeType = FORM_RESIZETYPE_RightBottom; | |
715 break; | |
716 } | |
717 default: { | |
718 FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_Arrow); | |
719 pCursorMgr->SetCursor(hCursor); | |
720 pCursorMgr->ShowCursor(TRUE); | |
721 } | |
722 } | |
723 } | 651 } |
724 void CFWL_FormImp::Layout() { | 652 void CFWL_FormImp::Layout() { |
725 GetRelativeRect(m_rtRelative); | 653 GetRelativeRect(m_rtRelative); |
726 #ifndef FWL_UseMacSystemBorder | 654 #ifndef FWL_UseMacSystemBorder |
727 ReSetSysBtn(); | 655 ReSetSysBtn(); |
728 #endif | 656 #endif |
729 if (m_pContent) { | 657 if (m_pContent) { |
730 CFX_RectF rtClient; | 658 CFX_RectF rtClient; |
731 GetClientRect(rtClient); | 659 GetClientRect(rtClient); |
732 m_pContent->SetWidgetRect(rtClient); | 660 m_pContent->SetWidgetRect(rtClient); |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 if (!pWidgetMgr) | 1065 if (!pWidgetMgr) |
1138 return; | 1066 return; |
1139 pWidgetMgr->SetMinimize_Native(m_pOwner->m_pInterface); | 1067 pWidgetMgr->SetMinimize_Native(m_pOwner->m_pInterface); |
1140 } else { | 1068 } else { |
1141 CFWL_EvtClose eClose; | 1069 CFWL_EvtClose eClose; |
1142 eClose.m_pSrcTarget = m_pOwner->m_pInterface; | 1070 eClose.m_pSrcTarget = m_pOwner->m_pInterface; |
1143 m_pOwner->DispatchEvent(&eClose); | 1071 m_pOwner->DispatchEvent(&eClose); |
1144 } | 1072 } |
1145 } | 1073 } |
1146 void CFWL_FormImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { | 1074 void CFWL_FormImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { |
1147 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); | |
1148 if (m_pOwner->m_bLButtonDown) { | 1075 if (m_pOwner->m_bLButtonDown) { |
1149 IFWL_AdapterNative* pNative = FWL_GetAdapterNative(); | |
1150 IFWL_AdapterCursorMgr* pCursorMgr = pNative->GetCursorMgr(); | |
1151 if (!pCursorMgr) | |
1152 return; | |
1153 CFWL_SysBtn* pPressedBtn = | |
1154 m_pOwner->GetSysBtnByIndex(m_pOwner->m_iCaptureBtn); | |
1155 FX_FLOAT fTop, fLeft, fWidth, fHeight; | |
1156 fTop = m_pOwner->m_pProperties->m_rtWidget.top; | |
1157 fLeft = m_pOwner->m_pProperties->m_rtWidget.left; | |
1158 fWidth = m_pOwner->m_pProperties->m_rtWidget.width; | |
1159 fHeight = m_pOwner->m_pProperties->m_rtWidget.height; | |
1160 FX_FLOAT fWidthMax, fWidthMin, fHeightMax, fHeightMin; | |
1161 if (m_pOwner->m_pContent) { | |
1162 m_pOwner->GetContent()->GetMaxSize(fWidthMax, fHeightMax); | |
1163 m_pOwner->GetContent()->GetMinSize(fWidthMin, fHeightMin); | |
1164 } else { | |
1165 fWidthMax = fHeightMax = 1024 * 4; | |
1166 fWidthMin = fHeightMin = 0; | |
1167 } | |
1168 FX_BOOL bWidthlimit = (fWidthMin != 0 || fWidthMax != 0); | |
1169 FX_BOOL bHeightlimit = (fHeightMin != 0 || fHeightMax != 0); | |
1170 FX_BOOL bSizelimit = bWidthlimit || bHeightlimit; | |
1171 if (fWidthMax != 0 || fHeightMax != 0 || fWidthMin != 0 || | |
1172 fHeightMin != 0) { | |
1173 bSizelimit = TRUE; | |
1174 } | |
1175 if (pPressedBtn) { | |
1176 if (!pPressedBtn->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { | |
1177 pPressedBtn->SetNormal(); | |
1178 } else { | |
1179 pPressedBtn->SetPressed(); | |
1180 } | |
1181 m_pOwner->Repaint(&pPressedBtn->m_rtBtn); | |
1182 return; | |
1183 } else if (m_pOwner->m_bMaximized) { | |
1184 return; | |
1185 } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_Cap) { | |
1186 m_pOwner->m_pProperties->m_rtWidget.Offset( | |
1187 pMsg->m_fx - m_pOwner->m_InfoStart.m_ptStart.x, | |
1188 pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y); | |
1189 pWidgetMgr->SetWidgetPosition_Native( | |
1190 m_pOwner->m_pInterface, m_pOwner->m_pProperties->m_rtWidget.left, | |
1191 m_pOwner->m_pProperties->m_rtWidget.top); | |
1192 return; | |
1193 } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_Right) { | |
1194 FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeWE); | |
1195 pCursorMgr->SetCursor(hCursor); | |
1196 pCursorMgr->ShowCursor(TRUE); | |
1197 if (!bWidthlimit) { | |
1198 fWidth += pMsg->m_fx - m_pOwner->m_InfoStart.m_ptStart.x; | |
1199 m_pOwner->m_InfoStart.m_ptStart.x = pMsg->m_fx; | |
1200 } else { | |
1201 m_pOwner->DoWidthLimit(fLeft, fWidth, pMsg->m_fx, | |
1202 m_pOwner->m_InfoStart.m_szStart.x - | |
1203 m_pOwner->m_InfoStart.m_ptStart.x, | |
1204 fWidthMin, fWidthMax, FALSE); | |
1205 } | |
1206 } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_Left) { | |
1207 FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeWE); | |
1208 pCursorMgr->SetCursor(hCursor); | |
1209 pCursorMgr->ShowCursor(TRUE); | |
1210 if (!bWidthlimit) { | |
1211 fLeft -= m_pOwner->m_InfoStart.m_ptStart.x - pMsg->m_fx; | |
1212 fWidth += m_pOwner->m_InfoStart.m_ptStart.x - pMsg->m_fx; | |
1213 } else { | |
1214 m_pOwner->DoWidthLimit(fLeft, fWidth, pMsg->m_fx, | |
1215 m_pOwner->m_InfoStart.m_ptStart.x, fWidthMin, | |
1216 fWidthMax, TRUE); | |
1217 } | |
1218 } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_Bottom) { | |
1219 FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNS); | |
1220 pCursorMgr->SetCursor(hCursor); | |
1221 pCursorMgr->ShowCursor(TRUE); | |
1222 if (!bHeightlimit) { | |
1223 fHeight += pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y; | |
1224 m_pOwner->m_InfoStart.m_ptStart.y = pMsg->m_fy; | |
1225 } else { | |
1226 m_pOwner->DoHeightLimit(fTop, fHeight, pMsg->m_fy, | |
1227 m_pOwner->m_InfoStart.m_szStart.y - | |
1228 m_pOwner->m_InfoStart.m_ptStart.y, | |
1229 fHeightMin, fHeightMax, FALSE); | |
1230 } | |
1231 } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_Top) { | |
1232 FWL_HCURSOR hCursor = pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNS); | |
1233 pCursorMgr->SetCursor(hCursor); | |
1234 pCursorMgr->ShowCursor(TRUE); | |
1235 if (!bHeightlimit) { | |
1236 fTop += pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y; | |
1237 fHeight -= pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y; | |
1238 } else { | |
1239 m_pOwner->DoHeightLimit(fTop, fHeight, pMsg->m_fy, | |
1240 m_pOwner->m_InfoStart.m_ptStart.y, fHeightMin, | |
1241 fHeightMax, TRUE); | |
1242 } | |
1243 } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_LeftTop) { | |
1244 FWL_HCURSOR hCursor = | |
1245 pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNWSE); | |
1246 pCursorMgr->SetCursor(hCursor); | |
1247 pCursorMgr->ShowCursor(TRUE); | |
1248 if (!bSizelimit) { | |
1249 fLeft -= m_pOwner->m_InfoStart.m_ptStart.x - pMsg->m_fx; | |
1250 fTop += pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y; | |
1251 fWidth += m_pOwner->m_InfoStart.m_ptStart.x - pMsg->m_fx; | |
1252 fHeight -= pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y; | |
1253 m_pOwner->m_InfoStart.m_ptStart.x = pMsg->m_fx; | |
1254 m_pOwner->m_InfoStart.m_ptStart.y = pMsg->m_fy; | |
1255 } else { | |
1256 m_pOwner->DoWidthLimit(fLeft, fWidth, pMsg->m_fx, | |
1257 m_pOwner->m_InfoStart.m_ptStart.x, fWidthMin, | |
1258 fWidthMax, TRUE); | |
1259 m_pOwner->DoHeightLimit(fTop, fHeight, pMsg->m_fy, | |
1260 m_pOwner->m_InfoStart.m_ptStart.y, fHeightMin, | |
1261 fHeightMax, TRUE); | |
1262 } | |
1263 } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_LeftBottom) { | |
1264 FWL_HCURSOR hCursor = | |
1265 pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNESW); | |
1266 pCursorMgr->SetCursor(hCursor); | |
1267 pCursorMgr->ShowCursor(TRUE); | |
1268 if (!bSizelimit) { | |
1269 fLeft -= m_pOwner->m_InfoStart.m_ptStart.x - pMsg->m_fx; | |
1270 fWidth += m_pOwner->m_InfoStart.m_ptStart.x - pMsg->m_fx; | |
1271 fHeight += pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y; | |
1272 m_pOwner->m_InfoStart.m_ptStart.x = pMsg->m_fx; | |
1273 m_pOwner->m_InfoStart.m_ptStart.y = pMsg->m_fy; | |
1274 } else { | |
1275 m_pOwner->DoWidthLimit(fLeft, fWidth, pMsg->m_fx, | |
1276 m_pOwner->m_InfoStart.m_ptStart.x, fWidthMin, | |
1277 fWidthMax, TRUE); | |
1278 m_pOwner->DoHeightLimit(fTop, fHeight, pMsg->m_fy, | |
1279 m_pOwner->m_InfoStart.m_szStart.y - | |
1280 m_pOwner->m_InfoStart.m_ptStart.y, | |
1281 fHeightMin, fHeightMax, FALSE); | |
1282 } | |
1283 } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_RightTop) { | |
1284 FWL_HCURSOR hCursor = | |
1285 pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNESW); | |
1286 pCursorMgr->SetCursor(hCursor); | |
1287 pCursorMgr->ShowCursor(TRUE); | |
1288 if (!bSizelimit) { | |
1289 fTop += pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y; | |
1290 fWidth += pMsg->m_fx - m_pOwner->m_InfoStart.m_ptStart.x; | |
1291 fHeight -= pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y; | |
1292 m_pOwner->m_InfoStart.m_ptStart.x = pMsg->m_fx; | |
1293 m_pOwner->m_InfoStart.m_ptStart.y = pMsg->m_fy; | |
1294 } else { | |
1295 m_pOwner->DoWidthLimit(fLeft, fWidth, pMsg->m_fx, | |
1296 m_pOwner->m_InfoStart.m_szStart.x - | |
1297 m_pOwner->m_InfoStart.m_ptStart.x, | |
1298 fWidthMin, fWidthMax, FALSE); | |
1299 m_pOwner->DoHeightLimit(fTop, fHeight, pMsg->m_fy, | |
1300 m_pOwner->m_InfoStart.m_ptStart.y, fHeightMin, | |
1301 fHeightMax, TRUE); | |
1302 } | |
1303 } else if (m_pOwner->m_eResizeType == FORM_RESIZETYPE_RightBottom) { | |
1304 FWL_HCURSOR hCursor = | |
1305 pCursorMgr->GetSystemCursor(FWL_CURSORTYPE_SizeNWSE); | |
1306 pCursorMgr->SetCursor(hCursor); | |
1307 pCursorMgr->ShowCursor(TRUE); | |
1308 if (!bSizelimit) { | |
1309 fWidth += pMsg->m_fx - m_pOwner->m_InfoStart.m_ptStart.x; | |
1310 fHeight += pMsg->m_fy - m_pOwner->m_InfoStart.m_ptStart.y; | |
1311 m_pOwner->m_InfoStart.m_ptStart.x = pMsg->m_fx; | |
1312 m_pOwner->m_InfoStart.m_ptStart.y = pMsg->m_fy; | |
1313 } else { | |
1314 m_pOwner->DoWidthLimit(fLeft, fWidth, pMsg->m_fx, | |
1315 m_pOwner->m_InfoStart.m_szStart.x - | |
1316 m_pOwner->m_InfoStart.m_ptStart.x, | |
1317 fWidthMin, fWidthMax, FALSE); | |
1318 m_pOwner->DoHeightLimit(fTop, fHeight, pMsg->m_fy, | |
1319 m_pOwner->m_InfoStart.m_szStart.y - | |
1320 m_pOwner->m_InfoStart.m_ptStart.y, | |
1321 fHeightMin, fHeightMax, FALSE); | |
1322 } | |
1323 } | |
1324 if (m_pOwner->m_pContent) { | |
1325 } | |
1326 CFX_RectF rtForm; | |
1327 rtForm.Set(fLeft, fTop, fWidth, fHeight); | |
1328 #if (_FX_OS_ == _FX_MACOSX_) | |
1329 m_pOwner->m_pProperties->m_rtWidget = rtForm; | |
1330 m_pOwner->Update(); | |
1331 m_pOwner->SetWidgetRect(rtForm); | |
1332 #else | |
1333 m_pOwner->SetWidgetRect(rtForm); | |
1334 m_pOwner->Update(); | |
1335 #endif | |
1336 return; | 1076 return; |
1337 } | 1077 } |
1338 if ((m_pOwner->m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && | 1078 if ((m_pOwner->m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && |
1339 (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && | 1079 (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && |
1340 !m_pOwner->m_bMaximized) { | 1080 !m_pOwner->m_bMaximized) { |
1341 m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy); | 1081 m_pOwner->SetCursor(pMsg->m_fx, pMsg->m_fy); |
1342 } | 1082 } |
1343 CFX_RectF rtInvalidate; | 1083 CFX_RectF rtInvalidate; |
1344 rtInvalidate.Reset(); | 1084 rtInvalidate.Reset(); |
1345 CFWL_SysBtn* pPointBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); | 1085 CFWL_SysBtn* pPointBtn = m_pOwner->GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 eClose.m_pSrcTarget = m_pOwner->m_pInterface; | 1169 eClose.m_pSrcTarget = m_pOwner->m_pInterface; |
1430 m_pOwner->DispatchEvent(&eClose); | 1170 m_pOwner->DispatchEvent(&eClose); |
1431 } | 1171 } |
1432 FWL_ERR FWL_Accelerator_SetForm(IFWL_Form* pFrom, | 1172 FWL_ERR FWL_Accelerator_SetForm(IFWL_Form* pFrom, |
1433 CFX_MapAccelerators* pMapAccel) { | 1173 CFX_MapAccelerators* pMapAccel) { |
1434 CFWL_FormImp* pImp = static_cast<CFWL_FormImp*>(pFrom->GetImpl()); | 1174 CFWL_FormImp* pImp = static_cast<CFWL_FormImp*>(pFrom->GetImpl()); |
1435 if (!pImp) | 1175 if (!pImp) |
1436 return FWL_ERR_Indefinite; | 1176 return FWL_ERR_Indefinite; |
1437 return FWL_ERR_Succeeded; | 1177 return FWL_ERR_Succeeded; |
1438 } | 1178 } |
OLD | NEW |