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 <map> | 7 #include <map> |
8 | 8 |
9 #include "../../include/pdfwindow/PDFWindow.h" | 9 #include "../../include/pdfwindow/PDFWindow.h" |
10 #include "../../include/pdfwindow/PWL_Wnd.h" | 10 #include "../../include/pdfwindow/PWL_Wnd.h" |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 646 |
647 CPDF_Rect CPWL_Wnd::GetWindowRect() const | 647 CPDF_Rect CPWL_Wnd::GetWindowRect() const |
648 { | 648 { |
649 return m_rcWindow; | 649 return m_rcWindow; |
650 } | 650 } |
651 | 651 |
652 CPDF_Rect CPWL_Wnd::GetClientRect() const | 652 CPDF_Rect CPWL_Wnd::GetClientRect() const |
653 { | 653 { |
654 CPDF_Rect rcWindow = GetWindowRect(); | 654 CPDF_Rect rcWindow = GetWindowRect(); |
655 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow,(FX_FLOAT)(GetBord
erWidth()+GetInnerBorderWidth())); | 655 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow,(FX_FLOAT)(GetBord
erWidth()+GetInnerBorderWidth())); |
656 | 656 » if (CPWL_ScrollBar* pVSB = GetVScrollBar()) |
657 » if (CPWL_ScrollBar * pVSB = GetVScrollBar()) | |
658 rcClient.right -= pVSB->GetScrollBarWidth(); | 657 rcClient.right -= pVSB->GetScrollBarWidth(); |
659 | 658 |
660 rcClient.Normalize(); | 659 rcClient.Normalize(); |
661 | 660 » return rcWindow.Contains(rcClient) ? rcClient : CPDF_Rect(); |
662 » if (rcWindow.Contains(rcClient)) | |
663 » » return rcClient; | |
664 » else | |
665 » » return CPDF_Rect(); | |
666 } | 661 } |
667 | 662 |
668 CPDF_Point CPWL_Wnd::GetCenterPoint() const | 663 CPDF_Point CPWL_Wnd::GetCenterPoint() const |
669 { | 664 { |
670 CPDF_Rect rcClient = GetClientRect(); | 665 CPDF_Rect rcClient = GetClientRect(); |
671 | |
672 return CPDF_Point((rcClient.left + rcClient.right) * 0.5f, | 666 return CPDF_Point((rcClient.left + rcClient.right) * 0.5f, |
673 » » (rcClient.top + rcClient.bottom) * 0.5f); | 667 (rcClient.top + rcClient.bottom) * 0.5f); |
674 } | 668 } |
675 | 669 |
676 CPDF_Rect CPWL_Wnd::GetClientCenterSquare() const | 670 CPDF_Rect CPWL_Wnd::GetClientCenterSquare() const |
677 { | 671 { |
678 return CPWL_Utils::GetCenterSquare(GetClientRect()); | 672 return CPWL_Utils::GetCenterSquare(GetClientRect()); |
679 } | 673 } |
680 | 674 |
681 CPDF_Rect CPWL_Wnd::GetWindowCenterSquare() const | 675 CPDF_Rect CPWL_Wnd::GetWindowCenterSquare() const |
682 { | 676 { |
683 return CPWL_Utils::GetCenterSquare(CPWL_Utils::DeflateRect(GetWindowRect
(),0.1f)); | 677 return CPWL_Utils::GetCenterSquare(CPWL_Utils::DeflateRect(GetWindowRect
(),0.1f)); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 FX_BOOL CPWL_Wnd::WndHitTest(const CPDF_Point & point) const | 868 FX_BOOL CPWL_Wnd::WndHitTest(const CPDF_Point & point) const |
875 { | 869 { |
876 return IsValid() && IsVisible() && GetWindowRect().Contains(point.x,poin
t.y); | 870 return IsValid() && IsVisible() && GetWindowRect().Contains(point.x,poin
t.y); |
877 } | 871 } |
878 | 872 |
879 FX_BOOL CPWL_Wnd::ClientHitTest(const CPDF_Point & point) const | 873 FX_BOOL CPWL_Wnd::ClientHitTest(const CPDF_Point & point) const |
880 { | 874 { |
881 return IsValid() && IsVisible() && GetClientRect().Contains(point.x,poin
t.y); | 875 return IsValid() && IsVisible() && GetClientRect().Contains(point.x,poin
t.y); |
882 } | 876 } |
883 | 877 |
884 const CPWL_Wnd * CPWL_Wnd::GetRootWnd() const | 878 const CPWL_Wnd* CPWL_Wnd::GetRootWnd() const |
885 { | 879 { |
886 if (m_sPrivateParam.pParentWnd) | 880 if (m_sPrivateParam.pParentWnd) |
887 return m_sPrivateParam.pParentWnd->GetRootWnd(); | 881 return m_sPrivateParam.pParentWnd->GetRootWnd(); |
888 » else | 882 |
889 » » return this; | 883 return this; |
890 } | 884 } |
891 | 885 |
892 void CPWL_Wnd::SetVisible(FX_BOOL bVisible) | 886 void CPWL_Wnd::SetVisible(FX_BOOL bVisible) |
893 { | 887 { |
894 if (IsValid()) | 888 if (IsValid()) |
895 { | 889 { |
896 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++) | 890 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++) |
897 { | 891 { |
898 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) | 892 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) |
899 { | 893 { |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 FX_HWND CPWL_Wnd::GetAttachedHWnd() const | 1131 FX_HWND CPWL_Wnd::GetAttachedHWnd() const |
1138 { | 1132 { |
1139 return m_sPrivateParam.hAttachedWnd; | 1133 return m_sPrivateParam.hAttachedWnd; |
1140 } | 1134 } |
1141 | 1135 |
1142 CPDF_Point CPWL_Wnd::ChildToParent(const CPDF_Point& point) const | 1136 CPDF_Point CPWL_Wnd::ChildToParent(const CPDF_Point& point) const |
1143 { | 1137 { |
1144 CPDF_Matrix mt = GetChildMatrix(); | 1138 CPDF_Matrix mt = GetChildMatrix(); |
1145 if (mt.IsIdentity()) | 1139 if (mt.IsIdentity()) |
1146 return point; | 1140 return point; |
1147 » else | 1141 |
1148 » { | 1142 CPDF_Point pt = point; |
1149 » » CPDF_Point pt = point; | 1143 mt.Transform(pt.x,pt.y); |
1150 » » mt.Transform(pt.x,pt.y); | 1144 return pt; |
1151 » » return pt; | |
1152 » } | |
1153 } | 1145 } |
1154 | 1146 |
1155 CPDF_Rect CPWL_Wnd::ChildToParent(const CPDF_Rect& rect) const | 1147 CPDF_Rect CPWL_Wnd::ChildToParent(const CPDF_Rect& rect) const |
1156 { | 1148 { |
1157 CPDF_Matrix mt = GetChildMatrix(); | 1149 CPDF_Matrix mt = GetChildMatrix(); |
1158 if (mt.IsIdentity()) | 1150 if (mt.IsIdentity()) |
1159 return rect; | 1151 return rect; |
1160 » else | 1152 |
1161 » { | 1153 CPDF_Rect rc = rect; |
1162 » » CPDF_Rect rc = rect; | 1154 mt.TransformRect(rc); |
1163 » » mt.TransformRect(rc); | 1155 return rc; |
1164 » » return rc; | |
1165 » } | |
1166 } | 1156 } |
1167 | 1157 |
1168 CPDF_Point CPWL_Wnd::ParentToChild(const CPDF_Point& point) const | 1158 CPDF_Point CPWL_Wnd::ParentToChild(const CPDF_Point& point) const |
1169 { | 1159 { |
1170 CPDF_Matrix mt = GetChildMatrix(); | 1160 CPDF_Matrix mt = GetChildMatrix(); |
1171 if (mt.IsIdentity()) | 1161 if (mt.IsIdentity()) |
1172 return point; | 1162 return point; |
1173 » else | 1163 |
1174 » { | 1164 mt.SetReverse(mt); |
1175 » » mt.SetReverse(mt); | 1165 CPDF_Point pt = point; |
1176 » » CPDF_Point pt = point; | 1166 mt.Transform(pt.x,pt.y); |
1177 » » mt.Transform(pt.x,pt.y); | 1167 return pt; |
1178 » » return pt; | |
1179 » } | |
1180 } | 1168 } |
1181 | 1169 |
1182 CPDF_Rect CPWL_Wnd::ParentToChild(const CPDF_Rect& rect) const | 1170 CPDF_Rect CPWL_Wnd::ParentToChild(const CPDF_Rect& rect) const |
1183 { | 1171 { |
1184 CPDF_Matrix mt = GetChildMatrix(); | 1172 CPDF_Matrix mt = GetChildMatrix(); |
1185 if (mt.IsIdentity()) | 1173 if (mt.IsIdentity()) |
1186 return rect; | 1174 return rect; |
1187 » else | 1175 |
1188 » { | 1176 mt.SetReverse(mt); |
1189 » » mt.SetReverse(mt); | 1177 CPDF_Rect rc = rect; |
1190 » » CPDF_Rect rc = rect; | 1178 mt.TransformRect(rc); |
1191 » » mt.TransformRect(rc); | 1179 return rc; |
1192 » » return rc; | |
1193 » } | |
1194 } | 1180 } |
1195 | 1181 |
1196 CPDF_Matrix CPWL_Wnd::GetChildToRoot() const | 1182 CPDF_Matrix CPWL_Wnd::GetChildToRoot() const |
1197 { | 1183 { |
1198 » CPDF_Matrix mt(1,0,0,1,0,0); | 1184 » CPDF_Matrix mt(1, 0, 0, 1, 0, 0); |
1199 | |
1200 if (HasFlag(PWS_CHILD)) | 1185 if (HasFlag(PWS_CHILD)) |
1201 { | 1186 { |
1202 const CPWL_Wnd* pParent = this; | 1187 const CPWL_Wnd* pParent = this; |
1203 while (pParent) | 1188 while (pParent) |
1204 { | 1189 { |
1205 mt.Concat(pParent->GetChildMatrix()); | 1190 mt.Concat(pParent->GetChildMatrix()); |
1206 pParent = pParent->GetParentWindow(); | 1191 pParent = pParent->GetParentWindow(); |
1207 } | 1192 } |
1208 } | 1193 } |
1209 | |
1210 return mt; | 1194 return mt; |
1211 } | 1195 } |
1212 | 1196 |
1213 CPDF_Matrix CPWL_Wnd::GetChildMatrix() const | 1197 CPDF_Matrix CPWL_Wnd::GetChildMatrix() const |
1214 { | 1198 { |
1215 if (HasFlag(PWS_CHILD)) | 1199 if (HasFlag(PWS_CHILD)) |
1216 return m_sPrivateParam.mtChild; | 1200 return m_sPrivateParam.mtChild; |
1217 | 1201 |
1218 return CPDF_Matrix(1,0,0,1,0,0); | 1202 return CPDF_Matrix(1,0,0,1,0,0); |
1219 } | 1203 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const | 1284 FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const |
1301 { | 1285 { |
1302 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) | 1286 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) |
1303 { | 1287 { |
1304 return pSystemHandler->IsINSERTKeyDown(nFlag); | 1288 return pSystemHandler->IsINSERTKeyDown(nFlag); |
1305 } | 1289 } |
1306 | 1290 |
1307 return FALSE; | 1291 return FALSE; |
1308 } | 1292 } |
1309 | 1293 |
OLD | NEW |