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 |
(...skipping 17 matching lines...) Expand all Loading... |
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" |
31 | 31 |
32 CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_FFPageView* pPageView, | 32 CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_FFPageView* pPageView, |
33 CXFA_WidgetAcc* pDataAcc) | 33 CXFA_WidgetAcc* pDataAcc) |
34 : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(nullptr) {} | 34 : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(nullptr) {} |
35 | 35 |
36 CXFA_FFTextEdit::~CXFA_FFTextEdit() { | 36 CXFA_FFTextEdit::~CXFA_FFTextEdit() { |
37 if (m_pNormalWidget) { | 37 if (m_pNormalWidget) { |
38 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); | 38 CFWL_NoteDriver* pNoteDriver = |
39 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); | 39 m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); |
40 pNoteDriver->UnregisterEventTarget(pWidget); | 40 pNoteDriver->UnregisterEventTarget(m_pNormalWidget); |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 bool CXFA_FFTextEdit::LoadWidget() { | 44 bool CXFA_FFTextEdit::LoadWidget() { |
45 CFWL_Edit* pFWLEdit = new CFWL_Edit(GetFWLApp()); | 45 CFWL_Edit* pFWLEdit = new CFWL_Edit( |
46 pFWLEdit->Initialize(); | 46 GetFWLApp(), pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr); |
47 m_pNormalWidget = pFWLEdit; | 47 m_pNormalWidget = pFWLEdit; |
48 m_pNormalWidget->SetLayoutItem(this); | 48 m_pNormalWidget->SetLayoutItem(this); |
49 | 49 |
50 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); | 50 CFWL_NoteDriver* pNoteDriver = |
51 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); | 51 m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); |
52 pNoteDriver->RegisterEventTarget(pWidget, pWidget); | 52 pNoteDriver->RegisterEventTarget(m_pNormalWidget, m_pNormalWidget); |
53 | 53 |
54 m_pOldDelegate = m_pNormalWidget->GetDelegate(); | 54 m_pOldDelegate = m_pNormalWidget->GetDelegate(); |
55 m_pNormalWidget->SetDelegate(this); | 55 m_pNormalWidget->SetDelegate(this); |
56 m_pNormalWidget->LockUpdate(); | 56 m_pNormalWidget->LockUpdate(); |
57 | 57 |
58 UpdateWidgetProperty(); | 58 UpdateWidgetProperty(); |
59 CFX_WideString wsText; | 59 CFX_WideString wsText; |
60 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); | 60 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); |
61 pFWLEdit->SetText(wsText); | 61 pFWLEdit->SetText(wsText); |
62 m_pNormalWidget->UnlockUpdate(); | 62 m_pNormalWidget->UnlockUpdate(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; | 120 CFWL_MsgMouse ms; |
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 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); | 125 ms.m_pDstTarget = m_pNormalWidget; |
126 FWLToClient(ms.m_fx, ms.m_fy); | 126 FWLToClient(ms.m_fx, ms.m_fy); |
127 TranslateFWLMessage(&ms); | 127 TranslateFWLMessage(&ms); |
128 return true; | 128 return true; |
129 } | 129 } |
130 bool CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags, | 130 bool CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags, |
131 FX_FLOAT fx, | 131 FX_FLOAT fx, |
132 FX_FLOAT fy) { | 132 FX_FLOAT fy) { |
133 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { | 133 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) { |
134 return false; | 134 return false; |
135 } | 135 } |
(...skipping 24 matching lines...) Expand all Loading... |
160 } | 160 } |
161 bool CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) { | 161 bool CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) { |
162 m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; | 162 m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; |
163 if (!IsFocused()) { | 163 if (!IsFocused()) { |
164 m_dwStatus |= XFA_WidgetStatus_Focused; | 164 m_dwStatus |= XFA_WidgetStatus_Focused; |
165 UpdateFWLData(); | 165 UpdateFWLData(); |
166 AddInvalidateRect(); | 166 AddInvalidateRect(); |
167 } | 167 } |
168 CXFA_FFWidget::OnSetFocus(pOldWidget); | 168 CXFA_FFWidget::OnSetFocus(pOldWidget); |
169 CFWL_MsgSetFocus ms; | 169 CFWL_MsgSetFocus ms; |
170 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); | 170 ms.m_pDstTarget = m_pNormalWidget; |
171 ms.m_pSrcTarget = nullptr; | 171 ms.m_pSrcTarget = nullptr; |
172 TranslateFWLMessage(&ms); | 172 TranslateFWLMessage(&ms); |
173 return true; | 173 return true; |
174 } | 174 } |
175 bool CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) { | 175 bool CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) { |
176 CFWL_MsgKillFocus ms; | 176 CFWL_MsgKillFocus ms; |
177 ms.m_pDstTarget = m_pNormalWidget->GetWidget(); | 177 ms.m_pDstTarget = m_pNormalWidget; |
178 ms.m_pSrcTarget = nullptr; | 178 ms.m_pSrcTarget = nullptr; |
179 TranslateFWLMessage(&ms); | 179 TranslateFWLMessage(&ms); |
180 m_dwStatus &= ~XFA_WidgetStatus_Focused; | 180 m_dwStatus &= ~XFA_WidgetStatus_Focused; |
181 SetEditScrollOffset(); | 181 SetEditScrollOffset(); |
182 ProcessCommittedData(); | 182 ProcessCommittedData(); |
183 UpdateFWLData(); | 183 UpdateFWLData(); |
184 AddInvalidateRect(); | 184 AddInvalidateRect(); |
185 CXFA_FFWidget::OnKillFocus(pNewWidget); | 185 CXFA_FFWidget::OnKillFocus(pNewWidget); |
186 m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; | 186 m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; |
187 return true; | 187 return true; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 ((CFWL_Edit*)m_pNormalWidget)->GetText(wsOldText); | 287 ((CFWL_Edit*)m_pNormalWidget)->GetText(wsOldText); |
288 if (wsText != wsOldText || (eType == XFA_VALUEPICTURE_Edit && bUpdate)) { | 288 if (wsText != wsOldText || (eType == XFA_VALUEPICTURE_Edit && bUpdate)) { |
289 ((CFWL_Edit*)m_pNormalWidget)->SetText(wsText); | 289 ((CFWL_Edit*)m_pNormalWidget)->SetText(wsText); |
290 bUpdate = true; | 290 bUpdate = true; |
291 } | 291 } |
292 if (bUpdate) { | 292 if (bUpdate) { |
293 m_pNormalWidget->Update(); | 293 m_pNormalWidget->Update(); |
294 } | 294 } |
295 return true; | 295 return true; |
296 } | 296 } |
297 void CXFA_FFTextEdit::OnTextChanged(IFWL_Widget* pWidget, | 297 void CXFA_FFTextEdit::OnTextChanged(CFWL_Widget* pWidget, |
298 const CFX_WideString& wsChanged, | 298 const CFX_WideString& wsChanged, |
299 const CFX_WideString& wsPrevText) { | 299 const CFX_WideString& wsPrevText) { |
300 m_dwStatus |= XFA_WidgetStatus_TextEditValueChanged; | 300 m_dwStatus |= XFA_WidgetStatus_TextEditValueChanged; |
301 CXFA_EventParam eParam; | 301 CXFA_EventParam eParam; |
302 eParam.m_eType = XFA_EVENT_Change; | 302 eParam.m_eType = XFA_EVENT_Change; |
303 eParam.m_wsChange = wsChanged; | 303 eParam.m_wsChange = wsChanged; |
304 eParam.m_pTarget = m_pDataAcc; | 304 eParam.m_pTarget = m_pDataAcc; |
305 eParam.m_wsPrevText = wsPrevText; | 305 eParam.m_wsPrevText = wsPrevText; |
306 CFWL_Edit* pEdit = ((CFWL_Edit*)m_pNormalWidget); | 306 CFWL_Edit* pEdit = ((CFWL_Edit*)m_pNormalWidget); |
307 if (m_pDataAcc->GetUIType() == XFA_Element::DateTimeEdit) { | 307 if (m_pDataAcc->GetUIType() == XFA_Element::DateTimeEdit) { |
308 CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)pEdit; | 308 CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)pEdit; |
309 pDateTime->GetEditText(eParam.m_wsNewText); | 309 pDateTime->GetEditText(eParam.m_wsNewText); |
310 int32_t iSels = pDateTime->CountSelRanges(); | 310 int32_t iSels = pDateTime->CountSelRanges(); |
311 if (iSels) { | 311 if (iSels) { |
312 eParam.m_iSelEnd = pDateTime->GetSelRange(0, eParam.m_iSelStart); | 312 eParam.m_iSelEnd = pDateTime->GetSelRange(0, eParam.m_iSelStart); |
313 } | 313 } |
314 } else { | 314 } else { |
315 pEdit->GetText(eParam.m_wsNewText); | 315 pEdit->GetText(eParam.m_wsNewText); |
316 int32_t iSels = pEdit->CountSelRanges(); | 316 int32_t iSels = pEdit->CountSelRanges(); |
317 if (iSels) { | 317 if (iSels) { |
318 eParam.m_iSelEnd = pEdit->GetSelRange(0, eParam.m_iSelStart); | 318 eParam.m_iSelEnd = pEdit->GetSelRange(0, eParam.m_iSelStart); |
319 } | 319 } |
320 } | 320 } |
321 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); | 321 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); |
322 } | 322 } |
323 void CXFA_FFTextEdit::OnTextFull(IFWL_Widget* pWidget) { | 323 void CXFA_FFTextEdit::OnTextFull(CFWL_Widget* pWidget) { |
324 CXFA_EventParam eParam; | 324 CXFA_EventParam eParam; |
325 eParam.m_eType = XFA_EVENT_Full; | 325 eParam.m_eType = XFA_EVENT_Full; |
326 eParam.m_pTarget = m_pDataAcc; | 326 eParam.m_pTarget = m_pDataAcc; |
327 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Full, &eParam); | 327 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Full, &eParam); |
328 } | 328 } |
329 | 329 |
330 bool CXFA_FFTextEdit::CheckWord(const CFX_ByteStringC& sWord) { | 330 bool CXFA_FFTextEdit::CheckWord(const CFX_ByteStringC& sWord) { |
331 if (sWord.IsEmpty() || m_pDataAcc->GetUIType() != XFA_Element::TextEdit) | 331 if (sWord.IsEmpty() || m_pDataAcc->GetUIType() != XFA_Element::TextEdit) |
332 return true; | 332 return true; |
333 return false; | 333 return false; |
334 } | 334 } |
335 | 335 |
336 void CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) { | 336 void CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) { |
337 m_pOldDelegate->OnProcessMessage(pMessage); | 337 m_pOldDelegate->OnProcessMessage(pMessage); |
338 } | 338 } |
339 | 339 |
340 void CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { | 340 void CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { |
341 CXFA_FFField::OnProcessEvent(pEvent); | 341 CXFA_FFField::OnProcessEvent(pEvent); |
342 switch (pEvent->GetClassID()) { | 342 switch (pEvent->GetClassID()) { |
343 case CFWL_EventType::TextChanged: { | 343 case CFWL_EventType::TextChanged: { |
344 CFWL_EvtTextChanged* event = static_cast<CFWL_EvtTextChanged*>(pEvent); | 344 CFWL_EvtTextChanged* event = static_cast<CFWL_EvtTextChanged*>(pEvent); |
345 CFX_WideString wsChange; | 345 CFX_WideString wsChange; |
346 OnTextChanged(m_pNormalWidget->GetWidget(), wsChange, event->wsPrevText); | 346 OnTextChanged(m_pNormalWidget, wsChange, event->wsPrevText); |
347 break; | 347 break; |
348 } | 348 } |
349 case CFWL_EventType::TextFull: { | 349 case CFWL_EventType::TextFull: { |
350 OnTextFull(m_pNormalWidget->GetWidget()); | 350 OnTextFull(m_pNormalWidget); |
351 break; | 351 break; |
352 } | 352 } |
353 case CFWL_EventType::CheckWord: { | 353 case CFWL_EventType::CheckWord: { |
354 CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged"); | 354 CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged"); |
355 CFWL_EvtCheckWord* event = static_cast<CFWL_EvtCheckWord*>(pEvent); | 355 CFWL_EvtCheckWord* event = static_cast<CFWL_EvtCheckWord*>(pEvent); |
356 event->bCheckWord = CheckWord(event->bsWord.AsStringC()); | 356 event->bCheckWord = CheckWord(event->bsWord.AsStringC()); |
357 break; | 357 break; |
358 } | 358 } |
359 default: | 359 default: |
360 break; | 360 break; |
361 } | 361 } |
362 m_pOldDelegate->OnProcessEvent(pEvent); | 362 m_pOldDelegate->OnProcessEvent(pEvent); |
363 } | 363 } |
364 | 364 |
365 void CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, | 365 void CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, |
366 const CFX_Matrix* pMatrix) { | 366 const CFX_Matrix* pMatrix) { |
367 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); | 367 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); |
368 } | 368 } |
369 | 369 |
370 CXFA_FFNumericEdit::CXFA_FFNumericEdit(CXFA_FFPageView* pPageView, | 370 CXFA_FFNumericEdit::CXFA_FFNumericEdit(CXFA_FFPageView* pPageView, |
371 CXFA_WidgetAcc* pDataAcc) | 371 CXFA_WidgetAcc* pDataAcc) |
372 : CXFA_FFTextEdit(pPageView, pDataAcc) {} | 372 : CXFA_FFTextEdit(pPageView, pDataAcc) {} |
373 CXFA_FFNumericEdit::~CXFA_FFNumericEdit() {} | 373 CXFA_FFNumericEdit::~CXFA_FFNumericEdit() {} |
374 bool CXFA_FFNumericEdit::LoadWidget() { | 374 bool CXFA_FFNumericEdit::LoadWidget() { |
375 CFWL_Edit* pWidget = new CFWL_Edit(GetFWLApp()); | 375 CFWL_Edit* pWidget = new CFWL_Edit( |
376 pWidget->Initialize(); | 376 GetFWLApp(), pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr); |
377 m_pNormalWidget = pWidget; | 377 m_pNormalWidget = pWidget; |
378 | 378 |
379 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); | |
380 m_pNormalWidget->SetLayoutItem(this); | 379 m_pNormalWidget->SetLayoutItem(this); |
381 CFWL_NoteDriver* pNoteDriver = pIWidget->GetOwnerApp()->GetNoteDriver(); | 380 CFWL_NoteDriver* pNoteDriver = |
382 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); | 381 m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); |
| 382 pNoteDriver->RegisterEventTarget(m_pNormalWidget, m_pNormalWidget); |
383 | 383 |
384 m_pOldDelegate = m_pNormalWidget->GetDelegate(); | 384 m_pOldDelegate = m_pNormalWidget->GetDelegate(); |
385 m_pNormalWidget->SetDelegate(this); | 385 m_pNormalWidget->SetDelegate(this); |
386 m_pNormalWidget->LockUpdate(); | 386 m_pNormalWidget->LockUpdate(); |
387 | 387 |
388 CFX_WideString wsText; | 388 CFX_WideString wsText; |
389 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); | 389 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); |
390 pWidget->SetText(wsText); | 390 pWidget->SetText(wsText); |
391 UpdateWidgetProperty(); | 391 UpdateWidgetProperty(); |
392 m_pNormalWidget->UnlockUpdate(); | 392 m_pNormalWidget->UnlockUpdate(); |
(...skipping 21 matching lines...) Expand all Loading... |
414 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || | 414 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || |
415 !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { | 415 !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { |
416 dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; | 416 dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; |
417 } | 417 } |
418 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); | 418 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); |
419 } | 419 } |
420 | 420 |
421 void CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) { | 421 void CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) { |
422 if (pEvent->GetClassID() == CFWL_EventType::Validate) { | 422 if (pEvent->GetClassID() == CFWL_EventType::Validate) { |
423 CFWL_EvtValidate* event = static_cast<CFWL_EvtValidate*>(pEvent); | 423 CFWL_EvtValidate* event = static_cast<CFWL_EvtValidate*>(pEvent); |
424 event->bValidate = | 424 event->bValidate = OnValidate(m_pNormalWidget, event->wsInsert); |
425 OnValidate(m_pNormalWidget->GetWidget(), event->wsInsert); | |
426 return; | 425 return; |
427 } | 426 } |
428 CXFA_FFTextEdit::OnProcessEvent(pEvent); | 427 CXFA_FFTextEdit::OnProcessEvent(pEvent); |
429 } | 428 } |
430 | 429 |
431 bool CXFA_FFNumericEdit::OnValidate(IFWL_Widget* pWidget, | 430 bool CXFA_FFNumericEdit::OnValidate(CFWL_Widget* pWidget, |
432 CFX_WideString& wsText) { | 431 CFX_WideString& wsText) { |
433 CFX_WideString wsPattern; | 432 CFX_WideString wsPattern; |
434 m_pDataAcc->GetPictureContent(wsPattern, XFA_VALUEPICTURE_Edit); | 433 m_pDataAcc->GetPictureContent(wsPattern, XFA_VALUEPICTURE_Edit); |
435 if (!wsPattern.IsEmpty()) { | 434 if (!wsPattern.IsEmpty()) { |
436 return true; | 435 return true; |
437 } | 436 } |
438 int32_t iLeads = 0; | 437 int32_t iLeads = 0; |
439 m_pDataAcc->GetLeadDigits(iLeads); | 438 m_pDataAcc->GetLeadDigits(iLeads); |
440 int32_t iFracs = 0; | 439 int32_t iFracs = 0; |
441 m_pDataAcc->GetFracDigits(iFracs); | 440 m_pDataAcc->GetFracDigits(iFracs); |
442 CFX_WideString wsFormat; | 441 CFX_WideString wsFormat; |
443 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(m_pDataAcc); | 442 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(m_pDataAcc); |
444 widgetValue.GetNumbericFormat(wsFormat, iLeads, iFracs); | 443 widgetValue.GetNumbericFormat(wsFormat, iLeads, iFracs); |
445 return widgetValue.ValidateNumericTemp(wsText, wsFormat, | 444 return widgetValue.ValidateNumericTemp(wsText, wsFormat, |
446 m_pDataAcc->GetLocal()); | 445 m_pDataAcc->GetLocal()); |
447 } | 446 } |
448 CXFA_FFPasswordEdit::CXFA_FFPasswordEdit(CXFA_FFPageView* pPageView, | 447 CXFA_FFPasswordEdit::CXFA_FFPasswordEdit(CXFA_FFPageView* pPageView, |
449 CXFA_WidgetAcc* pDataAcc) | 448 CXFA_WidgetAcc* pDataAcc) |
450 : CXFA_FFTextEdit(pPageView, pDataAcc) {} | 449 : CXFA_FFTextEdit(pPageView, pDataAcc) {} |
451 | 450 |
452 CXFA_FFPasswordEdit::~CXFA_FFPasswordEdit() {} | 451 CXFA_FFPasswordEdit::~CXFA_FFPasswordEdit() {} |
453 | 452 |
454 bool CXFA_FFPasswordEdit::LoadWidget() { | 453 bool CXFA_FFPasswordEdit::LoadWidget() { |
455 CFWL_Edit* pWidget = new CFWL_Edit(GetFWLApp()); | 454 CFWL_Edit* pWidget = new CFWL_Edit( |
456 pWidget->Initialize(); | 455 GetFWLApp(), pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr); |
457 m_pNormalWidget = pWidget; | 456 m_pNormalWidget = pWidget; |
458 m_pNormalWidget->SetLayoutItem(this); | 457 m_pNormalWidget->SetLayoutItem(this); |
459 | 458 |
460 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); | 459 CFWL_NoteDriver* pNoteDriver = |
461 CFWL_NoteDriver* pNoteDriver = pIWidget->GetOwnerApp()->GetNoteDriver(); | 460 m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); |
462 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); | 461 pNoteDriver->RegisterEventTarget(m_pNormalWidget, m_pNormalWidget); |
463 | 462 |
464 m_pOldDelegate = m_pNormalWidget->GetDelegate(); | 463 m_pOldDelegate = m_pNormalWidget->GetDelegate(); |
465 m_pNormalWidget->SetDelegate(this); | 464 m_pNormalWidget->SetDelegate(this); |
466 m_pNormalWidget->LockUpdate(); | 465 m_pNormalWidget->LockUpdate(); |
467 | 466 |
468 CFX_WideString wsText; | 467 CFX_WideString wsText; |
469 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); | 468 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); |
470 pWidget->SetText(wsText); | 469 pWidget->SetText(wsText); |
471 UpdateWidgetProperty(); | 470 UpdateWidgetProperty(); |
472 m_pNormalWidget->UnlockUpdate(); | 471 m_pNormalWidget->UnlockUpdate(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 } | 515 } |
517 CFX_RectF rtWidget; | 516 CFX_RectF rtWidget; |
518 ((CFWL_DateTimePicker*)m_pNormalWidget)->GetBBox(rtWidget); | 517 ((CFWL_DateTimePicker*)m_pNormalWidget)->GetBBox(rtWidget); |
519 if (rtWidget.Contains(fx, fy)) { | 518 if (rtWidget.Contains(fx, fy)) { |
520 return true; | 519 return true; |
521 } | 520 } |
522 return false; | 521 return false; |
523 } | 522 } |
524 bool CXFA_FFDateTimeEdit::LoadWidget() { | 523 bool CXFA_FFDateTimeEdit::LoadWidget() { |
525 CFWL_DateTimePicker* pWidget = new CFWL_DateTimePicker(GetFWLApp()); | 524 CFWL_DateTimePicker* pWidget = new CFWL_DateTimePicker(GetFWLApp()); |
526 pWidget->Initialize(); | |
527 m_pNormalWidget = pWidget; | 525 m_pNormalWidget = pWidget; |
528 m_pNormalWidget->SetLayoutItem(this); | 526 m_pNormalWidget->SetLayoutItem(this); |
529 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); | 527 CFWL_NoteDriver* pNoteDriver = |
530 CFWL_NoteDriver* pNoteDriver = pIWidget->GetOwnerApp()->GetNoteDriver(); | 528 m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); |
531 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); | 529 pNoteDriver->RegisterEventTarget(m_pNormalWidget, m_pNormalWidget); |
532 | 530 |
533 m_pOldDelegate = m_pNormalWidget->GetDelegate(); | 531 m_pOldDelegate = m_pNormalWidget->GetDelegate(); |
534 m_pNormalWidget->SetDelegate(this); | 532 m_pNormalWidget->SetDelegate(this); |
535 m_pNormalWidget->LockUpdate(); | 533 m_pNormalWidget->LockUpdate(); |
536 | 534 |
537 CFX_WideString wsText; | 535 CFX_WideString wsText; |
538 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); | 536 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); |
539 pWidget->SetEditText(wsText); | 537 pWidget->SetEditText(wsText); |
540 if (CXFA_Value value = m_pDataAcc->GetFormValue()) { | 538 if (CXFA_Value value = m_pDataAcc->GetFormValue()) { |
541 switch (value.GetChildValueClassID()) { | 539 switch (value.GetChildValueClassID()) { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 if (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) { | 652 if (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) { |
655 return true; | 653 return true; |
656 } | 654 } |
657 CFX_WideString wsText; | 655 CFX_WideString wsText; |
658 ((CFWL_DateTimePicker*)m_pNormalWidget)->GetEditText(wsText); | 656 ((CFWL_DateTimePicker*)m_pNormalWidget)->GetEditText(wsText); |
659 CFX_WideString wsOldValue; | 657 CFX_WideString wsOldValue; |
660 m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Edit); | 658 m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Edit); |
661 return wsOldValue != wsText; | 659 return wsOldValue != wsText; |
662 } | 660 } |
663 | 661 |
664 void CXFA_FFDateTimeEdit::OnSelectChanged(IFWL_Widget* pWidget, | 662 void CXFA_FFDateTimeEdit::OnSelectChanged(CFWL_Widget* pWidget, |
665 int32_t iYear, | 663 int32_t iYear, |
666 int32_t iMonth, | 664 int32_t iMonth, |
667 int32_t iDay) { | 665 int32_t iDay) { |
668 CFX_WideString wsPicture; | 666 CFX_WideString wsPicture; |
669 m_pDataAcc->GetPictureContent(wsPicture, XFA_VALUEPICTURE_Edit); | 667 m_pDataAcc->GetPictureContent(wsPicture, XFA_VALUEPICTURE_Edit); |
670 CXFA_LocaleValue date(XFA_VT_DATE, GetDoc()->GetXFADoc()->GetLocalMgr()); | 668 CXFA_LocaleValue date(XFA_VT_DATE, GetDoc()->GetXFADoc()->GetLocalMgr()); |
671 CFX_Unitime dt; | 669 CFX_Unitime dt; |
672 dt.Set(iYear, iMonth, iDay); | 670 dt.Set(iYear, iMonth, iDay); |
673 date.SetDate(dt); | 671 date.SetDate(dt); |
674 CFX_WideString wsDate; | 672 CFX_WideString wsDate; |
675 date.FormatPatterns(wsDate, wsPicture, m_pDataAcc->GetLocal(), | 673 date.FormatPatterns(wsDate, wsPicture, m_pDataAcc->GetLocal(), |
676 XFA_VALUEPICTURE_Edit); | 674 XFA_VALUEPICTURE_Edit); |
677 CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)m_pNormalWidget; | 675 CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)m_pNormalWidget; |
678 pDateTime->SetEditText(wsDate); | 676 pDateTime->SetEditText(wsDate); |
679 pDateTime->Update(); | 677 pDateTime->Update(); |
680 GetDoc()->GetDocEnvironment()->SetFocusWidget(GetDoc(), nullptr); | 678 GetDoc()->GetDocEnvironment()->SetFocusWidget(GetDoc(), nullptr); |
681 CXFA_EventParam eParam; | 679 CXFA_EventParam eParam; |
682 eParam.m_eType = XFA_EVENT_Change; | 680 eParam.m_eType = XFA_EVENT_Change; |
683 eParam.m_pTarget = m_pDataAcc; | 681 eParam.m_pTarget = m_pDataAcc; |
684 m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); | 682 m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); |
685 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); | 683 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); |
686 } | 684 } |
687 | 685 |
688 void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { | 686 void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { |
689 if (pEvent->GetClassID() == CFWL_EventType::SelectChanged) { | 687 if (pEvent->GetClassID() == CFWL_EventType::SelectChanged) { |
690 CFWL_EvtSelectChanged* event = static_cast<CFWL_EvtSelectChanged*>(pEvent); | 688 CFWL_EvtSelectChanged* event = static_cast<CFWL_EvtSelectChanged*>(pEvent); |
691 OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth, | 689 OnSelectChanged(m_pNormalWidget, event->iYear, event->iMonth, event->iDay); |
692 event->iDay); | |
693 return; | 690 return; |
694 } | 691 } |
695 CXFA_FFTextEdit::OnProcessEvent(pEvent); | 692 CXFA_FFTextEdit::OnProcessEvent(pEvent); |
696 } | 693 } |
OLD | NEW |