Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: fpdfsdk/src/pdfwindow/PWL_Wnd.cpp

Issue 1519693002: Merge to XFA: Remove CFX_AffineMatrix/CPDF_Matrix (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: XFA-specific changes Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "fpdfsdk/include/pdfwindow/PDFWindow.h" 9 #include "fpdfsdk/include/pdfwindow/PDFWindow.h"
10 #include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h" 10 #include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 m_rcClip = CPWL_Utils::InflateRect(m_rcWindow, 1.0f); 217 m_rcClip = CPWL_Utils::InflateRect(m_rcWindow, 1.0f);
218 218
219 CreateMsgControl(); 219 CreateMsgControl();
220 220
221 if (m_sPrivateParam.pParentWnd) 221 if (m_sPrivateParam.pParentWnd)
222 m_sPrivateParam.pParentWnd->OnNotify(this, PNM_ADDCHILD); 222 m_sPrivateParam.pParentWnd->OnNotify(this, PNM_ADDCHILD);
223 223
224 PWL_CREATEPARAM ccp = m_sPrivateParam; 224 PWL_CREATEPARAM ccp = m_sPrivateParam;
225 225
226 ccp.dwFlags &= 0xFFFF0000L; // remove sub styles 226 ccp.dwFlags &= 0xFFFF0000L; // remove sub styles
227 ccp.mtChild = CPDF_Matrix(1, 0, 0, 1, 0, 0); 227 ccp.mtChild = CFX_Matrix(1, 0, 0, 1, 0, 0);
228 228
229 CreateScrollBar(ccp); 229 CreateScrollBar(ccp);
230 CreateChildWnd(ccp); 230 CreateChildWnd(ccp);
231 231
232 m_bVisible = HasFlag(PWS_VISIBLE); 232 m_bVisible = HasFlag(PWS_VISIBLE);
233 233
234 OnCreated(); 234 OnCreated();
235 235
236 RePosChildWnd(); 236 RePosChildWnd();
237 m_bCreated = TRUE; 237 m_bCreated = TRUE;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 337
338 void CPWL_Wnd::GetChildAppearanceStream(CFX_ByteTextBuf& sAppStream) { 338 void CPWL_Wnd::GetChildAppearanceStream(CFX_ByteTextBuf& sAppStream) {
339 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { 339 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
340 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { 340 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
341 pChild->GetAppearanceStream(sAppStream); 341 pChild->GetAppearanceStream(sAppStream);
342 } 342 }
343 } 343 }
344 } 344 }
345 345
346 void CPWL_Wnd::DrawAppearance(CFX_RenderDevice* pDevice, 346 void CPWL_Wnd::DrawAppearance(CFX_RenderDevice* pDevice,
347 CPDF_Matrix* pUser2Device) { 347 CFX_Matrix* pUser2Device) {
348 if (IsValid() && IsVisible()) { 348 if (IsValid() && IsVisible()) {
349 DrawThisAppearance(pDevice, pUser2Device); 349 DrawThisAppearance(pDevice, pUser2Device);
350 DrawChildAppearance(pDevice, pUser2Device); 350 DrawChildAppearance(pDevice, pUser2Device);
351 } 351 }
352 } 352 }
353 353
354 void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice, 354 void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice,
355 CPDF_Matrix* pUser2Device) { 355 CFX_Matrix* pUser2Device) {
356 CPDF_Rect rectWnd = GetWindowRect(); 356 CPDF_Rect rectWnd = GetWindowRect();
357 if (!rectWnd.IsEmpty()) { 357 if (!rectWnd.IsEmpty()) {
358 if (HasFlag(PWS_BACKGROUND)) { 358 if (HasFlag(PWS_BACKGROUND)) {
359 CPDF_Rect rcClient = CPWL_Utils::DeflateRect( 359 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(
360 rectWnd, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); 360 rectWnd, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth()));
361 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient, 361 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient,
362 GetBackgroundColor(), GetTransparency()); 362 GetBackgroundColor(), GetTransparency());
363 } 363 }
364 364
365 if (HasFlag(PWS_BORDER)) 365 if (HasFlag(PWS_BORDER))
366 CPWL_Utils::DrawBorder( 366 CPWL_Utils::DrawBorder(
367 pDevice, pUser2Device, rectWnd, (FX_FLOAT)GetBorderWidth(), 367 pDevice, pUser2Device, rectWnd, (FX_FLOAT)GetBorderWidth(),
368 GetBorderColor(), GetBorderLeftTopColor(GetBorderStyle()), 368 GetBorderColor(), GetBorderLeftTopColor(GetBorderStyle()),
369 GetBorderRightBottomColor(GetBorderStyle()), GetBorderStyle(), 369 GetBorderRightBottomColor(GetBorderStyle()), GetBorderStyle(),
370 GetBorderDash(), GetTransparency()); 370 GetBorderDash(), GetTransparency());
371 } 371 }
372 } 372 }
373 373
374 void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice, 374 void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice,
375 CPDF_Matrix* pUser2Device) { 375 CFX_Matrix* pUser2Device) {
376 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { 376 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
377 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { 377 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
378 CPDF_Matrix mt = pChild->GetChildMatrix(); 378 CFX_Matrix mt = pChild->GetChildMatrix();
379 if (mt.IsIdentity()) { 379 if (mt.IsIdentity()) {
380 pChild->DrawAppearance(pDevice, pUser2Device); 380 pChild->DrawAppearance(pDevice, pUser2Device);
381 } else { 381 } else {
382 mt.Concat(*pUser2Device); 382 mt.Concat(*pUser2Device);
383 pChild->DrawAppearance(pDevice, &mt); 383 pChild->DrawAppearance(pDevice, &mt);
384 } 384 }
385 } 385 }
386 } 386 }
387 } 387 }
388 388
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 void CPWL_Wnd::SetTransparency(int32_t nTransparency) { 911 void CPWL_Wnd::SetTransparency(int32_t nTransparency) {
912 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { 912 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
913 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { 913 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
914 pChild->SetTransparency(nTransparency); 914 pChild->SetTransparency(nTransparency);
915 } 915 }
916 } 916 }
917 917
918 m_sPrivateParam.nTransparency = nTransparency; 918 m_sPrivateParam.nTransparency = nTransparency;
919 } 919 }
920 920
921 CPDF_Matrix CPWL_Wnd::GetWindowMatrix() const { 921 CFX_Matrix CPWL_Wnd::GetWindowMatrix() const {
922 CPDF_Matrix mt = GetChildToRoot(); 922 CFX_Matrix mt = GetChildToRoot();
923 923
924 if (IPWL_Provider* pProvider = GetProvider()) { 924 if (IPWL_Provider* pProvider = GetProvider()) {
925 mt.Concat(pProvider->GetWindowMatrix(GetAttachedData())); 925 mt.Concat(pProvider->GetWindowMatrix(GetAttachedData()));
926 return mt; 926 return mt;
927 } 927 }
928 928
929 return mt; 929 return mt;
930 } 930 }
931 931
932 void CPWL_Wnd::PWLtoWnd(const CPDF_Point& point, int32_t& x, int32_t& y) const { 932 void CPWL_Wnd::PWLtoWnd(const CPDF_Point& point, int32_t& x, int32_t& y) const {
933 CPDF_Matrix mt = GetWindowMatrix(); 933 CFX_Matrix mt = GetWindowMatrix();
934 CPDF_Point pt = point; 934 CPDF_Point pt = point;
935 mt.Transform(pt.x, pt.y); 935 mt.Transform(pt.x, pt.y);
936 x = (int32_t)(pt.x + 0.5); 936 x = (int32_t)(pt.x + 0.5);
937 y = (int32_t)(pt.y + 0.5); 937 y = (int32_t)(pt.y + 0.5);
938 } 938 }
939 939
940 FX_RECT CPWL_Wnd::PWLtoWnd(const CPDF_Rect& rect) const { 940 FX_RECT CPWL_Wnd::PWLtoWnd(const CPDF_Rect& rect) const {
941 CPDF_Rect rcTemp = rect; 941 CPDF_Rect rcTemp = rect;
942 CPDF_Matrix mt = GetWindowMatrix(); 942 CFX_Matrix mt = GetWindowMatrix();
943 mt.TransformRect(rcTemp); 943 mt.TransformRect(rcTemp);
944 return FX_RECT((int32_t)(rcTemp.left + 0.5), (int32_t)(rcTemp.bottom + 0.5), 944 return FX_RECT((int32_t)(rcTemp.left + 0.5), (int32_t)(rcTemp.bottom + 0.5),
945 (int32_t)(rcTemp.right + 0.5), (int32_t)(rcTemp.top + 0.5)); 945 (int32_t)(rcTemp.right + 0.5), (int32_t)(rcTemp.top + 0.5));
946 } 946 }
947 947
948 FX_HWND CPWL_Wnd::GetAttachedHWnd() const { 948 FX_HWND CPWL_Wnd::GetAttachedHWnd() const {
949 return m_sPrivateParam.hAttachedWnd; 949 return m_sPrivateParam.hAttachedWnd;
950 } 950 }
951 951
952 CPDF_Point CPWL_Wnd::ChildToParent(const CPDF_Point& point) const { 952 CPDF_Point CPWL_Wnd::ChildToParent(const CPDF_Point& point) const {
953 CPDF_Matrix mt = GetChildMatrix(); 953 CFX_Matrix mt = GetChildMatrix();
954 if (mt.IsIdentity()) 954 if (mt.IsIdentity())
955 return point; 955 return point;
956 956
957 CPDF_Point pt = point; 957 CPDF_Point pt = point;
958 mt.Transform(pt.x, pt.y); 958 mt.Transform(pt.x, pt.y);
959 return pt; 959 return pt;
960 } 960 }
961 961
962 CPDF_Rect CPWL_Wnd::ChildToParent(const CPDF_Rect& rect) const { 962 CPDF_Rect CPWL_Wnd::ChildToParent(const CPDF_Rect& rect) const {
963 CPDF_Matrix mt = GetChildMatrix(); 963 CFX_Matrix mt = GetChildMatrix();
964 if (mt.IsIdentity()) 964 if (mt.IsIdentity())
965 return rect; 965 return rect;
966 966
967 CPDF_Rect rc = rect; 967 CPDF_Rect rc = rect;
968 mt.TransformRect(rc); 968 mt.TransformRect(rc);
969 return rc; 969 return rc;
970 } 970 }
971 971
972 CPDF_Point CPWL_Wnd::ParentToChild(const CPDF_Point& point) const { 972 CPDF_Point CPWL_Wnd::ParentToChild(const CPDF_Point& point) const {
973 CPDF_Matrix mt = GetChildMatrix(); 973 CFX_Matrix mt = GetChildMatrix();
974 if (mt.IsIdentity()) 974 if (mt.IsIdentity())
975 return point; 975 return point;
976 976
977 mt.SetReverse(mt); 977 mt.SetReverse(mt);
978 CPDF_Point pt = point; 978 CPDF_Point pt = point;
979 mt.Transform(pt.x, pt.y); 979 mt.Transform(pt.x, pt.y);
980 return pt; 980 return pt;
981 } 981 }
982 982
983 CPDF_Rect CPWL_Wnd::ParentToChild(const CPDF_Rect& rect) const { 983 CPDF_Rect CPWL_Wnd::ParentToChild(const CPDF_Rect& rect) const {
984 CPDF_Matrix mt = GetChildMatrix(); 984 CFX_Matrix mt = GetChildMatrix();
985 if (mt.IsIdentity()) 985 if (mt.IsIdentity())
986 return rect; 986 return rect;
987 987
988 mt.SetReverse(mt); 988 mt.SetReverse(mt);
989 CPDF_Rect rc = rect; 989 CPDF_Rect rc = rect;
990 mt.TransformRect(rc); 990 mt.TransformRect(rc);
991 return rc; 991 return rc;
992 } 992 }
993 993
994 CPDF_Matrix CPWL_Wnd::GetChildToRoot() const { 994 CFX_Matrix CPWL_Wnd::GetChildToRoot() const {
995 CPDF_Matrix mt(1, 0, 0, 1, 0, 0); 995 CFX_Matrix mt(1, 0, 0, 1, 0, 0);
996 if (HasFlag(PWS_CHILD)) { 996 if (HasFlag(PWS_CHILD)) {
997 const CPWL_Wnd* pParent = this; 997 const CPWL_Wnd* pParent = this;
998 while (pParent) { 998 while (pParent) {
999 mt.Concat(pParent->GetChildMatrix()); 999 mt.Concat(pParent->GetChildMatrix());
1000 pParent = pParent->GetParentWindow(); 1000 pParent = pParent->GetParentWindow();
1001 } 1001 }
1002 } 1002 }
1003 return mt; 1003 return mt;
1004 } 1004 }
1005 1005
1006 CPDF_Matrix CPWL_Wnd::GetChildMatrix() const { 1006 CFX_Matrix CPWL_Wnd::GetChildMatrix() const {
1007 if (HasFlag(PWS_CHILD)) 1007 if (HasFlag(PWS_CHILD))
1008 return m_sPrivateParam.mtChild; 1008 return m_sPrivateParam.mtChild;
1009 1009
1010 return CPDF_Matrix(1, 0, 0, 1, 0, 0); 1010 return CFX_Matrix(1, 0, 0, 1, 0, 0);
1011 } 1011 }
1012 1012
1013 void CPWL_Wnd::SetChildMatrix(const CPDF_Matrix& mt) { 1013 void CPWL_Wnd::SetChildMatrix(const CFX_Matrix& mt) {
1014 m_sPrivateParam.mtChild = mt; 1014 m_sPrivateParam.mtChild = mt;
1015 } 1015 }
1016 1016
1017 const CPWL_Wnd* CPWL_Wnd::GetFocused() const { 1017 const CPWL_Wnd* CPWL_Wnd::GetFocused() const {
1018 if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) { 1018 if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) {
1019 return pMsgCtrl->m_pMainKeyboardWnd; 1019 return pMsgCtrl->m_pMainKeyboardWnd;
1020 } 1020 }
1021 1021
1022 return NULL; 1022 return NULL;
1023 } 1023 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 return FALSE; 1071 return FALSE;
1072 } 1072 }
1073 1073
1074 FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const { 1074 FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const {
1075 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) { 1075 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
1076 return pSystemHandler->IsINSERTKeyDown(nFlag); 1076 return pSystemHandler->IsINSERTKeyDown(nFlag);
1077 } 1077 }
1078 1078
1079 return FALSE; 1079 return FALSE;
1080 } 1080 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698