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 "fpdfsdk/pdfwindow/PWL_Note.h" | 7 #include "fpdfsdk/pdfwindow/PWL_Note.h" |
8 | 8 |
9 #include "core/include/fxge/fx_ge.h" | 9 #include "core/include/fxge/fx_ge.h" |
10 #include "fpdfsdk/pdfwindow/PWL_Button.h" | 10 #include "fpdfsdk/pdfwindow/PWL_Button.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pGrand; | 145 CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pGrand; |
146 | 146 |
147 pNoteItem->OnContentsValidate(); | 147 pNoteItem->OnContentsValidate(); |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 CPWL_Edit::OnKillFocus(); | 151 CPWL_Edit::OnKillFocus(); |
152 } | 152 } |
153 | 153 |
154 void CPWL_Note_Edit::OnNotify(CPWL_Wnd* pWnd, | 154 void CPWL_Note_Edit::OnNotify(CPWL_Wnd* pWnd, |
155 FX_DWORD msg, | 155 uint32_t msg, |
156 intptr_t wParam, | 156 intptr_t wParam, |
157 intptr_t lParam) { | 157 intptr_t lParam) { |
158 if (m_bEnableNotify) { | 158 if (m_bEnableNotify) { |
159 if (wParam == SBT_VSCROLL) { | 159 if (wParam == SBT_VSCROLL) { |
160 switch (msg) { | 160 switch (msg) { |
161 case PNM_SETSCROLLINFO: | 161 case PNM_SETSCROLLINFO: |
162 if (PWL_SCROLL_INFO* pInfo = (PWL_SCROLL_INFO*)lParam) { | 162 if (PWL_SCROLL_INFO* pInfo = (PWL_SCROLL_INFO*)lParam) { |
163 if (!IsFloatEqual(pInfo->fContentMax, m_fOldMax) || | 163 if (!IsFloatEqual(pInfo->fContentMax, m_fOldMax) || |
164 !IsFloatEqual(pInfo->fContentMin, m_fOldMin)) { | 164 !IsFloatEqual(pInfo->fContentMin, m_fOldMin)) { |
165 m_bSizeChanged = TRUE; | 165 m_bSizeChanged = TRUE; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 pathCross.SetPoint(2, rcClient.left, rcClient.top, FXPT_MOVETO); | 326 pathCross.SetPoint(2, rcClient.left, rcClient.top, FXPT_MOVETO); |
327 pathCross.SetPoint(3, rcClient.right, rcClient.bottom, FXPT_LINETO); | 327 pathCross.SetPoint(3, rcClient.right, rcClient.bottom, FXPT_LINETO); |
328 | 328 |
329 pDevice->DrawPath( | 329 pDevice->DrawPath( |
330 &pathCross, pUser2Device, &gsd, 0, | 330 &pathCross, pUser2Device, &gsd, 0, |
331 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), | 331 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
332 FXFILL_ALTERNATE); | 332 FXFILL_ALTERNATE); |
333 } | 333 } |
334 | 334 |
335 FX_BOOL CPWL_Note_CloseBox::OnLButtonDown(const CFX_FloatPoint& point, | 335 FX_BOOL CPWL_Note_CloseBox::OnLButtonDown(const CFX_FloatPoint& point, |
336 FX_DWORD nFlag) { | 336 uint32_t nFlag) { |
337 SetBorderStyle(PBS_INSET); | 337 SetBorderStyle(PBS_INSET); |
338 InvalidateRect(NULL); | 338 InvalidateRect(NULL); |
339 | 339 |
340 m_bMouseDown = TRUE; | 340 m_bMouseDown = TRUE; |
341 | 341 |
342 return CPWL_Button::OnLButtonDown(point, nFlag); | 342 return CPWL_Button::OnLButtonDown(point, nFlag); |
343 } | 343 } |
344 | 344 |
345 FX_BOOL CPWL_Note_CloseBox::OnLButtonUp(const CFX_FloatPoint& point, | 345 FX_BOOL CPWL_Note_CloseBox::OnLButtonUp(const CFX_FloatPoint& point, |
346 FX_DWORD nFlag) { | 346 uint32_t nFlag) { |
347 m_bMouseDown = FALSE; | 347 m_bMouseDown = FALSE; |
348 | 348 |
349 SetBorderStyle(PBS_BEVELED); | 349 SetBorderStyle(PBS_BEVELED); |
350 InvalidateRect(NULL); | 350 InvalidateRect(NULL); |
351 | 351 |
352 return CPWL_Button::OnLButtonUp(point, nFlag); | 352 return CPWL_Button::OnLButtonUp(point, nFlag); |
353 } | 353 } |
354 | 354 |
355 CPWL_Note_Contents::CPWL_Note_Contents() : m_pEdit(NULL) {} | 355 CPWL_Note_Contents::CPWL_Note_Contents() : m_pEdit(NULL) {} |
356 | 356 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild; | 459 CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild; |
460 if (IPWL_NoteItem* pRet = pNoteItem->GetHitNoteItem(pt)) | 460 if (IPWL_NoteItem* pRet = pNoteItem->GetHitNoteItem(pt)) |
461 return pRet; | 461 return pRet; |
462 } | 462 } |
463 } | 463 } |
464 } | 464 } |
465 return NULL; | 465 return NULL; |
466 } | 466 } |
467 | 467 |
468 void CPWL_Note_Contents::OnNotify(CPWL_Wnd* pWnd, | 468 void CPWL_Note_Contents::OnNotify(CPWL_Wnd* pWnd, |
469 FX_DWORD msg, | 469 uint32_t msg, |
470 intptr_t wParam, | 470 intptr_t wParam, |
471 intptr_t lParam) { | 471 intptr_t lParam) { |
472 switch (msg) { | 472 switch (msg) { |
473 case PNM_NOTEEDITCHANGED: { | 473 case PNM_NOTEEDITCHANGED: { |
474 int32_t nIndex = GetItemIndex(pWnd); | 474 int32_t nIndex = GetItemIndex(pWnd); |
475 if (nIndex < 0) | 475 if (nIndex < 0) |
476 nIndex = 0; | 476 nIndex = 0; |
477 | 477 |
478 m_pEdit->EnableNotify(FALSE); | 478 m_pEdit->EnableNotify(FALSE); |
479 ResetContent(nIndex); | 479 ResetContent(nIndex); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 ResetContent(0); | 520 ResetContent(0); |
521 m_pEdit->EnableNotify(TRUE); | 521 m_pEdit->EnableNotify(TRUE); |
522 } | 522 } |
523 return; | 523 return; |
524 } | 524 } |
525 | 525 |
526 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); | 526 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); |
527 } | 527 } |
528 | 528 |
529 FX_BOOL CPWL_Note_Contents::OnLButtonDown(const CFX_FloatPoint& point, | 529 FX_BOOL CPWL_Note_Contents::OnLButtonDown(const CFX_FloatPoint& point, |
530 FX_DWORD nFlag) { | 530 uint32_t nFlag) { |
531 if (CPWL_Wnd::OnLButtonDown(point, nFlag)) | 531 if (CPWL_Wnd::OnLButtonDown(point, nFlag)) |
532 return TRUE; | 532 return TRUE; |
533 | 533 |
534 if (!m_pEdit->IsFocused()) { | 534 if (!m_pEdit->IsFocused()) { |
535 m_pEdit->SetFocus(); | 535 m_pEdit->SetFocus(); |
536 } | 536 } |
537 | 537 |
538 return TRUE; | 538 return TRUE; |
539 } | 539 } |
540 | 540 |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 | 905 |
906 FX_FLOAT CPWL_NoteItem::GetItemLeftMargin() { | 906 FX_FLOAT CPWL_NoteItem::GetItemLeftMargin() { |
907 return POPUP_ITEM_SIDEMARGIN; | 907 return POPUP_ITEM_SIDEMARGIN; |
908 } | 908 } |
909 | 909 |
910 FX_FLOAT CPWL_NoteItem::GetItemRightMargin() { | 910 FX_FLOAT CPWL_NoteItem::GetItemRightMargin() { |
911 return POPUP_ITEM_SIDEMARGIN; | 911 return POPUP_ITEM_SIDEMARGIN; |
912 } | 912 } |
913 | 913 |
914 FX_BOOL CPWL_NoteItem::OnLButtonDown(const CFX_FloatPoint& point, | 914 FX_BOOL CPWL_NoteItem::OnLButtonDown(const CFX_FloatPoint& point, |
915 FX_DWORD nFlag) { | 915 uint32_t nFlag) { |
916 if (!m_pContents->WndHitTest(m_pContents->ParentToChild(point))) { | 916 if (!m_pContents->WndHitTest(m_pContents->ParentToChild(point))) { |
917 SetNoteFocus(FALSE); | 917 SetNoteFocus(FALSE); |
918 } | 918 } |
919 | 919 |
920 CPWL_Wnd::OnLButtonDown(point, nFlag); | 920 CPWL_Wnd::OnLButtonDown(point, nFlag); |
921 | 921 |
922 return TRUE; | 922 return TRUE; |
923 } | 923 } |
924 | 924 |
925 FX_BOOL CPWL_NoteItem::OnRButtonUp(const CFX_FloatPoint& point, | 925 FX_BOOL CPWL_NoteItem::OnRButtonUp(const CFX_FloatPoint& point, |
926 FX_DWORD nFlag) { | 926 uint32_t nFlag) { |
927 if (!m_pContents->WndHitTest(m_pContents->ParentToChild(point))) { | 927 if (!m_pContents->WndHitTest(m_pContents->ParentToChild(point))) { |
928 SetNoteFocus(FALSE); | 928 SetNoteFocus(FALSE); |
929 PopupNoteItemMenu(point); | 929 PopupNoteItemMenu(point); |
930 | 930 |
931 return TRUE; | 931 return TRUE; |
932 } | 932 } |
933 | 933 |
934 return CPWL_Wnd::OnRButtonUp(point, nFlag); | 934 return CPWL_Wnd::OnRButtonUp(point, nFlag); |
935 } | 935 } |
936 | 936 |
937 void CPWL_NoteItem::OnNotify(CPWL_Wnd* pWnd, | 937 void CPWL_NoteItem::OnNotify(CPWL_Wnd* pWnd, |
938 FX_DWORD msg, | 938 uint32_t msg, |
939 intptr_t wParam, | 939 intptr_t wParam, |
940 intptr_t lParam) { | 940 intptr_t lParam) { |
941 switch (msg) { | 941 switch (msg) { |
942 case PNM_NOTEEDITCHANGED: | 942 case PNM_NOTEEDITCHANGED: |
943 m_bSizeChanged = TRUE; | 943 m_bSizeChanged = TRUE; |
944 | 944 |
945 if (CPWL_Wnd* pParent = GetParentWindow()) { | 945 if (CPWL_Wnd* pParent = GetParentWindow()) { |
946 pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0); | 946 pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0); |
947 } | 947 } |
948 return; | 948 return; |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1295 | 1295 |
1296 CFX_WideString CPWL_Note::GetAuthorName() const { | 1296 CFX_WideString CPWL_Note::GetAuthorName() const { |
1297 if (m_pAuthor) | 1297 if (m_pAuthor) |
1298 return m_pAuthor->GetText(); | 1298 return m_pAuthor->GetText(); |
1299 | 1299 |
1300 return L""; | 1300 return L""; |
1301 } | 1301 } |
1302 | 1302 |
1303 FX_BOOL CPWL_Note::OnMouseWheel(short zDelta, | 1303 FX_BOOL CPWL_Note::OnMouseWheel(short zDelta, |
1304 const CFX_FloatPoint& point, | 1304 const CFX_FloatPoint& point, |
1305 FX_DWORD nFlag) { | 1305 uint32_t nFlag) { |
1306 CFX_FloatPoint ptScroll = m_pContents->GetScrollPos(); | 1306 CFX_FloatPoint ptScroll = m_pContents->GetScrollPos(); |
1307 CFX_FloatRect rcScroll = m_pContents->GetScrollArea(); | 1307 CFX_FloatRect rcScroll = m_pContents->GetScrollArea(); |
1308 CFX_FloatRect rcContents = m_pContents->GetClientRect(); | 1308 CFX_FloatRect rcContents = m_pContents->GetClientRect(); |
1309 | 1309 |
1310 if (rcScroll.top - rcScroll.bottom > rcContents.Height()) { | 1310 if (rcScroll.top - rcScroll.bottom > rcContents.Height()) { |
1311 CFX_FloatPoint ptNew = ptScroll; | 1311 CFX_FloatPoint ptNew = ptScroll; |
1312 | 1312 |
1313 if (zDelta > 0) | 1313 if (zDelta > 0) |
1314 ptNew.y += 30; | 1314 ptNew.y += 30; |
1315 else | 1315 else |
(...skipping 14 matching lines...) Expand all Loading... |
1330 (intptr_t)&ptNew.y); | 1330 (intptr_t)&ptNew.y); |
1331 | 1331 |
1332 return TRUE; | 1332 return TRUE; |
1333 } | 1333 } |
1334 } | 1334 } |
1335 | 1335 |
1336 return FALSE; | 1336 return FALSE; |
1337 } | 1337 } |
1338 | 1338 |
1339 void CPWL_Note::OnNotify(CPWL_Wnd* pWnd, | 1339 void CPWL_Note::OnNotify(CPWL_Wnd* pWnd, |
1340 FX_DWORD msg, | 1340 uint32_t msg, |
1341 intptr_t wParam, | 1341 intptr_t wParam, |
1342 intptr_t lParam) { | 1342 intptr_t lParam) { |
1343 switch (msg) { | 1343 switch (msg) { |
1344 case PNM_NOTEEDITCHANGED: { | 1344 case PNM_NOTEEDITCHANGED: { |
1345 CFX_FloatRect rcScroll = m_pContents->GetScrollArea(); | 1345 CFX_FloatRect rcScroll = m_pContents->GetScrollArea(); |
1346 | 1346 |
1347 PWL_SCROLL_INFO sInfo; | 1347 PWL_SCROLL_INFO sInfo; |
1348 sInfo.fContentMin = rcScroll.bottom; | 1348 sInfo.fContentMin = rcScroll.bottom; |
1349 sInfo.fContentMax = rcScroll.top; | 1349 sInfo.fContentMax = rcScroll.top; |
1350 sInfo.fPlateWidth = m_pContents->GetClientRect().Height(); | 1350 sInfo.fPlateWidth = m_pContents->GetClientRect().Height(); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1455 if (m_pAuthor) | 1455 if (m_pAuthor) |
1456 m_pAuthor->SetTextColor(sTextColor); | 1456 m_pAuthor->SetTextColor(sTextColor); |
1457 if (m_pOptions) | 1457 if (m_pOptions) |
1458 m_pOptions->SetTextColor(sTextColor); | 1458 m_pOptions->SetTextColor(sTextColor); |
1459 if (m_pLBBox) | 1459 if (m_pLBBox) |
1460 m_pLBBox->SetTextColor(sTextColor); | 1460 m_pLBBox->SetTextColor(sTextColor); |
1461 if (m_pRBBox) | 1461 if (m_pRBBox) |
1462 m_pRBBox->SetTextColor(sTextColor); | 1462 m_pRBBox->SetTextColor(sTextColor); |
1463 } | 1463 } |
1464 | 1464 |
1465 FX_BOOL CPWL_Note::OnLButtonDown(const CFX_FloatPoint& point, FX_DWORD nFlag) { | 1465 FX_BOOL CPWL_Note::OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) { |
1466 if (m_pOptions->WndHitTest(m_pOptions->ParentToChild(point))) { | 1466 if (m_pOptions->WndHitTest(m_pOptions->ParentToChild(point))) { |
1467 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) { | 1467 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) { |
1468 int32_t x, y; | 1468 int32_t x, y; |
1469 PWLtoWnd(point, x, y); | 1469 PWLtoWnd(point, x, y); |
1470 if (IFX_SystemHandler* pSH = GetSystemHandler()) | 1470 if (IFX_SystemHandler* pSH = GetSystemHandler()) |
1471 pSH->ClientToScreen(GetAttachedHWnd(), x, y); | 1471 pSH->ClientToScreen(GetAttachedHWnd(), x, y); |
1472 KillFocus(); | 1472 KillFocus(); |
1473 pNotify->OnPopupMenu(x, y); | 1473 pNotify->OnPopupMenu(x, y); |
1474 | 1474 |
1475 return TRUE; | 1475 return TRUE; |
1476 } | 1476 } |
1477 } | 1477 } |
1478 | 1478 |
1479 return CPWL_Wnd::OnLButtonDown(point, nFlag); | 1479 return CPWL_Wnd::OnLButtonDown(point, nFlag); |
1480 } | 1480 } |
1481 | 1481 |
1482 FX_BOOL CPWL_Note::OnRButtonUp(const CFX_FloatPoint& point, FX_DWORD nFlag) { | 1482 FX_BOOL CPWL_Note::OnRButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) { |
1483 return CPWL_Wnd::OnRButtonUp(point, nFlag); | 1483 return CPWL_Wnd::OnRButtonUp(point, nFlag); |
1484 } | 1484 } |
1485 | 1485 |
1486 const CPWL_Note* CPWL_Note::GetNote() const { | 1486 const CPWL_Note* CPWL_Note::GetNote() const { |
1487 return this; | 1487 return this; |
1488 } | 1488 } |
1489 | 1489 |
1490 IPWL_NoteNotify* CPWL_Note::GetNoteNotify() const { | 1490 IPWL_NoteNotify* CPWL_Note::GetNoteNotify() const { |
1491 return m_bEnableNotify ? m_pNoteNotify : nullptr; | 1491 return m_bEnableNotify ? m_pNoteNotify : nullptr; |
1492 } | 1492 } |
(...skipping 11 matching lines...) Expand all Loading... |
1504 m_pContents->EnableRead(bEnabled); | 1504 m_pContents->EnableRead(bEnabled); |
1505 } | 1505 } |
1506 | 1506 |
1507 CFX_WideString CPWL_Note::GetReplyString() const { | 1507 CFX_WideString CPWL_Note::GetReplyString() const { |
1508 return m_sReplyString; | 1508 return m_sReplyString; |
1509 } | 1509 } |
1510 | 1510 |
1511 void CPWL_Note::SetReplyString(const CFX_WideString& str) { | 1511 void CPWL_Note::SetReplyString(const CFX_WideString& str) { |
1512 m_sReplyString = str; | 1512 m_sReplyString = str; |
1513 } | 1513 } |
OLD | NEW |