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

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

Issue 2341453002: CFX_FloatPoint default constructor and equals operators (Closed)
Patch Set: style Created 4 years, 3 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_Caret.h ('k') | fpdfsdk/pdfwindow/PWL_Edit.cpp » ('j') | 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_Caret.h" 7 #include "fpdfsdk/pdfwindow/PWL_Caret.h"
8 8
9 #include "core/fxge/include/cfx_graphstatedata.h" 9 #include "core/fxge/include/cfx_graphstatedata.h"
10 #include "core/fxge/include/cfx_pathdata.h" 10 #include "core/fxge/include/cfx_pathdata.h"
11 #include "core/fxge/include/cfx_renderdevice.h" 11 #include "core/fxge/include/cfx_renderdevice.h"
12 #include "fpdfsdk/pdfwindow/PWL_Utils.h" 12 #include "fpdfsdk/pdfwindow/PWL_Utils.h"
13 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" 13 #include "fpdfsdk/pdfwindow/PWL_Wnd.h"
14 14
15 #define PWL_CARET_FLASHINTERVAL 500 15 #define PWL_CARET_FLASHINTERVAL 500
16 16
17 CPWL_Caret::CPWL_Caret() 17 CPWL_Caret::CPWL_Caret() : m_bFlash(FALSE), m_fWidth(0.4f), m_nDelay(0) {}
18 : m_bFlash(FALSE),
19 m_ptHead(0, 0),
20 m_ptFoot(0, 0),
21 m_fWidth(0.4f),
22 m_nDelay(0) {}
23 18
24 CPWL_Caret::~CPWL_Caret() {} 19 CPWL_Caret::~CPWL_Caret() {}
25 20
26 CFX_ByteString CPWL_Caret::GetClassName() const { 21 CFX_ByteString CPWL_Caret::GetClassName() const {
27 return "CPWL_Caret"; 22 return "CPWL_Caret";
28 } 23 }
29 24
30 void CPWL_Caret::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { 25 void CPWL_Caret::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
31 GetCaretApp(sAppStream, CFX_FloatPoint(0.0f, 0.0f)); 26 GetCaretApp(sAppStream, CFX_FloatPoint(0.0f, 0.0f));
32 } 27 }
33 28
34 void CPWL_Caret::DrawThisAppearance(CFX_RenderDevice* pDevice, 29 void CPWL_Caret::DrawThisAppearance(CFX_RenderDevice* pDevice,
35 CFX_Matrix* pUser2Device) { 30 CFX_Matrix* pUser2Device) {
36 if (IsVisible() && m_bFlash) { 31 if (IsVisible() && m_bFlash) {
37 CFX_FloatRect rcRect = GetCaretRect(); 32 CFX_FloatRect rcRect = GetCaretRect();
38 CFX_FloatRect rcClip = GetClipRect(); 33 CFX_FloatRect rcClip = GetClipRect();
39
40 CFX_PathData path; 34 CFX_PathData path;
41
42 path.SetPointCount(2); 35 path.SetPointCount(2);
43 36
44 FX_FLOAT fCaretX = rcRect.left + m_fWidth * 0.5f; 37 FX_FLOAT fCaretX = rcRect.left + m_fWidth * 0.5f;
45 FX_FLOAT fCaretTop = rcRect.top; 38 FX_FLOAT fCaretTop = rcRect.top;
46 FX_FLOAT fCaretBottom = rcRect.bottom; 39 FX_FLOAT fCaretBottom = rcRect.bottom;
47
48 if (!rcClip.IsEmpty()) { 40 if (!rcClip.IsEmpty()) {
49 rcRect.Intersect(rcClip); 41 rcRect.Intersect(rcClip);
50 if (!rcRect.IsEmpty()) { 42 if (!rcRect.IsEmpty()) {
51 fCaretTop = rcRect.top; 43 fCaretTop = rcRect.top;
52 fCaretBottom = rcRect.bottom; 44 fCaretBottom = rcRect.bottom;
53 path.SetPoint(0, fCaretX, fCaretBottom, FXPT_MOVETO); 45 path.SetPoint(0, fCaretX, fCaretBottom, FXPT_MOVETO);
54 path.SetPoint(1, fCaretX, fCaretTop, FXPT_LINETO); 46 path.SetPoint(1, fCaretX, fCaretTop, FXPT_LINETO);
55 } else { 47 } else {
56 return; 48 return;
57 } 49 }
58 } else { 50 } else {
59 path.SetPoint(0, fCaretX, fCaretBottom, FXPT_MOVETO); 51 path.SetPoint(0, fCaretX, fCaretBottom, FXPT_MOVETO);
60 path.SetPoint(1, fCaretX, fCaretTop, FXPT_LINETO); 52 path.SetPoint(1, fCaretX, fCaretTop, FXPT_LINETO);
61 } 53 }
62 54
63 CFX_GraphStateData gsd; 55 CFX_GraphStateData gsd;
64 gsd.m_LineWidth = m_fWidth; 56 gsd.m_LineWidth = m_fWidth;
65
66 pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255, 0, 0, 0), 57 pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255, 0, 0, 0),
67 FXFILL_ALTERNATE); 58 FXFILL_ALTERNATE);
68 } 59 }
69 } 60 }
70 61
71 void CPWL_Caret::GetCaretApp(CFX_ByteTextBuf& sAppStream, 62 void CPWL_Caret::GetCaretApp(CFX_ByteTextBuf& sAppStream,
72 const CFX_FloatPoint& ptOffset) { 63 const CFX_FloatPoint& ptOffset) {
73 if (IsVisible() && m_bFlash) { 64 if (IsVisible() && m_bFlash) {
74 CFX_ByteTextBuf sCaret; 65 CFX_ByteTextBuf sCaret;
75 66
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 CFX_FloatRect CPWL_Caret::GetCaretRect() const { 103 CFX_FloatRect CPWL_Caret::GetCaretRect() const {
113 return CFX_FloatRect(m_ptFoot.x, m_ptFoot.y, m_ptHead.x + m_fWidth, 104 return CFX_FloatRect(m_ptFoot.x, m_ptFoot.y, m_ptHead.x + m_fWidth,
114 m_ptHead.y); 105 m_ptHead.y);
115 } 106 }
116 107
117 void CPWL_Caret::SetCaret(FX_BOOL bVisible, 108 void CPWL_Caret::SetCaret(FX_BOOL bVisible,
118 const CFX_FloatPoint& ptHead, 109 const CFX_FloatPoint& ptHead,
119 const CFX_FloatPoint& ptFoot) { 110 const CFX_FloatPoint& ptFoot) {
120 if (bVisible) { 111 if (bVisible) {
121 if (IsVisible()) { 112 if (IsVisible()) {
122 if (m_ptHead.x != ptHead.x || m_ptHead.y != ptHead.y || 113 if (m_ptHead != ptHead || m_ptFoot != ptFoot) {
123 m_ptFoot.x != ptFoot.x || m_ptFoot.y != ptFoot.y) {
124 m_ptHead = ptHead; 114 m_ptHead = ptHead;
125 m_ptFoot = ptFoot; 115 m_ptFoot = ptFoot;
126
127 m_bFlash = TRUE; 116 m_bFlash = TRUE;
128 Move(m_rcInvalid, FALSE, TRUE); 117 Move(m_rcInvalid, FALSE, TRUE);
129 } 118 }
130 } else { 119 } else {
131 m_ptHead = ptHead; 120 m_ptHead = ptHead;
132 m_ptFoot = ptFoot; 121 m_ptFoot = ptFoot;
133
134 EndTimer(); 122 EndTimer();
135 BeginTimer(PWL_CARET_FLASHINTERVAL); 123 BeginTimer(PWL_CARET_FLASHINTERVAL);
136
137 CPWL_Wnd::SetVisible(TRUE); 124 CPWL_Wnd::SetVisible(TRUE);
138 m_bFlash = TRUE; 125 m_bFlash = TRUE;
139
140 Move(m_rcInvalid, FALSE, TRUE); 126 Move(m_rcInvalid, FALSE, TRUE);
141 } 127 }
142 } else { 128 } else {
143 m_ptHead = CFX_FloatPoint(0, 0); 129 m_ptHead = CFX_FloatPoint();
144 m_ptFoot = CFX_FloatPoint(0, 0); 130 m_ptFoot = CFX_FloatPoint();
145
146 m_bFlash = FALSE; 131 m_bFlash = FALSE;
147 if (IsVisible()) { 132 if (IsVisible()) {
148 EndTimer(); 133 EndTimer();
149 CPWL_Wnd::SetVisible(FALSE); 134 CPWL_Wnd::SetVisible(FALSE);
150 } 135 }
151 } 136 }
152 } 137 }
153 138
154 void CPWL_Caret::InvalidateRect(CFX_FloatRect* pRect) { 139 void CPWL_Caret::InvalidateRect(CFX_FloatRect* pRect) {
155 if (pRect) { 140 if (pRect) {
156 CFX_FloatRect rcRefresh = CPWL_Utils::InflateRect(*pRect, 0.5f); 141 CFX_FloatRect rcRefresh = CPWL_Utils::InflateRect(*pRect, 0.5f);
157 rcRefresh.top += 1; 142 rcRefresh.top += 1;
158 rcRefresh.bottom -= 1; 143 rcRefresh.bottom -= 1;
159
160 CPWL_Wnd::InvalidateRect(&rcRefresh); 144 CPWL_Wnd::InvalidateRect(&rcRefresh);
161 } else { 145 } else {
162 CPWL_Wnd::InvalidateRect(pRect); 146 CPWL_Wnd::InvalidateRect(pRect);
163 } 147 }
164 } 148 }
OLDNEW
« no previous file with comments | « fpdfsdk/pdfwindow/PWL_Caret.h ('k') | fpdfsdk/pdfwindow/PWL_Edit.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698