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_widgetmgrimp.h" | 7 #include "xfa/fwl/core/fwl_widgetmgrimp.h" |
8 | 8 |
9 #include "xfa/fwl/core/cfwl_message.h" | 9 #include "xfa/fwl/core/cfwl_message.h" |
10 #include "xfa/fwl/core/fwl_appimp.h" | 10 #include "xfa/fwl/core/fwl_appimp.h" |
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 CFX_RectF temp(m_pWidgetMgr->m_rtScreen); | 1000 CFX_RectF temp(m_pWidgetMgr->m_rtScreen); |
1001 temp.Deflate(50, 50); | 1001 temp.Deflate(50, 50); |
1002 if (!temp.Contains(r)) { | 1002 if (!temp.Contains(r)) { |
1003 return FALSE; | 1003 return FALSE; |
1004 } | 1004 } |
1005 pItem->bOutsideChanged = FALSE; | 1005 pItem->bOutsideChanged = FALSE; |
1006 } | 1006 } |
1007 #endif | 1007 #endif |
1008 return pItem->iRedrawCounter == 0; | 1008 return pItem->iRedrawCounter == 0; |
1009 } | 1009 } |
1010 static void FWL_WriteBMP(CFX_DIBitmap* pBitmap, const FX_CHAR* filename) { | |
1011 FILE* file = fopen(filename, "wb"); | |
1012 if (file == NULL) { | |
1013 return; | |
1014 } | |
1015 int size = 14 + 40 + pBitmap->GetPitch() * pBitmap->GetHeight(); | |
1016 unsigned char buffer[40]; | |
1017 buffer[0] = 'B'; | |
1018 buffer[1] = 'M'; | |
1019 buffer[2] = (unsigned char)size; | |
1020 buffer[3] = (unsigned char)(size >> 8); | |
1021 buffer[4] = (unsigned char)(size >> 16); | |
1022 buffer[5] = (unsigned char)(size >> 24); | |
1023 buffer[6] = buffer[7] = buffer[8] = buffer[9] = 0; | |
1024 buffer[10] = 54; | |
1025 buffer[11] = buffer[12] = buffer[13] = 0; | |
1026 fwrite(buffer, 14, 1, file); | |
1027 memset(buffer, 0, 40); | |
1028 buffer[0] = 40; | |
1029 buffer[4] = (unsigned char)pBitmap->GetWidth(); | |
1030 buffer[5] = (unsigned char)(pBitmap->GetWidth() >> 8); | |
1031 buffer[6] = (unsigned char)(pBitmap->GetWidth() >> 16); | |
1032 buffer[7] = (unsigned char)(pBitmap->GetWidth() >> 24); | |
1033 buffer[8] = (unsigned char)(-pBitmap->GetHeight()); | |
1034 buffer[9] = (unsigned char)((-pBitmap->GetHeight()) >> 8); | |
1035 buffer[10] = (unsigned char)((-pBitmap->GetHeight()) >> 16); | |
1036 buffer[11] = (unsigned char)((-pBitmap->GetHeight()) >> 24); | |
1037 buffer[12] = 1; | |
1038 buffer[14] = pBitmap->GetBPP(); | |
1039 fwrite(buffer, 40, 1, file); | |
1040 for (int row = 0; row < pBitmap->GetHeight(); row++) { | |
1041 uint8_t* scan_line = pBitmap->GetBuffer() + row * pBitmap->GetPitch(); | |
1042 fwrite(scan_line, pBitmap->GetPitch(), 1, file); | |
1043 } | |
1044 fclose(file); | |
1045 } | |
1046 FWL_ERR FWL_WidgetMgrSnapshot(IFWL_Widget* pWidget, | |
1047 const CFX_WideString* saveFile, | |
1048 const CFX_Matrix* pMatrix) { | |
1049 CFX_RectF r; | |
1050 pWidget->GetWidgetRect(r); | |
1051 CFX_Graphics gs; | |
1052 gs.Create((int32_t)r.width, (int32_t)r.height, FXDIB_Argb); | |
1053 CFWL_WidgetMgr* widgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); | |
1054 CFWL_WidgetMgrDelegate* delegate = widgetMgr->GetDelegate(); | |
1055 delegate->OnDrawWidget(pWidget, &gs, pMatrix); | |
1056 CFX_DIBitmap* dib = gs.GetRenderDevice()->GetBitmap(); | |
1057 FWL_WriteBMP(dib, saveFile->UTF8Encode()); | |
1058 return FWL_ERR_Succeeded; | |
1059 } | |
1060 FX_BOOL FWL_WidgetIsChild(IFWL_Widget* parent, IFWL_Widget* find) { | 1010 FX_BOOL FWL_WidgetIsChild(IFWL_Widget* parent, IFWL_Widget* find) { |
1061 if (!find) { | 1011 if (!find) { |
1062 return FALSE; | 1012 return FALSE; |
1063 } | 1013 } |
1064 IFWL_Widget* child = | 1014 IFWL_Widget* child = |
1065 FWL_GetWidgetMgr()->GetWidget(parent, FWL_WGTRELATION_FirstChild); | 1015 FWL_GetWidgetMgr()->GetWidget(parent, FWL_WGTRELATION_FirstChild); |
1066 while (child) { | 1016 while (child) { |
1067 if (child == find) { | 1017 if (child == find) { |
1068 return TRUE; | 1018 return TRUE; |
1069 } | 1019 } |
1070 if (FWL_WidgetIsChild(child, find)) { | 1020 if (FWL_WidgetIsChild(child, find)) { |
1071 return TRUE; | 1021 return TRUE; |
1072 } | 1022 } |
1073 child = FWL_GetWidgetMgr()->GetWidget(child, FWL_WGTRELATION_NextSibling); | 1023 child = FWL_GetWidgetMgr()->GetWidget(child, FWL_WGTRELATION_NextSibling); |
1074 } | 1024 } |
1075 return FALSE; | 1025 return FALSE; |
1076 } | 1026 } |
OLD | NEW |