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

Side by Side Diff: xfa/fxfa/app/xfa_fftextedit.cpp

Issue 1986503002: XFA_WIDGETSTATUS, LAYOUTSTATUS and WIDGETFILTER cleanup. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 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 | « xfa/fxfa/app/xfa_ffpageview.cpp ('k') | xfa/fxfa/app/xfa_ffwidget.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 "xfa/fxfa/app/xfa_fftextedit.h" 7 #include "xfa/fxfa/app/xfa_fftextedit.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 m_pNormalWidget->ModifyStyles(dwStyle, 0xFFFFFFFF); 94 m_pNormalWidget->ModifyStyles(dwStyle, 0xFFFFFFFF);
95 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); 95 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF);
96 } 96 }
97 FX_BOOL CXFA_FFTextEdit::OnLButtonDown(uint32_t dwFlags, 97 FX_BOOL CXFA_FFTextEdit::OnLButtonDown(uint32_t dwFlags,
98 FX_FLOAT fx, 98 FX_FLOAT fx,
99 FX_FLOAT fy) { 99 FX_FLOAT fy) {
100 if (!PtInActiveRect(fx, fy)) { 100 if (!PtInActiveRect(fx, fy)) {
101 return FALSE; 101 return FALSE;
102 } 102 }
103 if (!IsFocused()) { 103 if (!IsFocused()) {
104 m_dwStatus |= XFA_WIDGETSTATUS_Focused; 104 m_dwStatus |= XFA_WidgetStatus_Focused;
105 UpdateFWLData(); 105 UpdateFWLData();
106 AddInvalidateRect(); 106 AddInvalidateRect();
107 } 107 }
108 SetButtonDown(TRUE); 108 SetButtonDown(TRUE);
109 CFWL_MsgMouse ms; 109 CFWL_MsgMouse ms;
110 ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; 110 ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown;
111 ms.m_dwFlags = dwFlags; 111 ms.m_dwFlags = dwFlags;
112 ms.m_fx = fx; 112 ms.m_fx = fx;
113 ms.m_fy = fy; 113 ms.m_fy = fy;
114 ms.m_pDstTarget = m_pNormalWidget->m_pIface; 114 ms.m_pDstTarget = m_pNormalWidget->m_pIface;
115 FWLToClient(ms.m_fx, ms.m_fy); 115 FWLToClient(ms.m_fx, ms.m_fy);
116 TranslateFWLMessage(&ms); 116 TranslateFWLMessage(&ms);
117 return TRUE; 117 return TRUE;
118 } 118 }
119 FX_BOOL CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags, 119 FX_BOOL CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags,
120 FX_FLOAT fx, 120 FX_FLOAT fx,
121 FX_FLOAT fy) { 121 FX_FLOAT fy) {
122 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { 122 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) {
123 return FALSE; 123 return FALSE;
124 } 124 }
125 if (!PtInActiveRect(fx, fy)) { 125 if (!PtInActiveRect(fx, fy)) {
126 return FALSE; 126 return FALSE;
127 } 127 }
128 if (!IsFocused()) { 128 if (!IsFocused()) {
129 m_dwStatus |= XFA_WIDGETSTATUS_Focused; 129 m_dwStatus |= XFA_WidgetStatus_Focused;
130 UpdateFWLData(); 130 UpdateFWLData();
131 AddInvalidateRect(); 131 AddInvalidateRect();
132 } 132 }
133 SetButtonDown(TRUE); 133 SetButtonDown(TRUE);
134 CFWL_MsgMouse ms; 134 CFWL_MsgMouse ms;
135 ms.m_dwCmd = FWL_MouseCommand::RightButtonDown; 135 ms.m_dwCmd = FWL_MouseCommand::RightButtonDown;
136 ms.m_dwFlags = dwFlags; 136 ms.m_dwFlags = dwFlags;
137 ms.m_fx = fx; 137 ms.m_fx = fx;
138 ms.m_fy = fy; 138 ms.m_fy = fy;
139 FWLToClient(ms.m_fx, ms.m_fy); 139 FWLToClient(ms.m_fx, ms.m_fy);
140 TranslateFWLMessage(&ms); 140 TranslateFWLMessage(&ms);
141 return TRUE; 141 return TRUE;
142 } 142 }
143 FX_BOOL CXFA_FFTextEdit::OnRButtonUp(uint32_t dwFlags, 143 FX_BOOL CXFA_FFTextEdit::OnRButtonUp(uint32_t dwFlags,
144 FX_FLOAT fx, 144 FX_FLOAT fx,
145 FX_FLOAT fy) { 145 FX_FLOAT fy) {
146 if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) 146 if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy))
147 return FALSE; 147 return FALSE;
148 148
149 GetDoc()->GetDocProvider()->PopupMenu(this, CFX_PointF(fx, fy), nullptr); 149 GetDoc()->GetDocProvider()->PopupMenu(this, CFX_PointF(fx, fy), nullptr);
150 return TRUE; 150 return TRUE;
151 } 151 }
152 FX_BOOL CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) { 152 FX_BOOL CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) {
153 m_dwStatus &= ~XFA_WIDGETSTATUS_TextEditValueChanged; 153 m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged;
154 if (!IsFocused()) { 154 if (!IsFocused()) {
155 m_dwStatus |= XFA_WIDGETSTATUS_Focused; 155 m_dwStatus |= XFA_WidgetStatus_Focused;
156 UpdateFWLData(); 156 UpdateFWLData();
157 AddInvalidateRect(); 157 AddInvalidateRect();
158 } 158 }
159 CXFA_FFWidget::OnSetFocus(pOldWidget); 159 CXFA_FFWidget::OnSetFocus(pOldWidget);
160 CFWL_MsgSetFocus ms; 160 CFWL_MsgSetFocus ms;
161 ms.m_pDstTarget = m_pNormalWidget->m_pIface; 161 ms.m_pDstTarget = m_pNormalWidget->m_pIface;
162 ms.m_pSrcTarget = NULL; 162 ms.m_pSrcTarget = NULL;
163 TranslateFWLMessage(&ms); 163 TranslateFWLMessage(&ms);
164 return TRUE; 164 return TRUE;
165 } 165 }
166 FX_BOOL CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) { 166 FX_BOOL CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) {
167 CFWL_MsgKillFocus ms; 167 CFWL_MsgKillFocus ms;
168 ms.m_pDstTarget = m_pNormalWidget->m_pIface; 168 ms.m_pDstTarget = m_pNormalWidget->m_pIface;
169 ms.m_pSrcTarget = NULL; 169 ms.m_pSrcTarget = NULL;
170 TranslateFWLMessage(&ms); 170 TranslateFWLMessage(&ms);
171 m_dwStatus &= ~XFA_WIDGETSTATUS_Focused; 171 m_dwStatus &= ~XFA_WidgetStatus_Focused;
172 SetEditScrollOffset(); 172 SetEditScrollOffset();
173 ProcessCommittedData(); 173 ProcessCommittedData();
174 UpdateFWLData(); 174 UpdateFWLData();
175 AddInvalidateRect(); 175 AddInvalidateRect();
176 CXFA_FFWidget::OnKillFocus(pNewWidget); 176 CXFA_FFWidget::OnKillFocus(pNewWidget);
177 m_dwStatus &= ~XFA_WIDGETSTATUS_TextEditValueChanged; 177 m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged;
178 return TRUE; 178 return TRUE;
179 } 179 }
180 FX_BOOL CXFA_FFTextEdit::CommitData() { 180 FX_BOOL CXFA_FFTextEdit::CommitData() {
181 CFX_WideString wsText; 181 CFX_WideString wsText;
182 ((CFWL_Edit*)m_pNormalWidget)->GetText(wsText); 182 ((CFWL_Edit*)m_pNormalWidget)->GetText(wsText);
183 if (m_pDataAcc->SetValue(wsText, XFA_VALUEPICTURE_Edit)) { 183 if (m_pDataAcc->SetValue(wsText, XFA_VALUEPICTURE_Edit)) {
184 m_pDataAcc->UpdateUIDisplay(this); 184 m_pDataAcc->UpdateUIDisplay(this);
185 return TRUE; 185 return TRUE;
186 } 186 }
187 ValidateNumberField(wsText); 187 ValidateNumberField(wsText);
(...skipping 10 matching lines...) Expand all
198 pAppProvider->LoadString(XFA_IDS_ValidateNumberError, wsError); 198 pAppProvider->LoadString(XFA_IDS_ValidateNumberError, wsError);
199 CFX_WideString wsSomField; 199 CFX_WideString wsSomField;
200 pAcc->GetNode()->GetSOMExpression(wsSomField); 200 pAcc->GetNode()->GetSOMExpression(wsSomField);
201 CFX_WideString wsMessage; 201 CFX_WideString wsMessage;
202 wsMessage.Format(wsError.c_str(), wsText.c_str(), wsSomField.c_str()); 202 wsMessage.Format(wsError.c_str(), wsText.c_str(), wsSomField.c_str());
203 pAppProvider->MsgBox(wsMessage, wsTitle, XFA_MBICON_Error, XFA_MB_OK); 203 pAppProvider->MsgBox(wsMessage, wsTitle, XFA_MBICON_Error, XFA_MB_OK);
204 } 204 }
205 } 205 }
206 } 206 }
207 FX_BOOL CXFA_FFTextEdit::IsDataChanged() { 207 FX_BOOL CXFA_FFTextEdit::IsDataChanged() {
208 return (m_dwStatus & XFA_WIDGETSTATUS_TextEditValueChanged) != 0; 208 return (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) != 0;
209 } 209 }
210 uint32_t CXFA_FFTextEdit::GetAlignment() { 210 uint32_t CXFA_FFTextEdit::GetAlignment() {
211 uint32_t dwExtendedStyle = 0; 211 uint32_t dwExtendedStyle = 0;
212 if (CXFA_Para para = m_pDataAcc->GetPara()) { 212 if (CXFA_Para para = m_pDataAcc->GetPara()) {
213 int32_t iHorz = para.GetHorizontalAlign(); 213 int32_t iHorz = para.GetHorizontalAlign();
214 switch (iHorz) { 214 switch (iHorz) {
215 case XFA_ATTRIBUTEENUM_Center: 215 case XFA_ATTRIBUTEENUM_Center:
216 dwExtendedStyle |= FWL_STYLEEXT_EDT_HCenter; 216 dwExtendedStyle |= FWL_STYLEEXT_EDT_HCenter;
217 break; 217 break;
218 case XFA_ATTRIBUTEENUM_Justify: 218 case XFA_ATTRIBUTEENUM_Justify:
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { 349 if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) {
350 return FALSE; 350 return FALSE;
351 } 351 }
352 FWLToClient(pointf.x, pointf.y); 352 FWLToClient(pointf.x, pointf.y);
353 return ((CFWL_Edit*)m_pNormalWidget) 353 return ((CFWL_Edit*)m_pNormalWidget)
354 ->ReplaceSpellCheckWord(pointf, bsReplace); 354 ->ReplaceSpellCheckWord(pointf, bsReplace);
355 } 355 }
356 void CXFA_FFTextEdit::OnTextChanged(IFWL_Widget* pWidget, 356 void CXFA_FFTextEdit::OnTextChanged(IFWL_Widget* pWidget,
357 const CFX_WideString& wsChanged, 357 const CFX_WideString& wsChanged,
358 const CFX_WideString& wsPrevText) { 358 const CFX_WideString& wsPrevText) {
359 m_dwStatus |= XFA_WIDGETSTATUS_TextEditValueChanged; 359 m_dwStatus |= XFA_WidgetStatus_TextEditValueChanged;
360 CXFA_EventParam eParam; 360 CXFA_EventParam eParam;
361 eParam.m_eType = XFA_EVENT_Change; 361 eParam.m_eType = XFA_EVENT_Change;
362 eParam.m_wsChange = wsChanged; 362 eParam.m_wsChange = wsChanged;
363 eParam.m_pTarget = m_pDataAcc; 363 eParam.m_pTarget = m_pDataAcc;
364 eParam.m_wsPrevText = wsPrevText; 364 eParam.m_wsPrevText = wsPrevText;
365 CFWL_Edit* pEdit = ((CFWL_Edit*)m_pNormalWidget); 365 CFWL_Edit* pEdit = ((CFWL_Edit*)m_pNormalWidget);
366 if (m_pDataAcc->GetUIType() == XFA_ELEMENT_DateTimeEdit) { 366 if (m_pDataAcc->GetUIType() == XFA_ELEMENT_DateTimeEdit) {
367 CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)pEdit; 367 CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)pEdit;
368 pDateTime->GetEditText(eParam.m_wsNewText); 368 pDateTime->GetEditText(eParam.m_wsNewText);
369 int32_t iSels = pDateTime->CountSelRanges(); 369 int32_t iSels = pDateTime->CountSelRanges();
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 if ((FX_UNITIME)date != 0) { 705 if ((FX_UNITIME)date != 0) {
706 ((CFWL_DateTimePicker*)m_pNormalWidget) 706 ((CFWL_DateTimePicker*)m_pNormalWidget)
707 ->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); 707 ->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay());
708 } 708 }
709 } 709 }
710 } 710 }
711 m_pNormalWidget->Update(); 711 m_pNormalWidget->Update();
712 return TRUE; 712 return TRUE;
713 } 713 }
714 FX_BOOL CXFA_FFDateTimeEdit::IsDataChanged() { 714 FX_BOOL CXFA_FFDateTimeEdit::IsDataChanged() {
715 if (m_dwStatus & XFA_WIDGETSTATUS_TextEditValueChanged) { 715 if (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) {
716 return TRUE; 716 return TRUE;
717 } 717 }
718 CFX_WideString wsText; 718 CFX_WideString wsText;
719 ((CFWL_DateTimePicker*)m_pNormalWidget)->GetEditText(wsText); 719 ((CFWL_DateTimePicker*)m_pNormalWidget)->GetEditText(wsText);
720 CFX_WideString wsOldValue; 720 CFX_WideString wsOldValue;
721 m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Edit); 721 m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Edit);
722 return wsOldValue != wsText; 722 return wsOldValue != wsText;
723 } 723 }
724 FX_BOOL CXFA_FFDateTimeEdit::CanUndo() { 724 FX_BOOL CXFA_FFDateTimeEdit::CanUndo() {
725 return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanUndo(); 725 return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanUndo();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 792
793 void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { 793 void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) {
794 if (pEvent->GetClassID() == CFWL_EventType::SelectChanged) { 794 if (pEvent->GetClassID() == CFWL_EventType::SelectChanged) {
795 CFWL_Event_DtpSelectChanged* event = (CFWL_Event_DtpSelectChanged*)pEvent; 795 CFWL_Event_DtpSelectChanged* event = (CFWL_Event_DtpSelectChanged*)pEvent;
796 OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth, 796 OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth,
797 event->iDay); 797 event->iDay);
798 return; 798 return;
799 } 799 }
800 CXFA_FFTextEdit::OnProcessEvent(pEvent); 800 CXFA_FFTextEdit::OnProcessEvent(pEvent);
801 } 801 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffpageview.cpp ('k') | xfa/fxfa/app/xfa_ffwidget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698