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

Side by Side Diff: fpdfsdk/pdfwindow/PWL_Note.cpp

Issue 1867623002: Remove IPWL_NoteNotify and CPWL_Note. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months 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
« no previous file with comments | « fpdfsdk/pdfwindow/PWL_Note.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "fpdfsdk/pdfwindow/PWL_Note.h" 7 #include "fpdfsdk/pdfwindow/PWL_Note.h"
8 8
9 #include "core/fxge/include/fx_ge.h" 9 #include "core/fxge/include/fx_ge.h"
10 #include "fpdfsdk/pdfwindow/PWL_Button.h" 10 #include "fpdfsdk/pdfwindow/PWL_Button.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 void CPWL_Note_Edit::OnSetFocus() { 130 void CPWL_Note_Edit::OnSetFocus() {
131 m_bEnableNotify = FALSE; 131 m_bEnableNotify = FALSE;
132 CPWL_Edit::OnSetFocus(); 132 CPWL_Edit::OnSetFocus();
133 m_bEnableNotify = TRUE; 133 m_bEnableNotify = TRUE;
134 134
135 EnableSpellCheck(TRUE); 135 EnableSpellCheck(TRUE);
136 } 136 }
137 137
138 void CPWL_Note_Edit::OnKillFocus() { 138 void CPWL_Note_Edit::OnKillFocus() {
139 EnableSpellCheck(FALSE); 139 EnableSpellCheck(FALSE);
140
141 if (CPWL_Wnd* pParent = GetParentWindow()) {
142 if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) {
143 ASSERT(pGrand->GetClassName() == "CPWL_NoteItem");
144
145 CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pGrand;
146
147 pNoteItem->OnContentsValidate();
148 }
149 }
150
151 CPWL_Edit::OnKillFocus(); 140 CPWL_Edit::OnKillFocus();
152 } 141 }
153 142
154 void CPWL_Note_Edit::OnNotify(CPWL_Wnd* pWnd, 143 void CPWL_Note_Edit::OnNotify(CPWL_Wnd* pWnd,
155 uint32_t msg, 144 uint32_t msg,
156 intptr_t wParam, 145 intptr_t wParam,
157 intptr_t lParam) { 146 intptr_t lParam) {
158 if (m_bEnableNotify) { 147 if (m_bEnableNotify) {
159 if (wParam == SBT_VSCROLL) { 148 if (wParam == SBT_VSCROLL) {
160 switch (msg) { 149 switch (msg) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 370 }
382 } 371 }
383 372
384 CFX_WideString CPWL_Note_Contents::GetText() const { 373 CFX_WideString CPWL_Note_Contents::GetText() const {
385 if (m_pEdit) 374 if (m_pEdit)
386 return m_pEdit->GetText(); 375 return m_pEdit->GetText();
387 376
388 return L""; 377 return L"";
389 } 378 }
390 379
391 CPWL_NoteItem* CPWL_Note_Contents::CreateSubItem() {
392 CPWL_NoteItem* pNoteItem = new CPWL_NoteItem;
393 PWL_CREATEPARAM icp = GetCreationParam();
394 icp.pParentWnd = this;
395 icp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_BACKGROUND;
396 pNoteItem->Create(icp);
397
398 pNoteItem->OnCreateNoteItem();
399
400 pNoteItem->ResetSubjectName(m_aChildren.GetSize() - 1);
401
402 FX_SYSTEMTIME st;
403 if (IFX_SystemHandler* pSH = GetSystemHandler())
404 st = pSH->GetLocalTime();
405 pNoteItem->SetDateTime(st);
406
407 pNoteItem->SetContents(L"");
408
409 OnNotify(pNoteItem, PNM_NOTEEDITCHANGED, 0, 0);
410
411 return pNoteItem;
412 }
413
414 int32_t CPWL_Note_Contents::CountSubItems() const { 380 int32_t CPWL_Note_Contents::CountSubItems() const {
415 return m_aChildren.GetSize() - 1; 381 return m_aChildren.GetSize() - 1;
416 } 382 }
417 383
418 IPWL_NoteItem* CPWL_Note_Contents::GetSubItems(int32_t index) const { 384 IPWL_NoteItem* CPWL_Note_Contents::GetSubItems(int32_t index) const {
419 int32_t nIndex = index + 1; 385 int32_t nIndex = index + 1;
420 386
421 if (nIndex > 0 && nIndex < m_aChildren.GetSize()) { 387 if (nIndex > 0 && nIndex < m_aChildren.GetSize()) {
422 if (CPWL_Wnd* pChild = m_aChildren.GetAt(nIndex)) { 388 if (CPWL_Wnd* pChild = m_aChildren.GetAt(nIndex)) {
423 ASSERT(pChild->GetClassName() == "CPWL_NoteItem"); 389 ASSERT(pChild->GetClassName() == "CPWL_NoteItem");
424 CPWL_NoteItem* pItem = (CPWL_NoteItem*)pChild; 390 CPWL_NoteItem* pItem = (CPWL_NoteItem*)pChild;
425 return pItem; 391 return pItem;
426 } 392 }
427 } 393 }
428 return NULL; 394 return NULL;
429 } 395 }
430 396
431 void CPWL_Note_Contents::DeleteSubItem(IPWL_NoteItem* pNoteItem) {
432 int32_t nIndex = GetItemIndex((CPWL_NoteItem*)pNoteItem);
433
434 if (nIndex > 0) {
435 if (CPWL_NoteItem* pPWLNoteItem = (CPWL_NoteItem*)pNoteItem) {
436 pPWLNoteItem->KillFocus();
437 pPWLNoteItem->Destroy();
438 delete pPWLNoteItem;
439 }
440
441 for (int32_t i = nIndex, sz = m_aChildren.GetSize(); i < sz; i++) {
442 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
443 ASSERT(pChild->GetClassName() == "CPWL_NoteItem");
444 CPWL_NoteItem* pItem = (CPWL_NoteItem*)pChild;
445 pItem->ResetSubjectName(i);
446 }
447 }
448
449 OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
450 }
451 }
452
453 IPWL_NoteItem* CPWL_Note_Contents::GetHitNoteItem(const CFX_FloatPoint& point) { 397 IPWL_NoteItem* CPWL_Note_Contents::GetHitNoteItem(const CFX_FloatPoint& point) {
454 CFX_FloatPoint pt = ParentToChild(point); 398 CFX_FloatPoint pt = ParentToChild(point);
455 399
456 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { 400 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
457 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { 401 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
458 if (pChild->GetClassName() == "CPWL_NoteItem") { 402 if (pChild->GetClassName() == "CPWL_NoteItem") {
459 CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild; 403 CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild;
460 if (IPWL_NoteItem* pRet = pNoteItem->GetHitNoteItem(pt)) 404 if (IPWL_NoteItem* pRet = pNoteItem->GetHitNoteItem(pt))
461 return pRet; 405 return pRet;
462 } 406 }
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 else 628 else
685 sTextColor = PWL_DEFAULT_BLACKCOLOR; 629 sTextColor = PWL_DEFAULT_BLACKCOLOR;
686 630
687 SetTextColor(sTextColor); 631 SetTextColor(sTextColor);
688 if (m_pSubject) 632 if (m_pSubject)
689 m_pSubject->SetTextColor(sTextColor); 633 m_pSubject->SetTextColor(sTextColor);
690 if (m_pDateTime) 634 if (m_pDateTime)
691 m_pDateTime->SetTextColor(sTextColor); 635 m_pDateTime->SetTextColor(sTextColor);
692 636
693 InvalidateRect(nullptr); 637 InvalidateRect(nullptr);
694
695 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
696 pNotify->OnSetBkColor(this);
697 }
698 } 638 }
699 639
700 void CPWL_NoteItem::SetSubjectName(const CFX_WideString& sName) { 640 void CPWL_NoteItem::SetSubjectName(const CFX_WideString& sName) {
701 if (m_pSubject) { 641 if (m_pSubject)
702 m_pSubject->SetText(sName.c_str()); 642 m_pSubject->SetText(sName.c_str());
703 }
704
705 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
706 pNotify->OnSetSubjectName(this);
707 }
708 }
709
710 void CPWL_NoteItem::SetAuthorName(const CFX_WideString& sName) {
711 m_sAuthor = sName;
712 ResetSubjectName(-1);
713
714 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
715 pNotify->OnSetAuthorName(this);
716 }
717 }
718
719 void CPWL_NoteItem::ResetSubjectName(int32_t nItemIndex) {
720 if (nItemIndex < 0) {
721 if (CPWL_Wnd* pParent = GetParentWindow()) {
722 ASSERT(pParent->GetClassName() == "CPWL_Note_Contents");
723
724 CPWL_Note_Contents* pContents = (CPWL_Note_Contents*)pParent;
725 nItemIndex = pContents->GetItemIndex(this);
726 }
727 }
728
729 const CPWL_Note* pNote = GetNote();
730 CFX_WideString sSubject;
731 sSubject.Format(pNote->GetReplyString().c_str(), nItemIndex);
732
733 if (!m_sAuthor.IsEmpty()) {
734 sSubject += L" - ";
735 sSubject += m_sAuthor;
736 }
737 SetSubjectName(sSubject);
738 RePosChildWnd();
739 } 643 }
740 644
741 void CPWL_NoteItem::SetDateTime(FX_SYSTEMTIME time) { 645 void CPWL_NoteItem::SetDateTime(FX_SYSTEMTIME time) {
742 m_dtNote = time; 646 m_dtNote = time;
743 647
744 CFX_WideString swTime; 648 CFX_WideString swTime;
745 swTime.Format(L"%04d-%02d-%02d %02d:%02d:%02d", time.wYear, time.wMonth, 649 swTime.Format(L"%04d-%02d-%02d %02d:%02d:%02d", time.wYear, time.wMonth,
746 time.wDay, time.wHour, time.wMinute, time.wSecond); 650 time.wDay, time.wHour, time.wMinute, time.wSecond);
747 if (m_pDateTime) { 651 if (m_pDateTime) {
748 m_pDateTime->SetText(swTime.c_str()); 652 m_pDateTime->SetText(swTime.c_str());
749 } 653 }
750 654
751 RePosChildWnd(); 655 RePosChildWnd();
752
753 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
754 pNotify->OnSetDateTime(this);
755 }
756 } 656 }
757 657
758 void CPWL_NoteItem::SetContents(const CFX_WideString& sContents) { 658 void CPWL_NoteItem::SetContents(const CFX_WideString& sContents) {
759 if (m_pContents) { 659 if (m_pContents) {
760 m_pContents->SetText(sContents); 660 m_pContents->SetText(sContents);
761 } 661 }
762
763 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
764 pNotify->OnSetContents(this);
765 }
766 } 662 }
767 663
768 CPWL_NoteItem* CPWL_NoteItem::GetParentNoteItem() const { 664 CPWL_NoteItem* CPWL_NoteItem::GetParentNoteItem() const {
769 if (CPWL_Wnd* pParent = GetParentWindow()) { 665 if (CPWL_Wnd* pParent = GetParentWindow()) {
770 if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) { 666 if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) {
771 ASSERT(pGrand->GetClassName() == "CPWL_NoteItem"); 667 ASSERT(pGrand->GetClassName() == "CPWL_NoteItem");
772 return (CPWL_NoteItem*)pGrand; 668 return (CPWL_NoteItem*)pGrand;
773 } 669 }
774 } 670 }
775 671
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 return m_dtNote; 705 return m_dtNote;
810 } 706 }
811 707
812 CFX_WideString CPWL_NoteItem::GetSubjectName() const { 708 CFX_WideString CPWL_NoteItem::GetSubjectName() const {
813 if (m_pSubject) 709 if (m_pSubject)
814 return m_pSubject->GetText(); 710 return m_pSubject->GetText();
815 711
816 return L""; 712 return L"";
817 } 713 }
818 714
819 CPWL_NoteItem* CPWL_NoteItem::CreateNoteItem() {
820 if (m_pContents)
821 return m_pContents->CreateSubItem();
822
823 return NULL;
824 }
825
826 IPWL_NoteItem* CPWL_NoteItem::CreateSubItem() {
827 return CreateNoteItem();
828 }
829
830 int32_t CPWL_NoteItem::CountSubItems() const { 715 int32_t CPWL_NoteItem::CountSubItems() const {
831 if (m_pContents) 716 if (m_pContents)
832 return m_pContents->CountSubItems(); 717 return m_pContents->CountSubItems();
833 718
834 return 0; 719 return 0;
835 } 720 }
836 721
837 IPWL_NoteItem* CPWL_NoteItem::GetSubItems(int32_t index) const { 722 IPWL_NoteItem* CPWL_NoteItem::GetSubItems(int32_t index) const {
838 if (m_pContents) 723 if (m_pContents)
839 return m_pContents->GetSubItems(index); 724 return m_pContents->GetSubItems(index);
840 725
841 return NULL; 726 return NULL;
842 } 727 }
843 728
844 void CPWL_NoteItem::DeleteSubItem(IPWL_NoteItem* pNoteItem) {
845 KillFocus();
846
847 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
848 pNotify->OnItemDelete(pNoteItem);
849 }
850
851 if (m_pContents)
852 m_pContents->DeleteSubItem(pNoteItem);
853 }
854
855 IPWL_NoteItem* CPWL_NoteItem::GetHitNoteItem(const CFX_FloatPoint& point) { 729 IPWL_NoteItem* CPWL_NoteItem::GetHitNoteItem(const CFX_FloatPoint& point) {
856 CFX_FloatPoint pt = ParentToChild(point); 730 CFX_FloatPoint pt = ParentToChild(point);
857 731
858 if (WndHitTest(pt)) { 732 if (WndHitTest(pt)) {
859 if (m_pContents) { 733 if (m_pContents) {
860 if (IPWL_NoteItem* pNoteItem = m_pContents->GetHitNoteItem(pt)) 734 if (IPWL_NoteItem* pNoteItem = m_pContents->GetHitNoteItem(pt))
861 return pNoteItem; 735 return pNoteItem;
862 } 736 }
863 737
864 return this; 738 return this;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 m_bSizeChanged = TRUE; 836 m_bSizeChanged = TRUE;
963 m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0); 837 m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
964 838
965 return; 839 return;
966 } 840 }
967 841
968 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); 842 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
969 } 843 }
970 844
971 void CPWL_NoteItem::PopupNoteItemMenu(const CFX_FloatPoint& point) { 845 void CPWL_NoteItem::PopupNoteItemMenu(const CFX_FloatPoint& point) {
972 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
973 int32_t x, y;
974 PWLtoWnd(point, x, y);
975 if (IFX_SystemHandler* pSH = GetSystemHandler())
976 pSH->ClientToScreen(GetAttachedHWnd(), x, y);
977 pNotify->OnPopupMenu(this, x, y);
978 }
979 }
980
981 const CPWL_Note* CPWL_NoteItem::GetNote() const {
982 if (const CPWL_Wnd* pRoot = GetRootWnd()) {
983 ASSERT(pRoot->GetClassName() == "CPWL_NoteItem");
984 CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pRoot;
985 if (pNoteItem->IsTopItem()) {
986 return (CPWL_Note*)pNoteItem;
987 }
988 }
989
990 return NULL;
991 }
992
993 IPWL_NoteNotify* CPWL_NoteItem::GetNoteNotify() const {
994 if (const CPWL_Note* pNote = GetNote())
995 return pNote->GetNoteNotify();
996
997 return NULL;
998 }
999
1000 void CPWL_NoteItem::OnCreateNoteItem() {
1001 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
1002 pNotify->OnItemCreate(this);
1003 }
1004 }
1005
1006 void CPWL_NoteItem::OnContentsValidate() {
1007 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
1008 pNotify->OnSetContents(this);
1009 }
1010 } 846 }
1011 847
1012 void CPWL_NoteItem::SetNoteFocus(FX_BOOL bLast) { 848 void CPWL_NoteItem::SetNoteFocus(FX_BOOL bLast) {
1013 m_pContents->SetEditFocus(bLast); 849 m_pContents->SetEditFocus(bLast);
1014 } 850 }
1015 851
1016 void CPWL_NoteItem::EnableModify(FX_BOOL bEnabled) { 852 void CPWL_NoteItem::EnableModify(FX_BOOL bEnabled) {
1017 m_pContents->EnableModify(bEnabled); 853 m_pContents->EnableModify(bEnabled);
1018 m_bAllowModify = bEnabled; 854 m_bAllowModify = bEnabled;
1019 } 855 }
1020 856
1021 void CPWL_NoteItem::EnableRead(FX_BOOL bEnabled) { 857 void CPWL_NoteItem::EnableRead(FX_BOOL bEnabled) {
1022 m_pContents->EnableRead(bEnabled); 858 m_pContents->EnableRead(bEnabled);
1023 } 859 }
1024
1025 CPWL_Note::CPWL_Note(IPopup_Note* pPopupNote,
1026 IPWL_NoteNotify* pNoteNotify,
1027 IPWL_NoteHandler* pNoteHandler)
1028 : m_pAuthor(NULL),
1029 m_pIcon(NULL),
1030 m_pCloseBox(NULL),
1031 m_pLBBox(NULL),
1032 m_pRBBox(NULL),
1033 m_pContentsBar(NULL),
1034 m_pOptions(NULL),
1035 m_pNoteNotify(pNoteNotify),
1036 m_bResizing(FALSE),
1037 m_bEnableNotify(TRUE) {}
1038
1039 CPWL_Note::~CPWL_Note() {}
1040
1041 IPWL_NoteItem* CPWL_Note::Reply() {
1042 return CreateNoteItem();
1043 }
1044
1045 void CPWL_Note::EnableNotify(FX_BOOL bEnabled) {
1046 m_bEnableNotify = bEnabled;
1047 }
1048
1049 void CPWL_Note::RePosChildWnd() {
1050 RePosNoteChildren();
1051 m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
1052 ResetScrollBar();
1053 m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
1054 OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
1055 if (const CPWL_Wnd* pWnd = GetFocused()) {
1056 if (pWnd->GetClassName() == "CPWL_Edit") {
1057 CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;
1058 pEdit->SetCaret(pEdit->GetCaret());
1059 }
1060 }
1061 }
1062
1063 FX_BOOL CPWL_Note::ResetScrollBar() {
1064 FX_BOOL bScrollChanged = FALSE;
1065
1066 if (ScrollBarShouldVisible()) {
1067 if (!m_pContentsBar->IsVisible()) {
1068 m_pContentsBar->SetVisible(TRUE);
1069 if (m_pContentsBar->IsVisible()) {
1070 m_pContentsBar->InvalidateRect(NULL);
1071 bScrollChanged = TRUE;
1072 }
1073 }
1074 } else {
1075 if (m_pContentsBar->IsVisible()) {
1076 m_pContentsBar->SetVisible(FALSE);
1077 m_pContentsBar->InvalidateRect(NULL);
1078
1079 bScrollChanged = TRUE;
1080 }
1081 }
1082
1083 if (bScrollChanged) {
1084 CFX_FloatRect rcNote = GetClientRect();
1085 CFX_FloatRect rcContents = m_pContents->GetWindowRect();
1086 rcContents.right = rcNote.right - 3.0f;
1087 if (m_pContentsBar->IsVisible())
1088 rcContents.right -= PWL_SCROLLBAR_WIDTH;
1089 m_pContents->Move(rcContents, TRUE, TRUE);
1090 m_pContents->SetScrollPos(CFX_FloatPoint(0.0f, 0.0f));
1091 m_pContents->InvalidateRect(NULL);
1092 }
1093
1094 return bScrollChanged;
1095 }
1096
1097 FX_BOOL CPWL_Note::ScrollBarShouldVisible() {
1098 CFX_FloatRect rcContentsFact = m_pContents->GetScrollArea();
1099 CFX_FloatRect rcContentsClient = m_pContents->GetClientRect();
1100
1101 return rcContentsFact.Height() > rcContentsClient.Height();
1102 }
1103
1104 void CPWL_Note::SetOptionsText(const CFX_WideString& sText) {
1105 if (m_pOptions)
1106 m_pOptions->SetText(sText);
1107
1108 RePosNoteChildren();
1109 }
1110
1111 void CPWL_Note::RePosNoteChildren() {
1112 if (m_bResizing)
1113 return;
1114
1115 m_bResizing = TRUE;
1116
1117 if (IsValid()) {
1118 CFX_FloatRect rcClient = GetClientRect();
1119
1120 CFX_FloatRect rcIcon = rcClient;
1121 rcIcon.top -= 2.0f;
1122 rcIcon.right = rcIcon.left + 14.0f;
1123 rcIcon.bottom = rcIcon.top - 14.0f;
1124 rcIcon.Normalize();
1125 m_pIcon->Move(rcIcon, TRUE, FALSE);
1126 m_pIcon->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcIcon));
1127
1128 CFX_FloatRect rcCloseBox = rcClient;
1129 rcCloseBox.right -= 1.0f;
1130 rcCloseBox.top -= 1.0f;
1131 rcCloseBox.left = rcCloseBox.right - 14.0f;
1132 rcCloseBox.bottom = rcCloseBox.top - 14.0f;
1133 rcCloseBox.Normalize();
1134 m_pCloseBox->Move(rcCloseBox, TRUE, FALSE);
1135 m_pCloseBox->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcCloseBox));
1136
1137 CFX_FloatRect rcDate = rcClient;
1138 rcDate.right = rcCloseBox.left - POPUP_ITEM_TEXT_INDENT;
1139 rcDate.left =
1140 PWL_MAX(rcDate.right - m_pDateTime->GetContentRect().Width() - 1.0f,
1141 rcIcon.right + 1.0f);
1142 rcDate.top = rcClient.top - 2.0f;
1143 rcDate.bottom = rcDate.top - m_pDateTime->GetContentRect().Height();
1144 rcDate.Normalize();
1145 m_pDateTime->Move(rcDate, TRUE, FALSE);
1146 m_pDateTime->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcDate));
1147
1148 CFX_FloatRect rcSubject = rcClient;
1149 rcSubject.top = rcClient.top - 2.0f;
1150 rcSubject.left = rcIcon.right + POPUP_ITEM_TEXT_INDENT;
1151 rcSubject.right =
1152 PWL_MIN(rcSubject.left + m_pSubject->GetContentRect().Width() + 1.0f,
1153 rcDate.left - 1.0f);
1154 rcSubject.bottom = rcSubject.top - m_pSubject->GetContentRect().Height();
1155 rcSubject.Normalize();
1156 m_pSubject->Move(rcSubject, TRUE, FALSE);
1157 m_pSubject->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcSubject));
1158
1159 CFX_FloatRect rcOptions = rcClient;
1160 rcOptions.left =
1161 PWL_MAX(rcOptions.right - m_pOptions->GetContentRect().Width(),
1162 rcIcon.right + 1.0f);
1163 rcOptions.top = rcSubject.bottom - 4.0f;
1164 rcOptions.bottom = rcOptions.top - m_pOptions->GetContentRect().Height();
1165 rcOptions.Normalize();
1166 m_pOptions->Move(rcOptions, TRUE, FALSE);
1167 m_pOptions->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcOptions));
1168
1169 CFX_FloatRect rcAuthor = rcClient;
1170 rcAuthor.top = rcSubject.bottom - 4.0f;
1171 rcAuthor.left = rcSubject.left;
1172 rcAuthor.right =
1173 PWL_MIN(rcSubject.left + m_pAuthor->GetContentRect().Width() + 1.0f,
1174 rcOptions.left - 1.0f);
1175 rcAuthor.bottom = rcAuthor.top - m_pAuthor->GetContentRect().Height();
1176 rcAuthor.Normalize();
1177 m_pAuthor->Move(rcAuthor, TRUE, FALSE);
1178 m_pAuthor->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcAuthor));
1179
1180 CFX_FloatRect rcLBBox = rcClient;
1181 rcLBBox.top = rcLBBox.bottom + 7.0f;
1182 rcLBBox.right = rcLBBox.left + 7.0f;
1183 rcLBBox.Normalize();
1184 m_pLBBox->Move(rcLBBox, TRUE, FALSE);
1185 m_pLBBox->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcLBBox));
1186
1187 CFX_FloatRect rcRBBox = rcClient;
1188 rcRBBox.top = rcRBBox.bottom + 7.0f;
1189 rcRBBox.left = rcRBBox.right - 7.0f;
1190 rcRBBox.Normalize();
1191 m_pRBBox->Move(rcRBBox, TRUE, FALSE);
1192 m_pRBBox->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcRBBox));
1193
1194 CFX_FloatRect rcContents = rcClient;
1195 rcContents.top = rcAuthor.bottom - POPUP_ITEM_HEAD_BOTTOM;
1196 rcContents.left += 3.0f;
1197 rcContents.right -= 3.0f;
1198 if (m_pContentsBar->IsVisible())
1199 rcContents.right -= PWL_SCROLLBAR_WIDTH;
1200 rcContents.bottom += 14.0f;
1201 rcContents.Normalize();
1202 m_pContents->Move(rcContents, FALSE, FALSE);
1203 m_pContents->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcContents));
1204
1205 CFX_FloatRect rcContentsBar = rcContents;
1206 rcContentsBar.right = rcClient.right - 3.0f;
1207 rcContentsBar.left = rcContentsBar.right - PWL_SCROLLBAR_WIDTH;
1208 rcContentsBar.Normalize();
1209 m_pContentsBar->Move(rcContentsBar, TRUE, FALSE);
1210 }
1211
1212 m_bResizing = FALSE;
1213 }
1214
1215 void CPWL_Note::CreateChildWnd(const PWL_CREATEPARAM& cp) {
1216 CPWL_NoteItem::CreateChildWnd(cp);
1217
1218 CPWL_Color sTextColor;
1219
1220 if (CPWL_Utils::IsBlackOrWhite(GetBackgroundColor()))
1221 sTextColor = PWL_DEFAULT_WHITECOLOR;
1222 else
1223 sTextColor = PWL_DEFAULT_BLACKCOLOR;
1224
1225 m_pAuthor = new CPWL_Label;
1226 PWL_CREATEPARAM acp = cp;
1227 acp.pParentWnd = this;
1228 acp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_LEFT | PES_TOP;
1229 acp.sTextColor = sTextColor;
1230 m_pAuthor->Create(acp);
1231
1232 m_pCloseBox = new CPWL_Note_CloseBox;
1233 PWL_CREATEPARAM ccp = cp;
1234 ccp.pParentWnd = this;
1235 ccp.dwBorderWidth = 2;
1236 ccp.nBorderStyle = PBS_BEVELED;
1237 ccp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER;
1238 ccp.sTextColor = sTextColor;
1239 m_pCloseBox->Create(ccp);
1240
1241 m_pIcon = new CPWL_Note_Icon;
1242 PWL_CREATEPARAM icp = cp;
1243 icp.pParentWnd = this;
1244 icp.dwFlags = PWS_VISIBLE | PWS_CHILD;
1245 m_pIcon->Create(icp);
1246
1247 m_pOptions = new CPWL_Note_Options;
1248 PWL_CREATEPARAM ocp = cp;
1249 ocp.pParentWnd = this;
1250 ocp.dwFlags = PWS_CHILD | PWS_VISIBLE;
1251 ocp.sTextColor = sTextColor;
1252 m_pOptions->Create(ocp);
1253
1254 m_pLBBox = new CPWL_Note_LBBox;
1255 PWL_CREATEPARAM lcp = cp;
1256 lcp.pParentWnd = this;
1257 lcp.dwFlags = PWS_VISIBLE | PWS_CHILD;
1258 lcp.eCursorType = FXCT_NESW;
1259 lcp.sTextColor = sTextColor;
1260 m_pLBBox->Create(lcp);
1261
1262 m_pRBBox = new CPWL_Note_RBBox;
1263 PWL_CREATEPARAM rcp = cp;
1264 rcp.pParentWnd = this;
1265 rcp.dwFlags = PWS_VISIBLE | PWS_CHILD;
1266 rcp.eCursorType = FXCT_NWSE;
1267 rcp.sTextColor = sTextColor;
1268 m_pRBBox->Create(rcp);
1269
1270 m_pContentsBar = new CPWL_ScrollBar(SBT_VSCROLL);
1271 PWL_CREATEPARAM scp = cp;
1272 scp.pParentWnd = this;
1273 scp.sBackgroundColor =
1274 CPWL_Color(COLORTYPE_RGB, 240 / 255.0f, 240 / 255.0f, 240 / 255.0f);
1275 scp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_BACKGROUND;
1276 m_pContentsBar->Create(scp);
1277 m_pContentsBar->SetNotifyForever(TRUE);
1278 }
1279
1280 void CPWL_Note::SetSubjectName(const CFX_WideString& sName) {
1281 CPWL_NoteItem::SetSubjectName(sName);
1282 RePosChildWnd();
1283 }
1284
1285 void CPWL_Note::SetAuthorName(const CFX_WideString& sName) {
1286 if (m_pAuthor) {
1287 m_pAuthor->SetText(sName.c_str());
1288 RePosChildWnd();
1289 }
1290
1291 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
1292 pNotify->OnSetAuthorName(this);
1293 }
1294 }
1295
1296 CFX_WideString CPWL_Note::GetAuthorName() const {
1297 if (m_pAuthor)
1298 return m_pAuthor->GetText();
1299
1300 return L"";
1301 }
1302
1303 FX_BOOL CPWL_Note::OnMouseWheel(short zDelta,
1304 const CFX_FloatPoint& point,
1305 uint32_t nFlag) {
1306 CFX_FloatPoint ptScroll = m_pContents->GetScrollPos();
1307 CFX_FloatRect rcScroll = m_pContents->GetScrollArea();
1308 CFX_FloatRect rcContents = m_pContents->GetClientRect();
1309
1310 if (rcScroll.top - rcScroll.bottom > rcContents.Height()) {
1311 CFX_FloatPoint ptNew = ptScroll;
1312
1313 if (zDelta > 0)
1314 ptNew.y += 30;
1315 else
1316 ptNew.y -= 30;
1317
1318 if (ptNew.y > rcScroll.top)
1319 ptNew.y = rcScroll.top;
1320 if (ptNew.y < rcScroll.bottom + rcContents.Height())
1321 ptNew.y = rcScroll.bottom + rcContents.Height();
1322 if (ptNew.y < rcScroll.bottom)
1323 ptNew.y = rcScroll.bottom;
1324
1325 if (ptNew.y != ptScroll.y) {
1326 m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
1327 m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL,
1328 (intptr_t)&ptNew.y);
1329 m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
1330 (intptr_t)&ptNew.y);
1331
1332 return TRUE;
1333 }
1334 }
1335
1336 return FALSE;
1337 }
1338
1339 void CPWL_Note::OnNotify(CPWL_Wnd* pWnd,
1340 uint32_t msg,
1341 intptr_t wParam,
1342 intptr_t lParam) {
1343 switch (msg) {
1344 case PNM_NOTEEDITCHANGED: {
1345 CFX_FloatRect rcScroll = m_pContents->GetScrollArea();
1346
1347 PWL_SCROLL_INFO sInfo;
1348 sInfo.fContentMin = rcScroll.bottom;
1349 sInfo.fContentMax = rcScroll.top;
1350 sInfo.fPlateWidth = m_pContents->GetClientRect().Height();
1351 sInfo.fSmallStep = 13.0f;
1352 sInfo.fBigStep = sInfo.fPlateWidth;
1353
1354 if (FXSYS_memcmp(&m_OldScrollInfo, &sInfo, sizeof(PWL_SCROLL_INFO)) !=
1355 0) {
1356 FX_BOOL bScrollChanged = FALSE;
1357
1358 if (lParam < 3) {
1359 bScrollChanged = ResetScrollBar();
1360 if (bScrollChanged) {
1361 lParam++;
1362 m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
1363 OnNotify(this, PNM_NOTEEDITCHANGED, 0, lParam);
1364 }
1365 }
1366
1367 if (!bScrollChanged) {
1368 if (m_pContentsBar->IsVisible()) {
1369 m_pContentsBar->OnNotify(pWnd, PNM_SETSCROLLINFO, SBT_VSCROLL,
1370 (intptr_t)&sInfo);
1371 m_OldScrollInfo = sInfo;
1372
1373 CFX_FloatPoint ptScroll = m_pContents->GetScrollPos();
1374 CFX_FloatPoint ptOld = ptScroll;
1375
1376 if (ptScroll.y > sInfo.fContentMax)
1377 ptScroll.y = sInfo.fContentMax;
1378 if (ptScroll.y < sInfo.fContentMin + sInfo.fPlateWidth)
1379 ptScroll.y = sInfo.fContentMin + sInfo.fPlateWidth;
1380 if (ptScroll.y < sInfo.fContentMin)
1381 ptScroll.y = sInfo.fContentMin;
1382
1383 if (ptOld.y != ptScroll.y) {
1384 m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
1385 (intptr_t)&ptScroll.y);
1386 m_pContentsBar->InvalidateRect(NULL);
1387 m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL,
1388 (intptr_t)&ptScroll.y);
1389 }
1390 }
1391 }
1392 }
1393 }
1394
1395 m_pContents->InvalidateRect(NULL);
1396
1397 return;
1398 case PNM_SCROLLWINDOW:
1399 if (m_pContents)
1400 m_pContents->OnNotify(pWnd, msg, wParam, lParam);
1401 return;
1402 case PNM_SETSCROLLPOS:
1403 if (m_pContentsBar)
1404 m_pContentsBar->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam);
1405 return;
1406 }
1407
1408 if (msg == PNM_SETCARETINFO && IsValid()) {
1409 if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) {
1410 if (m_pContents) {
1411 CFX_FloatRect rcClient = m_pContents->GetClientRect();
1412 if (pInfo->ptHead.y > rcClient.top) {
1413 CFX_FloatPoint pt = m_pContents->OutToIn(pInfo->ptHead);
1414 m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL,
1415 (intptr_t)&pt.y);
1416
1417 CFX_FloatPoint ptScroll = m_pContents->GetScrollPos();
1418 m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
1419 (intptr_t)&ptScroll.y);
1420
1421 return;
1422 }
1423
1424 if (pInfo->ptFoot.y < rcClient.bottom) {
1425 CFX_FloatPoint pt = m_pContents->OutToIn(pInfo->ptFoot);
1426 pt.y += rcClient.Height();
1427 m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL,
1428 (intptr_t)&pt.y);
1429
1430 CFX_FloatPoint ptScroll = m_pContents->GetScrollPos();
1431 m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
1432 (intptr_t)&ptScroll.y);
1433
1434 return;
1435 }
1436 }
1437 }
1438 }
1439
1440 CPWL_NoteItem::OnNotify(pWnd, msg, wParam, lParam);
1441 }
1442
1443 void CPWL_Note::SetBkColor(const CPWL_Color& color) {
1444 CPWL_NoteItem::SetBkColor(color);
1445
1446 CPWL_Color sBK = color;
1447 CPWL_Color sTextColor;
1448 if (CPWL_Utils::IsBlackOrWhite(sBK))
1449 sTextColor = PWL_DEFAULT_WHITECOLOR;
1450 else
1451 sTextColor = PWL_DEFAULT_BLACKCOLOR;
1452
1453 if (m_pCloseBox)
1454 m_pCloseBox->SetTextColor(sTextColor);
1455 if (m_pAuthor)
1456 m_pAuthor->SetTextColor(sTextColor);
1457 if (m_pOptions)
1458 m_pOptions->SetTextColor(sTextColor);
1459 if (m_pLBBox)
1460 m_pLBBox->SetTextColor(sTextColor);
1461 if (m_pRBBox)
1462 m_pRBBox->SetTextColor(sTextColor);
1463 }
1464
1465 FX_BOOL CPWL_Note::OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) {
1466 if (m_pOptions->WndHitTest(m_pOptions->ParentToChild(point))) {
1467 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
1468 int32_t x, y;
1469 PWLtoWnd(point, x, y);
1470 if (IFX_SystemHandler* pSH = GetSystemHandler())
1471 pSH->ClientToScreen(GetAttachedHWnd(), x, y);
1472 KillFocus();
1473 pNotify->OnPopupMenu(x, y);
1474
1475 return TRUE;
1476 }
1477 }
1478
1479 return CPWL_Wnd::OnLButtonDown(point, nFlag);
1480 }
1481
1482 FX_BOOL CPWL_Note::OnRButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) {
1483 return CPWL_Wnd::OnRButtonUp(point, nFlag);
1484 }
1485
1486 const CPWL_Note* CPWL_Note::GetNote() const {
1487 return this;
1488 }
1489
1490 IPWL_NoteNotify* CPWL_Note::GetNoteNotify() const {
1491 return m_bEnableNotify ? m_pNoteNotify : nullptr;
1492 }
1493
1494 void CPWL_Note::SetIconType(int32_t nType) {
1495 if (m_pIcon)
1496 m_pIcon->SetIconType(nType);
1497 }
1498
1499 void CPWL_Note::EnableModify(FX_BOOL bEnabled) {
1500 m_pContents->EnableModify(bEnabled);
1501 }
1502
1503 void CPWL_Note::EnableRead(FX_BOOL bEnabled) {
1504 m_pContents->EnableRead(bEnabled);
1505 }
1506
1507 CFX_WideString CPWL_Note::GetReplyString() const {
1508 return m_sReplyString;
1509 }
1510
1511 void CPWL_Note::SetReplyString(const CFX_WideString& str) {
1512 m_sReplyString = str;
1513 }
OLDNEW
« no previous file with comments | « fpdfsdk/pdfwindow/PWL_Note.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698