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 "xfa/fxfa/app/xfa_fftextedit.h" | 7 #include "xfa/fxfa/app/xfa_fftextedit.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "xfa/fwl/core/cfwl_datetimepicker.h" | 11 #include "xfa/fwl/cfwl_datetimepicker.h" |
12 #include "xfa/fwl/core/cfwl_edit.h" | 12 #include "xfa/fwl/cfwl_edit.h" |
13 #include "xfa/fwl/core/cfwl_evtcheckword.h" | 13 #include "xfa/fwl/cfwl_eventcheckword.h" |
14 #include "xfa/fwl/core/cfwl_evtselectchanged.h" | 14 #include "xfa/fwl/cfwl_eventselectchanged.h" |
15 #include "xfa/fwl/core/cfwl_evttextchanged.h" | 15 #include "xfa/fwl/cfwl_eventtextchanged.h" |
16 #include "xfa/fwl/core/cfwl_evtvalidate.h" | 16 #include "xfa/fwl/cfwl_eventvalidate.h" |
17 #include "xfa/fwl/core/cfwl_msgkillfocus.h" | 17 #include "xfa/fwl/cfwl_messagekillfocus.h" |
18 #include "xfa/fwl/core/cfwl_msgmouse.h" | 18 #include "xfa/fwl/cfwl_messagemouse.h" |
19 #include "xfa/fwl/core/cfwl_msgsetfocus.h" | 19 #include "xfa/fwl/cfwl_messagesetfocus.h" |
20 #include "xfa/fwl/core/cfwl_notedriver.h" | 20 #include "xfa/fwl/cfwl_notedriver.h" |
21 #include "xfa/fxfa/app/xfa_fffield.h" | 21 #include "xfa/fxfa/app/xfa_fffield.h" |
22 #include "xfa/fxfa/app/xfa_fwladapter.h" | 22 #include "xfa/fxfa/app/xfa_fwladapter.h" |
23 #include "xfa/fxfa/app/xfa_textlayout.h" | 23 #include "xfa/fxfa/app/xfa_textlayout.h" |
24 #include "xfa/fxfa/cxfa_eventparam.h" | 24 #include "xfa/fxfa/cxfa_eventparam.h" |
25 #include "xfa/fxfa/parser/xfa_localevalue.h" | 25 #include "xfa/fxfa/parser/xfa_localevalue.h" |
26 #include "xfa/fxfa/xfa_ffapp.h" | 26 #include "xfa/fxfa/xfa_ffapp.h" |
27 #include "xfa/fxfa/xfa_ffdoc.h" | 27 #include "xfa/fxfa/xfa_ffdoc.h" |
28 #include "xfa/fxfa/xfa_ffdocview.h" | 28 #include "xfa/fxfa/xfa_ffdocview.h" |
29 #include "xfa/fxfa/xfa_ffpageview.h" | 29 #include "xfa/fxfa/xfa_ffpageview.h" |
30 #include "xfa/fxfa/xfa_ffwidget.h" | 30 #include "xfa/fxfa/xfa_ffwidget.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 FX_FLOAT fy) { | 110 FX_FLOAT fy) { |
111 if (!PtInActiveRect(fx, fy)) { | 111 if (!PtInActiveRect(fx, fy)) { |
112 return false; | 112 return false; |
113 } | 113 } |
114 if (!IsFocused()) { | 114 if (!IsFocused()) { |
115 m_dwStatus |= XFA_WidgetStatus_Focused; | 115 m_dwStatus |= XFA_WidgetStatus_Focused; |
116 UpdateFWLData(); | 116 UpdateFWLData(); |
117 AddInvalidateRect(); | 117 AddInvalidateRect(); |
118 } | 118 } |
119 SetButtonDown(true); | 119 SetButtonDown(true); |
120 CFWL_MsgMouse ms(nullptr, m_pNormalWidget); | 120 CFWL_MessageMouse ms(nullptr, m_pNormalWidget); |
121 ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; | 121 ms.m_dwCmd = FWL_MouseCommand::LeftButtonDown; |
122 ms.m_dwFlags = dwFlags; | 122 ms.m_dwFlags = dwFlags; |
123 ms.m_fx = fx; | 123 ms.m_fx = fx; |
124 ms.m_fy = fy; | 124 ms.m_fy = fy; |
125 FWLToClient(ms.m_fx, ms.m_fy); | 125 FWLToClient(ms.m_fx, ms.m_fy); |
126 TranslateFWLMessage(&ms); | 126 TranslateFWLMessage(&ms); |
127 return true; | 127 return true; |
128 } | 128 } |
129 bool CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags, | 129 bool CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags, |
130 FX_FLOAT fx, | 130 FX_FLOAT fx, |
131 FX_FLOAT fy) { | 131 FX_FLOAT fy) { |
132 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { | 132 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { |
133 return false; | 133 return false; |
134 } | 134 } |
135 if (!PtInActiveRect(fx, fy)) { | 135 if (!PtInActiveRect(fx, fy)) { |
136 return false; | 136 return false; |
137 } | 137 } |
138 if (!IsFocused()) { | 138 if (!IsFocused()) { |
139 m_dwStatus |= XFA_WidgetStatus_Focused; | 139 m_dwStatus |= XFA_WidgetStatus_Focused; |
140 UpdateFWLData(); | 140 UpdateFWLData(); |
141 AddInvalidateRect(); | 141 AddInvalidateRect(); |
142 } | 142 } |
143 SetButtonDown(true); | 143 SetButtonDown(true); |
144 CFWL_MsgMouse ms(nullptr, nullptr); | 144 CFWL_MessageMouse ms(nullptr, nullptr); |
145 ms.m_dwCmd = FWL_MouseCommand::RightButtonDown; | 145 ms.m_dwCmd = FWL_MouseCommand::RightButtonDown; |
146 ms.m_dwFlags = dwFlags; | 146 ms.m_dwFlags = dwFlags; |
147 ms.m_fx = fx; | 147 ms.m_fx = fx; |
148 ms.m_fy = fy; | 148 ms.m_fy = fy; |
149 FWLToClient(ms.m_fx, ms.m_fy); | 149 FWLToClient(ms.m_fx, ms.m_fy); |
150 TranslateFWLMessage(&ms); | 150 TranslateFWLMessage(&ms); |
151 return true; | 151 return true; |
152 } | 152 } |
153 bool CXFA_FFTextEdit::OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { | 153 bool CXFA_FFTextEdit::OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { |
154 if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) | 154 if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) |
155 return false; | 155 return false; |
156 | 156 |
157 GetDoc()->GetDocEnvironment()->PopupMenu(this, CFX_PointF(fx, fy)); | 157 GetDoc()->GetDocEnvironment()->PopupMenu(this, CFX_PointF(fx, fy)); |
158 return true; | 158 return true; |
159 } | 159 } |
160 bool CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) { | 160 bool CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) { |
161 m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; | 161 m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; |
162 if (!IsFocused()) { | 162 if (!IsFocused()) { |
163 m_dwStatus |= XFA_WidgetStatus_Focused; | 163 m_dwStatus |= XFA_WidgetStatus_Focused; |
164 UpdateFWLData(); | 164 UpdateFWLData(); |
165 AddInvalidateRect(); | 165 AddInvalidateRect(); |
166 } | 166 } |
167 CXFA_FFWidget::OnSetFocus(pOldWidget); | 167 CXFA_FFWidget::OnSetFocus(pOldWidget); |
168 CFWL_MsgSetFocus ms(nullptr, m_pNormalWidget); | 168 CFWL_MessageSetFocus ms(nullptr, m_pNormalWidget); |
169 TranslateFWLMessage(&ms); | 169 TranslateFWLMessage(&ms); |
170 return true; | 170 return true; |
171 } | 171 } |
172 bool CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) { | 172 bool CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) { |
173 CFWL_MsgKillFocus ms(nullptr, m_pNormalWidget); | 173 CFWL_MessageKillFocus ms(nullptr, m_pNormalWidget); |
174 TranslateFWLMessage(&ms); | 174 TranslateFWLMessage(&ms); |
175 m_dwStatus &= ~XFA_WidgetStatus_Focused; | 175 m_dwStatus &= ~XFA_WidgetStatus_Focused; |
176 SetEditScrollOffset(); | 176 SetEditScrollOffset(); |
177 ProcessCommittedData(); | 177 ProcessCommittedData(); |
178 UpdateFWLData(); | 178 UpdateFWLData(); |
179 AddInvalidateRect(); | 179 AddInvalidateRect(); |
180 CXFA_FFWidget::OnKillFocus(pNewWidget); | 180 CXFA_FFWidget::OnKillFocus(pNewWidget); |
181 m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; | 181 m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; |
182 return true; | 182 return true; |
183 } | 183 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 } | 328 } |
329 | 329 |
330 void CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) { | 330 void CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) { |
331 m_pOldDelegate->OnProcessMessage(pMessage); | 331 m_pOldDelegate->OnProcessMessage(pMessage); |
332 } | 332 } |
333 | 333 |
334 void CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { | 334 void CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { |
335 CXFA_FFField::OnProcessEvent(pEvent); | 335 CXFA_FFField::OnProcessEvent(pEvent); |
336 switch (pEvent->GetType()) { | 336 switch (pEvent->GetType()) { |
337 case CFWL_Event::Type::TextChanged: { | 337 case CFWL_Event::Type::TextChanged: { |
338 CFWL_EvtTextChanged* event = static_cast<CFWL_EvtTextChanged*>(pEvent); | 338 CFWL_EventTextChanged* event = |
| 339 static_cast<CFWL_EventTextChanged*>(pEvent); |
339 CFX_WideString wsChange; | 340 CFX_WideString wsChange; |
340 OnTextChanged(m_pNormalWidget, wsChange, event->wsPrevText); | 341 OnTextChanged(m_pNormalWidget, wsChange, event->wsPrevText); |
341 break; | 342 break; |
342 } | 343 } |
343 case CFWL_Event::Type::TextFull: { | 344 case CFWL_Event::Type::TextFull: { |
344 OnTextFull(m_pNormalWidget); | 345 OnTextFull(m_pNormalWidget); |
345 break; | 346 break; |
346 } | 347 } |
347 case CFWL_Event::Type::CheckWord: { | 348 case CFWL_Event::Type::CheckWord: { |
348 CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged"); | 349 CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged"); |
349 CFWL_EvtCheckWord* event = static_cast<CFWL_EvtCheckWord*>(pEvent); | 350 CFWL_EventCheckWord* event = static_cast<CFWL_EventCheckWord*>(pEvent); |
350 event->bCheckWord = CheckWord(event->bsWord.AsStringC()); | 351 event->bCheckWord = CheckWord(event->bsWord.AsStringC()); |
351 break; | 352 break; |
352 } | 353 } |
353 default: | 354 default: |
354 break; | 355 break; |
355 } | 356 } |
356 m_pOldDelegate->OnProcessEvent(pEvent); | 357 m_pOldDelegate->OnProcessEvent(pEvent); |
357 } | 358 } |
358 | 359 |
359 void CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, | 360 void CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 dwExtendedStyle |= GetAlignment(); | 408 dwExtendedStyle |= GetAlignment(); |
408 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || | 409 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || |
409 !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { | 410 !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { |
410 dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; | 411 dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; |
411 } | 412 } |
412 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); | 413 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); |
413 } | 414 } |
414 | 415 |
415 void CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) { | 416 void CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) { |
416 if (pEvent->GetType() == CFWL_Event::Type::Validate) { | 417 if (pEvent->GetType() == CFWL_Event::Type::Validate) { |
417 CFWL_EvtValidate* event = static_cast<CFWL_EvtValidate*>(pEvent); | 418 CFWL_EventValidate* event = static_cast<CFWL_EventValidate*>(pEvent); |
418 event->bValidate = OnValidate(m_pNormalWidget, event->wsInsert); | 419 event->bValidate = OnValidate(m_pNormalWidget, event->wsInsert); |
419 return; | 420 return; |
420 } | 421 } |
421 CXFA_FFTextEdit::OnProcessEvent(pEvent); | 422 CXFA_FFTextEdit::OnProcessEvent(pEvent); |
422 } | 423 } |
423 | 424 |
424 bool CXFA_FFNumericEdit::OnValidate(CFWL_Widget* pWidget, | 425 bool CXFA_FFNumericEdit::OnValidate(CFWL_Widget* pWidget, |
425 CFX_WideString& wsText) { | 426 CFX_WideString& wsText) { |
426 CFX_WideString wsPattern; | 427 CFX_WideString wsPattern; |
427 m_pDataAcc->GetPictureContent(wsPattern, XFA_VALUEPICTURE_Edit); | 428 m_pDataAcc->GetPictureContent(wsPattern, XFA_VALUEPICTURE_Edit); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 GetDoc()->GetDocEnvironment()->SetFocusWidget(GetDoc(), nullptr); | 673 GetDoc()->GetDocEnvironment()->SetFocusWidget(GetDoc(), nullptr); |
673 CXFA_EventParam eParam; | 674 CXFA_EventParam eParam; |
674 eParam.m_eType = XFA_EVENT_Change; | 675 eParam.m_eType = XFA_EVENT_Change; |
675 eParam.m_pTarget = m_pDataAcc; | 676 eParam.m_pTarget = m_pDataAcc; |
676 m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); | 677 m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); |
677 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); | 678 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); |
678 } | 679 } |
679 | 680 |
680 void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { | 681 void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { |
681 if (pEvent->GetType() == CFWL_Event::Type::SelectChanged) { | 682 if (pEvent->GetType() == CFWL_Event::Type::SelectChanged) { |
682 CFWL_EvtSelectChanged* event = static_cast<CFWL_EvtSelectChanged*>(pEvent); | 683 CFWL_EventSelectChanged* event = |
| 684 static_cast<CFWL_EventSelectChanged*>(pEvent); |
683 OnSelectChanged(m_pNormalWidget, event->iYear, event->iMonth, event->iDay); | 685 OnSelectChanged(m_pNormalWidget, event->iYear, event->iMonth, event->iDay); |
684 return; | 686 return; |
685 } | 687 } |
686 CXFA_FFTextEdit::OnProcessEvent(pEvent); | 688 CXFA_FFTextEdit::OnProcessEvent(pEvent); |
687 } | 689 } |
OLD | NEW |