summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/pdfwindow/PWL_Note.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-02-26 14:24:28 -0800
committerTom Sepez <tsepez@chromium.org>2016-02-26 14:24:28 -0800
commit281a9eadff15b167e2ee3032e21b83190ad49125 (patch)
treef02f7d0842f59d8e69bda011b3e62547ffb1acde /fpdfsdk/src/pdfwindow/PWL_Note.cpp
parent566b974287ce0e81a963138152b8898f22480f52 (diff)
downloadpdfium-281a9eadff15b167e2ee3032e21b83190ad49125.tar.xz
Re-land "Replace CPDF_Rect and CPDF_Point with CFX types."
TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1737593006 .
Diffstat (limited to 'fpdfsdk/src/pdfwindow/PWL_Note.cpp')
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Note.cpp123
1 files changed, 63 insertions, 60 deletions
diff --git a/fpdfsdk/src/pdfwindow/PWL_Note.cpp b/fpdfsdk/src/pdfwindow/PWL_Note.cpp
index 760967b6a2..1933d564f4 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Note.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Note.cpp
@@ -42,14 +42,14 @@ void CPWL_Note_Options::SetTextColor(const CPWL_Color& color) {
void CPWL_Note_Options::RePosChildWnd() {
if (IsValid()) {
- CPDF_Rect rcClient = GetClientRect();
+ CFX_FloatRect rcClient = GetClientRect();
if (rcClient.Width() > 15.0f) {
rcClient.right -= 15.0f;
m_pText->Move(rcClient, TRUE, FALSE);
m_pText->SetVisible(TRUE);
} else {
- m_pText->Move(CPDF_Rect(0, 0, 0, 0), TRUE, FALSE);
+ m_pText->Move(CFX_FloatRect(0, 0, 0, 0), TRUE, FALSE);
m_pText->SetVisible(FALSE);
}
}
@@ -71,15 +71,16 @@ void CPWL_Note_Options::DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device) {
CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
- CPDF_Rect rcClient = GetClientRect();
+ CFX_FloatRect rcClient = GetClientRect();
rcClient.left = rcClient.right - 15.0f;
- CPDF_Point ptCenter = CPDF_Point((rcClient.left + rcClient.right) * 0.5f,
- (rcClient.top + rcClient.bottom) * 0.5f);
+ CFX_FloatPoint ptCenter =
+ CFX_FloatPoint((rcClient.left + rcClient.right) * 0.5f,
+ (rcClient.top + rcClient.bottom) * 0.5f);
- CPDF_Point pt1(ptCenter.x - 2.0f, ptCenter.y + 2.0f * 0.5f);
- CPDF_Point pt2(ptCenter.x + 2.0f, ptCenter.y + 2.0f * 0.5f);
- CPDF_Point pt3(ptCenter.x, ptCenter.y - 3.0f * 0.5f);
+ CFX_FloatPoint pt1(ptCenter.x - 2.0f, ptCenter.y + 2.0f * 0.5f);
+ CFX_FloatPoint pt2(ptCenter.x + 2.0f, ptCenter.y + 2.0f * 0.5f);
+ CFX_FloatPoint pt3(ptCenter.x, ptCenter.y - 3.0f * 0.5f);
CFX_PathData path;
@@ -95,8 +96,8 @@ void CPWL_Note_Options::DrawThisAppearance(CFX_RenderDevice* pDevice,
FXFILL_ALTERNATE);
}
-CPDF_Rect CPWL_Note_Options::GetContentRect() const {
- CPDF_Rect rcText = m_pText->GetContentRect();
+CFX_FloatRect CPWL_Note_Options::GetContentRect() const {
+ CFX_FloatRect rcText = m_pText->GetContentRect();
rcText.right += 15.0f;
return rcText;
}
@@ -205,7 +206,7 @@ FX_FLOAT CPWL_Note_Edit::GetItemHeight(FX_FLOAT fLimitWidth) {
EnableRefresh(FALSE);
m_pEdit->EnableNotify(FALSE);
- Move(CPDF_Rect(0, 0, fLimitWidth, 0), TRUE, FALSE);
+ Move(CFX_FloatRect(0, 0, fLimitWidth, 0), TRUE, FALSE);
FX_FLOAT fRet = GetContentRect().Height();
m_pEdit->EnableNotify(TRUE);
@@ -232,7 +233,7 @@ CPWL_Note_LBBox::~CPWL_Note_LBBox() {}
void CPWL_Note_LBBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device) {
- CPDF_Rect rcClient = GetClientRect();
+ CFX_FloatRect rcClient = GetClientRect();
CFX_GraphStateData gsd;
gsd.m_LineWidth = 1.0f;
@@ -259,7 +260,7 @@ CPWL_Note_RBBox::~CPWL_Note_RBBox() {}
void CPWL_Note_RBBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device) {
- CPDF_Rect rcClient = GetClientRect();
+ CFX_FloatRect rcClient = GetClientRect();
CFX_GraphStateData gsd;
gsd.m_LineWidth = 1.0f;
@@ -303,7 +304,7 @@ void CPWL_Note_CloseBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device) {
CPWL_Button::DrawThisAppearance(pDevice, pUser2Device);
- CPDF_Rect rcClient = GetClientRect();
+ CFX_FloatRect rcClient = GetClientRect();
rcClient = CPWL_Utils::DeflateRect(rcClient, 2.0f);
CFX_GraphStateData gsd;
@@ -330,7 +331,7 @@ void CPWL_Note_CloseBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
FXFILL_ALTERNATE);
}
-FX_BOOL CPWL_Note_CloseBox::OnLButtonDown(const CPDF_Point& point,
+FX_BOOL CPWL_Note_CloseBox::OnLButtonDown(const CFX_FloatPoint& point,
FX_DWORD nFlag) {
SetBorderStyle(PBS_INSET);
InvalidateRect(NULL);
@@ -340,7 +341,7 @@ FX_BOOL CPWL_Note_CloseBox::OnLButtonDown(const CPDF_Point& point,
return CPWL_Button::OnLButtonDown(point, nFlag);
}
-FX_BOOL CPWL_Note_CloseBox::OnLButtonUp(const CPDF_Point& point,
+FX_BOOL CPWL_Note_CloseBox::OnLButtonUp(const CFX_FloatPoint& point,
FX_DWORD nFlag) {
m_bMouseDown = FALSE;
@@ -448,8 +449,8 @@ void CPWL_Note_Contents::DeleteSubItem(IPWL_NoteItem* pNoteItem) {
}
}
-IPWL_NoteItem* CPWL_Note_Contents::GetHitNoteItem(const CPDF_Point& point) {
- CPDF_Point pt = ParentToChild(point);
+IPWL_NoteItem* CPWL_Note_Contents::GetHitNoteItem(const CFX_FloatPoint& point) {
+ CFX_FloatPoint pt = ParentToChild(point);
for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
@@ -488,7 +489,7 @@ void CPWL_Note_Contents::OnNotify(CPWL_Wnd* pWnd,
}
return;
case PNM_SCROLLWINDOW:
- SetScrollPos(CPDF_Point(0.0f, *(FX_FLOAT*)lParam));
+ SetScrollPos(CFX_FloatPoint(0.0f, *(FX_FLOAT*)lParam));
ResetFace();
InvalidateRect(NULL);
return;
@@ -524,7 +525,7 @@ void CPWL_Note_Contents::OnNotify(CPWL_Wnd* pWnd,
CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
}
-FX_BOOL CPWL_Note_Contents::OnLButtonDown(const CPDF_Point& point,
+FX_BOOL CPWL_Note_Contents::OnLButtonDown(const CFX_FloatPoint& point,
FX_DWORD nFlag) {
if (CPWL_Wnd::OnLButtonDown(point, nFlag))
return TRUE;
@@ -631,9 +632,9 @@ void CPWL_NoteItem::CreateChildWnd(const PWL_CREATEPARAM& cp) {
void CPWL_NoteItem::RePosChildWnd() {
if (IsValid()) {
- CPDF_Rect rcClient = GetClientRect();
+ CFX_FloatRect rcClient = GetClientRect();
- CPDF_Rect rcSubject = rcClient;
+ CFX_FloatRect rcSubject = rcClient;
rcSubject.left += POPUP_ITEM_TEXT_INDENT;
rcSubject.top = rcClient.top;
rcSubject.right =
@@ -644,7 +645,7 @@ void CPWL_NoteItem::RePosChildWnd() {
m_pSubject->Move(rcSubject, TRUE, FALSE);
m_pSubject->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcSubject));
- CPDF_Rect rcDate = rcClient;
+ CFX_FloatRect rcDate = rcClient;
rcDate.right -= POPUP_ITEM_TEXT_INDENT;
rcDate.left =
PWL_MAX(rcDate.right - m_pDateTime->GetContentRect().Width() - 1.0f,
@@ -654,7 +655,7 @@ void CPWL_NoteItem::RePosChildWnd() {
m_pDateTime->Move(rcDate, TRUE, FALSE);
m_pDateTime->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcDate));
- CPDF_Rect rcContents = rcClient;
+ CFX_FloatRect rcContents = rcClient;
rcContents.left += 1.0f;
rcContents.right -= 1.0f;
rcContents.top = rcDate.bottom - POPUP_ITEM_HEAD_BOTTOM;
@@ -850,8 +851,8 @@ void CPWL_NoteItem::DeleteSubItem(IPWL_NoteItem* pNoteItem) {
m_pContents->DeleteSubItem(pNoteItem);
}
-IPWL_NoteItem* CPWL_NoteItem::GetHitNoteItem(const CPDF_Point& point) {
- CPDF_Point pt = ParentToChild(point);
+IPWL_NoteItem* CPWL_NoteItem::GetHitNoteItem(const CFX_FloatPoint& point) {
+ CFX_FloatPoint pt = ParentToChild(point);
if (WndHitTest(pt)) {
if (m_pContents) {
@@ -909,7 +910,8 @@ FX_FLOAT CPWL_NoteItem::GetItemRightMargin() {
return POPUP_ITEM_SIDEMARGIN;
}
-FX_BOOL CPWL_NoteItem::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) {
+FX_BOOL CPWL_NoteItem::OnLButtonDown(const CFX_FloatPoint& point,
+ FX_DWORD nFlag) {
if (!m_pContents->WndHitTest(m_pContents->ParentToChild(point))) {
SetNoteFocus(FALSE);
}
@@ -919,7 +921,8 @@ FX_BOOL CPWL_NoteItem::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) {
return TRUE;
}
-FX_BOOL CPWL_NoteItem::OnRButtonUp(const CPDF_Point& point, FX_DWORD nFlag) {
+FX_BOOL CPWL_NoteItem::OnRButtonUp(const CFX_FloatPoint& point,
+ FX_DWORD nFlag) {
if (!m_pContents->WndHitTest(m_pContents->ParentToChild(point))) {
SetNoteFocus(FALSE);
PopupNoteItemMenu(point);
@@ -964,7 +967,7 @@ void CPWL_NoteItem::OnNotify(CPWL_Wnd* pWnd,
CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
}
-void CPWL_NoteItem::PopupNoteItemMenu(const CPDF_Point& point) {
+void CPWL_NoteItem::PopupNoteItemMenu(const CFX_FloatPoint& point) {
if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
int32_t x, y;
PWLtoWnd(point, x, y);
@@ -1077,13 +1080,13 @@ FX_BOOL CPWL_Note::ResetScrollBar() {
}
if (bScrollChanged) {
- CPDF_Rect rcNote = GetClientRect();
- CPDF_Rect rcContents = m_pContents->GetWindowRect();
+ CFX_FloatRect rcNote = GetClientRect();
+ CFX_FloatRect rcContents = m_pContents->GetWindowRect();
rcContents.right = rcNote.right - 3.0f;
if (m_pContentsBar->IsVisible())
rcContents.right -= PWL_SCROLLBAR_WIDTH;
m_pContents->Move(rcContents, TRUE, TRUE);
- m_pContents->SetScrollPos(CPDF_Point(0.0f, 0.0f));
+ m_pContents->SetScrollPos(CFX_FloatPoint(0.0f, 0.0f));
m_pContents->InvalidateRect(NULL);
}
@@ -1091,8 +1094,8 @@ FX_BOOL CPWL_Note::ResetScrollBar() {
}
FX_BOOL CPWL_Note::ScrollBarShouldVisible() {
- CPDF_Rect rcContentsFact = m_pContents->GetScrollArea();
- CPDF_Rect rcContentsClient = m_pContents->GetClientRect();
+ CFX_FloatRect rcContentsFact = m_pContents->GetScrollArea();
+ CFX_FloatRect rcContentsClient = m_pContents->GetClientRect();
return rcContentsFact.Height() > rcContentsClient.Height();
}
@@ -1111,9 +1114,9 @@ void CPWL_Note::RePosNoteChildren() {
m_bResizing = TRUE;
if (IsValid()) {
- CPDF_Rect rcClient = GetClientRect();
+ CFX_FloatRect rcClient = GetClientRect();
- CPDF_Rect rcIcon = rcClient;
+ CFX_FloatRect rcIcon = rcClient;
rcIcon.top -= 2.0f;
rcIcon.right = rcIcon.left + 14.0f;
rcIcon.bottom = rcIcon.top - 14.0f;
@@ -1121,7 +1124,7 @@ void CPWL_Note::RePosNoteChildren() {
m_pIcon->Move(rcIcon, TRUE, FALSE);
m_pIcon->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcIcon));
- CPDF_Rect rcCloseBox = rcClient;
+ CFX_FloatRect rcCloseBox = rcClient;
rcCloseBox.right -= 1.0f;
rcCloseBox.top -= 1.0f;
rcCloseBox.left = rcCloseBox.right - 14.0f;
@@ -1130,7 +1133,7 @@ void CPWL_Note::RePosNoteChildren() {
m_pCloseBox->Move(rcCloseBox, TRUE, FALSE);
m_pCloseBox->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcCloseBox));
- CPDF_Rect rcDate = rcClient;
+ CFX_FloatRect rcDate = rcClient;
rcDate.right = rcCloseBox.left - POPUP_ITEM_TEXT_INDENT;
rcDate.left =
PWL_MAX(rcDate.right - m_pDateTime->GetContentRect().Width() - 1.0f,
@@ -1141,7 +1144,7 @@ void CPWL_Note::RePosNoteChildren() {
m_pDateTime->Move(rcDate, TRUE, FALSE);
m_pDateTime->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcDate));
- CPDF_Rect rcSubject = rcClient;
+ CFX_FloatRect rcSubject = rcClient;
rcSubject.top = rcClient.top - 2.0f;
rcSubject.left = rcIcon.right + POPUP_ITEM_TEXT_INDENT;
rcSubject.right =
@@ -1152,7 +1155,7 @@ void CPWL_Note::RePosNoteChildren() {
m_pSubject->Move(rcSubject, TRUE, FALSE);
m_pSubject->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcSubject));
- CPDF_Rect rcOptions = rcClient;
+ CFX_FloatRect rcOptions = rcClient;
rcOptions.left =
PWL_MAX(rcOptions.right - m_pOptions->GetContentRect().Width(),
rcIcon.right + 1.0f);
@@ -1162,7 +1165,7 @@ void CPWL_Note::RePosNoteChildren() {
m_pOptions->Move(rcOptions, TRUE, FALSE);
m_pOptions->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcOptions));
- CPDF_Rect rcAuthor = rcClient;
+ CFX_FloatRect rcAuthor = rcClient;
rcAuthor.top = rcSubject.bottom - 4.0f;
rcAuthor.left = rcSubject.left;
rcAuthor.right =
@@ -1173,21 +1176,21 @@ void CPWL_Note::RePosNoteChildren() {
m_pAuthor->Move(rcAuthor, TRUE, FALSE);
m_pAuthor->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcAuthor));
- CPDF_Rect rcLBBox = rcClient;
+ CFX_FloatRect rcLBBox = rcClient;
rcLBBox.top = rcLBBox.bottom + 7.0f;
rcLBBox.right = rcLBBox.left + 7.0f;
rcLBBox.Normalize();
m_pLBBox->Move(rcLBBox, TRUE, FALSE);
m_pLBBox->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcLBBox));
- CPDF_Rect rcRBBox = rcClient;
+ CFX_FloatRect rcRBBox = rcClient;
rcRBBox.top = rcRBBox.bottom + 7.0f;
rcRBBox.left = rcRBBox.right - 7.0f;
rcRBBox.Normalize();
m_pRBBox->Move(rcRBBox, TRUE, FALSE);
m_pRBBox->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcRBBox));
- CPDF_Rect rcContents = rcClient;
+ CFX_FloatRect rcContents = rcClient;
rcContents.top = rcAuthor.bottom - POPUP_ITEM_HEAD_BOTTOM;
rcContents.left += 3.0f;
rcContents.right -= 3.0f;
@@ -1198,7 +1201,7 @@ void CPWL_Note::RePosNoteChildren() {
m_pContents->Move(rcContents, FALSE, FALSE);
m_pContents->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcContents));
- CPDF_Rect rcContentsBar = rcContents;
+ CFX_FloatRect rcContentsBar = rcContents;
rcContentsBar.right = rcClient.right - 3.0f;
rcContentsBar.left = rcContentsBar.right - PWL_SCROLLBAR_WIDTH;
rcContentsBar.Normalize();
@@ -1297,14 +1300,14 @@ CFX_WideString CPWL_Note::GetAuthorName() const {
}
FX_BOOL CPWL_Note::OnMouseWheel(short zDelta,
- const CPDF_Point& point,
+ const CFX_FloatPoint& point,
FX_DWORD nFlag) {
- CPDF_Point ptScroll = m_pContents->GetScrollPos();
- CPDF_Rect rcScroll = m_pContents->GetScrollArea();
- CPDF_Rect rcContents = m_pContents->GetClientRect();
+ CFX_FloatPoint ptScroll = m_pContents->GetScrollPos();
+ CFX_FloatRect rcScroll = m_pContents->GetScrollArea();
+ CFX_FloatRect rcContents = m_pContents->GetClientRect();
if (rcScroll.top - rcScroll.bottom > rcContents.Height()) {
- CPDF_Point ptNew = ptScroll;
+ CFX_FloatPoint ptNew = ptScroll;
if (zDelta > 0)
ptNew.y += 30;
@@ -1338,7 +1341,7 @@ void CPWL_Note::OnNotify(CPWL_Wnd* pWnd,
intptr_t lParam) {
switch (msg) {
case PNM_NOTEEDITCHANGED: {
- CPDF_Rect rcScroll = m_pContents->GetScrollArea();
+ CFX_FloatRect rcScroll = m_pContents->GetScrollArea();
PWL_SCROLL_INFO sInfo;
sInfo.fContentMin = rcScroll.bottom;
@@ -1366,8 +1369,8 @@ void CPWL_Note::OnNotify(CPWL_Wnd* pWnd,
(intptr_t)&sInfo);
m_OldScrollInfo = sInfo;
- CPDF_Point ptScroll = m_pContents->GetScrollPos();
- CPDF_Point ptOld = ptScroll;
+ CFX_FloatPoint ptScroll = m_pContents->GetScrollPos();
+ CFX_FloatPoint ptOld = ptScroll;
if (ptScroll.y > sInfo.fContentMax)
ptScroll.y = sInfo.fContentMax;
@@ -1404,13 +1407,13 @@ void CPWL_Note::OnNotify(CPWL_Wnd* pWnd,
if (msg == PNM_SETCARETINFO && IsValid()) {
if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) {
if (m_pContents) {
- CPDF_Rect rcClient = m_pContents->GetClientRect();
+ CFX_FloatRect rcClient = m_pContents->GetClientRect();
if (pInfo->ptHead.y > rcClient.top) {
- CPDF_Point pt = m_pContents->OutToIn(pInfo->ptHead);
+ CFX_FloatPoint pt = m_pContents->OutToIn(pInfo->ptHead);
m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL,
(intptr_t)&pt.y);
- CPDF_Point ptScroll = m_pContents->GetScrollPos();
+ CFX_FloatPoint ptScroll = m_pContents->GetScrollPos();
m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
(intptr_t)&ptScroll.y);
@@ -1418,12 +1421,12 @@ void CPWL_Note::OnNotify(CPWL_Wnd* pWnd,
}
if (pInfo->ptFoot.y < rcClient.bottom) {
- CPDF_Point pt = m_pContents->OutToIn(pInfo->ptFoot);
+ CFX_FloatPoint pt = m_pContents->OutToIn(pInfo->ptFoot);
pt.y += rcClient.Height();
m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL,
(intptr_t)&pt.y);
- CPDF_Point ptScroll = m_pContents->GetScrollPos();
+ CFX_FloatPoint ptScroll = m_pContents->GetScrollPos();
m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
(intptr_t)&ptScroll.y);
@@ -1458,7 +1461,7 @@ void CPWL_Note::SetBkColor(const CPWL_Color& color) {
m_pRBBox->SetTextColor(sTextColor);
}
-FX_BOOL CPWL_Note::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) {
+FX_BOOL CPWL_Note::OnLButtonDown(const CFX_FloatPoint& point, FX_DWORD nFlag) {
if (m_pOptions->WndHitTest(m_pOptions->ParentToChild(point))) {
if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
int32_t x, y;
@@ -1475,7 +1478,7 @@ FX_BOOL CPWL_Note::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) {
return CPWL_Wnd::OnLButtonDown(point, nFlag);
}
-FX_BOOL CPWL_Note::OnRButtonUp(const CPDF_Point& point, FX_DWORD nFlag) {
+FX_BOOL CPWL_Note::OnRButtonUp(const CFX_FloatPoint& point, FX_DWORD nFlag) {
return CPWL_Wnd::OnRButtonUp(point, nFlag);
}